Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@asamuzakjp/dom-selector

Package Overview
Dependencies
Maintainers
1
Versions
191
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asamuzakjp/dom-selector - npm Package Compare versions

Comparing version 5.0.2 to 5.0.3

2

dist/cjs/index.js

@@ -6,3 +6,3 @@ var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var E=(f,e)=>{for(var t in e)p(f,t,{get:e[t],enumerable:!0})},_=(f,e,t,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of a(e))!T.call(f,i)&&i!==t&&p(f,i,{get:()=>e[i],enumerable:!(c=u(e,i))||c.enumerable});return f};var d=f=>_(p({},"__esModule",{value:!0}),f);var x={};E(x,{DOMSelector:()=>y});module.exports=d(x);var l=require("./js/dom-util.js"),m=require("./js/finder.js"),h=require("./js/nwsapi.js"),s=require("./js/constant.js");/*!

* @see {@link https://github.com/asamuzaK/domSelector/blob/main/LICENSE}
*/class y extends m.Finder{#t;#e;constructor(e,t){super(e),this.#t=t??e.document,this.#e=(0,h.initNwsapi)(e,t)}matches(e,t,c){let i;try{if(t?.nodeType!==s.ELEMENT_NODE){const n=`Unexpected node ${t?.nodeName}`;throw new TypeError(n)}const r=t.ownerDocument;if(r===this.#t&&r.contentType==="text/html"){const n={complex:s.REG_COMPLEX.test(e),descendant:!0,target:s.TARGET_SELF};if((0,h.filterSelector)(e,n))return this.#e.match(e,t)}this._setup(e,t,c),i=this._find(s.TARGET_SELF).size}catch(r){this._onError(r)}return!!i}closest(e,t,c){let i;try{if(t?.nodeType!==s.ELEMENT_NODE){const n=`Unexpected node ${t?.nodeName}`;throw new TypeError(n)}const r=t.ownerDocument;if(r===this.#t&&r.contentType==="text/html"){const n={complex:s.REG_COMPLEX.test(e),descendant:!0,target:s.TARGET_LINEAL};if((0,h.filterSelector)(e,n))return this.#e.closest(e,t)}this._setup(e,t,c);const o=this._find(s.TARGET_LINEAL);if(o.size){let n=t;for(;n;){if(o.has(n)){i=n;break}n=n.parentNode}}}catch(r){this._onError(r)}return i??null}querySelector(e,t,c){let i;try{let r;if(t?.nodeType===s.DOCUMENT_NODE?r=t:r=t?.ownerDocument,r===this.#t&&r?.contentType==="text/html"&&(0,h.filterSelector)(e,{complex:!1,descendant:!1,target:s.TARGET_FIRST}))return this.#e.first(e,t);this._setup(e,t,c);const o=this._find(s.TARGET_FIRST);o.delete(t),o.size&&([i]=(0,l.sortNodes)(o))}catch(r){this._onError(r)}return i??null}querySelectorAll(e,t,c){let i;try{let r;if(t?.nodeType===s.DOCUMENT_NODE?r=t:r=t?.ownerDocument,r===this.#t&&r?.contentType==="text/html"&&(0,h.filterSelector)(e,{complex:!1,descendant:!0,target:s.TARGET_ALL}))return this.#e.select(e,t);this._setup(e,t,c);const o=this._find(s.TARGET_ALL);o.delete(t),o.size&&(i=[...o])}catch(r){this._onError(r)}return i??[]}}0&&(module.exports={DOMSelector});
*/class y extends m.Finder{#t;#e;constructor(e,t){super(e),this.#t=t??e.document,this.#e=(0,h.initNwsapi)(e,t)}matches(e,t,c){let i;try{if(t?.nodeType!==s.ELEMENT_NODE){const n=`Unexpected node ${t?.nodeName}`;throw new TypeError(n)}const r=t.ownerDocument;if(r===this.#t&&r.contentType==="text/html"){const n={complex:s.REG_COMPLEX.test(e),descendant:!0,target:s.TARGET_SELF};if((0,h.filterSelector)(e,n))return this.#e.match(e,t)}this._setup(e,t,c),i=this._find(s.TARGET_SELF).size}catch(r){this._onError(r)}return!!i}closest(e,t,c){let i;try{if(t?.nodeType!==s.ELEMENT_NODE){const n=`Unexpected node ${t?.nodeName}`;throw new TypeError(n)}const r=t.ownerDocument;if(r===this.#t&&r.contentType==="text/html"){const n={complex:s.REG_COMPLEX.test(e),descendant:!0,target:s.TARGET_LINEAL};if((0,h.filterSelector)(e,n))return this.#e.closest(e,t)}this._setup(e,t,c);const o=this._find(s.TARGET_LINEAL);if(o.size){let n=t;for(;n;){if(o.has(n)){i=n;break}n=n.parentNode}}}catch(r){this._onError(r)}return i??null}querySelector(e,t,c){let i;try{let r;if(t?.nodeType===s.DOCUMENT_NODE?r=t:r=t?.ownerDocument,r===this.#t&&r.contentType==="text/html"&&(0,h.filterSelector)(e,{complex:!1,descendant:!1,target:s.TARGET_FIRST}))return this.#e.first(e,t);this._setup(e,t,c);const o=this._find(s.TARGET_FIRST);o.delete(t),o.size&&([i]=(0,l.sortNodes)(o))}catch(r){this._onError(r)}return i??null}querySelectorAll(e,t,c){let i;try{let r;if(t?.nodeType===s.DOCUMENT_NODE?r=t:r=t?.ownerDocument,r===this.#t&&r.contentType==="text/html"&&(0,h.filterSelector)(e,{complex:!1,descendant:!0,target:s.TARGET_ALL}))return this.#e.select(e,t);this._setup(e,t,c);const o=this._find(s.TARGET_ALL);o.delete(t),o.size&&(i=[...o])}catch(r){this._onError(r)}return i??[]}}0&&(module.exports={DOMSelector});
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

var O=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var Y=(o,t)=>{for(var n in t)O(o,n,{get:t[n],enumerable:!0})},H=(o,t,n,N)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of U(t))!d.call(o,s)&&s!==n&&O(o,s,{get:()=>t[s],enumerable:!(N=F(t,s))||N.enumerable});return o};var u=o=>H(O({},"__esModule",{value:!0}),o);var qt={};Y(qt,{ALPHA_NUM:()=>R,ANB:()=>D,AN_PLUS_B:()=>B,BIT_01:()=>et,BIT_02:()=>st,BIT_04:()=>rt,BIT_08:()=>Et,BIT_16:()=>nt,BIT_32:()=>ct,BIT_FFFF:()=>xt,BIT_HYPHEN:()=>_t,CHILD_IDX:()=>I,COMBINATOR:()=>m,COMBO:()=>T,COMPLEX:()=>L,COMPLEX_L:()=>C,COMPOUND:()=>E,COMPOUND_A:()=>A,COMPOUND_B:()=>S,COMPOUND_I:()=>i,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>St,DOCUMENT_NODE:()=>At,DOCUMENT_POSITION_CONTAINED_BY:()=>It,DOCUMENT_POSITION_CONTAINS:()=>Nt,DOCUMENT_POSITION_PRECEDING:()=>Ct,DUO:()=>pt,ELEMENT_NODE:()=>$t,EMPTY:()=>w,HEX:()=>Tt,IDENTIFIER:()=>g,LANG_PART:()=>G,LOGICAL_COMPLEX:()=>a,LOGICAL_COMPOUND:()=>M,LOGICAL_KEY:()=>p,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>l,NOT_SUPPORTED_ERR:()=>h,NTH:()=>X,N_TH:()=>_,PSEUDO_CLASSES:()=>x,RAW:()=>f,REG_ANCHOR:()=>at,REG_CHILD_INDEXED:()=>Mt,REG_COMPLEX:()=>Ft,REG_DIR:()=>Ut,REG_FORM:()=>dt,REG_FORM_CTRL:()=>Yt,REG_FORM_VALID:()=>Ht,REG_HEX:()=>ut,REG_INTERACT:()=>Bt,REG_INVALID_SELECTOR:()=>mt,REG_LANG:()=>wt,REG_LANG_QUOTED:()=>gt,REG_LOGICAL_COMPLEX:()=>ht,REG_LOGICAL_COMPOUND:()=>Xt,REG_LOGICAL_EMPTY:()=>ft,REG_LOGICAL_KEY:()=>bt,REG_LOGICAL_PSEUDO:()=>Wt,REG_SHADOW_HOST:()=>yt,REG_SHADOW_MODE:()=>kt,REG_SHADOW_PSEUDO:()=>Kt,REG_TYPE_CHECK:()=>Zt,REG_TYPE_DATE:()=>vt,REG_TYPE_RANGE:()=>zt,REG_TYPE_RESET:()=>Vt,REG_TYPE_SUBMIT:()=>Qt,REG_TYPE_TEXT:()=>jt,SELECTOR:()=>b,SELECTOR_ATTR:()=>W,SELECTOR_CLASS:()=>y,SELECTOR_ID:()=>k,SELECTOR_LIST:()=>K,SELECTOR_PSEUDO_CLASS:()=>Z,SELECTOR_PSEUDO_ELEMENT:()=>v,SELECTOR_TYPE:()=>z,SHOW_ALL:()=>Gt,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Pt,SHOW_ELEMENT:()=>lt,STRING:()=>V,SUB_TYPE:()=>r,SYNTAX_ERR:()=>Q,TAG_TYPE:()=>e,TAG_TYPE_I:()=>$,TARGET_ALL:()=>j,TARGET_FIRST:()=>q,TARGET_LINEAL:()=>J,TARGET_SELF:()=>tt,TEXT_NODE:()=>Lt,TYPE_FROM:()=>Ot,TYPE_TO:()=>Rt,U_FFFD:()=>ot,WALKER_FILTER:()=>it});module.exports=u(qt);const B="AnPlusB",m="Combinator",w="__EMPTY__",g="Identifier",h="NotSupportedError",X="Nth",f="Raw",b="Selector",W="AttributeSelector",y="ClassSelector",k="IdSelector",K="SelectorList",Z="PseudoClassSelector",v="PseudoElementSelector",z="TypeSelector",V="String",Q="SyntaxError",j="all",q="first",J="lineal",tt="self",ot="\uFFFD",et=1,st=2,rt=4,Et=8,nt=16,ct=32,xt=65535,_t=45,pt=2,Tt=16,Ot=8,Rt=-1,$t=1,Lt=3,At=9,St=11,Ct=2,Nt=8,It=16,Gt=4294967295,Dt=256,Pt=1024,lt=1,it=1281,R="[A-Z\\d]+",I="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",G=`(?:-${R})*`,x=`(?:any-)?link|${I}|checked|empty|indeterminate|root|target|visited`,D=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,_=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${D})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",$="\\*|[A-Z][\\w-]*",p="(?:is|not)",E=`(?:${e}|(?:${e})?(?:${r})+)`,T="\\s?[\\s>~+]\\s?",L=`${E}(?:${T}${E})*`,P=`:is\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,l=`:is\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,A=`(?:${e}|(?:${e})?(?:${r}|${P})+)`,S=`(?:${e}|(?:${e})?(?:${r}|${l})+)`,i=`(?:${$}|(?:${$})?(?:${r})+)`,C=`${S}(?:${T}${S})*`,a=`${p}\\(\\s*${C}(?:\\s*,\\s*${C})*\\s*\\)`,M=`${p}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,at=/^a(?:rea)?$/,Mt=new RegExp(`:(?!${x}|${_})`),Ft=new RegExp(`${T}${i}`,"i"),Ut=/^(?:ltr|rtl)$/,dt=/^(?:button|fieldset|form|input|select|textarea)$/,Yt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Ht=/^(?:button|form|input|select|textarea)$/,ut=/^([\da-f]{1,6}\s?)/i,Bt=/^(?:details|dialog)$/,mt=/^$|^\s*>|,\s*$/,wt=new RegExp(`^(?:\\*-)?${R}${G}$`,"i"),gt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,ht=new RegExp(`:(?!${x}|${_}|${a})`),Xt=new RegExp(`:(?!${x}|${_}|${M})`),ft=/(:(is|where)\(\s*\))/,bt=new RegExp(`:${p}\\(`),Wt=/^(?:has|is|not|where)$/,yt=/^host(?:-context)?$/,kt=/^(?:close|open)$/,Kt=/^part|slotted$/,Zt=/^(?:checkbox|radio)$/,vt=/^(?:date(?:time-local)?|month|time|week)$/,zt=/(?:date(?:time-local)?|month|number|range|time|week)$/,Vt=/^(?:button|reset)$/,Qt=/^(?:image|submit)$/,jt=/^(?:email|number|password|search|tel|text|url)$/;0&&(module.exports={ALPHA_NUM,ANB,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,BIT_HYPHEN,CHILD_IDX,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,LOGICAL_KEY,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_CHILD_INDEXED,REG_COMPLEX,REG_DIR,REG_FORM,REG_FORM_CTRL,REG_FORM_VALID,REG_HEX,REG_INTERACT,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_COMPLEX,REG_LOGICAL_COMPOUND,REG_LOGICAL_EMPTY,REG_LOGICAL_KEY,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TYPE_CHECK,REG_TYPE_DATE,REG_TYPE_RANGE,REG_TYPE_RESET,REG_TYPE_SUBMIT,REG_TYPE_TEXT,SELECTOR,SELECTOR_ATTR,SELECTOR_CLASS,SELECTOR_ID,SELECTOR_LIST,SELECTOR_PSEUDO_CLASS,SELECTOR_PSEUDO_ELEMENT,SELECTOR_TYPE,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,STRING,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER});
var O=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var Y=(o,t)=>{for(var r in t)O(o,r,{get:t[r],enumerable:!0})},H=(o,t,r,I)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of d(t))!U.call(o,s)&&s!==r&&O(o,s,{get:()=>t[s],enumerable:!(I=F(t,s))||I.enumerable});return o};var u=o=>H(O({},"__esModule",{value:!0}),o);var Jt={};Y(Jt,{ALPHA_NUM:()=>R,ANB:()=>D,AN_PLUS_B:()=>B,BIT_01:()=>et,BIT_02:()=>st,BIT_04:()=>nt,BIT_08:()=>Et,BIT_16:()=>rt,BIT_32:()=>ct,BIT_FFFF:()=>xt,BIT_HYPHEN:()=>_t,CHILD_IDX:()=>N,COMBINATOR:()=>m,COMBO:()=>T,COMPLEX:()=>L,COMPLEX_L:()=>C,COMPOUND:()=>E,COMPOUND_A:()=>A,COMPOUND_B:()=>S,COMPOUND_I:()=>l,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>St,DOCUMENT_NODE:()=>At,DOCUMENT_POSITION_CONTAINED_BY:()=>Nt,DOCUMENT_POSITION_CONTAINS:()=>It,DOCUMENT_POSITION_PRECEDING:()=>Ct,DUO:()=>pt,ELEMENT_NODE:()=>$t,EMPTY:()=>h,HEX:()=>Tt,IDENTIFIER:()=>w,LANG_PART:()=>G,LOGICAL_COMPLEX:()=>a,LOGICAL_COMPOUND:()=>M,LOGICAL_KEY:()=>p,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>i,NOT_SUPPORTED_ERR:()=>g,NTH:()=>f,N_TH:()=>_,PSEUDO_CLASSES:()=>x,RAW:()=>X,REG_ANCHOR:()=>at,REG_CHILD_INDEXED:()=>Mt,REG_COMPLEX:()=>Ft,REG_DIR:()=>dt,REG_FORM:()=>Ut,REG_FORM_CTRL:()=>Yt,REG_FORM_VALID:()=>Ht,REG_HEX:()=>ut,REG_INTERACT:()=>Bt,REG_INVALIDATE_PSEUDO:()=>mt,REG_INVALID_SELECTOR:()=>ht,REG_LANG:()=>wt,REG_LANG_QUOTED:()=>gt,REG_LOGICAL_COMPLEX:()=>ft,REG_LOGICAL_COMPOUND:()=>Xt,REG_LOGICAL_EMPTY:()=>bt,REG_LOGICAL_KEY:()=>Wt,REG_LOGICAL_PSEUDO:()=>yt,REG_SHADOW_HOST:()=>kt,REG_SHADOW_MODE:()=>Kt,REG_SHADOW_PSEUDO:()=>Zt,REG_TYPE_CHECK:()=>Vt,REG_TYPE_DATE:()=>vt,REG_TYPE_RANGE:()=>zt,REG_TYPE_RESET:()=>Qt,REG_TYPE_SUBMIT:()=>jt,REG_TYPE_TEXT:()=>qt,SELECTOR:()=>b,SELECTOR_ATTR:()=>W,SELECTOR_CLASS:()=>y,SELECTOR_ID:()=>k,SELECTOR_LIST:()=>K,SELECTOR_PSEUDO_CLASS:()=>Z,SELECTOR_PSEUDO_ELEMENT:()=>V,SELECTOR_TYPE:()=>v,SHOW_ALL:()=>Gt,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Pt,SHOW_ELEMENT:()=>it,STRING:()=>z,SUB_TYPE:()=>n,SYNTAX_ERR:()=>Q,TAG_TYPE:()=>e,TAG_TYPE_I:()=>$,TARGET_ALL:()=>j,TARGET_FIRST:()=>q,TARGET_LINEAL:()=>J,TARGET_SELF:()=>tt,TEXT_NODE:()=>Lt,TYPE_FROM:()=>Ot,TYPE_TO:()=>Rt,U_FFFD:()=>ot,WALKER_FILTER:()=>lt});module.exports=u(Jt);const B="AnPlusB",m="Combinator",h="__EMPTY__",w="Identifier",g="NotSupportedError",f="Nth",X="Raw",b="Selector",W="AttributeSelector",y="ClassSelector",k="IdSelector",K="SelectorList",Z="PseudoClassSelector",V="PseudoElementSelector",v="TypeSelector",z="String",Q="SyntaxError",j="all",q="first",J="lineal",tt="self",ot="\uFFFD",et=1,st=2,nt=4,Et=8,rt=16,ct=32,xt=65535,_t=45,pt=2,Tt=16,Ot=8,Rt=-1,$t=1,Lt=3,At=9,St=11,Ct=2,It=8,Nt=16,Gt=4294967295,Dt=256,Pt=1024,it=1,lt=1281,R="[A-Z\\d]+",N="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",G=`(?:-${R})*`,x=`(?:any-)?link|${N}|checked|empty|indeterminate|root|target|visited`,D=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,_=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${D})\\s*\\)`,n="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",$="\\*|[A-Z][\\w-]*",p="(?:is|not)",E=`(?:${e}|(?:${e})?(?:${n})+)`,T="\\s?[\\s>~+]\\s?",L=`${E}(?:${T}${E})*`,P=`:is\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,i=`:is\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,A=`(?:${e}|(?:${e})?(?:${n}|${P})+)`,S=`(?:${e}|(?:${e})?(?:${n}|${i})+)`,l=`(?:${$}|(?:${$})?(?:${n})+)`,C=`${S}(?:${T}${S})*`,a=`${p}\\(\\s*${C}(?:\\s*,\\s*${C})*\\s*\\)`,M=`${p}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,at=/^a(?:rea)?$/,Mt=new RegExp(`:(?!${x}|${_})`),Ft=new RegExp(`${T}${l}`,"i"),dt=/^(?:ltr|rtl)$/,Ut=/^(?:button|fieldset|form|input|select|textarea)$/,Yt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Ht=/^(?:button|form|input|select|textarea)$/,ut=/^([\da-f]{1,6}\s?)/i,Bt=/^(?:details|dialog)$/,mt=/^(?:(?:any-)?link|defined|dir|has|host(?:-context)?|not)$/,ht=/^$|^\s*>|,\s*$/,wt=new RegExp(`^(?:\\*-)?${R}${G}$`,"i"),gt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,ft=new RegExp(`:(?!${x}|${_}|${a})`),Xt=new RegExp(`:(?!${x}|${_}|${M})`),bt=/(:(is|where)\(\s*\))/,Wt=new RegExp(`:${p}\\(`),yt=/^(?:has|is|not|where)$/,kt=/^host(?:-context)?$/,Kt=/^(?:close|open)$/,Zt=/^part|slotted$/,Vt=/^(?:checkbox|radio)$/,vt=/^(?:date(?:time-local)?|month|time|week)$/,zt=/(?:date(?:time-local)?|month|number|range|time|week)$/,Qt=/^(?:button|reset)$/,jt=/^(?:image|submit)$/,qt=/^(?:email|number|password|search|tel|text|url)$/;0&&(module.exports={ALPHA_NUM,ANB,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,BIT_HYPHEN,CHILD_IDX,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,LOGICAL_KEY,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_CHILD_INDEXED,REG_COMPLEX,REG_DIR,REG_FORM,REG_FORM_CTRL,REG_FORM_VALID,REG_HEX,REG_INTERACT,REG_INVALIDATE_PSEUDO,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_COMPLEX,REG_LOGICAL_COMPOUND,REG_LOGICAL_EMPTY,REG_LOGICAL_KEY,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TYPE_CHECK,REG_TYPE_DATE,REG_TYPE_RANGE,REG_TYPE_RESET,REG_TYPE_SUBMIT,REG_TYPE_TEXT,SELECTOR,SELECTOR_ATTR,SELECTOR_CLASS,SELECTOR_ID,SELECTOR_LIST,SELECTOR_PSEUDO_CLASS,SELECTOR_PSEUDO_ELEMENT,SELECTOR_TYPE,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,STRING,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER});
//# sourceMappingURL=constant.js.map

