import{isMediaQueryInvalid as e,isMediaFeaturePlain as t,isMediaFeatureRange as s}from"../../../../@csstools/media-query-list-parser/dist/index.mjs";import{TokenType as r}from"../../../../@csstools/css-tokenizer/dist/index.mjs";import{isTokenNode as i}from"../../../../@csstools/css-parser-algorithms/dist/index.mjs";import{atRuleParamIndex as m}from"../../utils/nodeFieldIndices.mjs";import{atRuleRegexes as o}from"../../utils/regexes.mjs";import{isString as a}from"../../utils/validateTypes.mjs";import n from"../../utils/matchesStringOrRegExp.mjs";import u from"../../utils/parseMediaQuery.mjs";import l from"../../utils/report.mjs";import d from"../../utils/ruleMessages.mjs";import f from"../../utils/validateObjectWithArrayProps.mjs";import p from"../../utils/validateOptions.mjs";const c="media-feature-name-unit-allowed-list",j=d(c,{rejected:(e,t)=>`Unexpected unit "${e}" for name "${t}"`}),g=d=>(g,x)=>{if(!p(x,c,{actual:d,possible:[f(a)]}))return;const N=Object.entries(d);g.walkAtRules(o.mediaName,o=>{u(o).forEach(a=>{if(e(a))return;const u={mediaFeatureName:"",unitList:void 0};a.walk(({node:e,state:a})=>{if(!a)return;if(t(e)||s(e))return a.mediaFeatureName=e.getName(),void(a.unitList=(e=>{for(const[t,s]of N)if(n(e,t))return[s].flat()})(a.mediaFeatureName));if(!i(e))return;const{mediaFeatureName:u,unitList:d}=a;if(!u||!d)return;const[f,,p,g,v]=e.value;if(f!==r.Dimension)return;if(d.includes(v.unit.toLowerCase()))return;const y=m(o);l({message:j.rejected,messageArgs:[v.unit,u],node:o,index:y+p,endIndex:y+g+1,result:x,ruleName:c})},u)})})};g.ruleName=c,g.messages=j,g.meta={url:"https://stylelint.io/user-guide/rules/media-feature-name-unit-allowed-list"};export{g as default};