@pluno/product-agent-web 0.1.75 → 0.1.76
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/product-agent-widget.js +123 -123
- package/package.json +1 -1
|
@@ -2,10 +2,10 @@ import { PlunoProductAgent as ti, getProductAgentOriginAccessErrorMessage as ni
|
|
|
2
2
|
const oi = "#7c3aed", mt = "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", ft = "#2c2a1e", Pn = [253, 250, 241], Tn = 3.5;
|
|
3
3
|
function lo(e) {
|
|
4
4
|
const t = po(e);
|
|
5
|
-
if (In(
|
|
5
|
+
if (In(nt(t), Pn) >= Tn)
|
|
6
6
|
return t;
|
|
7
|
-
let o =
|
|
8
|
-
const i =
|
|
7
|
+
let o = nt(t);
|
|
8
|
+
const i = nt(ft);
|
|
9
9
|
for (let r = 0; r < 6; r += 1)
|
|
10
10
|
if (o = ri(o, i, 0.22), In(o, Pn) >= Tn)
|
|
11
11
|
return Xt(o);
|
|
@@ -20,7 +20,7 @@ function ii() {
|
|
|
20
20
|
return n;
|
|
21
21
|
}
|
|
22
22
|
function ai(e) {
|
|
23
|
-
const t = po(e), n = Zt(
|
|
23
|
+
const t = po(e), n = Zt(nt(t));
|
|
24
24
|
return n > 0.86 ? {
|
|
25
25
|
top: "#ffffff",
|
|
26
26
|
middle: "#f6f6f6",
|
|
@@ -60,7 +60,7 @@ function po(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()}` : oi;
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function nt(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 ri(e, t, n) {
|
|
|
91
91
|
];
|
|
92
92
|
}
|
|
93
93
|
function ie(e, t, n) {
|
|
94
|
-
const [o, i, r] = li(
|
|
94
|
+
const [o, i, r] = li(nt(e));
|
|
95
95
|
return Xt(pi(o, Jt(i + n), Jt(r + t)));
|
|
96
96
|
}
|
|
97
97
|
function li([e, t, n]) {
|
|
@@ -379,11 +379,11 @@ async function ia(e = {}) {
|
|
|
379
379
|
".pluno-pa-widget__attachment-error"
|
|
380
380
|
), xe = i.querySelector(
|
|
381
381
|
".pluno-pa-widget__billing-status"
|
|
382
|
-
),
|
|
382
|
+
), He = i.querySelector(
|
|
383
383
|
".pluno-pa-widget__attachments"
|
|
384
384
|
), z = i.querySelector(
|
|
385
385
|
".pluno-pa-widget__attachment-input"
|
|
386
|
-
),
|
|
386
|
+
), We = i.querySelector(
|
|
387
387
|
".pluno-pa-widget__attach"
|
|
388
388
|
), w = i.querySelector(
|
|
389
389
|
".pluno-pa-widget__input"
|
|
@@ -397,7 +397,7 @@ async function ia(e = {}) {
|
|
|
397
397
|
".pluno-pa-widget__history-panel"
|
|
398
398
|
), V = i.querySelector(
|
|
399
399
|
".pluno-pa-widget__history-list"
|
|
400
|
-
),
|
|
400
|
+
), ot = i.querySelector(
|
|
401
401
|
".pluno-pa-widget__history-close"
|
|
402
402
|
), ne = i.querySelector(
|
|
403
403
|
".pluno-pa-widget__history-status"
|
|
@@ -418,7 +418,7 @@ async function ia(e = {}) {
|
|
|
418
418
|
), Uo = i.querySelector(
|
|
419
419
|
".pluno-pa-widget__notify-suggestion-never"
|
|
420
420
|
);
|
|
421
|
-
if (!v || !C || !y || !A || !N || !q || !xe || !
|
|
421
|
+
if (!v || !C || !y || !A || !N || !q || !xe || !He || !z || !We || !w || !U || !ye || !ve || !Ae || !V || !ot || !ne || !x || !M || !T || !oe)
|
|
422
422
|
throw new Error("Failed to mount Pluno widget");
|
|
423
423
|
if (t.movableLauncher && !D)
|
|
424
424
|
throw new Error("Failed to mount Pluno widget drag handle");
|
|
@@ -426,7 +426,7 @@ async function ia(e = {}) {
|
|
|
426
426
|
let j = [], se = null;
|
|
427
427
|
const Ne = () => {
|
|
428
428
|
ja(
|
|
429
|
-
|
|
429
|
+
He,
|
|
430
430
|
j,
|
|
431
431
|
(a) => {
|
|
432
432
|
j = j.filter(
|
|
@@ -475,10 +475,10 @@ async function ia(e = {}) {
|
|
|
475
475
|
);
|
|
476
476
|
const vt = new Set(l.openToolGroupKeys), Re = new Set(
|
|
477
477
|
l.seenShareCandidateIds
|
|
478
|
-
),
|
|
479
|
-
let Ct = l.sharePromptsDisabled || await Er(t), J = null, de = !1,
|
|
478
|
+
), it = new Set(Re);
|
|
479
|
+
let Ct = l.sharePromptsDisabled || await Er(t), J = null, de = !1, at = !(t.loginRequired || t.signupRequired), he = !1, Ce = {
|
|
480
480
|
enabled: !0
|
|
481
|
-
}, Se = 0, hn = "", me = !1, ce = !1, fe = [], St = null,
|
|
481
|
+
}, Se = 0, hn = "", me = !1, ce = !1, fe = [], St = null, Ge = null;
|
|
482
482
|
const Q = (a, d) => {
|
|
483
483
|
Ce = { enabled: a, reason: d };
|
|
484
484
|
}, ee = () => {
|
|
@@ -486,7 +486,7 @@ async function ia(e = {}) {
|
|
|
486
486
|
}, Fo = () => {
|
|
487
487
|
x.hidden = !1;
|
|
488
488
|
}, Ho = (a = "jump") => {
|
|
489
|
-
Q(!0, a), ee(),
|
|
489
|
+
Q(!0, a), ee(), tt(T, () => Ce.enabled), Se = T.scrollTop;
|
|
490
490
|
}, Ee = () => {
|
|
491
491
|
if (ve.hidden = t.loginRequired, Ae.hidden = !me, ve.setAttribute("aria-expanded", String(me)), V.classList.toggle(
|
|
492
492
|
"pluno-pa-widget__history-list--center",
|
|
@@ -507,17 +507,17 @@ async function ia(e = {}) {
|
|
|
507
507
|
);
|
|
508
508
|
const O = document.createElement("small");
|
|
509
509
|
O.className = "pluno-pa-widget__history-path", O.textContent = Ea(a), d.append(_, P, O), d.addEventListener("click", () => {
|
|
510
|
-
me = !1,
|
|
510
|
+
me = !1, Ge = null, Ee(), Q(!0, "newSession"), ee(), b.loadSession(a.id), H(b.getState());
|
|
511
511
|
}), V.appendChild(d);
|
|
512
512
|
}
|
|
513
513
|
if (ce && fe.length > 0) {
|
|
514
514
|
const a = document.createElement("p");
|
|
515
515
|
a.className = "pluno-pa-widget__history-loading pluno-pa-widget__history-loading--inline", a.textContent = "Loading...", V.appendChild(a);
|
|
516
516
|
}
|
|
517
|
-
ne.textContent =
|
|
517
|
+
ne.textContent = Ge ?? (!ce && fe.length === 0 ? "No recent chats for this page yet." : ""), ne.hidden = ne.textContent.length === 0;
|
|
518
518
|
}, mn = async (a) => {
|
|
519
519
|
if (!ce) {
|
|
520
|
-
ce = !0,
|
|
520
|
+
ce = !0, Ge = null, Ee();
|
|
521
521
|
try {
|
|
522
522
|
const d = await b.listSessions({ cursor: a, limit: 20 });
|
|
523
523
|
fe = a ? [...fe, ...d.sessions] : d.sessions, St = d.nextCursor;
|
|
@@ -528,7 +528,7 @@ async function ia(e = {}) {
|
|
|
528
528
|
{
|
|
529
529
|
message: d instanceof Error ? d.message : String(d)
|
|
530
530
|
}
|
|
531
|
-
),
|
|
531
|
+
), Ge = Wi;
|
|
532
532
|
} finally {
|
|
533
533
|
ce = !1, Ee();
|
|
534
534
|
}
|
|
@@ -542,7 +542,7 @@ async function ia(e = {}) {
|
|
|
542
542
|
childList: !0,
|
|
543
543
|
subtree: !0
|
|
544
544
|
}), fn();
|
|
545
|
-
const
|
|
545
|
+
const $e = (a = !0) => {
|
|
546
546
|
const d = wt(i, a);
|
|
547
547
|
return on(
|
|
548
548
|
i,
|
|
@@ -570,9 +570,9 @@ async function ia(e = {}) {
|
|
|
570
570
|
});
|
|
571
571
|
}, rt = (a) => {
|
|
572
572
|
t.onDisplayStateChange?.(a);
|
|
573
|
-
},
|
|
573
|
+
}, qe = (a, d = !0) => {
|
|
574
574
|
if (a === "shown") {
|
|
575
|
-
i.classList.remove("pluno-pa-widget--minimized"), v.removeAttribute("tabindex"), !i.classList.contains("pluno-pa-widget--open") && !i.classList.contains("pluno-pa-widget--closing") &&
|
|
575
|
+
i.classList.remove("pluno-pa-widget--minimized"), v.removeAttribute("tabindex"), !i.classList.contains("pluno-pa-widget--open") && !i.classList.contains("pluno-pa-widget--closing") && je(!1), d && rt("shown");
|
|
576
576
|
return;
|
|
577
577
|
}
|
|
578
578
|
J !== null && (window.clearTimeout(J), J = null), i.classList.remove("pluno-pa-widget--open"), i.classList.remove("pluno-pa-widget--closing"), i.classList.add("pluno-pa-widget--minimized"), v.hidden = !1, y.hidden = !0, A.hidden = !0, v.tabIndex = 0, w.value = "", Te(
|
|
@@ -602,10 +602,10 @@ async function ia(e = {}) {
|
|
|
602
602
|
closeHidden: A.hidden,
|
|
603
603
|
...d
|
|
604
604
|
});
|
|
605
|
-
},
|
|
605
|
+
}, je = (a = !0) => {
|
|
606
606
|
if (!p)
|
|
607
|
-
return Te(i, null),
|
|
608
|
-
const d =
|
|
607
|
+
return Te(i, null), $e(a);
|
|
608
|
+
const d = $e(a);
|
|
609
609
|
return Te(i, d), ke("Applied stored closed launcher position", {
|
|
610
610
|
visibleLauncherPosition: d
|
|
611
611
|
}), d;
|
|
@@ -630,10 +630,10 @@ async function ia(e = {}) {
|
|
|
630
630
|
);
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
const a =
|
|
633
|
+
const a = je();
|
|
634
634
|
if (i.classList.contains("pluno-pa-widget--open") || i.classList.contains("pluno-pa-widget--closing")) {
|
|
635
635
|
Ht(i, c);
|
|
636
|
-
const d =
|
|
636
|
+
const d = Fe(c);
|
|
637
637
|
jt(
|
|
638
638
|
h,
|
|
639
639
|
d.width
|
|
@@ -658,11 +658,11 @@ async function ia(e = {}) {
|
|
|
658
658
|
};
|
|
659
659
|
let _n = () => {
|
|
660
660
|
};
|
|
661
|
-
window.addEventListener("resize", bn), t.movableLauncher && D ? (
|
|
661
|
+
window.addEventListener("resize", bn), t.movableLauncher && D ? (je(), _n = sa({
|
|
662
662
|
root: i,
|
|
663
663
|
launcher: v,
|
|
664
664
|
launcherDragHandle: D,
|
|
665
|
-
getPosition: () =>
|
|
665
|
+
getPosition: () => $e(),
|
|
666
666
|
setPosition: (a) => {
|
|
667
667
|
const d = a, _ = wt(i), P = on(
|
|
668
668
|
i,
|
|
@@ -681,7 +681,7 @@ async function ia(e = {}) {
|
|
|
681
681
|
}
|
|
682
682
|
})) : Te(i, null), Ht(i, c);
|
|
683
683
|
const Go = () => {
|
|
684
|
-
const a =
|
|
684
|
+
const a = Fe(c), d = $e();
|
|
685
685
|
return {
|
|
686
686
|
position: ht(
|
|
687
687
|
u ?? Gt(
|
|
@@ -697,12 +697,12 @@ async function ia(e = {}) {
|
|
|
697
697
|
}, $o = (a) => {
|
|
698
698
|
c = _t(a.size), Ht(i, c), jt(
|
|
699
699
|
h,
|
|
700
|
-
|
|
700
|
+
Fe(c).width
|
|
701
701
|
), u = ht(
|
|
702
702
|
a.position,
|
|
703
|
-
|
|
703
|
+
Fe(c)
|
|
704
704
|
);
|
|
705
|
-
const d =
|
|
705
|
+
const d = $e();
|
|
706
706
|
Et(u, d);
|
|
707
707
|
}, qo = S.length > 0 ? da({
|
|
708
708
|
root: i,
|
|
@@ -732,11 +732,11 @@ async function ia(e = {}) {
|
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
734
|
}, we = (a = "", d = !0) => {
|
|
735
|
-
xn(),
|
|
735
|
+
xn(), Ye && (Ye = !1, Tt()), i.classList.contains("pluno-pa-widget--open") || (u = null), J !== null && (window.clearTimeout(J), J = null), qe("shown", !1), y.hidden = !1, A.hidden = !1, jt(
|
|
736
736
|
h,
|
|
737
|
-
|
|
737
|
+
Fe(c).width
|
|
738
738
|
), i.classList.remove("pluno-pa-widget--closing");
|
|
739
|
-
const _ =
|
|
739
|
+
const _ = je(), P = Gt(
|
|
740
740
|
i,
|
|
741
741
|
_,
|
|
742
742
|
t.position,
|
|
@@ -746,16 +746,16 @@ async function ia(e = {}) {
|
|
|
746
746
|
openPanelPosition: P,
|
|
747
747
|
visibleLauncherPosition: _
|
|
748
748
|
}), Q(!0, "open"), ee(), !d) {
|
|
749
|
-
i.classList.add("pluno-pa-widget--open"), v.hidden = !0, a && (w.value = a,
|
|
749
|
+
i.classList.add("pluno-pa-widget--open"), v.hidden = !0, a && (w.value = a, et(w)), tt(T, () => Ce.enabled), Se = T.scrollTop, w.focus(), w.setSelectionRange(w.value.length, w.value.length), F(), rt("shown"), t.onPanelOpenChange?.(!0);
|
|
750
750
|
return;
|
|
751
751
|
}
|
|
752
752
|
window.requestAnimationFrame(() => {
|
|
753
|
-
i.classList.add("pluno-pa-widget--open"), a && (w.value = a,
|
|
754
|
-
v.hidden = !0,
|
|
753
|
+
i.classList.add("pluno-pa-widget--open"), a && (w.value = a, et(w)), tt(T, () => Ce.enabled), Se = T.scrollTop, w.focus(), w.setSelectionRange(w.value.length, w.value.length), F(), rt("shown"), t.onPanelOpenChange?.(!0), J = window.setTimeout(() => {
|
|
754
|
+
v.hidden = !0, tt(T, () => Ce.enabled), Se = T.scrollTop;
|
|
755
755
|
}, 220);
|
|
756
756
|
});
|
|
757
757
|
}, Lt = () => {
|
|
758
|
-
J !== null && (window.clearTimeout(J), J = null), v.hidden = !1, p && (
|
|
758
|
+
J !== null && (window.clearTimeout(J), J = null), v.hidden = !1, p && (je(!1), ke("Closing launcher at stored position")), i.classList.remove("pluno-pa-widget--open"), i.classList.add("pluno-pa-widget--closing"), F(), t.onPanelOpenChange?.(!1), J = window.setTimeout(() => {
|
|
759
759
|
y.hidden = !0, A.hidden = !0, u = null, i.classList.remove("pluno-pa-widget--closing");
|
|
760
760
|
}, 220);
|
|
761
761
|
};
|
|
@@ -798,8 +798,8 @@ async function ia(e = {}) {
|
|
|
798
798
|
const d = window.getComputedStyle(a);
|
|
799
799
|
return d.display !== "none" && d.visibility !== "hidden";
|
|
800
800
|
}, vn = (a) => {
|
|
801
|
-
|
|
802
|
-
const d =
|
|
801
|
+
Ke !== a && (Ke = a, i.classList.toggle("pluno-pa-widget--host-modal-conflict", a !== null), Pe(), a !== null ? Le = window.setInterval(() => {
|
|
802
|
+
const d = Ke;
|
|
803
803
|
(!d || !Vo(d)) && vn(null);
|
|
804
804
|
}, Hi) : Le !== null && (window.clearInterval(Le), Le = null, lt = null));
|
|
805
805
|
}, Ko = () => {
|
|
@@ -808,7 +808,7 @@ async function ia(e = {}) {
|
|
|
808
808
|
i.addEventListener("focusin", (a) => {
|
|
809
809
|
yn(a.target) && (Pt = Date.now(), F());
|
|
810
810
|
}), i.addEventListener("focusout", (a) => {
|
|
811
|
-
if (!yn(a.target) ||
|
|
811
|
+
if (!yn(a.target) || Ke !== null)
|
|
812
812
|
return;
|
|
813
813
|
const d = Pt;
|
|
814
814
|
if (Pt = null, d === null || Date.now() - d > Bi)
|
|
@@ -827,7 +827,7 @@ async function ia(e = {}) {
|
|
|
827
827
|
}), g?.addEventListener("pointerdown", (a) => {
|
|
828
828
|
a.stopPropagation();
|
|
829
829
|
}), g?.addEventListener("click", (a) => {
|
|
830
|
-
a.preventDefault(), a.stopPropagation(),
|
|
830
|
+
a.preventDefault(), a.stopPropagation(), qe("minimized");
|
|
831
831
|
}), A.addEventListener("click", Lt), T.addEventListener("scroll", () => {
|
|
832
832
|
T.scrollTop < Se - 1 && Q(!1, "userScroll"), Se = T.scrollTop;
|
|
833
833
|
}), x.addEventListener("click", () => {
|
|
@@ -840,30 +840,30 @@ async function ia(e = {}) {
|
|
|
840
840
|
{ root: T, threshold: 0 }
|
|
841
841
|
);
|
|
842
842
|
Cn?.observe(oe);
|
|
843
|
-
const
|
|
844
|
-
let
|
|
845
|
-
const K = () =>
|
|
846
|
-
const a =
|
|
847
|
-
C.readOnly = a || d || _, w.readOnly = d || _, C.placeholder = d ? zn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel :
|
|
843
|
+
const Ve = () => t.loginRequired || t.signupRequired;
|
|
844
|
+
let Ke = null, Ye = !1;
|
|
845
|
+
const K = () => at || b.getState().status !== "connected", Pe = () => {
|
|
846
|
+
const a = Ve(), d = Ke !== null, _ = !a && K();
|
|
847
|
+
C.readOnly = a || d || _, w.readOnly = d || _, C.placeholder = d ? zn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : Ye ? "New update" : t.launcherLabel, w.placeholder = d ? zn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : ae.launcherLabel, N.hidden = a;
|
|
848
848
|
}, G = () => {
|
|
849
|
-
U.disabled = K() || le(t.billingStatus) || !b.getState().isThinking && w.value.trim().length === 0 && j.length === 0,
|
|
849
|
+
U.disabled = K() || le(t.billingStatus) || !b.getState().isThinking && w.value.trim().length === 0 && j.length === 0, We.disabled = Ve() || K() || le(t.billingStatus);
|
|
850
850
|
};
|
|
851
851
|
Pe();
|
|
852
852
|
const Tt = () => {
|
|
853
853
|
const a = b.getState().isThinking;
|
|
854
854
|
i.classList.toggle("pluno-pa-widget--thinking", a), i.classList.toggle(
|
|
855
855
|
"pluno-pa-widget--unread",
|
|
856
|
-
!a &&
|
|
856
|
+
!a && Ye
|
|
857
857
|
), Pe();
|
|
858
858
|
};
|
|
859
859
|
Tt();
|
|
860
860
|
const It = () => {
|
|
861
|
-
|
|
861
|
+
Ve() || de || (at = !0, Pe(), G(), b.connect().then(
|
|
862
862
|
() => {
|
|
863
|
-
de || (
|
|
863
|
+
de || (at = !1, Pe(), G());
|
|
864
864
|
},
|
|
865
865
|
(a) => {
|
|
866
|
-
de || (
|
|
866
|
+
de || (at = !1, Pe(), G(), te(
|
|
867
867
|
"web-sdk.widget",
|
|
868
868
|
"Failed to connect Product Agent widget",
|
|
869
869
|
{
|
|
@@ -888,9 +888,9 @@ async function ia(e = {}) {
|
|
|
888
888
|
j
|
|
889
889
|
), Ne(), G());
|
|
890
890
|
});
|
|
891
|
-
let
|
|
891
|
+
let Xe = 0;
|
|
892
892
|
const Yo = () => {
|
|
893
|
-
|
|
893
|
+
Xe = 0, i.classList.remove("pluno-pa-widget--drag-over");
|
|
894
894
|
}, At = (a) => {
|
|
895
895
|
se !== null && window.clearTimeout(se), q.textContent = a, q.hidden = !1, se = window.setTimeout(() => {
|
|
896
896
|
q.textContent = "", q.hidden = !0, se = null;
|
|
@@ -903,7 +903,7 @@ async function ia(e = {}) {
|
|
|
903
903
|
const d = Ya(b, a);
|
|
904
904
|
j = [...j, ...d], Ne(), Xo(), G(), H(b.getState()), i.classList.contains("pluno-pa-widget--open") || we();
|
|
905
905
|
};
|
|
906
|
-
|
|
906
|
+
We.addEventListener("click", () => {
|
|
907
907
|
t.loginRequired || K() || le(t.billingStatus) || z.click();
|
|
908
908
|
}), z.addEventListener("change", () => {
|
|
909
909
|
const a = Array.from(z.files ?? []);
|
|
@@ -915,12 +915,12 @@ async function ia(e = {}) {
|
|
|
915
915
|
});
|
|
916
916
|
});
|
|
917
917
|
}), i.addEventListener("dragenter", (a) => {
|
|
918
|
-
!ct(a.dataTransfer) || t.loginRequired || K() || (a.preventDefault(), a.stopPropagation(),
|
|
918
|
+
!ct(a.dataTransfer) || t.loginRequired || K() || (a.preventDefault(), a.stopPropagation(), Xe += 1, i.classList.add("pluno-pa-widget--drag-over"));
|
|
919
919
|
}), i.addEventListener("dragover", (a) => {
|
|
920
920
|
const d = a.dataTransfer;
|
|
921
921
|
!ct(d) || t.loginRequired || K() || (a.preventDefault(), a.stopPropagation(), d.dropEffect = "copy");
|
|
922
922
|
}), i.addEventListener("dragleave", (a) => {
|
|
923
|
-
ct(a.dataTransfer) && (a.stopPropagation(),
|
|
923
|
+
ct(a.dataTransfer) && (a.stopPropagation(), Xe = Math.max(0, Xe - 1), Xe === 0 && i.classList.remove("pluno-pa-widget--drag-over"));
|
|
924
924
|
}), i.addEventListener("drop", (a) => {
|
|
925
925
|
const d = a.dataTransfer;
|
|
926
926
|
!ct(d) || t.loginRequired || K() || (a.preventDefault(), a.stopPropagation(), Yo(), Nt(d.files).catch((_) => {
|
|
@@ -955,11 +955,11 @@ async function ia(e = {}) {
|
|
|
955
955
|
j
|
|
956
956
|
), Ne(), G(), H(b.getState()));
|
|
957
957
|
}), ve.addEventListener("click", () => {
|
|
958
|
-
me = !me,
|
|
959
|
-
}),
|
|
958
|
+
me = !me, Ge = null, Ee(), me && fe.length === 0 && mn(null);
|
|
959
|
+
}), ot.addEventListener("click", () => {
|
|
960
960
|
me = !1, Ee();
|
|
961
961
|
}), V.addEventListener("scroll", Wo), w.addEventListener("input", () => {
|
|
962
|
-
|
|
962
|
+
et(w), F(), G(), Qo();
|
|
963
963
|
}), w.addEventListener("keydown", (a) => {
|
|
964
964
|
if (!(a.key !== "Enter" || a.shiftKey)) {
|
|
965
965
|
if (a.preventDefault(), t.loginRequired) {
|
|
@@ -974,60 +974,60 @@ async function ia(e = {}) {
|
|
|
974
974
|
}
|
|
975
975
|
}), i.addEventListener("click", (a) => {
|
|
976
976
|
(a.target instanceof Element ? a.target : null)?.closest("a[href]") && F();
|
|
977
|
-
}), l.composerValue && (w.value = l.composerValue,
|
|
977
|
+
}), l.composerValue && (w.value = l.composerValue, et(w)), t.initialDisplayState === "minimized" ? qe("minimized", !1) : t.initialDisplayState === void 0 && l.isOpen && we(w.value, !1), xa(l, i, C, w);
|
|
978
978
|
const pt = () => r;
|
|
979
|
-
let Rt = b.getState().appearance !== null, st = null,
|
|
980
|
-
const
|
|
981
|
-
let
|
|
979
|
+
let Rt = b.getState().appearance !== null, st = null, Ze = null, De = null, Sn = b.getState().isThinking, Me = null;
|
|
980
|
+
const Je = t.taskNotifications;
|
|
981
|
+
let ze = null, Oe = !1;
|
|
982
982
|
const En = () => {
|
|
983
|
-
|
|
983
|
+
ze !== null && (window.clearTimeout(ze), ze = null);
|
|
984
984
|
}, dt = () => {
|
|
985
985
|
W && (W.hidden = !0);
|
|
986
986
|
}, kn = () => b.getState().assistantDraft.trim().length > 0, Zo = async () => {
|
|
987
|
-
if (!
|
|
987
|
+
if (!Je || !W || Oe || de || !b.getState().isThinking || kn())
|
|
988
988
|
return;
|
|
989
989
|
let a;
|
|
990
990
|
try {
|
|
991
|
-
a = await
|
|
991
|
+
a = await Je.getState();
|
|
992
992
|
} catch {
|
|
993
993
|
return;
|
|
994
994
|
}
|
|
995
|
-
a.enabled || a.neverSuggest || !b.getState().isThinking || kn() ||
|
|
995
|
+
a.enabled || a.neverSuggest || !b.getState().isThinking || kn() || Oe || de || (W.hidden = !1);
|
|
996
996
|
};
|
|
997
997
|
L?.addEventListener("click", () => {
|
|
998
|
-
|
|
998
|
+
Oe = !0, dt(), Je?.enable().catch(() => {
|
|
999
999
|
});
|
|
1000
1000
|
}), R?.addEventListener("click", () => {
|
|
1001
|
-
|
|
1001
|
+
Oe = !0, dt();
|
|
1002
1002
|
}), Uo?.addEventListener("click", () => {
|
|
1003
|
-
|
|
1003
|
+
Oe = !0, dt(), Je?.dismissForever().catch(() => {
|
|
1004
1004
|
});
|
|
1005
1005
|
});
|
|
1006
|
-
let
|
|
1006
|
+
let Ue = null, Ln = () => {
|
|
1007
1007
|
};
|
|
1008
1008
|
const Jo = !!t.socialPostDraftHandler, Dt = /* @__PURE__ */ new Map(), Mt = () => w.value.trim().length > 0 || j.length > 0, Qo = () => {
|
|
1009
|
-
const a =
|
|
1010
|
-
M.hidden = !a, a &&
|
|
1009
|
+
const a = Ue !== null && Yt(b.getState(), Mt());
|
|
1010
|
+
M.hidden = !a, a && Ue !== null && Co(M, Ue);
|
|
1011
1011
|
};
|
|
1012
|
-
let
|
|
1012
|
+
let Be = null;
|
|
1013
1013
|
const zt = (a = {}) => {
|
|
1014
|
-
he = !0, Q(!0, "newSession"), ee(), me = !1, Ee(), b.startNewSession(a), vt.clear(), w.value = "", j = [], Ne(),
|
|
1014
|
+
he = !0, Q(!0, "newSession"), ee(), me = !1, Ee(), b.startNewSession(a), vt.clear(), w.value = "", j = [], Ne(), et(w), F(), G(), w.focus(), H(b.getState());
|
|
1015
1015
|
}, Ot = (a) => {
|
|
1016
1016
|
if (!a) {
|
|
1017
|
-
|
|
1017
|
+
Be?.remove(), Be = null;
|
|
1018
1018
|
return;
|
|
1019
1019
|
}
|
|
1020
|
-
|
|
1020
|
+
Be || (Be = xt(
|
|
1021
1021
|
"pluno-pa-widget__new-chat",
|
|
1022
1022
|
"New chat",
|
|
1023
1023
|
Ua(),
|
|
1024
1024
|
!1
|
|
1025
|
-
),
|
|
1025
|
+
), Be.addEventListener("click", () => zt()), ye.insertBefore(Be, ve));
|
|
1026
1026
|
}, H = (a) => {
|
|
1027
|
-
if (Ee(), un(a.lastErrorCode) ?
|
|
1027
|
+
if (Ee(), un(a.lastErrorCode) ? Me = a.lastErrorCode : t.billingStatus?.creditsUsed !== null && !le(t.billingStatus) && (Me = null), Kt(
|
|
1028
1028
|
xe,
|
|
1029
1029
|
t.billingStatus,
|
|
1030
|
-
|
|
1030
|
+
Me
|
|
1031
1031
|
), t.loginRequired) {
|
|
1032
1032
|
Dt.clear(), to(
|
|
1033
1033
|
T,
|
|
@@ -1064,8 +1064,8 @@ async function ia(e = {}) {
|
|
|
1064
1064
|
Ot,
|
|
1065
1065
|
M,
|
|
1066
1066
|
a,
|
|
1067
|
-
|
|
1068
|
-
|
|
1067
|
+
Ue,
|
|
1068
|
+
Ue !== null && Yt(a, Mt()),
|
|
1069
1069
|
P,
|
|
1070
1070
|
() => Ce.enabled,
|
|
1071
1071
|
vt,
|
|
@@ -1075,8 +1075,8 @@ async function ia(e = {}) {
|
|
|
1075
1075
|
(O) => {
|
|
1076
1076
|
if (K())
|
|
1077
1077
|
return;
|
|
1078
|
-
const
|
|
1079
|
-
t.morningReport = null,
|
|
1078
|
+
const Qe = t.morningReport !== null;
|
|
1079
|
+
t.morningReport = null, Qe && (t.onMorningReportTaskStart?.(), zt()), he = !0, Q(!0, "send"), ee(), b.sendMessage(O);
|
|
1080
1080
|
},
|
|
1081
1081
|
() => {
|
|
1082
1082
|
he = !0, Q(!0, "send"), ee(), b.retryLastMessage();
|
|
@@ -1087,9 +1087,9 @@ async function ia(e = {}) {
|
|
|
1087
1087
|
},
|
|
1088
1088
|
It,
|
|
1089
1089
|
Jo && !Ct ? {
|
|
1090
|
-
dismissedCandidateIds:
|
|
1090
|
+
dismissedCandidateIds: it,
|
|
1091
1091
|
draftingCandidateId: st,
|
|
1092
|
-
error:
|
|
1092
|
+
error: Ze,
|
|
1093
1093
|
characterIconOptions: pt(),
|
|
1094
1094
|
onSeen: (O) => {
|
|
1095
1095
|
Re.add(O.id), F();
|
|
@@ -1098,17 +1098,17 @@ async function ia(e = {}) {
|
|
|
1098
1098
|
ei(O);
|
|
1099
1099
|
},
|
|
1100
1100
|
onDismiss: (O) => {
|
|
1101
|
-
Re.add(O.id),
|
|
1101
|
+
Re.add(O.id), it.add(O.id), F(), Ze = null, H(b.getState());
|
|
1102
1102
|
},
|
|
1103
1103
|
onDisable: (O) => {
|
|
1104
|
-
Ct = !0, Re.add(O.id),
|
|
1104
|
+
Ct = !0, Re.add(O.id), it.add(O.id), F(), kr(t, !0), Ze = null, H(b.getState());
|
|
1105
1105
|
}
|
|
1106
1106
|
} : void 0
|
|
1107
1107
|
), P ? (Se = T.scrollTop, ee()) : _ && Ca(a) && Fo();
|
|
1108
1108
|
};
|
|
1109
1109
|
return Ln = _i(
|
|
1110
1110
|
(a) => {
|
|
1111
|
-
|
|
1111
|
+
Ue = a, !de && Yt(b.getState(), Mt()) && H(b.getState());
|
|
1112
1112
|
},
|
|
1113
1113
|
{
|
|
1114
1114
|
backendUrl: t.backendUrl,
|
|
@@ -1117,9 +1117,9 @@ async function ia(e = {}) {
|
|
|
1117
1117
|
}
|
|
1118
1118
|
), b.on("state", (a) => {
|
|
1119
1119
|
const d = Sn && !a.isThinking;
|
|
1120
|
-
Sn = a.isThinking, a.isThinking && !a.assistantDraft.trim() &&
|
|
1121
|
-
|
|
1122
|
-
}, Si)), (!a.isThinking || a.assistantDraft.trim()) && (En(), dt()), d && !i.classList.contains("pluno-pa-widget--open") && (
|
|
1120
|
+
Sn = a.isThinking, a.isThinking && !a.assistantDraft.trim() && Je && !Oe && ze === null && W?.hidden !== !1 && (ze = window.setTimeout(() => {
|
|
1121
|
+
ze = null, Zo();
|
|
1122
|
+
}, Si)), (!a.isThinking || a.assistantDraft.trim()) && (En(), dt()), d && !i.classList.contains("pluno-pa-widget--open") && (Ye = !0), Tt(), a.appearance ? (Rt = !0, te(
|
|
1123
1123
|
"web-sdk.widget",
|
|
1124
1124
|
"Agent state supplied appearance",
|
|
1125
1125
|
{
|
|
@@ -1146,16 +1146,16 @@ async function ia(e = {}) {
|
|
|
1146
1146
|
Zn(
|
|
1147
1147
|
t.billingStatus,
|
|
1148
1148
|
d,
|
|
1149
|
-
|
|
1150
|
-
) && (t.billingStatus = d, t.billingStatus?.creditsUsed !== null && !le(t.billingStatus) && (
|
|
1149
|
+
Me
|
|
1150
|
+
) && (t.billingStatus = d, t.billingStatus?.creditsUsed !== null && !le(t.billingStatus) && (Me = null), Kt(
|
|
1151
1151
|
i.querySelector(".pluno-pa-widget__billing-status"),
|
|
1152
1152
|
t.billingStatus,
|
|
1153
|
-
|
|
1153
|
+
Me
|
|
1154
1154
|
), G());
|
|
1155
1155
|
},
|
|
1156
1156
|
updateAuthGate: (a) => {
|
|
1157
|
-
const d =
|
|
1158
|
-
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), Pe(), H(b.getState()), G(), d && !
|
|
1157
|
+
const d = Ve();
|
|
1158
|
+
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), Pe(), H(b.getState()), G(), d && !Ve() && It();
|
|
1159
1159
|
},
|
|
1160
1160
|
openPanel: () => {
|
|
1161
1161
|
we(w.value, !1);
|
|
@@ -1163,57 +1163,57 @@ async function ia(e = {}) {
|
|
|
1163
1163
|
closePanel: Lt,
|
|
1164
1164
|
updateDisplayState: (a) => {
|
|
1165
1165
|
if (a === "shown") {
|
|
1166
|
-
|
|
1166
|
+
qe("shown", !1);
|
|
1167
1167
|
return;
|
|
1168
1168
|
}
|
|
1169
|
-
|
|
1169
|
+
qe("minimized", !1);
|
|
1170
1170
|
},
|
|
1171
1171
|
updateMorningReport: (a) => {
|
|
1172
1172
|
t.morningReport = a ?? null, H(b.getState());
|
|
1173
1173
|
},
|
|
1174
1174
|
destroy: () => {
|
|
1175
|
-
de || (F(), de = !0, wn.disconnect(), Cn?.disconnect(), Ko(), window.removeEventListener("resize", bn), _n(), qo(), se !== null && window.clearTimeout(se), En(), Ln(),
|
|
1175
|
+
de || (F(), de = !0, wn.disconnect(), Cn?.disconnect(), Ko(), window.removeEventListener("resize", bn), _n(), qo(), se !== null && window.clearTimeout(se), En(), Ln(), De?.remove(), b.destroy(), yt.release(), n.remove());
|
|
1176
1176
|
}
|
|
1177
1177
|
};
|
|
1178
1178
|
async function ei(a) {
|
|
1179
1179
|
if (!st) {
|
|
1180
|
-
st = a.id,
|
|
1180
|
+
st = a.id, Ze = null, H(b.getState());
|
|
1181
1181
|
try {
|
|
1182
1182
|
if (!t.socialPostDraftHandler)
|
|
1183
1183
|
throw new Error("Social post drafting is not available here.");
|
|
1184
1184
|
const d = await t.socialPostDraftHandler(a);
|
|
1185
1185
|
if (!d.linkedinPost || !d.xPost)
|
|
1186
1186
|
throw new Error("Pluno did not return a complete social post draft.");
|
|
1187
|
-
Re.add(a.id),
|
|
1187
|
+
Re.add(a.id), it.add(a.id), F(), De?.remove(), De = dr(d, {
|
|
1188
1188
|
socialPostRewardsUrl: t.socialPostRewardsUrl,
|
|
1189
1189
|
onClose: () => {
|
|
1190
|
-
|
|
1190
|
+
De?.remove(), De = null;
|
|
1191
1191
|
}
|
|
1192
|
-
}), i.appendChild(
|
|
1192
|
+
}), i.appendChild(De);
|
|
1193
1193
|
} catch (d) {
|
|
1194
|
-
|
|
1194
|
+
Ze = d instanceof Error ? d.message : "Could not draft social post.";
|
|
1195
1195
|
} finally {
|
|
1196
1196
|
st = null, H(b.getState());
|
|
1197
1197
|
}
|
|
1198
1198
|
}
|
|
1199
1199
|
}
|
|
1200
1200
|
function Ut(a, d) {
|
|
1201
|
-
const _ = a.accentColor ?? t.accentColor, P = a.colorScheme ?? t.colorScheme, O = a.fontFamily ?? t.fontFamily,
|
|
1201
|
+
const _ = a.accentColor ?? t.accentColor, P = a.colorScheme ?? t.colorScheme, O = a.fontFamily ?? t.fontFamily, Qe = a.scribbleStyle ?? t.scribbleStyle;
|
|
1202
1202
|
r = Hn(
|
|
1203
1203
|
_,
|
|
1204
|
-
|
|
1204
|
+
Qe
|
|
1205
1205
|
), Wn(i, r, {
|
|
1206
1206
|
accentColor: _,
|
|
1207
1207
|
colorScheme: P,
|
|
1208
1208
|
fontFamily: O,
|
|
1209
|
-
scribbleStyle:
|
|
1209
|
+
scribbleStyle: Qe
|
|
1210
1210
|
}), te("web-sdk.widget", "Updated widget appearance", {
|
|
1211
1211
|
source: d,
|
|
1212
1212
|
inputAppearance: a,
|
|
1213
1213
|
appliedAccentColor: _,
|
|
1214
1214
|
appliedColorScheme: P,
|
|
1215
1215
|
appliedFontFamily: O,
|
|
1216
|
-
appliedScribbleStyle:
|
|
1216
|
+
appliedScribbleStyle: Qe,
|
|
1217
1217
|
cssAccent: i.style.getPropertyValue("--pluno-pa-accent")
|
|
1218
1218
|
});
|
|
1219
1219
|
}
|
|
@@ -1470,7 +1470,7 @@ function ca() {
|
|
|
1470
1470
|
)
|
|
1471
1471
|
};
|
|
1472
1472
|
}
|
|
1473
|
-
function
|
|
1473
|
+
function Fe(e = null) {
|
|
1474
1474
|
return e ? _t(e) : ca();
|
|
1475
1475
|
}
|
|
1476
1476
|
function _t(e) {
|
|
@@ -1580,7 +1580,7 @@ function fa(e) {
|
|
|
1580
1580
|
return e.classList.contains("pluno-pa-widget--scribble") ? ta : ea;
|
|
1581
1581
|
}
|
|
1582
1582
|
function Gt(e, t, n, o = null) {
|
|
1583
|
-
const i = wt(e), r =
|
|
1583
|
+
const i = wt(e), r = Fe(o), l = {
|
|
1584
1584
|
x: n === "bottom-left" ? t.x : t.x + i.width - r.width,
|
|
1585
1585
|
y: t.y + i.height - r.height
|
|
1586
1586
|
};
|
|
@@ -1675,12 +1675,12 @@ function xa(e, t, n, o) {
|
|
|
1675
1675
|
function ya(e) {
|
|
1676
1676
|
return e;
|
|
1677
1677
|
}
|
|
1678
|
-
function
|
|
1678
|
+
function et(e) {
|
|
1679
1679
|
e.style.height = "0px";
|
|
1680
1680
|
const t = Math.max(22, Math.min(e.scrollHeight, 140));
|
|
1681
1681
|
e.style.height = `${t}px`, e.style.overflowY = e.scrollHeight > 140 ? "auto" : "hidden";
|
|
1682
1682
|
}
|
|
1683
|
-
function
|
|
1683
|
+
function tt(e, t = () => !0) {
|
|
1684
1684
|
e.scrollTop = e.scrollHeight, window.requestAnimationFrame(() => {
|
|
1685
1685
|
t() && (e.scrollTop = e.scrollHeight);
|
|
1686
1686
|
});
|
|
@@ -2686,12 +2686,12 @@ function Yt(e, t) {
|
|
|
2686
2686
|
function nr(e, t, n, o, i, r, l, p, s, c, u, m, k, v, D, C, g, y, h, S) {
|
|
2687
2687
|
const A = rr(r), N = A.filter(
|
|
2688
2688
|
(x) => !Ao(x)
|
|
2689
|
-
), q = e.scrollTop, xe = [],
|
|
2689
|
+
), q = e.scrollTop, xe = [], He = /* @__PURE__ */ new Set(), z = (x) => {
|
|
2690
2690
|
xe.push(x);
|
|
2691
2691
|
};
|
|
2692
2692
|
Ro(n, r.isThinking), i.hidden = !p, p && l !== null && Co(i, l);
|
|
2693
|
-
const
|
|
2694
|
-
if (o(
|
|
2693
|
+
const We = N.length > 0 || !!r.assistantDraft || r.isThinking;
|
|
2694
|
+
if (o(We), g || N.length === 0 && !r.assistantDraft && !r.lastError && !r.isThinking) {
|
|
2695
2695
|
const x = document.createElement("div");
|
|
2696
2696
|
x.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter" + (g ? " pluno-pa-widget__empty-state--morning-report" : "");
|
|
2697
2697
|
const M = document.createElement("div");
|
|
@@ -2763,11 +2763,11 @@ function nr(e, t, n, o, i, r, l, p, s, c, u, m, k, v, D, C, g, y, h, S) {
|
|
|
2763
2763
|
const L = No(v());
|
|
2764
2764
|
z(L), w = null, U = L;
|
|
2765
2765
|
}
|
|
2766
|
-
const W = or(M, oe, m,
|
|
2766
|
+
const W = or(M, oe, m, He);
|
|
2767
2767
|
z(W), w = W, U = null;
|
|
2768
2768
|
}
|
|
2769
|
-
const V = Ae(),
|
|
2770
|
-
if (r.isThinking && !
|
|
2769
|
+
const V = Ae(), ot = N[N.length - 1]?.id === "assistant-draft";
|
|
2770
|
+
if (r.isThinking && !ot && !ve)
|
|
2771
2771
|
if (V) {
|
|
2772
2772
|
const x = bt();
|
|
2773
2773
|
z(x), w = null, U = x;
|
|
@@ -2800,7 +2800,7 @@ function nr(e, t, n, o, i, r, l, p, s, c, u, m, k, v, D, C, g, y, h, S) {
|
|
|
2800
2800
|
});
|
|
2801
2801
|
z(x), S.onSeen(ne), w = null, U = x;
|
|
2802
2802
|
}
|
|
2803
|
-
w?.classList.add("pluno-pa-widget__message--bottom-reserve"), U?.classList.add("pluno-pa-widget__bottom-reserve-compact"), z(t), ar(m,
|
|
2803
|
+
w?.classList.add("pluno-pa-widget__message--bottom-reserve"), U?.classList.add("pluno-pa-widget__bottom-reserve-compact"), z(t), ar(m, He), Qn(e, xe), s ? tt(e, c) : e.scrollTop = q;
|
|
2804
2804
|
}
|
|
2805
2805
|
function or(e, t, n, o) {
|
|
2806
2806
|
const i = ir(e, t), r = i ? n.get(i) : void 0;
|
package/package.json
CHANGED