@@ -1,2 +0,2 @@

var T=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var U=(x,o)=>{for(var e in o)T(x,e,{get:o[e],enumerable:!0})},F=(x,o,e,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of I(o))!$.call(x,n)&&n!==e&&T(x,n,{get:()=>o[n],enumerable:!(h=D(o,n))||h.enumerable});return x};var G=x=>F(T({},"__esModule",{value:!0}),x);var H={};U(H,{Finder:()=>W});module.exports=G(H);var k=require("./dom-util.js"),L=require("./matcher.js"),g=require("./parser.js"),a=require("./constant.js");const v="next",S="prev";class W{#a;#c;#m;#t;#n;#d;#o;#e;#f;#w;#b;#p;#s;#h;#r;#u;#i;#l;constructor(o){this.#l=o,this.#c=new WeakMap,this.#n=new WeakMap,this.#p=new WeakMap}_onError(o){if(!this.#w)if(o instanceof DOMException||o instanceof this.#l.DOMException)if(o.name===a.NOT_SUPPORTED_ERR)this.#i&&console.warn(o.message);else throw new this.#l.DOMException(o.message,o.name);else throw o}_setup(o,e,h={}){const{event:n,noexcept:l,warn:c}=h;return this.#w=!!l,this.#i=!!c,this.#d=this._setEvent(n),this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#h=(0,k.isInShadowTree)(e),[this.#a,this.#f]=this._correspond(o),this.#u=new WeakMap,this.#o=!1,e}_setEvent(o){return o instanceof this.#l.KeyboardEvent||o instanceof this.#l.MouseEvent?o:null}_correspond(o){const e=[];this.#m=!1;let h;if(this.#n.has(this.#t)){const n=this.#n.get(this.#t);if(n&&n.has(`${o}`)){const l=n.get(`${o}`);h=l.ast,this.#m=l.descendant}}if(h){const n=h.length;for(let l=0;l<n;l++)h[l].collected=!1,h[l].dir=null,h[l].filtered=!1,h[l].find=!1,e[l]=[]}else{let n;try{n=(0,g.parseSelector)(o)}catch(d){this._onError(d)}const{branches:l}=(0,g.walkAST)(n);let c=!1,f=0;h=[];for(const[...d]of l){const i=[];let t=d.shift();if(t&&t.type!==a.COMBINATOR){const s=new Set;for(;t;){if(t.type===a.COMBINATOR){const[r]=d;if(r.type===a.COMBINATOR){const m=`Invalid selector ${o}`;throw new DOMException(m,a.SYNTAX_ERR)}const u=t.name;/^[\s>]$/.test(u)&&(c=!0),i.push({combo:t,leaves:(0,g.sortAST)(s)}),s.clear()}else if(t){let{name:r}=t;r&&typeof r=="string"&&(r=(0,g.unescapeSelector)(r),typeof r=="string"&&r!==t.name&&(t.name=r),/[|:]/.test(r)&&(t.namespace=!0)),s.add(t)}if(d.length)t=d.shift();else{i.push({combo:null,leaves:(0,g.sortAST)(s)}),s.clear();break}}}h.push({branch:i,collected:!1,dir:null,filtered:!1,find:!1}),e[f]=[],f++}let b;this.#n.has(this.#t)?b=this.#n.get(this.#t):b=new Map,b.set(`${o}`,{ast:h,descendant:c}),this.#n.set(this.#t,b),this.#m=c}return[h,e]}_createTreeWalker(o){let e;return this.#u.has(o)?e=this.#u.get(o):(e=this.#t.createTreeWalker(o,a.WALKER_FILTER),this.#u.set(o,e)),e}_prepareQuerySelectorWalker(){return this.#b=this._createTreeWalker(this.#e),this.#b}_collectNthChild(o,e,h){const{a:n,b:l,reverse:c,selector:f}=o,{parentNode:b}=e,d=new Set;let i;if(f)if(this.#c.has(f))i=this.#c.get(f);else{const{branches:t,info:s}=(0,g.walkAST)(f);i=t,this.#c.set(f,i),s.hasLogicalPseudoFunc&&(this.#o=!0)}if(b){const t=this.#r;let s=(0,k.traverseNode)(b,t);s=t.firstChild();let r=0;for(;s;)r++,s=t.nextSibling();const u=new Set;if(i)for(s=(0,k.traverseNode)(b,t),s=t.firstChild();s;){const{display:m,visibility:w}=this.#l.getComputedStyle(s);if(m!=="none"&&w!=="hidden"){let p;for(const N of i)if(p=this._matchLeaves(N,s,h),!p)break;p&&u.add(s)}s=t.nextSibling()}if(n===0){if(l>0&&l<=r){if(u.size){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(u.has(s)){if(m===l-1){d.add(s);break}m++}c?s=t.previousSibling():s=t.nextSibling()}}else if(!f){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(m===l-1){d.add(s);break}c?s=t.previousSibling():s=t.nextSibling(),m++}}}}else{let m=l-1;if(n>0)for(;m<0;)m+=n;if(m>=0&&m<r){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let w=0,p=n>0?0:l-1;for(;s&&(s&&m>=0&&m<r);)u.size?u.has(s)&&(p===m&&(d.add(s),m+=n),n>0?p++:p--):w===m&&(f||d.add(s),m+=n),c?s=t.previousSibling():s=t.nextSibling(),w++}}if(c&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&n+l===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,h),t)break;t&&d.add(e)}else d.add(e);return d}_collectNthOfType(o,e){const{a:h,b:n,reverse:l}=o,{localName:c,parentNode:f,prefix:b}=e,d=new Set;if(f){const i=this.#r;let t=(0,k.traverseNode)(f,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(h===0){if(n>0&&n<=s){t=(0,k.traverseNode)(f,i),l?t=i.lastChild():t=i.firstChild();let r=0;for(;t;){const{localName:u,prefix:m}=t;if(u===c&&m===b){if(r===n-1){d.add(t);break}r++}l?t=i.previousSibling():t=i.nextSibling()}}}else{let r=n-1;if(h>0)for(;r<0;)r+=h;if(r>=0&&r<s){t=(0,k.traverseNode)(f,i),l?t=i.lastChild():t=i.firstChild();let u=h>0?0:n-1;for(;t;){const{localName:m,prefix:w}=t;if(m===c&&w===b){if(u===r&&(d.add(t),r+=h),r<0||r>=s)break;h>0?u++:u--}l?t=i.previousSibling():t=i.nextSibling()}}}if(l&&d.size>1){const r=[...d];return new Set(r.reverse())}}else e===this.#s&&h+n===1&&d.add(e);return d}_matchAnPlusB(o,e,h,n){const{nth:{a:l,b:c,name:f},selector:b}=o,d=new Map;if(f?(f==="even"?(d.set("a",2),d.set("b",0)):f==="odd"&&(d.set("a",2),d.set("b",1)),h.indexOf("last")>-1&&d.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?d.set("a",l*1):d.set("a",0),typeof c=="string"&&/-?\d+/.test(c)?d.set("b",c*1):d.set("b",0),h.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(h)){b&&d.set("selector",b);const i=Object.fromEntries(d);return this._collectNthChild(i,e,n)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(o,e,h={}){let n;if(Array.isArray(o)&&o.length){const l=o.map(s=>s),[c]=l,{type:f}=c;let b;f===a.COMBINATOR?b=l.shift():b={name:" ",type:a.COMBINATOR};const d=[];for(;l.length;){const[s]=l,{type:r}=s;if(r===a.COMBINATOR)break;d.push(l.shift())}const i={combo:b,leaves:d};h.dir=v;const t=this._matchCombinator(i,e,h);if(t.size)if(l.length){for(const s of t)if(n=this._matchHasPseudoFunc(l,s,h),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(o,e,h={}){const{astName:n="",branches:l=[],selector:c="",twigBranches:f=[]}=o;let b;if(n==="has")if(c.includes(":has("))b=null;else{let d;for(const i of l)if(d=this._matchHasPseudoFunc(i,e,h),d)break;d&&(b=e)}else{const d=/^(?:is|where)$/.test(n);h.forgive=d;const i=f.length;let t;for(let s=0;s<i;s++){const r=f[s],u=r.length-1,{leaves:m}=r[u];if(t=this._matchLeaves(m,e,h),t&&u>0){let w=new Set([e]);for(let p=u-1;p>=0;p--){const N=r[p],_=[];h.dir=S;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?t=!0:w=new Set(_);else{t=!1;break}}}if(t)break}n==="not"?t||(b=e):t&&(b=e)}return b??null}_matchPseudoClassSelector(o,e,h={}){const{children:n,name:l}=o,{localName:c,parentNode:f}=e,{forgive:b,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(l)){let t;if(this.#c.has(o))t=this.#c.get(o);else{const{branches:r}=(0,g.walkAST)(o),u=[],m=[];for(const[...w]of r){for(const y of w){const E=(0,g.generateCSS)(y);u.push(E)}const p=[],N=new Set;let _=w.shift();for(;_;)if(_.type===a.COMBINATOR?(p.push({combo:_,leaves:[...N]}),N.clear()):_&&N.add(_),w.length)_=w.shift();else{p.push({combo:null,leaves:[...N]}),N.clear();break}m.push(p)}t={astName:l,branches:r,twigBranches:m,selector:u.join(",")},this.#c.set(o,t)}const s=this._matchLogicalPseudoFunc(t,e,h);s&&i.add(s)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[t]=n;return this._matchAnPlusB(t,e,l,h)}else switch(l){case"dir":case"lang":{const t=L.matcher.matchSelector(o,e);t&&i.add(t);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:t}]=n;t&&e[t]&&i.add(e)}break}case"current":case"nth-col":case"nth-last-col":{if(d){const t=`Unsupported pseudo-class :${l}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(d){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(!b){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,a.SYNTAX_ERR)}}else switch(l){case"any-link":case"link":{a.REG_ANCHOR.test(c)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(a.REG_ANCHOR.test(c)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:r}=new URL(this.#t.URL),u=new URL(e.getAttribute("href"),t);u.origin===s&&u.pathname===r&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#d??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:r}=this.#d??{};(r==="mousedown"||r==="pointerdown")&&t&a.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#t.URL);e.id&&t===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#t.URL);if(t){const s=t.replace(/^#/,"");let r=this.#t.getElementById(s);for(;r;){if(r===e){i.add(e);break}r=r.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#h&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#d??{};if(e===this.#t.activeElement&&e.tabIndex>=0&&(l==="focus"||s==="keydown"&&e.contains(t))){let r=e,u=!0;for(;r;){if(r.disabled||r.hasAttribute("disabled")||r.hidden||r.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(r);if(u=!(m==="none"||w==="hidden"),!u)break}if(r.parentNode&&r.parentNode.nodeType===a.ELEMENT_NODE)r=r.parentNode;else break}u&&i.add(e)}break}case"focus-within":{let t,s=this.#t.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.parentNode}if(t){let r=e,u=!0;for(;r;){if(r.disabled||r.hasAttribute("disabled")||r.hidden||r.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(r);if(u=!(m==="none"||w==="hidden"),!u)break}if(r.parentNode&&r.parentNode.nodeType===a.ELEMENT_NODE)r=r.parentNode;else break}u&&i.add(e)}break}case"open":{a.REG_INTERACT.test(c)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{a.REG_INTERACT.test(c)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(a.REG_FORM_CTRL.test(c)||(0,k.isCustomElement)(e,{formAssociated:!0})){if(e.disabled||e.hasAttribute("disabled"))i.add(e);else if(e.localName==="option")f.localName==="optgroup"&&(f.disabled||f.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const r=this.#r;let u=(0,k.traverseNode)(s,r);for(u=r.firstChild();u&&u.localName!=="legend";)u=r.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t&&i.add(e)}}break}case"enabled":{if((a.REG_FORM_CTRL.test(c)||(0,k.isCustomElement)(e,{formAssociated:!0}))&&!(e.disabled&&e.hasAttribute("disabled")))if(e.localName==="optgroup")i.add(e);else if(e.localName==="option")(f.localName!=="optgroup"||!(f.disabled||f.hasAttribute("disabled")))&&i.add(e);else{let t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const r=this.#r;let u=(0,k.traverseNode)(s,r);for(u=r.firstChild();u&&u.localName!=="legend";)u=r.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t||i.add(e)}break}case"read-only":{switch(c){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(c){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;c==="textarea"?s=e:c==="input"&&(e.hasAttribute("type")?a.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&c==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&c==="input"&&e.type==="checkbox"||c==="progress"&&!e.hasAttribute("value"))i.add(e);else if(c==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;s||(s=this.#t.documentElement);const r=s.getElementsByTagName("input"),u=r.length;let m;for(let w=0;w<u;w++){const p=r[w];if(p.getAttribute("type")==="radio"&&(t?p.getAttribute("name")===t&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(c==="button"&&!(e.hasAttribute("type")&&a.REG_TYPE_RESET.test(e.getAttribute("type")))||c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#r;let r=(0,k.traverseNode)(t,s);for(r=s.firstChild();r&&t.contains(r);){const u=r.localName;let m;if(u==="button"?m=!(r.hasAttribute("type")&&a.REG_TYPE_RESET.test(r.getAttribute("type"))):u==="input"&&(m=r.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(r.getAttribute("type"))),m){r===e&&i.add(e);break}r=s.nextNode()}}}else(c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))&&e.hasAttribute("checked")||c==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(a.REG_FORM_VALID.test(c))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(c==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let r;if(!s)r=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?r=s.maxLength>=s.value.length:r=!0:r=!1,!r));)s=t.nextNode();r&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(c))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(c==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let r;if(!s)r=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?r=s.maxLength>=s.value.length:r=!0:r=!1,!r));)s=t.nextNode();r||i.add(e)}break}case"in-range":{c==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&i.add(e);break}case"out-of-range":{c==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(c))t=e;else if(c==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(c))t=e;else if(c==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#t.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#t.createTreeWalker(e,a.SHOW_ALL);let s=t.firstChild(),r;for(;s&&(r=s.nodeType!==a.ELEMENT_NODE&&s.nodeType!==a.TEXT_NODE,!!r);)s=t.nextSibling();r&&i.add(e)}else i.add(e);break}case"first-child":{(f&&e===f.firstElementChild||e===this.#s)&&i.add(e);break}case"last-child":{(f&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"only-child":{(f&&e===f.firstElementChild&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"first-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s===e&&i.add(e)}}else e===this.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||c.includes("-")?(0,k.isCustomElement)(e)&&i.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.SVGElement)&&i.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#l.getComputedStyle(e);t!=="none"&&i.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d){const t=`Unsupported pseudo-element ::${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"autofill":case"blank":case"buffering":case"current":case"fullscreen":case"future":case"modal":case"muted":case"past":case"paused":case"picture-in-picture":case"playing":case"seeking":case"stalled":case"user-invalid":case"user-valid":case"volume-locked":case"-webkit-autofill":{if(d){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(l.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}}else if(!b){const t=`Unknown pseudo-class :${l}`;throw new DOMException(t,a.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(o,e){const{children:h,name:n}=o;let l;if(Array.isArray(h)){const{branches:c}=(0,g.walkAST)(h[0]),[f]=c,[...b]=f,{host:d}=e;if(n==="host"){let i;for(const t of b){const{type:s}=t;if(s===a.COMBINATOR){const u=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(u,a.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}i&&(l=e)}else if(n==="host-context"){let i=d,t;for(;i;){for(const s of b){const{type:r}=s;if(r===a.COMBINATOR){const m=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(m,a.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}t&&(l=e)}}else if(n==="host")l=e;else{const c=`Invalid selector :${n}`;throw new DOMException(c,a.SYNTAX_ERR)}return l??null}_matchSelector(o,e,h){const{type:n}=o,l=new Set;if(o.name===a.EMPTY)return l;const c=(0,g.unescapeSelector)(o.name);if(typeof c=="string"&&c!==o.name&&(o.name=c),e.nodeType===a.ELEMENT_NODE)switch(n){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(c,h);break}case a.SELECTOR_ID:{e.id===c&&l.add(e);break}case a.SELECTOR_CLASS:{e.classList.contains(c)&&l.add(e);break}case a.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(o,e,h);default:{const f=L.matcher.matchSelector(o,e,h);f&&l.add(f)}}else if(this.#h&&n===a.SELECTOR_PSEUDO_CLASS&&e.nodeType===a.DOCUMENT_FRAGMENT_NODE){if(c!=="has"&&a.REG_LOGICAL_PSEUDO.test(c))return this._matchPseudoClassSelector(o,e,h);if(a.REG_SHADOW_HOST.test(c)){const f=this._matchShadowHostPseudoClass(o,e,h);f&&l.add(f)}}return l}_matchLeaves(o,e,h){let n,l=this.#p.get(o);if(l&&l.has(e)){const{matched:c}=l.get(e);n=c}if(typeof n!="boolean"){for(const f of o){switch(f.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{this.#o=!0;break}case a.SELECTOR_PSEUDO_CLASS:{/^(?:(?:any-)?link|defined|dir|has)$/.test(f.name)&&(this.#o=!0);break}default:}if(n=this._matchSelector(f,e,h).has(e),!n)break}let c=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(c=!1),c&&!this.#o&&(l||(l=new WeakMap),l.set(e,{matched:n}),this.#p.set(o,l))}return!!n}_matchHTMLCollection(o,e={}){const{compound:h,filterLeaves:n}=e,l=new Set,c=o.length;if(c)if(h)for(let f=0;f<c;f++){const b=o[f];this._matchLeaves(n,b,e)&&l.add(b)}else{const f=[].slice.call(o);return new Set(f)}return l}_findDescendantNodes(o,e,h){const[n,...l]=o,c=l.length>0,{type:f}=n,b=(0,g.unescapeSelector)(n.name);typeof b=="string"&&b!==n.name&&(n.name=b);let d=new Set,i=!1;if(this.#h)i=!0;else switch(f){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,h);break}case a.SELECTOR_ID:{if(this.#s.nodeType===a.ELEMENT_NODE)i=!0;else{const t=this.#s.getElementById(b);t&&t!==e&&e.contains(t)&&(c?this._matchLeaves(l,t,h)&&d.add(t):d.add(t))}break}case a.SELECTOR_CLASS:{const t=e.getElementsByClassName(b);d=this._matchHTMLCollection(t,{compound:c,filterLeaves:l});break}case a.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(b)){const t=e.getElementsByTagName(b);d=this._matchHTMLCollection(t,{compound:c,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(o,e,h={}){const{combo:n,leaves:l}=o,{name:c}=n,{parentNode:f}=e,{dir:b}=h,d=new Set;if(b===v)switch(c){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(e,i);for(t=i.nextSibling();t;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=(0,k.traverseNode)(e,i);for(t=i.firstChild();t;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(l,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let r=(0,k.traverseNode)(e,s);for(r=s.nextNode();r&&e.contains(r);)this._matchLeaves(l,r,h)&&d.add(r),r=s.nextNode()}}}else switch(c){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(f,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{f&&this._matchLeaves(l,f,h)&&d.add(f);break}case" ":default:{const i=[];let t=f;for(;t;)this._matchLeaves(l,t,h)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(o,e){const{node:h}=e,n=this.#b;let l=(0,k.traverseNode)(h,n),c;if(l)for((l.nodeType!==a.ELEMENT_NODE||l===h&&l!==this.#s)&&(l=n.nextNode());l;){if(this._matchLeaves(o,l,{warn:this.#i})){c=l;break}l=n.nextNode()}return c??null}_matchSelf(o){const e=[],h=this._matchLeaves(o,this.#e,{warn:this.#i});let n=!1;return h&&(e.push(this.#e),n=!0),[e,n]}_findLineal(o,e={}){const{complex:h}=e,n=[];let l=this._matchLeaves(o,this.#e,{warn:this.#i}),c=!1;if(l&&(n.push(this.#e),c=!0),!l||h){let f=this.#e.parentNode;for(;f&&(l=this._matchLeaves(o,f,{warn:this.#i}),l&&(n.push(f),c=!0),f.parentNode);)f=f.parentNode}return[n,c]}_findFirst(o){const e=[],h=this._findNode(o,{node:this.#e});let n=!1;return h&&(e.push(h),n=!0),[e,n]}_findFromHTMLCollection(o,e={}){const{complex:h,compound:n,filterLeaves:l,targetType:c}=e;let f=[],b=!1,d=!1;const i=o.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let t=0;t<i;t++){const s=o[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(n){if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else if(f.push(s),b=!0,c===a.TARGET_FIRST)break}}else if(h)if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;else if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;return[f,b,d]}_findEntryNodes(o,e,h){const{leaves:n}=o,[l,...c]=n,f=c.length>0,{name:b,type:d}=l;let i=[],t=!1,s=!1,r=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(e===a.TARGET_FIRST&&this.#s.nodeType!==a.ELEMENT_NODE){const u=this.#s.getElementById(b);u&&(f?this._matchLeaves(c,u,{warn:this.#i})&&(i.push(u),s=!0):(i.push(u),s=!0))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):r=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(this.#s.nodeType===a.DOCUMENT_NODE){const u=this.#s.getElementsByClassName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:c,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):r=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===a.DOCUMENT_NODE&&!/[*|]/.test(b)){const u=this.#s.getElementsByTagName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:c,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):r=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(b)){if(this.#h&&this.#e.nodeType===a.DOCUMENT_FRAGMENT_NODE){const u=this._matchShadowHostPseudoClass(l,this.#e);u&&(i.push(u),s=!0)}}else e===a.TARGET_SELF?[i,s]=this._matchSelf(n):e===a.TARGET_LINEAL?[i,s]=this._findLineal(n,{complex:h}):e===a.TARGET_FIRST?[i,s]=this._findFirst(n):r=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:r}}_collectNodes(o){const e=this.#a.values();if(o===a.TARGET_ALL||o===a.TARGET_FIRST){const h=new Set;let n=0;for(const{branch:l}of e){const c=l.length,f=c>1,b=l[0];let d,i;if(f){const{combo:w,leaves:[{name:p,type:N}]}=b,_=l[c-1],{leaves:[{name:y,type:E}]}=_;if(E===a.SELECTOR_PSEUDO_ELEMENT||E===a.SELECTOR_ID)d=S,i=_;else if(N===a.SELECTOR_PSEUDO_ELEMENT||N===a.SELECTOR_ID)d=v,i=b;else if(o===a.TARGET_ALL)if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(c===2){const{name:A}=w;/^[+~]$/.test(A)?(d=S,i=_):(d=v,i=b)}else d=v,i=b;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else{let A;for(const{combo:C,leaves:[O]}of l){const{name:R,type:M}=O;if(M===a.SELECTOR_PSEUDO_CLASS&&R==="dir"){A=!1;break}if(!A&&C){const{name:P}=C;/^[+~]$/.test(P)&&(A=!0)}}A?(d=v,i=b):(d=S,i=_)}}else d=S,i=b;const{collected:t,compound:s,filtered:r,nodes:u,pending:m}=this._findEntryNodes(i,o,f);u.length?(this.#a[n].find=!0,this.#f[n]=u):m&&h.add(new Map([["index",n],["twig",i]])),this.#a[n].collected=t,this.#a[n].dir=d,this.#a[n].filtered=r||!s,n++}if(h.size){let l,c;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(l=this.#e,c=this.#b):(l=this.#s,c=this.#r);let f=(0,k.traverseNode)(l,c);for(;f;){let b=!1;if(this.#e.nodeType===a.ELEMENT_NODE?f===this.#e?b=!0:b=this.#e.contains(f):b=!0,b)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,f,{warn:this.#i})){const s=d.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#f[s].push(f)}}f!==c.currentNode&&(f=(0,k.traverseNode)(f,c)),f=c.nextNode()}}}else{let h=0;for(const{branch:n}of e){const l=n[n.length-1],c=n.length>1,{compound:f,filtered:b,nodes:d}=this._findEntryNodes(l,o,c);d.length&&(this.#a[h].find=!0,this.#f[h]=d),this.#a[h].dir=S,this.#a[h].filtered=b||!f,h++}}return[this.#a,this.#f]}_getCombinedNodes(o,e,h){const n=[];for(const l of e){const c=this._matchCombinator(o,l,{dir:h,warn:this.#i});c.size&&n.push(...c)}return n.length?new Set(n):new Set}_matchNodeNext(o,e,h){const{combo:n,index:l}=h,{combo:c,leaves:f}=o[l],b={combo:n,leaves:f},d=this._getCombinedNodes(b,e,v);let i;if(d.size)if(l===o.length-1){const[t]=(0,k.sortNodes)(d);i=t}else i=this._matchNodeNext(o,d,{combo:c,index:l+1});return i??null}_matchNodePrev(o,e,h){const{index:n}=h,l=o[n],c=new Set([e]),f=this._getCombinedNodes(l,c,S);let b;if(f.size){if(n===0)b=e;else for(const d of f)if(this._matchNodePrev(o,d,{index:n-1}))return e}return b??null}_find(o){(o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(o),n=e.length;let l,c=new Set;for(let f=0;f<n;f++){const{branch:b,collected:d,dir:i,find:t}=e[f],s=b.length;if(s&&t){const r=h[f],u=r.length,m=s-1;if(m===0)if((o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this.#e.nodeType===a.ELEMENT_NODE)for(let w=0;w<u;w++){const p=r[w];if(p!==this.#e&&this.#e.contains(p)&&(c.add(p),o!==a.TARGET_ALL))break}else if(o===a.TARGET_ALL)if(c.size){const w=[...c];c=new Set([...w,...r]),l=!0}else c=new Set(r);else{const[w]=r;c.add(w)}else if(o===a.TARGET_ALL)if(i===v){let{combo:w}=b[0];for(const p of r){let N=new Set([p]);for(let _=1;_<s;_++){const{combo:y,leaves:E}=b[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(c.size){const C=[...c];c=new Set([...C,...N]),l=!0}else c=N;else w=y;else break}}}else for(const w of r){let p=new Set([w]);for(let N=m-1;N>=0;N--){const _=b[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(c.add(w),s>1&&c.size>1&&(l=!0));else break}}else if(o===a.TARGET_FIRST&&i===v){const{combo:w}=b[0];let p;for(const N of r)if(p=this._matchNodeNext(b,new Set([N]),{combo:w,index:1}),p){c.add(p);break}if(!p&&!d){const{leaves:N}=b[0],[_]=r;let y=this._findNode(N,{node:_});for(;y;){if(p=this._matchNodeNext(b,new Set([y]),{combo:w,index:1}),p){c.add(p);break}y=this._findNode(N,{node:y})}}}else{let w;for(const p of r)if(w=this._matchNodePrev(b,p,{index:m-1}),w){c.add(p);break}if(!w&&!d&&o===a.TARGET_FIRST){const{leaves:p}=b[m],[N]=r;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(b,_,{index:m-1}),w){c.add(_);break}_=this._findNode(p,{node:_})}}}}}return o===a.TARGET_ALL&&l&&(c=new Set((0,k.sortNodes)(c))),c}}0&&(module.exports={Finder});
var T=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var $=(x,o)=>{for(var e in o)T(x,e,{get:o[e],enumerable:!0})},F=(x,o,e,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of I(o))!U.call(x,n)&&n!==e&&T(x,n,{get:()=>o[n],enumerable:!(h=D(o,n))||h.enumerable});return x};var G=x=>F(T({},"__esModule",{value:!0}),x);var H={};$(H,{Finder:()=>W});module.exports=G(H);var k=require("./dom-util.js"),L=require("./matcher.js"),g=require("./parser.js"),a=require("./constant.js");const v="next",S="prev";class W{#a;#c;#u;#t;#n;#h;#m;#e;#o;#w;#d;#p;#s;#f;#r;#b;#i;#l;constructor(o){this.#l=o,this.#c=new WeakMap,this.#n=new WeakMap,this.#p=new WeakMap}_onError(o){if(!this.#w)if(o instanceof DOMException||o instanceof this.#l.DOMException)if(o.name===a.NOT_SUPPORTED_ERR)this.#i&&console.warn(o.message);else throw new this.#l.DOMException(o.message,o.name);else throw o}_setup(o,e,h={}){const{event:n,noexcept:l,warn:r}=h;return this.#w=!!l,this.#i=!!r,this.#h=this._setEvent(n),this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#f=(0,k.isInShadowTree)(e),[this.#a,this.#o]=this._correspond(o),this.#b=new WeakMap,this.#m=!1,e}_setEvent(o){return o instanceof this.#l.KeyboardEvent||o instanceof this.#l.MouseEvent?o:null}_correspond(o){const e=[];this.#u=!1;let h;if(this.#n.has(this.#t)){const n=this.#n.get(this.#t);if(n&&n.has(`${o}`)){const l=n.get(`${o}`);h=l.ast,this.#u=l.descendant}}if(h){const n=h.length;for(let l=0;l<n;l++)h[l].collected=!1,h[l].dir=null,h[l].filtered=!1,h[l].find=!1,e[l]=[]}else{let n;try{n=(0,g.parseSelector)(o)}catch(d){this._onError(d)}const{branches:l}=(0,g.walkAST)(n);let r=!1,f=0;h=[];for(const[...d]of l){const i=[];let t=d.shift();if(t&&t.type!==a.COMBINATOR){const s=new Set;for(;t;){if(t.type===a.COMBINATOR){const[c]=d;if(c.type===a.COMBINATOR){const m=`Invalid selector ${o}`;throw new DOMException(m,a.SYNTAX_ERR)}const u=t.name;/^[\s>]$/.test(u)&&(r=!0),i.push({combo:t,leaves:(0,g.sortAST)(s)}),s.clear()}else if(t){let{name:c}=t;c&&typeof c=="string"&&(c=(0,g.unescapeSelector)(c),typeof c=="string"&&c!==t.name&&(t.name=c),/[|:]/.test(c)&&(t.namespace=!0)),s.add(t)}if(d.length)t=d.shift();else{i.push({combo:null,leaves:(0,g.sortAST)(s)}),s.clear();break}}}h.push({branch:i,collected:!1,dir:null,filtered:!1,find:!1}),e[f]=[],f++}let b;this.#n.has(this.#t)?b=this.#n.get(this.#t):b=new Map,b.set(`${o}`,{ast:h,descendant:r}),this.#n.set(this.#t,b),this.#u=r}return[h,e]}_createTreeWalker(o){let e;return this.#b.has(o)?e=this.#b.get(o):(e=this.#t.createTreeWalker(o,a.WALKER_FILTER),this.#b.set(o,e)),e}_prepareQuerySelectorWalker(){return this.#d=this._createTreeWalker(this.#e),this.#d}_collectNthChild(o,e,h){const{a:n,b:l,reverse:r,selector:f}=o,{parentNode:b}=e,d=new Set;let i;if(f)if(this.#c.has(f))i=this.#c.get(f);else{const{branches:t,info:s}=(0,g.walkAST)(f);i=t,this.#c.set(f,i),s.hasLogicalPseudoFunc&&(this.#m=!0)}if(b){const t=this.#r;let s=(0,k.traverseNode)(b,t);s=t.firstChild();let c=0;for(;s;)c++,s=t.nextSibling();const u=new Set;if(i)for(s=(0,k.traverseNode)(b,t),s=t.firstChild();s;){const{display:m,visibility:w}=this.#l.getComputedStyle(s);if(m!=="none"&&w!=="hidden"){let p;for(const N of i)if(p=this._matchLeaves(N,s,h),!p)break;p&&u.add(s)}s=t.nextSibling()}if(n===0){if(l>0&&l<=c){if(u.size){s=(0,k.traverseNode)(b,t),r?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(u.has(s)){if(m===l-1){d.add(s);break}m++}r?s=t.previousSibling():s=t.nextSibling()}}else if(!f){s=(0,k.traverseNode)(b,t),r?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(m===l-1){d.add(s);break}r?s=t.previousSibling():s=t.nextSibling(),m++}}}}else{let m=l-1;if(n>0)for(;m<0;)m+=n;if(m>=0&&m<c){s=(0,k.traverseNode)(b,t),r?s=t.lastChild():s=t.firstChild();let w=0,p=n>0?0:l-1;for(;s&&(s&&m>=0&&m<c);)u.size?u.has(s)&&(p===m&&(d.add(s),m+=n),n>0?p++:p--):w===m&&(f||d.add(s),m+=n),r?s=t.previousSibling():s=t.nextSibling(),w++}}if(r&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&n+l===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,h),t)break;t&&d.add(e)}else d.add(e);return d}_collectNthOfType(o,e){const{a:h,b:n,reverse:l}=o,{localName:r,parentNode:f,prefix:b}=e,d=new Set;if(f){const i=this.#r;let t=(0,k.traverseNode)(f,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(h===0){if(n>0&&n<=s){t=(0,k.traverseNode)(f,i),l?t=i.lastChild():t=i.firstChild();let c=0;for(;t;){const{localName:u,prefix:m}=t;if(u===r&&m===b){if(c===n-1){d.add(t);break}c++}l?t=i.previousSibling():t=i.nextSibling()}}}else{let c=n-1;if(h>0)for(;c<0;)c+=h;if(c>=0&&c<s){t=(0,k.traverseNode)(f,i),l?t=i.lastChild():t=i.firstChild();let u=h>0?0:n-1;for(;t;){const{localName:m,prefix:w}=t;if(m===r&&w===b){if(u===c&&(d.add(t),c+=h),c<0||c>=s)break;h>0?u++:u--}l?t=i.previousSibling():t=i.nextSibling()}}}if(l&&d.size>1){const c=[...d];return new Set(c.reverse())}}else e===this.#s&&h+n===1&&d.add(e);return d}_matchAnPlusB(o,e,h,n){const{nth:{a:l,b:r,name:f},selector:b}=o,d=new Map;if(f?(f==="even"?(d.set("a",2),d.set("b",0)):f==="odd"&&(d.set("a",2),d.set("b",1)),h.indexOf("last")>-1&&d.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?d.set("a",l*1):d.set("a",0),typeof r=="string"&&/-?\d+/.test(r)?d.set("b",r*1):d.set("b",0),h.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(h)){b&&d.set("selector",b);const i=Object.fromEntries(d);return this._collectNthChild(i,e,n)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(o,e,h={}){let n;if(Array.isArray(o)&&o.length){const l=o.map(s=>s),[r]=l,{type:f}=r;let b;f===a.COMBINATOR?b=l.shift():b={name:" ",type:a.COMBINATOR};const d=[];for(;l.length;){const[s]=l,{type:c}=s;if(c===a.COMBINATOR)break;d.push(l.shift())}const i={combo:b,leaves:d};h.dir=v;const t=this._matchCombinator(i,e,h);if(t.size)if(l.length){for(const s of t)if(n=this._matchHasPseudoFunc(l,s,h),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(o,e,h={}){const{astName:n="",branches:l=[],selector:r="",twigBranches:f=[]}=o;let b;if(n==="has")if(r.includes(":has("))b=null;else{let d;for(const i of l)if(d=this._matchHasPseudoFunc(i,e,h),d)break;d&&(b=e)}else{const d=/^(?:is|where)$/.test(n);h.forgive=d;const i=f.length;let t;for(let s=0;s<i;s++){const c=f[s],u=c.length-1,{leaves:m}=c[u];if(t=this._matchLeaves(m,e,h),t&&u>0){let w=new Set([e]);for(let p=u-1;p>=0;p--){const N=c[p],_=[];h.dir=S;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?t=!0:w=new Set(_);else{t=!1;break}}}if(t)break}n==="not"?t||(b=e):t&&(b=e)}return b??null}_matchPseudoClassSelector(o,e,h={}){const{children:n,name:l}=o,{localName:r,parentNode:f}=e,{forgive:b,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(l)){let t;if(this.#c.has(o))t=this.#c.get(o);else{const{branches:c}=(0,g.walkAST)(o),u=[],m=[];for(const[...w]of c){for(const y of w){const E=(0,g.generateCSS)(y);u.push(E)}const p=[],N=new Set;let _=w.shift();for(;_;)if(_.type===a.COMBINATOR?(p.push({combo:_,leaves:[...N]}),N.clear()):_&&N.add(_),w.length)_=w.shift();else{p.push({combo:null,leaves:[...N]}),N.clear();break}m.push(p)}t={astName:l,branches:c,twigBranches:m,selector:u.join(",")},this.#c.set(o,t)}const s=this._matchLogicalPseudoFunc(t,e,h);s&&i.add(s)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[t]=n;return this._matchAnPlusB(t,e,l,h)}else switch(l){case"dir":case"lang":{const t=L.matcher.matchSelector(o,e);t&&i.add(t);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:t}]=n;t&&e[t]&&i.add(e)}break}case"current":case"nth-col":case"nth-last-col":{if(d){const t=`Unsupported pseudo-class :${l}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(d){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(!b){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,a.SYNTAX_ERR)}}else switch(l){case"any-link":case"link":{a.REG_ANCHOR.test(r)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(a.REG_ANCHOR.test(r)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:c}=new URL(this.#t.URL),u=new URL(e.getAttribute("href"),t);u.origin===s&&u.pathname===c&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#h??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:c}=this.#h??{};(c==="mousedown"||c==="pointerdown")&&t&a.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#t.URL);e.id&&t===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#t.URL);if(t){const s=t.replace(/^#/,"");let c=this.#t.getElementById(s);for(;c;){if(c===e){i.add(e);break}c=c.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#f&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#h??{};if(e===this.#t.activeElement&&e.tabIndex>=0&&(l==="focus"||s==="keydown"&&e.contains(t))){let c=e,u=!0;for(;c;){if(c.disabled||c.hasAttribute("disabled")||c.hidden||c.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(c);if(u=!(m==="none"||w==="hidden"),!u)break}if(c.parentNode&&c.parentNode.nodeType===a.ELEMENT_NODE)c=c.parentNode;else break}u&&i.add(e)}break}case"focus-within":{let t,s=this.#t.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.parentNode}if(t){let c=e,u=!0;for(;c;){if(c.disabled||c.hasAttribute("disabled")||c.hidden||c.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(c);if(u=!(m==="none"||w==="hidden"),!u)break}if(c.parentNode&&c.parentNode.nodeType===a.ELEMENT_NODE)c=c.parentNode;else break}u&&i.add(e)}break}case"open":{a.REG_INTERACT.test(r)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{a.REG_INTERACT.test(r)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(a.REG_FORM_CTRL.test(r)||(0,k.isCustomElement)(e,{formAssociated:!0})){if(e.disabled||e.hasAttribute("disabled"))i.add(e);else if(e.localName==="option")f.localName==="optgroup"&&(f.disabled||f.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const c=this.#r;let u=(0,k.traverseNode)(s,c);for(u=c.firstChild();u&&u.localName!=="legend";)u=c.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t&&i.add(e)}}break}case"enabled":{if((a.REG_FORM_CTRL.test(r)||(0,k.isCustomElement)(e,{formAssociated:!0}))&&!(e.disabled&&e.hasAttribute("disabled")))if(e.localName==="optgroup")i.add(e);else if(e.localName==="option")(f.localName!=="optgroup"||!(f.disabled||f.hasAttribute("disabled")))&&i.add(e);else{let t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const c=this.#r;let u=(0,k.traverseNode)(s,c);for(u=c.firstChild();u&&u.localName!=="legend";)u=c.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t||i.add(e)}break}case"read-only":{switch(r){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(r){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;r==="textarea"?s=e:r==="input"&&(e.hasAttribute("type")?a.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))||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 c=s.getElementsByTagName("input"),u=c.length;let m;for(let w=0;w<u;w++){const p=c[w];if(p.getAttribute("type")==="radio"&&(t?p.getAttribute("name")===t&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(r==="button"&&!(e.hasAttribute("type")&&a.REG_TYPE_RESET.test(e.getAttribute("type")))||r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#r;let c=(0,k.traverseNode)(t,s);for(c=s.firstChild();c&&t.contains(c);){const u=c.localName;let m;if(u==="button"?m=!(c.hasAttribute("type")&&a.REG_TYPE_RESET.test(c.getAttribute("type"))):u==="input"&&(m=c.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(c.getAttribute("type"))),m){c===e&&i.add(e);break}c=s.nextNode()}}}else(r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))&&e.hasAttribute("checked")||r==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(a.REG_FORM_VALID.test(r))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(r==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let c;if(!s)c=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?c=s.maxLength>=s.value.length:c=!0:c=!1,!c));)s=t.nextNode();c&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(r))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(r==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let c;if(!s)c=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?c=s.maxLength>=s.value.length:c=!0:c=!1,!c));)s=t.nextNode();c||i.add(e)}break}case"in-range":{r==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&i.add(e);break}case"out-of-range":{r==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(r))t=e;else if(r==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(r))t=e;else if(r==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#t.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#t.createTreeWalker(e,a.SHOW_ALL);let s=t.firstChild(),c;for(;s&&(c=s.nodeType!==a.ELEMENT_NODE&&s.nodeType!==a.TEXT_NODE,!!c);)s=t.nextSibling();c&&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,k.isCustomElement)(e)&&i.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.SVGElement)&&i.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#l.getComputedStyle(e);t!=="none"&&i.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d){const t=`Unsupported pseudo-element ::${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"autofill":case"blank":case"buffering":case"current":case"fullscreen":case"future":case"modal":case"muted":case"past":case"paused":case"picture-in-picture":case"playing":case"seeking":case"stalled":case"user-invalid":case"user-valid":case"volume-locked":case"-webkit-autofill":{if(d){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(l.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}}else if(!b){const t=`Unknown pseudo-class :${l}`;throw new DOMException(t,a.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(o,e){const{children:h,name:n}=o;let l;if(Array.isArray(h)){const{branches:r}=(0,g.walkAST)(h[0]),[f]=r,[...b]=f,{host:d}=e;if(n==="host"){let i;for(const t of b){const{type:s}=t;if(s===a.COMBINATOR){const u=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(u,a.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}i&&(l=e)}else if(n==="host-context"){let i=d,t;for(;i;){for(const s of b){const{type:c}=s;if(c===a.COMBINATOR){const m=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(m,a.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}t&&(l=e)}}else if(n==="host")l=e;else{const r=`Invalid selector :${n}`;throw new DOMException(r,a.SYNTAX_ERR)}return l??null}_matchSelector(o,e,h){const{type:n}=o,l=new Set;if(o.name===a.EMPTY)return l;const r=(0,g.unescapeSelector)(o.name);if(typeof r=="string"&&r!==o.name&&(o.name=r),e.nodeType===a.ELEMENT_NODE)switch(n){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(r,h);break}case a.SELECTOR_ID:{e.id===r&&l.add(e);break}case a.SELECTOR_CLASS:{e.classList.contains(r)&&l.add(e);break}case a.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(o,e,h);default:{const f=L.matcher.matchSelector(o,e,h);f&&l.add(f)}}else if(this.#f&&n===a.SELECTOR_PSEUDO_CLASS&&e.nodeType===a.DOCUMENT_FRAGMENT_NODE){if(r!=="has"&&a.REG_LOGICAL_PSEUDO.test(r))return this._matchPseudoClassSelector(o,e,h);if(a.REG_SHADOW_HOST.test(r)){const f=this._matchShadowHostPseudoClass(o,e,h);f&&l.add(f)}}return l}_matchLeaves(o,e,h){let n,l=this.#p.get(o);if(l&&l.has(e)){const{matched:r}=l.get(e);n=r}if(typeof n!="boolean"){let r=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(r=!1);for(const f of o){switch(f.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{r=!1;break}case a.SELECTOR_PSEUDO_CLASS:{a.REG_INVALIDATE_PSEUDO.test(f.name)&&(r=!1);break}default:}if(n=this._matchSelector(f,e,h).has(e),!n)break}r&&!this.#m&&(l||(l=new WeakMap),l.set(e,{matched:n}),this.#p.set(o,l))}return!!n}_matchHTMLCollection(o,e={}){const{compound:h,filterLeaves:n}=e,l=new Set,r=o.length;if(r)if(h)for(let f=0;f<r;f++){const b=o[f];this._matchLeaves(n,b,e)&&l.add(b)}else{const f=[].slice.call(o);return new Set(f)}return l}_findDescendantNodes(o,e,h){const[n,...l]=o,r=l.length>0,{type:f}=n,b=(0,g.unescapeSelector)(n.name);typeof b=="string"&&b!==n.name&&(n.name=b);let d=new Set,i=!1;if(this.#f)i=!0;else switch(f){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,h);break}case a.SELECTOR_ID:{if(this.#s.nodeType===a.ELEMENT_NODE)i=!0;else{const t=this.#s.getElementById(b);t&&t!==e&&e.contains(t)&&(r?this._matchLeaves(l,t,h)&&d.add(t):d.add(t))}break}case a.SELECTOR_CLASS:{const t=e.getElementsByClassName(b);d=this._matchHTMLCollection(t,{compound:r,filterLeaves:l});break}case a.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(b)){const t=e.getElementsByTagName(b);d=this._matchHTMLCollection(t,{compound:r,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(o,e,h={}){const{combo:n,leaves:l}=o,{name:r}=n,{parentNode:f}=e,{dir:b}=h,d=new Set;if(b===v)switch(r){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(e,i);for(t=i.nextSibling();t;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=(0,k.traverseNode)(e,i);for(t=i.firstChild();t;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(l,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let c=(0,k.traverseNode)(e,s);for(c=s.nextNode();c&&e.contains(c);)this._matchLeaves(l,c,h)&&d.add(c),c=s.nextNode()}}}else switch(r){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(f,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{f&&this._matchLeaves(l,f,h)&&d.add(f);break}case" ":default:{const i=[];let t=f;for(;t;)this._matchLeaves(l,t,h)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(o,e){const{node:h}=e,n=this.#d;let l=(0,k.traverseNode)(h,n),r;if(l)for((l.nodeType!==a.ELEMENT_NODE||l===h&&l!==this.#s)&&(l=n.nextNode());l;){if(this._matchLeaves(o,l,{warn:this.#i})){r=l;break}l=n.nextNode()}return r??null}_matchSelf(o){const e=[],h=this._matchLeaves(o,this.#e,{warn:this.#i});let n=!1;return h&&(e.push(this.#e),n=!0),[e,n]}_findLineal(o,e={}){const{complex:h}=e,n=[];let l=this._matchLeaves(o,this.#e,{warn:this.#i}),r=!1;if(l&&(n.push(this.#e),r=!0),!l||h){let f=this.#e.parentNode;for(;f&&(l=this._matchLeaves(o,f,{warn:this.#i}),l&&(n.push(f),r=!0),f.parentNode);)f=f.parentNode}return[n,r]}_findFirst(o){const e=[],h=this._findNode(o,{node:this.#e});let n=!1;return h&&(e.push(h),n=!0),[e,n]}_findFromHTMLCollection(o,e={}){const{complex:h,compound:n,filterLeaves:l,targetType:r}=e;let f=[],b=!1,d=!1;const i=o.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let t=0;t<i;t++){const s=o[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(n){if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,r===a.TARGET_FIRST))break}else if(f.push(s),b=!0,r===a.TARGET_FIRST)break}}else if(h)if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,r===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;else if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,r===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;return[f,b,d]}_findEntryNodes(o,e,h){const{leaves:n}=o,[l,...r]=n,f=r.length>0,{name:b,type:d}=l;let i=[],t=!1,s=!1,c=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(e===a.TARGET_FIRST&&this.#s.nodeType!==a.ELEMENT_NODE){const u=this.#s.getElementById(b);u&&(f?this._matchLeaves(r,u,{warn:this.#i})&&(i.push(u),s=!0):(i.push(u),s=!0))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):c=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(this.#s.nodeType===a.DOCUMENT_NODE){const u=this.#s.getElementsByClassName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):c=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===a.DOCUMENT_NODE&&!/[*|]/.test(b)){const u=this.#s.getElementsByTagName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):c=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(b)){if(this.#f&&this.#e.nodeType===a.DOCUMENT_FRAGMENT_NODE){const u=this._matchShadowHostPseudoClass(l,this.#e);u&&(i.push(u),s=!0)}}else e===a.TARGET_SELF?[i,s]=this._matchSelf(n):e===a.TARGET_LINEAL?[i,s]=this._findLineal(n,{complex:h}):e===a.TARGET_FIRST?[i,s]=this._findFirst(n):c=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:c}}_collectNodes(o){const e=this.#a.values();if(o===a.TARGET_ALL||o===a.TARGET_FIRST){const h=new Set;let n=0;for(const{branch:l}of e){const r=l.length,f=r>1,b=l[0];let d,i;if(f){const{combo:w,leaves:[{name:p,type:N}]}=b,_=l[r-1],{leaves:[{name:y,type:E}]}=_;if(E===a.SELECTOR_PSEUDO_ELEMENT||E===a.SELECTOR_ID)d=S,i=_;else if(N===a.SELECTOR_PSEUDO_ELEMENT||N===a.SELECTOR_ID)d=v,i=b;else if(o===a.TARGET_ALL)if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(r===2){const{name:A}=w;/^[+~]$/.test(A)?(d=S,i=_):(d=v,i=b)}else d=v,i=b;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else{let A;for(const{combo:C,leaves:[O]}of l){const{name:R,type:M}=O;if(M===a.SELECTOR_PSEUDO_CLASS&&R==="dir"){A=!1;break}if(!A&&C){const{name:P}=C;/^[+~]$/.test(P)&&(A=!0)}}A?(d=v,i=b):(d=S,i=_)}}else d=S,i=b;const{collected:t,compound:s,filtered:c,nodes:u,pending:m}=this._findEntryNodes(i,o,f);u.length?(this.#a[n].find=!0,this.#o[n]=u):m&&h.add(new Map([["index",n],["twig",i]])),this.#a[n].collected=t,this.#a[n].dir=d,this.#a[n].filtered=c||!s,n++}if(h.size){let l,r;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(l=this.#e,r=this.#d):(l=this.#s,r=this.#r);let f=(0,k.traverseNode)(l,r);for(;f;){let b=!1;if(this.#e.nodeType===a.ELEMENT_NODE?f===this.#e?b=!0:b=this.#e.contains(f):b=!0,b)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,f,{warn:this.#i})){const s=d.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#o[s].push(f)}}f!==r.currentNode&&(f=(0,k.traverseNode)(f,r)),f=r.nextNode()}}}else{let h=0;for(const{branch:n}of e){const l=n[n.length-1],r=n.length>1,{compound:f,filtered:b,nodes:d}=this._findEntryNodes(l,o,r);d.length&&(this.#a[h].find=!0,this.#o[h]=d),this.#a[h].dir=S,this.#a[h].filtered=b||!f,h++}}return[this.#a,this.#o]}_getCombinedNodes(o,e,h){const n=[];for(const l of e){const r=this._matchCombinator(o,l,{dir:h,warn:this.#i});r.size&&n.push(...r)}return n.length?new Set(n):new Set}_matchNodeNext(o,e,h){const{combo:n,index:l}=h,{combo:r,leaves:f}=o[l],b={combo:n,leaves:f},d=this._getCombinedNodes(b,e,v);let i;if(d.size)if(l===o.length-1){const[t]=(0,k.sortNodes)(d);i=t}else i=this._matchNodeNext(o,d,{combo:r,index:l+1});return i??null}_matchNodePrev(o,e,h){const{index:n}=h,l=o[n],r=new Set([e]),f=this._getCombinedNodes(l,r,S);let b;if(f.size){if(n===0)b=e;else for(const d of f)if(this._matchNodePrev(o,d,{index:n-1}))return e}return b??null}_find(o){(o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(o),n=e.length;let l,r=new Set;for(let f=0;f<n;f++){const{branch:b,collected:d,dir:i,find:t}=e[f],s=b.length;if(s&&t){const c=h[f],u=c.length,m=s-1;if(m===0)if((o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this.#e.nodeType===a.ELEMENT_NODE)for(let w=0;w<u;w++){const p=c[w];if(p!==this.#e&&this.#e.contains(p)&&(r.add(p),o!==a.TARGET_ALL))break}else if(o===a.TARGET_ALL)if(r.size){const w=[...r];r=new Set([...w,...c]),l=!0}else r=new Set(c);else{const[w]=c;r.add(w)}else if(o===a.TARGET_ALL)if(i===v){let{combo:w}=b[0];for(const p of c){let N=new Set([p]);for(let _=1;_<s;_++){const{combo:y,leaves:E}=b[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(r.size){const C=[...r];r=new Set([...C,...N]),l=!0}else r=N;else w=y;else break}}}else for(const w of c){let p=new Set([w]);for(let N=m-1;N>=0;N--){const _=b[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(r.add(w),s>1&&r.size>1&&(l=!0));else break}}else if(o===a.TARGET_FIRST&&i===v){const{combo:w}=b[0];let p;for(const N of c)if(p=this._matchNodeNext(b,new Set([N]),{combo:w,index:1}),p){r.add(p);break}if(!p&&!d){const{leaves:N}=b[0],[_]=c;let y=this._findNode(N,{node:_});for(;y;){if(p=this._matchNodeNext(b,new Set([y]),{combo:w,index:1}),p){r.add(p);break}y=this._findNode(N,{node:y})}}}else{let w;for(const p of c)if(w=this._matchNodePrev(b,p,{index:m-1}),w){r.add(p);break}if(!w&&!d&&o===a.TARGET_FIRST){const{leaves:p}=b[m],[N]=c;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(b,_,{index:m-1}),w){r.add(_);break}_=this._findNode(p,{node:_})}}}}}return o===a.TARGET_ALL&&l&&(r=new Set((0,k.sortNodes)(r))),r}}0&&(module.exports={Finder});
//# sourceMappingURL=finder.js.map

@@ -43,3 +43,3 @@ {

"eslint-plugin-regexp": "^2.6.0",
"eslint-plugin-unicorn": "^54.0.0",
"eslint-plugin-unicorn": "^55.0.0",
"happy-dom": "^14.12.3",

@@ -64,3 +64,3 @@ "jsdom": "^24.1.1",

},
"version": "5.0.2"
"version": "5.0.3"
}

