1877 lines
		
	
	
		
			68 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			1877 lines
		
	
	
		
			68 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
| /**
 | |
|  * @license
 | |
|  * Copyright 2021 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| function O(t) {
 | |
|   return t < 0 ? -1 : t === 0 ? 0 : 1;
 | |
| }
 | |
| function K(t, e, r) {
 | |
|   return (1 - r) * t + r * e;
 | |
| }
 | |
| function It(t, e, r) {
 | |
|   return r < t ? t : r > e ? e : r;
 | |
| }
 | |
| function tt(t, e, r) {
 | |
|   return r < t ? t : r > e ? e : r;
 | |
| }
 | |
| function mt(t) {
 | |
|   return t = t % 360, t < 0 && (t = t + 360), t;
 | |
| }
 | |
| function Ot(t, e) {
 | |
|   return mt(e - t) <= 180 ? 1 : -1;
 | |
| }
 | |
| function _t(t, e) {
 | |
|   return 180 - Math.abs(Math.abs(t - e) - 180);
 | |
| }
 | |
| function ot(t, e) {
 | |
|   const r = t[0] * e[0][0] + t[1] * e[0][1] + t[2] * e[0][2], a = t[0] * e[1][0] + t[1] * e[1][1] + t[2] * e[1][2], n = t[0] * e[2][0] + t[1] * e[2][1] + t[2] * e[2][2];
 | |
|   return [r, a, n];
 | |
| }
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2021 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| const wt = [
 | |
|   [0.41233895, 0.35762064, 0.18051042],
 | |
|   [0.2126, 0.7152, 0.0722],
 | |
|   [0.01932141, 0.11916382, 0.95034478]
 | |
| ], Tt = [
 | |
|   [
 | |
|     3.2413774792388685,
 | |
|     -1.5376652402851851,
 | |
|     -0.49885366846268053
 | |
|   ],
 | |
|   [
 | |
|     -0.9691452513005321,
 | |
|     1.8758853451067872,
 | |
|     0.04156585616912061
 | |
|   ],
 | |
|   [
 | |
|     0.05562093689691305,
 | |
|     -0.20395524564742123,
 | |
|     1.0571799111220335
 | |
|   ]
 | |
| ], Ft = [95.047, 100, 108.883];
 | |
| function ct(t, e, r) {
 | |
|   return (255 << 24 | (t & 255) << 16 | (e & 255) << 8 | r & 255) >>> 0;
 | |
| }
 | |
| function ft(t) {
 | |
|   const e = j(t[0]), r = j(t[1]), a = j(t[2]);
 | |
|   return ct(e, r, a);
 | |
| }
 | |
| function gt(t) {
 | |
|   return t >> 16 & 255;
 | |
| }
 | |
| function pt(t) {
 | |
|   return t >> 8 & 255;
 | |
| }
 | |
| function Pt(t) {
 | |
|   return t & 255;
 | |
| }
 | |
| function Ct(t, e, r) {
 | |
|   const a = Tt, n = a[0][0] * t + a[0][1] * e + a[0][2] * r, s = a[1][0] * t + a[1][1] * e + a[1][2] * r, c = a[2][0] * t + a[2][1] * e + a[2][2] * r, i = j(n), l = j(s), f = j(c);
 | |
|   return ct(i, l, f);
 | |
| }
 | |
| function At(t) {
 | |
|   const e = X(gt(t)), r = X(pt(t)), a = X(Pt(t));
 | |
|   return ot([e, r, a], wt);
 | |
| }
 | |
| function Bt(t) {
 | |
|   const e = G(t), r = j(e);
 | |
|   return ct(r, r, r);
 | |
| }
 | |
| function dt(t) {
 | |
|   const e = At(t)[1];
 | |
|   return 116 * bt(e / 100) - 16;
 | |
| }
 | |
| function G(t) {
 | |
|   return 100 * Rt((t + 16) / 116);
 | |
| }
 | |
| function st(t) {
 | |
|   return bt(t / 100) * 116 - 16;
 | |
| }
 | |
| function X(t) {
 | |
|   const e = t / 255;
 | |
|   return e <= 0.040449936 ? e / 12.92 * 100 : Math.pow((e + 0.055) / 1.055, 2.4) * 100;
 | |
| }
 | |
| function j(t) {
 | |
|   const e = t / 100;
 | |
|   let r = 0;
 | |
|   return e <= 31308e-7 ? r = e * 12.92 : r = 1.055 * Math.pow(e, 1 / 2.4) - 0.055, It(0, 255, Math.round(r * 255));
 | |
| }
 | |
| function Lt() {
 | |
|   return Ft;
 | |
| }
 | |
| function bt(t) {
 | |
|   const e = 0.008856451679035631, r = 24389 / 27;
 | |
|   return t > e ? Math.pow(t, 1 / 3) : (r * t + 16) / 116;
 | |
| }
 | |
| function Rt(t) {
 | |
|   const e = 0.008856451679035631, r = 24389 / 27, a = t * t * t;
 | |
|   return a > e ? a : (116 * t - 16) / r;
 | |
| }
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2021 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| class S {
 | |
|   /**
 | |
|    * Create ViewingConditions from a simple, physically relevant, set of
 | |
|    * parameters.
 | |
|    *
 | |
|    * @param whitePoint White point, measured in the XYZ color space.
 | |
|    *     default = D65, or sunny day afternoon
 | |
|    * @param adaptingLuminance The luminance of the adapting field. Informally,
 | |
|    *     how bright it is in the room where the color is viewed. Can be
 | |
|    *     calculated from lux by multiplying lux by 0.0586. default = 11.72,
 | |
|    *     or 200 lux.
 | |
|    * @param backgroundLstar The lightness of the area surrounding the color.
 | |
|    *     measured by L* in L*a*b*. default = 50.0
 | |
|    * @param surround A general description of the lighting surrounding the
 | |
|    *     color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a
 | |
|    *     dimly light room, like watching TV at home at night. 2.0 means there
 | |
|    *     is no difference between the lighting on the color and around it.
 | |
|    *     default = 2.0
 | |
|    * @param discountingIlluminant Whether the eye accounts for the tint of the
 | |
|    *     ambient lighting, such as knowing an apple is still red in green light.
 | |
|    *     default = false, the eye does not perform this process on
 | |
|    *       self-luminous objects like displays.
 | |
|    */
 | |
|   static make(e = Lt(), r = 200 / Math.PI * G(50) / 100, a = 50, n = 2, s = !1) {
 | |
|     const c = e, i = c[0] * 0.401288 + c[1] * 0.650173 + c[2] * -0.051461, l = c[0] * -0.250268 + c[1] * 1.204414 + c[2] * 0.045854, f = c[0] * -2079e-6 + c[1] * 0.048952 + c[2] * 0.953127, h = 0.8 + n / 10, g = h >= 0.9 ? K(0.59, 0.69, (h - 0.9) * 10) : K(0.525, 0.59, (h - 0.8) * 10);
 | |
|     let p = s ? 1 : h * (1 - 1 / 3.6 * Math.exp((-r - 42) / 92));
 | |
|     p = p > 1 ? 1 : p < 0 ? 0 : p;
 | |
|     const y = h, k = [
 | |
|       p * (100 / i) + 1 - p,
 | |
|       p * (100 / l) + 1 - p,
 | |
|       p * (100 / f) + 1 - p
 | |
|     ], P = 1 / (5 * r + 1), D = P * P * P * P, C = 1 - D, w = D * r + 0.1 * C * C * Math.cbrt(5 * r), M = G(a) / e[1], x = 1.48 + Math.sqrt(M), b = 0.725 / Math.pow(M, 0.2), B = b, I = [
 | |
|       Math.pow(w * k[0] * i / 100, 0.42),
 | |
|       Math.pow(w * k[1] * l / 100, 0.42),
 | |
|       Math.pow(w * k[2] * f / 100, 0.42)
 | |
|     ], A = [
 | |
|       400 * I[0] / (I[0] + 27.13),
 | |
|       400 * I[1] / (I[1] + 27.13),
 | |
|       400 * I[2] / (I[2] + 27.13)
 | |
|     ], R = (2 * A[0] + A[1] + 0.05 * A[2]) * b;
 | |
|     return new S(M, R, b, B, g, y, k, w, Math.pow(w, 0.25), x);
 | |
|   }
 | |
|   /**
 | |
|    * Parameters are intermediate values of the CAM16 conversion process. Their
 | |
|    * names are shorthand for technical color science terminology, this class
 | |
|    * would not benefit from documenting them individually. A brief overview
 | |
|    * is available in the CAM16 specification, and a complete overview requires
 | |
|    * a color science textbook, such as Fairchild's Color Appearance Models.
 | |
|    */
 | |
|   constructor(e, r, a, n, s, c, i, l, f, h) {
 | |
|     this.n = e, this.aw = r, this.nbb = a, this.ncb = n, this.c = s, this.nc = c, this.rgbD = i, this.fl = l, this.fLRoot = f, this.z = h;
 | |
|   }
 | |
| }
 | |
