import e from"../../../../_virtual/index20.mjs";function n(e,n){return e.a===n.a?e.b===n.b?e.c-n.c:e.b-n.b:e.a-n.a}function s(n,a){const o=a?.customSpecificity?.(n);if(o)return o;if(!n)return{a:0,b:0,c:0};let c=0,i=0,r=0;if("universal"==n.type)return{a:0,b:0,c:0};if("id"===n.type)c+=1;else if("tag"===n.type)r+=1;else if("class"===n.type)i+=1;else if("attribute"===n.type)i+=1;else if(function(n){return e.isPseudoElement(n)}(n))switch(n.value.toLowerCase()){case"::slotted":if(r+=1,n.nodes&&n.nodes.length>0){const e=t(n.nodes,a);c+=e.a,i+=e.b,r+=e.c}break;case"::view-transition-group":case"::view-transition-image-pair":case"::view-transition-old":case"::view-transition-new":return n.nodes&&1===n.nodes.length&&"selector"===n.nodes[0].type&&function(e){if(!e)return!1;if(!e.nodes)return!1;const n=e.nodes.filter(e=>"comment"!==e.type);return 0===n.length||1===n.length&&"universal"===n[0].type}(n.nodes[0])?{a:0,b:0,c:0}:{a:0,b:0,c:1};default:r+=1}else if(e.isPseudoClass(n))switch(n.value.toLowerCase()){case":-webkit-any":case":any":default:i+=1;break;case":-moz-any":case":has":case":is":case":matches":case":not":if(n.nodes&&n.nodes.length>0){const e=t(n.nodes,a);c+=e.a,i+=e.b,r+=e.c}break;case":where":break;case":nth-child":case":nth-last-child":if(i+=1,n.nodes&&n.nodes.length>0){const s=n.nodes[0].nodes.findIndex(e=>"tag"===e.type&&"of"===e.value.toLowerCase());if(s>-1){const o=e.selector({nodes:[],value:""});n.nodes[0].nodes.slice(s+1).forEach(e=>{o.append(e.clone())});const l=[o];n.nodes.length>1&&l.push(...n.nodes.slice(1));const d=t(l,a);c+=d.a,i+=d.b,r+=d.c}}break;case":local":case":global":n.nodes&&n.nodes.length>0&&n.nodes.forEach(e=>{const n=s(e,a);c+=n.a,i+=n.b,r+=n.c});break;case":host":case":host-context":if(i+=1,n.nodes&&n.nodes.length>0){const e=t(n.nodes,a);c+=e.a,i+=e.b,r+=e.c}break;case":active-view-transition":case":active-view-transition-type":return{a:0,b:1,c:0}}else e.isContainer(n)&&n.nodes?.length>0&&n.nodes.forEach(e=>{const n=s(e,a);c+=n.a,i+=n.b,r+=n.c});return{a:c,b:i,c:r}}function t(e,t){let a={a:0,b:0,c:0};return e.forEach(e=>{const o=s(e,t);n(o,a)<0||(a=o)}),a}export{n as compare,s as selectorSpecificity,t as specificityOfMostSpecificListItem};