import{assertString as e}from"../../utils/validateTypes.mjs";import{keyframeSelectorKeywords as t}from"../../reference/keywords.mjs";import{atRuleRegexes as r}from"../../utils/regexes.mjs";import s from"../../utils/getRuleSelector.mjs";import o from"../../utils/parseSelector.mjs";import n from"../../../../../_virtual/index20.mjs";import i from"../../utils/report.mjs";import u from"../../utils/ruleMessages.mjs";import l from"../../utils/validateOptions.mjs";const a="keyframe-selector-notation",c=u(a,{expected:(e,t)=>`Expected "${e}" to be "${t}"`}),m=new Set(["0%","100%"]),p=new Map([["0%","from"],["100%","to"]]),f=new Map([["from","0%"],["to","100%"]]),d=e=>(u,d)=>{if(!l(d,a,{actual:e,possible:["keyword","percentage","percentage-unless-within-keyword-only-block"]}))return;const g={keyword:{expFunc:e=>t.has(e),fixFunc:e=>x(p,e)},percentage:{expFunc:e=>m.has(e),fixFunc:e=>x(f,e)},"percentage-unless-within-keyword-only-block":{expFunc:(e,r)=>!!r.every(e=>t.has(e))||m.has(e),fixFunc:e=>x(f,e)}},{expFunc:w,fixFunc:y}=g[e];u.walkAtRules(r.keyframesName,r=>{const u="percentage-unless-within-keyword-only-block"===e?function(e){const t=[];return e.walkRules(e=>{t.push(...e.selectors.map(e=>e.toLowerCase()))}),t}(r):[];r.walkRules(e=>{const r=o(s(e),d,e);r&&r.each(s=>{const o=function(e){const r=e.nodes.filter(e=>!n.isComment(e)&&(!n.isCombinator(e)||""!==e.value.trim()));if(1!==r.length)return;if(!r.every(n.isTag))return;const s=r[0];if(!s)return;const o=s.value.toLowerCase();if(!t.has(o)&&!m.has(o))return;return[s,o]}(s);if(!o)return;const[l,p]=o;if(w(p,u))return;const f=y(p);i({message:c.expected,messageArgs:[l.value,f],node:e,result:d,ruleName:a,index:l.sourceIndex,endIndex:l.sourceIndex+p.length,fix:{apply:()=>{l.value=f,e.selector=r.toString()},node:e}})})})})};function x(t,r){const s=t.get(r);return e(s),s}d.ruleName=a,d.messages=c,d.meta={url:"https://stylelint.io/user-guide/rules/keyframe-selector-notation",fixable:!0};export{d as default};