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