@udixio/theme 1.0.0-beta.9 → 1.0.0

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 (205) hide show
  1. package/.eslintrc.mjs +22 -0
  2. package/CHANGELOG.md +174 -0
  3. package/README.md +6 -68
  4. package/dist/API.d.ts +14 -0
  5. package/dist/API.d.ts.map +1 -0
  6. package/dist/LICENSE +202 -0
  7. package/dist/adapter/adapter.abstract.d.ts +10 -0
  8. package/dist/adapter/adapter.abstract.d.ts.map +1 -0
  9. package/dist/{config → adapter}/config.interface.d.ts +6 -5
  10. package/dist/adapter/config.interface.d.ts.map +1 -0
  11. package/dist/adapter/define-config.d.ts +3 -0
  12. package/dist/adapter/define-config.d.ts.map +1 -0
  13. package/dist/adapter/file-adapter.mixin.d.ts +18 -0
  14. package/dist/adapter/file-adapter.mixin.d.ts.map +1 -0
  15. package/dist/adapter/index.d.ts +4 -0
  16. package/dist/adapter/index.d.ts.map +1 -0
  17. package/dist/adapters/index.d.ts +3 -0
  18. package/dist/adapters/index.d.ts.map +1 -0
  19. package/dist/adapters/node.adapter.d.ts +7 -0
  20. package/dist/adapters/node.adapter.d.ts.map +1 -0
  21. package/dist/adapters/vite.adapter.d.ts +3 -0
  22. package/dist/adapters/vite.adapter.d.ts.map +1 -0
  23. package/dist/app.container.d.ts +5 -5
  24. package/dist/app.container.d.ts.map +1 -0
  25. package/dist/app.module.d.ts +1 -0
  26. package/dist/app.module.d.ts.map +1 -0
  27. package/dist/bootstrap.d.ts +3 -0
  28. package/dist/bootstrap.d.ts.map +1 -0
  29. package/dist/color/color.api.d.ts +39 -0
  30. package/dist/color/color.api.d.ts.map +1 -0
  31. package/dist/color/color.manager.d.ts +24 -0
  32. package/dist/color/color.manager.d.ts.map +1 -0
  33. package/dist/color/color.module.d.ts +1 -0
  34. package/dist/color/color.module.d.ts.map +1 -0
  35. package/dist/color/color.utils.d.ts +8 -0
  36. package/dist/color/color.utils.d.ts.map +1 -0
  37. package/dist/color/configurable-color.d.ts +31 -0
  38. package/dist/color/configurable-color.d.ts.map +1 -0
  39. package/dist/color/default-color.d.ts +3 -0
  40. package/dist/color/default-color.d.ts.map +1 -0
  41. package/dist/color/index.d.ts +5 -4
  42. package/dist/color/index.d.ts.map +1 -0
  43. package/dist/index.cjs +3215 -0
  44. package/dist/index.d.ts +7 -4
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +3175 -7
  47. package/dist/material-color-utilities/contrastCurve.d.ts +1 -0
  48. package/dist/material-color-utilities/contrastCurve.d.ts.map +1 -0
  49. package/dist/material-color-utilities/dynamic_color.d.ts +89 -76
  50. package/dist/material-color-utilities/dynamic_color.d.ts.map +1 -0
  51. package/dist/material-color-utilities/hct_solver.d.ts +131 -0
  52. package/dist/material-color-utilities/hct_solver.d.ts.map +1 -0
  53. package/dist/material-color-utilities/htc.d.ts +77 -0
  54. package/dist/material-color-utilities/htc.d.ts.map +1 -0
  55. package/dist/material-color-utilities/index.d.ts +1 -0
  56. package/dist/material-color-utilities/index.d.ts.map +1 -0
  57. package/dist/material-color-utilities/toneDeltaPair.d.ts +19 -25
  58. package/dist/material-color-utilities/toneDeltaPair.d.ts.map +1 -0
  59. package/dist/plugin/index.d.ts +4 -0
  60. package/dist/plugin/index.d.ts.map +1 -0
  61. package/dist/plugin/plugin.abstract.d.ts +19 -5
  62. package/dist/plugin/plugin.abstract.d.ts.map +1 -0
  63. package/dist/plugin/plugin.api.d.ts +10 -0
  64. package/dist/plugin/plugin.api.d.ts.map +1 -0
  65. package/dist/plugin/plugin.module.d.ts +1 -0
  66. package/dist/plugin/plugin.module.d.ts.map +1 -0
  67. package/dist/plugins/font/font.plugin.d.ts +50 -0
  68. package/dist/plugins/font/font.plugin.d.ts.map +1 -0
  69. package/dist/plugins/font/index.d.ts +2 -0
  70. package/dist/plugins/font/index.d.ts.map +1 -0
  71. package/dist/plugins/index.d.ts +2 -0
  72. package/dist/plugins/index.d.ts.map +1 -0
  73. package/dist/theme/index.d.ts +7 -3
  74. package/dist/theme/index.d.ts.map +1 -0
  75. package/dist/theme/scheme.d.ts +20 -0
  76. package/dist/theme/scheme.d.ts.map +1 -0
  77. package/dist/theme/scheme.manager.d.ts +31 -0
  78. package/dist/theme/scheme.manager.d.ts.map +1 -0
  79. package/dist/theme/theme.api.d.ts +23 -0
  80. package/dist/theme/theme.api.d.ts.map +1 -0
  81. package/dist/theme/theme.module.d.ts +1 -0
  82. package/dist/theme/theme.module.d.ts.map +1 -0
  83. package/dist/theme/variant.d.ts +36 -0
  84. package/dist/theme/variant.d.ts.map +1 -0
  85. package/dist/theme/variant.manager.d.ts +14 -0
  86. package/dist/theme/variant.manager.d.ts.map +1 -0
  87. package/dist/theme/variants/expressive.variant.d.ts +3 -0
  88. package/dist/theme/variants/expressive.variant.d.ts.map +1 -0
  89. package/dist/theme/variants/index.d.ts +11 -0
  90. package/dist/theme/variants/index.d.ts.map +1 -0
  91. package/dist/theme/variants/neutral.variant.d.ts +3 -0
  92. package/dist/theme/variants/neutral.variant.d.ts.map +1 -0
  93. package/dist/theme/variants/tonal-spot.variant.d.ts +3 -0
  94. package/dist/theme/variants/tonal-spot.variant.d.ts.map +1 -0
  95. package/dist/theme/variants/vibrant.variant.d.ts +3 -0
  96. package/dist/theme/variants/vibrant.variant.d.ts.map +1 -0
  97. package/package.json +24 -87
  98. package/src/API.ts +23 -0
  99. package/src/adapter/adapter.abstract.ts +64 -0
  100. package/src/{config → adapter}/config.interface.ts +5 -5
  101. package/src/adapter/define-config.ts +11 -0
  102. package/src/adapter/file-adapter.mixin.ts +72 -0
  103. package/src/adapter/index.ts +3 -0
  104. package/src/adapters/index.ts +2 -0
  105. package/src/adapters/node.adapter.ts +49 -0
  106. package/src/adapters/vite.adapter.ts +79 -0
  107. package/src/app.container.ts +12 -36
  108. package/src/app.module.ts +2 -2
  109. package/src/bootstrap.ts +6 -0
  110. package/src/color/color.api.ts +75 -0
  111. package/src/color/color.manager.ts +213 -0
  112. package/src/color/color.module.ts +4 -4
  113. package/src/color/color.utils.ts +126 -0
  114. package/src/color/configurable-color.ts +67 -0
  115. package/src/color/default-color.ts +832 -0
  116. package/src/color/index.ts +4 -4
  117. package/src/index.test.ts +5 -0
  118. package/src/index.ts +6 -4
  119. package/src/material-color-utilities/dynamic_color.ts +286 -222
  120. package/src/material-color-utilities/hct_solver.ts +536 -0
  121. package/src/material-color-utilities/htc.ts +198 -0
  122. package/src/material-color-utilities/toneDeltaPair.ts +29 -11
  123. package/src/plugin/index.ts +3 -0
  124. package/src/plugin/plugin.abstract.ts +45 -5
  125. package/src/plugin/plugin.api.ts +51 -0
  126. package/src/plugin/plugin.module.ts +2 -2
  127. package/src/plugins/font/font.plugin.ts +203 -0
  128. package/src/plugins/font/index.ts +1 -0
  129. package/src/plugins/index.ts +1 -0
  130. package/src/theme/index.ts +6 -3
  131. package/src/theme/{services/scheme.service.ts → scheme.manager.ts} +39 -19
  132. package/src/theme/{entities/scheme.entity.ts → scheme.ts} +20 -4
  133. package/src/theme/{services/theme.service.ts → theme.api.ts} +23 -19
  134. package/src/theme/theme.module.ts +6 -4
  135. package/src/theme/variant.manager.ts +58 -0
  136. package/src/theme/variant.ts +53 -0
  137. package/src/theme/variants/expressive.variant.ts +81 -0
  138. package/src/theme/variants/index.ts +16 -0
  139. package/src/theme/variants/neutral.variant.ts +45 -0
  140. package/src/theme/variants/tonal-spot.variant.ts +35 -0
  141. package/src/theme/variants/vibrant.variant.ts +72 -0
  142. package/tsconfig.json +13 -0
  143. package/tsconfig.lib.json +33 -0
  144. package/tsconfig.spec.json +36 -0
  145. package/vite.config.ts +54 -0
  146. package/LICENSE +0 -21
  147. package/dist/app.service.d.ts +0 -13
  148. package/dist/color/color.interface.d.ts +0 -8
  149. package/dist/color/entities/color.entity.d.ts +0 -42
  150. package/dist/color/entities/index.d.ts +0 -1
  151. package/dist/color/models/default-color.model.d.ts +0 -3
  152. package/dist/color/models/index.d.ts +0 -1
  153. package/dist/color/services/color-manager.service.d.ts +0 -18
  154. package/dist/color/services/color.service.d.ts +0 -21
  155. package/dist/color/services/index.d.ts +0 -2
  156. package/dist/config/config.module.d.ts +0 -2
  157. package/dist/config/config.service.d.ts +0 -12
  158. package/dist/config/index.d.ts +0 -2
  159. package/dist/main.d.ts +0 -3
  160. package/dist/plugin/plugin.service.d.ts +0 -10
  161. package/dist/plugins/tailwind/Tailwind.plugin.d.ts +0 -14
  162. package/dist/plugins/tailwind/main.d.ts +0 -10
  163. package/dist/plugins/tailwind/plugins-tailwind/state.d.ts +0 -4
  164. package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +0 -4
  165. package/dist/theme/entities/index.d.ts +0 -2
  166. package/dist/theme/entities/scheme.entity.d.ts +0 -15
  167. package/dist/theme/entities/variant.entity.d.ts +0 -7
  168. package/dist/theme/models/index.d.ts +0 -1
  169. package/dist/theme/models/variant.model.d.ts +0 -8
  170. package/dist/theme/services/index.d.ts +0 -3
  171. package/dist/theme/services/scheme.service.d.ts +0 -17
  172. package/dist/theme/services/theme.service.d.ts +0 -22
  173. package/dist/theme/services/variant.service.d.ts +0 -13
  174. package/dist/theme.cjs.development.js +0 -1983
  175. package/dist/theme.cjs.development.js.map +0 -1
  176. package/dist/theme.cjs.production.min.js +0 -2
  177. package/dist/theme.cjs.production.min.js.map +0 -1
  178. package/dist/theme.esm.js +0 -1955
  179. package/dist/theme.esm.js.map +0 -1
  180. package/src/app.service.spec.ts +0 -15
  181. package/src/app.service.ts +0 -23
  182. package/src/color/color.interface.ts +0 -13
  183. package/src/color/entities/color.entity.ts +0 -71
  184. package/src/color/entities/index.ts +0 -1
  185. package/src/color/models/default-color.model.ts +0 -300
  186. package/src/color/models/index.ts +0 -1
  187. package/src/color/services/color-manager.service.ts +0 -191
  188. package/src/color/services/color.service.spec.ts +0 -28
  189. package/src/color/services/color.service.ts +0 -75
  190. package/src/color/services/index.ts +0 -2
  191. package/src/config/config.module.ts +0 -7
  192. package/src/config/config.service.ts +0 -74
  193. package/src/config/index.ts +0 -2
  194. package/src/main.ts +0 -14
  195. package/src/plugin/plugin.service.ts +0 -30
  196. package/src/plugins/tailwind/Tailwind.plugin.ts +0 -53
  197. package/src/plugins/tailwind/main.ts +0 -18
  198. package/src/plugins/tailwind/plugins-tailwind/state.ts +0 -88
  199. package/src/plugins/tailwind/plugins-tailwind/themer.ts +0 -53
  200. package/src/theme/entities/index.ts +0 -2
  201. package/src/theme/entities/variant.entity.ts +0 -39
  202. package/src/theme/models/index.ts +0 -1
  203. package/src/theme/models/variant.model.ts +0 -63
  204. package/src/theme/services/index.ts +0 -3
  205. package/src/theme/services/variant.service.ts +0 -52
