@aiden-voice/widget 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js CHANGED
@@ -25,7 +25,8 @@ var e = {
25
25
  feedbackFailed: "Couldn't send feedback",
26
26
  conversationCleared: "Conversation cleared",
27
27
  genericError: "Something went wrong, please try again.",
28
- sessionExpired: "This chat session has expired. Reload the page to continue."
28
+ sessionExpired: "This chat session has expired. Reload the page to continue.",
29
+ opensInNewTab: "(opens in new tab)"
29
30
  }, t = Object.keys(e);
30
31
  //#endregion
31
32
  //#region src/imageUrl.ts
@@ -144,7 +145,7 @@ function y(e) {
144
145
  continue;
145
146
  }
146
147
  let i = e[r];
147
- if (typeof i != "string" || i.trim() === "") {
148
+ if (typeof i != "string" || /^[\p{White_Space}\p{Cf}\p{M}]*$/u.test(i)) {
148
149
  f(`ignoring \`messages.${r}\` -- expected a non-blank string.`);
149
150
  continue;
150
151
  }
@@ -525,12 +526,12 @@ function Qe(e, t) {
525
526
  });
526
527
  return e >= n.__.length && n.__.push({}), n.__[e];
527
528
  }
528
- function $e(e) {
529
- return Ue = 1, et(ut, e);
529
+ function V(e) {
530
+ return Ue = 1, $e(lt, e);
530
531
  }
531
- function et(e, t, n) {
532
+ function $e(e, t, n) {
532
533
  var r = Qe(R++, 2);
533
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : ut(void 0, t), function(e) {
534
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : lt(void 0, t), function(e) {
534
535
  var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
535
536
  He(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
536
537
  }], r.__c = z, !z.__f)) {
@@ -551,35 +552,35 @@ function et(e, t, n) {
551
552
  }
552
553
  return r.__;
553
554
  }
554
- function tt(e, t) {
555
+ function et(e, t) {
555
556
  var n = Qe(R++, 3);
556
- !B.__s && lt(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, z.__H.__h.push(n));
557
+ !B.__s && ct(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, z.__H.__h.push(n));
557
558
  }
558
- function nt(e, t) {
559
+ function tt(e, t) {
559
560
  var n = Qe(R++, 4);
560
- !B.__s && lt(n.__H, t) && (n.__P = !1, n.__ = e, n.u = t, z.__h.push(n));
561
+ !B.__s && ct(n.__H, t) && (n.__P = !1, n.__ = e, n.u = t, z.__h.push(n));
561
562
  }
562
- function V(e) {
563
- return Ue = 5, rt(function() {
563
+ function H(e) {
564
+ return Ue = 5, nt(function() {
564
565
  return { current: e };
565
566
  }, []);
566
567
  }
567
- function rt(e, t) {
568
+ function nt(e, t) {
568
569
  var n = Qe(R++, 7);
569
- return lt(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
570
+ return ct(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
570
571
  }
571
- function it() {
572
+ function rt() {
572
573
  var e;
573
574
  do {
574
575
  for (; e = Ge.shift();) try {
575
- H(e);
576
+ U(e);
576
577
  } catch (t) {
577
578
  B.__e(t, { __: (e = e.__P) && e.__v });
578
579
  }
579
580
  for (; e = We.shift();) {
580
581
  var t = e.__H;
581
582
  if (e.__P && t) try {
582
- t.__h.some(H), t.__h.some(ct), t.__h = [];
583
+ t.__h.some(U), t.__h.some(st), t.__h = [];
583
584
  } catch (n) {
584
585
  t.__h = [], B.__e(n, e.__v);
585
586
  }
@@ -593,20 +594,20 @@ B.__b = function(e) {
593
594
  }, B.__r = function(e) {
594
595
  qe && qe(e), R = 0;
595
596
  var t = (z = e.__c).__H;
596
- t && (Be == z ? z.__h = [] : (t.__h.some(H), t.__h.some(ct), R = 0), t.__h = [], t.__.some(function(e) {
597
+ t && (Be == z ? z.__h = [] : (t.__h.some(U), t.__h.some(st), R = 0), t.__h = [], t.__.some(function(e) {
597
598
  e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
598
599
  })), Be = z;
599
600
  }, B.diffed = function(e) {
600
601
  Je && Je(e);
601
602
  var t = e.__c;
602
- t && t.__H && (t.__H.__h.length && st(We.push(t)), t.__H.__.some(function(e) {
603
+ t && t.__H && (t.__H.__h.length && ot(We.push(t)), t.__H.__.some(function(e) {
603
604
  e.u && (e.__H = e.u);
604
605
  })), Be = z = null;
605
606
  }, B.__c = function(e, t) {
606
607
  t.some(function(e) {
607
608
  try {
608
- e.__h.some(H), e.__h = e.__h.filter(function(e) {
609
- return !e.__ || ct(e);
609
+ e.__h.some(U), e.__h = e.__h.filter(function(e) {
610
+ return !e.__ || st(e);
610
611
  });
611
612
  } catch (n) {
612
613
  t.some(function(e) {
@@ -624,44 +625,44 @@ B.__b = function(e) {
624
625
  for (n = e.__; n && (!n.__c || !n.__c.__P);) n = n.__;
625
626
  n &&= n.__c;
626
627
  }
627
- r.__P = n, st(Ge.push(r));
628
- } else H(r);
628
+ r.__P = n, ot(Ge.push(r));
629
+ } else U(r);
629
630
  } catch (e) {
630
631
  t = e;
631
632
  }
632
633
  }), r.__H = void 0, t && B.__e(t, r.__v));
633
634
  };
634
- var at = typeof requestAnimationFrame == "function";
635
- function ot(e) {
635
+ var it = typeof requestAnimationFrame == "function";
636
+ function at(e) {
636
637
  var t, n = function() {
637
- clearTimeout(r), at && cancelAnimationFrame(t), setTimeout(e);
638
+ clearTimeout(r), it && cancelAnimationFrame(t), setTimeout(e);
638
639
  }, r = setTimeout(n, 35);
639
- at && (t = requestAnimationFrame(n));
640
+ it && (t = requestAnimationFrame(n));
640
641
  }
641
- function st(e) {
642
- e != 1 && Ve == B.requestAnimationFrame || ((Ve = B.requestAnimationFrame) || ot)(it);
642
+ function ot(e) {
643
+ e != 1 && Ve == B.requestAnimationFrame || ((Ve = B.requestAnimationFrame) || at)(rt);
643
644
  }
644
- function H(e) {
645
+ function U(e) {
645
646
  var t = z, n = e.__c;
646
647
  typeof n == "function" && (e.__c = void 0, n()), z = t;
647
648
  }
648
- function ct(e) {
649
+ function st(e) {
649
650
  var t = z;
650
651
  e.__c = e.__(), z = t;
651
652
  }
652
- function lt(e, t) {
653
+ function ct(e, t) {
653
654
  return !e || e.length != t.length || t.some(function(t, n) {
654
655
  return !He(t, e[n]);
655
656
  });
656
657
  }
657
- function ut(e, t) {
658
+ function lt(e, t) {
658
659
  return typeof t == "function" ? t(e) : t;
659
660
  }
660
661
  //#endregion
661
662
  //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
662
- var dt = 0;
663
+ var ut = 0;
663
664
  Array.isArray;
664
- function U(e, t, n, r, i, a) {
665
+ function W(e, t, n, r, i, a) {
665
666
  t ||= {};
666
667
  var o, s, c = t;
667
668
  if ("ref" in c && typeof e != "function") for (s in c = {}, t) s == "ref" ? o = t[s] : c[s] = t[s];
@@ -676,7 +677,7 @@ function U(e, t, n, r, i, a) {
676
677
  __e: null,
677
678
  __c: null,
678
679
  constructor: void 0,
679
- __v: --dt,
680
+ __v: --ut,
680
681
  __i: -1,
681
682
  __u: 0
682
683
  };
@@ -684,8 +685,8 @@ function U(e, t, n, r, i, a) {
684
685
  }
685
686
  //#endregion
686
687
  //#region src/components/icons.tsx
687
- function W({ name: e, size: t, children: n }) {
688
- return /* @__PURE__ */ U("svg", {
688
+ function G({ name: e, size: t, children: n }) {
689
+ return /* @__PURE__ */ W("svg", {
689
690
  "data-icon": e,
690
691
  "aria-hidden": "true",
691
692
  focusable: "false",
@@ -700,83 +701,83 @@ function W({ name: e, size: t, children: n }) {
700
701
  children: n
701
702
  });
702
703
  }
703
- function ft({ size: e = 26 }) {
704
- return /* @__PURE__ */ U(W, {
704
+ function dt({ size: e = 26 }) {
705
+ return /* @__PURE__ */ W(G, {
705
706
  name: "chat",
706
707
  size: e,
707
- children: [/* @__PURE__ */ U("path", { d: "M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z" }), /* @__PURE__ */ U("path", {
708
+ children: [/* @__PURE__ */ W("path", { d: "M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z" }), /* @__PURE__ */ W("path", {
708
709
  d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
709
710
  "stroke-width": "2.5"
710
711
  })]
711
712
  });
712
713
  }
713
- function pt({ size: e = 26 }) {
714
- return /* @__PURE__ */ U(W, {
714
+ function ft({ size: e = 26 }) {
715
+ return /* @__PURE__ */ W(G, {
715
716
  name: "message",
716
717
  size: e,
717
- children: /* @__PURE__ */ U("path", { d: "M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z" })
718
+ children: /* @__PURE__ */ W("path", { d: "M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z" })
718
719
  });
719
720
  }
720
- function mt({ size: e = 26 }) {
721
- return /* @__PURE__ */ U(W, {
721
+ function pt({ size: e = 26 }) {
722
+ return /* @__PURE__ */ W(G, {
722
723
  name: "sparkle",
723
724
  size: e,
724
- children: [/* @__PURE__ */ U("path", { d: "M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z" }), /* @__PURE__ */ U("path", { d: "M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z" })]
725
+ children: [/* @__PURE__ */ W("path", { d: "M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z" }), /* @__PURE__ */ W("path", { d: "M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z" })]
725
726
  });
726
727
  }
727
- function ht({ size: e = 26 }) {
728
- return /* @__PURE__ */ U(W, {
728
+ function mt({ size: e = 26 }) {
729
+ return /* @__PURE__ */ W(G, {
729
730
  name: "chevron-down",
730
731
  size: e,
731
- children: /* @__PURE__ */ U("path", { d: "M6 9l6 6 6-6" })
732
+ children: /* @__PURE__ */ W("path", { d: "M6 9l6 6 6-6" })
732
733
  });
733
734
  }
734
- function gt({ size: e = 18 }) {
735
- return /* @__PURE__ */ U(W, {
735
+ function ht({ size: e = 18 }) {
736
+ return /* @__PURE__ */ W(G, {
736
737
  name: "close",
737
738
  size: e,
738
- children: /* @__PURE__ */ U("path", { d: "M6 6l12 12M18 6L6 18" })
739
+ children: /* @__PURE__ */ W("path", { d: "M6 6l12 12M18 6L6 18" })
739
740
  });
740
741
  }
741
- var _t = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
742
- function vt({ size: e = 16 }) {
743
- return /* @__PURE__ */ U(W, {
742
+ var gt = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
743
+ function _t({ size: e = 16 }) {
744
+ return /* @__PURE__ */ W(G, {
744
745
  name: "thumb-up",
745
746
  size: e,
746
- children: /* @__PURE__ */ U("path", { d: _t })
747
+ children: /* @__PURE__ */ W("path", { d: gt })
747
748
  });
748
749
  }
749
- function yt({ size: e = 16 }) {
750
- return /* @__PURE__ */ U(W, {
750
+ function vt({ size: e = 16 }) {
751
+ return /* @__PURE__ */ W(G, {
751
752
  name: "thumb-down",
752
753
  size: e,
753
- children: /* @__PURE__ */ U("path", {
754
- d: _t,
754
+ children: /* @__PURE__ */ W("path", {
755
+ d: gt,
755
756
  transform: "matrix(1 0 0 -1 0 24)"
756
757
  })
757
758
  });
758
759
  }
759
760
  //#endregion
760
761
  //#region src/components/Launcher.tsx
761
- var bt = {
762
- chat: ft,
763
- message: pt,
764
- sparkle: mt
765
- }, xt = {
766
- "chevron-down": ht,
767
- close: gt
762
+ var yt = {
763
+ chat: dt,
764
+ message: ft,
765
+ sparkle: pt
766
+ }, bt = {
767
+ "chevron-down": mt,
768
+ close: ht
768
769
  };
769
- function St({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl: a, openIcon: o = "chevron-down", buttonRef: s, text: c = e }) {
770
- let [l, u] = $e("loading"), [d, f] = $e("loading"), p = r !== void 0 && l !== "failed", m = a !== void 0 && d !== "failed", h = p && !t && l === "loaded", g = m && t && d === "loaded", _ = bt[i] ?? ft, v = xt[o] ?? ht;
771
- return /* @__PURE__ */ U("button", {
770
+ function xt({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl: a, openIcon: o = "chevron-down", buttonRef: s, text: c = e }) {
771
+ let [l, u] = V("loading"), [d, f] = V("loading"), p = r !== void 0 && l !== "failed", m = a !== void 0 && d !== "failed", h = p && !t && l === "loaded", g = m && t && d === "loaded", _ = yt[i] ?? dt, v = bt[o] ?? mt;
772
+ return /* @__PURE__ */ W("button", {
772
773
  type: "button",
773
774
  class: "whoo-widget-launcher",
774
775
  onClick: n,
775
776
  "aria-label": t ? c.closeChat : c.openChat,
776
777
  ref: s,
777
778
  children: [
778
- t ? g ? null : /* @__PURE__ */ U(v, {}) : h ? null : /* @__PURE__ */ U(_, {}),
779
- p ? /* @__PURE__ */ U("img", {
779
+ t ? g ? null : /* @__PURE__ */ W(v, {}) : h ? null : /* @__PURE__ */ W(_, {}),
780
+ p ? /* @__PURE__ */ W("img", {
780
781
  class: "whoo-widget-launcher-icon-image",
781
782
  src: r,
782
783
  alt: "",
@@ -785,7 +786,7 @@ function St({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl:
785
786
  onLoad: () => u("loaded"),
786
787
  onError: () => u("failed")
787
788
  }) : null,
788
- m ? /* @__PURE__ */ U("img", {
789
+ m ? /* @__PURE__ */ W("img", {
789
790
  class: "whoo-widget-launcher-icon-image",
790
791
  src: a,
791
792
  alt: "",
@@ -799,7 +800,7 @@ function St({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl:
799
800
  }
800
801
  //#endregion
801
802
  //#region src/i18n/index.ts
802
- var Ct = {
803
+ var St = {
803
804
  en: e,
804
805
  fr: {
805
806
  openChat: "Ouvrir le chat",
@@ -827,7 +828,8 @@ var Ct = {
827
828
  feedbackFailed: "Impossible d’envoyer votre commentaire",
828
829
  conversationCleared: "Conversation effacée",
829
830
  genericError: "Une erreur s’est produite. Veuillez réessayer.",
830
- sessionExpired: "Cette session de chat a expiré. Rechargez la page pour continuer."
831
+ sessionExpired: "Cette session de chat a expiré. Rechargez la page pour continuer.",
832
+ opensInNewTab: "(s’ouvre dans un nouvel onglet)"
831
833
  },
832
834
  es: {
833
835
  openChat: "Abrir chat",
@@ -855,7 +857,8 @@ var Ct = {
855
857
  feedbackFailed: "No se pudieron enviar sus comentarios",
856
858
  conversationCleared: "Se inició una nueva conversación",
857
859
  genericError: "Algo salió mal. Inténtelo de nuevo.",
858
- sessionExpired: "Esta sesión de chat expiró. Vuelva a cargar la página para continuar."
860
+ sessionExpired: "Esta sesión de chat expiró. Vuelva a cargar la página para continuar.",
861
+ opensInNewTab: "(se abre en una pestaña nueva)"
859
862
  },
860
863
  pt: {
861
864
  openChat: "Abrir chat",
@@ -883,7 +886,8 @@ var Ct = {
883
886
  feedbackFailed: "Não foi possível enviar o feedback",
884
887
  conversationCleared: "Nova conversa iniciada",
885
888
  genericError: "Algo deu errado. Tente novamente.",
886
- sessionExpired: "Esta sessão de chat expirou. Recarregue a página para continuar."
889
+ sessionExpired: "Esta sessão de chat expirou. Recarregue a página para continuar.",
890
+ opensInNewTab: "(abre em uma nova aba)"
887
891
  },
888
892
  de: {
889
893
  openChat: "Chat öffnen",
@@ -911,7 +915,8 @@ var Ct = {
911
915
  feedbackFailed: "Feedback konnte nicht gesendet werden",
912
916
  conversationCleared: "Neue Unterhaltung gestartet",
913
917
  genericError: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",
914
- sessionExpired: "Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren."
918
+ sessionExpired: "Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren.",
919
+ opensInNewTab: "(öffnet sich in neuem Tab)"
915
920
  },
916
921
  it: {
917
922
  openChat: "Apri la chat",
@@ -939,7 +944,8 @@ var Ct = {
939
944
  feedbackFailed: "Impossibile inviare il feedback",
940
945
  conversationCleared: "Nuova conversazione avviata",
941
946
  genericError: "Si è verificato un errore. Riprovi.",
942
- sessionExpired: "Questa sessione di chat è scaduta. Ricarichi la pagina per continuare."
947
+ sessionExpired: "Questa sessione di chat è scaduta. Ricarichi la pagina per continuare.",
948
+ opensInNewTab: "(si apre in una nuova scheda)"
943
949
  },
944
950
  ja: {
945
951
  openChat: "チャットを開く",
@@ -967,7 +973,8 @@ var Ct = {
967
973
  feedbackFailed: "フィードバックを送信できませんでした",
968
974
  conversationCleared: "会話を消去しました",
969
975
  genericError: "エラーが発生しました。もう一度お試しください。",
970
- sessionExpired: "このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。"
976
+ sessionExpired: "このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。",
977
+ opensInNewTab: "(新しいタブで開きます)"
971
978
  },
972
979
  zh: {
973
980
  openChat: "打开聊天",
@@ -995,7 +1002,8 @@ var Ct = {
995
1002
  feedbackFailed: "反馈提交失败",
996
1003
  conversationCleared: "对话已清除",
997
1004
  genericError: "出了点问题,请重试。",
998
- sessionExpired: "此聊天会话已过期。请刷新页面后继续。"
1005
+ sessionExpired: "此聊天会话已过期。请刷新页面后继续。",
1006
+ opensInNewTab: "(将在新标签页中打开)"
999
1007
  },
1000
1008
  ru: {
1001
1009
  openChat: "Открыть чат",
@@ -1023,7 +1031,8 @@ var Ct = {
1023
1031
  feedbackFailed: "Не удалось отправить отзыв",
1024
1032
  conversationCleared: "Диалог очищен",
1025
1033
  genericError: "Что-то пошло не так. Попробуйте ещё раз.",
1026
- sessionExpired: "Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить."
1034
+ sessionExpired: "Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить.",
1035
+ opensInNewTab: "(откроется в новой вкладке)"
1027
1036
  },
1028
1037
  hi: {
1029
1038
  openChat: "चैट खोलें",
@@ -1051,7 +1060,8 @@ var Ct = {
1051
1060
  feedbackFailed: "फ़ीडबैक नहीं भेजा जा सका",
1052
1061
  conversationCleared: "बातचीत मिटा दी गई",
1053
1062
  genericError: "कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।",
1054
- sessionExpired: "यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।"
1063
+ sessionExpired: "यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।",
1064
+ opensInNewTab: "(नए टैब में खुलता है)"
1055
1065
  },
1056
1066
  ar: {
1057
1067
  openChat: "فتح الدردشة",
@@ -1079,111 +1089,141 @@ var Ct = {
1079
1089
  feedbackFailed: "تعذّر إرسال الملاحظات",
1080
1090
  conversationCleared: "تم مسح المحادثة",
1081
1091
  genericError: "حدث خطأ ما. يُرجى المحاولة مرة أخرى.",
1082
- sessionExpired: "انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة."
1092
+ sessionExpired: "انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة.",
1093
+ opensInNewTab: "(يُفتح في علامة تبويب جديدة)"
1083
1094
  }
1084
- }, wt = Object.freeze(Object.keys(Ct)), Tt = {
1095
+ }, Ct = Object.freeze(Object.keys(St)), wt = {
1085
1096
  pt: "pt-BR",
1086
1097
  es: "es-419",
1087
1098
  zh: "zh-Hans"
1088
- }, Et = /* @__PURE__ */ new Set(["ar"]), Dt = /^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i, Ot = /^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;
1089
- function kt(e) {
1090
- return Ct[e];
1099
+ }, Tt = /* @__PURE__ */ new Set(["ar"]), Et = /^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i, Dt = /^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;
1100
+ function Ot(e) {
1101
+ return St[e];
1091
1102
  }
1092
- function At(e) {
1103
+ function kt(e) {
1093
1104
  let t = e.trim();
1094
- if (!Dt.test(t) || Ot.test(t)) return null;
1105
+ if (!Et.test(t) || Dt.test(t)) return null;
1095
1106
  let n = t.split(/[-_]/)[0].toLowerCase();
1096
- return Object.hasOwn(Ct, n) ? n : null;
1107
+ return Object.hasOwn(St, n) ? n : null;
1097
1108
  }
1098
- function jt(e, t) {
1109
+ function At(e, t) {
1099
1110
  let n = null;
1100
- return e != null && e !== "" && (n = typeof e == "string" ? At(e) : null, n || console.warn(`whoo-aiden-widget: ignoring \`language\` ${Mt(e)} -- expected one of ${wt.join(", ")} (or a regional tag like pt-BR). Using the page's language instead.`)), n ??= typeof t == "string" ? At(t) : null, n ??= "en", {
1111
+ return e != null && e !== "" && (n = typeof e == "string" ? kt(e) : null, n || console.warn(`whoo-aiden-widget: ignoring \`language\` ${jt(e)} -- expected one of ${Ct.join(", ")} (or a regional tag like pt-BR). Using the page's language instead.`)), n ??= typeof t == "string" ? kt(t) : null, n ??= "en", {
1101
1112
  language: n,
1102
- tag: Tt[n] ?? n,
1103
- dir: Et.has(n) ? "rtl" : "ltr"
1113
+ tag: wt[n] ?? n,
1114
+ dir: Tt.has(n) ? "rtl" : "ltr"
1104
1115
  };
1105
1116
  }
1106
- function Mt(e) {
1117
+ function jt(e) {
1107
1118
  return typeof e == "string" ? JSON.stringify(e) : `(a ${typeof e})`;
1108
1119
  }
1109
- function Nt(e, t) {
1110
- return e.split("{name}").join(t.name);
1120
+ function Mt(e) {
1121
+ if (typeof e != "string") return null;
1122
+ let t = e.trim().replace(/_/g, "-");
1123
+ return Et.test(t) ? t : null;
1124
+ }
1125
+ function Nt(e, t, n) {
1126
+ if (e != null && e !== "") {
1127
+ let t = Mt(e);
1128
+ if (t) return t;
1129
+ console.warn(`whoo-aiden-widget: ignoring \`contentLanguage\` ${jt(e)} -- expected a language tag such as 'nl' or 'pt-BR'. Using the page's language instead.`);
1130
+ }
1131
+ return Mt(t) ?? Mt(n) ?? "";
1132
+ }
1133
+ function Pt(e) {
1134
+ let t = e.indexOf("{name}");
1135
+ return t === -1 ? {
1136
+ before: e,
1137
+ after: "",
1138
+ hasName: !1
1139
+ } : {
1140
+ before: e.slice(0, t),
1141
+ after: e.slice(t + 6),
1142
+ hasName: !0
1143
+ };
1111
1144
  }
1112
1145
  //#endregion
1113
1146
  //#region src/viewport.ts
1114
- var Pt = "(max-width: 400px), (max-height: 420px)", Ft = "data-fit-visible", It = 40;
1115
- function Lt(e) {
1147
+ var Ft = "(max-width: 400px), (max-height: 420px)", It = "data-fit-visible", Lt = 40;
1148
+ function Rt(e) {
1116
1149
  let t = typeof window < "u" ? window.visualViewport : null;
1117
1150
  if (!t) return () => {};
1118
1151
  let n = () => {
1119
- e.removeAttribute(Ft), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
1152
+ e.removeAttribute(It), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
1120
1153
  }, r = () => {
1121
1154
  let r = document.documentElement.clientHeight, i = Math.abs(t.scale - 1) > .01, a = r - t.height;
1122
- if (i || r === 0 || a < It) {
1155
+ if (i || r === 0 || a < Lt) {
1123
1156
  n();
1124
1157
  return;
1125
1158
  }
1126
- e.setAttribute(Ft, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
1159
+ e.setAttribute(It, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
1160
+ let o = e.getRootNode().activeElement;
1161
+ o && e.contains(o) && typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest" });
1127
1162
  };
1128
1163
  return r(), t.addEventListener("resize", r), t.addEventListener("scroll", r), () => {
1129
1164
  t.removeEventListener("resize", r), t.removeEventListener("scroll", r), n();
1130
1165
  };
1131
1166
  }
1132
- function Rt(e, t) {
1167
+ function zt(e, t) {
1133
1168
  return typeof e.addEventListener == "function" ? (e.addEventListener("change", t), () => e.removeEventListener("change", t)) : typeof e.addListener == "function" ? (e.addListener(t), () => e.removeListener(t)) : () => {};
1134
1169
  }
1135
- var zt = 0, Bt = "";
1136
- function Vt() {
1137
- zt++ === 0 && (Bt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
1138
- }
1170
+ var Bt = 0, Vt = "";
1139
1171
  function Ht() {
1140
- --zt === 0 && (document.documentElement.style.overflow = Bt);
1172
+ Bt++ === 0 && (Vt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
1141
1173
  }
1142
1174
  function Ut() {
1175
+ --Bt === 0 && (document.documentElement.style.overflow = Vt);
1176
+ }
1177
+ function Wt() {
1143
1178
  if (typeof window > "u" || typeof window.matchMedia != "function") return () => {};
1144
- let e = window.matchMedia(Pt), t = !1, n = () => {
1145
- e.matches && !t ? (t = !0, Vt()) : !e.matches && t && (t = !1, Ht());
1179
+ let e = window.matchMedia(Ft), t = !1, n = () => {
1180
+ e.matches && !t ? (t = !0, Ht()) : !e.matches && t && (t = !1, Ut());
1146
1181
  };
1147
1182
  n();
1148
- let r = Rt(e, n);
1183
+ let r = zt(e, n);
1149
1184
  return () => {
1150
- r(), t && (t = !1, Ht());
1185
+ r(), t && (t = !1, Ut());
1151
1186
  };
1152
1187
  }
1153
- function Wt(e) {
1188
+ function Gt(e) {
1154
1189
  if (typeof window > "u" || typeof window.matchMedia != "function" || typeof e.showModal != "function") return () => {};
1155
- let t = window.matchMedia(Pt), n = !1, r = () => {
1190
+ let t = window.matchMedia(Ft), n = !1, r = () => {
1156
1191
  if (t.matches === n || !e.isConnected) return;
1157
1192
  n = t.matches;
1158
1193
  let r = e.getRootNode().activeElement;
1159
1194
  e.close(), n ? e.showModal() : e.show(), r && e.contains(r) && r.focus({ preventScroll: !0 });
1160
1195
  };
1161
- return r(), Rt(t, r);
1196
+ return r(), zt(t, r);
1162
1197
  }
1163
1198
  //#endregion
1164
1199
  //#region src/components/Composer.tsx
1165
- function Gt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text: o = e }) {
1166
- return /* @__PURE__ */ U("div", {
1200
+ function Kt(e) {
1201
+ return e.isComposing || e.keyCode === 229;
1202
+ }
1203
+ function qt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text: o = e, contentLanguage: s }) {
1204
+ return /* @__PURE__ */ W("div", {
1167
1205
  class: "whoo-widget-composer",
1168
1206
  children: [
1169
- /* @__PURE__ */ U("label", {
1207
+ /* @__PURE__ */ W("label", {
1170
1208
  class: "whoo-widget-sr-only",
1171
1209
  for: "whoo-widget-composer-input",
1172
1210
  children: o.message
1173
1211
  }),
1174
- /* @__PURE__ */ U("input", {
1212
+ /* @__PURE__ */ W("input", {
1175
1213
  id: "whoo-widget-composer-input",
1176
1214
  class: "whoo-widget-composer-input",
1215
+ lang: s,
1216
+ autoFocus: !0,
1177
1217
  value: t,
1178
1218
  readOnly: i,
1179
1219
  "aria-disabled": i,
1180
1220
  ref: a,
1181
1221
  onInput: (e) => n(e.target.value),
1182
1222
  onKeyDown: (e) => {
1183
- e.key === "Enter" && r();
1223
+ e.key === "Enter" && !Kt(e) && r();
1184
1224
  }
1185
1225
  }),
1186
- /* @__PURE__ */ U("button", {
1226
+ /* @__PURE__ */ W("button", {
1187
1227
  type: "button",
1188
1228
  class: "whoo-widget-composer-send",
1189
1229
  "aria-disabled": i,
@@ -1197,8 +1237,8 @@ function Gt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text:
1197
1237
  }
1198
1238
  //#endregion
1199
1239
  //#region src/components/ErrorBanner.tsx
1200
- function Kt({ message: e }) {
1201
- return /* @__PURE__ */ U("div", {
1240
+ function Jt({ message: e }) {
1241
+ return /* @__PURE__ */ W("div", {
1202
1242
  class: "whoo-widget-error-banner",
1203
1243
  role: "alert",
1204
1244
  children: e
@@ -1206,8 +1246,8 @@ function Kt({ message: e }) {
1206
1246
  }
1207
1247
  //#endregion
1208
1248
  //#region src/markdown/tokenizer.ts
1209
- var qt = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, Jt = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, Yt = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Xt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, Zt = /[ \t]*[*+-][ \t]+/y, Qt = /https?:\/\/\S+/y, $t = /[.,;:!?)\]}>]+$/;
1210
- function en(e) {
1249
+ var Yt = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, K = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, Xt = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Zt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, Qt = /[ \t]*[*+-][ \t]+/y, $t = /https?:\/\/\S+/y, en = /[.,;:!?)\]}>]+$/;
1250
+ function tn(e) {
1211
1251
  let t = [], n = 0, r = 0, i = (n) => {
1212
1252
  n > r && t.push({
1213
1253
  type: "text",
@@ -1217,13 +1257,13 @@ function en(e) {
1217
1257
  });
1218
1258
  };
1219
1259
  for (; n < e.length;) {
1220
- if ((n === 0 || e[n - 1] === "\n") && (Zt.lastIndex = n, Zt.exec(e))) {
1260
+ if ((n === 0 || e[n - 1] === "\n") && (Qt.lastIndex = n, Qt.exec(e))) {
1221
1261
  i(n), t.push({
1222
1262
  type: "text",
1223
1263
  value: "• ",
1224
1264
  start: n,
1225
- end: Zt.lastIndex
1226
- }), n = Zt.lastIndex, r = n;
1265
+ end: Qt.lastIndex
1266
+ }), n = Qt.lastIndex, r = n;
1227
1267
  continue;
1228
1268
  }
1229
1269
  if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
@@ -1236,56 +1276,56 @@ function en(e) {
1236
1276
  }
1237
1277
  }
1238
1278
  if (e[n - 1] !== "!") {
1239
- qt.lastIndex = n;
1240
- let a = qt.exec(e);
1279
+ Yt.lastIndex = n;
1280
+ let a = Yt.exec(e);
1241
1281
  if (a) {
1242
1282
  i(n), t.push({
1243
1283
  type: "link",
1244
1284
  text: a[1],
1245
1285
  url: a[2],
1246
1286
  start: n,
1247
- end: qt.lastIndex
1248
- }), n = qt.lastIndex, r = n;
1287
+ end: Yt.lastIndex
1288
+ }), n = Yt.lastIndex, r = n;
1249
1289
  continue;
1250
1290
  }
1251
1291
  }
1252
- Jt.lastIndex = n;
1253
- let a = Jt.exec(e);
1292
+ K.lastIndex = n;
1293
+ let a = K.exec(e);
1254
1294
  if (a) {
1255
1295
  i(n), t.push({
1256
1296
  type: "bold",
1257
1297
  value: a[1],
1258
1298
  start: n,
1259
- end: Jt.lastIndex
1260
- }), n = Jt.lastIndex, r = n;
1299
+ end: K.lastIndex
1300
+ }), n = K.lastIndex, r = n;
1261
1301
  continue;
1262
1302
  }
1263
- Yt.lastIndex = n;
1264
- let o = Yt.exec(e);
1303
+ Xt.lastIndex = n;
1304
+ let o = Xt.exec(e);
1265
1305
  if (o) {
1266
1306
  i(n), t.push({
1267
1307
  type: "italic",
1268
1308
  value: o[1],
1269
1309
  start: n,
1270
- end: Yt.lastIndex
1271
- }), n = Yt.lastIndex, r = n;
1310
+ end: Xt.lastIndex
1311
+ }), n = Xt.lastIndex, r = n;
1272
1312
  continue;
1273
1313
  }
1274
- Xt.lastIndex = n;
1275
- let s = Xt.exec(e);
1314
+ Zt.lastIndex = n;
1315
+ let s = Zt.exec(e);
1276
1316
  if (s) {
1277
1317
  i(n), t.push({
1278
1318
  type: "italic",
1279
1319
  value: s[1],
1280
1320
  start: n,
1281
- end: Xt.lastIndex
1282
- }), n = Xt.lastIndex, r = n;
1321
+ end: Zt.lastIndex
1322
+ }), n = Zt.lastIndex, r = n;
1283
1323
  continue;
1284
1324
  }
1285
- Qt.lastIndex = n;
1286
- let c = Qt.exec(e);
1325
+ $t.lastIndex = n;
1326
+ let c = $t.exec(e);
1287
1327
  if (c) {
1288
- let e = c[0].match($t), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
1328
+ let e = c[0].match(en), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
1289
1329
  if (a.length > 0) {
1290
1330
  i(n), t.push({
1291
1331
  type: "link",
@@ -1303,8 +1343,12 @@ function en(e) {
1303
1343
  }
1304
1344
  //#endregion
1305
1345
  //#region src/markdown/render.tsx
1306
- var tn = /^[ \t]*[*+-][ \t]+(.*)$/;
1307
- function nn(e) {
1346
+ var nn = /^[ \t]*[*+-][ \t]+(.*)$/, rn = /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Adlam}\p{Script=Samaritan}\p{Script=Mandaic}\p{Script=Hanifi_Rohingya}\p{Script=Mende_Kikakui}]/u;
1347
+ function an(e) {
1348
+ let t = e.match(/\p{L}/u)?.[0];
1349
+ if (t) return rn.test(t) ? "rtl" : "ltr";
1350
+ }
1351
+ function on(e) {
1308
1352
  let t = [], n = [], r = [], i = () => {
1309
1353
  n.length > 0 && t.push({
1310
1354
  type: "text",
@@ -1317,7 +1361,7 @@ function nn(e) {
1317
1361
  }), r = [];
1318
1362
  };
1319
1363
  for (let t of e.split("\n")) {
1320
- let e = t.match(tn);
1364
+ let e = t.match(nn);
1321
1365
  e ? (i(), r.push(e[1])) : (a(), n.push(t));
1322
1366
  }
1323
1367
  return i(), a(), t.some((e) => e.type === "list") ? t.flatMap((e, n) => {
@@ -1329,34 +1373,39 @@ function nn(e) {
1329
1373
  }];
1330
1374
  }) : null;
1331
1375
  }
1332
- function G(e) {
1333
- return en(e).map((e, t) => {
1376
+ function q(e, t = {}) {
1377
+ return tn(e).map((e, n) => {
1334
1378
  switch (e.type) {
1335
- case "bold": return /* @__PURE__ */ U("strong", { children: G(e.value) }, t);
1336
- case "italic": return /* @__PURE__ */ U("em", { children: G(e.value) }, t);
1337
- case "link": return /* @__PURE__ */ U("a", {
1379
+ case "bold": return /* @__PURE__ */ W("strong", { children: q(e.value, t) }, n);
1380
+ case "italic": return /* @__PURE__ */ W("em", { children: q(e.value, t) }, n);
1381
+ case "link": return /* @__PURE__ */ W("a", {
1338
1382
  href: e.url,
1339
1383
  target: "_blank",
1340
1384
  rel: "noopener noreferrer",
1341
- children: [e.text, /* @__PURE__ */ U("span", {
1385
+ children: [e.text, /* @__PURE__ */ W("span", {
1342
1386
  class: "whoo-widget-sr-only",
1343
- children: " (opens in new tab)"
1387
+ lang: t.linkCueLang,
1388
+ children: [" ", t.linkCue ?? "(opens in new tab)"]
1344
1389
  })]
1345
- }, t);
1390
+ }, n);
1346
1391
  default: return e.value;
1347
1392
  }
1348
1393
  });
1349
1394
  }
1350
- function rn(e) {
1351
- let t = e.replace(/\r\n?/g, "\n"), n = nn(t);
1352
- return n ? n.map((e, t) => e.type === "list" ? /* @__PURE__ */ U("ul", {
1395
+ function sn(e, t = {}) {
1396
+ let n = e.replace(/\r\n?/g, "\n"), r = on(n);
1397
+ return r ? r.map((e, n) => e.type === "list" ? /* @__PURE__ */ W("ul", {
1353
1398
  class: "whoo-widget-list",
1354
- children: e.items.map((e, t) => /* @__PURE__ */ U("li", { children: G(e) }, t))
1355
- }, t) : /* @__PURE__ */ U("span", { children: G(e.text) }, t)) : G(t);
1399
+ dir: an(e.items.find((e) => an(e)) ?? ""),
1400
+ children: e.items.map((e, n) => /* @__PURE__ */ W("li", {
1401
+ dir: an(e),
1402
+ children: q(e, t)
1403
+ }, n))
1404
+ }, n) : /* @__PURE__ */ W("span", { children: q(e.text, t) }, n)) : q(n, t);
1356
1405
  }
1357
1406
  //#endregion
1358
1407
  //#region src/components/MessageFeedback.tsx
1359
- function an(e) {
1408
+ function cn(e) {
1360
1409
  return [
1361
1410
  {
1362
1411
  value: "",
@@ -1380,54 +1429,55 @@ function an(e) {
1380
1429
  }
1381
1430
  ];
1382
1431
  }
1383
- function on({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraftChange: a, onSubmitDetailed: o, onCancel: s, text: c = e }) {
1384
- let l = t.correction ?? "", u = t.category ?? "", d = V(t.status), f = V(null), p = V(null);
1385
- if (nt(() => {
1386
- let e = d.current;
1387
- if (d.current = t.status, e === t.status) return;
1432
+ function ln({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraftChange: a, onSubmitDetailed: o, onCancel: s, text: c = e, contentLanguage: l }) {
1433
+ let u = t.correction ?? "", d = t.category ?? "", f = H(t.status), p = H(null), m = H(null);
1434
+ if (tt(() => {
1435
+ let e = f.current;
1436
+ if (f.current = t.status, e === t.status) return;
1388
1437
  if (t.status === "expanded") {
1389
- f.current?.focus();
1438
+ p.current?.focus();
1390
1439
  return;
1391
1440
  }
1392
1441
  if (e === "expanded" && t.status === "idle") {
1393
- p.current?.focus();
1442
+ m.current?.focus();
1394
1443
  return;
1395
1444
  }
1396
1445
  let r = n?.current;
1397
1446
  if (!r) return;
1398
- let i = r.getRootNode();
1399
- r.contains(i.activeElement) || r.focus();
1400
- }, [t.status, n]), t.status === "expanded") return /* @__PURE__ */ U("div", {
1447
+ let i = r.getRootNode(), a = r.ownerDocument, o = i.activeElement;
1448
+ (o === null ? a.activeElement === null || a.activeElement === a.body : o === a.body) && r.focus();
1449
+ }, [t.status, n]), t.status === "expanded") return /* @__PURE__ */ W("div", {
1401
1450
  class: "whoo-widget-feedback-form",
1402
1451
  children: [
1403
- /* @__PURE__ */ U("label", { children: [/* @__PURE__ */ U("span", {
1452
+ /* @__PURE__ */ W("label", { children: [/* @__PURE__ */ W("span", {
1404
1453
  class: "whoo-widget-sr-only",
1405
1454
  children: c.additionalFeedback
1406
- }), /* @__PURE__ */ U("textarea", {
1407
- ref: f,
1455
+ }), /* @__PURE__ */ W("textarea", {
1456
+ ref: p,
1408
1457
  class: "whoo-widget-feedback-textarea",
1409
- value: l,
1410
- onInput: (e) => a(e.target.value, u),
1458
+ lang: l,
1459
+ value: u,
1460
+ onInput: (e) => a(e.target.value, d),
1411
1461
  placeholder: c.feedbackPlaceholder
1412
1462
  })] }),
1413
- /* @__PURE__ */ U("select", {
1463
+ /* @__PURE__ */ W("select", {
1414
1464
  class: "whoo-widget-feedback-select",
1415
1465
  "aria-label": c.feedbackCategory,
1416
- value: u,
1417
- onChange: (e) => a(l, e.target.value),
1418
- children: an(c).map((e) => /* @__PURE__ */ U("option", {
1466
+ value: d,
1467
+ onChange: (e) => a(u, e.target.value),
1468
+ children: cn(c).map((e) => /* @__PURE__ */ W("option", {
1419
1469
  value: e.value,
1420
1470
  children: e.label
1421
1471
  }, e.value))
1422
1472
  }),
1423
- /* @__PURE__ */ U("div", {
1473
+ /* @__PURE__ */ W("div", {
1424
1474
  class: "whoo-widget-feedback-form-buttons",
1425
- children: [/* @__PURE__ */ U("button", {
1475
+ children: [/* @__PURE__ */ W("button", {
1426
1476
  type: "button",
1427
1477
  class: "whoo-widget-feedback-submit",
1428
- onClick: () => o(l, u),
1478
+ onClick: () => o(u, d),
1429
1479
  children: c.submit
1430
- }), /* @__PURE__ */ U("button", {
1480
+ }), /* @__PURE__ */ W("button", {
1431
1481
  type: "button",
1432
1482
  class: "whoo-widget-feedback-cancel",
1433
1483
  onClick: s,
@@ -1436,105 +1486,125 @@ function on({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraft
1436
1486
  })
1437
1487
  ]
1438
1488
  });
1439
- let m = t.status === "submitting", h = t.status === "submitted";
1440
- return /* @__PURE__ */ U("div", {
1489
+ let h = t.status === "submitting", g = t.status === "submitted";
1490
+ return /* @__PURE__ */ W("div", {
1441
1491
  class: "whoo-widget-feedback",
1442
- children: [h ? null : /* @__PURE__ */ U("div", {
1492
+ children: [g ? null : /* @__PURE__ */ W("div", {
1443
1493
  class: "whoo-widget-feedback-buttons",
1444
- children: [/* @__PURE__ */ U("button", {
1494
+ children: [/* @__PURE__ */ W("button", {
1445
1495
  type: "button",
1446
1496
  "aria-label": c.goodResponse,
1447
- disabled: m,
1448
- onClick: r,
1449
- children: /* @__PURE__ */ U(vt, {})
1450
- }), /* @__PURE__ */ U("button", {
1451
- ref: p,
1497
+ "aria-disabled": h,
1498
+ onClick: () => {
1499
+ h || r();
1500
+ },
1501
+ children: /* @__PURE__ */ W(_t, {})
1502
+ }), /* @__PURE__ */ W("button", {
1503
+ ref: m,
1452
1504
  type: "button",
1453
1505
  "aria-label": c.badResponse,
1454
- disabled: m,
1455
- onClick: i,
1456
- children: /* @__PURE__ */ U(yt, {})
1506
+ "aria-disabled": h,
1507
+ onClick: () => {
1508
+ h || i();
1509
+ },
1510
+ children: /* @__PURE__ */ W(vt, {})
1457
1511
  })]
1458
- }), /* @__PURE__ */ U("div", {
1512
+ }), /* @__PURE__ */ W("div", {
1459
1513
  role: "status",
1460
- class: h ? "whoo-widget-feedback-submitted" : t.status === "error" ? "whoo-widget-feedback-error" : void 0,
1461
- children: h ? c.feedbackThanks : t.status === "error" ? c.feedbackFailed : null
1514
+ class: g ? "whoo-widget-feedback-submitted" : t.status === "error" ? "whoo-widget-feedback-error" : void 0,
1515
+ children: g ? c.feedbackThanks : t.status === "error" ? c.feedbackFailed : null
1462
1516
  })]
1463
1517
  });
1464
1518
  }
1465
1519
  //#endregion
1466
1520
  //#region src/components/MessageList.tsx
1467
- function sn({ isSlowResponse: e, text: t }) {
1468
- return /* @__PURE__ */ U("div", {
1521
+ function un({ isSlowResponse: e, text: t }) {
1522
+ return /* @__PURE__ */ W("div", {
1469
1523
  class: "whoo-widget-pending",
1470
1524
  role: "status",
1471
- children: [/* @__PURE__ */ U("span", {
1525
+ children: [/* @__PURE__ */ W("span", {
1472
1526
  class: "whoo-widget-typing",
1473
1527
  "aria-hidden": "true",
1474
1528
  children: [
1475
- /* @__PURE__ */ U("span", {}),
1476
- /* @__PURE__ */ U("span", {}),
1477
- /* @__PURE__ */ U("span", {})
1529
+ /* @__PURE__ */ W("span", {}),
1530
+ /* @__PURE__ */ W("span", {}),
1531
+ /* @__PURE__ */ W("span", {})
1478
1532
  ]
1479
- }), e ? /* @__PURE__ */ U("span", {
1533
+ }), e ? /* @__PURE__ */ W("span", {
1480
1534
  class: "whoo-widget-pending-text",
1481
1535
  children: t.lookingItUp
1482
1536
  }) : null]
1483
1537
  });
1484
1538
  }
1485
- function cn({ url: e, alt: t }) {
1486
- let [n, r] = $e(!1);
1487
- return n ? null : /* @__PURE__ */ U("img", {
1539
+ function dn({ url: e, alt: t, lang: n }) {
1540
+ let [r, i] = V(!1);
1541
+ return r ? null : /* @__PURE__ */ W("img", {
1488
1542
  class: "whoo-widget-empty-state-image",
1489
1543
  src: e,
1490
1544
  alt: t,
1545
+ lang: n,
1491
1546
  referrerpolicy: "no-referrer",
1492
- onError: () => r(!0)
1547
+ onError: () => i(!0)
1493
1548
  });
1494
1549
  }
1495
- function ln({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u, text: d }) {
1496
- let f = V(null), p = e.id;
1497
- return /* @__PURE__ */ U("div", {
1498
- ref: f,
1550
+ function fn({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u, text: d, contentLanguage: f, languageTag: p }) {
1551
+ let m = H(null), h = e.id;
1552
+ return /* @__PURE__ */ W("div", {
1553
+ ref: m,
1499
1554
  tabIndex: -1,
1500
1555
  class: `whoo-widget-message whoo-widget-message--${e.role}`,
1501
1556
  children: [
1502
- /* @__PURE__ */ U("span", {
1557
+ /* @__PURE__ */ W("span", {
1503
1558
  class: "whoo-widget-sr-only",
1504
- children: [t, ": "]
1559
+ children: [
1560
+ e.role === "assistant" ? /* @__PURE__ */ W("span", {
1561
+ lang: f,
1562
+ children: t
1563
+ }) : t,
1564
+ ":",
1565
+ " "
1566
+ ]
1505
1567
  }),
1506
- i ? /* @__PURE__ */ U(sn, {
1568
+ i ? /* @__PURE__ */ W(un, {
1507
1569
  isSlowResponse: a,
1508
1570
  text: d
1509
- }) : /* @__PURE__ */ U("div", {
1571
+ }) : /* @__PURE__ */ W("div", {
1510
1572
  class: "whoo-widget-message-text",
1511
1573
  dir: "auto",
1512
- children: rn(e.content)
1574
+ lang: f,
1575
+ children: sn(e.content, {
1576
+ linkCue: d.opensInNewTab,
1577
+ linkCueLang: p
1578
+ })
1513
1579
  }),
1514
- r && e.role === "assistant" && p ? /* @__PURE__ */ U(on, {
1580
+ r && e.role === "assistant" && h ? /* @__PURE__ */ W(ln, {
1515
1581
  state: n,
1516
- containerRef: f,
1517
- onThumbsUp: () => o(p),
1518
- onThumbsDown: () => s(p),
1519
- onDraftChange: (e, t) => c(p, e, t),
1520
- onSubmitDetailed: (e, t) => l(p, e, t),
1521
- onCancel: () => u(p),
1522
- text: d
1582
+ containerRef: m,
1583
+ onThumbsUp: () => o(h),
1584
+ onThumbsDown: () => s(h),
1585
+ onDraftChange: (e, t) => c(h, e, t),
1586
+ onSubmitDetailed: (e, t) => l(h, e, t),
1587
+ onCancel: () => u(h),
1588
+ text: d,
1589
+ contentLanguage: f
1523
1590
  }) : null
1524
1591
  ]
1525
1592
  });
1526
1593
  }
1527
- function un({ messages: t, messageFeedback: n, announcement: r, emptyStateImage: i, agentName: a = l, showFeedback: o = !1, isStreaming: s = !1, isSlowResponse: c = !1, onThumbsUp: u, onThumbsDown: d, onDraftChange: f = () => {}, onSubmitDetailed: p, onCancelFeedback: m, text: h = e }) {
1528
- let g = V(null);
1529
- return tt(() => {
1530
- let e = g.current;
1594
+ function pn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage: i, agentName: a = l, showFeedback: o = !1, isStreaming: s = !1, isSlowResponse: c = !1, onThumbsUp: u, onThumbsDown: d, onDraftChange: f = () => {}, onSubmitDetailed: p, onCancelFeedback: m, text: h = e, contentLanguage: g, languageTag: _, announcementIsContent: v = !1 }) {
1595
+ let y = H(null);
1596
+ return et(() => {
1597
+ let e = y.current;
1531
1598
  e && (e.scrollTop = e.scrollHeight);
1532
- }, [t, c]), /* @__PURE__ */ U(I, { children: [/* @__PURE__ */ U("section", {
1599
+ }, [t, c]), /* @__PURE__ */ W(I, { children: [/* @__PURE__ */ W("section", {
1533
1600
  class: "whoo-widget-message-list",
1534
- ref: g,
1601
+ ref: y,
1535
1602
  "aria-label": h.conversation,
1536
1603
  tabIndex: 0,
1537
- children: [i ? /* @__PURE__ */ U(cn, { ...i }) : null, t.map((e, r) => /* @__PURE__ */ U(ln, {
1604
+ children: [i ? /* @__PURE__ */ W(dn, {
1605
+ ...i,
1606
+ lang: g
1607
+ }) : null, t.map((e, r) => /* @__PURE__ */ W(fn, {
1538
1608
  message: e,
1539
1609
  speaker: e.role === "user" ? h.you : a,
1540
1610
  showFeedback: o,
@@ -1546,100 +1616,124 @@ function un({ messages: t, messageFeedback: n, announcement: r, emptyStateImage:
1546
1616
  onDraftChange: f,
1547
1617
  onSubmitDetailed: p,
1548
1618
  onCancelFeedback: m,
1549
- text: h
1619
+ text: h,
1620
+ contentLanguage: g,
1621
+ languageTag: _
1550
1622
  }, e.id ?? r))]
1551
- }), /* @__PURE__ */ U("div", {
1623
+ }), /* @__PURE__ */ W("div", {
1552
1624
  class: "whoo-widget-sr-only",
1553
1625
  "aria-live": "polite",
1554
1626
  "aria-atomic": "true",
1627
+ lang: v ? g : _,
1555
1628
  children: r ?? ""
1556
1629
  })] });
1557
1630
  }
1558
1631
  //#endregion
1559
1632
  //#region src/components/Panel.tsx
1560
- var dn = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1561
- function fn(e) {
1562
- return Array.from(e.querySelectorAll(dn)).filter((e) => {
1633
+ var mn = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1634
+ function hn(e) {
1635
+ return Array.from(e.querySelectorAll(mn)).filter((e) => {
1563
1636
  let t = getComputedStyle(e);
1564
1637
  return t.display !== "none" && t.visibility !== "hidden";
1565
1638
  });
1566
1639
  }
1567
- function pn({ state: e, controller: t, greeting: n }) {
1568
- let r = V(null), i = V(null);
1569
- nt(() => {
1640
+ function gn({ state: e, controller: t, greeting: n }) {
1641
+ let r = H(null), i = H(null);
1642
+ tt(() => {
1570
1643
  i.current?.focus();
1571
- }, []), nt(() => {
1572
- let e = r.current, t = e ? Lt(e) : () => {}, n = e ? Wt(e) : () => {}, i = Ut();
1644
+ }, []), tt(() => {
1645
+ let e = r.current, n = e ? Rt(e) : () => {}, i = e ? Gt(e) : () => {}, a = () => {
1646
+ e && !e.open && t.close();
1647
+ };
1648
+ e?.addEventListener("close", a);
1649
+ let o = Wt();
1573
1650
  return () => {
1574
- t(), n(), i();
1651
+ n(), i(), e?.removeEventListener("close", a), o();
1575
1652
  };
1576
1653
  }, []);
1577
1654
  let a = (e) => {
1578
- if (e.key === "Escape") {
1655
+ if (e.key === "Escape" && !Kt(e)) {
1579
1656
  e.preventDefault(), t.close();
1580
1657
  return;
1581
1658
  }
1582
1659
  if (e.key !== "Tab") return;
1583
1660
  let n = r.current;
1584
1661
  if (!n) return;
1585
- let i = fn(n);
1662
+ let i = hn(n);
1586
1663
  if (i.length === 0) return;
1587
- let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
1588
- if (!n.contains(s)) {
1589
- e.preventDefault(), a.focus();
1590
- return;
1591
- }
1592
- e.shiftKey && s === a ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), a.focus());
1664
+ let a = n.getRootNode().activeElement;
1665
+ e.preventDefault();
1666
+ let o = i.length - 1, s, c = a ? i.indexOf(a) : -1;
1667
+ if (c !== -1) s = (c + (e.shiftKey ? -1 : 1) + i.length) % i.length;
1668
+ else if (a && a !== n && n.contains(a)) {
1669
+ let t = i.findIndex((e) => a.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING);
1670
+ s = e.shiftKey ? t <= 0 ? o : t - 1 : t === -1 ? 0 : t;
1671
+ } else s = e.shiftKey ? o : 0;
1672
+ i[s].focus();
1593
1673
  }, o = () => {
1594
1674
  let n = e.draft.trim();
1595
1675
  n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
1596
- }, s = u(t.config.name) || e.agentName || "Aiden", c = u(t.config.title) || Nt(t.text.chatWith, { name: s }), l = e.messages.length === 0 && n ? [{
1676
+ }, s = u(t.config.name) || e.agentName || "Aiden", c = u(t.config.title), { before: l, after: d, hasName: f } = Pt(t.text.chatWith), p = e.messages.length === 0 && n ? [{
1597
1677
  role: "assistant",
1598
1678
  content: n,
1599
1679
  id: null
1600
- }] : e.messages, d = t.emptyStateImageUrl, f = e.messages.length === 0 && d ? {
1601
- url: d,
1680
+ }] : e.messages, m = t.emptyStateImageUrl, h = e.messages.length === 0 && m ? {
1681
+ url: m,
1602
1682
  alt: t.emptyStateImageAlt
1603
1683
  } : void 0;
1604
- return /* @__PURE__ */ U("dialog", {
1684
+ return /* @__PURE__ */ W("dialog", {
1605
1685
  open: !0,
1606
1686
  class: "whoo-widget-panel",
1607
1687
  "aria-modal": "true",
1608
- "aria-label": c,
1688
+ "aria-labelledby": "whoo-widget-title",
1609
1689
  ref: r,
1610
1690
  onKeyDown: a,
1611
1691
  onCancel: (e) => {
1612
1692
  e.preventDefault(), t.close();
1613
1693
  },
1614
1694
  children: [
1615
- /* @__PURE__ */ U("div", {
1695
+ /* @__PURE__ */ W("div", {
1616
1696
  class: "whoo-widget-header",
1617
- children: [/* @__PURE__ */ U("h2", {
1697
+ children: [c ? /* @__PURE__ */ W("h2", {
1698
+ id: "whoo-widget-title",
1618
1699
  class: "whoo-widget-header-title",
1700
+ lang: t.contentLanguage,
1701
+ dir: "auto",
1619
1702
  children: c
1620
- }), /* @__PURE__ */ U("div", {
1703
+ }) : /* @__PURE__ */ W("h2", {
1704
+ id: "whoo-widget-title",
1705
+ class: "whoo-widget-header-title",
1706
+ children: [
1707
+ l,
1708
+ f ? /* @__PURE__ */ W("bdi", {
1709
+ lang: t.contentLanguage,
1710
+ children: s
1711
+ }) : null,
1712
+ d
1713
+ ]
1714
+ }), /* @__PURE__ */ W("div", {
1621
1715
  class: "whoo-widget-header-actions",
1622
- children: [e.messages.length > 0 && /* @__PURE__ */ U("button", {
1716
+ children: [e.messages.length > 0 && /* @__PURE__ */ W("button", {
1623
1717
  type: "button",
1624
1718
  class: "whoo-widget-header-reset",
1625
1719
  onClick: () => {
1626
1720
  t.resetConversation(), i.current?.focus();
1627
1721
  },
1628
1722
  children: t.text.newConversation
1629
- }), /* @__PURE__ */ U("button", {
1723
+ }), /* @__PURE__ */ W("button", {
1630
1724
  type: "button",
1631
1725
  class: "whoo-widget-header-close",
1632
1726
  "aria-label": t.text.closeChat,
1633
1727
  onClick: () => t.close(),
1634
- children: /* @__PURE__ */ U(gt, {})
1728
+ children: /* @__PURE__ */ W(ht, {})
1635
1729
  })]
1636
1730
  })]
1637
1731
  }),
1638
- /* @__PURE__ */ U(un, {
1639
- messages: l,
1732
+ /* @__PURE__ */ W(pn, {
1733
+ messages: p,
1640
1734
  messageFeedback: e.messageFeedback,
1641
1735
  announcement: e.announcement,
1642
- emptyStateImage: f,
1736
+ emptyStateImage: h,
1643
1737
  agentName: s,
1644
1738
  showFeedback: t.showFeedback,
1645
1739
  isStreaming: e.isStreaming,
@@ -1649,27 +1743,31 @@ function pn({ state: e, controller: t, greeting: n }) {
1649
1743
  onDraftChange: (e, n, r) => t.setFeedbackDraft(e, n, r),
1650
1744
  onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
1651
1745
  onCancelFeedback: (e) => t.cancelFeedback(e),
1652
- text: t.text
1746
+ text: t.text,
1747
+ contentLanguage: t.contentLanguage,
1748
+ languageTag: t.languageTag,
1749
+ announcementIsContent: e.announcementIsContent
1653
1750
  }),
1654
- e.runtimeError && /* @__PURE__ */ U(Kt, { message: e.runtimeError }),
1655
- /* @__PURE__ */ U(Gt, {
1751
+ e.runtimeError && /* @__PURE__ */ W(Jt, { message: e.runtimeError }),
1752
+ /* @__PURE__ */ W(qt, {
1656
1753
  value: e.draft,
1657
1754
  onChange: (e) => t.setDraft(e),
1658
1755
  onSend: o,
1659
1756
  disabled: e.isStreaming,
1660
1757
  inputRef: i,
1661
- text: t.text
1758
+ text: t.text,
1759
+ contentLanguage: t.contentLanguage
1662
1760
  })
1663
1761
  ]
1664
1762
  });
1665
1763
  }
1666
1764
  //#endregion
1667
1765
  //#region src/components/App.tsx
1668
- function mn({ controller: e }) {
1669
- let [t, n] = $e(e.getState()), r = V(null), i = V(t.isOpen);
1670
- return tt(() => (n(e.getState()), e.subscribe(n)), [e]), tt(() => {
1766
+ function _n({ controller: e }) {
1767
+ let [t, n] = V(e.getState()), r = H(null), i = H(t.isOpen);
1768
+ return et(() => (n(e.getState()), e.subscribe(n)), [e]), tt(() => {
1671
1769
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
1672
- }, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ U(I, { children: [/* @__PURE__ */ U(St, {
1770
+ }, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ W(I, { children: [/* @__PURE__ */ W(xt, {
1673
1771
  isOpen: t.isOpen,
1674
1772
  onClick: () => t.isOpen ? e.close() : e.open(),
1675
1773
  iconUrl: e.launcher.iconUrl,
@@ -1678,7 +1776,7 @@ function mn({ controller: e }) {
1678
1776
  openIcon: e.launcher.openIcon,
1679
1777
  buttonRef: r,
1680
1778
  text: e.text
1681
- }), t.isOpen && /* @__PURE__ */ U(pn, {
1779
+ }), t.isOpen && /* @__PURE__ */ W(gn, {
1682
1780
  state: t,
1683
1781
  controller: e,
1684
1782
  greeting: e.config.greeting
@@ -1686,44 +1784,44 @@ function mn({ controller: e }) {
1686
1784
  }
1687
1785
  //#endregion
1688
1786
  //#region src/api/client.ts
1689
- var hn = class extends Error {
1787
+ var vn = class extends Error {
1690
1788
  status;
1691
1789
  constructor(e, t) {
1692
1790
  super(e), this.name = "WidgetApiError", this.status = t;
1693
1791
  }
1694
1792
  };
1695
- function gn(e) {
1793
+ function yn(e) {
1696
1794
  if (typeof e != "string") return null;
1697
1795
  let t = e.trim();
1698
1796
  return t === "" ? null : t;
1699
1797
  }
1700
- async function _n(e, t) {
1798
+ async function bn(e, t) {
1701
1799
  let n = await fetch(`${e}/api/v1/widget/session`, {
1702
1800
  method: "POST",
1703
1801
  headers: { "Content-Type": "application/json" },
1704
1802
  body: JSON.stringify({ publishable_key: t })
1705
1803
  });
1706
- if (!n.ok) throw new hn(`Failed to create widget session (${n.status})`, n.status);
1804
+ if (!n.ok) throw new vn(`Failed to create widget session (${n.status})`, n.status);
1707
1805
  let r = await n.json();
1708
1806
  return {
1709
1807
  token: r.token,
1710
- ...vn(r)
1808
+ ...xn(r)
1711
1809
  };
1712
1810
  }
1713
- function vn(e) {
1811
+ function xn(e) {
1714
1812
  return {
1715
- primaryColor: gn(e.primary_color),
1716
- name: gn(e.name),
1717
- accentColor: gn(e.accent_color),
1718
- inkColor: gn(e.ink_color)
1813
+ primaryColor: yn(e.primary_color),
1814
+ name: yn(e.name),
1815
+ accentColor: yn(e.accent_color),
1816
+ inkColor: yn(e.ink_color)
1719
1817
  };
1720
1818
  }
1721
- async function yn(e, t) {
1819
+ async function Sn(e, t) {
1722
1820
  let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
1723
- if (!n.ok) throw new hn(`Failed to load widget branding (${n.status})`, n.status);
1724
- return vn(await n.json());
1821
+ if (!n.ok) throw new vn(`Failed to load widget branding (${n.status})`, n.status);
1822
+ return xn(await n.json());
1725
1823
  }
1726
- async function bn(e, t, n) {
1824
+ async function Cn(e, t, n) {
1727
1825
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
1728
1826
  method: "POST",
1729
1827
  headers: {
@@ -1737,11 +1835,11 @@ async function bn(e, t, n) {
1737
1835
  category: n.category ?? null
1738
1836
  })
1739
1837
  });
1740
- if (!r.ok) throw new hn(`Feedback submission failed (${r.status})`, r.status);
1838
+ if (!r.ok) throw new vn(`Feedback submission failed (${r.status})`, r.status);
1741
1839
  }
1742
1840
  //#endregion
1743
1841
  //#region src/api/sse.ts
1744
- async function* xn(e, t, n, r, i) {
1842
+ async function* wn(e, t, n, r, i) {
1745
1843
  let a = await fetch(`${e}/api/v1/widget/chat`, {
1746
1844
  method: "POST",
1747
1845
  headers: {
@@ -1754,7 +1852,7 @@ async function* xn(e, t, n, r, i) {
1754
1852
  }),
1755
1853
  signal: i
1756
1854
  });
1757
- if (!a.ok || !a.body) throw new hn(`Chat request failed (${a.status})`, a.status);
1855
+ if (!a.ok || !a.body) throw new vn(`Chat request failed (${a.status})`, a.status);
1758
1856
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
1759
1857
  for (;;) {
1760
1858
  let { done: e, value: t } = await o.read();
@@ -1765,11 +1863,12 @@ async function* xn(e, t, n, r, i) {
1765
1863
  let e = c.slice(0, n);
1766
1864
  c = c.slice(n + 2);
1767
1865
  let t = e.split("\n").find((e) => e.startsWith("data: "));
1768
- t && (yield Sn(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1866
+ if (i?.aborted) return;
1867
+ t && (yield Tn(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1769
1868
  }
1770
1869
  }
1771
1870
  }
1772
- function Sn(e) {
1871
+ function Tn(e) {
1773
1872
  return typeof e.error == "string" ? {
1774
1873
  type: "error",
1775
1874
  error: e.error,
@@ -1792,11 +1891,11 @@ function Sn(e) {
1792
1891
  }
1793
1892
  //#endregion
1794
1893
  //#region src/markdown/plainText.ts
1795
- function Cn(e) {
1796
- return en(e.replace(/\r\n?/g, "\n")).map((e) => {
1894
+ function En(e) {
1895
+ return tn(e.replace(/\r\n?/g, "\n")).map((e) => {
1797
1896
  switch (e.type) {
1798
1897
  case "bold":
1799
- case "italic": return Cn(e.value);
1898
+ case "italic": return En(e.value);
1800
1899
  case "link": return e.text;
1801
1900
  default: return e.value;
1802
1901
  }
@@ -1804,16 +1903,16 @@ function Cn(e) {
1804
1903
  }
1805
1904
  //#endregion
1806
1905
  //#region src/markdown/reveal.ts
1807
- var wn = 40, Tn = 120;
1808
- function En(e) {
1906
+ var Dn = 40, On = 120;
1907
+ function kn(e) {
1809
1908
  let t = [];
1810
- for (let n of en(e)) if (n.type === "text") {
1909
+ for (let n of tn(e)) if (n.type === "text") {
1811
1910
  let e = n.value.split(/(\s+)/), r = n.start;
1812
1911
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
1813
1912
  } else t.push(n.end);
1814
1913
  return t;
1815
1914
  }
1816
- function Dn(e) {
1915
+ function An(e) {
1817
1916
  let t = null;
1818
1917
  return e?.addEventListener("abort", () => {
1819
1918
  t?.();
@@ -1828,14 +1927,14 @@ function Dn(e) {
1828
1927
  });
1829
1928
  };
1830
1929
  }
1831
- async function On(e, t, n) {
1832
- let r = n?.wordIntervalMs ?? wn, i = n?.tokenIntervalMs ?? Tn, a = n?.signal, o = en(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = Dn(a), l = "";
1833
- for (let n of En(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1930
+ async function jn(e, t, n) {
1931
+ let r = n?.wordIntervalMs ?? Dn, i = n?.tokenIntervalMs ?? On, a = n?.signal, o = tn(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = An(a), l = "";
1932
+ for (let n of kn(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1834
1933
  l !== e && t(e);
1835
1934
  }
1836
1935
  //#endregion
1837
1936
  //#region src/sessionToken.ts
1838
- function kn(e) {
1937
+ function Mn(e) {
1839
1938
  let t = e.split(".");
1840
1939
  if (t.length !== 3 || t.some((e) => e === "")) return null;
1841
1940
  let n = t[1];
@@ -1849,45 +1948,45 @@ function kn(e) {
1849
1948
  return null;
1850
1949
  }
1851
1950
  }
1852
- function An(e) {
1853
- let t = kn(e)?.exp;
1951
+ function Nn(e) {
1952
+ let t = Mn(e)?.exp;
1854
1953
  return typeof t == "number" ? t * 1e3 : null;
1855
1954
  }
1856
- function jn(e, t = Date.now()) {
1857
- let n = An(e);
1955
+ function Pn(e, t = Date.now()) {
1956
+ let n = Nn(e);
1858
1957
  return n !== null && n <= t;
1859
1958
  }
1860
- function Mn(e, t = Date.now()) {
1861
- let n = kn(e);
1959
+ function Fn(e, t = Date.now()) {
1960
+ let n = Mn(e);
1862
1961
  return n?.exp == null ? null : n.iat != null && n.exp > n.iat ? t + (n.exp - n.iat) * 1e3 : n.exp * 1e3;
1863
1962
  }
1864
1963
  //#endregion
1865
1964
  //#region src/storage.ts
1866
- function Nn(e) {
1965
+ function In(e) {
1867
1966
  return `whoo-aiden-widget:conversation:${e}`;
1868
1967
  }
1869
- function Pn(e) {
1968
+ function Ln(e) {
1870
1969
  try {
1871
- return window.sessionStorage.getItem(Nn(e));
1970
+ return window.sessionStorage.getItem(In(e));
1872
1971
  } catch {
1873
1972
  return null;
1874
1973
  }
1875
1974
  }
1876
- function Fn(e, t) {
1975
+ function Rn(e, t) {
1877
1976
  try {
1878
- window.sessionStorage.setItem(Nn(e), t);
1977
+ window.sessionStorage.setItem(In(e), t);
1879
1978
  } catch {}
1880
1979
  }
1881
- function In(e) {
1980
+ function zn(e) {
1882
1981
  try {
1883
- window.sessionStorage.removeItem(Nn(e));
1982
+ window.sessionStorage.removeItem(In(e));
1884
1983
  } catch {}
1885
1984
  }
1886
1985
  //#endregion
1887
1986
  //#region src/theme.ts
1888
- var Ln = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1889
- function Rn(e) {
1890
- if (Ln.test(e.trim())) return null;
1987
+ var Bn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1988
+ function Vn(e) {
1989
+ if (Bn.test(e.trim())) return null;
1891
1990
  let t = document.createElement("div");
1892
1991
  if (t.style.color = e, t.style.color === "") return null;
1893
1992
  let n = document.createElement("div");
@@ -1906,69 +2005,69 @@ function Rn(e) {
1906
2005
  translucent: a < 1
1907
2006
  };
1908
2007
  }
1909
- function K(e) {
1910
- return Rn(e)?.rgb ?? null;
2008
+ function J(e) {
2009
+ return Vn(e)?.rgb ?? null;
1911
2010
  }
1912
- function q([e, t, n]) {
2011
+ function Y([e, t, n]) {
1913
2012
  let r = (e) => {
1914
2013
  let t = e / 255;
1915
2014
  return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
1916
2015
  };
1917
2016
  return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
1918
2017
  }
1919
- function zn(e, t) {
2018
+ function Hn(e, t) {
1920
2019
  let n = Math.max(e, t), r = Math.min(e, t);
1921
2020
  return (n + .05) / (r + .05);
1922
2021
  }
1923
- function Bn(e) {
1924
- let t = K(e);
2022
+ function Un(e) {
2023
+ let t = J(e);
1925
2024
  if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1926
- let n = q(t);
1927
- return zn(n, q([
2025
+ let n = Y(t);
2026
+ return Hn(n, Y([
1928
2027
  0,
1929
2028
  0,
1930
2029
  0
1931
- ])) >= zn(n, q([
2030
+ ])) >= Hn(n, Y([
1932
2031
  255,
1933
2032
  255,
1934
2033
  255
1935
2034
  ])) ? "#000000" : "#ffffff";
1936
2035
  }
1937
- function Vn(e, t) {
1938
- let n = K(e), r = K(t);
1939
- return !n || !r ? NaN : zn(q(n), q(r));
2036
+ function Wn(e, t) {
2037
+ let n = J(e), r = J(t);
2038
+ return !n || !r ? NaN : Hn(Y(n), Y(r));
1940
2039
  }
1941
- var Hn = i.primary, Un = i.panel, Wn = i.assistantBubble, Gn = i.headerHover, Kn = 4.5;
1942
- function J([e, t, n]) {
2040
+ var Gn = i.primary, Kn = i.panel, qn = i.assistantBubble, Jn = i.headerHover, Yn = 4.5;
2041
+ function Xn([e, t, n]) {
1943
2042
  return `#${[
1944
2043
  e,
1945
2044
  t,
1946
2045
  n
1947
2046
  ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
1948
2047
  }
1949
- function qn(e, t = Un) {
1950
- let n = K(e), r = K(t);
1951
- if (!n || !r) return Hn;
1952
- let i = q(r), a = (e) => zn(q(e), i) >= Kn;
1953
- if (a(n)) return J(n);
2048
+ function Zn(e, t = Kn) {
2049
+ let n = J(e), r = J(t);
2050
+ if (!n || !r) return Gn;
2051
+ let i = Y(r), a = (e) => Hn(Y(e), i) >= Yn;
2052
+ if (a(n)) return Xn(n);
1954
2053
  for (let e = .99; e > 0; e -= .01) {
1955
2054
  let t = n.map((t) => Math.round(t * e));
1956
- if (a(t)) return J(t);
2055
+ if (a(t)) return Xn(t);
1957
2056
  }
1958
2057
  return "#000000";
1959
2058
  }
1960
- var Jn = i.ink, Yn = i.link;
1961
- function Y(e) {
2059
+ var Qn = i.ink, $n = i.link;
2060
+ function X(e) {
1962
2061
  if (typeof e != "string" || !e) return null;
1963
- let t = Rn(e);
1964
- return t ? J(t.rgb) : null;
2062
+ let t = Vn(e);
2063
+ return t ? Xn(t.rgb) : null;
1965
2064
  }
1966
- function Xn(e) {
2065
+ function er(e) {
1967
2066
  if (typeof e != "string" || !e) return null;
1968
- let t = Rn(e);
1969
- return t ? t.translucent ? e.trim() : J(t.rgb) : null;
2067
+ let t = Vn(e);
2068
+ return t ? t.translucent ? e.trim() : Xn(t.rgb) : null;
1970
2069
  }
1971
- var Zn = [
2070
+ var tr = [
1972
2071
  {
1973
2072
  role: "onPrimary",
1974
2073
  against: ["primary"],
@@ -2020,8 +2119,8 @@ var Zn = [
2020
2119
  required: 3
2021
2120
  }
2022
2121
  ];
2023
- function X({ color: e, inkColor: t, accentColor: n, overrides: a }) {
2024
- let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => Xn(o[e]), c = Y(e), l = s("primary"), u = l ?? c ?? Hn, d = s("primaryText"), f = d ?? qn(u, Gn), p = s("onPrimary") ?? Bn(u), m = Y(t), h = s("ink") ?? (m ? qn(m, Wn) : Jn), g = Y(n), _ = s("link") ?? (g ? qn(g, Wn) : Yn), v = (e) => s(e) ?? i[e], y = {
2122
+ function Z({ color: e, inkColor: t, accentColor: n, overrides: a }) {
2123
+ let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => er(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? Gn, d = s("primaryText"), f = d ?? Zn(u, Jn), p = s("onPrimary") ?? Un(u), m = X(t), h = s("ink") ?? (m ? Zn(m, qn) : Qn), g = X(n), _ = s("link") ?? (g ? Zn(g, qn) : $n), v = (e) => s(e) ?? i[e], y = {
2025
2124
  primary: u,
2026
2125
  onPrimary: p,
2027
2126
  primaryText: f,
@@ -2039,9 +2138,9 @@ function X({ color: e, inkColor: t, accentColor: n, overrides: a }) {
2039
2138
  inputBorder: v("inputBorder"),
2040
2139
  focusRing: v("focusRing")
2041
2140
  }, b = Object.fromEntries(r.map((e) => [e, s(e) !== null])), x = [];
2042
- for (let { role: e, against: t, required: n } of Zn) for (let r of t) {
2141
+ for (let { role: e, against: t, required: n } of tr) for (let r of t) {
2043
2142
  if (!b[e] && !b[r]) continue;
2044
- let t = Vn(y[e], y[r]);
2143
+ let t = Wn(y[e], y[r]);
2045
2144
  Number.isFinite(t) && t < n && x.push({
2046
2145
  role: e,
2047
2146
  against: r,
@@ -2067,71 +2166,92 @@ function X({ color: e, inkColor: t, accentColor: n, overrides: a }) {
2067
2166
  contrastWarnings: x
2068
2167
  };
2069
2168
  }
2070
- function Z(e) {
2169
+ function Q(e) {
2071
2170
  return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
2072
2171
  }
2073
- function Qn(e, t, n = Hn) {
2172
+ function nr(e, t, n = Gn) {
2074
2173
  let r = t;
2075
- Y(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Z(t)} as the theme color; falling back to ${Z(n)}.`), r = n);
2076
- let i = X({ color: r });
2174
+ X(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`), r = n);
2175
+ let i = Z({ color: r });
2077
2176
  e.style.setProperty("--whoo-widget-color", i.primary), e.style.setProperty("--whoo-widget-text-on-color", i.textOnPrimary), e.style.setProperty("--whoo-widget-color-text", i.primaryAsText);
2078
2177
  }
2079
- function $n(e, { inkColor: t, accentColor: n }) {
2080
- let r = X({
2178
+ function rr(e, { inkColor: t, accentColor: n }) {
2179
+ let r = Z({
2081
2180
  inkColor: t,
2082
2181
  accentColor: n
2083
2182
  });
2084
2183
  e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
2085
2184
  }
2086
- function er(e, t) {
2087
- let n = X({ overrides: t });
2185
+ function ir(e, t) {
2186
+ let n = Z({ overrides: t });
2088
2187
  for (let t of r) {
2089
2188
  let r = n.overridden.primary && (t === "onPrimary" || t === "primaryText");
2090
2189
  (n.overridden[t] || r) && e.style.setProperty(a[t], n.roles[t]);
2091
2190
  }
2092
2191
  }
2093
- function tr(e, t) {
2094
- e && Y(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Z(e)} as the ${t}; using the default.`);
2192
+ function ar(e, t) {
2193
+ e && X(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`);
2095
2194
  }
2096
- function nr(e, t, n) {
2195
+ function or(e, t, n) {
2097
2196
  for (let e of r) {
2098
2197
  let n = t[e];
2099
- n && Y(n) === null && console.warn(`[whoo-aiden-widget] Could not use ${Z(n)} as theme.colors.${e}; using the calculated color.`);
2198
+ n && X(n) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(n)} as theme.colors.${e}; using the calculated color.`);
2100
2199
  }
2101
2200
  let i = t.primary;
2102
- typeof i == "string" && Rn(i)?.translucent && console.warn(`[whoo-aiden-widget] theme.colors.primary ${Z(i)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`), rr({
2201
+ typeof i == "string" && Vn(i)?.translucent && console.warn(`[whoo-aiden-widget] theme.colors.primary ${Q(i)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`), sr({
2103
2202
  color: e.color,
2104
2203
  inkColor: e.inkColor,
2105
2204
  accentColor: e.accentColor,
2106
2205
  overrides: t
2107
2206
  }, n);
2108
2207
  }
2109
- function rr(e, t) {
2110
- for (let n of X(e).contrastWarnings) {
2208
+ function sr(e, t) {
2209
+ for (let n of Z(e).contrastWarnings) {
2111
2210
  let { role: e, against: r, value: i, ratio: a, required: o, overridden: s } = n, c = `${e}|${r}|${i}`;
2112
2211
  t.has(c) || (t.add(c), console.warn(s ? `[whoo-aiden-widget] theme.colors.${e} (${i}) has ${a.toFixed(2)}:1 contrast against the ${r} color; ${o}:1 is recommended. Using it as given.` : `[whoo-aiden-widget] the ${e} color (${i}) has ${a.toFixed(2)}:1 contrast against your theme.colors.${r}; ${o}:1 is recommended. Override theme.colors.${e} too.`));
2113
2212
  }
2114
2213
  }
2115
- function ir(e, t, n = /* @__PURE__ */ new Set()) {
2116
- Qn(e, t.color ?? Hn), tr(t.inkColor, "ink color"), tr(t.accentColor, "accent color"), $n(e, {
2214
+ function cr(e, t, n = /* @__PURE__ */ new Set()) {
2215
+ nr(e, t.color ?? Gn), ar(t.inkColor, "ink color"), ar(t.accentColor, "accent color"), rr(e, {
2117
2216
  inkColor: t.inkColor,
2118
2217
  accentColor: t.accentColor
2119
2218
  });
2120
2219
  let r = te(t.theme);
2121
- nr(t, r.colors, n), er(e, r.colors), r.fontFamily && e.style.setProperty("--whoo-widget-font", r.fontFamily);
2220
+ or(t, r.colors, n), ir(e, r.colors), r.fontFamily && e.style.setProperty("--whoo-widget-font", r.fontFamily);
2122
2221
  }
2123
2222
  //#endregion
2124
2223
  //#region src/controller.ts
2125
- var ar = 8e3, or = 3e3, Q = class extends Error {
2224
+ var lr = 8e3, ur = 3e3, dr = 15e3, fr = class extends Error {
2225
+ name = "SessionUnavailableError";
2226
+ };
2227
+ function pr(e, t) {
2228
+ return t ? new Promise((n, r) => {
2229
+ let i = () => r(new DOMException("Aborted", "AbortError"));
2230
+ if (t.aborted) return i();
2231
+ t.addEventListener("abort", i, { once: !0 }), e.then((e) => {
2232
+ t.removeEventListener("abort", i), n(e);
2233
+ }, (e) => {
2234
+ t.removeEventListener("abort", i), r(e);
2235
+ });
2236
+ }) : e;
2237
+ }
2238
+ function mr(e, t) {
2239
+ return e === "refused" ? new gr(t) : new fr();
2240
+ }
2241
+ function hr(e) {
2242
+ let t = e?.status;
2243
+ return t === 401 || t === 403 || t === 404;
2244
+ }
2245
+ var gr = class extends Error {
2126
2246
  name = "SessionExpiredError";
2127
2247
  constructor(e) {
2128
2248
  super(e instanceof Error ? e.message : "The session has expired.");
2129
2249
  }
2130
2250
  };
2131
- function sr(e) {
2251
+ function _r(e) {
2132
2252
  return e?.status === 401;
2133
2253
  }
2134
- function cr(e, t) {
2254
+ function vr(e, t) {
2135
2255
  return new Promise((n) => {
2136
2256
  let r = setTimeout(n, t);
2137
2257
  e.then(() => {
@@ -2139,13 +2259,15 @@ function cr(e, t) {
2139
2259
  });
2140
2260
  });
2141
2261
  }
2142
- var lr = class {
2262
+ var yr = class {
2143
2263
  config;
2144
2264
  state;
2145
2265
  listeners = /* @__PURE__ */ new Set();
2146
2266
  sessionToken = null;
2147
2267
  sessionTokenExpiresAt = null;
2148
2268
  tokenRenewal = null;
2269
+ renewalGeneration = 0;
2270
+ sendEpoch = 0;
2149
2271
  getSessionToken;
2150
2272
  conversationId = null;
2151
2273
  storageIdentifier;
@@ -2160,6 +2282,7 @@ var lr = class {
2160
2282
  text;
2161
2283
  language;
2162
2284
  languageTag;
2285
+ contentLanguage;
2163
2286
  dir;
2164
2287
  constructor(e) {
2165
2288
  this.config = e;
@@ -2168,9 +2291,9 @@ var lr = class {
2168
2291
  ...t,
2169
2292
  ...r ? { iconUrl: r } : {}
2170
2293
  }, this.launcherIconUrl = r, this.emptyStateImageUrl = n(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.showFeedback = e.showFeedback === !0, this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.getSessionToken = p(e);
2171
- let { language: i, tag: a, dir: o } = jt(e.language, typeof document > "u" ? void 0 : document.documentElement.lang);
2172
- this.language = i, this.languageTag = a, this.dir = o, this.text = {
2173
- ...kt(i),
2294
+ let { language: i, tag: a, dir: o } = At(e.language, typeof document > "u" ? void 0 : document.documentElement.lang);
2295
+ this.language = i, this.languageTag = a, this.dir = o, this.contentLanguage = Nt(e.contentLanguage, typeof document > "u" ? void 0 : document.documentElement.lang, e.language), this.text = {
2296
+ ...Ot(i),
2174
2297
  ...y(e.messages)
2175
2298
  }, this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
2176
2299
  isOpen: !1,
@@ -2185,6 +2308,7 @@ var lr = class {
2185
2308
  accentColor: null,
2186
2309
  inkColor: null,
2187
2310
  announcement: null,
2311
+ announcementIsContent: !1,
2188
2312
  isSlowResponse: !1,
2189
2313
  draft: ""
2190
2314
  };
@@ -2217,12 +2341,12 @@ var lr = class {
2217
2341
  let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
2218
2342
  try {
2219
2343
  if (this.config.sessionToken) {
2220
- if (jn(this.config.sessionToken)) {
2221
- if (!await this.renewToken()) throw Error("The sessionToken has expired.");
2222
- } else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt = An(this.config.sessionToken);
2344
+ if (Pn(this.config.sessionToken)) {
2345
+ if (!("token" in await this.renewToken())) throw Error("The sessionToken has expired.");
2346
+ } else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt = Nn(this.config.sessionToken);
2223
2347
  } else if (this.config.publishableKey) {
2224
- let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await _n(e, this.config.publishableKey);
2225
- this.sessionToken = t, this.sessionTokenExpiresAt = Mn(t), this.setState({
2348
+ let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await bn(e, this.config.publishableKey);
2349
+ this.sessionToken = t, this.sessionTokenExpiresAt = Fn(t), this.setState({
2226
2350
  primaryColor: n,
2227
2351
  agentName: r,
2228
2352
  accentColor: i,
@@ -2233,13 +2357,13 @@ var lr = class {
2233
2357
  console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
2234
2358
  return;
2235
2359
  }
2236
- this.conversationId = Pn(this.storageIdentifier), this.config.sessionToken && await cr(this.loadBranding(e), or);
2360
+ this.conversationId = Ln(this.storageIdentifier), this.config.sessionToken && await vr(this.loadBranding(e), ur);
2237
2361
  }
2238
2362
  async loadBranding(e) {
2239
2363
  try {
2240
2364
  let t = this.config;
2241
- if (Y(t.color) && Y(t.inkColor) && Y(t.accentColor) && u(t.name)) return;
2242
- let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) => yn(e, t));
2365
+ if (X(t.color) && X(t.inkColor) && X(t.accentColor) && u(t.name)) return;
2366
+ let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) => Sn(e, t));
2243
2367
  this.setState({
2244
2368
  primaryColor: n,
2245
2369
  agentName: r,
@@ -2248,34 +2372,37 @@ var lr = class {
2248
2372
  });
2249
2373
  } catch (e) {
2250
2374
  let t = e?.status;
2251
- (e instanceof Q || t === 401 || t === 403) && (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) }));
2375
+ (e instanceof gr || t === 401 || t === 403) && (this.state.isInitializing ? (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) })) : (console.error("[whoo-aiden-widget] the session was refused after start-up:", e), this.setState({ runtimeError: this.text.sessionExpired })));
2252
2376
  }
2253
2377
  }
2254
2378
  open() {
2255
2379
  this.setState({ isOpen: !0 });
2256
2380
  }
2257
2381
  resetConversation() {
2258
- this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, In(this.storageIdentifier), this.setState({
2382
+ this.sendEpoch += 1, this.activeRequestController?.abort("reset"), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, zn(this.storageIdentifier), this.setState({
2259
2383
  messages: [],
2260
2384
  messageFeedback: {},
2261
2385
  runtimeError: null,
2262
2386
  isStreaming: !1,
2263
- announcement: this.text.conversationCleared
2387
+ announcement: this.text.conversationCleared,
2388
+ announcementIsContent: !1
2264
2389
  });
2265
2390
  }
2266
2391
  setDraft(e) {
2267
2392
  this.setState({ draft: e });
2268
2393
  }
2269
2394
  close() {
2270
- this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
2395
+ this.activeRequestController?.abort("close"), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
2271
2396
  }
2272
2397
  async sendMessage(e) {
2273
2398
  if (!this.sessionToken) return;
2274
- let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com", n = {
2399
+ let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
2400
+ this.sendEpoch += 1;
2401
+ let n = this.sendEpoch, r = () => n === this.sendEpoch, i = {
2275
2402
  role: "user",
2276
2403
  content: e,
2277
2404
  id: null
2278
- }, r = {
2405
+ }, a = {
2279
2406
  role: "assistant",
2280
2407
  content: "",
2281
2408
  id: null
@@ -2283,58 +2410,63 @@ var lr = class {
2283
2410
  this.setState({
2284
2411
  messages: [
2285
2412
  ...this.state.messages,
2286
- n,
2287
- r
2413
+ i,
2414
+ a
2288
2415
  ],
2289
2416
  isStreaming: !0,
2290
2417
  runtimeError: null,
2291
2418
  announcement: null
2292
2419
  });
2293
- let i = r, a = (e) => {
2294
- let t = i;
2295
- i = {
2296
- ...i,
2420
+ let o = a, s = (e) => {
2421
+ let t = o;
2422
+ o = {
2423
+ ...o,
2297
2424
  ...e
2298
- }, this.setState({ messages: this.state.messages.map((e) => e === t ? i : e) });
2299
- }, o = (e) => a({ content: e });
2300
- this.activeRequestController = new AbortController();
2301
- let { signal: s } = this.activeRequestController;
2425
+ }, this.setState({ messages: this.state.messages.map((e) => e === t ? o : e) });
2426
+ }, c = (e) => s({ content: e }), l = new AbortController();
2427
+ this.activeRequestController = l;
2428
+ let { signal: u } = l, d = !1;
2302
2429
  this.slowResponseTimer = setTimeout(() => {
2303
2430
  this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
2304
- }, ar);
2305
- let c = (t = this.text.genericError) => {
2306
- this.setState({
2307
- runtimeError: t,
2308
- ...this.state.draft === "" ? { draft: e } : {}
2309
- });
2310
- }, l = "";
2431
+ }, lr);
2432
+ let f = !1, p = () => {
2433
+ this.state.draft === "" && (f = !0, this.setState({ draft: e }));
2434
+ }, m = (e = this.text.genericError) => {
2435
+ r() && (this.setState({ runtimeError: e }), p());
2436
+ }, h = "";
2311
2437
  try {
2312
- let { stream: n, first: r } = await this.withSession(async (n) => {
2313
- let r = xn(t, n, this.conversationId, e, s);
2438
+ let { stream: n, first: i } = await this.withSession(async (n) => {
2439
+ d = !0;
2440
+ let r = wn(t, n, this.conversationId, e, u);
2314
2441
  return {
2315
2442
  stream: r,
2316
2443
  first: await r.next()
2317
2444
  };
2318
- });
2319
- for (let e = r; !e.done; e = await n.next()) {
2445
+ }, u);
2446
+ for (let e = i; !e.done && !u.aborted && r(); e = await n.next()) {
2320
2447
  let t = e.value;
2321
- if (t.type === "conversation_id") this.conversationId = t.conversationId, Fn(this.storageIdentifier, t.conversationId);
2322
- else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await On(t.delta, (e) => o(e), { signal: s }), l = t.delta) : t.verbatim ? (l = t.delta, o(l)) : (l += t.delta, o(l));
2323
- else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId, Fn(this.storageIdentifier, t.conversationId)), t.messageId && a({ id: t.messageId }), this.setState({ announcement: Cn(l) });
2448
+ if (t.type === "conversation_id") this.conversationId = t.conversationId, Rn(this.storageIdentifier, t.conversationId);
2449
+ else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await jn(t.delta, (e) => c(e), { signal: u }), h = t.delta) : t.verbatim ? (h = t.delta, c(h)) : (h += t.delta, c(h));
2450
+ else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId, Rn(this.storageIdentifier, t.conversationId)), t.messageId && s({ id: t.messageId }), r() && this.setState({
2451
+ announcement: En(h),
2452
+ announcementIsContent: !0
2453
+ });
2324
2454
  else if (t.type === "error") {
2325
- console.error("[whoo-aiden-widget] chat error:", t.error), c(), this.activeRequestController?.abort();
2455
+ console.error("[whoo-aiden-widget] chat error:", t.error), h.trim() !== "" && r() && this.setState({
2456
+ announcement: En(h),
2457
+ announcementIsContent: !0
2458
+ }), m(), l.abort();
2326
2459
  break;
2327
2460
  }
2328
2461
  }
2329
2462
  } catch (e) {
2330
- e?.name === "AbortError" || (e instanceof Q ? (console.error("[whoo-aiden-widget] chat request failed: the session has expired.", e), c(this.text.sessionExpired)) : (console.error("[whoo-aiden-widget] chat request failed:", e), c()));
2463
+ u.aborted ? u.reason === "close" && r() && !d && p() : e instanceof gr ? (console.error("[whoo-aiden-widget] chat request failed: the session has expired.", e), m(this.text.sessionExpired)) : e instanceof fr ? (console.error("[whoo-aiden-widget] chat request failed: no session could be had."), m()) : (console.error("[whoo-aiden-widget] chat request failed:", e), m());
2331
2464
  } finally {
2332
- this.activeRequestController = null, this.clearSlowResponse();
2333
- let e = i.id === null && i.content.trim() === "" ? this.state.messages.filter((e) => e !== i) : this.state.messages;
2334
- this.setState({
2465
+ let e = o.id === null && o.content.trim() === "", t = this.state.messages.filter((t) => !(e && t === o) && !(e && f && t === i)), n = t.length !== this.state.messages.length;
2466
+ r() ? (this.activeRequestController = null, this.clearSlowResponse(), this.setState({
2335
2467
  isStreaming: !1,
2336
- ...e.length === this.state.messages.length ? {} : { messages: e }
2337
- });
2468
+ ...n ? { messages: t } : {}
2469
+ })) : n && this.setState({ messages: t });
2338
2470
  }
2339
2471
  }
2340
2472
  expandFeedback(e) {
@@ -2375,7 +2507,7 @@ var lr = class {
2375
2507
  }
2376
2508
  } });
2377
2509
  try {
2378
- await this.withSession((a) => bn(i, a, {
2510
+ await this.withSession((a) => Cn(i, a, {
2379
2511
  messageId: e,
2380
2512
  rating: t,
2381
2513
  correction: n,
@@ -2399,9 +2531,9 @@ var lr = class {
2399
2531
  } });
2400
2532
  }
2401
2533
  }
2402
- async currentToken() {
2403
- let e = this.sessionToken, t = this.sessionTokenExpiresAt;
2404
- return e && (t === null || t - Date.now() > 6e4) ? e : this.renewToken();
2534
+ async currentToken(e) {
2535
+ let t = this.sessionToken, n = this.sessionTokenExpiresAt;
2536
+ return t && (n === null || n - Date.now() > 6e4) ? { token: t } : pr(this.renewToken(), e);
2405
2537
  }
2406
2538
  renewToken() {
2407
2539
  return this.tokenRenewal ??= this.fetchNewToken().finally(() => {
@@ -2409,83 +2541,95 @@ var lr = class {
2409
2541
  }), this.tokenRenewal;
2410
2542
  }
2411
2543
  async fetchNewToken() {
2412
- let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
2544
+ let e = ++this.renewalGeneration, t, n = new Promise((e) => {
2545
+ t = setTimeout(() => {
2546
+ console.error("[whoo-aiden-widget] could not renew the session: it took too long."), e({ failure: "unavailable" });
2547
+ }, dr);
2548
+ });
2413
2549
  try {
2414
- let t;
2415
- if (this.config.publishableKey) t = (await _n(e, this.config.publishableKey)).token;
2416
- else if (this.getSessionToken) t = await this.getSessionToken();
2417
- else return null;
2418
- let n = typeof t == "string" ? Mn(t) : null;
2419
- return typeof t != "string" || t === "" || n !== null && n <= Date.now() ? (console.error("[whoo-aiden-widget] could not renew the session: no usable token was returned."), null) : (this.sessionToken = t, this.sessionTokenExpiresAt = n, t);
2550
+ return await Promise.race([this.obtainToken(e), n]);
2551
+ } finally {
2552
+ clearTimeout(t);
2553
+ }
2554
+ }
2555
+ async obtainToken(e) {
2556
+ let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com", n;
2557
+ try {
2558
+ if (this.config.publishableKey) n = (await bn(t, this.config.publishableKey)).token;
2559
+ else if (this.getSessionToken) n = await this.getSessionToken();
2560
+ else return { failure: "refused" };
2420
2561
  } catch (e) {
2421
- return console.error("[whoo-aiden-widget] could not renew the session:", e), null;
2562
+ return console.error("[whoo-aiden-widget] could not renew the session:", e), { failure: this.config.publishableKey && hr(e) ? "refused" : "unavailable" };
2422
2563
  }
2564
+ let r = typeof n == "string" ? Fn(n) : null;
2565
+ return typeof n != "string" || n === "" || r !== null && r <= Date.now() ? (console.error("[whoo-aiden-widget] could not renew the session: no usable token was returned."), { failure: "refused" }) : (e === this.renewalGeneration && (this.sessionToken = n, this.sessionTokenExpiresAt = r), { token: n });
2423
2566
  }
2424
- async withSession(e) {
2425
- let t = await this.currentToken();
2426
- if (!t) throw new Q();
2567
+ async withSession(e, t) {
2568
+ let n = await this.currentToken(t);
2569
+ if (!("token" in n)) throw mr(n.failure);
2570
+ let { token: r } = n;
2427
2571
  try {
2428
- return await e(t);
2572
+ return await e(r);
2429
2573
  } catch (n) {
2430
- if (!sr(n)) throw n;
2431
- let r = this.sessionToken && this.sessionToken !== t ? this.sessionToken : await this.renewToken();
2432
- if (!r) throw new Q(n);
2574
+ if (!_r(n)) throw n;
2575
+ let i = this.sessionToken && this.sessionToken !== r ? { token: this.sessionToken } : await pr(this.renewToken(), t);
2576
+ if (!("token" in i)) throw mr(i.failure, n);
2433
2577
  try {
2434
- return await e(r);
2578
+ return await e(i.token);
2435
2579
  } catch (e) {
2436
- throw sr(e) ? new Q(e) : e;
2580
+ throw _r(e) ? new gr(e) : e;
2437
2581
  }
2438
2582
  }
2439
2583
  }
2440
- }, $ = 20, ur = 12, dr = 300, fr = 352;
2441
- function pr() {
2584
+ }, $ = 20, br = 12, xr = 300, Sr = 352;
2585
+ function Cr() {
2442
2586
  try {
2443
2587
  return typeof CSS < "u" && CSS.supports?.("height", "100dvh") ? "dvh" : "vh";
2444
2588
  } catch {
2445
2589
  return "vh";
2446
2590
  }
2447
2591
  }
2448
- function mr(e, t) {
2592
+ function wr(e, t) {
2449
2593
  let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = ie(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
2450
2594
  if (typeof window < "u" && window.innerWidth > 0 && window.innerHeight > 0) {
2451
- let e = Math.max($, window.innerWidth - dr), t = Math.max($, window.innerHeight - i - fr);
2595
+ let e = Math.max($, window.innerWidth - xr), t = Math.max($, window.innerHeight - i - Sr);
2452
2596
  s("x") && (n > e || n > window.innerWidth - i) && console.warn(`whoo-aiden-widget: \`layout.offset.x\` ${n} leaves no room for the launcher and panel in this viewport; it is held back.`), s("y") && (r > t || r > window.innerHeight - i) && console.warn(`whoo-aiden-widget: \`layout.offset.y\` ${r} leaves no room for the launcher and panel in this viewport; it is held back.`);
2453
2597
  }
2454
- let c = `100${pr()}`, l = `min(${n}px, max(${$}px, calc(100vw - ${dr}px)), calc(100vw - ${i}px))`, u = `min(${r}px, max(${$}px, calc(${c} - ${i + fr}px)), calc(${c} - ${i}px))`, d = `calc(${u} + ${i}px + ${ur}px)`, f = t.position === "bottom-left", p = (t, n) => e.style.setProperty(t, n);
2598
+ let c = `100${Cr()}`, l = `min(${n}px, max(${$}px, calc(100vw - ${xr}px)), calc(100vw - ${i}px))`, u = `min(${r}px, max(${$}px, calc(${c} - ${i + Sr}px)), calc(${c} - ${i}px))`, d = `calc(${u} + ${i}px + ${br}px)`, f = t.position === "bottom-left", p = (t, n) => e.style.setProperty(t, n);
2455
2599
  p("--whoo-widget-inset-left", f ? l : "auto"), p("--whoo-widget-inset-right", f ? "auto" : l), p("--whoo-widget-inset-bottom", u), p("--whoo-widget-launcher-size", `${i}px`), p("--whoo-widget-panel-bottom", d), p("--whoo-widget-panel-width", `${a}px`), p("--whoo-widget-panel-height", `${o}px`), p("--whoo-widget-panel-max-width", `calc(100vw - ${l} - ${$}px)`), p("--whoo-widget-panel-max-height", `calc(${c} - ${d} - ${$}px)`);
2456
2600
  }
2457
2601
  //#endregion
2458
2602
  //#region src/styles.css?inline
2459
- var hr = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);color:inherit;border:none;border-radius:12px;flex-direction:column;margin:0;padding:0;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}button,input,textarea,select{font-family:inherit}.whoo-widget-panel::backdrop{background:0 0}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding-block:8px;padding-inline:16px 8px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-inline-start:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{overscroll-behavior:contain;flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-list{margin:4px 0;padding-inline-start:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-inline-start:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);unicode-bidi:plaintext;border-radius:6px;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;unicode-bidi:plaintext;border-radius:6px;width:100%;padding:6px;font-size:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
2603
+ var Tr = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);color:inherit;border:none;border-radius:12px;flex-direction:column;margin:0;padding:0;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}button,input,textarea,select{font-family:inherit}.whoo-widget-panel:not([open]){display:none}.whoo-widget-panel::backdrop{background:0 0}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding-block:8px;padding-inline:16px 8px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-inline-start:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{overscroll-behavior:contain;flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message-text,.whoo-widget-message-text li{unicode-bidi:plaintext}.whoo-widget-list{margin:4px 0;padding-inline-start:0}.whoo-widget-list li{margin-inline-start:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-inline-start:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);unicode-bidi:plaintext;border-radius:6px;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button[aria-disabled=true]{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;unicode-bidi:plaintext;border-radius:6px;width:100%;padding:6px;font-size:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-message{border:1px solid canvastext}.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
2460
2604
  //#endregion
2461
2605
  //#region src/mount.tsx
2462
- function gr(e) {
2606
+ function Er(e) {
2463
2607
  let t = document.createElement("div");
2464
2608
  t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(c(e.zIndex));
2465
2609
  let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
2466
- r.textContent = hr, n.appendChild(r);
2610
+ r.textContent = Tr, n.appendChild(r);
2467
2611
  let i = document.createElement("div");
2468
2612
  n.appendChild(i);
2469
2613
  let a = /* @__PURE__ */ new Set();
2470
- ir(i, e, a), mr(i, e);
2471
- let o = new lr(e);
2614
+ cr(i, e, a), wr(i, e);
2615
+ let o = new yr(e);
2472
2616
  i.setAttribute("lang", o.languageTag), i.setAttribute("dir", o.dir);
2473
- let s = Y(e.color) !== null, l = null, u = "", d = te(e.theme).colors, f = Object.keys(d).length > 0, p = {
2617
+ let s = X(e.color) !== null, l = null, u = "", d = te(e.theme).colors, f = Object.keys(d).length > 0, p = {
2474
2618
  color: e.color,
2475
2619
  inkColor: e.inkColor,
2476
2620
  accentColor: e.accentColor
2477
2621
  };
2478
2622
  return o.subscribe((t) => {
2479
2623
  let n = !1;
2480
- !s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, Qn(i, t.primaryColor, e.color), Y(t.primaryColor) && (p = {
2624
+ !s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, nr(i, t.primaryColor, e.color), X(t.primaryColor) && (p = {
2481
2625
  ...p,
2482
2626
  color: t.primaryColor
2483
2627
  }), n = !0);
2484
2628
  let r = `${t.inkColor}|${t.accentColor}`;
2485
2629
  if ((t.inkColor || t.accentColor) && r !== u) {
2486
2630
  u = r;
2487
- let a = Y(e.inkColor) ? e.inkColor : t.inkColor, o = Y(e.accentColor) ? e.accentColor : t.accentColor;
2488
- $n(i, {
2631
+ let a = X(e.inkColor) ? e.inkColor : t.inkColor, o = X(e.accentColor) ? e.accentColor : t.accentColor;
2632
+ rr(i, {
2489
2633
  inkColor: a,
2490
2634
  accentColor: o
2491
2635
  }), p = {
@@ -2494,18 +2638,18 @@ function gr(e) {
2494
2638
  accentColor: o
2495
2639
  }, n = !0;
2496
2640
  }
2497
- n && (er(i, d), f && rr({
2641
+ n && (ir(i, d), f && sr({
2498
2642
  ...p,
2499
2643
  overrides: d
2500
2644
  }, a));
2501
- }), o.init(), ze(/* @__PURE__ */ U(mn, { controller: o }), i), document.body.appendChild(t), { unmount() {
2645
+ }), o.init(), ze(/* @__PURE__ */ W(_n, { controller: o }), i), document.body.appendChild(t), { unmount() {
2502
2646
  ze(null, i), t.remove();
2503
2647
  } };
2504
2648
  }
2505
2649
  //#endregion
2506
2650
  //#region src/index.ts
2507
- function _r(e) {
2508
- return d(e), gr(e);
2651
+ function Dr(e) {
2652
+ return d(e), Er(e);
2509
2653
  }
2510
2654
  //#endregion
2511
- export { wt as SUPPORTED_LANGUAGES, _r as init, X as resolveTheme };
2655
+ export { Ct as SUPPORTED_LANGUAGES, Dr as init, Z as resolveTheme };