@pluno/product-agent-web 0.1.14 → 0.1.16

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,7 +1,7 @@
1
- import { PlunoProductAgent as xe } from "./product-agent-sdk.js";
2
- const ye = "#7c3aed";
3
- function ve(t) {
4
- const e = Le(t);
1
+ import { PlunoProductAgent as ye } from "./product-agent-sdk.js";
2
+ const ve = "#7c3aed";
3
+ function ke(t) {
4
+ const e = Te(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 ke(t) {
79
- return `data:image/svg+xml,${encodeURIComponent(ve(t))}`;
78
+ function Ce(t) {
79
+ return `data:image/svg+xml,${encodeURIComponent(ke(t))}`;
80
80
  }
81
81
  const N = "#2c2a1e", J = [253, 250, 241], Q = 3.5;
82
82
  function he(t) {
83
- const e = be(t);
83
+ const e = fe(t);
84
84
  if (ee(M(e), J) >= Q)
85
85
  return e;
86
- let n = M(e);
86
+ let o = M(e);
87
87
  const a = M(N);
88
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);
89
+ if (o = Ne(o, a, 0.22), ee(o, J) >= Q)
90
+ return H(o);
91
+ return H(o);
92
92
  }
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";
93
+ function Se(t) {
94
+ const e = he(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="${o}"/>
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,9 +104,9 @@ function Ce(t) {
104
104
  </defs>
105
105
  <g filter="url(#scribbleBoltWobble)">
106
106
  <g clip-path="url(#scribbleBoltClip)">
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)"/>
107
+ <path d="${Le()}" 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="${o}" fill="none" stroke="${N}" stroke-width="18" stroke-linejoin="round"/>
109
+ <path d="${n}" fill="none" stroke="${N}" stroke-width="18" stroke-linejoin="round"/>
110
110
  <g transform="rotate(-2 528 463)">
111
111
  <ellipse cx="528" cy="463" rx="73" ry="80" fill="#ffffff" stroke="${N}" stroke-width="13"/>
112
112
  <ellipse cx="533" cy="473" rx="45" ry="53" fill="${N}"/>
@@ -120,20 +120,20 @@ function Ce(t) {
120
120
  </g>
121
121
  </svg>`;
122
122
  }
123
- function Se(t) {
124
- return `data:image/svg+xml,${encodeURIComponent(Ce(t))}`;
123
+ function Ee(t) {
124
+ return `data:image/svg+xml,${encodeURIComponent(Se(t))}`;
125
125
  }
126
- function Ee() {
127
- let o = "M 280 120", n = !1, a = 0;
126
+ function Le() {
127
+ let n = "M 280 120", o = !1, a = 0;
128
128
  for (let r = 150; r <= 1170; r += 62) {
129
- const i = (a % 3 - 1) * 18, d = n ? 280 - i : 1020 + i;
130
- o += ` L ${d} ${r}`, n = !n, a += 1;
129
+ const i = (a % 3 - 1) * 18, d = o ? 280 - i : 1020 + i;
130
+ n += ` L ${d} ${r}`, o = !o, a += 1;
131
131
  }
132
- return o;
132
+ return n;
133
133
  }
134
- function Le(t) {
135
- const e = be(t), o = H(M(e));
136
- return o > 0.86 ? {
134
+ function Te(t) {
135
+ const e = fe(t), n = W(M(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
- } : o < 0.05 ? {
147
+ } : n < 0.05 ? {
148
148
  top: "#3d3d3d",
149
149
  middle: "#171717",
150
150
  bottom: "#030303",
@@ -168,9 +168,9 @@ function Le(t) {
168
168
  shadow: v(e, -0.25, -0.08)
169
169
  };
170
170
  }
171
- function be(t) {
171
+ function fe(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((o) => o + o).join("").toLowerCase()}` : ye;
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()}` : ve;
174
174
  }
175
175
  function M(t) {
176
176
  return [
@@ -179,69 +179,69 @@ function M(t) {
179
179
  Number.parseInt(t.slice(5, 7), 16)
180
180
  ];
181
181
  }
182
- function W([t, e, o]) {
183
- const n = (a) => Math.max(0, Math.min(255, Math.round(a))).toString(16).padStart(2, "0");
184
- return `#${n(t)}${n(e)}${n(o)}`;
182
+ function H([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 H([t, e, o]) {
187
- const n = (a) => {
186
+ function W([t, e, n]) {
187
+ const o = (a) => {
188
188
  const r = a / 255;
189
189
  return r <= 0.04045 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
190
190
  };
191
- return 0.2126 * n(t) + 0.7152 * n(e) + 0.0722 * n(o);
191
+ return 0.2126 * o(t) + 0.7152 * o(e) + 0.0722 * o(n);
192
192
  }
193
193
  function ee(t, e) {
194
- const o = H(t), n = H(e), [a, r] = o > n ? [o, n] : [n, o];
194
+ const n = W(t), o = W(e), [a, r] = n > o ? [n, o] : [o, n];
195
195
  return (a + 0.05) / (r + 0.05);
196
196
  }
197
- function Te(t, e, o) {
198
- const n = V(o);
197
+ function Ne(t, e, n) {
198
+ const o = V(n);
199
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
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 v(t, e, o) {
206
- const [n, a, r] = Ne(M(t));
207
- return W(Pe(n, V(a + o), V(r + e)));
205
+ function v(t, e, n) {
206
+ const [o, a, r] = Pe(M(t));
207
+ return H(Ie(o, V(a + n), V(r + e)));
208
208
  }
209
- function Ne([t, e, o]) {
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;
209
+ function Pe([t, e, n]) {
210
+ const o = t / 255, a = e / 255, r = n / 255, i = Math.max(o, a, r), d = Math.min(o, a, r), u = (i + d) / 2;
211
211
  if (i === d)
212
212
  return [0, 0, u];
213
213
  const p = i - d, g = u > 0.5 ? p / (2 - i - d) : p / (i + d);
214
- return [(i === n ? (a - r) / p + (a < r ? 6 : 0) : i === a ? (r - n) / p + 2 : (n - a) / p + 4) / 6, g, u];
214
+ return [(i === o ? (a - r) / p + (a < r ? 6 : 0) : i === a ? (r - o) / p + 2 : (o - a) / p + 4) / 6, g, u];
215
215
  }
216
- function Pe(t, e, o) {
216
+ function Ie(t, e, n) {
217
217
  if (e === 0)
218
- return [o * 255, o * 255, o * 255];
219
- const n = o < 0.5 ? o * (1 + e) : o + e - o * e, a = 2 * o - n;
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
- B(a, n, t + 1 / 3) * 255,
222
- B(a, n, t) * 255,
223
- B(a, n, t - 1 / 3) * 255
221
+ B(a, o, t + 1 / 3) * 255,
222
+ B(a, o, t) * 255,
223
+ B(a, o, t - 1 / 3) * 255
224
224
  ];
225
225
  }
226
- function B(t, e, o) {
227
- let n = o;
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;
226
+ function B(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
230
  function V(t) {
231
231
  return Math.max(0, Math.min(1, t));
232
232
  }
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 = {
233
+ const Ae = "product-agent:sdk-preview-socket-connect", Me = "product-agent:sdk-preview-socket-send", Oe = "product-agent:sdk-preview-socket-close", $e = "product-agent:sdk-preview-socket-open", De = "product-agent:sdk-preview-socket-message", Fe = "product-agent:sdk-preview-socket-error", Re = "product-agent:sdk-preview-socket-closed", te = "product-agent:sdk-preview-socket-id", Ge = "product-agent:preview-diagnostic", T = {
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
239
  position: "bottom-right"
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) {
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>', ze = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', oe = "pluno-pa-scribble-font";
241
+ function Be(t) {
242
242
  return (e) => new C(e, t);
243
243
  }
244
- async function Be(t = {}) {
244
+ async function Ue(t = {}) {
245
245
  const e = {
246
246
  launcherLabel: t.launcherLabel ?? T.launcherLabel,
247
247
  accentColor: t.accentColor ?? T.accentColor,
@@ -253,10 +253,11 @@ async function Be(t = {}) {
253
253
  tokenProvider: t.tokenProvider,
254
254
  tokenEndpoint: t.tokenEndpoint,
255
255
  backendUrl: t.backendUrl,
256
+ metadata: t.metadata,
256
257
  initialStarterPrompts: t.initialStarterPrompts,
257
258
  webSocketFactory: t.webSocketFactory
258
259
  };
259
- A("web-sdk.widget", "Mounting widget with merged options", {
260
+ I("web-sdk.widget", "Mounting widget with merged options", {
260
261
  accentColor: e.accentColor,
261
262
  colorScheme: e.colorScheme,
262
263
  fontFamily: e.fontFamily,
@@ -267,9 +268,9 @@ async function Be(t = {}) {
267
268
  hasWebSocketFactory: !!e.webSocketFactory,
268
269
  initialStarterPromptCount: e.initialStarterPrompts?.length ?? 0
269
270
  });
270
- const o = document.createElement("div");
271
- o.className = "pluno-pa-widget-host";
272
- const n = o.attachShadow({ mode: "open" }), a = document.createElement("div");
271
+ const n = document.createElement("div");
272
+ n.className = "pluno-pa-widget-host";
273
+ const o = n.attachShadow({ mode: "open" }), a = document.createElement("div");
273
274
  a.className = `pluno-pa-widget pluno-pa-widget--${e.position}`;
274
275
  let r = ae(e.accentColor, e.scribbleStyle);
275
276
  a.innerHTML = `
@@ -332,22 +333,23 @@ async function Be(t = {}) {
332
333
  <a class="pluno-pa-widget__powered-by" href="https://pluno.ai" target="_blank" rel="noopener noreferrer">Powered by Pluno.ai</a>
333
334
  </form>
334
335
  </section>
335
- `, n.appendChild(a);
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, {
336
+ `, o.appendChild(a);
337
+ const i = await Ye(), d = i.ownerDocument;
338
+ i.appendChild(n), a.classList.add(`pluno-pa-widget--${e.colorScheme}`), ue(o, e.accentColor), re(a, r, {
338
339
  accentColor: e.accentColor,
339
340
  colorScheme: e.colorScheme,
340
341
  fontFamily: e.fontFamily,
341
342
  scribbleStyle: e.scribbleStyle
342
- }), A("web-sdk.widget", "Applied initial widget appearance", {
343
+ }), I("web-sdk.widget", "Applied initial widget appearance", {
343
344
  accentColor: e.accentColor,
344
345
  colorScheme: e.colorScheme,
345
346
  fontFamily: e.fontFamily,
346
347
  cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
347
348
  });
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)
349
+ const u = a.querySelector(".pluno-pa-widget__launcher"), p = a.querySelector(".pluno-pa-widget__launcher-input"), g = a.querySelector(".pluno-pa-widget__panel"), f = a.querySelector(".pluno-pa-widget__close"), x = a.querySelector(".pluno-pa-widget__composer"), s = a.querySelector(".pluno-pa-widget__input"), _ = a.querySelector(".pluno-pa-widget__send"), c = a.querySelector(".pluno-pa-widget__new-chat"), b = a.querySelector(".pluno-pa-widget__timeline");
350
+ if (!u || !p || !g || !f || !x || !s || !_ || !c || !b)
350
351
  throw new Error("Failed to mount Product Agent widget");
352
+ ie(p), ie(s);
351
353
  const y = e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (async () => {
352
354
  if (!e.tokenEndpoint)
353
355
  throw new Error("Product Agent widget requires token or tokenEndpoint");
@@ -363,37 +365,44 @@ async function Be(t = {}) {
363
365
  if (!k.token)
364
366
  throw new Error("Product Agent token endpoint did not return a token");
365
367
  return k.token;
366
- }), f = await xe.init({
368
+ });
369
+ let h;
370
+ h = await ye.init({
367
371
  token: e.token,
368
372
  tokenProvider: y,
369
373
  backendUrl: e.backendUrl,
374
+ metadata: () => ({
375
+ ...e.metadata ?? {},
376
+ ...!h.getState().sessionId && e.scribbleStyle ? { scribbleStyleStarted: !0 } : {}
377
+ }),
370
378
  initialStarterPrompts: e.initialStarterPrompts,
371
379
  webSocketFactory: e.webSocketFactory
372
- }), w = Ye(e), m = new Set(w.openToolGroupKeys);
380
+ });
381
+ const w = Ze(e), m = new Set(w.openToolGroupKeys);
373
382
  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);
383
+ const _e = () => {
384
+ j || typeof document > "u" || (ue(o, e.accentColor), n.isConnected || d.body?.appendChild(n));
385
+ }, q = new MutationObserver(_e);
377
386
  q.observe(d.documentElement, { childList: !0, subtree: !0 });
378
387
  const E = () => {
379
- Ze(e, {
388
+ Xe(e, {
380
389
  isOpen: a.classList.contains("pluno-pa-widget--open"),
381
390
  composerValue: s.value,
382
391
  openToolGroupKeys: [...m]
383
392
  });
384
393
  }, P = (l = "", k = !0) => {
385
- if (S !== null && (window.clearTimeout(S), S = null), g.hidden = !1, b.hidden = !1, a.classList.remove("pluno-pa-widget--closing"), !k) {
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();
394
+ if (S !== null && (window.clearTimeout(S), S = null), g.hidden = !1, f.hidden = !1, a.classList.remove("pluno-pa-widget--closing"), !k) {
395
+ a.classList.add("pluno-pa-widget--open"), u.hidden = !0, l && (s.value = l, A(s)), b.scrollTop = b.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E();
387
396
  return;
388
397
  }
389
398
  window.requestAnimationFrame(() => {
390
- a.classList.add("pluno-pa-widget--open"), l && (s.value = l, I(s)), h.scrollTop = h.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E(), S = window.setTimeout(() => {
391
- u.hidden = !0, h.scrollTop = h.scrollHeight;
399
+ a.classList.add("pluno-pa-widget--open"), l && (s.value = l, A(s)), b.scrollTop = b.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E(), S = window.setTimeout(() => {
400
+ u.hidden = !0, b.scrollTop = b.scrollHeight;
392
401
  }, 220);
393
402
  });
394
- }, _e = () => {
403
+ }, xe = () => {
395
404
  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(() => {
396
- g.hidden = !0, b.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
405
+ g.hidden = !0, f.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
397
406
  }, 220);
398
407
  };
399
408
  u.addEventListener("submit", (l) => {
@@ -407,48 +416,48 @@ async function Be(t = {}) {
407
416
  return;
408
417
  const l = p.value;
409
418
  P(l), p.value = "";
410
- }), b.addEventListener("click", _e);
419
+ }), f.addEventListener("click", xe);
411
420
  const L = () => {
412
- _.disabled = !f.getState().isThinking && s.value.trim().length === 0;
421
+ _.disabled = !h.getState().isThinking && s.value.trim().length === 0;
413
422
  };
414
423
  x.addEventListener("submit", (l) => {
415
- l.preventDefault(), U(f, s), L();
424
+ l.preventDefault(), U(h, s), L();
416
425
  }), _.addEventListener("click", () => {
417
- if (f.getState().isThinking) {
418
- f.stop();
426
+ if (h.getState().isThinking) {
427
+ h.stop();
419
428
  return;
420
429
  }
421
- U(f, s), L();
430
+ U(h, s), L();
422
431
  }), c.addEventListener("click", () => {
423
- f.startNewSession(), m.clear(), s.value = "", I(s), E(), L(), s.focus();
432
+ h.startNewSession(), m.clear(), s.value = "", A(s), E(), L(), s.focus();
424
433
  }), s.addEventListener("input", () => {
425
- I(s), E(), L();
434
+ A(s), E(), L();
426
435
  }), s.addEventListener("keydown", (l) => {
427
- l.key !== "Enter" || l.shiftKey || (l.preventDefault(), U(f, s), L());
436
+ l.key !== "Enter" || l.shiftKey || (l.preventDefault(), U(h, s), L());
428
437
  }), a.addEventListener("click", (l) => {
429
438
  (l.target instanceof Element ? l.target : null)?.closest("a[href]") && E();
430
- }), w.composerValue && (s.value = w.composerValue, I(s)), w.isOpen && P(s.value, !1);
439
+ }), w.composerValue && (s.value = w.composerValue, A(s)), w.isOpen && P(s.value, !1);
431
440
  const Y = () => r;
432
- let R = f.getState().appearance !== null;
433
- return f.on("state", (l) => {
434
- l.appearance ? (R = !0, A("web-sdk.widget", "Agent state supplied appearance", {
441
+ let R = h.getState().appearance !== null;
442
+ return h.on("state", (l) => {
443
+ l.appearance ? (R = !0, I("web-sdk.widget", "Agent state supplied appearance", {
435
444
  appearance: l.appearance
436
- }), G(l.appearance, "agent.state.appearance")) : R && (R = !1, A("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
445
+ }), G(l.appearance, "agent.state.appearance")) : R && (R = !1, I("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
437
446
  fallbackAccentColor: e.accentColor,
438
447
  fallbackColorScheme: e.colorScheme,
439
448
  fallbackFontFamily: e.fontFamily
440
- }), G({}, "agent.state.appearance-cleared")), ie(h, _, c, l, m, E, Y, (k) => {
441
- f.sendMessage(k);
449
+ }), G({}, "agent.state.appearance-cleared")), le(b, _, c, l, m, E, Y, (k) => {
450
+ h.sendMessage(k);
442
451
  }), L();
443
- }), ie(h, _, c, f.getState(), m, E, Y, (l) => {
444
- f.sendMessage(l);
452
+ }), le(b, _, c, h.getState(), m, E, Y, (l) => {
453
+ h.sendMessage(l);
445
454
  }), L(), {
446
- agent: f,
455
+ agent: h,
447
456
  updateAppearance: (l) => {
448
457
  l.scribbleStyle !== void 0 && (e.scribbleStyle = l.scribbleStyle), G(l, "widgetHandle.updateAppearance");
449
458
  },
450
459
  destroy: () => {
451
- j = !0, q.disconnect(), f.destroy(), o.remove();
460
+ j = !0, q.disconnect(), h.destroy(), n.remove();
452
461
  }
453
462
  };
454
463
  function G(l, k) {
@@ -458,7 +467,7 @@ async function Be(t = {}) {
458
467
  colorScheme: Z,
459
468
  fontFamily: X,
460
469
  scribbleStyle: z
461
- }), A("web-sdk.widget", "Updated widget appearance", {
470
+ }), I("web-sdk.widget", "Updated widget appearance", {
462
471
  source: k,
463
472
  inputAppearance: l,
464
473
  appliedAccentColor: O,
@@ -470,17 +479,17 @@ async function Be(t = {}) {
470
479
  }
471
480
  }
472
481
  function ae(t, e) {
473
- return e ? Se(t) : ke(t);
482
+ return e ? Ee(t) : Ce(t);
474
483
  }
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);
484
+ function re(t, e, n) {
485
+ t.classList.toggle("pluno-pa-widget--dark", n.colorScheme === "dark"), t.classList.toggle("pluno-pa-widget--light", n.colorScheme !== "dark"), t.classList.toggle("pluno-pa-widget--scribble", n.scribbleStyle);
486
+ const o = n.scribbleStyle ? he(n.accentColor) : n.accentColor;
487
+ t.style.setProperty("--pluno-pa-accent", o), t.style.fontFamily = n.scribbleStyle ? ze : n.fontFamily, n.scribbleStyle && He(t.ownerDocument);
479
488
  const a = Array.from(t.querySelectorAll(".pluno-pa-widget__character"));
480
489
  for (const r of a)
481
490
  r.src = e;
482
491
  }
483
- function Ue(t) {
492
+ function He(t) {
484
493
  if (t.getElementById(oe))
485
494
  return;
486
495
  const e = t.createElement("style");
@@ -492,204 +501,210 @@ function Ue(t) {
492
501
  src: url("https://fonts.gstatic.com/s/architectsdaughter/v20/KtkxAKiDZI_td1Lkx62xHZHDtgO_Y-bvTYlg4-7jA-U.woff2") format("woff2");
493
502
  }`, t.head.appendChild(e), t.fonts?.load('16px "Architects Daughter"');
494
503
  }
495
- function A(t, e, o) {
504
+ function I(t, e, n) {
496
505
  if (typeof window > "u")
497
506
  return;
498
- const n = window, a = {
507
+ const o = window, a = {
499
508
  at: (/* @__PURE__ */ new Date()).toISOString(),
500
509
  source: t,
501
510
  message: e,
502
- details: o
503
- }, r = n.__plunoProductAgentDiagnostics__ ?? [];
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 }));
511
+ details: n
512
+ }, r = o.__plunoProductAgentDiagnostics__ ?? [];
513
+ r.push(a), r.length > 120 && r.splice(0, r.length - 120), o.__plunoProductAgentDiagnostics__ = r, o.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...r], window.dispatchEvent(new CustomEvent(Ge, { detail: a }));
505
514
  }
506
515
  function U(t, e) {
507
- const o = e.value.trim();
508
- o && (e.value = "", e.style.height = "22px", e.style.overflowY = "hidden", t.sendMessage(o), e.dispatchEvent(new Event("input", { bubbles: !0 })));
516
+ const n = e.value.trim();
517
+ n && (e.value = "", e.style.height = "22px", e.style.overflowY = "hidden", t.sendMessage(n), e.dispatchEvent(new Event("input", { bubbles: !0 })));
509
518
  }
510
- function I(t) {
519
+ function A(t) {
511
520
  t.style.height = "0px";
512
521
  const e = Math.max(22, Math.min(t.scrollHeight, 140));
513
522
  t.style.height = `${e}px`, t.style.overflowY = t.scrollHeight > 140 ? "auto" : "hidden";
514
523
  }
515
- function ie(t, e, o, n, a, r, i, d) {
516
- const u = [...n.messages];
517
- t.innerHTML = "", Ke(e, n.isThinking);
518
- const p = u.length > 0 || !!n.assistantDraft || n.isThinking;
519
- if (o.hidden = !p, u.length === 0 && !n.assistantDraft && !n.lastError && !n.isThinking) {
524
+ function ie(t) {
525
+ for (const e of ["keydown", "keypress", "keyup"])
526
+ t.addEventListener(e, (n) => {
527
+ n.stopPropagation();
528
+ });
529
+ }
530
+ function le(t, e, n, o, a, r, i, d) {
531
+ const u = [...o.messages];
532
+ t.innerHTML = "", je(e, o.isThinking);
533
+ const p = u.length > 0 || !!o.assistantDraft || o.isThinking;
534
+ if (n.hidden = !p, u.length === 0 && !o.assistantDraft && !o.lastError && !o.isThinking) {
520
535
  const c = document.createElement("div");
521
536
  c.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
522
- const h = document.createElement("img");
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);
537
+ const b = document.createElement("img");
538
+ b.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", b.src = i(), b.alt = "", b.setAttribute("aria-hidden", "true"), c.appendChild(b);
524
539
  const y = document.createElement("div");
525
540
  y.className = "pluno-pa-widget__empty", y.innerHTML = "Hey there, I'm Pluno 👋<br />What do you want to do today?", c.appendChild(y);
526
- const f = document.createElement("div");
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");
528
- for (const w of n.starterPrompts) {
541
+ const h = document.createElement("div");
542
+ h.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 && h.setAttribute("aria-hidden", "true");
543
+ for (const w of o.starterPrompts) {
529
544
  const m = document.createElement("button");
530
545
  m.type = "button", m.className = "pluno-pa-widget__starter-prompt", m.textContent = `"${w}"`, m.addEventListener("click", () => {
531
546
  d(w);
532
- }), f.appendChild(m);
547
+ }), h.appendChild(m);
533
548
  }
534
- c.appendChild(f), t.appendChild(c);
549
+ c.appendChild(h), t.appendChild(c);
535
550
  return;
536
551
  }
537
- let g = null, b = null, x = [];
552
+ let g = null, f = null, x = [];
538
553
  const s = () => {
539
554
  if (x.length === 0)
540
555
  return !1;
541
556
  const c = We(x, a, r, i());
542
- return t.appendChild(c), g = null, b = c, x = [], !0;
557
+ return t.appendChild(c), g = null, f = c, x = [], !0;
543
558
  };
544
559
  for (let c = 0; c < u.length; c += 1) {
545
- const h = u[c];
546
- if (h.role === "tool") {
547
- x.push(h);
560
+ const b = u[c];
561
+ if (b.role === "tool") {
562
+ x.push(b);
548
563
  continue;
549
564
  }
550
- if (h.role === "system")
565
+ if (b.role === "system")
551
566
  continue;
552
- const y = s(), f = pe(h.content);
553
- if (h.role === "assistant" && !y) {
567
+ const y = s(), h = se(b.content);
568
+ if (b.role === "assistant" && !y) {
554
569
  const m = K(i());
555
- t.appendChild(m), g = null, b = m;
570
+ t.appendChild(m), g = null, f = m;
556
571
  }
557
572
  const w = document.createElement("div");
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;
573
+ w.className = `pluno-pa-widget__message pluno-pa-widget__message--${b.role}`, b.role === "assistant" ? ce(w, h) : w.textContent = h, w.appendChild(pe(h)), t.appendChild(w), g = w, f = null;
559
574
  }
560
575
  const _ = s();
561
- if (n.assistantDraft) {
576
+ if (o.assistantDraft) {
562
577
  if (!_) {
563
578
  const y = K(i());
564
- t.appendChild(y), g = null, b = y;
579
+ t.appendChild(y), g = null, f = y;
565
580
  }
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;
581
+ const c = se(o.assistantDraft), b = document.createElement("div");
582
+ b.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", ce(b, c), b.appendChild(pe(c)), t.appendChild(b), g = b, f = null;
568
583
  }
569
- if (n.isThinking && !n.assistantDraft)
584
+ if (o.isThinking && !o.assistantDraft)
570
585
  if (_) {
571
- const c = fe();
572
- t.appendChild(c), g = null, b = c;
586
+ const c = we();
587
+ t.appendChild(c), g = null, f = c;
573
588
  } else {
574
- const c = He(i());
575
- t.appendChild(c), g = null, b = c;
589
+ const c = Ve(i());
590
+ t.appendChild(c), g = null, f = c;
576
591
  }
577
- if (n.lastError) {
592
+ if (o.lastError) {
578
593
  const c = document.createElement("div");
579
- c.className = "pluno-pa-widget__error", c.textContent = n.lastError, t.appendChild(c), g = c, b = null;
594
+ c.className = "pluno-pa-widget__error", c.textContent = o.lastError, t.appendChild(c), g = c, f = null;
580
595
  }
581
- g?.classList.add("pluno-pa-widget__message--bottom-reserve"), b?.classList.add("pluno-pa-widget__bottom-reserve-compact"), t.scrollTop = t.scrollHeight;
596
+ g?.classList.add("pluno-pa-widget__message--bottom-reserve"), f?.classList.add("pluno-pa-widget__bottom-reserve-compact"), t.scrollTop = t.scrollHeight;
582
597
  }
583
- function le(t) {
598
+ function pe(t) {
584
599
  const e = document.createElement("button");
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) => {
586
- o.preventDefault(), o.stopPropagation(), navigator.clipboard.writeText(t);
600
+ return e.type = "button", e.className = "pluno-pa-widget__message-copy", e.setAttribute("aria-label", "Copy message"), e.title = "Copy message", e.innerHTML = '<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg>', e.addEventListener("click", (n) => {
601
+ n.preventDefault(), n.stopPropagation(), navigator.clipboard.writeText(t);
587
602
  }), e;
588
603
  }
589
- function pe(t) {
604
+ function se(t) {
590
605
  return t.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
591
606
  }
592
- function We(t, e, o, n) {
607
+ function We(t, e, n, o) {
593
608
  const a = document.createElement("article");
594
609
  a.className = "pluno-pa-widget__tool-group", a.title = new Date(t[t.length - 1].createdAt).toLocaleString();
595
610
  const r = document.createElement("img");
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);
597
- const i = document.createElement("details"), d = Ve(t);
611
+ r.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", r.src = o, r.alt = "", r.setAttribute("aria-hidden", "true"), a.appendChild(r);
612
+ const i = document.createElement("details"), d = Ke(t);
598
613
  i.open = e.has(d), i.addEventListener("toggle", () => {
599
- i.open ? e.add(d) : e.delete(d), o();
614
+ i.open ? e.add(d) : e.delete(d), n();
600
615
  });
601
616
  const u = document.createElement("summary");
602
- u.className = "pluno-pa-widget__tool-summary", t.some((b) => b.loading) && u.appendChild(se());
617
+ u.className = "pluno-pa-widget__tool-summary", t.some((f) => f.loading) && u.appendChild(de());
603
618
  const g = document.createElement("span");
604
619
  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) {
605
- const b = document.createElement("div");
606
- b.className = "pluno-pa-widget__tool-lines";
620
+ const f = document.createElement("div");
621
+ f.className = "pluno-pa-widget__tool-lines";
607
622
  for (const x of t) {
608
623
  const s = document.createElement("div");
609
- s.className = "pluno-pa-widget__tool-line", x.loading && s.appendChild(se());
624
+ s.className = "pluno-pa-widget__tool-line", x.loading && s.appendChild(de());
610
625
  const _ = document.createElement("span");
611
- _.textContent = x.content || "Run tool", s.appendChild(_), b.appendChild(s);
626
+ _.textContent = x.content || "Run tool", s.appendChild(_), f.appendChild(s);
612
627
  }
613
- i.appendChild(b);
628
+ i.appendChild(f);
614
629
  }
615
630
  return a.appendChild(i), a;
616
631
  }
617
632
  function K(t) {
618
633
  const e = document.createElement("article");
619
634
  e.className = "pluno-pa-widget__tool-group pluno-pa-widget__assistant-marker";
620
- const o = document.createElement("img");
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;
635
+ const n = document.createElement("img");
636
+ 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;
622
637
  }
623
- function He(t) {
638
+ function Ve(t) {
624
639
  const e = K(t);
625
- return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(fe()), e;
640
+ return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(we()), e;
626
641
  }
627
- function fe() {
642
+ function we() {
628
643
  const t = document.createElement("div");
629
644
  t.className = "pluno-pa-widget__status";
630
645
  const e = document.createElement("span");
631
646
  e.className = "pluno-pa-widget__thinking-dot", e.setAttribute("aria-hidden", "true"), t.appendChild(e);
632
- const o = document.createElement("span");
633
- return o.textContent = "Thinking...", t.appendChild(o), t;
647
+ const n = document.createElement("span");
648
+ return n.textContent = "Thinking...", t.appendChild(n), t;
634
649
  }
635
- function Ve(t) {
650
+ function Ke(t) {
636
651
  return `tools:${t.map((e) => e.id).join("|")}`;
637
652
  }
638
- function se() {
653
+ function de() {
639
654
  const t = document.createElement("span");
640
655
  return t.className = "pluno-pa-widget__spinner", t.setAttribute("aria-hidden", "true"), t;
641
656
  }
642
- function Ke(t, e) {
657
+ function je(t, e) {
643
658
  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>';
644
659
  }
645
- function de(t, e) {
646
- const o = e.replace(/\r\n/g, `
660
+ function ce(t, e) {
661
+ const n = e.replace(/\r\n/g, `
647
662
  `).split(`
648
663
  `);
649
- let n = 0;
650
- for (; n < o.length; ) {
651
- const a = o[n];
664
+ let o = 0;
665
+ for (; o < n.length; ) {
666
+ const a = n[o];
652
667
  if (!a.trim()) {
653
- n += 1;
668
+ o += 1;
654
669
  continue;
655
670
  }
656
671
  if (a.match(/^```(\w+)?\s*$/)) {
657
672
  const p = [];
658
- for (n += 1; n < o.length && !/^```\s*$/.test(o[n]); )
659
- p.push(o[n]), n += 1;
660
- n += n < o.length ? 1 : 0;
661
- const g = document.createElement("pre"), b = document.createElement("code");
662
- b.textContent = p.join(`
663
- `), g.appendChild(b), t.appendChild(g);
673
+ for (o += 1; o < n.length && !/^```\s*$/.test(n[o]); )
674
+ p.push(n[o]), o += 1;
675
+ o += o < n.length ? 1 : 0;
676
+ const g = document.createElement("pre"), f = document.createElement("code");
677
+ f.textContent = p.join(`
678
+ `), g.appendChild(f), t.appendChild(g);
664
679
  continue;
665
680
  }
666
681
  const i = a.match(/^(#{1,3})\s+(.+)$/);
667
682
  if (i) {
668
683
  const p = document.createElement(`h${i[1].length + 2}`);
669
- $(p, i[2]), t.appendChild(p), n += 1;
684
+ $(p, i[2]), t.appendChild(p), o += 1;
670
685
  continue;
671
686
  }
672
687
  if (/^\s*[-*+]\s+/.test(a)) {
673
688
  const p = document.createElement("ul");
674
- for (; n < o.length && /^\s*[-*+]\s+/.test(o[n]); ) {
689
+ for (; o < n.length && /^\s*[-*+]\s+/.test(n[o]); ) {
675
690
  const g = document.createElement("li");
676
- $(g, o[n].replace(/^\s*[-*+]\s+/, "")), p.appendChild(g), n += 1;
691
+ $(g, n[o].replace(/^\s*[-*+]\s+/, "")), p.appendChild(g), o += 1;
677
692
  }
678
693
  t.appendChild(p);
679
694
  continue;
680
695
  }
681
696
  if (/^\s*\d+\.\s+/.test(a)) {
682
697
  const p = document.createElement("ol");
683
- for (; n < o.length && /^\s*\d+\.\s+/.test(o[n]); ) {
698
+ for (; o < n.length && /^\s*\d+\.\s+/.test(n[o]); ) {
684
699
  const g = document.createElement("li");
685
- $(g, o[n].replace(/^\s*\d+\.\s+/, "")), p.appendChild(g), n += 1;
700
+ $(g, n[o].replace(/^\s*\d+\.\s+/, "")), p.appendChild(g), o += 1;
686
701
  }
687
702
  t.appendChild(p);
688
703
  continue;
689
704
  }
690
705
  const d = [a];
691
- for (n += 1; n < o.length && o[n].trim() && !/^```/.test(o[n]) && !/^(#{1,3})\s+/.test(o[n]) && !/^\s*[-*+]\s+/.test(o[n]) && !/^\s*\d+\.\s+/.test(o[n]); )
692
- d.push(o[n]), n += 1;
706
+ for (o += 1; o < n.length && n[o].trim() && !/^```/.test(n[o]) && !/^(#{1,3})\s+/.test(n[o]) && !/^\s*[-*+]\s+/.test(n[o]) && !/^\s*\d+\.\s+/.test(n[o]); )
707
+ d.push(n[o]), o += 1;
693
708
  const u = document.createElement("p");
694
709
  d.forEach((p, g) => {
695
710
  g > 0 && u.appendChild(document.createElement("br")), $(u, p);
@@ -697,11 +712,11 @@ function de(t, e) {
697
712
  }
698
713
  }
699
714
  function $(t, e) {
700
- const o = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
701
- let n = 0;
702
- for (const a of e.matchAll(o)) {
715
+ const n = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
716
+ let o = 0;
717
+ for (const a of e.matchAll(n)) {
703
718
  const r = a.index ?? 0;
704
- r > n && t.appendChild(document.createTextNode(e.slice(n, r)));
719
+ r > o && t.appendChild(document.createTextNode(e.slice(o, r)));
705
720
  const i = a[0];
706
721
  if (i.startsWith("`")) {
707
722
  const d = document.createElement("code");
@@ -714,17 +729,17 @@ function $(t, e) {
714
729
  d.textContent = i.slice(1, -1), t.appendChild(d);
715
730
  } else {
716
731
  const d = i.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
717
- if (d && je(d[2])) {
732
+ if (d && qe(d[2])) {
718
733
  const u = document.createElement("a");
719
734
  u.href = d[2], u.target = "_top", u.rel = "noreferrer", u.textContent = d[1], t.appendChild(u);
720
735
  } else
721
736
  t.appendChild(document.createTextNode(i));
722
737
  }
723
- n = r + i.length;
738
+ o = r + i.length;
724
739
  }
725
- n < e.length && t.appendChild(document.createTextNode(e.slice(n)));
740
+ o < e.length && t.appendChild(document.createTextNode(e.slice(o)));
726
741
  }
727
- function je(t) {
742
+ function qe(t) {
728
743
  if (t.startsWith("/") || t.startsWith("#"))
729
744
  return !0;
730
745
  try {
@@ -734,11 +749,11 @@ function je(t) {
734
749
  return !1;
735
750
  }
736
751
  }
737
- function ce(t, e) {
752
+ function ue(t, e) {
738
753
  if (t.getElementById("pluno-pa-widget-styles"))
739
754
  return;
740
- const o = t.ownerDocument.createElement("style");
741
- o.id = "pluno-pa-widget-styles", o.textContent = `
755
+ const n = t.ownerDocument.createElement("style");
756
+ n.id = "pluno-pa-widget-styles", n.textContent = `
742
757
  :host {
743
758
  all: initial;
744
759
  color-scheme: light;
@@ -1579,7 +1594,18 @@ function ce(t, e) {
1579
1594
  margin-top: -11px;
1580
1595
  }
1581
1596
  .pluno-pa-widget--scribble .pluno-pa-widget__tool-group {
1582
- margin-bottom: -16px;
1597
+ align-items: center;
1598
+ margin-bottom: -8px;
1599
+ }
1600
+ .pluno-pa-widget--scribble .pluno-pa-widget__tool-group details {
1601
+ transform: translateY(-3px);
1602
+ }
1603
+ .pluno-pa-widget--scribble .pluno-pa-widget__thinking-marker .pluno-pa-widget__status,
1604
+ .pluno-pa-widget--scribble .pluno-pa-widget__status.pluno-pa-widget__bottom-reserve-compact {
1605
+ transform: translateY(-2px);
1606
+ }
1607
+ .pluno-pa-widget--scribble .pluno-pa-widget__thinking-marker.pluno-pa-widget__bottom-reserve-compact {
1608
+ margin-bottom: 28px;
1583
1609
  }
1584
1610
  /* Wobbly outlines: the filter runs on a ::before layer that draws each
1585
1611
  box's fill and border, so text glyphs stay crisp */
@@ -1730,9 +1756,9 @@ function ce(t, e) {
1730
1756
  .pluno-pa-widget--scribble .pluno-pa-widget__close svg {
1731
1757
  filter: url(#pluno-pa-scribble-wobble-2);
1732
1758
  }
1733
- `, t.appendChild(o);
1759
+ `, t.appendChild(n);
1734
1760
  }
1735
- async function qe() {
1761
+ async function Ye() {
1736
1762
  return document.body ? document.body : await new Promise((t) => {
1737
1763
  const e = new MutationObserver(() => {
1738
1764
  document.body && (e.disconnect(), t(document.body));
@@ -1744,54 +1770,54 @@ function D(t) {
1744
1770
  const e = document.createElement("span");
1745
1771
  return e.textContent = t, e.innerHTML;
1746
1772
  }
1747
- function we(t) {
1773
+ function me(t) {
1748
1774
  return `pluno.productAgent.widgetState.${location.origin}.${t.backendUrl ?? ""}.${t.tokenEndpoint ?? ""}.${t.position ?? ""}`;
1749
1775
  }
1750
- function Ye(t) {
1776
+ function Ze(t) {
1751
1777
  try {
1752
- const e = window.localStorage.getItem(we(t));
1778
+ const e = window.localStorage.getItem(me(t));
1753
1779
  if (!e)
1754
1780
  return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
1755
- const o = JSON.parse(e);
1781
+ const n = JSON.parse(e);
1756
1782
  return {
1757
- isOpen: o.isOpen === !0,
1758
- composerValue: typeof o.composerValue == "string" ? o.composerValue : "",
1759
- openToolGroupKeys: Array.isArray(o.openToolGroupKeys) ? o.openToolGroupKeys.filter((n) => typeof n == "string") : []
1783
+ isOpen: n.isOpen === !0,
1784
+ composerValue: typeof n.composerValue == "string" ? n.composerValue : "",
1785
+ openToolGroupKeys: Array.isArray(n.openToolGroupKeys) ? n.openToolGroupKeys.filter((o) => typeof o == "string") : []
1760
1786
  };
1761
1787
  } catch {
1762
1788
  return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
1763
1789
  }
1764
1790
  }
1765
- function Ze(t, e) {
1791
+ function Xe(t, e) {
1766
1792
  try {
1767
- window.localStorage.setItem(we(t), JSON.stringify(e));
1793
+ window.localStorage.setItem(me(t), JSON.stringify(e));
1768
1794
  } catch {
1769
1795
  return;
1770
1796
  }
1771
1797
  }
1772
- const ue = /* @__PURE__ */ new WeakSet();
1773
- function Xe(t) {
1798
+ const ge = /* @__PURE__ */ new WeakSet();
1799
+ function Je(t) {
1774
1800
  return Object.keys(t.dataset).some((e) => e.startsWith("pluno"));
1775
1801
  }
1776
- function ge(t) {
1802
+ function be(t) {
1777
1803
  const e = t.pathname.split("/");
1778
1804
  return e[e.length - 1] ?? "";
1779
1805
  }
1780
- function Je(t, e) {
1781
- const o = new URL(t.src, document.baseURI);
1782
- return o.href === e.href || o.pathname === e.pathname ? !0 : ge(o) === ge(e);
1806
+ function Qe(t, e) {
1807
+ const n = new URL(t.src, document.baseURI);
1808
+ return n.href === e.href || n.pathname === e.pathname ? !0 : be(n) === be(e);
1783
1809
  }
1784
1810
  class C extends EventTarget {
1785
- constructor(e, o) {
1786
- super(), this.channelId = o, this.url = e, this.addPreviewListener(Oe, () => {
1811
+ constructor(e, n) {
1812
+ super(), this.channelId = n, this.url = e, this.addPreviewListener($e, () => {
1787
1813
  this.readyState = C.OPEN, this.dispatchEvent(new Event("open"));
1788
- }), this.addPreviewListener($e, (n) => {
1789
- const a = n;
1814
+ }), this.addPreviewListener(De, (o) => {
1815
+ const a = o;
1790
1816
  this.dispatchEvent(new MessageEvent("message", { data: a.detail?.data ?? "" }));
1791
- }), this.addPreviewListener(De, () => {
1817
+ }), this.addPreviewListener(Fe, () => {
1792
1818
  this.readyState = C.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
1793
- }), this.addPreviewListener(Fe, (n) => {
1794
- const a = n;
1819
+ }), this.addPreviewListener(Re, (o) => {
1820
+ const a = o;
1795
1821
  this.readyState = C.CLOSED, this.dispatchEvent(
1796
1822
  new CloseEvent("close", {
1797
1823
  code: a.detail?.code ?? 1e3,
@@ -1816,37 +1842,37 @@ class C extends EventTarget {
1816
1842
  binaryType = "blob";
1817
1843
  bufferedAmount = 0;
1818
1844
  readyState = C.CONNECTING;
1819
- socketId = Qe();
1845
+ socketId = et();
1820
1846
  listeners = /* @__PURE__ */ new Map();
1821
1847
  send(e) {
1822
1848
  if (this.readyState !== C.OPEN)
1823
1849
  throw new DOMException("Product Agent preview websocket is not open", "InvalidStateError");
1824
1850
  window.dispatchEvent(
1825
- new CustomEvent(F(Ie, this.channelId), {
1851
+ new CustomEvent(F(Me, this.channelId), {
1826
1852
  detail: { socketId: this.socketId, data: typeof e == "string" ? e : String(e) }
1827
1853
  })
1828
1854
  );
1829
1855
  }
1830
- close(e, o) {
1856
+ close(e, n) {
1831
1857
  this.readyState !== C.CLOSED && (this.readyState = C.CLOSING, window.dispatchEvent(
1832
- new CustomEvent(F(Me, this.channelId), {
1833
- detail: { socketId: this.socketId, code: e, reason: o }
1858
+ new CustomEvent(F(Oe, this.channelId), {
1859
+ detail: { socketId: this.socketId, code: e, reason: n }
1834
1860
  })
1835
1861
  ), this.cleanup());
1836
1862
  }
1837
- addPreviewListener(e, o) {
1838
- const n = F(e, this.channelId), a = (r) => {
1839
- r.detail?.socketId === this.socketId && o(r);
1863
+ addPreviewListener(e, n) {
1864
+ const o = F(e, this.channelId), a = (r) => {
1865
+ r.detail?.socketId === this.socketId && n(r);
1840
1866
  };
1841
- this.listeners.set(n, a), window.addEventListener(n, a);
1867
+ this.listeners.set(o, a), window.addEventListener(o, a);
1842
1868
  }
1843
1869
  cleanup() {
1844
- for (const [e, o] of this.listeners.entries())
1845
- window.removeEventListener(e, o);
1870
+ for (const [e, n] of this.listeners.entries())
1871
+ window.removeEventListener(e, n);
1846
1872
  this.listeners.clear();
1847
1873
  }
1848
1874
  }
1849
- function Qe() {
1875
+ function et() {
1850
1876
  const t = window.sessionStorage.getItem(te);
1851
1877
  if (t)
1852
1878
  return t;
@@ -1856,39 +1882,39 @@ function Qe() {
1856
1882
  function F(t, e) {
1857
1883
  return `${t}:${e}`;
1858
1884
  }
1859
- function et(t) {
1885
+ function tt(t) {
1860
1886
  const e = document.currentScript;
1861
1887
  if (e instanceof HTMLScriptElement)
1862
1888
  return [e];
1863
- const o = new URL(t, document.baseURI).href, n = new URL(o);
1889
+ const n = new URL(t, document.baseURI).href, o = new URL(n);
1864
1890
  return Array.from(document.querySelectorAll("script[type='module'][src]")).filter(
1865
- (a) => a instanceof HTMLScriptElement && Xe(a) && Je(a, n)
1891
+ (a) => a instanceof HTMLScriptElement && Je(a) && Qe(a, o)
1866
1892
  );
1867
1893
  }
1868
- function tt(t) {
1869
- for (const e of et(t)) {
1870
- if (ue.has(e) || e.dataset.plunoAutoMount === "false")
1894
+ function nt(t) {
1895
+ for (const e of tt(t)) {
1896
+ if (ge.has(e) || e.dataset.plunoAutoMount === "false")
1871
1897
  continue;
1872
- ue.add(e);
1873
- const o = e.dataset.plunoPreviewChannel;
1874
- Be({
1898
+ ge.add(e);
1899
+ const n = e.dataset.plunoPreviewChannel;
1900
+ Ue({
1875
1901
  token: e.dataset.plunoToken,
1876
1902
  tokenEndpoint: e.dataset.plunoTokenEndpoint,
1877
1903
  backendUrl: e.dataset.plunoBackendUrl,
1878
- webSocketFactory: o ? ze(o) : void 0,
1904
+ webSocketFactory: n ? Be(n) : void 0,
1879
1905
  launcherLabel: e.dataset.plunoLauncherLabel,
1880
1906
  accentColor: e.dataset.plunoAccentColor,
1881
1907
  colorScheme: e.dataset.plunoColorScheme === "dark" ? "dark" : "light",
1882
1908
  fontFamily: e.dataset.plunoFontFamily,
1883
1909
  scribbleStyle: e.dataset.plunoScribbleStyle === "true",
1884
1910
  position: e.dataset.plunoPosition === "bottom-left" ? "bottom-left" : "bottom-right"
1885
- }).catch((n) => {
1886
- console.error("Failed to mount Pluno Product Agent widget", n);
1911
+ }).catch((o) => {
1912
+ console.error("Failed to mount Pluno Product Agent widget", o);
1887
1913
  });
1888
1914
  }
1889
1915
  }
1890
- tt(import.meta.url);
1916
+ nt(import.meta.url);
1891
1917
  export {
1892
- ze as createProductAgentPreviewBridgeWebSocketFactory,
1893
- Be as mountPlunoProductAgentWidget
1918
+ Be as createProductAgentPreviewBridgeWebSocketFactory,
1919
+ Ue as mountPlunoProductAgentWidget
1894
1920
  };