| S.DEFAULT = S.make();
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2021 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| class E {
 | |
|   /**
 | |
|    * All of the CAM16 dimensions can be calculated from 3 of the dimensions, in
 | |
|    * the following combinations:
 | |
|    *      -  {j or q} and {c, m, or s} and hue
 | |
|    *      - jstar, astar, bstar
 | |
|    * Prefer using a static method that constructs from 3 of those dimensions.
 | |
|    * This constructor is intended for those methods to use to return all
 | |
|    * possible dimensions.
 | |
|    *
 | |
|    * @param hue
 | |
|    * @param chroma informally, colorfulness / color intensity. like saturation
 | |
|    *     in HSL, except perceptually accurate.
 | |
|    * @param j lightness
 | |
|    * @param q brightness; ratio of lightness to white point's lightness
 | |
|    * @param m colorfulness
 | |
|    * @param s saturation; ratio of chroma to white point's chroma
 | |
|    * @param jstar CAM16-UCS J coordinate
 | |
|    * @param astar CAM16-UCS a coordinate
 | |
|    * @param bstar CAM16-UCS b coordinate
 | |
|    */
 | |
|   constructor(e, r, a, n, s, c, i, l, f) {
 | |
|     this.hue = e, this.chroma = r, this.j = a, this.q = n, this.m = s, this.s = c, this.jstar = i, this.astar = l, this.bstar = f;
 | |
|   }
 | |
|   /**
 | |
|    * CAM16 instances also have coordinates in the CAM16-UCS space, called J*,
 | |
|    * a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
 | |
|    * specification, and is used to measure distances between colors.
 | |
|    */
 | |
|   distance(e) {
 | |
|     const r = this.jstar - e.jstar, a = this.astar - e.astar, n = this.bstar - e.bstar, s = Math.sqrt(r * r + a * a + n * n);
 | |
|     return 1.41 * Math.pow(s, 0.63);
 | |
|   }
 | |
|   /**
 | |
|    * @param argb ARGB representation of a color.
 | |
|    * @return CAM16 color, assuming the color was viewed in default viewing
 | |
|    *     conditions.
 | |
|    */
 | |
|   static fromInt(e) {
 | |
|     return E.fromIntInViewingConditions(e, S.DEFAULT);
 | |
|   }
 | |
|   /**
 | |
|    * @param argb ARGB representation of a color.
 | |
|    * @param viewingConditions Information about the environment where the color
 | |
|    *     was observed.
 | |
|    * @return CAM16 color.
 | |
|    */
 | |
|   static fromIntInViewingConditions(e, r) {
 | |
|     const a = (e & 16711680) >> 16, n = (e & 65280) >> 8, s = e & 255, c = X(a), i = X(n), l = X(s), f = 0.41233895 * c + 0.35762064 * i + 0.18051042 * l, h = 0.2126 * c + 0.7152 * i + 0.0722 * l, g = 0.01932141 * c + 0.11916382 * i + 0.95034478 * l, p = 0.401288 * f + 0.650173 * h - 0.051461 * g, y = -0.250268 * f + 1.204414 * h + 0.045854 * g, k = -2079e-6 * f + 0.048952 * h + 0.953127 * g, P = r.rgbD[0] * p, D = r.rgbD[1] * y, C = r.rgbD[2] * k, w = Math.pow(r.fl * Math.abs(P) / 100, 0.42), M = Math.pow(r.fl * Math.abs(D) / 100, 0.42), x = Math.pow(r.fl * Math.abs(C) / 100, 0.42), b = O(P) * 400 * w / (w + 27.13), B = O(D) * 400 * M / (M + 27.13), I = O(C) * 400 * x / (x + 27.13), A = (11 * b + -12 * B + I) / 11, R = (b + B - 2 * I) / 9, F = (20 * b + 20 * B + 21 * I) / 20, q = (40 * b + 20 * B + I) / 20, z = Math.atan2(R, A) * 180 / Math.PI, N = z < 0 ? z + 360 : z >= 360 ? z - 360 : z, Z = N * Math.PI / 180, Q = q * r.nbb, V = 100 * Math.pow(Q / r.aw, r.c * r.z), H = 4 / r.c * Math.sqrt(V / 100) * (r.aw + 4) * r.fLRoot, et = N < 20.14 ? N + 360 : N, rt = 0.25 * (Math.cos(et * Math.PI / 180 + 2) + 3.8), nt = 5e4 / 13 * rt * r.nc * r.ncb * Math.sqrt(A * A + R * R) / (F + 0.305), v = Math.pow(nt, 0.9) * Math.pow(1.64 - Math.pow(0.29, r.n), 0.73), ut = v * Math.sqrt(V / 100), lt = ut * r.fLRoot, kt = 50 * Math.sqrt(v * r.c / (r.aw + 4)), Mt = (1 + 100 * 7e-3) * V / (1 + 7e-3 * V), ht = 1 / 0.0228 * Math.log(1 + 0.0228 * lt), yt = ht * Math.cos(Z), Dt = ht * Math.sin(Z);
 | |
|     return new E(N, ut, V, H, lt, kt, Mt, yt, Dt);
 | |
|   }
 | |
|   /**
 | |
|    * @param j CAM16 lightness
 | |
|    * @param c CAM16 chroma
 | |
|    * @param h CAM16 hue
 | |
|    */
 | |
|   static fromJch(e, r, a) {
 | |
|     return E.fromJchInViewingConditions(e, r, a, S.DEFAULT);
 | |
|   }
 | |
|   /**
 | |
|    * @param j CAM16 lightness
 | |
|    * @param c CAM16 chroma
 | |
|    * @param h CAM16 hue
 | |
|    * @param viewingConditions Information about the environment where the color
 | |
|    *     was observed.
 | |
|    */
 | |
|   static fromJchInViewingConditions(e, r, a, n) {
 | |
|     const s = 4 / n.c * Math.sqrt(e / 100) * (n.aw + 4) * n.fLRoot, c = r * n.fLRoot, i = r / Math.sqrt(e / 100), l = 50 * Math.sqrt(i * n.c / (n.aw + 4)), f = a * Math.PI / 180, h = (1 + 100 * 7e-3) * e / (1 + 7e-3 * e), g = 1 / 0.0228 * Math.log(1 + 0.0228 * c), p = g * Math.cos(f), y = g * Math.sin(f);
 | |
|     return new E(a, r, e, s, c, l, h, p, y);
 | |
|   }
 | |
|   /**
 | |
|    * @param jstar CAM16-UCS lightness.
 | |
|    * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
 | |
|    *     coordinate on the Y axis.
 | |
|    * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
 | |
|    *     coordinate on the X axis.
 | |
|    */
 | |
|   static fromUcs(e, r, a) {
 | |
|     return E.fromUcsInViewingConditions(e, r, a, S.DEFAULT);
 | |
|   }
 | |
|   /**
 | |
|    * @param jstar CAM16-UCS lightness.
 | |
|    * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
 | |
|    *     coordinate on the Y axis.
 | |
|    * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
 | |
|    *     coordinate on the X axis.
 | |
|    * @param viewingConditions Information about the environment where the color
 | |
|    *     was observed.
 | |
|    */
 | |
|   static fromUcsInViewingConditions(e, r, a, n) {
 | |
|     const s = r, c = a, i = Math.sqrt(s * s + c * c), f = (Math.exp(i * 0.0228) - 1) / 0.0228 / n.fLRoot;
 | |
|     let h = Math.atan2(c, s) * (180 / Math.PI);
 | |
|     h < 0 && (h += 360);
 | |
|     const g = e / (1 - (e - 100) * 7e-3);
 | |
|     return E.fromJchInViewingConditions(g, f, h, n);
 | |
|   }
 | |
|   /**
 | |
|    *  @return ARGB representation of color, assuming the color was viewed in
 | |
|    *     default viewing conditions, which are near-identical to the default
 | |
|    *     viewing conditions for sRGB.
 | |
|    */
 | |
|   toInt() {
 | |
|     return this.viewed(S.DEFAULT);
 | |
|   }
 | |
|   /**
 | |
|    * @param viewingConditions Information about the environment where the color
 | |
|    *     will be viewed.
 | |
|    * @return ARGB representation of color
 | |
|    */
 | |
|   viewed(e) {
 | |
|     const r = this.chroma === 0 || this.j === 0 ? 0 : this.chroma / Math.sqrt(this.j / 100), a = Math.pow(r / Math.pow(1.64 - Math.pow(0.29, e.n), 0.73), 1 / 0.9), n = this.hue * Math.PI / 180, s = 0.25 * (Math.cos(n + 2) + 3.8), c = e.aw * Math.pow(this.j / 100, 1 / e.c / e.z), i = s * (5e4 / 13) * e.nc * e.ncb, l = c / e.nbb, f = Math.sin(n), h = Math.cos(n), g = 23 * (l + 0.305) * a / (23 * i + 11 * a * h + 108 * a * f), p = g * h, y = g * f, k = (460 * l + 451 * p + 288 * y) / 1403, P = (460 * l - 891 * p - 261 * y) / 1403, D = (460 * l - 220 * p - 6300 * y) / 1403, C = Math.max(0, 27.13 * Math.abs(k) / (400 - Math.abs(k))), w = O(k) * (100 / e.fl) * Math.pow(C, 1 / 0.42), M = Math.max(0, 27.13 * Math.abs(P) / (400 - Math.abs(P))), x = O(P) * (100 / e.fl) * Math.pow(M, 1 / 0.42), b = Math.max(0, 27.13 * Math.abs(D) / (400 - Math.abs(D))), B = O(D) * (100 / e.fl) * Math.pow(b, 1 / 0.42), I = w / e.rgbD[0], A = x / e.rgbD[1], R = B / e.rgbD[2], F = 1.86206786 * I - 1.01125463 * A + 0.14918677 * R, q = 0.38752654 * I + 0.62144744 * A - 897398e-8 * R, Y = -0.0158415 * I - 0.03412294 * A + 1.04996444 * R;
 | |
|     return Ct(F, q, Y);
 | |
|   }
 | |
|   /// Given color expressed in XYZ and viewed in [viewingConditions], convert to
 | |
|   /// CAM16.
 | |
|   static fromXyzInViewingConditions(e, r, a, n) {
 | |
|     const s = 0.401288 * e + 0.650173 * r - 0.051461 * a, c = -0.250268 * e + 1.204414 * r + 0.045854 * a, i = -2079e-6 * e + 0.048952 * r + 0.953127 * a, l = n.rgbD[0] * s, f = n.rgbD[1] * c, h = n.rgbD[2] * i, g = Math.pow(n.fl * Math.abs(l) / 100, 0.42), p = Math.pow(n.fl * Math.abs(f) / 100, 0.42), y = Math.pow(n.fl * Math.abs(h) / 100, 0.42), k = O(l) * 400 * g / (g + 27.13), P = O(f) * 400 * p / (p + 27.13), D = O(h) * 400 * y / (y + 27.13), C = (11 * k + -12 * P + D) / 11, w = (k + P - 2 * D) / 9, M = (20 * k + 20 * P + 21 * D) / 20, x = (40 * k + 20 * P + D) / 20, B = Math.atan2(w, C) * 180 / Math.PI, I = B < 0 ? B + 360 : B >= 360 ? B - 360 : B, A = I * Math.PI / 180, R = x * n.nbb, F = 100 * Math.pow(R / n.aw, n.c * n.z), q = 4 / n.c * Math.sqrt(F / 100) * (n.aw + 4) * n.fLRoot, Y = I < 20.14 ? I + 360 : I, z = 1 / 4 * (Math.cos(Y * Math.PI / 180 + 2) + 3.8), Z = 5e4 / 13 * z * n.nc * n.ncb * Math.sqrt(C * C + w * w) / (M + 0.305), Q = Math.pow(Z, 0.9) * Math.pow(1.64 - Math.pow(0.29, n.n), 0.73), V = Q * Math.sqrt(F / 100), H = V * n.fLRoot, et = 50 * Math.sqrt(Q * n.c / (n.aw + 4)), rt = (1 + 100 * 7e-3) * F / (1 + 7e-3 * F), at = Math.log(1 + 0.0228 * H) / 0.0228, nt = at * Math.cos(A), v = at * Math.sin(A);
 | |
|     return new E(I, V, F, q, H, et, rt, nt, v);
 | |
|   }
 | |
|   /// XYZ representation of CAM16 seen in [viewingConditions].
 | |
|   xyzInViewingConditions(e) {
 | |
|     const r = this.chroma === 0 || this.j === 0 ? 0 : this.chroma / Math.sqrt(this.j / 100), a = Math.pow(r / Math.pow(1.64 - Math.pow(0.29, e.n), 0.73), 1 / 0.9), n = this.hue * Math.PI / 180, s = 0.25 * (Math.cos(n + 2) + 3.8), c = e.aw * Math.pow(this.j / 100, 1 / e.c / e.z), i = s * (5e4 / 13) * e.nc * e.ncb, l = c / e.nbb, f = Math.sin(n), h = Math.cos(n), g = 23 * (l + 0.305) * a / (23 * i + 11 * a * h + 108 * a * f), p = g * h, y = g * f, k = (460 * l + 451 * p + 288 * y) / 1403, P = (460 * l - 891 * p - 261 * y) / 1403, D = (460 * l - 220 * p - 6300 * y) / 1403, C = Math.max(0, 27.13 * Math.abs(k) / (400 - Math.abs(k))), w = O(k) * (100 / e.fl) * Math.pow(C, 1 / 0.42), M = Math.max(0, 27.13 * Math.abs(P) / (400 - Math.abs(P))), x = O(P) * (100 / e.fl) * Math.pow(M, 1 / 0.42), b = Math.max(0, 27.13 * Math.abs(D) / (400 - Math.abs(D))), B = O(D) * (100 / e.fl) * Math.pow(b, 1 / 0.42), I = w / e.rgbD[0], A = x / e.rgbD[1], R = B / e.rgbD[2], F = 1.86206786 * I - 1.01125463 * A + 0.14918677 * R, q = 0.38752654 * I + 0.62144744 * A - 897398e-8 * R, Y = -0.0158415 * I - 0.03412294 * A + 1.04996444 * R;
 | |
|     return [F, q, Y];
 | |
|   }
 | |
| }
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2021 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| class d {
 | |
|   /**
 | |
|    * Sanitizes a small enough angle in radians.
 | |
|    *
 | |
|    * @param angle An angle in radians; must not deviate too much
 | |
|    * from 0.
 | |
|    * @return A coterminal angle between 0 and 2pi.
 | |
|    */
 | |
|   static sanitizeRadians(e) {
 | |
|     return (e + Math.PI * 8) % (Math.PI * 2);
 | |
|   }
 | |
|   /**
 | |
|    * Delinearizes an RGB component, returning a floating-point
 | |
|    * number.
 | |
|    *
 | |
|    * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
 | |
|    * linear R/G/B channel
 | |
|    * @return 0.0 <= output <= 255.0, color channel converted to
 | |
|    * regular RGB space
 | |
|    */
 | |
|   static trueDelinearized(e) {
 | |
|     const r = e / 100;
 | |
|     let a = 0;
 | |
|     return r <= 31308e-7 ? a = r * 12.92 : a = 1.055 * Math.pow(r, 1 / 2.4) - 0.055, a * 255;
 | |
|   }
 | |
|   static chromaticAdaptation(e) {
 | |
|     const r = Math.pow(Math.abs(e), 0.42);
 | |
|     return O(e) * 400 * r / (r + 27.13);
 | |
|   }
 | |
|   /**
 | |
|    * Returns the hue of a linear RGB color in CAM16.
 | |
|    *
 | |
|    * @param linrgb The linear RGB coordinates of a color.
 | |
|    * @return The hue of the color in CAM16, in radians.
 | |
|    */
 | |
|   static hueOf(e) {
 | |
|     const r = ot(e, d.SCALED_DISCOUNT_FROM_LINRGB), a = d.chromaticAdaptation(r[0]), n = d.chromaticAdaptation(r[1]), s = d.chromaticAdaptation(r[2]), c = (11 * a + -12 * n + s) / 11, i = (a + n - 2 * s) / 9;
 | |
|     return Math.atan2(i, c);
 | |
|   }
 | |
|   static areInCyclicOrder(e, r, a) {
 | |
|     const n = d.sanitizeRadians(r - e), s = d.sanitizeRadians(a - e);
 | |
|     return n < s;
 | |
|   }
 | |
|   /**
 | |
|    * Solves the lerp equation.
 | |
|    *
 | |
|    * @param source The starting number.
 | |
|    * @param mid The number in the middle.
 | |
|    * @param target The ending number.
 | |
|    * @return A number t such that lerp(source, target, t) = mid.
 | |
|    */
 | |
|   static intercept(e, r, a) {
 | |
|     return (r - e) / (a - e);
 | |
|   }
 | |
|   static lerpPoint(e, r, a) {
 | |
|     return [
 | |
|       e[0] + (a[0] - e[0]) * r,
 | |
|       e[1] + (a[1] - e[1]) * r,
 | |
|       e[2] + (a[2] - e[2]) * r
 | |
|     ];
 | |
|   }
 | |
|   /**
 | |
|    * Intersects a segment with a plane.
 | |
|    *
 | |
|    * @param source The coordinates of point A.
 | |
|    * @param coordinate The R-, G-, or B-coordinate of the plane.
 | |
|    * @param target The coordinates of point B.
 | |
|    * @param axis The axis the plane is perpendicular with. (0: R, 1:
 | |
|    * G, 2: B)
 | |
|    * @return The intersection point of the segment AB with the plane
 | |
|    * R=coordinate, G=coordinate, or B=coordinate
 | |
|    */
 | |
|   static setCoordinate(e, r, a, n) {
 | |
|     const s = d.intercept(e[n], r, a[n]);
 | |
|     return d.lerpPoint(e, s, a);
 | |
|   }
 | |
|   static isBounded(e) {
 | |
|     return 0 <= e && e <= 100;
 | |
|   }
 | |
|   /**
 | |
|    * Returns the nth possible vertex of the polygonal intersection.
 | |
|    *
 | |
|    * @param y The Y value of the plane.
 | |
|    * @param n The zero-based index of the point. 0 <= n <= 11.
 | |
|    * @return The nth possible vertex of the polygonal intersection
 | |
|    * of the y plane and the RGB cube, in linear RGB coordinates, if
 | |
|    * it exists. If this possible vertex lies outside of the cube,
 | |
|    * [-1.0, -1.0, -1.0] is returned.
 | |
|    */
 | |
|   static nthVertex(e, r) {
 | |
|     const a = d.Y_FROM_LINRGB[0], n = d.Y_FROM_LINRGB[1], s = d.Y_FROM_LINRGB[2], c = r % 4 <= 1 ? 0 : 100, i = r % 2 === 0 ? 0 : 100;
 | |
|     if (r < 4) {
 | |
|       const l = c, f = i, h = (e - l * n - f * s) / a;
 | |
|       return d.isBounded(h) ? [h, l, f] : [-1, -1, -1];
 | |
|     } else if (r < 8) {
 | |
|       const l = c, f = i, h = (e - f * a - l * s) / n;
 | |
|       return d.isBounded(h) ? [f, h, l] : [-1, -1, -1];
 | |
|     } else {
 | |
|       const l = c, f = i, h = (e - l * a - f * n) / s;
 | |
|       return d.isBounded(h) ? [l, f, h] : [-1, -1, -1];
 | |
|     }
 | |
|   }
 | |
|   /**
 | |
|    * Finds the segment containing the desired color.
 | |
|    *
 | |
|    * @param y The Y value of the color.
 | |
|    * @param targetHue The hue of the color.
 | |
|    * @return A list of two sets of linear RGB coordinates, each
 | |
|    * corresponding to an endpoint of the segment containing the
 | |
|    * desired color.
 | |
|    */
 | |
|   static bisectToSegment(e, r) {
 | |
|     let a = [-1, -1, -1], n = a, s = 0, c = 0, i = !1, l = !0;
 | |
|     for (let f = 0; f < 12; f++) {
 | |
|       const h = d.nthVertex(e, f);
 | |
|       if (h[0] < 0)
 | |
|         continue;
 | |
|       const g = d.hueOf(h);
 | |
|       if (!i) {
 | |
|         a = h, n = h, s = g, c = g, i = !0;
 | |
|         continue;
 | |
|       }
 | |
|       (l || d.areInCyclicOrder(s, g, c)) && (l = !1, d.areInCyclicOrder(s, r, g) ? (n = h, c = g) : (a = h, s = g));
 | |
|     }
 | |
|     return [a, n];
 | |
|   }
 | |
|   static midpoint(e, r) {
 | |
|     return [
 | |
|       (e[0] + r[0]) / 2,
 | |
|       (e[1] + r[1]) / 2,
 | |
|       (e[2] + r[2]) / 2
 | |
|     ];
 | |
|   }
 | |
|   static criticalPlaneBelow(e) {
 | |
|     return Math.floor(e - 0.5);
 | |
|   }
 | |
|   static criticalPlaneAbove(e) {
 | |
|     return Math.ceil(e - 0.5);
 | |
|   }
 | |
|   /**
 | |
|    * Finds a color with the given Y and hue on the boundary of the
 | |
|    * cube.
 | |
|    *
 | |
|    * @param y The Y value of the color.
 | |
|    * @param targetHue The hue of the color.
 | |
|    * @return The desired color, in linear RGB coordinates.
 | |
|    */
 | |
|   static bisectToLimit(e, r) {
 | |
|     const a = d.bisectToSegment(e, r);
 | |
|     let n = a[0], s = d.hueOf(n), c = a[1];
 | |
|     for (let i = 0; i < 3; i++)
 | |
|       if (n[i] !== c[i]) {
 | |
|         let l = -1, f = 255;
 | |
|         n[i] < c[i] ? (l = d.criticalPlaneBelow(d.trueDelinearized(n[i])), f = d.criticalPlaneAbove(d.trueDelinearized(c[i]))) : (l = d.criticalPlaneAbove(d.trueDelinearized(n[i])), f = d.criticalPlaneBelow(d.trueDelinearized(c[i])));
 | |
|         for (let h = 0; h < 8 && !(Math.abs(f - l) <= 1); h++) {
 | |
|           const g = Math.floor((l + f) / 2), p = d.CRITICAL_PLANES[g], y = d.setCoordinate(n, p, c, i), k = d.hueOf(y);
 | |
|           d.areInCyclicOrder(s, r, k) ? (c = y, f = g) : (n = y, s = k, l = g);
 | |
|         }
 | |
|       }
 | |
|     return d.midpoint(n, c);
 | |
|   }
 | |
|   static inverseChromaticAdaptation(e) {
 | |
|     const r = Math.abs(e), a = Math.max(0, 27.13 * r / (400 - r));
 | |
|     return O(e) * Math.pow(a, 1 / 0.42);
 | |
|   }
 | |
|   /**
 | |
|    * Finds a color with the given hue, chroma, and Y.
 | |
|    *
 | |
|    * @param hueRadians The desired hue in radians.
 | |
|    * @param chroma The desired chroma.
 | |
|    * @param y The desired Y.
 | |
|    * @return The desired color as a hexadecimal integer, if found; 0
 | |
|    * otherwise.
 | |
|    */
 | |
|   static findResultByJ(e, r, a) {
 | |
|     let n = Math.sqrt(a) * 11;
 | |
|     const s = S.DEFAULT, c = 1 / Math.pow(1.64 - Math.pow(0.29, s.n), 0.73), l = 0.25 * (Math.cos(e + 2) + 3.8) * (5e4 / 13) * s.nc * s.ncb, f = Math.sin(e), h = Math.cos(e);
 | |
|     for (let g = 0; g < 5; g++) {
 | |
|       const p = n / 100, y = r === 0 || n === 0 ? 0 : r / Math.sqrt(p), k = Math.pow(y * c, 1 / 0.9), D = s.aw * Math.pow(p, 1 / s.c / s.z) / s.nbb, C = 23 * (D + 0.305) * k / (23 * l + 11 * k * h + 108 * k * f), w = C * h, M = C * f, x = (460 * D + 451 * w + 288 * M) / 1403, b = (460 * D - 891 * w - 261 * M) / 1403, B = (460 * D - 220 * w - 6300 * M) / 1403, I = d.inverseChromaticAdaptation(x), A = d.inverseChromaticAdaptation(b), R = d.inverseChromaticAdaptation(B), F = ot([I, A, R], d.LINRGB_FROM_SCALED_DISCOUNT);
 | |
|       if (F[0] < 0 || F[1] < 0 || F[2] < 0)
 | |
|         return 0;
 | |
|       const q = d.Y_FROM_LINRGB[0], Y = d.Y_FROM_LINRGB[1], z = d.Y_FROM_LINRGB[2], N = q * F[0] + Y * F[1] + z * F[2];
 | |
|       if (N <= 0)
 | |
|         return 0;
 | |
|       if (g === 4 || Math.abs(N - a) < 2e-3)
 | |
|         return F[0] > 100.01 || F[1] > 100.01 || F[2] > 100.01 ? 0 : ft(F);
 | |
|       n = n - (N - a) * n / (2 * N);
 | |
|     }
 | |
|     return 0;
 | |
|   }
 | |
|   /**
 | |
|    * Finds an sRGB color with the given hue, chroma, and L*, if
 | |
|    * possible.
 | |
|    *
 | |
|    * @param hueDegrees The desired hue, in degrees.
 | |
|    * @param chroma The desired chroma.
 | |
|    * @param lstar The desired L*.
 | |
|    * @return A hexadecimal representing the sRGB color. The color
 | |
|    * has sufficiently close hue, chroma, and L* to the desired
 | |
|    * values, if possible; otherwise, the hue and L* will be
 | |
|    * sufficiently close, and chroma will be maximized.
 | |
|    */
 | |
|   static solveToInt(e, r, a) {
 | |
|     if (r < 1e-4 || a < 1e-4 || a > 99.9999)
 | |
|       return Bt(a);
 | |
|     e = mt(e);
 | |
|     const n = e / 180 * Math.PI, s = G(a), c = d.findResultByJ(n, r, s);
 | |
|     if (c !== 0)
 | |
|       return c;
 | |
|     const i = d.bisectToLimit(s, n);
 | |
|     return ft(i);
 | |
|   }
 | |
|   /**
 | |
|    * Finds an sRGB color with the given hue, chroma, and L*, if
 | |
|    * possible.
 | |
|    *
 | |
|    * @param hueDegrees The desired hue, in degrees.
 | |
|    * @param chroma The desired chroma.
 | |
|    * @param lstar The desired L*.
 | |
|    * @return An CAM16 object representing the sRGB color. The color
 | |
|    * has sufficiently close hue, chroma, and L* to the desired
 | |
|    * values, if possible; otherwise, the hue and L* will be
 | |
|    * sufficiently close, and chroma will be maximized.
 | |
|    */
 | |
|   static solveToCam(e, r, a) {
 | |
|     return E.fromInt(d.solveToInt(e, r, a));
 | |
|   }
 | |
| }
 | |
