"use strict";var e=require("@csstools/media-query-list-parser"),r=require("@csstools/css-parser-algorithms"),n=require("@csstools/css-tokenizer");const o=1e5,t=2147483647;function transformMediaFeatureValue(a){if(Array.isArray(a.value)&&e.matchesRatioExactly(a.value)){const e=[];for(let o=0;oe&&([e,r]=[r,e]);;){if(0==r)return e;if(0==(e%=r))return r;r%=e}}const a=new Set(["aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio"]);function transformMediaQueryList(r,n){const o=e.parse(r,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${r}"`)}}),t=new Set(o.map((e=>e.toString())));return o.flatMap((r=>{if(e.isMediaQueryInvalid(r))return[r.toString()];const o=e.cloneMediaQuery(r);o.walk((r=>{const n=r.node;if(e.isMediaFeaturePlain(n)||e.isMediaFeatureRangeNameValue(n)||e.isMediaFeatureRangeValueName(n)){const e=n.name.getName().toLowerCase();if(!a.has(e))return;transformMediaFeatureValue(n.value)}else if(e.isMediaFeatureRangeValueNameValue(n)){const e=n.name.getName().toLowerCase();if(!a.has(e))return;transformMediaFeatureValue(n.valueOne);transformMediaFeatureValue(n.valueTwo)}else;}));const i=r.toString(),u=o.toString();return u===i||t.has(u)?[i]:n?[i,u]:[u]})).join(",")}const creator=e=>{const r=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-media-queries-aspect-ratio-number-values",AtRule(e,{result:n}){if("media"!==e.name.toLowerCase())return;const o=e.params.toLowerCase();if(!(o.includes("aspect-ratio")||o.includes("min-aspect-ratio")||o.includes("max-aspect-ratio")||o.includes("device-aspect-ratio")||o.includes("min-device-aspect-ratio")||o.includes("max-device-aspect-ratio")))return;let t;try{if(t=transformMediaQueryList(e.params,r.preserve),t===e.params)return}catch(r){return void e.warn(n,`Failed to transform @media params for "${e.params}" with message: "${r instanceof Error?r.message:r}"`)}e.cloneBefore({params:t}),e.remove()}}};creator.postcss=!0,module.exports=creator;