@gradient-ui/gradient-engine 0.6.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +0 -6
  2. package/dist/animation.cjs +13 -13
  3. package/dist/animation.mjs +36 -36
  4. package/dist/core.cjs +1 -1
  5. package/dist/core.mjs +17 -17
  6. package/dist/css-B3xGfmW1.js +17 -0
  7. package/dist/css-CREh0Awz.cjs +1 -0
  8. package/dist/design-tokens.cjs +1 -1
  9. package/dist/design-tokens.mjs +5 -5
  10. package/dist/designTokens-Bw-HZ1f1.js +116 -0
  11. package/dist/designTokens-DsIk5RSi.cjs +1 -0
  12. package/dist/effects.cjs +67 -67
  13. package/dist/effects.mjs +153 -153
  14. package/dist/formatters.cjs +1 -1
  15. package/dist/formatters.mjs +33 -33
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.mjs +63 -63
  18. package/dist/material.cjs +8 -8
  19. package/dist/material.mjs +170 -170
  20. package/dist/presets-DA-6KYJh.cjs +316 -0
  21. package/dist/presets-Du6aTLtD.js +4025 -0
  22. package/dist/svg-B2CaHCLv.js +118 -0
  23. package/dist/svg-BtMrj3fP.cjs +32 -0
  24. package/dist/types/animation/css.d.ts +2 -2
  25. package/dist/types/animation/index.d.ts +1 -1
  26. package/dist/types/colorSystem.d.ts +3 -3
  27. package/dist/types/core.d.ts +7 -7
  28. package/dist/types/designTokens.d.ts +4 -4
  29. package/dist/types/effects/index.d.ts +2 -2
  30. package/dist/types/effects/morph.d.ts +1 -1
  31. package/dist/types/effects/shadow.d.ts +1 -1
  32. package/dist/types/formatters/canvas.d.ts +1 -1
  33. package/dist/types/formatters/css.d.ts +1 -1
  34. package/dist/types/formatters/index.d.ts +3 -3
  35. package/dist/types/formatters/svg.d.ts +1 -1
  36. package/dist/types/index.d.ts +11 -11
  37. package/dist/types/material.d.ts +1 -1
  38. package/dist/types/model.d.ts +3 -3
  39. package/dist/types/palette.d.ts +1 -1
  40. package/dist/types/presets.d.ts +1 -1
  41. package/dist/types/recipes.d.ts +12 -12
  42. package/dist/types/tokens.d.ts +3 -3
  43. package/dist/types/types.d.ts +1 -1
  44. package/dist/types/utils.d.ts +1 -1
  45. package/dist/{types-BFr1fN-7.js → types-B0eCazk8.js} +4 -4
  46. package/dist/types-BFkUlDkW.cjs +1 -0
  47. package/dist/types-cjs/animation/css.d.cts +12 -0
  48. package/dist/types-cjs/animation/index.d.cts +1 -0
  49. package/dist/types-cjs/color.d.cts +11 -0
  50. package/dist/types-cjs/colorMath.d.cts +3 -0
  51. package/dist/types-cjs/colorSeeds.d.cts +22 -0
  52. package/dist/types-cjs/colorSystem.d.cts +20 -0
  53. package/dist/types-cjs/constants.d.cts +3 -0
  54. package/dist/types-cjs/core.d.cts +9 -0
  55. package/dist/types-cjs/designTokens.d.cts +24 -0
  56. package/dist/types-cjs/effects/index.d.cts +2 -0
  57. package/dist/types-cjs/effects/morph.d.cts +8 -0
  58. package/dist/types-cjs/effects/shadow.d.cts +3 -0
  59. package/dist/types-cjs/formatters/canvas.d.cts +2 -0
  60. package/dist/types-cjs/formatters/css.d.cts +3 -0
  61. package/dist/types-cjs/formatters/index.d.cts +3 -0
  62. package/dist/types-cjs/formatters/svg.d.cts +5 -0
  63. package/dist/types-cjs/index.d.cts +11 -0
  64. package/dist/types-cjs/material.d.cts +1 -0
  65. package/dist/types-cjs/model.d.cts +5 -0
  66. package/dist/types-cjs/package.json +3 -0
  67. package/dist/types-cjs/palette.d.cts +13 -0
  68. package/dist/types-cjs/presets.d.cts +239 -0
  69. package/dist/types-cjs/recipes.d.cts +14 -0
  70. package/dist/types-cjs/scheme.d.cts +3 -0
  71. package/dist/types-cjs/tokens.d.cts +107 -0
  72. package/dist/types-cjs/types.d.cts +127 -0
  73. package/dist/types-cjs/utils.d.cts +10 -0
  74. package/dist/utils-Bry9BTmj.cjs +1 -0
  75. package/dist/utils-VaqPefmS.js +76 -0
  76. package/package.json +59 -23
  77. package/dist/css-BVHXLMRl.cjs +0 -1
  78. package/dist/css-DVaTTIqS.js +0 -17
  79. package/dist/designTokens-BnzZfRES.js +0 -116
  80. package/dist/designTokens-C1WdzS3v.cjs +0 -1
  81. package/dist/presets-BBLdqUE4.cjs +0 -316
  82. package/dist/presets-DYXLx_nN.js +0 -4025
  83. package/dist/svg-dGtLYnIJ.cjs +0 -32
  84. package/dist/svg-hZus3ztj.js +0 -118
  85. package/dist/types-BMLEvdee.cjs +0 -1
  86. package/dist/utils-BzSNCfat.js +0 -76
  87. package/dist/utils-D83DMCMa.cjs +0 -1
