@pluno/product-agent-web 0.1.13 → 0.1.14
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/product-agent-widget.js +218 -193
- package/package.json +1 -1
package/dist/boltIcon.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function createProductAgentCharacterSvg(primaryColor: string): string;
|
|
2
2
|
export declare function createProductAgentCharacterDataUri(primaryColor: string): string;
|
|
3
|
+
export declare function getScribbleVisibleAccentColor(primaryColor: string): string;
|
|
3
4
|
export declare function createScribbleProductAgentCharacterSvg(primaryColor: string): string;
|
|
4
5
|
export declare function createScribbleProductAgentCharacterDataUri(primaryColor: string): string;
|
|
@@ -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
|
+
}
|
|
81
|
+
const N = "#2c2a1e", J = [253, 250, 241], Q = 3.5;
|
|
82
|
+
function he(t) {
|
|
83
|
+
const e = be(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);
|
|
80
92
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const e = se(t), o = de(W(e)) > 0.8 ? x(e, -0.3, 0.05) : e, 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";
|
|
93
|
+
function Ce(t) {
|
|
94
|
+
const e = he(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 = be(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 be(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(Pe(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 Pe(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 Ae = "product-agent:sdk-preview-socket-connect", Ie = "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,
|
|
@@ -233,7 +256,7 @@ async function De(t = {}) {
|
|
|
233
256
|
initialStarterPrompts: t.initialStarterPrompts,
|
|
234
257
|
webSocketFactory: t.webSocketFactory
|
|
235
258
|
};
|
|
236
|
-
|
|
259
|
+
A("web-sdk.widget", "Mounting widget with merged options", {
|
|
237
260
|
accentColor: e.accentColor,
|
|
238
261
|
colorScheme: e.colorScheme,
|
|
239
262
|
fontFamily: e.fontFamily,
|
|
@@ -248,7 +271,7 @@ async function De(t = {}) {
|
|
|
248
271
|
o.className = "pluno-pa-widget-host";
|
|
249
272
|
const n = o.attachShadow({ mode: "open" }), a = document.createElement("div");
|
|
250
273
|
a.className = `pluno-pa-widget pluno-pa-widget--${e.position}`;
|
|
251
|
-
let r =
|
|
274
|
+
let r = ae(e.accentColor, e.scribbleStyle);
|
|
252
275
|
a.innerHTML = `
|
|
253
276
|
<svg class="pluno-pa-widget__scribble-defs" aria-hidden="true" focusable="false" width="0" height="0">
|
|
254
277
|
<defs>
|
|
@@ -273,8 +296,8 @@ async function De(t = {}) {
|
|
|
273
296
|
</defs>
|
|
274
297
|
</svg>
|
|
275
298
|
<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="${
|
|
299
|
+
<img class="pluno-pa-widget__character pluno-pa-widget__character--launcher" src="${D(r)}" alt="" aria-hidden="true" />
|
|
300
|
+
<input class="pluno-pa-widget__launcher-input" type="text" placeholder="${D(e.launcherLabel)}" aria-label="${D(e.launcherLabel)}" />
|
|
278
301
|
</form>
|
|
279
302
|
<button type="button" class="pluno-pa-widget__close" aria-label="Close" hidden>
|
|
280
303
|
<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 +308,7 @@ async function De(t = {}) {
|
|
|
285
308
|
<div class="pluno-pa-widget__timeline-wrap">
|
|
286
309
|
<main class="pluno-pa-widget__timeline">
|
|
287
310
|
<div class="pluno-pa-widget__empty-state">
|
|
288
|
-
<img class="pluno-pa-widget__character pluno-pa-widget__character--empty" src="${
|
|
311
|
+
<img class="pluno-pa-widget__character pluno-pa-widget__character--empty" src="${D(r)}" alt="" aria-hidden="true" />
|
|
289
312
|
<div class="pluno-pa-widget__empty">Hey there, I'm Pluno 👋<br />What do you want to do today?</div>
|
|
290
313
|
</div>
|
|
291
314
|
</main>
|
|
@@ -310,22 +333,22 @@ async function De(t = {}) {
|
|
|
310
333
|
</form>
|
|
311
334
|
</section>
|
|
312
335
|
`, n.appendChild(a);
|
|
313
|
-
const i = await
|
|
314
|
-
i.appendChild(o), a.classList.add(`pluno-pa-widget--${e.colorScheme}`),
|
|
336
|
+
const i = await qe(), d = i.ownerDocument;
|
|
337
|
+
i.appendChild(o), a.classList.add(`pluno-pa-widget--${e.colorScheme}`), ce(n, e.accentColor), re(a, r, {
|
|
315
338
|
accentColor: e.accentColor,
|
|
316
339
|
colorScheme: e.colorScheme,
|
|
317
340
|
fontFamily: e.fontFamily,
|
|
318
341
|
scribbleStyle: e.scribbleStyle
|
|
319
|
-
}),
|
|
342
|
+
}), A("web-sdk.widget", "Applied initial widget appearance", {
|
|
320
343
|
accentColor: e.accentColor,
|
|
321
344
|
colorScheme: e.colorScheme,
|
|
322
345
|
fontFamily: e.fontFamily,
|
|
323
346
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
324
347
|
});
|
|
325
|
-
const u = a.querySelector(".pluno-pa-widget__launcher"), p = a.querySelector(".pluno-pa-widget__launcher-input"), g = a.querySelector(".pluno-pa-widget__panel"), b = a.querySelector(".pluno-pa-widget__close"),
|
|
326
|
-
if (!u || !p || !g || !b || !
|
|
348
|
+
const u = a.querySelector(".pluno-pa-widget__launcher"), p = a.querySelector(".pluno-pa-widget__launcher-input"), g = a.querySelector(".pluno-pa-widget__panel"), b = 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"), h = a.querySelector(".pluno-pa-widget__timeline");
|
|
349
|
+
if (!u || !p || !g || !b || !x || !s || !_ || !c || !h)
|
|
327
350
|
throw new Error("Failed to mount Product Agent widget");
|
|
328
|
-
const
|
|
351
|
+
const y = e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (async () => {
|
|
329
352
|
if (!e.tokenEndpoint)
|
|
330
353
|
throw new Error("Product Agent widget requires token or tokenEndpoint");
|
|
331
354
|
const l = await fetch(e.tokenEndpoint, {
|
|
@@ -340,25 +363,25 @@ async function De(t = {}) {
|
|
|
340
363
|
if (!k.token)
|
|
341
364
|
throw new Error("Product Agent token endpoint did not return a token");
|
|
342
365
|
return k.token;
|
|
343
|
-
}), f = await
|
|
366
|
+
}), f = await xe.init({
|
|
344
367
|
token: e.token,
|
|
345
|
-
tokenProvider:
|
|
368
|
+
tokenProvider: y,
|
|
346
369
|
backendUrl: e.backendUrl,
|
|
347
370
|
initialStarterPrompts: e.initialStarterPrompts,
|
|
348
371
|
webSocketFactory: e.webSocketFactory
|
|
349
|
-
}), w =
|
|
350
|
-
let S = null,
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
},
|
|
354
|
-
|
|
372
|
+
}), w = Ye(e), m = new Set(w.openToolGroupKeys);
|
|
373
|
+
let S = null, j = !1;
|
|
374
|
+
const me = () => {
|
|
375
|
+
j || typeof document > "u" || (ce(n, e.accentColor), o.isConnected || d.body?.appendChild(o));
|
|
376
|
+
}, q = new MutationObserver(me);
|
|
377
|
+
q.observe(d.documentElement, { childList: !0, subtree: !0 });
|
|
355
378
|
const E = () => {
|
|
356
|
-
|
|
379
|
+
Ze(e, {
|
|
357
380
|
isOpen: a.classList.contains("pluno-pa-widget--open"),
|
|
358
381
|
composerValue: s.value,
|
|
359
382
|
openToolGroupKeys: [...m]
|
|
360
383
|
});
|
|
361
|
-
},
|
|
384
|
+
}, P = (l = "", k = !0) => {
|
|
362
385
|
if (S !== null && (window.clearTimeout(S), S = null), g.hidden = !1, b.hidden = !1, a.classList.remove("pluno-pa-widget--closing"), !k) {
|
|
363
386
|
a.classList.add("pluno-pa-widget--open"), u.hidden = !0, l && (s.value = l, I(s)), h.scrollTop = h.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E();
|
|
364
387
|
return;
|
|
@@ -368,56 +391,56 @@ async function De(t = {}) {
|
|
|
368
391
|
u.hidden = !0, h.scrollTop = h.scrollHeight;
|
|
369
392
|
}, 220);
|
|
370
393
|
});
|
|
371
|
-
},
|
|
394
|
+
}, _e = () => {
|
|
372
395
|
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
396
|
g.hidden = !0, b.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
|
|
374
397
|
}, 220);
|
|
375
398
|
};
|
|
376
399
|
u.addEventListener("submit", (l) => {
|
|
377
|
-
l.preventDefault(),
|
|
400
|
+
l.preventDefault(), P(p.value), p.value = "";
|
|
378
401
|
}), u.addEventListener("click", (l) => {
|
|
379
|
-
l.target !== p && (
|
|
402
|
+
l.target !== p && (P(p.value), p.value = "");
|
|
380
403
|
}), p.addEventListener("focus", () => {
|
|
381
|
-
|
|
404
|
+
P(p.value), p.value = "";
|
|
382
405
|
}), p.addEventListener("input", () => {
|
|
383
406
|
if (!p.value)
|
|
384
407
|
return;
|
|
385
408
|
const l = p.value;
|
|
386
|
-
|
|
387
|
-
}), b.addEventListener("click",
|
|
409
|
+
P(l), p.value = "";
|
|
410
|
+
}), b.addEventListener("click", _e);
|
|
388
411
|
const L = () => {
|
|
389
412
|
_.disabled = !f.getState().isThinking && s.value.trim().length === 0;
|
|
390
413
|
};
|
|
391
|
-
|
|
392
|
-
l.preventDefault(),
|
|
414
|
+
x.addEventListener("submit", (l) => {
|
|
415
|
+
l.preventDefault(), U(f, s), L();
|
|
393
416
|
}), _.addEventListener("click", () => {
|
|
394
417
|
if (f.getState().isThinking) {
|
|
395
418
|
f.stop();
|
|
396
419
|
return;
|
|
397
420
|
}
|
|
398
|
-
|
|
421
|
+
U(f, s), L();
|
|
399
422
|
}), c.addEventListener("click", () => {
|
|
400
423
|
f.startNewSession(), m.clear(), s.value = "", I(s), E(), L(), s.focus();
|
|
401
424
|
}), s.addEventListener("input", () => {
|
|
402
425
|
I(s), E(), L();
|
|
403
426
|
}), s.addEventListener("keydown", (l) => {
|
|
404
|
-
l.key !== "Enter" || l.shiftKey || (l.preventDefault(),
|
|
427
|
+
l.key !== "Enter" || l.shiftKey || (l.preventDefault(), U(f, s), L());
|
|
405
428
|
}), a.addEventListener("click", (l) => {
|
|
406
429
|
(l.target instanceof Element ? l.target : null)?.closest("a[href]") && E();
|
|
407
|
-
}), w.composerValue && (s.value = w.composerValue, I(s)), w.isOpen &&
|
|
408
|
-
const
|
|
409
|
-
let
|
|
430
|
+
}), w.composerValue && (s.value = w.composerValue, I(s)), w.isOpen && P(s.value, !1);
|
|
431
|
+
const Y = () => r;
|
|
432
|
+
let R = f.getState().appearance !== null;
|
|
410
433
|
return f.on("state", (l) => {
|
|
411
|
-
l.appearance ? (
|
|
434
|
+
l.appearance ? (R = !0, A("web-sdk.widget", "Agent state supplied appearance", {
|
|
412
435
|
appearance: l.appearance
|
|
413
|
-
}), G(l.appearance, "agent.state.appearance")) :
|
|
436
|
+
}), G(l.appearance, "agent.state.appearance")) : R && (R = !1, A("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
|
|
414
437
|
fallbackAccentColor: e.accentColor,
|
|
415
438
|
fallbackColorScheme: e.colorScheme,
|
|
416
439
|
fallbackFontFamily: e.fontFamily
|
|
417
|
-
}), G({}, "agent.state.appearance-cleared")),
|
|
440
|
+
}), G({}, "agent.state.appearance-cleared")), ie(h, _, c, l, m, E, Y, (k) => {
|
|
418
441
|
f.sendMessage(k);
|
|
419
442
|
}), L();
|
|
420
|
-
}),
|
|
443
|
+
}), ie(h, _, c, f.getState(), m, E, Y, (l) => {
|
|
421
444
|
f.sendMessage(l);
|
|
422
445
|
}), L(), {
|
|
423
446
|
agent: f,
|
|
@@ -425,41 +448,43 @@ async function De(t = {}) {
|
|
|
425
448
|
l.scribbleStyle !== void 0 && (e.scribbleStyle = l.scribbleStyle), G(l, "widgetHandle.updateAppearance");
|
|
426
449
|
},
|
|
427
450
|
destroy: () => {
|
|
428
|
-
|
|
451
|
+
j = !0, q.disconnect(), f.destroy(), o.remove();
|
|
429
452
|
}
|
|
430
453
|
};
|
|
431
454
|
function G(l, k) {
|
|
432
|
-
const
|
|
433
|
-
r =
|
|
434
|
-
accentColor:
|
|
435
|
-
colorScheme:
|
|
436
|
-
fontFamily:
|
|
455
|
+
const O = l.accentColor ?? e.accentColor, Z = l.colorScheme ?? e.colorScheme, X = l.fontFamily ?? e.fontFamily, z = l.scribbleStyle ?? e.scribbleStyle;
|
|
456
|
+
r = ae(O, z), re(a, r, {
|
|
457
|
+
accentColor: O,
|
|
458
|
+
colorScheme: Z,
|
|
459
|
+
fontFamily: X,
|
|
437
460
|
scribbleStyle: z
|
|
438
|
-
}),
|
|
461
|
+
}), A("web-sdk.widget", "Updated widget appearance", {
|
|
439
462
|
source: k,
|
|
440
463
|
inputAppearance: l,
|
|
441
|
-
appliedAccentColor:
|
|
442
|
-
appliedColorScheme:
|
|
443
|
-
appliedFontFamily:
|
|
464
|
+
appliedAccentColor: O,
|
|
465
|
+
appliedColorScheme: Z,
|
|
466
|
+
appliedFontFamily: X,
|
|
444
467
|
appliedScribbleStyle: z,
|
|
445
468
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
446
469
|
});
|
|
447
470
|
}
|
|
448
471
|
}
|
|
449
|
-
function
|
|
450
|
-
return e ?
|
|
472
|
+
function ae(t, e) {
|
|
473
|
+
return e ? Se(t) : ke(t);
|
|
451
474
|
}
|
|
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
|
-
|
|
475
|
+
function re(t, e, o) {
|
|
476
|
+
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);
|
|
477
|
+
const n = o.scribbleStyle ? he(o.accentColor) : o.accentColor;
|
|
478
|
+
t.style.setProperty("--pluno-pa-accent", n), t.style.fontFamily = o.scribbleStyle ? Ge : o.fontFamily, o.scribbleStyle && Ue(t.ownerDocument);
|
|
479
|
+
const a = Array.from(t.querySelectorAll(".pluno-pa-widget__character"));
|
|
480
|
+
for (const r of a)
|
|
481
|
+
r.src = e;
|
|
457
482
|
}
|
|
458
|
-
function
|
|
459
|
-
if (t.getElementById(
|
|
483
|
+
function Ue(t) {
|
|
484
|
+
if (t.getElementById(oe))
|
|
460
485
|
return;
|
|
461
486
|
const e = t.createElement("style");
|
|
462
|
-
e.id =
|
|
487
|
+
e.id = oe, e.textContent = `@font-face {
|
|
463
488
|
font-family: "Architects Daughter";
|
|
464
489
|
font-style: normal;
|
|
465
490
|
font-weight: 400;
|
|
@@ -467,7 +492,7 @@ function Fe(t) {
|
|
|
467
492
|
src: url("https://fonts.gstatic.com/s/architectsdaughter/v20/KtkxAKiDZI_td1Lkx62xHZHDtgO_Y-bvTYlg4-7jA-U.woff2") format("woff2");
|
|
468
493
|
}`, t.head.appendChild(e), t.fonts?.load('16px "Architects Daughter"');
|
|
469
494
|
}
|
|
470
|
-
function
|
|
495
|
+
function A(t, e, o) {
|
|
471
496
|
if (typeof window > "u")
|
|
472
497
|
return;
|
|
473
498
|
const n = window, a = {
|
|
@@ -476,9 +501,9 @@ function M(t, e, o) {
|
|
|
476
501
|
message: e,
|
|
477
502
|
details: o
|
|
478
503
|
}, 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(
|
|
504
|
+
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
505
|
}
|
|
481
|
-
function
|
|
506
|
+
function U(t, e) {
|
|
482
507
|
const o = e.value.trim();
|
|
483
508
|
o && (e.value = "", e.style.height = "22px", e.style.overflowY = "hidden", t.sendMessage(o), e.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
484
509
|
}
|
|
@@ -487,17 +512,17 @@ function I(t) {
|
|
|
487
512
|
const e = Math.max(22, Math.min(t.scrollHeight, 140));
|
|
488
513
|
t.style.height = `${e}px`, t.style.overflowY = t.scrollHeight > 140 ? "auto" : "hidden";
|
|
489
514
|
}
|
|
490
|
-
function
|
|
515
|
+
function ie(t, e, o, n, a, r, i, d) {
|
|
491
516
|
const u = [...n.messages];
|
|
492
|
-
t.innerHTML = "",
|
|
517
|
+
t.innerHTML = "", Ke(e, n.isThinking);
|
|
493
518
|
const p = u.length > 0 || !!n.assistantDraft || n.isThinking;
|
|
494
519
|
if (o.hidden = !p, u.length === 0 && !n.assistantDraft && !n.lastError && !n.isThinking) {
|
|
495
520
|
const c = document.createElement("div");
|
|
496
521
|
c.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
497
522
|
const h = document.createElement("img");
|
|
498
523
|
h.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", h.src = i(), h.alt = "", h.setAttribute("aria-hidden", "true"), c.appendChild(h);
|
|
499
|
-
const
|
|
500
|
-
|
|
524
|
+
const y = document.createElement("div");
|
|
525
|
+
y.className = "pluno-pa-widget__empty", y.innerHTML = "Hey there, I'm Pluno 👋<br />What do you want to do today?", c.appendChild(y);
|
|
501
526
|
const f = document.createElement("div");
|
|
502
527
|
f.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 && f.setAttribute("aria-hidden", "true");
|
|
503
528
|
for (const w of n.starterPrompts) {
|
|
@@ -509,44 +534,44 @@ function te(t, e, o, n, a, r, i, d) {
|
|
|
509
534
|
c.appendChild(f), t.appendChild(c);
|
|
510
535
|
return;
|
|
511
536
|
}
|
|
512
|
-
let g = null, b = null,
|
|
537
|
+
let g = null, b = null, x = [];
|
|
513
538
|
const s = () => {
|
|
514
|
-
if (
|
|
539
|
+
if (x.length === 0)
|
|
515
540
|
return !1;
|
|
516
|
-
const c =
|
|
517
|
-
return t.appendChild(c), g = null, b = c,
|
|
541
|
+
const c = We(x, a, r, i());
|
|
542
|
+
return t.appendChild(c), g = null, b = c, x = [], !0;
|
|
518
543
|
};
|
|
519
544
|
for (let c = 0; c < u.length; c += 1) {
|
|
520
545
|
const h = u[c];
|
|
521
546
|
if (h.role === "tool") {
|
|
522
|
-
|
|
547
|
+
x.push(h);
|
|
523
548
|
continue;
|
|
524
549
|
}
|
|
525
550
|
if (h.role === "system")
|
|
526
551
|
continue;
|
|
527
|
-
const
|
|
528
|
-
if (h.role === "assistant" && !
|
|
529
|
-
const m =
|
|
552
|
+
const y = s(), f = pe(h.content);
|
|
553
|
+
if (h.role === "assistant" && !y) {
|
|
554
|
+
const m = K(i());
|
|
530
555
|
t.appendChild(m), g = null, b = m;
|
|
531
556
|
}
|
|
532
557
|
const w = document.createElement("div");
|
|
533
|
-
w.className = `pluno-pa-widget__message pluno-pa-widget__message--${h.role}`, h.role === "assistant" ?
|
|
558
|
+
w.className = `pluno-pa-widget__message pluno-pa-widget__message--${h.role}`, h.role === "assistant" ? de(w, f) : w.textContent = f, w.appendChild(le(f)), t.appendChild(w), g = w, b = null;
|
|
534
559
|
}
|
|
535
560
|
const _ = s();
|
|
536
561
|
if (n.assistantDraft) {
|
|
537
562
|
if (!_) {
|
|
538
|
-
const
|
|
539
|
-
t.appendChild(
|
|
563
|
+
const y = K(i());
|
|
564
|
+
t.appendChild(y), g = null, b = y;
|
|
540
565
|
}
|
|
541
|
-
const c =
|
|
542
|
-
h.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant",
|
|
566
|
+
const c = pe(n.assistantDraft), h = document.createElement("div");
|
|
567
|
+
h.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", de(h, c), h.appendChild(le(c)), t.appendChild(h), g = h, b = null;
|
|
543
568
|
}
|
|
544
569
|
if (n.isThinking && !n.assistantDraft)
|
|
545
570
|
if (_) {
|
|
546
|
-
const c =
|
|
571
|
+
const c = fe();
|
|
547
572
|
t.appendChild(c), g = null, b = c;
|
|
548
573
|
} else {
|
|
549
|
-
const c =
|
|
574
|
+
const c = He(i());
|
|
550
575
|
t.appendChild(c), g = null, b = c;
|
|
551
576
|
}
|
|
552
577
|
if (n.lastError) {
|
|
@@ -555,51 +580,51 @@ function te(t, e, o, n, a, r, i, d) {
|
|
|
555
580
|
}
|
|
556
581
|
g?.classList.add("pluno-pa-widget__message--bottom-reserve"), b?.classList.add("pluno-pa-widget__bottom-reserve-compact"), t.scrollTop = t.scrollHeight;
|
|
557
582
|
}
|
|
558
|
-
function
|
|
583
|
+
function le(t) {
|
|
559
584
|
const e = document.createElement("button");
|
|
560
585
|
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
586
|
o.preventDefault(), o.stopPropagation(), navigator.clipboard.writeText(t);
|
|
562
587
|
}), e;
|
|
563
588
|
}
|
|
564
|
-
function
|
|
589
|
+
function pe(t) {
|
|
565
590
|
return t.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
|
|
566
591
|
}
|
|
567
|
-
function
|
|
592
|
+
function We(t, e, o, n) {
|
|
568
593
|
const a = document.createElement("article");
|
|
569
594
|
a.className = "pluno-pa-widget__tool-group", a.title = new Date(t[t.length - 1].createdAt).toLocaleString();
|
|
570
595
|
const r = document.createElement("img");
|
|
571
596
|
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 =
|
|
597
|
+
const i = document.createElement("details"), d = Ve(t);
|
|
573
598
|
i.open = e.has(d), i.addEventListener("toggle", () => {
|
|
574
599
|
i.open ? e.add(d) : e.delete(d), o();
|
|
575
600
|
});
|
|
576
601
|
const u = document.createElement("summary");
|
|
577
|
-
u.className = "pluno-pa-widget__tool-summary", t.some((b) => b.loading) && u.appendChild(
|
|
602
|
+
u.className = "pluno-pa-widget__tool-summary", t.some((b) => b.loading) && u.appendChild(se());
|
|
578
603
|
const g = document.createElement("span");
|
|
579
604
|
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
605
|
const b = document.createElement("div");
|
|
581
606
|
b.className = "pluno-pa-widget__tool-lines";
|
|
582
|
-
for (const
|
|
607
|
+
for (const x of t) {
|
|
583
608
|
const s = document.createElement("div");
|
|
584
|
-
s.className = "pluno-pa-widget__tool-line",
|
|
609
|
+
s.className = "pluno-pa-widget__tool-line", x.loading && s.appendChild(se());
|
|
585
610
|
const _ = document.createElement("span");
|
|
586
|
-
_.textContent =
|
|
611
|
+
_.textContent = x.content || "Run tool", s.appendChild(_), b.appendChild(s);
|
|
587
612
|
}
|
|
588
613
|
i.appendChild(b);
|
|
589
614
|
}
|
|
590
615
|
return a.appendChild(i), a;
|
|
591
616
|
}
|
|
592
|
-
function
|
|
617
|
+
function K(t) {
|
|
593
618
|
const e = document.createElement("article");
|
|
594
619
|
e.className = "pluno-pa-widget__tool-group pluno-pa-widget__assistant-marker";
|
|
595
620
|
const o = document.createElement("img");
|
|
596
621
|
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
622
|
}
|
|
598
|
-
function
|
|
599
|
-
const e =
|
|
600
|
-
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(
|
|
623
|
+
function He(t) {
|
|
624
|
+
const e = K(t);
|
|
625
|
+
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(fe()), e;
|
|
601
626
|
}
|
|
602
|
-
function
|
|
627
|
+
function fe() {
|
|
603
628
|
const t = document.createElement("div");
|
|
604
629
|
t.className = "pluno-pa-widget__status";
|
|
605
630
|
const e = document.createElement("span");
|
|
@@ -607,17 +632,17 @@ function ce() {
|
|
|
607
632
|
const o = document.createElement("span");
|
|
608
633
|
return o.textContent = "Thinking...", t.appendChild(o), t;
|
|
609
634
|
}
|
|
610
|
-
function
|
|
635
|
+
function Ve(t) {
|
|
611
636
|
return `tools:${t.map((e) => e.id).join("|")}`;
|
|
612
637
|
}
|
|
613
|
-
function
|
|
638
|
+
function se() {
|
|
614
639
|
const t = document.createElement("span");
|
|
615
640
|
return t.className = "pluno-pa-widget__spinner", t.setAttribute("aria-hidden", "true"), t;
|
|
616
641
|
}
|
|
617
|
-
function
|
|
642
|
+
function Ke(t, e) {
|
|
618
643
|
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
644
|
}
|
|
620
|
-
function
|
|
645
|
+
function de(t, e) {
|
|
621
646
|
const o = e.replace(/\r\n/g, `
|
|
622
647
|
`).split(`
|
|
623
648
|
`);
|
|
@@ -641,14 +666,14 @@ function re(t, e) {
|
|
|
641
666
|
const i = a.match(/^(#{1,3})\s+(.+)$/);
|
|
642
667
|
if (i) {
|
|
643
668
|
const p = document.createElement(`h${i[1].length + 2}`);
|
|
644
|
-
|
|
669
|
+
$(p, i[2]), t.appendChild(p), n += 1;
|
|
645
670
|
continue;
|
|
646
671
|
}
|
|
647
672
|
if (/^\s*[-*+]\s+/.test(a)) {
|
|
648
673
|
const p = document.createElement("ul");
|
|
649
674
|
for (; n < o.length && /^\s*[-*+]\s+/.test(o[n]); ) {
|
|
650
675
|
const g = document.createElement("li");
|
|
651
|
-
|
|
676
|
+
$(g, o[n].replace(/^\s*[-*+]\s+/, "")), p.appendChild(g), n += 1;
|
|
652
677
|
}
|
|
653
678
|
t.appendChild(p);
|
|
654
679
|
continue;
|
|
@@ -657,7 +682,7 @@ function re(t, e) {
|
|
|
657
682
|
const p = document.createElement("ol");
|
|
658
683
|
for (; n < o.length && /^\s*\d+\.\s+/.test(o[n]); ) {
|
|
659
684
|
const g = document.createElement("li");
|
|
660
|
-
|
|
685
|
+
$(g, o[n].replace(/^\s*\d+\.\s+/, "")), p.appendChild(g), n += 1;
|
|
661
686
|
}
|
|
662
687
|
t.appendChild(p);
|
|
663
688
|
continue;
|
|
@@ -667,11 +692,11 @@ function re(t, e) {
|
|
|
667
692
|
d.push(o[n]), n += 1;
|
|
668
693
|
const u = document.createElement("p");
|
|
669
694
|
d.forEach((p, g) => {
|
|
670
|
-
g > 0 && u.appendChild(document.createElement("br")),
|
|
695
|
+
g > 0 && u.appendChild(document.createElement("br")), $(u, p);
|
|
671
696
|
}), t.appendChild(u);
|
|
672
697
|
}
|
|
673
698
|
}
|
|
674
|
-
function
|
|
699
|
+
function $(t, e) {
|
|
675
700
|
const o = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
|
|
676
701
|
let n = 0;
|
|
677
702
|
for (const a of e.matchAll(o)) {
|
|
@@ -689,7 +714,7 @@ function O(t, e) {
|
|
|
689
714
|
d.textContent = i.slice(1, -1), t.appendChild(d);
|
|
690
715
|
} else {
|
|
691
716
|
const d = i.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
|
|
692
|
-
if (d &&
|
|
717
|
+
if (d && je(d[2])) {
|
|
693
718
|
const u = document.createElement("a");
|
|
694
719
|
u.href = d[2], u.target = "_top", u.rel = "noreferrer", u.textContent = d[1], t.appendChild(u);
|
|
695
720
|
} else
|
|
@@ -699,7 +724,7 @@ function O(t, e) {
|
|
|
699
724
|
}
|
|
700
725
|
n < e.length && t.appendChild(document.createTextNode(e.slice(n)));
|
|
701
726
|
}
|
|
702
|
-
function
|
|
727
|
+
function je(t) {
|
|
703
728
|
if (t.startsWith("/") || t.startsWith("#"))
|
|
704
729
|
return !0;
|
|
705
730
|
try {
|
|
@@ -709,7 +734,7 @@ function Ue(t) {
|
|
|
709
734
|
return !1;
|
|
710
735
|
}
|
|
711
736
|
}
|
|
712
|
-
function
|
|
737
|
+
function ce(t, e) {
|
|
713
738
|
if (t.getElementById("pluno-pa-widget-styles"))
|
|
714
739
|
return;
|
|
715
740
|
const o = t.ownerDocument.createElement("style");
|
|
@@ -1504,7 +1529,7 @@ function ie(t, e) {
|
|
|
1504
1529
|
right: 16px;
|
|
1505
1530
|
height: 36px;
|
|
1506
1531
|
z-index: 3;
|
|
1507
|
-
background-image: url('${
|
|
1532
|
+
background-image: url('${ne}');
|
|
1508
1533
|
background-repeat: repeat-x;
|
|
1509
1534
|
background-size: 104px 36px;
|
|
1510
1535
|
filter: url(#pluno-pa-scribble-wobble-2);
|
|
@@ -1693,7 +1718,7 @@ function ie(t, e) {
|
|
|
1693
1718
|
right: 12px;
|
|
1694
1719
|
height: 22px;
|
|
1695
1720
|
z-index: 1;
|
|
1696
|
-
background-image: url('${
|
|
1721
|
+
background-image: url('${ne}');
|
|
1697
1722
|
background-repeat: repeat-x;
|
|
1698
1723
|
background-size: 62px 21.5px;
|
|
1699
1724
|
filter: url(#pluno-pa-scribble-wobble-2);
|
|
@@ -1707,7 +1732,7 @@ function ie(t, e) {
|
|
|
1707
1732
|
}
|
|
1708
1733
|
`, t.appendChild(o);
|
|
1709
1734
|
}
|
|
1710
|
-
async function
|
|
1735
|
+
async function qe() {
|
|
1711
1736
|
return document.body ? document.body : await new Promise((t) => {
|
|
1712
1737
|
const e = new MutationObserver(() => {
|
|
1713
1738
|
document.body && (e.disconnect(), t(document.body));
|
|
@@ -1715,16 +1740,16 @@ async function We() {
|
|
|
1715
1740
|
e.observe(document.documentElement, { childList: !0 });
|
|
1716
1741
|
});
|
|
1717
1742
|
}
|
|
1718
|
-
function
|
|
1743
|
+
function D(t) {
|
|
1719
1744
|
const e = document.createElement("span");
|
|
1720
1745
|
return e.textContent = t, e.innerHTML;
|
|
1721
1746
|
}
|
|
1722
|
-
function
|
|
1747
|
+
function we(t) {
|
|
1723
1748
|
return `pluno.productAgent.widgetState.${location.origin}.${t.backendUrl ?? ""}.${t.tokenEndpoint ?? ""}.${t.position ?? ""}`;
|
|
1724
1749
|
}
|
|
1725
|
-
function
|
|
1750
|
+
function Ye(t) {
|
|
1726
1751
|
try {
|
|
1727
|
-
const e = window.localStorage.getItem(
|
|
1752
|
+
const e = window.localStorage.getItem(we(t));
|
|
1728
1753
|
if (!e)
|
|
1729
1754
|
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
1730
1755
|
const o = JSON.parse(e);
|
|
@@ -1737,35 +1762,35 @@ function He(t) {
|
|
|
1737
1762
|
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
1738
1763
|
}
|
|
1739
1764
|
}
|
|
1740
|
-
function
|
|
1765
|
+
function Ze(t, e) {
|
|
1741
1766
|
try {
|
|
1742
|
-
window.localStorage.setItem(
|
|
1767
|
+
window.localStorage.setItem(we(t), JSON.stringify(e));
|
|
1743
1768
|
} catch {
|
|
1744
1769
|
return;
|
|
1745
1770
|
}
|
|
1746
1771
|
}
|
|
1747
|
-
const
|
|
1748
|
-
function
|
|
1772
|
+
const ue = /* @__PURE__ */ new WeakSet();
|
|
1773
|
+
function Xe(t) {
|
|
1749
1774
|
return Object.keys(t.dataset).some((e) => e.startsWith("pluno"));
|
|
1750
1775
|
}
|
|
1751
|
-
function
|
|
1776
|
+
function ge(t) {
|
|
1752
1777
|
const e = t.pathname.split("/");
|
|
1753
1778
|
return e[e.length - 1] ?? "";
|
|
1754
1779
|
}
|
|
1755
|
-
function
|
|
1780
|
+
function Je(t, e) {
|
|
1756
1781
|
const o = new URL(t.src, document.baseURI);
|
|
1757
|
-
return o.href === e.href || o.pathname === e.pathname ? !0 :
|
|
1782
|
+
return o.href === e.href || o.pathname === e.pathname ? !0 : ge(o) === ge(e);
|
|
1758
1783
|
}
|
|
1759
1784
|
class C extends EventTarget {
|
|
1760
1785
|
constructor(e, o) {
|
|
1761
|
-
super(), this.channelId = o, this.url = e, this.addPreviewListener(
|
|
1786
|
+
super(), this.channelId = o, this.url = e, this.addPreviewListener(Oe, () => {
|
|
1762
1787
|
this.readyState = C.OPEN, this.dispatchEvent(new Event("open"));
|
|
1763
|
-
}), this.addPreviewListener(
|
|
1788
|
+
}), this.addPreviewListener($e, (n) => {
|
|
1764
1789
|
const a = n;
|
|
1765
1790
|
this.dispatchEvent(new MessageEvent("message", { data: a.detail?.data ?? "" }));
|
|
1766
|
-
}), this.addPreviewListener(
|
|
1791
|
+
}), this.addPreviewListener(De, () => {
|
|
1767
1792
|
this.readyState = C.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
|
|
1768
|
-
}), this.addPreviewListener(
|
|
1793
|
+
}), this.addPreviewListener(Fe, (n) => {
|
|
1769
1794
|
const a = n;
|
|
1770
1795
|
this.readyState = C.CLOSED, this.dispatchEvent(
|
|
1771
1796
|
new CloseEvent("close", {
|
|
@@ -1775,7 +1800,7 @@ class C extends EventTarget {
|
|
|
1775
1800
|
})
|
|
1776
1801
|
), this.cleanup();
|
|
1777
1802
|
}), window.dispatchEvent(
|
|
1778
|
-
new CustomEvent(
|
|
1803
|
+
new CustomEvent(F(Ae, this.channelId), {
|
|
1779
1804
|
detail: { socketId: this.socketId, url: e }
|
|
1780
1805
|
})
|
|
1781
1806
|
);
|
|
@@ -1791,26 +1816,26 @@ class C extends EventTarget {
|
|
|
1791
1816
|
binaryType = "blob";
|
|
1792
1817
|
bufferedAmount = 0;
|
|
1793
1818
|
readyState = C.CONNECTING;
|
|
1794
|
-
socketId =
|
|
1819
|
+
socketId = Qe();
|
|
1795
1820
|
listeners = /* @__PURE__ */ new Map();
|
|
1796
1821
|
send(e) {
|
|
1797
1822
|
if (this.readyState !== C.OPEN)
|
|
1798
1823
|
throw new DOMException("Product Agent preview websocket is not open", "InvalidStateError");
|
|
1799
1824
|
window.dispatchEvent(
|
|
1800
|
-
new CustomEvent(
|
|
1825
|
+
new CustomEvent(F(Ie, this.channelId), {
|
|
1801
1826
|
detail: { socketId: this.socketId, data: typeof e == "string" ? e : String(e) }
|
|
1802
1827
|
})
|
|
1803
1828
|
);
|
|
1804
1829
|
}
|
|
1805
1830
|
close(e, o) {
|
|
1806
1831
|
this.readyState !== C.CLOSED && (this.readyState = C.CLOSING, window.dispatchEvent(
|
|
1807
|
-
new CustomEvent(
|
|
1832
|
+
new CustomEvent(F(Me, this.channelId), {
|
|
1808
1833
|
detail: { socketId: this.socketId, code: e, reason: o }
|
|
1809
1834
|
})
|
|
1810
1835
|
), this.cleanup());
|
|
1811
1836
|
}
|
|
1812
1837
|
addPreviewListener(e, o) {
|
|
1813
|
-
const n =
|
|
1838
|
+
const n = F(e, this.channelId), a = (r) => {
|
|
1814
1839
|
r.detail?.socketId === this.socketId && o(r);
|
|
1815
1840
|
};
|
|
1816
1841
|
this.listeners.set(n, a), window.addEventListener(n, a);
|
|
@@ -1821,36 +1846,36 @@ class C extends EventTarget {
|
|
|
1821
1846
|
this.listeners.clear();
|
|
1822
1847
|
}
|
|
1823
1848
|
}
|
|
1824
|
-
function
|
|
1825
|
-
const t = window.sessionStorage.getItem(
|
|
1849
|
+
function Qe() {
|
|
1850
|
+
const t = window.sessionStorage.getItem(te);
|
|
1826
1851
|
if (t)
|
|
1827
1852
|
return t;
|
|
1828
1853
|
const e = crypto.randomUUID();
|
|
1829
|
-
return window.sessionStorage.setItem(
|
|
1854
|
+
return window.sessionStorage.setItem(te, e), e;
|
|
1830
1855
|
}
|
|
1831
|
-
function
|
|
1856
|
+
function F(t, e) {
|
|
1832
1857
|
return `${t}:${e}`;
|
|
1833
1858
|
}
|
|
1834
|
-
function
|
|
1859
|
+
function et(t) {
|
|
1835
1860
|
const e = document.currentScript;
|
|
1836
1861
|
if (e instanceof HTMLScriptElement)
|
|
1837
1862
|
return [e];
|
|
1838
1863
|
const o = new URL(t, document.baseURI).href, n = new URL(o);
|
|
1839
1864
|
return Array.from(document.querySelectorAll("script[type='module'][src]")).filter(
|
|
1840
|
-
(a) => a instanceof HTMLScriptElement &&
|
|
1865
|
+
(a) => a instanceof HTMLScriptElement && Xe(a) && Je(a, n)
|
|
1841
1866
|
);
|
|
1842
1867
|
}
|
|
1843
|
-
function
|
|
1844
|
-
for (const e of
|
|
1845
|
-
if (
|
|
1868
|
+
function tt(t) {
|
|
1869
|
+
for (const e of et(t)) {
|
|
1870
|
+
if (ue.has(e) || e.dataset.plunoAutoMount === "false")
|
|
1846
1871
|
continue;
|
|
1847
|
-
|
|
1872
|
+
ue.add(e);
|
|
1848
1873
|
const o = e.dataset.plunoPreviewChannel;
|
|
1849
|
-
|
|
1874
|
+
Be({
|
|
1850
1875
|
token: e.dataset.plunoToken,
|
|
1851
1876
|
tokenEndpoint: e.dataset.plunoTokenEndpoint,
|
|
1852
1877
|
backendUrl: e.dataset.plunoBackendUrl,
|
|
1853
|
-
webSocketFactory: o ?
|
|
1878
|
+
webSocketFactory: o ? ze(o) : void 0,
|
|
1854
1879
|
launcherLabel: e.dataset.plunoLauncherLabel,
|
|
1855
1880
|
accentColor: e.dataset.plunoAccentColor,
|
|
1856
1881
|
colorScheme: e.dataset.plunoColorScheme === "dark" ? "dark" : "light",
|
|
@@ -1862,8 +1887,8 @@ function Ze(t) {
|
|
|
1862
1887
|
});
|
|
1863
1888
|
}
|
|
1864
1889
|
}
|
|
1865
|
-
|
|
1890
|
+
tt(import.meta.url);
|
|
1866
1891
|
export {
|
|
1867
|
-
|
|
1868
|
-
|
|
1892
|
+
ze as createProductAgentPreviewBridgeWebSocketFactory,
|
|
1893
|
+
Be as mountPlunoProductAgentWidget
|
|
1869
1894
|
};
|
package/package.json
CHANGED