@asamuzakjp/dom-selector
Advanced tools
Comparing version 4.4.2 to 4.4.3
@@ -1,2 +0,2 @@ | ||
var O=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var H=(s,t)=>{for(var c in t)O(s,c,{get:t[c],enumerable:!0})},f=(s,t,c,P)=>{if(t&&typeof t=="object"||typeof t=="function")for(let E of u(t))!Y.call(s,E)&&E!==c&&O(s,E,{get:()=>t[E],enumerable:!(P=d(t,E))||P.enumerable});return s};var m=s=>f(O({},"__esModule",{value:!0}),s);var vt={};H(vt,{ALPHA_NUM:()=>$,ANB:()=>M,AN_PLUS_B:()=>w,BIT_01:()=>ot,BIT_02:()=>et,BIT_04:()=>st,BIT_08:()=>rt,BIT_16:()=>Et,BIT_32:()=>nt,BIT_FFFF:()=>_t,BIT_HYPHEN:()=>xt,COMBINATOR:()=>X,COMBO_A:()=>R,COMBO_B:()=>S,COMPLEX_A:()=>C,COMPLEX_B:()=>A,COMPLEX_C:()=>N,COMPLEX_D:()=>D,COMPOUND_A:()=>r,COMPOUND_B:()=>T,COMPOUND_C:()=>L,COMPOUND_D:()=>I,DIGIT:()=>p,DOCUMENT_FRAGMENT_NODE:()=>Lt,DOCUMENT_NODE:()=>Ct,DOCUMENT_POSITION_CONTAINED_BY:()=>At,DOCUMENT_POSITION_CONTAINS:()=>St,DOCUMENT_POSITION_PRECEDING:()=>Nt,DUO:()=>ct,ELEMENT_NODE:()=>Tt,EMPTY:()=>h,HEX:()=>pt,IDENTIFIER:()=>g,LANG_PART:()=>G,LOGICAL_COMPLEX_A:()=>U,LOGICAL_COMPLEX_B:()=>F,LOGICAL_COMPOUND:()=>a,LOGICAL_KEY:()=>e,NESTED_LOGICAL_A:()=>l,NESTED_LOGICAL_B:()=>i,NESTED_LOGICAL_C:()=>B,NOT_SUPPORTED_ERR:()=>b,NTH:()=>W,N_ST:()=>n,N_TH:()=>_,RAW:()=>y,REG_ANCHOR:()=>lt,REG_CHILD_INDEXED:()=>at,REG_DIR:()=>it,REG_FORM:()=>Ut,REG_FORM_CTRL:()=>Bt,REG_FORM_VALID:()=>Ft,REG_INTERACT:()=>dt,REG_LANG:()=>ut,REG_LOGICAL_COMPLEX_A:()=>Yt,REG_LOGICAL_COMPLEX_B:()=>Ht,REG_LOGICAL_COMPOUND:()=>ft,REG_LOGICAL_KEY:()=>mt,REG_LOGICAL_PSEUDO:()=>wt,REG_SHADOW_HOST:()=>Xt,REG_SHADOW_MODE:()=>ht,REG_SHADOW_PSEUDO:()=>gt,REG_TYPE_CHECK:()=>bt,REG_TYPE_DATE:()=>Wt,REG_TYPE_RANGE:()=>yt,REG_TYPE_RESET:()=>Kt,REG_TYPE_SUBMIT:()=>kt,REG_TYPE_TEXT:()=>Zt,SELECTOR:()=>K,SELECTOR_ATTR:()=>k,SELECTOR_CLASS:()=>Z,SELECTOR_ID:()=>v,SELECTOR_LIST:()=>z,SELECTOR_PSEUDO_CLASS:()=>V,SELECTOR_PSEUDO_ELEMENT:()=>j,SELECTOR_TYPE:()=>q,SHOW_ALL:()=>It,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Pt,SHOW_ELEMENT:()=>Gt,STRING:()=>J,SUB_TYPE:()=>x,SYNTAX_ERR:()=>Q,TAG_TYPE:()=>o,TEXT_NODE:()=>Rt,TYPE_FROM:()=>Ot,TYPE_TO:()=>$t,U_FFFD:()=>tt,WALKER_FILTER:()=>Mt});module.exports=m(vt);const w="AnPlusB",X="Combinator",h="__EMPTY__",g="Identifier",b="NotSupportedError",W="Nth",y="Raw",K="Selector",k="AttributeSelector",Z="ClassSelector",v="IdSelector",z="SelectorList",V="PseudoClassSelector",j="PseudoElementSelector",q="TypeSelector",J="String",Q="SyntaxError",tt="\uFFFD",ot=1,et=2,st=4,rt=8,Et=16,nt=32,_t=65535,xt=45,ct=2,pt=16,Ot=8,$t=-1,Tt=1,Rt=3,Ct=9,Lt=11,Nt=2,St=8,At=16,It=4294967295,Dt=256,Pt=1024,Gt=1,Mt=1281,$="[A-Z\\d]+",G=`(?:-${$})*`,n="(?:first|last|only)-(?:child|of-type)",p="(?:0|[1-9]\\d*)",M=`[+-]?(?:${p}n?|n)|(?:[+-]?${p})?n\\s*[+-]\\s*${p}`,_=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${M})\\s*\\)`,e="(?:is|not|where)",x="\\[[^\\]]+\\]|[#.:][\\w-]+",o="\\*|[A-Za-z][\\w-]*",r=`(?:${o}|(?:${o})?(?:${x})+)`,l=`:${e}\\(\\s*${r}(?:\\s*,\\s*${r})*\\s*\\)`,T=`(?:${o}|(?:${o})?(?:${x}|${l})+)`,a=`${e}\\(\\s*${T}(?:\\s*,\\s*${T})*\\s*\\)`,R="\\s?[\\s>~+]\\s?",C=`${r}(?:${R}${r})*`,i=`:${e}\\(\\s*${C}(?:\\s*,\\s*${C})*\\s*\\)`,L=`(?:${o}|(?:${o})?(?:${x}|${i})+)`,N=`${L}(?:${R}${L})*`,U=`${e}\\(\\s*${N}(?:\\s*,\\s*${N})*\\s*\\)`,S="\\s?[~+]\\s?",A=`${r}(?:${S}${r})*`,B=`:${e}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,I=`(?:${o}|(?:${o})?(?:${x}|${B})+)`,D=`${I}(?:${S}${I})*`,F=`${e}\\(\\s*${D}(?:\\s*,\\s*${D})*\\s*\\)`,lt=/^a(?:rea)?$/,at=new RegExp(`:(?!${n}|${_})`),it=/^(?:ltr|rtl)$/,Ut=/^(?:(?:fieldse|inpu|selec)t|button|form|textarea)$/,Bt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Ft=/^(?:button|form|input|select|textarea)$/,dt=/^(?:details|dialog)$/,ut=new RegExp(`^(?:\\*-)?${$}${G}$`,"i"),Yt=new RegExp(`:(?!${n}|${_}|${U})`),Ht=new RegExp(`:(?!${n}|${_}|${F})`),ft=new RegExp(`:(?!${n}|${_}|${a})`),mt=new RegExp(`:${e}\\(`),wt=/^(?:has|is|not|where)$/,Xt=/^host(?:-context)?$/,ht=/^(?:close|open)$/,gt=/^part|slotted$/,bt=/^(?:checkbox|radio)$/,Wt=/^(?:date(?:time-local)?|month|time|week)$/,yt=/(?:date(?:time-local)?|month|number|range|time|week)$/,Kt=/^(?:button|reset)$/,kt=/^(?:image|submit)$/,Zt=/^(?: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,COMBINATOR,COMBO_A,COMBO_B,COMPLEX_A,COMPLEX_B,COMPLEX_C,COMPLEX_D,COMPOUND_A,COMPOUND_B,COMPOUND_C,COMPOUND_D,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,LANG_PART,LOGICAL_COMPLEX_A,LOGICAL_COMPLEX_B,LOGICAL_COMPOUND,LOGICAL_KEY,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NESTED_LOGICAL_C,NOT_SUPPORTED_ERR,NTH,N_ST,N_TH,RAW,REG_ANCHOR,REG_CHILD_INDEXED,REG_DIR,REG_FORM,REG_FORM_CTRL,REG_FORM_VALID,REG_INTERACT,REG_LANG,REG_LOGICAL_COMPLEX_A,REG_LOGICAL_COMPLEX_B,REG_LOGICAL_COMPOUND,REG_LOGICAL_KEY,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TYPE_CHECK,REG_TYPE_DATE,REG_TYPE_RANGE,REG_TYPE_RESET,REG_TYPE_SUBMIT,REG_TYPE_TEXT,SELECTOR,SELECTOR_ATTR,SELECTOR_CLASS,SELECTOR_ID,SELECTOR_LIST,SELECTOR_PSEUDO_CLASS,SELECTOR_PSEUDO_ELEMENT,SELECTOR_TYPE,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,STRING,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER}); | ||
var T=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var f=(s,t)=>{for(var p in t)T(s,p,{get:t[p],enumerable:!0})},X=(s,t,p,M)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of w(t))!H.call(s,n)&&n!==p&&T(s,n,{get:()=>t[n],enumerable:!(M=u(t,n))||M.enumerable});return s};var m=s=>X(T({},"__esModule",{value:!0}),s);var oo={};f(oo,{ALPHA_NUM:()=>R,ANB:()=>a,AN_PLUS_B:()=>g,BIT_01:()=>st,BIT_02:()=>Et,BIT_04:()=>rt,BIT_08:()=>nt,BIT_16:()=>_t,BIT_32:()=>xt,BIT_FFFF:()=>pt,BIT_HYPHEN:()=>ct,COMBINATOR:()=>h,COMBO_A:()=>O,COMBO_B:()=>$,COMPLEX_A:()=>L,COMPLEX_B:()=>A,COMPLEX_C:()=>P,COMPLEX_D:()=>D,COMPOUND:()=>E,COMPOUND_A:()=>N,COMPOUND_B:()=>G,COMPOUND_C:()=>I,COMPOUND_I:()=>S,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>Nt,DOCUMENT_NODE:()=>At,DOCUMENT_POSITION_CONTAINED_BY:()=>St,DOCUMENT_POSITION_CONTAINS:()=>It,DOCUMENT_POSITION_PRECEDING:()=>Gt,DUO:()=>Ot,ELEMENT_NODE:()=>Ct,EMPTY:()=>b,HEX:()=>$t,IDENTIFIER:()=>W,LANG_PART:()=>l,LOGICAL_COMPLEX_A:()=>d,LOGICAL_COMPLEX_B:()=>F,LOGICAL_COMPOUND:()=>Y,LOGICAL_KEY:()=>e,NESTED_LOGICAL_A:()=>i,NESTED_LOGICAL_B:()=>U,NESTED_LOGICAL_C:()=>B,NOT_SUPPORTED_ERR:()=>y,NTH:()=>K,N_ST:()=>_,N_TH:()=>x,RAW:()=>Z,REG_ANCHOR:()=>it,REG_CHILD_INDEXED:()=>Ut,REG_COMPLEX_A:()=>Bt,REG_COMPLEX_B:()=>dt,REG_DIR:()=>Ft,REG_FORM:()=>Yt,REG_FORM_CTRL:()=>ut,REG_FORM_VALID:()=>wt,REG_HEX:()=>Ht,REG_INTERACT:()=>ft,REG_INVALID_SELECTOR:()=>Xt,REG_LANG:()=>mt,REG_LANG_QUOTED:()=>gt,REG_LOGICAL_COMPLEX_A:()=>ht,REG_LOGICAL_COMPLEX_B:()=>bt,REG_LOGICAL_COMPOUND:()=>Wt,REG_LOGICAL_EMPTY:()=>yt,REG_LOGICAL_KEY:()=>Kt,REG_LOGICAL_PSEUDO:()=>Zt,REG_SHADOW_HOST:()=>kt,REG_SHADOW_MODE:()=>zt,REG_SHADOW_PSEUDO:()=>Vt,REG_TYPE_CHECK:()=>vt,REG_TYPE_DATE:()=>Qt,REG_TYPE_RANGE:()=>jt,REG_TYPE_RESET:()=>qt,REG_TYPE_SUBMIT:()=>Jt,REG_TYPE_TEXT:()=>to,SELECTOR:()=>k,SELECTOR_ATTR:()=>z,SELECTOR_CLASS:()=>V,SELECTOR_ID:()=>v,SELECTOR_LIST:()=>Q,SELECTOR_PSEUDO_CLASS:()=>j,SELECTOR_PSEUDO_ELEMENT:()=>q,SELECTOR_TYPE:()=>J,SHOW_ALL:()=>Pt,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Mt,SHOW_ELEMENT:()=>lt,STRING:()=>tt,SUB_TYPE:()=>r,SYNTAX_ERR:()=>ot,TAG_TYPE:()=>o,TAG_TYPE_I:()=>C,TEXT_NODE:()=>Lt,TYPE_FROM:()=>Tt,TYPE_TO:()=>Rt,U_FFFD:()=>et,WALKER_FILTER:()=>at});module.exports=m(oo);const g="AnPlusB",h="Combinator",b="__EMPTY__",W="Identifier",y="NotSupportedError",K="Nth",Z="Raw",k="Selector",z="AttributeSelector",V="ClassSelector",v="IdSelector",Q="SelectorList",j="PseudoClassSelector",q="PseudoElementSelector",J="TypeSelector",tt="String",ot="SyntaxError",et="\uFFFD",st=1,Et=2,rt=4,nt=8,_t=16,xt=32,pt=65535,ct=45,Ot=2,$t=16,Tt=8,Rt=-1,Ct=1,Lt=3,At=9,Nt=11,Gt=2,It=8,St=16,Pt=4294967295,Dt=256,Mt=1024,lt=1,at=1281,R="[A-Z\\d]+",c="(?:0|[1-9]\\d*)",l=`(?:-${R})*`,_="(?:first|last|only)-(?:child|of-type)",a=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,x=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${a})\\s*\\)`,r="\\[[^\\]]+\\]|[#.:][\\w-]+",o="\\*|[A-Za-z][\\w-]*",C="\\*|[A-Z][\\w-]*",e="(?:is|not|where)",E=`(?:${o}|(?:${o})?(?:${r})+)`,O="\\s?[\\s>~+]\\s?",$="\\s?[~+]\\s?",L=`${E}(?:${O}${E})*`,A=`${E}(?:${$}${E})*`,i=`:${e}\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,U=`:${e}\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,B=`:${e}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,N=`(?:${o}|(?:${o})?(?:${r}|${i})+)`,G=`(?:${o}|(?:${o})?(?:${r}|${U})+)`,I=`(?:${o}|(?:${o})?(?:${r}|${B})+)`,S=`(?:${C}|(?:${C})?(?:${r})+)`,P=`${G}(?:${O}${G})*`,D=`${I}(?:${$}${I})*`,d=`${e}\\(\\s*${P}(?:\\s*,\\s*${P})*\\s*\\)`,F=`${e}\\(\\s*${D}(?:\\s*,\\s*${D})*\\s*\\)`,Y=`${e}\\(\\s*${N}(?:\\s*,\\s*${N})*\\s*\\)`,it=/^a(?:rea)?$/,Ut=new RegExp(`:(?!${_}|${x})`),Bt=new RegExp(`${O}${S}`,"i"),dt=new RegExp(`${$}${S}`,"i"),Ft=/^(?:ltr|rtl)$/,Yt=/^(?:(?:fieldse|inpu|selec)t|button|form|textarea)$/,ut=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,wt=/^(?:button|form|input|select|textarea)$/,Ht=/^([\da-f]{1,6}\s?)/i,ft=/^(?:details|dialog)$/,Xt=/^$|^\s*>|,\s*$/,mt=new RegExp(`^(?:\\*-)?${R}${l}$`,"i"),gt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,ht=new RegExp(`:(?!${_}|${x}|${d})`),bt=new RegExp(`:(?!${_}|${x}|${F})`),Wt=new RegExp(`:(?!${_}|${x}|${Y})`),yt=/(:(is|where)\(\s*\))/,Kt=new RegExp(`:${e}\\(`),Zt=/^(?:has|is|not|where)$/,kt=/^host(?:-context)?$/,zt=/^(?:close|open)$/,Vt=/^part|slotted$/,vt=/^(?:checkbox|radio)$/,Qt=/^(?:date(?:time-local)?|month|time|week)$/,jt=/(?:date(?:time-local)?|month|number|range|time|week)$/,qt=/^(?:button|reset)$/,Jt=/^(?:image|submit)$/,to=/^(?: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,COMBINATOR,COMBO_A,COMBO_B,COMPLEX_A,COMPLEX_B,COMPLEX_C,COMPLEX_D,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_C,COMPOUND_I,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,LANG_PART,LOGICAL_COMPLEX_A,LOGICAL_COMPLEX_B,LOGICAL_COMPOUND,LOGICAL_KEY,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NESTED_LOGICAL_C,NOT_SUPPORTED_ERR,NTH,N_ST,N_TH,RAW,REG_ANCHOR,REG_CHILD_INDEXED,REG_COMPLEX_A,REG_COMPLEX_B,REG_DIR,REG_FORM,REG_FORM_CTRL,REG_FORM_VALID,REG_HEX,REG_INTERACT,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_COMPLEX_A,REG_LOGICAL_COMPLEX_B,REG_LOGICAL_COMPOUND,REG_LOGICAL_EMPTY,REG_LOGICAL_KEY,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TYPE_CHECK,REG_TYPE_DATE,REG_TYPE_RANGE,REG_TYPE_RESET,REG_TYPE_SUBMIT,REG_TYPE_TEXT,SELECTOR,SELECTOR_ATTR,SELECTOR_CLASS,SELECTOR_ID,SELECTOR_LIST,SELECTOR_PSEUDO_CLASS,SELECTOR_PSEUDO_ELEMENT,SELECTOR_TYPE,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,STRING,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER}); | ||
//# sourceMappingURL=constant.js.map |
@@ -1,2 +0,2 @@ | ||
var W=Object.create;var P=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var V=(y,l)=>{for(var e in l)P(y,e,{get:l[e],enumerable:!0})},I=(y,l,e,n)=>{if(l&&typeof l=="object"||typeof l=="function")for(let r of j(l))!q.call(y,r)&&r!==e&&P(y,r,{get:()=>l[r],enumerable:!(n=B(l,r))||n.enumerable});return y};var U=(y,l,e)=>(e=y!=null?W(Y(y)):{},I(l||!y||!y.__esModule?P(e,"default",{value:y,enumerable:!0}):e,y)),X=y=>I(P({},"__esModule",{value:!0}),y);var Q={};V(Q,{Finder:()=>K});module.exports=X(Q);var M=U(require("is-potential-custom-element-name"),1),$=U(require("@asamuzakjp/nwsapi"),1),S=require("./dom-util.js"),O=require("./matcher.js"),k=require("./parser.js"),c=require("./constant.js");const v="next",x="prev",L="all",g="first",C="lineal",R="self";class K{#a;#r;#c;#t;#h;#d;#p;#e;#b;#N;#f;#o;#w;#s;#u;#m;#n;#_;#i;#l;constructor(l){this.#l=l,this.#d=l.document,this.#r=new WeakMap,this.#w=new WeakMap,this.#f=(0,$.default)({document:l.document,DOMException:l.DOMException}),this.#f.configure({LOGERRORS:!1})}_onError(l){if(!this.#N)if(l instanceof DOMException||l instanceof this.#l.DOMException)if(l.name===c.NOT_SUPPORTED_ERR)this.#i&&console.warn(l.message);else throw new this.#l.DOMException(l.message,l.name);else throw l}_setup(l,e,n={}){const{event:r,noexcept:a,warn:f}=n;return this.#N=!!a,this.#i=!!f,this.#p=this._setEvent(r),this.#e=e,[this.#t,this.#s,this.#n]=(0,S.resolveContent)(e),this.#u=(0,S.isInShadowTree)(e),[this.#a,this.#b]=this._correspond(l),this.#_=new WeakMap,e}_setEvent(l){return l instanceof this.#l.MouseEvent||l instanceof this.#l.KeyboardEvent?l:null}_correspond(l){const e=[];this.#c=!1,this.#h=!1;let n;if(this.#t){const r=this.#r.get(this.#t);if(r&&r.has(`${l}`)){const a=r.get(`${l}`);this.#c=a.complex,this.#h=a.descendant,n=a.ast}}if(n){const r=n.length;for(let a=0;a<r;a++)n[a].collected=!1,n[a].dir=null,n[a].filtered=!1,n[a].find=!1,e[a]=[]}else{let r;try{r=(0,k.parseSelector)(l)}catch(d){this._onError(d)}const{branches:a,complex:f}=(0,k.walkAST)(r,!0);let o=!1,b=0;n=[];for(const[...d]of a){const s=[];let t=d.shift();if(t&&t.type!==c.COMBINATOR){const i=new Set;for(;t;){if(t.type===c.COMBINATOR){const[h]=d;if(h.type===c.COMBINATOR){const u=`Invalid selector ${l}`;throw new DOMException(u,c.SYNTAX_ERR)}const m=t.name;/^[\s>]$/.test(m)&&(o=!0),s.push({combo:t,leaves:(0,k.sortAST)(i)}),i.clear()}else if(t){let{name:h}=t;h&&typeof h=="string"&&(h=(0,k.unescapeSelector)(h),typeof h=="string"&&h!==t.name&&(t.name=h),/[|:]/.test(h)&&(t.namespace=!0)),i.add(t)}if(d.length)t=d.shift();else{s.push({combo:null,leaves:(0,k.sortAST)(i)}),i.clear();break}}}n.push({branch:s,collected:!1,dir:null,filtered:!1,find:!1}),e[b]=[],b++}if(this.#t){let d;this.#r.has(this.#t)?d=this.#r.get(this.#t):d=new Map,d.set(`${l}`,{ast:n,complex:f,descendant:o}),this.#r.set(this.#t,d)}this.#c=f,this.#h=o}return[n,e]}_createTreeWalker(l){let e;return this.#_.has(l)?e=this.#_.get(l):(e=this.#d.createTreeWalker(l,c.WALKER_FILTER),this.#_.set(l,e)),e}_prepareQuerySelectorWalker(){return this.#o=this._createTreeWalker(this.#e),this.#m=!1,this.#o}_traverse(l,e=this.#n){let n=e.currentNode,r;if(n===l)r=n;else if(n.contains(l))for(n=e.nextNode();n;){if(n===l){r=n;break}n=e.nextNode()}else{if(n!==e.root)for(;n&&!(n===e.root||n===l);)n=e.parentNode();if(l?.nodeType===c.ELEMENT_NODE)for(;n;){if(n===l){r=n;break}n=e.nextNode()}else r=n}return r??null}_collectNthChild(l,e,n){const{a:r,b:a,reverse:f,selector:o}=l,{parentNode:b}=e,d=new Set;let s;if(o)if(this.#r.has(o))s=this.#r.get(o);else{const{branches:t}=(0,k.walkAST)(o);s=t,this.#r.set(o,s)}if(b){const t=this.#n;let i=this._traverse(b,t);i=t.firstChild();let h=0;for(;i;)h++,i=t.nextSibling();i=this._traverse(b,t);const m=new Set;if(s)for(i=t.firstChild();i;){let u;for(const p of s)if(u=this._matchLeaves(p,i,n),!u)break;u&&m.add(i),i=t.nextSibling()}if(r===0){if(a>0&&a<=h){if(m.size){i=this._traverse(b,t),f?i=t.lastChild():i=t.firstChild();let u=0;for(;i;){if(m.has(i)){if(u===a-1){d.add(i);break}u++}f?i=t.previousSibling():i=t.nextSibling()}}else if(!o){i=this._traverse(b,t),f?i=t.lastChild():i=t.firstChild();let u=0;for(;i;){if(u===a-1){d.add(i);break}f?i=t.previousSibling():i=t.nextSibling(),u++}}}}else{let u=a-1;if(r>0)for(;u<0;)u+=r;if(u>=0&&u<h){i=this._traverse(b,t),f?i=t.lastChild():i=t.firstChild();let p=0,_=r>0?0:a-1;for(;i&&(i&&u>=0&&u<h);)m.size?m.has(i)&&(_===u&&(d.add(i),u+=r),r>0?_++:_--):p===u&&(o||d.add(i),u+=r),f?i=t.previousSibling():i=t.nextSibling(),p++}}if(f&&d.size>1){const u=[...d];return new Set(u.reverse())}}else if(e===this.#s&&r+a===1)if(s){let t;for(const i of s)if(t=this._matchLeaves(i,e,n),t)break;t&&d.add(e)}else d.add(e);return d}_collectNthOfType(l,e){const{a:n,b:r,reverse:a}=l,{localName:f,parentNode:o,prefix:b}=e,d=new Set;if(o){const s=this.#n;let t=this._traverse(o,s);t=s.firstChild();let i=0;for(;t;)i++,t=s.nextSibling();if(n===0){if(r>0&&r<=i){t=this._traverse(o,s),a?t=s.lastChild():t=s.firstChild();let h=0;for(;t;){const{localName:m,prefix:u}=t;if(m===f&&u===b){if(h===r-1){d.add(t);break}h++}a?t=s.previousSibling():t=s.nextSibling()}}}else{let h=r-1;if(n>0)for(;h<0;)h+=n;if(h>=0&&h<i){t=this._traverse(o,s),a?t=s.lastChild():t=s.firstChild();let m=n>0?0:r-1;for(;t;){const{localName:u,prefix:p}=t;if(u===f&&p===b){if(m===h&&(d.add(t),h+=n),h<0||h>=i)break;n>0?m++:m--}a?t=s.previousSibling():t=s.nextSibling()}}}if(a&&d.size>1){const h=[...d];return new Set(h.reverse())}}else e===this.#s&&n+r===1&&d.add(e);return d}_matchAnPlusB(l,e,n,r){const{nth:{a,b:f,name:o},selector:b}=l,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)),n.indexOf("last")>-1&&d.set("reverse",!0)):(typeof a=="string"&&/-?\d+/.test(a)?d.set("a",a*1):d.set("a",0),typeof f=="string"&&/-?\d+/.test(f)?d.set("b",f*1):d.set("b",0),n.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(n)){b&&d.set("selector",b);const s=Object.fromEntries(d);return this._collectNthChild(s,e,r)}else if(/^nth-(?:last-)?of-type$/.test(n)){const s=Object.fromEntries(d);return this._collectNthOfType(s,e)}return new Set}_matchHasPseudoFunc(l,e,n={}){let r;if(Array.isArray(l)&&l.length){const[a]=l,{type:f}=a;let o;f===c.COMBINATOR?o=l.shift():o={name:" ",type:c.COMBINATOR};const b=[];for(;l.length;){const[t]=l,{type:i}=t;if(i===c.COMBINATOR)break;b.push(l.shift())}const d={combo:o,leaves:b};n.dir=v;const s=this._matchCombinator(d,e,n);if(s.size)if(l.length){for(const t of s)if(r=this._matchHasPseudoFunc(Object.assign([],l),t,n),r)break}else r=!0}return!!r}_matchLogicalPseudoFunc(l,e,n={}){const{astName:r="",branches:a=[],selector:f="",twigBranches:o=[]}=l;let b;if(r==="has")if(f.includes(":has("))b=null;else{let d;for(const s of a)if(d=this._matchHasPseudoFunc(Object.assign([],s),e,n),d)break;d&&(b=e)}else{const d=/^(?:is|where)$/.test(r);n.forgive=d;const s=o.length;let t;for(let i=0;i<s;i++){const h=o[i],m=h.length-1,{leaves:u}=h[m];if(t=this._matchLeaves(u,e,n),t&&m>0){let p=new Set([e]);for(let _=m-1;_>=0;_--){const w=h[_],N=[];n.dir=x;for(const A of p){const E=this._matchCombinator(w,A,n);E.size&&N.push(...E)}if(N.length)_===0?t=!0:p=new Set(N);else{t=!1;break}}}if(t)break}r==="not"?t||(b=e):t&&(b=e)}return b??null}_matchPseudoClassSelector(l,e,n={}){const{children:r,name:a}=l,{localName:f,parentNode:o}=e,{forgive:b,warn:d=this.#i}=n,s=new Set;if(c.REG_LOGICAL_PSEUDO.test(a)){let t;if(this.#r.has(l))t=this.#r.get(l);else{const{branches:h}=(0,k.walkAST)(l),m=[],u=[];for(const[...p]of h){for(const A of p){const E=(0,k.generateCSS)(A);m.push(E)}const _=[],w=new Set;let N=p.shift();for(;N;)if(N.type===c.COMBINATOR?(_.push({combo:N,leaves:[...w]}),w.clear()):N&&w.add(N),p.length)N=p.shift();else{_.push({combo:null,leaves:[...w]}),w.clear();break}u.push(_)}t={astName:a,branches:h,twigBranches:u,selector:m.join(",")},this.#r.set(l,t)}const i=this._matchLogicalPseudoFunc(t,e,n);i&&s.add(i)}else if(Array.isArray(r))if(/^nth-(?:last-)?(?:child|of-type)$/.test(a)){const[t]=r;return this._matchAnPlusB(t,e,a,n)}else switch(a){case"dir":case"lang":{const t=O.matcher.matchSelector(l,e);t&&s.add(t);break}case"current":case"nth-col":case"nth-last-col":{if(d){const t=`Unsupported pseudo-class :${a}()`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;default:if(!b){const t=`Unknown pseudo-class :${a}()`;throw new DOMException(t,c.SYNTAX_ERR)}}else switch(a){case"any-link":case"link":{c.REG_ANCHOR.test(f)&&e.hasAttribute("href")&&s.add(e);break}case"local-link":{if(c.REG_ANCHOR.test(f)&&e.hasAttribute("href")){const{href:t,origin:i,pathname:h}=new URL(this.#t.URL),m=new URL(e.getAttribute("href"),t);m.origin===i&&m.pathname===h&&s.add(e)}break}case"visited":break;case"hover":{const{target:t,type:i}=this.#p??{};(i==="mouseover"||i==="pointerover")&&e.contains(t)&&s.add(e);break}case"active":{const{buttons:t,target:i,type:h}=this.#p??{};(h==="mousedown"||h==="pointerdown")&&t&c.BIT_01&&e.contains(i)&&s.add(e);break}case"target":{const{hash:t}=new URL(this.#t.URL);e.id&&t===`#${e.id}`&&this.#t.contains(e)&&s.add(e);break}case"target-within":{const{hash:t}=new URL(this.#t.URL);if(t){const i=t.replace(/^#/,"");let h=this.#t.getElementById(i);for(;h;){if(h===e){s.add(e);break}h=h.parentNode}}break}case"scope":{this.#e.nodeType===c.ELEMENT_NODE?!this.#u&&e===this.#e&&s.add(e):e===this.#t.documentElement&&s.add(e);break}case"focus":case"focus-visible":{const{target:t,type:i}=this.#p??{};if(e===this.#t.activeElement&&e.tabIndex>=0&&(a==="focus"||i==="keydown"&&e.contains(t))){let h=e,m=!0;for(;h;){if(h.disabled||h.hasAttribute("disabled")||h.hidden||h.hasAttribute("hidden")){m=!1;break}else{const{display:u,visibility:p}=this.#l.getComputedStyle(h);if(m=!(u==="none"||p==="hidden"),!m)break}if(h.parentNode&&h.parentNode.nodeType===c.ELEMENT_NODE)h=h.parentNode;else break}m&&s.add(e)}break}case"focus-within":{let t,i=this.#t.activeElement;if(i.tabIndex>=0)for(;i;){if(i===e){t=!0;break}i=i.parentNode}if(t){let h=e,m=!0;for(;h;){if(h.disabled||h.hasAttribute("disabled")||h.hidden||h.hasAttribute("hidden")){m=!1;break}else{const{display:u,visibility:p}=this.#l.getComputedStyle(h);if(m=!(u==="none"||p==="hidden"),!m)break}if(h.parentNode&&h.parentNode.nodeType===c.ELEMENT_NODE)h=h.parentNode;else break}m&&s.add(e)}break}case"open":{c.REG_INTERACT.test(f)&&e.hasAttribute("open")&&s.add(e);break}case"closed":{c.REG_INTERACT.test(f)&&!e.hasAttribute("open")&&s.add(e);break}case"disabled":{if(c.REG_FORM_CTRL.test(f)||(0,M.default)(f))if(e.disabled||e.hasAttribute("disabled"))s.add(e);else{let t=o;for(;t&&t.localName!=="fieldset";)t=t.parentNode;t&&o.localName!=="legend"&&t.hasAttribute("disabled")&&s.add(e)}break}case"enabled":{(c.REG_FORM_CTRL.test(f)||(0,M.default)(f))&&!(e.disabled&&e.hasAttribute("disabled"))&&s.add(e);break}case"read-only":{switch(f){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&s.add(e);break}case"input":{(!e.type||c.REG_TYPE_DATE.test(e.type)||c.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&s.add(e);break}default:(0,S.isContentEditable)(e)||s.add(e)}break}case"read-write":{switch(f){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||s.add(e);break}case"input":{(!e.type||c.REG_TYPE_DATE.test(e.type)||c.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&s.add(e);break}default:(0,S.isContentEditable)(e)&&s.add(e)}break}case"placeholder-shown":{let t;f==="textarea"?t=e:f==="input"&&(e.hasAttribute("type")?c.REG_TYPE_TEXT.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&&f==="input"&&e.hasAttribute("type")&&c.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&f==="option")&&s.add(e);break}case"indeterminate":{if(e.indeterminate&&f==="input"&&e.type==="checkbox"||f==="progress"&&!e.hasAttribute("value"))s.add(e);else if(f==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let i=e.parentNode;for(;i&&i.localName!=="form";)i=i.parentNode;i||(i=this.#t.documentElement);const h=i.getElementsByTagName("input"),m=h.length;let u;for(let p=0;p<m;p++){const _=h[p];if(_.getAttribute("type")==="radio"&&(t?_.getAttribute("name")===t&&(u=!!_.checked):_.hasAttribute("name")||(u=!!_.checked),u))break}u||s.add(e)}break}case"default":{if(f==="button"&&!(e.hasAttribute("type")&&c.REG_TYPE_RESET.test(e.getAttribute("type")))||f==="input"&&e.hasAttribute("type")&&c.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const i=this.#n;let h=this._traverse(t,i);for(h=i.firstChild();h&&t.contains(h);){const m=h.localName;let u;if(m==="button"?u=!(h.hasAttribute("type")&&c.REG_TYPE_RESET.test(h.getAttribute("type"))):m==="input"&&(u=h.hasAttribute("type")&&c.REG_TYPE_SUBMIT.test(h.getAttribute("type"))),u){h===e&&s.add(e);break}h=i.nextNode()}}}else if(f==="input"&&e.hasAttribute("type")&&c.REG_TYPE_CHECK.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))s.add(e);else if(f==="option"){let t=o,i=!1;for(;t&&t.localName!=="datalist";){if(t.localName==="select"){(t.multiple||t.hasAttribute("multiple"))&&(i=!0);break}t=t.parentNode}if(i)(e.selected||e.hasAttribute("selected"))&&s.add(e);else{const h=new Set,m=this.#n;let u=this._traverse(o,m);for(u=m.firstChild();u;){if(u.selected||u.hasAttribute("selected")){h.add(u);break}u=m.nextSibling()}h.size&&h.has(e)&&s.add(e)}}break}case"valid":{if(c.REG_FORM_VALID.test(f))e.checkValidity()&&s.add(e);else if(f==="fieldset"){const t=this.#n;let i=this._traverse(e,t);i=t.firstChild();let h;for(;i&&e.contains(i)&&!(c.REG_FORM_VALID.test(i.localName)&&(h=i.checkValidity(),!h));)i=t.nextNode();h&&s.add(e)}break}case"invalid":{if(c.REG_FORM_VALID.test(f))e.checkValidity()||s.add(e);else if(f==="fieldset"){const t=this.#n;let i=this._traverse(e,t);i=t.firstChild();let h;for(;i&&e.contains(i)&&!(c.REG_FORM_VALID.test(i.localName)&&(h=i.checkValidity(),!h));)i=t.nextNode();h||s.add(e)}break}case"in-range":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&c.REG_TYPE_RANGE.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":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&c.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&s.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const i=e.getAttribute("type");(i==="file"||c.REG_TYPE_CHECK.test(i)||c.REG_TYPE_DATE.test(i)||c.REG_TYPE_TEXT.test(i))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&s.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const i=e.getAttribute("type");(i==="file"||c.REG_TYPE_CHECK.test(i)||c.REG_TYPE_DATE.test(i)||c.REG_TYPE_TEXT.test(i))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&s.add(e);break}case"root":{e===this.#t.documentElement&&s.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#d.createTreeWalker(e,c.SHOW_ALL);let i=t.firstChild(),h;for(;i&&(h=i.nodeType!==c.ELEMENT_NODE&&i.nodeType!==c.TEXT_NODE,!!h);)i=t.nextSibling();h&&s.add(e)}else s.add(e);break}case"first-child":{(o&&e===o.firstElementChild||e===this.#s)&&s.add(e);break}case"last-child":{(o&&e===o.lastElementChild||e===this.#s)&&s.add(e);break}case"only-child":{(o&&e===o.firstElementChild&&e===o.lastElementChild||e===this.#s)&&s.add(e);break}case"first-of-type":{if(o){const[t]=this._collectNthOfType({a:0,b:1},e);t&&s.add(t)}else e===this.#s&&s.add(e);break}case"last-of-type":{if(o){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&s.add(t)}else e===this.#s&&s.add(e);break}case"only-of-type":{if(o){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[i]=this._collectNthOfType({a:0,b:1,reverse:!0},e);i===e&&s.add(e)}}else e===this.#s&&s.add(e);break}case"defined":{const t=e.getAttribute("is");t?(0,M.default)(t)&&this.#l.customElements.get(t)&&s.add(e):(0,M.default)(f)?this.#l.customElements.get(f)&&s.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.SVGElement)&&s.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#l.getComputedStyle(e);t!=="none"&&s.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d){const t=`Unsupported pseudo-element ::${a}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}case"autofill":case"blank":case"buffering":case"current":case"fullscreen":case"future":case"modal":case"muted":case"past":case"paused":case"picture-in-picture":case"playing":case"seeking":case"stalled":case"user-invalid":case"user-valid":case"volume-locked":case"-webkit-autofill":{if(d){const t=`Unsupported pseudo-class :${a}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}default:if(a.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${a}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}}else if(!b){const t=`Unknown pseudo-class :${a}`;throw new DOMException(t,c.SYNTAX_ERR)}}return s}_matchShadowHostPseudoClass(l,e){const{children:n,name:r}=l;let a;if(Array.isArray(n)){const{branches:f}=(0,k.walkAST)(n[0]),[o]=f,[...b]=o,{host:d}=e;if(r==="host"){let s;for(const t of b){const{type:i}=t;if(i===c.COMBINATOR){const m=`Invalid selector ${(0,k.generateCSS)(l)}`;throw new DOMException(m,c.SYNTAX_ERR)}if(s=this._matchSelector(t,d).has(d),!s)break}s&&(a=e)}else if(r==="host-context"){let s=d,t;for(;s;){for(const i of b){const{type:h}=i;if(h===c.COMBINATOR){const u=`Invalid selector ${(0,k.generateCSS)(l)}`;throw new DOMException(u,c.SYNTAX_ERR)}if(t=this._matchSelector(i,s).has(s),!t)break}if(t)break;s=s.parentNode}t&&(a=e)}}else if(r==="host")a=e;else{const f=`Invalid selector :${r}`;throw new DOMException(f,c.SYNTAX_ERR)}return a??null}_matchSelector(l,e,n){const{type:r}=l,a=new Set;if(l.name===c.EMPTY)return a;const f=(0,k.unescapeSelector)(l.name);if(typeof f=="string"&&f!==l.name&&(l.name=f),e.nodeType===c.ELEMENT_NODE)switch(r){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(f,n);break}case c.SELECTOR_ID:{e.id===f&&a.add(e);break}case c.SELECTOR_CLASS:{e.classList.contains(f)&&a.add(e);break}case c.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(l,e,n);default:{const o=O.matcher.matchSelector(l,e,n);o&&a.add(o)}}else if(this.#u&&r===c.SELECTOR_PSEUDO_CLASS&&e.nodeType===c.DOCUMENT_FRAGMENT_NODE){if(f!=="has"&&c.REG_LOGICAL_PSEUDO.test(f))return this._matchPseudoClassSelector(l,e,n);if(c.REG_SHADOW_HOST.test(f)){const o=this._matchShadowHostPseudoClass(l,e,n);o&&a.add(o)}}return a}_matchLeaves(l,e,n){const{attributes:r,localName:a,nodeType:f}=e;let o=this.#w.get(l),b;if(o&&o.has(e)){const{attr:d,matched:s}=o.get(e);r?.length===d&&(b=s)}if(typeof b!="boolean"){let d;f===c.ELEMENT_NODE&&c.REG_FORM.test(a)?d=!1:d=!0;for(const s of l){const{name:t,type:i}=s;if(i===c.SELECTOR_PSEUDO_CLASS&&t==="dir"&&(d=!1),b=this._matchSelector(s,e,n).has(e),!b)break}d&&(o||(o=new WeakMap),o.set(e,{attr:r?.length,matched:b}),this.#w.set(l,o))}return!!b}_matchHTMLCollection(l,e={}){const{compound:n,filterLeaves:r}=e,a=new Set,f=l.length;if(f)if(n)for(let o=0;o<f;o++){const b=l[o];this._matchLeaves(r,b,e)&&a.add(b)}else{const o=[].slice.call(l);return new Set(o)}return a}_findDescendantNodes(l,e,n){const[r,...a]=l,f=a.length>0,{type:o}=r,b=(0,k.unescapeSelector)(r.name);typeof b=="string"&&b!==r.name&&(r.name=b);let d=new Set,s=!1;if(this.#u)s=!0;else switch(o){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(b,n);break}case c.SELECTOR_ID:{if(this.#s.nodeType===c.ELEMENT_NODE)s=!0;else{const t=this.#s.getElementById(b);t&&t!==e&&e.contains(t)&&(f?this._matchLeaves(a,t,n)&&d.add(t):d.add(t))}break}case c.SELECTOR_CLASS:{const t=e.getElementsByClassName(b);d=this._matchHTMLCollection(t,{compound:f,filterLeaves:a});break}case c.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(b)){const t=e.getElementsByTagName(b);d=this._matchHTMLCollection(t,{compound:f,filterLeaves:a})}else s=!0;break}default:s=!0}return{nodes:d,pending:s}}_matchCombinator(l,e,n={}){const{combo:r,leaves:a}=l,{name:f}=r,{parentNode:o}=e,{dir:b}=n,d=new Set;if(b===v)switch(f){case"+":{const s=e.nextElementSibling;s&&this._matchLeaves(a,s,n)&&d.add(s);break}case"~":{if(o){const s=this._createTreeWalker(o);let t=this._traverse(e,s);for(t=s.nextSibling();t;)this._matchLeaves(a,t,n)&&d.add(t),t=s.nextSibling()}break}case">":{const s=this._createTreeWalker(e);let t=this._traverse(e,s);for(t=s.firstChild();t;)this._matchLeaves(a,t,n)&&d.add(t),t=s.nextSibling();break}case" ":default:{const{nodes:s,pending:t}=this._findDescendantNodes(a,e);if(s.size)return s;if(t){const i=this._createTreeWalker(e);let h=this._traverse(e,i);for(h=i.nextNode();h&&e.contains(h);)this._matchLeaves(a,h,n)&&d.add(h),h=i.nextNode()}}}else switch(f){case"+":{const s=e.previousElementSibling;s&&this._matchLeaves(a,s,n)&&d.add(s);break}case"~":{if(o){const s=this._createTreeWalker(o);let t=this._traverse(o,s);for(t=s.firstChild();t&&t!==e;)this._matchLeaves(a,t,n)&&d.add(t),t=s.nextSibling()}break}case">":{o&&this._matchLeaves(a,o,n)&&d.add(o);break}case" ":default:{const s=[];let t=o;for(;t;)this._matchLeaves(a,t,n)&&s.push(t),t=t.parentNode;if(s.length)return new Set(s.reverse())}}return d}_findNode(l,e){const{node:n}=e;let r=this._traverse(n,this.#o),a;if(r)for(r.nodeType!==c.ELEMENT_NODE?r=this.#o.nextNode():r===n&&r!==this.#s&&(r=this.#o.nextNode());r;){if(this._matchLeaves(l,r,{warn:this.#i})){a=r;break}r=this.#o.nextNode()}return a??null}_matchSelf(l){const e=[],n=this._matchLeaves(l,this.#e,{warn:this.#i});let r=!1;return n&&(e.push(this.#e),r=!0),[e,r]}_findLineal(l,e={}){const{complex:n}=e,r=[];let a=this._matchLeaves(l,this.#e,{warn:this.#i}),f=!1;if(a&&(r.push(this.#e),f=!0),!a||n){let o=this.#e.parentNode;for(;o&&(a=this._matchLeaves(l,o,{warn:this.#i}),a&&(r.push(o),f=!0),o.parentNode);)o=o.parentNode}return[r,f]}_findFirst(l){const e=[],n=this._findNode(l,{node:this.#e});let r=!1;return n&&(e.push(n),r=!0),[e,r]}_findFromHTMLCollection(l,e={}){const{complex:n,compound:r,filterLeaves:a,targetType:f}=e;let o=[],b=!1,d=!1;const s=l.length;if(s)if(this.#e.nodeType===c.ELEMENT_NODE)for(let t=0;t<s;t++){const i=l[t];if(i!==this.#e&&(this.#e.contains(i)||i.contains(this.#e))){if(r){if(this._matchLeaves(a,i,{warn:this.#i})&&(o.push(i),b=!0,f===g))break}else if(o.push(i),b=!0,f===g)break}}else if(n)if(r)for(let t=0;t<s;t++){const i=l[t];if(this._matchLeaves(a,i,{warn:this.#i})&&(o.push(i),b=!0,f===g))break}else o=[].slice.call(l),b=!0,d=!0;else if(r)for(let t=0;t<s;t++){const i=l[t];if(this._matchLeaves(a,i,{warn:this.#i})&&(o.push(i),b=!0,f===g))break}else o=[].slice.call(l),b=!0,d=!0;return[o,b,d]}_findEntryNodes(l,e,n){const{leaves:r}=l,[a,...f]=r,o=f.length>0,{name:b,type:d}=a;let s=[],t=!1,i=!1,h=!1;switch(d){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(b,{warn:this.#i});break}case c.SELECTOR_ID:{if(e===R)[s,i]=this._matchSelf(r);else if(e===C)[s,i]=this._findLineal(r,{complex:n});else if(e===g&&this.#s.nodeType!==c.ELEMENT_NODE){const m=this.#s.getElementById(b);m&&(o?this._matchLeaves(f,m,{warn:this.#i})&&(s.push(m),i=!0):(s.push(m),i=!0))}else e===g?[s,i]=this._findFirst(r):h=!0;break}case c.SELECTOR_CLASS:{if(e===R)[s,i]=this._matchSelf(r);else if(e===C)[s,i]=this._findLineal(r,{complex:n});else if(this.#s.nodeType===c.DOCUMENT_NODE){const m=this.#s.getElementsByClassName(b);m.length&&([s,i,t]=this._findFromHTMLCollection(m,{complex:n,compound:o,filterLeaves:f,targetType:e}))}else e===g?[s,i]=this._findFirst(r):h=!0;break}case c.SELECTOR_TYPE:{if(e===R)[s,i]=this._matchSelf(r);else if(e===C)[s,i]=this._findLineal(r,{complex:n});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===c.DOCUMENT_NODE&&!/[*|]/.test(b)){const m=this.#s.getElementsByTagName(b);m.length&&([s,i,t]=this._findFromHTMLCollection(m,{complex:n,compound:o,filterLeaves:f,targetType:e}))}else e===g?[s,i]=this._findFirst(r):h=!0;break}default:if(e!==C&&c.REG_SHADOW_HOST.test(b)){if(this.#u&&this.#e.nodeType===c.DOCUMENT_FRAGMENT_NODE){const m=this._matchShadowHostPseudoClass(a,this.#e);m&&(s.push(m),i=!0)}}else e===R?[s,i]=this._matchSelf(r):e===C?[s,i]=this._findLineal(r,{complex:n}):e===g?[s,i]=this._findFirst(r):h=!0}return{collected:t,compound:o,filtered:i,nodes:s,pending:h}}_collectNodes(l){const e=this.#a.values();if(l===L||l===g){const n=new Set;let r=0;for(const{branch:a}of e){const f=a.length,o=f>1,b=a[0];let d,s;if(o){const{combo:p,leaves:[{name:_,type:w}]}=b,N=a[f-1],{leaves:[{name:A,type:E}]}=N;if(E===c.SELECTOR_PSEUDO_ELEMENT||E===c.SELECTOR_ID)d=x,s=N;else if(w===c.SELECTOR_PSEUDO_ELEMENT||w===c.SELECTOR_ID)d=v,s=b;else if(l===L)if(_==="*"&&w===c.SELECTOR_TYPE)d=x,s=N;else if(A==="*"&&E===c.SELECTOR_TYPE)d=v,s=b;else if(f===2){const{name:T}=p;/^[+~]$/.test(T)?(d=x,s=N):(d=v,s=b)}else d=v,s=b;else if(A==="*"&&E===c.SELECTOR_TYPE)d=v,s=b;else if(_==="*"&&w===c.SELECTOR_TYPE)d=x,s=N;else{let T;for(const{combo:D,leaves:[G]}of a){const{name:z,type:F}=G;if(F===c.SELECTOR_PSEUDO_CLASS&&z==="dir"){T=!1;break}if(!T&&D){const{name:H}=D;/^[+~]$/.test(H)&&(T=!0)}}T?(d=v,s=b):(d=x,s=N)}}else d=x,s=b;const{collected:t,compound:i,filtered:h,nodes:m,pending:u}=this._findEntryNodes(s,l,o);m.length?(this.#a[r].find=!0,this.#b[r]=m):u&&n.add(new Map([["index",r],["twig",s]])),this.#a[r].collected=t,this.#a[r].dir=d,this.#a[r].filtered=h||!i,r++}if(n.size){let a,f;this.#e!==this.#s&&this.#e.nodeType===c.ELEMENT_NODE?(a=this.#e,f=this.#o):(a=this.#s,f=this.#n);let o=this._traverse(a,f);for(;o;){let b=!1;if(this.#e.nodeType===c.ELEMENT_NODE?o===this.#e?b=!0:b=this.#e.contains(o):b=!0,b)for(const d of n){const{leaves:s}=d.get("twig");if(this._matchLeaves(s,o,{warn:this.#i})){const i=d.get("index");this.#a[i].filtered=!0,this.#a[i].find=!0,this.#b[i].push(o)}}o!==f.currentNode&&(o=this._traverse(o,f)),o=f.nextNode()}}}else{let n=0;for(const{branch:r}of e){const a=r[r.length-1],f=r.length>1,{compound:o,filtered:b,nodes:d}=this._findEntryNodes(a,l,f);d.length&&(this.#a[n].find=!0,this.#b[n]=d),this.#a[n].dir=x,this.#a[n].filtered=b||!o,n++}}return[this.#a,this.#b]}_getCombinedNodes(l,e,n){const r=[];for(const a of e){const f=this._matchCombinator(l,a,{dir:n,warn:this.#i});f.size&&r.push(...f)}return r.length?new Set(r):new Set}_matchNodeNext(l,e,n){const{combo:r,index:a}=n,{combo:f,leaves:o}=l[a],b={combo:r,leaves:o},d=this._getCombinedNodes(b,e,v);let s;if(d.size)if(a===l.length-1){const[t]=(0,S.sortNodes)(d);s=t}else s=this._matchNodeNext(l,d,{combo:f,index:a+1});return s??null}_matchNodePrev(l,e,n){const{index:r}=n,a=l[r],f=new Set([e]),o=this._getCombinedNodes(a,f,x);let b;if(o.size){if(r===0)b=e;else for(const d of o)if(this._matchNodePrev(l,d,{index:r-1}))return e}return b??null}_find(l){(l===L||l===g)&&this._prepareQuerySelectorWalker();const[[...e],n]=this._collectNodes(l),r=e.length;let a=new Set;for(let f=0;f<r;f++){const{branch:o,collected:b,dir:d,find:s}=e[f],t=o.length;if(t&&s){const i=n[f],h=i.length,m=t-1;if(m===0)if((l===L||l===g)&&this.#e.nodeType===c.ELEMENT_NODE)for(let u=0;u<h;u++){const p=i[u];if(p!==this.#e&&this.#e.contains(p)&&(a.add(p),l!==L))break}else if(l===L)if(a.size){const u=[...a];a=new Set([...u,...i]),this.#m=!0}else a=new Set(i);else{const[u]=i;a.add(u)}else if(l===L)if(d===v){let{combo:u}=o[0];for(const p of i){let _=new Set([p]);for(let w=1;w<t;w++){const{combo:N,leaves:A}=o[w],E={combo:u,leaves:A};if(_=this._getCombinedNodes(E,_,d),_.size)if(w===m)if(a.size){const T=[...a];a=new Set([...T,..._]),this.#m=!0}else a=_;else u=N;else break}}}else for(const u of i){let p=new Set([u]);for(let _=m-1;_>=0;_--){const w=o[_];if(p=this._getCombinedNodes(w,p,d),p.size)_===0&&(a.add(u),t>1&&a.size>1&&(this.#m=!0));else break}}else if(l===g&&d===v){const{combo:u}=o[0];let p;for(const _ of i)if(p=this._matchNodeNext(o,new Set([_]),{combo:u,index:1}),p){a.add(p);break}if(!p&&!b){const{leaves:_}=o[0],[w]=i;let N=this._findNode(_,{node:w});for(;N;){if(p=this._matchNodeNext(o,new Set([N]),{combo:u,index:1}),p){a.add(p);break}N=this._findNode(_,{node:N})}}}else{let u;for(const p of i)if(u=this._matchNodePrev(o,p,{index:m-1}),u){a.add(p);break}if(!u&&!b&&l===g){const{leaves:p}=o[m],[_]=i;let w=this._findNode(p,{node:_});for(;w;){if(u=this._matchNodePrev(o,w,{index:m-1}),u){a.add(w);break}w=this._findNode(p,{node:w})}}}}}return a}matches(l,e,n){let r;try{if(e?.nodeType!==c.ELEMENT_NODE){const a=`Unexpected node ${e?.nodeName}`;throw new TypeError(a)}(0,k.filterSelector)(l,{complex:this.#c,descendant:!0})?r=this.#f.match(l,e):(this._setup(l,e,n),r=this._find(R).size)}catch(a){this._onError(a)}return!!r}closest(l,e,n){let r;try{if(e?.nodeType!==c.ELEMENT_NODE){const a=`Unexpected node ${e?.nodeName}`;throw new TypeError(a)}if((0,k.filterSelector)(l,{complex:this.#c,descendant:!0}))r=this.#f.closest(l,e);else{this._setup(l,e,n);const a=this._find(C);if(a.size){let f=this.#e;for(;f;){if(a.has(f)){r=f;break}f=f.parentNode}}}}catch(a){this._onError(a)}return r??null}querySelector(l,e,n){let r;try{if(this._setup(l,e,n),this.#d===this.#t&&!this.#h&&(0,k.filterSelector)(l,{complex:this.#c,descendant:!1}))r=this.#f.first(l,e);else{const a=this._find(g);a.delete(this.#e),a.size&&([r]=(0,S.sortNodes)(a))}}catch(a){this._onError(a)}return r??null}querySelectorAll(l,e,n){let r;try{if(this._setup(l,e,n),this.#d===this.#t&&!this.#h&&(0,k.filterSelector)(l,{complex:this.#c,descendant:!1}))r=this.#f.select(l,e);else{const a=this._find(L);a.delete(this.#e),a.size&&(this.#m?r=(0,S.sortNodes)(a):r=[...a])}}catch(a){this._onError(a)}return r??[]}}0&&(module.exports={Finder}); | ||
var W=Object.create;var D=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var V=(y,a)=>{for(var e in a)D(y,e,{get:a[e],enumerable:!0})},I=(y,a,e,f)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of j(a))!q.call(y,r)&&r!==e&&D(y,r,{get:()=>a[r],enumerable:!(f=B(a,r))||f.enumerable});return y};var U=(y,a,e)=>(e=y!=null?W(Y(y)):{},I(a||!y||!y.__esModule?D(e,"default",{value:y,enumerable:!0}):e,y)),X=y=>I(D({},"__esModule",{value:!0}),y);var Q={};V(Q,{Finder:()=>K});module.exports=X(Q);var M=U(require("is-potential-custom-element-name"),1),$=U(require("@asamuzakjp/nwsapi"),1),E=require("./dom-util.js"),O=require("./matcher.js"),k=require("./parser.js"),c=require("./constant.js");const S="next",x="prev",L="all",g="first",C="lineal",R="self";class K{#l;#r;#s;#p;#o;#b;#e;#h;#w;#n;#f;#_;#t;#d;#u;#c;#m;#i;#a;constructor(a){this.#a=a,this.#o=a.document,this.#r=new WeakMap,this.#_=new WeakMap}_onError(a){if(!this.#w)if(a instanceof DOMException||a instanceof this.#a.DOMException)if(a.name===c.NOT_SUPPORTED_ERR)this.#i&&console.warn(a.message);else throw new this.#a.DOMException(a.message,a.name);else throw a}_setup(a,e,f={}){const{event:r,noexcept:l,warn:o}=f;return this.#w=!!l,this.#i=!!o,this.#b=this._setEvent(r),this.#e=e,[this.#s,this.#t,this.#c]=(0,E.resolveContent)(e),this.#d=(0,E.isInShadowTree)(e),[this.#l,this.#h]=this._correspond(a),this.#m=new WeakMap,e}_initNwsapi(a){return this.#n=(0,$.default)({DOMException:this.#a.DOMException,document:a}),this.#n.configure({LOGERRORS:!1}),this.#n}_setEvent(a){return a instanceof this.#a.MouseEvent||a instanceof this.#a.KeyboardEvent?a:null}_correspond(a){const e=[];this.#p=!1;let f;if(this.#s){const r=this.#r.get(this.#s);if(r&&r.has(`${a}`)){const l=r.get(`${a}`);this.#p=l.descendant,f=l.ast}}if(f){const r=f.length;for(let l=0;l<r;l++)f[l].collected=!1,f[l].dir=null,f[l].filtered=!1,f[l].find=!1,e[l]=[]}else{let r;try{r=(0,k.parseSelector)(a)}catch(u){this._onError(u)}const l=(0,k.walkAST)(r);let o=!1,n=0;f=[];for(const[...u]of l){const h=[];let s=u.shift();if(s&&s.type!==c.COMBINATOR){const t=new Set;for(;s;){if(s.type===c.COMBINATOR){const[i]=u;if(i.type===c.COMBINATOR){const m=`Invalid selector ${a}`;throw new DOMException(m,c.SYNTAX_ERR)}const d=s.name;/^[\s>]$/.test(d)&&(o=!0),h.push({combo:s,leaves:(0,k.sortAST)(t)}),t.clear()}else if(s){let{name:i}=s;i&&typeof i=="string"&&(i=(0,k.unescapeSelector)(i),typeof i=="string"&&i!==s.name&&(s.name=i),/[|:]/.test(i)&&(s.namespace=!0)),t.add(s)}if(u.length)s=u.shift();else{h.push({combo:null,leaves:(0,k.sortAST)(t)}),t.clear();break}}}f.push({branch:h,collected:!1,dir:null,filtered:!1,find:!1}),e[n]=[],n++}if(this.#s){let u;this.#r.has(this.#s)?u=this.#r.get(this.#s):u=new Map,u.set(`${a}`,{ast:f,descendant:o}),this.#r.set(this.#s,u)}this.#p=o}return[f,e]}_createTreeWalker(a){let e;return this.#m.has(a)?e=this.#m.get(a):(e=this.#o.createTreeWalker(a,c.WALKER_FILTER),this.#m.set(a,e)),e}_prepareQuerySelectorWalker(){return this.#f=this._createTreeWalker(this.#e),this.#u=!1,this.#f}_traverse(a,e=this.#c){let f=e.currentNode,r;if(f===a)r=f;else if(f.contains(a))for(f=e.nextNode();f;){if(f===a){r=f;break}f=e.nextNode()}else{if(f!==e.root)for(;f&&!(f===e.root||f===a);)f=e.parentNode();if(a?.nodeType===c.ELEMENT_NODE)for(;f;){if(f===a){r=f;break}f=e.nextNode()}else r=f}return r??null}_collectNthChild(a,e,f){const{a:r,b:l,reverse:o,selector:n}=a,{parentNode:u}=e,h=new Set;let s;if(n&&(this.#r.has(n)?s=this.#r.get(n):(s=(0,k.walkAST)(n),this.#r.set(n,s))),u){const t=this.#c;let i=this._traverse(u,t);i=t.firstChild();let d=0;for(;i;)d++,i=t.nextSibling();i=this._traverse(u,t);const m=new Set;if(s)for(i=t.firstChild();i;){let b;for(const p of s)if(b=this._matchLeaves(p,i,f),!b)break;b&&m.add(i),i=t.nextSibling()}if(r===0){if(l>0&&l<=d){if(m.size){i=this._traverse(u,t),o?i=t.lastChild():i=t.firstChild();let b=0;for(;i;){if(m.has(i)){if(b===l-1){h.add(i);break}b++}o?i=t.previousSibling():i=t.nextSibling()}}else if(!n){i=this._traverse(u,t),o?i=t.lastChild():i=t.firstChild();let b=0;for(;i;){if(b===l-1){h.add(i);break}o?i=t.previousSibling():i=t.nextSibling(),b++}}}}else{let b=l-1;if(r>0)for(;b<0;)b+=r;if(b>=0&&b<d){i=this._traverse(u,t),o?i=t.lastChild():i=t.firstChild();let p=0,_=r>0?0:l-1;for(;i&&(i&&b>=0&&b<d);)m.size?m.has(i)&&(_===b&&(h.add(i),b+=r),r>0?_++:_--):p===b&&(n||h.add(i),b+=r),o?i=t.previousSibling():i=t.nextSibling(),p++}}if(o&&h.size>1){const b=[...h];return new Set(b.reverse())}}else if(e===this.#t&&r+l===1)if(s){let t;for(const i of s)if(t=this._matchLeaves(i,e,f),t)break;t&&h.add(e)}else h.add(e);return h}_collectNthOfType(a,e){const{a:f,b:r,reverse:l}=a,{localName:o,parentNode:n,prefix:u}=e,h=new Set;if(n){const s=this.#c;let t=this._traverse(n,s);t=s.firstChild();let i=0;for(;t;)i++,t=s.nextSibling();if(f===0){if(r>0&&r<=i){t=this._traverse(n,s),l?t=s.lastChild():t=s.firstChild();let d=0;for(;t;){const{localName:m,prefix:b}=t;if(m===o&&b===u){if(d===r-1){h.add(t);break}d++}l?t=s.previousSibling():t=s.nextSibling()}}}else{let d=r-1;if(f>0)for(;d<0;)d+=f;if(d>=0&&d<i){t=this._traverse(n,s),l?t=s.lastChild():t=s.firstChild();let m=f>0?0:r-1;for(;t;){const{localName:b,prefix:p}=t;if(b===o&&p===u){if(m===d&&(h.add(t),d+=f),d<0||d>=i)break;f>0?m++:m--}l?t=s.previousSibling():t=s.nextSibling()}}}if(l&&h.size>1){const d=[...h];return new Set(d.reverse())}}else e===this.#t&&f+r===1&&h.add(e);return h}_matchAnPlusB(a,e,f,r){const{nth:{a:l,b:o,name:n},selector:u}=a,h=new Map;if(n?(n==="even"?(h.set("a",2),h.set("b",0)):n==="odd"&&(h.set("a",2),h.set("b",1)),f.indexOf("last")>-1&&h.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?h.set("a",l*1):h.set("a",0),typeof o=="string"&&/-?\d+/.test(o)?h.set("b",o*1):h.set("b",0),f.indexOf("last")>-1&&h.set("reverse",!0)),/^nth-(?:last-)?child$/.test(f)){u&&h.set("selector",u);const s=Object.fromEntries(h);return this._collectNthChild(s,e,r)}else if(/^nth-(?:last-)?of-type$/.test(f)){const s=Object.fromEntries(h);return this._collectNthOfType(s,e)}return new Set}_matchHasPseudoFunc(a,e,f={}){let r;if(Array.isArray(a)&&a.length){const[l]=a,{type:o}=l;let n;o===c.COMBINATOR?n=a.shift():n={name:" ",type:c.COMBINATOR};const u=[];for(;a.length;){const[t]=a,{type:i}=t;if(i===c.COMBINATOR)break;u.push(a.shift())}const h={combo:n,leaves:u};f.dir=S;const s=this._matchCombinator(h,e,f);if(s.size)if(a.length){for(const t of s)if(r=this._matchHasPseudoFunc(Object.assign([],a),t,f),r)break}else r=!0}return!!r}_matchLogicalPseudoFunc(a,e,f={}){const{astName:r="",branches:l=[],selector:o="",twigBranches:n=[]}=a;let u;if(r==="has")if(o.includes(":has("))u=null;else{let h;for(const s of l)if(h=this._matchHasPseudoFunc(Object.assign([],s),e,f),h)break;h&&(u=e)}else{const h=/^(?:is|where)$/.test(r);f.forgive=h;const s=n.length;let t;for(let i=0;i<s;i++){const d=n[i],m=d.length-1,{leaves:b}=d[m];if(t=this._matchLeaves(b,e,f),t&&m>0){let p=new Set([e]);for(let _=m-1;_>=0;_--){const w=d[_],N=[];f.dir=x;for(const A of p){const v=this._matchCombinator(w,A,f);v.size&&N.push(...v)}if(N.length)_===0?t=!0:p=new Set(N);else{t=!1;break}}}if(t)break}r==="not"?t||(u=e):t&&(u=e)}return u??null}_matchPseudoClassSelector(a,e,f={}){const{children:r,name:l}=a,{localName:o,parentNode:n}=e,{forgive:u,warn:h=this.#i}=f,s=new Set;if(c.REG_LOGICAL_PSEUDO.test(l)){let t;if(this.#r.has(a))t=this.#r.get(a);else{const d=(0,k.walkAST)(a),m=[],b=[];for(const[...p]of d){for(const A of p){const v=(0,k.generateCSS)(A);m.push(v)}const _=[],w=new Set;let N=p.shift();for(;N;)if(N.type===c.COMBINATOR?(_.push({combo:N,leaves:[...w]}),w.clear()):N&&w.add(N),p.length)N=p.shift();else{_.push({combo:null,leaves:[...w]}),w.clear();break}b.push(_)}t={astName:l,branches:d,twigBranches:b,selector:m.join(",")},this.#r.set(a,t)}const i=this._matchLogicalPseudoFunc(t,e,f);i&&s.add(i)}else if(Array.isArray(r))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[t]=r;return this._matchAnPlusB(t,e,l,f)}else switch(l){case"dir":case"lang":{const t=O.matcher.matchSelector(a,e);t&&s.add(t);break}case"current":case"nth-col":case"nth-last-col":{if(h){const t=`Unsupported pseudo-class :${l}()`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;default:if(!u){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,c.SYNTAX_ERR)}}else switch(l){case"any-link":case"link":{c.REG_ANCHOR.test(o)&&e.hasAttribute("href")&&s.add(e);break}case"local-link":{if(c.REG_ANCHOR.test(o)&&e.hasAttribute("href")){const{href:t,origin:i,pathname:d}=new URL(this.#s.URL),m=new URL(e.getAttribute("href"),t);m.origin===i&&m.pathname===d&&s.add(e)}break}case"visited":break;case"hover":{const{target:t,type:i}=this.#b??{};(i==="mouseover"||i==="pointerover")&&e.contains(t)&&s.add(e);break}case"active":{const{buttons:t,target:i,type:d}=this.#b??{};(d==="mousedown"||d==="pointerdown")&&t&c.BIT_01&&e.contains(i)&&s.add(e);break}case"target":{const{hash:t}=new URL(this.#s.URL);e.id&&t===`#${e.id}`&&this.#s.contains(e)&&s.add(e);break}case"target-within":{const{hash:t}=new URL(this.#s.URL);if(t){const i=t.replace(/^#/,"");let d=this.#s.getElementById(i);for(;d;){if(d===e){s.add(e);break}d=d.parentNode}}break}case"scope":{this.#e.nodeType===c.ELEMENT_NODE?!this.#d&&e===this.#e&&s.add(e):e===this.#s.documentElement&&s.add(e);break}case"focus":case"focus-visible":{const{target:t,type:i}=this.#b??{};if(e===this.#s.activeElement&&e.tabIndex>=0&&(l==="focus"||i==="keydown"&&e.contains(t))){let d=e,m=!0;for(;d;){if(d.disabled||d.hasAttribute("disabled")||d.hidden||d.hasAttribute("hidden")){m=!1;break}else{const{display:b,visibility:p}=this.#a.getComputedStyle(d);if(m=!(b==="none"||p==="hidden"),!m)break}if(d.parentNode&&d.parentNode.nodeType===c.ELEMENT_NODE)d=d.parentNode;else break}m&&s.add(e)}break}case"focus-within":{let t,i=this.#s.activeElement;if(i.tabIndex>=0)for(;i;){if(i===e){t=!0;break}i=i.parentNode}if(t){let d=e,m=!0;for(;d;){if(d.disabled||d.hasAttribute("disabled")||d.hidden||d.hasAttribute("hidden")){m=!1;break}else{const{display:b,visibility:p}=this.#a.getComputedStyle(d);if(m=!(b==="none"||p==="hidden"),!m)break}if(d.parentNode&&d.parentNode.nodeType===c.ELEMENT_NODE)d=d.parentNode;else break}m&&s.add(e)}break}case"open":{c.REG_INTERACT.test(o)&&e.hasAttribute("open")&&s.add(e);break}case"closed":{c.REG_INTERACT.test(o)&&!e.hasAttribute("open")&&s.add(e);break}case"disabled":{if(c.REG_FORM_CTRL.test(o)||(0,M.default)(o))if(e.disabled||e.hasAttribute("disabled"))s.add(e);else{let t=n;for(;t&&t.localName!=="fieldset";)t=t.parentNode;t&&n.localName!=="legend"&&t.hasAttribute("disabled")&&s.add(e)}break}case"enabled":{(c.REG_FORM_CTRL.test(o)||(0,M.default)(o))&&!(e.disabled&&e.hasAttribute("disabled"))&&s.add(e);break}case"read-only":{switch(o){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&s.add(e);break}case"input":{(!e.type||c.REG_TYPE_DATE.test(e.type)||c.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&s.add(e);break}default:(0,E.isContentEditable)(e)||s.add(e)}break}case"read-write":{switch(o){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||s.add(e);break}case"input":{(!e.type||c.REG_TYPE_DATE.test(e.type)||c.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&s.add(e);break}default:(0,E.isContentEditable)(e)&&s.add(e)}break}case"placeholder-shown":{let t;o==="textarea"?t=e:o==="input"&&(e.hasAttribute("type")?c.REG_TYPE_TEXT.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&&o==="input"&&e.hasAttribute("type")&&c.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&o==="option")&&s.add(e);break}case"indeterminate":{if(e.indeterminate&&o==="input"&&e.type==="checkbox"||o==="progress"&&!e.hasAttribute("value"))s.add(e);else if(o==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let i=e.parentNode;for(;i&&i.localName!=="form";)i=i.parentNode;i||(i=this.#s.documentElement);const d=i.getElementsByTagName("input"),m=d.length;let b;for(let p=0;p<m;p++){const _=d[p];if(_.getAttribute("type")==="radio"&&(t?_.getAttribute("name")===t&&(b=!!_.checked):_.hasAttribute("name")||(b=!!_.checked),b))break}b||s.add(e)}break}case"default":{if(o==="button"&&!(e.hasAttribute("type")&&c.REG_TYPE_RESET.test(e.getAttribute("type")))||o==="input"&&e.hasAttribute("type")&&c.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const i=this.#c;let d=this._traverse(t,i);for(d=i.firstChild();d&&t.contains(d);){const m=d.localName;let b;if(m==="button"?b=!(d.hasAttribute("type")&&c.REG_TYPE_RESET.test(d.getAttribute("type"))):m==="input"&&(b=d.hasAttribute("type")&&c.REG_TYPE_SUBMIT.test(d.getAttribute("type"))),b){d===e&&s.add(e);break}d=i.nextNode()}}}else if(o==="input"&&e.hasAttribute("type")&&c.REG_TYPE_CHECK.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))s.add(e);else if(o==="option"){let t=n,i=!1;for(;t&&t.localName!=="datalist";){if(t.localName==="select"){(t.multiple||t.hasAttribute("multiple"))&&(i=!0);break}t=t.parentNode}if(i)(e.selected||e.hasAttribute("selected"))&&s.add(e);else{const d=new Set,m=this.#c;let b=this._traverse(n,m);for(b=m.firstChild();b;){if(b.selected||b.hasAttribute("selected")){d.add(b);break}b=m.nextSibling()}d.size&&d.has(e)&&s.add(e)}}break}case"valid":{if(c.REG_FORM_VALID.test(o))e.checkValidity()&&s.add(e);else if(o==="fieldset"){const t=this.#c;let i=this._traverse(e,t);i=t.firstChild();let d;for(;i&&e.contains(i)&&!(c.REG_FORM_VALID.test(i.localName)&&(d=i.checkValidity(),!d));)i=t.nextNode();d&&s.add(e)}break}case"invalid":{if(c.REG_FORM_VALID.test(o))e.checkValidity()||s.add(e);else if(o==="fieldset"){const t=this.#c;let i=this._traverse(e,t);i=t.firstChild();let d;for(;i&&e.contains(i)&&!(c.REG_FORM_VALID.test(i.localName)&&(d=i.checkValidity(),!d));)i=t.nextNode();d||s.add(e)}break}case"in-range":{o==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&c.REG_TYPE_RANGE.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":{o==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&c.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&s.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(o))t=e;else if(o==="input")if(e.hasAttribute("type")){const i=e.getAttribute("type");(i==="file"||c.REG_TYPE_CHECK.test(i)||c.REG_TYPE_DATE.test(i)||c.REG_TYPE_TEXT.test(i))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&s.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(o))t=e;else if(o==="input")if(e.hasAttribute("type")){const i=e.getAttribute("type");(i==="file"||c.REG_TYPE_CHECK.test(i)||c.REG_TYPE_DATE.test(i)||c.REG_TYPE_TEXT.test(i))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&s.add(e);break}case"root":{e===this.#s.documentElement&&s.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#o.createTreeWalker(e,c.SHOW_ALL);let i=t.firstChild(),d;for(;i&&(d=i.nodeType!==c.ELEMENT_NODE&&i.nodeType!==c.TEXT_NODE,!!d);)i=t.nextSibling();d&&s.add(e)}else s.add(e);break}case"first-child":{(n&&e===n.firstElementChild||e===this.#t)&&s.add(e);break}case"last-child":{(n&&e===n.lastElementChild||e===this.#t)&&s.add(e);break}case"only-child":{(n&&e===n.firstElementChild&&e===n.lastElementChild||e===this.#t)&&s.add(e);break}case"first-of-type":{if(n){const[t]=this._collectNthOfType({a:0,b:1},e);t&&s.add(t)}else e===this.#t&&s.add(e);break}case"last-of-type":{if(n){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&s.add(t)}else e===this.#t&&s.add(e);break}case"only-of-type":{if(n){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[i]=this._collectNthOfType({a:0,b:1,reverse:!0},e);i===e&&s.add(e)}}else e===this.#t&&s.add(e);break}case"defined":{const t=e.getAttribute("is");t?(0,M.default)(t)&&this.#a.customElements.get(t)&&s.add(e):(0,M.default)(o)?this.#a.customElements.get(o)&&s.add(e):(e instanceof this.#a.HTMLElement||e instanceof this.#a.SVGElement)&&s.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#a.getComputedStyle(e);t!=="none"&&s.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(h){const t=`Unsupported pseudo-element ::${l}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}case"autofill":case"blank":case"buffering":case"current":case"fullscreen":case"future":case"modal":case"muted":case"past":case"paused":case"picture-in-picture":case"playing":case"seeking":case"stalled":case"user-invalid":case"user-valid":case"volume-locked":case"-webkit-autofill":{if(h){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}default:if(l.startsWith("-webkit-")){if(h){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}}else if(!u){const t=`Unknown pseudo-class :${l}`;throw new DOMException(t,c.SYNTAX_ERR)}}return s}_matchShadowHostPseudoClass(a,e){const{children:f,name:r}=a;let l;if(Array.isArray(f)){const[o]=(0,k.walkAST)(f[0]),[...n]=o,{host:u}=e;if(r==="host"){let h;for(const s of n){const{type:t}=s;if(t===c.COMBINATOR){const d=`Invalid selector ${(0,k.generateCSS)(a)}`;throw new DOMException(d,c.SYNTAX_ERR)}if(h=this._matchSelector(s,u).has(u),!h)break}h&&(l=e)}else if(r==="host-context"){let h=u,s;for(;h;){for(const t of n){const{type:i}=t;if(i===c.COMBINATOR){const m=`Invalid selector ${(0,k.generateCSS)(a)}`;throw new DOMException(m,c.SYNTAX_ERR)}if(s=this._matchSelector(t,h).has(h),!s)break}if(s)break;h=h.parentNode}s&&(l=e)}}else if(r==="host")l=e;else{const o=`Invalid selector :${r}`;throw new DOMException(o,c.SYNTAX_ERR)}return l??null}_matchSelector(a,e,f){const{type:r}=a,l=new Set;if(a.name===c.EMPTY)return l;const o=(0,k.unescapeSelector)(a.name);if(typeof o=="string"&&o!==a.name&&(a.name=o),e.nodeType===c.ELEMENT_NODE)switch(r){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(o,f);break}case c.SELECTOR_ID:{e.id===o&&l.add(e);break}case c.SELECTOR_CLASS:{e.classList.contains(o)&&l.add(e);break}case c.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(a,e,f);default:{const n=O.matcher.matchSelector(a,e,f);n&&l.add(n)}}else if(this.#d&&r===c.SELECTOR_PSEUDO_CLASS&&e.nodeType===c.DOCUMENT_FRAGMENT_NODE){if(o!=="has"&&c.REG_LOGICAL_PSEUDO.test(o))return this._matchPseudoClassSelector(a,e,f);if(c.REG_SHADOW_HOST.test(o)){const n=this._matchShadowHostPseudoClass(a,e,f);n&&l.add(n)}}return l}_matchLeaves(a,e,f){const{attributes:r,localName:l,nodeType:o}=e;let n=this.#_.get(a),u;if(n&&n.has(e)){const{attr:h,matched:s}=n.get(e);r?.length===h&&(u=s)}if(typeof u!="boolean"){let h;o===c.ELEMENT_NODE&&c.REG_FORM.test(l)?h=!1:h=!0;for(const s of a){const{name:t,type:i}=s;if(i===c.SELECTOR_PSEUDO_CLASS&&t==="dir"&&(h=!1),u=this._matchSelector(s,e,f).has(e),!u)break}h&&(n||(n=new WeakMap),n.set(e,{attr:r?.length,matched:u}),this.#_.set(a,n))}return!!u}_matchHTMLCollection(a,e={}){const{compound:f,filterLeaves:r}=e,l=new Set,o=a.length;if(o)if(f)for(let n=0;n<o;n++){const u=a[n];this._matchLeaves(r,u,e)&&l.add(u)}else{const n=[].slice.call(a);return new Set(n)}return l}_findDescendantNodes(a,e,f){const[r,...l]=a,o=l.length>0,{type:n}=r,u=(0,k.unescapeSelector)(r.name);typeof u=="string"&&u!==r.name&&(r.name=u);let h=new Set,s=!1;if(this.#d)s=!0;else switch(n){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,f);break}case c.SELECTOR_ID:{if(this.#t.nodeType===c.ELEMENT_NODE)s=!0;else{const t=this.#t.getElementById(u);t&&t!==e&&e.contains(t)&&(o?this._matchLeaves(l,t,f)&&h.add(t):h.add(t))}break}case c.SELECTOR_CLASS:{const t=e.getElementsByClassName(u);h=this._matchHTMLCollection(t,{compound:o,filterLeaves:l});break}case c.SELECTOR_TYPE:{if(this.#s.contentType==="text/html"&&!/[*|]/.test(u)){const t=e.getElementsByTagName(u);h=this._matchHTMLCollection(t,{compound:o,filterLeaves:l})}else s=!0;break}default:s=!0}return{nodes:h,pending:s}}_matchCombinator(a,e,f={}){const{combo:r,leaves:l}=a,{name:o}=r,{parentNode:n}=e,{dir:u}=f,h=new Set;if(u===S)switch(o){case"+":{const s=e.nextElementSibling;s&&this._matchLeaves(l,s,f)&&h.add(s);break}case"~":{if(n){const s=this._createTreeWalker(n);let t=this._traverse(e,s);for(t=s.nextSibling();t;)this._matchLeaves(l,t,f)&&h.add(t),t=s.nextSibling()}break}case">":{const s=this._createTreeWalker(e);let t=this._traverse(e,s);for(t=s.firstChild();t;)this._matchLeaves(l,t,f)&&h.add(t),t=s.nextSibling();break}case" ":default:{const{nodes:s,pending:t}=this._findDescendantNodes(l,e);if(s.size)return s;if(t){const i=this._createTreeWalker(e);let d=this._traverse(e,i);for(d=i.nextNode();d&&e.contains(d);)this._matchLeaves(l,d,f)&&h.add(d),d=i.nextNode()}}}else switch(o){case"+":{const s=e.previousElementSibling;s&&this._matchLeaves(l,s,f)&&h.add(s);break}case"~":{if(n){const s=this._createTreeWalker(n);let t=this._traverse(n,s);for(t=s.firstChild();t&&t!==e;)this._matchLeaves(l,t,f)&&h.add(t),t=s.nextSibling()}break}case">":{n&&this._matchLeaves(l,n,f)&&h.add(n);break}case" ":default:{const s=[];let t=n;for(;t;)this._matchLeaves(l,t,f)&&s.push(t),t=t.parentNode;if(s.length)return new Set(s.reverse())}}return h}_findNode(a,e){const{node:f}=e;let r=this._traverse(f,this.#f),l;if(r)for(r.nodeType!==c.ELEMENT_NODE?r=this.#f.nextNode():r===f&&r!==this.#t&&(r=this.#f.nextNode());r;){if(this._matchLeaves(a,r,{warn:this.#i})){l=r;break}r=this.#f.nextNode()}return l??null}_matchSelf(a){const e=[],f=this._matchLeaves(a,this.#e,{warn:this.#i});let r=!1;return f&&(e.push(this.#e),r=!0),[e,r]}_findLineal(a,e={}){const{complex:f}=e,r=[];let l=this._matchLeaves(a,this.#e,{warn:this.#i}),o=!1;if(l&&(r.push(this.#e),o=!0),!l||f){let n=this.#e.parentNode;for(;n&&(l=this._matchLeaves(a,n,{warn:this.#i}),l&&(r.push(n),o=!0),n.parentNode);)n=n.parentNode}return[r,o]}_findFirst(a){const e=[],f=this._findNode(a,{node:this.#e});let r=!1;return f&&(e.push(f),r=!0),[e,r]}_findFromHTMLCollection(a,e={}){const{complex:f,compound:r,filterLeaves:l,targetType:o}=e;let n=[],u=!1,h=!1;const s=a.length;if(s)if(this.#e.nodeType===c.ELEMENT_NODE)for(let t=0;t<s;t++){const i=a[t];if(i!==this.#e&&(this.#e.contains(i)||i.contains(this.#e))){if(r){if(this._matchLeaves(l,i,{warn:this.#i})&&(n.push(i),u=!0,o===g))break}else if(n.push(i),u=!0,o===g)break}}else if(f)if(r)for(let t=0;t<s;t++){const i=a[t];if(this._matchLeaves(l,i,{warn:this.#i})&&(n.push(i),u=!0,o===g))break}else n=[].slice.call(a),u=!0,h=!0;else if(r)for(let t=0;t<s;t++){const i=a[t];if(this._matchLeaves(l,i,{warn:this.#i})&&(n.push(i),u=!0,o===g))break}else n=[].slice.call(a),u=!0,h=!0;return[n,u,h]}_findEntryNodes(a,e,f){const{leaves:r}=a,[l,...o]=r,n=o.length>0,{name:u,type:h}=l;let s=[],t=!1,i=!1,d=!1;switch(h){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,{warn:this.#i});break}case c.SELECTOR_ID:{if(e===R)[s,i]=this._matchSelf(r);else if(e===C)[s,i]=this._findLineal(r,{complex:f});else if(e===g&&this.#t.nodeType!==c.ELEMENT_NODE){const m=this.#t.getElementById(u);m&&(n?this._matchLeaves(o,m,{warn:this.#i})&&(s.push(m),i=!0):(s.push(m),i=!0))}else e===g?[s,i]=this._findFirst(r):d=!0;break}case c.SELECTOR_CLASS:{if(e===R)[s,i]=this._matchSelf(r);else if(e===C)[s,i]=this._findLineal(r,{complex:f});else if(this.#t.nodeType===c.DOCUMENT_NODE){const m=this.#t.getElementsByClassName(u);m.length&&([s,i,t]=this._findFromHTMLCollection(m,{complex:f,compound:n,filterLeaves:o,targetType:e}))}else e===g?[s,i]=this._findFirst(r):d=!0;break}case c.SELECTOR_TYPE:{if(e===R)[s,i]=this._matchSelf(r);else if(e===C)[s,i]=this._findLineal(r,{complex:f});else if(this.#s.contentType==="text/html"&&this.#t.nodeType===c.DOCUMENT_NODE&&!/[*|]/.test(u)){const m=this.#t.getElementsByTagName(u);m.length&&([s,i,t]=this._findFromHTMLCollection(m,{complex:f,compound:n,filterLeaves:o,targetType:e}))}else e===g?[s,i]=this._findFirst(r):d=!0;break}default:if(e!==C&&c.REG_SHADOW_HOST.test(u)){if(this.#d&&this.#e.nodeType===c.DOCUMENT_FRAGMENT_NODE){const m=this._matchShadowHostPseudoClass(l,this.#e);m&&(s.push(m),i=!0)}}else e===R?[s,i]=this._matchSelf(r):e===C?[s,i]=this._findLineal(r,{complex:f}):e===g?[s,i]=this._findFirst(r):d=!0}return{collected:t,compound:n,filtered:i,nodes:s,pending:d}}_collectNodes(a){const e=this.#l.values();if(a===L||a===g){const f=new Set;let r=0;for(const{branch:l}of e){const o=l.length,n=o>1,u=l[0];let h,s;if(n){const{combo:p,leaves:[{name:_,type:w}]}=u,N=l[o-1],{leaves:[{name:A,type:v}]}=N;if(v===c.SELECTOR_PSEUDO_ELEMENT||v===c.SELECTOR_ID)h=x,s=N;else if(w===c.SELECTOR_PSEUDO_ELEMENT||w===c.SELECTOR_ID)h=S,s=u;else if(a===L)if(_==="*"&&w===c.SELECTOR_TYPE)h=x,s=N;else if(A==="*"&&v===c.SELECTOR_TYPE)h=S,s=u;else if(o===2){const{name:T}=p;/^[+~]$/.test(T)?(h=x,s=N):(h=S,s=u)}else h=S,s=u;else if(A==="*"&&v===c.SELECTOR_TYPE)h=S,s=u;else if(_==="*"&&w===c.SELECTOR_TYPE)h=x,s=N;else{let T;for(const{combo:P,leaves:[G]}of l){const{name:z,type:F}=G;if(F===c.SELECTOR_PSEUDO_CLASS&&z==="dir"){T=!1;break}if(!T&&P){const{name:H}=P;/^[+~]$/.test(H)&&(T=!0)}}T?(h=S,s=u):(h=x,s=N)}}else h=x,s=u;const{collected:t,compound:i,filtered:d,nodes:m,pending:b}=this._findEntryNodes(s,a,n);m.length?(this.#l[r].find=!0,this.#h[r]=m):b&&f.add(new Map([["index",r],["twig",s]])),this.#l[r].collected=t,this.#l[r].dir=h,this.#l[r].filtered=d||!i,r++}if(f.size){let l,o;this.#e!==this.#t&&this.#e.nodeType===c.ELEMENT_NODE?(l=this.#e,o=this.#f):(l=this.#t,o=this.#c);let n=this._traverse(l,o);for(;n;){let u=!1;if(this.#e.nodeType===c.ELEMENT_NODE?n===this.#e?u=!0:u=this.#e.contains(n):u=!0,u)for(const h of f){const{leaves:s}=h.get("twig");if(this._matchLeaves(s,n,{warn:this.#i})){const i=h.get("index");this.#l[i].filtered=!0,this.#l[i].find=!0,this.#h[i].push(n)}}n!==o.currentNode&&(n=this._traverse(n,o)),n=o.nextNode()}}}else{let f=0;for(const{branch:r}of e){const l=r[r.length-1],o=r.length>1,{compound:n,filtered:u,nodes:h}=this._findEntryNodes(l,a,o);h.length&&(this.#l[f].find=!0,this.#h[f]=h),this.#l[f].dir=x,this.#l[f].filtered=u||!n,f++}}return[this.#l,this.#h]}_getCombinedNodes(a,e,f){const r=[];for(const l of e){const o=this._matchCombinator(a,l,{dir:f,warn:this.#i});o.size&&r.push(...o)}return r.length?new Set(r):new Set}_matchNodeNext(a,e,f){const{combo:r,index:l}=f,{combo:o,leaves:n}=a[l],u={combo:r,leaves:n},h=this._getCombinedNodes(u,e,S);let s;if(h.size)if(l===a.length-1){const[t]=(0,E.sortNodes)(h);s=t}else s=this._matchNodeNext(a,h,{combo:o,index:l+1});return s??null}_matchNodePrev(a,e,f){const{index:r}=f,l=a[r],o=new Set([e]),n=this._getCombinedNodes(l,o,x);let u;if(n.size){if(r===0)u=e;else for(const h of n)if(this._matchNodePrev(a,h,{index:r-1}))return e}return u??null}_find(a){(a===L||a===g)&&this._prepareQuerySelectorWalker();const[[...e],f]=this._collectNodes(a),r=e.length;let l=new Set;for(let o=0;o<r;o++){const{branch:n,collected:u,dir:h,find:s}=e[o],t=n.length;if(t&&s){const i=f[o],d=i.length,m=t-1;if(m===0)if((a===L||a===g)&&this.#e.nodeType===c.ELEMENT_NODE)for(let b=0;b<d;b++){const p=i[b];if(p!==this.#e&&this.#e.contains(p)&&(l.add(p),a!==L))break}else if(a===L)if(l.size){const b=[...l];l=new Set([...b,...i]),this.#u=!0}else l=new Set(i);else{const[b]=i;l.add(b)}else if(a===L)if(h===S){let{combo:b}=n[0];for(const p of i){let _=new Set([p]);for(let w=1;w<t;w++){const{combo:N,leaves:A}=n[w],v={combo:b,leaves:A};if(_=this._getCombinedNodes(v,_,h),_.size)if(w===m)if(l.size){const T=[...l];l=new Set([...T,..._]),this.#u=!0}else l=_;else b=N;else break}}}else for(const b of i){let p=new Set([b]);for(let _=m-1;_>=0;_--){const w=n[_];if(p=this._getCombinedNodes(w,p,h),p.size)_===0&&(l.add(b),t>1&&l.size>1&&(this.#u=!0));else break}}else if(a===g&&h===S){const{combo:b}=n[0];let p;for(const _ of i)if(p=this._matchNodeNext(n,new Set([_]),{combo:b,index:1}),p){l.add(p);break}if(!p&&!u){const{leaves:_}=n[0],[w]=i;let N=this._findNode(_,{node:w});for(;N;){if(p=this._matchNodeNext(n,new Set([N]),{combo:b,index:1}),p){l.add(p);break}N=this._findNode(_,{node:N})}}}else{let b;for(const p of i)if(b=this._matchNodePrev(n,p,{index:m-1}),b){l.add(p);break}if(!b&&!u&&a===g){const{leaves:p}=n[m],[_]=i;let w=this._findNode(p,{node:_});for(;w;){if(b=this._matchNodePrev(n,w,{index:m-1}),b){l.add(w);break}w=this._findNode(p,{node:w})}}}}}return l}matches(a,e,f){let r;try{if(e?.nodeType!==c.ELEMENT_NODE){const n=`Unexpected node ${e?.nodeName}`;throw new TypeError(n)}const l=e.ownerDocument;if(l===this.#o&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:c.REG_COMPLEX_A.test(a),descendant:!0}))return this.#n||this._initNwsapi(l),this.#n.match(a,e);this._setup(a,e,f),r=this._find(R).size}catch(l){this._onError(l)}return!!r}closest(a,e,f){let r;try{if(e?.nodeType!==c.ELEMENT_NODE){const n=`Unexpected node ${e?.nodeName}`;throw new TypeError(n)}const l=e.ownerDocument;if(l===this.#o&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:c.REG_COMPLEX_A.test(a),descendant:!0}))return this.#n||this._initNwsapi(l),this.#n.closest(a,e);this._setup(a,e,f);const o=this._find(C);if(o.size){let n=this.#e;for(;n;){if(o.has(n)){r=n;break}n=n.parentNode}}}catch(l){this._onError(l)}return r??null}querySelector(a,e,f){let r;try{(0,E.verifyNode)(e);let l;if(e.nodeType===c.DOCUMENT_NODE?l=e:l=e.ownerDocument,l===this.#o&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:c.REG_COMPLEX_B.test(a),descendant:!1}))return this.#n||this._initNwsapi(l),this.#n.first(a,e);this._setup(a,e,f);const o=this._find(g);o.delete(this.#e),o.size&&([r]=(0,E.sortNodes)(o))}catch(l){this._onError(l)}return r??null}querySelectorAll(a,e,f){let r;try{(0,E.verifyNode)(e);let l;if(e.nodeType===c.DOCUMENT_NODE?l=e:l=e.ownerDocument,l===this.#o&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:c.REG_COMPLEX_B.test(a),descendant:!1}))return this.#n||this._initNwsapi(l),this.#n.select(a,e);this._setup(a,e,f);const o=this._find(L);o.delete(this.#e),o.size&&(this.#u?r=(0,E.sortNodes)(o):r=[...o])}catch(l){this._onError(l)}return r??[]}}0&&(module.exports={Finder}); | ||
//# sourceMappingURL=finder.js.map |
@@ -1,3 +0,3 @@ | ||
var O=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var C=(n,t)=>{for(var s in t)O(n,s,{get:t[s],enumerable:!0})},L=(n,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!y.call(n,r)&&r!==s&&O(n,r,{get:()=>t[r],enumerable:!(o=$(t,r))||o.enumerable});return n};var T=n=>L(O({},"__esModule",{value:!0}),n);var P={};C(P,{filterSelector:()=>R,generateCSS:()=>_.generate,parseAstName:()=>D,parseSelector:()=>h,preprocess:()=>x,sortAST:()=>A,unescapeSelector:()=>m,walkAST:()=>w});module.exports=T(P);var g=require("css-tree"),e=require("./constant.js"),_=require("css-tree");const m=(n="")=>{if(typeof n=="string"&&n.indexOf("\\",0)>=0){const t=n.split("\\"),s=t.length;for(let o=1;o<s;o++){let r=t[o];if(r===""&&o===s-1)r=e.U_FFFD;else{const p=/^([\da-f]{1,6}\s?)/i.exec(r);if(p){const[,i]=p;let l;try{const c=parseInt("D800",e.HEX),d=parseInt("DFFF",e.HEX),f=parseInt(i,e.HEX);f===0||f>=c&&f<=d?l=e.U_FFFD:l=String.fromCodePoint(f)}catch{l=e.U_FFFD}let a="";r.length>i.length&&(a=r.substring(i.length)),r=`${l}${a}`}else/^[\n\r\f]/.test(r)&&(r="\\"+r)}t[o]=r}n=t.join("")}return n},x=(...n)=>{if(!n.length)throw new TypeError("1 argument required, but only 0 present.");let[t]=n;if(typeof t=="string"){let s=0;for(;s>=0&&(s=t.indexOf("#",s),!(s<0));){const o=t.substring(0,s+1);let r=t.substring(s+1);if(/^\d$/.test(r.substring(0,1)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);const p=r.codePointAt(0);if(p===e.BIT_HYPHEN){if(/^\d$/.test(r.substring(1,2)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR)}else if(p>e.BIT_FFFF){const i=`\\${p.toString(e.HEX)} `;r.length===e.DUO?r=i:r=`${i}${r.substring(e.DUO)}`}t=`${o}${r}`,s++}t=t.replace(/\f|\r\n?/g,` | ||
`).replace(/[\0\uD800-\uDFFF]|\\$/g,e.U_FFFD)}else if(t==null)t=Object.prototype.toString.call(t).slice(e.TYPE_FROM,e.TYPE_TO).toLowerCase();else if(Array.isArray(t))t=t.join(",");else if(Object.prototype.hasOwnProperty.call(t,"toString"))t=t.toString();else throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);return t},h=n=>{if(n=x(n),/^$|^\s*>|,\s*$/.test(n))throw new DOMException(`Invalid selector ${n}`,e.SYNTAX_ERR);let t;try{const s=(0,g.parse)(n,{context:"selectorList",parseCustomProperty:!0});t=(0,g.toPlainObject)(s)}catch(s){const{message:o}=s,r=/(:(is|where)\(\s*\))/,p=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/;if(o==="Identifier is expected"&&p.test(n)){const[,i,l]=p.exec(n),a=l.replaceAll("*","\\*").replace(/^"/,"").replace(/"$/,"");let c=i.replace(l,a);c===":lang()"&&(c=`:lang(${e.EMPTY})`),t=h(n.replace(i,c))}else if((o==="Identifier is expected"||o==="Selector is expected")&&r.test(n)){const[,i,l]=r.exec(n),a=`:${l}(${e.EMPTY})`;t=h(n.replace(i,a))}else if(/^(?:"\]"|Attribute selector [()\s,=~^$*|]+) is expected$/.test(o)&&!n.endsWith("]")){const i=n.lastIndexOf("["),l=n.substring(i);l.includes('"')?l.match(/"/g).length%2?t=h(`${n}"]`):t=h(`${n}]`):t=h(`${n}]`)}else if(o==='")" is expected'&&!n.endsWith(")"))t=h(`${n})`);else throw new DOMException(o,e.SYNTAX_ERR)}return t},w=(n={},t=!1)=>{const s=new Set;let o,r;return(0,g.walk)(n,{enter:i=>{i.type===e.SELECTOR?s.add(i.children):(i.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(i.name)||i.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(i.name))&&(o=!0)}}),o&&(0,g.findAll)(n,(i,l,a)=>{if(a){if(i.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(i.name)){const c=a.filter(d=>{const{name:f,type:E}=d;return E===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(f)});for(const{children:d}of c)for(const{children:f}of d)for(const{children:E}of f)if(s.has(E)){if(t)for(const u of E){const{type:S}=u;if(S===e.COMBINATOR){r=!0;break}}else r=!1;s.delete(E)}}else if(i.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(i.name)){const c=a.filter(d=>{const{name:f,type:E}=d;return E===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(f)});for(const{children:d}of c)for(const{children:f}of d)s.has(f)&&s.delete(f)}}}),{branches:[...s],complex:r}},A=n=>{const t=[...n];if(t.length>1){const s=new Map([[e.SELECTOR_PSEUDO_ELEMENT,e.BIT_01],[e.SELECTOR_ID,e.BIT_02],[e.SELECTOR_CLASS,e.BIT_04],[e.SELECTOR_TYPE,e.BIT_08],[e.SELECTOR_ATTR,e.BIT_16],[e.SELECTOR_PSEUDO_CLASS,e.BIT_32]]);t.sort((o,r)=>{const{type:p}=o,{type:i}=r,l=s.get(p),a=s.get(i);let c;return l===a?c=0:l>a?c=1:c=-1,c})}return t},D=n=>{let t,s;if(n&&typeof n=="string")n.indexOf("|")>-1?[t,s]=n.split("|"):(t="*",s=n);else throw new DOMException(`Invalid selector ${n}`,e.SYNTAX_ERR);return{prefix:t,localName:s}},R=(n,t={})=>{if(!n||typeof n!="string"||/\||::|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]/.test(n))return!1;if(n.includes(":")){let s;if(e.REG_LOGICAL_KEY.test(n)){const{complex:o,descendant:r}=t;o&&r?s=e.REG_LOGICAL_COMPLEX_A:o?s=e.REG_LOGICAL_COMPLEX_B:s=e.REG_LOGICAL_COMPOUND}else s=e.REG_CHILD_INDEXED;if(s.test(n))return!1}return!0};0&&(module.exports={filterSelector,generateCSS,parseAstName,parseSelector,preprocess,sortAST,unescapeSelector,walkAST}); | ||
var u=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var S=(n,t)=>{for(var i in t)u(n,i,{get:t[i],enumerable:!0})},I=(n,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of x(t))!L.call(n,s)&&s!==i&&u(n,s,{get:()=>t[s],enumerable:!(r=h(t,s))||r.enumerable});return n};var T=n=>I(u({},"__esModule",{value:!0}),n);var m={};S(m,{filterSelector:()=>A,generateCSS:()=>_.generate,parseAstName:()=>y,parseSelector:()=>d,preprocess:()=>O,sortAST:()=>w,unescapeSelector:()=>$,walkAST:()=>C});module.exports=T(m);var E=require("css-tree"),e=require("./constant.js"),_=require("css-tree");const $=(n="")=>{if(typeof n=="string"&&n.indexOf("\\",0)>=0){const t=n.split("\\"),i=t.length;for(let r=1;r<i;r++){let s=t[r];if(s===""&&r===i-1)s=e.U_FFFD;else{const o=e.REG_HEX.exec(s);if(o){const[,l]=o;let a;try{const f=parseInt("D800",e.HEX),p=parseInt("DFFF",e.HEX),g=parseInt(l,e.HEX);g===0||g>=f&&g<=p?a=e.U_FFFD:a=String.fromCodePoint(g)}catch{a=e.U_FFFD}let c="";s.length>l.length&&(c=s.substring(l.length)),s=`${a}${c}`}else/^[\n\r\f]/.test(s)&&(s="\\"+s)}t[r]=s}n=t.join("")}return n},O=(...n)=>{if(!n.length)throw new TypeError("1 argument required, but only 0 present.");let[t]=n;if(typeof t=="string"){let i=0;for(;i>=0&&(i=t.indexOf("#",i),!(i<0));){const r=t.substring(0,i+1);let s=t.substring(i+1);if(/^\d$/.test(s.substring(0,1)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);const o=s.codePointAt(0);if(o===e.BIT_HYPHEN){if(/^\d$/.test(s.substring(1,2)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR)}else if(o>e.BIT_FFFF){const l=`\\${o.toString(e.HEX)} `;s.length===e.DUO?s=l:s=`${l}${s.substring(e.DUO)}`}t=`${r}${s}`,i++}t=t.replace(/\f|\r\n?/g,` | ||
`).replace(/[\0\uD800-\uDFFF]|\\$/g,e.U_FFFD)}else if(t==null)t=Object.prototype.toString.call(t).slice(e.TYPE_FROM,e.TYPE_TO).toLowerCase();else if(Array.isArray(t))t=t.join(",");else if(Object.prototype.hasOwnProperty.call(t,"toString"))t=t.toString();else throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);return t},d=n=>{if(n=O(n),e.REG_INVALID_SELECTOR.test(n))throw new DOMException(`Invalid selector ${n}`,e.SYNTAX_ERR);let t;try{const i=(0,E.parse)(n,{context:"selectorList",parseCustomProperty:!0});t=(0,E.toPlainObject)(i)}catch(i){const{message:r}=i;if(r==="Identifier is expected"&&e.REG_LANG_QUOTED.test(n)){const[,s,o]=e.REG_LANG_QUOTED.exec(n),l=o.replaceAll("*","\\*").replace(/^"/,"").replace(/"$/,"");let a=s.replace(o,l);a===":lang()"&&(a=`:lang(${e.EMPTY})`),t=d(n.replace(s,a))}else if(/^(?:Identifier|Selector) is expected$/.test(r)&&e.REG_LOGICAL_EMPTY.test(n)){const[,s,o]=e.REG_LOGICAL_EMPTY.exec(n);t=d(n.replace(s,`:${o}(${e.EMPTY})`))}else if(/^(?:"\]"|Attribute selector [()\s,=~^$*|]+) is expected$/.test(r)&&!n.endsWith("]")){const s=n.lastIndexOf("["),o=n.substring(s);o.includes('"')?o.match(/"/g).length%2?t=d(`${n}"]`):t=d(`${n}]`):t=d(`${n}]`)}else if(r==='")" is expected'&&!n.endsWith(")"))t=d(`${n})`);else throw new DOMException(r,e.SYNTAX_ERR)}return t},C=(n={})=>{const t=new Set;let i;return(0,E.walk)(n,{enter:s=>{s.type===e.SELECTOR?t.add(s.children):(s.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(s.name)||s.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(s.name))&&(i=!0)}}),i&&(0,E.findAll)(n,(s,o,l)=>{if(l){if(s.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(s.name)){const a=l.filter(c=>{const{name:f,type:p}=c;return p===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(f)});for(const{children:c}of a)for(const{children:f}of c)for(const{children:p}of f)t.has(p)&&t.delete(p)}else if(s.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(s.name)){const a=l.filter(c=>{const{name:f,type:p}=c;return p===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(f)});for(const{children:c}of a)for(const{children:f}of c)t.has(f)&&t.delete(f)}}}),[...t]},w=n=>{const t=[...n];if(t.length>1){const i=new Map([[e.SELECTOR_PSEUDO_ELEMENT,e.BIT_01],[e.SELECTOR_ID,e.BIT_02],[e.SELECTOR_CLASS,e.BIT_04],[e.SELECTOR_TYPE,e.BIT_08],[e.SELECTOR_ATTR,e.BIT_16],[e.SELECTOR_PSEUDO_CLASS,e.BIT_32]]);t.sort((r,s)=>{const{type:o}=r,{type:l}=s,a=i.get(o),c=i.get(l);let f;return a===c?f=0:a>c?f=1:f=-1,f})}return t},y=n=>{let t,i;if(n&&typeof n=="string")n.indexOf("|")>-1?[t,i]=n.split("|"):(t="*",i=n);else throw new DOMException(`Invalid selector ${n}`,e.SYNTAX_ERR);return{prefix:t,localName:i}},A=(n,t={})=>{if(!n||typeof n!="string")return!1;if(n.includes("[")){const i=n.lastIndexOf("[");if(n.substring(i).lastIndexOf("]")<0)return!1}if(/\||::|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]/.test(n))return!1;if(n.includes(":")){let i;if(e.REG_LOGICAL_KEY.test(n)){if(e.REG_LOGICAL_EMPTY.test(n))return!1;const{complex:r,descendant:s}=t;r&&s?i=e.REG_LOGICAL_COMPLEX_A:r?i=e.REG_LOGICAL_COMPLEX_B:i=e.REG_LOGICAL_COMPOUND}else i=e.REG_CHILD_INDEXED;if(i.test(n))return!1}return!0};0&&(module.exports={filterSelector,generateCSS,parseAstName,parseSelector,preprocess,sortAST,unescapeSelector,walkAST}); | ||
//# sourceMappingURL=parser.js.map |
@@ -52,6 +52,2 @@ { | ||
}, | ||
"overrides": { | ||
"jsdom": "^24.1.0", | ||
"nwsapi": "2.2.2" | ||
}, | ||
"scripts": { | ||
@@ -68,3 +64,3 @@ "bench": "node benchmark/bench.js", | ||
}, | ||
"version": "4.4.2" | ||
"version": "4.4.3" | ||
} |
@@ -57,41 +57,44 @@ /** | ||
export const ALPHA_NUM = '[A-Z\\d]+'; | ||
export const DIGIT = '(?:0|[1-9]\\d*)'; | ||
export const LANG_PART = `(?:-${ALPHA_NUM})*`; | ||
export const N_ST = '(?:first|last|only)-(?:child|of-type)'; | ||
export const DIGIT = '(?:0|[1-9]\\d*)'; | ||
export const ANB = | ||
`[+-]?(?:${DIGIT}n?|n)|(?:[+-]?${DIGIT})?n\\s*[+-]\\s*${DIGIT}`; | ||
// excludes An+B with selector list, e.g. :nth-child(2n+1 of .foo) | ||
// N_TH: excludes An+B with selector list, e.g. :nth-child(2n+1 of .foo) | ||
export const N_TH = | ||
`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${ANB})\\s*\\)`; | ||
// excludes :has() | ||
export const LOGICAL_KEY = '(?:is|not|where)'; | ||
// attr, id, class, pseudo-class | ||
// SUB_TYPE: attr, id, class, pseudo-class | ||
export const SUB_TYPE = '\\[[^\\]]+\\]|[#.:][\\w-]+'; | ||
// *, tag | ||
// TAG_TYPE: *, tag | ||
export const TAG_TYPE = '\\*|[A-Za-z][\\w-]*'; | ||
export const COMPOUND_A = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`; | ||
export const TAG_TYPE_I = '\\*|[A-Z][\\w-]*'; | ||
// LOGICAL_KEY: excludes :has() | ||
export const LOGICAL_KEY = '(?:is|not|where)'; | ||
export const COMPOUND = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`; | ||
export const COMBO_A = '\\s?[\\s>~+]\\s?'; | ||
export const COMBO_B = '\\s?[~+]\\s?'; | ||
export const COMPLEX_A = `${COMPOUND}(?:${COMBO_A}${COMPOUND})*`; | ||
export const COMPLEX_B = `${COMPOUND}(?:${COMBO_B}${COMPOUND})*`; | ||
export const NESTED_LOGICAL_A = | ||
`:${LOGICAL_KEY}\\(\\s*${COMPOUND_A}(?:\\s*,\\s*${COMPOUND_A})*\\s*\\)`; | ||
export const COMPOUND_B = | ||
`(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_A})+)`; | ||
export const LOGICAL_COMPOUND = | ||
`${LOGICAL_KEY}\\(\\s*${COMPOUND_B}(?:\\s*,\\s*${COMPOUND_B})*\\s*\\)`; | ||
export const COMBO_A = '\\s?[\\s>~+]\\s?'; | ||
export const COMPLEX_A = `${COMPOUND_A}(?:${COMBO_A}${COMPOUND_A})*`; | ||
`:${LOGICAL_KEY}\\(\\s*${COMPOUND}(?:\\s*,\\s*${COMPOUND})*\\s*\\)`; | ||
export const NESTED_LOGICAL_B = | ||
`:${LOGICAL_KEY}\\(\\s*${COMPLEX_A}(?:\\s*,\\s*${COMPLEX_A})*\\s*\\)`; | ||
export const NESTED_LOGICAL_C = | ||
`:${LOGICAL_KEY}\\(\\s*${COMPLEX_B}(?:\\s*,\\s*${COMPLEX_B})*\\s*\\)`; | ||
export const COMPOUND_A = | ||
`(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_A})+)`; | ||
export const COMPOUND_B = | ||
`(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_B})+)`; | ||
export const COMPOUND_C = | ||
`(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_B})+)`; | ||
export const COMPLEX_C = `${COMPOUND_C}(?:${COMBO_A}${COMPOUND_C})*`; | ||
`(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_C})+)`; | ||
export const COMPOUND_I = | ||
`(?:${TAG_TYPE_I}|(?:${TAG_TYPE_I})?(?:${SUB_TYPE})+)`; | ||
export const COMPLEX_C = `${COMPOUND_B}(?:${COMBO_A}${COMPOUND_B})*`; | ||
export const COMPLEX_D = `${COMPOUND_C}(?:${COMBO_B}${COMPOUND_C})*`; | ||
export const LOGICAL_COMPLEX_A = | ||
`${LOGICAL_KEY}\\(\\s*${COMPLEX_C}(?:\\s*,\\s*${COMPLEX_C})*\\s*\\)`; | ||
export const COMBO_B = '\\s?[~+]\\s?'; | ||
export const COMPLEX_B = `${COMPOUND_A}(?:${COMBO_B}${COMPOUND_A})*`; | ||
export const NESTED_LOGICAL_C = | ||
`:${LOGICAL_KEY}\\(\\s*${COMPLEX_B}(?:\\s*,\\s*${COMPLEX_B})*\\s*\\)`; | ||
export const COMPOUND_D = | ||
`(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE}|${NESTED_LOGICAL_C})+)`; | ||
export const COMPLEX_D = `${COMPOUND_D}(?:${COMBO_B}${COMPOUND_D})*`; | ||
export const LOGICAL_COMPLEX_B = | ||
`${LOGICAL_KEY}\\(\\s*${COMPLEX_D}(?:\\s*,\\s*${COMPLEX_D})*\\s*\\)`; | ||
export const LOGICAL_COMPOUND = | ||
`${LOGICAL_KEY}\\(\\s*${COMPOUND_A}(?:\\s*,\\s*${COMPOUND_A})*\\s*\\)`; | ||
@@ -101,2 +104,4 @@ /* regexp */ | ||
export const REG_CHILD_INDEXED = new RegExp(`:(?!${N_ST}|${N_TH})`); | ||
export const REG_COMPLEX_A = new RegExp(`${COMBO_A}${COMPOUND_I}`, 'i'); | ||
export const REG_COMPLEX_B = new RegExp(`${COMBO_B}${COMPOUND_I}`, 'i'); | ||
export const REG_DIR = /^(?:ltr|rtl)$/; | ||
@@ -107,4 +112,7 @@ export const REG_FORM = /^(?:(?:fieldse|inpu|selec)t|button|form|textarea)$/; | ||
export const REG_FORM_VALID = /^(?:button|form|input|select|textarea)$/; | ||
export const REG_HEX = /^([\da-f]{1,6}\s?)/i; | ||
export const REG_INTERACT = /^(?:details|dialog)$/; | ||
export const REG_INVALID_SELECTOR = /^$|^\s*>|,\s*$/; | ||
export const REG_LANG = new RegExp(`^(?:\\*-)?${ALPHA_NUM}${LANG_PART}$`, 'i'); | ||
export const REG_LANG_QUOTED = /(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/; | ||
export const REG_LOGICAL_COMPLEX_A = | ||
@@ -116,2 +124,3 @@ new RegExp(`:(?!${N_ST}|${N_TH}|${LOGICAL_COMPLEX_A})`); | ||
new RegExp(`:(?!${N_ST}|${N_TH}|${LOGICAL_COMPOUND})`); | ||
export const REG_LOGICAL_EMPTY = /(:(is|where)\(\s*\))/; | ||
export const REG_LOGICAL_KEY = new RegExp(`:${LOGICAL_KEY}\\(`); | ||
@@ -118,0 +127,0 @@ export const REG_LOGICAL_PSEUDO = /^(?:has|is|not|where)$/; |
@@ -11,7 +11,8 @@ /** | ||
BIT_01, BIT_02, BIT_04, BIT_08, BIT_16, BIT_32, BIT_FFFF, BIT_HYPHEN, | ||
COMBINATOR, DUO, EMPTY, HEX, REG_CHILD_INDEXED, REG_LOGICAL_COMPLEX_A, | ||
REG_LOGICAL_COMPLEX_B, REG_LOGICAL_COMPOUND, REG_LOGICAL_KEY, | ||
REG_LOGICAL_PSEUDO, REG_SHADOW_PSEUDO, SELECTOR, SELECTOR_ATTR, | ||
SELECTOR_CLASS, SELECTOR_ID, SELECTOR_PSEUDO_CLASS, SELECTOR_PSEUDO_ELEMENT, | ||
SELECTOR_TYPE, SYNTAX_ERR, TYPE_FROM, TYPE_TO, U_FFFD | ||
DUO, EMPTY, HEX, REG_CHILD_INDEXED, REG_HEX, REG_INVALID_SELECTOR, | ||
REG_LANG_QUOTED, REG_LOGICAL_COMPLEX_A, REG_LOGICAL_COMPLEX_B, | ||
REG_LOGICAL_COMPOUND, REG_LOGICAL_EMPTY, REG_LOGICAL_KEY, REG_LOGICAL_PSEUDO, | ||
REG_SHADOW_PSEUDO, SELECTOR, SELECTOR_ATTR, SELECTOR_CLASS, SELECTOR_ID, | ||
SELECTOR_PSEUDO_CLASS, SELECTOR_PSEUDO_ELEMENT, SELECTOR_TYPE, SYNTAX_ERR, | ||
TYPE_FROM, TYPE_TO, U_FFFD | ||
} from './constant.js'; | ||
@@ -33,3 +34,3 @@ | ||
} else { | ||
const hexExists = /^([\da-f]{1,6}\s?)/i.exec(item); | ||
const hexExists = REG_HEX.exec(item); | ||
if (hexExists) { | ||
@@ -132,3 +133,3 @@ const [, hex] = hexExists; | ||
// invalid selectors | ||
if (/^$|^\s*>|,\s*$/.test(selector)) { | ||
if (REG_INVALID_SELECTOR.test(selector)) { | ||
throw new DOMException(`Invalid selector ${selector}`, SYNTAX_ERR); | ||
@@ -145,7 +146,6 @@ } | ||
const { message } = e; | ||
const regEmptyIs = /(:(is|where)\(\s*\))/; | ||
// workaround for https://github.com/csstree/csstree/issues/265 | ||
const regLang = /(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/; | ||
if (message === 'Identifier is expected' && regLang.test(selector)) { | ||
const [, lang, range] = regLang.exec(selector); | ||
if (message === 'Identifier is expected' && | ||
REG_LANG_QUOTED.test(selector)) { | ||
const [, lang, range] = REG_LANG_QUOTED.exec(selector); | ||
const escapedRange = | ||
@@ -158,8 +158,6 @@ range.replaceAll('*', '\\*').replace(/^"/, '').replace(/"$/, ''); | ||
res = parseSelector(selector.replace(lang, escapedLang)); | ||
} else if ((message === 'Identifier is expected' || | ||
message === 'Selector is expected') && | ||
regEmptyIs.test(selector)) { | ||
const [, logic, name] = regEmptyIs.exec(selector); | ||
const emptyIs = `:${name}(${EMPTY})`; | ||
res = parseSelector(selector.replace(logic, emptyIs)); | ||
} else if (/^(?:Identifier|Selector) is expected$/.test(message) && | ||
REG_LOGICAL_EMPTY.test(selector)) { | ||
const [, sel, name] = REG_LOGICAL_EMPTY.exec(selector); | ||
res = parseSelector(selector.replace(sel, `:${name}(${EMPTY})`)); | ||
} else if (/^(?:"\]"|Attribute selector [()\s,=~^$*|]+) is expected$/.test(message) && | ||
@@ -170,4 +168,4 @@ !selector.endsWith(']')) { | ||
if (sel.includes('"')) { | ||
const count = sel.match(/"/g).length; | ||
if (count % 2) { | ||
const quotes = sel.match(/"/g).length; | ||
if (quotes % 2) { | ||
res = parseSelector(`${selector}"]`); | ||
@@ -192,9 +190,7 @@ } else { | ||
* @param {object} ast - AST | ||
* @param {boolean} check - check selector within logical combinators | ||
* @returns {object} - branches and complex | ||
* @returns {Array.<object|undefined>} - collection of AST branches | ||
*/ | ||
export const walkAST = (ast = {}, check = false) => { | ||
export const walkAST = (ast = {}) => { | ||
const branches = new Set(); | ||
let hasPseudoFunc; | ||
let hasComplexSelector; | ||
const opt = { | ||
@@ -230,13 +226,2 @@ enter: node => { | ||
if (branches.has(greatGrandChildren)) { | ||
if (check) { | ||
for (const greatGrandChild of greatGrandChildren) { | ||
const { type: greatGrandChildType } = greatGrandChild; | ||
if (greatGrandChildType === COMBINATOR) { | ||
hasComplexSelector = true; | ||
break; | ||
} | ||
} | ||
} else { | ||
hasComplexSelector = false; | ||
} | ||
branches.delete(greatGrandChildren); | ||
@@ -267,6 +252,3 @@ } | ||
} | ||
return { | ||
branches: [...branches], | ||
complex: hasComplexSelector | ||
}; | ||
return [...branches]; | ||
}; | ||
@@ -343,2 +325,10 @@ | ||
} | ||
// filter missing close square bracket | ||
if (selector.includes('[')) { | ||
const index = selector.lastIndexOf('['); | ||
const sel = selector.substring(index); | ||
if (sel.lastIndexOf(']') < 0) { | ||
return false; | ||
} | ||
} | ||
// filter namespaced selectors, e.g. ns|E, pseudo-element selectors and | ||
@@ -353,2 +343,6 @@ // attribute selectors with case flag, e.g. [attr i], and unclosed quotes | ||
if (REG_LOGICAL_KEY.test(selector)) { | ||
// filter empty :is() and :where() | ||
if (REG_LOGICAL_EMPTY.test(selector)) { | ||
return false; | ||
} | ||
const { complex, descendant } = opt; | ||
@@ -355,0 +349,0 @@ if (complex && descendant) { |
@@ -44,28 +44,32 @@ export const AN_PLUS_B: "AnPlusB"; | ||
export const ALPHA_NUM: "[A-Z\\d]+"; | ||
export const DIGIT: "(?:0|[1-9]\\d*)"; | ||
export const LANG_PART: "(?:-[A-Z\\d]+)*"; | ||
export const N_ST: "(?:first|last|only)-(?:child|of-type)"; | ||
export const DIGIT: "(?:0|[1-9]\\d*)"; | ||
export const ANB: "[+-]?(?:(?:0|[1-9]\\d*)n?|n)|(?:[+-]?(?:0|[1-9]\\d*))?n\\s*[+-]\\s*(?:0|[1-9]\\d*)"; | ||
export const N_TH: "nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|[+-]?(?:(?:0|[1-9]\\d*)n?|n)|(?:[+-]?(?:0|[1-9]\\d*))?n\\s*[+-]\\s*(?:0|[1-9]\\d*))\\s*\\)"; | ||
export const LOGICAL_KEY: "(?:is|not|where)"; | ||
export const SUB_TYPE: "\\[[^\\]]+\\]|[#.:][\\w-]+"; | ||
export const TAG_TYPE: "\\*|[A-Za-z][\\w-]*"; | ||
export const COMPOUND_A: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)"; | ||
export const NESTED_LOGICAL_A: ":(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\)"; | ||
export const COMPOUND_B: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+|:(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+)"; | ||
export const LOGICAL_COMPOUND: "(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+|:(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+|:(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+))*\\s*\\)"; | ||
export const TAG_TYPE_I: "\\*|[A-Z][\\w-]*"; | ||
export const LOGICAL_KEY: "(?:is|not|where)"; | ||
export const COMPOUND: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)"; | ||
export const COMBO_A: "\\s?[\\s>~+]\\s?"; | ||
export const COMBO_B: "\\s?[~+]\\s?"; | ||
export const COMPLEX_A: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*"; | ||
export const COMPLEX_B: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*"; | ||
export const NESTED_LOGICAL_A: ":(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\)"; | ||
export const NESTED_LOGICAL_B: ":(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\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z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\)"; | ||
export const COMPOUND_A: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+|:(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+)"; | ||
export const COMPOUND_B: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+|:(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\))+)"; | ||
export const COMPOUND_C: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+|:(?:is|not|where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Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\))+))*)*\\s*\\)"; | ||
export const COMBO_B: "\\s?[~+]\\s?"; | ||
export const COMPLEX_B: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*"; | ||
export const NESTED_LOGICAL_C: ":(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\)"; | ||
export const COMPOUND_D: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+|:(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[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export const LOGICAL_COMPOUND: "(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+|:(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+|:(?:is|not|where)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+))*\\s*\\)"; | ||
export const REG_ANCHOR: RegExp; | ||
export const REG_CHILD_INDEXED: RegExp; | ||
export const REG_COMPLEX_A: RegExp; | ||
export const REG_COMPLEX_B: RegExp; | ||
export const REG_DIR: RegExp; | ||
@@ -75,7 +79,11 @@ export const REG_FORM: RegExp; | ||
export const REG_FORM_VALID: RegExp; | ||
export const REG_HEX: RegExp; | ||
export const REG_INTERACT: RegExp; | ||
export const REG_INVALID_SELECTOR: RegExp; | ||
export const REG_LANG: RegExp; | ||
export const REG_LANG_QUOTED: RegExp; | ||
export const REG_LOGICAL_COMPLEX_A: RegExp; | ||
export const REG_LOGICAL_COMPLEX_B: RegExp; | ||
export const REG_LOGICAL_COMPOUND: RegExp; | ||
export const REG_LOGICAL_EMPTY: RegExp; | ||
export const REG_LOGICAL_KEY: RegExp; | ||
@@ -82,0 +90,0 @@ export const REG_LOGICAL_PSEUDO: RegExp; |
@@ -5,2 +5,3 @@ export class Finder { | ||
private _setup; | ||
private _initNwsapi; | ||
private _setEvent; | ||
@@ -7,0 +8,0 @@ private _correspond; |
export function unescapeSelector(selector?: string): string | null; | ||
export function preprocess(...args: any[]): string; | ||
export function parseSelector(selector: string): object; | ||
export function walkAST(ast?: object, check?: boolean): object; | ||
export function walkAST(ast?: object): Array<object | undefined>; | ||
export function sortAST(asts: Array<object>): Array<object>; | ||
@@ -6,0 +6,0 @@ export function parseAstName(selector: string): object; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
417993
4640