import{tokenize as e,TokenType as t,stringify as r,isToken as s}from"../../../@csstools/css-tokenizer/dist/index.mjs";import{parseFromTokens as n,isMediaQueryInvalid as o,isMediaFeature as i,isGeneralEnclosed as a}from"../../../@csstools/media-query-list-parser/dist/index.mjs";import{parseCommaSeparatedListOfComponentValues as l,isSimpleBlockNode as u,isTokenNode as f}from"../../../@csstools/css-parser-algorithms/dist/index.mjs";const c=/[<>=]/;function d(d,m){const p=e({css:d});return l(p).flatMap(e=>e.flatMap(e=>{if(!u(e)||e.startToken[0]!==t.OpenParen)return[];const r=e.tokens();return n(r,{preserveInvalidMediaQueries:!0}).filter(e=>!o(e))})).forEach(e=>{e.walk(({node:e})=>{if(i(e)){const r=e.getNameToken();if(r[0]!==t.Ident)return;m(r)}a(e)&&function(e){const r=e.value.value;if(s(r)||0===r.length||s(r[0]))return[];const n=[];let o=!1;return r.forEach(e=>{if(e&&f(e)){if(e.value[0]===t.Delim&&"$"===e.value[4].value)return void(o=!0);if(o)return void(o=!1);n.push(e.value)}}),n}(e).forEach((e,r,s)=>{if(e[0]!==t.Ident)return;const n=s[r+1],o=s[r-1];(!o&&n&&n[0]===t.Colon||n&&n[0]===t.Delim&&c.test(n[4].value)||o&&o[0]===t.Delim&&c.test(o[4].value))&&m(e)})})}),{stringify:()=>r(...p)}}export{d as default};