import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as r,serializeRGB as t,colorDataFitsRGB_Gamut as o,serializeP3 as i}from"@csstools/css-color-parser";import{hasFallback as a,hasSupportsAtRuleAncestor as c}from"@csstools/utilities";import{replaceComponentValues as l,parseCommaSeparatedListOfComponentValues as n,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const f=/\bcolor-mix\(/i,g=/^color-mix$/i,basePlugin=s=>({postcssPlugin:"postcss-color-mix-function",Declaration(v){const x=v.value;if(!f.test(x))return;if(a(v))return;if(c(v,f))return;const b=m({css:x}),P=l(n(b),s=>{if(!u(s)||!g.test(s.getName()))return;const o=e(s);return!o||o.syntaxFlags.has(r.Experimental)||o.syntaxFlags.has(r.ColorMixVariadic)?void 0:t(o)}),d=p(P);if(d===x)return;let F=d;s?.subFeatures.displayP3&&(F=p(l(n(b),s=>{if(!u(s)||!g.test(s.getName()))return;const a=e(s);return a&&!a.syntaxFlags.has(r.Experimental)?o(a)?t(a):i(a):void 0}))),v.cloneBefore({value:d}),s?.subFeatures.displayP3&&F!==d&&v.cloneBefore({value:F}),s?.preserve||v.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-color-mix-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"};
