@asamuzakjp/dom-selector 5.0.2 → 5.0.4

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/README.md CHANGED
@@ -292,43 +292,43 @@ See [benchmark](https://github.com/asamuzaK/domSelector/actions/workflows/benchm
292
292
 
293
293
  |Selector|jsdom v24.1.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
294
294
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
295
- |simple selector:<br>`matches('.content')`|989,454 ops/sec ±1.51%|7,613 ops/sec ±1.10%|9,516 ops/sec ±0.60%|848,327 ops/sec ±0.66%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
296
- |compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|602,507 ops/sec ±0.32%|7,328 ops/sec ±0.81%|9,052 ops/sec ±0.48%|405,877 ops/sec ±0.15%|jsdom is the fastest and 1.5 times faster than patched-jsdom.|
297
- |compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|7,365 ops/sec ±0.90%|F|66,159 ops/sec ±0.98%|patched-jsdom is the fastest.|
298
- |compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|479,695 ops/sec ±1.60%|7,470 ops/sec ±0.57%|8,804 ops/sec ±0.44%|346,257 ops/sec ±0.31%|jsdom is the fastest and 1.4 times faster than patched-jsdom.|
299
- |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|154,869 ops/sec ±0.80%|F|5,845 ops/sec ±0.34%|132,313 ops/sec ±0.22%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
300
- |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,754 ops/sec ±1.33%|21,105 ops/sec ±1.16%|patched-jsdom is the fastest.|
301
- |complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|411,631 ops/sec ±0.31%|F|6,123 ops/sec ±0.38%|340,899 ops/sec ±0.19%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
295
+ |simple selector:<br>`matches('.content')`|957,875 ops/sec ±0.97%|7,248 ops/sec ±0.58%|7,435 ops/sec ±0.63%|811,680 ops/sec ±1.32%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
296
+ |compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|591,790 ops/sec ±1.01%|7,003 ops/sec ±0.84%|7,118 ops/sec ±0.77%|400,189 ops/sec ±0.29%|jsdom is the fastest and 1.5 times faster than patched-jsdom.|
297
+ |compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|7,018 ops/sec ±0.53%|F|74,449 ops/sec ±0.90%|patched-jsdom is the fastest.|
298
+ |compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|471,272 ops/sec ±0.38%|6,777 ops/sec ±0.57%|7,067 ops/sec ±0.54%|338,117 ops/sec ±1.49%|jsdom is the fastest and 1.4 times faster than patched-jsdom.|
299
+ |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|151,368 ops/sec ±1.59%|F|4,723 ops/sec ±0.69%|124,920 ops/sec ±1.31%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
300
+ |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|4,610 ops/sec ±0.68%|41,718 ops/sec ±2.02%|patched-jsdom is the fastest.|
301
+ |complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|411,511 ops/sec ±1.61%|F|4,958 ops/sec ±0.35%|333,788 ops/sec ±1.24%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
302
302
 
303
303
  ### closest()
304
304
 
305
305
  |Selector|jsdom v24.1.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
306
306
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
307
- |simple selector:<br>`closest('.container')`|379,529 ops/sec ±0.13%|7,469 ops/sec ±1.56%|9,306 ops/sec ±0.72%|346,182 ops/sec ±1.52%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
308
- |compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|137,674 ops/sec ±1.76%|F|8,696 ops/sec ±0.72%|125,138 ops/sec ±1.62%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
309
- |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|142,675 ops/sec ±0.43%|F|5,804 ops/sec ±0.87%|122,213 ops/sec ±1.38%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
310
- |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,733 ops/sec ±0.87%|17,024 ops/sec ±0.74%|patched-jsdom is the fastest.|
311
- |complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|200,172 ops/sec ±1.51%|4,808 ops/sec ±1.19%|6,145 ops/sec ±0.53%|176,908 ops/sec ±1.42%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
307
+ |simple selector:<br>`closest('.container')`|370,268 ops/sec ±1.72%|7,123 ops/sec ±0.63%|7,399 ops/sec ±0.75%|339,853 ops/sec ±1.49%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
308
+ |compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|133,846 ops/sec ±1.40%|F|6,977 ops/sec ±0.61%|124,635 ops/sec ±1.41%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
309
+ |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|139,233 ops/sec ±1.93%|F|4,648 ops/sec ±0.87%|119,991 ops/sec ±0.23%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
310
+ |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|4,618 ops/sec ±0.76%|37,743 ops/sec ±1.86%|patched-jsdom is the fastest.|
311
+ |complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|196,742 ops/sec ±1.46%|4,454 ops/sec ±1.05%|4,846 ops/sec ±0.61%|176,010 ops/sec ±1.34%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
312
312
 
313
313
  ### querySelector()
314
314
 
315
315
  |Selector|jsdom v24.1.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
316
316
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
317
- |simple selector:<br>`querySelector('.content')`|28,846 ops/sec ±0.23%|9,426 ops/sec ±0.83%|10,729 ops/sec ±0.58%|29,550 ops/sec ±0.89%|patched-jsdom is the fastest. patched-jsdom is 1.0 times faster than jsdom.|
318
- |compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|10,152 ops/sec ±0.29%|9,270 ops/sec ±0.75%|10,907 ops/sec ±0.62%|9,682 ops/sec ±1.47%|linkedom is the fastest and 1.1 times faster than patched-jsdom. jsdom is 1.0 times faster than patched-jsdom.|
319
- |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|229 ops/sec ±1.41%|F|1,319 ops/sec ±1.57%|281 ops/sec ±0.46%|linkedom is the fastest and 4.7 times faster than patched-jsdom. patched-jsdom is 1.2 times faster than jsdom.|
320
- |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|1,606 ops/sec ±1.47%|803 ops/sec ±1.47%|linkedom is the fastest and 2.0 times faster than patched-jsdom.|
321
- |complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|3,246 ops/sec ±1.58%|F|9,831 ops/sec ±0.80%|153,338 ops/sec ±1.76%|patched-jsdom is the fastest. patched-jsdom is 47.2 times faster than jsdom.|
317
+ |simple selector:<br>`querySelector('.content')`|32,150 ops/sec ±1.48%|8,957 ops/sec ±1.16%|8,707 ops/sec ±0.68%|29,777 ops/sec ±1.81%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
318
+ |compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|10,249 ops/sec ±1.33%|8,618 ops/sec ±1.28%|8,311 ops/sec ±0.60%|9,614 ops/sec ±1.31%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
319
+ |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|230 ops/sec ±1.26%|F|1,265 ops/sec ±1.58%|268 ops/sec ±1.23%|linkedom is the fastest and 4.7 times faster than patched-jsdom. patched-jsdom is 1.2 times faster than jsdom.|
320
+ |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|1,501 ops/sec ±1.51%|706 ops/sec ±2.25%|linkedom is the fastest and 2.1 times faster than patched-jsdom.|
321
+ |complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|3,305 ops/sec ±1.72%|F|8,133 ops/sec ±0.71%|154,046 ops/sec ±2.15%|patched-jsdom is the fastest. patched-jsdom is 46.6 times faster than jsdom.|
322
322
 
323
323
  ### querySelectorAll()
324
324
 
325
325
  |Selector|jsdom v24.1.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
326
326
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
327
- |simple selector:<br>`querySelectorAll('.content')`|2,660 ops/sec ±1.25%|782 ops/sec ±0.27%|1,234 ops/sec ±1.40%|3,276 ops/sec ±0.90%|patched-jsdom is the fastest. patched-jsdom is 1.2 times faster than jsdom.|
328
- |compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|977 ops/sec ±1.05%|730 ops/sec ±1.55%|1,191 ops/sec ±1.07%|1,046 ops/sec ±1.11%|linkedom is the fastest and 1.1 times faster than patched-jsdom. patched-jsdom is 1.1 times faster than jsdom.|
329
- |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|228 ops/sec ±1.21%|F|428 ops/sec ±1.36%|279 ops/sec ±1.28%|linkedom is the fastest and 1.5 times faster than patched-jsdom. patched-jsdom is 1.2 times faster than jsdom.|
330
- |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|465 ops/sec ±0.20%|924 ops/sec ±0.52%|patched-jsdom is the fastest.|
331
- |complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|312 ops/sec ±1.25%|F|519 ops/sec ±1.57%|780 ops/sec ±2.24%|patched-jsdom is the fastest. patched-jsdom is 2.5 times faster than jsdom.|
327
+ |simple selector:<br>`querySelectorAll('.content')`|3,099 ops/sec ±1.08%|785 ops/sec ±1.79%|1,145 ops/sec ±1.41%|3,032 ops/sec ±0.28%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
328
+ |compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|1,018 ops/sec ±0.34%|731 ops/sec ±1.57%|1,155 ops/sec ±1.23%|995 ops/sec ±1.18%|linkedom is the fastest and 1.2 times faster than patched-jsdom. jsdom is 1.0 times faster than patched-jsdom.|
329
+ |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|231 ops/sec ±1.23%|F|420 ops/sec ±1.37%|276 ops/sec ±0.23%|linkedom is the fastest and 1.5 times faster than patched-jsdom. patched-jsdom is 1.2 times faster than jsdom.|
330
+ |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|447 ops/sec ±1.41%|801 ops/sec ±2.65%|patched-jsdom is the fastest.|
331
+ |complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|322 ops/sec ±0.40%|F|508 ops/sec ±1.40%|767 ops/sec ±1.66%|patched-jsdom is the fastest. patched-jsdom is 2.4 times faster than jsdom.|
332
332
 
333
333
 
334
334
  ## Acknowledgments
package/dist/cjs/index.js CHANGED
@@ -3,5 +3,5 @@ var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.g
3
3
  * @license MIT
4
4
  * @copyright asamuzaK (Kazz)
5
5
  * @see {@link https://github.com/asamuzaK/domSelector/blob/main/LICENSE}
6
- */class y extends m.Finder{#t;#e;constructor(e,t){super(e),this.#t=t??e.document,this.#e=(0,h.initNwsapi)(e,t)}matches(e,t,c){let i;try{if(t?.nodeType!==s.ELEMENT_NODE){const n=`Unexpected node ${t?.nodeName}`;throw new TypeError(n)}const r=t.ownerDocument;if(r===this.#t&&r.contentType==="text/html"){const n={complex:s.REG_COMPLEX.test(e),descendant:!0,target:s.TARGET_SELF};if((0,h.filterSelector)(e,n))return this.#e.match(e,t)}this._setup(e,t,c),i=this._find(s.TARGET_SELF).size}catch(r){this._onError(r)}return!!i}closest(e,t,c){let i;try{if(t?.nodeType!==s.ELEMENT_NODE){const n=`Unexpected node ${t?.nodeName}`;throw new TypeError(n)}const r=t.ownerDocument;if(r===this.#t&&r.contentType==="text/html"){const n={complex:s.REG_COMPLEX.test(e),descendant:!0,target:s.TARGET_LINEAL};if((0,h.filterSelector)(e,n))return this.#e.closest(e,t)}this._setup(e,t,c);const o=this._find(s.TARGET_LINEAL);if(o.size){let n=t;for(;n;){if(o.has(n)){i=n;break}n=n.parentNode}}}catch(r){this._onError(r)}return i??null}querySelector(e,t,c){let i;try{let r;if(t?.nodeType===s.DOCUMENT_NODE?r=t:r=t?.ownerDocument,r===this.#t&&r?.contentType==="text/html"&&(0,h.filterSelector)(e,{complex:!1,descendant:!1,target:s.TARGET_FIRST}))return this.#e.first(e,t);this._setup(e,t,c);const o=this._find(s.TARGET_FIRST);o.delete(t),o.size&&([i]=(0,l.sortNodes)(o))}catch(r){this._onError(r)}return i??null}querySelectorAll(e,t,c){let i;try{let r;if(t?.nodeType===s.DOCUMENT_NODE?r=t:r=t?.ownerDocument,r===this.#t&&r?.contentType==="text/html"&&(0,h.filterSelector)(e,{complex:!1,descendant:!0,target:s.TARGET_ALL}))return this.#e.select(e,t);this._setup(e,t,c);const o=this._find(s.TARGET_ALL);o.delete(t),o.size&&(i=[...o])}catch(r){this._onError(r)}return i??[]}}0&&(module.exports={DOMSelector});
6
+ */class y extends m.Finder{#t;#e;constructor(e,t){super(e),this.#t=t??e.document,this.#e=(0,h.initNwsapi)(e,t)}matches(e,t,c){let i;try{if(t?.nodeType!==s.ELEMENT_NODE){const n=`Unexpected node ${t?.nodeName}`;throw new TypeError(n)}const r=t.ownerDocument;if(r===this.#t&&r.contentType==="text/html"){const n={complex:s.REG_COMPLEX.test(e),descendant:!0,target:s.TARGET_SELF};if((0,h.filterSelector)(e,n))return this.#e.match(e,t)}this._setup(e,t,c),i=this._find(s.TARGET_SELF).size}catch(r){this._onError(r)}return!!i}closest(e,t,c){let i;try{if(t?.nodeType!==s.ELEMENT_NODE){const n=`Unexpected node ${t?.nodeName}`;throw new TypeError(n)}const r=t.ownerDocument;if(r===this.#t&&r.contentType==="text/html"){const n={complex:s.REG_COMPLEX.test(e),descendant:!0,target:s.TARGET_LINEAL};if((0,h.filterSelector)(e,n))return this.#e.closest(e,t)}this._setup(e,t,c);const o=this._find(s.TARGET_LINEAL);if(o.size){let n=t;for(;n;){if(o.has(n)){i=n;break}n=n.parentNode}}}catch(r){this._onError(r)}return i??null}querySelector(e,t,c){let i;try{let r;if(t?.nodeType===s.DOCUMENT_NODE?r=t:r=t?.ownerDocument,r===this.#t&&r.contentType==="text/html"&&(0,h.filterSelector)(e,{complex:!1,descendant:!1,target:s.TARGET_FIRST}))return this.#e.first(e,t);this._setup(e,t,c);const o=this._find(s.TARGET_FIRST);o.delete(t),o.size&&([i]=(0,l.sortNodes)(o))}catch(r){this._onError(r)}return i??null}querySelectorAll(e,t,c){let i;try{let r;if(t?.nodeType===s.DOCUMENT_NODE?r=t:r=t?.ownerDocument,r===this.#t&&r.contentType==="text/html"&&(0,h.filterSelector)(e,{complex:!1,descendant:!0,target:s.TARGET_ALL}))return this.#e.select(e,t);this._setup(e,t,c);const o=this._find(s.TARGET_ALL);o.delete(t),o.size&&(i=[...o])}catch(r){this._onError(r)}return i??[]}}0&&(module.exports={DOMSelector});
7
7
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.js"],
4
- "sourcesContent": ["/*!\n * DOM Selector - A CSS selector engine.\n * @license MIT\n * @copyright asamuzaK (Kazz)\n * @see {@link https://github.com/asamuzaK/domSelector/blob/main/LICENSE}\n */\n\n/* import */\nimport { sortNodes } from './js/dom-util.js';\nimport { Finder } from './js/finder.js';\nimport { filterSelector, initNwsapi } from './js/nwsapi.js';\n\n/* constants */\nimport {\n DOCUMENT_NODE, ELEMENT_NODE, REG_COMPLEX, TARGET_ALL, TARGET_FIRST,\n TARGET_LINEAL, TARGET_SELF\n} from './js/constant.js';\n\nexport class DOMSelector extends Finder {\n /* private fields */\n #document;\n #nwsapi;\n\n /**\n * construct\n * @param {object} window - window\n * @param {object} document - document\n */\n constructor(window, document) {\n super(window);\n this.#document = document ?? window.document;\n this.#nwsapi = initNwsapi(window, document);\n }\n\n /**\n * matches\n * @param {string} selector - CSS selector\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {boolean} - `true` if matched `false` otherwise\n */\n matches(selector, node, opt) {\n let res;\n try {\n if (node?.nodeType !== ELEMENT_NODE) {\n const msg = `Unexpected node ${node?.nodeName}`;\n throw new TypeError(msg);\n }\n const document = node.ownerDocument;\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: REG_COMPLEX.test(selector),\n descendant: true,\n target: TARGET_SELF\n };\n if (filterSelector(selector, filterOpt)) {\n return this.#nwsapi.match(selector, node);\n }\n }\n this._setup(selector, node, opt);\n const nodes = this._find(TARGET_SELF);\n res = nodes.size;\n } catch (e) {\n this._onError(e);\n }\n return !!res;\n }\n\n /**\n * closest\n * @param {string} selector - CSS selector\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {?object} - matched node\n */\n closest(selector, node, opt) {\n let res;\n try {\n if (node?.nodeType !== ELEMENT_NODE) {\n const msg = `Unexpected node ${node?.nodeName}`;\n throw new TypeError(msg);\n }\n const document = node.ownerDocument;\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: REG_COMPLEX.test(selector),\n descendant: true,\n target: TARGET_LINEAL\n };\n if (filterSelector(selector, filterOpt)) {\n return this.#nwsapi.closest(selector, node);\n }\n }\n this._setup(selector, node, opt);\n const nodes = this._find(TARGET_LINEAL);\n if (nodes.size) {\n let refNode = node;\n while (refNode) {\n if (nodes.has(refNode)) {\n res = refNode;\n break;\n }\n refNode = refNode.parentNode;\n }\n }\n } catch (e) {\n this._onError(e);\n }\n return res ?? null;\n }\n\n /**\n * query selector\n * @param {string} selector - CSS selector\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} opt - options\n * @returns {?object} - matched node\n */\n querySelector(selector, node, opt) {\n let res;\n try {\n let document;\n if (node?.nodeType === DOCUMENT_NODE) {\n document = node;\n } else {\n document = node?.ownerDocument;\n }\n if (document === this.#document &&\n document?.contentType === 'text/html') {\n const filterOpt = {\n complex: false,\n descendant: false,\n target: TARGET_FIRST\n };\n if (filterSelector(selector, filterOpt)) {\n return this.#nwsapi.first(selector, node);\n }\n }\n this._setup(selector, node, opt);\n const nodes = this._find(TARGET_FIRST);\n nodes.delete(node);\n if (nodes.size) {\n [res] = sortNodes(nodes);\n }\n } catch (e) {\n this._onError(e);\n }\n return res ?? null;\n }\n\n /**\n * query selector all\n * NOTE: returns Array, not NodeList\n * @param {string} selector - CSS selector\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} opt - options\n * @returns {Array.<object|undefined>} - collection of matched nodes\n */\n querySelectorAll(selector, node, opt) {\n let res;\n try {\n let document;\n if (node?.nodeType === DOCUMENT_NODE) {\n document = node;\n } else {\n document = node?.ownerDocument;\n }\n if (document === this.#document &&\n document?.contentType === 'text/html') {\n const filterOpt = {\n complex: false,\n descendant: true,\n target: TARGET_ALL\n };\n if (filterSelector(selector, filterOpt)) {\n return this.#nwsapi.select(selector, node);\n }\n }\n this._setup(selector, node, opt);\n const nodes = this._find(TARGET_ALL);\n nodes.delete(node);\n if (nodes.size) {\n res = [...nodes];\n }\n } catch (e) {\n this._onError(e);\n }\n return res ?? [];\n }\n}\n"],
5
- "mappings": "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",
4
+ "sourcesContent": ["/*!\n * DOM Selector - A CSS selector engine.\n * @license MIT\n * @copyright asamuzaK (Kazz)\n * @see {@link https://github.com/asamuzaK/domSelector/blob/main/LICENSE}\n */\n\n/* import */\nimport { sortNodes } from './js/dom-util.js';\nimport { Finder } from './js/finder.js';\nimport { filterSelector, initNwsapi } from './js/nwsapi.js';\n\n/* constants */\nimport {\n DOCUMENT_NODE, ELEMENT_NODE, REG_COMPLEX, TARGET_ALL, TARGET_FIRST,\n TARGET_LINEAL, TARGET_SELF\n} from './js/constant.js';\n\nexport class DOMSelector extends Finder {\n /* private fields */\n #document;\n #nwsapi;\n\n /**\n * construct\n * @param {object} window - window\n * @param {object} document - document\n */\n constructor(window, document) {\n super(window);\n this.#document = document ?? window.document;\n this.#nwsapi = initNwsapi(window, document);\n }\n\n /**\n * matches\n * @param {string} selector - CSS selector\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {boolean} - `true` if matched `false` otherwise\n */\n matches(selector, node, opt) {\n let res;\n try {\n if (node?.nodeType !== ELEMENT_NODE) {\n const msg = `Unexpected node ${node?.nodeName}`;\n throw new TypeError(msg);\n }\n const document = node.ownerDocument;\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: REG_COMPLEX.test(selector),\n descendant: true,\n target: TARGET_SELF\n };\n if (filterSelector(selector, filterOpt)) {\n return this.#nwsapi.match(selector, node);\n }\n }\n this._setup(selector, node, opt);\n const nodes = this._find(TARGET_SELF);\n res = nodes.size;\n } catch (e) {\n this._onError(e);\n }\n return !!res;\n }\n\n /**\n * closest\n * @param {string} selector - CSS selector\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {?object} - matched node\n */\n closest(selector, node, opt) {\n let res;\n try {\n if (node?.nodeType !== ELEMENT_NODE) {\n const msg = `Unexpected node ${node?.nodeName}`;\n throw new TypeError(msg);\n }\n const document = node.ownerDocument;\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: REG_COMPLEX.test(selector),\n descendant: true,\n target: TARGET_LINEAL\n };\n if (filterSelector(selector, filterOpt)) {\n return this.#nwsapi.closest(selector, node);\n }\n }\n this._setup(selector, node, opt);\n const nodes = this._find(TARGET_LINEAL);\n if (nodes.size) {\n let refNode = node;\n while (refNode) {\n if (nodes.has(refNode)) {\n res = refNode;\n break;\n }\n refNode = refNode.parentNode;\n }\n }\n } catch (e) {\n this._onError(e);\n }\n return res ?? null;\n }\n\n /**\n * query selector\n * @param {string} selector - CSS selector\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} opt - options\n * @returns {?object} - matched node\n */\n querySelector(selector, node, opt) {\n let res;\n try {\n let document;\n if (node?.nodeType === DOCUMENT_NODE) {\n document = node;\n } else {\n document = node?.ownerDocument;\n }\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: false,\n descendant: false,\n target: TARGET_FIRST\n };\n if (filterSelector(selector, filterOpt)) {\n return this.#nwsapi.first(selector, node);\n }\n }\n this._setup(selector, node, opt);\n const nodes = this._find(TARGET_FIRST);\n nodes.delete(node);\n if (nodes.size) {\n [res] = sortNodes(nodes);\n }\n } catch (e) {\n this._onError(e);\n }\n return res ?? null;\n }\n\n /**\n * query selector all\n * NOTE: returns Array, not NodeList\n * @param {string} selector - CSS selector\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} opt - options\n * @returns {Array.<object|undefined>} - collection of matched nodes\n */\n querySelectorAll(selector, node, opt) {\n let res;\n try {\n let document;\n if (node?.nodeType === DOCUMENT_NODE) {\n document = node;\n } else {\n document = node?.ownerDocument;\n }\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: false,\n descendant: true,\n target: TARGET_ALL\n };\n if (filterSelector(selector, filterOpt)) {\n return this.#nwsapi.select(selector, node);\n }\n }\n this._setup(selector, node, opt);\n const nodes = this._find(TARGET_ALL);\n nodes.delete(node);\n if (nodes.size) {\n res = [...nodes];\n }\n } catch (e) {\n this._onError(e);\n }\n return res ?? [];\n }\n}\n"],
5
+ "mappings": "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",
6
6
  "names": ["src_exports", "__export", "DOMSelector", "__toCommonJS", "import_dom_util", "import_finder", "import_nwsapi", "import_constant", "#document", "#nwsapi", "window", "document", "selector", "node", "opt", "res", "msg", "filterOpt", "e", "nodes", "refNode"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var O=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var Y=(o,t)=>{for(var n in t)O(o,n,{get:t[n],enumerable:!0})},H=(o,t,n,N)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of U(t))!d.call(o,s)&&s!==n&&O(o,s,{get:()=>t[s],enumerable:!(N=F(t,s))||N.enumerable});return o};var u=o=>H(O({},"__esModule",{value:!0}),o);var qt={};Y(qt,{ALPHA_NUM:()=>R,ANB:()=>D,AN_PLUS_B:()=>B,BIT_01:()=>et,BIT_02:()=>st,BIT_04:()=>rt,BIT_08:()=>Et,BIT_16:()=>nt,BIT_32:()=>ct,BIT_FFFF:()=>xt,BIT_HYPHEN:()=>_t,CHILD_IDX:()=>I,COMBINATOR:()=>m,COMBO:()=>T,COMPLEX:()=>L,COMPLEX_L:()=>C,COMPOUND:()=>E,COMPOUND_A:()=>A,COMPOUND_B:()=>S,COMPOUND_I:()=>i,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>St,DOCUMENT_NODE:()=>At,DOCUMENT_POSITION_CONTAINED_BY:()=>It,DOCUMENT_POSITION_CONTAINS:()=>Nt,DOCUMENT_POSITION_PRECEDING:()=>Ct,DUO:()=>pt,ELEMENT_NODE:()=>$t,EMPTY:()=>w,HEX:()=>Tt,IDENTIFIER:()=>g,LANG_PART:()=>G,LOGICAL_COMPLEX:()=>a,LOGICAL_COMPOUND:()=>M,LOGICAL_KEY:()=>p,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>l,NOT_SUPPORTED_ERR:()=>h,NTH:()=>X,N_TH:()=>_,PSEUDO_CLASSES:()=>x,RAW:()=>f,REG_ANCHOR:()=>at,REG_CHILD_INDEXED:()=>Mt,REG_COMPLEX:()=>Ft,REG_DIR:()=>Ut,REG_FORM:()=>dt,REG_FORM_CTRL:()=>Yt,REG_FORM_VALID:()=>Ht,REG_HEX:()=>ut,REG_INTERACT:()=>Bt,REG_INVALID_SELECTOR:()=>mt,REG_LANG:()=>wt,REG_LANG_QUOTED:()=>gt,REG_LOGICAL_COMPLEX:()=>ht,REG_LOGICAL_COMPOUND:()=>Xt,REG_LOGICAL_EMPTY:()=>ft,REG_LOGICAL_KEY:()=>bt,REG_LOGICAL_PSEUDO:()=>Wt,REG_SHADOW_HOST:()=>yt,REG_SHADOW_MODE:()=>kt,REG_SHADOW_PSEUDO:()=>Kt,REG_TYPE_CHECK:()=>Zt,REG_TYPE_DATE:()=>vt,REG_TYPE_RANGE:()=>zt,REG_TYPE_RESET:()=>Vt,REG_TYPE_SUBMIT:()=>Qt,REG_TYPE_TEXT:()=>jt,SELECTOR:()=>b,SELECTOR_ATTR:()=>W,SELECTOR_CLASS:()=>y,SELECTOR_ID:()=>k,SELECTOR_LIST:()=>K,SELECTOR_PSEUDO_CLASS:()=>Z,SELECTOR_PSEUDO_ELEMENT:()=>v,SELECTOR_TYPE:()=>z,SHOW_ALL:()=>Gt,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Pt,SHOW_ELEMENT:()=>lt,STRING:()=>V,SUB_TYPE:()=>r,SYNTAX_ERR:()=>Q,TAG_TYPE:()=>e,TAG_TYPE_I:()=>$,TARGET_ALL:()=>j,TARGET_FIRST:()=>q,TARGET_LINEAL:()=>J,TARGET_SELF:()=>tt,TEXT_NODE:()=>Lt,TYPE_FROM:()=>Ot,TYPE_TO:()=>Rt,U_FFFD:()=>ot,WALKER_FILTER:()=>it});module.exports=u(qt);const B="AnPlusB",m="Combinator",w="__EMPTY__",g="Identifier",h="NotSupportedError",X="Nth",f="Raw",b="Selector",W="AttributeSelector",y="ClassSelector",k="IdSelector",K="SelectorList",Z="PseudoClassSelector",v="PseudoElementSelector",z="TypeSelector",V="String",Q="SyntaxError",j="all",q="first",J="lineal",tt="self",ot="\uFFFD",et=1,st=2,rt=4,Et=8,nt=16,ct=32,xt=65535,_t=45,pt=2,Tt=16,Ot=8,Rt=-1,$t=1,Lt=3,At=9,St=11,Ct=2,Nt=8,It=16,Gt=4294967295,Dt=256,Pt=1024,lt=1,it=1281,R="[A-Z\\d]+",I="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",G=`(?:-${R})*`,x=`(?:any-)?link|${I}|checked|empty|indeterminate|root|target|visited`,D=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,_=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${D})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",$="\\*|[A-Z][\\w-]*",p="(?:is|not)",E=`(?:${e}|(?:${e})?(?:${r})+)`,T="\\s?[\\s>~+]\\s?",L=`${E}(?:${T}${E})*`,P=`:is\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,l=`:is\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,A=`(?:${e}|(?:${e})?(?:${r}|${P})+)`,S=`(?:${e}|(?:${e})?(?:${r}|${l})+)`,i=`(?:${$}|(?:${$})?(?:${r})+)`,C=`${S}(?:${T}${S})*`,a=`${p}\\(\\s*${C}(?:\\s*,\\s*${C})*\\s*\\)`,M=`${p}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,at=/^a(?:rea)?$/,Mt=new RegExp(`:(?!${x}|${_})`),Ft=new RegExp(`${T}${i}`,"i"),Ut=/^(?:ltr|rtl)$/,dt=/^(?:button|fieldset|form|input|select|textarea)$/,Yt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Ht=/^(?:button|form|input|select|textarea)$/,ut=/^([\da-f]{1,6}\s?)/i,Bt=/^(?:details|dialog)$/,mt=/^$|^\s*>|,\s*$/,wt=new RegExp(`^(?:\\*-)?${R}${G}$`,"i"),gt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,ht=new RegExp(`:(?!${x}|${_}|${a})`),Xt=new RegExp(`:(?!${x}|${_}|${M})`),ft=/(:(is|where)\(\s*\))/,bt=new RegExp(`:${p}\\(`),Wt=/^(?:has|is|not|where)$/,yt=/^host(?:-context)?$/,kt=/^(?:close|open)$/,Kt=/^part|slotted$/,Zt=/^(?:checkbox|radio)$/,vt=/^(?:date(?:time-local)?|month|time|week)$/,zt=/(?:date(?:time-local)?|month|number|range|time|week)$/,Vt=/^(?:button|reset)$/,Qt=/^(?:image|submit)$/,jt=/^(?:email|number|password|search|tel|text|url)$/;0&&(module.exports={ALPHA_NUM,ANB,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,BIT_HYPHEN,CHILD_IDX,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,LOGICAL_KEY,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_CHILD_INDEXED,REG_COMPLEX,REG_DIR,REG_FORM,REG_FORM_CTRL,REG_FORM_VALID,REG_HEX,REG_INTERACT,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_COMPLEX,REG_LOGICAL_COMPOUND,REG_LOGICAL_EMPTY,REG_LOGICAL_KEY,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TYPE_CHECK,REG_TYPE_DATE,REG_TYPE_RANGE,REG_TYPE_RESET,REG_TYPE_SUBMIT,REG_TYPE_TEXT,SELECTOR,SELECTOR_ATTR,SELECTOR_CLASS,SELECTOR_ID,SELECTOR_LIST,SELECTOR_PSEUDO_CLASS,SELECTOR_PSEUDO_ELEMENT,SELECTOR_TYPE,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,STRING,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER});
1
+ var O=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var Y=(o,t)=>{for(var r in t)O(o,r,{get:t[r],enumerable:!0})},H=(o,t,r,I)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of d(t))!U.call(o,s)&&s!==r&&O(o,s,{get:()=>t[s],enumerable:!(I=F(t,s))||I.enumerable});return o};var u=o=>H(O({},"__esModule",{value:!0}),o);var Jt={};Y(Jt,{ALPHA_NUM:()=>R,ANB:()=>D,AN_PLUS_B:()=>B,BIT_01:()=>et,BIT_02:()=>st,BIT_04:()=>nt,BIT_08:()=>Et,BIT_16:()=>rt,BIT_32:()=>ct,BIT_FFFF:()=>xt,BIT_HYPHEN:()=>_t,CHILD_IDX:()=>N,COMBINATOR:()=>m,COMBO:()=>T,COMPLEX:()=>L,COMPLEX_L:()=>C,COMPOUND:()=>E,COMPOUND_A:()=>A,COMPOUND_B:()=>S,COMPOUND_I:()=>l,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>St,DOCUMENT_NODE:()=>At,DOCUMENT_POSITION_CONTAINED_BY:()=>Nt,DOCUMENT_POSITION_CONTAINS:()=>It,DOCUMENT_POSITION_PRECEDING:()=>Ct,DUO:()=>pt,ELEMENT_NODE:()=>$t,EMPTY:()=>h,HEX:()=>Tt,IDENTIFIER:()=>w,LANG_PART:()=>G,LOGICAL_COMPLEX:()=>a,LOGICAL_COMPOUND:()=>M,LOGICAL_KEY:()=>p,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>i,NOT_SUPPORTED_ERR:()=>g,NTH:()=>f,N_TH:()=>_,PSEUDO_CLASSES:()=>x,RAW:()=>X,REG_ANCHOR:()=>at,REG_CHILD_INDEXED:()=>Mt,REG_COMPLEX:()=>Ft,REG_DIR:()=>dt,REG_FORM:()=>Ut,REG_FORM_CTRL:()=>Yt,REG_FORM_VALID:()=>Ht,REG_HEX:()=>ut,REG_INTERACT:()=>Bt,REG_INVALIDATE_PSEUDO:()=>mt,REG_INVALID_SELECTOR:()=>ht,REG_LANG:()=>wt,REG_LANG_QUOTED:()=>gt,REG_LOGICAL_COMPLEX:()=>ft,REG_LOGICAL_COMPOUND:()=>Xt,REG_LOGICAL_EMPTY:()=>bt,REG_LOGICAL_KEY:()=>Wt,REG_LOGICAL_PSEUDO:()=>yt,REG_SHADOW_HOST:()=>kt,REG_SHADOW_MODE:()=>Kt,REG_SHADOW_PSEUDO:()=>Zt,REG_TYPE_CHECK:()=>Vt,REG_TYPE_DATE:()=>vt,REG_TYPE_RANGE:()=>zt,REG_TYPE_RESET:()=>Qt,REG_TYPE_SUBMIT:()=>jt,REG_TYPE_TEXT:()=>qt,SELECTOR:()=>b,SELECTOR_ATTR:()=>W,SELECTOR_CLASS:()=>y,SELECTOR_ID:()=>k,SELECTOR_LIST:()=>K,SELECTOR_PSEUDO_CLASS:()=>Z,SELECTOR_PSEUDO_ELEMENT:()=>V,SELECTOR_TYPE:()=>v,SHOW_ALL:()=>Gt,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Pt,SHOW_ELEMENT:()=>it,STRING:()=>z,SUB_TYPE:()=>n,SYNTAX_ERR:()=>Q,TAG_TYPE:()=>e,TAG_TYPE_I:()=>$,TARGET_ALL:()=>j,TARGET_FIRST:()=>q,TARGET_LINEAL:()=>J,TARGET_SELF:()=>tt,TEXT_NODE:()=>Lt,TYPE_FROM:()=>Ot,TYPE_TO:()=>Rt,U_FFFD:()=>ot,WALKER_FILTER:()=>lt});module.exports=u(Jt);const B="AnPlusB",m="Combinator",h="__EMPTY__",w="Identifier",g="NotSupportedError",f="Nth",X="Raw",b="Selector",W="AttributeSelector",y="ClassSelector",k="IdSelector",K="SelectorList",Z="PseudoClassSelector",V="PseudoElementSelector",v="TypeSelector",z="String",Q="SyntaxError",j="all",q="first",J="lineal",tt="self",ot="\uFFFD",et=1,st=2,nt=4,Et=8,rt=16,ct=32,xt=65535,_t=45,pt=2,Tt=16,Ot=8,Rt=-1,$t=1,Lt=3,At=9,St=11,Ct=2,It=8,Nt=16,Gt=4294967295,Dt=256,Pt=1024,it=1,lt=1281,R="[A-Z\\d]+",N="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",G=`(?:-${R})*`,x=`(?:any-)?link|${N}|checked|empty|indeterminate|root|target|visited`,D=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,_=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${D})\\s*\\)`,n="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",$="\\*|[A-Z][\\w-]*",p="(?:is|not)",E=`(?:${e}|(?:${e})?(?:${n})+)`,T="\\s?[\\s>~+]\\s?",L=`${E}(?:${T}${E})*`,P=`:is\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,i=`:is\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,A=`(?:${e}|(?:${e})?(?:${n}|${P})+)`,S=`(?:${e}|(?:${e})?(?:${n}|${i})+)`,l=`(?:${$}|(?:${$})?(?:${n})+)`,C=`${S}(?:${T}${S})*`,a=`${p}\\(\\s*${C}(?:\\s*,\\s*${C})*\\s*\\)`,M=`${p}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,at=/^a(?:rea)?$/,Mt=new RegExp(`:(?!${x}|${_})`),Ft=new RegExp(`${T}${l}`,"i"),dt=/^(?:ltr|rtl)$/,Ut=/^(?:button|fieldset|form|input|select|textarea)$/,Yt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Ht=/^(?:button|form|input|select|textarea)$/,ut=/^([\da-f]{1,6}\s?)/i,Bt=/^(?:details|dialog)$/,mt=/^(?:(?:any-)?link|defined|dir|has|host(?:-context)?|not)$/,ht=/^$|^\s*>|,\s*$/,wt=new RegExp(`^(?:\\*-)?${R}${G}$`,"i"),gt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,ft=new RegExp(`:(?!${x}|${_}|${a})`),Xt=new RegExp(`:(?!${x}|${_}|${M})`),bt=/(:(is|where)\(\s*\))/,Wt=new RegExp(`:${p}\\(`),yt=/^(?:has|is|not|where)$/,kt=/^host(?:-context)?$/,Kt=/^(?:close|open)$/,Zt=/^part|slotted$/,Vt=/^(?:checkbox|radio)$/,vt=/^(?:date(?:time-local)?|month|time|week)$/,zt=/(?:date(?:time-local)?|month|number|range|time|week)$/,Qt=/^(?:button|reset)$/,jt=/^(?:image|submit)$/,qt=/^(?:email|number|password|search|tel|text|url)$/;0&&(module.exports={ALPHA_NUM,ANB,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,BIT_HYPHEN,CHILD_IDX,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,LOGICAL_KEY,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_CHILD_INDEXED,REG_COMPLEX,REG_DIR,REG_FORM,REG_FORM_CTRL,REG_FORM_VALID,REG_HEX,REG_INTERACT,REG_INVALIDATE_PSEUDO,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_COMPLEX,REG_LOGICAL_COMPOUND,REG_LOGICAL_EMPTY,REG_LOGICAL_KEY,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TYPE_CHECK,REG_TYPE_DATE,REG_TYPE_RANGE,REG_TYPE_RESET,REG_TYPE_SUBMIT,REG_TYPE_TEXT,SELECTOR,SELECTOR_ATTR,SELECTOR_CLASS,SELECTOR_ID,SELECTOR_LIST,SELECTOR_PSEUDO_CLASS,SELECTOR_PSEUDO_ELEMENT,SELECTOR_TYPE,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,STRING,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER});
2
2
  //# sourceMappingURL=constant.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/js/constant.js"],
