import h from "../Color.js";
import m from "../generator/mix.js";
/**
 * @license
 *
 * The APCA contrast prediction algorithm is based of the formulas published
 * in the APCA-1.0.98G specification by Myndex. The specification is available at:
 * https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg
 *
 * Note that the APCA implementation is still beta, so please update to
 * future versions of chroma.js when they become available.
 *
 * You can read more about the APCA Readability Criterion at
 * https://readtech.org/ARC/
 */
const _ = 0.027, i = 5e-4, u = 0.1, w = 1.14, r = 0.022, M = 1.414, P = (o, t) => {
  o = new h(o), t = new h(t), o.alpha() < 1 && (o = m(t, o, o.alpha(), "rgb"));
  const n = l(...o.rgb()), a = l(...t.rgb()), s = n >= r ? n : n + Math.pow(r - n, M), c = a >= r ? a : a + Math.pow(r - a, M), e = Math.pow(c, 0.56) - Math.pow(s, 0.57), f = Math.pow(c, 0.65) - Math.pow(s, 0.62), p = Math.abs(c - s) < i ? 0 : s < c ? e * w : f * w;
  return (Math.abs(p) < u ? 0 : p > 0 ? p - _ : p + _) * 100;
};
function l(o, t, n) {
  return 0.2126729 * Math.pow(o / 255, 2.4) + 0.7151522 * Math.pow(t / 255, 2.4) + 0.072175 * Math.pow(n / 255, 2.4);
}
export {
  P as default
};
//# sourceMappingURL=contrastAPCA.js.map