@@ -295,9 +295,9 @@ # DOM Selector

|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|simple selector:<br>`matches('.content')`|989,454 ops/sec ±1.51%|7,613 ops/sec ±1.10%|9,516 ops/sec ±0.60%|848,327 ops/sec ±0.66%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|602,507 ops/sec ±0.32%|7,328 ops/sec ±0.81%|9,052 ops/sec ±0.48%|405,877 ops/sec ±0.15%|jsdom is the fastest and 1.5 times faster than patched-jsdom.|
|compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|7,365 ops/sec ±0.90%|F|66,159 ops/sec ±0.98%|patched-jsdom is the fastest.|
|compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|479,695 ops/sec ±1.60%|7,470 ops/sec ±0.57%|8,804 ops/sec ±0.44%|346,257 ops/sec ±0.31%|jsdom is the fastest and 1.4 times faster than patched-jsdom.|
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|154,869 ops/sec ±0.80%|F|5,845 ops/sec ±0.34%|132,313 ops/sec ±0.22%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,754 ops/sec ±1.33%|21,105 ops/sec ±1.16%|patched-jsdom is the fastest.|
|complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|411,631 ops/sec ±0.31%|F|6,123 ops/sec ±0.38%|340,899 ops/sec ±0.19%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|simple selector:<br>`matches('.content')`|957,875 ops/sec ±0.97%|7,248 ops/sec ±0.58%|7,435 ops/sec ±0.63%|811,680 ops/sec ±1.32%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|591,790 ops/sec ±1.01%|7,003 ops/sec ±0.84%|7,118 ops/sec ±0.77%|400,189 ops/sec ±0.29%|jsdom is the fastest and 1.5 times faster than patched-jsdom.|
|compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|7,018 ops/sec ±0.53%|F|74,449 ops/sec ±0.90%|patched-jsdom is the fastest.|
|compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|471,272 ops/sec ±0.38%|6,777 ops/sec ±0.57%|7,067 ops/sec ±0.54%|338,117 ops/sec ±1.49%|jsdom is the fastest and 1.4 times faster than patched-jsdom.|
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|151,368 ops/sec ±1.59%|F|4,723 ops/sec ±0.69%|124,920 ops/sec ±1.31%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|4,610 ops/sec ±0.68%|41,718 ops/sec ±2.02%|patched-jsdom is the fastest.|
|complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|411,511 ops/sec ±1.61%|F|4,958 ops/sec ±0.35%|333,788 ops/sec ±1.24%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|

