import e from"../../../../../_virtual/index19.mjs";import{declarationValueIndex as t}from"../../utils/nodeFieldIndices.mjs";import r from"../../utils/getDeclarationValue.mjs";import l from"../../utils/isHexColor.mjs";import o from"../../utils/isUrlFunction.mjs";import s from"../../utils/report.mjs";import i from"../../utils/ruleMessages.mjs";import n from"../../utils/setDeclarationValue.mjs";import u from"../../utils/validateOptions.mjs";const a="color-hex-length",m=i(a,{expected:(e,t)=>`Expected "${e}" to be "${t}"`}),f=/#[\da-z]+/i,g=i=>(g,d)=>{u(d,a,{actual:i,possible:["short","long"]})&&g.walkDecls(u=>{if(!f.test(u.value))return;const g=e(r(u));g.walk(e=>{const{value:r}=e;if(o(e))return!1;if(!l(e))return;if("long"===i&&4!==r.length&&5!==r.length)return;if("short"===i&&(r.length<6||((f=(f=r).toLowerCase())[1]!==f[2]||f[3]!==f[4]||f[5]!==f[6]||7!==f.length&&(9!==f.length||f[7]!==f[8]))))return;var f;const h=("long"===i?c:p)(r),x=t(u)+e.sourceIndex,j=x+e.value.length;s({message:m.expected,messageArgs:[r,h],node:u,index:x,endIndex:j,result:d,ruleName:a,fix:{apply:()=>{e.value=h,n(u,g.toString())},node:u}})})})};function p(e){let t="#";for(let r=1;r<e.length;r+=2)t+=e[r];return t}function c(e){let t="#";for(let r=1;r<e.length;r++)t+=e.charAt(r).repeat(2);return t}g.ruleName=a,g.messages=m,g.meta={url:"https://stylelint.io/user-guide/rules/color-hex-length",fixable:!0};export{g as default};