import e from"../../../../../_virtual/index20.mjs";import s from"../../utils/flattenNestedSelectorsForRule.mjs";import t from"../../utils/getStrippedSelectorSource.mjs";import o from"../../utils/isContextFunctionalPseudoClass.mjs";import r from"../../utils/isNonNegativeInteger.mjs";import l from"../../utils/isStandardSyntaxRule.mjs";import{levelOneAndTwoPseudoElements as i}from"../../reference/selectors.mjs";import m from"../../utils/report.mjs";import a from"../../utils/ruleMessages.mjs";import u from"../../utils/validateOptions.mjs";const{isRoot:p,isSelector:n}=e,c="selector-max-pseudo-class",d=a(c,{expected:(e,s)=>`Expected "${e}" to have no more than ${s} pseudo-${1===s?"class":"classes"}`}),f=e=>(a,f)=>{u(f,c,{actual:e,possible:r})&&a.walkRules(r=>{l(r)&&s(r,f).forEach(({selector:s,resolvedSelectors:l})=>{l.walk(l=>{n(l)&&(p(l.parent)||o(l.parent))&&function(s,o,r){if(s.reduce((e,s)=>("pseudo"===s.type&&(s.value.includes("::")||i.has(s.value.toLowerCase().slice(1)))||"pseudo"===s.type&&(e+=1),e),0)>e){const{index:s,endIndex:l,selector:i}=t(o);m({ruleName:c,result:f,node:r,message:d.expected,messageArgs:[i,e],index:s,endIndex:l})}}(l,s,r)})})})};f.ruleName=c,f.messages=d,f.meta={url:"https://stylelint.io/user-guide/rules/selector-max-pseudo-class"};export{f as default};