@@ -308,7 +308,7 @@ ### closest()

|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|simple selector:<br>`closest('.container')`|379,529 ops/sec ±0.13%|7,469 ops/sec ±1.56%|9,306 ops/sec ±0.72%|346,182 ops/sec ±1.52%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|137,674 ops/sec ±1.76%|F|8,696 ops/sec ±0.72%|125,138 ops/sec ±1.62%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|142,675 ops/sec ±0.43%|F|5,804 ops/sec ±0.87%|122,213 ops/sec ±1.38%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|5,733 ops/sec ±0.87%|17,024 ops/sec ±0.74%|patched-jsdom is the fastest.|
|complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|200,172 ops/sec ±1.51%|4,808 ops/sec ±1.19%|6,145 ops/sec ±0.53%|176,908 ops/sec ±1.42%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|simple selector:<br>`closest('.container')`|370,268 ops/sec ±1.72%|7,123 ops/sec ±0.63%|7,399 ops/sec ±0.75%|339,853 ops/sec ±1.49%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|133,846 ops/sec ±1.40%|F|6,977 ops/sec ±0.61%|124,635 ops/sec ±1.41%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|139,233 ops/sec ±1.93%|F|4,648 ops/sec ±0.87%|119,991 ops/sec ±0.23%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|4,618 ops/sec ±0.76%|37,743 ops/sec ±1.86%|patched-jsdom is the fastest.|
|complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|196,742 ops/sec ±1.46%|4,454 ops/sec ±1.05%|4,846 ops/sec ±0.61%|176,010 ops/sec ±1.34%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|

