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