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,GACrB,SACI,EAAkB,KAE5B,CAMA,KAAA,CAAM,GACJ,MAAM,EAAa,KAAK,YAAY,KAC9B,EAAyB,oBAAoB,0BAA0B,KAAK,QAAQ,UAC1F,EAAS,MAAM,YAAY,IAAI,GAAY,IACzC,EAAY,MAAM,cAAc,WAAW,CACzC,KAAM,EACN,MAAO,EAAS,QAAQ,YAAY,mCACpC,kBAAkB,IACjB,GAAU,KAAK,SAAS,EAAU,EAAa,EAAQ,CACxD,6BAEF,EAAY,MAAM,aAAa,IAAI,GAAY,IAC7C,EAAM,MAAM,MAAM,IAAI,wBAAwB,IAAI,iCAAiC,CAAC,GAClF,QACA,gBACI,EAAmD,EAA6C,EAAW,cAAgB,IAAG,GACpI,GAEN,EAEF,oBAAoB,mBAAqB,mBACzC,oBAAoB,UAAY,UAChC,oBAAoB,kBAAoB,kBACxC,oBAAoB,eAAiB,eACrC,OAAO,QAAU","file":"/npm/html-minimizer-webpack-plugin@5.0.3/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/html-minimizer-webpack-plugin@5.0.3/dist/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","\"use strict\";\n\nconst os = require(\"node:os\");\nconst {\n  validate\n} = require(\"schema-utils\");\nconst {\n  minify: internalMinify\n} = require(\"./minify\");\nconst schema = require(\"./options.json\");\nconst {\n  htmlMinifierTerser,\n  memoize,\n  minifyHtmlNode,\n  swcMinify,\n  swcMinifyFragment,\n  throttleAll\n} = require(\"./utils\");\n\n/** @typedef {import(\"schema-utils/declarations/validate\").Schema} Schema */\n/** @typedef {import(\"webpack\").Compiler} Compiler */\n/** @typedef {import(\"webpack\").Compilation} Compilation */\n/** @typedef {import(\"webpack\").WebpackError} WebpackError */\n/** @typedef {import(\"webpack\").Asset} Asset */\n/** @typedef {import(\"jest-worker\").Worker} JestWorker */\n\n/** @typedef {RegExp | string} Rule */\n/** @typedef {Rule[] | Rule} Rules */\n// eslint-disable-next-line jsdoc/no-restricted-syntax\n/** @typedef {any} EXPECTED_ANY */\n\n/** @typedef {Error & { plugin?: string, text?: string, source?: string } | string} Warning */\n\n/**\n * @typedef {object} WarningObject\n * @property {string} message The warning message\n * @property {string=} plugin The plugin name\n * @property {string=} text The text content\n * @property {number=} line The line number\n * @property {number=} column The column number\n */\n\n/**\n * @typedef {object} ErrorObject\n * @property {string} message The error message\n * @property {number=} line The line number\n * @property {number=} column The column number\n * @property {string=} stack The error stack trace\n */\n\n/**\n * @typedef {object} MinimizedResultObj\n * @property {string} code The minimized code\n * @property {Array<Error | ErrorObject| string>=} errors Array of errors\n * @property {Array<Warning | WarningObject | string>=} warnings Array of warnings\n */\n\n/**\n * @typedef {MinimizedResultObj | string} MinimizedResult\n */\n\n/**\n * @typedef {{ [file: string]: string }} Input\n */\n\n/**\n * @typedef {{ [key: string]: EXPECTED_ANY }} CustomOptions\n */\n\n/**\n * @template T\n * @typedef {T extends infer U ? U : CustomOptions} InferDefaultType\n */\n\n/**\n * @template T\n * @typedef {T extends any[] ? { [P in keyof T]?: InferDefaultType<T[P]> } : InferDefaultType<T>} MinimizerOptions\n */\n\n/**\n * @template T\n * @callback BasicMinimizerImplementation\n * @param {Input} input\n * @param {InferDefaultType<T>} minifyOptions\n * @returns {Promise<MinimizedResult> | MinimizedResult}\n */\n\n/**\n * @typedef {object} MinimizeFunctionHelpers\n * @property {() => boolean | undefined=} supportsWorkerThreads - Function to check if worker threads are supported\n */\n\n/**\n * @template T\n * @typedef {T extends any[] ? { [P in keyof T]: BasicMinimizerImplementation<T[P]> & MinimizeFunctionHelpers; } : BasicMinimizerImplementation<T> & MinimizeFunctionHelpers} MinimizerImplementation\n */\n\n/**\n * @template T\n * @typedef {object} InternalOptions\n * @property {string} name The name of the minimizer\n * @property {string} input The input content\n * @property {{ implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> }} minimizer The minimizer configuration\n */\n\n/**\n * @typedef InternalResult\n * @property {Array<{ code: string }>} outputs Array of output objects\n * @property {Array<Warning | WarningObject | string>} warnings Array of warnings\n * @property {Array<Error | ErrorObject | string>} errors Array of errors\n */\n\n/**\n * @template T\n * @typedef {JestWorker & { transform: (options: string) => Promise<InternalResult>, minify: (options: InternalOptions<T>) => Promise<InternalResult> }} MinimizerWorker\n */\n\n/**\n * @typedef {undefined | boolean | number} Parallel\n */\n\n/**\n * @typedef {object} BasePluginOptions\n * @property {Rule=} test Test rule for files to process\n * @property {Rule=} include Include rule for files to process\n * @property {Rule=} exclude Exclude rule for files to process\n * @property {Parallel=} parallel Parallel processing configuration\n */\n\n/**\n * @template T\n * @typedef {BasePluginOptions & { minimizer: { implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> } }} InternalPluginOptions\n */\n\n/**\n * @template T\n * @typedef {T extends import(\"html-minifier-terser\").Options ? { minify?: MinimizerImplementation<T> | undefined, minimizerOptions?: MinimizerOptions<T> | undefined } : { minify: MinimizerImplementation<T>, minimizerOptions?: MinimizerOptions<T> | undefined }} DefinedDefaultMinimizerAndOptions\n */\n\nconst getSerializeJavascript = memoize(() => require(\"serialize-javascript\"));\n\n/**\n * @template [T=import(\"html-minifier-terser\").Options]\n * @typedef {BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>} PluginOptions\n */\n\n/**\n * @template {PluginOptions<CustomOptions>} [T=PluginOptions<import(\"html-minifier-terser\").Options>]\n */\nclass HtmlMinimizerPlugin {\n  /**\n   * @param {T=} options Plugin options\n   */\n  constructor(options) {\n    validate(/** @type {Schema} */schema, options || {}, {\n      name: \"Html Minimizer Plugin\",\n      baseDataPath: \"options\"\n    });\n    const {\n      minify = htmlMinifierTerser,\n      minimizerOptions = {},\n      parallel = true,\n      test = /\\.html(\\?.*)?$/i,\n      include,\n      exclude\n    } = /** @type {T} */options || {};\n\n    /**\n     * @private\n     * @type {InternalPluginOptions<T>}\n     */\n    this.options = {\n      test,\n      parallel,\n      include,\n      exclude,\n      minimizer: {\n        implementation: (/** @type {MinimizerImplementation<T>} */minify),\n        options: (/** @type {MinimizerOptions<T>} */minimizerOptions)\n      }\n    };\n  }\n\n  /**\n   * @private\n   * @param {EXPECTED_ANY} warning The warning to build\n   * @param {string} file The file path\n   * @returns {Error & { hideStack?: boolean, file?: string }} The built warning\n   */\n  static buildWarning(warning, file) {\n    /**\n     * @type {Error & { hideStack?: true, file?: string }}\n     */\n    const builtWarning = new Error(warning instanceof Error ? warning.message : typeof warning.message !== \"undefined\" ? warning.message : warning.toString());\n    builtWarning.name = \"Warning\";\n    builtWarning.hideStack = true;\n    builtWarning.file = file;\n    return builtWarning;\n  }\n\n  /**\n   * @private\n   * @param {EXPECTED_ANY} error The error to build\n   * @param {string} file The file path\n   * @returns {Error} The built error\n   */\n  static buildError(error, file) {\n    /**\n     * @type {Error & { file?: string }}\n     */\n    let builtError;\n    if (typeof error === \"string\") {\n      builtError = new Error(`${file} from Html Minimizer plugin\\n${error}`);\n      builtError.file = file;\n      return builtError;\n    }\n    if (error.stack) {\n      builtError = new Error(`${file} from Html Minimizer plugin\\n${typeof error.message !== \"undefined\" ? error.message : \"\"}\\n${error.stack}`);\n      builtError.file = file;\n      return builtError;\n    }\n    builtError = new Error(`${file} from Html Minimizer plugin\\n${error.message}`);\n    builtError.file = file;\n    return builtError;\n  }\n\n  /**\n   * @private\n   * @param {Parallel} parallel Parallel configuration\n   * @returns {number} The number of available cores\n   */\n  static getAvailableNumberOfCores(parallel) {\n    // In some cases cpus() returns undefined\n    // https://github.com/nodejs/node/issues/19022\n    /* eslint-disable n/no-unsupported-features/node-builtins */\n    const cpus = typeof os.availableParallelism === \"function\" ? {\n      length: (/** @type {number} */os.availableParallelism())\n    } : os.cpus() || {\n      length: 1\n    };\n    /* eslint-enable n/no-unsupported-features/node-builtins */\n\n    return parallel === true || typeof parallel === \"undefined\" ? cpus.length - 1 : Math.min(parallel || 0, cpus.length - 1);\n  }\n\n  /**\n   * @private\n   * @template T\n   * @param {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers} implementation The minimizer implementation\n   * @returns {boolean} Whether worker threads are supported\n   */\n  static isSupportsWorkerThreads(implementation) {\n    return typeof implementation.supportsWorkerThreads !== \"undefined\" ? implementation.supportsWorkerThreads() !== false : true;\n  }\n\n  /**\n   * @private\n   * @param {Compiler} compiler The webpack compiler\n   * @param {Compilation} compilation The webpack compilation\n   * @param {Record<string, import(\"webpack\").sources.Source>} assets The assets to optimize\n   * @param {{availableNumberOfCores: number}} optimizeOptions Optimization options\n   * @returns {Promise<void>} Promise that resolves when optimization is complete\n   */\n  async optimize(compiler, compilation, assets, optimizeOptions) {\n    const cache = compilation.getCache(\"HtmlMinimizerWebpackPlugin\");\n    let numberOfAssets = 0;\n    const assetsForMinify = await Promise.all(Object.keys(assets).filter(name => {\n      const {\n        info\n      } = /** @type {Asset} */compilation.getAsset(name);\n\n      // Skip double minimize assets from child compilation\n      if (info.minimized) {\n        return false;\n      }\n      if (!compiler.webpack.ModuleFilenameHelpers.matchObject.bind(undefined, this.options)(name)) {\n        return false;\n      }\n      return true;\n    }).map(async name => {\n      const {\n        info,\n        source\n      } = /** @type {Asset} */\n      compilation.getAsset(name);\n      const eTag = cache.getLazyHashedEtag(source);\n      const cacheItem = cache.getItemCache(name, eTag);\n      const output = await cacheItem.getPromise();\n      if (!output) {\n        numberOfAssets += 1;\n      }\n      return {\n        name,\n        info,\n        inputSource: source,\n        output,\n        cacheItem\n      };\n    }));\n    if (assetsForMinify.length === 0) {\n      return;\n    }\n\n    /** @type {undefined | (() => MinimizerWorker<T>)} */\n    let getWorker;\n    /** @type {undefined | MinimizerWorker<T>} */\n    let initializedWorker;\n    /** @type {undefined | number} */\n    let numberOfWorkers;\n    if (optimizeOptions.availableNumberOfCores > 0) {\n      // Do not create unnecessary workers when the number of files is less than the available cores, it saves memory\n      numberOfWorkers = Math.min(numberOfAssets, optimizeOptions.availableNumberOfCores);\n      getWorker = () => {\n        if (initializedWorker) {\n          return initializedWorker;\n        }\n        const {\n          Worker\n        } = require(\"jest-worker\");\n        initializedWorker = /** @type {MinimizerWorker<T>} */\n\n        new Worker(require.resolve(\"./minify\"), {\n          numWorkers: numberOfWorkers,\n          enableWorkerThreads: Array.isArray(this.options.minimizer.implementation) ? this.options.minimizer.implementation.every(item => HtmlMinimizerPlugin.isSupportsWorkerThreads(item)) : HtmlMinimizerPlugin.isSupportsWorkerThreads(this.options.minimizer.implementation)\n        });\n\n        // https://github.com/facebook/jest/issues/8872#issuecomment-524822081\n        const workerStdout = initializedWorker.getStdout();\n        if (workerStdout) {\n          workerStdout.on(\"data\", chunk => process.stdout.write(chunk));\n        }\n        const workerStderr = initializedWorker.getStderr();\n        if (workerStderr) {\n          workerStderr.on(\"data\", chunk => process.stderr.write(chunk));\n        }\n        return initializedWorker;\n      };\n    }\n    const {\n      RawSource\n    } = compiler.webpack.sources;\n    const scheduledTasks = [];\n    for (const asset of assetsForMinify) {\n      scheduledTasks.push(async () => {\n        const {\n          name,\n          inputSource,\n          cacheItem\n        } = asset;\n        let {\n          output\n        } = asset;\n        let input;\n        const sourceFromInputSource = inputSource.source();\n        if (!output) {\n          input = sourceFromInputSource;\n          if (Buffer.isBuffer(input)) {\n            input = input.toString();\n          }\n\n          /**\n           * @type {InternalOptions<T>}\n           */\n          const options = {\n            name,\n            input,\n            minimizer: {\n              implementation: this.options.minimizer.implementation,\n              options: this.options.minimizer.options\n            }\n          };\n          let result;\n          try {\n            result = await (getWorker ? getWorker().transform(getSerializeJavascript()(options)) : internalMinify(options));\n          } catch (error) {\n            compilation.errors.push(/** @type {WebpackError} */\n            HtmlMinimizerPlugin.buildError(error, name));\n            return;\n          }\n          output = {\n            warnings: [],\n            errors: []\n          };\n          output.source = new RawSource(result.outputs[result.outputs.length - 1].code);\n          for (const error of result.errors) {\n            output.errors.push(HtmlMinimizerPlugin.buildError(error, name));\n          }\n          for (const warning of result.warnings) {\n            output.warnings.push(HtmlMinimizerPlugin.buildWarning(warning, name));\n          }\n          await cacheItem.storePromise({\n            source: output.source,\n            errors: output.errors,\n            warnings: output.warnings\n          });\n        }\n        const newInfo = {\n          minimized: true\n        };\n        if (output.warnings && output.warnings.length > 0) {\n          for (const warning of output.warnings) {\n            compilation.warnings.push(/** @type {WebpackError} */\n            HtmlMinimizerPlugin.buildWarning(warning, name));\n          }\n        }\n        if (output.errors && output.errors.length > 0) {\n          for (const error of output.errors) {\n            compilation.errors.push(/** @type {WebpackError} */\n            HtmlMinimizerPlugin.buildError(error, name));\n          }\n        }\n        compilation.updateAsset(name, output.source, newInfo);\n      });\n    }\n    const limit = getWorker && numberOfAssets > 0 ? (/** @type {number} */numberOfWorkers) : scheduledTasks.length;\n    await throttleAll(limit, scheduledTasks);\n    if (initializedWorker) {\n      await initializedWorker.end();\n    }\n  }\n\n  /**\n   * @param {Compiler} compiler The webpack compiler\n   * @returns {void}\n   */\n  apply(compiler) {\n    const pluginName = this.constructor.name;\n    const availableNumberOfCores = HtmlMinimizerPlugin.getAvailableNumberOfCores(this.options.parallel);\n    compiler.hooks.compilation.tap(pluginName, compilation => {\n      compilation.hooks.processAssets.tapPromise({\n        name: pluginName,\n        stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,\n        additionalAssets: true\n      }, assets => this.optimize(compiler, compilation, assets, {\n        availableNumberOfCores\n      }));\n      compilation.hooks.statsPrinter.tap(pluginName, stats => {\n        stats.hooks.print.for(\"asset.info.minimized\").tap(\"html-minimizer-webpack-plugin\", (minimized, {\n          green,\n          formatFlag\n        }) => minimized ? /** @type {(text: string) => string} */green(/** @type {(flag: string) => string} */formatFlag(\"minimized\")) : \"\");\n      });\n    });\n  }\n}\nHtmlMinimizerPlugin.htmlMinifierTerser = htmlMinifierTerser;\nHtmlMinimizerPlugin.swcMinify = swcMinify;\nHtmlMinimizerPlugin.swcMinifyFragment = swcMinifyFragment;\nHtmlMinimizerPlugin.minifyHtmlNode = minifyHtmlNode;\nmodule.exports = HtmlMinimizerPlugin;"]}