@@ -319,7 +319,7 @@ ### querySelector()

|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|simple selector:<br>`querySelector('.content')`|28,846 ops/sec ±0.23%|9,426 ops/sec ±0.83%|10,729 ops/sec ±0.58%|29,550 ops/sec ±0.89%|patched-jsdom is the fastest. patched-jsdom is 1.0 times faster than jsdom.|
|compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|10,152 ops/sec ±0.29%|9,270 ops/sec ±0.75%|10,907 ops/sec ±0.62%|9,682 ops/sec ±1.47%|linkedom is the fastest and 1.1 times faster than patched-jsdom. jsdom is 1.0 times faster than patched-jsdom.|
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|229 ops/sec ±1.41%|F|1,319 ops/sec ±1.57%|281 ops/sec ±0.46%|linkedom is the fastest and 4.7 times faster than patched-jsdom. patched-jsdom is 1.2 times faster than jsdom.|
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|1,606 ops/sec ±1.47%|803 ops/sec ±1.47%|linkedom is the fastest and 2.0 times faster than patched-jsdom.|
|complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|3,246 ops/sec ±1.58%|F|9,831 ops/sec ±0.80%|153,338 ops/sec ±1.76%|patched-jsdom is the fastest. patched-jsdom is 47.2 times faster than jsdom.|
|simple selector:<br>`querySelector('.content')`|32,150 ops/sec ±1.48%|8,957 ops/sec ±1.16%|8,707 ops/sec ±0.68%|29,777 ops/sec ±1.81%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|10,249 ops/sec ±1.33%|8,618 ops/sec ±1.28%|8,311 ops/sec ±0.60%|9,614 ops/sec ±1.31%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|230 ops/sec ±1.26%|F|1,265 ops/sec ±1.58%|268 ops/sec ±1.23%|linkedom is the fastest and 4.7 times faster than patched-jsdom. patched-jsdom is 1.2 times faster than jsdom.|
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|1,501 ops/sec ±1.51%|706 ops/sec ±2.25%|linkedom is the fastest and 2.1 times faster than patched-jsdom.|
|complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|3,305 ops/sec ±1.72%|F|8,133 ops/sec ±0.71%|154,046 ops/sec ±2.15%|patched-jsdom is the fastest. patched-jsdom is 46.6 times faster than jsdom.|

