@sidebandai/sideband-react 0.0.0-stage → 1.4.3

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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -2
  3. package/dist/SurveyRenderer-DeiwF3pw.js +1270 -0
  4. package/dist/client/create-sideband-client.d.ts +2 -0
  5. package/dist/client/create-sideband-client.d.ts.map +1 -0
  6. package/dist/components/SurveyFab.d.ts +11 -0
  7. package/dist/components/SurveyFab.d.ts.map +1 -0
  8. package/dist/components/SurveyProgress.d.ts +6 -0
  9. package/dist/components/SurveyProgress.d.ts.map +1 -0
  10. package/dist/components/SurveyQuestionView.d.ts +11 -0
  11. package/dist/components/SurveyQuestionView.d.ts.map +1 -0
  12. package/dist/components/SurveyRenderer.d.ts +7 -0
  13. package/dist/components/SurveyRenderer.d.ts.map +1 -0
  14. package/dist/components/SurveySheet.d.ts +10 -0
  15. package/dist/components/SurveySheet.d.ts.map +1 -0
  16. package/dist/components/SurveySnackbar.d.ts +9 -0
  17. package/dist/components/SurveySnackbar.d.ts.map +1 -0
  18. package/dist/components/SurveyThankYou.d.ts +9 -0
  19. package/dist/components/SurveyThankYou.d.ts.map +1 -0
  20. package/dist/context/SidebandProvider.d.ts +8 -0
  21. package/dist/context/SidebandProvider.d.ts.map +1 -0
  22. package/dist/context/sideband-context.d.ts +18 -0
  23. package/dist/context/sideband-context.d.ts.map +1 -0
  24. package/dist/hooks/useSideband.d.ts +2 -0
  25. package/dist/hooks/useSideband.d.ts.map +1 -0
  26. package/dist/index.d.ts +12 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +183 -0
  29. package/dist/preview.d.ts +21 -0
  30. package/dist/preview.d.ts.map +1 -0
  31. package/dist/preview.js +50 -0
  32. package/dist/style.css +2 -0
  33. package/dist/style.css.d.ts +2 -0
  34. package/dist/types.d.ts +4 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/package.json +46 -4
