import e from"../../../../../_virtual/index19.mjs";import{atRuleRegexes as t,functionRegexes as r}from"../../utils/regexes.mjs";import{isRegExp as s,isString as a}from"../../utils/validateTypes.mjs";import{atRuleParamIndex as o}from"../../utils/nodeFieldIndices.mjs";import l from"../../utils/report.mjs";import m from"../../utils/ruleMessages.mjs";import i from"../../utils/validateOptions.mjs";const n="layer-name-pattern",u=m(n,{expected:(e,t)=>`Expected "${e}" to match pattern "${t}"`}),p=m=>(p,d)=>{if(!i(d,n,{actual:m,possible:[s,a]}))return;const f=a(m)?new RegExp(m):m;function c(e,t,r,s){if("word"!==e)return;if(f.test(t))return;const a=o(s)+r,i=a+t.length;l({message:u.expected,messageArgs:[t,m],node:s,index:a,endIndex:i,ruleName:n,result:d})}p.walkAtRules(t.layerName,t=>{const{params:r}=t;if(!r)return;e(r).walk(e=>{c(e.type,e.value,e.sourceIndex,t)})}),p.walkAtRules(t.importName,t=>{const{params:s}=t;if(!r.layer.test(s))return;e(t.params).walk(e=>{if("function"===e.type&&"layer"===e.value.toLowerCase())for(const r of e.nodes)c(r.type,r.value,r.sourceIndex,t)})})};p.ruleName=n,p.messages=u,p.meta={url:"https://stylelint.io/user-guide/rules/layer-name-pattern"};export{p as default};