dynaura 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,563 @@
1
+ "use client";
2
+
3
+ // src/store.ts
4
+ var g = globalThis;
5
+ var _a;
6
+ var S = (_a = g.__dynaura) != null ? _a : g.__dynaura = { current: null, queue: [], n: 0, subs: /* @__PURE__ */ new Set(), useQueue: false };
7
+ var set = (t) => {
8
+ S.current = t;
9
+ S.subs.forEach((f) => f());
10
+ };
11
+ var subscribe = (f) => {
12
+ S.subs.add(f);
13
+ return () => {
14
+ S.subs.delete(f);
15
+ };
16
+ };
17
+ var getCurrent = () => S.current;
18
+ var setQueue = (v) => {
19
+ S.useQueue = v;
20
+ };
21
+ var norm = (o) => typeof o === "string" ? { title: o } : o;
22
+ var make = (type) => (o) => {
23
+ var _a2;
24
+ const id = String(++S.n);
25
+ const sticky = type === "loading" || type === "live";
26
+ const t = { duration: sticky ? null : 4e3, ...type === "live" ? { kind: "timer" } : {}, ...norm(o), id, type };
27
+ if (S.current && ((_a2 = t.queue) != null ? _a2 : S.useQueue)) S.queue.push(t);
28
+ else set(t);
29
+ return id;
30
+ };
31
+ var update = (id, patch) => {
32
+ var _a2;
33
+ if (((_a2 = S.current) == null ? void 0 : _a2.id) === id) return set({ ...S.current, ...patch });
34
+ const i = S.queue.findIndex((t) => t.id === id);
35
+ if (i >= 0) S.queue[i] = { ...S.queue[i], ...patch };
36
+ };
37
+ var pick = (r, v) => norm(typeof r === "function" ? r(v) : r);
38
+ var dynaura = {
39
+ success: make("success"),
40
+ error: make("error"),
41
+ warning: make("warning"),
42
+ info: make("info"),
43
+ loading: make("loading"),
44
+ /** Live activity: sticky island with a running timer (default) or waveform. */
45
+ live: make("live"),
46
+ update,
47
+ /** dismiss the current toast (next queued one shows) or a specific id */
48
+ dismiss: (id) => {
49
+ var _a2, _b;
50
+ if (id && ((_a2 = S.current) == null ? void 0 : _a2.id) !== id) {
51
+ S.queue = S.queue.filter((t) => t.id !== id);
52
+ return;
53
+ }
54
+ set((_b = S.queue.shift()) != null ? _b : null);
55
+ },
56
+ clear: () => {
57
+ S.queue = [];
58
+ set(null);
59
+ },
60
+ promise(p, o) {
61
+ const id = make("loading")(o.loading);
62
+ p.then(
63
+ (v) => update(id, { duration: 4e3, ...pick(o.success, v), type: "success" }),
64
+ (e) => update(id, { duration: 4e3, ...pick(o.error, e), type: "error" })
65
+ );
66
+ return p;
67
+ }
68
+ };
69
+
70
+ // src/confetti.ts
71
+ function burst(x, y, color) {
72
+ const c = document.createElement("canvas");
73
+ const dpr = window.devicePixelRatio || 1;
74
+ const W = innerWidth, H = innerHeight;
75
+ c.width = W * dpr;
76
+ c.height = H * dpr;
77
+ c.style.cssText = `position:fixed;top:0;left:0;width:${W}px;height:${H}px;pointer-events:none;z-index:2147483647`;
78
+ document.body.append(c);
79
+ const ctx = c.getContext("2d");
80
+ if (!ctx) return c.remove();
81
+ ctx.scale(dpr, dpr);
82
+ const colors = [color, "#fff", color, "#ffd60a", "#0a84ff"];
83
+ const ps = Array.from({ length: 36 }, () => {
84
+ const a = Math.random() * Math.PI * 2, s = 3 + Math.random() * 6;
85
+ return { x, y, vx: Math.cos(a) * s, vy: Math.sin(a) * s - 3, r: 2 + Math.random() * 3, rot: Math.random() * 6, c: colors[Math.random() * colors.length | 0] };
86
+ });
87
+ const t0 = performance.now();
88
+ const frame = (t) => {
89
+ const k = (t - t0) / 1e3;
90
+ if (k >= 1) return c.remove();
91
+ ctx.clearRect(0, 0, W, H);
92
+ for (const p of ps) {
93
+ p.x += p.vx;
94
+ p.y += p.vy;
95
+ p.vy += 0.28;
96
+ p.vx *= 0.985;
97
+ p.rot += 0.2;
98
+ ctx.globalAlpha = 1 - k * k;
99
+ ctx.fillStyle = p.c;
100
+ ctx.save();
101
+ ctx.translate(p.x, p.y);
102
+ ctx.rotate(p.rot);
103
+ ctx.fillRect(-p.r, -p.r / 2, p.r * 2, p.r);
104
+ ctx.restore();
105
+ }
106
+ requestAnimationFrame(frame);
107
+ };
108
+ requestAnimationFrame(frame);
109
+ }
110
+
111
+ // src/core.ts
112
+ var VAR = {
113
+ background: "bg",
114
+ foreground: "fg",
115
+ muted: "muted",
116
+ ring: "ring",
117
+ button: "btn",
118
+ success: "success",
119
+ error: "error",
120
+ warning: "warning",
121
+ info: "info",
122
+ loading: "loading",
123
+ live: "live"
124
+ };
125
+ var svg = (d) => `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">${d}</svg>`;
126
+ var ICON = {
127
+ success: svg('<path class="dynaura-draw" d="M5 12.5l4.5 4.5L19 7.5"/>'),
128
+ error: svg('<path class="dynaura-draw" d="M7 7l10 10M17 7L7 17"/>'),
129
+ warning: svg('<path class="dynaura-draw" d="M12 6v7M12 17.5v.01"/>'),
130
+ info: svg('<path class="dynaura-draw" d="M12 11v6M12 7.5v.01"/>'),
131
+ loading: svg('<circle class="dynaura-spin" cx="12" cy="12" r="8" stroke-dasharray="30 50"/>')
132
+ };
133
+ var DOT = '<span class="dynaura-dot"></span>';
134
+ var WAVE = '<span class="dynaura-wave"><i></i><i></i><i></i><i></i></span>';
135
+ var VIBRATE = { success: [12], error: [24, 40, 24], warning: [30], info: [8], loading: [], live: [8] };
136
+ var f2 = (n) => +n.toFixed(2);
137
+ function outline(w, h2, cw, ch, hx) {
138
+ if (h2 <= ch + 1 || w <= cw + 1) {
139
+ const q = f2(Math.min(h2 / 2, w / 2, 32));
140
+ return `M${q} 0H${f2(w - q)}A${q} ${q} 0 0 1 ${f2(w)} ${q}V${f2(h2 - q)}A${q} ${q} 0 0 1 ${f2(w - q)} ${f2(h2)}H${q}A${q} ${q} 0 0 1 0 ${f2(h2 - q)}V${q}A${q} ${q} 0 0 1 ${q} 0Z`;
141
+ }
142
+ const r = f2(Math.min(ch / 2, 32));
143
+ const b = f2(Math.max(0, Math.min(28, (h2 - ch) / 2, (w - cw) / 2)));
144
+ const f = f2(Math.min(16, b));
145
+ const x0 = f2(hx), x1 = f2(hx + cw);
146
+ const flushL = hx < 1, flushR = hx + cw > w - 1;
147
+ let d = `M${f2(x0 + r)} 0H${f2(x1 - r)}A${r} ${r} 0 0 1 ${x1} ${r}`;
148
+ d += flushR ? `V${f2(h2 - b)}` : `V${f2(ch - f)}A${f} ${f} 0 0 0 ${f2(x1 + f)} ${f2(ch)}H${f2(w - b)}A${b} ${b} 0 0 1 ${f2(w)} ${f2(ch + b)}V${f2(h2 - b)}`;
149
+ d += `A${b} ${b} 0 0 1 ${f2(w - b)} ${f2(h2)}H${b}A${b} ${b} 0 0 1 0 ${f2(h2 - b)}`;
150
+ d += flushL ? `V${r}` : `V${f2(ch + b)}A${b} ${b} 0 0 1 ${b} ${f2(ch)}H${f2(x0 - f)}A${f} ${f} 0 0 0 ${x0} ${f2(ch - f)}V${r}`;
151
+ return d + `A${r} ${r} 0 0 1 ${f2(x0 + r)} 0Z`;
152
+ }
153
+ var h = (tag, cls, parent) => {
154
+ const e = document.createElement(tag);
155
+ e.className = cls;
156
+ parent == null ? void 0 : parent.append(e);
157
+ return e;
158
+ };
159
+ var restart = (e) => {
160
+ e.style.animation = "none";
161
+ void e.offsetWidth;
162
+ e.style.animation = "";
163
+ };
164
+ function roll(e, s) {
165
+ const sig = s.replace(/\d/g, "0");
166
+ if (e.dataset.sig !== sig) {
167
+ e.dataset.sig = sig;
168
+ e.replaceChildren();
169
+ e.setAttribute("role", "img");
170
+ for (const ch of s) {
171
+ if (/\d/.test(ch)) {
172
+ const d = h("span", "dynaura-digit", e);
173
+ d.setAttribute("aria-hidden", "true");
174
+ h("span", "dynaura-strip", d).innerHTML = "0123456789".replace(/\d/g, "<i>$&</i>");
175
+ } else h("span", "dynaura-char", e).textContent = ch;
176
+ }
177
+ }
178
+ e.setAttribute("aria-label", s);
179
+ [...s].forEach((ch, i) => {
180
+ if (/\d/.test(ch)) e.children[i].style.setProperty("--d", ch);
181
+ });
182
+ }
183
+ function createToaster(initial = {}) {
184
+ const o = { position: "top", offset: 12, theme: "dark", timer: true, haptics: true, queue: false };
185
+ const merge = (n) => {
186
+ for (const k in n) if (n[k] !== void 0) o[k] = n[k];
187
+ };
188
+ merge(initial);
189
+ const root = h("div", "dynaura-root");
190
+ const drag = h("div", "dynaura-drag", root);
191
+ const island = h("div", "dynaura-island", drag);
192
+ island.setAttribute("role", "status");
193
+ island.setAttribute("aria-live", "polite");
194
+ const inner = h("div", "dynaura-inner", island);
195
+ const row = h("div", "dynaura-row", inner);
196
+ const badge = h("span", "dynaura-badge", row);
197
+ const title = h("span", "dynaura-title", row);
198
+ const trail = h("span", "dynaura-trailing", row);
199
+ const body = h("div", "dynaura-body", inner);
200
+ const desc = h("div", "dynaura-desc", body);
201
+ const btn = h("button", "dynaura-button", body);
202
+ const bar = h("div", "dynaura-bar", island);
203
+ island.hidden = true;
204
+ island.dataset.expanded = "false";
205
+ island.dataset.paused = "false";
206
+ document.body.append(root);
207
+ let t = null;
208
+ let expanded = false, hovered = false, pinned = false, dragging = false, ready = false;
209
+ let hideT, expandT, collapseT, dismissT, liveI, lp;
210
+ let remaining = 0, startedAt = 0, liveStart = 0;
211
+ let sz = { cw: 0, ch: 0, ew: 0, eh: 0 };
212
+ let applied = [];
213
+ const hosts = /* @__PURE__ */ new Map();
214
+ const dir = () => o.position.startsWith("bottom") ? 1 : -1;
215
+ const hasBody = () => !!t && (t.description != null && typeof t.description !== "boolean" || !!t.button);
216
+ const paused = () => hovered || pinned || dragging;
217
+ function put(slot, c) {
218
+ var _a2;
219
+ const old = hosts.get(slot);
220
+ if (old) {
221
+ (_a2 = o.render) == null ? void 0 : _a2.call(o, old, null);
222
+ hosts.delete(slot);
223
+ }
224
+ slot.replaceChildren();
225
+ if (c == null || typeof c === "boolean") return;
226
+ if (typeof c === "string" || typeof c === "number") slot.textContent = String(c);
227
+ else if (c instanceof Node) slot.append(c);
228
+ else if (o.render) {
229
+ const host = h("span", "dynaura-host", slot);
230
+ hosts.set(slot, host);
231
+ o.render(host, c);
232
+ }
233
+ }
234
+ let raf = 0;
235
+ const isCard = () => island.dataset.variant === "card";
236
+ function shape() {
237
+ if (!isCard()) {
238
+ island.style.clipPath = "";
239
+ row.style.transform = "";
240
+ return;
241
+ }
242
+ const cs = getComputedStyle(island);
243
+ const w = parseFloat(cs.width), hh = parseFloat(cs.height);
244
+ if (!isFinite(w) || !isFinite(hh) || w <= 0) return;
245
+ const x = o.position.split("-")[1];
246
+ const hx = x === "left" ? 0 : x === "right" ? Math.max(0, w - sz.cw) : Math.max(0, (w - sz.cw) / 2);
247
+ row.style.transform = `translateX(${f2(hx)}px)`;
248
+ island.style.clipPath = `path('${outline(w, hh, sz.cw, sz.ch, hx)}')`;
249
+ }
250
+ function shapeLoop() {
251
+ cancelAnimationFrame(raf);
252
+ const end = performance.now() + 1300;
253
+ const f = () => {
254
+ shape();
255
+ if (performance.now() < end) raf = requestAnimationFrame(f);
256
+ };
257
+ f();
258
+ }
259
+ function size() {
260
+ if (!sz.cw) return;
261
+ const w = expanded ? sz.ew : sz.cw, hh = expanded ? sz.eh : sz.ch;
262
+ island.style.width = w + "px";
263
+ island.style.height = hh + "px";
264
+ island.style.borderRadius = isCard() ? "0" : Math.min(hh / 2, 32) + "px";
265
+ if (isCard()) shapeLoop();
266
+ else {
267
+ cancelAnimationFrame(raf);
268
+ island.style.clipPath = "";
269
+ row.style.transform = "";
270
+ }
271
+ }
272
+ function measure() {
273
+ if (island.hidden) return;
274
+ sz = { cw: row.offsetWidth, ch: row.offsetHeight, ew: inner.offsetWidth, eh: inner.offsetHeight };
275
+ size();
276
+ if (!ready && sz.cw) requestAnimationFrame(() => {
277
+ ready = true;
278
+ island.dataset.ready = "true";
279
+ });
280
+ }
281
+ const ro = new ResizeObserver(measure);
282
+ ro.observe(row);
283
+ ro.observe(inner);
284
+ function setExpanded(v) {
285
+ v = v && hasBody();
286
+ if (v === expanded) return;
287
+ expanded = v;
288
+ island.dataset.expanded = String(v);
289
+ size();
290
+ }
291
+ function clear() {
292
+ if (startedAt) {
293
+ remaining -= Date.now() - startedAt;
294
+ startedAt = 0;
295
+ }
296
+ clearTimeout(collapseT);
297
+ clearTimeout(dismissT);
298
+ }
299
+ function arm() {
300
+ clear();
301
+ if (!t || t.duration == null || paused()) return;
302
+ const id = t.id;
303
+ startedAt = Date.now();
304
+ collapseT = setTimeout(() => {
305
+ if (!pinned) setExpanded(false);
306
+ }, Math.max(0, remaining - 500));
307
+ dismissT = setTimeout(() => dynaura.dismiss(id), remaining);
308
+ }
309
+ function sync() {
310
+ island.dataset.paused = String(paused());
311
+ if (paused()) {
312
+ clear();
313
+ if (hovered || pinned) setExpanded(true);
314
+ } else arm();
315
+ }
316
+ function tick() {
317
+ var _a2;
318
+ if (!t || t.trailing != null) return;
319
+ if (t.progress != null) roll(trail, Math.round(t.progress * 100) + "%");
320
+ else if (t.type === "live" && ((_a2 = t.kind) != null ? _a2 : "timer") === "timer") {
321
+ const s = Math.floor((Date.now() - liveStart) / 1e3);
322
+ roll(trail, `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`);
323
+ }
324
+ }
325
+ const hasTrail = (n) => {
326
+ var _a2;
327
+ return n.trailing != null || n.progress != null || n.type === "live" && ((_a2 = n.kind) != null ? _a2 : "timer") === "timer";
328
+ };
329
+ function apply(n, p) {
330
+ var _a2, _b, _c;
331
+ const ch = (k) => !p || n[k] !== p[k];
332
+ island.dataset.type = n.type;
333
+ island.dataset.variant = drag.dataset.variant = (_a2 = n.variant) != null ? _a2 : "default";
334
+ if (ch("type") || ch("icon") || ch("kind")) {
335
+ put(badge, void 0);
336
+ if (n.icon != null) put(badge, n.icon);
337
+ else badge.innerHTML = n.type === "live" ? ((_b = n.kind) != null ? _b : "timer") === "wave" ? WAVE : DOT : ICON[n.type];
338
+ restart(badge);
339
+ }
340
+ if (ch("title")) {
341
+ title.textContent = n.title;
342
+ restart(title);
343
+ }
344
+ if (ch("trailing") || ch("progress") || ch("type") || ch("kind")) {
345
+ trail.hidden = !hasTrail(n);
346
+ if (n.trailing != null) {
347
+ delete trail.dataset.sig;
348
+ trail.removeAttribute("aria-label");
349
+ put(trail, n.trailing);
350
+ } else if (!hasTrail(n)) {
351
+ delete trail.dataset.sig;
352
+ put(trail, void 0);
353
+ }
354
+ }
355
+ if (ch("description")) put(desc, n.description);
356
+ desc.hidden = n.description == null || typeof n.description === "boolean";
357
+ btn.hidden = !n.button;
358
+ if (n.button) btn.textContent = n.button.title;
359
+ body.hidden = !(n.description != null && typeof n.description !== "boolean") && !n.button;
360
+ bar.dataset.mode = n.progress != null ? "value" : n.duration != null ? "time" : "none";
361
+ bar.style.setProperty("--p", String((_c = n.progress) != null ? _c : 0));
362
+ }
363
+ function feedback(n) {
364
+ var _a2, _b;
365
+ const active = (_b = (_a2 = navigator.userActivation) == null ? void 0 : _a2.hasBeenActive) != null ? _b : true;
366
+ if (o.haptics && typeof navigator !== "undefined" && navigator.vibrate && active && VIBRATE[n.type].length) navigator.vibrate(VIBRATE[n.type]);
367
+ if (n.confetti && !matchMedia("(prefers-reduced-motion: reduce)").matches) {
368
+ requestAnimationFrame(() => {
369
+ const r = island.getBoundingClientRect();
370
+ burst(r.left + r.width / 2, r.top + r.height / 2, getComputedStyle(island).getPropertyValue("--state").trim() || "#30d158");
371
+ });
372
+ }
373
+ }
374
+ const onlyProgress = (p, n) => p.progress == null === (n.progress == null) && [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(p)])].every((k) => k === "progress" || n[k] === p[k]);
375
+ function render() {
376
+ var _a2, _b, _c;
377
+ const n = getCurrent();
378
+ const p = t;
379
+ if (!n) {
380
+ if (p) leave();
381
+ return;
382
+ }
383
+ const same = !!p && p.id === n.id;
384
+ if (same && onlyProgress(p, n)) {
385
+ t = n;
386
+ bar.style.setProperty("--p", String((_a2 = n.progress) != null ? _a2 : 0));
387
+ tick();
388
+ return;
389
+ }
390
+ t = n;
391
+ clearTimeout(hideT);
392
+ if (island.hidden) {
393
+ island.hidden = false;
394
+ drag.style.transform = "";
395
+ drag.style.opacity = "";
396
+ restart(island);
397
+ }
398
+ island.dataset.open = "true";
399
+ if (!same) {
400
+ liveStart = Date.now();
401
+ pinned = false;
402
+ }
403
+ apply(n, same ? p : null);
404
+ measure();
405
+ if (!same || n.type !== p.type) feedback(n);
406
+ clearInterval(liveI);
407
+ if (n.type === "live") liveI = setInterval(tick, 1e3);
408
+ tick();
409
+ clear();
410
+ startedAt = 0;
411
+ remaining = (_b = n.duration) != null ? _b : 0;
412
+ restart(bar);
413
+ bar.style.animationDuration = ((_c = n.duration) != null ? _c : 0) + "ms";
414
+ if (!pinned) setExpanded(false);
415
+ clearTimeout(expandT);
416
+ if (hasBody()) expandT = setTimeout(() => setExpanded(true), 450);
417
+ sync();
418
+ }
419
+ function leave() {
420
+ clear();
421
+ startedAt = 0;
422
+ clearTimeout(expandT);
423
+ clearInterval(liveI);
424
+ hovered = pinned = dragging = false;
425
+ t = null;
426
+ island.dataset.open = "false";
427
+ hideT = setTimeout(() => {
428
+ cancelAnimationFrame(raf);
429
+ island.style.clipPath = "";
430
+ island.hidden = true;
431
+ ready = false;
432
+ expanded = false;
433
+ row.style.transform = "";
434
+ delete island.dataset.ready;
435
+ island.dataset.expanded = "false";
436
+ island.style.width = island.style.height = island.style.borderRadius = "";
437
+ [badge, trail, desc].forEach((s) => put(s, void 0));
438
+ delete trail.dataset.sig;
439
+ }, 450);
440
+ }
441
+ btn.onclick = () => {
442
+ const c = t;
443
+ if (c == null ? void 0 : c.button) {
444
+ c.button.onClick();
445
+ dynaura.dismiss(c.id);
446
+ }
447
+ };
448
+ let sy = 0, t0 = 0, moved = false, longed = false;
449
+ island.addEventListener("pointerenter", (e) => {
450
+ if (e.pointerType === "mouse") {
451
+ hovered = true;
452
+ sync();
453
+ }
454
+ });
455
+ island.addEventListener("pointerleave", (e) => {
456
+ if (e.pointerType !== "mouse") return;
457
+ hovered = false;
458
+ if (!pinned) setExpanded(false);
459
+ sync();
460
+ });
461
+ drag.addEventListener("pointerdown", (e) => {
462
+ var _a2;
463
+ if (!t || e.target.closest("button")) return;
464
+ dragging = true;
465
+ moved = longed = false;
466
+ sy = e.clientY;
467
+ t0 = Date.now();
468
+ (_a2 = drag.setPointerCapture) == null ? void 0 : _a2.call(drag, e.pointerId);
469
+ drag.style.transition = "none";
470
+ lp = setTimeout(() => {
471
+ var _a3;
472
+ if (!moved) {
473
+ longed = true;
474
+ pinned = true;
475
+ if (o.haptics) (_a3 = navigator.vibrate) == null ? void 0 : _a3.call(navigator, 8);
476
+ sync();
477
+ }
478
+ }, 450);
479
+ sync();
480
+ });
481
+ drag.addEventListener("pointermove", (e) => {
482
+ if (!dragging) return;
483
+ const dy = e.clientY - sy;
484
+ if (Math.abs(dy) > 6) {
485
+ moved = true;
486
+ clearTimeout(lp);
487
+ }
488
+ if (!moved) return;
489
+ const d = dy * dir();
490
+ const off = d > 0 ? d : -Math.sqrt(-d) * 4;
491
+ drag.style.transform = `translateY(${off * dir()}px)`;
492
+ });
493
+ const up = (e) => {
494
+ if (!dragging) return;
495
+ dragging = false;
496
+ clearTimeout(lp);
497
+ drag.style.transition = "";
498
+ const d = (e.clientY - sy) * dir();
499
+ const v = d / Math.max(1, Date.now() - t0);
500
+ if (e.type === "pointerup" && moved && (d > 40 || v > 0.5 && d > 10) && t) {
501
+ dynaura.dismiss(t.id);
502
+ return;
503
+ }
504
+ drag.style.transform = "";
505
+ if (e.type === "pointerup" && !moved && !longed && hasBody()) {
506
+ pinned = !pinned;
507
+ if (!pinned && !hovered) setExpanded(false);
508
+ }
509
+ sync();
510
+ };
511
+ drag.addEventListener("pointerup", up);
512
+ drag.addEventListener("pointercancel", up);
513
+ const outside = (e) => {
514
+ if (pinned && !island.contains(e.target)) {
515
+ pinned = false;
516
+ if (!hovered) setExpanded(false);
517
+ sync();
518
+ }
519
+ };
520
+ document.addEventListener("pointerdown", outside);
521
+ function set2(n) {
522
+ merge(n);
523
+ setQueue(o.queue);
524
+ const [y, x = "center"] = o.position.split("-");
525
+ root.dataset.y = y;
526
+ root.dataset.x = x;
527
+ root.dataset.timer = String(o.timer);
528
+ root.dataset.theme = typeof o.theme === "object" ? "custom" : o.theme;
529
+ root.style.setProperty("--dynaura-offset", o.offset + "px");
530
+ applied.forEach((v) => root.style.removeProperty(v));
531
+ applied = [];
532
+ if (typeof o.theme === "object")
533
+ for (const k in o.theme) {
534
+ const v = `--dynaura-${VAR[k]}`;
535
+ root.style.setProperty(v, o.theme[k]);
536
+ applied.push(v);
537
+ }
538
+ }
539
+ set2({});
540
+ const unsub = subscribe(render);
541
+ render();
542
+ return {
543
+ set: set2,
544
+ destroy() {
545
+ unsub();
546
+ ro.disconnect();
547
+ cancelAnimationFrame(raf);
548
+ document.removeEventListener("pointerdown", outside);
549
+ clear();
550
+ [hideT, expandT, liveI, lp].forEach((x) => {
551
+ clearTimeout(x);
552
+ clearInterval(x);
553
+ });
554
+ [badge, trail, desc].forEach((s) => put(s, void 0));
555
+ root.remove();
556
+ }
557
+ };
558
+ }
559
+
560
+ export {
561
+ dynaura,
562
+ createToaster
563
+ };