@pluno/product-agent-web 0.1.13 → 0.1.15
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/boltIcon.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/product-agent-sdk.js +84 -80
- package/dist/product-agent-widget.js +273 -229
- 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 xe } from "./product-agent-sdk.js";
|
|
2
|
+
const ye = "#7c3aed";
|
|
3
|
+
function ve(t) {
|
|
4
|
+
const e = Le(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,16 +75,27 @@ function we(t) {
|
|
|
75
75
|
</g>
|
|
76
76
|
</svg>`;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return `data:image/svg+xml,${encodeURIComponent(
|
|
78
|
+
function ke(t) {
|
|
79
|
+
return `data:image/svg+xml,${encodeURIComponent(ve(t))}`;
|
|
80
80
|
}
|
|
81
|
-
const
|
|
82
|
-
function
|
|
83
|
-
const e =
|
|
81
|
+
const N = "#2c2a1e", J = [253, 250, 241], Q = 3.5;
|
|
82
|
+
function be(t) {
|
|
83
|
+
const e = he(t);
|
|
84
|
+
if (ee(M(e), J) >= Q)
|
|
85
|
+
return e;
|
|
86
|
+
let n = M(e);
|
|
87
|
+
const a = M(N);
|
|
88
|
+
for (let r = 0; r < 6; r += 1)
|
|
89
|
+
if (n = Te(n, a, 0.22), ee(n, J) >= Q)
|
|
90
|
+
return W(n);
|
|
91
|
+
return W(n);
|
|
92
|
+
}
|
|
93
|
+
function Ce(t) {
|
|
94
|
+
const e = be(t), o = "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";
|
|
84
95
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1254 1254" role="img" aria-label="Pluno">
|
|
85
96
|
<defs>
|
|
86
97
|
<clipPath id="scribbleBoltClip">
|
|
87
|
-
<path d="${
|
|
98
|
+
<path d="${o}"/>
|
|
88
99
|
</clipPath>
|
|
89
100
|
<filter id="scribbleBoltWobble" x="-10%" y="-10%" width="120%" height="120%" color-interpolation-filters="sRGB">
|
|
90
101
|
<feTurbulence type="fractalNoise" baseFrequency="0.011" numOctaves="3" seed="7" result="noise"/>
|
|
@@ -93,26 +104,26 @@ function _e(t) {
|
|
|
93
104
|
</defs>
|
|
94
105
|
<g filter="url(#scribbleBoltWobble)">
|
|
95
106
|
<g clip-path="url(#scribbleBoltClip)">
|
|
96
|
-
<path d="${
|
|
107
|
+
<path d="${Ee()}" fill="none" stroke="${e}" stroke-width="56" stroke-linecap="round" stroke-linejoin="round" opacity="0.9" transform="rotate(-14 627 600)"/>
|
|
97
108
|
</g>
|
|
98
|
-
<path d="${
|
|
109
|
+
<path d="${o}" fill="none" stroke="${N}" stroke-width="18" stroke-linejoin="round"/>
|
|
99
110
|
<g transform="rotate(-2 528 463)">
|
|
100
|
-
<ellipse cx="528" cy="463" rx="73" ry="80" fill="#ffffff" stroke="${
|
|
101
|
-
<ellipse cx="533" cy="473" rx="45" ry="53" fill="${
|
|
111
|
+
<ellipse cx="528" cy="463" rx="73" ry="80" fill="#ffffff" stroke="${N}" stroke-width="13"/>
|
|
112
|
+
<ellipse cx="533" cy="473" rx="45" ry="53" fill="${N}"/>
|
|
102
113
|
<circle cx="557" cy="447" r="16" fill="#ffffff"/>
|
|
103
114
|
</g>
|
|
104
115
|
<g transform="rotate(2 717 462)">
|
|
105
|
-
<ellipse cx="717" cy="462" rx="73" ry="80" fill="#ffffff" stroke="${
|
|
106
|
-
<ellipse cx="712" cy="473" rx="45" ry="53" fill="${
|
|
116
|
+
<ellipse cx="717" cy="462" rx="73" ry="80" fill="#ffffff" stroke="${N}" stroke-width="13"/>
|
|
117
|
+
<ellipse cx="712" cy="473" rx="45" ry="53" fill="${N}"/>
|
|
107
118
|
<circle cx="728" cy="447" r="16" fill="#ffffff"/>
|
|
108
119
|
</g>
|
|
109
120
|
</g>
|
|
110
121
|
</svg>`;
|
|
111
122
|
}
|
|
112
|
-
function
|
|
113
|
-
return `data:image/svg+xml,${encodeURIComponent(
|
|
123
|
+
function Se(t) {
|
|
124
|
+
return `data:image/svg+xml,${encodeURIComponent(Ce(t))}`;
|
|
114
125
|
}
|
|
115
|
-
function
|
|
126
|
+
function Ee() {
|
|
116
127
|
let o = "M 280 120", n = !1, a = 0;
|
|
117
128
|
for (let r = 150; r <= 1170; r += 62) {
|
|
118
129
|
const i = (a % 3 - 1) * 18, d = n ? 280 - i : 1020 + i;
|
|
@@ -120,8 +131,8 @@ function ye() {
|
|
|
120
131
|
}
|
|
121
132
|
return o;
|
|
122
133
|
}
|
|
123
|
-
function
|
|
124
|
-
const e =
|
|
134
|
+
function Le(t) {
|
|
135
|
+
const e = he(t), o = H(M(e));
|
|
125
136
|
return o > 0.86 ? {
|
|
126
137
|
top: "#ffffff",
|
|
127
138
|
middle: "#f6f6f6",
|
|
@@ -145,80 +156,92 @@ function ve(t) {
|
|
|
145
156
|
inner: "#4b4b4b",
|
|
146
157
|
shadow: "#000000"
|
|
147
158
|
} : {
|
|
148
|
-
top:
|
|
149
|
-
middle:
|
|
150
|
-
bottom:
|
|
151
|
-
edgeStart:
|
|
152
|
-
edgeMiddle:
|
|
153
|
-
edgeEnd:
|
|
154
|
-
glow:
|
|
155
|
-
highlight:
|
|
156
|
-
inner:
|
|
157
|
-
shadow:
|
|
159
|
+
top: v(e, 0.28, -0.03),
|
|
160
|
+
middle: v(e, 0.08, 0.04),
|
|
161
|
+
bottom: v(e, -0.1, 0.02),
|
|
162
|
+
edgeStart: v(e, 0.08, 0.08),
|
|
163
|
+
edgeMiddle: v(e, -0.08, 0.08),
|
|
164
|
+
edgeEnd: v(e, -0.18, 0.05),
|
|
165
|
+
glow: v(e, 0.32, -0.12),
|
|
166
|
+
highlight: v(e, 0.38, -0.18),
|
|
167
|
+
inner: v(e, 0.24, -0.1),
|
|
168
|
+
shadow: v(e, -0.25, -0.08)
|
|
158
169
|
};
|
|
159
170
|
}
|
|
160
|
-
function
|
|
171
|
+
function he(t) {
|
|
161
172
|
const e = t.trim();
|
|
162
|
-
return /^#[0-9a-f]{6}$/i.test(e) ? e.toLowerCase() : /^#[0-9a-f]{3}$/i.test(e) ? `#${e.slice(1).split("").map((o) => o + o).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((o) => o + o).join("").toLowerCase()}` : ye;
|
|
163
174
|
}
|
|
164
|
-
function
|
|
175
|
+
function M(t) {
|
|
165
176
|
return [
|
|
166
177
|
Number.parseInt(t.slice(1, 3), 16),
|
|
167
178
|
Number.parseInt(t.slice(3, 5), 16),
|
|
168
179
|
Number.parseInt(t.slice(5, 7), 16)
|
|
169
180
|
];
|
|
170
181
|
}
|
|
171
|
-
function
|
|
182
|
+
function W([t, e, o]) {
|
|
172
183
|
const n = (a) => Math.max(0, Math.min(255, Math.round(a))).toString(16).padStart(2, "0");
|
|
173
184
|
return `#${n(t)}${n(e)}${n(o)}`;
|
|
174
185
|
}
|
|
175
|
-
function
|
|
186
|
+
function H([t, e, o]) {
|
|
176
187
|
const n = (a) => {
|
|
177
188
|
const r = a / 255;
|
|
178
189
|
return r <= 0.04045 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
179
190
|
};
|
|
180
191
|
return 0.2126 * n(t) + 0.7152 * n(e) + 0.0722 * n(o);
|
|
181
192
|
}
|
|
182
|
-
function
|
|
183
|
-
const
|
|
184
|
-
return
|
|
193
|
+
function ee(t, e) {
|
|
194
|
+
const o = H(t), n = H(e), [a, r] = o > n ? [o, n] : [n, o];
|
|
195
|
+
return (a + 0.05) / (r + 0.05);
|
|
196
|
+
}
|
|
197
|
+
function Te(t, e, o) {
|
|
198
|
+
const n = V(o);
|
|
199
|
+
return [
|
|
200
|
+
t[0] + (e[0] - t[0]) * n,
|
|
201
|
+
t[1] + (e[1] - t[1]) * n,
|
|
202
|
+
t[2] + (e[2] - t[2]) * n
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
function v(t, e, o) {
|
|
206
|
+
const [n, a, r] = Ne(M(t));
|
|
207
|
+
return W(Ie(n, V(a + o), V(r + e)));
|
|
185
208
|
}
|
|
186
|
-
function
|
|
209
|
+
function Ne([t, e, o]) {
|
|
187
210
|
const n = t / 255, a = e / 255, r = o / 255, i = Math.max(n, a, r), d = Math.min(n, a, r), u = (i + d) / 2;
|
|
188
211
|
if (i === d)
|
|
189
212
|
return [0, 0, u];
|
|
190
213
|
const p = i - d, g = u > 0.5 ? p / (2 - i - d) : p / (i + d);
|
|
191
214
|
return [(i === n ? (a - r) / p + (a < r ? 6 : 0) : i === a ? (r - n) / p + 2 : (n - a) / p + 4) / 6, g, u];
|
|
192
215
|
}
|
|
193
|
-
function
|
|
216
|
+
function Ie(t, e, o) {
|
|
194
217
|
if (e === 0)
|
|
195
218
|
return [o * 255, o * 255, o * 255];
|
|
196
219
|
const n = o < 0.5 ? o * (1 + e) : o + e - o * e, a = 2 * o - n;
|
|
197
220
|
return [
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
221
|
+
B(a, n, t + 1 / 3) * 255,
|
|
222
|
+
B(a, n, t) * 255,
|
|
223
|
+
B(a, n, t - 1 / 3) * 255
|
|
201
224
|
];
|
|
202
225
|
}
|
|
203
|
-
function
|
|
226
|
+
function B(t, e, o) {
|
|
204
227
|
let n = o;
|
|
205
228
|
return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? t + (e - t) * 6 * n : n < 1 / 2 ? e : n < 2 / 3 ? t + (e - t) * (2 / 3 - n) * 6 : t;
|
|
206
229
|
}
|
|
207
|
-
function
|
|
230
|
+
function V(t) {
|
|
208
231
|
return Math.max(0, Math.min(1, t));
|
|
209
232
|
}
|
|
210
|
-
const
|
|
233
|
+
const Pe = "product-agent:sdk-preview-socket-connect", Ae = "product-agent:sdk-preview-socket-send", Me = "product-agent:sdk-preview-socket-close", Oe = "product-agent:sdk-preview-socket-open", $e = "product-agent:sdk-preview-socket-message", De = "product-agent:sdk-preview-socket-error", Fe = "product-agent:sdk-preview-socket-closed", te = "product-agent:sdk-preview-socket-id", Re = "product-agent:preview-diagnostic", T = {
|
|
211
234
|
launcherLabel: "Ask for anything...",
|
|
212
235
|
accentColor: "#7c3aed",
|
|
213
236
|
colorScheme: "light",
|
|
214
237
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", sans-serif',
|
|
215
238
|
scribbleStyle: !1,
|
|
216
239
|
position: "bottom-right"
|
|
217
|
-
},
|
|
218
|
-
function
|
|
240
|
+
}, ne = '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>', Ge = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', oe = "pluno-pa-scribble-font";
|
|
241
|
+
function ze(t) {
|
|
219
242
|
return (e) => new C(e, t);
|
|
220
243
|
}
|
|
221
|
-
async function
|
|
244
|
+
async function Be(t = {}) {
|
|
222
245
|
const e = {
|
|
223
246
|
launcherLabel: t.launcherLabel ?? T.launcherLabel,
|
|
224
247
|
accentColor: t.accentColor ?? T.accentColor,
|
|
@@ -230,10 +253,11 @@ async function De(t = {}) {
|
|
|
230
253
|
tokenProvider: t.tokenProvider,
|
|
231
254
|
tokenEndpoint: t.tokenEndpoint,
|
|
232
255
|
backendUrl: t.backendUrl,
|
|
256
|
+
metadata: t.metadata,
|
|
233
257
|
initialStarterPrompts: t.initialStarterPrompts,
|
|
234
258
|
webSocketFactory: t.webSocketFactory
|
|
235
259
|
};
|
|
236
|
-
|
|
260
|
+
P("web-sdk.widget", "Mounting widget with merged options", {
|
|
237
261
|
accentColor: e.accentColor,
|
|
238
262
|
colorScheme: e.colorScheme,
|
|
239
263
|
fontFamily: e.fontFamily,
|
|
@@ -248,7 +272,7 @@ async function De(t = {}) {
|
|
|
248
272
|
o.className = "pluno-pa-widget-host";
|
|
249
273
|
const n = o.attachShadow({ mode: "open" }), a = document.createElement("div");
|
|
250
274
|
a.className = `pluno-pa-widget pluno-pa-widget--${e.position}`;
|
|
251
|
-
let r =
|
|
275
|
+
let r = ae(e.accentColor, e.scribbleStyle);
|
|
252
276
|
a.innerHTML = `
|
|
253
277
|
<svg class="pluno-pa-widget__scribble-defs" aria-hidden="true" focusable="false" width="0" height="0">
|
|
254
278
|
<defs>
|
|
@@ -273,8 +297,8 @@ async function De(t = {}) {
|
|
|
273
297
|
</defs>
|
|
274
298
|
</svg>
|
|
275
299
|
<form class="pluno-pa-widget__launcher">
|
|
276
|
-
<img class="pluno-pa-widget__character pluno-pa-widget__character--launcher" src="${
|
|
277
|
-
<input class="pluno-pa-widget__launcher-input" type="text" placeholder="${
|
|
300
|
+
<img class="pluno-pa-widget__character pluno-pa-widget__character--launcher" src="${D(r)}" alt="" aria-hidden="true" />
|
|
301
|
+
<input class="pluno-pa-widget__launcher-input" type="text" placeholder="${D(e.launcherLabel)}" aria-label="${D(e.launcherLabel)}" />
|
|
278
302
|
</form>
|
|
279
303
|
<button type="button" class="pluno-pa-widget__close" aria-label="Close" hidden>
|
|
280
304
|
<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">
|
|
@@ -285,7 +309,7 @@ async function De(t = {}) {
|
|
|
285
309
|
<div class="pluno-pa-widget__timeline-wrap">
|
|
286
310
|
<main class="pluno-pa-widget__timeline">
|
|
287
311
|
<div class="pluno-pa-widget__empty-state">
|
|
288
|
-
<img class="pluno-pa-widget__character pluno-pa-widget__character--empty" src="${
|
|
312
|
+
<img class="pluno-pa-widget__character pluno-pa-widget__character--empty" src="${D(r)}" alt="" aria-hidden="true" />
|
|
289
313
|
<div class="pluno-pa-widget__empty">Hey there, I'm Pluno 👋<br />What do you want to do today?</div>
|
|
290
314
|
</div>
|
|
291
315
|
</main>
|
|
@@ -310,22 +334,22 @@ async function De(t = {}) {
|
|
|
310
334
|
</form>
|
|
311
335
|
</section>
|
|
312
336
|
`, n.appendChild(a);
|
|
313
|
-
const i = await
|
|
314
|
-
i.appendChild(o), a.classList.add(`pluno-pa-widget--${e.colorScheme}`),
|
|
337
|
+
const i = await qe(), d = i.ownerDocument;
|
|
338
|
+
i.appendChild(o), a.classList.add(`pluno-pa-widget--${e.colorScheme}`), ce(n, e.accentColor), re(a, r, {
|
|
315
339
|
accentColor: e.accentColor,
|
|
316
340
|
colorScheme: e.colorScheme,
|
|
317
341
|
fontFamily: e.fontFamily,
|
|
318
342
|
scribbleStyle: e.scribbleStyle
|
|
319
|
-
}),
|
|
343
|
+
}), P("web-sdk.widget", "Applied initial widget appearance", {
|
|
320
344
|
accentColor: e.accentColor,
|
|
321
345
|
colorScheme: e.colorScheme,
|
|
322
346
|
fontFamily: e.fontFamily,
|
|
323
347
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
324
348
|
});
|
|
325
|
-
const u = a.querySelector(".pluno-pa-widget__launcher"), p = a.querySelector(".pluno-pa-widget__launcher-input"), g = a.querySelector(".pluno-pa-widget__panel"),
|
|
326
|
-
if (!u || !p || !g || !
|
|
349
|
+
const u = a.querySelector(".pluno-pa-widget__launcher"), p = a.querySelector(".pluno-pa-widget__launcher-input"), g = a.querySelector(".pluno-pa-widget__panel"), f = a.querySelector(".pluno-pa-widget__close"), x = a.querySelector(".pluno-pa-widget__composer"), s = a.querySelector(".pluno-pa-widget__input"), _ = a.querySelector(".pluno-pa-widget__send"), c = a.querySelector(".pluno-pa-widget__new-chat"), b = a.querySelector(".pluno-pa-widget__timeline");
|
|
350
|
+
if (!u || !p || !g || !f || !x || !s || !_ || !c || !b)
|
|
327
351
|
throw new Error("Failed to mount Product Agent widget");
|
|
328
|
-
const
|
|
352
|
+
const y = e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (async () => {
|
|
329
353
|
if (!e.tokenEndpoint)
|
|
330
354
|
throw new Error("Product Agent widget requires token or tokenEndpoint");
|
|
331
355
|
const l = await fetch(e.tokenEndpoint, {
|
|
@@ -340,126 +364,135 @@ async function De(t = {}) {
|
|
|
340
364
|
if (!k.token)
|
|
341
365
|
throw new Error("Product Agent token endpoint did not return a token");
|
|
342
366
|
return k.token;
|
|
343
|
-
})
|
|
367
|
+
});
|
|
368
|
+
let h;
|
|
369
|
+
h = await xe.init({
|
|
344
370
|
token: e.token,
|
|
345
|
-
tokenProvider:
|
|
371
|
+
tokenProvider: y,
|
|
346
372
|
backendUrl: e.backendUrl,
|
|
373
|
+
metadata: () => ({
|
|
374
|
+
...e.metadata ?? {},
|
|
375
|
+
...!h.getState().sessionId && e.scribbleStyle ? { scribbleStyleStarted: !0 } : {}
|
|
376
|
+
}),
|
|
347
377
|
initialStarterPrompts: e.initialStarterPrompts,
|
|
348
378
|
webSocketFactory: e.webSocketFactory
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
379
|
+
});
|
|
380
|
+
const w = Ye(e), m = new Set(w.openToolGroupKeys);
|
|
381
|
+
let S = null, j = !1;
|
|
382
|
+
const me = () => {
|
|
383
|
+
j || typeof document > "u" || (ce(n, e.accentColor), o.isConnected || d.body?.appendChild(o));
|
|
384
|
+
}, q = new MutationObserver(me);
|
|
385
|
+
q.observe(d.documentElement, { childList: !0, subtree: !0 });
|
|
355
386
|
const E = () => {
|
|
356
|
-
|
|
387
|
+
Ze(e, {
|
|
357
388
|
isOpen: a.classList.contains("pluno-pa-widget--open"),
|
|
358
389
|
composerValue: s.value,
|
|
359
390
|
openToolGroupKeys: [...m]
|
|
360
391
|
});
|
|
361
|
-
},
|
|
362
|
-
if (S !== null && (window.clearTimeout(S), S = null), g.hidden = !1,
|
|
363
|
-
a.classList.add("pluno-pa-widget--open"), u.hidden = !0, l && (s.value = l,
|
|
392
|
+
}, I = (l = "", k = !0) => {
|
|
393
|
+
if (S !== null && (window.clearTimeout(S), S = null), g.hidden = !1, f.hidden = !1, a.classList.remove("pluno-pa-widget--closing"), !k) {
|
|
394
|
+
a.classList.add("pluno-pa-widget--open"), u.hidden = !0, l && (s.value = l, A(s)), b.scrollTop = b.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E();
|
|
364
395
|
return;
|
|
365
396
|
}
|
|
366
397
|
window.requestAnimationFrame(() => {
|
|
367
|
-
a.classList.add("pluno-pa-widget--open"), l && (s.value = l,
|
|
368
|
-
u.hidden = !0,
|
|
398
|
+
a.classList.add("pluno-pa-widget--open"), l && (s.value = l, A(s)), b.scrollTop = b.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E(), S = window.setTimeout(() => {
|
|
399
|
+
u.hidden = !0, b.scrollTop = b.scrollHeight;
|
|
369
400
|
}, 220);
|
|
370
401
|
});
|
|
371
|
-
},
|
|
402
|
+
}, _e = () => {
|
|
372
403
|
S !== null && (window.clearTimeout(S), S = null), u.hidden = !1, a.classList.add("pluno-pa-widget--closing"), a.classList.remove("pluno-pa-widget--open"), E(), S = window.setTimeout(() => {
|
|
373
|
-
g.hidden = !0,
|
|
404
|
+
g.hidden = !0, f.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
|
|
374
405
|
}, 220);
|
|
375
406
|
};
|
|
376
407
|
u.addEventListener("submit", (l) => {
|
|
377
|
-
l.preventDefault(),
|
|
408
|
+
l.preventDefault(), I(p.value), p.value = "";
|
|
378
409
|
}), u.addEventListener("click", (l) => {
|
|
379
|
-
l.target !== p && (
|
|
410
|
+
l.target !== p && (I(p.value), p.value = "");
|
|
380
411
|
}), p.addEventListener("focus", () => {
|
|
381
|
-
|
|
412
|
+
I(p.value), p.value = "";
|
|
382
413
|
}), p.addEventListener("input", () => {
|
|
383
414
|
if (!p.value)
|
|
384
415
|
return;
|
|
385
416
|
const l = p.value;
|
|
386
|
-
|
|
387
|
-
}),
|
|
417
|
+
I(l), p.value = "";
|
|
418
|
+
}), f.addEventListener("click", _e);
|
|
388
419
|
const L = () => {
|
|
389
|
-
_.disabled = !
|
|
420
|
+
_.disabled = !h.getState().isThinking && s.value.trim().length === 0;
|
|
390
421
|
};
|
|
391
|
-
|
|
392
|
-
l.preventDefault(),
|
|
422
|
+
x.addEventListener("submit", (l) => {
|
|
423
|
+
l.preventDefault(), U(h, s), L();
|
|
393
424
|
}), _.addEventListener("click", () => {
|
|
394
|
-
if (
|
|
395
|
-
|
|
425
|
+
if (h.getState().isThinking) {
|
|
426
|
+
h.stop();
|
|
396
427
|
return;
|
|
397
428
|
}
|
|
398
|
-
|
|
429
|
+
U(h, s), L();
|
|
399
430
|
}), c.addEventListener("click", () => {
|
|
400
|
-
|
|
431
|
+
h.startNewSession(), m.clear(), s.value = "", A(s), E(), L(), s.focus();
|
|
401
432
|
}), s.addEventListener("input", () => {
|
|
402
|
-
|
|
433
|
+
A(s), E(), L();
|
|
403
434
|
}), s.addEventListener("keydown", (l) => {
|
|
404
|
-
l.key !== "Enter" || l.shiftKey || (l.preventDefault(),
|
|
435
|
+
l.key !== "Enter" || l.shiftKey || (l.preventDefault(), U(h, s), L());
|
|
405
436
|
}), a.addEventListener("click", (l) => {
|
|
406
437
|
(l.target instanceof Element ? l.target : null)?.closest("a[href]") && E();
|
|
407
|
-
}), w.composerValue && (s.value = w.composerValue,
|
|
408
|
-
const
|
|
409
|
-
let
|
|
410
|
-
return
|
|
411
|
-
l.appearance ? (
|
|
438
|
+
}), w.composerValue && (s.value = w.composerValue, A(s)), w.isOpen && I(s.value, !1);
|
|
439
|
+
const Y = () => r;
|
|
440
|
+
let R = h.getState().appearance !== null;
|
|
441
|
+
return h.on("state", (l) => {
|
|
442
|
+
l.appearance ? (R = !0, P("web-sdk.widget", "Agent state supplied appearance", {
|
|
412
443
|
appearance: l.appearance
|
|
413
|
-
}), G(l.appearance, "agent.state.appearance")) :
|
|
444
|
+
}), G(l.appearance, "agent.state.appearance")) : R && (R = !1, P("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
|
|
414
445
|
fallbackAccentColor: e.accentColor,
|
|
415
446
|
fallbackColorScheme: e.colorScheme,
|
|
416
447
|
fallbackFontFamily: e.fontFamily
|
|
417
|
-
}), G({}, "agent.state.appearance-cleared")),
|
|
418
|
-
|
|
448
|
+
}), G({}, "agent.state.appearance-cleared")), ie(b, _, c, l, m, E, Y, (k) => {
|
|
449
|
+
h.sendMessage(k);
|
|
419
450
|
}), L();
|
|
420
|
-
}),
|
|
421
|
-
|
|
451
|
+
}), ie(b, _, c, h.getState(), m, E, Y, (l) => {
|
|
452
|
+
h.sendMessage(l);
|
|
422
453
|
}), L(), {
|
|
423
|
-
agent:
|
|
454
|
+
agent: h,
|
|
424
455
|
updateAppearance: (l) => {
|
|
425
456
|
l.scribbleStyle !== void 0 && (e.scribbleStyle = l.scribbleStyle), G(l, "widgetHandle.updateAppearance");
|
|
426
457
|
},
|
|
427
458
|
destroy: () => {
|
|
428
|
-
|
|
459
|
+
j = !0, q.disconnect(), h.destroy(), o.remove();
|
|
429
460
|
}
|
|
430
461
|
};
|
|
431
462
|
function G(l, k) {
|
|
432
|
-
const
|
|
433
|
-
r =
|
|
434
|
-
accentColor:
|
|
435
|
-
colorScheme:
|
|
436
|
-
fontFamily:
|
|
463
|
+
const O = l.accentColor ?? e.accentColor, Z = l.colorScheme ?? e.colorScheme, X = l.fontFamily ?? e.fontFamily, z = l.scribbleStyle ?? e.scribbleStyle;
|
|
464
|
+
r = ae(O, z), re(a, r, {
|
|
465
|
+
accentColor: O,
|
|
466
|
+
colorScheme: Z,
|
|
467
|
+
fontFamily: X,
|
|
437
468
|
scribbleStyle: z
|
|
438
|
-
}),
|
|
469
|
+
}), P("web-sdk.widget", "Updated widget appearance", {
|
|
439
470
|
source: k,
|
|
440
471
|
inputAppearance: l,
|
|
441
|
-
appliedAccentColor:
|
|
442
|
-
appliedColorScheme:
|
|
443
|
-
appliedFontFamily:
|
|
472
|
+
appliedAccentColor: O,
|
|
473
|
+
appliedColorScheme: Z,
|
|
474
|
+
appliedFontFamily: X,
|
|
444
475
|
appliedScribbleStyle: z,
|
|
445
476
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
446
477
|
});
|
|
447
478
|
}
|
|
448
479
|
}
|
|
449
|
-
function
|
|
450
|
-
return e ?
|
|
480
|
+
function ae(t, e) {
|
|
481
|
+
return e ? Se(t) : ke(t);
|
|
451
482
|
}
|
|
452
|
-
function
|
|
453
|
-
t.classList.toggle("pluno-pa-widget--dark", o.colorScheme === "dark"), t.classList.toggle("pluno-pa-widget--light", o.colorScheme !== "dark"), t.classList.toggle("pluno-pa-widget--scribble", o.scribbleStyle)
|
|
454
|
-
const n =
|
|
455
|
-
|
|
456
|
-
|
|
483
|
+
function re(t, e, o) {
|
|
484
|
+
t.classList.toggle("pluno-pa-widget--dark", o.colorScheme === "dark"), t.classList.toggle("pluno-pa-widget--light", o.colorScheme !== "dark"), t.classList.toggle("pluno-pa-widget--scribble", o.scribbleStyle);
|
|
485
|
+
const n = o.scribbleStyle ? be(o.accentColor) : o.accentColor;
|
|
486
|
+
t.style.setProperty("--pluno-pa-accent", n), t.style.fontFamily = o.scribbleStyle ? Ge : o.fontFamily, o.scribbleStyle && Ue(t.ownerDocument);
|
|
487
|
+
const a = Array.from(t.querySelectorAll(".pluno-pa-widget__character"));
|
|
488
|
+
for (const r of a)
|
|
489
|
+
r.src = e;
|
|
457
490
|
}
|
|
458
|
-
function
|
|
459
|
-
if (t.getElementById(
|
|
491
|
+
function Ue(t) {
|
|
492
|
+
if (t.getElementById(oe))
|
|
460
493
|
return;
|
|
461
494
|
const e = t.createElement("style");
|
|
462
|
-
e.id =
|
|
495
|
+
e.id = oe, e.textContent = `@font-face {
|
|
463
496
|
font-family: "Architects Daughter";
|
|
464
497
|
font-style: normal;
|
|
465
498
|
font-weight: 400;
|
|
@@ -467,7 +500,7 @@ function Fe(t) {
|
|
|
467
500
|
src: url("https://fonts.gstatic.com/s/architectsdaughter/v20/KtkxAKiDZI_td1Lkx62xHZHDtgO_Y-bvTYlg4-7jA-U.woff2") format("woff2");
|
|
468
501
|
}`, t.head.appendChild(e), t.fonts?.load('16px "Architects Daughter"');
|
|
469
502
|
}
|
|
470
|
-
function
|
|
503
|
+
function P(t, e, o) {
|
|
471
504
|
if (typeof window > "u")
|
|
472
505
|
return;
|
|
473
506
|
const n = window, a = {
|
|
@@ -476,130 +509,130 @@ function M(t, e, o) {
|
|
|
476
509
|
message: e,
|
|
477
510
|
details: o
|
|
478
511
|
}, r = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
479
|
-
r.push(a), r.length > 120 && r.splice(0, r.length - 120), n.__plunoProductAgentDiagnostics__ = r, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...r], window.dispatchEvent(new CustomEvent(
|
|
512
|
+
r.push(a), r.length > 120 && r.splice(0, r.length - 120), n.__plunoProductAgentDiagnostics__ = r, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...r], window.dispatchEvent(new CustomEvent(Re, { detail: a }));
|
|
480
513
|
}
|
|
481
|
-
function
|
|
514
|
+
function U(t, e) {
|
|
482
515
|
const o = e.value.trim();
|
|
483
516
|
o && (e.value = "", e.style.height = "22px", e.style.overflowY = "hidden", t.sendMessage(o), e.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
484
517
|
}
|
|
485
|
-
function
|
|
518
|
+
function A(t) {
|
|
486
519
|
t.style.height = "0px";
|
|
487
520
|
const e = Math.max(22, Math.min(t.scrollHeight, 140));
|
|
488
521
|
t.style.height = `${e}px`, t.style.overflowY = t.scrollHeight > 140 ? "auto" : "hidden";
|
|
489
522
|
}
|
|
490
|
-
function
|
|
523
|
+
function ie(t, e, o, n, a, r, i, d) {
|
|
491
524
|
const u = [...n.messages];
|
|
492
|
-
t.innerHTML = "",
|
|
525
|
+
t.innerHTML = "", Ke(e, n.isThinking);
|
|
493
526
|
const p = u.length > 0 || !!n.assistantDraft || n.isThinking;
|
|
494
527
|
if (o.hidden = !p, u.length === 0 && !n.assistantDraft && !n.lastError && !n.isThinking) {
|
|
495
528
|
const c = document.createElement("div");
|
|
496
529
|
c.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
const
|
|
502
|
-
|
|
530
|
+
const b = document.createElement("img");
|
|
531
|
+
b.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", b.src = i(), b.alt = "", b.setAttribute("aria-hidden", "true"), c.appendChild(b);
|
|
532
|
+
const y = document.createElement("div");
|
|
533
|
+
y.className = "pluno-pa-widget__empty", y.innerHTML = "Hey there, I'm Pluno 👋<br />What do you want to do today?", c.appendChild(y);
|
|
534
|
+
const h = document.createElement("div");
|
|
535
|
+
h.className = n.starterPrompts.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", n.starterPrompts.length === 0 && h.setAttribute("aria-hidden", "true");
|
|
503
536
|
for (const w of n.starterPrompts) {
|
|
504
537
|
const m = document.createElement("button");
|
|
505
538
|
m.type = "button", m.className = "pluno-pa-widget__starter-prompt", m.textContent = `"${w}"`, m.addEventListener("click", () => {
|
|
506
539
|
d(w);
|
|
507
|
-
}),
|
|
540
|
+
}), h.appendChild(m);
|
|
508
541
|
}
|
|
509
|
-
c.appendChild(
|
|
542
|
+
c.appendChild(h), t.appendChild(c);
|
|
510
543
|
return;
|
|
511
544
|
}
|
|
512
|
-
let g = null,
|
|
545
|
+
let g = null, f = null, x = [];
|
|
513
546
|
const s = () => {
|
|
514
|
-
if (
|
|
547
|
+
if (x.length === 0)
|
|
515
548
|
return !1;
|
|
516
|
-
const c =
|
|
517
|
-
return t.appendChild(c), g = null,
|
|
549
|
+
const c = We(x, a, r, i());
|
|
550
|
+
return t.appendChild(c), g = null, f = c, x = [], !0;
|
|
518
551
|
};
|
|
519
552
|
for (let c = 0; c < u.length; c += 1) {
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
522
|
-
|
|
553
|
+
const b = u[c];
|
|
554
|
+
if (b.role === "tool") {
|
|
555
|
+
x.push(b);
|
|
523
556
|
continue;
|
|
524
557
|
}
|
|
525
|
-
if (
|
|
558
|
+
if (b.role === "system")
|
|
526
559
|
continue;
|
|
527
|
-
const
|
|
528
|
-
if (
|
|
529
|
-
const m =
|
|
530
|
-
t.appendChild(m), g = null,
|
|
560
|
+
const y = s(), h = pe(b.content);
|
|
561
|
+
if (b.role === "assistant" && !y) {
|
|
562
|
+
const m = K(i());
|
|
563
|
+
t.appendChild(m), g = null, f = m;
|
|
531
564
|
}
|
|
532
565
|
const w = document.createElement("div");
|
|
533
|
-
w.className = `pluno-pa-widget__message pluno-pa-widget__message--${
|
|
566
|
+
w.className = `pluno-pa-widget__message pluno-pa-widget__message--${b.role}`, b.role === "assistant" ? de(w, h) : w.textContent = h, w.appendChild(le(h)), t.appendChild(w), g = w, f = null;
|
|
534
567
|
}
|
|
535
568
|
const _ = s();
|
|
536
569
|
if (n.assistantDraft) {
|
|
537
570
|
if (!_) {
|
|
538
|
-
const
|
|
539
|
-
t.appendChild(
|
|
571
|
+
const y = K(i());
|
|
572
|
+
t.appendChild(y), g = null, f = y;
|
|
540
573
|
}
|
|
541
|
-
const c =
|
|
542
|
-
|
|
574
|
+
const c = pe(n.assistantDraft), b = document.createElement("div");
|
|
575
|
+
b.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", de(b, c), b.appendChild(le(c)), t.appendChild(b), g = b, f = null;
|
|
543
576
|
}
|
|
544
577
|
if (n.isThinking && !n.assistantDraft)
|
|
545
578
|
if (_) {
|
|
546
|
-
const c =
|
|
547
|
-
t.appendChild(c), g = null,
|
|
579
|
+
const c = fe();
|
|
580
|
+
t.appendChild(c), g = null, f = c;
|
|
548
581
|
} else {
|
|
549
|
-
const c =
|
|
550
|
-
t.appendChild(c), g = null,
|
|
582
|
+
const c = He(i());
|
|
583
|
+
t.appendChild(c), g = null, f = c;
|
|
551
584
|
}
|
|
552
585
|
if (n.lastError) {
|
|
553
586
|
const c = document.createElement("div");
|
|
554
|
-
c.className = "pluno-pa-widget__error", c.textContent = n.lastError, t.appendChild(c), g = c,
|
|
587
|
+
c.className = "pluno-pa-widget__error", c.textContent = n.lastError, t.appendChild(c), g = c, f = null;
|
|
555
588
|
}
|
|
556
|
-
g?.classList.add("pluno-pa-widget__message--bottom-reserve"),
|
|
589
|
+
g?.classList.add("pluno-pa-widget__message--bottom-reserve"), f?.classList.add("pluno-pa-widget__bottom-reserve-compact"), t.scrollTop = t.scrollHeight;
|
|
557
590
|
}
|
|
558
|
-
function
|
|
591
|
+
function le(t) {
|
|
559
592
|
const e = document.createElement("button");
|
|
560
593
|
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", (o) => {
|
|
561
594
|
o.preventDefault(), o.stopPropagation(), navigator.clipboard.writeText(t);
|
|
562
595
|
}), e;
|
|
563
596
|
}
|
|
564
|
-
function
|
|
597
|
+
function pe(t) {
|
|
565
598
|
return t.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
|
|
566
599
|
}
|
|
567
|
-
function
|
|
600
|
+
function We(t, e, o, n) {
|
|
568
601
|
const a = document.createElement("article");
|
|
569
602
|
a.className = "pluno-pa-widget__tool-group", a.title = new Date(t[t.length - 1].createdAt).toLocaleString();
|
|
570
603
|
const r = document.createElement("img");
|
|
571
604
|
r.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", r.src = n, r.alt = "", r.setAttribute("aria-hidden", "true"), a.appendChild(r);
|
|
572
|
-
const i = document.createElement("details"), d =
|
|
605
|
+
const i = document.createElement("details"), d = Ve(t);
|
|
573
606
|
i.open = e.has(d), i.addEventListener("toggle", () => {
|
|
574
607
|
i.open ? e.add(d) : e.delete(d), o();
|
|
575
608
|
});
|
|
576
609
|
const u = document.createElement("summary");
|
|
577
|
-
u.className = "pluno-pa-widget__tool-summary", t.some((
|
|
610
|
+
u.className = "pluno-pa-widget__tool-summary", t.some((f) => f.loading) && u.appendChild(se());
|
|
578
611
|
const g = document.createElement("span");
|
|
579
612
|
if (g.className = "pluno-pa-widget__tool-summary-title", g.textContent = t[t.length - 1].content || "Run tool", u.appendChild(g), i.appendChild(u), t.length > 0) {
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
for (const
|
|
613
|
+
const f = document.createElement("div");
|
|
614
|
+
f.className = "pluno-pa-widget__tool-lines";
|
|
615
|
+
for (const x of t) {
|
|
583
616
|
const s = document.createElement("div");
|
|
584
|
-
s.className = "pluno-pa-widget__tool-line",
|
|
617
|
+
s.className = "pluno-pa-widget__tool-line", x.loading && s.appendChild(se());
|
|
585
618
|
const _ = document.createElement("span");
|
|
586
|
-
_.textContent =
|
|
619
|
+
_.textContent = x.content || "Run tool", s.appendChild(_), f.appendChild(s);
|
|
587
620
|
}
|
|
588
|
-
i.appendChild(
|
|
621
|
+
i.appendChild(f);
|
|
589
622
|
}
|
|
590
623
|
return a.appendChild(i), a;
|
|
591
624
|
}
|
|
592
|
-
function
|
|
625
|
+
function K(t) {
|
|
593
626
|
const e = document.createElement("article");
|
|
594
627
|
e.className = "pluno-pa-widget__tool-group pluno-pa-widget__assistant-marker";
|
|
595
628
|
const o = document.createElement("img");
|
|
596
629
|
return o.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", o.src = t, o.alt = "", o.setAttribute("aria-hidden", "true"), e.appendChild(o), e;
|
|
597
630
|
}
|
|
598
|
-
function
|
|
599
|
-
const e =
|
|
600
|
-
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(
|
|
631
|
+
function He(t) {
|
|
632
|
+
const e = K(t);
|
|
633
|
+
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(fe()), e;
|
|
601
634
|
}
|
|
602
|
-
function
|
|
635
|
+
function fe() {
|
|
603
636
|
const t = document.createElement("div");
|
|
604
637
|
t.className = "pluno-pa-widget__status";
|
|
605
638
|
const e = document.createElement("span");
|
|
@@ -607,17 +640,17 @@ function ce() {
|
|
|
607
640
|
const o = document.createElement("span");
|
|
608
641
|
return o.textContent = "Thinking...", t.appendChild(o), t;
|
|
609
642
|
}
|
|
610
|
-
function
|
|
643
|
+
function Ve(t) {
|
|
611
644
|
return `tools:${t.map((e) => e.id).join("|")}`;
|
|
612
645
|
}
|
|
613
|
-
function
|
|
646
|
+
function se() {
|
|
614
647
|
const t = document.createElement("span");
|
|
615
648
|
return t.className = "pluno-pa-widget__spinner", t.setAttribute("aria-hidden", "true"), t;
|
|
616
649
|
}
|
|
617
|
-
function
|
|
650
|
+
function Ke(t, e) {
|
|
618
651
|
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>';
|
|
619
652
|
}
|
|
620
|
-
function
|
|
653
|
+
function de(t, e) {
|
|
621
654
|
const o = e.replace(/\r\n/g, `
|
|
622
655
|
`).split(`
|
|
623
656
|
`);
|
|
@@ -633,22 +666,22 @@ function re(t, e) {
|
|
|
633
666
|
for (n += 1; n < o.length && !/^```\s*$/.test(o[n]); )
|
|
634
667
|
p.push(o[n]), n += 1;
|
|
635
668
|
n += n < o.length ? 1 : 0;
|
|
636
|
-
const g = document.createElement("pre"),
|
|
637
|
-
|
|
638
|
-
`), g.appendChild(
|
|
669
|
+
const g = document.createElement("pre"), f = document.createElement("code");
|
|
670
|
+
f.textContent = p.join(`
|
|
671
|
+
`), g.appendChild(f), t.appendChild(g);
|
|
639
672
|
continue;
|
|
640
673
|
}
|
|
641
674
|
const i = a.match(/^(#{1,3})\s+(.+)$/);
|
|
642
675
|
if (i) {
|
|
643
676
|
const p = document.createElement(`h${i[1].length + 2}`);
|
|
644
|
-
|
|
677
|
+
$(p, i[2]), t.appendChild(p), n += 1;
|
|
645
678
|
continue;
|
|
646
679
|
}
|
|
647
680
|
if (/^\s*[-*+]\s+/.test(a)) {
|
|
648
681
|
const p = document.createElement("ul");
|
|
649
682
|
for (; n < o.length && /^\s*[-*+]\s+/.test(o[n]); ) {
|
|
650
683
|
const g = document.createElement("li");
|
|
651
|
-
|
|
684
|
+
$(g, o[n].replace(/^\s*[-*+]\s+/, "")), p.appendChild(g), n += 1;
|
|
652
685
|
}
|
|
653
686
|
t.appendChild(p);
|
|
654
687
|
continue;
|
|
@@ -657,7 +690,7 @@ function re(t, e) {
|
|
|
657
690
|
const p = document.createElement("ol");
|
|
658
691
|
for (; n < o.length && /^\s*\d+\.\s+/.test(o[n]); ) {
|
|
659
692
|
const g = document.createElement("li");
|
|
660
|
-
|
|
693
|
+
$(g, o[n].replace(/^\s*\d+\.\s+/, "")), p.appendChild(g), n += 1;
|
|
661
694
|
}
|
|
662
695
|
t.appendChild(p);
|
|
663
696
|
continue;
|
|
@@ -667,11 +700,11 @@ function re(t, e) {
|
|
|
667
700
|
d.push(o[n]), n += 1;
|
|
668
701
|
const u = document.createElement("p");
|
|
669
702
|
d.forEach((p, g) => {
|
|
670
|
-
g > 0 && u.appendChild(document.createElement("br")),
|
|
703
|
+
g > 0 && u.appendChild(document.createElement("br")), $(u, p);
|
|
671
704
|
}), t.appendChild(u);
|
|
672
705
|
}
|
|
673
706
|
}
|
|
674
|
-
function
|
|
707
|
+
function $(t, e) {
|
|
675
708
|
const o = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
|
|
676
709
|
let n = 0;
|
|
677
710
|
for (const a of e.matchAll(o)) {
|
|
@@ -689,7 +722,7 @@ function O(t, e) {
|
|
|
689
722
|
d.textContent = i.slice(1, -1), t.appendChild(d);
|
|
690
723
|
} else {
|
|
691
724
|
const d = i.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
|
|
692
|
-
if (d &&
|
|
725
|
+
if (d && je(d[2])) {
|
|
693
726
|
const u = document.createElement("a");
|
|
694
727
|
u.href = d[2], u.target = "_top", u.rel = "noreferrer", u.textContent = d[1], t.appendChild(u);
|
|
695
728
|
} else
|
|
@@ -699,7 +732,7 @@ function O(t, e) {
|
|
|
699
732
|
}
|
|
700
733
|
n < e.length && t.appendChild(document.createTextNode(e.slice(n)));
|
|
701
734
|
}
|
|
702
|
-
function
|
|
735
|
+
function je(t) {
|
|
703
736
|
if (t.startsWith("/") || t.startsWith("#"))
|
|
704
737
|
return !0;
|
|
705
738
|
try {
|
|
@@ -709,7 +742,7 @@ function Ue(t) {
|
|
|
709
742
|
return !1;
|
|
710
743
|
}
|
|
711
744
|
}
|
|
712
|
-
function
|
|
745
|
+
function ce(t, e) {
|
|
713
746
|
if (t.getElementById("pluno-pa-widget-styles"))
|
|
714
747
|
return;
|
|
715
748
|
const o = t.ownerDocument.createElement("style");
|
|
@@ -1504,7 +1537,7 @@ function ie(t, e) {
|
|
|
1504
1537
|
right: 16px;
|
|
1505
1538
|
height: 36px;
|
|
1506
1539
|
z-index: 3;
|
|
1507
|
-
background-image: url('${
|
|
1540
|
+
background-image: url('${ne}');
|
|
1508
1541
|
background-repeat: repeat-x;
|
|
1509
1542
|
background-size: 104px 36px;
|
|
1510
1543
|
filter: url(#pluno-pa-scribble-wobble-2);
|
|
@@ -1554,7 +1587,18 @@ function ie(t, e) {
|
|
|
1554
1587
|
margin-top: -11px;
|
|
1555
1588
|
}
|
|
1556
1589
|
.pluno-pa-widget--scribble .pluno-pa-widget__tool-group {
|
|
1557
|
-
|
|
1590
|
+
align-items: center;
|
|
1591
|
+
margin-bottom: -8px;
|
|
1592
|
+
}
|
|
1593
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__tool-group details {
|
|
1594
|
+
transform: translateY(-3px);
|
|
1595
|
+
}
|
|
1596
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__thinking-marker .pluno-pa-widget__status,
|
|
1597
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__status.pluno-pa-widget__bottom-reserve-compact {
|
|
1598
|
+
transform: translateY(-2px);
|
|
1599
|
+
}
|
|
1600
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__thinking-marker.pluno-pa-widget__bottom-reserve-compact {
|
|
1601
|
+
margin-bottom: 28px;
|
|
1558
1602
|
}
|
|
1559
1603
|
/* Wobbly outlines: the filter runs on a ::before layer that draws each
|
|
1560
1604
|
box's fill and border, so text glyphs stay crisp */
|
|
@@ -1693,7 +1737,7 @@ function ie(t, e) {
|
|
|
1693
1737
|
right: 12px;
|
|
1694
1738
|
height: 22px;
|
|
1695
1739
|
z-index: 1;
|
|
1696
|
-
background-image: url('${
|
|
1740
|
+
background-image: url('${ne}');
|
|
1697
1741
|
background-repeat: repeat-x;
|
|
1698
1742
|
background-size: 62px 21.5px;
|
|
1699
1743
|
filter: url(#pluno-pa-scribble-wobble-2);
|
|
@@ -1707,7 +1751,7 @@ function ie(t, e) {
|
|
|
1707
1751
|
}
|
|
1708
1752
|
`, t.appendChild(o);
|
|
1709
1753
|
}
|
|
1710
|
-
async function
|
|
1754
|
+
async function qe() {
|
|
1711
1755
|
return document.body ? document.body : await new Promise((t) => {
|
|
1712
1756
|
const e = new MutationObserver(() => {
|
|
1713
1757
|
document.body && (e.disconnect(), t(document.body));
|
|
@@ -1715,16 +1759,16 @@ async function We() {
|
|
|
1715
1759
|
e.observe(document.documentElement, { childList: !0 });
|
|
1716
1760
|
});
|
|
1717
1761
|
}
|
|
1718
|
-
function
|
|
1762
|
+
function D(t) {
|
|
1719
1763
|
const e = document.createElement("span");
|
|
1720
1764
|
return e.textContent = t, e.innerHTML;
|
|
1721
1765
|
}
|
|
1722
|
-
function
|
|
1766
|
+
function we(t) {
|
|
1723
1767
|
return `pluno.productAgent.widgetState.${location.origin}.${t.backendUrl ?? ""}.${t.tokenEndpoint ?? ""}.${t.position ?? ""}`;
|
|
1724
1768
|
}
|
|
1725
|
-
function
|
|
1769
|
+
function Ye(t) {
|
|
1726
1770
|
try {
|
|
1727
|
-
const e = window.localStorage.getItem(
|
|
1771
|
+
const e = window.localStorage.getItem(we(t));
|
|
1728
1772
|
if (!e)
|
|
1729
1773
|
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
1730
1774
|
const o = JSON.parse(e);
|
|
@@ -1737,35 +1781,35 @@ function He(t) {
|
|
|
1737
1781
|
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
1738
1782
|
}
|
|
1739
1783
|
}
|
|
1740
|
-
function
|
|
1784
|
+
function Ze(t, e) {
|
|
1741
1785
|
try {
|
|
1742
|
-
window.localStorage.setItem(
|
|
1786
|
+
window.localStorage.setItem(we(t), JSON.stringify(e));
|
|
1743
1787
|
} catch {
|
|
1744
1788
|
return;
|
|
1745
1789
|
}
|
|
1746
1790
|
}
|
|
1747
|
-
const
|
|
1748
|
-
function
|
|
1791
|
+
const ue = /* @__PURE__ */ new WeakSet();
|
|
1792
|
+
function Xe(t) {
|
|
1749
1793
|
return Object.keys(t.dataset).some((e) => e.startsWith("pluno"));
|
|
1750
1794
|
}
|
|
1751
|
-
function
|
|
1795
|
+
function ge(t) {
|
|
1752
1796
|
const e = t.pathname.split("/");
|
|
1753
1797
|
return e[e.length - 1] ?? "";
|
|
1754
1798
|
}
|
|
1755
|
-
function
|
|
1799
|
+
function Je(t, e) {
|
|
1756
1800
|
const o = new URL(t.src, document.baseURI);
|
|
1757
|
-
return o.href === e.href || o.pathname === e.pathname ? !0 :
|
|
1801
|
+
return o.href === e.href || o.pathname === e.pathname ? !0 : ge(o) === ge(e);
|
|
1758
1802
|
}
|
|
1759
1803
|
class C extends EventTarget {
|
|
1760
1804
|
constructor(e, o) {
|
|
1761
|
-
super(), this.channelId = o, this.url = e, this.addPreviewListener(
|
|
1805
|
+
super(), this.channelId = o, this.url = e, this.addPreviewListener(Oe, () => {
|
|
1762
1806
|
this.readyState = C.OPEN, this.dispatchEvent(new Event("open"));
|
|
1763
|
-
}), this.addPreviewListener(
|
|
1807
|
+
}), this.addPreviewListener($e, (n) => {
|
|
1764
1808
|
const a = n;
|
|
1765
1809
|
this.dispatchEvent(new MessageEvent("message", { data: a.detail?.data ?? "" }));
|
|
1766
|
-
}), this.addPreviewListener(
|
|
1810
|
+
}), this.addPreviewListener(De, () => {
|
|
1767
1811
|
this.readyState = C.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
|
|
1768
|
-
}), this.addPreviewListener(
|
|
1812
|
+
}), this.addPreviewListener(Fe, (n) => {
|
|
1769
1813
|
const a = n;
|
|
1770
1814
|
this.readyState = C.CLOSED, this.dispatchEvent(
|
|
1771
1815
|
new CloseEvent("close", {
|
|
@@ -1775,7 +1819,7 @@ class C extends EventTarget {
|
|
|
1775
1819
|
})
|
|
1776
1820
|
), this.cleanup();
|
|
1777
1821
|
}), window.dispatchEvent(
|
|
1778
|
-
new CustomEvent(
|
|
1822
|
+
new CustomEvent(F(Pe, this.channelId), {
|
|
1779
1823
|
detail: { socketId: this.socketId, url: e }
|
|
1780
1824
|
})
|
|
1781
1825
|
);
|
|
@@ -1791,26 +1835,26 @@ class C extends EventTarget {
|
|
|
1791
1835
|
binaryType = "blob";
|
|
1792
1836
|
bufferedAmount = 0;
|
|
1793
1837
|
readyState = C.CONNECTING;
|
|
1794
|
-
socketId =
|
|
1838
|
+
socketId = Qe();
|
|
1795
1839
|
listeners = /* @__PURE__ */ new Map();
|
|
1796
1840
|
send(e) {
|
|
1797
1841
|
if (this.readyState !== C.OPEN)
|
|
1798
1842
|
throw new DOMException("Product Agent preview websocket is not open", "InvalidStateError");
|
|
1799
1843
|
window.dispatchEvent(
|
|
1800
|
-
new CustomEvent(
|
|
1844
|
+
new CustomEvent(F(Ae, this.channelId), {
|
|
1801
1845
|
detail: { socketId: this.socketId, data: typeof e == "string" ? e : String(e) }
|
|
1802
1846
|
})
|
|
1803
1847
|
);
|
|
1804
1848
|
}
|
|
1805
1849
|
close(e, o) {
|
|
1806
1850
|
this.readyState !== C.CLOSED && (this.readyState = C.CLOSING, window.dispatchEvent(
|
|
1807
|
-
new CustomEvent(
|
|
1851
|
+
new CustomEvent(F(Me, this.channelId), {
|
|
1808
1852
|
detail: { socketId: this.socketId, code: e, reason: o }
|
|
1809
1853
|
})
|
|
1810
1854
|
), this.cleanup());
|
|
1811
1855
|
}
|
|
1812
1856
|
addPreviewListener(e, o) {
|
|
1813
|
-
const n =
|
|
1857
|
+
const n = F(e, this.channelId), a = (r) => {
|
|
1814
1858
|
r.detail?.socketId === this.socketId && o(r);
|
|
1815
1859
|
};
|
|
1816
1860
|
this.listeners.set(n, a), window.addEventListener(n, a);
|
|
@@ -1821,36 +1865,36 @@ class C extends EventTarget {
|
|
|
1821
1865
|
this.listeners.clear();
|
|
1822
1866
|
}
|
|
1823
1867
|
}
|
|
1824
|
-
function
|
|
1825
|
-
const t = window.sessionStorage.getItem(
|
|
1868
|
+
function Qe() {
|
|
1869
|
+
const t = window.sessionStorage.getItem(te);
|
|
1826
1870
|
if (t)
|
|
1827
1871
|
return t;
|
|
1828
1872
|
const e = crypto.randomUUID();
|
|
1829
|
-
return window.sessionStorage.setItem(
|
|
1873
|
+
return window.sessionStorage.setItem(te, e), e;
|
|
1830
1874
|
}
|
|
1831
|
-
function
|
|
1875
|
+
function F(t, e) {
|
|
1832
1876
|
return `${t}:${e}`;
|
|
1833
1877
|
}
|
|
1834
|
-
function
|
|
1878
|
+
function et(t) {
|
|
1835
1879
|
const e = document.currentScript;
|
|
1836
1880
|
if (e instanceof HTMLScriptElement)
|
|
1837
1881
|
return [e];
|
|
1838
1882
|
const o = new URL(t, document.baseURI).href, n = new URL(o);
|
|
1839
1883
|
return Array.from(document.querySelectorAll("script[type='module'][src]")).filter(
|
|
1840
|
-
(a) => a instanceof HTMLScriptElement &&
|
|
1884
|
+
(a) => a instanceof HTMLScriptElement && Xe(a) && Je(a, n)
|
|
1841
1885
|
);
|
|
1842
1886
|
}
|
|
1843
|
-
function
|
|
1844
|
-
for (const e of
|
|
1845
|
-
if (
|
|
1887
|
+
function tt(t) {
|
|
1888
|
+
for (const e of et(t)) {
|
|
1889
|
+
if (ue.has(e) || e.dataset.plunoAutoMount === "false")
|
|
1846
1890
|
continue;
|
|
1847
|
-
|
|
1891
|
+
ue.add(e);
|
|
1848
1892
|
const o = e.dataset.plunoPreviewChannel;
|
|
1849
|
-
|
|
1893
|
+
Be({
|
|
1850
1894
|
token: e.dataset.plunoToken,
|
|
1851
1895
|
tokenEndpoint: e.dataset.plunoTokenEndpoint,
|
|
1852
1896
|
backendUrl: e.dataset.plunoBackendUrl,
|
|
1853
|
-
webSocketFactory: o ?
|
|
1897
|
+
webSocketFactory: o ? ze(o) : void 0,
|
|
1854
1898
|
launcherLabel: e.dataset.plunoLauncherLabel,
|
|
1855
1899
|
accentColor: e.dataset.plunoAccentColor,
|
|
1856
1900
|
colorScheme: e.dataset.plunoColorScheme === "dark" ? "dark" : "light",
|
|
@@ -1862,8 +1906,8 @@ function Ze(t) {
|
|
|
1862
1906
|
});
|
|
1863
1907
|
}
|
|
1864
1908
|
}
|
|
1865
|
-
|
|
1909
|
+
tt(import.meta.url);
|
|
1866
1910
|
export {
|
|
1867
|
-
|
|
1868
|
-
|
|
1911
|
+
ze as createProductAgentPreviewBridgeWebSocketFactory,
|
|
1912
|
+
Be as mountPlunoProductAgentWidget
|
|
1869
1913
|
};
|