@ghuri/ai-widget 0.1.3 → 0.3.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,47 +1,48 @@
1
- import { t as e } from "./core-B5cGLmtw.js";
2
- import { LitElement as t, css as n, html as r, nothing as i, svg as a } from "lit";
3
- import { unsafeSVG as o } from "lit/directives/unsafe-svg.js";
4
- import { Lexer as s } from "marked";
1
+ import { n as e, t } from "./core-2Z4rCitF.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";
5
6
  // src/ui/format.ts
6
- function c(e) {
7
+ function u(e) {
7
8
  let t = e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-.]+/g, " ").trim().toLowerCase();
8
9
  return t ? t[0].toUpperCase() + t.slice(1) : e;
9
10
  }
10
- function l(e) {
11
- 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(l).join(", ") : JSON.stringify(e);
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);
12
13
  }
13
- function u(e) {
14
+ function f(e) {
14
15
  return Array.isArray(e) && e.length > 0 && e.every((e) => e && typeof e == "object" && !Array.isArray(e));
15
16
  }
16
- function d(e) {
17
+ function p(e) {
17
18
  if (typeof e != "object" || !e || Array.isArray(e)) return e === void 0 ? [] : [{
18
19
  label: "Value",
19
- value: l(e)
20
+ value: d(e)
20
21
  }];
21
22
  let t = [];
22
- for (let [n, r] of Object.entries(e)) if (u(r)) r.forEach((e, r) => {
23
+ for (let [n, r] of Object.entries(e)) if (f(r)) r.forEach((e, r) => {
23
24
  for (let [i, a] of Object.entries(e)) t.push({
24
- label: `${c(n)} ${r + 1} · ${c(i)}`,
25
- value: l(a)
25
+ label: `${u(n)} ${r + 1} · ${u(i)}`,
26
+ value: d(a)
26
27
  });
27
28
  });
28
29
  else if (r && typeof r == "object" && !Array.isArray(r)) {
29
30
  let e = Object.entries(r);
30
31
  e.length || t.push({
31
- label: c(n),
32
+ label: u(n),
32
33
  value: "{}"
33
34
  });
34
35
  for (let [r, i] of e) t.push({
35
- label: `${c(n)} · ${c(r)}`,
36
- value: l(i)
36
+ label: `${u(n)} · ${u(r)}`,
37
+ value: d(i)
37
38
  });
38
39
  } else t.push({
39
- label: c(n),
40
- value: l(r)
40
+ label: u(n),
41
+ value: d(r)
41
42
  });
42
43
  return t;
43
44
  }
44
- function f(e) {
45
+ function m(e) {
45
46
  if (!e || typeof e != "object") return null;
46
47
  let t = e;
47
48
  if (typeof t.count == "number") return t.count;
@@ -54,8 +55,8 @@ function f(e) {
54
55
  return null;
55
56
  }
56
57
  // src/ui/icons.ts
57
- function p(e = 20) {
58
- return a`<svg class="kite" width=${e} height=${e} viewBox="0 0 28 28" aria-hidden="true" focusable="false">
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">
59
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"/>
60
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"/>
61
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"/>
@@ -63,13 +64,14 @@ function p(e = 20) {
63
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"/>
64
65
  </svg>`;
65
66
  }
66
- var m = {
67
+ var g = {
67
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\"/>",
68
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\"/>",
69
70
  x: "<path d=\"M18 6 6 18\"/><path d=\"m6 6 12 12\"/>",
70
71
  check: "<path d=\"M20 6 9 17l-5-5\"/>",
71
72
  loader: "<path d=\"M21 12a9 9 0 1 1-6.22-8.56\"/>",
72
73
  "circle-check": "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"m9 12 2 2 4-4\"/>",
74
+ "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\"/>",
73
75
  "circle-x": "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"m15 9-6 6\"/><path d=\"m9 9 6 6\"/>",
74
76
  "circle-alert": "<circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" x2=\"12\" y1=\"8\" y2=\"12\"/><line x1=\"12\" x2=\"12.01\" y1=\"16\" y2=\"16\"/>",
75
77
  "arrow-up": "<path d=\"m5 12 7-7 7 7\"/><path d=\"M12 19V5\"/>",
@@ -80,14 +82,27 @@ var m = {
80
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\"/>",
81
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\"/>",
82
84
  "chevron-down": "<path d=\"m6 9 6 6 6-6\"/>",
83
- ban: "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"m4.9 4.9 14.2 14.2\"/>"
85
+ ban: "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"m4.9 4.9 14.2 14.2\"/>",
86
+ "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
+ "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\"/>"
84
88
  };
85
- function h(e, t = 16) {
86
- return a`<svg class="icon" width=${t} height=${t} viewBox="0 0 24 24" fill="none" stroke="currentColor"
87
- stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${o(m[e] ?? "")}</svg>`;
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>`;
88
92
  }
89
93
  // src/ui/labels.ts
90
- var g = {
94
+ var v = {
95
+ attachPhoto: "Add photos",
96
+ removePhoto: "Remove photo",
97
+ retryPhoto: "Upload again",
98
+ photoProblem: {
99
+ type: "Not a photo",
100
+ size: "Too large",
101
+ count: "Too many",
102
+ upload: "Upload failed"
103
+ },
104
+ photosLimit: (e, t) => `Up to ${e} photos · ${t} MB each. Location data is removed.`,
105
+ dropPhotos: "Drop photos to add them",
91
106
  placeholder: "Write in Bangla, Banglish or English…",
92
107
  send: "Send",
93
108
  stop: "Stop",
@@ -116,12 +131,21 @@ var g = {
116
131
  running: "Working…",
117
132
  found: (e) => `${e} found`,
118
133
  footer: "Changes always ask you first. AI can make mistakes.",
134
+ footerAllowed: "Changes ask first, except what you allowed. AI can make mistakes.",
119
135
  newMessageCancels: "Sending a new message cancels the waiting change.",
120
136
  leaveWarning: "A reply is still being written. Leave anyway?",
121
137
  tryAgain: "Try again",
122
138
  reload: "Reload",
123
139
  continue: "Continue",
124
140
  continueMessage: "Continue",
141
+ continueSmallerMessage: "Your last reply was too long and got cut off. Continue, doing it in smaller steps.",
142
+ allowChoice: "Confirm and allow for this conversation",
143
+ allowHint: (e, t) => `${e.length > 1 || t ? "Only " : ""}${e.join(", ")} won't ask again in this chat. ${t ? "The other changes still ask." : "Other kinds of changes still ask."}`,
144
+ allowed: "Allowed",
145
+ allowedAt: (e, t) => `Ran without asking: you allowed ${e} at ${t}.`,
146
+ confirmedAllowed: "Confirmed, allowed for this chat",
147
+ allowanceBar: (e) => `${e} runs without asking here`,
148
+ askEveryTime: "Ask every time",
125
149
  newConversation: "New conversation",
126
150
  dismiss: "Dismiss",
127
151
  problems: {
@@ -157,10 +181,26 @@ var g = {
157
181
  title: "The assistant isn't available",
158
182
  text: () => "Check your connection, then try again."
159
183
  },
184
+ "answer-cut": {
185
+ title: "The answer was too long",
186
+ text: () => "It stopped before it finished. Continue to get the rest."
187
+ },
188
+ "step-limit": {
189
+ title: "Paused before finishing",
190
+ text: () => "The assistant took as many steps as one reply can and still has work to do. Continue to let it finish."
191
+ },
192
+ "too-long": {
193
+ title: "The reply was too long",
194
+ text: () => "It was cut off before its last step, so that step was not done. Continue to finish it in smaller steps."
195
+ },
160
196
  "cut-off": {
161
197
  title: "The reply was cut off",
162
198
  text: () => "The connection dropped. Reload the conversation to see what finished."
163
199
  },
200
+ "photos-refused": {
201
+ title: "Photos can't be sent here",
202
+ text: () => "Nothing was sent. Send your message without photos, or upload them in the dashboard."
203
+ },
164
204
  failed: {
165
205
  title: "Something went wrong",
166
206
  text: () => "Please try again."
@@ -168,8 +208,19 @@ var g = {
168
208
  },
169
209
  noConversations: "No conversations yet.",
170
210
  loading: "Loading…"
171
- }, _ = {
172
- ...g,
211
+ }, y = {
212
+ ...v,
213
+ attachPhoto: "ছবি যোগ করুন",
214
+ removePhoto: "ছবি সরান",
215
+ retryPhoto: "আবার আপলোড করুন",
216
+ photoProblem: {
217
+ type: "ছবি নয়",
218
+ size: "খুব বড়",
219
+ count: "অনেক বেশি",
220
+ upload: "আপলোড হয়নি"
221
+ },
222
+ photosLimit: (e, t) => `সর্বোচ্চ ${e}টি ছবি · প্রতিটি ${t} MB। লোকেশনের তথ্য মুছে দেওয়া হয়।`,
223
+ dropPhotos: "ছবি এখানে ছেড়ে দিন",
173
224
  placeholder: "বাংলা, Banglish বা English-এ লিখুন…",
174
225
  send: "পাঠান",
175
226
  stop: "থামান",
@@ -181,9 +232,9 @@ var g = {
181
232
  emptyTitle: "কী সাহায্য করতে পারি?",
182
233
  confirm: "নিশ্চিত করুন",
183
234
  cancel: "বাতিল",
184
- confirmN: (e) => `${y(e)}টি নিশ্চিত করুন`,
235
+ confirmN: (e) => `${x(e)}টি নিশ্চিত করুন`,
185
236
  cancelAll: "সব বাতিল",
186
- changes: (e) => `${y(e)}টি পরিবর্তন`,
237
+ changes: (e) => `${x(e)}টি পরিবর্তন`,
187
238
  needsOk: "আপনার অনুমতি দরকার",
188
239
  exactValues: "ঠিক যা পাঠানো হবে",
189
240
  unticked: "টিক না থাকলে বাতিল",
@@ -194,16 +245,25 @@ var g = {
194
245
  outcomeUnknown: "ফলাফল জানা নেই",
195
246
  stepFailed: "হয়নি",
196
247
  now: "এখন",
197
- lines: (e) => `${y(e)} লাইন`,
248
+ lines: (e) => `${x(e)} লাইন`,
198
249
  running: "কাজ চলছে…",
199
- found: (e) => `${y(e)}টি পাওয়া গেছে`,
250
+ found: (e) => `${x(e)}টি পাওয়া গেছে`,
200
251
  footer: "যেকোনো পরিবর্তনের আগে আপনার অনুমতি নেওয়া হয়। AI ভুল করতে পারে।",
252
+ footerAllowed: "উপরে যেগুলোর অনুমতি দিয়েছেন সেগুলো ছাড়া, পরিবর্তনের আগে অনুমতি নেওয়া হয়। AI ভুল করতে পারে।",
201
253
  newMessageCancels: "নতুন মেসেজ পাঠালে অপেক্ষমাণ পরিবর্তন বাতিল হবে।",
202
254
  leaveWarning: "উত্তর এখনো লেখা হচ্ছে। তবুও চলে যাবেন?",
203
255
  tryAgain: "আবার চেষ্টা করুন",
204
256
  reload: "আবার লোড করুন",
205
257
  continue: "চালিয়ে যান",
206
258
  continueMessage: "চালিয়ে যাও",
259
+ continueSmallerMessage: "তোমার আগের উত্তর বেশি লম্বা হয়ে মাঝপথে কেটে গেছে। ছোট ছোট ধাপে চালিয়ে যাও।",
260
+ allowChoice: "নিশ্চিত করুন, এই কথোপকথনে অনুমতি দিন",
261
+ allowHint: (e, t) => `${e.length > 1 || t ? "শুধু " : ""}${e.map((e) => `"${e}"`).join(", ")} এই চ্যাটে আর জিজ্ঞেস করবে না। ${t ? "বাকি পরিবর্তনগুলো সবসময় জিজ্ঞেস করবে।" : "অন্য ধরনের পরিবর্তন আগের মতোই জিজ্ঞেস করবে।"}`,
262
+ allowed: "অনুমতি আছে",
263
+ allowedAt: (e, t) => `জিজ্ঞেস না করে চলেছে: ${t}-এ আপনি "${e}"-এর অনুমতি দিয়েছিলেন।`,
264
+ confirmedAllowed: "নিশ্চিত, এই চ্যাটে অনুমতি দেওয়া",
265
+ allowanceBar: (e) => `"${e}" এখানে জিজ্ঞেস না করে চলবে`,
266
+ askEveryTime: "প্রতিবার জিজ্ঞেস করুন",
207
267
  newConversation: "নতুন কথোপকথন",
208
268
  dismiss: "ঠিক আছে",
209
269
  problems: {
@@ -225,7 +285,7 @@ var g = {
225
285
  },
226
286
  throttled: {
227
287
  title: "অনেক বেশি মেসেজ",
228
- text: (e) => e ? `আরেকটি পাঠানোর আগে ${y(e)} সেকেন্ড অপেক্ষা করুন।` : "আরেকটি পাঠানোর আগে একটু অপেক্ষা করুন।"
288
+ text: (e) => e ? `আরেকটি পাঠানোর আগে ${x(e)} সেকেন্ড অপেক্ষা করুন।` : "আরেকটি পাঠানোর আগে একটু অপেক্ষা করুন।"
229
289
  },
230
290
  forbidden: {
231
291
  title: "অনুমতি নেই",
@@ -239,10 +299,26 @@ var g = {
239
299
  title: "অ্যাসিস্ট্যান্ট এখন পাওয়া যাচ্ছে না",
240
300
  text: () => "ইন্টারনেট সংযোগ দেখে আবার চেষ্টা করুন।"
241
301
  },
302
+ "answer-cut": {
303
+ title: "উত্তর বেশি লম্বা হয়ে গেছে",
304
+ text: () => "শেষ হওয়ার আগেই থেমে গেছে। বাকিটা পেতে চালিয়ে যান।"
305
+ },
306
+ "step-limit": {
307
+ title: "শেষ হওয়ার আগে থেমেছে",
308
+ text: () => "একটি উত্তরে যত ধাপ নেওয়া যায় তা শেষ, কিন্তু কাজ এখনো বাকি। শেষ করতে চালিয়ে যান।"
309
+ },
310
+ "too-long": {
311
+ title: "উত্তর বেশি লম্বা হয়ে গেছে",
312
+ text: () => "শেষ ধাপের আগেই উত্তর কেটে গেছে, তাই সেই ধাপটি করা হয়নি। ছোট ছোট ধাপে শেষ করতে চালিয়ে যান।"
313
+ },
242
314
  "cut-off": {
243
315
  title: "উত্তর মাঝপথে থেমে গেছে",
244
316
  text: () => "সংযোগ বিচ্ছিন্ন হয়েছিল। কী শেষ হয়েছে দেখতে আবার লোড করুন।"
245
317
  },
318
+ "photos-refused": {
319
+ title: "এখানে ছবি পাঠানো যাচ্ছে না",
320
+ text: () => "কিছুই পাঠানো হয়নি। ছবি ছাড়া মেসেজ পাঠান, বা ড্যাশবোর্ডে ছবি আপলোড করুন।"
321
+ },
246
322
  failed: {
247
323
  title: "কিছু একটা ভুল হয়েছে",
248
324
  text: () => "আবার চেষ্টা করুন।"
@@ -250,12 +326,12 @@ var g = {
250
326
  },
251
327
  noConversations: "এখনো কোনো কথোপকথন নেই।",
252
328
  loading: "লোড হচ্ছে…"
253
- }, v = "০১২৩৪৫৬৭৮৯";
254
- function y(e) {
255
- return String(e).replace(/\d/g, (e) => v[Number(e)]);
329
+ }, b = "০১২৩৪৫৬৭৮৯";
330
+ function x(e) {
331
+ return String(e).replace(/\d/g, (e) => b[Number(e)]);
256
332
  }
257
- function b(e, t = {}) {
258
- let n = (e ?? "").toLowerCase().startsWith("bn") ? _ : g;
333
+ function S(e, t = {}) {
334
+ let n = (e ?? "").toLowerCase().startsWith("bn") ? y : v;
259
335
  return {
260
336
  ...n,
261
337
  ...t,
@@ -266,89 +342,89 @@ function b(e, t = {}) {
266
342
  };
267
343
  }
268
344
  // src/ui/markdown.ts
269
- var x = /^(https?:|mailto:)/i;
270
- function S(e) {
345
+ var C = /^(https?:|mailto:)/i;
346
+ function w(e) {
271
347
  let t = e.trim();
272
- return x.test(t) ? t : null;
348
+ return C.test(t) ? t : null;
273
349
  }
274
- function C(e) {
275
- return (e ?? []).map((e) => w(e));
350
+ function T(e) {
351
+ return (e ?? []).map((e) => E(e));
276
352
  }
277
- function w(e) {
353
+ function E(e) {
278
354
  switch (e.type) {
279
- case "strong": return r`<strong>${C(e.tokens)}</strong>`;
280
- case "em": return r`<em>${C(e.tokens)}</em>`;
281
- case "del": return r`<del>${C(e.tokens)}</del>`;
282
- case "codespan": return r`<code>${e.text}</code>`;
283
- case "br": return r`<br />`;
355
+ case "strong": return i`<strong>${T(e.tokens)}</strong>`;
356
+ case "em": return i`<em>${T(e.tokens)}</em>`;
357
+ case "del": return i`<del>${T(e.tokens)}</del>`;
358
+ case "codespan": return i`<code>${e.text}</code>`;
359
+ case "br": return i`<br />`;
284
360
  case "link": {
285
- let t = e, n = S(t.href);
286
- return n ? r`<a href=${n} target="_blank" rel="noopener noreferrer nofollow">${C(t.tokens)}</a>` : r`${C(t.tokens)}`;
361
+ let t = e, n = w(t.href);
362
+ return n ? i`<a href=${n} target="_blank" rel="noopener noreferrer nofollow">${T(t.tokens)}</a>` : i`${T(t.tokens)}`;
287
363
  }
288
364
  case "image": return e.text || "";
289
365
  case "text": {
290
366
  let t = e;
291
- return t.tokens ? r`${C(t.tokens)}` : T(t.text);
367
+ return t.tokens ? i`${T(t.tokens)}` : D(t.text);
292
368
  }
293
369
  case "escape": return e.text;
294
370
  case "html": return e.raw;
295
371
  default: return "raw" in e ? String(e.raw) : "";
296
372
  }
297
373
  }
298
- function T(e) {
374
+ function D(e) {
299
375
  return e.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&#39;/g, "'").replace(/&amp;/g, "&");
300
376
  }
301
- function E(e) {
377
+ function O(e) {
302
378
  switch (e.type) {
303
- case "paragraph": return r`<p>${C(e.tokens)}</p>`;
304
- case "heading": return r`<p class="heading">${C(e.tokens)}</p>`;
379
+ case "paragraph": return i`<p>${T(e.tokens)}</p>`;
380
+ case "heading": return i`<p class="heading">${T(e.tokens)}</p>`;
305
381
  case "list": {
306
- let t = e, n = t.items.map((e) => r`<li>${e.tokens.map(D)}</li>`);
307
- return t.ordered ? r`<ol start=${typeof t.start == "number" ? t.start : 1}>${n}</ol>` : r`<ul>${n}</ul>`;
382
+ let t = e, n = t.items.map((e) => i`<li>${e.tokens.map(k)}</li>`);
383
+ return t.ordered ? i`<ol start=${typeof t.start == "number" ? t.start : 1}>${n}</ol>` : i`<ul>${n}</ul>`;
308
384
  }
309
385
  case "table": {
310
386
  let t = e;
311
- return r`<div class="table-wrap">
387
+ return i`<div class="table-wrap">
312
388
  <table>
313
389
  <thead>
314
390
  <tr>
315
- ${t.header.map((e) => r`<th>${C(e.tokens)}</th>`)}
391
+ ${t.header.map((e) => i`<th>${T(e.tokens)}</th>`)}
316
392
  </tr>
317
393
  </thead>
318
394
  <tbody>
319
- ${t.rows.map((e) => r`<tr>${e.map((e) => r`<td>${C(e.tokens)}</td>`)}</tr>`)}
395
+ ${t.rows.map((e) => i`<tr>${e.map((e) => i`<td>${T(e.tokens)}</td>`)}</tr>`)}
320
396
  </tbody>
321
397
  </table>
322
398
  </div>`;
323
399
  }
324
- case "code": return r`<pre><code>${e.text}</code></pre>`;
325
- case "blockquote": return r`<blockquote>${e.tokens.map(E)}</blockquote>`;
326
- case "hr": return r`<hr />`;
327
- case "html": return r`<p>${e.raw}</p>`;
400
+ case "code": return i`<pre><code>${e.text}</code></pre>`;
401
+ case "blockquote": return i`<blockquote>${e.tokens.map(O)}</blockquote>`;
402
+ case "hr": return i`<hr />`;
403
+ case "html": return i`<p>${e.raw}</p>`;
328
404
  case "text": {
329
405
  let t = e;
330
- return r`<p>${t.tokens ? C(t.tokens) : T(t.text)}</p>`;
406
+ return i`<p>${t.tokens ? T(t.tokens) : D(t.text)}</p>`;
331
407
  }
332
- case "space": return i;
333
- default: return "raw" in e ? r`<p>${String(e.raw)}</p>` : i;
408
+ case "space": return a;
409
+ default: return "raw" in e ? i`<p>${String(e.raw)}</p>` : a;
334
410
  }
335
411
  }
336
- function D(e) {
412
+ function k(e) {
337
413
  if (e.type === "text") {
338
414
  let t = e;
339
- return t.tokens ? r`${C(t.tokens)}` : T(t.text);
415
+ return t.tokens ? i`${T(t.tokens)}` : D(t.text);
340
416
  }
341
- return E(e);
417
+ return O(e);
342
418
  }
343
- function O(e) {
344
- let t = s.lex(e, {
419
+ function A(e) {
420
+ let t = l.lex(e, {
345
421
  gfm: !0,
346
422
  breaks: !0
347
423
  });
348
- return r`${t.map(E)}`;
424
+ return i`${t.map(O)}`;
349
425
  }
350
426
  // src/ui/styles.ts
351
- var k = n`
427
+ var j = r`
352
428
  :host {
353
429
  --_accent: var(--ghuri-accent, #8e1b2b);
354
430
  --_accent-text: var(--ghuri-accent-text, #ffffff);
@@ -366,6 +442,8 @@ var k = n`
366
442
  --_warning-soft: var(--ghuri-warning-soft, #fffbeb);
367
443
  --_danger: var(--ghuri-danger, #dc2626);
368
444
  --_danger-soft: var(--ghuri-danger-soft, #fef2f2);
445
+ --_allowed: var(--ghuri-allowed, #0e8a5f);
446
+ --_allowed-soft: var(--ghuri-allowed-soft, #ecf8f2);
369
447
  --_radius: var(--ghuri-radius, 12px);
370
448
  --_radius-sm: var(--ghuri-radius-sm, 8px);
371
449
  --_bubble-radius: var(--ghuri-bubble-radius, 14px);
@@ -694,6 +772,118 @@ var k = n`
694
772
  color: var(--_warning);
695
773
  }
696
774
 
775
+ /* --- "Allow for this conversation" --- */
776
+ .allow-choice {
777
+ display: flex;
778
+ flex-direction: column;
779
+ align-items: flex-start;
780
+ gap: 3px;
781
+ width: 100%;
782
+ padding: 8px 12px;
783
+ border: 1px solid var(--_border);
784
+ border-radius: var(--_radius-sm);
785
+ background: var(--_background);
786
+ color: var(--_text);
787
+ font: inherit;
788
+ text-align: left;
789
+ cursor: pointer;
790
+ }
791
+ .allow-choice:hover {
792
+ border-color: var(--_allowed);
793
+ }
794
+ .allow-choice:focus-visible {
795
+ outline: 2px solid var(--_allowed);
796
+ outline-offset: 2px;
797
+ }
798
+ .allow-head {
799
+ display: inline-flex;
800
+ align-items: center;
801
+ gap: 8px;
802
+ font-size: 13px;
803
+ font-weight: 500;
804
+ }
805
+ .allow-head svg {
806
+ color: var(--_allowed);
807
+ }
808
+ .allow-hint {
809
+ font-size: 12px;
810
+ line-height: 1.4;
811
+ color: var(--_muted);
812
+ }
813
+ .allowed {
814
+ display: flex;
815
+ flex-direction: column;
816
+ gap: 6px;
817
+ padding: 8px 10px;
818
+ border: 1px solid var(--_border);
819
+ border-radius: var(--_radius-sm);
820
+ font-size: 12px;
821
+ }
822
+ .allowed-head {
823
+ display: flex;
824
+ align-items: center;
825
+ justify-content: space-between;
826
+ gap: 8px;
827
+ }
828
+ .allowed-head .what {
829
+ display: inline-flex;
830
+ align-items: center;
831
+ gap: 6px;
832
+ font-weight: 500;
833
+ color: var(--_text);
834
+ }
835
+ .allowed .ok {
836
+ color: var(--_success);
837
+ }
838
+ .allowed .bad {
839
+ color: var(--_danger);
840
+ }
841
+ .allowed-tag,
842
+ .allowance {
843
+ background: var(--_allowed-soft);
844
+ }
845
+ .allowed-tag {
846
+ display: inline-flex;
847
+ align-items: center;
848
+ gap: 4px;
849
+ padding: 2px 6px;
850
+ border-radius: 999px;
851
+ color: var(--_allowed);
852
+ font-size: 11px;
853
+ font-weight: 500;
854
+ }
855
+ .allowed .preview {
856
+ margin: 0;
857
+ }
858
+ .allowed-by {
859
+ font-size: 11px;
860
+ color: var(--_muted);
861
+ }
862
+ .allowances {
863
+ display: flex;
864
+ flex-direction: column;
865
+ gap: 6px;
866
+ margin-bottom: 8px;
867
+ }
868
+ .allowance {
869
+ display: flex;
870
+ align-items: center;
871
+ justify-content: space-between;
872
+ gap: 8px;
873
+ padding: 6px 10px;
874
+ border-radius: var(--_radius-sm);
875
+ font-size: 12px;
876
+ }
877
+ .allowance-text {
878
+ display: inline-flex;
879
+ align-items: center;
880
+ gap: 6px;
881
+ }
882
+ .allowance-text svg {
883
+ color: var(--_allowed);
884
+ flex: none;
885
+ }
886
+
697
887
  /* --- confirm card --- */
698
888
  .confirm {
699
889
  border: 1px solid var(--_accent-border);
@@ -962,6 +1152,149 @@ var k = n`
962
1152
  background: var(--_accent);
963
1153
  color: var(--_accent-text);
964
1154
  }
1155
+ .attach {
1156
+ flex: none;
1157
+ display: grid;
1158
+ place-items: center;
1159
+ width: 32px;
1160
+ height: 32px;
1161
+ border-radius: var(--_radius-sm);
1162
+ color: var(--_muted);
1163
+ }
1164
+ .attach:hover:not(:disabled) {
1165
+ background: var(--_muted-surface);
1166
+ color: var(--_text);
1167
+ }
1168
+ .composer[data-dragging] .box {
1169
+ border-color: var(--_accent);
1170
+ border-style: dashed;
1171
+ }
1172
+ .drop-note,
1173
+ .chips-note {
1174
+ margin: 0 0 6px;
1175
+ font-size: 11px;
1176
+ color: var(--_muted);
1177
+ }
1178
+ .chips {
1179
+ display: flex;
1180
+ flex-wrap: wrap;
1181
+ gap: 8px;
1182
+ margin-bottom: 6px;
1183
+ }
1184
+ .chip {
1185
+ position: relative;
1186
+ display: grid;
1187
+ place-items: center;
1188
+ width: 64px;
1189
+ height: 64px;
1190
+ border-radius: var(--_radius-sm);
1191
+ background: var(--_muted-surface);
1192
+ overflow: hidden;
1193
+ }
1194
+ .chip img {
1195
+ width: 100%;
1196
+ height: 100%;
1197
+ object-fit: cover;
1198
+ }
1199
+ .chip[data-status='preparing'] img,
1200
+ .chip[data-status='uploading'] img {
1201
+ opacity: 0.6;
1202
+ }
1203
+ .chip[data-status='failed'] {
1204
+ background: var(--_danger-soft);
1205
+ color: var(--_danger);
1206
+ outline: 1px solid color-mix(in oklab, var(--_danger) 40%, transparent);
1207
+ }
1208
+ .chip[data-status='failed'] img {
1209
+ opacity: 0.35;
1210
+ }
1211
+ .chip-icon {
1212
+ display: grid;
1213
+ place-items: center;
1214
+ }
1215
+ .chip-progress {
1216
+ position: absolute;
1217
+ left: 6px;
1218
+ right: 6px;
1219
+ bottom: 6px;
1220
+ height: 4px;
1221
+ border-radius: 2px;
1222
+ background: rgb(255 255 255 / 0.7);
1223
+ }
1224
+ .chip-progress span {
1225
+ display: block;
1226
+ height: 100%;
1227
+ border-radius: 2px;
1228
+ background: var(--_text);
1229
+ transition: width 0.2s;
1230
+ }
1231
+ .chip-error {
1232
+ position: absolute;
1233
+ left: 0;
1234
+ right: 0;
1235
+ bottom: 4px;
1236
+ font-size: 10px;
1237
+ text-align: center;
1238
+ }
1239
+ .chip-remove,
1240
+ .chip-retry {
1241
+ position: absolute;
1242
+ top: 4px;
1243
+ display: grid;
1244
+ place-items: center;
1245
+ width: 18px;
1246
+ height: 18px;
1247
+ border-radius: 999px;
1248
+ background: rgb(24 24 27 / 0.8);
1249
+ color: #fff;
1250
+ }
1251
+ .chip-remove {
1252
+ right: 4px;
1253
+ }
1254
+ .chip-retry {
1255
+ left: 4px;
1256
+ }
1257
+ .photos {
1258
+ align-self: flex-end;
1259
+ display: flex;
1260
+ flex-wrap: wrap;
1261
+ justify-content: flex-end;
1262
+ gap: 6px;
1263
+ max-width: 85%;
1264
+ margin-bottom: -10px;
1265
+ }
1266
+ .photo {
1267
+ display: block;
1268
+ width: 96px;
1269
+ height: 120px;
1270
+ border-radius: var(--_radius);
1271
+ overflow: hidden;
1272
+ background: var(--_muted-surface);
1273
+ }
1274
+ .photo img {
1275
+ width: 100%;
1276
+ height: 100%;
1277
+ object-fit: cover;
1278
+ }
1279
+ .photo .photo-name {
1280
+ display: none;
1281
+ }
1282
+ .photo[data-broken] img {
1283
+ display: none;
1284
+ }
1285
+ .photo[data-broken] .photo-name {
1286
+ display: flex;
1287
+ flex-direction: column;
1288
+ align-items: center;
1289
+ justify-content: center;
1290
+ gap: 4px;
1291
+ height: 100%;
1292
+ padding: 6px;
1293
+ font-size: 11px;
1294
+ color: var(--_muted);
1295
+ text-align: center;
1296
+ overflow-wrap: anywhere;
1297
+ }
965
1298
  .stop {
966
1299
  flex: none;
967
1300
  display: inline-flex;
@@ -1103,8 +1436,8 @@ var k = n`
1103
1436
  font-weight: 500;
1104
1437
  min-height: 48px;
1105
1438
  }
1106
- `, A = "result was not recorded", j = class extends t {
1107
- static styles = k;
1439
+ `, M = "result was not recorded", N = class extends n {
1440
+ static styles = j;
1108
1441
  static properties = {
1109
1442
  layout: {
1110
1443
  type: String,
@@ -1122,7 +1455,8 @@ var k = n`
1122
1455
  conversations: { state: !0 },
1123
1456
  draft: { state: !0 },
1124
1457
  expanded: { state: !0 },
1125
- unticked: { state: !0 }
1458
+ unticked: { state: !0 },
1459
+ dragging: { state: !0 }
1126
1460
  };
1127
1461
  chat = null;
1128
1462
  options = null;
@@ -1145,8 +1479,9 @@ var k = n`
1145
1479
  }), ...[
1146
1480
  "tool-result",
1147
1481
  "approval-pending",
1148
- "turn-end"
1149
- ].map((e) => n.on(e, (t) => this.fire(e, t)))], this.layout === "page" && this.loadConversations();
1482
+ "turn-end",
1483
+ "attachment-error"
1484
+ ].map((e) => n.on(e, (t) => this.fire(e, t)))], this.layout === "page" && this.loadConversations(), (this.open || this.layout === "page") && n.loadCapabilities();
1150
1485
  }
1151
1486
  setOptions(e) {
1152
1487
  if (this.options) {
@@ -1162,7 +1497,7 @@ var k = n`
1162
1497
  return this.chat;
1163
1498
  }
1164
1499
  show() {
1165
- this.open || (this.open = !0, this.fire("open", {}), this.updateComplete.then(() => this.focusInput()));
1500
+ this.open || (this.open = !0, this.chat?.loadCapabilities(), this.fire("open", {}), this.updateComplete.then(() => this.focusInput()));
1166
1501
  }
1167
1502
  hide() {
1168
1503
  this.open && (this.open = !1, this.fire("close", {}));
@@ -1192,7 +1527,7 @@ var k = n`
1192
1527
  this.unsubscribe = [];
1193
1528
  }
1194
1529
  get labels() {
1195
- return b(this.locale || this.options?.locale || document.documentElement.lang || "en", this.options?.labels);
1530
+ return S(this.locale || this.options?.locale || document.documentElement.lang || "en", this.options?.labels);
1196
1531
  }
1197
1532
  fire(e, t) {
1198
1533
  this.dispatchEvent(new CustomEvent(`ghuri:${e}`, {
@@ -1229,10 +1564,14 @@ var k = n`
1229
1564
  }
1230
1565
  async submit() {
1231
1566
  let e = this.draft.trim(), t = this.state?.status;
1232
- if (!e || !this.chat || t === "sending" || t === "streaming") return;
1567
+ if (!this.canSend() || !this.chat || t === "sending" || t === "streaming") return;
1233
1568
  this.draft = "", this.stickToBottom = !0;
1234
1569
  let n = !this.state?.conversationId;
1235
- await this.chat.send(e), n && this.layout === "page" && this.loadConversations();
1570
+ await this.chat.send(e), this.chat?.getState().problem?.code === "photos-refused" && !this.draft && (this.draft = e), n && this.layout === "page" && this.loadConversations();
1571
+ }
1572
+ canSend() {
1573
+ let e = this.state?.uploads ?? [];
1574
+ 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");
1236
1575
  }
1237
1576
  onKeydown(e) {
1238
1577
  e.key !== "Enter" || e.shiftKey || e.isComposing || e.keyCode === 229 || (e.preventDefault(), this.submit());
@@ -1249,28 +1588,41 @@ var k = n`
1249
1588
  let n = new Set(this.unticked);
1250
1589
  t ? n.delete(e) : n.add(e), this.unticked = n;
1251
1590
  }
1252
- async decideAll(e) {
1253
- let t = this.state?.pendingApprovals ?? [];
1254
- this.chat && t.length && (await this.chat.decide(t.map((t) => ({
1255
- approvalId: t.approvalId,
1256
- approved: e && !this.unticked.has(t.approvalId)
1257
- }))), this.unticked = /* @__PURE__ */ new Set());
1591
+ async decideAll(e, t = !1) {
1592
+ let n = this.state?.pendingApprovals ?? [];
1593
+ this.chat && n.length && (await this.chat.decide(n.map((n) => {
1594
+ let r = e && !this.unticked.has(n.approvalId);
1595
+ return {
1596
+ approvalId: n.approvalId,
1597
+ approved: r,
1598
+ ...r && t && n.allowable ? { allowForConversation: !0 } : {}
1599
+ };
1600
+ })), this.unticked = /* @__PURE__ */ new Set());
1601
+ }
1602
+ renderAllowChoice(e) {
1603
+ let t = e.filter((e) => e.allowable);
1604
+ if (!t.length) return a;
1605
+ let n = this.labels, r = [...new Set(t.map((e) => this.toolLabel(e)))];
1606
+ return i`<button class="allow-choice" part="button-allow" @click=${() => this.decideAll(!0, !0)}>
1607
+ <span class="allow-head">${_("shield-check", 15)} ${n.allowChoice}</span>
1608
+ <span class="allow-hint">${n.allowHint(r, t.length < e.length)}</span>
1609
+ </button>`;
1258
1610
  }
1259
1611
  async showHistory() {
1260
1612
  this.view = this.view === "history" ? "chat" : "history", this.view === "history" && await this.loadConversations();
1261
1613
  }
1262
1614
  wanted = /* @__PURE__ */ new Map();
1263
1615
  cardSlot(e, t, n) {
1264
- let i = this.cards.get(e);
1265
- if (!i) {
1616
+ let r = this.cards.get(e);
1617
+ if (!r) {
1266
1618
  let t = document.createElement("div");
1267
- t.slot = `ghuri-card-${++this.cardSeq}`, t.dataset.ghuriCard = e, this.appendChild(t), i = { container: t }, this.cards.set(e, i);
1619
+ t.slot = `ghuri-card-${++this.cardSeq}`, t.dataset.ghuriCard = e, this.appendChild(t), r = { container: t }, this.cards.set(e, r);
1268
1620
  }
1269
1621
  return this.wanted.set(e, {
1270
- slot: i.container.slot,
1622
+ slot: r.container.slot,
1271
1623
  ctx: t,
1272
1624
  render: n
1273
- }), r`<slot name=${i.container.slot}></slot>`;
1625
+ }), i`<slot name=${r.container.slot}></slot>`;
1274
1626
  }
1275
1627
  mountCards() {
1276
1628
  for (let [e, t] of this.cards) {
@@ -1287,7 +1639,7 @@ var k = n`
1287
1639
  }
1288
1640
  }
1289
1641
  render() {
1290
- return this.wanted = /* @__PURE__ */ new Map(), this.layout === "page" ? r`<div class="page">
1642
+ return this.wanted = /* @__PURE__ */ new Map(), this.layout === "page" ? i`<div class="page">
1291
1643
  <aside class="sidebar" part="history">${this.renderSidebar()}</aside>
1292
1644
  <section class="main">
1293
1645
  <div class="page-head" part="header">
@@ -1296,8 +1648,8 @@ var k = n`
1296
1648
  </div>
1297
1649
  ${this.renderScroll()} ${this.renderBottom()}
1298
1650
  </section>
1299
- </div>` : r`${this.renderHeader()}
1300
- ${this.view === "history" ? this.renderPanelHistory() : r`${this.renderScroll()} ${this.renderBottom()}`}`;
1651
+ </div>` : i`${this.renderHeader()}
1652
+ ${this.view === "history" ? this.renderPanelHistory() : i`${this.renderScroll()} ${this.renderBottom()}`}`;
1301
1653
  }
1302
1654
  currentTitle() {
1303
1655
  let e = this.state?.conversationId;
@@ -1305,37 +1657,37 @@ var k = n`
1305
1657
  }
1306
1658
  renderHeader() {
1307
1659
  let e = this.labels;
1308
- return r`<header class="header" part="header">
1660
+ return i`<header class="header" part="header">
1309
1661
  <div class="brand">
1310
- <span class="avatar">${p(20)}</span>
1662
+ <span class="avatar">${h(20)}</span>
1311
1663
  <span class="names">
1312
1664
  <span class="title" part="title">${this.heading || "Ghuri AI"}</span>
1313
- ${this.subtitle ? r`<span class="subtitle">${this.subtitle}</span>` : i}
1665
+ ${this.subtitle ? i`<span class="subtitle">${this.subtitle}</span>` : a}
1314
1666
  </span>
1315
1667
  </div>
1316
1668
  <div class="tools">
1317
1669
  <button class="icon-button" title=${e.history} aria-label=${e.history} @click=${() => this.showHistory()}>
1318
- ${h("history")}
1670
+ ${_("history")}
1319
1671
  </button>
1320
1672
  <button class="icon-button" title=${e.newChat} aria-label=${e.newChat} @click=${() => this.newConversation()}>
1321
- ${h("square-pen")}
1673
+ ${_("square-pen")}
1322
1674
  </button>
1323
1675
  <button class="icon-button" title=${e.close} aria-label=${e.close} @click=${() => this.hide()}>
1324
- ${h("x")}
1676
+ ${_("x")}
1325
1677
  </button>
1326
1678
  </div>
1327
1679
  </header>`;
1328
1680
  }
1329
1681
  renderConversationList() {
1330
1682
  let e = this.labels;
1331
- if (this.conversations === null) return r`<div class="muted">${e.loading}</div>`;
1332
- if (!this.conversations.length) return r`<div class="muted">${e.noConversations}</div>`;
1683
+ if (this.conversations === null) return i`<div class="muted">${e.loading}</div>`;
1684
+ if (!this.conversations.length) return i`<div class="muted">${e.noConversations}</div>`;
1333
1685
  let t = new Intl.DateTimeFormat(this.locale || void 0, {
1334
1686
  dateStyle: "medium",
1335
1687
  timeStyle: "short"
1336
1688
  });
1337
- return r`<nav class="history" aria-label=${e.conversations}>
1338
- ${this.conversations.map((e) => r`<button
1689
+ return i`<nav class="history" aria-label=${e.conversations}>
1690
+ ${this.conversations.map((e) => i`<button
1339
1691
  class="conversation"
1340
1692
  aria-current=${e.id === this.state?.conversationId ? "true" : "false"}
1341
1693
  @click=${() => this.openConversation(e.id)}
@@ -1347,7 +1699,7 @@ var k = n`
1347
1699
  }
1348
1700
  renderPanelHistory() {
1349
1701
  let e = this.labels;
1350
- return r`<div class="scroll">
1702
+ return i`<div class="scroll">
1351
1703
  <div class="history-head">
1352
1704
  <span>${e.conversations}</span>
1353
1705
  <button class="btn primary" @click=${() => this.newConversation()}>${e.newChat}</button>
@@ -1357,56 +1709,107 @@ var k = n`
1357
1709
  }
1358
1710
  renderSidebar() {
1359
1711
  let e = this.labels;
1360
- return r`<div class="side-brand">${p(24)}<span>${this.heading || "Ghuri AI"}</span></div>
1361
- <button class="new-chat" @click=${() => this.newConversation()}>${h("square-pen", 15)} ${e.newChat}</button>
1712
+ return i`<div class="side-brand">${h(24)}<span>${this.heading || "Ghuri AI"}</span></div>
1713
+ <button class="new-chat" @click=${() => this.newConversation()}>${_("square-pen", 15)} ${e.newChat}</button>
1362
1714
  ${this.renderConversationList()}`;
1363
1715
  }
1364
1716
  renderScroll() {
1365
- let e = this.state, t = e?.messages ?? [], n = e?.status === "loading" ? r`<div class="muted">${this.labels.loading}</div>` : t.length ? r`${t.map((e, n) => this.renderMessage(e, n === t.length - 1))}
1717
+ 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))}
1366
1718
  ${this.renderPending()}` : this.renderEmpty();
1367
- return r`<div class="scroll">
1719
+ return i`<div class="scroll">
1368
1720
  <div class="messages column" role="log" aria-live="polite" aria-busy=${e?.status === "streaming"}>${n}</div>
1369
1721
  </div>`;
1370
1722
  }
1371
1723
  renderEmpty() {
1372
1724
  let e = this.labels, t = this.options?.starters ?? [];
1373
- return r`<div class="empty" part="empty">
1374
- <span class="avatar">${p(24)}</span>
1725
+ return i`<div class="empty" part="empty">
1726
+ <span class="avatar">${h(24)}</span>
1375
1727
  <span class="heading">${e.emptyTitle}</span>
1376
- ${t.length ? r`<div class="starters">
1377
- ${t.map((e) => r`<button class="starter" part="starter" @click=${() => this.chat?.send(e)}>${e}</button>`)}
1378
- </div>` : i}
1728
+ ${t.length ? i`<div class="starters">
1729
+ ${t.map((e) => i`<button class="starter" part="starter" @click=${() => this.chat?.send(e)}>${e}</button>`)}
1730
+ </div>` : a}
1379
1731
  </div>`;
1380
1732
  }
1381
1733
  renderMessage(e, t) {
1382
1734
  if (e.role === "user") {
1383
- let t = e.parts.map((e) => e.kind === "text" ? e.text : "").join("");
1384
- return r`<div class="user" part="user-bubble">${t}</div>`;
1735
+ let t = e.parts.map((e) => e.kind === "text" ? e.text : "").join(""), n = e.parts.flatMap((e) => e.kind === "attachments" ? e.attachments : []);
1736
+ 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}`;
1385
1737
  }
1386
- let n = t && this.state?.status === "streaming", a = e.parts.map((t, a) => {
1738
+ let n = t && this.state?.status === "streaming", r = e.parts.map((t, r) => {
1387
1739
  if (t.kind === "text") {
1388
- if (!t.text) return i;
1389
- let o = n && a === e.parts.length - 1;
1390
- return r`<div class="md" part="assistant">${O(t.text)}${o ? r`<span class="caret"></span>` : i}</div>`;
1740
+ if (!t.text) return a;
1741
+ let o = n && r === e.parts.length - 1;
1742
+ return i`<div class="md" part="assistant">${A(t.text)}${o ? i`<span class="caret"></span>` : a}</div>`;
1391
1743
  }
1392
- return this.renderTool(t);
1393
- }), o = n && !e.parts.length, s = r`<div class="assistant">
1394
- ${a}
1395
- ${o ? r`<span class="step" part="tool-step">${h("loader", 13)}<span>${this.labels.running}</span></span>` : i}
1744
+ return t.kind === "tool" ? this.renderTool(t) : a;
1745
+ }), o = n && !e.parts.length, s = i`<div class="assistant">
1746
+ ${r}
1747
+ ${o ? i`<span class="step" part="tool-step">${_("loader", 13)}<span>${this.labels.running}</span></span>` : a}
1396
1748
  </div>`;
1397
- return this.layout === "page" ? r`<div class="assistant-row"><span class="avatar">${p(18)}</span>${s}</div>` : s;
1749
+ return this.layout === "page" ? i`<div class="assistant-row"><span class="avatar">${h(18)}</span>${s}</div>` : s;
1750
+ }
1751
+ renderPhoto(e) {
1752
+ 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
1753
+ src=${n}
1754
+ alt=${e.name}
1755
+ loading="lazy"
1756
+ @error=${(e) => e.target.closest(".photo")?.setAttribute("data-broken", "")}
1757
+ />${r}` : r;
1758
+ 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>`;
1759
+ }
1760
+ renderChip(e) {
1761
+ let t = this.labels, n = e.status === "preparing" || e.status === "uploading", r = e.status === "failed";
1762
+ return i`<div class="chip" part="attachment-chip" data-status=${e.status} title=${e.name}>
1763
+ ${e.previewUrl && e.error !== "type" ? i`<img src=${e.previewUrl} alt=${e.name} />` : i`<span class="chip-icon">${_("image-off", 18)}</span>`}
1764
+ ${n ? i`<span
1765
+ class="chip-progress"
1766
+ role="progressbar"
1767
+ aria-label=${e.name}
1768
+ aria-valuemin="0"
1769
+ aria-valuemax="100"
1770
+ aria-valuenow=${Math.round(e.progress * 100)}
1771
+ ><span style=${s({ width: `${Math.max(8, Math.round(e.progress * 100))}%` })}></span
1772
+ ></span>` : a}
1773
+ ${r && e.error ? i`<span class="chip-error">${t.photoProblem[e.error]}</span>` : a}
1774
+ ${r && e.error === "upload" ? i`<button class="chip-retry" aria-label=${t.retryPhoto} title=${t.retryPhoto} @click=${() => this.chat?.retryUpload(e.id)}>
1775
+ ${_("refresh-cw", 12)}
1776
+ </button>` : a}
1777
+ <button class="chip-remove" aria-label=${t.removePhoto} title=${t.removePhoto} @click=${() => this.chat?.removeUpload(e.id)}>
1778
+ ${_("x", 11)}
1779
+ </button>
1780
+ </div>`;
1781
+ }
1782
+ pickPhotos() {
1783
+ this.renderRoot.querySelector("input[type=file]")?.click();
1784
+ }
1785
+ onPicked(e) {
1786
+ let t = e.target;
1787
+ t.files?.length && this.chat?.addFiles(t.files), t.value = "";
1788
+ }
1789
+ onPaste(e) {
1790
+ if (!this.state?.canAttach) return;
1791
+ let t = Array.from(e.clipboardData?.files ?? []);
1792
+ t.length && (e.preventDefault(), this.chat?.addFiles(t));
1793
+ }
1794
+ onDrag(e, t) {
1795
+ this.state?.canAttach && e.dataTransfer?.types?.includes("Files") && (e.preventDefault(), this.dragging = t);
1796
+ }
1797
+ onDrop(e) {
1798
+ if (this.dragging = !1, !this.state?.canAttach) return;
1799
+ let t = Array.from(e.dataTransfer?.files ?? []);
1800
+ t.length && (e.preventDefault(), this.chat?.addFiles(t));
1398
1801
  }
1399
1802
  toolLabel(e) {
1400
- return e.title || c(e.toolName);
1803
+ return e.title || u(e.toolName);
1401
1804
  }
1402
1805
  renderTool(e) {
1403
1806
  let t = this.labels;
1404
- if (e.state === "awaiting-approval") return i;
1807
+ if (e.state === "awaiting-approval") return a;
1405
1808
  if (e.approvalId) {
1406
- let [n, i, a] = e.state === "done" ? [
1809
+ let [n, r, a] = e.state === "done" ? [
1407
1810
  "done",
1408
1811
  "circle-check",
1409
- t.confirmed
1812
+ e.granted ? t.confirmedAllowed : t.confirmed
1410
1813
  ] : e.state === "denied" ? [
1411
1814
  "denied",
1412
1815
  "circle-x",
@@ -1414,60 +1817,81 @@ var k = n`
1414
1817
  ] : e.state === "error" ? [
1415
1818
  "error",
1416
1819
  "circle-alert",
1417
- e.errorText?.includes(A) ? t.outcomeUnknown : t.stepFailed
1820
+ e.errorText?.includes(M) ? t.outcomeUnknown : t.stepFailed
1418
1821
  ] : [
1419
1822
  "denied",
1420
1823
  "loader",
1421
1824
  t.running
1422
1825
  ];
1423
- return r`<div class="decided" part="decided" title=${e.state === "error" ? e.errorText ?? "" : ""}>
1826
+ return i`<div class="decided" part="decided" title=${e.state === "error" ? e.errorText ?? "" : ""}>
1424
1827
  <span class="what"
1425
- ><span class=${n}>${h(i, 15)}</span>${this.toolLabel(e)}${e.preview ? ` · ${e.preview.summary}` : ""}</span
1828
+ ><span class=${n}>${_(r, 15)}</span>${this.toolLabel(e)}${e.preview ? ` · ${e.preview.summary}` : ""}</span
1426
1829
  >
1427
1830
  <span class=${n}>${a}</span>
1428
1831
  </div>`;
1429
1832
  }
1833
+ if (e.allowed) return this.renderAllowed(e);
1430
1834
  let n = this.options?.cards?.[e.toolName]?.result;
1431
1835
  if (n && e.state === "done" && this.chat) return this.cardSlot(`result:${e.toolCallId}`, {
1432
1836
  part: e,
1433
1837
  client: this.chat
1434
1838
  }, n);
1435
- if (this.options?.toolSteps === "hide") return i;
1436
- let a = e.state === "done" ? f(e.output) : null, o = e.state === "done" ? r`<span class="ok">${h("check", 13)}</span>` : e.state === "error" ? r`<span class="bad">${h("circle-alert", 13)}</span>` : e.state === "denied" ? h("ban", 13) : r`<span class="spin">${h("loader", 13)}</span>`;
1437
- return r`<span class="step" part="tool-step" title=${e.state === "error" ? e.errorText ?? "" : ""}>
1438
- ${o}<span>${this.toolLabel(e)}${a === null ? "" : ` · ${t.found(a)}`}</span>
1839
+ if (this.options?.toolSteps === "hide") return a;
1840
+ 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>`;
1841
+ return i`<span class="step" part="tool-step" title=${e.state === "error" ? e.errorText ?? "" : ""}>
1842
+ ${o}<span>${this.toolLabel(e)}${r === null ? "" : ` · ${t.found(r)}`}</span>
1439
1843
  </span>`;
1844
+ }
1845
+ renderAllowed(e) {
1846
+ 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>`;
1847
+ return i`<div class="allowed" part="allowed-step" title=${e.state === "error" ? e.errorText ?? "" : ""}>
1848
+ <div class="allowed-head">
1849
+ <span class="what">${r}${this.toolLabel(e)}</span>
1850
+ <span class="allowed-tag">${_("shield-check", 12)} ${t.allowed}</span>
1851
+ </div>
1852
+ ${e.preview ? this.renderPreview(e.preview) : this.renderRows(`allowed:${e.toolCallId}`, e.input)}
1853
+ ${n ? i`<div class="allowed-by">${t.allowedAt(this.toolLabel(e), F(n.grantedAt))}</div>` : a}
1854
+ </div>`;
1855
+ }
1856
+ renderAllowances() {
1857
+ let e = this.state?.allowances ?? [];
1858
+ if (!e.length) return a;
1859
+ let t = this.labels;
1860
+ return i`${e.map((e) => i`<div class="allowance" part="allowance-bar" role="status">
1861
+ <span class="allowance-text">${_("shield-check", 13)} ${t.allowanceBar(this.toolLabel(e))}</span>
1862
+ <button class="link" @click=${() => this.chat?.revokeAllowance(e.toolName)}>${t.askEveryTime}</button>
1863
+ </div>`)}`;
1440
1864
  }
1441
1865
  renderPreview(e) {
1442
- if (!e) return i;
1866
+ if (!e) return a;
1443
1867
  let t = this.labels;
1444
- return r`<div class="preview" part="preview">
1868
+ return i`<div class="preview" part="preview">
1445
1869
  <div class="preview-summary">${e.summary}</div>
1446
- ${e.changes.length ? r`<ul class="preview-changes">
1447
- ${e.changes.map((e) => r`<li>
1870
+ ${e.changes.length ? i`<ul class="preview-changes">
1871
+ ${e.changes.map((e) => i`<li>
1448
1872
  <span class="preview-label">${e.label}:</span>
1449
- ${e.current === void 0 ? i : r`<span class="preview-now">${t.now} ${e.current}</span> → `}
1873
+ ${e.current === void 0 ? a : i`<span class="preview-now">${t.now} ${e.current}</span> → `}
1450
1874
  <span class="preview-next">${e.next}</span>
1451
1875
  </li>`)}
1452
- </ul>` : i}
1876
+ </ul>` : a}
1453
1877
  </div>`;
1454
1878
  }
1455
1879
  renderRows(e, t) {
1456
- let n = this.labels, a = d(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 = a.some((e) => e.value.length > 160 || s(e.value) > 1);
1457
- return r`<div class="rows">
1458
- ${a.map((e) => r`<div class="row">
1880
+ 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);
1881
+ return i`<div class="rows">
1882
+ ${r.map((e) => i`<div class="row">
1459
1883
  <span class="label">${e.label}</span>
1460
1884
  <span class="value">${o ? e.value : c(e.value)}</span>
1461
1885
  </div>`)}
1462
- ${l ? r`<button class="link" @click=${() => this.toggleRows(e)}>${o ? n.showLess : n.showMore}</button>` : i}
1886
+ ${l ? i`<button class="link" @click=${() => this.toggleRows(e)}>${o ? n.showLess : n.showMore}</button>` : a}
1463
1887
  </div>`;
1464
1888
  }
1465
1889
  renderPending() {
1466
1890
  let e = this.state?.pendingApprovals ?? [];
1467
- if (!e.length || this.state?.status !== "awaiting-approval") return i;
1891
+ if (!e.length || this.state?.status !== "awaiting-approval") return a;
1468
1892
  let t = this.labels;
1469
1893
  if (e.length === 1) {
1470
- let n = e[0], a = this.options?.cards?.[n.toolName]?.confirm, o = {
1894
+ let n = e[0], r = this.options?.cards?.[n.toolName]?.confirm, o = {
1471
1895
  kind: "tool",
1472
1896
  toolCallId: n.toolCallId,
1473
1897
  toolName: n.toolName,
@@ -1476,7 +1900,7 @@ var k = n`
1476
1900
  state: "awaiting-approval",
1477
1901
  approvalId: n.approvalId
1478
1902
  };
1479
- if (a && this.chat) {
1903
+ if (r && this.chat) {
1480
1904
  let e = this.chat;
1481
1905
  return this.cardSlot(`confirm:${n.approvalId}`, {
1482
1906
  part: o,
@@ -1487,15 +1911,15 @@ var k = n`
1487
1911
  approved: t,
1488
1912
  ...r ? { reason: r } : {}
1489
1913
  }])
1490
- }, a);
1914
+ }, r);
1491
1915
  }
1492
- return r`<div class="confirm" part="confirm-card" role="group" aria-label=${this.toolLabel(n)}>
1916
+ return i`<div class="confirm" part="confirm-card" role="group" aria-label=${this.toolLabel(n)}>
1493
1917
  <div class="confirm-head" part="confirm-header">
1494
- <span class="what">${h("pencil-line", 15)} ${this.toolLabel(n)}</span>
1918
+ <span class="what">${_("pencil-line", 15)} ${this.toolLabel(n)}</span>
1495
1919
  <span class="badge">${t.needsOk}</span>
1496
1920
  </div>
1497
1921
  ${this.renderPreview(n.preview)}
1498
- ${n.preview ? r`<div class="exact-head">${t.exactValues}</div>` : i}
1922
+ ${n.preview ? i`<div class="exact-head">${t.exactValues}</div>` : a}
1499
1923
  ${this.renderRows(n.approvalId, n.input)}
1500
1924
  <div class="confirm-foot">
1501
1925
  <span class="hint">${n.preview ? "" : t.exactValues}</span>
@@ -1503,16 +1927,17 @@ var k = n`
1503
1927
  <button class="btn secondary" part="button-secondary" @click=${() => this.decideAll(!1)}>${t.cancel}</button>
1504
1928
  <button class="btn primary" part="button-primary" @click=${() => this.decideAll(!0)}>${t.confirm}</button>
1505
1929
  </span>
1930
+ ${this.renderAllowChoice([n])}
1506
1931
  </div>
1507
1932
  </div>`;
1508
1933
  }
1509
1934
  let n = e.filter((e) => !this.unticked.has(e.approvalId)).length;
1510
- return r`<div class="confirm" part="confirm-card" role="group" aria-label=${t.changes(e.length)}>
1935
+ return i`<div class="confirm" part="confirm-card" role="group" aria-label=${t.changes(e.length)}>
1511
1936
  <div class="confirm-head" part="confirm-header">
1512
1937
  <span class="what">${t.changes(e.length)}</span>
1513
1938
  <span class="badge">${t.needsOk}</span>
1514
1939
  </div>
1515
- ${e.map((e) => r`<div class="item">
1940
+ ${e.map((e) => i`<div class="item">
1516
1941
  <input
1517
1942
  type="checkbox"
1518
1943
  aria-label=${this.toolLabel(e)}
@@ -1522,7 +1947,7 @@ var k = n`
1522
1947
  <span class="body">
1523
1948
  <span class="name">${this.toolLabel(e)}</span>
1524
1949
  ${this.renderPreview(e.preview)}
1525
- ${e.preview ? r`<span class="exact-head">${t.exactValues}</span>` : i}
1950
+ ${e.preview ? i`<span class="exact-head">${t.exactValues}</span>` : a}
1526
1951
  ${this.renderRows(e.approvalId, e.input)}
1527
1952
  </span>
1528
1953
  </div>`)}
@@ -1534,11 +1959,12 @@ var k = n`
1534
1959
  ${t.confirmN(n)}
1535
1960
  </button>
1536
1961
  </span>
1962
+ ${this.renderAllowChoice(e.filter((e) => !this.unticked.has(e.approvalId)))}
1537
1963
  </div>
1538
1964
  </div>`;
1539
1965
  }
1540
1966
  renderProblem(e) {
1541
- let t = this.labels, n = t.problems[e.code], a = this.chat, o = e.code === "reconnecting" || e.code === "in-progress" ? "" : e.code === "throttled" || e.code === "conversation-full" || e.code === "token-expired" ? "warn" : "error", s = {
1967
+ 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 = {
1542
1968
  reconnecting: "refresh-cw",
1543
1969
  "token-expired": "refresh-cw",
1544
1970
  "in-progress": "clock",
@@ -1547,9 +1973,9 @@ var k = n`
1547
1973
  "store-unreachable": "plug-zap",
1548
1974
  "cut-off": "wifi-off",
1549
1975
  unavailable: "wifi-off"
1550
- }, c = e.code === "conversation-full" ? r`<button class="btn secondary" @click=${() => this.newConversation()}>${t.newConversation}</button>` : e.code === "cut-off" ? r`<button class="btn secondary" @click=${() => a?.reload()}>${t.reload}</button>` : e.code === "token-expired" ? r`<button class="btn secondary" @click=${() => a?.send(t.continueMessage)}>${t.continue}</button>` : e.code === "store-unreachable" || e.code === "unavailable" || e.code === "failed" || e.code === "in-progress" ? r`<button class="btn secondary" @click=${() => a?.retry()}>${t.tryAgain}</button>` : i, l = e.code === "reconnecting" ? i : r`<button class="btn secondary" @click=${() => a?.dismissProblem()}>${t.dismiss}</button>`;
1551
- return r`<div class=${`problem ${o}`} part="problem" role="status">
1552
- <span class=${e.code === "reconnecting" ? "icon spin" : "icon"}>${h(s[e.code] ?? "circle-alert", 16)}</span>
1976
+ }, 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>`;
1977
+ return i`<div class=${`problem ${o}`} part="problem" role="status">
1978
+ <span class=${e.code === "reconnecting" ? "icon spin" : "icon"}>${_(s[e.code] ?? "circle-alert", 16)}</span>
1553
1979
  <span class="body">
1554
1980
  <span class="head">${n.title}</span>
1555
1981
  <span>${e.code === "failed" && e.message ? e.message : n.text(e.retryAfter)}</span>
@@ -1558,44 +1984,92 @@ var k = n`
1558
1984
  </div>`;
1559
1985
  }
1560
1986
  renderBottom() {
1561
- let e = this.labels, t = this.state, n = t?.status === "sending" || t?.status === "streaming", a = t?.status === "awaiting-approval";
1562
- return r`${t?.problem ? r`<div class="column">${this.renderProblem(t.problem)}</div>` : i}
1563
- <div class="composer column" part="composer">
1987
+ let e = this.labels, n = this.state, r = n?.status === "sending" || n?.status === "streaming", o = n?.status === "awaiting-approval";
1988
+ return i`${n?.problem ? i`<div class="column">${this.renderProblem(n.problem)}</div>` : a}
1989
+ <div
1990
+ class="composer column"
1991
+ part="composer"
1992
+ ?data-dragging=${this.dragging}
1993
+ @dragover=${(e) => this.onDrag(e, !0)}
1994
+ @dragleave=${(e) => this.onDrag(e, !1)}
1995
+ @drop=${this.onDrop}
1996
+ >
1997
+ ${n?.allowances.length ? i`<div class="allowances">${this.renderAllowances()}</div>` : a}
1998
+ ${n?.uploads.length ? i`<div class="chips" part="attachment-chips">${n.uploads.map((e) => this.renderChip(e))}</div>
1999
+ <div class="chips-note">${e.photosLimit(this.photoCount(), this.photoMb())}</div>` : a}
2000
+ ${this.dragging ? i`<div class="drop-note">${e.dropPhotos}</div>` : a}
1564
2001
  <div class="box">
2002
+ ${n?.canAttach ? i`<button
2003
+ class="attach"
2004
+ part="attach-button"
2005
+ aria-label=${e.attachPhoto}
2006
+ title=${e.attachPhoto}
2007
+ ?disabled=${!this.chat}
2008
+ @click=${() => this.pickPhotos()}
2009
+ >
2010
+ ${_("image-plus", 17)}
2011
+ </button>
2012
+ <input
2013
+ type="file"
2014
+ hidden
2015
+ multiple
2016
+ accept=${(this.chat?.attachmentLimits().accept ?? t.accept).join(",")}
2017
+ @change=${this.onPicked}
2018
+ />` : a}
1565
2019
  <label class="sr-only" for="input">${e.placeholder}</label>
1566
2020
  <textarea
1567
2021
  id="input"
1568
2022
  part="input"
1569
2023
  rows="1"
1570
- lang=${this.locale || i}
2024
+ lang=${this.locale || a}
1571
2025
  placeholder=${e.placeholder}
1572
2026
  .value=${this.draft}
1573
2027
  ?disabled=${!this.chat}
1574
2028
  @input=${this.onInput}
1575
2029
  @keydown=${this.onKeydown}
2030
+ @paste=${this.onPaste}
1576
2031
  ></textarea>
1577
- ${n ? r`<button class="stop" part="stop" @click=${() => this.chat?.stop()}>
2032
+ ${r ? i`<button class="stop" part="stop" @click=${() => this.chat?.stop()}>
1578
2033
  <span class="square"></span>${e.stop}
1579
- </button>` : r`<button
2034
+ </button>` : i`<button
1580
2035
  class="send"
1581
2036
  part="send"
1582
2037
  aria-label=${e.send}
1583
2038
  title=${e.send}
1584
- ?disabled=${!this.draft.trim() || !this.chat}
2039
+ ?disabled=${!this.canSend() || !this.chat}
1585
2040
  @click=${() => this.submit()}
1586
2041
  >
1587
- ${h("arrow-up", 17)}
2042
+ ${_("arrow-up", 17)}
1588
2043
  </button>`}
1589
2044
  </div>
1590
2045
  <div class="footer">
1591
- <span class="ghuri">${p(12)} Ghuri AI</span>
1592
- <span>· ${a ? e.newMessageCancels : e.footer}</span>
2046
+ <span class="ghuri">${h(12)} Ghuri AI</span>
2047
+ <span>· ${o ? e.newMessageCancels : n?.allowances.length ? e.footerAllowed : e.footer}</span>
1593
2048
  </div>
1594
2049
  </div>`;
1595
2050
  }
2051
+ photoCount() {
2052
+ return this.chat?.attachmentLimits().maxCount ?? t.maxCount;
2053
+ }
2054
+ photoMb() {
2055
+ let e = this.chat?.attachmentLimits().maxBytes ?? t.maxBytes;
2056
+ return Math.round(e / 1048576 * 10) / 10;
2057
+ }
1596
2058
  };
2059
+ function P(e) {
2060
+ if (typeof e == "string") try {
2061
+ let t = new URL(e);
2062
+ return t.protocol === "https:" ? t.toString() : void 0;
2063
+ } catch {
2064
+ return;
2065
+ }
2066
+ }
2067
+ function F(e) {
2068
+ let t = new Date(e);
2069
+ return Number.isNaN(t.getTime()) ? "" : `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}`;
2070
+ }
1597
2071
  // src/index.ts
1598
- typeof customElements < "u" && !customElements.get("ghuri-chat") && customElements.define("ghuri-chat", j);
1599
- export { j as t };
2072
+ typeof customElements < "u" && !customElements.get("ghuri-chat") && customElements.define("ghuri-chat", N);
2073
+ export { N as t };
1600
2074
 
1601
- //# sourceMappingURL=src-BNRsAIH2.js.map
2075
+ //# sourceMappingURL=src-Bh9z-NWv.js.map