import{fontFamilyKeywords as e,prefixedSystemFonts as s}from"../../reference/keywords.mjs";import t from"../../utils/findFontFamily.mjs";import r from"../../utils/isStandardSyntaxValue.mjs";import a from"../../utils/isVariable.mjs";import o from"../../utils/report.mjs";import n from"../../utils/ruleMessages.mjs";import u from"../../utils/validateOptions.mjs";const i="font-family-name-quotes",l=n(i,{expected:e=>`Expected quotes around "${e}"`,rejected:e=>`Unexpected quotes around "${e}"`});const m=(e,s)=>{const t=[];return e.forEach((e,r)=>{const a="quote"in e&&e.quote,o=e.value,n={name:o,rawName:a?`${a}${o}${a}`:o,sourceIndex:e.sourceIndex,hasQuotes:Boolean(a),resetIndexes(e){t.slice(r+1).forEach(s=>s.sourceIndex+=e)},removeQuotes(){if(!1===this.hasQuotes)return;const e=this.sourceIndex,t=e+this.name.length+2;this.hasQuotes=!1,s.value=s.value.slice(0,e)+this.name+s.value.substring(t),this.resetIndexes(-2)},addQuotes(){if(!0===this.hasQuotes)return;const e=this.sourceIndex,t=e+this.name.length;this.hasQuotes=!0;const r=`"${this.name}"`;s.value=s.value.slice(0,e)+r+s.value.substring(t),this.resetIndexes(2)}};t.push(n)}),t},d=n=>(d,c)=>{function f(t,r){const{name:o,rawName:u,hasQuotes:i}=t;if(a(u))return;if(e.has(o.toLowerCase())||(l=o,s.has(l)||"BlinkMacSystemFont"===l))return i?h("rejected",t,r):void 0;var l;const m=function(e){return e.split(/\s+/).some(e=>/^(?:-?\d|--)/.test(e)||!/^[-\w\u{00A0}-\u{10FFFF}]+$/u.test(e))}(o),d=function(e){return!/^[-a-z]+$/i.test(e)}(o);switch(n){case"always-unless-keyword":return i?void 0:h("expected",t,r);case"always-where-recommended":return!d&&i?h("rejected",t,r):d&&!i?h("expected",t,r):void 0;case"always-where-required":if(!m&&i)return h("rejected",t,r);if(m&&!i)return h("expected",t,r)}}function h(e,s,t){const{name:r,rawName:a}=s;o({result:c,ruleName:i,message:l[e],messageArgs:[r],node:t,word:a,fix:{apply:()=>"expected"===e?s.addQuotes():s.removeQuotes(),node:t}})}u(c,i,{actual:n,possible:["always-where-required","always-where-recommended","always-unless-keyword"]})&&d.walkDecls(/^font(-family)?$/i,e=>{if(!r(e.value))return;let s=m(t(e.value),e);if(0!==s.length)for(const t of s)f(t,e)})};d.ruleName=i,d.messages=l,d.meta={url:"https://stylelint.io/user-guide/rules/font-family-name-quotes",fixable:!0};export{d as default};