@@ -330,7 +330,7 @@ ### querySelectorAll()

|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|simple selector:<br>`querySelectorAll('.content')`|2,660 ops/sec ±1.25%|782 ops/sec ±0.27%|1,234 ops/sec ±1.40%|3,276 ops/sec ±0.90%|patched-jsdom is the fastest. patched-jsdom is 1.2 times faster than jsdom.|
|compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|977 ops/sec ±1.05%|730 ops/sec ±1.55%|1,191 ops/sec ±1.07%|1,046 ops/sec ±1.11%|linkedom is the fastest and 1.1 times faster than patched-jsdom. patched-jsdom is 1.1 times faster than jsdom.|
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|228 ops/sec ±1.21%|F|428 ops/sec ±1.36%|279 ops/sec ±1.28%|linkedom is the fastest and 1.5 times faster than patched-jsdom. patched-jsdom is 1.2 times faster than jsdom.|
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|465 ops/sec ±0.20%|924 ops/sec ±0.52%|patched-jsdom is the fastest.|
|complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|312 ops/sec ±1.25%|F|519 ops/sec ±1.57%|780 ops/sec ±2.24%|patched-jsdom is the fastest. patched-jsdom is 2.5 times faster than jsdom.|
|simple selector:<br>`querySelectorAll('.content')`|3,099 ops/sec ±1.08%|785 ops/sec ±1.79%|1,145 ops/sec ±1.41%|3,032 ops/sec ±0.28%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
|compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|1,018 ops/sec ±0.34%|731 ops/sec ±1.57%|1,155 ops/sec ±1.23%|995 ops/sec ±1.18%|linkedom is the fastest and 1.2 times faster than patched-jsdom. jsdom is 1.0 times faster than patched-jsdom.|
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|231 ops/sec ±1.23%|F|420 ops/sec ±1.37%|276 ops/sec ±0.23%|linkedom is the fastest and 1.5 times faster than patched-jsdom. patched-jsdom is 1.2 times faster than jsdom.|
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner:has(> .content)')`|F|F|447 ops/sec ±1.41%|801 ops/sec ±2.65%|patched-jsdom is the fastest.|
|complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|322 ops/sec ±0.40%|F|508 ops/sec ±1.40%|767 ops/sec ±1.66%|patched-jsdom is the fastest. patched-jsdom is 2.4 times faster than jsdom.|