| d.SCALED_DISCOUNT_FROM_LINRGB = [
 | |
|   [
 | |
|     0.001200833568784504,
 | |
|     0.002389694492170889,
 | |
|     2795742885861124e-19
 | |
|   ],
 | |
|   [
 | |
|     5891086651375999e-19,
 | |
|     0.0029785502573438758,
 | |
|     3270666104008398e-19
 | |
|   ],
 | |
|   [
 | |
|     10146692491640572e-20,
 | |
|     5364214359186694e-19,
 | |
|     0.0032979401770712076
 | |
|   ]
 | |
| ];
 | |
| d.LINRGB_FROM_SCALED_DISCOUNT = [
 | |
|   [
 | |
|     1373.2198709594231,
 | |
|     -1100.4251190754821,
 | |
|     -7.278681089101213
 | |
|   ],
 | |
|   [
 | |
|     -271.815969077903,
 | |
|     559.6580465940733,
 | |
|     -32.46047482791194
 | |
|   ],
 | |
|   [
 | |
|     1.9622899599665666,
 | |
|     -57.173814538844006,
 | |
|     308.7233197812385
 | |
|   ]
 | |
| ];
 | |
| d.Y_FROM_LINRGB = [0.2126, 0.7152, 0.0722];
 | |
| d.CRITICAL_PLANES = [
 | |
|   0.015176349177441876,
 | |
|   0.045529047532325624,
 | |
|   0.07588174588720938,
 | |
|   0.10623444424209313,
 | |
|   0.13658714259697685,
 | |
|   0.16693984095186062,
 | |
|   0.19729253930674434,
 | |
|   0.2276452376616281,
 | |
|   0.2579979360165119,
 | |
|   0.28835063437139563,
 | |
|   0.3188300904430532,
 | |
|   0.350925934958123,
 | |
|   0.3848314933096426,
 | |
|   0.42057480301049466,
 | |
|   0.458183274052838,
 | |
|   0.4976837250274023,
 | |
|   0.5391024159806381,
 | |
|   0.5824650784040898,
 | |
|   0.6277969426914107,
 | |
|   0.6751227633498623,
 | |
|   0.7244668422128921,
 | |
|   0.775853049866786,
 | |
|   0.829304845476233,
 | |
|   0.8848452951698498,
 | |
|   0.942497089126609,
 | |
|   1.0022825574869039,
 | |
|   1.0642236851973577,
 | |
|   1.1283421258858297,
 | |
|   1.1946592148522128,
 | |
|   1.2631959812511864,
 | |
|   1.3339731595349034,
 | |
|   1.407011200216447,
 | |
|   1.4823302800086415,
 | |
|   1.5599503113873272,
 | |
|   1.6398909516233677,
 | |
|   1.7221716113234105,
 | |
|   1.8068114625156377,
 | |
|   1.8938294463134073,
 | |
|   1.9832442801866852,
 | |
|   2.075074464868551,
 | |
|   2.1693382909216234,
 | |
|   2.2660538449872063,
 | |
|   2.36523901573795,
 | |
|   2.4669114995532007,
 | |
|   2.5710888059345764,
 | |
|   2.6777882626779785,
 | |
|   2.7870270208169257,
 | |
|   2.898822059350997,
 | |
|   3.0131901897720907,
 | |
|   3.1301480604002863,
 | |
|   3.2497121605402226,
 | |
|   3.3718988244681087,
 | |
|   3.4967242352587946,
 | |
|   3.624204428461639,
 | |
|   3.754355295633311,
 | |
|   3.887192587735158,
 | |
|   4.022731918402185,
 | |
|   4.160988767090289,
 | |
|   4.301978482107941,
 | |
|   4.445716283538092,
 | |
|   4.592217266055746,
 | |
|   4.741496401646282,
 | |
|   4.893568542229298,
 | |
|   5.048448422192488,
 | |
|   5.20615066083972,
 | |
|   5.3666897647573375,
 | |
|   5.5300801301023865,
 | |
|   5.696336044816294,
 | |
|   5.865471690767354,
 | |
|   6.037501145825082,
 | |
|   6.212438385869475,
 | |
|   6.390297286737924,
 | |
|   6.571091626112461,
 | |
|   6.7548350853498045,
 | |
|   6.941541251256611,
 | |
|   7.131223617812143,
 | |
|   7.323895587840543,
 | |
|   7.5195704746346665,
 | |
|   7.7182615035334345,
 | |
|   7.919981813454504,
 | |
|   8.124744458384042,
 | |
|   8.332562408825165,
 | |
|   8.543448553206703,
 | |
|   8.757415699253682,
 | |
|   8.974476575321063,
 | |
|   9.194643831691977,
 | |
|   9.417930041841839,
 | |
|   9.644347703669503,
 | |
|   9.873909240696694,
 | |
|   10.106627003236781,
 | |
|   10.342513269534024,
 | |
|   10.58158024687427,
 | |
|   10.8238400726681,
 | |
|   11.069304815507364,
 | |
|   11.317986476196008,
 | |
|   11.569896988756009,
 | |
|   11.825048221409341,
 | |
|   12.083451977536606,
 | |
|   12.345119996613247,
 | |
|   12.610063955123938,
 | |
|   12.878295467455942,
 | |
|   13.149826086772048,
 | |
|   13.42466730586372,
 | |
|   13.702830557985108,
 | |
|   13.984327217668513,
 | |
|   14.269168601521828,
 | |
|   14.55736596900856,
 | |
|   14.848930523210871,
 | |
|   15.143873411576273,
 | |
|   15.44220572664832,
 | |
|   15.743938506781891,
 | |
|   16.04908273684337,
 | |
|   16.35764934889634,
 | |
|   16.66964922287304,
 | |
|   16.985093187232053,
 | |
|   17.30399201960269,
 | |
|   17.62635644741625,
 | |
|   17.95219714852476,
 | |
|   18.281524751807332,
 | |
|   18.614349837764564,
 | |
|   18.95068293910138,
 | |
|   19.290534541298456,
 | |
|   19.633915083172692,
 | |
|   19.98083495742689,
 | |
|   20.331304511189067,
 | |
|   20.685334046541502,
 | |
|   21.042933821039977,
 | |
|   21.404114048223256,
 | |
|   21.76888489811322,
 | |
|   22.137256497705877,
 | |
|   22.50923893145328,
 | |
|   22.884842241736916,
 | |
|   23.264076429332462,
 | |
|   23.6469514538663,
 | |
|   24.033477234264016,
 | |
|   24.42366364919083,
 | |
|   24.817520537484558,
 | |
|   25.21505769858089,
 | |
|   25.61628489293138,
 | |
|   26.021211842414342,
 | |
|   26.429848230738664,
 | |
|   26.842203703840827,
 | |
|   27.258287870275353,
 | |
|   27.678110301598522,
 | |
|   28.10168053274597,
 | |
|   28.529008062403893,
 | |
|   28.96010235337422,
 | |
|   29.39497283293396,
 | |
|   29.83362889318845,
 | |
|   30.276079891419332,
 | |
|   30.722335150426627,
 | |
|   31.172403958865512,
 | |
|   31.62629557157785,
 | |
|   32.08401920991837,
 | |
|   32.54558406207592,
 | |
|   33.010999283389665,
 | |
|   33.4802739966603,
 | |
|   33.953417292456834,
 | |
|   34.430438229418264,
 | |
|   34.911345834551085,
 | |
|   35.39614910352207,
 | |
|   35.88485700094671,
 | |
|   36.37747846067349,
 | |
|   36.87402238606382,
 | |
|   37.37449765026789,
 | |
|   37.87891309649659,
 | |
|   38.38727753828926,
 | |
|   38.89959975977785,
 | |
|   39.41588851594697,
 | |
|   39.93615253289054,
 | |
|   40.460400508064545,
 | |
|   40.98864111053629,
 | |
|   41.520882981230194,
 | |
|   42.05713473317016,
 | |
|   42.597404951718396,
 | |
|   43.141702194811224,
 | |
|   43.6900349931913,
 | |
|   44.24241185063697,
 | |
|   44.798841244188324,
 | |
|   45.35933162437017,
 | |
|   45.92389141541209,
 | |
|   46.49252901546552,
 | |
|   47.065252796817916,
 | |
|   47.64207110610409,
 | |
|   48.22299226451468,
 | |
|   48.808024568002054,
 | |
|   49.3971762874833,
 | |
|   49.9904556690408,
 | |
|   50.587870934119984,
 | |
|   51.189430279724725,
 | |
|   51.79514187861014,
 | |
|   52.40501387947288,
 | |
|   53.0190544071392,
 | |
|   53.637271562750364,
 | |
|   54.259673423945976,
 | |
|   54.88626804504493,
 | |
|   55.517063457223934,
 | |
|   56.15206766869424,
 | |
|   56.79128866487574,
 | |
|   57.43473440856916,
 | |
|   58.08241284012621,
 | |
|   58.734331877617365,
 | |
|   59.39049941699807,
 | |
|   60.05092333227251,
 | |
|   60.715611475655585,
 | |
|   61.38457167773311,
 | |
|   62.057811747619894,
 | |
|   62.7353394731159,
 | |
|   63.417162620860914,
 | |
|   64.10328893648692,
 | |
|   64.79372614476921,
 | |
|   65.48848194977529,
 | |
|   66.18756403501224,
 | |
|   66.89098006357258,
 | |
|   67.59873767827808,
 | |
|   68.31084450182222,
 | |
|   69.02730813691093,
 | |
|   69.74813616640164,
 | |
|   70.47333615344107,
 | |
|   71.20291564160104,
 | |
|   71.93688215501312,
 | |
|   72.67524319850172,
 | |
|   73.41800625771542,
 | |
|   74.16517879925733,
 | |
|   74.9167682708136,
 | |
|   75.67278210128072,
 | |
|   76.43322770089146,
 | |
|   77.1981124613393,
 | |
|   77.96744375590167,
 | |
|   78.74122893956174,
 | |
|   79.51947534912904,
 | |
|   80.30219030335869,
 | |
|   81.08938110306934,
 | |
|   81.88105503125999,
 | |
|   82.67721935322541,
 | |
|   83.4778813166706,
 | |
|   84.28304815182372,
 | |
|   85.09272707154808,
 | |
|   85.90692527145302,
 | |
|   86.72564993000343,
 | |
|   87.54890820862819,
 | |
|   88.3767072518277,
 | |
|   89.2090541872801,
 | |
|   90.04595612594655,
 | |
|   90.88742016217518,
 | |
|   91.73345337380438,
 | |
|   92.58406282226491,
 | |
|   93.43925555268066,
 | |
|   94.29903859396902,
 | |
|   95.16341895893969,
 | |
|   96.03240364439274,
 | |
|   96.9059996312159,
 | |
|   97.78421388448044,
 | |
|   98.6670533535366,
 | |
|   99.55452497210776
 | |
| ];
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2021 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| class J {
 | |
|   static from(e, r, a) {
 | |
|     return new J(d.solveToInt(e, r, a));
 | |
|   }
 | |
|   /**
 | |
|    * @param argb ARGB representation of a color.
 | |
|    * @return HCT representation of a color in default viewing conditions
 | |
|    */
 | |
|   static fromInt(e) {
 | |
|     return new J(e);
 | |
|   }
 | |
|   toInt() {
 | |
|     return this.argb;
 | |
|   }
 | |
|   /**
 | |
|    * A number, in degrees, representing ex. red, orange, yellow, etc.
 | |
|    * Ranges from 0 <= hue < 360.
 | |
|    */
 | |
|   get hue() {
 | |
|     return this.internalHue;
 | |
|   }
 | |
|   /**
 | |
|    * @param newHue 0 <= newHue < 360; invalid values are corrected.
 | |
|    * Chroma may decrease because chroma has a different maximum for any given
 | |
|    * hue and tone.
 | |
|    */
 | |
|   set hue(e) {
 | |
|     this.setInternalState(d.solveToInt(e, this.internalChroma, this.internalTone));
 | |
|   }
 | |
|   get chroma() {
 | |
|     return this.internalChroma;
 | |
|   }
 | |
|   /**
 | |
|    * @param newChroma 0 <= newChroma < ?
 | |
|    * Chroma may decrease because chroma has a different maximum for any given
 | |
|    * hue and tone.
 | |
|    */
 | |
|   set chroma(e) {
 | |
|     this.setInternalState(d.solveToInt(this.internalHue, e, this.internalTone));
 | |
|   }
 | |
|   /** Lightness. Ranges from 0 to 100. */
 | |
|   get tone() {
 | |
|     return this.internalTone;
 | |
|   }
 | |
|   /**
 | |
|    * @param newTone 0 <= newTone <= 100; invalid valids are corrected.
 | |
|    * Chroma may decrease because chroma has a different maximum for any given
 | |
|    * hue and tone.
 | |
|    */
 | |
|   set tone(e) {
 | |
|     this.setInternalState(d.solveToInt(this.internalHue, this.internalChroma, e));
 | |
|   }
 | |
|   constructor(e) {
 | |
|     this.argb = e;
 | |
|     const r = E.fromInt(e);
 | |
|     this.internalHue = r.hue, this.internalChroma = r.chroma, this.internalTone = dt(e), this.argb = e;
 | |
|   }
 | |
|   setInternalState(e) {
 | |
|     const r = E.fromInt(e);
 | |
|     this.internalHue = r.hue, this.internalChroma = r.chroma, this.internalTone = dt(e), this.argb = e;
 | |
|   }
 | |
|   /**
 | |
|    * Translates a color into different [ViewingConditions].
 | |
|    *
 | |
|    * Colors change appearance. They look different with lights on versus off,
 | |
|    * the same color, as in hex code, on white looks different when on black.
 | |
|    * This is called color relativity, most famously explicated by Josef Albers
 | |
|    * in Interaction of Color.
 | |
|    *
 | |
|    * In color science, color appearance models can account for this and
 | |
|    * calculate the appearance of a color in different settings. HCT is based on
 | |
|    * CAM16, a color appearance model, and uses it to make these calculations.
 | |
|    *
 | |
|    * See [ViewingConditions.make] for parameters affecting color appearance.
 | |
|    */
 | |
|   inViewingConditions(e) {
 | |
|     const a = E.fromInt(this.toInt()).xyzInViewingConditions(e), n = E.fromXyzInViewingConditions(a[0], a[1], a[2], S.make());
 | |
|     return J.from(n.hue, n.chroma, st(a[1]));
 | |
|   }
 | |
| }
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2022 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| class L {
 | |
|   /**
 | |
|    * Returns a contrast ratio, which ranges from 1 to 21.
 | |
|    *
 | |
|    * @param toneA Tone between 0 and 100. Values outside will be clamped.
 | |
|    * @param toneB Tone between 0 and 100. Values outside will be clamped.
 | |
|    */
 | |
|   static ratioOfTones(e, r) {
 | |
|     return e = tt(0, 100, e), r = tt(0, 100, r), L.ratioOfYs(G(e), G(r));
 | |
|   }
 | |
|   static ratioOfYs(e, r) {
 | |
|     const a = e > r ? e : r, n = a === r ? e : r;
 | |
|     return (a + 5) / (n + 5);
 | |
|   }
 | |
|   /**
 | |
|    * Returns a tone >= tone parameter that ensures ratio parameter.
 | |
|    * Return value is between 0 and 100.
 | |
|    * Returns -1 if ratio cannot be achieved with tone parameter.
 | |
|    *
 | |
|    * @param tone Tone return value must contrast with.
 | |
|    * Range is 0 to 100. Invalid values will result in -1 being returned.
 | |
|    * @param ratio Contrast ratio of return value and tone.
 | |
|    * Range is 1 to 21, invalid values have undefined behavior.
 | |
|    */
 | |
|   static lighter(e, r) {
 | |
|     if (e < 0 || e > 100)
 | |
|       return -1;
 | |
|     const a = G(e), n = r * (a + 5) - 5, s = L.ratioOfYs(n, a), c = Math.abs(s - r);
 | |
|     if (s < r && c > 0.04)
 | |
|       return -1;
 | |
|     const i = st(n) + 0.4;
 | |
|     return i < 0 || i > 100 ? -1 : i;
 | |
|   }
 | |
|   /**
 | |
|    * Returns a tone <= tone parameter that ensures ratio parameter.
 | |
|    * Return value is between 0 and 100.
 | |
|    * Returns -1 if ratio cannot be achieved with tone parameter.
 | |
|    *
 | |
|    * @param tone Tone return value must contrast with.
 | |
|    * Range is 0 to 100. Invalid values will result in -1 being returned.
 | |
|    * @param ratio Contrast ratio of return value and tone.
 | |
|    * Range is 1 to 21, invalid values have undefined behavior.
 | |
|    */
 | |
|   static darker(e, r) {
 | |
|     if (e < 0 || e > 100)
 | |
|       return -1;
 | |
|     const a = G(e), n = (a + 5) / r - 5, s = L.ratioOfYs(a, n), c = Math.abs(s - r);
 | |
|     if (s < r && c > 0.04)
 | |
|       return -1;
 | |
|     const i = st(n) - 0.4;
 | |
|     return i < 0 || i > 100 ? -1 : i;
 | |
|   }
 | |
|   /**
 | |
|    * Returns a tone >= tone parameter that ensures ratio parameter.
 | |
|    * Return value is between 0 and 100.
 | |
|    * Returns 100 if ratio cannot be achieved with tone parameter.
 | |
|    *
 | |
|    * This method is unsafe because the returned value is guaranteed to be in
 | |
|    * bounds for tone, i.e. between 0 and 100. However, that value may not reach
 | |
|    * the ratio with tone. For example, there is no color lighter than T100.
 | |
|    *
 | |
|    * @param tone Tone return value must contrast with.
 | |
|    * Range is 0 to 100. Invalid values will result in 100 being returned.
 | |
|    * @param ratio Desired contrast ratio of return value and tone parameter.
 | |
|    * Range is 1 to 21, invalid values have undefined behavior.
 | |
|    */
 | |
|   static lighterUnsafe(e, r) {
 | |
|     const a = L.lighter(e, r);
 | |
|     return a < 0 ? 100 : a;
 | |
|   }
 | |
|   /**
 | |
|    * Returns a tone >= tone parameter that ensures ratio parameter.
 | |
|    * Return value is between 0 and 100.
 | |
|    * Returns 100 if ratio cannot be achieved with tone parameter.
 | |
|    *
 | |
|    * This method is unsafe because the returned value is guaranteed to be in
 | |
|    * bounds for tone, i.e. between 0 and 100. However, that value may not reach
 | |
|    * the [ratio with [tone]. For example, there is no color darker than T0.
 | |
|    *
 | |
|    * @param tone Tone return value must contrast with.
 | |
|    * Range is 0 to 100. Invalid values will result in 0 being returned.
 | |
|    * @param ratio Desired contrast ratio of return value and tone parameter.
 | |
|    * Range is 1 to 21, invalid values have undefined behavior.
 | |
|    */
 | |
|   static darkerUnsafe(e, r) {
 | |
|     const a = L.darker(e, r);
 | |
|     return a < 0 ? 0 : a;
 | |
|   }
 | |
| }
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2023 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| class it {
 | |
|   /**
 | |
|    * Returns true if a color is disliked.
 | |
|    *
 | |
|    * @param hct A color to be judged.
 | |
|    * @return Whether the color is disliked.
 | |
|    *
 | |
|    * Disliked is defined as a dark yellow-green that is not neutral.
 | |
|    */
 | |
|   static isDisliked(e) {
 | |
|     const r = Math.round(e.hue) >= 90 && Math.round(e.hue) <= 111, a = Math.round(e.chroma) > 16, n = Math.round(e.tone) < 65;
 | |
|     return r && a && n;
 | |
|   }
 | |
|   /**
 | |
|    * If a color is disliked, lighten it to make it likable.
 | |
|    *
 | |
|    * @param hct A color to be judged.
 | |
|    * @return A new color if the original color is disliked, or the original
 | |
|    *   color if it is acceptable.
 | |
|    */
 | |
|   static fixIfDisliked(e) {
 | |
|     return it.isDisliked(e) ? J.from(e.hue, e.chroma, 70) : e;
 | |
|   }
 | |
| }
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2022 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| class u {
 | |
|   /**
 | |
|    * Create a DynamicColor defined by a TonalPalette and HCT tone.
 | |
|    *
 | |
|    * @param args Functions with DynamicScheme as input. Must provide a palette
 | |
|    * and tone. May provide a background DynamicColor and ToneDeltaConstraint.
 | |
|    */
 | |
|   static fromPalette(e) {
 | |
|     return new u(e.name ?? "", e.palette, e.tone, e.isBackground ?? !1, e.background, e.secondBackground, e.contrastCurve, e.toneDeltaPair);
 | |
|   }
 | |
|   /**
 | |
|    * The base constructor for DynamicColor.
 | |
|    *
 | |
|    * _Strongly_ prefer using one of the convenience constructors. This class is
 | |
|    * arguably too flexible to ensure it can support any scenario. Functional
 | |
|    * arguments allow  overriding without risks that come with subclasses.
 | |
|    *
 | |
|    * For example, the default behavior of adjust tone at max contrast
 | |
|    * to be at a 7.0 ratio with its background is principled and
 | |
|    * matches accessibility guidance. That does not mean it's the desired
 | |
|    * approach for _every_ design system, and every color pairing,
 | |
|    * always, in every case.
 | |
|    *
 | |
|    * @param name The name of the dynamic color. Defaults to empty.
 | |
|    * @param palette Function that provides a TonalPalette given
 | |
|    * DynamicScheme. A TonalPalette is defined by a hue and chroma, so this
 | |
|    * replaces the need to specify hue/chroma. By providing a tonal palette, when
 | |
|    * contrast adjustments are made, intended chroma can be preserved.
 | |
|    * @param tone Function that provides a tone, given a DynamicScheme.
 | |
|    * @param isBackground Whether this dynamic color is a background, with
 | |
|    * some other color as the foreground. Defaults to false.
 | |
|    * @param background The background of the dynamic color (as a function of a
 | |
|    *     `DynamicScheme`), if it exists.
 | |
|    * @param secondBackground A second background of the dynamic color (as a
 | |
|    *     function of a `DynamicScheme`), if it
 | |
|    * exists.
 | |
|    * @param contrastCurve A `ContrastCurve` object specifying how its contrast
 | |
|    * against its background should behave in various contrast levels options.
 | |
|    * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
 | |
|    * constraint between two colors. One of them must be the color being
 | |
|    * constructed.
 | |
|    */
 | |
|   constructor(e, r, a, n, s, c, i, l) {
 | |
|     if (this.name = e, this.palette = r, this.tone = a, this.isBackground = n, this.background = s, this.secondBackground = c, this.contrastCurve = i, this.toneDeltaPair = l, this.hctCache = /* @__PURE__ */ new Map(), !s && c)
 | |
|       throw new Error(`Color ${e} has secondBackgrounddefined, but background is not defined.`);
 | |
|     if (!s && i)
 | |
|       throw new Error(`Color ${e} has contrastCurvedefined, but background is not defined.`);
 | |
|     if (s && !i)
 | |
|       throw new Error(`Color ${e} has backgrounddefined, but contrastCurve is not defined.`);
 | |
|   }
 | |
|   /**
 | |
|    * Return a ARGB integer (i.e. a hex code).
 | |
|    *
 | |
|    * @param scheme Defines the conditions of the user interface, for example,
 | |
|    * whether or not it is dark mode or light mode, and what the desired
 | |
|    * contrast level is.
 | |
|    */
 | |
|   getArgb(e) {
 | |
|     return this.getHct(e).toInt();
 | |
|   }
 | |
|   /**
 | |
|    * Return a color, expressed in the HCT color space, that this
 | |
|    * DynamicColor is under the conditions in scheme.
 | |
|    *
 | |
|    * @param scheme Defines the conditions of the user interface, for example,
 | |
|    * whether or not it is dark mode or light mode, and what the desired
 | |
|    * contrast level is.
 | |
|    */
 | |
|   getHct(e) {
 | |
|     const r = this.hctCache.get(e);
 | |
|     if (r != null)
 | |
|       return r;
 | |
|     const a = this.getTone(e), n = this.palette(e).getHct(a);
 | |
|     return this.hctCache.size > 4 && this.hctCache.clear(), this.hctCache.set(e, n), n;
 | |
|   }
 | |
|   /**
 | |
|    * Return a tone, T in the HCT color space, that this DynamicColor is under
 | |
|    * the conditions in scheme.
 | |
|    *
 | |
|    * @param scheme Defines the conditions of the user interface, for example,
 | |
|    * whether or not it is dark mode or light mode, and what the desired
 | |
|    * contrast level is.
 | |
|    */
 | |
|   getTone(e) {
 | |
|     const r = e.contrastLevel < 0;
 | |
|     if (this.toneDeltaPair) {
 | |
|       const a = this.toneDeltaPair(e), n = a.roleA, s = a.roleB, c = a.delta, i = a.polarity, l = a.stayTogether, h = this.background(e).getTone(e), g = i === "nearer" || i === "lighter" && !e.isDark || i === "darker" && e.isDark, p = g ? n : s, y = g ? s : n, k = this.name === p.name, P = e.isDark ? 1 : -1, D = p.contrastCurve.get(e.contrastLevel), C = y.contrastCurve.get(e.contrastLevel), w = p.tone(e);
 | |
|       let M = L.ratioOfTones(h, w) >= D ? w : u.foregroundTone(h, D);
 | |
|       const x = y.tone(e);
 | |
|       let b = L.ratioOfTones(h, x) >= C ? x : u.foregroundTone(h, C);
 | |
|       return r && (M = u.foregroundTone(h, D), b = u.foregroundTone(h, C)), (b - M) * P >= c || (b = tt(0, 100, M + c * P), (b - M) * P >= c || (M = tt(0, 100, b - c * P))), 50 <= M && M < 60 ? P > 0 ? (M = 60, b = Math.max(b, M + c * P)) : (M = 49, b = Math.min(b, M + c * P)) : 50 <= b && b < 60 && (l ? P > 0 ? (M = 60, b = Math.max(b, M + c * P)) : (M = 49, b = Math.min(b, M + c * P)) : P > 0 ? b = 60 : b = 49), k ? M : b;
 | |
|     } else {
 | |
|       let a = this.tone(e);
 | |
|       if (this.background == null)
 | |
|         return a;
 | |
|       const n = this.background(e).getTone(e), s = this.contrastCurve.get(e.contrastLevel);
 | |
|       if (L.ratioOfTones(n, a) >= s || (a = u.foregroundTone(n, s)), r && (a = u.foregroundTone(n, s)), this.isBackground && 50 <= a && a < 60 && (L.ratioOfTones(49, n) >= s ? a = 49 : a = 60), this.secondBackground) {
 | |
|         const [c, i] = [this.background, this.secondBackground], [l, f] = [c(e).getTone(e), i(e).getTone(e)], [h, g] = [Math.max(l, f), Math.min(l, f)];
 | |
|         if (L.ratioOfTones(h, a) >= s && L.ratioOfTones(g, a) >= s)
 | |
|           return a;
 | |
|         const p = L.lighter(h, s), y = L.darker(g, s), k = [];
 | |
|         return p !== -1 && k.push(p), y !== -1 && k.push(y), u.tonePrefersLightForeground(l) || u.tonePrefersLightForeground(f) ? p < 0 ? 100 : p : k.length === 1 ? k[0] : y < 0 ? 0 : y;
 | |
|       }
 | |
|       return a;
 | |
|     }
 | |
|   }
 | |
|   /**
 | |
|    * Given a background tone, find a foreground tone, while ensuring they reach
 | |
|    * a contrast ratio that is as close to [ratio] as possible.
 | |
|    *
 | |
|    * @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it
 | |
|    *     falls outside that range.
 | |
|    * @param ratio The contrast ratio desired between bgTone and the return
 | |
|    *     value.
 | |
|    */
 | |
|   static foregroundTone(e, r) {
 | |
|     const a = L.lighterUnsafe(e, r), n = L.darkerUnsafe(e, r), s = L.ratioOfTones(a, e), c = L.ratioOfTones(n, e);
 | |
|     if (u.tonePrefersLightForeground(e)) {
 | |
|       const l = Math.abs(s - c) < 0.1 && s < r && c < r;
 | |
|       return s >= r || s >= c || l ? a : n;
 | |
|     } else
 | |
|       return c >= r || c >= s ? n : a;
 | |
|   }
 | |
|   /**
 | |
|    * Returns whether [tone] prefers a light foreground.
 | |
|    *
 | |
|    * People prefer white foregrounds on ~T60-70. Observed over time, and also
 | |
|    * by Andrew Somers during research for APCA.
 | |
|    *
 | |
|    * T60 used as to create the smallest discontinuity possible when skipping
 | |
|    * down to T49 in order to ensure light foregrounds.
 | |
|    * Since `tertiaryContainer` in dark monochrome scheme requires a tone of
 | |
|    * 60, it should not be adjusted. Therefore, 60 is excluded here.
 | |
|    */
 | |
|   static tonePrefersLightForeground(e) {
 | |
|     return Math.round(e) < 60;
 | |
|   }
 | |
|   /**
 | |
|    * Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter
 | |
|    * color.
 | |
|    */
 | |
|   static toneAllowsLightForeground(e) {
 | |
|     return Math.round(e) <= 49;
 | |
|   }
 | |
|   /**
 | |
|    * Adjust a tone such that white has 4.5 contrast, if the tone is
 | |
|    * reasonably close to supporting it.
 | |
|    */
 | |
|   static enableLightForeground(e) {
 | |
|     return u.tonePrefersLightForeground(e) && !u.toneAllowsLightForeground(e) ? 49 : e;
 | |
|   }
 | |
| }
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2023 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| class m {
 | |
|   /**
 | |
|    * Creates a `ContrastCurve` object.
 | |
|    *
 | |
|    * @param low Value for contrast level -1.0
 | |
|    * @param normal Value for contrast level 0.0
 | |
|    * @param medium Value for contrast level 0.5
 | |
|    * @param high Value for contrast level 1.0
 | |
|    */
 | |
|   constructor(e, r, a, n) {
 | |
|     this.low = e, this.normal = r, this.medium = a, this.high = n;
 | |
|   }
 | |
|   /**
 | |
|    * Returns the value at a given contrast level.
 | |
|    *
 | |
|    * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
 | |
|    *     is the lowest; 1.0 is the highest.
 | |
|    * @return The value. For contrast ratios, a number between 1.0 and 21.0.
 | |
|    */
 | |
|   get(e) {
 | |
|     return e <= -1 ? this.low : e < 0 ? K(this.low, this.normal, (e - -1) / 1) : e < 0.5 ? K(this.normal, this.medium, (e - 0) / 0.5) : e < 1 ? K(this.medium, this.high, (e - 0.5) / 0.5) : this.high;
 | |
|   }
 | |
| }
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2023 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| class _ {
 | |
|   /**
 | |
|    * Documents a constraint in tone distance between two DynamicColors.
 | |
|    *
 | |
|    * The polarity is an adjective that describes "A", compared to "B".
 | |
|    *
 | |
|    * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
 | |
|    * A's tone should be at least 15 darker than B's.
 | |
|    *
 | |
|    * 'nearer' and 'farther' describes closeness to the surface roles. For
 | |
|    * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
 | |
|    * should be 10 lighter than B in light mode, and 10 darker than B in dark
 | |
|    * mode.
 | |
|    *
 | |
|    * @param roleA The first role in a pair.
 | |
|    * @param roleB The second role in a pair.
 | |
|    * @param delta Required difference between tones. Absolute value, negative
 | |
|    * values have undefined behavior.
 | |
|    * @param polarity The relative relation between tones of roleA and roleB,
 | |
|    * as described above.
 | |
|    * @param stayTogether Whether these two roles should stay on the same side of
 | |
|    * the "awkward zone" (T50-59). This is necessary for certain cases where
 | |
|    * one role has two backgrounds.
 | |
|    */
 | |
|   constructor(e, r, a, n, s) {
 | |
|     this.roleA = e, this.roleB = r, this.delta = a, this.polarity = n, this.stayTogether = s;
 | |
|   }
 | |
| }
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2022 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| var $;
 | |
