import{parseCommaSeparatedListOfComponentValues as e,isWhiteSpaceOrCommentNode as s,isTokenNode as t,stringify as o,TokenNode as n}from"@csstools/css-parser-algorithms";import{tokenize as r,isTokenIdent as i,TokenType as l}from"@csstools/css-tokenizer";const a=/^font(?:-family)?$/i,c=["system-ui","-apple-system","Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans","sans-serif"];const u=c.join(","),creator=p=>{const f=Object.assign({preserve:!0},p);return{postcssPlugin:"postcss-system-ui-font-family",Declaration(p){if(!p.variable&&!a.test(p.prop))return;if(p.value.includes(u))return;const m=p.value,v=r({css:m}),g=e(v),y=new Map;let h=-1;e:for(let e=0;e<g.length;e++){const o=g[e],n=[];for(let r=0;r<o.length;r++){const l=o[r];if(s(l))continue;if(!t(l))continue e;const a=l.value;if(!i(a))continue e;"system-ui"===a[4].value.toLowerCase()&&(h=e),n.push(a[4].value)}const r=n.join(" ");c.includes(r)&&y.set(r,e)}if(-1===h)return;const d=(b=y,j=!!f.preserve,c.filter(e=>!("system-ui"!==e||!j)||!b.has(e)).map(e=>[new n([l.Ident,e,-1,-1,{value:e}])]));var b,j;if(0===d.length)return;g.splice(h,1,...d);const w=o(g);w!==m&&(p.cloneBefore({prop:p.prop,value:w}),p.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"};