@@ -337,0 +337,0 @@

@@ -128,4 +128,3 @@ /*!

}
if (document === this.#document &&
document?.contentType === 'text/html') {
if (document === this.#document && document.contentType === 'text/html') {
const filterOpt = {

@@ -169,4 +168,3 @@ complex: false,

}
if (document === this.#document &&
document?.contentType === 'text/html') {
if (document === this.#document && document.contentType === 'text/html') {
const filterOpt = {

@@ -173,0 +171,0 @@ complex: false,

@@ -108,2 +108,4 @@ /**

export const REG_INTERACT = /^(?:details|dialog)$/;
export const REG_INVALIDATE_PSEUDO =
/^(?:(?:any-)?link|defined|dir|has|host(?:-context)?|not)$/;
export const REG_INVALID_SELECTOR = /^$|^\s*>|,\s*$/;

@@ -110,0 +112,0 @@ export const REG_LANG = new RegExp(`^(?:\\*-)?${ALPHA_NUM}${LANG_PART}$`, 'i');

@@ -78,2 +78,3 @@ export const AN_PLUS_B: "AnPlusB";

export const REG_INTERACT: RegExp;
export const REG_INVALIDATE_PSEUDO: RegExp;
export const REG_INVALID_SELECTOR: RegExp;

@@ -80,0 +81,0 @@ export const REG_LANG: RegExp;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc