From 0cf179ad78c0bd6879b3e7186014af61ba3ac2c9 Mon Sep 17 00:00:00 2001 From: "asamuzaK (Kazz)" Date: Tue, 13 Aug 2024 14:43:32 +0900 Subject: [PATCH] v5.2.1 --- dist/cjs/js/constant.js | 2 +- dist/cjs/js/constant.js.map | 6 +++--- dist/cjs/js/finder.js | 2 +- dist/cjs/js/finder.js.map | 6 +++--- dist/cjs/js/utility.js | 2 +- dist/cjs/js/utility.js.map | 6 +++--- package.json | 2 +- types/js/constant.d.ts | 2 +- types/js/finder.d.ts | 1 + types/js/utility.d.ts | 2 ++ 10 files changed, 17 insertions(+), 14 deletions(-) diff --git a/dist/cjs/js/constant.js b/dist/cjs/js/constant.js index afda7090..9c8f65f6 100644 --- a/dist/cjs/js/constant.js +++ b/dist/cjs/js/constant.js @@ -1,2 +1,2 @@ -var T=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var Y=(o,t)=>{for(var n in t)T(o,n,{get:t[n],enumerable:!0})},u=(o,t,n,I)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of U(t))!d.call(o,s)&&s!==n&&T(o,s,{get:()=>t[s],enumerable:!(I=F(t,s))||I.enumerable});return o};var B=o=>u(T({},"__esModule",{value:!0}),o);var qt={};Y(qt,{ALPHA_NUM:()=>O,ANB:()=>D,AN_PLUS_B:()=>H,BIT_01:()=>et,BIT_02:()=>st,BIT_04:()=>Et,BIT_08:()=>rt,BIT_16:()=>nt,BIT_32:()=>_t,BIT_FFFF:()=>ct,BIT_HYPHEN:()=>xt,CHILD_IDX:()=>C,COMBINATOR:()=>m,COMBO:()=>p,COMPLEX:()=>$,COMPLEX_L:()=>A,COMPOUND:()=>r,COMPOUND_A:()=>S,COMPOUND_B:()=>L,COMPOUND_I:()=>i,DIGIT:()=>_,DOCUMENT_FRAGMENT_NODE:()=>At,DOCUMENT_NODE:()=>Lt,DOCUMENT_POSITION_CONTAINED_BY:()=>Ct,DOCUMENT_POSITION_CONTAINS:()=>It,DOCUMENT_POSITION_PRECEDING:()=>Nt,DUO:()=>pt,ELEMENT_NODE:()=>$t,EMPTY:()=>w,HEX:()=>Tt,IDENTIFIER:()=>h,KEY_IS_NOT:()=>N,LANG_PART:()=>G,LOGICAL_COMPLEX:()=>a,LOGICAL_COMPOUND:()=>M,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>l,NOT_SUPPORTED_ERR:()=>g,NTH:()=>f,N_TH:()=>x,PSEUDO_CLASSES:()=>c,RAW:()=>X,REG_ANCHOR:()=>at,REG_COMPLEX:()=>Mt,REG_DIR:()=>Ft,REG_FILTER_COMPLEX:()=>Ut,REG_FILTER_COMPOUND:()=>dt,REG_FILTER_SIMPLE:()=>Yt,REG_FORM:()=>ut,REG_FORM_CTRL:()=>Bt,REG_FORM_VALID:()=>Ht,REG_HEX:()=>mt,REG_INTERACT:()=>wt,REG_INVALID_SELECTOR:()=>ht,REG_LANG:()=>gt,REG_LANG_QUOTED:()=>ft,REG_LOGICAL_EMPTY:()=>Xt,REG_LOGICAL_PSEUDO:()=>bt,REG_SHADOW_HOST:()=>Wt,REG_SHADOW_MODE:()=>yt,REG_SHADOW_PSEUDO:()=>kt,REG_TAG_NAME:()=>Zt,REG_TYPE_CHECK:()=>Kt,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:()=>Z,SELECTOR_PSEUDO_CLASS:()=>K,SELECTOR_PSEUDO_ELEMENT:()=>v,SELECTOR_TYPE:()=>z,SHOW_ALL:()=>Gt,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Pt,SHOW_ELEMENT:()=>lt,STRING:()=>V,SUB_TYPE:()=>E,SYNTAX_ERR:()=>Q,TAG_TYPE:()=>e,TAG_TYPE_I:()=>R,TARGET_ALL:()=>j,TARGET_FIRST:()=>q,TARGET_LINEAL:()=>J,TARGET_SELF:()=>tt,TEXT_NODE:()=>St,TYPE_FROM:()=>Ot,TYPE_TO:()=>Rt,U_FFFD:()=>ot,WALKER_FILTER:()=>it});module.exports=B(qt);const H="AnPlusB",m="Combinator",w="__EMPTY__",h="Identifier",g="NotSupportedError",f="Nth",X="Raw",b="Selector",W="AttributeSelector",y="ClassSelector",k="IdSelector",Z="SelectorList",K="PseudoClassSelector",v="PseudoElementSelector",z="TypeSelector",V="String",Q="SyntaxError",j="all",q="first",J="lineal",tt="self",ot="\uFFFD",et=1,st=2,Et=4,rt=8,nt=16,_t=32,ct=65535,xt=45,pt=2,Tt=16,Ot=8,Rt=-1,$t=1,St=3,Lt=9,At=11,Nt=2,It=8,Ct=16,Gt=4294967295,Dt=256,Pt=1024,lt=1,it=1281,O="[A-Z\\d]+",C="(?:first|last|only)-(?:child|of-type)",_="(?:0|[1-9]\\d*)",G=`(?:-${O})*`,c=`(?:any-)?link|${C}|checked|empty|indeterminate|root|target|visited`,D=`[+-]?(?:${_}n?|n)|(?:[+-]?${_})?n\\s*[+-]\\s*${_}`,x=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${D})\\s*\\)`,E="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",R="\\*|[A-Z][\\w-]*",r=`(?:${e}|(?:${e})?(?:${E})+)`,p="\\s?[\\s>~+]\\s?",$=`${r}(?:${p}${r})*`,P=`:is\\(\\s*${r}(?:\\s*,\\s*${r})*\\s*\\)`,l=`:is\\(\\s*${$}(?:\\s*,\\s*${$})*\\s*\\)`,S=`(?:${e}|(?:${e})?(?:${E}|${P})+)`,L=`(?:${e}|(?:${e})?(?:${E}|${l})+)`,i=`(?:${R}|(?:${R})?(?:${E})+)`,A=`${L}(?:${p}${L})*`,N="(?:is|not)",a=`${N}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,M=`${N}\\(\\s*${S}(?:\\s*,\\s*${S})*\\s*\\)`,at=/^a(?:rea)?$/,Mt=new RegExp(`${p}${i}`,"i"),Ft=/^(?:ltr|rtl)$/,Ut=new RegExp(`:(?!${c}|${x}|${a})`),dt=new RegExp(`:(?!${c}|${x}|${M})`),Yt=new RegExp(`:(?!${c}|${x})`),ut=/^(?:button|fieldset|form|input|select|textarea)$/,Bt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Ht=/^(?:button|form|input|select|textarea)$/,mt=/^([\da-f]{1,6}\s?)/i,wt=/^(?:details|dialog)$/,ht=/^$|^\s*>|,\s*$/,gt=new RegExp(`^(?:\\*-)?${O}${G}$`,"i"),ft=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,Xt=/(:(is|where)\(\s*\))/,bt=/^(?:has|is|not|where)$/,Wt=/^host(?:-context)?$/,yt=/^(?:close|open)$/,kt=/^part|slotted$/,Zt=/[A-Z][\\w-]*/i,Kt=/^(?: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,KEY_IS_NOT,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_COMPLEX,REG_DIR,REG_FILTER_COMPLEX,REG_FILTER_COMPOUND,REG_FILTER_SIMPLE,REG_FORM,REG_FORM_CTRL,REG_FORM_VALID,REG_HEX,REG_INTERACT,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_EMPTY,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TAG_NAME,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 T=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var u=(o,t)=>{for(var n in t)T(o,n,{get:t[n],enumerable:!0})},m=(o,t,n,I)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of U(t))!d.call(o,s)&&s!==n&&T(o,s,{get:()=>t[s],enumerable:!(I=F(t,s))||I.enumerable});return o};var Y=o=>m(T({},"__esModule",{value:!0}),o);var qt={};u(qt,{ALPHA_NUM:()=>O,ANB:()=>P,AN_PLUS_B:()=>B,BIT_01:()=>et,BIT_02:()=>st,BIT_04:()=>rt,BIT_08:()=>Et,BIT_16:()=>nt,BIT_32:()=>ct,BIT_FFFF:()=>_t,BIT_HYPHEN:()=>xt,CHILD_IDX:()=>C,COMBINATOR:()=>H,COMBO:()=>p,COMPLEX:()=>$,COMPLEX_L:()=>N,COMPOUND:()=>E,COMPOUND_A:()=>S,COMPOUND_B:()=>L,COMPOUND_I:()=>i,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>Nt,DOCUMENT_NODE:()=>Lt,DOCUMENT_POSITION_CONTAINED_BY:()=>Ct,DOCUMENT_POSITION_CONTAINS:()=>It,DOCUMENT_POSITION_PRECEDING:()=>At,DUO:()=>pt,ELEMENT_NODE:()=>$t,EMPTY:()=>w,HEX:()=>Tt,IDENTIFIER:()=>h,KEY_IS_NOT:()=>A,LANG_PART:()=>G,LOGICAL_COMPLEX:()=>a,LOGICAL_COMPOUND:()=>M,NESTED_LOGICAL_A:()=>l,NESTED_LOGICAL_B:()=>D,NOT_SUPPORTED_ERR:()=>g,NTH:()=>b,N_TH:()=>x,PSEUDO_CLASSES:()=>_,RAW:()=>f,REG_ANCHOR:()=>at,REG_COMPLEX:()=>Mt,REG_DIR:()=>Ft,REG_FILTER_COMPLEX:()=>Ut,REG_FILTER_COMPOUND:()=>dt,REG_FILTER_SIMPLE:()=>ut,REG_FORM:()=>mt,REG_FORM_CTRL:()=>Yt,REG_FORM_VALID:()=>Bt,REG_HEX:()=>Ht,REG_INTERACT:()=>wt,REG_INVALID_SELECTOR:()=>ht,REG_LANG:()=>gt,REG_LANG_QUOTED:()=>bt,REG_LOGICAL_EMPTY:()=>ft,REG_LOGICAL_PSEUDO:()=>Xt,REG_SHADOW_HOST:()=>Wt,REG_SHADOW_MODE:()=>yt,REG_SHADOW_PSEUDO:()=>kt,REG_TAG_NAME:()=>Zt,REG_TYPE_CHECK:()=>Kt,REG_TYPE_INPUT:()=>vt,REG_TYPE_RANGE:()=>zt,REG_TYPE_RESET:()=>Vt,REG_TYPE_SUBMIT:()=>Qt,REG_TYPE_TEXT:()=>jt,SELECTOR:()=>X,SELECTOR_ATTR:()=>W,SELECTOR_CLASS:()=>y,SELECTOR_ID:()=>k,SELECTOR_LIST:()=>Z,SELECTOR_PSEUDO_CLASS:()=>K,SELECTOR_PSEUDO_ELEMENT:()=>v,SELECTOR_TYPE:()=>z,SHOW_ALL:()=>Gt,SHOW_DOCUMENT:()=>Pt,SHOW_DOCUMENT_FRAGMENT:()=>lt,SHOW_ELEMENT:()=>Dt,STRING:()=>V,SUB_TYPE:()=>r,SYNTAX_ERR:()=>Q,TAG_TYPE:()=>e,TAG_TYPE_I:()=>R,TARGET_ALL:()=>j,TARGET_FIRST:()=>q,TARGET_LINEAL:()=>J,TARGET_SELF:()=>tt,TEXT_NODE:()=>St,TYPE_FROM:()=>Ot,TYPE_TO:()=>Rt,U_FFFD:()=>ot,WALKER_FILTER:()=>it});module.exports=Y(qt);const B="AnPlusB",H="Combinator",w="__EMPTY__",h="Identifier",g="NotSupportedError",b="Nth",f="Raw",X="Selector",W="AttributeSelector",y="ClassSelector",k="IdSelector",Z="SelectorList",K="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,_t=65535,xt=45,pt=2,Tt=16,Ot=8,Rt=-1,$t=1,St=3,Lt=9,Nt=11,At=2,It=8,Ct=16,Gt=4294967295,Pt=256,lt=1024,Dt=1,it=1281,O="[A-Z\\d]+",C="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",G=`(?:-${O})*`,_=`(?:any-)?link|${C}|checked|empty|indeterminate|root|target|visited`,P=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,x=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${P})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",R="\\*|[A-Z][\\w-]*",E=`(?:${e}|(?:${e})?(?:${r})+)`,p="\\s?[\\s>~+]\\s?",$=`${E}(?:${p}${E})*`,l=`:is\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,D=`:is\\(\\s*${$}(?:\\s*,\\s*${$})*\\s*\\)`,S=`(?:${e}|(?:${e})?(?:${r}|${l})+)`,L=`(?:${e}|(?:${e})?(?:${r}|${D})+)`,i=`(?:${R}|(?:${R})?(?:${r})+)`,N=`${L}(?:${p}${L})*`,A="(?:is|not)",a=`${A}\\(\\s*${N}(?:\\s*,\\s*${N})*\\s*\\)`,M=`${A}\\(\\s*${S}(?:\\s*,\\s*${S})*\\s*\\)`,at=/^a(?:rea)?$/,Mt=new RegExp(`${p}${i}`,"i"),Ft=/^(?:ltr|rtl)$/,Ut=new RegExp(`:(?!${_}|${x}|${a})`),dt=new RegExp(`:(?!${_}|${x}|${M})`),ut=new RegExp(`:(?!${_}|${x})`),mt=/^(?:button|fieldset|form|input|select|textarea)$/,Yt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Bt=/^(?:button|form|input|select|textarea)$/,Ht=/^([\da-f]{1,6}\s?)/i,wt=/^(?:details|dialog)$/,ht=/^$|^\s*>|,\s*$/,gt=new RegExp(`^(?:\\*-)?${O}${G}$`,"i"),bt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,ft=/(:(is|where)\(\s*\))/,Xt=/^(?:has|is|not|where)$/,Wt=/^host(?:-context)?$/,yt=/^(?:close|open)$/,kt=/^part|slotted$/,Zt=/[A-Z][\\w-]*/i,Kt=/^(?:checkbox|radio)$/,vt=/^(?:date(?:time-local)?|email|month|number|password|search|tel|text|time|url|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,KEY_IS_NOT,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_COMPLEX,REG_DIR,REG_FILTER_COMPLEX,REG_FILTER_COMPOUND,REG_FILTER_SIMPLE,REG_FORM,REG_FORM_CTRL,REG_FORM_VALID,REG_HEX,REG_INTERACT,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_EMPTY,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TAG_NAME,REG_TYPE_CHECK,REG_TYPE_INPUT,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 diff --git a/dist/cjs/js/constant.js.map b/dist/cjs/js/constant.js.map index 5fd0677b..9a19d1f9 100644 --- a/dist/cjs/js/constant.js.map +++ b/dist/cjs/js/constant.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../../src/js/constant.js"], - "sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const AN_PLUS_B = 'AnPlusB';\nexport const COMBINATOR = 'Combinator';\nexport const EMPTY = '__EMPTY__';\nexport const IDENTIFIER = 'Identifier';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const RAW = 'Raw';\nexport const SELECTOR = 'Selector';\nexport const SELECTOR_ATTR = 'AttributeSelector';\nexport const SELECTOR_CLASS = 'ClassSelector';\nexport const SELECTOR_ID = 'IdSelector';\nexport const SELECTOR_LIST = 'SelectorList';\nexport const SELECTOR_PSEUDO_CLASS = 'PseudoClassSelector';\nexport const SELECTOR_PSEUDO_ELEMENT = 'PseudoElementSelector';\nexport const SELECTOR_TYPE = 'TypeSelector';\nexport const STRING = 'String';\nexport const SYNTAX_ERR = 'SyntaxError';\nexport const TARGET_ALL = 'all';\nexport const TARGET_FIRST = 'first';\nexport const TARGET_LINEAL = 'lineal';\nexport const TARGET_SELF = 'self';\nexport const U_FFFD = '\\uFFFD';\n\n/* numeric */\nexport const BIT_01 = 1;\nexport const BIT_02 = 2;\nexport const BIT_04 = 4;\nexport const BIT_08 = 8;\nexport const BIT_16 = 0x10;\nexport const BIT_32 = 0x20;\nexport const BIT_FFFF = 0xFFFF;\nexport const BIT_HYPHEN = 0x2D;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const TYPE_FROM = 8;\nexport const TYPE_TO = -1;\n\n/* Node */\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\nexport const DOCUMENT_POSITION_PRECEDING = 2;\nexport const DOCUMENT_POSITION_CONTAINS = 8;\nexport const DOCUMENT_POSITION_CONTAINED_BY = 0x10;\n\n/* NodeFilter */\nexport const SHOW_ALL = 0xFFFFFFFF;\nexport const SHOW_DOCUMENT = 0x100;\nexport const SHOW_DOCUMENT_FRAGMENT = 0x400;\nexport const SHOW_ELEMENT = 1;\nexport const WALKER_FILTER = 0x501;\n\n/* selectors */\nexport const ALPHA_NUM = '[A-Z\\\\d]+';\nexport const CHILD_IDX = '(?:first|last|only)-(?:child|of-type)';\nexport const DIGIT = '(?:0|[1-9]\\\\d*)';\nexport const LANG_PART = `(?:-${ALPHA_NUM})*`;\nexport const PSEUDO_CLASSES =\n `(?:any-)?link|${CHILD_IDX}|checked|empty|indeterminate|root|target|visited`;\nexport const ANB =\n `[+-]?(?:${DIGIT}n?|n)|(?:[+-]?${DIGIT})?n\\\\s*[+-]\\\\s*${DIGIT}`;\n// N_TH: excludes An+B with selector list, e.g. :nth-child(2n+1 of .foo)\nexport const N_TH =\n `nth-(?:last-)?(?:child|of-type)\\\\(\\\\s*(?:even|odd|${ANB})\\\\s*\\\\)`;\n// SUB_TYPE: attr, id, class, pseudo-class, note that [foo|=bar] is excluded\nexport const SUB_TYPE = '\\\\[[^|\\\\]]+\\\\]|[#.:][\\\\w-]+';\n// TAG_TYPE: *, tag\nexport const TAG_TYPE = '\\\\*|[A-Za-z][\\\\w-]*';\nexport const TAG_TYPE_I = '\\\\*|[A-Z][\\\\w-]*';\nexport const COMPOUND = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`;\nexport const COMBO = '\\\\s?[\\\\s>~+]\\\\s?';\nexport const COMPLEX = `${COMPOUND}(?:${COMBO}${COMPOUND})*`;\nexport const NESTED_LOGICAL_A =\n `:is\\\\(\\\\s*${COMPOUND}(?:\\\\s*,\\\\s*${COMPOUND})*\\\\s*\\\\)`;\nexport const NESTED_LOGICAL_B =\n `:is\\\\(\\\\s*${COMPLEX}(?:\\\\s*,\\\\s*${COMPLEX})*\\\\s*\\\\)`;\nexport const COMPOUND_A =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_A})+)`;\nexport const COMPOUND_B =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_B})+)`;\nexport const COMPOUND_I =\n `(?:${TAG_TYPE_I}|(?:${TAG_TYPE_I})?(?:${SUB_TYPE})+)`;\nexport const COMPLEX_L = `${COMPOUND_B}(?:${COMBO}${COMPOUND_B})*`;\nexport const KEY_IS_NOT = '(?:is|not)';\nexport const LOGICAL_COMPLEX =\n `${KEY_IS_NOT}\\\\(\\\\s*${COMPLEX_L}(?:\\\\s*,\\\\s*${COMPLEX_L})*\\\\s*\\\\)`;\nexport const LOGICAL_COMPOUND =\n `${KEY_IS_NOT}\\\\(\\\\s*${COMPOUND_A}(?:\\\\s*,\\\\s*${COMPOUND_A})*\\\\s*\\\\)`;\n\n/* regexp */\nexport const REG_ANCHOR = /^a(?:rea)?$/;\nexport const REG_COMPLEX = new RegExp(`${COMBO}${COMPOUND_I}`, 'i');\nexport const REG_DIR = /^(?:ltr|rtl)$/;\nexport const REG_FILTER_COMPLEX =\n new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPLEX})`);\nexport const REG_FILTER_COMPOUND =\n new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPOUND})`);\nexport const REG_FILTER_SIMPLE = new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH})`);\nexport const REG_FORM = /^(?:button|fieldset|form|input|select|textarea)$/;\nexport const REG_FORM_CTRL =\n /^(?:button|fieldset|input|optgroup|option|select|textarea)$/;\nexport const REG_FORM_VALID = /^(?:button|form|input|select|textarea)$/;\nexport const REG_HEX = /^([\\da-f]{1,6}\\s?)/i;\nexport const REG_INTERACT = /^(?:details|dialog)$/;\nexport const REG_INVALID_SELECTOR = /^$|^\\s*>|,\\s*$/;\nexport const REG_LANG = new RegExp(`^(?:\\\\*-)?${ALPHA_NUM}${LANG_PART}$`, 'i');\nexport const REG_LANG_QUOTED = /(:lang\\(\\s*(\"[A-Za-z\\d\\-*]*\")\\s*\\))/;\nexport const REG_LOGICAL_EMPTY = /(:(is|where)\\(\\s*\\))/;\nexport const REG_LOGICAL_PSEUDO = /^(?:has|is|not|where)$/;\nexport const REG_SHADOW_HOST = /^host(?:-context)?$/;\nexport const REG_SHADOW_MODE = /^(?:close|open)$/;\nexport const REG_SHADOW_PSEUDO = /^part|slotted$/;\nexport const REG_TAG_NAME = /[A-Z][\\\\w-]*/i;\nexport const REG_TYPE_CHECK = /^(?:checkbox|radio)$/;\nexport const REG_TYPE_DATE = /^(?:date(?:time-local)?|month|time|week)$/;\nexport const REG_TYPE_RANGE =\n /(?:date(?:time-local)?|month|number|range|time|week)$/;\nexport const REG_TYPE_RESET = /^(?:button|reset)$/;\nexport const REG_TYPE_SUBMIT = /^(?:image|submit)$/;\nexport const REG_TYPE_TEXT = /^(?:email|number|password|search|tel|text|url)$/;\n"], - "mappings": "4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAAAE,EAAA,QAAAC,EAAA,cAAAC,EAAA,WAAAC,GAAA,WAAAC,GAAA,WAAAC,GAAA,WAAAC,GAAA,WAAAC,GAAA,WAAAC,GAAA,aAAAC,GAAA,eAAAC,GAAA,cAAAC,EAAA,eAAAC,EAAA,UAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,UAAAC,EAAA,2BAAAC,GAAA,kBAAAC,GAAA,mCAAAC,GAAA,+BAAAC,GAAA,gCAAAC,GAAA,QAAAC,GAAA,iBAAAC,GAAA,UAAAC,EAAA,QAAAC,GAAA,eAAAC,EAAA,eAAAC,EAAA,cAAAC,EAAA,oBAAAC,EAAA,qBAAAC,EAAA,qBAAAC,EAAA,qBAAAC,EAAA,sBAAAC,EAAA,QAAAC,EAAA,SAAAC,EAAA,mBAAAC,EAAA,QAAAC,EAAA,eAAAC,GAAA,gBAAAC,GAAA,YAAAC,GAAA,uBAAAC,GAAA,wBAAAC,GAAA,sBA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,GAAe,uBACfC,GAAuB,iBACvBC,GAAW,IAAI,OAAO,aAAatD,CAAS,GAAGgC,CAAS,IAAK,GAAG,EAChEuB,GAAkB,sCAClBC,GAAoB,uBACpBC,GAAqB,yBACrBC,GAAkB,sBAClBC,GAAkB,mBAClBC,GAAoB,iBACpBC,GAAe,gBACfC,GAAiB,uBACjBC,GAAgB,4CAChBC,GACX,wDACWC,GAAiB,qBACjBC,GAAkB,qBAClBC,GAAgB", - "names": ["constant_exports", "__export", "ALPHA_NUM", "ANB", "AN_PLUS_B", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "BIT_FFFF", "BIT_HYPHEN", "CHILD_IDX", "COMBINATOR", "COMBO", "COMPLEX", "COMPLEX_L", "COMPOUND", "COMPOUND_A", "COMPOUND_B", "COMPOUND_I", "DIGIT", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "EMPTY", "HEX", "IDENTIFIER", "KEY_IS_NOT", "LANG_PART", "LOGICAL_COMPLEX", "LOGICAL_COMPOUND", "NESTED_LOGICAL_A", "NESTED_LOGICAL_B", "NOT_SUPPORTED_ERR", "NTH", "N_TH", "PSEUDO_CLASSES", "RAW", "REG_ANCHOR", "REG_COMPLEX", "REG_DIR", "REG_FILTER_COMPLEX", "REG_FILTER_COMPOUND", "REG_FILTER_SIMPLE", "REG_FORM", "REG_FORM_CTRL", "REG_FORM_VALID", "REG_HEX", "REG_INTERACT", "REG_INVALID_SELECTOR", "REG_LANG", "REG_LANG_QUOTED", "REG_LOGICAL_EMPTY", "REG_LOGICAL_PSEUDO", "REG_SHADOW_HOST", "REG_SHADOW_MODE", "REG_SHADOW_PSEUDO", "REG_TAG_NAME", "REG_TYPE_CHECK", "REG_TYPE_DATE", "REG_TYPE_RANGE", "REG_TYPE_RESET", "REG_TYPE_SUBMIT", "REG_TYPE_TEXT", "SELECTOR", "SELECTOR_ATTR", "SELECTOR_CLASS", "SELECTOR_ID", "SELECTOR_LIST", "SELECTOR_PSEUDO_CLASS", "SELECTOR_PSEUDO_ELEMENT", "SELECTOR_TYPE", "SHOW_ALL", "SHOW_DOCUMENT", "SHOW_DOCUMENT_FRAGMENT", "SHOW_ELEMENT", "STRING", "SUB_TYPE", "SYNTAX_ERR", "TAG_TYPE", "TAG_TYPE_I", "TARGET_ALL", "TARGET_FIRST", "TARGET_LINEAL", "TARGET_SELF", "TEXT_NODE", "TYPE_FROM", "TYPE_TO", "U_FFFD", "WALKER_FILTER", "__toCommonJS"] + "sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const AN_PLUS_B = 'AnPlusB';\nexport const COMBINATOR = 'Combinator';\nexport const EMPTY = '__EMPTY__';\nexport const IDENTIFIER = 'Identifier';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const RAW = 'Raw';\nexport const SELECTOR = 'Selector';\nexport const SELECTOR_ATTR = 'AttributeSelector';\nexport const SELECTOR_CLASS = 'ClassSelector';\nexport const SELECTOR_ID = 'IdSelector';\nexport const SELECTOR_LIST = 'SelectorList';\nexport const SELECTOR_PSEUDO_CLASS = 'PseudoClassSelector';\nexport const SELECTOR_PSEUDO_ELEMENT = 'PseudoElementSelector';\nexport const SELECTOR_TYPE = 'TypeSelector';\nexport const STRING = 'String';\nexport const SYNTAX_ERR = 'SyntaxError';\nexport const TARGET_ALL = 'all';\nexport const TARGET_FIRST = 'first';\nexport const TARGET_LINEAL = 'lineal';\nexport const TARGET_SELF = 'self';\nexport const U_FFFD = '\\uFFFD';\n\n/* numeric */\nexport const BIT_01 = 1;\nexport const BIT_02 = 2;\nexport const BIT_04 = 4;\nexport const BIT_08 = 8;\nexport const BIT_16 = 0x10;\nexport const BIT_32 = 0x20;\nexport const BIT_FFFF = 0xFFFF;\nexport const BIT_HYPHEN = 0x2D;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const TYPE_FROM = 8;\nexport const TYPE_TO = -1;\n\n/* Node */\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\nexport const DOCUMENT_POSITION_PRECEDING = 2;\nexport const DOCUMENT_POSITION_CONTAINS = 8;\nexport const DOCUMENT_POSITION_CONTAINED_BY = 0x10;\n\n/* NodeFilter */\nexport const SHOW_ALL = 0xFFFFFFFF;\nexport const SHOW_DOCUMENT = 0x100;\nexport const SHOW_DOCUMENT_FRAGMENT = 0x400;\nexport const SHOW_ELEMENT = 1;\nexport const WALKER_FILTER = 0x501;\n\n/* selectors */\nexport const ALPHA_NUM = '[A-Z\\\\d]+';\nexport const CHILD_IDX = '(?:first|last|only)-(?:child|of-type)';\nexport const DIGIT = '(?:0|[1-9]\\\\d*)';\nexport const LANG_PART = `(?:-${ALPHA_NUM})*`;\nexport const PSEUDO_CLASSES =\n `(?:any-)?link|${CHILD_IDX}|checked|empty|indeterminate|root|target|visited`;\nexport const ANB =\n `[+-]?(?:${DIGIT}n?|n)|(?:[+-]?${DIGIT})?n\\\\s*[+-]\\\\s*${DIGIT}`;\n// N_TH: excludes An+B with selector list, e.g. :nth-child(2n+1 of .foo)\nexport const N_TH =\n `nth-(?:last-)?(?:child|of-type)\\\\(\\\\s*(?:even|odd|${ANB})\\\\s*\\\\)`;\n// SUB_TYPE: attr, id, class, pseudo-class, note that [foo|=bar] is excluded\nexport const SUB_TYPE = '\\\\[[^|\\\\]]+\\\\]|[#.:][\\\\w-]+';\n// TAG_TYPE: *, tag\nexport const TAG_TYPE = '\\\\*|[A-Za-z][\\\\w-]*';\nexport const TAG_TYPE_I = '\\\\*|[A-Z][\\\\w-]*';\nexport const COMPOUND = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`;\nexport const COMBO = '\\\\s?[\\\\s>~+]\\\\s?';\nexport const COMPLEX = `${COMPOUND}(?:${COMBO}${COMPOUND})*`;\nexport const NESTED_LOGICAL_A =\n `:is\\\\(\\\\s*${COMPOUND}(?:\\\\s*,\\\\s*${COMPOUND})*\\\\s*\\\\)`;\nexport const NESTED_LOGICAL_B =\n `:is\\\\(\\\\s*${COMPLEX}(?:\\\\s*,\\\\s*${COMPLEX})*\\\\s*\\\\)`;\nexport const COMPOUND_A =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_A})+)`;\nexport const COMPOUND_B =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_B})+)`;\nexport const COMPOUND_I =\n `(?:${TAG_TYPE_I}|(?:${TAG_TYPE_I})?(?:${SUB_TYPE})+)`;\nexport const COMPLEX_L = `${COMPOUND_B}(?:${COMBO}${COMPOUND_B})*`;\nexport const KEY_IS_NOT = '(?:is|not)';\nexport const LOGICAL_COMPLEX =\n `${KEY_IS_NOT}\\\\(\\\\s*${COMPLEX_L}(?:\\\\s*,\\\\s*${COMPLEX_L})*\\\\s*\\\\)`;\nexport const LOGICAL_COMPOUND =\n `${KEY_IS_NOT}\\\\(\\\\s*${COMPOUND_A}(?:\\\\s*,\\\\s*${COMPOUND_A})*\\\\s*\\\\)`;\n\n/* regexp */\nexport const REG_ANCHOR = /^a(?:rea)?$/;\nexport const REG_COMPLEX = new RegExp(`${COMBO}${COMPOUND_I}`, 'i');\nexport const REG_DIR = /^(?:ltr|rtl)$/;\nexport const REG_FILTER_COMPLEX =\n new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPLEX})`);\nexport const REG_FILTER_COMPOUND =\n new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPOUND})`);\nexport const REG_FILTER_SIMPLE = new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH})`);\nexport const REG_FORM = /^(?:button|fieldset|form|input|select|textarea)$/;\nexport const REG_FORM_CTRL =\n /^(?:button|fieldset|input|optgroup|option|select|textarea)$/;\nexport const REG_FORM_VALID = /^(?:button|form|input|select|textarea)$/;\nexport const REG_HEX = /^([\\da-f]{1,6}\\s?)/i;\nexport const REG_INTERACT = /^(?:details|dialog)$/;\nexport const REG_INVALID_SELECTOR = /^$|^\\s*>|,\\s*$/;\nexport const REG_LANG = new RegExp(`^(?:\\\\*-)?${ALPHA_NUM}${LANG_PART}$`, 'i');\nexport const REG_LANG_QUOTED = /(:lang\\(\\s*(\"[A-Za-z\\d\\-*]*\")\\s*\\))/;\nexport const REG_LOGICAL_EMPTY = /(:(is|where)\\(\\s*\\))/;\nexport const REG_LOGICAL_PSEUDO = /^(?:has|is|not|where)$/;\nexport const REG_SHADOW_HOST = /^host(?:-context)?$/;\nexport const REG_SHADOW_MODE = /^(?:close|open)$/;\nexport const REG_SHADOW_PSEUDO = /^part|slotted$/;\nexport const REG_TAG_NAME = /[A-Z][\\\\w-]*/i;\nexport const REG_TYPE_CHECK = /^(?:checkbox|radio)$/;\nexport const REG_TYPE_INPUT =\n /^(?:date(?:time-local)?|email|month|number|password|search|tel|text|time|url|week)$/;\nexport const REG_TYPE_RANGE =\n /^(?:date(?:time-local)?|month|number|range|time|week)$/;\nexport const REG_TYPE_RESET = /^(?:button|reset)$/;\nexport const REG_TYPE_SUBMIT = /^(?:image|submit)$/;\nexport const REG_TYPE_TEXT = /^(?:email|number|password|search|tel|text|url)$/;\n"], + "mappings": "4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAAAE,EAAA,QAAAC,EAAA,cAAAC,EAAA,WAAAC,GAAA,WAAAC,GAAA,WAAAC,GAAA,WAAAC,GAAA,WAAAC,GAAA,WAAAC,GAAA,aAAAC,GAAA,eAAAC,GAAA,cAAAC,EAAA,eAAAC,EAAA,UAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,UAA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AAUd,CAAU,eAAeA,CAAU,YAG/CyB,GAAa,cACbC,GAAc,IAAI,OAAO,GAAG9B,CAAK,GAAGM,CAAU,GAAI,GAAG,EACrDyB,GAAU,gBACVC,GACX,IAAI,OAAO,OAAOL,CAAc,IAAID,CAAI,IAAIN,CAAe,GAAG,EACnDa,GACX,IAAI,OAAO,OAAON,CAAc,IAAID,CAAI,IAAIL,CAAgB,GAAG,EACpDa,GAAoB,IAAI,OAAO,OAAOP,CAAc,IAAID,CAAI,GAAG,EAC/DS,GAAW,mDACXC,GACX,8DACWC,GAAiB,0CACjBC,GAAU,sBACVC,GAAe,uBACfC,GAAuB,iBACvBC,GAAW,IAAI,OAAO,aAAatD,CAAS,GAAGgC,CAAS,IAAK,GAAG,EAChEuB,GAAkB,sCAClBC,GAAoB,uBACpBC,GAAqB,yBACrBC,GAAkB,sBAClBC,GAAkB,mBAClBC,GAAoB,iBACpBC,GAAe,gBACfC,GAAiB,uBACjBC,GACX,sFACWC,GACX,yDACWC,GAAiB,qBACjBC,GAAkB,qBAClBC,GAAgB", + "names": ["constant_exports", "__export", "ALPHA_NUM", "ANB", "AN_PLUS_B", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "BIT_FFFF", "BIT_HYPHEN", "CHILD_IDX", "COMBINATOR", "COMBO", "COMPLEX", "COMPLEX_L", "COMPOUND", "COMPOUND_A", "COMPOUND_B", "COMPOUND_I", "DIGIT", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "EMPTY", "HEX", "IDENTIFIER", "KEY_IS_NOT", "LANG_PART", "LOGICAL_COMPLEX", "LOGICAL_COMPOUND", "NESTED_LOGICAL_A", "NESTED_LOGICAL_B", "NOT_SUPPORTED_ERR", "NTH", "N_TH", "PSEUDO_CLASSES", "RAW", "REG_ANCHOR", "REG_COMPLEX", "REG_DIR", "REG_FILTER_COMPLEX", "REG_FILTER_COMPOUND", "REG_FILTER_SIMPLE", "REG_FORM", "REG_FORM_CTRL", "REG_FORM_VALID", "REG_HEX", "REG_INTERACT", "REG_INVALID_SELECTOR", "REG_LANG", "REG_LANG_QUOTED", "REG_LOGICAL_EMPTY", "REG_LOGICAL_PSEUDO", "REG_SHADOW_HOST", "REG_SHADOW_MODE", "REG_SHADOW_PSEUDO", "REG_TAG_NAME", "REG_TYPE_CHECK", "REG_TYPE_INPUT", "REG_TYPE_RANGE", "REG_TYPE_RESET", "REG_TYPE_SUBMIT", "REG_TYPE_TEXT", "SELECTOR", "SELECTOR_ATTR", "SELECTOR_CLASS", "SELECTOR_ID", "SELECTOR_LIST", "SELECTOR_PSEUDO_CLASS", "SELECTOR_PSEUDO_ELEMENT", "SELECTOR_TYPE", "SHOW_ALL", "SHOW_DOCUMENT", "SHOW_DOCUMENT_FRAGMENT", "SHOW_ELEMENT", "STRING", "SUB_TYPE", "SYNTAX_ERR", "TAG_TYPE", "TAG_TYPE_I", "TARGET_ALL", "TARGET_FIRST", "TARGET_LINEAL", "TARGET_SELF", "TEXT_NODE", "TYPE_FROM", "TYPE_TO", "U_FFFD", "WALKER_FILTER", "__toCommonJS"] } diff --git a/dist/cjs/js/finder.js b/dist/cjs/js/finder.js index b4eb2430..7381082c 100644 --- a/dist/cjs/js/finder.js +++ b/dist/cjs/js/finder.js @@ -1,2 +1,2 @@ -var C=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var $=(x,c)=>{for(var e in c)C(x,e,{get:c[e],enumerable:!0})},F=(x,c,e,h)=>{if(c&&typeof c=="object"||typeof c=="function")for(let f of D(c))!U.call(x,f)&&f!==e&&C(x,f,{get:()=>c[f],enumerable:!(h=I(c,f))||h.enumerable});return x};var G=x=>F(C({},"__esModule",{value:!0}),x);var H={};$(H,{Finder:()=>W});module.exports=G(H);var T=require("./matcher.js"),g=require("./parser.js"),k=require("./utility.js"),a=require("./constant.js");const v="next",S="prev";class W{#a;#n;#w;#t;#c;#b;#f;#u;#o;#e;#h;#N;#m;#k;#s;#d;#r;#p;#i;#l;constructor(c){this.#l=c,this.#o=new T.Matcher,this.#n=new WeakMap,this.#c=new WeakMap,this.#u=new WeakMap,this.#k=new WeakMap}onError(c,e={}){if(!(e.noexcept??this.#N))if(c instanceof DOMException||c instanceof this.#l.DOMException)if(c.name===a.NOT_SUPPORTED_ERR)this.#i&&console.warn(c.message);else throw new this.#l.DOMException(c.message,c.name);else throw c}setup(c,e,h={}){const{event:f,noexcept:l,warn:r}=h;return this.#N=!!l,this.#i=!!r,this.#b=this._setEvent(f),this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#d=(0,k.isInShadowTree)(e),[this.#a,this.#h]=this._correspond(c),this.#u=new WeakMap,this.#p=new WeakMap,e}_setEvent(c){return c instanceof this.#l.KeyboardEvent||c instanceof this.#l.MouseEvent?c:null}_correspond(c){const e=[];this.#w=!1,this.#f=!1;let h;if(this.#c.has(this.#t)){const f=this.#c.get(this.#t);if(f&&f.has(`${c}`)){const l=f.get(`${c}`);h=l.ast,this.#w=l.descendant,this.#f=l.invalidate}}if(h){const f=h.length;for(let l=0;l]$/.test(w)?b=!0:o=!0,t.push({combo:n,leaves:(0,g.sortAST)(u)}),u.clear()}else if(n){let{name:m}=n;m&&typeof m=="string"&&(m=(0,g.unescapeSelector)(m),typeof m=="string"&&m!==n.name&&(n.name=m),/[|:]/.test(m)&&(n.namespace=!0)),u.add(n)}if(s.length)n=s.shift();else{t.push({combo:null,leaves:(0,g.sortAST)(u)}),u.clear();break}}}h.push({branch:t,collected:!1,dir:null,filtered:!1,find:!1}),e[d]=[],d++}let i;this.#c.has(this.#t)?i=this.#c.get(this.#t):i=new Map,i.set(`${c}`,{ast:h,descendant:b,invalidate:o}),this.#c.set(this.#t,i),this.#w=b,this.#f=o}return[h,e]}_createTreeWalker(c){let e;return this.#p.has(c)?e=this.#p.get(c):(e=this.#t.createTreeWalker(c,a.WALKER_FILTER),this.#p.set(c,e)),e}_prepareQuerySelectorWalker(){return this.#m=this._createTreeWalker(this.#e),this.#m}_collectNthChild(c,e,h){const{a:f,b:l,reverse:r,selector:o}=c,{parentNode:b}=e,d=new Set;let i;if(o)if(this.#n.has(o))i=this.#n.get(o);else{const{branches:s,info:t}=(0,g.walkAST)(o);i=s,this.#n.set(o,i),t.hasLogicalPseudoFunc&&(this.#f=!0)}if(b){const s=this.#r;let t=(0,k.traverseNode)(b,s);t=s.firstChild();let n=0;for(;t;)n++,t=s.nextSibling();const u=new Set;if(i)for(t=(0,k.traverseNode)(b,s),t=s.firstChild();t;){const{display:m,visibility:w}=this.#l.getComputedStyle(t);if(m!=="none"&&w!=="hidden"){let p;for(const N of i)if(p=this._matchLeaves(N,t,h),!p)break;p&&u.add(t)}t=s.nextSibling()}if(f===0){if(l>0&&l<=n){if(u.size){t=(0,k.traverseNode)(b,s),r?t=s.lastChild():t=s.firstChild();let m=0;for(;t;){if(u.has(t)){if(m===l-1){d.add(t);break}m++}r?t=s.previousSibling():t=s.nextSibling()}}else if(!o){t=(0,k.traverseNode)(b,s),r?t=s.lastChild():t=s.firstChild();let m=0;for(;t;){if(m===l-1){d.add(t);break}r?t=s.previousSibling():t=s.nextSibling(),m++}}}}else{let m=l-1;if(f>0)for(;m<0;)m+=f;if(m>=0&&m0?0:l-1;for(;t&&(t&&m>=0&&m0?p++:p--):w===m&&(o||d.add(t),m+=f),r?t=s.previousSibling():t=s.nextSibling(),w++}}if(r&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&f+l===1)if(i){let s;for(const t of i)if(s=this._matchLeaves(t,e,h),s)break;s&&d.add(e)}else d.add(e);return d}_collectNthOfType(c,e){const{a:h,b:f,reverse:l}=c,{localName:r,namespaceURI:o,parentNode:b,prefix:d}=e,i=new Set;if(b){const s=this.#r;let t=(0,k.traverseNode)(b,s);t=s.firstChild();let n=0;for(;t;)n++,t=s.nextSibling();if(h===0){if(f>0&&f<=n){t=(0,k.traverseNode)(b,s),l?t=s.lastChild():t=s.firstChild();let u=0;for(;t;){const{localName:m,namespaceURI:w,prefix:p}=t;if(m===r&&p===d&&w===o){if(u===f-1){i.add(t);break}u++}l?t=s.previousSibling():t=s.nextSibling()}}}else{let u=f-1;if(h>0)for(;u<0;)u+=h;if(u>=0&&u0?0:f-1;for(;t;){const{localName:w,namespaceURI:p,prefix:N}=t;if(w===r&&N===d&&p===o){if(m===u&&(i.add(t),u+=h),u<0||u>=n)break;h>0?m++:m--}l?t=s.previousSibling():t=s.nextSibling()}}}if(l&&i.size>1){const u=[...i];return new Set(u.reverse())}}else e===this.#s&&h+f===1&&i.add(e);return i}_matchAnPlusB(c,e,h,f){const{nth:{a:l,b:r,name:o},selector:b}=c,d=new Map;if(o?(o==="even"?(d.set("a",2),d.set("b",0)):o==="odd"&&(d.set("a",2),d.set("b",1)),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,f)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(c,e,h={}){let f;if(Array.isArray(c)&&c.length){const l=c.map(t=>t),[r]=l,{type:o}=r;let b;o===a.COMBINATOR?b=l.shift():b={name:" ",type:a.COMBINATOR};const d=[];for(;l.length;){const[t]=l,{type:n}=t;if(n===a.COMBINATOR)break;d.push(l.shift())}const i={combo:b,leaves:d};h.dir=v;const s=this._matchCombinator(i,e,h);if(s.size)if(l.length){for(const t of s)if(f=this._matchHasPseudoFunc(l,t,h),f)break}else f=!0}return!!f}_matchLogicalPseudoFunc(c,e,h={}){const{astName:f="",branches:l=[],selector:r="",twigBranches:o=[]}=c;let b;if(f==="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(f);h.forgive=d;const i=o.length;let s;for(let t=0;t0){let w=new Set([e]);for(let p=u-1;p>=0;p--){const N=n[p],_=[];h.dir=S;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?s=!0:w=new Set(_);else{s=!1;break}}}if(s)break}f==="not"?s||(b=e):s&&(b=e)}return b??null}_matchPseudoClassSelector(c,e,h={}){const{children:f,name:l}=c,{localName:r,parentNode:o}=e,{forgive:b,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(l)){let s;if(this.#n.has(c))s=this.#n.get(c);else{const{branches:n}=(0,g.walkAST)(c),u=[],m=[];for(const[...w]of n){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)}s={astName:l,branches:n,twigBranches:m,selector:u.join(",")},this.#n.set(c,s)}const t=this._matchLogicalPseudoFunc(s,e,h);t&&i.add(t)}else if(Array.isArray(f))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[s]=f;return this._matchAnPlusB(s,e,l,h)}else switch(l){case"dir":case"lang":{const s=this.#o.matchSelector(c,e,h,!0);s&&i.add(s);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:s}]=f;if(s)if(e[s])i.add(e);else for(const t in e){const n=e[t];if(n instanceof this.#l.ElementInternals){n?.states?.has(s)&&i.add(e);break}}}break}case"current":case"nth-col":case"nth-last-col":{if(d)throw new DOMException(`Unsupported pseudo-class :${l}()`,a.NOT_SUPPORTED_ERR);break}case"host":case"host-context":break;case"contains":{if(d)throw new DOMException(`Unknown pseudo-class :${l}()`,a.NOT_SUPPORTED_ERR);break}default:if(!b)throw new DOMException(`Unknown pseudo-class :${l}()`,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:s,origin:t,pathname:n}=new URL(this.#t.URL),u=new URL(e.getAttribute("href"),s);u.origin===t&&u.pathname===n&&i.add(e)}break}case"visited":break;case"hover":{const{target:s,type:t}=this.#b??{};(t==="mouseover"||t==="pointerover")&&e.contains(s)&&i.add(e);break}case"active":{const{buttons:s,target:t,type:n}=this.#b??{};(n==="mousedown"||n==="pointerdown")&&s&a.BIT_01&&e.contains(t)&&i.add(e);break}case"target":{const{hash:s}=new URL(this.#t.URL);e.id&&s===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:s}=new URL(this.#t.URL);if(s){const t=s.replace(/^#/,"");let n=this.#t.getElementById(t);for(;n;){if(n===e){i.add(e);break}n=n.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#d&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:s,type:t}=this.#b??{};if(e===this.#t.activeElement&&e.tabIndex>=0&&(l==="focus"||t==="keydown"&&e.contains(s))){let n=e,u=!0;for(;n;){if(n.disabled||n.hasAttribute("disabled")||n.hidden||n.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(n);if(u=!(m==="none"||w==="hidden"),!u)break}if(n.parentNode&&n.parentNode.nodeType===a.ELEMENT_NODE)n=n.parentNode;else break}u&&i.add(e)}break}case"focus-within":{let s,t=this.#t.activeElement;if(t.tabIndex>=0)for(;t;){if(t===e){s=!0;break}t=t.parentNode}if(s){let n=e,u=!0;for(;n;){if(n.disabled||n.hasAttribute("disabled")||n.hidden||n.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(n);if(u=!(m==="none"||w==="hidden"),!u)break}if(n.parentNode&&n.parentNode.nodeType===a.ELEMENT_NODE)n=n.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")o.localName==="optgroup"&&(o.disabled||o.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let s,t=o;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const n=this.#r;let u=(0,k.traverseNode)(t,n);for(u=n.firstChild();u&&u.localName!=="legend";)u=n.nextSibling();u&&u.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===a.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s&&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")(o.localName!=="optgroup"||!(o.disabled||o.hasAttribute("disabled")))&&i.add(e);else{let s,t=o;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const n=this.#r;let u=(0,k.traverseNode)(t,n);for(u=n.firstChild();u&&u.localName!=="legend";)u=n.nextSibling();u&&u.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===a.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s||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 s;if(e.placeholder?s=e.placeholder:e.hasAttribute("placeholder")&&(s=e.getAttribute("placeholder")),typeof s=="string"&&!/[\r\n]/.test(s)){let t;r==="textarea"?t=e:r==="input"&&(e.hasAttribute("type")?a.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(t=e):t=e),t&&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 s=e.name;let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;t||(t=this.#t.documentElement);const n=t.getElementsByTagName("input"),u=n.length;let m;for(let w=0;w=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(r==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let n;if(!t)n=!0;else for(;t&&e.contains(t)&&!(a.REG_FORM_VALID.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?n=t.maxLength>=t.value.length:n=!0:n=!1,!n));)t=s.nextNode();n&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(r))e.checkValidity()?e.maxLength>=0&&e.maxLength=0?n=t.maxLength>=t.value.length:n=!0:n=!1,!n));)t=s.nextNode();n||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 s;if(/^(?:select|textarea)$/.test(r))s=e;else if(r==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||a.REG_TYPE_CHECK.test(t)||a.REG_TYPE_DATE.test(t)||a.REG_TYPE_TEXT.test(t))&&(s=e)}else s=e;s&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let s;if(/^(?:select|textarea)$/.test(r))s=e;else if(r==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||a.REG_TYPE_CHECK.test(t)||a.REG_TYPE_DATE.test(t)||a.REG_TYPE_TEXT.test(t))&&(s=e)}else s=e;s&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#t.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const s=this.#t.createTreeWalker(e,a.SHOW_ALL);let t=s.firstChild(),n;for(;t&&(n=t.nodeType!==a.ELEMENT_NODE&&t.nodeType!==a.TEXT_NODE,!!n);)t=s.nextSibling();n&&i.add(e)}else i.add(e);break}case"first-child":{(o&&e===o.firstElementChild||e===this.#s)&&i.add(e);break}case"last-child":{(o&&e===o.lastElementChild||e===this.#s)&&i.add(e);break}case"only-child":{(o&&e===o.firstElementChild&&e===o.lastElementChild||e===this.#s)&&i.add(e);break}case"first-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1},e);if(s===e){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t===e&&i.add(e)}}else e===this.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||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:s}=this.#l.getComputedStyle(e);s!=="none"&&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 ::${l}`,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)throw new DOMException(`Unsupported pseudo-class :${l}`,a.NOT_SUPPORTED_ERR);break}default:if(l.startsWith("-webkit-")){if(d)throw new DOMException(`Unsupported pseudo-class :${l}`,a.NOT_SUPPORTED_ERR)}else if(!b)throw new DOMException(`Unknown pseudo-class :${l}`,a.SYNTAX_ERR)}return i}_matchShadowHostPseudoClass(c,e){const{children:h,name:f}=c;let l;if(Array.isArray(h)){const{branches:r}=(0,g.walkAST)(h[0]),[o]=r,[...b]=o,{host:d}=e;if(f==="host"){let i;for(const s of b){const{type:t}=s;if(t===a.COMBINATOR){const n=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${n}`,a.SYNTAX_ERR)}if(i=this._matchSelector(s,d).has(d),!i)break}i&&(l=e)}else if(f==="host-context"){let i=d,s;for(;i;){for(const t of b){const{type:n}=t;if(n===a.COMBINATOR){const u=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${u}`,a.SYNTAX_ERR)}if(s=this._matchSelector(t,i).has(i),!s)break}if(s)break;i=i.parentNode}s&&(l=e)}}else if(f==="host")l=e;else throw new DOMException(`Invalid selector :${f}`,a.SYNTAX_ERR);return l??null}_matchSelector(c,e,h){const{type:f}=c,l=new Set;if(c.name===a.EMPTY)return l;const r=(0,g.unescapeSelector)(c.name);if(typeof r=="string"&&r!==c.name&&(c.name=r),e.nodeType===a.ELEMENT_NODE)switch(f){case a.SELECTOR_PSEUDO_ELEMENT:{this.#o.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(c,e,h);default:{const o=this.#o.matchSelector(c,e,h,!0);o&&l.add(o)}}else if(this.#d&&f===a.SELECTOR_PSEUDO_CLASS&&e.nodeType===a.DOCUMENT_FRAGMENT_NODE){if(r!=="has"&&a.REG_LOGICAL_PSEUDO.test(r))return this._matchPseudoClassSelector(c,e,h);if(a.REG_SHADOW_HOST.test(r)){const o=this._matchShadowHostPseudoClass(c,e,h);o&&l.add(o)}}return l}_matchLeaves(c,e,h){let f,l;if(this.#f?l=this.#u.get(c):l=this.#k.get(c),l&&l.has(e)){const{matched:r}=l.get(e);f=r}if(typeof f!="boolean"){let r=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(r=!1);for(const o of c){switch(o.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{r=!1;break}case a.SELECTOR_PSEUDO_CLASS:{/^(?:(?:any-)?link|defined|dir)$/.test(o.name)&&(r=!1);break}default:}if(f=this._matchSelector(o,e,h).has(e),!f)break}r&&(l||(l=new WeakMap),l.set(e,{matched:f}),this.#f?this.#u.set(c,l):this.#k.set(c,l))}return!!f}_matchHTMLCollection(c,e={}){const{compound:h,filterLeaves:f}=e,l=new Set,r=c.length;if(r)if(h)for(let o=0;o0,{type:o}=f,b=(0,g.unescapeSelector)(f.name);typeof b=="string"&&b!==f.name&&(f.name=b);let d=new Set,i=!1;if(this.#d)i=!0;else switch(o){case a.SELECTOR_PSEUDO_ELEMENT:{this.#o.matchPseudoElementSelector(b,h);break}case a.SELECTOR_ID:{if(this.#s.nodeType===a.ELEMENT_NODE)i=!0;else{const s=this.#s.getElementById(b);s&&s!==e&&e.contains(s)&&(r?this._matchLeaves(l,s,h)&&d.add(s):d.add(s))}break}case a.SELECTOR_CLASS:{const s=e.getElementsByClassName(b);d=this._matchHTMLCollection(s,{compound:r,filterLeaves:l});break}case a.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(b)){const s=e.getElementsByTagName(b);d=this._matchHTMLCollection(s,{compound:r,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(c,e,h={}){const{combo:f,leaves:l}=c,{name:r}=f,{parentNode:o}=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(o){const i=this._createTreeWalker(o);let s=(0,k.traverseNode)(e,i);for(s=i.nextSibling();s;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let s=(0,k.traverseNode)(e,i);for(s=i.firstChild();s;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling();break}case" ":default:{const{nodes:i,pending:s}=this._findDescendantNodes(l,e);if(i.size)return i;if(s){const t=this._createTreeWalker(e);let n=(0,k.traverseNode)(e,t);for(n=t.nextNode();n&&e.contains(n);)this._matchLeaves(l,n,h)&&d.add(n),n=t.nextNode()}}}else switch(r){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(o){const i=this._createTreeWalker(o);let s=(0,k.traverseNode)(o,i);for(s=i.firstChild();s&&s!==e;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling()}break}case">":{o&&this._matchLeaves(l,o,h)&&d.add(o);break}case" ":default:{const i=[];let s=o;for(;s;)this._matchLeaves(l,s,h)&&i.push(s),s=s.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(c,e){const{node:h}=e,f=this.#m;let l=(0,k.traverseNode)(h,f),r;if(l)for((l.nodeType!==a.ELEMENT_NODE||l===h&&l!==this.#s)&&(l=f.nextNode());l;){if(this._matchLeaves(c,l,{warn:this.#i})){r=l;break}l=f.nextNode()}return r??null}_matchSelf(c){const e=[],h=this._matchLeaves(c,this.#e,{warn:this.#i});let f=!1;return h&&(e.push(this.#e),f=!0),[e,f]}_findLineal(c,e={}){const{complex:h}=e,f=[];let l=this._matchLeaves(c,this.#e,{warn:this.#i}),r=!1;if(l&&(f.push(this.#e),r=!0),!l||h){let o=this.#e.parentNode;for(;o&&(l=this._matchLeaves(c,o,{warn:this.#i}),l&&(f.push(o),r=!0),o.parentNode);)o=o.parentNode}return[f,r]}_findFirst(c){const e=[],h=this._findNode(c,{node:this.#e});let f=!1;return h&&(e.push(h),f=!0),[e,f]}_findFromHTMLCollection(c,e={}){const{complex:h,compound:f,filterLeaves:l,targetType:r}=e;let o=[],b=!1,d=!1;const i=c.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let s=0;s0,{name:b,type:d}=l;let i=[],s=!1,t=!1,n=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{this.#o.matchPseudoElementSelector(b,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(f);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(f,{complex:h});else if(e===a.TARGET_FIRST&&this.#s.nodeType!==a.ELEMENT_NODE){const u=this.#s.getElementById(b);u&&(o?this._matchLeaves(r,u,{warn:this.#i})&&(i.push(u),t=!0):(i.push(u),t=!0))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(f):n=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(f);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(f,{complex:h});else if(this.#s.nodeType===a.DOCUMENT_NODE){const u=this.#s.getElementsByClassName(b);u.length&&([i,t,s]=this._findFromHTMLCollection(u,{complex:h,compound:o,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(f):n=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(f);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(f,{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,t,s]=this._findFromHTMLCollection(u,{complex:h,compound:o,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(f):n=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(b)){if(this.#d&&this.#e.nodeType===a.DOCUMENT_FRAGMENT_NODE){const u=this._matchShadowHostPseudoClass(l,this.#e);u&&(i.push(u),t=!0)}}else e===a.TARGET_SELF?[i,t]=this._matchSelf(f):e===a.TARGET_LINEAL?[i,t]=this._findLineal(f,{complex:h}):e===a.TARGET_FIRST?[i,t]=this._findFirst(f):n=!0}return{collected:s,compound:o,filtered:t,nodes:i,pending:n}}_collectNodes(c){const e=this.#a.values();if(c===a.TARGET_ALL||c===a.TARGET_FIRST){const h=new Set;let f=0;for(const{branch:l}of e){const r=l.length,o=r>1,b=l[0];let d,i;if(o){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(c===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:L,leaves:[R]}of l){const{name:O,type:M}=R;if(M===a.SELECTOR_PSEUDO_CLASS&&O==="dir"){A=!1;break}if(!A&&L){const{name:P}=L;/^[+~]$/.test(P)&&(A=!0)}}A?(d=v,i=b):(d=S,i=_)}}else d=S,i=b;const{collected:s,compound:t,filtered:n,nodes:u,pending:m}=this._findEntryNodes(i,c,o);u.length?(this.#a[f].find=!0,this.#h[f]=u):m&&h.add(new Map([["index",f],["twig",i]])),this.#a[f].collected=s,this.#a[f].dir=d,this.#a[f].filtered=n||!t,f++}if(h.size){let l,r;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(l=this.#e,r=this.#m):(l=this.#s,r=this.#r);let o=(0,k.traverseNode)(l,r);for(;o;){let b=!1;if(this.#e.nodeType===a.ELEMENT_NODE?o===this.#e?b=!0:b=this.#e.contains(o):b=!0,b)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,o,{warn:this.#i})){const t=d.get("index");this.#a[t].filtered=!0,this.#a[t].find=!0,this.#h[t].push(o)}}o!==r.currentNode&&(o=(0,k.traverseNode)(o,r)),o=r.nextNode()}}}else{let h=0;for(const{branch:f}of e){const l=f[f.length-1],r=f.length>1,{compound:o,filtered:b,nodes:d}=this._findEntryNodes(l,c,r);d.length&&(this.#a[h].find=!0,this.#h[h]=d),this.#a[h].dir=S,this.#a[h].filtered=b||!o,h++}}return[this.#a,this.#h]}_getCombinedNodes(c,e,h){const f=[];for(const l of e){const r=this._matchCombinator(c,l,{dir:h,warn:this.#i});r.size&&f.push(...r)}return f.length?new Set(f):new Set}_matchNodeNext(c,e,h){const{combo:f,index:l}=h,{combo:r,leaves:o}=c[l],b={combo:f,leaves:o},d=this._getCombinedNodes(b,e,v);let i;if(d.size)if(l===c.length-1){const[s]=(0,k.sortNodes)(d);i=s}else i=this._matchNodeNext(c,d,{combo:r,index:l+1});return i??null}_matchNodePrev(c,e,h){const{index:f}=h,l=c[f],r=new Set([e]),o=this._getCombinedNodes(l,r,S);let b;if(o.size){if(f===0)b=e;else for(const d of o)if(this._matchNodePrev(c,d,{index:f-1}))return e}return b??null}find(c){(c===a.TARGET_ALL||c===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(c),f=e.length;let l,r=new Set;for(let o=0;o=0;N--){const _=b[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(r.add(w),t>1&&r.size>1&&(l=!0));else break}}else if(c===a.TARGET_FIRST&&i===v){const{combo:w}=b[0];let p;for(const N of n)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],[_]=n;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 n)if(w=this._matchNodePrev(b,p,{index:m-1}),w){r.add(p);break}if(!w&&!d&&c===a.TARGET_FIRST){const{leaves:p}=b[m],[N]=n;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(b,_,{index:m-1}),w){r.add(_);break}_=this._findNode(p,{node:_})}}}}}return c===a.TARGET_FIRST?(r.delete(this.#e),r.size>1&&(r=new Set((0,k.sortNodes)(r)))):c===a.TARGET_ALL&&(r.delete(this.#e),l&&r.size>1&&(r=new Set((0,k.sortNodes)(r)))),r}}0&&(module.exports={Finder}); +var T=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var $=(x,n)=>{for(var e in n)T(x,e,{get:n[e],enumerable:!0})},F=(x,n,e,h)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of D(n))!U.call(x,c)&&c!==e&&T(x,c,{get:()=>n[c],enumerable:!(h=I(n,c))||h.enumerable});return x};var G=x=>F(T({},"__esModule",{value:!0}),x);var z={};$(z,{Finder:()=>H});module.exports=G(z);var C=require("./matcher.js"),g=require("./parser.js"),k=require("./utility.js"),a=require("./constant.js");const v="next",S="prev",W="Tab";class H{#l;#c;#w;#t;#o;#n;#k;#f;#b;#h;#e;#d;#_;#m;#N;#s;#u;#r;#p;#i;#a;constructor(n){this.#a=n,this.#h=new C.Matcher,this.#c=new WeakMap,this.#o=new WeakMap,this.#b=new WeakMap,this.#N=new WeakMap,this.#n=null,this.#k=null,this._registerEventListeners()}onError(n,e={}){if(!(e.noexcept??this.#_))if(n instanceof DOMException||n instanceof this.#a.DOMException)if(n.name===a.NOT_SUPPORTED_ERR)this.#i&&console.warn(n.message);else throw new this.#a.DOMException(n.message,n.name);else throw n}setup(n,e,h={}){const{event:c,noexcept:l,warn:r}=h;return this.#_=!!l,this.#i=!!r,this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#u=(0,k.isInShadowTree)(e),[this.#l,this.#d]=this._correspond(n),this.#b=new WeakMap,this.#p=new WeakMap,this._setEvent(c),e}_registerEventListeners(){const n={capture:!0,passive:!0},e=[],h=["mouseover","mousedown","mouseup","mouseout"];for(const l of h)e.push(this.#a.addEventListener(l,r=>{this.#n=r},n));const c=["keydown","keyup"];for(const l of c)e.push(this.#a.addEventListener(l,r=>{r.key===W&&(this.#n=r)},n));return e.push(this.#a.addEventListener("focusin",l=>{this.#k=l},n)),e}_setEvent(n){return(n instanceof this.#a.KeyboardEvent||n instanceof this.#a.MouseEvent)&&(this.#n=n),this.#n}_correspond(n){const e=[];this.#w=!1,this.#f=!1;let h;if(this.#o.has(this.#t)){const c=this.#o.get(this.#t);if(c&&c.has(`${n}`)){const l=c.get(`${n}`);h=l.ast,this.#w=l.descendant,this.#f=l.invalidate}}if(h){const c=h.length;for(let l=0;l]$/.test(w)?u=!0:o=!0,t.push({combo:f,leaves:(0,g.sortAST)(b)}),b.clear()}else if(f){let{name:m}=f;m&&typeof m=="string"&&(m=(0,g.unescapeSelector)(m),typeof m=="string"&&m!==f.name&&(f.name=m),/[|:]/.test(m)&&(f.namespace=!0)),b.add(f)}if(s.length)f=s.shift();else{t.push({combo:null,leaves:(0,g.sortAST)(b)}),b.clear();break}}}h.push({branch:t,collected:!1,dir:null,filtered:!1,find:!1}),e[d]=[],d++}let i;this.#o.has(this.#t)?i=this.#o.get(this.#t):i=new Map,i.set(`${n}`,{ast:h,descendant:u,invalidate:o}),this.#o.set(this.#t,i),this.#w=u,this.#f=o}return[h,e]}_createTreeWalker(n){let e;return this.#p.has(n)?e=this.#p.get(n):(e=this.#t.createTreeWalker(n,a.WALKER_FILTER),this.#p.set(n,e)),e}_prepareQuerySelectorWalker(){return this.#m=this._createTreeWalker(this.#e),this.#m}_collectNthChild(n,e,h){const{a:c,b:l,reverse:r,selector:o}=n,{parentNode:u}=e,d=new Set;let i;if(o)if(this.#c.has(o))i=this.#c.get(o);else{const{branches:s,info:t}=(0,g.walkAST)(o);i=s,this.#c.set(o,i),t.hasLogicalPseudoFunc&&(this.#f=!0)}if(u){const s=this.#r;let t=(0,k.traverseNode)(u,s);t=s.firstChild();let f=0;for(;t;)f++,t=s.nextSibling();const b=new Set;if(i)for(t=(0,k.traverseNode)(u,s),t=s.firstChild();t;){const{display:m,visibility:w}=this.#a.getComputedStyle(t);if(m!=="none"&&w!=="hidden"){let p;for(const N of i)if(p=this._matchLeaves(N,t,h),!p)break;p&&b.add(t)}t=s.nextSibling()}if(c===0){if(l>0&&l<=f){if(b.size){t=(0,k.traverseNode)(u,s),r?t=s.lastChild():t=s.firstChild();let m=0;for(;t;){if(b.has(t)){if(m===l-1){d.add(t);break}m++}r?t=s.previousSibling():t=s.nextSibling()}}else if(!o){t=(0,k.traverseNode)(u,s),r?t=s.lastChild():t=s.firstChild();let m=0;for(;t;){if(m===l-1){d.add(t);break}r?t=s.previousSibling():t=s.nextSibling(),m++}}}}else{let m=l-1;if(c>0)for(;m<0;)m+=c;if(m>=0&&m0?0:l-1;for(;t&&(t&&m>=0&&m0?p++:p--):w===m&&(o||d.add(t),m+=c),r?t=s.previousSibling():t=s.nextSibling(),w++}}if(r&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&c+l===1)if(i){let s;for(const t of i)if(s=this._matchLeaves(t,e,h),s)break;s&&d.add(e)}else d.add(e);return d}_collectNthOfType(n,e){const{a:h,b:c,reverse:l}=n,{localName:r,namespaceURI:o,parentNode:u,prefix:d}=e,i=new Set;if(u){const s=this.#r;let t=(0,k.traverseNode)(u,s);t=s.firstChild();let f=0;for(;t;)f++,t=s.nextSibling();if(h===0){if(c>0&&c<=f){t=(0,k.traverseNode)(u,s),l?t=s.lastChild():t=s.firstChild();let b=0;for(;t;){const{localName:m,namespaceURI:w,prefix:p}=t;if(m===r&&p===d&&w===o){if(b===c-1){i.add(t);break}b++}l?t=s.previousSibling():t=s.nextSibling()}}}else{let b=c-1;if(h>0)for(;b<0;)b+=h;if(b>=0&&b0?0:c-1;for(;t;){const{localName:w,namespaceURI:p,prefix:N}=t;if(w===r&&N===d&&p===o){if(m===b&&(i.add(t),b+=h),b<0||b>=f)break;h>0?m++:m--}l?t=s.previousSibling():t=s.nextSibling()}}}if(l&&i.size>1){const b=[...i];return new Set(b.reverse())}}else e===this.#s&&h+c===1&&i.add(e);return i}_matchAnPlusB(n,e,h,c){const{nth:{a:l,b:r,name:o},selector:u}=n,d=new Map;if(o?(o==="even"?(d.set("a",2),d.set("b",0)):o==="odd"&&(d.set("a",2),d.set("b",1)),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)){u&&d.set("selector",u);const i=Object.fromEntries(d);return this._collectNthChild(i,e,c)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(n,e,h={}){let c;if(Array.isArray(n)&&n.length){const l=n.map(t=>t),[r]=l,{type:o}=r;let u;o===a.COMBINATOR?u=l.shift():u={name:" ",type:a.COMBINATOR};const d=[];for(;l.length;){const[t]=l,{type:f}=t;if(f===a.COMBINATOR)break;d.push(l.shift())}const i={combo:u,leaves:d};h.dir=v;const s=this._matchCombinator(i,e,h);if(s.size)if(l.length){for(const t of s)if(c=this._matchHasPseudoFunc(l,t,h),c)break}else c=!0}return!!c}_matchLogicalPseudoFunc(n,e,h={}){const{astName:c="",branches:l=[],selector:r="",twigBranches:o=[]}=n;let u;if(c==="has")if(r.includes(":has("))u=null;else{let d;for(const i of l)if(d=this._matchHasPseudoFunc(i,e,h),d)break;d&&(u=e)}else{const d=/^(?:is|where)$/.test(c);h.forgive=d;const i=o.length;let s;for(let t=0;t0){let w=new Set([e]);for(let p=b-1;p>=0;p--){const N=f[p],_=[];h.dir=S;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?s=!0:w=new Set(_);else{s=!1;break}}}if(s)break}c==="not"?s||(u=e):s&&(u=e)}return u??null}_matchPseudoClassSelector(n,e,h={}){const{children:c,name:l}=n,{localName:r,parentNode:o}=e,{forgive:u,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(l)){let s;if(this.#c.has(n))s=this.#c.get(n);else{const{branches:f}=(0,g.walkAST)(n),b=[],m=[];for(const[...w]of f){for(const y of w){const E=(0,g.generateCSS)(y);b.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)}s={astName:l,branches:f,twigBranches:m,selector:b.join(",")},this.#c.set(n,s)}const t=this._matchLogicalPseudoFunc(s,e,h);t&&i.add(t)}else if(Array.isArray(c))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[s]=c;return this._matchAnPlusB(s,e,l,h)}else switch(l){case"dir":case"lang":{const s=this.#h.matchSelector(n,e,h,!0);s&&i.add(s);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:s}]=c;if(s)if(e[s])i.add(e);else for(const t in e){const f=e[t];if(f instanceof this.#a.ElementInternals){f?.states?.has(s)&&i.add(e);break}}}break}case"current":case"nth-col":case"nth-last-col":{if(d)throw new DOMException(`Unsupported pseudo-class :${l}()`,a.NOT_SUPPORTED_ERR);break}case"host":case"host-context":break;case"contains":{if(d)throw new DOMException(`Unknown pseudo-class :${l}()`,a.NOT_SUPPORTED_ERR);break}default:if(!u)throw new DOMException(`Unknown pseudo-class :${l}()`,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:s,origin:t,pathname:f}=new URL(this.#t.URL),b=new URL(e.getAttribute("href"),s);b.origin===t&&b.pathname===f&&i.add(e)}break}case"visited":break;case"hover":{const{target:s,type:t}=this.#n??{};/^(?:mouse|pointer)(?:down|over|up)$/.test(t)&&e.contains(s)&&i.add(e);break}case"active":{const{buttons:s,target:t,type:f}=this.#n??{};/(?:mouse|pointer)down/.test(f)&&s&a.BIT_01&&e.contains(t)&&i.add(e);break}case"target":{const{hash:s}=new URL(this.#t.URL);e.id&&s===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:s}=new URL(this.#t.URL);if(s){const t=s.replace(/^#/,"");let f=this.#t.getElementById(t);for(;f;){if(f===e){i.add(e);break}f=f.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#u&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":{e===this.#t.activeElement&&e.tabIndex>=0&&(0,k.isFocusable)(e)&&i.add(e);break}case"focus-visible":{if(e===this.#t.activeElement&&e.tabIndex>=0){let s;if((0,k.isFocusVisible)(e))s=!0;else{const{target:t,type:f}=this.#n??{},{target:b,relatedTarget:m}=this.#k??{};(/^key(?:down|up)$/.test(f)&&e.contains(t)||m&&(0,k.isFocusVisible)(m)&&e.contains(b))&&(s=!0)}s&&(0,k.isFocusable)(e)&&i.add(e)}break}case"focus-within":{let s,t=this.#t.activeElement;if(t.tabIndex>=0)for(;t;){if(t===e){s=!0;break}t=t.parentNode}s&&(0,k.isFocusable)(e)&&i.add(e);break}case"open":{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")o.localName==="optgroup"&&(o.disabled||o.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let s,t=o;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const f=this.#r;let b=(0,k.traverseNode)(t,f);for(b=f.firstChild();b&&b.localName!=="legend";)b=f.nextSibling();b&&b.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===a.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s&&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")(o.localName!=="optgroup"||!(o.disabled||o.hasAttribute("disabled")))&&i.add(e);else{let s,t=o;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const f=this.#r;let b=(0,k.traverseNode)(t,f);for(b=f.firstChild();b&&b.localName!=="legend";)b=f.nextSibling();b&&b.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===a.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s||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_INPUT.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_INPUT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let s;if(e.placeholder?s=e.placeholder:e.hasAttribute("placeholder")&&(s=e.getAttribute("placeholder")),typeof s=="string"&&!/[\r\n]/.test(s)){let t;r==="textarea"?t=e:r==="input"&&(e.hasAttribute("type")?a.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(t=e):t=e),t&&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 s=e.name;let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;t||(t=this.#t.documentElement);const f=t.getElementsByTagName("input"),b=f.length;let m;for(let w=0;w=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(r==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let f;if(!t)f=!0;else for(;t&&e.contains(t)&&!(a.REG_FORM_VALID.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?f=t.maxLength>=t.value.length:f=!0:f=!1,!f));)t=s.nextNode();f&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(r))e.checkValidity()?e.maxLength>=0&&e.maxLength=0?f=t.maxLength>=t.value.length:f=!0:f=!1,!f));)t=s.nextNode();f||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 s;if(/^(?:select|textarea)$/.test(r))s=e;else if(r==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||a.REG_TYPE_CHECK.test(t)||a.REG_TYPE_INPUT.test(t))&&(s=e)}else s=e;s&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let s;if(/^(?:select|textarea)$/.test(r))s=e;else if(r==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||a.REG_TYPE_CHECK.test(t)||a.REG_TYPE_INPUT.test(t))&&(s=e)}else s=e;s&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#t.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const s=this.#t.createTreeWalker(e,a.SHOW_ALL);let t=s.firstChild(),f;for(;t&&(f=t.nodeType!==a.ELEMENT_NODE&&t.nodeType!==a.TEXT_NODE,!!f);)t=s.nextSibling();f&&i.add(e)}else i.add(e);break}case"first-child":{(o&&e===o.firstElementChild||e===this.#s)&&i.add(e);break}case"last-child":{(o&&e===o.lastElementChild||e===this.#s)&&i.add(e);break}case"only-child":{(o&&e===o.firstElementChild&&e===o.lastElementChild||e===this.#s)&&i.add(e);break}case"first-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1},e);if(s===e){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t===e&&i.add(e)}}else e===this.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||r.includes("-")?(0,k.isCustomElement)(e)&&i.add(e):(e instanceof this.#a.HTMLElement||e instanceof this.#a.SVGElement)&&i.add(e);break}case"popover-open":{if(e.popover){const{display:s}=this.#a.getComputedStyle(e);s!=="none"&&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 ::${l}`,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)throw new DOMException(`Unsupported pseudo-class :${l}`,a.NOT_SUPPORTED_ERR);break}default:if(l.startsWith("-webkit-")){if(d)throw new DOMException(`Unsupported pseudo-class :${l}`,a.NOT_SUPPORTED_ERR)}else if(!u)throw new DOMException(`Unknown pseudo-class :${l}`,a.SYNTAX_ERR)}return i}_matchShadowHostPseudoClass(n,e){const{children:h,name:c}=n;let l;if(Array.isArray(h)){const{branches:r}=(0,g.walkAST)(h[0]),[o]=r,[...u]=o,{host:d}=e;if(c==="host"){let i;for(const s of u){const{type:t}=s;if(t===a.COMBINATOR){const f=(0,g.generateCSS)(n);throw new DOMException(`Invalid selector ${f}`,a.SYNTAX_ERR)}if(i=this._matchSelector(s,d).has(d),!i)break}i&&(l=e)}else if(c==="host-context"){let i=d,s;for(;i;){for(const t of u){const{type:f}=t;if(f===a.COMBINATOR){const b=(0,g.generateCSS)(n);throw new DOMException(`Invalid selector ${b}`,a.SYNTAX_ERR)}if(s=this._matchSelector(t,i).has(i),!s)break}if(s)break;i=i.parentNode}s&&(l=e)}}else if(c==="host")l=e;else throw new DOMException(`Invalid selector :${c}`,a.SYNTAX_ERR);return l??null}_matchSelector(n,e,h){const{type:c}=n,l=new Set;if(n.name===a.EMPTY)return l;const r=(0,g.unescapeSelector)(n.name);if(typeof r=="string"&&r!==n.name&&(n.name=r),e.nodeType===a.ELEMENT_NODE)switch(c){case a.SELECTOR_PSEUDO_ELEMENT:{this.#h.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(n,e,h);default:{const o=this.#h.matchSelector(n,e,h,!0);o&&l.add(o)}}else if(this.#u&&c===a.SELECTOR_PSEUDO_CLASS&&e.nodeType===a.DOCUMENT_FRAGMENT_NODE){if(r!=="has"&&a.REG_LOGICAL_PSEUDO.test(r))return this._matchPseudoClassSelector(n,e,h);if(a.REG_SHADOW_HOST.test(r)){const o=this._matchShadowHostPseudoClass(n,e,h);o&&l.add(o)}}return l}_matchLeaves(n,e,h){let c,l;if(this.#f?l=this.#b.get(n):l=this.#N.get(n),l&&l.has(e)){const{matched:r}=l.get(e);c=r}if(typeof c!="boolean"){let r=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(r=!1);for(const o of n){switch(o.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{r=!1;break}case a.SELECTOR_PSEUDO_CLASS:{/^(?:(?:any-)?link|defined|dir)$/.test(o.name)&&(r=!1);break}default:}if(c=this._matchSelector(o,e,h).has(e),!c)break}r&&(l||(l=new WeakMap),l.set(e,{matched:c}),this.#f?this.#b.set(n,l):this.#N.set(n,l))}return!!c}_matchHTMLCollection(n,e={}){const{compound:h,filterLeaves:c}=e,l=new Set,r=n.length;if(r)if(h)for(let o=0;o0,{type:o}=c,u=(0,g.unescapeSelector)(c.name);typeof u=="string"&&u!==c.name&&(c.name=u);let d=new Set,i=!1;if(this.#u)i=!0;else switch(o){case a.SELECTOR_PSEUDO_ELEMENT:{this.#h.matchPseudoElementSelector(u,h);break}case a.SELECTOR_ID:{if(this.#s.nodeType===a.ELEMENT_NODE)i=!0;else{const s=this.#s.getElementById(u);s&&s!==e&&e.contains(s)&&(r?this._matchLeaves(l,s,h)&&d.add(s):d.add(s))}break}case a.SELECTOR_CLASS:{const s=e.getElementsByClassName(u);d=this._matchHTMLCollection(s,{compound:r,filterLeaves:l});break}case a.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(u)){const s=e.getElementsByTagName(u);d=this._matchHTMLCollection(s,{compound:r,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(n,e,h={}){const{combo:c,leaves:l}=n,{name:r}=c,{parentNode:o}=e,{dir:u}=h,d=new Set;if(u===v)switch(r){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(o){const i=this._createTreeWalker(o);let s=(0,k.traverseNode)(e,i);for(s=i.nextSibling();s;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let s=(0,k.traverseNode)(e,i);for(s=i.firstChild();s;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling();break}case" ":default:{const{nodes:i,pending:s}=this._findDescendantNodes(l,e);if(i.size)return i;if(s){const t=this._createTreeWalker(e);let f=(0,k.traverseNode)(e,t);for(f=t.nextNode();f&&e.contains(f);)this._matchLeaves(l,f,h)&&d.add(f),f=t.nextNode()}}}else switch(r){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(o){const i=this._createTreeWalker(o);let s=(0,k.traverseNode)(o,i);for(s=i.firstChild();s&&s!==e;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling()}break}case">":{o&&this._matchLeaves(l,o,h)&&d.add(o);break}case" ":default:{const i=[];let s=o;for(;s;)this._matchLeaves(l,s,h)&&i.push(s),s=s.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(n,e){const{node:h}=e,c=this.#m;let l=(0,k.traverseNode)(h,c),r;if(l)for((l.nodeType!==a.ELEMENT_NODE||l===h&&l!==this.#s)&&(l=c.nextNode());l;){if(this._matchLeaves(n,l,{warn:this.#i})){r=l;break}l=c.nextNode()}return r??null}_matchSelf(n){const e=[],h=this._matchLeaves(n,this.#e,{warn:this.#i});let c=!1;return h&&(e.push(this.#e),c=!0),[e,c]}_findLineal(n,e={}){const{complex:h}=e,c=[];let l=this._matchLeaves(n,this.#e,{warn:this.#i}),r=!1;if(l&&(c.push(this.#e),r=!0),!l||h){let o=this.#e.parentNode;for(;o&&(l=this._matchLeaves(n,o,{warn:this.#i}),l&&(c.push(o),r=!0),o.parentNode);)o=o.parentNode}return[c,r]}_findFirst(n){const e=[],h=this._findNode(n,{node:this.#e});let c=!1;return h&&(e.push(h),c=!0),[e,c]}_findFromHTMLCollection(n,e={}){const{complex:h,compound:c,filterLeaves:l,targetType:r}=e;let o=[],u=!1,d=!1;const i=n.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let s=0;s0,{name:u,type:d}=l;let i=[],s=!1,t=!1,f=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{this.#h.matchPseudoElementSelector(u,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(c);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(c,{complex:h});else if(e===a.TARGET_FIRST&&this.#s.nodeType!==a.ELEMENT_NODE){const b=this.#s.getElementById(u);b&&(o?this._matchLeaves(r,b,{warn:this.#i})&&(i.push(b),t=!0):(i.push(b),t=!0))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(c):f=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(c);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(c,{complex:h});else if(this.#s.nodeType===a.DOCUMENT_NODE){const b=this.#s.getElementsByClassName(u);b.length&&([i,t,s]=this._findFromHTMLCollection(b,{complex:h,compound:o,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(c):f=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(c);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(c,{complex:h});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===a.DOCUMENT_NODE&&!/[*|]/.test(u)){const b=this.#s.getElementsByTagName(u);b.length&&([i,t,s]=this._findFromHTMLCollection(b,{complex:h,compound:o,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(c):f=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(u)){if(this.#u&&this.#e.nodeType===a.DOCUMENT_FRAGMENT_NODE){const b=this._matchShadowHostPseudoClass(l,this.#e);b&&(i.push(b),t=!0)}}else e===a.TARGET_SELF?[i,t]=this._matchSelf(c):e===a.TARGET_LINEAL?[i,t]=this._findLineal(c,{complex:h}):e===a.TARGET_FIRST?[i,t]=this._findFirst(c):f=!0}return{collected:s,compound:o,filtered:t,nodes:i,pending:f}}_collectNodes(n){const e=this.#l.values();if(n===a.TARGET_ALL||n===a.TARGET_FIRST){const h=new Set;let c=0;for(const{branch:l}of e){const r=l.length,o=r>1,u=l[0];let d,i;if(o){const{combo:w,leaves:[{name:p,type:N}]}=u,_=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=u;else if(n===a.TARGET_ALL)if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=u;else if(r===2){const{name:A}=w;/^[+~]$/.test(A)?(d=S,i=_):(d=v,i=u)}else d=v,i=u;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=u;else if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else{let A;for(const{combo:L,leaves:[R]}of l){const{name:O,type:M}=R;if(M===a.SELECTOR_PSEUDO_CLASS&&O==="dir"){A=!1;break}if(!A&&L){const{name:P}=L;/^[+~]$/.test(P)&&(A=!0)}}A?(d=v,i=u):(d=S,i=_)}}else d=S,i=u;const{collected:s,compound:t,filtered:f,nodes:b,pending:m}=this._findEntryNodes(i,n,o);b.length?(this.#l[c].find=!0,this.#d[c]=b):m&&h.add(new Map([["index",c],["twig",i]])),this.#l[c].collected=s,this.#l[c].dir=d,this.#l[c].filtered=f||!t,c++}if(h.size){let l,r;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(l=this.#e,r=this.#m):(l=this.#s,r=this.#r);let o=(0,k.traverseNode)(l,r);for(;o;){let u=!1;if(this.#e.nodeType===a.ELEMENT_NODE?o===this.#e?u=!0:u=this.#e.contains(o):u=!0,u)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,o,{warn:this.#i})){const t=d.get("index");this.#l[t].filtered=!0,this.#l[t].find=!0,this.#d[t].push(o)}}o!==r.currentNode&&(o=(0,k.traverseNode)(o,r)),o=r.nextNode()}}}else{let h=0;for(const{branch:c}of e){const l=c[c.length-1],r=c.length>1,{compound:o,filtered:u,nodes:d}=this._findEntryNodes(l,n,r);d.length&&(this.#l[h].find=!0,this.#d[h]=d),this.#l[h].dir=S,this.#l[h].filtered=u||!o,h++}}return[this.#l,this.#d]}_getCombinedNodes(n,e,h){const c=[];for(const l of e){const r=this._matchCombinator(n,l,{dir:h,warn:this.#i});r.size&&c.push(...r)}return c.length?new Set(c):new Set}_matchNodeNext(n,e,h){const{combo:c,index:l}=h,{combo:r,leaves:o}=n[l],u={combo:c,leaves:o},d=this._getCombinedNodes(u,e,v);let i;if(d.size)if(l===n.length-1){const[s]=(0,k.sortNodes)(d);i=s}else i=this._matchNodeNext(n,d,{combo:r,index:l+1});return i??null}_matchNodePrev(n,e,h){const{index:c}=h,l=n[c],r=new Set([e]),o=this._getCombinedNodes(l,r,S);let u;if(o.size){if(c===0)u=e;else for(const d of o)if(this._matchNodePrev(n,d,{index:c-1}))return e}return u??null}find(n){(n===a.TARGET_ALL||n===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(n),c=e.length;let l,r=new Set;for(let o=0;o=0;N--){const _=u[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(r.add(w),t>1&&r.size>1&&(l=!0));else break}}else if(n===a.TARGET_FIRST&&i===v){const{combo:w}=u[0];let p;for(const N of f)if(p=this._matchNodeNext(u,new Set([N]),{combo:w,index:1}),p){r.add(p);break}if(!p&&!d){const{leaves:N}=u[0],[_]=f;let y=this._findNode(N,{node:_});for(;y;){if(p=this._matchNodeNext(u,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 f)if(w=this._matchNodePrev(u,p,{index:m-1}),w){r.add(p);break}if(!w&&!d&&n===a.TARGET_FIRST){const{leaves:p}=u[m],[N]=f;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(u,_,{index:m-1}),w){r.add(_);break}_=this._findNode(p,{node:_})}}}}}return n===a.TARGET_FIRST?(r.delete(this.#e),r.size>1&&(r=new Set((0,k.sortNodes)(r)))):n===a.TARGET_ALL&&(r.delete(this.#e),l&&r.size>1&&(r=new Set((0,k.sortNodes)(r)))),r}}0&&(module.exports={Finder}); //# sourceMappingURL=finder.js.map diff --git a/dist/cjs/js/finder.js.map b/dist/cjs/js/finder.js.map index 134669f1..bdcc37a1 100644 --- a/dist/cjs/js/finder.js.map +++ b/dist/cjs/js/finder.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../../src/js/finder.js"], - "sourcesContent": ["/**\n * finder.js\n */\n\n/* import */\nimport { Matcher } from './matcher.js';\nimport {\n generateCSS, parseSelector, sortAST, unescapeSelector, walkAST\n} from './parser.js';\nimport {\n isContentEditable, isCustomElement, isInShadowTree, resolveContent,\n sortNodes, traverseNode\n} from './utility.js';\n\n/* constants */\nimport {\n BIT_01, COMBINATOR, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, ELEMENT_NODE,\n EMPTY, NOT_SUPPORTED_ERR, REG_ANCHOR, REG_FORM, REG_FORM_CTRL,\n REG_FORM_VALID, REG_INTERACT, REG_LOGICAL_PSEUDO, REG_SHADOW_HOST,\n REG_TYPE_CHECK, REG_TYPE_DATE, REG_TYPE_RANGE, REG_TYPE_RESET,\n REG_TYPE_SUBMIT, REG_TYPE_TEXT, SELECTOR_ATTR, SELECTOR_CLASS, SELECTOR_ID,\n SELECTOR_PSEUDO_CLASS, SELECTOR_PSEUDO_ELEMENT, SELECTOR_TYPE, SHOW_ALL,\n SYNTAX_ERR, TARGET_ALL, TARGET_FIRST, TARGET_LINEAL, TARGET_SELF, TEXT_NODE,\n WALKER_FILTER\n} from './constant.js';\nconst DIR_NEXT = 'next';\nconst DIR_PREV = 'prev';\n\n/**\n * Finder\n * NOTE: #ast[i] corresponds to #nodes[i]\n * #ast: Array\n * #nodes: Array\n * Ast: {\n * branch: Array,\n * collected: boolean,\n * dir: string | null,\n * filtered: boolean,\n * find: boolean\n * }\n * Branch: Array\n * Twig: {\n * combo: Leaf | null,\n * leaves: Array\n * }\n * Leaf: {\n * children: Array | null,\n * loc: null,\n * type: string\n * }\n * Nodes: Array\n */\nexport class Finder {\n /* private fields */\n #ast;\n #astCache;\n #descendant;\n #document;\n #documentCache;\n #event;\n #invalidate;\n #invalidateResults;\n #matcher;\n #node;\n #nodes;\n #noexcept;\n #qswalker;\n #results;\n #root;\n #shadow;\n #walker;\n #walkers;\n #warn;\n #window;\n\n /**\n * construct\n * @param {object} window - window\n */\n constructor(window) {\n this.#window = window;\n this.#matcher = new Matcher();\n this.#astCache = new WeakMap();\n this.#documentCache = new WeakMap();\n this.#invalidateResults = new WeakMap();\n this.#results = new WeakMap();\n }\n\n /**\n * handle error\n * @param {Error} e - Error\n * @param {object} opt - options\n * @throws Error\n * @returns {void}\n */\n onError(e, opt = {}) {\n const noexcept = opt.noexcept ?? this.#noexcept;\n if (!noexcept) {\n if (e instanceof DOMException ||\n e instanceof this.#window.DOMException) {\n if (e.name === NOT_SUPPORTED_ERR) {\n if (this.#warn) {\n console.warn(e.message);\n }\n } else {\n throw new this.#window.DOMException(e.message, e.name);\n }\n } else {\n throw e;\n }\n }\n }\n\n /**\n * setup finder\n * @param {string} selector - CSS selector\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} opt - options\n * @param {object} [opt.event] - MouseEvent, KeyboardEvent\n * @param {boolean} [opt.noexcept] - no exception\n * @param {boolean} [opt.warn] - console warn\n * @returns {object} - node\n */\n setup(selector, node, opt = {}) {\n const { event, noexcept, warn } = opt;\n this.#noexcept = !!noexcept;\n this.#warn = !!warn;\n this.#event = this._setEvent(event);\n this.#node = node;\n [this.#document, this.#root, this.#walker] = resolveContent(node);\n this.#shadow = isInShadowTree(node);\n [this.#ast, this.#nodes] = this._correspond(selector);\n this.#invalidateResults = new WeakMap();\n this.#walkers = new WeakMap();\n return node;\n }\n\n /**\n * set event\n * @private\n * @param {object} event - instance of KeyboardEvent, MouseEvent\n * @returns {object} - result\n */\n _setEvent(event) {\n // NOTE: PointerEvent not implemented in jsdom\n return (event instanceof this.#window.KeyboardEvent ||\n event instanceof this.#window.MouseEvent)\n ? event\n : null;\n }\n\n /**\n * correspond ast and nodes\n * @private\n * @param {string} selector - CSS selector\n * @returns {Array.>} - array of ast and nodes\n */\n _correspond(selector) {\n const nodes = [];\n this.#descendant = false;\n this.#invalidate = false;\n let ast;\n if (this.#documentCache.has(this.#document)) {\n const cachedItem = this.#documentCache.get(this.#document);\n if (cachedItem && cachedItem.has(`${selector}`)) {\n const item = cachedItem.get(`${selector}`);\n ast = item.ast;\n this.#descendant = item.descendant;\n this.#invalidate = item.invalidate;\n }\n }\n if (ast) {\n const l = ast.length;\n for (let i = 0; i < l; i++) {\n ast[i].collected = false;\n ast[i].dir = null;\n ast[i].filtered = false;\n ast[i].find = false;\n nodes[i] = [];\n }\n } else {\n let cssAst;\n try {\n cssAst = parseSelector(selector);\n } catch (e) {\n this.onError(e);\n }\n const { branches, info: { hasHasPseudoFunc } } = walkAST(cssAst);\n let invalidate = !!hasHasPseudoFunc;\n let descendant = false;\n let i = 0;\n ast = [];\n for (const [...items] of branches) {\n const branch = [];\n let item = items.shift();\n if (item && item.type !== COMBINATOR) {\n const leaves = new Set();\n while (item) {\n if (item.type === COMBINATOR) {\n const [nextItem] = items;\n if (nextItem.type === COMBINATOR) {\n throw new DOMException(`Invalid selector ${selector}`,\n SYNTAX_ERR);\n }\n const itemName = item.name;\n if (/^[\\s>]$/.test(itemName)) {\n descendant = true;\n } else {\n invalidate = true;\n }\n branch.push({\n combo: item,\n leaves: sortAST(leaves)\n });\n leaves.clear();\n } else if (item) {\n let { name: itemName } = item;\n if (itemName && typeof itemName === 'string') {\n itemName = unescapeSelector(itemName);\n if (typeof itemName === 'string' && itemName !== item.name) {\n item.name = itemName;\n }\n if (/[|:]/.test(itemName)) {\n item.namespace = true;\n }\n }\n leaves.add(item);\n }\n if (items.length) {\n item = items.shift();\n } else {\n branch.push({\n combo: null,\n leaves: sortAST(leaves)\n });\n leaves.clear();\n break;\n }\n }\n }\n ast.push({\n branch,\n collected: false,\n dir: null,\n filtered: false,\n find: false\n });\n nodes[i] = [];\n i++;\n }\n let cachedItem;\n if (this.#documentCache.has(this.#document)) {\n cachedItem = this.#documentCache.get(this.#document);\n } else {\n cachedItem = new Map();\n }\n cachedItem.set(`${selector}`, {\n ast,\n descendant,\n invalidate\n });\n this.#documentCache.set(this.#document, cachedItem);\n this.#descendant = descendant;\n this.#invalidate = invalidate;\n }\n return [\n ast,\n nodes\n ];\n }\n\n /**\n * create tree walker\n * @private\n * @param {object} node - Document, DocumentFragment, Element node\n * @returns {object} - tree walker\n */\n _createTreeWalker(node) {\n let walker;\n if (this.#walkers.has(node)) {\n walker = this.#walkers.get(node);\n } else {\n walker = this.#document.createTreeWalker(node, WALKER_FILTER);\n this.#walkers.set(node, walker);\n }\n return walker;\n }\n\n /**\n * prepare querySelector walker\n * @private\n * @returns {object} - tree walker\n */\n _prepareQuerySelectorWalker() {\n this.#qswalker = this._createTreeWalker(this.#node);\n return this.#qswalker;\n }\n\n /**\n * collect nth child\n * @private\n * @param {object} anb - An+B options\n * @param {number} anb.a - a\n * @param {number} anb.b - b\n * @param {boolean} [anb.reverse] - reverse order\n * @param {object} [anb.selector] - AST\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {Set.} - collection of matched nodes\n */\n _collectNthChild(anb, node, opt) {\n const { a, b, reverse, selector } = anb;\n const { parentNode } = node;\n const matched = new Set();\n let selectorBranches;\n if (selector) {\n if (this.#astCache.has(selector)) {\n selectorBranches = this.#astCache.get(selector);\n } else {\n const { branches, info } = walkAST(selector);\n selectorBranches = branches;\n this.#astCache.set(selector, selectorBranches);\n if (info.hasLogicalPseudoFunc) {\n this.#invalidate = true;\n }\n }\n }\n if (parentNode) {\n const walker = this.#walker;\n let refNode = traverseNode(parentNode, walker);\n refNode = walker.firstChild();\n let l = 0;\n while (refNode) {\n l++;\n refNode = walker.nextSibling();\n }\n const selectorNodes = new Set();\n if (selectorBranches) {\n refNode = traverseNode(parentNode, walker);\n refNode = walker.firstChild();\n while (refNode) {\n const { display, visibility } =\n this.#window.getComputedStyle(refNode);\n if (display !== 'none' && visibility !== 'hidden') {\n let bool;\n for (const leaves of selectorBranches) {\n bool = this._matchLeaves(leaves, refNode, opt);\n if (!bool) {\n break;\n }\n }\n if (bool) {\n selectorNodes.add(refNode);\n }\n }\n refNode = walker.nextSibling();\n }\n }\n // :first-child, :last-child, :nth-child(b of S), :nth-last-child(b of S)\n if (a === 0) {\n if (b > 0 && b <= l) {\n if (selectorNodes.size) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let i = 0;\n while (refNode) {\n if (selectorNodes.has(refNode)) {\n if (i === b - 1) {\n matched.add(refNode);\n break;\n }\n i++;\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n }\n } else if (!selector) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let i = 0;\n while (refNode) {\n if (i === b - 1) {\n matched.add(refNode);\n break;\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n i++;\n }\n }\n }\n // :nth-child()\n } else {\n let nth = b - 1;\n if (a > 0) {\n while (nth < 0) {\n nth += a;\n }\n }\n if (nth >= 0 && nth < l) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let i = 0;\n let j = a > 0 ? 0 : b - 1;\n while (refNode) {\n if (refNode && nth >= 0 && nth < l) {\n if (selectorNodes.size) {\n if (selectorNodes.has(refNode)) {\n if (j === nth) {\n matched.add(refNode);\n nth += a;\n }\n if (a > 0) {\n j++;\n } else {\n j--;\n }\n }\n } else if (i === nth) {\n if (!selector) {\n matched.add(refNode);\n }\n nth += a;\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n i++;\n } else {\n break;\n }\n }\n }\n }\n if (reverse && matched.size > 1) {\n const m = [...matched];\n return new Set(m.reverse());\n }\n } else if (node === this.#root && (a + b) === 1) {\n if (selectorBranches) {\n let bool;\n for (const leaves of selectorBranches) {\n bool = this._matchLeaves(leaves, node, opt);\n if (bool) {\n break;\n }\n }\n if (bool) {\n matched.add(node);\n }\n } else {\n matched.add(node);\n }\n }\n return matched;\n }\n\n /**\n * collect nth of type\n * @private\n * @param {object} anb - An+B options\n * @param {number} anb.a - a\n * @param {number} anb.b - b\n * @param {boolean} [anb.reverse] - reverse order\n * @param {object} node - Element node\n * @returns {Set.} - collection of matched nodes\n */\n _collectNthOfType(anb, node) {\n const { a, b, reverse } = anb;\n const { localName, namespaceURI, parentNode, prefix } = node;\n const matched = new Set();\n if (parentNode) {\n const walker = this.#walker;\n let refNode = traverseNode(parentNode, walker);\n refNode = walker.firstChild();\n let l = 0;\n while (refNode) {\n l++;\n refNode = walker.nextSibling();\n }\n // :first-of-type, :last-of-type\n if (a === 0) {\n if (b > 0 && b <= l) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let j = 0;\n while (refNode) {\n const {\n localName: itemLocalName, namespaceURI: itemNamespaceURI,\n prefix: itemPrefix\n } = refNode;\n if (itemLocalName === localName && itemPrefix === prefix &&\n itemNamespaceURI === namespaceURI) {\n if (j === b - 1) {\n matched.add(refNode);\n break;\n }\n j++;\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n }\n }\n // :nth-of-type()\n } else {\n let nth = b - 1;\n if (a > 0) {\n while (nth < 0) {\n nth += a;\n }\n }\n if (nth >= 0 && nth < l) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let j = a > 0 ? 0 : b - 1;\n while (refNode) {\n const {\n localName: itemLocalName, namespaceURI: itemNamespaceURI,\n prefix: itemPrefix\n } = refNode;\n if (itemLocalName === localName && itemPrefix === prefix &&\n itemNamespaceURI === namespaceURI) {\n if (j === nth) {\n matched.add(refNode);\n nth += a;\n }\n if (nth < 0 || nth >= l) {\n break;\n } else if (a > 0) {\n j++;\n } else {\n j--;\n }\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n }\n }\n }\n if (reverse && matched.size > 1) {\n const m = [...matched];\n return new Set(m.reverse());\n }\n } else if (node === this.#root && (a + b) === 1) {\n matched.add(node);\n }\n return matched;\n }\n\n /**\n * match An+B\n * @private\n * @param {object} ast - AST\n * @param {object} node - Element node\n * @param {string} nthName - nth pseudo-class name\n * @param {object} opt - options\n * @returns {Set.} - collection of matched nodes\n */\n _matchAnPlusB(ast, node, nthName, opt) {\n const {\n nth: {\n a,\n b,\n name: nthIdentName\n },\n selector\n } = ast;\n const anbMap = new Map();\n if (nthIdentName) {\n if (nthIdentName === 'even') {\n anbMap.set('a', 2);\n anbMap.set('b', 0);\n } else if (nthIdentName === 'odd') {\n anbMap.set('a', 2);\n anbMap.set('b', 1);\n }\n if (nthName.indexOf('last') > -1) {\n anbMap.set('reverse', true);\n }\n } else {\n if (typeof a === 'string' && /-?\\d+/.test(a)) {\n anbMap.set('a', a * 1);\n } else {\n anbMap.set('a', 0);\n }\n if (typeof b === 'string' && /-?\\d+/.test(b)) {\n anbMap.set('b', b * 1);\n } else {\n anbMap.set('b', 0);\n }\n if (nthName.indexOf('last') > -1) {\n anbMap.set('reverse', true);\n }\n }\n if (/^nth-(?:last-)?child$/.test(nthName)) {\n if (selector) {\n anbMap.set('selector', selector);\n }\n const anb = Object.fromEntries(anbMap);\n const nodes = this._collectNthChild(anb, node, opt);\n return nodes;\n } else if (/^nth-(?:last-)?of-type$/.test(nthName)) {\n const anb = Object.fromEntries(anbMap);\n const nodes = this._collectNthOfType(anb, node);\n return nodes;\n }\n return new Set();\n }\n\n /**\n * match :has() pseudo-class function\n * @private\n * @param {Array.} astLeaves - AST leaves\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {boolean} - result\n */\n _matchHasPseudoFunc(astLeaves, node, opt = {}) {\n let bool;\n if (Array.isArray(astLeaves) && astLeaves.length) {\n const leaves = astLeaves.map(i => i);\n const [leaf] = leaves;\n const { type: leafType } = leaf;\n let combo;\n if (leafType === COMBINATOR) {\n combo = leaves.shift();\n } else {\n combo = {\n name: ' ',\n type: COMBINATOR\n };\n }\n const twigLeaves = [];\n while (leaves.length) {\n const [item] = leaves;\n const { type: itemType } = item;\n if (itemType === COMBINATOR) {\n break;\n } else {\n twigLeaves.push(leaves.shift());\n }\n }\n const twig = {\n combo,\n leaves: twigLeaves\n };\n opt.dir = DIR_NEXT;\n const nodes = this._matchCombinator(twig, node, opt);\n if (nodes.size) {\n if (leaves.length) {\n for (const nextNode of nodes) {\n bool = this._matchHasPseudoFunc(leaves, nextNode, opt);\n if (bool) {\n break;\n }\n }\n } else {\n bool = true;\n }\n }\n }\n return !!bool;\n }\n\n /**\n * match logical pseudo-class functions - :has(), :is(), :not(), :where()\n * @private\n * @param {object} astData - AST data\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {?object} - matched node\n */\n _matchLogicalPseudoFunc(astData, node, opt = {}) {\n const {\n astName = '', branches = [], selector = '', twigBranches = []\n } = astData;\n let res;\n if (astName === 'has') {\n if (selector.includes(':has(')) {\n res = null;\n } else {\n let bool;\n for (const leaves of branches) {\n bool = this._matchHasPseudoFunc(leaves, node, opt);\n if (bool) {\n break;\n }\n }\n if (bool) {\n res = node;\n }\n }\n } else {\n const forgive = /^(?:is|where)$/.test(astName);\n opt.forgive = forgive;\n const l = twigBranches.length;\n let bool;\n for (let i = 0; i < l; i++) {\n const branch = twigBranches[i];\n const lastIndex = branch.length - 1;\n const { leaves } = branch[lastIndex];\n bool = this._matchLeaves(leaves, node, opt);\n if (bool && lastIndex > 0) {\n let nextNodes = new Set([node]);\n for (let j = lastIndex - 1; j >= 0; j--) {\n const twig = branch[j];\n const arr = [];\n opt.dir = DIR_PREV;\n for (const nextNode of nextNodes) {\n const m = this._matchCombinator(twig, nextNode, opt);\n if (m.size) {\n arr.push(...m);\n }\n }\n if (arr.length) {\n if (j === 0) {\n bool = true;\n } else {\n nextNodes = new Set(arr);\n }\n } else {\n bool = false;\n break;\n }\n }\n }\n if (bool) {\n break;\n }\n }\n if (astName === 'not') {\n if (!bool) {\n res = node;\n }\n } else if (bool) {\n res = node;\n }\n }\n return res ?? null;\n }\n\n /**\n * match pseudo-class selector\n * @private\n * @see https://html.spec.whatwg.org/#pseudo-classes\n * @param {object} ast - AST\n * @param {object} node - Element node\n * @param {object} opt - options\n * @param {boolean} [opt.forgive] - forgive unknown pseudo-class\n * @param {boolean} [opt.warn] - warn unsupported pseudo-class\n * @returns {Set.} - collection of matched nodes\n */\n _matchPseudoClassSelector(ast, node, opt = {}) {\n const { children: astChildren, name: astName } = ast;\n const { localName, parentNode } = node;\n const {\n forgive,\n warn = this.#warn\n } = opt;\n const matched = new Set();\n // :has(), :is(), :not(), :where()\n if (REG_LOGICAL_PSEUDO.test(astName)) {\n let astData;\n if (this.#astCache.has(ast)) {\n astData = this.#astCache.get(ast);\n } else {\n const { branches } = walkAST(ast);\n const selectors = [];\n const twigBranches = [];\n for (const [...leaves] of branches) {\n for (const leaf of leaves) {\n const css = generateCSS(leaf);\n selectors.push(css);\n }\n const branch = [];\n const leavesSet = new Set();\n let item = leaves.shift();\n while (item) {\n if (item.type === COMBINATOR) {\n branch.push({\n combo: item,\n leaves: [...leavesSet]\n });\n leavesSet.clear();\n } else if (item) {\n leavesSet.add(item);\n }\n if (leaves.length) {\n item = leaves.shift();\n } else {\n branch.push({\n combo: null,\n leaves: [...leavesSet]\n });\n leavesSet.clear();\n break;\n }\n }\n twigBranches.push(branch);\n }\n astData = {\n astName,\n branches,\n twigBranches,\n selector: selectors.join(',')\n };\n this.#astCache.set(ast, astData);\n }\n const res = this._matchLogicalPseudoFunc(astData, node, opt);\n if (res) {\n matched.add(res);\n }\n } else if (Array.isArray(astChildren)) {\n // :nth-child(), :nth-last-child(), nth-of-type(), :nth-last-of-type()\n if (/^nth-(?:last-)?(?:child|of-type)$/.test(astName)) {\n const [branch] = astChildren;\n const nodes = this._matchAnPlusB(branch, node, astName, opt);\n return nodes;\n } else {\n switch (astName) {\n // :dir(), :lang()\n case 'dir':\n case 'lang': {\n const res = this.#matcher.matchSelector(ast, node, opt, true);\n if (res) {\n matched.add(res);\n }\n break;\n }\n // :state()\n case 'state': {\n if (isCustomElement(node)) {\n const [{ value: stateValue }] = astChildren;\n if (stateValue) {\n if (node[stateValue]) {\n matched.add(node);\n } else {\n for (const i in node) {\n const prop = node[i];\n if (prop instanceof this.#window.ElementInternals) {\n if (prop?.states?.has(stateValue)) {\n matched.add(node);\n }\n break;\n }\n }\n }\n }\n }\n break;\n }\n case 'current':\n case 'nth-col':\n case 'nth-last-col': {\n if (warn) {\n throw new DOMException(`Unsupported pseudo-class :${astName}()`,\n NOT_SUPPORTED_ERR);\n }\n break;\n }\n case 'host':\n case 'host-context': {\n // ignore\n break;\n }\n // dropped from CSS Selectors 3\n case 'contains': {\n if (warn) {\n throw new DOMException(`Unknown pseudo-class :${astName}()`,\n NOT_SUPPORTED_ERR);\n }\n break;\n }\n default: {\n if (!forgive) {\n throw new DOMException(`Unknown pseudo-class :${astName}()`,\n SYNTAX_ERR);\n }\n }\n }\n }\n } else {\n switch (astName) {\n case 'any-link':\n case 'link': {\n if (REG_ANCHOR.test(localName) && node.hasAttribute('href')) {\n matched.add(node);\n }\n break;\n }\n case 'local-link': {\n if (REG_ANCHOR.test(localName) && node.hasAttribute('href')) {\n const { href, origin, pathname } = new URL(this.#document.URL);\n const attrURL = new URL(node.getAttribute('href'), href);\n if (attrURL.origin === origin && attrURL.pathname === pathname) {\n matched.add(node);\n }\n }\n break;\n }\n case 'visited': {\n // prevent fingerprinting\n break;\n }\n case 'hover': {\n const { target, type } = this.#event ?? {};\n if ((type === 'mouseover' || type === 'pointerover') &&\n node.contains(target)) {\n matched.add(node);\n }\n break;\n }\n case 'active': {\n const { buttons, target, type } = this.#event ?? {};\n if ((type === 'mousedown' || type === 'pointerdown') &&\n buttons & BIT_01 && node.contains(target)) {\n matched.add(node);\n }\n break;\n }\n case 'target': {\n const { hash } = new URL(this.#document.URL);\n if (node.id && hash === `#${node.id}` &&\n this.#document.contains(node)) {\n matched.add(node);\n }\n break;\n }\n case 'target-within': {\n const { hash } = new URL(this.#document.URL);\n if (hash) {\n const id = hash.replace(/^#/, '');\n let current = this.#document.getElementById(id);\n while (current) {\n if (current === node) {\n matched.add(node);\n break;\n }\n current = current.parentNode;\n }\n }\n break;\n }\n case 'scope': {\n if (this.#node.nodeType === ELEMENT_NODE) {\n if (!this.#shadow && node === this.#node) {\n matched.add(node);\n }\n } else if (node === this.#document.documentElement) {\n matched.add(node);\n }\n break;\n }\n case 'focus':\n case 'focus-visible': {\n const { target, type } = this.#event ?? {};\n if (node === this.#document.activeElement && node.tabIndex >= 0 &&\n (astName === 'focus' ||\n (type === 'keydown' && node.contains(target)))) {\n let refNode = node;\n let focus = true;\n while (refNode) {\n if (refNode.disabled || refNode.hasAttribute('disabled') ||\n refNode.hidden || refNode.hasAttribute('hidden')) {\n focus = false;\n break;\n } else {\n const { display, visibility } =\n this.#window.getComputedStyle(refNode);\n focus = !(display === 'none' || visibility === 'hidden');\n if (!focus) {\n break;\n }\n }\n if (refNode.parentNode &&\n refNode.parentNode.nodeType === ELEMENT_NODE) {\n refNode = refNode.parentNode;\n } else {\n break;\n }\n }\n if (focus) {\n matched.add(node);\n }\n }\n break;\n }\n case 'focus-within': {\n let active;\n let current = this.#document.activeElement;\n if (current.tabIndex >= 0) {\n while (current) {\n if (current === node) {\n active = true;\n break;\n }\n current = current.parentNode;\n }\n }\n if (active) {\n let refNode = node;\n let focus = true;\n while (refNode) {\n if (refNode.disabled || refNode.hasAttribute('disabled') ||\n refNode.hidden || refNode.hasAttribute('hidden')) {\n focus = false;\n break;\n } else {\n const { display, visibility } =\n this.#window.getComputedStyle(refNode);\n focus = !(display === 'none' || visibility === 'hidden');\n if (!focus) {\n break;\n }\n }\n if (refNode.parentNode &&\n refNode.parentNode.nodeType === ELEMENT_NODE) {\n refNode = refNode.parentNode;\n } else {\n break;\n }\n }\n if (focus) {\n matched.add(node);\n }\n }\n break;\n }\n case 'open': {\n if (REG_INTERACT.test(localName) && node.hasAttribute('open')) {\n matched.add(node);\n }\n break;\n }\n case 'closed': {\n if (REG_INTERACT.test(localName) && !node.hasAttribute('open')) {\n matched.add(node);\n }\n break;\n }\n case 'disabled': {\n if (REG_FORM_CTRL.test(localName) ||\n isCustomElement(node, { formAssociated: true })) {\n if (node.disabled || node.hasAttribute('disabled')) {\n matched.add(node);\n } else if (node.localName === 'option') {\n if (parentNode.localName === 'optgroup' &&\n (parentNode.disabled ||\n parentNode.hasAttribute('disabled'))) {\n matched.add(node);\n }\n } else if (node.localName !== 'optgroup') {\n let bool;\n let parent = parentNode;\n while (parent) {\n if (parent.localName === 'fieldset' &&\n (parent.disabled || parent.hasAttribute('disabled'))) {\n const walker = this.#walker;\n let refNode = traverseNode(parent, walker);\n refNode = walker.firstChild();\n while (refNode) {\n if (refNode.localName === 'legend') {\n break;\n }\n refNode = walker.nextSibling();\n }\n if (refNode) {\n if (!refNode.contains(node)) {\n bool = true;\n }\n } else {\n bool = true;\n }\n break;\n } else if (parent.localName === 'form') {\n break;\n } else if (parent.parentNode?.nodeType === ELEMENT_NODE) {\n if (parent.parentNode.localName === 'form') {\n break;\n } else {\n parent = parent.parentNode;\n }\n } else {\n break;\n }\n }\n if (bool) {\n matched.add(node);\n }\n }\n }\n break;\n }\n case 'enabled': {\n if ((REG_FORM_CTRL.test(localName) ||\n isCustomElement(node, { formAssociated: true })) &&\n !(node.disabled && node.hasAttribute('disabled'))) {\n if (node.localName === 'optgroup') {\n matched.add(node);\n } else if (node.localName === 'option') {\n if (parentNode.localName !== 'optgroup' ||\n !(parentNode.disabled ||\n parentNode.hasAttribute('disabled'))) {\n matched.add(node);\n }\n } else {\n let bool;\n let parent = parentNode;\n while (parent) {\n if (parent.localName === 'fieldset' &&\n (parent.disabled || parent.hasAttribute('disabled'))) {\n const walker = this.#walker;\n let refNode = traverseNode(parent, walker);\n refNode = walker.firstChild();\n while (refNode) {\n if (refNode.localName === 'legend') {\n break;\n }\n refNode = walker.nextSibling();\n }\n if (refNode) {\n if (!refNode.contains(node)) {\n bool = true;\n }\n } else {\n bool = true;\n }\n break;\n } else if (parent.localName === 'form') {\n break;\n } else if (parent.parentNode?.nodeType === ELEMENT_NODE) {\n if (parent.parentNode.localName === 'form') {\n break;\n } else {\n parent = parent.parentNode;\n }\n } else {\n break;\n }\n }\n if (!bool) {\n matched.add(node);\n }\n }\n }\n break;\n }\n case 'read-only': {\n switch (localName) {\n case 'textarea': {\n if (node.readonly || node.hasAttribute('readonly') ||\n node.disabled || node.hasAttribute('disabled')) {\n matched.add(node);\n }\n break;\n }\n case 'input': {\n if ((!node.type || REG_TYPE_DATE.test(node.type) ||\n REG_TYPE_TEXT.test(node.type)) &&\n (node.readonly || node.hasAttribute('readonly') ||\n node.disabled || node.hasAttribute('disabled'))) {\n matched.add(node);\n }\n break;\n }\n default: {\n if (!isContentEditable(node)) {\n matched.add(node);\n }\n }\n }\n break;\n }\n case 'read-write': {\n switch (localName) {\n case 'textarea': {\n if (!(node.readonly || node.hasAttribute('readonly') ||\n node.disabled || node.hasAttribute('disabled'))) {\n matched.add(node);\n }\n break;\n }\n case 'input': {\n if ((!node.type || REG_TYPE_DATE.test(node.type) ||\n REG_TYPE_TEXT.test(node.type)) &&\n !(node.readonly || node.hasAttribute('readonly') ||\n node.disabled || node.hasAttribute('disabled'))) {\n matched.add(node);\n }\n break;\n }\n default: {\n if (isContentEditable(node)) {\n matched.add(node);\n }\n }\n }\n break;\n }\n case 'placeholder-shown': {\n let placeholder;\n if (node.placeholder) {\n placeholder = node.placeholder;\n } else if (node.hasAttribute('placeholder')) {\n placeholder = node.getAttribute('placeholder');\n }\n if (typeof placeholder === 'string' && !/[\\r\\n]/.test(placeholder)) {\n let targetNode;\n if (localName === 'textarea') {\n targetNode = node;\n } else if (localName === 'input') {\n if (node.hasAttribute('type')) {\n if (REG_TYPE_TEXT.test(node.getAttribute('type'))) {\n targetNode = node;\n }\n } else {\n targetNode = node;\n }\n }\n if (targetNode && node.value === '') {\n matched.add(node);\n }\n }\n break;\n }\n case 'checked': {\n if ((node.checked && localName === 'input' &&\n node.hasAttribute('type') &&\n REG_TYPE_CHECK.test(node.getAttribute('type'))) ||\n (node.selected && localName === 'option')) {\n matched.add(node);\n }\n break;\n }\n case 'indeterminate': {\n if ((node.indeterminate && localName === 'input' &&\n node.type === 'checkbox') ||\n (localName === 'progress' && !node.hasAttribute('value'))) {\n matched.add(node);\n } else if (localName === 'input' && node.type === 'radio' &&\n !node.hasAttribute('checked')) {\n const nodeName = node.name;\n let parent = node.parentNode;\n while (parent) {\n if (parent.localName === 'form') {\n break;\n }\n parent = parent.parentNode;\n }\n if (!parent) {\n parent = this.#document.documentElement;\n }\n const items = parent.getElementsByTagName('input');\n const l = items.length;\n let checked;\n for (let i = 0; i < l; i++) {\n const item = items[i];\n if (item.getAttribute('type') === 'radio') {\n if (nodeName) {\n if (item.getAttribute('name') === nodeName) {\n checked = !!item.checked;\n }\n } else if (!item.hasAttribute('name')) {\n checked = !!item.checked;\n }\n if (checked) {\n break;\n }\n }\n }\n if (!checked) {\n matched.add(node);\n }\n }\n break;\n }\n case 'default': {\n // button[type=\"submit\"], input[type=\"submit\"], input[type=\"image\"]\n if ((localName === 'button' &&\n !(node.hasAttribute('type') &&\n REG_TYPE_RESET.test(node.getAttribute('type')))) ||\n (localName === 'input' && node.hasAttribute('type') &&\n REG_TYPE_SUBMIT.test(node.getAttribute('type')))) {\n let form = node.parentNode;\n while (form) {\n if (form.localName === 'form') {\n break;\n }\n form = form.parentNode;\n }\n if (form) {\n const walker = this.#walker;\n let nextNode = traverseNode(form, walker);\n nextNode = walker.firstChild();\n while (nextNode && form.contains(nextNode)) {\n const nodeName = nextNode.localName;\n let m;\n if (nodeName === 'button') {\n m = !(nextNode.hasAttribute('type') &&\n REG_TYPE_RESET.test(nextNode.getAttribute('type')));\n } else if (nodeName === 'input') {\n m = nextNode.hasAttribute('type') &&\n REG_TYPE_SUBMIT.test(nextNode.getAttribute('type'));\n }\n if (m) {\n if (nextNode === node) {\n matched.add(node);\n }\n break;\n }\n nextNode = walker.nextNode();\n }\n }\n // input[type=\"checkbox\"], input[type=\"radio\"]\n } else if (localName === 'input' && node.hasAttribute('type') &&\n REG_TYPE_CHECK.test(node.getAttribute('type')) &&\n node.hasAttribute('checked')) {\n matched.add(node);\n // option\n } else if (localName === 'option' && node.hasAttribute('selected')) {\n matched.add(node);\n }\n break;\n }\n case 'valid': {\n if (REG_FORM_VALID.test(localName)) {\n if (node.checkValidity()) {\n if (node.maxLength >= 0) {\n if (node.maxLength >= node.value.length) {\n matched.add(node);\n }\n } else {\n matched.add(node);\n }\n }\n } else if (localName === 'fieldset') {\n const walker = this.#walker;\n let refNode = traverseNode(node, walker);\n refNode = walker.firstChild();\n let bool;\n if (!refNode) {\n bool = true;\n } else {\n while (refNode && node.contains(refNode)) {\n if (REG_FORM_VALID.test(refNode.localName)) {\n if (refNode.checkValidity()) {\n if (refNode.maxLength >= 0) {\n bool = refNode.maxLength >= refNode.value.length;\n } else {\n bool = true;\n }\n } else {\n bool = false;\n }\n if (!bool) {\n break;\n }\n }\n refNode = walker.nextNode();\n }\n }\n if (bool) {\n matched.add(node);\n }\n }\n break;\n }\n case 'invalid': {\n if (REG_FORM_VALID.test(localName)) {\n if (node.checkValidity()) {\n if (node.maxLength >= 0 && node.maxLength < node.value.length) {\n matched.add(node);\n }\n } else {\n matched.add(node);\n }\n } else if (localName === 'fieldset') {\n const walker = this.#walker;\n let refNode = traverseNode(node, walker);\n refNode = walker.firstChild();\n let bool;\n if (!refNode) {\n bool = true;\n } else {\n while (refNode && node.contains(refNode)) {\n if (REG_FORM_VALID.test(refNode.localName)) {\n if (refNode.checkValidity()) {\n if (refNode.maxLength >= 0) {\n bool = refNode.maxLength >= refNode.value.length;\n } else {\n bool = true;\n }\n } else {\n bool = false;\n }\n if (!bool) {\n break;\n }\n }\n refNode = walker.nextNode();\n }\n }\n if (!bool) {\n matched.add(node);\n }\n }\n break;\n }\n case 'in-range': {\n if (localName === 'input' &&\n !(node.readonly || node.hasAttribute('readonly')) &&\n !(node.disabled || node.hasAttribute('disabled')) &&\n node.hasAttribute('type') &&\n REG_TYPE_RANGE.test(node.getAttribute('type')) &&\n !(node.validity.rangeUnderflow ||\n node.validity.rangeOverflow) &&\n (node.hasAttribute('min') || node.hasAttribute('max') ||\n node.getAttribute('type') === 'range')) {\n matched.add(node);\n }\n break;\n }\n case 'out-of-range': {\n if (localName === 'input' &&\n !(node.readonly || node.hasAttribute('readonly')) &&\n !(node.disabled || node.hasAttribute('disabled')) &&\n node.hasAttribute('type') &&\n REG_TYPE_RANGE.test(node.getAttribute('type')) &&\n (node.validity.rangeUnderflow || node.validity.rangeOverflow)) {\n matched.add(node);\n }\n break;\n }\n case 'required': {\n let targetNode;\n if (/^(?:select|textarea)$/.test(localName)) {\n targetNode = node;\n } else if (localName === 'input') {\n if (node.hasAttribute('type')) {\n const inputType = node.getAttribute('type');\n if (inputType === 'file' || REG_TYPE_CHECK.test(inputType) ||\n REG_TYPE_DATE.test(inputType) ||\n REG_TYPE_TEXT.test(inputType)) {\n targetNode = node;\n }\n } else {\n targetNode = node;\n }\n }\n if (targetNode &&\n (node.required || node.hasAttribute('required'))) {\n matched.add(node);\n }\n break;\n }\n case 'optional': {\n let targetNode;\n if (/^(?:select|textarea)$/.test(localName)) {\n targetNode = node;\n } else if (localName === 'input') {\n if (node.hasAttribute('type')) {\n const inputType = node.getAttribute('type');\n if (inputType === 'file' || REG_TYPE_CHECK.test(inputType) ||\n REG_TYPE_DATE.test(inputType) ||\n REG_TYPE_TEXT.test(inputType)) {\n targetNode = node;\n }\n } else {\n targetNode = node;\n }\n }\n if (targetNode &&\n !(node.required || node.hasAttribute('required'))) {\n matched.add(node);\n }\n break;\n }\n case 'root': {\n if (node === this.#document.documentElement) {\n matched.add(node);\n }\n break;\n }\n case 'empty': {\n if (node.hasChildNodes()) {\n const walker = this.#document.createTreeWalker(node, SHOW_ALL);\n let refNode = walker.firstChild();\n let bool;\n while (refNode) {\n bool = refNode.nodeType !== ELEMENT_NODE &&\n refNode.nodeType !== TEXT_NODE;\n if (!bool) {\n break;\n }\n refNode = walker.nextSibling();\n }\n if (bool) {\n matched.add(node);\n }\n } else {\n matched.add(node);\n }\n break;\n }\n case 'first-child': {\n if ((parentNode && node === parentNode.firstElementChild) ||\n node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'last-child': {\n if ((parentNode && node === parentNode.lastElementChild) ||\n node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'only-child': {\n if ((parentNode && node === parentNode.firstElementChild &&\n node === parentNode.lastElementChild) || node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'first-of-type': {\n if (parentNode) {\n const [node1] = this._collectNthOfType({\n a: 0,\n b: 1\n }, node);\n if (node1) {\n matched.add(node1);\n }\n } else if (node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'last-of-type': {\n if (parentNode) {\n const [node1] = this._collectNthOfType({\n a: 0,\n b: 1,\n reverse: true\n }, node);\n if (node1) {\n matched.add(node1);\n }\n } else if (node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'only-of-type': {\n if (parentNode) {\n const [node1] = this._collectNthOfType({\n a: 0,\n b: 1\n }, node);\n if (node1 === node) {\n const [node2] = this._collectNthOfType({\n a: 0,\n b: 1,\n reverse: true\n }, node);\n if (node2 === node) {\n matched.add(node);\n }\n }\n } else if (node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'defined': {\n if (node.hasAttribute('is') || localName.includes('-')) {\n if (isCustomElement(node)) {\n matched.add(node);\n }\n // NOTE: MathMLElement not implemented in jsdom\n } else if (node instanceof this.#window.HTMLElement ||\n node instanceof this.#window.SVGElement) {\n matched.add(node);\n }\n break;\n }\n case 'popover-open': {\n if (node.popover) {\n const { display } = this.#window.getComputedStyle(node);\n if (display !== 'none') {\n matched.add(node);\n }\n }\n break;\n }\n case 'host':\n case 'host-context': {\n // ignore\n break;\n }\n // legacy pseudo-elements\n case 'after':\n case 'before':\n case 'first-letter':\n case 'first-line': {\n if (warn) {\n throw new DOMException(`Unsupported pseudo-element ::${astName}`,\n NOT_SUPPORTED_ERR);\n }\n break;\n }\n // not supported\n case 'autofill':\n case 'blank':\n case 'buffering':\n case 'current':\n case 'fullscreen':\n case 'future':\n case 'modal':\n case 'muted':\n case 'past':\n case 'paused':\n case 'picture-in-picture':\n case 'playing':\n case 'seeking':\n case 'stalled':\n case 'user-invalid':\n case 'user-valid':\n case 'volume-locked':\n case '-webkit-autofill': {\n if (warn) {\n throw new DOMException(`Unsupported pseudo-class :${astName}`,\n NOT_SUPPORTED_ERR);\n }\n break;\n }\n default: {\n if (astName.startsWith('-webkit-')) {\n if (warn) {\n throw new DOMException(`Unsupported pseudo-class :${astName}`,\n NOT_SUPPORTED_ERR);\n }\n } else if (!forgive) {\n throw new DOMException(`Unknown pseudo-class :${astName}`,\n SYNTAX_ERR);\n }\n }\n }\n }\n return matched;\n }\n\n /**\n * match shadow host pseudo class\n * @private\n * @param {object} ast - AST\n * @param {object} node - DocumentFragment node\n * @returns {?object} - matched node\n */\n _matchShadowHostPseudoClass(ast, node) {\n const { children: astChildren, name: astName } = ast;\n let res;\n if (Array.isArray(astChildren)) {\n const { branches } = walkAST(astChildren[0]);\n const [branch] = branches;\n const [...leaves] = branch;\n const { host } = node;\n if (astName === 'host') {\n let bool;\n for (const leaf of leaves) {\n const { type: leafType } = leaf;\n if (leafType === COMBINATOR) {\n const css = generateCSS(ast);\n throw new DOMException(`Invalid selector ${css}`, SYNTAX_ERR);\n }\n bool = this._matchSelector(leaf, host).has(host);\n if (!bool) {\n break;\n }\n }\n if (bool) {\n res = node;\n }\n } else if (astName === 'host-context') {\n let parent = host;\n let bool;\n while (parent) {\n for (const leaf of leaves) {\n const { type: leafType } = leaf;\n if (leafType === COMBINATOR) {\n const css = generateCSS(ast);\n throw new DOMException(`Invalid selector ${css}`, SYNTAX_ERR);\n }\n bool = this._matchSelector(leaf, parent).has(parent);\n if (!bool) {\n break;\n }\n }\n if (bool) {\n break;\n } else {\n parent = parent.parentNode;\n }\n }\n if (bool) {\n res = node;\n }\n }\n } else if (astName === 'host') {\n res = node;\n } else {\n throw new DOMException(`Invalid selector :${astName}`, SYNTAX_ERR);\n }\n return res ?? null;\n }\n\n /**\n * match selector\n * @private\n * @param {object} ast - AST\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} [opt] - options\n * @returns {Set.} - collection of matched nodes\n */\n _matchSelector(ast, node, opt) {\n const { type: astType } = ast;\n const matched = new Set();\n if (ast.name === EMPTY) {\n return matched;\n }\n const astName = unescapeSelector(ast.name);\n if (typeof astName === 'string' && astName !== ast.name) {\n ast.name = astName;\n }\n if (node.nodeType === ELEMENT_NODE) {\n switch (astType) {\n case SELECTOR_PSEUDO_ELEMENT: {\n this.#matcher.matchPseudoElementSelector(astName, opt);\n break;\n }\n case SELECTOR_ID: {\n if (node.id === astName) {\n matched.add(node);\n }\n break;\n }\n case SELECTOR_CLASS: {\n if (node.classList.contains(astName)) {\n matched.add(node);\n }\n break;\n }\n case SELECTOR_PSEUDO_CLASS: {\n const nodes = this._matchPseudoClassSelector(ast, node, opt);\n return nodes;\n }\n default: {\n const res = this.#matcher.matchSelector(ast, node, opt, true);\n if (res) {\n matched.add(res);\n }\n }\n }\n } else if (this.#shadow && astType === SELECTOR_PSEUDO_CLASS &&\n node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n if (astName !== 'has' && REG_LOGICAL_PSEUDO.test(astName)) {\n const nodes = this._matchPseudoClassSelector(ast, node, opt);\n return nodes;\n } else if (REG_SHADOW_HOST.test(astName)) {\n const res = this._matchShadowHostPseudoClass(ast, node, opt);\n if (res) {\n matched.add(res);\n }\n }\n }\n return matched;\n }\n\n /**\n * match leaves\n * @private\n * @param {Array.} leaves - AST leaves\n * @param {object} node - node\n * @param {object} opt - options\n * @returns {boolean} - result\n */\n _matchLeaves(leaves, node, opt) {\n let bool;\n let result;\n if (this.#invalidate) {\n result = this.#invalidateResults.get(leaves);\n } else {\n result = this.#results.get(leaves);\n }\n if (result && result.has(node)) {\n const { matched } = result.get(node);\n bool = matched;\n }\n if (typeof bool !== 'boolean') {\n let cacheable = true;\n if (node.nodeType === ELEMENT_NODE && REG_FORM.test(node.localName)) {\n cacheable = false;\n }\n for (const leaf of leaves) {\n switch (leaf.type) {\n case SELECTOR_ATTR:\n case SELECTOR_ID: {\n cacheable = false;\n break;\n }\n case SELECTOR_PSEUDO_CLASS: {\n if (/^(?:(?:any-)?link|defined|dir)$/.test(leaf.name)) {\n cacheable = false;\n }\n break;\n }\n default:\n }\n bool = this._matchSelector(leaf, node, opt).has(node);\n if (!bool) {\n break;\n }\n }\n if (cacheable) {\n if (!result) {\n result = new WeakMap();\n }\n result.set(node, {\n matched: bool\n });\n if (this.#invalidate) {\n this.#invalidateResults.set(leaves, result);\n } else {\n this.#results.set(leaves, result);\n }\n }\n }\n return !!bool;\n }\n\n /**\n * match HTML collection\n * @private\n * @param {object} items - HTML collection\n * @param {object} opt - options\n * @returns {Set.} - matched nodes\n */\n _matchHTMLCollection(items, opt = {}) {\n const { compound, filterLeaves } = opt;\n const nodes = new Set();\n const l = items.length;\n if (l) {\n if (compound) {\n for (let i = 0; i < l; i++) {\n const item = items[i];\n const bool = this._matchLeaves(filterLeaves, item, opt);\n if (bool) {\n nodes.add(item);\n }\n }\n } else {\n const arr = [].slice.call(items);\n return new Set(arr);\n }\n }\n return nodes;\n }\n\n /**\n * find descendant nodes\n * @private\n * @param {Array.} leaves - AST leaves\n * @param {object} baseNode - base Element node\n * @param {object} opt - options\n * @returns {object} - collection of nodes and pending state\n */\n _findDescendantNodes(leaves, baseNode, opt) {\n const [leaf, ...filterLeaves] = leaves;\n const compound = filterLeaves.length > 0;\n const { type: leafType } = leaf;\n const leafName = unescapeSelector(leaf.name);\n if (typeof leafName === 'string' && leafName !== leaf.name) {\n leaf.name = leafName;\n }\n let nodes = new Set();\n let pending = false;\n if (this.#shadow) {\n pending = true;\n } else {\n switch (leafType) {\n case SELECTOR_PSEUDO_ELEMENT: {\n this.#matcher.matchPseudoElementSelector(leafName, opt);\n break;\n }\n case SELECTOR_ID: {\n if (this.#root.nodeType === ELEMENT_NODE) {\n pending = true;\n } else {\n const node = this.#root.getElementById(leafName);\n if (node && node !== baseNode && baseNode.contains(node)) {\n if (compound) {\n const bool = this._matchLeaves(filterLeaves, node, opt);\n if (bool) {\n nodes.add(node);\n }\n } else {\n nodes.add(node);\n }\n }\n }\n break;\n }\n case SELECTOR_CLASS: {\n const items = baseNode.getElementsByClassName(leafName);\n nodes = this._matchHTMLCollection(items, {\n compound,\n filterLeaves\n });\n break;\n }\n case SELECTOR_TYPE: {\n if (this.#document.contentType === 'text/html' &&\n !/[*|]/.test(leafName)) {\n const items = baseNode.getElementsByTagName(leafName);\n nodes = this._matchHTMLCollection(items, {\n compound,\n filterLeaves\n });\n } else {\n pending = true;\n }\n break;\n }\n default: {\n pending = true;\n }\n }\n }\n return {\n nodes,\n pending\n };\n }\n\n /**\n * match combinator\n * @private\n * @param {object} twig - twig\n * @param {object} node - Element node\n * @param {object} opt - option\n * @returns {Set.} - collection of matched nodes\n */\n _matchCombinator(twig, node, opt = {}) {\n const { combo, leaves } = twig;\n const { name: comboName } = combo;\n const { parentNode } = node;\n const { dir } = opt;\n const matched = new Set();\n if (dir === DIR_NEXT) {\n switch (comboName) {\n case '+': {\n const refNode = node.nextElementSibling;\n if (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n }\n break;\n }\n case '~': {\n if (parentNode) {\n const walker = this._createTreeWalker(parentNode);\n let refNode = traverseNode(node, walker);\n refNode = walker.nextSibling();\n while (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n refNode = walker.nextSibling();\n }\n }\n break;\n }\n case '>': {\n const walker = this._createTreeWalker(node);\n let refNode = traverseNode(node, walker);\n refNode = walker.firstChild();\n while (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n refNode = walker.nextSibling();\n }\n break;\n }\n case ' ':\n default: {\n const { nodes, pending } = this._findDescendantNodes(leaves, node);\n if (nodes.size) {\n return nodes;\n }\n if (pending) {\n const walker = this._createTreeWalker(node);\n let refNode = traverseNode(node, walker);\n refNode = walker.nextNode();\n while (refNode && node.contains(refNode)) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n refNode = walker.nextNode();\n }\n }\n }\n }\n } else {\n switch (comboName) {\n case '+': {\n const refNode = node.previousElementSibling;\n if (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n }\n break;\n }\n case '~': {\n if (parentNode) {\n const walker = this._createTreeWalker(parentNode);\n let refNode = traverseNode(parentNode, walker);\n refNode = walker.firstChild();\n while (refNode) {\n if (refNode === node) {\n break;\n } else {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n }\n refNode = walker.nextSibling();\n }\n }\n break;\n }\n case '>': {\n if (parentNode) {\n const bool = this._matchLeaves(leaves, parentNode, opt);\n if (bool) {\n matched.add(parentNode);\n }\n }\n break;\n }\n case ' ':\n default: {\n const arr = [];\n let refNode = parentNode;\n while (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n arr.push(refNode);\n }\n refNode = refNode.parentNode;\n }\n if (arr.length) {\n return new Set(arr.reverse());\n }\n }\n }\n }\n return matched;\n }\n\n /**\n * find matched node from #qswalker\n * @private\n * @param {Array.} leaves - AST leaves\n * @param {object} [opt] - options\n * @param {object} [opt.node] - node to start from\n * @returns {?object} - matched node\n */\n _findNode(leaves, opt) {\n const { node } = opt;\n const walker = this.#qswalker;\n let refNode = traverseNode(node, walker);\n let matchedNode;\n if (refNode) {\n if (refNode.nodeType !== ELEMENT_NODE) {\n refNode = walker.nextNode();\n } else if (refNode === node) {\n if (refNode !== this.#root) {\n refNode = walker.nextNode();\n }\n }\n while (refNode) {\n const matched = this._matchLeaves(leaves, refNode, {\n warn: this.#warn\n });\n if (matched) {\n matchedNode = refNode;\n break;\n }\n refNode = walker.nextNode();\n }\n }\n return matchedNode ?? null;\n }\n\n /**\n * match self\n * @private\n * @param {Array} leaves - AST leaves\n * @returns {Array} - [nodes, filtered]\n */\n _matchSelf(leaves) {\n const nodes = [];\n const bool = this._matchLeaves(leaves, this.#node, {\n warn: this.#warn\n });\n let filtered = false;\n if (bool) {\n nodes.push(this.#node);\n filtered = true;\n }\n return [nodes, filtered];\n }\n\n /**\n * find lineal\n * @private\n * @param {Array} leaves - AST leaves\n * @param {object} opt - options\n * @returns {Array} - [nodes, filtered]\n */\n _findLineal(leaves, opt = {}) {\n const { complex } = opt;\n const nodes = [];\n let bool = this._matchLeaves(leaves, this.#node, {\n warn: this.#warn\n });\n let filtered = false;\n if (bool) {\n nodes.push(this.#node);\n filtered = true;\n }\n if (!bool || complex) {\n let refNode = this.#node.parentNode;\n while (refNode) {\n bool = this._matchLeaves(leaves, refNode, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(refNode);\n filtered = true;\n }\n if (refNode.parentNode) {\n refNode = refNode.parentNode;\n } else {\n break;\n }\n }\n }\n return [nodes, filtered];\n }\n\n /**\n * find first\n * @private\n * @param {Array} leaves - AST leaves\n * @returns {Array} - [nodes, filtered]\n */\n _findFirst(leaves) {\n const nodes = [];\n const node = this._findNode(leaves, {\n node: this.#node\n });\n let filtered = false;\n if (node) {\n nodes.push(node);\n filtered = true;\n }\n return [nodes, filtered];\n }\n\n /**\n * find from HTML collection\n * @private\n * @param {object} items - HTML collection\n * @param {object} opt - options\n * @param {boolean} [opt.compound] - compound selector\n * @param {Array} [opt.filterLeaves] - filter leaves\n * @returns {Array} - [nodes, filtered]\n */\n _findFromHTMLCollection(items, opt = {}) {\n const { complex, compound, filterLeaves, targetType } = opt;\n let nodes = [];\n let filtered = false;\n let collected = false;\n const l = items.length;\n if (l) {\n if (this.#node.nodeType === ELEMENT_NODE) {\n for (let i = 0; i < l; i++) {\n const node = items[i];\n if (node !== this.#node &&\n (this.#node.contains(node) || node.contains(this.#node))) {\n if (compound) {\n const bool = this._matchLeaves(filterLeaves, node, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(node);\n filtered = true;\n if (targetType === TARGET_FIRST) {\n break;\n }\n }\n } else {\n nodes.push(node);\n filtered = true;\n if (targetType === TARGET_FIRST) {\n break;\n }\n }\n }\n }\n } else if (complex) {\n if (compound) {\n for (let i = 0; i < l; i++) {\n const node = items[i];\n const bool = this._matchLeaves(filterLeaves, node, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(node);\n filtered = true;\n if (targetType === TARGET_FIRST) {\n break;\n }\n }\n }\n } else {\n nodes = [].slice.call(items);\n filtered = true;\n collected = true;\n }\n } else if (compound) {\n for (let i = 0; i < l; i++) {\n const node = items[i];\n const bool = this._matchLeaves(filterLeaves, node, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(node);\n filtered = true;\n if (targetType === TARGET_FIRST) {\n break;\n }\n }\n }\n } else {\n nodes = [].slice.call(items);\n filtered = true;\n collected = true;\n }\n }\n return [nodes, filtered, collected];\n }\n\n /**\n * find entry nodes\n * @private\n * @param {object} twig - twig\n * @param {string} targetType - target type\n * @param {boolean} complex - complex selector\n * @returns {object} - collection of nodes etc.\n */\n _findEntryNodes(twig, targetType, complex) {\n const { leaves } = twig;\n const [leaf, ...filterLeaves] = leaves;\n const compound = filterLeaves.length > 0;\n const { name: leafName, type: leafType } = leaf;\n let nodes = [];\n let collected = false;\n let filtered = false;\n let pending = false;\n switch (leafType) {\n case SELECTOR_PSEUDO_ELEMENT: {\n this.#matcher.matchPseudoElementSelector(leafName, {\n warn: this.#warn\n });\n break;\n }\n case SELECTOR_ID: {\n if (targetType === TARGET_SELF) {\n [nodes, filtered] = this._matchSelf(leaves);\n } else if (targetType === TARGET_LINEAL) {\n [nodes, filtered] = this._findLineal(leaves, {\n complex\n });\n } else if (targetType === TARGET_FIRST &&\n this.#root.nodeType !== ELEMENT_NODE) {\n const node = this.#root.getElementById(leafName);\n if (node) {\n if (compound) {\n const bool = this._matchLeaves(filterLeaves, node, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(node);\n filtered = true;\n }\n } else {\n nodes.push(node);\n filtered = true;\n }\n }\n } else if (targetType === TARGET_FIRST) {\n [nodes, filtered] = this._findFirst(leaves);\n } else {\n pending = true;\n }\n break;\n }\n case SELECTOR_CLASS: {\n if (targetType === TARGET_SELF) {\n [nodes, filtered] = this._matchSelf(leaves);\n } else if (targetType === TARGET_LINEAL) {\n [nodes, filtered] = this._findLineal(leaves, {\n complex\n });\n } else if (this.#root.nodeType === DOCUMENT_NODE) {\n const items = this.#root.getElementsByClassName(leafName);\n if (items.length) {\n [nodes, filtered, collected] = this._findFromHTMLCollection(items, {\n complex,\n compound,\n filterLeaves,\n targetType\n });\n }\n } else if (targetType === TARGET_FIRST) {\n [nodes, filtered] = this._findFirst(leaves);\n } else {\n pending = true;\n }\n break;\n }\n case SELECTOR_TYPE: {\n if (targetType === TARGET_SELF) {\n [nodes, filtered] = this._matchSelf(leaves);\n } else if (targetType === TARGET_LINEAL) {\n [nodes, filtered] = this._findLineal(leaves, {\n complex\n });\n } else if (this.#document.contentType === 'text/html' &&\n this.#root.nodeType === DOCUMENT_NODE &&\n !/[*|]/.test(leafName)) {\n const items = this.#root.getElementsByTagName(leafName);\n if (items.length) {\n [nodes, filtered, collected] = this._findFromHTMLCollection(items, {\n complex,\n compound,\n filterLeaves,\n targetType\n });\n }\n } else if (targetType === TARGET_FIRST) {\n [nodes, filtered] = this._findFirst(leaves);\n } else {\n pending = true;\n }\n break;\n }\n default: {\n if (targetType !== TARGET_LINEAL && REG_SHADOW_HOST.test(leafName)) {\n if (this.#shadow &&\n this.#node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n const node = this._matchShadowHostPseudoClass(leaf, this.#node);\n if (node) {\n nodes.push(node);\n filtered = true;\n }\n }\n } else if (targetType === TARGET_SELF) {\n [nodes, filtered] = this._matchSelf(leaves);\n } else if (targetType === TARGET_LINEAL) {\n [nodes, filtered] = this._findLineal(leaves, {\n complex\n });\n } else if (targetType === TARGET_FIRST) {\n [nodes, filtered] = this._findFirst(leaves);\n } else {\n pending = true;\n }\n }\n }\n return {\n collected,\n compound,\n filtered,\n nodes,\n pending\n };\n }\n\n /**\n * collect nodes\n * @private\n * @param {string} targetType - target type\n * @returns {Array.>} - #ast and #nodes\n */\n _collectNodes(targetType) {\n const ast = this.#ast.values();\n if (targetType === TARGET_ALL || targetType === TARGET_FIRST) {\n const pendingItems = new Set();\n let i = 0;\n for (const { branch } of ast) {\n const branchLen = branch.length;\n const complex = branchLen > 1;\n const firstTwig = branch[0];\n let dir;\n let twig;\n if (complex) {\n const {\n combo: firstCombo,\n leaves: [{\n name: firstName,\n type: firstType\n }]\n } = firstTwig;\n const lastTwig = branch[branchLen - 1];\n const {\n leaves: [{\n name: lastName,\n type: lastType\n }]\n } = lastTwig;\n if (lastType === SELECTOR_PSEUDO_ELEMENT ||\n lastType === SELECTOR_ID) {\n dir = DIR_PREV;\n twig = lastTwig;\n } else if (firstType === SELECTOR_PSEUDO_ELEMENT ||\n firstType === SELECTOR_ID) {\n dir = DIR_NEXT;\n twig = firstTwig;\n } else if (targetType === TARGET_ALL) {\n if (firstName === '*' && firstType === SELECTOR_TYPE) {\n dir = DIR_PREV;\n twig = lastTwig;\n } else if (lastName === '*' && lastType === SELECTOR_TYPE) {\n dir = DIR_NEXT;\n twig = firstTwig;\n } else if (branchLen === 2) {\n const { name: comboName } = firstCombo;\n if (/^[+~]$/.test(comboName)) {\n dir = DIR_PREV;\n twig = lastTwig;\n } else {\n dir = DIR_NEXT;\n twig = firstTwig;\n }\n } else {\n dir = DIR_NEXT;\n twig = firstTwig;\n }\n } else if (lastName === '*' && lastType === SELECTOR_TYPE) {\n dir = DIR_NEXT;\n twig = firstTwig;\n } else if (firstName === '*' && firstType === SELECTOR_TYPE) {\n dir = DIR_PREV;\n twig = lastTwig;\n } else {\n let bool;\n for (const { combo, leaves: [leaf] } of branch) {\n const { name: leafName, type: leafType } = leaf;\n if (leafType === SELECTOR_PSEUDO_CLASS && leafName === 'dir') {\n bool = false;\n break;\n }\n if (!bool && combo) {\n const { name: comboName } = combo;\n if (/^[+~]$/.test(comboName)) {\n bool = true;\n }\n }\n }\n if (bool) {\n dir = DIR_NEXT;\n twig = firstTwig;\n } else {\n dir = DIR_PREV;\n twig = lastTwig;\n }\n }\n } else {\n dir = DIR_PREV;\n twig = firstTwig;\n }\n const {\n collected, compound, filtered, nodes, pending\n } = this._findEntryNodes(twig, targetType, complex);\n if (nodes.length) {\n this.#ast[i].find = true;\n this.#nodes[i] = nodes;\n } else if (pending) {\n pendingItems.add(new Map([\n ['index', i],\n ['twig', twig]\n ]));\n }\n this.#ast[i].collected = collected;\n this.#ast[i].dir = dir;\n this.#ast[i].filtered = filtered || !compound;\n i++;\n }\n if (pendingItems.size) {\n let node;\n let walker;\n if (this.#node !== this.#root && this.#node.nodeType === ELEMENT_NODE) {\n node = this.#node;\n walker = this.#qswalker;\n } else {\n node = this.#root;\n walker = this.#walker;\n }\n let nextNode = traverseNode(node, walker);\n while (nextNode) {\n let bool = false;\n if (this.#node.nodeType === ELEMENT_NODE) {\n if (nextNode === this.#node) {\n bool = true;\n } else {\n bool = this.#node.contains(nextNode);\n }\n } else {\n bool = true;\n }\n if (bool) {\n for (const pendingItem of pendingItems) {\n const { leaves } = pendingItem.get('twig');\n const matched = this._matchLeaves(leaves, nextNode, {\n warn: this.#warn\n });\n if (matched) {\n const index = pendingItem.get('index');\n this.#ast[index].filtered = true;\n this.#ast[index].find = true;\n this.#nodes[index].push(nextNode);\n }\n }\n }\n if (nextNode !== walker.currentNode) {\n nextNode = traverseNode(nextNode, walker);\n }\n nextNode = walker.nextNode();\n }\n }\n } else {\n let i = 0;\n for (const { branch } of ast) {\n const twig = branch[branch.length - 1];\n const complex = branch.length > 1;\n const {\n compound, filtered, nodes\n } = this._findEntryNodes(twig, targetType, complex);\n if (nodes.length) {\n this.#ast[i].find = true;\n this.#nodes[i] = nodes;\n }\n this.#ast[i].dir = DIR_PREV;\n this.#ast[i].filtered = filtered || !compound;\n i++;\n }\n }\n return [\n this.#ast,\n this.#nodes\n ];\n }\n\n /**\n * get combined nodes\n * @private\n * @param {object} twig - twig\n * @param {object} nodes - collection of nodes\n * @param {string} dir - direction\n * @returns {Array.} - collection of matched nodes\n */\n _getCombinedNodes(twig, nodes, dir) {\n const arr = [];\n for (const node of nodes) {\n const matched = this._matchCombinator(twig, node, {\n dir,\n warn: this.#warn\n });\n if (matched.size) {\n arr.push(...matched);\n }\n }\n if (arr.length) {\n return new Set(arr);\n }\n return new Set();\n }\n\n /**\n * match node to next direction\n * @private\n * @param {Array} branch - branch\n * @param {Set.} nodes - collection of Element node\n * @param {object} opt - option\n * @param {object} opt.combo - combo\n * @returns {?object} - matched node\n */\n _matchNodeNext(branch, nodes, opt) {\n const { combo, index } = opt;\n const { combo: nextCombo, leaves } = branch[index];\n const twig = {\n combo,\n leaves\n };\n const nextNodes = this._getCombinedNodes(twig, nodes, DIR_NEXT);\n let res;\n if (nextNodes.size) {\n if (index === branch.length - 1) {\n const [nextNode] = sortNodes(nextNodes);\n res = nextNode;\n } else {\n res = this._matchNodeNext(branch, nextNodes, {\n combo: nextCombo,\n index: index + 1\n });\n }\n }\n return res ?? null;\n }\n\n /**\n * match node to previous direction\n * @private\n * @param {Array} branch - branch\n * @param {object} node - Element node\n * @param {object} opt - option\n * @param {number} opt.index - index\n * @returns {?object} - node\n */\n _matchNodePrev(branch, node, opt) {\n const { index } = opt;\n const twig = branch[index];\n const nodes = new Set([node]);\n const nextNodes = this._getCombinedNodes(twig, nodes, DIR_PREV);\n let res;\n if (nextNodes.size) {\n if (index === 0) {\n res = node;\n } else {\n for (const nextNode of nextNodes) {\n const matched = this._matchNodePrev(branch, nextNode, {\n index: index - 1\n });\n if (matched) {\n return node;\n }\n }\n }\n }\n return res ?? null;\n }\n\n /**\n * find matched nodes\n * @param {string} targetType - target type\n * @returns {Set.} - collection of matched nodes\n */\n find(targetType) {\n if (targetType === TARGET_ALL || targetType === TARGET_FIRST) {\n this._prepareQuerySelectorWalker();\n }\n const [[...branches], collectedNodes] = this._collectNodes(targetType);\n const l = branches.length;\n let sort;\n let nodes = new Set();\n for (let i = 0; i < l; i++) {\n const { branch, collected, dir, find } = branches[i];\n const branchLen = branch.length;\n if (branchLen && find) {\n const entryNodes = collectedNodes[i];\n const entryNodesLen = entryNodes.length;\n const lastIndex = branchLen - 1;\n if (lastIndex === 0) {\n if ((targetType === TARGET_ALL || targetType === TARGET_FIRST) &&\n this.#node.nodeType === ELEMENT_NODE) {\n for (let j = 0; j < entryNodesLen; j++) {\n const node = entryNodes[j];\n if (node !== this.#node && this.#node.contains(node)) {\n nodes.add(node);\n if (targetType !== TARGET_ALL) {\n break;\n }\n }\n }\n } else if (targetType === TARGET_ALL) {\n if (nodes.size) {\n const n = [...nodes];\n nodes = new Set([...n, ...entryNodes]);\n sort = true;\n } else {\n nodes = new Set(entryNodes);\n }\n } else {\n const [node] = entryNodes;\n nodes.add(node);\n }\n } else if (targetType === TARGET_ALL) {\n if (dir === DIR_NEXT) {\n let { combo } = branch[0];\n for (const node of entryNodes) {\n let nextNodes = new Set([node]);\n for (let j = 1; j < branchLen; j++) {\n const { combo: nextCombo, leaves } = branch[j];\n const twig = {\n combo,\n leaves\n };\n nextNodes = this._getCombinedNodes(twig, nextNodes, dir);\n if (nextNodes.size) {\n if (j === lastIndex) {\n if (nodes.size) {\n const n = [...nodes];\n nodes = new Set([...n, ...nextNodes]);\n sort = true;\n } else {\n nodes = nextNodes;\n }\n } else {\n combo = nextCombo;\n }\n } else {\n break;\n }\n }\n }\n } else {\n for (const node of entryNodes) {\n let nextNodes = new Set([node]);\n for (let j = lastIndex - 1; j >= 0; j--) {\n const twig = branch[j];\n nextNodes = this._getCombinedNodes(twig, nextNodes, dir);\n if (nextNodes.size) {\n if (j === 0) {\n nodes.add(node);\n if (branchLen > 1 && nodes.size > 1) {\n sort = true;\n }\n }\n } else {\n break;\n }\n }\n }\n }\n } else if (targetType === TARGET_FIRST && dir === DIR_NEXT) {\n const { combo: entryCombo } = branch[0];\n let matched;\n for (const node of entryNodes) {\n matched = this._matchNodeNext(branch, new Set([node]), {\n combo: entryCombo,\n index: 1\n });\n if (matched) {\n nodes.add(matched);\n break;\n }\n }\n if (!matched && !collected) {\n const { leaves: entryLeaves } = branch[0];\n const [entryNode] = entryNodes;\n let refNode = this._findNode(entryLeaves, {\n node: entryNode\n });\n while (refNode) {\n matched = this._matchNodeNext(branch, new Set([refNode]), {\n combo: entryCombo,\n index: 1\n });\n if (matched) {\n nodes.add(matched);\n break;\n }\n refNode = this._findNode(entryLeaves, {\n node: refNode\n });\n }\n }\n } else {\n let matched;\n for (const node of entryNodes) {\n matched = this._matchNodePrev(branch, node, {\n index: lastIndex - 1\n });\n if (matched) {\n nodes.add(node);\n break;\n }\n }\n if (!matched && !collected && targetType === TARGET_FIRST) {\n const { leaves: entryLeaves } = branch[lastIndex];\n const [entryNode] = entryNodes;\n let refNode = this._findNode(entryLeaves, {\n node: entryNode\n });\n while (refNode) {\n matched = this._matchNodePrev(branch, refNode, {\n index: lastIndex - 1\n });\n if (matched) {\n nodes.add(refNode);\n break;\n }\n refNode = this._findNode(entryLeaves, {\n node: refNode\n });\n }\n }\n }\n }\n }\n if (targetType === TARGET_FIRST) {\n nodes.delete(this.#node);\n if (nodes.size > 1) {\n nodes = new Set(sortNodes(nodes));\n }\n } else if (targetType === TARGET_ALL) {\n nodes.delete(this.#node);\n if (sort && nodes.size > 1) {\n nodes = new Set(sortNodes(nodes));\n }\n }\n return nodes;\n }\n};\n"], - "mappings": "4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAAwB,wBACxBC,EAEO,uBACPC,EAGO,wBAGPC,EASO,yBACP,MAAMC,EAAW,OACXC,EAAW,OA0BV,MAAMP,CAAO,CAElBQ,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GAMA,YAAYC,EAAQ,CAClB,KAAKD,GAAUC,EACf,KAAKZ,GAAW,IAAI,UACpB,KAAKP,GAAY,IAAI,QACrB,KAAKG,GAAiB,IAAI,QAC1B,KAAKG,GAAqB,IAAI,QAC9B,KAAKM,GAAW,IAAI,OACtB,CASA,QAAQQ,EAAGC,EAAM,CAAC,EAAG,CAEnB,GAAI,EADaA,EAAI,UAAY,KAAKX,IAEpC,GAAIU,aAAa,cACbA,aAAa,KAAKF,GAAQ,aAC5B,GAAIE,EAAE,OAAS,oBACT,KAAKH,IACP,QAAQ,KAAKG,EAAE,OAAO,MAGxB,OAAM,IAAI,KAAKF,GAAQ,aAAaE,EAAE,QAASA,EAAE,IAAI,MAGvD,OAAMA,CAGZ,CAYA,MAAME,EAAUC,EAAMF,EAAM,CAAC,EAAG,CAC9B,KAAM,CAAE,MAAAG,EAAO,SAAAC,EAAU,KAAAC,CAAK,EAAIL,EAClC,YAAKX,GAAY,CAAC,CAACe,EACnB,KAAKR,GAAQ,CAAC,CAACS,EACf,KAAKtB,GAAS,KAAK,UAAUoB,CAAK,EAClC,KAAKhB,GAAQe,EACb,CAAC,KAAKrB,GAAW,KAAKW,GAAO,KAAKE,EAAO,KAAI,kBAAeQ,C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,EAAQ,IAAI,OAAI,aAAUA,CAAK,CAAC,IAG7BA,CACT,CACF", - "names": ["finder_exports", "__export", "Finder", "__toCommonJS", "import_matcher", "import_parser", "import_utility", "import_constant", "DIR_NEXT", "DIR_PREV", "#ast", "#astCache", "#descendant", "#document", "#documentCache", "#event", "#invalidate", "#invalidateResults", "#matcher", "#node", "#nodes", "#noexcept", "#qswalker", "#results", "#root", "#shadow", "#walker", "#walkers", "#warn", "#window", "window", "e", "opt", "selector", "node", "event", "noexcept", "warn", "nodes", "ast", "cachedItem", "item", "l", "i", "cssAst", "branches", "hasHasPseudoFunc", "invalidate", "descendant", "items", "branch", "leaves", "nextItem", "itemName", "walker", "anb", "a", "b", "reverse", "parentNode", "matched", "selectorBranches", "info", "refNode", "selectorNodes", "display", "visibility", "bool", "nth", "j", "localName", "namespaceURI", "prefix", "itemLocalName", "itemNamespaceURI", "itemPrefix", "m", "nthName", "nthIdentName", "anbMap", "astLeaves", "leaf", "leafType", "combo", "twigLeaves", "itemType", "twig", "nextNode", "astData", "astName", "twigBranches", "res", "forgive", "lastIndex", "nextNodes", "arr", "astChildren", "selectors", "css", "leavesSet", "stateValue", "prop", "href", "origin", "pathname", "attrURL", "target", "type", "buttons", "hash", "id", "current", "focus", "active", "parent", "placeholder", "targetNode", "nodeName", "checked", "form", "inputType", "node1", "node2", "host", "astType", "result", "cacheable", "compound", "filterLeaves", "baseNode", "leafName", "pending", "comboName", "dir", "matchedNode", "filtered", "complex", "targetType", "collected", "pendingItems", "branchLen", "firstTwig", "firstCombo", "firstName", "firstType", "lastTwig", "lastName", "lastType", "pendingItem", "index", "nextCombo", "collectedNodes", "sort", "find", "entryNodes", "entryNodesLen", "n", "entryCombo", "entryLeaves", "entryNode"] + "sourcesContent": ["/**\n * finder.js\n */\n\n/* import */\nimport { Matcher } from './matcher.js';\nimport {\n generateCSS, parseSelector, sortAST, unescapeSelector, walkAST\n} from './parser.js';\nimport {\n isContentEditable, isCustomElement, isFocusVisible, isFocusable,\n isInShadowTree, resolveContent, sortNodes, traverseNode\n} from './utility.js';\n\n/* constants */\nimport {\n BIT_01, COMBINATOR, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, ELEMENT_NODE,\n EMPTY, NOT_SUPPORTED_ERR, REG_ANCHOR, REG_FORM, REG_FORM_CTRL,\n REG_FORM_VALID, REG_INTERACT, REG_LOGICAL_PSEUDO, REG_SHADOW_HOST,\n REG_TYPE_CHECK, REG_TYPE_INPUT, REG_TYPE_RANGE, REG_TYPE_RESET,\n REG_TYPE_SUBMIT, REG_TYPE_TEXT, SELECTOR_ATTR, SELECTOR_CLASS, SELECTOR_ID,\n SELECTOR_PSEUDO_CLASS, SELECTOR_PSEUDO_ELEMENT, SELECTOR_TYPE, SHOW_ALL,\n SYNTAX_ERR, TARGET_ALL, TARGET_FIRST, TARGET_LINEAL, TARGET_SELF, TEXT_NODE,\n WALKER_FILTER\n} from './constant.js';\nconst DIR_NEXT = 'next';\nconst DIR_PREV = 'prev';\nconst KEY_TAB = 'Tab';\n\n/**\n * Finder\n * NOTE: #ast[i] corresponds to #nodes[i]\n * #ast: Array\n * #nodes: Array\n * Ast: {\n * branch: Array,\n * collected: boolean,\n * dir: string | null,\n * filtered: boolean,\n * find: boolean\n * }\n * Branch: Array\n * Twig: {\n * combo: Leaf | null,\n * leaves: Array\n * }\n * Leaf: {\n * children: Array | null,\n * loc: null,\n * type: string\n * }\n * Nodes: Array\n */\nexport class Finder {\n /* private fields */\n #ast;\n #astCache;\n #descendant;\n #document;\n #documentCache;\n #event;\n #focus;\n #invalidate;\n #invalidateResults;\n #matcher;\n #node;\n #nodes;\n #noexcept;\n #qswalker;\n #results;\n #root;\n #shadow;\n #walker;\n #walkers;\n #warn;\n #window;\n\n /**\n * construct\n * @param {object} window - window\n */\n constructor(window) {\n this.#window = window;\n this.#matcher = new Matcher();\n this.#astCache = new WeakMap();\n this.#documentCache = new WeakMap();\n this.#invalidateResults = new WeakMap();\n this.#results = new WeakMap();\n this.#event = null;\n this.#focus = null;\n this._registerEventListeners();\n }\n\n /**\n * handle error\n * @param {Error} e - Error\n * @param {object} opt - options\n * @throws Error\n * @returns {void}\n */\n onError(e, opt = {}) {\n const noexcept = opt.noexcept ?? this.#noexcept;\n if (!noexcept) {\n if (e instanceof DOMException ||\n e instanceof this.#window.DOMException) {\n if (e.name === NOT_SUPPORTED_ERR) {\n if (this.#warn) {\n console.warn(e.message);\n }\n } else {\n throw new this.#window.DOMException(e.message, e.name);\n }\n } else {\n throw e;\n }\n }\n }\n\n /**\n * setup finder\n * @param {string} selector - CSS selector\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} opt - options\n * @param {object} [opt.event] - MouseEvent, KeyboardEvent\n * @param {boolean} [opt.noexcept] - no exception\n * @param {boolean} [opt.warn] - console warn\n * @returns {object} - node\n */\n setup(selector, node, opt = {}) {\n const { event, noexcept, warn } = opt;\n this.#noexcept = !!noexcept;\n this.#warn = !!warn;\n this.#node = node;\n [this.#document, this.#root, this.#walker] = resolveContent(node);\n this.#shadow = isInShadowTree(node);\n [this.#ast, this.#nodes] = this._correspond(selector);\n this.#invalidateResults = new WeakMap();\n this.#walkers = new WeakMap();\n this._setEvent(event);\n return node;\n }\n\n /**\n * register event listeners\n * @private\n * @returns {Array.} - results\n */\n _registerEventListeners() {\n const opt = {\n capture: true,\n passive: true\n };\n const func = [];\n const mouseKeys = ['mouseover', 'mousedown', 'mouseup', 'mouseout'];\n for (const key of mouseKeys) {\n func.push(this.#window.addEventListener(key, evt => {\n this.#event = evt;\n }, opt));\n }\n const keyboardKeys = ['keydown', 'keyup'];\n for (const key of keyboardKeys) {\n func.push(this.#window.addEventListener(key, evt => {\n if (evt.key === KEY_TAB) {\n this.#event = evt;\n }\n }, opt));\n }\n func.push(this.#window.addEventListener('focusin', evt => {\n this.#focus = evt;\n }, opt));\n return func;\n }\n\n /**\n * set event\n * @private\n * @param {object} event - instance of KeyboardEvent, MouseEvent\n * @returns {object} - event\n */\n _setEvent(event) {\n // NOTE: PointerEvent not implemented in jsdom\n if (event instanceof this.#window.KeyboardEvent ||\n event instanceof this.#window.MouseEvent) {\n this.#event = event;\n }\n return this.#event;\n }\n\n /**\n * correspond ast and nodes\n * @private\n * @param {string} selector - CSS selector\n * @returns {Array.>} - array of ast and nodes\n */\n _correspond(selector) {\n const nodes = [];\n this.#descendant = false;\n this.#invalidate = false;\n let ast;\n if (this.#documentCache.has(this.#document)) {\n const cachedItem = this.#documentCache.get(this.#document);\n if (cachedItem && cachedItem.has(`${selector}`)) {\n const item = cachedItem.get(`${selector}`);\n ast = item.ast;\n this.#descendant = item.descendant;\n this.#invalidate = item.invalidate;\n }\n }\n if (ast) {\n const l = ast.length;\n for (let i = 0; i < l; i++) {\n ast[i].collected = false;\n ast[i].dir = null;\n ast[i].filtered = false;\n ast[i].find = false;\n nodes[i] = [];\n }\n } else {\n let cssAst;\n try {\n cssAst = parseSelector(selector);\n } catch (e) {\n this.onError(e);\n }\n const { branches, info: { hasHasPseudoFunc } } = walkAST(cssAst);\n let invalidate = !!hasHasPseudoFunc;\n let descendant = false;\n let i = 0;\n ast = [];\n for (const [...items] of branches) {\n const branch = [];\n let item = items.shift();\n if (item && item.type !== COMBINATOR) {\n const leaves = new Set();\n while (item) {\n if (item.type === COMBINATOR) {\n const [nextItem] = items;\n if (nextItem.type === COMBINATOR) {\n throw new DOMException(`Invalid selector ${selector}`,\n SYNTAX_ERR);\n }\n const itemName = item.name;\n if (/^[\\s>]$/.test(itemName)) {\n descendant = true;\n } else {\n invalidate = true;\n }\n branch.push({\n combo: item,\n leaves: sortAST(leaves)\n });\n leaves.clear();\n } else if (item) {\n let { name: itemName } = item;\n if (itemName && typeof itemName === 'string') {\n itemName = unescapeSelector(itemName);\n if (typeof itemName === 'string' && itemName !== item.name) {\n item.name = itemName;\n }\n if (/[|:]/.test(itemName)) {\n item.namespace = true;\n }\n }\n leaves.add(item);\n }\n if (items.length) {\n item = items.shift();\n } else {\n branch.push({\n combo: null,\n leaves: sortAST(leaves)\n });\n leaves.clear();\n break;\n }\n }\n }\n ast.push({\n branch,\n collected: false,\n dir: null,\n filtered: false,\n find: false\n });\n nodes[i] = [];\n i++;\n }\n let cachedItem;\n if (this.#documentCache.has(this.#document)) {\n cachedItem = this.#documentCache.get(this.#document);\n } else {\n cachedItem = new Map();\n }\n cachedItem.set(`${selector}`, {\n ast,\n descendant,\n invalidate\n });\n this.#documentCache.set(this.#document, cachedItem);\n this.#descendant = descendant;\n this.#invalidate = invalidate;\n }\n return [\n ast,\n nodes\n ];\n }\n\n /**\n * create tree walker\n * @private\n * @param {object} node - Document, DocumentFragment, Element node\n * @returns {object} - tree walker\n */\n _createTreeWalker(node) {\n let walker;\n if (this.#walkers.has(node)) {\n walker = this.#walkers.get(node);\n } else {\n walker = this.#document.createTreeWalker(node, WALKER_FILTER);\n this.#walkers.set(node, walker);\n }\n return walker;\n }\n\n /**\n * prepare querySelector walker\n * @private\n * @returns {object} - tree walker\n */\n _prepareQuerySelectorWalker() {\n this.#qswalker = this._createTreeWalker(this.#node);\n return this.#qswalker;\n }\n\n /**\n * collect nth child\n * @private\n * @param {object} anb - An+B options\n * @param {number} anb.a - a\n * @param {number} anb.b - b\n * @param {boolean} [anb.reverse] - reverse order\n * @param {object} [anb.selector] - AST\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {Set.} - collection of matched nodes\n */\n _collectNthChild(anb, node, opt) {\n const { a, b, reverse, selector } = anb;\n const { parentNode } = node;\n const matched = new Set();\n let selectorBranches;\n if (selector) {\n if (this.#astCache.has(selector)) {\n selectorBranches = this.#astCache.get(selector);\n } else {\n const { branches, info } = walkAST(selector);\n selectorBranches = branches;\n this.#astCache.set(selector, selectorBranches);\n if (info.hasLogicalPseudoFunc) {\n this.#invalidate = true;\n }\n }\n }\n if (parentNode) {\n const walker = this.#walker;\n let refNode = traverseNode(parentNode, walker);\n refNode = walker.firstChild();\n let l = 0;\n while (refNode) {\n l++;\n refNode = walker.nextSibling();\n }\n const selectorNodes = new Set();\n if (selectorBranches) {\n refNode = traverseNode(parentNode, walker);\n refNode = walker.firstChild();\n while (refNode) {\n const { display, visibility } =\n this.#window.getComputedStyle(refNode);\n if (display !== 'none' && visibility !== 'hidden') {\n let bool;\n for (const leaves of selectorBranches) {\n bool = this._matchLeaves(leaves, refNode, opt);\n if (!bool) {\n break;\n }\n }\n if (bool) {\n selectorNodes.add(refNode);\n }\n }\n refNode = walker.nextSibling();\n }\n }\n // :first-child, :last-child, :nth-child(b of S), :nth-last-child(b of S)\n if (a === 0) {\n if (b > 0 && b <= l) {\n if (selectorNodes.size) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let i = 0;\n while (refNode) {\n if (selectorNodes.has(refNode)) {\n if (i === b - 1) {\n matched.add(refNode);\n break;\n }\n i++;\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n }\n } else if (!selector) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let i = 0;\n while (refNode) {\n if (i === b - 1) {\n matched.add(refNode);\n break;\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n i++;\n }\n }\n }\n // :nth-child()\n } else {\n let nth = b - 1;\n if (a > 0) {\n while (nth < 0) {\n nth += a;\n }\n }\n if (nth >= 0 && nth < l) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let i = 0;\n let j = a > 0 ? 0 : b - 1;\n while (refNode) {\n if (refNode && nth >= 0 && nth < l) {\n if (selectorNodes.size) {\n if (selectorNodes.has(refNode)) {\n if (j === nth) {\n matched.add(refNode);\n nth += a;\n }\n if (a > 0) {\n j++;\n } else {\n j--;\n }\n }\n } else if (i === nth) {\n if (!selector) {\n matched.add(refNode);\n }\n nth += a;\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n i++;\n } else {\n break;\n }\n }\n }\n }\n if (reverse && matched.size > 1) {\n const m = [...matched];\n return new Set(m.reverse());\n }\n } else if (node === this.#root && (a + b) === 1) {\n if (selectorBranches) {\n let bool;\n for (const leaves of selectorBranches) {\n bool = this._matchLeaves(leaves, node, opt);\n if (bool) {\n break;\n }\n }\n if (bool) {\n matched.add(node);\n }\n } else {\n matched.add(node);\n }\n }\n return matched;\n }\n\n /**\n * collect nth of type\n * @private\n * @param {object} anb - An+B options\n * @param {number} anb.a - a\n * @param {number} anb.b - b\n * @param {boolean} [anb.reverse] - reverse order\n * @param {object} node - Element node\n * @returns {Set.} - collection of matched nodes\n */\n _collectNthOfType(anb, node) {\n const { a, b, reverse } = anb;\n const { localName, namespaceURI, parentNode, prefix } = node;\n const matched = new Set();\n if (parentNode) {\n const walker = this.#walker;\n let refNode = traverseNode(parentNode, walker);\n refNode = walker.firstChild();\n let l = 0;\n while (refNode) {\n l++;\n refNode = walker.nextSibling();\n }\n // :first-of-type, :last-of-type\n if (a === 0) {\n if (b > 0 && b <= l) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let j = 0;\n while (refNode) {\n const {\n localName: itemLocalName, namespaceURI: itemNamespaceURI,\n prefix: itemPrefix\n } = refNode;\n if (itemLocalName === localName && itemPrefix === prefix &&\n itemNamespaceURI === namespaceURI) {\n if (j === b - 1) {\n matched.add(refNode);\n break;\n }\n j++;\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n }\n }\n // :nth-of-type()\n } else {\n let nth = b - 1;\n if (a > 0) {\n while (nth < 0) {\n nth += a;\n }\n }\n if (nth >= 0 && nth < l) {\n refNode = traverseNode(parentNode, walker);\n if (reverse) {\n refNode = walker.lastChild();\n } else {\n refNode = walker.firstChild();\n }\n let j = a > 0 ? 0 : b - 1;\n while (refNode) {\n const {\n localName: itemLocalName, namespaceURI: itemNamespaceURI,\n prefix: itemPrefix\n } = refNode;\n if (itemLocalName === localName && itemPrefix === prefix &&\n itemNamespaceURI === namespaceURI) {\n if (j === nth) {\n matched.add(refNode);\n nth += a;\n }\n if (nth < 0 || nth >= l) {\n break;\n } else if (a > 0) {\n j++;\n } else {\n j--;\n }\n }\n if (reverse) {\n refNode = walker.previousSibling();\n } else {\n refNode = walker.nextSibling();\n }\n }\n }\n }\n if (reverse && matched.size > 1) {\n const m = [...matched];\n return new Set(m.reverse());\n }\n } else if (node === this.#root && (a + b) === 1) {\n matched.add(node);\n }\n return matched;\n }\n\n /**\n * match An+B\n * @private\n * @param {object} ast - AST\n * @param {object} node - Element node\n * @param {string} nthName - nth pseudo-class name\n * @param {object} opt - options\n * @returns {Set.} - collection of matched nodes\n */\n _matchAnPlusB(ast, node, nthName, opt) {\n const {\n nth: {\n a,\n b,\n name: nthIdentName\n },\n selector\n } = ast;\n const anbMap = new Map();\n if (nthIdentName) {\n if (nthIdentName === 'even') {\n anbMap.set('a', 2);\n anbMap.set('b', 0);\n } else if (nthIdentName === 'odd') {\n anbMap.set('a', 2);\n anbMap.set('b', 1);\n }\n if (nthName.indexOf('last') > -1) {\n anbMap.set('reverse', true);\n }\n } else {\n if (typeof a === 'string' && /-?\\d+/.test(a)) {\n anbMap.set('a', a * 1);\n } else {\n anbMap.set('a', 0);\n }\n if (typeof b === 'string' && /-?\\d+/.test(b)) {\n anbMap.set('b', b * 1);\n } else {\n anbMap.set('b', 0);\n }\n if (nthName.indexOf('last') > -1) {\n anbMap.set('reverse', true);\n }\n }\n if (/^nth-(?:last-)?child$/.test(nthName)) {\n if (selector) {\n anbMap.set('selector', selector);\n }\n const anb = Object.fromEntries(anbMap);\n const nodes = this._collectNthChild(anb, node, opt);\n return nodes;\n } else if (/^nth-(?:last-)?of-type$/.test(nthName)) {\n const anb = Object.fromEntries(anbMap);\n const nodes = this._collectNthOfType(anb, node);\n return nodes;\n }\n return new Set();\n }\n\n /**\n * match :has() pseudo-class function\n * @private\n * @param {Array.} astLeaves - AST leaves\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {boolean} - result\n */\n _matchHasPseudoFunc(astLeaves, node, opt = {}) {\n let bool;\n if (Array.isArray(astLeaves) && astLeaves.length) {\n const leaves = astLeaves.map(i => i);\n const [leaf] = leaves;\n const { type: leafType } = leaf;\n let combo;\n if (leafType === COMBINATOR) {\n combo = leaves.shift();\n } else {\n combo = {\n name: ' ',\n type: COMBINATOR\n };\n }\n const twigLeaves = [];\n while (leaves.length) {\n const [item] = leaves;\n const { type: itemType } = item;\n if (itemType === COMBINATOR) {\n break;\n } else {\n twigLeaves.push(leaves.shift());\n }\n }\n const twig = {\n combo,\n leaves: twigLeaves\n };\n opt.dir = DIR_NEXT;\n const nodes = this._matchCombinator(twig, node, opt);\n if (nodes.size) {\n if (leaves.length) {\n for (const nextNode of nodes) {\n bool = this._matchHasPseudoFunc(leaves, nextNode, opt);\n if (bool) {\n break;\n }\n }\n } else {\n bool = true;\n }\n }\n }\n return !!bool;\n }\n\n /**\n * match logical pseudo-class functions - :has(), :is(), :not(), :where()\n * @private\n * @param {object} astData - AST data\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {?object} - matched node\n */\n _matchLogicalPseudoFunc(astData, node, opt = {}) {\n const {\n astName = '', branches = [], selector = '', twigBranches = []\n } = astData;\n let res;\n if (astName === 'has') {\n if (selector.includes(':has(')) {\n res = null;\n } else {\n let bool;\n for (const leaves of branches) {\n bool = this._matchHasPseudoFunc(leaves, node, opt);\n if (bool) {\n break;\n }\n }\n if (bool) {\n res = node;\n }\n }\n } else {\n const forgive = /^(?:is|where)$/.test(astName);\n opt.forgive = forgive;\n const l = twigBranches.length;\n let bool;\n for (let i = 0; i < l; i++) {\n const branch = twigBranches[i];\n const lastIndex = branch.length - 1;\n const { leaves } = branch[lastIndex];\n bool = this._matchLeaves(leaves, node, opt);\n if (bool && lastIndex > 0) {\n let nextNodes = new Set([node]);\n for (let j = lastIndex - 1; j >= 0; j--) {\n const twig = branch[j];\n const arr = [];\n opt.dir = DIR_PREV;\n for (const nextNode of nextNodes) {\n const m = this._matchCombinator(twig, nextNode, opt);\n if (m.size) {\n arr.push(...m);\n }\n }\n if (arr.length) {\n if (j === 0) {\n bool = true;\n } else {\n nextNodes = new Set(arr);\n }\n } else {\n bool = false;\n break;\n }\n }\n }\n if (bool) {\n break;\n }\n }\n if (astName === 'not') {\n if (!bool) {\n res = node;\n }\n } else if (bool) {\n res = node;\n }\n }\n return res ?? null;\n }\n\n /**\n * match pseudo-class selector\n * @private\n * @see https://html.spec.whatwg.org/#pseudo-classes\n * @param {object} ast - AST\n * @param {object} node - Element node\n * @param {object} opt - options\n * @param {boolean} [opt.forgive] - forgive unknown pseudo-class\n * @param {boolean} [opt.warn] - warn unsupported pseudo-class\n * @returns {Set.} - collection of matched nodes\n */\n _matchPseudoClassSelector(ast, node, opt = {}) {\n const { children: astChildren, name: astName } = ast;\n const { localName, parentNode } = node;\n const {\n forgive,\n warn = this.#warn\n } = opt;\n const matched = new Set();\n // :has(), :is(), :not(), :where()\n if (REG_LOGICAL_PSEUDO.test(astName)) {\n let astData;\n if (this.#astCache.has(ast)) {\n astData = this.#astCache.get(ast);\n } else {\n const { branches } = walkAST(ast);\n const selectors = [];\n const twigBranches = [];\n for (const [...leaves] of branches) {\n for (const leaf of leaves) {\n const css = generateCSS(leaf);\n selectors.push(css);\n }\n const branch = [];\n const leavesSet = new Set();\n let item = leaves.shift();\n while (item) {\n if (item.type === COMBINATOR) {\n branch.push({\n combo: item,\n leaves: [...leavesSet]\n });\n leavesSet.clear();\n } else if (item) {\n leavesSet.add(item);\n }\n if (leaves.length) {\n item = leaves.shift();\n } else {\n branch.push({\n combo: null,\n leaves: [...leavesSet]\n });\n leavesSet.clear();\n break;\n }\n }\n twigBranches.push(branch);\n }\n astData = {\n astName,\n branches,\n twigBranches,\n selector: selectors.join(',')\n };\n this.#astCache.set(ast, astData);\n }\n const res = this._matchLogicalPseudoFunc(astData, node, opt);\n if (res) {\n matched.add(res);\n }\n } else if (Array.isArray(astChildren)) {\n // :nth-child(), :nth-last-child(), nth-of-type(), :nth-last-of-type()\n if (/^nth-(?:last-)?(?:child|of-type)$/.test(astName)) {\n const [branch] = astChildren;\n const nodes = this._matchAnPlusB(branch, node, astName, opt);\n return nodes;\n } else {\n switch (astName) {\n // :dir(), :lang()\n case 'dir':\n case 'lang': {\n const res = this.#matcher.matchSelector(ast, node, opt, true);\n if (res) {\n matched.add(res);\n }\n break;\n }\n // :state()\n case 'state': {\n if (isCustomElement(node)) {\n const [{ value: stateValue }] = astChildren;\n if (stateValue) {\n if (node[stateValue]) {\n matched.add(node);\n } else {\n for (const i in node) {\n const prop = node[i];\n if (prop instanceof this.#window.ElementInternals) {\n if (prop?.states?.has(stateValue)) {\n matched.add(node);\n }\n break;\n }\n }\n }\n }\n }\n break;\n }\n case 'current':\n case 'nth-col':\n case 'nth-last-col': {\n if (warn) {\n throw new DOMException(`Unsupported pseudo-class :${astName}()`,\n NOT_SUPPORTED_ERR);\n }\n break;\n }\n case 'host':\n case 'host-context': {\n // ignore\n break;\n }\n // dropped from CSS Selectors 3\n case 'contains': {\n if (warn) {\n throw new DOMException(`Unknown pseudo-class :${astName}()`,\n NOT_SUPPORTED_ERR);\n }\n break;\n }\n default: {\n if (!forgive) {\n throw new DOMException(`Unknown pseudo-class :${astName}()`,\n SYNTAX_ERR);\n }\n }\n }\n }\n } else {\n switch (astName) {\n case 'any-link':\n case 'link': {\n if (REG_ANCHOR.test(localName) && node.hasAttribute('href')) {\n matched.add(node);\n }\n break;\n }\n case 'local-link': {\n if (REG_ANCHOR.test(localName) && node.hasAttribute('href')) {\n const { href, origin, pathname } = new URL(this.#document.URL);\n const attrURL = new URL(node.getAttribute('href'), href);\n if (attrURL.origin === origin && attrURL.pathname === pathname) {\n matched.add(node);\n }\n }\n break;\n }\n case 'visited': {\n // prevent fingerprinting\n break;\n }\n case 'hover': {\n const { target, type } = this.#event ?? {};\n if (/^(?:mouse|pointer)(?:down|over|up)$/.test(type) &&\n node.contains(target)) {\n matched.add(node);\n }\n break;\n }\n case 'active': {\n const { buttons, target, type } = this.#event ?? {};\n if (/(?:mouse|pointer)down/.test(type) && buttons & BIT_01 &&\n node.contains(target)) {\n matched.add(node);\n }\n break;\n }\n case 'target': {\n const { hash } = new URL(this.#document.URL);\n if (node.id && hash === `#${node.id}` &&\n this.#document.contains(node)) {\n matched.add(node);\n }\n break;\n }\n case 'target-within': {\n const { hash } = new URL(this.#document.URL);\n if (hash) {\n const id = hash.replace(/^#/, '');\n let current = this.#document.getElementById(id);\n while (current) {\n if (current === node) {\n matched.add(node);\n break;\n }\n current = current.parentNode;\n }\n }\n break;\n }\n case 'scope': {\n if (this.#node.nodeType === ELEMENT_NODE) {\n if (!this.#shadow && node === this.#node) {\n matched.add(node);\n }\n } else if (node === this.#document.documentElement) {\n matched.add(node);\n }\n break;\n }\n case 'focus': {\n if (node === this.#document.activeElement && node.tabIndex >= 0 &&\n isFocusable(node)) {\n matched.add(node);\n }\n break;\n }\n case 'focus-visible': {\n if (node === this.#document.activeElement && node.tabIndex >= 0) {\n let bool;\n if (isFocusVisible(node)) {\n bool = true;\n } else {\n const { target: eventTarget, type } = this.#event ?? {};\n const { target: focusTarget, relatedTarget } = this.#focus ?? {};\n if (/^key(?:down|up)$/.test(type) && node.contains(eventTarget)) {\n bool = true;\n } else if (relatedTarget && isFocusVisible(relatedTarget) &&\n node.contains(focusTarget)) {\n bool = true;\n }\n }\n if (bool && isFocusable(node)) {\n matched.add(node);\n }\n }\n break;\n }\n case 'focus-within': {\n let bool;\n let current = this.#document.activeElement;\n if (current.tabIndex >= 0) {\n while (current) {\n if (current === node) {\n bool = true;\n break;\n }\n current = current.parentNode;\n }\n }\n if (bool && isFocusable(node)) {\n matched.add(node);\n }\n break;\n }\n case 'open': {\n if (REG_INTERACT.test(localName) && node.hasAttribute('open')) {\n matched.add(node);\n }\n break;\n }\n case 'closed': {\n if (REG_INTERACT.test(localName) && !node.hasAttribute('open')) {\n matched.add(node);\n }\n break;\n }\n case 'disabled': {\n if (REG_FORM_CTRL.test(localName) ||\n isCustomElement(node, { formAssociated: true })) {\n if (node.disabled || node.hasAttribute('disabled')) {\n matched.add(node);\n } else if (node.localName === 'option') {\n if (parentNode.localName === 'optgroup' &&\n (parentNode.disabled ||\n parentNode.hasAttribute('disabled'))) {\n matched.add(node);\n }\n } else if (node.localName !== 'optgroup') {\n let bool;\n let parent = parentNode;\n while (parent) {\n if (parent.localName === 'fieldset' &&\n (parent.disabled || parent.hasAttribute('disabled'))) {\n const walker = this.#walker;\n let refNode = traverseNode(parent, walker);\n refNode = walker.firstChild();\n while (refNode) {\n if (refNode.localName === 'legend') {\n break;\n }\n refNode = walker.nextSibling();\n }\n if (refNode) {\n if (!refNode.contains(node)) {\n bool = true;\n }\n } else {\n bool = true;\n }\n break;\n } else if (parent.localName === 'form') {\n break;\n } else if (parent.parentNode?.nodeType === ELEMENT_NODE) {\n if (parent.parentNode.localName === 'form') {\n break;\n } else {\n parent = parent.parentNode;\n }\n } else {\n break;\n }\n }\n if (bool) {\n matched.add(node);\n }\n }\n }\n break;\n }\n case 'enabled': {\n if ((REG_FORM_CTRL.test(localName) ||\n isCustomElement(node, { formAssociated: true })) &&\n !(node.disabled && node.hasAttribute('disabled'))) {\n if (node.localName === 'optgroup') {\n matched.add(node);\n } else if (node.localName === 'option') {\n if (parentNode.localName !== 'optgroup' ||\n !(parentNode.disabled ||\n parentNode.hasAttribute('disabled'))) {\n matched.add(node);\n }\n } else {\n let bool;\n let parent = parentNode;\n while (parent) {\n if (parent.localName === 'fieldset' &&\n (parent.disabled || parent.hasAttribute('disabled'))) {\n const walker = this.#walker;\n let refNode = traverseNode(parent, walker);\n refNode = walker.firstChild();\n while (refNode) {\n if (refNode.localName === 'legend') {\n break;\n }\n refNode = walker.nextSibling();\n }\n if (refNode) {\n if (!refNode.contains(node)) {\n bool = true;\n }\n } else {\n bool = true;\n }\n break;\n } else if (parent.localName === 'form') {\n break;\n } else if (parent.parentNode?.nodeType === ELEMENT_NODE) {\n if (parent.parentNode.localName === 'form') {\n break;\n } else {\n parent = parent.parentNode;\n }\n } else {\n break;\n }\n }\n if (!bool) {\n matched.add(node);\n }\n }\n }\n break;\n }\n case 'read-only': {\n switch (localName) {\n case 'textarea': {\n if (node.readonly || node.hasAttribute('readonly') ||\n node.disabled || node.hasAttribute('disabled')) {\n matched.add(node);\n }\n break;\n }\n case 'input': {\n if ((!node.type || REG_TYPE_INPUT.test(node.type)) &&\n (node.readonly || node.hasAttribute('readonly') ||\n node.disabled || node.hasAttribute('disabled'))) {\n matched.add(node);\n }\n break;\n }\n default: {\n if (!isContentEditable(node)) {\n matched.add(node);\n }\n }\n }\n break;\n }\n case 'read-write': {\n switch (localName) {\n case 'textarea': {\n if (!(node.readonly || node.hasAttribute('readonly') ||\n node.disabled || node.hasAttribute('disabled'))) {\n matched.add(node);\n }\n break;\n }\n case 'input': {\n if ((!node.type || REG_TYPE_INPUT.test(node.type)) &&\n !(node.readonly || node.hasAttribute('readonly') ||\n node.disabled || node.hasAttribute('disabled'))) {\n matched.add(node);\n }\n break;\n }\n default: {\n if (isContentEditable(node)) {\n matched.add(node);\n }\n }\n }\n break;\n }\n case 'placeholder-shown': {\n let placeholder;\n if (node.placeholder) {\n placeholder = node.placeholder;\n } else if (node.hasAttribute('placeholder')) {\n placeholder = node.getAttribute('placeholder');\n }\n if (typeof placeholder === 'string' && !/[\\r\\n]/.test(placeholder)) {\n let targetNode;\n if (localName === 'textarea') {\n targetNode = node;\n } else if (localName === 'input') {\n if (node.hasAttribute('type')) {\n if (REG_TYPE_TEXT.test(node.getAttribute('type'))) {\n targetNode = node;\n }\n } else {\n targetNode = node;\n }\n }\n if (targetNode && node.value === '') {\n matched.add(node);\n }\n }\n break;\n }\n case 'checked': {\n if ((node.checked && localName === 'input' &&\n node.hasAttribute('type') &&\n REG_TYPE_CHECK.test(node.getAttribute('type'))) ||\n (node.selected && localName === 'option')) {\n matched.add(node);\n }\n break;\n }\n case 'indeterminate': {\n if ((node.indeterminate && localName === 'input' &&\n node.type === 'checkbox') ||\n (localName === 'progress' && !node.hasAttribute('value'))) {\n matched.add(node);\n } else if (localName === 'input' && node.type === 'radio' &&\n !node.hasAttribute('checked')) {\n const nodeName = node.name;\n let parent = node.parentNode;\n while (parent) {\n if (parent.localName === 'form') {\n break;\n }\n parent = parent.parentNode;\n }\n if (!parent) {\n parent = this.#document.documentElement;\n }\n const items = parent.getElementsByTagName('input');\n const l = items.length;\n let checked;\n for (let i = 0; i < l; i++) {\n const item = items[i];\n if (item.getAttribute('type') === 'radio') {\n if (nodeName) {\n if (item.getAttribute('name') === nodeName) {\n checked = !!item.checked;\n }\n } else if (!item.hasAttribute('name')) {\n checked = !!item.checked;\n }\n if (checked) {\n break;\n }\n }\n }\n if (!checked) {\n matched.add(node);\n }\n }\n break;\n }\n case 'default': {\n // button[type=\"submit\"], input[type=\"submit\"], input[type=\"image\"]\n if ((localName === 'button' &&\n !(node.hasAttribute('type') &&\n REG_TYPE_RESET.test(node.getAttribute('type')))) ||\n (localName === 'input' && node.hasAttribute('type') &&\n REG_TYPE_SUBMIT.test(node.getAttribute('type')))) {\n let form = node.parentNode;\n while (form) {\n if (form.localName === 'form') {\n break;\n }\n form = form.parentNode;\n }\n if (form) {\n const walker = this.#walker;\n let nextNode = traverseNode(form, walker);\n nextNode = walker.firstChild();\n while (nextNode && form.contains(nextNode)) {\n const nodeName = nextNode.localName;\n let m;\n if (nodeName === 'button') {\n m = !(nextNode.hasAttribute('type') &&\n REG_TYPE_RESET.test(nextNode.getAttribute('type')));\n } else if (nodeName === 'input') {\n m = nextNode.hasAttribute('type') &&\n REG_TYPE_SUBMIT.test(nextNode.getAttribute('type'));\n }\n if (m) {\n if (nextNode === node) {\n matched.add(node);\n }\n break;\n }\n nextNode = walker.nextNode();\n }\n }\n // input[type=\"checkbox\"], input[type=\"radio\"]\n } else if (localName === 'input' && node.hasAttribute('type') &&\n REG_TYPE_CHECK.test(node.getAttribute('type')) &&\n node.hasAttribute('checked')) {\n matched.add(node);\n // option\n } else if (localName === 'option' && node.hasAttribute('selected')) {\n matched.add(node);\n }\n break;\n }\n case 'valid': {\n if (REG_FORM_VALID.test(localName)) {\n if (node.checkValidity()) {\n if (node.maxLength >= 0) {\n if (node.maxLength >= node.value.length) {\n matched.add(node);\n }\n } else {\n matched.add(node);\n }\n }\n } else if (localName === 'fieldset') {\n const walker = this.#walker;\n let refNode = traverseNode(node, walker);\n refNode = walker.firstChild();\n let bool;\n if (!refNode) {\n bool = true;\n } else {\n while (refNode && node.contains(refNode)) {\n if (REG_FORM_VALID.test(refNode.localName)) {\n if (refNode.checkValidity()) {\n if (refNode.maxLength >= 0) {\n bool = refNode.maxLength >= refNode.value.length;\n } else {\n bool = true;\n }\n } else {\n bool = false;\n }\n if (!bool) {\n break;\n }\n }\n refNode = walker.nextNode();\n }\n }\n if (bool) {\n matched.add(node);\n }\n }\n break;\n }\n case 'invalid': {\n if (REG_FORM_VALID.test(localName)) {\n if (node.checkValidity()) {\n if (node.maxLength >= 0 && node.maxLength < node.value.length) {\n matched.add(node);\n }\n } else {\n matched.add(node);\n }\n } else if (localName === 'fieldset') {\n const walker = this.#walker;\n let refNode = traverseNode(node, walker);\n refNode = walker.firstChild();\n let bool;\n if (!refNode) {\n bool = true;\n } else {\n while (refNode && node.contains(refNode)) {\n if (REG_FORM_VALID.test(refNode.localName)) {\n if (refNode.checkValidity()) {\n if (refNode.maxLength >= 0) {\n bool = refNode.maxLength >= refNode.value.length;\n } else {\n bool = true;\n }\n } else {\n bool = false;\n }\n if (!bool) {\n break;\n }\n }\n refNode = walker.nextNode();\n }\n }\n if (!bool) {\n matched.add(node);\n }\n }\n break;\n }\n case 'in-range': {\n if (localName === 'input' &&\n !(node.readonly || node.hasAttribute('readonly')) &&\n !(node.disabled || node.hasAttribute('disabled')) &&\n node.hasAttribute('type') &&\n REG_TYPE_RANGE.test(node.getAttribute('type')) &&\n !(node.validity.rangeUnderflow ||\n node.validity.rangeOverflow) &&\n (node.hasAttribute('min') || node.hasAttribute('max') ||\n node.getAttribute('type') === 'range')) {\n matched.add(node);\n }\n break;\n }\n case 'out-of-range': {\n if (localName === 'input' &&\n !(node.readonly || node.hasAttribute('readonly')) &&\n !(node.disabled || node.hasAttribute('disabled')) &&\n node.hasAttribute('type') &&\n REG_TYPE_RANGE.test(node.getAttribute('type')) &&\n (node.validity.rangeUnderflow || node.validity.rangeOverflow)) {\n matched.add(node);\n }\n break;\n }\n case 'required': {\n let targetNode;\n if (/^(?:select|textarea)$/.test(localName)) {\n targetNode = node;\n } else if (localName === 'input') {\n if (node.hasAttribute('type')) {\n const inputType = node.getAttribute('type');\n if (inputType === 'file' || REG_TYPE_CHECK.test(inputType) ||\n REG_TYPE_INPUT.test(inputType)) {\n targetNode = node;\n }\n } else {\n targetNode = node;\n }\n }\n if (targetNode &&\n (node.required || node.hasAttribute('required'))) {\n matched.add(node);\n }\n break;\n }\n case 'optional': {\n let targetNode;\n if (/^(?:select|textarea)$/.test(localName)) {\n targetNode = node;\n } else if (localName === 'input') {\n if (node.hasAttribute('type')) {\n const inputType = node.getAttribute('type');\n if (inputType === 'file' || REG_TYPE_CHECK.test(inputType) ||\n REG_TYPE_INPUT.test(inputType)) {\n targetNode = node;\n }\n } else {\n targetNode = node;\n }\n }\n if (targetNode &&\n !(node.required || node.hasAttribute('required'))) {\n matched.add(node);\n }\n break;\n }\n case 'root': {\n if (node === this.#document.documentElement) {\n matched.add(node);\n }\n break;\n }\n case 'empty': {\n if (node.hasChildNodes()) {\n const walker = this.#document.createTreeWalker(node, SHOW_ALL);\n let refNode = walker.firstChild();\n let bool;\n while (refNode) {\n bool = refNode.nodeType !== ELEMENT_NODE &&\n refNode.nodeType !== TEXT_NODE;\n if (!bool) {\n break;\n }\n refNode = walker.nextSibling();\n }\n if (bool) {\n matched.add(node);\n }\n } else {\n matched.add(node);\n }\n break;\n }\n case 'first-child': {\n if ((parentNode && node === parentNode.firstElementChild) ||\n node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'last-child': {\n if ((parentNode && node === parentNode.lastElementChild) ||\n node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'only-child': {\n if ((parentNode && node === parentNode.firstElementChild &&\n node === parentNode.lastElementChild) || node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'first-of-type': {\n if (parentNode) {\n const [node1] = this._collectNthOfType({\n a: 0,\n b: 1\n }, node);\n if (node1) {\n matched.add(node1);\n }\n } else if (node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'last-of-type': {\n if (parentNode) {\n const [node1] = this._collectNthOfType({\n a: 0,\n b: 1,\n reverse: true\n }, node);\n if (node1) {\n matched.add(node1);\n }\n } else if (node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'only-of-type': {\n if (parentNode) {\n const [node1] = this._collectNthOfType({\n a: 0,\n b: 1\n }, node);\n if (node1 === node) {\n const [node2] = this._collectNthOfType({\n a: 0,\n b: 1,\n reverse: true\n }, node);\n if (node2 === node) {\n matched.add(node);\n }\n }\n } else if (node === this.#root) {\n matched.add(node);\n }\n break;\n }\n case 'defined': {\n if (node.hasAttribute('is') || localName.includes('-')) {\n if (isCustomElement(node)) {\n matched.add(node);\n }\n // NOTE: MathMLElement not implemented in jsdom\n } else if (node instanceof this.#window.HTMLElement ||\n node instanceof this.#window.SVGElement) {\n matched.add(node);\n }\n break;\n }\n case 'popover-open': {\n if (node.popover) {\n const { display } = this.#window.getComputedStyle(node);\n if (display !== 'none') {\n matched.add(node);\n }\n }\n break;\n }\n case 'host':\n case 'host-context': {\n // ignore\n break;\n }\n // legacy pseudo-elements\n case 'after':\n case 'before':\n case 'first-letter':\n case 'first-line': {\n if (warn) {\n throw new DOMException(`Unsupported pseudo-element ::${astName}`,\n NOT_SUPPORTED_ERR);\n }\n break;\n }\n // not supported\n case 'autofill':\n case 'blank':\n case 'buffering':\n case 'current':\n case 'fullscreen':\n case 'future':\n case 'modal':\n case 'muted':\n case 'past':\n case 'paused':\n case 'picture-in-picture':\n case 'playing':\n case 'seeking':\n case 'stalled':\n case 'user-invalid':\n case 'user-valid':\n case 'volume-locked':\n case '-webkit-autofill': {\n if (warn) {\n throw new DOMException(`Unsupported pseudo-class :${astName}`,\n NOT_SUPPORTED_ERR);\n }\n break;\n }\n default: {\n if (astName.startsWith('-webkit-')) {\n if (warn) {\n throw new DOMException(`Unsupported pseudo-class :${astName}`,\n NOT_SUPPORTED_ERR);\n }\n } else if (!forgive) {\n throw new DOMException(`Unknown pseudo-class :${astName}`,\n SYNTAX_ERR);\n }\n }\n }\n }\n return matched;\n }\n\n /**\n * match shadow host pseudo class\n * @private\n * @param {object} ast - AST\n * @param {object} node - DocumentFragment node\n * @returns {?object} - matched node\n */\n _matchShadowHostPseudoClass(ast, node) {\n const { children: astChildren, name: astName } = ast;\n let res;\n if (Array.isArray(astChildren)) {\n const { branches } = walkAST(astChildren[0]);\n const [branch] = branches;\n const [...leaves] = branch;\n const { host } = node;\n if (astName === 'host') {\n let bool;\n for (const leaf of leaves) {\n const { type: leafType } = leaf;\n if (leafType === COMBINATOR) {\n const css = generateCSS(ast);\n throw new DOMException(`Invalid selector ${css}`, SYNTAX_ERR);\n }\n bool = this._matchSelector(leaf, host).has(host);\n if (!bool) {\n break;\n }\n }\n if (bool) {\n res = node;\n }\n } else if (astName === 'host-context') {\n let parent = host;\n let bool;\n while (parent) {\n for (const leaf of leaves) {\n const { type: leafType } = leaf;\n if (leafType === COMBINATOR) {\n const css = generateCSS(ast);\n throw new DOMException(`Invalid selector ${css}`, SYNTAX_ERR);\n }\n bool = this._matchSelector(leaf, parent).has(parent);\n if (!bool) {\n break;\n }\n }\n if (bool) {\n break;\n } else {\n parent = parent.parentNode;\n }\n }\n if (bool) {\n res = node;\n }\n }\n } else if (astName === 'host') {\n res = node;\n } else {\n throw new DOMException(`Invalid selector :${astName}`, SYNTAX_ERR);\n }\n return res ?? null;\n }\n\n /**\n * match selector\n * @private\n * @param {object} ast - AST\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} [opt] - options\n * @returns {Set.} - collection of matched nodes\n */\n _matchSelector(ast, node, opt) {\n const { type: astType } = ast;\n const matched = new Set();\n if (ast.name === EMPTY) {\n return matched;\n }\n const astName = unescapeSelector(ast.name);\n if (typeof astName === 'string' && astName !== ast.name) {\n ast.name = astName;\n }\n if (node.nodeType === ELEMENT_NODE) {\n switch (astType) {\n case SELECTOR_PSEUDO_ELEMENT: {\n this.#matcher.matchPseudoElementSelector(astName, opt);\n break;\n }\n case SELECTOR_ID: {\n if (node.id === astName) {\n matched.add(node);\n }\n break;\n }\n case SELECTOR_CLASS: {\n if (node.classList.contains(astName)) {\n matched.add(node);\n }\n break;\n }\n case SELECTOR_PSEUDO_CLASS: {\n const nodes = this._matchPseudoClassSelector(ast, node, opt);\n return nodes;\n }\n default: {\n const res = this.#matcher.matchSelector(ast, node, opt, true);\n if (res) {\n matched.add(res);\n }\n }\n }\n } else if (this.#shadow && astType === SELECTOR_PSEUDO_CLASS &&\n node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n if (astName !== 'has' && REG_LOGICAL_PSEUDO.test(astName)) {\n const nodes = this._matchPseudoClassSelector(ast, node, opt);\n return nodes;\n } else if (REG_SHADOW_HOST.test(astName)) {\n const res = this._matchShadowHostPseudoClass(ast, node, opt);\n if (res) {\n matched.add(res);\n }\n }\n }\n return matched;\n }\n\n /**\n * match leaves\n * @private\n * @param {Array.} leaves - AST leaves\n * @param {object} node - node\n * @param {object} opt - options\n * @returns {boolean} - result\n */\n _matchLeaves(leaves, node, opt) {\n let bool;\n let result;\n if (this.#invalidate) {\n result = this.#invalidateResults.get(leaves);\n } else {\n result = this.#results.get(leaves);\n }\n if (result && result.has(node)) {\n const { matched } = result.get(node);\n bool = matched;\n }\n if (typeof bool !== 'boolean') {\n let cacheable = true;\n if (node.nodeType === ELEMENT_NODE && REG_FORM.test(node.localName)) {\n cacheable = false;\n }\n for (const leaf of leaves) {\n switch (leaf.type) {\n case SELECTOR_ATTR:\n case SELECTOR_ID: {\n cacheable = false;\n break;\n }\n case SELECTOR_PSEUDO_CLASS: {\n if (/^(?:(?:any-)?link|defined|dir)$/.test(leaf.name)) {\n cacheable = false;\n }\n break;\n }\n default:\n }\n bool = this._matchSelector(leaf, node, opt).has(node);\n if (!bool) {\n break;\n }\n }\n if (cacheable) {\n if (!result) {\n result = new WeakMap();\n }\n result.set(node, {\n matched: bool\n });\n if (this.#invalidate) {\n this.#invalidateResults.set(leaves, result);\n } else {\n this.#results.set(leaves, result);\n }\n }\n }\n return !!bool;\n }\n\n /**\n * match HTML collection\n * @private\n * @param {object} items - HTML collection\n * @param {object} opt - options\n * @returns {Set.} - matched nodes\n */\n _matchHTMLCollection(items, opt = {}) {\n const { compound, filterLeaves } = opt;\n const nodes = new Set();\n const l = items.length;\n if (l) {\n if (compound) {\n for (let i = 0; i < l; i++) {\n const item = items[i];\n const bool = this._matchLeaves(filterLeaves, item, opt);\n if (bool) {\n nodes.add(item);\n }\n }\n } else {\n const arr = [].slice.call(items);\n return new Set(arr);\n }\n }\n return nodes;\n }\n\n /**\n * find descendant nodes\n * @private\n * @param {Array.} leaves - AST leaves\n * @param {object} baseNode - base Element node\n * @param {object} opt - options\n * @returns {object} - collection of nodes and pending state\n */\n _findDescendantNodes(leaves, baseNode, opt) {\n const [leaf, ...filterLeaves] = leaves;\n const compound = filterLeaves.length > 0;\n const { type: leafType } = leaf;\n const leafName = unescapeSelector(leaf.name);\n if (typeof leafName === 'string' && leafName !== leaf.name) {\n leaf.name = leafName;\n }\n let nodes = new Set();\n let pending = false;\n if (this.#shadow) {\n pending = true;\n } else {\n switch (leafType) {\n case SELECTOR_PSEUDO_ELEMENT: {\n this.#matcher.matchPseudoElementSelector(leafName, opt);\n break;\n }\n case SELECTOR_ID: {\n if (this.#root.nodeType === ELEMENT_NODE) {\n pending = true;\n } else {\n const node = this.#root.getElementById(leafName);\n if (node && node !== baseNode && baseNode.contains(node)) {\n if (compound) {\n const bool = this._matchLeaves(filterLeaves, node, opt);\n if (bool) {\n nodes.add(node);\n }\n } else {\n nodes.add(node);\n }\n }\n }\n break;\n }\n case SELECTOR_CLASS: {\n const items = baseNode.getElementsByClassName(leafName);\n nodes = this._matchHTMLCollection(items, {\n compound,\n filterLeaves\n });\n break;\n }\n case SELECTOR_TYPE: {\n if (this.#document.contentType === 'text/html' &&\n !/[*|]/.test(leafName)) {\n const items = baseNode.getElementsByTagName(leafName);\n nodes = this._matchHTMLCollection(items, {\n compound,\n filterLeaves\n });\n } else {\n pending = true;\n }\n break;\n }\n default: {\n pending = true;\n }\n }\n }\n return {\n nodes,\n pending\n };\n }\n\n /**\n * match combinator\n * @private\n * @param {object} twig - twig\n * @param {object} node - Element node\n * @param {object} opt - option\n * @returns {Set.} - collection of matched nodes\n */\n _matchCombinator(twig, node, opt = {}) {\n const { combo, leaves } = twig;\n const { name: comboName } = combo;\n const { parentNode } = node;\n const { dir } = opt;\n const matched = new Set();\n if (dir === DIR_NEXT) {\n switch (comboName) {\n case '+': {\n const refNode = node.nextElementSibling;\n if (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n }\n break;\n }\n case '~': {\n if (parentNode) {\n const walker = this._createTreeWalker(parentNode);\n let refNode = traverseNode(node, walker);\n refNode = walker.nextSibling();\n while (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n refNode = walker.nextSibling();\n }\n }\n break;\n }\n case '>': {\n const walker = this._createTreeWalker(node);\n let refNode = traverseNode(node, walker);\n refNode = walker.firstChild();\n while (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n refNode = walker.nextSibling();\n }\n break;\n }\n case ' ':\n default: {\n const { nodes, pending } = this._findDescendantNodes(leaves, node);\n if (nodes.size) {\n return nodes;\n }\n if (pending) {\n const walker = this._createTreeWalker(node);\n let refNode = traverseNode(node, walker);\n refNode = walker.nextNode();\n while (refNode && node.contains(refNode)) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n refNode = walker.nextNode();\n }\n }\n }\n }\n } else {\n switch (comboName) {\n case '+': {\n const refNode = node.previousElementSibling;\n if (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n }\n break;\n }\n case '~': {\n if (parentNode) {\n const walker = this._createTreeWalker(parentNode);\n let refNode = traverseNode(parentNode, walker);\n refNode = walker.firstChild();\n while (refNode) {\n if (refNode === node) {\n break;\n } else {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n matched.add(refNode);\n }\n }\n refNode = walker.nextSibling();\n }\n }\n break;\n }\n case '>': {\n if (parentNode) {\n const bool = this._matchLeaves(leaves, parentNode, opt);\n if (bool) {\n matched.add(parentNode);\n }\n }\n break;\n }\n case ' ':\n default: {\n const arr = [];\n let refNode = parentNode;\n while (refNode) {\n const bool = this._matchLeaves(leaves, refNode, opt);\n if (bool) {\n arr.push(refNode);\n }\n refNode = refNode.parentNode;\n }\n if (arr.length) {\n return new Set(arr.reverse());\n }\n }\n }\n }\n return matched;\n }\n\n /**\n * find matched node from #qswalker\n * @private\n * @param {Array.} leaves - AST leaves\n * @param {object} [opt] - options\n * @param {object} [opt.node] - node to start from\n * @returns {?object} - matched node\n */\n _findNode(leaves, opt) {\n const { node } = opt;\n const walker = this.#qswalker;\n let refNode = traverseNode(node, walker);\n let matchedNode;\n if (refNode) {\n if (refNode.nodeType !== ELEMENT_NODE) {\n refNode = walker.nextNode();\n } else if (refNode === node) {\n if (refNode !== this.#root) {\n refNode = walker.nextNode();\n }\n }\n while (refNode) {\n const matched = this._matchLeaves(leaves, refNode, {\n warn: this.#warn\n });\n if (matched) {\n matchedNode = refNode;\n break;\n }\n refNode = walker.nextNode();\n }\n }\n return matchedNode ?? null;\n }\n\n /**\n * match self\n * @private\n * @param {Array} leaves - AST leaves\n * @returns {Array} - [nodes, filtered]\n */\n _matchSelf(leaves) {\n const nodes = [];\n const bool = this._matchLeaves(leaves, this.#node, {\n warn: this.#warn\n });\n let filtered = false;\n if (bool) {\n nodes.push(this.#node);\n filtered = true;\n }\n return [nodes, filtered];\n }\n\n /**\n * find lineal\n * @private\n * @param {Array} leaves - AST leaves\n * @param {object} opt - options\n * @returns {Array} - [nodes, filtered]\n */\n _findLineal(leaves, opt = {}) {\n const { complex } = opt;\n const nodes = [];\n let bool = this._matchLeaves(leaves, this.#node, {\n warn: this.#warn\n });\n let filtered = false;\n if (bool) {\n nodes.push(this.#node);\n filtered = true;\n }\n if (!bool || complex) {\n let refNode = this.#node.parentNode;\n while (refNode) {\n bool = this._matchLeaves(leaves, refNode, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(refNode);\n filtered = true;\n }\n if (refNode.parentNode) {\n refNode = refNode.parentNode;\n } else {\n break;\n }\n }\n }\n return [nodes, filtered];\n }\n\n /**\n * find first\n * @private\n * @param {Array} leaves - AST leaves\n * @returns {Array} - [nodes, filtered]\n */\n _findFirst(leaves) {\n const nodes = [];\n const node = this._findNode(leaves, {\n node: this.#node\n });\n let filtered = false;\n if (node) {\n nodes.push(node);\n filtered = true;\n }\n return [nodes, filtered];\n }\n\n /**\n * find from HTML collection\n * @private\n * @param {object} items - HTML collection\n * @param {object} opt - options\n * @param {boolean} [opt.compound] - compound selector\n * @param {Array} [opt.filterLeaves] - filter leaves\n * @returns {Array} - [nodes, filtered]\n */\n _findFromHTMLCollection(items, opt = {}) {\n const { complex, compound, filterLeaves, targetType } = opt;\n let nodes = [];\n let filtered = false;\n let collected = false;\n const l = items.length;\n if (l) {\n if (this.#node.nodeType === ELEMENT_NODE) {\n for (let i = 0; i < l; i++) {\n const node = items[i];\n if (node !== this.#node &&\n (this.#node.contains(node) || node.contains(this.#node))) {\n if (compound) {\n const bool = this._matchLeaves(filterLeaves, node, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(node);\n filtered = true;\n if (targetType === TARGET_FIRST) {\n break;\n }\n }\n } else {\n nodes.push(node);\n filtered = true;\n if (targetType === TARGET_FIRST) {\n break;\n }\n }\n }\n }\n } else if (complex) {\n if (compound) {\n for (let i = 0; i < l; i++) {\n const node = items[i];\n const bool = this._matchLeaves(filterLeaves, node, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(node);\n filtered = true;\n if (targetType === TARGET_FIRST) {\n break;\n }\n }\n }\n } else {\n nodes = [].slice.call(items);\n filtered = true;\n collected = true;\n }\n } else if (compound) {\n for (let i = 0; i < l; i++) {\n const node = items[i];\n const bool = this._matchLeaves(filterLeaves, node, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(node);\n filtered = true;\n if (targetType === TARGET_FIRST) {\n break;\n }\n }\n }\n } else {\n nodes = [].slice.call(items);\n filtered = true;\n collected = true;\n }\n }\n return [nodes, filtered, collected];\n }\n\n /**\n * find entry nodes\n * @private\n * @param {object} twig - twig\n * @param {string} targetType - target type\n * @param {boolean} complex - complex selector\n * @returns {object} - collection of nodes etc.\n */\n _findEntryNodes(twig, targetType, complex) {\n const { leaves } = twig;\n const [leaf, ...filterLeaves] = leaves;\n const compound = filterLeaves.length > 0;\n const { name: leafName, type: leafType } = leaf;\n let nodes = [];\n let collected = false;\n let filtered = false;\n let pending = false;\n switch (leafType) {\n case SELECTOR_PSEUDO_ELEMENT: {\n this.#matcher.matchPseudoElementSelector(leafName, {\n warn: this.#warn\n });\n break;\n }\n case SELECTOR_ID: {\n if (targetType === TARGET_SELF) {\n [nodes, filtered] = this._matchSelf(leaves);\n } else if (targetType === TARGET_LINEAL) {\n [nodes, filtered] = this._findLineal(leaves, {\n complex\n });\n } else if (targetType === TARGET_FIRST &&\n this.#root.nodeType !== ELEMENT_NODE) {\n const node = this.#root.getElementById(leafName);\n if (node) {\n if (compound) {\n const bool = this._matchLeaves(filterLeaves, node, {\n warn: this.#warn\n });\n if (bool) {\n nodes.push(node);\n filtered = true;\n }\n } else {\n nodes.push(node);\n filtered = true;\n }\n }\n } else if (targetType === TARGET_FIRST) {\n [nodes, filtered] = this._findFirst(leaves);\n } else {\n pending = true;\n }\n break;\n }\n case SELECTOR_CLASS: {\n if (targetType === TARGET_SELF) {\n [nodes, filtered] = this._matchSelf(leaves);\n } else if (targetType === TARGET_LINEAL) {\n [nodes, filtered] = this._findLineal(leaves, {\n complex\n });\n } else if (this.#root.nodeType === DOCUMENT_NODE) {\n const items = this.#root.getElementsByClassName(leafName);\n if (items.length) {\n [nodes, filtered, collected] = this._findFromHTMLCollection(items, {\n complex,\n compound,\n filterLeaves,\n targetType\n });\n }\n } else if (targetType === TARGET_FIRST) {\n [nodes, filtered] = this._findFirst(leaves);\n } else {\n pending = true;\n }\n break;\n }\n case SELECTOR_TYPE: {\n if (targetType === TARGET_SELF) {\n [nodes, filtered] = this._matchSelf(leaves);\n } else if (targetType === TARGET_LINEAL) {\n [nodes, filtered] = this._findLineal(leaves, {\n complex\n });\n } else if (this.#document.contentType === 'text/html' &&\n this.#root.nodeType === DOCUMENT_NODE &&\n !/[*|]/.test(leafName)) {\n const items = this.#root.getElementsByTagName(leafName);\n if (items.length) {\n [nodes, filtered, collected] = this._findFromHTMLCollection(items, {\n complex,\n compound,\n filterLeaves,\n targetType\n });\n }\n } else if (targetType === TARGET_FIRST) {\n [nodes, filtered] = this._findFirst(leaves);\n } else {\n pending = true;\n }\n break;\n }\n default: {\n if (targetType !== TARGET_LINEAL && REG_SHADOW_HOST.test(leafName)) {\n if (this.#shadow &&\n this.#node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n const node = this._matchShadowHostPseudoClass(leaf, this.#node);\n if (node) {\n nodes.push(node);\n filtered = true;\n }\n }\n } else if (targetType === TARGET_SELF) {\n [nodes, filtered] = this._matchSelf(leaves);\n } else if (targetType === TARGET_LINEAL) {\n [nodes, filtered] = this._findLineal(leaves, {\n complex\n });\n } else if (targetType === TARGET_FIRST) {\n [nodes, filtered] = this._findFirst(leaves);\n } else {\n pending = true;\n }\n }\n }\n return {\n collected,\n compound,\n filtered,\n nodes,\n pending\n };\n }\n\n /**\n * collect nodes\n * @private\n * @param {string} targetType - target type\n * @returns {Array.>} - #ast and #nodes\n */\n _collectNodes(targetType) {\n const ast = this.#ast.values();\n if (targetType === TARGET_ALL || targetType === TARGET_FIRST) {\n const pendingItems = new Set();\n let i = 0;\n for (const { branch } of ast) {\n const branchLen = branch.length;\n const complex = branchLen > 1;\n const firstTwig = branch[0];\n let dir;\n let twig;\n if (complex) {\n const {\n combo: firstCombo,\n leaves: [{\n name: firstName,\n type: firstType\n }]\n } = firstTwig;\n const lastTwig = branch[branchLen - 1];\n const {\n leaves: [{\n name: lastName,\n type: lastType\n }]\n } = lastTwig;\n if (lastType === SELECTOR_PSEUDO_ELEMENT ||\n lastType === SELECTOR_ID) {\n dir = DIR_PREV;\n twig = lastTwig;\n } else if (firstType === SELECTOR_PSEUDO_ELEMENT ||\n firstType === SELECTOR_ID) {\n dir = DIR_NEXT;\n twig = firstTwig;\n } else if (targetType === TARGET_ALL) {\n if (firstName === '*' && firstType === SELECTOR_TYPE) {\n dir = DIR_PREV;\n twig = lastTwig;\n } else if (lastName === '*' && lastType === SELECTOR_TYPE) {\n dir = DIR_NEXT;\n twig = firstTwig;\n } else if (branchLen === 2) {\n const { name: comboName } = firstCombo;\n if (/^[+~]$/.test(comboName)) {\n dir = DIR_PREV;\n twig = lastTwig;\n } else {\n dir = DIR_NEXT;\n twig = firstTwig;\n }\n } else {\n dir = DIR_NEXT;\n twig = firstTwig;\n }\n } else if (lastName === '*' && lastType === SELECTOR_TYPE) {\n dir = DIR_NEXT;\n twig = firstTwig;\n } else if (firstName === '*' && firstType === SELECTOR_TYPE) {\n dir = DIR_PREV;\n twig = lastTwig;\n } else {\n let bool;\n for (const { combo, leaves: [leaf] } of branch) {\n const { name: leafName, type: leafType } = leaf;\n if (leafType === SELECTOR_PSEUDO_CLASS && leafName === 'dir') {\n bool = false;\n break;\n }\n if (!bool && combo) {\n const { name: comboName } = combo;\n if (/^[+~]$/.test(comboName)) {\n bool = true;\n }\n }\n }\n if (bool) {\n dir = DIR_NEXT;\n twig = firstTwig;\n } else {\n dir = DIR_PREV;\n twig = lastTwig;\n }\n }\n } else {\n dir = DIR_PREV;\n twig = firstTwig;\n }\n const {\n collected, compound, filtered, nodes, pending\n } = this._findEntryNodes(twig, targetType, complex);\n if (nodes.length) {\n this.#ast[i].find = true;\n this.#nodes[i] = nodes;\n } else if (pending) {\n pendingItems.add(new Map([\n ['index', i],\n ['twig', twig]\n ]));\n }\n this.#ast[i].collected = collected;\n this.#ast[i].dir = dir;\n this.#ast[i].filtered = filtered || !compound;\n i++;\n }\n if (pendingItems.size) {\n let node;\n let walker;\n if (this.#node !== this.#root && this.#node.nodeType === ELEMENT_NODE) {\n node = this.#node;\n walker = this.#qswalker;\n } else {\n node = this.#root;\n walker = this.#walker;\n }\n let nextNode = traverseNode(node, walker);\n while (nextNode) {\n let bool = false;\n if (this.#node.nodeType === ELEMENT_NODE) {\n if (nextNode === this.#node) {\n bool = true;\n } else {\n bool = this.#node.contains(nextNode);\n }\n } else {\n bool = true;\n }\n if (bool) {\n for (const pendingItem of pendingItems) {\n const { leaves } = pendingItem.get('twig');\n const matched = this._matchLeaves(leaves, nextNode, {\n warn: this.#warn\n });\n if (matched) {\n const index = pendingItem.get('index');\n this.#ast[index].filtered = true;\n this.#ast[index].find = true;\n this.#nodes[index].push(nextNode);\n }\n }\n }\n if (nextNode !== walker.currentNode) {\n nextNode = traverseNode(nextNode, walker);\n }\n nextNode = walker.nextNode();\n }\n }\n } else {\n let i = 0;\n for (const { branch } of ast) {\n const twig = branch[branch.length - 1];\n const complex = branch.length > 1;\n const {\n compound, filtered, nodes\n } = this._findEntryNodes(twig, targetType, complex);\n if (nodes.length) {\n this.#ast[i].find = true;\n this.#nodes[i] = nodes;\n }\n this.#ast[i].dir = DIR_PREV;\n this.#ast[i].filtered = filtered || !compound;\n i++;\n }\n }\n return [\n this.#ast,\n this.#nodes\n ];\n }\n\n /**\n * get combined nodes\n * @private\n * @param {object} twig - twig\n * @param {object} nodes - collection of nodes\n * @param {string} dir - direction\n * @returns {Array.} - collection of matched nodes\n */\n _getCombinedNodes(twig, nodes, dir) {\n const arr = [];\n for (const node of nodes) {\n const matched = this._matchCombinator(twig, node, {\n dir,\n warn: this.#warn\n });\n if (matched.size) {\n arr.push(...matched);\n }\n }\n if (arr.length) {\n return new Set(arr);\n }\n return new Set();\n }\n\n /**\n * match node to next direction\n * @private\n * @param {Array} branch - branch\n * @param {Set.} nodes - collection of Element node\n * @param {object} opt - option\n * @param {object} opt.combo - combo\n * @returns {?object} - matched node\n */\n _matchNodeNext(branch, nodes, opt) {\n const { combo, index } = opt;\n const { combo: nextCombo, leaves } = branch[index];\n const twig = {\n combo,\n leaves\n };\n const nextNodes = this._getCombinedNodes(twig, nodes, DIR_NEXT);\n let res;\n if (nextNodes.size) {\n if (index === branch.length - 1) {\n const [nextNode] = sortNodes(nextNodes);\n res = nextNode;\n } else {\n res = this._matchNodeNext(branch, nextNodes, {\n combo: nextCombo,\n index: index + 1\n });\n }\n }\n return res ?? null;\n }\n\n /**\n * match node to previous direction\n * @private\n * @param {Array} branch - branch\n * @param {object} node - Element node\n * @param {object} opt - option\n * @param {number} opt.index - index\n * @returns {?object} - node\n */\n _matchNodePrev(branch, node, opt) {\n const { index } = opt;\n const twig = branch[index];\n const nodes = new Set([node]);\n const nextNodes = this._getCombinedNodes(twig, nodes, DIR_PREV);\n let res;\n if (nextNodes.size) {\n if (index === 0) {\n res = node;\n } else {\n for (const nextNode of nextNodes) {\n const matched = this._matchNodePrev(branch, nextNode, {\n index: index - 1\n });\n if (matched) {\n return node;\n }\n }\n }\n }\n return res ?? null;\n }\n\n /**\n * find matched nodes\n * @param {string} targetType - target type\n * @returns {Set.} - collection of matched nodes\n */\n find(targetType) {\n if (targetType === TARGET_ALL || targetType === TARGET_FIRST) {\n this._prepareQuerySelectorWalker();\n }\n const [[...branches], collectedNodes] = this._collectNodes(targetType);\n const l = branches.length;\n let sort;\n let nodes = new Set();\n for (let i = 0; i < l; i++) {\n const { branch, collected, dir, find } = branches[i];\n const branchLen = branch.length;\n if (branchLen && find) {\n const entryNodes = collectedNodes[i];\n const entryNodesLen = entryNodes.length;\n const lastIndex = branchLen - 1;\n if (lastIndex === 0) {\n if ((targetType === TARGET_ALL || targetType === TARGET_FIRST) &&\n this.#node.nodeType === ELEMENT_NODE) {\n for (let j = 0; j < entryNodesLen; j++) {\n const node = entryNodes[j];\n if (node !== this.#node && this.#node.contains(node)) {\n nodes.add(node);\n if (targetType !== TARGET_ALL) {\n break;\n }\n }\n }\n } else if (targetType === TARGET_ALL) {\n if (nodes.size) {\n const n = [...nodes];\n nodes = new Set([...n, ...entryNodes]);\n sort = true;\n } else {\n nodes = new Set(entryNodes);\n }\n } else {\n const [node] = entryNodes;\n nodes.add(node);\n }\n } else if (targetType === TARGET_ALL) {\n if (dir === DIR_NEXT) {\n let { combo } = branch[0];\n for (const node of entryNodes) {\n let nextNodes = new Set([node]);\n for (let j = 1; j < branchLen; j++) {\n const { combo: nextCombo, leaves } = branch[j];\n const twig = {\n combo,\n leaves\n };\n nextNodes = this._getCombinedNodes(twig, nextNodes, dir);\n if (nextNodes.size) {\n if (j === lastIndex) {\n if (nodes.size) {\n const n = [...nodes];\n nodes = new Set([...n, ...nextNodes]);\n sort = true;\n } else {\n nodes = nextNodes;\n }\n } else {\n combo = nextCombo;\n }\n } else {\n break;\n }\n }\n }\n } else {\n for (const node of entryNodes) {\n let nextNodes = new Set([node]);\n for (let j = lastIndex - 1; j >= 0; j--) {\n const twig = branch[j];\n nextNodes = this._getCombinedNodes(twig, nextNodes, dir);\n if (nextNodes.size) {\n if (j === 0) {\n nodes.add(node);\n if (branchLen > 1 && nodes.size > 1) {\n sort = true;\n }\n }\n } else {\n break;\n }\n }\n }\n }\n } else if (targetType === TARGET_FIRST && dir === DIR_NEXT) {\n const { combo: entryCombo } = branch[0];\n let matched;\n for (const node of entryNodes) {\n matched = this._matchNodeNext(branch, new Set([node]), {\n combo: entryCombo,\n index: 1\n });\n if (matched) {\n nodes.add(matched);\n break;\n }\n }\n if (!matched && !collected) {\n const { leaves: entryLeaves } = branch[0];\n const [entryNode] = entryNodes;\n let refNode = this._findNode(entryLeaves, {\n node: entryNode\n });\n while (refNode) {\n matched = this._matchNodeNext(branch, new Set([refNode]), {\n combo: entryCombo,\n index: 1\n });\n if (matched) {\n nodes.add(matched);\n break;\n }\n refNode = this._findNode(entryLeaves, {\n node: refNode\n });\n }\n }\n } else {\n let matched;\n for (const node of entryNodes) {\n matched = this._matchNodePrev(branch, node, {\n index: lastIndex - 1\n });\n if (matched) {\n nodes.add(node);\n break;\n }\n }\n if (!matched && !collected && targetType === TARGET_FIRST) {\n const { leaves: entryLeaves } = branch[lastIndex];\n const [entryNode] = entryNodes;\n let refNode = this._findNode(entryLeaves, {\n node: entryNode\n });\n while (refNode) {\n matched = this._matchNodePrev(branch, refNode, {\n index: lastIndex - 1\n });\n if (matched) {\n nodes.add(refNode);\n break;\n }\n refNode = this._findNode(entryLeaves, {\n node: refNode\n });\n }\n }\n }\n }\n }\n if (targetType === TARGET_FIRST) {\n nodes.delete(this.#node);\n if (nodes.size > 1) {\n nodes = new Set(sortNodes(nodes));\n }\n } else if (targetType === TARGET_ALL) {\n nodes.delete(this.#node);\n if (sort && nodes.size > 1) {\n nodes = new Set(sortNodes(nodes));\n }\n }\n return nodes;\n }\n};\n"], + "mappings": "4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAAwB,wBACxBC,EAEO,uBACPC,EAGO,wBAGPC,EASO,yBACP,MAAMC,EAAW,OACXC,EAAW,OACXC,EAAU,MA0BT,MAAMR,CAAO,CAElBS,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC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L,IAAIH,EACJ,UAAW/B,KAAQ8H,EAIjB,GAHA/F,EAAU,KAAK,eAAeV,EAAQrB,EAAM,CAC1C,MAAOgE,EAAY,CACrB,CAAC,EACGjC,EAAS,CACXtB,EAAM,IAAIT,CAAI,EACd,KACF,CAEF,GAAI,CAAC+B,GAAW,CAAC+E,GAAaD,IAAe,eAAc,CACzD,KAAM,CAAE,OAAQqB,CAAY,EAAI7G,EAAO2C,CAAS,EAC1C,CAACmE,CAAS,EAAIL,EACpB,IAAI5F,EAAU,KAAK,UAAUgG,EAAa,CACxC,KAAMC,CACR,CAAC,EACD,KAAOjG,GAAS,CAId,GAHAH,EAAU,KAAK,eAAeV,EAAQa,EAAS,CAC7C,MAAO8B,EAAY,CACrB,CAAC,EACGjC,EAAS,CACXtB,EAAM,IAAIyB,CAAO,EACjB,KACF,CACAA,EAAU,KAAK,UAAUgG,EAAa,CACpC,KAAMhG,CACR,CAAC,CACH,CACF,CACF,CACF,CACF,CACA,OAAI2E,IAAe,gBACjBpG,EAAM,OAAO,KAAKxB,EAAK,EACnBwB,EAAM,KAAO,IACfA,EAAQ,IAAI,OAAI,aAAUA,CAAK,CAAC,IAEzBoG,IAAe,eACxBpG,EAAM,OAAO,KAAKxB,EAAK,EACnB2I,GAAQnH,EAAM,KAAO,IACvBA,EAAQ,IAAI,OAAI,aAAUA,CAAK,CAAC,IAG7BA,CACT,CACF", + "names": ["finder_exports", "__export", "Finder", "__toCommonJS", "import_matcher", "import_parser", "import_utility", "import_constant", "DIR_NEXT", "DIR_PREV", "KEY_TAB", "#ast", "#astCache", "#descendant", "#document", "#documentCache", "#event", "#focus", "#invalidate", "#invalidateResults", "#matcher", "#node", "#nodes", "#noexcept", "#qswalker", "#results", "#root", "#shadow", "#walker", "#walkers", "#warn", "#window", "window", "e", "opt", "selector", "node", "event", "noexcept", "warn", "func", "mouseKeys", "key", "evt", "keyboardKeys", "nodes", "ast", "cachedItem", "item", "l", "i", "cssAst", "branches", "hasHasPseudoFunc", "invalidate", "descendant", "items", "branch", "leaves", "nextItem", "itemName", "walker", "anb", "a", "b", "reverse", "parentNode", "matched", "selectorBranches", "info", "refNode", "selectorNodes", "display", "visibility", "bool", "nth", "j", "localName", "namespaceURI", "prefix", "itemLocalName", "itemNamespaceURI", "itemPrefix", "m", "nthName", "nthIdentName", "anbMap", "astLeaves", "leaf", "leafType", "combo", "twigLeaves", "itemType", "twig", "nextNode", "astData", "astName", "twigBranches", "res", "forgive", "lastIndex", "nextNodes", "arr", "astChildren", "selectors", "css", "leavesSet", "stateValue", "prop", "href", "origin", "pathname", "attrURL", "target", "type", "buttons", "hash", "id", "current", "eventTarget", "focusTarget", "relatedTarget", "parent", "placeholder", "targetNode", "nodeName", "checked", "form", "inputType", "node1", "node2", "host", "astType", "result", "cacheable", "compound", "filterLeaves", "baseNode", "leafName", "pending", "comboName", "dir", "matchedNode", "filtered", "complex", "targetType", "collected", "pendingItems", "branchLen", "firstTwig", "firstCombo", "firstName", "firstType", "lastTwig", "lastName", "lastType", "pendingItem", "index", "nextCombo", "collectedNodes", "sort", "find", "entryNodes", "entryNodesLen", "n", "entryCombo", "entryLeaves", "entryNode"] } diff --git a/dist/cjs/js/utility.js b/dist/cjs/js/utility.js index 5beebe54..a7f4f799 100644 --- a/dist/cjs/js/utility.js +++ b/dist/cjs/js/utility.js @@ -1,2 +1,2 @@ -var C=Object.create;var c=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},w=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _(t))!I.call(e,s)&&s!==r&&c(e,s,{get:()=>t[s],enumerable:!(i=U(t,s))||i.enumerable});return e};var y=(e,t,r)=>(r=e!=null?C(R(e)):{},w(t||!e||!e.__esModule?c(r,"default",{value:e,enumerable:!0}):r,e)),k=e=>w(c({},"__esModule",{value:!0}),e);var W={};M(W,{filterSelector:()=>A,getDirectionality:()=>m,getNamespaceURI:()=>D,getSlottedTextContent:()=>u,getType:()=>p,initNwsapi:()=>G,isContentEditable:()=>O,isCustomElement:()=>S,isInShadowTree:()=>g,isNamespaceDeclared:()=>v,isPreceding:()=>$,resolveContent:()=>L,sortNodes:()=>F,traverseNode:()=>P});module.exports=k(W);var d=y(require("@asamuzakjp/nwsapi"),1),h=y(require("bidi-js"),1),T=y(require("is-potential-custom-element-name"),1),o=require("./constant.js");const p=e=>Object.prototype.toString.call(e).slice(o.TYPE_FROM,o.TYPE_TO),L=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t,r;switch(e.nodeType){case o.DOCUMENT_NODE:{t=e,r=e;break}case o.DOCUMENT_FRAGMENT_NODE:{t=e.ownerDocument,r=e;break}case o.ELEMENT_NODE:{t=e.ownerDocument;let s=e;for(;s&&s.parentNode;)s=s.parentNode;r=s;break}default:throw new TypeError(`Unexpected node ${e.nodeName}`)}const i=t.createTreeWalker(r,o.WALKER_FILTER);return[t,r,i]},P=(e,t)=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let r;if(t?.currentNode){let i=t.currentNode;if(i===e)r=i;else if(i.contains(e))for(i=t.nextNode();i;){if(i===e){r=i;break}i=t.nextNode()}else{if(i!==t.root)for(;i&&!(i===t.root||i===e);)i=t.parentNode();if(e.nodeType===o.ELEMENT_NODE)for(;i;){if(i===e){r=i;break}i=t.nextNode()}else r=i}}return r??null},S=(e,t={})=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let r;if(e.nodeType===o.ELEMENT_NODE){const{localName:i,ownerDocument:s}=e,{formAssociated:a}=t,n=s.defaultView;let l;const f=e.getAttribute("is");f?l=(0,T.default)(f)&&n.customElements.get(f):l=(0,T.default)(i)&&n.customElements.get(i),l&&(a?r=l.formAssociated:r=!0)}return!!r},g=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===o.ELEMENT_NODE||e.nodeType===o.DOCUMENT_FRAGMENT_NODE){let r=e;for(;r;){const{host:i,mode:s,nodeType:a,parentNode:n}=r;if(i&&s&&a===o.DOCUMENT_FRAGMENT_NODE&&o.REG_SHADOW_MODE.test(s)){t=!0;break}r=n}}return!!t},u=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.localName==="slot"&&g(e)){const r=e.assignedNodes();if(r.length){for(const i of r)if(t=i.textContent.trim(),t)break}else t=e.textContent.trim()}return t??null},m=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===o.ELEMENT_NODE){const{dir:r,localName:i,parentNode:s}=e,{getEmbeddingLevels:a}=(0,h.default)();if(o.REG_DIR.test(r))t=r;else if(r==="auto"){let n;switch(i){case"input":{!e.type||/^(?:button|email|hidden|password|reset|search|submit|tel|text|url)$/.test(e.type)?n=e.value:/^(?:checkbox|color|date|image|number|radio|range|time)$/.test(e.type)&&(t="ltr");break}case"slot":{n=u(e);break}case"textarea":{n=e.value;break}default:{const l=[].slice.call(e.childNodes);for(const f of l){const{dir:E,localName:x,nodeType:N,textContent:b}=f;if(N===o.TEXT_NODE?n=b.trim():N===o.ELEMENT_NODE&&!/^(?:bdi|script|style|textarea)$/.test(x)&&(!E||!o.REG_DIR.test(E))&&(x==="slot"?n=u(f):n=b.trim()),n)break}}}if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}if(!t)if(s){const{nodeType:l}=s;l===o.ELEMENT_NODE?t=m(s):(l===o.DOCUMENT_NODE||l===o.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}else t="ltr"}else if(i==="bdi"){const n=e.textContent.trim();if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}t||s||(t="ltr")}else if(i==="input"&&e.type==="tel")t="ltr";else if(s){if(i==="slot"){const n=u(e);if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}}if(!t){const{nodeType:n}=s;n===o.ELEMENT_NODE?t=m(s):(n===o.DOCUMENT_NODE||n===o.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}}else t="ltr"}return t??null},O=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===o.ELEMENT_NODE){if(typeof e.isContentEditable=="boolean")t=e.isContentEditable;else if(e.ownerDocument.designMode==="on")t=!0;else if(e.hasAttribute("contenteditable")){const r=e.getAttribute("contenteditable");if(r===""||/^(?:plaintext-only|true)$/.test(r))t=!0;else if(r==="inherit"){let i=e.parentNode;for(;i;){if(O(i)){t=!0;break}i=i.parentNode}}}}return!!t},D=(e,t)=>{if(typeof e!="string")throw new TypeError(`Unexpected type ${p(e)}`);if(!t?.nodeType)throw new TypeError(`Unexpected type ${p(t)}`);let r;if(e&&t.nodeType===o.ELEMENT_NODE){const{attributes:i}=t;for(const s of i){const{name:a,namespaceURI:n,prefix:l,value:f}=s;if(a===`xmlns:${e}`){r=f;break}else if(l===e){r=n;break}}}return r??null},v=(e="",t={})=>{let r;if(e&&typeof e=="string"&&t.nodeType===o.ELEMENT_NODE&&(r=t.lookupNamespaceURI(e),!r)){const i=t.ownerDocument.documentElement;let s=t;for(;s&&(r=D(e,s),!(r||s===i));)s=s.parentNode}return!!r},$=(e,t)=>{if(e?.nodeType){if(!t?.nodeType)throw new TypeError(`Unexpected type ${p(t)}`)}else throw new TypeError(`Unexpected type ${p(e)}`);let r;if(e.nodeType===o.ELEMENT_NODE&&t.nodeType===o.ELEMENT_NODE){const i=t.compareDocumentPosition(e);r=i&o.DOCUMENT_POSITION_PRECEDING||i&o.DOCUMENT_POSITION_CONTAINS}return!!r},F=(e=[])=>{const t=[...e];return t.length>1&&t.sort((r,i)=>{let s;return $(i,r)?s=1:s=-1,s}),t},G=(e,t)=>{if(!e?.DOMException)throw new TypeError(`Unexpected global object ${p(e)}`);t?.nodeType!==o.DOCUMENT_NODE&&(t=e.document);const r=(0,d.default)({document:t,DOMException:e.DOMException});return r.configure({LOGERRORS:!1}),r},A=(e,t={})=>{if(!e||typeof e!="string")return!1;if(e.includes("[")){const r=e.lastIndexOf("[");if(e.substring(r).indexOf("]")<0)return!1}if(/\||::|[^\u0021-\u007F\s]|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]|:(?:is|where)\(\s*\)/.test(e))return!1;if(e.includes(":")){let r;if(/:(?:is|not)\(/.test(e)){const{complex:i}=t;i?r=o.REG_FILTER_COMPLEX:r=o.REG_FILTER_COMPOUND}else r=o.REG_FILTER_SIMPLE;if(r.test(e))return!1}return!0};0&&(module.exports={filterSelector,getDirectionality,getNamespaceURI,getSlottedTextContent,getType,initNwsapi,isContentEditable,isCustomElement,isInShadowTree,isNamespaceDeclared,isPreceding,resolveContent,sortNodes,traverseNode}); +var $=Object.create;var c=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},w=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!I.call(e,o)&&o!==r&&c(e,o,{get:()=>t[o],enumerable:!(i=C(t,o))||i.enumerable});return e};var y=(e,t,r)=>(r=e!=null?$(R(e)):{},w(t||!e||!e.__esModule?c(r,"default",{value:e,enumerable:!0}):r,e)),M=e=>w(c({},"__esModule",{value:!0}),e);var Y={};k(Y,{filterSelector:()=>W,getDirectionality:()=>m,getNamespaceURI:()=>D,getSlottedTextContent:()=>u,getType:()=>p,initNwsapi:()=>V,isContentEditable:()=>E,isCustomElement:()=>S,isFocusVisible:()=>v,isFocusable:()=>F,isInShadowTree:()=>O,isNamespaceDeclared:()=>G,isPreceding:()=>_,resolveContent:()=>P,sortNodes:()=>A,traverseNode:()=>L});module.exports=M(Y);var h=y(require("@asamuzakjp/nwsapi"),1),g=y(require("bidi-js"),1),T=y(require("is-potential-custom-element-name"),1),s=require("./constant.js");const p=e=>Object.prototype.toString.call(e).slice(s.TYPE_FROM,s.TYPE_TO),P=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t,r;switch(e.nodeType){case s.DOCUMENT_NODE:{t=e,r=e;break}case s.DOCUMENT_FRAGMENT_NODE:{t=e.ownerDocument,r=e;break}case s.ELEMENT_NODE:{t=e.ownerDocument;let o=e;for(;o&&o.parentNode;)o=o.parentNode;r=o;break}default:throw new TypeError(`Unexpected node ${e.nodeName}`)}const i=t.createTreeWalker(r,s.WALKER_FILTER);return[t,r,i]},L=(e,t)=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let r;if(t?.currentNode){let i=t.currentNode;if(i===e)r=i;else if(i.contains(e))for(i=t.nextNode();i;){if(i===e){r=i;break}i=t.nextNode()}else{if(i!==t.root)for(;i&&!(i===t.root||i===e);)i=t.parentNode();if(e.nodeType===s.ELEMENT_NODE)for(;i;){if(i===e){r=i;break}i=t.nextNode()}else r=i}}return r??null},S=(e,t={})=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let r;if(e.nodeType===s.ELEMENT_NODE){const{localName:i,ownerDocument:o}=e,{formAssociated:a}=t,n=o.defaultView;let l;const f=e.getAttribute("is");f?l=(0,T.default)(f)&&n.customElements.get(f):l=(0,T.default)(i)&&n.customElements.get(i),l&&(a?r=l.formAssociated:r=!0)}return!!r},O=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===s.ELEMENT_NODE||e.nodeType===s.DOCUMENT_FRAGMENT_NODE){let r=e;for(;r;){const{host:i,mode:o,nodeType:a,parentNode:n}=r;if(i&&o&&a===s.DOCUMENT_FRAGMENT_NODE&&s.REG_SHADOW_MODE.test(o)){t=!0;break}r=n}}return!!t},u=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.localName==="slot"&&O(e)){const r=e.assignedNodes();if(r.length){for(const i of r)if(t=i.textContent.trim(),t)break}else t=e.textContent.trim()}return t??null},m=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===s.ELEMENT_NODE){const{dir:r,localName:i,parentNode:o}=e,{getEmbeddingLevels:a}=(0,g.default)();if(s.REG_DIR.test(r))t=r;else if(r==="auto"){let n;switch(i){case"input":{!e.type||/^(?:button|email|hidden|password|reset|search|submit|tel|text|url)$/.test(e.type)?n=e.value:/^(?:checkbox|color|date|image|number|radio|range|time)$/.test(e.type)&&(t="ltr");break}case"slot":{n=u(e);break}case"textarea":{n=e.value;break}default:{const l=[].slice.call(e.childNodes);for(const f of l){const{dir:d,localName:x,nodeType:N,textContent:b}=f;if(N===s.TEXT_NODE?n=b.trim():N===s.ELEMENT_NODE&&!/^(?:bdi|script|style|textarea)$/.test(x)&&(!d||!s.REG_DIR.test(d))&&(x==="slot"?n=u(f):n=b.trim()),n)break}}}if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}if(!t)if(o){const{nodeType:l}=o;l===s.ELEMENT_NODE?t=m(o):(l===s.DOCUMENT_NODE||l===s.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}else t="ltr"}else if(i==="bdi"){const n=e.textContent.trim();if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}t||o||(t="ltr")}else if(i==="input"&&e.type==="tel")t="ltr";else if(o){if(i==="slot"){const n=u(e);if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}}if(!t){const{nodeType:n}=o;n===s.ELEMENT_NODE?t=m(o):(n===s.DOCUMENT_NODE||n===s.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}}else t="ltr"}return t??null},E=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===s.ELEMENT_NODE){if(typeof e.isContentEditable=="boolean")t=e.isContentEditable;else if(e.ownerDocument.designMode==="on")t=!0;else if(e.hasAttribute("contenteditable")){const r=e.getAttribute("contenteditable");if(r===""||/^(?:plaintext-only|true)$/.test(r))t=!0;else if(r==="inherit"){let i=e.parentNode;for(;i;){if(E(i)){t=!0;break}i=i.parentNode}}}}return!!t},v=e=>{let t;if(e?.nodeType===s.ELEMENT_NODE){const{localName:r,type:i}=e;switch(r){case"input":{(!i||s.REG_TYPE_INPUT.test(i))&&(t=!0);break}case"textarea":{t=!0;break}default:t=E(e)}}return!!t},F=e=>{let t;if(e?.nodeType===s.ELEMENT_NODE){const r=e.ownerDocument.defaultView;let i=e;for(t=!0;i;){if(i.disabled||i.hasAttribute("disabled"))return!1;(i.hidden||i.hasAttribute("hidden"))&&(t=!1);const{contentVisibility:o,display:a,visibility:n}=r.getComputedStyle(i);if(a==="none"||/^(?:collapse|hidden)$/.test(n)||o==="hidden"?t=!1:t=!0,t&&i?.parentNode?.nodeType===s.ELEMENT_NODE)i=i.parentNode;else break}}return!!t},D=(e,t)=>{if(typeof e!="string")throw new TypeError(`Unexpected type ${p(e)}`);if(!t?.nodeType)throw new TypeError(`Unexpected type ${p(t)}`);let r;if(e&&t.nodeType===s.ELEMENT_NODE){const{attributes:i}=t;for(const o of i){const{name:a,namespaceURI:n,prefix:l,value:f}=o;if(a===`xmlns:${e}`){r=f;break}else if(l===e){r=n;break}}}return r??null},G=(e="",t={})=>{let r;if(e&&typeof e=="string"&&t.nodeType===s.ELEMENT_NODE&&(r=t.lookupNamespaceURI(e),!r)){const i=t.ownerDocument.documentElement;let o=t;for(;o&&(r=D(e,o),!(r||o===i));)o=o.parentNode}return!!r},_=(e,t)=>{if(e?.nodeType){if(!t?.nodeType)throw new TypeError(`Unexpected type ${p(t)}`)}else throw new TypeError(`Unexpected type ${p(e)}`);let r;if(e.nodeType===s.ELEMENT_NODE&&t.nodeType===s.ELEMENT_NODE){const i=t.compareDocumentPosition(e);r=i&s.DOCUMENT_POSITION_PRECEDING||i&s.DOCUMENT_POSITION_CONTAINS}return!!r},A=(e=[])=>{const t=[...e];return t.length>1&&t.sort((r,i)=>{let o;return _(i,r)?o=1:o=-1,o}),t},V=(e,t)=>{if(!e?.DOMException)throw new TypeError(`Unexpected global object ${p(e)}`);t?.nodeType!==s.DOCUMENT_NODE&&(t=e.document);const r=(0,h.default)({document:t,DOMException:e.DOMException});return r.configure({LOGERRORS:!1}),r},W=(e,t={})=>{if(!e||typeof e!="string")return!1;if(e.includes("[")){const r=e.lastIndexOf("[");if(e.substring(r).indexOf("]")<0)return!1}if(/\||::|[^\u0021-\u007F\s]|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]|:(?:is|where)\(\s*\)/.test(e))return!1;if(e.includes(":")){let r;if(/:(?:is|not)\(/.test(e)){const{complex:i}=t;i?r=s.REG_FILTER_COMPLEX:r=s.REG_FILTER_COMPOUND}else r=s.REG_FILTER_SIMPLE;if(r.test(e))return!1}return!0};0&&(module.exports={filterSelector,getDirectionality,getNamespaceURI,getSlottedTextContent,getType,initNwsapi,isContentEditable,isCustomElement,isFocusVisible,isFocusable,isInShadowTree,isNamespaceDeclared,isPreceding,resolveContent,sortNodes,traverseNode}); //# sourceMappingURL=utility.js.map diff --git a/dist/cjs/js/utility.js.map b/dist/cjs/js/utility.js.map index 32d122df..c1c9aef3 100644 --- a/dist/cjs/js/utility.js.map +++ b/dist/cjs/js/utility.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../../src/js/utility.js"], - "sourcesContent": ["/**\n * utility.js\n */\n\n/* import */\nimport nwsapi from '@asamuzakjp/nwsapi';\nimport bidiFactory from 'bidi-js';\nimport isCustomElementName from 'is-potential-custom-element-name';\n\n/* constants */\nimport {\n DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINS,\n DOCUMENT_POSITION_PRECEDING, ELEMENT_NODE, REG_DIR, REG_FILTER_COMPLEX,\n REG_FILTER_COMPOUND, REG_FILTER_SIMPLE, REG_SHADOW_MODE, TEXT_NODE,\n TYPE_FROM, TYPE_TO, WALKER_FILTER\n} from './constant.js';\n\n/**\n * get type\n * @param {*} o - object to check\n * @returns {string} - type of object\n */\nexport const getType = o =>\n Object.prototype.toString.call(o).slice(TYPE_FROM, TYPE_TO);\n\n/**\n * resolve content document, root node and tree walker\n * @param {object} node - Document, DocumentFragment, Element node\n * @returns {Array.} - array of document, root node, tree walker\n */\nexport const resolveContent = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let document;\n let root;\n switch (node.nodeType) {\n case DOCUMENT_NODE: {\n document = node;\n root = node;\n break;\n }\n case DOCUMENT_FRAGMENT_NODE: {\n document = node.ownerDocument;\n root = node;\n break;\n }\n case ELEMENT_NODE: {\n document = node.ownerDocument;\n let parent = node;\n while (parent) {\n if (parent.parentNode) {\n parent = parent.parentNode;\n } else {\n break;\n }\n }\n root = parent;\n break;\n }\n default : {\n throw new TypeError(`Unexpected node ${node.nodeName}`);\n }\n }\n const walker = document.createTreeWalker(root, WALKER_FILTER);\n return [\n document,\n root,\n walker\n ];\n};\n\n/**\n * traverse node tree\n * @private\n * @param {object} node - node\n * @param {object} walker - tree walker\n * @returns {?object} - current node\n */\nexport const traverseNode = (node, walker) => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let current;\n if (walker?.currentNode) {\n let refNode = walker.currentNode;\n if (refNode === node) {\n current = refNode;\n } else if (refNode.contains(node)) {\n refNode = walker.nextNode();\n while (refNode) {\n if (refNode === node) {\n current = refNode;\n break;\n }\n refNode = walker.nextNode();\n }\n } else {\n if (refNode !== walker.root) {\n while (refNode) {\n if (refNode === walker.root || refNode === node) {\n break;\n }\n refNode = walker.parentNode();\n }\n }\n if (node.nodeType === ELEMENT_NODE) {\n while (refNode) {\n if (refNode === node) {\n current = refNode;\n break;\n }\n refNode = walker.nextNode();\n }\n } else {\n current = refNode;\n }\n }\n }\n return current ?? null;\n};\n\n/**\n * is custom element\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {boolean} - result;\n */\nexport const isCustomElement = (node, opt = {}) => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let bool;\n if (node.nodeType === ELEMENT_NODE) {\n const { localName, ownerDocument } = node;\n const { formAssociated } = opt;\n const window = ownerDocument.defaultView;\n let elmConstructor;\n const attr = node.getAttribute('is');\n if (attr) {\n elmConstructor =\n isCustomElementName(attr) && window.customElements.get(attr);\n } else {\n elmConstructor =\n isCustomElementName(localName) && window.customElements.get(localName);\n }\n if (elmConstructor) {\n if (formAssociated) {\n bool = elmConstructor.formAssociated;\n } else {\n bool = true;\n }\n }\n }\n return !!bool;\n};\n\n/**\n * is in shadow tree\n * @param {object} node - node\n * @returns {boolean} - result;\n */\nexport const isInShadowTree = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let bool;\n if (node.nodeType === ELEMENT_NODE ||\n node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n let refNode = node;\n while (refNode) {\n const { host, mode, nodeType, parentNode } = refNode;\n if (host && mode && nodeType === DOCUMENT_FRAGMENT_NODE &&\n REG_SHADOW_MODE.test(mode)) {\n bool = true;\n break;\n }\n refNode = parentNode;\n }\n }\n return !!bool;\n};\n\n/**\n * get slotted text content\n * @param {object} node - Element node\n * @returns {?string} - text content\n */\nexport const getSlottedTextContent = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let res;\n if (node.localName === 'slot' && isInShadowTree(node)) {\n const nodes = node.assignedNodes();\n if (nodes.length) {\n for (const item of nodes) {\n res = item.textContent.trim();\n if (res) {\n break;\n }\n }\n } else {\n res = node.textContent.trim();\n }\n }\n return res ?? null;\n};\n\n/**\n * get directionality of node\n * @see https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute\n * @param {object} node - Element node\n * @returns {?string} - 'ltr' / 'rtl'\n */\nexport const getDirectionality = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let res;\n if (node.nodeType === ELEMENT_NODE) {\n const { dir: nodeDir, localName, parentNode } = node;\n const { getEmbeddingLevels } = bidiFactory();\n if (REG_DIR.test(nodeDir)) {\n res = nodeDir;\n } else if (nodeDir === 'auto') {\n let text;\n switch (localName) {\n case 'input': {\n if (!node.type || /^(?:button|email|hidden|password|reset|search|submit|tel|text|url)$/.test(node.type)) {\n text = node.value;\n } else if (/^(?:checkbox|color|date|image|number|radio|range|time)$/.test(node.type)) {\n res = 'ltr';\n }\n break;\n }\n case 'slot': {\n text = getSlottedTextContent(node);\n break;\n }\n case 'textarea': {\n text = node.value;\n break;\n }\n default: {\n const items = [].slice.call(node.childNodes);\n for (const item of items) {\n const {\n dir: itemDir, localName: itemLocalName, nodeType: itemNodeType,\n textContent: itemTextContent\n } = item;\n if (itemNodeType === TEXT_NODE) {\n text = itemTextContent.trim();\n } else if (itemNodeType === ELEMENT_NODE) {\n if (!/^(?:bdi|script|style|textarea)$/.test(itemLocalName) &&\n (!itemDir || !REG_DIR.test(itemDir))) {\n if (itemLocalName === 'slot') {\n text = getSlottedTextContent(item);\n } else {\n text = itemTextContent.trim();\n }\n }\n }\n if (text) {\n break;\n }\n }\n }\n }\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n if (!res) {\n if (parentNode) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n res = getDirectionality(parentNode);\n } else if (parentNodeType === DOCUMENT_NODE ||\n parentNodeType === DOCUMENT_FRAGMENT_NODE) {\n res = 'ltr';\n }\n } else {\n res = 'ltr';\n }\n }\n } else if (localName === 'bdi') {\n const text = node.textContent.trim();\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n if (!(res || parentNode)) {\n res = 'ltr';\n }\n } else if (localName === 'input' && node.type === 'tel') {\n res = 'ltr';\n } else if (parentNode) {\n if (localName === 'slot') {\n const text = getSlottedTextContent(node);\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n }\n if (!res) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n res = getDirectionality(parentNode);\n } else if (parentNodeType === DOCUMENT_NODE ||\n parentNodeType === DOCUMENT_FRAGMENT_NODE) {\n res = 'ltr';\n }\n }\n } else {\n res = 'ltr';\n }\n }\n return res ?? null;\n};\n\n/**\n * is content editable\n * NOTE: not implemented in jsdom https://github.com/jsdom/jsdom/issues/1670\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isContentEditable = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let res;\n if (node.nodeType === ELEMENT_NODE) {\n if (typeof node.isContentEditable === 'boolean') {\n res = node.isContentEditable;\n } else if (node.ownerDocument.designMode === 'on') {\n res = true;\n } else if (node.hasAttribute('contenteditable')) {\n const attr = node.getAttribute('contenteditable');\n if (attr === '' || /^(?:plaintext-only|true)$/.test(attr)) {\n res = true;\n } else if (attr === 'inherit') {\n let parent = node.parentNode;\n while (parent) {\n if (isContentEditable(parent)) {\n res = true;\n break;\n }\n parent = parent.parentNode;\n }\n }\n }\n }\n return !!res;\n};\n\n/**\n * get namespace URI\n * @param {string} ns - namespace prefix\n * @param {Array} node - Element node\n * @returns {?string} - namespace URI\n */\nexport const getNamespaceURI = (ns, node) => {\n if (typeof ns !== 'string') {\n throw new TypeError(`Unexpected type ${getType(ns)}`);\n } else if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let res;\n if (ns && node.nodeType === ELEMENT_NODE) {\n const { attributes } = node;\n for (const attr of attributes) {\n const { name, namespaceURI, prefix, value } = attr;\n if (name === `xmlns:${ns}`) {\n res = value;\n break;\n } else if (prefix === ns) {\n res = namespaceURI;\n break;\n }\n }\n }\n return res ?? null;\n};\n\n/**\n * is namespace declared\n * @param {string} ns - namespace\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isNamespaceDeclared = (ns = '', node = {}) => {\n let res;\n if (ns && typeof ns === 'string' && node.nodeType === ELEMENT_NODE) {\n res = node.lookupNamespaceURI(ns);\n if (!res) {\n const root = node.ownerDocument.documentElement;\n let parent = node;\n while (parent) {\n res = getNamespaceURI(ns, parent);\n if (res || parent === root) {\n break;\n }\n parent = parent.parentNode;\n }\n }\n }\n return !!res;\n};\n\n/**\n * is preceding - nodeA precedes and/or contains nodeB\n * @param {object} nodeA - Element node\n * @param {object} nodeB - Element node\n * @returns {boolean} - result\n */\nexport const isPreceding = (nodeA, nodeB) => {\n if (!nodeA?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(nodeA)}`);\n } else if (!nodeB?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(nodeB)}`);\n }\n let res;\n if (nodeA.nodeType === ELEMENT_NODE && nodeB.nodeType === ELEMENT_NODE) {\n const posBit = nodeB.compareDocumentPosition(nodeA);\n res = posBit & DOCUMENT_POSITION_PRECEDING ||\n posBit & DOCUMENT_POSITION_CONTAINS;\n }\n return !!res;\n};\n\n/**\n * sort nodes\n * @param {Array.|Set.} nodes - collection of nodes\n * @returns {Array.} - collection of sorted nodes\n */\nexport const sortNodes = (nodes = []) => {\n const arr = [...nodes];\n if (arr.length > 1) {\n arr.sort((a, b) => {\n let res;\n if (isPreceding(b, a)) {\n res = 1;\n } else {\n res = -1;\n }\n return res;\n });\n }\n return arr;\n};\n\n/**\n * init nwsapi\n * @param {object} window - Window\n * @param {object} document - Document\n * @returns {object} - nwsapi\n */\nexport const initNwsapi = (window, document) => {\n if (!window?.DOMException) {\n throw new TypeError(`Unexpected global object ${getType(window)}`);\n }\n if (document?.nodeType !== DOCUMENT_NODE) {\n document = window.document;\n }\n const nw = nwsapi({\n document,\n DOMException: window.DOMException\n });\n nw.configure({\n LOGERRORS: false\n });\n return nw;\n};\n\n/**\n * filter selector (for nwsapi)\n * @param {string} selector - selector\n * @param {object} opt - options\n * @returns {boolean} - result\n */\nexport const filterSelector = (selector, opt = {}) => {\n if (!selector || typeof selector !== 'string') {\n return false;\n }\n // filter missing close square bracket\n if (selector.includes('[')) {\n const index = selector.lastIndexOf('[');\n const sel = selector.substring(index);\n if (sel.indexOf(']') < 0) {\n return false;\n }\n }\n // filter namespace selector, e.g. ns|E, pseudo-element selector,\n // selector containing non-ASCII or control character other than whitespace,\n // attribute selector with case flag, e.g. [attr i], or with unclosed quotes,\n // and empty :is() or :where()\n if (/\\||::|[^\\u0021-\\u007F\\s]|\\[\\s*[\\w$*=^|~-]+(?:(?:\"[\\w$*=^|~\\s'-]+\"|'[\\w$*=^|~\\s\"-]+')?(?:\\s+[\\w$*=^|~-]+)+|\"[^\"\\]]{1,255}|'[^'\\]]{1,255})\\s*\\]|:(?:is|where)\\(\\s*\\)/.test(selector)) {\n return false;\n }\n // filter pseudo-classes\n if (selector.includes(':')) {\n let reg;\n if (/:(?:is|not)\\(/.test(selector)) {\n const { complex } = opt;\n if (complex) {\n reg = REG_FILTER_COMPLEX;\n } else {\n reg = REG_FILTER_COMPOUND;\n }\n } else {\n reg = REG_FILTER_SIMPLE;\n }\n if (reg.test(selector)) {\n return false;\n }\n }\n return true;\n};\n"], - "mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,sBAAAC,EAAA,oBAAAC,EAAA,0BAAAC,EAAA,YAAAC,EAAA,eAAAC,EAAA,sBAAAC,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,EAAG,UAAU,CACX,UAAW,EACb,CAAC,EACMA,CACT,EAQalE,EAAiB,CAACoE,EAAUzC,EAAM,CAAC,IAAM,CACpD,GAAI,CAACyC,GAAY,OAAOA,GAAa,SACnC,MAAO,GAGT,GAAIA,EAAS,SAAS,GAAG,EAAG,CAC1B,MAAMC,EAAQD,EAAS,YAAY,GAAG,EAEtC,GADYA,EAAS,UAAUC,CAAK,EAC5B,QAAQ,GAAG,EAAI,EACrB,MAAO,EAEX,CAKA,GAAI,qKAAqK,KAAKD,CAAQ,EACpL,MAAO,GAGT,GAAIA,EAAS,SAAS,GAAG,EAAG,CAC1B,IAAIE,EACJ,GAAI,gBAAgB,KAAKF,CAAQ,EAAG,CAClC,KAAM,CAAE,QAAAG,CAAQ,EAAI5C,EAChB4C,EACFD,EAAM,qBAENA,EAAM,qBAEV,MACEA,EAAM,oBAER,GAAIA,EAAI,KAAKF,CAAQ,EACnB,MAAO,EAEX,CACA,MAAO,EACT", - "names": ["utility_exports", "__export", "filterSelector", "getDirectionality", "getNamespaceURI", "getSlottedTextContent", "getType", "initNwsapi", "isContentEditable", "isCustomElement", "isInShadowTree", "isNamespaceDeclared", "isPreceding", "resolveContent", "sortNodes", "traverseNode", "__toCommonJS", "import_nwsapi", "import_bidi_js", "import_is_potential_custom_element_name", "import_constant", "o", "node", "document", "root", "parent", "walker", "current", "refNode", "opt", "bool", "localName", "ownerDocument", "formAssociated", "window", "elmConstructor", "attr", "isCustomElementName", "host", "mode", "nodeType", "parentNode", "res", "nodes", "item", "nodeDir", "getEmbeddingLevels", "bidiFactory", "text", "items", "itemDir", "itemLocalName", "itemNodeType", "itemTextContent", "level", "parentNodeType", "ns", "attributes", "name", "namespaceURI", "prefix", "value", "nodeA", "nodeB", "posBit", "arr", "a", "b", "nw", "nwsapi", "selector", "index", "reg", "complex"] + "sourcesContent": ["/**\n * utility.js\n */\n\n/* import */\nimport nwsapi from '@asamuzakjp/nwsapi';\nimport bidiFactory from 'bidi-js';\nimport isCustomElementName from 'is-potential-custom-element-name';\n\n/* constants */\nimport {\n DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINS,\n DOCUMENT_POSITION_PRECEDING, ELEMENT_NODE, REG_DIR, REG_FILTER_COMPLEX,\n REG_FILTER_COMPOUND, REG_FILTER_SIMPLE, REG_SHADOW_MODE, REG_TYPE_INPUT,\n TEXT_NODE, TYPE_FROM, TYPE_TO, WALKER_FILTER\n} from './constant.js';\n\n/**\n * get type\n * @param {*} o - object to check\n * @returns {string} - type of object\n */\nexport const getType = o =>\n Object.prototype.toString.call(o).slice(TYPE_FROM, TYPE_TO);\n\n/**\n * resolve content document, root node and tree walker\n * @param {object} node - Document, DocumentFragment, Element node\n * @returns {Array.} - array of document, root node, tree walker\n */\nexport const resolveContent = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let document;\n let root;\n switch (node.nodeType) {\n case DOCUMENT_NODE: {\n document = node;\n root = node;\n break;\n }\n case DOCUMENT_FRAGMENT_NODE: {\n document = node.ownerDocument;\n root = node;\n break;\n }\n case ELEMENT_NODE: {\n document = node.ownerDocument;\n let parent = node;\n while (parent) {\n if (parent.parentNode) {\n parent = parent.parentNode;\n } else {\n break;\n }\n }\n root = parent;\n break;\n }\n default : {\n throw new TypeError(`Unexpected node ${node.nodeName}`);\n }\n }\n const walker = document.createTreeWalker(root, WALKER_FILTER);\n return [\n document,\n root,\n walker\n ];\n};\n\n/**\n * traverse node tree\n * @private\n * @param {object} node - node\n * @param {object} walker - tree walker\n * @returns {?object} - current node\n */\nexport const traverseNode = (node, walker) => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let current;\n if (walker?.currentNode) {\n let refNode = walker.currentNode;\n if (refNode === node) {\n current = refNode;\n } else if (refNode.contains(node)) {\n refNode = walker.nextNode();\n while (refNode) {\n if (refNode === node) {\n current = refNode;\n break;\n }\n refNode = walker.nextNode();\n }\n } else {\n if (refNode !== walker.root) {\n while (refNode) {\n if (refNode === walker.root || refNode === node) {\n break;\n }\n refNode = walker.parentNode();\n }\n }\n if (node.nodeType === ELEMENT_NODE) {\n while (refNode) {\n if (refNode === node) {\n current = refNode;\n break;\n }\n refNode = walker.nextNode();\n }\n } else {\n current = refNode;\n }\n }\n }\n return current ?? null;\n};\n\n/**\n * is custom element\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {boolean} - result;\n */\nexport const isCustomElement = (node, opt = {}) => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let bool;\n if (node.nodeType === ELEMENT_NODE) {\n const { localName, ownerDocument } = node;\n const { formAssociated } = opt;\n const window = ownerDocument.defaultView;\n let elmConstructor;\n const attr = node.getAttribute('is');\n if (attr) {\n elmConstructor =\n isCustomElementName(attr) && window.customElements.get(attr);\n } else {\n elmConstructor =\n isCustomElementName(localName) && window.customElements.get(localName);\n }\n if (elmConstructor) {\n if (formAssociated) {\n bool = elmConstructor.formAssociated;\n } else {\n bool = true;\n }\n }\n }\n return !!bool;\n};\n\n/**\n * is in shadow tree\n * @param {object} node - node\n * @returns {boolean} - result;\n */\nexport const isInShadowTree = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let bool;\n if (node.nodeType === ELEMENT_NODE ||\n node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n let refNode = node;\n while (refNode) {\n const { host, mode, nodeType, parentNode } = refNode;\n if (host && mode && nodeType === DOCUMENT_FRAGMENT_NODE &&\n REG_SHADOW_MODE.test(mode)) {\n bool = true;\n break;\n }\n refNode = parentNode;\n }\n }\n return !!bool;\n};\n\n/**\n * get slotted text content\n * @param {object} node - Element node\n * @returns {?string} - text content\n */\nexport const getSlottedTextContent = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let res;\n if (node.localName === 'slot' && isInShadowTree(node)) {\n const nodes = node.assignedNodes();\n if (nodes.length) {\n for (const item of nodes) {\n res = item.textContent.trim();\n if (res) {\n break;\n }\n }\n } else {\n res = node.textContent.trim();\n }\n }\n return res ?? null;\n};\n\n/**\n * get directionality of node\n * @see https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute\n * @param {object} node - Element node\n * @returns {?string} - 'ltr' / 'rtl'\n */\nexport const getDirectionality = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let res;\n if (node.nodeType === ELEMENT_NODE) {\n const { dir: nodeDir, localName, parentNode } = node;\n const { getEmbeddingLevels } = bidiFactory();\n if (REG_DIR.test(nodeDir)) {\n res = nodeDir;\n } else if (nodeDir === 'auto') {\n let text;\n switch (localName) {\n case 'input': {\n if (!node.type || /^(?:button|email|hidden|password|reset|search|submit|tel|text|url)$/.test(node.type)) {\n text = node.value;\n } else if (/^(?:checkbox|color|date|image|number|radio|range|time)$/.test(node.type)) {\n res = 'ltr';\n }\n break;\n }\n case 'slot': {\n text = getSlottedTextContent(node);\n break;\n }\n case 'textarea': {\n text = node.value;\n break;\n }\n default: {\n const items = [].slice.call(node.childNodes);\n for (const item of items) {\n const {\n dir: itemDir, localName: itemLocalName, nodeType: itemNodeType,\n textContent: itemTextContent\n } = item;\n if (itemNodeType === TEXT_NODE) {\n text = itemTextContent.trim();\n } else if (itemNodeType === ELEMENT_NODE) {\n if (!/^(?:bdi|script|style|textarea)$/.test(itemLocalName) &&\n (!itemDir || !REG_DIR.test(itemDir))) {\n if (itemLocalName === 'slot') {\n text = getSlottedTextContent(item);\n } else {\n text = itemTextContent.trim();\n }\n }\n }\n if (text) {\n break;\n }\n }\n }\n }\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n if (!res) {\n if (parentNode) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n res = getDirectionality(parentNode);\n } else if (parentNodeType === DOCUMENT_NODE ||\n parentNodeType === DOCUMENT_FRAGMENT_NODE) {\n res = 'ltr';\n }\n } else {\n res = 'ltr';\n }\n }\n } else if (localName === 'bdi') {\n const text = node.textContent.trim();\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n if (!(res || parentNode)) {\n res = 'ltr';\n }\n } else if (localName === 'input' && node.type === 'tel') {\n res = 'ltr';\n } else if (parentNode) {\n if (localName === 'slot') {\n const text = getSlottedTextContent(node);\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n }\n if (!res) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n res = getDirectionality(parentNode);\n } else if (parentNodeType === DOCUMENT_NODE ||\n parentNodeType === DOCUMENT_FRAGMENT_NODE) {\n res = 'ltr';\n }\n }\n } else {\n res = 'ltr';\n }\n }\n return res ?? null;\n};\n\n/**\n * is content editable\n * NOTE: not implemented in jsdom https://github.com/jsdom/jsdom/issues/1670\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isContentEditable = node => {\n if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let res;\n if (node.nodeType === ELEMENT_NODE) {\n if (typeof node.isContentEditable === 'boolean') {\n res = node.isContentEditable;\n } else if (node.ownerDocument.designMode === 'on') {\n res = true;\n } else if (node.hasAttribute('contenteditable')) {\n const attr = node.getAttribute('contenteditable');\n if (attr === '' || /^(?:plaintext-only|true)$/.test(attr)) {\n res = true;\n } else if (attr === 'inherit') {\n let parent = node.parentNode;\n while (parent) {\n if (isContentEditable(parent)) {\n res = true;\n break;\n }\n parent = parent.parentNode;\n }\n }\n }\n }\n return !!res;\n};\n\n/**\n * is focus visible\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isFocusVisible = node => {\n let res;\n if (node?.nodeType === ELEMENT_NODE) {\n const { localName, type } = node;\n switch (localName) {\n case 'input': {\n if (!type || REG_TYPE_INPUT.test(type)) {\n res = true;\n }\n break;\n }\n case 'textarea': {\n res = true;\n break;\n }\n default: {\n res = isContentEditable(node);\n }\n }\n }\n return !!res;\n};\n\n/**\n * is focusable\n * NOTE: workaround for jsdom issue: https://github.com/jsdom/jsdom/issues/3464\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isFocusable = node => {\n let res;\n if (node?.nodeType === ELEMENT_NODE) {\n const window = node.ownerDocument.defaultView;\n let refNode = node;\n res = true;\n while (refNode) {\n if (refNode.disabled || refNode.hasAttribute('disabled')) {\n return false;\n }\n if (refNode.hidden || refNode.hasAttribute('hidden')) {\n res = false;\n }\n const {\n contentVisibility, display, visibility\n } = window.getComputedStyle(refNode);\n if (display === 'none' || /^(?:collapse|hidden)$/.test(visibility) ||\n contentVisibility === 'hidden') {\n res = false;\n } else {\n res = true;\n }\n if (res && refNode?.parentNode?.nodeType === ELEMENT_NODE) {\n refNode = refNode.parentNode;\n } else {\n break;\n }\n }\n }\n return !!res;\n};\n\n/**\n * get namespace URI\n * @param {string} ns - namespace prefix\n * @param {Array} node - Element node\n * @returns {?string} - namespace URI\n */\nexport const getNamespaceURI = (ns, node) => {\n if (typeof ns !== 'string') {\n throw new TypeError(`Unexpected type ${getType(ns)}`);\n } else if (!node?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(node)}`);\n }\n let res;\n if (ns && node.nodeType === ELEMENT_NODE) {\n const { attributes } = node;\n for (const attr of attributes) {\n const { name, namespaceURI, prefix, value } = attr;\n if (name === `xmlns:${ns}`) {\n res = value;\n break;\n } else if (prefix === ns) {\n res = namespaceURI;\n break;\n }\n }\n }\n return res ?? null;\n};\n\n/**\n * is namespace declared\n * @param {string} ns - namespace\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isNamespaceDeclared = (ns = '', node = {}) => {\n let res;\n if (ns && typeof ns === 'string' && node.nodeType === ELEMENT_NODE) {\n res = node.lookupNamespaceURI(ns);\n if (!res) {\n const root = node.ownerDocument.documentElement;\n let parent = node;\n while (parent) {\n res = getNamespaceURI(ns, parent);\n if (res || parent === root) {\n break;\n }\n parent = parent.parentNode;\n }\n }\n }\n return !!res;\n};\n\n/**\n * is preceding - nodeA precedes and/or contains nodeB\n * @param {object} nodeA - Element node\n * @param {object} nodeB - Element node\n * @returns {boolean} - result\n */\nexport const isPreceding = (nodeA, nodeB) => {\n if (!nodeA?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(nodeA)}`);\n } else if (!nodeB?.nodeType) {\n throw new TypeError(`Unexpected type ${getType(nodeB)}`);\n }\n let res;\n if (nodeA.nodeType === ELEMENT_NODE && nodeB.nodeType === ELEMENT_NODE) {\n const posBit = nodeB.compareDocumentPosition(nodeA);\n res = posBit & DOCUMENT_POSITION_PRECEDING ||\n posBit & DOCUMENT_POSITION_CONTAINS;\n }\n return !!res;\n};\n\n/**\n * sort nodes\n * @param {Array.|Set.} nodes - collection of nodes\n * @returns {Array.} - collection of sorted nodes\n */\nexport const sortNodes = (nodes = []) => {\n const arr = [...nodes];\n if (arr.length > 1) {\n arr.sort((a, b) => {\n let res;\n if (isPreceding(b, a)) {\n res = 1;\n } else {\n res = -1;\n }\n return res;\n });\n }\n return arr;\n};\n\n/**\n * init nwsapi\n * @param {object} window - Window\n * @param {object} document - Document\n * @returns {object} - nwsapi\n */\nexport const initNwsapi = (window, document) => {\n if (!window?.DOMException) {\n throw new TypeError(`Unexpected global object ${getType(window)}`);\n }\n if (document?.nodeType !== DOCUMENT_NODE) {\n document = window.document;\n }\n const nw = nwsapi({\n document,\n DOMException: window.DOMException\n });\n nw.configure({\n LOGERRORS: false\n });\n return nw;\n};\n\n/**\n * filter selector (for nwsapi)\n * @param {string} selector - selector\n * @param {object} opt - options\n * @returns {boolean} - result\n */\nexport const filterSelector = (selector, opt = {}) => {\n if (!selector || typeof selector !== 'string') {\n return false;\n }\n // filter missing close square bracket\n if (selector.includes('[')) {\n const index = selector.lastIndexOf('[');\n const sel = selector.substring(index);\n if (sel.indexOf(']') < 0) {\n return false;\n }\n }\n // filter namespace selector, e.g. ns|E, pseudo-element selector,\n // selector containing non-ASCII or control character other than whitespace,\n // attribute selector with case flag, e.g. [attr i], or with unclosed quotes,\n // and empty :is() or :where()\n if (/\\||::|[^\\u0021-\\u007F\\s]|\\[\\s*[\\w$*=^|~-]+(?:(?:\"[\\w$*=^|~\\s'-]+\"|'[\\w$*=^|~\\s\"-]+')?(?:\\s+[\\w$*=^|~-]+)+|\"[^\"\\]]{1,255}|'[^'\\]]{1,255})\\s*\\]|:(?:is|where)\\(\\s*\\)/.test(selector)) {\n return false;\n }\n // filter pseudo-classes\n if (selector.includes(':')) {\n let reg;\n if (/:(?:is|not)\\(/.test(selector)) {\n const { complex } = opt;\n if (complex) {\n reg = REG_FILTER_COMPLEX;\n } else {\n reg = REG_FILTER_COMPOUND;\n }\n } else {\n reg = REG_FILTER_SIMPLE;\n }\n if (reg.test(selector)) {\n return false;\n }\n }\n return true;\n};\n"], + "mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,sBAAAC,EAAA,oBAAAC,EAAA,0BAAAC,EAAA,YAAAC,EAAA,eAAAC,EAAA,sBAAAC,EAAA,oBAAAC,EAAA,mBAAAC,EAAA,gBAAAC,EAAA,mBAAAC,EAAA,wBAAAC,EAAA,gBAAAC,EAAA,mBAAAC,EAAA,cAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAlB,GAKA,IAAAmB,EAAmB,mCACnBC,EAAwB,wBACxBC,EAAgC,iDAGhCC,EAKO,yBAOA,MAAMhB,EAAUiB,GACrB,OAAO,UAAU,SAAS,KAAKA,CAAC,EAAE,MAAM,YAAW,SAAO,EAO/CR,EAAiBS,GAAQ,CACpC,GAAI,CAACA,GAAM,SACT,MAAM,IAAI,UAAU,mBAAmBlB,EAAQkB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C,CAAC1B,CACX,EAOa5B,EAAY,CAAC6B,EAAQ,CAAC,IAAM,CACvC,MAAM0B,EAAM,CAAC,GAAG1B,CAAK,EACrB,OAAI0B,EAAI,OAAS,GACfA,EAAI,KAAK,CAACC,EAAGC,IAAM,CACjB,IAAI7B,EACJ,OAAI9B,EAAY2D,EAAGD,CAAC,EAClB5B,EAAM,EAENA,EAAM,GAEDA,CACT,CAAC,EAEI2B,CACT,EAQahE,EAAa,CAAC6B,EAAQX,IAAa,CAC9C,GAAI,CAACW,GAAQ,aACX,MAAM,IAAI,UAAU,4BAA4B9B,EAAQ8B,CAAM,CAAC,EAAE,EAE/DX,GAAU,WAAa,kBACzBA,EAAWW,EAAO,UAEpB,MAAMsC,KAAK,EAAAC,SAAO,CAChB,SAAAlD,EACA,aAAcW,EAAO,YACvB,CAAC,EACD,OAAAsC,EAAG,UAAU,CACX,UAAW,EACb,CAAC,EACMA,CACT,EAQaxE,EAAiB,CAAC0E,EAAU7C,EAAM,CAAC,IAAM,CACpD,GAAI,CAAC6C,GAAY,OAAOA,GAAa,SACnC,MAAO,GAGT,GAAIA,EAAS,SAAS,GAAG,EAAG,CAC1B,MAAMC,EAAQD,EAAS,YAAY,GAAG,EAEtC,GADYA,EAAS,UAAUC,CAAK,EAC5B,QAAQ,GAAG,EAAI,EACrB,MAAO,EAEX,CAKA,GAAI,qKAAqK,KAAKD,CAAQ,EACpL,MAAO,GAGT,GAAIA,EAAS,SAAS,GAAG,EAAG,CAC1B,IAAIE,EACJ,GAAI,gBAAgB,KAAKF,CAAQ,EAAG,CAClC,KAAM,CAAE,QAAAG,CAAQ,EAAIhD,EAChBgD,EACFD,EAAM,qBAENA,EAAM,qBAEV,MACEA,EAAM,oBAER,GAAIA,EAAI,KAAKF,CAAQ,EACnB,MAAO,EAEX,CACA,MAAO,EACT", + "names": ["utility_exports", "__export", "filterSelector", "getDirectionality", "getNamespaceURI", "getSlottedTextContent", "getType", "initNwsapi", "isContentEditable", "isCustomElement", "isFocusVisible", "isFocusable", "isInShadowTree", "isNamespaceDeclared", "isPreceding", "resolveContent", "sortNodes", "traverseNode", "__toCommonJS", "import_nwsapi", "import_bidi_js", "import_is_potential_custom_element_name", "import_constant", "o", "node", "document", "root", "parent", "walker", "current", "refNode", "opt", "bool", "localName", "ownerDocument", "formAssociated", "window", "elmConstructor", "attr", "isCustomElementName", "host", "mode", "nodeType", "parentNode", "res", "nodes", "item", "nodeDir", "getEmbeddingLevels", "bidiFactory", "text", "items", "itemDir", "itemLocalName", "itemNodeType", "itemTextContent", "level", "parentNodeType", "type", "contentVisibility", "display", "visibility", "ns", "attributes", "name", "namespaceURI", "prefix", "value", "nodeA", "nodeB", "posBit", "arr", "a", "b", "nw", "nwsapi", "selector", "index", "reg", "complex"] } diff --git a/package.json b/package.json index 17245848..f7a9bc2b 100644 --- a/package.json +++ b/package.json @@ -60,5 +60,5 @@ "tsc": "node scripts/index clean --dir=types -i && npx tsc", "update-wpt": "git submodule update --init --recursive --remote" }, - "version": "5.2.0" + "version": "5.2.1" } diff --git a/types/js/constant.d.ts b/types/js/constant.d.ts index d5c02f8b..97e738e5 100644 --- a/types/js/constant.d.ts +++ b/types/js/constant.d.ts @@ -87,7 +87,7 @@ export const REG_SHADOW_MODE: RegExp; export const REG_SHADOW_PSEUDO: RegExp; export const REG_TAG_NAME: RegExp; export const REG_TYPE_CHECK: RegExp; -export const REG_TYPE_DATE: RegExp; +export const REG_TYPE_INPUT: RegExp; export const REG_TYPE_RANGE: RegExp; export const REG_TYPE_RESET: RegExp; export const REG_TYPE_SUBMIT: RegExp; diff --git a/types/js/finder.d.ts b/types/js/finder.d.ts index c3138945..f62c54d4 100644 --- a/types/js/finder.d.ts +++ b/types/js/finder.d.ts @@ -6,6 +6,7 @@ export class Finder { noexcept?: boolean; warn?: boolean; }): object; + private _registerEventListeners; private _setEvent; private _correspond; private _createTreeWalker; diff --git a/types/js/utility.d.ts b/types/js/utility.d.ts index 28d9787a..56f04a18 100644 --- a/types/js/utility.d.ts +++ b/types/js/utility.d.ts @@ -6,6 +6,8 @@ export function isInShadowTree(node: object): boolean; export function getSlottedTextContent(node: object): string | null; export function getDirectionality(node: object): string | null; export function isContentEditable(node: object): boolean; +export function isFocusVisible(node: object): boolean; +export function isFocusable(node: object): boolean; export function getNamespaceURI(ns: string, node: any[]): string | null; export function isNamespaceDeclared(ns?: string, node?: object): boolean; export function isPreceding(nodeA: object, nodeB: object): boolean;