| (function(t) {
 | |
|   t[t.MONOCHROME = 0] = "MONOCHROME", t[t.NEUTRAL = 1] = "NEUTRAL", t[t.TONAL_SPOT = 2] = "TONAL_SPOT", t[t.VIBRANT = 3] = "VIBRANT", t[t.EXPRESSIVE = 4] = "EXPRESSIVE", t[t.FIDELITY = 5] = "FIDELITY", t[t.CONTENT = 6] = "CONTENT", t[t.RAINBOW = 7] = "RAINBOW", t[t.FRUIT_SALAD = 8] = "FRUIT_SALAD";
 | |
| })($ || ($ = {}));
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2022 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| function W(t) {
 | |
|   return t.variant === $.FIDELITY || t.variant === $.CONTENT;
 | |
| }
 | |
| function T(t) {
 | |
|   return t.variant === $.MONOCHROME;
 | |
| }
 | |
| function xt(t, e, r, a) {
 | |
|   let n = r, s = J.from(t, e, r);
 | |
|   if (s.chroma < e) {
 | |
|     let c = s.chroma;
 | |
|     for (; s.chroma < e; ) {
 | |
|       n += a ? -1 : 1;
 | |
|       const i = J.from(t, e, n);
 | |
|       if (c > i.chroma || Math.abs(i.chroma - e) < 0.4)
 | |
|         break;
 | |
|       const l = Math.abs(i.chroma - e), f = Math.abs(s.chroma - e);
 | |
|       l < f && (s = i), c = Math.max(c, i.chroma);
 | |
|     }
 | |
|   }
 | |
|   return n;
 | |
| }
 | |
