@asamuzakjp/dom-selector 6.0.4 → 6.1.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
@@ -87,6 +87,86 @@ querySelectorAll - equivalent to [Document.querySelectorAll()][69], [DocumentFra
87
87
  Returns **[Array][62]<([object][60] \| [undefined][63])>** array of matched nodes
88
88
 
89
89
 
90
+ ## Monkey patch jsdom
91
+
92
+ ``` javascript
93
+ import { DOMSelector } from '@asamuzakjp/dom-selector';
94
+ import { JSDOM } from 'jsdom';
95
+
96
+ const dom = new JSDOM('', {
97
+ runScripts: 'dangerously',
98
+ url: 'http://localhost/',
99
+ beforeParse: window => {
100
+ const domSelector = new DOMSelector(window);
101
+
102
+ const matches = domSelector.matches.bind(domSelector);
103
+ window.Element.prototype.matches = function (...args) {
104
+ if (!args.length) {
105
+ throw new window.TypeError('1 argument required, but only 0 present.');
106
+ }
107
+ const [selector] = args;
108
+ return matches(selector, this);
109
+ };
110
+
111
+ const closest = domSelector.closest.bind(domSelector);
112
+ window.Element.prototype.closest = function (...args) {
113
+ if (!args.length) {
114
+ throw new window.TypeError('1 argument required, but only 0 present.');
115
+ }
116
+ const [selector] = args;
117
+ return closest(selector, this);
118
+ };
119
+
120
+ const querySelector = domSelector.querySelector.bind(domSelector);
121
+ window.Document.prototype.querySelector = function (...args) {
122
+ if (!args.length) {
123
+ throw new window.TypeError('1 argument required, but only 0 present.');
124
+ }
125
+ const [selector] = args;
126
+ return querySelector(selector, this);
127
+ };
128
+ window.DocumentFragment.prototype.querySelector = function (...args) {
129
+ if (!args.length) {
130
+ throw new window.TypeError('1 argument required, but only 0 present.');
131
+ }
132
+ const [selector] = args;
133
+ return querySelector(selector, this);
134
+ };
135
+ window.Element.prototype.querySelector = function (...args) {
136
+ if (!args.length) {
137
+ throw new window.TypeError('1 argument required, but only 0 present.');
138
+ }
139
+ const [selector] = args;
140
+ return querySelector(selector, this);
141
+ };
142
+
143
+ const querySelectorAll = domSelector.querySelectorAll.bind(domSelector);
144
+ window.Document.prototype.querySelectorAll = function (...args) {
145
+ if (!args.length) {
146
+ throw new window.TypeError('1 argument required, but only 0 present.');
147
+ }
148
+ const [selector] = args;
149
+ return querySelectorAll(selector, this);
150
+ };
151
+ window.DocumentFragment.prototype.querySelectorAll = function (...args) {
152
+ if (!args.length) {
153
+ throw new window.TypeError('1 argument required, but only 0 present.');
154
+ }
155
+ const [selector] = args;
156
+ return querySelectorAll(selector, this);
157
+ };
158
+ window.Element.prototype.querySelectorAll = function (...args) {
159
+ if (!args.length) {
160
+ throw new window.TypeError('1 argument required, but only 0 present.');
161
+ }
162
+ const [selector] = args;
163
+ return querySelectorAll(selector, this);
164
+ };
165
+ }
166
+ });
167
+ ```
168
+
169
+
90
170
  ## Supported CSS selectors
91
171
 
92
172
  |Pattern|Supported|Note|
@@ -113,7 +193,7 @@ Returns **[Array][62]<([object][60] \| [undefined][63])>** array of matched n
113
193
  |E\[foo\|="en"\]|✓| |
114
194
  |E:defined|Partially supported|Matching with MathML is not yet supported.|
115
195
  |E:dir(ltr)|✓| |
116
- |E:lang(en)|Partially supported|Comma-separated list of language codes, e.g. `:lang(en, fr)`, is not yet supported.|
196
+ |E:lang(en)|✓| |
117
197
  |E:any‑link|✓| |
118
198
  |E:link|✓| |
119
199
  |E:visited|✓|Returns `false` or `null` to prevent fingerprinting.|
@@ -198,86 +278,6 @@ class LabeledCheckbox extends window.HTMLElement {
198
278
  ```
199
279
 
200
280
 
201
- ## Monkey patch jsdom
202
-
203
- ``` javascript
204
- import { DOMSelector } from '@asamuzakjp/dom-selector';
205
- import { JSDOM } from 'jsdom';
206
-
207
- const dom = new JSDOM('', {
208
- runScripts: 'dangerously',
209
- url: 'http://localhost/',
210
- beforeParse: window => {
211
- const domSelector = new DOMSelector(window);
212
-
213
- const matches = domSelector.matches.bind(domSelector);
214
- window.Element.prototype.matches = function (...args) {
215
- if (!args.length) {
216
- throw new window.TypeError('1 argument required, but only 0 present.');
217
- }
218
- const [selector] = args;
219
- return matches(selector, this);
220
- };
221
-
222
- const closest = domSelector.closest.bind(domSelector);
223
- window.Element.prototype.closest = function (...args) {
224
- if (!args.length) {
225
- throw new window.TypeError('1 argument required, but only 0 present.');
226
- }
227
- const [selector] = args;
228
- return closest(selector, this);
229
- };
230
-
231
- const querySelector = domSelector.querySelector.bind(domSelector);
232
- window.Document.prototype.querySelector = function (...args) {
233
- if (!args.length) {
234
- throw new window.TypeError('1 argument required, but only 0 present.');
235
- }
236
- const [selector] = args;
237
- return querySelector(selector, this);
238
- };
239
- window.DocumentFragment.prototype.querySelector = function (...args) {
240
- if (!args.length) {
241
- throw new window.TypeError('1 argument required, but only 0 present.');
242
- }
243
- const [selector] = args;
244
- return querySelector(selector, this);
245
- };
246
- window.Element.prototype.querySelector = function (...args) {
247
- if (!args.length) {
248
- throw new window.TypeError('1 argument required, but only 0 present.');
249
- }
250
- const [selector] = args;
251
- return querySelector(selector, this);
252
- };
253
-
254
- const querySelectorAll = domSelector.querySelectorAll.bind(domSelector);
255
- window.Document.prototype.querySelectorAll = function (...args) {
256
- if (!args.length) {
257
- throw new window.TypeError('1 argument required, but only 0 present.');
258
- }
259
- const [selector] = args;
260
- return querySelectorAll(selector, this);
261
- };
262
- window.DocumentFragment.prototype.querySelectorAll = function (...args) {
263
- if (!args.length) {
264
- throw new window.TypeError('1 argument required, but only 0 present.');
265
- }
266
- const [selector] = args;
267
- return querySelectorAll(selector, this);
268
- };
269
- window.Element.prototype.querySelectorAll = function (...args) {
270
- if (!args.length) {
271
- throw new window.TypeError('1 argument required, but only 0 present.');
272
- }
273
- const [selector] = args;
274
- return querySelectorAll(selector, this);
275
- };
276
- }
277
- });
278
- ```
279
-
280
-
281
281
  ## Performance
282
282
 
283
283
  See [benchmark](https://github.com/asamuzaK/domSelector/actions/workflows/benchmark.yml) for the latest results.
@@ -1,2 +1,2 @@
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});
1
+ var p=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var F=(o,t)=>{for(var n in t)p(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&&p(o,s,{get:()=>t[s],enumerable:!(L=R(t,s))||L.enumerable});return o};var U=o=>M(p({},"__esModule",{value:!0}),o);var bt={};F(bt,{ALPHA_NUM:()=>I,ANB:()=>A,ATTR_SELECTOR:()=>d,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:()=>b,COMBINATOR:()=>G,COMBO:()=>T,COMPLEX:()=>_,COMPLEX_L:()=>S,COMPOUND:()=>c,COMPOUND_A:()=>O,COMPOUND_B:()=>N,COMPOUND_I:()=>Pt,DESCEND:()=>Dt,DIGIT:()=>E,DOCUMENT_FRAGMENT_NODE:()=>pt,DOCUMENT_NODE:()=>Et,DOCUMENT_POSITION_CONTAINED_BY:()=>_t,DOCUMENT_POSITION_CONTAINS:()=>Tt,DOCUMENT_POSITION_PRECEDING:()=>xt,DUO:()=>tt,ELEMENT_NODE:()=>ct,HEX:()=>ot,HYPHEN:()=>et,IDENT:()=>Y,ID_SELECTOR:()=>m,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:()=>dt,LANG_PART:()=>Ct,LOGICAL_COMPLEX:()=>$t,LOGICAL_COMPOUND:()=>Rt,NESTED_LOGICAL_A:()=>l,NESTED_LOGICAL_B:()=>D,NOT_SUPPORTED_ERR:()=>f,NTH:()=>B,N_TH:()=>lt,OPERATOR:()=>u,PSEUDO_CLASS:()=>At,PS_CLASS_SELECTOR:()=>h,PS_ELEMENT_SELECTOR:()=>H,SELECTOR:()=>y,SHOW_ALL:()=>Ot,SHOW_DOCUMENT:()=>Nt,SHOW_DOCUMENT_FRAGMENT:()=>St,SHOW_ELEMENT:()=>Lt,STRING:()=>k,SUB_TYPE:()=>r,SYNTAX_ERR:()=>z,TAG_TYPE:()=>e,TAG_TYPE_I:()=>x,TARGET_ALL:()=>K,TARGET_FIRST:()=>j,TARGET_LINEAL:()=>X,TARGET_SELF:()=>w,TEXT_NODE:()=>nt,TYPE_FROM:()=>st,TYPE_SELECTOR:()=>W,TYPE_TO:()=>rt,WALKER_FILTER:()=>It});module.exports=U(bt);const d="AttributeSelector",b="ClassSelector",G="Combinator",Y="Identifier",m="IdSelector",f="NotSupportedError",B="Nth",u="Operator",h="PseudoClassSelector",H="PseudoElementSelector",y="Selector",k="String",z="SyntaxError",K="all",j="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,Et=9,pt=11,xt=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)",E="(?:0|[1-9]\\d*)",Ct=`(?:-${I})*`,At=`(?:any-)?link|${C}|checked|empty|indeterminate|root|target|visited`,A=`[+-]?(?:${E}n?|n)|(?:[+-]?${E})?n\\s*[+-]\\s*${E}`,lt=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${A})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",x="\\*|[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=`(?:${x}|(?:${x})?(?:${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"]),dt=Object.freeze(["Alt","AltGraph","CapsLock","Control","Fn","FnLock","Hyper","Meta","NumLock","ScrollLock","Shift","Super","Symbol","SymbolLock"]);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,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 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"]
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": "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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", "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"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var C=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var F=(x,c)=>{for(var e in c)C(x,e,{get:c[e],enumerable:!0})},W=(x,c,e,o)=>{if(c&&typeof c=="object"||typeof c=="function")for(let n of D(c))!U.call(x,n)&&n!==e&&C(x,n,{get:()=>c[n],enumerable:!(o=P(c,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"),y=require("./parser.js"),N=require("./utility.js"),r=require("./constant.js");const v="next",E="prev";class ${#a;#n;#k;#t;#h;#r;#N;#c;#m;#o;#d;#e;#u;#g;#p;#_;#s;#b;#y;#f;#w;#i;#l;constructor(c){this.#l=c,this.#d=new O.Matcher,this.#n=new WeakMap,this.#h=new WeakMap,this.#m=new WeakMap,this.#_=new WeakMap,this.#r=null,this.#N=null,this.#o=null,this._registerEventListeners()}onError(c,e){if(!(e?.noexcept??this.#g))if(c instanceof DOMException||c instanceof this.#l.DOMException)if(c.name===r.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:n,warn:a}=o;return this.#g=!!n,this.#i=!!a,this.#e=e,[this.#t,this.#s,this.#f]=(0,N.resolveContent)(e),this.#b=(0,N.isInShadowTree)(e),[this.#a,this.#u]=this._correspond(c),this.#m=new WeakMap,this.#w=new WeakMap,this.#y=null,this}_registerEventListeners(){const c={capture:!0,passive:!0},e=[],o=["mouseover","mousedown","mouseup","mouseout"];for(const l of o)e.push(this.#l.addEventListener(l,f=>{this.#r=f},c));const n=["keydown","keyup"];for(const l of n)e.push(this.#l.addEventListener(l,f=>{f.key==="Tab"&&(this.#r=f)},c));const a=["focus","focusin"];for(const l of a)e.push(this.#l.addEventListener(l,f=>{this.#N=f},c));return e}_correspond(c){const e=[];this.#k=!1,this.#c=!1;let o;if(this.#h.has(this.#t)){const n=this.#h.get(this.#t);if(n&&n.has(`${c}`)){const a=n.get(`${c}`);o=a.ast,this.#k=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,y.parseSelector)(c)}catch(b){this.onError(b)}const{branches:a,info:l}=(0,y.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!==r.COMBINATOR){const w=new Set;for(;p;){let k=p.name;if(p.type===r.COMBINATOR){const[_]=b;if(_.type===r.COMBINATOR)throw new DOMException(`Invalid selector ${c}`,r.SYNTAX_ERR);k==="+"||k==="~"?i=!0:t=!0,m.push({combo:p,leaves:(0,y.sortAST)(w)}),w.clear()}else p&&(k&&typeof k=="string"&&(k=(0,y.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,y.sortAST)(w)}),w.clear();break}}}o.push({branch:m,collected:!1,dir:null,filtered:!1,find:!1}),e[s]=[],s++}let h;this.#h.has(this.#t)?h=this.#h.get(this.#t):h=new Map,h.set(`${c}`,{ast:o,descendant:t,invalidate:i}),this.#h.set(this.#t,h),this.#k=t,this.#c=i}return[o,e]}_createTreeWalker(c){let e;return this.#w.has(c)?e=this.#w.get(c):(e=this.#t.createTreeWalker(c,r.WALKER_FILTER),this.#w.set(c,e)),e}_prepareQuerySelectorWalker(){return this.#p=this._createTreeWalker(this.#e),this.#p}_collectNthChild(c,e,o){const{a:n,b:a,reverse:l,selector:f}=c,{parentNode:u}=e,d=new Set;let i;if(f){if(this.#n.has(f))i=this.#n.get(f);else{const{branches:s}=(0,y.walkAST)(f);i=s,this.#c||this.#n.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 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(c,e){const{a:o,b:n,reverse:a}=c,{localName:l,namespaceURI:f,parentNode:u,prefix:d}=e,i=new Set;if(u){const t=this.#f;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(c,e,o,n){const{nth:{a,b:l,name:f},selector:u}=c,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(c,e,o){let n;if(Array.isArray(c)&&c.length){const a=[...c],[l]=a,{type:f}=l;let u;f===r.COMBINATOR?u=a.shift():u={name:" ",type:r.COMBINATOR};const d=[];for(;a.length;){const[s]=a,{type:h}=s;if(h===r.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(c,e,o){const{astName:n,branches:a,twigBranches:l}=c,{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.#y)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=E;for(const _ of m){const g=this._matchCombinator(w,_,o);g.size&&k.push(...g)}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(c,e,o){const{children:n,name:a}=c,{localName:l,parentNode:f}=e,{forgive:u,warn:d=this.#i}=o,i=new Set;if(r.KEY_LOGICAL.includes(a)){let t;if(this.#n.has(c))t=this.#n.get(c);else{const{branches:h}=(0,y.walkAST)(c);if(a==="has"){for(const b of n){const m=(0,y.findAST)(b,p=>r.KEY_LOGICAL.includes(p.name)&&(0,y.findAST)(p,w=>w.name==="has")?p:null);if(m){const p=m.name;if(p==="is"||p==="where")return i;{const w=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${w}`,r.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===r.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.#n.set(c,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.#d.matchSelector(c,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.#l.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}()`,r.NOT_SUPPORTED_ERR);break}case"host":case"host-context":break;case"contains":{if(d)throw new DOMException(`Unknown pseudo-class :${a}()`,r.NOT_SUPPORTED_ERR);break}default:if(!u)throw new DOMException(`Unknown pseudo-class :${a}()`,r.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.#r??{};["mousedown","mouseover","mouseup"].includes(s)&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:h}=this.#r??{};h==="mousedown"&&t&r.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===r.ELEMENT_NODE?!this.#b&&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{relatedTarget:s,target:h}=this.#N??{};if(h===e)if((0,N.isFocusVisible)(s))t=!0;else if(this.#r){const{key:b,target:m,type:p}=this.#r;(b==="Tab"&&(p==="keydown"&&m!==e||p==="keyup"&&m===e)||!this.#o||s===this.#o)&&(t=!0)}else(s===null||s===this.#o)&&(t=!0)}t?(this.#o=e,i.add(e)):this.#o===e&&(this.#o=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":{(l==="details"||l==="dialog")&&(e.hasAttribute("open")?a==="open"&&i.add(e):a==="closed"&&i.add(e));break}case"disabled":case"enabled":{if([...r.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.#f;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===r.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||r.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")?[...r.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.#f;let w=(0,N.traverseNode)(m,p);for(w=p.firstChild();w&&m.contains(w);){const k=w.localName,_=w.getAttribute("type");let g;if(k==="button"?g=!(w.hasAttribute("type")&&s.includes(_)):k==="input"&&(g=w.hasAttribute("type")&&h.includes(_)),g){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=[...r.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.#f;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=[...r.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=[...r.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,r.SHOW_ALL);let s=t.firstChild(),h;for(;s&&(h=s.nodeType!==r.ELEMENT_NODE&&s.nodeType!==r.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.#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(d)throw new DOMException(`Unsupported pseudo-element ::${a}`,r.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}`,r.NOT_SUPPORTED_ERR);break}default:if(a.startsWith("-webkit-")){if(d)throw new DOMException(`Unsupported pseudo-class :${a}`,r.NOT_SUPPORTED_ERR)}else if(!u)throw new DOMException(`Unknown pseudo-class :${a}`,r.SYNTAX_ERR)}return i}_matchShadowHostPseudoClass(c,e){const{children:o,name:n}=c;let a;if(Array.isArray(o)){const{branches:l}=(0,y.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===r.COMBINATOR){const h=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${h}`,r.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===r.COMBINATOR){const b=(0,y.generateCSS)(c);throw new DOMException(`Invalid selector ${b}`,r.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}`,r.SYNTAX_ERR)}return a??null}_matchSelector(c,e,o={}){const{type:n}=c,a=new Set;if(c.name===r.EMPTY)return a;const l=(0,y.unescapeSelector)(c.name);if(typeof l=="string"&&l!==c.name&&(c.name=l),e.nodeType===r.ELEMENT_NODE)switch(n){case r.PS_ELEMENT_SELECTOR:{this.#d.matchPseudoElementSelector(l,o);break}case r.ID_SELECTOR:{e.id===l&&a.add(e);break}case r.CLASS_SELECTOR:{e.classList.contains(l)&&a.add(e);break}case r.PS_CLASS_SELECTOR:return this._matchPseudoClassSelector(c,e,o);default:{const f=this.#d.matchSelector(c,e,o,!0);f&&a.add(f)}}else if(this.#b&&n===r.PS_CLASS_SELECTOR&&e.nodeType===r.DOCUMENT_FRAGMENT_NODE){if(r.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.#y=!0,a.add(f))}}return a}_matchLeaves(c,e,o){let n,a;if(this.#c?a=this.#m.get(c):a=this.#_.get(c),a&&a.has(e)){const{matched:l}=a.get(e);n=l}if(typeof n!="boolean"){let l=!0;const f=[...r.KEY_FORM_FOCUS,"fieldset","form"],u=["any-link","defined","dir","link"];e.nodeType===r.ELEMENT_NODE&&f.includes(e.localName)&&(l=!1);for(const d of c){switch(d.type){case r.ATTR_SELECTOR:case r.ID_SELECTOR:{l=!1;break}case r.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.#m.set(c,a):this.#_.set(c,a))}return!!n}_matchHTMLCollection(c,e){const{compound:o,filterLeaves:n}=e,a=new Set,l=c.length;if(l)if(o)for(let f=0;f<l;f++){const u=c[f];this._matchLeaves(n,u,e)&&a.add(u)}else{const f=[].slice.call(c);return new Set(f)}return a}_findDescendantNodes(c,e,o){const[n,...a]=c,l=a.length>0,{type:f}=n,u=(0,y.unescapeSelector)(n.name);typeof u=="string"&&u!==n.name&&(n.name=u);let d=new Set,i=!1;if(this.#b)i=!0;else switch(f){case r.PS_ELEMENT_SELECTOR:{this.#d.matchPseudoElementSelector(u,o);break}case r.ID_SELECTOR:{if(this.#s.nodeType===r.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 r.CLASS_SELECTOR:{const t=e.getElementsByClassName(u);d=this._matchHTMLCollection(t,{compound:l,filterLeaves:a});break}case r.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(c,e,o){const{combo:n,leaves:a}=c,{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(c,e){const o=this.#p;let n=(0,N.traverseNode)(e,o),a;if(n)for((n.nodeType!==r.ELEMENT_NODE||n===e&&n!==this.#s)&&(n=o.nextNode());n;){if(this._matchLeaves(c,n,{warn:this.#i})){a=n;break}n=o.nextNode()}return a??null}_matchSelf(c){const e=[],o=this._matchLeaves(c,this.#e,{warn:this.#i});let n=!1;return o&&(e.push(this.#e),n=!0),[e,n]}_findLineal(c,e){const{complex:o}=e,n=[];let a=this._matchLeaves(c,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(c,f,{warn:this.#i}),a&&(n.push(f),l=!0),f.parentNode);)f=f.parentNode}return[n,l]}_findFirst(c){const e=[],o=this._findNode(c,this.#e);let n=!1;return o&&(e.push(o),n=!0),[e,n]}_findFromHTMLCollection(c,e){const{complex:o,compound:n,filterLeaves:a,targetType:l}=e;let f=[],u=!1,d=!1;const i=c.length;if(i)if(this.#e.nodeType===r.ELEMENT_NODE)for(let t=0;t<i;t++){const s=c[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===r.TARGET_FIRST))break}else if(f.push(s),u=!0,l===r.TARGET_FIRST)break}}else if(o)if(n)for(let t=0;t<i;t++){const s=c[t];if(this._matchLeaves(a,s,{warn:this.#i})&&(f.push(s),u=!0,l===r.TARGET_FIRST))break}else f=[].slice.call(c),u=!0,d=!0;else if(n)for(let t=0;t<i;t++){const s=c[t];if(this._matchLeaves(a,s,{warn:this.#i})&&(f.push(s),u=!0,l===r.TARGET_FIRST))break}else f=[].slice.call(c),u=!0,d=!0;return[f,u,d]}_findEntryNodes(c,e,o){const{leaves:n}=c,[a,...l]=n,f=l.length>0,{name:u,type:d}=a;let i=[],t=!1,s=!1,h=!1;switch(d){case r.PS_ELEMENT_SELECTOR:{this.#d.matchPseudoElementSelector(u,{warn:this.#i});break}case r.ID_SELECTOR:{if(e===r.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===r.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:o});else if(e===r.TARGET_FIRST&&this.#s.nodeType!==r.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===r.TARGET_FIRST?[i,s]=this._findFirst(n):h=!0;break}case r.CLASS_SELECTOR:{if(e===r.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===r.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:o});else if(this.#s.nodeType===r.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===r.TARGET_FIRST?[i,s]=this._findFirst(n):h=!0;break}case r.TYPE_SELECTOR:{if(e===r.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===r.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:o});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===r.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===r.TARGET_FIRST?[i,s]=this._findFirst(n):h=!0;break}default:if(e!==r.TARGET_LINEAL&&(u==="host"||u==="host-context")){if(this.#b&&this.#e.nodeType===r.DOCUMENT_FRAGMENT_NODE){const b=this._matchShadowHostPseudoClass(a,this.#e);b&&(i.push(b),s=!0)}}else e===r.TARGET_SELF?[i,s]=this._matchSelf(n):e===r.TARGET_LINEAL?[i,s]=this._findLineal(n,{complex:o}):e===r.TARGET_FIRST?[i,s]=this._findFirst(n):h=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:h}}_collectNodes(c){const e=this.#a.values();if(c===r.TARGET_ALL||c===r.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:g,type:L}]}=_;if(L===r.PS_ELEMENT_SELECTOR||L===r.ID_SELECTOR)d=E,i=_;else if(k===r.PS_ELEMENT_SELECTOR||k===r.ID_SELECTOR)d=v,i=u;else if(c===r.TARGET_ALL)if(w==="*"&&k===r.TYPE_SELECTOR)d=E,i=_;else if(g==="*"&&L===r.TYPE_SELECTOR)d=v,i=u;else if(l===2){const{name:S}=p;S==="+"||S==="~"?(d=E,i=_):(d=v,i=u)}else d=v,i=u;else if(w==="*"&&k===r.TYPE_SELECTOR)d=E,i=_;else if(g==="*"&&L===r.TYPE_SELECTOR)d=v,i=u;else{let S;for(const{combo:T,leaves:[M]}of a){const{name:R,type:I}=M;if(I===r.PS_CLASS_SELECTOR&&R==="dir"){S=!1;break}if(!S&&T){const{name:A}=T;(A==="+"||A==="~")&&(S=!0)}}S?(d=v,i=u):(d=E,i=_)}}else d=E,i=u;const{collected:t,compound:s,filtered:h,nodes:b,pending:m}=this._findEntryNodes(i,c,f);b.length?(this.#a[n].find=!0,this.#u[n]=b):m&&o.add(new Map([["index",n],["twig",i]])),this.#a[n].collected=t,this.#a[n].dir=d,this.#a[n].filtered=h||!s,n++}if(o.size){let a,l;this.#e!==this.#s&&this.#e.nodeType===r.ELEMENT_NODE?(a=this.#e,l=this.#p):(a=this.#s,l=this.#f);let f=(0,N.traverseNode)(a,l);for(;f;){let u=!1;if(this.#e.nodeType===r.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.#a[s].filtered=!0,this.#a[s].find=!0,this.#u[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,c,l);d.length&&(this.#a[o].find=!0,this.#u[o]=d),this.#a[o].dir=E,this.#a[o].filtered=u||!f,o++}}return[this.#a,this.#u]}_getCombinedNodes(c,e,o){const n=[];for(const a of e){const l=this._matchCombinator(c,a,{dir:o,warn:this.#i});l.size&&n.push(...l)}return n.length?new Set(n):new Set}_matchNodeNext(c,e,o){const{combo:n,index:a}=o,{combo:l,leaves:f}=c[a],u={combo:n,leaves:f},d=this._getCombinedNodes(u,e,v);let i;if(d.size)if(a===c.length-1){const[t]=(0,N.sortNodes)(d);i=t}else i=this._matchNodeNext(c,d,{combo:l,index:a+1});return i??null}_matchNodePrev(c,e,o){const{index:n}=o,a=c[n],l=new Set([e]),f=this._getCombinedNodes(a,l,E);let u;if(f.size){if(n===0)u=e;else for(const d of f)if(this._matchNodePrev(c,d,{index:n-1}))return e}return u??null}find(c){(c===r.TARGET_ALL||c===r.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],o]=this._collectNodes(c),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((c===r.TARGET_ALL||c===r.TARGET_FIRST)&&this.#e.nodeType===r.ELEMENT_NODE)for(let p=0;p<b;p++){const w=h[p];if(w!==this.#e&&this.#e.contains(w)&&(l.add(w),c===r.TARGET_FIRST))break}else if(c===r.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(c===r.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:g,leaves:L}=u[_],S={combo:p,leaves:L};if(k=this._getCombinedNodes(S,k,i),k.size)if(_===m)if(l.size){const T=[...l];l=new Set([...T,...k]),a=!0}else l=k;else p=g;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(c===r.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 g=this._findNode(k,_);for(;g;){if(w=this._matchNodeNext(u,new Set([g]),{combo:p,index:1}),w){l.add(w);break}g=this._findNode(k,g)}}}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&&c===r.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 c===r.TARGET_FIRST?(l.delete(this.#e),l.size>1&&(l=new Set((0,N.sortNodes)(l)))):c===r.TARGET_ALL&&(l.delete(this.#e),a&&l.size>1&&(l=new Set((0,N.sortNodes)(l)))),l}}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"),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});
2
2
  //# sourceMappingURL=finder.js.map