@pluno/product-agent-web 0.1.100 → 0.1.101

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.
@@ -2,10 +2,10 @@ import { PlunoProductAgent as wi, getProductAgentOriginAccessErrorMessage as bi
2
2
  const _i = "#7c3aed", vt = "M547 151 C516 151 493 169 485 199 L382 606 C373 641 396 666 431 666 L523 666 C552 666 568 684 563 713 L491 1028 C486 1054 510 1067 527 1044 L894 487 C915 455 894 432 856 432 L815 432 C784 432 773 411 789 382 L904 205 C922 171 901 145 859 145 Z", Ct = "#2c2a1e", Un = [253, 250, 241], Bn = 3.5;
3
3
  function vo(e) {
4
4
  const t = Co(e);
5
- if (Fn(rt(t), Un) >= Bn)
5
+ if (Fn(lt(t), Un) >= Bn)
6
6
  return t;
7
- let i = rt(t);
8
- const o = rt(Ct);
7
+ let i = lt(t);
8
+ const o = lt(Ct);
9
9
  for (let r = 0; r < 6; r += 1)
10
10
  if (i = vi(i, o, 0.22), Fn(i, Un) >= Bn)
11
11
  return rn(i);
@@ -20,7 +20,7 @@ function xi() {
20
20
  return n;
21
21
  }
22
22
  function yi(e) {
23
- const t = Co(e), n = ln(rt(t));
23
+ const t = Co(e), n = ln(lt(t));
24
24
  return n > 0.86 ? {
25
25
  top: "#ffffff",
26
26
  middle: "#f6f6f6",
@@ -60,7 +60,7 @@ function Co(e) {
60
60
  const t = e.trim();
61
61
  return /^#[0-9a-f]{6}$/i.test(t) ? t.toLowerCase() : /^#[0-9a-f]{3}$/i.test(t) ? `#${t.slice(1).split("").map((n) => n + n).join("").toLowerCase()}` : _i;
62
62
  }
63
- function rt(e) {
63
+ function lt(e) {
64
64
  return [
65
65
  Number.parseInt(e.slice(1, 3), 16),
66
66
  Number.parseInt(e.slice(3, 5), 16),
@@ -91,7 +91,7 @@ function vi(e, t, n) {
91
91
  ];
92
92
  }
93
93
  function se(e, t, n) {
94
- const [i, o, r] = Ci(rt(e));
94
+ const [i, o, r] = Ci(lt(e));
95
95
  return rn(Si(i, sn(o + n), sn(r + t)));
96
96
  }
97
97
  function Ci([e, t, n]) {
@@ -480,7 +480,7 @@ async function La(e = {}) {
480
480
  ".pluno-pa-widget__attachment-error"
481
481
  ), Se = o.querySelector(
482
482
  ".pluno-pa-widget__billing-status"
483
- ), je = o.querySelector(
483
+ ), Ve = o.querySelector(
484
484
  ".pluno-pa-widget__attachments"
485
485
  ), D = o.querySelector(
486
486
  ".pluno-pa-widget__attachment-input"
@@ -494,11 +494,11 @@ async function La(e = {}) {
494
494
  ".pluno-pa-widget__top-actions"
495
495
  ), re = o.querySelector(
496
496
  ".pluno-pa-widget__history"
497
- ), Ve = o.querySelector(
497
+ ), Ke = o.querySelector(
498
498
  ".pluno-pa-widget__history-panel"
499
499
  ), H = o.querySelector(
500
500
  ".pluno-pa-widget__history-list"
501
- ), lt = o.querySelector(
501
+ ), st = o.querySelector(
502
502
  ".pluno-pa-widget__history-close"
503
503
  ), De = o.querySelector(
504
504
  ".pluno-pa-widget__history-status"
@@ -525,7 +525,7 @@ async function La(e = {}) {
525
525
  ), Qo = o.querySelector(
526
526
  ".pluno-pa-widget__tab-groups-suggestion-dismiss"
527
527
  );
528
- if (!T || !u || !m || !R || !U || !ue || !Se || !je || !D || !Re || !f || !O || !Ee || !re || !Ve || !H || !lt || !De || !le || !_ || !y || !j)
528
+ if (!T || !u || !m || !R || !U || !ue || !Se || !Ve || !D || !Re || !f || !O || !Ee || !re || !Ke || !H || !st || !De || !le || !_ || !y || !j)
529
529
  throw new Error("Failed to mount Pluno widget");
530
530
  if (t.movableLauncher && !M)
531
531
  throw new Error("Failed to mount Pluno widget drag handle");
@@ -536,7 +536,7 @@ async function La(e = {}) {
536
536
  o.classList.contains("pluno-pa-widget--open") && !t.loginRequired && !t.signupRequired && !ae(t.billingStatus)
537
537
  ), Me = () => {
538
538
  fr(
539
- je,
539
+ Ve,
540
540
  G,
541
541
  (a) => {
542
542
  G = G.filter(
@@ -586,10 +586,10 @@ async function La(e = {}) {
586
586
  );
587
587
  const Tt = new Set(l.openToolGroupKeys), Oe = new Set(
588
588
  l.seenShareCandidateIds
589
- ), st = new Set(Oe);
590
- let At = l.sharePromptsDisabled || await Yr(t), te = null, Y = !1, pt = !(t.loginRequired || t.signupRequired), xe = !1, ke = {
589
+ ), pt = new Set(Oe);
590
+ let At = l.sharePromptsDisabled || await Yr(t), te = null, Y = !1, dt = !(t.loginRequired || t.signupRequired), xe = !1, ke = {
591
591
  enabled: !0
592
- }, Le = 0, Sn = "", V = !1, he = !1, ye = [], It = null, Ke = null;
592
+ }, Le = 0, Sn = "", V = !1, he = !1, ye = [], It = null, Ye = null;
593
593
  const ne = (a, d) => {
594
594
  ke = { enabled: a, reason: d };
595
595
  }, oe = () => {
@@ -597,9 +597,9 @@ async function La(e = {}) {
597
597
  }, ti = () => {
598
598
  le.hidden = !1;
599
599
  }, ni = (a = "jump") => {
600
- ne(!0, a), oe(), at(y, () => ke.enabled), Le = y.scrollTop;
600
+ ne(!0, a), oe(), rt(y, () => ke.enabled), Le = y.scrollTop;
601
601
  }, me = () => {
602
- if (re.hidden = t.layout === "page" || t.loginRequired, Ve.hidden = !V, re.setAttribute("aria-expanded", String(V)), H.classList.toggle(
602
+ if (re.hidden = t.layout === "page" || t.loginRequired, Ke.hidden = !V, re.setAttribute("aria-expanded", String(V)), H.classList.toggle(
603
603
  "pluno-pa-widget__history-list--center",
604
604
  he && ye.length === 0
605
605
  ), H.replaceChildren(), he && ye.length === 0) {
@@ -618,17 +618,17 @@ async function La(e = {}) {
618
618
  );
619
619
  const z = document.createElement("small");
620
620
  z.className = "pluno-pa-widget__history-path", z.textContent = Ka(a), d.append(x, S, z), d.addEventListener("click", () => {
621
- V = !1, Ke = null, me(), ne(!0, "newSession"), oe(), b.loadSession(a.id), W(b.getState()), _e();
621
+ V = !1, Ye = null, me(), ne(!0, "newSession"), oe(), b.loadSession(a.id), W(b.getState()), _e();
622
622
  }), H.appendChild(d);
623
623
  }
624
624
  if (he && ye.length > 0) {
625
625
  const a = document.createElement("p");
626
626
  a.className = "pluno-pa-widget__history-loading pluno-pa-widget__history-loading--inline", a.textContent = "Loading...", H.appendChild(a);
627
627
  }
628
- De.textContent = Ke ?? (!he && ye.length === 0 ? "No recent chats for this page yet." : ""), De.hidden = De.textContent.length === 0;
628
+ De.textContent = Ye ?? (!he && ye.length === 0 ? "No recent chats for this page yet." : ""), De.hidden = De.textContent.length === 0;
629
629
  }, En = async (a) => {
630
630
  if (!he) {
631
- he = !0, Ke = null, me();
631
+ he = !0, Ye = null, me();
632
632
  try {
633
633
  const d = await b.listSessions({ cursor: a, limit: 20 });
634
634
  ye = a ? [...ye, ...d.sessions] : d.sessions, It = d.nextCursor;
@@ -639,7 +639,7 @@ async function La(e = {}) {
639
639
  {
640
640
  message: d instanceof Error ? d.message : String(d)
641
641
  }
642
- ), Ke = ga;
642
+ ), Ye = ga;
643
643
  } finally {
644
644
  he = !1, me();
645
645
  }
@@ -653,7 +653,7 @@ async function La(e = {}) {
653
653
  childList: !0,
654
654
  subtree: !0
655
655
  }), kn();
656
- const Ye = (a = !0) => {
656
+ const Xe = (a = !0) => {
657
657
  const d = St(o, a);
658
658
  return gn(
659
659
  o,
@@ -679,11 +679,11 @@ async function La(e = {}) {
679
679
  ),
680
680
  sharePromptsDisabled: At
681
681
  });
682
- }, dt = (a) => {
682
+ }, ct = (a) => {
683
683
  t.onDisplayStateChange?.(a);
684
- }, Xe = (a, d = !0) => {
684
+ }, Ze = (a, d = !0) => {
685
685
  if (bo(t, a), a === "shown") {
686
- o.classList.remove("pluno-pa-widget--minimized"), T.removeAttribute("tabindex"), !o.classList.contains("pluno-pa-widget--open") && !o.classList.contains("pluno-pa-widget--closing") && Ze(!1), d && dt("shown");
686
+ o.classList.remove("pluno-pa-widget--minimized"), T.removeAttribute("tabindex"), !o.classList.contains("pluno-pa-widget--open") && !o.classList.contains("pluno-pa-widget--closing") && Je(!1), d && ct("shown");
687
687
  return;
688
688
  }
689
689
  te !== null && (window.clearTimeout(te), te = null), o.classList.remove("pluno-pa-widget--open"), o.classList.remove("pluno-pa-widget--closing"), o.classList.add("pluno-pa-widget--minimized"), T.hidden = !1, m.hidden = !0, R.hidden = !0, T.tabIndex = 0, f.value = "", Ie(
@@ -693,7 +693,7 @@ async function La(e = {}) {
693
693
  p,
694
694
  t.position
695
695
  )
696
- ), io(o), F(), d && dt("minimized");
696
+ ), io(o), F(), d && ct("minimized");
697
697
  }, Pe = (a, d = {}) => {
698
698
  Wa(a, {
699
699
  debugVersion: Ea,
@@ -713,10 +713,10 @@ async function La(e = {}) {
713
713
  closeHidden: R.hidden,
714
714
  ...d
715
715
  });
716
- }, Ze = (a = !0) => {
716
+ }, Je = (a = !0) => {
717
717
  if (!p)
718
- return Ie(o, null), Ye(a);
719
- const d = Ye(a);
718
+ return Ie(o, null), Xe(a);
719
+ const d = Xe(a);
720
720
  return Ie(o, d), Pe("Applied stored closed launcher position", {
721
721
  visibleLauncherPosition: d
722
722
  }), d;
@@ -730,7 +730,7 @@ async function La(e = {}) {
730
730
  y: a.y - d.y
731
731
  });
732
732
  }, Rt = () => {
733
- const a = it(c).width;
733
+ const a = at(c).width;
734
734
  return t.layout === "page" && m.getBoundingClientRect().width || a;
735
735
  }, Pn = () => {
736
736
  if (o.classList.contains("pluno-pa-widget--minimized")) {
@@ -744,10 +744,10 @@ async function La(e = {}) {
744
744
  );
745
745
  return;
746
746
  }
747
- const a = Ze();
747
+ const a = Je();
748
748
  if (o.classList.contains("pluno-pa-widget--open") || o.classList.contains("pluno-pa-widget--closing")) {
749
749
  Xt(o, c);
750
- const d = it(c);
750
+ const d = at(c);
751
751
  tn(
752
752
  N,
753
753
  Rt()
@@ -772,11 +772,11 @@ async function La(e = {}) {
772
772
  };
773
773
  let Tn = () => {
774
774
  };
775
- window.addEventListener("resize", Pn), t.movableLauncher && M ? (Ze(), Tn = Na({
775
+ window.addEventListener("resize", Pn), t.movableLauncher && M ? (Je(), Tn = Na({
776
776
  root: o,
777
777
  launcher: T,
778
778
  launcherDragHandle: M,
779
- getPosition: () => Ye(),
779
+ getPosition: () => Xe(),
780
780
  setPosition: (a) => {
781
781
  const d = a, x = St(o), S = gn(
782
782
  o,
@@ -795,7 +795,7 @@ async function La(e = {}) {
795
795
  }
796
796
  })) : Ie(o, null), Xt(o, c);
797
797
  const ii = () => {
798
- const a = it(c), d = Ye();
798
+ const a = at(c), d = Xe();
799
799
  return {
800
800
  position: yt(
801
801
  h ?? Jt(
@@ -814,9 +814,9 @@ async function La(e = {}) {
814
814
  Rt()
815
815
  ), h = yt(
816
816
  a.position,
817
- it(c)
817
+ at(c)
818
818
  );
819
- const d = Ye();
819
+ const d = Xe();
820
820
  Nt(h, d);
821
821
  }, ri = L.length > 0 ? Ra({
822
822
  root: o,
@@ -854,11 +854,11 @@ async function La(e = {}) {
854
854
  }
855
855
  }
856
856
  }, fe = (a = "", d = !0) => {
857
- An(), Qe && (Qe = !1, Ot()), o.classList.contains("pluno-pa-widget--open") || (h = null), te !== null && (window.clearTimeout(te), te = null), Xe("shown", !1), m.hidden = !1, R.hidden = !1, tn(
857
+ An(), et && (et = !1, Ot()), o.classList.contains("pluno-pa-widget--open") || (h = null), te !== null && (window.clearTimeout(te), te = null), Ze("shown", !1), m.hidden = !1, R.hidden = !1, tn(
858
858
  N,
859
859
  Rt()
860
860
  ), o.classList.remove("pluno-pa-widget--closing");
861
- const x = Ze(), S = Jt(
861
+ const x = Je(), S = Jt(
862
862
  o,
863
863
  x,
864
864
  t.position,
@@ -868,16 +868,16 @@ async function La(e = {}) {
868
868
  openPanelPosition: S,
869
869
  visibleLauncherPosition: x
870
870
  }), ne(!0, "open"), oe(), !d) {
871
- o.classList.add("pluno-pa-widget--open"), T.hidden = !0, a && (f.value = a, ot(f)), at(y, () => ke.enabled), Le = y.scrollTop, f.focus(), f.setSelectionRange(f.value.length, f.value.length), F(), dt("shown"), t.onPanelOpenChange?.(!0);
871
+ o.classList.add("pluno-pa-widget--open"), T.hidden = !0, a && (f.value = a, it(f)), rt(y, () => ke.enabled), Le = y.scrollTop, f.focus(), f.setSelectionRange(f.value.length, f.value.length), F(), ct("shown"), t.onPanelOpenChange?.(!0);
872
872
  return;
873
873
  }
874
874
  window.requestAnimationFrame(() => {
875
- o.classList.add("pluno-pa-widget--open"), a && (f.value = a, ot(f)), at(y, () => ke.enabled), Le = y.scrollTop, f.focus(), f.setSelectionRange(f.value.length, f.value.length), F(), dt("shown"), t.onPanelOpenChange?.(!0), te = window.setTimeout(() => {
876
- T.hidden = !0, at(y, () => ke.enabled), Le = y.scrollTop;
875
+ o.classList.add("pluno-pa-widget--open"), a && (f.value = a, it(f)), rt(y, () => ke.enabled), Le = y.scrollTop, f.focus(), f.setSelectionRange(f.value.length, f.value.length), F(), ct("shown"), t.onPanelOpenChange?.(!0), te = window.setTimeout(() => {
876
+ T.hidden = !0, rt(y, () => ke.enabled), Le = y.scrollTop;
877
877
  }, 220);
878
878
  });
879
879
  }, zt = () => {
880
- te !== null && (window.clearTimeout(te), te = null), T.hidden = !1, p && (Ze(!1), Pe("Closing launcher at stored position")), o.classList.remove("pluno-pa-widget--open"), o.classList.add("pluno-pa-widget--closing"), F(), t.onPanelOpenChange?.(!1), te = window.setTimeout(() => {
880
+ te !== null && (window.clearTimeout(te), te = null), T.hidden = !1, p && (Je(!1), Pe("Closing launcher at stored position")), o.classList.remove("pluno-pa-widget--open"), o.classList.add("pluno-pa-widget--closing"), F(), t.onPanelOpenChange?.(!1), te = window.setTimeout(() => {
881
881
  m.hidden = !0, R.hidden = !0, h = null, o.classList.remove("pluno-pa-widget--closing");
882
882
  }, 220);
883
883
  };
@@ -895,7 +895,7 @@ async function La(e = {}) {
895
895
  const a = u.value;
896
896
  fe(a), u.value = "";
897
897
  });
898
- let Mt = null, ct = null, Te = null;
898
+ let Mt = null, ut = null, Te = null;
899
899
  const In = (a) => a === u || a === f, li = (a) => {
900
900
  if (!(a instanceof Element) || a.getRootNode() === o.getRootNode())
901
901
  return null;
@@ -923,7 +923,7 @@ async function La(e = {}) {
923
923
  Ue !== a && (Ue = a, o.classList.toggle("pluno-pa-widget--host-modal-conflict", a !== null), Ae(), a !== null ? Te = window.setInterval(() => {
924
924
  const d = Ue;
925
925
  (!d || !si(d)) && Nn(null);
926
- }, ua) : Te !== null && (window.clearInterval(Te), Te = null, ct = null));
926
+ }, ua) : Te !== null && (window.clearInterval(Te), Te = null, ut = null));
927
927
  }, pi = () => {
928
928
  Te !== null && (window.clearInterval(Te), Te = null);
929
929
  };
@@ -939,17 +939,17 @@ async function La(e = {}) {
939
939
  if (!x)
940
940
  return;
941
941
  const S = Date.now();
942
- if (ct !== null && S - ct <= ca) {
942
+ if (ut !== null && S - ut <= ca) {
943
943
  Nn(x);
944
944
  return;
945
945
  }
946
- ct = S;
946
+ ut = S;
947
947
  }), T.addEventListener("keydown", (a) => {
948
948
  !o.classList.contains("pluno-pa-widget--minimized") || a.key !== "Enter" && a.key !== " " || (a.preventDefault(), fe());
949
949
  }), C?.addEventListener("pointerdown", (a) => {
950
950
  a.stopPropagation();
951
951
  }), C?.addEventListener("click", (a) => {
952
- a.preventDefault(), a.stopPropagation(), Xe("minimized");
952
+ a.preventDefault(), a.stopPropagation(), Ze("minimized");
953
953
  }), R.addEventListener("click", zt), y.addEventListener("scroll", () => {
954
954
  y.scrollTop < Le - 1 && ne(!1, "userScroll"), Le = y.scrollTop;
955
955
  }), le.addEventListener("click", () => {
@@ -962,30 +962,30 @@ async function La(e = {}) {
962
962
  { root: y, threshold: 0 }
963
963
  );
964
964
  Rn?.observe(j);
965
- const Je = () => t.loginRequired || t.signupRequired;
966
- let Ue = null, Qe = !1;
967
- const ie = () => pt || b.getState().status !== "connected", Ae = () => {
968
- const a = Je(), d = Ue !== null;
969
- u.readOnly = !1, f.readOnly = !1, u.placeholder = d ? Kn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : Qe ? "New update" : t.launcherLabel, f.placeholder = d ? Kn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : pe.launcherLabel, U.hidden = a;
965
+ const Qe = () => t.loginRequired || t.signupRequired;
966
+ let Ue = null, et = !1;
967
+ const ie = () => dt || b.getState().status !== "connected", Ae = () => {
968
+ const a = Qe(), d = Ue !== null;
969
+ u.readOnly = !1, f.readOnly = !1, u.placeholder = d ? Kn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : et ? "New update" : t.launcherLabel, f.placeholder = d ? Kn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : pe.launcherLabel, U.hidden = a;
970
970
  }, $ = () => {
971
- O.disabled = ie() || ae(t.billingStatus) || !b.getState().isThinking && f.value.trim().length === 0 && G.length === 0, Re.disabled = Je() || ie() || ae(t.billingStatus);
971
+ O.disabled = ie() || ae(t.billingStatus) || !b.getState().isThinking && f.value.trim().length === 0 && G.length === 0, Re.disabled = Qe() || ie() || ae(t.billingStatus);
972
972
  };
973
973
  Ae();
974
974
  const Ot = () => {
975
975
  const a = b.getState().isThinking;
976
976
  o.classList.toggle("pluno-pa-widget--thinking", a), o.classList.toggle(
977
977
  "pluno-pa-widget--unread",
978
- !a && Qe
978
+ !a && et
979
979
  ), Ae();
980
980
  };
981
981
  Ot();
982
982
  const Ut = () => {
983
- Je() || Y || (pt = !0, Ae(), $(), b.connect().then(
983
+ Qe() || Y || (dt = !0, Ae(), $(), b.connect().then(
984
984
  () => {
985
- Y || (pt = !1, Ae(), $());
985
+ Y || (dt = !1, Ae(), $());
986
986
  },
987
987
  (a) => {
988
- Y || (pt = !1, Ae(), $(), X(
988
+ Y || (dt = !1, Ae(), $(), X(
989
989
  "web-sdk.widget",
990
990
  "Failed to connect Product Agent widget",
991
991
  {
@@ -1008,12 +1008,12 @@ async function La(e = {}) {
1008
1008
  b,
1009
1009
  f,
1010
1010
  G,
1011
- wt
1011
+ bt
1012
1012
  ), Me(), $());
1013
1013
  });
1014
- let et = 0;
1014
+ let tt = 0;
1015
1015
  const di = () => {
1016
- et = 0, o.classList.remove("pluno-pa-widget--drag-over");
1016
+ tt = 0, o.classList.remove("pluno-pa-widget--drag-over");
1017
1017
  }, Bt = (a) => {
1018
1018
  ge !== null && window.clearTimeout(ge), ue.textContent = a, ue.hidden = !1, ge = window.setTimeout(() => {
1019
1019
  ue.textContent = "", ue.hidden = !0, ge = null;
@@ -1044,15 +1044,15 @@ async function La(e = {}) {
1044
1044
  });
1045
1045
  });
1046
1046
  }), o.addEventListener("dragenter", (a) => {
1047
- !t.attachmentsEnabled || !bt(a.dataTransfer) || t.loginRequired || ie() || (a.preventDefault(), a.stopPropagation(), et += 1, o.classList.add("pluno-pa-widget--drag-over"));
1047
+ !t.attachmentsEnabled || !_t(a.dataTransfer) || t.loginRequired || ie() || (a.preventDefault(), a.stopPropagation(), tt += 1, o.classList.add("pluno-pa-widget--drag-over"));
1048
1048
  }), o.addEventListener("dragover", (a) => {
1049
1049
  const d = a.dataTransfer;
1050
- !t.attachmentsEnabled || !bt(d) || t.loginRequired || ie() || (a.preventDefault(), a.stopPropagation(), d.dropEffect = "copy");
1050
+ !t.attachmentsEnabled || !_t(d) || t.loginRequired || ie() || (a.preventDefault(), a.stopPropagation(), d.dropEffect = "copy");
1051
1051
  }), o.addEventListener("dragleave", (a) => {
1052
- bt(a.dataTransfer) && (a.stopPropagation(), et = Math.max(0, et - 1), et === 0 && o.classList.remove("pluno-pa-widget--drag-over"));
1052
+ _t(a.dataTransfer) && (a.stopPropagation(), tt = Math.max(0, tt - 1), tt === 0 && o.classList.remove("pluno-pa-widget--drag-over"));
1053
1053
  }), o.addEventListener("drop", (a) => {
1054
1054
  const d = a.dataTransfer;
1055
- !t.attachmentsEnabled || !bt(d) || t.loginRequired || ie() || (a.preventDefault(), a.stopPropagation(), di(), Ft(d.files).catch((x) => {
1055
+ !t.attachmentsEnabled || !_t(d) || t.loginRequired || ie() || (a.preventDefault(), a.stopPropagation(), di(), Ft(d.files).catch((x) => {
1056
1056
  Bt(
1057
1057
  x instanceof Error ? x.message : "Failed to attach file"
1058
1058
  ), X("web-sdk.widget", "Attachment failed", {
@@ -1085,14 +1085,14 @@ async function La(e = {}) {
1085
1085
  b,
1086
1086
  f,
1087
1087
  G,
1088
- wt
1088
+ bt
1089
1089
  ), Me(), $(), W(b.getState()), a && _e();
1090
1090
  }), re.addEventListener("click", () => {
1091
- V = !V, Ke = null, me(), V && ye.length === 0 && En(null), V || _e();
1092
- }), lt.addEventListener("click", () => {
1091
+ V = !V, Ye = null, me(), V && ye.length === 0 && En(null), V || _e();
1092
+ }), st.addEventListener("click", () => {
1093
1093
  V = !1, me(), _e();
1094
1094
  }), H.addEventListener("scroll", oi), f.addEventListener("input", () => {
1095
- ot(f), F(), $(), mi();
1095
+ it(f), F(), $(), mi();
1096
1096
  }), f.addEventListener("keydown", (a) => {
1097
1097
  if (!(a.key !== "Enter" || a.shiftKey)) {
1098
1098
  if (a.preventDefault(), t.loginRequired) {
@@ -1103,12 +1103,12 @@ async function La(e = {}) {
1103
1103
  b,
1104
1104
  f,
1105
1105
  G,
1106
- wt
1106
+ bt
1107
1107
  ), Me(), $(), W(b.getState()));
1108
1108
  }
1109
1109
  }), o.addEventListener("click", (a) => {
1110
1110
  const d = a.target instanceof Element ? a.target : null;
1111
- d?.closest("a[href]") && F(), V && Gi(d, Ve, re) && (V = !1, me());
1111
+ d?.closest("a[href]") && F(), V && Gi(d, Ke, re) && (V = !1, me());
1112
1112
  const S = window.getSelection(), z = !!(S && !S.isCollapsed && S.anchorNode && o.contains(S.anchorNode));
1113
1113
  Wi(
1114
1114
  a.target,
@@ -1117,54 +1117,54 @@ async function La(e = {}) {
1117
1117
  ) && _e();
1118
1118
  }), o.addEventListener("keydown", (a) => {
1119
1119
  a.key !== "Escape" || !V || (V = !1, me(), _e());
1120
- }), l.composerValue && (f.value = l.composerValue, ot(f)), t.layout === "page" ? fe(f.value, !1) : s === "minimized" ? Xe("minimized", !1) : t.initialDisplayState === void 0 && l.isOpen && fe(f.value, !1), Ga(l, o, u, f);
1121
- const ut = () => r;
1122
- let Wt = b.getState().appearance !== null, gt = null, tt = null, Be = null, Dn = b.getState().isThinking, Fe = null;
1123
- const nt = t.taskNotifications;
1120
+ }), l.composerValue && (f.value = l.composerValue, it(f)), t.layout === "page" ? fe(f.value, !1) : s === "minimized" ? Ze("minimized", !1) : t.initialDisplayState === void 0 && l.isOpen && fe(f.value, !1), Ga(l, o, u, f);
1121
+ const gt = () => r;
1122
+ let Wt = b.getState().appearance !== null, ht = null, nt = null, Be = null, Dn = b.getState().isThinking, Fe = null;
1123
+ const ot = t.taskNotifications;
1124
1124
  let We = null, He = !1;
1125
1125
  const zn = () => {
1126
1126
  We !== null && (window.clearTimeout(We), We = null);
1127
- }, ht = () => {
1127
+ }, mt = () => {
1128
1128
  K && (K.hidden = !0);
1129
1129
  }, Mn = () => b.getState().assistantDraft.trim().length > 0, gi = async () => {
1130
- if (!nt || !K || He || Y || !b.getState().isThinking || Mn())
1130
+ if (!ot || !K || He || Y || !b.getState().isThinking || Mn())
1131
1131
  return;
1132
1132
  let a;
1133
1133
  try {
1134
- a = await nt.getState();
1134
+ a = await ot.getState();
1135
1135
  } catch {
1136
1136
  return;
1137
1137
  }
1138
1138
  a.enabled || a.neverSuggest || !b.getState().isThinking || Mn() || He || Y || (K.hidden = !1);
1139
1139
  };
1140
1140
  ee?.addEventListener("click", () => {
1141
- He = !0, ht(), nt?.enable().catch(() => {
1141
+ He = !0, mt(), ot?.enable().catch(() => {
1142
1142
  });
1143
1143
  }), v?.addEventListener("click", () => {
1144
- He = !0, ht();
1144
+ He = !0, mt();
1145
1145
  }), A?.addEventListener("click", () => {
1146
- He = !0, ht(), nt?.dismissForever().catch(() => {
1146
+ He = !0, mt(), ot?.dismissForever().catch(() => {
1147
1147
  });
1148
1148
  });
1149
- const mt = t.tabGroups;
1149
+ const ft = t.tabGroups;
1150
1150
  let Ge = !1;
1151
- const ft = async () => {
1152
- if (!mt || !ze || Ge || Y)
1151
+ const wt = async () => {
1152
+ if (!ft || !ze || Ge || Y)
1153
1153
  return;
1154
- const a = await mt.getState().catch(() => null);
1154
+ const a = await ft.getState().catch(() => null);
1155
1155
  !a || Ge || Y || (ze.hidden = !a.permissionNeeded);
1156
1156
  };
1157
1157
  Jo?.addEventListener("click", () => {
1158
- Ge = !0, ze && (ze.hidden = !0), mt?.enable().catch(() => {
1158
+ Ge = !0, ze && (ze.hidden = !0), ft?.enable().catch(() => {
1159
1159
  }).finally(() => {
1160
- Ge = !1, ft();
1160
+ Ge = !1, wt();
1161
1161
  });
1162
1162
  }), Qo?.addEventListener("click", () => {
1163
- Ge = !0, ze && (ze.hidden = !0), mt?.dismiss().catch(() => {
1163
+ Ge = !0, ze && (ze.hidden = !0), ft?.dismiss().catch(() => {
1164
1164
  }).finally(() => {
1165
- Ge = !1, ft();
1165
+ Ge = !1, wt();
1166
1166
  });
1167
- }), ft();
1167
+ }), wt();
1168
1168
  let $e = null, On = () => {
1169
1169
  };
1170
1170
  const hi = !!t.socialPostDraftHandler, Ht = /* @__PURE__ */ new Map(), Gt = () => f.value.trim().length > 0 || G.length > 0, mi = () => {
@@ -1173,8 +1173,8 @@ async function La(e = {}) {
1173
1173
  };
1174
1174
  let qe = null;
1175
1175
  const $t = (a = {}) => {
1176
- xe = !0, ne(!0, "newSession"), oe(), V = !1, me(), b.startNewSession(a), Tt.clear(), f.value = "", G = [], Me(), ot(f), F(), $(), f.focus(), W(b.getState());
1177
- }, wt = () => {
1176
+ xe = !0, ne(!0, "newSession"), oe(), V = !1, me(), b.startNewSession(a), Tt.clear(), f.value = "", G = [], Me(), it(f), F(), $(), f.focus(), W(b.getState());
1177
+ }, bt = () => {
1178
1178
  t.morningReport !== null && (t.morningReport = null, t.onMorningReportTaskStart?.(), $t());
1179
1179
  }, qt = (a) => {
1180
1180
  if (!a || t.layout === "page") {
@@ -1197,7 +1197,7 @@ async function La(e = {}) {
1197
1197
  y,
1198
1198
  O,
1199
1199
  qt,
1200
- ut,
1200
+ gt,
1201
1201
  "Log in to use Pluno on this page.",
1202
1202
  t.loginButtonLabel,
1203
1203
  t.loginUrl,
@@ -1210,7 +1210,7 @@ async function La(e = {}) {
1210
1210
  y,
1211
1211
  O,
1212
1212
  qt,
1213
- ut,
1213
+ gt,
1214
1214
  "Complete signup to unlock your free trial credits.",
1215
1215
  t.signupButtonLabel,
1216
1216
  t.signupUrl,
@@ -1235,9 +1235,9 @@ async function La(e = {}) {
1235
1235
  Tt,
1236
1236
  Ht,
1237
1237
  F,
1238
- ut,
1238
+ gt,
1239
1239
  (z) => {
1240
- ie() || (wt(), xe = !0, ne(!0, "send"), oe(), b.sendMessage(z));
1240
+ ie() || (bt(), xe = !0, ne(!0, "send"), oe(), b.sendMessage(z));
1241
1241
  },
1242
1242
  () => {
1243
1243
  xe = !0, ne(!0, "send"), oe(), b.retryLastMessage();
@@ -1249,10 +1249,10 @@ async function La(e = {}) {
1249
1249
  Ut,
1250
1250
  t.attachmentPreviewUrlResolver,
1251
1251
  hi && !At ? {
1252
- dismissedCandidateIds: st,
1253
- draftingCandidate: gt,
1254
- error: tt,
1255
- characterIconOptions: ut(),
1252
+ dismissedCandidateIds: pt,
1253
+ draftingCandidate: ht,
1254
+ error: nt,
1255
+ characterIconOptions: gt(),
1256
1256
  onSeen: (z) => {
1257
1257
  Oe.add(z.id), F();
1258
1258
  },
@@ -1260,10 +1260,10 @@ async function La(e = {}) {
1260
1260
  fi(z);
1261
1261
  },
1262
1262
  onDismiss: (z) => {
1263
- Oe.add(z.id), st.add(z.id), F(), tt = null, W(b.getState());
1263
+ Oe.add(z.id), pt.add(z.id), F(), nt = null, W(b.getState());
1264
1264
  },
1265
1265
  onDisable: (z) => {
1266
- At = !0, Oe.add(z.id), st.add(z.id), F(), Xr(t, !0), tt = null, W(b.getState());
1266
+ At = !0, Oe.add(z.id), pt.add(z.id), F(), Xr(t, !0), nt = null, W(b.getState());
1267
1267
  }
1268
1268
  } : void 0
1269
1269
  ), S ? (Le = y.scrollTop, oe()) : x && ja(a) && ti();
@@ -1278,11 +1278,11 @@ async function La(e = {}) {
1278
1278
  loader: t.activeUsersLoader
1279
1279
  }
1280
1280
  ), b.on("state", (a) => {
1281
- ft();
1281
+ wt();
1282
1282
  const d = Dn && !a.isThinking;
1283
- Dn = a.isThinking, a.isThinking && !a.assistantDraft.trim() && nt && !He && We === null && K?.hidden !== !1 && (We = window.setTimeout(() => {
1283
+ Dn = a.isThinking, a.isThinking && !a.assistantDraft.trim() && ot && !He && We === null && K?.hidden !== !1 && (We = window.setTimeout(() => {
1284
1284
  We = null, gi();
1285
- }, Yi)), (!a.isThinking || a.assistantDraft.trim()) && (zn(), ht()), d && !o.classList.contains("pluno-pa-widget--open") && (Qe = !0), Ot(), a.appearance ? (Wt = !0, X(
1285
+ }, Yi)), (!a.isThinking || a.assistantDraft.trim()) && (zn(), mt()), d && !o.classList.contains("pluno-pa-widget--open") && (et = !0), Ot(), a.appearance ? (Wt = !0, X(
1286
1286
  "web-sdk.widget",
1287
1287
  "Agent state supplied appearance",
1288
1288
  {
@@ -1317,8 +1317,8 @@ async function La(e = {}) {
1317
1317
  ), $());
1318
1318
  },
1319
1319
  updateAuthGate: (a) => {
1320
- const d = Je();
1321
- t.loginRequired = a.loginRequired === !0, t.signupRequired = a.signupRequired === !0, a.loginButtonLabel !== void 0 && (t.loginButtonLabel = a.loginButtonLabel), a.loginUrl !== void 0 && (t.loginUrl = a.loginUrl), a.signupButtonLabel !== void 0 && (t.signupButtonLabel = a.signupButtonLabel), a.signupUrl !== void 0 && (t.signupUrl = a.signupUrl), Ae(), W(b.getState()), $(), d && !Je() && Ut();
1320
+ const d = Qe();
1321
+ t.loginRequired = a.loginRequired === !0, t.signupRequired = a.signupRequired === !0, a.loginButtonLabel !== void 0 && (t.loginButtonLabel = a.loginButtonLabel), a.loginUrl !== void 0 && (t.loginUrl = a.loginUrl), a.signupButtonLabel !== void 0 && (t.signupButtonLabel = a.signupButtonLabel), a.signupUrl !== void 0 && (t.signupUrl = a.signupUrl), Ae(), W(b.getState()), $(), d && !Qe() && Ut();
1322
1322
  },
1323
1323
  openPanel: () => {
1324
1324
  fe(f.value, !1);
@@ -1326,10 +1326,10 @@ async function La(e = {}) {
1326
1326
  closePanel: zt,
1327
1327
  updateDisplayState: (a) => {
1328
1328
  if (a === "shown") {
1329
- Xe("shown", !1);
1329
+ Ze("shown", !1);
1330
1330
  return;
1331
1331
  }
1332
- Xe("minimized", !1);
1332
+ Ze("minimized", !1);
1333
1333
  },
1334
1334
  updateMorningReport: (a) => {
1335
1335
  t.morningReport = a ?? null, W(b.getState());
@@ -1339,24 +1339,24 @@ async function La(e = {}) {
1339
1339
  }
1340
1340
  };
1341
1341
  async function fi(a) {
1342
- if (!gt) {
1343
- gt = a, tt = null, W(b.getState());
1342
+ if (!ht) {
1343
+ ht = a, nt = null, W(b.getState());
1344
1344
  try {
1345
1345
  if (!t.socialPostDraftHandler)
1346
1346
  throw new Error("Social post drafting is not available here.");
1347
1347
  const d = await t.socialPostDraftHandler(a);
1348
1348
  if (!d.linkedinPost || !d.xPost)
1349
1349
  throw new Error("Pluno did not return a complete social post draft.");
1350
- Oe.add(a.id), st.add(a.id), F(), Be?.remove(), Be = Dr(d, {
1350
+ Oe.add(a.id), pt.add(a.id), F(), Be?.remove(), Be = Dr(d, {
1351
1351
  socialPostRewardsUrl: t.socialPostRewardsUrl,
1352
1352
  onClose: () => {
1353
1353
  Be?.remove(), Be = null;
1354
1354
  }
1355
1355
  }), o.appendChild(Be);
1356
1356
  } catch (d) {
1357
- tt = d instanceof Error ? d.message : "Could not draft social post.";
1357
+ nt = d instanceof Error ? d.message : "Could not draft social post.";
1358
1358
  } finally {
1359
- gt = null, W(b.getState());
1359
+ ht = null, W(b.getState());
1360
1360
  }
1361
1361
  }
1362
1362
  }
@@ -1630,7 +1630,7 @@ function Da() {
1630
1630
  )
1631
1631
  };
1632
1632
  }
1633
- function it(e = null) {
1633
+ function at(e = null) {
1634
1634
  return e ? kt(e) : Da();
1635
1635
  }
1636
1636
  function kt(e) {
@@ -1740,7 +1740,7 @@ function Ba(e) {
1740
1740
  return e.classList.contains("pluno-pa-widget--scribble") ? Sa : Ca;
1741
1741
  }
1742
1742
  function Jt(e, t, n, i = null) {
1743
- const o = St(e), r = it(i), l = {
1743
+ const o = St(e), r = at(i), l = {
1744
1744
  x: n === "bottom-left" ? t.x : t.x + o.width - r.width,
1745
1745
  y: t.y + o.height - r.height
1746
1746
  };
@@ -1835,12 +1835,12 @@ function Ga(e, t, n, i) {
1835
1835
  function $a(e) {
1836
1836
  return e;
1837
1837
  }
1838
- function ot(e) {
1838
+ function it(e) {
1839
1839
  e.style.height = "0px";
1840
1840
  const t = Math.max(22, Math.min(e.scrollHeight, 140));
1841
1841
  e.style.height = `${t}px`, e.style.overflowY = e.scrollHeight > 140 ? "auto" : "hidden";
1842
1842
  }
1843
- function at(e, t = () => !0) {
1843
+ function rt(e, t = () => !0) {
1844
1844
  e.scrollTop = e.scrollHeight, window.requestAnimationFrame(() => {
1845
1845
  t() && (e.scrollTop = e.scrollHeight);
1846
1846
  });
@@ -2778,7 +2778,7 @@ function _r(e, t) {
2778
2778
  function xr(e) {
2779
2779
  return typeof URL.createObjectURL == "function" ? URL.createObjectURL(e) : void 0;
2780
2780
  }
2781
- function bt(e) {
2781
+ function _t(e) {
2782
2782
  return !!(e && Array.from(e.types).includes("Files"));
2783
2783
  }
2784
2784
  function on(e, t, n = null) {
@@ -2871,7 +2871,7 @@ function an(e, t) {
2871
2871
  function kr(e, t, n, i, o, r, l, s, p, g, c, h, E, P, T, M, u, C, m, N, L) {
2872
2872
  const R = Ar(r), U = R.filter(
2873
2873
  (_) => !qo(_)
2874
- ), ue = e.scrollTop, Se = [], je = /* @__PURE__ */ new Set(), D = (_) => {
2874
+ ), ue = e.scrollTop, Se = [], Ve = /* @__PURE__ */ new Set(), D = (_) => {
2875
2875
  Se.push(_);
2876
2876
  };
2877
2877
  Vo(n, r.isThinking), o.hidden = !s, s && l !== null && Oo(o, l);
@@ -2914,7 +2914,7 @@ function kr(e, t, n, i, o, r, l, s, p, g, c, h, E, P, T, M, u, C, m, N, L) {
2914
2914
  return;
2915
2915
  }
2916
2916
  let f = null, O = null, Ee = [];
2917
- const re = U.length - 1, Ve = re >= 0 && fn(U[re]), H = () => {
2917
+ const re = U.length - 1, Ke = re >= 0 && fn(U[re]), H = () => {
2918
2918
  if (Ee.length === 0)
2919
2919
  return !1;
2920
2920
  const _ = Br(
@@ -2960,14 +2960,14 @@ function kr(e, t, n, i, o, r, l, s, p, g, c, h, E, P, T, M, u, C, m, N, L) {
2960
2960
  y,
2961
2961
  K,
2962
2962
  h,
2963
- je,
2963
+ Ve,
2964
2964
  N
2965
2965
  );
2966
2966
  D(ee), f = ee, O = null;
2967
2967
  }
2968
- const lt = H(), De = U[U.length - 1]?.id === "assistant-draft";
2969
- if (r.isThinking && !De && !Ve)
2970
- if (lt) {
2968
+ const st = H(), De = U[U.length - 1]?.id === "assistant-draft";
2969
+ if (r.isThinking && !De && !Ke)
2970
+ if (st) {
2971
2971
  const _ = Et();
2972
2972
  D(_), f = null, O = _;
2973
2973
  } else {
@@ -2999,7 +2999,7 @@ function kr(e, t, n, i, o, r, l, s, p, g, c, h, E, P, T, M, u, C, m, N, L) {
2999
2999
  });
3000
3000
  D(_), L.onSeen(le), f = null, O = _;
3001
3001
  }
3002
- f?.classList.add("pluno-pa-widget__message--bottom-reserve"), O?.classList.add("pluno-pa-widget__bottom-reserve-compact"), D(t), Tr(h, je), uo(e, Se), p ? at(e, g) : e.scrollTop = ue;
3002
+ f?.classList.add("pluno-pa-widget__message--bottom-reserve"), O?.classList.add("pluno-pa-widget__bottom-reserve-compact"), D(t), Tr(h, Ve), uo(e, Se), p ? rt(e, g) : e.scrollTop = ue;
3003
3003
  }
3004
3004
  function Lr(e, t, n, i, o) {
3005
3005
  const r = Pr(e, t), l = r ? n.get(r) : void 0;
@@ -3381,14 +3381,14 @@ function Wr(e, t) {
3381
3381
  const l = o.match(/^(#{1,3})\s+(.+)$/);
3382
3382
  if (l) {
3383
3383
  const c = document.createElement(`h${l[1].length + 2}`);
3384
- _t(c, l[2]), e.appendChild(c), i += 1;
3384
+ je(c, l[2]), e.appendChild(c), i += 1;
3385
3385
  continue;
3386
3386
  }
3387
3387
  if (/^\s*[-*+]\s+/.test(o)) {
3388
3388
  const c = document.createElement("ul");
3389
3389
  for (; i < n.length && /^\s*[-*+]\s+/.test(n[i]); ) {
3390
3390
  const h = document.createElement("li");
3391
- _t(h, n[i].replace(/^\s*[-*+]\s+/, "")), c.appendChild(h), i += 1;
3391
+ je(h, n[i].replace(/^\s*[-*+]\s+/, "")), c.appendChild(h), i += 1;
3392
3392
  }
3393
3393
  e.appendChild(c);
3394
3394
  continue;
@@ -3398,7 +3398,7 @@ function Wr(e, t) {
3398
3398
  const c = document.createElement("ol");
3399
3399
  for (c.start = Number(s[1]); i < n.length && /^\s*\d+\.\s+/.test(n[i]); ) {
3400
3400
  const h = document.createElement("li");
3401
- _t(h, n[i].replace(/^\s*\d+\.\s+/, "")), c.appendChild(h), i += 1;
3401
+ je(h, n[i].replace(/^\s*\d+\.\s+/, "")), c.appendChild(h), i += 1;
3402
3402
  }
3403
3403
  e.appendChild(c);
3404
3404
  continue;
@@ -3408,11 +3408,11 @@ function Wr(e, t) {
3408
3408
  p.push(n[i]), i += 1;
3409
3409
  const g = document.createElement("p");
3410
3410
  p.forEach((c, h) => {
3411
- h > 0 && g.appendChild(document.createElement("br")), _t(g, c);
3411
+ h > 0 && g.appendChild(document.createElement("br")), je(g, c);
3412
3412
  }), e.appendChild(g);
3413
3413
  }
3414
3414
  }
3415
- function _t(e, t) {
3415
+ function je(e, t) {
3416
3416
  const n = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
3417
3417
  let i = 0;
3418
3418
  for (const o of t.matchAll(n)) {
@@ -3426,10 +3426,10 @@ function _t(e, t) {
3426
3426
  s.textContent = l.slice(1, -1), e.appendChild(s);
3427
3427
  } else if (l.startsWith("**")) {
3428
3428
  const s = document.createElement("strong");
3429
- s.textContent = l.slice(2, -2), e.appendChild(s);
3429
+ je(s, l.slice(2, -2)), e.appendChild(s);
3430
3430
  } else if (l.startsWith("*")) {
3431
3431
  const s = document.createElement("em");
3432
- s.textContent = l.slice(1, -1), e.appendChild(s);
3432
+ je(s, l.slice(1, -1)), e.appendChild(s);
3433
3433
  } else {
3434
3434
  const s = l.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
3435
3435
  if (s && Hr(s[2])) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluno/product-agent-web",
3
- "version": "0.1.100",
3
+ "version": "0.1.101",
4
4
  "description": "Browser SDK and default widget for embedding Pluno Product Agent into customer web apps.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",