@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.
@@ -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 be } from "./product-agent-sdk.js";
2
- const fe = "#7c3aed";
3
- function we(t) {
4
- const e = ve(t);
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 me(t) {
79
- return `data:image/svg+xml,${encodeURIComponent(we(t))}`;
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
- const P = "#2c2a1e";
82
- function _e(t) {
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="${n}"/>
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="${ye()}" fill="none" stroke="${o}" stroke-width="56" stroke-linecap="round" stroke-linejoin="round" opacity="0.9" transform="rotate(-14 627 600)"/>
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="${n}" fill="none" stroke="${P}" stroke-width="18" stroke-linejoin="round"/>
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="${P}" stroke-width="13"/>
101
- <ellipse cx="533" cy="473" rx="45" ry="53" fill="${P}"/>
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="${P}" stroke-width="13"/>
106
- <ellipse cx="712" cy="473" rx="45" ry="53" fill="${P}"/>
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 xe(t) {
113
- return `data:image/svg+xml,${encodeURIComponent(_e(t))}`;
123
+ function Se(t) {
124
+ return `data:image/svg+xml,${encodeURIComponent(Ce(t))}`;
114
125
  }
115
- function ye() {
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 ve(t) {
124
- const e = se(t), o = de(W(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: x(e, 0.28, -0.03),
149
- middle: x(e, 0.08, 0.04),
150
- bottom: x(e, -0.1, 0.02),
151
- edgeStart: x(e, 0.08, 0.08),
152
- edgeMiddle: x(e, -0.08, 0.08),
153
- edgeEnd: x(e, -0.18, 0.05),
154
- glow: x(e, 0.32, -0.12),
155
- highlight: x(e, 0.38, -0.18),
156
- inner: x(e, 0.24, -0.1),
157
- shadow: x(e, -0.25, -0.08)
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 se(t) {
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()}` : fe;
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 W(t) {
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 ke([t, e, o]) {
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 de([t, e, o]) {
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 x(t, e, o) {
183
- const [n, a, r] = Ce(W(t));
184
- return ke(Se(n, Y(a + o), Y(r + e)));
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 Ce([t, e, o]) {
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 Se(t, e, o) {
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
- R(a, n, t + 1 / 3) * 255,
199
- R(a, n, t) * 255,
200
- R(a, n, t - 1 / 3) * 255
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 R(t, e, o) {
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 Y(t) {
230
+ function V(t) {
208
231
  return Math.max(0, Math.min(1, t));
209
232
  }
210
- const Ee = "product-agent:sdk-preview-socket-connect", Le = "product-agent:sdk-preview-socket-send", Te = "product-agent:sdk-preview-socket-close", Ne = "product-agent:sdk-preview-socket-open", Pe = "product-agent:sdk-preview-socket-message", Me = "product-agent:sdk-preview-socket-error", Ie = "product-agent:sdk-preview-socket-closed", Z = "product-agent:sdk-preview-socket-id", Ae = "product-agent:preview-diagnostic", T = {
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
- }, X = '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>', Oe = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', J = "pluno-pa-scribble-font";
218
- function $e(t) {
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 De(t = {}) {
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
- M("web-sdk.widget", "Mounting widget with merged options", {
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 = Q(e.accentColor, e.scribbleStyle);
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="${$(r)}" alt="" aria-hidden="true" />
277
- <input class="pluno-pa-widget__launcher-input" type="text" placeholder="${$(e.launcherLabel)}" aria-label="${$(e.launcherLabel)}" />
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="${$(r)}" alt="" aria-hidden="true" />
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 We(), d = i.ownerDocument;
314
- i.appendChild(o), a.classList.add(`pluno-pa-widget--${e.colorScheme}`), ie(n, e.accentColor), ee(a, r, {
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
- }), M("web-sdk.widget", "Applied initial widget appearance", {
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"), y = 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");
326
- if (!u || !p || !g || !b || !y || !s || !_ || !c || !h)
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 v = e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (async () => {
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 be.init({
366
+ }), f = await xe.init({
344
367
  token: e.token,
345
- tokenProvider: v,
368
+ tokenProvider: y,
346
369
  backendUrl: e.backendUrl,
347
370
  initialStarterPrompts: e.initialStarterPrompts,
348
371
  webSocketFactory: e.webSocketFactory
349
- }), w = He(e), m = new Set(w.openToolGroupKeys);
350
- let S = null, H = !1;
351
- const ge = () => {
352
- H || typeof document > "u" || (ie(n, e.accentColor), o.isConnected || d.body?.appendChild(o));
353
- }, V = new MutationObserver(ge);
354
- V.observe(d.documentElement, { childList: !0, subtree: !0 });
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
- Ve(e, {
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
- }, N = (l = "", k = !0) => {
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
- }, he = () => {
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(), N(p.value), p.value = "";
400
+ l.preventDefault(), P(p.value), p.value = "";
378
401
  }), u.addEventListener("click", (l) => {
379
- l.target !== p && (N(p.value), p.value = "");
402
+ l.target !== p && (P(p.value), p.value = "");
380
403
  }), p.addEventListener("focus", () => {
381
- N(p.value), p.value = "";
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
- N(l), p.value = "";
387
- }), b.addEventListener("click", he);
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
- y.addEventListener("submit", (l) => {
392
- l.preventDefault(), B(f, s), L();
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
- B(f, s), L();
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(), B(f, s), L());
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 && N(s.value, !1);
408
- const K = () => r;
409
- let F = f.getState().appearance !== null;
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 ? (F = !0, M("web-sdk.widget", "Agent state supplied 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")) : F && (F = !1, M("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
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")), te(h, _, c, l, m, E, K, (k) => {
440
+ }), G({}, "agent.state.appearance-cleared")), ie(h, _, c, l, m, E, Y, (k) => {
418
441
  f.sendMessage(k);
419
442
  }), L();
420
- }), te(h, _, c, f.getState(), m, E, K, (l) => {
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
- H = !0, V.disconnect(), f.destroy(), o.remove();
451
+ j = !0, q.disconnect(), f.destroy(), o.remove();
429
452
  }
430
453
  };
431
454
  function G(l, k) {
432
- const A = l.accentColor ?? e.accentColor, j = l.colorScheme ?? e.colorScheme, q = l.fontFamily ?? e.fontFamily, z = l.scribbleStyle ?? e.scribbleStyle;
433
- r = Q(A, z), ee(a, r, {
434
- accentColor: A,
435
- colorScheme: j,
436
- fontFamily: q,
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
- }), M("web-sdk.widget", "Updated widget appearance", {
461
+ }), A("web-sdk.widget", "Updated widget appearance", {
439
462
  source: k,
440
463
  inputAppearance: l,
441
- appliedAccentColor: A,
442
- appliedColorScheme: j,
443
- appliedFontFamily: q,
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 Q(t, e) {
450
- return e ? xe(t) : me(t);
472
+ function ae(t, e) {
473
+ return e ? Se(t) : ke(t);
451
474
  }
452
- function ee(t, e, o) {
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), t.style.setProperty("--pluno-pa-accent", o.accentColor), t.style.fontFamily = o.scribbleStyle ? Oe : o.fontFamily, o.scribbleStyle && Fe(t.ownerDocument);
454
- const n = Array.from(t.querySelectorAll(".pluno-pa-widget__character"));
455
- for (const a of n)
456
- a.src = e;
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 Fe(t) {
459
- if (t.getElementById(J))
483
+ function Ue(t) {
484
+ if (t.getElementById(oe))
460
485
  return;
461
486
  const e = t.createElement("style");
462
- e.id = J, e.textContent = `@font-face {
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 M(t, e, o) {
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(Ae, { detail: a }));
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 B(t, e) {
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 te(t, e, o, n, a, r, i, d) {
515
+ function ie(t, e, o, n, a, r, i, d) {
491
516
  const u = [...n.messages];
492
- t.innerHTML = "", Be(e, n.isThinking);
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 v = document.createElement("div");
500
- v.className = "pluno-pa-widget__empty", v.innerHTML = "Hey there, I'm Pluno 👋<br />What do you want to do today?", c.appendChild(v);
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, y = [];
537
+ let g = null, b = null, x = [];
513
538
  const s = () => {
514
- if (y.length === 0)
539
+ if (x.length === 0)
515
540
  return !1;
516
- const c = Ge(y, a, r, i());
517
- return t.appendChild(c), g = null, b = c, y = [], !0;
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
- y.push(h);
547
+ x.push(h);
523
548
  continue;
524
549
  }
525
550
  if (h.role === "system")
526
551
  continue;
527
- const v = s(), f = ne(h.content);
528
- if (h.role === "assistant" && !v) {
529
- const m = U(i());
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" ? re(w, f) : w.textContent = f, w.appendChild(oe(f)), t.appendChild(w), g = w, b = null;
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 v = U(i());
539
- t.appendChild(v), g = null, b = v;
563
+ const y = K(i());
564
+ t.appendChild(y), g = null, b = y;
540
565
  }
541
- const c = ne(n.assistantDraft), h = document.createElement("div");
542
- h.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", re(h, c), h.appendChild(oe(c)), t.appendChild(h), g = h, b = null;
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 = ce();
571
+ const c = fe();
547
572
  t.appendChild(c), g = null, b = c;
548
573
  } else {
549
- const c = ze(i());
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 oe(t) {
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 ne(t) {
589
+ function pe(t) {
565
590
  return t.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
566
591
  }
567
- function Ge(t, e, o, n) {
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 = Re(t);
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(ae());
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 y of t) {
607
+ for (const x of t) {
583
608
  const s = document.createElement("div");
584
- s.className = "pluno-pa-widget__tool-line", y.loading && s.appendChild(ae());
609
+ s.className = "pluno-pa-widget__tool-line", x.loading && s.appendChild(se());
585
610
  const _ = document.createElement("span");
586
- _.textContent = y.content || "Run tool", s.appendChild(_), b.appendChild(s);
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 U(t) {
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 ze(t) {
599
- const e = U(t);
600
- return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(ce()), e;
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 ce() {
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 Re(t) {
635
+ function Ve(t) {
611
636
  return `tools:${t.map((e) => e.id).join("|")}`;
612
637
  }
613
- function ae() {
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 Be(t, e) {
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 re(t, e) {
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
- O(p, i[2]), t.appendChild(p), n += 1;
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
- O(g, o[n].replace(/^\s*[-*+]\s+/, "")), p.appendChild(g), n += 1;
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
- O(g, o[n].replace(/^\s*\d+\.\s+/, "")), p.appendChild(g), n += 1;
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")), O(u, p);
695
+ g > 0 && u.appendChild(document.createElement("br")), $(u, p);
671
696
  }), t.appendChild(u);
672
697
  }
673
698
  }
674
- function O(t, e) {
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 && Ue(d[2])) {
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 Ue(t) {
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 ie(t, e) {
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('${X}');
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('${X}');
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 We() {
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 $(t) {
1743
+ function D(t) {
1719
1744
  const e = document.createElement("span");
1720
1745
  return e.textContent = t, e.innerHTML;
1721
1746
  }
1722
- function ue(t) {
1747
+ function we(t) {
1723
1748
  return `pluno.productAgent.widgetState.${location.origin}.${t.backendUrl ?? ""}.${t.tokenEndpoint ?? ""}.${t.position ?? ""}`;
1724
1749
  }
1725
- function He(t) {
1750
+ function Ye(t) {
1726
1751
  try {
1727
- const e = window.localStorage.getItem(ue(t));
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 Ve(t, e) {
1765
+ function Ze(t, e) {
1741
1766
  try {
1742
- window.localStorage.setItem(ue(t), JSON.stringify(e));
1767
+ window.localStorage.setItem(we(t), JSON.stringify(e));
1743
1768
  } catch {
1744
1769
  return;
1745
1770
  }
1746
1771
  }
1747
- const le = /* @__PURE__ */ new WeakSet();
1748
- function Ke(t) {
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 pe(t) {
1776
+ function ge(t) {
1752
1777
  const e = t.pathname.split("/");
1753
1778
  return e[e.length - 1] ?? "";
1754
1779
  }
1755
- function je(t, e) {
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 : pe(o) === pe(e);
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(Ne, () => {
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(Pe, (n) => {
1788
+ }), this.addPreviewListener($e, (n) => {
1764
1789
  const a = n;
1765
1790
  this.dispatchEvent(new MessageEvent("message", { data: a.detail?.data ?? "" }));
1766
- }), this.addPreviewListener(Me, () => {
1791
+ }), this.addPreviewListener(De, () => {
1767
1792
  this.readyState = C.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
1768
- }), this.addPreviewListener(Ie, (n) => {
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(D(Ee, this.channelId), {
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 = qe();
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(D(Le, this.channelId), {
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(D(Te, this.channelId), {
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 = D(e, this.channelId), a = (r) => {
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 qe() {
1825
- const t = window.sessionStorage.getItem(Z);
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(Z, e), e;
1854
+ return window.sessionStorage.setItem(te, e), e;
1830
1855
  }
1831
- function D(t, e) {
1856
+ function F(t, e) {
1832
1857
  return `${t}:${e}`;
1833
1858
  }
1834
- function Ye(t) {
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 && Ke(a) && je(a, n)
1865
+ (a) => a instanceof HTMLScriptElement && Xe(a) && Je(a, n)
1841
1866
  );
1842
1867
  }
1843
- function Ze(t) {
1844
- for (const e of Ye(t)) {
1845
- if (le.has(e) || e.dataset.plunoAutoMount === "false")
1868
+ function tt(t) {
1869
+ for (const e of et(t)) {
1870
+ if (ue.has(e) || e.dataset.plunoAutoMount === "false")
1846
1871
  continue;
1847
- le.add(e);
1872
+ ue.add(e);
1848
1873
  const o = e.dataset.plunoPreviewChannel;
1849
- De({
1874
+ Be({
1850
1875
  token: e.dataset.plunoToken,
1851
1876
  tokenEndpoint: e.dataset.plunoTokenEndpoint,
1852
1877
  backendUrl: e.dataset.plunoBackendUrl,
1853
- webSocketFactory: o ? $e(o) : void 0,
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
- Ze(import.meta.url);
1890
+ tt(import.meta.url);
1866
1891
  export {
1867
- $e as createProductAgentPreviewBridgeWebSocketFactory,
1868
- De as mountPlunoProductAgentWidget
1892
+ ze as createProductAgentPreviewBridgeWebSocketFactory,
1893
+ Be as mountPlunoProductAgentWidget
1869
1894
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluno/product-agent-web",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Browser SDK and default widget for embedding Pluno Product Agent into customer web apps.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",