4
- "sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const AN_PLUS_B = 'AnPlusB';\nexport const COMBINATOR = 'Combinator';\nexport const EMPTY = '__EMPTY__';\nexport const IDENTIFIER = 'Identifier';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const RAW = 'Raw';\nexport const SELECTOR = 'Selector';\nexport const SELECTOR_ATTR = 'AttributeSelector';\nexport const SELECTOR_CLASS = 'ClassSelector';\nexport const SELECTOR_ID = 'IdSelector';\nexport const SELECTOR_LIST = 'SelectorList';\nexport const SELECTOR_PSEUDO_CLASS = 'PseudoClassSelector';\nexport const SELECTOR_PSEUDO_ELEMENT = 'PseudoElementSelector';\nexport const SELECTOR_TYPE = 'TypeSelector';\nexport const STRING = 'String';\nexport const SYNTAX_ERR = 'SyntaxError';\nexport const TARGET_ALL = 'all';\nexport const TARGET_FIRST = 'first';\nexport const TARGET_LINEAL = 'lineal';\nexport const TARGET_SELF = 'self';\nexport const U_FFFD = '\\uFFFD';\n\n/* numeric */\nexport const BIT_01 = 1;\nexport const BIT_02 = 2;\nexport const BIT_04 = 4;\nexport const BIT_08 = 8;\nexport const BIT_16 = 0x10;\nexport const BIT_32 = 0x20;\nexport const BIT_FFFF = 0xFFFF;\nexport const BIT_HYPHEN = 0x2D;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const TYPE_FROM = 8;\nexport const TYPE_TO = -1;\n\n/* Node */\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\nexport const DOCUMENT_POSITION_PRECEDING = 2;\nexport const DOCUMENT_POSITION_CONTAINS = 8;\nexport const DOCUMENT_POSITION_CONTAINED_BY = 0x10;\n\n/* NodeFilter */\nexport const SHOW_ALL = 0xFFFFFFFF;\nexport const SHOW_DOCUMENT = 0x100;\nexport const SHOW_DOCUMENT_FRAGMENT = 0x400;\nexport const SHOW_ELEMENT = 1;\nexport const WALKER_FILTER = 0x501;\n\n/* selectors */\nexport const ALPHA_NUM = '[A-Z\\\\d]+';\nexport const CHILD_IDX = '(?:first|last|only)-(?:child|of-type)';\nexport const DIGIT = '(?:0|[1-9]\\\\d*)';\nexport const LANG_PART = `(?:-${ALPHA_NUM})*`;\nexport const PSEUDO_CLASSES =\n `(?:any-)?link|${CHILD_IDX}|checked|empty|indeterminate|root|target|visited`;\nexport const ANB =\n `[+-]?(?:${DIGIT}n?|n)|(?:[+-]?${DIGIT})?n\\\\s*[+-]\\\\s*${DIGIT}`;\n// N_TH: excludes An+B with selector list, e.g. :nth-child(2n+1 of .foo)\nexport const N_TH =\n `nth-(?:last-)?(?:child|of-type)\\\\(\\\\s*(?:even|odd|${ANB})\\\\s*\\\\)`;\n// SUB_TYPE: attr, id, class, pseudo-class, note that [foo|=bar] is excluded\nexport const SUB_TYPE = '\\\\[[^|\\\\]]+\\\\]|[#.:][\\\\w-]+';\n// TAG_TYPE: *, tag\nexport const TAG_TYPE = '\\\\*|[A-Za-z][\\\\w-]*';\nexport const TAG_TYPE_I = '\\\\*|[A-Z][\\\\w-]*';\n// LOGICAL_KEY: :has() and :where() are excluded\nexport const LOGICAL_KEY = '(?:is|not)';\nexport const COMPOUND = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`;\nexport const COMBO = '\\\\s?[\\\\s>~+]\\\\s?';\nexport const COMPLEX = `${COMPOUND}(?:${COMBO}${COMPOUND})*`;\nexport const NESTED_LOGICAL_A =\n `:is\\\\(\\\\s*${COMPOUND}(?:\\\\s*,\\\\s*${COMPOUND})*\\\\s*\\\\)`;\nexport const NESTED_LOGICAL_B =\n `:is\\\\(\\\\s*${COMPLEX}(?:\\\\s*,\\\\s*${COMPLEX})*\\\\s*\\\\)`;\nexport const COMPOUND_A =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_A})+)`;\nexport const COMPOUND_B =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_B})+)`;\nexport const COMPOUND_I =\n `(?:${TAG_TYPE_I}|(?:${TAG_TYPE_I})?(?:${SUB_TYPE})+)`;\nexport const COMPLEX_L = `${COMPOUND_B}(?:${COMBO}${COMPOUND_B})*`;\nexport const LOGICAL_COMPLEX =\n `${LOGICAL_KEY}\\\\(\\\\s*${COMPLEX_L}(?:\\\\s*,\\\\s*${COMPLEX_L})*\\\\s*\\\\)`;\nexport const LOGICAL_COMPOUND =\n `${LOGICAL_KEY}\\\\(\\\\s*${COMPOUND_A}(?:\\\\s*,\\\\s*${COMPOUND_A})*\\\\s*\\\\)`;\n\n/* regexp */\nexport const REG_ANCHOR = /^a(?:rea)?$/;\nexport const REG_CHILD_INDEXED = new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH})`);\nexport const REG_COMPLEX = new RegExp(`${COMBO}${COMPOUND_I}`, 'i');\nexport const REG_DIR = /^(?:ltr|rtl)$/;\nexport const REG_FORM = /^(?:button|fieldset|form|input|select|textarea)$/;\nexport const REG_FORM_CTRL =\n /^(?:button|fieldset|input|optgroup|option|select|textarea)$/;\nexport const REG_FORM_VALID = /^(?:button|form|input|select|textarea)$/;\nexport const REG_HEX = /^([\\da-f]{1,6}\\s?)/i;\nexport const REG_INTERACT = /^(?:details|dialog)$/;\nexport const REG_INVALID_SELECTOR = /^$|^\\s*>|,\\s*$/;\nexport const REG_LANG = new RegExp(`^(?:\\\\*-)?${ALPHA_NUM}${LANG_PART}$`, 'i');\nexport const REG_LANG_QUOTED = /(:lang\\(\\s*(\"[A-Za-z\\d\\-*]*\")\\s*\\))/;\nexport const REG_LOGICAL_COMPLEX =\n new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPLEX})`);\nexport const REG_LOGICAL_COMPOUND =\n new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPOUND})`);\nexport const REG_LOGICAL_EMPTY = /(:(is|where)\\(\\s*\\))/;\nexport const REG_LOGICAL_KEY = new RegExp(`:${LOGICAL_KEY}\\\\(`);\nexport const REG_LOGICAL_PSEUDO = /^(?:has|is|not|where)$/;\nexport const REG_SHADOW_HOST = /^host(?:-context)?$/;\nexport const REG_SHADOW_MODE = /^(?:close|open)$/;\nexport const REG_SHADOW_PSEUDO = /^part|slotted$/;\nexport const REG_TYPE_CHECK = /^(?:checkbox|radio)$/;\nexport const REG_TYPE_DATE = /^(?:date(?:time-local)?|month|time|week)$/;\nexport const REG_TYPE_RANGE =\n /(?:date(?:time-local)?|month|number|range|time|week)$/;\nexport const REG_TYPE_RESET = /^(?:button|reset)$/;\nexport const REG_TYPE_SUBMIT = /^(?:image|submit)$/;\nexport const REG_TYPE_TEXT = /^(?:email|number|password|search|tel|text|url)$/;\n"],
5
- "mappings": "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",
6
- "names": ["constant_exports", "__export", "ALPHA_NUM", "ANB", "AN_PLUS_B", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "BIT_FFFF", "BIT_HYPHEN", "CHILD_IDX", "COMBINATOR", "COMBO", "COMPLEX", "COMPLEX_L", "COMPOUND", "COMPOUND_A", "COMPOUND_B", "COMPOUND_I", "DIGIT", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "EMPTY", "HEX", "IDENTIFIER", "LANG_PART", "LOGICAL_COMPLEX", "LOGICAL_COMPOUND", "LOGICAL_KEY", "NESTED_LOGICAL_A", "NESTED_LOGICAL_B", "NOT_SUPPORTED_ERR", "NTH", "N_TH", "PSEUDO_CLASSES", "RAW", "REG_ANCHOR", "REG_CHILD_INDEXED", "REG_COMPLEX", "REG_DIR", "REG_FORM", "REG_FORM_CTRL", "REG_FORM_VALID", "REG_HEX", "REG_INTERACT", "REG_INVALID_SELECTOR", "REG_LANG", "REG_LANG_QUOTED", "REG_LOGICAL_COMPLEX", "REG_LOGICAL_COMPOUND", "REG_LOGICAL_EMPTY", "REG_LOGICAL_KEY", "REG_LOGICAL_PSEUDO", "REG_SHADOW_HOST", "REG_SHADOW_MODE", "REG_SHADOW_PSEUDO", "REG_TYPE_CHECK", "REG_TYPE_DATE", "REG_TYPE_RANGE", "REG_TYPE_RESET", "REG_TYPE_SUBMIT", "REG_TYPE_TEXT", "SELECTOR", "SELECTOR_ATTR", "SELECTOR_CLASS", "SELECTOR_ID", "SELECTOR_LIST", "SELECTOR_PSEUDO_CLASS", "SELECTOR_PSEUDO_ELEMENT", "SELECTOR_TYPE", "SHOW_ALL", "SHOW_DOCUMENT", "SHOW_DOCUMENT_FRAGMENT", "SHOW_ELEMENT", "STRING", "SUB_TYPE", "SYNTAX_ERR", "TAG_TYPE", "TAG_TYPE_I", "TARGET_ALL", "TARGET_FIRST", "TARGET_LINEAL", "TARGET_SELF", "TEXT_NODE", "TYPE_FROM", "TYPE_TO", "U_FFFD", "WALKER_FILTER", "__toCommonJS"]
4
+ "sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const AN_PLUS_B = 'AnPlusB';\nexport const COMBINATOR = 'Combinator';\nexport const EMPTY = '__EMPTY__';\nexport const IDENTIFIER = 'Identifier';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const RAW = 'Raw';\nexport const SELECTOR = 'Selector';\nexport const SELECTOR_ATTR = 'AttributeSelector';\nexport const SELECTOR_CLASS = 'ClassSelector';\nexport const SELECTOR_ID = 'IdSelector';\nexport const SELECTOR_LIST = 'SelectorList';\nexport const SELECTOR_PSEUDO_CLASS = 'PseudoClassSelector';\nexport const SELECTOR_PSEUDO_ELEMENT = 'PseudoElementSelector';\nexport const SELECTOR_TYPE = 'TypeSelector';\nexport const STRING = 'String';\nexport const SYNTAX_ERR = 'SyntaxError';\nexport const TARGET_ALL = 'all';\nexport const TARGET_FIRST = 'first';\nexport const TARGET_LINEAL = 'lineal';\nexport const TARGET_SELF = 'self';\nexport const U_FFFD = '\\uFFFD';\n\n/* numeric */\nexport const BIT_01 = 1;\nexport const BIT_02 = 2;\nexport const BIT_04 = 4;\nexport const BIT_08 = 8;\nexport const BIT_16 = 0x10;\nexport const BIT_32 = 0x20;\nexport const BIT_FFFF = 0xFFFF;\nexport const BIT_HYPHEN = 0x2D;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const TYPE_FROM = 8;\nexport const TYPE_TO = -1;\n\n/* Node */\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\nexport const DOCUMENT_POSITION_PRECEDING = 2;\nexport const DOCUMENT_POSITION_CONTAINS = 8;\nexport const DOCUMENT_POSITION_CONTAINED_BY = 0x10;\n\n/* NodeFilter */\nexport const SHOW_ALL = 0xFFFFFFFF;\nexport const SHOW_DOCUMENT = 0x100;\nexport const SHOW_DOCUMENT_FRAGMENT = 0x400;\nexport const SHOW_ELEMENT = 1;\nexport const WALKER_FILTER = 0x501;\n\n/* selectors */\nexport const ALPHA_NUM = '[A-Z\\\\d]+';\nexport const CHILD_IDX = '(?:first|last|only)-(?:child|of-type)';\nexport const DIGIT = '(?:0|[1-9]\\\\d*)';\nexport const LANG_PART = `(?:-${ALPHA_NUM})*`;\nexport const PSEUDO_CLASSES =\n `(?:any-)?link|${CHILD_IDX}|checked|empty|indeterminate|root|target|visited`;\nexport const ANB =\n `[+-]?(?:${DIGIT}n?|n)|(?:[+-]?${DIGIT})?n\\\\s*[+-]\\\\s*${DIGIT}`;\n// N_TH: excludes An+B with selector list, e.g. :nth-child(2n+1 of .foo)\nexport const N_TH =\n `nth-(?:last-)?(?:child|of-type)\\\\(\\\\s*(?:even|odd|${ANB})\\\\s*\\\\)`;\n// SUB_TYPE: attr, id, class, pseudo-class, note that [foo|=bar] is excluded\nexport const SUB_TYPE = '\\\\[[^|\\\\]]+\\\\]|[#.:][\\\\w-]+';\n// TAG_TYPE: *, tag\nexport const TAG_TYPE = '\\\\*|[A-Za-z][\\\\w-]*';\nexport const TAG_TYPE_I = '\\\\*|[A-Z][\\\\w-]*';\n// LOGICAL_KEY: :has() and :where() are excluded\nexport const LOGICAL_KEY = '(?:is|not)';\nexport const COMPOUND = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`;\nexport const COMBO = '\\\\s?[\\\\s>~+]\\\\s?';\nexport const COMPLEX = `${COMPOUND}(?:${COMBO}${COMPOUND})*`;\nexport const NESTED_LOGICAL_A =\n `:is\\\\(\\\\s*${COMPOUND}(?:\\\\s*,\\\\s*${COMPOUND})*\\\\s*\\\\)`;\nexport const NESTED_LOGICAL_B =\n `:is\\\\(\\\\s*${COMPLEX}(?:\\\\s*,\\\\s*${COMPLEX})*\\\\s*\\\\)`;\nexport const COMPOUND_A =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_A})+)`;\nexport const COMPOUND_B =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_B})+)`;\nexport const COMPOUND_I =\n `(?:${TAG_TYPE_I}|(?:${TAG_TYPE_I})?(?:${SUB_TYPE})+)`;\nexport const COMPLEX_L = `${COMPOUND_B}(?:${COMBO}${COMPOUND_B})*`;\nexport const LOGICAL_COMPLEX =\n `${LOGICAL_KEY}\\\\(\\\\s*${COMPLEX_L}(?:\\\\s*,\\\\s*${COMPLEX_L})*\\\\s*\\\\)`;\nexport const LOGICAL_COMPOUND =\n `${LOGICAL_KEY}\\\\(\\\\s*${COMPOUND_A}(?:\\\\s*,\\\\s*${COMPOUND_A})*\\\\s*\\\\)`;\n\n/* regexp */\nexport const REG_ANCHOR = /^a(?:rea)?$/;\nexport const REG_CHILD_INDEXED = new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH})`);\nexport const REG_COMPLEX = new RegExp(`${COMBO}${COMPOUND_I}`, 'i');\nexport const REG_DIR = /^(?:ltr|rtl)$/;\nexport const REG_FORM = /^(?:button|fieldset|form|input|select|textarea)$/;\nexport const REG_FORM_CTRL =\n /^(?:button|fieldset|input|optgroup|option|select|textarea)$/;\nexport const REG_FORM_VALID = /^(?:button|form|input|select|textarea)$/;\nexport const REG_HEX = /^([\\da-f]{1,6}\\s?)/i;\nexport const REG_INTERACT = /^(?:details|dialog)$/;\nexport const REG_INVALIDATE_PSEUDO =\n /^(?:(?:any-)?link|defined|dir|has|host(?:-context)?|not)$/;\nexport const REG_INVALID_SELECTOR = /^$|^\\s*>|,\\s*$/;\nexport const REG_LANG = new RegExp(`^(?:\\\\*-)?${ALPHA_NUM}${LANG_PART}$`, 'i');\nexport const REG_LANG_QUOTED = /(:lang\\(\\s*(\"[A-Za-z\\d\\-*]*\")\\s*\\))/;\nexport const REG_LOGICAL_COMPLEX =\n new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPLEX})`);\nexport const REG_LOGICAL_COMPOUND =\n new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPOUND})`);\nexport const REG_LOGICAL_EMPTY = /(:(is|where)\\(\\s*\\))/;\nexport const REG_LOGICAL_KEY = new RegExp(`:${LOGICAL_KEY}\\\\(`);\nexport const REG_LOGICAL_PSEUDO = /^(?:has|is|not|where)$/;\nexport const REG_SHADOW_HOST = /^host(?:-context)?$/;\nexport const REG_SHADOW_MODE = /^(?:close|open)$/;\nexport const REG_SHADOW_PSEUDO = /^part|slotted$/;\nexport const REG_TYPE_CHECK = /^(?:checkbox|radio)$/;\nexport const REG_TYPE_DATE = /^(?:date(?:time-local)?|month|time|week)$/;\nexport const REG_TYPE_RANGE =\n /(?:date(?:time-local)?|month|number|range|time|week)$/;\nexport const REG_TYPE_RESET = /^(?:button|reset)$/;\nexport const REG_TYPE_SUBMIT = /^(?:image|submit)$/;\nexport const REG_TYPE_TEXT = /^(?:email|number|password|search|tel|text|url)$/;\n"],
5
+ "mappings": "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",
6
+ "names": ["constant_exports", "__export", "ALPHA_NUM", "ANB", "AN_PLUS_B", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "BIT_FFFF", "BIT_HYPHEN", "CHILD_IDX", "COMBINATOR", "COMBO", "COMPLEX", "COMPLEX_L", "COMPOUND", "COMPOUND_A", "COMPOUND_B", "COMPOUND_I", "DIGIT", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "EMPTY", "HEX", "IDENTIFIER", "LANG_PART", "LOGICAL_COMPLEX", "LOGICAL_COMPOUND", "LOGICAL_KEY", "NESTED_LOGICAL_A", "NESTED_LOGICAL_B", "NOT_SUPPORTED_ERR", "NTH", "N_TH", "PSEUDO_CLASSES", "RAW", "REG_ANCHOR", "REG_CHILD_INDEXED", "REG_COMPLEX", "REG_DIR", "REG_FORM", "REG_FORM_CTRL", "REG_FORM_VALID", "REG_HEX", "REG_INTERACT", "REG_INVALIDATE_PSEUDO", "REG_INVALID_SELECTOR", "REG_LANG", "REG_LANG_QUOTED", "REG_LOGICAL_COMPLEX", "REG_LOGICAL_COMPOUND", "REG_LOGICAL_EMPTY", "REG_LOGICAL_KEY", "REG_LOGICAL_PSEUDO", "REG_SHADOW_HOST", "REG_SHADOW_MODE", "REG_SHADOW_PSEUDO", "REG_TYPE_CHECK", "REG_TYPE_DATE", "REG_TYPE_RANGE", "REG_TYPE_RESET", "REG_TYPE_SUBMIT", "REG_TYPE_TEXT", "SELECTOR", "SELECTOR_ATTR", "SELECTOR_CLASS", "SELECTOR_ID", "SELECTOR_LIST", "SELECTOR_PSEUDO_CLASS", "SELECTOR_PSEUDO_ELEMENT", "SELECTOR_TYPE", "SHOW_ALL", "SHOW_DOCUMENT", "SHOW_DOCUMENT_FRAGMENT", "SHOW_ELEMENT", "STRING", "SUB_TYPE", "SYNTAX_ERR", "TAG_TYPE", "TAG_TYPE_I", "TARGET_ALL", "TARGET_FIRST", "TARGET_LINEAL", "TARGET_SELF", "TEXT_NODE", "TYPE_FROM", "TYPE_TO", "U_FFFD", "WALKER_FILTER", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var T=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var U=(x,o)=>{for(var e in o)T(x,e,{get:o[e],enumerable:!0})},F=(x,o,e,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of I(o))!$.call(x,n)&&n!==e&&T(x,n,{get:()=>o[n],enumerable:!(h=D(o,n))||h.enumerable});return x};var G=x=>F(T({},"__esModule",{value:!0}),x);var H={};U(H,{Finder:()=>W});module.exports=G(H);var k=require("./dom-util.js"),L=require("./matcher.js"),g=require("./parser.js"),a=require("./constant.js");const v="next",S="prev";class W{#a;#c;#m;#t;#n;#d;#o;#e;#f;#w;#b;#p;#s;#h;#r;#u;#i;#l;constructor(o){this.#l=o,this.#c=new WeakMap,this.#n=new WeakMap,this.#p=new WeakMap}_onError(o){if(!this.#w)if(o instanceof DOMException||o instanceof this.#l.DOMException)if(o.name===a.NOT_SUPPORTED_ERR)this.#i&&console.warn(o.message);else throw new this.#l.DOMException(o.message,o.name);else throw o}_setup(o,e,h={}){const{event:n,noexcept:l,warn:c}=h;return this.#w=!!l,this.#i=!!c,this.#d=this._setEvent(n),this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#h=(0,k.isInShadowTree)(e),[this.#a,this.#f]=this._correspond(o),this.#u=new WeakMap,this.#o=!1,e}_setEvent(o){return o instanceof this.#l.KeyboardEvent||o instanceof this.#l.MouseEvent?o:null}_correspond(o){const e=[];this.#m=!1;let h;if(this.#n.has(this.#t)){const n=this.#n.get(this.#t);if(n&&n.has(`${o}`)){const l=n.get(`${o}`);h=l.ast,this.#m=l.descendant}}if(h){const n=h.length;for(let l=0;l<n;l++)h[l].collected=!1,h[l].dir=null,h[l].filtered=!1,h[l].find=!1,e[l]=[]}else{let n;try{n=(0,g.parseSelector)(o)}catch(d){this._onError(d)}const{branches:l}=(0,g.walkAST)(n);let c=!1,f=0;h=[];for(const[...d]of l){const i=[];let t=d.shift();if(t&&t.type!==a.COMBINATOR){const s=new Set;for(;t;){if(t.type===a.COMBINATOR){const[r]=d;if(r.type===a.COMBINATOR){const m=`Invalid selector ${o}`;throw new DOMException(m,a.SYNTAX_ERR)}const u=t.name;/^[\s>]$/.test(u)&&(c=!0),i.push({combo:t,leaves:(0,g.sortAST)(s)}),s.clear()}else if(t){let{name:r}=t;r&&typeof r=="string"&&(r=(0,g.unescapeSelector)(r),typeof r=="string"&&r!==t.name&&(t.name=r),/[|:]/.test(r)&&(t.namespace=!0)),s.add(t)}if(d.length)t=d.shift();else{i.push({combo:null,leaves:(0,g.sortAST)(s)}),s.clear();break}}}h.push({branch:i,collected:!1,dir:null,filtered:!1,find:!1}),e[f]=[],f++}let b;this.#n.has(this.#t)?b=this.#n.get(this.#t):b=new Map,b.set(`${o}`,{ast:h,descendant:c}),this.#n.set(this.#t,b),this.#m=c}return[h,e]}_createTreeWalker(o){let e;return this.#u.has(o)?e=this.#u.get(o):(e=this.#t.createTreeWalker(o,a.WALKER_FILTER),this.#u.set(o,e)),e}_prepareQuerySelectorWalker(){return this.#b=this._createTreeWalker(this.#e),this.#b}_collectNthChild(o,e,h){const{a:n,b:l,reverse:c,selector:f}=o,{parentNode:b}=e,d=new Set;let i;if(f)if(this.#c.has(f))i=this.#c.get(f);else{const{branches:t,info:s}=(0,g.walkAST)(f);i=t,this.#c.set(f,i),s.hasLogicalPseudoFunc&&(this.#o=!0)}if(b){const t=this.#r;let s=(0,k.traverseNode)(b,t);s=t.firstChild();let r=0;for(;s;)r++,s=t.nextSibling();const u=new Set;if(i)for(s=(0,k.traverseNode)(b,t),s=t.firstChild();s;){const{display:m,visibility:w}=this.#l.getComputedStyle(s);if(m!=="none"&&w!=="hidden"){let p;for(const N of i)if(p=this._matchLeaves(N,s,h),!p)break;p&&u.add(s)}s=t.nextSibling()}if(n===0){if(l>0&&l<=r){if(u.size){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(u.has(s)){if(m===l-1){d.add(s);break}m++}c?s=t.previousSibling():s=t.nextSibling()}}else if(!f){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(m===l-1){d.add(s);break}c?s=t.previousSibling():s=t.nextSibling(),m++}}}}else{let m=l-1;if(n>0)for(;m<0;)m+=n;if(m>=0&&m<r){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let w=0,p=n>0?0:l-1;for(;s&&(s&&m>=0&&m<r);)u.size?u.has(s)&&(p===m&&(d.add(s),m+=n),n>0?p++:p--):w===m&&(f||d.add(s),m+=n),c?s=t.previousSibling():s=t.nextSibling(),w++}}if(c&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&n+l===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,h),t)break;t&&d.add(e)}else d.add(e);return d}_collectNthOfType(o,e){const{a:h,b:n,reverse:l}=o,{localName:c,parentNode:f,prefix:b}=e,d=new Set;if(f){const i=this.#r;let t=(0,k.traverseNode)(f,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(h===0){if(n>0&&n<=s){t=(0,k.traverseNode)(f,i),l?t=i.lastChild():t=i.firstChild();let r=0;for(;t;){const{localName:u,prefix:m}=t;if(u===c&&m===b){if(r===n-1){d.add(t);break}r++}l?t=i.previousSibling():t=i.nextSibling()}}}else{let r=n-1;if(h>0)for(;r<0;)r+=h;if(r>=0&&r<s){t=(0,k.traverseNode)(f,i),l?t=i.lastChild():t=i.firstChild();let u=h>0?0:n-1;for(;t;){const{localName:m,prefix:w}=t;if(m===c&&w===b){if(u===r&&(d.add(t),r+=h),r<0||r>=s)break;h>0?u++:u--}l?t=i.previousSibling():t=i.nextSibling()}}}if(l&&d.size>1){const r=[...d];return new Set(r.reverse())}}else e===this.#s&&h+n===1&&d.add(e);return d}_matchAnPlusB(o,e,h,n){const{nth:{a:l,b:c,name:f},selector:b}=o,d=new Map;if(f?(f==="even"?(d.set("a",2),d.set("b",0)):f==="odd"&&(d.set("a",2),d.set("b",1)),h.indexOf("last")>-1&&d.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?d.set("a",l*1):d.set("a",0),typeof c=="string"&&/-?\d+/.test(c)?d.set("b",c*1):d.set("b",0),h.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(h)){b&&d.set("selector",b);const i=Object.fromEntries(d);return this._collectNthChild(i,e,n)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(o,e,h={}){let n;if(Array.isArray(o)&&o.length){const l=o.map(s=>s),[c]=l,{type:f}=c;let b;f===a.COMBINATOR?b=l.shift():b={name:" ",type:a.COMBINATOR};const d=[];for(;l.length;){const[s]=l,{type:r}=s;if(r===a.COMBINATOR)break;d.push(l.shift())}const i={combo:b,leaves:d};h.dir=v;const t=this._matchCombinator(i,e,h);if(t.size)if(l.length){for(const s of t)if(n=this._matchHasPseudoFunc(l,s,h),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(o,e,h={}){const{astName:n="",branches:l=[],selector:c="",twigBranches:f=[]}=o;let b;if(n==="has")if(c.includes(":has("))b=null;else{let d;for(const i of l)if(d=this._matchHasPseudoFunc(i,e,h),d)break;d&&(b=e)}else{const d=/^(?:is|where)$/.test(n);h.forgive=d;const i=f.length;let t;for(let s=0;s<i;s++){const r=f[s],u=r.length-1,{leaves:m}=r[u];if(t=this._matchLeaves(m,e,h),t&&u>0){let w=new Set([e]);for(let p=u-1;p>=0;p--){const N=r[p],_=[];h.dir=S;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?t=!0:w=new Set(_);else{t=!1;break}}}if(t)break}n==="not"?t||(b=e):t&&(b=e)}return b??null}_matchPseudoClassSelector(o,e,h={}){const{children:n,name:l}=o,{localName:c,parentNode:f}=e,{forgive:b,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(l)){let t;if(this.#c.has(o))t=this.#c.get(o);else{const{branches:r}=(0,g.walkAST)(o),u=[],m=[];for(const[...w]of r){for(const y of w){const E=(0,g.generateCSS)(y);u.push(E)}const p=[],N=new Set;let _=w.shift();for(;_;)if(_.type===a.COMBINATOR?(p.push({combo:_,leaves:[...N]}),N.clear()):_&&N.add(_),w.length)_=w.shift();else{p.push({combo:null,leaves:[...N]}),N.clear();break}m.push(p)}t={astName:l,branches:r,twigBranches:m,selector:u.join(",")},this.#c.set(o,t)}const s=this._matchLogicalPseudoFunc(t,e,h);s&&i.add(s)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[t]=n;return this._matchAnPlusB(t,e,l,h)}else switch(l){case"dir":case"lang":{const t=L.matcher.matchSelector(o,e);t&&i.add(t);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:t}]=n;t&&e[t]&&i.add(e)}break}case"current":case"nth-col":case"nth-last-col":{if(d){const t=`Unsupported pseudo-class :${l}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(d){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(!b){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,a.SYNTAX_ERR)}}else switch(l){case"any-link":case"link":{a.REG_ANCHOR.test(c)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(a.REG_ANCHOR.test(c)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:r}=new URL(this.#t.URL),u=new URL(e.getAttribute("href"),t);u.origin===s&&u.pathname===r&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#d??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:r}=this.#d??{};(r==="mousedown"||r==="pointerdown")&&t&a.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#t.URL);e.id&&t===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#t.URL);if(t){const s=t.replace(/^#/,"");let r=this.#t.getElementById(s);for(;r;){if(r===e){i.add(e);break}r=r.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#h&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#d??{};if(e===this.#t.activeElement&&e.tabIndex>=0&&(l==="focus"||s==="keydown"&&e.contains(t))){let r=e,u=!0;for(;r;){if(r.disabled||r.hasAttribute("disabled")||r.hidden||r.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(r);if(u=!(m==="none"||w==="hidden"),!u)break}if(r.parentNode&&r.parentNode.nodeType===a.ELEMENT_NODE)r=r.parentNode;else break}u&&i.add(e)}break}case"focus-within":{let t,s=this.#t.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.parentNode}if(t){let r=e,u=!0;for(;r;){if(r.disabled||r.hasAttribute("disabled")||r.hidden||r.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(r);if(u=!(m==="none"||w==="hidden"),!u)break}if(r.parentNode&&r.parentNode.nodeType===a.ELEMENT_NODE)r=r.parentNode;else break}u&&i.add(e)}break}case"open":{a.REG_INTERACT.test(c)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{a.REG_INTERACT.test(c)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(a.REG_FORM_CTRL.test(c)||(0,k.isCustomElement)(e,{formAssociated:!0})){if(e.disabled||e.hasAttribute("disabled"))i.add(e);else if(e.localName==="option")f.localName==="optgroup"&&(f.disabled||f.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const r=this.#r;let u=(0,k.traverseNode)(s,r);for(u=r.firstChild();u&&u.localName!=="legend";)u=r.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t&&i.add(e)}}break}case"enabled":{if((a.REG_FORM_CTRL.test(c)||(0,k.isCustomElement)(e,{formAssociated:!0}))&&!(e.disabled&&e.hasAttribute("disabled")))if(e.localName==="optgroup")i.add(e);else if(e.localName==="option")(f.localName!=="optgroup"||!(f.disabled||f.hasAttribute("disabled")))&&i.add(e);else{let t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const r=this.#r;let u=(0,k.traverseNode)(s,r);for(u=r.firstChild();u&&u.localName!=="legend";)u=r.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t||i.add(e)}break}case"read-only":{switch(c){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(c){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;c==="textarea"?s=e:c==="input"&&(e.hasAttribute("type")?a.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&c==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&c==="input"&&e.type==="checkbox"||c==="progress"&&!e.hasAttribute("value"))i.add(e);else if(c==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;s||(s=this.#t.documentElement);const r=s.getElementsByTagName("input"),u=r.length;let m;for(let w=0;w<u;w++){const p=r[w];if(p.getAttribute("type")==="radio"&&(t?p.getAttribute("name")===t&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(c==="button"&&!(e.hasAttribute("type")&&a.REG_TYPE_RESET.test(e.getAttribute("type")))||c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#r;let r=(0,k.traverseNode)(t,s);for(r=s.firstChild();r&&t.contains(r);){const u=r.localName;let m;if(u==="button"?m=!(r.hasAttribute("type")&&a.REG_TYPE_RESET.test(r.getAttribute("type"))):u==="input"&&(m=r.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(r.getAttribute("type"))),m){r===e&&i.add(e);break}r=s.nextNode()}}}else(c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))&&e.hasAttribute("checked")||c==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(a.REG_FORM_VALID.test(c))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(c==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let r;if(!s)r=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?r=s.maxLength>=s.value.length:r=!0:r=!1,!r));)s=t.nextNode();r&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(c))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(c==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let r;if(!s)r=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?r=s.maxLength>=s.value.length:r=!0:r=!1,!r));)s=t.nextNode();r||i.add(e)}break}case"in-range":{c==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&i.add(e);break}case"out-of-range":{c==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(c))t=e;else if(c==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(c))t=e;else if(c==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#t.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#t.createTreeWalker(e,a.SHOW_ALL);let s=t.firstChild(),r;for(;s&&(r=s.nodeType!==a.ELEMENT_NODE&&s.nodeType!==a.TEXT_NODE,!!r);)s=t.nextSibling();r&&i.add(e)}else i.add(e);break}case"first-child":{(f&&e===f.firstElementChild||e===this.#s)&&i.add(e);break}case"last-child":{(f&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"only-child":{(f&&e===f.firstElementChild&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"first-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s===e&&i.add(e)}}else e===this.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||c.includes("-")?(0,k.isCustomElement)(e)&&i.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.SVGElement)&&i.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#l.getComputedStyle(e);t!=="none"&&i.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d){const t=`Unsupported pseudo-element ::${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"autofill":case"blank":case"buffering":case"current":case"fullscreen":case"future":case"modal":case"muted":case"past":case"paused":case"picture-in-picture":case"playing":case"seeking":case"stalled":case"user-invalid":case"user-valid":case"volume-locked":case"-webkit-autofill":{if(d){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(l.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}}else if(!b){const t=`Unknown pseudo-class :${l}`;throw new DOMException(t,a.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(o,e){const{children:h,name:n}=o;let l;if(Array.isArray(h)){const{branches:c}=(0,g.walkAST)(h[0]),[f]=c,[...b]=f,{host:d}=e;if(n==="host"){let i;for(const t of b){const{type:s}=t;if(s===a.COMBINATOR){const u=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(u,a.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}i&&(l=e)}else if(n==="host-context"){let i=d,t;for(;i;){for(const s of b){const{type:r}=s;if(r===a.COMBINATOR){const m=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(m,a.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}t&&(l=e)}}else if(n==="host")l=e;else{const c=`Invalid selector :${n}`;throw new DOMException(c,a.SYNTAX_ERR)}return l??null}_matchSelector(o,e,h){const{type:n}=o,l=new Set;if(o.name===a.EMPTY)return l;const c=(0,g.unescapeSelector)(o.name);if(typeof c=="string"&&c!==o.name&&(o.name=c),e.nodeType===a.ELEMENT_NODE)switch(n){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(c,h);break}case a.SELECTOR_ID:{e.id===c&&l.add(e);break}case a.SELECTOR_CLASS:{e.classList.contains(c)&&l.add(e);break}case a.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(o,e,h);default:{const f=L.matcher.matchSelector(o,e,h);f&&l.add(f)}}else if(this.#h&&n===a.SELECTOR_PSEUDO_CLASS&&e.nodeType===a.DOCUMENT_FRAGMENT_NODE){if(c!=="has"&&a.REG_LOGICAL_PSEUDO.test(c))return this._matchPseudoClassSelector(o,e,h);if(a.REG_SHADOW_HOST.test(c)){const f=this._matchShadowHostPseudoClass(o,e,h);f&&l.add(f)}}return l}_matchLeaves(o,e,h){let n,l=this.#p.get(o);if(l&&l.has(e)){const{matched:c}=l.get(e);n=c}if(typeof n!="boolean"){for(const f of o){switch(f.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{this.#o=!0;break}case a.SELECTOR_PSEUDO_CLASS:{/^(?:(?:any-)?link|defined|dir|has)$/.test(f.name)&&(this.#o=!0);break}default:}if(n=this._matchSelector(f,e,h).has(e),!n)break}let c=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(c=!1),c&&!this.#o&&(l||(l=new WeakMap),l.set(e,{matched:n}),this.#p.set(o,l))}return!!n}_matchHTMLCollection(o,e={}){const{compound:h,filterLeaves:n}=e,l=new Set,c=o.length;if(c)if(h)for(let f=0;f<c;f++){const b=o[f];this._matchLeaves(n,b,e)&&l.add(b)}else{const f=[].slice.call(o);return new Set(f)}return l}_findDescendantNodes(o,e,h){const[n,...l]=o,c=l.length>0,{type:f}=n,b=(0,g.unescapeSelector)(n.name);typeof b=="string"&&b!==n.name&&(n.name=b);let d=new Set,i=!1;if(this.#h)i=!0;else switch(f){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,h);break}case a.SELECTOR_ID:{if(this.#s.nodeType===a.ELEMENT_NODE)i=!0;else{const t=this.#s.getElementById(b);t&&t!==e&&e.contains(t)&&(c?this._matchLeaves(l,t,h)&&d.add(t):d.add(t))}break}case a.SELECTOR_CLASS:{const t=e.getElementsByClassName(b);d=this._matchHTMLCollection(t,{compound:c,filterLeaves:l});break}case a.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(b)){const t=e.getElementsByTagName(b);d=this._matchHTMLCollection(t,{compound:c,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(o,e,h={}){const{combo:n,leaves:l}=o,{name:c}=n,{parentNode:f}=e,{dir:b}=h,d=new Set;if(b===v)switch(c){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(e,i);for(t=i.nextSibling();t;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=(0,k.traverseNode)(e,i);for(t=i.firstChild();t;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(l,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let r=(0,k.traverseNode)(e,s);for(r=s.nextNode();r&&e.contains(r);)this._matchLeaves(l,r,h)&&d.add(r),r=s.nextNode()}}}else switch(c){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(f,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{f&&this._matchLeaves(l,f,h)&&d.add(f);break}case" ":default:{const i=[];let t=f;for(;t;)this._matchLeaves(l,t,h)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(o,e){const{node:h}=e,n=this.#b;let l=(0,k.traverseNode)(h,n),c;if(l)for((l.nodeType!==a.ELEMENT_NODE||l===h&&l!==this.#s)&&(l=n.nextNode());l;){if(this._matchLeaves(o,l,{warn:this.#i})){c=l;break}l=n.nextNode()}return c??null}_matchSelf(o){const e=[],h=this._matchLeaves(o,this.#e,{warn:this.#i});let n=!1;return h&&(e.push(this.#e),n=!0),[e,n]}_findLineal(o,e={}){const{complex:h}=e,n=[];let l=this._matchLeaves(o,this.#e,{warn:this.#i}),c=!1;if(l&&(n.push(this.#e),c=!0),!l||h){let f=this.#e.parentNode;for(;f&&(l=this._matchLeaves(o,f,{warn:this.#i}),l&&(n.push(f),c=!0),f.parentNode);)f=f.parentNode}return[n,c]}_findFirst(o){const e=[],h=this._findNode(o,{node:this.#e});let n=!1;return h&&(e.push(h),n=!0),[e,n]}_findFromHTMLCollection(o,e={}){const{complex:h,compound:n,filterLeaves:l,targetType:c}=e;let f=[],b=!1,d=!1;const i=o.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let t=0;t<i;t++){const s=o[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(n){if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else if(f.push(s),b=!0,c===a.TARGET_FIRST)break}}else if(h)if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;else if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;return[f,b,d]}_findEntryNodes(o,e,h){const{leaves:n}=o,[l,...c]=n,f=c.length>0,{name:b,type:d}=l;let i=[],t=!1,s=!1,r=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(e===a.TARGET_FIRST&&this.#s.nodeType!==a.ELEMENT_NODE){const u=this.#s.getElementById(b);u&&(f?this._matchLeaves(c,u,{warn:this.#i})&&(i.push(u),s=!0):(i.push(u),s=!0))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):r=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(this.#s.nodeType===a.DOCUMENT_NODE){const u=this.#s.getElementsByClassName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:c,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):r=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===a.DOCUMENT_NODE&&!/[*|]/.test(b)){const u=this.#s.getElementsByTagName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:c,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):r=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(b)){if(this.#h&&this.#e.nodeType===a.DOCUMENT_FRAGMENT_NODE){const u=this._matchShadowHostPseudoClass(l,this.#e);u&&(i.push(u),s=!0)}}else e===a.TARGET_SELF?[i,s]=this._matchSelf(n):e===a.TARGET_LINEAL?[i,s]=this._findLineal(n,{complex:h}):e===a.TARGET_FIRST?[i,s]=this._findFirst(n):r=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:r}}_collectNodes(o){const e=this.#a.values();if(o===a.TARGET_ALL||o===a.TARGET_FIRST){const h=new Set;let n=0;for(const{branch:l}of e){const c=l.length,f=c>1,b=l[0];let d,i;if(f){const{combo:w,leaves:[{name:p,type:N}]}=b,_=l[c-1],{leaves:[{name:y,type:E}]}=_;if(E===a.SELECTOR_PSEUDO_ELEMENT||E===a.SELECTOR_ID)d=S,i=_;else if(N===a.SELECTOR_PSEUDO_ELEMENT||N===a.SELECTOR_ID)d=v,i=b;else if(o===a.TARGET_ALL)if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(c===2){const{name:A}=w;/^[+~]$/.test(A)?(d=S,i=_):(d=v,i=b)}else d=v,i=b;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else{let A;for(const{combo:C,leaves:[O]}of l){const{name:R,type:M}=O;if(M===a.SELECTOR_PSEUDO_CLASS&&R==="dir"){A=!1;break}if(!A&&C){const{name:P}=C;/^[+~]$/.test(P)&&(A=!0)}}A?(d=v,i=b):(d=S,i=_)}}else d=S,i=b;const{collected:t,compound:s,filtered:r,nodes:u,pending:m}=this._findEntryNodes(i,o,f);u.length?(this.#a[n].find=!0,this.#f[n]=u):m&&h.add(new Map([["index",n],["twig",i]])),this.#a[n].collected=t,this.#a[n].dir=d,this.#a[n].filtered=r||!s,n++}if(h.size){let l,c;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(l=this.#e,c=this.#b):(l=this.#s,c=this.#r);let f=(0,k.traverseNode)(l,c);for(;f;){let b=!1;if(this.#e.nodeType===a.ELEMENT_NODE?f===this.#e?b=!0:b=this.#e.contains(f):b=!0,b)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,f,{warn:this.#i})){const s=d.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#f[s].push(f)}}f!==c.currentNode&&(f=(0,k.traverseNode)(f,c)),f=c.nextNode()}}}else{let h=0;for(const{branch:n}of e){const l=n[n.length-1],c=n.length>1,{compound:f,filtered:b,nodes:d}=this._findEntryNodes(l,o,c);d.length&&(this.#a[h].find=!0,this.#f[h]=d),this.#a[h].dir=S,this.#a[h].filtered=b||!f,h++}}return[this.#a,this.#f]}_getCombinedNodes(o,e,h){const n=[];for(const l of e){const c=this._matchCombinator(o,l,{dir:h,warn:this.#i});c.size&&n.push(...c)}return n.length?new Set(n):new Set}_matchNodeNext(o,e,h){const{combo:n,index:l}=h,{combo:c,leaves:f}=o[l],b={combo:n,leaves:f},d=this._getCombinedNodes(b,e,v);let i;if(d.size)if(l===o.length-1){const[t]=(0,k.sortNodes)(d);i=t}else i=this._matchNodeNext(o,d,{combo:c,index:l+1});return i??null}_matchNodePrev(o,e,h){const{index:n}=h,l=o[n],c=new Set([e]),f=this._getCombinedNodes(l,c,S);let b;if(f.size){if(n===0)b=e;else for(const d of f)if(this._matchNodePrev(o,d,{index:n-1}))return e}return b??null}_find(o){(o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(o),n=e.length;let l,c=new Set;for(let f=0;f<n;f++){const{branch:b,collected:d,dir:i,find:t}=e[f],s=b.length;if(s&&t){const r=h[f],u=r.length,m=s-1;if(m===0)if((o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this.#e.nodeType===a.ELEMENT_NODE)for(let w=0;w<u;w++){const p=r[w];if(p!==this.#e&&this.#e.contains(p)&&(c.add(p),o!==a.TARGET_ALL))break}else if(o===a.TARGET_ALL)if(c.size){const w=[...c];c=new Set([...w,...r]),l=!0}else c=new Set(r);else{const[w]=r;c.add(w)}else if(o===a.TARGET_ALL)if(i===v){let{combo:w}=b[0];for(const p of r){let N=new Set([p]);for(let _=1;_<s;_++){const{combo:y,leaves:E}=b[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(c.size){const C=[...c];c=new Set([...C,...N]),l=!0}else c=N;else w=y;else break}}}else for(const w of r){let p=new Set([w]);for(let N=m-1;N>=0;N--){const _=b[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(c.add(w),s>1&&c.size>1&&(l=!0));else break}}else if(o===a.TARGET_FIRST&&i===v){const{combo:w}=b[0];let p;for(const N of r)if(p=this._matchNodeNext(b,new Set([N]),{combo:w,index:1}),p){c.add(p);break}if(!p&&!d){const{leaves:N}=b[0],[_]=r;let y=this._findNode(N,{node:_});for(;y;){if(p=this._matchNodeNext(b,new Set([y]),{combo:w,index:1}),p){c.add(p);break}y=this._findNode(N,{node:y})}}}else{let w;for(const p of r)if(w=this._matchNodePrev(b,p,{index:m-1}),w){c.add(p);break}if(!w&&!d&&o===a.TARGET_FIRST){const{leaves:p}=b[m],[N]=r;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(b,_,{index:m-1}),w){c.add(_);break}_=this._findNode(p,{node:_})}}}}}return o===a.TARGET_ALL&&l&&(c=new Set((0,k.sortNodes)(c))),c}}0&&(module.exports={Finder});
1
+ var T=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var $=(x,o)=>{for(var e in o)T(x,e,{get:o[e],enumerable:!0})},F=(x,o,e,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of I(o))!U.call(x,n)&&n!==e&&T(x,n,{get:()=>o[n],enumerable:!(h=D(o,n))||h.enumerable});return x};var G=x=>F(T({},"__esModule",{value:!0}),x);var W={};$(W,{Finder:()=>H});module.exports=G(W);var k=require("./dom-util.js"),L=require("./matcher.js"),g=require("./parser.js"),a=require("./constant.js");const v="next",S="prev";class H{#a;#c;#m;#t;#n;#d;#o;#e;#f;#w;#b;#p;#s;#h;#r;#u;#i;#l;constructor(o){this.#l=o,this.#c=new WeakMap,this.#n=new WeakMap,this.#p=new WeakMap}_onError(o){if(!this.#w)if(o instanceof DOMException||o instanceof this.#l.DOMException)if(o.name===a.NOT_SUPPORTED_ERR)this.#i&&console.warn(o.message);else throw new this.#l.DOMException(o.message,o.name);else throw o}_setup(o,e,h={}){const{event:n,noexcept:r,warn:c}=h;return this.#w=!!r,this.#i=!!c,this.#d=this._setEvent(n),this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#h=(0,k.isInShadowTree)(e),[this.#a,this.#f]=this._correspond(o),this.#u=new WeakMap,this.#o=!1,e}_setEvent(o){return o instanceof this.#l.KeyboardEvent||o instanceof this.#l.MouseEvent?o:null}_correspond(o){const e=[];this.#m=!1;let h;if(this.#n.has(this.#t)){const n=this.#n.get(this.#t);if(n&&n.has(`${o}`)){const r=n.get(`${o}`);h=r.ast,this.#m=r.descendant,this.#o=r.invalidate}}if(h){const n=h.length;for(let r=0;r<n;r++)h[r].collected=!1,h[r].dir=null,h[r].filtered=!1,h[r].find=!1,e[r]=[]}else{let n;try{n=(0,g.parseSelector)(o)}catch(t){this._onError(t)}const{branches:r,info:{hasHasPseudo:c}}=(0,g.walkAST)(n),f=!!c;let b=!1,d=0;h=[];for(const[...t]of r){const s=[];let l=t.shift();if(l&&l.type!==a.COMBINATOR){const u=new Set;for(;l;){if(l.type===a.COMBINATOR){const[m]=t;if(m.type===a.COMBINATOR){const p=`Invalid selector ${o}`;throw new DOMException(p,a.SYNTAX_ERR)}const w=l.name;/^[\s>]$/.test(w)&&(b=!0),s.push({combo:l,leaves:(0,g.sortAST)(u)}),u.clear()}else if(l){let{name:m}=l;m&&typeof m=="string"&&(m=(0,g.unescapeSelector)(m),typeof m=="string"&&m!==l.name&&(l.name=m),/[|:]/.test(m)&&(l.namespace=!0)),u.add(l)}if(t.length)l=t.shift();else{s.push({combo:null,leaves:(0,g.sortAST)(u)}),u.clear();break}}}h.push({branch:s,collected:!1,dir:null,filtered:!1,find:!1}),e[d]=[],d++}let i;this.#n.has(this.#t)?i=this.#n.get(this.#t):i=new Map,i.set(`${o}`,{ast:h,descendant:b,invalidate:f}),this.#n.set(this.#t,i),this.#m=b,this.#o=f}return[h,e]}_createTreeWalker(o){let e;return this.#u.has(o)?e=this.#u.get(o):(e=this.#t.createTreeWalker(o,a.WALKER_FILTER),this.#u.set(o,e)),e}_prepareQuerySelectorWalker(){return this.#b=this._createTreeWalker(this.#e),this.#b}_collectNthChild(o,e,h){const{a:n,b:r,reverse:c,selector:f}=o,{parentNode:b}=e,d=new Set;let i;if(f)if(this.#c.has(f))i=this.#c.get(f);else{const{branches:t,info:s}=(0,g.walkAST)(f);i=t,this.#c.set(f,i),s.hasLogicalPseudoFunc&&(this.#o=!0)}if(b){const t=this.#r;let s=(0,k.traverseNode)(b,t);s=t.firstChild();let l=0;for(;s;)l++,s=t.nextSibling();const u=new Set;if(i)for(s=(0,k.traverseNode)(b,t),s=t.firstChild();s;){const{display:m,visibility:w}=this.#l.getComputedStyle(s);if(m!=="none"&&w!=="hidden"){let p;for(const N of i)if(p=this._matchLeaves(N,s,h),!p)break;p&&u.add(s)}s=t.nextSibling()}if(n===0){if(r>0&&r<=l){if(u.size){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(u.has(s)){if(m===r-1){d.add(s);break}m++}c?s=t.previousSibling():s=t.nextSibling()}}else if(!f){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(m===r-1){d.add(s);break}c?s=t.previousSibling():s=t.nextSibling(),m++}}}}else{let m=r-1;if(n>0)for(;m<0;)m+=n;if(m>=0&&m<l){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let w=0,p=n>0?0:r-1;for(;s&&(s&&m>=0&&m<l);)u.size?u.has(s)&&(p===m&&(d.add(s),m+=n),n>0?p++:p--):w===m&&(f||d.add(s),m+=n),c?s=t.previousSibling():s=t.nextSibling(),w++}}if(c&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&n+r===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,h),t)break;t&&d.add(e)}else d.add(e);return d}_collectNthOfType(o,e){const{a:h,b:n,reverse:r}=o,{localName:c,parentNode:f,prefix:b}=e,d=new Set;if(f){const i=this.#r;let t=(0,k.traverseNode)(f,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(h===0){if(n>0&&n<=s){t=(0,k.traverseNode)(f,i),r?t=i.lastChild():t=i.firstChild();let l=0;for(;t;){const{localName:u,prefix:m}=t;if(u===c&&m===b){if(l===n-1){d.add(t);break}l++}r?t=i.previousSibling():t=i.nextSibling()}}}else{let l=n-1;if(h>0)for(;l<0;)l+=h;if(l>=0&&l<s){t=(0,k.traverseNode)(f,i),r?t=i.lastChild():t=i.firstChild();let u=h>0?0:n-1;for(;t;){const{localName:m,prefix:w}=t;if(m===c&&w===b){if(u===l&&(d.add(t),l+=h),l<0||l>=s)break;h>0?u++:u--}r?t=i.previousSibling():t=i.nextSibling()}}}if(r&&d.size>1){const l=[...d];return new Set(l.reverse())}}else e===this.#s&&h+n===1&&d.add(e);return d}_matchAnPlusB(o,e,h,n){const{nth:{a:r,b:c,name:f},selector:b}=o,d=new Map;if(f?(f==="even"?(d.set("a",2),d.set("b",0)):f==="odd"&&(d.set("a",2),d.set("b",1)),h.indexOf("last")>-1&&d.set("reverse",!0)):(typeof r=="string"&&/-?\d+/.test(r)?d.set("a",r*1):d.set("a",0),typeof c=="string"&&/-?\d+/.test(c)?d.set("b",c*1):d.set("b",0),h.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(h)){b&&d.set("selector",b);const i=Object.fromEntries(d);return this._collectNthChild(i,e,n)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(o,e,h={}){let n;if(Array.isArray(o)&&o.length){const r=o.map(s=>s),[c]=r,{type:f}=c;let b;f===a.COMBINATOR?b=r.shift():b={name:" ",type:a.COMBINATOR};const d=[];for(;r.length;){const[s]=r,{type:l}=s;if(l===a.COMBINATOR)break;d.push(r.shift())}const i={combo:b,leaves:d};h.dir=v;const t=this._matchCombinator(i,e,h);if(t.size)if(r.length){for(const s of t)if(n=this._matchHasPseudoFunc(r,s,h),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(o,e,h={}){const{astName:n="",branches:r=[],selector:c="",twigBranches:f=[]}=o;let b;if(n==="has")if(c.includes(":has("))b=null;else{let d;for(const i of r)if(d=this._matchHasPseudoFunc(i,e,h),d)break;d&&(b=e)}else{const d=/^(?:is|where)$/.test(n);h.forgive=d;const i=f.length;let t;for(let s=0;s<i;s++){const l=f[s],u=l.length-1,{leaves:m}=l[u];if(t=this._matchLeaves(m,e,h),t&&u>0){let w=new Set([e]);for(let p=u-1;p>=0;p--){const N=l[p],_=[];h.dir=S;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?t=!0:w=new Set(_);else{t=!1;break}}}if(t)break}n==="not"?t||(b=e):t&&(b=e)}return b??null}_matchPseudoClassSelector(o,e,h={}){const{children:n,name:r}=o,{localName:c,parentNode:f}=e,{forgive:b,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(r)){let t;if(this.#c.has(o))t=this.#c.get(o);else{const{branches:l}=(0,g.walkAST)(o),u=[],m=[];for(const[...w]of l){for(const y of w){const E=(0,g.generateCSS)(y);u.push(E)}const p=[],N=new Set;let _=w.shift();for(;_;)if(_.type===a.COMBINATOR?(p.push({combo:_,leaves:[...N]}),N.clear()):_&&N.add(_),w.length)_=w.shift();else{p.push({combo:null,leaves:[...N]}),N.clear();break}m.push(p)}t={astName:r,branches:l,twigBranches:m,selector:u.join(",")},this.#c.set(o,t)}const s=this._matchLogicalPseudoFunc(t,e,h);s&&i.add(s)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(r)){const[t]=n;return this._matchAnPlusB(t,e,r,h)}else switch(r){case"dir":case"lang":{const t=L.matcher.matchSelector(o,e);t&&i.add(t);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:t}]=n;t&&e[t]&&i.add(e)}break}case"current":case"nth-col":case"nth-last-col":{if(d){const t=`Unsupported pseudo-class :${r}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(d){const t=`Unknown pseudo-class :${r}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(!b){const t=`Unknown pseudo-class :${r}()`;throw new DOMException(t,a.SYNTAX_ERR)}}else switch(r){case"any-link":case"link":{a.REG_ANCHOR.test(c)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(a.REG_ANCHOR.test(c)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:l}=new URL(this.#t.URL),u=new URL(e.getAttribute("href"),t);u.origin===s&&u.pathname===l&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#d??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:l}=this.#d??{};(l==="mousedown"||l==="pointerdown")&&t&a.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#t.URL);e.id&&t===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#t.URL);if(t){const s=t.replace(/^#/,"");let l=this.#t.getElementById(s);for(;l;){if(l===e){i.add(e);break}l=l.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#h&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#d??{};if(e===this.#t.activeElement&&e.tabIndex>=0&&(r==="focus"||s==="keydown"&&e.contains(t))){let l=e,u=!0;for(;l;){if(l.disabled||l.hasAttribute("disabled")||l.hidden||l.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(l);if(u=!(m==="none"||w==="hidden"),!u)break}if(l.parentNode&&l.parentNode.nodeType===a.ELEMENT_NODE)l=l.parentNode;else break}u&&i.add(e)}break}case"focus-within":{let t,s=this.#t.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.parentNode}if(t){let l=e,u=!0;for(;l;){if(l.disabled||l.hasAttribute("disabled")||l.hidden||l.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(l);if(u=!(m==="none"||w==="hidden"),!u)break}if(l.parentNode&&l.parentNode.nodeType===a.ELEMENT_NODE)l=l.parentNode;else break}u&&i.add(e)}break}case"open":{a.REG_INTERACT.test(c)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{a.REG_INTERACT.test(c)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(a.REG_FORM_CTRL.test(c)||(0,k.isCustomElement)(e,{formAssociated:!0})){if(e.disabled||e.hasAttribute("disabled"))i.add(e);else if(e.localName==="option")f.localName==="optgroup"&&(f.disabled||f.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const l=this.#r;let u=(0,k.traverseNode)(s,l);for(u=l.firstChild();u&&u.localName!=="legend";)u=l.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t&&i.add(e)}}break}case"enabled":{if((a.REG_FORM_CTRL.test(c)||(0,k.isCustomElement)(e,{formAssociated:!0}))&&!(e.disabled&&e.hasAttribute("disabled")))if(e.localName==="optgroup")i.add(e);else if(e.localName==="option")(f.localName!=="optgroup"||!(f.disabled||f.hasAttribute("disabled")))&&i.add(e);else{let t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const l=this.#r;let u=(0,k.traverseNode)(s,l);for(u=l.firstChild();u&&u.localName!=="legend";)u=l.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t||i.add(e)}break}case"read-only":{switch(c){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(c){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;c==="textarea"?s=e:c==="input"&&(e.hasAttribute("type")?a.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&c==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&c==="input"&&e.type==="checkbox"||c==="progress"&&!e.hasAttribute("value"))i.add(e);else if(c==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;s||(s=this.#t.documentElement);const l=s.getElementsByTagName("input"),u=l.length;let m;for(let w=0;w<u;w++){const p=l[w];if(p.getAttribute("type")==="radio"&&(t?p.getAttribute("name")===t&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(c==="button"&&!(e.hasAttribute("type")&&a.REG_TYPE_RESET.test(e.getAttribute("type")))||c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#r;let l=(0,k.traverseNode)(t,s);for(l=s.firstChild();l&&t.contains(l);){const u=l.localName;let m;if(u==="button"?m=!(l.hasAttribute("type")&&a.REG_TYPE_RESET.test(l.getAttribute("type"))):u==="input"&&(m=l.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(l.getAttribute("type"))),m){l===e&&i.add(e);break}l=s.nextNode()}}}else(c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))&&e.hasAttribute("checked")||c==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(a.REG_FORM_VALID.test(c))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(c==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let l;if(!s)l=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?l=s.maxLength>=s.value.length:l=!0:l=!1,!l));)s=t.nextNode();l&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(c))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(c==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let l;if(!s)l=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?l=s.maxLength>=s.value.length:l=!0:l=!1,!l));)s=t.nextNode();l||i.add(e)}break}case"in-range":{c==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&i.add(e);break}case"out-of-range":{c==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(c))t=e;else if(c==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(c))t=e;else if(c==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#t.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#t.createTreeWalker(e,a.SHOW_ALL);let s=t.firstChild(),l;for(;s&&(l=s.nodeType!==a.ELEMENT_NODE&&s.nodeType!==a.TEXT_NODE,!!l);)s=t.nextSibling();l&&i.add(e)}else i.add(e);break}case"first-child":{(f&&e===f.firstElementChild||e===this.#s)&&i.add(e);break}case"last-child":{(f&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"only-child":{(f&&e===f.firstElementChild&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"first-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s===e&&i.add(e)}}else e===this.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||c.includes("-")?(0,k.isCustomElement)(e)&&i.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.SVGElement)&&i.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#l.getComputedStyle(e);t!=="none"&&i.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d){const t=`Unsupported pseudo-element ::${r}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"autofill":case"blank":case"buffering":case"current":case"fullscreen":case"future":case"modal":case"muted":case"past":case"paused":case"picture-in-picture":case"playing":case"seeking":case"stalled":case"user-invalid":case"user-valid":case"volume-locked":case"-webkit-autofill":{if(d){const t=`Unsupported pseudo-class :${r}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(r.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${r}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}}else if(!b){const t=`Unknown pseudo-class :${r}`;throw new DOMException(t,a.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(o,e){const{children:h,name:n}=o;let r;if(Array.isArray(h)){const{branches:c}=(0,g.walkAST)(h[0]),[f]=c,[...b]=f,{host:d}=e;if(n==="host"){let i;for(const t of b){const{type:s}=t;if(s===a.COMBINATOR){const u=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(u,a.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}i&&(r=e)}else if(n==="host-context"){let i=d,t;for(;i;){for(const s of b){const{type:l}=s;if(l===a.COMBINATOR){const m=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(m,a.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}t&&(r=e)}}else if(n==="host")r=e;else{const c=`Invalid selector :${n}`;throw new DOMException(c,a.SYNTAX_ERR)}return r??null}_matchSelector(o,e,h){const{type:n}=o,r=new Set;if(o.name===a.EMPTY)return r;const c=(0,g.unescapeSelector)(o.name);if(typeof c=="string"&&c!==o.name&&(o.name=c),e.nodeType===a.ELEMENT_NODE)switch(n){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(c,h);break}case a.SELECTOR_ID:{e.id===c&&r.add(e);break}case a.SELECTOR_CLASS:{e.classList.contains(c)&&r.add(e);break}case a.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(o,e,h);default:{const f=L.matcher.matchSelector(o,e,h);f&&r.add(f)}}else if(this.#h&&n===a.SELECTOR_PSEUDO_CLASS&&e.nodeType===a.DOCUMENT_FRAGMENT_NODE){if(c!=="has"&&a.REG_LOGICAL_PSEUDO.test(c))return this._matchPseudoClassSelector(o,e,h);if(a.REG_SHADOW_HOST.test(c)){const f=this._matchShadowHostPseudoClass(o,e,h);f&&r.add(f)}}return r}_matchLeaves(o,e,h){let n,r=this.#p.get(o);if(r&&r.has(e)){const{matched:c}=r.get(e);n=c}if(typeof n!="boolean"){let c=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(c=!1);for(const f of o){switch(f.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{c=!1;break}case a.SELECTOR_PSEUDO_CLASS:{a.REG_INVALIDATE_PSEUDO.test(f.name)&&(c=!1);break}default:}if(n=this._matchSelector(f,e,h).has(e),!n)break}c&&!this.#o&&(r||(r=new WeakMap),r.set(e,{matched:n}),this.#p.set(o,r))}return!!n}_matchHTMLCollection(o,e={}){const{compound:h,filterLeaves:n}=e,r=new Set,c=o.length;if(c)if(h)for(let f=0;f<c;f++){const b=o[f];this._matchLeaves(n,b,e)&&r.add(b)}else{const f=[].slice.call(o);return new Set(f)}return r}_findDescendantNodes(o,e,h){const[n,...r]=o,c=r.length>0,{type:f}=n,b=(0,g.unescapeSelector)(n.name);typeof b=="string"&&b!==n.name&&(n.name=b);let d=new Set,i=!1;if(this.#h)i=!0;else switch(f){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,h);break}case a.SELECTOR_ID:{if(this.#s.nodeType===a.ELEMENT_NODE)i=!0;else{const t=this.#s.getElementById(b);t&&t!==e&&e.contains(t)&&(c?this._matchLeaves(r,t,h)&&d.add(t):d.add(t))}break}case a.SELECTOR_CLASS:{const t=e.getElementsByClassName(b);d=this._matchHTMLCollection(t,{compound:c,filterLeaves:r});break}case a.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(b)){const t=e.getElementsByTagName(b);d=this._matchHTMLCollection(t,{compound:c,filterLeaves:r})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(o,e,h={}){const{combo:n,leaves:r}=o,{name:c}=n,{parentNode:f}=e,{dir:b}=h,d=new Set;if(b===v)switch(c){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(r,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(e,i);for(t=i.nextSibling();t;)this._matchLeaves(r,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=(0,k.traverseNode)(e,i);for(t=i.firstChild();t;)this._matchLeaves(r,t,h)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(r,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let l=(0,k.traverseNode)(e,s);for(l=s.nextNode();l&&e.contains(l);)this._matchLeaves(r,l,h)&&d.add(l),l=s.nextNode()}}}else switch(c){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(r,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(f,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(r,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{f&&this._matchLeaves(r,f,h)&&d.add(f);break}case" ":default:{const i=[];let t=f;for(;t;)this._matchLeaves(r,t,h)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(o,e){const{node:h}=e,n=this.#b;let r=(0,k.traverseNode)(h,n),c;if(r)for((r.nodeType!==a.ELEMENT_NODE||r===h&&r!==this.#s)&&(r=n.nextNode());r;){if(this._matchLeaves(o,r,{warn:this.#i})){c=r;break}r=n.nextNode()}return c??null}_matchSelf(o){const e=[],h=this._matchLeaves(o,this.#e,{warn:this.#i});let n=!1;return h&&(e.push(this.#e),n=!0),[e,n]}_findLineal(o,e={}){const{complex:h}=e,n=[];let r=this._matchLeaves(o,this.#e,{warn:this.#i}),c=!1;if(r&&(n.push(this.#e),c=!0),!r||h){let f=this.#e.parentNode;for(;f&&(r=this._matchLeaves(o,f,{warn:this.#i}),r&&(n.push(f),c=!0),f.parentNode);)f=f.parentNode}return[n,c]}_findFirst(o){const e=[],h=this._findNode(o,{node:this.#e});let n=!1;return h&&(e.push(h),n=!0),[e,n]}_findFromHTMLCollection(o,e={}){const{complex:h,compound:n,filterLeaves:r,targetType:c}=e;let f=[],b=!1,d=!1;const i=o.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let t=0;t<i;t++){const s=o[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(n){if(this._matchLeaves(r,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else if(f.push(s),b=!0,c===a.TARGET_FIRST)break}}else if(h)if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(r,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;else if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(r,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;return[f,b,d]}_findEntryNodes(o,e,h){const{leaves:n}=o,[r,...c]=n,f=c.length>0,{name:b,type:d}=r;let i=[],t=!1,s=!1,l=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(e===a.TARGET_FIRST&&this.#s.nodeType!==a.ELEMENT_NODE){const u=this.#s.getElementById(b);u&&(f?this._matchLeaves(c,u,{warn:this.#i})&&(i.push(u),s=!0):(i.push(u),s=!0))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):l=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(this.#s.nodeType===a.DOCUMENT_NODE){const u=this.#s.getElementsByClassName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:c,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):l=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===a.DOCUMENT_NODE&&!/[*|]/.test(b)){const u=this.#s.getElementsByTagName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:c,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):l=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(b)){if(this.#h&&this.#e.nodeType===a.DOCUMENT_FRAGMENT_NODE){const u=this._matchShadowHostPseudoClass(r,this.#e);u&&(i.push(u),s=!0)}}else e===a.TARGET_SELF?[i,s]=this._matchSelf(n):e===a.TARGET_LINEAL?[i,s]=this._findLineal(n,{complex:h}):e===a.TARGET_FIRST?[i,s]=this._findFirst(n):l=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:l}}_collectNodes(o){const e=this.#a.values();if(o===a.TARGET_ALL||o===a.TARGET_FIRST){const h=new Set;let n=0;for(const{branch:r}of e){const c=r.length,f=c>1,b=r[0];let d,i;if(f){const{combo:w,leaves:[{name:p,type:N}]}=b,_=r[c-1],{leaves:[{name:y,type:E}]}=_;if(E===a.SELECTOR_PSEUDO_ELEMENT||E===a.SELECTOR_ID)d=S,i=_;else if(N===a.SELECTOR_PSEUDO_ELEMENT||N===a.SELECTOR_ID)d=v,i=b;else if(o===a.TARGET_ALL)if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(c===2){const{name:A}=w;/^[+~]$/.test(A)?(d=S,i=_):(d=v,i=b)}else d=v,i=b;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else{let A;for(const{combo:C,leaves:[O]}of r){const{name:R,type:M}=O;if(M===a.SELECTOR_PSEUDO_CLASS&&R==="dir"){A=!1;break}if(!A&&C){const{name:P}=C;/^[+~]$/.test(P)&&(A=!0)}}A?(d=v,i=b):(d=S,i=_)}}else d=S,i=b;const{collected:t,compound:s,filtered:l,nodes:u,pending:m}=this._findEntryNodes(i,o,f);u.length?(this.#a[n].find=!0,this.#f[n]=u):m&&h.add(new Map([["index",n],["twig",i]])),this.#a[n].collected=t,this.#a[n].dir=d,this.#a[n].filtered=l||!s,n++}if(h.size){let r,c;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(r=this.#e,c=this.#b):(r=this.#s,c=this.#r);let f=(0,k.traverseNode)(r,c);for(;f;){let b=!1;if(this.#e.nodeType===a.ELEMENT_NODE?f===this.#e?b=!0:b=this.#e.contains(f):b=!0,b)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,f,{warn:this.#i})){const s=d.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#f[s].push(f)}}f!==c.currentNode&&(f=(0,k.traverseNode)(f,c)),f=c.nextNode()}}}else{let h=0;for(const{branch:n}of e){const r=n[n.length-1],c=n.length>1,{compound:f,filtered:b,nodes:d}=this._findEntryNodes(r,o,c);d.length&&(this.#a[h].find=!0,this.#f[h]=d),this.#a[h].dir=S,this.#a[h].filtered=b||!f,h++}}return[this.#a,this.#f]}_getCombinedNodes(o,e,h){const n=[];for(const r of e){const c=this._matchCombinator(o,r,{dir:h,warn:this.#i});c.size&&n.push(...c)}return n.length?new Set(n):new Set}_matchNodeNext(o,e,h){const{combo:n,index:r}=h,{combo:c,leaves:f}=o[r],b={combo:n,leaves:f},d=this._getCombinedNodes(b,e,v);let i;if(d.size)if(r===o.length-1){const[t]=(0,k.sortNodes)(d);i=t}else i=this._matchNodeNext(o,d,{combo:c,index:r+1});return i??null}_matchNodePrev(o,e,h){const{index:n}=h,r=o[n],c=new Set([e]),f=this._getCombinedNodes(r,c,S);let b;if(f.size){if(n===0)b=e;else for(const d of f)if(this._matchNodePrev(o,d,{index:n-1}))return e}return b??null}_find(o){(o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(o),n=e.length;let r,c=new Set;for(let f=0;f<n;f++){const{branch:b,collected:d,dir:i,find:t}=e[f],s=b.length;if(s&&t){const l=h[f],u=l.length,m=s-1;if(m===0)if((o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this.#e.nodeType===a.ELEMENT_NODE)for(let w=0;w<u;w++){const p=l[w];if(p!==this.#e&&this.#e.contains(p)&&(c.add(p),o!==a.TARGET_ALL))break}else if(o===a.TARGET_ALL)if(c.size){const w=[...c];c=new Set([...w,...l]),r=!0}else c=new Set(l);else{const[w]=l;c.add(w)}else if(o===a.TARGET_ALL)if(i===v){let{combo:w}=b[0];for(const p of l){let N=new Set([p]);for(let _=1;_<s;_++){const{combo:y,leaves:E}=b[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(c.size){const C=[...c];c=new Set([...C,...N]),r=!0}else c=N;else w=y;else break}}}else for(const w of l){let p=new Set([w]);for(let N=m-1;N>=0;N--){const _=b[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(c.add(w),s>1&&c.size>1&&(r=!0));else break}}else if(o===a.TARGET_FIRST&&i===v){const{combo:w}=b[0];let p;for(const N of l)if(p=this._matchNodeNext(b,new Set([N]),{combo:w,index:1}),p){c.add(p);break}if(!p&&!d){const{leaves:N}=b[0],[_]=l;let y=this._findNode(N,{node:_});for(;y;){if(p=this._matchNodeNext(b,new Set([y]),{combo:w,index:1}),p){c.add(p);break}y=this._findNode(N,{node:y})}}}else{let w;for(const p of l)if(w=this._matchNodePrev(b,p,{index:m-1}),w){c.add(p);break}if(!w&&!d&&o===a.TARGET_FIRST){const{leaves:p}=b[m],[N]=l;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(b,_,{index:m-1}),w){c.add(_);break}_=this._findNode(p,{node:_})}}}}}return o===a.TARGET_ALL&&r&&(c=new Set((0,k.sortNodes)(c))),c}}0&&(module.exports={Finder});
2
2
  //# sourceMappingURL=finder.js.map