@pluno/product-agent-web 0.1.19 → 0.1.20
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 +258 -244
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlunoProductAgent as dt } from "./product-agent-sdk.js";
|
|
2
2
|
const ct = "#7c3aed";
|
|
3
3
|
function ut(t) {
|
|
4
|
-
const e =
|
|
4
|
+
const e = wt(t);
|
|
5
5
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1254 1254" role="img" aria-label="Pluno">
|
|
6
6
|
<defs>
|
|
7
7
|
<linearGradient id="boltFill" x1="420" y1="180" x2="790" y2="1040" gradientUnits="userSpaceOnUse">
|
|
@@ -85,8 +85,8 @@ function Ve(t) {
|
|
|
85
85
|
return e;
|
|
86
86
|
let o = q(e);
|
|
87
87
|
const a = q(G);
|
|
88
|
-
for (let
|
|
89
|
-
if (o =
|
|
88
|
+
for (let i = 0; i < 6; i += 1)
|
|
89
|
+
if (o = bt(o, a, 0.22), Ce(o, ye) >= ve)
|
|
90
90
|
return de(o);
|
|
91
91
|
return de(o);
|
|
92
92
|
}
|
|
@@ -104,7 +104,7 @@ function ht(t) {
|
|
|
104
104
|
</defs>
|
|
105
105
|
<g filter="url(#scribbleBoltWobble)">
|
|
106
106
|
<g clip-path="url(#scribbleBoltClip)">
|
|
107
|
-
<path d="${
|
|
107
|
+
<path d="${ft()}" fill="none" stroke="${e}" stroke-width="56" stroke-linecap="round" stroke-linejoin="round" opacity="0.9" transform="rotate(-14 627 600)"/>
|
|
108
108
|
</g>
|
|
109
109
|
<path d="${n}" fill="none" stroke="${G}" stroke-width="18" stroke-linejoin="round"/>
|
|
110
110
|
<g transform="rotate(-2 528 463)">
|
|
@@ -120,18 +120,18 @@ function ht(t) {
|
|
|
120
120
|
</g>
|
|
121
121
|
</svg>`;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function mt(t) {
|
|
124
124
|
return `data:image/svg+xml,${encodeURIComponent(ht(t))}`;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function ft() {
|
|
127
127
|
let n = "M 280 120", o = !1, a = 0;
|
|
128
|
-
for (let
|
|
129
|
-
const l = (a % 3 - 1) * 18,
|
|
130
|
-
n += ` L ${
|
|
128
|
+
for (let i = 150; i <= 1170; i += 62) {
|
|
129
|
+
const l = (a % 3 - 1) * 18, s = o ? 280 - l : 1020 + l;
|
|
130
|
+
n += ` L ${s} ${i}`, o = !o, a += 1;
|
|
131
131
|
}
|
|
132
132
|
return n;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function wt(t) {
|
|
135
135
|
const e = qe(t), n = ce(q(e));
|
|
136
136
|
return n > 0.86 ? {
|
|
137
137
|
top: "#ffffff",
|
|
@@ -185,16 +185,16 @@ function de([t, e, n]) {
|
|
|
185
185
|
}
|
|
186
186
|
function ce([t, e, n]) {
|
|
187
187
|
const o = (a) => {
|
|
188
|
-
const
|
|
189
|
-
return
|
|
188
|
+
const i = a / 255;
|
|
189
|
+
return i <= 0.04045 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4;
|
|
190
190
|
};
|
|
191
191
|
return 0.2126 * o(t) + 0.7152 * o(e) + 0.0722 * o(n);
|
|
192
192
|
}
|
|
193
193
|
function Ce(t, e) {
|
|
194
|
-
const n = ce(t), o = ce(e), [a,
|
|
195
|
-
return (a + 0.05) / (
|
|
194
|
+
const n = ce(t), o = ce(e), [a, i] = n > o ? [n, o] : [o, n];
|
|
195
|
+
return (a + 0.05) / (i + 0.05);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function bt(t, e, n) {
|
|
198
198
|
const o = ue(n);
|
|
199
199
|
return [
|
|
200
200
|
t[0] + (e[0] - t[0]) * o,
|
|
@@ -203,27 +203,27 @@ function wt(t, e, n) {
|
|
|
203
203
|
];
|
|
204
204
|
}
|
|
205
205
|
function L(t, e, n) {
|
|
206
|
-
const [o, a,
|
|
207
|
-
return de(xt(o, ue(a + n), ue(
|
|
206
|
+
const [o, a, i] = _t(q(t));
|
|
207
|
+
return de(xt(o, ue(a + n), ue(i + e)));
|
|
208
208
|
}
|
|
209
209
|
function _t([t, e, n]) {
|
|
210
|
-
const o = t / 255, a = e / 255,
|
|
211
|
-
if (l ===
|
|
210
|
+
const o = t / 255, a = e / 255, i = n / 255, l = Math.max(o, a, i), s = Math.min(o, a, i), u = (l + s) / 2;
|
|
211
|
+
if (l === s)
|
|
212
212
|
return [0, 0, u];
|
|
213
|
-
const h = l -
|
|
214
|
-
return [(l === o ? (a -
|
|
213
|
+
const h = l - s, c = u > 0.5 ? h / (2 - l - s) : h / (l + s);
|
|
214
|
+
return [(l === o ? (a - i) / h + (a < i ? 6 : 0) : l === a ? (i - o) / h + 2 : (o - a) / h + 4) / 6, c, u];
|
|
215
215
|
}
|
|
216
216
|
function xt(t, e, n) {
|
|
217
217
|
if (e === 0)
|
|
218
218
|
return [n * 255, n * 255, n * 255];
|
|
219
219
|
const o = n < 0.5 ? n * (1 + e) : n + e - n * e, a = 2 * n - o;
|
|
220
220
|
return [
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
re(a, o, t + 1 / 3) * 255,
|
|
222
|
+
re(a, o, t) * 255,
|
|
223
|
+
re(a, o, t - 1 / 3) * 255
|
|
224
224
|
];
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function re(t, e, n) {
|
|
227
227
|
let o = n;
|
|
228
228
|
return o < 0 && (o += 1), o > 1 && (o -= 1), o < 1 / 6 ? t + (e - t) * 6 * o : o < 1 / 2 ? e : o < 2 / 3 ? t + (e - t) * (2 / 3 - o) * 6 : t;
|
|
229
229
|
}
|
|
@@ -277,10 +277,10 @@ async function Ut(t = {}) {
|
|
|
277
277
|
n.className = "pluno-pa-widget-host";
|
|
278
278
|
const o = n.attachShadow({ mode: "open" }), a = document.createElement("div");
|
|
279
279
|
a.className = `pluno-pa-widget pluno-pa-widget--${e.position}`;
|
|
280
|
-
let
|
|
281
|
-
Zt(a, e.launcherLabel,
|
|
282
|
-
const l = await kn(),
|
|
283
|
-
l.appendChild(n), a.classList.add(`pluno-pa-widget--${e.colorScheme}`), We(o, e.accentColor), Ae(a,
|
|
280
|
+
let i = Pe(e.accentColor, e.scribbleStyle);
|
|
281
|
+
Zt(a, e.launcherLabel, i, e.movableLauncher), o.appendChild(a);
|
|
282
|
+
const l = await kn(), s = l.ownerDocument;
|
|
283
|
+
l.appendChild(n), a.classList.add(`pluno-pa-widget--${e.colorScheme}`), We(o, e.accentColor), Ae(a, i, {
|
|
284
284
|
accentColor: e.accentColor,
|
|
285
285
|
colorScheme: e.colorScheme,
|
|
286
286
|
fontFamily: e.fontFamily,
|
|
@@ -291,29 +291,29 @@ async function Ut(t = {}) {
|
|
|
291
291
|
fontFamily: e.fontFamily,
|
|
292
292
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
293
293
|
});
|
|
294
|
-
const u = a.querySelector(".pluno-pa-widget__launcher"), h = a.querySelector(".pluno-pa-widget__launcher-drag-handle"), c = a.querySelector(".pluno-pa-widget__launcher-input"),
|
|
295
|
-
if (!u || !c || !
|
|
294
|
+
const u = a.querySelector(".pluno-pa-widget__launcher"), h = a.querySelector(".pluno-pa-widget__launcher-drag-handle"), c = a.querySelector(".pluno-pa-widget__launcher-input"), f = a.querySelector(".pluno-pa-widget__panel"), y = a.querySelector(".pluno-pa-widget__close"), k = a.querySelector(".pluno-pa-widget__composer"), v = a.querySelector(".pluno-pa-widget__attachment-error"), d = a.querySelector(".pluno-pa-widget__attachments"), p = a.querySelector(".pluno-pa-widget__input"), m = a.querySelector(".pluno-pa-widget__send"), b = a.querySelector(".pluno-pa-widget__new-chat"), w = a.querySelector(".pluno-pa-widget__timeline");
|
|
295
|
+
if (!u || !c || !f || !y || !k || !v || !d || !p || !m || !b || !w)
|
|
296
296
|
throw new Error("Failed to mount Pluno widget");
|
|
297
297
|
if (e.movableLauncher && !h)
|
|
298
298
|
throw new Error("Failed to mount Pluno widget drag handle");
|
|
299
299
|
De(c), De(p);
|
|
300
300
|
let x = [], P = null;
|
|
301
301
|
const F = () => {
|
|
302
|
-
sn(
|
|
303
|
-
x = x.filter((g, E) => E !==
|
|
302
|
+
sn(d, x, (r) => {
|
|
303
|
+
x = x.filter((g, E) => E !== r), F(), N();
|
|
304
304
|
});
|
|
305
305
|
}, ot = e.loginRequired || e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (async () => {
|
|
306
306
|
if (!e.tokenEndpoint)
|
|
307
307
|
throw new Error("Pluno widget requires token or tokenEndpoint");
|
|
308
|
-
const
|
|
308
|
+
const r = await fetch(e.tokenEndpoint, {
|
|
309
309
|
method: "POST",
|
|
310
310
|
credentials: "include",
|
|
311
311
|
headers: { "content-type": "application/json" },
|
|
312
312
|
body: JSON.stringify({ origin: location.origin, url: location.href })
|
|
313
313
|
});
|
|
314
|
-
if (!
|
|
314
|
+
if (!r.ok)
|
|
315
315
|
throw new Error("Failed to load Pluno token");
|
|
316
|
-
const g = await
|
|
316
|
+
const g = await r.json();
|
|
317
317
|
if (!g.token)
|
|
318
318
|
throw new Error("Pluno token endpoint did not return a token");
|
|
319
319
|
return g.token;
|
|
@@ -332,13 +332,13 @@ async function Ut(t = {}) {
|
|
|
332
332
|
autoConnect: e.loginRequired ? !1 : void 0
|
|
333
333
|
});
|
|
334
334
|
const z = Sn(e), K = new Set(z.openToolGroupKeys);
|
|
335
|
-
let A = e.movableLauncher ? z.launcherPosition : null, he = A !== null, R = null,
|
|
335
|
+
let A = e.movableLauncher ? z.launcherPosition : null, he = A !== null, R = null, me = !1;
|
|
336
336
|
const at = () => {
|
|
337
|
-
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
-
const ne = (
|
|
341
|
-
const g = Te(a,
|
|
337
|
+
me || typeof document > "u" || (We(o, e.accentColor), n.isConnected || s.body?.appendChild(n));
|
|
338
|
+
}, fe = new MutationObserver(at);
|
|
339
|
+
fe.observe(s.documentElement, { childList: !0, subtree: !0 });
|
|
340
|
+
const ne = (r = !0) => {
|
|
341
|
+
const g = Te(a, r);
|
|
342
342
|
return Ne(
|
|
343
343
|
a,
|
|
344
344
|
A ?? Kt(a, e.position, g),
|
|
@@ -351,8 +351,8 @@ async function Ut(t = {}) {
|
|
|
351
351
|
openToolGroupKeys: [...K],
|
|
352
352
|
launcherPosition: he ? A : null
|
|
353
353
|
});
|
|
354
|
-
}, M = (
|
|
355
|
-
Xt(
|
|
354
|
+
}, M = (r, g = {}) => {
|
|
355
|
+
Xt(r, {
|
|
356
356
|
debugVersion: zt,
|
|
357
357
|
launcherPosition: A,
|
|
358
358
|
rootClasses: a.className,
|
|
@@ -364,123 +364,123 @@ async function Ut(t = {}) {
|
|
|
364
364
|
},
|
|
365
365
|
rootRect: le(a),
|
|
366
366
|
launcherRect: le(u),
|
|
367
|
-
panelRect: le(
|
|
367
|
+
panelRect: le(f),
|
|
368
368
|
viewport: B(),
|
|
369
|
-
panelHidden:
|
|
369
|
+
panelHidden: f.hidden,
|
|
370
370
|
closeHidden: y.hidden,
|
|
371
371
|
...g
|
|
372
372
|
});
|
|
373
|
-
}, j = (
|
|
373
|
+
}, j = (r = !0) => {
|
|
374
374
|
if (!A)
|
|
375
|
-
return X(a, null), ne(
|
|
376
|
-
const g = ne(
|
|
375
|
+
return X(a, null), ne(r);
|
|
376
|
+
const g = ne(r);
|
|
377
377
|
return X(a, g), M("Applied stored closed launcher position", { visibleLauncherPosition: g }), g;
|
|
378
|
-
},
|
|
379
|
-
if (!
|
|
378
|
+
}, we = (r, g) => {
|
|
379
|
+
if (!r || !g) {
|
|
380
380
|
Re(a);
|
|
381
381
|
return;
|
|
382
382
|
}
|
|
383
383
|
Yt(a, {
|
|
384
|
-
x:
|
|
385
|
-
y:
|
|
384
|
+
x: r.x - g.x,
|
|
385
|
+
y: r.y - g.y
|
|
386
386
|
});
|
|
387
|
-
},
|
|
388
|
-
const
|
|
387
|
+
}, be = () => {
|
|
388
|
+
const r = j();
|
|
389
389
|
if (a.classList.contains("pluno-pa-widget--open") || a.classList.contains("pluno-pa-widget--closing")) {
|
|
390
|
-
const g = Ie(
|
|
391
|
-
|
|
392
|
-
} else A && M("Applied visible launcher position after viewport resize", { visibleLauncherPosition:
|
|
390
|
+
const g = Ie(r);
|
|
391
|
+
we(g, r), M("Applied open panel position after viewport resize", { openPanelPosition: g });
|
|
392
|
+
} else A && M("Applied visible launcher position after viewport resize", { visibleLauncherPosition: r });
|
|
393
393
|
};
|
|
394
394
|
let _e = () => {
|
|
395
395
|
};
|
|
396
|
-
e.movableLauncher && h ? (j(), window.addEventListener("resize",
|
|
396
|
+
e.movableLauncher && h ? (j(), window.addEventListener("resize", be), _e = Vt({
|
|
397
397
|
root: a,
|
|
398
398
|
launcherDragHandle: h,
|
|
399
399
|
getPosition: () => ne(),
|
|
400
|
-
setPosition: (
|
|
401
|
-
const g =
|
|
402
|
-
A = Ne(a,
|
|
400
|
+
setPosition: (r) => {
|
|
401
|
+
const g = r;
|
|
402
|
+
A = Ne(a, r, Te(a)), X(a, A), M("Dragging closed launcher", { requestedPosition: g });
|
|
403
403
|
},
|
|
404
404
|
persist: () => {
|
|
405
405
|
he = !0, T(), M("Persisted closed launcher drag position");
|
|
406
406
|
}
|
|
407
407
|
})) : X(a, null);
|
|
408
|
-
const W = (
|
|
409
|
-
if (R !== null && (window.clearTimeout(R), R = null),
|
|
408
|
+
const W = (r = "", g = !0) => {
|
|
409
|
+
if (R !== null && (window.clearTimeout(R), R = null), f.hidden = !1, y.hidden = !1, a.classList.remove("pluno-pa-widget--closing"), e.movableLauncher) {
|
|
410
410
|
const E = j(), H = Ie(E);
|
|
411
|
-
|
|
411
|
+
we(H, E), M("Opening launcher at clamped open panel position", { openPanelPosition: H, visibleLauncherPosition: E });
|
|
412
412
|
} else
|
|
413
413
|
Re(a);
|
|
414
414
|
if (!g) {
|
|
415
|
-
a.classList.add("pluno-pa-widget--open"), u.hidden = !0,
|
|
415
|
+
a.classList.add("pluno-pa-widget--open"), u.hidden = !0, r && (p.value = r, V(p)), w.scrollTop = w.scrollHeight, p.focus(), p.setSelectionRange(p.value.length, p.value.length), T();
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
418
418
|
window.requestAnimationFrame(() => {
|
|
419
|
-
a.classList.add("pluno-pa-widget--open"),
|
|
420
|
-
u.hidden = !0,
|
|
419
|
+
a.classList.add("pluno-pa-widget--open"), r && (p.value = r, V(p)), w.scrollTop = w.scrollHeight, p.focus(), p.setSelectionRange(p.value.length, p.value.length), T(), R = window.setTimeout(() => {
|
|
420
|
+
u.hidden = !0, w.scrollTop = w.scrollHeight;
|
|
421
421
|
}, 220);
|
|
422
422
|
});
|
|
423
|
-
},
|
|
423
|
+
}, it = () => {
|
|
424
424
|
R !== null && (window.clearTimeout(R), R = null), u.hidden = !1, A && (j(!1), M("Closing launcher at stored position")), a.classList.remove("pluno-pa-widget--open"), a.classList.add("pluno-pa-widget--closing"), T(), R = window.setTimeout(() => {
|
|
425
|
-
|
|
425
|
+
f.hidden = !0, y.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
|
|
426
426
|
}, 220);
|
|
427
427
|
};
|
|
428
|
-
u.addEventListener("submit", (
|
|
429
|
-
|
|
430
|
-
}), h?.addEventListener("click", (
|
|
431
|
-
|
|
432
|
-
}), u.addEventListener("click", (
|
|
433
|
-
|
|
428
|
+
u.addEventListener("submit", (r) => {
|
|
429
|
+
r.preventDefault(), W(c.value), c.value = "";
|
|
430
|
+
}), h?.addEventListener("click", (r) => {
|
|
431
|
+
r.preventDefault(), r.stopPropagation();
|
|
432
|
+
}), u.addEventListener("click", (r) => {
|
|
433
|
+
r.target !== c && (W(c.value), c.value = "");
|
|
434
434
|
}), c.addEventListener("focus", () => {
|
|
435
435
|
W(c.value), c.value = "";
|
|
436
436
|
}), c.addEventListener("input", () => {
|
|
437
437
|
if (!c.value)
|
|
438
438
|
return;
|
|
439
|
-
const
|
|
440
|
-
W(
|
|
441
|
-
}), y.addEventListener("click",
|
|
439
|
+
const r = c.value;
|
|
440
|
+
W(r), c.value = "";
|
|
441
|
+
}), y.addEventListener("click", it);
|
|
442
442
|
const N = () => {
|
|
443
|
-
|
|
443
|
+
m.disabled = !C.getState().isThinking && p.value.trim().length === 0 && x.length === 0;
|
|
444
444
|
};
|
|
445
|
-
e.loginRequired && (c.readOnly = !0, c.placeholder = e.loginButtonLabel, p.placeholder = e.loginButtonLabel, k.hidden = !0), k.addEventListener("submit", (
|
|
446
|
-
if (
|
|
445
|
+
e.loginRequired && (c.readOnly = !0, c.placeholder = e.loginButtonLabel, p.placeholder = e.loginButtonLabel, k.hidden = !0), k.addEventListener("submit", (r) => {
|
|
446
|
+
if (r.preventDefault(), e.loginRequired) {
|
|
447
447
|
e.onLoginClick?.();
|
|
448
448
|
return;
|
|
449
449
|
}
|
|
450
450
|
x = pe(C, p, x), F(), N();
|
|
451
451
|
});
|
|
452
452
|
let U = 0;
|
|
453
|
-
const
|
|
453
|
+
const rt = () => {
|
|
454
454
|
U = 0, a.classList.remove("pluno-pa-widget--drag-over");
|
|
455
|
-
}, lt = (
|
|
456
|
-
P !== null && window.clearTimeout(P), v.textContent =
|
|
455
|
+
}, lt = (r) => {
|
|
456
|
+
P !== null && window.clearTimeout(P), v.textContent = r, v.hidden = !1, P = window.setTimeout(() => {
|
|
457
457
|
v.textContent = "", v.hidden = !0, P = null;
|
|
458
458
|
}, 3e3);
|
|
459
459
|
}, pt = () => {
|
|
460
460
|
P !== null && (window.clearTimeout(P), P = null), v.textContent = "", v.hidden = !0;
|
|
461
|
-
}, st = async (
|
|
462
|
-
if (
|
|
461
|
+
}, st = async (r) => {
|
|
462
|
+
if (r.length === 0)
|
|
463
463
|
return;
|
|
464
|
-
const g = await gn(
|
|
464
|
+
const g = await gn(r);
|
|
465
465
|
if (x.length + g.length > ee)
|
|
466
466
|
throw new Error(`Attach up to ${ee} files per message.`);
|
|
467
467
|
x = [...x, ...g], F(), pt(), N();
|
|
468
468
|
};
|
|
469
|
-
a.addEventListener("dragenter", (
|
|
470
|
-
!Z(
|
|
471
|
-
}), a.addEventListener("dragover", (
|
|
472
|
-
const g =
|
|
473
|
-
!Z(g) || e.loginRequired || (
|
|
474
|
-
}), a.addEventListener("dragleave", (
|
|
475
|
-
Z(
|
|
476
|
-
}), a.addEventListener("drop", (
|
|
477
|
-
const g =
|
|
478
|
-
!Z(g) || e.loginRequired || (
|
|
469
|
+
a.addEventListener("dragenter", (r) => {
|
|
470
|
+
!Z(r.dataTransfer) || e.loginRequired || (r.preventDefault(), r.stopPropagation(), U += 1, a.classList.add("pluno-pa-widget--drag-over"));
|
|
471
|
+
}), a.addEventListener("dragover", (r) => {
|
|
472
|
+
const g = r.dataTransfer;
|
|
473
|
+
!Z(g) || e.loginRequired || (r.preventDefault(), r.stopPropagation(), g.dropEffect = "copy");
|
|
474
|
+
}), a.addEventListener("dragleave", (r) => {
|
|
475
|
+
Z(r.dataTransfer) && (r.stopPropagation(), U = Math.max(0, U - 1), U === 0 && a.classList.remove("pluno-pa-widget--drag-over"));
|
|
476
|
+
}), a.addEventListener("drop", (r) => {
|
|
477
|
+
const g = r.dataTransfer;
|
|
478
|
+
!Z(g) || e.loginRequired || (r.preventDefault(), r.stopPropagation(), rt(), st(g.files).catch((E) => {
|
|
479
479
|
lt(E instanceof Error ? E.message : "Failed to attach file"), O("web-sdk.widget", "Attachment failed", {
|
|
480
480
|
message: E instanceof Error ? E.message : String(E)
|
|
481
481
|
});
|
|
482
482
|
}));
|
|
483
|
-
}),
|
|
483
|
+
}), m.addEventListener("click", () => {
|
|
484
484
|
if (e.loginRequired) {
|
|
485
485
|
e.onLoginClick?.();
|
|
486
486
|
return;
|
|
@@ -490,72 +490,72 @@ async function Ut(t = {}) {
|
|
|
490
490
|
return;
|
|
491
491
|
}
|
|
492
492
|
x = pe(C, p, x), F(), N();
|
|
493
|
-
}),
|
|
493
|
+
}), b.addEventListener("click", () => {
|
|
494
494
|
C.startNewSession(), K.clear(), p.value = "", x = [], F(), V(p), T(), N(), p.focus();
|
|
495
495
|
}), p.addEventListener("input", () => {
|
|
496
496
|
V(p), T(), N();
|
|
497
|
-
}), p.addEventListener("keydown", (
|
|
498
|
-
if (!(
|
|
499
|
-
if (
|
|
497
|
+
}), p.addEventListener("keydown", (r) => {
|
|
498
|
+
if (!(r.key !== "Enter" || r.shiftKey)) {
|
|
499
|
+
if (r.preventDefault(), e.loginRequired) {
|
|
500
500
|
e.onLoginClick?.();
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
503
|
x = pe(C, p, x), F(), N();
|
|
504
504
|
}
|
|
505
|
-
}), a.addEventListener("click", (
|
|
506
|
-
(
|
|
505
|
+
}), a.addEventListener("click", (r) => {
|
|
506
|
+
(r.target instanceof Element ? r.target : null)?.closest("a[href]") && T();
|
|
507
507
|
}), z.composerValue && (p.value = z.composerValue, V(p)), z.isOpen && W(p.value, !1);
|
|
508
|
-
const Y = () =>
|
|
508
|
+
const Y = () => i;
|
|
509
509
|
let oe = C.getState().appearance !== null;
|
|
510
|
-
return C.on("state", (
|
|
511
|
-
|
|
512
|
-
appearance:
|
|
513
|
-
}), ae(
|
|
510
|
+
return C.on("state", (r) => {
|
|
511
|
+
r.appearance ? (oe = !0, O("web-sdk.widget", "Agent state supplied appearance", {
|
|
512
|
+
appearance: r.appearance
|
|
513
|
+
}), ae(r.appearance, "agent.state.appearance")) : oe && (oe = !1, O("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
|
|
514
514
|
fallbackAccentColor: e.accentColor,
|
|
515
515
|
fallbackColorScheme: e.colorScheme,
|
|
516
516
|
fallbackFontFamily: e.fontFamily
|
|
517
|
-
}), ae({}, "agent.state.appearance-cleared")), e.loginRequired ? Fe(
|
|
517
|
+
}), ae({}, "agent.state.appearance-cleared")), e.loginRequired ? Fe(w, m, b, Y, e.loginButtonLabel, e.onLoginClick) : Oe(w, m, b, r, K, T, Y, (g) => {
|
|
518
518
|
C.sendMessage(g);
|
|
519
519
|
}), N();
|
|
520
|
-
}), e.loginRequired ? Fe(
|
|
521
|
-
C.sendMessage(
|
|
520
|
+
}), e.loginRequired ? Fe(w, m, b, Y, e.loginButtonLabel, e.onLoginClick) : Oe(w, m, b, C.getState(), K, T, Y, (r) => {
|
|
521
|
+
C.sendMessage(r);
|
|
522
522
|
}), N(), {
|
|
523
523
|
agent: C,
|
|
524
|
-
updateAppearance: (
|
|
525
|
-
|
|
524
|
+
updateAppearance: (r) => {
|
|
525
|
+
r.scribbleStyle !== void 0 && (e.scribbleStyle = r.scribbleStyle), ae(r, "widgetHandle.updateAppearance");
|
|
526
526
|
},
|
|
527
527
|
destroy: () => {
|
|
528
|
-
|
|
528
|
+
me = !0, fe.disconnect(), e.movableLauncher && window.removeEventListener("resize", be), _e(), P !== null && window.clearTimeout(P), C.destroy(), n.remove();
|
|
529
529
|
}
|
|
530
530
|
};
|
|
531
|
-
function ae(
|
|
532
|
-
const E =
|
|
533
|
-
|
|
531
|
+
function ae(r, g) {
|
|
532
|
+
const E = r.accentColor ?? e.accentColor, H = r.colorScheme ?? e.colorScheme, xe = r.fontFamily ?? e.fontFamily, ie = r.scribbleStyle ?? e.scribbleStyle;
|
|
533
|
+
i = Pe(E, ie), Ae(a, i, {
|
|
534
534
|
accentColor: E,
|
|
535
535
|
colorScheme: H,
|
|
536
536
|
fontFamily: xe,
|
|
537
|
-
scribbleStyle:
|
|
537
|
+
scribbleStyle: ie
|
|
538
538
|
}), O("web-sdk.widget", "Updated widget appearance", {
|
|
539
539
|
source: g,
|
|
540
|
-
inputAppearance:
|
|
540
|
+
inputAppearance: r,
|
|
541
541
|
appliedAccentColor: E,
|
|
542
542
|
appliedColorScheme: H,
|
|
543
543
|
appliedFontFamily: xe,
|
|
544
|
-
appliedScribbleStyle:
|
|
544
|
+
appliedScribbleStyle: ie,
|
|
545
545
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
546
546
|
});
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
function Pe(t, e) {
|
|
550
|
-
return e ?
|
|
550
|
+
return e ? mt(t) : gt(t);
|
|
551
551
|
}
|
|
552
552
|
function Ae(t, e, n) {
|
|
553
553
|
t.classList.toggle("pluno-pa-widget--dark", n.colorScheme === "dark"), t.classList.toggle("pluno-pa-widget--light", n.colorScheme !== "dark"), t.classList.toggle("pluno-pa-widget--scribble", n.scribbleStyle);
|
|
554
554
|
const o = n.scribbleStyle ? Ve(n.accentColor) : n.accentColor;
|
|
555
555
|
t.style.setProperty("--pluno-pa-accent", o), t.style.fontFamily = n.scribbleStyle ? Nt : n.fontFamily, n.scribbleStyle && Ht(t.ownerDocument);
|
|
556
556
|
const a = Array.from(t.querySelectorAll(".pluno-pa-widget__character"));
|
|
557
|
-
for (const
|
|
558
|
-
|
|
557
|
+
for (const i of a)
|
|
558
|
+
i.src = e;
|
|
559
559
|
}
|
|
560
560
|
function Ht(t) {
|
|
561
561
|
if (t.getElementById(Se))
|
|
@@ -576,30 +576,30 @@ function Vt({
|
|
|
576
576
|
setPosition: o,
|
|
577
577
|
persist: a
|
|
578
578
|
}) {
|
|
579
|
-
let
|
|
579
|
+
let i = null, l = null, s = null, u = !1;
|
|
580
580
|
const h = () => {
|
|
581
|
-
|
|
582
|
-
}, c = (
|
|
583
|
-
t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing") || (
|
|
584
|
-
},
|
|
585
|
-
if (
|
|
581
|
+
i = null, l = null, s = null, u = !1, t.classList.remove("pluno-pa-widget--dragging");
|
|
582
|
+
}, c = (d) => {
|
|
583
|
+
t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing") || (d.preventDefault(), d.stopPropagation(), i = d.pointerId, l = { x: d.clientX, y: d.clientY }, s = n(), u = !1, e.setPointerCapture?.(d.pointerId));
|
|
584
|
+
}, f = (d) => {
|
|
585
|
+
if (i !== d.pointerId || !l || !s)
|
|
586
586
|
return;
|
|
587
|
-
|
|
588
|
-
const p =
|
|
589
|
-
!u && Math.hypot(p,
|
|
590
|
-
}, y = (
|
|
591
|
-
|
|
592
|
-
}, k = (
|
|
593
|
-
|
|
594
|
-
}, v = (
|
|
587
|
+
d.preventDefault();
|
|
588
|
+
const p = d.clientX - l.x, m = d.clientY - l.y;
|
|
589
|
+
!u && Math.hypot(p, m) < Gt || (u = !0, t.classList.add("pluno-pa-widget--dragging"), o({ x: s.x + p, y: s.y + m }));
|
|
590
|
+
}, y = (d) => {
|
|
591
|
+
i === d.pointerId && (d.preventDefault(), d.stopPropagation(), u && a(), h());
|
|
592
|
+
}, k = (d) => {
|
|
593
|
+
i === d.pointerId && (d.preventDefault(), h());
|
|
594
|
+
}, v = (d) => {
|
|
595
595
|
if (t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing"))
|
|
596
596
|
return;
|
|
597
|
-
const p =
|
|
598
|
-
let
|
|
599
|
-
|
|
597
|
+
const p = d.shiftKey ? $t : Bt, m = n();
|
|
598
|
+
let b = null;
|
|
599
|
+
d.key === "ArrowUp" ? b = { x: m.x, y: m.y - p } : d.key === "ArrowDown" ? b = { x: m.x, y: m.y + p } : d.key === "ArrowLeft" ? b = { x: m.x - p, y: m.y } : d.key === "ArrowRight" && (b = { x: m.x + p, y: m.y }), b && (d.preventDefault(), d.stopPropagation(), o(b), a());
|
|
600
600
|
};
|
|
601
|
-
return e.addEventListener("pointerdown", c), e.addEventListener("pointermove",
|
|
602
|
-
e.removeEventListener("pointerdown", c), e.removeEventListener("pointermove",
|
|
601
|
+
return e.addEventListener("pointerdown", c), e.addEventListener("pointermove", f), e.addEventListener("pointerup", y), e.addEventListener("pointercancel", k), e.addEventListener("keydown", v), () => {
|
|
602
|
+
e.removeEventListener("pointerdown", c), e.removeEventListener("pointermove", f), e.removeEventListener("pointerup", y), e.removeEventListener("pointercancel", k), e.removeEventListener("keydown", v);
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
605
|
function Te(t, e = !0) {
|
|
@@ -620,9 +620,9 @@ function Kt(t, e, n) {
|
|
|
620
620
|
const o = Number.parseFloat(t.style.left), a = Number.parseFloat(t.style.top);
|
|
621
621
|
if (Number.isFinite(o) && Number.isFinite(a))
|
|
622
622
|
return { x: o, y: a };
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
625
|
-
return { x:
|
|
623
|
+
const i = t.getBoundingClientRect();
|
|
624
|
+
if (i.width > 0 || i.height > 0)
|
|
625
|
+
return { x: i.left, y: i.top };
|
|
626
626
|
const l = B();
|
|
627
627
|
return {
|
|
628
628
|
x: e === "bottom-left" ? 26 : l.width - 26 - n.width,
|
|
@@ -689,8 +689,8 @@ function O(t, e, n) {
|
|
|
689
689
|
source: t,
|
|
690
690
|
message: e,
|
|
691
691
|
details: n
|
|
692
|
-
},
|
|
693
|
-
|
|
692
|
+
}, i = o.__plunoProductAgentDiagnostics__ ?? [];
|
|
693
|
+
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(Pt, { detail: a }));
|
|
694
694
|
}
|
|
695
695
|
function Xt(t, e) {
|
|
696
696
|
O("web-sdk.widget.position", t, e);
|
|
@@ -710,8 +710,8 @@ function Zt(t, e, n, o) {
|
|
|
710
710
|
function Jt(t, e, n) {
|
|
711
711
|
const o = document.createElement("form");
|
|
712
712
|
if (o.className = "pluno-pa-widget__launcher", n) {
|
|
713
|
-
const
|
|
714
|
-
|
|
713
|
+
const i = document.createElement("button");
|
|
714
|
+
i.type = "button", i.className = "pluno-pa-widget__launcher-drag-handle", i.setAttribute("aria-label", "Move Pluno launcher"), i.title = "Move Pluno launcher", o.appendChild(i);
|
|
715
715
|
}
|
|
716
716
|
o.appendChild(Xe("pluno-pa-widget__character--launcher", e));
|
|
717
717
|
const a = document.createElement("input");
|
|
@@ -736,10 +736,14 @@ function en() {
|
|
|
736
736
|
o.className = "pluno-pa-widget__composer-inner";
|
|
737
737
|
const a = document.createElement("textarea");
|
|
738
738
|
a.className = "pluno-pa-widget__input", a.rows = 1, a.placeholder = "Ask for anything...", o.appendChild(a);
|
|
739
|
-
const
|
|
740
|
-
|
|
741
|
-
const l = document.createElement("
|
|
742
|
-
|
|
739
|
+
const i = document.createElement("button");
|
|
740
|
+
i.type = "button", i.className = "pluno-pa-widget__send", i.setAttribute("aria-label", "Send"), i.appendChild(Je()), o.appendChild(i), t.appendChild(o);
|
|
741
|
+
const l = document.createElement("div");
|
|
742
|
+
l.className = "pluno-pa-widget__composer-meta";
|
|
743
|
+
const s = document.createElement("a");
|
|
744
|
+
s.className = "pluno-pa-widget__powered-by", s.href = "https://pluno.ai", s.target = "_blank", s.rel = "noopener noreferrer", s.textContent = "Powered by Pluno.ai", l.appendChild(s);
|
|
745
|
+
const u = document.createElement("span");
|
|
746
|
+
return u.className = "pluno-pa-widget__ai-disclaimer", u.textContent = "AI can make mistakes", l.appendChild(u), t.appendChild(l), t;
|
|
743
747
|
}
|
|
744
748
|
function tn(t) {
|
|
745
749
|
const e = document.createElement("div");
|
|
@@ -828,7 +832,7 @@ function pn() {
|
|
|
828
832
|
const t = $("0 0 24 24", 13, 13, "none", "currentColor", "2.25");
|
|
829
833
|
return t.appendChild(_("rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2" })), t.appendChild(_("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })), t;
|
|
830
834
|
}
|
|
831
|
-
function $(t, e, n, o, a,
|
|
835
|
+
function $(t, e, n, o, a, i) {
|
|
832
836
|
const l = {
|
|
833
837
|
viewBox: t,
|
|
834
838
|
width: String(e),
|
|
@@ -836,7 +840,7 @@ function $(t, e, n, o, a, r) {
|
|
|
836
840
|
fill: o,
|
|
837
841
|
"aria-hidden": "true"
|
|
838
842
|
};
|
|
839
|
-
return a && (l.stroke = a, l["stroke-linecap"] = "round", l["stroke-linejoin"] = "round"),
|
|
843
|
+
return a && (l.stroke = a, l["stroke-linecap"] = "round", l["stroke-linejoin"] = "round"), i && (l["stroke-width"] = i), _("svg", l);
|
|
840
844
|
}
|
|
841
845
|
function _(t, e = {}) {
|
|
842
846
|
const n = document.createElementNS(Mt, t);
|
|
@@ -853,12 +857,12 @@ function De(t) {
|
|
|
853
857
|
function sn(t, e, n) {
|
|
854
858
|
t.replaceChildren(), t.hidden = e.length === 0;
|
|
855
859
|
for (const [o, a] of e.entries()) {
|
|
856
|
-
const
|
|
857
|
-
|
|
860
|
+
const i = document.createElement("div");
|
|
861
|
+
i.className = "pluno-pa-widget__attachment", i.appendChild(dn(a));
|
|
858
862
|
const l = document.createElement("span");
|
|
859
|
-
l.textContent = a.name,
|
|
860
|
-
const
|
|
861
|
-
|
|
863
|
+
l.textContent = a.name, i.appendChild(l);
|
|
864
|
+
const s = document.createElement("button");
|
|
865
|
+
s.type = "button", s.setAttribute("aria-label", `Remove ${a.name}`), s.appendChild(ln()), s.addEventListener("click", () => n(o)), i.appendChild(s), t.appendChild(i);
|
|
862
866
|
}
|
|
863
867
|
}
|
|
864
868
|
function dn(t) {
|
|
@@ -901,15 +905,15 @@ async function gn(t) {
|
|
|
901
905
|
if (n.size > At)
|
|
902
906
|
throw new Error("Each Pluno attachment can be up to 10 MB.");
|
|
903
907
|
if (o === "image/gif") {
|
|
904
|
-
const a = new Uint8Array(await
|
|
905
|
-
if (
|
|
908
|
+
const a = new Uint8Array(await bn(n));
|
|
909
|
+
if (fn(a))
|
|
906
910
|
throw new Error("Pluno supports non-animated GIF images.");
|
|
907
911
|
}
|
|
908
912
|
return {
|
|
909
913
|
name: n.name || un(o),
|
|
910
914
|
mimeType: o,
|
|
911
915
|
sizeBytes: n.size,
|
|
912
|
-
dataUrl:
|
|
916
|
+
dataUrl: mn(await _n(n), o)
|
|
913
917
|
};
|
|
914
918
|
})
|
|
915
919
|
);
|
|
@@ -920,12 +924,12 @@ function hn(t) {
|
|
|
920
924
|
const e = t.name.toLowerCase();
|
|
921
925
|
return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
|
|
922
926
|
}
|
|
923
|
-
function
|
|
927
|
+
function mn(t, e) {
|
|
924
928
|
const n = `data:${e};base64,`;
|
|
925
929
|
return t.startsWith(n) ? t : t.replace(/^data:[^;]*;base64,/, n);
|
|
926
930
|
}
|
|
927
|
-
function
|
|
928
|
-
if (t.length < 14 || !
|
|
931
|
+
function fn(t) {
|
|
932
|
+
if (t.length < 14 || !wn(t))
|
|
929
933
|
return !1;
|
|
930
934
|
const e = t[10];
|
|
931
935
|
let n = 13;
|
|
@@ -945,14 +949,14 @@ function mn(t) {
|
|
|
945
949
|
return !0;
|
|
946
950
|
if (n + 9 >= t.length)
|
|
947
951
|
return !1;
|
|
948
|
-
const
|
|
949
|
-
if (n += 9,
|
|
952
|
+
const i = t[n + 8];
|
|
953
|
+
if (n += 9, i & 128 && (n += 3 * 2 ** ((i & 7) + 1)), n >= t.length)
|
|
950
954
|
return !1;
|
|
951
955
|
n += 1, n = Me(t, n);
|
|
952
956
|
}
|
|
953
957
|
return !1;
|
|
954
958
|
}
|
|
955
|
-
function
|
|
959
|
+
function wn(t) {
|
|
956
960
|
return t[0] === 71 && t[1] === 73 && t[2] === 70 && t[3] === 56 && (t[4] === 55 || t[4] === 57) && t[5] === 97;
|
|
957
961
|
}
|
|
958
962
|
function Me(t, e) {
|
|
@@ -967,7 +971,7 @@ function Me(t, e) {
|
|
|
967
971
|
function Z(t) {
|
|
968
972
|
return !!(t && Array.from(t.types).includes("Files"));
|
|
969
973
|
}
|
|
970
|
-
function
|
|
974
|
+
function bn(t) {
|
|
971
975
|
return new Promise((e, n) => {
|
|
972
976
|
const o = new FileReader();
|
|
973
977
|
o.addEventListener("load", () => {
|
|
@@ -995,82 +999,82 @@ function _n(t) {
|
|
|
995
999
|
}), o.readAsDataURL(t);
|
|
996
1000
|
});
|
|
997
1001
|
}
|
|
998
|
-
function Oe(t, e, n, o, a,
|
|
1002
|
+
function Oe(t, e, n, o, a, i, l, s) {
|
|
999
1003
|
const u = [...o.messages];
|
|
1000
1004
|
t.replaceChildren(), tt(e, o.isThinking);
|
|
1001
1005
|
const h = u.length > 0 || !!o.assistantDraft || o.isThinking;
|
|
1002
1006
|
if (n.hidden = !h, u.length === 0 && !o.assistantDraft && !o.lastError && !o.isThinking) {
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1007
|
+
const d = document.createElement("div");
|
|
1008
|
+
d.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
1005
1009
|
const p = document.createElement("img");
|
|
1006
|
-
p.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", p.src = l(), p.alt = "", p.setAttribute("aria-hidden", "true"),
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1009
|
-
for (const
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
}),
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1010
|
+
p.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", p.src = l(), p.alt = "", p.setAttribute("aria-hidden", "true"), d.appendChild(p), d.appendChild(Ye());
|
|
1011
|
+
const m = document.createElement("div");
|
|
1012
|
+
m.className = o.starterPrompts.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", o.starterPrompts.length === 0 && m.setAttribute("aria-hidden", "true");
|
|
1013
|
+
for (const b of o.starterPrompts) {
|
|
1014
|
+
const w = document.createElement("button");
|
|
1015
|
+
w.type = "button", w.className = "pluno-pa-widget__starter-prompt", w.textContent = `"${b}"`, w.addEventListener("click", () => {
|
|
1016
|
+
s(b);
|
|
1017
|
+
}), m.appendChild(w);
|
|
1018
|
+
}
|
|
1019
|
+
d.appendChild(m), t.appendChild(d);
|
|
1016
1020
|
return;
|
|
1017
1021
|
}
|
|
1018
|
-
let c = null,
|
|
1022
|
+
let c = null, f = null, y = [];
|
|
1019
1023
|
const k = () => {
|
|
1020
1024
|
if (y.length === 0)
|
|
1021
1025
|
return !1;
|
|
1022
|
-
const
|
|
1023
|
-
return t.appendChild(
|
|
1026
|
+
const d = yn(y, a, i, l());
|
|
1027
|
+
return t.appendChild(d), c = null, f = d, y = [], !0;
|
|
1024
1028
|
};
|
|
1025
|
-
for (let
|
|
1026
|
-
const p = u[
|
|
1029
|
+
for (let d = 0; d < u.length; d += 1) {
|
|
1030
|
+
const p = u[d];
|
|
1027
1031
|
if (p.role === "tool") {
|
|
1028
1032
|
y.push(p);
|
|
1029
1033
|
continue;
|
|
1030
1034
|
}
|
|
1031
1035
|
if (p.role === "system")
|
|
1032
1036
|
continue;
|
|
1033
|
-
const
|
|
1034
|
-
if (p.role === "assistant" && !
|
|
1037
|
+
const m = k(), b = Be(p.content);
|
|
1038
|
+
if (p.role === "assistant" && !m) {
|
|
1035
1039
|
const x = ge(l());
|
|
1036
|
-
t.appendChild(x), c = null,
|
|
1040
|
+
t.appendChild(x), c = null, f = x;
|
|
1037
1041
|
}
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1042
|
+
const w = document.createElement("div");
|
|
1043
|
+
w.className = `pluno-pa-widget__message pluno-pa-widget__message--${p.role}`, p.role === "assistant" ? ze(w, b) : w.textContent = b, p.role === "user" && p.attachments?.length && w.appendChild(xn(p.attachments)), w.appendChild(Ge(b)), t.appendChild(w), c = w, f = null;
|
|
1040
1044
|
}
|
|
1041
1045
|
const v = k();
|
|
1042
1046
|
if (o.assistantDraft) {
|
|
1043
1047
|
if (!v) {
|
|
1044
|
-
const
|
|
1045
|
-
t.appendChild(
|
|
1048
|
+
const m = ge(l());
|
|
1049
|
+
t.appendChild(m), c = null, f = m;
|
|
1046
1050
|
}
|
|
1047
|
-
const
|
|
1048
|
-
p.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", ze(p,
|
|
1051
|
+
const d = Be(o.assistantDraft), p = document.createElement("div");
|
|
1052
|
+
p.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", ze(p, d), p.appendChild(Ge(d)), t.appendChild(p), c = p, f = null;
|
|
1049
1053
|
}
|
|
1050
1054
|
if (o.isThinking && !o.assistantDraft)
|
|
1051
1055
|
if (v) {
|
|
1052
|
-
const
|
|
1053
|
-
t.appendChild(
|
|
1056
|
+
const d = et();
|
|
1057
|
+
t.appendChild(d), c = null, f = d;
|
|
1054
1058
|
} else {
|
|
1055
|
-
const
|
|
1056
|
-
t.appendChild(
|
|
1059
|
+
const d = vn(l());
|
|
1060
|
+
t.appendChild(d), c = null, f = d;
|
|
1057
1061
|
}
|
|
1058
1062
|
if (o.lastError) {
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1063
|
+
const d = document.createElement("div");
|
|
1064
|
+
d.className = "pluno-pa-widget__error", d.textContent = o.lastError, t.appendChild(d), c = d, f = null;
|
|
1061
1065
|
}
|
|
1062
|
-
c?.classList.add("pluno-pa-widget__message--bottom-reserve"),
|
|
1066
|
+
c?.classList.add("pluno-pa-widget__message--bottom-reserve"), f?.classList.add("pluno-pa-widget__bottom-reserve-compact"), t.scrollTop = t.scrollHeight;
|
|
1063
1067
|
}
|
|
1064
|
-
function Fe(t, e, n, o, a,
|
|
1068
|
+
function Fe(t, e, n, o, a, i) {
|
|
1065
1069
|
t.replaceChildren(), tt(e, !1), e.disabled = !0, n.hidden = !0;
|
|
1066
1070
|
const l = document.createElement("div");
|
|
1067
1071
|
l.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1072
|
+
const s = document.createElement("img");
|
|
1073
|
+
s.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", s.src = o(), s.alt = "", s.setAttribute("aria-hidden", "true"), l.appendChild(s);
|
|
1070
1074
|
const u = document.createElement("div");
|
|
1071
1075
|
u.className = "pluno-pa-widget__empty", u.textContent = "Log in to use Pluno on this page.", l.appendChild(u);
|
|
1072
1076
|
const h = document.createElement("button");
|
|
1073
|
-
h.type = "button", h.className = "pluno-pa-widget__login", h.textContent = a, h.addEventListener("click", () =>
|
|
1077
|
+
h.type = "button", h.className = "pluno-pa-widget__login", h.textContent = a, h.addEventListener("click", () => i?.()), l.appendChild(h), t.appendChild(l);
|
|
1074
1078
|
}
|
|
1075
1079
|
function xn(t) {
|
|
1076
1080
|
const e = document.createElement("div");
|
|
@@ -1091,25 +1095,25 @@ function Be(t) {
|
|
|
1091
1095
|
function yn(t, e, n, o) {
|
|
1092
1096
|
const a = document.createElement("article");
|
|
1093
1097
|
a.className = "pluno-pa-widget__tool-group", a.title = new Date(t[t.length - 1].createdAt).toLocaleString();
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
const l = document.createElement("details"),
|
|
1097
|
-
l.open = e.has(
|
|
1098
|
-
l.open ? e.add(
|
|
1098
|
+
const i = document.createElement("img");
|
|
1099
|
+
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);
|
|
1100
|
+
const l = document.createElement("details"), s = Cn(t);
|
|
1101
|
+
l.open = e.has(s), l.addEventListener("toggle", () => {
|
|
1102
|
+
l.open ? e.add(s) : e.delete(s), n();
|
|
1099
1103
|
});
|
|
1100
1104
|
const u = document.createElement("summary");
|
|
1101
|
-
u.className = "pluno-pa-widget__tool-summary", t.some((
|
|
1105
|
+
u.className = "pluno-pa-widget__tool-summary", t.some((f) => f.loading) && u.appendChild($e());
|
|
1102
1106
|
const c = document.createElement("span");
|
|
1103
1107
|
if (c.className = "pluno-pa-widget__tool-summary-title", c.textContent = t[t.length - 1].content || "Run tool", u.appendChild(c), l.appendChild(u), t.length > 0) {
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1108
|
+
const f = document.createElement("div");
|
|
1109
|
+
f.className = "pluno-pa-widget__tool-lines";
|
|
1106
1110
|
for (const y of t) {
|
|
1107
1111
|
const k = document.createElement("div");
|
|
1108
1112
|
k.className = "pluno-pa-widget__tool-line", y.loading && k.appendChild($e());
|
|
1109
1113
|
const v = document.createElement("span");
|
|
1110
|
-
v.textContent = y.content || "Run tool", k.appendChild(v),
|
|
1114
|
+
v.textContent = y.content || "Run tool", k.appendChild(v), f.appendChild(k);
|
|
1111
1115
|
}
|
|
1112
|
-
l.appendChild(
|
|
1116
|
+
l.appendChild(f);
|
|
1113
1117
|
}
|
|
1114
1118
|
return a.appendChild(l), a;
|
|
1115
1119
|
}
|
|
@@ -1157,9 +1161,9 @@ function ze(t, e) {
|
|
|
1157
1161
|
for (o += 1; o < n.length && !/^```\s*$/.test(n[o]); )
|
|
1158
1162
|
h.push(n[o]), o += 1;
|
|
1159
1163
|
o += o < n.length ? 1 : 0;
|
|
1160
|
-
const c = document.createElement("pre"),
|
|
1161
|
-
|
|
1162
|
-
`), c.appendChild(
|
|
1164
|
+
const c = document.createElement("pre"), f = document.createElement("code");
|
|
1165
|
+
f.textContent = h.join(`
|
|
1166
|
+
`), c.appendChild(f), t.appendChild(c);
|
|
1163
1167
|
continue;
|
|
1164
1168
|
}
|
|
1165
1169
|
const l = a.match(/^(#{1,3})\s+(.+)$/);
|
|
@@ -1186,11 +1190,11 @@ function ze(t, e) {
|
|
|
1186
1190
|
t.appendChild(h);
|
|
1187
1191
|
continue;
|
|
1188
1192
|
}
|
|
1189
|
-
const
|
|
1193
|
+
const s = [a];
|
|
1190
1194
|
for (o += 1; o < n.length && n[o].trim() && !/^```/.test(n[o]) && !/^(#{1,3})\s+/.test(n[o]) && !/^\s*[-*+]\s+/.test(n[o]) && !/^\s*\d+\.\s+/.test(n[o]); )
|
|
1191
|
-
|
|
1195
|
+
s.push(n[o]), o += 1;
|
|
1192
1196
|
const u = document.createElement("p");
|
|
1193
|
-
|
|
1197
|
+
s.forEach((h, c) => {
|
|
1194
1198
|
c > 0 && u.appendChild(document.createElement("br")), J(u, h);
|
|
1195
1199
|
}), t.appendChild(u);
|
|
1196
1200
|
}
|
|
@@ -1199,27 +1203,27 @@ function J(t, e) {
|
|
|
1199
1203
|
const n = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
|
|
1200
1204
|
let o = 0;
|
|
1201
1205
|
for (const a of e.matchAll(n)) {
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1206
|
+
const i = a.index ?? 0;
|
|
1207
|
+
i > o && t.appendChild(document.createTextNode(e.slice(o, i)));
|
|
1204
1208
|
const l = a[0];
|
|
1205
1209
|
if (l.startsWith("`")) {
|
|
1206
|
-
const
|
|
1207
|
-
|
|
1210
|
+
const s = document.createElement("code");
|
|
1211
|
+
s.textContent = l.slice(1, -1), t.appendChild(s);
|
|
1208
1212
|
} else if (l.startsWith("**")) {
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1213
|
+
const s = document.createElement("strong");
|
|
1214
|
+
s.textContent = l.slice(2, -2), t.appendChild(s);
|
|
1211
1215
|
} else if (l.startsWith("*")) {
|
|
1212
|
-
const
|
|
1213
|
-
|
|
1216
|
+
const s = document.createElement("em");
|
|
1217
|
+
s.textContent = l.slice(1, -1), t.appendChild(s);
|
|
1214
1218
|
} else {
|
|
1215
|
-
const
|
|
1216
|
-
if (
|
|
1219
|
+
const s = l.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
|
|
1220
|
+
if (s && En(s[2])) {
|
|
1217
1221
|
const u = document.createElement("a");
|
|
1218
|
-
u.href =
|
|
1222
|
+
u.href = s[2], u.target = "_top", u.rel = "noreferrer", u.textContent = s[1], t.appendChild(u);
|
|
1219
1223
|
} else
|
|
1220
1224
|
t.appendChild(document.createTextNode(l));
|
|
1221
1225
|
}
|
|
1222
|
-
o =
|
|
1226
|
+
o = i + l.length;
|
|
1223
1227
|
}
|
|
1224
1228
|
o < e.length && t.appendChild(document.createTextNode(e.slice(o)));
|
|
1225
1229
|
}
|
|
@@ -2023,20 +2027,30 @@ function We(t, e) {
|
|
|
2023
2027
|
color: var(--pluno-pa-faint);
|
|
2024
2028
|
cursor: not-allowed;
|
|
2025
2029
|
}
|
|
2026
|
-
.pluno-pa-
|
|
2027
|
-
display:
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
+
.pluno-pa-widget__composer-meta {
|
|
2031
|
+
display: flex;
|
|
2032
|
+
align-items: center;
|
|
2033
|
+
justify-content: space-between;
|
|
2034
|
+
gap: 10px;
|
|
2035
|
+
margin-top: 8px;
|
|
2030
2036
|
color: var(--pluno-pa-faint);
|
|
2031
2037
|
font: inherit;
|
|
2032
2038
|
font-size: 11px;
|
|
2033
2039
|
line-height: 1.2;
|
|
2040
|
+
}
|
|
2041
|
+
.pluno-pa-widget__powered-by {
|
|
2042
|
+
color: inherit;
|
|
2034
2043
|
text-decoration: none;
|
|
2035
2044
|
transition: color 120ms ease;
|
|
2036
2045
|
}
|
|
2037
2046
|
.pluno-pa-widget__powered-by:hover {
|
|
2038
2047
|
color: var(--pluno-pa-muted);
|
|
2039
2048
|
}
|
|
2049
|
+
.pluno-pa-widget__ai-disclaimer {
|
|
2050
|
+
color: inherit;
|
|
2051
|
+
text-align: right;
|
|
2052
|
+
white-space: nowrap;
|
|
2053
|
+
}
|
|
2040
2054
|
.pluno-pa-widget__empty,
|
|
2041
2055
|
.pluno-pa-widget__status,
|
|
2042
2056
|
.pluno-pa-widget__error {
|
|
@@ -2543,8 +2557,8 @@ class I extends EventTarget {
|
|
|
2543
2557
|
), this.cleanup());
|
|
2544
2558
|
}
|
|
2545
2559
|
addPreviewListener(e, n) {
|
|
2546
|
-
const o = Q(e, this.channelId), a = (
|
|
2547
|
-
|
|
2560
|
+
const o = Q(e, this.channelId), a = (i) => {
|
|
2561
|
+
i.detail?.socketId === this.socketId && n(i);
|
|
2548
2562
|
};
|
|
2549
2563
|
this.listeners.set(o, a), window.addEventListener(o, a);
|
|
2550
2564
|
}
|
package/package.json
CHANGED