"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { alphaBlend: () => alphaBlend }); module.exports = __toCommonJS(src_exports); var import_rgb_hex = __toESM(require("rgb-hex"), 1); // src/minmax/index.ts var minmax = (min, value, max) => Math.min(Math.max(min, value), max); // src/to-rgba/index.ts var import_color_rgba = __toESM(require("color-rgba"), 1); var toRGBA = (color) => { const result = (0, import_color_rgba.default)(color); if (result === void 0) { throw new Error("Invalid color string"); } if (result.length !== 4) { throw new Error("Invalid color string"); } return result; }; // src/index.ts var alphaBlend = (background, foreground) => { const [rb, gb, bb, ab] = toRGBA(background); const [rf, gf, bf, af] = toRGBA(foreground); const a = ab * (1 - af) + af; if (a === 0) return `#${(0, import_rgb_hex.default)(0, 0, 0, 0).toLowerCase()}`; const r = minmax(0, (ab * (1 - af) * rb + rf * af) / a, 255); const g = minmax(0, (ab * (1 - af) * gb + gf * af) / a, 255); const b = minmax(0, (ab * (1 - af) * bb + bf * af) / a, 255); return `#${(0, import_rgb_hex.default)(r, g, b, a).toLowerCase()}`; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { alphaBlend });