package/dist/index.cjs ADDED
@@ -0,0 +1,3215 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
27
+ const awilix = require("awilix");
28
+ const materialColorUtilities = require("@material/material-color-utilities");
29
+ const vite = require("vite");
30
+ const path = require("node:path");
31
+ const fs = require("node:fs");
32
+ function _interopNamespaceDefault(e) {
33
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
34
+ if (e) {
35
+ for (const k in e) {
36
+ if (k !== "default") {
37
+ const d = Object.getOwnPropertyDescriptor(e, k);
38
+ Object.defineProperty(n, k, d.get ? d : {
39
+ enumerable: true,
40
+ get: () => e[k]
41
+ });
42
+ }
43
+ }
44
+ }
45
+ n.default = e;
46
+ return Object.freeze(n);
47
+ }
48
+ const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
49
+ const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
50
+ class ColorApi {
51
+ constructor({ colorManager }) {
52
+ __publicField(this, "colorManager");
53
+ this.colorManager = colorManager;
54
+ }
55
+ getColors() {
56
+ return this.colorManager.getAll();
57
+ }
58
+ addColor(key, color) {
59
+ return this.colorManager.createOrUpdate(key, color);
60
+ }
61
+ addColors(args) {
62
+ if (!Array.isArray(args)) args = [args];
63
+ args.forEach((args2) => {
64
+ if (typeof args2 === "function") {
65
+ args2 = args2(this);
66
+ }
67
+ if (args2.fromPalettes) {
68
+ if (!Array.isArray(args2.fromPalettes))
69
+ args2.fromPalettes = [args2.fromPalettes];
70
+ args2.fromPalettes.map((paletteKey) => {
71
+ this.colorManager.addFromPalette(paletteKey);
72
+ });
73
+ }
74
+ if (args2.colors) {
75
+ Object.keys(args2.colors).map(
76
+ (key) => this.addColor(key, args2.colors[key])
77
+ );
78
+ }
79
+ });
80
+ }
81
+ getColor(key) {
82
+ return this.colorManager.get(key);
83
+ }
84
+ removeColor(key) {
85
+ return this.colorManager.remove(key);
86
+ }
87
+ updateColor(key, newColor) {
88
+ return this.colorManager.createOrUpdate(key, newColor);
89
+ }
90
+ }
91
+ /**
92
+ * @license
93
+ * Copyright 2023 Google LLC
94
+ *
95
+ * Licensed under the Apache License, Version 2.0 (the "License");
96
+ * you may not use this file except in compliance with the License.
97
+ * You may obtain a copy of the License at
98
+ *
99
+ * http://www.apache.org/licenses/LICENSE-2.0
100
+ *
101
+ * Unless required by applicable law or agreed to in writing, software
102
+ * distributed under the License is distributed on an "AS IS" BASIS,
103
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104
+ * See the License for the specific language governing permissions and
105
+ * limitations under the License.
106
+ */
107
+ class ContrastCurve {
108
+ /**
109
+ * Creates a `ContrastCurve` object.
110
+ *
111
+ * @param low Value for contrast level -1.0
112
+ * @param normal Value for contrast level 0.0
113
+ * @param medium Value for contrast level 0.5
114
+ * @param high Value for contrast level 1.0
115
+ */
116
+ constructor(low, normal, medium, high) {
117
+ this.low = low;
118
+ this.normal = normal;
119
+ this.medium = medium;
120
+ this.high = high;
121
+ }
122
+ /**
123
+ * Returns the value at a given contrast level.
124
+ *
125
+ * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
126
+ * is the lowest; 1.0 is the highest.
127
+ * @return The value. For contrast ratios, a number between 1.0 and 21.0.
128
+ */
129
+ get(contrastLevel) {
130
+ if (contrastLevel <= -1) {
131
+ return this.low;
132
+ } else if (contrastLevel < 0) {
133
+ return materialColorUtilities.lerp(this.low, this.normal, (contrastLevel - -1) / 1);
134
+ } else if (contrastLevel < 0.5) {
135
+ return materialColorUtilities.lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);
136
+ } else if (contrastLevel < 1) {
137
+ return materialColorUtilities.lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);
138
+ } else {
139
+ return this.high;
140
+ }
141
+ }
142
+ }
143
+ /**
144
+ * @license
145
+ * Copyright 2021 Google LLC
146
+ *
147
+ * Licensed under the Apache License, Version 2.0 (the "License");
148
+ * you may not use this file except in compliance with the License.
149
+ * You may obtain a copy of the License at
150
+ *
151
+ * http://www.apache.org/licenses/LICENSE-2.0
152
+ *
153
+ * Unless required by applicable law or agreed to in writing, software
154
+ * distributed under the License is distributed on an "AS IS" BASIS,
155
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
156
+ * See the License for the specific language governing permissions and
157
+ * limitations under the License.
158
+ */
159
+ const _HctSolver = class _HctSolver {
160
+ /**
161
+ * Finds an sRGB color with the given hue, chroma, and L*, if
162
+ * possible.
163
+ *
164
+ * @param hueDegrees The desired hue, in degrees.
165
+ * @param chroma The desired chroma.
166
+ * @param lstar The desired L*.
167
+ * @return A hexadecimal representing the sRGB color. The color
168
+ * has sufficiently close hue, chroma, and L* to the desired
169
+ * values, if possible; otherwise, the hue and L* will be
170
+ * sufficiently close, and chroma will be maximized.
171
+ */
172
+ static solveToInt(hueDegrees, chroma, lstar) {
173
+ if (chroma < 1e-4 || lstar < 1e-4 || lstar > 99.9999) {
174
+ return materialColorUtilities.argbFromLstar(lstar);
175
+ }
176
+ hueDegrees = materialColorUtilities.sanitizeDegreesDouble(hueDegrees);
177
+ const hueRadians = hueDegrees / 180 * Math.PI;
178
+ const y = materialColorUtilities.yFromLstar(lstar);
179
+ const exactAnswer = _HctSolver.findResultByJ(hueRadians, chroma, y);
180
+ if (exactAnswer !== 0) {
181
+ return exactAnswer;
182
+ }
183
+ const linrgb = _HctSolver.bisectToLimit(y, hueRadians);
184
+ return materialColorUtilities.argbFromLinrgb(linrgb);
185
+ }
186
+ /**
187
+ * Finds an sRGB color with the given hue, chroma, and L*, if
188
+ * possible.
189
+ *
190
+ * @param hueDegrees The desired hue, in degrees.
191
+ * @param chroma The desired chroma.
192
+ * @param lstar The desired L*.
193
+ * @return An CAM16 object representing the sRGB color. The color
194
+ * has sufficiently close hue, chroma, and L* to the desired
195
+ * values, if possible; otherwise, the hue and L* will be
196
+ * sufficiently close, and chroma will be maximized.
197
+ */
198
+ static solveToCam(hueDegrees, chroma, lstar) {
199
+ return materialColorUtilities.Cam16.fromInt(_HctSolver.solveToInt(hueDegrees, chroma, lstar));
200
+ }
201
+ /**
202
+ * Sanitizes a small enough angle in radians.
203
+ *
204
+ * @param angle An angle in radians; must not deviate too much
205
+ * from 0.
206
+ * @return A coterminal angle between 0 and 2pi.
207
+ */
208
+ static sanitizeRadians(angle) {
209
+ return (angle + Math.PI * 8) % (Math.PI * 2);
210
+ }
211
+ /**
212
+ * Delinearizes an RGB component, returning a floating-point
213
+ * number.
214
+ *
215
+ * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
216
+ * linear R/G/B channel
217
+ * @return 0.0 <= output <= 255.0, color channel converted to
218
+ * regular RGB space
219
+ */
220
+ static trueDelinearized(rgbComponent) {
221
+ const normalized = rgbComponent / 100;
222
+ let delinearized = 0;
223
+ if (normalized <= 31308e-7) {
224
+ delinearized = normalized * 12.92;
225
+ } else {
226
+ delinearized = 1.055 * Math.pow(normalized, 1 / 2.4) - 0.055;
227
+ }
228
+ return delinearized * 255;
229
+ }
230
+ static chromaticAdaptation(component) {
231
+ const af = Math.pow(Math.abs(component), 0.42);
232
+ return materialColorUtilities.signum(component) * 400 * af / (af + 27.13);
233
+ }
234
+ /**
235
+ * Returns the hue of a linear RGB color in CAM16.
236
+ *
237
+ * @param linrgb The linear RGB coordinates of a color.
238
+ * @return The hue of the color in CAM16, in radians.
239
+ */
240
+ static hueOf(linrgb) {
241
+ const scaledDiscount = materialColorUtilities.matrixMultiply(
242
+ linrgb,
243
+ _HctSolver.SCALED_DISCOUNT_FROM_LINRGB
244
+ );
245
+ const rA = _HctSolver.chromaticAdaptation(scaledDiscount[0]);
246
+ const gA = _HctSolver.chromaticAdaptation(scaledDiscount[1]);
247
+ const bA = _HctSolver.chromaticAdaptation(scaledDiscount[2]);
248
+ const a = (11 * rA + -12 * gA + bA) / 11;
249
+ const b = (rA + gA - 2 * bA) / 9;
250
+ return Math.atan2(b, a);
251
+ }
252
+ static areInCyclicOrder(a, b, c) {
253
+ const deltaAB = _HctSolver.sanitizeRadians(b - a);
254
+ const deltaAC = _HctSolver.sanitizeRadians(c - a);
255
+ return deltaAB < deltaAC;
256
+ }
257
+ /**
258
+ * Solves the lerp equation.
259
+ *
260
+ * @param source The starting number.
261
+ * @param mid The number in the middle.
262
+ * @param target The ending number.
263
+ * @return A number t such that lerp(source, target, t) = mid.
264
+ */
265
+ static intercept(source, mid, target) {
266
+ return (mid - source) / (target - source);
267
+ }
268
+ static lerpPoint(source, t, target) {
269
+ return [
270
+ source[0] + (target[0] - source[0]) * t,
271
+ source[1] + (target[1] - source[1]) * t,
272
+ source[2] + (target[2] - source[2]) * t
273
+ ];
274
+ }
275
+ /**
276
+ * Intersects a segment with a plane.
277
+ *
278
+ * @param source The coordinates of point A.
279
+ * @param coordinate The R-, G-, or B-coordinate of the plane.
280
+ * @param target The coordinates of point B.
281
+ * @param axis The axis the plane is perpendicular with. (0: R, 1:
282
+ * G, 2: B)
283
+ * @return The intersection point of the segment AB with the plane
284
+ * R=coordinate, G=coordinate, or B=coordinate
285
+ */
286
+ static setCoordinate(source, coordinate, target, axis) {
287
+ const t = _HctSolver.intercept(source[axis], coordinate, target[axis]);
288
+ return _HctSolver.lerpPoint(source, t, target);
289
+ }
290
+ static isBounded(x) {
291
+ return 0 <= x && x <= 100;
292
+ }
293
+ /**
294
+ * Returns the nth possible vertex of the polygonal intersection.
295
+ *
296
+ * @param y The Y value of the plane.
297
+ * @param n The zero-based index of the point. 0 <= n <= 11.
298
+ * @return The nth possible vertex of the polygonal intersection
299
+ * of the y plane and the RGB cube, in linear RGB coordinates, if
300
+ * it exists. If this possible vertex lies outside of the cube,
301
+ * [-1.0, -1.0, -1.0] is returned.
302
+ */
303
+ static nthVertex(y, n) {
304
+ const kR = _HctSolver.Y_FROM_LINRGB[0];
305
+ const kG = _HctSolver.Y_FROM_LINRGB[1];
306
+ const kB = _HctSolver.Y_FROM_LINRGB[2];
307
+ const coordA = n % 4 <= 1 ? 0 : 100;
308
+ const coordB = n % 2 === 0 ? 0 : 100;
309
+ if (n < 4) {
310
+ const g = coordA;
311
+ const b = coordB;
312
+ const r = (y - g * kG - b * kB) / kR;
313
+ if (_HctSolver.isBounded(r)) {
314
+ return [r, g, b];
315
+ } else {
316
+ return [-1, -1, -1];
317
+ }
318
+ } else if (n < 8) {
319
+ const b = coordA;
320
+ const r = coordB;
321
+ const g = (y - r * kR - b * kB) / kG;
322
+ if (_HctSolver.isBounded(g)) {
323
+ return [r, g, b];
324
+ } else {
325
+ return [-1, -1, -1];
326
+ }
327
+ } else {
328
+ const r = coordA;
329
+ const g = coordB;
330
+ const b = (y - r * kR - g * kG) / kB;
331
+ if (_HctSolver.isBounded(b)) {
332
+ return [r, g, b];
333
+ } else {
334
+ return [-1, -1, -1];
335
+ }
336
+ }
337
+ }
338
+ /**
339
+ * Finds the segment containing the desired color.
340
+ *
341
+ * @param y The Y value of the color.
342
+ * @param targetHue The hue of the color.
343
+ * @return A list of two sets of linear RGB coordinates, each
344
+ * corresponding to an endpoint of the segment containing the
345
+ * desired color.
346
+ */
347
+ static bisectToSegment(y, targetHue) {
348
+ let left = [-1, -1, -1];
349
+ let right = left;
350
+ let leftHue = 0;
351
+ let rightHue = 0;
352
+ let initialized = false;
353
+ let uncut = true;
354
+ for (let n = 0; n < 12; n++) {
355
+ const mid = _HctSolver.nthVertex(y, n);
356
+ if (mid[0] < 0) {
357
+ continue;
358
+ }
359
+ const midHue = _HctSolver.hueOf(mid);
360
+ if (!initialized) {
361
+ left = mid;
362
+ right = mid;
363
+ leftHue = midHue;
364
+ rightHue = midHue;
365
+ initialized = true;
366
+ continue;
367
+ }
368
+ if (uncut || _HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) {
369
+ uncut = false;
370
+ if (_HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {
371
+ right = mid;
372
+ rightHue = midHue;
373
+ } else {
374
+ left = mid;
375
+ leftHue = midHue;
376
+ }
377
+ }
378
+ }
379
+ return [left, right];
380
+ }
381
+ static midpoint(a, b) {
382
+ return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
383
+ }
384
+ static criticalPlaneBelow(x) {
385
+ return Math.floor(x - 0.5);
386
+ }
387
+ static criticalPlaneAbove(x) {
388
+ return Math.ceil(x - 0.5);
389
+ }
390
+ /**
391
+ * Finds a color with the given Y and hue on the boundary of the
392
+ * cube.
393
+ *
394
+ * @param y The Y value of the color.
395
+ * @param targetHue The hue of the color.
396
+ * @return The desired color, in linear RGB coordinates.
397
+ */
398
+ static bisectToLimit(y, targetHue) {
399
+ const segment = _HctSolver.bisectToSegment(y, targetHue);
400
+ let left = segment[0];
401
+ let leftHue = _HctSolver.hueOf(left);
402
+ let right = segment[1];
403
+ for (let axis = 0; axis < 3; axis++) {
404
+ if (left[axis] !== right[axis]) {
405
+ let lPlane = -1;
406
+ let rPlane = 255;
407
+ if (left[axis] < right[axis]) {
408
+ lPlane = _HctSolver.criticalPlaneBelow(
409
+ _HctSolver.trueDelinearized(left[axis])
410
+ );
411
+ rPlane = _HctSolver.criticalPlaneAbove(
412
+ _HctSolver.trueDelinearized(right[axis])
413
+ );
414
+ } else {
415
+ lPlane = _HctSolver.criticalPlaneAbove(
416
+ _HctSolver.trueDelinearized(left[axis])
417
+ );
418
+ rPlane = _HctSolver.criticalPlaneBelow(
419
+ _HctSolver.trueDelinearized(right[axis])
420
+ );
421
+ }
422
+ for (let i = 0; i < 8; i++) {
423
+ if (Math.abs(rPlane - lPlane) <= 1) {
424
+ break;
425
+ } else {
426
+ const mPlane = Math.floor((lPlane + rPlane) / 2);
427
+ const midPlaneCoordinate = _HctSolver.CRITICAL_PLANES[mPlane];
428
+ const mid = _HctSolver.setCoordinate(
429
+ left,
430
+ midPlaneCoordinate,
431
+ right,
432
+ axis
433
+ );
434
+ const midHue = _HctSolver.hueOf(mid);
435
+ if (_HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {
436
+ right = mid;
437
+ rPlane = mPlane;
438
+ } else {
439
+ left = mid;
440
+ leftHue = midHue;
441
+ lPlane = mPlane;
442
+ }
443
+ }
444
+ }
445
+ }
446
+ }
447
+ return _HctSolver.midpoint(left, right);
448
+ }
449
+ static inverseChromaticAdaptation(adapted) {
450
+ const adaptedAbs = Math.abs(adapted);
451
+ const base = Math.max(0, 27.13 * adaptedAbs / (400 - adaptedAbs));
452
+ return materialColorUtilities.signum(adapted) * Math.pow(base, 1 / 0.42);
453
+ }
454
+ /**
455
+ * Finds a color with the given hue, chroma, and Y.
456
+ *
457
+ * @param hueRadians The desired hue in radians.
458
+ * @param chroma The desired chroma.
459
+ * @param y The desired Y.
460
+ * @return The desired color as a hexadecimal integer, if found; 0
461
+ * otherwise.
462
+ */
463
+ static findResultByJ(hueRadians, chroma, y) {
464
+ let j = Math.sqrt(y) * 11;
465
+ const viewingConditions = materialColorUtilities.ViewingConditions.DEFAULT;
466
+ const tInnerCoeff = 1 / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);
467
+ const eHue = 0.25 * (Math.cos(hueRadians + 2) + 3.8);
468
+ const p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb;
469
+ const hSin = Math.sin(hueRadians);
470
+ const hCos = Math.cos(hueRadians);
471
+ for (let iterationRound = 0; iterationRound < 5; iterationRound++) {
472
+ const jNormalized = j / 100;
473
+ const alpha = chroma === 0 || j === 0 ? 0 : chroma / Math.sqrt(jNormalized);
474
+ const t = Math.pow(alpha * tInnerCoeff, 1 / 0.9);
475
+ const ac = viewingConditions.aw * Math.pow(jNormalized, 1 / viewingConditions.c / viewingConditions.z);
476
+ const p2 = ac / viewingConditions.nbb;
477
+ const gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin);
478
+ const a = gamma * hCos;
479
+ const b = gamma * hSin;
480
+ const rA = (460 * p2 + 451 * a + 288 * b) / 1403;
481
+ const gA = (460 * p2 - 891 * a - 261 * b) / 1403;
482
+ const bA = (460 * p2 - 220 * a - 6300 * b) / 1403;
483
+ const rCScaled = _HctSolver.inverseChromaticAdaptation(rA);
484
+ const gCScaled = _HctSolver.inverseChromaticAdaptation(gA);
485
+ const bCScaled = _HctSolver.inverseChromaticAdaptation(bA);
486
+ const linrgb = materialColorUtilities.matrixMultiply(
487
+ [rCScaled, gCScaled, bCScaled],
488
+ _HctSolver.LINRGB_FROM_SCALED_DISCOUNT
489
+ );
490
+ if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0) {
491
+ return 0;
492
+ }
493
+ const kR = _HctSolver.Y_FROM_LINRGB[0];
494
+ const kG = _HctSolver.Y_FROM_LINRGB[1];
495
+ const kB = _HctSolver.Y_FROM_LINRGB[2];
496
+ const fnj = kR * linrgb[0] + kG * linrgb[1] + kB * linrgb[2];
497
+ if (fnj <= 0) {
498
+ return 0;
499
+ }
500
+ if (iterationRound === 4 || Math.abs(fnj - y) < 2e-3) {
501
+ if (linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01) {
502
+ return 0;
503
+ }
504
+ return materialColorUtilities.argbFromLinrgb(linrgb);
505
+ }
506
+ j = j - (fnj - y) * j / (2 * fnj);
507
+ }
508
+ return 0;
509
+ }
510
+ };
511
+ __publicField(_HctSolver, "SCALED_DISCOUNT_FROM_LINRGB", [
512
+ [0.001200833568784504, 0.002389694492170889, 2795742885861124e-19],
513
+ [5891086651375999e-19, 0.0029785502573438758, 3270666104008398e-19],
514
+ [10146692491640572e-20, 5364214359186694e-19, 0.0032979401770712076]
515
+ ]);
516
+ __publicField(_HctSolver, "LINRGB_FROM_SCALED_DISCOUNT", [
517
+ [1373.2198709594231, -1100.4251190754821, -7.278681089101213],
518
+ [-271.815969077903, 559.6580465940733, -32.46047482791194],
519
+ [1.9622899599665666, -57.173814538844006, 308.7233197812385]
520
+ ]);
521
+ __publicField(_HctSolver, "Y_FROM_LINRGB", [0.2126, 0.7152, 0.0722]);
522
+ __publicField(_HctSolver, "CRITICAL_PLANES", [
523
+ 0.015176349177441876,
524
+ 0.045529047532325624,
525
+ 0.07588174588720938,
526
+ 0.10623444424209313,
527
+ 0.13658714259697685,
528
+ 0.16693984095186062,
529
+ 0.19729253930674434,
530
+ 0.2276452376616281,
531
+ 0.2579979360165119,
532
+ 0.28835063437139563,
533
+ 0.3188300904430532,
534
+ 0.350925934958123,
535
+ 0.3848314933096426,
536
+ 0.42057480301049466,
537
+ 0.458183274052838,
538
+ 0.4976837250274023,
539
+ 0.5391024159806381,
540
+ 0.5824650784040898,
541
+ 0.6277969426914107,
542
+ 0.6751227633498623,
543
+ 0.7244668422128921,
544
+ 0.775853049866786,
545
+ 0.829304845476233,
546
+ 0.8848452951698498,
547
+ 0.942497089126609,
548
+ 1.0022825574869039,
549
+ 1.0642236851973577,
550
+ 1.1283421258858297,
551
+ 1.1946592148522128,
552
+ 1.2631959812511864,
553
+ 1.3339731595349034,
554
+ 1.407011200216447,
555
+ 1.4823302800086415,
556
+ 1.5599503113873272,
557
+ 1.6398909516233677,
558
+ 1.7221716113234105,
559
+ 1.8068114625156377,
560
+ 1.8938294463134073,
561
+ 1.9832442801866852,
562
+ 2.075074464868551,
563
+ 2.1693382909216234,
564
+ 2.2660538449872063,
565
+ 2.36523901573795,
566
+ 2.4669114995532007,
567
+ 2.5710888059345764,
568
+ 2.6777882626779785,
569
+ 2.7870270208169257,
570
+ 2.898822059350997,
571
+ 3.0131901897720907,
572
+ 3.1301480604002863,
573
+ 3.2497121605402226,
574
+ 3.3718988244681087,
575
+ 3.4967242352587946,
576
+ 3.624204428461639,
577
+ 3.754355295633311,
578
+ 3.887192587735158,
579
+ 4.022731918402185,
580
+ 4.160988767090289,
581
+ 4.301978482107941,
582
+ 4.445716283538092,
583
+ 4.592217266055746,
584
+ 4.741496401646282,
585
+ 4.893568542229298,
586
+ 5.048448422192488,
587
+ 5.20615066083972,
588
+ 5.3666897647573375,
589
+ 5.5300801301023865,
590
+ 5.696336044816294,
591
+ 5.865471690767354,
592
+ 6.037501145825082,
593
+ 6.212438385869475,
594
+ 6.390297286737924,
595
+ 6.571091626112461,
596
+ 6.7548350853498045,
597
+ 6.941541251256611,
598
+ 7.131223617812143,
599
+ 7.323895587840543,
600
+ 7.5195704746346665,
601
+ 7.7182615035334345,
602
+ 7.919981813454504,
603
+ 8.124744458384042,
604
+ 8.332562408825165,
605
+ 8.543448553206703,
606
+ 8.757415699253682,
607
+ 8.974476575321063,
608
+ 9.194643831691977,
609
+ 9.417930041841839,
610
+ 9.644347703669503,
611
+ 9.873909240696694,
612
+ 10.106627003236781,
613
+ 10.342513269534024,
614
+ 10.58158024687427,
615
+ 10.8238400726681,
616
+ 11.069304815507364,
617
+ 11.317986476196008,
618
+ 11.569896988756009,
619
+ 11.825048221409341,
620
+ 12.083451977536606,
621
+ 12.345119996613247,
622
+ 12.610063955123938,
623
+ 12.878295467455942,
624
+ 13.149826086772048,
625
+ 13.42466730586372,
626
+ 13.702830557985108,
627
+ 13.984327217668513,
628
+ 14.269168601521828,
629
+ 14.55736596900856,
630
+ 14.848930523210871,
631
+ 15.143873411576273,
632
+ 15.44220572664832,
633
+ 15.743938506781891,
634
+ 16.04908273684337,
635
+ 16.35764934889634,
636
+ 16.66964922287304,
637
+ 16.985093187232053,
638
+ 17.30399201960269,
639
+ 17.62635644741625,
640
+ 17.95219714852476,
641
+ 18.281524751807332,
642
+ 18.614349837764564,
643
+ 18.95068293910138,
644
+ 19.290534541298456,
645
+ 19.633915083172692,
646
+ 19.98083495742689,
647
+ 20.331304511189067,
648
+ 20.685334046541502,
649
+ 21.042933821039977,
650
+ 21.404114048223256,
651
+ 21.76888489811322,
652
+ 22.137256497705877,
653
+ 22.50923893145328,
654
+ 22.884842241736916,
655
+ 23.264076429332462,
656
+ 23.6469514538663,
657
+ 24.033477234264016,
658
+ 24.42366364919083,
659
+ 24.817520537484558,
660
+ 25.21505769858089,
661
+ 25.61628489293138,
662
+ 26.021211842414342,
663
+ 26.429848230738664,
664
+ 26.842203703840827,
665
+ 27.258287870275353,
666
+ 27.678110301598522,
667
+ 28.10168053274597,
668
+ 28.529008062403893,
669
+ 28.96010235337422,
670
+ 29.39497283293396,
671
+ 29.83362889318845,
672
+ 30.276079891419332,
673
+ 30.722335150426627,
674
+ 31.172403958865512,
675
+ 31.62629557157785,
676
+ 32.08401920991837,
677
+ 32.54558406207592,
678
+ 33.010999283389665,
679
+ 33.4802739966603,
680
+ 33.953417292456834,
681
+ 34.430438229418264,
682
+ 34.911345834551085,
683
+ 35.39614910352207,
684
+ 35.88485700094671,
685
+ 36.37747846067349,
686
+ 36.87402238606382,
687
+ 37.37449765026789,
688
+ 37.87891309649659,
689
+ 38.38727753828926,
690
+ 38.89959975977785,
691
+ 39.41588851594697,
692
+ 39.93615253289054,
693
+ 40.460400508064545,
694
+ 40.98864111053629,
695
+ 41.520882981230194,
696
+ 42.05713473317016,
697
+ 42.597404951718396,
698
+ 43.141702194811224,
699
+ 43.6900349931913,
700
+ 44.24241185063697,
701
+ 44.798841244188324,
702
+ 45.35933162437017,
703
+ 45.92389141541209,
704
+ 46.49252901546552,
705
+ 47.065252796817916,
706
+ 47.64207110610409,
707
+ 48.22299226451468,
708
+ 48.808024568002054,
709
+ 49.3971762874833,
710
+ 49.9904556690408,
711
+ 50.587870934119984,
712
+ 51.189430279724725,
713
+ 51.79514187861014,
714
+ 52.40501387947288,
715
+ 53.0190544071392,
716
+ 53.637271562750364,
717
+ 54.259673423945976,
718
+ 54.88626804504493,
719
+ 55.517063457223934,
720
+ 56.15206766869424,
721
+ 56.79128866487574,
722
+ 57.43473440856916,
723
+ 58.08241284012621,
724
+ 58.734331877617365,
725
+ 59.39049941699807,
726
+ 60.05092333227251,
727
+ 60.715611475655585,
728
+ 61.38457167773311,
729
+ 62.057811747619894,
730
+ 62.7353394731159,
731
+ 63.417162620860914,
732
+ 64.10328893648692,
733
+ 64.79372614476921,
734
+ 65.48848194977529,
735
+ 66.18756403501224,
736
+ 66.89098006357258,
737
+ 67.59873767827808,
738
+ 68.31084450182222,
739
+ 69.02730813691093,
740
+ 69.74813616640164,
741
+ 70.47333615344107,
742
+ 71.20291564160104,
743
+ 71.93688215501312,
744
+ 72.67524319850172,
745
+ 73.41800625771542,
746
+ 74.16517879925733,
747
+ 74.9167682708136,
748
+ 75.67278210128072,
749
+ 76.43322770089146,
750
+ 77.1981124613393,
751
+ 77.96744375590167,
752
+ 78.74122893956174,
753
+ 79.51947534912904,
754
+ 80.30219030335869,
755
+ 81.08938110306934,
756
+ 81.88105503125999,
757
+ 82.67721935322541,
758
+ 83.4778813166706,
759
+ 84.28304815182372,
760
+ 85.09272707154808,
761
+ 85.90692527145302,
762
+ 86.72564993000343,
763
+ 87.54890820862819,
764
+ 88.3767072518277,
765
+ 89.2090541872801,
766
+ 90.04595612594655,
767
+ 90.88742016217518,
768
+ 91.73345337380438,
769
+ 92.58406282226491,
770
+ 93.43925555268066,
771
+ 94.29903859396902,
772
+ 95.16341895893969,
773
+ 96.03240364439274,
774
+ 96.9059996312159,
775
+ 97.78421388448044,
776
+ 98.6670533535366,
777
+ 99.55452497210776
778
+ ]);
779
+ let HctSolver = _HctSolver;
780
+ /**
781
+ * @license
782
+ * Copyright 2021 Google LLC
783
+ *
784
+ * Licensed under the Apache License, Version 2.0 (the "License");
785
+ * you may not use this file except in compliance with the License.
786
+ * You may obtain a copy of the License at
787
+ *
788
+ * http://www.apache.org/licenses/LICENSE-2.0
789
+ *
790
+ * Unless required by applicable law or agreed to in writing, software
791
+ * distributed under the License is distributed on an "AS IS" BASIS,
792
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
793
+ * See the License for the specific language governing permissions and
794
+ * limitations under the License.
795
+ */
796
+ class Hct {
797
+ constructor(argb) {
798
+ /**
799
+ * @param hue 0 <= hue < 360; invalid values are corrected.
800
+ * @param chroma 0 <= chroma < ?; Informally, colorfulness. The color
801
+ * returned may be lower than the requested chroma. Chroma has a different
802
+ * maximum for any given hue and tone.
803
+ * @param tone 0 <= tone <= 100; invalid values are corrected.
804
+ * @return HCT representation of a color in default viewing conditions.
805
+ */
806
+ __publicField(this, "internalHue");
807
+ __publicField(this, "internalChroma");
808
+ __publicField(this, "internalTone");
809
+ this.argb = argb;
810
+ const cam = materialColorUtilities.Cam16.fromInt(argb);
811
+ this.internalHue = cam.hue;
812
+ this.internalChroma = cam.chroma;
813
+ this.internalTone = materialColorUtilities.lstarFromArgb(argb);
814
+ this.argb = argb;
815
+ }
816
+ /**
817
+ * A number, in degrees, representing ex. red, orange, yellow, etc.
818
+ * Ranges from 0 <= hue < 360.
819
+ */
820
+ get hue() {
821
+ return this.internalHue;
822
+ }
823
+ /**
824
+ * @param newHue 0 <= newHue < 360; invalid values are corrected.
825
+ * Chroma may decrease because chroma has a different maximum for any given
826
+ * hue and tone.
827
+ */
828
+ set hue(newHue) {
829
+ this.setInternalState(
830
+ HctSolver.solveToInt(newHue, this.internalChroma, this.internalTone)
831
+ );
832
+ }
833
+ get chroma() {
834
+ return this.internalChroma;
835
+ }
836
+ /**
837
+ * @param newChroma 0 <= newChroma < ?
838
+ * Chroma may decrease because chroma has a different maximum for any given
839
+ * hue and tone.
840
+ */
841
+ set chroma(newChroma) {
842
+ this.setInternalState(
843
+ HctSolver.solveToInt(this.internalHue, newChroma, this.internalTone)
844
+ );
845
+ }
846
+ /** Lightness. Ranges from 0 to 100. */
847
+ get tone() {
848
+ return this.internalTone;
849
+ }
850
+ /**
851
+ * @param newTone 0 <= newTone <= 100; invalid valids are corrected.
852
+ * Chroma may decrease because chroma has a different maximum for any given
853
+ * hue and tone.
854
+ */
855
+ set tone(newTone) {
856
+ this.setInternalState(
857
+ HctSolver.solveToInt(this.internalHue, this.internalChroma, newTone)
858
+ );
859
+ }
860
+ static from(hue, chroma, tone) {
861
+ return new Hct(HctSolver.solveToInt(hue, chroma, tone));
862
+ }
863
+ /**
864
+ * @param argb ARGB representation of a color.
865
+ * @return HCT representation of a color in default viewing conditions
866
+ */
867
+ static fromInt(argb) {
868
+ return new Hct(argb);
869
+ }
870
+ static isBlue(hue) {
871
+ return hue >= 250 && hue < 270;
872
+ }
873
+ static isYellow(hue) {
874
+ return hue >= 105 && hue < 125;
875
+ }
876
+ static isCyan(hue) {
877
+ return hue >= 170 && hue < 207;
878
+ }
879
+ toInt() {
880
+ return this.argb;
881
+ }
882
+ /** Sets a property of the Hct object. */
883
+ setValue(propertyName, value) {
884
+ this[propertyName] = value;
885
+ }
886
+ toString() {
887
+ return `HCT(${this.hue.toFixed(0)}, ${this.chroma.toFixed(0)}, ${this.tone.toFixed(
888
+ 0
889
+ )})`;
890
+ }
891
+ /**
892
+ * Translates a color into different [ViewingConditions].
893
+ *
894
+ * Colors change appearance. They look different with lights on versus off,
895
+ * the same color, as in hex code, on white looks different when on black.
896
+ * This is called color relativity, most famously explicated by Josef Albers
897
+ * in Interaction of Color.
898
+ *
899
+ * In color science, color appearance models can account for this and
900
+ * calculate the appearance of a color in different settings. HCT is based on
901
+ * CAM16, a color appearance model, and uses it to make these calculations.
902
+ *
903
+ * See [ViewingConditions.make] for parameters affecting color appearance.
904
+ */
905
+ inViewingConditions(vc) {
906
+ const cam = materialColorUtilities.Cam16.fromInt(this.toInt());
907
+ const viewedInVc = cam.xyzInViewingConditions(vc);
908
+ const recastInVc = materialColorUtilities.Cam16.fromXyzInViewingConditions(
909
+ viewedInVc[0],
910
+ viewedInVc[1],
911
+ viewedInVc[2],
912
+ materialColorUtilities.ViewingConditions.make()
913
+ );
914
+ const recastHct = Hct.from(
915
+ recastInVc.hue,
916
+ recastInVc.chroma,
917
+ materialColorUtilities.lstarFromY(viewedInVc[1])
918
+ );
919
+ return recastHct;
920
+ }
921
+ setInternalState(argb) {
922
+ const cam = materialColorUtilities.Cam16.fromInt(argb);
923
+ this.internalHue = cam.hue;
924
+ this.internalChroma = cam.chroma;
925
+ this.internalTone = materialColorUtilities.lstarFromArgb(argb);
926
+ this.argb = argb;
927
+ }
928
+ }
929
+ /**
930
+ * @license
931
+ * Copyright 2022 Google LLC
932
+ *
933
+ * Licensed under the Apache License, Version 2.0 (the "License");
934
+ * you may not use this file except in compliance with the License.
935
+ * You may obtain a copy of the License at
936
+ *
937
+ * http://www.apache.org/licenses/LICENSE-2.0
938
+ *
939
+ * Unless required by applicable law or agreed to in writing, software
940
+ * distributed under the License is distributed on an "AS IS" BASIS,
941
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
942
+ * See the License for the specific language governing permissions and
943
+ * limitations under the License.
944
+ */
945
+ function extendSpecVersion(originlColor, extendedColor) {
946
+ return DynamicColor.fromPalette({
947
+ name: originlColor.name,
948
+ palette: (s) => extendedColor.palette(s),
949
+ tone: (s) => extendedColor.tone(s),
950
+ isBackground: originlColor.isBackground,
951
+ chromaMultiplier: (s) => {
952
+ const chromaMultiplier = extendedColor.chromaMultiplier;
953
+ return chromaMultiplier !== void 0 ? chromaMultiplier(s) : 1;
954
+ },
955
+ background: (s) => {
956
+ const background = extendedColor.background;
957
+ return background !== void 0 ? background(s) : void 0;
958
+ },
959
+ secondBackground: (s) => {
960
+ const secondBackground = extendedColor.secondBackground;
961
+ return secondBackground !== void 0 ? secondBackground(s) : void 0;
962
+ },
963
+ contrastCurve: (s) => {
964
+ const contrastCurve = extendedColor.contrastCurve;
965
+ return contrastCurve !== void 0 ? contrastCurve(s) : void 0;
966
+ },
967
+ toneDeltaPair: (s) => {
968
+ const toneDeltaPair = extendedColor.toneDeltaPair;
969
+ return toneDeltaPair !== void 0 ? toneDeltaPair(s) : void 0;
970
+ }
971
+ });
972
+ }
973
+ class DynamicColor {
974
+ /**
975
+ * The base constructor for DynamicColor.
976
+ *
977
+ * _Strongly_ prefer using one of the convenience constructors. This class is
978
+ * arguably too flexible to ensure it can support any scenario. Functional
979
+ * arguments allow overriding without risks that come with subclasses.
980
+ *
981
+ * For example, the default behavior of adjust tone at max contrast
982
+ * to be at a 7.0 ratio with its background is principled and
983
+ * matches accessibility guidance. That does not mean it's the desired
984
+ * approach for _every_ design system, and every color pairing,
985
+ * always, in every case.
986
+ *
987
+ * @param name The name of the dynamic color. Defaults to empty.
988
+ * @param palette Function that provides a TonalPalette given DynamicScheme. A
989
+ * TonalPalette is defined by a hue and chroma, so this replaces the need
990
+ * to specify hue/chroma. By providing a tonal palette, when contrast
991
+ * adjustments are made, intended chroma can be preserved.
992
+ * @param tone Function that provides a tone, given a DynamicScheme.
993
+ * @param isBackground Whether this dynamic color is a background, with some
994
+ * other color as the foreground. Defaults to false.
995
+ * @param chromaMultiplier A factor that multiplies the chroma for this color.
996
+ * @param background The background of the dynamic color (as a function of a
997
+ * `DynamicScheme`), if it exists.
998
+ * @param secondBackground A second background of the dynamic color (as a
999
+ * function of a `DynamicScheme`), if it exists.
1000
+ * @param contrastCurve A `ContrastCurve` object specifying how its contrast
1001
+ * against its background should behave in various contrast levels
1002
+ * options.
1003
+ * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
1004
+ * constraint between two colors. One of them must be the color being
1005
+ * constructed.
1006
+ */
1007
+ constructor(name, palette, tone, isBackground, chromaMultiplier, background, secondBackground, contrastCurve, toneDeltaPair) {
1008
+ __publicField(this, "hctCache", /* @__PURE__ */ new Map());
1009
+ this.name = name;
1010
+ this.palette = palette;
1011
+ this.tone = tone;
1012
+ this.isBackground = isBackground;
1013
+ this.chromaMultiplier = chromaMultiplier;
1014
+ this.background = background;
1015
+ this.secondBackground = secondBackground;
1016
+ this.contrastCurve = contrastCurve;
1017
+ this.toneDeltaPair = toneDeltaPair;
1018
+ if (!background && secondBackground) {
1019
+ throw new Error(
1020
+ `Color ${name} has secondBackgrounddefined, but background is not defined.`
1021
+ );
1022
+ }
1023
+ if (!background && contrastCurve) {
1024
+ throw new Error(
1025
+ `Color ${name} has contrastCurvedefined, but background is not defined.`
1026
+ );
1027
+ }
1028
+ if (background && !contrastCurve) {
1029
+ throw new Error(
1030
+ `Color ${name} has backgrounddefined, but contrastCurve is not defined.`
1031
+ );
1032
+ }
1033
+ }
1034
+ /**
1035
+ * Create a DynamicColor defined by a TonalPalette and HCT tone.
1036
+ *
1037
+ * @param args Functions with DynamicScheme as input. Must provide a palette
1038
+ * and tone. May provide a background DynamicColor and ToneDeltaPair.
1039
+ */
1040
+ static fromPalette(args) {
1041
+ return new DynamicColor(
1042
+ args.name ?? "",
1043
+ args.palette,
1044
+ args.tone ?? DynamicColor.getInitialToneFromBackground(args.background),
1045
+ args.isBackground ?? false,
1046
+ args.chromaMultiplier,
1047
+ args.background,
1048
+ args.secondBackground,
1049
+ args.contrastCurve,
1050
+ args.toneDeltaPair
1051
+ );
1052
+ }
1053
+ static getInitialToneFromBackground(background) {
1054
+ if (background === void 0) {
1055
+ return (s) => 50;
1056
+ }
1057
+ return (s) => background(s) ? background(s).getTone(s) : 50;
1058
+ }
1059
+ /**
1060
+ * Given a background tone, finds a foreground tone, while ensuring they reach
1061
+ * a contrast ratio that is as close to [ratio] as possible.
1062
+ *
1063
+ * @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it
1064
+ * falls outside that range.
1065
+ * @param ratio The contrast ratio desired between bgTone and the return
1066
+ * value.
1067
+ */
1068
+ static foregroundTone(bgTone, ratio) {
1069
+ const lighterTone = materialColorUtilities.Contrast.lighterUnsafe(bgTone, ratio);
1070
+ const darkerTone = materialColorUtilities.Contrast.darkerUnsafe(bgTone, ratio);
1071
+ const lighterRatio = materialColorUtilities.Contrast.ratioOfTones(lighterTone, bgTone);
1072
+ const darkerRatio = materialColorUtilities.Contrast.ratioOfTones(darkerTone, bgTone);
1073
+ const preferLighter = DynamicColor.tonePrefersLightForeground(bgTone);
1074
+ if (preferLighter) {
1075
+ const negligibleDifference = Math.abs(lighterRatio - darkerRatio) < 0.1 && lighterRatio < ratio && darkerRatio < ratio;
1076
+ return lighterRatio >= ratio || lighterRatio >= darkerRatio || negligibleDifference ? lighterTone : darkerTone;
1077
+ } else {
1078
+ return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone : lighterTone;
1079
+ }
1080
+ }
1081
+ /**
1082
+ * Returns whether [tone] prefers a light foreground.
1083
+ *
1084
+ * People prefer white foregrounds on ~T60-70. Observed over time, and also
1085
+ * by Andrew Somers during research for APCA.
1086
+ *
1087
+ * T60 used as to create the smallest discontinuity possible when skipping
1088
+ * down to T49 in order to ensure light foregrounds.
1089
+ * Since `tertiaryContainer` in dark monochrome scheme requires a tone of
1090
+ * 60, it should not be adjusted. Therefore, 60 is excluded here.
1091
+ */
1092
+ static tonePrefersLightForeground(tone) {
1093
+ return Math.round(tone) < 60;
1094
+ }
1095
+ /**
1096
+ * Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter
1097
+ * color.
1098
+ */
1099
+ static toneAllowsLightForeground(tone) {
1100
+ return Math.round(tone) <= 49;
1101
+ }
1102
+ /**
1103
+ * Adjusts a tone such that white has 4.5 contrast, if the tone is
1104
+ * reasonably close to supporting it.
1105
+ */
1106
+ static enableLightForeground(tone) {
1107
+ if (DynamicColor.tonePrefersLightForeground(tone) && !DynamicColor.toneAllowsLightForeground(tone)) {
1108
+ return 49;
1109
+ }
1110
+ return tone;
1111
+ }
1112
+ /**
1113
+ * Returns a deep copy of this DynamicColor.
1114
+ */
1115
+ clone() {
1116
+ return DynamicColor.fromPalette({
1117
+ name: this.name,
1118
+ palette: this.palette,
1119
+ tone: this.tone,
1120
+ isBackground: this.isBackground,
1121
+ chromaMultiplier: this.chromaMultiplier,
1122
+ background: this.background,
1123
+ secondBackground: this.secondBackground,
1124
+ contrastCurve: this.contrastCurve,
1125
+ toneDeltaPair: this.toneDeltaPair
1126
+ });
1127
+ }
1128
+ /**
1129
+ * Clears the cache of HCT values for this color. For testing or debugging
1130
+ * purposes.
1131
+ */
1132
+ clearCache() {
1133
+ this.hctCache.clear();
1134
+ }
1135
+ /**
1136
+ * Returns a ARGB integer (i.e. a hex code).
1137
+ *
1138
+ * @param scheme Defines the conditions of the user interface, for example,
1139
+ * whether or not it is dark mode or light mode, and what the desired
1140
+ * contrast level is.
1141
+ */
1142
+ getArgb(scheme) {
1143
+ return this.getHct(scheme).toInt();
1144
+ }
1145
+ /**
1146
+ * Returns a color, expressed in the HCT color space, that this
1147
+ * DynamicColor is under the conditions in scheme.
1148
+ *
1149
+ * @param scheme Defines the conditions of the user interface, for example,
1150
+ * whether or not it is dark mode or light mode, and what the desired
1151
+ * contrast level is.
1152
+ */
1153
+ getHct(scheme) {
1154
+ const palette = this.palette(scheme);
1155
+ const tone = this.getTone(scheme);
1156
+ const hue = palette.hue;
1157
+ const chroma = palette.chroma * (this.chromaMultiplier ? this.chromaMultiplier(scheme) : 1);
1158
+ return Hct.from(hue, chroma, tone);
1159
+ }
1160
+ /**
1161
+ * Returns a tone, T in the HCT color space, that this DynamicColor is under
1162
+ * the conditions in scheme.
1163
+ *
1164
+ * @param scheme Defines the conditions of the user interface, for example,
1165
+ * whether or not it is dark mode or light mode, and what the desired
1166
+ * contrast level is.
1167
+ */
1168
+ getTone(scheme) {
1169
+ const toneDeltaPair = this.toneDeltaPair ? this.toneDeltaPair(scheme) : void 0;
1170
+ if (toneDeltaPair) {
1171
+ const roleA = toneDeltaPair.roleA;
1172
+ const roleB = toneDeltaPair.roleB;
1173
+ const polarity = toneDeltaPair.polarity;
1174
+ const constraint = toneDeltaPair.constraint;
1175
+ const absoluteDelta = polarity === "darker" || polarity === "relative_lighter" && scheme.isDark || polarity === "relative_darker" && !scheme.isDark ? -toneDeltaPair.delta : toneDeltaPair.delta;
1176
+ const amRoleA = this.name === roleA.name;
1177
+ const selfRole = amRoleA ? roleA : roleB;
1178
+ const refRole = amRoleA ? roleB : roleA;
1179
+ let selfTone = selfRole.tone(scheme);
1180
+ const refTone = refRole.getTone(scheme);
1181
+ const relativeDelta = absoluteDelta * (amRoleA ? 1 : -1);
1182
+ if (constraint === "exact") {
1183
+ selfTone = materialColorUtilities.clampDouble(0, 100, refTone + relativeDelta);
1184
+ } else if (constraint === "nearer") {
1185
+ if (relativeDelta > 0) {
1186
+ selfTone = materialColorUtilities.clampDouble(
1187
+ 0,
1188
+ 100,
1189
+ materialColorUtilities.clampDouble(refTone, refTone + relativeDelta, selfTone)
1190
+ );
1191
+ } else {
1192
+ selfTone = materialColorUtilities.clampDouble(
1193
+ 0,
1194
+ 100,
1195
+ materialColorUtilities.clampDouble(refTone + relativeDelta, refTone, selfTone)
1196
+ );
1197
+ }
1198
+ } else if (constraint === "farther") {
1199
+ if (relativeDelta > 0) {
1200
+ selfTone = materialColorUtilities.clampDouble(refTone + relativeDelta, 100, selfTone);
1201
+ } else {
1202
+ selfTone = materialColorUtilities.clampDouble(0, refTone + relativeDelta, selfTone);
1203
+ }
1204
+ }
1205
+ if (this.background && this.contrastCurve) {
1206
+ const background = this.background(scheme);
1207
+ const contrastCurve = this.contrastCurve(scheme);
1208
+ if (background && contrastCurve) {
1209
+ const bgTone = background.getTone(scheme);
1210
+ const selfContrast = contrastCurve.get(scheme.contrastLevel);
1211
+ selfTone = materialColorUtilities.Contrast.ratioOfTones(bgTone, selfTone) >= selfContrast && scheme.contrastLevel >= 0 ? selfTone : DynamicColor.foregroundTone(bgTone, selfContrast);
1212
+ }
1213
+ }
1214
+ if (this.isBackground && !this.name.endsWith("_fixed_dim")) {
1215
+ if (selfTone >= 57) {
1216
+ selfTone = materialColorUtilities.clampDouble(65, 100, selfTone);
1217
+ } else {
1218
+ selfTone = materialColorUtilities.clampDouble(0, 49, selfTone);
1219
+ }
1220
+ }
1221
+ return selfTone;
1222
+ } else {
1223
+ let answer = this.tone(scheme);
1224
+ if (this.background == void 0 || this.background(scheme) === void 0 || this.contrastCurve == void 0 || this.contrastCurve(scheme) === void 0) {
1225
+ return answer;
1226
+ }
1227
+ const bgTone = this.background(scheme).getTone(scheme);
1228
+ const desiredRatio = this.contrastCurve(scheme).get(
1229
+ scheme.contrastLevel
1230
+ );
1231
+ answer = materialColorUtilities.Contrast.ratioOfTones(bgTone, answer) >= desiredRatio && scheme.contrastLevel >= 0 ? answer : DynamicColor.foregroundTone(bgTone, desiredRatio);
1232
+ if (this.isBackground && !this.name.endsWith("_fixed_dim")) {
1233
+ if (answer >= 57) {
1234
+ answer = materialColorUtilities.clampDouble(65, 100, answer);
1235
+ } else {
1236
+ answer = materialColorUtilities.clampDouble(0, 49, answer);
1237
+ }
1238
+ }
1239
+ if (this.secondBackground == void 0 || this.secondBackground(scheme) === void 0) {
1240
+ return answer;
1241
+ }
1242
+ const [bg1, bg2] = [this.background, this.secondBackground];
1243
+ const [bgTone1, bgTone2] = [
1244
+ bg1(scheme).getTone(scheme),
1245
+ bg2(scheme).getTone(scheme)
1246
+ ];
1247
+ const [upper, lower] = [
1248
+ Math.max(bgTone1, bgTone2),
1249
+ Math.min(bgTone1, bgTone2)
1250
+ ];
1251
+ if (materialColorUtilities.Contrast.ratioOfTones(upper, answer) >= desiredRatio && materialColorUtilities.Contrast.ratioOfTones(lower, answer) >= desiredRatio) {
1252
+ return answer;
1253
+ }
1254
+ const lightOption = materialColorUtilities.Contrast.lighter(upper, desiredRatio);
1255
+ const darkOption = materialColorUtilities.Contrast.darker(lower, desiredRatio);
1256
+ const availables = [];
1257
+ if (lightOption !== -1) availables.push(lightOption);
1258
+ if (darkOption !== -1) availables.push(darkOption);
1259
+ const prefersLight = DynamicColor.tonePrefersLightForeground(bgTone1) || DynamicColor.tonePrefersLightForeground(bgTone2);
1260
+ if (prefersLight) {
1261
+ return lightOption < 0 ? 100 : lightOption;
1262
+ }
1263
+ if (availables.length === 1) {
1264
+ return availables[0];
1265
+ }
1266
+ return darkOption < 0 ? 0 : darkOption;
1267
+ }
1268
+ }
1269
+ }
1270
+ /**
1271
+ * @license
1272
+ * Copyright 2023 Google LLC
1273
+ *
1274
+ * Licensed under the Apache License, Version 2.0 (the "License");
1275
+ * you may not use this file except in compliance with the License.
1276
+ * You may obtain a copy of the License at
1277
+ *
1278
+ * http://www.apache.org/licenses/LICENSE-2.0
1279
+ *
1280
+ * Unless required by applicable law or agreed to in writing, software
1281
+ * distributed under the License is distributed on an "AS IS" BASIS,
1282
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1283
+ * See the License for the specific language governing permissions and
1284
+ * limitations under the License.
1285
+ */
1286
+ class ToneDeltaPair {
1287
+ /**
1288
+ * Documents a constraint in tone distance between two DynamicColors.
1289
+ *
1290
+ * The polarity is an adjective that describes "A", compared to "B".
1291
+ *
1292
+ * For instance, ToneDeltaPair(A, B, 15, 'darker', 'exact') states that
1293
+ * A's tone should be exactly 15 darker than B's.
1294
+ *
1295
+ * 'relative_darker' and 'relative_lighter' describes the tone adjustment
1296
+ * relative to the surface color trend (white in light mode; black in dark
1297
+ * mode). For instance, ToneDeltaPair(A, B, 10, 'relative_lighter',
1298
+ * 'farther') states that A should be at least 10 lighter than B in light
1299
+ * mode, and at least 10 darker than B in dark mode.
1300
+ *
1301
+ * @param roleA The first role in a pair.
1302
+ * @param roleB The second role in a pair.
1303
+ * @param delta Required difference between tones. Absolute value, negative
1304
+ * values have undefined behavior.
1305
+ * @param polarity The relative relation between tones of roleA and roleB,
1306
+ * as described above.
1307
+ * @param constraint How to fulfill the tone delta pair constraint.
1308
+ * @param stayTogether Whether these two roles should stay on the same side
1309
+ * of the "awkward zone" (T50-59). This is necessary for certain cases where
1310
+ * one role has two backgrounds.
1311
+ */
1312
+ constructor(roleA, roleB, delta, polarity, stayTogether, constraint) {
1313
+ this.roleA = roleA;
1314
+ this.roleB = roleB;
1315
+ this.delta = delta;
1316
+ this.polarity = polarity;
1317
+ this.stayTogether = stayTogether;
1318
+ this.constraint = constraint;
1319
+ this.constraint = constraint ?? "exact";
1320
+ }
1321
+ }
1322
+ function argbToRgb(argb) {
1323
+ return {
1324
+ r: argb >> 16 & 255,
1325
+ g: argb >> 8 & 255,
1326
+ b: argb & 255
1327
+ };
1328
+ }
1329
+ class ConfigurableColor {
1330
+ constructor(option, schemeService, colorService) {
1331
+ __publicField(this, "dynamicColor", null);
1332
+ this.option = option;
1333
+ this.schemeService = schemeService;
1334
+ this.colorService = colorService;
1335
+ }
1336
+ update(args) {
1337
+ this.dynamicColor = null;
1338
+ this.option = { ...this.option, ...args };
1339
+ }
1340
+ getHex() {
1341
+ return materialColorUtilities.hexFromArgb(this.getArgb());
1342
+ }
1343
+ getArgb() {
1344
+ return this.getMaterialColor().getArgb(this.schemeService.get());
1345
+ }
1346
+ getRgb() {
1347
+ return argbToRgb(this.getArgb());
1348
+ }
1349
+ getName() {
1350
+ return this.option.name.replace(/([A-Z])/g, "_$1").toLowerCase();
1351
+ }
1352
+ getMaterialColor() {
1353
+ if ("alias" in this.option) {
1354
+ if (!this.option.alias) {
1355
+ throw new Error("Alias option must be defined");
1356
+ }
1357
+ return this.colorService.get(this.option.alias).getMaterialColor();
1358
+ }
1359
+ if (!this.dynamicColor) {
1360
+ this.dynamicColor = DynamicColor.fromPalette({
1361
+ ...this.option,
1362
+ name: this.getName()
1363
+ });
1364
+ }
1365
+ return this.dynamicColor;
1366
+ }
1367
+ }
1368
+ function getCurve(defaultContrast) {
1369
+ if (defaultContrast === 1.5) {
1370
+ return new ContrastCurve(1.5, 1.5, 3, 4.5);
1371
+ } else if (defaultContrast === 3) {
1372
+ return new ContrastCurve(3, 3, 4.5, 7);
1373
+ } else if (defaultContrast === 4.5) {
1374
+ return new ContrastCurve(4.5, 4.5, 7, 11);
1375
+ } else if (defaultContrast === 6) {
1376
+ return new ContrastCurve(6, 6, 7, 11);
1377
+ } else if (defaultContrast === 7) {
1378
+ return new ContrastCurve(7, 7, 11, 21);
1379
+ } else if (defaultContrast === 9) {
1380
+ return new ContrastCurve(9, 9, 11, 21);
1381
+ } else if (defaultContrast === 11) {
1382
+ return new ContrastCurve(11, 11, 21, 21);
1383
+ } else if (defaultContrast === 21) {
1384
+ return new ContrastCurve(21, 21, 21, 21);
1385
+ } else {
1386
+ return new ContrastCurve(defaultContrast, defaultContrast, 7, 21);
1387
+ }
1388
+ }
1389
+ function tMaxC(palette, lowerBound = 0, upperBound = 100, chromaMultiplier = 1) {
1390
+ const answer = findBestToneForChroma(
1391
+ palette.hue,
1392
+ palette.chroma * chromaMultiplier,
1393
+ 100,
1394
+ true
1395
+ );
1396
+ return materialColorUtilities.clampDouble(lowerBound, upperBound, answer);
1397
+ }
1398
+ function tMinC(palette, lowerBound = 0, upperBound = 100) {
1399
+ const answer = findBestToneForChroma(palette.hue, palette.chroma, 0, false);
1400
+ return materialColorUtilities.clampDouble(lowerBound, upperBound, answer);
1401
+ }
1402
+ function findBestToneForChroma(hue, chroma, tone, byDecreasingTone) {
1403
+ let answer = tone;
1404
+ let bestCandidate = Hct.from(hue, chroma, answer);
1405
+ while (bestCandidate.chroma < chroma) {
1406
+ if (tone < 0 || tone > 100) {
1407
+ break;
1408
+ }
1409
+ tone += byDecreasingTone ? -1 : 1;
1410
+ const newCandidate = Hct.from(hue, chroma, tone);
1411
+ if (bestCandidate.chroma < newCandidate.chroma) {
1412
+ bestCandidate = newCandidate;
1413
+ answer = tone;
1414
+ }
1415
+ }
1416
+ return answer;
1417
+ }
1418
+ function capitalizeFirstLetter(string) {
1419
+ return string.charAt(0).toUpperCase() + string.slice(1);
1420
+ }
1421
+ const highestSurface = (s, colorService) => {
1422
+ if (colorService instanceof ColorApi) {
1423
+ return s.isDark ? colorService.getColor("surfaceBright").getMaterialColor() : colorService.getColor("surfaceDim").getMaterialColor();
1424
+ } else {
1425
+ return s.isDark ? colorService.get("surfaceBright").getMaterialColor() : colorService.get("surfaceDim").getMaterialColor();
1426
+ }
1427
+ };
1428
+ class ColorManager {
1429
+ constructor({ schemeManager }) {
1430
+ __publicField(this, "colorMap", /* @__PURE__ */ new Map());
1431
+ __publicField(this, "schemeManager");
1432
+ this.schemeManager = schemeManager;
1433
+ }
1434
+ createOrUpdate(key, args) {
1435
+ let colorEntity = this.colorMap.get(key);
1436
+ if (!colorEntity) {
1437
+ const { palette, alias } = args;
1438
+ if (palette) {
1439
+ colorEntity = new ConfigurableColor(
1440
+ { ...args, palette, name: key },
1441
+ this.schemeManager,
1442
+ this
1443
+ );
1444
+ this.colorMap.set(key, colorEntity);
1445
+ } else if (alias) {
1446
+ colorEntity = new ConfigurableColor(
1447
+ { ...args, alias, name: key },
1448
+ this.schemeManager,
1449
+ this
1450
+ );
1451
+ this.colorMap.set(key, colorEntity);
1452
+ } else {
1453
+ throw new Error(`Palette ${palette} does not exist from ${key}`);
1454
+ }
1455
+ } else {
1456
+ colorEntity.update({ ...args, name: key });
1457
+ this.colorMap.set(key, colorEntity);
1458
+ }
1459
+ return colorEntity;
1460
+ }
1461
+ remove(key) {
1462
+ return this.colorMap.delete(key);
1463
+ }
1464
+ get(key) {
1465
+ const colorEntity = this.colorMap.get(key);
1466
+ if (colorEntity) {
1467
+ return colorEntity;
1468
+ } else {
1469
+ throw new Error(`Color ${key} does not exist`);
1470
+ }
1471
+ }
1472
+ getAll() {
1473
+ return this.colorMap;
1474
+ }
1475
+ addFromPalette(key) {
1476
+ const colorKey = key;
1477
+ const colorDimKey = colorKey + "Dim";
1478
+ const ColorKey = capitalizeFirstLetter(key);
1479
+ const onColorKey = "on" + ColorKey;
1480
+ const colorContainerKey = colorKey + "Container";
1481
+ const onColorContainerKey = "on" + ColorKey + "Container";
1482
+ const colorFixedKey = colorKey + "Fixed";
1483
+ const colorFixedDimKey = colorKey + "FixedDim";
1484
+ const onColorFixedKey = "on" + ColorKey + "Fixed";
1485
+ const onColorFixedVariantKey = "on" + ColorKey + "FixedVariant";
1486
+ this.createOrUpdate(colorKey, {
1487
+ palette: (s) => s.getPalette(colorKey),
1488
+ tone: (s) => {
1489
+ if (s.variant === "neutral") {
1490
+ return s.isDark ? tMinC(s.getPalette(colorKey), 0, 98) : tMaxC(s.getPalette(colorKey));
1491
+ } else if (s.variant === "vibrant") {
1492
+ return tMaxC(s.getPalette(colorKey), 0, s.isDark ? 90 : 98);
1493
+ } else {
1494
+ return s.isDark ? 80 : tMaxC(s.getPalette(colorKey));
1495
+ }
1496
+ },
1497
+ isBackground: true,
1498
+ background: (s) => highestSurface(s, this),
1499
+ contrastCurve: (s) => getCurve(4.5),
1500
+ toneDeltaPair: (s) => new ToneDeltaPair(
1501
+ this.get(colorContainerKey).getMaterialColor(),
1502
+ this.get(colorKey).getMaterialColor(),
1503
+ 5,
1504
+ "relative_lighter",
1505
+ true,
1506
+ "farther"
1507
+ )
1508
+ });
1509
+ this.createOrUpdate(colorDimKey, {
1510
+ palette: (s) => s.getPalette(colorKey),
1511
+ tone: (s) => {
1512
+ if (s.variant === "neutral") {
1513
+ return 85;
1514
+ } else {
1515
+ return tMaxC(s.getPalette(colorKey), 0, 90);
1516
+ }
1517
+ },
1518
+ isBackground: true,
1519
+ background: (s) => this.get("surfaceContainerHigh").getMaterialColor(),
1520
+ contrastCurve: (s) => getCurve(4.5),
1521
+ toneDeltaPair: (s) => new ToneDeltaPair(
1522
+ this.get(colorDimKey).getMaterialColor(),
1523
+ this.get(colorKey).getMaterialColor(),
1524
+ 5,
1525
+ "darker",
1526
+ true,
1527
+ "farther"
1528
+ )
1529
+ });
1530
+ this.createOrUpdate(onColorKey, {
1531
+ palette: (s) => s.getPalette(colorKey),
1532
+ background: (s) => this.get(colorKey).getMaterialColor(),
1533
+ contrastCurve: (s) => getCurve(6)
1534
+ });
1535
+ this.createOrUpdate(colorContainerKey, {
1536
+ palette: (s) => s.getPalette(colorKey),
1537
+ tone: (s) => {
1538
+ if (s.variant === "vibrant") {
1539
+ return s.isDark ? tMinC(s.getPalette(colorKey), 30, 40) : tMaxC(s.getPalette(colorKey), 84, 90);
1540
+ } else if (s.variant === "expressive") {
1541
+ return s.isDark ? 15 : tMaxC(s.getPalette(colorKey), 90, 95);
1542
+ } else {
1543
+ return s.isDark ? 25 : 90;
1544
+ }
1545
+ },
1546
+ isBackground: true,
1547
+ background: (s) => highestSurface(s, this),
1548
+ toneDeltaPair: (s) => void 0,
1549
+ contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
1550
+ });
1551
+ this.createOrUpdate(onColorContainerKey, {
1552
+ palette: (s) => s.getPalette(colorKey),
1553
+ background: (s) => this.get(colorContainerKey).getMaterialColor(),
1554
+ contrastCurve: (s) => getCurve(6)
1555
+ });
1556
+ this.createOrUpdate(colorFixedKey, {
1557
+ palette: (s) => s.getPalette(colorKey),
1558
+ tone: (s) => {
1559
+ const tempS = Object.assign({}, s, { isDark: false, contrastLevel: 0 });
1560
+ return this.get(colorContainerKey).getMaterialColor().getTone(tempS);
1561
+ },
1562
+ isBackground: true,
1563
+ background: (s) => highestSurface(s, this),
1564
+ contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
1565
+ });
1566
+ this.createOrUpdate(colorFixedDimKey, {
1567
+ palette: (s) => s.getPalette(colorKey),
1568
+ tone: (s) => this.get(colorFixedKey).getMaterialColor().getTone(s),
1569
+ isBackground: true,
1570
+ toneDeltaPair: (s) => new ToneDeltaPair(
1571
+ this.get(colorFixedDimKey).getMaterialColor(),
1572
+ this.get(colorFixedKey).getMaterialColor(),
1573
+ 5,
1574
+ "darker",
1575
+ true,
1576
+ "exact"
1577
+ )
1578
+ });
1579
+ this.createOrUpdate(onColorFixedKey, {
1580
+ palette: (s) => s.getPalette(colorKey),
1581
+ background: (s) => this.get(colorFixedDimKey).getMaterialColor(),
1582
+ contrastCurve: (s) => getCurve(7)
1583
+ });
1584
+ this.createOrUpdate(onColorFixedVariantKey, {
1585
+ palette: (s) => s.getPalette(colorKey),
1586
+ background: (s) => this.get(colorFixedDimKey).getMaterialColor(),
1587
+ contrastCurve: (s) => getCurve(4.5)
1588
+ });
1589
+ }
1590
+ }
1591
+ const ColorModule = {
1592
+ colorManager: awilix.asClass(ColorManager).singleton(),
1593
+ colorApi: awilix.asClass(ColorApi).singleton()
1594
+ };
1595
+ class Scheme {
1596
+ constructor(options) {
1597
+ this.options = options;
1598
+ }
1599
+ get variant() {
1600
+ return this.options.variant.name;
1601
+ }
1602
+ get contrastLevel() {
1603
+ if (!this.options) {
1604
+ throw new Error("Scheme options is not set");
1605
+ }
1606
+ return this.options.contrastLevel;
1607
+ }
1608
+ get isDark() {
1609
+ if (!this.options) {
1610
+ throw new Error("Scheme options is not set");
1611
+ }
1612
+ return this.options.isDark;
1613
+ }
1614
+ get sourceColorHct() {
1615
+ if (!this.options) {
1616
+ throw new Error("Scheme options is not set");
1617
+ }
1618
+ return Hct.fromInt(this.options.sourceColorArgb);
1619
+ }
1620
+ getPalette(key) {
1621
+ if (!this.options) {
1622
+ throw new Error("Scheme options is not set");
1623
+ }
1624
+ const palette = this.options.palettes.get(key);
1625
+ if (!palette) {
1626
+ throw new Error(`Palette ${key} not found`);
1627
+ }
1628
+ return palette;
1629
+ }
1630
+ }
1631
+ class SchemeManager {
1632
+ constructor() {
1633
+ __publicField(this, "schemeEntity");
1634
+ __publicField(this, "options");
1635
+ }
1636
+ createOrUpdate(options) {
1637
+ var _a, _b;
1638
+ this.options = {
1639
+ ...this.options,
1640
+ ...options,
1641
+ sourcesColorHex: {
1642
+ ...(_a = this.options) == null ? void 0 : _a.sourcesColorHex,
1643
+ ...options.sourcesColorHex
1644
+ },
1645
+ palettes: {
1646
+ ...(_b = this.options) == null ? void 0 : _b.palettes,
1647
+ ...options.palettes
1648
+ }
1649
+ };
1650
+ const palettes = /* @__PURE__ */ new Map();
1651
+ if (!this.options.sourcesColorHex.primary) {
1652
+ throw new Error("Primary source color is not set");
1653
+ }
1654
+ const sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourcesColorHex.primary);
1655
+ const sourceColorHct = Hct.fromInt(sourceColorArgb);
1656
+ if (!this.options.palettes) {
1657
+ return;
1658
+ }
1659
+ for (const [
1660
+ key,
1661
+ { sourceColorkey, tonalPalette: paletteFunction }
1662
+ ] of Object.entries(this.options.palettes)) {
1663
+ let palette;
1664
+ if (typeof sourceColorkey != "string") {
1665
+ palette = paletteFunction({
1666
+ sourceColorHct,
1667
+ isDark: options.isDark ?? false
1668
+ });
1669
+ } else {
1670
+ const sourceColorArgb2 = materialColorUtilities.argbFromHex(
1671
+ this.options.sourcesColorHex[sourceColorkey]
1672
+ );
1673
+ const colorHct = Hct.fromInt(sourceColorArgb2);
1674
+ palette = paletteFunction({
1675
+ sourceColorHct,
1676
+ colorHct,
1677
+ isDark: options.isDark ?? false
1678
+ });
1679
+ }
1680
+ palettes.set(key, palette);
1681
+ }
1682
+ this.schemeEntity = new Scheme({
1683
+ ...this.options,
1684
+ palettes,
1685
+ sourceColorArgb
1686
+ });
1687
+ }
1688
+ get() {
1689
+ if (!this.schemeEntity) {
1690
+ throw new Error("Scheme is not created");
1691
+ }
1692
+ return this.schemeEntity;
1693
+ }
1694
+ }
1695
+ class VariantManager {
1696
+ constructor({ schemeManager }) {
1697
+ __publicField(this, "customPalettes", {});
1698
+ __publicField(this, "variantEntity");
1699
+ __publicField(this, "schemeManager");
1700
+ this.schemeManager = schemeManager;
1701
+ }
1702
+ addCustomPalette(key, colorHex) {
1703
+ this.customPalettes[key] = colorHex;
1704
+ this.update();
1705
+ }
1706
+ set(variantEntity) {
1707
+ this.variantEntity = variantEntity;
1708
+ this.update();
1709
+ }
1710
+ update() {
1711
+ if (!this.variantEntity) return;
1712
+ const palettes = {};
1713
+ Object.keys(this.variantEntity.palettes).forEach((key) => {
1714
+ palettes[key] = { tonalPalette: this.variantEntity.palettes[key] };
1715
+ });
1716
+ const customPalettes = this.variantEntity.customPalettes;
1717
+ if (customPalettes) {
1718
+ Object.keys(this.customPalettes).forEach((key) => {
1719
+ palettes[key] = {
1720
+ sourceColorkey: key,
1721
+ tonalPalette: customPalettes
1722
+ };
1723
+ });
1724
+ }
1725
+ this.schemeManager.createOrUpdate({
1726
+ sourcesColorHex: this.customPalettes,
1727
+ palettes
1728
+ });
1729
+ }
1730
+ }
1731
+ materialColorUtilities.DynamicColor.fromPalette({
1732
+ name: "primary_palette_key_color",
1733
+ palette: (s) => s.primaryPalette,
1734
+ tone: (s) => s.primaryPalette.keyColor.tone
1735
+ });
1736
+ class ThemeApi {
1737
+ constructor({
1738
+ schemeManager,
1739
+ variantManager
1740
+ }) {
1741
+ __publicField(this, "schemeManager");
1742
+ __publicField(this, "variantManager");
1743
+ this.schemeManager = schemeManager;
1744
+ this.variantManager = variantManager;
1745
+ }
1746
+ // addPalette({key, palette, addDefaultColors}: {key: string; palette: TonalPalette; addDefaultColors: boolean}) {
1747
+ // this.themeOptions.palettes.set(key, palette);
1748
+ // if (addDefaultColors){
1749
+ // this.colorService.addPalette(key)
1750
+ // }
1751
+ // }
1752
+ // create(args: ThemeOptions): SchemeService {
1753
+ // return new SchemeService(args, this.colorService)
1754
+ // }
1755
+ //
1756
+ // update(options: Partial<ThemeOptions>): SchemeService {
1757
+ // Object.assign(this.themeOptions, options);
1758
+ // return this.theme();
1759
+ // }
1760
+ create(options) {
1761
+ this.schemeManager.createOrUpdate({
1762
+ ...options,
1763
+ sourcesColorHex: { primary: options.sourceColorHex }
1764
+ });
1765
+ this.variantManager.set(options.variant);
1766
+ }
1767
+ update(options) {
1768
+ const themeOptions = { ...options };
1769
+ if (options.sourceColorHex)
1770
+ themeOptions.sourcesColorHex = { primary: options.sourceColorHex };
1771
+ this.schemeManager.createOrUpdate(themeOptions);
1772
+ if (options.variant) this.variantManager.set(options.variant);
1773
+ }
1774
+ addCustomPalette(key, colorHex) {
1775
+ this.variantManager.addCustomPalette(key, colorHex);
1776
+ }
1777
+ // theme(): SchemeService {
1778
+ // return new SchemeService(this.themeOptions, this.colorService)
1779
+ // }
1780
+ }
1781
+ const ThemeModule = {
1782
+ schemeManager: awilix.asClass(SchemeManager).singleton(),
1783
+ variantManager: awilix.asClass(VariantManager).singleton(),
1784
+ themeApi: awilix.asClass(ThemeApi).singleton()
1785
+ };
1786
+ const getPiecewiseHue = (sourceColorHct, hueBreakpoints, hues) => {
1787
+ const size = Math.min(hueBreakpoints.length - 1, hues.length);
1788
+ const sourceHue = sourceColorHct.hue;
1789
+ for (let i = 0; i < size; i++) {
1790
+ if (sourceHue >= hueBreakpoints[i] && sourceHue < hueBreakpoints[i + 1]) {
1791
+ return materialColorUtilities.sanitizeDegreesDouble(hues[i]);
1792
+ }
1793
+ }
1794
+ return sourceHue;
1795
+ };
1796
+ const getRotatedHue = (sourceColorHct, hueBreakpoints, rotations) => {
1797
+ let rotation = getPiecewiseHue(sourceColorHct, hueBreakpoints, rotations);
1798
+ if (Math.min(hueBreakpoints.length - 1, rotations.length) <= 0) {
1799
+ rotation = 0;
1800
+ }
1801
+ return materialColorUtilities.sanitizeDegreesDouble(sourceColorHct.hue + rotation);
1802
+ };
1803
+ class Variant {
1804
+ constructor(palettes = {}, name, customPalettes, colors) {
1805
+ this.palettes = palettes;
1806
+ this.name = name;
1807
+ this.customPalettes = customPalettes;
1808
+ this.colors = colors;
1809
+ }
1810
+ }
1811
+ const getExpressiveNeutralHue = (sourceColorHct) => {
1812
+ const hue = getRotatedHue(
1813
+ sourceColorHct,
1814
+ [0, 71, 124, 253, 278, 300, 360],
1815
+ [10, 0, 10, 0, 10, 0]
1816
+ );
1817
+ return hue;
1818
+ };
1819
+ const getExpressiveNeutralChroma = (sourceColorHct, isDark) => {
1820
+ const neutralHue = getExpressiveNeutralHue(sourceColorHct);
1821
+ return isDark ? Hct.isYellow(neutralHue) ? 6 : 14 : 18;
1822
+ };
1823
+ const expressiveVariant = {
1824
+ name: "expressive",
1825
+ palettes: {
1826
+ primary: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 36 : 48),
1827
+ secondary: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1828
+ getRotatedHue(
1829
+ sourceColorHct,
1830
+ [0, 105, 140, 204, 253, 278, 300, 333, 360],
1831
+ [-160, 155, -100, 96, -96, -156, -165, -160]
1832
+ ),
1833
+ isDark ? 16 : 24
1834
+ ),
1835
+ tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1836
+ getRotatedHue(
1837
+ sourceColorHct,
1838
+ [0, 105, 140, 204, 253, 278, 300, 333, 360],
1839
+ [-165, 160, -105, 101, -101, -160, -170, -165]
1840
+ ),
1841
+ 48
1842
+ ),
1843
+ neutral: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1844
+ getExpressiveNeutralHue(sourceColorHct),
1845
+ getExpressiveNeutralChroma(sourceColorHct, isDark)
1846
+ ),
1847
+ neutralVariant: ({ sourceColorHct, isDark }) => {
1848
+ const expressiveNeutralHue = getExpressiveNeutralHue(sourceColorHct);
1849
+ const expressiveNeutralChroma = getExpressiveNeutralChroma(
1850
+ sourceColorHct,
1851
+ isDark
1852
+ );
1853
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(
1854
+ expressiveNeutralHue,
1855
+ expressiveNeutralChroma * (expressiveNeutralHue >= 105 && expressiveNeutralHue < 125 ? 1.6 : 2.3)
1856
+ );
1857
+ },
1858
+ error: ({ sourceColorHct }) => {
1859
+ const errorHue = getPiecewiseHue(
1860
+ sourceColorHct,
1861
+ [0, 3, 13, 23, 33, 43, 153, 273, 360],
1862
+ [12, 22, 32, 12, 22, 32, 22, 12]
1863
+ );
1864
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 64);
1865
+ }
1866
+ },
1867
+ customPalettes: ({ colorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1868
+ getRotatedHue(
1869
+ colorHct,
1870
+ [0, 105, 140, 204, 253, 278, 300, 333, 360],
1871
+ [-160, 155, -100, 96, -96, -156, -165, -160]
1872
+ ),
1873
+ isDark ? 16 : 24
1874
+ )
1875
+ };
1876
+ const neutralVariant = {
1877
+ name: "neutral",
1878
+ palettes: {
1879
+ primary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1880
+ sourceColorHct.hue,
1881
+ Hct.isBlue(sourceColorHct.hue) ? 12 : 8
1882
+ ),
1883
+ secondary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1884
+ sourceColorHct.hue,
1885
+ Hct.isBlue(sourceColorHct.hue) ? 6 : 4
1886
+ ),
1887
+ tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1888
+ getRotatedHue(
1889
+ sourceColorHct,
1890
+ [0, 38, 105, 161, 204, 278, 333, 360],
1891
+ [-32, 26, 10, -39, 24, -15, -32]
1892
+ ),
1893
+ 20
1894
+ ),
1895
+ neutral: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4),
1896
+ neutralVariant: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4 * 2.2),
1897
+ error: ({ sourceColorHct }) => {
1898
+ const errorHue = getPiecewiseHue(
1899
+ sourceColorHct,
1900
+ [0, 3, 13, 23, 33, 43, 153, 273, 360],
1901
+ [12, 22, 32, 12, 22, 32, 22, 12]
1902
+ );
1903
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 50);
1904
+ }
1905
+ },
1906
+ customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1907
+ colorHct.hue,
1908
+ Hct.isBlue(colorHct.hue) ? 6 : 4
1909
+ )
1910
+ };
1911
+ const tonalSpotVariant = {
1912
+ name: "tonalSpot",
1913
+ palettes: {
1914
+ primary: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 26 : 32),
1915
+ secondary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16),
1916
+ tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1917
+ getRotatedHue(
1918
+ sourceColorHct,
1919
+ [0, 20, 71, 161, 333, 360],
1920
+ [-40, 48, -32, 40, -32]
1921
+ ),
1922
+ 28
1923
+ ),
1924
+ neutral: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5),
1925
+ neutralVariant: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5 * 1.7),
1926
+ error: ({ sourceColorHct }) => {
1927
+ const errorHue = getPiecewiseHue(
1928
+ sourceColorHct,
1929
+ [0, 3, 13, 23, 33, 43, 153, 273, 360],
1930
+ [12, 22, 32, 12, 22, 32, 22, 12]
1931
+ );
1932
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 60);
1933
+ }
1934
+ },
1935
+ customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16)
1936
+ };
1937
+ const getVibrantNeutralHue = (sourceColorHct) => {
1938
+ return getRotatedHue(
1939
+ sourceColorHct,
1940
+ [0, 38, 105, 140, 333, 360],
1941
+ [-14, 10, -14, 10, -14]
1942
+ );
1943
+ };
1944
+ const getVibrantNeutralChroma = (sourceColorHct) => {
1945
+ getVibrantNeutralHue(sourceColorHct);
1946
+ return 28;
1947
+ };
1948
+ const vibrantVariant = {
1949
+ name: "vibrant",
1950
+ palettes: {
1951
+ primary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 74),
1952
+ secondary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1953
+ getRotatedHue(
1954
+ sourceColorHct,
1955
+ [0, 38, 105, 140, 333, 360],
1956
+ [-14, 10, -14, 10, -14]
1957
+ ),
1958
+ 56
1959
+ ),
1960
+ tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1961
+ getRotatedHue(
1962
+ sourceColorHct,
1963
+ [0, 38, 71, 105, 140, 161, 253, 333, 360],
1964
+ [-72, 35, 24, -24, 62, 50, 62, -72]
1965
+ ),
1966
+ 56
1967
+ ),
1968
+ neutral: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1969
+ getVibrantNeutralHue(sourceColorHct),
1970
+ getVibrantNeutralChroma(sourceColorHct)
1971
+ ),
1972
+ neutralVariant: ({ sourceColorHct }) => {
1973
+ const vibrantNeutralHue = getVibrantNeutralHue(sourceColorHct);
1974
+ const vibrantNeutralChroma = getVibrantNeutralChroma(sourceColorHct);
1975
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(
1976
+ vibrantNeutralHue,
1977
+ vibrantNeutralChroma * 1.29
1978
+ );
1979
+ },
1980
+ error: ({ sourceColorHct }) => {
1981
+ const errorHue = getPiecewiseHue(
1982
+ sourceColorHct,
1983
+ [0, 3, 13, 23, 33, 43, 153, 273, 360],
1984
+ [12, 22, 32, 12, 22, 32, 22, 12]
1985
+ );
1986
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 80);
1987
+ }
1988
+ },
1989
+ customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
1990
+ getRotatedHue(
1991
+ colorHct,
1992
+ [0, 38, 105, 140, 333, 360],
1993
+ [-14, 10, -14, 10, -14]
1994
+ ),
1995
+ 56
1996
+ )
1997
+ };
1998
+ const Variants = {
1999
+ Expressive: expressiveVariant,
2000
+ Neutral: neutralVariant,
2001
+ TonalSpot: tonalSpotVariant,
2002
+ Vibrant: vibrantVariant
2003
+ };
2004
+ const defaultColors = (colorService) => {
2005
+ const getColor = (key) => {
2006
+ return colorService.getColor(key).getMaterialColor();
2007
+ };
2008
+ const colors = {
2009
+ ////////////////////////////////////////////////////////////////
2010
+ // Surfaces [S] //
2011
+ ////////////////////////////////////////////////////////////////
2012
+ surface: {
2013
+ palette: (s) => s.getPalette("neutral"),
2014
+ tone: (s) => {
2015
+ if (s.isDark) {
2016
+ return 4;
2017
+ } else {
2018
+ if (Hct.isYellow(s.getPalette("neutral").hue)) {
2019
+ return 99;
2020
+ } else if (s.variant === "vibrant") {
2021
+ return 97;
2022
+ } else {
2023
+ return 98;
2024
+ }
2025
+ }
2026
+ },
2027
+ isBackground: true
2028
+ },
2029
+ surfaceDim: {
2030
+ palette: (s) => s.getPalette("neutral"),
2031
+ tone: (s) => {
2032
+ if (s.isDark) {
2033
+ return 4;
2034
+ } else {
2035
+ if (Hct.isYellow(s.getPalette("neutral").hue)) {
2036
+ return 90;
2037
+ } else if (s.variant === "vibrant") {
2038
+ return 85;
2039
+ } else {
2040
+ return 87;
2041
+ }
2042
+ }
2043
+ },
2044
+ isBackground: true,
2045
+ chromaMultiplier: (s) => {
2046
+ if (!s.isDark) {
2047
+ if (s.variant === "neutral") {
2048
+ return 2.5;
2049
+ } else if (s.variant === "tonalSpot") {
2050
+ return 1.7;
2051
+ } else if (s.variant === "expressive") {
2052
+ return Hct.isYellow(s.getPalette("neutral").hue) ? 2.7 : 1.75;
2053
+ } else if (s.variant === "vibrant") {
2054
+ return 1.36;
2055
+ }
2056
+ }
2057
+ return 1;
2058
+ }
2059
+ },
2060
+ surfaceBright: {
2061
+ palette: (s) => s.getPalette("neutral"),
2062
+ tone: (s) => {
2063
+ if (s.isDark) {
2064
+ return 18;
2065
+ } else {
2066
+ if (Hct.isYellow(s.getPalette("neutral").hue)) {
2067
+ return 99;
2068
+ } else if (s.variant === "vibrant") {
2069
+ return 97;
2070
+ } else {
2071
+ return 98;
2072
+ }
2073
+ }
2074
+ },
2075
+ isBackground: true,
2076
+ chromaMultiplier: (s) => {
2077
+ if (s.isDark) {
2078
+ if (s.variant === "neutral") {
2079
+ return 2.5;
2080
+ } else if (s.variant === "tonalSpot") {
2081
+ return 1.7;
2082
+ } else if (s.variant === "expressive") {
2083
+ return Hct.isYellow(s.getPalette("neutral").hue) ? 2.7 : 1.75;
2084
+ } else if (s.variant === "vibrant") {
2085
+ return 1.36;
2086
+ }
2087
+ }
2088
+ return 1;
2089
+ }
2090
+ },
2091
+ surfaceContainerLowest: {
2092
+ palette: (s) => s.getPalette("neutral"),
2093
+ tone: (s) => s.isDark ? 0 : 100,
2094
+ isBackground: true
2095
+ },
2096
+ surfaceContainerLow: {
2097
+ palette: (s) => s.getPalette("neutral"),
2098
+ tone: (s) => {
2099
+ if (s.isDark) {
2100
+ return 6;
2101
+ } else {
2102
+ if (Hct.isYellow(s.getPalette("neutral").hue)) {
2103
+ return 98;
2104
+ } else if (s.variant === "vibrant") {
2105
+ return 95;
2106
+ } else {
2107
+ return 96;
2108
+ }
2109
+ }
2110
+ },
2111
+ isBackground: true,
2112
+ chromaMultiplier: (s) => {
2113
+ if (s.variant === "neutral") {
2114
+ return 1.3;
2115
+ } else if (s.variant === "tonalSpot") {
2116
+ return 1.25;
2117
+ } else if (s.variant === "expressive") {
2118
+ return Hct.isYellow(s.getPalette("neutral").hue) ? 1.3 : 1.15;
2119
+ } else if (s.variant === "vibrant") {
2120
+ return 1.08;
2121
+ }
2122
+ return 1;
2123
+ }
2124
+ },
2125
+ surfaceContainer: {
2126
+ palette: (s) => s.getPalette("neutral"),
2127
+ tone: (s) => {
2128
+ if (s.isDark) {
2129
+ return 9;
2130
+ } else {
2131
+ if (Hct.isYellow(s.getPalette("neutral").hue)) {
2132
+ return 96;
2133
+ } else if (s.variant === "vibrant") {
2134
+ return 92;
2135
+ } else {
2136
+ return 94;
2137
+ }
2138
+ }
2139
+ },
2140
+ isBackground: true,
2141
+ chromaMultiplier: (s) => {
2142
+ if (s.variant === "neutral") {
2143
+ return 1.6;
2144
+ } else if (s.variant === "tonalSpot") {
2145
+ return 1.4;
2146
+ } else if (s.variant === "expressive") {
2147
+ return Hct.isYellow(s.getPalette("neutral").hue) ? 1.6 : 1.3;
2148
+ } else if (s.variant === "vibrant") {
2149
+ return 1.15;
2150
+ }
2151
+ return 1;
2152
+ }
2153
+ },
2154
+ surfaceContainerHigh: {
2155
+ palette: (s) => s.getPalette("neutral"),
2156
+ tone: (s) => {
2157
+ if (s.isDark) {
2158
+ return 12;
2159
+ } else {
2160
+ if (Hct.isYellow(s.getPalette("neutral").hue)) {
2161
+ return 94;
2162
+ } else if (s.variant === "vibrant") {
2163
+ return 90;
2164
+ } else {
2165
+ return 92;
2166
+ }
2167
+ }
2168
+ },
2169
+ isBackground: true,
2170
+ chromaMultiplier: (s) => {
2171
+ if (s.variant === "neutral") {
2172
+ return 1.9;
2173
+ } else if (s.variant === "tonalSpot") {
2174
+ return 1.5;
2175
+ } else if (s.variant === "expressive") {
2176
+ return Hct.isYellow(s.getPalette("neutral").hue) ? 1.95 : 1.45;
2177
+ } else if (s.variant === "vibrant") {
2178
+ return 1.22;
2179
+ }
2180
+ return 1;
2181
+ }
2182
+ },
2183
+ surfaceContainerHighest: {
2184
+ palette: (s) => s.getPalette("neutral"),
2185
+ tone: (s) => {
2186
+ if (s.isDark) {
2187
+ return 15;
2188
+ } else {
2189
+ if (Hct.isYellow(s.getPalette("neutral").hue)) {
2190
+ return 92;
2191
+ } else if (s.variant === "vibrant") {
2192
+ return 88;
2193
+ } else {
2194
+ return 90;
2195
+ }
2196
+ }
2197
+ },
2198
+ isBackground: true,
2199
+ chromaMultiplier: (s) => {
2200
+ if (s.variant === "neutral") {
2201
+ return 2.2;
2202
+ } else if (s.variant === "tonalSpot") {
2203
+ return 1.7;
2204
+ } else if (s.variant === "expressive") {
2205
+ return Hct.isYellow(s.getPalette("neutral").hue) ? 2.3 : 1.6;
2206
+ } else if (s.variant === "vibrant") {
2207
+ return 1.29;
2208
+ } else {
2209
+ return 1;
2210
+ }
2211
+ }
2212
+ },
2213
+ onSurface: {
2214
+ palette: (s) => s.getPalette("neutral"),
2215
+ tone: (s) => {
2216
+ if (s.variant === "vibrant") {
2217
+ return tMaxC(s.getPalette("neutral"), 0, 100, 1.1);
2218
+ } else {
2219
+ return DynamicColor.getInitialToneFromBackground(
2220
+ (s2) => highestSurface(s2, colorService)
2221
+ )(s);
2222
+ }
2223
+ },
2224
+ chromaMultiplier: (s) => {
2225
+ if (s.variant === "neutral") {
2226
+ return 2.2;
2227
+ } else if (s.variant === "tonalSpot") {
2228
+ return 1.7;
2229
+ } else if (s.variant === "expressive") {
2230
+ return Hct.isYellow(s.getPalette("neutral").hue) ? s.isDark ? 3 : 2.3 : 1.6;
2231
+ }
2232
+ return 1;
2233
+ },
2234
+ background: (s) => highestSurface(s, colorService),
2235
+ contrastCurve: (s) => s.isDark ? getCurve(11) : getCurve(9)
2236
+ },
2237
+ onSurfaceVariant: {
2238
+ palette: (s) => s.getPalette("neutralVariant"),
2239
+ chromaMultiplier: (s) => {
2240
+ if (s.variant === "neutral") {
2241
+ return 2.2;
2242
+ } else if (s.variant === "tonalSpot") {
2243
+ return 1.7;
2244
+ } else if (s.variant === "expressive") {
2245
+ return Hct.isYellow(s.getPalette("neutral").hue) ? s.isDark ? 3 : 2.3 : 1.6;
2246
+ }
2247
+ return 1;
2248
+ },
2249
+ background: (s) => highestSurface(s, colorService),
2250
+ contrastCurve: (s) => s.isDark ? getCurve(6) : getCurve(4.5)
2251
+ },
2252
+ outline: {
2253
+ palette: (s) => s.getPalette("neutralVariant"),
2254
+ chromaMultiplier: (s) => {
2255
+ if (s.variant === "neutral") {
2256
+ return 2.2;
2257
+ } else if (s.variant === "tonalSpot") {
2258
+ return 1.7;
2259
+ } else if (s.variant === "expressive") {
2260
+ return Hct.isYellow(s.getPalette("neutral").hue) ? s.isDark ? 3 : 2.3 : 1.6;
2261
+ }
2262
+ return 1;
2263
+ },
2264
+ background: (s) => highestSurface(s, colorService),
2265
+ contrastCurve: (s) => getCurve(3)
2266
+ },
2267
+ outlineVariant: {
2268
+ palette: (s) => s.getPalette("neutralVariant"),
2269
+ chromaMultiplier: (s) => {
2270
+ if (s.variant === "neutral") {
2271
+ return 2.2;
2272
+ } else if (s.variant === "tonalSpot") {
2273
+ return 1.7;
2274
+ } else if (s.variant === "expressive") {
2275
+ return Hct.isYellow(s.getPalette("neutral").hue) ? s.isDark ? 3 : 2.3 : 1.6;
2276
+ }
2277
+ return 1;
2278
+ },
2279
+ background: (s) => highestSurface(s, colorService),
2280
+ contrastCurve: (s) => getCurve(1.5)
2281
+ },
2282
+ inverseSurface: {
2283
+ palette: (s) => s.getPalette("neutral"),
2284
+ tone: (s) => s.isDark ? 98 : 4,
2285
+ isBackground: true
2286
+ },
2287
+ inverseOnSurface: {
2288
+ palette: (s) => s.getPalette("neutral"),
2289
+ tone: (s) => s.isDark ? 20 : 95,
2290
+ background: (s) => colorService.getColor("inverseSurface").getMaterialColor(),
2291
+ contrastCurve: (s) => getCurve(7)
2292
+ },
2293
+ ////////////////////////////////////////////////////////////////
2294
+ // Primaries [P] //
2295
+ ////////////////////////////////////////////////////////////////
2296
+ primary: {
2297
+ palette: (s) => s.getPalette("primary"),
2298
+ tone: (s) => {
2299
+ if (s.variant === "neutral") {
2300
+ return s.isDark ? 80 : 40;
2301
+ } else if (s.variant === "tonalSpot") {
2302
+ if (s.isDark) {
2303
+ return 80;
2304
+ } else {
2305
+ return tMaxC(s.getPalette("primary"));
2306
+ }
2307
+ } else if (s.variant === "expressive") {
2308
+ return tMaxC(
2309
+ s.getPalette("primary"),
2310
+ 0,
2311
+ Hct.isYellow(s.getPalette("primary").hue) ? 25 : Hct.isCyan(s.getPalette("primary").hue) ? 88 : 98
2312
+ );
2313
+ } else {
2314
+ return tMaxC(
2315
+ s.getPalette("primary"),
2316
+ 0,
2317
+ Hct.isCyan(s.getPalette("primary").hue) ? 88 : 98
2318
+ );
2319
+ }
2320
+ },
2321
+ isBackground: true,
2322
+ background: (s) => highestSurface(s, colorService),
2323
+ contrastCurve: (s) => getCurve(4.5),
2324
+ toneDeltaPair: (s) => new ToneDeltaPair(
2325
+ colorService.getColor("primaryContainer").getMaterialColor(),
2326
+ colorService.getColor("primary").getMaterialColor(),
2327
+ 5,
2328
+ "relative_lighter",
2329
+ true,
2330
+ "farther"
2331
+ )
2332
+ },
2333
+ primaryDim: {
2334
+ palette: (s) => s.getPalette("primary"),
2335
+ tone: (s) => {
2336
+ if (s.variant === "neutral") {
2337
+ return 85;
2338
+ } else if (s.variant === "tonalSpot") {
2339
+ return tMaxC(s.getPalette("primary"), 0, 90);
2340
+ } else {
2341
+ return tMaxC(s.getPalette("primary"));
2342
+ }
2343
+ },
2344
+ isBackground: true,
2345
+ background: (s) => getColor("surfaceContainerHigh"),
2346
+ contrastCurve: (s) => getCurve(4.5),
2347
+ toneDeltaPair: (s) => new ToneDeltaPair(
2348
+ colorService.getColor("primaryDim").getMaterialColor(),
2349
+ colorService.getColor("primary").getMaterialColor(),
2350
+ 5,
2351
+ "darker",
2352
+ true,
2353
+ "farther"
2354
+ )
2355
+ },
2356
+ onPrimary: {
2357
+ palette: (s) => s.getPalette("primary"),
2358
+ background: (s) => colorService.getColor("primary").getMaterialColor(),
2359
+ contrastCurve: (s) => getCurve(6)
2360
+ },
2361
+ primaryContainer: {
2362
+ palette: (s) => s.getPalette("primary"),
2363
+ tone: (s) => {
2364
+ if (s.variant === "neutral") {
2365
+ return s.isDark ? 30 : 90;
2366
+ } else if (s.variant === "tonalSpot") {
2367
+ return s.isDark ? tMinC(s.getPalette("primary"), 35, 93) : tMaxC(s.getPalette("primary"), 0, 90);
2368
+ } else if (s.variant === "expressive") {
2369
+ return s.isDark ? tMaxC(s.getPalette("primary"), 30, 93) : tMaxC(
2370
+ s.getPalette("primary"),
2371
+ 78,
2372
+ Hct.isCyan(s.getPalette("primary").hue) ? 88 : 90
2373
+ );
2374
+ } else {
2375
+ return s.isDark ? tMinC(s.getPalette("primary"), 66, 93) : tMaxC(
2376
+ s.getPalette("primary"),
2377
+ 66,
2378
+ Hct.isCyan(s.getPalette("primary").hue) ? 88 : 93
2379
+ );
2380
+ }
2381
+ },
2382
+ isBackground: true,
2383
+ background: (s) => highestSurface(s, colorService),
2384
+ toneDeltaPair: (s) => void 0,
2385
+ contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2386
+ },
2387
+ onPrimaryContainer: {
2388
+ palette: (s) => s.getPalette("primary"),
2389
+ background: (s) => colorService.getColor("primaryContainer").getMaterialColor(),
2390
+ contrastCurve: (s) => getCurve(6)
2391
+ },
2392
+ primaryFixed: {
2393
+ palette: (s) => s.getPalette("primary"),
2394
+ tone: (s) => {
2395
+ const tempS = new Scheme({
2396
+ ...s.options,
2397
+ isDark: false,
2398
+ contrastLevel: 0
2399
+ });
2400
+ return getColor("primaryContainer").getTone(tempS);
2401
+ },
2402
+ isBackground: true,
2403
+ background: (s) => highestSurface(s, colorService),
2404
+ contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2405
+ },
2406
+ primaryFixedDim: {
2407
+ palette: (s) => s.getPalette("primary"),
2408
+ tone: (s) => colorService.getColor("primaryFixed").getMaterialColor().getTone(s),
2409
+ isBackground: true,
2410
+ toneDeltaPair: (s) => new ToneDeltaPair(
2411
+ getColor("primaryFixedDim"),
2412
+ getColor("primaryFixed"),
2413
+ 5,
2414
+ "darker",
2415
+ true,
2416
+ "exact"
2417
+ )
2418
+ },
2419
+ onPrimaryFixed: {
2420
+ palette: (s) => s.getPalette("primary"),
2421
+ background: (s) => colorService.getColor("primaryFixedDim").getMaterialColor(),
2422
+ contrastCurve: (s) => getCurve(7)
2423
+ },
2424
+ onPrimaryFixedVariant: {
2425
+ palette: (s) => s.getPalette("primary"),
2426
+ background: (s) => colorService.getColor("primaryFixedDim").getMaterialColor(),
2427
+ contrastCurve: (s) => getCurve(4.5)
2428
+ },
2429
+ inversePrimary: {
2430
+ palette: (s) => s.getPalette("primary"),
2431
+ tone: (s) => tMaxC(s.getPalette("primary")),
2432
+ background: (s) => colorService.getColor("inverseSurface").getMaterialColor(),
2433
+ contrastCurve: (s) => getCurve(6)
2434
+ },
2435
+ ////////////////////////////////////////////////////////////////
2436
+ // Secondaries [Q] //
2437
+ ////////////////////////////////////////////////////////////////
2438
+ secondary: {
2439
+ palette: (s) => s.getPalette("secondary"),
2440
+ tone: (s) => {
2441
+ if (s.variant === "neutral") {
2442
+ return s.isDark ? tMinC(s.getPalette("secondary"), 0, 98) : tMaxC(s.getPalette("secondary"));
2443
+ } else if (s.variant === "vibrant") {
2444
+ return tMaxC(s.getPalette("secondary"), 0, s.isDark ? 90 : 98);
2445
+ } else {
2446
+ return s.isDark ? 80 : tMaxC(s.getPalette("secondary"));
2447
+ }
2448
+ },
2449
+ isBackground: true,
2450
+ background: (s) => highestSurface(s, colorService),
2451
+ contrastCurve: (s) => getCurve(4.5),
2452
+ toneDeltaPair: (s) => new ToneDeltaPair(
2453
+ getColor("secondaryContainer"),
2454
+ getColor("secondary"),
2455
+ 5,
2456
+ "relative_lighter",
2457
+ true,
2458
+ "farther"
2459
+ )
2460
+ },
2461
+ secondaryDim: {
2462
+ palette: (s) => s.getPalette("secondary"),
2463
+ tone: (s) => {
2464
+ if (s.variant === "neutral") {
2465
+ return 85;
2466
+ } else {
2467
+ return tMaxC(s.getPalette("secondary"), 0, 90);
2468
+ }
2469
+ },
2470
+ isBackground: true,
2471
+ background: (s) => getColor("surfaceContainerHigh"),
2472
+ contrastCurve: (s) => getCurve(4.5),
2473
+ toneDeltaPair: (s) => new ToneDeltaPair(
2474
+ getColor("secondaryDim"),
2475
+ getColor("secondary"),
2476
+ 5,
2477
+ "darker",
2478
+ true,
2479
+ "farther"
2480
+ )
2481
+ },
2482
+ onSecondary: {
2483
+ palette: (s) => s.getPalette("secondary"),
2484
+ background: (s) => getColor("secondary"),
2485
+ contrastCurve: (s) => getCurve(6)
2486
+ },
2487
+ secondaryContainer: {
2488
+ palette: (s) => s.getPalette("secondary"),
2489
+ tone: (s) => {
2490
+ if (s.variant === "vibrant") {
2491
+ return s.isDark ? tMinC(s.getPalette("secondary"), 30, 40) : tMaxC(s.getPalette("secondary"), 84, 90);
2492
+ } else if (s.variant === "expressive") {
2493
+ return s.isDark ? 15 : tMaxC(s.getPalette("secondary"), 90, 95);
2494
+ } else {
2495
+ return s.isDark ? 25 : 90;
2496
+ }
2497
+ },
2498
+ isBackground: true,
2499
+ background: (s) => highestSurface(s, colorService),
2500
+ toneDeltaPair: (s) => void 0,
2501
+ contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2502
+ },
2503
+ onSecondaryContainer: {
2504
+ palette: (s) => s.getPalette("secondary"),
2505
+ background: (s) => getColor("secondaryContainer"),
2506
+ contrastCurve: (s) => getCurve(6)
2507
+ },
2508
+ secondaryFixed: {
2509
+ palette: (s) => s.getPalette("secondary"),
2510
+ tone: (s) => {
2511
+ const tempS = new Scheme({
2512
+ ...s.options,
2513
+ isDark: false,
2514
+ contrastLevel: 0
2515
+ });
2516
+ return getColor("secondaryContainer").getTone(tempS);
2517
+ },
2518
+ isBackground: true,
2519
+ background: (s) => highestSurface(s, colorService),
2520
+ contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2521
+ },
2522
+ secondaryFixedDim: {
2523
+ palette: (s) => s.getPalette("secondary"),
2524
+ tone: (s) => getColor("secondaryFixed").getTone(s),
2525
+ isBackground: true,
2526
+ toneDeltaPair: (s) => new ToneDeltaPair(
2527
+ getColor("secondaryFixedDim"),
2528
+ getColor("secondaryFixed"),
2529
+ 5,
2530
+ "darker",
2531
+ true,
2532
+ "exact"
2533
+ )
2534
+ },
2535
+ onSecondaryFixed: {
2536
+ palette: (s) => s.getPalette("secondary"),
2537
+ background: (s) => getColor("secondaryFixedDim"),
2538
+ contrastCurve: (s) => getCurve(7)
2539
+ },
2540
+ onSecondaryFixedVariant: {
2541
+ palette: (s) => s.getPalette("secondary"),
2542
+ background: (s) => getColor("secondaryFixedDim"),
2543
+ contrastCurve: (s) => getCurve(4.5)
2544
+ },
2545
+ ////////////////////////////////////////////////////////////////
2546
+ // Tertiaries [T] //
2547
+ ////////////////////////////////////////////////////////////////
2548
+ tertiary: {
2549
+ palette: (s) => s.getPalette("tertiary"),
2550
+ tone: (s) => {
2551
+ if (s.variant === "expressive" || s.variant === "vibrant") {
2552
+ return tMaxC(
2553
+ s.getPalette("tertiary"),
2554
+ 0,
2555
+ Hct.isCyan(s.getPalette("tertiary").hue) ? 88 : s.isDark ? 98 : 100
2556
+ );
2557
+ } else {
2558
+ return s.isDark ? tMaxC(s.getPalette("tertiary"), 0, 98) : tMaxC(s.getPalette("tertiary"));
2559
+ }
2560
+ },
2561
+ isBackground: true,
2562
+ background: (s) => highestSurface(s, colorService),
2563
+ contrastCurve: (s) => getCurve(4.5),
2564
+ toneDeltaPair: (s) => new ToneDeltaPair(
2565
+ getColor("tertiaryContainer"),
2566
+ getColor("tertiary"),
2567
+ 5,
2568
+ "relative_lighter",
2569
+ true,
2570
+ "farther"
2571
+ )
2572
+ },
2573
+ tertiaryDim: {
2574
+ palette: (s) => s.getPalette("tertiary"),
2575
+ tone: (s) => {
2576
+ if (s.variant === "tonalSpot") {
2577
+ return tMaxC(s.getPalette("tertiary"), 0, 90);
2578
+ } else {
2579
+ return tMaxC(s.getPalette("tertiary"));
2580
+ }
2581
+ },
2582
+ isBackground: true,
2583
+ background: (s) => getColor("surfaceContainerHigh"),
2584
+ contrastCurve: (s) => getCurve(4.5),
2585
+ toneDeltaPair: (s) => new ToneDeltaPair(
2586
+ getColor("tertiaryDim"),
2587
+ getColor("tertiary"),
2588
+ 5,
2589
+ "darker",
2590
+ true,
2591
+ "farther"
2592
+ )
2593
+ },
2594
+ onTertiary: {
2595
+ palette: (s) => s.getPalette("tertiary"),
2596
+ background: (s) => getColor("tertiary"),
2597
+ contrastCurve: (s) => getCurve(6)
2598
+ },
2599
+ tertiaryContainer: {
2600
+ palette: (s) => s.getPalette("tertiary"),
2601
+ tone: (s) => {
2602
+ if (s.variant === "neutral") {
2603
+ return s.isDark ? tMaxC(s.getPalette("tertiary"), 0, 93) : tMaxC(s.getPalette("tertiary"), 0, 96);
2604
+ } else if (s.variant === "tonalSpot") {
2605
+ return tMaxC(s.getPalette("tertiary"), 0, s.isDark ? 93 : 100);
2606
+ } else if (s.variant === "expressive") {
2607
+ return tMaxC(
2608
+ s.getPalette("tertiary"),
2609
+ 75,
2610
+ Hct.isCyan(s.getPalette("tertiary").hue) ? 88 : s.isDark ? 93 : 100
2611
+ );
2612
+ } else {
2613
+ return s.isDark ? tMaxC(s.getPalette("tertiary"), 0, 93) : tMaxC(s.getPalette("tertiary"), 72, 100);
2614
+ }
2615
+ },
2616
+ isBackground: true,
2617
+ background: (s) => highestSurface(s, colorService),
2618
+ toneDeltaPair: (s) => void 0,
2619
+ contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2620
+ },
2621
+ onTertiaryContainer: {
2622
+ palette: (s) => s.getPalette("tertiary"),
2623
+ background: (s) => getColor("tertiaryContainer"),
2624
+ contrastCurve: (s) => getCurve(6)
2625
+ },
2626
+ tertiaryFixed: {
2627
+ palette: (s) => s.getPalette("tertiary"),
2628
+ tone: (s) => {
2629
+ const tempS = new Scheme({
2630
+ ...s.options,
2631
+ isDark: false,
2632
+ contrastLevel: 0
2633
+ });
2634
+ return getColor("tertiaryContainer").getTone(tempS);
2635
+ },
2636
+ isBackground: true,
2637
+ background: (s) => highestSurface(s, colorService),
2638
+ contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2639
+ },
2640
+ tertiaryFixedDim: {
2641
+ palette: (s) => s.getPalette("tertiary"),
2642
+ tone: (s) => getColor("tertiaryFixed").getTone(s),
2643
+ isBackground: true,
2644
+ toneDeltaPair: (s) => new ToneDeltaPair(
2645
+ getColor("tertiaryFixedDim"),
2646
+ getColor("tertiaryFixed"),
2647
+ 5,
2648
+ "darker",
2649
+ true,
2650
+ "exact"
2651
+ )
2652
+ },
2653
+ onTertiaryFixed: {
2654
+ palette: (s) => s.getPalette("tertiary"),
2655
+ background: (s) => getColor("tertiaryFixedDim"),
2656
+ contrastCurve: (s) => getCurve(7)
2657
+ },
2658
+ onTertiaryFixedVariant: {
2659
+ palette: (s) => s.getPalette("tertiary"),
2660
+ background: (s) => getColor("tertiaryFixedDim"),
2661
+ contrastCurve: (s) => getCurve(4.5)
2662
+ },
2663
+ ////////////////////////////////////////////////////////////////
2664
+ // Errors [E] //
2665
+ ////////////////////////////////////////////////////////////////
2666
+ error: {
2667
+ palette: (s) => s.getPalette("error"),
2668
+ tone: (s) => {
2669
+ return s.isDark ? tMinC(s.getPalette("error"), 0, 98) : tMaxC(s.getPalette("error"));
2670
+ },
2671
+ isBackground: true,
2672
+ background: (s) => highestSurface(s, colorService),
2673
+ contrastCurve: (s) => getCurve(4.5),
2674
+ toneDeltaPair: (s) => new ToneDeltaPair(
2675
+ colorService.getColor("errorContainer").getMaterialColor(),
2676
+ colorService.getColor("error").getMaterialColor(),
2677
+ 5,
2678
+ "relative_lighter",
2679
+ true,
2680
+ "farther"
2681
+ )
2682
+ },
2683
+ errorDim: {
2684
+ palette: (s) => s.getPalette("error"),
2685
+ tone: (s) => tMinC(s.getPalette("error")),
2686
+ isBackground: true,
2687
+ background: (s) => getColor("surfaceContainerHigh"),
2688
+ contrastCurve: (s) => getCurve(4.5),
2689
+ toneDeltaPair: (s) => new ToneDeltaPair(
2690
+ getColor("errorDim"),
2691
+ getColor("error"),
2692
+ 5,
2693
+ "darker",
2694
+ true,
2695
+ "farther"
2696
+ )
2697
+ },
2698
+ onError: {
2699
+ palette: (s) => s.getPalette("error"),
2700
+ background: (s) => colorService.getColor("error").getMaterialColor(),
2701
+ contrastCurve: (s) => getCurve(6)
2702
+ },
2703
+ errorContainer: {
2704
+ palette: (s) => s.getPalette("error"),
2705
+ tone: (s) => {
2706
+ return s.isDark ? tMinC(s.getPalette("error"), 30, 93) : tMaxC(s.getPalette("error"), 0, 90);
2707
+ },
2708
+ isBackground: true,
2709
+ background: (s) => highestSurface(s, colorService),
2710
+ toneDeltaPair: (s) => void 0,
2711
+ contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2712
+ },
2713
+ onErrorContainer: {
2714
+ palette: (s) => s.getPalette("error"),
2715
+ background: (s) => colorService.getColor("errorContainer").getMaterialColor(),
2716
+ contrastCurve: (s) => getCurve(4.5)
2717
+ },
2718
+ /////////////////////////////////////////////////////////////////
2719
+ // Remapped Colors //
2720
+ /////////////////////////////////////////////////////////////////
2721
+ surfaceVariant: {
2722
+ alias: "surfaceContainerHighest"
2723
+ },
2724
+ surfaceTint: {
2725
+ alias: "primary"
2726
+ },
2727
+ background: {
2728
+ alias: "surface"
2729
+ },
2730
+ onBackground: {
2731
+ alias: "onSurface"
2732
+ }
2733
+ };
2734
+ return {
2735
+ colors
2736
+ };
2737
+ };
2738
+ class API {
2739
+ constructor({
2740
+ colorApi,
2741
+ themeApi,
2742
+ pluginApi
2743
+ }) {
2744
+ __publicField(this, "colors");
2745
+ __publicField(this, "themes");
2746
+ __publicField(this, "plugins");
2747
+ this.plugins = pluginApi;
2748
+ this.colors = colorApi;
2749
+ this.themes = themeApi;
2750
+ }
2751
+ }
2752
+ const AppModule = {
2753
+ api: awilix.asClass(API).singleton()
2754
+ };
2755
+ class PluginAbstract {
2756
+ constructor(options) {
2757
+ __publicField(this, "options");
2758
+ __publicField(this, "pluginInstance");
2759
+ this.options = options;
2760
+ }
2761
+ init(api) {
2762
+ var _a, _b;
2763
+ this.pluginInstance = new this.pluginClass(api, this.options);
2764
+ (_b = (_a = this.pluginInstance).onInit) == null ? void 0 : _b.call(_a);
2765
+ return this;
2766
+ }
2767
+ getInstance() {
2768
+ if (!this.pluginInstance) {
2769
+ throw new Error(`Plugin ${this.name} is not initialized`);
2770
+ }
2771
+ return this.pluginInstance;
2772
+ }
2773
+ }
2774
+ class PluginImplAbstract {
2775
+ constructor(api, options) {
2776
+ var _a;
2777
+ this.api = api;
2778
+ this.options = options;
2779
+ (_a = this.onInit) == null ? void 0 : _a.call(this);
2780
+ }
2781
+ }
2782
+ class PluginApi {
2783
+ constructor() {
2784
+ __publicField(this, "plugins", /* @__PURE__ */ new Map());
2785
+ }
2786
+ addPlugin(plugin) {
2787
+ this.plugins.set(plugin.name, plugin);
2788
+ }
2789
+ initPlugins(api) {
2790
+ const plugins = new Map(this.plugins);
2791
+ let size = 0;
2792
+ this.plugins = /* @__PURE__ */ new Map();
2793
+ do {
2794
+ size = plugins.size;
2795
+ plugins.forEach((plugin, key) => {
2796
+ const deps = plugin.dependencies.filter(
2797
+ (dep) => !this.plugins.has(new dep().name)
2798
+ );
2799
+ if (deps.length === 0) {
2800
+ this.plugins.set(plugin.name, plugin.init(api));
2801
+ plugins.delete(key);
2802
+ }
2803
+ });
2804
+ } while (plugins.size != 0 && plugins.size < size);
2805
+ if (plugins.size > 0)
2806
+ throw new Error(
2807
+ "Some plugins couldn't be loaded due to missing dependencies: " + Array.from(plugins.keys())
2808
+ );
2809
+ }
2810
+ loadPlugins() {
2811
+ this.plugins.forEach((plugin) => {
2812
+ var _a, _b;
2813
+ (_b = (_a = plugin.getInstance()).onLoad) == null ? void 0 : _b.call(_a);
2814
+ });
2815
+ }
2816
+ getPlugin(plugin) {
2817
+ const pluginInstance = this.plugins.get(new plugin().name);
2818
+ if (!pluginInstance) throw new Error(`Plugin ${plugin.name} not found`);
2819
+ return pluginInstance;
2820
+ }
2821
+ }
2822
+ const PluginModule = {
2823
+ pluginApi: awilix.asClass(PluginApi).singleton()
2824
+ };
2825
+ function registerModule(...modules) {
2826
+ modules.forEach((module2) => {
2827
+ Object.entries(module2).forEach(([name, moduleClass]) => {
2828
+ AppContainer.register(name, moduleClass);
2829
+ });
2830
+ });
2831
+ return AppContainer;
2832
+ }
2833
+ const AppContainer = awilix.createContainer({
2834
+ injectionMode: awilix.InjectionMode.PROXY
2835
+ });
2836
+ registerModule(AppModule, PluginModule, ColorModule, ThemeModule);
2837
+ function bootstrap() {
2838
+ return AppContainer.resolve("api");
2839
+ }
2840
+ class AdapterAbstract {
2841
+ constructor() {
2842
+ __publicField(this, "api");
2843
+ this.api = bootstrap();
2844
+ registerModule({
2845
+ adapter: awilix.asValue(this)
2846
+ });
2847
+ }
2848
+ async init() {
2849
+ const config = await this.getConfig();
2850
+ if (config == null) {
2851
+ return;
2852
+ }
2853
+ const {
2854
+ sourceColor,
2855
+ contrastLevel = 0,
2856
+ isDark = false,
2857
+ variant = tonalSpotVariant,
2858
+ palettes,
2859
+ colors,
2860
+ useDefaultColors = true,
2861
+ plugins
2862
+ } = config;
2863
+ this.api.themes.create({
2864
+ contrastLevel,
2865
+ isDark,
2866
+ sourceColorHex: sourceColor,
2867
+ variant
2868
+ });
2869
+ if (palettes) {
2870
+ Object.entries(palettes).forEach(
2871
+ ([key, value]) => this.api.themes.addCustomPalette(key, value)
2872
+ );
2873
+ }
2874
+ if (useDefaultColors) {
2875
+ this.api.colors.addColors(defaultColors);
2876
+ }
2877
+ if (colors) {
2878
+ this.api.colors.addColors(colors);
2879
+ }
2880
+ if (plugins) {
2881
+ plugins.forEach((plugin) => {
2882
+ this.api.plugins.addPlugin(plugin);
2883
+ });
2884
+ this.api.plugins.initPlugins(this.api);
2885
+ }
2886
+ }
2887
+ load() {
2888
+ this.api.plugins.loadPlugins();
2889
+ }
2890
+ }
2891
+ function defineConfig(configObject) {
2892
+ if (!configObject || typeof configObject !== "object") {
2893
+ throw new Error("The configuration is missing or not an object");
2894
+ }
2895
+ if (!("sourceColor" in configObject)) {
2896
+ throw new Error("Invalid configuration");
2897
+ }
2898
+ return configObject;
2899
+ }
2900
+ class NodeAdapter extends AdapterAbstract {
2901
+ constructor(configPath = "./theme.config") {
2902
+ super();
2903
+ this.configPath = configPath;
2904
+ }
2905
+ async getConfig() {
2906
+ if (typeof process !== "undefined" && process.release && process.release.name === "node") {
2907
+ const path2 = (await import("path")).default;
2908
+ const fs2 = (await import("fs")).default;
2909
+ const base = path2.resolve(this.configPath);
2910
+ const extensions = [".js", ".ts", ".mjs", ".cjs"];
2911
+ let configImport = null;
2912
+ for (const ext of extensions) {
2913
+ const path22 = base + ext;
2914
+ if (fs2.existsSync(path22)) {
2915
+ configImport = (await import(path22)).default;
2916
+ break;
2917
+ }
2918
+ }
2919
+ if (!configImport) {
2920
+ throw new Error(
2921
+ `Configuration file not found, looked for: ${base} with extensions: ${extensions.join(", ")}`
2922
+ );
2923
+ }
2924
+ let config;
2925
+ if ("default" in configImport) {
2926
+ config = configImport.default;
2927
+ } else {
2928
+ config = configImport;
2929
+ }
2930
+ return config;
2931
+ } else {
2932
+ throw new Error(
2933
+ "You must provide configuration object when using this library in a browser."
2934
+ );
2935
+ }
2936
+ }
2937
+ }
2938
+ const udixioVite = async (configPath = "./theme.config") => {
2939
+ if (global.NX_GRAPH_CREATION) {
2940
+ return;
2941
+ }
2942
+ class ViteAdapter extends AdapterAbstract {
2943
+ constructor(configPath2) {
2944
+ super();
2945
+ __publicField(this, "configExtension");
2946
+ this.configPath = configPath2;
2947
+ }
2948
+ getConfigPath() {
2949
+ if (!this.configExtension) {
2950
+ throw new Error("config extension not found");
2951
+ }
2952
+ return path__namespace.resolve(this.configPath + this.configExtension);
2953
+ }
2954
+ async getConfig() {
2955
+ const resolvedPath = path__namespace.resolve(this.configPath);
2956
+ const result = await vite.loadConfigFromFile(
2957
+ { command: "serve", mode: "development" },
2958
+ // ou 'build'
2959
+ resolvedPath
2960
+ );
2961
+ if (!(result == null ? void 0 : result.config)) {
2962
+ throw new Error("config not found");
2963
+ }
2964
+ if (!this.configExtension) {
2965
+ this.configExtension = path__namespace.extname(result.dependencies[0]);
2966
+ }
2967
+ return result.config;
2968
+ }
2969
+ }
2970
+ const adapter = new ViteAdapter(configPath);
2971
+ await adapter.init();
2972
+ configPath = adapter.getConfigPath();
2973
+ return {
2974
+ name: "vite:udixio-theme",
2975
+ async buildStart() {
2976
+ if (fs__namespace.existsSync(configPath)) {
2977
+ this.addWatchFile(configPath);
2978
+ }
2979
+ adapter.load();
2980
+ },
2981
+ async generateBundle() {
2982
+ adapter.load();
2983
+ },
2984
+ // Handles Hot Module Replacement in dev server
2985
+ async handleHotUpdate({ server, file, modules }) {
2986
+ if (configPath === file) {
2987
+ const adapter2 = new ViteAdapter(configPath);
2988
+ await adapter2.init();
2989
+ adapter2.load();
2990
+ server.ws.send({ type: "full-reload", path: "*" });
2991
+ return modules;
2992
+ }
2993
+ return;
2994
+ }
2995
+ };
2996
+ };
2997
+ var FontFamily = /* @__PURE__ */ ((FontFamily2) => {
2998
+ FontFamily2["Expressive"] = "expressive";
2999
+ FontFamily2["Neutral"] = "neutral";
3000
+ return FontFamily2;
3001
+ })(FontFamily || {});
3002
+ class FontPlugin extends PluginAbstract {
3003
+ constructor() {
3004
+ super(...arguments);
3005
+ __publicField(this, "dependencies", []);
3006
+ __publicField(this, "name", "font");
3007
+ __publicField(this, "pluginClass", FontPluginImpl);
3008
+ }
3009
+ }
3010
+ class FontPluginImpl extends PluginImplAbstract {
3011
+ constructor() {
3012
+ super(...arguments);
3013
+ __publicField(this, "_fontFamily");
3014
+ __publicField(this, "_fontStyles");
3015
+ }
3016
+ get fontFamily() {
3017
+ if (!this._fontFamily) throw new Error("Font family not initialized");
3018
+ return this._fontFamily;
3019
+ }
3020
+ set fontFamily(value) {
3021
+ this._fontFamily = value;
3022
+ }
3023
+ get fontStyles() {
3024
+ if (!this._fontStyles) throw new Error("Font styles not initialized");
3025
+ return this._fontStyles;
3026
+ }
3027
+ set fontStyles(value) {
3028
+ this._fontStyles = value;
3029
+ }
3030
+ getFonts() {
3031
+ return {
3032
+ fontStyles: this.fontStyles,
3033
+ fontFamily: this.fontFamily
3034
+ };
3035
+ }
3036
+ onInit() {
3037
+ var _a, _b, _c, _d;
3038
+ this.fontFamily = {
3039
+ expressive: ((_b = (_a = this.options) == null ? void 0 : _a.fontFamily) == null ? void 0 : _b.expressive) ?? [
3040
+ "Roboto",
3041
+ "sans-serif"
3042
+ ],
3043
+ neutral: ((_d = (_c = this.options) == null ? void 0 : _c.fontFamily) == null ? void 0 : _d.neutral) ?? ["Roboto", "sans-serif"]
3044
+ };
3045
+ this.fontStyles = {
3046
+ display: {
3047
+ large: {
3048
+ fontWeight: 400,
3049
+ fontSize: 3.5625,
3050
+ lineHeight: 4,
3051
+ letterSpacing: -0.015625,
3052
+ fontFamily: "expressive"
3053
+ /* Expressive */
3054
+ },
3055
+ medium: {
3056
+ fontWeight: 400,
3057
+ fontSize: 2.8125,
3058
+ lineHeight: 3.25,
3059
+ fontFamily: "expressive"
3060
+ /* Expressive */
3061
+ },
3062
+ small: {
3063
+ fontWeight: 400,
3064
+ fontSize: 2.25,
3065
+ lineHeight: 2.75,
3066
+ fontFamily: "expressive"
3067
+ /* Expressive */
3068
+ }
3069
+ },
3070
+ headline: {
3071
+ large: {
3072
+ fontWeight: 400,
3073
+ fontSize: 2,
3074
+ lineHeight: 2.5,
3075
+ fontFamily: "expressive"
3076
+ /* Expressive */
3077
+ },
3078
+ medium: {
3079
+ fontWeight: 400,
3080
+ fontSize: 1.75,
3081
+ lineHeight: 2.25,
3082
+ fontFamily: "expressive"
3083
+ /* Expressive */
3084
+ },
3085
+ small: {
3086
+ fontWeight: 400,
3087
+ fontSize: 1.5,
3088
+ lineHeight: 2,
3089
+ fontFamily: "expressive"
3090
+ /* Expressive */
3091
+ }
3092
+ },
3093
+ title: {
3094
+ large: {
3095
+ fontWeight: 400,
3096
+ fontSize: 1.375,
3097
+ lineHeight: 1.75,
3098
+ fontFamily: "neutral"
3099
+ /* Neutral */
3100
+ },
3101
+ medium: {
3102
+ fontWeight: 500,
3103
+ fontSize: 1,
3104
+ lineHeight: 1.5,
3105
+ fontFamily: "neutral",
3106
+ letterSpacing: 9375e-6
3107
+ },
3108
+ small: {
3109
+ fontWeight: 500,
3110
+ fontSize: 0.875,
3111
+ lineHeight: 1.25,
3112
+ fontFamily: "neutral",
3113
+ letterSpacing: 625e-5
3114
+ }
3115
+ },
3116
+ label: {
3117
+ large: {
3118
+ fontWeight: 500,
3119
+ fontSize: 0.875,
3120
+ lineHeight: 1.25,
3121
+ fontFamily: "neutral",
3122
+ letterSpacing: 625e-5
3123
+ },
3124
+ medium: {
3125
+ fontWeight: 500,
3126
+ fontSize: 0.75,
3127
+ lineHeight: 1,
3128
+ fontFamily: "neutral",
3129
+ letterSpacing: 0.03125
3130
+ },
3131
+ small: {
3132
+ fontWeight: 500,
3133
+ fontSize: 0.6875,
3134
+ lineHeight: 1,
3135
+ fontFamily: "neutral",
3136
+ letterSpacing: 0.03125
3137
+ }
3138
+ },
3139
+ body: {
3140
+ large: {
3141
+ fontWeight: 400,
3142
+ fontSize: 1,
3143
+ lineHeight: 1.5625,
3144
+ fontFamily: "neutral",
3145
+ letterSpacing: 0.03125
3146
+ },
3147
+ medium: {
3148
+ fontWeight: 400,
3149
+ fontSize: 0.875,
3150
+ lineHeight: 1.25,
3151
+ fontFamily: "neutral",
3152
+ letterSpacing: 0.015625
3153
+ },
3154
+ small: {
3155
+ fontWeight: 400,
3156
+ fontSize: 0.75,
3157
+ lineHeight: 1,
3158
+ fontFamily: "neutral",
3159
+ letterSpacing: 0.025
3160
+ }
3161
+ }
3162
+ };
3163
+ if (this.options && this.options.fontStyles)
3164
+ Object.entries(this.options.fontStyles).forEach(([key, fontParam]) => {
3165
+ const fontRole = key;
3166
+ Object.entries(fontParam).forEach(([size, fontStyle]) => {
3167
+ const fontSize = size;
3168
+ if (fontStyle) {
3169
+ this.fontStyles[fontRole][fontSize] = {
3170
+ ...this.fontStyles[fontRole][fontSize],
3171
+ ...fontStyle
3172
+ };
3173
+ }
3174
+ });
3175
+ });
3176
+ }
3177
+ }
3178
+ exports.API = API;
3179
+ exports.AdapterAbstract = AdapterAbstract;
3180
+ exports.AppContainer = AppContainer;
3181
+ exports.AppModule = AppModule;
3182
+ exports.ColorApi = ColorApi;
3183
+ exports.ColorManager = ColorManager;
3184
+ exports.ColorModule = ColorModule;
3185
+ exports.ConfigurableColor = ConfigurableColor;
3186
+ exports.ContrastCurve = ContrastCurve;
3187
+ exports.DynamicColor = DynamicColor;
3188
+ exports.FontFamily = FontFamily;
3189
+ exports.FontPlugin = FontPlugin;
3190
+ exports.NodeAdapter = NodeAdapter;
3191
+ exports.PluginAbstract = PluginAbstract;
3192
+ exports.PluginApi = PluginApi;
3193
+ exports.PluginImplAbstract = PluginImplAbstract;
3194
+ exports.PluginModule = PluginModule;
3195
+ exports.Scheme = Scheme;
3196
+ exports.SchemeManager = SchemeManager;
3197
+ exports.ThemeApi = ThemeApi;
3198
+ exports.ThemeModule = ThemeModule;
3199
+ exports.ToneDeltaPair = ToneDeltaPair;
3200
+ exports.Variant = Variant;
3201
+ exports.VariantManager = VariantManager;
3202
+ exports.Variants = Variants;
3203
+ exports.bootstrap = bootstrap;
3204
+ exports.defaultColors = defaultColors;
3205
+ exports.defineConfig = defineConfig;
3206
+ exports.expressiveVariant = expressiveVariant;
3207
+ exports.extendSpecVersion = extendSpecVersion;
3208
+ exports.getPiecewiseHue = getPiecewiseHue;
3209
+ exports.getRotatedHue = getRotatedHue;
3210
+ exports.highestSurface = highestSurface;
3211
+ exports.neutralVariant = neutralVariant;
3212
+ exports.registerModule = registerModule;
3213
+ exports.tonalSpotVariant = tonalSpotVariant;
3214
+ exports.udixioVite = udixioVite;
3215
+ exports.vibrantVariant = vibrantVariant;