@whenessel/seql-js 1.1.0 → 1.2.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.
package/dist/seql-js.js CHANGED
@@ -1,9 +1,9 @@
1
- const ee = "1.0", se = 10, L = {
1
+ const se = "1.0", re = 10, _ = {
2
2
  ANCHOR: 0.4,
3
3
  PATH: 0.3,
4
4
  TARGET: 0.2,
5
5
  UNIQUENESS: 0.1
6
- }, I = {
6
+ }, N = {
7
7
  SEMANTIC_TAG: 0.5,
8
8
  ROLE: 0.3,
9
9
  ARIA_LABEL: 0.1,
@@ -12,9 +12,9 @@ const ee = "1.0", se = 10, L = {
12
12
  DEPTH_PENALTY_THRESHOLD: 5,
13
13
  DEPTH_PENALTY_FACTOR: 0.05,
14
14
  DEGRADED_SCORE: 0.3
15
- }, ct = {
15
+ }, lt = {
16
16
  MIN_CONFIDENCE_FOR_SKIP: 0.7
17
- }, Y = [
17
+ }, X = [
18
18
  "form",
19
19
  "main",
20
20
  "nav",
@@ -22,7 +22,7 @@ const ee = "1.0", se = 10, L = {
22
22
  "article",
23
23
  "footer",
24
24
  "header"
25
- ], X = [
25
+ ], K = [
26
26
  "form",
27
27
  "navigation",
28
28
  "main",
@@ -31,7 +31,7 @@ const ee = "1.0", se = 10, L = {
31
31
  "complementary",
32
32
  "banner",
33
33
  "search"
34
- ], lt = [
34
+ ], ht = [
35
35
  // HTML5 Semantic
36
36
  "article",
37
37
  "aside",
@@ -108,7 +108,7 @@ const ee = "1.0", se = 10, L = {
108
108
  "g",
109
109
  "text",
110
110
  "use"
111
- ], ht = [
111
+ ], ut = [
112
112
  "rect",
113
113
  "path",
114
114
  "circle",
@@ -122,7 +122,7 @@ const ee = "1.0", se = 10, L = {
122
122
  "defs",
123
123
  "clipPath",
124
124
  "mask"
125
- ], re = [
125
+ ], ne = [
126
126
  "aria-label",
127
127
  "aria-labelledby",
128
128
  "aria-describedby",
@@ -135,7 +135,7 @@ const ee = "1.0", se = 10, L = {
135
135
  "title",
136
136
  "placeholder",
137
137
  "alt"
138
- ], w = {
138
+ ], E = {
139
139
  // Test attributes (highest priority)
140
140
  "data-testid": 100,
141
141
  "data-qa": 99,
@@ -162,7 +162,7 @@ const ee = "1.0", se = 10, L = {
162
162
  "data-*": 30,
163
163
  // Any aria-* attribute (if not above)
164
164
  "aria-*": 25
165
- }, et = /* @__PURE__ */ new Set([
165
+ }, B = /* @__PURE__ */ new Set([
166
166
  "id",
167
167
  // handled separately
168
168
  "class",
@@ -174,14 +174,14 @@ const ee = "1.0", se = 10, L = {
174
174
  "tabindex",
175
175
  // can change
176
176
  "contenteditable"
177
- ]), ut = {
177
+ ]), dt = {
178
178
  maxPathDepth: 10,
179
179
  enableSvgFingerprint: !0,
180
180
  confidenceThreshold: 0.1,
181
181
  fallbackToBody: !0,
182
182
  includeUtilityClasses: !1,
183
183
  source: "dom-dsl"
184
- }, dt = {
184
+ }, ft = {
185
185
  strictMode: !1,
186
186
  enableFallback: !0,
187
187
  maxCandidates: 20
@@ -189,7 +189,7 @@ const ee = "1.0", se = 10, L = {
189
189
  function D(n) {
190
190
  return !!(/^[a-z]+-\d+$/i.test(n) || /^[a-z]+(-[a-z]+)+-\d+$/i.test(n) || /^[a-z]+(_[a-z]+)*_\d+$/i.test(n) || /^\d+$/.test(n) || /^:[a-z0-9]+:$/i.test(n) || /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(n) || /^[a-z]{1,3}[A-Za-z0-9]{8,}$/.test(n) && (/\d/.test(n) || /[A-Z]/.test(n)) || /^radix-/.test(n) || /^mui-\d+$/.test(n));
191
191
  }
192
- const B = /* @__PURE__ */ new Set([
192
+ const G = /* @__PURE__ */ new Set([
193
193
  "aria-labelledby",
194
194
  "aria-describedby",
195
195
  "aria-controls",
@@ -203,10 +203,10 @@ const B = /* @__PURE__ */ new Set([
203
203
  "aria-errormessage",
204
204
  "aria-flowto"
205
205
  ]);
206
- function G(n) {
206
+ function V(n) {
207
207
  return n.trim().split(/\s+/).some((e) => D(e));
208
208
  }
209
- class ft {
209
+ class gt {
210
210
  constructor(t, e) {
211
211
  this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
212
212
  }
@@ -214,33 +214,72 @@ class ft {
214
214
  * Finds the best anchor element for the target
215
215
  * @param target - Target element to find anchor for
216
216
  * @returns Anchor result or null if not found
217
+ * @remarks
218
+ * Special handling for root elements (html, head, body):
219
+ * - For html: returns html itself as anchor
220
+ * - For head or elements inside head: returns html as anchor
221
+ * - For body: returns html as anchor
217
222
  */
218
223
  findAnchor(t) {
219
224
  if (this.cache) {
220
- const i = this.cache.getAnchor(t);
221
- if (i !== void 0)
222
- return i;
225
+ const c = this.cache.getAnchor(t);
226
+ if (c !== void 0)
227
+ return c;
228
+ }
229
+ const e = t.tagName.toLowerCase(), s = t.ownerDocument;
230
+ if (e === "html") {
231
+ const c = {
232
+ element: t,
233
+ score: 1,
234
+ tier: "A",
235
+ depth: 0
236
+ };
237
+ return this.cacheResult(t, c), c;
238
+ }
239
+ if (e === "head" || this.isInsideHead(t)) {
240
+ const c = s?.documentElement;
241
+ if (c) {
242
+ const u = {
243
+ element: c,
244
+ score: 1,
245
+ tier: "A",
246
+ depth: 0
247
+ };
248
+ return this.cacheResult(t, u), u;
249
+ }
223
250
  }
224
- let e = t.parentElement, s = 0, r = null;
225
- for (; e && s < this.maxDepth; ) {
226
- if (e.tagName.toLowerCase() === "body")
227
- return r || {
228
- element: e,
229
- score: I.DEGRADED_SCORE,
251
+ if (e === "body") {
252
+ const c = s?.documentElement;
253
+ if (c) {
254
+ const u = {
255
+ element: c,
256
+ score: 1,
257
+ tier: "A",
258
+ depth: 0
259
+ };
260
+ return this.cacheResult(t, u), u;
261
+ }
262
+ }
263
+ let r = t.parentElement, a = 0, i = null;
264
+ for (; r && a < this.maxDepth; ) {
265
+ if (r.tagName.toLowerCase() === "body")
266
+ return i || {
267
+ element: r,
268
+ score: N.DEGRADED_SCORE,
230
269
  tier: "C",
231
- depth: s
270
+ depth: a
232
271
  };
233
- const i = this.scoreAnchor(e);
234
- if (i > 0) {
235
- const o = this.applyDepthPenalty(i, s), l = this.getTier(e), u = { element: e, score: o, tier: l, depth: s };
236
- if (l === "A")
237
- return u;
238
- (!r || o > r.score) && (r = u);
272
+ const c = this.scoreAnchor(r);
273
+ if (c > 0) {
274
+ const u = this.applyDepthPenalty(c, a), d = this.getTier(r), l = { element: r, score: u, tier: d, depth: a };
275
+ if (d === "A")
276
+ return l;
277
+ (!i || u > i.score) && (i = l);
239
278
  }
240
- e = e.parentElement, s++;
279
+ r = r.parentElement, a++;
241
280
  }
242
- const a = r;
243
- return this.cache && this.cache.setAnchor(t, a), a;
281
+ const o = i;
282
+ return this.cache && this.cache.setAnchor(t, o), o;
244
283
  }
245
284
  /**
246
285
  * Scores an element as anchor candidate (without depth penalty)
@@ -250,20 +289,20 @@ class ft {
250
289
  scoreAnchor(t) {
251
290
  let e = 0;
252
291
  const s = t.tagName.toLowerCase();
253
- Y.includes(s) && (e += I.SEMANTIC_TAG);
292
+ X.includes(s) && (e += N.SEMANTIC_TAG);
254
293
  const r = t.getAttribute("role");
255
- r && X.includes(r) && (e += I.ROLE), (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) && (e += I.ARIA_LABEL);
294
+ r && K.includes(r) && (e += N.ROLE), (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) && (e += N.ARIA_LABEL);
256
295
  const a = t.id;
257
- return a && !D(a) && (e += I.STABLE_ID), (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test")) && (e += I.TEST_MARKER), Math.min(e, 1);
296
+ return a && !D(a) && (e += N.STABLE_ID), (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test")) && (e += N.TEST_MARKER), Math.min(e, 1);
258
297
  }
259
298
  /**
260
299
  * Applies depth penalty to score
261
300
  * Following SPECIFICATION.md §7: depthPenalty = (depth - threshold) * factor
262
301
  */
263
302
  applyDepthPenalty(t, e) {
264
- if (e <= I.DEPTH_PENALTY_THRESHOLD)
303
+ if (e <= N.DEPTH_PENALTY_THRESHOLD)
265
304
  return t;
266
- const s = (e - I.DEPTH_PENALTY_THRESHOLD) * I.DEPTH_PENALTY_FACTOR;
305
+ const s = (e - N.DEPTH_PENALTY_THRESHOLD) * N.DEPTH_PENALTY_FACTOR;
267
306
  return Math.max(0, t - s);
268
307
  }
269
308
  /**
@@ -271,13 +310,43 @@ class ft {
271
310
  */
272
311
  getTier(t) {
273
312
  const e = t.tagName.toLowerCase();
274
- if (Y.includes(e))
313
+ if (X.includes(e))
275
314
  return "A";
276
315
  const s = t.getAttribute("role");
277
- return s && X.includes(s) ? "B" : "C";
316
+ return s && K.includes(s) ? "B" : "C";
317
+ }
318
+ /**
319
+ * Checks if element is inside <head> section.
320
+ * Stops at <body> to avoid false positives.
321
+ * @param element - Element to check
322
+ * @returns True if element is inside head, false otherwise
323
+ * @remarks
324
+ * Traverses up the DOM tree until finding head or body.
325
+ * Returns false if body is encountered first.
326
+ * @example
327
+ * const meta = document.querySelector('meta');
328
+ * if (isInsideHead(meta)) { ... }
329
+ */
330
+ isInsideHead(t) {
331
+ let e = t.parentElement;
332
+ for (; e; ) {
333
+ const s = e.tagName.toLowerCase();
334
+ if (s === "head") return !0;
335
+ if (s === "body") return !1;
336
+ e = e.parentElement;
337
+ }
338
+ return !1;
339
+ }
340
+ /**
341
+ * Caches the anchor result for the target element
342
+ * @param target - Target element
343
+ * @param result - Anchor result to cache
344
+ */
345
+ cacheResult(t, e) {
346
+ this.cache && this.cache.setAnchor(t, e);
278
347
  }
279
348
  }
280
- const gt = [
349
+ const mt = [
281
350
  // CSS-in-JS
282
351
  /^css-[a-z0-9]+$/i,
283
352
  /^sc-[a-z0-9]+-\d+$/i,
@@ -403,7 +472,7 @@ const gt = [
403
472
  /^clearfix$/,
404
473
  /^pull-(left|right)$/,
405
474
  /^float-(left|right|none)$/
406
- ], mt = [
475
+ ], bt = [
407
476
  // === Navigation ===
408
477
  /^(nav|menu|header|footer|sidebar|topbar|navbar|breadcrumb)/,
409
478
  /(navigation|dropdown|megamenu)$/,
@@ -430,41 +499,41 @@ const gt = [
430
499
  // === Status ===
431
500
  /^(loading|pending|complete|failed|draft|published)/
432
501
  ];
433
- function k(n) {
434
- return gt.some((t) => t.test(n));
502
+ function L(n) {
503
+ return mt.some((t) => t.test(n));
435
504
  }
436
- function q(n) {
505
+ function k(n) {
437
506
  return n.length <= 2 || /^\d/.test(n) ? !0 : pt.some((t) => t.test(n));
438
507
  }
439
- function bt(n) {
440
- return k(n) || q(n) ? !1 : mt.some((t) => t.test(n));
441
- }
442
508
  function St(n) {
443
- return !k(n) && !q(n);
444
- }
445
- function N(n) {
446
- return n.filter((t) => St(t));
509
+ return L(n) || k(n) ? !1 : bt.some((t) => t.test(n));
447
510
  }
448
511
  function yt(n) {
449
- if (k(n) || q(n))
512
+ return !L(n) && !k(n);
513
+ }
514
+ function M(n) {
515
+ return n.filter((t) => yt(t));
516
+ }
517
+ function At(n) {
518
+ if (L(n) || k(n))
450
519
  return 0;
451
520
  let t = 0.5;
452
- return bt(n) && (t = 0.8), n.length < 3 ? t *= 0.3 : n.length < 5 && (t *= 0.6), /\d/.test(n) && (t *= 0.7), Math.min(t, 1);
521
+ return St(n) && (t = 0.8), n.length < 3 ? t *= 0.3 : n.length < 5 && (t *= 0.6), /\d/.test(n) && (t *= 0.7), Math.min(t, 1);
453
522
  }
454
- function At(n) {
523
+ function xt(n) {
455
524
  const t = [], e = [];
456
525
  for (const s of n)
457
- q(s) || k(s) ? e.push(s) : t.push(s);
526
+ k(s) || L(s) ? e.push(s) : t.push(s);
458
527
  return { semantic: t, utility: e };
459
528
  }
460
- function K(n) {
461
- return q(n) || k(n);
529
+ function J(n) {
530
+ return k(n) || L(n);
462
531
  }
463
- function ne(n) {
464
- return yt(n);
532
+ function ae(n) {
533
+ return At(n);
465
534
  }
466
- const J = (n) => n.replace(/([#:.[\]@])/g, "\\$1");
467
- class xt {
535
+ const tt = (n) => n.replace(/([#:.[\]@])/g, "\\$1");
536
+ class Ct {
468
537
  constructor(t, e) {
469
538
  this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
470
539
  }
@@ -474,37 +543,49 @@ class xt {
474
543
  * @param target - Target element (end)
475
544
  * @param extractor - Semantic extractor instance
476
545
  * @returns Path build result with nodes and degradation info
546
+ * @remarks
547
+ * Special handling for root elements:
548
+ * - If anchor is html and target is head/body: returns empty path
549
+ * - If anchor is html and target is inside head: builds path through head
477
550
  */
478
551
  buildPath(t, e, s) {
479
- const r = [];
480
- let a = e.parentElement;
481
- for (; a && a !== t && r.length < this.maxDepth; )
482
- r.unshift(a), a = a.parentElement;
483
- const i = r.length >= this.maxDepth && a !== t;
484
- let o = this.filterNoise(r);
485
- return o = this.ensureUniqueness(
486
- r,
487
- o,
488
- t,
489
- e,
490
- s
491
- ), {
492
- path: o.map((u) => {
493
- const d = u.parentElement;
494
- let c;
495
- if (d) {
496
- const g = Array.from(d.children).indexOf(u);
497
- g !== -1 && (c = g + 1);
552
+ const r = t.tagName.toLowerCase(), a = e.tagName.toLowerCase();
553
+ if (r === "html" && (a === "head" || a === "body"))
554
+ return {
555
+ path: [],
556
+ degraded: !1
557
+ };
558
+ if (r === "html" && this.isInsideHead(e))
559
+ return this.buildHeadPath(t, e, s);
560
+ const i = [];
561
+ let o = e.parentElement;
562
+ for (; o && o !== t && i.length < this.maxDepth; )
563
+ i.unshift(o), o = o.parentElement;
564
+ const c = i.length >= this.maxDepth && o !== t;
565
+ if (!c && o !== t)
566
+ return console.warn("[PathBuilder] Target is not a descendant of anchor"), {
567
+ path: [],
568
+ degraded: !0,
569
+ degradationReason: "target-not-descendant-of-anchor"
570
+ };
571
+ let u = this.filterNoise(i);
572
+ return u = this.ensureUniqueness(i, u, t, e, s), {
573
+ path: u.map((l) => {
574
+ const h = l.parentElement;
575
+ let g;
576
+ if (h) {
577
+ const m = Array.from(h.children).indexOf(l);
578
+ m !== -1 && (g = m + 1);
498
579
  }
499
580
  return {
500
- tag: u.tagName.toLowerCase(),
501
- semantics: s.extract(u),
502
- score: s.scoreElement(u),
503
- nthChild: c
581
+ tag: l.tagName.toLowerCase(),
582
+ semantics: s.extract(l),
583
+ score: s.scoreElement(l),
584
+ nthChild: g
504
585
  };
505
586
  }),
506
- degraded: i,
507
- degradationReason: i ? "path-depth-overflow" : void 0
587
+ degraded: c,
588
+ degradationReason: c ? "path-depth-overflow" : void 0
508
589
  };
509
590
  }
510
591
  /**
@@ -522,29 +603,29 @@ class xt {
522
603
  try {
523
604
  const o = r.ownerDocument;
524
605
  if (!o) return e;
525
- let l;
606
+ let c;
526
607
  if (this.cache) {
527
608
  const d = this.cache.getSelectorResults(i);
528
- d !== void 0 ? l = d : (l = Array.from(o.querySelectorAll(i)), this.cache.setSelectorResults(i, l));
609
+ d !== void 0 ? c = d : (c = Array.from(o.querySelectorAll(i)), this.cache.setSelectorResults(i, c));
529
610
  } else
530
- l = o.querySelectorAll(i);
531
- if (l.length <= 1)
611
+ c = o.querySelectorAll(i);
612
+ if (c.length <= 1)
532
613
  return e;
533
614
  const u = t.filter((d) => !e.includes(d));
534
615
  for (const d of u) {
535
- if (a.scoreElement(d) < ct.MIN_CONFIDENCE_FOR_SKIP)
616
+ if (a.scoreElement(d) < lt.MIN_CONFIDENCE_FOR_SKIP)
536
617
  continue;
537
618
  const h = this.insertNodeInOrder(e, d, t), g = this.buildTestSelector(s, h, r);
538
619
  try {
539
620
  let f;
540
621
  if (this.cache) {
541
- const p = this.cache.getSelectorResults(g);
542
- p !== void 0 ? f = p : (f = Array.from(o.querySelectorAll(g)), this.cache.setSelectorResults(g, f));
622
+ const m = this.cache.getSelectorResults(g);
623
+ m !== void 0 ? f = m : (f = Array.from(o.querySelectorAll(g)), this.cache.setSelectorResults(g, f));
543
624
  } else
544
625
  f = o.querySelectorAll(g);
545
626
  if (f.length === 1)
546
627
  return h;
547
- f.length < l.length && (e = h);
628
+ f.length < c.length && (e = h);
548
629
  } catch {
549
630
  }
550
631
  }
@@ -578,9 +659,9 @@ class xt {
578
659
  */
579
660
  elementToSelector(t) {
580
661
  let e = t.tagName.toLowerCase();
581
- t.id && !D(t.id) && (e += `#${J(t.id)}`);
662
+ t.id && !D(t.id) && (e += `#${tt(t.id)}`);
582
663
  for (const s of Array.from(t.classList))
583
- K(s) || (e += `.${J(s)}`);
664
+ J(s) || (e += `.${tt(s)}`);
584
665
  return e;
585
666
  }
586
667
  /**
@@ -594,7 +675,7 @@ class xt {
594
675
  */
595
676
  shouldInclude(t) {
596
677
  const e = t.tagName.toLowerCase();
597
- return lt.includes(e) ? !0 : e === "div" || e === "span" ? this.hasSemanticFeatures(t) : !1;
678
+ return ht.includes(e) ? !0 : e === "div" || e === "span" ? this.hasSemanticFeatures(t) : !1;
598
679
  }
599
680
  /**
600
681
  * Checks if element has meaningful semantic features
@@ -605,22 +686,83 @@ class xt {
605
686
  if (s.name.startsWith("aria-")) return !0;
606
687
  if (t.classList.length > 0) {
607
688
  for (const s of Array.from(t.classList))
608
- if (!K(s)) return !0;
689
+ if (!J(s)) return !0;
609
690
  }
610
691
  if (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test"))
611
692
  return !0;
612
693
  const e = t.id;
613
694
  return !!(e && !D(e));
614
695
  }
696
+ /**
697
+ * Checks if element is inside <head> section.
698
+ * Stops at <body> to avoid false positives.
699
+ * @param element - Element to check
700
+ * @returns True if element is inside head, false otherwise
701
+ * @remarks
702
+ * Traverses up the DOM tree until finding head or body.
703
+ * Returns false if body is encountered first.
704
+ */
705
+ isInsideHead(t) {
706
+ let e = t.parentElement;
707
+ for (; e; ) {
708
+ const s = e.tagName.toLowerCase();
709
+ if (s === "head") return !0;
710
+ if (s === "body") return !1;
711
+ e = e.parentElement;
712
+ }
713
+ return !1;
714
+ }
715
+ /**
716
+ * Builds path from html to target through head element.
717
+ * Always includes head in the path for correct CSS selector generation.
718
+ * @param htmlElement - The html element (anchor)
719
+ * @param target - Target element inside head
720
+ * @param extractor - Semantic extractor instance
721
+ * @returns Path build result with head and intermediate nodes
722
+ * @example
723
+ * For <html><head><meta name="description"></head></html>
724
+ * Returns path: [head]
725
+ */
726
+ buildHeadPath(t, e, s) {
727
+ const r = [];
728
+ let a = e.parentElement;
729
+ for (; a && a !== t; )
730
+ r.unshift(a), a = a.parentElement;
731
+ return a !== t ? {
732
+ path: [],
733
+ degraded: !0,
734
+ degradationReason: "target-not-descendant-of-html"
735
+ } : r.findIndex((c) => c.tagName.toLowerCase() === "head") === -1 ? {
736
+ path: [],
737
+ degraded: !0,
738
+ degradationReason: "head-not-found-in-path"
739
+ } : {
740
+ path: r.map((c) => {
741
+ const u = c.parentElement;
742
+ let d;
743
+ if (u) {
744
+ const h = Array.from(u.children).indexOf(c);
745
+ h !== -1 && (d = h + 1);
746
+ }
747
+ return {
748
+ tag: c.tagName.toLowerCase(),
749
+ semantics: s.extract(c),
750
+ score: s.scoreElement(c),
751
+ nthChild: d
752
+ };
753
+ }),
754
+ degraded: !1
755
+ };
756
+ }
615
757
  }
616
- function V(n) {
758
+ function Q(n) {
617
759
  return n ? n.trim().replace(/[\n\t\r]/g, " ").replace(/\s+/g, " ") : "";
618
760
  }
619
- const Ct = {
761
+ const Tt = {
620
762
  preserveQueryForAbsolute: !0,
621
763
  removeDynamicHashes: !0
622
764
  };
623
- function Tt(n) {
765
+ function Et(n) {
624
766
  return n ? [
625
767
  /\d{5,}/,
626
768
  // 5+ digits
@@ -634,20 +776,18 @@ function Tt(n) {
634
776
  // UUID-like
635
777
  ].some((e) => e.test(n)) : !1;
636
778
  }
637
- function Et(n, t) {
779
+ function wt(n, t) {
638
780
  if (!n) return n;
639
- const e = n.startsWith("http://") || n.startsWith("https://");
640
- let [s, r] = n.split("#");
641
- const [a, i] = s.split("?");
781
+ const e = n.startsWith("http://") || n.startsWith("https://"), [s, r] = n.split("#"), [a, i] = s.split("?");
642
782
  let o = a;
643
- return e && t.preserveQueryForAbsolute && i && (o += `?${i}`), r && (t.removeDynamicHashes && Tt(r) || (o += `#${r}`)), o;
783
+ return e && t.preserveQueryForAbsolute && i && (o += `?${i}`), r && (t.removeDynamicHashes && Et(r) || (o += `#${r}`)), o;
644
784
  }
645
- function _(n, t, e = {}) {
785
+ function q(n, t, e = {}) {
646
786
  if (!t) return t;
647
- const s = { ...Ct, ...e };
648
- return n === "href" || n === "src" ? Et(t, s) : t;
787
+ const s = { ...Tt, ...e };
788
+ return n === "href" || n === "src" ? wt(t, s) : t;
649
789
  }
650
- const wt = [
790
+ const vt = [
651
791
  "role",
652
792
  "aria-label",
653
793
  "aria-labelledby",
@@ -658,7 +798,7 @@ const wt = [
658
798
  "aria-posinset",
659
799
  "aria-setsize",
660
800
  "aria-haspopup"
661
- ], vt = [
801
+ ], $t = [
662
802
  "aria-selected",
663
803
  "aria-checked",
664
804
  "aria-pressed",
@@ -671,7 +811,7 @@ const wt = [
671
811
  "aria-grabbed",
672
812
  "aria-live",
673
813
  "aria-atomic"
674
- ], $t = [
814
+ ], It = [
675
815
  "data-state",
676
816
  "data-active",
677
817
  "data-inactive",
@@ -690,7 +830,7 @@ const wt = [
690
830
  "data-hover",
691
831
  "data-orientation",
692
832
  "data-theme"
693
- ], Mt = [
833
+ ], Nt = [
694
834
  "data-radix-",
695
835
  "data-headlessui-",
696
836
  "data-reach-",
@@ -698,7 +838,7 @@ const wt = [
698
838
  "data-chakra-",
699
839
  "data-mantine-",
700
840
  "data-tw-"
701
- ], It = [
841
+ ], Rt = [
702
842
  "data-testid",
703
843
  "data-test-id",
704
844
  "data-test",
@@ -710,7 +850,7 @@ const wt = [
710
850
  "data-entity-id",
711
851
  "data-product-id",
712
852
  "data-user-id"
713
- ], Rt = [
853
+ ], Mt = [
714
854
  "id",
715
855
  "name",
716
856
  "type",
@@ -719,7 +859,7 @@ const wt = [
719
859
  "for",
720
860
  "alt",
721
861
  "href"
722
- ], Nt = [
862
+ ], Dt = [
723
863
  "disabled",
724
864
  "checked",
725
865
  "selected",
@@ -727,17 +867,17 @@ const wt = [
727
867
  "readonly",
728
868
  "required",
729
869
  "value"
730
- ], Dt = [
870
+ ], Ht = [
731
871
  /^radix-/,
732
872
  /^headlessui-/,
733
873
  /^mui-/,
734
874
  /:\w+:/
735
875
  // matches :ru:, :r1:, etc.
736
876
  ];
737
- function Ht(n, t) {
738
- return wt.includes(n) ? !0 : vt.includes(n) || $t.includes(n) || Mt.some((e) => n.startsWith(e)) ? !1 : It.includes(n) || n.startsWith("data-") && n.endsWith("-id") ? !0 : n === "id" ? !Dt.some((e) => e.test(t)) : Rt.includes(n) ? !0 : Nt.includes(n) ? !1 : !!n.startsWith("data-");
877
+ function Pt(n, t) {
878
+ return vt.includes(n) ? !0 : $t.includes(n) || It.includes(n) || Nt.some((e) => n.startsWith(e)) ? !1 : Rt.includes(n) || n.startsWith("data-") && n.endsWith("-id") ? !0 : n === "id" ? !Ht.some((e) => e.test(t)) : Mt.includes(n) ? !0 : Dt.includes(n) ? !1 : !!n.startsWith("data-");
739
879
  }
740
- class Pt {
880
+ class et {
741
881
  constructor(t, e) {
742
882
  this.includeUtilityClasses = t.includeUtilityClasses ?? !1, this.cache = e;
743
883
  }
@@ -758,7 +898,7 @@ class Pt {
758
898
  if (this.includeUtilityClasses)
759
899
  e.classes = i;
760
900
  else {
761
- const { semantic: o } = At(i);
901
+ const { semantic: o } = xt(i);
762
902
  o.length > 0 && (e.classes = o);
763
903
  }
764
904
  }
@@ -787,7 +927,7 @@ class Pt {
787
927
  * @returns True if should be ignored
788
928
  */
789
929
  shouldIgnoreAttribute(t) {
790
- return !!(et.has(t) || t.startsWith("on") || t.startsWith("ng-") || t.startsWith("_ng") || t.startsWith("data-reactid") || t.startsWith("data-react") || t.startsWith("data-v-"));
930
+ return !!(B.has(t) || t.startsWith("on") || t.startsWith("ng-") || t.startsWith("_ng") || t.startsWith("data-reactid") || t.startsWith("data-react") || t.startsWith("data-v-"));
791
931
  }
792
932
  /**
793
933
  * Gets attribute priority
@@ -795,7 +935,7 @@ class Pt {
795
935
  * @returns Priority number (higher = more priority)
796
936
  */
797
937
  getAttributePriority(t) {
798
- return w[t] !== void 0 ? w[t] : t.startsWith("data-") ? w["data-*"] : t.startsWith("aria-") ? w["aria-*"] : 0;
938
+ return E[t] !== void 0 ? E[t] : t.startsWith("data-") ? E["data-*"] : t.startsWith("aria-") ? E["aria-*"] : 0;
799
939
  }
800
940
  /**
801
941
  * Checks if attribute value is dynamic (should be ignored)
@@ -822,8 +962,8 @@ class Pt {
822
962
  const e = {};
823
963
  for (const s of Array.from(t.attributes)) {
824
964
  const r = s.name;
825
- if (this.shouldIgnoreAttribute(r) || !Ht(r, s.value) || B.has(r) && G(s.value) || this.getAttributePriority(r) === 0) continue;
826
- const i = r === "href" || r === "src" ? _(r, s.value) : s.value;
965
+ if (this.shouldIgnoreAttribute(r) || !Pt(r, s.value) || G.has(r) && V(s.value) || this.getAttributePriority(r) === 0) continue;
966
+ const i = r === "href" || r === "src" ? q(r, s.value) : s.value;
827
967
  !i || i.trim() === "" || this.isDynamicValue(i) || (e[r] = i);
828
968
  }
829
969
  return e;
@@ -834,7 +974,7 @@ class Pt {
834
974
  extractText(t) {
835
975
  const e = this.getDirectTextContent(t);
836
976
  if (!e) return null;
837
- const s = V(e);
977
+ const s = Q(e);
838
978
  if (!s) return null;
839
979
  const r = 100, a = e.length > r ? e.slice(0, r) + "..." : e, i = s.length > r ? s.slice(0, r) + "..." : s;
840
980
  return {
@@ -882,7 +1022,7 @@ class Pt {
882
1022
  ].includes(e);
883
1023
  }
884
1024
  }
885
- class _t {
1025
+ class qt {
886
1026
  /**
887
1027
  * Generates fingerprint for SVG element
888
1028
  * @param element - SVG element to fingerprint
@@ -958,8 +1098,8 @@ class _t {
958
1098
  break;
959
1099
  case "line":
960
1100
  {
961
- const r = parseFloat(t.getAttribute("x1") ?? "0"), a = parseFloat(t.getAttribute("y1") ?? "0"), i = parseFloat(t.getAttribute("x2") ?? "0"), o = parseFloat(t.getAttribute("y2") ?? "0"), l = Math.atan2(o - a, i - r);
962
- s.push(`angle=${l.toFixed(2)}`);
1101
+ const r = parseFloat(t.getAttribute("x1") ?? "0"), a = parseFloat(t.getAttribute("y1") ?? "0"), i = parseFloat(t.getAttribute("x2") ?? "0"), o = parseFloat(t.getAttribute("y2") ?? "0"), c = Math.atan2(o - a, i - r);
1102
+ s.push(`angle=${c.toFixed(2)}`);
963
1103
  }
964
1104
  break;
965
1105
  }
@@ -993,22 +1133,22 @@ class _t {
993
1133
  return Math.abs(e).toString(16).padStart(8, "0");
994
1134
  }
995
1135
  }
996
- function kt(n, t = 0) {
997
- const e = n.anchor.score, s = n.path.length > 0 ? n.path.reduce((o, l) => o + l.score, 0) / n.path.length : 0.5, r = n.target.score, a = e * L.ANCHOR + s * L.PATH + r * L.TARGET + t * L.UNIQUENESS, i = n.anchor.degraded ? 0.2 : 0;
1136
+ function Lt(n, t = 0) {
1137
+ const e = n.anchor.score, s = n.path.length > 0 ? n.path.reduce((o, c) => o + c.score, 0) / n.path.length : 0.5, r = n.target.score, a = e * _.ANCHOR + s * _.PATH + r * _.TARGET + t * _.UNIQUENESS, i = n.anchor.degraded ? 0.2 : 0;
998
1138
  return Math.max(0, Math.min(1, a - i));
999
1139
  }
1000
- function ae(n, t, e) {
1140
+ function ie(n, t, e) {
1001
1141
  let s = 0.5;
1002
1142
  return t && (s += 0.2), e && (s += 0.15), s += Math.min(n * 0.05, 0.15), Math.min(s, 1);
1003
1143
  }
1004
- class qt {
1144
+ class kt {
1005
1145
  constructor(t) {
1006
1146
  this.cache = /* @__PURE__ */ new Map(), this.maxSize = t;
1007
1147
  }
1008
1148
  get(t) {
1009
- if (!this.cache.has(t)) return;
1010
1149
  const e = this.cache.get(t);
1011
- return this.cache.delete(t), this.cache.set(t, e), e;
1150
+ if (e !== void 0)
1151
+ return this.cache.delete(t), this.cache.set(t, e), e;
1012
1152
  }
1013
1153
  set(t, e) {
1014
1154
  if (this.cache.has(t))
@@ -1032,9 +1172,9 @@ class qt {
1032
1172
  return this.cache.size;
1033
1173
  }
1034
1174
  }
1035
- class Lt {
1175
+ class _t {
1036
1176
  constructor(t = {}) {
1037
- this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new qt(
1177
+ this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new kt(
1038
1178
  t.maxSelectorCacheSize ?? 1e3
1039
1179
  ), this.anchorCache = /* @__PURE__ */ new WeakMap(), this.semanticsCache = /* @__PURE__ */ new WeakMap(), this.stats = {
1040
1180
  eidHits: 0,
@@ -1184,82 +1324,82 @@ class Lt {
1184
1324
  }
1185
1325
  }
1186
1326
  function Ot(n) {
1187
- return new Lt(n);
1327
+ return new _t(n);
1188
1328
  }
1189
1329
  let O = null;
1190
- function Q() {
1330
+ function Z() {
1191
1331
  return O || (O = Ot()), O;
1192
1332
  }
1193
- function ie() {
1333
+ function oe() {
1194
1334
  O = null;
1195
1335
  }
1196
- function Z(n, t = {}) {
1336
+ function Y(n, t = {}) {
1197
1337
  if (!n || !n.ownerDocument || !n.isConnected)
1198
1338
  return null;
1199
- const e = { ...ut, ...t }, s = e.cache ?? Q(), r = s.getEID(n);
1339
+ const e = { ...dt, ...t }, s = e.cache ?? Z(), r = s.getEID(n);
1200
1340
  if (r !== void 0)
1201
1341
  return r;
1202
- const a = new ft(e, s), i = new xt(e, s), o = new Pt(e, s), l = new _t(), u = a.findAnchor(n);
1203
- if (!u && !e.fallbackToBody)
1342
+ if (n.tagName.toLowerCase() === "html") {
1343
+ const v = new et(e, s), A = Ft(n, e, v);
1344
+ return s.setEID(n, A), A;
1345
+ }
1346
+ const i = new gt(e, s), o = new Ct(e, s), c = new et(e, s), u = new qt(), d = i.findAnchor(n);
1347
+ if (!d && !e.fallbackToBody)
1204
1348
  return null;
1205
- const d = u?.element ?? n.ownerDocument?.body ?? null;
1206
- if (!d) return null;
1207
- const c = !u || u.tier === "C", h = d.tagName.toLowerCase(), g = d.parentElement;
1208
- let f;
1209
- if (g && h !== "body" && h !== "html") {
1210
- const T = Array.from(g.children).indexOf(d);
1211
- T !== -1 && (f = T + 1);
1212
- }
1213
- const p = o.extract(d), m = {
1214
- tag: d.tagName.toLowerCase(),
1349
+ const l = d?.element ?? n.ownerDocument?.body ?? null;
1350
+ if (!l) return null;
1351
+ const h = !d || d.tier === "C", g = l.tagName.toLowerCase(), f = l.parentElement;
1352
+ let m;
1353
+ if (f && g !== "body" && g !== "html") {
1354
+ const A = Array.from(f.children).indexOf(l);
1355
+ A !== -1 && (m = A + 1);
1356
+ }
1357
+ const p = c.extract(l), S = {
1358
+ tag: l.tagName.toLowerCase(),
1215
1359
  semantics: p,
1216
- score: u?.score ?? I.DEGRADED_SCORE,
1217
- degraded: c,
1218
- nthChild: f
1219
- }, b = i.buildPath(
1220
- d,
1221
- n,
1222
- o
1223
- ), y = o.extract(n);
1224
- e.enableSvgFingerprint && zt(n) && (y.svg = l.fingerprint(n));
1225
- const v = n.parentElement;
1226
- let A;
1227
- if (v) {
1228
- const T = Array.from(v.children).indexOf(n);
1229
- T !== -1 && (A = T + 1);
1230
- }
1231
- const S = {
1360
+ score: d?.score ?? N.DEGRADED_SCORE,
1361
+ degraded: h,
1362
+ nthChild: m
1363
+ }, y = o.buildPath(l, n, c), w = c.extract(n);
1364
+ e.enableSvgFingerprint && Ut(n) && (w.svg = u.fingerprint(n));
1365
+ const x = n.parentElement;
1366
+ let b;
1367
+ if (x) {
1368
+ const A = Array.from(x.children).indexOf(n);
1369
+ A !== -1 && (b = A + 1);
1370
+ }
1371
+ const $ = {
1232
1372
  tag: n.tagName.toLowerCase(),
1233
- semantics: y,
1234
- score: o.scoreElement(n),
1235
- nthChild: A
1236
- }, $ = [], M = {
1373
+ semantics: w,
1374
+ score: c.scoreElement(n),
1375
+ nthChild: b
1376
+ }, I = [], H = {
1237
1377
  onMultiple: "best-score",
1238
1378
  onMissing: "anchor-only",
1239
1379
  maxDepth: 3
1240
- }, H = m.degraded || b.degraded, E = Ut(m.degraded, b), C = {
1380
+ }, T = S.degraded || y.degraded, R = zt(S.degraded, y), C = {
1241
1381
  version: "1.0",
1242
- anchor: m,
1243
- path: b.path,
1244
- target: S,
1245
- constraints: $,
1246
- fallback: M,
1382
+ anchor: S,
1383
+ path: y.path,
1384
+ target: $,
1385
+ constraints: I,
1386
+ fallback: H,
1247
1387
  meta: {
1248
1388
  confidence: 0,
1249
1389
  // Calculated below
1250
1390
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1251
1391
  generator: "dom-eid@1.0",
1252
1392
  source: e.source,
1253
- degraded: H,
1254
- degradationReason: E
1393
+ degraded: T,
1394
+ degradationReason: R
1255
1395
  }
1256
1396
  };
1257
- return C.meta.confidence = kt(C), C.meta.confidence < e.confidenceThreshold ? null : (s.setEID(n, C), C);
1397
+ return C.meta.confidence = Lt(C), C.meta.confidence < e.confidenceThreshold ? null : (s.setEID(n, C), C);
1258
1398
  }
1259
- function zt(n) {
1399
+ function Ut(n) {
1260
1400
  return n.namespaceURI === "http://www.w3.org/2000/svg" || n.tagName.toLowerCase() === "svg" || n instanceof SVGElement;
1261
1401
  }
1262
- function Ut(n, t) {
1402
+ function zt(n, t) {
1263
1403
  if (n && t.degraded)
1264
1404
  return "anchor-and-path-degraded";
1265
1405
  if (n)
@@ -1267,22 +1407,71 @@ function Ut(n, t) {
1267
1407
  if (t.degraded)
1268
1408
  return t.degradationReason;
1269
1409
  }
1270
- class st {
1410
+ function Ft(n, t, e, s) {
1411
+ const a = {
1412
+ tag: "html",
1413
+ semantics: e.extract(n),
1414
+ score: 1,
1415
+ degraded: !1,
1416
+ nthChild: void 0
1417
+ };
1418
+ return {
1419
+ version: "1.0",
1420
+ anchor: a,
1421
+ path: [],
1422
+ target: a,
1423
+ constraints: [],
1424
+ fallback: {
1425
+ onMultiple: "best-score",
1426
+ onMissing: "anchor-only",
1427
+ maxDepth: 3
1428
+ },
1429
+ meta: {
1430
+ confidence: 1,
1431
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1432
+ generator: "dom-eid@1.0",
1433
+ source: t.source,
1434
+ degraded: !1,
1435
+ degradationReason: void 0
1436
+ }
1437
+ };
1438
+ }
1439
+ class rt {
1271
1440
  buildSelector(t, e) {
1441
+ if (t.target.tag === "html") {
1442
+ const l = "html";
1443
+ return e?.ensureUnique ? {
1444
+ selector: l,
1445
+ isUnique: !0,
1446
+ usedNthOfType: !1,
1447
+ extraClassesAdded: 0
1448
+ } : l;
1449
+ }
1450
+ if (t.anchor.tag === "html" && t.path.length === 0) {
1451
+ const h = `html > ${this.buildNodeSelector(t.target.tag, t.target.semantics)}`;
1452
+ return e?.ensureUnique ? {
1453
+ selector: h,
1454
+ isUnique: this.isUnique(h, e.root ?? document),
1455
+ usedNthOfType: !1,
1456
+ extraClassesAdded: 0
1457
+ } : h;
1458
+ }
1459
+ if (t.anchor.tag === "html" && t.path.length > 0 && t.path[0].tag === "head")
1460
+ return this.buildHeadSelector(t, e);
1272
1461
  if (t.path.length === 0 && t.anchor.tag === t.target.tag && JSON.stringify(t.anchor.semantics) === JSON.stringify(t.target.semantics)) {
1273
- const c = this.buildNodeSelector(
1462
+ const l = this.buildNodeSelector(
1274
1463
  t.target.tag,
1275
1464
  t.target.semantics,
1276
1465
  { excludeClasses: !1 }
1277
1466
  // Include classes for same-element case
1278
1467
  );
1279
- return e?.ensureUnique ? this.ensureUniqueSelector(c, t, e) : c;
1468
+ return e?.ensureUnique ? this.ensureUniqueSelector(l, t, e) : l;
1280
1469
  }
1281
1470
  const r = [], a = e?.ensureUnique ? this.ensureUniqueAnchor(t, e.root ?? document) : this.buildNodeSelector(t.anchor.tag, t.anchor.semantics);
1282
1471
  r.push(a);
1283
- for (const c of t.path) {
1284
- let h = this.buildNodeSelector(c.tag, c.semantics);
1285
- c.nthChild !== void 0 && (["tr", "td", "th", "thead", "tbody", "tfoot"].includes(c.tag) ? h += `:nth-child(${c.nthChild})` : h += `:nth-child(${c.nthChild})`), r.push(h);
1472
+ for (const l of t.path) {
1473
+ let h = this.buildNodeSelector(l.tag, l.semantics);
1474
+ l.nthChild !== void 0 && (["tr", "td", "th", "thead", "tbody", "tfoot"].includes(l.tag) ? h += `:nth-child(${l.nthChild})` : h += `:nth-child(${l.nthChild})`), r.push(h);
1286
1475
  }
1287
1476
  let i = this.buildNodeSelector(
1288
1477
  t.target.tag,
@@ -1291,13 +1480,13 @@ class st {
1291
1480
  // Exclude classes initially if we need unique
1292
1481
  );
1293
1482
  t.target.nthChild !== void 0 && (["tr", "td", "th", "thead", "tbody", "tfoot"].includes(t.target.tag) ? i += `:nth-child(${t.target.nthChild})` : i += `:nth-child(${t.target.nthChild})`), r.push(i);
1294
- const o = this.isSvgChildElement(t.target.tag), l = t.path.some((c) => c.tag === "svg");
1483
+ const o = this.isSvgChildElement(t.target.tag), c = t.path.some((l) => l.tag === "svg");
1295
1484
  let u;
1296
- if (o && l) {
1297
- const c = t.path.findIndex((h) => h.tag === "svg");
1298
- if (c !== -1) {
1299
- const h = c + 1, g = r.slice(0, h + 1), f = r.slice(h + 1, -1), p = r[r.length - 1];
1300
- f.length > 0 ? u = g.join(" ") + " > " + f.join(" > ") + " > " + p : u = g.join(" ") + " > " + p;
1485
+ if (o && c) {
1486
+ const l = t.path.findIndex((h) => h.tag === "svg");
1487
+ if (l !== -1) {
1488
+ const h = l + 1, g = r.slice(0, h + 1), f = r.slice(h + 1, -1), m = r[r.length - 1];
1489
+ f.length > 0 ? u = g.join(" ") + " > " + f.join(" > ") + " > " + m : u = g.join(" ") + " > " + m;
1301
1490
  } else
1302
1491
  u = r.join(" ");
1303
1492
  } else
@@ -1313,24 +1502,20 @@ class st {
1313
1502
  extraClassesAdded: 0
1314
1503
  };
1315
1504
  if (d.length === 0 || d.length > 1) {
1316
- const c = this.buildFullDomPathSelector(
1505
+ const l = this.buildFullDomPathSelector(
1317
1506
  t,
1318
1507
  t.target.semantics,
1319
1508
  e.root ?? document
1320
1509
  );
1321
- if (c && this.isUnique(c, e.root ?? document))
1510
+ if (l && this.isUnique(l, e.root ?? document))
1322
1511
  return {
1323
- selector: c,
1512
+ selector: l,
1324
1513
  isUnique: !0,
1325
- usedNthOfType: c.includes(":nth-"),
1514
+ usedNthOfType: l.includes(":nth-"),
1326
1515
  extraClassesAdded: 0
1327
1516
  };
1328
1517
  }
1329
- return this.ensureUniqueSelector(
1330
- u,
1331
- t,
1332
- e
1333
- );
1518
+ return this.ensureUniqueSelector(u, t, e);
1334
1519
  }
1335
1520
  /**
1336
1521
  * Builds selector for anchor only (used in fallback)
@@ -1345,36 +1530,36 @@ class st {
1345
1530
  */
1346
1531
  ensureUniqueSelector(t, e, s) {
1347
1532
  const r = s.root ?? document, a = s.maxClasses ?? 4, i = e.target.tag, o = e.target.semantics;
1348
- let l = t, u = 0, d = !1;
1349
- if (this.querySelectorSafe(l, r).length === 0) {
1533
+ let c = t, u = 0, d = !1;
1534
+ if (this.querySelectorSafe(c, r).length === 0) {
1350
1535
  const f = this.buildFullDomPathSelector(e, o, r);
1351
- if (f && (l = f, this.isUnique(l, r)))
1536
+ if (f && (c = f, this.isUnique(c, r)))
1352
1537
  return {
1353
- selector: l,
1538
+ selector: c,
1354
1539
  isUnique: !0,
1355
1540
  usedNthOfType: !1,
1356
1541
  extraClassesAdded: 0
1357
1542
  };
1358
1543
  }
1359
- if (this.isUnique(l, r))
1544
+ if (this.isUnique(c, r))
1360
1545
  return {
1361
- selector: l,
1546
+ selector: c,
1362
1547
  isUnique: !0,
1363
1548
  usedNthOfType: !1,
1364
1549
  extraClassesAdded: 0
1365
1550
  };
1366
- const h = N(o.classes ?? []);
1551
+ const h = M(o.classes ?? []);
1367
1552
  for (let f = 0; f < Math.min(h.length, a); f++) {
1368
- const p = h[f];
1369
- if (l += `.${this.escapeCSS(p)}`, u++, this.isUnique(l, r))
1553
+ const m = h[f];
1554
+ if (c += `.${this.escapeCSS(m)}`, u++, this.isUnique(c, r))
1370
1555
  return {
1371
- selector: l,
1556
+ selector: c,
1372
1557
  isUnique: !0,
1373
1558
  usedNthOfType: !1,
1374
1559
  extraClassesAdded: u
1375
1560
  };
1376
1561
  }
1377
- if (!this.isUnique(l, r)) {
1562
+ if (!this.isUnique(c, r)) {
1378
1563
  const f = this.buildFullDomPathSelector(e, o, r);
1379
1564
  if (f && this.isUnique(f, r))
1380
1565
  return {
@@ -1384,10 +1569,10 @@ class st {
1384
1569
  extraClassesAdded: u
1385
1570
  };
1386
1571
  }
1387
- const g = this.findNthElementByText(l, o, r);
1388
- return g && (l += this.getNthSelector(g, i), d = !0), {
1389
- selector: l,
1390
- isUnique: this.isUnique(l, r),
1572
+ const g = this.findNthElementByText(c, o, r);
1573
+ return g && (c += this.getNthSelector(g, i), d = !0), {
1574
+ selector: c,
1575
+ isUnique: this.isUnique(c, r),
1391
1576
  usedNthOfType: d,
1392
1577
  extraClassesAdded: u
1393
1578
  };
@@ -1400,24 +1585,15 @@ class st {
1400
1585
  const r = this.buildNodeSelector(t.anchor.tag, t.anchor.semantics), a = this.querySelectorSafe(r, s);
1401
1586
  if (a.length === 0) return null;
1402
1587
  for (const i of a) {
1403
- const o = this.findTargetWithinAnchor(
1404
- i,
1405
- t.target.tag,
1406
- e
1407
- );
1588
+ const o = this.findTargetWithinAnchor(i, t.target.tag, e);
1408
1589
  if (o.length === 0) continue;
1409
- const l = o.map((u) => {
1590
+ const c = o.map((u) => {
1410
1591
  const d = this.scorePathMatch(u, i, t.path);
1411
1592
  return { element: u, score: d };
1412
1593
  });
1413
- l.sort((u, d) => d.score - u.score);
1414
- for (const { element: u } of l) {
1415
- const d = this.buildPathFromAnchorToTarget(
1416
- i,
1417
- u,
1418
- t,
1419
- s
1420
- );
1594
+ c.sort((u, d) => d.score - u.score);
1595
+ for (const { element: u } of c) {
1596
+ const d = this.buildPathFromAnchorToTarget(i, u, t, s);
1421
1597
  if (d && this.isUnique(d, s))
1422
1598
  return d;
1423
1599
  }
@@ -1440,29 +1616,29 @@ class st {
1440
1616
  let i = 0;
1441
1617
  const o = Math.min(r.length, s.length);
1442
1618
  for (let u = 0; u < o; u++) {
1443
- const d = r[u], c = s[u];
1444
- if (d.tagName.toLowerCase() === c.tag) {
1445
- if (i += 10, c.nthChild !== void 0) {
1619
+ const d = r[u], l = s[u];
1620
+ if (d.tagName.toLowerCase() === l.tag) {
1621
+ if (i += 10, l.nthChild !== void 0) {
1446
1622
  const h = d.parentElement;
1447
- h && (Array.from(h.children).indexOf(d) + 1 === c.nthChild ? i += 20 : i -= 10);
1623
+ h && (Array.from(h.children).indexOf(d) + 1 === l.nthChild ? i += 20 : i -= 10);
1448
1624
  }
1449
1625
  } else
1450
1626
  i -= 5;
1451
- if (c.semantics.classes && c.semantics.classes.length > 0) {
1452
- const h = c.semantics.classes.filter(
1627
+ if (l.semantics.classes && l.semantics.classes.length > 0) {
1628
+ const h = l.semantics.classes.filter(
1453
1629
  (g) => d.classList.contains(g)
1454
1630
  );
1455
1631
  i += h.length * 2;
1456
1632
  }
1457
- if (c.semantics.attributes) {
1458
- const h = Object.entries(c.semantics.attributes).filter(
1633
+ if (l.semantics.attributes) {
1634
+ const h = Object.entries(l.semantics.attributes).filter(
1459
1635
  ([g, f]) => d.getAttribute(g) === f
1460
1636
  );
1461
1637
  i += h.length * 3;
1462
1638
  }
1463
1639
  }
1464
- const l = Math.abs(r.length - s.length);
1465
- return i -= l * 2, i;
1640
+ const c = Math.abs(r.length - s.length);
1641
+ return i -= c * 2, i;
1466
1642
  }
1467
1643
  /**
1468
1644
  * Finds target elements within an anchor by matching semantics
@@ -1474,14 +1650,10 @@ class st {
1474
1650
  if (!i.includes(o) && !o.includes(i))
1475
1651
  return !1;
1476
1652
  }
1477
- return !!(s.classes && s.classes.length > 0 && s.classes.every(
1478
- (o) => a.classList.contains(o)
1479
- ) || s.attributes && Object.entries(s.attributes).every(
1480
- ([o, l]) => {
1481
- const u = a.getAttribute(o);
1482
- return o === "href" || o === "src" ? _(o, u || "") === _(o, l) : u === l;
1483
- }
1484
- ) || s.text);
1653
+ return !!(s.classes && s.classes.length > 0 && s.classes.every((o) => a.classList.contains(o)) || s.attributes && Object.entries(s.attributes).every(([o, c]) => {
1654
+ const u = a.getAttribute(o);
1655
+ return o === "href" || o === "src" ? q(o, u || "") === q(o, c) : u === c;
1656
+ }) || s.text);
1485
1657
  });
1486
1658
  }
1487
1659
  /**
@@ -1498,22 +1670,20 @@ class st {
1498
1670
  if (s?.semantics?.attributes) {
1499
1671
  const o = this.buildNodeSelector(e, s.semantics, {
1500
1672
  excludeClasses: !0
1501
- }), l = [...r, e].join(" > "), u = this.querySelectorSafe(l, a), d = [...r, o].join(" > "), c = this.querySelectorSafe(d, a);
1502
- if (c.length > 0 && c.length < u.length)
1673
+ }), c = [...r, e].join(" > "), u = this.querySelectorSafe(c, a), d = [...r, o].join(" > "), l = this.querySelectorSafe(d, a);
1674
+ if (l.length > 0 && l.length < u.length)
1503
1675
  return o;
1504
1676
  }
1505
1677
  if (s?.semantics?.classes) {
1506
- const o = N(s.semantics.classes);
1678
+ const o = M(s.semantics.classes);
1507
1679
  if (o.length > 0) {
1508
- const l = `${e}.${this.escapeCSS(o[0])}`, u = [...r, e].join(" > "), d = this.querySelectorSafe(u, a), c = [...r, l].join(" > "), h = this.querySelectorSafe(c, a);
1680
+ const c = `${e}.${this.escapeCSS(o[0])}`, u = [...r, e].join(" > "), d = this.querySelectorSafe(u, a), l = [...r, c].join(" > "), h = this.querySelectorSafe(l, a);
1509
1681
  if (h.length > 0 && h.length < d.length)
1510
- return l;
1682
+ return c;
1511
1683
  }
1512
1684
  }
1513
1685
  const i = t.parentElement;
1514
- return i && Array.from(i.children).filter(
1515
- (l) => l.tagName.toLowerCase() === e
1516
- ).length > 1 ? `${e}${this.getNthSelector(t, e)}` : e;
1686
+ return i && Array.from(i.children).filter((c) => c.tagName.toLowerCase() === e).length > 1 ? `${e}${this.getNthSelector(t, e)}` : e;
1517
1687
  }
1518
1688
  /**
1519
1689
  * Builds CSS selector path from anchor to target by traversing actual DOM
@@ -1531,17 +1701,21 @@ class st {
1531
1701
  // Most flexible - no classes on target, only semantic attributes
1532
1702
  // ============================================================
1533
1703
  () => {
1534
- const l = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), u = s.target.tag, d = s.target.semantics, c = [];
1535
- for (const m of s.path)
1536
- c.push(m.tag);
1537
- const g = [l, ...c, u].filter(Boolean).join(" ");
1704
+ const c = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), u = s.target.tag, d = s.target.semantics, l = [];
1705
+ for (const p of s.path)
1706
+ l.push(p.tag);
1707
+ const g = [c, ...l, u].filter(Boolean).join(" ");
1538
1708
  if (this.isUnique(g, r))
1539
1709
  return g;
1540
1710
  const f = this.buildNodeSelector(u, d, {
1541
1711
  excludeClasses: !0
1542
1712
  // KEY: no classes on target in Strategy 0
1543
- }), p = [l, ...c.slice(0, -1), f].join(" ");
1544
- return this.isUnique(p, r) ? p : null;
1713
+ }), m = [
1714
+ c,
1715
+ ...l.slice(0, -1),
1716
+ f
1717
+ ].join(" ");
1718
+ return this.isUnique(m, r) ? m : null;
1545
1719
  },
1546
1720
  // ============================================================
1547
1721
  // Strategy 1: anchor > parent[attrs|class|nth] > target[attrs_only]
@@ -1550,7 +1724,7 @@ class st {
1550
1724
  // Target: ONLY attributes, NO classes
1551
1725
  // ============================================================
1552
1726
  () => {
1553
- const l = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)], u = /* @__PURE__ */ new Map();
1727
+ const c = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)], u = /* @__PURE__ */ new Map();
1554
1728
  let d = 0;
1555
1729
  for (let h = 0; h < a.length - 1; h++) {
1556
1730
  const g = a[h], f = g.tagName.toLowerCase();
@@ -1559,22 +1733,22 @@ class st {
1559
1733
  for (let h = 0; h < a.length; h++) {
1560
1734
  const g = a[h], f = g.tagName.toLowerCase();
1561
1735
  if (h < a.length - 1) {
1562
- const b = u.get(g) || null, y = this.disambiguateParent(g, f, b, l, r);
1563
- l.push(y);
1736
+ const S = u.get(g) || null, y = this.disambiguateParent(g, f, S, c, r);
1737
+ c.push(y);
1564
1738
  continue;
1565
1739
  }
1566
- const p = this.buildNodeSelector(
1740
+ const m = this.buildNodeSelector(
1567
1741
  s.target.tag,
1568
1742
  s.target.semantics,
1569
1743
  { excludeClasses: !0 }
1570
1744
  // KEY: no classes on target
1571
- ), m = g.parentElement;
1572
- m && ["td", "th", "tr", "thead", "tbody", "tfoot"].includes(f) && Array.from(m.children).filter(
1745
+ ), p = g.parentElement;
1746
+ p && ["td", "th", "tr", "thead", "tbody", "tfoot"].includes(f) && Array.from(p.children).filter(
1573
1747
  (y) => y.tagName.toLowerCase() === f
1574
- ).length > 1 ? l.push(`${p}${this.getNthSelector(g, f)}`) : l.push(p);
1748
+ ).length > 1 ? c.push(`${m}${this.getNthSelector(g, f)}`) : c.push(m);
1575
1749
  }
1576
- const c = l.join(" > ");
1577
- return this.isUnique(c, r) ? c : null;
1750
+ const l = c.join(" > ");
1751
+ return this.isUnique(l, r) ? l : null;
1578
1752
  },
1579
1753
  // ============================================================
1580
1754
  // Strategy 2: anchor parent[attrs|class|nth] target[attrs_only]
@@ -1585,30 +1759,30 @@ class st {
1585
1759
  () => {
1586
1760
  const u = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)];
1587
1761
  for (let h = 0; h < a.length - 1; h++) {
1588
- const f = a[h].tagName.toLowerCase(), p = s.path[h] || null, m = u.join(" ") + " " + f;
1589
- if (this.querySelectorSafe(m, r).length > 1) {
1590
- if (p?.semantics?.attributes) {
1591
- const A = this.buildNodeSelector(f, p.semantics, {
1762
+ const f = a[h].tagName.toLowerCase(), m = s.path[h] || null, p = u.join(" ") + " " + f;
1763
+ if (this.querySelectorSafe(p, r).length > 1) {
1764
+ if (m?.semantics?.attributes) {
1765
+ const x = this.buildNodeSelector(f, m.semantics, {
1592
1766
  excludeClasses: !0
1593
- }), S = u.join(" ") + " " + A;
1594
- if (this.querySelectorSafe(S, r).length === 1 || this.querySelectorSafe(S + " " + s.target.tag, r).length === 1) {
1595
- u.push(A);
1767
+ }), b = u.join(" ") + " " + x;
1768
+ if (this.querySelectorSafe(b, r).length === 1 || this.querySelectorSafe(b + " " + s.target.tag, r).length === 1) {
1769
+ u.push(x);
1596
1770
  continue;
1597
1771
  }
1598
1772
  }
1599
- if (p?.semantics?.classes) {
1600
- const A = N(p.semantics.classes);
1601
- if (A.length > 0) {
1602
- const S = `${f}.${this.escapeCSS(A[0])}`, $ = u.join(" ") + " " + S;
1773
+ if (m?.semantics?.classes) {
1774
+ const x = M(m.semantics.classes);
1775
+ if (x.length > 0) {
1776
+ const b = `${f}.${this.escapeCSS(x[0])}`, $ = u.join(" ") + " " + b;
1603
1777
  if (this.querySelectorSafe($, r).length === 1 || this.querySelectorSafe($ + " " + s.target.tag, r).length === 1) {
1604
- u.push(S);
1778
+ u.push(b);
1605
1779
  continue;
1606
1780
  }
1607
1781
  }
1608
1782
  }
1609
- const y = a[h], v = y.parentElement;
1610
- if (v && Array.from(v.children).filter(
1611
- (S) => S.tagName.toLowerCase() === f
1783
+ const y = a[h], w = y.parentElement;
1784
+ if (w && Array.from(w.children).filter(
1785
+ (b) => b.tagName.toLowerCase() === f
1612
1786
  ).length > 1) {
1613
1787
  u.push(`${f}${this.getNthSelector(y, f)}`);
1614
1788
  continue;
@@ -1623,8 +1797,8 @@ class st {
1623
1797
  // KEY: no classes on target
1624
1798
  );
1625
1799
  u.push(d);
1626
- const c = u.join(" ");
1627
- return this.isUnique(c, r) ? c : null;
1800
+ const l = u.join(" ");
1801
+ return this.isUnique(l, r) ? l : null;
1628
1802
  },
1629
1803
  // ============================================================
1630
1804
  // Strategy 3: anchor path target[attrs + 1_stable_class]
@@ -1632,17 +1806,17 @@ class st {
1632
1806
  // Only use this if attrs alone are not sufficient
1633
1807
  // ============================================================
1634
1808
  () => {
1635
- const l = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), u = [];
1809
+ const c = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), u = [];
1636
1810
  for (const g of s.path)
1637
1811
  u.push(g.tag);
1638
- if (N(s.target.semantics.classes ?? []).length === 0)
1812
+ if (M(s.target.semantics.classes ?? []).length === 0)
1639
1813
  return null;
1640
- const c = this.buildNodeSelector(
1814
+ const l = this.buildNodeSelector(
1641
1815
  s.target.tag,
1642
1816
  s.target.semantics,
1643
1817
  { maxClasses: 1 }
1644
1818
  // KEY: ONE stable class only
1645
- ), h = [l, ...u.slice(0, -1), c].join(" ");
1819
+ ), h = [c, ...u.slice(0, -1), l].join(" ");
1646
1820
  return this.isUnique(h, r) ? h : null;
1647
1821
  },
1648
1822
  // ============================================================
@@ -1651,24 +1825,24 @@ class st {
1651
1825
  // Only use when all other strategies fail
1652
1826
  // ============================================================
1653
1827
  () => {
1654
- const l = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), u = [];
1655
- for (const p of s.path)
1656
- u.push(p.tag);
1657
- const d = a[a.length - 1], c = d.parentElement;
1658
- if (!c || Array.from(c.children).filter(
1659
- (p) => p.tagName.toLowerCase() === s.target.tag
1828
+ const c = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), u = [];
1829
+ for (const m of s.path)
1830
+ u.push(m.tag);
1831
+ const d = a[a.length - 1], l = d.parentElement;
1832
+ if (!l || Array.from(l.children).filter(
1833
+ (m) => m.tagName.toLowerCase() === s.target.tag
1660
1834
  ).length <= 1) return null;
1661
1835
  const g = this.buildNodeSelector(
1662
1836
  s.target.tag,
1663
1837
  s.target.semantics,
1664
1838
  { excludeClasses: !0 }
1665
1839
  // No classes, just attrs + nth
1666
- ) + this.getNthSelector(d, s.target.tag), f = [l, ...u.slice(0, -1), g].join(" ");
1840
+ ) + this.getNthSelector(d, s.target.tag), f = [c, ...u.slice(0, -1), g].join(" ");
1667
1841
  return this.isUnique(f, r) ? f : null;
1668
1842
  }
1669
1843
  ];
1670
- for (const l of o) {
1671
- const u = l();
1844
+ for (const c of o) {
1845
+ const u = c();
1672
1846
  if (u) return u;
1673
1847
  }
1674
1848
  return null;
@@ -1678,13 +1852,12 @@ class st {
1678
1852
  * @param element The DOM element to create a selector for
1679
1853
  * @returns A minimal CSS selector for the element
1680
1854
  */
1681
- // @ts-ignore: Method is used dynamically in buildPathFromAnchorToTarget
1682
1855
  buildElementSelector(t) {
1683
1856
  const e = t.tagName.toLowerCase();
1684
1857
  let s = e;
1685
1858
  if (t.id && !D(t.id))
1686
1859
  return `${e}#${this.escapeCSS(t.id)}`;
1687
- const r = Array.from(t.classList), a = N(r);
1860
+ const r = Array.from(t.classList), a = M(r);
1688
1861
  a.length > 0 && (s += a.slice(0, 2).map((o) => `.${this.escapeCSS(o)}`).join(""));
1689
1862
  const i = t.getAttribute("role");
1690
1863
  return i && (s += `[role="${this.escapeAttr(i)}"]`), s;
@@ -1732,9 +1905,7 @@ class st {
1732
1905
  getNthOfTypeIndex(t, e) {
1733
1906
  const s = t.parentElement;
1734
1907
  if (!s) return null;
1735
- const a = Array.from(s.children).filter(
1736
- (i) => i.tagName.toLowerCase() === e
1737
- ).indexOf(t);
1908
+ const a = Array.from(s.children).filter((i) => i.tagName.toLowerCase() === e).indexOf(t);
1738
1909
  return a !== -1 ? a + 1 : null;
1739
1910
  }
1740
1911
  /**
@@ -1749,7 +1920,7 @@ class st {
1749
1920
  if (this.isUnique(s, e))
1750
1921
  return s;
1751
1922
  if (r.classes && r.classes.length > 0) {
1752
- const i = N(r.classes);
1923
+ const i = M(r.classes);
1753
1924
  if (i.length > 0) {
1754
1925
  const o = `${s}.${this.escapeCSS(i[0])}`;
1755
1926
  if (this.isUnique(o, e))
@@ -1758,8 +1929,8 @@ class st {
1758
1929
  }
1759
1930
  if (r.attributes) {
1760
1931
  const i = this.getSortedAttributes(r.attributes);
1761
- for (const { name: o, value: l } of i) {
1762
- const u = o === "href" || o === "src" ? _(o, l) : l;
1932
+ for (const { name: o, value: c } of i) {
1933
+ const u = o === "href" || o === "src" ? q(o, c) : c;
1763
1934
  if (u) {
1764
1935
  const d = `${s}[${o}="${this.escapeAttr(u)}"]`;
1765
1936
  if (this.isUnique(d, e))
@@ -1791,9 +1962,7 @@ class st {
1791
1962
  */
1792
1963
  findElementBySemantics(t, e) {
1793
1964
  return e.classes && e.classes.length > 0 || e.attributes && Object.keys(e.attributes).length > 0 || e.text ? t.find((r) => {
1794
- if (e.classes && e.classes.length > 0 && e.classes.every(
1795
- (i) => r.classList.contains(i)
1796
- ) || e.attributes && Object.entries(e.attributes).every(
1965
+ if (e.classes && e.classes.length > 0 && e.classes.every((i) => r.classList.contains(i)) || e.attributes && Object.entries(e.attributes).every(
1797
1966
  ([i, o]) => r.getAttribute(i) === o
1798
1967
  ))
1799
1968
  return !0;
@@ -1817,7 +1986,7 @@ class st {
1817
1986
  const s = t.parentElement;
1818
1987
  if (!s) return "";
1819
1988
  const r = Array.from(s.children), a = r.indexOf(t) + 1;
1820
- return ["tr", "td", "th", "thead", "tbody", "tfoot"].includes(e) ? `:nth-child(${a})` : `:nth-of-type(${r.filter((l) => l.tagName.toLowerCase() === e).indexOf(t) + 1})`;
1989
+ return ["tr", "td", "th", "thead", "tbody", "tfoot"].includes(e) ? `:nth-child(${a})` : `:nth-of-type(${r.filter((c) => c.tagName.toLowerCase() === e).indexOf(t) + 1})`;
1821
1990
  }
1822
1991
  /**
1823
1992
  * Gets attribute priority for sorting
@@ -1825,7 +1994,7 @@ class st {
1825
1994
  * @returns Priority number (higher = more priority)
1826
1995
  */
1827
1996
  getAttributePriority(t) {
1828
- return w[t] !== void 0 ? w[t] : t.startsWith("data-") ? w["data-*"] : t.startsWith("aria-") ? w["aria-*"] : 0;
1997
+ return E[t] !== void 0 ? E[t] : t.startsWith("data-") ? E["data-*"] : t.startsWith("aria-") ? E["aria-*"] : 0;
1829
1998
  }
1830
1999
  /**
1831
2000
  * Checks if attribute should be ignored
@@ -1833,7 +2002,7 @@ class st {
1833
2002
  * @returns True if should be ignored
1834
2003
  */
1835
2004
  shouldIgnoreAttribute(t) {
1836
- return !!(et.has(t) || t.startsWith("on") || t.startsWith("ng-") || t.startsWith("_ng") || t.startsWith("data-reactid") || t.startsWith("data-react") || t.startsWith("data-v-"));
2005
+ return !!(B.has(t) || t.startsWith("on") || t.startsWith("ng-") || t.startsWith("_ng") || t.startsWith("data-reactid") || t.startsWith("data-react") || t.startsWith("data-v-"));
1837
2006
  }
1838
2007
  /**
1839
2008
  * Gets attributes sorted by priority
@@ -1841,7 +2010,9 @@ class st {
1841
2010
  * @returns Sorted array of attributes with priority
1842
2011
  */
1843
2012
  getSortedAttributes(t) {
1844
- return Object.entries(t).filter(([e]) => !this.shouldIgnoreAttribute(e)).filter(([e, s]) => !B.has(e) || !G(s)).map(([e, s]) => ({
2013
+ return Object.entries(t).filter(([e]) => !this.shouldIgnoreAttribute(e)).filter(
2014
+ ([e, s]) => !G.has(e) || !V(s)
2015
+ ).map(([e, s]) => ({
1845
2016
  name: e,
1846
2017
  value: s,
1847
2018
  priority: this.getAttributePriority(e)
@@ -1858,12 +2029,12 @@ class st {
1858
2029
  if (e.attributes) {
1859
2030
  const a = this.getSortedAttributes(e.attributes);
1860
2031
  for (const { name: i, value: o } of a) {
1861
- const l = i === "href" || i === "src" ? _(i, o) : o;
1862
- l && (r += `[${i}="${this.escapeAttr(l)}"]`);
2032
+ const c = i === "href" || i === "src" ? q(i, o) : o;
2033
+ c && (r += `[${i}="${this.escapeAttr(c)}"]`);
1863
2034
  }
1864
2035
  }
1865
2036
  if (e.role && !e.attributes?.role && (r += `[role="${this.escapeAttr(e.role)}"]`), !s?.excludeClasses && e.classes && e.classes.length > 0) {
1866
- const a = N(e.classes), i = s?.maxClasses !== void 0 ? a.slice(0, s.maxClasses) : a;
2037
+ const a = M(e.classes), i = s?.maxClasses !== void 0 ? a.slice(0, s.maxClasses) : a;
1867
2038
  r += i.map((o) => `.${this.escapeCSS(o)}`).join("");
1868
2039
  }
1869
2040
  return r;
@@ -1887,10 +2058,42 @@ class st {
1887
2058
  * @returns True if element is an SVG child
1888
2059
  */
1889
2060
  isSvgChildElement(t) {
1890
- return ht.includes(t);
2061
+ return ut.includes(t);
2062
+ }
2063
+ /**
2064
+ * Builds CSS selector for elements inside <head>.
2065
+ * Uses child combinator (>) for strict structure: html > head > ... > target
2066
+ * @param eid - Element Identity with anchor=html and path[0]=head
2067
+ * @param options - Optional uniqueness control settings
2068
+ * @returns CSS selector string or BuildSelectorResult
2069
+ * @remarks
2070
+ * This method handles the special case where elements are inside <head>.
2071
+ * The selector always uses child combinators for strict parent-child relationships.
2072
+ * @example
2073
+ * For <html><head><meta name="description"></head></html>
2074
+ * Returns: "html > head > meta[name='description']"
2075
+ */
2076
+ buildHeadSelector(t, e) {
2077
+ const s = ["html"];
2078
+ for (const o of t.path) {
2079
+ let c = this.buildNodeSelector(o.tag, o.semantics);
2080
+ o.nthChild !== void 0 && (c += `:nth-child(${o.nthChild})`), s.push(c);
2081
+ }
2082
+ let r = this.buildNodeSelector(t.target.tag, t.target.semantics);
2083
+ t.target.nthChild !== void 0 && (r += `:nth-child(${t.target.nthChild})`), s.push(r);
2084
+ const a = s.join(" > ");
2085
+ if (!e?.ensureUnique)
2086
+ return a;
2087
+ const i = this.isUnique(a, e.root ?? document);
2088
+ return {
2089
+ selector: a,
2090
+ isUnique: i,
2091
+ usedNthOfType: a.includes(":nth-"),
2092
+ extraClassesAdded: 0
2093
+ };
1891
2094
  }
1892
2095
  }
1893
- class Ft {
2096
+ class jt {
1894
2097
  /**
1895
2098
  * Filters elements that match the semantics
1896
2099
  * @param elements - Candidate elements
@@ -1911,9 +2114,11 @@ class Ft {
1911
2114
  * Prioritizes direct text nodes, but falls back to full textContent if no direct text
1912
2115
  */
1913
2116
  matchText(t, e) {
1914
- const a = Array.from(t.childNodes).filter((o) => o.nodeType === Node.TEXT_NODE).map((o) => o.textContent?.trim() ?? "").join(" ") || (t.textContent?.trim() ?? "");
2117
+ const a = Array.from(t.childNodes).filter(
2118
+ (o) => o.nodeType === Node.TEXT_NODE
2119
+ ).map((o) => o.textContent?.trim() ?? "").join(" ") || (t.textContent?.trim() ?? "");
1915
2120
  if (!a) return !1;
1916
- const i = V(a);
2121
+ const i = Q(a);
1917
2122
  return e.matchMode === "partial" ? i.includes(e.normalized) : i === e.normalized;
1918
2123
  }
1919
2124
  /**
@@ -1965,8 +2170,8 @@ class Ft {
1965
2170
  break;
1966
2171
  }
1967
2172
  case "line": {
1968
- const r = parseFloat(t.getAttribute("x1") ?? "0"), a = parseFloat(t.getAttribute("y1") ?? "0"), i = parseFloat(t.getAttribute("x2") ?? "0"), o = parseFloat(t.getAttribute("y2") ?? "0"), l = Math.atan2(o - a, i - r);
1969
- s.push(`angle=${l.toFixed(2)}`);
2173
+ const r = parseFloat(t.getAttribute("x1") ?? "0"), a = parseFloat(t.getAttribute("y1") ?? "0"), i = parseFloat(t.getAttribute("x2") ?? "0"), o = parseFloat(t.getAttribute("y2") ?? "0"), c = Math.atan2(o - a, i - r);
2174
+ s.push(`angle=${c.toFixed(2)}`);
1970
2175
  break;
1971
2176
  }
1972
2177
  }
@@ -1984,7 +2189,7 @@ class Ft {
1984
2189
  return Math.abs(e).toString(16).padStart(8, "0");
1985
2190
  }
1986
2191
  }
1987
- class jt {
2192
+ class Wt {
1988
2193
  /**
1989
2194
  * Applies a single constraint to candidates
1990
2195
  * @param candidates - Current candidate elements
@@ -1999,10 +2204,7 @@ class jt {
1999
2204
  e.params
2000
2205
  );
2001
2206
  case "position":
2002
- return this.applyPosition(
2003
- t,
2004
- e.params
2005
- );
2207
+ return this.applyPosition(t, e.params);
2006
2208
  default:
2007
2209
  return t;
2008
2210
  }
@@ -2077,9 +2279,9 @@ class jt {
2077
2279
  return s[e.length];
2078
2280
  }
2079
2281
  }
2080
- class Wt {
2282
+ class Bt {
2081
2283
  constructor() {
2082
- this.cssGenerator = new st();
2284
+ this.cssGenerator = new rt();
2083
2285
  }
2084
2286
  /**
2085
2287
  * Handles fallback when resolution fails
@@ -2186,9 +2388,7 @@ class Wt {
2186
2388
  return {
2187
2389
  status: "success",
2188
2390
  elements: [r],
2189
- warnings: [
2190
- `Multiple matches (${t.length}), selected best-scoring element`
2191
- ],
2391
+ warnings: [`Multiple matches (${t.length}), selected best-scoring element`],
2192
2392
  confidence: e.meta.confidence * (0.7 + a * 0.2),
2193
2393
  meta: { degraded: !0, degradationReason: "best-of-multiple" }
2194
2394
  };
@@ -2211,60 +2411,57 @@ class Wt {
2211
2411
  if (a.length > 0) {
2212
2412
  r += 0.2;
2213
2413
  let i = 0;
2214
- for (const [o, l] of a)
2215
- t.getAttribute(o) === l && i++;
2414
+ for (const [o, c] of a)
2415
+ t.getAttribute(o) === c && i++;
2216
2416
  s += i / a.length * 0.2;
2217
2417
  }
2218
2418
  }
2219
2419
  if (e.role && (r += 0.15, t.getAttribute("role") === e.role && (s += 0.15)), e.text) {
2220
2420
  r += 0.1;
2221
- const a = V(t.textContent);
2421
+ const a = Q(t.textContent);
2222
2422
  a === e.text.normalized ? s += 0.1 : a.includes(e.text.normalized) && (s += 0.05);
2223
2423
  }
2224
2424
  return r > 0 ? s / r : 0;
2225
2425
  }
2226
2426
  }
2227
- function Bt(n, t, e = {}) {
2228
- const s = { ...dt, ...e }, r = new st(), a = new Ft(), i = new jt(), o = new Wt(), l = t instanceof Document ? t : t.ownerDocument ?? t, u = r.buildSelector(n, {
2427
+ function Gt(n, t, e = {}) {
2428
+ const s = { ...ft, ...e }, r = new rt(), a = new jt(), i = new Wt(), o = new Bt(), c = t instanceof Document ? t : t.ownerDocument ?? t, u = r.buildSelector(n, {
2229
2429
  ensureUnique: !1,
2230
- root: l
2430
+ root: c
2231
2431
  });
2232
2432
  let d;
2233
2433
  try {
2234
- d = Array.from(l.querySelectorAll(u));
2434
+ d = Array.from(c.querySelectorAll(u));
2235
2435
  } catch (f) {
2236
- const p = f instanceof Error ? f.message : "Unknown selector error";
2436
+ const m = f instanceof Error ? f.message : "Unknown selector error";
2237
2437
  return {
2238
2438
  status: "error",
2239
2439
  elements: [],
2240
- warnings: [
2241
- `Invalid CSS selector: ${u}`,
2242
- `Error: ${p}`
2243
- ],
2440
+ warnings: [`Invalid CSS selector: ${u}`, `Error: ${m}`],
2244
2441
  confidence: 0,
2245
2442
  meta: { degraded: !0, degradationReason: "invalid-selector" }
2246
2443
  };
2247
2444
  }
2248
2445
  d.length > s.maxCandidates && (d = d.slice(0, s.maxCandidates));
2249
- const c = a.match(d, n.target.semantics);
2250
- if (c.length === 1)
2446
+ const l = a.match(d, n.target.semantics);
2447
+ if (l.length === 1)
2251
2448
  return {
2252
2449
  status: "success",
2253
- elements: c,
2450
+ elements: l,
2254
2451
  warnings: [],
2255
2452
  confidence: n.meta.confidence,
2256
2453
  meta: { degraded: !1 }
2257
2454
  };
2258
- if (c.length === 0)
2259
- return s.enableFallback ? o.handleFallback(n, l) : {
2455
+ if (l.length === 0)
2456
+ return s.enableFallback ? o.handleFallback(n, c) : {
2260
2457
  status: "error",
2261
2458
  elements: [],
2262
2459
  warnings: ["No matching elements found"],
2263
2460
  confidence: 0,
2264
2461
  meta: { degraded: !0, degradationReason: "not-found" }
2265
2462
  };
2266
- let h = c;
2267
- const g = Gt(n.constraints);
2463
+ let h = l;
2464
+ const g = Vt(n.constraints);
2268
2465
  for (const f of g) {
2269
2466
  if (h = i.applyConstraint(h, f), h.length === 1)
2270
2467
  return {
@@ -2275,7 +2472,7 @@ function Bt(n, t, e = {}) {
2275
2472
  meta: { degraded: !1 }
2276
2473
  };
2277
2474
  if (h.length === 0)
2278
- return s.enableFallback ? o.handleFallback(n, l) : {
2475
+ return s.enableFallback ? o.handleFallback(n, c) : {
2279
2476
  status: "error",
2280
2477
  elements: [],
2281
2478
  warnings: ["Constraints eliminated all candidates"],
@@ -2291,10 +2488,10 @@ function Bt(n, t, e = {}) {
2291
2488
  meta: { degraded: !0, degradationReason: "ambiguous" }
2292
2489
  } : o.handleAmbiguous(h, n);
2293
2490
  }
2294
- function Gt(n) {
2491
+ function Vt(n) {
2295
2492
  return [...n].sort((t, e) => e.priority - t.priority);
2296
2493
  }
2297
- function oe(n) {
2494
+ function ce(n) {
2298
2495
  const t = [], e = [];
2299
2496
  if (n.version ? n.version !== "1.0" && e.push(`Unknown version: ${n.version}`) : t.push("Missing version field"), n.anchor ? (n.anchor.tag || t.push("Anchor missing tag"), typeof n.anchor.score != "number" && t.push("Anchor missing score"), n.anchor.semantics || t.push("Anchor missing semantics")) : t.push("Missing anchor field"), n.target ? (n.target.tag || t.push("Target missing tag"), typeof n.target.score != "number" && t.push("Target missing score"), n.target.semantics || t.push("Target missing semantics")) : t.push("Missing target field"), !Array.isArray(n.path))
2300
2497
  t.push("Path must be an array");
@@ -2309,12 +2506,12 @@ function oe(n) {
2309
2506
  warnings: e
2310
2507
  };
2311
2508
  }
2312
- function ce(n) {
2509
+ function le(n) {
2313
2510
  if (!n || typeof n != "object") return !1;
2314
2511
  const t = n;
2315
2512
  return typeof t.version == "string" && typeof t.anchor == "object" && Array.isArray(t.path) && typeof t.target == "object";
2316
2513
  }
2317
- const rt = {
2514
+ const nt = {
2318
2515
  maxClasses: 2,
2319
2516
  maxAttributes: 5,
2320
2517
  includeText: !0,
@@ -2322,20 +2519,20 @@ const rt = {
2322
2519
  simplifyTarget: !0,
2323
2520
  includeConstraints: !0
2324
2521
  };
2325
- function tt(n) {
2326
- return n === "id" ? 101 : w[n] !== void 0 ? w[n] : n.startsWith("data-") ? w["data-*"] : n.startsWith("aria-") ? w["aria-*"] : 0;
2522
+ function st(n) {
2523
+ return n === "id" ? 101 : E[n] !== void 0 ? E[n] : n.startsWith("data-") ? E["data-*"] : n.startsWith("aria-") ? E["aria-*"] : 0;
2327
2524
  }
2328
- function Vt(n) {
2525
+ function Qt(n) {
2329
2526
  return ["id", "data-testid", "data-qa", "data-cy", "href", "text", "role"].includes(n);
2330
2527
  }
2331
- function Qt(n) {
2528
+ function Zt(n) {
2332
2529
  return !!(/@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/.test(n) || /(\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/.test(n) || /\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}/.test(n));
2333
2530
  }
2334
- function Zt(n, t) {
2335
- const e = { ...rt, ...t }, s = `v${n.version}`, r = U(n.anchor, !1, e), a = n.path.length > 0 ? n.path.map((l) => U(l, !1, e)).join(" > ") + " > " : "", i = U(n.target, !0, e), o = e.includeConstraints ? Xt(n) : "";
2531
+ function Yt(n, t) {
2532
+ const e = { ...nt, ...t }, s = `v${n.version}`, r = z(n.anchor, !1, e), a = n.path.length > 0 ? n.path.map((c) => z(c, !1, e)).join(" > ") + " > " : "", i = z(n.target, !0, e), o = e.includeConstraints ? Kt(n) : "";
2336
2533
  return `${s}: ${r} :: ${a}${i}${o}`;
2337
2534
  }
2338
- function Yt(n) {
2535
+ function Xt(n) {
2339
2536
  n = n.trim();
2340
2537
  const t = n.match(/^v(\d+(?:\.\d+)?)\s*:\s*/);
2341
2538
  if (!t)
@@ -2352,13 +2549,13 @@ function Yt(n) {
2352
2549
  const i = s.match(/\s*\{([^}]+)\}\s*$/);
2353
2550
  let o = "";
2354
2551
  i && (o = i[1], s = s.slice(0, i.index));
2355
- const l = s.split(/\s*>\s*/).map((m) => m.trim()).filter((m) => m);
2356
- if (l.length === 0)
2552
+ const c = s.split(/\s*>\s*/).map((p) => p.trim()).filter((p) => p);
2553
+ if (c.length === 0)
2357
2554
  throw new Error("Invalid SEQL Selector: missing target node");
2358
- const u = l[l.length - 1], d = l.slice(0, -1), c = F(a, !0), h = d.map((m) => F(m, !1)), g = F(u, !1), f = Kt(o);
2555
+ const u = c[c.length - 1], d = c.slice(0, -1), l = F(a, !0), h = d.map((p) => F(p, !1)), g = F(u, !1), f = Jt(o);
2359
2556
  return {
2360
2557
  version: "1.0",
2361
- anchor: c,
2558
+ anchor: l,
2362
2559
  path: h,
2363
2560
  target: g,
2364
2561
  constraints: f,
@@ -2376,42 +2573,44 @@ function Yt(n) {
2376
2573
  }
2377
2574
  };
2378
2575
  }
2379
- function U(n, t = !1, e = rt) {
2576
+ function z(n, t = !1, e = nt) {
2380
2577
  const { tag: s, semantics: r } = n;
2381
2578
  let a = s;
2382
2579
  const i = [], o = { ...r.attributes };
2383
2580
  r.id && (o.id = r.id), r.role && !o.role && (o.role = r.role);
2384
- const l = Object.entries(o).map(([c, h]) => {
2385
- const g = tt(c), f = c === "href" || c === "src" ? _(c, h) : h;
2386
- return { name: c, value: f, priority: g };
2387
- }).filter((c) => ["style", "xmlns", "tabindex", "contenteditable"].includes(c.name) || B.has(c.name) && G(c.value) ? !1 : c.priority > 0 || c.name === "role" || c.name === "id");
2388
- l.sort((c, h) => h.priority - c.priority);
2389
- const u = l.slice(0, e.maxAttributes);
2390
- u.sort((c, h) => c.name.localeCompare(h.name));
2391
- for (const { name: c, value: h } of u)
2392
- i.push(`${c}="${j(h)}"`);
2393
- if (e.includeText && r.text && !Qt(r.text.normalized)) {
2394
- const c = r.text.normalized;
2395
- c.length > 0 && c.length <= e.maxTextLength && i.push(`text="${j(c)}"`);
2581
+ const c = Object.entries(o).map(([l, h]) => {
2582
+ const g = st(l), f = l === "href" || l === "src" ? q(l, h) : h;
2583
+ return { name: l, value: f, priority: g };
2584
+ }).filter((l) => l.name !== "id" && l.name !== "class" && B.has(l.name) || G.has(l.name) && V(l.value) ? !1 : l.priority > 0 || l.name === "role" || l.name === "id");
2585
+ c.sort((l, h) => h.priority - l.priority);
2586
+ const u = c.slice(0, e.maxAttributes);
2587
+ u.sort((l, h) => l.name.localeCompare(h.name));
2588
+ for (const { name: l, value: h } of u)
2589
+ i.push(`${l}="${j(h)}"`);
2590
+ if (e.includeText && r.text && !Zt(r.text.normalized)) {
2591
+ const l = r.text.normalized;
2592
+ l.length > 0 && l.length <= e.maxTextLength && i.push(`text="${j(l)}"`);
2396
2593
  }
2397
2594
  let d = i;
2398
- if (i.length > 0 && (t && e.simplifyTarget && r.id && (d = i.filter((c) => {
2399
- const h = c.split("=")[0];
2400
- return tt(h) >= 60 || h === "text" || h === "id" || h === "role";
2401
- })), d.length > 0 && d.sort((c, h) => c.localeCompare(h))), r.classes && r.classes.length > 0) {
2402
- const c = N(r.classes), h = !!r.id || i.some((f) => f.startsWith("href=") || f.startsWith("data-testid=") || f.startsWith("text=") || f.startsWith("role="));
2403
- if (!(t && e.simplifyTarget && h) && c.length > 0) {
2404
- const f = c.sort().slice(0, e.maxClasses);
2405
- a += f.map((p) => `.${p}`).join("");
2595
+ if (i.length > 0 && (t && e.simplifyTarget && r.id && (d = i.filter((l) => {
2596
+ const h = l.split("=")[0];
2597
+ return st(h) >= 60 || h === "text" || h === "id" || h === "role";
2598
+ })), d.length > 0 && d.sort((l, h) => l.localeCompare(h))), r.classes && r.classes.length > 0) {
2599
+ const l = M(r.classes), h = !!r.id || i.some(
2600
+ (f) => f.startsWith("href=") || f.startsWith("data-testid=") || f.startsWith("text=") || f.startsWith("role=")
2601
+ );
2602
+ if (!(t && e.simplifyTarget && h) && l.length > 0) {
2603
+ const f = l.sort().slice(0, e.maxClasses);
2604
+ a += f.map((m) => `.${m}`).join("");
2406
2605
  }
2407
2606
  }
2408
2607
  if (d.length > 0 && (a += `[${d.join(",")}]`), "nthChild" in n && n.nthChild) {
2409
- const c = !!r.id || r.attributes && Object.keys(r.attributes).some(Vt);
2410
- t && e.simplifyTarget && c || (a += `#${n.nthChild}`);
2608
+ const l = !!r.id || r.attributes && Object.keys(r.attributes).some(Qt);
2609
+ t && e.simplifyTarget && l || (a += `#${n.nthChild}`);
2411
2610
  }
2412
2611
  return a;
2413
2612
  }
2414
- function Xt(n) {
2613
+ function Kt(n) {
2415
2614
  if (!n.constraints || n.constraints.length === 0)
2416
2615
  return "";
2417
2616
  const t = [];
@@ -2444,20 +2643,20 @@ function F(n, t) {
2444
2643
  for (; o = e.match(/^\.([a-zA-Z][a-zA-Z0-9-_]*)/); )
2445
2644
  i.push(o[1]), e = e.slice(o[0].length);
2446
2645
  i.length > 0 && (s.classes = i);
2447
- const l = e.match(/^\[([^\]]+)\]/);
2448
- if (l) {
2449
- const c = l[1], h = {}, g = Jt(c);
2646
+ const c = e.match(/^\[([^\]]+)\]/);
2647
+ if (c) {
2648
+ const l = c[1], h = {}, g = te(l);
2450
2649
  for (const f of g) {
2451
- const p = f.match(/^([a-z][a-z0-9-]*)(?:=|~=)"((?:[^"\\]|\\.)*)"/);
2452
- if (p) {
2453
- const [, m, b] = p;
2454
- h[m] = nt(b);
2650
+ const m = f.match(/^([a-z][a-z0-9-]*)(?:=|~=)"((?:[^"\\]|\\.)*)"/);
2651
+ if (m) {
2652
+ const [, p, S] = m;
2653
+ h[p] = at(S);
2455
2654
  }
2456
2655
  }
2457
2656
  Object.keys(h).length > 0 && (h.text && (s.text = {
2458
2657
  raw: h.text,
2459
2658
  normalized: h.text
2460
- }, delete h.text), h.id && (s.id = h.id, delete h.id), h.role && (s.role = h.role, delete h.role), Object.keys(h).length > 0 && (s.attributes = h)), e = e.slice(l[0].length);
2659
+ }, delete h.text), h.id && (s.id = h.id, delete h.id), h.role && (s.role = h.role, delete h.role), Object.keys(h).length > 0 && (s.attributes = h)), e = e.slice(c[0].length);
2461
2660
  }
2462
2661
  let u;
2463
2662
  const d = e.match(/^#(\d+)/);
@@ -2475,7 +2674,7 @@ function F(n, t) {
2475
2674
  nthChild: u
2476
2675
  };
2477
2676
  }
2478
- function Kt(n) {
2677
+ function Jt(n) {
2479
2678
  if (!n.trim())
2480
2679
  return [];
2481
2680
  const t = [], e = n.split(",").map((s) => s.trim());
@@ -2500,22 +2699,23 @@ function Kt(n) {
2500
2699
  priority: 70
2501
2700
  });
2502
2701
  break;
2503
- case "text":
2702
+ case "text": {
2504
2703
  const i = a.replace(/^"(.*)"$/, "$1");
2505
2704
  t.push({
2506
2705
  type: "text-proximity",
2507
2706
  params: {
2508
- reference: nt(i),
2707
+ reference: at(i),
2509
2708
  maxDistance: 5
2510
2709
  },
2511
2710
  priority: 60
2512
2711
  });
2513
2712
  break;
2713
+ }
2514
2714
  }
2515
2715
  }
2516
2716
  return t;
2517
2717
  }
2518
- function Jt(n) {
2718
+ function te(n) {
2519
2719
  const t = [];
2520
2720
  let e = "", s = !1;
2521
2721
  for (let r = 0; r < n.length; r++) {
@@ -2527,36 +2727,28 @@ function Jt(n) {
2527
2727
  function j(n) {
2528
2728
  return n.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/>/g, "\\>").replace(/:/g, "\\:");
2529
2729
  }
2530
- function nt(n) {
2730
+ function at(n) {
2531
2731
  return n.replace(/\\\\/g, "\0").replace(/\\"/g, '"').replace(/\\>/g, ">").replace(/\\:/g, ":").replace(/\x00/g, "\\");
2532
2732
  }
2533
- function le(n, t, e) {
2534
- const s = Z(n, t);
2535
- return s ? Zt(s, e) : null;
2536
- }
2537
2733
  function he(n, t, e) {
2734
+ const s = Y(n, t);
2735
+ return s ? Yt(s, e) : null;
2736
+ }
2737
+ function ue(n, t, e) {
2538
2738
  try {
2539
- const s = Yt(n);
2540
- return Bt(s, t, e).elements || [];
2739
+ const s = Xt(n);
2740
+ return Gt(s, t, e).elements || [];
2541
2741
  } catch (s) {
2542
2742
  return console.error("Failed to resolve SEQL Selector:", s), [];
2543
2743
  }
2544
2744
  }
2545
- const te = /* @__PURE__ */ new Set([
2546
- "script",
2547
- "style",
2548
- "noscript",
2549
- "meta",
2550
- "link",
2551
- "head",
2552
- "title"
2553
- ]);
2745
+ const ee = /* @__PURE__ */ new Set(["script", "style", "noscript", "meta", "link", "head", "title"]);
2554
2746
  function W(n) {
2555
2747
  return n.id && !D(n.id) ? 3 : n.hasAttribute("role") || n.hasAttribute("aria-label") || n.hasAttribute("aria-labelledby") || n.hasAttribute("data-testid") || n.hasAttribute("data-qa") || n.hasAttribute("data-test") ? 2 : 1;
2556
2748
  }
2557
- function at(n, t) {
2749
+ function it(n, t) {
2558
2750
  const e = n.tagName.toLowerCase();
2559
- return !!(te.has(e) || t && W(n) === 1 && ![
2751
+ return !!(ee.has(e) || t && W(n) === 1 && ![
2560
2752
  "form",
2561
2753
  "main",
2562
2754
  "nav",
@@ -2572,13 +2764,13 @@ function at(n, t) {
2572
2764
  "textarea"
2573
2765
  ].includes(e));
2574
2766
  }
2575
- function it(n) {
2767
+ function ot(n) {
2576
2768
  return [...n].sort((t, e) => {
2577
2769
  const s = W(t);
2578
2770
  return W(e) - s;
2579
2771
  });
2580
2772
  }
2581
- function ue(n = {}) {
2773
+ function de(n = {}) {
2582
2774
  const t = performance.now(), {
2583
2775
  root: e = typeof document < "u" ? document.body : void 0,
2584
2776
  filter: s = "*",
@@ -2586,13 +2778,13 @@ function ue(n = {}) {
2586
2778
  onProgress: a,
2587
2779
  progressInterval: i = 100,
2588
2780
  skipNonSemantic: o = !0,
2589
- generatorOptions: l = {},
2781
+ generatorOptions: c = {},
2590
2782
  cache: u,
2591
2783
  signal: d
2592
2784
  } = n;
2593
2785
  if (!e)
2594
2786
  throw new Error("Root element or document is required");
2595
- const c = u ?? Q(), h = { ...l, cache: c };
2787
+ const l = u ?? Z(), h = { ...c, cache: l };
2596
2788
  let g;
2597
2789
  try {
2598
2790
  e instanceof Document, g = Array.from(e.querySelectorAll(s));
@@ -2611,148 +2803,144 @@ function ue(n = {}) {
2611
2803
  }
2612
2804
  };
2613
2805
  }
2614
- const f = g.filter(
2615
- (x) => !at(x, o)
2616
- ), m = it(f).slice(0, r), b = [], y = [];
2617
- let v = 0;
2618
- const A = m.length;
2619
- let S = 0;
2620
- for (let x = 0; x < m.length && !d?.aborted; x++) {
2621
- const T = m[x], R = c.getEID(T);
2622
- if (R)
2623
- b.push({
2624
- element: T,
2625
- eid: R,
2806
+ const f = g.filter((C) => !it(C, o)), p = ot(f).slice(0, r), S = [], y = [];
2807
+ let w = 0;
2808
+ const x = p.length;
2809
+ let b = 0;
2810
+ for (let C = 0; C < p.length && !d?.aborted; C++) {
2811
+ const v = p[C], A = l.getEID(v);
2812
+ if (A)
2813
+ S.push({
2814
+ element: v,
2815
+ eid: A,
2626
2816
  generationTimeMs: 0
2627
2817
  // Cached, no generation time
2628
2818
  });
2629
2819
  else {
2630
- const z = performance.now();
2820
+ const U = performance.now();
2631
2821
  try {
2632
- const P = Z(T, h), ot = performance.now() - z;
2633
- P ? b.push({
2634
- element: T,
2822
+ const P = Y(v, h), ct = performance.now() - U;
2823
+ P ? S.push({
2824
+ element: v,
2635
2825
  eid: P,
2636
- generationTimeMs: ot
2637
- }) : v++;
2826
+ generationTimeMs: ct
2827
+ }) : w++;
2638
2828
  } catch (P) {
2639
2829
  y.push({
2640
- element: T,
2830
+ element: v,
2641
2831
  error: P instanceof Error ? P.message : String(P)
2642
2832
  });
2643
2833
  }
2644
2834
  }
2645
- a && x - S >= i && (a(x + 1, A), S = x);
2835
+ a && C - b >= i && (a(C + 1, x), b = C);
2646
2836
  }
2647
- a && a(A, A);
2648
- const $ = performance.now() - t, M = c.getStats(), H = M.eidHits + M.eidMisses + M.selectorHits + M.selectorMisses, E = M.eidHits + M.selectorHits, C = H > 0 ? E / H : 0;
2837
+ a && a(x, x);
2838
+ const $ = performance.now() - t, I = l.getStats(), H = I.eidHits + I.eidMisses + I.selectorHits + I.selectorMisses, T = I.eidHits + I.selectorHits, R = H > 0 ? T / H : 0;
2649
2839
  return {
2650
- results: b,
2840
+ results: S,
2651
2841
  failed: y,
2652
2842
  stats: {
2653
- totalElements: A,
2654
- successful: b.length,
2843
+ totalElements: x,
2844
+ successful: S.length,
2655
2845
  failed: y.length,
2656
- skipped: v,
2846
+ skipped: w,
2657
2847
  totalTimeMs: $,
2658
- avgTimePerElementMs: b.length > 0 ? $ / b.length : 0,
2659
- cacheHitRate: C
2848
+ avgTimePerElementMs: S.length > 0 ? $ / S.length : 0,
2849
+ cacheHitRate: R
2660
2850
  }
2661
2851
  };
2662
2852
  }
2663
- function de(n, t = {}) {
2853
+ function fe(n, t = {}) {
2664
2854
  const e = performance.now(), {
2665
2855
  limit: s = 1 / 0,
2666
2856
  onProgress: r,
2667
2857
  progressInterval: a = 100,
2668
2858
  skipNonSemantic: i = !0,
2669
2859
  generatorOptions: o = {},
2670
- cache: l,
2860
+ cache: c,
2671
2861
  signal: u
2672
- } = t, d = l ?? Q(), c = { ...o, cache: d }, h = n.filter(
2673
- (E) => !at(E, i)
2674
- ), f = it(h).slice(0, s), p = [], m = [];
2675
- let b = 0;
2862
+ } = t, d = c ?? Z(), l = { ...o, cache: d }, h = n.filter((T) => !it(T, i)), f = ot(h).slice(0, s), m = [], p = [];
2863
+ let S = 0;
2676
2864
  const y = f.length;
2677
- let v = 0;
2678
- for (let E = 0; E < f.length && !u?.aborted; E++) {
2679
- const C = f[E], x = d.getEID(C);
2680
- if (x)
2681
- p.push({
2682
- element: C,
2683
- eid: x,
2865
+ let w = 0;
2866
+ for (let T = 0; T < f.length && !u?.aborted; T++) {
2867
+ const R = f[T], C = d.getEID(R);
2868
+ if (C)
2869
+ m.push({
2870
+ element: R,
2871
+ eid: C,
2684
2872
  generationTimeMs: 0
2685
2873
  });
2686
2874
  else {
2687
- const T = performance.now();
2875
+ const v = performance.now();
2688
2876
  try {
2689
- const R = Z(C, c), z = performance.now() - T;
2690
- R ? p.push({
2691
- element: C,
2692
- eid: R,
2693
- generationTimeMs: z
2694
- }) : b++;
2695
- } catch (R) {
2696
- m.push({
2697
- element: C,
2698
- error: R instanceof Error ? R.message : String(R)
2877
+ const A = Y(R, l), U = performance.now() - v;
2878
+ A ? m.push({
2879
+ element: R,
2880
+ eid: A,
2881
+ generationTimeMs: U
2882
+ }) : S++;
2883
+ } catch (A) {
2884
+ p.push({
2885
+ element: R,
2886
+ error: A instanceof Error ? A.message : String(A)
2699
2887
  });
2700
2888
  }
2701
2889
  }
2702
- r && E - v >= a && (r(E + 1, y), v = E);
2890
+ r && T - w >= a && (r(T + 1, y), w = T);
2703
2891
  }
2704
2892
  r && r(y, y);
2705
- const A = performance.now() - e, S = d.getStats(), $ = S.eidHits + S.eidMisses + S.selectorHits + S.selectorMisses, M = S.eidHits + S.selectorHits, H = $ > 0 ? M / $ : 0;
2893
+ const x = performance.now() - e, b = d.getStats(), $ = b.eidHits + b.eidMisses + b.selectorHits + b.selectorMisses, I = b.eidHits + b.selectorHits, H = $ > 0 ? I / $ : 0;
2706
2894
  return {
2707
- results: p,
2708
- failed: m,
2895
+ results: m,
2896
+ failed: p,
2709
2897
  stats: {
2710
2898
  totalElements: y,
2711
- successful: p.length,
2712
- failed: m.length,
2713
- skipped: b,
2714
- totalTimeMs: A,
2715
- avgTimePerElementMs: p.length > 0 ? A / p.length : 0,
2899
+ successful: m.length,
2900
+ failed: p.length,
2901
+ skipped: S,
2902
+ totalTimeMs: x,
2903
+ avgTimePerElementMs: m.length > 0 ? x / m.length : 0,
2716
2904
  cacheHitRate: H
2717
2905
  }
2718
2906
  };
2719
2907
  }
2720
2908
  export {
2721
- ft as AnchorFinder,
2722
- jt as ConstraintsEvaluator,
2723
- st as CssGenerator,
2724
- ut as DEFAULT_GENERATOR_OPTIONS,
2725
- dt as DEFAULT_RESOLVER_OPTIONS,
2726
- Lt as EIDCache,
2727
- ee as EID_VERSION,
2728
- Wt as FallbackHandler,
2729
- se as MAX_PATH_DEPTH,
2730
- xt as PathBuilder,
2731
- X as ROLE_ANCHOR_VALUES,
2732
- Y as SEMANTIC_ANCHOR_TAGS,
2733
- re as SEMANTIC_ATTRIBUTES,
2734
- lt as SEMANTIC_TAGS,
2735
- Pt as SemanticExtractor,
2736
- Ft as SemanticsMatcher,
2737
- _t as SvgFingerprinter,
2738
- kt as calculateConfidence,
2739
- ae as calculateElementScore,
2909
+ gt as AnchorFinder,
2910
+ Wt as ConstraintsEvaluator,
2911
+ rt as CssGenerator,
2912
+ dt as DEFAULT_GENERATOR_OPTIONS,
2913
+ ft as DEFAULT_RESOLVER_OPTIONS,
2914
+ _t as EIDCache,
2915
+ se as EID_VERSION,
2916
+ Bt as FallbackHandler,
2917
+ re as MAX_PATH_DEPTH,
2918
+ Ct as PathBuilder,
2919
+ K as ROLE_ANCHOR_VALUES,
2920
+ X as SEMANTIC_ANCHOR_TAGS,
2921
+ ne as SEMANTIC_ATTRIBUTES,
2922
+ ht as SEMANTIC_TAGS,
2923
+ et as SemanticExtractor,
2924
+ jt as SemanticsMatcher,
2925
+ qt as SvgFingerprinter,
2926
+ Lt as calculateConfidence,
2927
+ ie as calculateElementScore,
2740
2928
  Ot as createEIDCache,
2741
- At as filterClasses,
2742
- Z as generateEID,
2743
- ue as generateEIDBatch,
2744
- de as generateEIDForElements,
2745
- le as generateSEQL,
2746
- ne as getClassScore,
2747
- Q as getGlobalCache,
2748
- ce as isEID,
2749
- K as isUtilityClass,
2750
- V as normalizeText,
2751
- Yt as parseSEQL,
2752
- ie as resetGlobalCache,
2753
- Bt as resolve,
2754
- he as resolveSEQL,
2755
- Zt as stringifySEQL,
2756
- oe as validateEID
2929
+ xt as filterClasses,
2930
+ Y as generateEID,
2931
+ de as generateEIDBatch,
2932
+ fe as generateEIDForElements,
2933
+ he as generateSEQL,
2934
+ ae as getClassScore,
2935
+ Z as getGlobalCache,
2936
+ le as isEID,
2937
+ J as isUtilityClass,
2938
+ Q as normalizeText,
2939
+ Xt as parseSEQL,
2940
+ oe as resetGlobalCache,
2941
+ Gt as resolve,
2942
+ ue as resolveSEQL,
2943
+ Yt as stringifySEQL,
2944
+ ce as validateEID
2757
2945
  };
2758
2946
  //# sourceMappingURL=seql-js.js.map