@@ -0,0 +1,1270 @@
1
+ import { buildFabTitle as e, getChoiceValue as t, isPositiveSentimentChoice as n, isSystemOtherChoice as r, resolveSnackbarPresentation as i } from "@sidebandai/sideband-core";
2
+ import { memo as a, useCallback as o, useEffect as s, useId as c, useLayoutEffect as l, useRef as u, useState as d, useSyncExternalStore as f } from "react";
3
+ import { createPortal as p } from "react-dom";
4
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
5
+ //#region ../design-tokens/src/index.ts
6
+ var _ = "rgba(0, 0, 0, 0)", v = (e, t = 1) => ({
7
+ hex: e,
8
+ alpha: t
9
+ }), y = (e, t) => [
10
+ {
11
+ variable: `--sb-theme-choice-${e}-background`,
12
+ path: [
13
+ "choice",
14
+ e,
15
+ "background"
16
+ ],
17
+ fallback: t[0]
18
+ },
19
+ {
20
+ variable: `--sb-theme-choice-${e}-foreground`,
21
+ path: [
22
+ "choice",
23
+ e,
24
+ "foreground"
25
+ ],
26
+ fallback: t[1]
27
+ },
28
+ {
29
+ variable: `--sb-theme-choice-${e}-border`,
30
+ path: [
31
+ "choice",
32
+ e,
33
+ "border"
34
+ ],
35
+ fallback: t[2]
36
+ }
37
+ ], b = (e, t) => [
38
+ {
39
+ variable: `--sb-theme-button-${e}-foreground`,
40
+ path: [
41
+ "button",
42
+ e,
43
+ "foreground"
44
+ ],
45
+ fallback: t[0]
46
+ },
47
+ {
48
+ variable: `--sb-theme-button-${e}-background`,
49
+ path: [
50
+ "button",
51
+ e,
52
+ "background"
53
+ ],
54
+ fallback: t[1]
55
+ },
56
+ {
57
+ variable: `--sb-theme-button-${e}-hover-background`,
58
+ path: [
59
+ "button",
60
+ e,
61
+ "hoverBackground"
62
+ ],
63
+ fallback: t[2]
64
+ },
65
+ {
66
+ variable: `--sb-theme-button-${e}-pressed-background`,
67
+ path: [
68
+ "button",
69
+ e,
70
+ "pressedBackground"
71
+ ],
72
+ fallback: t[3]
73
+ },
74
+ {
75
+ variable: `--sb-theme-button-${e}-disabled-background`,
76
+ path: [
77
+ "button",
78
+ e,
79
+ "disabledBackground"
80
+ ],
81
+ fallback: t[4]
82
+ },
83
+ {
84
+ variable: `--sb-theme-button-${e}-disabled-foreground`,
85
+ path: [
86
+ "button",
87
+ e,
88
+ "disabledForeground"
89
+ ],
90
+ fallback: t[5]
91
+ }
92
+ ], x = [
93
+ {
94
+ variable: "--sb-theme-sheet-background",
95
+ path: ["sheet", "background"],
96
+ fallback: v("#FFFFFF")
97
+ },
98
+ {
99
+ variable: "--sb-theme-sheet-scrim",
100
+ path: ["sheet", "scrim"],
101
+ fallback: v("#000000", .5)
102
+ },
103
+ {
104
+ variable: "--sb-theme-sheet-divider",
105
+ path: ["sheet", "divider"],
106
+ fallback: v("#E5E5E5")
107
+ },
108
+ {
109
+ variable: "--sb-theme-sheet-progress-track",
110
+ path: ["sheet", "progressTrack"],
111
+ fallback: v("#000000", .12)
112
+ },
113
+ {
114
+ variable: "--sb-theme-sheet-progress-fill",
115
+ path: ["sheet", "progressFill"],
116
+ fallback: v("#000000")
117
+ },
118
+ {
119
+ variable: "--sb-theme-sheet-close-button-background",
120
+ path: ["sheet", "closeButtonBackground"],
121
+ fallback: v("#000000", 0)
122
+ },
123
+ {
124
+ variable: "--sb-theme-sheet-close-button-foreground",
125
+ path: ["sheet", "closeButtonForeground"],
126
+ fallback: v("#000000")
127
+ },
128
+ {
129
+ variable: "--sb-theme-content-heading",
130
+ path: ["content", "heading"],
131
+ fallback: v("#000000")
132
+ },
133
+ {
134
+ variable: "--sb-theme-content-body",
135
+ path: ["content", "body"],
136
+ fallback: v("#333030")
137
+ },
138
+ {
139
+ variable: "--sb-theme-content-helper",
140
+ path: ["content", "helper"],
141
+ fallback: v("#5C5C5C")
142
+ },
143
+ {
144
+ variable: "--sb-theme-content-error",
145
+ path: ["content", "error"],
146
+ fallback: v("#B42318")
147
+ },
148
+ {
149
+ variable: "--sb-theme-completion-outer-background",
150
+ path: ["completion", "outerBackground"],
151
+ fallback: v("#E8E8E8")
152
+ },
153
+ {
154
+ variable: "--sb-theme-completion-inner-background",
155
+ path: ["completion", "innerBackground"],
156
+ fallback: v("#000000")
157
+ },
158
+ {
159
+ variable: "--sb-theme-completion-glyph",
160
+ path: ["completion", "glyph"],
161
+ fallback: v("#FFFFFF")
162
+ },
163
+ ...y("default", [
164
+ v("#FFFFFF"),
165
+ v("#000000"),
166
+ v("#DBDBDB")
167
+ ]),
168
+ ...y("hover", [
169
+ v("#F5F5F5"),
170
+ v("#000000"),
171
+ v("#DBDBDB")
172
+ ]),
173
+ ...y("pressed", [
174
+ v("#000000"),
175
+ v("#FFFFFF"),
176
+ v("#000000")
177
+ ]),
178
+ ...y("selected", [
179
+ v("#000000"),
180
+ v("#FFFFFF"),
181
+ v("#000000")
182
+ ]),
183
+ ...y("disabled", [
184
+ v("#F2F2F2"),
185
+ v("#8A8A8A"),
186
+ v("#E5E5E5")
187
+ ]),
188
+ ...b("primary", [
189
+ v("#FFFFFF"),
190
+ v("#121212"),
191
+ v("#292929"),
192
+ v("#000000"),
193
+ v("#E5E5E5"),
194
+ v("#8A8A8A")
195
+ ]),
196
+ ...b("secondary", [
197
+ v("#000000"),
198
+ v("#F2F2F2"),
199
+ v("#E8E8E8"),
200
+ v("#DBDBDB"),
201
+ v("#E5E5E5"),
202
+ v("#8A8A8A")
203
+ ]),
204
+ ...b("tertiary", [
205
+ v("#000000"),
206
+ v("#FFFFFF"),
207
+ v("#F5F5F5"),
208
+ v("#E8E8E8"),
209
+ v("#E5E5E5"),
210
+ v("#8A8A8A")
211
+ ]),
212
+ {
213
+ variable: "--sb-theme-input-background",
214
+ path: ["input", "background"],
215
+ fallback: v("#FFFFFF")
216
+ },
217
+ {
218
+ variable: "--sb-theme-input-foreground",
219
+ path: ["input", "foreground"],
220
+ fallback: v("#000000")
221
+ },
222
+ {
223
+ variable: "--sb-theme-input-placeholder",
224
+ path: ["input", "placeholder"],
225
+ fallback: v("#000000", .4)
226
+ },
227
+ {
228
+ variable: "--sb-theme-input-border",
229
+ path: ["input", "border"],
230
+ fallback: v("#000000", .18)
231
+ },
232
+ {
233
+ variable: "--sb-theme-input-focused-border",
234
+ path: ["input", "focusedBorder"],
235
+ fallback: v("#000000", .7)
236
+ },
237
+ {
238
+ variable: "--sb-theme-input-error-border",
239
+ path: ["input", "errorBorder"],
240
+ fallback: v("#B42318")
241
+ },
242
+ {
243
+ variable: "--sb-theme-input-disabled-background",
244
+ path: ["input", "disabledBackground"],
245
+ fallback: v("#F2F2F2")
246
+ },
247
+ {
248
+ variable: "--sb-theme-input-disabled-foreground",
249
+ path: ["input", "disabledForeground"],
250
+ fallback: v("#8A8A8A")
251
+ },
252
+ {
253
+ variable: "--sb-theme-fab-background",
254
+ path: ["fab", "background"],
255
+ fallback: v("#000000")
256
+ },
257
+ {
258
+ variable: "--sb-theme-fab-foreground",
259
+ path: ["fab", "foreground"],
260
+ fallback: v("#FFFFFF")
261
+ },
262
+ {
263
+ variable: "--sb-theme-fab-border",
264
+ path: ["fab", "border"],
265
+ fallback: v("#FFFFFF", .15)
266
+ },
267
+ {
268
+ variable: "--sb-theme-fab-accent-primary",
269
+ path: ["fab", "accentPrimary"],
270
+ fallback: v("#000000")
271
+ },
272
+ {
273
+ variable: "--sb-theme-fab-accent-secondary",
274
+ path: ["fab", "accentSecondary"],
275
+ fallback: v("#FFFFFF")
276
+ },
277
+ {
278
+ variable: "--sb-theme-fab-timer-track",
279
+ path: ["fab", "timerTrack"],
280
+ fallback: v("#000000", .16)
281
+ },
282
+ {
283
+ variable: "--sb-theme-fab-timer-fill",
284
+ path: ["fab", "timerFill"],
285
+ fallback: v("#000000")
286
+ }
287
+ ];
288
+ x.map((e) => e.variable), Object.fromEntries(x.map((e) => [e.variable, C(e.fallback)]));
289
+ function S(e) {
290
+ return e && typeof e == "object" && !Array.isArray(e) ? e : {};
291
+ }
292
+ function C(e, t = _) {
293
+ return !e || typeof e.hex != "string" || !/^#[0-9a-fA-F]{6}$/.test(e.hex) || !Number.isFinite(e.alpha) || e.alpha < 0 || e.alpha > 1 ? t : `rgba(${Number.parseInt(e.hex.slice(1, 3), 16)}, ${Number.parseInt(e.hex.slice(3, 5), 16)}, ${Number.parseInt(e.hex.slice(5, 7), 16)}, ${e.alpha})`;
294
+ }
295
+ function w(e, t) {
296
+ let n = e;
297
+ for (let e of t) n = S(n)[e];
298
+ return n;
299
+ }
300
+ function T(e) {
301
+ return Object.fromEntries(x.map((t) => [t.variable, C(w(e, t.path), C(t.fallback))]));
302
+ }
303
+ function E(e, t) {
304
+ return v(`#${[
305
+ 1,
306
+ 3,
307
+ 5
308
+ ].map((n) => {
309
+ let r = Number.parseInt(e.hex.slice(n, n + 2), 16), i = Number.parseInt(t.hex.slice(n, n + 2), 16);
310
+ return Math.round(r * e.alpha + i * (1 - e.alpha)).toString(16).padStart(2, "0");
311
+ }).join("")}`, 1);
312
+ }
313
+ function ee(e) {
314
+ let t = (t) => {
315
+ let n = x.find((e) => e.path.join(".") === t.join(".")), r = w(e, t);
316
+ return C(r, "") ? r : n.fallback;
317
+ }, n = {
318
+ ...t(["sheet", "background"]),
319
+ alpha: 1
320
+ }, r = t(["content", "heading"]), i = t([
321
+ "choice",
322
+ "selected",
323
+ "background"
324
+ ]), a = E(i, n), o = [
325
+ 1,
326
+ 3,
327
+ 5
328
+ ].map((e) => Number.parseInt(n.hex.slice(e, e + 2), 16) / 255), s = o[0] * .2126 + o[1] * .7152 + o[2] * .0722 < .5, c = n.hex.toUpperCase() === (s ? "#000000" : "#FFFFFF"), l = (e, t) => C(E({
329
+ ...e,
330
+ alpha: e.alpha * t
331
+ }, n)), u = E({
332
+ ...r,
333
+ alpha: r.alpha * (s ? c ? .15 : .08 : .14)
334
+ }, n), d = (e) => [
335
+ 1,
336
+ 3,
337
+ 5
338
+ ].reduce((t, n, r) => t + Number.parseInt(e.hex.slice(n, n + 2), 16) * [
339
+ .2126,
340
+ .7152,
341
+ .0722
342
+ ][r], 0), f = d(u) > d(n);
343
+ return {
344
+ "--sb-snackbar-surface": C(n),
345
+ "--sb-snackbar-text": C(r),
346
+ "--sb-snackbar-border": C(v(s ? "#FFFFFF" : "#000000", s ? .1 : .05)),
347
+ "--sb-snackbar-normal": l(r, s ? c ? .2 : .14 : c ? .08 : .1),
348
+ "--sb-snackbar-hover": l(r, s ? c ? .24 : .18 : .04),
349
+ "--sb-snackbar-pressed": l(i, s ? c ? .28 : .24 : .2),
350
+ "--sb-snackbar-active": C(a),
351
+ "--sb-snackbar-on-active": C(t([
352
+ "choice",
353
+ "selected",
354
+ "foreground"
355
+ ])),
356
+ "--sb-snackbar-ghost": C(u),
357
+ "--sb-snackbar-remaining": C(f ? u : n),
358
+ "--sb-snackbar-elapsed": C(f ? n : u)
359
+ };
360
+ }
361
+ var D = {
362
+ entrance: 1969.207,
363
+ timerEntrance: 2169.207,
364
+ widen: 200,
365
+ expand: 450
366
+ }, O = {
367
+ delay: 400,
368
+ enter: 450,
369
+ exit: 400,
370
+ removal: 450,
371
+ reduced: 150
372
+ }, te = O.delay + O.enter;
373
+ function k(e, t) {
374
+ let { viewport: n, safeArea: r = {}, compactHeight: i } = t, a = M(r.left) + 12, o = M(r.right) + 12, s = M(r.top) + 24, c = M(r.bottom) + 8, l = Math.max(0, n.width - a - o), u = Math.min(364, l), d = Math.min(376, l), f = Math.max(0, n.height - s - c), p = Math.min(t.cardHeight, f);
375
+ if (t.barPosition) return {
376
+ compactWidth: n.width,
377
+ compactLeft: 0,
378
+ compactBottom: 0,
379
+ cardWidth: d,
380
+ cardHeight: p,
381
+ maxCardHeight: f,
382
+ cardLeft: a + (l - d) / 2,
383
+ cardBottom: c,
384
+ cardTop: M(r.top) + 12,
385
+ entranceOffset: 0,
386
+ transformOrigin: t.barPosition === "top" ? "50% 0%" : "50% 100%"
387
+ };
388
+ let m = F(e, {
389
+ viewport: n,
390
+ element: {
391
+ width: u,
392
+ height: i
393
+ },
394
+ safeArea: r
395
+ }), h = Math.max(a, Math.min(m.left, n.width - o - u)), g = Math.max(c, Math.min(n.height - m.top - i, n.height - s - i));
396
+ return {
397
+ compactWidth: u,
398
+ cardWidth: d,
399
+ compactLeft: h,
400
+ compactBottom: g,
401
+ cardHeight: p,
402
+ maxCardHeight: f,
403
+ cardTop: 0,
404
+ entranceOffset: (u - i) * P(e?.anchor).x,
405
+ cardLeft: a + (l - d) / 2,
406
+ cardBottom: Math.max(c, Math.min(g, n.height - s - p)),
407
+ transformOrigin: m.transformOrigin
408
+ };
409
+ }
410
+ var A = {
411
+ x: 1,
412
+ y: 1
413
+ }, j = {
414
+ x: -16,
415
+ y: -24
416
+ };
417
+ function M(e) {
418
+ return typeof e == "number" && Number.isFinite(e) ? Math.max(0, e) : 0;
419
+ }
420
+ function N(e) {
421
+ return typeof e == "number" && Number.isFinite(e) ? e : 0;
422
+ }
423
+ function P(e) {
424
+ let t = S(e), n = typeof t.x == "number" && Number.isFinite(t.x) ? t.x : A.x, r = typeof t.y == "number" && Number.isFinite(t.y) ? t.y : A.y;
425
+ return {
426
+ x: Math.min(1, Math.max(0, n)),
427
+ y: Math.min(1, Math.max(0, r))
428
+ };
429
+ }
430
+ function F(e, t) {
431
+ let n = S(e), r = P(n.position), i = P(n.anchor), a = S(n.offset), o = e ? N(a.x) : j.x, s = e ? N(a.y) : j.y, c = t.safeArea ?? {}, l = M(c.left), u = M(c.right), d = M(c.top), f = M(c.bottom), p = Math.max(0, M(t.viewport.width) - l - u - M(t.element.width)), m = Math.max(0, M(t.viewport.height) - d - f - M(t.element.height));
432
+ return {
433
+ left: l + r.x * p + o,
434
+ top: d + r.y * m + s,
435
+ travelX: p,
436
+ travelY: m,
437
+ position: r,
438
+ anchor: i,
439
+ transformOrigin: `${i.x * 100}% ${i.y * 100}%`
440
+ };
441
+ }
442
+ function I(e, t, n = "forward") {
443
+ let r = e === "bar" || e === "fill" ? e : "none", i = n === "reverse" ? "reverse" : "forward", a = typeof t == "number" && Number.isFinite(t) && t > 0 ? t : null;
444
+ return {
445
+ style: r,
446
+ direction: i,
447
+ durationMs: a,
448
+ visible: r !== "none",
449
+ cssVariables: {
450
+ "--sb-timer-style": r,
451
+ "--sb-timer-direction": i,
452
+ ...a === null ? {} : { "--sb-timer-duration": `${a}ms` }
453
+ }
454
+ };
455
+ }
456
+ //#endregion
457
+ //#region src/lib/components/SurveyFab.tsx
458
+ function L({ session: t, fabRef: n, onClick: r, animationState: i }) {
459
+ let { survey: a } = t, o = I(a.fab?.timerStyle, a.fab?.expandedTimeout), s = { ...o.cssVariables }, c = a.fab?.imageUrl, [l, u] = d(null), f = !!(c && l !== c);
460
+ return /* @__PURE__ */ g("button", {
461
+ ref: n,
462
+ type: "button",
463
+ className: `sb-fab sb-fab--expanded sb-fab--${i}`,
464
+ onClick: r,
465
+ disabled: i === "exiting",
466
+ "aria-hidden": i === "exiting" || void 0,
467
+ tabIndex: i === "exiting" ? -1 : void 0,
468
+ "aria-label": e(a),
469
+ "data-timer-style": o.style,
470
+ style: s,
471
+ children: [
472
+ o.visible ? /* @__PURE__ */ h("span", {
473
+ className: `sb-fab__timer sb-fab__timer--${o.style}`,
474
+ "aria-hidden": "true",
475
+ children: /* @__PURE__ */ h("span", { className: "sb-fab__timer-fill" })
476
+ }) : null,
477
+ /* @__PURE__ */ h("span", {
478
+ className: "sb-fab__badge",
479
+ "aria-hidden": "true",
480
+ children: f ? /* @__PURE__ */ h("img", {
481
+ className: "sb-fab__badge-image",
482
+ src: c,
483
+ alt: "",
484
+ onError: () => u(c ?? null)
485
+ }) : /* @__PURE__ */ g("span", {
486
+ className: "sb-fab__badge-art",
487
+ children: [
488
+ /* @__PURE__ */ h("span", { className: "sb-fab__badge-inner" }),
489
+ /* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--center" }),
490
+ /* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--amber" }),
491
+ /* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--mint" }),
492
+ /* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--rose" })
493
+ ]
494
+ })
495
+ }),
496
+ /* @__PURE__ */ h("span", {
497
+ className: "sb-fab__label",
498
+ children: e(a)
499
+ })
500
+ ]
501
+ });
502
+ }
503
+ //#endregion
504
+ //#region src/lib/components/SurveyProgress.tsx
505
+ function R({ value: e }) {
506
+ return /* @__PURE__ */ h("div", {
507
+ className: "sb-progress",
508
+ "aria-hidden": "true",
509
+ children: /* @__PURE__ */ h("span", {
510
+ className: "sb-progress__fill",
511
+ style: { "--sb-progress-value": `${Math.max(0, Math.min(1, e)) * 100}%` }
512
+ })
513
+ });
514
+ }
515
+ //#endregion
516
+ //#region src/lib/components/SurveyQuestionView.tsx
517
+ var z = [];
518
+ function B() {
519
+ return /* @__PURE__ */ h("svg", {
520
+ viewBox: "0 0 35.5556 35.5556",
521
+ "aria-hidden": "true",
522
+ children: /* @__PURE__ */ h("path", {
523
+ d: "M19.436 3.05195 11.2286 11.2594c-.5481.5481-.8592 1.3037-.8592 2.0888v14.8c0 1.6297 1.3333 2.963 2.9629 2.963h13.3334c1.1851 0 2.2518-.7111 2.7259-1.7926l4.8296-11.2741c1.2445-2.9333-.9037-6.1925-4.0889-6.1925H21.762l1.4074-6.78523c.1481-.74075-.0741-1.4963-.6074-2.02963-.8741-.85926-2.2667-.85926-3.126.01481ZM4.44343 31.1112c1.62963 0 2.96296-1.3333 2.96296-2.963V16.2964c0-1.6296-1.33333-2.963-2.96296-2.963-1.62963 0-2.96296 1.3334-2.96296 2.963v11.8518c0 1.6297 1.33333 2.963 2.96296 2.963Z",
524
+ fill: "currentColor"
525
+ })
526
+ });
527
+ }
528
+ function V() {
529
+ return /* @__PURE__ */ h("svg", {
530
+ viewBox: "0 0 35.5556 35.5556",
531
+ "aria-hidden": "true",
532
+ children: /* @__PURE__ */ h("path", {
533
+ d: "m16.1165 32.5036 8.1926-8.2074c.5481-.5482.8592-1.3037.8592-2.0889v-14.8c0-1.62963-1.3333-2.96296-2.9629-2.96296H8.88686c-1.18519 0-2.25185.71111-2.71111 1.79259L1.34612 17.511c-1.25926 2.9333.88889 6.1926 4.07407 6.1926h8.37041l-1.4074 6.7852c-.1482.7407.074 1.4963.6074 2.0296.874.8593 2.2666.8593 3.1259-.0148ZM31.1091 4.44434c-1.6296 0-2.963 1.33333-2.963 2.96296v11.8519c0 1.6296 1.3334 2.9629 2.963 2.9629 1.6296 0 2.9629-1.3333 2.9629-2.9629V7.4073c0-1.62963-1.3333-2.96296-2.9629-2.96296Z",
534
+ fill: "currentColor"
535
+ })
536
+ });
537
+ }
538
+ function H() {
539
+ return /* @__PURE__ */ h("span", {
540
+ className: "sb-spark-ring",
541
+ "aria-hidden": "true",
542
+ children: Array.from({ length: 12 }, (e, t) => /* @__PURE__ */ h("span", {
543
+ className: t % 2 == 0 ? "sb-spark-ring__dot sb-spark-ring__dot--large" : "sb-spark-ring__dot",
544
+ style: { "--sb-spark-index": t }
545
+ }, t))
546
+ });
547
+ }
548
+ function U({ question: e, store: t, isSentiment: n }) {
549
+ let i = t.currentDraft(), a = t.getState(), o = !!(a?.isBusy || a?.isCompleting), s = e.answers?.find((e) => e.id === i?.answer_key);
550
+ return s && r(s) ? /* @__PURE__ */ h(G, {
551
+ store: t,
552
+ disabled: o,
553
+ placeholder: s.label,
554
+ autoFocus: !0,
555
+ ariaLabel: "Other response",
556
+ isOther: !0
557
+ }) : n ? /* @__PURE__ */ h(W, {
558
+ store: t,
559
+ disabled: o || !!a?.sentimentSelectionLocked
560
+ }) : e.type === "yes_no" || e.type === "multiple_choice" ? /* @__PURE__ */ h(ne, {
561
+ question: e,
562
+ store: t,
563
+ disabled: o
564
+ }) : /* @__PURE__ */ h(G, {
565
+ store: t,
566
+ disabled: o,
567
+ placeholder: e.free_text_placeholder ?? "Please explain more... (Optional)",
568
+ autoFocus: e.required,
569
+ ariaLabel: e.prompt
570
+ });
571
+ }
572
+ function W({ store: e, disabled: t }) {
573
+ let r = e.currentDraft();
574
+ return /* @__PURE__ */ h("div", {
575
+ className: "sb-question sb-question--sentiment",
576
+ children: e.sentimentChoices().map((i) => {
577
+ let a = n(i), o = r?.answer_key === i.id;
578
+ return /* @__PURE__ */ g("span", {
579
+ className: "sb-sentiment-control",
580
+ children: [o && a ? /* @__PURE__ */ h(H, {}) : null, /* @__PURE__ */ h("button", {
581
+ type: "button",
582
+ className: `sb-yesno ${o ? "sb-yesno--selected" : ""}`,
583
+ "data-choice-value": i.id,
584
+ onClick: () => void e.selectChoice(i),
585
+ disabled: t,
586
+ "aria-label": i.label,
587
+ "aria-pressed": o,
588
+ children: /* @__PURE__ */ h("span", {
589
+ className: "sb-yesno__icon",
590
+ children: h(a ? B : V, {})
591
+ })
592
+ })]
593
+ }, i.id);
594
+ })
595
+ });
596
+ }
597
+ function ne({ question: e, store: t, disabled: n }) {
598
+ let i = e.answers ?? z, a = t.currentDraft(), o = u(null), [c, l] = d(() => i.every((e) => e.label.trim().length < 20));
599
+ return s(() => {
600
+ let e = () => {
601
+ let e = ((o.current?.clientWidth || 328) - 8) / 2, t = document.createElement("span");
602
+ t.style.cssText = "position:fixed;visibility:hidden;white-space:nowrap;font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif;font-size:16px;", document.body.appendChild(t);
603
+ let n = i.every((n) => {
604
+ t.style.fontWeight = r(n) ? "400" : "700", t.textContent = n.label.trim();
605
+ let i = t.getBoundingClientRect().width;
606
+ return (i > 0 ? i : n.label.trim().length * (r(n) ? 8 : 8.6)) + 16 + +!!r(n) < e;
607
+ });
608
+ t.remove(), l(n);
609
+ };
610
+ e(), window.addEventListener("resize", e);
611
+ let t = o.current, n = typeof ResizeObserver > "u" || !t ? null : new ResizeObserver(e);
612
+ return t && n?.observe(t), () => {
613
+ window.removeEventListener("resize", e), n?.disconnect();
614
+ };
615
+ }, [i]), /* @__PURE__ */ h("div", {
616
+ ref: o,
617
+ className: `sb-question sb-question--choices ${c ? "sb-question--choices-grid" : "sb-question--choices-list"}`,
618
+ children: /* @__PURE__ */ h("div", {
619
+ className: `sb-options-scroll ${(c ? Math.ceil(i.length / 2) : i.length) >= 5 ? "sb-options-scroll--scrolling" : ""}`,
620
+ children: i.map((e) => /* @__PURE__ */ h(re, {
621
+ choice: e,
622
+ selected: a?.answer_key === e.id,
623
+ disabled: n,
624
+ store: t
625
+ }, e.id))
626
+ })
627
+ });
628
+ }
629
+ function re({ choice: e, selected: n, disabled: i, store: a }) {
630
+ let o = r(e);
631
+ return /* @__PURE__ */ h("button", {
632
+ type: "button",
633
+ className: `sb-choice ${n ? "sb-choice--selected" : ""} ${o ? "sb-choice--other" : ""}`,
634
+ "data-choice-value": t(e),
635
+ onClick: () => void a.selectChoice(e),
636
+ disabled: i,
637
+ "aria-label": e.label,
638
+ "aria-pressed": n,
639
+ children: o ? /* @__PURE__ */ g("span", {
640
+ className: "sb-choice__other-content",
641
+ "aria-hidden": "true",
642
+ children: [/* @__PURE__ */ h("span", { className: "sb-choice__other-caret" }), /* @__PURE__ */ h("span", {
643
+ className: "sb-choice__other-label",
644
+ children: e.label
645
+ })]
646
+ }) : /* @__PURE__ */ h("span", {
647
+ className: "sb-choice__label",
648
+ children: e.label
649
+ })
650
+ });
651
+ }
652
+ function G({ store: e, disabled: t, placeholder: n, autoFocus: r, ariaLabel: i, isOther: a = !1 }) {
653
+ let o = u(null);
654
+ return s(() => {
655
+ r && !t && o.current?.focus({ preventScroll: !0 });
656
+ }, [r, t]), /* @__PURE__ */ h("div", {
657
+ className: `sb-question sb-question--text ${a ? "sb-question--other sb-question--other-text" : ""}`,
658
+ children: /* @__PURE__ */ h("div", {
659
+ className: "sb-textarea-shell",
660
+ children: /* @__PURE__ */ h("textarea", {
661
+ ref: o,
662
+ className: "sb-textarea",
663
+ value: e.currentText(),
664
+ onChange: (t) => e.setText(t.target.value),
665
+ disabled: t,
666
+ placeholder: n,
667
+ "aria-label": i,
668
+ autoFocus: r,
669
+ "data-autofocus": r || void 0
670
+ })
671
+ })
672
+ });
673
+ }
674
+ //#endregion
675
+ //#region src/lib/components/SurveyThankYou.tsx
676
+ function ie({ completion: e, store: t, isBusy: n, headingId: r, bodyId: i }) {
677
+ let a = u(null), [o, c] = d(!1);
678
+ return s(() => {
679
+ let e = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1, t = setTimeout(() => c(!0), e ? 0 : 890);
680
+ return () => clearTimeout(t);
681
+ }, [e.node_id]), s(() => {
682
+ o && a.current?.focus({ preventScroll: !0 });
683
+ }, [o]), /* @__PURE__ */ g("div", {
684
+ className: "sb-thanks",
685
+ children: [
686
+ /* @__PURE__ */ h("div", {
687
+ className: "sb-thanks__icon-shell",
688
+ "aria-hidden": "true",
689
+ children: /* @__PURE__ */ h("div", {
690
+ className: "sb-thanks__icon-core",
691
+ children: /* @__PURE__ */ h("svg", {
692
+ viewBox: "0 0 36 28",
693
+ children: /* @__PURE__ */ h("path", {
694
+ d: "M11.2619 21.3151 2.86082 12.914 0 15.7546l11.2619 11.262 24.176-24.17593L32.5972 0 11.2619 21.3151Z",
695
+ fill: "currentColor"
696
+ })
697
+ })
698
+ })
699
+ }),
700
+ /* @__PURE__ */ g("div", {
701
+ className: "sb-thanks__copy",
702
+ "aria-hidden": !o,
703
+ children: [/* @__PURE__ */ h("h2", {
704
+ ref: a,
705
+ id: r,
706
+ tabIndex: -1,
707
+ children: e.title
708
+ }), e.body ? /* @__PURE__ */ h("p", {
709
+ id: i,
710
+ children: e.body
711
+ }) : null]
712
+ }),
713
+ e.actions.length ? /* @__PURE__ */ h("div", {
714
+ className: "sb-thanks__actions",
715
+ "aria-hidden": !o,
716
+ children: e.actions.map((e) => /* @__PURE__ */ h("button", {
717
+ type: "button",
718
+ className: `sb-button sb-button--${e.style === "primary" || e.style === "secondary" ? e.style : "tertiary"}`,
719
+ onClick: () => void t.handleCompletionAction(e),
720
+ disabled: n || !o,
721
+ children: e.label
722
+ }, e.id))
723
+ }) : null
724
+ ]
725
+ });
726
+ }
727
+ //#endregion
728
+ //#region src/lib/components/SurveySheet.tsx
729
+ var K = a(function({ session: e, store: t, modal: n, rootRef: r, interactive: i = !0 }) {
730
+ let a = e.currentNodeId ? e.survey.questions[e.currentNodeId] : void 0, o = !!(a && t.isSentimentStep()), l = a?.answers?.find((e) => e.id === t.currentDraft()?.answer_key), d = l?.comment?.trim() || null, f = l?.id === "system_other", p = u(null), _ = c();
731
+ s(() => {
732
+ if (!i) return;
733
+ let e = (e) => {
734
+ if (e.key === "Escape" && t.closeSurvey(), !n || e.key !== "Tab" || !p.current) return;
735
+ let r = Array.from(p.current.querySelectorAll("button:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])"));
736
+ if (!r.length) {
737
+ e.preventDefault(), p.current.querySelector("[tabindex=\"-1\"]")?.focus();
738
+ return;
739
+ }
740
+ let i = document.activeElement, a = r.indexOf(i), o = e.shiftKey ? a <= 0 ? r.length - 1 : a - 1 : a === r.length - 1 ? 0 : a + 1;
741
+ e.preventDefault(), r[o]?.focus();
742
+ };
743
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
744
+ }, [
745
+ i,
746
+ n,
747
+ e.completion,
748
+ t
749
+ ]);
750
+ let v = e.completion ? `sb-completion-${_}` : `sb-question-${_}`, y = `sb-completion-body-${_}`;
751
+ return /* @__PURE__ */ g("div", {
752
+ ref: r,
753
+ className: `sb-sheet-root ${e.isCompleting ? "sb-sheet-root--completing" : ""}`,
754
+ children: [/* @__PURE__ */ h("button", {
755
+ type: "button",
756
+ tabIndex: -1,
757
+ className: "sb-sheet-root__overlay",
758
+ onClick: () => void t.closeSurvey(),
759
+ "aria-label": "Dismiss survey"
760
+ }), /* @__PURE__ */ h("div", {
761
+ ref: p,
762
+ className: `sb-sheet ${e.completion ? "sb-sheet--thanks" : ""} ${o ? "sb-sheet--sentiment" : ""}`,
763
+ role: "dialog",
764
+ ...n ? { "aria-modal": !0 } : {},
765
+ "aria-labelledby": v,
766
+ "aria-describedby": e.completion?.body ? y : void 0,
767
+ "aria-busy": e.isCompleting || void 0,
768
+ children: e.completion ? /* @__PURE__ */ h(ie, {
769
+ completion: e.completion,
770
+ store: t,
771
+ isBusy: e.isBusy,
772
+ headingId: v,
773
+ bodyId: y
774
+ }) : a ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g("div", {
775
+ className: "sb-sheet__header",
776
+ children: [o ? null : /* @__PURE__ */ h(R, { value: t.progress() }), /* @__PURE__ */ h("button", {
777
+ type: "button",
778
+ className: "sb-sheet__close",
779
+ onClick: () => void t.closeSurvey(),
780
+ "aria-label": "Close survey",
781
+ children: /* @__PURE__ */ h("svg", {
782
+ viewBox: "0 0 24 24",
783
+ "aria-hidden": "true",
784
+ children: /* @__PURE__ */ h("path", {
785
+ d: "M6.4 6.4 17.6 17.6M17.6 6.4 6.4 17.6",
786
+ fill: "none",
787
+ stroke: "currentColor",
788
+ strokeWidth: "2",
789
+ strokeLinecap: "round"
790
+ })
791
+ })
792
+ })]
793
+ }), /* @__PURE__ */ g("div", {
794
+ className: "sb-sheet__stage",
795
+ children: [/* @__PURE__ */ g("div", {
796
+ className: `sb-sheet__body ${o ? "sb-sheet__body--sentiment" : "sb-sheet__body--question"}`,
797
+ children: [/* @__PURE__ */ g("div", {
798
+ className: `sb-sheet__copy ${o && d ? "sb-sheet__copy--acknowledgement" : ""}`,
799
+ children: [o && !d ? /* @__PURE__ */ h("p", {
800
+ className: "sb-sheet__eyebrow",
801
+ children: e.survey.title
802
+ }) : null, /* @__PURE__ */ h("h2", {
803
+ id: v,
804
+ tabIndex: -1,
805
+ "aria-live": o && d ? "polite" : void 0,
806
+ children: o && d ? d : a.prompt
807
+ })]
808
+ }), /* @__PURE__ */ h(U, {
809
+ question: a,
810
+ store: t,
811
+ isSentiment: o
812
+ }, a.node_id)]
813
+ }), t.shouldShowContinue() ? /* @__PURE__ */ g("div", {
814
+ className: "sb-sheet__footer",
815
+ children: [d ? /* @__PURE__ */ h("p", {
816
+ className: "sb-sheet__answer-comment",
817
+ role: "status",
818
+ children: d
819
+ }) : /* @__PURE__ */ h("span", { className: "sb-sheet__footer-spacer" }), /* @__PURE__ */ h("button", {
820
+ type: "button",
821
+ className: `sb-next ${l ? "sb-next--acknowledging" : ""}`,
822
+ onClick: () => void t.advance(),
823
+ disabled: e.isBusy || e.isCompleting || !t.canContinue(),
824
+ "aria-label": "Continue",
825
+ children: /* @__PURE__ */ h("svg", {
826
+ viewBox: "0 0 14 14",
827
+ "aria-hidden": "true",
828
+ children: /* @__PURE__ */ h("path", {
829
+ d: "M6.66667 0 5.49167 1.175l4.65 4.65833H0V7.5h10.1417l-4.65 4.6583 1.175 1.175L13.3333 6.66667 6.66667 0Z",
830
+ fill: "currentColor"
831
+ })
832
+ })
833
+ }, l?.id ?? "unselected")]
834
+ }) : null]
835
+ }, `${a.node_id}:${f ? "text" : "options"}`)] }) : null
836
+ })]
837
+ });
838
+ }), ae = typeof window > "u" ? s : l, q = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1;
839
+ function oe({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
840
+ let c = u(null), [l, f] = d("entering"), { presentationId: p, survey: _, snackbar: v, isOpen: y } = e, b = e.sentimentPresentation === "bar", x = b ? e.barPosition : void 0, S = o ? "exiting" : y && (l === "entering" || l === "compact") ? "widening" : l, C = _.questions[_.root_node_id], w = i(C, _.fab), T = _.fab?.timerStyle ?? "none", E = b && e.barBehavior === "dismiss" && v?.selectedKey != null, [A, j] = d(!1);
841
+ s(() => {
842
+ if (o) return;
843
+ let e = setTimeout(() => {
844
+ f("compact"), t.confirmPresentation("expanded_fab", p), t.confirmFabEntranceCompleted(p), b && c.current?.querySelector(".sb-snackbar-surface")?.matches(":hover") && window.matchMedia?.("(hover: hover)").matches && t.setBarTimerPaused(p, !0);
845
+ }, b ? q() ? O.reduced : te : q() ? 0 : T === "none" ? D.entrance : D.timerEntrance);
846
+ return () => clearTimeout(e);
847
+ }, [
848
+ p,
849
+ t,
850
+ T,
851
+ b,
852
+ o
853
+ ]), s(() => {
854
+ if (!y || o) return;
855
+ let e = q(), n = setTimeout(() => f("expanding"), e ? 0 : D.widen), r = setTimeout(() => {
856
+ f("ready"), t.confirmPresentation("sheet", p), t.confirmSnackbarContentReady(p), c.current?.querySelector(".sb-sheet h2")?.focus({ preventScroll: !0 });
857
+ }, e ? 0 : D.widen + D.expand);
858
+ return () => {
859
+ clearTimeout(n), clearTimeout(r);
860
+ };
861
+ }, [
862
+ y,
863
+ p,
864
+ t,
865
+ o
866
+ ]), ae(() => {
867
+ let e = c.current;
868
+ if (!e || o) return;
869
+ let t = () => {
870
+ let t = e.parentElement, n = window.visualViewport, a = r === "inline" ? t.clientWidth : n?.width || window.innerWidth, o = r === "inline" ? t.clientHeight : n?.height || window.innerHeight, s = t.querySelector(".sb-safe-area-probe"), c = s ? getComputedStyle(s) : null, l = (e) => Number.parseFloat(e ?? "") || 0, u = e.querySelector(".sb-snackbar-compact"), d = e.querySelector(".sb-sheet"), f = i(C, _.fab).placement, p = {
871
+ viewport: {
872
+ width: a,
873
+ height: o
874
+ },
875
+ safeArea: r === "inline" ? {} : {
876
+ left: l(c?.paddingLeft),
877
+ right: l(c?.paddingRight),
878
+ top: l(c?.paddingTop),
879
+ bottom: l(c?.paddingBottom)
880
+ },
881
+ compactHeight: 64,
882
+ cardHeight: d?.offsetHeight || 0,
883
+ barPosition: x
884
+ };
885
+ e.style.setProperty("--sb-snackbar-compact-width", `${k(f, p).compactWidth}px`), E && (u.style.minHeight = "48px");
886
+ let m = getComputedStyle(u), h = Number.parseFloat(m.height) || u.offsetHeight || (x ? 48 : 64), g = E ? Math.max(h, (e.querySelector(".sb-bar-acknowledgement-copy")?.scrollHeight ?? 0) + l(m.paddingTop) + l(m.paddingBottom)) : h;
887
+ E && u.style.removeProperty("min-height");
888
+ let v = k(f, {
889
+ ...p,
890
+ compactHeight: g
891
+ });
892
+ r === "fixed" ? (e.style.left = `${n?.offsetLeft ?? 0}px`, e.style.top = `${n?.offsetTop ?? 0}px`, e.style.width = `${a}px`, e.style.height = `${o}px`) : (e.style.left = "0px", e.style.top = "0px", e.style.width = "100%", e.style.height = "100%");
893
+ let y = S === "widening" || S === "expanding" || S === "ready";
894
+ e.style.setProperty("--sb-bar-top", `${y ? v.cardTop : 0}px`);
895
+ let b = S === "expanding" || S === "ready", w = {
896
+ left: y ? v.cardLeft : v.compactLeft,
897
+ bottom: y ? v.cardBottom : v.compactBottom,
898
+ width: y ? v.cardWidth : v.compactWidth,
899
+ height: b ? v.cardHeight : g,
900
+ "compact-height": g,
901
+ "card-width": v.cardWidth,
902
+ "compact-width": v.compactWidth,
903
+ "entrance-offset": v.entranceOffset,
904
+ "max-height": v.maxCardHeight
905
+ };
906
+ for (let [t, n] of Object.entries(w)) e.style.setProperty(`--sb-snackbar-${t}`, `${n}px`);
907
+ e.querySelector(".sb-snackbar-shell").style.transformOrigin = v.transformOrigin;
908
+ };
909
+ t();
910
+ let n = typeof ResizeObserver > "u" ? null : new ResizeObserver(t), a = e.querySelector(".sb-snackbar-compact");
911
+ n?.observe(a);
912
+ let s = e.querySelector(".sb-sheet");
913
+ return s && n?.observe(s), r === "inline" && n?.observe(e.parentElement), window.addEventListener("resize", t), window.visualViewport?.addEventListener("resize", t), window.visualViewport?.addEventListener("scroll", t), () => {
914
+ n?.disconnect(), window.removeEventListener("resize", t), window.visualViewport?.removeEventListener("resize", t), window.visualViewport?.removeEventListener("scroll", t);
915
+ };
916
+ }, [
917
+ r,
918
+ S,
919
+ _,
920
+ C,
921
+ y,
922
+ x,
923
+ o,
924
+ E
925
+ ]), s(() => {
926
+ if (y || o) return;
927
+ let e = (e) => {
928
+ e.key === "Escape" && c.current?.contains(document.activeElement) && t.closeSurvey();
929
+ };
930
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
931
+ }, [
932
+ y,
933
+ t,
934
+ o
935
+ ]);
936
+ let M = v?.selectedKey, N = b && e.barBehavior === "dismiss", P = C.answers?.find((e) => e.id === M), F = P ? P.comment?.trim() || "Thanks for your feedback." : "", I = E, L = !o && e.fabEntranceCompleted && v?.phase === "question", R = v?.deadline != null || v?.pausedRemainingMs != null, z = T !== "none" && typeof _.fab?.expandedTimeout == "number" && _.fab.expandedTimeout > 0, H = {
937
+ ...ee(_.theme),
938
+ "--sb-snackbar-duration": `${_.fab?.expandedTimeout ?? 0}ms`,
939
+ "--sb-snackbar-fraction": v?.frozenFraction ?? 1
940
+ }, U = T === "none" ? null : /* @__PURE__ */ h("span", {
941
+ className: `sb-snackbar-timer sb-snackbar-timer--${T}`,
942
+ "aria-hidden": "true",
943
+ children: /* @__PURE__ */ h("span", { className: "sb-snackbar-timer-fill" })
944
+ }), W = /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g("p", {
945
+ className: "sb-snackbar-prompt",
946
+ children: [C.prompt, T === "bar" && !b ? U : null]
947
+ }), /* @__PURE__ */ h("div", {
948
+ className: "sb-snackbar-answers",
949
+ children: (C.answers ?? []).map((e) => /* @__PURE__ */ h("button", {
950
+ className: "sb-snackbar-answer",
951
+ type: "button",
952
+ "aria-label": e.label,
953
+ "aria-pressed": M === e.id,
954
+ disabled: !L,
955
+ onClick: () => t.answerSnackbar(p, e.id),
956
+ children: n(e) ? /* @__PURE__ */ h(B, {}) : /* @__PURE__ */ h(V, {})
957
+ }, e.id))
958
+ })] });
959
+ return /* @__PURE__ */ g("div", {
960
+ ref: c,
961
+ className: "sb-snackbar-root",
962
+ style: H,
963
+ "data-presentation": e.sentimentPresentation,
964
+ "data-position": x,
965
+ "data-behavior": e.barBehavior,
966
+ "data-stage": S,
967
+ "data-expanded": y,
968
+ "data-counting": R,
969
+ "data-paused": v?.pausedRemainingMs != null,
970
+ "data-timed": z,
971
+ "data-rated": I,
972
+ "data-exiting": o,
973
+ "data-frozen": v?.frozenFraction != null,
974
+ children: [/* @__PURE__ */ h("button", {
975
+ className: "sb-snackbar-overlay",
976
+ type: "button",
977
+ tabIndex: -1,
978
+ "aria-hidden": "true",
979
+ disabled: S !== "ready",
980
+ onClick: () => void t.closeSurvey()
981
+ }), /* @__PURE__ */ g("div", {
982
+ className: "sb-snackbar-shell",
983
+ children: [/* @__PURE__ */ g("div", {
984
+ className: "sb-snackbar-surface",
985
+ onPointerEnter: (e) => {
986
+ b && !o && e.pointerType === "mouse" && window.matchMedia?.("(hover: hover)").matches && t.setBarTimerPaused(p, !0);
987
+ },
988
+ onPointerLeave: () => {
989
+ b && !o && t.setBarTimerPaused(p, !1);
990
+ },
991
+ children: [/* @__PURE__ */ g("div", {
992
+ className: "sb-snackbar-compact",
993
+ role: "group",
994
+ "aria-label": C.prompt,
995
+ "aria-hidden": y || S === "entering" || o,
996
+ inert: y || S === "entering" || o,
997
+ children: [
998
+ T === "fill" || b && T === "bar" ? U : null,
999
+ b ? null : /* @__PURE__ */ g("span", {
1000
+ className: "sb-snackbar-artwork",
1001
+ "aria-hidden": "true",
1002
+ children: [/* @__PURE__ */ g("span", {
1003
+ className: "sb-fab__badge-art",
1004
+ children: [
1005
+ /* @__PURE__ */ h("span", { className: "sb-fab__badge-inner" }),
1006
+ /* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--center" }),
1007
+ /* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--amber" }),
1008
+ /* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--mint" }),
1009
+ /* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--rose" })
1010
+ ]
1011
+ }), w.imageUrl && !A ? /* @__PURE__ */ h("img", {
1012
+ src: w.imageUrl,
1013
+ alt: "",
1014
+ onError: () => j(!0)
1015
+ }) : null]
1016
+ }),
1017
+ b ? /* @__PURE__ */ h("div", {
1018
+ className: "sb-bar-content",
1019
+ inert: I,
1020
+ "aria-hidden": I,
1021
+ children: W
1022
+ }) : W,
1023
+ b ? /* @__PURE__ */ h("button", {
1024
+ className: "sb-bar-dismiss",
1025
+ type: "button",
1026
+ disabled: y || I || o,
1027
+ onClick: () => void t.closeSurvey(),
1028
+ children: "Not Now"
1029
+ }) : null,
1030
+ N ? /* @__PURE__ */ h("span", {
1031
+ className: "sb-bar-acknowledgement",
1032
+ role: "status",
1033
+ children: /* @__PURE__ */ h("span", {
1034
+ className: "sb-bar-acknowledgement-copy",
1035
+ children: F
1036
+ })
1037
+ }) : null
1038
+ ]
1039
+ }), y ? /* @__PURE__ */ h("div", {
1040
+ className: "sb-snackbar-card",
1041
+ inert: S !== "ready",
1042
+ "aria-hidden": S !== "ready",
1043
+ children: /* @__PURE__ */ h(K, {
1044
+ session: e,
1045
+ store: t,
1046
+ modal: a,
1047
+ interactive: S === "ready"
1048
+ })
1049
+ }) : null]
1050
+ }), b ? null : /* @__PURE__ */ h("button", {
1051
+ className: "sb-snackbar-close",
1052
+ type: "button",
1053
+ "aria-label": "Close survey",
1054
+ disabled: y,
1055
+ onClick: () => void t.closeSurvey(),
1056
+ children: /* @__PURE__ */ h("svg", {
1057
+ viewBox: "0 0 24 24",
1058
+ "aria-hidden": "true",
1059
+ children: /* @__PURE__ */ h("path", {
1060
+ d: "m6 6 12 12M18 6 6 18",
1061
+ fill: "none",
1062
+ stroke: "currentColor",
1063
+ strokeWidth: "2"
1064
+ })
1065
+ })
1066
+ })]
1067
+ })]
1068
+ });
1069
+ }
1070
+ //#endregion
1071
+ //#region src/lib/components/SurveyRenderer.tsx
1072
+ var J = typeof window > "u" ? s : l, Y = 1969.207, se = 2169.207, X = 856.839, Z = 450;
1073
+ function Q(e) {
1074
+ let t = Number.parseFloat(e);
1075
+ return Number.isFinite(t) ? Math.max(0, t) : 0;
1076
+ }
1077
+ function ce(e) {
1078
+ let t = 0;
1079
+ for (let n of e) t += /[MW@#%&]/.test(n) ? 11 : /[ilI1.,' ]/.test(n) ? 4 : 7.5;
1080
+ return Math.ceil(t);
1081
+ }
1082
+ function $() {
1083
+ return typeof window < "u" && (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1);
1084
+ }
1085
+ function le(e) {
1086
+ if (!e) return null;
1087
+ let { pulse_id: t, version: n, impression_id: r } = e.survey;
1088
+ return typeof r == "string" ? `${t}:${n}:${r}` : `${t}:${n}`;
1089
+ }
1090
+ function ue(e) {
1091
+ if (!e) return;
1092
+ let t = getComputedStyle(e), n = Number.parseFloat(t.width) || e.offsetWidth || 86, r = Number.parseFloat(e.style.getPropertyValue("--sb-fab-expanded-width")) || n, i = Number.parseFloat(e.style.getPropertyValue("--sb-fab-anchor-offset")) || 0, a = r === 60 ? 0 : i / (r - 60), o = e.querySelector(".sb-fab__label"), s = e.querySelector(".sb-fab__timer");
1093
+ e.style.setProperty("--sb-fab-exit-width", `${n}px`), e.style.setProperty("--sb-fab-exit-offset", `${(r - n) * a}px`), e.style.setProperty("--sb-fab-exit-scale", t.getPropertyValue("scale") || "1"), e.style.setProperty("--sb-fab-exit-label-opacity", o ? getComputedStyle(o).opacity : "0"), e.style.setProperty("--sb-fab-exit-timer-opacity", s ? getComputedStyle(s).opacity : "0");
1094
+ }
1095
+ function de({ session: e, store: t, fabRef: n, onClick: r }) {
1096
+ let [i, a] = d(e), [o, c] = d(null), l = le(e), u = e?.survey.fab, f = (u?.timerStyle === "bar" || u?.timerStyle === "fill") && typeof u.expandedTimeout == "number" && Number.isFinite(u.expandedTimeout) && u.expandedTimeout > 0, p = e ?? i;
1097
+ return J(() => {
1098
+ e && a(e);
1099
+ }, [e]), J(() => {
1100
+ !e && i && ue(n.current);
1101
+ }, [
1102
+ n,
1103
+ i,
1104
+ e
1105
+ ]), s(() => {
1106
+ if (!l) return;
1107
+ let e = $(), n = setTimeout(() => {
1108
+ t.confirmPresentation("expanded_fab"), t.confirmFabEntranceCompleted();
1109
+ }, e ? 0 : Y), r = setTimeout(() => c(l), e ? 0 : f ? se : Y);
1110
+ return () => {
1111
+ clearTimeout(n), clearTimeout(r);
1112
+ };
1113
+ }, [
1114
+ f,
1115
+ l,
1116
+ t
1117
+ ]), s(() => {
1118
+ if (e || !i) return;
1119
+ let t = setTimeout(() => a(null), $() ? 0 : X);
1120
+ return () => clearTimeout(t);
1121
+ }, [i, e]), p ? /* @__PURE__ */ h(L, {
1122
+ session: p,
1123
+ fabRef: n,
1124
+ onClick: r,
1125
+ animationState: e ? o === l ? "visible" : "entering" : "exiting"
1126
+ }) : null;
1127
+ }
1128
+ function fe({ session: e, store: t, modal: n }) {
1129
+ let [r, i] = d(e), a = u(null), o = e ?? r;
1130
+ return J(() => {
1131
+ e && i(e);
1132
+ }, [e]), J(() => {
1133
+ let t = a.current;
1134
+ !t || e || (t.classList.add("sb-sheet-root--exiting"), t.setAttribute("aria-hidden", "true"), t.querySelectorAll("button").forEach((e) => {
1135
+ e.disabled = !0;
1136
+ }));
1137
+ }, [e]), s(() => {
1138
+ if (e || !r) return;
1139
+ let t = setTimeout(() => i(null), $() ? 0 : Z);
1140
+ return () => clearTimeout(t);
1141
+ }, [r, e]), o ? /* @__PURE__ */ h(K, {
1142
+ session: o,
1143
+ store: t,
1144
+ modal: n,
1145
+ rootRef: a
1146
+ }, le(o)) : null;
1147
+ }
1148
+ function pe({ session: e, store: t, placement: n, modal: r }) {
1149
+ let [i, a] = d(e), o = e ?? i;
1150
+ return J(() => {
1151
+ e && a(e);
1152
+ }, [e]), s(() => {
1153
+ if (e || !i) return;
1154
+ let t = i.sentimentPresentation === "bar" ? $() ? O.reduced : O.removal : 0, n = setTimeout(() => a(null), t);
1155
+ return () => clearTimeout(n);
1156
+ }, [e, i]), !o || !e && o.sentimentPresentation !== "bar" ? null : /* @__PURE__ */ h(oe, {
1157
+ session: o,
1158
+ store: t,
1159
+ placement: n,
1160
+ modal: r,
1161
+ exiting: !e
1162
+ }, o.presentationId);
1163
+ }
1164
+ function me({ store: e, portal: t = !0, placement: n = "fixed" }) {
1165
+ let r = f(o((t) => e.subscribe(t), [e]), o(() => e.getSnapshot(), [e]), o(() => e.getServerSnapshot(), [e])).state, i = u(null), a = u(null), c = u(null), l = u(null), d = r ? r.completion ? "completion" : r.isOpen ? `sheet:${r.currentNodeId}` : `fab:${r.fabState}` : "none";
1166
+ J(() => {
1167
+ if (!r || !i.current) return;
1168
+ let e = T(r.survey.theme);
1169
+ for (let [t, n] of Object.entries(e)) i.current.style.setProperty(t, n);
1170
+ }, [r]), s(() => {
1171
+ let t = e.getState();
1172
+ if (!t) {
1173
+ let e = i.current?.querySelector("[data-presentation=\"bar\"][data-exiting=\"true\"]"), t = i.current?.querySelector(".sb-fab--exiting") ? X : Z, n = setTimeout(() => {
1174
+ let e = l.current;
1175
+ e?.isConnected ? e.focus() : e && i.current?.focus(), l.current = null;
1176
+ }, e ? $() ? O.reduced : O.removal : $() ? 0 : t);
1177
+ return () => clearTimeout(n);
1178
+ }
1179
+ if (t.isOpen || t.completion) {
1180
+ if (!l.current && document.activeElement instanceof HTMLElement && (l.current = document.activeElement), t.snackbar?.phase === "awaitingReady") return;
1181
+ e.confirmPresentation("sheet"), (i.current?.querySelector("textarea[data-autofocus=\"true\"]") ?? i.current?.querySelector(".sb-sheet__body h2"))?.focus({ preventScroll: !0 });
1182
+ }
1183
+ t.snackbar && !l.current && document.activeElement instanceof HTMLElement && (l.current = document.activeElement);
1184
+ }, [d, e]), J(() => {
1185
+ let e = a.current, t = i.current;
1186
+ if (!e || !t || !r || r.fabState !== "expanded" || r.isOpen) return;
1187
+ let o = () => {
1188
+ let e = a.current;
1189
+ if (!e || !c.current) return;
1190
+ let i = window.visualViewport, o = n === "inline" ? t.getBoundingClientRect() : null, s = n === "inline" ? t.clientWidth || o.width : i?.width && i.width > 0 ? i.width : window.innerWidth, l = n === "inline" ? t.clientHeight || o.height : i?.height && i.height > 0 ? i.height : window.innerHeight, u = e.getBoundingClientRect(), d = getComputedStyle(c.current), f = {
1191
+ top: Q(d.paddingTop),
1192
+ right: Q(d.paddingRight),
1193
+ bottom: Q(d.paddingBottom),
1194
+ left: Q(d.paddingLeft)
1195
+ }, p = Math.max(0, s - f.left - f.right), m = e.querySelector(".sb-fab__label"), h = m ? m.scrollWidth || m.getBoundingClientRect().width || ce(m.textContent ?? "") : 0, g = Math.min(p, Math.max(86, 86 + Math.ceil(h))), _ = e.offsetHeight || u.height || 60;
1196
+ e.style.setProperty("--sb-fab-expanded-width", `${g}px`), e.style.setProperty("--sb-fab-label-width", `${Math.max(0, g - 86)}px`);
1197
+ let v = Math.max(0, Math.min(1, r.survey.fab?.placement?.anchor.x ?? 1));
1198
+ e.style.setProperty("--sb-fab-anchor-offset", `${(g - 60) * v}px`);
1199
+ let y = F(r.survey.fab?.placement, {
1200
+ viewport: {
1201
+ width: s,
1202
+ height: l
1203
+ },
1204
+ element: {
1205
+ width: g,
1206
+ height: _
1207
+ },
1208
+ safeArea: f
1209
+ }), b = n === "inline" ? 0 : i?.offsetLeft ?? 0, x = n === "inline" ? 0 : i?.offsetTop ?? 0;
1210
+ e.style.left = `${y.left + b}px`, e.style.top = `${y.top + x}px`, e.style.right = "auto", e.style.bottom = "auto", e.style.transformOrigin = y.transformOrigin;
1211
+ };
1212
+ if (o(), n === "inline") {
1213
+ let e = typeof ResizeObserver > "u" ? null : new ResizeObserver(o);
1214
+ return e?.observe(t), window.addEventListener("resize", o), window.addEventListener("orientationchange", o), () => {
1215
+ e?.disconnect(), window.removeEventListener("resize", o), window.removeEventListener("orientationchange", o);
1216
+ };
1217
+ }
1218
+ return window.addEventListener("resize", o), window.addEventListener("orientationchange", o), window.visualViewport?.addEventListener("resize", o), window.visualViewport?.addEventListener("scroll", o), () => {
1219
+ window.removeEventListener("resize", o), window.removeEventListener("orientationchange", o), window.visualViewport?.removeEventListener("resize", o), window.visualViewport?.removeEventListener("scroll", o);
1220
+ };
1221
+ }, [n, r]), s(() => {
1222
+ if (!t || !r || !r.isOpen && !r.completion || !i.current) return;
1223
+ let e = i.current, n = Array.from(document.body.children).filter((t) => t !== e).map((e) => ({
1224
+ child: e,
1225
+ ariaHidden: e.getAttribute("aria-hidden"),
1226
+ inert: e.inert
1227
+ }));
1228
+ for (let { child: e } of n) e.setAttribute("aria-hidden", "true"), e.inert = !0;
1229
+ return () => {
1230
+ for (let e of n) e.ariaHidden === null ? e.child.removeAttribute("aria-hidden") : e.child.setAttribute("aria-hidden", e.ariaHidden), e.child.inert = e.inert;
1231
+ };
1232
+ }, [
1233
+ t,
1234
+ d,
1235
+ r
1236
+ ]);
1237
+ let m = /* @__PURE__ */ g("div", {
1238
+ ref: i,
1239
+ className: `sb-root sb-root--${n}`,
1240
+ tabIndex: -1,
1241
+ children: [
1242
+ /* @__PURE__ */ h("div", {
1243
+ ref: c,
1244
+ className: "sb-safe-area-probe"
1245
+ }),
1246
+ /* @__PURE__ */ h(pe, {
1247
+ session: r?.snackbar ? r : null,
1248
+ store: e,
1249
+ placement: n,
1250
+ modal: t
1251
+ }),
1252
+ /* @__PURE__ */ h(de, {
1253
+ session: r && !r.snackbar && !r.isOpen && !r.completion && r.fabState === "expanded" ? r : null,
1254
+ store: e,
1255
+ fabRef: a,
1256
+ onClick: () => {
1257
+ ue(a.current), l.current = a.current, e.openSurvey();
1258
+ }
1259
+ }),
1260
+ /* @__PURE__ */ h(fe, {
1261
+ session: r && !r.snackbar && (r.isOpen || r.completion) ? r : null,
1262
+ store: e,
1263
+ modal: t
1264
+ })
1265
+ ]
1266
+ });
1267
+ return t && typeof document < "u" ? p(m, document.body) : m;
1268
+ }
1269
+ //#endregion
1270
+ export { me as t };