@pluno/product-agent-web 0.1.16 → 0.1.17
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 +613 -389
- package/dist/widget.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PlunoProductAgent as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const e =
|
|
1
|
+
import { PlunoProductAgent as He } from "./product-agent-sdk.js";
|
|
2
|
+
const Ue = "#7c3aed";
|
|
3
|
+
function We(t) {
|
|
4
|
+
const e = Ye(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">
|
|
@@ -75,23 +75,23 @@ function ke(t) {
|
|
|
75
75
|
</g>
|
|
76
76
|
</svg>`;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return `data:image/svg+xml,${encodeURIComponent(
|
|
78
|
+
function Ve(t) {
|
|
79
|
+
return `data:image/svg+xml,${encodeURIComponent(We(t))}`;
|
|
80
80
|
}
|
|
81
|
-
const
|
|
82
|
-
function
|
|
83
|
-
const e =
|
|
84
|
-
if (
|
|
81
|
+
const M = "#2c2a1e", ue = [253, 250, 241], ge = 3.5;
|
|
82
|
+
function Oe(t) {
|
|
83
|
+
const e = Re(t);
|
|
84
|
+
if (he(G(e), ue) >= ge)
|
|
85
85
|
return e;
|
|
86
|
-
let o =
|
|
87
|
-
const a = M
|
|
88
|
-
for (let
|
|
89
|
-
if (o =
|
|
90
|
-
return
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
function
|
|
94
|
-
const e =
|
|
86
|
+
let o = G(e);
|
|
87
|
+
const a = G(M);
|
|
88
|
+
for (let i = 0; i < 6; i += 1)
|
|
89
|
+
if (o = Xe(o, a, 0.22), he(o, ue) >= ge)
|
|
90
|
+
return ee(o);
|
|
91
|
+
return ee(o);
|
|
92
|
+
}
|
|
93
|
+
function Ke(t) {
|
|
94
|
+
const e = Oe(t), n = "M547 151 C516 151 493 169 485 199 L382 606 C373 641 396 666 431 666 L523 666 C552 666 568 684 563 713 L491 1028 C486 1054 510 1067 527 1044 L894 487 C915 455 894 432 856 432 L815 432 C784 432 773 411 789 382 L904 205 C922 171 901 145 859 145 Z";
|
|
95
95
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1254 1254" role="img" aria-label="Pluno">
|
|
96
96
|
<defs>
|
|
97
97
|
<clipPath id="scribbleBoltClip">
|
|
@@ -104,35 +104,35 @@ function Se(t) {
|
|
|
104
104
|
</defs>
|
|
105
105
|
<g filter="url(#scribbleBoltWobble)">
|
|
106
106
|
<g clip-path="url(#scribbleBoltClip)">
|
|
107
|
-
<path d="${
|
|
107
|
+
<path d="${qe()}" 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
|
-
<path d="${n}" fill="none" stroke="${
|
|
109
|
+
<path d="${n}" fill="none" stroke="${M}" stroke-width="18" stroke-linejoin="round"/>
|
|
110
110
|
<g transform="rotate(-2 528 463)">
|
|
111
|
-
<ellipse cx="528" cy="463" rx="73" ry="80" fill="#ffffff" stroke="${
|
|
112
|
-
<ellipse cx="533" cy="473" rx="45" ry="53" fill="${
|
|
111
|
+
<ellipse cx="528" cy="463" rx="73" ry="80" fill="#ffffff" stroke="${M}" stroke-width="13"/>
|
|
112
|
+
<ellipse cx="533" cy="473" rx="45" ry="53" fill="${M}"/>
|
|
113
113
|
<circle cx="557" cy="447" r="16" fill="#ffffff"/>
|
|
114
114
|
</g>
|
|
115
115
|
<g transform="rotate(2 717 462)">
|
|
116
|
-
<ellipse cx="717" cy="462" rx="73" ry="80" fill="#ffffff" stroke="${
|
|
117
|
-
<ellipse cx="712" cy="473" rx="45" ry="53" fill="${
|
|
116
|
+
<ellipse cx="717" cy="462" rx="73" ry="80" fill="#ffffff" stroke="${M}" stroke-width="13"/>
|
|
117
|
+
<ellipse cx="712" cy="473" rx="45" ry="53" fill="${M}"/>
|
|
118
118
|
<circle cx="728" cy="447" r="16" fill="#ffffff"/>
|
|
119
119
|
</g>
|
|
120
120
|
</g>
|
|
121
121
|
</svg>`;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
return `data:image/svg+xml,${encodeURIComponent(
|
|
123
|
+
function je(t) {
|
|
124
|
+
return `data:image/svg+xml,${encodeURIComponent(Ke(t))}`;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function qe() {
|
|
127
127
|
let n = "M 280 120", o = !1, a = 0;
|
|
128
|
-
for (let
|
|
129
|
-
const
|
|
130
|
-
n += ` L ${
|
|
128
|
+
for (let i = 150; i <= 1170; i += 62) {
|
|
129
|
+
const p = (a % 3 - 1) * 18, c = o ? 280 - p : 1020 + p;
|
|
130
|
+
n += ` L ${c} ${i}`, o = !o, a += 1;
|
|
131
131
|
}
|
|
132
132
|
return n;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
const e =
|
|
134
|
+
function Ye(t) {
|
|
135
|
+
const e = Re(t), n = te(G(e));
|
|
136
136
|
return n > 0.86 ? {
|
|
137
137
|
top: "#ffffff",
|
|
138
138
|
middle: "#f6f6f6",
|
|
@@ -156,99 +156,101 @@ function Te(t) {
|
|
|
156
156
|
inner: "#4b4b4b",
|
|
157
157
|
shadow: "#000000"
|
|
158
158
|
} : {
|
|
159
|
-
top:
|
|
160
|
-
middle:
|
|
161
|
-
bottom:
|
|
162
|
-
edgeStart:
|
|
163
|
-
edgeMiddle:
|
|
164
|
-
edgeEnd:
|
|
165
|
-
glow:
|
|
166
|
-
highlight:
|
|
167
|
-
inner:
|
|
168
|
-
shadow:
|
|
159
|
+
top: C(e, 0.28, -0.03),
|
|
160
|
+
middle: C(e, 0.08, 0.04),
|
|
161
|
+
bottom: C(e, -0.1, 0.02),
|
|
162
|
+
edgeStart: C(e, 0.08, 0.08),
|
|
163
|
+
edgeMiddle: C(e, -0.08, 0.08),
|
|
164
|
+
edgeEnd: C(e, -0.18, 0.05),
|
|
165
|
+
glow: C(e, 0.32, -0.12),
|
|
166
|
+
highlight: C(e, 0.38, -0.18),
|
|
167
|
+
inner: C(e, 0.24, -0.1),
|
|
168
|
+
shadow: C(e, -0.25, -0.08)
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function Re(t) {
|
|
172
172
|
const e = t.trim();
|
|
173
|
-
return /^#[0-9a-f]{6}$/i.test(e) ? e.toLowerCase() : /^#[0-9a-f]{3}$/i.test(e) ? `#${e.slice(1).split("").map((n) => n + n).join("").toLowerCase()}` :
|
|
173
|
+
return /^#[0-9a-f]{6}$/i.test(e) ? e.toLowerCase() : /^#[0-9a-f]{3}$/i.test(e) ? `#${e.slice(1).split("").map((n) => n + n).join("").toLowerCase()}` : Ue;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function G(t) {
|
|
176
176
|
return [
|
|
177
177
|
Number.parseInt(t.slice(1, 3), 16),
|
|
178
178
|
Number.parseInt(t.slice(3, 5), 16),
|
|
179
179
|
Number.parseInt(t.slice(5, 7), 16)
|
|
180
180
|
];
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function ee([t, e, n]) {
|
|
183
183
|
const o = (a) => Math.max(0, Math.min(255, Math.round(a))).toString(16).padStart(2, "0");
|
|
184
184
|
return `#${o(t)}${o(e)}${o(n)}`;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function te([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
|
-
function
|
|
194
|
-
const n =
|
|
195
|
-
return (a + 0.05) / (
|
|
193
|
+
function he(t, e) {
|
|
194
|
+
const n = te(t), o = te(e), [a, i] = n > o ? [n, o] : [o, n];
|
|
195
|
+
return (a + 0.05) / (i + 0.05);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
const o =
|
|
197
|
+
function Xe(t, e, n) {
|
|
198
|
+
const o = ne(n);
|
|
199
199
|
return [
|
|
200
200
|
t[0] + (e[0] - t[0]) * o,
|
|
201
201
|
t[1] + (e[1] - t[1]) * o,
|
|
202
202
|
t[2] + (e[2] - t[2]) * o
|
|
203
203
|
];
|
|
204
204
|
}
|
|
205
|
-
function
|
|
206
|
-
const [o, a,
|
|
207
|
-
return
|
|
205
|
+
function C(t, e, n) {
|
|
206
|
+
const [o, a, i] = Ze(G(t));
|
|
207
|
+
return ee(Je(o, ne(a + n), ne(i + e)));
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
const o = t / 255, a = e / 255,
|
|
211
|
-
if (
|
|
212
|
-
return [0, 0,
|
|
213
|
-
const
|
|
214
|
-
return [(
|
|
209
|
+
function Ze([t, e, n]) {
|
|
210
|
+
const o = t / 255, a = e / 255, i = n / 255, p = Math.max(o, a, i), c = Math.min(o, a, i), d = (p + c) / 2;
|
|
211
|
+
if (p === c)
|
|
212
|
+
return [0, 0, d];
|
|
213
|
+
const h = p - c, s = d > 0.5 ? h / (2 - p - c) : h / (p + c);
|
|
214
|
+
return [(p === o ? (a - i) / h + (a < i ? 6 : 0) : p === a ? (i - o) / h + 2 : (o - a) / h + 4) / 6, s, d];
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function Je(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
|
+
Z(a, o, t + 1 / 3) * 255,
|
|
222
|
+
Z(a, o, t) * 255,
|
|
223
|
+
Z(a, o, t - 1 / 3) * 255
|
|
224
224
|
];
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function Z(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
|
}
|
|
230
|
-
function
|
|
230
|
+
function ne(t) {
|
|
231
231
|
return Math.max(0, Math.min(1, t));
|
|
232
232
|
}
|
|
233
|
-
const
|
|
233
|
+
const Qe = "product-agent:sdk-preview-socket-connect", et = "product-agent:sdk-preview-socket-send", tt = "product-agent:sdk-preview-socket-close", nt = "product-agent:sdk-preview-socket-open", ot = "product-agent:sdk-preview-socket-message", at = "product-agent:sdk-preview-socket-error", it = "product-agent:sdk-preview-socket-closed", fe = "product-agent:sdk-preview-socket-id", rt = "product-agent:preview-diagnostic", A = {
|
|
234
234
|
launcherLabel: "Ask for anything...",
|
|
235
235
|
accentColor: "#7c3aed",
|
|
236
236
|
colorScheme: "light",
|
|
237
237
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", sans-serif',
|
|
238
238
|
scribbleStyle: !1,
|
|
239
|
-
position: "bottom-right"
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
position: "bottom-right",
|
|
240
|
+
movableLauncher: !1
|
|
241
|
+
}, be = '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>', lt = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', we = "pluno-pa-scribble-font", De = 190, Fe = 41, pt = 48, st = 420, ct = 680, k = 8, me = 50, dt = 11, ut = 13, gt = 4, ht = 10, ft = 40, bt = "movable-launcher-position-v2";
|
|
242
|
+
function wt(t) {
|
|
243
|
+
return (e) => new L(e, t);
|
|
243
244
|
}
|
|
244
|
-
async function
|
|
245
|
+
async function mt(t = {}) {
|
|
245
246
|
const e = {
|
|
246
|
-
launcherLabel: t.launcherLabel ??
|
|
247
|
-
accentColor: t.accentColor ??
|
|
248
|
-
colorScheme: t.colorScheme ??
|
|
249
|
-
fontFamily: t.fontFamily ??
|
|
250
|
-
scribbleStyle: t.scribbleStyle ??
|
|
251
|
-
position: t.position ??
|
|
247
|
+
launcherLabel: t.launcherLabel ?? A.launcherLabel,
|
|
248
|
+
accentColor: t.accentColor ?? A.accentColor,
|
|
249
|
+
colorScheme: t.colorScheme ?? A.colorScheme,
|
|
250
|
+
fontFamily: t.fontFamily ?? A.fontFamily,
|
|
251
|
+
scribbleStyle: t.scribbleStyle ?? A.scribbleStyle,
|
|
252
|
+
position: t.position ?? A.position,
|
|
253
|
+
movableLauncher: t.movableLauncher ?? A.movableLauncher,
|
|
252
254
|
token: t.token,
|
|
253
255
|
tokenProvider: t.tokenProvider,
|
|
254
256
|
tokenEndpoint: t.tokenEndpoint,
|
|
@@ -257,7 +259,7 @@ async function Ue(t = {}) {
|
|
|
257
259
|
initialStarterPrompts: t.initialStarterPrompts,
|
|
258
260
|
webSocketFactory: t.webSocketFactory
|
|
259
261
|
};
|
|
260
|
-
|
|
262
|
+
O("web-sdk.widget", "Mounting widget with merged options", {
|
|
261
263
|
accentColor: e.accentColor,
|
|
262
264
|
colorScheme: e.colorScheme,
|
|
263
265
|
fontFamily: e.fontFamily,
|
|
@@ -272,7 +274,7 @@ async function Ue(t = {}) {
|
|
|
272
274
|
n.className = "pluno-pa-widget-host";
|
|
273
275
|
const o = n.attachShadow({ mode: "open" }), a = document.createElement("div");
|
|
274
276
|
a.className = `pluno-pa-widget pluno-pa-widget--${e.position}`;
|
|
275
|
-
let
|
|
277
|
+
let i = _e(e.accentColor, e.scribbleStyle);
|
|
276
278
|
a.innerHTML = `
|
|
277
279
|
<svg class="pluno-pa-widget__scribble-defs" aria-hidden="true" focusable="false" width="0" height="0">
|
|
278
280
|
<defs>
|
|
@@ -297,8 +299,9 @@ async function Ue(t = {}) {
|
|
|
297
299
|
</defs>
|
|
298
300
|
</svg>
|
|
299
301
|
<form class="pluno-pa-widget__launcher">
|
|
300
|
-
<
|
|
301
|
-
<
|
|
302
|
+
${e.movableLauncher ? '<button type="button" class="pluno-pa-widget__launcher-drag-handle" aria-label="Move Product Agent launcher" title="Move Product Agent launcher"></button>' : ""}
|
|
303
|
+
<img class="pluno-pa-widget__character pluno-pa-widget__character--launcher" src="${W(i)}" alt="" aria-hidden="true" />
|
|
304
|
+
<input class="pluno-pa-widget__launcher-input" type="text" placeholder="${W(e.launcherLabel)}" aria-label="${W(e.launcherLabel)}" />
|
|
302
305
|
</form>
|
|
303
306
|
<button type="button" class="pluno-pa-widget__close" aria-label="Close" hidden>
|
|
304
307
|
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
@@ -309,7 +312,7 @@ async function Ue(t = {}) {
|
|
|
309
312
|
<div class="pluno-pa-widget__timeline-wrap">
|
|
310
313
|
<main class="pluno-pa-widget__timeline">
|
|
311
314
|
<div class="pluno-pa-widget__empty-state">
|
|
312
|
-
<img class="pluno-pa-widget__character pluno-pa-widget__character--empty" src="${
|
|
315
|
+
<img class="pluno-pa-widget__character pluno-pa-widget__character--empty" src="${W(i)}" alt="" aria-hidden="true" />
|
|
313
316
|
<div class="pluno-pa-widget__empty">Hey there, I'm Pluno 👋<br />What do you want to do today?</div>
|
|
314
317
|
</div>
|
|
315
318
|
</main>
|
|
@@ -334,166 +337,237 @@ async function Ue(t = {}) {
|
|
|
334
337
|
</form>
|
|
335
338
|
</section>
|
|
336
339
|
`, o.appendChild(a);
|
|
337
|
-
const
|
|
338
|
-
|
|
340
|
+
const p = await Nt(), c = p.ownerDocument;
|
|
341
|
+
p.appendChild(n), a.classList.add(`pluno-pa-widget--${e.colorScheme}`), Ne(o, e.accentColor), xe(a, i, {
|
|
339
342
|
accentColor: e.accentColor,
|
|
340
343
|
colorScheme: e.colorScheme,
|
|
341
344
|
fontFamily: e.fontFamily,
|
|
342
345
|
scribbleStyle: e.scribbleStyle
|
|
343
|
-
}),
|
|
346
|
+
}), O("web-sdk.widget", "Applied initial widget appearance", {
|
|
344
347
|
accentColor: e.accentColor,
|
|
345
348
|
colorScheme: e.colorScheme,
|
|
346
349
|
fontFamily: e.fontFamily,
|
|
347
350
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
348
351
|
});
|
|
349
|
-
const
|
|
350
|
-
if (!
|
|
352
|
+
const d = a.querySelector(".pluno-pa-widget__launcher"), h = a.querySelector(".pluno-pa-widget__launcher-drag-handle"), s = a.querySelector(".pluno-pa-widget__launcher-input"), b = a.querySelector(".pluno-pa-widget__panel"), x = a.querySelector(".pluno-pa-widget__close"), v = a.querySelector(".pluno-pa-widget__composer"), u = a.querySelector(".pluno-pa-widget__input"), l = a.querySelector(".pluno-pa-widget__send"), g = a.querySelector(".pluno-pa-widget__new-chat"), f = a.querySelector(".pluno-pa-widget__timeline");
|
|
353
|
+
if (!d || !s || !b || !x || !v || !u || !l || !g || !f)
|
|
351
354
|
throw new Error("Failed to mount Product Agent widget");
|
|
352
|
-
|
|
353
|
-
|
|
355
|
+
if (e.movableLauncher && !h)
|
|
356
|
+
throw new Error("Failed to mount Product Agent widget drag handle");
|
|
357
|
+
Ee(s), Ee(u);
|
|
358
|
+
const _ = e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (async () => {
|
|
354
359
|
if (!e.tokenEndpoint)
|
|
355
360
|
throw new Error("Product Agent widget requires token or tokenEndpoint");
|
|
356
|
-
const
|
|
361
|
+
const r = await fetch(e.tokenEndpoint, {
|
|
357
362
|
method: "POST",
|
|
358
363
|
credentials: "include",
|
|
359
364
|
headers: { "content-type": "application/json" },
|
|
360
365
|
body: JSON.stringify({ origin: location.origin, url: location.href })
|
|
361
366
|
});
|
|
362
|
-
if (!
|
|
367
|
+
if (!r.ok)
|
|
363
368
|
throw new Error("Failed to load Product Agent token");
|
|
364
|
-
const
|
|
365
|
-
if (!
|
|
369
|
+
const w = await r.json();
|
|
370
|
+
if (!w.token)
|
|
366
371
|
throw new Error("Product Agent token endpoint did not return a token");
|
|
367
|
-
return
|
|
372
|
+
return w.token;
|
|
368
373
|
});
|
|
369
|
-
let
|
|
370
|
-
|
|
374
|
+
let m;
|
|
375
|
+
m = await He.init({
|
|
371
376
|
token: e.token,
|
|
372
|
-
tokenProvider:
|
|
377
|
+
tokenProvider: _,
|
|
373
378
|
backendUrl: e.backendUrl,
|
|
374
379
|
metadata: () => ({
|
|
375
380
|
...e.metadata ?? {},
|
|
376
|
-
...!
|
|
381
|
+
...!m.getState().sessionId && e.scribbleStyle ? { scribbleStyleStarted: !0 } : {}
|
|
377
382
|
}),
|
|
378
383
|
initialStarterPrompts: e.initialStarterPrompts,
|
|
379
384
|
webSocketFactory: e.webSocketFactory
|
|
380
385
|
});
|
|
381
|
-
const
|
|
382
|
-
let
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
|
|
386
|
+
const y = It(e), B = new Set(y.openToolGroupKeys);
|
|
387
|
+
let E = e.movableLauncher ? y.launcherPosition : null, ae = E !== null, P = null, ie = !1;
|
|
388
|
+
const Be = () => {
|
|
389
|
+
ie || typeof document > "u" || (Ne(o, e.accentColor), n.isConnected || c.body?.appendChild(n));
|
|
390
|
+
}, re = new MutationObserver(Be);
|
|
391
|
+
re.observe(c.documentElement, { childList: !0, subtree: !0 });
|
|
392
|
+
const j = (r = !0) => {
|
|
393
|
+
const w = ye(a, r);
|
|
394
|
+
return ve(
|
|
395
|
+
a,
|
|
396
|
+
E ?? vt(a, e.position, w),
|
|
397
|
+
w
|
|
398
|
+
);
|
|
399
|
+
}, S = () => {
|
|
400
|
+
Mt(e, {
|
|
389
401
|
isOpen: a.classList.contains("pluno-pa-widget--open"),
|
|
390
|
-
composerValue:
|
|
391
|
-
openToolGroupKeys: [...
|
|
402
|
+
composerValue: u.value,
|
|
403
|
+
openToolGroupKeys: [...B],
|
|
404
|
+
launcherPosition: ae ? E : null
|
|
405
|
+
});
|
|
406
|
+
}, N = (r, w = {}) => {
|
|
407
|
+
Et(r, {
|
|
408
|
+
debugVersion: bt,
|
|
409
|
+
launcherPosition: E,
|
|
410
|
+
rootClasses: a.className,
|
|
411
|
+
rootStyle: {
|
|
412
|
+
left: a.style.left,
|
|
413
|
+
top: a.style.top,
|
|
414
|
+
right: a.style.right,
|
|
415
|
+
bottom: a.style.bottom
|
|
416
|
+
},
|
|
417
|
+
rootRect: J(a),
|
|
418
|
+
launcherRect: J(d),
|
|
419
|
+
panelRect: J(b),
|
|
420
|
+
viewport: R(),
|
|
421
|
+
panelHidden: b.hidden,
|
|
422
|
+
closeHidden: x.hidden,
|
|
423
|
+
...w
|
|
392
424
|
});
|
|
393
|
-
},
|
|
394
|
-
if (
|
|
395
|
-
|
|
425
|
+
}, z = (r = !0) => {
|
|
426
|
+
if (!E)
|
|
427
|
+
return H(a, null), j(r);
|
|
428
|
+
const w = j(r);
|
|
429
|
+
return H(a, w), N("Applied stored closed launcher position", { visibleLauncherPosition: w }), w;
|
|
430
|
+
}, le = (r, w) => {
|
|
431
|
+
if (!r || !w) {
|
|
432
|
+
Ce(a);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
Ct(a, {
|
|
436
|
+
x: r.x - w.x,
|
|
437
|
+
y: r.y - w.y
|
|
438
|
+
});
|
|
439
|
+
}, pe = () => {
|
|
440
|
+
const r = z();
|
|
441
|
+
if (a.classList.contains("pluno-pa-widget--open") || a.classList.contains("pluno-pa-widget--closing")) {
|
|
442
|
+
const w = ke(r);
|
|
443
|
+
le(w, r), N("Applied open panel position after viewport resize", { openPanelPosition: w });
|
|
444
|
+
} else E && N("Applied visible launcher position after viewport resize", { visibleLauncherPosition: r });
|
|
445
|
+
};
|
|
446
|
+
let se = () => {
|
|
447
|
+
};
|
|
448
|
+
e.movableLauncher && h ? (z(), window.addEventListener("resize", pe), se = xt({
|
|
449
|
+
root: a,
|
|
450
|
+
launcherDragHandle: h,
|
|
451
|
+
getPosition: () => j(),
|
|
452
|
+
setPosition: (r) => {
|
|
453
|
+
const w = r;
|
|
454
|
+
E = ve(a, r, ye(a)), H(a, E), N("Dragging closed launcher", { requestedPosition: w });
|
|
455
|
+
},
|
|
456
|
+
persist: () => {
|
|
457
|
+
ae = !0, S(), N("Persisted closed launcher drag position");
|
|
458
|
+
}
|
|
459
|
+
})) : H(a, null);
|
|
460
|
+
const D = (r = "", w = !0) => {
|
|
461
|
+
if (P !== null && (window.clearTimeout(P), P = null), b.hidden = !1, x.hidden = !1, a.classList.remove("pluno-pa-widget--closing"), e.movableLauncher) {
|
|
462
|
+
const T = z(), F = ke(T);
|
|
463
|
+
le(F, T), N("Opening launcher at clamped open panel position", { openPanelPosition: F, visibleLauncherPosition: T });
|
|
464
|
+
} else
|
|
465
|
+
Ce(a);
|
|
466
|
+
if (!w) {
|
|
467
|
+
a.classList.add("pluno-pa-widget--open"), d.hidden = !0, r && (u.value = r, $(u)), f.scrollTop = f.scrollHeight, u.focus(), u.setSelectionRange(u.value.length, u.value.length), S();
|
|
396
468
|
return;
|
|
397
469
|
}
|
|
398
470
|
window.requestAnimationFrame(() => {
|
|
399
|
-
a.classList.add("pluno-pa-widget--open"),
|
|
400
|
-
|
|
471
|
+
a.classList.add("pluno-pa-widget--open"), r && (u.value = r, $(u)), f.scrollTop = f.scrollHeight, u.focus(), u.setSelectionRange(u.value.length, u.value.length), S(), P = window.setTimeout(() => {
|
|
472
|
+
d.hidden = !0, f.scrollTop = f.scrollHeight;
|
|
401
473
|
}, 220);
|
|
402
474
|
});
|
|
403
|
-
},
|
|
404
|
-
|
|
405
|
-
|
|
475
|
+
}, ze = () => {
|
|
476
|
+
P !== null && (window.clearTimeout(P), P = null), d.hidden = !1, E && (z(!1), N("Closing launcher at stored position")), a.classList.remove("pluno-pa-widget--open"), a.classList.add("pluno-pa-widget--closing"), S(), P = window.setTimeout(() => {
|
|
477
|
+
b.hidden = !0, x.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
|
|
406
478
|
}, 220);
|
|
407
479
|
};
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}),
|
|
411
|
-
|
|
412
|
-
}),
|
|
413
|
-
|
|
414
|
-
}),
|
|
415
|
-
|
|
480
|
+
d.addEventListener("submit", (r) => {
|
|
481
|
+
r.preventDefault(), D(s.value), s.value = "";
|
|
482
|
+
}), h?.addEventListener("click", (r) => {
|
|
483
|
+
r.preventDefault(), r.stopPropagation();
|
|
484
|
+
}), d.addEventListener("click", (r) => {
|
|
485
|
+
r.target !== s && (D(s.value), s.value = "");
|
|
486
|
+
}), s.addEventListener("focus", () => {
|
|
487
|
+
D(s.value), s.value = "";
|
|
488
|
+
}), s.addEventListener("input", () => {
|
|
489
|
+
if (!s.value)
|
|
416
490
|
return;
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
}),
|
|
420
|
-
const
|
|
421
|
-
|
|
491
|
+
const r = s.value;
|
|
492
|
+
D(r), s.value = "";
|
|
493
|
+
}), x.addEventListener("click", ze);
|
|
494
|
+
const I = () => {
|
|
495
|
+
l.disabled = !m.getState().isThinking && u.value.trim().length === 0;
|
|
422
496
|
};
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}),
|
|
426
|
-
if (
|
|
427
|
-
|
|
497
|
+
v.addEventListener("submit", (r) => {
|
|
498
|
+
r.preventDefault(), Q(m, u), I();
|
|
499
|
+
}), l.addEventListener("click", () => {
|
|
500
|
+
if (m.getState().isThinking) {
|
|
501
|
+
m.stop();
|
|
428
502
|
return;
|
|
429
503
|
}
|
|
430
|
-
|
|
431
|
-
}),
|
|
432
|
-
|
|
433
|
-
}),
|
|
434
|
-
|
|
435
|
-
}),
|
|
436
|
-
|
|
437
|
-
}), a.addEventListener("click", (
|
|
438
|
-
(
|
|
439
|
-
}),
|
|
440
|
-
const
|
|
441
|
-
let
|
|
442
|
-
return
|
|
443
|
-
|
|
444
|
-
appearance:
|
|
445
|
-
}),
|
|
504
|
+
Q(m, u), I();
|
|
505
|
+
}), g.addEventListener("click", () => {
|
|
506
|
+
m.startNewSession(), B.clear(), u.value = "", $(u), S(), I(), u.focus();
|
|
507
|
+
}), u.addEventListener("input", () => {
|
|
508
|
+
$(u), S(), I();
|
|
509
|
+
}), u.addEventListener("keydown", (r) => {
|
|
510
|
+
r.key !== "Enter" || r.shiftKey || (r.preventDefault(), Q(m, u), I());
|
|
511
|
+
}), a.addEventListener("click", (r) => {
|
|
512
|
+
(r.target instanceof Element ? r.target : null)?.closest("a[href]") && S();
|
|
513
|
+
}), y.composerValue && (u.value = y.composerValue, $(u)), y.isOpen && D(u.value, !1);
|
|
514
|
+
const ce = () => i;
|
|
515
|
+
let q = m.getState().appearance !== null;
|
|
516
|
+
return m.on("state", (r) => {
|
|
517
|
+
r.appearance ? (q = !0, O("web-sdk.widget", "Agent state supplied appearance", {
|
|
518
|
+
appearance: r.appearance
|
|
519
|
+
}), Y(r.appearance, "agent.state.appearance")) : q && (q = !1, O("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
|
|
446
520
|
fallbackAccentColor: e.accentColor,
|
|
447
521
|
fallbackColorScheme: e.colorScheme,
|
|
448
522
|
fallbackFontFamily: e.fontFamily
|
|
449
|
-
}),
|
|
450
|
-
|
|
451
|
-
}),
|
|
452
|
-
}),
|
|
453
|
-
|
|
454
|
-
}),
|
|
455
|
-
agent:
|
|
456
|
-
updateAppearance: (
|
|
457
|
-
|
|
523
|
+
}), Y({}, "agent.state.appearance-cleared")), Se(f, l, g, r, B, S, ce, (w) => {
|
|
524
|
+
m.sendMessage(w);
|
|
525
|
+
}), I();
|
|
526
|
+
}), Se(f, l, g, m.getState(), B, S, ce, (r) => {
|
|
527
|
+
m.sendMessage(r);
|
|
528
|
+
}), I(), {
|
|
529
|
+
agent: m,
|
|
530
|
+
updateAppearance: (r) => {
|
|
531
|
+
r.scribbleStyle !== void 0 && (e.scribbleStyle = r.scribbleStyle), Y(r, "widgetHandle.updateAppearance");
|
|
458
532
|
},
|
|
459
533
|
destroy: () => {
|
|
460
|
-
|
|
534
|
+
ie = !0, re.disconnect(), e.movableLauncher && window.removeEventListener("resize", pe), se(), m.destroy(), n.remove();
|
|
461
535
|
}
|
|
462
536
|
};
|
|
463
|
-
function
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
accentColor:
|
|
467
|
-
colorScheme:
|
|
468
|
-
fontFamily:
|
|
469
|
-
scribbleStyle:
|
|
470
|
-
}),
|
|
471
|
-
source:
|
|
472
|
-
inputAppearance:
|
|
473
|
-
appliedAccentColor:
|
|
474
|
-
appliedColorScheme:
|
|
475
|
-
appliedFontFamily:
|
|
476
|
-
appliedScribbleStyle:
|
|
537
|
+
function Y(r, w) {
|
|
538
|
+
const T = r.accentColor ?? e.accentColor, F = r.colorScheme ?? e.colorScheme, de = r.fontFamily ?? e.fontFamily, X = r.scribbleStyle ?? e.scribbleStyle;
|
|
539
|
+
i = _e(T, X), xe(a, i, {
|
|
540
|
+
accentColor: T,
|
|
541
|
+
colorScheme: F,
|
|
542
|
+
fontFamily: de,
|
|
543
|
+
scribbleStyle: X
|
|
544
|
+
}), O("web-sdk.widget", "Updated widget appearance", {
|
|
545
|
+
source: w,
|
|
546
|
+
inputAppearance: r,
|
|
547
|
+
appliedAccentColor: T,
|
|
548
|
+
appliedColorScheme: F,
|
|
549
|
+
appliedFontFamily: de,
|
|
550
|
+
appliedScribbleStyle: X,
|
|
477
551
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
478
552
|
});
|
|
479
553
|
}
|
|
480
554
|
}
|
|
481
|
-
function
|
|
482
|
-
return e ?
|
|
555
|
+
function _e(t, e) {
|
|
556
|
+
return e ? je(t) : Ve(t);
|
|
483
557
|
}
|
|
484
|
-
function
|
|
558
|
+
function xe(t, e, n) {
|
|
485
559
|
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);
|
|
486
|
-
const o = n.scribbleStyle ?
|
|
487
|
-
t.style.setProperty("--pluno-pa-accent", o), t.style.fontFamily = n.scribbleStyle ?
|
|
560
|
+
const o = n.scribbleStyle ? Oe(n.accentColor) : n.accentColor;
|
|
561
|
+
t.style.setProperty("--pluno-pa-accent", o), t.style.fontFamily = n.scribbleStyle ? lt : n.fontFamily, n.scribbleStyle && _t(t.ownerDocument);
|
|
488
562
|
const a = Array.from(t.querySelectorAll(".pluno-pa-widget__character"));
|
|
489
|
-
for (const
|
|
490
|
-
|
|
563
|
+
for (const i of a)
|
|
564
|
+
i.src = e;
|
|
491
565
|
}
|
|
492
|
-
function
|
|
493
|
-
if (t.getElementById(
|
|
566
|
+
function _t(t) {
|
|
567
|
+
if (t.getElementById(we))
|
|
494
568
|
return;
|
|
495
569
|
const e = t.createElement("style");
|
|
496
|
-
e.id =
|
|
570
|
+
e.id = we, e.textContent = `@font-face {
|
|
497
571
|
font-family: "Architects Daughter";
|
|
498
572
|
font-style: normal;
|
|
499
573
|
font-weight: 400;
|
|
@@ -501,7 +575,119 @@ function He(t) {
|
|
|
501
575
|
src: url("https://fonts.gstatic.com/s/architectsdaughter/v20/KtkxAKiDZI_td1Lkx62xHZHDtgO_Y-bvTYlg4-7jA-U.woff2") format("woff2");
|
|
502
576
|
}`, t.head.appendChild(e), t.fonts?.load('16px "Architects Daughter"');
|
|
503
577
|
}
|
|
504
|
-
function
|
|
578
|
+
function xt({
|
|
579
|
+
root: t,
|
|
580
|
+
launcherDragHandle: e,
|
|
581
|
+
getPosition: n,
|
|
582
|
+
setPosition: o,
|
|
583
|
+
persist: a
|
|
584
|
+
}) {
|
|
585
|
+
let i = null, p = null, c = null, d = !1;
|
|
586
|
+
const h = () => {
|
|
587
|
+
i = null, p = null, c = null, d = !1, t.classList.remove("pluno-pa-widget--dragging");
|
|
588
|
+
}, s = (l) => {
|
|
589
|
+
t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing") || (l.preventDefault(), l.stopPropagation(), i = l.pointerId, p = { x: l.clientX, y: l.clientY }, c = n(), d = !1, e.setPointerCapture?.(l.pointerId));
|
|
590
|
+
}, b = (l) => {
|
|
591
|
+
if (i !== l.pointerId || !p || !c)
|
|
592
|
+
return;
|
|
593
|
+
l.preventDefault();
|
|
594
|
+
const g = l.clientX - p.x, f = l.clientY - p.y;
|
|
595
|
+
!d && Math.hypot(g, f) < gt || (d = !0, t.classList.add("pluno-pa-widget--dragging"), o({ x: c.x + g, y: c.y + f }));
|
|
596
|
+
}, x = (l) => {
|
|
597
|
+
i === l.pointerId && (l.preventDefault(), l.stopPropagation(), d && a(), h());
|
|
598
|
+
}, v = (l) => {
|
|
599
|
+
i === l.pointerId && (l.preventDefault(), h());
|
|
600
|
+
}, u = (l) => {
|
|
601
|
+
if (t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing"))
|
|
602
|
+
return;
|
|
603
|
+
const g = l.shiftKey ? ft : ht, f = n();
|
|
604
|
+
let _ = null;
|
|
605
|
+
l.key === "ArrowUp" ? _ = { x: f.x, y: f.y - g } : l.key === "ArrowDown" ? _ = { x: f.x, y: f.y + g } : l.key === "ArrowLeft" ? _ = { x: f.x - g, y: f.y } : l.key === "ArrowRight" && (_ = { x: f.x + g, y: f.y }), _ && (l.preventDefault(), l.stopPropagation(), o(_), a());
|
|
606
|
+
};
|
|
607
|
+
return e.addEventListener("pointerdown", s), e.addEventListener("pointermove", b), e.addEventListener("pointerup", x), e.addEventListener("pointercancel", v), e.addEventListener("keydown", u), () => {
|
|
608
|
+
e.removeEventListener("pointerdown", s), e.removeEventListener("pointermove", b), e.removeEventListener("pointerup", x), e.removeEventListener("pointercancel", v), e.removeEventListener("keydown", u);
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function ye(t, e = !0) {
|
|
612
|
+
const n = R(), o = t.getBoundingClientRect(), a = !t.classList.contains("pluno-pa-widget--open") && !t.classList.contains("pluno-pa-widget--closing");
|
|
613
|
+
return {
|
|
614
|
+
width: e && a && o.width > 0 ? o.width : Math.min(De, n.width - 36),
|
|
615
|
+
height: e && a && o.height > 0 ? o.height : t.classList.contains("pluno-pa-widget--scribble") ? pt : Fe
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
function yt() {
|
|
619
|
+
const t = R();
|
|
620
|
+
return {
|
|
621
|
+
width: Math.min(st, t.width - 28),
|
|
622
|
+
height: Math.min(ct, t.height - 28)
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function vt(t, e, n) {
|
|
626
|
+
const o = Number.parseFloat(t.style.left), a = Number.parseFloat(t.style.top);
|
|
627
|
+
if (Number.isFinite(o) && Number.isFinite(a))
|
|
628
|
+
return { x: o, y: a };
|
|
629
|
+
const i = t.getBoundingClientRect();
|
|
630
|
+
if (i.width > 0 || i.height > 0)
|
|
631
|
+
return { x: i.left, y: i.top };
|
|
632
|
+
const p = R();
|
|
633
|
+
return {
|
|
634
|
+
x: e === "bottom-left" ? 26 : p.width - 26 - n.width,
|
|
635
|
+
y: p.height - 24 - n.height
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function ve(t, e, n) {
|
|
639
|
+
const o = R(), a = k + kt(t);
|
|
640
|
+
return {
|
|
641
|
+
x: K(e.x, k, Math.max(k, o.width - n.width - k)),
|
|
642
|
+
y: K(e.y, a, Math.max(a, o.height - n.height - k))
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
function kt(t) {
|
|
646
|
+
return t.classList.contains("pluno-pa-widget--scribble") ? ut : dt;
|
|
647
|
+
}
|
|
648
|
+
function ke(t) {
|
|
649
|
+
const e = R(), n = yt();
|
|
650
|
+
return {
|
|
651
|
+
x: K(t.x, k, Math.max(k, e.width - n.width - k)),
|
|
652
|
+
y: K(
|
|
653
|
+
t.y,
|
|
654
|
+
me,
|
|
655
|
+
Math.max(me, e.height - n.height - k)
|
|
656
|
+
)
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
function H(t, e) {
|
|
660
|
+
if (t.classList.toggle("pluno-pa-widget--custom-position", e !== null), !e) {
|
|
661
|
+
t.style.removeProperty("left"), t.style.removeProperty("top"), t.style.removeProperty("right"), t.style.removeProperty("bottom");
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
t.style.left = `${e.x}px`, t.style.top = `${e.y}px`, t.style.right = "auto", t.style.bottom = "auto";
|
|
665
|
+
}
|
|
666
|
+
function Ct(t, e) {
|
|
667
|
+
t.style.setProperty("--pluno-pa-panel-offset-x", `${e.x}px`), t.style.setProperty("--pluno-pa-panel-offset-y", `${e.y}px`);
|
|
668
|
+
}
|
|
669
|
+
function Ce(t) {
|
|
670
|
+
t.style.removeProperty("--pluno-pa-panel-offset-x"), t.style.removeProperty("--pluno-pa-panel-offset-y");
|
|
671
|
+
}
|
|
672
|
+
function R() {
|
|
673
|
+
return {
|
|
674
|
+
width: window.innerWidth || document.documentElement.clientWidth || De + k * 2,
|
|
675
|
+
height: window.innerHeight || document.documentElement.clientHeight || Fe + k * 2
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
function J(t) {
|
|
679
|
+
const e = t.getBoundingClientRect();
|
|
680
|
+
return {
|
|
681
|
+
x: Math.round(e.x),
|
|
682
|
+
y: Math.round(e.y),
|
|
683
|
+
width: Math.round(e.width),
|
|
684
|
+
height: Math.round(e.height)
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
function K(t, e, n) {
|
|
688
|
+
return Math.min(Math.max(t, e), n);
|
|
689
|
+
}
|
|
690
|
+
function O(t, e, n) {
|
|
505
691
|
if (typeof window > "u")
|
|
506
692
|
return;
|
|
507
693
|
const o = window, a = {
|
|
@@ -509,137 +695,140 @@ function I(t, e, n) {
|
|
|
509
695
|
source: t,
|
|
510
696
|
message: e,
|
|
511
697
|
details: n
|
|
512
|
-
},
|
|
513
|
-
|
|
698
|
+
}, i = o.__plunoProductAgentDiagnostics__ ?? [];
|
|
699
|
+
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(rt, { detail: a }));
|
|
514
700
|
}
|
|
515
|
-
function
|
|
701
|
+
function Et(t, e) {
|
|
702
|
+
O("web-sdk.widget.position", t, e);
|
|
703
|
+
}
|
|
704
|
+
function Q(t, e) {
|
|
516
705
|
const n = e.value.trim();
|
|
517
706
|
n && (e.value = "", e.style.height = "22px", e.style.overflowY = "hidden", t.sendMessage(n), e.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
518
707
|
}
|
|
519
|
-
function
|
|
708
|
+
function $(t) {
|
|
520
709
|
t.style.height = "0px";
|
|
521
710
|
const e = Math.max(22, Math.min(t.scrollHeight, 140));
|
|
522
711
|
t.style.height = `${e}px`, t.style.overflowY = t.scrollHeight > 140 ? "auto" : "hidden";
|
|
523
712
|
}
|
|
524
|
-
function
|
|
713
|
+
function Ee(t) {
|
|
525
714
|
for (const e of ["keydown", "keypress", "keyup"])
|
|
526
715
|
t.addEventListener(e, (n) => {
|
|
527
716
|
n.stopPropagation();
|
|
528
717
|
});
|
|
529
718
|
}
|
|
530
|
-
function
|
|
531
|
-
const
|
|
532
|
-
t.innerHTML = "",
|
|
533
|
-
const
|
|
534
|
-
if (n.hidden = !
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
for (const
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}),
|
|
548
|
-
}
|
|
549
|
-
|
|
719
|
+
function Se(t, e, n, o, a, i, p, c) {
|
|
720
|
+
const d = [...o.messages];
|
|
721
|
+
t.innerHTML = "", Tt(e, o.isThinking);
|
|
722
|
+
const h = d.length > 0 || !!o.assistantDraft || o.isThinking;
|
|
723
|
+
if (n.hidden = !h, d.length === 0 && !o.assistantDraft && !o.lastError && !o.isThinking) {
|
|
724
|
+
const l = document.createElement("div");
|
|
725
|
+
l.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
726
|
+
const g = document.createElement("img");
|
|
727
|
+
g.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", g.src = p(), g.alt = "", g.setAttribute("aria-hidden", "true"), l.appendChild(g);
|
|
728
|
+
const f = document.createElement("div");
|
|
729
|
+
f.className = "pluno-pa-widget__empty", f.innerHTML = "Hey there, I'm Pluno 👋<br />What do you want to do today?", l.appendChild(f);
|
|
730
|
+
const _ = document.createElement("div");
|
|
731
|
+
_.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 && _.setAttribute("aria-hidden", "true");
|
|
732
|
+
for (const m of o.starterPrompts) {
|
|
733
|
+
const y = document.createElement("button");
|
|
734
|
+
y.type = "button", y.className = "pluno-pa-widget__starter-prompt", y.textContent = `"${m}"`, y.addEventListener("click", () => {
|
|
735
|
+
c(m);
|
|
736
|
+
}), _.appendChild(y);
|
|
737
|
+
}
|
|
738
|
+
l.appendChild(_), t.appendChild(l);
|
|
550
739
|
return;
|
|
551
740
|
}
|
|
552
|
-
let
|
|
553
|
-
const
|
|
741
|
+
let s = null, b = null, x = [];
|
|
742
|
+
const v = () => {
|
|
554
743
|
if (x.length === 0)
|
|
555
744
|
return !1;
|
|
556
|
-
const
|
|
557
|
-
return t.appendChild(
|
|
745
|
+
const l = St(x, a, i, p());
|
|
746
|
+
return t.appendChild(l), s = null, b = l, x = [], !0;
|
|
558
747
|
};
|
|
559
|
-
for (let
|
|
560
|
-
const
|
|
561
|
-
if (
|
|
562
|
-
x.push(
|
|
748
|
+
for (let l = 0; l < d.length; l += 1) {
|
|
749
|
+
const g = d[l];
|
|
750
|
+
if (g.role === "tool") {
|
|
751
|
+
x.push(g);
|
|
563
752
|
continue;
|
|
564
753
|
}
|
|
565
|
-
if (
|
|
754
|
+
if (g.role === "system")
|
|
566
755
|
continue;
|
|
567
|
-
const
|
|
568
|
-
if (
|
|
569
|
-
const
|
|
570
|
-
t.appendChild(
|
|
756
|
+
const f = v(), _ = Pe(g.content);
|
|
757
|
+
if (g.role === "assistant" && !f) {
|
|
758
|
+
const y = oe(p());
|
|
759
|
+
t.appendChild(y), s = null, b = y;
|
|
571
760
|
}
|
|
572
|
-
const
|
|
573
|
-
|
|
761
|
+
const m = document.createElement("div");
|
|
762
|
+
m.className = `pluno-pa-widget__message pluno-pa-widget__message--${g.role}`, g.role === "assistant" ? Ae(m, _) : m.textContent = _, m.appendChild(Le(_)), t.appendChild(m), s = m, b = null;
|
|
574
763
|
}
|
|
575
|
-
const
|
|
764
|
+
const u = v();
|
|
576
765
|
if (o.assistantDraft) {
|
|
577
|
-
if (!
|
|
578
|
-
const
|
|
579
|
-
t.appendChild(
|
|
766
|
+
if (!u) {
|
|
767
|
+
const f = oe(p());
|
|
768
|
+
t.appendChild(f), s = null, b = f;
|
|
580
769
|
}
|
|
581
|
-
const
|
|
582
|
-
|
|
770
|
+
const l = Pe(o.assistantDraft), g = document.createElement("div");
|
|
771
|
+
g.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", Ae(g, l), g.appendChild(Le(l)), t.appendChild(g), s = g, b = null;
|
|
583
772
|
}
|
|
584
773
|
if (o.isThinking && !o.assistantDraft)
|
|
585
|
-
if (
|
|
586
|
-
const
|
|
587
|
-
t.appendChild(
|
|
774
|
+
if (u) {
|
|
775
|
+
const l = $e();
|
|
776
|
+
t.appendChild(l), s = null, b = l;
|
|
588
777
|
} else {
|
|
589
|
-
const
|
|
590
|
-
t.appendChild(
|
|
778
|
+
const l = Lt(p());
|
|
779
|
+
t.appendChild(l), s = null, b = l;
|
|
591
780
|
}
|
|
592
781
|
if (o.lastError) {
|
|
593
|
-
const
|
|
594
|
-
|
|
782
|
+
const l = document.createElement("div");
|
|
783
|
+
l.className = "pluno-pa-widget__error", l.textContent = o.lastError, t.appendChild(l), s = l, b = null;
|
|
595
784
|
}
|
|
596
|
-
|
|
785
|
+
s?.classList.add("pluno-pa-widget__message--bottom-reserve"), b?.classList.add("pluno-pa-widget__bottom-reserve-compact"), t.scrollTop = t.scrollHeight;
|
|
597
786
|
}
|
|
598
|
-
function
|
|
787
|
+
function Le(t) {
|
|
599
788
|
const e = document.createElement("button");
|
|
600
789
|
return e.type = "button", e.className = "pluno-pa-widget__message-copy", e.setAttribute("aria-label", "Copy message"), e.title = "Copy message", e.innerHTML = '<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg>', e.addEventListener("click", (n) => {
|
|
601
790
|
n.preventDefault(), n.stopPropagation(), navigator.clipboard.writeText(t);
|
|
602
791
|
}), e;
|
|
603
792
|
}
|
|
604
|
-
function
|
|
793
|
+
function Pe(t) {
|
|
605
794
|
return t.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
|
|
606
795
|
}
|
|
607
|
-
function
|
|
796
|
+
function St(t, e, n, o) {
|
|
608
797
|
const a = document.createElement("article");
|
|
609
798
|
a.className = "pluno-pa-widget__tool-group", a.title = new Date(t[t.length - 1].createdAt).toLocaleString();
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
|
|
799
|
+
const i = document.createElement("img");
|
|
800
|
+
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);
|
|
801
|
+
const p = document.createElement("details"), c = Pt(t);
|
|
802
|
+
p.open = e.has(c), p.addEventListener("toggle", () => {
|
|
803
|
+
p.open ? e.add(c) : e.delete(c), n();
|
|
615
804
|
});
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
const
|
|
619
|
-
if (
|
|
620
|
-
const
|
|
621
|
-
|
|
805
|
+
const d = document.createElement("summary");
|
|
806
|
+
d.className = "pluno-pa-widget__tool-summary", t.some((b) => b.loading) && d.appendChild(Te());
|
|
807
|
+
const s = document.createElement("span");
|
|
808
|
+
if (s.className = "pluno-pa-widget__tool-summary-title", s.textContent = t[t.length - 1].content || "Run tool", d.appendChild(s), p.appendChild(d), t.length > 0) {
|
|
809
|
+
const b = document.createElement("div");
|
|
810
|
+
b.className = "pluno-pa-widget__tool-lines";
|
|
622
811
|
for (const x of t) {
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
const
|
|
626
|
-
|
|
812
|
+
const v = document.createElement("div");
|
|
813
|
+
v.className = "pluno-pa-widget__tool-line", x.loading && v.appendChild(Te());
|
|
814
|
+
const u = document.createElement("span");
|
|
815
|
+
u.textContent = x.content || "Run tool", v.appendChild(u), b.appendChild(v);
|
|
627
816
|
}
|
|
628
|
-
|
|
817
|
+
p.appendChild(b);
|
|
629
818
|
}
|
|
630
|
-
return a.appendChild(
|
|
819
|
+
return a.appendChild(p), a;
|
|
631
820
|
}
|
|
632
|
-
function
|
|
821
|
+
function oe(t) {
|
|
633
822
|
const e = document.createElement("article");
|
|
634
823
|
e.className = "pluno-pa-widget__tool-group pluno-pa-widget__assistant-marker";
|
|
635
824
|
const n = document.createElement("img");
|
|
636
825
|
return n.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", n.src = t, n.alt = "", n.setAttribute("aria-hidden", "true"), e.appendChild(n), e;
|
|
637
826
|
}
|
|
638
|
-
function
|
|
639
|
-
const e =
|
|
640
|
-
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(
|
|
827
|
+
function Lt(t) {
|
|
828
|
+
const e = oe(t);
|
|
829
|
+
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild($e()), e;
|
|
641
830
|
}
|
|
642
|
-
function
|
|
831
|
+
function $e() {
|
|
643
832
|
const t = document.createElement("div");
|
|
644
833
|
t.className = "pluno-pa-widget__status";
|
|
645
834
|
const e = document.createElement("span");
|
|
@@ -647,17 +836,17 @@ function we() {
|
|
|
647
836
|
const n = document.createElement("span");
|
|
648
837
|
return n.textContent = "Thinking...", t.appendChild(n), t;
|
|
649
838
|
}
|
|
650
|
-
function
|
|
839
|
+
function Pt(t) {
|
|
651
840
|
return `tools:${t.map((e) => e.id).join("|")}`;
|
|
652
841
|
}
|
|
653
|
-
function
|
|
842
|
+
function Te() {
|
|
654
843
|
const t = document.createElement("span");
|
|
655
844
|
return t.className = "pluno-pa-widget__spinner", t.setAttribute("aria-hidden", "true"), t;
|
|
656
845
|
}
|
|
657
|
-
function
|
|
846
|
+
function Tt(t, e) {
|
|
658
847
|
t.setAttribute("aria-label", e ? "Stop" : "Send"), t.classList.toggle("pluno-pa-widget__send--stop", e), t.innerHTML = e ? '<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true"><rect x="6" y="6" width="12" height="12" rx="2" /></svg>' : '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="12" y1="19" x2="12" y2="5" /><polyline points="5 12 12 5 19 12" /></svg>';
|
|
659
848
|
}
|
|
660
|
-
function
|
|
849
|
+
function Ae(t, e) {
|
|
661
850
|
const n = e.replace(/\r\n/g, `
|
|
662
851
|
`).split(`
|
|
663
852
|
`);
|
|
@@ -669,77 +858,77 @@ function ce(t, e) {
|
|
|
669
858
|
continue;
|
|
670
859
|
}
|
|
671
860
|
if (a.match(/^```(\w+)?\s*$/)) {
|
|
672
|
-
const
|
|
861
|
+
const h = [];
|
|
673
862
|
for (o += 1; o < n.length && !/^```\s*$/.test(n[o]); )
|
|
674
|
-
|
|
863
|
+
h.push(n[o]), o += 1;
|
|
675
864
|
o += o < n.length ? 1 : 0;
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
`),
|
|
865
|
+
const s = document.createElement("pre"), b = document.createElement("code");
|
|
866
|
+
b.textContent = h.join(`
|
|
867
|
+
`), s.appendChild(b), t.appendChild(s);
|
|
679
868
|
continue;
|
|
680
869
|
}
|
|
681
|
-
const
|
|
682
|
-
if (
|
|
683
|
-
const
|
|
684
|
-
|
|
870
|
+
const p = a.match(/^(#{1,3})\s+(.+)$/);
|
|
871
|
+
if (p) {
|
|
872
|
+
const h = document.createElement(`h${p[1].length + 2}`);
|
|
873
|
+
U(h, p[2]), t.appendChild(h), o += 1;
|
|
685
874
|
continue;
|
|
686
875
|
}
|
|
687
876
|
if (/^\s*[-*+]\s+/.test(a)) {
|
|
688
|
-
const
|
|
877
|
+
const h = document.createElement("ul");
|
|
689
878
|
for (; o < n.length && /^\s*[-*+]\s+/.test(n[o]); ) {
|
|
690
|
-
const
|
|
691
|
-
|
|
879
|
+
const s = document.createElement("li");
|
|
880
|
+
U(s, n[o].replace(/^\s*[-*+]\s+/, "")), h.appendChild(s), o += 1;
|
|
692
881
|
}
|
|
693
|
-
t.appendChild(
|
|
882
|
+
t.appendChild(h);
|
|
694
883
|
continue;
|
|
695
884
|
}
|
|
696
885
|
if (/^\s*\d+\.\s+/.test(a)) {
|
|
697
|
-
const
|
|
886
|
+
const h = document.createElement("ol");
|
|
698
887
|
for (; o < n.length && /^\s*\d+\.\s+/.test(n[o]); ) {
|
|
699
|
-
const
|
|
700
|
-
|
|
888
|
+
const s = document.createElement("li");
|
|
889
|
+
U(s, n[o].replace(/^\s*\d+\.\s+/, "")), h.appendChild(s), o += 1;
|
|
701
890
|
}
|
|
702
|
-
t.appendChild(
|
|
891
|
+
t.appendChild(h);
|
|
703
892
|
continue;
|
|
704
893
|
}
|
|
705
|
-
const
|
|
894
|
+
const c = [a];
|
|
706
895
|
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]); )
|
|
707
|
-
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}), t.appendChild(
|
|
896
|
+
c.push(n[o]), o += 1;
|
|
897
|
+
const d = document.createElement("p");
|
|
898
|
+
c.forEach((h, s) => {
|
|
899
|
+
s > 0 && d.appendChild(document.createElement("br")), U(d, h);
|
|
900
|
+
}), t.appendChild(d);
|
|
712
901
|
}
|
|
713
902
|
}
|
|
714
|
-
function
|
|
903
|
+
function U(t, e) {
|
|
715
904
|
const n = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
|
|
716
905
|
let o = 0;
|
|
717
906
|
for (const a of e.matchAll(n)) {
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
const
|
|
721
|
-
if (
|
|
722
|
-
const
|
|
723
|
-
|
|
724
|
-
} else if (
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
} else if (
|
|
728
|
-
const
|
|
729
|
-
|
|
907
|
+
const i = a.index ?? 0;
|
|
908
|
+
i > o && t.appendChild(document.createTextNode(e.slice(o, i)));
|
|
909
|
+
const p = a[0];
|
|
910
|
+
if (p.startsWith("`")) {
|
|
911
|
+
const c = document.createElement("code");
|
|
912
|
+
c.textContent = p.slice(1, -1), t.appendChild(c);
|
|
913
|
+
} else if (p.startsWith("**")) {
|
|
914
|
+
const c = document.createElement("strong");
|
|
915
|
+
c.textContent = p.slice(2, -2), t.appendChild(c);
|
|
916
|
+
} else if (p.startsWith("*")) {
|
|
917
|
+
const c = document.createElement("em");
|
|
918
|
+
c.textContent = p.slice(1, -1), t.appendChild(c);
|
|
730
919
|
} else {
|
|
731
|
-
const
|
|
732
|
-
if (
|
|
733
|
-
const
|
|
734
|
-
|
|
920
|
+
const c = p.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
|
|
921
|
+
if (c && At(c[2])) {
|
|
922
|
+
const d = document.createElement("a");
|
|
923
|
+
d.href = c[2], d.target = "_top", d.rel = "noreferrer", d.textContent = c[1], t.appendChild(d);
|
|
735
924
|
} else
|
|
736
|
-
t.appendChild(document.createTextNode(
|
|
925
|
+
t.appendChild(document.createTextNode(p));
|
|
737
926
|
}
|
|
738
|
-
o =
|
|
927
|
+
o = i + p.length;
|
|
739
928
|
}
|
|
740
929
|
o < e.length && t.appendChild(document.createTextNode(e.slice(o)));
|
|
741
930
|
}
|
|
742
|
-
function
|
|
931
|
+
function At(t) {
|
|
743
932
|
if (t.startsWith("/") || t.startsWith("#"))
|
|
744
933
|
return !0;
|
|
745
934
|
try {
|
|
@@ -749,7 +938,7 @@ function qe(t) {
|
|
|
749
938
|
return !1;
|
|
750
939
|
}
|
|
751
940
|
}
|
|
752
|
-
function
|
|
941
|
+
function Ne(t, e) {
|
|
753
942
|
if (t.getElementById("pluno-pa-widget-styles"))
|
|
754
943
|
return;
|
|
755
944
|
const n = t.ownerDocument.createElement("style");
|
|
@@ -795,18 +984,20 @@ function ue(t, e) {
|
|
|
795
984
|
--pluno-pa-divider: rgba(24, 24, 27, 0.08);
|
|
796
985
|
--pluno-pa-launcher-hairline: rgba(24, 24, 27, 0.06);
|
|
797
986
|
--pluno-pa-launcher-width: min(190px, calc(100vw - 36px));
|
|
987
|
+
--pluno-pa-launcher-height: 41px;
|
|
988
|
+
--pluno-pa-panel-width: min(420px, calc(100vw - 28px));
|
|
989
|
+
--pluno-pa-panel-height: min(680px, calc(100vh - 28px));
|
|
990
|
+
--pluno-pa-panel-offset-x: calc(var(--pluno-pa-launcher-width) - var(--pluno-pa-panel-width));
|
|
991
|
+
--pluno-pa-panel-offset-y: calc(var(--pluno-pa-launcher-height) - var(--pluno-pa-panel-height));
|
|
798
992
|
--pluno-pa-accent-soft: rgba(24, 24, 27, 0.12);
|
|
799
993
|
--pluno-pa-accent-contrast: #fafafa;
|
|
800
994
|
position: fixed;
|
|
801
995
|
z-index: 2147483645;
|
|
802
|
-
font-family: ${
|
|
996
|
+
font-family: ${A.fontFamily};
|
|
803
997
|
font-size: 14px;
|
|
804
998
|
color: var(--pluno-pa-text);
|
|
805
999
|
width: var(--pluno-pa-launcher-width);
|
|
806
|
-
height:
|
|
807
|
-
transition:
|
|
808
|
-
width 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
|
|
809
|
-
height 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
1000
|
+
height: var(--pluno-pa-launcher-height);
|
|
810
1001
|
}
|
|
811
1002
|
.pluno-pa-widget--dark {
|
|
812
1003
|
--pluno-pa-bg: #0f0f10;
|
|
@@ -825,10 +1016,12 @@ function ue(t, e) {
|
|
|
825
1016
|
}
|
|
826
1017
|
.pluno-pa-widget--bottom-right { right: 26px; bottom: 24px; }
|
|
827
1018
|
.pluno-pa-widget--bottom-left { left: 26px; bottom: 24px; }
|
|
828
|
-
.pluno-pa-widget--
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
1019
|
+
.pluno-pa-widget--bottom-left {
|
|
1020
|
+
--pluno-pa-panel-offset-x: 0px;
|
|
1021
|
+
}
|
|
1022
|
+
.pluno-pa-widget--custom-position {
|
|
1023
|
+
right: auto;
|
|
1024
|
+
bottom: auto;
|
|
832
1025
|
}
|
|
833
1026
|
.pluno-pa-widget__launcher {
|
|
834
1027
|
position: absolute;
|
|
@@ -848,11 +1041,33 @@ function ue(t, e) {
|
|
|
848
1041
|
inset 0 0 0 1px var(--pluno-pa-launcher-hairline);
|
|
849
1042
|
transform-origin: bottom right;
|
|
850
1043
|
transition:
|
|
851
|
-
opacity 160ms ease,
|
|
852
|
-
transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
|
|
853
1044
|
box-shadow 150ms ease,
|
|
854
1045
|
background 150ms ease;
|
|
855
1046
|
}
|
|
1047
|
+
.pluno-pa-widget__launcher-drag-handle {
|
|
1048
|
+
position: absolute;
|
|
1049
|
+
z-index: 2;
|
|
1050
|
+
top: -11px;
|
|
1051
|
+
left: 8px;
|
|
1052
|
+
right: 8px;
|
|
1053
|
+
height: 11px;
|
|
1054
|
+
border: 0;
|
|
1055
|
+
border-radius: 999px;
|
|
1056
|
+
background: transparent;
|
|
1057
|
+
color: transparent;
|
|
1058
|
+
padding: 0;
|
|
1059
|
+
cursor: grab;
|
|
1060
|
+
touch-action: none;
|
|
1061
|
+
}
|
|
1062
|
+
.pluno-pa-widget__launcher-drag-handle:active,
|
|
1063
|
+
.pluno-pa-widget__launcher-drag-handle:focus-visible,
|
|
1064
|
+
.pluno-pa-widget--dragging .pluno-pa-widget__launcher-drag-handle {
|
|
1065
|
+
cursor: grabbing;
|
|
1066
|
+
}
|
|
1067
|
+
.pluno-pa-widget__launcher-drag-handle:focus-visible {
|
|
1068
|
+
outline: 2px solid var(--pluno-pa-accent);
|
|
1069
|
+
outline-offset: 2px;
|
|
1070
|
+
}
|
|
856
1071
|
.pluno-pa-widget__character {
|
|
857
1072
|
display: block;
|
|
858
1073
|
flex: 0 0 auto;
|
|
@@ -900,14 +1115,13 @@ function ue(t, e) {
|
|
|
900
1115
|
.pluno-pa-widget--open .pluno-pa-widget__launcher {
|
|
901
1116
|
opacity: 0;
|
|
902
1117
|
pointer-events: none;
|
|
903
|
-
transform: translateY(-8px) scale(0.96);
|
|
904
1118
|
}
|
|
905
1119
|
.pluno-pa-widget__panel {
|
|
906
1120
|
position: absolute;
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
width:
|
|
910
|
-
height:
|
|
1121
|
+
left: var(--pluno-pa-panel-offset-x);
|
|
1122
|
+
top: var(--pluno-pa-panel-offset-y);
|
|
1123
|
+
width: var(--pluno-pa-panel-width);
|
|
1124
|
+
height: var(--pluno-pa-panel-height);
|
|
911
1125
|
display: flex;
|
|
912
1126
|
flex-direction: column;
|
|
913
1127
|
min-height: 0;
|
|
@@ -924,8 +1138,6 @@ function ue(t, e) {
|
|
|
924
1138
|
transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
925
1139
|
}
|
|
926
1140
|
.pluno-pa-widget--bottom-left .pluno-pa-widget__panel {
|
|
927
|
-
left: 0;
|
|
928
|
-
right: auto;
|
|
929
1141
|
transform-origin: bottom left;
|
|
930
1142
|
}
|
|
931
1143
|
.pluno-pa-widget--open .pluno-pa-widget__panel {
|
|
@@ -934,8 +1146,8 @@ function ue(t, e) {
|
|
|
934
1146
|
}
|
|
935
1147
|
.pluno-pa-widget__close {
|
|
936
1148
|
position: absolute;
|
|
937
|
-
|
|
938
|
-
|
|
1149
|
+
left: calc(var(--pluno-pa-panel-offset-x) + var(--pluno-pa-panel-width) - 32px);
|
|
1150
|
+
top: calc(var(--pluno-pa-panel-offset-y) - 42px);
|
|
939
1151
|
z-index: 2;
|
|
940
1152
|
width: 32px;
|
|
941
1153
|
height: 32px;
|
|
@@ -1497,6 +1709,7 @@ function ue(t, e) {
|
|
|
1497
1709
|
}
|
|
1498
1710
|
.pluno-pa-widget--scribble {
|
|
1499
1711
|
/* Paper is always light; scribble ignores the configured color scheme */
|
|
1712
|
+
--pluno-pa-launcher-height: 48px;
|
|
1500
1713
|
--pluno-pa-bg: #fdfaf1;
|
|
1501
1714
|
--pluno-pa-surface: #f7f2e3;
|
|
1502
1715
|
--pluno-pa-bubble: #f3ecd8;
|
|
@@ -1544,7 +1757,7 @@ function ue(t, e) {
|
|
|
1544
1757
|
right: 16px;
|
|
1545
1758
|
height: 36px;
|
|
1546
1759
|
z-index: 3;
|
|
1547
|
-
background-image: url('${
|
|
1760
|
+
background-image: url('${be}');
|
|
1548
1761
|
background-repeat: repeat-x;
|
|
1549
1762
|
background-size: 104px 36px;
|
|
1550
1763
|
filter: url(#pluno-pa-scribble-wobble-2);
|
|
@@ -1720,15 +1933,19 @@ function ue(t, e) {
|
|
|
1720
1933
|
/* Taller strip so the bolt clears the spiral ring stubs */
|
|
1721
1934
|
height: 48px;
|
|
1722
1935
|
}
|
|
1723
|
-
.pluno-pa-widget--scribble:not(.pluno-pa-widget--open):not(.pluno-pa-widget--closing) {
|
|
1724
|
-
height: 48px;
|
|
1725
|
-
}
|
|
1726
1936
|
.pluno-pa-widget--scribble .pluno-pa-widget__character--launcher {
|
|
1727
1937
|
margin-top: 3px;
|
|
1728
1938
|
}
|
|
1729
1939
|
.pluno-pa-widget--scribble .pluno-pa-widget__launcher-input {
|
|
1730
1940
|
margin-top: 2px;
|
|
1731
1941
|
}
|
|
1942
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__launcher-drag-handle {
|
|
1943
|
+
top: -13px;
|
|
1944
|
+
left: 12px;
|
|
1945
|
+
right: 12px;
|
|
1946
|
+
height: 12px;
|
|
1947
|
+
z-index: 3;
|
|
1948
|
+
}
|
|
1732
1949
|
.pluno-pa-widget--scribble .pluno-pa-widget__launcher::before {
|
|
1733
1950
|
background-color: var(--pluno-pa-bg);
|
|
1734
1951
|
background-image:
|
|
@@ -1744,7 +1961,7 @@ function ue(t, e) {
|
|
|
1744
1961
|
right: 12px;
|
|
1745
1962
|
height: 22px;
|
|
1746
1963
|
z-index: 1;
|
|
1747
|
-
background-image: url('${
|
|
1964
|
+
background-image: url('${be}');
|
|
1748
1965
|
background-repeat: repeat-x;
|
|
1749
1966
|
background-size: 62px 21.5px;
|
|
1750
1967
|
filter: url(#pluno-pa-scribble-wobble-2);
|
|
@@ -1758,7 +1975,7 @@ function ue(t, e) {
|
|
|
1758
1975
|
}
|
|
1759
1976
|
`, t.appendChild(n);
|
|
1760
1977
|
}
|
|
1761
|
-
async function
|
|
1978
|
+
async function Nt() {
|
|
1762
1979
|
return document.body ? document.body : await new Promise((t) => {
|
|
1763
1980
|
const e = new MutationObserver(() => {
|
|
1764
1981
|
document.body && (e.disconnect(), t(document.body));
|
|
@@ -1766,59 +1983,66 @@ async function Ye() {
|
|
|
1766
1983
|
e.observe(document.documentElement, { childList: !0 });
|
|
1767
1984
|
});
|
|
1768
1985
|
}
|
|
1769
|
-
function
|
|
1986
|
+
function W(t) {
|
|
1770
1987
|
const e = document.createElement("span");
|
|
1771
1988
|
return e.textContent = t, e.innerHTML;
|
|
1772
1989
|
}
|
|
1773
|
-
function
|
|
1990
|
+
function Ge(t) {
|
|
1774
1991
|
return `pluno.productAgent.widgetState.${location.origin}.${t.backendUrl ?? ""}.${t.tokenEndpoint ?? ""}.${t.position ?? ""}`;
|
|
1775
1992
|
}
|
|
1776
|
-
function
|
|
1993
|
+
function It(t) {
|
|
1777
1994
|
try {
|
|
1778
|
-
const e = window.localStorage.getItem(
|
|
1995
|
+
const e = window.localStorage.getItem(Ge(t));
|
|
1779
1996
|
if (!e)
|
|
1780
|
-
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
1997
|
+
return { isOpen: !1, composerValue: "", openToolGroupKeys: [], launcherPosition: null };
|
|
1781
1998
|
const n = JSON.parse(e);
|
|
1782
1999
|
return {
|
|
1783
2000
|
isOpen: n.isOpen === !0,
|
|
1784
2001
|
composerValue: typeof n.composerValue == "string" ? n.composerValue : "",
|
|
1785
|
-
openToolGroupKeys: Array.isArray(n.openToolGroupKeys) ? n.openToolGroupKeys.filter((o) => typeof o == "string") : []
|
|
2002
|
+
openToolGroupKeys: Array.isArray(n.openToolGroupKeys) ? n.openToolGroupKeys.filter((o) => typeof o == "string") : [],
|
|
2003
|
+
launcherPosition: Ot(n.launcherPosition) ? n.launcherPosition : null
|
|
1786
2004
|
};
|
|
1787
2005
|
} catch {
|
|
1788
|
-
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
2006
|
+
return { isOpen: !1, composerValue: "", openToolGroupKeys: [], launcherPosition: null };
|
|
1789
2007
|
}
|
|
1790
2008
|
}
|
|
1791
|
-
function
|
|
2009
|
+
function Mt(t, e) {
|
|
1792
2010
|
try {
|
|
1793
|
-
window.localStorage.setItem(
|
|
2011
|
+
window.localStorage.setItem(Ge(t), JSON.stringify(e));
|
|
1794
2012
|
} catch {
|
|
1795
2013
|
return;
|
|
1796
2014
|
}
|
|
1797
2015
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
2016
|
+
function Ot(t) {
|
|
2017
|
+
if (!t || typeof t != "object")
|
|
2018
|
+
return !1;
|
|
2019
|
+
const e = t;
|
|
2020
|
+
return Number.isFinite(e.x) && Number.isFinite(e.y);
|
|
2021
|
+
}
|
|
2022
|
+
const Ie = /* @__PURE__ */ new WeakSet();
|
|
2023
|
+
function Rt(t) {
|
|
1800
2024
|
return Object.keys(t.dataset).some((e) => e.startsWith("pluno"));
|
|
1801
2025
|
}
|
|
1802
|
-
function
|
|
2026
|
+
function Me(t) {
|
|
1803
2027
|
const e = t.pathname.split("/");
|
|
1804
2028
|
return e[e.length - 1] ?? "";
|
|
1805
2029
|
}
|
|
1806
|
-
function
|
|
2030
|
+
function Dt(t, e) {
|
|
1807
2031
|
const n = new URL(t.src, document.baseURI);
|
|
1808
|
-
return n.href === e.href || n.pathname === e.pathname ? !0 :
|
|
2032
|
+
return n.href === e.href || n.pathname === e.pathname ? !0 : Me(n) === Me(e);
|
|
1809
2033
|
}
|
|
1810
|
-
class
|
|
2034
|
+
class L extends EventTarget {
|
|
1811
2035
|
constructor(e, n) {
|
|
1812
|
-
super(), this.channelId = n, this.url = e, this.addPreviewListener(
|
|
1813
|
-
this.readyState =
|
|
1814
|
-
}), this.addPreviewListener(
|
|
2036
|
+
super(), this.channelId = n, this.url = e, this.addPreviewListener(nt, () => {
|
|
2037
|
+
this.readyState = L.OPEN, this.dispatchEvent(new Event("open"));
|
|
2038
|
+
}), this.addPreviewListener(ot, (o) => {
|
|
1815
2039
|
const a = o;
|
|
1816
2040
|
this.dispatchEvent(new MessageEvent("message", { data: a.detail?.data ?? "" }));
|
|
1817
|
-
}), this.addPreviewListener(
|
|
1818
|
-
this.readyState =
|
|
1819
|
-
}), this.addPreviewListener(
|
|
2041
|
+
}), this.addPreviewListener(at, () => {
|
|
2042
|
+
this.readyState = L.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
|
|
2043
|
+
}), this.addPreviewListener(it, (o) => {
|
|
1820
2044
|
const a = o;
|
|
1821
|
-
this.readyState =
|
|
2045
|
+
this.readyState = L.CLOSED, this.dispatchEvent(
|
|
1822
2046
|
new CloseEvent("close", {
|
|
1823
2047
|
code: a.detail?.code ?? 1e3,
|
|
1824
2048
|
reason: a.detail?.reason ?? "",
|
|
@@ -1826,7 +2050,7 @@ class C extends EventTarget {
|
|
|
1826
2050
|
})
|
|
1827
2051
|
), this.cleanup();
|
|
1828
2052
|
}), window.dispatchEvent(
|
|
1829
|
-
new CustomEvent(
|
|
2053
|
+
new CustomEvent(V(Qe, this.channelId), {
|
|
1830
2054
|
detail: { socketId: this.socketId, url: e }
|
|
1831
2055
|
})
|
|
1832
2056
|
);
|
|
@@ -1841,28 +2065,28 @@ class C extends EventTarget {
|
|
|
1841
2065
|
extensions = "";
|
|
1842
2066
|
binaryType = "blob";
|
|
1843
2067
|
bufferedAmount = 0;
|
|
1844
|
-
readyState =
|
|
1845
|
-
socketId =
|
|
2068
|
+
readyState = L.CONNECTING;
|
|
2069
|
+
socketId = Ft();
|
|
1846
2070
|
listeners = /* @__PURE__ */ new Map();
|
|
1847
2071
|
send(e) {
|
|
1848
|
-
if (this.readyState !==
|
|
2072
|
+
if (this.readyState !== L.OPEN)
|
|
1849
2073
|
throw new DOMException("Product Agent preview websocket is not open", "InvalidStateError");
|
|
1850
2074
|
window.dispatchEvent(
|
|
1851
|
-
new CustomEvent(
|
|
2075
|
+
new CustomEvent(V(et, this.channelId), {
|
|
1852
2076
|
detail: { socketId: this.socketId, data: typeof e == "string" ? e : String(e) }
|
|
1853
2077
|
})
|
|
1854
2078
|
);
|
|
1855
2079
|
}
|
|
1856
2080
|
close(e, n) {
|
|
1857
|
-
this.readyState !==
|
|
1858
|
-
new CustomEvent(
|
|
2081
|
+
this.readyState !== L.CLOSED && (this.readyState = L.CLOSING, window.dispatchEvent(
|
|
2082
|
+
new CustomEvent(V(tt, this.channelId), {
|
|
1859
2083
|
detail: { socketId: this.socketId, code: e, reason: n }
|
|
1860
2084
|
})
|
|
1861
2085
|
), this.cleanup());
|
|
1862
2086
|
}
|
|
1863
2087
|
addPreviewListener(e, n) {
|
|
1864
|
-
const o =
|
|
1865
|
-
|
|
2088
|
+
const o = V(e, this.channelId), a = (i) => {
|
|
2089
|
+
i.detail?.socketId === this.socketId && n(i);
|
|
1866
2090
|
};
|
|
1867
2091
|
this.listeners.set(o, a), window.addEventListener(o, a);
|
|
1868
2092
|
}
|
|
@@ -1872,36 +2096,36 @@ class C extends EventTarget {
|
|
|
1872
2096
|
this.listeners.clear();
|
|
1873
2097
|
}
|
|
1874
2098
|
}
|
|
1875
|
-
function
|
|
1876
|
-
const t = window.sessionStorage.getItem(
|
|
2099
|
+
function Ft() {
|
|
2100
|
+
const t = window.sessionStorage.getItem(fe);
|
|
1877
2101
|
if (t)
|
|
1878
2102
|
return t;
|
|
1879
2103
|
const e = crypto.randomUUID();
|
|
1880
|
-
return window.sessionStorage.setItem(
|
|
2104
|
+
return window.sessionStorage.setItem(fe, e), e;
|
|
1881
2105
|
}
|
|
1882
|
-
function
|
|
2106
|
+
function V(t, e) {
|
|
1883
2107
|
return `${t}:${e}`;
|
|
1884
2108
|
}
|
|
1885
|
-
function
|
|
2109
|
+
function $t(t) {
|
|
1886
2110
|
const e = document.currentScript;
|
|
1887
2111
|
if (e instanceof HTMLScriptElement)
|
|
1888
2112
|
return [e];
|
|
1889
2113
|
const n = new URL(t, document.baseURI).href, o = new URL(n);
|
|
1890
2114
|
return Array.from(document.querySelectorAll("script[type='module'][src]")).filter(
|
|
1891
|
-
(a) => a instanceof HTMLScriptElement &&
|
|
2115
|
+
(a) => a instanceof HTMLScriptElement && Rt(a) && Dt(a, o)
|
|
1892
2116
|
);
|
|
1893
2117
|
}
|
|
1894
|
-
function
|
|
1895
|
-
for (const e of
|
|
1896
|
-
if (
|
|
2118
|
+
function Gt(t) {
|
|
2119
|
+
for (const e of $t(t)) {
|
|
2120
|
+
if (Ie.has(e) || e.dataset.plunoAutoMount === "false")
|
|
1897
2121
|
continue;
|
|
1898
|
-
|
|
2122
|
+
Ie.add(e);
|
|
1899
2123
|
const n = e.dataset.plunoPreviewChannel;
|
|
1900
|
-
|
|
2124
|
+
mt({
|
|
1901
2125
|
token: e.dataset.plunoToken,
|
|
1902
2126
|
tokenEndpoint: e.dataset.plunoTokenEndpoint,
|
|
1903
2127
|
backendUrl: e.dataset.plunoBackendUrl,
|
|
1904
|
-
webSocketFactory: n ?
|
|
2128
|
+
webSocketFactory: n ? wt(n) : void 0,
|
|
1905
2129
|
launcherLabel: e.dataset.plunoLauncherLabel,
|
|
1906
2130
|
accentColor: e.dataset.plunoAccentColor,
|
|
1907
2131
|
colorScheme: e.dataset.plunoColorScheme === "dark" ? "dark" : "light",
|
|
@@ -1913,8 +2137,8 @@ function nt(t) {
|
|
|
1913
2137
|
});
|
|
1914
2138
|
}
|
|
1915
2139
|
}
|
|
1916
|
-
|
|
2140
|
+
Gt(import.meta.url);
|
|
1917
2141
|
export {
|
|
1918
|
-
|
|
1919
|
-
|
|
2142
|
+
wt as createProductAgentPreviewBridgeWebSocketFactory,
|
|
2143
|
+
mt as mountPlunoProductAgentWidget
|
|
1920
2144
|
};
|