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,eAAM,CAAU,EAAM,EAAU,GAC9B,GAAI,EAAK,SACP,OAAO,EAAS,KAAM,GAGxB,GAAI,EAAK,WACP,OAAO,EAAS,IAAI,MAAM,GAAG,yCAG/B,IACE,GAAI,EAAK,WAAY,CACnB,IAAI,EAAU,EAAK,SAAS,WAE5B,MAAM,QAAsB,EAAW,GACjC,EAAmB,QAAQ,EAAc,SAG/C,QAAgB,aAAa,EAAS,GAAe,MAAO,EAAO,EAAO,KACxE,MAAM,EAAY,EAAM,MAAM,GAC1B,GAAa,IACf,QAAY,EAAS,EAAU,GAAG,cAAe,EAAK,IAGxD,MAAO,SAAS,YADK,EAAiB,QAAQ,EAAK,EAAc,UACjC,aAAG,IAIrC,QAAgB,aAAa,EAAS,GAAkB,MAAO,EAAO,EAAO,IAEpE,SAAS,WADK,EAAiB,QAAQ,EAAK,EAAc,UAClC,MAAM,MAGvC,EAAK,SAAW,OAAO,KAAK,EAC9B,CAEA,KAAK,KAAK,GACV,GACF,CAAE,MAAO,GACP,EAAS,IAAI,MAAM,GAAG,gBAAgB,EAAM,WAC9C,CACF,GAIJ,CAEA,OAAO,QAAU","file":"/npm/gulp-html-css@1.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/gulp-html-css@1.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const path = require('path')\nconst { Transform } = require('stream')\nconst postcss = require('postcss')\n\nconst PLUGIN_NAME = 'gulp-html-css'\n\n/**\n * Create a CSS compiler function\n * @param {Object} compiler - CSS compiler object\n * @param {Object} options - Compiler options\n * @returns {Function} - CSS compiler function\n */\nfunction cssCompiler(compiler, options) {\n  const compilerMap = {\n    sass: async (input, file) => {\n      if (typeof compiler.compileStringAsync !== 'function') {\n        throw new Error('Invalid Sass compiler')\n      }\n      const opts = {\n        file: file.path,\n        importers: [\n          {\n            findFileUrl(url) {\n              if (!path.isAbsolute(url)) {\n                url = path.resolve(path.dirname(file.path), url)\n              }\n              return new URL(`file://${url}`)\n            },\n          },\n        ],\n        // loadPaths: [path.dirname(file.path)],\n        ...options,\n      }\n      const result = await compiler.compileStringAsync(input, opts)\n      return result.css\n    },\n    less: (input, file) => {\n      if (typeof compiler.render !== 'function') {\n        throw new Error('Invalid Less compiler')\n      }\n      const opts = {\n        filename: file.path,\n        // paths: [path.dirname(file.path)],\n        javascriptEnabled: true,\n        ...options,\n      }\n      return new Promise((resolve, reject) =>\n        compiler.render(input, opts, (err, res) => (err ? reject(err) : resolve(res.css)))\n      )\n    },\n    stylus: (input, file) => {\n      if (typeof compiler.render !== 'function') {\n        throw new Error('Invalid Stylus compiler')\n      }\n      const opts = {\n        filename: file.path,\n        // paths: [path.dirname(file.path)],\n        ...options,\n      }\n      if (file.data) {\n        opts.define = file.data\n      }\n      return new Promise((resolve, reject) =>\n        compiler.render(input, opts, (err, css) => (err ? reject(err) : resolve(css)))\n      )\n    },\n  }\n\n  return async (lang, input, file) => {\n    if (lang === 'scss') lang = 'sass'\n    const renderer = compilerMap[lang]\n    if (!renderer) {\n      throw new Error(`Unsupported language ${lang}`)\n    }\n    return renderer(input, file)\n  }\n}\n\n/**\n * Asynchronous string replace function\n * @param {string} str - Input string\n * @param {RegExp} regex - Regular expression to match\n * @param {Function} asyncFn - Async function to generate replacement\n * @returns {Promise<string>} - Resulting string after async replacements\n */\nasync function asyncReplace(str, regex, asyncFn) {\n  const promises = []\n  str.replace(regex, (match, ...args) => {\n    const promise = asyncFn(match, ...args)\n    promises.push(promise)\n  })\n  const data = await Promise.all(promises)\n  return str.replace(regex, () => data.shift())\n}\n\n/**\n * Create a PostCSS config loader\n * @param {Object} config - PostCSS configuration\n * @param {Array} config.plugins - PostCSS plugins\n * @param {Object} config.options - PostCSS options\n * @param {boolean} merge - Merge with existing PostCSS config\n * @returns {Function} - PostCSS loader function\n */\nfunction createPostCSSLoader(config, merge) {\n  return async (file) => {\n    try {\n      if (!config.plugins?.length || merge) {\n        const postcssrc = require('postcss-load-config')\n        const ctx = config.options || {}\n        let configPath\n        if (ctx.config) {\n          configPath = path.isAbsolute(ctx.config) ? ctx.config : path.join(file.base, ctx.config)\n        } else {\n          configPath = file.dirname\n        }\n        ctx.options = Object.assign({}, ctx)\n        ctx.file = file\n\n        const result = await postcssrc(ctx, configPath)\n        config = {\n          file: result.file || file,\n          plugins: [].concat(result.plugins || [], config.plugins || []),\n          options: Object.assign({}, config.options, result.options),\n        }\n      }\n    } catch (err) {\n      console.error(err)\n    }\n\n    return {\n      ...config,\n      options: {\n        from: file.path,\n        to: file.path,\n        ...config.options,\n      },\n    }\n  }\n}\n\n/**\n * Process HTML file, compile and transform CSS in <style> tags and inline styles using PostCSS.\n * If <style lang=\"\"> attribute exists, compile the content using appropriate preprocessor before PostCSS.\n *\n * @param {Array|Object} plugins - PostCSS plugins\n * @param {Object} options - Configuration options\n * @param {Object} options.postcss - PostCSS options\n * @param {Object} options.compiler - CSS preprocessor compiler\n * @param {Object} options.compilerOptions - Preprocessor options\n * @param {boolean} ext - Extended configuration, .e.g: merge: Merge with existing PostCSS config\n * @returns {Transform} - Transform stream object\n */\nfunction gulpHtmlCss(plugins = [], options = {}, ext) {\n  if (plugins && !Array.isArray(plugins)) {\n    options = plugins\n    plugins = options.plugins || []\n  }\n  if (typeof options === 'boolean') ext = options\n\n  let renderer = null\n  let postcssOptions = options\n  if (options.compiler) {\n    renderer = cssCompiler(options.compiler, options.compilerOptions)\n    postcssOptions = options.postcss || {}\n  }\n\n  const loadConfig = createPostCSSLoader(\n    { plugins, options: postcssOptions },\n    typeof ext === 'boolean' ? ext : ext?.merge\n  )\n\n  const styleTagRegex = /<style\\b([^>]*)>([\\s\\S]*?)<\\/style>/gi\n  const langAttrRegex = /\\blang=(['\"])(.*?)\\1/i\n  const inlineStyleRegex = /\\bstyle=([\"'])((?:(?!\\1).)*)\\1/gi\n\n  const transformStream = new Transform({\n    objectMode: true,\n    async transform(file, encoding, callback) {\n      if (file.isNull()) {\n        return callback(null, file)\n      }\n\n      if (file.isStream()) {\n        return callback(new Error(`${PLUGIN_NAME}: Streaming not supported`))\n      }\n\n      try {\n        if (file.isBuffer()) {\n          let content = file.contents.toString()\n\n          const postcssConfig = await loadConfig(file)\n          const postcssProcessor = postcss(postcssConfig.plugins)\n\n          // Process <style> tags\n          content = await asyncReplace(content, styleTagRegex, async (match, attrs, css) => {\n            const langMatch = attrs.match(langAttrRegex)\n            if (langMatch && renderer) {\n              css = await renderer(langMatch[2].toLowerCase(), css, file)\n            }\n            const result = await postcssProcessor.process(css, postcssConfig.options)\n            return `<style${attrs}>${result.css}</style>`\n          })\n\n          // Process inline styles\n          content = await asyncReplace(content, inlineStyleRegex, async (match, quote, css) => {\n            const result = await postcssProcessor.process(css, postcssConfig.options)\n            return `style=${quote}${result.css}${quote}`\n          })\n\n          file.contents = Buffer.from(content)\n        }\n\n        this.push(file)\n        callback()\n      } catch (error) {\n        callback(new Error(`${PLUGIN_NAME}: ${error.message}`))\n      }\n    },\n  })\n\n  return transformStream\n}\n\nmodule.exports = gulpHtmlCss\n"]}