| class o {
 | |
|   static highestSurface(e) {
 | |
|     return e.isDark ? o.surfaceBright : o.surfaceDim;
 | |
|   }
 | |
| }
 | |
| o.contentAccentToneDelta = 15;
 | |
| o.primaryPaletteKeyColor = u.fromPalette({
 | |
|   name: "primary_palette_key_color",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => t.primaryPalette.keyColor.tone
 | |
| });
 | |
| o.secondaryPaletteKeyColor = u.fromPalette({
 | |
|   name: "secondary_palette_key_color",
 | |
|   palette: (t) => t.secondaryPalette,
 | |
|   tone: (t) => t.secondaryPalette.keyColor.tone
 | |
| });
 | |
| o.tertiaryPaletteKeyColor = u.fromPalette({
 | |
|   name: "tertiary_palette_key_color",
 | |
|   palette: (t) => t.tertiaryPalette,
 | |
|   tone: (t) => t.tertiaryPalette.keyColor.tone
 | |
| });
 | |
| o.neutralPaletteKeyColor = u.fromPalette({
 | |
|   name: "neutral_palette_key_color",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.neutralPalette.keyColor.tone
 | |
| });
 | |
| o.neutralVariantPaletteKeyColor = u.fromPalette({
 | |
|   name: "neutral_variant_palette_key_color",
 | |
|   palette: (t) => t.neutralVariantPalette,
 | |
|   tone: (t) => t.neutralVariantPalette.keyColor.tone
 | |
| });
 | |
