react-guide-step 0.1.0

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,863 @@
1
+ import { jsx as y, jsxs as R, Fragment as q } from "react/jsx-runtime";
2
+ import { createContext as Q, useState as A, useRef as E, useEffect as L, useCallback as S, useContext as D, useLayoutEffect as tt, useMemo as H, useReducer as et } from "react";
3
+ import { createPortal as rt } from "react-dom";
4
+ const B = Q(null);
5
+ function U(t) {
6
+ return t instanceof HTMLElement ? t : document.querySelector(t);
7
+ }
8
+ function M(t) {
9
+ return t.getBoundingClientRect();
10
+ }
11
+ function X(...t) {
12
+ return t.filter(Boolean).join(" ");
13
+ }
14
+ const nt = ({
15
+ targetElement: t,
16
+ highlightPadding: e = 4,
17
+ allowInteraction: n = !1,
18
+ onMaskClick: r,
19
+ placement: s
20
+ }) => {
21
+ if (s === "center")
22
+ return /* @__PURE__ */ y(
23
+ "div",
24
+ {
25
+ className: "rgs-spotlight",
26
+ style: { top: 0, left: 0, width: 0, height: 0 },
27
+ onClick: r
28
+ }
29
+ );
30
+ const l = t ? (() => {
31
+ const c = M(t);
32
+ return {
33
+ top: c.top - e,
34
+ left: c.left - e,
35
+ width: c.width + e * 2,
36
+ height: c.height + e * 2
37
+ };
38
+ })() : { top: 0, left: 0, width: 0, height: 0 };
39
+ return /* @__PURE__ */ R(q, { children: [
40
+ /* @__PURE__ */ y("div", { className: "rgs-overlay", onClick: r }),
41
+ /* @__PURE__ */ y(
42
+ "div",
43
+ {
44
+ className: X("rgs-spotlight", n && "rgs-spotlight--interactive"),
45
+ style: l
46
+ }
47
+ )
48
+ ] });
49
+ }, Y = 10, ot = 8, st = {
50
+ top: "bottom",
51
+ bottom: "top",
52
+ left: "right",
53
+ right: "left"
54
+ };
55
+ function it(t) {
56
+ const e = t.split("-")[0];
57
+ return {
58
+ top: "bottom",
59
+ bottom: "top",
60
+ left: "right",
61
+ right: "left",
62
+ center: "top"
63
+ }[e] || "top";
64
+ }
65
+ function ct(t, e) {
66
+ const n = it(e), r = ot, s = {
67
+ position: "absolute",
68
+ width: 0,
69
+ height: 0,
70
+ borderStyle: "solid",
71
+ borderTopWidth: r,
72
+ borderBottomWidth: r,
73
+ borderLeftWidth: r,
74
+ borderRightWidth: r,
75
+ borderTopColor: "transparent",
76
+ borderBottomColor: "transparent",
77
+ borderLeftColor: "transparent",
78
+ borderRightColor: "transparent"
79
+ };
80
+ switch (n) {
81
+ case "bottom":
82
+ return {
83
+ ...s,
84
+ left: t.x - r,
85
+ bottom: -r,
86
+ borderBottomWidth: 0,
87
+ borderTopColor: "var(--rgs-bg)"
88
+ };
89
+ case "top":
90
+ return {
91
+ ...s,
92
+ left: t.x - r,
93
+ top: -r,
94
+ borderTopWidth: 0,
95
+ borderBottomColor: "var(--rgs-bg)"
96
+ };
97
+ case "right":
98
+ return {
99
+ ...s,
100
+ top: t.y - r,
101
+ right: -r,
102
+ borderRightWidth: 0,
103
+ borderLeftColor: "var(--rgs-bg)"
104
+ };
105
+ case "left":
106
+ return {
107
+ ...s,
108
+ top: t.y - r,
109
+ left: -r,
110
+ borderLeftWidth: 0,
111
+ borderRightColor: "var(--rgs-bg)"
112
+ };
113
+ }
114
+ }
115
+ const at = ({ arrowPos: t, placement: e }) => {
116
+ const n = ct(t, e);
117
+ return /* @__PURE__ */ y("div", { className: "rgs-arrow", style: n });
118
+ }, lt = {
119
+ next: "Next",
120
+ prev: "Previous",
121
+ skip: "Skip",
122
+ finish: "Finish",
123
+ stepOf: "{current} of {total}"
124
+ };
125
+ function ut(t) {
126
+ return { ...lt, ...t };
127
+ }
128
+ const dt = ({
129
+ step: t,
130
+ stepIndex: e,
131
+ totalSteps: n,
132
+ position: r,
133
+ tooltipRef: s,
134
+ labels: o,
135
+ showSkip: l = !0,
136
+ onNext: c,
137
+ onPrev: d,
138
+ onSkip: i
139
+ }) => {
140
+ const [a, f] = A(!1), [p, x] = A(r), [m, u] = A(t), [w, T] = A(e), P = E(e), _ = E();
141
+ L(() => {
142
+ const v = P.current !== e;
143
+ if (P.current = e, _.current && clearTimeout(_.current), !v) {
144
+ r && (x(r), u(t), T(e), a || requestAnimationFrame(() => f(!0)));
145
+ return;
146
+ }
147
+ return f(!1), _.current = setTimeout(() => {
148
+ u(t), T(e), x(r), requestAnimationFrame(() => f(!0));
149
+ }, 200), () => {
150
+ _.current && clearTimeout(_.current);
151
+ };
152
+ }, [e, r, t]);
153
+ const I = w === 0, k = w === n - 1, W = m.showArrow !== !1 && (p == null ? void 0 : p.resolvedPlacement) !== "center", F = p ? { left: p.x, top: p.y } : { left: -9999, top: -9999 }, g = o.stepOf.replace("{current}", String(w + 1)).replace("{total}", String(n)), h = W && p && /* @__PURE__ */ y(at, { arrowPos: p.arrow, placement: p.resolvedPlacement }), b = {
154
+ ref: s,
155
+ className: X("rgs-tooltip", a && "rgs-tooltip--visible"),
156
+ style: F,
157
+ role: "dialog",
158
+ "aria-modal": !0,
159
+ "aria-label": m.title || "Guide step",
160
+ tabIndex: -1
161
+ };
162
+ if (m.customRender) {
163
+ const v = {
164
+ step: m,
165
+ stepIndex: w,
166
+ totalSteps: n,
167
+ next: c,
168
+ prev: d,
169
+ skip: i,
170
+ finish: c
171
+ };
172
+ return /* @__PURE__ */ R("div", { ...b, children: [
173
+ m.customRender(v),
174
+ h
175
+ ] });
176
+ }
177
+ return /* @__PURE__ */ R("div", { ...b, children: [
178
+ m.title && /* @__PURE__ */ y("div", { className: "rgs-tooltip__title", children: m.title }),
179
+ m.content && /* @__PURE__ */ y("div", { className: "rgs-tooltip__content", children: m.content }),
180
+ /* @__PURE__ */ R("div", { className: "rgs-tooltip__footer", children: [
181
+ /* @__PURE__ */ y("span", { className: "rgs-tooltip__counter", children: g }),
182
+ /* @__PURE__ */ R("div", { className: "rgs-tooltip__actions", children: [
183
+ l && !k && /* @__PURE__ */ y("button", { className: "rgs-btn rgs-btn--text", onClick: i, type: "button", children: o.skip }),
184
+ !I && /* @__PURE__ */ y("button", { className: "rgs-btn rgs-btn--default", onClick: d, type: "button", children: o.prev }),
185
+ /* @__PURE__ */ y("button", { className: "rgs-btn rgs-btn--primary", onClick: c, type: "button", children: k ? o.finish : o.next })
186
+ ] })
187
+ ] }),
188
+ h
189
+ ] });
190
+ };
191
+ function $(t) {
192
+ return t.split("-")[0];
193
+ }
194
+ function K(t) {
195
+ return t.split("-")[1] || "center";
196
+ }
197
+ function G(t, e, n, r) {
198
+ const s = $(n), o = K(n);
199
+ let l = 0, c = 0;
200
+ switch (s) {
201
+ case "top":
202
+ c = t.y - e.height - r;
203
+ break;
204
+ case "bottom":
205
+ c = t.y + t.height + r;
206
+ break;
207
+ case "left":
208
+ l = t.x - e.width - r;
209
+ break;
210
+ case "right":
211
+ l = t.x + t.width + r;
212
+ break;
213
+ }
214
+ if (s === "top" || s === "bottom")
215
+ switch (o) {
216
+ case "start":
217
+ l = t.x;
218
+ break;
219
+ case "end":
220
+ l = t.x + t.width - e.width;
221
+ break;
222
+ default:
223
+ l = t.x + t.width / 2 - e.width / 2;
224
+ break;
225
+ }
226
+ else
227
+ switch (o) {
228
+ case "start":
229
+ c = t.y;
230
+ break;
231
+ case "end":
232
+ c = t.y + t.height - e.height;
233
+ break;
234
+ default:
235
+ c = t.y + t.height / 2 - e.height / 2;
236
+ break;
237
+ }
238
+ return { x: l, y: c };
239
+ }
240
+ function V(t, e, n) {
241
+ const r = window.innerWidth, s = window.innerHeight;
242
+ switch (n) {
243
+ case "top":
244
+ return t.y < 0;
245
+ case "bottom":
246
+ return t.y + e.height > s;
247
+ case "left":
248
+ return t.x < 0;
249
+ case "right":
250
+ return t.x + e.width > r;
251
+ default:
252
+ return !1;
253
+ }
254
+ }
255
+ function ft(t) {
256
+ const e = $(t), n = K(t), r = st[e] || e;
257
+ return n === "center" ? r : `${r}-${n}`;
258
+ }
259
+ function j(t, e, n = 8) {
260
+ const r = window.innerWidth, s = window.innerHeight;
261
+ return {
262
+ x: Math.max(n, Math.min(t.x, r - e.width - n)),
263
+ y: Math.max(n, Math.min(t.y, s - e.height - n))
264
+ };
265
+ }
266
+ function pt(t, e, n) {
267
+ const r = $(n);
268
+ if (r === "top" || r === "bottom") {
269
+ const s = t.x + t.width / 2 - e.x;
270
+ return {
271
+ x: Math.max(12, Math.min(s, e.width - 12)),
272
+ y: r === "top" ? e.height : 0
273
+ };
274
+ } else {
275
+ const s = t.y + t.height / 2 - e.y, o = Math.max(12, Math.min(s, e.height - 12));
276
+ return {
277
+ x: r === "left" ? e.width : 0,
278
+ y: o
279
+ };
280
+ }
281
+ }
282
+ function ht(t, e, n = "bottom", r = Y) {
283
+ if (n === "center") {
284
+ const i = {
285
+ x: t.x + t.width / 2 - e.width / 2,
286
+ y: t.y + t.height / 2 - e.height / 2
287
+ }, a = j(i, e);
288
+ return {
289
+ x: a.x,
290
+ y: a.y,
291
+ resolvedPlacement: "center",
292
+ arrow: { x: 0, y: 0 }
293
+ };
294
+ }
295
+ const s = $(n);
296
+ let o = G(t, e, n, r), l = n;
297
+ if (V(o, e, s)) {
298
+ const i = ft(n), a = $(i), f = G(t, e, i, r);
299
+ V(f, e, a) || (o = f, l = i);
300
+ }
301
+ const c = j(o, e), d = pt(
302
+ t,
303
+ { ...c, width: e.width, height: e.height },
304
+ l
305
+ );
306
+ return {
307
+ x: c.x,
308
+ y: c.y,
309
+ resolvedPlacement: l,
310
+ arrow: d
311
+ };
312
+ }
313
+ function gt({ targetElement: t, placement: e, enabled: n, highlightPadding: r = 0 }) {
314
+ const [s, o] = A(null), l = E(null), c = E(0), d = S(() => {
315
+ if (!t || !l.current) return;
316
+ const i = M(t), a = M(l.current), f = ht(i, a, e, Y + r);
317
+ o(f);
318
+ }, [t, e, r]);
319
+ return L(() => {
320
+ if (!n) {
321
+ o(null);
322
+ return;
323
+ }
324
+ if (!t)
325
+ return;
326
+ d(), c.current = requestAnimationFrame(d);
327
+ const i = () => {
328
+ cancelAnimationFrame(c.current), c.current = requestAnimationFrame(d);
329
+ };
330
+ window.addEventListener("scroll", i, !0), window.addEventListener("resize", i);
331
+ let a;
332
+ return a = new ResizeObserver(i), l.current && a.observe(l.current), a.observe(t), () => {
333
+ cancelAnimationFrame(c.current), window.removeEventListener("scroll", i, !0), window.removeEventListener("resize", i), a == null || a.disconnect();
334
+ };
335
+ }, [n, t, d]), { position: s, tooltipRef: l, updatePosition: d };
336
+ }
337
+ function mt({ enabled: t, onNext: e, onPrev: n, onSkip: r }) {
338
+ L(() => {
339
+ if (!t) return;
340
+ const s = (o) => {
341
+ switch (o.key) {
342
+ case "ArrowRight":
343
+ case "Enter":
344
+ o.preventDefault(), e();
345
+ break;
346
+ case "ArrowLeft":
347
+ o.preventDefault(), n();
348
+ break;
349
+ case "Escape":
350
+ o.preventDefault(), r();
351
+ break;
352
+ }
353
+ };
354
+ return document.addEventListener("keydown", s), () => document.removeEventListener("keydown", s);
355
+ }, [t, e, n, r]);
356
+ }
357
+ function bt(t, e) {
358
+ const [n, r] = A(null), [s, o] = A(!1);
359
+ return L(() => {
360
+ if (!e || !t) {
361
+ r(null), o(!1);
362
+ return;
363
+ }
364
+ const l = U(t);
365
+ if (l) {
366
+ r(l), o(!1);
367
+ return;
368
+ }
369
+ if (o(!0), typeof t != "string") {
370
+ o(!1);
371
+ return;
372
+ }
373
+ const c = new MutationObserver(() => {
374
+ const d = document.querySelector(t);
375
+ d && (r(d), o(!1), c.disconnect());
376
+ });
377
+ return c.observe(document.body, {
378
+ childList: !0,
379
+ subtree: !0
380
+ }), () => c.disconnect();
381
+ }, [t, e]), { element: n, isWaiting: s };
382
+ }
383
+ function vt(t = "smooth") {
384
+ return S(
385
+ (n) => {
386
+ if (!n) return;
387
+ const r = n.getBoundingClientRect();
388
+ r.top >= 0 && r.left >= 0 && r.bottom <= window.innerHeight && r.right <= window.innerWidth || n.scrollIntoView({ behavior: t, block: "center", inline: "center" });
389
+ },
390
+ [t]
391
+ );
392
+ }
393
+ function yt(t, e, n) {
394
+ const r = E(/* @__PURE__ */ new Map()), [s, o] = A(!0), l = E(e), c = E(t);
395
+ l.current = e, c.current = t;
396
+ const d = S(() => {
397
+ var f;
398
+ const i = (f = c.current[l.current]) == null ? void 0 : f.preloadImages;
399
+ if (!i || i.length === 0) {
400
+ o(!0);
401
+ return;
402
+ }
403
+ const a = i.every((p) => r.current.get(p) === !0);
404
+ o(a);
405
+ }, []);
406
+ return L(() => {
407
+ var a;
408
+ if (!n) {
409
+ r.current.clear();
410
+ return;
411
+ }
412
+ const i = /* @__PURE__ */ new Set();
413
+ for (const f of t)
414
+ (a = f.preloadImages) == null || a.forEach((p) => i.add(p));
415
+ for (const f of i) {
416
+ if (r.current.has(f)) continue;
417
+ r.current.set(f, !1);
418
+ const p = new Image();
419
+ p.src = f;
420
+ const x = () => {
421
+ r.current.set(f, !0), d();
422
+ };
423
+ p.onload = x, p.onerror = x;
424
+ }
425
+ d();
426
+ }, [n, t, d]), L(() => {
427
+ d();
428
+ }, [e, d]), s;
429
+ }
430
+ const xt = {
431
+ primaryColor: "#1677ff",
432
+ textColor: "#333333",
433
+ bgColor: "#ffffff",
434
+ overlayColor: "rgba(0, 0, 0, 0.5)",
435
+ borderRadius: 8,
436
+ zIndex: 99999,
437
+ animationDuration: 150
438
+ };
439
+ function Z(t) {
440
+ return { ...xt, ...t };
441
+ }
442
+ function wt(t) {
443
+ return `
444
+ --rgs-primary: ${t.primaryColor};
445
+ --rgs-text: ${t.textColor};
446
+ --rgs-bg: ${t.bgColor};
447
+ --rgs-overlay: ${t.overlayColor};
448
+ --rgs-radius: ${t.borderRadius}px;
449
+ --rgs-z: ${t.zIndex};
450
+ --rgs-duration: ${t.animationDuration}ms;
451
+ `;
452
+ }
453
+ const St = () => {
454
+ const t = D(B), { controller: e, options: n } = t, {
455
+ steps: r,
456
+ maskClosable: s = !1,
457
+ showSkip: o = !0,
458
+ keyboardNavigation: l = !0,
459
+ scrollBehavior: c = "smooth",
460
+ labels: d
461
+ } = n, { isActive: i, currentStep: a, next: f, prev: p, stop: x } = e, m = ut(d), u = r[a], w = !!(u != null && u.waitForElement), { element: T, isWaiting: P } = bt(
462
+ u == null ? void 0 : u.target,
463
+ i && w
464
+ ), [_, I] = A(null);
465
+ L(() => {
466
+ if (!i || !u || w) {
467
+ I(null);
468
+ return;
469
+ }
470
+ const C = U(u.target);
471
+ I(C || null);
472
+ }, [i, a, u, w]);
473
+ const k = w ? T : _, W = yt(r, a, i), F = vt(c);
474
+ L(() => {
475
+ k && F(k);
476
+ }, [k, F]);
477
+ const { position: g, tooltipRef: h } = gt({
478
+ targetElement: k,
479
+ placement: (u == null ? void 0 : u.placement) || "bottom",
480
+ enabled: i && !!k,
481
+ highlightPadding: u == null ? void 0 : u.highlightPadding
482
+ });
483
+ L(() => {
484
+ i && g && h.current && h.current.focus();
485
+ }, [i, a, g, h]);
486
+ const b = S(() => {
487
+ var C;
488
+ (C = n.onSkip) == null || C.call(n, a), x();
489
+ }, [n, a, x]);
490
+ mt({
491
+ enabled: i && l,
492
+ onNext: f,
493
+ onPrev: p,
494
+ onSkip: b
495
+ });
496
+ const v = S(() => {
497
+ s && b();
498
+ }, [s, b]), z = E(null), [N, O] = A(!1);
499
+ return tt(() => {
500
+ if (i) {
501
+ const C = document.createElement("div");
502
+ return C.className = "rgs-portal", C.setAttribute("aria-live", "polite"), C.style.zIndex = String(Z(n.theme).zIndex), document.body.appendChild(C), z.current = C, O(!0), () => {
503
+ C.remove(), z.current = null, O(!1);
504
+ };
505
+ } else
506
+ O(!1);
507
+ }, [i, n.theme]), !i || !u || !N || !z.current ? null : rt(
508
+ /* @__PURE__ */ R(q, { children: [
509
+ /* @__PURE__ */ y(
510
+ nt,
511
+ {
512
+ targetElement: k,
513
+ highlightPadding: u.highlightPadding,
514
+ allowInteraction: u.allowInteraction,
515
+ onMaskClick: v,
516
+ placement: u.placement
517
+ }
518
+ ),
519
+ P || !W ? /* @__PURE__ */ y("div", { className: "rgs-waiting", children: "Loading..." }) : /* @__PURE__ */ y(
520
+ dt,
521
+ {
522
+ step: u,
523
+ stepIndex: a,
524
+ totalSteps: r.length,
525
+ position: g,
526
+ tooltipRef: h,
527
+ labels: m,
528
+ showSkip: o,
529
+ onNext: f,
530
+ onPrev: p,
531
+ onSkip: b
532
+ }
533
+ )
534
+ ] }),
535
+ z.current
536
+ );
537
+ }, Et = () => D(B) ? /* @__PURE__ */ y(St, {}) : null, J = "rgs";
538
+ function kt(t, e) {
539
+ const n = `${J}-${t}`;
540
+ let r = document.getElementById(n);
541
+ r || (r = document.createElement("style"), r.id = n, r.setAttribute("data-rgs", ""), document.head.appendChild(r)), r.textContent = e;
542
+ }
543
+ function Ct(t) {
544
+ const e = `${J}-${t}`, n = document.getElementById(e);
545
+ n && n.remove();
546
+ }
547
+ const Tt = `
548
+ .rgs-portal {
549
+ position: fixed;
550
+ inset: 0;
551
+ z-index: var(--rgs-z);
552
+ pointer-events: none;
553
+ }
554
+
555
+ .rgs-portal > * {
556
+ pointer-events: auto;
557
+ }
558
+
559
+ /* Spotlight overlay — uses box-shadow for the mask */
560
+ .rgs-spotlight {
561
+ position: fixed;
562
+ box-shadow: 0 0 0 9999px var(--rgs-overlay);
563
+ border-radius: 4px;
564
+ z-index: var(--rgs-z);
565
+ pointer-events: none;
566
+ }
567
+
568
+ .rgs-spotlight--interactive {
569
+ pointer-events: auto;
570
+ }
571
+
572
+ /* Clickable overlay behind everything to detect mask clicks */
573
+ .rgs-overlay {
574
+ position: fixed;
575
+ inset: 0;
576
+ z-index: calc(var(--rgs-z) - 1);
577
+ cursor: default;
578
+ }
579
+
580
+ /* Tooltip container */
581
+ .rgs-tooltip {
582
+ position: fixed;
583
+ z-index: calc(var(--rgs-z) + 1);
584
+ background: var(--rgs-bg);
585
+ color: var(--rgs-text);
586
+ border-radius: var(--rgs-radius);
587
+ box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08),
588
+ 0 3px 6px -4px rgba(0, 0, 0, 0.12),
589
+ 0 9px 28px 8px rgba(0, 0, 0, 0.05);
590
+ padding: 16px;
591
+ min-width: 280px;
592
+ max-width: 420px;
593
+ opacity: 0;
594
+ transition: opacity var(--rgs-duration) ease;
595
+ outline: none;
596
+ }
597
+
598
+ .rgs-tooltip--visible {
599
+ opacity: 1;
600
+ }
601
+
602
+ .rgs-tooltip__title {
603
+ font-size: 16px;
604
+ font-weight: 600;
605
+ margin: 0 0 8px 0;
606
+ line-height: 1.4;
607
+ }
608
+
609
+ .rgs-tooltip__content {
610
+ font-size: 14px;
611
+ line-height: 1.6;
612
+ margin: 0 0 16px 0;
613
+ color: var(--rgs-text);
614
+ opacity: 0.85;
615
+ }
616
+
617
+ .rgs-tooltip__footer {
618
+ display: flex;
619
+ align-items: center;
620
+ justify-content: space-between;
621
+ gap: 8px;
622
+ }
623
+
624
+ .rgs-tooltip__counter {
625
+ font-size: 12px;
626
+ color: var(--rgs-text);
627
+ opacity: 0.45;
628
+ flex-shrink: 0;
629
+ }
630
+
631
+ .rgs-tooltip__actions {
632
+ display: flex;
633
+ align-items: center;
634
+ gap: 8px;
635
+ margin-left: auto;
636
+ }
637
+
638
+ /* Buttons */
639
+ .rgs-btn {
640
+ display: inline-flex;
641
+ align-items: center;
642
+ justify-content: center;
643
+ padding: 4px 16px;
644
+ font-size: 14px;
645
+ line-height: 1.5;
646
+ border-radius: calc(var(--rgs-radius) - 2px);
647
+ cursor: pointer;
648
+ border: 1px solid transparent;
649
+ transition: all 0.2s ease;
650
+ white-space: nowrap;
651
+ font-family: inherit;
652
+ }
653
+
654
+ .rgs-btn:focus-visible {
655
+ outline: 2px solid var(--rgs-primary);
656
+ outline-offset: 2px;
657
+ }
658
+
659
+ .rgs-btn--primary {
660
+ background: var(--rgs-primary);
661
+ color: #fff;
662
+ border-color: var(--rgs-primary);
663
+ }
664
+
665
+ .rgs-btn--primary:hover {
666
+ opacity: 0.85;
667
+ }
668
+
669
+ .rgs-btn--default {
670
+ background: transparent;
671
+ color: var(--rgs-text);
672
+ border-color: #d9d9d9;
673
+ }
674
+
675
+ .rgs-btn--default:hover {
676
+ color: var(--rgs-primary);
677
+ border-color: var(--rgs-primary);
678
+ }
679
+
680
+ .rgs-btn--text {
681
+ background: transparent;
682
+ color: var(--rgs-text);
683
+ opacity: 0.65;
684
+ padding: 4px 8px;
685
+ }
686
+
687
+ .rgs-btn--text:hover {
688
+ opacity: 1;
689
+ }
690
+
691
+ /* Arrow (styles applied inline, this is a fallback) */
692
+ .rgs-arrow {
693
+ position: absolute;
694
+ }
695
+
696
+ /* Waiting state */
697
+ .rgs-waiting {
698
+ position: fixed;
699
+ top: 50%;
700
+ left: 50%;
701
+ transform: translate(-50%, -50%);
702
+ z-index: calc(var(--rgs-z) + 1);
703
+ color: var(--rgs-bg);
704
+ font-size: 14px;
705
+ }
706
+ `, Ft = ({ guide: t, options: e, children: n }) => {
707
+ L(() => {
708
+ const s = Z(e.theme), l = `
709
+ .rgs-portal { ${wt(s)} }
710
+ ${Tt}
711
+ `;
712
+ return kt("base", l), () => Ct("base");
713
+ }, [e.theme]);
714
+ const r = H(
715
+ () => ({ controller: t, options: e }),
716
+ [t, e]
717
+ );
718
+ return /* @__PURE__ */ R(B.Provider, { value: r, children: [
719
+ n,
720
+ /* @__PURE__ */ y(Et, {})
721
+ ] });
722
+ }, At = "rgs:";
723
+ function Lt(t) {
724
+ if (!t) return !1;
725
+ try {
726
+ return localStorage.getItem(t) === "done";
727
+ } catch {
728
+ return !1;
729
+ }
730
+ }
731
+ function _t(t) {
732
+ const e = t ? `${At}${t}` : null, [n, r] = A(() => Lt(e)), s = S(() => {
733
+ if (e) {
734
+ try {
735
+ localStorage.setItem(e, "done");
736
+ } catch {
737
+ }
738
+ r(!0);
739
+ }
740
+ }, [e]), o = S(() => {
741
+ if (e) {
742
+ try {
743
+ localStorage.removeItem(e);
744
+ } catch {
745
+ }
746
+ r(!1);
747
+ }
748
+ }, [e]);
749
+ return { isCompleted: n, markCompleted: s, reset: o };
750
+ }
751
+ function It(t, e) {
752
+ switch (e.type) {
753
+ case "START":
754
+ return { ...t, isActive: !0, currentStep: e.step, targetElement: null, isWaiting: !1 };
755
+ case "STOP":
756
+ return { isActive: !1, currentStep: 0, targetElement: null, isWaiting: !1 };
757
+ case "GO_TO":
758
+ return { ...t, currentStep: e.step, targetElement: null, isWaiting: !1 };
759
+ default:
760
+ return t;
761
+ }
762
+ }
763
+ const Pt = {
764
+ isActive: !1,
765
+ currentStep: 0,
766
+ targetElement: null,
767
+ isWaiting: !1
768
+ };
769
+ function Ot(t) {
770
+ const {
771
+ steps: e,
772
+ onComplete: n,
773
+ onSkip: r,
774
+ onStepChange: s,
775
+ initialStep: o = 0,
776
+ persistKey: l,
777
+ autoStart: c = !1
778
+ } = t, [d, i] = et(It, Pt), { isCompleted: a, markCompleted: f } = _t(l), p = E(!1), x = E(d);
779
+ x.current = d;
780
+ const m = E(e);
781
+ m.current = e;
782
+ const u = E(s);
783
+ u.current = s;
784
+ const w = E(n);
785
+ w.current = n, L(() => {
786
+ c && !a && e.length > 0 && i({ type: "START", step: o });
787
+ }, [c, a, e.length, o]);
788
+ const T = S(
789
+ async (g) => {
790
+ var h;
791
+ if (!p.current) {
792
+ p.current = !0;
793
+ try {
794
+ const b = m.current[x.current.currentStep], v = m.current[g];
795
+ b != null && b.afterLeave && await b.afterLeave(), v != null && v.beforeEnter && await v.beforeEnter(), i({ type: "GO_TO", step: g }), (h = u.current) == null || h.call(u, g);
796
+ } catch (b) {
797
+ console.error("[react-guide-step] Error during step transition:", b);
798
+ } finally {
799
+ p.current = !1;
800
+ }
801
+ }
802
+ },
803
+ []
804
+ // stable — reads from refs
805
+ ), P = S(() => {
806
+ if (a) return;
807
+ const g = o, h = m.current[g];
808
+ (async () => {
809
+ var v;
810
+ try {
811
+ h != null && h.beforeEnter && await h.beforeEnter(), i({ type: "START", step: g }), (v = u.current) == null || v.call(u, g);
812
+ } catch (z) {
813
+ console.error("[react-guide-step] Error in beforeEnter:", z);
814
+ }
815
+ })();
816
+ }, [a, o]), _ = S(() => {
817
+ i({ type: "STOP" });
818
+ }, []), I = S(() => {
819
+ const { isActive: g, currentStep: h } = x.current;
820
+ if (!g) return;
821
+ const b = h + 1;
822
+ if (b >= m.current.length) {
823
+ const v = m.current[h];
824
+ (async () => {
825
+ var N;
826
+ try {
827
+ v != null && v.afterLeave && await v.afterLeave(), i({ type: "STOP" }), f(), (N = w.current) == null || N.call(w);
828
+ } catch (O) {
829
+ console.error("[react-guide-step] Error in afterLeave:", O), i({ type: "STOP" });
830
+ }
831
+ })();
832
+ } else
833
+ T(b);
834
+ }, [T, f]), k = S(() => {
835
+ const { isActive: g, currentStep: h } = x.current;
836
+ !g || h <= 0 || T(h - 1);
837
+ }, [T]), W = S(
838
+ (g) => {
839
+ const { isActive: h } = x.current;
840
+ !h || g < 0 || g >= m.current.length || T(g);
841
+ },
842
+ [T]
843
+ );
844
+ return H(
845
+ () => ({
846
+ start: P,
847
+ stop: _,
848
+ next: I,
849
+ prev: k,
850
+ goTo: W,
851
+ isActive: d.isActive,
852
+ currentStep: d.currentStep,
853
+ totalSteps: e.length,
854
+ isCompleted: a
855
+ }),
856
+ [P, _, I, k, W, d.isActive, d.currentStep, e.length, a]
857
+ );
858
+ }
859
+ export {
860
+ xt as DEFAULT_THEME,
861
+ Ft as GuideProvider,
862
+ Ot as useGuide
863
+ };