import{parse as e}from"../../../../css-tree/lib/index.mjs";import{aNPlusBNotationPseudoClasses as t,aNPlusBOfSNotationPseudoClasses as s}from"../../reference/selectors.mjs";import{assert as r}from"../../utils/validateTypes.mjs";import o from"../../utils/getRuleSelector.mjs";import l from"../../utils/hasANPlusBNotationPseudoClasses.mjs";import n from"../../utils/isStandardSyntaxRule.mjs";import i from"../../utils/report.mjs";import a from"../../utils/ruleMessages.mjs";import c from"../../utils/validateOptions.mjs";const u="selector-anb-no-unmatchable",m=a(u,{rejected:e=>`Unexpected unmatchable An+B selector "${e}"`});const f=a=>(f,d)=>{c(d,u,{actual:a})&&f.walkRules(a=>{if(!l(a.selector))return;if(!n(a))return;const c=o(a);let f;try{f=e(c,{context:"selectorList",positions:!0})}catch{return}"SelectorList"===f.type&&f.children.forEach(e=>{!function(e){if("Selector"!==e.type)return;e.children.forEach(e=>{if("PseudoClassSelector"!==e.type||!t.has(e.name)&&!s.has(e.name))return;const o=e;null!==o.children&&o.children.forEach(e=>{if("Nth"!==e.type||"AnPlusB"!==e.nth.type)return;r(o.loc);const t=o.loc.start.offset,s=o.loc.end.offset;(function(e){const{a:t,b:s}=e;return!(null!==t&&"0"!==t&&"-0"!==t||null!==s&&"0"!==s&&"-0"!==s)})(e.nth)&&i({message:m.rejected,messageArgs:[c.slice(t,s)],node:a,index:t,endIndex:s,result:d,ruleName:u})})})}(e)})})};f.ruleName=u,f.messages=m,f.meta={url:"https://stylelint.io/user-guide/rules/selector-anb-no-unmatchable"};export{f as default};