| o.background = u.fromPalette({
 | |
|   name: "background",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? 6 : 98,
 | |
|   isBackground: !0
 | |
| });
 | |
| o.onBackground = u.fromPalette({
 | |
|   name: "on_background",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? 90 : 10,
 | |
|   background: (t) => o.background,
 | |
|   contrastCurve: new m(3, 3, 4.5, 7)
 | |
| });
 | |
| o.surface = u.fromPalette({
 | |
|   name: "surface",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? 6 : 98,
 | |
|   isBackground: !0
 | |
| });
 | |
| o.surfaceDim = u.fromPalette({
 | |
|   name: "surface_dim",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? 6 : new m(87, 87, 80, 75).get(t.contrastLevel),
 | |
|   isBackground: !0
 | |
| });
 | |
| o.surfaceBright = u.fromPalette({
 | |
|   name: "surface_bright",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? new m(24, 24, 29, 34).get(t.contrastLevel) : 98,
 | |
|   isBackground: !0
 | |
| });
 | |
| o.surfaceContainerLowest = u.fromPalette({
 | |
|   name: "surface_container_lowest",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? new m(4, 4, 2, 0).get(t.contrastLevel) : 100,
 | |
|   isBackground: !0
 | |
| });
 | |
| o.surfaceContainerLow = u.fromPalette({
 | |
|   name: "surface_container_low",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? new m(10, 10, 11, 12).get(t.contrastLevel) : new m(96, 96, 96, 95).get(t.contrastLevel),
 | |
|   isBackground: !0
 | |
| });
 | |
