import{readFile as t}from"node:fs/promises";import"../../postcss/lib/postcss.mjs";import e from"./utils/dynamicImport.mjs";import o from"./utils/getModulePath.mjs";import s from"./utils/normalizeFixMode.mjs";import r from"../../../_virtual/postcss2.mjs";const i=r();async function n(n,{customSyntax:a,filePath:c,code:p}={}){const f=c?n._postcssResultCache.get(c):void 0;if(f)return f;const u=s(n._options.fix),m=await(a?async function(t,s){if("string"==typeof t){const i=s?o(s,t):t;let n;try{n=await e(i),n=n.default??n}catch(e){if(e&&"object"==typeof e&&"code"in e&&("MODULE_NOT_FOUND"===e.code||"ERR_MODULE_NOT_FOUND"===e.code)&&"message"in e&&"string"==typeof e.message&&e.message.includes(t))throw new Error(`Cannot resolve custom syntax module "${t}". Check that module "${t}" is available and spelled correctly.\n\nCaused by: ${e}`);throw e}return n.parse||(n={parse:n,stringify:r.stringify}),n}if("object"==typeof t||"function"==typeof t){if("function"==typeof t.parse)return{...t};throw new TypeError('An object provided to the "customSyntax" option must have a "parse" property. Ensure the "parse" property exists and its value is a function.')}throw new Error("Custom syntax must be a string or a Syntax object")}(a,n._options.configBasedir):async function(t){const e=await(t?import("../../../_virtual/safe-parse.mjs").then(function(t){return t.s}).then(t=>t.default):r.parse);return{parse:e,stringify:r.stringify}}("lax"===u)),l={from:c,syntax:m};let y;if(void 0!==p?y=p:c&&(y=await t(c,"utf8")),void 0===y)throw new Error("code or filePath required");const d=await i.process(y,l).async();return c&&n._postcssResultCache.set(c,d),d}export{n as default};