@trailguide/core 0.0.1 → 0.0.2

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.
package/dist/index.d.ts CHANGED
@@ -2,4 +2,6 @@
2
2
  export { Trailguide, start, stop, next, prev, skip } from './trailguide';
3
3
  export type { Trail, Step, Placement, StepAction, NextTrigger, TrailguideOptions, TrailguideState, } from './types';
4
4
  export { findElement, isElementVisible, scrollToElement, } from './dom';
5
+ export { validateTrail, logValidationResults, } from './validate';
6
+ export type { ValidationResult, ValidationError, ValidationWarning, } from './validate';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzE,YAAY,EACV,KAAK,EACL,IAAI,EACJ,SAAS,EACT,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzE,YAAY,EACV,KAAK,EACL,IAAI,EACJ,SAAS,EACT,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,aAAa,EACb,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
@@ -1,25 +1,25 @@
1
- var Vt = Object.defineProperty;
2
- var Mt = (t, e, n) => e in t ? Vt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var F = (t, e, n) => Mt(t, typeof e != "symbol" ? e + "" : e, n);
4
- const Q = Math.min, _ = Math.max, it = Math.round, k = (t) => ({
1
+ var Wt = Object.defineProperty;
2
+ var Mt = (t, e, n) => e in t ? Wt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var I = (t, e, n) => Mt(t, typeof e != "symbol" ? e + "" : e, n);
4
+ const J = Math.min, X = Math.max, nt = Math.round, k = (t) => ({
5
5
  x: t,
6
6
  y: t
7
- }), Wt = {
7
+ }), qt = {
8
8
  left: "right",
9
9
  right: "left",
10
10
  bottom: "top",
11
11
  top: "bottom"
12
- }, Ht = {
12
+ }, _t = {
13
13
  start: "end",
14
14
  end: "start"
15
15
  };
16
16
  function ut(t, e, n) {
17
- return _(t, Q(e, n));
17
+ return X(t, J(e, n));
18
18
  }
19
19
  function Z(t, e) {
20
20
  return typeof t == "function" ? t(e) : t;
21
21
  }
22
- function X(t) {
22
+ function H(t) {
23
23
  return t.split("-")[0];
24
24
  }
25
25
  function tt(t) {
@@ -31,48 +31,48 @@ function Et(t) {
31
31
  function pt(t) {
32
32
  return t === "y" ? "height" : "width";
33
33
  }
34
- const It = /* @__PURE__ */ new Set(["top", "bottom"]);
34
+ const Ht = /* @__PURE__ */ new Set(["top", "bottom"]);
35
35
  function V(t) {
36
- return It.has(X(t)) ? "y" : "x";
36
+ return Ht.has(H(t)) ? "y" : "x";
37
37
  }
38
38
  function gt(t) {
39
39
  return Et(V(t));
40
40
  }
41
- function qt(t, e, n) {
41
+ function Xt(t, e, n) {
42
42
  n === void 0 && (n = !1);
43
43
  const i = tt(t), o = gt(t), s = pt(o);
44
44
  let r = o === "x" ? i === (n ? "end" : "start") ? "right" : "left" : i === "start" ? "bottom" : "top";
45
45
  return e.reference[s] > e.floating[s] && (r = ot(r)), [r, ot(r)];
46
46
  }
47
- function Xt(t) {
47
+ function jt(t) {
48
48
  const e = ot(t);
49
49
  return [dt(t), e, dt(e)];
50
50
  }
51
51
  function dt(t) {
52
- return t.replace(/start|end/g, (e) => Ht[e]);
52
+ return t.replace(/start|end/g, (e) => _t[e]);
53
53
  }
54
- const yt = ["left", "right"], xt = ["right", "left"], _t = ["top", "bottom"], jt = ["bottom", "top"];
55
- function Yt(t, e, n) {
54
+ const yt = ["left", "right"], xt = ["right", "left"], Yt = ["top", "bottom"], zt = ["bottom", "top"];
55
+ function Kt(t, e, n) {
56
56
  switch (t) {
57
57
  case "top":
58
58
  case "bottom":
59
59
  return n ? e ? xt : yt : e ? yt : xt;
60
60
  case "left":
61
61
  case "right":
62
- return e ? _t : jt;
62
+ return e ? Yt : zt;
63
63
  default:
64
64
  return [];
65
65
  }
66
66
  }
67
- function zt(t, e, n, i) {
67
+ function Ut(t, e, n, i) {
68
68
  const o = tt(t);
69
- let s = Yt(X(t), n === "start", i);
69
+ let s = Kt(H(t), n === "start", i);
70
70
  return o && (s = s.map((r) => r + "-" + o), e && (s = s.concat(s.map(dt)))), s;
71
71
  }
72
72
  function ot(t) {
73
- return t.replace(/left|right|bottom|top/g, (e) => Wt[e]);
73
+ return t.replace(/left|right|bottom|top/g, (e) => qt[e]);
74
74
  }
75
- function Kt(t) {
75
+ function Gt(t) {
76
76
  return {
77
77
  top: 0,
78
78
  right: 0,
@@ -81,8 +81,8 @@ function Kt(t) {
81
81
  ...t
82
82
  };
83
83
  }
84
- function Ot(t) {
85
- return typeof t != "number" ? Kt(t) : {
84
+ function Tt(t) {
85
+ return typeof t != "number" ? Gt(t) : {
86
86
  top: t,
87
87
  right: t,
88
88
  bottom: t,
@@ -112,7 +112,7 @@ function vt(t, e, n) {
112
112
  reference: i,
113
113
  floating: o
114
114
  } = t;
115
- const s = V(e), r = gt(e), l = pt(r), c = X(e), a = s === "y", d = i.x + i.width / 2 - o.width / 2, u = i.y + i.height / 2 - o.height / 2, p = i[l] / 2 - o[l] / 2;
115
+ const s = V(e), r = gt(e), l = pt(r), c = H(e), a = s === "y", d = i.x + i.width / 2 - o.width / 2, u = i.y + i.height / 2 - o.height / 2, p = i[l] / 2 - o[l] / 2;
116
116
  let f;
117
117
  switch (c) {
118
118
  case "top":
@@ -155,7 +155,7 @@ function vt(t, e, n) {
155
155
  }
156
156
  return f;
157
157
  }
158
- async function Gt(t, e) {
158
+ async function Jt(t, e) {
159
159
  var n;
160
160
  e === void 0 && (e = {});
161
161
  const {
@@ -171,7 +171,7 @@ async function Gt(t, e) {
171
171
  elementContext: u = "floating",
172
172
  altBoundary: p = !1,
173
173
  padding: f = 0
174
- } = Z(e, t), h = Ot(f), m = l[p ? u === "floating" ? "reference" : "floating" : u], w = st(await s.getClippingRect({
174
+ } = Z(e, t), h = Tt(f), m = l[p ? u === "floating" ? "reference" : "floating" : u], w = st(await s.getClippingRect({
175
175
  element: (n = await (s.isElement == null ? void 0 : s.isElement(m))) == null || n ? m : m.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(l.floating)),
176
176
  boundary: a,
177
177
  rootBoundary: d,
@@ -200,7 +200,7 @@ async function Gt(t, e) {
200
200
  right: (E.right - w.right + h.right) / v.x
201
201
  };
202
202
  }
203
- const Jt = async (t, e, n) => {
203
+ const Qt = async (t, e, n) => {
204
204
  const {
205
205
  placement: i = "bottom",
206
206
  strategy: o = "absolute",
@@ -235,7 +235,7 @@ const Jt = async (t, e, n) => {
235
235
  rects: a,
236
236
  platform: {
237
237
  ...r,
238
- detectOverflow: (g = r.detectOverflow) != null ? g : Gt
238
+ detectOverflow: (g = r.detectOverflow) != null ? g : Jt
239
239
  },
240
240
  elements: {
241
241
  reference: t,
@@ -264,7 +264,7 @@ const Jt = async (t, e, n) => {
264
264
  strategy: o,
265
265
  middlewareData: f
266
266
  };
267
- }, Qt = (t) => ({
267
+ }, Zt = (t) => ({
268
268
  name: "arrow",
269
269
  options: t,
270
270
  async fn(e) {
@@ -282,26 +282,26 @@ const Jt = async (t, e, n) => {
282
282
  } = Z(t, e) || {};
283
283
  if (a == null)
284
284
  return {};
285
- const u = Ot(d), p = {
285
+ const u = Tt(d), p = {
286
286
  x: n,
287
287
  y: i
288
288
  }, f = gt(o), h = pt(f), g = await r.getDimensions(a), m = f === "y", w = m ? "top" : "left", y = m ? "bottom" : "right", x = m ? "clientHeight" : "clientWidth", v = s.reference[h] + s.reference[f] - p[f] - s.floating[h], E = p[f] - s.reference[f], A = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(a));
289
289
  let W = A ? A[x] : 0;
290
290
  (!W || !await (r.isElement == null ? void 0 : r.isElement(A))) && (W = l.floating[x] || s.floating[h]);
291
- const K = v / 2 - E / 2, H = W / 2 - g[h] / 2 - 1, D = Q(u[w], H), G = Q(u[y], H), I = D, J = W - g[h] - G, S = W / 2 - g[h] / 2 + K, q = ut(I, S, J), $ = !c.arrow && tt(o) != null && S !== q && s.reference[h] / 2 - (S < I ? D : G) - g[h] / 2 < 0, O = $ ? S < I ? S - I : S - J : 0;
291
+ const K = v / 2 - E / 2, M = W / 2 - g[h] / 2 - 1, P = J(u[w], M), U = J(u[y], M), q = P, G = W - g[h] - U, S = W / 2 - g[h] / 2 + K, _ = ut(q, S, G), D = !c.arrow && tt(o) != null && S !== _ && s.reference[h] / 2 - (S < q ? P : U) - g[h] / 2 < 0, T = D ? S < q ? S - q : S - G : 0;
292
292
  return {
293
- [f]: p[f] + O,
293
+ [f]: p[f] + T,
294
294
  data: {
295
- [f]: q,
296
- centerOffset: S - q - O,
297
- ...$ && {
298
- alignmentOffset: O
295
+ [f]: _,
296
+ centerOffset: S - _ - T,
297
+ ...D && {
298
+ alignmentOffset: T
299
299
  }
300
300
  },
301
- reset: $
301
+ reset: D
302
302
  };
303
303
  }
304
- }), Ut = function(t) {
304
+ }), te = function(t) {
305
305
  return t === void 0 && (t = {}), {
306
306
  name: "flip",
307
307
  options: t,
@@ -325,70 +325,70 @@ const Jt = async (t, e, n) => {
325
325
  } = Z(t, e);
326
326
  if ((n = s.arrow) != null && n.alignmentOffset)
327
327
  return {};
328
- const w = X(o), y = V(l), x = X(l) === l, v = await (c.isRTL == null ? void 0 : c.isRTL(a.floating)), E = p || (x || !g ? [ot(l)] : Xt(l)), A = h !== "none";
329
- !p && A && E.push(...zt(l, g, h, v));
330
- const W = [l, ...E], K = await c.detectOverflow(e, m), H = [];
331
- let D = ((i = s.flip) == null ? void 0 : i.overflows) || [];
332
- if (d && H.push(K[w]), u) {
333
- const S = qt(o, r, v);
334
- H.push(K[S[0]], K[S[1]]);
328
+ const w = H(o), y = V(l), x = H(l) === l, v = await (c.isRTL == null ? void 0 : c.isRTL(a.floating)), E = p || (x || !g ? [ot(l)] : jt(l)), A = h !== "none";
329
+ !p && A && E.push(...Ut(l, g, h, v));
330
+ const W = [l, ...E], K = await c.detectOverflow(e, m), M = [];
331
+ let P = ((i = s.flip) == null ? void 0 : i.overflows) || [];
332
+ if (d && M.push(K[w]), u) {
333
+ const S = Xt(o, r, v);
334
+ M.push(K[S[0]], K[S[1]]);
335
335
  }
336
- if (D = [...D, {
336
+ if (P = [...P, {
337
337
  placement: o,
338
- overflows: H
339
- }], !H.every((S) => S <= 0)) {
340
- var G, I;
341
- const S = (((G = s.flip) == null ? void 0 : G.index) || 0) + 1, q = W[S];
342
- if (q && (!(u === "alignment" ? y !== V(q) : !1) || // We leave the current main axis only if every placement on that axis
338
+ overflows: M
339
+ }], !M.every((S) => S <= 0)) {
340
+ var U, q;
341
+ const S = (((U = s.flip) == null ? void 0 : U.index) || 0) + 1, _ = W[S];
342
+ if (_ && (!(u === "alignment" ? y !== V(_) : !1) || // We leave the current main axis only if every placement on that axis
343
343
  // overflows the main axis.
344
- D.every((L) => V(L.placement) === y ? L.overflows[0] > 0 : !0)))
344
+ P.every((O) => V(O.placement) === y ? O.overflows[0] > 0 : !0)))
345
345
  return {
346
346
  data: {
347
347
  index: S,
348
- overflows: D
348
+ overflows: P
349
349
  },
350
350
  reset: {
351
- placement: q
351
+ placement: _
352
352
  }
353
353
  };
354
- let $ = (I = D.filter((O) => O.overflows[0] <= 0).sort((O, L) => O.overflows[1] - L.overflows[1])[0]) == null ? void 0 : I.placement;
355
- if (!$)
354
+ let D = (q = P.filter((T) => T.overflows[0] <= 0).sort((T, O) => T.overflows[1] - O.overflows[1])[0]) == null ? void 0 : q.placement;
355
+ if (!D)
356
356
  switch (f) {
357
357
  case "bestFit": {
358
- var J;
359
- const O = (J = D.filter((L) => {
358
+ var G;
359
+ const T = (G = P.filter((O) => {
360
360
  if (A) {
361
- const N = V(L.placement);
362
- return N === y || // Create a bias to the `y` side axis due to horizontal
361
+ const B = V(O.placement);
362
+ return B === y || // Create a bias to the `y` side axis due to horizontal
363
363
  // reading directions favoring greater width.
364
- N === "y";
364
+ B === "y";
365
365
  }
366
366
  return !0;
367
- }).map((L) => [L.placement, L.overflows.filter((N) => N > 0).reduce((N, Nt) => N + Nt, 0)]).sort((L, N) => L[1] - N[1])[0]) == null ? void 0 : J[0];
368
- O && ($ = O);
367
+ }).map((O) => [O.placement, O.overflows.filter((B) => B > 0).reduce((B, Nt) => B + Nt, 0)]).sort((O, B) => O[1] - B[1])[0]) == null ? void 0 : G[0];
368
+ T && (D = T);
369
369
  break;
370
370
  }
371
371
  case "initialPlacement":
372
- $ = l;
372
+ D = l;
373
373
  break;
374
374
  }
375
- if (o !== $)
375
+ if (o !== D)
376
376
  return {
377
377
  reset: {
378
- placement: $
378
+ placement: D
379
379
  }
380
380
  };
381
381
  }
382
382
  return {};
383
383
  }
384
384
  };
385
- }, Zt = /* @__PURE__ */ new Set(["left", "top"]);
386
- async function te(t, e) {
385
+ }, ee = /* @__PURE__ */ new Set(["left", "top"]);
386
+ async function ie(t, e) {
387
387
  const {
388
388
  placement: n,
389
389
  platform: i,
390
390
  elements: o
391
- } = t, s = await (i.isRTL == null ? void 0 : i.isRTL(o.floating)), r = X(n), l = tt(n), c = V(n) === "y", a = Zt.has(r) ? -1 : 1, d = s && c ? -1 : 1, u = Z(e, t);
391
+ } = t, s = await (i.isRTL == null ? void 0 : i.isRTL(o.floating)), r = H(n), l = tt(n), c = V(n) === "y", a = ee.has(r) ? -1 : 1, d = s && c ? -1 : 1, u = Z(e, t);
392
392
  let {
393
393
  mainAxis: p,
394
394
  crossAxis: f,
@@ -410,7 +410,7 @@ async function te(t, e) {
410
410
  y: f * d
411
411
  };
412
412
  }
413
- const ee = function(t) {
413
+ const ne = function(t) {
414
414
  return t === void 0 && (t = 0), {
415
415
  name: "offset",
416
416
  options: t,
@@ -421,7 +421,7 @@ const ee = function(t) {
421
421
  y: s,
422
422
  placement: r,
423
423
  middlewareData: l
424
- } = e, c = await te(e, t);
424
+ } = e, c = await ie(e, t);
425
425
  return r === ((n = l.offset) == null ? void 0 : n.placement) && (i = l.arrow) != null && i.alignmentOffset ? {} : {
426
426
  x: o + c.x,
427
427
  y: s + c.y,
@@ -432,7 +432,7 @@ const ee = function(t) {
432
432
  };
433
433
  }
434
434
  };
435
- }, ne = function(t) {
435
+ }, oe = function(t) {
436
436
  return t === void 0 && (t = {}), {
437
437
  name: "shift",
438
438
  options: t,
@@ -461,7 +461,7 @@ const ee = function(t) {
461
461
  } = Z(t, e), d = {
462
462
  x: n,
463
463
  y: i
464
- }, u = await s.detectOverflow(e, a), p = V(X(o)), f = Et(p);
464
+ }, u = await s.detectOverflow(e, a), p = V(H(o)), f = Et(p);
465
465
  let h = d[f], g = d[p];
466
466
  if (r) {
467
467
  const w = f === "y" ? "top" : "left", y = f === "y" ? "bottom" : "right", x = h + u[w], v = h - u[y];
@@ -494,45 +494,45 @@ function rt() {
494
494
  return typeof window < "u";
495
495
  }
496
496
  function z(t) {
497
- return Lt(t) ? (t.nodeName || "").toLowerCase() : "#document";
497
+ return Ot(t) ? (t.nodeName || "").toLowerCase() : "#document";
498
498
  }
499
499
  function C(t) {
500
500
  var e;
501
501
  return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
502
502
  }
503
- function B(t) {
503
+ function F(t) {
504
504
  var e;
505
- return (e = (Lt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
505
+ return (e = (Ot(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
506
506
  }
507
- function Lt(t) {
507
+ function Ot(t) {
508
508
  return rt() ? t instanceof Node || t instanceof C(t).Node : !1;
509
509
  }
510
510
  function R(t) {
511
511
  return rt() ? t instanceof Element || t instanceof C(t).Element : !1;
512
512
  }
513
- function P(t) {
513
+ function $(t) {
514
514
  return rt() ? t instanceof HTMLElement || t instanceof C(t).HTMLElement : !1;
515
515
  }
516
516
  function bt(t) {
517
517
  return !rt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof C(t).ShadowRoot;
518
518
  }
519
- const ie = /* @__PURE__ */ new Set(["inline", "contents"]);
519
+ const se = /* @__PURE__ */ new Set(["inline", "contents"]);
520
520
  function et(t) {
521
521
  const {
522
522
  overflow: e,
523
523
  overflowX: n,
524
524
  overflowY: i,
525
525
  display: o
526
- } = T(t);
527
- return /auto|scroll|overlay|hidden|clip/.test(e + i + n) && !ie.has(o);
526
+ } = L(t);
527
+ return /auto|scroll|overlay|hidden|clip/.test(e + i + n) && !se.has(o);
528
528
  }
529
- const oe = /* @__PURE__ */ new Set(["table", "td", "th"]);
530
- function se(t) {
531
- return oe.has(z(t));
529
+ const re = /* @__PURE__ */ new Set(["table", "td", "th"]);
530
+ function le(t) {
531
+ return re.has(z(t));
532
532
  }
533
- const re = [":popover-open", ":modal"];
533
+ const ce = [":popover-open", ":modal"];
534
534
  function lt(t) {
535
- return re.some((e) => {
535
+ return ce.some((e) => {
536
536
  try {
537
537
  return t.matches(e);
538
538
  } catch {
@@ -540,30 +540,30 @@ function lt(t) {
540
540
  }
541
541
  });
542
542
  }
543
- const le = ["transform", "translate", "scale", "rotate", "perspective"], ce = ["transform", "translate", "scale", "rotate", "perspective", "filter"], ae = ["paint", "layout", "strict", "content"];
543
+ const ae = ["transform", "translate", "scale", "rotate", "perspective"], fe = ["transform", "translate", "scale", "rotate", "perspective", "filter"], ue = ["paint", "layout", "strict", "content"];
544
544
  function mt(t) {
545
- const e = wt(), n = R(t) ? T(t) : t;
546
- return le.some((i) => n[i] ? n[i] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || ce.some((i) => (n.willChange || "").includes(i)) || ae.some((i) => (n.contain || "").includes(i));
545
+ const e = wt(), n = R(t) ? L(t) : t;
546
+ return ae.some((i) => n[i] ? n[i] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || fe.some((i) => (n.willChange || "").includes(i)) || ue.some((i) => (n.contain || "").includes(i));
547
547
  }
548
- function fe(t) {
549
- let e = M(t);
550
- for (; P(e) && !Y(e); ) {
548
+ function de(t) {
549
+ let e = N(t);
550
+ for (; $(e) && !Y(e); ) {
551
551
  if (mt(e))
552
552
  return e;
553
553
  if (lt(e))
554
554
  return null;
555
- e = M(e);
555
+ e = N(e);
556
556
  }
557
557
  return null;
558
558
  }
559
559
  function wt() {
560
560
  return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
561
561
  }
562
- const ue = /* @__PURE__ */ new Set(["html", "body", "#document"]);
562
+ const he = /* @__PURE__ */ new Set(["html", "body", "#document"]);
563
563
  function Y(t) {
564
- return ue.has(z(t));
564
+ return he.has(z(t));
565
565
  }
566
- function T(t) {
566
+ function L(t) {
567
567
  return C(t).getComputedStyle(t);
568
568
  }
569
569
  function ct(t) {
@@ -575,7 +575,7 @@ function ct(t) {
575
575
  scrollTop: t.scrollY
576
576
  };
577
577
  }
578
- function M(t) {
578
+ function N(t) {
579
579
  if (z(t) === "html")
580
580
  return t;
581
581
  const e = (
@@ -583,74 +583,74 @@ function M(t) {
583
583
  t.assignedSlot || // DOM Element detected.
584
584
  t.parentNode || // ShadowRoot detected.
585
585
  bt(t) && t.host || // Fallback.
586
- B(t)
586
+ F(t)
587
587
  );
588
588
  return bt(e) ? e.host : e;
589
589
  }
590
590
  function Rt(t) {
591
- const e = M(t);
592
- return Y(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : P(e) && et(e) ? e : Rt(e);
591
+ const e = N(t);
592
+ return Y(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : $(e) && et(e) ? e : Rt(e);
593
593
  }
594
- function Tt(t, e, n) {
594
+ function Lt(t, e, n) {
595
595
  var i;
596
596
  e === void 0 && (e = []);
597
597
  const o = Rt(t), s = o === ((i = t.ownerDocument) == null ? void 0 : i.body), r = C(o);
598
- return s ? (ht(r), e.concat(r, r.visualViewport || [], et(o) ? o : [], [])) : e.concat(o, Tt(o, []));
598
+ return s ? (ht(r), e.concat(r, r.visualViewport || [], et(o) ? o : [], [])) : e.concat(o, Lt(o, []));
599
599
  }
600
600
  function ht(t) {
601
601
  return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
602
602
  }
603
603
  function kt(t) {
604
- const e = T(t);
604
+ const e = L(t);
605
605
  let n = parseFloat(e.width) || 0, i = parseFloat(e.height) || 0;
606
- const o = P(t), s = o ? t.offsetWidth : n, r = o ? t.offsetHeight : i, l = it(n) !== s || it(i) !== r;
606
+ const o = $(t), s = o ? t.offsetWidth : n, r = o ? t.offsetHeight : i, l = nt(n) !== s || nt(i) !== r;
607
607
  return l && (n = s, i = r), {
608
608
  width: n,
609
609
  height: i,
610
610
  $: l
611
611
  };
612
612
  }
613
- function Pt(t) {
613
+ function $t(t) {
614
614
  return R(t) ? t : t.contextElement;
615
615
  }
616
616
  function j(t) {
617
- const e = Pt(t);
618
- if (!P(e))
617
+ const e = $t(t);
618
+ if (!$(e))
619
619
  return k(1);
620
620
  const n = e.getBoundingClientRect(), {
621
621
  width: i,
622
622
  height: o,
623
623
  $: s
624
624
  } = kt(e);
625
- let r = (s ? it(n.width) : n.width) / i, l = (s ? it(n.height) : n.height) / o;
625
+ let r = (s ? nt(n.width) : n.width) / i, l = (s ? nt(n.height) : n.height) / o;
626
626
  return (!r || !Number.isFinite(r)) && (r = 1), (!l || !Number.isFinite(l)) && (l = 1), {
627
627
  x: r,
628
628
  y: l
629
629
  };
630
630
  }
631
- const de = /* @__PURE__ */ k(0);
632
- function Dt(t) {
631
+ const pe = /* @__PURE__ */ k(0);
632
+ function Pt(t) {
633
633
  const e = C(t);
634
- return !wt() || !e.visualViewport ? de : {
634
+ return !wt() || !e.visualViewport ? pe : {
635
635
  x: e.visualViewport.offsetLeft,
636
636
  y: e.visualViewport.offsetTop
637
637
  };
638
638
  }
639
- function he(t, e, n) {
639
+ function ge(t, e, n) {
640
640
  return e === void 0 && (e = !1), !n || e && n !== C(t) ? !1 : e;
641
641
  }
642
- function U(t, e, n, i) {
642
+ function Q(t, e, n, i) {
643
643
  e === void 0 && (e = !1), n === void 0 && (n = !1);
644
- const o = t.getBoundingClientRect(), s = Pt(t);
644
+ const o = t.getBoundingClientRect(), s = $t(t);
645
645
  let r = k(1);
646
646
  e && (i ? R(i) && (r = j(i)) : r = j(t));
647
- const l = he(s, n, i) ? Dt(s) : k(0);
647
+ const l = ge(s, n, i) ? Pt(s) : k(0);
648
648
  let c = (o.left + l.x) / r.x, a = (o.top + l.y) / r.y, d = o.width / r.x, u = o.height / r.y;
649
649
  if (s) {
650
650
  const p = C(s), f = i && R(i) ? C(i) : i;
651
651
  let h = p, g = ht(h);
652
652
  for (; g && i && f !== h; ) {
653
- const m = j(g), w = g.getBoundingClientRect(), y = T(g), x = w.left + (g.clientLeft + parseFloat(y.paddingLeft)) * m.x, v = w.top + (g.clientTop + parseFloat(y.paddingTop)) * m.y;
653
+ const m = j(g), w = g.getBoundingClientRect(), y = L(g), x = w.left + (g.clientLeft + parseFloat(y.paddingLeft)) * m.x, v = w.top + (g.clientTop + parseFloat(y.paddingTop)) * m.y;
654
654
  c *= m.x, a *= m.y, d *= m.x, u *= m.y, c += x, a += v, h = C(g), g = ht(h);
655
655
  }
656
656
  }
@@ -663,35 +663,35 @@ function U(t, e, n, i) {
663
663
  }
664
664
  function at(t, e) {
665
665
  const n = ct(t).scrollLeft;
666
- return e ? e.left + n : U(B(t)).left + n;
666
+ return e ? e.left + n : Q(F(t)).left + n;
667
667
  }
668
- function $t(t, e) {
668
+ function Dt(t, e) {
669
669
  const n = t.getBoundingClientRect(), i = n.left + e.scrollLeft - at(t, n), o = n.top + e.scrollTop;
670
670
  return {
671
671
  x: i,
672
672
  y: o
673
673
  };
674
674
  }
675
- function pe(t) {
675
+ function me(t) {
676
676
  let {
677
677
  elements: e,
678
678
  rect: n,
679
679
  offsetParent: i,
680
680
  strategy: o
681
681
  } = t;
682
- const s = o === "fixed", r = B(i), l = e ? lt(e.floating) : !1;
682
+ const s = o === "fixed", r = F(i), l = e ? lt(e.floating) : !1;
683
683
  if (i === r || l && s)
684
684
  return n;
685
685
  let c = {
686
686
  scrollLeft: 0,
687
687
  scrollTop: 0
688
688
  }, a = k(1);
689
- const d = k(0), u = P(i);
690
- if ((u || !u && !s) && ((z(i) !== "body" || et(r)) && (c = ct(i)), P(i))) {
691
- const f = U(i);
689
+ const d = k(0), u = $(i);
690
+ if ((u || !u && !s) && ((z(i) !== "body" || et(r)) && (c = ct(i)), $(i))) {
691
+ const f = Q(i);
692
692
  a = j(i), d.x = f.x + i.clientLeft, d.y = f.y + i.clientTop;
693
693
  }
694
- const p = r && !u && !s ? $t(r, c) : k(0);
694
+ const p = r && !u && !s ? Dt(r, c) : k(0);
695
695
  return {
696
696
  width: n.width * a.x,
697
697
  height: n.height * a.y,
@@ -699,14 +699,14 @@ function pe(t) {
699
699
  y: n.y * a.y - c.scrollTop * a.y + d.y + p.y
700
700
  };
701
701
  }
702
- function ge(t) {
702
+ function we(t) {
703
703
  return Array.from(t.getClientRects());
704
704
  }
705
- function me(t) {
706
- const e = B(t), n = ct(t), i = t.ownerDocument.body, o = _(e.scrollWidth, e.clientWidth, i.scrollWidth, i.clientWidth), s = _(e.scrollHeight, e.clientHeight, i.scrollHeight, i.clientHeight);
705
+ function ye(t) {
706
+ const e = F(t), n = ct(t), i = t.ownerDocument.body, o = X(e.scrollWidth, e.clientWidth, i.scrollWidth, i.clientWidth), s = X(e.scrollHeight, e.clientHeight, i.scrollHeight, i.clientHeight);
707
707
  let r = -n.scrollLeft + at(t);
708
708
  const l = -n.scrollTop;
709
- return T(i).direction === "rtl" && (r += _(e.clientWidth, i.clientWidth) - o), {
709
+ return L(i).direction === "rtl" && (r += X(e.clientWidth, i.clientWidth) - o), {
710
710
  width: o,
711
711
  height: s,
712
712
  x: r,
@@ -714,8 +714,8 @@ function me(t) {
714
714
  };
715
715
  }
716
716
  const St = 25;
717
- function we(t, e) {
718
- const n = C(t), i = B(t), o = n.visualViewport;
717
+ function xe(t, e) {
718
+ const n = C(t), i = F(t), o = n.visualViewport;
719
719
  let s = i.clientWidth, r = i.clientHeight, l = 0, c = 0;
720
720
  if (o) {
721
721
  s = o.width, r = o.height;
@@ -734,9 +734,9 @@ function we(t, e) {
734
734
  y: c
735
735
  };
736
736
  }
737
- const ye = /* @__PURE__ */ new Set(["absolute", "fixed"]);
738
- function xe(t, e) {
739
- const n = U(t, !0, e === "fixed"), i = n.top + t.clientTop, o = n.left + t.clientLeft, s = P(t) ? j(t) : k(1), r = t.clientWidth * s.x, l = t.clientHeight * s.y, c = o * s.x, a = i * s.y;
737
+ const ve = /* @__PURE__ */ new Set(["absolute", "fixed"]);
738
+ function be(t, e) {
739
+ const n = Q(t, !0, e === "fixed"), i = n.top + t.clientTop, o = n.left + t.clientLeft, s = $(t) ? j(t) : k(1), r = t.clientWidth * s.x, l = t.clientHeight * s.y, c = o * s.x, a = i * s.y;
740
740
  return {
741
741
  width: r,
742
742
  height: l,
@@ -747,13 +747,13 @@ function xe(t, e) {
747
747
  function At(t, e, n) {
748
748
  let i;
749
749
  if (e === "viewport")
750
- i = we(t, n);
750
+ i = xe(t, n);
751
751
  else if (e === "document")
752
- i = me(B(t));
752
+ i = ye(F(t));
753
753
  else if (R(e))
754
- i = xe(e, n);
754
+ i = be(e, n);
755
755
  else {
756
- const o = Dt(t);
756
+ const o = Pt(t);
757
757
  i = {
758
758
  x: e.x - o.x,
759
759
  y: e.y - o.y,
@@ -763,33 +763,33 @@ function At(t, e, n) {
763
763
  }
764
764
  return st(i);
765
765
  }
766
- function Ft(t, e) {
767
- const n = M(t);
768
- return n === e || !R(n) || Y(n) ? !1 : T(n).position === "fixed" || Ft(n, e);
766
+ function It(t, e) {
767
+ const n = N(t);
768
+ return n === e || !R(n) || Y(n) ? !1 : L(n).position === "fixed" || It(n, e);
769
769
  }
770
- function ve(t, e) {
770
+ function Se(t, e) {
771
771
  const n = e.get(t);
772
772
  if (n)
773
773
  return n;
774
- let i = Tt(t, []).filter((l) => R(l) && z(l) !== "body"), o = null;
775
- const s = T(t).position === "fixed";
776
- let r = s ? M(t) : t;
774
+ let i = Lt(t, []).filter((l) => R(l) && z(l) !== "body"), o = null;
775
+ const s = L(t).position === "fixed";
776
+ let r = s ? N(t) : t;
777
777
  for (; R(r) && !Y(r); ) {
778
- const l = T(r), c = mt(r);
779
- !c && l.position === "fixed" && (o = null), (s ? !c && !o : !c && l.position === "static" && !!o && ye.has(o.position) || et(r) && !c && Ft(t, r)) ? i = i.filter((d) => d !== r) : o = l, r = M(r);
778
+ const l = L(r), c = mt(r);
779
+ !c && l.position === "fixed" && (o = null), (s ? !c && !o : !c && l.position === "static" && !!o && ve.has(o.position) || et(r) && !c && It(t, r)) ? i = i.filter((d) => d !== r) : o = l, r = N(r);
780
780
  }
781
781
  return e.set(t, i), i;
782
782
  }
783
- function be(t) {
783
+ function Ae(t) {
784
784
  let {
785
785
  element: e,
786
786
  boundary: n,
787
787
  rootBoundary: i,
788
788
  strategy: o
789
789
  } = t;
790
- const r = [...n === "clippingAncestors" ? lt(e) ? [] : ve(e, this._c) : [].concat(n), i], l = r[0], c = r.reduce((a, d) => {
790
+ const r = [...n === "clippingAncestors" ? lt(e) ? [] : Se(e, this._c) : [].concat(n), i], l = r[0], c = r.reduce((a, d) => {
791
791
  const u = At(e, d, o);
792
- return a.top = _(u.top, a.top), a.right = Q(u.right, a.right), a.bottom = Q(u.bottom, a.bottom), a.left = _(u.left, a.left), a;
792
+ return a.top = X(u.top, a.top), a.right = J(u.right, a.right), a.bottom = J(u.bottom, a.bottom), a.left = X(u.left, a.left), a;
793
793
  }, At(e, l, o));
794
794
  return {
795
795
  width: c.right - c.left,
@@ -798,7 +798,7 @@ function be(t) {
798
798
  y: c.top
799
799
  };
800
800
  }
801
- function Se(t) {
801
+ function Ce(t) {
802
802
  const {
803
803
  width: e,
804
804
  height: n
@@ -808,8 +808,8 @@ function Se(t) {
808
808
  height: n
809
809
  };
810
810
  }
811
- function Ae(t, e, n) {
812
- const i = P(e), o = B(e), s = n === "fixed", r = U(t, !0, s, e);
811
+ function Ee(t, e, n) {
812
+ const i = $(e), o = F(e), s = n === "fixed", r = Q(t, !0, s, e);
813
813
  let l = {
814
814
  scrollLeft: 0,
815
815
  scrollTop: 0
@@ -820,11 +820,11 @@ function Ae(t, e, n) {
820
820
  }
821
821
  if (i || !i && !s)
822
822
  if ((z(e) !== "body" || et(o)) && (l = ct(e)), i) {
823
- const f = U(e, !0, s, e);
823
+ const f = Q(e, !0, s, e);
824
824
  c.x = f.x + e.clientLeft, c.y = f.y + e.clientTop;
825
825
  } else o && a();
826
826
  s && !i && o && a();
827
- const d = o && !i && !s ? $t(o, l) : k(0), u = r.left + l.scrollLeft - c.x - d.x, p = r.top + l.scrollTop - c.y - d.y;
827
+ const d = o && !i && !s ? Dt(o, l) : k(0), u = r.left + l.scrollLeft - c.x - d.x, p = r.top + l.scrollTop - c.y - d.y;
828
828
  return {
829
829
  x: u,
830
830
  y: p,
@@ -833,38 +833,38 @@ function Ae(t, e, n) {
833
833
  };
834
834
  }
835
835
  function ft(t) {
836
- return T(t).position === "static";
836
+ return L(t).position === "static";
837
837
  }
838
838
  function Ct(t, e) {
839
- if (!P(t) || T(t).position === "fixed")
839
+ if (!$(t) || L(t).position === "fixed")
840
840
  return null;
841
841
  if (e)
842
842
  return e(t);
843
843
  let n = t.offsetParent;
844
- return B(t) === n && (n = n.ownerDocument.body), n;
844
+ return F(t) === n && (n = n.ownerDocument.body), n;
845
845
  }
846
- function Bt(t, e) {
846
+ function Ft(t, e) {
847
847
  const n = C(t);
848
848
  if (lt(t))
849
849
  return n;
850
- if (!P(t)) {
851
- let o = M(t);
850
+ if (!$(t)) {
851
+ let o = N(t);
852
852
  for (; o && !Y(o); ) {
853
853
  if (R(o) && !ft(o))
854
854
  return o;
855
- o = M(o);
855
+ o = N(o);
856
856
  }
857
857
  return n;
858
858
  }
859
859
  let i = Ct(t, e);
860
- for (; i && se(i) && ft(i); )
860
+ for (; i && le(i) && ft(i); )
861
861
  i = Ct(i, e);
862
- return i && Y(i) && ft(i) && !mt(i) ? n : i || fe(t) || n;
862
+ return i && Y(i) && ft(i) && !mt(i) ? n : i || de(t) || n;
863
863
  }
864
- const Ce = async function(t) {
865
- const e = this.getOffsetParent || Bt, n = this.getDimensions, i = await n(t.floating);
864
+ const Te = async function(t) {
865
+ const e = this.getOffsetParent || Ft, n = this.getDimensions, i = await n(t.floating);
866
866
  return {
867
- reference: Ae(t.reference, await e(t.floating), t.strategy),
867
+ reference: Ee(t.reference, await e(t.floating), t.strategy),
868
868
  floating: {
869
869
  x: 0,
870
870
  y: 0,
@@ -873,67 +873,67 @@ const Ce = async function(t) {
873
873
  }
874
874
  };
875
875
  };
876
- function Ee(t) {
877
- return T(t).direction === "rtl";
878
- }
879
- const Oe = {
880
- convertOffsetParentRelativeRectToViewportRelativeRect: pe,
881
- getDocumentElement: B,
882
- getClippingRect: be,
883
- getOffsetParent: Bt,
884
- getElementRects: Ce,
885
- getClientRects: ge,
886
- getDimensions: Se,
876
+ function Oe(t) {
877
+ return L(t).direction === "rtl";
878
+ }
879
+ const Re = {
880
+ convertOffsetParentRelativeRectToViewportRelativeRect: me,
881
+ getDocumentElement: F,
882
+ getClippingRect: Ae,
883
+ getOffsetParent: Ft,
884
+ getElementRects: Te,
885
+ getClientRects: we,
886
+ getDimensions: Ce,
887
887
  getScale: j,
888
888
  isElement: R,
889
- isRTL: Ee
890
- }, Le = ee, Re = ne, Te = Ut, ke = Qt, Pe = (t, e, n) => {
889
+ isRTL: Oe
890
+ }, Le = ne, ke = oe, $e = te, Pe = Zt, De = (t, e, n) => {
891
891
  const i = /* @__PURE__ */ new Map(), o = {
892
- platform: Oe,
892
+ platform: Re,
893
893
  ...n
894
894
  }, s = {
895
895
  ...o.platform,
896
896
  _c: i
897
897
  };
898
- return Jt(t, e, {
898
+ return Qt(t, e, {
899
899
  ...o,
900
900
  platform: s
901
901
  });
902
902
  };
903
- function De(t) {
903
+ function Bt(t) {
904
904
  try {
905
905
  return document.querySelector(t);
906
906
  } catch {
907
907
  return console.warn(`[Trailguide] Invalid selector: ${t}`), null;
908
908
  }
909
909
  }
910
- function $e(t) {
910
+ function Vt(t) {
911
911
  const e = t.getBoundingClientRect(), n = window.getComputedStyle(t);
912
912
  return e.width > 0 && e.height > 0 && n.visibility !== "hidden" && n.display !== "none" && n.opacity !== "0";
913
913
  }
914
- function Fe(t) {
914
+ function Ie(t) {
915
915
  t.scrollIntoView({
916
916
  behavior: "smooth",
917
917
  block: "center",
918
918
  inline: "center"
919
919
  });
920
920
  }
921
- function nt(t, e, n) {
921
+ function it(t, e, n) {
922
922
  const i = document.createElement(t);
923
923
  return e && (i.className = e), n && n.appendChild(i), i;
924
924
  }
925
- class Be {
925
+ class Fe {
926
926
  constructor(e = {}) {
927
- F(this, "trail", null);
928
- F(this, "currentStepIndex", 0);
929
- F(this, "isActive", !1);
930
- F(this, "options", {});
927
+ I(this, "trail", null);
928
+ I(this, "currentStepIndex", 0);
929
+ I(this, "isActive", !1);
930
+ I(this, "options", {});
931
931
  // DOM elements
932
- F(this, "overlay", null);
933
- F(this, "tooltip", null);
934
- F(this, "arrowEl", null);
932
+ I(this, "overlay", null);
933
+ I(this, "tooltip", null);
934
+ I(this, "arrowEl", null);
935
935
  // Cleanup functions
936
- F(this, "cleanupFns", []);
936
+ I(this, "cleanupFns", []);
937
937
  this.options = e;
938
938
  }
939
939
  start(e) {
@@ -961,8 +961,8 @@ class Be {
961
961
  }
962
962
  createOverlay() {
963
963
  var n, i, o;
964
- this.overlay = nt("div", "trailguide-overlay"), document.body.appendChild(this.overlay);
965
- const e = nt("div", "trailguide-spotlight", this.overlay);
964
+ this.overlay = it("div", "trailguide-overlay"), document.body.appendChild(this.overlay);
965
+ const e = it("div", "trailguide-spotlight", this.overlay);
966
966
  e.innerHTML = `
967
967
  <svg width="100%" height="100%">
968
968
  <defs>
@@ -973,7 +973,7 @@ class Be {
973
973
  </defs>
974
974
  <rect x="0" y="0" width="100%" height="100%" fill="rgba(0,0,0,0.5)" mask="url(#trailguide-mask)" />
975
975
  </svg>
976
- `, nt("div", "trailguide-highlight", this.overlay), this.tooltip = nt("div", "trailguide-tooltip"), this.tooltip.innerHTML = `
976
+ `, it("div", "trailguide-highlight", this.overlay), this.tooltip = it("div", "trailguide-tooltip"), this.tooltip.innerHTML = `
977
977
  <div class="trailguide-tooltip-content">
978
978
  <div class="trailguide-tooltip-header">
979
979
  <h3 class="trailguide-tooltip-title"></h3>
@@ -995,12 +995,12 @@ class Be {
995
995
  if (!this.trail || !this.overlay || !this.tooltip) return;
996
996
  const e = this.trail.steps[this.currentStepIndex];
997
997
  if (!e) return;
998
- const n = De(e.target);
999
- if (!n || !$e(n)) {
998
+ const n = Bt(e.target);
999
+ if (!n || !Vt(n)) {
1000
1000
  console.warn(`[Trailguide] Target not found or not visible: ${e.target}`);
1001
1001
  return;
1002
1002
  }
1003
- Fe(n), setTimeout(() => {
1003
+ Ie(n), setTimeout(() => {
1004
1004
  var i, o;
1005
1005
  this.updateSpotlight(n), this.updateTooltip(e, n), (o = (i = this.options).onStepChange) == null || o.call(i, e, this.currentStepIndex);
1006
1006
  }, 100);
@@ -1024,13 +1024,13 @@ class Be {
1024
1024
  if (!this.tooltip || !this.trail || !this.arrowEl) return;
1025
1025
  const i = this.currentStepIndex === 0, o = this.currentStepIndex === this.trail.steps.length - 1, s = this.tooltip.querySelector(".trailguide-tooltip-title"), r = this.tooltip.querySelector(".trailguide-tooltip-body"), l = this.tooltip.querySelector(".trailguide-tooltip-progress"), c = this.tooltip.querySelector(".trailguide-btn-prev"), a = this.tooltip.querySelector(".trailguide-btn-next");
1026
1026
  s && (s.textContent = e.title), r && (r.textContent = e.content), l && (l.textContent = `${this.currentStepIndex + 1} of ${this.trail.steps.length}`), c && (c.style.display = i ? "none" : "block"), a && (a.textContent = o ? "Finish" : "Next");
1027
- const { x: d, y: u, middlewareData: p } = await Pe(n, this.tooltip, {
1027
+ const { x: d, y: u, middlewareData: p } = await De(n, this.tooltip, {
1028
1028
  placement: e.placement,
1029
1029
  middleware: [
1030
1030
  Le(12),
1031
- Te(),
1032
- Re({ padding: 8 }),
1033
- ke({ element: this.arrowEl })
1031
+ $e(),
1032
+ ke({ padding: 8 }),
1033
+ Pe({ element: this.arrowEl })
1034
1034
  ]
1035
1035
  });
1036
1036
  if (this.tooltip.style.left = `${d}px`, this.tooltip.style.top = `${u}px`, p.arrow && this.arrowEl) {
@@ -1062,29 +1062,98 @@ class Be {
1062
1062
  }
1063
1063
  }
1064
1064
  let b = null;
1065
- function Ve(t, e) {
1066
- return b && b.stop(), b = new Be(e), b.start(t), b;
1065
+ function Ne(t, e) {
1066
+ return b && b.stop(), b = new Fe(e), b.start(t), b;
1067
1067
  }
1068
- function Me() {
1068
+ function We() {
1069
1069
  b == null || b.stop();
1070
1070
  }
1071
- function We() {
1071
+ function Me() {
1072
1072
  b == null || b.next();
1073
1073
  }
1074
- function He() {
1074
+ function qe() {
1075
1075
  b == null || b.prev();
1076
1076
  }
1077
- function Ie() {
1077
+ function _e() {
1078
1078
  b == null || b.skip();
1079
1079
  }
1080
+ function He(t) {
1081
+ const e = [], n = [];
1082
+ return t.id || e.push({
1083
+ stepId: "",
1084
+ stepIndex: -1,
1085
+ type: "missing_required_field",
1086
+ message: 'Trail is missing required "id" field'
1087
+ }), !t.steps || t.steps.length === 0 ? (e.push({
1088
+ stepId: "",
1089
+ stepIndex: -1,
1090
+ type: "missing_required_field",
1091
+ message: "Trail has no steps"
1092
+ }), { valid: !1, errors: e, warnings: n }) : (t.steps.forEach((i, o) => {
1093
+ if (i.id || e.push({
1094
+ stepId: `step-${o}`,
1095
+ stepIndex: o,
1096
+ type: "missing_required_field",
1097
+ message: `Step ${o + 1} is missing required "id" field`
1098
+ }), !i.target) {
1099
+ e.push({
1100
+ stepId: i.id || `step-${o}`,
1101
+ stepIndex: o,
1102
+ type: "missing_required_field",
1103
+ message: `Step ${o + 1} is missing required "target" field`
1104
+ });
1105
+ return;
1106
+ }
1107
+ const s = Bt(i.target);
1108
+ s ? Vt(s) || n.push({
1109
+ stepId: i.id,
1110
+ stepIndex: o,
1111
+ type: "hidden_target",
1112
+ message: `Step ${o + 1} ("${i.title}"): Target element exists but is hidden`,
1113
+ selector: i.target
1114
+ }) : e.push({
1115
+ stepId: i.id,
1116
+ stepIndex: o,
1117
+ type: "missing_target",
1118
+ message: `Step ${o + 1} ("${i.title}"): Target element not found`,
1119
+ selector: i.target
1120
+ }), i.target && Be(i.target) && n.push({
1121
+ stepId: i.id,
1122
+ stepIndex: o,
1123
+ type: "unstable_selector",
1124
+ message: `Step ${o + 1}: Consider using data-trail-id for more stable targeting`,
1125
+ selector: i.target
1126
+ });
1127
+ }), {
1128
+ valid: e.length === 0,
1129
+ errors: e,
1130
+ warnings: n
1131
+ });
1132
+ }
1133
+ function Be(t) {
1134
+ return t.startsWith("#") || t.includes("[data-") ? !1 : !!(t.includes(":nth-child") || t.includes(":nth-of-type") || /^\.[a-z]+-[a-z0-9]+$/i.test(t));
1135
+ }
1136
+ function Xe(t) {
1137
+ if (t.valid && t.warnings.length === 0) {
1138
+ console.log("%c✓ Trail validation passed", "color: green; font-weight: bold");
1139
+ return;
1140
+ }
1141
+ t.errors.length > 0 && (console.group("%c✗ Trail validation errors", "color: red; font-weight: bold"), t.errors.forEach((e) => {
1142
+ console.error(`Step ${e.stepIndex + 1}: ${e.message}`), e.selector && console.error(` Selector: ${e.selector}`);
1143
+ }), console.groupEnd()), t.warnings.length > 0 && (console.group("%c⚠ Trail validation warnings", "color: orange; font-weight: bold"), t.warnings.forEach((e) => {
1144
+ console.warn(`Step ${e.stepIndex + 1}: ${e.message}`), e.selector && console.warn(` Selector: ${e.selector}`);
1145
+ }), console.groupEnd());
1146
+ }
1080
1147
  export {
1081
- Be as Trailguide,
1082
- De as findElement,
1083
- $e as isElementVisible,
1084
- We as next,
1085
- He as prev,
1086
- Fe as scrollToElement,
1087
- Ie as skip,
1088
- Ve as start,
1089
- Me as stop
1148
+ Fe as Trailguide,
1149
+ Bt as findElement,
1150
+ Vt as isElementVisible,
1151
+ Xe as logValidationResults,
1152
+ Me as next,
1153
+ qe as prev,
1154
+ Ie as scrollToElement,
1155
+ _e as skip,
1156
+ Ne as start,
1157
+ We as stop,
1158
+ He as validateTrail
1090
1159
  };
@@ -1,4 +1,4 @@
1
- (function(w,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(w=typeof globalThis<"u"?globalThis:w||self,S(w.Trailguide={}))})(this,function(w){"use strict";var He=Object.defineProperty;var Ie=(w,S,T)=>S in w?He(w,S,{enumerable:!0,configurable:!0,writable:!0,value:T}):w[S]=T;var M=(w,S,T)=>Ie(w,typeof S!="symbol"?S+"":S,T);const S=Math.min,T=Math.max,it=Math.round,$=t=>({x:t,y:t}),It={left:"right",right:"left",bottom:"top",top:"bottom"},qt={start:"end",end:"start"};function ut(t,e,i){return T(t,S(e,i))}function J(t,e){return typeof t=="function"?t(e):t}function q(t){return t.split("-")[0]}function Q(t){return t.split("-")[1]}function xt(t){return t==="x"?"y":"x"}function dt(t){return t==="y"?"height":"width"}const jt=new Set(["top","bottom"]);function W(t){return jt.has(q(t))?"y":"x"}function ht(t){return xt(W(t))}function Xt(t,e,i){i===void 0&&(i=!1);const n=Q(t),o=ht(t),s=dt(o);let r=o==="x"?n===(i?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(r=ot(r)),[r,ot(r)]}function _t(t){const e=ot(t);return[pt(t),e,pt(e)]}function pt(t){return t.replace(/start|end/g,e=>qt[e])}const vt=["left","right"],bt=["right","left"],Yt=["top","bottom"],zt=["bottom","top"];function Kt(t,e,i){switch(t){case"top":case"bottom":return i?e?bt:vt:e?vt:bt;case"left":case"right":return e?Yt:zt;default:return[]}}function Gt(t,e,i,n){const o=Q(t);let s=Kt(q(t),i==="start",n);return o&&(s=s.map(r=>r+"-"+o),e&&(s=s.concat(s.map(pt)))),s}function ot(t){return t.replace(/left|right|bottom|top/g,e=>It[e])}function Jt(t){return{top:0,right:0,bottom:0,left:0,...t}}function St(t){return typeof t!="number"?Jt(t):{top:t,right:t,bottom:t,left:t}}function st(t){const{x:e,y:i,width:n,height:o}=t;return{width:n,height:o,top:i,left:e,right:e+n,bottom:i+o,x:e,y:i}}function At(t,e,i){let{reference:n,floating:o}=t;const s=W(e),r=ht(e),l=dt(r),c=q(e),a=s==="y",d=n.x+n.width/2-o.width/2,u=n.y+n.height/2-o.height/2,p=n[l]/2-o[l]/2;let f;switch(c){case"top":f={x:d,y:n.y-o.height};break;case"bottom":f={x:d,y:n.y+n.height};break;case"right":f={x:n.x+n.width,y:u};break;case"left":f={x:n.x-o.width,y:u};break;default:f={x:n.x,y:n.y}}switch(Q(e)){case"start":f[r]-=p*(i&&a?-1:1);break;case"end":f[r]+=p*(i&&a?-1:1);break}return f}async function Qt(t,e){var i;e===void 0&&(e={});const{x:n,y:o,platform:s,rects:r,elements:l,strategy:c}=t,{boundary:a="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:p=!1,padding:f=0}=J(e,t),h=St(f),m=l[p?u==="floating"?"reference":"floating":u],y=st(await s.getClippingRect({element:(i=await(s.isElement==null?void 0:s.isElement(m)))==null||i?m:m.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:a,rootBoundary:d,strategy:c})),x=u==="floating"?{x:n,y:o,width:r.floating.width,height:r.floating.height}:r.reference,v=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),b=await(s.isElement==null?void 0:s.isElement(v))?await(s.getScale==null?void 0:s.getScale(v))||{x:1,y:1}:{x:1,y:1},k=st(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:v,strategy:c}):x);return{top:(y.top-k.top+h.top)/b.y,bottom:(k.bottom-y.bottom+h.bottom)/b.y,left:(y.left-k.left+h.left)/b.x,right:(k.right-y.right+h.right)/b.x}}const Ut=async(t,e,i)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:r}=i,l=s.filter(Boolean),c=await(r.isRTL==null?void 0:r.isRTL(e));let a=await r.getElementRects({reference:t,floating:e,strategy:o}),{x:d,y:u}=At(a,n,c),p=n,f={},h=0;for(let m=0;m<l.length;m++){var g;const{name:y,fn:x}=l[m],{x:v,y:b,data:k,reset:E}=await x({x:d,y:u,initialPlacement:n,placement:p,strategy:o,middlewareData:f,rects:a,platform:{...r,detectOverflow:(g=r.detectOverflow)!=null?g:Qt},elements:{reference:t,floating:e}});d=v??d,u=b??u,f={...f,[y]:{...f[y],...k}},E&&h<=50&&(h++,typeof E=="object"&&(E.placement&&(p=E.placement),E.rects&&(a=E.rects===!0?await r.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:d,y:u}=At(a,p,c)),m=-1)}return{x:d,y:u,placement:p,strategy:o,middlewareData:f}},Zt=t=>({name:"arrow",options:t,async fn(e){const{x:i,y:n,placement:o,rects:s,platform:r,elements:l,middlewareData:c}=e,{element:a,padding:d=0}=J(t,e)||{};if(a==null)return{};const u=St(d),p={x:i,y:n},f=ht(o),h=dt(f),g=await r.getDimensions(a),m=f==="y",y=m?"top":"left",x=m?"bottom":"right",v=m?"clientHeight":"clientWidth",b=s.reference[h]+s.reference[f]-p[f]-s.floating[h],k=p[f]-s.reference[f],E=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a));let j=E?E[v]:0;(!j||!await(r.isElement==null?void 0:r.isElement(E)))&&(j=l.floating[v]||s.floating[h]);const tt=b/2-k/2,X=j/2-g[h]/2-1,V=S(u[y],X),et=S(u[x],X),_=V,nt=j-g[h]-et,C=j/2-g[h]/2+tt,Y=ut(_,C,nt),N=!c.arrow&&Q(o)!=null&&C!==Y&&s.reference[h]/2-(C<_?V:et)-g[h]/2<0,P=N?C<_?C-_:C-nt:0;return{[f]:p[f]+P,data:{[f]:Y,centerOffset:C-Y-P,...N&&{alignmentOffset:P}},reset:N}}}),te=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var i,n;const{placement:o,middlewareData:s,rects:r,initialPlacement:l,platform:c,elements:a}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:g=!0,...m}=J(t,e);if((i=s.arrow)!=null&&i.alignmentOffset)return{};const y=q(o),x=W(l),v=q(l)===l,b=await(c.isRTL==null?void 0:c.isRTL(a.floating)),k=p||(v||!g?[ot(l)]:_t(l)),E=h!=="none";!p&&E&&k.push(...Gt(l,g,h,b));const j=[l,...k],tt=await c.detectOverflow(e,m),X=[];let V=((n=s.flip)==null?void 0:n.overflows)||[];if(d&&X.push(tt[y]),u){const C=Xt(o,r,b);X.push(tt[C[0]],tt[C[1]])}if(V=[...V,{placement:o,overflows:X}],!X.every(C=>C<=0)){var et,_;const C=(((et=s.flip)==null?void 0:et.index)||0)+1,Y=j[C];if(Y&&(!(u==="alignment"?x!==W(Y):!1)||V.every(D=>W(D.placement)===x?D.overflows[0]>0:!0)))return{data:{index:C,overflows:V},reset:{placement:Y}};let N=(_=V.filter(P=>P.overflows[0]<=0).sort((P,D)=>P.overflows[1]-D.overflows[1])[0])==null?void 0:_.placement;if(!N)switch(f){case"bestFit":{var nt;const P=(nt=V.filter(D=>{if(E){const I=W(D.placement);return I===x||I==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(I=>I>0).reduce((I,We)=>I+We,0)]).sort((D,I)=>D[1]-I[1])[0])==null?void 0:nt[0];P&&(N=P);break}case"initialPlacement":N=l;break}if(o!==N)return{reset:{placement:N}}}return{}}}},ee=new Set(["left","top"]);async function ne(t,e){const{placement:i,platform:n,elements:o}=t,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),r=q(i),l=Q(i),c=W(i)==="y",a=ee.has(r)?-1:1,d=s&&c?-1:1,u=J(e,t);let{mainAxis:p,crossAxis:f,alignmentAxis:h}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof h=="number"&&(f=l==="end"?h*-1:h),c?{x:f*d,y:p*a}:{x:p*a,y:f*d}}const ie=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var i,n;const{x:o,y:s,placement:r,middlewareData:l}=e,c=await ne(e,t);return r===((i=l.offset)==null?void 0:i.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:r}}}}},oe=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:i,y:n,placement:o,platform:s}=e,{mainAxis:r=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x,y:v}=y;return{x,y:v}}},...a}=J(t,e),d={x:i,y:n},u=await s.detectOverflow(e,a),p=W(q(o)),f=xt(p);let h=d[f],g=d[p];if(r){const y=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=h+u[y],b=h-u[x];h=ut(v,h,b)}if(l){const y=p==="y"?"top":"left",x=p==="y"?"bottom":"right",v=g+u[y],b=g-u[x];g=ut(v,g,b)}const m=c.fn({...e,[f]:h,[p]:g});return{...m,data:{x:m.x-i,y:m.y-n,enabled:{[f]:r,[p]:l}}}}}};function rt(){return typeof window<"u"}function z(t){return Ct(t)?(t.nodeName||"").toLowerCase():"#document"}function O(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function B(t){var e;return(e=(Ct(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ct(t){return rt()?t instanceof Node||t instanceof O(t).Node:!1}function L(t){return rt()?t instanceof Element||t instanceof O(t).Element:!1}function F(t){return rt()?t instanceof HTMLElement||t instanceof O(t).HTMLElement:!1}function Et(t){return!rt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof O(t).ShadowRoot}const se=new Set(["inline","contents"]);function U(t){const{overflow:e,overflowX:i,overflowY:n,display:o}=R(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+i)&&!se.has(o)}const re=new Set(["table","td","th"]);function le(t){return re.has(z(t))}const ce=[":popover-open",":modal"];function lt(t){return ce.some(e=>{try{return t.matches(e)}catch{return!1}})}const ae=["transform","translate","scale","rotate","perspective"],fe=["transform","translate","scale","rotate","perspective","filter"],ue=["paint","layout","strict","content"];function gt(t){const e=mt(),i=L(t)?R(t):t;return ae.some(n=>i[n]?i[n]!=="none":!1)||(i.containerType?i.containerType!=="normal":!1)||!e&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!e&&(i.filter?i.filter!=="none":!1)||fe.some(n=>(i.willChange||"").includes(n))||ue.some(n=>(i.contain||"").includes(n))}function de(t){let e=H(t);for(;F(e)&&!K(e);){if(gt(e))return e;if(lt(e))return null;e=H(e)}return null}function mt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const he=new Set(["html","body","#document"]);function K(t){return he.has(z(t))}function R(t){return O(t).getComputedStyle(t)}function ct(t){return L(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function H(t){if(z(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Et(t)&&t.host||B(t);return Et(e)?e.host:e}function Ot(t){const e=H(t);return K(e)?t.ownerDocument?t.ownerDocument.body:t.body:F(e)&&U(e)?e:Ot(e)}function Tt(t,e,i){var n;e===void 0&&(e=[]);const o=Ot(t),s=o===((n=t.ownerDocument)==null?void 0:n.body),r=O(o);return s?(wt(r),e.concat(r,r.visualViewport||[],U(o)?o:[],[])):e.concat(o,Tt(o,[]))}function wt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Lt(t){const e=R(t);let i=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const o=F(t),s=o?t.offsetWidth:i,r=o?t.offsetHeight:n,l=it(i)!==s||it(n)!==r;return l&&(i=s,n=r),{width:i,height:n,$:l}}function Rt(t){return L(t)?t:t.contextElement}function G(t){const e=Rt(t);if(!F(e))return $(1);const i=e.getBoundingClientRect(),{width:n,height:o,$:s}=Lt(e);let r=(s?it(i.width):i.width)/n,l=(s?it(i.height):i.height)/o;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const pe=$(0);function kt(t){const e=O(t);return!mt()||!e.visualViewport?pe:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ge(t,e,i){return e===void 0&&(e=!1),!i||e&&i!==O(t)?!1:e}function Z(t,e,i,n){e===void 0&&(e=!1),i===void 0&&(i=!1);const o=t.getBoundingClientRect(),s=Rt(t);let r=$(1);e&&(n?L(n)&&(r=G(n)):r=G(t));const l=ge(s,i,n)?kt(s):$(0);let c=(o.left+l.x)/r.x,a=(o.top+l.y)/r.y,d=o.width/r.x,u=o.height/r.y;if(s){const p=O(s),f=n&&L(n)?O(n):n;let h=p,g=wt(h);for(;g&&n&&f!==h;){const m=G(g),y=g.getBoundingClientRect(),x=R(g),v=y.left+(g.clientLeft+parseFloat(x.paddingLeft))*m.x,b=y.top+(g.clientTop+parseFloat(x.paddingTop))*m.y;c*=m.x,a*=m.y,d*=m.x,u*=m.y,c+=v,a+=b,h=O(g),g=wt(h)}}return st({width:d,height:u,x:c,y:a})}function at(t,e){const i=ct(t).scrollLeft;return e?e.left+i:Z(B(t)).left+i}function Pt(t,e){const i=t.getBoundingClientRect(),n=i.left+e.scrollLeft-at(t,i),o=i.top+e.scrollTop;return{x:n,y:o}}function me(t){let{elements:e,rect:i,offsetParent:n,strategy:o}=t;const s=o==="fixed",r=B(n),l=e?lt(e.floating):!1;if(n===r||l&&s)return i;let c={scrollLeft:0,scrollTop:0},a=$(1);const d=$(0),u=F(n);if((u||!u&&!s)&&((z(n)!=="body"||U(r))&&(c=ct(n)),F(n))){const f=Z(n);a=G(n),d.x=f.x+n.clientLeft,d.y=f.y+n.clientTop}const p=r&&!u&&!s?Pt(r,c):$(0);return{width:i.width*a.x,height:i.height*a.y,x:i.x*a.x-c.scrollLeft*a.x+d.x+p.x,y:i.y*a.y-c.scrollTop*a.y+d.y+p.y}}function we(t){return Array.from(t.getClientRects())}function ye(t){const e=B(t),i=ct(t),n=t.ownerDocument.body,o=T(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),s=T(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let r=-i.scrollLeft+at(t);const l=-i.scrollTop;return R(n).direction==="rtl"&&(r+=T(e.clientWidth,n.clientWidth)-o),{width:o,height:s,x:r,y:l}}const Dt=25;function xe(t,e){const i=O(t),n=B(t),o=i.visualViewport;let s=n.clientWidth,r=n.clientHeight,l=0,c=0;if(o){s=o.width,r=o.height;const d=mt();(!d||d&&e==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const a=at(n);if(a<=0){const d=n.ownerDocument,u=d.body,p=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,h=Math.abs(n.clientWidth-u.clientWidth-f);h<=Dt&&(s-=h)}else a<=Dt&&(s+=a);return{width:s,height:r,x:l,y:c}}const ve=new Set(["absolute","fixed"]);function be(t,e){const i=Z(t,!0,e==="fixed"),n=i.top+t.clientTop,o=i.left+t.clientLeft,s=F(t)?G(t):$(1),r=t.clientWidth*s.x,l=t.clientHeight*s.y,c=o*s.x,a=n*s.y;return{width:r,height:l,x:c,y:a}}function $t(t,e,i){let n;if(e==="viewport")n=xe(t,i);else if(e==="document")n=ye(B(t));else if(L(e))n=be(e,i);else{const o=kt(t);n={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return st(n)}function Ft(t,e){const i=H(t);return i===e||!L(i)||K(i)?!1:R(i).position==="fixed"||Ft(i,e)}function Se(t,e){const i=e.get(t);if(i)return i;let n=Tt(t,[]).filter(l=>L(l)&&z(l)!=="body"),o=null;const s=R(t).position==="fixed";let r=s?H(t):t;for(;L(r)&&!K(r);){const l=R(r),c=gt(r);!c&&l.position==="fixed"&&(o=null),(s?!c&&!o:!c&&l.position==="static"&&!!o&&ve.has(o.position)||U(r)&&!c&&Ft(t,r))?n=n.filter(d=>d!==r):o=l,r=H(r)}return e.set(t,n),n}function Ae(t){let{element:e,boundary:i,rootBoundary:n,strategy:o}=t;const r=[...i==="clippingAncestors"?lt(e)?[]:Se(e,this._c):[].concat(i),n],l=r[0],c=r.reduce((a,d)=>{const u=$t(e,d,o);return a.top=T(u.top,a.top),a.right=S(u.right,a.right),a.bottom=S(u.bottom,a.bottom),a.left=T(u.left,a.left),a},$t(e,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Ce(t){const{width:e,height:i}=Lt(t);return{width:e,height:i}}function Ee(t,e,i){const n=F(e),o=B(e),s=i==="fixed",r=Z(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const c=$(0);function a(){c.x=at(o)}if(n||!n&&!s)if((z(e)!=="body"||U(o))&&(l=ct(e)),n){const f=Z(e,!0,s,e);c.x=f.x+e.clientLeft,c.y=f.y+e.clientTop}else o&&a();s&&!n&&o&&a();const d=o&&!n&&!s?Pt(o,l):$(0),u=r.left+l.scrollLeft-c.x-d.x,p=r.top+l.scrollTop-c.y-d.y;return{x:u,y:p,width:r.width,height:r.height}}function yt(t){return R(t).position==="static"}function Bt(t,e){if(!F(t)||R(t).position==="fixed")return null;if(e)return e(t);let i=t.offsetParent;return B(t)===i&&(i=i.ownerDocument.body),i}function Vt(t,e){const i=O(t);if(lt(t))return i;if(!F(t)){let o=H(t);for(;o&&!K(o);){if(L(o)&&!yt(o))return o;o=H(o)}return i}let n=Bt(t,e);for(;n&&le(n)&&yt(n);)n=Bt(n,e);return n&&K(n)&&yt(n)&&!gt(n)?i:n||de(t)||i}const Oe=async function(t){const e=this.getOffsetParent||Vt,i=this.getDimensions,n=await i(t.floating);return{reference:Ee(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Te(t){return R(t).direction==="rtl"}const Le={convertOffsetParentRelativeRectToViewportRelativeRect:me,getDocumentElement:B,getClippingRect:Ae,getOffsetParent:Vt,getElementRects:Oe,getClientRects:we,getDimensions:Ce,getScale:G,isElement:L,isRTL:Te},Re=ie,ke=oe,Pe=te,De=Zt,$e=(t,e,i)=>{const n=new Map,o={platform:Le,...i},s={...o.platform,_c:n};return Ut(t,e,{...o,platform:s})};function Nt(t){try{return document.querySelector(t)}catch{return console.warn(`[Trailguide] Invalid selector: ${t}`),null}}function Mt(t){const e=t.getBoundingClientRect(),i=window.getComputedStyle(t);return e.width>0&&e.height>0&&i.visibility!=="hidden"&&i.display!=="none"&&i.opacity!=="0"}function Wt(t){t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})}function ft(t,e,i){const n=document.createElement(t);return e&&(n.className=e),i&&i.appendChild(n),n}class Ht{constructor(e={}){M(this,"trail",null);M(this,"currentStepIndex",0);M(this,"isActive",!1);M(this,"options",{});M(this,"overlay",null);M(this,"tooltip",null);M(this,"arrowEl",null);M(this,"cleanupFns",[]);this.options=e}start(e){this.trail=e,this.currentStepIndex=0,this.isActive=!0,this.createOverlay(),this.showStep(),this.bindKeyboard()}stop(){this.isActive=!1,this.cleanup()}next(){!this.trail||!this.isActive||(this.currentStepIndex<this.trail.steps.length-1?(this.currentStepIndex++,this.showStep()):this.complete())}prev(){!this.trail||!this.isActive||this.currentStepIndex>0&&(this.currentStepIndex--,this.showStep())}skip(){var e,i;this.isActive=!1,this.cleanup(),(i=(e=this.options).onSkip)==null||i.call(e)}goToStep(e){!this.trail||!this.isActive||e>=0&&e<this.trail.steps.length&&(this.currentStepIndex=e,this.showStep())}complete(){var e,i;this.isActive=!1,this.cleanup(),(i=(e=this.options).onComplete)==null||i.call(e)}createOverlay(){var i,n,o;this.overlay=ft("div","trailguide-overlay"),document.body.appendChild(this.overlay);const e=ft("div","trailguide-spotlight",this.overlay);e.innerHTML=`
1
+ (function(w,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(w=typeof globalThis<"u"?globalThis:w||self,S(w.Trailguide={}))})(this,function(w){"use strict";var He=Object.defineProperty;var je=(w,S,O)=>S in w?He(w,S,{enumerable:!0,configurable:!0,writable:!0,value:O}):w[S]=O;var N=(w,S,O)=>je(w,typeof S!="symbol"?S+"":S,O);const S=Math.min,O=Math.max,nt=Math.round,D=t=>({x:t,y:t}),qt={left:"right",right:"left",bottom:"top",top:"bottom"},_t={start:"end",end:"start"};function ut(t,e,n){return O(t,S(e,n))}function G(t,e){return typeof t=="function"?t(e):t}function _(t){return t.split("-")[0]}function J(t){return t.split("-")[1]}function bt(t){return t==="x"?"y":"x"}function dt(t){return t==="y"?"height":"width"}const Ht=new Set(["top","bottom"]);function M(t){return Ht.has(_(t))?"y":"x"}function ht(t){return bt(M(t))}function jt(t,e,n){n===void 0&&(n=!1);const i=J(t),o=ht(t),s=dt(o);let r=o==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(r=ot(r)),[r,ot(r)]}function Xt(t){const e=ot(t);return[pt(t),e,pt(e)]}function pt(t){return t.replace(/start|end/g,e=>_t[e])}const St=["left","right"],At=["right","left"],Yt=["top","bottom"],zt=["bottom","top"];function Kt(t,e,n){switch(t){case"top":case"bottom":return n?e?At:St:e?St:At;case"left":case"right":return e?Yt:zt;default:return[]}}function Ut(t,e,n,i){const o=J(t);let s=Kt(_(t),n==="start",i);return o&&(s=s.map(r=>r+"-"+o),e&&(s=s.concat(s.map(pt)))),s}function ot(t){return t.replace(/left|right|bottom|top/g,e=>qt[e])}function Gt(t){return{top:0,right:0,bottom:0,left:0,...t}}function Tt(t){return typeof t!="number"?Gt(t):{top:t,right:t,bottom:t,left:t}}function st(t){const{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function Ct(t,e,n){let{reference:i,floating:o}=t;const s=M(e),r=ht(e),l=dt(r),c=_(e),a=s==="y",d=i.x+i.width/2-o.width/2,u=i.y+i.height/2-o.height/2,p=i[l]/2-o[l]/2;let f;switch(c){case"top":f={x:d,y:i.y-o.height};break;case"bottom":f={x:d,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:u};break;case"left":f={x:i.x-o.width,y:u};break;default:f={x:i.x,y:i.y}}switch(J(e)){case"start":f[r]-=p*(n&&a?-1:1);break;case"end":f[r]+=p*(n&&a?-1:1);break}return f}async function Jt(t,e){var n;e===void 0&&(e={});const{x:i,y:o,platform:s,rects:r,elements:l,strategy:c}=t,{boundary:a="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:p=!1,padding:f=0}=G(e,t),h=Tt(f),m=l[p?u==="floating"?"reference":"floating":u],y=st(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(m)))==null||n?m:m.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:a,rootBoundary:d,strategy:c})),x=u==="floating"?{x:i,y:o,width:r.floating.width,height:r.floating.height}:r.reference,v=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),b=await(s.isElement==null?void 0:s.isElement(v))?await(s.getScale==null?void 0:s.getScale(v))||{x:1,y:1}:{x:1,y:1},k=st(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:v,strategy:c}):x);return{top:(y.top-k.top+h.top)/b.y,bottom:(k.bottom-y.bottom+h.bottom)/b.y,left:(y.left-k.left+h.left)/b.x,right:(k.right-y.right+h.right)/b.x}}const Qt=async(t,e,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:s=[],platform:r}=n,l=s.filter(Boolean),c=await(r.isRTL==null?void 0:r.isRTL(e));let a=await r.getElementRects({reference:t,floating:e,strategy:o}),{x:d,y:u}=Ct(a,i,c),p=i,f={},h=0;for(let m=0;m<l.length;m++){var g;const{name:y,fn:x}=l[m],{x:v,y:b,data:k,reset:C}=await x({x:d,y:u,initialPlacement:i,placement:p,strategy:o,middlewareData:f,rects:a,platform:{...r,detectOverflow:(g=r.detectOverflow)!=null?g:Jt},elements:{reference:t,floating:e}});d=v??d,u=b??u,f={...f,[y]:{...f[y],...k}},C&&h<=50&&(h++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(a=C.rects===!0?await r.getElementRects({reference:t,floating:e,strategy:o}):C.rects),{x:d,y:u}=Ct(a,p,c)),m=-1)}return{x:d,y:u,placement:p,strategy:o,middlewareData:f}},Zt=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:o,rects:s,platform:r,elements:l,middlewareData:c}=e,{element:a,padding:d=0}=G(t,e)||{};if(a==null)return{};const u=Tt(d),p={x:n,y:i},f=ht(o),h=dt(f),g=await r.getDimensions(a),m=f==="y",y=m?"top":"left",x=m?"bottom":"right",v=m?"clientHeight":"clientWidth",b=s.reference[h]+s.reference[f]-p[f]-s.floating[h],k=p[f]-s.reference[f],C=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a));let H=C?C[v]:0;(!H||!await(r.isElement==null?void 0:r.isElement(C)))&&(H=l.floating[v]||s.floating[h]);const tt=b/2-k/2,j=H/2-g[h]/2-1,V=S(u[y],j),et=S(u[x],j),X=V,it=H-g[h]-et,T=H/2-g[h]/2+tt,Y=ut(X,T,it),B=!c.arrow&&J(o)!=null&&T!==Y&&s.reference[h]/2-(T<X?V:et)-g[h]/2<0,$=B?T<X?T-X:T-it:0;return{[f]:p[f]+$,data:{[f]:Y,centerOffset:T-Y-$,...B&&{alignmentOffset:$}},reset:B}}}),te=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,i;const{placement:o,middlewareData:s,rects:r,initialPlacement:l,platform:c,elements:a}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:g=!0,...m}=G(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=_(o),x=M(l),v=_(l)===l,b=await(c.isRTL==null?void 0:c.isRTL(a.floating)),k=p||(v||!g?[ot(l)]:Xt(l)),C=h!=="none";!p&&C&&k.push(...Ut(l,g,h,b));const H=[l,...k],tt=await c.detectOverflow(e,m),j=[];let V=((i=s.flip)==null?void 0:i.overflows)||[];if(d&&j.push(tt[y]),u){const T=jt(o,r,b);j.push(tt[T[0]],tt[T[1]])}if(V=[...V,{placement:o,overflows:j}],!j.every(T=>T<=0)){var et,X;const T=(((et=s.flip)==null?void 0:et.index)||0)+1,Y=H[T];if(Y&&(!(u==="alignment"?x!==M(Y):!1)||V.every(P=>M(P.placement)===x?P.overflows[0]>0:!0)))return{data:{index:T,overflows:V},reset:{placement:Y}};let B=(X=V.filter($=>$.overflows[0]<=0).sort(($,P)=>$.overflows[1]-P.overflows[1])[0])==null?void 0:X.placement;if(!B)switch(f){case"bestFit":{var it;const $=(it=V.filter(P=>{if(C){const q=M(P.placement);return q===x||q==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(q=>q>0).reduce((q,_e)=>q+_e,0)]).sort((P,q)=>P[1]-q[1])[0])==null?void 0:it[0];$&&(B=$);break}case"initialPlacement":B=l;break}if(o!==B)return{reset:{placement:B}}}return{}}}},ee=new Set(["left","top"]);async function ie(t,e){const{placement:n,platform:i,elements:o}=t,s=await(i.isRTL==null?void 0:i.isRTL(o.floating)),r=_(n),l=J(n),c=M(n)==="y",a=ee.has(r)?-1:1,d=s&&c?-1:1,u=G(e,t);let{mainAxis:p,crossAxis:f,alignmentAxis:h}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof h=="number"&&(f=l==="end"?h*-1:h),c?{x:f*d,y:p*a}:{x:p*a,y:f*d}}const ne=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:o,y:s,placement:r,middlewareData:l}=e,c=await ie(e,t);return r===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:r}}}}},oe=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:o,platform:s}=e,{mainAxis:r=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x,y:v}=y;return{x,y:v}}},...a}=G(t,e),d={x:n,y:i},u=await s.detectOverflow(e,a),p=M(_(o)),f=bt(p);let h=d[f],g=d[p];if(r){const y=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=h+u[y],b=h-u[x];h=ut(v,h,b)}if(l){const y=p==="y"?"top":"left",x=p==="y"?"bottom":"right",v=g+u[y],b=g-u[x];g=ut(v,g,b)}const m=c.fn({...e,[f]:h,[p]:g});return{...m,data:{x:m.x-n,y:m.y-i,enabled:{[f]:r,[p]:l}}}}}};function rt(){return typeof window<"u"}function z(t){return Et(t)?(t.nodeName||"").toLowerCase():"#document"}function E(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function F(t){var e;return(e=(Et(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Et(t){return rt()?t instanceof Node||t instanceof E(t).Node:!1}function R(t){return rt()?t instanceof Element||t instanceof E(t).Element:!1}function I(t){return rt()?t instanceof HTMLElement||t instanceof E(t).HTMLElement:!1}function Ot(t){return!rt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof E(t).ShadowRoot}const se=new Set(["inline","contents"]);function Q(t){const{overflow:e,overflowX:n,overflowY:i,display:o}=L(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!se.has(o)}const re=new Set(["table","td","th"]);function le(t){return re.has(z(t))}const ce=[":popover-open",":modal"];function lt(t){return ce.some(e=>{try{return t.matches(e)}catch{return!1}})}const ae=["transform","translate","scale","rotate","perspective"],fe=["transform","translate","scale","rotate","perspective","filter"],ue=["paint","layout","strict","content"];function gt(t){const e=mt(),n=R(t)?L(t):t;return ae.some(i=>n[i]?n[i]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||fe.some(i=>(n.willChange||"").includes(i))||ue.some(i=>(n.contain||"").includes(i))}function de(t){let e=W(t);for(;I(e)&&!K(e);){if(gt(e))return e;if(lt(e))return null;e=W(e)}return null}function mt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const he=new Set(["html","body","#document"]);function K(t){return he.has(z(t))}function L(t){return E(t).getComputedStyle(t)}function ct(t){return R(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function W(t){if(z(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Ot(t)&&t.host||F(t);return Ot(e)?e.host:e}function Rt(t){const e=W(t);return K(e)?t.ownerDocument?t.ownerDocument.body:t.body:I(e)&&Q(e)?e:Rt(e)}function Lt(t,e,n){var i;e===void 0&&(e=[]);const o=Rt(t),s=o===((i=t.ownerDocument)==null?void 0:i.body),r=E(o);return s?(wt(r),e.concat(r,r.visualViewport||[],Q(o)?o:[],[])):e.concat(o,Lt(o,[]))}function wt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function kt(t){const e=L(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const o=I(t),s=o?t.offsetWidth:n,r=o?t.offsetHeight:i,l=nt(n)!==s||nt(i)!==r;return l&&(n=s,i=r),{width:n,height:i,$:l}}function $t(t){return R(t)?t:t.contextElement}function U(t){const e=$t(t);if(!I(e))return D(1);const n=e.getBoundingClientRect(),{width:i,height:o,$:s}=kt(e);let r=(s?nt(n.width):n.width)/i,l=(s?nt(n.height):n.height)/o;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const pe=D(0);function Pt(t){const e=E(t);return!mt()||!e.visualViewport?pe:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ge(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==E(t)?!1:e}function Z(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=$t(t);let r=D(1);e&&(i?R(i)&&(r=U(i)):r=U(t));const l=ge(s,n,i)?Pt(s):D(0);let c=(o.left+l.x)/r.x,a=(o.top+l.y)/r.y,d=o.width/r.x,u=o.height/r.y;if(s){const p=E(s),f=i&&R(i)?E(i):i;let h=p,g=wt(h);for(;g&&i&&f!==h;){const m=U(g),y=g.getBoundingClientRect(),x=L(g),v=y.left+(g.clientLeft+parseFloat(x.paddingLeft))*m.x,b=y.top+(g.clientTop+parseFloat(x.paddingTop))*m.y;c*=m.x,a*=m.y,d*=m.x,u*=m.y,c+=v,a+=b,h=E(g),g=wt(h)}}return st({width:d,height:u,x:c,y:a})}function at(t,e){const n=ct(t).scrollLeft;return e?e.left+n:Z(F(t)).left+n}function Dt(t,e){const n=t.getBoundingClientRect(),i=n.left+e.scrollLeft-at(t,n),o=n.top+e.scrollTop;return{x:i,y:o}}function me(t){let{elements:e,rect:n,offsetParent:i,strategy:o}=t;const s=o==="fixed",r=F(i),l=e?lt(e.floating):!1;if(i===r||l&&s)return n;let c={scrollLeft:0,scrollTop:0},a=D(1);const d=D(0),u=I(i);if((u||!u&&!s)&&((z(i)!=="body"||Q(r))&&(c=ct(i)),I(i))){const f=Z(i);a=U(i),d.x=f.x+i.clientLeft,d.y=f.y+i.clientTop}const p=r&&!u&&!s?Dt(r,c):D(0);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-c.scrollLeft*a.x+d.x+p.x,y:n.y*a.y-c.scrollTop*a.y+d.y+p.y}}function we(t){return Array.from(t.getClientRects())}function ye(t){const e=F(t),n=ct(t),i=t.ownerDocument.body,o=O(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=O(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let r=-n.scrollLeft+at(t);const l=-n.scrollTop;return L(i).direction==="rtl"&&(r+=O(e.clientWidth,i.clientWidth)-o),{width:o,height:s,x:r,y:l}}const It=25;function xe(t,e){const n=E(t),i=F(t),o=n.visualViewport;let s=i.clientWidth,r=i.clientHeight,l=0,c=0;if(o){s=o.width,r=o.height;const d=mt();(!d||d&&e==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const a=at(i);if(a<=0){const d=i.ownerDocument,u=d.body,p=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,h=Math.abs(i.clientWidth-u.clientWidth-f);h<=It&&(s-=h)}else a<=It&&(s+=a);return{width:s,height:r,x:l,y:c}}const ve=new Set(["absolute","fixed"]);function be(t,e){const n=Z(t,!0,e==="fixed"),i=n.top+t.clientTop,o=n.left+t.clientLeft,s=I(t)?U(t):D(1),r=t.clientWidth*s.x,l=t.clientHeight*s.y,c=o*s.x,a=i*s.y;return{width:r,height:l,x:c,y:a}}function Ft(t,e,n){let i;if(e==="viewport")i=xe(t,n);else if(e==="document")i=ye(F(t));else if(R(e))i=be(e,n);else{const o=Pt(t);i={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return st(i)}function Vt(t,e){const n=W(t);return n===e||!R(n)||K(n)?!1:L(n).position==="fixed"||Vt(n,e)}function Se(t,e){const n=e.get(t);if(n)return n;let i=Lt(t,[]).filter(l=>R(l)&&z(l)!=="body"),o=null;const s=L(t).position==="fixed";let r=s?W(t):t;for(;R(r)&&!K(r);){const l=L(r),c=gt(r);!c&&l.position==="fixed"&&(o=null),(s?!c&&!o:!c&&l.position==="static"&&!!o&&ve.has(o.position)||Q(r)&&!c&&Vt(t,r))?i=i.filter(d=>d!==r):o=l,r=W(r)}return e.set(t,i),i}function Ae(t){let{element:e,boundary:n,rootBoundary:i,strategy:o}=t;const r=[...n==="clippingAncestors"?lt(e)?[]:Se(e,this._c):[].concat(n),i],l=r[0],c=r.reduce((a,d)=>{const u=Ft(e,d,o);return a.top=O(u.top,a.top),a.right=S(u.right,a.right),a.bottom=S(u.bottom,a.bottom),a.left=O(u.left,a.left),a},Ft(e,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Te(t){const{width:e,height:n}=kt(t);return{width:e,height:n}}function Ce(t,e,n){const i=I(e),o=F(e),s=n==="fixed",r=Z(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const c=D(0);function a(){c.x=at(o)}if(i||!i&&!s)if((z(e)!=="body"||Q(o))&&(l=ct(e)),i){const f=Z(e,!0,s,e);c.x=f.x+e.clientLeft,c.y=f.y+e.clientTop}else o&&a();s&&!i&&o&&a();const d=o&&!i&&!s?Dt(o,l):D(0),u=r.left+l.scrollLeft-c.x-d.x,p=r.top+l.scrollTop-c.y-d.y;return{x:u,y:p,width:r.width,height:r.height}}function yt(t){return L(t).position==="static"}function Bt(t,e){if(!I(t)||L(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return F(t)===n&&(n=n.ownerDocument.body),n}function Nt(t,e){const n=E(t);if(lt(t))return n;if(!I(t)){let o=W(t);for(;o&&!K(o);){if(R(o)&&!yt(o))return o;o=W(o)}return n}let i=Bt(t,e);for(;i&&le(i)&&yt(i);)i=Bt(i,e);return i&&K(i)&&yt(i)&&!gt(i)?n:i||de(t)||n}const Ee=async function(t){const e=this.getOffsetParent||Nt,n=this.getDimensions,i=await n(t.floating);return{reference:Ce(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Oe(t){return L(t).direction==="rtl"}const Re={convertOffsetParentRelativeRectToViewportRelativeRect:me,getDocumentElement:F,getClippingRect:Ae,getOffsetParent:Nt,getElementRects:Ee,getClientRects:we,getDimensions:Te,getScale:U,isElement:R,isRTL:Oe},Le=ne,ke=oe,$e=te,Pe=Zt,De=(t,e,n)=>{const i=new Map,o={platform:Re,...n},s={...o.platform,_c:i};return Qt(t,e,{...o,platform:s})};function xt(t){try{return document.querySelector(t)}catch{return console.warn(`[Trailguide] Invalid selector: ${t}`),null}}function vt(t){const e=t.getBoundingClientRect(),n=window.getComputedStyle(t);return e.width>0&&e.height>0&&n.visibility!=="hidden"&&n.display!=="none"&&n.opacity!=="0"}function Mt(t){t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})}function ft(t,e,n){const i=document.createElement(t);return e&&(i.className=e),n&&n.appendChild(i),i}class Wt{constructor(e={}){N(this,"trail",null);N(this,"currentStepIndex",0);N(this,"isActive",!1);N(this,"options",{});N(this,"overlay",null);N(this,"tooltip",null);N(this,"arrowEl",null);N(this,"cleanupFns",[]);this.options=e}start(e){this.trail=e,this.currentStepIndex=0,this.isActive=!0,this.createOverlay(),this.showStep(),this.bindKeyboard()}stop(){this.isActive=!1,this.cleanup()}next(){!this.trail||!this.isActive||(this.currentStepIndex<this.trail.steps.length-1?(this.currentStepIndex++,this.showStep()):this.complete())}prev(){!this.trail||!this.isActive||this.currentStepIndex>0&&(this.currentStepIndex--,this.showStep())}skip(){var e,n;this.isActive=!1,this.cleanup(),(n=(e=this.options).onSkip)==null||n.call(e)}goToStep(e){!this.trail||!this.isActive||e>=0&&e<this.trail.steps.length&&(this.currentStepIndex=e,this.showStep())}complete(){var e,n;this.isActive=!1,this.cleanup(),(n=(e=this.options).onComplete)==null||n.call(e)}createOverlay(){var n,i,o;this.overlay=ft("div","trailguide-overlay"),document.body.appendChild(this.overlay);const e=ft("div","trailguide-spotlight",this.overlay);e.innerHTML=`
2
2
  <svg width="100%" height="100%">
3
3
  <defs>
4
4
  <mask id="trailguide-mask">
@@ -24,4 +24,4 @@
24
24
  </div>
25
25
  <div class="trailguide-tooltip-arrow"></div>
26
26
  </div>
27
- `,document.body.appendChild(this.tooltip),this.arrowEl=this.tooltip.querySelector(".trailguide-tooltip-arrow"),(i=this.tooltip.querySelector(".trailguide-tooltip-close"))==null||i.addEventListener("click",()=>this.skip()),(n=this.tooltip.querySelector(".trailguide-btn-prev"))==null||n.addEventListener("click",()=>this.prev()),(o=this.tooltip.querySelector(".trailguide-btn-next"))==null||o.addEventListener("click",()=>this.next())}showStep(){if(!this.trail||!this.overlay||!this.tooltip)return;const e=this.trail.steps[this.currentStepIndex];if(!e)return;const i=Nt(e.target);if(!i||!Mt(i)){console.warn(`[Trailguide] Target not found or not visible: ${e.target}`);return}Wt(i),setTimeout(()=>{var n,o;this.updateSpotlight(i),this.updateTooltip(e,i),(o=(n=this.options).onStepChange)==null||o.call(n,e,this.currentStepIndex)},100)}updateSpotlight(e){if(!this.overlay)return;const i=e.getBoundingClientRect(),n=8,o=this.overlay.querySelector(".trailguide-cutout");o&&(o.setAttribute("x",String(i.left-n)),o.setAttribute("y",String(i.top-n)),o.setAttribute("width",String(i.width+n*2)),o.setAttribute("height",String(i.height+n*2)));const s=this.overlay.querySelector(".trailguide-highlight");s&&(s.style.top=`${i.top-n}px`,s.style.left=`${i.left-n}px`,s.style.width=`${i.width+n*2}px`,s.style.height=`${i.height+n*2}px`);const r=()=>{if(!this.isActive)return;const l=e.getBoundingClientRect();o&&(o.setAttribute("x",String(l.left-n)),o.setAttribute("y",String(l.top-n)),o.setAttribute("width",String(l.width+n*2)),o.setAttribute("height",String(l.height+n*2))),s&&(s.style.top=`${l.top-n}px`,s.style.left=`${l.left-n}px`,s.style.width=`${l.width+n*2}px`,s.style.height=`${l.height+n*2}px`)};window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),this.cleanupFns.push(()=>{window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)})}async updateTooltip(e,i){if(!this.tooltip||!this.trail||!this.arrowEl)return;const n=this.currentStepIndex===0,o=this.currentStepIndex===this.trail.steps.length-1,s=this.tooltip.querySelector(".trailguide-tooltip-title"),r=this.tooltip.querySelector(".trailguide-tooltip-body"),l=this.tooltip.querySelector(".trailguide-tooltip-progress"),c=this.tooltip.querySelector(".trailguide-btn-prev"),a=this.tooltip.querySelector(".trailguide-btn-next");s&&(s.textContent=e.title),r&&(r.textContent=e.content),l&&(l.textContent=`${this.currentStepIndex+1} of ${this.trail.steps.length}`),c&&(c.style.display=n?"none":"block"),a&&(a.textContent=o?"Finish":"Next");const{x:d,y:u,middlewareData:p}=await $e(i,this.tooltip,{placement:e.placement,middleware:[Re(12),Pe(),ke({padding:8}),De({element:this.arrowEl})]});if(this.tooltip.style.left=`${d}px`,this.tooltip.style.top=`${u}px`,p.arrow&&this.arrowEl){const{x:f,y:h}=p.arrow;this.arrowEl.style.left=f!=null?`${f}px`:"",this.arrowEl.style.top=h!=null?`${h}px`:""}}bindKeyboard(){const e=i=>{if(this.isActive)switch(i.key){case"ArrowRight":case"Enter":this.next();break;case"ArrowLeft":this.prev();break;case"Escape":this.skip();break}};window.addEventListener("keydown",e),this.cleanupFns.push(()=>window.removeEventListener("keydown",e))}cleanup(){var e,i;this.cleanupFns.forEach(n=>n()),this.cleanupFns=[],(e=this.overlay)==null||e.remove(),(i=this.tooltip)==null||i.remove(),this.overlay=null,this.tooltip=null}}let A=null;function Fe(t,e){return A&&A.stop(),A=new Ht(e),A.start(t),A}function Be(){A==null||A.stop()}function Ve(){A==null||A.next()}function Ne(){A==null||A.prev()}function Me(){A==null||A.skip()}w.Trailguide=Ht,w.findElement=Nt,w.isElementVisible=Mt,w.next=Ve,w.prev=Ne,w.scrollToElement=Wt,w.skip=Me,w.start=Fe,w.stop=Be,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
27
+ `,document.body.appendChild(this.tooltip),this.arrowEl=this.tooltip.querySelector(".trailguide-tooltip-arrow"),(n=this.tooltip.querySelector(".trailguide-tooltip-close"))==null||n.addEventListener("click",()=>this.skip()),(i=this.tooltip.querySelector(".trailguide-btn-prev"))==null||i.addEventListener("click",()=>this.prev()),(o=this.tooltip.querySelector(".trailguide-btn-next"))==null||o.addEventListener("click",()=>this.next())}showStep(){if(!this.trail||!this.overlay||!this.tooltip)return;const e=this.trail.steps[this.currentStepIndex];if(!e)return;const n=xt(e.target);if(!n||!vt(n)){console.warn(`[Trailguide] Target not found or not visible: ${e.target}`);return}Mt(n),setTimeout(()=>{var i,o;this.updateSpotlight(n),this.updateTooltip(e,n),(o=(i=this.options).onStepChange)==null||o.call(i,e,this.currentStepIndex)},100)}updateSpotlight(e){if(!this.overlay)return;const n=e.getBoundingClientRect(),i=8,o=this.overlay.querySelector(".trailguide-cutout");o&&(o.setAttribute("x",String(n.left-i)),o.setAttribute("y",String(n.top-i)),o.setAttribute("width",String(n.width+i*2)),o.setAttribute("height",String(n.height+i*2)));const s=this.overlay.querySelector(".trailguide-highlight");s&&(s.style.top=`${n.top-i}px`,s.style.left=`${n.left-i}px`,s.style.width=`${n.width+i*2}px`,s.style.height=`${n.height+i*2}px`);const r=()=>{if(!this.isActive)return;const l=e.getBoundingClientRect();o&&(o.setAttribute("x",String(l.left-i)),o.setAttribute("y",String(l.top-i)),o.setAttribute("width",String(l.width+i*2)),o.setAttribute("height",String(l.height+i*2))),s&&(s.style.top=`${l.top-i}px`,s.style.left=`${l.left-i}px`,s.style.width=`${l.width+i*2}px`,s.style.height=`${l.height+i*2}px`)};window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),this.cleanupFns.push(()=>{window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)})}async updateTooltip(e,n){if(!this.tooltip||!this.trail||!this.arrowEl)return;const i=this.currentStepIndex===0,o=this.currentStepIndex===this.trail.steps.length-1,s=this.tooltip.querySelector(".trailguide-tooltip-title"),r=this.tooltip.querySelector(".trailguide-tooltip-body"),l=this.tooltip.querySelector(".trailguide-tooltip-progress"),c=this.tooltip.querySelector(".trailguide-btn-prev"),a=this.tooltip.querySelector(".trailguide-btn-next");s&&(s.textContent=e.title),r&&(r.textContent=e.content),l&&(l.textContent=`${this.currentStepIndex+1} of ${this.trail.steps.length}`),c&&(c.style.display=i?"none":"block"),a&&(a.textContent=o?"Finish":"Next");const{x:d,y:u,middlewareData:p}=await De(n,this.tooltip,{placement:e.placement,middleware:[Le(12),$e(),ke({padding:8}),Pe({element:this.arrowEl})]});if(this.tooltip.style.left=`${d}px`,this.tooltip.style.top=`${u}px`,p.arrow&&this.arrowEl){const{x:f,y:h}=p.arrow;this.arrowEl.style.left=f!=null?`${f}px`:"",this.arrowEl.style.top=h!=null?`${h}px`:""}}bindKeyboard(){const e=n=>{if(this.isActive)switch(n.key){case"ArrowRight":case"Enter":this.next();break;case"ArrowLeft":this.prev();break;case"Escape":this.skip();break}};window.addEventListener("keydown",e),this.cleanupFns.push(()=>window.removeEventListener("keydown",e))}cleanup(){var e,n;this.cleanupFns.forEach(i=>i()),this.cleanupFns=[],(e=this.overlay)==null||e.remove(),(n=this.tooltip)==null||n.remove(),this.overlay=null,this.tooltip=null}}let A=null;function Ie(t,e){return A&&A.stop(),A=new Wt(e),A.start(t),A}function Fe(){A==null||A.stop()}function Ve(){A==null||A.next()}function Be(){A==null||A.prev()}function Ne(){A==null||A.skip()}function Me(t){const e=[],n=[];return t.id||e.push({stepId:"",stepIndex:-1,type:"missing_required_field",message:'Trail is missing required "id" field'}),!t.steps||t.steps.length===0?(e.push({stepId:"",stepIndex:-1,type:"missing_required_field",message:"Trail has no steps"}),{valid:!1,errors:e,warnings:n}):(t.steps.forEach((i,o)=>{if(i.id||e.push({stepId:`step-${o}`,stepIndex:o,type:"missing_required_field",message:`Step ${o+1} is missing required "id" field`}),!i.target){e.push({stepId:i.id||`step-${o}`,stepIndex:o,type:"missing_required_field",message:`Step ${o+1} is missing required "target" field`});return}const s=xt(i.target);s?vt(s)||n.push({stepId:i.id,stepIndex:o,type:"hidden_target",message:`Step ${o+1} ("${i.title}"): Target element exists but is hidden`,selector:i.target}):e.push({stepId:i.id,stepIndex:o,type:"missing_target",message:`Step ${o+1} ("${i.title}"): Target element not found`,selector:i.target}),i.target&&We(i.target)&&n.push({stepId:i.id,stepIndex:o,type:"unstable_selector",message:`Step ${o+1}: Consider using data-trail-id for more stable targeting`,selector:i.target})}),{valid:e.length===0,errors:e,warnings:n})}function We(t){return t.startsWith("#")||t.includes("[data-")?!1:!!(t.includes(":nth-child")||t.includes(":nth-of-type")||/^\.[a-z]+-[a-z0-9]+$/i.test(t))}function qe(t){if(t.valid&&t.warnings.length===0){console.log("%c✓ Trail validation passed","color: green; font-weight: bold");return}t.errors.length>0&&(console.group("%c✗ Trail validation errors","color: red; font-weight: bold"),t.errors.forEach(e=>{console.error(`Step ${e.stepIndex+1}: ${e.message}`),e.selector&&console.error(` Selector: ${e.selector}`)}),console.groupEnd()),t.warnings.length>0&&(console.group("%c⚠ Trail validation warnings","color: orange; font-weight: bold"),t.warnings.forEach(e=>{console.warn(`Step ${e.stepIndex+1}: ${e.message}`),e.selector&&console.warn(` Selector: ${e.selector}`)}),console.groupEnd())}w.Trailguide=Wt,w.findElement=xt,w.isElementVisible=vt,w.logValidationResults=qe,w.next=Ve,w.prev=Be,w.scrollToElement=Mt,w.skip=Ne,w.start=Ie,w.stop=Fe,w.validateTrail=Me,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,42 @@
1
+ import { Trail } from './types';
2
+
3
+ export interface ValidationResult {
4
+ valid: boolean;
5
+ errors: ValidationError[];
6
+ warnings: ValidationWarning[];
7
+ }
8
+ export interface ValidationError {
9
+ stepId: string;
10
+ stepIndex: number;
11
+ type: 'missing_target' | 'invalid_selector' | 'missing_required_field';
12
+ message: string;
13
+ selector?: string;
14
+ }
15
+ export interface ValidationWarning {
16
+ stepId: string;
17
+ stepIndex: number;
18
+ type: 'hidden_target' | 'unstable_selector';
19
+ message: string;
20
+ selector?: string;
21
+ }
22
+ /**
23
+ * Validates a trail and checks if all target selectors exist in the DOM.
24
+ * Run this in development to catch broken selectors before they reach users.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { validateTrail } from '@trailguide/core';
29
+ *
30
+ * const result = validateTrail(myTrail);
31
+ * if (!result.valid) {
32
+ * console.error('Trail validation failed:', result.errors);
33
+ * }
34
+ * ```
35
+ */
36
+ export declare function validateTrail(trail: Trail): ValidationResult;
37
+ /**
38
+ * Logs validation results to the console with formatting.
39
+ * Useful for development debugging.
40
+ */
41
+ export declare function logValidationResults(result: ValidationResult): void;
42
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,GAAG,wBAAwB,CAAC;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,eAAe,GAAG,mBAAmB,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,gBAAgB,CAkF5D;AAkBD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CA2BnE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trailguide/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Framework-agnostic product tours. Tutorials as code for any web app.",
5
5
  "type": "module",
6
6
  "main": "./dist/trailguide.js",