@whenessel/seql-js 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/seql-js.js CHANGED
@@ -14,7 +14,7 @@ const ee = "1.0", se = 10, L = {
14
14
  DEGRADED_SCORE: 0.3
15
15
  }, ct = {
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",
@@ -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",
@@ -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,7 +203,7 @@ 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
209
  class ft {
@@ -250,9 +250,9 @@ class ft {
250
250
  scoreAnchor(t) {
251
251
  let e = 0;
252
252
  const s = t.tagName.toLowerCase();
253
- Y.includes(s) && (e += I.SEMANTIC_TAG);
253
+ X.includes(s) && (e += I.SEMANTIC_TAG);
254
254
  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);
255
+ r && K.includes(r) && (e += I.ROLE), (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) && (e += I.ARIA_LABEL);
256
256
  const a = t.id;
257
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);
258
258
  }
@@ -271,10 +271,10 @@ class ft {
271
271
  */
272
272
  getTier(t) {
273
273
  const e = t.tagName.toLowerCase();
274
- if (Y.includes(e))
274
+ if (X.includes(e))
275
275
  return "A";
276
276
  const s = t.getAttribute("role");
277
- return s && X.includes(s) ? "B" : "C";
277
+ return s && K.includes(s) ? "B" : "C";
278
278
  }
279
279
  }
280
280
  const gt = [
@@ -430,23 +430,23 @@ const gt = [
430
430
  // === Status ===
431
431
  /^(loading|pending|complete|failed|draft|published)/
432
432
  ];
433
- function k(n) {
433
+ function _(n) {
434
434
  return gt.some((t) => t.test(n));
435
435
  }
436
436
  function q(n) {
437
437
  return n.length <= 2 || /^\d/.test(n) ? !0 : pt.some((t) => t.test(n));
438
438
  }
439
439
  function bt(n) {
440
- return k(n) || q(n) ? !1 : mt.some((t) => t.test(n));
440
+ return _(n) || q(n) ? !1 : mt.some((t) => t.test(n));
441
441
  }
442
442
  function St(n) {
443
- return !k(n) && !q(n);
443
+ return !_(n) && !q(n);
444
444
  }
445
445
  function N(n) {
446
446
  return n.filter((t) => St(t));
447
447
  }
448
448
  function yt(n) {
449
- if (k(n) || q(n))
449
+ if (_(n) || q(n))
450
450
  return 0;
451
451
  let t = 0.5;
452
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);
@@ -454,16 +454,16 @@ function yt(n) {
454
454
  function At(n) {
455
455
  const t = [], e = [];
456
456
  for (const s of n)
457
- q(s) || k(s) ? e.push(s) : t.push(s);
457
+ q(s) || _(s) ? e.push(s) : t.push(s);
458
458
  return { semantic: t, utility: e };
459
459
  }
460
- function K(n) {
461
- return q(n) || k(n);
460
+ function J(n) {
461
+ return q(n) || _(n);
462
462
  }
463
463
  function ne(n) {
464
464
  return yt(n);
465
465
  }
466
- const J = (n) => n.replace(/([#:.[\]@])/g, "\\$1");
466
+ const tt = (n) => n.replace(/([#:.[\]@])/g, "\\$1");
467
467
  class xt {
468
468
  constructor(t, e) {
469
469
  this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
@@ -482,13 +482,7 @@ class xt {
482
482
  r.unshift(a), a = a.parentElement;
483
483
  const i = r.length >= this.maxDepth && a !== t;
484
484
  let o = this.filterNoise(r);
485
- return o = this.ensureUniqueness(
486
- r,
487
- o,
488
- t,
489
- e,
490
- s
491
- ), {
485
+ return o = this.ensureUniqueness(r, o, t, e, s), {
492
486
  path: o.map((u) => {
493
487
  const d = u.parentElement;
494
488
  let c;
@@ -578,9 +572,9 @@ class xt {
578
572
  */
579
573
  elementToSelector(t) {
580
574
  let e = t.tagName.toLowerCase();
581
- t.id && !D(t.id) && (e += `#${J(t.id)}`);
575
+ t.id && !D(t.id) && (e += `#${tt(t.id)}`);
582
576
  for (const s of Array.from(t.classList))
583
- K(s) || (e += `.${J(s)}`);
577
+ J(s) || (e += `.${tt(s)}`);
584
578
  return e;
585
579
  }
586
580
  /**
@@ -605,7 +599,7 @@ class xt {
605
599
  if (s.name.startsWith("aria-")) return !0;
606
600
  if (t.classList.length > 0) {
607
601
  for (const s of Array.from(t.classList))
608
- if (!K(s)) return !0;
602
+ if (!J(s)) return !0;
609
603
  }
610
604
  if (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test"))
611
605
  return !0;
@@ -613,7 +607,7 @@ class xt {
613
607
  return !!(e && !D(e));
614
608
  }
615
609
  }
616
- function V(n) {
610
+ function Q(n) {
617
611
  return n ? n.trim().replace(/[\n\t\r]/g, " ").replace(/\s+/g, " ") : "";
618
612
  }
619
613
  const Ct = {
@@ -636,13 +630,11 @@ function Tt(n) {
636
630
  }
637
631
  function Et(n, t) {
638
632
  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("?");
633
+ const e = n.startsWith("http://") || n.startsWith("https://"), [s, r] = n.split("#"), [a, i] = s.split("?");
642
634
  let o = a;
643
635
  return e && t.preserveQueryForAbsolute && i && (o += `?${i}`), r && (t.removeDynamicHashes && Tt(r) || (o += `#${r}`)), o;
644
636
  }
645
- function _(n, t, e = {}) {
637
+ function k(n, t, e = {}) {
646
638
  if (!t) return t;
647
639
  const s = { ...Ct, ...e };
648
640
  return n === "href" || n === "src" ? Et(t, s) : t;
@@ -787,7 +779,7 @@ class Pt {
787
779
  * @returns True if should be ignored
788
780
  */
789
781
  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-"));
782
+ 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
783
  }
792
784
  /**
793
785
  * Gets attribute priority
@@ -822,8 +814,8 @@ class Pt {
822
814
  const e = {};
823
815
  for (const s of Array.from(t.attributes)) {
824
816
  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;
817
+ if (this.shouldIgnoreAttribute(r) || !Ht(r, s.value) || G.has(r) && V(s.value) || this.getAttributePriority(r) === 0) continue;
818
+ const i = r === "href" || r === "src" ? k(r, s.value) : s.value;
827
819
  !i || i.trim() === "" || this.isDynamicValue(i) || (e[r] = i);
828
820
  }
829
821
  return e;
@@ -834,7 +826,7 @@ class Pt {
834
826
  extractText(t) {
835
827
  const e = this.getDirectTextContent(t);
836
828
  if (!e) return null;
837
- const s = V(e);
829
+ const s = Q(e);
838
830
  if (!s) return null;
839
831
  const r = 100, a = e.length > r ? e.slice(0, r) + "..." : e, i = s.length > r ? s.slice(0, r) + "..." : s;
840
832
  return {
@@ -882,7 +874,7 @@ class Pt {
882
874
  ].includes(e);
883
875
  }
884
876
  }
885
- class _t {
877
+ class kt {
886
878
  /**
887
879
  * Generates fingerprint for SVG element
888
880
  * @param element - SVG element to fingerprint
@@ -993,7 +985,7 @@ class _t {
993
985
  return Math.abs(e).toString(16).padStart(8, "0");
994
986
  }
995
987
  }
996
- function kt(n, t = 0) {
988
+ function _t(n, t = 0) {
997
989
  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;
998
990
  return Math.max(0, Math.min(1, a - i));
999
991
  }
@@ -1006,9 +998,9 @@ class qt {
1006
998
  this.cache = /* @__PURE__ */ new Map(), this.maxSize = t;
1007
999
  }
1008
1000
  get(t) {
1009
- if (!this.cache.has(t)) return;
1010
1001
  const e = this.cache.get(t);
1011
- return this.cache.delete(t), this.cache.set(t, e), e;
1002
+ if (e !== void 0)
1003
+ return this.cache.delete(t), this.cache.set(t, e), e;
1012
1004
  }
1013
1005
  set(t, e) {
1014
1006
  if (this.cache.has(t))
@@ -1187,19 +1179,19 @@ function Ot(n) {
1187
1179
  return new Lt(n);
1188
1180
  }
1189
1181
  let O = null;
1190
- function Q() {
1182
+ function Z() {
1191
1183
  return O || (O = Ot()), O;
1192
1184
  }
1193
1185
  function ie() {
1194
1186
  O = null;
1195
1187
  }
1196
- function Z(n, t = {}) {
1188
+ function Y(n, t = {}) {
1197
1189
  if (!n || !n.ownerDocument || !n.isConnected)
1198
1190
  return null;
1199
- const e = { ...ut, ...t }, s = e.cache ?? Q(), r = s.getEID(n);
1191
+ const e = { ...ut, ...t }, s = e.cache ?? Z(), r = s.getEID(n);
1200
1192
  if (r !== void 0)
1201
1193
  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);
1194
+ const a = new ft(e, s), i = new xt(e, s), o = new Pt(e, s), l = new kt(), u = a.findAnchor(n);
1203
1195
  if (!u && !e.fallbackToBody)
1204
1196
  return null;
1205
1197
  const d = u?.element ?? n.ownerDocument?.body ?? null;
@@ -1216,11 +1208,7 @@ function Z(n, t = {}) {
1216
1208
  score: u?.score ?? I.DEGRADED_SCORE,
1217
1209
  degraded: c,
1218
1210
  nthChild: f
1219
- }, b = i.buildPath(
1220
- d,
1221
- n,
1222
- o
1223
- ), y = o.extract(n);
1211
+ }, b = i.buildPath(d, n, o), y = o.extract(n);
1224
1212
  e.enableSvgFingerprint && zt(n) && (y.svg = l.fingerprint(n));
1225
1213
  const v = n.parentElement;
1226
1214
  let A;
@@ -1237,7 +1225,7 @@ function Z(n, t = {}) {
1237
1225
  onMultiple: "best-score",
1238
1226
  onMissing: "anchor-only",
1239
1227
  maxDepth: 3
1240
- }, H = m.degraded || b.degraded, E = Ut(m.degraded, b), C = {
1228
+ }, H = m.degraded || b.degraded, E = Ut(m.degraded, b), x = {
1241
1229
  version: "1.0",
1242
1230
  anchor: m,
1243
1231
  path: b.path,
@@ -1254,7 +1242,7 @@ function Z(n, t = {}) {
1254
1242
  degradationReason: E
1255
1243
  }
1256
1244
  };
1257
- return C.meta.confidence = kt(C), C.meta.confidence < e.confidenceThreshold ? null : (s.setEID(n, C), C);
1245
+ return x.meta.confidence = _t(x), x.meta.confidence < e.confidenceThreshold ? null : (s.setEID(n, x), x);
1258
1246
  }
1259
1247
  function zt(n) {
1260
1248
  return n.namespaceURI === "http://www.w3.org/2000/svg" || n.tagName.toLowerCase() === "svg" || n instanceof SVGElement;
@@ -1326,11 +1314,7 @@ class st {
1326
1314
  extraClassesAdded: 0
1327
1315
  };
1328
1316
  }
1329
- return this.ensureUniqueSelector(
1330
- u,
1331
- t,
1332
- e
1333
- );
1317
+ return this.ensureUniqueSelector(u, t, e);
1334
1318
  }
1335
1319
  /**
1336
1320
  * Builds selector for anchor only (used in fallback)
@@ -1400,11 +1384,7 @@ class st {
1400
1384
  const r = this.buildNodeSelector(t.anchor.tag, t.anchor.semantics), a = this.querySelectorSafe(r, s);
1401
1385
  if (a.length === 0) return null;
1402
1386
  for (const i of a) {
1403
- const o = this.findTargetWithinAnchor(
1404
- i,
1405
- t.target.tag,
1406
- e
1407
- );
1387
+ const o = this.findTargetWithinAnchor(i, t.target.tag, e);
1408
1388
  if (o.length === 0) continue;
1409
1389
  const l = o.map((u) => {
1410
1390
  const d = this.scorePathMatch(u, i, t.path);
@@ -1412,12 +1392,7 @@ class st {
1412
1392
  });
1413
1393
  l.sort((u, d) => d.score - u.score);
1414
1394
  for (const { element: u } of l) {
1415
- const d = this.buildPathFromAnchorToTarget(
1416
- i,
1417
- u,
1418
- t,
1419
- s
1420
- );
1395
+ const d = this.buildPathFromAnchorToTarget(i, u, t, s);
1421
1396
  if (d && this.isUnique(d, s))
1422
1397
  return d;
1423
1398
  }
@@ -1474,14 +1449,10 @@ class st {
1474
1449
  if (!i.includes(o) && !o.includes(i))
1475
1450
  return !1;
1476
1451
  }
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);
1452
+ return !!(s.classes && s.classes.length > 0 && s.classes.every((o) => a.classList.contains(o)) || s.attributes && Object.entries(s.attributes).every(([o, l]) => {
1453
+ const u = a.getAttribute(o);
1454
+ return o === "href" || o === "src" ? k(o, u || "") === k(o, l) : u === l;
1455
+ }) || s.text);
1485
1456
  });
1486
1457
  }
1487
1458
  /**
@@ -1511,9 +1482,7 @@ class st {
1511
1482
  }
1512
1483
  }
1513
1484
  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;
1485
+ return i && Array.from(i.children).filter((l) => l.tagName.toLowerCase() === e).length > 1 ? `${e}${this.getNthSelector(t, e)}` : e;
1517
1486
  }
1518
1487
  /**
1519
1488
  * Builds CSS selector path from anchor to target by traversing actual DOM
@@ -1540,7 +1509,11 @@ class st {
1540
1509
  const f = this.buildNodeSelector(u, d, {
1541
1510
  excludeClasses: !0
1542
1511
  // KEY: no classes on target in Strategy 0
1543
- }), p = [l, ...c.slice(0, -1), f].join(" ");
1512
+ }), p = [
1513
+ l,
1514
+ ...c.slice(0, -1),
1515
+ f
1516
+ ].join(" ");
1544
1517
  return this.isUnique(p, r) ? p : null;
1545
1518
  },
1546
1519
  // ============================================================
@@ -1678,7 +1651,6 @@ class st {
1678
1651
  * @param element The DOM element to create a selector for
1679
1652
  * @returns A minimal CSS selector for the element
1680
1653
  */
1681
- // @ts-ignore: Method is used dynamically in buildPathFromAnchorToTarget
1682
1654
  buildElementSelector(t) {
1683
1655
  const e = t.tagName.toLowerCase();
1684
1656
  let s = e;
@@ -1732,9 +1704,7 @@ class st {
1732
1704
  getNthOfTypeIndex(t, e) {
1733
1705
  const s = t.parentElement;
1734
1706
  if (!s) return null;
1735
- const a = Array.from(s.children).filter(
1736
- (i) => i.tagName.toLowerCase() === e
1737
- ).indexOf(t);
1707
+ const a = Array.from(s.children).filter((i) => i.tagName.toLowerCase() === e).indexOf(t);
1738
1708
  return a !== -1 ? a + 1 : null;
1739
1709
  }
1740
1710
  /**
@@ -1759,7 +1729,7 @@ class st {
1759
1729
  if (r.attributes) {
1760
1730
  const i = this.getSortedAttributes(r.attributes);
1761
1731
  for (const { name: o, value: l } of i) {
1762
- const u = o === "href" || o === "src" ? _(o, l) : l;
1732
+ const u = o === "href" || o === "src" ? k(o, l) : l;
1763
1733
  if (u) {
1764
1734
  const d = `${s}[${o}="${this.escapeAttr(u)}"]`;
1765
1735
  if (this.isUnique(d, e))
@@ -1791,9 +1761,7 @@ class st {
1791
1761
  */
1792
1762
  findElementBySemantics(t, e) {
1793
1763
  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(
1764
+ if (e.classes && e.classes.length > 0 && e.classes.every((i) => r.classList.contains(i)) || e.attributes && Object.entries(e.attributes).every(
1797
1765
  ([i, o]) => r.getAttribute(i) === o
1798
1766
  ))
1799
1767
  return !0;
@@ -1833,7 +1801,7 @@ class st {
1833
1801
  * @returns True if should be ignored
1834
1802
  */
1835
1803
  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-"));
1804
+ 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
1805
  }
1838
1806
  /**
1839
1807
  * Gets attributes sorted by priority
@@ -1841,7 +1809,9 @@ class st {
1841
1809
  * @returns Sorted array of attributes with priority
1842
1810
  */
1843
1811
  getSortedAttributes(t) {
1844
- return Object.entries(t).filter(([e]) => !this.shouldIgnoreAttribute(e)).filter(([e, s]) => !B.has(e) || !G(s)).map(([e, s]) => ({
1812
+ return Object.entries(t).filter(([e]) => !this.shouldIgnoreAttribute(e)).filter(
1813
+ ([e, s]) => !G.has(e) || !V(s)
1814
+ ).map(([e, s]) => ({
1845
1815
  name: e,
1846
1816
  value: s,
1847
1817
  priority: this.getAttributePriority(e)
@@ -1858,7 +1828,7 @@ class st {
1858
1828
  if (e.attributes) {
1859
1829
  const a = this.getSortedAttributes(e.attributes);
1860
1830
  for (const { name: i, value: o } of a) {
1861
- const l = i === "href" || i === "src" ? _(i, o) : o;
1831
+ const l = i === "href" || i === "src" ? k(i, o) : o;
1862
1832
  l && (r += `[${i}="${this.escapeAttr(l)}"]`);
1863
1833
  }
1864
1834
  }
@@ -1911,9 +1881,11 @@ class Ft {
1911
1881
  * Prioritizes direct text nodes, but falls back to full textContent if no direct text
1912
1882
  */
1913
1883
  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() ?? "");
1884
+ const a = Array.from(t.childNodes).filter(
1885
+ (o) => o.nodeType === Node.TEXT_NODE
1886
+ ).map((o) => o.textContent?.trim() ?? "").join(" ") || (t.textContent?.trim() ?? "");
1915
1887
  if (!a) return !1;
1916
- const i = V(a);
1888
+ const i = Q(a);
1917
1889
  return e.matchMode === "partial" ? i.includes(e.normalized) : i === e.normalized;
1918
1890
  }
1919
1891
  /**
@@ -1999,10 +1971,7 @@ class jt {
1999
1971
  e.params
2000
1972
  );
2001
1973
  case "position":
2002
- return this.applyPosition(
2003
- t,
2004
- e.params
2005
- );
1974
+ return this.applyPosition(t, e.params);
2006
1975
  default:
2007
1976
  return t;
2008
1977
  }
@@ -2186,9 +2155,7 @@ class Wt {
2186
2155
  return {
2187
2156
  status: "success",
2188
2157
  elements: [r],
2189
- warnings: [
2190
- `Multiple matches (${t.length}), selected best-scoring element`
2191
- ],
2158
+ warnings: [`Multiple matches (${t.length}), selected best-scoring element`],
2192
2159
  confidence: e.meta.confidence * (0.7 + a * 0.2),
2193
2160
  meta: { degraded: !0, degradationReason: "best-of-multiple" }
2194
2161
  };
@@ -2218,7 +2185,7 @@ class Wt {
2218
2185
  }
2219
2186
  if (e.role && (r += 0.15, t.getAttribute("role") === e.role && (s += 0.15)), e.text) {
2220
2187
  r += 0.1;
2221
- const a = V(t.textContent);
2188
+ const a = Q(t.textContent);
2222
2189
  a === e.text.normalized ? s += 0.1 : a.includes(e.text.normalized) && (s += 0.05);
2223
2190
  }
2224
2191
  return r > 0 ? s / r : 0;
@@ -2237,10 +2204,7 @@ function Bt(n, t, e = {}) {
2237
2204
  return {
2238
2205
  status: "error",
2239
2206
  elements: [],
2240
- warnings: [
2241
- `Invalid CSS selector: ${u}`,
2242
- `Error: ${p}`
2243
- ],
2207
+ warnings: [`Invalid CSS selector: ${u}`, `Error: ${p}`],
2244
2208
  confidence: 0,
2245
2209
  meta: { degraded: !0, degradationReason: "invalid-selector" }
2246
2210
  };
@@ -2322,7 +2286,7 @@ const rt = {
2322
2286
  simplifyTarget: !0,
2323
2287
  includeConstraints: !0
2324
2288
  };
2325
- function tt(n) {
2289
+ function et(n) {
2326
2290
  return n === "id" ? 101 : w[n] !== void 0 ? w[n] : n.startsWith("data-") ? w["data-*"] : n.startsWith("aria-") ? w["aria-*"] : 0;
2327
2291
  }
2328
2292
  function Vt(n) {
@@ -2382,9 +2346,9 @@ function U(n, t = !1, e = rt) {
2382
2346
  const i = [], o = { ...r.attributes };
2383
2347
  r.id && (o.id = r.id), r.role && !o.role && (o.role = r.role);
2384
2348
  const l = Object.entries(o).map(([c, h]) => {
2385
- const g = tt(c), f = c === "href" || c === "src" ? _(c, h) : h;
2349
+ const g = et(c), f = c === "href" || c === "src" ? k(c, h) : h;
2386
2350
  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");
2351
+ }).filter((c) => c.name !== "id" && c.name !== "class" && B.has(c.name) || G.has(c.name) && V(c.value) ? !1 : c.priority > 0 || c.name === "role" || c.name === "id");
2388
2352
  l.sort((c, h) => h.priority - c.priority);
2389
2353
  const u = l.slice(0, e.maxAttributes);
2390
2354
  u.sort((c, h) => c.name.localeCompare(h.name));
@@ -2397,9 +2361,11 @@ function U(n, t = !1, e = rt) {
2397
2361
  let d = i;
2398
2362
  if (i.length > 0 && (t && e.simplifyTarget && r.id && (d = i.filter((c) => {
2399
2363
  const h = c.split("=")[0];
2400
- return tt(h) >= 60 || h === "text" || h === "id" || h === "role";
2364
+ return et(h) >= 60 || h === "text" || h === "id" || h === "role";
2401
2365
  })), 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="));
2366
+ const c = N(r.classes), h = !!r.id || i.some(
2367
+ (f) => f.startsWith("href=") || f.startsWith("data-testid=") || f.startsWith("text=") || f.startsWith("role=")
2368
+ );
2403
2369
  if (!(t && e.simplifyTarget && h) && c.length > 0) {
2404
2370
  const f = c.sort().slice(0, e.maxClasses);
2405
2371
  a += f.map((p) => `.${p}`).join("");
@@ -2500,7 +2466,7 @@ function Kt(n) {
2500
2466
  priority: 70
2501
2467
  });
2502
2468
  break;
2503
- case "text":
2469
+ case "text": {
2504
2470
  const i = a.replace(/^"(.*)"$/, "$1");
2505
2471
  t.push({
2506
2472
  type: "text-proximity",
@@ -2511,6 +2477,7 @@ function Kt(n) {
2511
2477
  priority: 60
2512
2478
  });
2513
2479
  break;
2480
+ }
2514
2481
  }
2515
2482
  }
2516
2483
  return t;
@@ -2531,7 +2498,7 @@ function nt(n) {
2531
2498
  return n.replace(/\\\\/g, "\0").replace(/\\"/g, '"').replace(/\\>/g, ">").replace(/\\:/g, ":").replace(/\x00/g, "\\");
2532
2499
  }
2533
2500
  function le(n, t, e) {
2534
- const s = Z(n, t);
2501
+ const s = Y(n, t);
2535
2502
  return s ? Zt(s, e) : null;
2536
2503
  }
2537
2504
  function he(n, t, e) {
@@ -2542,15 +2509,7 @@ function he(n, t, e) {
2542
2509
  return console.error("Failed to resolve SEQL Selector:", s), [];
2543
2510
  }
2544
2511
  }
2545
- const te = /* @__PURE__ */ new Set([
2546
- "script",
2547
- "style",
2548
- "noscript",
2549
- "meta",
2550
- "link",
2551
- "head",
2552
- "title"
2553
- ]);
2512
+ const te = /* @__PURE__ */ new Set(["script", "style", "noscript", "meta", "link", "head", "title"]);
2554
2513
  function W(n) {
2555
2514
  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
2515
  }
@@ -2592,7 +2551,7 @@ function ue(n = {}) {
2592
2551
  } = n;
2593
2552
  if (!e)
2594
2553
  throw new Error("Root element or document is required");
2595
- const c = u ?? Q(), h = { ...l, cache: c };
2554
+ const c = u ?? Z(), h = { ...l, cache: c };
2596
2555
  let g;
2597
2556
  try {
2598
2557
  e instanceof Document, g = Array.from(e.querySelectorAll(s));
@@ -2611,14 +2570,12 @@ function ue(n = {}) {
2611
2570
  }
2612
2571
  };
2613
2572
  }
2614
- const f = g.filter(
2615
- (x) => !at(x, o)
2616
- ), m = it(f).slice(0, r), b = [], y = [];
2573
+ const f = g.filter((C) => !at(C, o)), m = it(f).slice(0, r), b = [], y = [];
2617
2574
  let v = 0;
2618
2575
  const A = m.length;
2619
2576
  let S = 0;
2620
- for (let x = 0; x < m.length && !d?.aborted; x++) {
2621
- const T = m[x], R = c.getEID(T);
2577
+ for (let C = 0; C < m.length && !d?.aborted; C++) {
2578
+ const T = m[C], R = c.getEID(T);
2622
2579
  if (R)
2623
2580
  b.push({
2624
2581
  element: T,
@@ -2629,7 +2586,7 @@ function ue(n = {}) {
2629
2586
  else {
2630
2587
  const z = performance.now();
2631
2588
  try {
2632
- const P = Z(T, h), ot = performance.now() - z;
2589
+ const P = Y(T, h), ot = performance.now() - z;
2633
2590
  P ? b.push({
2634
2591
  element: T,
2635
2592
  eid: P,
@@ -2642,10 +2599,10 @@ function ue(n = {}) {
2642
2599
  });
2643
2600
  }
2644
2601
  }
2645
- a && x - S >= i && (a(x + 1, A), S = x);
2602
+ a && C - S >= i && (a(C + 1, A), S = C);
2646
2603
  }
2647
2604
  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;
2605
+ const $ = performance.now() - t, M = c.getStats(), H = M.eidHits + M.eidMisses + M.selectorHits + M.selectorMisses, E = M.eidHits + M.selectorHits, x = H > 0 ? E / H : 0;
2649
2606
  return {
2650
2607
  results: b,
2651
2608
  failed: y,
@@ -2656,7 +2613,7 @@ function ue(n = {}) {
2656
2613
  skipped: v,
2657
2614
  totalTimeMs: $,
2658
2615
  avgTimePerElementMs: b.length > 0 ? $ / b.length : 0,
2659
- cacheHitRate: C
2616
+ cacheHitRate: x
2660
2617
  }
2661
2618
  };
2662
2619
  }
@@ -2669,32 +2626,30 @@ function de(n, t = {}) {
2669
2626
  generatorOptions: o = {},
2670
2627
  cache: l,
2671
2628
  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 = [];
2629
+ } = t, d = l ?? Z(), c = { ...o, cache: d }, h = n.filter((E) => !at(E, i)), f = it(h).slice(0, s), p = [], m = [];
2675
2630
  let b = 0;
2676
2631
  const y = f.length;
2677
2632
  let v = 0;
2678
2633
  for (let E = 0; E < f.length && !u?.aborted; E++) {
2679
- const C = f[E], x = d.getEID(C);
2680
- if (x)
2634
+ const x = f[E], C = d.getEID(x);
2635
+ if (C)
2681
2636
  p.push({
2682
- element: C,
2683
- eid: x,
2637
+ element: x,
2638
+ eid: C,
2684
2639
  generationTimeMs: 0
2685
2640
  });
2686
2641
  else {
2687
2642
  const T = performance.now();
2688
2643
  try {
2689
- const R = Z(C, c), z = performance.now() - T;
2644
+ const R = Y(x, c), z = performance.now() - T;
2690
2645
  R ? p.push({
2691
- element: C,
2646
+ element: x,
2692
2647
  eid: R,
2693
2648
  generationTimeMs: z
2694
2649
  }) : b++;
2695
2650
  } catch (R) {
2696
2651
  m.push({
2697
- element: C,
2652
+ element: x,
2698
2653
  error: R instanceof Error ? R.message : String(R)
2699
2654
  });
2700
2655
  }
@@ -2728,26 +2683,26 @@ export {
2728
2683
  Wt as FallbackHandler,
2729
2684
  se as MAX_PATH_DEPTH,
2730
2685
  xt as PathBuilder,
2731
- X as ROLE_ANCHOR_VALUES,
2732
- Y as SEMANTIC_ANCHOR_TAGS,
2686
+ K as ROLE_ANCHOR_VALUES,
2687
+ X as SEMANTIC_ANCHOR_TAGS,
2733
2688
  re as SEMANTIC_ATTRIBUTES,
2734
2689
  lt as SEMANTIC_TAGS,
2735
2690
  Pt as SemanticExtractor,
2736
2691
  Ft as SemanticsMatcher,
2737
- _t as SvgFingerprinter,
2738
- kt as calculateConfidence,
2692
+ kt as SvgFingerprinter,
2693
+ _t as calculateConfidence,
2739
2694
  ae as calculateElementScore,
2740
2695
  Ot as createEIDCache,
2741
2696
  At as filterClasses,
2742
- Z as generateEID,
2697
+ Y as generateEID,
2743
2698
  ue as generateEIDBatch,
2744
2699
  de as generateEIDForElements,
2745
2700
  le as generateSEQL,
2746
2701
  ne as getClassScore,
2747
- Q as getGlobalCache,
2702
+ Z as getGlobalCache,
2748
2703
  ce as isEID,
2749
- K as isUtilityClass,
2750
- V as normalizeText,
2704
+ J as isUtilityClass,
2705
+ Q as normalizeText,
2751
2706
  Yt as parseSEQL,
2752
2707
  ie as resetGlobalCache,
2753
2708
  Bt as resolve,