@ghuri/ai-widget 0.5.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,4 +1,4 @@
1
- import { n as e, r as t, t as n } from "./core-4zFtqSww.js";
1
+ import { a as e, n as t, t as n } from "./core-B_prP9RO.js";
2
2
  import { LitElement as r, css as i, html as a, nothing as o, svg as s } from "lit";
3
3
  import { styleMap as c } from "lit/directives/style-map.js";
4
4
  import { unsafeSVG as l } from "lit/directives/unsafe-svg.js";
@@ -69,6 +69,9 @@ var _ = {
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\"/>",
@@ -109,6 +112,10 @@ var y = {
109
112
  },
110
113
  photosLimit: (e, t) => `Up to ${e} photos · ${t} MB each. Location data is removed.`,
111
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.",
112
119
  placeholder: "Write in Bangla, Banglish or English…",
113
120
  send: "Send",
114
121
  stop: "Stop",
@@ -166,11 +173,27 @@ var y = {
166
173
  continuedFrom: (e) => `Continued from “${e}”`,
167
174
  carriedOver: "What I carried over",
168
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.",
169
177
  carryOn: "Carry on with the task",
170
178
  carryOnMessage: "Carry on with the task.",
171
179
  continuedIn: "Continued in a new conversation",
172
180
  open: "Open →"
173
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
+ },
174
197
  problems: {
175
198
  reconnecting: {
176
199
  title: "Reconnecting…",
@@ -224,6 +247,10 @@ var y = {
224
247
  title: "Photos can't be sent here",
225
248
  text: () => "Nothing was sent. Send your message without photos, or upload them in the dashboard."
226
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
+ },
227
254
  failed: {
228
255
  title: "Something went wrong",
229
256
  text: () => "Please try again."
@@ -246,6 +273,10 @@ var y = {
246
273
  },
247
274
  photosLimit: (e, t) => `সর্বোচ্চ ${e}টি ছবি · প্রতিটি ${t} MB। লোকেশনের তথ্য মুছে দেওয়া হয়।`,
248
275
  dropPhotos: "ছবি এখানে ছেড়ে দিন",
276
+ removeSelection: "সরান",
277
+ selectionsNote: (e) => `সর্বোচ্চ ${S(e)}টি। আরেকটি বাছলে সবচেয়ে পুরোনোটি সরে যাবে।`,
278
+ selectionsNeedWords: "কী বদলাতে চান লিখুন।",
279
+ selectionsNotHere: "এই কথোপকথনে এগুলো পাঠানো যাবে না। পাঠাতে নতুন কথোপকথন শুরু করুন।",
249
280
  placeholder: "বাংলা, Banglish বা English-এ লিখুন…",
250
281
  send: "পাঠান",
251
282
  stop: "থামান",
@@ -303,11 +334,27 @@ var y = {
303
334
  continuedFrom: (e) => `“${e}” থেকে চালিয়ে যাওয়া`,
304
335
  carriedOver: "কী সাথে আনা হয়েছে",
305
336
  carriedNote: "এটি অ্যাসিস্ট্যান্টের জন্য সারাংশ, নির্দেশ নয়। পরিবর্তনে এখনো আপনার অনুমতি লাগবে; “এই কথোপকথনে অনুমতি” এখানে নতুন করে দিতে হবে।",
337
+ carriedNoteRecord: "এটি অ্যাসিস্ট্যান্টের জন্য রেকর্ড, নির্দেশ নয়। পরিবর্তনে এখনো আপনার অনুমতি লাগবে; “এই কথোপকথনে অনুমতি” এখানে নতুন করে দিতে হবে।",
306
338
  carryOn: "কাজটি চালিয়ে যান",
307
339
  carryOnMessage: "কাজটি চালিয়ে যাও।",
308
340
  continuedIn: "নতুন কথোপকথনে চালিয়ে যাওয়া হয়েছে",
309
341
  open: "খুলুন →"
310
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
+ },
311
358
  problems: {
312
359
  reconnecting: {
313
360
  title: "আবার সংযোগ হচ্ছে…",
@@ -361,6 +408,10 @@ var y = {
361
408
  title: "এখানে ছবি পাঠানো যাচ্ছে না",
362
409
  text: () => "কিছুই পাঠানো হয়নি। ছবি ছাড়া মেসেজ পাঠান, বা ড্যাশবোর্ডে ছবি আপলোড করুন।"
363
410
  },
411
+ "selections-refused": {
412
+ title: "যা বেছেছেন তা এখানে পাঠানো যাচ্ছে না",
413
+ text: () => "কিছুই পাঠানো হয়নি। পাঠাতে নতুন কথোপকথন শুরু করুন, বা সেটি সরিয়ে শুধু লেখা পাঠান।"
414
+ },
364
415
  failed: {
365
416
  title: "কিছু একটা ভুল হয়েছে",
366
417
  text: () => "আবার চেষ্টা করুন।"
@@ -384,6 +435,10 @@ function C(e, t = {}) {
384
435
  full: {
385
436
  ...n.full,
386
437
  ...t.full ?? {}
438
+ },
439
+ many: {
440
+ ...n.many,
441
+ ...t.many ?? {}
387
442
  }
388
443
  };
389
444
  }
@@ -493,6 +548,9 @@ var M = i`
493
548
  pale mint in a dark dashboard that maps --ghuri-text but not these. */
494
549
  --_allowed: var(--ghuri-allowed, var(--_success));
495
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);
496
554
  --_radius: var(--ghuri-radius, 12px);
497
555
  --_radius-sm: var(--ghuri-radius-sm, 8px);
498
556
  --_bubble-radius: var(--ghuri-bubble-radius, 14px);
@@ -821,6 +879,190 @@ var M = i`
821
879
  color: var(--_warning);
822
880
  }
823
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
+
824
1066
  /* --- "Allow for this conversation" --- */
825
1067
  .allow-choice {
826
1068
  display: flex;
@@ -1208,11 +1450,27 @@ var M = i`
1208
1450
  font-weight: 600;
1209
1451
  }
1210
1452
  .carried-text {
1211
- white-space: pre-wrap;
1453
+ display: flex;
1454
+ flex-direction: column;
1212
1455
  overflow-wrap: anywhere;
1213
1456
  font-size: 12px;
1214
1457
  line-height: 18px;
1215
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
+ }
1216
1474
  .carried-note {
1217
1475
  color: var(--_muted);
1218
1476
  font-size: 11px;
@@ -1344,6 +1602,90 @@ var M = i`
1344
1602
  gap: 8px;
1345
1603
  margin-bottom: 6px;
1346
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
+ }
1347
1689
  .chip {
1348
1690
  position: relative;
1349
1691
  display: grid;
@@ -1617,8 +1959,23 @@ var M = i`
1617
1959
  text-overflow: ellipsis;
1618
1960
  }
1619
1961
  .conversation .when {
1962
+ display: flex;
1963
+ align-items: center;
1964
+ gap: 4px;
1620
1965
  font-size: 11px;
1621
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;
1622
1979
  }
1623
1980
  .panel-history {
1624
1981
  padding: 0 8px 12px;
@@ -1655,7 +2012,7 @@ var M = i`
1655
2012
  font-weight: 500;
1656
2013
  min-height: 48px;
1657
2014
  }
1658
- `, N = "result was not recorded", P = class extends r {
2015
+ `, N = "result was not recorded", P = 3, F = 6, I = 3, L = class extends r {
1659
2016
  static styles = M;
1660
2017
  static properties = {
1661
2018
  layout: {
@@ -1692,16 +2049,18 @@ var M = i`
1692
2049
  constructor() {
1693
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;
1694
2051
  }
1695
- configure(t) {
1696
- this.detach(), this.options = t, t.layout && (this.layout = t.layout), t.title !== void 0 && (this.heading = t.title), t.subtitle !== void 0 && (this.subtitle = t.subtitle), t.locale && (this.locale = t.locale);
1697
- 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);
1698
2055
  this.chat = n, this.state = n.getState(), this.unsubscribe = [n.subscribe((e) => {
1699
2056
  this.state = e, this.guardUnload(e.status === "sending" || e.status === "streaming");
1700
2057
  }), ...[
1701
2058
  "tool-result",
1702
2059
  "approval-pending",
1703
2060
  "turn-end",
1704
- "attachment-error"
2061
+ "attachment-error",
2062
+ "selection-removed",
2063
+ "selection-sent"
1705
2064
  ].map((e) => n.on(e, (t) => this.fire(e, t)))], this.layout === "page" && this.loadConversations(), (this.open || this.layout === "page") && n.loadCapabilities();
1706
2065
  }
1707
2066
  setOptions(e) {
@@ -1729,6 +2088,18 @@ var M = i`
1729
2088
  async ask(e, t = {}) {
1730
2089
  this.show(), this.view = "chat", t.send === !1 ? (this.draft = e, await this.updateComplete, this.focusInput()) : await this.chat?.send(e);
1731
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
+ }
1732
2103
  newConversation() {
1733
2104
  this.chat?.newConversation(), this.view = "chat", this.expanded = /* @__PURE__ */ new Set(), this.unticked = /* @__PURE__ */ new Set(), this.updateComplete.then(() => this.focusInput());
1734
2105
  }
@@ -1793,12 +2164,12 @@ var M = i`
1793
2164
  let n = !this.state?.conversationId;
1794
2165
  await this.chat.send(e);
1795
2166
  let r = this.chat?.getState().problem?.code;
1796
- r !== "photos-refused" && r !== "conversation-full" || this.draft || (this.draft = e), n && this.layout === "page" && this.loadConversations();
2167
+ r !== "photos-refused" && r !== "selections-refused" && r !== "conversation-full" || this.draft || (this.draft = e), n && this.layout === "page" && this.loadConversations();
1797
2168
  }
1798
2169
  canSend() {
1799
2170
  if (this.state?.full) return !1;
1800
2171
  let e = this.state?.uploads ?? [];
1801
- return e.some((e) => e.status === "preparing" || e.status === "uploading") || e.some((e) => e.status === "failed" && e.error === "upload") ? !1 : !!this.draft.trim() || e.some((e) => e.status === "ready");
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");
1802
2173
  }
1803
2174
  onKeydown(e) {
1804
2175
  e.key !== "Enter" || e.shiftKey || e.isComposing || e.keyCode === 229 || (e.preventDefault(), this.submit());
@@ -1811,6 +2182,11 @@ var M = i`
1811
2182
  let t = new Set(this.expanded);
1812
2183
  t.has(e) ? t.delete(e) : t.add(e), this.expanded = t;
1813
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
+ }
1814
2190
  tick(e, t) {
1815
2191
  let n = new Set(this.unticked);
1816
2192
  t ? n.delete(e) : n.add(e), this.unticked = n;
@@ -1954,10 +2330,14 @@ var M = i`
1954
2330
  @click=${() => this.openConversation(e.id)}
1955
2331
  >
1956
2332
  <span class="name">${e.title || "—"}</span>
1957
- <span class="when">${t.format(new Date(e.updatedAt))}</span>
2333
+ <span class="when">${this.renderListMark(e)}${t.format(new Date(e.updatedAt))}</span>
1958
2334
  </button>`)}
1959
2335
  </nav>`;
1960
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
+ }
1961
2341
  renderPanelHistory() {
1962
2342
  let e = this.labels;
1963
2343
  return a`<div class="scroll">
@@ -1982,24 +2362,29 @@ var M = i`
1982
2362
  </div>`;
1983
2363
  }
1984
2364
  renderContinued() {
1985
- let e = this.labels.full, n = this.state, r = n.continuedFrom, i = n.handover ? t(n.handover) : "", s = !this.carriedClosed, c = !n.messages.length && n.status === "idle";
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";
1986
2369
  return a`<div class="continued" part="continued">
1987
2370
  <button class="continued-from" @click=${() => this.openConversation(r.id)}>
1988
- ${v("corner-down-right", 13)}<span>${e.continuedFrom(r.title)} ↗</span>
2371
+ ${v("corner-down-right", 13)}<span>${t.continuedFrom(r.title)} ↗</span>
1989
2372
  </button>
1990
- ${i ? a`<div class="carried" part="carried-over">
1991
- <button class="carried-head" aria-expanded=${s ? "true" : "false"} @click=${() => {
1992
- this.carriedClosed = s;
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;
1993
2376
  }}>
1994
- <span class="name">${v("package-open", 14)}${e.carriedOver}</span>
1995
- ${v(s ? "chevron-up" : "chevron-down", 14)}
2377
+ <span class="name">${v("package-open", 14)}${t.carriedOver}</span>
2378
+ ${v(c ? "chevron-up" : "chevron-down", 14)}
1996
2379
  </button>
1997
- ${s ? a`<div class="carried-text">${i}</div>
1998
- <div class="carried-note">${e.carriedNote}</div>` : o}
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}
1999
2384
  </div>` : o}
2000
- ${c ? a`<div class="carry-on-row">
2001
- <button class="carry-on" part="carry-on" @click=${() => this.chat?.send(e.carryOnMessage)}>
2002
- ${v("play", 13)}${e.carryOn}
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}
2003
2388
  </button>
2004
2389
  </div>` : o}
2005
2390
  </div>`;
@@ -2016,24 +2401,62 @@ var M = i`
2016
2401
  }
2017
2402
  renderMessage(e, t) {
2018
2403
  if (e.role === "user") {
2019
- let t = e.parts.map((e) => e.kind === "text" ? e.text : "").join(""), n = e.parts.flatMap((e) => e.kind === "attachments" ? e.attachments : []);
2020
- return a`${n.length ? a`<div class="photos" part="message-photos">${n.map((e) => this.renderPhoto(e))}</div>` : o}${t ? a`<div class="user" part="user-bubble">${t}</div>` : o}`;
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}`;
2021
2408
  }
2022
- let n = t && this.state?.status === "streaming", r = e.parts.map((t, r) => {
2023
- if (t.kind === "text") {
2024
- if (!t.text) return o;
2025
- let i = n && r === e.parts.length - 1;
2026
- return a`<div class="md" part="assistant">${j(t.text)}${i ? a`<span class="caret"></span>` : o}</div>`;
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;
2027
2417
  }
2028
- return t.kind === "tool" ? this.renderTool(t) : o;
2029
- }), i = n && !e.parts.length, s = a`<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">
2030
2423
  ${r}
2031
2424
  ${i ? a`<span class="step" part="tool-step">${v("loader", 13)}<span>${this.labels.running}</span></span>` : o}
2032
2425
  </div>`;
2033
2426
  return this.layout === "page" ? a`<div class="assistant-row"><span class="avatar">${g(18)}</span>${s}</div>` : s;
2034
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>`}`;
2457
+ }
2035
2458
  renderPhoto(e) {
2036
- let t = F(e.thumbnailUrl), n = (e.previewUrl?.startsWith("blob:") ? e.previewUrl : void 0) ?? t, r = a`<span class="photo-name">${v("image-off", 14)}<span>${e.name}</span></span>`, i = n ? a`<img
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
2037
2460
  src=${n}
2038
2461
  alt=${e.name}
2039
2462
  loading="lazy"
@@ -2130,11 +2553,42 @@ var M = i`
2130
2553
  ${e.images.map((n, r) => a`<button
2131
2554
  class="picture"
2132
2555
  aria-label=${t.showPicture(r + 1, e.images.length)}
2133
- @click=${() => this.enlarged = L(n)}
2556
+ @click=${() => this.enlarged = U(n)}
2134
2557
  >
2135
- <img src=${L(n)} alt=${t.showPicture(r + 1, e.images.length)} />
2558
+ <img src=${U(n)} alt=${t.showPicture(r + 1, e.images.length)} />
2136
2559
  </button>`)}
2137
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>
2138
2592
  </div>`;
2139
2593
  }
2140
2594
  renderAllowed(e) {
@@ -2145,7 +2599,7 @@ var M = i`
2145
2599
  <span class="allowed-tag">${v("shield-check", 12)} ${t.allowed}</span>
2146
2600
  </div>
2147
2601
  ${e.preview ? this.renderPreview(e.preview) : this.renderRows(`allowed:${e.toolCallId}`, e.input)}
2148
- ${n ? a`<div class="allowed-by">${t.allowedAt(this.toolLabel(e), I(n.grantedAt))}</div>` : o}
2602
+ ${n ? a`<div class="allowed-by">${t.allowedAt(this.toolLabel(e), H(n.grantedAt))}</div>` : o}
2149
2603
  </div>`;
2150
2604
  }
2151
2605
  renderAllowances() {
@@ -2229,23 +2683,10 @@ var M = i`
2229
2683
  let n = e.filter((e) => !this.unticked.has(e.approvalId)).length;
2230
2684
  return a`<div class="confirm" part="confirm-card" role="group" aria-label=${t.changes(e.length)}>
2231
2685
  <div class="confirm-head" part="confirm-header">
2232
- <span class="what">${t.changes(e.length)}</span>
2686
+ <span class="what">${v("pencil-line", 15)} ${t.changes(e.length)}</span>
2233
2687
  <span class="badge">${t.needsOk}</span>
2234
2688
  </div>
2235
- ${e.map((e) => a`<div class="item">
2236
- <input
2237
- type="checkbox"
2238
- aria-label=${this.toolLabel(e)}
2239
- .checked=${!this.unticked.has(e.approvalId)}
2240
- @change=${(t) => this.tick(e.approvalId, t.target.checked)}
2241
- />
2242
- <span class="body">
2243
- <span class="name">${this.toolLabel(e)}</span>
2244
- ${this.renderPreview(e.preview)}
2245
- ${e.preview ? a`<span class="exact-head">${t.exactValues}</span>` : o}
2246
- ${this.renderRows(e.approvalId, e.input)}
2247
- </span>
2248
- </div>`)}
2689
+ ${R(e).map((e) => e.length >= P ? this.renderCompactGroup(e) : e.map((e) => this.renderItem(e)))}
2249
2690
  <div class="confirm-foot">
2250
2691
  <span class="hint">${t.unticked}</span>
2251
2692
  <span class="buttons">
@@ -2256,6 +2697,76 @@ var M = i`
2256
2697
  </span>
2257
2698
  ${this.renderAllowChoice(e.filter((e) => !this.unticked.has(e.approvalId)))}
2258
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}
2259
2770
  </div>`;
2260
2771
  }
2261
2772
  renderProblem(e) {
@@ -2327,6 +2838,7 @@ var M = i`
2327
2838
  @drop=${this.onDrop}
2328
2839
  >
2329
2840
  ${t?.allowances.length ? a`<div class="allowances">${this.renderAllowances()}</div>` : o}
2841
+ ${t ? this.renderComposerSelections(t) : o}
2330
2842
  ${t?.uploads.length ? a`<div class="chips" part="attachment-chips">${t.uploads.map((e) => this.renderChip(e))}</div>
2331
2843
  <div class="chips-note">${e.photosLimit(this.photoCount(), this.photoMb())}</div>` : o}
2332
2844
  ${this.dragging ? a`<div class="drop-note">${e.dropPhotos}</div>` : o}
@@ -2388,7 +2900,32 @@ var M = i`
2388
2900
  return Math.round(e / 1048576 * 10) / 10;
2389
2901
  }
2390
2902
  };
2391
- function F(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) {
2392
2929
  if (typeof e == "string") try {
2393
2930
  let t = new URL(e);
2394
2931
  return t.protocol === "https:" ? t.toString() : void 0;
@@ -2396,15 +2933,15 @@ function F(e) {
2396
2933
  return;
2397
2934
  }
2398
2935
  }
2399
- function I(e) {
2936
+ function H(e) {
2400
2937
  let t = new Date(e);
2401
2938
  return Number.isNaN(t.getTime()) ? "" : `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}`;
2402
2939
  }
2403
- function L(e) {
2940
+ function U(e) {
2404
2941
  return `data:${e.mediaType};base64,${e.data}`;
2405
2942
  }
2406
2943
  // src/index.ts
2407
- typeof customElements < "u" && !customElements.get("ghuri-chat") && customElements.define("ghuri-chat", P);
2408
- export { P as t };
2944
+ typeof customElements < "u" && !customElements.get("ghuri-chat") && customElements.define("ghuri-chat", L);
2945
+ export { L as t };
2409
2946
 
2410
- //# sourceMappingURL=src-COOw7K47.js.map
2947
+ //# sourceMappingURL=src-CKqHiJZD.js.map