import e from"@csstools/postcss-progressive-custom-properties";import{hasFallback as s,hasSupportsAtRuleAncestor as o}from"@csstools/utilities";import{replaceComponentValues as t,parseCommaSeparatedListOfComponentValues as r,isFunctionNode as i,isWhiteSpaceOrCommentNode as n,FunctionNode as a,TokenNode as c,stringify as l}from"@csstools/css-parser-algorithms";import{tokenize as m,TokenType as p}from"@csstools/css-tokenizer";const u=/\bimage\(/i,g=/^image$/i,basePlugin=e=>({postcssPlugin:"postcss-image-function",Declaration(v){const f=v.value;if(!u.test(f))return;if(s(v))return;if(o(v,u))return;const d=t(r(m({css:f})),e=>{if(i(e)&&g.test(e.getName())&&1===e.value.filter(e=>!n(e)).length)return new a([p.Function,"linear-gradient(",e.name[2],e.name[3],{value:"linear-gradient"}],e.endToken,[...e.value,new c([p.Comma,",",e.name[2],e.name[3],void 0]),...e.value])}),P=l(d);P!==f&&(v.cloneBefore({value:P}),e?.preserve||v.remove())}});basePlugin.postcss=!0;const postcssPlugin=s=>{const o=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},s);return o.enableProgressiveCustomProperties&&o.preserve?{postcssPlugin:"postcss-image-function",plugins:[e(),basePlugin(o)]}:basePlugin(o)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"};