| o.surfaceContainer = u.fromPalette({
 | |
|   name: "surface_container",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? new m(12, 12, 16, 20).get(t.contrastLevel) : new m(94, 94, 92, 90).get(t.contrastLevel),
 | |
|   isBackground: !0
 | |
| });
 | |
| o.surfaceContainerHigh = u.fromPalette({
 | |
|   name: "surface_container_high",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? new m(17, 17, 21, 25).get(t.contrastLevel) : new m(92, 92, 88, 85).get(t.contrastLevel),
 | |
|   isBackground: !0
 | |
| });
 | |
| o.surfaceContainerHighest = u.fromPalette({
 | |
|   name: "surface_container_highest",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? new m(22, 22, 26, 30).get(t.contrastLevel) : new m(90, 90, 84, 80).get(t.contrastLevel),
 | |
|   isBackground: !0
 | |
| });
 | |
| o.onSurface = u.fromPalette({
 | |
|   name: "on_surface",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? 90 : 10,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(4.5, 7, 11, 21)
 | |
| });
 | |
| o.surfaceVariant = u.fromPalette({
 | |
|   name: "surface_variant",
 | |
|   palette: (t) => t.neutralVariantPalette,
 | |
|   tone: (t) => t.isDark ? 30 : 90,
 | |
|   isBackground: !0
 | |
| });
 | |
| o.onSurfaceVariant = u.fromPalette({
 | |
|   name: "on_surface_variant",
 | |
|   palette: (t) => t.neutralVariantPalette,
 | |
|   tone: (t) => t.isDark ? 80 : 30,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(3, 4.5, 7, 11)
 | |
| });
 | |
| o.inverseSurface = u.fromPalette({
 | |
|   name: "inverse_surface",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? 90 : 20
 | |
| });
 | |
| o.inverseOnSurface = u.fromPalette({
 | |
|   name: "inverse_on_surface",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => t.isDark ? 20 : 95,
 | |
|   background: (t) => o.inverseSurface,
 | |
|   contrastCurve: new m(4.5, 7, 11, 21)
 | |
| });
 | |
| o.outline = u.fromPalette({
 | |
|   name: "outline",
 | |
|   palette: (t) => t.neutralVariantPalette,
 | |
|   tone: (t) => t.isDark ? 60 : 50,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1.5, 3, 4.5, 7)
 | |
| });
 | |
| o.outlineVariant = u.fromPalette({
 | |
|   name: "outline_variant",
 | |
|   palette: (t) => t.neutralVariantPalette,
 | |
|   tone: (t) => t.isDark ? 30 : 80,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5)
 | |
| });
 | |
| o.shadow = u.fromPalette({
 | |
|   name: "shadow",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => 0
 | |
| });
 | |
| o.scrim = u.fromPalette({
 | |
|   name: "scrim",
 | |
|   palette: (t) => t.neutralPalette,
 | |
|   tone: (t) => 0
 | |
| });
 | |
| o.surfaceTint = u.fromPalette({
 | |
|   name: "surface_tint",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => t.isDark ? 80 : 40,
 | |
|   isBackground: !0
 | |
| });
 | |
| o.primary = u.fromPalette({
 | |
|   name: "primary",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => T(t) ? t.isDark ? 100 : 0 : t.isDark ? 80 : 40,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(3, 4.5, 7, 7),
 | |
|   toneDeltaPair: (t) => new _(o.primaryContainer, o.primary, 10, "nearer", !1)
 | |
| });
 | |
| o.onPrimary = u.fromPalette({
 | |
|   name: "on_primary",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => T(t) ? t.isDark ? 10 : 90 : t.isDark ? 20 : 100,
 | |
|   background: (t) => o.primary,
 | |
|   contrastCurve: new m(4.5, 7, 11, 21)
 | |
| });
 | |
| o.primaryContainer = u.fromPalette({
 | |
|   name: "primary_container",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => W(t) ? t.sourceColorHct.tone : T(t) ? t.isDark ? 85 : 25 : t.isDark ? 30 : 90,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.primaryContainer, o.primary, 10, "nearer", !1)
 | |
| });
 | |
| o.onPrimaryContainer = u.fromPalette({
 | |
|   name: "on_primary_container",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => W(t) ? u.foregroundTone(o.primaryContainer.tone(t), 4.5) : T(t) ? t.isDark ? 0 : 100 : t.isDark ? 90 : 30,
 | |
|   background: (t) => o.primaryContainer,
 | |
|   contrastCurve: new m(3, 4.5, 7, 11)
 | |
| });
 | |
| o.inversePrimary = u.fromPalette({
 | |
|   name: "inverse_primary",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => t.isDark ? 40 : 80,
 | |
|   background: (t) => o.inverseSurface,
 | |
|   contrastCurve: new m(3, 4.5, 7, 7)
 | |
| });
 | |
| o.secondary = u.fromPalette({
 | |
|   name: "secondary",
 | |
|   palette: (t) => t.secondaryPalette,
 | |
|   tone: (t) => t.isDark ? 80 : 40,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(3, 4.5, 7, 7),
 | |
|   toneDeltaPair: (t) => new _(o.secondaryContainer, o.secondary, 10, "nearer", !1)
 | |
| });
 | |
