@pluno/product-agent-web 0.1.34 → 0.1.35
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 +316 -283
- package/package.json +1 -1
|
@@ -265,7 +265,7 @@ function st(e, t, n) {
|
|
|
265
265
|
async function yn(e) {
|
|
266
266
|
return await (await fetch(e)).blob();
|
|
267
267
|
}
|
|
268
|
-
const Cn = "https://app.pluno.ai", En = "/api/product-agent/embed/active-users",
|
|
268
|
+
const Cn = "https://app.pluno.ai", En = "/api/product-agent/embed/active-users", Sn = 1800, kn = 15e3, Ln = 250, Pn = 1e3, An = 3e4;
|
|
269
269
|
function Tn(e, t = {}) {
|
|
270
270
|
let n = !1, o = null, a = null, i = null;
|
|
271
271
|
const l = () => {
|
|
@@ -285,8 +285,8 @@ function Tn(e, t = {}) {
|
|
|
285
285
|
l();
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
-
const
|
|
289
|
-
o = Math.round(f + (s - f) * Mn(
|
|
288
|
+
const k = Math.min(1, (performance.now() - C) / Sn);
|
|
289
|
+
o = Math.round(f + (s - f) * Mn(k)), e(o), k >= 1 && (o = s, e(s), l());
|
|
290
290
|
}, Ln);
|
|
291
291
|
}, d = async () => {
|
|
292
292
|
try {
|
|
@@ -295,7 +295,7 @@ function Tn(e, t = {}) {
|
|
|
295
295
|
return;
|
|
296
296
|
c(s.count), p(s.refreshAfterMs);
|
|
297
297
|
} catch {
|
|
298
|
-
p(
|
|
298
|
+
p(kn);
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
301
|
return d(), () => {
|
|
@@ -328,7 +328,7 @@ function Dn(e) {
|
|
|
328
328
|
function Mn(e) {
|
|
329
329
|
return e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2;
|
|
330
330
|
}
|
|
331
|
-
const Mt = 100, Rn = "product-agent:sdk-preview-socket-connect",
|
|
331
|
+
const Mt = 100, Rn = "product-agent:sdk-preview-socket-connect", On = "product-agent:sdk-preview-socket-send", Bn = "product-agent:sdk-preview-socket-close", Fn = "product-agent:sdk-preview-socket-open", Un = "product-agent:sdk-preview-socket-message", zn = "product-agent:sdk-preview-socket-error", $n = "product-agent:sdk-preview-socket-closed", ct = "product-agent:sdk-preview-socket-id", Gn = "product-agent:preview-diagnostic", Rt = "pluno.productAgent.sharePromptsDisabled", Ce = 10, Hn = 10 * 1024 * 1024, Ot = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/webp", "image/gif", "application/pdf"]), Wn = Array.from(Ot).join(","), jn = 3, j = {
|
|
332
332
|
launcherLabel: "Ask for anything...",
|
|
333
333
|
accentColor: "#7c3aed",
|
|
334
334
|
colorScheme: "light",
|
|
@@ -336,11 +336,11 @@ const Mt = 100, Rn = "product-agent:sdk-preview-socket-connect", Bn = "product-a
|
|
|
336
336
|
scribbleStyle: !1,
|
|
337
337
|
position: "bottom-right",
|
|
338
338
|
movableLauncher: !1
|
|
339
|
-
}, ut = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 104 36"><g><ellipse cx="17.5" cy="24.5" rx="2.4" ry="3" fill="none" stroke="%232c2a1e" stroke-width="1.6" opacity="0.8"/><path d="M18.5 27 C20.5 12, 7.5 2.5, 6 18.5" fill="none" stroke="%232c2a1e" stroke-width="2.5" stroke-linecap="round"/></g><g transform="translate(26 0)"><ellipse cx="17.9" cy="24.1" rx="2.5" ry="2.8" fill="none" stroke="%232c2a1e" stroke-width="1.5" opacity="0.8"/><path d="M18.9 26.4 C21.2 13, 8.6 3.6, 6.9 17.4" fill="none" stroke="%232c2a1e" stroke-width="2.35" stroke-linecap="round"/></g><g transform="translate(52 0)"><ellipse cx="17.1" cy="24.9" rx="2.2" ry="3.1" fill="none" stroke="%232c2a1e" stroke-width="1.7" opacity="0.8"/><path d="M18.1 27.5 C19.9 10.4, 6.4 2, 5.6 19.2" fill="none" stroke="%232c2a1e" stroke-width="2.6" stroke-linecap="round"/></g><g transform="translate(78 0)"><ellipse cx="17.6" cy="24.4" rx="2.4" ry="2.9" fill="none" stroke="%232c2a1e" stroke-width="1.6" opacity="0.8"/><path d="M18.7 26.8 C21 11.2, 7.1 1.6, 6.3 18.1" fill="none" stroke="%232c2a1e" stroke-width="2.45" stroke-linecap="round"/></g></svg>',
|
|
340
|
-
function
|
|
339
|
+
}, ut = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 104 36"><g><ellipse cx="17.5" cy="24.5" rx="2.4" ry="3" fill="none" stroke="%232c2a1e" stroke-width="1.6" opacity="0.8"/><path d="M18.5 27 C20.5 12, 7.5 2.5, 6 18.5" fill="none" stroke="%232c2a1e" stroke-width="2.5" stroke-linecap="round"/></g><g transform="translate(26 0)"><ellipse cx="17.9" cy="24.1" rx="2.5" ry="2.8" fill="none" stroke="%232c2a1e" stroke-width="1.5" opacity="0.8"/><path d="M18.9 26.4 C21.2 13, 8.6 3.6, 6.9 17.4" fill="none" stroke="%232c2a1e" stroke-width="2.35" stroke-linecap="round"/></g><g transform="translate(52 0)"><ellipse cx="17.1" cy="24.9" rx="2.2" ry="3.1" fill="none" stroke="%232c2a1e" stroke-width="1.7" opacity="0.8"/><path d="M18.1 27.5 C19.9 10.4, 6.4 2, 5.6 19.2" fill="none" stroke="%232c2a1e" stroke-width="2.6" stroke-linecap="round"/></g><g transform="translate(78 0)"><ellipse cx="17.6" cy="24.4" rx="2.4" ry="2.9" fill="none" stroke="%232c2a1e" stroke-width="1.6" opacity="0.8"/><path d="M18.7 26.8 C21 11.2, 7.1 1.6, 6.3 18.1" fill="none" stroke="%232c2a1e" stroke-width="2.45" stroke-linecap="round"/></g></svg>', Vn = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', gt = "pluno-pa-scribble-font", Bt = 190, Ft = 41, qn = 48, Kn = 420, Yn = 520, Xn = 0.24, Zn = 680, Jn = 800, Qn = 0.76, B = 8, $e = 50, eo = "http://www.w3.org/2000/svg", to = 11, no = 13, ht = 4, oo = 10, ao = 40, io = "movable-launcher-position-v2", Ut = "pluno-pa-widget-styles", zt = "data-pluno-pa-widget-styles";
|
|
340
|
+
function ro(e) {
|
|
341
341
|
return (t) => new V(t, e);
|
|
342
342
|
}
|
|
343
|
-
async function
|
|
343
|
+
async function lo(e = {}) {
|
|
344
344
|
const t = {
|
|
345
345
|
launcherLabel: e.launcherLabel ?? j.launcherLabel,
|
|
346
346
|
accentColor: e.accentColor ?? j.accentColor,
|
|
@@ -386,8 +386,8 @@ async function ro(e = {}) {
|
|
|
386
386
|
const o = n.attachShadow({ mode: "open" }), a = document.createElement("div");
|
|
387
387
|
a.className = `pluno-pa-widget pluno-pa-widget--${t.position}`, a.setAttribute("data-pluno-product-agent-ui-root", "widget");
|
|
388
388
|
let i = mt(t.accentColor, t.scribbleStyle);
|
|
389
|
-
|
|
390
|
-
const l = await
|
|
389
|
+
yo(a, t.launcherLabel, i, t.movableLauncher), o.appendChild(a);
|
|
390
|
+
const l = await ga(), p = l.ownerDocument;
|
|
391
391
|
l.appendChild(n), a.classList.add(`pluno-pa-widget--${t.colorScheme}`), Lt(o, t.accentColor), ft(a, i, {
|
|
392
392
|
accentColor: t.accentColor,
|
|
393
393
|
colorScheme: t.colorScheme,
|
|
@@ -399,18 +399,18 @@ async function ro(e = {}) {
|
|
|
399
399
|
fontFamily: t.fontFamily,
|
|
400
400
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
401
401
|
});
|
|
402
|
-
const c = a.querySelector(".pluno-pa-widget__launcher"), d = a.querySelector(".pluno-pa-widget__launcher-drag-handle"), s = a.querySelector(".pluno-pa-widget__launcher-input"), f = a.querySelector(".pluno-pa-widget__panel"), C = a.querySelector(".pluno-pa-widget__close"),
|
|
403
|
-
if (!c || !s || !f || !C || !
|
|
402
|
+
const c = a.querySelector(".pluno-pa-widget__launcher"), d = a.querySelector(".pluno-pa-widget__launcher-drag-handle"), s = a.querySelector(".pluno-pa-widget__launcher-input"), f = a.querySelector(".pluno-pa-widget__panel"), C = a.querySelector(".pluno-pa-widget__close"), k = a.querySelector(".pluno-pa-widget__composer"), x = a.querySelector(".pluno-pa-widget__attachment-error"), R = a.querySelector(".pluno-pa-widget__billing-status"), v = a.querySelector(".pluno-pa-widget__attachments"), y = a.querySelector(".pluno-pa-widget__attachment-input"), h = a.querySelector(".pluno-pa-widget__attach"), g = a.querySelector(".pluno-pa-widget__input"), _ = a.querySelector(".pluno-pa-widget__send"), N = a.querySelector(".pluno-pa-widget__new-chat"), Z = a.querySelector(".pluno-pa-widget__timeline-jump"), de = a.querySelector(".pluno-pa-widget__active-users-counter"), E = a.querySelector(".pluno-pa-widget__timeline"), b = a.querySelector(".pluno-pa-widget__timeline-bottom-sentinel");
|
|
403
|
+
if (!c || !s || !f || !C || !k || !x || !R || !v || !y || !h || !g || !_ || !N || !Z || !de || !E || !b)
|
|
404
404
|
throw new Error("Failed to mount Pluno widget");
|
|
405
405
|
if (t.movableLauncher && !d)
|
|
406
406
|
throw new Error("Failed to mount Pluno widget drag handle");
|
|
407
407
|
_t(s), _t(g);
|
|
408
|
-
let m = [],
|
|
408
|
+
let m = [], S = null;
|
|
409
409
|
const P = () => {
|
|
410
|
-
|
|
411
|
-
m = m.filter((u,
|
|
410
|
+
Oo(v, m, (r) => {
|
|
411
|
+
m = m.filter((u, T) => T !== r), P(), O(w.getState()), U();
|
|
412
412
|
});
|
|
413
|
-
},
|
|
413
|
+
}, I = t.loginRequired || t.token || t.webSocketFactory ? void 0 : t.tokenProvider ?? (async () => {
|
|
414
414
|
if (!t.tokenEndpoint)
|
|
415
415
|
throw new Error("Pluno widget requires token or tokenEndpoint");
|
|
416
416
|
const r = await fetch(t.tokenEndpoint, {
|
|
@@ -425,11 +425,11 @@ async function ro(e = {}) {
|
|
|
425
425
|
if (!u.token)
|
|
426
426
|
throw new Error("Pluno token endpoint did not return a token");
|
|
427
427
|
return u.token;
|
|
428
|
-
}),
|
|
428
|
+
}), A = window.fetch.bind(window);
|
|
429
429
|
let w;
|
|
430
430
|
w = await sn.init({
|
|
431
431
|
token: t.token,
|
|
432
|
-
tokenProvider:
|
|
432
|
+
tokenProvider: I,
|
|
433
433
|
backendUrl: t.backendUrl,
|
|
434
434
|
metadata: () => ({
|
|
435
435
|
...t.metadata ?? {},
|
|
@@ -442,8 +442,8 @@ async function ro(e = {}) {
|
|
|
442
442
|
webSocketFactory: t.webSocketFactory,
|
|
443
443
|
autoConnect: t.loginRequired ? !1 : void 0
|
|
444
444
|
});
|
|
445
|
-
const J =
|
|
446
|
-
let
|
|
445
|
+
const J = ha(t), Ee = new Set(J.openToolGroupKeys), ae = new Set(J.seenShareCandidateIds), fe = new Set(ae);
|
|
446
|
+
let Se = J.sharePromptsDisabled || await ma(t), G = t.movableLauncher ? J.launcherPosition : null, qe = G !== null, q = null, ke = !1, Q = !1, ee = {
|
|
447
447
|
enabled: !0
|
|
448
448
|
}, te = 0, Ke = "";
|
|
449
449
|
const H = (r, u) => {
|
|
@@ -455,29 +455,29 @@ async function ro(e = {}) {
|
|
|
455
455
|
}, tn = (r = "jump") => {
|
|
456
456
|
H(!0, r), W(), he(E, () => ee.enabled), te = E.scrollTop;
|
|
457
457
|
}, nn = () => {
|
|
458
|
-
|
|
458
|
+
ke || typeof document > "u" || (Lt(o, t.accentColor), n.isConnected || p.body?.appendChild(n));
|
|
459
459
|
}, Ye = new MutationObserver(nn);
|
|
460
460
|
Ye.observe(p.documentElement, { childList: !0, subtree: !0 });
|
|
461
461
|
const Le = (r = !0) => {
|
|
462
|
-
const u =
|
|
462
|
+
const u = Ge(a, r);
|
|
463
463
|
return bt(
|
|
464
464
|
a,
|
|
465
|
-
|
|
465
|
+
G ?? ho(a, t.position, u),
|
|
466
466
|
u
|
|
467
467
|
);
|
|
468
|
-
},
|
|
469
|
-
|
|
468
|
+
}, F = () => {
|
|
469
|
+
ba(t, {
|
|
470
470
|
isOpen: a.classList.contains("pluno-pa-widget--open"),
|
|
471
471
|
composerValue: g.value,
|
|
472
472
|
openToolGroupKeys: [...Ee],
|
|
473
|
-
launcherPosition: qe ?
|
|
473
|
+
launcherPosition: qe ? G : null,
|
|
474
474
|
seenShareCandidateIds: [...ae].slice(-Mt),
|
|
475
|
-
sharePromptsDisabled:
|
|
475
|
+
sharePromptsDisabled: Se
|
|
476
476
|
});
|
|
477
477
|
}, ne = (r, u = {}) => {
|
|
478
|
-
|
|
479
|
-
debugVersion:
|
|
480
|
-
launcherPosition:
|
|
478
|
+
_o(r, {
|
|
479
|
+
debugVersion: io,
|
|
480
|
+
launcherPosition: G,
|
|
481
481
|
rootClasses: a.className,
|
|
482
482
|
rootStyle: {
|
|
483
483
|
left: a.style.left,
|
|
@@ -494,16 +494,16 @@ async function ro(e = {}) {
|
|
|
494
494
|
...u
|
|
495
495
|
});
|
|
496
496
|
}, be = (r = !0) => {
|
|
497
|
-
if (
|
|
497
|
+
if (!G)
|
|
498
498
|
return _e(a, null), Le(r);
|
|
499
499
|
const u = Le(r);
|
|
500
500
|
return _e(a, u), ne("Applied stored closed launcher position", { visibleLauncherPosition: u }), u;
|
|
501
501
|
}, Xe = (r, u) => {
|
|
502
502
|
if (!r || !u) {
|
|
503
|
-
|
|
503
|
+
wo(a);
|
|
504
504
|
return;
|
|
505
505
|
}
|
|
506
|
-
|
|
506
|
+
bo(a, {
|
|
507
507
|
x: r.x - u.x,
|
|
508
508
|
y: r.y - u.y
|
|
509
509
|
});
|
|
@@ -512,21 +512,21 @@ async function ro(e = {}) {
|
|
|
512
512
|
if (a.classList.contains("pluno-pa-widget--open") || a.classList.contains("pluno-pa-widget--closing")) {
|
|
513
513
|
const u = wt(a, r, t.position);
|
|
514
514
|
Xe(u, r), ne("Applied open panel position after viewport resize", { openPanelPosition: u });
|
|
515
|
-
} else
|
|
515
|
+
} else G && ne("Applied visible launcher position after viewport resize", { visibleLauncherPosition: r });
|
|
516
516
|
};
|
|
517
517
|
let Je = () => {
|
|
518
518
|
};
|
|
519
|
-
window.addEventListener("resize", Ze), t.movableLauncher && d ? (be(), Je =
|
|
519
|
+
window.addEventListener("resize", Ze), t.movableLauncher && d ? (be(), Je = go({
|
|
520
520
|
root: a,
|
|
521
521
|
launcher: c,
|
|
522
522
|
launcherDragHandle: d,
|
|
523
523
|
getPosition: () => Le(),
|
|
524
524
|
setPosition: (r) => {
|
|
525
525
|
const u = r;
|
|
526
|
-
|
|
526
|
+
G = bt(a, r, Ge(a)), _e(a, G), ne("Dragging closed launcher", { requestedPosition: u });
|
|
527
527
|
},
|
|
528
528
|
persist: () => {
|
|
529
|
-
qe = !0,
|
|
529
|
+
qe = !0, F(), ne("Persisted closed launcher drag position");
|
|
530
530
|
}
|
|
531
531
|
})) : _e(a, null);
|
|
532
532
|
let Pe = !1;
|
|
@@ -535,25 +535,25 @@ async function ro(e = {}) {
|
|
|
535
535
|
Pe = !0;
|
|
536
536
|
try {
|
|
537
537
|
const r = await t.billingStatusLoader();
|
|
538
|
-
vt(t.billingStatus, r, w.getState().lastErrorCode) && (t.billingStatus = r,
|
|
538
|
+
vt(t.billingStatus, r, w.getState().lastErrorCode) && (t.billingStatus = r, Be(R, t.billingStatus, w.getState().lastErrorCode), U());
|
|
539
539
|
} finally {
|
|
540
540
|
Pe = !1;
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
}, oe = (r = "", u = !0) => {
|
|
544
544
|
Qe(), q !== null && (window.clearTimeout(q), q = null), f.hidden = !1, C.hidden = !1, a.classList.remove("pluno-pa-widget--closing");
|
|
545
|
-
const
|
|
546
|
-
if (Xe(K,
|
|
547
|
-
a.classList.add("pluno-pa-widget--open"), c.hidden = !0, r && (g.value = r, ge(g)), he(E, () => ee.enabled), te = E.scrollTop, g.focus(), g.setSelectionRange(g.value.length, g.value.length),
|
|
545
|
+
const T = be(), K = wt(a, T, t.position);
|
|
546
|
+
if (Xe(K, T), ne("Opening launcher at clamped open panel position", { openPanelPosition: K, visibleLauncherPosition: T }), H(!0, "open"), W(), !u) {
|
|
547
|
+
a.classList.add("pluno-pa-widget--open"), c.hidden = !0, r && (g.value = r, ge(g)), he(E, () => ee.enabled), te = E.scrollTop, g.focus(), g.setSelectionRange(g.value.length, g.value.length), F();
|
|
548
548
|
return;
|
|
549
549
|
}
|
|
550
550
|
window.requestAnimationFrame(() => {
|
|
551
|
-
a.classList.add("pluno-pa-widget--open"), r && (g.value = r, ge(g)), he(E, () => ee.enabled), te = E.scrollTop, g.focus(), g.setSelectionRange(g.value.length, g.value.length),
|
|
551
|
+
a.classList.add("pluno-pa-widget--open"), r && (g.value = r, ge(g)), he(E, () => ee.enabled), te = E.scrollTop, g.focus(), g.setSelectionRange(g.value.length, g.value.length), F(), q = window.setTimeout(() => {
|
|
552
552
|
c.hidden = !0, he(E, () => ee.enabled), te = E.scrollTop;
|
|
553
553
|
}, 220);
|
|
554
554
|
});
|
|
555
555
|
}, on = () => {
|
|
556
|
-
q !== null && (window.clearTimeout(q), q = null), c.hidden = !1,
|
|
556
|
+
q !== null && (window.clearTimeout(q), q = null), c.hidden = !1, G && (be(!1), ne("Closing launcher at stored position")), a.classList.remove("pluno-pa-widget--open"), a.classList.add("pluno-pa-widget--closing"), F(), q = window.setTimeout(() => {
|
|
557
557
|
f.hidden = !0, C.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
|
|
558
558
|
}, 220);
|
|
559
559
|
};
|
|
@@ -583,34 +583,34 @@ async function ro(e = {}) {
|
|
|
583
583
|
);
|
|
584
584
|
et?.observe(b);
|
|
585
585
|
const U = () => {
|
|
586
|
-
_.disabled =
|
|
586
|
+
_.disabled = $(t.billingStatus) || !w.getState().isThinking && g.value.trim().length === 0 && m.length === 0, h.disabled = t.loginRequired || $(t.billingStatus);
|
|
587
587
|
};
|
|
588
|
-
t.loginRequired && (s.readOnly = !0, s.placeholder = t.loginButtonLabel, g.placeholder = t.loginButtonLabel,
|
|
588
|
+
t.loginRequired && (s.readOnly = !0, s.placeholder = t.loginButtonLabel, g.placeholder = t.loginButtonLabel, k.hidden = !0), k.addEventListener("submit", (r) => {
|
|
589
589
|
if (r.preventDefault(), t.loginRequired) {
|
|
590
590
|
t.onLoginClick?.();
|
|
591
591
|
return;
|
|
592
592
|
}
|
|
593
|
-
|
|
593
|
+
$(t.billingStatus) || (Q = !0, H(!0, "send"), W(), m = Re(w, g, m), P(), U());
|
|
594
594
|
});
|
|
595
595
|
let ce = 0;
|
|
596
596
|
const an = () => {
|
|
597
597
|
ce = 0, a.classList.remove("pluno-pa-widget--drag-over");
|
|
598
598
|
}, tt = (r) => {
|
|
599
|
-
|
|
600
|
-
x.textContent = "", x.hidden = !0,
|
|
599
|
+
S !== null && window.clearTimeout(S), x.textContent = r, x.hidden = !1, S = window.setTimeout(() => {
|
|
600
|
+
x.textContent = "", x.hidden = !0, S = null;
|
|
601
601
|
}, 3e3);
|
|
602
602
|
}, rn = () => {
|
|
603
|
-
|
|
603
|
+
S !== null && (window.clearTimeout(S), S = null), x.textContent = "", x.hidden = !0;
|
|
604
604
|
}, nt = async (r) => {
|
|
605
605
|
if (r.length === 0)
|
|
606
606
|
return;
|
|
607
|
-
const u = await
|
|
607
|
+
const u = await zo(r);
|
|
608
608
|
if (m.length + u.length > Ce)
|
|
609
609
|
throw new Error(`Attach up to ${Ce} files per message.`);
|
|
610
|
-
m = [...m, ...u], P(), rn(), U(),
|
|
610
|
+
m = [...m, ...u], P(), rn(), U(), O(w.getState()), a.classList.contains("pluno-pa-widget--open") || oe();
|
|
611
611
|
};
|
|
612
612
|
h.addEventListener("click", () => {
|
|
613
|
-
t.loginRequired ||
|
|
613
|
+
t.loginRequired || $(t.billingStatus) || y.click();
|
|
614
614
|
}), y.addEventListener("change", () => {
|
|
615
615
|
const r = Array.from(y.files ?? []);
|
|
616
616
|
y.value = "", nt(r).catch((u) => {
|
|
@@ -627,9 +627,9 @@ async function ro(e = {}) {
|
|
|
627
627
|
xe(r.dataTransfer) && (r.stopPropagation(), ce = Math.max(0, ce - 1), ce === 0 && a.classList.remove("pluno-pa-widget--drag-over"));
|
|
628
628
|
}), a.addEventListener("drop", (r) => {
|
|
629
629
|
const u = r.dataTransfer;
|
|
630
|
-
!xe(u) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), an(), nt(u.files).catch((
|
|
631
|
-
tt(
|
|
632
|
-
message:
|
|
630
|
+
!xe(u) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), an(), nt(u.files).catch((T) => {
|
|
631
|
+
tt(T instanceof Error ? T.message : "Failed to attach file"), Y("web-sdk.widget", "Attachment failed", {
|
|
632
|
+
message: T instanceof Error ? T.message : String(T)
|
|
633
633
|
});
|
|
634
634
|
}));
|
|
635
635
|
}), _.addEventListener("click", () => {
|
|
@@ -641,38 +641,38 @@ async function ro(e = {}) {
|
|
|
641
641
|
w.stop();
|
|
642
642
|
return;
|
|
643
643
|
}
|
|
644
|
-
Q = !0, H(!0, "send"), W(), m = Re(w, g, m), P(), U(),
|
|
645
|
-
}),
|
|
646
|
-
Q = !0, H(!0, "newSession"), W(), w.startNewSession(), Ee.clear(), g.value = "", m = [], P(), ge(g),
|
|
644
|
+
Q = !0, H(!0, "send"), W(), m = Re(w, g, m), P(), U(), O(w.getState());
|
|
645
|
+
}), N.addEventListener("click", () => {
|
|
646
|
+
Q = !0, H(!0, "newSession"), W(), w.startNewSession(), Ee.clear(), g.value = "", m = [], P(), ge(g), F(), U(), g.focus(), O(w.getState());
|
|
647
647
|
}), g.addEventListener("input", () => {
|
|
648
|
-
ge(g),
|
|
648
|
+
ge(g), F(), U(), O(w.getState());
|
|
649
649
|
}), g.addEventListener("keydown", (r) => {
|
|
650
650
|
if (!(r.key !== "Enter" || r.shiftKey)) {
|
|
651
651
|
if (r.preventDefault(), t.loginRequired) {
|
|
652
652
|
t.onLoginClick?.();
|
|
653
653
|
return;
|
|
654
654
|
}
|
|
655
|
-
Q = !0, H(!0, "send"), W(), m = Re(w, g, m), P(), U(),
|
|
655
|
+
Q = !0, H(!0, "send"), W(), m = Re(w, g, m), P(), U(), O(w.getState());
|
|
656
656
|
}
|
|
657
657
|
}), a.addEventListener("click", (r) => {
|
|
658
|
-
(r.target instanceof Element ? r.target : null)?.closest("a[href]") &&
|
|
658
|
+
(r.target instanceof Element ? r.target : null)?.closest("a[href]") && F();
|
|
659
659
|
}), J.composerValue && (g.value = J.composerValue, ge(g)), J.isOpen && oe(g.value, !1);
|
|
660
660
|
const ot = () => i;
|
|
661
661
|
let Ae = w.getState().appearance !== null, we = null, ue = null, ie = null, at = w.getState().isThinking, re = null, Te = null, it = () => {
|
|
662
662
|
};
|
|
663
|
-
const ln = !!t.socialPostDraftHandler,
|
|
664
|
-
if (Ve(r.lastErrorCode) ? re = r.lastErrorCode : t.billingStatus?.creditsUsed !== null &&
|
|
665
|
-
|
|
663
|
+
const ln = !!t.socialPostDraftHandler, O = (r) => {
|
|
664
|
+
if (Ve(r.lastErrorCode) ? re = r.lastErrorCode : t.billingStatus?.creditsUsed !== null && !$(t.billingStatus) && (re = null), Be(R, t.billingStatus, re), t.loginRequired) {
|
|
665
|
+
Qo(E, _, N, ot, t.loginButtonLabel, t.onLoginClick);
|
|
666
666
|
return;
|
|
667
667
|
}
|
|
668
|
-
const u =
|
|
668
|
+
const u = xo(r), T = u !== Ke;
|
|
669
669
|
Ke = u;
|
|
670
670
|
const K = Q || ee.enabled;
|
|
671
|
-
Q = !1,
|
|
671
|
+
Q = !1, Jo(
|
|
672
672
|
E,
|
|
673
673
|
b,
|
|
674
674
|
_,
|
|
675
|
-
|
|
675
|
+
N,
|
|
676
676
|
de,
|
|
677
677
|
r,
|
|
678
678
|
Te,
|
|
@@ -680,33 +680,33 @@ async function ro(e = {}) {
|
|
|
680
680
|
K,
|
|
681
681
|
() => ee.enabled,
|
|
682
682
|
Ee,
|
|
683
|
-
|
|
683
|
+
F,
|
|
684
684
|
ot,
|
|
685
|
-
(
|
|
686
|
-
Q = !0, H(!0, "send"), W(), w.sendMessage(
|
|
685
|
+
(M) => {
|
|
686
|
+
Q = !0, H(!0, "send"), W(), w.sendMessage(M);
|
|
687
687
|
},
|
|
688
|
-
ln && !
|
|
688
|
+
ln && !Se ? {
|
|
689
689
|
dismissedCandidateIds: fe,
|
|
690
690
|
draftingCandidateId: we,
|
|
691
691
|
error: ue,
|
|
692
|
-
onSeen: (
|
|
693
|
-
ae.add(
|
|
692
|
+
onSeen: (M) => {
|
|
693
|
+
ae.add(M.id), F();
|
|
694
694
|
},
|
|
695
|
-
onDraft: (
|
|
696
|
-
pn(
|
|
695
|
+
onDraft: (M) => {
|
|
696
|
+
pn(M);
|
|
697
697
|
},
|
|
698
|
-
onDismiss: (
|
|
699
|
-
ae.add(
|
|
698
|
+
onDismiss: (M) => {
|
|
699
|
+
ae.add(M.id), fe.add(M.id), F(), ue = null, O(w.getState());
|
|
700
700
|
},
|
|
701
|
-
onDisable: (
|
|
702
|
-
|
|
701
|
+
onDisable: (M) => {
|
|
702
|
+
Se = !0, ae.add(M.id), fe.add(M.id), F(), fa(t, !0), ue = null, O(w.getState());
|
|
703
703
|
}
|
|
704
704
|
} : void 0
|
|
705
|
-
), K ? (te = E.scrollTop, W()) :
|
|
705
|
+
), K ? (te = E.scrollTop, W()) : T && vo(r) && en();
|
|
706
706
|
};
|
|
707
707
|
return it = Tn((r) => {
|
|
708
|
-
Te = r, !
|
|
709
|
-
}, { backendUrl: t.backendUrl, fetcher:
|
|
708
|
+
Te = r, !ke && Ct(w.getState(), g.value.trim().length > 0 || m.length > 0) && O(w.getState());
|
|
709
|
+
}, { backendUrl: t.backendUrl, fetcher: A, loader: t.activeUsersLoader }), w.on("state", (r) => {
|
|
710
710
|
const u = at && !r.isThinking;
|
|
711
711
|
at = r.isThinking, r.appearance ? (Ae = !0, Y("web-sdk.widget", "Agent state supplied appearance", {
|
|
712
712
|
appearance: r.appearance
|
|
@@ -714,15 +714,15 @@ async function ro(e = {}) {
|
|
|
714
714
|
fallbackAccentColor: t.accentColor,
|
|
715
715
|
fallbackColorScheme: t.colorScheme,
|
|
716
716
|
fallbackFontFamily: t.fontFamily
|
|
717
|
-
}), Ne({}, "agent.state.appearance-cleared")),
|
|
718
|
-
}),
|
|
717
|
+
}), Ne({}, "agent.state.appearance-cleared")), O(r), U(), u && Qe();
|
|
718
|
+
}), O(w.getState()), U(), {
|
|
719
719
|
agent: w,
|
|
720
720
|
updateAppearance: (r) => {
|
|
721
721
|
r.scribbleStyle !== void 0 && (t.scribbleStyle = r.scribbleStyle), Ne(r, "widgetHandle.updateAppearance");
|
|
722
722
|
},
|
|
723
723
|
updateBillingStatus: (r) => {
|
|
724
724
|
const u = r ?? null;
|
|
725
|
-
vt(t.billingStatus, u, re) && (t.billingStatus = u, t.billingStatus?.creditsUsed !== null &&
|
|
725
|
+
vt(t.billingStatus, u, re) && (t.billingStatus = u, t.billingStatus?.creditsUsed !== null && !$(t.billingStatus) && (re = null), Be(
|
|
726
726
|
a.querySelector(".pluno-pa-widget__billing-status"),
|
|
727
727
|
t.billingStatus,
|
|
728
728
|
re
|
|
@@ -732,19 +732,19 @@ async function ro(e = {}) {
|
|
|
732
732
|
oe(g.value, !1);
|
|
733
733
|
},
|
|
734
734
|
destroy: () => {
|
|
735
|
-
|
|
735
|
+
ke = !0, Ye.disconnect(), et?.disconnect(), window.removeEventListener("resize", Ze), Je(), S !== null && window.clearTimeout(S), it(), ie?.remove(), w.destroy(), n.remove();
|
|
736
736
|
}
|
|
737
737
|
};
|
|
738
738
|
async function pn(r) {
|
|
739
739
|
if (!we) {
|
|
740
|
-
we = r.id, ue = null,
|
|
740
|
+
we = r.id, ue = null, O(w.getState());
|
|
741
741
|
try {
|
|
742
742
|
if (!t.socialPostDraftHandler)
|
|
743
743
|
throw new Error("Social post drafting is not available here.");
|
|
744
744
|
const u = await t.socialPostDraftHandler(r);
|
|
745
745
|
if (!u.linkedinPost || !u.xPost)
|
|
746
746
|
throw new Error("Pluno did not return a complete social post draft.");
|
|
747
|
-
ae.add(r.id), fe.add(r.id),
|
|
747
|
+
ae.add(r.id), fe.add(r.id), F(), ie?.remove(), ie = na(u, {
|
|
748
748
|
socialPostRewardsUrl: t.socialPostRewardsUrl,
|
|
749
749
|
onClose: () => {
|
|
750
750
|
ie?.remove(), ie = null;
|
|
@@ -753,23 +753,23 @@ async function ro(e = {}) {
|
|
|
753
753
|
} catch (u) {
|
|
754
754
|
ue = u instanceof Error ? u.message : "Could not draft social post.";
|
|
755
755
|
} finally {
|
|
756
|
-
we = null,
|
|
756
|
+
we = null, O(w.getState());
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
759
|
}
|
|
760
760
|
function Ne(r, u) {
|
|
761
|
-
const
|
|
762
|
-
i = mt(
|
|
763
|
-
accentColor:
|
|
761
|
+
const T = r.accentColor ?? t.accentColor, K = r.colorScheme ?? t.colorScheme, M = r.fontFamily ?? t.fontFamily, Ie = r.scribbleStyle ?? t.scribbleStyle;
|
|
762
|
+
i = mt(T, Ie), ft(a, i, {
|
|
763
|
+
accentColor: T,
|
|
764
764
|
colorScheme: K,
|
|
765
|
-
fontFamily:
|
|
765
|
+
fontFamily: M,
|
|
766
766
|
scribbleStyle: Ie
|
|
767
767
|
}), Y("web-sdk.widget", "Updated widget appearance", {
|
|
768
768
|
source: u,
|
|
769
769
|
inputAppearance: r,
|
|
770
|
-
appliedAccentColor:
|
|
770
|
+
appliedAccentColor: T,
|
|
771
771
|
appliedColorScheme: K,
|
|
772
|
-
appliedFontFamily:
|
|
772
|
+
appliedFontFamily: M,
|
|
773
773
|
appliedScribbleStyle: Ie,
|
|
774
774
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
775
775
|
});
|
|
@@ -778,15 +778,38 @@ async function ro(e = {}) {
|
|
|
778
778
|
function mt(e, t) {
|
|
779
779
|
return t ? hn(e) : un(e);
|
|
780
780
|
}
|
|
781
|
+
function po(e) {
|
|
782
|
+
const t = so(e);
|
|
783
|
+
return t === null ? "#fafafa" : co(t) > 0.5 ? "#18181b" : "#fafaf9";
|
|
784
|
+
}
|
|
785
|
+
function so(e) {
|
|
786
|
+
const t = e.trim();
|
|
787
|
+
return /^#[0-9a-f]{6}$/i.test(t) ? [
|
|
788
|
+
Number.parseInt(t.slice(1, 3), 16),
|
|
789
|
+
Number.parseInt(t.slice(3, 5), 16),
|
|
790
|
+
Number.parseInt(t.slice(5, 7), 16)
|
|
791
|
+
] : /^#[0-9a-f]{3}$/i.test(t) ? [
|
|
792
|
+
Number.parseInt(t[1] + t[1], 16),
|
|
793
|
+
Number.parseInt(t[2] + t[2], 16),
|
|
794
|
+
Number.parseInt(t[3] + t[3], 16)
|
|
795
|
+
] : null;
|
|
796
|
+
}
|
|
797
|
+
function co([e, t, n]) {
|
|
798
|
+
const o = (a) => {
|
|
799
|
+
const i = a / 255;
|
|
800
|
+
return i <= 0.03928 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4;
|
|
801
|
+
};
|
|
802
|
+
return 0.2126 * o(e) + 0.7152 * o(t) + 0.0722 * o(n);
|
|
803
|
+
}
|
|
781
804
|
function ft(e, t, n) {
|
|
782
805
|
e.classList.toggle("pluno-pa-widget--dark", n.colorScheme === "dark"), e.classList.toggle("pluno-pa-widget--light", n.colorScheme !== "dark"), e.classList.toggle("pluno-pa-widget--scribble", n.scribbleStyle);
|
|
783
806
|
const o = n.scribbleStyle ? Nt(n.accentColor) : n.accentColor;
|
|
784
|
-
e.style.setProperty("--pluno-pa-accent", o), e.style.fontFamily = n.scribbleStyle ?
|
|
807
|
+
e.style.setProperty("--pluno-pa-accent", o), n.scribbleStyle ? e.style.setProperty("--pluno-pa-accent-contrast", po(o)) : e.style.removeProperty("--pluno-pa-accent-contrast"), e.style.fontFamily = n.scribbleStyle ? Vn : n.fontFamily, n.scribbleStyle && uo(e.ownerDocument);
|
|
785
808
|
const a = Array.from(e.querySelectorAll(".pluno-pa-widget__character"));
|
|
786
809
|
for (const i of a)
|
|
787
810
|
i.src = t;
|
|
788
811
|
}
|
|
789
|
-
function
|
|
812
|
+
function uo(e) {
|
|
790
813
|
if (e.getElementById(gt))
|
|
791
814
|
return;
|
|
792
815
|
const t = e.createElement("style");
|
|
@@ -798,7 +821,7 @@ function lo(e) {
|
|
|
798
821
|
src: url("https://fonts.gstatic.com/s/architectsdaughter/v20/KtkxAKiDZI_td1Lkx62xHZHDtgO_Y-bvTYlg4-7jA-U.woff2") format("woff2");
|
|
799
822
|
}`, e.head.appendChild(t), e.fonts?.load('16px "Architects Daughter"');
|
|
800
823
|
}
|
|
801
|
-
function
|
|
824
|
+
function go({
|
|
802
825
|
root: e,
|
|
803
826
|
launcher: t,
|
|
804
827
|
launcherDragHandle: n,
|
|
@@ -811,7 +834,7 @@ function po({
|
|
|
811
834
|
l = null, p = null, c = null, d = !1, e.classList.remove("pluno-pa-widget--dragging");
|
|
812
835
|
}, C = (h) => {
|
|
813
836
|
e.classList.contains("pluno-pa-widget--open") || e.classList.contains("pluno-pa-widget--closing") || (h.preventDefault(), h.stopPropagation(), l = h.pointerId, p = { x: h.clientX, y: h.clientY }, c = o(), d = !1, t.setPointerCapture?.(h.pointerId));
|
|
814
|
-
},
|
|
837
|
+
}, k = (h) => {
|
|
815
838
|
if (l !== h.pointerId || !p || !c)
|
|
816
839
|
return;
|
|
817
840
|
h.preventDefault();
|
|
@@ -819,7 +842,7 @@ function po({
|
|
|
819
842
|
!d && Math.hypot(g, _) < ht || (d = !0, e.classList.add("pluno-pa-widget--dragging"), a({ x: c.x + g, y: c.y + _ }));
|
|
820
843
|
}, x = (h) => {
|
|
821
844
|
l === h.pointerId && (h.preventDefault(), h.stopPropagation(), d && (s = { x: h.clientX, y: h.clientY }, i()), f());
|
|
822
|
-
},
|
|
845
|
+
}, R = (h) => {
|
|
823
846
|
l === h.pointerId && (h.preventDefault(), f());
|
|
824
847
|
}, v = (h) => {
|
|
825
848
|
if (!s)
|
|
@@ -829,35 +852,35 @@ function po({
|
|
|
829
852
|
}, y = (h) => {
|
|
830
853
|
if (e.classList.contains("pluno-pa-widget--open") || e.classList.contains("pluno-pa-widget--closing"))
|
|
831
854
|
return;
|
|
832
|
-
const g = h.shiftKey ?
|
|
833
|
-
let
|
|
834
|
-
h.key === "ArrowUp" ?
|
|
855
|
+
const g = h.shiftKey ? ao : oo, _ = o();
|
|
856
|
+
let N = null;
|
|
857
|
+
h.key === "ArrowUp" ? N = { x: _.x, y: _.y - g } : h.key === "ArrowDown" ? N = { x: _.x, y: _.y + g } : h.key === "ArrowLeft" ? N = { x: _.x - g, y: _.y } : h.key === "ArrowRight" && (N = { x: _.x + g, y: _.y }), N && (h.preventDefault(), h.stopPropagation(), a(N), i());
|
|
835
858
|
};
|
|
836
|
-
return t.addEventListener("pointerdown", C), t.addEventListener("pointermove",
|
|
837
|
-
t.removeEventListener("pointerdown", C), t.removeEventListener("pointermove",
|
|
859
|
+
return t.addEventListener("pointerdown", C), t.addEventListener("pointermove", k), t.addEventListener("pointerup", x), t.addEventListener("pointercancel", R), t.addEventListener("click", v, !0), n.addEventListener("keydown", y), () => {
|
|
860
|
+
t.removeEventListener("pointerdown", C), t.removeEventListener("pointermove", k), t.removeEventListener("pointerup", x), t.removeEventListener("pointercancel", R), t.removeEventListener("click", v, !0), n.removeEventListener("keydown", y);
|
|
838
861
|
};
|
|
839
862
|
}
|
|
840
|
-
function
|
|
863
|
+
function Ge(e, t = !0) {
|
|
841
864
|
const n = se(), o = e.getBoundingClientRect(), a = !e.classList.contains("pluno-pa-widget--open") && !e.classList.contains("pluno-pa-widget--closing");
|
|
842
865
|
return {
|
|
843
|
-
width: t && a && o.width > 0 ? o.width : Math.min(
|
|
844
|
-
height: t && a && o.height > 0 ? o.height : e.classList.contains("pluno-pa-widget--scribble") ?
|
|
866
|
+
width: t && a && o.width > 0 ? o.width : Math.min(Bt, n.width - 36),
|
|
867
|
+
height: t && a && o.height > 0 ? o.height : e.classList.contains("pluno-pa-widget--scribble") ? qn : Ft
|
|
845
868
|
};
|
|
846
869
|
}
|
|
847
|
-
function
|
|
870
|
+
function $t() {
|
|
848
871
|
const e = se();
|
|
849
872
|
return {
|
|
850
873
|
width: Math.min(
|
|
851
|
-
pe(e.width *
|
|
852
|
-
e.width -
|
|
874
|
+
pe(e.width * Xn, Kn, Yn),
|
|
875
|
+
e.width - B * 2
|
|
853
876
|
),
|
|
854
877
|
height: Math.min(
|
|
855
|
-
pe(e.height *
|
|
856
|
-
e.height -
|
|
878
|
+
pe(e.height * Qn, Zn, Jn),
|
|
879
|
+
e.height - $e - B
|
|
857
880
|
)
|
|
858
881
|
};
|
|
859
882
|
}
|
|
860
|
-
function
|
|
883
|
+
function ho(e, t, n) {
|
|
861
884
|
const o = Number.parseFloat(e.style.left), a = Number.parseFloat(e.style.top);
|
|
862
885
|
if (Number.isFinite(o) && Number.isFinite(a))
|
|
863
886
|
return { x: o, y: a };
|
|
@@ -871,30 +894,30 @@ function so(e, t, n) {
|
|
|
871
894
|
};
|
|
872
895
|
}
|
|
873
896
|
function bt(e, t, n) {
|
|
874
|
-
const o = se(), a =
|
|
897
|
+
const o = se(), a = B + mo(e);
|
|
875
898
|
return {
|
|
876
|
-
x: pe(t.x,
|
|
877
|
-
y: pe(t.y, a, Math.max(a, o.height - n.height -
|
|
899
|
+
x: pe(t.x, B, Math.max(B, o.width - n.width - B)),
|
|
900
|
+
y: pe(t.y, a, Math.max(a, o.height - n.height - B))
|
|
878
901
|
};
|
|
879
902
|
}
|
|
880
|
-
function
|
|
881
|
-
return e.classList.contains("pluno-pa-widget--scribble") ?
|
|
903
|
+
function mo(e) {
|
|
904
|
+
return e.classList.contains("pluno-pa-widget--scribble") ? no : to;
|
|
882
905
|
}
|
|
883
906
|
function wt(e, t, n) {
|
|
884
|
-
const o =
|
|
907
|
+
const o = Ge(e), a = $t(), i = {
|
|
885
908
|
x: n === "bottom-left" ? t.x : t.x + o.width - a.width,
|
|
886
909
|
y: t.y + o.height - a.height
|
|
887
910
|
};
|
|
888
|
-
return
|
|
911
|
+
return fo(i);
|
|
889
912
|
}
|
|
890
|
-
function
|
|
891
|
-
const t = se(), n =
|
|
913
|
+
function fo(e) {
|
|
914
|
+
const t = se(), n = $t();
|
|
892
915
|
return {
|
|
893
|
-
x: pe(e.x,
|
|
916
|
+
x: pe(e.x, B, Math.max(B, t.width - n.width - B)),
|
|
894
917
|
y: pe(
|
|
895
918
|
e.y,
|
|
896
|
-
|
|
897
|
-
Math.max(
|
|
919
|
+
$e,
|
|
920
|
+
Math.max($e, t.height - n.height - B)
|
|
898
921
|
)
|
|
899
922
|
};
|
|
900
923
|
}
|
|
@@ -905,16 +928,16 @@ function _e(e, t) {
|
|
|
905
928
|
}
|
|
906
929
|
e.style.left = `${t.x}px`, e.style.top = `${t.y}px`, e.style.right = "auto", e.style.bottom = "auto";
|
|
907
930
|
}
|
|
908
|
-
function
|
|
931
|
+
function bo(e, t) {
|
|
909
932
|
e.style.setProperty("--pluno-pa-panel-offset-x", `${t.x}px`), e.style.setProperty("--pluno-pa-panel-offset-y", `${t.y}px`);
|
|
910
933
|
}
|
|
911
|
-
function
|
|
934
|
+
function wo(e) {
|
|
912
935
|
e.style.removeProperty("--pluno-pa-panel-offset-x"), e.style.removeProperty("--pluno-pa-panel-offset-y");
|
|
913
936
|
}
|
|
914
937
|
function se() {
|
|
915
938
|
return {
|
|
916
|
-
width: window.innerWidth || document.documentElement.clientWidth ||
|
|
917
|
-
height: window.innerHeight || document.documentElement.clientHeight || Ft +
|
|
939
|
+
width: window.innerWidth || document.documentElement.clientWidth || Bt + B * 2,
|
|
940
|
+
height: window.innerHeight || document.documentElement.clientHeight || Ft + B * 2
|
|
918
941
|
};
|
|
919
942
|
}
|
|
920
943
|
function Me(e) {
|
|
@@ -938,9 +961,9 @@ function Y(e, t, n) {
|
|
|
938
961
|
message: t,
|
|
939
962
|
details: n
|
|
940
963
|
}, i = o.__plunoProductAgentDiagnostics__ ?? [];
|
|
941
|
-
i.push(a), i.length > 120 && i.splice(0, i.length - 120), o.__plunoProductAgentDiagnostics__ = i, o.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent(
|
|
964
|
+
i.push(a), i.length > 120 && i.splice(0, i.length - 120), o.__plunoProductAgentDiagnostics__ = i, o.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent(Gn, { detail: a }));
|
|
942
965
|
}
|
|
943
|
-
function
|
|
966
|
+
function _o(e, t) {
|
|
944
967
|
Y("web-sdk.widget.position", e, t);
|
|
945
968
|
}
|
|
946
969
|
function Re(e, t, n) {
|
|
@@ -957,7 +980,7 @@ function he(e, t = () => !0) {
|
|
|
957
980
|
t() && (e.scrollTop = e.scrollHeight);
|
|
958
981
|
});
|
|
959
982
|
}
|
|
960
|
-
function
|
|
983
|
+
function xo(e) {
|
|
961
984
|
const t = e.messages[e.messages.length - 1];
|
|
962
985
|
return [
|
|
963
986
|
e.messages.length,
|
|
@@ -968,13 +991,13 @@ function fo(e) {
|
|
|
968
991
|
e.lastError ?? ""
|
|
969
992
|
].join(":");
|
|
970
993
|
}
|
|
971
|
-
function
|
|
994
|
+
function vo(e) {
|
|
972
995
|
return e.messages.length > 0 || e.assistantDraft.length > 0 || e.isThinking || !!e.lastError;
|
|
973
996
|
}
|
|
974
|
-
function
|
|
975
|
-
e.appendChild(
|
|
997
|
+
function yo(e, t, n, o) {
|
|
998
|
+
e.appendChild(Po()), e.appendChild(Co(t, n, o)), e.appendChild(Wt("pluno-pa-widget__close", "Close", Ao(16), !0)), e.appendChild(Eo(n));
|
|
976
999
|
}
|
|
977
|
-
function
|
|
1000
|
+
function Co(e, t, n) {
|
|
978
1001
|
const o = document.createElement("form");
|
|
979
1002
|
if (o.className = "pluno-pa-widget__launcher", n) {
|
|
980
1003
|
const i = document.createElement("button");
|
|
@@ -984,21 +1007,21 @@ function _o(e, t, n) {
|
|
|
984
1007
|
const a = document.createElement("input");
|
|
985
1008
|
return a.className = "pluno-pa-widget__launcher-input", a.type = "text", a.placeholder = e, a.setAttribute("aria-label", e), o.appendChild(a), o;
|
|
986
1009
|
}
|
|
987
|
-
function
|
|
1010
|
+
function Eo(e) {
|
|
988
1011
|
const t = document.createElement("section");
|
|
989
1012
|
t.className = "pluno-pa-widget__panel", t.hidden = !0;
|
|
990
1013
|
const n = document.createElement("div");
|
|
991
1014
|
n.className = "pluno-pa-widget__timeline-wrap";
|
|
992
1015
|
const o = document.createElement("main");
|
|
993
|
-
o.className = "pluno-pa-widget__timeline", o.appendChild(
|
|
1016
|
+
o.className = "pluno-pa-widget__timeline", o.appendChild(ko(e));
|
|
994
1017
|
const a = document.createElement("div");
|
|
995
1018
|
a.className = "pluno-pa-widget__timeline-bottom-sentinel", a.setAttribute("aria-hidden", "true"), o.appendChild(a), n.appendChild(o);
|
|
996
1019
|
const i = document.createElement("div");
|
|
997
1020
|
i.className = "pluno-pa-widget__active-users-counter", i.hidden = !0, n.appendChild(i);
|
|
998
1021
|
const l = document.createElement("button");
|
|
999
|
-
return l.type = "button", l.className = "pluno-pa-widget__timeline-jump", l.textContent = "New messages ↓", l.hidden = !0, n.appendChild(l), n.appendChild(Wt("pluno-pa-widget__new-chat", "New chat",
|
|
1022
|
+
return l.type = "button", l.className = "pluno-pa-widget__timeline-jump", l.textContent = "New messages ↓", l.hidden = !0, n.appendChild(l), n.appendChild(Wt("pluno-pa-widget__new-chat", "New chat", To(), !0)), t.appendChild(n), t.appendChild(So()), t;
|
|
1000
1023
|
}
|
|
1001
|
-
function
|
|
1024
|
+
function So() {
|
|
1002
1025
|
const e = document.createElement("form");
|
|
1003
1026
|
e.className = "pluno-pa-widget__composer";
|
|
1004
1027
|
const t = document.createElement("div");
|
|
@@ -1012,7 +1035,7 @@ function vo() {
|
|
|
1012
1035
|
const i = document.createElement("input");
|
|
1013
1036
|
i.className = "pluno-pa-widget__attachment-input", i.type = "file", i.accept = Wn, i.multiple = !0, i.tabIndex = -1, i.setAttribute("aria-hidden", "true"), a.appendChild(i);
|
|
1014
1037
|
const l = document.createElement("button");
|
|
1015
|
-
l.type = "button", l.className = "pluno-pa-widget__attach", l.setAttribute("aria-label", "Attach files"), l.title = "Attach files", l.appendChild(
|
|
1038
|
+
l.type = "button", l.className = "pluno-pa-widget__attach", l.setAttribute("aria-label", "Attach files"), l.title = "Attach files", l.appendChild(No()), l.appendChild(Io()), a.appendChild(l);
|
|
1016
1039
|
const p = document.createElement("textarea");
|
|
1017
1040
|
p.className = "pluno-pa-widget__input", p.rows = 1, p.placeholder = "Ask for anything...", a.appendChild(p);
|
|
1018
1041
|
const c = document.createElement("button");
|
|
@@ -1024,15 +1047,15 @@ function vo() {
|
|
|
1024
1047
|
const f = document.createElement("span");
|
|
1025
1048
|
return f.className = "pluno-pa-widget__ai-disclaimer", f.textContent = "AI can make mistakes. Verify outputs.", d.appendChild(f), e.appendChild(d), e;
|
|
1026
1049
|
}
|
|
1027
|
-
function
|
|
1050
|
+
function ko(e) {
|
|
1028
1051
|
const t = document.createElement("div");
|
|
1029
|
-
return t.className = "pluno-pa-widget__empty-state", t.appendChild(Ht("pluno-pa-widget__character--empty", e)), t.appendChild(
|
|
1052
|
+
return t.className = "pluno-pa-widget__empty-state", t.appendChild(Ht("pluno-pa-widget__character--empty", e)), t.appendChild(Gt()), t;
|
|
1030
1053
|
}
|
|
1031
|
-
function
|
|
1054
|
+
function Gt() {
|
|
1032
1055
|
const e = document.createElement("div");
|
|
1033
1056
|
return e.className = "pluno-pa-widget__empty", e.appendChild(document.createTextNode("Hey there, I'm Pluno 👋")), e.appendChild(document.createElement("br")), e.appendChild(document.createTextNode("What do you want to do today?")), e;
|
|
1034
1057
|
}
|
|
1035
|
-
function
|
|
1058
|
+
function Lo(e, t) {
|
|
1036
1059
|
e.replaceChildren(), e.setAttribute("aria-label", `${t.toLocaleString("en-US")} users currently active`);
|
|
1037
1060
|
const n = document.createElement("span");
|
|
1038
1061
|
n.className = "pluno-pa-widget__active-users-counter-dot", n.setAttribute("aria-hidden", "true"), e.appendChild(n), e.appendChild(document.createTextNode(`${t.toLocaleString("en-US")} users currently active`));
|
|
@@ -1045,7 +1068,7 @@ function Wt(e, t, n, o) {
|
|
|
1045
1068
|
const a = document.createElement("button");
|
|
1046
1069
|
return a.type = "button", a.className = e, a.setAttribute("aria-label", t), a.title = t, a.hidden = o, a.appendChild(n), a;
|
|
1047
1070
|
}
|
|
1048
|
-
function
|
|
1071
|
+
function Po() {
|
|
1049
1072
|
const e = L("svg", {
|
|
1050
1073
|
class: "pluno-pa-widget__scribble-defs",
|
|
1051
1074
|
"aria-hidden": "true",
|
|
@@ -1053,9 +1076,9 @@ function Eo() {
|
|
|
1053
1076
|
width: "0",
|
|
1054
1077
|
height: "0"
|
|
1055
1078
|
}), t = L("defs");
|
|
1056
|
-
return t.appendChild(
|
|
1079
|
+
return t.appendChild(Oe("pluno-pa-scribble-wobble", "2", "12")), t.appendChild(Oe("pluno-pa-scribble-wobble-2", "5", "15")), t.appendChild(Oe("pluno-pa-scribble-wobble-3", "9", "19")), e.appendChild(t), e;
|
|
1057
1080
|
}
|
|
1058
|
-
function
|
|
1081
|
+
function Oe(e, t, n) {
|
|
1059
1082
|
const o = L("filter", { id: e, x: "-8%", y: "-8%", width: "116%", height: "116%" });
|
|
1060
1083
|
return o.appendChild(
|
|
1061
1084
|
L("feTurbulence", {
|
|
@@ -1092,11 +1115,11 @@ function Be(e, t, n) {
|
|
|
1092
1115
|
})
|
|
1093
1116
|
), o;
|
|
1094
1117
|
}
|
|
1095
|
-
function
|
|
1118
|
+
function Ao(e) {
|
|
1096
1119
|
const t = X("0 0 24 24", e, e, "none", "currentColor", "2.25");
|
|
1097
1120
|
return t.appendChild(L("path", { d: "m6 9 6 6 6-6" })), t;
|
|
1098
1121
|
}
|
|
1099
|
-
function
|
|
1122
|
+
function To() {
|
|
1100
1123
|
const e = X("0 0 24 24", 17, 17, "none", "currentColor", "2.25");
|
|
1101
1124
|
return e.appendChild(L("path", { d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" })), e.appendChild(L("path", { d: "M18.4 2.6a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4Z" })), e;
|
|
1102
1125
|
}
|
|
@@ -1104,7 +1127,7 @@ function jt() {
|
|
|
1104
1127
|
const e = X("0 0 24 24", 14, 14, "none", "currentColor", "2.75");
|
|
1105
1128
|
return e.appendChild(L("line", { x1: "12", y1: "19", x2: "12", y2: "5" })), e.appendChild(L("polyline", { points: "5 12 12 5 19 12" })), e;
|
|
1106
1129
|
}
|
|
1107
|
-
function
|
|
1130
|
+
function No() {
|
|
1108
1131
|
const e = X("0 0 24 24", 16, 16, "none", "currentColor", "2.4");
|
|
1109
1132
|
return e.setAttribute("class", "pluno-pa-widget__paperclip-icon pluno-pa-widget__paperclip-icon--standard"), e.appendChild(
|
|
1110
1133
|
L("path", {
|
|
@@ -1112,7 +1135,7 @@ function Lo() {
|
|
|
1112
1135
|
})
|
|
1113
1136
|
), e;
|
|
1114
1137
|
}
|
|
1115
|
-
function
|
|
1138
|
+
function Io() {
|
|
1116
1139
|
const e = X("0 0 24 24", 19, 19, "none", "currentColor");
|
|
1117
1140
|
return e.setAttribute("class", "pluno-pa-widget__paperclip-icon pluno-pa-widget__paperclip-icon--scribble"), e.appendChild(
|
|
1118
1141
|
L("path", {
|
|
@@ -1124,15 +1147,15 @@ function Po() {
|
|
|
1124
1147
|
})
|
|
1125
1148
|
), e;
|
|
1126
1149
|
}
|
|
1127
|
-
function
|
|
1150
|
+
function Do() {
|
|
1128
1151
|
const e = X("0 0 24 24", 18, 18, "currentColor");
|
|
1129
1152
|
return e.appendChild(L("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" })), e;
|
|
1130
1153
|
}
|
|
1131
|
-
function
|
|
1154
|
+
function Mo() {
|
|
1132
1155
|
const e = X("0 0 24 24", 12, 12, "none", "currentColor", "2.4");
|
|
1133
1156
|
return e.appendChild(L("path", { d: "M18 6 6 18" })), e.appendChild(L("path", { d: "m6 6 12 12" })), e;
|
|
1134
1157
|
}
|
|
1135
|
-
function
|
|
1158
|
+
function Ro() {
|
|
1136
1159
|
const e = X("0 0 24 24", 13, 13, "none", "currentColor", "2.25");
|
|
1137
1160
|
return e.appendChild(L("rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2" })), e.appendChild(L("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })), e;
|
|
1138
1161
|
}
|
|
@@ -1147,7 +1170,7 @@ function X(e, t, n, o, a, i) {
|
|
|
1147
1170
|
return a && (l.stroke = a, l["stroke-linecap"] = "round", l["stroke-linejoin"] = "round"), i && (l["stroke-width"] = i), L("svg", l);
|
|
1148
1171
|
}
|
|
1149
1172
|
function L(e, t = {}) {
|
|
1150
|
-
const n = document.createElementNS(
|
|
1173
|
+
const n = document.createElementNS(eo, e);
|
|
1151
1174
|
for (const [o, a] of Object.entries(t))
|
|
1152
1175
|
n.setAttribute(o, a);
|
|
1153
1176
|
return n;
|
|
@@ -1158,18 +1181,18 @@ function _t(e) {
|
|
|
1158
1181
|
n.stopPropagation();
|
|
1159
1182
|
});
|
|
1160
1183
|
}
|
|
1161
|
-
function
|
|
1184
|
+
function Oo(e, t, n) {
|
|
1162
1185
|
e.replaceChildren(), e.hidden = t.length === 0;
|
|
1163
1186
|
for (const [o, a] of t.entries()) {
|
|
1164
1187
|
const i = document.createElement("div");
|
|
1165
|
-
i.className = "pluno-pa-widget__attachment", i.appendChild(
|
|
1188
|
+
i.className = "pluno-pa-widget__attachment", i.appendChild(Bo(a));
|
|
1166
1189
|
const l = document.createElement("span");
|
|
1167
1190
|
l.textContent = a.name, i.appendChild(l);
|
|
1168
1191
|
const p = document.createElement("button");
|
|
1169
|
-
p.type = "button", p.setAttribute("aria-label", `Remove ${a.name}`), p.appendChild(
|
|
1192
|
+
p.type = "button", p.setAttribute("aria-label", `Remove ${a.name}`), p.appendChild(Mo()), p.addEventListener("click", () => n(o)), i.appendChild(p), e.appendChild(i);
|
|
1170
1193
|
}
|
|
1171
1194
|
}
|
|
1172
|
-
function
|
|
1195
|
+
function Bo(e) {
|
|
1173
1196
|
if (Vt(e)) {
|
|
1174
1197
|
const n = document.createElement("img");
|
|
1175
1198
|
return n.src = e.dataUrl, n.alt = "", n.setAttribute("aria-hidden", "true"), n;
|
|
@@ -1177,7 +1200,7 @@ function Do(e) {
|
|
|
1177
1200
|
const t = document.createElement("span");
|
|
1178
1201
|
return t.className = "pluno-pa-widget__attachment-file", t.textContent = "PDF", t;
|
|
1179
1202
|
}
|
|
1180
|
-
function
|
|
1203
|
+
function Fo(e) {
|
|
1181
1204
|
if (Vt(e)) {
|
|
1182
1205
|
const a = document.createElement("img");
|
|
1183
1206
|
return a.src = e.dataUrl, a.alt = e.name, a;
|
|
@@ -1192,10 +1215,10 @@ function Mo(e) {
|
|
|
1192
1215
|
function Vt(e) {
|
|
1193
1216
|
return e.mimeType.startsWith("image/");
|
|
1194
1217
|
}
|
|
1195
|
-
function
|
|
1218
|
+
function Uo(e) {
|
|
1196
1219
|
return e === "application/pdf" ? "document.pdf" : "image";
|
|
1197
1220
|
}
|
|
1198
|
-
async function
|
|
1221
|
+
async function zo(e) {
|
|
1199
1222
|
if (!e)
|
|
1200
1223
|
return [];
|
|
1201
1224
|
const t = Array.from(e);
|
|
@@ -1203,37 +1226,37 @@ async function Bo(e) {
|
|
|
1203
1226
|
throw new Error(`Attach up to ${Ce} files per message.`);
|
|
1204
1227
|
return Promise.all(
|
|
1205
1228
|
t.map(async (n) => {
|
|
1206
|
-
const o =
|
|
1229
|
+
const o = $o(n);
|
|
1207
1230
|
if (!o)
|
|
1208
1231
|
throw new Error("Pluno supports PNG, JPEG, WebP, non-animated GIF, and PDF files.");
|
|
1209
1232
|
if (n.size > Hn)
|
|
1210
1233
|
throw new Error("Each Pluno attachment can be up to 10 MB.");
|
|
1211
1234
|
if (o === "image/gif") {
|
|
1212
|
-
const a = new Uint8Array(await
|
|
1213
|
-
if (
|
|
1235
|
+
const a = new Uint8Array(await Xo(n));
|
|
1236
|
+
if (Ho(a))
|
|
1214
1237
|
throw new Error("Pluno supports non-animated GIF images.");
|
|
1215
1238
|
}
|
|
1216
1239
|
return {
|
|
1217
|
-
name: n.name ||
|
|
1240
|
+
name: n.name || Uo(o),
|
|
1218
1241
|
mimeType: o,
|
|
1219
1242
|
sizeBytes: n.size,
|
|
1220
|
-
dataUrl:
|
|
1243
|
+
dataUrl: Go(await Zo(n), o)
|
|
1221
1244
|
};
|
|
1222
1245
|
})
|
|
1223
1246
|
);
|
|
1224
1247
|
}
|
|
1225
|
-
function
|
|
1226
|
-
if (
|
|
1248
|
+
function $o(e) {
|
|
1249
|
+
if (Ot.has(e.type))
|
|
1227
1250
|
return e.type;
|
|
1228
1251
|
const t = e.name.toLowerCase();
|
|
1229
1252
|
return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
|
|
1230
1253
|
}
|
|
1231
|
-
function
|
|
1254
|
+
function Go(e, t) {
|
|
1232
1255
|
const n = `data:${t};base64,`;
|
|
1233
1256
|
return e.startsWith(n) ? e : e.replace(/^data:[^;]*;base64,/, n);
|
|
1234
1257
|
}
|
|
1235
|
-
function
|
|
1236
|
-
if (e.length < 14 || !
|
|
1258
|
+
function Ho(e) {
|
|
1259
|
+
if (e.length < 14 || !Wo(e))
|
|
1237
1260
|
return !1;
|
|
1238
1261
|
const t = e[10];
|
|
1239
1262
|
let n = 13;
|
|
@@ -1260,7 +1283,7 @@ function Uo(e) {
|
|
|
1260
1283
|
}
|
|
1261
1284
|
return !1;
|
|
1262
1285
|
}
|
|
1263
|
-
function
|
|
1286
|
+
function Wo(e) {
|
|
1264
1287
|
return e[0] === 71 && e[1] === 73 && e[2] === 70 && e[3] === 56 && (e[4] === 55 || e[4] === 57) && e[5] === 97;
|
|
1265
1288
|
}
|
|
1266
1289
|
function xt(e, t) {
|
|
@@ -1275,14 +1298,14 @@ function xt(e, t) {
|
|
|
1275
1298
|
function xe(e) {
|
|
1276
1299
|
return !!(e && Array.from(e.types).includes("Files"));
|
|
1277
1300
|
}
|
|
1278
|
-
function
|
|
1301
|
+
function Be(e, t, n = null) {
|
|
1279
1302
|
if (!e || !He(t, n)) {
|
|
1280
1303
|
e && (e.hidden = !0, e.replaceChildren());
|
|
1281
1304
|
return;
|
|
1282
1305
|
}
|
|
1283
|
-
e.hidden = !1, e.replaceChildren(), e.className = "pluno-pa-widget__billing-status",
|
|
1306
|
+
e.hidden = !1, e.replaceChildren(), e.className = "pluno-pa-widget__billing-status", $(t) || Ve(n) ? e.appendChild(jo(t, n)) : qt(t) && e.appendChild(Vo(t));
|
|
1284
1307
|
}
|
|
1285
|
-
function
|
|
1308
|
+
function jo(e, t) {
|
|
1286
1309
|
const n = document.createElement("div");
|
|
1287
1310
|
n.className = "pluno-pa-widget__billing-action-card";
|
|
1288
1311
|
const o = e.limitExceeded || t === "limit_exceeded", a = document.createElement("strong");
|
|
@@ -1290,36 +1313,36 @@ function Go(e, t) {
|
|
|
1290
1313
|
const i = document.createElement("span");
|
|
1291
1314
|
return i.textContent = o ? "Earn bonus credits or upgrade to keep using Pluno on this product." : e.paymentIssue ?? "Open billing to keep using Pluno.", n.appendChild(i), n.appendChild(Kt(e, "Upgrade plan", "pluno-pa-widget__billing-action-card-actions")), n;
|
|
1292
1315
|
}
|
|
1293
|
-
function
|
|
1316
|
+
function Vo(e) {
|
|
1294
1317
|
const t = document.createElement("div");
|
|
1295
1318
|
t.className = "pluno-pa-widget__billing-action-card pluno-pa-widget__billing-action-card--low";
|
|
1296
1319
|
const n = document.createElement("strong");
|
|
1297
1320
|
n.textContent = "Credits running low", t.appendChild(n);
|
|
1298
1321
|
const o = document.createElement("span");
|
|
1299
|
-
return o.textContent =
|
|
1322
|
+
return o.textContent = Ko(e) ?? "Credits are running low for this period.", t.appendChild(o), t.appendChild(Kt(e, "Upgrade", "pluno-pa-widget__billing-action-card-actions")), t;
|
|
1300
1323
|
}
|
|
1301
1324
|
function He(e, t) {
|
|
1302
|
-
return e !== null && (
|
|
1325
|
+
return e !== null && ($(e) || qt(e) || Ve(t));
|
|
1303
1326
|
}
|
|
1304
1327
|
function vt(e, t, n) {
|
|
1305
|
-
return He(t, n) ||
|
|
1328
|
+
return He(t, n) || qo(t) ? !0 : !He(e, n);
|
|
1306
1329
|
}
|
|
1307
|
-
function
|
|
1308
|
-
return e != null && (e.creditsUsed !== null || e.creditLimit !== null || e.creditsRemaining !== null ||
|
|
1330
|
+
function qo(e) {
|
|
1331
|
+
return e != null && (e.creditsUsed !== null || e.creditLimit !== null || e.creditsRemaining !== null || $(e));
|
|
1309
1332
|
}
|
|
1310
|
-
function
|
|
1333
|
+
function $(e) {
|
|
1311
1334
|
return e?.limitExceeded === !0 || !!e?.paymentIssue;
|
|
1312
1335
|
}
|
|
1313
1336
|
function Ve(e) {
|
|
1314
1337
|
return e === "limit_exceeded" || e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required";
|
|
1315
1338
|
}
|
|
1316
1339
|
function qt(e) {
|
|
1317
|
-
return
|
|
1340
|
+
return !$(e) && e.creditLimit !== null && e.creditLimit > 0 && e.creditsRemaining !== null && e.creditsRemaining > 0 && e.creditsRemaining / e.creditLimit <= 0.2;
|
|
1318
1341
|
}
|
|
1319
|
-
function
|
|
1320
|
-
return e.creditsRemaining === null ? null : `${
|
|
1342
|
+
function Ko(e) {
|
|
1343
|
+
return e.creditsRemaining === null ? null : `${Yo(e.creditsRemaining)} credits left`;
|
|
1321
1344
|
}
|
|
1322
|
-
function
|
|
1345
|
+
function Yo(e) {
|
|
1323
1346
|
return new Intl.NumberFormat("en-US", {
|
|
1324
1347
|
maximumFractionDigits: 0
|
|
1325
1348
|
}).format(Math.ceil(e));
|
|
@@ -1334,7 +1357,7 @@ function yt(e, t) {
|
|
|
1334
1357
|
t.trim().length !== 0 && window.open(t, "_blank", "noopener,noreferrer");
|
|
1335
1358
|
}), n;
|
|
1336
1359
|
}
|
|
1337
|
-
function
|
|
1360
|
+
function Xo(e) {
|
|
1338
1361
|
return new Promise((t, n) => {
|
|
1339
1362
|
const o = new FileReader();
|
|
1340
1363
|
o.addEventListener("load", () => {
|
|
@@ -1348,7 +1371,7 @@ function Vo(e) {
|
|
|
1348
1371
|
}), o.readAsArrayBuffer(e);
|
|
1349
1372
|
});
|
|
1350
1373
|
}
|
|
1351
|
-
function
|
|
1374
|
+
function Zo(e) {
|
|
1352
1375
|
return new Promise((t, n) => {
|
|
1353
1376
|
const o = new FileReader();
|
|
1354
1377
|
o.addEventListener("load", () => {
|
|
@@ -1365,52 +1388,57 @@ function qo(e) {
|
|
|
1365
1388
|
function Ct(e, t) {
|
|
1366
1389
|
return e.messages.filter((o) => !Yt(o)).length === 0 && !e.assistantDraft && !e.lastError && !e.isThinking && !t;
|
|
1367
1390
|
}
|
|
1368
|
-
function
|
|
1369
|
-
const
|
|
1370
|
-
e.replaceChildren(), Zt(n, i.isThinking), a.hidden = !p, p && l !== null &&
|
|
1391
|
+
function Jo(e, t, n, o, a, i, l, p, c, d, s, f, C, k, x) {
|
|
1392
|
+
const R = [...i.messages], v = R.filter((b) => !Yt(b)), y = e.scrollTop;
|
|
1393
|
+
e.replaceChildren(), Zt(n, i.isThinking), a.hidden = !p, p && l !== null && Lo(a, l);
|
|
1371
1394
|
const h = v.length > 0 || !!i.assistantDraft || i.isThinking;
|
|
1372
1395
|
if (o.hidden = !h, v.length === 0 && !i.assistantDraft && !i.lastError && !i.isThinking) {
|
|
1373
1396
|
const b = document.createElement("div");
|
|
1374
1397
|
b.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
1375
1398
|
const m = document.createElement("div");
|
|
1376
1399
|
m.className = "pluno-pa-widget__empty-hero";
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1400
|
+
const S = document.createElement("img");
|
|
1401
|
+
S.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", S.src = C(), S.alt = "", S.setAttribute("aria-hidden", "true"), m.appendChild(S), b.appendChild(m), b.appendChild(Gt());
|
|
1379
1402
|
const P = document.createElement("div");
|
|
1380
|
-
P.className = i.starterPrompts.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", i.starterPrompts.length === 0 && P.setAttribute("aria-hidden", "true")
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1403
|
+
if (P.className = i.starterPrompts.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", i.starterPrompts.length === 0 && P.setAttribute("aria-hidden", "true"), i.starterPrompts.length > 0)
|
|
1404
|
+
for (const I of i.starterPrompts) {
|
|
1405
|
+
const A = document.createElement("button");
|
|
1406
|
+
A.type = "button", A.className = "pluno-pa-widget__starter-prompt", A.textContent = `"${I}"`, A.addEventListener("click", () => {
|
|
1407
|
+
k(I);
|
|
1408
|
+
}), P.appendChild(A);
|
|
1409
|
+
}
|
|
1410
|
+
else
|
|
1411
|
+
for (let I = 0; I < jn; I += 1) {
|
|
1412
|
+
const A = document.createElement("button");
|
|
1413
|
+
A.type = "button", A.className = "pluno-pa-widget__starter-prompt pluno-pa-widget__starter-prompt--placeholder", A.disabled = !0, A.tabIndex = -1, A.innerHTML = " ", P.appendChild(A);
|
|
1414
|
+
}
|
|
1387
1415
|
b.appendChild(P), e.appendChild(b), e.appendChild(t);
|
|
1388
1416
|
return;
|
|
1389
1417
|
}
|
|
1390
|
-
let g = null, _ = null,
|
|
1418
|
+
let g = null, _ = null, N = [];
|
|
1391
1419
|
const Z = () => {
|
|
1392
|
-
if (
|
|
1420
|
+
if (N.length === 0)
|
|
1393
1421
|
return !1;
|
|
1394
|
-
const b =
|
|
1395
|
-
return e.appendChild(b), g = null, _ = b,
|
|
1422
|
+
const b = la(N, s, f, C());
|
|
1423
|
+
return e.appendChild(b), g = null, _ = b, N = [], !0;
|
|
1396
1424
|
};
|
|
1397
1425
|
for (let b = 0; b < v.length; b += 1) {
|
|
1398
1426
|
const m = v[b];
|
|
1399
1427
|
if (m.role === "tool") {
|
|
1400
|
-
|
|
1428
|
+
N.push(m);
|
|
1401
1429
|
continue;
|
|
1402
1430
|
}
|
|
1403
1431
|
if (m.role === "system")
|
|
1404
1432
|
continue;
|
|
1405
|
-
const
|
|
1406
|
-
if (m.role === "assistant" && !
|
|
1433
|
+
const S = Z(), P = St(m.content);
|
|
1434
|
+
if (m.role === "assistant" && !S) {
|
|
1407
1435
|
const w = We(C());
|
|
1408
1436
|
e.appendChild(w), g = null, _ = w;
|
|
1409
1437
|
}
|
|
1410
|
-
const
|
|
1411
|
-
|
|
1412
|
-
const
|
|
1413
|
-
|
|
1438
|
+
const I = document.createElement("div");
|
|
1439
|
+
I.className = `pluno-pa-widget__message pluno-pa-widget__message--${m.role}`, m.role === "assistant" ? kt(I, P) : I.textContent = P, m.role === "user" && m.attachments?.length && I.appendChild(ea(m.attachments));
|
|
1440
|
+
const A = document.createElement("div");
|
|
1441
|
+
A.className = "pluno-pa-widget__message-actions", A.appendChild(Et(P)), I.appendChild(A), e.appendChild(I), g = I, _ = null;
|
|
1414
1442
|
}
|
|
1415
1443
|
const de = Z();
|
|
1416
1444
|
if (i.assistantDraft) {
|
|
@@ -1418,26 +1446,26 @@ function Ko(e, t, n, o, a, i, l, p, c, d, s, f, C, S, x) {
|
|
|
1418
1446
|
const P = We(C());
|
|
1419
1447
|
e.appendChild(P), g = null, _ = P;
|
|
1420
1448
|
}
|
|
1421
|
-
const b =
|
|
1422
|
-
m.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant",
|
|
1423
|
-
const
|
|
1424
|
-
|
|
1449
|
+
const b = St(i.assistantDraft), m = document.createElement("div");
|
|
1450
|
+
m.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", kt(m, b);
|
|
1451
|
+
const S = document.createElement("div");
|
|
1452
|
+
S.className = "pluno-pa-widget__message-actions", S.appendChild(Et(b)), m.appendChild(S), e.appendChild(m), g = m, _ = null;
|
|
1425
1453
|
}
|
|
1426
1454
|
if (i.isThinking && !i.assistantDraft)
|
|
1427
1455
|
if (de) {
|
|
1428
1456
|
const b = Xt();
|
|
1429
1457
|
e.appendChild(b), g = null, _ = b;
|
|
1430
1458
|
} else {
|
|
1431
|
-
const b =
|
|
1459
|
+
const b = pa(C());
|
|
1432
1460
|
e.appendChild(b), g = null, _ = b;
|
|
1433
1461
|
}
|
|
1434
1462
|
if (i.lastError) {
|
|
1435
1463
|
const b = document.createElement("div");
|
|
1436
1464
|
b.className = "pluno-pa-widget__error", b.textContent = i.lastError, e.appendChild(b), g = b, _ = null;
|
|
1437
1465
|
}
|
|
1438
|
-
const E = x && !i.isThinking ? xn(
|
|
1466
|
+
const E = x && !i.isThinking ? xn(R) : null;
|
|
1439
1467
|
if (x && E && !x.dismissedCandidateIds.has(E.id)) {
|
|
1440
|
-
const b =
|
|
1468
|
+
const b = ta(E, {
|
|
1441
1469
|
isDrafting: x.draftingCandidateId === E.id,
|
|
1442
1470
|
error: x.error,
|
|
1443
1471
|
onDraft: x.onDraft,
|
|
@@ -1448,7 +1476,7 @@ function Ko(e, t, n, o, a, i, l, p, c, d, s, f, C, S, x) {
|
|
|
1448
1476
|
}
|
|
1449
1477
|
g?.classList.add("pluno-pa-widget__message--bottom-reserve"), _?.classList.add("pluno-pa-widget__bottom-reserve-compact"), e.appendChild(t), c ? he(e, d) : e.scrollTop = y;
|
|
1450
1478
|
}
|
|
1451
|
-
function
|
|
1479
|
+
function Qo(e, t, n, o, a, i) {
|
|
1452
1480
|
e.replaceChildren(), Zt(t, !1), t.disabled = !0, n.hidden = !0;
|
|
1453
1481
|
const l = document.createElement("div");
|
|
1454
1482
|
l.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
@@ -1459,20 +1487,20 @@ function Yo(e, t, n, o, a, i) {
|
|
|
1459
1487
|
const d = document.createElement("button");
|
|
1460
1488
|
d.type = "button", d.className = "pluno-pa-widget__login", d.textContent = a, d.addEventListener("click", () => i?.()), l.appendChild(d), e.appendChild(l);
|
|
1461
1489
|
}
|
|
1462
|
-
function
|
|
1490
|
+
function ea(e) {
|
|
1463
1491
|
const t = document.createElement("div");
|
|
1464
1492
|
t.className = "pluno-pa-widget__message-attachments";
|
|
1465
1493
|
for (const n of e)
|
|
1466
|
-
t.appendChild(
|
|
1494
|
+
t.appendChild(Fo(n));
|
|
1467
1495
|
return t;
|
|
1468
1496
|
}
|
|
1469
1497
|
function Et(e) {
|
|
1470
1498
|
const t = document.createElement("button");
|
|
1471
|
-
return t.type = "button", t.className = "pluno-pa-widget__message-copy", t.setAttribute("aria-label", "Copy message"), t.title = "Copy message", t.appendChild(
|
|
1499
|
+
return t.type = "button", t.className = "pluno-pa-widget__message-copy", t.setAttribute("aria-label", "Copy message"), t.title = "Copy message", t.appendChild(Ro()), t.addEventListener("click", (n) => {
|
|
1472
1500
|
n.preventDefault(), n.stopPropagation(), navigator.clipboard.writeText(e);
|
|
1473
1501
|
}), t;
|
|
1474
1502
|
}
|
|
1475
|
-
function
|
|
1503
|
+
function ta(e, t) {
|
|
1476
1504
|
const n = document.createElement("article");
|
|
1477
1505
|
n.className = "pluno-pa-widget__share-prompt";
|
|
1478
1506
|
const o = document.createElement("div");
|
|
@@ -1508,7 +1536,7 @@ function Zo(e, t) {
|
|
|
1508
1536
|
}
|
|
1509
1537
|
return o.appendChild(p), n.appendChild(o), n;
|
|
1510
1538
|
}
|
|
1511
|
-
function
|
|
1539
|
+
function na(e, t) {
|
|
1512
1540
|
const n = document.createElement("div");
|
|
1513
1541
|
n.className = "pluno-pa-widget__share-dialog-backdrop", n.addEventListener("click", (v) => {
|
|
1514
1542
|
v.target === n && t.onClose();
|
|
@@ -1527,7 +1555,7 @@ function Jo(e, t) {
|
|
|
1527
1555
|
d.className = "pluno-pa-widget__share-dialog-step-header";
|
|
1528
1556
|
const s = document.createElement("strong");
|
|
1529
1557
|
s.textContent = "1) Copy Screenshot", d.appendChild(s);
|
|
1530
|
-
const f =
|
|
1558
|
+
const f = oa("Copy Screenshot", async () => {
|
|
1531
1559
|
try {
|
|
1532
1560
|
return await vn(e.screenshotDataUrl ?? ""), p.textContent = "", p.hidden = !0, !0;
|
|
1533
1561
|
} catch {
|
|
@@ -1543,33 +1571,33 @@ function Jo(e, t) {
|
|
|
1543
1571
|
o.appendChild(c), o.appendChild(p);
|
|
1544
1572
|
const C = document.createElement("div");
|
|
1545
1573
|
C.className = "pluno-pa-widget__share-dialog-step";
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1574
|
+
const k = document.createElement("strong");
|
|
1575
|
+
k.className = "pluno-pa-widget__share-dialog-step-title", k.textContent = "2) Share on", C.appendChild(k);
|
|
1548
1576
|
const x = document.createElement("p");
|
|
1549
1577
|
x.className = "pluno-pa-widget__share-dialog-hint", x.textContent = "Post draft opens prefilled on supported platforms.", C.appendChild(x);
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1552
|
-
for (const v of
|
|
1578
|
+
const R = document.createElement("footer");
|
|
1579
|
+
R.className = "pluno-pa-widget__share-dialog-platforms";
|
|
1580
|
+
for (const v of aa(e)) {
|
|
1553
1581
|
const y = document.createElement("a");
|
|
1554
|
-
y.href = v.href, y.target = "_blank", y.rel = "noopener noreferrer", y.title = v.label, y.setAttribute("aria-label", `Open ${v.label}`), y.appendChild(
|
|
1582
|
+
y.href = v.href, y.target = "_blank", y.rel = "noopener noreferrer", y.title = v.label, y.setAttribute("aria-label", `Open ${v.label}`), y.appendChild(ia(v.id)), R.appendChild(y);
|
|
1555
1583
|
}
|
|
1556
|
-
if (C.appendChild(
|
|
1584
|
+
if (C.appendChild(R), o.appendChild(C), t.socialPostRewardsUrl) {
|
|
1557
1585
|
const v = document.createElement("div");
|
|
1558
1586
|
v.className = "pluno-pa-widget__share-dialog-step";
|
|
1559
1587
|
const y = document.createElement("strong");
|
|
1560
1588
|
y.className = "pluno-pa-widget__share-dialog-step-title", y.textContent = "3) Submit post to get 2000 free credits!", v.appendChild(y);
|
|
1561
1589
|
const h = document.createElement("a");
|
|
1562
|
-
h.className = "pluno-pa-widget__share-dialog-reward-link", h.href = t.socialPostRewardsUrl, h.target = "_blank", h.rel = "noopener noreferrer", h.appendChild(document.createTextNode("Submit post URL")), h.appendChild(
|
|
1590
|
+
h.className = "pluno-pa-widget__share-dialog-reward-link", h.href = t.socialPostRewardsUrl, h.target = "_blank", h.rel = "noopener noreferrer", h.appendChild(document.createTextNode("Submit post URL")), h.appendChild(ra()), v.appendChild(h), o.appendChild(v);
|
|
1563
1591
|
}
|
|
1564
1592
|
return n.appendChild(o), n;
|
|
1565
1593
|
}
|
|
1566
|
-
function
|
|
1594
|
+
function oa(e, t) {
|
|
1567
1595
|
const n = document.createElement("button");
|
|
1568
1596
|
return n.type = "button", n.className = "pluno-pa-widget__share-dialog-copy", n.textContent = e, n.addEventListener("click", async (o) => {
|
|
1569
1597
|
o.preventDefault(), o.stopPropagation(), await t() && (n.textContent = "Copied ✓");
|
|
1570
1598
|
}), n;
|
|
1571
1599
|
}
|
|
1572
|
-
function
|
|
1600
|
+
function aa(e) {
|
|
1573
1601
|
const t = e.linkedinPost.trim(), n = e.xPost.trim();
|
|
1574
1602
|
return [
|
|
1575
1603
|
{
|
|
@@ -1589,30 +1617,30 @@ function ea(e) {
|
|
|
1589
1617
|
}
|
|
1590
1618
|
];
|
|
1591
1619
|
}
|
|
1592
|
-
function
|
|
1620
|
+
function ia(e) {
|
|
1593
1621
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1594
|
-
return t.setAttribute("class", "pluno-pa-widget__share-dialog-platform-logo"), t.setAttribute("viewBox", "0 0 32 32"), t.setAttribute("aria-hidden", "true"), e === "linkedin" ? (
|
|
1622
|
+
return t.setAttribute("class", "pluno-pa-widget__share-dialog-platform-logo"), t.setAttribute("viewBox", "0 0 32 32"), t.setAttribute("aria-hidden", "true"), e === "linkedin" ? (D(t, "M6.7 13.2c.4 4.1.2 8.1.1 12.3"), D(t, "M6.4 6.9c.6-.5 1.6-.5 2.1.1.7.7.5 1.8-.2 2.3-.8.5-1.9.2-2.3-.6-.2-.6 0-1.3.4-1.8Z"), D(t, "M14.4 13.3c.1 3.8.1 7.8 0 11.9"), D(t, "M14.8 16.2c1.2-2 3-3.1 5.1-2.9 3.4.3 4.8 2.7 4.8 6.2 0 1.9-.1 3.8-.1 5.8"), D(t, "M20 18c.1 2.2.1 4.7 0 7.2"), t) : e === "x" ? (D(t, "M7.2 7.4c5.6 6.4 10.9 12.2 17.7 17.2"), D(t, "M24.4 7.2c-5.1 6.3-10.6 11.8-17 17.8"), D(t, "M9.1 8.2c5.1 5.6 9.7 10.8 15 15.5", "0.55"), t) : (D(t, "M10.2 6.4c3.8-.3 8-.3 11.6.1 2.5.3 3.8 1.8 4 4 .4 3.3.4 7.4 0 10.9-.3 2.4-1.7 3.8-4 4.1-3.8.4-8.2.4-11.8 0-2.3-.3-3.7-1.8-4-4.1-.4-3.5-.3-7.8.1-11.1.2-2.2 1.8-3.6 4.1-3.9Z"), D(t, "M11 7.3c3.4-.4 7.1-.4 10.2.1 2 .3 3.1 1.4 3.4 3.2.4 3 .4 6.6.1 9.9-.3 2.2-1.3 3.3-3.3 3.7-3.2.5-7.2.5-10.5.1", "0.48"), D(t, "M12.1 16.1c.1-2.4 1.8-4.1 4-4.2 2.4-.1 4.2 1.6 4.3 4 .1 2.3-1.6 4.1-3.9 4.2-2.6.2-4.3-1.5-4.4-4Z"), D(t, "M22 10.7c.3-.1.7 0 .9.3.2.4.1.8-.2 1-.4.2-.8.1-1-.2-.2-.4-.1-.8.3-1.1Z"), t);
|
|
1595
1623
|
}
|
|
1596
|
-
function
|
|
1624
|
+
function D(e, t, n) {
|
|
1597
1625
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1598
1626
|
o.setAttribute("d", t), n && o.setAttribute("opacity", n), e.appendChild(o);
|
|
1599
1627
|
}
|
|
1600
|
-
function
|
|
1628
|
+
function ra() {
|
|
1601
1629
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1602
|
-
return e.setAttribute("class", "pluno-pa-widget__share-dialog-external-icon"), e.setAttribute("viewBox", "0 0 24 24"), e.setAttribute("aria-hidden", "true"),
|
|
1630
|
+
return e.setAttribute("class", "pluno-pa-widget__share-dialog-external-icon"), e.setAttribute("viewBox", "0 0 24 24"), e.setAttribute("aria-hidden", "true"), D(e, "M14 5h5v5"), D(e, "M19 5l-8 8"), D(e, "M18 13v5a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h5"), e;
|
|
1603
1631
|
}
|
|
1604
1632
|
function Yt(e) {
|
|
1605
1633
|
return e.role === "tool" && e.toolName === Dt;
|
|
1606
1634
|
}
|
|
1607
|
-
function
|
|
1635
|
+
function St(e) {
|
|
1608
1636
|
return e.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
|
|
1609
1637
|
}
|
|
1610
|
-
function
|
|
1638
|
+
function la(e, t, n, o) {
|
|
1611
1639
|
const a = document.createElement("article");
|
|
1612
1640
|
a.className = "pluno-pa-widget__tool-group", a.title = new Date(e[e.length - 1].createdAt).toLocaleString();
|
|
1613
1641
|
const i = document.createElement("img");
|
|
1614
1642
|
i.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", i.src = o, i.alt = "", i.setAttribute("aria-hidden", "true"), a.appendChild(i);
|
|
1615
|
-
const l = document.createElement("details"), p =
|
|
1643
|
+
const l = document.createElement("details"), p = sa(e);
|
|
1616
1644
|
l.open = t.has(p), a.classList.toggle("pluno-pa-widget__tool-group--open", l.open), l.addEventListener("toggle", () => {
|
|
1617
1645
|
a.classList.toggle("pluno-pa-widget__tool-group--open", l.open), l.open ? t.add(p) : t.delete(p), n();
|
|
1618
1646
|
});
|
|
@@ -1623,10 +1651,10 @@ function oa(e, t, n, o) {
|
|
|
1623
1651
|
const f = document.createElement("div");
|
|
1624
1652
|
f.className = "pluno-pa-widget__tool-lines";
|
|
1625
1653
|
for (const C of e) {
|
|
1626
|
-
const
|
|
1627
|
-
|
|
1654
|
+
const k = document.createElement("div");
|
|
1655
|
+
k.className = "pluno-pa-widget__tool-line", C.loading && k.appendChild(je());
|
|
1628
1656
|
const x = document.createElement("span");
|
|
1629
|
-
x.textContent = C.content || "Run tool",
|
|
1657
|
+
x.textContent = C.content || "Run tool", k.appendChild(x), f.appendChild(k);
|
|
1630
1658
|
}
|
|
1631
1659
|
l.appendChild(f);
|
|
1632
1660
|
}
|
|
@@ -1638,7 +1666,7 @@ function We(e) {
|
|
|
1638
1666
|
const n = document.createElement("img");
|
|
1639
1667
|
return n.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", n.src = e, n.alt = "", n.setAttribute("aria-hidden", "true"), t.appendChild(n), t;
|
|
1640
1668
|
}
|
|
1641
|
-
function
|
|
1669
|
+
function pa(e) {
|
|
1642
1670
|
const t = We(e);
|
|
1643
1671
|
return t.classList.add("pluno-pa-widget__thinking-marker"), t.appendChild(Xt()), t;
|
|
1644
1672
|
}
|
|
@@ -1650,7 +1678,7 @@ function Xt() {
|
|
|
1650
1678
|
const n = document.createElement("span");
|
|
1651
1679
|
return n.textContent = "Thinking...", e.appendChild(n), e;
|
|
1652
1680
|
}
|
|
1653
|
-
function
|
|
1681
|
+
function sa(e) {
|
|
1654
1682
|
return `tools:${e[0]?.id ?? ""}`;
|
|
1655
1683
|
}
|
|
1656
1684
|
function je() {
|
|
@@ -1658,9 +1686,9 @@ function je() {
|
|
|
1658
1686
|
return e.className = "pluno-pa-widget__spinner", e.setAttribute("aria-hidden", "true"), e;
|
|
1659
1687
|
}
|
|
1660
1688
|
function Zt(e, t) {
|
|
1661
|
-
e.setAttribute("aria-label", t ? "Stop" : "Send"), e.classList.toggle("pluno-pa-widget__send--stop", t), e.replaceChildren(t ?
|
|
1689
|
+
e.setAttribute("aria-label", t ? "Stop" : "Send"), e.classList.toggle("pluno-pa-widget__send--stop", t), e.replaceChildren(t ? Do() : jt());
|
|
1662
1690
|
}
|
|
1663
|
-
function
|
|
1691
|
+
function kt(e, t) {
|
|
1664
1692
|
const n = t.replace(/\r\n/g, `
|
|
1665
1693
|
`).split(`
|
|
1666
1694
|
`);
|
|
@@ -1732,7 +1760,7 @@ function ve(e, t) {
|
|
|
1732
1760
|
p.textContent = l.slice(1, -1), e.appendChild(p);
|
|
1733
1761
|
} else {
|
|
1734
1762
|
const p = l.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
|
|
1735
|
-
if (p &&
|
|
1763
|
+
if (p && da(p[2])) {
|
|
1736
1764
|
const c = document.createElement("a");
|
|
1737
1765
|
c.href = p[2], c.target = "_top", c.rel = "noreferrer", c.textContent = p[1], e.appendChild(c);
|
|
1738
1766
|
} else
|
|
@@ -1742,7 +1770,7 @@ function ve(e, t) {
|
|
|
1742
1770
|
}
|
|
1743
1771
|
o < t.length && e.appendChild(document.createTextNode(t.slice(o)));
|
|
1744
1772
|
}
|
|
1745
|
-
function
|
|
1773
|
+
function da(e) {
|
|
1746
1774
|
if (e.startsWith("/") || e.startsWith("#"))
|
|
1747
1775
|
return !0;
|
|
1748
1776
|
try {
|
|
@@ -1753,7 +1781,7 @@ function ra(e) {
|
|
|
1753
1781
|
}
|
|
1754
1782
|
}
|
|
1755
1783
|
function Lt(e, t) {
|
|
1756
|
-
if (
|
|
1784
|
+
if (ca(e))
|
|
1757
1785
|
return;
|
|
1758
1786
|
const n = `
|
|
1759
1787
|
:host {
|
|
@@ -3140,7 +3168,6 @@ function Lt(e, t) {
|
|
|
3140
3168
|
width: min(100%, 320px);
|
|
3141
3169
|
}
|
|
3142
3170
|
.pluno-pa-widget__starter-prompts--empty {
|
|
3143
|
-
min-height: 96px;
|
|
3144
3171
|
pointer-events: none;
|
|
3145
3172
|
}
|
|
3146
3173
|
.pluno-pa-widget__starter-prompt {
|
|
@@ -3160,6 +3187,9 @@ function Lt(e, t) {
|
|
|
3160
3187
|
color: var(--pluno-pa-text);
|
|
3161
3188
|
background: transparent;
|
|
3162
3189
|
}
|
|
3190
|
+
.pluno-pa-widget__starter-prompt--placeholder {
|
|
3191
|
+
visibility: hidden;
|
|
3192
|
+
}
|
|
3163
3193
|
.pluno-pa-widget__login {
|
|
3164
3194
|
border: 0;
|
|
3165
3195
|
border-radius: 8px;
|
|
@@ -3407,6 +3437,9 @@ function Lt(e, t) {
|
|
|
3407
3437
|
.pluno-pa-widget--scribble .pluno-pa-widget__send::before {
|
|
3408
3438
|
background: var(--pluno-pa-accent);
|
|
3409
3439
|
}
|
|
3440
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__send:disabled {
|
|
3441
|
+
color: var(--pluno-pa-faint);
|
|
3442
|
+
}
|
|
3410
3443
|
.pluno-pa-widget--scribble .pluno-pa-widget__send:disabled::before {
|
|
3411
3444
|
background: var(--pluno-pa-surface);
|
|
3412
3445
|
}
|
|
@@ -3550,18 +3583,18 @@ function Lt(e, t) {
|
|
|
3550
3583
|
filter: url(#pluno-pa-scribble-wobble-2);
|
|
3551
3584
|
}
|
|
3552
3585
|
`;
|
|
3553
|
-
if (
|
|
3586
|
+
if (ua(e, n))
|
|
3554
3587
|
return;
|
|
3555
3588
|
const o = e.ownerDocument.createElement("style");
|
|
3556
3589
|
o.id = Ut, o.textContent = n, e.appendChild(o), Jt(e);
|
|
3557
3590
|
}
|
|
3558
|
-
function
|
|
3591
|
+
function ca(e) {
|
|
3559
3592
|
return e.getElementById(Ut) !== null || e.host instanceof HTMLElement && e.host.getAttribute(zt) === "true";
|
|
3560
3593
|
}
|
|
3561
3594
|
function Jt(e) {
|
|
3562
3595
|
e.host instanceof HTMLElement && e.host.setAttribute(zt, "true");
|
|
3563
3596
|
}
|
|
3564
|
-
function
|
|
3597
|
+
function ua(e, t) {
|
|
3565
3598
|
if (typeof CSSStyleSheet > "u" || typeof CSSStyleSheet.prototype.replaceSync != "function" || !("adoptedStyleSheets" in e))
|
|
3566
3599
|
return !1;
|
|
3567
3600
|
try {
|
|
@@ -3571,7 +3604,7 @@ function pa(e, t) {
|
|
|
3571
3604
|
return !1;
|
|
3572
3605
|
}
|
|
3573
3606
|
}
|
|
3574
|
-
async function
|
|
3607
|
+
async function ga() {
|
|
3575
3608
|
return document.body ? document.body : await new Promise((e) => {
|
|
3576
3609
|
const t = new MutationObserver(() => {
|
|
3577
3610
|
document.body && (t.disconnect(), e(document.body));
|
|
@@ -3582,7 +3615,7 @@ async function sa() {
|
|
|
3582
3615
|
function Qt(e) {
|
|
3583
3616
|
return `pluno.productAgent.widgetState.${location.origin}.${e.backendUrl ?? ""}.${e.tokenEndpoint ?? ""}.${e.position ?? ""}`;
|
|
3584
3617
|
}
|
|
3585
|
-
function
|
|
3618
|
+
function ha(e) {
|
|
3586
3619
|
try {
|
|
3587
3620
|
const t = window.localStorage.getItem(Qt(e));
|
|
3588
3621
|
if (!t)
|
|
@@ -3592,7 +3625,7 @@ function da(e) {
|
|
|
3592
3625
|
isOpen: n.isOpen === !0,
|
|
3593
3626
|
composerValue: typeof n.composerValue == "string" ? n.composerValue : "",
|
|
3594
3627
|
openToolGroupKeys: Array.isArray(n.openToolGroupKeys) ? n.openToolGroupKeys.filter((o) => typeof o == "string") : [],
|
|
3595
|
-
launcherPosition:
|
|
3628
|
+
launcherPosition: wa(n.launcherPosition) ? n.launcherPosition : null,
|
|
3596
3629
|
seenShareCandidateIds: Array.isArray(n.seenShareCandidateIds) ? n.seenShareCandidateIds.filter((o) => typeof o == "string").slice(-Mt) : [],
|
|
3597
3630
|
sharePromptsDisabled: n.sharePromptsDisabled === !0
|
|
3598
3631
|
};
|
|
@@ -3600,7 +3633,7 @@ function da(e) {
|
|
|
3600
3633
|
return Pt();
|
|
3601
3634
|
}
|
|
3602
3635
|
}
|
|
3603
|
-
async function
|
|
3636
|
+
async function ma(e) {
|
|
3604
3637
|
if (e.loadSharePromptsDisabled)
|
|
3605
3638
|
return e.loadSharePromptsDisabled();
|
|
3606
3639
|
try {
|
|
@@ -3609,7 +3642,7 @@ async function ca(e) {
|
|
|
3609
3642
|
return !1;
|
|
3610
3643
|
}
|
|
3611
3644
|
}
|
|
3612
|
-
function
|
|
3645
|
+
function fa(e, t) {
|
|
3613
3646
|
if (e.persistSharePromptsDisabled) {
|
|
3614
3647
|
Promise.resolve(e.persistSharePromptsDisabled(t)).catch(() => {
|
|
3615
3648
|
});
|
|
@@ -3631,28 +3664,28 @@ function Pt() {
|
|
|
3631
3664
|
sharePromptsDisabled: !1
|
|
3632
3665
|
};
|
|
3633
3666
|
}
|
|
3634
|
-
function
|
|
3667
|
+
function ba(e, t) {
|
|
3635
3668
|
try {
|
|
3636
3669
|
window.localStorage.setItem(Qt(e), JSON.stringify(t));
|
|
3637
3670
|
} catch {
|
|
3638
3671
|
return;
|
|
3639
3672
|
}
|
|
3640
3673
|
}
|
|
3641
|
-
function
|
|
3674
|
+
function wa(e) {
|
|
3642
3675
|
if (!e || typeof e != "object")
|
|
3643
3676
|
return !1;
|
|
3644
3677
|
const t = e;
|
|
3645
3678
|
return Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
3646
3679
|
}
|
|
3647
3680
|
const At = /* @__PURE__ */ new WeakSet();
|
|
3648
|
-
function
|
|
3681
|
+
function _a(e) {
|
|
3649
3682
|
return Object.keys(e.dataset).some((t) => t.startsWith("pluno"));
|
|
3650
3683
|
}
|
|
3651
3684
|
function Tt(e) {
|
|
3652
3685
|
const t = e.pathname.split("/");
|
|
3653
3686
|
return t[t.length - 1] ?? "";
|
|
3654
3687
|
}
|
|
3655
|
-
function
|
|
3688
|
+
function xa(e, t) {
|
|
3656
3689
|
const n = new URL(e.src, document.baseURI);
|
|
3657
3690
|
return n.href === t.href || n.pathname === t.pathname ? !0 : Tt(n) === Tt(t);
|
|
3658
3691
|
}
|
|
@@ -3665,7 +3698,7 @@ class V extends EventTarget {
|
|
|
3665
3698
|
this.dispatchEvent(new MessageEvent("message", { data: a.detail?.data ?? "" }));
|
|
3666
3699
|
}), this.addPreviewListener(zn, () => {
|
|
3667
3700
|
this.readyState = V.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
|
|
3668
|
-
}), this.addPreviewListener(
|
|
3701
|
+
}), this.addPreviewListener($n, (o) => {
|
|
3669
3702
|
const a = o;
|
|
3670
3703
|
this.readyState = V.CLOSED, this.dispatchEvent(
|
|
3671
3704
|
new CloseEvent("close", {
|
|
@@ -3691,20 +3724,20 @@ class V extends EventTarget {
|
|
|
3691
3724
|
binaryType = "blob";
|
|
3692
3725
|
bufferedAmount = 0;
|
|
3693
3726
|
readyState = V.CONNECTING;
|
|
3694
|
-
socketId =
|
|
3727
|
+
socketId = va();
|
|
3695
3728
|
listeners = /* @__PURE__ */ new Map();
|
|
3696
3729
|
send(t) {
|
|
3697
3730
|
if (this.readyState !== V.OPEN)
|
|
3698
3731
|
throw new DOMException("Pluno preview websocket is not open", "InvalidStateError");
|
|
3699
3732
|
window.dispatchEvent(
|
|
3700
|
-
new CustomEvent(ye(
|
|
3733
|
+
new CustomEvent(ye(On, this.channelId), {
|
|
3701
3734
|
detail: { socketId: this.socketId, data: typeof t == "string" ? t : String(t) }
|
|
3702
3735
|
})
|
|
3703
3736
|
);
|
|
3704
3737
|
}
|
|
3705
3738
|
close(t, n) {
|
|
3706
3739
|
this.readyState !== V.CLOSED && (this.readyState = V.CLOSING, window.dispatchEvent(
|
|
3707
|
-
new CustomEvent(ye(
|
|
3740
|
+
new CustomEvent(ye(Bn, this.channelId), {
|
|
3708
3741
|
detail: { socketId: this.socketId, code: t, reason: n }
|
|
3709
3742
|
})
|
|
3710
3743
|
), this.cleanup());
|
|
@@ -3721,7 +3754,7 @@ class V extends EventTarget {
|
|
|
3721
3754
|
this.listeners.clear();
|
|
3722
3755
|
}
|
|
3723
3756
|
}
|
|
3724
|
-
function
|
|
3757
|
+
function va() {
|
|
3725
3758
|
const e = window.sessionStorage.getItem(ct);
|
|
3726
3759
|
if (e)
|
|
3727
3760
|
return e;
|
|
@@ -3731,26 +3764,26 @@ function ba() {
|
|
|
3731
3764
|
function ye(e, t) {
|
|
3732
3765
|
return `${e}:${t}`;
|
|
3733
3766
|
}
|
|
3734
|
-
function
|
|
3767
|
+
function ya(e) {
|
|
3735
3768
|
const t = document.currentScript;
|
|
3736
3769
|
if (t instanceof HTMLScriptElement)
|
|
3737
3770
|
return [t];
|
|
3738
3771
|
const n = new URL(e, document.baseURI).href, o = new URL(n);
|
|
3739
3772
|
return Array.from(document.querySelectorAll("script[type='module'][src]")).filter(
|
|
3740
|
-
(a) => a instanceof HTMLScriptElement &&
|
|
3773
|
+
(a) => a instanceof HTMLScriptElement && _a(a) && xa(a, o)
|
|
3741
3774
|
);
|
|
3742
3775
|
}
|
|
3743
|
-
function
|
|
3744
|
-
for (const t of
|
|
3776
|
+
function Ca(e) {
|
|
3777
|
+
for (const t of ya(e)) {
|
|
3745
3778
|
if (At.has(t) || t.dataset.plunoAutoMount === "false")
|
|
3746
3779
|
continue;
|
|
3747
3780
|
At.add(t);
|
|
3748
3781
|
const n = t.dataset.plunoPreviewChannel;
|
|
3749
|
-
|
|
3782
|
+
lo({
|
|
3750
3783
|
token: t.dataset.plunoToken,
|
|
3751
3784
|
tokenEndpoint: t.dataset.plunoTokenEndpoint,
|
|
3752
3785
|
backendUrl: t.dataset.plunoBackendUrl,
|
|
3753
|
-
webSocketFactory: n ?
|
|
3786
|
+
webSocketFactory: n ? ro(n) : void 0,
|
|
3754
3787
|
launcherLabel: t.dataset.plunoLauncherLabel,
|
|
3755
3788
|
accentColor: t.dataset.plunoAccentColor,
|
|
3756
3789
|
colorScheme: t.dataset.plunoColorScheme === "dark" ? "dark" : "light",
|
|
@@ -3762,8 +3795,8 @@ function _a(e) {
|
|
|
3762
3795
|
});
|
|
3763
3796
|
}
|
|
3764
3797
|
}
|
|
3765
|
-
|
|
3798
|
+
Ca(import.meta.url);
|
|
3766
3799
|
export {
|
|
3767
|
-
|
|
3768
|
-
|
|
3800
|
+
ro as createProductAgentPreviewBridgeWebSocketFactory,
|
|
3801
|
+
lo as mountPlunoProductAgentWidget
|
|
3769
3802
|
};
|