@asamuzakjp/dom-selector 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/cjs/js/dom-util.js +1 -1
- package/dist/cjs/js/dom-util.js.map +3 -3
- package/dist/cjs/js/matcher.js +1 -1
- package/dist/cjs/js/matcher.js.map +3 -3
- package/dist/cjs/js/parser.js +2 -2
- package/dist/cjs/js/parser.js.map +3 -3
- package/package.json +1 -1
- package/src/js/dom-util.js +35 -25
- package/src/js/matcher.js +150 -57
- package/src/js/parser.js +36 -16
- package/types/js/dom-util.d.ts +1 -0
- package/types/js/matcher.d.ts +10 -9
package/README.md
CHANGED
|
@@ -155,6 +155,9 @@ Returns **[Array][62]<([object][60] \| [undefined][63])>** array of matched n
|
|
|
155
155
|
|F \|\| E|Unsupported| |
|
|
156
156
|
|E:nth‑col(n)|Unsupported| |
|
|
157
157
|
|E:nth‑last‑col(n)|Unsupported| |
|
|
158
|
+
|:host|✓| |
|
|
159
|
+
|:host(s)|✓| |
|
|
160
|
+
|:host-context(s)|✓| |
|
|
158
161
|
|
|
159
162
|
|
|
160
163
|
## Monkey patch jsdom
|
package/dist/cjs/js/dom-util.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y=Object.create;var f=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var i in t)f(e,i,{get:t[i],enumerable:!0})},N=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of x(t))!g.call(e,l)&&l!==i&&f(e,l,{get:()=>t[l],enumerable:!(r=E(t,l))||r.enumerable});return e};var O=(e,t,i)=>(i=e!=null?y(D(e)):{},N(t||!e||!e.__esModule?f(i,"default",{value:e,enumerable:!0}):i,e)),C=e=>N(f({},"__esModule",{value:!0}),e);var L={};h(L,{getDirectionality:()=>m,getSlottedTextContent:()=>u,isContentEditable:()=>d,isInShadowTree:()=>b,isNamespaceDeclared:()=>v,isSameOrDescendant:()=>A,selectorToNodeProps:()=>M});module.exports=C(L);var T=O(require("bidi-js"),1),n=require("./constant.js");const a="ltr",p="rtl",w=/^(?:(?:butto|hidde)n|(?:emai|te|ur)l|(?:rese|submi|tex)t|password|search)$/,_=/^(?:close|open)$/,c=(0,T.default)(),b=(e={})=>{let t;if(e.nodeType===n.ELEMENT_NODE||e.nodeType===n.DOCUMENT_FRAGMENT_NODE){let i=e;for(;i;){const{host:r,mode:l,nodeType:s,parentNode:o}=i;if(r&&l&&s===n.DOCUMENT_FRAGMENT_NODE&&_.test(l)){t=!0;break}i=o}}return!!t},u=(e={})=>{let t;if(e.localName==="slot"&&b(e)){const i=e.assignedNodes();if(i.length){for(const r of i)if(t=r.textContent.trim(),t)break}else t=e.textContent.trim()}return t??null},m=(e={})=>{let t;if(e.nodeType===n.ELEMENT_NODE){const{dir:i,localName:r,parentNode:l}=e;if(/^(?:ltr|rtl)$/.test(i))t=i;else if(i==="auto"){let s;if(r==="textarea"||r==="input"&&(!e.type||w.test(e.type))?s=e.value:r==="slot"?s=u(e):s=e.textContent.trim(),s){const{paragraphs:[{level:o}]}=c.getEmbeddingLevels(s);o%2===1?t=p:t=a}if(!t)if(l){const{nodeType:o}=l;o===n.ELEMENT_NODE?t=m(l):(o===n.DOCUMENT_NODE||o===n.DOCUMENT_FRAGMENT_NODE)&&(t=a)}else t=a}else if(r==="bdi"){const s=e.textContent.trim();if(s){const{paragraphs:[{level:o}]}=c.getEmbeddingLevels(s);o%2===1?t=p:t=a}t||l||(t=a)}else if(r==="input"&&e.type==="tel")t=a;else if(l){if(r==="slot"){const s=u(e);if(s){const{paragraphs:[{level:o}]}=c.getEmbeddingLevels(s);o%2===1?t=p:t=a}}if(!t){const{nodeType:s}=l;s===n.ELEMENT_NODE?t=m(l):(s===n.DOCUMENT_NODE||s===n.DOCUMENT_FRAGMENT_NODE)&&(t=a)}}else t=a}return t??null},d=(e={})=>{let t;if(e.nodeType===n.ELEMENT_NODE){if(typeof e.isContentEditable=="boolean")t=e.isContentEditable;else if(e.ownerDocument.designMode==="on")t=!0;else if(e.hasAttribute("contenteditable")){const i=e.getAttribute("contenteditable");if(i===""||/^(?:plaintext-only|true)$/.test(i))t=!0;else if(i==="inherit"){let r=e.parentNode;for(;r;){if(d(r)){t=!0;break}r=r.parentNode}}}}return!!t},v=(e="",t={})=>{let i;if(e&&typeof e=="string"&&t.nodeType===n.ELEMENT_NODE){const r=`xmlns:${e}`,l=t.ownerDocument.documentElement;let s=t;for(;s;){if(typeof s.hasAttribute=="function"&&s.hasAttribute(r)){i=!0;break}else if(s===l)break;s=s.parentNode}}return!!i},A=(e={},t={})=>{let i;return e.ownerDocument&&e.nodeType===n.ELEMENT_NODE&&((!t||t.nodeType!==n.ELEMENT_NODE)&&(t=e.ownerDocument),e===t?i=!0:t&&(i=t.compareDocumentPosition(e)&n.DOCUMENT_POSITION_CONTAINED_BY)),!!i},M=(e,t)=>{let i,r;if(e&&typeof e=="string")/\|/.test(e)?[i,r]=e.split("|"):(i="*",r=e);else throw new DOMException(`invalid selector ${e}`,n.SYNTAX_ERR);return{prefix:i,tagName:r}};0&&(module.exports={getDirectionality,getSlottedTextContent,isContentEditable,isInShadowTree,isNamespaceDeclared,isSameOrDescendant,selectorToNodeProps});
|
|
2
2
|
//# sourceMappingURL=dom-util.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/js/dom-util.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * dom-util.js\n */\n\n/* import */\nimport bidiFactory from 'bidi-js';\n\n/* constants */\nimport {\n DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY,\n ELEMENT_NODE, SYNTAX_ERR\n} from './constant.js';\nconst LTR = 'ltr';\nconst RTL = 'rtl';\n\n/* regexp */\nconst INPUT_TYPE =\n /^(?:(?:butto|hidde)n|(?:emai|te|ur)l|(?:rese|submi|tex)t|password|search)$/;\nconst SHADOW_MODE = /^(?:close|open)$/;\n\n/* bidi */\nconst bidi = bidiFactory();\n\n/**\n *
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,0BAAAC,EAAA,sBAAAC,EAAA,wBAAAC,EAAA,uBAAAC,EAAA,wBAAAC,IAAA,eAAAC,
|
|
6
|
-
"names": ["dom_util_exports", "__export", "getDirectionality", "getSlottedTextContent", "isContentEditable", "isNamespaceDeclared", "isSameOrDescendant", "selectorToNodeProps", "__toCommonJS", "import_bidi_js", "import_constant", "LTR", "RTL", "INPUT_TYPE", "SHADOW_MODE", "bidi", "bidiFactory", "node", "
|
|
4
|
+
"sourcesContent": ["/**\n * dom-util.js\n */\n\n/* import */\nimport bidiFactory from 'bidi-js';\n\n/* constants */\nimport {\n DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY,\n ELEMENT_NODE, SYNTAX_ERR\n} from './constant.js';\nconst LTR = 'ltr';\nconst RTL = 'rtl';\n\n/* regexp */\nconst INPUT_TYPE =\n /^(?:(?:butto|hidde)n|(?:emai|te|ur)l|(?:rese|submi|tex)t|password|search)$/;\nconst SHADOW_MODE = /^(?:close|open)$/;\n\n/* bidi */\nconst bidi = bidiFactory();\n\n/**\n * is in shadow tree\n * @param {object} node - node\n * @returns {boolean} - result;\n */\nexport const isInShadowTree = (node = {}) => {\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 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 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 let res;\n if (node.nodeType === ELEMENT_NODE) {\n const { dir: nodeDir, localName, parentNode } = node;\n if (/^(?:ltr|rtl)$/.test(nodeDir)) {\n res = nodeDir;\n } else if (nodeDir === 'auto') {\n let text;\n if (localName === 'textarea') {\n text = node.value;\n } else if (localName === 'input' &&\n (!node.type || INPUT_TYPE.test(node.type))) {\n text = node.value;\n } else if (localName === 'slot') {\n text = getSlottedTextContent(node);\n } else {\n text = node.textContent.trim();\n }\n if (text) {\n const { paragraphs: [{ level }] } = bidi.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 }] } = bidi.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 }] } = bidi.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 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 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 const attr = `xmlns:${ns}`;\n const root = node.ownerDocument.documentElement;\n let parent = node;\n while (parent) {\n if (typeof parent.hasAttribute === 'function' &&\n parent.hasAttribute(attr)) {\n res = true;\n break;\n } else if (parent === root) {\n break;\n }\n parent = parent.parentNode;\n }\n }\n return !!res;\n};\n\n/**\n * is node same or descendant of the root node\n * @param {object} node - Element node\n * @param {object} root - Document, DocumentFragment, Element node\n * @returns {boolean} - result\n */\nexport const isSameOrDescendant = (node = {}, root = {}) => {\n let res;\n if (node.ownerDocument && node.nodeType === ELEMENT_NODE) {\n if (!root || root.nodeType !== ELEMENT_NODE) {\n root = node.ownerDocument;\n }\n if (node === root) {\n res = true;\n } else if (root) {\n res = root.compareDocumentPosition(node) & DOCUMENT_POSITION_CONTAINED_BY;\n }\n }\n return !!res;\n};\n\n/**\n * selector to node properties - e.g. ns|E -> { prefix: ns, tagName: E }\n * @param {string} selector - type selector\n * @param {object} [node] - Element node\n * @returns {object} - node properties\n */\nexport const selectorToNodeProps = (selector, node) => {\n let prefix;\n let tagName;\n if (selector && typeof selector === 'string') {\n if (/\\|/.test(selector)) {\n [prefix, tagName] = selector.split('|');\n } else {\n prefix = '*';\n tagName = selector;\n }\n } else {\n throw new DOMException(`invalid selector ${selector}`, SYNTAX_ERR);\n }\n return {\n prefix,\n tagName\n };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["dom_util_exports", "__export", "getDirectionality", "getSlottedTextContent", "isContentEditable", "isInShadowTree", "isNamespaceDeclared", "isSameOrDescendant", "selectorToNodeProps", "__toCommonJS", "import_bidi_js", "import_constant", "LTR", "RTL", "INPUT_TYPE", "SHADOW_MODE", "bidi", "bidiFactory", "node", "bool", "refNode", "host", "mode", "nodeType", "parentNode", "res", "nodes", "item", "nodeDir", "localName", "text", "level", "parentNodeType", "attr", "parent", "ns", "root", "selector", "prefix", "tagName"]
|
|
7
7
|
}
|
package/dist/cjs/js/matcher.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var G=Object.create;var $=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var K=(_,r)=>{for(var e in r)$(_,e,{get:r[e],enumerable:!0})},U=(_,r,e,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let h of q(r))!X.call(_,h)&&h!==e&&$(_,h,{get:()=>r[h],enumerable:!(c=W(r,h))||c.enumerable});return _};var Z=(_,r,e)=>(e=_!=null?G(Y(_)):{},U(r||!_||!_.__esModule?$(e,"default",{value:_,enumerable:!0}):e,_)),J=_=>U($({},"__esModule",{value:!0}),_);var ie={};K(ie,{Matcher:()=>se});module.exports=J(ie);var R=Z(require("is-potential-custom-element-name"),1),k=require("./dom-util.js"),g=require("./parser.js"),b=require("./constant.js");const P="[A-Z\\d]+",T=`(?:-${P})*`,C="all",v="first",x="lineal",S="self",B=/^(?:(?:fieldse|inpu|selec)t|button|opt(?:group|ion)|textarea)$/,O=/^(?:(?:(?:in|out)pu|selec)t|button|form|textarea)$/,z=/^a(?:rea)?$/,F=/^d(?:etails|ialog)$/,I=/^(?:checkbox|radio)$/,L=/^(?:(?:emai|te|ur)l|number|password|search|text)$/,V=/(?:(?:rang|tim)e|date(?:time-local)?|month|number|week)$/,j=/^(?:button|reset)$/,H=/^(?:image|submit)$/,D=/^(?:date(?:time-local)?|month|time|week)$/,Q=/^(?:(?:ha|i)s|not|where)$/,ee=/^nth-(?:last-)?(?:child|of-type)$/,te=new RegExp(`^(?:\\*-)?${P}${T}$`,"i");class se{#s;#l;#a;#e;#r;#t;#o;#c;#i;constructor(r,e,c={}){const{sort:h,warn:o}=c;this.#l=new Map([[b.PSEUDO_ELEMENT_SELECTOR,b.BIT_1],[b.ID_SELECTOR,b.BIT_10],[b.CLASS_SELECTOR,b.BIT_100],[b.TYPE_SELECTOR,b.BIT_1000],[b.ATTRIBUTE_SELECTOR,b.BIT_10000],[b.PSEUDO_CLASS_SELECTOR,b.BIT_100000]]),this.#a=new WeakMap,this.#o=r,this.#e=e,this.#c=!!h,this.#i=!!o,[this.#s,this.#r]=this._prepare(r),this.#t=this._getRoot(e)}_onError(r){if(r instanceof DOMException&&r.name===b.NOT_SUPPORTED_ERR)this.#i&&console.warn(r.message);else throw r}_getRoot(r=this.#e){let e,c;switch(r.nodeType){case b.DOCUMENT_NODE:{e=r,c=r;break}case b.DOCUMENT_FRAGMENT_NODE:{e=r.ownerDocument,c=r;break}case b.ELEMENT_NODE:{if((0,k.isSameOrDescendant)(r))e=r.ownerDocument,c=r.ownerDocument;else{let h=r;for(;h&&h.parentNode;)h=h.parentNode;e=h.ownerDocument,c=h}break}default:throw new TypeError(`Unexpected node ${r.nodeName}`)}return{document:e,root:c}}_sortLeaves(r){const e=[...r];return e.length>1&&e.sort((c,h)=>{const{type:o}=c,{type:d}=h,p=this.#l.get(o),u=this.#l.get(d);let t;return p===u?t=0:p>u?t=1:t=-1,t}),e}_prepare(r=this.#o){const e=(0,g.parseSelector)(r),c=(0,g.walkAST)(e),h=[],o=[];let d=0;for(const[...p]of c){const u=[];let t=p.shift();if(t&&t.type!==b.COMBINATOR){const s=new Set;for(;t;){if(t.type===b.COMBINATOR){const[f]=p;if(f.type===b.COMBINATOR){const n=`Invalid combinator ${t.name}${f.name}`;throw new DOMException(n,b.SYNTAX_ERR)}u.push({combo:t,leaves:this._sortLeaves(s)}),s.clear()}else t&&s.add(t);if(p.length)t=p.shift();else{u.push({combo:null,leaves:this._sortLeaves(s)}),s.clear();break}}}h.push({branch:u,find:null,skip:!1}),o[d]=new Set,d++}return[h,o]}_collectNthChild(r,e){const{a:c,b:h,reverse:o,selector:d}=r,{parentNode:p}=e,u=new Set;let t;if(d&&(this.#a.has(d)?t=this.#a.get(d):(t=(0,g.walkAST)(d),this.#a.set(d,t))),p){const s=[...p.children],f=s.length;if(f){const n=new Set;if(t){const i=t.length;for(const a of s){let l;for(let m=0;m<i;m++){const N=t[m];if(l=this._matchLeaves(N,a),!l)break}l&&n.add(a)}}if(o&&s.reverse(),c===0){if(h>0&&h<=f){if(n.size)for(let i=0;i<f;i++){const a=s[i];if(n.has(a)){u.add(a);break}}else if(!d){const i=s[h-1];u.add(i)}}}else{let i=h-1;if(c>0)for(;i<0;)i+=c;if(i>=0&&i<f){let a=c>0?0:h-1;for(let l=0;l<f&&i>=0&&i<f;l++){const m=s[l];n.size?n.has(m)&&(a===i&&(u.add(m),i+=c),c>0?a++:a--):l===i&&(d||u.add(m),i+=c)}}}}}else{const{root:s}=this.#t;if(s.nodeType===b.ELEMENT_NODE&&e===s&&c+h===1)if(t){const f=t.length;let n;for(let i=0;i<f;i++){const a=t[i];if(n=this._matchLeaves(a,e),n)break}n&&u.add(e)}else u.add(e)}return u}_collectNthOfType(r,e){const{a:c,b:h,reverse:o}=r,{localName:d,parentNode:p,prefix:u}=e,t=new Set;if(p){const s=[...p.children],f=s.length;if(f)if(o&&s.reverse(),c===0){if(h>0&&h<=f){let n=0;for(let i=0;i<f;i++){const a=s[i],{localName:l,prefix:m}=a;if(l===d&&m===u){if(n===h-1){t.add(a);break}n++}}}}else{let n=h-1;if(c>0)for(;n<0;)n+=c;if(n>=0&&n<f){let i=c>0?0:h-1;for(let a=0;a<f;a++){const l=s[a],{localName:m,prefix:N}=l;if(m===d&&N===u){if(i===n&&(t.add(l),n+=c),n<0||n>=f)break;c>0?i++:i--}}}}}else{const{root:s}=this.#t;s.nodeType===b.ELEMENT_NODE&&e===s&&c+h===1&&t.add(e)}return t}_matchAnPlusB(r,e,c){const{nth:{a:h,b:o,name:d},selector:p}=r,u=(0,g.unescapeSelector)(d),t=new Map;u?(u==="even"?(t.set("a",2),t.set("b",0)):u==="odd"&&(t.set("a",2),t.set("b",1)),/last/.test(c)&&t.set("reverse",!0)):(typeof h=="string"&&/-?\d+/.test(h)?t.set("a",h*1):t.set("a",0),typeof o=="string"&&/-?\d+/.test(o)?t.set("b",o*1):t.set("b",0),/last/.test(c)&&t.set("reverse",!0));let s=new Set;if(t.has("a")&&t.has("b")){if(/^nth-(?:last-)?child$/.test(c)){p&&t.set("selector",p);const f=Object.fromEntries(t),n=this._collectNthChild(f,e);n.size&&(s=n)}else if(/^nth-(?:last-)?of-type$/.test(c)){const f=Object.fromEntries(t),n=this._collectNthOfType(f,e);n.size&&(s=n)}}return s}_matchPseudoElementSelector(r,e={}){const{forgive:c}=e;switch(r){case"after":case"backdrop":case"before":case"cue":case"cue-region":case"first-letter":case"first-line":case"file-selector-button":case"marker":case"part":case"placeholder":case"selection":case"slotted":case"target-text":{if(this.#i)throw new DOMException(`Unsupported pseudo-element ::${r}`,b.NOT_SUPPORTED_ERR);break}default:if(r.startsWith("-webkit-")){if(this.#i)throw new DOMException(`Unsupported pseudo-element ::${r}`,b.NOT_SUPPORTED_ERR)}else if(!c)throw new DOMException(`Unknown pseudo-element ::${r}`,b.SYNTAX_ERR)}}_matchDirectionPseudoClass(r,e){const c=(0,g.unescapeSelector)(r.name),h=(0,k.getDirectionality)(e);let o;return c===h&&(o=e),o??null}_matchLanguagePseudoClass(r,e){const c=(0,g.unescapeSelector)(r.name);let h;if(c){if(c==="*")if(e.hasAttribute("lang"))e.getAttribute("lang")&&(h=e);else{let o=e.parentNode;for(;o;){if(o.hasAttribute("lang")){o.getAttribute("lang")&&(h=e);break}o=o.parentNode}}else if(te.test(c)){let o;if(/-/.test(c)){const[d,p,...u]=c.split("-");let t;d==="*"?t=`${P}${T}`:t=`${d}${T}`;const s=`-${p}${T}`,f=u.length;let n="";if(f)for(let i=0;i<f;i++)n+=`-${u[i]}${T}`;o=new RegExp(`^${t}${s}${n}$`,"i")}else o=new RegExp(`^${c}${T}$`,"i");if(e.hasAttribute("lang"))o.test(e.getAttribute("lang"))&&(h=e);else{let d=e.parentNode;for(;d;){if(d.hasAttribute("lang")){const p=d.getAttribute("lang");o.test(p)&&(h=e);break}d=d.parentNode}}}}return h??null}_matchHasPseudoFunc(r,e){let c;if(Array.isArray(r)&&r.length){const[h]=r,{type:o}=h;let d;o===b.COMBINATOR?d=r.shift():d={name:" ",type:b.COMBINATOR};const p=[];for(;r.length;){const[s]=r,{type:f}=s;if(f===b.COMBINATOR)break;p.push(r.shift())}const u={combo:d,leaves:p},t=this._matchCombinator(u,e,{find:"next"});if(t.size)if(r.length){for(const s of t)if(c=this._matchHasPseudoFunc(Object.assign([],r),s),c)break}else c=!0}return!!c}_matchLogicalPseudoFunc(r,e){const{astName:c="",branches:h=[],selector:o="",twigBranches:d=[]}=r;let p;if(c==="has")if(o.includes(":has("))p=null;else{const u=h.length;let t;for(let s=0;s<u;s++){const f=h[s];if(t=this._matchHasPseudoFunc(Object.assign([],f),e),t)break}t&&(p=e)}else{const u=/^(?:is|where)$/.test(c),t=d.length;let s;for(let f=0;f<t;f++){const n=d[f],i=n.length-1,{leaves:a}=n[i];if(s=this._matchLeaves(a,e,{forgive:u}),s&&i>0){let l=new Set([e]);for(let m=i-1;m>=0;m--){const N=n[m],w=[];for(const y of l){const A=this._matchCombinator(N,y,{forgive:u,find:"prev"});A.size&&w.push(...A)}const E=new Set(w);if(E.size)if(m===0){s=!0;break}else l=E;else{s=!1;break}}}if(s)break}c==="not"?s||(p=e):s&&(p=e)}return p??null}_matchPseudoClassSelector(r,e,c={}){const{children:h}=r,{localName:o,parentNode:d}=e,{forgive:p}=c,u=(0,g.unescapeSelector)(r.name);let t=new Set;if(Q.test(u)){let s;if(this.#a.has(r))s=this.#a.get(r);else{const n=(0,g.walkAST)(r),i=[],a=[];for(const[...l]of n){for(const E of l){const y=(0,g.generateCSS)(E);i.push(y)}const m=[],N=new Set;let w=l.shift();for(;w;)if(w.type===b.COMBINATOR?(m.push({combo:w,leaves:[...N]}),N.clear()):w&&N.add(w),l.length)w=l.shift();else{m.push({combo:null,leaves:[...N]}),N.clear();break}a.push(m)}s={astName:u,branches:n,twigBranches:a,selector:i.join(",")},this.#a.set(r,s)}const f=this._matchLogicalPseudoFunc(s,e);f&&t.add(f)}else if(Array.isArray(h)){const[s]=h;if(ee.test(u)){const f=this._matchAnPlusB(s,e,u);f.size&&(t=f)}else if(u==="dir"){const f=this._matchDirectionPseudoClass(s,e);f&&t.add(f)}else if(u==="lang"){const f=this._matchLanguagePseudoClass(s,e);f&&t.add(f)}else switch(u){case"current":case"nth-col":case"nth-last-col":{if(this.#i)throw new DOMException(`Unsupported pseudo-class :${u}()`,b.NOT_SUPPORTED_ERR);break}default:if(!p)throw new DOMException(`Unknown pseudo-class :${u}()`,b.SYNTAX_ERR)}}else{const{document:s,root:f}=this.#t,{documentElement:n}=s,i=new URL(s.URL);switch(u){case"any-link":case"link":{z.test(o)&&e.hasAttribute("href")&&t.add(e);break}case"local-link":{if(z.test(o)&&e.hasAttribute("href")){const a=new URL(e.getAttribute("href"),i.href);a.origin===i.origin&&a.pathname===i.pathname&&t.add(e)}break}case"visited":break;case"target":{(0,k.isSameOrDescendant)(e)&&i.hash&&e.id&&i.hash===`#${e.id}`&&t.add(e);break}case"target-within":{if(i.hash){const a=i.hash.replace(/^#/,"");let l=s.getElementById(a);for(;l;){if(l===e){t.add(e);break}l=l.parentNode}}break}case"scope":{this.#e.nodeType===b.ELEMENT_NODE?e===this.#e&&t.add(e):e===n&&t.add(e);break}case"focus":{e===s.activeElement&&t.add(e);break}case"focus-within":{let a=s.activeElement;for(;a;){if(a===e){t.add(e);break}a=a.parentNode}break}case"open":{F.test(o)&&e.hasAttribute("open")&&t.add(e);break}case"closed":{F.test(o)&&!e.hasAttribute("open")&&t.add(e);break}case"disabled":{if(B.test(o)||(0,R.default)(o))if(e.disabled||e.hasAttribute("disabled"))t.add(e);else{let a=d;for(;a&&a.localName!=="fieldset";)a=a.parentNode;a&&a.hasAttribute("disabled")&&d.localName!=="legend"&&t.add(e)}break}case"enabled":{(B.test(o)||(0,R.default)(o))&&!(e.disabled&&e.hasAttribute("disabled"))&&t.add(e);break}case"read-only":{switch(o){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}case"input":{(!e.type||L.test(e.type)||D.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,k.isContentEditable)(e)||t.add(e)}break}case"read-write":{switch(o){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||t.add(e);break}case"input":{(!e.type||L.test(e.type)||D.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,k.isContentEditable)(e)&&t.add(e)}break}case"placeholder-shown":{let a;o==="textarea"?a=e:o==="input"&&(e.hasAttribute("type")?L.test(e.getAttribute("type"))&&(a=e):a=e),a&&e.hasAttribute("placeholder")&&e.getAttribute("placeholder").trim().length&&e.value===""&&t.add(e);break}case"checked":{(o==="input"&&e.hasAttribute("type")&&I.test(e.getAttribute("type"))&&e.checked||o==="option"&&e.selected)&&t.add(e);break}case"indeterminate":{if(o==="input"&&e.type==="checkbox"&&e.indeterminate||o==="progress"&&!e.hasAttribute("value"))t.add(e);else if(o==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const a=e.name;let l=e.parentNode;for(;l&&l.localName!=="form";)l=l.parentNode;l||(l=n);const m=[...l.getElementsByTagName("input")];let N;for(const w of m)if(w.getAttribute("type")==="radio"&&(a?w.getAttribute("name")===a&&(N=!!w.checked):w.hasAttribute("name")||(N=!!w.checked),N))break;N||t.add(e)}break}case"default":{if(o==="button"&&!(e.hasAttribute("type")&&j.test(e.getAttribute("type")))||o==="input"&&e.hasAttribute("type")&&H.test(e.getAttribute("type"))){let a=e.parentNode;for(;a&&a.localName!=="form";)a=a.parentNode;if(a){const l=s.createNodeIterator(a,b.SHOW_ELEMENT);let m=l.nextNode();for(;m;){const N=m.localName;let w;if(N==="button"?w=!(m.hasAttribute("type")&&j.test(m.getAttribute("type"))):N==="input"&&(w=m.hasAttribute("type")&&H.test(m.getAttribute("type"))),w){m===e&&t.add(e);break}m=l.nextNode()}}}else if(o==="input"&&e.hasAttribute("type")&&I.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))t.add(e);else if(o==="option"){let a=!1,l=d;for(;l&&l.localName!=="datalist";){if(l.localName==="select"){(l.multiple||l.hasAttribute("multiple"))&&(a=!0);break}l=l.parentNode}if(a)(e.selected||e.hasAttribute("selected"))&&t.add(e);else{const m=d.firstElementChild,N=new Set;let w=m;for(;w;){if(w.selected||w.hasAttribute("selected")){N.add(w);break}w=w.nextElementSibling}N.size||N.add(m),N.has(e)&&t.add(e)}}break}case"valid":{if(O.test(o))e.checkValidity()&&t.add(e);else if(/^fieldset$/.test(o)){const a=s.createNodeIterator(e,b.SHOW_ELEMENT);let l=a.nextNode();l===e&&(l=a.nextNode());let m;for(;l&&!(O.test(l.localName)&&(m=l.checkValidity(),!m));)l=a.nextNode();m&&t.add(e)}break}case"invalid":{if(O.test(o))e.checkValidity()||t.add(e);else if(/^fieldset$/.test(o)){const a=s.createNodeIterator(e,b.SHOW_ELEMENT);let l=a.nextNode();l===e&&(l=a.nextNode());let m;for(;l&&!(O.test(l.localName)&&(m=l.checkValidity(),!m));)l=a.nextNode();m||t.add(e)}break}case"in-range":{o==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&V.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&t.add(e);break}case"out-of-range":{o==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&V.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&t.add(e);break}case"required":{let a;if(/^(?:select|textarea)$/.test(o))a=e;else if(o==="input")if(e.hasAttribute("type")){const l=e.getAttribute("type");(L.test(l)||I.test(l)||D.test(l)||l==="file")&&(a=e)}else a=e;a&&(e.required||e.hasAttribute("required"))&&t.add(e);break}case"optional":{let a;if(/^(?:select|textarea)$/.test(o))a=e;else if(o==="input")if(e.hasAttribute("type")){const l=e.getAttribute("type");(L.test(l)||I.test(l)||D.test(l)||l==="file")&&(a=e)}else a=e;a&&!(e.required||e.hasAttribute("required"))&&t.add(e);break}case"root":{e===n&&t.add(e);break}case"empty":{if(e.hasChildNodes()){const a=e.childNodes.values();let l;for(const m of a)if(l=m.nodeType!==b.ELEMENT_NODE&&m.nodeType!==b.TEXT_NODE,!l)break;l&&t.add(e)}else t.add(e);break}case"first-child":{(d&&e===d.firstElementChild||f.nodeType===b.ELEMENT_NODE&&e===f)&&t.add(e);break}case"last-child":{(d&&e===d.lastElementChild||f.nodeType===b.ELEMENT_NODE&&e===f)&&t.add(e);break}case"only-child":{(d&&e===d.firstElementChild&&e===d.lastElementChild||f.nodeType===b.ELEMENT_NODE&&e===f)&&t.add(e);break}case"first-of-type":{if(d){const[a]=this._collectNthOfType({a:0,b:1},e);a&&t.add(a)}else f.nodeType===b.ELEMENT_NODE&&e===f&&t.add(e);break}case"last-of-type":{if(d){const[a]=this._collectNthOfType({a:0,b:1,reverse:!0},e);a&&t.add(a)}else f.nodeType===b.ELEMENT_NODE&&e===f&&t.add(e);break}case"only-of-type":{if(d){const[a]=this._collectNthOfType({a:0,b:1},e);if(a===e){const[l]=this._collectNthOfType({a:0,b:1,reverse:!0},e);l===e&&t.add(e)}}else f.nodeType===b.ELEMENT_NODE&&e===f&&t.add(e);break}case"after":case"before":case"first-letter":case"first-line":{if(this.#i)throw new DOMException(`Unsupported pseudo-element ::${u}`,b.NOT_SUPPORTED_ERR);break}case"active":case"autofill":case"blank":case"buffering":case"current":case"focus-visible":case"fullscreen":case"future":case"hover":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(this.#i)throw new DOMException(`Unsupported pseudo-class :${u}`,b.NOT_SUPPORTED_ERR);break}default:if(u.startsWith("-webkit-")){if(this.#i)throw new DOMException(`Unsupported pseudo-class :${u}`,b.NOT_SUPPORTED_ERR)}else if(!p)throw new DOMException(`Unknown pseudo-class :${u}`,b.SYNTAX_ERR)}}return t}_matchAttributeSelector(r,e){const{flags:c,matcher:h,name:o,value:d}=r;if(typeof c=="string"&&!/^[is]$/i.test(c))throw new DOMException("Invalid attribute selector",b.SYNTAX_ERR);const{attributes:p}=e;let u;if(p&&p.length){const{document:t}=this.#t;let s;t.contentType==="text/html"?typeof c=="string"&&/^s$/i.test(c)?s=!1:s=!0:typeof c=="string"&&/^i$/i.test(c)?s=!0:s=!1;let{name:f}=o;f=(0,g.unescapeSelector)(f),s&&(f=f.toLowerCase());const n=new Set;if(/\|/.test(f)){const{prefix:i,tagName:a}=(0,k.selectorToNodeProps)(f);for(let{name:l,value:m}of p)switch(s&&(l=l.toLowerCase(),m=m.toLowerCase()),i){case"":{a===l&&n.add(m);break}case"*":{/:/.test(l)?l.endsWith(`:${a}`)&&n.add(m):a===l&&n.add(m);break}default:if(/:/.test(l)){const[N,w]=l.split(":");i===N&&a===w&&(0,k.isNamespaceDeclared)(i,e)&&n.add(m)}}}else for(let{name:i,value:a}of p)if(s&&(i=i.toLowerCase(),a=a.toLowerCase()),/:/.test(i)){const[l,m]=i.split(":");if(l==="xml"&&m==="lang")continue;f===m&&n.add(a)}else f===i&&n.add(a);if(n.size){const{name:i,value:a}=d||{};let l;switch(i?s?l=i.toLowerCase():l=i:a?s?l=a.toLowerCase():l=a:a===""&&(l=a),h){case"=":{typeof l=="string"&&n.has(l)&&(u=e);break}case"~=":{if(l&&typeof l=="string"){for(const m of n)if(new Set(m.split(/\s+/)).has(l)){u=e;break}}break}case"|=":{if(l&&typeof l=="string"){let m;for(const N of n)if(N===l||N.startsWith(`${l}-`)){m=N;break}m&&(u=e)}break}case"^=":{if(l&&typeof l=="string"){let m;for(const N of n)if(N.startsWith(`${l}`)){m=N;break}m&&(u=e)}break}case"$=":{if(l&&typeof l=="string"){let m;for(const N of n)if(N.endsWith(`${l}`)){m=N;break}m&&(u=e)}break}case"*=":{if(l&&typeof l=="string"){let m;for(const N of n)if(N.includes(`${l}`)){m=N;break}m&&(u=e)}break}case null:default:u=e}}}return u??null}_matchClassSelector(r,e){const c=(0,g.unescapeSelector)(r.name);let h;return e.classList.contains(c)&&(h=e),h??null}_matchIDSelector(r,e){const{id:c}=e,h=(0,g.unescapeSelector)(r.name);let o;return h===c&&(o=e),o??null}_matchTypeSelector(r,e){const c=(0,g.unescapeSelector)(r.name),{localName:h,prefix:o}=e,{document:d}=this.#t;let{prefix:p,tagName:u}=(0,k.selectorToNodeProps)(c,e);d.contentType==="text/html"&&(p=p.toLowerCase(),u=u.toLowerCase());let t,s;/:/.test(h)?[t,s]=h.split(":"):(t=o||"",s=h);let f;return p===""&&t===""?e.namespaceURI===null&&(u==="*"||u===s)&&(f=e):p==="*"?(u==="*"||u===s)&&(f=e):p===t&&(0,k.isNamespaceDeclared)(p,e)&&(u==="*"||u===s)&&(f=e),f??null}_matchSelector(r,e,c){const{type:h}=r;let o=new Set;if(e.nodeType===b.ELEMENT_NODE)switch(h){case b.ATTRIBUTE_SELECTOR:{const d=this._matchAttributeSelector(r,e);d&&o.add(d);break}case b.CLASS_SELECTOR:{const d=this._matchClassSelector(r,e);d&&o.add(d);break}case b.ID_SELECTOR:{const d=this._matchIDSelector(r,e);d&&o.add(d);break}case b.PSEUDO_CLASS_SELECTOR:{const d=this._matchPseudoClassSelector(r,e,c);d.size&&(o=d);break}case b.PSEUDO_ELEMENT_SELECTOR:{const d=(0,g.unescapeSelector)(r.name);this._matchPseudoElementSelector(d,c);break}case b.TYPE_SELECTOR:default:{const d=this._matchTypeSelector(r,e);d&&o.add(d)}}return o}_matchLeaves(r,e,c){let h;for(const o of r)if(h=this._matchSelector(o,e,c).has(e),!h)break;return!!h}_findDescendantNodes(r,e){const[c,...h]=r,{type:o}=c,d=(0,g.unescapeSelector)(c.name),p=h.length>0,u=new Set;let t=!1;switch(o){case b.ID_SELECTOR:{const{root:s}=this.#t;if(s.nodeType===b.ELEMENT_NODE)t=!0;else{const f=s.getElementById(d);if(f&&f!==e){const n=(0,k.isSameOrDescendant)(f,e);let i;n&&(i=f),i&&(p?this._matchLeaves(h,i)&&u.add(i):u.add(i))}}break}case b.PSEUDO_ELEMENT_SELECTOR:{this._matchPseudoElementSelector(d);break}default:t=!0}return{nodes:u,pending:t}}_matchCombinator(r,e,c={}){const{combo:h,leaves:o}=r,{name:d}=h,{find:p,forgive:u}=c;let t=new Set;if(p==="next")switch(d){case"+":{const s=e.nextElementSibling;s&&this._matchLeaves(o,s,{forgive:u})&&t.add(s);break}case"~":{let s=e.nextElementSibling;for(;s;)this._matchLeaves(o,s,{forgive:u})&&t.add(s),s=s.nextElementSibling;break}case">":{const s=[...e.children];for(const f of s)this._matchLeaves(o,f,{forgive:u})&&t.add(f);break}case" ":default:{const{nodes:s,pending:f}=this._findDescendantNodes(o,e);if(s.size)t=s;else if(f){const{document:n}=this.#t,i=n.createNodeIterator(e,b.SHOW_ELEMENT);let a=i.nextNode();for(a===e&&(a=i.nextNode());a;)this._matchLeaves(o,a,{forgive:u})&&t.add(a),a=i.nextNode()}}}else switch(d){case"+":{const s=e.previousElementSibling;s&&this._matchLeaves(o,s,{forgive:u})&&t.add(s);break}case"~":{const s=[];let f=e.previousElementSibling;for(;f;)this._matchLeaves(o,f,{forgive:u})&&s.push(f),f=f.previousElementSibling;s.length&&(t=new Set(s.reverse()));break}case">":{const s=e.parentNode;s&&this._matchLeaves(o,s,{forgive:u})&&t.add(s);break}case" ":default:{const s=[];let f=e.parentNode;for(;f;)this._matchLeaves(o,f,{forgive:u})&&s.push(f),f=f.parentNode;s.length&&(t=new Set(s.reverse()))}}return t}_findNodes(r,e){const{leaves:[c,...h]}=r,{type:o}=c,d=(0,g.unescapeSelector)(c.name),p=h.length>0,{document:u,root:t}=this.#t;let s=new Set,f=!1;switch(o){case b.ID_SELECTOR:{let n;if(e===S)this._matchLeaves([c],this.#e)&&(n=this.#e);else if(e===x){let i=this.#e;for(;i;){if(this._matchLeaves([c],i)){n=i;break}i=i.parentNode}}else t.nodeType===b.ELEMENT_NODE?f=!0:n=t.getElementById(d);n&&(p?this._matchLeaves(h,n)&&s.add(n):s.add(n));break}case b.CLASS_SELECTOR:{const n=[];if(e===S)this.#e.nodeType===b.ELEMENT_NODE&&this.#e.classList.contains(d)&&n.push(this.#e);else if(e===x){let i=this.#e;for(;i&&i.nodeType===b.ELEMENT_NODE;)i.classList.contains(d)&&n.push(i),i=i.parentNode}else if(t.nodeType===b.DOCUMENT_FRAGMENT_NODE){const i=[...t.children];for(const a of i){a.classList.contains(d)&&n.push(a);const l=[...a.getElementsByClassName(d)];n.push(...l)}}else{const i=[...t.getElementsByClassName(d)];n.push(...i)}if(n.length)if(p)for(const i of n)this._matchLeaves(h,i)&&s.add(i);else s=new Set(n);break}case b.TYPE_SELECTOR:{const n=[];if(e===S)this.#e.nodeType===b.ELEMENT_NODE&&this._matchLeaves([c],this.#e)&&n.push(this.#e);else if(e===x){let i=this.#e;for(;i&&i.nodeType===b.ELEMENT_NODE;)this._matchLeaves([c],i)&&n.push(i),i=i.parentNode}else if(u.contentType!=="text/html"||/[*|]/.test(d))f=!0;else if(t.nodeType===b.DOCUMENT_FRAGMENT_NODE){const i=d.toLowerCase(),a=[...t.children];for(const l of a){l.localName===i&&n.push(l);const m=[...l.getElementsByTagName(d)];n.push(...m)}}else{const i=[...t.getElementsByTagName(d)];n.push(...i)}if(n.length)if(p)for(const i of n)this._matchLeaves(h,i)&&s.add(i);else s=new Set(n);break}case b.PSEUDO_ELEMENT_SELECTOR:{this._matchPseudoElementSelector(d);break}default:{const n=[];if(e===S)this._matchLeaves([c],this.#e)&&n.push(this.#e);else if(e===x){let i=this.#e;for(;i;)this._matchLeaves([c],i)&&n.push(i),i=i.parentNode}else f=!0;if(n.length)if(p)for(const i of n)this._matchLeaves(h,i)&&s.add(i);else s=new Set(n)}}return{nodes:s,pending:f}}_getFirstTwig(r){const e=r.length-1,c=r[0];let h,o;if(e){const d=r[e],{leaves:[{type:p}]}=d;p===b.PSEUDO_ELEMENT_SELECTOR||p===b.ID_SELECTOR?(h="prev",o=d):(h="next",o=c)}else h="prev",o=c;return{find:h,twig:o}}_collectNodes(r){const e=this.#s.values();if(r===C||r===v){const c=new Set;let h=0;for(const{branch:o}of e){const{find:d,twig:p}=this._getFirstTwig(o),{nodes:u,pending:t}=this._findNodes(p,r);u.size?this.#r[h]=u:t?c.add(new Map([["index",h],["twig",p]])):this.#s[h].skip=!0,this.#s[h].find=d,h++}if(c.size){const{document:o,root:d}=this.#t,p=o.createNodeIterator(d,b.SHOW_ELEMENT);let u=p.nextNode();for(;u;){let t=!1;if(this.#e.nodeType===b.ELEMENT_NODE?t=(0,k.isSameOrDescendant)(u,this.#e):t=!0,t)for(const s of c){const{leaves:f}=s.get("twig");if(this._matchLeaves(f,u)){const i=s.get("index");this.#r[i].add(u)}}u=p.nextNode()}}}else{let c=0;for(const{branch:h}of e){const o=h[h.length-1],{nodes:d}=this._findNodes(o,r);d.size?this.#r[c]=d:this.#s[c].skip=!0,this.#s[c].find="prev",c++}}return[this.#s,this.#r]}_sortNodes(r){const e=[...r];return e.length>1&&e.sort((c,h)=>{const o=c.compareDocumentPosition(h);let d;return o&b.DOCUMENT_POSITION_PRECEDING||o&b.DOCUMENT_POSITION_CONTAINS?d=1:d=-1,d}),e}_matchNodes(r){const[...e]=this.#s,c=e.length;let h=new Set;for(let o=0;o<c;o++){const{branch:d,find:p,skip:u}=e[o],t=d.length;if(!u&&t){const s=this.#r[o],f=t-1;if(f===0)if((r===C||r===v)&&this.#e.nodeType===b.ELEMENT_NODE){for(const n of s)if(n!==this.#e&&(0,k.isSameOrDescendant)(n,this.#e)&&(h.add(n),r===v))break}else if(r===v){const[n]=this._sortNodes(s);h.add(n)}else{const n=[...h],i=[...s];h=new Set([...n,...i])}else if(p==="next"){let{combo:n}=d[0];for(const i of s){let a=new Set([i]);for(let l=1;l<t;l++){const{combo:m,leaves:N}=d[l],w=[];for(const y of a){const A={combo:n,leaves:N},M=this._matchCombinator(A,y,{find:p});M.size&&w.push(...M)}const E=new Set(w);if(E.size)if(l===f){if(r===v){const[y]=this._sortNodes(E);h.add(y)}else{const y=[...h],A=[...E];h=new Set([...y,...A])}break}else n=m,a=E;else break}}}else for(const n of s){let i=new Set([n]),a;for(let l=f-1;l>=0;l--){const m=d[l],N=[];for(const E of i){const y=this._matchCombinator(m,E,{find:p});y.size&&N.push(...y)}const w=new Set(N);if(w.size)if(a=!0,l===0){h.add(n);break}else i=w;else{a=!1;break}}if(a&&r!==C)break}}}return h}_find(r){return this._collectNodes(r),this._matchNodes(r)}matches(){if(this.#e.nodeType!==b.ELEMENT_NODE)throw new TypeError(`Unexpected node ${this.#e.nodeName}`);let r;try{r=this._find(S).has(this.#e)}catch(e){this._onError(e)}return!!r}closest(){if(this.#e.nodeType!==b.ELEMENT_NODE)throw new TypeError(`Unexpected node ${this.#e.nodeName}`);let r;try{const e=this._find(x);let c=this.#e;for(;c;){if(e.has(c)){r=c;break}c=c.parentNode}}catch(e){this._onError(e)}return r??null}querySelector(){let r;try{const e=this._find(v);e.delete(this.#e),e.size>1?[r]=this._sortNodes(e):e.size&&([r]=[...e])}catch(e){this._onError(e)}return r??null}querySelectorAll(){const r=[];try{const e=this._find(C);e.delete(this.#e),e.size>1&&this.#c?r.push(...this._sortNodes(e)):e.size&&r.push(...e)}catch(e){this._onError(e)}return r}}0&&(module.exports={Matcher});
|
|
1
|
+
var W=Object.create;var L=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var Z=(_,i)=>{for(var e in i)L(_,e,{get:i[e],enumerable:!0})},R=(_,i,e,c)=>{if(i&&typeof i=="object"||typeof i=="function")for(let d of Y(i))!K.call(_,d)&&d!==e&&L(_,d,{get:()=>i[d],enumerable:!(c=q(i,d))||c.enumerable});return _};var J=(_,i,e)=>(e=_!=null?W(X(_)):{},R(i||!_||!_.__esModule?L(e,"default",{value:_,enumerable:!0}):e,_)),Q=_=>R(L({},"__esModule",{value:!0}),_);var ie={};Z(ie,{Matcher:()=>se});module.exports=Q(ie);var P=J(require("is-potential-custom-element-name"),1),k=require("./dom-util.js"),g=require("./parser.js"),h=require("./constant.js");const D="[A-Z\\d]+",A=`(?:-${D})*`,$="all",T="first",S="lineal",v="self",U=/^(?:(?:fieldse|inpu|selec)t|button|opt(?:group|ion)|textarea)$/,C=/^(?:(?:(?:in|out)pu|selec)t|button|form|textarea)$/,B=/^a(?:rea)?$/,z=/^d(?:etails|ialog)$/,O=/^(?:checkbox|radio)$/,x=/^(?:(?:emai|te|ur)l|number|password|search|text)$/,H=/(?:(?:rang|tim)e|date(?:time-local)?|month|number|week)$/,F=/^(?:button|reset)$/,V=/^(?:image|submit)$/,I=/^(?:date(?:time-local)?|month|time|week)$/,j=/^(?:(?:ha|i)s|not|where)$/,ee=/^nth-(?:last-)?(?:child|of-type)$/,G=/^host(?:-context)?$/,te=new RegExp(`^(?:\\*-)?${D}${A}$`,"i");class se{#i;#r;#a;#e;#l;#t;#o;#c;#s;constructor(i,e,c={}){const{sort:d,warn:r}=c;this.#r=new Map([[h.PSEUDO_ELEMENT_SELECTOR,h.BIT_1],[h.ID_SELECTOR,h.BIT_10],[h.CLASS_SELECTOR,h.BIT_100],[h.TYPE_SELECTOR,h.BIT_1000],[h.ATTRIBUTE_SELECTOR,h.BIT_10000],[h.PSEUDO_CLASS_SELECTOR,h.BIT_100000]]),this.#a=new WeakMap,this.#o=i,this.#e=e,this.#c=!!d,this.#s=!!r,[this.#i,this.#l]=this._prepare(i),this.#t=this._getRoot(e)}_onError(i){if(i instanceof DOMException&&i.name===h.NOT_SUPPORTED_ERR)this.#s&&console.warn(i.message);else throw i}_getRoot(i=this.#e){let e,c;switch(i.nodeType){case h.DOCUMENT_NODE:{e=i,c=i;break}case h.DOCUMENT_FRAGMENT_NODE:{e=i.ownerDocument,c=i;break}case h.ELEMENT_NODE:{if((0,k.isSameOrDescendant)(i))e=i.ownerDocument,c=i.ownerDocument;else{let r=i;for(;r&&r.parentNode;)r=r.parentNode;e=r.ownerDocument,c=r}break}default:throw new TypeError(`Unexpected node ${i.nodeName}`)}const d=(0,k.isInShadowTree)(i);return{document:e,root:c,shadow:d}}_sortLeaves(i){const e=[...i];return e.length>1&&e.sort((c,d)=>{const{type:r}=c,{type:b}=d,m=this.#r.get(r),f=this.#r.get(b);let s;return m===f?s=0:m>f?s=1:s=-1,s}),e}_prepare(i=this.#o){const e=(0,g.parseSelector)(i),c=(0,g.walkAST)(e),d=[],r=[];let b=0;for(const[...m]of c){const f=[];let s=m.shift();if(s&&s.type!==h.COMBINATOR){const l=new Set;for(;s;){if(s.type===h.COMBINATOR){const[o]=m;if(o.type===h.COMBINATOR){const u=`Invalid combinator ${s.name}${o.name}`;throw new DOMException(u,h.SYNTAX_ERR)}f.push({combo:s,leaves:this._sortLeaves(l)}),l.clear()}else s&&l.add(s);if(m.length)s=m.shift();else{f.push({combo:null,leaves:this._sortLeaves(l)}),l.clear();break}}}d.push({branch:f,find:null,skip:!1}),r[b]=new Set,b++}return[d,r]}_collectNthChild(i,e){const{a:c,b:d,reverse:r,selector:b}=i,{parentNode:m}=e,f=new Set;let s;if(b&&(this.#a.has(b)?s=this.#a.get(b):(s=(0,g.walkAST)(b),this.#a.set(b,s))),m){const l=[...m.children],o=l.length;if(o){const u=new Set;if(s){const n=s.length;for(const t of l){let a;for(let p=0;p<n;p++){const N=s[p];if(a=this._matchLeaves(N,t),!a)break}a&&u.add(t)}}if(r&&l.reverse(),c===0){if(d>0&&d<=o){if(u.size)for(let n=0;n<o;n++){const t=l[n];if(u.has(t)){f.add(t);break}}else if(!b){const n=l[d-1];f.add(n)}}}else{let n=d-1;if(c>0)for(;n<0;)n+=c;if(n>=0&&n<o){let t=c>0?0:d-1;for(let a=0;a<o&&n>=0&&n<o;a++){const p=l[a];u.size?u.has(p)&&(t===n&&(f.add(p),n+=c),c>0?t++:t--):a===n&&(b||f.add(p),n+=c)}}}}}else{const{root:l}=this.#t;if(e===l&&l.nodeType===h.ELEMENT_NODE&&c+d===1)if(s){const o=s.length;let u;for(let n=0;n<o;n++){const t=s[n];if(u=this._matchLeaves(t,e),u)break}u&&f.add(e)}else f.add(e)}return f}_collectNthOfType(i,e){const{a:c,b:d,reverse:r}=i,{localName:b,parentNode:m,prefix:f}=e,s=new Set;if(m){const l=[...m.children],o=l.length;if(o)if(r&&l.reverse(),c===0){if(d>0&&d<=o){let u=0;for(let n=0;n<o;n++){const t=l[n],{localName:a,prefix:p}=t;if(a===b&&p===f){if(u===d-1){s.add(t);break}u++}}}}else{let u=d-1;if(c>0)for(;u<0;)u+=c;if(u>=0&&u<o){let n=c>0?0:d-1;for(let t=0;t<o;t++){const a=l[t],{localName:p,prefix:N}=a;if(p===b&&N===f){if(n===u&&(s.add(a),u+=c),u<0||u>=o)break;c>0?n++:n--}}}}}else{const{root:l}=this.#t;e===l&&l.nodeType===h.ELEMENT_NODE&&c+d===1&&s.add(e)}return s}_matchAnPlusB(i,e,c){const{nth:{a:d,b:r,name:b},selector:m}=i,f=(0,g.unescapeSelector)(b),s=new Map;f?(f==="even"?(s.set("a",2),s.set("b",0)):f==="odd"&&(s.set("a",2),s.set("b",1)),/last/.test(c)&&s.set("reverse",!0)):(typeof d=="string"&&/-?\d+/.test(d)?s.set("a",d*1):s.set("a",0),typeof r=="string"&&/-?\d+/.test(r)?s.set("b",r*1):s.set("b",0),/last/.test(c)&&s.set("reverse",!0));let l=new Set;if(s.has("a")&&s.has("b")){if(/^nth-(?:last-)?child$/.test(c)){m&&s.set("selector",m);const o=Object.fromEntries(s),u=this._collectNthChild(o,e);u.size&&(l=u)}else if(/^nth-(?:last-)?of-type$/.test(c)){const o=Object.fromEntries(s),u=this._collectNthOfType(o,e);u.size&&(l=u)}}return l}_matchPseudoElementSelector(i,e={}){const{forgive:c}=e;switch(i){case"after":case"backdrop":case"before":case"cue":case"cue-region":case"first-letter":case"first-line":case"file-selector-button":case"marker":case"placeholder":case"selection":case"target-text":{if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${i}`,h.NOT_SUPPORTED_ERR);break}case"part":case"slotted":{if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${i}()`,h.NOT_SUPPORTED_ERR);break}default:if(i.startsWith("-webkit-")){if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${i}`,h.NOT_SUPPORTED_ERR)}else if(!c)throw new DOMException(`Unknown pseudo-element ::${i}`,h.SYNTAX_ERR)}}_matchDirectionPseudoClass(i,e){const c=(0,g.unescapeSelector)(i.name),d=(0,k.getDirectionality)(e);let r;return c===d&&(r=e),r??null}_matchLanguagePseudoClass(i,e){const c=(0,g.unescapeSelector)(i.name);let d;if(c){if(c==="*")if(e.hasAttribute("lang"))e.getAttribute("lang")&&(d=e);else{let r=e.parentNode;for(;r;){if(r.hasAttribute("lang")){r.getAttribute("lang")&&(d=e);break}r=r.parentNode}}else if(te.test(c)){let r;if(/-/.test(c)){const[b,m,...f]=c.split("-");let s;b==="*"?s=`${D}${A}`:s=`${b}${A}`;const l=`-${m}${A}`,o=f.length;let u="";if(o)for(let n=0;n<o;n++)u+=`-${f[n]}${A}`;r=new RegExp(`^${s}${l}${u}$`,"i")}else r=new RegExp(`^${c}${A}$`,"i");if(e.hasAttribute("lang"))r.test(e.getAttribute("lang"))&&(d=e);else{let b=e.parentNode;for(;b;){if(b.hasAttribute("lang")){const m=b.getAttribute("lang");r.test(m)&&(d=e);break}b=b.parentNode}}}}return d??null}_matchHasPseudoFunc(i,e){let c;if(Array.isArray(i)&&i.length){const[d]=i,{type:r}=d;let b;r===h.COMBINATOR?b=i.shift():b={name:" ",type:h.COMBINATOR};const m=[];for(;i.length;){const[l]=i,{type:o}=l;if(o===h.COMBINATOR)break;m.push(i.shift())}const f={combo:b,leaves:m},s=this._matchCombinator(f,e,{find:"next"});if(s.size)if(i.length){for(const l of s)if(c=this._matchHasPseudoFunc(Object.assign([],i),l),c)break}else c=!0}return!!c}_matchLogicalPseudoFunc(i,e){const{astName:c="",branches:d=[],selector:r="",twigBranches:b=[]}=i;let m;if(c==="has")if(r.includes(":has("))m=null;else{const f=d.length;let s;for(let l=0;l<f;l++){const o=d[l];if(s=this._matchHasPseudoFunc(Object.assign([],o),e),s)break}s&&(m=e)}else{const f=/^(?:is|where)$/.test(c),s=b.length;let l;for(let o=0;o<s;o++){const u=b[o],n=u.length-1,{leaves:t}=u[n];if(l=this._matchLeaves(t,e,{forgive:f}),l&&n>0){let a=new Set([e]);for(let p=n-1;p>=0;p--){const N=u[p],w=[];for(const y of a){const E=this._matchCombinator(N,y,{forgive:f,find:"prev"});E.size&&w.push(...E)}if(w.length)if(p===0){l=!0;break}else a=new Set(w);else{l=!1;break}}}if(l)break}c==="not"?l||(m=e):l&&(m=e)}return m??null}_matchPseudoClassSelector(i,e,c={}){const{children:d}=i,{localName:r,parentNode:b}=e,{forgive:m}=c,f=(0,g.unescapeSelector)(i.name);let s=new Set;if(j.test(f)){let l;if(this.#a.has(i))l=this.#a.get(i);else{const u=(0,g.walkAST)(i),n=[],t=[];for(const[...a]of u){for(const y of a){const E=(0,g.generateCSS)(y);n.push(E)}const p=[],N=new Set;let w=a.shift();for(;w;)if(w.type===h.COMBINATOR?(p.push({combo:w,leaves:[...N]}),N.clear()):w&&N.add(w),a.length)w=a.shift();else{p.push({combo:null,leaves:[...N]}),N.clear();break}t.push(p)}l={astName:f,branches:u,twigBranches:t,selector:n.join(",")},this.#a.set(i,l)}const o=this._matchLogicalPseudoFunc(l,e);o&&s.add(o)}else if(Array.isArray(d)){const[l]=d;if(ee.test(f)){const o=this._matchAnPlusB(l,e,f);o.size&&(s=o)}else if(f==="dir"){const o=this._matchDirectionPseudoClass(l,e);o&&s.add(o)}else if(f==="lang"){const o=this._matchLanguagePseudoClass(l,e);o&&s.add(o)}else switch(f){case"current":case"nth-col":case"nth-last-col":{if(this.#s)throw new DOMException(`Unsupported pseudo-class :${f}()`,h.NOT_SUPPORTED_ERR);break}default:if(!m)throw new DOMException(`Unknown pseudo-class :${f}()`,h.SYNTAX_ERR)}}else{const{document:l,root:o}=this.#t,{documentElement:u}=l,n=new URL(l.URL);switch(f){case"any-link":case"link":{B.test(r)&&e.hasAttribute("href")&&s.add(e);break}case"local-link":{if(B.test(r)&&e.hasAttribute("href")){const t=new URL(e.getAttribute("href"),n.href);t.origin===n.origin&&t.pathname===n.pathname&&s.add(e)}break}case"visited":break;case"target":{e.id&&n.hash&&n.hash===`#${e.id}`&&(0,k.isSameOrDescendant)(e)&&s.add(e);break}case"target-within":{if(n.hash){const t=n.hash.replace(/^#/,"");let a=l.getElementById(t);for(;a;){if(a===e){s.add(e);break}a=a.parentNode}}break}case"scope":{this.#e.nodeType===h.ELEMENT_NODE?e===this.#e&&s.add(e):e===u&&s.add(e);break}case"focus":{e===l.activeElement&&s.add(e);break}case"focus-within":{let t=l.activeElement;for(;t;){if(t===e){s.add(e);break}t=t.parentNode}break}case"open":{z.test(r)&&e.hasAttribute("open")&&s.add(e);break}case"closed":{z.test(r)&&!e.hasAttribute("open")&&s.add(e);break}case"disabled":{if(U.test(r)||(0,P.default)(r))if(e.disabled||e.hasAttribute("disabled"))s.add(e);else{let t=b;for(;t&&t.localName!=="fieldset";)t=t.parentNode;t&&b.localName!=="legend"&&t.hasAttribute("disabled")&&s.add(e)}break}case"enabled":{(U.test(r)||(0,P.default)(r))&&!(e.disabled&&e.hasAttribute("disabled"))&&s.add(e);break}case"read-only":{switch(r){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&s.add(e);break}case"input":{(!e.type||x.test(e.type)||I.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&s.add(e);break}default:(0,k.isContentEditable)(e)||s.add(e)}break}case"read-write":{switch(r){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||s.add(e);break}case"input":{(!e.type||x.test(e.type)||I.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&s.add(e);break}default:(0,k.isContentEditable)(e)&&s.add(e)}break}case"placeholder-shown":{let t;r==="textarea"?t=e:r==="input"&&(e.hasAttribute("type")?x.test(e.getAttribute("type"))&&(t=e):t=e),t&&e.value===""&&e.hasAttribute("placeholder")&&e.getAttribute("placeholder").trim().length&&s.add(e);break}case"checked":{(e.checked&&r==="input"&&e.hasAttribute("type")&&O.test(e.getAttribute("type"))||e.selected&&r==="option")&&s.add(e);break}case"indeterminate":{if(e.indeterminate&&r==="input"&&e.type==="checkbox"||r==="progress"&&!e.hasAttribute("value"))s.add(e);else if(r==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let a=e.parentNode;for(;a&&a.localName!=="form";)a=a.parentNode;a||(a=u);const p=[...a.getElementsByTagName("input")];let N;for(const w of p)if(w.getAttribute("type")==="radio"&&(t?w.getAttribute("name")===t&&(N=!!w.checked):w.hasAttribute("name")||(N=!!w.checked),N))break;N||s.add(e)}break}case"default":{if(r==="button"&&!(e.hasAttribute("type")&&F.test(e.getAttribute("type")))||r==="input"&&e.hasAttribute("type")&&V.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const a=l.createNodeIterator(t,h.SHOW_ELEMENT);let p=a.nextNode();for(;p;){const N=p.localName;let w;if(N==="button"?w=!(p.hasAttribute("type")&&F.test(p.getAttribute("type"))):N==="input"&&(w=p.hasAttribute("type")&&V.test(p.getAttribute("type"))),w){p===e&&s.add(e);break}p=a.nextNode()}}}else if(r==="input"&&e.hasAttribute("type")&&O.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))s.add(e);else if(r==="option"){let t=!1,a=b;for(;a&&a.localName!=="datalist";){if(a.localName==="select"){(a.multiple||a.hasAttribute("multiple"))&&(t=!0);break}a=a.parentNode}if(t)(e.selected||e.hasAttribute("selected"))&&s.add(e);else{const p=b.firstElementChild,N=new Set;let w=p;for(;w;){if(w.selected||w.hasAttribute("selected")){N.add(w);break}w=w.nextElementSibling}N.size||N.add(p),N.has(e)&&s.add(e)}}break}case"valid":{if(C.test(r))e.checkValidity()&&s.add(e);else if(/^fieldset$/.test(r)){const t=l.createNodeIterator(e,h.SHOW_ELEMENT);let a=t.nextNode();a===e&&(a=t.nextNode());let p;for(;a&&!(C.test(a.localName)&&(p=a.checkValidity(),!p));)a=t.nextNode();p&&s.add(e)}break}case"invalid":{if(C.test(r))e.checkValidity()||s.add(e);else if(/^fieldset$/.test(r)){const t=l.createNodeIterator(e,h.SHOW_ELEMENT);let a=t.nextNode();a===e&&(a=t.nextNode());let p;for(;a&&!(C.test(a.localName)&&(p=a.checkValidity(),!p));)a=t.nextNode();p||s.add(e)}break}case"in-range":{r==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&H.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&s.add(e);break}case"out-of-range":{r==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&H.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&s.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(r))t=e;else if(r==="input")if(e.hasAttribute("type")){const a=e.getAttribute("type");(a==="file"||x.test(a)||O.test(a)||I.test(a))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&s.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(r))t=e;else if(r==="input")if(e.hasAttribute("type")){const a=e.getAttribute("type");(a==="file"||x.test(a)||O.test(a)||I.test(a))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&s.add(e);break}case"root":{e===u&&s.add(e);break}case"empty":{if(e.hasChildNodes()){const t=e.childNodes.values();let a;for(const p of t)if(a=p.nodeType!==h.ELEMENT_NODE&&p.nodeType!==h.TEXT_NODE,!a)break;a&&s.add(e)}else s.add(e);break}case"first-child":{(b&&e===b.firstElementChild||e===o&&o.nodeType===h.ELEMENT_NODE)&&s.add(e);break}case"last-child":{(b&&e===b.lastElementChild||e===o&&o.nodeType===h.ELEMENT_NODE)&&s.add(e);break}case"only-child":{(b&&e===b.firstElementChild&&e===b.lastElementChild||e===o&&o.nodeType===h.ELEMENT_NODE)&&s.add(e);break}case"first-of-type":{if(b){const[t]=this._collectNthOfType({a:0,b:1},e);t&&s.add(t)}else e===o&&o.nodeType===h.ELEMENT_NODE&&s.add(e);break}case"last-of-type":{if(b){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&s.add(t)}else e===o&&o.nodeType===h.ELEMENT_NODE&&s.add(e);break}case"only-of-type":{if(b){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[a]=this._collectNthOfType({a:0,b:1,reverse:!0},e);a===e&&s.add(e)}}else e===o&&o.nodeType===h.ELEMENT_NODE&&s.add(e);break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${f}`,h.NOT_SUPPORTED_ERR);break}case"active":case"autofill":case"blank":case"buffering":case"current":case"focus-visible":case"fullscreen":case"future":case"hover":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(this.#s)throw new DOMException(`Unsupported pseudo-class :${f}`,h.NOT_SUPPORTED_ERR);break}default:if(f.startsWith("-webkit-")){if(this.#s)throw new DOMException(`Unsupported pseudo-class :${f}`,h.NOT_SUPPORTED_ERR)}else if(!m)throw new DOMException(`Unknown pseudo-class :${f}`,h.SYNTAX_ERR)}}return s}_matchAttributeSelector(i,e){const{flags:c,matcher:d,name:r,value:b}=i;if(typeof c=="string"&&!/^[is]$/i.test(c)){const s=(0,g.generateCSS)(i);throw new DOMException(`Invalid selector ${s}`,h.SYNTAX_ERR)}const{attributes:m}=e;let f;if(m&&m.length){const{document:s}=this.#t;let l;s.contentType==="text/html"?typeof c=="string"&&/^s$/i.test(c)?l=!1:l=!0:typeof c=="string"&&/^i$/i.test(c)?l=!0:l=!1;let{name:o}=r;o=(0,g.unescapeSelector)(o),l&&(o=o.toLowerCase());const u=new Set;if(/\|/.test(o)){const{prefix:n,tagName:t}=(0,k.selectorToNodeProps)(o);for(let{name:a,value:p}of m)switch(l&&(a=a.toLowerCase(),p=p.toLowerCase()),n){case"":{t===a&&u.add(p);break}case"*":{/:/.test(a)?a.endsWith(`:${t}`)&&u.add(p):t===a&&u.add(p);break}default:if(/:/.test(a)){const[N,w]=a.split(":");n===N&&t===w&&(0,k.isNamespaceDeclared)(n,e)&&u.add(p)}}}else for(let{name:n,value:t}of m)if(l&&(n=n.toLowerCase(),t=t.toLowerCase()),/:/.test(n)){const[a,p]=n.split(":");if(a==="xml"&&p==="lang")continue;o===p&&u.add(t)}else o===n&&u.add(t);if(u.size){const{name:n,value:t}=b||{};let a;switch(n?l?a=n.toLowerCase():a=n:t?l?a=t.toLowerCase():a=t:t===""&&(a=t),d){case"=":{typeof a=="string"&&u.has(a)&&(f=e);break}case"~=":{if(a&&typeof a=="string"){for(const p of u)if(new Set(p.split(/\s+/)).has(a)){f=e;break}}break}case"|=":{if(a&&typeof a=="string"){let p;for(const N of u)if(N===a||N.startsWith(`${a}-`)){p=N;break}p&&(f=e)}break}case"^=":{if(a&&typeof a=="string"){let p;for(const N of u)if(N.startsWith(`${a}`)){p=N;break}p&&(f=e)}break}case"$=":{if(a&&typeof a=="string"){let p;for(const N of u)if(N.endsWith(`${a}`)){p=N;break}p&&(f=e)}break}case"*=":{if(a&&typeof a=="string"){let p;for(const N of u)if(N.includes(`${a}`)){p=N;break}p&&(f=e)}break}case null:default:f=e}}}return f??null}_matchClassSelector(i,e){const c=(0,g.unescapeSelector)(i.name);let d;return e.classList.contains(c)&&(d=e),d??null}_matchIDSelector(i,e){const c=(0,g.unescapeSelector)(i.name),{id:d}=e;let r;return c===d&&(r=e),r??null}_matchTypeSelector(i,e){const c=(0,g.unescapeSelector)(i.name),{localName:d,prefix:r}=e,{document:b}=this.#t;let{prefix:m,tagName:f}=(0,k.selectorToNodeProps)(c,e);b.contentType==="text/html"&&(m=m.toLowerCase(),f=f.toLowerCase());let s,l;/:/.test(d)?[s,l]=d.split(":"):(s=r||"",l=d);let o;return m===""&&s===""?e.namespaceURI===null&&(f==="*"||f===l)&&(o=e):m==="*"?(f==="*"||f===l)&&(o=e):m===s&&(0,k.isNamespaceDeclared)(m,e)&&(f==="*"||f===l)&&(o=e),o??null}_matchShadowHostPseudoClass(i,e){const{children:c}=i,d=(0,g.unescapeSelector)(i.name);let r;if(Array.isArray(c)){const[b]=(0,g.walkAST)(c[0]),[...m]=b,{host:f}=e;if(d==="host"){let s;for(const l of m){const{type:o}=l;if(o===h.COMBINATOR){const u=(0,g.generateCSS)(i);throw new DOMException(`Invalid selector ${u}`,h.SYNTAX_ERR)}if(s=this._matchSelector(l,f).has(f),!s)break}s&&(r=e)}else if(d==="host-context"){let s=f,l;for(;s;){for(const o of m){const{type:u}=o;if(u===h.COMBINATOR){const n=(0,g.generateCSS)(i);throw new DOMException(`Invalid selector ${n}`,h.SYNTAX_ERR)}if(l=this._matchSelector(o,s).has(s),!l)break}if(l)break;s=s.parentNode}l&&(r=e)}}else d==="host"&&(r=e);return r??null}_matchSelector(i,e,c){const{type:d}=i,r=(0,g.unescapeSelector)(i.name),{shadow:b}=this.#t;let m=new Set;if(e.nodeType===h.ELEMENT_NODE)switch(d){case h.ATTRIBUTE_SELECTOR:{const f=this._matchAttributeSelector(i,e);f&&m.add(f);break}case h.CLASS_SELECTOR:{const f=this._matchClassSelector(i,e);f&&m.add(f);break}case h.ID_SELECTOR:{const f=this._matchIDSelector(i,e);f&&m.add(f);break}case h.PSEUDO_CLASS_SELECTOR:{const f=this._matchPseudoClassSelector(i,e,c);f.size&&(m=f);break}case h.PSEUDO_ELEMENT_SELECTOR:{this._matchPseudoElementSelector(r,c);break}case h.TYPE_SELECTOR:default:{const f=this._matchTypeSelector(i,e);f&&m.add(f)}}else if(b&&d===h.PSEUDO_CLASS_SELECTOR&&e.nodeType===h.DOCUMENT_FRAGMENT_NODE){if(r!=="has"&&j.test(r)){const f=this._matchPseudoClassSelector(i,e,c);f.size&&(m=f)}else if(G.test(r)){const f=this._matchShadowHostPseudoClass(i,e);f&&m.add(f)}}return m}_matchLeaves(i,e,c){let d;for(const r of i)if(d=this._matchSelector(r,e,c).has(e),!d)break;return!!d}_findDescendantNodes(i,e){const[c,...d]=i,{type:r}=c,b=(0,g.unescapeSelector)(c.name),m=d.length>0,f=new Set;let s=!1;switch(r){case h.ID_SELECTOR:{const{root:l}=this.#t;if(l.nodeType===h.ELEMENT_NODE)s=!0;else{const o=l.getElementById(b);if(o&&o!==e){const u=(0,k.isSameOrDescendant)(o,e);let n;u&&(n=o),n&&(m?this._matchLeaves(d,n)&&f.add(n):f.add(n))}}break}case h.PSEUDO_ELEMENT_SELECTOR:{this._matchPseudoElementSelector(b);break}default:s=!0}return{nodes:f,pending:s}}_matchCombinator(i,e,c={}){const{combo:d,leaves:r}=i,{name:b}=d,{find:m,forgive:f}=c;let s=new Set;if(m==="next")switch(b){case"+":{const l=e.nextElementSibling;l&&this._matchLeaves(r,l,{forgive:f})&&s.add(l);break}case"~":{let l=e.nextElementSibling;for(;l;)this._matchLeaves(r,l,{forgive:f})&&s.add(l),l=l.nextElementSibling;break}case">":{const l=[...e.children];for(const o of l)this._matchLeaves(r,o,{forgive:f})&&s.add(o);break}case" ":default:{const{nodes:l,pending:o}=this._findDescendantNodes(r,e);if(l.size)s=l;else if(o){const{document:u}=this.#t,n=u.createNodeIterator(e,h.SHOW_ELEMENT);let t=n.nextNode();for(t===e&&(t=n.nextNode());t;)this._matchLeaves(r,t,{forgive:f})&&s.add(t),t=n.nextNode()}}}else switch(b){case"+":{const l=e.previousElementSibling;l&&this._matchLeaves(r,l,{forgive:f})&&s.add(l);break}case"~":{const l=[];let o=e.previousElementSibling;for(;o;)this._matchLeaves(r,o,{forgive:f})&&l.push(o),o=o.previousElementSibling;l.length&&(s=new Set(l.reverse()));break}case">":{const l=e.parentNode;l&&this._matchLeaves(r,l,{forgive:f})&&s.add(l);break}case" ":default:{const l=[];let o=e.parentNode;for(;o;)this._matchLeaves(r,o,{forgive:f})&&l.push(o),o=o.parentNode;l.length&&(s=new Set(l.reverse()))}}return s}_findNodes(i,e){const{leaves:[c,...d]}=i,{type:r}=c,b=(0,g.unescapeSelector)(c.name),m=d.length>0,{document:f,root:s,shadow:l}=this.#t;let o=new Set,u=!1;switch(r){case h.ID_SELECTOR:{let n;if(e===v)this._matchLeaves([c],this.#e)&&(n=this.#e);else if(e===S){let t=this.#e;for(;t;){if(this._matchLeaves([c],t)){n=t;break}t=t.parentNode}}else s.nodeType===h.ELEMENT_NODE?u=!0:n=s.getElementById(b);n&&(m?this._matchLeaves(d,n)&&o.add(n):o.add(n));break}case h.CLASS_SELECTOR:{const n=[];if(e===v)this.#e.nodeType===h.ELEMENT_NODE&&this.#e.classList.contains(b)&&n.push(this.#e);else if(e===S){let t=this.#e;for(;t&&t.nodeType===h.ELEMENT_NODE;)t.classList.contains(b)&&n.push(t),t=t.parentNode}else if(s.nodeType===h.DOCUMENT_FRAGMENT_NODE){const t=[...s.children];for(const a of t){a.classList.contains(b)&&n.push(a);const p=[...a.getElementsByClassName(b)];n.push(...p)}}else{const t=[...s.getElementsByClassName(b)];n.push(...t)}if(n.length)if(m)for(const t of n)this._matchLeaves(d,t)&&o.add(t);else o=new Set(n);break}case h.TYPE_SELECTOR:{const n=[];if(e===v)this.#e.nodeType===h.ELEMENT_NODE&&this._matchLeaves([c],this.#e)&&n.push(this.#e);else if(e===S){let t=this.#e;for(;t&&t.nodeType===h.ELEMENT_NODE;)this._matchLeaves([c],t)&&n.push(t),t=t.parentNode}else if(f.contentType!=="text/html"||/[*|]/.test(b))u=!0;else if(s.nodeType===h.DOCUMENT_FRAGMENT_NODE){const t=b.toLowerCase(),a=[...s.children];for(const p of a){p.localName===t&&n.push(p);const N=[...p.getElementsByTagName(b)];n.push(...N)}}else{const t=[...s.getElementsByTagName(b)];n.push(...t)}if(n.length)if(m)for(const t of n)this._matchLeaves(d,t)&&o.add(t);else o=new Set(n);break}case h.PSEUDO_ELEMENT_SELECTOR:{this._matchPseudoElementSelector(b);break}default:{const n=[];if(e!==S&&G.test(b)){if(l&&this.#e.nodeType===h.DOCUMENT_FRAGMENT_NODE){const t=this._matchShadowHostPseudoClass(c,this.#e);t&&n.push(t)}}else if(e===v)this._matchLeaves([c],this.#e)&&n.push(this.#e);else if(e===S){let t=this.#e;for(;t;)this._matchLeaves([c],t)&&n.push(t),t=t.parentNode}else u=!0;if(n.length)if(m)for(const t of n)this._matchLeaves(d,t)&&o.add(t);else o=new Set(n)}}return{nodes:o,pending:u}}_getFirstTwig(i){const e=i.length-1,c=i[0];let d,r;if(e){const b=i[e],{leaves:[{type:m}]}=b;m===h.PSEUDO_ELEMENT_SELECTOR||m===h.ID_SELECTOR?(d="prev",r=b):(d="next",r=c)}else d="prev",r=c;return{find:d,twig:r}}_collectNodes(i){const e=this.#i.values();if(i===$||i===T){const c=new Set;let d=0;for(const{branch:r}of e){const{find:b,twig:m}=this._getFirstTwig(r),{nodes:f,pending:s}=this._findNodes(m,i);f.size?this.#l[d]=f:s?c.add(new Map([["index",d],["twig",m]])):this.#i[d].skip=!0,this.#i[d].find=b,d++}if(c.size){const{document:r,root:b}=this.#t,m=r.createNodeIterator(b,h.SHOW_ELEMENT);let f=m.nextNode();for(;f;){let s=!1;if(this.#e.nodeType===h.ELEMENT_NODE?s=(0,k.isSameOrDescendant)(f,this.#e):s=!0,s)for(const l of c){const{leaves:o}=l.get("twig");if(this._matchLeaves(o,f)){const n=l.get("index");this.#l[n].add(f)}}f=m.nextNode()}}}else{let c=0;for(const{branch:d}of e){const r=d[d.length-1],{nodes:b}=this._findNodes(r,i);b.size?this.#l[c]=b:this.#i[c].skip=!0,this.#i[c].find="prev",c++}}return[this.#i,this.#l]}_sortNodes(i){const e=[...i];return e.length>1&&e.sort((c,d)=>{const r=c.compareDocumentPosition(d);let b;return r&h.DOCUMENT_POSITION_PRECEDING||r&h.DOCUMENT_POSITION_CONTAINS?b=1:b=-1,b}),e}_matchNodes(i){const[...e]=this.#i,c=e.length;let d=new Set;for(let r=0;r<c;r++){const{branch:b,find:m,skip:f}=e[r],s=b.length;if(!f&&s){const l=this.#l[r],o=s-1;if(o===0)if((i===$||i===T)&&this.#e.nodeType===h.ELEMENT_NODE){for(const u of l)if(u!==this.#e&&(0,k.isSameOrDescendant)(u,this.#e)&&(d.add(u),i===T))break}else if(i===T){const[u]=this._sortNodes(l);d.add(u)}else{const u=[...d],n=[...l];d=new Set([...u,...n])}else if(m==="next"){let{combo:u}=b[0];for(const n of l){let t=new Set([n]);for(let a=1;a<s;a++){const{combo:p,leaves:N}=b[a],w=[];for(const y of t){const E={combo:u,leaves:N},M=this._matchCombinator(E,y,{find:m});M.size&&w.push(...M)}if(w.length)if(a===o){if(i===T){const[y]=this._sortNodes(w);d.add(y)}else{const y=[...d];d=new Set([...y,...w])}break}else u=p,t=new Set(w);else break}}}else for(const u of l){let n=new Set([u]),t;for(let a=o-1;a>=0;a--){const p=b[a],N=[];for(const w of n){const y=this._matchCombinator(p,w,{find:m});y.size&&N.push(...y)}if(N.length)if(t=!0,a===0){d.add(u);break}else n=new Set(N);else{t=!1;break}}if(t&&i!==$)break}}}return d}_find(i){return this._collectNodes(i),this._matchNodes(i)}matches(){if(this.#e.nodeType!==h.ELEMENT_NODE)throw new TypeError(`Unexpected node ${this.#e.nodeName}`);let i;try{i=this._find(v).has(this.#e)}catch(e){this._onError(e)}return!!i}closest(){if(this.#e.nodeType!==h.ELEMENT_NODE)throw new TypeError(`Unexpected node ${this.#e.nodeName}`);let i;try{const e=this._find(S);let c=this.#e;for(;c;){if(e.has(c)){i=c;break}c=c.parentNode}}catch(e){this._onError(e)}return i??null}querySelector(){let i;try{const e=this._find(T);e.delete(this.#e),e.size>1?[i]=this._sortNodes(e):e.size&&([i]=[...e])}catch(e){this._onError(e)}return i??null}querySelectorAll(){const i=[];try{const e=this._find($);e.delete(this.#e),e.size>1&&this.#c?i.push(...this._sortNodes(e)):e.size&&i.push(...e)}catch(e){this._onError(e)}return i}}0&&(module.exports={Matcher});
|
|
2
2
|
//# sourceMappingURL=matcher.js.map
|