@@ -0,0 +1,4025 @@
1
+ import { c as colorToHex, i as createStop, d as DEFAULT_GRADIENT_SIZE, e as DEFAULT_GRADIENT_POSITION, D as DEFAULT_GRADIENT_DIRECTION } from "./utils-VaqPefmS.js";
2
+ /**
3
+ * @license
4
+ * Copyright 2021 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ function signum(num) {
19
+ return num < 0 ? -1 : num === 0 ? 0 : 1;
20
+ }
21
+ function lerp(start, stop, amount) {
22
+ return (1 - amount) * start + amount * stop;
23
+ }
24
+ function clampInt(min, max, input) {
25
+ return input < min ? min : input > max ? max : input;
26
+ }
27
+ function clampDouble(min, max, input) {
28
+ return input < min ? min : input > max ? max : input;
29
+ }
30
+ function sanitizeDegreesDouble(degrees) {
31
+ return degrees = degrees % 360, degrees < 0 && (degrees = degrees + 360), degrees;
32
+ }
33
+ function rotationDirection(from, to) {
34
+ return sanitizeDegreesDouble(to - from) <= 180 ? 1 : -1;
35
+ }
36
+ function differenceDegrees(a, b) {
37
+ return 180 - Math.abs(Math.abs(a - b) - 180);
38
+ }
39
+ function matrixMultiply(row, matrix) {
40
+ const a = row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2], b = row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2], c = row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];
41
+ return [a, b, c];
42
+ }
43
+ /**
44
+ * @license
45
+ * Copyright 2021 Google LLC
46
+ *
47
+ * Licensed under the Apache License, Version 2.0 (the "License");
48
+ * you may not use this file except in compliance with the License.
49
+ * You may obtain a copy of the License at
50
+ *
51
+ * http://www.apache.org/licenses/LICENSE-2.0
52
+ *
53
+ * Unless required by applicable law or agreed to in writing, software
54
+ * distributed under the License is distributed on an "AS IS" BASIS,
55
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
56
+ * See the License for the specific language governing permissions and
57
+ * limitations under the License.
58
+ */
59
+ const SRGB_TO_XYZ = [
60
+ [0.41233895, 0.35762064, 0.18051042],
61
+ [0.2126, 0.7152, 0.0722],
62
+ [0.01932141, 0.11916382, 0.95034478]
63
+ ], XYZ_TO_SRGB = [
64
+ [
65
+ 3.2413774792388685,
66
+ -1.5376652402851851,
67
+ -0.49885366846268053
68
+ ],
69
+ [
70
+ -0.9691452513005321,
71
+ 1.8758853451067872,
72
+ 0.04156585616912061
73
+ ],
74
+ [
75
+ 0.05562093689691305,
76
+ -0.20395524564742123,
77
+ 1.0571799111220335
78
+ ]
79
+ ], WHITE_POINT_D65 = [95.047, 100, 108.883];
80
+ function argbFromRgb(red, green, blue) {
81
+ return (255 << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255) >>> 0;
82
+ }
83
+ function argbFromLinrgb(linrgb) {
84
+ const r = delinearized(linrgb[0]), g = delinearized(linrgb[1]), b = delinearized(linrgb[2]);
85
+ return argbFromRgb(r, g, b);
86
+ }
87
+ function redFromArgb(argb) {
88
+ return argb >> 16 & 255;
89
+ }
90
+ function greenFromArgb(argb) {
91
+ return argb >> 8 & 255;
92
+ }
93
+ function blueFromArgb(argb) {
94
+ return argb & 255;
95
+ }
96
+ function argbFromXyz(x, y, z) {
97
+ const matrix = XYZ_TO_SRGB, linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z, linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z, linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z, r = delinearized(linearR), g = delinearized(linearG), b = delinearized(linearB);
98
+ return argbFromRgb(r, g, b);
99
+ }
100
+ function xyzFromArgb(argb) {
101
+ const r = linearized(redFromArgb(argb)), g = linearized(greenFromArgb(argb)), b = linearized(blueFromArgb(argb));
102
+ return matrixMultiply([r, g, b], SRGB_TO_XYZ);
103
+ }
104
+ function argbFromLstar(lstar) {
105
+ const y = yFromLstar(lstar), component = delinearized(y);
106
+ return argbFromRgb(component, component, component);
107
+ }
108
+ function lstarFromArgb(argb) {
109
+ const y = xyzFromArgb(argb)[1];
110
+ return 116 * labF(y / 100) - 16;
111
+ }
112
+ function yFromLstar(lstar) {
113
+ return 100 * labInvf((lstar + 16) / 116);
114
+ }
115
+ function lstarFromY(y) {
116
+ return labF(y / 100) * 116 - 16;
117
+ }
118
+ function linearized(rgbComponent) {
119
+ const normalized = rgbComponent / 255;
120
+ return normalized <= 0.040449936 ? normalized / 12.92 * 100 : Math.pow((normalized + 0.055) / 1.055, 2.4) * 100;
121
+ }
122
+ function delinearized(rgbComponent) {
123
+ const normalized = rgbComponent / 100;
124
+ let delinearized2 = 0;
125
+ return normalized <= 31308e-7 ? delinearized2 = normalized * 12.92 : delinearized2 = 1.055 * Math.pow(normalized, 1 / 2.4) - 0.055, clampInt(0, 255, Math.round(delinearized2 * 255));
126
+ }
127
+ function whitePointD65() {
128
+ return WHITE_POINT_D65;
129
+ }
130
+ function labF(t) {
131
+ const e = 0.008856451679035631, kappa = 24389 / 27;
132
+ return t > e ? Math.pow(t, 1 / 3) : (kappa * t + 16) / 116;
133
+ }
134
+ function labInvf(ft) {
135
+ const e = 0.008856451679035631, kappa = 24389 / 27, ft3 = ft * ft * ft;
136
+ return ft3 > e ? ft3 : (116 * ft - 16) / kappa;
137
+ }
138
+ /**
139
+ * @license
140
+ * Copyright 2021 Google LLC
141
+ *
142
+ * Licensed under the Apache License, Version 2.0 (the "License");
143
+ * you may not use this file except in compliance with the License.
144
+ * You may obtain a copy of the License at
145
+ *
146
+ * http://www.apache.org/licenses/LICENSE-2.0
147
+ *
148
+ * Unless required by applicable law or agreed to in writing, software
149
+ * distributed under the License is distributed on an "AS IS" BASIS,
150
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
151
+ * See the License for the specific language governing permissions and
152
+ * limitations under the License.
153
+ */
154
+ class ViewingConditions {
155
+ /**
156
+ * Create ViewingConditions from a simple, physically relevant, set of
157
+ * parameters.
158
+ *
159
+ * @param whitePoint White point, measured in the XYZ color space.
160
+ * default = D65, or sunny day afternoon
161
+ * @param adaptingLuminance The luminance of the adapting field. Informally,
162
+ * how bright it is in the room where the color is viewed. Can be
163
+ * calculated from lux by multiplying lux by 0.0586. default = 11.72,
164
+ * or 200 lux.
165
+ * @param backgroundLstar The lightness of the area surrounding the color.
166
+ * measured by L* in L*a*b*. default = 50.0
167
+ * @param surround A general description of the lighting surrounding the
168
+ * color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a
169
+ * dimly light room, like watching TV at home at night. 2.0 means there
170
+ * is no difference between the lighting on the color and around it.
171
+ * default = 2.0
172
+ * @param discountingIlluminant Whether the eye accounts for the tint of the
173
+ * ambient lighting, such as knowing an apple is still red in green light.
174
+ * default = false, the eye does not perform this process on
175
+ * self-luminous objects like displays.
176
+ */
177
+ static make(whitePoint = whitePointD65(), adaptingLuminance = 200 / Math.PI * yFromLstar(50) / 100, backgroundLstar = 50, surround = 2, discountingIlluminant = !1) {
178
+ const xyz = whitePoint, rW = xyz[0] * 0.401288 + xyz[1] * 0.650173 + xyz[2] * -0.051461, gW = xyz[0] * -0.250268 + xyz[1] * 1.204414 + xyz[2] * 0.045854, bW = xyz[0] * -2079e-6 + xyz[1] * 0.048952 + xyz[2] * 0.953127, f = 0.8 + surround / 10, c = f >= 0.9 ? lerp(0.59, 0.69, (f - 0.9) * 10) : lerp(0.525, 0.59, (f - 0.8) * 10);
179
+ let d = discountingIlluminant ? 1 : f * (1 - 1 / 3.6 * Math.exp((-adaptingLuminance - 42) / 92));
180
+ d = d > 1 ? 1 : d < 0 ? 0 : d;
181
+ const nc = f, rgbD = [
182
+ d * (100 / rW) + 1 - d,
183
+ d * (100 / gW) + 1 - d,
184
+ d * (100 / bW) + 1 - d
185
+ ], k = 1 / (5 * adaptingLuminance + 1), k4 = k * k * k * k, k4F = 1 - k4, fl = k4 * adaptingLuminance + 0.1 * k4F * k4F * Math.cbrt(5 * adaptingLuminance), n = yFromLstar(backgroundLstar) / whitePoint[1], z = 1.48 + Math.sqrt(n), nbb = 0.725 / Math.pow(n, 0.2), ncb = nbb, rgbAFactors = [
186
+ Math.pow(fl * rgbD[0] * rW / 100, 0.42),
187
+ Math.pow(fl * rgbD[1] * gW / 100, 0.42),
188
+ Math.pow(fl * rgbD[2] * bW / 100, 0.42)
189
+ ], rgbA = [
190
+ 400 * rgbAFactors[0] / (rgbAFactors[0] + 27.13),
191
+ 400 * rgbAFactors[1] / (rgbAFactors[1] + 27.13),
192
+ 400 * rgbAFactors[2] / (rgbAFactors[2] + 27.13)
193
+ ], aw = (2 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]) * nbb;
194
+ return new ViewingConditions(n, aw, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, 0.25), z);
195
+ }
196
+ /**
197
+ * Parameters are intermediate values of the CAM16 conversion process. Their
198
+ * names are shorthand for technical color science terminology, this class
199
+ * would not benefit from documenting them individually. A brief overview
200
+ * is available in the CAM16 specification, and a complete overview requires
201
+ * a color science textbook, such as Fairchild's Color Appearance Models.
202
+ */
203
+ constructor(n, aw, nbb, ncb, c, nc, rgbD, fl, fLRoot, z) {
204
+ this.n = n, this.aw = aw, this.nbb = nbb, this.ncb = ncb, this.c = c, this.nc = nc, this.rgbD = rgbD, this.fl = fl, this.fLRoot = fLRoot, this.z = z;
205
+ }
206
+ }
207
+ ViewingConditions.DEFAULT = ViewingConditions.make();
208
+ /**
209
+ * @license
210
+ * Copyright 2021 Google LLC
211
+ *
212
+ * Licensed under the Apache License, Version 2.0 (the "License");
213
+ * you may not use this file except in compliance with the License.
214
+ * You may obtain a copy of the License at
215
+ *
216
+ * http://www.apache.org/licenses/LICENSE-2.0
217
+ *
218
+ * Unless required by applicable law or agreed to in writing, software
219
+ * distributed under the License is distributed on an "AS IS" BASIS,
220
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
221
+ * See the License for the specific language governing permissions and
222
+ * limitations under the License.
223
+ */
224
+ class Cam16 {
225
+ /**
226
+ * All of the CAM16 dimensions can be calculated from 3 of the dimensions, in
227
+ * the following combinations:
228
+ * - {j or q} and {c, m, or s} and hue
229
+ * - jstar, astar, bstar
230
+ * Prefer using a static method that constructs from 3 of those dimensions.
231
+ * This constructor is intended for those methods to use to return all
232
+ * possible dimensions.
233
+ *
234
+ * @param hue
235
+ * @param chroma informally, colorfulness / color intensity. like saturation
236
+ * in HSL, except perceptually accurate.
237
+ * @param j lightness
238
+ * @param q brightness; ratio of lightness to white point's lightness
239
+ * @param m colorfulness
240
+ * @param s saturation; ratio of chroma to white point's chroma
241
+ * @param jstar CAM16-UCS J coordinate
242
+ * @param astar CAM16-UCS a coordinate
243
+ * @param bstar CAM16-UCS b coordinate
244
+ */
245
+ constructor(hue, chroma, j, q, m, s, jstar, astar, bstar) {
246
+ this.hue = hue, this.chroma = chroma, this.j = j, this.q = q, this.m = m, this.s = s, this.jstar = jstar, this.astar = astar, this.bstar = bstar;
247
+ }
248
+ /**
249
+ * CAM16 instances also have coordinates in the CAM16-UCS space, called J*,
250
+ * a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
251
+ * specification, and is used to measure distances between colors.
252
+ */
253
+ distance(other) {
254
+ const dJ = this.jstar - other.jstar, dA = this.astar - other.astar, dB = this.bstar - other.bstar, dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);
255
+ return 1.41 * Math.pow(dEPrime, 0.63);
256
+ }
257
+ /**
258
+ * @param argb ARGB representation of a color.
259
+ * @return CAM16 color, assuming the color was viewed in default viewing
260
+ * conditions.
261
+ */
262
+ static fromInt(argb) {
263
+ return Cam16.fromIntInViewingConditions(argb, ViewingConditions.DEFAULT);
264
+ }
265
+ /**
266
+ * @param argb ARGB representation of a color.
267
+ * @param viewingConditions Information about the environment where the color
268
+ * was observed.
269
+ * @return CAM16 color.
270
+ */
271
+ static fromIntInViewingConditions(argb, viewingConditions) {
272
+ const red = (argb & 16711680) >> 16, green = (argb & 65280) >> 8, blue = argb & 255, redL = linearized(red), greenL = linearized(green), blueL = linearized(blue), x = 0.41233895 * redL + 0.35762064 * greenL + 0.18051042 * blueL, y = 0.2126 * redL + 0.7152 * greenL + 0.0722 * blueL, z = 0.01932141 * redL + 0.11916382 * greenL + 0.95034478 * blueL, rC = 0.401288 * x + 0.650173 * y - 0.051461 * z, gC = -0.250268 * x + 1.204414 * y + 0.045854 * z, bC = -2079e-6 * x + 0.048952 * y + 0.953127 * z, rD = viewingConditions.rgbD[0] * rC, gD = viewingConditions.rgbD[1] * gC, bD = viewingConditions.rgbD[2] * bC, rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, 0.42), gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, 0.42), bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, 0.42), rA = signum(rD) * 400 * rAF / (rAF + 27.13), gA = signum(gD) * 400 * gAF / (gAF + 27.13), bA = signum(bD) * 400 * bAF / (bAF + 27.13), a = (11 * rA + -12 * gA + bA) / 11, b = (rA + gA - 2 * bA) / 9, u = (20 * rA + 20 * gA + 21 * bA) / 20, p2 = (40 * rA + 20 * gA + bA) / 20, atanDegrees = Math.atan2(b, a) * 180 / Math.PI, hue = sanitizeDegreesDouble(atanDegrees), hueRadians = hue * Math.PI / 180, ac = p2 * viewingConditions.nbb, j = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z), q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot, huePrime = hue < 20.14 ? hue + 360 : hue, eHue = 0.25 * (Math.cos(huePrime * Math.PI / 180 + 2) + 3.8), t = 5e4 / 13 * eHue * viewingConditions.nc * viewingConditions.ncb * Math.sqrt(a * a + b * b) / (u + 0.305), alpha = Math.pow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), c = alpha * Math.sqrt(j / 100), m = c * viewingConditions.fLRoot, s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)), jstar = (1 + 100 * 7e-3) * j / (1 + 7e-3 * j), mstar = 1 / 0.0228 * Math.log(1 + 0.0228 * m), astar = mstar * Math.cos(hueRadians), bstar = mstar * Math.sin(hueRadians);
273
+ return new Cam16(hue, c, j, q, m, s, jstar, astar, bstar);
274
+ }
275
+ /**
276
+ * @param j CAM16 lightness
277
+ * @param c CAM16 chroma
278
+ * @param h CAM16 hue
279
+ */
280
+ static fromJch(j, c, h) {
281
+ return Cam16.fromJchInViewingConditions(j, c, h, ViewingConditions.DEFAULT);
282
+ }
283
+ /**
284
+ * @param j CAM16 lightness
285
+ * @param c CAM16 chroma
286
+ * @param h CAM16 hue
287
+ * @param viewingConditions Information about the environment where the color
288
+ * was observed.
289
+ */
290
+ static fromJchInViewingConditions(j, c, h, viewingConditions) {
291
+ const q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot, m = c * viewingConditions.fLRoot, alpha = c / Math.sqrt(j / 100), s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)), hueRadians = h * Math.PI / 180, jstar = (1 + 100 * 7e-3) * j / (1 + 7e-3 * j), mstar = 1 / 0.0228 * Math.log(1 + 0.0228 * m), astar = mstar * Math.cos(hueRadians), bstar = mstar * Math.sin(hueRadians);
292
+ return new Cam16(h, c, j, q, m, s, jstar, astar, bstar);
293
+ }
294
+ /**
295
+ * @param jstar CAM16-UCS lightness.
296
+ * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
297
+ * coordinate on the Y axis.
298
+ * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
299
+ * coordinate on the X axis.
300
+ */
301
+ static fromUcs(jstar, astar, bstar) {
302
+ return Cam16.fromUcsInViewingConditions(jstar, astar, bstar, ViewingConditions.DEFAULT);
303
+ }
304
+ /**
305
+ * @param jstar CAM16-UCS lightness.
306
+ * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
307
+ * coordinate on the Y axis.
308
+ * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
309
+ * coordinate on the X axis.
310
+ * @param viewingConditions Information about the environment where the color
311
+ * was observed.
312
+ */
313
+ static fromUcsInViewingConditions(jstar, astar, bstar, viewingConditions) {
314
+ const a = astar, b = bstar, m = Math.sqrt(a * a + b * b), c = (Math.exp(m * 0.0228) - 1) / 0.0228 / viewingConditions.fLRoot;
315
+ let h = Math.atan2(b, a) * (180 / Math.PI);
316
+ h < 0 && (h += 360);
317
+ const j = jstar / (1 - (jstar - 100) * 7e-3);
318
+ return Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);
319
+ }
320
+ /**
321
+ * @return ARGB representation of color, assuming the color was viewed in
322
+ * default viewing conditions, which are near-identical to the default
323
+ * viewing conditions for sRGB.
324
+ */
325
+ toInt() {
326
+ return this.viewed(ViewingConditions.DEFAULT);
327
+ }
328
+ /**
329
+ * @param viewingConditions Information about the environment where the color
330
+ * will be viewed.
331
+ * @return ARGB representation of color
332
+ */
333
+ viewed(viewingConditions) {
334
+ const alpha = this.chroma === 0 || this.j === 0 ? 0 : this.chroma / Math.sqrt(this.j / 100), t = Math.pow(alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), 1 / 0.9), hRad = this.hue * Math.PI / 180, eHue = 0.25 * (Math.cos(hRad + 2) + 3.8), ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z), p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb, p2 = ac / viewingConditions.nbb, hSin = Math.sin(hRad), hCos = Math.cos(hRad), gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin), a = gamma * hCos, b = gamma * hSin, rA = (460 * p2 + 451 * a + 288 * b) / 1403, gA = (460 * p2 - 891 * a - 261 * b) / 1403, bA = (460 * p2 - 220 * a - 6300 * b) / 1403, rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA))), rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / 0.42), gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA))), gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / 0.42), bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA))), bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / 0.42), rF = rC / viewingConditions.rgbD[0], gF = gC / viewingConditions.rgbD[1], bF = bC / viewingConditions.rgbD[2], x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF, y = 0.38752654 * rF + 0.62144744 * gF - 897398e-8 * bF, z = -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF;
335
+ return argbFromXyz(x, y, z);
336
+ }
337
+ /// Given color expressed in XYZ and viewed in [viewingConditions], convert to
338
+ /// CAM16.
339
+ static fromXyzInViewingConditions(x, y, z, viewingConditions) {
340
+ const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z, gC = -0.250268 * x + 1.204414 * y + 0.045854 * z, bC = -2079e-6 * x + 0.048952 * y + 0.953127 * z, rD = viewingConditions.rgbD[0] * rC, gD = viewingConditions.rgbD[1] * gC, bD = viewingConditions.rgbD[2] * bC, rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, 0.42), gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, 0.42), bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, 0.42), rA = signum(rD) * 400 * rAF / (rAF + 27.13), gA = signum(gD) * 400 * gAF / (gAF + 27.13), bA = signum(bD) * 400 * bAF / (bAF + 27.13), a = (11 * rA + -12 * gA + bA) / 11, b = (rA + gA - 2 * bA) / 9, u = (20 * rA + 20 * gA + 21 * bA) / 20, p2 = (40 * rA + 20 * gA + bA) / 20, atanDegrees = Math.atan2(b, a) * 180 / Math.PI, hue = atanDegrees < 0 ? atanDegrees + 360 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees, hueRadians = hue * Math.PI / 180, ac = p2 * viewingConditions.nbb, J = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z), Q = 4 / viewingConditions.c * Math.sqrt(J / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot, huePrime = hue < 20.14 ? hue + 360 : hue, eHue = 1 / 4 * (Math.cos(huePrime * Math.PI / 180 + 2) + 3.8), t = 5e4 / 13 * eHue * viewingConditions.nc * viewingConditions.ncb * Math.sqrt(a * a + b * b) / (u + 0.305), alpha = Math.pow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), C = alpha * Math.sqrt(J / 100), M = C * viewingConditions.fLRoot, s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)), jstar = (1 + 100 * 7e-3) * J / (1 + 7e-3 * J), mstar = Math.log(1 + 0.0228 * M) / 0.0228, astar = mstar * Math.cos(hueRadians), bstar = mstar * Math.sin(hueRadians);
341
+ return new Cam16(hue, C, J, Q, M, s, jstar, astar, bstar);
342
+ }
343
+ /// XYZ representation of CAM16 seen in [viewingConditions].
344
+ xyzInViewingConditions(viewingConditions) {
345
+ const alpha = this.chroma === 0 || this.j === 0 ? 0 : this.chroma / Math.sqrt(this.j / 100), t = Math.pow(alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), 1 / 0.9), hRad = this.hue * Math.PI / 180, eHue = 0.25 * (Math.cos(hRad + 2) + 3.8), ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z), p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb, p2 = ac / viewingConditions.nbb, hSin = Math.sin(hRad), hCos = Math.cos(hRad), gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin), a = gamma * hCos, b = gamma * hSin, rA = (460 * p2 + 451 * a + 288 * b) / 1403, gA = (460 * p2 - 891 * a - 261 * b) / 1403, bA = (460 * p2 - 220 * a - 6300 * b) / 1403, rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA))), rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / 0.42), gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA))), gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / 0.42), bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA))), bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / 0.42), rF = rC / viewingConditions.rgbD[0], gF = gC / viewingConditions.rgbD[1], bF = bC / viewingConditions.rgbD[2], x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF, y = 0.38752654 * rF + 0.62144744 * gF - 897398e-8 * bF, z = -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF;
346
+ return [x, y, z];
347
+ }
348
+ }
349
+ /**
350
+ * @license
351
+ * Copyright 2021 Google LLC
352
+ *
353
+ * Licensed under the Apache License, Version 2.0 (the "License");
354
+ * you may not use this file except in compliance with the License.
355
+ * You may obtain a copy of the License at
356
+ *
357
+ * http://www.apache.org/licenses/LICENSE-2.0
358
+ *
359
+ * Unless required by applicable law or agreed to in writing, software
360
+ * distributed under the License is distributed on an "AS IS" BASIS,
361
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
362
+ * See the License for the specific language governing permissions and
363
+ * limitations under the License.
364
+ */
365
+ class HctSolver {
366
+ /**
367
+ * Sanitizes a small enough angle in radians.
368
+ *
369
+ * @param angle An angle in radians; must not deviate too much
370
+ * from 0.
371
+ * @return A coterminal angle between 0 and 2pi.
372
+ */
373
+ static sanitizeRadians(angle) {
374
+ return (angle + Math.PI * 8) % (Math.PI * 2);
375
+ }
376
+ /**
377
+ * Delinearizes an RGB component, returning a floating-point
378
+ * number.
379
+ *
380
+ * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
381
+ * linear R/G/B channel
382
+ * @return 0.0 <= output <= 255.0, color channel converted to
383
+ * regular RGB space
384
+ */
385
+ static trueDelinearized(rgbComponent) {
386
+ const normalized = rgbComponent / 100;
387
+ let delinearized2 = 0;
388
+ return normalized <= 31308e-7 ? delinearized2 = normalized * 12.92 : delinearized2 = 1.055 * Math.pow(normalized, 1 / 2.4) - 0.055, delinearized2 * 255;
389
+ }
390
+ static chromaticAdaptation(component) {
391
+ const af = Math.pow(Math.abs(component), 0.42);
392
+ return signum(component) * 400 * af / (af + 27.13);
393
+ }
394
+ /**
395
+ * Returns the hue of a linear RGB color in CAM16.
396
+ *
397
+ * @param linrgb The linear RGB coordinates of a color.
398
+ * @return The hue of the color in CAM16, in radians.
399
+ */
400
+ static hueOf(linrgb) {
401
+ const scaledDiscount = matrixMultiply(linrgb, HctSolver.SCALED_DISCOUNT_FROM_LINRGB), rA = HctSolver.chromaticAdaptation(scaledDiscount[0]), gA = HctSolver.chromaticAdaptation(scaledDiscount[1]), bA = HctSolver.chromaticAdaptation(scaledDiscount[2]), a = (11 * rA + -12 * gA + bA) / 11, b = (rA + gA - 2 * bA) / 9;
402
+ return Math.atan2(b, a);
403
+ }
404
+ static areInCyclicOrder(a, b, c) {
405
+ const deltaAB = HctSolver.sanitizeRadians(b - a), deltaAC = HctSolver.sanitizeRadians(c - a);
406
+ return deltaAB < deltaAC;
407
+ }
408
+ /**
409
+ * Solves the lerp equation.
410
+ *
411
+ * @param source The starting number.
412
+ * @param mid The number in the middle.
413
+ * @param target The ending number.
414
+ * @return A number t such that lerp(source, target, t) = mid.
415
+ */
416
+ static intercept(source, mid, target) {
417
+ return (mid - source) / (target - source);
418
+ }
419
+ static lerpPoint(source, t, target) {
420
+ return [
421
+ source[0] + (target[0] - source[0]) * t,
422
+ source[1] + (target[1] - source[1]) * t,
423
+ source[2] + (target[2] - source[2]) * t
424
+ ];
425
+ }
426
+ /**
427
+ * Intersects a segment with a plane.
428
+ *
429
+ * @param source The coordinates of point A.
430
+ * @param coordinate The R-, G-, or B-coordinate of the plane.
431
+ * @param target The coordinates of point B.
432
+ * @param axis The axis the plane is perpendicular with. (0: R, 1:
433
+ * G, 2: B)
434
+ * @return The intersection point of the segment AB with the plane
435
+ * R=coordinate, G=coordinate, or B=coordinate
436
+ */
437
+ static setCoordinate(source, coordinate, target, axis) {
438
+ const t = HctSolver.intercept(source[axis], coordinate, target[axis]);
439
+ return HctSolver.lerpPoint(source, t, target);
440
+ }
441
+ static isBounded(x) {
442
+ return 0 <= x && x <= 100;
443
+ }
444
+ /**
445
+ * Returns the nth possible vertex of the polygonal intersection.
446
+ *
447
+ * @param y The Y value of the plane.
448
+ * @param n The zero-based index of the point. 0 <= n <= 11.
449
+ * @return The nth possible vertex of the polygonal intersection
450
+ * of the y plane and the RGB cube, in linear RGB coordinates, if
451
+ * it exists. If this possible vertex lies outside of the cube,
452
+ * [-1.0, -1.0, -1.0] is returned.
453
+ */
454
+ static nthVertex(y, n) {
455
+ const kR = HctSolver.Y_FROM_LINRGB[0], kG = HctSolver.Y_FROM_LINRGB[1], kB = HctSolver.Y_FROM_LINRGB[2], coordA = n % 4 <= 1 ? 0 : 100, coordB = n % 2 === 0 ? 0 : 100;
456
+ if (n < 4) {
457
+ const g = coordA, b = coordB, r = (y - g * kG - b * kB) / kR;
458
+ return HctSolver.isBounded(r) ? [r, g, b] : [-1, -1, -1];
459
+ } else if (n < 8) {
460
+ const b = coordA, r = coordB, g = (y - r * kR - b * kB) / kG;
461
+ return HctSolver.isBounded(g) ? [r, g, b] : [-1, -1, -1];
462
+ } else {
463
+ const r = coordA, g = coordB, b = (y - r * kR - g * kG) / kB;
464
+ return HctSolver.isBounded(b) ? [r, g, b] : [-1, -1, -1];
465
+ }
466
+ }
467
+ /**
468
+ * Finds the segment containing the desired color.
469
+ *
470
+ * @param y The Y value of the color.
471
+ * @param targetHue The hue of the color.
472
+ * @return A list of two sets of linear RGB coordinates, each
473
+ * corresponding to an endpoint of the segment containing the
474
+ * desired color.
475
+ */
476
+ static bisectToSegment(y, targetHue) {
477
+ let left = [-1, -1, -1], right = left, leftHue = 0, rightHue = 0, initialized = !1, uncut = !0;
478
+ for (let n = 0; n < 12; n++) {
479
+ const mid = HctSolver.nthVertex(y, n);
480
+ if (mid[0] < 0)
481
+ continue;
482
+ const midHue = HctSolver.hueOf(mid);
483
+ if (!initialized) {
484
+ left = mid, right = mid, leftHue = midHue, rightHue = midHue, initialized = !0;
485
+ continue;
486
+ }
487
+ (uncut || HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) && (uncut = !1, HctSolver.areInCyclicOrder(leftHue, targetHue, midHue) ? (right = mid, rightHue = midHue) : (left = mid, leftHue = midHue));
488
+ }
489
+ return [left, right];
490
+ }
491
+ static midpoint(a, b) {
492
+ return [
493
+ (a[0] + b[0]) / 2,
494
+ (a[1] + b[1]) / 2,
495
+ (a[2] + b[2]) / 2
496
+ ];
497
+ }
498
+ static criticalPlaneBelow(x) {
499
+ return Math.floor(x - 0.5);
500
+ }
501
+ static criticalPlaneAbove(x) {
502
+ return Math.ceil(x - 0.5);
503
+ }
504
+ /**
505
+ * Finds a color with the given Y and hue on the boundary of the
506
+ * cube.
507
+ *
508
+ * @param y The Y value of the color.
509
+ * @param targetHue The hue of the color.
510
+ * @return The desired color, in linear RGB coordinates.
511
+ */
512
+ static bisectToLimit(y, targetHue) {
513
+ const segment = HctSolver.bisectToSegment(y, targetHue);
514
+ let left = segment[0], leftHue = HctSolver.hueOf(left), right = segment[1];
515
+ for (let axis = 0; axis < 3; axis++)
516
+ if (left[axis] !== right[axis]) {
517
+ let lPlane = -1, rPlane = 255;
518
+ left[axis] < right[axis] ? (lPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(left[axis])), rPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(right[axis]))) : (lPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(left[axis])), rPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(right[axis])));
519
+ for (let i = 0; i < 8 && !(Math.abs(rPlane - lPlane) <= 1); i++) {
520
+ const mPlane = Math.floor((lPlane + rPlane) / 2), midPlaneCoordinate = HctSolver.CRITICAL_PLANES[mPlane], mid = HctSolver.setCoordinate(left, midPlaneCoordinate, right, axis), midHue = HctSolver.hueOf(mid);
521
+ HctSolver.areInCyclicOrder(leftHue, targetHue, midHue) ? (right = mid, rPlane = mPlane) : (left = mid, leftHue = midHue, lPlane = mPlane);
522
+ }
523
+ }
524
+ return HctSolver.midpoint(left, right);
525
+ }
526
+ static inverseChromaticAdaptation(adapted) {
527
+ const adaptedAbs = Math.abs(adapted), base = Math.max(0, 27.13 * adaptedAbs / (400 - adaptedAbs));
528
+ return signum(adapted) * Math.pow(base, 1 / 0.42);
529
+ }
530
+ /**
531
+ * Finds a color with the given hue, chroma, and Y.
532
+ *
533
+ * @param hueRadians The desired hue in radians.
534
+ * @param chroma The desired chroma.
535
+ * @param y The desired Y.
536
+ * @return The desired color as a hexadecimal integer, if found; 0
537
+ * otherwise.
538
+ */
539
+ static findResultByJ(hueRadians, chroma, y) {
540
+ let j = Math.sqrt(y) * 11;
541
+ const viewingConditions = ViewingConditions.DEFAULT, tInnerCoeff = 1 / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), p1 = 0.25 * (Math.cos(hueRadians + 2) + 3.8) * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb, hSin = Math.sin(hueRadians), hCos = Math.cos(hueRadians);
542
+ for (let iterationRound = 0; iterationRound < 5; iterationRound++) {
543
+ const jNormalized = j / 100, alpha = chroma === 0 || j === 0 ? 0 : chroma / Math.sqrt(jNormalized), t = Math.pow(alpha * tInnerCoeff, 1 / 0.9), p2 = viewingConditions.aw * Math.pow(jNormalized, 1 / viewingConditions.c / viewingConditions.z) / viewingConditions.nbb, gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin), a = gamma * hCos, b = gamma * hSin, rA = (460 * p2 + 451 * a + 288 * b) / 1403, gA = (460 * p2 - 891 * a - 261 * b) / 1403, bA = (460 * p2 - 220 * a - 6300 * b) / 1403, rCScaled = HctSolver.inverseChromaticAdaptation(rA), gCScaled = HctSolver.inverseChromaticAdaptation(gA), bCScaled = HctSolver.inverseChromaticAdaptation(bA), linrgb = matrixMultiply([rCScaled, gCScaled, bCScaled], HctSolver.LINRGB_FROM_SCALED_DISCOUNT);
544
+ if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0)
545
+ return 0;
546
+ const kR = HctSolver.Y_FROM_LINRGB[0], kG = HctSolver.Y_FROM_LINRGB[1], kB = HctSolver.Y_FROM_LINRGB[2], fnj = kR * linrgb[0] + kG * linrgb[1] + kB * linrgb[2];
547
+ if (fnj <= 0)
548
+ return 0;
549
+ if (iterationRound === 4 || Math.abs(fnj - y) < 2e-3)
550
+ return linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01 ? 0 : argbFromLinrgb(linrgb);
551
+ j = j - (fnj - y) * j / (2 * fnj);
552
+ }
553
+ return 0;
554
+ }
555
+ /**
556
+ * Finds an sRGB color with the given hue, chroma, and L*, if
557
+ * possible.
558
+ *
559
+ * @param hueDegrees The desired hue, in degrees.
560
+ * @param chroma The desired chroma.
561
+ * @param lstar The desired L*.
562
+ * @return A hexadecimal representing the sRGB color. The color
563
+ * has sufficiently close hue, chroma, and L* to the desired
564
+ * values, if possible; otherwise, the hue and L* will be
565
+ * sufficiently close, and chroma will be maximized.
566
+ */
567
+ static solveToInt(hueDegrees, chroma, lstar) {
568
+ if (chroma < 1e-4 || lstar < 1e-4 || lstar > 99.9999)
569
+ return argbFromLstar(lstar);
570
+ hueDegrees = sanitizeDegreesDouble(hueDegrees);
571
+ const hueRadians = hueDegrees / 180 * Math.PI, y = yFromLstar(lstar), exactAnswer = HctSolver.findResultByJ(hueRadians, chroma, y);
572
+ if (exactAnswer !== 0)
573
+ return exactAnswer;
574
+ const linrgb = HctSolver.bisectToLimit(y, hueRadians);
575
+ return argbFromLinrgb(linrgb);
576
+ }
577
+ /**
578
+ * Finds an sRGB color with the given hue, chroma, and L*, if
579
+ * possible.
580
+ *
581
+ * @param hueDegrees The desired hue, in degrees.
582
+ * @param chroma The desired chroma.
583
+ * @param lstar The desired L*.
584
+ * @return An CAM16 object representing the sRGB color. The color
585
+ * has sufficiently close hue, chroma, and L* to the desired
586
+ * values, if possible; otherwise, the hue and L* will be
587
+ * sufficiently close, and chroma will be maximized.
588
+ */
589
+ static solveToCam(hueDegrees, chroma, lstar) {
590
+ return Cam16.fromInt(HctSolver.solveToInt(hueDegrees, chroma, lstar));
591
+ }
592
+ }
593
+ HctSolver.SCALED_DISCOUNT_FROM_LINRGB = [
594
+ [
595
+ 0.001200833568784504,
596
+ 0.002389694492170889,
597
+ 2795742885861124e-19
598
+ ],
599
+ [
600
+ 5891086651375999e-19,
601
+ 0.0029785502573438758,
602
+ 3270666104008398e-19
603
+ ],
604
+ [
605
+ 10146692491640572e-20,
606
+ 5364214359186694e-19,
607
+ 0.0032979401770712076
608
+ ]
609
+ ];
610
+ HctSolver.LINRGB_FROM_SCALED_DISCOUNT = [
611
+ [
612
+ 1373.2198709594231,
613
+ -1100.4251190754821,
614
+ -7.278681089101213
615
+ ],
616
+ [
617
+ -271.815969077903,
618
+ 559.6580465940733,
619
+ -32.46047482791194
620
+ ],
621
+ [
622
+ 1.9622899599665666,
623
+ -57.173814538844006,
624
+ 308.7233197812385
625
+ ]
626
+ ];
627
+ HctSolver.Y_FROM_LINRGB = [0.2126, 0.7152, 0.0722];
628
+ HctSolver.CRITICAL_PLANES = [
629
+ 0.015176349177441876,
630
+ 0.045529047532325624,
631
+ 0.07588174588720938,
632
+ 0.10623444424209313,
633
+ 0.13658714259697685,
634
+ 0.16693984095186062,
635
+ 0.19729253930674434,
636
+ 0.2276452376616281,
637
+ 0.2579979360165119,
638
+ 0.28835063437139563,
639
+ 0.3188300904430532,
640
+ 0.350925934958123,
641
+ 0.3848314933096426,
642
+ 0.42057480301049466,
643
+ 0.458183274052838,
644
+ 0.4976837250274023,
645
+ 0.5391024159806381,
646
+ 0.5824650784040898,
647
+ 0.6277969426914107,
648
+ 0.6751227633498623,
649
+ 0.7244668422128921,
650
+ 0.775853049866786,
651
+ 0.829304845476233,
652
+ 0.8848452951698498,
653
+ 0.942497089126609,
654
+ 1.0022825574869039,
655
+ 1.0642236851973577,
656
+ 1.1283421258858297,
657
+ 1.1946592148522128,
658
+ 1.2631959812511864,
659
+ 1.3339731595349034,
660
+ 1.407011200216447,
661
+ 1.4823302800086415,
662
+ 1.5599503113873272,
663
+ 1.6398909516233677,
664
+ 1.7221716113234105,
665
+ 1.8068114625156377,
666
+ 1.8938294463134073,
667
+ 1.9832442801866852,
668
+ 2.075074464868551,
669
+ 2.1693382909216234,
670
+ 2.2660538449872063,
671
+ 2.36523901573795,
672
+ 2.4669114995532007,
673
+ 2.5710888059345764,
674
+ 2.6777882626779785,
675
+ 2.7870270208169257,
676
+ 2.898822059350997,
677
+ 3.0131901897720907,
678
+ 3.1301480604002863,
679
+ 3.2497121605402226,
680
+ 3.3718988244681087,
681
+ 3.4967242352587946,
682
+ 3.624204428461639,
683
+ 3.754355295633311,
684
+ 3.887192587735158,
685
+ 4.022731918402185,
686
+ 4.160988767090289,
687
+ 4.301978482107941,
688
+ 4.445716283538092,
689
+ 4.592217266055746,
690
+ 4.741496401646282,
691
+ 4.893568542229298,
692
+ 5.048448422192488,
693
+ 5.20615066083972,
694
+ 5.3666897647573375,
695
+ 5.5300801301023865,
696
+ 5.696336044816294,
697
+ 5.865471690767354,
698
+ 6.037501145825082,
699
+ 6.212438385869475,
700
+ 6.390297286737924,
701
+ 6.571091626112461,
702
+ 6.7548350853498045,
703
+ 6.941541251256611,
704
+ 7.131223617812143,
705
+ 7.323895587840543,
706
+ 7.5195704746346665,
707
+ 7.7182615035334345,
708
+ 7.919981813454504,
709
+ 8.124744458384042,
710
+ 8.332562408825165,
711
+ 8.543448553206703,
712
+ 8.757415699253682,
713
+ 8.974476575321063,
714
+ 9.194643831691977,
715
+ 9.417930041841839,
716
+ 9.644347703669503,
717
+ 9.873909240696694,
718
+ 10.106627003236781,
719
+ 10.342513269534024,
720
+ 10.58158024687427,
721
+ 10.8238400726681,
722
+ 11.069304815507364,
723
+ 11.317986476196008,
724
+ 11.569896988756009,
725
+ 11.825048221409341,
726
+ 12.083451977536606,
727
+ 12.345119996613247,
728
+ 12.610063955123938,
729
+ 12.878295467455942,
730
+ 13.149826086772048,
731
+ 13.42466730586372,
732
+ 13.702830557985108,
733
+ 13.984327217668513,
734
+ 14.269168601521828,
735
+ 14.55736596900856,
736
+ 14.848930523210871,
737
+ 15.143873411576273,
738
+ 15.44220572664832,
739
+ 15.743938506781891,
740
+ 16.04908273684337,
741
+ 16.35764934889634,
742
+ 16.66964922287304,
743
+ 16.985093187232053,
744
+ 17.30399201960269,
745
+ 17.62635644741625,
746
+ 17.95219714852476,
747
+ 18.281524751807332,
748
+ 18.614349837764564,
749
+ 18.95068293910138,
750
+ 19.290534541298456,
751
+ 19.633915083172692,
752
+ 19.98083495742689,
753
+ 20.331304511189067,
754
+ 20.685334046541502,
755
+ 21.042933821039977,
756
+ 21.404114048223256,
757
+ 21.76888489811322,
758
+ 22.137256497705877,
759
+ 22.50923893145328,
760
+ 22.884842241736916,
761
+ 23.264076429332462,
762
+ 23.6469514538663,
763
+ 24.033477234264016,
764
+ 24.42366364919083,
765
+ 24.817520537484558,
766
+ 25.21505769858089,
767
+ 25.61628489293138,
768
+ 26.021211842414342,
769
+ 26.429848230738664,
770
+ 26.842203703840827,
771
+ 27.258287870275353,
772
+ 27.678110301598522,
773
+ 28.10168053274597,
774
+ 28.529008062403893,
775
+ 28.96010235337422,
776
+ 29.39497283293396,
777
+ 29.83362889318845,
778
+ 30.276079891419332,
779
+ 30.722335150426627,
780
+ 31.172403958865512,
781
+ 31.62629557157785,
782
+ 32.08401920991837,
783
+ 32.54558406207592,
784
+ 33.010999283389665,
785
+ 33.4802739966603,
786
+ 33.953417292456834,
787
+ 34.430438229418264,
788
+ 34.911345834551085,
789
+ 35.39614910352207,
790
+ 35.88485700094671,
791
+ 36.37747846067349,
792
+ 36.87402238606382,
793
+ 37.37449765026789,
794
+ 37.87891309649659,
795
+ 38.38727753828926,
796
+ 38.89959975977785,
797
+ 39.41588851594697,
798
+ 39.93615253289054,
799
+ 40.460400508064545,
800
+ 40.98864111053629,
801
+ 41.520882981230194,
802
+ 42.05713473317016,
803
+ 42.597404951718396,
804
+ 43.141702194811224,
805
+ 43.6900349931913,
806
+ 44.24241185063697,
807
+ 44.798841244188324,
808
+ 45.35933162437017,
809
+ 45.92389141541209,
810
+ 46.49252901546552,
811
+ 47.065252796817916,
812
+ 47.64207110610409,
813
+ 48.22299226451468,
814
+ 48.808024568002054,
815
+ 49.3971762874833,
816
+ 49.9904556690408,
817
+ 50.587870934119984,
818
+ 51.189430279724725,
819
+ 51.79514187861014,
820
+ 52.40501387947288,
821
+ 53.0190544071392,
822
+ 53.637271562750364,
823
+ 54.259673423945976,
824
+ 54.88626804504493,
825
+ 55.517063457223934,
826
+ 56.15206766869424,
827
+ 56.79128866487574,
828
+ 57.43473440856916,
829
+ 58.08241284012621,
830
+ 58.734331877617365,
831
+ 59.39049941699807,
832
+ 60.05092333227251,
833
+ 60.715611475655585,
834
+ 61.38457167773311,
835
+ 62.057811747619894,
836
+ 62.7353394731159,
837
+ 63.417162620860914,
838
+ 64.10328893648692,
839
+ 64.79372614476921,
840
+ 65.48848194977529,
841
+ 66.18756403501224,
842
+ 66.89098006357258,
843
+ 67.59873767827808,
844
+ 68.31084450182222,
845
+ 69.02730813691093,
846
+ 69.74813616640164,
847
+ 70.47333615344107,
848
+ 71.20291564160104,
849
+ 71.93688215501312,
850
+ 72.67524319850172,
851
+ 73.41800625771542,
852
+ 74.16517879925733,
853
+ 74.9167682708136,
854
+ 75.67278210128072,
855
+ 76.43322770089146,
856
+ 77.1981124613393,
857
+ 77.96744375590167,
858
+ 78.74122893956174,
859
+ 79.51947534912904,
860
+ 80.30219030335869,
861
+ 81.08938110306934,
862
+ 81.88105503125999,
863
+ 82.67721935322541,
864
+ 83.4778813166706,
865
+ 84.28304815182372,
866
+ 85.09272707154808,
867
+ 85.90692527145302,
868
+ 86.72564993000343,
869
+ 87.54890820862819,
870
+ 88.3767072518277,
871
+ 89.2090541872801,
872
+ 90.04595612594655,
873
+ 90.88742016217518,
874
+ 91.73345337380438,
875
+ 92.58406282226491,
876
+ 93.43925555268066,
877
+ 94.29903859396902,
878
+ 95.16341895893969,
879
+ 96.03240364439274,
880
+ 96.9059996312159,
881
+ 97.78421388448044,
882
+ 98.6670533535366,
883
+ 99.55452497210776
884
+ ];
885
+ /**
886
+ * @license
887
+ * Copyright 2021 Google LLC
888
+ *
889
+ * Licensed under the Apache License, Version 2.0 (the "License");
890
+ * you may not use this file except in compliance with the License.
891
+ * You may obtain a copy of the License at
892
+ *
893
+ * http://www.apache.org/licenses/LICENSE-2.0
894
+ *
895
+ * Unless required by applicable law or agreed to in writing, software
896
+ * distributed under the License is distributed on an "AS IS" BASIS,
897
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
898
+ * See the License for the specific language governing permissions and
899
+ * limitations under the License.
900
+ */
901
+ class Hct {
902
+ static from(hue, chroma, tone) {
903
+ return new Hct(HctSolver.solveToInt(hue, chroma, tone));
904
+ }
905
+ /**
906
+ * @param argb ARGB representation of a color.
907
+ * @return HCT representation of a color in default viewing conditions
908
+ */
909
+ static fromInt(argb) {
910
+ return new Hct(argb);
911
+ }
912
+ toInt() {
913
+ return this.argb;
914
+ }
915
+ /**
916
+ * A number, in degrees, representing ex. red, orange, yellow, etc.
917
+ * Ranges from 0 <= hue < 360.
918
+ */
919
+ get hue() {
920
+ return this.internalHue;
921
+ }
922
+ /**
923
+ * @param newHue 0 <= newHue < 360; invalid values are corrected.
924
+ * Chroma may decrease because chroma has a different maximum for any given
925
+ * hue and tone.
926
+ */
927
+ set hue(newHue) {
928
+ this.setInternalState(HctSolver.solveToInt(newHue, this.internalChroma, this.internalTone));
929
+ }
930
+ get chroma() {
931
+ return this.internalChroma;
932
+ }
933
+ /**
934
+ * @param newChroma 0 <= newChroma < ?
935
+ * Chroma may decrease because chroma has a different maximum for any given
936
+ * hue and tone.
937
+ */
938
+ set chroma(newChroma) {
939
+ this.setInternalState(HctSolver.solveToInt(this.internalHue, newChroma, this.internalTone));
940
+ }
941
+ /** Lightness. Ranges from 0 to 100. */
942
+ get tone() {
943
+ return this.internalTone;
944
+ }
945
+ /**
946
+ * @param newTone 0 <= newTone <= 100; invalid valids are corrected.
947
+ * Chroma may decrease because chroma has a different maximum for any given
948
+ * hue and tone.
949
+ */
950
+ set tone(newTone) {
951
+ this.setInternalState(HctSolver.solveToInt(this.internalHue, this.internalChroma, newTone));
952
+ }
953
+ /** Sets a property of the Hct object. */
954
+ setValue(propertyName, value) {
955
+ this[propertyName] = value;
956
+ }
957
+ toString() {
958
+ return `HCT(${this.hue.toFixed(0)}, ${this.chroma.toFixed(0)}, ${this.tone.toFixed(0)})`;
959
+ }
960
+ static isBlue(hue) {
961
+ return hue >= 250 && hue < 270;
962
+ }
963
+ static isYellow(hue) {
964
+ return hue >= 105 && hue < 125;
965
+ }
966
+ static isCyan(hue) {
967
+ return hue >= 170 && hue < 207;
968
+ }
969
+ constructor(argb) {
970
+ this.argb = argb;
971
+ const cam = Cam16.fromInt(argb);
972
+ this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
973
+ }
974
+ setInternalState(argb) {
975
+ const cam = Cam16.fromInt(argb);
976
+ this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
977
+ }
978
+ /**
979
+ * Translates a color into different [ViewingConditions].
980
+ *
981
+ * Colors change appearance. They look different with lights on versus off,
982
+ * the same color, as in hex code, on white looks different when on black.
983
+ * This is called color relativity, most famously explicated by Josef Albers
984
+ * in Interaction of Color.
985
+ *
986
+ * In color science, color appearance models can account for this and
987
+ * calculate the appearance of a color in different settings. HCT is based on
988
+ * CAM16, a color appearance model, and uses it to make these calculations.
989
+ *
990
+ * See [ViewingConditions.make] for parameters affecting color appearance.
991
+ */
992
+ inViewingConditions(vc) {
993
+ const viewedInVc = Cam16.fromInt(this.toInt()).xyzInViewingConditions(vc), recastInVc = Cam16.fromXyzInViewingConditions(viewedInVc[0], viewedInVc[1], viewedInVc[2], ViewingConditions.make());
994
+ return Hct.from(recastInVc.hue, recastInVc.chroma, lstarFromY(viewedInVc[1]));
995
+ }
996
+ }
997
+ /**
998
+ * @license
999
+ * Copyright 2021 Google LLC
1000
+ *
1001
+ * Licensed under the Apache License, Version 2.0 (the "License");
1002
+ * you may not use this file except in compliance with the License.
1003
+ * You may obtain a copy of the License at
1004
+ *
1005
+ * http://www.apache.org/licenses/LICENSE-2.0
1006
+ *
1007
+ * Unless required by applicable law or agreed to in writing, software
1008
+ * distributed under the License is distributed on an "AS IS" BASIS,
1009
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
+ * See the License for the specific language governing permissions and
1011
+ * limitations under the License.
1012
+ */
1013
+ class Blend {
1014
+ /**
1015
+ * Blend the design color's HCT hue towards the key color's HCT
1016
+ * hue, in a way that leaves the original color recognizable and
1017
+ * recognizably shifted towards the key color.
1018
+ *
1019
+ * @param designColor ARGB representation of an arbitrary color.
1020
+ * @param sourceColor ARGB representation of the main theme color.
1021
+ * @return The design color with a hue shifted towards the
1022
+ * system's color, a slightly warmer/cooler variant of the design
1023
+ * color's hue.
1024
+ */
1025
+ static harmonize(designColor, sourceColor) {
1026
+ const fromHct = Hct.fromInt(designColor), toHct = Hct.fromInt(sourceColor), differenceDegrees$1 = differenceDegrees(fromHct.hue, toHct.hue), rotationDegrees = Math.min(differenceDegrees$1 * 0.5, 15), outputHue = sanitizeDegreesDouble(fromHct.hue + rotationDegrees * rotationDirection(fromHct.hue, toHct.hue));
1027
+ return Hct.from(outputHue, fromHct.chroma, fromHct.tone).toInt();
1028
+ }
1029
+ /**
1030
+ * Blends hue from one color into another. The chroma and tone of
1031
+ * the original color are maintained.
1032
+ *
1033
+ * @param from ARGB representation of color
1034
+ * @param to ARGB representation of color
1035
+ * @param amount how much blending to perform; 0.0 >= and <= 1.0
1036
+ * @return from, with a hue blended towards to. Chroma and tone
1037
+ * are constant.
1038
+ */
1039
+ static hctHue(from, to, amount) {
1040
+ const ucs = Blend.cam16Ucs(from, to, amount), ucsCam = Cam16.fromInt(ucs), fromCam = Cam16.fromInt(from);
1041
+ return Hct.from(ucsCam.hue, fromCam.chroma, lstarFromArgb(from)).toInt();
1042
+ }
1043
+ /**
1044
+ * Blend in CAM16-UCS space.
1045
+ *
1046
+ * @param from ARGB representation of color
1047
+ * @param to ARGB representation of color
1048
+ * @param amount how much blending to perform; 0.0 >= and <= 1.0
1049
+ * @return from, blended towards to. Hue, chroma, and tone will
1050
+ * change.
1051
+ */
1052
+ static cam16Ucs(from, to, amount) {
1053
+ const fromCam = Cam16.fromInt(from), toCam = Cam16.fromInt(to), fromJ = fromCam.jstar, fromA = fromCam.astar, fromB = fromCam.bstar, toJ = toCam.jstar, toA = toCam.astar, toB = toCam.bstar, jstar = fromJ + (toJ - fromJ) * amount, astar = fromA + (toA - fromA) * amount, bstar = fromB + (toB - fromB) * amount;
1054
+ return Cam16.fromUcs(jstar, astar, bstar).toInt();
1055
+ }
1056
+ }
1057
+ /**
1058
+ * @license
1059
+ * Copyright 2022 Google LLC
1060
+ *
1061
+ * Licensed under the Apache License, Version 2.0 (the "License");
1062
+ * you may not use this file except in compliance with the License.
1063
+ * You may obtain a copy of the License at
1064
+ *
1065
+ * http://www.apache.org/licenses/LICENSE-2.0
1066
+ *
1067
+ * Unless required by applicable law or agreed to in writing, software
1068
+ * distributed under the License is distributed on an "AS IS" BASIS,
1069
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1070
+ * See the License for the specific language governing permissions and
1071
+ * limitations under the License.
1072
+ */
1073
+ class Contrast {
1074
+ /**
1075
+ * Returns a contrast ratio, which ranges from 1 to 21.
1076
+ *
1077
+ * @param toneA Tone between 0 and 100. Values outside will be clamped.
1078
+ * @param toneB Tone between 0 and 100. Values outside will be clamped.
1079
+ */
1080
+ static ratioOfTones(toneA, toneB) {
1081
+ return toneA = clampDouble(0, 100, toneA), toneB = clampDouble(0, 100, toneB), Contrast.ratioOfYs(yFromLstar(toneA), yFromLstar(toneB));
1082
+ }
1083
+ static ratioOfYs(y1, y2) {
1084
+ const lighter = y1 > y2 ? y1 : y2, darker = lighter === y2 ? y1 : y2;
1085
+ return (lighter + 5) / (darker + 5);
1086
+ }
1087
+ /**
1088
+ * Returns a tone >= tone parameter that ensures ratio parameter.
1089
+ * Return value is between 0 and 100.
1090
+ * Returns -1 if ratio cannot be achieved with tone parameter.
1091
+ *
1092
+ * @param tone Tone return value must contrast with.
1093
+ * Range is 0 to 100. Invalid values will result in -1 being returned.
1094
+ * @param ratio Contrast ratio of return value and tone.
1095
+ * Range is 1 to 21, invalid values have undefined behavior.
1096
+ */
1097
+ static lighter(tone, ratio) {
1098
+ if (tone < 0 || tone > 100)
1099
+ return -1;
1100
+ const darkY = yFromLstar(tone), lightY = ratio * (darkY + 5) - 5, realContrast = Contrast.ratioOfYs(lightY, darkY), delta = Math.abs(realContrast - ratio);
1101
+ if (realContrast < ratio && delta > 0.04)
1102
+ return -1;
1103
+ const returnValue = lstarFromY(lightY) + 0.4;
1104
+ return returnValue < 0 || returnValue > 100 ? -1 : returnValue;
1105
+ }
1106
+ /**
1107
+ * Returns a tone <= tone parameter that ensures ratio parameter.
1108
+ * Return value is between 0 and 100.
1109
+ * Returns -1 if ratio cannot be achieved with tone parameter.
1110
+ *
1111
+ * @param tone Tone return value must contrast with.
1112
+ * Range is 0 to 100. Invalid values will result in -1 being returned.
1113
+ * @param ratio Contrast ratio of return value and tone.
1114
+ * Range is 1 to 21, invalid values have undefined behavior.
1115
+ */
1116
+ static darker(tone, ratio) {
1117
+ if (tone < 0 || tone > 100)
1118
+ return -1;
1119
+ const lightY = yFromLstar(tone), darkY = (lightY + 5) / ratio - 5, realContrast = Contrast.ratioOfYs(lightY, darkY), delta = Math.abs(realContrast - ratio);
1120
+ if (realContrast < ratio && delta > 0.04)
1121
+ return -1;
1122
+ const returnValue = lstarFromY(darkY) - 0.4;
1123
+ return returnValue < 0 || returnValue > 100 ? -1 : returnValue;
1124
+ }
1125
+ /**
1126
+ * Returns a tone >= tone parameter that ensures ratio parameter.
1127
+ * Return value is between 0 and 100.
1128
+ * Returns 100 if ratio cannot be achieved with tone parameter.
1129
+ *
1130
+ * This method is unsafe because the returned value is guaranteed to be in
1131
+ * bounds for tone, i.e. between 0 and 100. However, that value may not reach
1132
+ * the ratio with tone. For example, there is no color lighter than T100.
1133
+ *
1134
+ * @param tone Tone return value must contrast with.
1135
+ * Range is 0 to 100. Invalid values will result in 100 being returned.
1136
+ * @param ratio Desired contrast ratio of return value and tone parameter.
1137
+ * Range is 1 to 21, invalid values have undefined behavior.
1138
+ */
1139
+ static lighterUnsafe(tone, ratio) {
1140
+ const lighterSafe = Contrast.lighter(tone, ratio);
1141
+ return lighterSafe < 0 ? 100 : lighterSafe;
1142
+ }
1143
+ /**
1144
+ * Returns a tone >= tone parameter that ensures ratio parameter.
1145
+ * Return value is between 0 and 100.
1146
+ * Returns 100 if ratio cannot be achieved with tone parameter.
1147
+ *
1148
+ * This method is unsafe because the returned value is guaranteed to be in
1149
+ * bounds for tone, i.e. between 0 and 100. However, that value may not reach
1150
+ * the [ratio with [tone]. For example, there is no color darker than T0.
1151
+ *
1152
+ * @param tone Tone return value must contrast with.
1153
+ * Range is 0 to 100. Invalid values will result in 0 being returned.
1154
+ * @param ratio Desired contrast ratio of return value and tone parameter.
1155
+ * Range is 1 to 21, invalid values have undefined behavior.
1156
+ */
1157
+ static darkerUnsafe(tone, ratio) {
1158
+ const darkerSafe = Contrast.darker(tone, ratio);
1159
+ return darkerSafe < 0 ? 0 : darkerSafe;
1160
+ }
1161
+ }
1162
+ /**
1163
+ * @license
1164
+ * Copyright 2023 Google LLC
1165
+ *
1166
+ * Licensed under the Apache License, Version 2.0 (the "License");
1167
+ * you may not use this file except in compliance with the License.
1168
+ * You may obtain a copy of the License at
1169
+ *
1170
+ * http://www.apache.org/licenses/LICENSE-2.0
1171
+ *
1172
+ * Unless required by applicable law or agreed to in writing, software
1173
+ * distributed under the License is distributed on an "AS IS" BASIS,
1174
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1175
+ * See the License for the specific language governing permissions and
1176
+ * limitations under the License.
1177
+ */
1178
+ class DislikeAnalyzer {
1179
+ /**
1180
+ * Returns true if a color is disliked.
1181
+ *
1182
+ * @param hct A color to be judged.
1183
+ * @return Whether the color is disliked.
1184
+ *
1185
+ * Disliked is defined as a dark yellow-green that is not neutral.
1186
+ */
1187
+ static isDisliked(hct) {
1188
+ const huePasses = Math.round(hct.hue) >= 90 && Math.round(hct.hue) <= 111, chromaPasses = Math.round(hct.chroma) > 16, tonePasses = Math.round(hct.tone) < 65;
1189
+ return huePasses && chromaPasses && tonePasses;
1190
+ }
1191
+ /**
1192
+ * If a color is disliked, lighten it to make it likable.
1193
+ *
1194
+ * @param hct A color to be judged.
1195
+ * @return A new color if the original color is disliked, or the original
1196
+ * color if it is acceptable.
1197
+ */
1198
+ static fixIfDisliked(hct) {
1199
+ return DislikeAnalyzer.isDisliked(hct) ? Hct.from(hct.hue, hct.chroma, 70) : hct;
1200
+ }
1201
+ }
1202
+ /**
1203
+ * @license
1204
+ * Copyright 2022 Google LLC
1205
+ *
1206
+ * Licensed under the Apache License, Version 2.0 (the "License");
1207
+ * you may not use this file except in compliance with the License.
1208
+ * You may obtain a copy of the License at
1209
+ *
1210
+ * http://www.apache.org/licenses/LICENSE-2.0
1211
+ *
1212
+ * Unless required by applicable law or agreed to in writing, software
1213
+ * distributed under the License is distributed on an "AS IS" BASIS,
1214
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1215
+ * See the License for the specific language governing permissions and
1216
+ * limitations under the License.
1217
+ */
1218
+ function validateExtendedColor(originalColor, specVersion, extendedColor) {
1219
+ if (originalColor.name !== extendedColor.name)
1220
+ throw new Error(`Attempting to extend color ${originalColor.name} with color ${extendedColor.name} of different name for spec version ${specVersion}.`);
1221
+ if (originalColor.isBackground !== extendedColor.isBackground)
1222
+ throw new Error(`Attempting to extend color ${originalColor.name} as a ${originalColor.isBackground ? "background" : "foreground"} with color ${extendedColor.name} as a ${extendedColor.isBackground ? "background" : "foreground"} for spec version ${specVersion}.`);
1223
+ }
1224
+ function extendSpecVersion(originlColor, specVersion, extendedColor) {
1225
+ return validateExtendedColor(originlColor, specVersion, extendedColor), DynamicColor.fromPalette({
1226
+ name: originlColor.name,
1227
+ palette: (s) => s.specVersion === specVersion ? extendedColor.palette(s) : originlColor.palette(s),
1228
+ tone: (s) => s.specVersion === specVersion ? extendedColor.tone(s) : originlColor.tone(s),
1229
+ isBackground: originlColor.isBackground,
1230
+ chromaMultiplier: (s) => {
1231
+ const chromaMultiplier = s.specVersion === specVersion ? extendedColor.chromaMultiplier : originlColor.chromaMultiplier;
1232
+ return chromaMultiplier !== void 0 ? chromaMultiplier(s) : 1;
1233
+ },
1234
+ background: (s) => {
1235
+ const background = s.specVersion === specVersion ? extendedColor.background : originlColor.background;
1236
+ return background !== void 0 ? background(s) : void 0;
1237
+ },
1238
+ secondBackground: (s) => {
1239
+ const secondBackground = s.specVersion === specVersion ? extendedColor.secondBackground : originlColor.secondBackground;
1240
+ return secondBackground !== void 0 ? secondBackground(s) : void 0;
1241
+ },
1242
+ contrastCurve: (s) => {
1243
+ const contrastCurve = s.specVersion === specVersion ? extendedColor.contrastCurve : originlColor.contrastCurve;
1244
+ return contrastCurve !== void 0 ? contrastCurve(s) : void 0;
1245
+ },
1246
+ toneDeltaPair: (s) => {
1247
+ const toneDeltaPair = s.specVersion === specVersion ? extendedColor.toneDeltaPair : originlColor.toneDeltaPair;
1248
+ return toneDeltaPair !== void 0 ? toneDeltaPair(s) : void 0;
1249
+ }
1250
+ });
1251
+ }
1252
+ class DynamicColor {
1253
+ /**
1254
+ * Create a DynamicColor defined by a TonalPalette and HCT tone.
1255
+ *
1256
+ * @param args Functions with DynamicScheme as input. Must provide a palette
1257
+ * and tone. May provide a background DynamicColor and ToneDeltaPair.
1258
+ */
1259
+ static fromPalette(args) {
1260
+ return new DynamicColor(args.name ?? "", args.palette, args.tone ?? DynamicColor.getInitialToneFromBackground(args.background), args.isBackground ?? !1, args.chromaMultiplier, args.background, args.secondBackground, args.contrastCurve, args.toneDeltaPair);
1261
+ }
1262
+ static getInitialToneFromBackground(background) {
1263
+ return background === void 0 ? (s) => 50 : (s) => background(s) ? background(s).getTone(s) : 50;
1264
+ }
1265
+ /**
1266
+ * The base constructor for DynamicColor.
1267
+ *
1268
+ * _Strongly_ prefer using one of the convenience constructors. This class is
1269
+ * arguably too flexible to ensure it can support any scenario. Functional
1270
+ * arguments allow overriding without risks that come with subclasses.
1271
+ *
1272
+ * For example, the default behavior of adjust tone at max contrast
1273
+ * to be at a 7.0 ratio with its background is principled and
1274
+ * matches accessibility guidance. That does not mean it's the desired
1275
+ * approach for _every_ design system, and every color pairing,
1276
+ * always, in every case.
1277
+ *
1278
+ * @param name The name of the dynamic color. Defaults to empty.
1279
+ * @param palette Function that provides a TonalPalette given DynamicScheme. A
1280
+ * TonalPalette is defined by a hue and chroma, so this replaces the need
1281
+ * to specify hue/chroma. By providing a tonal palette, when contrast
1282
+ * adjustments are made, intended chroma can be preserved.
1283
+ * @param tone Function that provides a tone, given a DynamicScheme.
1284
+ * @param isBackground Whether this dynamic color is a background, with some
1285
+ * other color as the foreground. Defaults to false.
1286
+ * @param chromaMultiplier A factor that multiplies the chroma for this color.
1287
+ * @param background The background of the dynamic color (as a function of a
1288
+ * `DynamicScheme`), if it exists.
1289
+ * @param secondBackground A second background of the dynamic color (as a
1290
+ * function of a `DynamicScheme`), if it exists.
1291
+ * @param contrastCurve A `ContrastCurve` object specifying how its contrast
1292
+ * against its background should behave in various contrast levels
1293
+ * options.
1294
+ * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
1295
+ * constraint between two colors. One of them must be the color being
1296
+ * constructed.
1297
+ */
1298
+ constructor(name, palette, tone, isBackground, chromaMultiplier, background, secondBackground, contrastCurve, toneDeltaPair) {
1299
+ if (this.name = name, this.palette = palette, this.tone = tone, this.isBackground = isBackground, this.chromaMultiplier = chromaMultiplier, this.background = background, this.secondBackground = secondBackground, this.contrastCurve = contrastCurve, this.toneDeltaPair = toneDeltaPair, this.hctCache = /* @__PURE__ */ new Map(), !background && secondBackground)
1300
+ throw new Error(`Color ${name} has secondBackgrounddefined, but background is not defined.`);
1301
+ if (!background && contrastCurve)
1302
+ throw new Error(`Color ${name} has contrastCurvedefined, but background is not defined.`);
1303
+ if (background && !contrastCurve)
1304
+ throw new Error(`Color ${name} has backgrounddefined, but contrastCurve is not defined.`);
1305
+ }
1306
+ /**
1307
+ * Returns a deep copy of this DynamicColor.
1308
+ */
1309
+ clone() {
1310
+ return DynamicColor.fromPalette({
1311
+ name: this.name,
1312
+ palette: this.palette,
1313
+ tone: this.tone,
1314
+ isBackground: this.isBackground,
1315
+ chromaMultiplier: this.chromaMultiplier,
1316
+ background: this.background,
1317
+ secondBackground: this.secondBackground,
1318
+ contrastCurve: this.contrastCurve,
1319
+ toneDeltaPair: this.toneDeltaPair
1320
+ });
1321
+ }
1322
+ /**
1323
+ * Clears the cache of HCT values for this color. For testing or debugging
1324
+ * purposes.
1325
+ */
1326
+ clearCache() {
1327
+ this.hctCache.clear();
1328
+ }
1329
+ /**
1330
+ * Returns a ARGB integer (i.e. a hex code).
1331
+ *
1332
+ * @param scheme Defines the conditions of the user interface, for example,
1333
+ * whether or not it is dark mode or light mode, and what the desired
1334
+ * contrast level is.
1335
+ */
1336
+ getArgb(scheme) {
1337
+ return this.getHct(scheme).toInt();
1338
+ }
1339
+ /**
1340
+ * Returns a color, expressed in the HCT color space, that this
1341
+ * DynamicColor is under the conditions in scheme.
1342
+ *
1343
+ * @param scheme Defines the conditions of the user interface, for example,
1344
+ * whether or not it is dark mode or light mode, and what the desired
1345
+ * contrast level is.
1346
+ */
1347
+ getHct(scheme) {
1348
+ const cachedAnswer = this.hctCache.get(scheme);
1349
+ if (cachedAnswer != null)
1350
+ return cachedAnswer;
1351
+ const answer = getSpec(scheme.specVersion).getHct(scheme, this);
1352
+ return this.hctCache.size > 4 && this.hctCache.clear(), this.hctCache.set(scheme, answer), answer;
1353
+ }
1354
+ /**
1355
+ * Returns a tone, T in the HCT color space, that this DynamicColor is under
1356
+ * the conditions in scheme.
1357
+ *
1358
+ * @param scheme Defines the conditions of the user interface, for example,
1359
+ * whether or not it is dark mode or light mode, and what the desired
1360
+ * contrast level is.
1361
+ */
1362
+ getTone(scheme) {
1363
+ return getSpec(scheme.specVersion).getTone(scheme, this);
1364
+ }
1365
+ /**
1366
+ * Given a background tone, finds a foreground tone, while ensuring they reach
1367
+ * a contrast ratio that is as close to [ratio] as possible.
1368
+ *
1369
+ * @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it
1370
+ * falls outside that range.
1371
+ * @param ratio The contrast ratio desired between bgTone and the return
1372
+ * value.
1373
+ */
1374
+ static foregroundTone(bgTone, ratio) {
1375
+ const lighterTone = Contrast.lighterUnsafe(bgTone, ratio), darkerTone = Contrast.darkerUnsafe(bgTone, ratio), lighterRatio = Contrast.ratioOfTones(lighterTone, bgTone), darkerRatio = Contrast.ratioOfTones(darkerTone, bgTone);
1376
+ if (DynamicColor.tonePrefersLightForeground(bgTone)) {
1377
+ const negligibleDifference = Math.abs(lighterRatio - darkerRatio) < 0.1 && lighterRatio < ratio && darkerRatio < ratio;
1378
+ return lighterRatio >= ratio || lighterRatio >= darkerRatio || negligibleDifference ? lighterTone : darkerTone;
1379
+ } else
1380
+ return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone : lighterTone;
1381
+ }
1382
+ /**
1383
+ * Returns whether [tone] prefers a light foreground.
1384
+ *
1385
+ * People prefer white foregrounds on ~T60-70. Observed over time, and also
1386
+ * by Andrew Somers during research for APCA.
1387
+ *
1388
+ * T60 used as to create the smallest discontinuity possible when skipping
1389
+ * down to T49 in order to ensure light foregrounds.
1390
+ * Since `tertiaryContainer` in dark monochrome scheme requires a tone of
1391
+ * 60, it should not be adjusted. Therefore, 60 is excluded here.
1392
+ */
1393
+ static tonePrefersLightForeground(tone) {
1394
+ return Math.round(tone) < 60;
1395
+ }
1396
+ /**
1397
+ * Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter
1398
+ * color.
1399
+ */
1400
+ static toneAllowsLightForeground(tone) {
1401
+ return Math.round(tone) <= 49;
1402
+ }
1403
+ /**
1404
+ * Adjusts a tone such that white has 4.5 contrast, if the tone is
1405
+ * reasonably close to supporting it.
1406
+ */
1407
+ static enableLightForeground(tone) {
1408
+ return DynamicColor.tonePrefersLightForeground(tone) && !DynamicColor.toneAllowsLightForeground(tone) ? 49 : tone;
1409
+ }
1410
+ }
1411
+ class ColorCalculationDelegateImpl2021 {
1412
+ getHct(scheme, color) {
1413
+ const tone = color.getTone(scheme);
1414
+ return color.palette(scheme).getHct(tone);
1415
+ }
1416
+ getTone(scheme, color) {
1417
+ const decreasingContrast = scheme.contrastLevel < 0, toneDeltaPair = color.toneDeltaPair ? color.toneDeltaPair(scheme) : void 0;
1418
+ if (toneDeltaPair) {
1419
+ const roleA = toneDeltaPair.roleA, roleB = toneDeltaPair.roleB, delta = toneDeltaPair.delta, polarity = toneDeltaPair.polarity, stayTogether = toneDeltaPair.stayTogether, aIsNearer = polarity === "nearer" || polarity === "lighter" && !scheme.isDark || polarity === "darker" && scheme.isDark, nearer = aIsNearer ? roleA : roleB, farther = aIsNearer ? roleB : roleA, amNearer = color.name === nearer.name, expansionDir = scheme.isDark ? 1 : -1;
1420
+ let nTone = nearer.tone(scheme), fTone = farther.tone(scheme);
1421
+ if (color.background && nearer.contrastCurve && farther.contrastCurve) {
1422
+ const bg = color.background(scheme), nContrastCurve = nearer.contrastCurve(scheme), fContrastCurve = farther.contrastCurve(scheme);
1423
+ if (bg && nContrastCurve && fContrastCurve) {
1424
+ const bgTone = bg.getTone(scheme), nContrast = nContrastCurve.get(scheme.contrastLevel), fContrast = fContrastCurve.get(scheme.contrastLevel);
1425
+ Contrast.ratioOfTones(bgTone, nTone) < nContrast && (nTone = DynamicColor.foregroundTone(bgTone, nContrast)), Contrast.ratioOfTones(bgTone, fTone) < fContrast && (fTone = DynamicColor.foregroundTone(bgTone, fContrast)), decreasingContrast && (nTone = DynamicColor.foregroundTone(bgTone, nContrast), fTone = DynamicColor.foregroundTone(bgTone, fContrast));
1426
+ }
1427
+ }
1428
+ return (fTone - nTone) * expansionDir < delta && (fTone = clampDouble(0, 100, nTone + delta * expansionDir), (fTone - nTone) * expansionDir >= delta || (nTone = clampDouble(0, 100, fTone - delta * expansionDir))), 50 <= nTone && nTone < 60 ? expansionDir > 0 ? (nTone = 60, fTone = Math.max(fTone, nTone + delta * expansionDir)) : (nTone = 49, fTone = Math.min(fTone, nTone + delta * expansionDir)) : 50 <= fTone && fTone < 60 && (stayTogether ? expansionDir > 0 ? (nTone = 60, fTone = Math.max(fTone, nTone + delta * expansionDir)) : (nTone = 49, fTone = Math.min(fTone, nTone + delta * expansionDir)) : expansionDir > 0 ? fTone = 60 : fTone = 49), amNearer ? nTone : fTone;
1429
+ } else {
1430
+ let answer = color.tone(scheme);
1431
+ if (color.background == null || color.background(scheme) === void 0 || color.contrastCurve == null || color.contrastCurve(scheme) === void 0)
1432
+ return answer;
1433
+ const bgTone = color.background(scheme).getTone(scheme), desiredRatio = color.contrastCurve(scheme).get(scheme.contrastLevel);
1434
+ if (Contrast.ratioOfTones(bgTone, answer) >= desiredRatio || (answer = DynamicColor.foregroundTone(bgTone, desiredRatio)), decreasingContrast && (answer = DynamicColor.foregroundTone(bgTone, desiredRatio)), color.isBackground && 50 <= answer && answer < 60 && (Contrast.ratioOfTones(49, bgTone) >= desiredRatio ? answer = 49 : answer = 60), color.secondBackground == null || color.secondBackground(scheme) === void 0)
1435
+ return answer;
1436
+ const [bg1, bg2] = [color.background, color.secondBackground], [bgTone1, bgTone2] = [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)], [upper, lower] = [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)];
1437
+ if (Contrast.ratioOfTones(upper, answer) >= desiredRatio && Contrast.ratioOfTones(lower, answer) >= desiredRatio)
1438
+ return answer;
1439
+ const lightOption = Contrast.lighter(upper, desiredRatio), darkOption = Contrast.darker(lower, desiredRatio), availables = [];
1440
+ return lightOption !== -1 && availables.push(lightOption), darkOption !== -1 && availables.push(darkOption), DynamicColor.tonePrefersLightForeground(bgTone1) || DynamicColor.tonePrefersLightForeground(bgTone2) ? lightOption < 0 ? 100 : lightOption : availables.length === 1 ? availables[0] : darkOption < 0 ? 0 : darkOption;
1441
+ }
1442
+ }
1443
+ }
1444
+ class ColorCalculationDelegateImpl2025 {
1445
+ getHct(scheme, color) {
1446
+ const palette = color.palette(scheme), tone = color.getTone(scheme), hue = palette.hue, chroma = palette.chroma * (color.chromaMultiplier ? color.chromaMultiplier(scheme) : 1);
1447
+ return Hct.from(hue, chroma, tone);
1448
+ }
1449
+ getTone(scheme, color) {
1450
+ const toneDeltaPair = color.toneDeltaPair ? color.toneDeltaPair(scheme) : void 0;
1451
+ if (toneDeltaPair) {
1452
+ const roleA = toneDeltaPair.roleA, roleB = toneDeltaPair.roleB, polarity = toneDeltaPair.polarity, constraint = toneDeltaPair.constraint, absoluteDelta = polarity === "darker" || polarity === "relative_lighter" && scheme.isDark || polarity === "relative_darker" && !scheme.isDark ? -toneDeltaPair.delta : toneDeltaPair.delta, amRoleA = color.name === roleA.name, selfRole = amRoleA ? roleA : roleB, refRole = amRoleA ? roleB : roleA;
1453
+ let selfTone = selfRole.tone(scheme), refTone = refRole.getTone(scheme);
1454
+ const relativeDelta = absoluteDelta * (amRoleA ? 1 : -1);
1455
+ if (constraint === "exact" ? selfTone = clampDouble(0, 100, refTone + relativeDelta) : constraint === "nearer" ? relativeDelta > 0 ? selfTone = clampDouble(0, 100, clampDouble(refTone, refTone + relativeDelta, selfTone)) : selfTone = clampDouble(0, 100, clampDouble(refTone + relativeDelta, refTone, selfTone)) : constraint === "farther" && (relativeDelta > 0 ? selfTone = clampDouble(refTone + relativeDelta, 100, selfTone) : selfTone = clampDouble(0, refTone + relativeDelta, selfTone)), color.background && color.contrastCurve) {
1456
+ const background = color.background(scheme), contrastCurve = color.contrastCurve(scheme);
1457
+ if (background && contrastCurve) {
1458
+ const bgTone = background.getTone(scheme), selfContrast = contrastCurve.get(scheme.contrastLevel);
1459
+ selfTone = Contrast.ratioOfTones(bgTone, selfTone) >= selfContrast && scheme.contrastLevel >= 0 ? selfTone : DynamicColor.foregroundTone(bgTone, selfContrast);
1460
+ }
1461
+ }
1462
+ return color.isBackground && !color.name.endsWith("_fixed_dim") && (selfTone >= 57 ? selfTone = clampDouble(65, 100, selfTone) : selfTone = clampDouble(0, 49, selfTone)), selfTone;
1463
+ } else {
1464
+ let answer = color.tone(scheme);
1465
+ if (color.background == null || color.background(scheme) === void 0 || color.contrastCurve == null || color.contrastCurve(scheme) === void 0)
1466
+ return answer;
1467
+ const bgTone = color.background(scheme).getTone(scheme), desiredRatio = color.contrastCurve(scheme).get(scheme.contrastLevel);
1468
+ if (answer = Contrast.ratioOfTones(bgTone, answer) >= desiredRatio && scheme.contrastLevel >= 0 ? answer : DynamicColor.foregroundTone(bgTone, desiredRatio), color.isBackground && !color.name.endsWith("_fixed_dim") && (answer >= 57 ? answer = clampDouble(65, 100, answer) : answer = clampDouble(0, 49, answer)), color.secondBackground == null || color.secondBackground(scheme) === void 0)
1469
+ return answer;
1470
+ const [bg1, bg2] = [color.background, color.secondBackground], [bgTone1, bgTone2] = [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)], [upper, lower] = [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)];
1471
+ if (Contrast.ratioOfTones(upper, answer) >= desiredRatio && Contrast.ratioOfTones(lower, answer) >= desiredRatio)
1472
+ return answer;
1473
+ const lightOption = Contrast.lighter(upper, desiredRatio), darkOption = Contrast.darker(lower, desiredRatio), availables = [];
1474
+ return lightOption !== -1 && availables.push(lightOption), darkOption !== -1 && availables.push(darkOption), DynamicColor.tonePrefersLightForeground(bgTone1) || DynamicColor.tonePrefersLightForeground(bgTone2) ? lightOption < 0 ? 100 : lightOption : availables.length === 1 ? availables[0] : darkOption < 0 ? 0 : darkOption;
1475
+ }
1476
+ }
1477
+ }
1478
+ const spec2021 = new ColorCalculationDelegateImpl2021(), spec2025 = new ColorCalculationDelegateImpl2025();
1479
+ function getSpec(specVersion) {
1480
+ return specVersion === "2025" ? spec2025 : spec2021;
1481
+ }
1482
+ /**
1483
+ * @license
1484
+ * Copyright 2021 Google LLC
1485
+ *
1486
+ * Licensed under the Apache License, Version 2.0 (the "License");
1487
+ * you may not use this file except in compliance with the License.
1488
+ * You may obtain a copy of the License at
1489
+ *
1490
+ * http://www.apache.org/licenses/LICENSE-2.0
1491
+ *
1492
+ * Unless required by applicable law or agreed to in writing, software
1493
+ * distributed under the License is distributed on an "AS IS" BASIS,
1494
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1495
+ * See the License for the specific language governing permissions and
1496
+ * limitations under the License.
1497
+ */
1498
+ class TonalPalette {
1499
+ /**
1500
+ * @param argb ARGB representation of a color
1501
+ * @return Tones matching that color's hue and chroma.
1502
+ */
1503
+ static fromInt(argb) {
1504
+ const hct = Hct.fromInt(argb);
1505
+ return TonalPalette.fromHct(hct);
1506
+ }
1507
+ /**
1508
+ * @param hct Hct
1509
+ * @return Tones matching that color's hue and chroma.
1510
+ */
1511
+ static fromHct(hct) {
1512
+ return new TonalPalette(hct.hue, hct.chroma, hct);
1513
+ }
1514
+ /**
1515
+ * @param hue HCT hue
1516
+ * @param chroma HCT chroma
1517
+ * @return Tones matching hue and chroma.
1518
+ */
1519
+ static fromHueAndChroma(hue, chroma) {
1520
+ const keyColor = new KeyColor(hue, chroma).create();
1521
+ return new TonalPalette(hue, chroma, keyColor);
1522
+ }
1523
+ constructor(hue, chroma, keyColor) {
1524
+ this.hue = hue, this.chroma = chroma, this.keyColor = keyColor, this.cache = /* @__PURE__ */ new Map();
1525
+ }
1526
+ /**
1527
+ * @param tone HCT tone, measured from 0 to 100.
1528
+ * @return ARGB representation of a color with that tone.
1529
+ */
1530
+ tone(tone) {
1531
+ let argb = this.cache.get(tone);
1532
+ return argb === void 0 && (tone == 99 && Hct.isYellow(this.hue) ? argb = this.averageArgb(this.tone(98), this.tone(100)) : argb = Hct.from(this.hue, this.chroma, tone).toInt(), this.cache.set(tone, argb)), argb;
1533
+ }
1534
+ /**
1535
+ * @param tone HCT tone.
1536
+ * @return HCT representation of a color with that tone.
1537
+ */
1538
+ getHct(tone) {
1539
+ return Hct.fromInt(this.tone(tone));
1540
+ }
1541
+ averageArgb(argb1, argb2) {
1542
+ const red1 = argb1 >>> 16 & 255, green1 = argb1 >>> 8 & 255, blue1 = argb1 & 255, red2 = argb2 >>> 16 & 255, green2 = argb2 >>> 8 & 255, blue2 = argb2 & 255, red = Math.round((red1 + red2) / 2), green = Math.round((green1 + green2) / 2), blue = Math.round((blue1 + blue2) / 2);
1543
+ return (255 << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255) >>> 0;
1544
+ }
1545
+ }
1546
+ class KeyColor {
1547
+ constructor(hue, requestedChroma) {
1548
+ this.hue = hue, this.requestedChroma = requestedChroma, this.chromaCache = /* @__PURE__ */ new Map(), this.maxChromaValue = 200;
1549
+ }
1550
+ /**
1551
+ * Creates a key color from a [hue] and a [chroma].
1552
+ * The key color is the first tone, starting from T50, matching the given hue
1553
+ * and chroma.
1554
+ *
1555
+ * @return Key color [Hct]
1556
+ */
1557
+ create() {
1558
+ let lowerTone = 0, upperTone = 100;
1559
+ for (; lowerTone < upperTone; ) {
1560
+ const midTone = Math.floor((lowerTone + upperTone) / 2), isAscending = this.maxChroma(midTone) < this.maxChroma(midTone + 1);
1561
+ if (this.maxChroma(midTone) >= this.requestedChroma - 0.01)
1562
+ if (Math.abs(lowerTone - 50) < Math.abs(upperTone - 50))
1563
+ upperTone = midTone;
1564
+ else {
1565
+ if (lowerTone === midTone)
1566
+ return Hct.from(this.hue, this.requestedChroma, lowerTone);
1567
+ lowerTone = midTone;
1568
+ }
1569
+ else
1570
+ isAscending ? lowerTone = midTone + 1 : upperTone = midTone;
1571
+ }
1572
+ return Hct.from(this.hue, this.requestedChroma, lowerTone);
1573
+ }
1574
+ // Find the maximum chroma for a given tone
1575
+ maxChroma(tone) {
1576
+ if (this.chromaCache.has(tone))
1577
+ return this.chromaCache.get(tone);
1578
+ const chroma = Hct.from(this.hue, this.maxChromaValue, tone).chroma;
1579
+ return this.chromaCache.set(tone, chroma), chroma;
1580
+ }
1581
+ }
1582
+ /**
1583
+ * @license
1584
+ * Copyright 2023 Google LLC
1585
+ *
1586
+ * Licensed under the Apache License, Version 2.0 (the "License");
1587
+ * you may not use this file except in compliance with the License.
1588
+ * You may obtain a copy of the License at
1589
+ *
1590
+ * http://www.apache.org/licenses/LICENSE-2.0
1591
+ *
1592
+ * Unless required by applicable law or agreed to in writing, software
1593
+ * distributed under the License is distributed on an "AS IS" BASIS,
1594
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1595
+ * See the License for the specific language governing permissions and
1596
+ * limitations under the License.
1597
+ */
1598
+ class ContrastCurve {
1599
+ /**
1600
+ * Creates a `ContrastCurve` object.
1601
+ *
1602
+ * @param low Value for contrast level -1.0
1603
+ * @param normal Value for contrast level 0.0
1604
+ * @param medium Value for contrast level 0.5
1605
+ * @param high Value for contrast level 1.0
1606
+ */
1607
+ constructor(low, normal, medium, high) {
1608
+ this.low = low, this.normal = normal, this.medium = medium, this.high = high;
1609
+ }
1610
+ /**
1611
+ * Returns the value at a given contrast level.
1612
+ *
1613
+ * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
1614
+ * is the lowest; 1.0 is the highest.
1615
+ * @return The value. For contrast ratios, a number between 1.0 and 21.0.
1616
+ */
1617
+ get(contrastLevel) {
1618
+ return contrastLevel <= -1 ? this.low : contrastLevel < 0 ? lerp(this.low, this.normal, (contrastLevel - -1) / 1) : contrastLevel < 0.5 ? lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5) : contrastLevel < 1 ? lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5) : this.high;
1619
+ }
1620
+ }
1621
+ /**
1622
+ * @license
1623
+ * Copyright 2023 Google LLC
1624
+ *
1625
+ * Licensed under the Apache License, Version 2.0 (the "License");
1626
+ * you may not use this file except in compliance with the License.
1627
+ * You may obtain a copy of the License at
1628
+ *
1629
+ * http://www.apache.org/licenses/LICENSE-2.0
1630
+ *
1631
+ * Unless required by applicable law or agreed to in writing, software
1632
+ * distributed under the License is distributed on an "AS IS" BASIS,
1633
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1634
+ * See the License for the specific language governing permissions and
1635
+ * limitations under the License.
1636
+ */
1637
+ class ToneDeltaPair {
1638
+ /**
1639
+ * Documents a constraint in tone distance between two DynamicColors.
1640
+ *
1641
+ * The polarity is an adjective that describes "A", compared to "B".
1642
+ *
1643
+ * For instance, ToneDeltaPair(A, B, 15, 'darker', 'exact') states that
1644
+ * A's tone should be exactly 15 darker than B's.
1645
+ *
1646
+ * 'relative_darker' and 'relative_lighter' describes the tone adjustment
1647
+ * relative to the surface color trend (white in light mode; black in dark
1648
+ * mode). For instance, ToneDeltaPair(A, B, 10, 'relative_lighter',
1649
+ * 'farther') states that A should be at least 10 lighter than B in light
1650
+ * mode, and at least 10 darker than B in dark mode.
1651
+ *
1652
+ * @param roleA The first role in a pair.
1653
+ * @param roleB The second role in a pair.
1654
+ * @param delta Required difference between tones. Absolute value, negative
1655
+ * values have undefined behavior.
1656
+ * @param polarity The relative relation between tones of roleA and roleB,
1657
+ * as described above.
1658
+ * @param constraint How to fulfill the tone delta pair constraint.
1659
+ * @param stayTogether Whether these two roles should stay on the same side
1660
+ * of the "awkward zone" (T50-59). This is necessary for certain cases where
1661
+ * one role has two backgrounds.
1662
+ */
1663
+ constructor(roleA, roleB, delta, polarity, stayTogether, constraint) {
1664
+ this.roleA = roleA, this.roleB = roleB, this.delta = delta, this.polarity = polarity, this.stayTogether = stayTogether, this.constraint = constraint, this.constraint = constraint ?? "exact";
1665
+ }
1666
+ }
1667
+ /**
1668
+ * @license
1669
+ * Copyright 2022 Google LLC
1670
+ *
1671
+ * Licensed under the Apache License, Version 2.0 (the "License");
1672
+ * you may not use this file except in compliance with the License.
1673
+ * You may obtain a copy of the License at
1674
+ *
1675
+ * http://www.apache.org/licenses/LICENSE-2.0
1676
+ *
1677
+ * Unless required by applicable law or agreed to in writing, software
1678
+ * distributed under the License is distributed on an "AS IS" BASIS,
1679
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1680
+ * See the License for the specific language governing permissions and
1681
+ * limitations under the License.
1682
+ */
1683
+ var Variant;
1684
+ (function(Variant2) {
1685
+ Variant2[Variant2.MONOCHROME = 0] = "MONOCHROME", Variant2[Variant2.NEUTRAL = 1] = "NEUTRAL", Variant2[Variant2.TONAL_SPOT = 2] = "TONAL_SPOT", Variant2[Variant2.VIBRANT = 3] = "VIBRANT", Variant2[Variant2.EXPRESSIVE = 4] = "EXPRESSIVE", Variant2[Variant2.FIDELITY = 5] = "FIDELITY", Variant2[Variant2.CONTENT = 6] = "CONTENT", Variant2[Variant2.RAINBOW = 7] = "RAINBOW", Variant2[Variant2.FRUIT_SALAD = 8] = "FRUIT_SALAD";
1686
+ })(Variant || (Variant = {}));
1687
+ /**
1688
+ * @license
1689
+ * Copyright 2025 Google LLC
1690
+ *
1691
+ * Licensed under the Apache License, Version 2.0 (the "License");
1692
+ * you may not use this file except in compliance with the License.
1693
+ * You may obtain a copy of the License at
1694
+ *
1695
+ * http://www.apache.org/licenses/LICENSE-2.0
1696
+ *
1697
+ * Unless required by applicable law or agreed to in writing, software
1698
+ * distributed under the License is distributed on an "AS IS" BASIS,
1699
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1700
+ * See the License for the specific language governing permissions and
1701
+ * limitations under the License.
1702
+ */
1703
+ function isFidelity(scheme) {
1704
+ return scheme.variant === Variant.FIDELITY || scheme.variant === Variant.CONTENT;
1705
+ }
1706
+ function isMonochrome(scheme) {
1707
+ return scheme.variant === Variant.MONOCHROME;
1708
+ }
1709
+ function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1710
+ let answer = tone, closestToChroma = Hct.from(hue, chroma, tone);
1711
+ if (closestToChroma.chroma < chroma) {
1712
+ let chromaPeak = closestToChroma.chroma;
1713
+ for (; closestToChroma.chroma < chroma; ) {
1714
+ answer += byDecreasingTone ? -1 : 1;
1715
+ const potentialSolution = Hct.from(hue, chroma, answer);
1716
+ if (chromaPeak > potentialSolution.chroma || Math.abs(potentialSolution.chroma - chroma) < 0.4)
1717
+ break;
1718
+ const potentialDelta = Math.abs(potentialSolution.chroma - chroma), currentDelta = Math.abs(closestToChroma.chroma - chroma);
1719
+ potentialDelta < currentDelta && (closestToChroma = potentialSolution), chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);
1720
+ }
1721
+ }
1722
+ return answer;
1723
+ }
1724
+ class ColorSpecDelegateImpl2021 {
1725
+ ////////////////////////////////////////////////////////////////
1726
+ // Main Palettes //
1727
+ ////////////////////////////////////////////////////////////////
1728
+ primaryPaletteKeyColor() {
1729
+ return DynamicColor.fromPalette({
1730
+ name: "primary_palette_key_color",
1731
+ palette: (s) => s.primaryPalette,
1732
+ tone: (s) => s.primaryPalette.keyColor.tone
1733
+ });
1734
+ }
1735
+ secondaryPaletteKeyColor() {
1736
+ return DynamicColor.fromPalette({
1737
+ name: "secondary_palette_key_color",
1738
+ palette: (s) => s.secondaryPalette,
1739
+ tone: (s) => s.secondaryPalette.keyColor.tone
1740
+ });
1741
+ }
1742
+ tertiaryPaletteKeyColor() {
1743
+ return DynamicColor.fromPalette({
1744
+ name: "tertiary_palette_key_color",
1745
+ palette: (s) => s.tertiaryPalette,
1746
+ tone: (s) => s.tertiaryPalette.keyColor.tone
1747
+ });
1748
+ }
1749
+ neutralPaletteKeyColor() {
1750
+ return DynamicColor.fromPalette({
1751
+ name: "neutral_palette_key_color",
1752
+ palette: (s) => s.neutralPalette,
1753
+ tone: (s) => s.neutralPalette.keyColor.tone
1754
+ });
1755
+ }
1756
+ neutralVariantPaletteKeyColor() {
1757
+ return DynamicColor.fromPalette({
1758
+ name: "neutral_variant_palette_key_color",
1759
+ palette: (s) => s.neutralVariantPalette,
1760
+ tone: (s) => s.neutralVariantPalette.keyColor.tone
1761
+ });
1762
+ }
1763
+ errorPaletteKeyColor() {
1764
+ return DynamicColor.fromPalette({
1765
+ name: "error_palette_key_color",
1766
+ palette: (s) => s.errorPalette,
1767
+ tone: (s) => s.errorPalette.keyColor.tone
1768
+ });
1769
+ }
1770
+ ////////////////////////////////////////////////////////////////
1771
+ // Surfaces [S] //
1772
+ ////////////////////////////////////////////////////////////////
1773
+ background() {
1774
+ return DynamicColor.fromPalette({
1775
+ name: "background",
1776
+ palette: (s) => s.neutralPalette,
1777
+ tone: (s) => s.isDark ? 6 : 98,
1778
+ isBackground: !0
1779
+ });
1780
+ }
1781
+ onBackground() {
1782
+ return DynamicColor.fromPalette({
1783
+ name: "on_background",
1784
+ palette: (s) => s.neutralPalette,
1785
+ tone: (s) => s.isDark ? 90 : 10,
1786
+ background: (s) => this.background(),
1787
+ contrastCurve: (s) => new ContrastCurve(3, 3, 4.5, 7)
1788
+ });
1789
+ }
1790
+ surface() {
1791
+ return DynamicColor.fromPalette({
1792
+ name: "surface",
1793
+ palette: (s) => s.neutralPalette,
1794
+ tone: (s) => s.isDark ? 6 : 98,
1795
+ isBackground: !0
1796
+ });
1797
+ }
1798
+ surfaceDim() {
1799
+ return DynamicColor.fromPalette({
1800
+ name: "surface_dim",
1801
+ palette: (s) => s.neutralPalette,
1802
+ tone: (s) => s.isDark ? 6 : new ContrastCurve(87, 87, 80, 75).get(s.contrastLevel),
1803
+ isBackground: !0
1804
+ });
1805
+ }
1806
+ surfaceBright() {
1807
+ return DynamicColor.fromPalette({
1808
+ name: "surface_bright",
1809
+ palette: (s) => s.neutralPalette,
1810
+ tone: (s) => s.isDark ? new ContrastCurve(24, 24, 29, 34).get(s.contrastLevel) : 98,
1811
+ isBackground: !0
1812
+ });
1813
+ }
1814
+ surfaceContainerLowest() {
1815
+ return DynamicColor.fromPalette({
1816
+ name: "surface_container_lowest",
1817
+ palette: (s) => s.neutralPalette,
1818
+ tone: (s) => s.isDark ? new ContrastCurve(4, 4, 2, 0).get(s.contrastLevel) : 100,
1819
+ isBackground: !0
1820
+ });
1821
+ }
1822
+ surfaceContainerLow() {
1823
+ return DynamicColor.fromPalette({
1824
+ name: "surface_container_low",
1825
+ palette: (s) => s.neutralPalette,
1826
+ tone: (s) => s.isDark ? new ContrastCurve(10, 10, 11, 12).get(s.contrastLevel) : new ContrastCurve(96, 96, 96, 95).get(s.contrastLevel),
1827
+ isBackground: !0
1828
+ });
1829
+ }
1830
+ surfaceContainer() {
1831
+ return DynamicColor.fromPalette({
1832
+ name: "surface_container",
1833
+ palette: (s) => s.neutralPalette,
1834
+ tone: (s) => s.isDark ? new ContrastCurve(12, 12, 16, 20).get(s.contrastLevel) : new ContrastCurve(94, 94, 92, 90).get(s.contrastLevel),
1835
+ isBackground: !0
1836
+ });
1837
+ }
1838
+ surfaceContainerHigh() {
1839
+ return DynamicColor.fromPalette({
1840
+ name: "surface_container_high",
1841
+ palette: (s) => s.neutralPalette,
1842
+ tone: (s) => s.isDark ? new ContrastCurve(17, 17, 21, 25).get(s.contrastLevel) : new ContrastCurve(92, 92, 88, 85).get(s.contrastLevel),
1843
+ isBackground: !0
1844
+ });
1845
+ }
1846
+ surfaceContainerHighest() {
1847
+ return DynamicColor.fromPalette({
1848
+ name: "surface_container_highest",
1849
+ palette: (s) => s.neutralPalette,
1850
+ tone: (s) => s.isDark ? new ContrastCurve(22, 22, 26, 30).get(s.contrastLevel) : new ContrastCurve(90, 90, 84, 80).get(s.contrastLevel),
1851
+ isBackground: !0
1852
+ });
1853
+ }
1854
+ onSurface() {
1855
+ return DynamicColor.fromPalette({
1856
+ name: "on_surface",
1857
+ palette: (s) => s.neutralPalette,
1858
+ tone: (s) => s.isDark ? 90 : 10,
1859
+ background: (s) => this.highestSurface(s),
1860
+ contrastCurve: (s) => new ContrastCurve(4.5, 7, 11, 21)
1861
+ });
1862
+ }
1863
+ surfaceVariant() {
1864
+ return DynamicColor.fromPalette({
1865
+ name: "surface_variant",
1866
+ palette: (s) => s.neutralVariantPalette,
1867
+ tone: (s) => s.isDark ? 30 : 90,
1868
+ isBackground: !0
1869
+ });
1870
+ }
1871
+ onSurfaceVariant() {
1872
+ return DynamicColor.fromPalette({
1873
+ name: "on_surface_variant",
1874
+ palette: (s) => s.neutralVariantPalette,
1875
+ tone: (s) => s.isDark ? 80 : 30,
1876
+ background: (s) => this.highestSurface(s),
1877
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 11)
1878
+ });
1879
+ }
1880
+ inverseSurface() {
1881
+ return DynamicColor.fromPalette({
1882
+ name: "inverse_surface",
1883
+ palette: (s) => s.neutralPalette,
1884
+ tone: (s) => s.isDark ? 90 : 20,
1885
+ isBackground: !0
1886
+ });
1887
+ }
1888
+ inverseOnSurface() {
1889
+ return DynamicColor.fromPalette({
1890
+ name: "inverse_on_surface",
1891
+ palette: (s) => s.neutralPalette,
1892
+ tone: (s) => s.isDark ? 20 : 95,
1893
+ background: (s) => this.inverseSurface(),
1894
+ contrastCurve: (s) => new ContrastCurve(4.5, 7, 11, 21)
1895
+ });
1896
+ }
1897
+ outline() {
1898
+ return DynamicColor.fromPalette({
1899
+ name: "outline",
1900
+ palette: (s) => s.neutralVariantPalette,
1901
+ tone: (s) => s.isDark ? 60 : 50,
1902
+ background: (s) => this.highestSurface(s),
1903
+ contrastCurve: (s) => new ContrastCurve(1.5, 3, 4.5, 7)
1904
+ });
1905
+ }
1906
+ outlineVariant() {
1907
+ return DynamicColor.fromPalette({
1908
+ name: "outline_variant",
1909
+ palette: (s) => s.neutralVariantPalette,
1910
+ tone: (s) => s.isDark ? 30 : 80,
1911
+ background: (s) => this.highestSurface(s),
1912
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5)
1913
+ });
1914
+ }
1915
+ shadow() {
1916
+ return DynamicColor.fromPalette({
1917
+ name: "shadow",
1918
+ palette: (s) => s.neutralPalette,
1919
+ tone: (s) => 0
1920
+ });
1921
+ }
1922
+ scrim() {
1923
+ return DynamicColor.fromPalette({
1924
+ name: "scrim",
1925
+ palette: (s) => s.neutralPalette,
1926
+ tone: (s) => 0
1927
+ });
1928
+ }
1929
+ surfaceTint() {
1930
+ return DynamicColor.fromPalette({
1931
+ name: "surface_tint",
1932
+ palette: (s) => s.primaryPalette,
1933
+ tone: (s) => s.isDark ? 80 : 40,
1934
+ isBackground: !0
1935
+ });
1936
+ }
1937
+ ////////////////////////////////////////////////////////////////
1938
+ // Primary [P]. //
1939
+ ////////////////////////////////////////////////////////////////
1940
+ primary() {
1941
+ return DynamicColor.fromPalette({
1942
+ name: "primary",
1943
+ palette: (s) => s.primaryPalette,
1944
+ tone: (s) => isMonochrome(s) ? s.isDark ? 100 : 0 : s.isDark ? 80 : 40,
1945
+ isBackground: !0,
1946
+ background: (s) => this.highestSurface(s),
1947
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 7),
1948
+ toneDeltaPair: (s) => new ToneDeltaPair(this.primaryContainer(), this.primary(), 10, "nearer", !1)
1949
+ });
1950
+ }
1951
+ primaryDim() {
1952
+ }
1953
+ onPrimary() {
1954
+ return DynamicColor.fromPalette({
1955
+ name: "on_primary",
1956
+ palette: (s) => s.primaryPalette,
1957
+ tone: (s) => isMonochrome(s) ? s.isDark ? 10 : 90 : s.isDark ? 20 : 100,
1958
+ background: (s) => this.primary(),
1959
+ contrastCurve: (s) => new ContrastCurve(4.5, 7, 11, 21)
1960
+ });
1961
+ }
1962
+ primaryContainer() {
1963
+ return DynamicColor.fromPalette({
1964
+ name: "primary_container",
1965
+ palette: (s) => s.primaryPalette,
1966
+ tone: (s) => isFidelity(s) ? s.sourceColorHct.tone : isMonochrome(s) ? s.isDark ? 85 : 25 : s.isDark ? 30 : 90,
1967
+ isBackground: !0,
1968
+ background: (s) => this.highestSurface(s),
1969
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
1970
+ toneDeltaPair: (s) => new ToneDeltaPair(this.primaryContainer(), this.primary(), 10, "nearer", !1)
1971
+ });
1972
+ }
1973
+ onPrimaryContainer() {
1974
+ return DynamicColor.fromPalette({
1975
+ name: "on_primary_container",
1976
+ palette: (s) => s.primaryPalette,
1977
+ tone: (s) => isFidelity(s) ? DynamicColor.foregroundTone(this.primaryContainer().tone(s), 4.5) : isMonochrome(s) ? s.isDark ? 0 : 100 : s.isDark ? 90 : 30,
1978
+ background: (s) => this.primaryContainer(),
1979
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 11)
1980
+ });
1981
+ }
1982
+ inversePrimary() {
1983
+ return DynamicColor.fromPalette({
1984
+ name: "inverse_primary",
1985
+ palette: (s) => s.primaryPalette,
1986
+ tone: (s) => s.isDark ? 40 : 80,
1987
+ background: (s) => this.inverseSurface(),
1988
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 7)
1989
+ });
1990
+ }
1991
+ /////////////////////////////////////////////////////////////////
1992
+ // Secondary [Q]. //
1993
+ /////////////////////////////////////////////////////////////////
1994
+ secondary() {
1995
+ return DynamicColor.fromPalette({
1996
+ name: "secondary",
1997
+ palette: (s) => s.secondaryPalette,
1998
+ tone: (s) => s.isDark ? 80 : 40,
1999
+ isBackground: !0,
2000
+ background: (s) => this.highestSurface(s),
2001
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 7),
2002
+ toneDeltaPair: (s) => new ToneDeltaPair(this.secondaryContainer(), this.secondary(), 10, "nearer", !1)
2003
+ });
2004
+ }
2005
+ secondaryDim() {
2006
+ }
2007
+ onSecondary() {
2008
+ return DynamicColor.fromPalette({
2009
+ name: "on_secondary",
2010
+ palette: (s) => s.secondaryPalette,
2011
+ tone: (s) => isMonochrome(s) ? s.isDark ? 10 : 100 : s.isDark ? 20 : 100,
2012
+ background: (s) => this.secondary(),
2013
+ contrastCurve: (s) => new ContrastCurve(4.5, 7, 11, 21)
2014
+ });
2015
+ }
2016
+ secondaryContainer() {
2017
+ return DynamicColor.fromPalette({
2018
+ name: "secondary_container",
2019
+ palette: (s) => s.secondaryPalette,
2020
+ tone: (s) => {
2021
+ const initialTone = s.isDark ? 30 : 90;
2022
+ return isMonochrome(s) ? s.isDark ? 30 : 85 : isFidelity(s) ? findDesiredChromaByTone(s.secondaryPalette.hue, s.secondaryPalette.chroma, initialTone, !s.isDark) : initialTone;
2023
+ },
2024
+ isBackground: !0,
2025
+ background: (s) => this.highestSurface(s),
2026
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
2027
+ toneDeltaPair: (s) => new ToneDeltaPair(this.secondaryContainer(), this.secondary(), 10, "nearer", !1)
2028
+ });
2029
+ }
2030
+ onSecondaryContainer() {
2031
+ return DynamicColor.fromPalette({
2032
+ name: "on_secondary_container",
2033
+ palette: (s) => s.secondaryPalette,
2034
+ tone: (s) => isMonochrome(s) ? s.isDark ? 90 : 10 : isFidelity(s) ? DynamicColor.foregroundTone(this.secondaryContainer().tone(s), 4.5) : s.isDark ? 90 : 30,
2035
+ background: (s) => this.secondaryContainer(),
2036
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 11)
2037
+ });
2038
+ }
2039
+ /////////////////////////////////////////////////////////////////
2040
+ // Tertiary [T]. //
2041
+ /////////////////////////////////////////////////////////////////
2042
+ tertiary() {
2043
+ return DynamicColor.fromPalette({
2044
+ name: "tertiary",
2045
+ palette: (s) => s.tertiaryPalette,
2046
+ tone: (s) => isMonochrome(s) ? s.isDark ? 90 : 25 : s.isDark ? 80 : 40,
2047
+ isBackground: !0,
2048
+ background: (s) => this.highestSurface(s),
2049
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 7),
2050
+ toneDeltaPair: (s) => new ToneDeltaPair(this.tertiaryContainer(), this.tertiary(), 10, "nearer", !1)
2051
+ });
2052
+ }
2053
+ tertiaryDim() {
2054
+ }
2055
+ onTertiary() {
2056
+ return DynamicColor.fromPalette({
2057
+ name: "on_tertiary",
2058
+ palette: (s) => s.tertiaryPalette,
2059
+ tone: (s) => isMonochrome(s) ? s.isDark ? 10 : 90 : s.isDark ? 20 : 100,
2060
+ background: (s) => this.tertiary(),
2061
+ contrastCurve: (s) => new ContrastCurve(4.5, 7, 11, 21)
2062
+ });
2063
+ }
2064
+ tertiaryContainer() {
2065
+ return DynamicColor.fromPalette({
2066
+ name: "tertiary_container",
2067
+ palette: (s) => s.tertiaryPalette,
2068
+ tone: (s) => {
2069
+ if (isMonochrome(s))
2070
+ return s.isDark ? 60 : 49;
2071
+ if (!isFidelity(s))
2072
+ return s.isDark ? 30 : 90;
2073
+ const proposedHct = s.tertiaryPalette.getHct(s.sourceColorHct.tone);
2074
+ return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
2075
+ },
2076
+ isBackground: !0,
2077
+ background: (s) => this.highestSurface(s),
2078
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
2079
+ toneDeltaPair: (s) => new ToneDeltaPair(this.tertiaryContainer(), this.tertiary(), 10, "nearer", !1)
2080
+ });
2081
+ }
2082
+ onTertiaryContainer() {
2083
+ return DynamicColor.fromPalette({
2084
+ name: "on_tertiary_container",
2085
+ palette: (s) => s.tertiaryPalette,
2086
+ tone: (s) => isMonochrome(s) ? s.isDark ? 0 : 100 : isFidelity(s) ? DynamicColor.foregroundTone(this.tertiaryContainer().tone(s), 4.5) : s.isDark ? 90 : 30,
2087
+ background: (s) => this.tertiaryContainer(),
2088
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 11)
2089
+ });
2090
+ }
2091
+ //////////////////////////////////////////////////////////////////
2092
+ // Error [E]. //
2093
+ //////////////////////////////////////////////////////////////////
2094
+ error() {
2095
+ return DynamicColor.fromPalette({
2096
+ name: "error",
2097
+ palette: (s) => s.errorPalette,
2098
+ tone: (s) => s.isDark ? 80 : 40,
2099
+ isBackground: !0,
2100
+ background: (s) => this.highestSurface(s),
2101
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 7),
2102
+ toneDeltaPair: (s) => new ToneDeltaPair(this.errorContainer(), this.error(), 10, "nearer", !1)
2103
+ });
2104
+ }
2105
+ errorDim() {
2106
+ }
2107
+ onError() {
2108
+ return DynamicColor.fromPalette({
2109
+ name: "on_error",
2110
+ palette: (s) => s.errorPalette,
2111
+ tone: (s) => s.isDark ? 20 : 100,
2112
+ background: (s) => this.error(),
2113
+ contrastCurve: (s) => new ContrastCurve(4.5, 7, 11, 21)
2114
+ });
2115
+ }
2116
+ errorContainer() {
2117
+ return DynamicColor.fromPalette({
2118
+ name: "error_container",
2119
+ palette: (s) => s.errorPalette,
2120
+ tone: (s) => s.isDark ? 30 : 90,
2121
+ isBackground: !0,
2122
+ background: (s) => this.highestSurface(s),
2123
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
2124
+ toneDeltaPair: (s) => new ToneDeltaPair(this.errorContainer(), this.error(), 10, "nearer", !1)
2125
+ });
2126
+ }
2127
+ onErrorContainer() {
2128
+ return DynamicColor.fromPalette({
2129
+ name: "on_error_container",
2130
+ palette: (s) => s.errorPalette,
2131
+ tone: (s) => isMonochrome(s) ? s.isDark ? 90 : 10 : s.isDark ? 90 : 30,
2132
+ background: (s) => this.errorContainer(),
2133
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 11)
2134
+ });
2135
+ }
2136
+ //////////////////////////////////////////////////////////////////
2137
+ // Primary Fixed [PF] //
2138
+ //////////////////////////////////////////////////////////////////
2139
+ primaryFixed() {
2140
+ return DynamicColor.fromPalette({
2141
+ name: "primary_fixed",
2142
+ palette: (s) => s.primaryPalette,
2143
+ tone: (s) => isMonochrome(s) ? 40 : 90,
2144
+ isBackground: !0,
2145
+ background: (s) => this.highestSurface(s),
2146
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
2147
+ toneDeltaPair: (s) => new ToneDeltaPair(this.primaryFixed(), this.primaryFixedDim(), 10, "lighter", !0)
2148
+ });
2149
+ }
2150
+ primaryFixedDim() {
2151
+ return DynamicColor.fromPalette({
2152
+ name: "primary_fixed_dim",
2153
+ palette: (s) => s.primaryPalette,
2154
+ tone: (s) => isMonochrome(s) ? 30 : 80,
2155
+ isBackground: !0,
2156
+ background: (s) => this.highestSurface(s),
2157
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
2158
+ toneDeltaPair: (s) => new ToneDeltaPair(this.primaryFixed(), this.primaryFixedDim(), 10, "lighter", !0)
2159
+ });
2160
+ }
2161
+ onPrimaryFixed() {
2162
+ return DynamicColor.fromPalette({
2163
+ name: "on_primary_fixed",
2164
+ palette: (s) => s.primaryPalette,
2165
+ tone: (s) => isMonochrome(s) ? 100 : 10,
2166
+ background: (s) => this.primaryFixedDim(),
2167
+ secondBackground: (s) => this.primaryFixed(),
2168
+ contrastCurve: (s) => new ContrastCurve(4.5, 7, 11, 21)
2169
+ });
2170
+ }
2171
+ onPrimaryFixedVariant() {
2172
+ return DynamicColor.fromPalette({
2173
+ name: "on_primary_fixed_variant",
2174
+ palette: (s) => s.primaryPalette,
2175
+ tone: (s) => isMonochrome(s) ? 90 : 30,
2176
+ background: (s) => this.primaryFixedDim(),
2177
+ secondBackground: (s) => this.primaryFixed(),
2178
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 11)
2179
+ });
2180
+ }
2181
+ ///////////////////////////////////////////////////////////////////
2182
+ // Secondary Fixed [QF] //
2183
+ ///////////////////////////////////////////////////////////////////
2184
+ secondaryFixed() {
2185
+ return DynamicColor.fromPalette({
2186
+ name: "secondary_fixed",
2187
+ palette: (s) => s.secondaryPalette,
2188
+ tone: (s) => isMonochrome(s) ? 80 : 90,
2189
+ isBackground: !0,
2190
+ background: (s) => this.highestSurface(s),
2191
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
2192
+ toneDeltaPair: (s) => new ToneDeltaPair(this.secondaryFixed(), this.secondaryFixedDim(), 10, "lighter", !0)
2193
+ });
2194
+ }
2195
+ secondaryFixedDim() {
2196
+ return DynamicColor.fromPalette({
2197
+ name: "secondary_fixed_dim",
2198
+ palette: (s) => s.secondaryPalette,
2199
+ tone: (s) => isMonochrome(s) ? 70 : 80,
2200
+ isBackground: !0,
2201
+ background: (s) => this.highestSurface(s),
2202
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
2203
+ toneDeltaPair: (s) => new ToneDeltaPair(this.secondaryFixed(), this.secondaryFixedDim(), 10, "lighter", !0)
2204
+ });
2205
+ }
2206
+ onSecondaryFixed() {
2207
+ return DynamicColor.fromPalette({
2208
+ name: "on_secondary_fixed",
2209
+ palette: (s) => s.secondaryPalette,
2210
+ tone: (s) => 10,
2211
+ background: (s) => this.secondaryFixedDim(),
2212
+ secondBackground: (s) => this.secondaryFixed(),
2213
+ contrastCurve: (s) => new ContrastCurve(4.5, 7, 11, 21)
2214
+ });
2215
+ }
2216
+ onSecondaryFixedVariant() {
2217
+ return DynamicColor.fromPalette({
2218
+ name: "on_secondary_fixed_variant",
2219
+ palette: (s) => s.secondaryPalette,
2220
+ tone: (s) => isMonochrome(s) ? 25 : 30,
2221
+ background: (s) => this.secondaryFixedDim(),
2222
+ secondBackground: (s) => this.secondaryFixed(),
2223
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 11)
2224
+ });
2225
+ }
2226
+ /////////////////////////////////////////////////////////////////
2227
+ // Tertiary Fixed [TF] //
2228
+ /////////////////////////////////////////////////////////////////
2229
+ tertiaryFixed() {
2230
+ return DynamicColor.fromPalette({
2231
+ name: "tertiary_fixed",
2232
+ palette: (s) => s.tertiaryPalette,
2233
+ tone: (s) => isMonochrome(s) ? 40 : 90,
2234
+ isBackground: !0,
2235
+ background: (s) => this.highestSurface(s),
2236
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
2237
+ toneDeltaPair: (s) => new ToneDeltaPair(this.tertiaryFixed(), this.tertiaryFixedDim(), 10, "lighter", !0)
2238
+ });
2239
+ }
2240
+ tertiaryFixedDim() {
2241
+ return DynamicColor.fromPalette({
2242
+ name: "tertiary_fixed_dim",
2243
+ palette: (s) => s.tertiaryPalette,
2244
+ tone: (s) => isMonochrome(s) ? 30 : 80,
2245
+ isBackground: !0,
2246
+ background: (s) => this.highestSurface(s),
2247
+ contrastCurve: (s) => new ContrastCurve(1, 1, 3, 4.5),
2248
+ toneDeltaPair: (s) => new ToneDeltaPair(this.tertiaryFixed(), this.tertiaryFixedDim(), 10, "lighter", !0)
2249
+ });
2250
+ }
2251
+ onTertiaryFixed() {
2252
+ return DynamicColor.fromPalette({
2253
+ name: "on_tertiary_fixed",
2254
+ palette: (s) => s.tertiaryPalette,
2255
+ tone: (s) => isMonochrome(s) ? 100 : 10,
2256
+ background: (s) => this.tertiaryFixedDim(),
2257
+ secondBackground: (s) => this.tertiaryFixed(),
2258
+ contrastCurve: (s) => new ContrastCurve(4.5, 7, 11, 21)
2259
+ });
2260
+ }
2261
+ onTertiaryFixedVariant() {
2262
+ return DynamicColor.fromPalette({
2263
+ name: "on_tertiary_fixed_variant",
2264
+ palette: (s) => s.tertiaryPalette,
2265
+ tone: (s) => isMonochrome(s) ? 90 : 30,
2266
+ background: (s) => this.tertiaryFixedDim(),
2267
+ secondBackground: (s) => this.tertiaryFixed(),
2268
+ contrastCurve: (s) => new ContrastCurve(3, 4.5, 7, 11)
2269
+ });
2270
+ }
2271
+ ////////////////////////////////////////////////////////////////
2272
+ // Other //
2273
+ ////////////////////////////////////////////////////////////////
2274
+ highestSurface(s) {
2275
+ return s.isDark ? this.surfaceBright() : this.surfaceDim();
2276
+ }
2277
+ }
2278
+ /**
2279
+ * @license
2280
+ * Copyright 2025 Google LLC
2281
+ *
2282
+ * Licensed under the Apache License, Version 2.0 (the "License");
2283
+ * you may not use this file except in compliance with the License.
2284
+ * You may obtain a copy of the License at
2285
+ *
2286
+ * http://www.apache.org/licenses/LICENSE-2.0
2287
+ *
2288
+ * Unless required by applicable law or agreed to in writing, software
2289
+ * distributed under the License is distributed on an "AS IS" BASIS,
2290
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2291
+ * See the License for the specific language governing permissions and
2292
+ * limitations under the License.
2293
+ */
2294
+ function tMaxC(palette, lowerBound = 0, upperBound = 100, chromaMultiplier = 1) {
2295
+ let answer = findBestToneForChroma(palette.hue, palette.chroma * chromaMultiplier, 100, !0);
2296
+ return clampDouble(lowerBound, upperBound, answer);
2297
+ }
2298
+ function tMinC(palette, lowerBound = 0, upperBound = 100) {
2299
+ let answer = findBestToneForChroma(palette.hue, palette.chroma, 0, !1);
2300
+ return clampDouble(lowerBound, upperBound, answer);
2301
+ }
2302
+ function findBestToneForChroma(hue, chroma, tone, byDecreasingTone) {
2303
+ let answer = tone, bestCandidate = Hct.from(hue, chroma, answer);
2304
+ for (; bestCandidate.chroma < chroma && !(tone < 0 || tone > 100); ) {
2305
+ tone += byDecreasingTone ? -1 : 1;
2306
+ const newCandidate = Hct.from(hue, chroma, tone);
2307
+ bestCandidate.chroma < newCandidate.chroma && (bestCandidate = newCandidate, answer = tone);
2308
+ }
2309
+ return answer;
2310
+ }
2311
+ function getCurve(defaultContrast) {
2312
+ return defaultContrast === 1.5 ? new ContrastCurve(1.5, 1.5, 3, 5.5) : defaultContrast === 3 ? new ContrastCurve(3, 3, 4.5, 7) : defaultContrast === 4.5 ? new ContrastCurve(4.5, 4.5, 7, 11) : defaultContrast === 6 ? new ContrastCurve(6, 6, 7, 11) : defaultContrast === 7 ? new ContrastCurve(7, 7, 11, 21) : defaultContrast === 9 ? new ContrastCurve(9, 9, 11, 21) : defaultContrast === 11 ? new ContrastCurve(11, 11, 21, 21) : defaultContrast === 21 ? new ContrastCurve(21, 21, 21, 21) : new ContrastCurve(defaultContrast, defaultContrast, 7, 21);
2313
+ }
2314
+ class ColorSpecDelegateImpl2025 extends ColorSpecDelegateImpl2021 {
2315
+ ////////////////////////////////////////////////////////////////
2316
+ // Surfaces [S] //
2317
+ ////////////////////////////////////////////////////////////////
2318
+ surface() {
2319
+ const color2025 = DynamicColor.fromPalette({
2320
+ name: "surface",
2321
+ palette: (s) => s.neutralPalette,
2322
+ tone: (s) => (super.surface().tone(s), s.platform === "phone" ? s.isDark ? 4 : Hct.isYellow(s.neutralPalette.hue) ? 99 : s.variant === Variant.VIBRANT ? 97 : 98 : 0),
2323
+ isBackground: !0
2324
+ });
2325
+ return extendSpecVersion(super.surface(), "2025", color2025);
2326
+ }
2327
+ surfaceDim() {
2328
+ const color2025 = DynamicColor.fromPalette({
2329
+ name: "surface_dim",
2330
+ palette: (s) => s.neutralPalette,
2331
+ tone: (s) => s.isDark ? 4 : Hct.isYellow(s.neutralPalette.hue) ? 90 : s.variant === Variant.VIBRANT ? 85 : 87,
2332
+ isBackground: !0,
2333
+ chromaMultiplier: (s) => {
2334
+ if (!s.isDark) {
2335
+ if (s.variant === Variant.NEUTRAL)
2336
+ return 2.5;
2337
+ if (s.variant === Variant.TONAL_SPOT)
2338
+ return 1.7;
2339
+ if (s.variant === Variant.EXPRESSIVE)
2340
+ return Hct.isYellow(s.neutralPalette.hue) ? 2.7 : 1.75;
2341
+ if (s.variant === Variant.VIBRANT)
2342
+ return 1.36;
2343
+ }
2344
+ return 1;
2345
+ }
2346
+ });
2347
+ return extendSpecVersion(super.surfaceDim(), "2025", color2025);
2348
+ }
2349
+ surfaceBright() {
2350
+ const color2025 = DynamicColor.fromPalette({
2351
+ name: "surface_bright",
2352
+ palette: (s) => s.neutralPalette,
2353
+ tone: (s) => s.isDark ? 18 : Hct.isYellow(s.neutralPalette.hue) ? 99 : s.variant === Variant.VIBRANT ? 97 : 98,
2354
+ isBackground: !0,
2355
+ chromaMultiplier: (s) => {
2356
+ if (s.isDark) {
2357
+ if (s.variant === Variant.NEUTRAL)
2358
+ return 2.5;
2359
+ if (s.variant === Variant.TONAL_SPOT)
2360
+ return 1.7;
2361
+ if (s.variant === Variant.EXPRESSIVE)
2362
+ return Hct.isYellow(s.neutralPalette.hue) ? 2.7 : 1.75;
2363
+ if (s.variant === Variant.VIBRANT)
2364
+ return 1.36;
2365
+ }
2366
+ return 1;
2367
+ }
2368
+ });
2369
+ return extendSpecVersion(super.surfaceBright(), "2025", color2025);
2370
+ }
2371
+ surfaceContainerLowest() {
2372
+ const color2025 = DynamicColor.fromPalette({
2373
+ name: "surface_container_lowest",
2374
+ palette: (s) => s.neutralPalette,
2375
+ tone: (s) => s.isDark ? 0 : 100,
2376
+ isBackground: !0
2377
+ });
2378
+ return extendSpecVersion(super.surfaceContainerLowest(), "2025", color2025);
2379
+ }
2380
+ surfaceContainerLow() {
2381
+ const color2025 = DynamicColor.fromPalette({
2382
+ name: "surface_container_low",
2383
+ palette: (s) => s.neutralPalette,
2384
+ tone: (s) => s.platform === "phone" ? s.isDark ? 6 : Hct.isYellow(s.neutralPalette.hue) ? 98 : s.variant === Variant.VIBRANT ? 95 : 96 : 15,
2385
+ isBackground: !0,
2386
+ chromaMultiplier: (s) => {
2387
+ if (s.platform === "phone") {
2388
+ if (s.variant === Variant.NEUTRAL)
2389
+ return 1.3;
2390
+ if (s.variant === Variant.TONAL_SPOT)
2391
+ return 1.25;
2392
+ if (s.variant === Variant.EXPRESSIVE)
2393
+ return Hct.isYellow(s.neutralPalette.hue) ? 1.3 : 1.15;
2394
+ if (s.variant === Variant.VIBRANT)
2395
+ return 1.08;
2396
+ }
2397
+ return 1;
2398
+ }
2399
+ });
2400
+ return extendSpecVersion(super.surfaceContainerLow(), "2025", color2025);
2401
+ }
2402
+ surfaceContainer() {
2403
+ const color2025 = DynamicColor.fromPalette({
2404
+ name: "surface_container",
2405
+ palette: (s) => s.neutralPalette,
2406
+ tone: (s) => s.platform === "phone" ? s.isDark ? 9 : Hct.isYellow(s.neutralPalette.hue) ? 96 : s.variant === Variant.VIBRANT ? 92 : 94 : 20,
2407
+ isBackground: !0,
2408
+ chromaMultiplier: (s) => {
2409
+ if (s.platform === "phone") {
2410
+ if (s.variant === Variant.NEUTRAL)
2411
+ return 1.6;
2412
+ if (s.variant === Variant.TONAL_SPOT)
2413
+ return 1.4;
2414
+ if (s.variant === Variant.EXPRESSIVE)
2415
+ return Hct.isYellow(s.neutralPalette.hue) ? 1.6 : 1.3;
2416
+ if (s.variant === Variant.VIBRANT)
2417
+ return 1.15;
2418
+ }
2419
+ return 1;
2420
+ }
2421
+ });
2422
+ return extendSpecVersion(super.surfaceContainer(), "2025", color2025);
2423
+ }
2424
+ surfaceContainerHigh() {
2425
+ const color2025 = DynamicColor.fromPalette({
2426
+ name: "surface_container_high",
2427
+ palette: (s) => s.neutralPalette,
2428
+ tone: (s) => s.platform === "phone" ? s.isDark ? 12 : Hct.isYellow(s.neutralPalette.hue) ? 94 : s.variant === Variant.VIBRANT ? 90 : 92 : 25,
2429
+ isBackground: !0,
2430
+ chromaMultiplier: (s) => {
2431
+ if (s.platform === "phone") {
2432
+ if (s.variant === Variant.NEUTRAL)
2433
+ return 1.9;
2434
+ if (s.variant === Variant.TONAL_SPOT)
2435
+ return 1.5;
2436
+ if (s.variant === Variant.EXPRESSIVE)
2437
+ return Hct.isYellow(s.neutralPalette.hue) ? 1.95 : 1.45;
2438
+ if (s.variant === Variant.VIBRANT)
2439
+ return 1.22;
2440
+ }
2441
+ return 1;
2442
+ }
2443
+ });
2444
+ return extendSpecVersion(super.surfaceContainerHigh(), "2025", color2025);
2445
+ }
2446
+ surfaceContainerHighest() {
2447
+ const color2025 = DynamicColor.fromPalette({
2448
+ name: "surface_container_highest",
2449
+ palette: (s) => s.neutralPalette,
2450
+ tone: (s) => s.isDark ? 15 : Hct.isYellow(s.neutralPalette.hue) ? 92 : s.variant === Variant.VIBRANT ? 88 : 90,
2451
+ isBackground: !0,
2452
+ chromaMultiplier: (s) => s.variant === Variant.NEUTRAL ? 2.2 : s.variant === Variant.TONAL_SPOT ? 1.7 : s.variant === Variant.EXPRESSIVE ? Hct.isYellow(s.neutralPalette.hue) ? 2.3 : 1.6 : s.variant === Variant.VIBRANT ? 1.29 : 1
2453
+ });
2454
+ return extendSpecVersion(super.surfaceContainerHighest(), "2025", color2025);
2455
+ }
2456
+ onSurface() {
2457
+ const color2025 = DynamicColor.fromPalette({
2458
+ name: "on_surface",
2459
+ palette: (s) => s.neutralPalette,
2460
+ tone: (s) => s.variant === Variant.VIBRANT ? tMaxC(s.neutralPalette, 0, 100, 1.1) : DynamicColor.getInitialToneFromBackground((s2) => s2.platform === "phone" ? this.highestSurface(s2) : this.surfaceContainerHigh())(s),
2461
+ chromaMultiplier: (s) => {
2462
+ if (s.platform === "phone") {
2463
+ if (s.variant === Variant.NEUTRAL)
2464
+ return 2.2;
2465
+ if (s.variant === Variant.TONAL_SPOT)
2466
+ return 1.7;
2467
+ if (s.variant === Variant.EXPRESSIVE)
2468
+ return Hct.isYellow(s.neutralPalette.hue) ? s.isDark ? 3 : 2.3 : 1.6;
2469
+ }
2470
+ return 1;
2471
+ },
2472
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : this.surfaceContainerHigh(),
2473
+ contrastCurve: (s) => s.isDark && s.platform === "phone" ? getCurve(11) : getCurve(9)
2474
+ });
2475
+ return extendSpecVersion(super.onSurface(), "2025", color2025);
2476
+ }
2477
+ onSurfaceVariant() {
2478
+ const color2025 = DynamicColor.fromPalette({
2479
+ name: "on_surface_variant",
2480
+ palette: (s) => s.neutralPalette,
2481
+ chromaMultiplier: (s) => {
2482
+ if (s.platform === "phone") {
2483
+ if (s.variant === Variant.NEUTRAL)
2484
+ return 2.2;
2485
+ if (s.variant === Variant.TONAL_SPOT)
2486
+ return 1.7;
2487
+ if (s.variant === Variant.EXPRESSIVE)
2488
+ return Hct.isYellow(s.neutralPalette.hue) ? s.isDark ? 3 : 2.3 : 1.6;
2489
+ }
2490
+ return 1;
2491
+ },
2492
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : this.surfaceContainerHigh(),
2493
+ contrastCurve: (s) => s.platform === "phone" ? s.isDark ? getCurve(6) : getCurve(4.5) : getCurve(7)
2494
+ });
2495
+ return extendSpecVersion(super.onSurfaceVariant(), "2025", color2025);
2496
+ }
2497
+ outline() {
2498
+ const color2025 = DynamicColor.fromPalette({
2499
+ name: "outline",
2500
+ palette: (s) => s.neutralPalette,
2501
+ chromaMultiplier: (s) => {
2502
+ if (s.platform === "phone") {
2503
+ if (s.variant === Variant.NEUTRAL)
2504
+ return 2.2;
2505
+ if (s.variant === Variant.TONAL_SPOT)
2506
+ return 1.7;
2507
+ if (s.variant === Variant.EXPRESSIVE)
2508
+ return Hct.isYellow(s.neutralPalette.hue) ? s.isDark ? 3 : 2.3 : 1.6;
2509
+ }
2510
+ return 1;
2511
+ },
2512
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : this.surfaceContainerHigh(),
2513
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(3) : getCurve(4.5)
2514
+ });
2515
+ return extendSpecVersion(super.outline(), "2025", color2025);
2516
+ }
2517
+ outlineVariant() {
2518
+ const color2025 = DynamicColor.fromPalette({
2519
+ name: "outline_variant",
2520
+ palette: (s) => s.neutralPalette,
2521
+ chromaMultiplier: (s) => {
2522
+ if (s.platform === "phone") {
2523
+ if (s.variant === Variant.NEUTRAL)
2524
+ return 2.2;
2525
+ if (s.variant === Variant.TONAL_SPOT)
2526
+ return 1.7;
2527
+ if (s.variant === Variant.EXPRESSIVE)
2528
+ return Hct.isYellow(s.neutralPalette.hue) ? s.isDark ? 3 : 2.3 : 1.6;
2529
+ }
2530
+ return 1;
2531
+ },
2532
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : this.surfaceContainerHigh(),
2533
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(1.5) : getCurve(3)
2534
+ });
2535
+ return extendSpecVersion(super.outlineVariant(), "2025", color2025);
2536
+ }
2537
+ inverseSurface() {
2538
+ const color2025 = DynamicColor.fromPalette({
2539
+ name: "inverse_surface",
2540
+ palette: (s) => s.neutralPalette,
2541
+ tone: (s) => s.isDark ? 98 : 4,
2542
+ isBackground: !0
2543
+ });
2544
+ return extendSpecVersion(super.inverseSurface(), "2025", color2025);
2545
+ }
2546
+ inverseOnSurface() {
2547
+ const color2025 = DynamicColor.fromPalette({
2548
+ name: "inverse_on_surface",
2549
+ palette: (s) => s.neutralPalette,
2550
+ background: (s) => this.inverseSurface(),
2551
+ contrastCurve: (s) => getCurve(7)
2552
+ });
2553
+ return extendSpecVersion(super.inverseOnSurface(), "2025", color2025);
2554
+ }
2555
+ ////////////////////////////////////////////////////////////////
2556
+ // Primaries [P] //
2557
+ ////////////////////////////////////////////////////////////////
2558
+ primary() {
2559
+ const color2025 = DynamicColor.fromPalette({
2560
+ name: "primary",
2561
+ palette: (s) => s.primaryPalette,
2562
+ tone: (s) => s.variant === Variant.NEUTRAL ? s.platform === "phone" ? s.isDark ? 80 : 40 : 90 : s.variant === Variant.TONAL_SPOT ? s.platform === "phone" ? s.isDark ? 80 : tMaxC(s.primaryPalette) : tMaxC(s.primaryPalette, 0, 90) : s.variant === Variant.EXPRESSIVE ? s.platform === "phone" ? tMaxC(s.primaryPalette, 0, Hct.isYellow(s.primaryPalette.hue) ? 25 : Hct.isCyan(s.primaryPalette.hue) ? 88 : 98) : tMaxC(s.primaryPalette) : s.platform === "phone" ? tMaxC(s.primaryPalette, 0, Hct.isCyan(s.primaryPalette.hue) ? 88 : 98) : tMaxC(s.primaryPalette),
2563
+ isBackground: !0,
2564
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : this.surfaceContainerHigh(),
2565
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(4.5) : getCurve(7),
2566
+ toneDeltaPair: (s) => s.platform === "phone" ? new ToneDeltaPair(this.primaryContainer(), this.primary(), 5, "relative_lighter", !0, "farther") : void 0
2567
+ });
2568
+ return extendSpecVersion(super.primary(), "2025", color2025);
2569
+ }
2570
+ primaryDim() {
2571
+ return DynamicColor.fromPalette({
2572
+ name: "primary_dim",
2573
+ palette: (s) => s.primaryPalette,
2574
+ tone: (s) => s.variant === Variant.NEUTRAL ? 85 : s.variant === Variant.TONAL_SPOT ? tMaxC(s.primaryPalette, 0, 90) : tMaxC(s.primaryPalette),
2575
+ isBackground: !0,
2576
+ background: (s) => this.surfaceContainerHigh(),
2577
+ contrastCurve: (s) => getCurve(4.5),
2578
+ toneDeltaPair: (s) => new ToneDeltaPair(this.primaryDim(), this.primary(), 5, "darker", !0, "farther")
2579
+ });
2580
+ }
2581
+ onPrimary() {
2582
+ const color2025 = DynamicColor.fromPalette({
2583
+ name: "on_primary",
2584
+ palette: (s) => s.primaryPalette,
2585
+ background: (s) => s.platform === "phone" ? this.primary() : this.primaryDim(),
2586
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(6) : getCurve(7)
2587
+ });
2588
+ return extendSpecVersion(super.onPrimary(), "2025", color2025);
2589
+ }
2590
+ primaryContainer() {
2591
+ const color2025 = DynamicColor.fromPalette({
2592
+ name: "primary_container",
2593
+ palette: (s) => s.primaryPalette,
2594
+ tone: (s) => s.platform === "watch" ? 30 : s.variant === Variant.NEUTRAL ? s.isDark ? 30 : 90 : s.variant === Variant.TONAL_SPOT ? s.isDark ? tMinC(s.primaryPalette, 35, 93) : tMaxC(s.primaryPalette, 0, 90) : s.variant === Variant.EXPRESSIVE ? s.isDark ? tMaxC(s.primaryPalette, 30, 93) : tMaxC(s.primaryPalette, 78, Hct.isCyan(s.primaryPalette.hue) ? 88 : 90) : s.isDark ? tMinC(s.primaryPalette, 66, 93) : tMaxC(s.primaryPalette, 66, Hct.isCyan(s.primaryPalette.hue) ? 88 : 93),
2595
+ isBackground: !0,
2596
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : void 0,
2597
+ toneDeltaPair: (s) => s.platform === "phone" ? void 0 : new ToneDeltaPair(this.primaryContainer(), this.primaryDim(), 10, "darker", !0, "farther"),
2598
+ contrastCurve: (s) => s.platform === "phone" && s.contrastLevel > 0 ? getCurve(1.5) : void 0
2599
+ });
2600
+ return extendSpecVersion(super.primaryContainer(), "2025", color2025);
2601
+ }
2602
+ onPrimaryContainer() {
2603
+ const color2025 = DynamicColor.fromPalette({
2604
+ name: "on_primary_container",
2605
+ palette: (s) => s.primaryPalette,
2606
+ background: (s) => this.primaryContainer(),
2607
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(6) : getCurve(7)
2608
+ });
2609
+ return extendSpecVersion(super.onPrimaryContainer(), "2025", color2025);
2610
+ }
2611
+ primaryFixed() {
2612
+ const color2025 = DynamicColor.fromPalette({
2613
+ name: "primary_fixed",
2614
+ palette: (s) => s.primaryPalette,
2615
+ tone: (s) => {
2616
+ let tempS = Object.assign({}, s, { isDark: !1, contrastLevel: 0 });
2617
+ return this.primaryContainer().getTone(tempS);
2618
+ },
2619
+ isBackground: !0,
2620
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : void 0,
2621
+ contrastCurve: (s) => s.platform === "phone" && s.contrastLevel > 0 ? getCurve(1.5) : void 0
2622
+ });
2623
+ return extendSpecVersion(super.primaryFixed(), "2025", color2025);
2624
+ }
2625
+ primaryFixedDim() {
2626
+ const color2025 = DynamicColor.fromPalette({
2627
+ name: "primary_fixed_dim",
2628
+ palette: (s) => s.primaryPalette,
2629
+ tone: (s) => this.primaryFixed().getTone(s),
2630
+ isBackground: !0,
2631
+ toneDeltaPair: (s) => new ToneDeltaPair(this.primaryFixedDim(), this.primaryFixed(), 5, "darker", !0, "exact")
2632
+ });
2633
+ return extendSpecVersion(super.primaryFixedDim(), "2025", color2025);
2634
+ }
2635
+ onPrimaryFixed() {
2636
+ const color2025 = DynamicColor.fromPalette({
2637
+ name: "on_primary_fixed",
2638
+ palette: (s) => s.primaryPalette,
2639
+ background: (s) => this.primaryFixedDim(),
2640
+ contrastCurve: (s) => getCurve(7)
2641
+ });
2642
+ return extendSpecVersion(super.onPrimaryFixed(), "2025", color2025);
2643
+ }
2644
+ onPrimaryFixedVariant() {
2645
+ const color2025 = DynamicColor.fromPalette({
2646
+ name: "on_primary_fixed_variant",
2647
+ palette: (s) => s.primaryPalette,
2648
+ background: (s) => this.primaryFixedDim(),
2649
+ contrastCurve: (s) => getCurve(4.5)
2650
+ });
2651
+ return extendSpecVersion(super.onPrimaryFixedVariant(), "2025", color2025);
2652
+ }
2653
+ inversePrimary() {
2654
+ const color2025 = DynamicColor.fromPalette({
2655
+ name: "inverse_primary",
2656
+ palette: (s) => s.primaryPalette,
2657
+ tone: (s) => tMaxC(s.primaryPalette),
2658
+ background: (s) => this.inverseSurface(),
2659
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(6) : getCurve(7)
2660
+ });
2661
+ return extendSpecVersion(super.inversePrimary(), "2025", color2025);
2662
+ }
2663
+ ////////////////////////////////////////////////////////////////
2664
+ // Secondaries [Q] //
2665
+ ////////////////////////////////////////////////////////////////
2666
+ secondary() {
2667
+ const color2025 = DynamicColor.fromPalette({
2668
+ name: "secondary",
2669
+ palette: (s) => s.secondaryPalette,
2670
+ tone: (s) => s.platform === "watch" ? s.variant === Variant.NEUTRAL ? 90 : tMaxC(s.secondaryPalette, 0, 90) : s.variant === Variant.NEUTRAL ? s.isDark ? tMinC(s.secondaryPalette, 0, 98) : tMaxC(s.secondaryPalette) : s.variant === Variant.VIBRANT ? tMaxC(s.secondaryPalette, 0, s.isDark ? 90 : 98) : s.isDark ? 80 : tMaxC(s.secondaryPalette),
2671
+ isBackground: !0,
2672
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : this.surfaceContainerHigh(),
2673
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(4.5) : getCurve(7),
2674
+ toneDeltaPair: (s) => s.platform === "phone" ? new ToneDeltaPair(this.secondaryContainer(), this.secondary(), 5, "relative_lighter", !0, "farther") : void 0
2675
+ });
2676
+ return extendSpecVersion(super.secondary(), "2025", color2025);
2677
+ }
2678
+ secondaryDim() {
2679
+ return DynamicColor.fromPalette({
2680
+ name: "secondary_dim",
2681
+ palette: (s) => s.secondaryPalette,
2682
+ tone: (s) => s.variant === Variant.NEUTRAL ? 85 : tMaxC(s.secondaryPalette, 0, 90),
2683
+ isBackground: !0,
2684
+ background: (s) => this.surfaceContainerHigh(),
2685
+ contrastCurve: (s) => getCurve(4.5),
2686
+ toneDeltaPair: (s) => new ToneDeltaPair(this.secondaryDim(), this.secondary(), 5, "darker", !0, "farther")
2687
+ });
2688
+ }
2689
+ onSecondary() {
2690
+ const color2025 = DynamicColor.fromPalette({
2691
+ name: "on_secondary",
2692
+ palette: (s) => s.secondaryPalette,
2693
+ background: (s) => s.platform === "phone" ? this.secondary() : this.secondaryDim(),
2694
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(6) : getCurve(7)
2695
+ });
2696
+ return extendSpecVersion(super.onSecondary(), "2025", color2025);
2697
+ }
2698
+ secondaryContainer() {
2699
+ const color2025 = DynamicColor.fromPalette({
2700
+ name: "secondary_container",
2701
+ palette: (s) => s.secondaryPalette,
2702
+ tone: (s) => s.platform === "watch" ? 30 : s.variant === Variant.VIBRANT ? s.isDark ? tMinC(s.secondaryPalette, 30, 40) : tMaxC(s.secondaryPalette, 84, 90) : s.variant === Variant.EXPRESSIVE ? s.isDark ? 15 : tMaxC(s.secondaryPalette, 90, 95) : s.isDark ? 25 : 90,
2703
+ isBackground: !0,
2704
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : void 0,
2705
+ toneDeltaPair: (s) => s.platform === "watch" ? new ToneDeltaPair(this.secondaryContainer(), this.secondaryDim(), 10, "darker", !0, "farther") : void 0,
2706
+ contrastCurve: (s) => s.platform === "phone" && s.contrastLevel > 0 ? getCurve(1.5) : void 0
2707
+ });
2708
+ return extendSpecVersion(super.secondaryContainer(), "2025", color2025);
2709
+ }
2710
+ onSecondaryContainer() {
2711
+ const color2025 = DynamicColor.fromPalette({
2712
+ name: "on_secondary_container",
2713
+ palette: (s) => s.secondaryPalette,
2714
+ background: (s) => this.secondaryContainer(),
2715
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(6) : getCurve(7)
2716
+ });
2717
+ return extendSpecVersion(super.onSecondaryContainer(), "2025", color2025);
2718
+ }
2719
+ secondaryFixed() {
2720
+ const color2025 = DynamicColor.fromPalette({
2721
+ name: "secondary_fixed",
2722
+ palette: (s) => s.secondaryPalette,
2723
+ tone: (s) => {
2724
+ let tempS = Object.assign({}, s, { isDark: !1, contrastLevel: 0 });
2725
+ return this.secondaryContainer().getTone(tempS);
2726
+ },
2727
+ isBackground: !0,
2728
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : void 0,
2729
+ contrastCurve: (s) => s.platform === "phone" && s.contrastLevel > 0 ? getCurve(1.5) : void 0
2730
+ });
2731
+ return extendSpecVersion(super.secondaryFixed(), "2025", color2025);
2732
+ }
2733
+ secondaryFixedDim() {
2734
+ const color2025 = DynamicColor.fromPalette({
2735
+ name: "secondary_fixed_dim",
2736
+ palette: (s) => s.secondaryPalette,
2737
+ tone: (s) => this.secondaryFixed().getTone(s),
2738
+ isBackground: !0,
2739
+ toneDeltaPair: (s) => new ToneDeltaPair(this.secondaryFixedDim(), this.secondaryFixed(), 5, "darker", !0, "exact")
2740
+ });
2741
+ return extendSpecVersion(super.secondaryFixedDim(), "2025", color2025);
2742
+ }
2743
+ onSecondaryFixed() {
2744
+ const color2025 = DynamicColor.fromPalette({
2745
+ name: "on_secondary_fixed",
2746
+ palette: (s) => s.secondaryPalette,
2747
+ background: (s) => this.secondaryFixedDim(),
2748
+ contrastCurve: (s) => getCurve(7)
2749
+ });
2750
+ return extendSpecVersion(super.onSecondaryFixed(), "2025", color2025);
2751
+ }
2752
+ onSecondaryFixedVariant() {
2753
+ const color2025 = DynamicColor.fromPalette({
2754
+ name: "on_secondary_fixed_variant",
2755
+ palette: (s) => s.secondaryPalette,
2756
+ background: (s) => this.secondaryFixedDim(),
2757
+ contrastCurve: (s) => getCurve(4.5)
2758
+ });
2759
+ return extendSpecVersion(super.onSecondaryFixedVariant(), "2025", color2025);
2760
+ }
2761
+ ////////////////////////////////////////////////////////////////
2762
+ // Tertiaries [T] //
2763
+ ////////////////////////////////////////////////////////////////
2764
+ tertiary() {
2765
+ const color2025 = DynamicColor.fromPalette({
2766
+ name: "tertiary",
2767
+ palette: (s) => s.tertiaryPalette,
2768
+ tone: (s) => s.platform === "watch" ? s.variant === Variant.TONAL_SPOT ? tMaxC(s.tertiaryPalette, 0, 90) : tMaxC(s.tertiaryPalette) : s.variant === Variant.EXPRESSIVE || s.variant === Variant.VIBRANT ? tMaxC(s.tertiaryPalette, 0, Hct.isCyan(s.tertiaryPalette.hue) ? 88 : s.isDark ? 98 : 100) : s.isDark ? tMaxC(s.tertiaryPalette, 0, 98) : tMaxC(s.tertiaryPalette),
2769
+ isBackground: !0,
2770
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : this.surfaceContainerHigh(),
2771
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(4.5) : getCurve(7),
2772
+ toneDeltaPair: (s) => s.platform === "phone" ? new ToneDeltaPair(this.tertiaryContainer(), this.tertiary(), 5, "relative_lighter", !0, "farther") : void 0
2773
+ });
2774
+ return extendSpecVersion(super.tertiary(), "2025", color2025);
2775
+ }
2776
+ tertiaryDim() {
2777
+ return DynamicColor.fromPalette({
2778
+ name: "tertiary_dim",
2779
+ palette: (s) => s.tertiaryPalette,
2780
+ tone: (s) => s.variant === Variant.TONAL_SPOT ? tMaxC(s.tertiaryPalette, 0, 90) : tMaxC(s.tertiaryPalette),
2781
+ isBackground: !0,
2782
+ background: (s) => this.surfaceContainerHigh(),
2783
+ contrastCurve: (s) => getCurve(4.5),
2784
+ toneDeltaPair: (s) => new ToneDeltaPair(this.tertiaryDim(), this.tertiary(), 5, "darker", !0, "farther")
2785
+ });
2786
+ }
2787
+ onTertiary() {
2788
+ const color2025 = DynamicColor.fromPalette({
2789
+ name: "on_tertiary",
2790
+ palette: (s) => s.tertiaryPalette,
2791
+ background: (s) => s.platform === "phone" ? this.tertiary() : this.tertiaryDim(),
2792
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(6) : getCurve(7)
2793
+ });
2794
+ return extendSpecVersion(super.onTertiary(), "2025", color2025);
2795
+ }
2796
+ tertiaryContainer() {
2797
+ const color2025 = DynamicColor.fromPalette({
2798
+ name: "tertiary_container",
2799
+ palette: (s) => s.tertiaryPalette,
2800
+ tone: (s) => s.platform === "watch" ? s.variant === Variant.TONAL_SPOT ? tMaxC(s.tertiaryPalette, 0, 90) : tMaxC(s.tertiaryPalette) : s.variant === Variant.NEUTRAL ? s.isDark ? tMaxC(s.tertiaryPalette, 0, 93) : tMaxC(s.tertiaryPalette, 0, 96) : s.variant === Variant.TONAL_SPOT ? tMaxC(s.tertiaryPalette, 0, s.isDark ? 93 : 100) : s.variant === Variant.EXPRESSIVE ? tMaxC(s.tertiaryPalette, 75, Hct.isCyan(s.tertiaryPalette.hue) ? 88 : s.isDark ? 93 : 100) : s.isDark ? tMaxC(s.tertiaryPalette, 0, 93) : tMaxC(s.tertiaryPalette, 72, 100),
2801
+ isBackground: !0,
2802
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : void 0,
2803
+ toneDeltaPair: (s) => s.platform === "watch" ? new ToneDeltaPair(this.tertiaryContainer(), this.tertiaryDim(), 10, "darker", !0, "farther") : void 0,
2804
+ contrastCurve: (s) => s.platform === "phone" && s.contrastLevel > 0 ? getCurve(1.5) : void 0
2805
+ });
2806
+ return extendSpecVersion(super.tertiaryContainer(), "2025", color2025);
2807
+ }
2808
+ onTertiaryContainer() {
2809
+ const color2025 = DynamicColor.fromPalette({
2810
+ name: "on_tertiary_container",
2811
+ palette: (s) => s.tertiaryPalette,
2812
+ background: (s) => this.tertiaryContainer(),
2813
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(6) : getCurve(7)
2814
+ });
2815
+ return extendSpecVersion(super.onTertiaryContainer(), "2025", color2025);
2816
+ }
2817
+ tertiaryFixed() {
2818
+ const color2025 = DynamicColor.fromPalette({
2819
+ name: "tertiary_fixed",
2820
+ palette: (s) => s.tertiaryPalette,
2821
+ tone: (s) => {
2822
+ let tempS = Object.assign({}, s, { isDark: !1, contrastLevel: 0 });
2823
+ return this.tertiaryContainer().getTone(tempS);
2824
+ },
2825
+ isBackground: !0,
2826
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : void 0,
2827
+ contrastCurve: (s) => s.platform === "phone" && s.contrastLevel > 0 ? getCurve(1.5) : void 0
2828
+ });
2829
+ return extendSpecVersion(super.tertiaryFixed(), "2025", color2025);
2830
+ }
2831
+ tertiaryFixedDim() {
2832
+ const color2025 = DynamicColor.fromPalette({
2833
+ name: "tertiary_fixed_dim",
2834
+ palette: (s) => s.tertiaryPalette,
2835
+ tone: (s) => this.tertiaryFixed().getTone(s),
2836
+ isBackground: !0,
2837
+ toneDeltaPair: (s) => new ToneDeltaPair(this.tertiaryFixedDim(), this.tertiaryFixed(), 5, "darker", !0, "exact")
2838
+ });
2839
+ return extendSpecVersion(super.tertiaryFixedDim(), "2025", color2025);
2840
+ }
2841
+ onTertiaryFixed() {
2842
+ const color2025 = DynamicColor.fromPalette({
2843
+ name: "on_tertiary_fixed",
2844
+ palette: (s) => s.tertiaryPalette,
2845
+ background: (s) => this.tertiaryFixedDim(),
2846
+ contrastCurve: (s) => getCurve(7)
2847
+ });
2848
+ return extendSpecVersion(super.onTertiaryFixed(), "2025", color2025);
2849
+ }
2850
+ onTertiaryFixedVariant() {
2851
+ const color2025 = DynamicColor.fromPalette({
2852
+ name: "on_tertiary_fixed_variant",
2853
+ palette: (s) => s.tertiaryPalette,
2854
+ background: (s) => this.tertiaryFixedDim(),
2855
+ contrastCurve: (s) => getCurve(4.5)
2856
+ });
2857
+ return extendSpecVersion(super.onTertiaryFixedVariant(), "2025", color2025);
2858
+ }
2859
+ ////////////////////////////////////////////////////////////////
2860
+ // Errors [E] //
2861
+ ////////////////////////////////////////////////////////////////
2862
+ error() {
2863
+ const color2025 = DynamicColor.fromPalette({
2864
+ name: "error",
2865
+ palette: (s) => s.errorPalette,
2866
+ tone: (s) => s.platform === "phone" ? s.isDark ? tMinC(s.errorPalette, 0, 98) : tMaxC(s.errorPalette) : tMinC(s.errorPalette),
2867
+ isBackground: !0,
2868
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : this.surfaceContainerHigh(),
2869
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(4.5) : getCurve(7),
2870
+ toneDeltaPair: (s) => s.platform === "phone" ? new ToneDeltaPair(this.errorContainer(), this.error(), 5, "relative_lighter", !0, "farther") : void 0
2871
+ });
2872
+ return extendSpecVersion(super.error(), "2025", color2025);
2873
+ }
2874
+ errorDim() {
2875
+ return DynamicColor.fromPalette({
2876
+ name: "error_dim",
2877
+ palette: (s) => s.errorPalette,
2878
+ tone: (s) => tMinC(s.errorPalette),
2879
+ isBackground: !0,
2880
+ background: (s) => this.surfaceContainerHigh(),
2881
+ contrastCurve: (s) => getCurve(4.5),
2882
+ toneDeltaPair: (s) => new ToneDeltaPair(this.errorDim(), this.error(), 5, "darker", !0, "farther")
2883
+ });
2884
+ }
2885
+ onError() {
2886
+ const color2025 = DynamicColor.fromPalette({
2887
+ name: "on_error",
2888
+ palette: (s) => s.errorPalette,
2889
+ background: (s) => s.platform === "phone" ? this.error() : this.errorDim(),
2890
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(6) : getCurve(7)
2891
+ });
2892
+ return extendSpecVersion(super.onError(), "2025", color2025);
2893
+ }
2894
+ errorContainer() {
2895
+ const color2025 = DynamicColor.fromPalette({
2896
+ name: "error_container",
2897
+ palette: (s) => s.errorPalette,
2898
+ tone: (s) => s.platform === "watch" ? 30 : s.isDark ? tMinC(s.errorPalette, 30, 93) : tMaxC(s.errorPalette, 0, 90),
2899
+ isBackground: !0,
2900
+ background: (s) => s.platform === "phone" ? this.highestSurface(s) : void 0,
2901
+ toneDeltaPair: (s) => s.platform === "watch" ? new ToneDeltaPair(this.errorContainer(), this.errorDim(), 10, "darker", !0, "farther") : void 0,
2902
+ contrastCurve: (s) => s.platform === "phone" && s.contrastLevel > 0 ? getCurve(1.5) : void 0
2903
+ });
2904
+ return extendSpecVersion(super.errorContainer(), "2025", color2025);
2905
+ }
2906
+ onErrorContainer() {
2907
+ const color2025 = DynamicColor.fromPalette({
2908
+ name: "on_error_container",
2909
+ palette: (s) => s.errorPalette,
2910
+ background: (s) => this.errorContainer(),
2911
+ contrastCurve: (s) => s.platform === "phone" ? getCurve(4.5) : getCurve(7)
2912
+ });
2913
+ return extendSpecVersion(super.onErrorContainer(), "2025", color2025);
2914
+ }
2915
+ /////////////////////////////////////////////////////////////////
2916
+ // Remapped Colors //
2917
+ /////////////////////////////////////////////////////////////////
2918
+ surfaceVariant() {
2919
+ const color2025 = Object.assign(this.surfaceContainerHighest().clone(), { name: "surface_variant" });
2920
+ return extendSpecVersion(super.surfaceVariant(), "2025", color2025);
2921
+ }
2922
+ surfaceTint() {
2923
+ const color2025 = Object.assign(this.primary().clone(), { name: "surface_tint" });
2924
+ return extendSpecVersion(super.surfaceTint(), "2025", color2025);
2925
+ }
2926
+ background() {
2927
+ const color2025 = Object.assign(this.surface().clone(), { name: "background" });
2928
+ return extendSpecVersion(super.background(), "2025", color2025);
2929
+ }
2930
+ onBackground() {
2931
+ const color2025 = Object.assign(this.onSurface().clone(), {
2932
+ name: "on_background",
2933
+ tone: (s) => s.platform === "watch" ? 100 : this.onSurface().getTone(s)
2934
+ });
2935
+ return extendSpecVersion(super.onBackground(), "2025", color2025);
2936
+ }
2937
+ }
2938
+ /**
2939
+ * @license
2940
+ * Copyright 2022 Google LLC
2941
+ *
2942
+ * Licensed under the Apache License, Version 2.0 (the "License");
2943
+ * you may not use this file except in compliance with the License.
2944
+ * You may obtain a copy of the License at
2945
+ *
2946
+ * http://www.apache.org/licenses/LICENSE-2.0
2947
+ *
2948
+ * Unless required by applicable law or agreed to in writing, software
2949
+ * distributed under the License is distributed on an "AS IS" BASIS,
2950
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2951
+ * See the License for the specific language governing permissions and
2952
+ * limitations under the License.
2953
+ */
2954
+ class MaterialDynamicColors {
2955
+ constructor() {
2956
+ this.allColors = [
2957
+ this.background(),
2958
+ this.onBackground(),
2959
+ this.surface(),
2960
+ this.surfaceDim(),
2961
+ this.surfaceBright(),
2962
+ this.surfaceContainerLowest(),
2963
+ this.surfaceContainerLow(),
2964
+ this.surfaceContainer(),
2965
+ this.surfaceContainerHigh(),
2966
+ this.surfaceContainerHighest(),
2967
+ this.onSurface(),
2968
+ this.onSurfaceVariant(),
2969
+ this.outline(),
2970
+ this.outlineVariant(),
2971
+ this.inverseSurface(),
2972
+ this.inverseOnSurface(),
2973
+ this.primary(),
2974
+ this.primaryDim(),
2975
+ this.onPrimary(),
2976
+ this.primaryContainer(),
2977
+ this.onPrimaryContainer(),
2978
+ this.primaryFixed(),
2979
+ this.primaryFixedDim(),
2980
+ this.onPrimaryFixed(),
2981
+ this.onPrimaryFixedVariant(),
2982
+ this.inversePrimary(),
2983
+ this.secondary(),
2984
+ this.secondaryDim(),
2985
+ this.onSecondary(),
2986
+ this.secondaryContainer(),
2987
+ this.onSecondaryContainer(),
2988
+ this.secondaryFixed(),
2989
+ this.secondaryFixedDim(),
2990
+ this.onSecondaryFixed(),
2991
+ this.onSecondaryFixedVariant(),
2992
+ this.tertiary(),
2993
+ this.tertiaryDim(),
2994
+ this.onTertiary(),
2995
+ this.tertiaryContainer(),
2996
+ this.onTertiaryContainer(),
2997
+ this.tertiaryFixed(),
2998
+ this.tertiaryFixedDim(),
2999
+ this.onTertiaryFixed(),
3000
+ this.onTertiaryFixedVariant(),
3001
+ this.error(),
3002
+ this.errorDim(),
3003
+ this.onError(),
3004
+ this.errorContainer(),
3005
+ this.onErrorContainer()
3006
+ ].filter((c) => c !== void 0);
3007
+ }
3008
+ highestSurface(s) {
3009
+ return MaterialDynamicColors.colorSpec.highestSurface(s);
3010
+ }
3011
+ ////////////////////////////////////////////////////////////////
3012
+ // Main Palettes //
3013
+ ////////////////////////////////////////////////////////////////
3014
+ primaryPaletteKeyColor() {
3015
+ return MaterialDynamicColors.colorSpec.primaryPaletteKeyColor();
3016
+ }
3017
+ secondaryPaletteKeyColor() {
3018
+ return MaterialDynamicColors.colorSpec.secondaryPaletteKeyColor();
3019
+ }
3020
+ tertiaryPaletteKeyColor() {
3021
+ return MaterialDynamicColors.colorSpec.tertiaryPaletteKeyColor();
3022
+ }
3023
+ neutralPaletteKeyColor() {
3024
+ return MaterialDynamicColors.colorSpec.neutralPaletteKeyColor();
3025
+ }
3026
+ neutralVariantPaletteKeyColor() {
3027
+ return MaterialDynamicColors.colorSpec.neutralVariantPaletteKeyColor();
3028
+ }
3029
+ errorPaletteKeyColor() {
3030
+ return MaterialDynamicColors.colorSpec.errorPaletteKeyColor();
3031
+ }
3032
+ ////////////////////////////////////////////////////////////////
3033
+ // Surfaces [S] //
3034
+ ////////////////////////////////////////////////////////////////
3035
+ background() {
3036
+ return MaterialDynamicColors.colorSpec.background();
3037
+ }
3038
+ onBackground() {
3039
+ return MaterialDynamicColors.colorSpec.onBackground();
3040
+ }
3041
+ surface() {
3042
+ return MaterialDynamicColors.colorSpec.surface();
3043
+ }
3044
+ surfaceDim() {
3045
+ return MaterialDynamicColors.colorSpec.surfaceDim();
3046
+ }
3047
+ surfaceBright() {
3048
+ return MaterialDynamicColors.colorSpec.surfaceBright();
3049
+ }
3050
+ surfaceContainerLowest() {
3051
+ return MaterialDynamicColors.colorSpec.surfaceContainerLowest();
3052
+ }
3053
+ surfaceContainerLow() {
3054
+ return MaterialDynamicColors.colorSpec.surfaceContainerLow();
3055
+ }
3056
+ surfaceContainer() {
3057
+ return MaterialDynamicColors.colorSpec.surfaceContainer();
3058
+ }
3059
+ surfaceContainerHigh() {
3060
+ return MaterialDynamicColors.colorSpec.surfaceContainerHigh();
3061
+ }
3062
+ surfaceContainerHighest() {
3063
+ return MaterialDynamicColors.colorSpec.surfaceContainerHighest();
3064
+ }
3065
+ onSurface() {
3066
+ return MaterialDynamicColors.colorSpec.onSurface();
3067
+ }
3068
+ surfaceVariant() {
3069
+ return MaterialDynamicColors.colorSpec.surfaceVariant();
3070
+ }
3071
+ onSurfaceVariant() {
3072
+ return MaterialDynamicColors.colorSpec.onSurfaceVariant();
3073
+ }
3074
+ outline() {
3075
+ return MaterialDynamicColors.colorSpec.outline();
3076
+ }
3077
+ outlineVariant() {
3078
+ return MaterialDynamicColors.colorSpec.outlineVariant();
3079
+ }
3080
+ inverseSurface() {
3081
+ return MaterialDynamicColors.colorSpec.inverseSurface();
3082
+ }
3083
+ inverseOnSurface() {
3084
+ return MaterialDynamicColors.colorSpec.inverseOnSurface();
3085
+ }
3086
+ shadow() {
3087
+ return MaterialDynamicColors.colorSpec.shadow();
3088
+ }
3089
+ scrim() {
3090
+ return MaterialDynamicColors.colorSpec.scrim();
3091
+ }
3092
+ surfaceTint() {
3093
+ return MaterialDynamicColors.colorSpec.surfaceTint();
3094
+ }
3095
+ ////////////////////////////////////////////////////////////////
3096
+ // Primaries [P] //
3097
+ ////////////////////////////////////////////////////////////////
3098
+ primary() {
3099
+ return MaterialDynamicColors.colorSpec.primary();
3100
+ }
3101
+ primaryDim() {
3102
+ return MaterialDynamicColors.colorSpec.primaryDim();
3103
+ }
3104
+ onPrimary() {
3105
+ return MaterialDynamicColors.colorSpec.onPrimary();
3106
+ }
3107
+ primaryContainer() {
3108
+ return MaterialDynamicColors.colorSpec.primaryContainer();
3109
+ }
3110
+ onPrimaryContainer() {
3111
+ return MaterialDynamicColors.colorSpec.onPrimaryContainer();
3112
+ }
3113
+ inversePrimary() {
3114
+ return MaterialDynamicColors.colorSpec.inversePrimary();
3115
+ }
3116
+ /////////////////////////////////////////////////////////////////
3117
+ // Primary Fixed [PF] //
3118
+ /////////////////////////////////////////////////////////////////
3119
+ primaryFixed() {
3120
+ return MaterialDynamicColors.colorSpec.primaryFixed();
3121
+ }
3122
+ primaryFixedDim() {
3123
+ return MaterialDynamicColors.colorSpec.primaryFixedDim();
3124
+ }
3125
+ onPrimaryFixed() {
3126
+ return MaterialDynamicColors.colorSpec.onPrimaryFixed();
3127
+ }
3128
+ onPrimaryFixedVariant() {
3129
+ return MaterialDynamicColors.colorSpec.onPrimaryFixedVariant();
3130
+ }
3131
+ ////////////////////////////////////////////////////////////////
3132
+ // Secondaries [Q] //
3133
+ ////////////////////////////////////////////////////////////////
3134
+ secondary() {
3135
+ return MaterialDynamicColors.colorSpec.secondary();
3136
+ }
3137
+ secondaryDim() {
3138
+ return MaterialDynamicColors.colorSpec.secondaryDim();
3139
+ }
3140
+ onSecondary() {
3141
+ return MaterialDynamicColors.colorSpec.onSecondary();
3142
+ }
3143
+ secondaryContainer() {
3144
+ return MaterialDynamicColors.colorSpec.secondaryContainer();
3145
+ }
3146
+ onSecondaryContainer() {
3147
+ return MaterialDynamicColors.colorSpec.onSecondaryContainer();
3148
+ }
3149
+ /////////////////////////////////////////////////////////////////
3150
+ // Secondary Fixed [QF] //
3151
+ /////////////////////////////////////////////////////////////////
3152
+ secondaryFixed() {
3153
+ return MaterialDynamicColors.colorSpec.secondaryFixed();
3154
+ }
3155
+ secondaryFixedDim() {
3156
+ return MaterialDynamicColors.colorSpec.secondaryFixedDim();
3157
+ }
3158
+ onSecondaryFixed() {
3159
+ return MaterialDynamicColors.colorSpec.onSecondaryFixed();
3160
+ }
3161
+ onSecondaryFixedVariant() {
3162
+ return MaterialDynamicColors.colorSpec.onSecondaryFixedVariant();
3163
+ }
3164
+ ////////////////////////////////////////////////////////////////
3165
+ // Tertiaries [T] //
3166
+ ////////////////////////////////////////////////////////////////
3167
+ tertiary() {
3168
+ return MaterialDynamicColors.colorSpec.tertiary();
3169
+ }
3170
+ tertiaryDim() {
3171
+ return MaterialDynamicColors.colorSpec.tertiaryDim();
3172
+ }
3173
+ onTertiary() {
3174
+ return MaterialDynamicColors.colorSpec.onTertiary();
3175
+ }
3176
+ tertiaryContainer() {
3177
+ return MaterialDynamicColors.colorSpec.tertiaryContainer();
3178
+ }
3179
+ onTertiaryContainer() {
3180
+ return MaterialDynamicColors.colorSpec.onTertiaryContainer();
3181
+ }
3182
+ /////////////////////////////////////////////////////////////////
3183
+ // Tertiary Fixed [TF] //
3184
+ /////////////////////////////////////////////////////////////////
3185
+ tertiaryFixed() {
3186
+ return MaterialDynamicColors.colorSpec.tertiaryFixed();
3187
+ }
3188
+ tertiaryFixedDim() {
3189
+ return MaterialDynamicColors.colorSpec.tertiaryFixedDim();
3190
+ }
3191
+ onTertiaryFixed() {
3192
+ return MaterialDynamicColors.colorSpec.onTertiaryFixed();
3193
+ }
3194
+ onTertiaryFixedVariant() {
3195
+ return MaterialDynamicColors.colorSpec.onTertiaryFixedVariant();
3196
+ }
3197
+ ////////////////////////////////////////////////////////////////
3198
+ // Errors [E] //
3199
+ ////////////////////////////////////////////////////////////////
3200
+ error() {
3201
+ return MaterialDynamicColors.colorSpec.error();
3202
+ }
3203
+ errorDim() {
3204
+ return MaterialDynamicColors.colorSpec.errorDim();
3205
+ }
3206
+ onError() {
3207
+ return MaterialDynamicColors.colorSpec.onError();
3208
+ }
3209
+ errorContainer() {
3210
+ return MaterialDynamicColors.colorSpec.errorContainer();
3211
+ }
3212
+ onErrorContainer() {
3213
+ return MaterialDynamicColors.colorSpec.onErrorContainer();
3214
+ }
3215
+ // Static variables are deprecated. Use the instance methods to get correct
3216
+ // specs based on request.
3217
+ /** @deprecated Use highestSurface() instead. */
3218
+ static highestSurface(s) {
3219
+ return MaterialDynamicColors.colorSpec.highestSurface(s);
3220
+ }
3221
+ }
3222
+ MaterialDynamicColors.contentAccentToneDelta = 15;
3223
+ MaterialDynamicColors.colorSpec = new ColorSpecDelegateImpl2025();
3224
+ MaterialDynamicColors.primaryPaletteKeyColor = MaterialDynamicColors.colorSpec.primaryPaletteKeyColor();
3225
+ MaterialDynamicColors.secondaryPaletteKeyColor = MaterialDynamicColors.colorSpec.secondaryPaletteKeyColor();
3226
+ MaterialDynamicColors.tertiaryPaletteKeyColor = MaterialDynamicColors.colorSpec.tertiaryPaletteKeyColor();
3227
+ MaterialDynamicColors.neutralPaletteKeyColor = MaterialDynamicColors.colorSpec.neutralPaletteKeyColor();
3228
+ MaterialDynamicColors.neutralVariantPaletteKeyColor = MaterialDynamicColors.colorSpec.neutralVariantPaletteKeyColor();
3229
+ MaterialDynamicColors.background = MaterialDynamicColors.colorSpec.background();
3230
+ MaterialDynamicColors.onBackground = MaterialDynamicColors.colorSpec.onBackground();
3231
+ MaterialDynamicColors.surface = MaterialDynamicColors.colorSpec.surface();
3232
+ MaterialDynamicColors.surfaceDim = MaterialDynamicColors.colorSpec.surfaceDim();
3233
+ MaterialDynamicColors.surfaceBright = MaterialDynamicColors.colorSpec.surfaceBright();
3234
+ MaterialDynamicColors.surfaceContainerLowest = MaterialDynamicColors.colorSpec.surfaceContainerLowest();
3235
+ MaterialDynamicColors.surfaceContainerLow = MaterialDynamicColors.colorSpec.surfaceContainerLow();
3236
+ MaterialDynamicColors.surfaceContainer = MaterialDynamicColors.colorSpec.surfaceContainer();
3237
+ MaterialDynamicColors.surfaceContainerHigh = MaterialDynamicColors.colorSpec.surfaceContainerHigh();
3238
+ MaterialDynamicColors.surfaceContainerHighest = MaterialDynamicColors.colorSpec.surfaceContainerHighest();
3239
+ MaterialDynamicColors.onSurface = MaterialDynamicColors.colorSpec.onSurface();
3240
+ MaterialDynamicColors.surfaceVariant = MaterialDynamicColors.colorSpec.surfaceVariant();
3241
+ MaterialDynamicColors.onSurfaceVariant = MaterialDynamicColors.colorSpec.onSurfaceVariant();
3242
+ MaterialDynamicColors.inverseSurface = MaterialDynamicColors.colorSpec.inverseSurface();
3243
+ MaterialDynamicColors.inverseOnSurface = MaterialDynamicColors.colorSpec.inverseOnSurface();
3244
+ MaterialDynamicColors.outline = MaterialDynamicColors.colorSpec.outline();
3245
+ MaterialDynamicColors.outlineVariant = MaterialDynamicColors.colorSpec.outlineVariant();
3246
+ MaterialDynamicColors.shadow = MaterialDynamicColors.colorSpec.shadow();
3247
+ MaterialDynamicColors.scrim = MaterialDynamicColors.colorSpec.scrim();
3248
+ MaterialDynamicColors.surfaceTint = MaterialDynamicColors.colorSpec.surfaceTint();
3249
+ MaterialDynamicColors.primary = MaterialDynamicColors.colorSpec.primary();
3250
+ MaterialDynamicColors.onPrimary = MaterialDynamicColors.colorSpec.onPrimary();
3251
+ MaterialDynamicColors.primaryContainer = MaterialDynamicColors.colorSpec.primaryContainer();
3252
+ MaterialDynamicColors.onPrimaryContainer = MaterialDynamicColors.colorSpec.onPrimaryContainer();
3253
+ MaterialDynamicColors.inversePrimary = MaterialDynamicColors.colorSpec.inversePrimary();
3254
+ MaterialDynamicColors.secondary = MaterialDynamicColors.colorSpec.secondary();
3255
+ MaterialDynamicColors.onSecondary = MaterialDynamicColors.colorSpec.onSecondary();
3256
+ MaterialDynamicColors.secondaryContainer = MaterialDynamicColors.colorSpec.secondaryContainer();
3257
+ MaterialDynamicColors.onSecondaryContainer = MaterialDynamicColors.colorSpec.onSecondaryContainer();
3258
+ MaterialDynamicColors.tertiary = MaterialDynamicColors.colorSpec.tertiary();
3259
+ MaterialDynamicColors.onTertiary = MaterialDynamicColors.colorSpec.onTertiary();
3260
+ MaterialDynamicColors.tertiaryContainer = MaterialDynamicColors.colorSpec.tertiaryContainer();
3261
+ MaterialDynamicColors.onTertiaryContainer = MaterialDynamicColors.colorSpec.onTertiaryContainer();
3262
+ MaterialDynamicColors.error = MaterialDynamicColors.colorSpec.error();
3263
+ MaterialDynamicColors.onError = MaterialDynamicColors.colorSpec.onError();
3264
+ MaterialDynamicColors.errorContainer = MaterialDynamicColors.colorSpec.errorContainer();
3265
+ MaterialDynamicColors.onErrorContainer = MaterialDynamicColors.colorSpec.onErrorContainer();
3266
+ MaterialDynamicColors.primaryFixed = MaterialDynamicColors.colorSpec.primaryFixed();
3267
+ MaterialDynamicColors.primaryFixedDim = MaterialDynamicColors.colorSpec.primaryFixedDim();
3268
+ MaterialDynamicColors.onPrimaryFixed = MaterialDynamicColors.colorSpec.onPrimaryFixed();
3269
+ MaterialDynamicColors.onPrimaryFixedVariant = MaterialDynamicColors.colorSpec.onPrimaryFixedVariant();
3270
+ MaterialDynamicColors.secondaryFixed = MaterialDynamicColors.colorSpec.secondaryFixed();
3271
+ MaterialDynamicColors.secondaryFixedDim = MaterialDynamicColors.colorSpec.secondaryFixedDim();
3272
+ MaterialDynamicColors.onSecondaryFixed = MaterialDynamicColors.colorSpec.onSecondaryFixed();
3273
+ MaterialDynamicColors.onSecondaryFixedVariant = MaterialDynamicColors.colorSpec.onSecondaryFixedVariant();
3274
+ MaterialDynamicColors.tertiaryFixed = MaterialDynamicColors.colorSpec.tertiaryFixed();
3275
+ MaterialDynamicColors.tertiaryFixedDim = MaterialDynamicColors.colorSpec.tertiaryFixedDim();
3276
+ MaterialDynamicColors.onTertiaryFixed = MaterialDynamicColors.colorSpec.onTertiaryFixed();
3277
+ MaterialDynamicColors.onTertiaryFixedVariant = MaterialDynamicColors.colorSpec.onTertiaryFixedVariant();
3278
+ /**
3279
+ * @license
3280
+ * Copyright 2021 Google LLC
3281
+ *
3282
+ * Licensed under the Apache License, Version 2.0 (the "License");
3283
+ * you may not use this file except in compliance with the License.
3284
+ * You may obtain a copy of the License at
3285
+ *
3286
+ * http://www.apache.org/licenses/LICENSE-2.0
3287
+ *
3288
+ * Unless required by applicable law or agreed to in writing, software
3289
+ * distributed under the License is distributed on an "AS IS" BASIS,
3290
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3291
+ * See the License for the specific language governing permissions and
3292
+ * limitations under the License.
3293
+ */
3294
+ class CorePalette {
3295
+ /**
3296
+ * @param argb ARGB representation of a color
3297
+ *
3298
+ * @deprecated Use {@link DynamicScheme} for color scheme generation.
3299
+ * Use {@link CorePalettes} for core palettes container class.
3300
+ */
3301
+ static of(argb) {
3302
+ return new CorePalette(argb, !1);
3303
+ }
3304
+ /**
3305
+ * @param argb ARGB representation of a color
3306
+ *
3307
+ * @deprecated Use {@link DynamicScheme} for color scheme generation.
3308
+ * Use {@link CorePalettes} for core palettes container class.
3309
+ */
3310
+ static contentOf(argb) {
3311
+ return new CorePalette(argb, !0);
3312
+ }
3313
+ /**
3314
+ * Create a [CorePalette] from a set of colors
3315
+ *
3316
+ * @deprecated Use {@link DynamicScheme} for color scheme generation.
3317
+ * Use {@link CorePalettes} for core palettes container class.
3318
+ */
3319
+ static fromColors(colors) {
3320
+ return CorePalette.createPaletteFromColors(!1, colors);
3321
+ }
3322
+ /**
3323
+ * Create a content [CorePalette] from a set of colors
3324
+ *
3325
+ * @deprecated Use {@link DynamicScheme} for color scheme generation.
3326
+ * Use {@link CorePalettes} for core palettes container class.
3327
+ */
3328
+ static contentFromColors(colors) {
3329
+ return CorePalette.createPaletteFromColors(!0, colors);
3330
+ }
3331
+ static createPaletteFromColors(content, colors) {
3332
+ const palette = new CorePalette(colors.primary, content);
3333
+ if (colors.secondary) {
3334
+ const p = new CorePalette(colors.secondary, content);
3335
+ palette.a2 = p.a1;
3336
+ }
3337
+ if (colors.tertiary) {
3338
+ const p = new CorePalette(colors.tertiary, content);
3339
+ palette.a3 = p.a1;
3340
+ }
3341
+ if (colors.error) {
3342
+ const p = new CorePalette(colors.error, content);
3343
+ palette.error = p.a1;
3344
+ }
3345
+ if (colors.neutral) {
3346
+ const p = new CorePalette(colors.neutral, content);
3347
+ palette.n1 = p.n1;
3348
+ }
3349
+ if (colors.neutralVariant) {
3350
+ const p = new CorePalette(colors.neutralVariant, content);
3351
+ palette.n2 = p.n2;
3352
+ }
3353
+ return palette;
3354
+ }
3355
+ constructor(argb, isContent) {
3356
+ const hct = Hct.fromInt(argb), hue = hct.hue, chroma = hct.chroma;
3357
+ isContent ? (this.a1 = TonalPalette.fromHueAndChroma(hue, chroma), this.a2 = TonalPalette.fromHueAndChroma(hue, chroma / 3), this.a3 = TonalPalette.fromHueAndChroma(hue + 60, chroma / 2), this.n1 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 12, 4)), this.n2 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 6, 8))) : (this.a1 = TonalPalette.fromHueAndChroma(hue, Math.max(48, chroma)), this.a2 = TonalPalette.fromHueAndChroma(hue, 16), this.a3 = TonalPalette.fromHueAndChroma(hue + 60, 24), this.n1 = TonalPalette.fromHueAndChroma(hue, 4), this.n2 = TonalPalette.fromHueAndChroma(hue, 8)), this.error = TonalPalette.fromHueAndChroma(25, 84);
3358
+ }
3359
+ }
3360
+ /**
3361
+ * @license
3362
+ * Copyright 2021 Google LLC
3363
+ *
3364
+ * Licensed under the Apache License, Version 2.0 (the "License");
3365
+ * you may not use this file except in compliance with the License.
3366
+ * You may obtain a copy of the License at
3367
+ *
3368
+ * http://www.apache.org/licenses/LICENSE-2.0
3369
+ *
3370
+ * Unless required by applicable law or agreed to in writing, software
3371
+ * distributed under the License is distributed on an "AS IS" BASIS,
3372
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3373
+ * See the License for the specific language governing permissions and
3374
+ * limitations under the License.
3375
+ */
3376
+ class Scheme {
3377
+ get primary() {
3378
+ return this.props.primary;
3379
+ }
3380
+ get onPrimary() {
3381
+ return this.props.onPrimary;
3382
+ }
3383
+ get primaryContainer() {
3384
+ return this.props.primaryContainer;
3385
+ }
3386
+ get onPrimaryContainer() {
3387
+ return this.props.onPrimaryContainer;
3388
+ }
3389
+ get secondary() {
3390
+ return this.props.secondary;
3391
+ }
3392
+ get onSecondary() {
3393
+ return this.props.onSecondary;
3394
+ }
3395
+ get secondaryContainer() {
3396
+ return this.props.secondaryContainer;
3397
+ }
3398
+ get onSecondaryContainer() {
3399
+ return this.props.onSecondaryContainer;
3400
+ }
3401
+ get tertiary() {
3402
+ return this.props.tertiary;
3403
+ }
3404
+ get onTertiary() {
3405
+ return this.props.onTertiary;
3406
+ }
3407
+ get tertiaryContainer() {
3408
+ return this.props.tertiaryContainer;
3409
+ }
3410
+ get onTertiaryContainer() {
3411
+ return this.props.onTertiaryContainer;
3412
+ }
3413
+ get error() {
3414
+ return this.props.error;
3415
+ }
3416
+ get onError() {
3417
+ return this.props.onError;
3418
+ }
3419
+ get errorContainer() {
3420
+ return this.props.errorContainer;
3421
+ }
3422
+ get onErrorContainer() {
3423
+ return this.props.onErrorContainer;
3424
+ }
3425
+ get background() {
3426
+ return this.props.background;
3427
+ }
3428
+ get onBackground() {
3429
+ return this.props.onBackground;
3430
+ }
3431
+ get surface() {
3432
+ return this.props.surface;
3433
+ }
3434
+ get onSurface() {
3435
+ return this.props.onSurface;
3436
+ }
3437
+ get surfaceVariant() {
3438
+ return this.props.surfaceVariant;
3439
+ }
3440
+ get onSurfaceVariant() {
3441
+ return this.props.onSurfaceVariant;
3442
+ }
3443
+ get outline() {
3444
+ return this.props.outline;
3445
+ }
3446
+ get outlineVariant() {
3447
+ return this.props.outlineVariant;
3448
+ }
3449
+ get shadow() {
3450
+ return this.props.shadow;
3451
+ }
3452
+ get scrim() {
3453
+ return this.props.scrim;
3454
+ }
3455
+ get inverseSurface() {
3456
+ return this.props.inverseSurface;
3457
+ }
3458
+ get inverseOnSurface() {
3459
+ return this.props.inverseOnSurface;
3460
+ }
3461
+ get inversePrimary() {
3462
+ return this.props.inversePrimary;
3463
+ }
3464
+ /**
3465
+ * @param argb ARGB representation of a color.
3466
+ * @return Light Material color scheme, based on the color's hue.
3467
+ */
3468
+ static light(argb) {
3469
+ return Scheme.lightFromCorePalette(CorePalette.of(argb));
3470
+ }
3471
+ /**
3472
+ * @param argb ARGB representation of a color.
3473
+ * @return Dark Material color scheme, based on the color's hue.
3474
+ */
3475
+ static dark(argb) {
3476
+ return Scheme.darkFromCorePalette(CorePalette.of(argb));
3477
+ }
3478
+ /**
3479
+ * @param argb ARGB representation of a color.
3480
+ * @return Light Material content color scheme, based on the color's hue.
3481
+ */
3482
+ static lightContent(argb) {
3483
+ return Scheme.lightFromCorePalette(CorePalette.contentOf(argb));
3484
+ }
3485
+ /**
3486
+ * @param argb ARGB representation of a color.
3487
+ * @return Dark Material content color scheme, based on the color's hue.
3488
+ */
3489
+ static darkContent(argb) {
3490
+ return Scheme.darkFromCorePalette(CorePalette.contentOf(argb));
3491
+ }
3492
+ /**
3493
+ * Light scheme from core palette
3494
+ */
3495
+ static lightFromCorePalette(core) {
3496
+ return new Scheme({
3497
+ primary: core.a1.tone(40),
3498
+ onPrimary: core.a1.tone(100),
3499
+ primaryContainer: core.a1.tone(90),
3500
+ onPrimaryContainer: core.a1.tone(10),
3501
+ secondary: core.a2.tone(40),
3502
+ onSecondary: core.a2.tone(100),
3503
+ secondaryContainer: core.a2.tone(90),
3504
+ onSecondaryContainer: core.a2.tone(10),
3505
+ tertiary: core.a3.tone(40),
3506
+ onTertiary: core.a3.tone(100),
3507
+ tertiaryContainer: core.a3.tone(90),
3508
+ onTertiaryContainer: core.a3.tone(10),
3509
+ error: core.error.tone(40),
3510
+ onError: core.error.tone(100),
3511
+ errorContainer: core.error.tone(90),
3512
+ onErrorContainer: core.error.tone(10),
3513
+ background: core.n1.tone(99),
3514
+ onBackground: core.n1.tone(10),
3515
+ surface: core.n1.tone(99),
3516
+ onSurface: core.n1.tone(10),
3517
+ surfaceVariant: core.n2.tone(90),
3518
+ onSurfaceVariant: core.n2.tone(30),
3519
+ outline: core.n2.tone(50),
3520
+ outlineVariant: core.n2.tone(80),
3521
+ shadow: core.n1.tone(0),
3522
+ scrim: core.n1.tone(0),
3523
+ inverseSurface: core.n1.tone(20),
3524
+ inverseOnSurface: core.n1.tone(95),
3525
+ inversePrimary: core.a1.tone(80)
3526
+ });
3527
+ }
3528
+ /**
3529
+ * Dark scheme from core palette
3530
+ */
3531
+ static darkFromCorePalette(core) {
3532
+ return new Scheme({
3533
+ primary: core.a1.tone(80),
3534
+ onPrimary: core.a1.tone(20),
3535
+ primaryContainer: core.a1.tone(30),
3536
+ onPrimaryContainer: core.a1.tone(90),
3537
+ secondary: core.a2.tone(80),
3538
+ onSecondary: core.a2.tone(20),
3539
+ secondaryContainer: core.a2.tone(30),
3540
+ onSecondaryContainer: core.a2.tone(90),
3541
+ tertiary: core.a3.tone(80),
3542
+ onTertiary: core.a3.tone(20),
3543
+ tertiaryContainer: core.a3.tone(30),
3544
+ onTertiaryContainer: core.a3.tone(90),
3545
+ error: core.error.tone(80),
3546
+ onError: core.error.tone(20),
3547
+ errorContainer: core.error.tone(30),
3548
+ onErrorContainer: core.error.tone(80),
3549
+ background: core.n1.tone(10),
3550
+ onBackground: core.n1.tone(90),
3551
+ surface: core.n1.tone(10),
3552
+ onSurface: core.n1.tone(90),
3553
+ surfaceVariant: core.n2.tone(30),
3554
+ onSurfaceVariant: core.n2.tone(80),
3555
+ outline: core.n2.tone(60),
3556
+ outlineVariant: core.n2.tone(30),
3557
+ shadow: core.n1.tone(0),
3558
+ scrim: core.n1.tone(0),
3559
+ inverseSurface: core.n1.tone(90),
3560
+ inverseOnSurface: core.n1.tone(20),
3561
+ inversePrimary: core.a1.tone(40)
3562
+ });
3563
+ }
3564
+ constructor(props) {
3565
+ this.props = props;
3566
+ }
3567
+ toJSON() {
3568
+ return {
3569
+ ...this.props
3570
+ };
3571
+ }
3572
+ }
3573
+ /**
3574
+ * @license
3575
+ * Copyright 2021 Google LLC
3576
+ *
3577
+ * Licensed under the Apache License, Version 2.0 (the "License");
3578
+ * you may not use this file except in compliance with the License.
3579
+ * You may obtain a copy of the License at
3580
+ *
3581
+ * http://www.apache.org/licenses/LICENSE-2.0
3582
+ *
3583
+ * Unless required by applicable law or agreed to in writing, software
3584
+ * distributed under the License is distributed on an "AS IS" BASIS,
3585
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3586
+ * See the License for the specific language governing permissions and
3587
+ * limitations under the License.
3588
+ */
3589
+ function hexFromArgb(argb) {
3590
+ const r = redFromArgb(argb), g = greenFromArgb(argb), b = blueFromArgb(argb), outParts = [r.toString(16), g.toString(16), b.toString(16)];
3591
+ for (const [i, part] of outParts.entries())
3592
+ part.length === 1 && (outParts[i] = "0" + part);
3593
+ return "#" + outParts.join("");
3594
+ }
3595
+ function argbFromHex(hex) {
3596
+ hex = hex.replace("#", "");
3597
+ const isThree = hex.length === 3, isSix = hex.length === 6, isEight = hex.length === 8;
3598
+ if (!isThree && !isSix && !isEight)
3599
+ throw new Error("unexpected hex " + hex);
3600
+ let r = 0, g = 0, b = 0;
3601
+ return isThree ? (r = parseIntHex(hex.slice(0, 1).repeat(2)), g = parseIntHex(hex.slice(1, 2).repeat(2)), b = parseIntHex(hex.slice(2, 3).repeat(2))) : isSix ? (r = parseIntHex(hex.slice(0, 2)), g = parseIntHex(hex.slice(2, 4)), b = parseIntHex(hex.slice(4, 6))) : isEight && (r = parseIntHex(hex.slice(2, 4)), g = parseIntHex(hex.slice(4, 6)), b = parseIntHex(hex.slice(6, 8))), (255 << 24 | (r & 255) << 16 | (g & 255) << 8 | b & 255) >>> 0;
3602
+ }
3603
+ function parseIntHex(value) {
3604
+ return parseInt(value, 16);
3605
+ }
3606
+ /**
3607
+ * @license
3608
+ * Copyright 2021 Google LLC
3609
+ *
3610
+ * Licensed under the Apache License, Version 2.0 (the "License");
3611
+ * you may not use this file except in compliance with the License.
3612
+ * You may obtain a copy of the License at
3613
+ *
3614
+ * http://www.apache.org/licenses/LICENSE-2.0
3615
+ *
3616
+ * Unless required by applicable law or agreed to in writing, software
3617
+ * distributed under the License is distributed on an "AS IS" BASIS,
3618
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3619
+ * See the License for the specific language governing permissions and
3620
+ * limitations under the License.
3621
+ */
3622
+ function themeFromSourceColor(source, customColors = []) {
3623
+ const palette = CorePalette.of(source);
3624
+ return {
3625
+ source,
3626
+ schemes: {
3627
+ light: Scheme.light(source),
3628
+ dark: Scheme.dark(source)
3629
+ },
3630
+ palettes: {
3631
+ primary: palette.a1,
3632
+ secondary: palette.a2,
3633
+ tertiary: palette.a3,
3634
+ neutral: palette.n1,
3635
+ neutralVariant: palette.n2,
3636
+ error: palette.error
3637
+ },
3638
+ customColors: customColors.map((c) => customColor(source, c))
3639
+ };
3640
+ }
3641
+ function customColor(source, color) {
3642
+ let value = color.value;
3643
+ const from = value, to = source;
3644
+ color.blend && (value = Blend.harmonize(from, to));
3645
+ const tones = CorePalette.of(value).a1;
3646
+ return {
3647
+ color,
3648
+ value,
3649
+ light: {
3650
+ color: tones.tone(40),
3651
+ onColor: tones.tone(100),
3652
+ colorContainer: tones.tone(90),
3653
+ onColorContainer: tones.tone(10)
3654
+ },
3655
+ dark: {
3656
+ color: tones.tone(80),
3657
+ onColor: tones.tone(20),
3658
+ colorContainer: tones.tone(30),
3659
+ onColorContainer: tones.tone(90)
3660
+ }
3661
+ };
3662
+ }
3663
+ const COLOR_SHADES = [
3664
+ 50,
3665
+ 100,
3666
+ 200,
3667
+ 300,
3668
+ 400,
3669
+ 500,
3670
+ 600,
3671
+ 700,
3672
+ 800,
3673
+ 900
3674
+ ], SHADE_TONES = {
3675
+ 50: 90,
3676
+ 100: 80,
3677
+ 200: 70,
3678
+ 300: 60,
3679
+ 400: 50,
3680
+ 500: 40,
3681
+ 600: 35,
3682
+ 700: 30,
3683
+ 800: 20,
3684
+ 900: 10
3685
+ }, ON_SHADE_TONES = Object.fromEntries(
3686
+ COLOR_SHADES.map((shade) => [shade, SHADE_TONES[shade] >= 60 ? 10 : 100])
3687
+ ), createTonalPalette = (seed) => {
3688
+ const hex = colorToHex(seed, "#000000");
3689
+ return themeFromSourceColor(argbFromHex(hex)).palettes.primary;
3690
+ }, createPaletteFromTones = (seed, tones) => {
3691
+ const tonalPalette = createTonalPalette(seed);
3692
+ return Object.fromEntries(
3693
+ COLOR_SHADES.map((shade) => [
3694
+ shade,
3695
+ hexFromArgb(tonalPalette.tone(tones[shade]))
3696
+ ])
3697
+ );
3698
+ }, createPalette = (seed) => createPaletteFromTones(seed, SHADE_TONES), createOnPalette = (seed) => createPaletteFromTones(seed, ON_SHADE_TONES), createPalettePair = (seed) => ({
3699
+ colors: createPalette(seed),
3700
+ onColors: createOnPalette(seed)
3701
+ }), changeTone = (hex, tone) => {
3702
+ const hct = Hct.fromInt(argbFromHex(hex));
3703
+ return hexFromArgb(Hct.from(hct.hue, hct.chroma, tone).toInt());
3704
+ }, shiftHue = (hex, hueShift, tone, chromaMultiplier = 1) => {
3705
+ const hct = Hct.fromInt(argbFromHex(hex)), hue = (hct.hue + hueShift + 360) % 360, chroma = Math.min(hct.chroma * chromaMultiplier, 100);
3706
+ return hexFromArgb(Hct.from(hue, chroma, tone).toInt());
3707
+ }, getComplementaryColor = (hex) => {
3708
+ const hct = Hct.fromInt(argbFromHex(hex)), hue = (hct.hue + 110) % 360, chroma = Math.min(hct.chroma * 1.2, 100), tone = hct.tone < 50 ? 65 : Math.min(hct.tone + 10, 75);
3709
+ return hexFromArgb(Hct.from(hue, chroma, tone).toInt());
3710
+ }, createGlareStops = (base) => {
3711
+ const complementary = getComplementaryColor(base);
3712
+ return [
3713
+ createStop(changeTone(complementary, 95), 0),
3714
+ createStop(complementary, 25),
3715
+ createStop(base, 50),
3716
+ createStop(changeTone(base, 80), 75),
3717
+ createStop(changeTone(base, 20), 100)
3718
+ ];
3719
+ }, createMonochromeStops = (base) => [
3720
+ createStop(changeTone(base, 94), 0),
3721
+ createStop(changeTone(base, 72), 28),
3722
+ createStop(base, 55),
3723
+ createStop(changeTone(base, 24), 100)
3724
+ ], createComplementaryStops = (base) => [
3725
+ createStop(changeTone(getComplementaryColor(base), 88), 0),
3726
+ createStop(base, 50),
3727
+ createStop(changeTone(getComplementaryColor(base), 32), 100)
3728
+ ], createSplitComplementaryStops = (base) => [
3729
+ createStop(shiftHue(base, 148, 82, 0.95), 0),
3730
+ createStop(shiftHue(base, -148, 70, 1.05), 28),
3731
+ createStop(base, 56),
3732
+ createStop(shiftHue(base, 150, 34, 1.08), 100)
3733
+ ], createAnalogousStops = (base) => [
3734
+ createStop(shiftHue(base, -34, 72, 0.95), 0),
3735
+ createStop(base, 50),
3736
+ createStop(shiftHue(base, 34, 34, 1.05), 100)
3737
+ ], createTriadicStops = (base) => [
3738
+ createStop(shiftHue(base, -120, 78, 0.9), 0),
3739
+ createStop(base, 50),
3740
+ createStop(shiftHue(base, 120, 36, 1.05), 100)
3741
+ ], createTetradicStops = (base) => [
3742
+ createStop(shiftHue(base, -90, 78, 0.92), 0),
3743
+ createStop(base, 32),
3744
+ createStop(shiftHue(base, 90, 62, 1), 58),
3745
+ createStop(shiftHue(base, 180, 34, 1.08), 100)
3746
+ ], createRectangleStops = (base) => [
3747
+ createStop(shiftHue(base, -28, 82, 0.96), 0),
3748
+ createStop(base, 27),
3749
+ createStop(shiftHue(base, 152, 66, 1.02), 62),
3750
+ createStop(shiftHue(base, 180, 34, 1.08), 100)
3751
+ ], createSquareStops = (base) => [
3752
+ createStop(shiftHue(base, -90, 78, 0.94), 0),
3753
+ createStop(base, 30),
3754
+ createStop(shiftHue(base, 90, 62, 1), 62),
3755
+ createStop(shiftHue(base, 180, 36, 1.08), 100)
3756
+ ], createDuotoneStops = (base, colors) => {
3757
+ const first = (colors == null ? void 0 : colors[0]) ?? changeTone(base, 84), second = (colors == null ? void 0 : colors[1]) ?? getComplementaryColor(base);
3758
+ return [
3759
+ createStop(first, 0),
3760
+ createStop(base, 48),
3761
+ createStop(second, 100)
3762
+ ];
3763
+ }, gradientRecipes = {
3764
+ glare: createGlareStops,
3765
+ monochrome: createMonochromeStops,
3766
+ complementary: createComplementaryStops,
3767
+ "split-complementary": createSplitComplementaryStops,
3768
+ analogous: createAnalogousStops,
3769
+ triadic: createTriadicStops,
3770
+ tetradic: createTetradicStops,
3771
+ rectangle: createRectangleStops,
3772
+ square: createSquareStops,
3773
+ duotone: createDuotoneStops
3774
+ }, createRecipeStops = (base, recipe, colors) => gradientRecipes[recipe](base, colors), createGradientModel = (palette, options = {}) => {
3775
+ const shade = options.shade ?? 500, recipe = options.recipe ?? "glare";
3776
+ return {
3777
+ type: options.type ?? "linear",
3778
+ stops: createRecipeStops(palette[shade], recipe, options.colors),
3779
+ direction: options.direction ?? DEFAULT_GRADIENT_DIRECTION,
3780
+ shape: options.shape ?? "ellipse",
3781
+ position: options.position ?? DEFAULT_GRADIENT_POSITION,
3782
+ size: options.size ?? DEFAULT_GRADIENT_SIZE
3783
+ };
3784
+ }, createGradientModelFromColor = (color, options = {}) => createGradientModel(createPalette(color), options), defineGradientPreset = (preset) => preset, defineGradientPresetRegistry = (presets) => presets, gradientPresets = defineGradientPresetRegistry({
3785
+ materialBorder: defineGradientPreset({
3786
+ label: "Material border",
3787
+ description: "Default Gradient UI border material.",
3788
+ gradient: {
3789
+ recipe: "glare",
3790
+ type: "linear",
3791
+ direction: 135
3792
+ },
3793
+ shadow: {
3794
+ layers: 2,
3795
+ opacity: 0.22,
3796
+ blur: 12,
3797
+ y: 4,
3798
+ spread: -3
3799
+ },
3800
+ dropShadow: {
3801
+ layers: 2,
3802
+ opacity: 0.32,
3803
+ blur: 12,
3804
+ y: 5
3805
+ },
3806
+ animation: {
3807
+ preset: "shift",
3808
+ duration: 6400,
3809
+ easing: "ease-in-out"
3810
+ }
3811
+ }),
3812
+ materialAction: defineGradientPreset({
3813
+ label: "Material action",
3814
+ description: "Compact action material for buttons, chips and controls.",
3815
+ gradient: {
3816
+ recipe: "glare",
3817
+ type: "linear",
3818
+ direction: 135
3819
+ },
3820
+ shadow: {
3821
+ layers: 2,
3822
+ opacity: 0.2,
3823
+ blur: 10,
3824
+ y: 3,
3825
+ spread: -2
3826
+ },
3827
+ dropShadow: {
3828
+ layers: 2,
3829
+ opacity: 0.28,
3830
+ blur: 10,
3831
+ y: 4
3832
+ },
3833
+ animation: {
3834
+ preset: "shift",
3835
+ duration: 6800,
3836
+ easing: "ease-in-out"
3837
+ }
3838
+ }),
3839
+ materialSurface: defineGradientPreset({
3840
+ label: "Material surface",
3841
+ description: "Soft surface material for calm gradient backgrounds.",
3842
+ gradient: {
3843
+ recipe: "monochrome",
3844
+ type: "linear",
3845
+ direction: 145
3846
+ },
3847
+ shadow: {
3848
+ layers: 2,
3849
+ opacity: 0.18,
3850
+ blur: 14,
3851
+ y: 5,
3852
+ spread: -3
3853
+ },
3854
+ dropShadow: {
3855
+ layers: 2,
3856
+ opacity: 0.22,
3857
+ blur: 14,
3858
+ y: 5
3859
+ },
3860
+ animation: {
3861
+ preset: "pulse",
3862
+ duration: 7600,
3863
+ easing: "ease-in-out"
3864
+ }
3865
+ }),
3866
+ brandGlare: defineGradientPreset({
3867
+ label: "Brand glare",
3868
+ description: "Classic Gradient UI glare with a vivid complementary highlight.",
3869
+ gradient: {
3870
+ recipe: "glare",
3871
+ type: "linear",
3872
+ direction: 135
3873
+ },
3874
+ shadow: {
3875
+ layers: 2,
3876
+ opacity: 0.24,
3877
+ blur: 16,
3878
+ y: 6,
3879
+ spread: -3
3880
+ },
3881
+ dropShadow: {
3882
+ layers: 3,
3883
+ opacity: 0.38,
3884
+ blur: 16,
3885
+ y: 6
3886
+ },
3887
+ animation: {
3888
+ preset: "shift",
3889
+ duration: 6e3,
3890
+ easing: "ease-in-out"
3891
+ }
3892
+ }),
3893
+ softMono: defineGradientPreset({
3894
+ label: "Soft mono",
3895
+ description: "Quiet monochrome ramp for subtle surfaces.",
3896
+ gradient: {
3897
+ recipe: "monochrome",
3898
+ type: "linear",
3899
+ direction: 145
3900
+ },
3901
+ shadow: {
3902
+ layers: 2,
3903
+ opacity: 0.18,
3904
+ blur: 18,
3905
+ y: 7,
3906
+ spread: -4
3907
+ },
3908
+ dropShadow: {
3909
+ layers: 2,
3910
+ opacity: 0.26,
3911
+ blur: 16,
3912
+ y: 6
3913
+ },
3914
+ animation: {
3915
+ preset: "pulse",
3916
+ duration: 7200,
3917
+ easing: "ease-in-out"
3918
+ }
3919
+ }),
3920
+ neonDuo: defineGradientPreset({
3921
+ label: "Neon duo",
3922
+ description: "Punchy duotone setup with stronger glow defaults.",
3923
+ gradient: {
3924
+ recipe: "duotone",
3925
+ type: "linear",
3926
+ direction: 120
3927
+ },
3928
+ shadow: {
3929
+ layers: 2,
3930
+ opacity: 0.32,
3931
+ blur: 18,
3932
+ y: 7,
3933
+ spread: -3
3934
+ },
3935
+ dropShadow: {
3936
+ layers: 3,
3937
+ opacity: 0.52,
3938
+ blur: 18,
3939
+ y: 7
3940
+ },
3941
+ animation: {
3942
+ preset: "shift",
3943
+ duration: 5200,
3944
+ easing: "ease-in-out"
3945
+ }
3946
+ }),
3947
+ orbitalConic: defineGradientPreset({
3948
+ label: "Orbital conic",
3949
+ description: "Smooth mirrored conic gradient for badges and marks.",
3950
+ gradient: {
3951
+ recipe: "triadic",
3952
+ type: "conic",
3953
+ direction: 35,
3954
+ position: "center"
3955
+ },
3956
+ shadow: {
3957
+ layers: 2,
3958
+ opacity: 0.24,
3959
+ blur: 16,
3960
+ y: 6,
3961
+ spread: -3
3962
+ },
3963
+ dropShadow: {
3964
+ layers: 3,
3965
+ opacity: 0.36,
3966
+ blur: 16,
3967
+ y: 6
3968
+ },
3969
+ animation: {
3970
+ preset: "rotate",
3971
+ duration: 9e3
3972
+ }
3973
+ }),
3974
+ auroraRadial: defineGradientPreset({
3975
+ label: "Aurora radial",
3976
+ description: "Radial analogous gradient with slow hue motion.",
3977
+ gradient: {
3978
+ recipe: "analogous",
3979
+ type: "radial",
3980
+ direction: 0,
3981
+ position: "top left",
3982
+ shape: "circle"
3983
+ },
3984
+ shadow: {
3985
+ layers: 2,
3986
+ opacity: 0.22,
3987
+ blur: 18,
3988
+ y: 7,
3989
+ spread: -4
3990
+ },
3991
+ dropShadow: {
3992
+ layers: 3,
3993
+ opacity: 0.32,
3994
+ blur: 18,
3995
+ y: 7
3996
+ },
3997
+ animation: {
3998
+ preset: "hue-rotate",
3999
+ duration: 8e3,
4000
+ easing: "ease-in-out"
4001
+ }
4002
+ })
4003
+ }), getGradientPreset = (name, registry = gradientPresets) => registry[name] ?? gradientPresets.brandGlare;
4004
+ export {
4005
+ COLOR_SHADES as C,
4006
+ ON_SHADE_TONES as O,
4007
+ SHADE_TONES as S,
4008
+ createGradientModelFromColor as a,
4009
+ createOnPalette as b,
4010
+ createGradientModel as c,
4011
+ createPalette as d,
4012
+ createPalettePair as e,
4013
+ createRecipeStops as f,
4014
+ defineGradientPreset as g,
4015
+ defineGradientPresetRegistry as h,
4016
+ getGradientPreset as i,
4017
+ gradientPresets as j,
4018
+ gradientRecipes as k,
4019
+ argbFromHex as l,
4020
+ hexFromArgb as m,
4021
+ getComplementaryColor as n,
4022
+ changeTone as o,
4023
+ shiftHue as s,
4024
+ themeFromSourceColor as t
4025
+ };