import e from"../../../../../_virtual/index20.mjs";import{assert as t}from"../../utils/validateTypes.mjs";import s from"../../utils/getRuleSelector.mjs";import o from"../../utils/isStandardSyntaxRule.mjs";import n from"../../utils/parseSelector.mjs";import r from"../../utils/report.mjs";import i from"../../utils/ruleMessages.mjs";import l from"../../utils/validateOptions.mjs";const{isAttribute:a,isClassName:d,isIdentifier:c,isPseudoClass:u,isTag:m,isUniversal:p}=e,f="selector-not-notation",g=i(f,{expected:e=>`Expected ${e} :not() pseudo-class notation`}),x=e=>u(e)||a(e)||d(e)||p(e)||c(e)||m(e),S=e=>u(e)&&void 0!==e.value&&":not"===e.value.toLowerCase(),v=e=>(i,a)=>{l(a,f,{actual:e,possible:["simple","complex"]})&&i.walkRules(i=>{if(!o(i))return;if(!i.selector.includes(":not("))return;const l=n(s(i),a,i);l&&l.walkPseudos(s=>{if(!S(s))return;const o=s.sourceIndex,n=o+s.toString().trim().length;let d;if("complex"===e){const e=s.prev();if(!(e&&S(e)))return;d=()=>function(e,s,o){const n=e=>{for(const s of e)t(s.nodes[0]),s.nodes[0].rawSpaceBefore=" ",s.nodes[0].rawSpaceAfter=""},[r,...i]=e.nodes;let l=e.next();if(null==r||0===r.nodes.length)return;t(r.nodes[0]),r.nodes[0].rawSpaceBefore="",r.nodes[0].rawSpaceAfter="",n(i);for(;S(l);){const t=l.nodes,s=l;n(t),e.nodes=e.nodes.concat(t),l=l.next(),s.remove()}s.selector=o.toString()}(e,i,l)}else{const e=s.nodes;if((e=>{if(e.length>1)return!1;t(e[0],"list is never empty");const[s,o]=e[0].nodes;return!s||!o&&x(s)&&!S(s)})(e))return;const o=e.length>1&&e[1];o&&(!o.nodes.length||e.every(({nodes:e})=>1===e.length))&&(d=()=>function(e,s,o){const n=e.nodes.filter(({nodes:e})=>e[0]&&x(e[0])).map(e=>(t(e.nodes[0]),e.nodes[0].rawSpaceBefore="",e.nodes[0].rawSpaceAfter="",e)),r=n.shift();t(r),t(e.parent),e.empty(),e.nodes.push(r);for(const t of n){const s=h(e),o=s.clone({nodes:[t]});o.rawSpaceBefore="",e.parent.insertAfter(s,o)}s.selector=o.toString()}(s,i,l))}r({message:g.expected,messageArgs:[e],node:i,result:a,ruleName:f,index:o,endIndex:n,fix:{apply:d,node:i}})})})},h=({parent:e,sourceIndex:s})=>{t(e);const o=e.nodes,n=o.findIndex(e=>e.sourceIndex>=s&&!S(e)),r=-1===n?o[o.length-1]:o[n-1];return t(r),r};v.ruleName=f,v.messages=g,v.meta={url:"https://stylelint.io/user-guide/rules/selector-not-notation",fixable:!0};export{v as default};