@asamuzakjp/dom-selector 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -29
- package/dist/cjs/js/constant.js +1 -1
- package/dist/cjs/js/constant.js.map +3 -3
- package/dist/cjs/js/finder.js +1 -1
- package/dist/cjs/js/finder.js.map +3 -3
- package/dist/cjs/js/matcher.js +1 -1
- package/dist/cjs/js/matcher.js.map +3 -3
- package/dist/cjs/js/parser.js +2 -2
- package/dist/cjs/js/parser.js.map +3 -3
- package/dist/cjs/js/utility.js +1 -1
- package/dist/cjs/js/utility.js.map +3 -3
- package/package.json +13 -12
- package/src/js/constant.js +1 -0
- package/src/js/finder.js +68 -20
- package/src/js/matcher.js +2 -5
- package/src/js/parser.js +28 -7
- package/src/js/utility.js +37 -56
- package/types/js/constant.d.ts +1 -0
- package/types/js/utility.d.ts +1 -2
package/README.md
CHANGED
|
@@ -240,12 +240,15 @@ const dom = new JSDOM('', {
|
|
|
240
240
|
|F \|\| E|Unsupported| |
|
|
241
241
|
|E:nth‑col(n)|Unsupported| |
|
|
242
242
|
|E:nth‑last‑col(n)|Unsupported| |
|
|
243
|
-
|E:host|✓| |
|
|
244
|
-
|E:host(s)|✓| |
|
|
245
|
-
|E:host‑context(s)|✓| |
|
|
246
243
|
|E:popover-open|✓| |
|
|
247
244
|
|E:state(v)|✓|*1|
|
|
248
|
-
|
|
245
|
+
|:host|✓| |
|
|
246
|
+
|:host(s)|✓| |
|
|
247
|
+
|:host‑context(s)|✓| |
|
|
248
|
+
|:host(:state(v))|✓|*1|
|
|
249
|
+
|:host:has(rs1, rs2, ...)|✓| |
|
|
250
|
+
|:host(s):has(rs1, rs2, ...)|✓| |
|
|
251
|
+
|:host‑context(s):has(rs1, rs2, ...)|✓| |
|
|
249
252
|
|
|
250
253
|
*1: `ElementInternals.states`, i.e. `CustomStateSet`, is not implemented in jsdom, so you need to apply a patch in the custom element constructor.
|
|
251
254
|
|
|
@@ -286,45 +289,45 @@ See [benchmark](https://github.com/asamuzaK/domSelector/actions/workflows/benchm
|
|
|
286
289
|
|
|
287
290
|
### matches()
|
|
288
291
|
|
|
289
|
-
|Selector|jsdom v25.0.
|
|
292
|
+
|Selector|jsdom v25.0.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
|
|
290
293
|
|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|
|
291
|
-
|simple selector:<br>`matches('.content')`|
|
|
292
|
-
|compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|
|
|
293
|
-
|compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|
|
|
294
|
-
|compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|
|
|
295
|
-
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|
|
|
296
|
-
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,
|
|
297
|
-
|complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|
|
|
294
|
+
|simple selector:<br>`matches('.content')`|970,195 ops/sec ±1.09%|6,434,629 ops/sec ±0.72%|8,542 ops/sec ±0.55%|759,550 ops/sec ±0.36%|happydom is the fastest and 8.5 times faster than patched-jsdom. jsdom is 1.3 times faster than patched-jsdom.|
|
|
295
|
+
|compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|577,536 ops/sec ±1.66%|5,548,367 ops/sec ±1.02%|8,290 ops/sec ±0.73%|418,490 ops/sec ±0.46%|happydom is the fastest and 13.3 times faster than patched-jsdom. jsdom is 1.4 times faster than patched-jsdom.|
|
|
296
|
+
|compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|4,987,842 ops/sec ±1.99%|F|88,901 ops/sec ±1.31%|happydom is the fastest and 56.1 times faster than patched-jsdom.|
|
|
297
|
+
|compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|463,747 ops/sec ±1.81%|5,014,172 ops/sec ±0.53%|8,200 ops/sec ±0.91%|334,734 ops/sec ±1.63%|happydom is the fastest and 15.0 times faster than patched-jsdom. jsdom is 1.4 times faster than patched-jsdom.|
|
|
298
|
+
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|145,755 ops/sec ±2.56%|F|5,309 ops/sec ±1.61%|122,806 ops/sec ±0.33%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|
|
299
|
+
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,372 ops/sec ±0.85%|18,921 ops/sec ±1.80%|patched-jsdom is the fastest.|
|
|
300
|
+
|complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|394,756 ops/sec ±1.62%|F|5,688 ops/sec ±0.65%|316,784 ops/sec ±1.25%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|
|
298
301
|
|
|
299
302
|
### closest()
|
|
300
303
|
|
|
301
|
-
|Selector|jsdom v25.0.
|
|
304
|
+
|Selector|jsdom v25.0.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
|
|
302
305
|
|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|
|
303
|
-
|simple selector:<br>`closest('.container')`|
|
|
304
|
-
|compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|
|
|
305
|
-
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|
|
|
306
|
-
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,
|
|
307
|
-
|complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|
|
|
306
|
+
|simple selector:<br>`closest('.container')`|364,468 ops/sec ±0.84%|2,002,932 ops/sec ±0.94%|8,666 ops/sec ±0.76%|328,519 ops/sec ±1.61%|happydom is the fastest and 6.1 times faster than patched-jsdom. jsdom is 1.1 times faster than patched-jsdom.|
|
|
307
|
+
|compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|130,479 ops/sec ±1.60%|F|8,186 ops/sec ±0.71%|118,992 ops/sec ±1.59%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|
|
308
|
+
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|139,006 ops/sec ±1.51%|F|5,315 ops/sec ±0.71%|114,474 ops/sec ±1.29%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|
|
309
|
+
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,228 ops/sec ±0.40%|15,264 ops/sec ±1.96%|patched-jsdom is the fastest.|
|
|
310
|
+
|complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|186,594 ops/sec ±1.66%|1,735,355 ops/sec ±1.03%|5,608 ops/sec ±0.72%|166,431 ops/sec ±0.24%|happydom is the fastest and 10.4 times faster than patched-jsdom. jsdom is 1.1 times faster than patched-jsdom.|
|
|
308
311
|
|
|
309
312
|
### querySelector()
|
|
310
313
|
|
|
311
314
|
|Selector|jsdom v25.0.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
|
|
312
315
|
|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|
|
313
|
-
|simple selector:<br>`querySelector('.content')`|
|
|
314
|
-
|compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|9,
|
|
315
|
-
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|
|
|
316
|
-
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|1,
|
|
317
|
-
|complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|3,
|
|
316
|
+
|simple selector:<br>`querySelector('.content')`|29,510 ops/sec ±0.88%|3,177,172 ops/sec ±1.25%|10,026 ops/sec ±0.83%|29,689 ops/sec ±1.43%|happydom is the fastest and 107.0 times faster than patched-jsdom. patched-jsdom is 1.0 times faster than jsdom.|
|
|
317
|
+
|compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|9,909 ops/sec ±1.42%|2,754,183 ops/sec ±1.03%|9,476 ops/sec ±0.59%|9,355 ops/sec ±1.40%|happydom is the fastest and 294.4 times faster than patched-jsdom. jsdom is 1.1 times faster than patched-jsdom.|
|
|
318
|
+
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|217 ops/sec ±1.98%|F|1,402 ops/sec ±2.03%|444 ops/sec ±1.64%|linkedom is the fastest and 3.2 times faster than patched-jsdom. patched-jsdom is 2.0 times faster than jsdom.|
|
|
319
|
+
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|1,619 ops/sec ±0.62%|320 ops/sec ±1.49%|linkedom is the fastest and 5.1 times faster than patched-jsdom.|
|
|
320
|
+
|complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|3,180 ops/sec ±1.84%|F|9,415 ops/sec ±0.69%|208,961 ops/sec ±2.48%|patched-jsdom is the fastest. patched-jsdom is 65.7 times faster than jsdom.|
|
|
318
321
|
|
|
319
322
|
### querySelectorAll()
|
|
320
323
|
|
|
321
|
-
|Selector|jsdom v25.0.
|
|
324
|
+
|Selector|jsdom v25.0.1 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
|
|
322
325
|
|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|
|
323
|
-
|simple selector:<br>`querySelectorAll('.content')`|
|
|
324
|
-
|compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|
|
|
325
|
-
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|
|
|
326
|
-
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|
|
|
327
|
-
|complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|
|
|
326
|
+
|simple selector:<br>`querySelectorAll('.content')`|2,892 ops/sec ±1.11%|5,500,951 ops/sec ±0.94%|1,218 ops/sec ±0.25%|3,244 ops/sec ±1.25%|happydom is the fastest and 1695.8 times faster than patched-jsdom. patched-jsdom is 1.1 times faster than jsdom.|
|
|
327
|
+
|compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|964 ops/sec ±1.18%|4,385,931 ops/sec ±0.80%|1,193 ops/sec ±1.17%|,020 ops/sec ±0.14%|happydom is the fastest and 4299.2 times faster than patched-jsdom. patched-jsdom is 1.1 times faster than jsdom.|
|
|
328
|
+
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|218 ops/sec ±1.53%|F|429 ops/sec ±1.71%|479 ops/sec ±1.20%|patched-jsdom is the fastest. patched-jsdom is 2.2 times faster than jsdom.|
|
|
329
|
+
|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.18%|332 ops/sec ±1.21%|linkedom is the fastest and 1.4 times faster than patched-jsdom.|
|
|
330
|
+
|complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|302 ops/sec ±1.50%|F|542 ops/sec ±0.33%|795 ops/sec ±3.24%|patched-jsdom is the fastest. patched-jsdom is 2.6 times faster than jsdom.|
|
|
328
331
|
|
|
329
332
|
|
|
330
333
|
## Acknowledgments
|
package/dist/cjs/js/constant.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var E=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var F=(o,t)=>{for(var n in t)E(o,n,{get:t[n],enumerable:!0})},M=(o,t,n,L)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of a(t))!i.call(o,s)&&s!==n&&E(o,s,{get:()=>t[s],enumerable:!(L=R(t,s))||L.enumerable});return o};var U=o=>M(E({},"__esModule",{value:!0}),o);var Gt={};F(Gt,{ALPHA_NUM:()=>I,ANB:()=>A,ATTR_SELECTOR:()=>b,BIT_01:()=>g,BIT_02:()=>Z,BIT_04:()=>v,BIT_08:()=>q,BIT_16:()=>J,BIT_32:()=>Q,BIT_FFFF:()=>V,CHILD_IDX:()=>C,CLASS_SELECTOR:()=>d,COMBINATOR:()=>G,COMBO:()=>T,COMPLEX:()=>_,COMPLEX_L:()=>S,COMPOUND:()=>c,COMPOUND_A:()=>O,COMPOUND_B:()=>N,COMPOUND_I:()=>Pt,DESCEND:()=>Dt,DIGIT:()=>x,DOCUMENT_FRAGMENT_NODE:()=>Et,DOCUMENT_NODE:()=>xt,DOCUMENT_POSITION_CONTAINED_BY:()=>_t,DOCUMENT_POSITION_CONTAINS:()=>Tt,DOCUMENT_POSITION_PRECEDING:()=>pt,DUO:()=>tt,ELEMENT_NODE:()=>ct,HEX:()=>ot,HYPHEN:()=>et,IDENT:()=>Y,ID_SELECTOR:()=>f,KEY_FORM_FOCUS:()=>at,KEY_INPUT_BUTTON:()=>it,KEY_INPUT_DATE:()=>P,KEY_INPUT_EDIT:()=>Ft,KEY_INPUT_LTR:()=>Mt,KEY_INPUT_TEXT:()=>$,KEY_LOGICAL:()=>Ut,KEY_MODIFIER:()=>bt,KEY_SHADOW_HOST:()=>dt,LANG_PART:()=>Ct,LOGICAL_COMPLEX:()=>$t,LOGICAL_COMPOUND:()=>Rt,NESTED_LOGICAL_A:()=>l,NESTED_LOGICAL_B:()=>D,NOT_SUPPORTED_ERR:()=>m,NTH:()=>B,N_TH:()=>lt,OPERATOR:()=>h,PSEUDO_CLASS:()=>At,PS_CLASS_SELECTOR:()=>H,PS_ELEMENT_SELECTOR:()=>u,SELECTOR:()=>y,SHOW_ALL:()=>Ot,SHOW_DOCUMENT:()=>Nt,SHOW_DOCUMENT_FRAGMENT:()=>St,SHOW_ELEMENT:()=>Lt,STRING:()=>z,SUB_TYPE:()=>r,SYNTAX_ERR:()=>K,TAG_TYPE:()=>e,TAG_TYPE_I:()=>p,TARGET_ALL:()=>j,TARGET_FIRST:()=>k,TARGET_LINEAL:()=>X,TARGET_SELF:()=>w,TEXT_NODE:()=>nt,TYPE_FROM:()=>st,TYPE_SELECTOR:()=>W,TYPE_TO:()=>rt,WALKER_FILTER:()=>It});module.exports=U(Gt);const b="AttributeSelector",d="ClassSelector",G="Combinator",Y="Identifier",f="IdSelector",m="NotSupportedError",B="Nth",h="Operator",H="PseudoClassSelector",u="PseudoElementSelector",y="Selector",z="String",K="SyntaxError",j="all",k="first",X="lineal",w="self",W="TypeSelector",g=1,Z=2,v=4,q=8,J=16,Q=32,V=65535,tt=2,ot=16,et=45,st=8,rt=-1,ct=1,nt=3,xt=9,Et=11,pt=2,Tt=8,_t=16,Ot=4294967295,Nt=256,St=1024,Lt=1,It=1281,I="[A-Z\\d]+",C="(?:first|last|only)-(?:child|of-type)",x="(?:0|[1-9]\\d*)",Ct=`(?:-${I})*`,At=`(?:any-)?link|${C}|checked|empty|indeterminate|root|target|visited`,A=`[+-]?(?:${x}n?|n)|(?:[+-]?${x})?n\\s*[+-]\\s*${x}`,lt=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${A})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",p="\\*|[A-Z][\\w-]*",c=`(?:${e}|(?:${e})?(?:${r})+)`,T="\\s?[\\s>~+]\\s?",_=`${c}(?:${T}${c})*`,Dt="\\s?[\\s>]\\s?",l=`:is\\(\\s*${c}(?:\\s*,\\s*${c})*\\s*\\)`,D=`:is\\(\\s*${_}(?:\\s*,\\s*${_})*\\s*\\)`,O=`(?:${e}|(?:${e})?(?:${r}|${l})+)`,N=`(?:${e}|(?:${e})?(?:${r}|${D})+)`,Pt=`(?:${p}|(?:${p})?(?:${r})+)`,S=`${N}(?:${T}${N})*`,$t=`(?:is|not)\\(\\s*${S}(?:\\s*,\\s*${S})*\\s*\\)`,Rt=`(?:is|not)\\(\\s*${O}(?:\\s*,\\s*${O})*\\s*\\)`,at=Object.freeze(["button","input","select","textarea"]),it=Object.freeze(["button","reset","submit"]),P=Object.freeze(["date","datetime-local","month","time","week"]),$=Object.freeze(["email","password","search","tel","text","url"]),Ft=Object.freeze([...P,...$,"number"]),Mt=Object.freeze(["checkbox","color","date","image","number","range","radio","time"]),Ut=Object.freeze(["has","is","not","where"]),bt=Object.freeze(["Alt","AltGraph","CapsLock","Control","Fn","FnLock","Hyper","Meta","NumLock","ScrollLock","Shift","Super","Symbol","SymbolLock"]),dt=Object.freeze(["host","host-context"]);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,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,KEY_MODIFIER,KEY_SHADOW_HOST,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,OPERATOR,PSEUDO_CLASS,PS_CLASS_SELECTOR,PS_ELEMENT_SELECTOR,SELECTOR,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_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 IDENT = 'Identifier';\nexport const ID_SELECTOR = 'IdSelector';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const OPERATOR = 'Operator';\nexport const PS_CLASS_SELECTOR = 'PseudoClassSelector';\nexport const PS_ELEMENT_SELECTOR = 'PseudoElementSelector';\nexport const SELECTOR = 'Selector';\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 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']);\nexport const KEY_MODIFIER = Object.freeze([\n 'Alt', 'AltGraph', 'CapsLock', 'Control', 'Fn', 'FnLock', 'Hyper', 'Meta',\n 'NumLock', 'ScrollLock', 'Shift', 'Super', 'Symbol', 'SymbolLock'\n]);\n"],
|
|
5
|
-
"mappings": "4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAAAE,EAAA,QAAAC,EAAA,kBAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,aAAAC,EAAA,cAAAC,EAAA,mBAAAC,EAAA,eAAAC,EAAA,UAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,eAAAC,GAAA,YAAAC,GAAA,UAAAC,EAAA,2BAAAC,GAAA,kBAAAC,GAAA,mCAAAC,GAAA,+BAAAC,GAAA,gCAAAC,GAAA,QAAAC,GAAA,iBAAAC,GAAA,QAAAC,GAAA,WAAAC,GAAA,UAAAC,EAAA,gBAAAC,EAAA,mBAAAC,GAAA,qBAAAC,GAAA,mBAAAC,EAAA,mBAAAC,GAAA,kBAAAC,GAAA,mBAAAC,EAAA,gBAAAC,GAAA,iBAAAC,GAAA,cAAAC,GAAA,oBAAAC,GAAA,qBAAAC,GAAA,qBAAAC,EAAA,qBAAAC,EAAA,sBAAAC,EAAA,QAAAC,EAAA,SAAAC,GAAA,aAAAC,EAAA,iBAAAC,GAAA,sBAAAC,EAAA,wBAAAC,EAAA,aAAAC,EAAA,aAAAC,GAAA,kBAAAC,GAAA,2BAAAC,GAAA,iBAAAC,GAAA,WAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,iBAAAC,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,cAAAC,GAAA,cAAAC,GAAA,kBAAAC,EAAA,YAAAC,GAAA,kBAAAC,KAAA,eAAAC,
|
|
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", "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", "KEY_MODIFIER", "LANG_PART", "LOGICAL_COMPLEX", "LOGICAL_COMPOUND", "NESTED_LOGICAL_A", "NESTED_LOGICAL_B", "NOT_SUPPORTED_ERR", "NTH", "N_TH", "OPERATOR", "PSEUDO_CLASS", "PS_CLASS_SELECTOR", "PS_ELEMENT_SELECTOR", "SELECTOR", "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_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 IDENT = 'Identifier';\nexport const ID_SELECTOR = 'IdSelector';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const OPERATOR = 'Operator';\nexport const PS_CLASS_SELECTOR = 'PseudoClassSelector';\nexport const PS_ELEMENT_SELECTOR = 'PseudoElementSelector';\nexport const SELECTOR = 'Selector';\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 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']);\nexport const KEY_MODIFIER = Object.freeze([\n 'Alt', 'AltGraph', 'CapsLock', 'Control', 'Fn', 'FnLock', 'Hyper', 'Meta',\n 'NumLock', 'ScrollLock', 'Shift', 'Super', 'Symbol', 'SymbolLock'\n]);\nexport const KEY_SHADOW_HOST = Object.freeze(['host', 'host-context']);\n"],
|
|
5
|
+
"mappings": "4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAAAE,EAAA,QAAAC,EAAA,kBAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,aAAAC,EAAA,cAAAC,EAAA,mBAAAC,EAAA,eAAAC,EAAA,UAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,eAAAC,GAAA,YAAAC,GAAA,UAAAC,EAAA,2BAAAC,GAAA,kBAAAC,GAAA,mCAAAC,GAAA,+BAAAC,GAAA,gCAAAC,GAAA,QAAAC,GAAA,iBAAAC,GAAA,QAAAC,GAAA,WAAAC,GAAA,UAAAC,EAAA,gBAAAC,EAAA,mBAAAC,GAAA,qBAAAC,GAAA,mBAAAC,EAAA,mBAAAC,GAAA,kBAAAC,GAAA,mBAAAC,EAAA,gBAAAC,GAAA,iBAAAC,GAAA,oBAAAC,GAAA,cAAAC,GAAA,oBAAAC,GAAA,qBAAAC,GAAA,qBAAAC,EAAA,qBAAAC,EAAA,sBAAAC,EAAA,QAAAC,EAAA,SAAAC,GAAA,aAAAC,EAAA,iBAAAC,GAAA,sBAAAC,EAAA,wBAAAC,EAAA,aAAAC,EAAA,aAAAC,GAAA,kBAAAC,GAAA,2BAAAC,GAAA,iBAAAC,GAAA,WAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,iBAAAC,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,cAAAC,GAAA,cAAAC,GAAA,kBAAAC,EAAA,YAAAC,GAAA,kBAAAC,KAAA,eAAAC,EAAA3E,IAKO,MAAMI,EAAgB,oBAChBS,EAAiB,gBACjBC,EAAa,aACbmB,EAAQ,aACRC,EAAc,aACde,EAAoB,oBACpBC,EAAM,MACNE,EAAW,WACXE,EAAoB,sBACpBC,EAAsB,wBACtBC,EAAW,WACXK,EAAS,SACTE,EAAa,cACbG,EAAa,MACbC,EAAe,QACfC,EAAgB,SAChBC,EAAc,OACdG,EAAgB,eAGhBnE,EAAS,EACTC,EAAS,EACTC,EAAS,EACTC,EAAS,EACTC,EAAS,GACTC,EAAS,GACTC,EAAW,MACXkB,GAAM,EACNE,GAAM,GACNC,GAAS,GACTuC,GAAY,EACZE,GAAU,GAGV3C,GAAe,EACfwC,GAAY,EACZ7C,GAAgB,EAChBD,GAAyB,GACzBI,GAA8B,EAC9BD,GAA6B,EAC7BD,GAAiC,GAGjC+B,GAAW,WACXC,GAAgB,IAChBC,GAAyB,KACzBC,GAAe,EACfc,GAAgB,KAGhBxE,EAAY,YACZU,EAAY,wCACZW,EAAQ,kBACRqB,GAAY,OAAO1C,CAAS,KAC5BmD,GACX,iBAAiBzC,CAAS,mDACfT,EACX,WAAWoB,CAAK,iBAAiBA,CAAK,kBAAkBA,CAAK,GAElD4B,GACX,qDAAqDhD,CAAG,WAE7C2D,EAAW,8BAEXE,EAAW,sBACXC,EAAa,mBACb/C,EAAW,MAAM8C,CAAQ,OAAOA,CAAQ,QAAQF,CAAQ,MACxD/C,EAAQ,mBACRC,EAAU,GAAGE,CAAQ,MAAMH,CAAK,GAAGG,CAAQ,KAC3CI,GAAU,iBACVyB,EACX,aAAa7B,CAAQ,eAAeA,CAAQ,YACjC8B,EACX,aAAahC,CAAO,eAAeA,CAAO,YAC/BG,EACX,MAAM6C,CAAQ,OAAOA,CAAQ,QAAQF,CAAQ,IAAIf,CAAgB,MACtD3B,EACX,MAAM4C,CAAQ,OAAOA,CAAQ,QAAQF,CAAQ,IAAId,CAAgB,MACtD3B,GACX,MAAM4C,CAAU,OAAOA,CAAU,QAAQH,CAAQ,MACtC7C,EAAY,GAAGG,CAAU,MAAML,CAAK,GAAGK,CAAU,KACjDyB,GACX,oBAAoB5B,CAAS,eAAeA,CAAS,YAC1C6B,GACX,oBAAoB3B,CAAU,eAAeA,CAAU,YAG5CgB,GACX,OAAO,OAAO,CAAC,SAAU,QAAS,SAAU,UAAU,CAAC,EAC5CC,GAAmB,OAAO,OAAO,CAAC,SAAU,QAAS,QAAQ,CAAC,EAC9DC,EACX,OAAO,OAAO,CAAC,OAAQ,iBAAkB,QAAS,OAAQ,MAAM,CAAC,EACtDG,EACX,OAAO,OAAO,CAAC,QAAS,WAAY,SAAU,MAAO,OAAQ,KAAK,CAAC,EACxDF,GACX,OAAO,OAAO,CAAC,GAAGD,EAAgB,GAAGG,EAAgB,QAAQ,CAAC,EACnDD,GAAgB,OAAO,OAAO,CACzC,WAAY,QAAS,OAAQ,QAAS,SAAU,QAAS,QAAS,MACpE,CAAC,EACYE,GAAc,OAAO,OAAO,CAAC,MAAO,KAAM,MAAO,OAAO,CAAC,EACzDC,GAAe,OAAO,OAAO,CACxC,MAAO,WAAY,WAAY,UAAW,KAAM,SAAU,QAAS,OACnE,UAAW,aAAc,QAAS,QAAS,SAAU,YACvD,CAAC,EACYC,GAAkB,OAAO,OAAO,CAAC,OAAQ,cAAc,CAAC",
|
|
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", "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", "KEY_MODIFIER", "KEY_SHADOW_HOST", "LANG_PART", "LOGICAL_COMPLEX", "LOGICAL_COMPOUND", "NESTED_LOGICAL_A", "NESTED_LOGICAL_B", "NOT_SUPPORTED_ERR", "NTH", "N_TH", "OPERATOR", "PSEUDO_CLASS", "PS_CLASS_SELECTOR", "PS_ELEMENT_SELECTOR", "SELECTOR", "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_SELECTOR", "TYPE_TO", "WALKER_FILTER", "__toCommonJS"]
|
|
7
7
|
}
|
package/dist/cjs/js/finder.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var A=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var F=(L,c)=>{for(var e in c)A(L,e,{get:c[e],enumerable:!0})},$=(L,c,e,o)=>{if(c&&typeof c=="object"||typeof c=="function")for(let a of P(c))!U.call(L,a)&&a!==e&&A(L,a,{get:()=>c[a],enumerable:!(o=D(c,a))||o.enumerable});return L};var W=L=>$(A({},"__esModule",{value:!0}),L);var H={};F(H,{Finder:()=>z});module.exports=W(H);var v=require("./matcher.js"),g=require("./parser.js"),N=require("./utility.js"),n=require("./constant.js");const E="next",S="prev";class z{#a;#r;#k;#t;#h;#c;#b;#o;#m;#n;#e;#d;#g;#p;#N;#s;#u;#_;#f;#w;#i;#l;constructor(c){this.#l=c,this.#r=new WeakMap,this.#h=new WeakMap,this.#m=new WeakMap,this.#N=new WeakMap,this.#c=null,this.#b=null,this.#n=null,this._registerEventListeners()}onError(c,e){if(!(e?.noexcept??this.#g))if(c instanceof DOMException||c instanceof this.#l.DOMException)if(c.name===n.NOT_SUPPORTED_ERR)this.#i&&console.warn(c.message);else throw new this.#l.DOMException(c.message,c.name);else throw c.name in this.#l?new this.#l[c.name](c.message):c}setup(c,e,o={}){const{noexcept:a,warn:l}=o;return this.#g=!!a,this.#i=!!l,this.#e=e,[this.#t,this.#s,this.#f]=(0,N.resolveContent)(e),this.#u=(0,N.isInShadowTree)(e),[this.#a,this.#d]=this._correspond(c),this.#m=new WeakMap,this.#w=new WeakMap,this.#_=null,this}_registerEventListeners(){const c={capture:!0,passive:!0},e=[],o=["focus","focusin"];for(const r of o)e.push(this.#l.addEventListener(r,f=>{this.#b=f},c));const a=["keydown","keyup"];for(const r of a)e.push(this.#l.addEventListener(r,f=>{const{key:u}=f;n.KEY_MODIFIER.includes(u)||(this.#c=f)},c));const l=["mouseover","mousedown","mouseup","click","mouseout"];for(const r of l)e.push(this.#l.addEventListener(r,f=>{this.#c=f},c));return e}_correspond(c){const e=[];this.#k=!1,this.#o=!1;let o;if(this.#h.has(this.#t)){const a=this.#h.get(this.#t);if(a&&a.has(`${c}`)){const l=a.get(`${c}`);o=l.ast,this.#k=l.descendant,this.#o=l.invalidate}}if(o){const a=o.length;for(let l=0;l<a;l++)o[l].collected=!1,o[l].dir=null,o[l].filtered=!1,o[l].find=!1,e[l]=[]}else{let a;try{a=(0,g.parseSelector)(c)}catch(m){this.onError(m)}const{branches:l,info:r}=(0,g.walkAST)(a),{hasHasPseudoFunc:f,hasLogicalPseudoFunc:u,hasNthChildOfSelector:h}=r;let i=f||!!(u&&h),t=!1,s=0;o=[];for(const[...m]of l){const b=[];let p=m.shift();if(p&&p.type!==n.COMBINATOR){const w=new Set;for(;p;){let k=p.name;if(p.type===n.COMBINATOR){const[_]=m;if(_.type===n.COMBINATOR)throw new DOMException(`Invalid selector ${c}`,n.SYNTAX_ERR);k==="+"||k==="~"?i=!0:t=!0,b.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(m.length)p=m.shift();else{b.push({combo:null,leaves:(0,g.sortAST)(w)}),w.clear();break}}}o.push({branch:b,collected:!1,dir:null,filtered:!1,find:!1}),e[s]=[],s++}let d;this.#h.has(this.#t)?d=this.#h.get(this.#t):d=new Map,d.set(`${c}`,{ast:o,descendant:t,invalidate:i}),this.#h.set(this.#t,d),this.#k=t,this.#o=i}return[o,e]}_createTreeWalker(c){let e;return this.#w.has(c)?e=this.#w.get(c):(e=this.#t.createTreeWalker(c,n.WALKER_FILTER),this.#w.set(c,e)),e}_prepareQuerySelectorWalker(){return this.#p=this._createTreeWalker(this.#e),this.#p}_collectNthChild(c,e,o){const{a,b:l,reverse:r,selector:f}=c,{parentNode:u}=e,h=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.#o||this.#r.set(f,i)}const{branches:t}=(0,g.walkAST)(f);i=t}if(u){const t=this.#f;let s=(0,N.traverseNode)(u,t);s=t.firstChild();let d=0;for(;s;)d++,s=t.nextSibling();const m=new Set;if(i)for(s=(0,N.traverseNode)(u,t),s=t.firstChild();s;){if((0,N.isVisible)(s)){let b;for(const p of i)if(b=this._matchLeaves(p,s,o),!b)break;b&&m.add(s)}s=t.nextSibling()}if(a===0){if(l>0&&l<=d){if(m.size){s=(0,N.traverseNode)(u,t),r?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(m.has(s)){if(b===l-1){h.add(s);break}b++}r?s=t.previousSibling():s=t.nextSibling()}}else if(!f){s=(0,N.traverseNode)(u,t),r?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(b===l-1){h.add(s);break}r?s=t.previousSibling():s=t.nextSibling(),b++}}}}else{let b=l-1;if(a>0)for(;b<0;)b+=a;if(b>=0&&b<d){s=(0,N.traverseNode)(u,t),r?s=t.lastChild():s=t.firstChild();let p=0,w=a>0?0:l-1;for(;s&&(s&&b>=0&&b<d);)m.size?m.has(s)&&(w===b&&(h.add(s),b+=a),a>0?w++:w--):p===b&&(f||h.add(s),b+=a),r?s=t.previousSibling():s=t.nextSibling(),p++}}if(r&&h.size>1){const b=[...h];return new Set(b.reverse())}}else if(e===this.#s&&a+l===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,o),t)break;t&&h.add(e)}else h.add(e);return h}_collectNthOfType(c,e){const{a:o,b:a,reverse:l}=c,{localName:r,namespaceURI:f,parentNode:u,prefix:h}=e,i=new Set;if(u){const t=this.#f;let s=(0,N.traverseNode)(u,t);s=t.firstChild();let d=0;for(;s;)d++,s=t.nextSibling();if(o===0){if(a>0&&a<=d){s=(0,N.traverseNode)(u,t),l?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){const{localName:b,namespaceURI:p,prefix:w}=s;if(b===r&&w===h&&p===f){if(m===a-1){i.add(s);break}m++}l?s=t.previousSibling():s=t.nextSibling()}}}else{let m=a-1;if(o>0)for(;m<0;)m+=o;if(m>=0&&m<d){s=(0,N.traverseNode)(u,t),l?s=t.lastChild():s=t.firstChild();let b=o>0?0:a-1;for(;s;){const{localName:p,namespaceURI:w,prefix:k}=s;if(p===r&&k===h&&w===f){if(b===m&&(i.add(s),m+=o),m<0||m>=d)break;o>0?b++:b--}l?s=t.previousSibling():s=t.nextSibling()}}}if(l&&i.size>1){const m=[...i];return new Set(m.reverse())}}else e===this.#s&&o+a===1&&i.add(e);return i}_matchAnPlusB(c,e,o,a){const{nth:{a:l,b:r,name:f},selector:u}=c,h=new Map;if(f?(f==="even"?(h.set("a",2),h.set("b",0)):f==="odd"&&(h.set("a",2),h.set("b",1)),o.indexOf("last")>-1&&h.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?h.set("a",l*1):h.set("a",0),typeof r=="string"&&/-?\d+/.test(r)?h.set("b",r*1):h.set("b",0),o.indexOf("last")>-1&&h.set("reverse",!0)),o==="nth-child"||o==="nth-last-child"){u&&h.set("selector",u);const i=Object.fromEntries(h);return this._collectNthChild(i,e,a)}else if(o==="nth-of-type"||o==="nth-last-of-type"){const i=Object.fromEntries(h);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(c,e,o){if(Array.isArray(c)&&c.length){const a=[...c],[l]=a,{type:r}=l;let f;r===n.COMBINATOR?f=a.shift():f={name:" ",type:n.COMBINATOR};const u=[];for(;a.length;){const[t]=a,{type:s}=t;if(s===n.COMBINATOR)break;u.push(a.shift())}const h={combo:f,leaves:u};o.dir=E;const i=this._matchCombinator(h,e,o);if(i.size){if(a.length){let t;for(const s of i)if(t=this._matchHasPseudoFunc(a,s,o),t)break;return!!t}return!0}return!1}return!1}_matchLogicalPseudoFunc(c,e,o){const{astName:a,branches:l,twigBranches:r}=c,{isShadowRoot:f}=o;if(a==="has"){let u;for(const h of l)if(u=this._matchHasPseudoFunc(h,e,o),u)break;return u?f?this.#_?e:null:e:null}else{if(f){for(const i of l)if(i.length>1)return null}o.forgive=a==="is"||a==="where";const u=r.length;let h;for(let i=0;i<u;i++){const t=r[i],s=t.length-1,{leaves:d}=t[s];if(h=this._matchLeaves(d,e,o),h&&s>0){let m=new Set([e]);for(let b=s-1;b>=0;b--){const p=t[b],w=[];o.dir=S;for(const k of m){const _=this._matchCombinator(p,k,o);_.size&&w.push(..._)}if(w.length)b===0?h=!0:m=new Set(w);else{h=!1;break}}}if(h)break}return a==="not"?h?null:e:h?e:null}}_matchPseudoClassSelector(c,e,o){const{children:a,name:l}=c,{localName:r,parentNode:f}=e,{forgive:u,warn:h=this.#i}=o,i=new Set;if(Array.isArray(a)&&n.KEY_LOGICAL.includes(l)){if(!a.length&&l!=="is"&&l!=="where"){const d=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${d}`,n.SYNTAX_ERR)}let t;if(this.#r.has(c))t=this.#r.get(c);else{const{branches:d}=(0,g.walkAST)(c);if(l==="has"){for(const m of a){const b=(0,g.findAST)(m,p=>n.KEY_LOGICAL.includes(p.name)&&(0,g.findAST)(p,w=>w.name==="has")?p:null);if(b){const p=b.name;if(p==="is"||p==="where")return i;{const w=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${w}`,n.SYNTAX_ERR)}}}t={astName:l,branches:d}}else{const m=[];for(const[...b]of d){const p=[],w=new Set;let k=b.shift();for(;k;)if(k.type===n.COMBINATOR?(p.push({combo:k,leaves:[...w]}),w.clear()):k&&w.add(k),b.length)k=b.shift();else{p.push({combo:null,leaves:[...w]}),w.clear();break}m.push(p)}t={astName:l,branches:d,twigBranches:m},this.#o||this.#r.set(c,t)}}const s=this._matchLogicalPseudoFunc(t,e,o);s&&i.add(s)}else if(Array.isArray(a))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){if(a.length!==1){const d=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${d}`,n.SYNTAX_ERR)}const[t]=a;return this._matchAnPlusB(t,e,l,o)}else switch(l){case"dir":{if(a.length!==1){const d=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${d}`,n.SYNTAX_ERR)}const[t]=a;(0,v.matchDirectionPseudoClass)(t,e)&&i.add(e);break}case"lang":{if(!a.length){const s=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${s}`,n.SYNTAX_ERR)}let t;for(const s of a)if(t=(0,v.matchLanguagePseudoClass)(s,e),t)break;t&&i.add(e);break}case"state":{if((0,N.isCustomElement)(e)){const[{value:t}]=a;if(t)if(e[t])i.add(e);else for(const s in e){const d=e[s];if(d instanceof this.#l.ElementInternals){d?.states?.has(t)&&i.add(e);break}}}break}case"current":case"nth-col":case"nth-last-col":{if(h)throw new DOMException(`Unsupported pseudo-class :${l}()`,n.NOT_SUPPORTED_ERR);break}case"host":case"host-context":break;case"contains":{if(h)throw new DOMException(`Unknown pseudo-class :${l}()`,n.NOT_SUPPORTED_ERR);break}default:if(!u)throw new DOMException(`Unknown pseudo-class :${l}()`,n.SYNTAX_ERR)}else switch(l){case"any-link":case"link":{(r==="a"||r==="area")&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if((r==="a"||r==="area")&&e.hasAttribute("href")){const{href:t,origin:s,pathname:d}=new URL(this.#t.URL),m=new URL(e.getAttribute("href"),t);m.origin===s&&m.pathname===d&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#c??{};/^(?:click|mouse(?:down|over|up))$/.test(s)&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:d}=this.#c??{};d==="mousedown"&&t&n.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 d=this.#t.getElementById(s);for(;d;){if(d===e){i.add(e);break}d=d.parentNode}}break}case"scope":{this.#e.nodeType===n.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 if(this.#b){const{relatedTarget:s,target:d}=this.#b;if(d===e)if((0,N.isFocusVisible)(s))t=!0;else if(this.#c){const{key:m,target:b,type:p}=this.#c;b===s?(this.#n===null||d===this.#n)&&(t=!0):m==="Tab"?(p==="keydown"&&b!==e||p==="keyup"&&b===e)&&(b===d?(this.#n===null||b===this.#n&&s===null)&&(t=!0):t=!0):m&&(p==="keydown"||p==="keyup")&&b===e&&(t=!0)}else(s===null||s===this.#n)&&(t=!0)}t?(this.#n=e,i.add(e)):this.#n===e&&(this.#n=null)}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":{(r==="details"||r==="dialog")&&(e.hasAttribute("open")?l==="open"&&i.add(e):l==="closed"&&i.add(e));break}case"disabled":case"enabled":{if([...n.KEY_FORM_FOCUS,"fieldset","optgroup","option"].includes(r)||(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 d=f;for(;d;)if(d.localName==="fieldset"&&(d.disabled||d.hasAttribute("disabled"))){const m=this.#f;let b=(0,N.traverseNode)(d,m);for(b=m.firstChild();b&&b.localName!=="legend";)b=m.nextSibling();b&&b.contains(e)||(s=!0);break}else{if(d.localName==="form")break;if(d.parentNode?.nodeType===n.ELEMENT_NODE){if(d.parentNode.localName==="form")break;d=d.parentNode}else break}}s?l==="disabled"&&i.add(e):l==="enabled"&&i.add(e)}break}case"read-only":case"read-write":{let t,s;switch(r){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")?t=!0:s=!0;break}case"input":{(!e.type||n.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?l==="read-only"&&i.add(e):l==="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;r==="textarea"?s=e:r==="input"&&(e.hasAttribute("type")?[...n.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&&r==="input"&&(t==="checkbox"||t==="radio")||e.selected&&r==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&r==="input"&&e.type==="checkbox"||r==="progress"&&!e.hasAttribute("value"))i.add(e);else if(r==="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 d=s.getElementsByTagName("input"),m=d.length;let b;for(let p=0;p<m;p++){const w=d[p];if(w.getAttribute("type")==="radio"&&(t?w.getAttribute("name")===t&&(b=!!w.checked):w.hasAttribute("name")||(b=!!w.checked),b))break}b||i.add(e)}break}case"default":{const t=["checkbox","radio"],s=["button","reset"],d=["image","submit"],m=e.getAttribute("type");if(r==="button"&&!(e.hasAttribute("type")&&s.includes(m))||r==="input"&&e.hasAttribute("type")&&d.includes(m)){let b=e.parentNode;for(;b&&b.localName!=="form";)b=b.parentNode;if(b){const p=this.#f;let w=(0,N.traverseNode)(b,p);for(w=p.firstChild();w&&b.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")&&d.includes(_)),y){w===e&&i.add(e);break}w=p.nextNode()}}}else(r==="input"&&e.hasAttribute("type")&&t.includes(m)&&e.hasAttribute("checked")||r==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":case"invalid":{const t=[...n.KEY_FORM_FOCUS,"form"];if(t.includes(r)){let s;e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&(s=!0):s=!0),s?l==="valid"&&i.add(e):l==="invalid"&&i.add(e)}else if(r==="fieldset"){const s=this.#f;let d=(0,N.traverseNode)(e,s);d=s.firstChild();let m;if(!d)m=!0;else for(;d&&e.contains(d)&&!(t.includes(d.localName)&&(d.checkValidity()?d.maxLength>=0?m=d.maxLength>=d.value.length:m=!0:m=!1,!m));)d=s.nextNode();m?l==="valid"&&i.add(e):l==="invalid"&&i.add(e)}break}case"in-range":case"out-of-range":{const t=[...n.KEY_INPUT_DATE,"number","range"],s=e.getAttribute("type");if(r==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&t.includes(s)){const d=e.validity.rangeUnderflow||e.validity.rangeOverflow;(l==="out-of-range"&&d||l==="in-range"&&!d&&(e.hasAttribute("min")||e.hasAttribute("max")||s==="range"))&&i.add(e)}break}case"required":case"optional":{let t;if(r==="select"||r==="textarea")t=e;else if(r==="input")if(e.hasAttribute("type")){const s=[...n.KEY_INPUT_EDIT,"checkbox","file","radio"],d=e.getAttribute("type");s.includes(d)&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required")?l==="required"&&i.add(e):l==="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,n.SHOW_ALL);let s=t.firstChild(),d;for(;s&&(d=s.nodeType!==n.ELEMENT_NODE&&s.nodeType!==n.TEXT_NODE,!!d);)s=t.nextSibling();d&&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")||r.includes("-")?(0,N.isCustomElement)(e)&&i.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.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(h)throw new DOMException(`Unsupported pseudo-element ::${l}`,n.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(h)throw new DOMException(`Unsupported pseudo-class :${l}`,n.NOT_SUPPORTED_ERR);break}default:if(l.startsWith("-webkit-")){if(h)throw new DOMException(`Unsupported pseudo-class :${l}`,n.NOT_SUPPORTED_ERR)}else if(!u)throw new DOMException(`Unknown pseudo-class :${l}`,n.SYNTAX_ERR)}return i}_matchShadowHostPseudoClass(c,e){const{children:o,name:a}=c;if(Array.isArray(o)){if(o.length!==1){const h=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${h}`,n.SYNTAX_ERR)}const{branches:l}=(0,g.walkAST)(o[0]),[r]=l,[...f]=r,{host:u}=e;if(a==="host"){let h;for(const i of f){const{type:t}=i;if(t===n.COMBINATOR){const s=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${s}`,n.SYNTAX_ERR)}if(h=this._matchSelector(i,u).has(u),!h)break}return h?e:null}else if(a==="host-context"){let h=u,i;for(;h;){for(const t of f){const{type:s}=t;if(s===n.COMBINATOR){const d=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${d}`,n.SYNTAX_ERR)}if(i=this._matchSelector(t,h).has(h),!i)break}if(i)break;h=h.parentNode}return i?e:null}throw new DOMException(`Invalid selector :${a}`,n.SYNTAX_ERR)}else{if(a==="host")return e;throw new DOMException(`Invalid selector :${a}`,n.SYNTAX_ERR)}}_matchSelector(c,e,o={}){const{type:a}=c,l=(0,g.unescapeSelector)(c.name),r=new Set;if(e.nodeType===n.ELEMENT_NODE)switch(a){case n.ATTR_SELECTOR:{(0,v.matchAttributeSelector)(c,e)&&r.add(e);break}case n.ID_SELECTOR:{e.id===l&&r.add(e);break}case n.CLASS_SELECTOR:{e.classList.contains(l)&&r.add(e);break}case n.PS_CLASS_SELECTOR:return this._matchPseudoClassSelector(c,e,o);case n.TYPE_SELECTOR:{(0,v.matchTypeSelector)(c,e,o)&&r.add(e);break}case n.PS_ELEMENT_SELECTOR:default:(0,v.matchPseudoElementSelector)(l,a,o)}else if(this.#u&&a===n.PS_CLASS_SELECTOR&&e.nodeType===n.DOCUMENT_FRAGMENT_NODE){if(n.KEY_LOGICAL.includes(l))return o.isShadowRoot=!0,this._matchPseudoClassSelector(c,e,o);if(l==="host"||l==="host-context"){const f=this._matchShadowHostPseudoClass(c,e,o);f&&(this.#_=!0,r.add(f))}}return r}_matchLeaves(c,e,o){let a;if(this.#o?a=this.#m.get(c):a=this.#N.get(c),a&&a.has(e)){const{matched:l}=a.get(e);return l}else{let l=!0;const r=[...n.KEY_FORM_FOCUS,"fieldset","form"],f=["any-link","defined","dir","link"];e.nodeType===n.ELEMENT_NODE&&r.includes(e.localName)&&(l=!1);let u;for(const h of c){switch(h.type){case n.ATTR_SELECTOR:case n.ID_SELECTOR:{l=!1;break}case n.PS_CLASS_SELECTOR:{f.includes(h.name)&&(l=!1);break}default:}if(u=this._matchSelector(h,e,o).has(e),!u)break}return l&&(a||(a=new WeakMap),a.set(e,{matched:u}),this.#o?this.#m.set(c,a):this.#N.set(c,a)),u}}_matchHTMLCollection(c,e){if(c.length){const{compound:o,filterLeaves:a}=e;if(o){const l=new Set;for(const r of c)this._matchLeaves(a,r,e)&&l.add(r);return l}else{const l=[].slice.call(c);return new Set(l)}}return new Set}_findDescendantNodes(c,e,o){const[a,...l]=c,r=l.length>0,{type:f}=a,u=(0,g.unescapeSelector)(a.name);let h=new Set,i=!1;if(this.#u)i=!0;else switch(f){case n.PS_ELEMENT_SELECTOR:{(0,v.matchPseudoElementSelector)(u,f,o);break}case n.ID_SELECTOR:{if(this.#s.nodeType===n.ELEMENT_NODE)i=!0;else{const t=this.#s.getElementById(u);t&&t!==e&&e.contains(t)&&(r?this._matchLeaves(l,t,o)&&h.add(t):h.add(t))}break}case n.CLASS_SELECTOR:{const t=e.getElementsByClassName(u);h=this._matchHTMLCollection(t,{compound:r,filterLeaves:l});break}case n.TYPE_SELECTOR:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(u)){const t=e.getElementsByTagName(u);h=this._matchHTMLCollection(t,{compound:r,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:h,pending:i}}_matchCombinator(c,e,o){const{combo:a,leaves:l}=c,{name:r}=a,{parentNode:f}=e,{dir:u}=o,h=new Set;if(u===E)switch(r){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,o)&&h.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(l,t,o)&&h.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(l,t,o)&&h.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 d=(0,N.traverseNode)(e,s);for(d=s.nextNode();d&&e.contains(d);)this._matchLeaves(l,d,o)&&h.add(d),d=s.nextNode()}}}else switch(r){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,o)&&h.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(l,t,o)&&h.add(t),t=i.nextSibling()}break}case">":{f&&this._matchLeaves(l,f,o)&&h.add(f);break}case" ":default:{const i=[];let t=f;for(;t;)this._matchLeaves(l,t,o)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return h}_findNode(c,e){const o=this.#p;let a=(0,N.traverseNode)(e,o),l;if(a)for((a.nodeType!==n.ELEMENT_NODE||a===e&&a!==this.#s)&&(a=o.nextNode());a;){if(this._matchLeaves(c,a,{warn:this.#i})){l=a;break}a=o.nextNode()}return l??null}_matchSelf(c){const e=[];let o=!1;return this._matchLeaves(c,this.#e,{warn:this.#i})&&(e.push(this.#e),o=!0),[e,o]}_findLineal(c,e){const{complex:o}=e,a=[];let l=!1,r=this._matchLeaves(c,this.#e,{warn:this.#i});if(r&&(a.push(this.#e),l=!0),!r||o){let f=this.#e.parentNode;for(;f&&(r=this._matchLeaves(c,f,{warn:this.#i}),r&&(a.push(f),l=!0),f.parentNode);)f=f.parentNode}return[a,l]}_findFirst(c){const e=[];let o=!1;const a=this._findNode(c,this.#e);return a&&(e.push(a),o=!0),[e,o]}_findFromHTMLCollection(c,e){const{complex:o,compound:a,filterLeaves:l,targetType:r}=e;let f=[],u=!1,h=!1;if(c.length)if(this.#e.nodeType===n.ELEMENT_NODE){for(const i of c)if(i!==this.#e&&(this.#e.contains(i)||i.contains(this.#e))){if(a){if(this._matchLeaves(l,i,{warn:this.#i})&&(f.push(i),u=!0,r===n.TARGET_FIRST))break}else if(f.push(i),u=!0,r===n.TARGET_FIRST)break}}else if(o)if(a){for(const i of c)if(this._matchLeaves(l,i,{warn:this.#i})&&(f.push(i),u=!0,r===n.TARGET_FIRST))break}else f=[].slice.call(c),u=!0,h=!0;else if(a){for(const i of c)if(this._matchLeaves(l,i,{warn:this.#i})&&(f.push(i),u=!0,r===n.TARGET_FIRST))break}else f=[].slice.call(c),u=!0,h=!0;return[f,u,h]}_findEntryNodes(c,e,o){const{leaves:a}=c,[l,...r]=a,f=r.length>0,{name:u,type:h}=l;let i=[],t=!1,s=!1,d=!1;switch(h){case n.PS_ELEMENT_SELECTOR:{(0,v.matchPseudoElementSelector)(u,h,{warn:this.#i});break}case n.ID_SELECTOR:{if(e===n.TARGET_SELF)[i,s]=this._matchSelf(a);else if(e===n.TARGET_LINEAL)[i,s]=this._findLineal(a,{complex:o});else if(e===n.TARGET_FIRST&&this.#s.nodeType!==n.ELEMENT_NODE){const m=this.#s.getElementById(u);m&&(f?this._matchLeaves(r,m,{warn:this.#i})&&(i.push(m),s=!0):(i.push(m),s=!0))}else e===n.TARGET_FIRST?[i,s]=this._findFirst(a):d=!0;break}case n.CLASS_SELECTOR:{if(e===n.TARGET_SELF)[i,s]=this._matchSelf(a);else if(e===n.TARGET_LINEAL)[i,s]=this._findLineal(a,{complex:o});else if(this.#s.nodeType===n.DOCUMENT_NODE){const m=this.#s.getElementsByClassName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:o,compound:f,filterLeaves:r,targetType:e}))}else e===n.TARGET_FIRST?[i,s]=this._findFirst(a):d=!0;break}case n.TYPE_SELECTOR:{if(e===n.TARGET_SELF)[i,s]=this._matchSelf(a);else if(e===n.TARGET_LINEAL)[i,s]=this._findLineal(a,{complex:o});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===n.DOCUMENT_NODE&&!/[*|]/.test(u)){const m=this.#s.getElementsByTagName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:o,compound:f,filterLeaves:r,targetType:e}))}else e===n.TARGET_FIRST?[i,s]=this._findFirst(a):d=!0;break}default:if(e!==n.TARGET_LINEAL&&(u==="host"||u==="host-context")){if(this.#u&&this.#e.nodeType===n.DOCUMENT_FRAGMENT_NODE){const m=this._matchShadowHostPseudoClass(l,this.#e);m&&(i.push(m),s=!0)}}else e===n.TARGET_SELF?[i,s]=this._matchSelf(a):e===n.TARGET_LINEAL?[i,s]=this._findLineal(a,{complex:o}):e===n.TARGET_FIRST?[i,s]=this._findFirst(a):d=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:d}}_collectNodes(c){const e=this.#a.values();if(c===n.TARGET_ALL||c===n.TARGET_FIRST){const o=new Set;let a=0;for(const{branch:l}of e){const r=l.length,f=r>1,u=l[0];let h,i;if(f){const{combo:p,leaves:[{name:w,type:k}]}=u,_=l[r-1],{leaves:[{name:y,type:T}]}=_;if(T===n.PS_ELEMENT_SELECTOR||T===n.ID_SELECTOR)h=S,i=_;else if(k===n.PS_ELEMENT_SELECTOR||k===n.ID_SELECTOR)h=E,i=u;else if(c===n.TARGET_ALL)if(w==="*"&&k===n.TYPE_SELECTOR)h=S,i=_;else if(y==="*"&&T===n.TYPE_SELECTOR)h=E,i=u;else if(r===2){const{name:x}=p;x==="+"||x==="~"?(h=S,i=_):(h=E,i=u)}else h=E,i=u;else if(w==="*"&&k===n.TYPE_SELECTOR)h=S,i=_;else if(y==="*"&&T===n.TYPE_SELECTOR)h=E,i=u;else{let x;for(const{combo:C,leaves:[M]}of l){const{name:I,type:R}=M;if(R===n.PS_CLASS_SELECTOR&&I==="dir"){x=!1;break}if(!x&&C){const{name:O}=C;(O==="+"||O==="~")&&(x=!0)}}x?(h=E,i=u):(h=S,i=_)}}else h=S,i=u;const{collected:t,compound:s,filtered:d,nodes:m,pending:b}=this._findEntryNodes(i,c,f);m.length?(this.#a[a].find=!0,this.#d[a]=m):b&&o.add(new Map([["index",a],["twig",i]])),this.#a[a].collected=t,this.#a[a].dir=h,this.#a[a].filtered=d||!s,a++}if(o.size){let l,r;this.#e!==this.#s&&this.#e.nodeType===n.ELEMENT_NODE?(l=this.#e,r=this.#p):(l=this.#s,r=this.#f);let f=(0,N.traverseNode)(l,r);for(;f;){let u=!1;if(this.#e.nodeType===n.ELEMENT_NODE?f===this.#e?u=!0:u=this.#e.contains(f):u=!0,u)for(const h of o){const{leaves:i}=h.get("twig");if(this._matchLeaves(i,f,{warn:this.#i})){const s=h.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#d[s].push(f)}}f!==r.currentNode&&(f=(0,N.traverseNode)(f,r)),f=r.nextNode()}}}else{let o=0;for(const{branch:a}of e){const l=a[a.length-1],r=a.length>1,{compound:f,filtered:u,nodes:h}=this._findEntryNodes(l,c,r);h.length&&(this.#a[o].find=!0,this.#d[o]=h),this.#a[o].dir=S,this.#a[o].filtered=u||!f,o++}}return[this.#a,this.#d]}_getCombinedNodes(c,e,o){const a=[];for(const l of e){const r=this._matchCombinator(c,l,{dir:o,warn:this.#i});r.size&&a.push(...r)}return a.length?new Set(a):new Set}_matchNodeNext(c,e,o){const{combo:a,index:l}=o,{combo:r,leaves:f}=c[l],u={combo:a,leaves:f},h=this._getCombinedNodes(u,e,E);if(h.size)if(l===c.length-1){const[i]=(0,N.sortNodes)(h);return i}else return this._matchNodeNext(c,h,{combo:r,index:l+1});return null}_matchNodePrev(c,e,o){const{index:a}=o,l=c[a],r=new Set([e]),f=this._getCombinedNodes(l,r,S);if(f.size){if(a===0)return e;{let u;for(const h of f)if(u=this._matchNodePrev(c,h,{index:a-1}),u)break;return u?e:null}}return null}find(c){(c===n.TARGET_ALL||c===n.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],o]=this._collectNodes(c),a=e.length;let l,r=new Set;for(let f=0;f<a;f++){const{branch:u,collected:h,dir:i,find:t}=e[f],s=u.length;if(s&&t){const d=o[f],m=d.length,b=s-1;if(b===0)if((c===n.TARGET_ALL||c===n.TARGET_FIRST)&&this.#e.nodeType===n.ELEMENT_NODE)for(let p=0;p<m;p++){const w=d[p];if(w!==this.#e&&this.#e.contains(w)&&(r.add(w),c===n.TARGET_FIRST))break}else if(c===n.TARGET_ALL)if(r.size){const p=[...r];r=new Set([...p,...d]),l=!0}else r=new Set(d);else{const[p]=d;r.add(p)}else if(c===n.TARGET_ALL)if(i===E){let{combo:p}=u[0];for(const w of d){let k=new Set([w]);for(let _=1;_<s;_++){const{combo:y,leaves:T}=u[_],x={combo:p,leaves:T};if(k=this._getCombinedNodes(x,k,i),k.size)if(_===b)if(r.size){const C=[...r];r=new Set([...C,...k]),l=!0}else r=k;else p=y;else break}}}else for(const p of d){let w=new Set([p]);for(let k=b-1;k>=0;k--){const _=u[k];if(w=this._getCombinedNodes(_,w,i),w.size)k===0&&(r.add(p),s>1&&r.size>1&&(l=!0));else break}}else if(c===n.TARGET_FIRST&&i===E){const{combo:p}=u[0];let w;for(const k of d)if(w=this._matchNodeNext(u,new Set([k]),{combo:p,index:1}),w){r.add(w);break}if(!w&&!h){const{leaves:k}=u[0],[_]=d;let y=this._findNode(k,_);for(;y;){if(w=this._matchNodeNext(u,new Set([y]),{combo:p,index:1}),w){r.add(w);break}y=this._findNode(k,y)}}}else{let p;for(const w of d)if(p=this._matchNodePrev(u,w,{index:b-1}),p){r.add(w);break}if(!p&&!h&&c===n.TARGET_FIRST){const{leaves:w}=u[b],[k]=d;let _=this._findNode(w,k);for(;_;){if(p=this._matchNodePrev(u,_,{index:b-1}),p){r.add(_);break}_=this._findNode(w,_)}}}}}return c===n.TARGET_FIRST?(r.delete(this.#e),r.size>1&&(r=new Set((0,N.sortNodes)(r)))):c===n.TARGET_ALL&&(r.delete(this.#e),l&&r.size>1&&(r=new Set((0,N.sortNodes)(r)))),r}}0&&(module.exports={Finder});
|
|
1
|
+
var A=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var F=(L,c)=>{for(var e in c)A(L,e,{get:c[e],enumerable:!0})},$=(L,c,e,o)=>{if(c&&typeof c=="object"||typeof c=="function")for(let a of P(c))!U.call(L,a)&&a!==e&&A(L,a,{get:()=>c[a],enumerable:!(o=D(c,a))||o.enumerable});return L};var W=L=>$(A({},"__esModule",{value:!0}),L);var H={};F(H,{Finder:()=>z});module.exports=W(H);var v=require("./matcher.js"),y=require("./parser.js"),N=require("./utility.js"),n=require("./constant.js");const E="next",S="prev";class z{#a;#r;#k;#t;#h;#c;#b;#o;#m;#n;#e;#u;#y;#p;#N;#s;#d;#_;#f;#w;#i;#l;constructor(c){this.#l=c,this.#r=new WeakMap,this.#h=new WeakMap,this.#m=new WeakMap,this.#N=new WeakMap,this.#c=null,this.#b=null,this.#n=null,this._registerEventListeners()}onError(c,e){if(!(e?.noexcept??this.#y))if(c instanceof DOMException||c instanceof this.#l.DOMException)if(c.name===n.NOT_SUPPORTED_ERR)this.#i&&console.warn(c.message);else throw new this.#l.DOMException(c.message,c.name);else throw c.name in this.#l?new this.#l[c.name](c.message):c}setup(c,e,o={}){const{noexcept:a,warn:l}=o;return this.#y=!!a,this.#i=!!l,this.#e=e,[this.#t,this.#s,this.#f,this.#d]=(0,N.resolveContent)(e),[this.#a,this.#u]=this._correspond(c),this.#m=new WeakMap,this.#w=new WeakMap,this.#_=null,this}_registerEventListeners(){const c={capture:!0,passive:!0},e=[],o=["focus","focusin"];for(const r of o)e.push(this.#l.addEventListener(r,f=>{this.#b=f},c));const a=["keydown","keyup"];for(const r of a)e.push(this.#l.addEventListener(r,f=>{const{key:u}=f;n.KEY_MODIFIER.includes(u)||(this.#c=f)},c));const l=["mouseover","mousedown","mouseup","click","mouseout"];for(const r of l)e.push(this.#l.addEventListener(r,f=>{this.#c=f},c));return e}_correspond(c){const e=[];this.#k=!1,this.#o=!1;let o;if(this.#h.has(this.#t)){const a=this.#h.get(this.#t);if(a&&a.has(`${c}`)){const l=a.get(`${c}`);o=l.ast,this.#k=l.descendant,this.#o=l.invalidate}}if(o){const a=o.length;for(let l=0;l<a;l++)o[l].collected=!1,o[l].dir=null,o[l].filtered=!1,o[l].find=!1,e[l]=[]}else{let a;try{a=(0,y.parseSelector)(c)}catch(m){this.onError(m)}const{branches:l,info:r}=(0,y.walkAST)(a),{hasHasPseudoFunc:f,hasLogicalPseudoFunc:u,hasNthChildOfSelector:h}=r;let i=f||!!(u&&h),t=!1,s=0;o=[];for(const[...m]of l){const b=[];let w=m.shift();if(w&&w.type!==n.COMBINATOR){const p=new Set;for(;w;){let k=w.name;if(w.type===n.COMBINATOR){const[_]=m;if(_.type===n.COMBINATOR)throw new DOMException(`Invalid selector ${c}`,n.SYNTAX_ERR);k==="+"||k==="~"?i=!0:t=!0,b.push({combo:w,leaves:(0,y.sortAST)(p)}),p.clear()}else w&&(k&&typeof k=="string"&&(k=(0,y.unescapeSelector)(k),typeof k=="string"&&k!==w.name&&(w.name=k),/[|:]/.test(k)&&(w.namespace=!0)),p.add(w));if(m.length)w=m.shift();else{b.push({combo:null,leaves:(0,y.sortAST)(p)}),p.clear();break}}}o.push({branch:b,collected:!1,dir:null,filtered:!1,find:!1}),e[s]=[],s++}let d;this.#h.has(this.#t)?d=this.#h.get(this.#t):d=new Map,d.set(`${c}`,{ast:o,descendant:t,invalidate:i}),this.#h.set(this.#t,d),this.#k=t,this.#o=i}return[o,e]}_createTreeWalker(c){let e;return this.#w.has(c)?e=this.#w.get(c):(e=this.#t.createTreeWalker(c,n.WALKER_FILTER),this.#w.set(c,e)),e}_prepareQuerySelectorWalker(){return this.#p=this._createTreeWalker(this.#e),this.#p}_collectNthChild(c,e,o){const{a,b:l,reverse:r,selector:f}=c,{parentNode:u}=e,h=new Set;let i;if(f){if(this.#r.has(f))i=this.#r.get(f);else{const{branches:s}=(0,y.walkAST)(f);i=s,this.#o||this.#r.set(f,i)}const{branches:t}=(0,y.walkAST)(f);i=t}if(u){const t=this.#f;let s=(0,N.traverseNode)(u,t);s=t.firstChild();let d=0;for(;s;)d++,s=t.nextSibling();const m=new Set;if(i)for(s=(0,N.traverseNode)(u,t),s=t.firstChild();s;){if((0,N.isVisible)(s)){let b;for(const w of i)if(b=this._matchLeaves(w,s,o),!b)break;b&&m.add(s)}s=t.nextSibling()}if(a===0){if(l>0&&l<=d){if(m.size){s=(0,N.traverseNode)(u,t),r?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(m.has(s)){if(b===l-1){h.add(s);break}b++}r?s=t.previousSibling():s=t.nextSibling()}}else if(!f){s=(0,N.traverseNode)(u,t),r?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(b===l-1){h.add(s);break}r?s=t.previousSibling():s=t.nextSibling(),b++}}}}else{let b=l-1;if(a>0)for(;b<0;)b+=a;if(b>=0&&b<d){s=(0,N.traverseNode)(u,t),r?s=t.lastChild():s=t.firstChild();let w=0,p=a>0?0:l-1;for(;s&&(s&&b>=0&&b<d);)m.size?m.has(s)&&(p===b&&(h.add(s),b+=a),a>0?p++:p--):w===b&&(f||h.add(s),b+=a),r?s=t.previousSibling():s=t.nextSibling(),w++}}if(r&&h.size>1){const b=[...h];return new Set(b.reverse())}}else if(e===this.#s&&a+l===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,o),t)break;t&&h.add(e)}else h.add(e);return h}_collectNthOfType(c,e){const{a:o,b:a,reverse:l}=c,{localName:r,namespaceURI:f,parentNode:u,prefix:h}=e,i=new Set;if(u){const t=this.#f;let s=(0,N.traverseNode)(u,t);s=t.firstChild();let d=0;for(;s;)d++,s=t.nextSibling();if(o===0){if(a>0&&a<=d){s=(0,N.traverseNode)(u,t),l?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){const{localName:b,namespaceURI:w,prefix:p}=s;if(b===r&&p===h&&w===f){if(m===a-1){i.add(s);break}m++}l?s=t.previousSibling():s=t.nextSibling()}}}else{let m=a-1;if(o>0)for(;m<0;)m+=o;if(m>=0&&m<d){s=(0,N.traverseNode)(u,t),l?s=t.lastChild():s=t.firstChild();let b=o>0?0:a-1;for(;s;){const{localName:w,namespaceURI:p,prefix:k}=s;if(w===r&&k===h&&p===f){if(b===m&&(i.add(s),m+=o),m<0||m>=d)break;o>0?b++:b--}l?s=t.previousSibling():s=t.nextSibling()}}}if(l&&i.size>1){const m=[...i];return new Set(m.reverse())}}else e===this.#s&&o+a===1&&i.add(e);return i}_matchAnPlusB(c,e,o,a){const{nth:{a:l,b:r,name:f},selector:u}=c,h=new Map;if(f?(f==="even"?(h.set("a",2),h.set("b",0)):f==="odd"&&(h.set("a",2),h.set("b",1)),o.indexOf("last")>-1&&h.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?h.set("a",l*1):h.set("a",0),typeof r=="string"&&/-?\d+/.test(r)?h.set("b",r*1):h.set("b",0),o.indexOf("last")>-1&&h.set("reverse",!0)),o==="nth-child"||o==="nth-last-child"){u&&h.set("selector",u);const i=Object.fromEntries(h);return this._collectNthChild(i,e,a)}else if(o==="nth-of-type"||o==="nth-last-of-type"){const i=Object.fromEntries(h);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(c,e,o){if(Array.isArray(c)&&c.length){const a=[...c],[l]=a,{type:r}=l;let f;r===n.COMBINATOR?f=a.shift():f={name:" ",type:n.COMBINATOR};const u=[];for(;a.length;){const[t]=a,{type:s}=t;if(s===n.COMBINATOR)break;u.push(a.shift())}const h={combo:f,leaves:u};o.dir=E;const i=this._matchCombinator(h,e,o);if(i.size){if(a.length){let t=!1;for(const s of i)if(t=this._matchHasPseudoFunc(a,s,o),t)break;return t}return!0}}return!1}_matchLogicalPseudoFunc(c,e,o){const{astName:a,branches:l,twigBranches:r}=c,f=(o.isShadowRoot||this.#d)&&e.nodeType===n.DOCUMENT_FRAGMENT_NODE;if(a==="has"){let u;for(const h of l)if(u=this._matchHasPseudoFunc(h,e,o),u)break;if(u)if(f){if(this.#_)return e}else return e}else{if(f){let i;for(const t of l)if(t.length>1){i=!0;break}else if(a==="not"){const[{type:s}]=t;if(s!==n.PS_CLASS_SELECTOR){i=!0;break}}if(i)return null}o.forgive=a==="is"||a==="where";const u=r.length;let h;for(let i=0;i<u;i++){const t=r[i],s=t.length-1,{leaves:d}=t[s];if(h=this._matchLeaves(d,e,o),h&&s>0){let m=new Set([e]);for(let b=s-1;b>=0;b--){const w=t[b],p=[];o.dir=S;for(const k of m){const _=this._matchCombinator(w,k,o);_.size&&p.push(..._)}if(p.length)b===0?h=!0:m=new Set(p);else{h=!1;break}}}if(h)break}if(a==="not")return h?null:e;if(h)return e}return null}_matchPseudoClassSelector(c,e,o){const{children:a,name:l}=c,{localName:r,parentNode:f}=e,{forgive:u,warn:h=this.#i}=o,i=new Set;if(Array.isArray(a)&&n.KEY_LOGICAL.includes(l)){if(!a.length&&l!=="is"&&l!=="where"){const d=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${d}`,n.SYNTAX_ERR)}let t;if(this.#r.has(c))t=this.#r.get(c);else{const{branches:d}=(0,y.walkAST)(c);if(l==="has"){let m;for(const b of a){const w=(0,y.findAST)(b,p=>n.KEY_LOGICAL.includes(p.name)&&(0,y.findAST)(p,k=>k.name==="has")?p:null);if(w){const p=w.name;if(p==="is"||p==="where"){m=!0;break}else{const k=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${k}`,n.SYNTAX_ERR)}}}if(m)return i;t={astName:l,branches:d}}else{const m=[];for(const[...b]of d){const w=[],p=new Set;let k=b.shift();for(;k;)if(k.type===n.COMBINATOR?(w.push({combo:k,leaves:[...p]}),p.clear()):k&&p.add(k),b.length)k=b.shift();else{w.push({combo:null,leaves:[...p]}),p.clear();break}m.push(w)}t={astName:l,branches:d,twigBranches:m},this.#o||this.#r.set(c,t)}}const s=this._matchLogicalPseudoFunc(t,e,o);s&&i.add(s)}else if(Array.isArray(a))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){if(a.length!==1){const d=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${d}`,n.SYNTAX_ERR)}const[t]=a;return this._matchAnPlusB(t,e,l,o)}else switch(l){case"dir":{if(a.length!==1){const d=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${d}`,n.SYNTAX_ERR)}const[t]=a;(0,v.matchDirectionPseudoClass)(t,e)&&i.add(e);break}case"lang":{if(!a.length){const s=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${s}`,n.SYNTAX_ERR)}let t;for(const s of a)if(t=(0,v.matchLanguagePseudoClass)(s,e),t)break;t&&i.add(e);break}case"state":{if((0,N.isCustomElement)(e)){const[{value:t}]=a;if(t)if(e[t])i.add(e);else for(const s in e){const d=e[s];if(d instanceof this.#l.ElementInternals){d?.states?.has(t)&&i.add(e);break}}}break}case"current":case"nth-col":case"nth-last-col":{if(h)throw new DOMException(`Unsupported pseudo-class :${l}()`,n.NOT_SUPPORTED_ERR);break}case"host":case"host-context":break;case"contains":{if(h)throw new DOMException(`Unknown pseudo-class :${l}()`,n.NOT_SUPPORTED_ERR);break}default:if(!u)throw new DOMException(`Unknown pseudo-class :${l}()`,n.SYNTAX_ERR)}else switch(l){case"any-link":case"link":{(r==="a"||r==="area")&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if((r==="a"||r==="area")&&e.hasAttribute("href")){const{href:t,origin:s,pathname:d}=new URL(this.#t.URL),m=new URL(e.getAttribute("href"),t);m.origin===s&&m.pathname===d&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#c??{};/^(?:click|mouse(?:down|over|up))$/.test(s)&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:d}=this.#c??{};d==="mousedown"&&t&n.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 d=this.#t.getElementById(s);for(;d;){if(d===e){i.add(e);break}d=d.parentNode}}break}case"scope":{this.#e.nodeType===n.ELEMENT_NODE?!this.#d&&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 if(this.#b){const{relatedTarget:s,target:d}=this.#b;if(d===e)if((0,N.isFocusVisible)(s))t=!0;else if(this.#c){const{key:m,target:b,type:w}=this.#c;b===s?(this.#n===null||d===this.#n)&&(t=!0):m==="Tab"?(w==="keydown"&&b!==e||w==="keyup"&&b===e)&&(b===d?(this.#n===null||b===this.#n&&s===null)&&(t=!0):t=!0):m&&(w==="keydown"||w==="keyup")&&b===e&&(t=!0)}else(s===null||s===this.#n)&&(t=!0)}t?(this.#n=e,i.add(e)):this.#n===e&&(this.#n=null)}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":{(r==="details"||r==="dialog")&&(e.hasAttribute("open")?l==="open"&&i.add(e):l==="closed"&&i.add(e));break}case"disabled":case"enabled":{if([...n.KEY_FORM_FOCUS,"fieldset","optgroup","option"].includes(r)||(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 d=f;for(;d;)if(d.localName==="fieldset"&&(d.disabled||d.hasAttribute("disabled"))){const m=this.#f;let b=(0,N.traverseNode)(d,m);for(b=m.firstChild();b&&b.localName!=="legend";)b=m.nextSibling();b&&b.contains(e)||(s=!0);break}else{if(d.localName==="form")break;if(d.parentNode?.nodeType===n.ELEMENT_NODE){if(d.parentNode.localName==="form")break;d=d.parentNode}else break}}s?l==="disabled"&&i.add(e):l==="enabled"&&i.add(e)}break}case"read-only":case"read-write":{let t,s;switch(r){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")?t=!0:s=!0;break}case"input":{(!e.type||n.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?l==="read-only"&&i.add(e):l==="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;r==="textarea"?s=e:r==="input"&&(e.hasAttribute("type")?[...n.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&&r==="input"&&(t==="checkbox"||t==="radio")||e.selected&&r==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&r==="input"&&e.type==="checkbox"||r==="progress"&&!e.hasAttribute("value"))i.add(e);else if(r==="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 d=s.getElementsByTagName("input"),m=d.length;let b;for(let w=0;w<m;w++){const p=d[w];if(p.getAttribute("type")==="radio"&&(t?p.getAttribute("name")===t&&(b=!!p.checked):p.hasAttribute("name")||(b=!!p.checked),b))break}b||i.add(e)}break}case"default":{const t=["checkbox","radio"],s=["button","reset"],d=["image","submit"],m=e.getAttribute("type");if(r==="button"&&!(e.hasAttribute("type")&&s.includes(m))||r==="input"&&e.hasAttribute("type")&&d.includes(m)){let b=e.parentNode;for(;b&&b.localName!=="form";)b=b.parentNode;if(b){const w=this.#f;let p=(0,N.traverseNode)(b,w);for(p=w.firstChild();p&&b.contains(p);){const k=p.localName,_=p.getAttribute("type");let g;if(k==="button"?g=!(p.hasAttribute("type")&&s.includes(_)):k==="input"&&(g=p.hasAttribute("type")&&d.includes(_)),g){p===e&&i.add(e);break}p=w.nextNode()}}}else(r==="input"&&e.hasAttribute("type")&&t.includes(m)&&e.hasAttribute("checked")||r==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":case"invalid":{const t=[...n.KEY_FORM_FOCUS,"form"];if(t.includes(r)){let s;e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&(s=!0):s=!0),s?l==="valid"&&i.add(e):l==="invalid"&&i.add(e)}else if(r==="fieldset"){const s=this.#f;let d=(0,N.traverseNode)(e,s);d=s.firstChild();let m;if(!d)m=!0;else for(;d&&e.contains(d)&&!(t.includes(d.localName)&&(d.checkValidity()?d.maxLength>=0?m=d.maxLength>=d.value.length:m=!0:m=!1,!m));)d=s.nextNode();m?l==="valid"&&i.add(e):l==="invalid"&&i.add(e)}break}case"in-range":case"out-of-range":{const t=[...n.KEY_INPUT_DATE,"number","range"],s=e.getAttribute("type");if(r==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&t.includes(s)){const d=e.validity.rangeUnderflow||e.validity.rangeOverflow;(l==="out-of-range"&&d||l==="in-range"&&!d&&(e.hasAttribute("min")||e.hasAttribute("max")||s==="range"))&&i.add(e)}break}case"required":case"optional":{let t;if(r==="select"||r==="textarea")t=e;else if(r==="input")if(e.hasAttribute("type")){const s=[...n.KEY_INPUT_EDIT,"checkbox","file","radio"],d=e.getAttribute("type");s.includes(d)&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required")?l==="required"&&i.add(e):l==="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,n.SHOW_ALL);let s=t.firstChild(),d;for(;s&&(d=s.nodeType!==n.ELEMENT_NODE&&s.nodeType!==n.TEXT_NODE,!!d);)s=t.nextSibling();d&&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")||r.includes("-")?(0,N.isCustomElement)(e)&&i.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.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(h)throw new DOMException(`Unsupported pseudo-element ::${l}`,n.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(h)throw new DOMException(`Unsupported pseudo-class :${l}`,n.NOT_SUPPORTED_ERR);break}default:if(l.startsWith("-webkit-")){if(h)throw new DOMException(`Unsupported pseudo-class :${l}`,n.NOT_SUPPORTED_ERR)}else if(!u)throw new DOMException(`Unknown pseudo-class :${l}`,n.SYNTAX_ERR)}return i}_matchShadowHostPseudoClass(c,e){const{children:o,name:a}=c;if(Array.isArray(o)){if(o.length!==1){const h=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${h}`,n.SYNTAX_ERR)}const{branches:l}=(0,y.walkAST)(o[0]),[r]=l,[...f]=r,{host:u}=e;if(a==="host"){let h;for(const i of f){const{type:t}=i;if(t===n.COMBINATOR){const s=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${s}`,n.SYNTAX_ERR)}if(h=this._matchSelector(i,u).has(u),!h)break}return h?e:null}else if(a==="host-context"){let h=u,i;for(;h;){for(const t of f){const{type:s}=t;if(s===n.COMBINATOR){const d=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${d}`,n.SYNTAX_ERR)}if(i=this._matchSelector(t,h).has(h),!i)break}if(i)break;h=h.parentNode}return i?e:null}throw new DOMException(`Invalid selector :${a}`,n.SYNTAX_ERR)}else{if(a==="host")return e;throw new DOMException(`Invalid selector :${a}`,n.SYNTAX_ERR)}}_matchSelector(c,e,o={}){const{type:a}=c,l=(0,y.unescapeSelector)(c.name),r=new Set;if(e.nodeType===n.ELEMENT_NODE)switch(a){case n.ATTR_SELECTOR:{(0,v.matchAttributeSelector)(c,e)&&r.add(e);break}case n.ID_SELECTOR:{e.id===l&&r.add(e);break}case n.CLASS_SELECTOR:{e.classList.contains(l)&&r.add(e);break}case n.PS_CLASS_SELECTOR:return this._matchPseudoClassSelector(c,e,o);case n.TYPE_SELECTOR:{(0,v.matchTypeSelector)(c,e,o)&&r.add(e);break}case n.PS_ELEMENT_SELECTOR:default:(0,v.matchPseudoElementSelector)(l,a,o)}else if(this.#d&&a===n.PS_CLASS_SELECTOR&&e.nodeType===n.DOCUMENT_FRAGMENT_NODE){if(n.KEY_LOGICAL.includes(l))return o.isShadowRoot=!0,this._matchPseudoClassSelector(c,e,o);if(l==="host"||l==="host-context"){const f=this._matchShadowHostPseudoClass(c,e,o);f&&(this.#_=!0,r.add(f))}}return r}_matchLeaves(c,e,o){let a;if(this.#o?a=this.#m.get(c):a=this.#N.get(c),a&&a.has(e)){const{matched:l}=a.get(e);return l}else{let l=!0;const r=[...n.KEY_FORM_FOCUS,"fieldset","form"],f=["any-link","defined","dir","link"];e.nodeType===n.ELEMENT_NODE&&r.includes(e.localName)&&(l=!1);let u;for(const h of c){switch(h.type){case n.ATTR_SELECTOR:case n.ID_SELECTOR:{l=!1;break}case n.PS_CLASS_SELECTOR:{f.includes(h.name)&&(l=!1);break}default:}if(u=this._matchSelector(h,e,o).has(e),!u)break}return l&&(a||(a=new WeakMap),a.set(e,{matched:u}),this.#o?this.#m.set(c,a):this.#N.set(c,a)),u}}_matchHTMLCollection(c,e){if(c.length){const{compound:o,filterLeaves:a}=e;if(o){const l=new Set;for(const r of c)this._matchLeaves(a,r,e)&&l.add(r);return l}else{const l=[].slice.call(c);return new Set(l)}}return new Set}_findDescendantNodes(c,e,o){const[a,...l]=c,r=l.length>0,{type:f}=a,u=(0,y.unescapeSelector)(a.name);let h=new Set,i=!1;if(this.#d||e.nodeType!==n.ELEMENT_NODE)i=!0;else switch(f){case n.PS_ELEMENT_SELECTOR:{(0,v.matchPseudoElementSelector)(u,f,o);break}case n.ID_SELECTOR:{if(this.#s.nodeType===n.ELEMENT_NODE)i=!0;else{const t=this.#s.getElementById(u);t&&t!==e&&e.contains(t)&&(r?this._matchLeaves(l,t,o)&&h.add(t):h.add(t))}break}case n.CLASS_SELECTOR:{const t=e.getElementsByClassName(u);h=this._matchHTMLCollection(t,{compound:r,filterLeaves:l});break}case n.TYPE_SELECTOR:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(u)){const t=e.getElementsByTagName(u);h=this._matchHTMLCollection(t,{compound:r,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:h,pending:i}}_matchCombinator(c,e,o){const{combo:a,leaves:l}=c,{name:r}=a,{parentNode:f}=e,{dir:u}=o,h=new Set;if(u===E)switch(r){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,o)&&h.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(l,t,o)&&h.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(l,t,o)&&h.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 d=(0,N.traverseNode)(e,s);for(d=s.nextNode();d&&e.contains(d);)this._matchLeaves(l,d,o)&&h.add(d),d=s.nextNode()}}}else switch(r){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,o)&&h.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(l,t,o)&&h.add(t),t=i.nextSibling()}break}case">":{f&&this._matchLeaves(l,f,o)&&h.add(f);break}case" ":default:{const i=[];let t=f;for(;t;)this._matchLeaves(l,t,o)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return h}_findNode(c,e){const o=this.#p;let a=(0,N.traverseNode)(e,o),l;if(a)for((a.nodeType!==n.ELEMENT_NODE||a===e&&a!==this.#s)&&(a=o.nextNode());a;){if(this._matchLeaves(c,a,{warn:this.#i})){l=a;break}a=o.nextNode()}return l??null}_matchSelf(c){const e=[];let o=!1;return this._matchLeaves(c,this.#e,{warn:this.#i})&&(e.push(this.#e),o=!0),[e,o]}_findLineal(c,e){const{complex:o}=e,a=[];let l=!1,r=this._matchLeaves(c,this.#e,{warn:this.#i});if(r&&(a.push(this.#e),l=!0),!r||o){let f=this.#e.parentNode;for(;f&&(r=this._matchLeaves(c,f,{warn:this.#i}),r&&(a.push(f),l=!0),f.parentNode);)f=f.parentNode}return[a,l]}_findFirst(c){const e=[];let o=!1;const a=this._findNode(c,this.#e);return a&&(e.push(a),o=!0),[e,o]}_findFromHTMLCollection(c,e){const{complex:o,compound:a,filterLeaves:l,targetType:r}=e;let f=[],u=!1,h=!1;if(c.length)if(this.#e.nodeType===n.ELEMENT_NODE){for(const i of c)if(i!==this.#e&&(this.#e.contains(i)||i.contains(this.#e))){if(a){if(this._matchLeaves(l,i,{warn:this.#i})&&(f.push(i),u=!0,r===n.TARGET_FIRST))break}else if(f.push(i),u=!0,r===n.TARGET_FIRST)break}}else if(o)if(a){for(const i of c)if(this._matchLeaves(l,i,{warn:this.#i})&&(f.push(i),u=!0,r===n.TARGET_FIRST))break}else f=[].slice.call(c),u=!0,h=!0;else if(a){for(const i of c)if(this._matchLeaves(l,i,{warn:this.#i})&&(f.push(i),u=!0,r===n.TARGET_FIRST))break}else f=[].slice.call(c),u=!0,h=!0;return[f,u,h]}_findEntryNodes(c,e,o){const{leaves:a}=c,[l,...r]=a,f=r.length>0,{name:u,type:h}=l;let i=[],t=!1,s=!1,d=!1;switch(h){case n.PS_ELEMENT_SELECTOR:{(0,v.matchPseudoElementSelector)(u,h,{warn:this.#i});break}case n.ID_SELECTOR:{if(e===n.TARGET_SELF)[i,s]=this._matchSelf(a);else if(e===n.TARGET_LINEAL)[i,s]=this._findLineal(a,{complex:o});else if(e===n.TARGET_FIRST&&this.#s.nodeType!==n.ELEMENT_NODE){const m=this.#s.getElementById(u);m&&(f?this._matchLeaves(r,m,{warn:this.#i})&&(i.push(m),s=!0):(i.push(m),s=!0))}else e===n.TARGET_FIRST?[i,s]=this._findFirst(a):d=!0;break}case n.CLASS_SELECTOR:{if(e===n.TARGET_SELF)[i,s]=this._matchSelf(a);else if(e===n.TARGET_LINEAL)[i,s]=this._findLineal(a,{complex:o});else if(this.#s.nodeType===n.DOCUMENT_NODE){const m=this.#s.getElementsByClassName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:o,compound:f,filterLeaves:r,targetType:e}))}else e===n.TARGET_FIRST?[i,s]=this._findFirst(a):d=!0;break}case n.TYPE_SELECTOR:{if(e===n.TARGET_SELF)[i,s]=this._matchSelf(a);else if(e===n.TARGET_LINEAL)[i,s]=this._findLineal(a,{complex:o});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===n.DOCUMENT_NODE&&!/[*|]/.test(u)){const m=this.#s.getElementsByTagName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:o,compound:f,filterLeaves:r,targetType:e}))}else e===n.TARGET_FIRST?[i,s]=this._findFirst(a):d=!0;break}default:if(e!==n.TARGET_LINEAL&&(u==="host"||u==="host-context")){let m;if(this.#d&&this.#e.nodeType===n.DOCUMENT_FRAGMENT_NODE?m=this._matchShadowHostPseudoClass(l,this.#e):f&&this.#e.nodeType===n.ELEMENT_NODE&&(m=this._matchShadowHostPseudoClass(l,this.#e.shadowRoot)),m){let b;if(f){for(const w of r)if(/^host(?:-context)?$/.test(w.name)?b=this._matchShadowHostPseudoClass(w,m)===m:w.name==="has"?b=this._matchPseudoClassSelector(w,m,{}).has(m):b=!1,!b)break}else b=!0;b&&(i.push(m),s=!0)}}else e===n.TARGET_SELF?[i,s]=this._matchSelf(a):e===n.TARGET_LINEAL?[i,s]=this._findLineal(a,{complex:o}):e===n.TARGET_FIRST?[i,s]=this._findFirst(a):d=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:d}}_collectNodes(c){const e=this.#a.values();if(c===n.TARGET_ALL||c===n.TARGET_FIRST){const o=new Set;let a=0;for(const{branch:l}of e){const r=l.length,f=r>1,u=l[0];let h,i;if(f){const{combo:w,leaves:[{name:p,type:k}]}=u,_=l[r-1],{leaves:[{name:g,type:T}]}=_;if(T===n.PS_ELEMENT_SELECTOR||T===n.ID_SELECTOR)h=S,i=_;else if(k===n.PS_ELEMENT_SELECTOR||k===n.ID_SELECTOR)h=E,i=u;else if(c===n.TARGET_ALL)if(p==="*"&&k===n.TYPE_SELECTOR)h=S,i=_;else if(g==="*"&&T===n.TYPE_SELECTOR)h=E,i=u;else if(r===2){const{name:x}=w;x==="+"||x==="~"?(h=S,i=_):(h=E,i=u)}else h=E,i=u;else if(p==="*"&&k===n.TYPE_SELECTOR)h=S,i=_;else if(g==="*"&&T===n.TYPE_SELECTOR)h=E,i=u;else{let x;for(const{combo:C,leaves:[M]}of l){const{name:R,type:I}=M;if(I===n.PS_CLASS_SELECTOR&&R==="dir"){x=!1;break}if(!x&&C){const{name:O}=C;(O==="+"||O==="~")&&(x=!0)}}x?(h=E,i=u):(h=S,i=_)}}else h=S,i=u;const{collected:t,compound:s,filtered:d,nodes:m,pending:b}=this._findEntryNodes(i,c,f);m.length?(this.#a[a].find=!0,this.#u[a]=m):b&&o.add(new Map([["index",a],["twig",i]])),this.#a[a].collected=t,this.#a[a].dir=h,this.#a[a].filtered=d||!s,a++}if(o.size){let l,r;this.#e!==this.#s&&this.#e.nodeType===n.ELEMENT_NODE?(l=this.#e,r=this.#p):(l=this.#s,r=this.#f);let f=(0,N.traverseNode)(l,r);for(;f;){let u=!1;if(this.#e.nodeType===n.ELEMENT_NODE?f===this.#e?u=!0:u=this.#e.contains(f):u=!0,u)for(const h of o){const{leaves:i}=h.get("twig");if(this._matchLeaves(i,f,{warn:this.#i})){const s=h.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#u[s].push(f)}}f!==r.currentNode&&(f=(0,N.traverseNode)(f,r)),f=r.nextNode()}}}else{let o=0;for(const{branch:a}of e){const l=a[a.length-1],r=a.length>1,{compound:f,filtered:u,nodes:h}=this._findEntryNodes(l,c,r);h.length&&(this.#a[o].find=!0,this.#u[o]=h),this.#a[o].dir=S,this.#a[o].filtered=u||!f,o++}}return[this.#a,this.#u]}_getCombinedNodes(c,e,o){const a=[];for(const l of e){const r=this._matchCombinator(c,l,{dir:o,warn:this.#i});r.size&&a.push(...r)}return a.length?new Set(a):new Set}_matchNodeNext(c,e,o){const{combo:a,index:l}=o,{combo:r,leaves:f}=c[l],u={combo:a,leaves:f},h=this._getCombinedNodes(u,e,E);if(h.size)if(l===c.length-1){const[i]=(0,N.sortNodes)(h);return i}else return this._matchNodeNext(c,h,{combo:r,index:l+1});return null}_matchNodePrev(c,e,o){const{index:a}=o,l=c[a],r=new Set([e]),f=this._getCombinedNodes(l,r,S);if(f.size){if(a===0)return e;{let u;for(const h of f)if(u=this._matchNodePrev(c,h,{index:a-1}),u)break;if(u)return e}}return null}find(c){(c===n.TARGET_ALL||c===n.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],o]=this._collectNodes(c),a=e.length;let l,r=new Set;for(let f=0;f<a;f++){const{branch:u,collected:h,dir:i,find:t}=e[f],s=u.length;if(s&&t){const d=o[f],m=d.length,b=s-1;if(b===0)if((c===n.TARGET_ALL||c===n.TARGET_FIRST)&&this.#e.nodeType===n.ELEMENT_NODE)for(let w=0;w<m;w++){const p=d[w];if(p!==this.#e&&this.#e.contains(p)&&(r.add(p),c===n.TARGET_FIRST))break}else if(c===n.TARGET_ALL)if(r.size){const w=[...r];r=new Set([...w,...d]),l=!0}else r=new Set(d);else{const[w]=d;r.add(w)}else if(c===n.TARGET_ALL)if(i===E){let{combo:w}=u[0];for(const p of d){let k=new Set([p]);for(let _=1;_<s;_++){const{combo:g,leaves:T}=u[_],x={combo:w,leaves:T};if(k=this._getCombinedNodes(x,k,i),k.size)if(_===b)if(r.size){const C=[...r];r=new Set([...C,...k]),l=!0}else r=k;else w=g;else break}}}else for(const w of d){let p=new Set([w]);for(let k=b-1;k>=0;k--){const _=u[k];if(p=this._getCombinedNodes(_,p,i),p.size)k===0&&(r.add(w),s>1&&r.size>1&&(l=!0));else break}}else if(c===n.TARGET_FIRST&&i===E){const{combo:w}=u[0];let p;for(const k of d)if(p=this._matchNodeNext(u,new Set([k]),{combo:w,index:1}),p){r.add(p);break}if(!p&&!h){const{leaves:k}=u[0],[_]=d;let g=this._findNode(k,_);for(;g;){if(p=this._matchNodeNext(u,new Set([g]),{combo:w,index:1}),p){r.add(p);break}g=this._findNode(k,g)}}}else{let w;for(const p of d)if(w=this._matchNodePrev(u,p,{index:b-1}),w){r.add(p);break}if(!w&&!h&&c===n.TARGET_FIRST){const{leaves:p}=u[b],[k]=d;let _=this._findNode(p,k);for(;_;){if(w=this._matchNodePrev(u,_,{index:b-1}),w){r.add(_);break}_=this._findNode(p,_)}}}}}return c===n.TARGET_FIRST?(r.delete(this.#e),r.size>1&&(r=new Set((0,N.sortNodes)(r)))):c===n.TARGET_ALL&&(r.delete(this.#e),l&&r.size>1&&(r=new Set((0,N.sortNodes)(r)))),r}}0&&(module.exports={Finder});
|
|
2
2
|
//# sourceMappingURL=finder.js.map
|