| o.onSecondary = u.fromPalette({
 | |
|   name: "on_secondary",
 | |
|   palette: (t) => t.secondaryPalette,
 | |
|   tone: (t) => T(t) ? t.isDark ? 10 : 100 : t.isDark ? 20 : 100,
 | |
|   background: (t) => o.secondary,
 | |
|   contrastCurve: new m(4.5, 7, 11, 21)
 | |
| });
 | |
| o.secondaryContainer = u.fromPalette({
 | |
|   name: "secondary_container",
 | |
|   palette: (t) => t.secondaryPalette,
 | |
|   tone: (t) => {
 | |
|     const e = t.isDark ? 30 : 90;
 | |
|     return T(t) ? t.isDark ? 30 : 85 : W(t) ? xt(t.secondaryPalette.hue, t.secondaryPalette.chroma, e, !t.isDark) : e;
 | |
|   },
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.secondaryContainer, o.secondary, 10, "nearer", !1)
 | |
| });
 | |
| o.onSecondaryContainer = u.fromPalette({
 | |
|   name: "on_secondary_container",
 | |
|   palette: (t) => t.secondaryPalette,
 | |
|   tone: (t) => T(t) ? t.isDark ? 90 : 10 : W(t) ? u.foregroundTone(o.secondaryContainer.tone(t), 4.5) : t.isDark ? 90 : 30,
 | |
|   background: (t) => o.secondaryContainer,
 | |
|   contrastCurve: new m(3, 4.5, 7, 11)
 | |
| });
 | |
| o.tertiary = u.fromPalette({
 | |
|   name: "tertiary",
 | |
|   palette: (t) => t.tertiaryPalette,
 | |
|   tone: (t) => T(t) ? t.isDark ? 90 : 25 : t.isDark ? 80 : 40,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(3, 4.5, 7, 7),
 | |
|   toneDeltaPair: (t) => new _(o.tertiaryContainer, o.tertiary, 10, "nearer", !1)
 | |
| });
 | |
| o.onTertiary = u.fromPalette({
 | |
|   name: "on_tertiary",
 | |
|   palette: (t) => t.tertiaryPalette,
 | |
|   tone: (t) => T(t) ? t.isDark ? 10 : 90 : t.isDark ? 20 : 100,
 | |
|   background: (t) => o.tertiary,
 | |
|   contrastCurve: new m(4.5, 7, 11, 21)
 | |
| });
 | |
| o.tertiaryContainer = u.fromPalette({
 | |
|   name: "tertiary_container",
 | |
|   palette: (t) => t.tertiaryPalette,
 | |
|   tone: (t) => {
 | |
|     if (T(t))
 | |
|       return t.isDark ? 60 : 49;
 | |
|     if (!W(t))
 | |
|       return t.isDark ? 30 : 90;
 | |
|     const e = t.tertiaryPalette.getHct(t.sourceColorHct.tone);
 | |
|     return it.fixIfDisliked(e).tone;
 | |
|   },
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.tertiaryContainer, o.tertiary, 10, "nearer", !1)
 | |
| });
 | |
| o.onTertiaryContainer = u.fromPalette({
 | |
|   name: "on_tertiary_container",
 | |
|   palette: (t) => t.tertiaryPalette,
 | |
|   tone: (t) => T(t) ? t.isDark ? 0 : 100 : W(t) ? u.foregroundTone(o.tertiaryContainer.tone(t), 4.5) : t.isDark ? 90 : 30,
 | |
|   background: (t) => o.tertiaryContainer,
 | |
|   contrastCurve: new m(3, 4.5, 7, 11)
 | |
| });
 | |
| o.error = u.fromPalette({
 | |
|   name: "error",
 | |
|   palette: (t) => t.errorPalette,
 | |
|   tone: (t) => t.isDark ? 80 : 40,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(3, 4.5, 7, 7),
 | |
|   toneDeltaPair: (t) => new _(o.errorContainer, o.error, 10, "nearer", !1)
 | |
| });
 | |
| o.onError = u.fromPalette({
 | |
|   name: "on_error",
 | |
|   palette: (t) => t.errorPalette,
 | |
|   tone: (t) => t.isDark ? 20 : 100,
 | |
|   background: (t) => o.error,
 | |
|   contrastCurve: new m(4.5, 7, 11, 21)
 | |
| });
 | |
| o.errorContainer = u.fromPalette({
 | |
|   name: "error_container",
 | |
|   palette: (t) => t.errorPalette,
 | |
|   tone: (t) => t.isDark ? 30 : 90,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.errorContainer, o.error, 10, "nearer", !1)
 | |
| });
 | |
| o.onErrorContainer = u.fromPalette({
 | |
|   name: "on_error_container",
 | |
|   palette: (t) => t.errorPalette,
 | |
|   tone: (t) => T(t) ? t.isDark ? 90 : 10 : t.isDark ? 90 : 30,
 | |
|   background: (t) => o.errorContainer,
 | |
|   contrastCurve: new m(3, 4.5, 7, 11)
 | |
| });
 | |
| o.primaryFixed = u.fromPalette({
 | |
|   name: "primary_fixed",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => T(t) ? 40 : 90,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.primaryFixed, o.primaryFixedDim, 10, "lighter", !0)
 | |
| });
 | |
| o.primaryFixedDim = u.fromPalette({
 | |
|   name: "primary_fixed_dim",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => T(t) ? 30 : 80,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.primaryFixed, o.primaryFixedDim, 10, "lighter", !0)
 | |
| });
 | |
| o.onPrimaryFixed = u.fromPalette({
 | |
|   name: "on_primary_fixed",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => T(t) ? 100 : 10,
 | |
|   background: (t) => o.primaryFixedDim,
 | |
|   secondBackground: (t) => o.primaryFixed,
 | |
|   contrastCurve: new m(4.5, 7, 11, 21)
 | |
| });
 | |
| o.onPrimaryFixedVariant = u.fromPalette({
 | |
|   name: "on_primary_fixed_variant",
 | |
|   palette: (t) => t.primaryPalette,
 | |
|   tone: (t) => T(t) ? 90 : 30,
 | |
|   background: (t) => o.primaryFixedDim,
 | |
|   secondBackground: (t) => o.primaryFixed,
 | |
|   contrastCurve: new m(3, 4.5, 7, 11)
 | |
| });
 | |
| o.secondaryFixed = u.fromPalette({
 | |
|   name: "secondary_fixed",
 | |
|   palette: (t) => t.secondaryPalette,
 | |
|   tone: (t) => T(t) ? 80 : 90,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.secondaryFixed, o.secondaryFixedDim, 10, "lighter", !0)
 | |
| });
 | |
| o.secondaryFixedDim = u.fromPalette({
 | |
|   name: "secondary_fixed_dim",
 | |
|   palette: (t) => t.secondaryPalette,
 | |
|   tone: (t) => T(t) ? 70 : 80,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.secondaryFixed, o.secondaryFixedDim, 10, "lighter", !0)
 | |
| });
 | |
| o.onSecondaryFixed = u.fromPalette({
 | |
|   name: "on_secondary_fixed",
 | |
|   palette: (t) => t.secondaryPalette,
 | |
|   tone: (t) => 10,
 | |
|   background: (t) => o.secondaryFixedDim,
 | |
|   secondBackground: (t) => o.secondaryFixed,
 | |
|   contrastCurve: new m(4.5, 7, 11, 21)
 | |
| });
 | |
| o.onSecondaryFixedVariant = u.fromPalette({
 | |
|   name: "on_secondary_fixed_variant",
 | |
|   palette: (t) => t.secondaryPalette,
 | |
|   tone: (t) => T(t) ? 25 : 30,
 | |
|   background: (t) => o.secondaryFixedDim,
 | |
|   secondBackground: (t) => o.secondaryFixed,
 | |
|   contrastCurve: new m(3, 4.5, 7, 11)
 | |
| });
 | |
| o.tertiaryFixed = u.fromPalette({
 | |
|   name: "tertiary_fixed",
 | |
|   palette: (t) => t.tertiaryPalette,
 | |
|   tone: (t) => T(t) ? 40 : 90,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.tertiaryFixed, o.tertiaryFixedDim, 10, "lighter", !0)
 | |
| });
 | |
| o.tertiaryFixedDim = u.fromPalette({
 | |
|   name: "tertiary_fixed_dim",
 | |
|   palette: (t) => t.tertiaryPalette,
 | |
|   tone: (t) => T(t) ? 30 : 80,
 | |
|   isBackground: !0,
 | |
|   background: (t) => o.highestSurface(t),
 | |
|   contrastCurve: new m(1, 1, 3, 4.5),
 | |
|   toneDeltaPair: (t) => new _(o.tertiaryFixed, o.tertiaryFixedDim, 10, "lighter", !0)
 | |
| });
 | |
| o.onTertiaryFixed = u.fromPalette({
 | |
|   name: "on_tertiary_fixed",
 | |
|   palette: (t) => t.tertiaryPalette,
 | |
|   tone: (t) => T(t) ? 100 : 10,
 | |
|   background: (t) => o.tertiaryFixedDim,
 | |
|   secondBackground: (t) => o.tertiaryFixed,
 | |
|   contrastCurve: new m(4.5, 7, 11, 21)
 | |
| });
 | |
| o.onTertiaryFixedVariant = u.fromPalette({
 | |
|   name: "on_tertiary_fixed_variant",
 | |
|   palette: (t) => t.tertiaryPalette,
 | |
|   tone: (t) => T(t) ? 90 : 30,
 | |
|   background: (t) => o.tertiaryFixedDim,
 | |
|   secondBackground: (t) => o.tertiaryFixed,
 | |
|   contrastCurve: new m(3, 4.5, 7, 11)
 | |
| });
 | |
| /**
 | |
|  * @license
 | |
|  * Copyright 2021 Google LLC
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| function Et(t) {
 | |
|   const e = gt(t), r = pt(t), a = Pt(t), n = [e.toString(16), r.toString(16), a.toString(16)];
 | |
|   for (const [s, c] of n.entries())
 | |
|     c.length === 1 && (n[s] = "0" + c);
 | |
|   return "#" + n.join("");
 | |
| }
 | |
| function Nt(t) {
 | |
|   t = t.replace("#", "");
 | |
|   const e = t.length === 3, r = t.length === 6, a = t.length === 8;
 | |
|   if (!e && !r && !a)
 | |
|     throw new Error("unexpected hex " + t);
 | |
|   let n = 0, s = 0, c = 0;
 | |
|   return e ? (n = U(t.slice(0, 1).repeat(2)), s = U(t.slice(1, 2).repeat(2)), c = U(t.slice(2, 3).repeat(2))) : r ? (n = U(t.slice(0, 2)), s = U(t.slice(2, 4)), c = U(t.slice(4, 6))) : a && (n = U(t.slice(2, 4)), s = U(t.slice(4, 6)), c = U(t.slice(6, 8))), (255 << 24 | (n & 255) << 16 | (s & 255) << 8 | c & 255) >>> 0;
 | |
| }
 | |
| function U(t) {
 | |
|   return parseInt(t, 16);
 | |
| }
 | |
| export {
 | |
|   E as C,
 | |
|   J as H,
 | |
|   Nt as a,
 | |
|   _t as d,
 | |
|   Et as h,
 | |
|   dt as l,
 | |
|   Ot as r,
 | |
|   mt as s
 | |
| };
 |