@asamuzakjp/dom-selector 5.3.4 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -286,45 +286,45 @@ See [benchmark](https://github.com/asamuzaK/domSelector/actions/workflows/benchm
286
286
 
287
287
  ### matches()
288
288
 
289
- |Selector|jsdom v24.1.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
289
+ |Selector|jsdom v25.0.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
290
290
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
291
- |simple selector:<br>`matches('.content')`|1,031,169 ops/sec ±0.30%|7,650 ops/sec ±0.75%|9,438 ops/sec ±0.58%|828,526 ops/sec ±0.28%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
292
- |compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|603,664 ops/sec ±1.24%|7,430 ops/sec ±0.65%|8,923 ops/sec ±0.98%|400,799 ops/sec ±0.31%|jsdom is the fastest and 1.5 times faster than patched-jsdom.|
293
- |compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|7,358 ops/sec ±1.45%|F|73,167 ops/sec ±0.99%|patched-jsdom is the fastest.|
294
- |compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|478,859 ops/sec ±1.56%|7,312 ops/sec ±1.24%|8,786 ops/sec ±0.75%|338,833 ops/sec ±1.37%|jsdom is the fastest and 1.4 times faster than patched-jsdom.|
295
- |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|154,200 ops/sec ±1.15%|F|5,852 ops/sec ±0.74%|127,543 ops/sec ±1.23%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
296
- |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,792 ops/sec ±0.81%|18,981 ops/sec ±1.80%|patched-jsdom is the fastest.|
297
- |complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|414,939 ops/sec ±1.14%|F|6,158 ops/sec ±0.44%|332,506 ops/sec ±0.26%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
291
+ |simple selector:<br>`matches('.content')`|937,822 ops/sec ±0.50%|7,910,671 ops/sec ±0.27%|8,620 ops/sec ±0.75%|772,780 ops/sec ±0.30%|happydom is the fastest and 10.2 times faster than patched-jsdom. jsdom is 1.2 times faster than patched-jsdom.|
292
+ |compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|572,176 ops/sec ±0.38%|7,693,760 ops/sec ±1.88%|8,257 ops/sec ±0.63%|402,508 ops/sec ±0.21%|happydom is the fastest and 19.1 times faster than patched-jsdom. jsdom is 1.4 times faster than patched-jsdom.|
293
+ |compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|6,987,723 ops/sec ±0.39%|F|74,756 ops/sec ±1.26%|happydom is the fastest and 93.5 times faster than patched-jsdom.|
294
+ |compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|455,833 ops/sec ±1.90%|6,645,611 ops/sec ±1.63%|8,205 ops/sec ±1.12%|326,773 ops/sec ±1.38%|happydom is the fastest and 20.3 times faster than patched-jsdom. jsdom is 1.4 times faster than patched-jsdom.|
295
+ |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|144,430 ops/sec ±1.65%|F|5,445 ops/sec ±1.00%|121,298 ops/sec ±1.34%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
296
+ |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,337 ops/sec ±0.86%|17,419 ops/sec ±2.05%|patched-jsdom is the fastest.|
297
+ |complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|398,206 ops/sec ±0.51%|F|5,719 ops/sec ±0.84%|326,625 ops/sec ±1.25%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
298
298
 
299
299
  ### closest()
300
300
 
301
- |Selector|jsdom v24.1.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
301
+ |Selector|jsdom v25.0.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
302
302
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
303
- |simple selector:<br>`closest('.container')`|376,552 ops/sec ±1.42%|7,476 ops/sec ±0.84%|9,281 ops/sec ±0.63%|340,692 ops/sec ±1.37%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
304
- |compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|138,076 ops/sec ±1.49%|F|8,643 ops/sec ±0.96%|121,489 ops/sec ±1.12%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
305
- |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|141,376 ops/sec ±1.33%|F|5,795 ops/sec ±0.80%|120,433 ops/sec ±1.28%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
306
- |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,723 ops/sec ±0.73%|15,392 ops/sec ±1.58%|patched-jsdom is the fastest.|
307
- |complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|194,922 ops/sec ±1.40%|4,752 ops/sec ±1.20%|6,139 ops/sec ±0.35%|176,281 ops/sec ±0.32%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
303
+ |simple selector:<br>`closest('.container')`|357,783 ops/sec ±1.70%|2,319,384 ops/sec ±0.92%|8,581 ops/sec ±0.84%|328,849 ops/sec ±1.31%|happydom is the fastest and 7.1 times faster than patched-jsdom. jsdom is 1.1 times faster than patched-jsdom.|
304
+ |compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|131,236 ops/sec ±0.73%|F|8,052 ops/sec ±0.95%|119,653 ops/sec ±1.44%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
305
+ |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|137,291 ops/sec ±0.17%|F|5,483 ops/sec ±0.36%|116,733 ops/sec ±0.21%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
306
+ |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,354 ops/sec ±0.87%|14,363 ops/sec ±1.58%|patched-jsdom is the fastest.|
307
+ |complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|190,643 ops/sec ±1.69%|2,819,109 ops/sec ±1.22%|5,732 ops/sec ±0.34%|169,772 ops/sec ±1.48%|happydom is the fastest and 16.6 times faster than patched-jsdom. jsdom is 1.1 times faster than patched-jsdom.|
308
308
 
309
309
  ### querySelector()
310
310
 
311
- |Selector|jsdom v24.1.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
311
+ |Selector|jsdom v25.0.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
312
312
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
313
- |simple selector:<br>`querySelector('.content')`|27,103 ops/sec ±0.78%|9,293 ops/sec ±0.55%|11,341 ops/sec ±0.46%|30,262 ops/sec ±0.23%|patched-jsdom is the fastest. patched-jsdom is 1.1 times faster than jsdom.|
314
- |compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|10,072 ops/sec ±1.46%|9,055 ops/sec ±0.95%|10,058 ops/sec ±0.84%|9,716 ops/sec ±1.34%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
315
- |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|225 ops/sec ±0.61%|F|1,267 ops/sec ±1.48%|271 ops/sec ±1.37%|linkedom is the fastest and 4.7 times faster than patched-jsdom. patched-jsdom is 1.2 times faster than jsdom.|
316
- |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|1,611 ops/sec ±1.52%|730 ops/sec ±1.58%|linkedom is the fastest and 2.2 times faster than patched-jsdom.|
317
- |complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|3,152 ops/sec ±2.67%|F|9,906 ops/sec ±0.94%|159,199 ops/sec ±1.91%|patched-jsdom is the fastest. patched-jsdom is 50.5 times faster than jsdom.|
313
+ |simple selector:<br>`querySelector('.content')`|30,752 ops/sec ±1.40%|3,402,064 ops/sec ±1.11%|10,466 ops/sec ±0.91%|30,353 ops/sec ±1.46%|happydom is the fastest and 112.1 times faster than patched-jsdom. jsdom is 1.0 times faster than patched-jsdom.|
314
+ |compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|9,716 ops/sec ±1.63%|3,318,668 ops/sec ±1.19%|9,481 ops/sec ±0.59%|9,123 ops/sec ±0.47%|happydom is the fastest and 363.8 times faster than patched-jsdom. jsdom is 1.1 times faster than patched-jsdom.|
315
+ |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|219 ops/sec ±1.75%|F|1,270 ops/sec ±0.34%|779 ops/sec ±2.08%|linkedom is the fastest and 1.6 times faster than patched-jsdom. patched-jsdom is 3.6 times faster than jsdom.|
316
+ |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|1,532 ops/sec ±1.81%|516 ops/sec ±1.93%|linkedom is the fastest and 3.0 times faster than patched-jsdom.|
317
+ |complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|3,215 ops/sec ±0.60%|F|9,656 ops/sec ±1.10%|159,781 ops/sec ±2.23%|patched-jsdom is the fastest. patched-jsdom is 49.7 times faster than jsdom.|
318
318
 
319
319
  ### querySelectorAll()
320
320
 
321
- |Selector|jsdom v24.1.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
321
+ |Selector|jsdom v25.0.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
322
322
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
323
- |simple selector:<br>`querySelectorAll('.content')`|2,684 ops/sec ±1.00%|758 ops/sec ±1.65%|1,231 ops/sec ±1.45%|3,131 ops/sec ±0.90%|patched-jsdom is the fastest. patched-jsdom is 1.2 times faster than jsdom.|
324
- |compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|958 ops/sec ±0.29%|686 ops/sec ±1.79%|1,171 ops/sec ±1.23%|996 ops/sec ±1.17%|linkedom is the fastest and 1.2 times faster than patched-jsdom. patched-jsdom is 1.0 times faster than jsdom.|
325
- |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|210 ops/sec ±1.78%|F|421 ops/sec ±1.53%|240 ops/sec ±1.51%|linkedom is the fastest and 1.8 times faster than patched-jsdom. patched-jsdom is 1.1 times faster than jsdom.|
326
- |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|442 ops/sec ±1.84%|823 ops/sec ±1.64%|patched-jsdom is the fastest.|
327
- |complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|302 ops/sec ±1.43%|F|518 ops/sec ±1.47%|785 ops/sec ±0.98%|patched-jsdom is the fastest. patched-jsdom is 2.6 times faster than jsdom.|
323
+ |simple selector:<br>`querySelectorAll('.content')`|3,145 ops/sec ±1.24%|7,471,952 ops/sec ±0.97%|1,187 ops/sec ±0.18%|3,330 ops/sec ±0.40%|happydom is the fastest and 2244.1 times faster than patched-jsdom. patched-jsdom is 1.1 times faster than jsdom.|
324
+ |compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|969 ops/sec ±1.23%|6,444,347 ops/sec ±0.86%|1,155 ops/sec ±1.22%|993 ops/sec ±0.21%|happydom is the fastest and 6486.9 times faster than patched-jsdom. patched-jsdom is 1.0 times faster than jsdom.|
325
+ |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|221 ops/sec ±1.66%|F|418 ops/sec ±1.84%|905 ops/sec ±1.45%|patched-jsdom is the fastest. patched-jsdom is 4.1 times faster than jsdom.|
326
+ |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|454 ops/sec ±0.15%|567 ops/sec ±1.60%|patched-jsdom is the fastest.|
327
+ |complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|295 ops/sec ±1.89%|F|515 ops/sec ±1.81%|790 ops/sec ±1.60%|patched-jsdom is the fastest. patched-jsdom is 2.7 times faster than jsdom.|
328
328
 
329
329
 
330
330
  ## Acknowledgments
@@ -1,2 +1,2 @@
1
- var x=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var F=(o,t)=>{for(var c in t)x(o,c,{get:t[c],enumerable:!0})},i=(o,t,c,L)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of l(t))!M.call(o,s)&&s!==c&&x(o,s,{get:()=>t[s],enumerable:!(L=R(t,s))||L.enumerable});return o};var a=o=>i(x({},"__esModule",{value:!0}),o);var Mt={};F(Mt,{ALPHA_NUM:()=>$,ANB:()=>A,ATTR_SELECTOR:()=>G,BIT_01:()=>v,BIT_02:()=>K,BIT_04:()=>g,BIT_08:()=>z,BIT_16:()=>j,BIT_32:()=>q,BIT_FFFF:()=>J,CHILD_IDX:()=>I,CLASS_SELECTOR:()=>U,COMBINATOR:()=>d,COMBO:()=>T,COMPLEX:()=>_,COMPLEX_L:()=>S,COMPOUND:()=>n,COMPOUND_A:()=>O,COMPOUND_B:()=>N,COMPOUND_I:()=>At,DESCEND:()=>It,DIGIT:()=>E,DOCUMENT_FRAGMENT_NODE:()=>ct,DOCUMENT_NODE:()=>nt,DOCUMENT_POSITION_CONTAINED_BY:()=>pt,DOCUMENT_POSITION_CONTAINS:()=>xt,DOCUMENT_POSITION_PRECEDING:()=>Et,DUO:()=>Q,ELEMENT_NODE:()=>st,EMPTY:()=>B,HEX:()=>V,HYPHEN:()=>tt,IDENT:()=>Y,ID_SELECTOR:()=>H,KEY_IS_NOT:()=>C,LANG_PART:()=>Ct,LOGICAL_COMPLEX:()=>Pt,LOGICAL_COMPOUND:()=>Dt,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>D,NOT_SUPPORTED_ERR:()=>h,NTH:()=>m,N_TH:()=>$t,PSEUDO_CLASS:()=>Lt,PS_CLASS_SELECTOR:()=>y,PS_ELEMENT_SELECTOR:()=>X,REG_INPUT_TYPE:()=>lt,REG_LOGICAL:()=>Rt,SELECTOR:()=>f,SHOW_ALL:()=>Tt,SHOW_DOCUMENT:()=>_t,SHOW_DOCUMENT_FRAGMENT:()=>Ot,SHOW_ELEMENT:()=>Nt,SUB_TYPE:()=>r,SYNTAX_ERR:()=>u,TAG_TYPE:()=>e,TAG_TYPE_I:()=>p,TARGET_ALL:()=>w,TARGET_FIRST:()=>W,TARGET_LINEAL:()=>b,TARGET_SELF:()=>k,TEXT_NODE:()=>rt,TYPE_FROM:()=>ot,TYPE_SELECTOR:()=>Z,TYPE_TO:()=>et,WALKER_FILTER:()=>St});module.exports=a(Mt);const G="AttributeSelector",U="ClassSelector",d="Combinator",B="__EMPTY__",Y="Identifier",H="IdSelector",h="NotSupportedError",m="Nth",y="PseudoClassSelector",X="PseudoElementSelector",f="Selector",u="SyntaxError",w="all",W="first",b="lineal",k="self",Z="TypeSelector",v=1,K=2,g=4,z=8,j=16,q=32,J=65535,Q=2,V=16,tt=45,ot=8,et=-1,st=1,rt=3,nt=9,ct=11,Et=2,xt=8,pt=16,Tt=4294967295,_t=256,Ot=1024,Nt=1,St=1281,$="[A-Z\\d]+",I="(?:first|last|only)-(?:child|of-type)",E="(?:0|[1-9]\\d*)",Ct=`(?:-${$})*`,Lt=`(?:any-)?link|${I}|checked|empty|indeterminate|root|target|visited`,A=`[+-]?(?:${E}n?|n)|(?:[+-]?${E})?n\\s*[+-]\\s*${E}`,$t=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${A})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",p="\\*|[A-Z][\\w-]*",n=`(?:${e}|(?:${e})?(?:${r})+)`,T="\\s?[\\s>~+]\\s?",_=`${n}(?:${T}${n})*`,It="\\s?[\\s>]\\s?",P=`:is\\(\\s*${n}(?:\\s*,\\s*${n})*\\s*\\)`,D=`:is\\(\\s*${_}(?:\\s*,\\s*${_})*\\s*\\)`,O=`(?:${e}|(?:${e})?(?:${r}|${P})+)`,N=`(?:${e}|(?:${e})?(?:${r}|${D})+)`,At=`(?:${p}|(?:${p})?(?:${r})+)`,S=`${N}(?:${T}${N})*`,C="(?:is|not)",Pt=`${C}\\(\\s*${S}(?:\\s*,\\s*${S})*\\s*\\)`,Dt=`${C}\\(\\s*${O}(?:\\s*,\\s*${O})*\\s*\\)`,Rt=/^(?:has|is|not|where)$/,lt=/^(?:date(?:time-local)?|email|month|number|password|search|tel|text|time|url|week)$/;0&&(module.exports={ALPHA_NUM,ANB,ATTR_SELECTOR,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,CHILD_IDX,CLASS_SELECTOR,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DESCEND,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,HYPHEN,IDENT,ID_SELECTOR,KEY_IS_NOT,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASS,PS_CLASS_SELECTOR,PS_ELEMENT_SELECTOR,REG_INPUT_TYPE,REG_LOGICAL,SELECTOR,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_SELECTOR,TYPE_TO,WALKER_FILTER});
1
+ var x=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var a=(o,t)=>{for(var c in t)x(o,c,{get:t[c],enumerable:!0})},F=(o,t,c,C)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of i(t))!M.call(o,s)&&s!==c&&x(o,s,{get:()=>t[s],enumerable:!(C=R(t,s))||C.enumerable});return o};var U=o=>F(x({},"__esModule",{value:!0}),o);var Ut={};a(Ut,{ALPHA_NUM:()=>I,ANB:()=>A,ATTR_SELECTOR:()=>d,BIT_01:()=>k,BIT_02:()=>g,BIT_04:()=>Z,BIT_08:()=>v,BIT_16:()=>q,BIT_32:()=>J,BIT_FFFF:()=>Q,CHILD_IDX:()=>L,CLASS_SELECTOR:()=>Y,COMBINATOR:()=>G,COMBO:()=>p,COMPLEX:()=>_,COMPLEX_L:()=>S,COMPOUND:()=>n,COMPOUND_A:()=>O,COMPOUND_B:()=>N,COMPOUND_I:()=>$t,DESCEND:()=>Pt,DIGIT:()=>E,DOCUMENT_FRAGMENT_NODE:()=>Et,DOCUMENT_NODE:()=>ct,DOCUMENT_POSITION_CONTAINED_BY:()=>pt,DOCUMENT_POSITION_CONTAINS:()=>Tt,DOCUMENT_POSITION_PRECEDING:()=>xt,DUO:()=>V,ELEMENT_NODE:()=>rt,EMPTY:()=>b,HEX:()=>tt,HYPHEN:()=>ot,IDENT:()=>B,ID_SELECTOR:()=>f,KEY_FORM_FOCUS:()=>Rt,KEY_INPUT_BUTTON:()=>it,KEY_INPUT_DATE:()=>D,KEY_INPUT_EDIT:()=>Mt,KEY_INPUT_LTR:()=>at,KEY_INPUT_TEXT:()=>l,KEY_LOGICAL:()=>Ft,LANG_PART:()=>It,LOGICAL_COMPLEX:()=>Dt,LOGICAL_COMPOUND:()=>lt,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>$,NOT_SUPPORTED_ERR:()=>m,NTH:()=>u,N_TH:()=>At,PSEUDO_CLASS:()=>Lt,PS_CLASS_SELECTOR:()=>H,PS_ELEMENT_SELECTOR:()=>h,SELECTOR:()=>z,SHOW_ALL:()=>_t,SHOW_DOCUMENT:()=>Ot,SHOW_DOCUMENT_FRAGMENT:()=>Nt,SHOW_ELEMENT:()=>St,SUB_TYPE:()=>r,SYNTAX_ERR:()=>K,TAG_TYPE:()=>e,TAG_TYPE_I:()=>T,TARGET_ALL:()=>X,TARGET_FIRST:()=>j,TARGET_LINEAL:()=>y,TARGET_SELF:()=>w,TEXT_NODE:()=>nt,TYPE_FROM:()=>et,TYPE_SELECTOR:()=>W,TYPE_TO:()=>st,WALKER_FILTER:()=>Ct});module.exports=U(Ut);const d="AttributeSelector",Y="ClassSelector",G="Combinator",b="__EMPTY__",B="Identifier",f="IdSelector",m="NotSupportedError",u="Nth",H="PseudoClassSelector",h="PseudoElementSelector",z="Selector",K="SyntaxError",X="all",j="first",y="lineal",w="self",W="TypeSelector",k=1,g=2,Z=4,v=8,q=16,J=32,Q=65535,V=2,tt=16,ot=45,et=8,st=-1,rt=1,nt=3,ct=9,Et=11,xt=2,Tt=8,pt=16,_t=4294967295,Ot=256,Nt=1024,St=1,Ct=1281,I="[A-Z\\d]+",L="(?:first|last|only)-(?:child|of-type)",E="(?:0|[1-9]\\d*)",It=`(?:-${I})*`,Lt=`(?:any-)?link|${L}|checked|empty|indeterminate|root|target|visited`,A=`[+-]?(?:${E}n?|n)|(?:[+-]?${E})?n\\s*[+-]\\s*${E}`,At=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${A})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",T="\\*|[A-Z][\\w-]*",n=`(?:${e}|(?:${e})?(?:${r})+)`,p="\\s?[\\s>~+]\\s?",_=`${n}(?:${p}${n})*`,Pt="\\s?[\\s>]\\s?",P=`:is\\(\\s*${n}(?:\\s*,\\s*${n})*\\s*\\)`,$=`:is\\(\\s*${_}(?:\\s*,\\s*${_})*\\s*\\)`,O=`(?:${e}|(?:${e})?(?:${r}|${P})+)`,N=`(?:${e}|(?:${e})?(?:${r}|${$})+)`,$t=`(?:${T}|(?:${T})?(?:${r})+)`,S=`${N}(?:${p}${N})*`,Dt=`(?:is|not)\\(\\s*${S}(?:\\s*,\\s*${S})*\\s*\\)`,lt=`(?:is|not)\\(\\s*${O}(?:\\s*,\\s*${O})*\\s*\\)`,Rt=Object.freeze(["button","input","select","textarea"]),it=Object.freeze(["button","reset","submit"]),D=Object.freeze(["date","datetime-local","month","time","week"]),l=Object.freeze(["email","password","search","tel","text","url"]),Mt=Object.freeze([...D,...l,"number"]),at=Object.freeze(["checkbox","color","date","image","number","range","radio","time"]),Ft=Object.freeze(["has","is","not","where"]);0&&(module.exports={ALPHA_NUM,ANB,ATTR_SELECTOR,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,CHILD_IDX,CLASS_SELECTOR,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DESCEND,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,HYPHEN,IDENT,ID_SELECTOR,KEY_FORM_FOCUS,KEY_INPUT_BUTTON,KEY_INPUT_DATE,KEY_INPUT_EDIT,KEY_INPUT_LTR,KEY_INPUT_TEXT,KEY_LOGICAL,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASS,PS_CLASS_SELECTOR,PS_ELEMENT_SELECTOR,SELECTOR,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_SELECTOR,TYPE_TO,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 ATTR_SELECTOR = 'AttributeSelector';\nexport const CLASS_SELECTOR = 'ClassSelector';\nexport const COMBINATOR = 'Combinator';\nexport const EMPTY = '__EMPTY__';\nexport const IDENT = 'Identifier';\nexport const ID_SELECTOR = 'IdSelector';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const PS_CLASS_SELECTOR = 'PseudoClassSelector';\nexport const PS_ELEMENT_SELECTOR = 'PseudoElementSelector';\nexport const SELECTOR = 'Selector';\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 TYPE_SELECTOR = 'TypeSelector';\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 DUO = 2;\nexport const HEX = 16;\nexport const HYPHEN = 0x2D;\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_CLASS =\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-]*';\nexport const COMPOUND = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`;\nexport const COMBO = '\\\\s?[\\\\s>~+]\\\\s?';\nexport const COMPLEX = `${COMPOUND}(?:${COMBO}${COMPOUND})*`;\nexport const DESCEND = '\\\\s?[\\\\s>]\\\\s?';\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 KEY_IS_NOT = '(?:is|not)';\nexport const LOGICAL_COMPLEX =\n `${KEY_IS_NOT}\\\\(\\\\s*${COMPLEX_L}(?:\\\\s*,\\\\s*${COMPLEX_L})*\\\\s*\\\\)`;\nexport const LOGICAL_COMPOUND =\n `${KEY_IS_NOT}\\\\(\\\\s*${COMPOUND_A}(?:\\\\s*,\\\\s*${COMPOUND_A})*\\\\s*\\\\)`;\n\n/* regexp */\nexport const REG_LOGICAL = /^(?:has|is|not|where)$/;\nexport const REG_INPUT_TYPE =\n /^(?:date(?:time-local)?|email|month|number|password|search|tel|text|time|url|week)$/;\n"],
5
- "mappings": "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",
6
- "names": ["constant_exports", "__export", "ALPHA_NUM", "ANB", "ATTR_SELECTOR", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "BIT_FFFF", "CHILD_IDX", "CLASS_SELECTOR", "COMBINATOR", "COMBO", "COMPLEX", "COMPLEX_L", "COMPOUND", "COMPOUND_A", "COMPOUND_B", "COMPOUND_I", "DESCEND", "DIGIT", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "EMPTY", "HEX", "HYPHEN", "IDENT", "ID_SELECTOR", "KEY_IS_NOT", "LANG_PART", "LOGICAL_COMPLEX", "LOGICAL_COMPOUND", "NESTED_LOGICAL_A", "NESTED_LOGICAL_B", "NOT_SUPPORTED_ERR", "NTH", "N_TH", "PSEUDO_CLASS", "PS_CLASS_SELECTOR", "PS_ELEMENT_SELECTOR", "REG_INPUT_TYPE", "REG_LOGICAL", "SELECTOR", "SHOW_ALL", "SHOW_DOCUMENT", "SHOW_DOCUMENT_FRAGMENT", "SHOW_ELEMENT", "SUB_TYPE", "SYNTAX_ERR", "TAG_TYPE", "TAG_TYPE_I", "TARGET_ALL", "TARGET_FIRST", "TARGET_LINEAL", "TARGET_SELF", "TEXT_NODE", "TYPE_FROM", "TYPE_SELECTOR", "TYPE_TO", "WALKER_FILTER", "__toCommonJS"]
4
+ "sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const ATTR_SELECTOR = 'AttributeSelector';\nexport const CLASS_SELECTOR = 'ClassSelector';\nexport const COMBINATOR = 'Combinator';\nexport const EMPTY = '__EMPTY__';\nexport const IDENT = 'Identifier';\nexport const ID_SELECTOR = 'IdSelector';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const PS_CLASS_SELECTOR = 'PseudoClassSelector';\nexport const PS_ELEMENT_SELECTOR = 'PseudoElementSelector';\nexport const SELECTOR = 'Selector';\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 TYPE_SELECTOR = 'TypeSelector';\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 DUO = 2;\nexport const HEX = 16;\nexport const HYPHEN = 0x2D;\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_CLASS =\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-]*';\nexport const COMPOUND = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`;\nexport const COMBO = '\\\\s?[\\\\s>~+]\\\\s?';\nexport const COMPLEX = `${COMPOUND}(?:${COMBO}${COMPOUND})*`;\nexport const DESCEND = '\\\\s?[\\\\s>]\\\\s?';\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 `(?:is|not)\\\\(\\\\s*${COMPLEX_L}(?:\\\\s*,\\\\s*${COMPLEX_L})*\\\\s*\\\\)`;\nexport const LOGICAL_COMPOUND =\n `(?:is|not)\\\\(\\\\s*${COMPOUND_A}(?:\\\\s*,\\\\s*${COMPOUND_A})*\\\\s*\\\\)`;\n\n/* array */\nexport const KEY_FORM_FOCUS =\n Object.freeze(['button', 'input', 'select', 'textarea']);\nexport const KEY_INPUT_BUTTON = Object.freeze(['button', 'reset', 'submit']);\nexport const KEY_INPUT_DATE =\n Object.freeze(['date', 'datetime-local', 'month', 'time', 'week']);\nexport const KEY_INPUT_TEXT =\n Object.freeze(['email', 'password', 'search', 'tel', 'text', 'url']);\nexport const KEY_INPUT_EDIT =\n Object.freeze([...KEY_INPUT_DATE, ...KEY_INPUT_TEXT, 'number']);\nexport const KEY_INPUT_LTR = Object.freeze([\n 'checkbox', 'color', 'date', 'image', 'number', 'range', 'radio', 'time'\n]);\nexport const KEY_LOGICAL = Object.freeze(['has', 'is', 'not', 'where']);\n"],
5
+ "mappings": "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",
6
+ "names": ["constant_exports", "__export", "ALPHA_NUM", "ANB", "ATTR_SELECTOR", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "BIT_FFFF", "CHILD_IDX", "CLASS_SELECTOR", "COMBINATOR", "COMBO", "COMPLEX", "COMPLEX_L", "COMPOUND", "COMPOUND_A", "COMPOUND_B", "COMPOUND_I", "DESCEND", "DIGIT", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "EMPTY", "HEX", "HYPHEN", "IDENT", "ID_SELECTOR", "KEY_FORM_FOCUS", "KEY_INPUT_BUTTON", "KEY_INPUT_DATE", "KEY_INPUT_EDIT", "KEY_INPUT_LTR", "KEY_INPUT_TEXT", "KEY_LOGICAL", "LANG_PART", "LOGICAL_COMPLEX", "LOGICAL_COMPOUND", "NESTED_LOGICAL_A", "NESTED_LOGICAL_B", "NOT_SUPPORTED_ERR", "NTH", "N_TH", "PSEUDO_CLASS", "PS_CLASS_SELECTOR", "PS_ELEMENT_SELECTOR", "SELECTOR", "SHOW_ALL", "SHOW_DOCUMENT", "SHOW_DOCUMENT_FRAGMENT", "SHOW_ELEMENT", "SUB_TYPE", "SYNTAX_ERR", "TAG_TYPE", "TAG_TYPE_I", "TARGET_ALL", "TARGET_FIRST", "TARGET_LINEAL", "TARGET_SELF", "TEXT_NODE", "TYPE_FROM", "TYPE_SELECTOR", "TYPE_TO", "WALKER_FILTER", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var R=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var j=(S,r)=>{for(var e in r)R(S,e,{get:r[e],enumerable:!0})},q=(S,r,e,f)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of V(r))!Y.call(S,n)&&n!==e&&R(S,n,{get:()=>r[n],enumerable:!(f=B(r,n))||f.enumerable});return S};var K=S=>q(R({},"__esModule",{value:!0}),S);var Z={};j(Z,{Finder:()=>J});module.exports=K(Z);var F=require("./matcher.js"),g=require("./parser.js"),k=require("./utility.js"),c=require("./constant.js");const E="next",x="prev",X="Tab",O=/^a(?:rea)?$/,M=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,T=/^(?:button|form|input|select|textarea)$/,$=/^(?:details|dialog)$/,I=/^host(?:-context)?$/,C=/^(?:checkbox|radio)$/,P=/^(?:date(?:time-local)?|month|number|range|time|week)$/,D=/^(?:button|reset)$/,U=/^(?:image|submit)$/,Q=/^(?:email|number|password|search|tel|text|url)$/;class J{#l;#c;#w;#t;#f;#n;#k;#o;#b;#h;#e;#d;#g;#m;#N;#s;#u;#_;#r;#p;#i;#a;constructor(r){this.#a=r,this.#h=new F.Matcher,this.#c=new WeakMap,this.#f=new WeakMap,this.#b=new WeakMap,this.#N=new WeakMap,this.#n=null,this.#k=null,this._registerEventListeners()}onError(r,e={}){if(!(e.noexcept??this.#g))if(r instanceof DOMException||r instanceof this.#a.DOMException)if(r.name===c.NOT_SUPPORTED_ERR)this.#i&&console.warn(r.message);else throw new this.#a.DOMException(r.message,r.name);else throw r.name in this.#a?new this.#a[r.name](r.message):r}setup(r,e,f={}){const{event:n,noexcept:a,warn:l}=f;return this.#g=!!a,this.#i=!!l,this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#u=(0,k.isInShadowTree)(e),[this.#l,this.#d]=this._correspond(r),this.#b=new WeakMap,this.#p=new WeakMap,this.#_=null,this._setEvent(n),e}_registerEventListeners(){const r={capture:!0,passive:!0},e=[],f=["mouseover","mousedown","mouseup","mouseout"];for(const a of f)e.push(this.#a.addEventListener(a,l=>{this.#n=l},r));const n=["keydown","keyup"];for(const a of n)e.push(this.#a.addEventListener(a,l=>{l.key===X&&(this.#n=l)},r));return e.push(this.#a.addEventListener("focusin",a=>{this.#k=a},r)),e}_setEvent(r){return(r instanceof this.#a.KeyboardEvent||r instanceof this.#a.MouseEvent)&&(this.#n=r),this.#n}_correspond(r){const e=[];this.#w=!1,this.#o=!1;let f;if(this.#f.has(this.#t)){const n=this.#f.get(this.#t);if(n&&n.has(`${r}`)){const a=n.get(`${r}`);f=a.ast,this.#w=a.descendant,this.#o=a.invalidate}}if(f){const n=f.length;for(let a=0;a<n;a++)f[a].collected=!1,f[a].dir=null,f[a].filtered=!1,f[a].find=!1,e[a]=[]}else{let n;try{n=(0,g.parseSelector)(r)}catch(b){this.onError(b)}const{branches:a,info:l}=(0,g.walkAST)(n),{hasHasPseudoFunc:o,hasLogicalPseudoFunc:u,hasNthChildOfSelector:d}=l;let i=o||!!(u&&d),s=!1,t=0;f=[];for(const[...b]of a){const p=[];let m=b.shift();if(m&&m.type!==c.COMBINATOR){const w=new Set;for(;m;){if(m.type===c.COMBINATOR){const[N]=b;if(N.type===c.COMBINATOR)throw new DOMException(`Invalid selector ${r}`,c.SYNTAX_ERR);const _=m.name;/^[\s>]$/.test(_)?s=!0:i=!0,p.push({combo:m,leaves:(0,g.sortAST)(w)}),w.clear()}else if(m){let{name:N}=m;N&&typeof N=="string"&&(N=(0,g.unescapeSelector)(N),typeof N=="string"&&N!==m.name&&(m.name=N),/[|:]/.test(N)&&(m.namespace=!0)),w.add(m)}if(b.length)m=b.shift();else{p.push({combo:null,leaves:(0,g.sortAST)(w)}),w.clear();break}}}f.push({branch:p,collected:!1,dir:null,filtered:!1,find:!1}),e[t]=[],t++}let h;this.#f.has(this.#t)?h=this.#f.get(this.#t):h=new Map,h.set(`${r}`,{ast:f,descendant:s,invalidate:i}),this.#f.set(this.#t,h),this.#w=s,this.#o=i}return[f,e]}_createTreeWalker(r){let e;return this.#p.has(r)?e=this.#p.get(r):(e=this.#t.createTreeWalker(r,c.WALKER_FILTER),this.#p.set(r,e)),e}_prepareQuerySelectorWalker(){return this.#m=this._createTreeWalker(this.#e),this.#m}_collectNthChild(r,e,f){const{a:n,b:a,reverse:l,selector:o}=r,{parentNode:u}=e,d=new Set;let i;if(o){if(this.#c.has(o))i=this.#c.get(o);else{const{branches:t}=(0,g.walkAST)(o);i=t,this.#o||this.#c.set(o,i)}const{branches:s}=(0,g.walkAST)(o);i=s}if(u){const s=this.#r;let t=(0,k.traverseNode)(u,s);t=s.firstChild();let h=0;for(;t;)h++,t=s.nextSibling();const b=new Set;if(i)for(t=(0,k.traverseNode)(u,s),t=s.firstChild();t;){if((0,k.isVisible)(t)){let p;for(const m of i)if(p=this._matchLeaves(m,t,f),!p)break;p&&b.add(t)}t=s.nextSibling()}if(n===0){if(a>0&&a<=h){if(b.size){t=(0,k.traverseNode)(u,s),l?t=s.lastChild():t=s.firstChild();let p=0;for(;t;){if(b.has(t)){if(p===a-1){d.add(t);break}p++}l?t=s.previousSibling():t=s.nextSibling()}}else if(!o){t=(0,k.traverseNode)(u,s),l?t=s.lastChild():t=s.firstChild();let p=0;for(;t;){if(p===a-1){d.add(t);break}l?t=s.previousSibling():t=s.nextSibling(),p++}}}}else{let p=a-1;if(n>0)for(;p<0;)p+=n;if(p>=0&&p<h){t=(0,k.traverseNode)(u,s),l?t=s.lastChild():t=s.firstChild();let m=0,w=n>0?0:a-1;for(;t&&(t&&p>=0&&p<h);)b.size?b.has(t)&&(w===p&&(d.add(t),p+=n),n>0?w++:w--):m===p&&(o||d.add(t),p+=n),l?t=s.previousSibling():t=s.nextSibling(),m++}}if(l&&d.size>1){const p=[...d];return new Set(p.reverse())}}else if(e===this.#s&&n+a===1)if(i){let s;for(const t of i)if(s=this._matchLeaves(t,e,f),s)break;s&&d.add(e)}else d.add(e);return d}_collectNthOfType(r,e){const{a:f,b:n,reverse:a}=r,{localName:l,namespaceURI:o,parentNode:u,prefix:d}=e,i=new Set;if(u){const s=this.#r;let t=(0,k.traverseNode)(u,s);t=s.firstChild();let h=0;for(;t;)h++,t=s.nextSibling();if(f===0){if(n>0&&n<=h){t=(0,k.traverseNode)(u,s),a?t=s.lastChild():t=s.firstChild();let b=0;for(;t;){const{localName:p,namespaceURI:m,prefix:w}=t;if(p===l&&w===d&&m===o){if(b===n-1){i.add(t);break}b++}a?t=s.previousSibling():t=s.nextSibling()}}}else{let b=n-1;if(f>0)for(;b<0;)b+=f;if(b>=0&&b<h){t=(0,k.traverseNode)(u,s),a?t=s.lastChild():t=s.firstChild();let p=f>0?0:n-1;for(;t;){const{localName:m,namespaceURI:w,prefix:N}=t;if(m===l&&N===d&&w===o){if(p===b&&(i.add(t),b+=f),b<0||b>=h)break;f>0?p++:p--}a?t=s.previousSibling():t=s.nextSibling()}}}if(a&&i.size>1){const b=[...i];return new Set(b.reverse())}}else e===this.#s&&f+n===1&&i.add(e);return i}_matchAnPlusB(r,e,f,n){const{nth:{a,b:l,name:o},selector:u}=r,d=new Map;if(o?(o==="even"?(d.set("a",2),d.set("b",0)):o==="odd"&&(d.set("a",2),d.set("b",1)),f.indexOf("last")>-1&&d.set("reverse",!0)):(typeof a=="string"&&/-?\d+/.test(a)?d.set("a",a*1):d.set("a",0),typeof l=="string"&&/-?\d+/.test(l)?d.set("b",l*1):d.set("b",0),f.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(f)){u&&d.set("selector",u);const i=Object.fromEntries(d);return this._collectNthChild(i,e,n)}else if(/^nth-(?:last-)?of-type$/.test(f)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(r,e,f={}){let n;if(Array.isArray(r)&&r.length){const a=r.map(t=>t),[l]=a,{type:o}=l;let u;o===c.COMBINATOR?u=a.shift():u={name:" ",type:c.COMBINATOR};const d=[];for(;a.length;){const[t]=a,{type:h}=t;if(h===c.COMBINATOR)break;d.push(a.shift())}const i={combo:u,leaves:d};f.dir=E;const s=this._matchCombinator(i,e,f);if(s.size)if(a.length){for(const t of s)if(n=this._matchHasPseudoFunc(a,t,f),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(r,e,f={}){const{astName:n,branches:a,twigBranches:l}=r,{isShadowRoot:o}=f;let u;if(n==="has"){let d;for(const i of a)if(d=this._matchHasPseudoFunc(i,e,f),d)break;d&&(o?this.#_&&(u=e):u=e)}else{if(o){for(const t of a)if(t.length>1)return null}const d=/^(?:is|where)$/.test(n);f.forgive=d;const i=l.length;let s;for(let t=0;t<i;t++){const h=l[t],b=h.length-1,{leaves:p}=h[b];if(s=this._matchLeaves(p,e,f),s&&b>0){let m=new Set([e]);for(let w=b-1;w>=0;w--){const N=h[w],_=[];f.dir=x;for(const y of m){const v=this._matchCombinator(N,y,f);v.size&&_.push(...v)}if(_.length)w===0?s=!0:m=new Set(_);else{s=!1;break}}}if(s)break}n==="not"?s||(u=e):s&&(u=e)}return u??null}_matchPseudoClassSelector(r,e,f={}){const{children:n,name:a}=r,{localName:l,parentNode:o}=e,{forgive:u,warn:d=this.#i}=f,i=new Set;if(c.REG_LOGICAL.test(a)){let s;if(this.#c.has(r))s=this.#c.get(r);else{const{branches:h}=(0,g.walkAST)(r);if(a==="has"){for(const b of n){const p=(0,g.findAST)(b,m=>c.REG_LOGICAL.test(m.name)&&(0,g.findAST)(m,w=>w.name==="has")?m:null);if(p){if(/^(?:is|where)$/.test(p.name))return i;{const m=(0,g.generateCSS)(r);throw new DOMException(`Invalid selector ${m}`,c.SYNTAX_ERR)}}}s={astName:a,branches:h}}else{const b=[];for(const[...p]of h){const m=[],w=new Set;let N=p.shift();for(;N;)if(N.type===c.COMBINATOR?(m.push({combo:N,leaves:[...w]}),w.clear()):N&&w.add(N),p.length)N=p.shift();else{m.push({combo:null,leaves:[...w]}),w.clear();break}b.push(m)}s={astName:a,branches:h,twigBranches:b},this.#o||this.#c.set(r,s)}}const t=this._matchLogicalPseudoFunc(s,e,f);t&&i.add(t)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(a)){const[s]=n;return this._matchAnPlusB(s,e,a,f)}else switch(a){case"dir":case"lang":{const s=this.#h.matchSelector(r,e,f,!0);s&&i.add(s);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:s}]=n;if(s)if(e[s])i.add(e);else for(const t in e){const h=e[t];if(h instanceof this.#a.ElementInternals){h?.states?.has(s)&&i.add(e);break}}}break}case"current":case"nth-col":case"nth-last-col":{if(d)throw new DOMException(`Unsupported pseudo-class :${a}()`,c.NOT_SUPPORTED_ERR);break}case"host":case"host-context":break;case"contains":{if(d)throw new DOMException(`Unknown pseudo-class :${a}()`,c.NOT_SUPPORTED_ERR);break}default:if(!u)throw new DOMException(`Unknown pseudo-class :${a}()`,c.SYNTAX_ERR)}else switch(a){case"any-link":case"link":{O.test(l)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(O.test(l)&&e.hasAttribute("href")){const{href:s,origin:t,pathname:h}=new URL(this.#t.URL),b=new URL(e.getAttribute("href"),s);b.origin===t&&b.pathname===h&&i.add(e)}break}case"visited":break;case"hover":{const{target:s,type:t}=this.#n??{};/^(?:mouse|pointer)(?:down|over|up)$/.test(t)&&e.contains(s)&&i.add(e);break}case"active":{const{buttons:s,target:t,type:h}=this.#n??{};/(?:mouse|pointer)down/.test(h)&&s&c.BIT_01&&e.contains(t)&&i.add(e);break}case"target":{const{hash:s}=new URL(this.#t.URL);e.id&&s===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:s}=new URL(this.#t.URL);if(s){const t=s.replace(/^#/,"");let h=this.#t.getElementById(t);for(;h;){if(h===e){i.add(e);break}h=h.parentNode}}break}case"scope":{this.#e.nodeType===c.ELEMENT_NODE?!this.#u&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":{e===this.#t.activeElement&&e.tabIndex>=0&&(0,k.isFocusable)(e)&&i.add(e);break}case"focus-visible":{if(e===this.#t.activeElement&&e.tabIndex>=0){let s;if((0,k.isFocusVisible)(e))s=!0;else{const{target:t,type:h}=this.#n??{},{target:b,relatedTarget:p}=this.#k??{};(/^key(?:down|up)$/.test(h)&&e.contains(t)||p&&(0,k.isFocusVisible)(p)&&e.contains(b))&&(s=!0)}s&&(0,k.isFocusable)(e)&&i.add(e)}break}case"focus-within":{let s,t=this.#t.activeElement;if(t.tabIndex>=0)for(;t;){if(t===e){s=!0;break}t=t.parentNode}s&&(0,k.isFocusable)(e)&&i.add(e);break}case"open":{$.test(l)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{$.test(l)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(M.test(l)||(0,k.isCustomElement)(e,{formAssociated:!0})){if(e.disabled||e.hasAttribute("disabled"))i.add(e);else if(e.localName==="option")o.localName==="optgroup"&&(o.disabled||o.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let s,t=o;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const h=this.#r;let b=(0,k.traverseNode)(t,h);for(b=h.firstChild();b&&b.localName!=="legend";)b=h.nextSibling();b&&b.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===c.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s&&i.add(e)}}break}case"enabled":{if((M.test(l)||(0,k.isCustomElement)(e,{formAssociated:!0}))&&!(e.disabled&&e.hasAttribute("disabled")))if(e.localName==="optgroup")i.add(e);else if(e.localName==="option")(o.localName!=="optgroup"||!(o.disabled||o.hasAttribute("disabled")))&&i.add(e);else{let s,t=o;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const h=this.#r;let b=(0,k.traverseNode)(t,h);for(b=h.firstChild();b&&b.localName!=="legend";)b=h.nextSibling();b&&b.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===c.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s||i.add(e)}break}case"read-only":{switch(l){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||c.REG_INPUT_TYPE.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(l){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||c.REG_INPUT_TYPE.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 s;if(e.placeholder?s=e.placeholder:e.hasAttribute("placeholder")&&(s=e.getAttribute("placeholder")),typeof s=="string"&&!/[\r\n]/.test(s)){let t;l==="textarea"?t=e:l==="input"&&(e.hasAttribute("type")?Q.test(e.getAttribute("type"))&&(t=e):t=e),t&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&l==="input"&&e.hasAttribute("type")&&C.test(e.getAttribute("type"))||e.selected&&l==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&l==="input"&&e.type==="checkbox"||l==="progress"&&!e.hasAttribute("value"))i.add(e);else if(l==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const s=e.name;let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;t||(t=this.#t.documentElement);const h=t.getElementsByTagName("input"),b=h.length;let p;for(let m=0;m<b;m++){const w=h[m];if(w.getAttribute("type")==="radio"&&(s?w.getAttribute("name")===s&&(p=!!w.checked):w.hasAttribute("name")||(p=!!w.checked),p))break}p||i.add(e)}break}case"default":{if(l==="button"&&!(e.hasAttribute("type")&&D.test(e.getAttribute("type")))||l==="input"&&e.hasAttribute("type")&&U.test(e.getAttribute("type"))){let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;if(s){const t=this.#r;let h=(0,k.traverseNode)(s,t);for(h=t.firstChild();h&&s.contains(h);){const b=h.localName;let p;if(b==="button"?p=!(h.hasAttribute("type")&&D.test(h.getAttribute("type"))):b==="input"&&(p=h.hasAttribute("type")&&U.test(h.getAttribute("type"))),p){h===e&&i.add(e);break}h=t.nextNode()}}}else(l==="input"&&e.hasAttribute("type")&&C.test(e.getAttribute("type"))&&e.hasAttribute("checked")||l==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(T.test(l))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(l==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let h;if(!t)h=!0;else for(;t&&e.contains(t)&&!(T.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?h=t.maxLength>=t.value.length:h=!0:h=!1,!h));)t=s.nextNode();h&&i.add(e)}break}case"invalid":{if(T.test(l))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(l==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let h;if(!t)h=!0;else for(;t&&e.contains(t)&&!(T.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?h=t.maxLength>=t.value.length:h=!0:h=!1,!h));)t=s.nextNode();h||i.add(e)}break}case"in-range":{l==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&P.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":{l==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&P.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let s;if(/^(?:select|textarea)$/.test(l))s=e;else if(l==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||C.test(t)||c.REG_INPUT_TYPE.test(t))&&(s=e)}else s=e;s&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let s;if(/^(?:select|textarea)$/.test(l))s=e;else if(l==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||C.test(t)||c.REG_INPUT_TYPE.test(t))&&(s=e)}else s=e;s&&!(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 s=this.#t.createTreeWalker(e,c.SHOW_ALL);let t=s.firstChild(),h;for(;t&&(h=t.nodeType!==c.ELEMENT_NODE&&t.nodeType!==c.TEXT_NODE,!!h);)t=s.nextSibling();h&&i.add(e)}else i.add(e);break}case"first-child":{(o&&e===o.firstElementChild||e===this.#s)&&i.add(e);break}case"last-child":{(o&&e===o.lastElementChild||e===this.#s)&&i.add(e);break}case"only-child":{(o&&e===o.firstElementChild&&e===o.lastElementChild||e===this.#s)&&i.add(e);break}case"first-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1},e);if(s===e){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t===e&&i.add(e)}}else e===this.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||l.includes("-")?(0,k.isCustomElement)(e)&&i.add(e):(e instanceof this.#a.HTMLElement||e instanceof this.#a.SVGElement)&&i.add(e);break}case"popover-open":{e.popover&&(0,k.isVisible)(e)&&i.add(e);break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d)throw new DOMException(`Unsupported pseudo-element ::${a}`,c.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)throw new DOMException(`Unsupported pseudo-class :${a}`,c.NOT_SUPPORTED_ERR);break}default:if(a.startsWith("-webkit-")){if(d)throw new DOMException(`Unsupported pseudo-class :${a}`,c.NOT_SUPPORTED_ERR)}else if(!u)throw new DOMException(`Unknown pseudo-class :${a}`,c.SYNTAX_ERR)}return i}_matchShadowHostPseudoClass(r,e){const{children:f,name:n}=r;let a;if(Array.isArray(f)){const{branches:l}=(0,g.walkAST)(f[0]),[o]=l,[...u]=o,{host:d}=e;if(n==="host"){let i;for(const s of u){const{type:t}=s;if(t===c.COMBINATOR){const h=(0,g.generateCSS)(r);throw new DOMException(`Invalid selector ${h}`,c.SYNTAX_ERR)}if(i=this._matchSelector(s,d).has(d),!i)break}i&&(a=e)}else if(n==="host-context"){let i=d,s;for(;i;){for(const t of u){const{type:h}=t;if(h===c.COMBINATOR){const b=(0,g.generateCSS)(r);throw new DOMException(`Invalid selector ${b}`,c.SYNTAX_ERR)}if(s=this._matchSelector(t,i).has(i),!s)break}if(s)break;i=i.parentNode}s&&(a=e)}}else if(n==="host")a=e;else throw new DOMException(`Invalid selector :${n}`,c.SYNTAX_ERR);return a??null}_matchSelector(r,e,f={}){const{type:n}=r,a=new Set;if(r.name===c.EMPTY)return a;const l=(0,g.unescapeSelector)(r.name);if(typeof l=="string"&&l!==r.name&&(r.name=l),e.nodeType===c.ELEMENT_NODE)switch(n){case c.PS_ELEMENT_SELECTOR:{this.#h.matchPseudoElementSelector(l,f);break}case c.ID_SELECTOR:{e.id===l&&a.add(e);break}case c.CLASS_SELECTOR:{e.classList.contains(l)&&a.add(e);break}case c.PS_CLASS_SELECTOR:return this._matchPseudoClassSelector(r,e,f);default:{const o=this.#h.matchSelector(r,e,f,!0);o&&a.add(o)}}else if(this.#u&&n===c.PS_CLASS_SELECTOR&&e.nodeType===c.DOCUMENT_FRAGMENT_NODE){if(c.REG_LOGICAL.test(l))return f.isShadowRoot=!0,this._matchPseudoClassSelector(r,e,f);if(I.test(l)){const o=this._matchShadowHostPseudoClass(r,e,f);o&&(this.#_=!0,a.add(o))}}return a}_matchLeaves(r,e,f){let n,a;if(this.#o?a=this.#b.get(r):a=this.#N.get(r),a&&a.has(e)){const{matched:l}=a.get(e);n=l}if(typeof n!="boolean"){let l=!0;e.nodeType===c.ELEMENT_NODE&&/^(?:button|fieldset|form|input|select|textarea)$/.test(e.localName)&&(l=!1);for(const o of r){switch(o.type){case c.ATTR_SELECTOR:case c.ID_SELECTOR:{l=!1;break}case c.PS_CLASS_SELECTOR:{/^(?:(?:any-)?link|defined|dir)$/.test(o.name)&&(l=!1);break}default:}if(n=this._matchSelector(o,e,f).has(e),!n)break}l&&(a||(a=new WeakMap),a.set(e,{matched:n}),this.#o?this.#b.set(r,a):this.#N.set(r,a))}return!!n}_matchHTMLCollection(r,e={}){const{compound:f,filterLeaves:n}=e,a=new Set,l=r.length;if(l)if(f)for(let o=0;o<l;o++){const u=r[o];this._matchLeaves(n,u,e)&&a.add(u)}else{const o=[].slice.call(r);return new Set(o)}return a}_findDescendantNodes(r,e,f){const[n,...a]=r,l=a.length>0,{type:o}=n,u=(0,g.unescapeSelector)(n.name);typeof u=="string"&&u!==n.name&&(n.name=u);let d=new Set,i=!1;if(this.#u)i=!0;else switch(o){case c.PS_ELEMENT_SELECTOR:{this.#h.matchPseudoElementSelector(u,f);break}case c.ID_SELECTOR:{if(this.#s.nodeType===c.ELEMENT_NODE)i=!0;else{const s=this.#s.getElementById(u);s&&s!==e&&e.contains(s)&&(l?this._matchLeaves(a,s,f)&&d.add(s):d.add(s))}break}case c.CLASS_SELECTOR:{const s=e.getElementsByClassName(u);d=this._matchHTMLCollection(s,{compound:l,filterLeaves:a});break}case c.TYPE_SELECTOR:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(u)){const s=e.getElementsByTagName(u);d=this._matchHTMLCollection(s,{compound:l,filterLeaves:a})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(r,e,f={}){const{combo:n,leaves:a}=r,{name:l}=n,{parentNode:o}=e,{dir:u}=f,d=new Set;if(u===E)switch(l){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(a,i,f)&&d.add(i);break}case"~":{if(o){const i=this._createTreeWalker(o);let s=(0,k.traverseNode)(e,i);for(s=i.nextSibling();s;)this._matchLeaves(a,s,f)&&d.add(s),s=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let s=(0,k.traverseNode)(e,i);for(s=i.firstChild();s;)this._matchLeaves(a,s,f)&&d.add(s),s=i.nextSibling();break}case" ":default:{const{nodes:i,pending:s}=this._findDescendantNodes(a,e);if(i.size)return i;if(s){const t=this._createTreeWalker(e);let h=(0,k.traverseNode)(e,t);for(h=t.nextNode();h&&e.contains(h);)this._matchLeaves(a,h,f)&&d.add(h),h=t.nextNode()}}}else switch(l){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(a,i,f)&&d.add(i);break}case"~":{if(o){const i=this._createTreeWalker(o);let s=(0,k.traverseNode)(o,i);for(s=i.firstChild();s&&s!==e;)this._matchLeaves(a,s,f)&&d.add(s),s=i.nextSibling()}break}case">":{o&&this._matchLeaves(a,o,f)&&d.add(o);break}case" ":default:{const i=[];let s=o;for(;s;)this._matchLeaves(a,s,f)&&i.push(s),s=s.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(r,e){const{node:f}=e,n=this.#m;let a=(0,k.traverseNode)(f,n),l;if(a)for((a.nodeType!==c.ELEMENT_NODE||a===f&&a!==this.#s)&&(a=n.nextNode());a;){if(this._matchLeaves(r,a,{warn:this.#i})){l=a;break}a=n.nextNode()}return l??null}_matchSelf(r){const e=[],f=this._matchLeaves(r,this.#e,{warn:this.#i});let n=!1;return f&&(e.push(this.#e),n=!0),[e,n]}_findLineal(r,e={}){const{complex:f}=e,n=[];let a=this._matchLeaves(r,this.#e,{warn:this.#i}),l=!1;if(a&&(n.push(this.#e),l=!0),!a||f){let o=this.#e.parentNode;for(;o&&(a=this._matchLeaves(r,o,{warn:this.#i}),a&&(n.push(o),l=!0),o.parentNode);)o=o.parentNode}return[n,l]}_findFirst(r){const e=[],f=this._findNode(r,{node:this.#e});let n=!1;return f&&(e.push(f),n=!0),[e,n]}_findFromHTMLCollection(r,e={}){const{complex:f,compound:n,filterLeaves:a,targetType:l}=e;let o=[],u=!1,d=!1;const i=r.length;if(i)if(this.#e.nodeType===c.ELEMENT_NODE)for(let s=0;s<i;s++){const t=r[s];if(t!==this.#e&&(this.#e.contains(t)||t.contains(this.#e))){if(n){if(this._matchLeaves(a,t,{warn:this.#i})&&(o.push(t),u=!0,l===c.TARGET_FIRST))break}else if(o.push(t),u=!0,l===c.TARGET_FIRST)break}}else if(f)if(n)for(let s=0;s<i;s++){const t=r[s];if(this._matchLeaves(a,t,{warn:this.#i})&&(o.push(t),u=!0,l===c.TARGET_FIRST))break}else o=[].slice.call(r),u=!0,d=!0;else if(n)for(let s=0;s<i;s++){const t=r[s];if(this._matchLeaves(a,t,{warn:this.#i})&&(o.push(t),u=!0,l===c.TARGET_FIRST))break}else o=[].slice.call(r),u=!0,d=!0;return[o,u,d]}_findEntryNodes(r,e,f){const{leaves:n}=r,[a,...l]=n,o=l.length>0,{name:u,type:d}=a;let i=[],s=!1,t=!1,h=!1;switch(d){case c.PS_ELEMENT_SELECTOR:{this.#h.matchPseudoElementSelector(u,{warn:this.#i});break}case c.ID_SELECTOR:{if(e===c.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===c.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:f});else if(e===c.TARGET_FIRST&&this.#s.nodeType!==c.ELEMENT_NODE){const b=this.#s.getElementById(u);b&&(o?this._matchLeaves(l,b,{warn:this.#i})&&(i.push(b),t=!0):(i.push(b),t=!0))}else e===c.TARGET_FIRST?[i,t]=this._findFirst(n):h=!0;break}case c.CLASS_SELECTOR:{if(e===c.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===c.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:f});else if(this.#s.nodeType===c.DOCUMENT_NODE){const b=this.#s.getElementsByClassName(u);b.length&&([i,t,s]=this._findFromHTMLCollection(b,{complex:f,compound:o,filterLeaves:l,targetType:e}))}else e===c.TARGET_FIRST?[i,t]=this._findFirst(n):h=!0;break}case c.TYPE_SELECTOR:{if(e===c.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===c.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:f});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===c.DOCUMENT_NODE&&!/[*|]/.test(u)){const b=this.#s.getElementsByTagName(u);b.length&&([i,t,s]=this._findFromHTMLCollection(b,{complex:f,compound:o,filterLeaves:l,targetType:e}))}else e===c.TARGET_FIRST?[i,t]=this._findFirst(n):h=!0;break}default:if(e!==c.TARGET_LINEAL&&I.test(u)){if(this.#u&&this.#e.nodeType===c.DOCUMENT_FRAGMENT_NODE){const b=this._matchShadowHostPseudoClass(a,this.#e);b&&(i.push(b),t=!0)}}else e===c.TARGET_SELF?[i,t]=this._matchSelf(n):e===c.TARGET_LINEAL?[i,t]=this._findLineal(n,{complex:f}):e===c.TARGET_FIRST?[i,t]=this._findFirst(n):h=!0}return{collected:s,compound:o,filtered:t,nodes:i,pending:h}}_collectNodes(r){const e=this.#l.values();if(r===c.TARGET_ALL||r===c.TARGET_FIRST){const f=new Set;let n=0;for(const{branch:a}of e){const l=a.length,o=l>1,u=a[0];let d,i;if(o){const{combo:m,leaves:[{name:w,type:N}]}=u,_=a[l-1],{leaves:[{name:y,type:v}]}=_;if(v===c.PS_ELEMENT_SELECTOR||v===c.ID_SELECTOR)d=x,i=_;else if(N===c.PS_ELEMENT_SELECTOR||N===c.ID_SELECTOR)d=E,i=u;else if(r===c.TARGET_ALL)if(w==="*"&&N===c.TYPE_SELECTOR)d=x,i=_;else if(y==="*"&&v===c.TYPE_SELECTOR)d=E,i=u;else if(l===2){const{name:A}=m;/^[+~]$/.test(A)?(d=x,i=_):(d=E,i=u)}else d=E,i=u;else if(y==="*"&&v===c.TYPE_SELECTOR)d=E,i=u;else if(w==="*"&&N===c.TYPE_SELECTOR)d=x,i=_;else{let A;for(const{combo:L,leaves:[W]}of a){const{name:G,type:H}=W;if(H===c.PS_CLASS_SELECTOR&&G==="dir"){A=!1;break}if(!A&&L){const{name:z}=L;/^[+~]$/.test(z)&&(A=!0)}}A?(d=E,i=u):(d=x,i=_)}}else d=x,i=u;const{collected:s,compound:t,filtered:h,nodes:b,pending:p}=this._findEntryNodes(i,r,o);b.length?(this.#l[n].find=!0,this.#d[n]=b):p&&f.add(new Map([["index",n],["twig",i]])),this.#l[n].collected=s,this.#l[n].dir=d,this.#l[n].filtered=h||!t,n++}if(f.size){let a,l;this.#e!==this.#s&&this.#e.nodeType===c.ELEMENT_NODE?(a=this.#e,l=this.#m):(a=this.#s,l=this.#r);let o=(0,k.traverseNode)(a,l);for(;o;){let u=!1;if(this.#e.nodeType===c.ELEMENT_NODE?o===this.#e?u=!0:u=this.#e.contains(o):u=!0,u)for(const d of f){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,o,{warn:this.#i})){const t=d.get("index");this.#l[t].filtered=!0,this.#l[t].find=!0,this.#d[t].push(o)}}o!==l.currentNode&&(o=(0,k.traverseNode)(o,l)),o=l.nextNode()}}}else{let f=0;for(const{branch:n}of e){const a=n[n.length-1],l=n.length>1,{compound:o,filtered:u,nodes:d}=this._findEntryNodes(a,r,l);d.length&&(this.#l[f].find=!0,this.#d[f]=d),this.#l[f].dir=x,this.#l[f].filtered=u||!o,f++}}return[this.#l,this.#d]}_getCombinedNodes(r,e,f){const n=[];for(const a of e){const l=this._matchCombinator(r,a,{dir:f,warn:this.#i});l.size&&n.push(...l)}return n.length?new Set(n):new Set}_matchNodeNext(r,e,f){const{combo:n,index:a}=f,{combo:l,leaves:o}=r[a],u={combo:n,leaves:o},d=this._getCombinedNodes(u,e,E);let i;if(d.size)if(a===r.length-1){const[s]=(0,k.sortNodes)(d);i=s}else i=this._matchNodeNext(r,d,{combo:l,index:a+1});return i??null}_matchNodePrev(r,e,f){const{index:n}=f,a=r[n],l=new Set([e]),o=this._getCombinedNodes(a,l,x);let u;if(o.size){if(n===0)u=e;else for(const d of o)if(this._matchNodePrev(r,d,{index:n-1}))return e}return u??null}find(r){(r===c.TARGET_ALL||r===c.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],f]=this._collectNodes(r),n=e.length;let a,l=new Set;for(let o=0;o<n;o++){const{branch:u,collected:d,dir:i,find:s}=e[o],t=u.length;if(t&&s){const h=f[o],b=h.length,p=t-1;if(p===0)if((r===c.TARGET_ALL||r===c.TARGET_FIRST)&&this.#e.nodeType===c.ELEMENT_NODE)for(let m=0;m<b;m++){const w=h[m];if(w!==this.#e&&this.#e.contains(w)&&(l.add(w),r!==c.TARGET_ALL))break}else if(r===c.TARGET_ALL)if(l.size){const m=[...l];l=new Set([...m,...h]),a=!0}else l=new Set(h);else{const[m]=h;l.add(m)}else if(r===c.TARGET_ALL)if(i===E){let{combo:m}=u[0];for(const w of h){let N=new Set([w]);for(let _=1;_<t;_++){const{combo:y,leaves:v}=u[_],A={combo:m,leaves:v};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===p)if(l.size){const L=[...l];l=new Set([...L,...N]),a=!0}else l=N;else m=y;else break}}}else for(const m of h){let w=new Set([m]);for(let N=p-1;N>=0;N--){const _=u[N];if(w=this._getCombinedNodes(_,w,i),w.size)N===0&&(l.add(m),t>1&&l.size>1&&(a=!0));else break}}else if(r===c.TARGET_FIRST&&i===E){const{combo:m}=u[0];let w;for(const N of h)if(w=this._matchNodeNext(u,new Set([N]),{combo:m,index:1}),w){l.add(w);break}if(!w&&!d){const{leaves:N}=u[0],[_]=h;let y=this._findNode(N,{node:_});for(;y;){if(w=this._matchNodeNext(u,new Set([y]),{combo:m,index:1}),w){l.add(w);break}y=this._findNode(N,{node:y})}}}else{let m;for(const w of h)if(m=this._matchNodePrev(u,w,{index:p-1}),m){l.add(w);break}if(!m&&!d&&r===c.TARGET_FIRST){const{leaves:w}=u[p],[N]=h;let _=this._findNode(w,{node:N});for(;_;){if(m=this._matchNodePrev(u,_,{index:p-1}),m){l.add(_);break}_=this._findNode(w,{node:_})}}}}}return r===c.TARGET_FIRST?(l.delete(this.#e),l.size>1&&(l=new Set((0,k.sortNodes)(l)))):r===c.TARGET_ALL&&(l.delete(this.#e),a&&l.size>1&&(l=new Set((0,k.sortNodes)(l)))),l}}0&&(module.exports={Finder});
1
+ var C=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var F=(x,r)=>{for(var e in r)C(x,e,{get:r[e],enumerable:!0})},W=(x,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of D(r))!U.call(x,n)&&n!==e&&C(x,n,{get:()=>r[n],enumerable:!(o=P(r,n))||o.enumerable});return x};var z=x=>W(C({},"__esModule",{value:!0}),x);var H={};F(H,{Finder:()=>$});module.exports=z(H);var O=require("./matcher.js"),g=require("./parser.js"),N=require("./utility.js"),c=require("./constant.js");const v="next",S="prev";class ${#l;#r;#w;#t;#f;#n;#k;#c;#b;#h;#e;#d;#g;#m;#N;#s;#u;#_;#o;#p;#i;#a;constructor(r){this.#a=r,this.#h=new O.Matcher,this.#r=new WeakMap,this.#f=new WeakMap,this.#b=new WeakMap,this.#N=new WeakMap,this.#n=null,this.#k=null,this._registerEventListeners()}onError(r,e){if(!(e?.noexcept??this.#g))if(r instanceof DOMException||r instanceof this.#a.DOMException)if(r.name===c.NOT_SUPPORTED_ERR)this.#i&&console.warn(r.message);else throw new this.#a.DOMException(r.message,r.name);else throw r.name in this.#a?new this.#a[r.name](r.message):r}setup(r,e,o={}){const{event:n,noexcept:a,warn:l}=o;return this.#g=!!a,this.#i=!!l,this.#e=e,[this.#t,this.#s,this.#o]=(0,N.resolveContent)(e),this.#u=(0,N.isInShadowTree)(e),[this.#l,this.#d]=this._correspond(r),this.#b=new WeakMap,this.#p=new WeakMap,this.#_=null,this._setEvent(n),this}_registerEventListeners(){const r={capture:!0,passive:!0},e=[],o=["mouseover","mousedown","mouseup","mouseout"];for(const a of o)e.push(this.#a.addEventListener(a,l=>{this.#n=l},r));const n=["keydown","keyup"];for(const a of n)e.push(this.#a.addEventListener(a,l=>{l.key==="Tab"&&(this.#n=l)},r));return e.push(this.#a.addEventListener("focusin",a=>{this.#k=a},r)),e}_setEvent(r){return(r instanceof this.#a.KeyboardEvent||r instanceof this.#a.MouseEvent)&&(this.#n=r),this.#n}_correspond(r){const e=[];this.#w=!1,this.#c=!1;let o;if(this.#f.has(this.#t)){const n=this.#f.get(this.#t);if(n&&n.has(`${r}`)){const a=n.get(`${r}`);o=a.ast,this.#w=a.descendant,this.#c=a.invalidate}}if(o){const n=o.length;for(let a=0;a<n;a++)o[a].collected=!1,o[a].dir=null,o[a].filtered=!1,o[a].find=!1,e[a]=[]}else{let n;try{n=(0,g.parseSelector)(r)}catch(b){this.onError(b)}const{branches:a,info:l}=(0,g.walkAST)(n),{hasHasPseudoFunc:f,hasLogicalPseudoFunc:u,hasNthChildOfSelector:d}=l;let i=f||!!(u&&d),t=!1,s=0;o=[];for(const[...b]of a){const m=[];let p=b.shift();if(p&&p.type!==c.COMBINATOR){const w=new Set;for(;p;){let k=p.name;if(p.type===c.COMBINATOR){const[_]=b;if(_.type===c.COMBINATOR)throw new DOMException(`Invalid selector ${r}`,c.SYNTAX_ERR);k==="+"||k==="~"?i=!0:t=!0,m.push({combo:p,leaves:(0,g.sortAST)(w)}),w.clear()}else p&&(k&&typeof k=="string"&&(k=(0,g.unescapeSelector)(k),typeof k=="string"&&k!==p.name&&(p.name=k),/[|:]/.test(k)&&(p.namespace=!0)),w.add(p));if(b.length)p=b.shift();else{m.push({combo:null,leaves:(0,g.sortAST)(w)}),w.clear();break}}}o.push({branch:m,collected:!1,dir:null,filtered:!1,find:!1}),e[s]=[],s++}let h;this.#f.has(this.#t)?h=this.#f.get(this.#t):h=new Map,h.set(`${r}`,{ast:o,descendant:t,invalidate:i}),this.#f.set(this.#t,h),this.#w=t,this.#c=i}return[o,e]}_createTreeWalker(r){let e;return this.#p.has(r)?e=this.#p.get(r):(e=this.#t.createTreeWalker(r,c.WALKER_FILTER),this.#p.set(r,e)),e}_prepareQuerySelectorWalker(){return this.#m=this._createTreeWalker(this.#e),this.#m}_collectNthChild(r,e,o){const{a:n,b:a,reverse:l,selector:f}=r,{parentNode:u}=e,d=new Set;let i;if(f){if(this.#r.has(f))i=this.#r.get(f);else{const{branches:s}=(0,g.walkAST)(f);i=s,this.#c||this.#r.set(f,i)}const{branches:t}=(0,g.walkAST)(f);i=t}if(u){const t=this.#o;let s=(0,N.traverseNode)(u,t);s=t.firstChild();let h=0;for(;s;)h++,s=t.nextSibling();const b=new Set;if(i)for(s=(0,N.traverseNode)(u,t),s=t.firstChild();s;){if((0,N.isVisible)(s)){let m;for(const p of i)if(m=this._matchLeaves(p,s,o),!m)break;m&&b.add(s)}s=t.nextSibling()}if(n===0){if(a>0&&a<=h){if(b.size){s=(0,N.traverseNode)(u,t),l?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(b.has(s)){if(m===a-1){d.add(s);break}m++}l?s=t.previousSibling():s=t.nextSibling()}}else if(!f){s=(0,N.traverseNode)(u,t),l?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(m===a-1){d.add(s);break}l?s=t.previousSibling():s=t.nextSibling(),m++}}}}else{let m=a-1;if(n>0)for(;m<0;)m+=n;if(m>=0&&m<h){s=(0,N.traverseNode)(u,t),l?s=t.lastChild():s=t.firstChild();let p=0,w=n>0?0:a-1;for(;s&&(s&&m>=0&&m<h);)b.size?b.has(s)&&(w===m&&(d.add(s),m+=n),n>0?w++:w--):p===m&&(f||d.add(s),m+=n),l?s=t.previousSibling():s=t.nextSibling(),p++}}if(l&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&n+a===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,o),t)break;t&&d.add(e)}else d.add(e);return d}_collectNthOfType(r,e){const{a:o,b:n,reverse:a}=r,{localName:l,namespaceURI:f,parentNode:u,prefix:d}=e,i=new Set;if(u){const t=this.#o;let s=(0,N.traverseNode)(u,t);s=t.firstChild();let h=0;for(;s;)h++,s=t.nextSibling();if(o===0){if(n>0&&n<=h){s=(0,N.traverseNode)(u,t),a?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){const{localName:m,namespaceURI:p,prefix:w}=s;if(m===l&&w===d&&p===f){if(b===n-1){i.add(s);break}b++}a?s=t.previousSibling():s=t.nextSibling()}}}else{let b=n-1;if(o>0)for(;b<0;)b+=o;if(b>=0&&b<h){s=(0,N.traverseNode)(u,t),a?s=t.lastChild():s=t.firstChild();let m=o>0?0:n-1;for(;s;){const{localName:p,namespaceURI:w,prefix:k}=s;if(p===l&&k===d&&w===f){if(m===b&&(i.add(s),b+=o),b<0||b>=h)break;o>0?m++:m--}a?s=t.previousSibling():s=t.nextSibling()}}}if(a&&i.size>1){const b=[...i];return new Set(b.reverse())}}else e===this.#s&&o+n===1&&i.add(e);return i}_matchAnPlusB(r,e,o,n){const{nth:{a,b:l,name:f},selector:u}=r,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)),o.indexOf("last")>-1&&d.set("reverse",!0)):(typeof a=="string"&&/-?\d+/.test(a)?d.set("a",a*1):d.set("a",0),typeof l=="string"&&/-?\d+/.test(l)?d.set("b",l*1):d.set("b",0),o.indexOf("last")>-1&&d.set("reverse",!0)),o==="nth-child"||o==="nth-last-child"){u&&d.set("selector",u);const i=Object.fromEntries(d);return this._collectNthChild(i,e,n)}else if(o==="nth-of-type"||o==="nth-last-of-type"){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(r,e,o){let n;if(Array.isArray(r)&&r.length){const a=[...r],[l]=a,{type:f}=l;let u;f===c.COMBINATOR?u=a.shift():u={name:" ",type:c.COMBINATOR};const d=[];for(;a.length;){const[s]=a,{type:h}=s;if(h===c.COMBINATOR)break;d.push(a.shift())}const i={combo:u,leaves:d};o.dir=v;const t=this._matchCombinator(i,e,o);if(t.size)if(a.length){for(const s of t)if(n=this._matchHasPseudoFunc(a,s,o),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(r,e,o){const{astName:n,branches:a,twigBranches:l}=r,{isShadowRoot:f}=o;let u;if(n==="has"){let d;for(const i of a)if(d=this._matchHasPseudoFunc(i,e,o),d)break;if(d)if(f){if(this.#_)return e}else return e}else{if(f){for(const t of a)if(t.length>1)return null}o.forgive=n==="is"||n==="where";const d=l.length;let i;for(let t=0;t<d;t++){const s=l[t],h=s.length-1,{leaves:b}=s[h];if(i=this._matchLeaves(b,e,o),i&&h>0){let m=new Set([e]);for(let p=h-1;p>=0;p--){const w=s[p],k=[];o.dir=S;for(const _ of m){const y=this._matchCombinator(w,_,o);y.size&&k.push(...y)}if(k.length)p===0?i=!0:m=new Set(k);else{i=!1;break}}}if(i)break}if(n==="not"){if(!i)return e}else if(i)return e}return u??null}_matchPseudoClassSelector(r,e,o){const{children:n,name:a}=r,{localName:l,parentNode:f}=e,{forgive:u,warn:d=this.#i}=o,i=new Set;if(c.KEY_LOGICAL.includes(a)){let t;if(this.#r.has(r))t=this.#r.get(r);else{const{branches:h}=(0,g.walkAST)(r);if(a==="has"){for(const b of n){const m=(0,g.findAST)(b,p=>c.KEY_LOGICAL.includes(p.name)&&(0,g.findAST)(p,w=>w.name==="has")?p:null);if(m){const p=m.name;if(p==="is"||p==="where")return i;{const w=(0,g.generateCSS)(r);throw new DOMException(`Invalid selector ${w}`,c.SYNTAX_ERR)}}}t={astName:a,branches:h}}else{const b=[];for(const[...m]of h){const p=[],w=new Set;let k=m.shift();for(;k;)if(k.type===c.COMBINATOR?(p.push({combo:k,leaves:[...w]}),w.clear()):k&&w.add(k),m.length)k=m.shift();else{p.push({combo:null,leaves:[...w]}),w.clear();break}b.push(p)}t={astName:a,branches:h,twigBranches:b},this.#c||this.#r.set(r,t)}}const s=this._matchLogicalPseudoFunc(t,e,o);s&&i.add(s)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(a)){const[t]=n;return this._matchAnPlusB(t,e,a,o)}else switch(a){case"dir":case"lang":{const t=this.#h.matchSelector(r,e,o,!0);t&&i.add(t);break}case"state":{if((0,N.isCustomElement)(e)){const[{value:t}]=n;if(t)if(e[t])i.add(e);else for(const s in e){const h=e[s];if(h instanceof this.#a.ElementInternals){h?.states?.has(t)&&i.add(e);break}}}break}case"current":case"nth-col":case"nth-last-col":{if(d)throw new DOMException(`Unsupported pseudo-class :${a}()`,c.NOT_SUPPORTED_ERR);break}case"host":case"host-context":break;case"contains":{if(d)throw new DOMException(`Unknown pseudo-class :${a}()`,c.NOT_SUPPORTED_ERR);break}default:if(!u)throw new DOMException(`Unknown pseudo-class :${a}()`,c.SYNTAX_ERR)}else switch(a){case"any-link":case"link":{(l==="a"||l==="area")&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if((l==="a"||l==="area")&&e.hasAttribute("href")){const{href:t,origin:s,pathname:h}=new URL(this.#t.URL),b=new URL(e.getAttribute("href"),t);b.origin===s&&b.pathname===h&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#n??{};["mousedown","mouseover","mouseup"].includes(s)&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:h}=this.#n??{};h==="mousedown"&&t&c.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 h=this.#t.getElementById(s);for(;h;){if(h===e){i.add(e);break}h=h.parentNode}}break}case"scope":{this.#e.nodeType===c.ELEMENT_NODE?!this.#u&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":{e===this.#t.activeElement&&(0,N.isFocusableArea)(e)&&i.add(e);break}case"focus-visible":{if(e===this.#t.activeElement&&(0,N.isFocusableArea)(e)){let t;if((0,N.isFocusVisible)(e))t=!0;else{const{target:s,type:h}=this.#n??{},{target:b,relatedTarget:m}=this.#k??{};((h==="keydown"||h==="keyup")&&e.contains(s)||m&&(0,N.isFocusVisible)(m)&&e.contains(b))&&(t=!0)}t&&i.add(e)}break}case"focus-within":{let t,s=this.#t.activeElement;if((0,N.isFocusableArea)(s))for(;s;){if(s===e){t=!0;break}s=s.parentNode}t&&i.add(e);break}case"open":case"closed":{(l==="details"||l==="dialog")&&(e.hasAttribute("open")?a==="open"&&i.add(e):a==="closed"&&i.add(e));break}case"disabled":case"enabled":{if([...c.KEY_FORM_FOCUS,"fieldset","optgroup","option"].includes(l)||(0,N.isCustomElement)(e,{formAssociated:!0})){let s;if(e.disabled||e.hasAttribute("disabled"))s=!0;else if(e.localName==="option")f.localName==="optgroup"&&(f.disabled||f.hasAttribute("disabled"))&&(s=!0);else if(e.localName!=="optgroup"){let h=f;for(;h;)if(h.localName==="fieldset"&&(h.disabled||h.hasAttribute("disabled"))){const b=this.#o;let m=(0,N.traverseNode)(h,b);for(m=b.firstChild();m&&m.localName!=="legend";)m=b.nextSibling();m&&m.contains(e)||(s=!0);break}else{if(h.localName==="form")break;if(h.parentNode?.nodeType===c.ELEMENT_NODE){if(h.parentNode.localName==="form")break;h=h.parentNode}else break}}s?a==="disabled"&&i.add(e):a==="enabled"&&i.add(e)}break}case"read-only":case"read-write":{let t,s;switch(l){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")?t=!0:s=!0;break}case"input":{(!e.type||c.KEY_INPUT_EDIT.includes(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")?t=!0:s=!0);break}default:(0,N.isContentEditable)(e)?s=!0:t=!0}t?a==="read-only"&&i.add(e):a==="read-write"&&s&&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;l==="textarea"?s=e:l==="input"&&(e.hasAttribute("type")?[...c.KEY_INPUT_TEXT,"number"].includes(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{const t=e.getAttribute("type");(e.checked&&l==="input"&&(t==="checkbox"||t==="radio")||e.selected&&l==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&l==="input"&&e.type==="checkbox"||l==="progress"&&!e.hasAttribute("value"))i.add(e);else if(l==="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 h=s.getElementsByTagName("input"),b=h.length;let m;for(let p=0;p<b;p++){const w=h[p];if(w.getAttribute("type")==="radio"&&(t?w.getAttribute("name")===t&&(m=!!w.checked):w.hasAttribute("name")||(m=!!w.checked),m))break}m||i.add(e)}break}case"default":{const t=["checkbox","radio"],s=["button","reset"],h=["image","submit"],b=e.getAttribute("type");if(l==="button"&&!(e.hasAttribute("type")&&s.includes(b))||l==="input"&&e.hasAttribute("type")&&h.includes(b)){let m=e.parentNode;for(;m&&m.localName!=="form";)m=m.parentNode;if(m){const p=this.#o;let w=(0,N.traverseNode)(m,p);for(w=p.firstChild();w&&m.contains(w);){const k=w.localName,_=w.getAttribute("type");let y;if(k==="button"?y=!(w.hasAttribute("type")&&s.includes(_)):k==="input"&&(y=w.hasAttribute("type")&&h.includes(_)),y){w===e&&i.add(e);break}w=p.nextNode()}}}else(l==="input"&&e.hasAttribute("type")&&t.includes(b)&&e.hasAttribute("checked")||l==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":case"invalid":{const t=[...c.KEY_FORM_FOCUS,"form"];if(t.includes(l)){let s;e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&(s=!0):s=!0),s?a==="valid"&&i.add(e):a==="invalid"&&i.add(e)}else if(l==="fieldset"){const s=this.#o;let h=(0,N.traverseNode)(e,s);h=s.firstChild();let b;if(!h)b=!0;else for(;h&&e.contains(h)&&!(t.includes(h.localName)&&(h.checkValidity()?h.maxLength>=0?b=h.maxLength>=h.value.length:b=!0:b=!1,!b));)h=s.nextNode();b?a==="valid"&&i.add(e):a==="invalid"&&i.add(e)}break}case"in-range":case"out-of-range":{const t=[...c.KEY_INPUT_DATE,"number","range"],s=e.getAttribute("type");if(l==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&t.includes(s)){const h=e.validity.rangeUnderflow||e.validity.rangeOverflow;(a==="out-of-range"&&h||a==="in-range"&&!h&&(e.hasAttribute("min")||e.hasAttribute("max")||s==="range"))&&i.add(e)}break}case"required":case"optional":{let t;if(l==="select"||l==="textarea")t=e;else if(l==="input")if(e.hasAttribute("type")){const s=[...c.KEY_INPUT_EDIT,"checkbox","file","radio"],h=e.getAttribute("type");s.includes(h)&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required")?a==="required"&&i.add(e):a==="optional"&&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,c.SHOW_ALL);let s=t.firstChild(),h;for(;s&&(h=s.nodeType!==c.ELEMENT_NODE&&s.nodeType!==c.TEXT_NODE,!!h);)s=t.nextSibling();h&&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")||l.includes("-")?(0,N.isCustomElement)(e)&&i.add(e):(e instanceof this.#a.HTMLElement||e instanceof this.#a.SVGElement)&&i.add(e);break}case"popover-open":{e.popover&&(0,N.isVisible)(e)&&i.add(e);break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d)throw new DOMException(`Unsupported pseudo-element ::${a}`,c.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)throw new DOMException(`Unsupported pseudo-class :${a}`,c.NOT_SUPPORTED_ERR);break}default:if(a.startsWith("-webkit-")){if(d)throw new DOMException(`Unsupported pseudo-class :${a}`,c.NOT_SUPPORTED_ERR)}else if(!u)throw new DOMException(`Unknown pseudo-class :${a}`,c.SYNTAX_ERR)}return i}_matchShadowHostPseudoClass(r,e){const{children:o,name:n}=r;let a;if(Array.isArray(o)){const{branches:l}=(0,g.walkAST)(o[0]),[f]=l,[...u]=f,{host:d}=e;if(n==="host"){let i;for(const t of u){const{type:s}=t;if(s===c.COMBINATOR){const h=(0,g.generateCSS)(r);throw new DOMException(`Invalid selector ${h}`,c.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}if(i)return e}else if(n==="host-context"){let i=d,t;for(;i;){for(const s of u){const{type:h}=s;if(h===c.COMBINATOR){const b=(0,g.generateCSS)(r);throw new DOMException(`Invalid selector ${b}`,c.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}if(t)return e}}else{if(n==="host")return e;throw new DOMException(`Invalid selector :${n}`,c.SYNTAX_ERR)}return a??null}_matchSelector(r,e,o={}){const{type:n}=r,a=new Set;if(r.name===c.EMPTY)return a;const l=(0,g.unescapeSelector)(r.name);if(typeof l=="string"&&l!==r.name&&(r.name=l),e.nodeType===c.ELEMENT_NODE)switch(n){case c.PS_ELEMENT_SELECTOR:{this.#h.matchPseudoElementSelector(l,o);break}case c.ID_SELECTOR:{e.id===l&&a.add(e);break}case c.CLASS_SELECTOR:{e.classList.contains(l)&&a.add(e);break}case c.PS_CLASS_SELECTOR:return this._matchPseudoClassSelector(r,e,o);default:{const f=this.#h.matchSelector(r,e,o,!0);f&&a.add(f)}}else if(this.#u&&n===c.PS_CLASS_SELECTOR&&e.nodeType===c.DOCUMENT_FRAGMENT_NODE){if(c.KEY_LOGICAL.includes(l))return o.isShadowRoot=!0,this._matchPseudoClassSelector(r,e,o);if(l==="host"||l==="host-context"){const f=this._matchShadowHostPseudoClass(r,e,o);f&&(this.#_=!0,a.add(f))}}return a}_matchLeaves(r,e,o){let n,a;if(this.#c?a=this.#b.get(r):a=this.#N.get(r),a&&a.has(e)){const{matched:l}=a.get(e);n=l}if(typeof n!="boolean"){let l=!0;const f=[...c.KEY_FORM_FOCUS,"fieldset","form"],u=["any-link","defined","dir","link"];e.nodeType===c.ELEMENT_NODE&&f.includes(e.localName)&&(l=!1);for(const d of r){switch(d.type){case c.ATTR_SELECTOR:case c.ID_SELECTOR:{l=!1;break}case c.PS_CLASS_SELECTOR:{u.includes(d.name)&&(l=!1);break}default:}if(n=this._matchSelector(d,e,o).has(e),!n)break}l&&(a||(a=new WeakMap),a.set(e,{matched:n}),this.#c?this.#b.set(r,a):this.#N.set(r,a))}return!!n}_matchHTMLCollection(r,e){const{compound:o,filterLeaves:n}=e,a=new Set,l=r.length;if(l)if(o)for(let f=0;f<l;f++){const u=r[f];this._matchLeaves(n,u,e)&&a.add(u)}else{const f=[].slice.call(r);return new Set(f)}return a}_findDescendantNodes(r,e,o){const[n,...a]=r,l=a.length>0,{type:f}=n,u=(0,g.unescapeSelector)(n.name);typeof u=="string"&&u!==n.name&&(n.name=u);let d=new Set,i=!1;if(this.#u)i=!0;else switch(f){case c.PS_ELEMENT_SELECTOR:{this.#h.matchPseudoElementSelector(u,o);break}case c.ID_SELECTOR:{if(this.#s.nodeType===c.ELEMENT_NODE)i=!0;else{const t=this.#s.getElementById(u);t&&t!==e&&e.contains(t)&&(l?this._matchLeaves(a,t,o)&&d.add(t):d.add(t))}break}case c.CLASS_SELECTOR:{const t=e.getElementsByClassName(u);d=this._matchHTMLCollection(t,{compound:l,filterLeaves:a});break}case c.TYPE_SELECTOR:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(u)){const t=e.getElementsByTagName(u);d=this._matchHTMLCollection(t,{compound:l,filterLeaves:a})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(r,e,o){const{combo:n,leaves:a}=r,{name:l}=n,{parentNode:f}=e,{dir:u}=o,d=new Set;if(u===v)switch(l){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(a,i,o)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,N.traverseNode)(e,i);for(t=i.nextSibling();t;)this._matchLeaves(a,t,o)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=(0,N.traverseNode)(e,i);for(t=i.firstChild();t;)this._matchLeaves(a,t,o)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(a,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let h=(0,N.traverseNode)(e,s);for(h=s.nextNode();h&&e.contains(h);)this._matchLeaves(a,h,o)&&d.add(h),h=s.nextNode()}}}else switch(l){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(a,i,o)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,N.traverseNode)(f,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(a,t,o)&&d.add(t),t=i.nextSibling()}break}case">":{f&&this._matchLeaves(a,f,o)&&d.add(f);break}case" ":default:{const i=[];let t=f;for(;t;)this._matchLeaves(a,t,o)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(r,e){const o=this.#m;let n=(0,N.traverseNode)(e,o),a;if(n)for((n.nodeType!==c.ELEMENT_NODE||n===e&&n!==this.#s)&&(n=o.nextNode());n;){if(this._matchLeaves(r,n,{warn:this.#i})){a=n;break}n=o.nextNode()}return a??null}_matchSelf(r){const e=[],o=this._matchLeaves(r,this.#e,{warn:this.#i});let n=!1;return o&&(e.push(this.#e),n=!0),[e,n]}_findLineal(r,e){const{complex:o}=e,n=[];let a=this._matchLeaves(r,this.#e,{warn:this.#i}),l=!1;if(a&&(n.push(this.#e),l=!0),!a||o){let f=this.#e.parentNode;for(;f&&(a=this._matchLeaves(r,f,{warn:this.#i}),a&&(n.push(f),l=!0),f.parentNode);)f=f.parentNode}return[n,l]}_findFirst(r){const e=[],o=this._findNode(r,this.#e);let n=!1;return o&&(e.push(o),n=!0),[e,n]}_findFromHTMLCollection(r,e){const{complex:o,compound:n,filterLeaves:a,targetType:l}=e;let f=[],u=!1,d=!1;const i=r.length;if(i)if(this.#e.nodeType===c.ELEMENT_NODE)for(let t=0;t<i;t++){const s=r[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(n){if(this._matchLeaves(a,s,{warn:this.#i})&&(f.push(s),u=!0,l===c.TARGET_FIRST))break}else if(f.push(s),u=!0,l===c.TARGET_FIRST)break}}else if(o)if(n)for(let t=0;t<i;t++){const s=r[t];if(this._matchLeaves(a,s,{warn:this.#i})&&(f.push(s),u=!0,l===c.TARGET_FIRST))break}else f=[].slice.call(r),u=!0,d=!0;else if(n)for(let t=0;t<i;t++){const s=r[t];if(this._matchLeaves(a,s,{warn:this.#i})&&(f.push(s),u=!0,l===c.TARGET_FIRST))break}else f=[].slice.call(r),u=!0,d=!0;return[f,u,d]}_findEntryNodes(r,e,o){const{leaves:n}=r,[a,...l]=n,f=l.length>0,{name:u,type:d}=a;let i=[],t=!1,s=!1,h=!1;switch(d){case c.PS_ELEMENT_SELECTOR:{this.#h.matchPseudoElementSelector(u,{warn:this.#i});break}case c.ID_SELECTOR:{if(e===c.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===c.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:o});else if(e===c.TARGET_FIRST&&this.#s.nodeType!==c.ELEMENT_NODE){const b=this.#s.getElementById(u);b&&(f?this._matchLeaves(l,b,{warn:this.#i})&&(i.push(b),s=!0):(i.push(b),s=!0))}else e===c.TARGET_FIRST?[i,s]=this._findFirst(n):h=!0;break}case c.CLASS_SELECTOR:{if(e===c.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===c.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:o});else if(this.#s.nodeType===c.DOCUMENT_NODE){const b=this.#s.getElementsByClassName(u);b.length&&([i,s,t]=this._findFromHTMLCollection(b,{complex:o,compound:f,filterLeaves:l,targetType:e}))}else e===c.TARGET_FIRST?[i,s]=this._findFirst(n):h=!0;break}case c.TYPE_SELECTOR:{if(e===c.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===c.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:o});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===c.DOCUMENT_NODE&&!/[*|]/.test(u)){const b=this.#s.getElementsByTagName(u);b.length&&([i,s,t]=this._findFromHTMLCollection(b,{complex:o,compound:f,filterLeaves:l,targetType:e}))}else e===c.TARGET_FIRST?[i,s]=this._findFirst(n):h=!0;break}default:if(e!==c.TARGET_LINEAL&&(u==="host"||u==="host-context")){if(this.#u&&this.#e.nodeType===c.DOCUMENT_FRAGMENT_NODE){const b=this._matchShadowHostPseudoClass(a,this.#e);b&&(i.push(b),s=!0)}}else e===c.TARGET_SELF?[i,s]=this._matchSelf(n):e===c.TARGET_LINEAL?[i,s]=this._findLineal(n,{complex:o}):e===c.TARGET_FIRST?[i,s]=this._findFirst(n):h=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:h}}_collectNodes(r){const e=this.#l.values();if(r===c.TARGET_ALL||r===c.TARGET_FIRST){const o=new Set;let n=0;for(const{branch:a}of e){const l=a.length,f=l>1,u=a[0];let d,i;if(f){const{combo:p,leaves:[{name:w,type:k}]}=u,_=a[l-1],{leaves:[{name:y,type:L}]}=_;if(L===c.PS_ELEMENT_SELECTOR||L===c.ID_SELECTOR)d=S,i=_;else if(k===c.PS_ELEMENT_SELECTOR||k===c.ID_SELECTOR)d=v,i=u;else if(r===c.TARGET_ALL)if(w==="*"&&k===c.TYPE_SELECTOR)d=S,i=_;else if(y==="*"&&L===c.TYPE_SELECTOR)d=v,i=u;else if(l===2){const{name:E}=p;E==="+"||E==="~"?(d=S,i=_):(d=v,i=u)}else d=v,i=u;else if(w==="*"&&k===c.TYPE_SELECTOR)d=S,i=_;else if(y==="*"&&L===c.TYPE_SELECTOR)d=v,i=u;else{let E;for(const{combo:T,leaves:[M]}of a){const{name:R,type:I}=M;if(I===c.PS_CLASS_SELECTOR&&R==="dir"){E=!1;break}if(!E&&T){const{name:A}=T;(A==="+"||A==="~")&&(E=!0)}}E?(d=v,i=u):(d=S,i=_)}}else d=S,i=u;const{collected:t,compound:s,filtered:h,nodes:b,pending:m}=this._findEntryNodes(i,r,f);b.length?(this.#l[n].find=!0,this.#d[n]=b):m&&o.add(new Map([["index",n],["twig",i]])),this.#l[n].collected=t,this.#l[n].dir=d,this.#l[n].filtered=h||!s,n++}if(o.size){let a,l;this.#e!==this.#s&&this.#e.nodeType===c.ELEMENT_NODE?(a=this.#e,l=this.#m):(a=this.#s,l=this.#o);let f=(0,N.traverseNode)(a,l);for(;f;){let u=!1;if(this.#e.nodeType===c.ELEMENT_NODE?f===this.#e?u=!0:u=this.#e.contains(f):u=!0,u)for(const d of o){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,f,{warn:this.#i})){const s=d.get("index");this.#l[s].filtered=!0,this.#l[s].find=!0,this.#d[s].push(f)}}f!==l.currentNode&&(f=(0,N.traverseNode)(f,l)),f=l.nextNode()}}}else{let o=0;for(const{branch:n}of e){const a=n[n.length-1],l=n.length>1,{compound:f,filtered:u,nodes:d}=this._findEntryNodes(a,r,l);d.length&&(this.#l[o].find=!0,this.#d[o]=d),this.#l[o].dir=S,this.#l[o].filtered=u||!f,o++}}return[this.#l,this.#d]}_getCombinedNodes(r,e,o){const n=[];for(const a of e){const l=this._matchCombinator(r,a,{dir:o,warn:this.#i});l.size&&n.push(...l)}return n.length?new Set(n):new Set}_matchNodeNext(r,e,o){const{combo:n,index:a}=o,{combo:l,leaves:f}=r[a],u={combo:n,leaves:f},d=this._getCombinedNodes(u,e,v);let i;if(d.size)if(a===r.length-1){const[t]=(0,N.sortNodes)(d);i=t}else i=this._matchNodeNext(r,d,{combo:l,index:a+1});return i??null}_matchNodePrev(r,e,o){const{index:n}=o,a=r[n],l=new Set([e]),f=this._getCombinedNodes(a,l,S);let u;if(f.size){if(n===0)u=e;else for(const d of f)if(this._matchNodePrev(r,d,{index:n-1}))return e}return u??null}find(r){(r===c.TARGET_ALL||r===c.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],o]=this._collectNodes(r),n=e.length;let a,l=new Set;for(let f=0;f<n;f++){const{branch:u,collected:d,dir:i,find:t}=e[f],s=u.length;if(s&&t){const h=o[f],b=h.length,m=s-1;if(m===0)if((r===c.TARGET_ALL||r===c.TARGET_FIRST)&&this.#e.nodeType===c.ELEMENT_NODE)for(let p=0;p<b;p++){const w=h[p];if(w!==this.#e&&this.#e.contains(w)&&(l.add(w),r===c.TARGET_FIRST))break}else if(r===c.TARGET_ALL)if(l.size){const p=[...l];l=new Set([...p,...h]),a=!0}else l=new Set(h);else{const[p]=h;l.add(p)}else if(r===c.TARGET_ALL)if(i===v){let{combo:p}=u[0];for(const w of h){let k=new Set([w]);for(let _=1;_<s;_++){const{combo:y,leaves:L}=u[_],E={combo:p,leaves:L};if(k=this._getCombinedNodes(E,k,i),k.size)if(_===m)if(l.size){const T=[...l];l=new Set([...T,...k]),a=!0}else l=k;else p=y;else break}}}else for(const p of h){let w=new Set([p]);for(let k=m-1;k>=0;k--){const _=u[k];if(w=this._getCombinedNodes(_,w,i),w.size)k===0&&(l.add(p),s>1&&l.size>1&&(a=!0));else break}}else if(r===c.TARGET_FIRST&&i===v){const{combo:p}=u[0];let w;for(const k of h)if(w=this._matchNodeNext(u,new Set([k]),{combo:p,index:1}),w){l.add(w);break}if(!w&&!d){const{leaves:k}=u[0],[_]=h;let y=this._findNode(k,_);for(;y;){if(w=this._matchNodeNext(u,new Set([y]),{combo:p,index:1}),w){l.add(w);break}y=this._findNode(k,y)}}}else{let p;for(const w of h)if(p=this._matchNodePrev(u,w,{index:m-1}),p){l.add(w);break}if(!p&&!d&&r===c.TARGET_FIRST){const{leaves:w}=u[m],[k]=h;let _=this._findNode(w,k);for(;_;){if(p=this._matchNodePrev(u,_,{index:m-1}),p){l.add(_);break}_=this._findNode(w,_)}}}}}return r===c.TARGET_FIRST?(l.delete(this.#e),l.size>1&&(l=new Set((0,N.sortNodes)(l)))):r===c.TARGET_ALL&&(l.delete(this.#e),a&&l.size>1&&(l=new Set((0,N.sortNodes)(l)))),l}}0&&(module.exports={Finder});
2
2
  //# sourceMappingURL=finder.js.map