@pluno/product-agent-web 0.1.15 → 0.1.17

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