@asamuzakjp/dom-selector
Advanced tools
Comparing version 4.4.10 to 4.4.11
@@ -1,2 +0,2 @@ | ||
var T=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var w=(s,t)=>{for(var x in t)T(s,x,{get:t[x],enumerable:!0})},g=(s,t,x,M)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of H(t))!m.call(s,n)&&n!==x&&T(s,n,{get:()=>t[n],enumerable:!(M=f(t,n))||M.enumerable});return s};var X=s=>g(T({},"__esModule",{value:!0}),s);var so={};w(so,{ALPHA_NUM:()=>R,ANB:()=>a,AN_PLUS_B:()=>h,BIT_01:()=>Et,BIT_02:()=>rt,BIT_04:()=>nt,BIT_08:()=>_t,BIT_16:()=>pt,BIT_32:()=>xt,BIT_FFFF:()=>ct,BIT_HYPHEN:()=>Ot,COMBINATOR:()=>b,COMBO_A:()=>O,COMBO_B:()=>$,COMPLEX_A:()=>L,COMPLEX_B:()=>A,COMPLEX_C:()=>P,COMPLEX_D:()=>D,COMPOUND:()=>E,COMPOUND_A:()=>N,COMPOUND_B:()=>S,COMPOUND_C:()=>G,COMPOUND_I:()=>I,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>St,DOCUMENT_NODE:()=>Nt,DOCUMENT_POSITION_CONTAINED_BY:()=>Pt,DOCUMENT_POSITION_CONTAINS:()=>It,DOCUMENT_POSITION_PRECEDING:()=>Gt,DUO:()=>$t,ELEMENT_NODE:()=>Lt,EMPTY:()=>W,HEX:()=>Tt,IDENTIFIER:()=>y,LANG_PART:()=>l,LOGICAL_COMPLEX_A:()=>F,LOGICAL_COMPLEX_B:()=>Y,LOGICAL_COMPOUND:()=>u,LOGICAL_KEY:()=>e,NESTED_LOGICAL_A:()=>U,NESTED_LOGICAL_B:()=>d,NESTED_LOGICAL_C:()=>B,NOT_SUPPORTED_ERR:()=>k,NTH:()=>K,N_ST:()=>i,N_TH:()=>p,PSEUDO_CLASSES:()=>_,RAW:()=>Z,REG_ANCHOR:()=>Ut,REG_CHILD_INDEXED:()=>dt,REG_COMPLEX_A:()=>Bt,REG_COMPLEX_B:()=>Ft,REG_DIR:()=>Yt,REG_FORM:()=>ut,REG_FORM_CTRL:()=>ft,REG_FORM_GROUP:()=>Ht,REG_FORM_VALID:()=>mt,REG_HEX:()=>wt,REG_INTERACT:()=>gt,REG_INVALID_SELECTOR:()=>Xt,REG_LANG:()=>ht,REG_LANG_QUOTED:()=>bt,REG_LOGICAL_COMPLEX_A:()=>Wt,REG_LOGICAL_COMPLEX_B:()=>yt,REG_LOGICAL_COMPOUND:()=>kt,REG_LOGICAL_EMPTY:()=>Kt,REG_LOGICAL_KEY:()=>Zt,REG_LOGICAL_PSEUDO:()=>vt,REG_SHADOW_HOST:()=>zt,REG_SHADOW_MODE:()=>Vt,REG_SHADOW_PSEUDO:()=>Qt,REG_TYPE_CHECK:()=>jt,REG_TYPE_DATE:()=>qt,REG_TYPE_RANGE:()=>Jt,REG_TYPE_RESET:()=>to,REG_TYPE_SUBMIT:()=>oo,REG_TYPE_TEXT:()=>eo,SELECTOR:()=>v,SELECTOR_ATTR:()=>z,SELECTOR_CLASS:()=>V,SELECTOR_ID:()=>Q,SELECTOR_LIST:()=>j,SELECTOR_PSEUDO_CLASS:()=>q,SELECTOR_PSEUDO_ELEMENT:()=>J,SELECTOR_TYPE:()=>tt,SHOW_ALL:()=>Dt,SHOW_DOCUMENT:()=>Mt,SHOW_DOCUMENT_FRAGMENT:()=>lt,SHOW_ELEMENT:()=>it,STRING:()=>ot,SUB_TYPE:()=>r,SYNTAX_ERR:()=>et,TAG_TYPE:()=>o,TAG_TYPE_I:()=>C,TEXT_NODE:()=>At,TYPE_FROM:()=>Rt,TYPE_TO:()=>Ct,U_FFFD:()=>st,WALKER_FILTER:()=>at});module.exports=X(so);const h="AnPlusB",b="Combinator",W="__EMPTY__",y="Identifier",k="NotSupportedError",K="Nth",Z="Raw",v="Selector",z="AttributeSelector",V="ClassSelector",Q="IdSelector",j="SelectorList",q="PseudoClassSelector",J="PseudoElementSelector",tt="TypeSelector",ot="String",et="SyntaxError",st="\uFFFD",Et=1,rt=2,nt=4,_t=8,pt=16,xt=32,ct=65535,Ot=45,$t=2,Tt=16,Rt=8,Ct=-1,Lt=1,At=3,Nt=9,St=11,Gt=2,It=8,Pt=16,Dt=4294967295,Mt=256,lt=1024,it=1,at=1281,R="[A-Z\\d]+",c="(?:0|[1-9]\\d*)",l=`(?:-${R})*`,i="(?:first|last|only)-(?:child|of-type)",_=`(?:any-)?link|${i}|checked|empty|indeterminate|root|target|visited`,a=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,p=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${a})\\s*\\)`,r="\\[[^\\]]+\\]|[#.:][\\w-]+",o="\\*|[A-Za-z][\\w-]*",C="\\*|[A-Z][\\w-]*",e="(?:is|not)",E=`(?:${o}|(?:${o})?(?:${r})+)`,O="\\s?[\\s>~+]\\s?",$="\\s?[~+]\\s?",L=`${E}(?:${O}${E})*`,A=`${E}(?:${$}${E})*`,U=`:${e}\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,d=`:${e}\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,B=`:${e}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,N=`(?:${o}|(?:${o})?(?:${r}|${U})+)`,S=`(?:${o}|(?:${o})?(?:${r}|${d})+)`,G=`(?:${o}|(?:${o})?(?:${r}|${B})+)`,I=`(?:${C}|(?:${C})?(?:${r})+)`,P=`${S}(?:${O}${S})*`,D=`${G}(?:${$}${G})*`,F=`${e}\\(\\s*${P}(?:\\s*,\\s*${P})*\\s*\\)`,Y=`${e}\\(\\s*${D}(?:\\s*,\\s*${D})*\\s*\\)`,u=`${e}\\(\\s*${N}(?:\\s*,\\s*${N})*\\s*\\)`,Ut=/^a(?:rea)?$/,dt=new RegExp(`:(?!${_}|${p})`),Bt=new RegExp(`${O}${I}`,"i"),Ft=new RegExp(`${$}${I}`,"i"),Yt=/^(?:ltr|rtl)$/,ut=/^(?:(?:fieldse|inpu|selec)t|button|form|textarea)$/,ft=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Ht=/^(?:fieldset|optgroup|select)$/,mt=/^(?:button|form|input|select|textarea)$/,wt=/^([\da-f]{1,6}\s?)/i,gt=/^(?:details|dialog)$/,Xt=/^$|^\s*>|,\s*$/,ht=new RegExp(`^(?:\\*-)?${R}${l}$`,"i"),bt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,Wt=new RegExp(`:(?!${_}|${p}|${F})`),yt=new RegExp(`:(?!${_}|${p}|${Y})`),kt=new RegExp(`:(?!${_}|${p}|${u})`),Kt=/(:(is|where)\(\s*\))/,Zt=new RegExp(`:${e}\\(`),vt=/^(?:has|is|not|where)$/,zt=/^host(?:-context)?$/,Vt=/^(?:close|open)$/,Qt=/^part|slotted$/,jt=/^(?:checkbox|radio)$/,qt=/^(?:date(?:time-local)?|month|time|week)$/,Jt=/(?:date(?:time-local)?|month|number|range|time|week)$/,to=/^(?:button|reset)$/,oo=/^(?:image|submit)$/,eo=/^(?: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,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_CHILD_INDEXED,REG_COMPLEX_A,REG_COMPLEX_B,REG_DIR,REG_FORM,REG_FORM_CTRL,REG_FORM_GROUP,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}); | ||
var T=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var w=(s,t)=>{for(var x in t)T(s,x,{get:t[x],enumerable:!0})},X=(s,t,x,M)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of f(t))!m.call(s,n)&&n!==x&&T(s,n,{get:()=>t[n],enumerable:!(M=H(t,n))||M.enumerable});return s};var g=s=>X(T({},"__esModule",{value:!0}),s);var so={};w(so,{ALPHA_NUM:()=>R,ANB:()=>a,AN_PLUS_B:()=>h,BIT_01:()=>Et,BIT_02:()=>rt,BIT_04:()=>nt,BIT_08:()=>_t,BIT_16:()=>pt,BIT_32:()=>xt,BIT_FFFF:()=>ct,BIT_HYPHEN:()=>Ot,CHILD_IDX:()=>l,COMBINATOR:()=>b,COMBO_A:()=>O,COMBO_B:()=>$,COMPLEX_A:()=>L,COMPLEX_B:()=>A,COMPLEX_C:()=>D,COMPLEX_D:()=>P,COMPOUND:()=>E,COMPOUND_A:()=>N,COMPOUND_B:()=>S,COMPOUND_C:()=>G,COMPOUND_I:()=>I,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>St,DOCUMENT_NODE:()=>Nt,DOCUMENT_POSITION_CONTAINED_BY:()=>Dt,DOCUMENT_POSITION_CONTAINS:()=>It,DOCUMENT_POSITION_PRECEDING:()=>Gt,DUO:()=>$t,ELEMENT_NODE:()=>Lt,EMPTY:()=>W,HEX:()=>Tt,IDENTIFIER:()=>y,LANG_PART:()=>i,LOGICAL_COMPLEX_A:()=>F,LOGICAL_COMPLEX_B:()=>Y,LOGICAL_COMPOUND:()=>u,LOGICAL_KEY:()=>e,NESTED_LOGICAL_A:()=>U,NESTED_LOGICAL_B:()=>d,NESTED_LOGICAL_C:()=>B,NOT_SUPPORTED_ERR:()=>k,NTH:()=>K,N_TH:()=>p,PSEUDO_CLASSES:()=>_,RAW:()=>Z,REG_ANCHOR:()=>Ut,REG_CHILD_INDEXED:()=>dt,REG_COMPLEX_A:()=>Bt,REG_COMPLEX_B:()=>Ft,REG_DIR:()=>Yt,REG_FORM:()=>ut,REG_FORM_CTRL:()=>Ht,REG_FORM_GROUP:()=>ft,REG_FORM_VALID:()=>mt,REG_HEX:()=>wt,REG_INTERACT:()=>Xt,REG_INVALID_SELECTOR:()=>gt,REG_LANG:()=>ht,REG_LANG_QUOTED:()=>bt,REG_LOGICAL_COMPLEX_A:()=>Wt,REG_LOGICAL_COMPLEX_B:()=>yt,REG_LOGICAL_COMPOUND:()=>kt,REG_LOGICAL_EMPTY:()=>Kt,REG_LOGICAL_KEY:()=>Zt,REG_LOGICAL_PSEUDO:()=>vt,REG_SHADOW_HOST:()=>zt,REG_SHADOW_MODE:()=>Vt,REG_SHADOW_PSEUDO:()=>Qt,REG_TYPE_CHECK:()=>jt,REG_TYPE_DATE:()=>qt,REG_TYPE_RANGE:()=>Jt,REG_TYPE_RESET:()=>to,REG_TYPE_SUBMIT:()=>oo,REG_TYPE_TEXT:()=>eo,SELECTOR:()=>v,SELECTOR_ATTR:()=>z,SELECTOR_CLASS:()=>V,SELECTOR_ID:()=>Q,SELECTOR_LIST:()=>j,SELECTOR_PSEUDO_CLASS:()=>q,SELECTOR_PSEUDO_ELEMENT:()=>J,SELECTOR_TYPE:()=>tt,SHOW_ALL:()=>Pt,SHOW_DOCUMENT:()=>Mt,SHOW_DOCUMENT_FRAGMENT:()=>lt,SHOW_ELEMENT:()=>it,STRING:()=>ot,SUB_TYPE:()=>r,SYNTAX_ERR:()=>et,TAG_TYPE:()=>o,TAG_TYPE_I:()=>C,TEXT_NODE:()=>At,TYPE_FROM:()=>Rt,TYPE_TO:()=>Ct,U_FFFD:()=>st,WALKER_FILTER:()=>at});module.exports=g(so);const h="AnPlusB",b="Combinator",W="__EMPTY__",y="Identifier",k="NotSupportedError",K="Nth",Z="Raw",v="Selector",z="AttributeSelector",V="ClassSelector",Q="IdSelector",j="SelectorList",q="PseudoClassSelector",J="PseudoElementSelector",tt="TypeSelector",ot="String",et="SyntaxError",st="\uFFFD",Et=1,rt=2,nt=4,_t=8,pt=16,xt=32,ct=65535,Ot=45,$t=2,Tt=16,Rt=8,Ct=-1,Lt=1,At=3,Nt=9,St=11,Gt=2,It=8,Dt=16,Pt=4294967295,Mt=256,lt=1024,it=1,at=1281,R="[A-Z\\d]+",l="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",i=`(?:-${R})*`,_=`(?:any-)?link|${l}|checked|empty|indeterminate|root|target|visited`,a=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,p=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${a})\\s*\\)`,r="\\[[^\\]]+\\]|[#.:][\\w-]+",o="\\*|[A-Za-z][\\w-]*",C="\\*|[A-Z][\\w-]*",e="(?:is|not)",E=`(?:${o}|(?:${o})?(?:${r})+)`,O="\\s?[\\s>~+]\\s?",$="\\s?[~+]\\s?",L=`${E}(?:${O}${E})*`,A=`${E}(?:${$}${E})*`,U=`:${e}\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,d=`:${e}\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,B=`:${e}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,N=`(?:${o}|(?:${o})?(?:${r}|${U})+)`,S=`(?:${o}|(?:${o})?(?:${r}|${d})+)`,G=`(?:${o}|(?:${o})?(?:${r}|${B})+)`,I=`(?:${C}|(?:${C})?(?:${r})+)`,D=`${S}(?:${O}${S})*`,P=`${G}(?:${$}${G})*`,F=`${e}\\(\\s*${D}(?:\\s*,\\s*${D})*\\s*\\)`,Y=`${e}\\(\\s*${P}(?:\\s*,\\s*${P})*\\s*\\)`,u=`${e}\\(\\s*${N}(?:\\s*,\\s*${N})*\\s*\\)`,Ut=/^a(?:rea)?$/,dt=new RegExp(`:(?!${_}|${p})`),Bt=new RegExp(`${O}${I}`,"i"),Ft=new RegExp(`${$}${I}`,"i"),Yt=/^(?:ltr|rtl)$/,ut=/^(?:(?:fieldse|inpu|selec)t|button|form|textarea)$/,Ht=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,ft=/^(?:fieldset|optgroup|select)$/,mt=/^(?:button|form|input|select|textarea)$/,wt=/^([\da-f]{1,6}\s?)/i,Xt=/^(?:details|dialog)$/,gt=/^$|^\s*>|,\s*$/,ht=new RegExp(`^(?:\\*-)?${R}${i}$`,"i"),bt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,Wt=new RegExp(`:(?!${_}|${p}|${F})`),yt=new RegExp(`:(?!${_}|${p}|${Y})`),kt=new RegExp(`:(?!${_}|${p}|${u})`),Kt=/(:(is|where)\(\s*\))/,Zt=new RegExp(`:${e}\\(`),vt=/^(?:has|is|not|where)$/,zt=/^host(?:-context)?$/,Vt=/^(?:close|open)$/,Qt=/^part|slotted$/,jt=/^(?:checkbox|radio)$/,qt=/^(?:date(?:time-local)?|month|time|week)$/,Jt=/(?:date(?:time-local)?|month|number|range|time|week)$/,to=/^(?:button|reset)$/,oo=/^(?:image|submit)$/,eo=/^(?:email|number|password|search|tel|text|url)$/;0&&(module.exports={ALPHA_NUM,ANB,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,BIT_HYPHEN,CHILD_IDX,COMBINATOR,COMBO_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_TH,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_CHILD_INDEXED,REG_COMPLEX_A,REG_COMPLEX_B,REG_DIR,REG_FORM,REG_FORM_CTRL,REG_FORM_GROUP,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 H=Object.create;var D=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var V=(g,a)=>{for(var e in a)D(g,e,{get:a[e],enumerable:!0})},I=(g,a,e,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of j(a))!q.call(g,r)&&r!==e&&D(g,r,{get:()=>a[r],enumerable:!(o=B(a,r))||o.enumerable});return g};var U=(g,a,e)=>(e=g!=null?H(Y(g)):{},I(a||!g||!g.__esModule?D(e,"default",{value:g,enumerable:!0}):e,g)),X=g=>I(D({},"__esModule",{value:!0}),g);var Q={};V(Q,{Finder:()=>K});module.exports=X(Q);var M=U(require("is-potential-custom-element-name"),1),G=U(require("@asamuzakjp/nwsapi"),1),E=require("./dom-util.js"),O=require("./matcher.js"),k=require("./parser.js"),n=require("./constant.js");const x="next",S="prev",L="all",y="first",C="lineal",R="self";class K{#l;#r;#s;#p;#c;#b;#e;#h;#w;#f;#o;#_;#t;#d;#u;#n;#m;#i;#a;constructor(a,e){this.#a=a,this.#c=e??a.document,this.#r=new WeakMap,this.#_=new WeakMap,this._initNwsapi()}_onError(a){if(!this.#w)if(a instanceof DOMException||a instanceof this.#a.DOMException)if(a.name===n.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,o={}){const{event:r,invalidate:l,noexcept:f,warn:c}=o;return(typeof a=="string"&&a.includes(":has(")||l&&e.nodeType===n.ELEMENT_NODE)&&(this.#r=new WeakMap),this.#w=!!f,this.#i=!!c,this.#b=this._setEvent(r),this.#e=e,[this.#s,this.#t,this.#n]=(0,E.resolveContent)(e),this.#d=(0,E.isInShadowTree)(e),[this.#l,this.#h]=this._correspond(a),this.#m=new WeakMap,e}_initNwsapi(){return this.#f=(0,G.default)({DOMException:this.#a.DOMException,document:this.#c}),this.#f.configure({LOGERRORS:!1}),this.#f}_setEvent(a){return a instanceof this.#a.MouseEvent||a instanceof this.#a.KeyboardEvent?a:null}_correspond(a){const e=[];this.#p=!1;let o;if(this.#s){const r=this.#r.get(this.#s);if(r&&r.has(`${a}`)){const l=r.get(`${a}`);this.#p=l.descendant,o=l.ast}}if(o){const r=o.length;for(let l=0;l<r;l++)o[l].collected=!1,o[l].dir=null,o[l].filtered=!1,o[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 f=!1,c=0;o=[];for(const[...u]of l){const h=[];let i=u.shift();if(i&&i.type!==n.COMBINATOR){const t=new Set;for(;i;){if(i.type===n.COMBINATOR){const[s]=u;if(s.type===n.COMBINATOR){const m=`Invalid selector ${a}`;throw new DOMException(m,n.SYNTAX_ERR)}const d=i.name;/^[\s>]$/.test(d)&&(f=!0),h.push({combo:i,leaves:(0,k.sortAST)(t)}),t.clear()}else if(i){let{name:s}=i;s&&typeof s=="string"&&(s=(0,k.unescapeSelector)(s),typeof s=="string"&&s!==i.name&&(i.name=s),/[|:]/.test(s)&&(i.namespace=!0)),t.add(i)}if(u.length)i=u.shift();else{h.push({combo:null,leaves:(0,k.sortAST)(t)}),t.clear();break}}}o.push({branch:h,collected:!1,dir:null,filtered:!1,find:!1}),e[c]=[],c++}if(this.#s){let u;this.#r.has(this.#s)?u=this.#r.get(this.#s):u=new Map,u.set(`${a}`,{ast:o,descendant:f}),this.#r.set(this.#s,u)}this.#p=f}return[o,e]}_createTreeWalker(a){let e;return this.#m.has(a)?e=this.#m.get(a):(e=this.#c.createTreeWalker(a,n.WALKER_FILTER),this.#m.set(a,e)),e}_prepareQuerySelectorWalker(){return this.#o=this._createTreeWalker(this.#e),this.#u=!1,this.#o}_traverse(a,e=this.#n){let o=e.currentNode,r;if(o===a)r=o;else if(o.contains(a))for(o=e.nextNode();o;){if(o===a){r=o;break}o=e.nextNode()}else{if(o!==e.root)for(;o&&!(o===e.root||o===a);)o=e.parentNode();if(a?.nodeType===n.ELEMENT_NODE)for(;o;){if(o===a){r=o;break}o=e.nextNode()}else r=o}return r??null}_collectNthChild(a,e,o){const{a:r,b:l,reverse:f,selector:c}=a,{parentNode:u}=e,h=new Set;let i;if(c&&(this.#r.has(c)?i=this.#r.get(c):(i=(0,k.walkAST)(c),this.#r.set(c,i))),u){const t=this.#n;let s=this._traverse(u,t);s=t.firstChild();let d=0;for(;s;)d++,s=t.nextSibling();s=this._traverse(u,t);const m=new Set;if(i)for(s=t.firstChild();s;){let b;for(const p of i)if(b=this._matchLeaves(p,s,o),!b)break;b&&m.add(s),s=t.nextSibling()}if(r===0){if(l>0&&l<=d){if(m.size){s=this._traverse(u,t),f?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(m.has(s)){if(b===l-1){h.add(s);break}b++}f?s=t.previousSibling():s=t.nextSibling()}}else if(!c){s=this._traverse(u,t),f?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(b===l-1){h.add(s);break}f?s=t.previousSibling():s=t.nextSibling(),b++}}}}else{let b=l-1;if(r>0)for(;b<0;)b+=r;if(b>=0&&b<d){s=this._traverse(u,t),f?s=t.lastChild():s=t.firstChild();let p=0,_=r>0?0:l-1;for(;s&&(s&&b>=0&&b<d);)m.size?m.has(s)&&(_===b&&(h.add(s),b+=r),r>0?_++:_--):p===b&&(c||h.add(s),b+=r),f?s=t.previousSibling():s=t.nextSibling(),p++}}if(f&&h.size>1){const b=[...h];return new Set(b.reverse())}}else if(e===this.#t&&r+l===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,o),t)break;t&&h.add(e)}else h.add(e);return h}_collectNthOfType(a,e){const{a:o,b:r,reverse:l}=a,{localName:f,parentNode:c,prefix:u}=e,h=new Set;if(c){const i=this.#n;let t=this._traverse(c,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(o===0){if(r>0&&r<=s){t=this._traverse(c,i),l?t=i.lastChild():t=i.firstChild();let d=0;for(;t;){const{localName:m,prefix:b}=t;if(m===f&&b===u){if(d===r-1){h.add(t);break}d++}l?t=i.previousSibling():t=i.nextSibling()}}}else{let d=r-1;if(o>0)for(;d<0;)d+=o;if(d>=0&&d<s){t=this._traverse(c,i),l?t=i.lastChild():t=i.firstChild();let m=o>0?0:r-1;for(;t;){const{localName:b,prefix:p}=t;if(b===f&&p===u){if(m===d&&(h.add(t),d+=o),d<0||d>=s)break;o>0?m++:m--}l?t=i.previousSibling():t=i.nextSibling()}}}if(l&&h.size>1){const d=[...h];return new Set(d.reverse())}}else e===this.#t&&o+r===1&&h.add(e);return h}_matchAnPlusB(a,e,o,r){const{nth:{a:l,b:f,name:c},selector:u}=a,h=new Map;if(c?(c==="even"?(h.set("a",2),h.set("b",0)):c==="odd"&&(h.set("a",2),h.set("b",1)),o.indexOf("last")>-1&&h.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?h.set("a",l*1):h.set("a",0),typeof f=="string"&&/-?\d+/.test(f)?h.set("b",f*1):h.set("b",0),o.indexOf("last")>-1&&h.set("reverse",!0)),/^nth-(?:last-)?child$/.test(o)){u&&h.set("selector",u);const i=Object.fromEntries(h);return this._collectNthChild(i,e,r)}else if(/^nth-(?:last-)?of-type$/.test(o)){const i=Object.fromEntries(h);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(a,e,o={}){let r;if(Array.isArray(a)&&a.length){const[l]=a,{type:f}=l;let c;f===n.COMBINATOR?c=a.shift():c={name:" ",type:n.COMBINATOR};const u=[];for(;a.length;){const[t]=a,{type:s}=t;if(s===n.COMBINATOR)break;u.push(a.shift())}const h={combo:c,leaves:u};o.dir=x;const i=this._matchCombinator(h,e,o);if(i.size)if(a.length){for(const t of i)if(r=this._matchHasPseudoFunc(Object.assign([],a),t,o),r)break}else r=!0}return!!r}_matchLogicalPseudoFunc(a,e,o={}){const{astName:r="",branches:l=[],selector:f="",twigBranches:c=[]}=a;let u;if(r==="has")if(f.includes(":has("))u=null;else{let h;for(const i of l)if(h=this._matchHasPseudoFunc(Object.assign([],i),e,o),h)break;h&&(u=e)}else{const h=/^(?:is|where)$/.test(r);o.forgive=h;const i=c.length;let t;for(let s=0;s<i;s++){const d=c[s],m=d.length-1,{leaves:b}=d[m];if(t=this._matchLeaves(b,e,o),t&&m>0){let p=new Set([e]);for(let _=m-1;_>=0;_--){const w=d[_],N=[];o.dir=S;for(const A of p){const v=this._matchCombinator(w,A,o);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,o={}){const{children:r,name:l}=a,{localName:f,parentNode:c}=e,{forgive:u,warn:h=this.#i}=o,i=new Set;if(n.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===n.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 s=this._matchLogicalPseudoFunc(t,e,o);s&&i.add(s)}else if(Array.isArray(r))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[t]=r;return this._matchAnPlusB(t,e,l,o)}else switch(l){case"dir":case"lang":{const t=O.matcher.matchSelector(a,e);t&&i.add(t);break}case"current":case"nth-col":case"nth-last-col":{if(h){const t=`Unsupported pseudo-class :${l}()`;throw new DOMException(t,n.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(h){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,n.NOT_SUPPORTED_ERR)}break}default:if(!u){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,n.SYNTAX_ERR)}}else switch(l){case"any-link":case"link":{n.REG_ANCHOR.test(f)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(n.REG_ANCHOR.test(f)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:d}=new URL(this.#s.URL),m=new URL(e.getAttribute("href"),t);m.origin===s&&m.pathname===d&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#b??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:d}=this.#b??{};(d==="mousedown"||d==="pointerdown")&&t&n.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#s.URL);e.id&&t===`#${e.id}`&&this.#s.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#s.URL);if(t){const s=t.replace(/^#/,"");let d=this.#s.getElementById(s);for(;d;){if(d===e){i.add(e);break}d=d.parentNode}}break}case"scope":{this.#e.nodeType===n.ELEMENT_NODE?!this.#d&&e===this.#e&&i.add(e):e===this.#s.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#b??{};if(e===this.#s.activeElement&&e.tabIndex>=0&&(l==="focus"||s==="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===n.ELEMENT_NODE)d=d.parentNode;else break}m&&i.add(e)}break}case"focus-within":{let t,s=this.#s.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.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===n.ELEMENT_NODE)d=d.parentNode;else break}m&&i.add(e)}break}case"open":{n.REG_INTERACT.test(f)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{n.REG_INTERACT.test(f)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(n.REG_FORM_CTRL.test(f)||(0,M.default)(f))if(e.disabled||e.hasAttribute("disabled"))i.add(e);else{let t=c;for(;t;){if(n.REG_FORM_GROUP.test(t.localName))if(t.localName==="fieldset"){if(t.disabled&&t.hasAttribute("disabled"))break}else break;t=t.parentNode}t&&c.localName!=="legend"&&(t.disabled||t.hasAttribute("disabled"))&&i.add(e)}break}case"enabled":{(n.REG_FORM_CTRL.test(f)||(0,M.default)(f))&&!(e.disabled&&e.hasAttribute("disabled"))&&i.add(e);break}case"read-only":{switch(f){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||n.REG_TYPE_DATE.test(e.type)||n.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,E.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(f){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||n.REG_TYPE_DATE.test(e.type)||n.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,E.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;f==="textarea"?s=e:f==="input"&&(e.hasAttribute("type")?n.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&f==="input"&&e.hasAttribute("type")&&n.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&f==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&f==="input"&&e.type==="checkbox"||f==="progress"&&!e.hasAttribute("value"))i.add(e);else if(f==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;s||(s=this.#s.documentElement);const d=s.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||i.add(e)}break}case"default":{if(f==="button"&&!(e.hasAttribute("type")&&n.REG_TYPE_RESET.test(e.getAttribute("type")))||f==="input"&&e.hasAttribute("type")&&n.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#n;let d=this._traverse(t,s);for(d=s.firstChild();d&&t.contains(d);){const m=d.localName;let b;if(m==="button"?b=!(d.hasAttribute("type")&&n.REG_TYPE_RESET.test(d.getAttribute("type"))):m==="input"&&(b=d.hasAttribute("type")&&n.REG_TYPE_SUBMIT.test(d.getAttribute("type"))),b){d===e&&i.add(e);break}d=s.nextNode()}}}else if(f==="input"&&e.hasAttribute("type")&&n.REG_TYPE_CHECK.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))i.add(e);else if(f==="option"){let t=c,s=!1;for(;t&&t.localName!=="datalist";){if(t.localName==="select"){(t.multiple||t.hasAttribute("multiple"))&&(s=!0);break}t=t.parentNode}if(s)(e.selected||e.hasAttribute("selected"))&&i.add(e);else{const d=new Set,m=this.#n;let b=this._traverse(c,m);for(b=m.firstChild();b;){if(b.selected||b.hasAttribute("selected")){d.add(b);break}b=m.nextSibling()}d.size&&d.has(e)&&i.add(e)}}break}case"valid":{if(n.REG_FORM_VALID.test(f))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(f==="fieldset"){const t=this.#n;let s=this._traverse(e,t);s=t.firstChild();let d;if(!s)d=!0;else for(;s&&e.contains(s)&&!(n.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?d=s.maxLength>=s.value.length:d=!0:d=!1,!d));)s=t.nextNode();d&&i.add(e)}break}case"invalid":{if(n.REG_FORM_VALID.test(f))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(f==="fieldset"){const t=this.#n;let s=this._traverse(e,t);s=t.firstChild();let d;if(!s)d=!0;else for(;s&&e.contains(s)&&!(n.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?d=s.maxLength>=s.value.length:d=!0:d=!1,!d));)s=t.nextNode();d||i.add(e)}break}case"in-range":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&n.REG_TYPE_RANGE.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&i.add(e);break}case"out-of-range":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&n.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||n.REG_TYPE_CHECK.test(s)||n.REG_TYPE_DATE.test(s)||n.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||n.REG_TYPE_CHECK.test(s)||n.REG_TYPE_DATE.test(s)||n.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#s.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#c.createTreeWalker(e,n.SHOW_ALL);let s=t.firstChild(),d;for(;s&&(d=s.nodeType!==n.ELEMENT_NODE&&s.nodeType!==n.TEXT_NODE,!!d);)s=t.nextSibling();d&&i.add(e)}else i.add(e);break}case"first-child":{(c&&e===c.firstElementChild||e===this.#t)&&i.add(e);break}case"last-child":{(c&&e===c.lastElementChild||e===this.#t)&&i.add(e);break}case"only-child":{(c&&e===c.firstElementChild&&e===c.lastElementChild||e===this.#t)&&i.add(e);break}case"first-of-type":{if(c){const[t]=this._collectNthOfType({a:0,b:1},e);t&&i.add(t)}else e===this.#t&&i.add(e);break}case"last-of-type":{if(c){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&i.add(t)}else e===this.#t&&i.add(e);break}case"only-of-type":{if(c){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s===e&&i.add(e)}}else e===this.#t&&i.add(e);break}case"defined":{const t=e.getAttribute("is");t?(0,M.default)(t)&&this.#a.customElements.get(t)&&i.add(e):(0,M.default)(f)?this.#a.customElements.get(f)&&i.add(e):(e instanceof this.#a.HTMLElement||e instanceof this.#a.SVGElement)&&i.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#a.getComputedStyle(e);t!=="none"&&i.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(h){const t=`Unsupported pseudo-element ::${l}`;throw new DOMException(t,n.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,n.NOT_SUPPORTED_ERR)}break}default:if(l.startsWith("-webkit-")){if(h){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,n.NOT_SUPPORTED_ERR)}}else if(!u){const t=`Unknown pseudo-class :${l}`;throw new DOMException(t,n.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(a,e){const{children:o,name:r}=a;let l;if(Array.isArray(o)){const[f]=(0,k.walkAST)(o[0]),[...c]=f,{host:u}=e;if(r==="host"){let h;for(const i of c){const{type:t}=i;if(t===n.COMBINATOR){const d=`Invalid selector ${(0,k.generateCSS)(a)}`;throw new DOMException(d,n.SYNTAX_ERR)}if(h=this._matchSelector(i,u).has(u),!h)break}h&&(l=e)}else if(r==="host-context"){let h=u,i;for(;h;){for(const t of c){const{type:s}=t;if(s===n.COMBINATOR){const m=`Invalid selector ${(0,k.generateCSS)(a)}`;throw new DOMException(m,n.SYNTAX_ERR)}if(i=this._matchSelector(t,h).has(h),!i)break}if(i)break;h=h.parentNode}i&&(l=e)}}else if(r==="host")l=e;else{const f=`Invalid selector :${r}`;throw new DOMException(f,n.SYNTAX_ERR)}return l??null}_matchSelector(a,e,o){const{type:r}=a,l=new Set;if(a.name===n.EMPTY)return l;const f=(0,k.unescapeSelector)(a.name);if(typeof f=="string"&&f!==a.name&&(a.name=f),e.nodeType===n.ELEMENT_NODE)switch(r){case n.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(f,o);break}case n.SELECTOR_ID:{e.id===f&&l.add(e);break}case n.SELECTOR_CLASS:{e.classList.contains(f)&&l.add(e);break}case n.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(a,e,o);default:{const c=O.matcher.matchSelector(a,e,o);c&&l.add(c)}}else if(this.#d&&r===n.SELECTOR_PSEUDO_CLASS&&e.nodeType===n.DOCUMENT_FRAGMENT_NODE){if(f!=="has"&&n.REG_LOGICAL_PSEUDO.test(f))return this._matchPseudoClassSelector(a,e,o);if(n.REG_SHADOW_HOST.test(f)){const c=this._matchShadowHostPseudoClass(a,e,o);c&&l.add(c)}}return l}_matchLeaves(a,e,o){const{attributes:r,localName:l,nodeType:f}=e;let c=this.#_.get(a),u;if(c&&c.has(e)){const{attr:h,matched:i}=c.get(e);r?.length===h&&(u=i)}if(typeof u!="boolean"){let h;f===n.ELEMENT_NODE&&n.REG_FORM.test(l)?h=!1:h=!0;for(const i of a){const{name:t,type:s}=i;if(s===n.SELECTOR_PSEUDO_CLASS&&t==="dir"&&(h=!1),u=this._matchSelector(i,e,o).has(e),!u)break}h&&(c||(c=new WeakMap),c.set(e,{attr:r?.length,matched:u}),this.#_.set(a,c))}return!!u}_matchHTMLCollection(a,e={}){const{compound:o,filterLeaves:r}=e,l=new Set,f=a.length;if(f)if(o)for(let c=0;c<f;c++){const u=a[c];this._matchLeaves(r,u,e)&&l.add(u)}else{const c=[].slice.call(a);return new Set(c)}return l}_findDescendantNodes(a,e,o){const[r,...l]=a,f=l.length>0,{type:c}=r,u=(0,k.unescapeSelector)(r.name);typeof u=="string"&&u!==r.name&&(r.name=u);let h=new Set,i=!1;if(this.#d)i=!0;else switch(c){case n.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,o);break}case n.SELECTOR_ID:{if(this.#t.nodeType===n.ELEMENT_NODE)i=!0;else{const t=this.#t.getElementById(u);t&&t!==e&&e.contains(t)&&(f?this._matchLeaves(l,t,o)&&h.add(t):h.add(t))}break}case n.SELECTOR_CLASS:{const t=e.getElementsByClassName(u);h=this._matchHTMLCollection(t,{compound:f,filterLeaves:l});break}case n.SELECTOR_TYPE:{if(this.#s.contentType==="text/html"&&!/[*|]/.test(u)){const t=e.getElementsByTagName(u);h=this._matchHTMLCollection(t,{compound:f,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:h,pending:i}}_matchCombinator(a,e,o={}){const{combo:r,leaves:l}=a,{name:f}=r,{parentNode:c}=e,{dir:u}=o,h=new Set;if(u===x)switch(f){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,o)&&h.add(i);break}case"~":{if(c){const i=this._createTreeWalker(c);let t=this._traverse(e,i);for(t=i.nextSibling();t;)this._matchLeaves(l,t,o)&&h.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=this._traverse(e,i);for(t=i.firstChild();t;)this._matchLeaves(l,t,o)&&h.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(l,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let d=this._traverse(e,s);for(d=s.nextNode();d&&e.contains(d);)this._matchLeaves(l,d,o)&&h.add(d),d=s.nextNode()}}}else switch(f){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,o)&&h.add(i);break}case"~":{if(c){const i=this._createTreeWalker(c);let t=this._traverse(c,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(l,t,o)&&h.add(t),t=i.nextSibling()}break}case">":{c&&this._matchLeaves(l,c,o)&&h.add(c);break}case" ":default:{const i=[];let t=c;for(;t;)this._matchLeaves(l,t,o)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return h}_findNode(a,e){const{node:o}=e;let r=this._traverse(o,this.#o),l;if(r)for(r.nodeType!==n.ELEMENT_NODE?r=this.#o.nextNode():r===o&&r!==this.#t&&(r=this.#o.nextNode());r;){if(this._matchLeaves(a,r,{warn:this.#i})){l=r;break}r=this.#o.nextNode()}return l??null}_matchSelf(a){const e=[],o=this._matchLeaves(a,this.#e,{warn:this.#i});let r=!1;return o&&(e.push(this.#e),r=!0),[e,r]}_findLineal(a,e={}){const{complex:o}=e,r=[];let l=this._matchLeaves(a,this.#e,{warn:this.#i}),f=!1;if(l&&(r.push(this.#e),f=!0),!l||o){let c=this.#e.parentNode;for(;c&&(l=this._matchLeaves(a,c,{warn:this.#i}),l&&(r.push(c),f=!0),c.parentNode);)c=c.parentNode}return[r,f]}_findFirst(a){const e=[],o=this._findNode(a,{node:this.#e});let r=!1;return o&&(e.push(o),r=!0),[e,r]}_findFromHTMLCollection(a,e={}){const{complex:o,compound:r,filterLeaves:l,targetType:f}=e;let c=[],u=!1,h=!1;const i=a.length;if(i)if(this.#e.nodeType===n.ELEMENT_NODE)for(let t=0;t<i;t++){const s=a[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(r){if(this._matchLeaves(l,s,{warn:this.#i})&&(c.push(s),u=!0,f===y))break}else if(c.push(s),u=!0,f===y)break}}else if(o)if(r)for(let t=0;t<i;t++){const s=a[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(c.push(s),u=!0,f===y))break}else c=[].slice.call(a),u=!0,h=!0;else if(r)for(let t=0;t<i;t++){const s=a[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(c.push(s),u=!0,f===y))break}else c=[].slice.call(a),u=!0,h=!0;return[c,u,h]}_findEntryNodes(a,e,o){const{leaves:r}=a,[l,...f]=r,c=f.length>0,{name:u,type:h}=l;let i=[],t=!1,s=!1,d=!1;switch(h){case n.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,{warn:this.#i});break}case n.SELECTOR_ID:{if(e===R)[i,s]=this._matchSelf(r);else if(e===C)[i,s]=this._findLineal(r,{complex:o});else if(e===y&&this.#t.nodeType!==n.ELEMENT_NODE){const m=this.#t.getElementById(u);m&&(c?this._matchLeaves(f,m,{warn:this.#i})&&(i.push(m),s=!0):(i.push(m),s=!0))}else e===y?[i,s]=this._findFirst(r):d=!0;break}case n.SELECTOR_CLASS:{if(e===R)[i,s]=this._matchSelf(r);else if(e===C)[i,s]=this._findLineal(r,{complex:o});else if(this.#t.nodeType===n.DOCUMENT_NODE){const m=this.#t.getElementsByClassName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:o,compound:c,filterLeaves:f,targetType:e}))}else e===y?[i,s]=this._findFirst(r):d=!0;break}case n.SELECTOR_TYPE:{if(e===R)[i,s]=this._matchSelf(r);else if(e===C)[i,s]=this._findLineal(r,{complex:o});else if(this.#s.contentType==="text/html"&&this.#t.nodeType===n.DOCUMENT_NODE&&!/[*|]/.test(u)){const m=this.#t.getElementsByTagName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:o,compound:c,filterLeaves:f,targetType:e}))}else e===y?[i,s]=this._findFirst(r):d=!0;break}default:if(e!==C&&n.REG_SHADOW_HOST.test(u)){if(this.#d&&this.#e.nodeType===n.DOCUMENT_FRAGMENT_NODE){const m=this._matchShadowHostPseudoClass(l,this.#e);m&&(i.push(m),s=!0)}}else e===R?[i,s]=this._matchSelf(r):e===C?[i,s]=this._findLineal(r,{complex:o}):e===y?[i,s]=this._findFirst(r):d=!0}return{collected:t,compound:c,filtered:s,nodes:i,pending:d}}_collectNodes(a){const e=this.#l.values();if(a===L||a===y){const o=new Set;let r=0;for(const{branch:l}of e){const f=l.length,c=f>1,u=l[0];let h,i;if(c){const{combo:p,leaves:[{name:_,type:w}]}=u,N=l[f-1],{leaves:[{name:A,type:v}]}=N;if(v===n.SELECTOR_PSEUDO_ELEMENT||v===n.SELECTOR_ID)h=S,i=N;else if(w===n.SELECTOR_PSEUDO_ELEMENT||w===n.SELECTOR_ID)h=x,i=u;else if(a===L)if(_==="*"&&w===n.SELECTOR_TYPE)h=S,i=N;else if(A==="*"&&v===n.SELECTOR_TYPE)h=x,i=u;else if(f===2){const{name:T}=p;/^[+~]$/.test(T)?(h=S,i=N):(h=x,i=u)}else h=x,i=u;else if(A==="*"&&v===n.SELECTOR_TYPE)h=x,i=u;else if(_==="*"&&w===n.SELECTOR_TYPE)h=S,i=N;else{let T;for(const{combo:P,leaves:[$]}of l){const{name:F,type:z}=$;if(z===n.SELECTOR_PSEUDO_CLASS&&F==="dir"){T=!1;break}if(!T&&P){const{name:W}=P;/^[+~]$/.test(W)&&(T=!0)}}T?(h=x,i=u):(h=S,i=N)}}else h=S,i=u;const{collected:t,compound:s,filtered:d,nodes:m,pending:b}=this._findEntryNodes(i,a,c);m.length?(this.#l[r].find=!0,this.#h[r]=m):b&&o.add(new Map([["index",r],["twig",i]])),this.#l[r].collected=t,this.#l[r].dir=h,this.#l[r].filtered=d||!s,r++}if(o.size){let l,f;this.#e!==this.#t&&this.#e.nodeType===n.ELEMENT_NODE?(l=this.#e,f=this.#o):(l=this.#t,f=this.#n);let c=this._traverse(l,f);for(;c;){let u=!1;if(this.#e.nodeType===n.ELEMENT_NODE?c===this.#e?u=!0:u=this.#e.contains(c):u=!0,u)for(const h of o){const{leaves:i}=h.get("twig");if(this._matchLeaves(i,c,{warn:this.#i})){const s=h.get("index");this.#l[s].filtered=!0,this.#l[s].find=!0,this.#h[s].push(c)}}c!==f.currentNode&&(c=this._traverse(c,f)),c=f.nextNode()}}}else{let o=0;for(const{branch:r}of e){const l=r[r.length-1],f=r.length>1,{compound:c,filtered:u,nodes:h}=this._findEntryNodes(l,a,f);h.length&&(this.#l[o].find=!0,this.#h[o]=h),this.#l[o].dir=S,this.#l[o].filtered=u||!c,o++}}return[this.#l,this.#h]}_getCombinedNodes(a,e,o){const r=[];for(const l of e){const f=this._matchCombinator(a,l,{dir:o,warn:this.#i});f.size&&r.push(...f)}return r.length?new Set(r):new Set}_matchNodeNext(a,e,o){const{combo:r,index:l}=o,{combo:f,leaves:c}=a[l],u={combo:r,leaves:c},h=this._getCombinedNodes(u,e,x);let i;if(h.size)if(l===a.length-1){const[t]=(0,E.sortNodes)(h);i=t}else i=this._matchNodeNext(a,h,{combo:f,index:l+1});return i??null}_matchNodePrev(a,e,o){const{index:r}=o,l=a[r],f=new Set([e]),c=this._getCombinedNodes(l,f,S);let u;if(c.size){if(r===0)u=e;else for(const h of c)if(this._matchNodePrev(a,h,{index:r-1}))return e}return u??null}_find(a){(a===L||a===y)&&this._prepareQuerySelectorWalker();const[[...e],o]=this._collectNodes(a),r=e.length;let l=new Set;for(let f=0;f<r;f++){const{branch:c,collected:u,dir:h,find:i}=e[f],t=c.length;if(t&&i){const s=o[f],d=s.length,m=t-1;if(m===0)if((a===L||a===y)&&this.#e.nodeType===n.ELEMENT_NODE)for(let b=0;b<d;b++){const p=s[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,...s]),this.#u=!0}else l=new Set(s);else{const[b]=s;l.add(b)}else if(a===L)if(h===x){let{combo:b}=c[0];for(const p of s){let _=new Set([p]);for(let w=1;w<t;w++){const{combo:N,leaves:A}=c[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 s){let p=new Set([b]);for(let _=m-1;_>=0;_--){const w=c[_];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===y&&h===x){const{combo:b}=c[0];let p;for(const _ of s)if(p=this._matchNodeNext(c,new Set([_]),{combo:b,index:1}),p){l.add(p);break}if(!p&&!u){const{leaves:_}=c[0],[w]=s;let N=this._findNode(_,{node:w});for(;N;){if(p=this._matchNodeNext(c,new Set([N]),{combo:b,index:1}),p){l.add(p);break}N=this._findNode(_,{node:N})}}}else{let b;for(const p of s)if(b=this._matchNodePrev(c,p,{index:m-1}),b){l.add(p);break}if(!b&&!u&&a===y){const{leaves:p}=c[m],[_]=s;let w=this._findNode(p,{node:_});for(;w;){if(b=this._matchNodePrev(c,w,{index:m-1}),b){l.add(w);break}w=this._findNode(p,{node:w})}}}}}return l}matches(a,e,o){let r;try{if(e?.nodeType!==n.ELEMENT_NODE){const c=`Unexpected node ${e?.nodeName}`;throw new TypeError(c)}const l=e.ownerDocument;if(l===this.#c&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:n.REG_COMPLEX_A.test(a),descendant:!0}))return this.#f.match(a,e);this._setup(a,e,o),r=this._find(R).size}catch(l){this._onError(l)}return!!r}closest(a,e,o){let r;try{if(e?.nodeType!==n.ELEMENT_NODE){const c=`Unexpected node ${e?.nodeName}`;throw new TypeError(c)}const l=e.ownerDocument;if(l===this.#c&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:n.REG_COMPLEX_A.test(a),descendant:!0}))return this.#f.closest(a,e);this._setup(a,e,o);const f=this._find(C);if(f.size){let c=this.#e;for(;c;){if(f.has(c)){r=c;break}c=c.parentNode}}}catch(l){this._onError(l)}return r??null}querySelector(a,e,o){let r;try{(0,E.verifyNode)(e);let l;if(e.nodeType===n.DOCUMENT_NODE?l=e:l=e.ownerDocument,l===this.#c&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:n.REG_COMPLEX_B.test(a),descendant:!1}))return this.#f.first(a,e);this._setup(a,e,o);const f=this._find(y);f.delete(this.#e),f.size&&([r]=(0,E.sortNodes)(f))}catch(l){this._onError(l)}return r??null}querySelectorAll(a,e,o){let r;try{(0,E.verifyNode)(e);let l;if(e.nodeType===n.DOCUMENT_NODE?l=e:l=e.ownerDocument,l===this.#c&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:n.REG_COMPLEX_B.test(a),descendant:!0}))return this.#f.select(a,e);this._setup(a,e,o);const f=this._find(L);f.delete(this.#e),f.size&&(this.#u?r=(0,E.sortNodes)(f):r=[...f])}catch(l){this._onError(l)}return r??[]}}0&&(module.exports={Finder}); | ||
var H=Object.create;var P=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var V=(g,a)=>{for(var e in a)P(g,e,{get:a[e],enumerable:!0})},I=(g,a,e,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of j(a))!q.call(g,r)&&r!==e&&P(g,r,{get:()=>a[r],enumerable:!(o=B(a,r))||o.enumerable});return g};var U=(g,a,e)=>(e=g!=null?H(Y(g)):{},I(a||!g||!g.__esModule?P(e,"default",{value:g,enumerable:!0}):e,g)),X=g=>I(P({},"__esModule",{value:!0}),g);var Q={};V(Q,{Finder:()=>K});module.exports=X(Q);var M=U(require("is-potential-custom-element-name"),1),G=U(require("@asamuzakjp/nwsapi"),1),E=require("./dom-util.js"),O=require("./matcher.js"),k=require("./parser.js"),n=require("./constant.js");const x="next",S="prev",L="all",y="first",C="lineal",R="self";class K{#l;#r;#s;#p;#c;#b;#e;#h;#w;#o;#f;#_;#t;#d;#u;#n;#m;#i;#a;constructor(a,e){this.#a=a,this.#c=e??a.document,this.#r=new WeakMap,this.#_=new WeakMap,this._initNwsapi()}_onError(a){if(!this.#w)if(a instanceof DOMException||a instanceof this.#a.DOMException)if(a.name===n.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,o={}){const{event:r,invalidate:l,noexcept:f,warn:c}=o;return l&&e.nodeType===n.ELEMENT_NODE&&(this.#r=new WeakMap),this.#w=!!f,this.#i=!!c,this.#b=this._setEvent(r),this.#e=e,[this.#s,this.#t,this.#n]=(0,E.resolveContent)(e),this.#d=(0,E.isInShadowTree)(e),[this.#l,this.#h]=this._correspond(a),this.#m=new WeakMap,e}_initNwsapi(){return this.#o=(0,G.default)({DOMException:this.#a.DOMException,document:this.#c}),this.#o.configure({LOGERRORS:!1}),this.#o}_setEvent(a){return a instanceof this.#a.MouseEvent||a instanceof this.#a.KeyboardEvent?a:null}_correspond(a){const e=[];this.#p=!1;let o;if(this.#s){const r=this.#r.get(this.#s);if(r&&r.has(`${a}`)){const l=r.get(`${a}`);this.#p=l.descendant,o=l.ast}}if(o){const r=o.length;for(let l=0;l<r;l++)o[l].collected=!1,o[l].dir=null,o[l].filtered=!1,o[l].find=!1,e[l]=[]}else{let r;try{r=(0,k.parseSelector)(a)}catch(d){this._onError(d)}const{branches:l,info:{hasPseudo:f}}=(0,k.walkAST)(r);let c=!1,u=0;o=[];for(const[...d]of l){const i=[];let t=d.shift();if(t&&t.type!==n.COMBINATOR){const s=new Set;for(;t;){if(t.type===n.COMBINATOR){const[h]=d;if(h.type===n.COMBINATOR){const b=`Invalid selector ${a}`;throw new DOMException(b,n.SYNTAX_ERR)}const m=t.name;/^[\s>]$/.test(m)&&(c=!0),i.push({combo:t,leaves:(0,k.sortAST)(s)}),s.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)),s.add(t)}if(d.length)t=d.shift();else{i.push({combo:null,leaves:(0,k.sortAST)(s)}),s.clear();break}}}o.push({branch:i,collected:!1,dir:null,filtered:!1,find:!1}),e[u]=[],u++}if(this.#s&&!f){let d;this.#r.has(this.#s)?d=this.#r.get(this.#s):d=new Map,d.set(`${a}`,{ast:o,descendant:c}),this.#r.set(this.#s,d)}this.#p=c}return[o,e]}_createTreeWalker(a){let e;return this.#m.has(a)?e=this.#m.get(a):(e=this.#c.createTreeWalker(a,n.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.#n){let o=e.currentNode,r;if(o===a)r=o;else if(o.contains(a))for(o=e.nextNode();o;){if(o===a){r=o;break}o=e.nextNode()}else{if(o!==e.root)for(;o&&!(o===e.root||o===a);)o=e.parentNode();if(a?.nodeType===n.ELEMENT_NODE)for(;o;){if(o===a){r=o;break}o=e.nextNode()}else r=o}return r??null}_collectNthChild(a,e,o){const{a:r,b:l,reverse:f,selector:c}=a,{parentNode:u}=e,d=new Set;let i;if(c)if(this.#r.has(c))i=this.#r.get(c);else{const{branches:t}=(0,k.walkAST)(c);i=t,this.#r.set(c,i)}if(u){const t=this.#n;let s=this._traverse(u,t);s=t.firstChild();let h=0;for(;s;)h++,s=t.nextSibling();s=this._traverse(u,t);const m=new Set;if(i)for(s=t.firstChild();s;){let b;for(const p of i)if(b=this._matchLeaves(p,s,o),!b)break;b&&m.add(s),s=t.nextSibling()}if(r===0){if(l>0&&l<=h){if(m.size){s=this._traverse(u,t),f?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(m.has(s)){if(b===l-1){d.add(s);break}b++}f?s=t.previousSibling():s=t.nextSibling()}}else if(!c){s=this._traverse(u,t),f?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(b===l-1){d.add(s);break}f?s=t.previousSibling():s=t.nextSibling(),b++}}}}else{let b=l-1;if(r>0)for(;b<0;)b+=r;if(b>=0&&b<h){s=this._traverse(u,t),f?s=t.lastChild():s=t.firstChild();let p=0,_=r>0?0:l-1;for(;s&&(s&&b>=0&&b<h);)m.size?m.has(s)&&(_===b&&(d.add(s),b+=r),r>0?_++:_--):p===b&&(c||d.add(s),b+=r),f?s=t.previousSibling():s=t.nextSibling(),p++}}if(f&&d.size>1){const b=[...d];return new Set(b.reverse())}}else if(e===this.#t&&r+l===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,o),t)break;t&&d.add(e)}else d.add(e);return d}_collectNthOfType(a,e){const{a:o,b:r,reverse:l}=a,{localName:f,parentNode:c,prefix:u}=e,d=new Set;if(c){const i=this.#n;let t=this._traverse(c,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(o===0){if(r>0&&r<=s){t=this._traverse(c,i),l?t=i.lastChild():t=i.firstChild();let h=0;for(;t;){const{localName:m,prefix:b}=t;if(m===f&&b===u){if(h===r-1){d.add(t);break}h++}l?t=i.previousSibling():t=i.nextSibling()}}}else{let h=r-1;if(o>0)for(;h<0;)h+=o;if(h>=0&&h<s){t=this._traverse(c,i),l?t=i.lastChild():t=i.firstChild();let m=o>0?0:r-1;for(;t;){const{localName:b,prefix:p}=t;if(b===f&&p===u){if(m===h&&(d.add(t),h+=o),h<0||h>=s)break;o>0?m++:m--}l?t=i.previousSibling():t=i.nextSibling()}}}if(l&&d.size>1){const h=[...d];return new Set(h.reverse())}}else e===this.#t&&o+r===1&&d.add(e);return d}_matchAnPlusB(a,e,o,r){const{nth:{a:l,b:f,name:c},selector:u}=a,d=new Map;if(c?(c==="even"?(d.set("a",2),d.set("b",0)):c==="odd"&&(d.set("a",2),d.set("b",1)),o.indexOf("last")>-1&&d.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?d.set("a",l*1):d.set("a",0),typeof f=="string"&&/-?\d+/.test(f)?d.set("b",f*1):d.set("b",0),o.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(o)){u&&d.set("selector",u);const i=Object.fromEntries(d);return this._collectNthChild(i,e,r)}else if(/^nth-(?:last-)?of-type$/.test(o)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(a,e,o={}){let r;if(Array.isArray(a)&&a.length){const[l]=a,{type:f}=l;let c;f===n.COMBINATOR?c=a.shift():c={name:" ",type:n.COMBINATOR};const u=[];for(;a.length;){const[t]=a,{type:s}=t;if(s===n.COMBINATOR)break;u.push(a.shift())}const d={combo:c,leaves:u};o.dir=x;const i=this._matchCombinator(d,e,o);if(i.size)if(a.length){for(const t of i)if(r=this._matchHasPseudoFunc(Object.assign([],a),t,o),r)break}else r=!0}return!!r}_matchLogicalPseudoFunc(a,e,o={}){const{astName:r="",branches:l=[],selector:f="",twigBranches:c=[]}=a;let u;if(r==="has")if(f.includes(":has("))u=null;else{let d;for(const i of l)if(d=this._matchHasPseudoFunc(Object.assign([],i),e,o),d)break;d&&(u=e)}else{const d=/^(?:is|where)$/.test(r);o.forgive=d;const i=c.length;let t;for(let s=0;s<i;s++){const h=c[s],m=h.length-1,{leaves:b}=h[m];if(t=this._matchLeaves(b,e,o),t&&m>0){let p=new Set([e]);for(let _=m-1;_>=0;_--){const w=h[_],N=[];o.dir=S;for(const A of p){const v=this._matchCombinator(w,A,o);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,o={}){const{children:r,name:l}=a,{localName:f,parentNode:c}=e,{forgive:u,warn:d=this.#i}=o,i=new Set;if(n.REG_LOGICAL_PSEUDO.test(l)){let t;if(this.#r.has(a))t=this.#r.get(a);else{const{branches:h}=(0,k.walkAST)(a),m=[],b=[];for(const[...p]of h){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===n.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:h,twigBranches:b,selector:m.join(",")},this.#r.set(a,t)}const s=this._matchLogicalPseudoFunc(t,e,o);s&&i.add(s)}else if(Array.isArray(r))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[t]=r;return this._matchAnPlusB(t,e,l,o)}else switch(l){case"dir":case"lang":{const t=O.matcher.matchSelector(a,e);t&&i.add(t);break}case"current":case"nth-col":case"nth-last-col":{if(d){const t=`Unsupported pseudo-class :${l}()`;throw new DOMException(t,n.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(d){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,n.NOT_SUPPORTED_ERR)}break}default:if(!u){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,n.SYNTAX_ERR)}}else switch(l){case"any-link":case"link":{n.REG_ANCHOR.test(f)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(n.REG_ANCHOR.test(f)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:h}=new URL(this.#s.URL),m=new URL(e.getAttribute("href"),t);m.origin===s&&m.pathname===h&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#b??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:h}=this.#b??{};(h==="mousedown"||h==="pointerdown")&&t&n.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#s.URL);e.id&&t===`#${e.id}`&&this.#s.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#s.URL);if(t){const s=t.replace(/^#/,"");let h=this.#s.getElementById(s);for(;h;){if(h===e){i.add(e);break}h=h.parentNode}}break}case"scope":{this.#e.nodeType===n.ELEMENT_NODE?!this.#d&&e===this.#e&&i.add(e):e===this.#s.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#b??{};if(e===this.#s.activeElement&&e.tabIndex>=0&&(l==="focus"||s==="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:b,visibility:p}=this.#a.getComputedStyle(h);if(m=!(b==="none"||p==="hidden"),!m)break}if(h.parentNode&&h.parentNode.nodeType===n.ELEMENT_NODE)h=h.parentNode;else break}m&&i.add(e)}break}case"focus-within":{let t,s=this.#s.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.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:b,visibility:p}=this.#a.getComputedStyle(h);if(m=!(b==="none"||p==="hidden"),!m)break}if(h.parentNode&&h.parentNode.nodeType===n.ELEMENT_NODE)h=h.parentNode;else break}m&&i.add(e)}break}case"open":{n.REG_INTERACT.test(f)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{n.REG_INTERACT.test(f)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(n.REG_FORM_CTRL.test(f)||(0,M.default)(f))if(e.disabled||e.hasAttribute("disabled"))i.add(e);else{let t=c;for(;t;){if(n.REG_FORM_GROUP.test(t.localName))if(t.localName==="fieldset"){if(t.disabled&&t.hasAttribute("disabled"))break}else break;t=t.parentNode}t&&c.localName!=="legend"&&(t.disabled||t.hasAttribute("disabled"))&&i.add(e)}break}case"enabled":{(n.REG_FORM_CTRL.test(f)||(0,M.default)(f))&&!(e.disabled&&e.hasAttribute("disabled"))&&i.add(e);break}case"read-only":{switch(f){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||n.REG_TYPE_DATE.test(e.type)||n.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,E.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(f){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||n.REG_TYPE_DATE.test(e.type)||n.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,E.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;f==="textarea"?s=e:f==="input"&&(e.hasAttribute("type")?n.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&f==="input"&&e.hasAttribute("type")&&n.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&f==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&f==="input"&&e.type==="checkbox"||f==="progress"&&!e.hasAttribute("value"))i.add(e);else if(f==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;s||(s=this.#s.documentElement);const h=s.getElementsByTagName("input"),m=h.length;let b;for(let p=0;p<m;p++){const _=h[p];if(_.getAttribute("type")==="radio"&&(t?_.getAttribute("name")===t&&(b=!!_.checked):_.hasAttribute("name")||(b=!!_.checked),b))break}b||i.add(e)}break}case"default":{if(f==="button"&&!(e.hasAttribute("type")&&n.REG_TYPE_RESET.test(e.getAttribute("type")))||f==="input"&&e.hasAttribute("type")&&n.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#n;let h=this._traverse(t,s);for(h=s.firstChild();h&&t.contains(h);){const m=h.localName;let b;if(m==="button"?b=!(h.hasAttribute("type")&&n.REG_TYPE_RESET.test(h.getAttribute("type"))):m==="input"&&(b=h.hasAttribute("type")&&n.REG_TYPE_SUBMIT.test(h.getAttribute("type"))),b){h===e&&i.add(e);break}h=s.nextNode()}}}else if(f==="input"&&e.hasAttribute("type")&&n.REG_TYPE_CHECK.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))i.add(e);else if(f==="option"){let t=c,s=!1;for(;t&&t.localName!=="datalist";){if(t.localName==="select"){(t.multiple||t.hasAttribute("multiple"))&&(s=!0);break}t=t.parentNode}if(s)(e.selected||e.hasAttribute("selected"))&&i.add(e);else{const h=new Set,m=this.#n;let b=this._traverse(c,m);for(b=m.firstChild();b;){if(b.selected||b.hasAttribute("selected")){h.add(b);break}b=m.nextSibling()}h.size&&h.has(e)&&i.add(e)}}break}case"valid":{if(n.REG_FORM_VALID.test(f))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(f==="fieldset"){const t=this.#n;let s=this._traverse(e,t);s=t.firstChild();let h;if(!s)h=!0;else for(;s&&e.contains(s)&&!(n.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?h=s.maxLength>=s.value.length:h=!0:h=!1,!h));)s=t.nextNode();h&&i.add(e)}break}case"invalid":{if(n.REG_FORM_VALID.test(f))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(f==="fieldset"){const t=this.#n;let s=this._traverse(e,t);s=t.firstChild();let h;if(!s)h=!0;else for(;s&&e.contains(s)&&!(n.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?h=s.maxLength>=s.value.length:h=!0:h=!1,!h));)s=t.nextNode();h||i.add(e)}break}case"in-range":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&n.REG_TYPE_RANGE.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&i.add(e);break}case"out-of-range":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&n.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||n.REG_TYPE_CHECK.test(s)||n.REG_TYPE_DATE.test(s)||n.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||n.REG_TYPE_CHECK.test(s)||n.REG_TYPE_DATE.test(s)||n.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#s.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#c.createTreeWalker(e,n.SHOW_ALL);let s=t.firstChild(),h;for(;s&&(h=s.nodeType!==n.ELEMENT_NODE&&s.nodeType!==n.TEXT_NODE,!!h);)s=t.nextSibling();h&&i.add(e)}else i.add(e);break}case"first-child":{(c&&e===c.firstElementChild||e===this.#t)&&i.add(e);break}case"last-child":{(c&&e===c.lastElementChild||e===this.#t)&&i.add(e);break}case"only-child":{(c&&e===c.firstElementChild&&e===c.lastElementChild||e===this.#t)&&i.add(e);break}case"first-of-type":{if(c){const[t]=this._collectNthOfType({a:0,b:1},e);t&&i.add(t)}else e===this.#t&&i.add(e);break}case"last-of-type":{if(c){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&i.add(t)}else e===this.#t&&i.add(e);break}case"only-of-type":{if(c){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s===e&&i.add(e)}}else e===this.#t&&i.add(e);break}case"defined":{const t=e.getAttribute("is");t?(0,M.default)(t)&&this.#a.customElements.get(t)&&i.add(e):(0,M.default)(f)?this.#a.customElements.get(f)&&i.add(e):(e instanceof this.#a.HTMLElement||e instanceof this.#a.SVGElement)&&i.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#a.getComputedStyle(e);t!=="none"&&i.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d){const t=`Unsupported pseudo-element ::${l}`;throw new DOMException(t,n.NOT_SUPPORTED_ERR)}break}case"autofill":case"blank":case"buffering":case"current":case"fullscreen":case"future":case"modal":case"muted":case"past":case"paused":case"picture-in-picture":case"playing":case"seeking":case"stalled":case"user-invalid":case"user-valid":case"volume-locked":case"-webkit-autofill":{if(d){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,n.NOT_SUPPORTED_ERR)}break}default:if(l.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,n.NOT_SUPPORTED_ERR)}}else if(!u){const t=`Unknown pseudo-class :${l}`;throw new DOMException(t,n.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(a,e){const{children:o,name:r}=a;let l;if(Array.isArray(o)){const{branches:f}=(0,k.walkAST)(o[0]),[c]=f,[...u]=c,{host:d}=e;if(r==="host"){let i;for(const t of u){const{type:s}=t;if(s===n.COMBINATOR){const m=`Invalid selector ${(0,k.generateCSS)(a)}`;throw new DOMException(m,n.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}i&&(l=e)}else if(r==="host-context"){let i=d,t;for(;i;){for(const s of u){const{type:h}=s;if(h===n.COMBINATOR){const b=`Invalid selector ${(0,k.generateCSS)(a)}`;throw new DOMException(b,n.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}t&&(l=e)}}else if(r==="host")l=e;else{const f=`Invalid selector :${r}`;throw new DOMException(f,n.SYNTAX_ERR)}return l??null}_matchSelector(a,e,o){const{type:r}=a,l=new Set;if(a.name===n.EMPTY)return l;const f=(0,k.unescapeSelector)(a.name);if(typeof f=="string"&&f!==a.name&&(a.name=f),e.nodeType===n.ELEMENT_NODE)switch(r){case n.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(f,o);break}case n.SELECTOR_ID:{e.id===f&&l.add(e);break}case n.SELECTOR_CLASS:{e.classList.contains(f)&&l.add(e);break}case n.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(a,e,o);default:{const c=O.matcher.matchSelector(a,e,o);c&&l.add(c)}}else if(this.#d&&r===n.SELECTOR_PSEUDO_CLASS&&e.nodeType===n.DOCUMENT_FRAGMENT_NODE){if(f!=="has"&&n.REG_LOGICAL_PSEUDO.test(f))return this._matchPseudoClassSelector(a,e,o);if(n.REG_SHADOW_HOST.test(f)){const c=this._matchShadowHostPseudoClass(a,e,o);c&&l.add(c)}}return l}_matchLeaves(a,e,o){const{attributes:r,localName:l,nodeType:f}=e;let c=this.#_.get(a),u;if(c&&c.has(e)){const{attr:d,matched:i}=c.get(e);r?.length===d&&(u=i)}if(typeof u!="boolean"){let d;f===n.ELEMENT_NODE&&n.REG_FORM.test(l)?d=!1:d=!0;for(const i of a){const{name:t,type:s}=i;if(s===n.SELECTOR_PSEUDO_CLASS&&t==="dir"&&(d=!1),u=this._matchSelector(i,e,o).has(e),!u)break}d&&(c||(c=new WeakMap),c.set(e,{attr:r?.length,matched:u}),this.#_.set(a,c))}return!!u}_matchHTMLCollection(a,e={}){const{compound:o,filterLeaves:r}=e,l=new Set,f=a.length;if(f)if(o)for(let c=0;c<f;c++){const u=a[c];this._matchLeaves(r,u,e)&&l.add(u)}else{const c=[].slice.call(a);return new Set(c)}return l}_findDescendantNodes(a,e,o){const[r,...l]=a,f=l.length>0,{type:c}=r,u=(0,k.unescapeSelector)(r.name);typeof u=="string"&&u!==r.name&&(r.name=u);let d=new Set,i=!1;if(this.#d)i=!0;else switch(c){case n.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,o);break}case n.SELECTOR_ID:{if(this.#t.nodeType===n.ELEMENT_NODE)i=!0;else{const t=this.#t.getElementById(u);t&&t!==e&&e.contains(t)&&(f?this._matchLeaves(l,t,o)&&d.add(t):d.add(t))}break}case n.SELECTOR_CLASS:{const t=e.getElementsByClassName(u);d=this._matchHTMLCollection(t,{compound:f,filterLeaves:l});break}case n.SELECTOR_TYPE:{if(this.#s.contentType==="text/html"&&!/[*|]/.test(u)){const t=e.getElementsByTagName(u);d=this._matchHTMLCollection(t,{compound:f,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(a,e,o={}){const{combo:r,leaves:l}=a,{name:f}=r,{parentNode:c}=e,{dir:u}=o,d=new Set;if(u===x)switch(f){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,o)&&d.add(i);break}case"~":{if(c){const i=this._createTreeWalker(c);let t=this._traverse(e,i);for(t=i.nextSibling();t;)this._matchLeaves(l,t,o)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=this._traverse(e,i);for(t=i.firstChild();t;)this._matchLeaves(l,t,o)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(l,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let h=this._traverse(e,s);for(h=s.nextNode();h&&e.contains(h);)this._matchLeaves(l,h,o)&&d.add(h),h=s.nextNode()}}}else switch(f){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,o)&&d.add(i);break}case"~":{if(c){const i=this._createTreeWalker(c);let t=this._traverse(c,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(l,t,o)&&d.add(t),t=i.nextSibling()}break}case">":{c&&this._matchLeaves(l,c,o)&&d.add(c);break}case" ":default:{const i=[];let t=c;for(;t;)this._matchLeaves(l,t,o)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(a,e){const{node:o}=e;let r=this._traverse(o,this.#f),l;if(r)for(r.nodeType!==n.ELEMENT_NODE?r=this.#f.nextNode():r===o&&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=[],o=this._matchLeaves(a,this.#e,{warn:this.#i});let r=!1;return o&&(e.push(this.#e),r=!0),[e,r]}_findLineal(a,e={}){const{complex:o}=e,r=[];let l=this._matchLeaves(a,this.#e,{warn:this.#i}),f=!1;if(l&&(r.push(this.#e),f=!0),!l||o){let c=this.#e.parentNode;for(;c&&(l=this._matchLeaves(a,c,{warn:this.#i}),l&&(r.push(c),f=!0),c.parentNode);)c=c.parentNode}return[r,f]}_findFirst(a){const e=[],o=this._findNode(a,{node:this.#e});let r=!1;return o&&(e.push(o),r=!0),[e,r]}_findFromHTMLCollection(a,e={}){const{complex:o,compound:r,filterLeaves:l,targetType:f}=e;let c=[],u=!1,d=!1;const i=a.length;if(i)if(this.#e.nodeType===n.ELEMENT_NODE)for(let t=0;t<i;t++){const s=a[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(r){if(this._matchLeaves(l,s,{warn:this.#i})&&(c.push(s),u=!0,f===y))break}else if(c.push(s),u=!0,f===y)break}}else if(o)if(r)for(let t=0;t<i;t++){const s=a[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(c.push(s),u=!0,f===y))break}else c=[].slice.call(a),u=!0,d=!0;else if(r)for(let t=0;t<i;t++){const s=a[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(c.push(s),u=!0,f===y))break}else c=[].slice.call(a),u=!0,d=!0;return[c,u,d]}_findEntryNodes(a,e,o){const{leaves:r}=a,[l,...f]=r,c=f.length>0,{name:u,type:d}=l;let i=[],t=!1,s=!1,h=!1;switch(d){case n.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,{warn:this.#i});break}case n.SELECTOR_ID:{if(e===R)[i,s]=this._matchSelf(r);else if(e===C)[i,s]=this._findLineal(r,{complex:o});else if(e===y&&this.#t.nodeType!==n.ELEMENT_NODE){const m=this.#t.getElementById(u);m&&(c?this._matchLeaves(f,m,{warn:this.#i})&&(i.push(m),s=!0):(i.push(m),s=!0))}else e===y?[i,s]=this._findFirst(r):h=!0;break}case n.SELECTOR_CLASS:{if(e===R)[i,s]=this._matchSelf(r);else if(e===C)[i,s]=this._findLineal(r,{complex:o});else if(this.#t.nodeType===n.DOCUMENT_NODE){const m=this.#t.getElementsByClassName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:o,compound:c,filterLeaves:f,targetType:e}))}else e===y?[i,s]=this._findFirst(r):h=!0;break}case n.SELECTOR_TYPE:{if(e===R)[i,s]=this._matchSelf(r);else if(e===C)[i,s]=this._findLineal(r,{complex:o});else if(this.#s.contentType==="text/html"&&this.#t.nodeType===n.DOCUMENT_NODE&&!/[*|]/.test(u)){const m=this.#t.getElementsByTagName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:o,compound:c,filterLeaves:f,targetType:e}))}else e===y?[i,s]=this._findFirst(r):h=!0;break}default:if(e!==C&&n.REG_SHADOW_HOST.test(u)){if(this.#d&&this.#e.nodeType===n.DOCUMENT_FRAGMENT_NODE){const m=this._matchShadowHostPseudoClass(l,this.#e);m&&(i.push(m),s=!0)}}else e===R?[i,s]=this._matchSelf(r):e===C?[i,s]=this._findLineal(r,{complex:o}):e===y?[i,s]=this._findFirst(r):h=!0}return{collected:t,compound:c,filtered:s,nodes:i,pending:h}}_collectNodes(a){const e=this.#l.values();if(a===L||a===y){const o=new Set;let r=0;for(const{branch:l}of e){const f=l.length,c=f>1,u=l[0];let d,i;if(c){const{combo:p,leaves:[{name:_,type:w}]}=u,N=l[f-1],{leaves:[{name:A,type:v}]}=N;if(v===n.SELECTOR_PSEUDO_ELEMENT||v===n.SELECTOR_ID)d=S,i=N;else if(w===n.SELECTOR_PSEUDO_ELEMENT||w===n.SELECTOR_ID)d=x,i=u;else if(a===L)if(_==="*"&&w===n.SELECTOR_TYPE)d=S,i=N;else if(A==="*"&&v===n.SELECTOR_TYPE)d=x,i=u;else if(f===2){const{name:T}=p;/^[+~]$/.test(T)?(d=S,i=N):(d=x,i=u)}else d=x,i=u;else if(A==="*"&&v===n.SELECTOR_TYPE)d=x,i=u;else if(_==="*"&&w===n.SELECTOR_TYPE)d=S,i=N;else{let T;for(const{combo:D,leaves:[$]}of l){const{name:F,type:z}=$;if(z===n.SELECTOR_PSEUDO_CLASS&&F==="dir"){T=!1;break}if(!T&&D){const{name:W}=D;/^[+~]$/.test(W)&&(T=!0)}}T?(d=x,i=u):(d=S,i=N)}}else d=S,i=u;const{collected:t,compound:s,filtered:h,nodes:m,pending:b}=this._findEntryNodes(i,a,c);m.length?(this.#l[r].find=!0,this.#h[r]=m):b&&o.add(new Map([["index",r],["twig",i]])),this.#l[r].collected=t,this.#l[r].dir=d,this.#l[r].filtered=h||!s,r++}if(o.size){let l,f;this.#e!==this.#t&&this.#e.nodeType===n.ELEMENT_NODE?(l=this.#e,f=this.#f):(l=this.#t,f=this.#n);let c=this._traverse(l,f);for(;c;){let u=!1;if(this.#e.nodeType===n.ELEMENT_NODE?c===this.#e?u=!0:u=this.#e.contains(c):u=!0,u)for(const d of o){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,c,{warn:this.#i})){const s=d.get("index");this.#l[s].filtered=!0,this.#l[s].find=!0,this.#h[s].push(c)}}c!==f.currentNode&&(c=this._traverse(c,f)),c=f.nextNode()}}}else{let o=0;for(const{branch:r}of e){const l=r[r.length-1],f=r.length>1,{compound:c,filtered:u,nodes:d}=this._findEntryNodes(l,a,f);d.length&&(this.#l[o].find=!0,this.#h[o]=d),this.#l[o].dir=S,this.#l[o].filtered=u||!c,o++}}return[this.#l,this.#h]}_getCombinedNodes(a,e,o){const r=[];for(const l of e){const f=this._matchCombinator(a,l,{dir:o,warn:this.#i});f.size&&r.push(...f)}return r.length?new Set(r):new Set}_matchNodeNext(a,e,o){const{combo:r,index:l}=o,{combo:f,leaves:c}=a[l],u={combo:r,leaves:c},d=this._getCombinedNodes(u,e,x);let i;if(d.size)if(l===a.length-1){const[t]=(0,E.sortNodes)(d);i=t}else i=this._matchNodeNext(a,d,{combo:f,index:l+1});return i??null}_matchNodePrev(a,e,o){const{index:r}=o,l=a[r],f=new Set([e]),c=this._getCombinedNodes(l,f,S);let u;if(c.size){if(r===0)u=e;else for(const d of c)if(this._matchNodePrev(a,d,{index:r-1}))return e}return u??null}_find(a){(a===L||a===y)&&this._prepareQuerySelectorWalker();const[[...e],o]=this._collectNodes(a),r=e.length;let l=new Set;for(let f=0;f<r;f++){const{branch:c,collected:u,dir:d,find:i}=e[f],t=c.length;if(t&&i){const s=o[f],h=s.length,m=t-1;if(m===0)if((a===L||a===y)&&this.#e.nodeType===n.ELEMENT_NODE)for(let b=0;b<h;b++){const p=s[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,...s]),this.#u=!0}else l=new Set(s);else{const[b]=s;l.add(b)}else if(a===L)if(d===x){let{combo:b}=c[0];for(const p of s){let _=new Set([p]);for(let w=1;w<t;w++){const{combo:N,leaves:A}=c[w],v={combo:b,leaves:A};if(_=this._getCombinedNodes(v,_,d),_.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 s){let p=new Set([b]);for(let _=m-1;_>=0;_--){const w=c[_];if(p=this._getCombinedNodes(w,p,d),p.size)_===0&&(l.add(b),t>1&&l.size>1&&(this.#u=!0));else break}}else if(a===y&&d===x){const{combo:b}=c[0];let p;for(const _ of s)if(p=this._matchNodeNext(c,new Set([_]),{combo:b,index:1}),p){l.add(p);break}if(!p&&!u){const{leaves:_}=c[0],[w]=s;let N=this._findNode(_,{node:w});for(;N;){if(p=this._matchNodeNext(c,new Set([N]),{combo:b,index:1}),p){l.add(p);break}N=this._findNode(_,{node:N})}}}else{let b;for(const p of s)if(b=this._matchNodePrev(c,p,{index:m-1}),b){l.add(p);break}if(!b&&!u&&a===y){const{leaves:p}=c[m],[_]=s;let w=this._findNode(p,{node:_});for(;w;){if(b=this._matchNodePrev(c,w,{index:m-1}),b){l.add(w);break}w=this._findNode(p,{node:w})}}}}}return l}matches(a,e,o){let r;try{if(e?.nodeType!==n.ELEMENT_NODE){const c=`Unexpected node ${e?.nodeName}`;throw new TypeError(c)}const l=e.ownerDocument;if(l===this.#c&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:n.REG_COMPLEX_A.test(a),descendant:!0}))return this.#o.match(a,e);this._setup(a,e,o),r=this._find(R).size}catch(l){this._onError(l)}return!!r}closest(a,e,o){let r;try{if(e?.nodeType!==n.ELEMENT_NODE){const c=`Unexpected node ${e?.nodeName}`;throw new TypeError(c)}const l=e.ownerDocument;if(l===this.#c&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:n.REG_COMPLEX_A.test(a),descendant:!0}))return this.#o.closest(a,e);this._setup(a,e,o);const f=this._find(C);if(f.size){let c=this.#e;for(;c;){if(f.has(c)){r=c;break}c=c.parentNode}}}catch(l){this._onError(l)}return r??null}querySelector(a,e,o){let r;try{(0,E.verifyNode)(e);let l;if(e.nodeType===n.DOCUMENT_NODE?l=e:l=e.ownerDocument,l===this.#c&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:n.REG_COMPLEX_B.test(a),descendant:!1}))return this.#o.first(a,e);this._setup(a,e,o);const f=this._find(y);f.delete(this.#e),f.size&&([r]=(0,E.sortNodes)(f))}catch(l){this._onError(l)}return r??null}querySelectorAll(a,e,o){let r;try{(0,E.verifyNode)(e);let l;if(e.nodeType===n.DOCUMENT_NODE?l=e:l=e.ownerDocument,l===this.#c&&l.contentType==="text/html"&&(0,k.filterSelector)(a,{complex:n.REG_COMPLEX_B.test(a),descendant:!0}))return this.#o.select(a,e);this._setup(a,e,o);const f=this._find(L);f.delete(this.#e),f.size&&(this.#u?r=(0,E.sortNodes)(f):r=[...f])}catch(l){this._onError(l)}return r??[]}}0&&(module.exports={Finder}); | ||
//# sourceMappingURL=finder.js.map |
@@ -1,3 +0,3 @@ | ||
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}); | ||
var g=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var T=(n,t)=>{for(var s in t)g(n,s,{get:t[s],enumerable:!0})},$=(n,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of S(t))!I.call(n,i)&&i!==s&&g(n,i,{get:()=>t[i],enumerable:!(r=L(t,i))||r.enumerable});return n};var C=n=>$(g({},"__esModule",{value:!0}),n);var R={};T(R,{filterSelector:()=>D,generateCSS:()=>_.generate,parseAstName:()=>m,parseSelector:()=>u,preprocess:()=>O,sortAST:()=>A,unescapeSelector:()=>w,walkAST:()=>y});module.exports=C(R);var d=require("css-tree"),e=require("./constant.js"),_=require("css-tree");const w=(n="")=>{if(typeof n=="string"&&n.indexOf("\\",0)>=0){const t=n.split("\\"),s=t.length;for(let r=1;r<s;r++){let i=t[r];if(i===""&&r===s-1)i=e.U_FFFD;else{const f=e.REG_HEX.exec(i);if(f){const[,o]=f;let a;try{const c=parseInt("D800",e.HEX),E=parseInt("DFFF",e.HEX),l=parseInt(o,e.HEX);l===0||l>=c&&l<=E?a=e.U_FFFD:a=String.fromCodePoint(l)}catch{a=e.U_FFFD}let p="";i.length>o.length&&(p=i.substring(o.length)),i=`${a}${p}`}else/^[\n\r\f]/.test(i)&&(i="\\"+i)}t[r]=i}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 s=0;for(;s>=0&&(s=t.indexOf("#",s),!(s<0));){const r=t.substring(0,s+1);let i=t.substring(s+1);if(/^\d$/.test(i.substring(0,1)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);const f=i.codePointAt(0);if(f===e.BIT_HYPHEN){if(/^\d$/.test(i.substring(1,2)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR)}else if(f>e.BIT_FFFF){const o=`\\${f.toString(e.HEX)} `;i.length===e.DUO?i=o:i=`${o}${i.substring(e.DUO)}`}t=`${r}${i}`,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},u=n=>{if(n=O(n),e.REG_INVALID_SELECTOR.test(n))throw new DOMException(`Invalid selector ${n}`,e.SYNTAX_ERR);let t;try{const s=(0,d.parse)(n,{context:"selectorList",parseCustomProperty:!0});t=(0,d.toPlainObject)(s)}catch(s){const{message:r}=s;if(r==="Identifier is expected"&&e.REG_LANG_QUOTED.test(n)){const[,i,f]=e.REG_LANG_QUOTED.exec(n),o=f.replaceAll("*","\\*").replace(/^"/,"").replace(/"$/,"");let a=i.replace(f,o);a===":lang()"&&(a=`:lang(${e.EMPTY})`),t=u(n.replace(i,a))}else if(/^(?:Identifier|Selector) is expected$/.test(r)&&e.REG_LOGICAL_EMPTY.test(n)){const[,i,f]=e.REG_LOGICAL_EMPTY.exec(n);t=u(n.replace(i,`:${f}(${e.EMPTY})`))}else if(/^(?:"\]"|Attribute selector [()\s,=~^$*|]+) is expected$/.test(r)&&!n.endsWith("]")){const i=n.lastIndexOf("["),f=n.substring(i);f.includes('"')?f.match(/"/g).length%2?t=u(`${n}"]`):t=u(`${n}]`):t=u(`${n}]`)}else if(r==='")" is expected'&&!n.endsWith(")"))t=u(`${n})`);else throw new DOMException(r,e.SYNTAX_ERR)}return t},y=(n={})=>{const t=new Set;let s,r;(0,d.walk)(n,{enter:o=>{o.type===e.SELECTOR?t.add(o.children):o.type===e.SELECTOR_PSEUDO_CLASS?(s=!0,e.REG_LOGICAL_PSEUDO.test(o.name)&&(r=!0)):o.type===e.SELECTOR_PSEUDO_ELEMENT&&(s=!0,e.REG_SHADOW_PSEUDO.test(o.name)&&(r=!0))}}),r&&(0,d.findAll)(n,(o,a,p)=>{if(p){if(o.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(o.name)){const c=p.filter(E=>{const{name:l,type:h}=E;return h===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(l)});for(const{children:E}of c)for(const{children:l}of E)for(const{children:h}of l)t.has(h)&&t.delete(h)}else if(o.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(o.name)){const c=p.filter(E=>{const{name:l,type:h}=E;return h===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(l)});for(const{children:E}of c)for(const{children:l}of E)t.has(l)&&t.delete(l)}}});const f={};return s&&(f.hasPseudo=s),r&&(f.hasPseudoFunc=r),{info:f,branches:[...t]}},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((r,i)=>{const{type:f}=r,{type:o}=i,a=s.get(f),p=s.get(o);let c;return a===p?c=0:a>p?c=1:c=-1,c})}return t},m=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}},D=(n,t={})=>{if(!n||typeof n!="string")return!1;if(n.includes("[")){const s=n.lastIndexOf("[");if(n.substring(s).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 s;if(e.REG_LOGICAL_KEY.test(n)){if(e.REG_LOGICAL_EMPTY.test(n))return!1;const{complex:r,descendant:i}=t;r&&i?s=e.REG_LOGICAL_COMPLEX_A:r?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}); | ||
//# sourceMappingURL=parser.js.map |
@@ -32,5 +32,5 @@ { | ||
"devDependencies": { | ||
"@types/css-tree": "^2.3.7", | ||
"@types/css-tree": "^2.3.8", | ||
"benchmark": "^2.1.4", | ||
"c8": "^10.0.0", | ||
"c8": "^10.1.1", | ||
"chai": "^5.1.1", | ||
@@ -64,3 +64,3 @@ "commander": "^12.1.0", | ||
}, | ||
"version": "4.4.10" | ||
"version": "4.4.11" | ||
} |
@@ -57,7 +57,7 @@ /** | ||
export const ALPHA_NUM = '[A-Z\\d]+'; | ||
export const CHILD_IDX = '(?:first|last|only)-(?:child|of-type)'; | ||
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 PSEUDO_CLASSES = | ||
`(?:any-)?link|${N_ST}|checked|empty|indeterminate|root|target|visited`; | ||
`(?:any-)?link|${CHILD_IDX}|checked|empty|indeterminate|root|target|visited`; | ||
export const ANB = | ||
@@ -64,0 +64,0 @@ `[+-]?(?:${DIGIT}n?|n)|(?:[+-]?${DIGIT})?n\\s*[+-]\\s*${DIGIT}`; |
@@ -188,2 +188,3 @@ /** | ||
const branches = new Set(); | ||
let hasPseudo; | ||
let hasPseudoFunc; | ||
@@ -194,7 +195,12 @@ const opt = { | ||
branches.add(node.children); | ||
} else if ((node.type === SELECTOR_PSEUDO_CLASS && | ||
REG_LOGICAL_PSEUDO.test(node.name)) || | ||
(node.type === SELECTOR_PSEUDO_ELEMENT && | ||
REG_SHADOW_PSEUDO.test(node.name))) { | ||
hasPseudoFunc = true; | ||
} else if (node.type === SELECTOR_PSEUDO_CLASS) { | ||
hasPseudo = true; | ||
if (REG_LOGICAL_PSEUDO.test(node.name)) { | ||
hasPseudoFunc = true; | ||
} | ||
} else if (node.type === SELECTOR_PSEUDO_ELEMENT) { | ||
hasPseudo = true; | ||
if (REG_SHADOW_PSEUDO.test(node.name)) { | ||
hasPseudoFunc = true; | ||
} | ||
} | ||
@@ -246,3 +252,13 @@ } | ||
} | ||
return [...branches]; | ||
const info = {}; | ||
if (hasPseudo) { | ||
info.hasPseudo = hasPseudo; | ||
} | ||
if (hasPseudoFunc) { | ||
info.hasPseudoFunc = hasPseudoFunc; | ||
} | ||
return { | ||
info, | ||
branches: [...branches] | ||
}; | ||
}; | ||
@@ -249,0 +265,0 @@ |
@@ -44,5 +44,5 @@ export const AN_PLUS_B: "AnPlusB"; | ||
export const ALPHA_NUM: "[A-Z\\d]+"; | ||
export const CHILD_IDX: "(?:first|last|only)-(?:child|of-type)"; | ||
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 PSEUDO_CLASSES: "(?:any-)?link|(?:first|last|only)-(?:child|of-type)|checked|empty|indeterminate|root|target|visited"; | ||
@@ -49,0 +49,0 @@ export const ANB: "[+-]?(?:(?:0|[1-9]\\d*)n?|n)|(?:[+-]?(?:0|[1-9]\\d*))?n\\s*[+-]\\s*(?:0|[1-9]\\d*)"; |
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
424888
4715