@asamuzakjp/dom-selector 5.2.0 → 5.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/js/constant.js +1 -1
- package/dist/cjs/js/constant.js.map +3 -3
- package/dist/cjs/js/finder.js +1 -1
- package/dist/cjs/js/finder.js.map +3 -3
- package/dist/cjs/js/utility.js +1 -1
- package/dist/cjs/js/utility.js.map +3 -3
- package/package.json +6 -6
- package/src/index.js +14 -8
- package/src/js/constant.js +2 -0
- package/src/js/finder.js +4 -9
- package/src/js/utility.js +36 -12
- package/types/js/constant.d.ts +3 -1
- package/types/js/finder.d.ts +1 -0
- package/types/js/utility.d.ts +3 -0
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var m=(f,r)=>{for(var t in r)p(f,t,{get:r[t],enumerable:!0})},a=(f,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of l(r))!T.call(f,i)&&i!==t&&p(f,i,{get:()=>r[i],enumerable:!(n=E(r,i))||n.enumerable});return f};var u=f=>a(p({},"__esModule",{value:!0}),f);var x={};m(x,{DOMSelector:()=>d});module.exports=u(x);var y=require("./js/finder.js"),h=require("./js/utility.js"),s=require("./js/constant.js");/*!
|
|
2
2
|
* DOM Selector - A CSS selector engine.
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @copyright asamuzaK (Kazz)
|
|
5
5
|
* @see {@link https://github.com/asamuzaK/domSelector/blob/main/LICENSE}
|
|
6
|
-
*/class
|
|
6
|
+
*/class d{#e;#r;#t;#s;constructor(r,t){this.#e=r,this.#r=t??r.document,this.#t=new y.Finder(r),this.#s=(0,h.initNwsapi)(r,t)}matches(r,t,n){if(t?.nodeType){if(t.nodeType!==s.ELEMENT_NODE){const e=new this.#e.TypeError(`Unexpected node ${t.nodeName}`);this.#t.onError(e,n)}}else{const e=new this.#e.TypeError(`Unexpected type ${(0,h.getType)(t)}`);this.#t.onError(e,n)}const i=t.ownerDocument;if(i===this.#r&&i.contentType==="text/html"){const e={complex:s.REG_COMPLEX.test(r),descend:!1,target:s.TARGET_SELF};if((0,h.filterSelector)(r,e))try{return this.#s.match(r,t)}catch{}}let o;try{this.#t.setup(r,t,n),o=this.#t.find(s.TARGET_SELF).size}catch(e){this.#t.onError(e,n)}return!!o}closest(r,t,n){if(t?.nodeType){if(t.nodeType!==s.ELEMENT_NODE){const e=new this.#e.TypeError(`Unexpected node ${t.nodeName}`);this.#t.onError(e,n)}}else{const e=new this.#e.TypeError(`Unexpected type ${(0,h.getType)(t)}`);this.#t.onError(e,n)}const i=t.ownerDocument;if(i===this.#r&&i.contentType==="text/html"){const e={complex:s.REG_COMPLEX.test(r),descend:!1,target:s.TARGET_LINEAL};if((0,h.filterSelector)(r,e))try{return this.#s.closest(r,t)}catch{}}let o;try{this.#t.setup(r,t,n);const e=this.#t.find(s.TARGET_LINEAL);if(e.size){let c=t;for(;c;){if(e.has(c)){o=c;break}c=c.parentNode}}}catch(e){this.#t.onError(e,n)}return o??null}querySelector(r,t,n){if(!t?.nodeType){const e=new this.#e.TypeError(`Unexpected type ${(0,h.getType)(t)}`);this.#t.onError(e,n)}let i;if(t.nodeType===s.DOCUMENT_NODE?i=t:i=t.ownerDocument,i===this.#r&&i.contentType==="text/html"){const e={complex:!1,descend:s.REG_DESCEND.test(r),target:s.TARGET_FIRST};if((0,h.filterSelector)(r,e))try{return this.#s.first(r,t)}catch{}}let o;try{this.#t.setup(r,t,n);const e=this.#t.find(s.TARGET_FIRST);e.size&&([o]=e)}catch(e){this.#t.onError(e,n)}return o??null}querySelectorAll(r,t,n){if(!t?.nodeType){const e=new this.#e.TypeError(`Unexpected type ${(0,h.getType)(t)}`);this.#t.onError(e,n)}let i;if(t.nodeType===s.DOCUMENT_NODE?i=t:i=t.ownerDocument,i===this.#r&&i.contentType==="text/html"){const e={complex:!1,descend:s.REG_DESCEND.test(r),target:s.TARGET_ALL};if((0,h.filterSelector)(r,e))try{return this.#s.select(r,t)}catch{}}let o;try{this.#t.setup(r,t,n);const e=this.#t.find(s.TARGET_ALL);e.size&&(o=[...e])}catch(e){this.#t.onError(e,n)}return o??[]}}0&&(module.exports={DOMSelector});
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.js"],
|
|
4
|
-
"sourcesContent": ["/*!\n * DOM Selector - A CSS selector engine.\n * @license MIT\n * @copyright asamuzaK (Kazz)\n * @see {@link https://github.com/asamuzaK/domSelector/blob/main/LICENSE}\n */\n\n/* import */\nimport { Finder } from './js/finder.js';\nimport { filterSelector, getType, initNwsapi } from './js/utility.js';\n\n/* constants */\nimport {\n DOCUMENT_NODE, ELEMENT_NODE, REG_COMPLEX,
|
|
5
|
-
"mappings": "4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAQA,IAAAI,EAAuB,0BACvBC,EAAoD,2BAGpDC,EAGO,4BAfP;AAAA;AAAA;AAAA;AAAA;AAAA,GAkBO,MAAMJ,CAAY,CAEvBK,GACAC,GACAC,GAOA,YAAYC,EAAQC,EAAU,CAC5B,
|
|
6
|
-
"names": ["src_exports", "__export", "DOMSelector", "__toCommonJS", "import_finder", "import_utility", "import_constant", "#document", "#finder", "#nwsapi", "window", "document", "selector", "node", "opt", "filterOpt", "res", "nodes", "refNode"]
|
|
4
|
+
"sourcesContent": ["/*!\n * DOM Selector - A CSS selector engine.\n * @license MIT\n * @copyright asamuzaK (Kazz)\n * @see {@link https://github.com/asamuzaK/domSelector/blob/main/LICENSE}\n */\n\n/* import */\nimport { Finder } from './js/finder.js';\nimport { filterSelector, getType, initNwsapi } from './js/utility.js';\n\n/* constants */\nimport {\n DOCUMENT_NODE, ELEMENT_NODE, REG_COMPLEX, REG_DESCEND, TARGET_ALL,\n TARGET_FIRST, TARGET_LINEAL, TARGET_SELF\n} from './js/constant.js';\n\n/* DOMSelector */\nexport class DOMSelector {\n /* private fields */\n #window;\n #document;\n #finder;\n #nwsapi;\n\n /**\n * construct\n * @param {object} window - window\n * @param {object} document - document\n */\n constructor(window, document) {\n this.#window = window;\n this.#document = document ?? window.document;\n this.#finder = new Finder(window);\n this.#nwsapi = initNwsapi(window, document);\n }\n\n /**\n * matches\n * @param {string} selector - CSS selector\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {boolean} - `true` if matched `false` otherwise\n */\n matches(selector, node, opt) {\n if (!node?.nodeType) {\n const e = new this.#window.TypeError(`Unexpected type ${getType(node)}`);\n this.#finder.onError(e, opt);\n } else if (node.nodeType !== ELEMENT_NODE) {\n const e = new this.#window.TypeError(`Unexpected node ${node.nodeName}`);\n this.#finder.onError(e, opt);\n }\n const document = node.ownerDocument;\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: REG_COMPLEX.test(selector),\n descend: false,\n target: TARGET_SELF\n };\n if (filterSelector(selector, filterOpt)) {\n try {\n const res = this.#nwsapi.match(selector, node);\n return res;\n } catch (e) {\n // fall through\n }\n }\n }\n let res;\n try {\n this.#finder.setup(selector, node, opt);\n const nodes = this.#finder.find(TARGET_SELF);\n res = nodes.size;\n } catch (e) {\n this.#finder.onError(e, opt);\n }\n return !!res;\n }\n\n /**\n * closest\n * @param {string} selector - CSS selector\n * @param {object} node - Element node\n * @param {object} opt - options\n * @returns {?object} - matched node\n */\n closest(selector, node, opt) {\n if (!node?.nodeType) {\n const e = new this.#window.TypeError(`Unexpected type ${getType(node)}`);\n this.#finder.onError(e, opt);\n } else if (node.nodeType !== ELEMENT_NODE) {\n const e = new this.#window.TypeError(`Unexpected node ${node.nodeName}`);\n this.#finder.onError(e, opt);\n }\n const document = node.ownerDocument;\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: REG_COMPLEX.test(selector),\n descend: false,\n target: TARGET_LINEAL\n };\n if (filterSelector(selector, filterOpt)) {\n try {\n const res = this.#nwsapi.closest(selector, node);\n return res;\n } catch (e) {\n // fall through\n }\n }\n }\n let res;\n try {\n this.#finder.setup(selector, node, opt);\n const nodes = this.#finder.find(TARGET_LINEAL);\n if (nodes.size) {\n let refNode = node;\n while (refNode) {\n if (nodes.has(refNode)) {\n res = refNode;\n break;\n }\n refNode = refNode.parentNode;\n }\n }\n } catch (e) {\n this.#finder.onError(e, opt);\n }\n return res ?? null;\n }\n\n /**\n * query selector\n * @param {string} selector - CSS selector\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} opt - options\n * @returns {?object} - matched node\n */\n querySelector(selector, node, opt) {\n if (!node?.nodeType) {\n const e = new this.#window.TypeError(`Unexpected type ${getType(node)}`);\n this.#finder.onError(e, opt);\n }\n let document;\n if (node.nodeType === DOCUMENT_NODE) {\n document = node;\n } else {\n document = node.ownerDocument;\n }\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: false,\n descend: REG_DESCEND.test(selector),\n target: TARGET_FIRST\n };\n if (filterSelector(selector, filterOpt)) {\n try {\n const res = this.#nwsapi.first(selector, node);\n return res;\n } catch (e) {\n // fall through\n }\n }\n }\n let res;\n try {\n this.#finder.setup(selector, node, opt);\n const nodes = this.#finder.find(TARGET_FIRST);\n if (nodes.size) {\n [res] = nodes;\n }\n } catch (e) {\n this.#finder.onError(e, opt);\n }\n return res ?? null;\n }\n\n /**\n * query selector all\n * NOTE: returns Array, not NodeList\n * @param {string} selector - CSS selector\n * @param {object} node - Document, DocumentFragment, Element node\n * @param {object} opt - options\n * @returns {Array.<object|undefined>} - collection of matched nodes\n */\n querySelectorAll(selector, node, opt) {\n if (!node?.nodeType) {\n const e = new this.#window.TypeError(`Unexpected type ${getType(node)}`);\n this.#finder.onError(e, opt);\n }\n let document;\n if (node.nodeType === DOCUMENT_NODE) {\n document = node;\n } else {\n document = node.ownerDocument;\n }\n if (document === this.#document && document.contentType === 'text/html') {\n const filterOpt = {\n complex: false,\n descend: REG_DESCEND.test(selector),\n target: TARGET_ALL\n };\n if (filterSelector(selector, filterOpt)) {\n try {\n const res = this.#nwsapi.select(selector, node);\n return res;\n } catch (e) {\n // fall through\n }\n }\n }\n let res;\n try {\n this.#finder.setup(selector, node, opt);\n const nodes = this.#finder.find(TARGET_ALL);\n if (nodes.size) {\n res = [...nodes];\n }\n } catch (e) {\n this.#finder.onError(e, opt);\n }\n return res ?? [];\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["src_exports", "__export", "DOMSelector", "__toCommonJS", "import_finder", "import_utility", "import_constant", "#window", "#document", "#finder", "#nwsapi", "window", "document", "selector", "node", "opt", "filterOpt", "res", "nodes", "refNode"]
|
|
7
7
|
}
|
package/dist/cjs/js/constant.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var T=Object.defineProperty;var
|
|
1
|
+
var T=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var m=(o,t)=>{for(var n in t)T(o,n,{get:t[n],enumerable:!0})},Y=(o,t,n,C)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of d(t))!u.call(o,s)&&s!==n&&T(o,s,{get:()=>t[s],enumerable:!(C=U(t,s))||C.enumerable});return o};var B=o=>Y(T({},"__esModule",{value:!0}),o);var to={};m(to,{ALPHA_NUM:()=>O,ANB:()=>P,AN_PLUS_B:()=>H,BIT_01:()=>st,BIT_02:()=>rt,BIT_04:()=>Et,BIT_08:()=>nt,BIT_16:()=>ct,BIT_32:()=>xt,BIT_FFFF:()=>pt,BIT_HYPHEN:()=>_t,CHILD_IDX:()=>G,COMBINATOR:()=>w,COMBO:()=>_,COMPLEX:()=>$,COMPLEX_L:()=>A,COMPOUND:()=>E,COMPOUND_A:()=>S,COMPOUND_B:()=>N,COMPOUND_I:()=>L,DESCEND:()=>l,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>At,DOCUMENT_NODE:()=>Lt,DOCUMENT_POSITION_CONTAINED_BY:()=>Gt,DOCUMENT_POSITION_CONTAINS:()=>Ct,DOCUMENT_POSITION_PRECEDING:()=>It,DUO:()=>Tt,ELEMENT_NODE:()=>St,EMPTY:()=>h,HEX:()=>Ot,IDENTIFIER:()=>g,KEY_IS_NOT:()=>I,LANG_PART:()=>D,LOGICAL_COMPLEX:()=>M,LOGICAL_COMPOUND:()=>F,NESTED_LOGICAL_A:()=>i,NESTED_LOGICAL_B:()=>a,NOT_SUPPORTED_ERR:()=>b,NTH:()=>f,N_TH:()=>p,PSEUDO_CLASSES:()=>x,RAW:()=>X,REG_ANCHOR:()=>Mt,REG_COMPLEX:()=>Ft,REG_DESCEND:()=>Ut,REG_DIR:()=>dt,REG_FILTER_COMPLEX:()=>ut,REG_FILTER_COMPOUND:()=>mt,REG_FILTER_SIMPLE:()=>Yt,REG_FORM:()=>Bt,REG_FORM_CTRL:()=>Ht,REG_FORM_VALID:()=>wt,REG_HEX:()=>ht,REG_INTERACT:()=>gt,REG_INVALID_SELECTOR:()=>bt,REG_LANG:()=>ft,REG_LANG_QUOTED:()=>Xt,REG_LOGICAL_EMPTY:()=>Wt,REG_LOGICAL_PSEUDO:()=>yt,REG_SHADOW_HOST:()=>kt,REG_SHADOW_MODE:()=>Zt,REG_SHADOW_PSEUDO:()=>Kt,REG_TAG_NAME:()=>vt,REG_TYPE_CHECK:()=>zt,REG_TYPE_INPUT:()=>Vt,REG_TYPE_RANGE:()=>Qt,REG_TYPE_RESET:()=>jt,REG_TYPE_SUBMIT:()=>qt,REG_TYPE_TEXT:()=>Jt,SELECTOR:()=>W,SELECTOR_ATTR:()=>y,SELECTOR_CLASS:()=>k,SELECTOR_ID:()=>Z,SELECTOR_LIST:()=>K,SELECTOR_PSEUDO_CLASS:()=>v,SELECTOR_PSEUDO_ELEMENT:()=>z,SELECTOR_TYPE:()=>V,SHOW_ALL:()=>Dt,SHOW_DOCUMENT:()=>Pt,SHOW_DOCUMENT_FRAGMENT:()=>lt,SHOW_ELEMENT:()=>it,STRING:()=>Q,SUB_TYPE:()=>r,SYNTAX_ERR:()=>j,TAG_TYPE:()=>e,TAG_TYPE_I:()=>R,TARGET_ALL:()=>q,TARGET_FIRST:()=>J,TARGET_LINEAL:()=>tt,TARGET_SELF:()=>ot,TEXT_NODE:()=>Nt,TYPE_FROM:()=>Rt,TYPE_TO:()=>$t,U_FFFD:()=>et,WALKER_FILTER:()=>at});module.exports=B(to);const H="AnPlusB",w="Combinator",h="__EMPTY__",g="Identifier",b="NotSupportedError",f="Nth",X="Raw",W="Selector",y="AttributeSelector",k="ClassSelector",Z="IdSelector",K="SelectorList",v="PseudoClassSelector",z="PseudoElementSelector",V="TypeSelector",Q="String",j="SyntaxError",q="all",J="first",tt="lineal",ot="self",et="\uFFFD",st=1,rt=2,Et=4,nt=8,ct=16,xt=32,pt=65535,_t=45,Tt=2,Ot=16,Rt=8,$t=-1,St=1,Nt=3,Lt=9,At=11,It=2,Ct=8,Gt=16,Dt=4294967295,Pt=256,lt=1024,it=1,at=1281,O="[A-Z\\d]+",G="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",D=`(?:-${O})*`,x=`(?:any-)?link|${G}|checked|empty|indeterminate|root|target|visited`,P=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,p=`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})+)`,_="\\s?[\\s>~+]\\s?",$=`${E}(?:${_}${E})*`,l="\\s?[\\s>]\\s?",i=`:is\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,a=`:is\\(\\s*${$}(?:\\s*,\\s*${$})*\\s*\\)`,S=`(?:${e}|(?:${e})?(?:${r}|${i})+)`,N=`(?:${e}|(?:${e})?(?:${r}|${a})+)`,L=`(?:${R}|(?:${R})?(?:${r})+)`,A=`${N}(?:${_}${N})*`,I="(?:is|not)",M=`${I}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,F=`${I}\\(\\s*${S}(?:\\s*,\\s*${S})*\\s*\\)`,Mt=/^a(?:rea)?$/,Ft=new RegExp(`${_}${L}`,"i"),Ut=new RegExp(`${l}${L}`,"i"),dt=/^(?:ltr|rtl)$/,ut=new RegExp(`:(?!${x}|${p}|${M})`),mt=new RegExp(`:(?!${x}|${p}|${F})`),Yt=new RegExp(`:(?!${x}|${p})`),Bt=/^(?:button|fieldset|form|input|select|textarea)$/,Ht=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,wt=/^(?:button|form|input|select|textarea)$/,ht=/^([\da-f]{1,6}\s?)/i,gt=/^(?:details|dialog)$/,bt=/^$|^\s*>|,\s*$/,ft=new RegExp(`^(?:\\*-)?${O}${D}$`,"i"),Xt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,Wt=/(:(is|where)\(\s*\))/,yt=/^(?:has|is|not|where)$/,kt=/^host(?:-context)?$/,Zt=/^(?:close|open)$/,Kt=/^part|slotted$/,vt=/[A-Z][\\w-]*/i,zt=/^(?:checkbox|radio)$/,Vt=/^(?:date(?:time-local)?|email|month|number|password|search|tel|text|time|url|week)$/,Qt=/^(?:date(?:time-local)?|month|number|range|time|week)$/,jt=/^(?: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,DESCEND,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_DESCEND,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});
|
|
2
2
|
//# sourceMappingURL=constant.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/js/constant.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const 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
|
|
5
|
-
"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,sBAAAC,GAAA,aAAAC,GAAA,kBAAAC,GAAA,mBAAAC,GAAA,YAAAC,GAAA,iBAAAC,GAAA,yBAAAC,GAAA,aAAAC,GAAA,oBAAAC,GAAA,sBAAAC,GAAA,uBAAAC,GAAA,oBAAAC,GAAA,oBAAAC,GAAA,sBAAAC,GAAA,iBAAAC,GAAA,mBAAAC,GAAA,
|
|
6
|
-
"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", "
|
|
4
|
+
"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 DESCEND = '\\\\s?[\\\\s>]\\\\s?';\nexport const NESTED_LOGICAL_A =\n `:is\\\\(\\\\s*${COMPOUND}(?:\\\\s*,\\\\s*${COMPOUND})*\\\\s*\\\\)`;\nexport const NESTED_LOGICAL_B =\n `:is\\\\(\\\\s*${COMPLEX}(?:\\\\s*,\\\\s*${COMPLEX})*\\\\s*\\\\)`;\nexport const COMPOUND_A =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_A})+)`;\nexport const COMPOUND_B =\n `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_B})+)`;\nexport const COMPOUND_I =\n `(?:${TAG_TYPE_I}|(?:${TAG_TYPE_I})?(?:${SUB_TYPE})+)`;\nexport const COMPLEX_L = `${COMPOUND_B}(?:${COMBO}${COMPOUND_B})*`;\nexport const KEY_IS_NOT = '(?:is|not)';\nexport const LOGICAL_COMPLEX =\n `${KEY_IS_NOT}\\\\(\\\\s*${COMPLEX_L}(?:\\\\s*,\\\\s*${COMPLEX_L})*\\\\s*\\\\)`;\nexport const LOGICAL_COMPOUND =\n `${KEY_IS_NOT}\\\\(\\\\s*${COMPOUND_A}(?:\\\\s*,\\\\s*${COMPOUND_A})*\\\\s*\\\\)`;\n\n/* regexp */\nexport const REG_ANCHOR = /^a(?:rea)?$/;\nexport const REG_COMPLEX = new RegExp(`${COMBO}${COMPOUND_I}`, 'i');\nexport const REG_DESCEND = new RegExp(`${DESCEND}${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"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"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", "DESCEND", "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_DESCEND", "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"]
|
|
7
7
|
}
|
package/dist/cjs/js/finder.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
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<f;l++)h[l].collected=!1,h[l].dir=null,h[l].filtered=!1,h[l].find=!1,e[l]=[]}else{let f;try{f=(0,g.parseSelector)(c)}catch(s){this.onError(s)}const{branches:l,info:{hasHasPseudoFunc:r}}=(0,g.walkAST)(f);let o=!!r,b=!1,d=0;h=[];for(const[...s]of l){const t=[];let n=s.shift();if(n&&n.type!==a.COMBINATOR){const u=new Set;for(;n;){if(n.type===a.COMBINATOR){const[m]=s;if(m.type===a.COMBINATOR)throw new DOMException(`Invalid selector ${c}`,a.SYNTAX_ERR);const w=n.name;/^[\s>]$/.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&&m<n){t=(0,k.traverseNode)(b,s),r?t=s.lastChild():t=s.firstChild();let w=0,p=f>0?0:l-1;for(;t&&(t&&m>=0&&m<n);)u.size?u.has(t)&&(p===m&&(d.add(t),m+=f),f>0?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&&u<n){t=(0,k.traverseNode)(b,s),l?t=s.lastChild():t=s.firstChild();let m=h>0?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;t<i;t++){const n=o[t],u=n.length-1,{leaves:m}=n[u];if(s=this._matchLeaves(m,e,h),s&&u>0){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<u;w++){const p=n[w];if(p.getAttribute("type")==="radio"&&(s?p.getAttribute("name")===s&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(r==="button"&&!(e.hasAttribute("type")&&a.REG_TYPE_RESET.test(e.getAttribute("type")))||r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;if(s){const t=this.#r;let n=(0,k.traverseNode)(s,t);for(n=t.firstChild();n&&s.contains(n);){const u=n.localName;let m;if(u==="button"?m=!(n.hasAttribute("type")&&a.REG_TYPE_RESET.test(n.getAttribute("type"))):u==="input"&&(m=n.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(n.getAttribute("type"))),m){n===e&&i.add(e);break}n=t.nextNode()}}}else(r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))&&e.hasAttribute("checked")||r==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(a.REG_FORM_VALID.test(r))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(r==="fieldset"){const 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<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"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;o<r;o++){const b=c[o];this._matchLeaves(f,b,e)&&l.add(b)}else{const o=[].slice.call(c);return new Set(o)}return l}_findDescendantNodes(c,e,h){const[f,...l]=c,r=l.length>0,{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;s<i;s++){const t=c[s];if(t!==this.#e&&(this.#e.contains(t)||t.contains(this.#e))){if(f){if(this._matchLeaves(l,t,{warn:this.#i})&&(o.push(t),b=!0,r===a.TARGET_FIRST))break}else if(o.push(t),b=!0,r===a.TARGET_FIRST)break}}else if(h)if(f)for(let s=0;s<i;s++){const t=c[s];if(this._matchLeaves(l,t,{warn:this.#i})&&(o.push(t),b=!0,r===a.TARGET_FIRST))break}else o=[].slice.call(c),b=!0,d=!0;else if(f)for(let s=0;s<i;s++){const t=c[s];if(this._matchLeaves(l,t,{warn:this.#i})&&(o.push(t),b=!0,r===a.TARGET_FIRST))break}else o=[].slice.call(c),b=!0,d=!0;return[o,b,d]}_findEntryNodes(c,e,h){const{leaves:f}=c,[l,...r]=f,o=r.length>0,{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<f;o++){const{branch:b,collected:d,dir:i,find:s}=e[o],t=b.length;if(t&&s){const n=h[o],u=n.length,m=t-1;if(m===0)if((c===a.TARGET_ALL||c===a.TARGET_FIRST)&&this.#e.nodeType===a.ELEMENT_NODE)for(let w=0;w<u;w++){const p=n[w];if(p!==this.#e&&this.#e.contains(p)&&(r.add(p),c!==a.TARGET_ALL))break}else if(c===a.TARGET_ALL)if(r.size){const w=[...r];r=new Set([...w,...n]),l=!0}else r=new Set(n);else{const[w]=n;r.add(w)}else if(c===a.TARGET_ALL)if(i===v){let{combo:w}=b[0];for(const p of n){let N=new Set([p]);for(let _=1;_<t;_++){const{combo:y,leaves:E}=b[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(r.size){const L=[...r];r=new Set([...L,...N]),l=!0}else r=N;else w=y;else break}}}else for(const w of n){let p=new Set([w]);for(let N=m-1;N>=0;N--){const _=b[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(r.add(w),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});
|
|
1
|
+
var T=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var $=(S,c)=>{for(var e in c)T(S,e,{get:c[e],enumerable:!0})},F=(S,c,e,h)=>{if(c&&typeof c=="object"||typeof c=="function")for(let n of D(c))!U.call(S,n)&&n!==e&&T(S,n,{get:()=>c[n],enumerable:!(h=I(c,n))||h.enumerable});return S};var G=S=>F(T({},"__esModule",{value:!0}),S);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",x="prev",W="Tab";class H{#a;#n;#w;#t;#f;#c;#k;#o;#u;#h;#e;#d;#_;#m;#N;#s;#b;#r;#p;#i;#l;constructor(c){this.#l=c,this.#h=new C.Matcher,this.#n=new WeakMap,this.#f=new WeakMap,this.#u=new WeakMap,this.#N=new WeakMap,this.#c=null,this.#k=null,this._registerEventListeners()}onError(c,e={}){if(!(e.noexcept??this.#_))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:n,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.#b=(0,k.isInShadowTree)(e),[this.#a,this.#d]=this._correspond(c),this.#u=new WeakMap,this.#p=new WeakMap,this._setEvent(n),e}_registerEventListeners(){const c={capture:!0,passive:!0},e=[],h=["mouseover","mousedown","mouseup","mouseout"];for(const l of h)e.push(this.#l.addEventListener(l,r=>{this.#c=r},c));const n=["keydown","keyup"];for(const l of n)e.push(this.#l.addEventListener(l,r=>{r.key===W&&(this.#c=r)},c));return e.push(this.#l.addEventListener("focusin",l=>{this.#k=l},c)),e}_setEvent(c){return(c instanceof this.#l.KeyboardEvent||c instanceof this.#l.MouseEvent)&&(this.#c=c),this.#c}_correspond(c){const e=[];this.#w=!1,this.#o=!1;let h;if(this.#f.has(this.#t)){const n=this.#f.get(this.#t);if(n&&n.has(`${c}`)){const l=n.get(`${c}`);h=l.ast,this.#w=l.descendant,this.#o=l.invalidate}}if(h){const n=h.length;for(let l=0;l<n;l++)h[l].collected=!1,h[l].dir=null,h[l].filtered=!1,h[l].find=!1,e[l]=[]}else{let n;try{n=(0,g.parseSelector)(c)}catch(s){this.onError(s)}const{branches:l,info:{hasHasPseudoFunc:r}}=(0,g.walkAST)(n);let f=!!r,b=!1,d=0;h=[];for(const[...s]of l){const t=[];let o=s.shift();if(o&&o.type!==a.COMBINATOR){const u=new Set;for(;o;){if(o.type===a.COMBINATOR){const[m]=s;if(m.type===a.COMBINATOR)throw new DOMException(`Invalid selector ${c}`,a.SYNTAX_ERR);const w=o.name;/^[\s>]$/.test(w)?b=!0:f=!0,t.push({combo:o,leaves:(0,g.sortAST)(u)}),u.clear()}else if(o){let{name:m}=o;m&&typeof m=="string"&&(m=(0,g.unescapeSelector)(m),typeof m=="string"&&m!==o.name&&(o.name=m),/[|:]/.test(m)&&(o.namespace=!0)),u.add(o)}if(s.length)o=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.#f.has(this.#t)?i=this.#f.get(this.#t):i=new Map,i.set(`${c}`,{ast:h,descendant:b,invalidate:f}),this.#f.set(this.#t,i),this.#w=b,this.#o=f}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:n,b:l,reverse:r,selector:f}=c,{parentNode:b}=e,d=new Set;let i;if(f)if(this.#n.has(f))i=this.#n.get(f);else{const{branches:s,info:t}=(0,g.walkAST)(f);i=s,this.#n.set(f,i),t.hasLogicalPseudoFunc&&(this.#o=!0)}if(b){const s=this.#r;let t=(0,k.traverseNode)(b,s);t=s.firstChild();let o=0;for(;t;)o++,t=s.nextSibling();const u=new Set;if(i)for(t=(0,k.traverseNode)(b,s),t=s.firstChild();t;){if((0,k.isVisible)(t)){let m;for(const w of i)if(m=this._matchLeaves(w,t,h),!m)break;m&&u.add(t)}t=s.nextSibling()}if(n===0){if(l>0&&l<=o){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(!f){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(n>0)for(;m<0;)m+=n;if(m>=0&&m<o){t=(0,k.traverseNode)(b,s),r?t=s.lastChild():t=s.firstChild();let w=0,p=n>0?0:l-1;for(;t&&(t&&m>=0&&m<o);)u.size?u.has(t)&&(p===m&&(d.add(t),m+=n),n>0?p++:p--):w===m&&(f||d.add(t),m+=n),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&&n+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:n,reverse:l}=c,{localName:r,namespaceURI:f,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 o=0;for(;t;)o++,t=s.nextSibling();if(h===0){if(n>0&&n<=o){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===f){if(u===n-1){i.add(t);break}u++}l?t=s.previousSibling():t=s.nextSibling()}}}else{let u=n-1;if(h>0)for(;u<0;)u+=h;if(u>=0&&u<o){t=(0,k.traverseNode)(b,s),l?t=s.lastChild():t=s.firstChild();let m=h>0?0:n-1;for(;t;){const{localName:w,namespaceURI:p,prefix:N}=t;if(w===r&&N===d&&p===f){if(m===u&&(i.add(t),u+=h),u<0||u>=o)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+n===1&&i.add(e);return i}_matchAnPlusB(c,e,h,n){const{nth:{a:l,b:r,name:f},selector:b}=c,d=new Map;if(f?(f==="even"?(d.set("a",2),d.set("b",0)):f==="odd"&&(d.set("a",2),d.set("b",1)),h.indexOf("last")>-1&&d.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?d.set("a",l*1):d.set("a",0),typeof r=="string"&&/-?\d+/.test(r)?d.set("b",r*1):d.set("b",0),h.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(h)){b&&d.set("selector",b);const i=Object.fromEntries(d);return this._collectNthChild(i,e,n)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(c,e,h={}){let n;if(Array.isArray(c)&&c.length){const l=c.map(t=>t),[r]=l,{type:f}=r;let b;f===a.COMBINATOR?b=l.shift():b={name:" ",type:a.COMBINATOR};const d=[];for(;l.length;){const[t]=l,{type:o}=t;if(o===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(n=this._matchHasPseudoFunc(l,t,h),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(c,e,h={}){const{astName:n="",branches:l=[],selector:r="",twigBranches:f=[]}=c;let b;if(n==="has")if(r.includes(":has("))b=null;else{let d;for(const i of l)if(d=this._matchHasPseudoFunc(i,e,h),d)break;d&&(b=e)}else{const d=/^(?:is|where)$/.test(n);h.forgive=d;const i=f.length;let s;for(let t=0;t<i;t++){const o=f[t],u=o.length-1,{leaves:m}=o[u];if(s=this._matchLeaves(m,e,h),s&&u>0){let w=new Set([e]);for(let p=u-1;p>=0;p--){const N=o[p],_=[];h.dir=x;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}n==="not"?s||(b=e):s&&(b=e)}return b??null}_matchPseudoClassSelector(c,e,h={}){const{children:n,name:l}=c,{localName:r,parentNode:f}=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:o}=(0,g.walkAST)(c),u=[],m=[];for(const[...w]of o){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:o,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(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[s]=n;return this._matchAnPlusB(s,e,l,h)}else switch(l){case"dir":case"lang":{const s=this.#h.matchSelector(c,e,h,!0);s&&i.add(s);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:s}]=n;if(s)if(e[s])i.add(e);else for(const t in e){const o=e[t];if(o instanceof this.#l.ElementInternals){o?.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:o}=new URL(this.#t.URL),u=new URL(e.getAttribute("href"),s);u.origin===t&&u.pathname===o&&i.add(e)}break}case"visited":break;case"hover":{const{target:s,type:t}=this.#c??{};/^(?:mouse|pointer)(?:down|over|up)$/.test(t)&&e.contains(s)&&i.add(e);break}case"active":{const{buttons:s,target:t,type:o}=this.#c??{};/(?:mouse|pointer)down/.test(o)&&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 o=this.#t.getElementById(t);for(;o;){if(o===e){i.add(e);break}o=o.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#b&&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:o}=this.#c??{},{target:u,relatedTarget:m}=this.#k??{};(/^key(?:down|up)$/.test(o)&&e.contains(t)||m&&(0,k.isFocusVisible)(m)&&e.contains(u))&&(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")f.localName==="optgroup"&&(f.disabled||f.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let s,t=f;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const o=this.#r;let u=(0,k.traverseNode)(t,o);for(u=o.firstChild();u&&u.localName!=="legend";)u=o.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")(f.localName!=="optgroup"||!(f.disabled||f.hasAttribute("disabled")))&&i.add(e);else{let s,t=f;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const o=this.#r;let u=(0,k.traverseNode)(t,o);for(u=o.firstChild();u&&u.localName!=="legend";)u=o.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_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 o=t.getElementsByTagName("input"),u=o.length;let m;for(let w=0;w<u;w++){const p=o[w];if(p.getAttribute("type")==="radio"&&(s?p.getAttribute("name")===s&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(r==="button"&&!(e.hasAttribute("type")&&a.REG_TYPE_RESET.test(e.getAttribute("type")))||r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;if(s){const t=this.#r;let o=(0,k.traverseNode)(s,t);for(o=t.firstChild();o&&s.contains(o);){const u=o.localName;let m;if(u==="button"?m=!(o.hasAttribute("type")&&a.REG_TYPE_RESET.test(o.getAttribute("type"))):u==="input"&&(m=o.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(o.getAttribute("type"))),m){o===e&&i.add(e);break}o=t.nextNode()}}}else(r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))&&e.hasAttribute("checked")||r==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(a.REG_FORM_VALID.test(r))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(r==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let o;if(!t)o=!0;else for(;t&&e.contains(t)&&!(a.REG_FORM_VALID.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?o=t.maxLength>=t.value.length:o=!0:o=!1,!o));)t=s.nextNode();o&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(r))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(r==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let o;if(!t)o=!0;else for(;t&&e.contains(t)&&!(a.REG_FORM_VALID.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?o=t.maxLength>=t.value.length:o=!0:o=!1,!o));)t=s.nextNode();o||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(),o;for(;t&&(o=t.nodeType!==a.ELEMENT_NODE&&t.nodeType!==a.TEXT_NODE,!!o);)t=s.nextSibling();o&&i.add(e)}else i.add(e);break}case"first-child":{(f&&e===f.firstElementChild||e===this.#s)&&i.add(e);break}case"last-child":{(f&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"only-child":{(f&&e===f.firstElementChild&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"first-of-type":{if(f){const[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(f){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(f){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":{e.popover&&(0,k.isVisible)(e)&&i.add(e);break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d)throw new DOMException(`Unsupported pseudo-element ::${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:n}=c;let l;if(Array.isArray(h)){const{branches:r}=(0,g.walkAST)(h[0]),[f]=r,[...b]=f,{host:d}=e;if(n==="host"){let i;for(const s of b){const{type:t}=s;if(t===a.COMBINATOR){const o=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${o}`,a.SYNTAX_ERR)}if(i=this._matchSelector(s,d).has(d),!i)break}i&&(l=e)}else if(n==="host-context"){let i=d,s;for(;i;){for(const t of b){const{type:o}=t;if(o===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(n==="host")l=e;else throw new DOMException(`Invalid selector :${n}`,a.SYNTAX_ERR);return l??null}_matchSelector(c,e,h){const{type:n}=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(n){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(c,e,h);default:{const f=this.#h.matchSelector(c,e,h,!0);f&&l.add(f)}}else if(this.#b&&n===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 f=this._matchShadowHostPseudoClass(c,e,h);f&&l.add(f)}}return l}_matchLeaves(c,e,h){let n,l;if(this.#o?l=this.#u.get(c):l=this.#N.get(c),l&&l.has(e)){const{matched:r}=l.get(e);n=r}if(typeof n!="boolean"){let r=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(r=!1);for(const f of c){switch(f.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{r=!1;break}case a.SELECTOR_PSEUDO_CLASS:{/^(?:(?:any-)?link|defined|dir)$/.test(f.name)&&(r=!1);break}default:}if(n=this._matchSelector(f,e,h).has(e),!n)break}r&&(l||(l=new WeakMap),l.set(e,{matched:n}),this.#o?this.#u.set(c,l):this.#N.set(c,l))}return!!n}_matchHTMLCollection(c,e={}){const{compound:h,filterLeaves:n}=e,l=new Set,r=c.length;if(r)if(h)for(let f=0;f<r;f++){const b=c[f];this._matchLeaves(n,b,e)&&l.add(b)}else{const f=[].slice.call(c);return new Set(f)}return l}_findDescendantNodes(c,e,h){const[n,...l]=c,r=l.length>0,{type:f}=n,b=(0,g.unescapeSelector)(n.name);typeof b=="string"&&b!==n.name&&(n.name=b);let d=new Set,i=!1;if(this.#b)i=!0;else switch(f){case a.SELECTOR_PSEUDO_ELEMENT:{this.#h.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:n,leaves:l}=c,{name:r}=n,{parentNode:f}=e,{dir:b}=h,d=new Set;if(b===v)switch(r){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let 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 o=(0,k.traverseNode)(e,t);for(o=t.nextNode();o&&e.contains(o);)this._matchLeaves(l,o,h)&&d.add(o),o=t.nextNode()}}}else switch(r){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let s=(0,k.traverseNode)(f,i);for(s=i.firstChild();s&&s!==e;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling()}break}case">":{f&&this._matchLeaves(l,f,h)&&d.add(f);break}case" ":default:{const i=[];let s=f;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,n=this.#m;let l=(0,k.traverseNode)(h,n),r;if(l)for((l.nodeType!==a.ELEMENT_NODE||l===h&&l!==this.#s)&&(l=n.nextNode());l;){if(this._matchLeaves(c,l,{warn:this.#i})){r=l;break}l=n.nextNode()}return r??null}_matchSelf(c){const e=[],h=this._matchLeaves(c,this.#e,{warn:this.#i});let n=!1;return h&&(e.push(this.#e),n=!0),[e,n]}_findLineal(c,e={}){const{complex:h}=e,n=[];let l=this._matchLeaves(c,this.#e,{warn:this.#i}),r=!1;if(l&&(n.push(this.#e),r=!0),!l||h){let f=this.#e.parentNode;for(;f&&(l=this._matchLeaves(c,f,{warn:this.#i}),l&&(n.push(f),r=!0),f.parentNode);)f=f.parentNode}return[n,r]}_findFirst(c){const e=[],h=this._findNode(c,{node:this.#e});let n=!1;return h&&(e.push(h),n=!0),[e,n]}_findFromHTMLCollection(c,e={}){const{complex:h,compound:n,filterLeaves:l,targetType:r}=e;let f=[],b=!1,d=!1;const i=c.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let s=0;s<i;s++){const t=c[s];if(t!==this.#e&&(this.#e.contains(t)||t.contains(this.#e))){if(n){if(this._matchLeaves(l,t,{warn:this.#i})&&(f.push(t),b=!0,r===a.TARGET_FIRST))break}else if(f.push(t),b=!0,r===a.TARGET_FIRST)break}}else if(h)if(n)for(let s=0;s<i;s++){const t=c[s];if(this._matchLeaves(l,t,{warn:this.#i})&&(f.push(t),b=!0,r===a.TARGET_FIRST))break}else f=[].slice.call(c),b=!0,d=!0;else if(n)for(let s=0;s<i;s++){const t=c[s];if(this._matchLeaves(l,t,{warn:this.#i})&&(f.push(t),b=!0,r===a.TARGET_FIRST))break}else f=[].slice.call(c),b=!0,d=!0;return[f,b,d]}_findEntryNodes(c,e,h){const{leaves:n}=c,[l,...r]=n,f=r.length>0,{name:b,type:d}=l;let i=[],s=!1,t=!1,o=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{this.#h.matchPseudoElementSelector(b,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:h});else if(e===a.TARGET_FIRST&&this.#s.nodeType!==a.ELEMENT_NODE){const u=this.#s.getElementById(b);u&&(f?this._matchLeaves(r,u,{warn:this.#i})&&(i.push(u),t=!0):(i.push(u),t=!0))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(n):o=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(n,{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:f,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(n):o=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:h});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===a.DOCUMENT_NODE&&!/[*|]/.test(b)){const u=this.#s.getElementsByTagName(b);u.length&&([i,t,s]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(n):o=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(b)){if(this.#b&&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(n):e===a.TARGET_LINEAL?[i,t]=this._findLineal(n,{complex:h}):e===a.TARGET_FIRST?[i,t]=this._findFirst(n):o=!0}return{collected:s,compound:f,filtered:t,nodes:i,pending:o}}_collectNodes(c){const e=this.#a.values();if(c===a.TARGET_ALL||c===a.TARGET_FIRST){const h=new Set;let n=0;for(const{branch:l}of e){const r=l.length,f=r>1,b=l[0];let d,i;if(f){const{combo:w,leaves:[{name:p,type:N}]}=b,_=l[r-1],{leaves:[{name:y,type:E}]}=_;if(E===a.SELECTOR_PSEUDO_ELEMENT||E===a.SELECTOR_ID)d=x,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=x,i=_;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(r===2){const{name:A}=w;/^[+~]$/.test(A)?(d=x,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=x,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=x,i=_)}}else d=x,i=b;const{collected:s,compound:t,filtered:o,nodes:u,pending:m}=this._findEntryNodes(i,c,f);u.length?(this.#a[n].find=!0,this.#d[n]=u):m&&h.add(new Map([["index",n],["twig",i]])),this.#a[n].collected=s,this.#a[n].dir=d,this.#a[n].filtered=o||!t,n++}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 f=(0,k.traverseNode)(l,r);for(;f;){let b=!1;if(this.#e.nodeType===a.ELEMENT_NODE?f===this.#e?b=!0:b=this.#e.contains(f):b=!0,b)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,f,{warn:this.#i})){const t=d.get("index");this.#a[t].filtered=!0,this.#a[t].find=!0,this.#d[t].push(f)}}f!==r.currentNode&&(f=(0,k.traverseNode)(f,r)),f=r.nextNode()}}}else{let h=0;for(const{branch:n}of e){const l=n[n.length-1],r=n.length>1,{compound:f,filtered:b,nodes:d}=this._findEntryNodes(l,c,r);d.length&&(this.#a[h].find=!0,this.#d[h]=d),this.#a[h].dir=x,this.#a[h].filtered=b||!f,h++}}return[this.#a,this.#d]}_getCombinedNodes(c,e,h){const n=[];for(const l of e){const r=this._matchCombinator(c,l,{dir:h,warn:this.#i});r.size&&n.push(...r)}return n.length?new Set(n):new Set}_matchNodeNext(c,e,h){const{combo:n,index:l}=h,{combo:r,leaves:f}=c[l],b={combo:n,leaves:f},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:n}=h,l=c[n],r=new Set([e]),f=this._getCombinedNodes(l,r,x);let b;if(f.size){if(n===0)b=e;else for(const d of f)if(this._matchNodePrev(c,d,{index:n-1}))return e}return b??null}find(c){(c===a.TARGET_ALL||c===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(c),n=e.length;let l,r=new Set;for(let f=0;f<n;f++){const{branch:b,collected:d,dir:i,find:s}=e[f],t=b.length;if(t&&s){const o=h[f],u=o.length,m=t-1;if(m===0)if((c===a.TARGET_ALL||c===a.TARGET_FIRST)&&this.#e.nodeType===a.ELEMENT_NODE)for(let w=0;w<u;w++){const p=o[w];if(p!==this.#e&&this.#e.contains(p)&&(r.add(p),c!==a.TARGET_ALL))break}else if(c===a.TARGET_ALL)if(r.size){const w=[...r];r=new Set([...w,...o]),l=!0}else r=new Set(o);else{const[w]=o;r.add(w)}else if(c===a.TARGET_ALL)if(i===v){let{combo:w}=b[0];for(const p of o){let N=new Set([p]);for(let _=1;_<t;_++){const{combo:y,leaves:E}=b[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(r.size){const L=[...r];r=new Set([...L,...N]),l=!0}else r=N;else w=y;else break}}}else for(const w of o){let p=new Set([w]);for(let N=m-1;N>=0;N--){const _=b[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(r.add(w),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 o)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],[_]=o;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 o)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]=o;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});
|
|
2
2
|
//# sourceMappingURL=finder.js.map
|