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,CACL,mBACA,cACD,EAEH,eAAe,cAAc,EAAS,GACpC,MAAM,EAAU,KAAK,QAAQ,GAC7B,UACQ,WAAW,SAAS,MAAM,EAAS,CAAE,WAAW,GACxD,CAAE,MAAO,GAEP,OADA,OAAO,MAAM,+BAA+B,iBAAwB,SACvD,QAAQ,OAAO,IAAI,MAAM,4BAA4B,OACpE,CACA,aAAa,IAAI,SAAQ,CAAC,EAAS,KACjC,MAAM,GAAO,EAAI,WAAW,mBAAmB,GAC/C,EAAK,GAAG,SAAU,IAChB,OAAO,MAAM,2BAA2B,iBAA0B,GAClE,EAAO,IAAI,MAAM,uBAAuB,OAAe,IAEzD,EAAQ,OAAO,KAAK,GAAM,GAAG,UAAU,KACrC,GAAQ,EAAK,IACZ,GAAG,SAAU,IACd,OAAO,MAAM,0BAA0B,iBAA0B,GACjE,EAAO,EAAM,GACb,GAEN,CACA,IAAI,0BAA6B,IAC/B,EAAG,OAAQ,CACT,kCACA,+BACA","file":"/npm/cypress-visual-regression-hirsch@4.0.1/dist/plugin.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/cypress-visual-regression-hirsch@4.0.1/dist/plugin.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\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n  for (var name in all)\n    __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n  if (from && typeof from === \"object\" || typeof from === \"function\") {\n    for (let key of __getOwnPropNames(from))\n      if (!__hasOwnProp.call(to, key) && key !== except)\n        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n  }\n  return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n  // If the importer is in node compatibility mode or this is not an ESM\n  // file that has been converted to a CommonJS file using a Babel-\n  // compatible transform (i.e. \"__esModule\" has not been set), then set\n  // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n  isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n  mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/plugin.ts\nvar plugin_exports = {};\n__export(plugin_exports, {\n  compareSnapshots: () => compareSnapshots,\n  configureVisualRegression: () => configureVisualRegression,\n  generateImage: () => generateImage,\n  updateSnapshot: () => updateSnapshot\n});\nmodule.exports = __toCommonJS(plugin_exports);\nvar import_fs2 = require(\"fs\");\nvar path = __toESM(require(\"path\"));\nvar import_pixelmatch = __toESM(require(\"pixelmatch\"));\nvar import_pngjs2 = require(\"pngjs\");\nvar import_sanitize_filename = __toESM(require(\"sanitize-filename\"));\n\n// src/utils/image.ts\nvar import_fs = require(\"fs\");\nvar import_pngjs = require(\"pngjs\");\n\n// src/utils/logger.ts\nvar import_winston = require(\"winston\");\nvar logger = (0, import_winston.createLogger)({\n  silent: process.env.visualRegressionLogger !== \"true\",\n  level: \"info\",\n  format: import_winston.format.combine(import_winston.format.splat(), import_winston.format.json()),\n  transports: [\n    new import_winston.transports.Console({\n      format: import_winston.format.combine(\n        import_winston.format.timestamp({\n          format: \"YY-MM-DD HH:mm:ss\"\n        }),\n        import_winston.format.label({\n          label: \"[LOGGER]\"\n        }),\n        import_winston.format.simple(),\n        import_winston.format.printf(\n          (msg) => import_winston.format.colorize().colorize(msg.level, `${msg.timestamp} - ${msg.label}: ${msg.message}`)\n        )\n      )\n    })\n  ]\n});\n\n// src/utils/image.ts\nvar parseImage = async (imagePath) => {\n  return await new Promise((resolve, reject) => {\n    const stream = (0, import_fs.createReadStream)(imagePath);\n    stream.on(\"error\", (error) => {\n      logger.error('Failed to open \"%s\" with message: \"%s\"', imagePath, error.message);\n      reject(new Error(`File '${imagePath}' does not exist.`));\n    });\n    stream.pipe(new import_pngjs.PNG()).on(\"parsed\", function() {\n      resolve(this);\n    }).on(\"error\", (error) => {\n      logger.error('Failed to parse image \"%s\" with message: \"%s\"', imagePath, error.message);\n      reject(error);\n    });\n  });\n};\nvar adjustCanvas = (image, width, height) => {\n  if (image.width === width && image.height === height) {\n    return image;\n  }\n  const imageAdjustedCanvas = new import_pngjs.PNG({ width, height, inputHasAlpha: true });\n  import_pngjs.PNG.bitblt(image, imageAdjustedCanvas, 0, 0, image.width, image.height, 0, 0);\n  return imageAdjustedCanvas;\n};\n\n// src/plugin.ts\nvar updateSnapshot = async (options) => {\n  const toDir = options.baseDirectory ?? path.join(process.cwd(), \"cypress\", \"snapshots\", \"base\");\n  const destDir = path.join(toDir, options.specName);\n  const destFile = path.join(destDir, `${options.screenshotName}.png`);\n  try {\n    await import_fs2.promises.mkdir(destDir, { recursive: true });\n  } catch (error) {\n    logger.error(`Failed to create directory '${destDir}' with error:`, error);\n    throw new Error(`cannot create directory '${destDir}'.`);\n  }\n  try {\n    await import_fs2.promises.copyFile(options.screenshotAbsolutePath, destFile);\n    logger.debug(`Updated base snapshot '${options.screenshotName}' at ${destFile}`);\n    return { baseGenerated: true };\n  } catch (error) {\n    logger.error(`Failed to copy file '${destDir}' with error:`, error);\n    throw new Error(`Failed to copy file from '${options.screenshotAbsolutePath}' to '${destFile}'.`);\n  }\n};\nvar compareSnapshots = async (options) => {\n  const snapshotBaseDirectory = options.baseDirectory ?? path.join(process.cwd(), \"cypress\", \"snapshots\", \"base\");\n  const snapshotDiffDirectory = options.diffDirectory ?? path.join(process.cwd(), \"cypress\", \"snapshots\", \"diff\");\n  const fileName = (0, import_sanitize_filename.default)(options.screenshotName);\n  const actualImage = options.screenshotAbsolutePath;\n  const expectedImage = path.join(snapshotBaseDirectory, options.specName, `${fileName}.png`);\n  const diffImage = path.join(snapshotDiffDirectory, options.specName, `${fileName}.png`);\n  const [imgExpected, imgActual] = await Promise.all([parseImage(expectedImage), parseImage(actualImage)]);\n  const diffPNG = new import_pngjs2.PNG({\n    width: Math.max(imgActual.width, imgExpected.width),\n    height: Math.max(imgActual.height, imgExpected.height)\n  });\n  const imgActualFullCanvas = adjustCanvas(imgActual, diffPNG.width, diffPNG.height);\n  const imgExpectedFullCanvas = adjustCanvas(imgExpected, diffPNG.width, diffPNG.height);\n  const mismatchedPixels = (0, import_pixelmatch.default)(\n    imgActualFullCanvas.data,\n    imgExpectedFullCanvas.data,\n    diffPNG.data,\n    diffPNG.width,\n    diffPNG.height,\n    { threshold: 0.1 }\n  );\n  const percentage = (mismatchedPixels / diffPNG.width / diffPNG.height) ** 0.5;\n  if (percentage > options.errorThreshold) {\n    logger.error('Error in visual regression found: \"%s\"', percentage.toFixed(2));\n    if (options.generateDiff !== \"never\") {\n      await generateImage(diffPNG, diffImage);\n    }\n    return {\n      error: `The \"${fileName}\" image is different. Threshold limit exceeded!\n       Expected: ${options.errorThreshold}\n       Actual: ${percentage}`,\n      mismatchedPixels,\n      percentage\n    };\n  } else if (options.generateDiff === \"always\") {\n    await generateImage(diffPNG, diffImage);\n  }\n  return {\n    mismatchedPixels,\n    percentage\n  };\n};\nasync function generateImage(diffPNG, imagePath) {\n  const dirName = path.dirname(imagePath);\n  try {\n    await import_fs2.promises.mkdir(dirName, { recursive: true });\n  } catch (error) {\n    logger.error(`Failed to create directory '${dirName}' with error:`, error);\n    return await Promise.reject(new Error(`cannot create directory '${dirName}'.`));\n  }\n  return await new Promise((resolve, reject) => {\n    const file = (0, import_fs2.createWriteStream)(imagePath);\n    file.on(\"error\", (error) => {\n      logger.error(`Failed to write stream '${imagePath}' with error:`, error);\n      reject(new Error(`cannot create file '${imagePath}'.`));\n    });\n    diffPNG.pack().pipe(file).on(\"finish\", () => {\n      resolve(true);\n    }).on(\"error\", (error) => {\n      logger.error(`Failed to parse image '${imagePath}' with error:`, error);\n      reject(error);\n    });\n  });\n}\nvar configureVisualRegression = (on) => {\n  on(\"task\", {\n    compareSnapshots,\n    updateSnapshot\n  });\n};\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n  compareSnapshots,\n  configureVisualRegression,\n  generateImage,\n  updateSnapshot\n});\n"]}