@supportpages.io/wtfm 0.0.0-stage → 0.3.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.
- package/LICENSE +201 -0
- package/NOTICE +23 -0
- package/README.md +392 -2
- package/dist/actions.d.ts +98 -0
- package/dist/actions.js +86 -0
- package/dist/actions.js.map +1 -0
- package/dist/agent-settings.d.ts +22 -0
- package/dist/agent-settings.js +35 -0
- package/dist/agent-settings.js.map +1 -0
- package/dist/api.d.ts +14 -0
- package/dist/api.js +159 -0
- package/dist/api.js.map +1 -0
- package/dist/article-link.d.ts +16 -0
- package/dist/article-link.js +25 -0
- package/dist/article-link.js.map +1 -0
- package/dist/artifacts.d.ts +45 -0
- package/dist/artifacts.js +144 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/brand.d.ts +4 -0
- package/dist/brand.js +9 -0
- package/dist/brand.js.map +1 -0
- package/dist/bridge.d.ts +2964 -0
- package/dist/bridge.js +1036 -0
- package/dist/bridge.js.map +1 -0
- package/dist/capacity.d.ts +5 -0
- package/dist/capacity.js +11 -0
- package/dist/capacity.js.map +1 -0
- package/dist/credentials.d.ts +13 -0
- package/dist/credentials.js +88 -0
- package/dist/credentials.js.map +1 -0
- package/dist/development-tls.d.ts +8 -0
- package/dist/development-tls.js +38 -0
- package/dist/development-tls.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +18 -0
- package/dist/errors.js.map +1 -0
- package/dist/export.d.ts +11 -0
- package/dist/export.js +91 -0
- package/dist/export.js.map +1 -0
- package/dist/hosted-operations.d.ts +108 -0
- package/dist/hosted-operations.js +120 -0
- package/dist/hosted-operations.js.map +1 -0
- package/dist/hosting-benefits.d.ts +66 -0
- package/dist/hosting-benefits.js +67 -0
- package/dist/hosting-benefits.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/local-inventory.d.ts +22 -0
- package/dist/local-inventory.js +59 -0
- package/dist/local-inventory.js.map +1 -0
- package/dist/local-setup.d.ts +208 -0
- package/dist/local-setup.js +140 -0
- package/dist/local-setup.js.map +1 -0
- package/dist/pairing.d.ts +71 -0
- package/dist/pairing.js +235 -0
- package/dist/pairing.js.map +1 -0
- package/dist/preferences.d.ts +18 -0
- package/dist/preferences.js +44 -0
- package/dist/preferences.js.map +1 -0
- package/dist/progress.d.ts +205 -0
- package/dist/progress.js +224 -0
- package/dist/progress.js.map +1 -0
- package/dist/reminders.d.ts +31 -0
- package/dist/reminders.js +73 -0
- package/dist/reminders.js.map +1 -0
- package/dist/replace-connection.d.ts +6 -0
- package/dist/replace-connection.js +77 -0
- package/dist/replace-connection.js.map +1 -0
- package/dist/repository-actions.d.ts +18 -0
- package/dist/repository-actions.js +9 -0
- package/dist/repository-actions.js.map +1 -0
- package/dist/repository-benefits.d.ts +96 -0
- package/dist/repository-benefits.js +64 -0
- package/dist/repository-benefits.js.map +1 -0
- package/dist/run-update.d.ts +17 -0
- package/dist/run-update.js +27 -0
- package/dist/run-update.js.map +1 -0
- package/dist/runs.d.ts +541 -0
- package/dist/runs.js +146 -0
- package/dist/runs.js.map +1 -0
- package/dist/runtime.d.ts +12 -0
- package/dist/runtime.js +58 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema.d.ts +277 -0
- package/dist/schema.js +66 -0
- package/dist/schema.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +298 -0
- package/dist/server.js.map +1 -0
- package/dist/session.d.ts +1714 -0
- package/dist/session.js +619 -0
- package/dist/session.js.map +1 -0
- package/dist/settings.d.ts +9 -0
- package/dist/settings.js +21 -0
- package/dist/settings.js.map +1 -0
- package/dist/sync.d.ts +495 -0
- package/dist/sync.js +191 -0
- package/dist/sync.js.map +1 -0
- package/dist/telemetry-scrub.d.ts +13 -0
- package/dist/telemetry-scrub.js +51 -0
- package/dist/telemetry-scrub.js.map +1 -0
- package/dist/telemetry.d.ts +73 -0
- package/dist/telemetry.js +173 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/walkthroughs.d.ts +224 -0
- package/dist/walkthroughs.js +109 -0
- package/dist/walkthroughs.js.map +1 -0
- package/dist/workspace.d.ts +14 -0
- package/dist/workspace.js +127 -0
- package/dist/workspace.js.map +1 -0
- package/dist/writer-agent.d.ts +21 -0
- package/dist/writer-agent.js +27 -0
- package/dist/writer-agent.js.map +1 -0
- package/dist/writer-entry.d.ts +171 -0
- package/dist/writer-entry.js +233 -0
- package/dist/writer-entry.js.map +1 -0
- package/dist/writing-style.d.ts +7 -0
- package/dist/writing-style.js +52 -0
- package/dist/writing-style.js.map +1 -0
- package/engine/SYNC.json +4 -0
- package/engine/VERSION +1 -0
- package/engine/detect-project/README.md +141 -0
- package/engine/detect-project/SKILL.md +1421 -0
- package/engine/detect-project/assets/desktop/desktop-frame.css +428 -0
- package/engine/detect-project/assets/game/game-frame.css +132 -0
- package/engine/detect-project/assets/macosui/LICENSE-puppertino.txt +21 -0
- package/engine/detect-project/assets/macosui/VERSIONS.txt +1 -0
- package/engine/detect-project/assets/macosui/fonts.css +15 -0
- package/engine/detect-project/assets/macosui/macos-frame.css +481 -0
- package/engine/detect-project/assets/macosui/puppertino.css +2153 -0
- package/engine/detect-project/assets/mobileui/LICENSE-fonts.txt +13 -0
- package/engine/detect-project/assets/mobileui/LICENSE-framework7.txt +52 -0
- package/engine/detect-project/assets/mobileui/VERSIONS.txt +6 -0
- package/engine/detect-project/assets/mobileui/device-frame.css +316 -0
- package/engine/detect-project/assets/mobileui/f7-color-theme.mjs +1345 -0
- package/engine/detect-project/assets/mobileui/f7-icons-names.json +1254 -0
- package/engine/detect-project/assets/mobileui/fonts.css +16 -0
- package/engine/detect-project/assets/mobileui/framework7-components.css +39 -0
- package/engine/detect-project/assets/mobileui/framework7-core.css +5245 -0
- package/engine/detect-project/assets/mobileui/icons.css +31 -0
- package/engine/detect-project/assets/mobileui/md3-defaults.css +89 -0
- package/engine/detect-project/assets/mobileui/platforms.json +46 -0
- package/engine/detect-project/assets/tailwind-fallback.css +1729 -0
- package/engine/detect-project/assets/webtui/LICENSE-webtui.txt +28 -0
- package/engine/detect-project/assets/webtui/VERSIONS.txt +7 -0
- package/engine/detect-project/assets/webtui/terminal-frame.css +195 -0
- package/engine/detect-project/assets/webtui/theme-catppuccin.css +1 -0
- package/engine/detect-project/assets/webtui/theme-everforest.css +1 -0
- package/engine/detect-project/assets/webtui/theme-gruvbox.css +1 -0
- package/engine/detect-project/assets/webtui/theme-nord.css +1 -0
- package/engine/detect-project/assets/webtui/theme-vitesse.css +1 -0
- package/engine/detect-project/assets/webtui/themes.json +37 -0
- package/engine/detect-project/assets/webtui/webtui-core.css +1 -0
- package/engine/detect-project/assets/win32ui/7css.css +2 -0
- package/engine/detect-project/assets/win32ui/LICENSE-7css.txt +21 -0
- package/engine/detect-project/assets/win32ui/VERSIONS.txt +1 -0
- package/engine/detect-project/assets/win32ui/win32-frame.css +278 -0
- package/engine/detect-project/package-lock.json +12 -0
- package/engine/detect-project/package.json +10 -0
- package/engine/detect-project/scripts/apply_runtime_profiles.js +313 -0
- package/engine/detect-project/scripts/check_css_health.js +412 -0
- package/engine/detect-project/scripts/check_project_map.js +150 -0
- package/engine/detect-project/scripts/check_runtime_coverage.js +311 -0
- package/engine/detect-project/scripts/check_runtime_recipe_quality.js +184 -0
- package/engine/detect-project/scripts/classify_app_type.sh +246 -0
- package/engine/detect-project/scripts/classify_surface.sh +95 -0
- package/engine/detect-project/scripts/classify_workspace.js +39 -0
- package/engine/detect-project/scripts/compile_css.sh +447 -0
- package/engine/detect-project/scripts/detect_static.js +645 -0
- package/engine/detect-project/scripts/detect_structure.js +187 -0
- package/engine/detect-project/scripts/include_census.js +451 -0
- package/engine/detect-project/scripts/json_get.js +142 -0
- package/engine/detect-project/scripts/merge_json.js +52 -0
- package/engine/detect-project/scripts/recommend_model_tier.js +252 -0
- package/engine/detect-project/scripts/resolve_route_chains.js +135 -0
- package/engine/detect-project/scripts/run_css_build.sh +40 -0
- package/engine/detect-project/scripts/sanitize_css.js +83 -0
- package/engine/detect-project/scripts/test_classify_surface.js +108 -0
- package/engine/detect-project/scripts/test_node_helpers.js +142 -0
- package/engine/detect-project/scripts/test_recommend_model_tier.js +119 -0
- package/engine/detect-project/scripts/test_resolve_route_chains.js +182 -0
- package/engine/detect-project/scripts/test_runtime_coverage.js +323 -0
- package/engine/detect-project/scripts/test_runtime_recipe_quality.js +187 -0
- package/engine/detect-project/scripts/theme_overrides.js +169 -0
- package/engine/detect-project/scripts/write_branding.js +129 -0
- package/engine/generate-illustrated-article/SKILL.md +461 -0
- package/engine/generate-illustrated-article/contracts/desktop.md +90 -0
- package/engine/generate-illustrated-article/contracts/game.md +38 -0
- package/engine/generate-illustrated-article/contracts/label-evidence.md +38 -0
- package/engine/generate-illustrated-article/contracts/macos.md +79 -0
- package/engine/generate-illustrated-article/contracts/mobile.md +40 -0
- package/engine/generate-illustrated-article/contracts/terminal.md +29 -0
- package/engine/generate-illustrated-article/contracts/win32.md +43 -0
- package/engine/generate-illustrated-article/package-lock.json +366 -0
- package/engine/generate-illustrated-article/package.json +15 -0
- package/engine/generate-illustrated-article/scripts/article_blocks.js +34 -0
- package/engine/generate-illustrated-article/scripts/check_article_json.js +105 -0
- package/engine/generate-illustrated-article/scripts/emit_walkthrough_signals.js +100 -0
- package/engine/generate-illustrated-article/scripts/extract_images.js +187 -0
- package/engine/generate-illustrated-article/scripts/generate_content_images.js +376 -0
- package/engine/generate-illustrated-article/scripts/include_census.js +451 -0
- package/engine/generate-illustrated-article/scripts/inject_assets.js +1691 -0
- package/engine/generate-illustrated-article/scripts/jit_mockup_css.js +191 -0
- package/engine/generate-illustrated-article/scripts/label_evidence.js +87 -0
- package/engine/generate-illustrated-article/scripts/lint_article_copy.js +252 -0
- package/engine/generate-illustrated-article/scripts/lint_mockup_fidelity.js +2403 -0
- package/engine/generate-illustrated-article/scripts/polish_tickets.js +1148 -0
- package/engine/generate-illustrated-article/scripts/related_repos.sh +52 -0
- package/engine/generate-illustrated-article/scripts/render_all.js +177 -0
- package/engine/generate-illustrated-article/scripts/render_mockup.js +665 -0
- package/engine/generate-illustrated-article/scripts/render_ready.js +164 -0
- package/engine/generate-illustrated-article/scripts/resolve_workspace.sh +86 -0
- package/engine/generate-illustrated-article/scripts/runtime_region_geometry.js +55 -0
- package/engine/generate-illustrated-article/scripts/source_paths.js +49 -0
- package/engine/generate-illustrated-article/scripts/test_control_visibility.js +30 -0
- package/engine/generate-illustrated-article/scripts/test_emit_walkthrough_signals.js +157 -0
- package/engine/generate-illustrated-article/scripts/test_generate_content_images.js +168 -0
- package/engine/generate-illustrated-article/scripts/test_include_census.js +126 -0
- package/engine/generate-illustrated-article/scripts/test_label_evidence.js +49 -0
- package/engine/generate-illustrated-article/scripts/test_lint_article_copy.js +138 -0
- package/engine/generate-illustrated-article/scripts/test_lint_mockup_fidelity.js +653 -0
- package/engine/generate-illustrated-article/scripts/test_node_ports.js +152 -0
- package/engine/generate-illustrated-article/scripts/test_polish_tickets.js +481 -0
- package/engine/generate-illustrated-article/scripts/test_related_repos.js +64 -0
- package/engine/generate-illustrated-article/scripts/test_render_ready.js +85 -0
- package/engine/generate-illustrated-article/scripts/test_source_paths.js +68 -0
- package/engine/generate-illustrated-article/scripts/trace_hook.js +79 -0
- package/engine/generate-illustrated-article/scripts/trace_hook.sh +4 -0
- package/engine/generate-illustrated-article/scripts/validate_html.js +114 -0
- package/engine/generate-illustrated-article/scripts/watermark.js +69 -0
- package/install.sh +14 -0
- package/package.json +57 -4
- package/scripts/auth.mjs +33 -0
- package/scripts/auto-update.mjs +7 -0
- package/scripts/build-plugin.mjs +58 -0
- package/scripts/build-release.mjs +94 -0
- package/scripts/check-release.mjs +40 -0
- package/scripts/check-runtime.mjs +10 -0
- package/scripts/cli.mjs +8 -0
- package/scripts/install.mjs +64 -0
- package/scripts/lib/agent-runner.mjs +181 -0
- package/scripts/lib/agent-settings.mjs +215 -0
- package/scripts/lib/article-skills.mjs +82 -0
- package/scripts/lib/auto-update.mjs +50 -0
- package/scripts/lib/brand.mjs +9 -0
- package/scripts/lib/browser.mjs +12 -0
- package/scripts/lib/claude-connection.mjs +33 -0
- package/scripts/lib/claude-permissions.mjs +47 -0
- package/scripts/lib/claude-plugin.mjs +15 -0
- package/scripts/lib/claude-writer.mjs +10 -0
- package/scripts/lib/cli-main.mjs +85 -0
- package/scripts/lib/cli.mjs +888 -0
- package/scripts/lib/codex-config.mjs +51 -0
- package/scripts/lib/codex-integration.mjs +61 -0
- package/scripts/lib/codex-skill.mjs +34 -0
- package/scripts/lib/harness-models.mjs +109 -0
- package/scripts/lib/install.mjs +269 -0
- package/scripts/lib/managed-writer.mjs +38 -0
- package/scripts/lib/planning.mjs +263 -0
- package/scripts/lib/prepare-update.mjs +85 -0
- package/scripts/lib/refresh-writers.mjs +12 -0
- package/scripts/lib/remove.mjs +167 -0
- package/scripts/lib/renderer.mjs +34 -0
- package/scripts/lib/terminal.mjs +252 -0
- package/scripts/lib/uninit.mjs +72 -0
- package/scripts/lib/update.mjs +55 -0
- package/scripts/lib/writer-recovery.mjs +35 -0
- package/scripts/lib/yolo.mjs +362 -0
- package/scripts/plugin-session.mjs +65 -0
- package/scripts/prepare-update.mjs +12 -0
- package/scripts/publish-release.mjs +92 -0
- package/scripts/skills/supportpages/SKILL.md +120 -0
- package/scripts/smoke-release.mjs +101 -0
- package/server.json +27 -0
|
@@ -0,0 +1,1345 @@
|
|
|
1
|
+
// node_modules/framework7/shared/material-color-utils.js
|
|
2
|
+
function signum(num) {
|
|
3
|
+
return num < 0 ? -1 : 0 === num ? 0 : 1;
|
|
4
|
+
}
|
|
5
|
+
function lerp(start, stop, amount) {
|
|
6
|
+
return (1 - amount) * start + amount * stop;
|
|
7
|
+
}
|
|
8
|
+
function clampInt(min, max, input) {
|
|
9
|
+
return input < min ? min : input > max ? max : input;
|
|
10
|
+
}
|
|
11
|
+
function clampDouble(min, max, input) {
|
|
12
|
+
return input < min ? min : input > max ? max : input;
|
|
13
|
+
}
|
|
14
|
+
function sanitizeDegreesDouble(degrees) {
|
|
15
|
+
return (degrees %= 360) < 0 && (degrees += 360), degrees;
|
|
16
|
+
}
|
|
17
|
+
function rotationDirection(from, to) {
|
|
18
|
+
return sanitizeDegreesDouble(to - from) <= 180 ? 1 : -1;
|
|
19
|
+
}
|
|
20
|
+
function differenceDegrees(a, b) {
|
|
21
|
+
return 180 - Math.abs(Math.abs(a - b) - 180);
|
|
22
|
+
}
|
|
23
|
+
function matrixMultiply(row, matrix) {
|
|
24
|
+
return [row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2], row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2], row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2]];
|
|
25
|
+
}
|
|
26
|
+
var SRGB_TO_XYZ = [[0.41233895, 0.35762064, 0.18051042], [0.2126, 0.7152, 0.0722], [0.01932141, 0.11916382, 0.95034478]];
|
|
27
|
+
var XYZ_TO_SRGB = [[3.2413774792388685, -1.5376652402851851, -0.49885366846268053], [-0.9691452513005321, 1.8758853451067872, 0.04156585616912061], [0.05562093689691305, -0.20395524564742123, 1.0571799111220335]];
|
|
28
|
+
var WHITE_POINT_D65 = [95.047, 100, 108.883];
|
|
29
|
+
function argbFromRgb(red, green, blue) {
|
|
30
|
+
return (255 << 24 | (255 & red) << 16 | (255 & green) << 8 | 255 & blue) >>> 0;
|
|
31
|
+
}
|
|
32
|
+
function argbFromLinrgb(linrgb) {
|
|
33
|
+
return argbFromRgb(delinearized(linrgb[0]), delinearized(linrgb[1]), delinearized(linrgb[2]));
|
|
34
|
+
}
|
|
35
|
+
function redFromArgb(argb) {
|
|
36
|
+
return argb >> 16 & 255;
|
|
37
|
+
}
|
|
38
|
+
function greenFromArgb(argb) {
|
|
39
|
+
return argb >> 8 & 255;
|
|
40
|
+
}
|
|
41
|
+
function blueFromArgb(argb) {
|
|
42
|
+
return 255 & argb;
|
|
43
|
+
}
|
|
44
|
+
function argbFromXyz(x, y, z) {
|
|
45
|
+
const matrix = XYZ_TO_SRGB, linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z, linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z, linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z;
|
|
46
|
+
return argbFromRgb(delinearized(linearR), delinearized(linearG), delinearized(linearB));
|
|
47
|
+
}
|
|
48
|
+
function xyzFromArgb(argb) {
|
|
49
|
+
return matrixMultiply([linearized(redFromArgb(argb)), linearized(greenFromArgb(argb)), linearized(blueFromArgb(argb))], SRGB_TO_XYZ);
|
|
50
|
+
}
|
|
51
|
+
function argbFromLstar(lstar) {
|
|
52
|
+
const component = delinearized(yFromLstar(lstar));
|
|
53
|
+
return argbFromRgb(component, component, component);
|
|
54
|
+
}
|
|
55
|
+
function lstarFromArgb(argb) {
|
|
56
|
+
return 116 * labF(xyzFromArgb(argb)[1] / 100) - 16;
|
|
57
|
+
}
|
|
58
|
+
function yFromLstar(lstar) {
|
|
59
|
+
return 100 * labInvf((lstar + 16) / 116);
|
|
60
|
+
}
|
|
61
|
+
function lstarFromY(y) {
|
|
62
|
+
return 116 * labF(y / 100) - 16;
|
|
63
|
+
}
|
|
64
|
+
function linearized(rgbComponent) {
|
|
65
|
+
const normalized = rgbComponent / 255;
|
|
66
|
+
return normalized <= 0.040449936 ? normalized / 12.92 * 100 : 100 * Math.pow((normalized + 0.055) / 1.055, 2.4);
|
|
67
|
+
}
|
|
68
|
+
function delinearized(rgbComponent) {
|
|
69
|
+
const normalized = rgbComponent / 100;
|
|
70
|
+
let delinearized2 = 0;
|
|
71
|
+
return delinearized2 = normalized <= 31308e-7 ? 12.92 * normalized : 1.055 * Math.pow(normalized, 1 / 2.4) - 0.055, clampInt(0, 255, Math.round(255 * delinearized2));
|
|
72
|
+
}
|
|
73
|
+
function whitePointD65() {
|
|
74
|
+
return WHITE_POINT_D65;
|
|
75
|
+
}
|
|
76
|
+
function labF(t) {
|
|
77
|
+
return t > 216 / 24389 ? Math.pow(t, 1 / 3) : (903.2962962962963 * t + 16) / 116;
|
|
78
|
+
}
|
|
79
|
+
function labInvf(ft) {
|
|
80
|
+
const ft3 = ft * ft * ft;
|
|
81
|
+
return ft3 > 216 / 24389 ? ft3 : (116 * ft - 16) / 903.2962962962963;
|
|
82
|
+
}
|
|
83
|
+
var ViewingConditions = class _ViewingConditions {
|
|
84
|
+
static make(whitePoint, adaptingLuminance, backgroundLstar, surround, discountingIlluminant) {
|
|
85
|
+
if (whitePoint === void 0) {
|
|
86
|
+
whitePoint = whitePointD65();
|
|
87
|
+
}
|
|
88
|
+
if (adaptingLuminance === void 0) {
|
|
89
|
+
adaptingLuminance = 200 / Math.PI * yFromLstar(50) / 100;
|
|
90
|
+
}
|
|
91
|
+
if (backgroundLstar === void 0) {
|
|
92
|
+
backgroundLstar = 50;
|
|
93
|
+
}
|
|
94
|
+
if (surround === void 0) {
|
|
95
|
+
surround = 2;
|
|
96
|
+
}
|
|
97
|
+
if (discountingIlluminant === void 0) {
|
|
98
|
+
discountingIlluminant = false;
|
|
99
|
+
}
|
|
100
|
+
const xyz = whitePoint, rW = 0.401288 * xyz[0] + 0.650173 * xyz[1] + -0.051461 * xyz[2], gW = -0.250268 * xyz[0] + 1.204414 * xyz[1] + 0.045854 * xyz[2], bW = -2079e-6 * xyz[0] + 0.048952 * xyz[1] + 0.953127 * xyz[2], f = 0.8 + surround / 10, c = f >= 0.9 ? lerp(0.59, 0.69, 10 * (f - 0.9)) : lerp(0.525, 0.59, 10 * (f - 0.8));
|
|
101
|
+
let d = discountingIlluminant ? 1 : f * (1 - 1 / 3.6 * Math.exp((-adaptingLuminance - 42) / 92));
|
|
102
|
+
d = d > 1 ? 1 : d < 0 ? 0 : d;
|
|
103
|
+
const nc = f, rgbD = [d * (100 / rW) + 1 - d, d * (100 / gW) + 1 - d, d * (100 / bW) + 1 - d], k = 1 / (5 * adaptingLuminance + 1), k4 = k * k * k * k, k4F = 1 - k4, fl = k4 * adaptingLuminance + 0.1 * k4F * k4F * Math.cbrt(5 * adaptingLuminance), n = yFromLstar(backgroundLstar) / whitePoint[1], z = 1.48 + Math.sqrt(n), nbb = 0.725 / Math.pow(n, 0.2), ncb = nbb, rgbAFactors = [Math.pow(fl * rgbD[0] * rW / 100, 0.42), Math.pow(fl * rgbD[1] * gW / 100, 0.42), Math.pow(fl * rgbD[2] * bW / 100, 0.42)], rgbA = [400 * rgbAFactors[0] / (rgbAFactors[0] + 27.13), 400 * rgbAFactors[1] / (rgbAFactors[1] + 27.13), 400 * rgbAFactors[2] / (rgbAFactors[2] + 27.13)];
|
|
104
|
+
return new _ViewingConditions(n, (2 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]) * nbb, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, 0.25), z);
|
|
105
|
+
}
|
|
106
|
+
constructor(n, aw, nbb, ncb, c, nc, rgbD, fl, fLRoot, z) {
|
|
107
|
+
this.n = n, this.aw = aw, this.nbb = nbb, this.ncb = ncb, this.c = c, this.nc = nc, this.rgbD = rgbD, this.fl = fl, this.fLRoot = fLRoot, this.z = z;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
ViewingConditions.DEFAULT = ViewingConditions.make();
|
|
111
|
+
var Cam16 = class _Cam16 {
|
|
112
|
+
constructor(hue, chroma, j, q, m, s, jstar, astar, bstar) {
|
|
113
|
+
this.hue = hue, this.chroma = chroma, this.j = j, this.q = q, this.m = m, this.s = s, this.jstar = jstar, this.astar = astar, this.bstar = bstar;
|
|
114
|
+
}
|
|
115
|
+
distance(other) {
|
|
116
|
+
const dJ = this.jstar - other.jstar, dA = this.astar - other.astar, dB = this.bstar - other.bstar, dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);
|
|
117
|
+
return 1.41 * Math.pow(dEPrime, 0.63);
|
|
118
|
+
}
|
|
119
|
+
static fromInt(argb) {
|
|
120
|
+
return _Cam16.fromIntInViewingConditions(argb, ViewingConditions.DEFAULT);
|
|
121
|
+
}
|
|
122
|
+
static fromIntInViewingConditions(argb, viewingConditions) {
|
|
123
|
+
const green = (65280 & argb) >> 8, blue = 255 & argb, redL = linearized((16711680 & argb) >> 16), greenL = linearized(green), blueL = linearized(blue), x = 0.41233895 * redL + 0.35762064 * greenL + 0.18051042 * blueL, y = 0.2126 * redL + 0.7152 * greenL + 0.0722 * blueL, z = 0.01932141 * redL + 0.11916382 * greenL + 0.95034478 * blueL, rC = 0.401288 * x + 0.650173 * y - 0.051461 * z, gC = -0.250268 * x + 1.204414 * y + 0.045854 * z, bC = -2079e-6 * x + 0.048952 * y + 0.953127 * z, rD = viewingConditions.rgbD[0] * rC, gD = viewingConditions.rgbD[1] * gC, bD = viewingConditions.rgbD[2] * bC, rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, 0.42), gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, 0.42), bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, 0.42), rA = 400 * signum(rD) * rAF / (rAF + 27.13), gA = 400 * signum(gD) * gAF / (gAF + 27.13), bA = 400 * signum(bD) * bAF / (bAF + 27.13), a = (11 * rA + -12 * gA + bA) / 11, b = (rA + gA - 2 * bA) / 9, u = (20 * rA + 20 * gA + 21 * bA) / 20, p2 = (40 * rA + 20 * gA + bA) / 20, atanDegrees = 180 * Math.atan2(b, a) / Math.PI, hue = atanDegrees < 0 ? atanDegrees + 360 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees, hueRadians = hue * Math.PI / 180, ac = p2 * viewingConditions.nbb, j = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z), q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot, huePrime = hue < 20.14 ? hue + 360 : hue, t = 5e4 / 13 * (0.25 * (Math.cos(huePrime * Math.PI / 180 + 2) + 3.8)) * viewingConditions.nc * viewingConditions.ncb * Math.sqrt(a * a + b * b) / (u + 0.305), alpha = Math.pow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), c = alpha * Math.sqrt(j / 100), m = c * viewingConditions.fLRoot, s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)), jstar = (1 + 100 * 7e-3) * j / (1 + 7e-3 * j), mstar = 1 / 0.0228 * Math.log(1 + 0.0228 * m), astar = mstar * Math.cos(hueRadians), bstar = mstar * Math.sin(hueRadians);
|
|
124
|
+
return new _Cam16(hue, c, j, q, m, s, jstar, astar, bstar);
|
|
125
|
+
}
|
|
126
|
+
static fromJch(j, c, h) {
|
|
127
|
+
return _Cam16.fromJchInViewingConditions(j, c, h, ViewingConditions.DEFAULT);
|
|
128
|
+
}
|
|
129
|
+
static fromJchInViewingConditions(j, c, h, viewingConditions) {
|
|
130
|
+
const q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot, m = c * viewingConditions.fLRoot, alpha = c / Math.sqrt(j / 100), s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)), hueRadians = h * Math.PI / 180, jstar = (1 + 100 * 7e-3) * j / (1 + 7e-3 * j), mstar = 1 / 0.0228 * Math.log(1 + 0.0228 * m), astar = mstar * Math.cos(hueRadians), bstar = mstar * Math.sin(hueRadians);
|
|
131
|
+
return new _Cam16(h, c, j, q, m, s, jstar, astar, bstar);
|
|
132
|
+
}
|
|
133
|
+
static fromUcs(jstar, astar, bstar) {
|
|
134
|
+
return _Cam16.fromUcsInViewingConditions(jstar, astar, bstar, ViewingConditions.DEFAULT);
|
|
135
|
+
}
|
|
136
|
+
static fromUcsInViewingConditions(jstar, astar, bstar, viewingConditions) {
|
|
137
|
+
const a = astar, b = bstar, m = Math.sqrt(a * a + b * b), c = (Math.exp(0.0228 * m) - 1) / 0.0228 / viewingConditions.fLRoot;
|
|
138
|
+
let h = Math.atan2(b, a) * (180 / Math.PI);
|
|
139
|
+
h < 0 && (h += 360);
|
|
140
|
+
const j = jstar / (1 - 7e-3 * (jstar - 100));
|
|
141
|
+
return _Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);
|
|
142
|
+
}
|
|
143
|
+
toInt() {
|
|
144
|
+
return this.viewed(ViewingConditions.DEFAULT);
|
|
145
|
+
}
|
|
146
|
+
viewed(viewingConditions) {
|
|
147
|
+
const alpha = 0 === this.chroma || 0 === this.j ? 0 : this.chroma / Math.sqrt(this.j / 100), t = Math.pow(alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), 1 / 0.9), hRad = this.hue * Math.PI / 180, eHue = 0.25 * (Math.cos(hRad + 2) + 3.8), ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z), p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb, p2 = ac / viewingConditions.nbb, hSin = Math.sin(hRad), hCos = Math.cos(hRad), gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin), a = gamma * hCos, b = gamma * hSin, rA = (460 * p2 + 451 * a + 288 * b) / 1403, gA = (460 * p2 - 891 * a - 261 * b) / 1403, bA = (460 * p2 - 220 * a - 6300 * b) / 1403, rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA))), rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / 0.42), gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA))), gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / 0.42), bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA))), bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / 0.42), rF = rC / viewingConditions.rgbD[0], gF = gC / viewingConditions.rgbD[1], bF = bC / viewingConditions.rgbD[2];
|
|
148
|
+
return argbFromXyz(1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF, 0.38752654 * rF + 0.62144744 * gF - 897398e-8 * bF, -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF);
|
|
149
|
+
}
|
|
150
|
+
static fromXyzInViewingConditions(x, y, z, viewingConditions) {
|
|
151
|
+
const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z, gC = -0.250268 * x + 1.204414 * y + 0.045854 * z, bC = -2079e-6 * x + 0.048952 * y + 0.953127 * z, rD = viewingConditions.rgbD[0] * rC, gD = viewingConditions.rgbD[1] * gC, bD = viewingConditions.rgbD[2] * bC, rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, 0.42), gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, 0.42), bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, 0.42), rA = 400 * signum(rD) * rAF / (rAF + 27.13), gA = 400 * signum(gD) * gAF / (gAF + 27.13), bA = 400 * signum(bD) * bAF / (bAF + 27.13), a = (11 * rA + -12 * gA + bA) / 11, b = (rA + gA - 2 * bA) / 9, u = (20 * rA + 20 * gA + 21 * bA) / 20, p2 = (40 * rA + 20 * gA + bA) / 20, atanDegrees = 180 * Math.atan2(b, a) / Math.PI, hue = atanDegrees < 0 ? atanDegrees + 360 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees, hueRadians = hue * Math.PI / 180, ac = p2 * viewingConditions.nbb, J = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z), Q = 4 / viewingConditions.c * Math.sqrt(J / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot, huePrime = hue < 20.14 ? hue + 360 : hue, t = 5e4 / 13 * (1 / 4 * (Math.cos(huePrime * Math.PI / 180 + 2) + 3.8)) * viewingConditions.nc * viewingConditions.ncb * Math.sqrt(a * a + b * b) / (u + 0.305), alpha = Math.pow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), C = alpha * Math.sqrt(J / 100), M = C * viewingConditions.fLRoot, s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)), jstar = (1 + 100 * 7e-3) * J / (1 + 7e-3 * J), mstar = Math.log(1 + 0.0228 * M) / 0.0228, astar = mstar * Math.cos(hueRadians), bstar = mstar * Math.sin(hueRadians);
|
|
152
|
+
return new _Cam16(hue, C, J, Q, M, s, jstar, astar, bstar);
|
|
153
|
+
}
|
|
154
|
+
xyzInViewingConditions(viewingConditions) {
|
|
155
|
+
const alpha = 0 === this.chroma || 0 === this.j ? 0 : this.chroma / Math.sqrt(this.j / 100), t = Math.pow(alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), 1 / 0.9), hRad = this.hue * Math.PI / 180, eHue = 0.25 * (Math.cos(hRad + 2) + 3.8), ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z), p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb, p2 = ac / viewingConditions.nbb, hSin = Math.sin(hRad), hCos = Math.cos(hRad), gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin), a = gamma * hCos, b = gamma * hSin, rA = (460 * p2 + 451 * a + 288 * b) / 1403, gA = (460 * p2 - 891 * a - 261 * b) / 1403, bA = (460 * p2 - 220 * a - 6300 * b) / 1403, rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA))), rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / 0.42), gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA))), gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / 0.42), bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA))), bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / 0.42), rF = rC / viewingConditions.rgbD[0], gF = gC / viewingConditions.rgbD[1], bF = bC / viewingConditions.rgbD[2];
|
|
156
|
+
return [1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF, 0.38752654 * rF + 0.62144744 * gF - 897398e-8 * bF, -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF];
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var HctSolver = class _HctSolver {
|
|
160
|
+
static sanitizeRadians(angle) {
|
|
161
|
+
return (angle + 8 * Math.PI) % (2 * Math.PI);
|
|
162
|
+
}
|
|
163
|
+
static trueDelinearized(rgbComponent) {
|
|
164
|
+
const normalized = rgbComponent / 100;
|
|
165
|
+
let delinearized2 = 0;
|
|
166
|
+
return delinearized2 = normalized <= 31308e-7 ? 12.92 * normalized : 1.055 * Math.pow(normalized, 1 / 2.4) - 0.055, 255 * delinearized2;
|
|
167
|
+
}
|
|
168
|
+
static chromaticAdaptation(component) {
|
|
169
|
+
const af = Math.pow(Math.abs(component), 0.42);
|
|
170
|
+
return 400 * signum(component) * af / (af + 27.13);
|
|
171
|
+
}
|
|
172
|
+
static hueOf(linrgb) {
|
|
173
|
+
const scaledDiscount = matrixMultiply(linrgb, _HctSolver.SCALED_DISCOUNT_FROM_LINRGB), rA = _HctSolver.chromaticAdaptation(scaledDiscount[0]), gA = _HctSolver.chromaticAdaptation(scaledDiscount[1]), bA = _HctSolver.chromaticAdaptation(scaledDiscount[2]), a = (11 * rA + -12 * gA + bA) / 11, b = (rA + gA - 2 * bA) / 9;
|
|
174
|
+
return Math.atan2(b, a);
|
|
175
|
+
}
|
|
176
|
+
static areInCyclicOrder(a, b, c) {
|
|
177
|
+
return _HctSolver.sanitizeRadians(b - a) < _HctSolver.sanitizeRadians(c - a);
|
|
178
|
+
}
|
|
179
|
+
static intercept(source, mid, target) {
|
|
180
|
+
return (mid - source) / (target - source);
|
|
181
|
+
}
|
|
182
|
+
static lerpPoint(source, t, target) {
|
|
183
|
+
return [source[0] + (target[0] - source[0]) * t, source[1] + (target[1] - source[1]) * t, source[2] + (target[2] - source[2]) * t];
|
|
184
|
+
}
|
|
185
|
+
static setCoordinate(source, coordinate, target, axis) {
|
|
186
|
+
const t = _HctSolver.intercept(source[axis], coordinate, target[axis]);
|
|
187
|
+
return _HctSolver.lerpPoint(source, t, target);
|
|
188
|
+
}
|
|
189
|
+
static isBounded(x) {
|
|
190
|
+
return 0 <= x && x <= 100;
|
|
191
|
+
}
|
|
192
|
+
static nthVertex(y, n) {
|
|
193
|
+
const kR = _HctSolver.Y_FROM_LINRGB[0], kG = _HctSolver.Y_FROM_LINRGB[1], kB = _HctSolver.Y_FROM_LINRGB[2], coordA = n % 4 <= 1 ? 0 : 100, coordB = n % 2 == 0 ? 0 : 100;
|
|
194
|
+
if (n < 4) {
|
|
195
|
+
const g = coordA, b = coordB, r = (y - g * kG - b * kB) / kR;
|
|
196
|
+
return _HctSolver.isBounded(r) ? [r, g, b] : [-1, -1, -1];
|
|
197
|
+
}
|
|
198
|
+
if (n < 8) {
|
|
199
|
+
const b = coordA, r = coordB, g = (y - r * kR - b * kB) / kG;
|
|
200
|
+
return _HctSolver.isBounded(g) ? [r, g, b] : [-1, -1, -1];
|
|
201
|
+
}
|
|
202
|
+
{
|
|
203
|
+
const r = coordA, g = coordB, b = (y - r * kR - g * kG) / kB;
|
|
204
|
+
return _HctSolver.isBounded(b) ? [r, g, b] : [-1, -1, -1];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
static bisectToSegment(y, targetHue) {
|
|
208
|
+
let left = [-1, -1, -1], right = left, leftHue = 0, rightHue = 0, initialized = false, uncut = true;
|
|
209
|
+
for (let n = 0; n < 12; n++) {
|
|
210
|
+
const mid = _HctSolver.nthVertex(y, n);
|
|
211
|
+
if (mid[0] < 0) continue;
|
|
212
|
+
const midHue = _HctSolver.hueOf(mid);
|
|
213
|
+
initialized ? (uncut || _HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) && (uncut = false, _HctSolver.areInCyclicOrder(leftHue, targetHue, midHue) ? (right = mid, rightHue = midHue) : (left = mid, leftHue = midHue)) : (left = mid, right = mid, leftHue = midHue, rightHue = midHue, initialized = true);
|
|
214
|
+
}
|
|
215
|
+
return [left, right];
|
|
216
|
+
}
|
|
217
|
+
static midpoint(a, b) {
|
|
218
|
+
return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
|
|
219
|
+
}
|
|
220
|
+
static criticalPlaneBelow(x) {
|
|
221
|
+
return Math.floor(x - 0.5);
|
|
222
|
+
}
|
|
223
|
+
static criticalPlaneAbove(x) {
|
|
224
|
+
return Math.ceil(x - 0.5);
|
|
225
|
+
}
|
|
226
|
+
static bisectToLimit(y, targetHue) {
|
|
227
|
+
const segment = _HctSolver.bisectToSegment(y, targetHue);
|
|
228
|
+
let left = segment[0], leftHue = _HctSolver.hueOf(left), right = segment[1];
|
|
229
|
+
for (let axis = 0; axis < 3; axis++) if (left[axis] !== right[axis]) {
|
|
230
|
+
let lPlane = -1, rPlane = 255;
|
|
231
|
+
left[axis] < right[axis] ? (lPlane = _HctSolver.criticalPlaneBelow(_HctSolver.trueDelinearized(left[axis])), rPlane = _HctSolver.criticalPlaneAbove(_HctSolver.trueDelinearized(right[axis]))) : (lPlane = _HctSolver.criticalPlaneAbove(_HctSolver.trueDelinearized(left[axis])), rPlane = _HctSolver.criticalPlaneBelow(_HctSolver.trueDelinearized(right[axis])));
|
|
232
|
+
for (let i = 0; i < 8 && !(Math.abs(rPlane - lPlane) <= 1); i++) {
|
|
233
|
+
const mPlane = Math.floor((lPlane + rPlane) / 2), midPlaneCoordinate = _HctSolver.CRITICAL_PLANES[mPlane], mid = _HctSolver.setCoordinate(left, midPlaneCoordinate, right, axis), midHue = _HctSolver.hueOf(mid);
|
|
234
|
+
_HctSolver.areInCyclicOrder(leftHue, targetHue, midHue) ? (right = mid, rPlane = mPlane) : (left = mid, leftHue = midHue, lPlane = mPlane);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return _HctSolver.midpoint(left, right);
|
|
238
|
+
}
|
|
239
|
+
static inverseChromaticAdaptation(adapted) {
|
|
240
|
+
const adaptedAbs = Math.abs(adapted), base = Math.max(0, 27.13 * adaptedAbs / (400 - adaptedAbs));
|
|
241
|
+
return signum(adapted) * Math.pow(base, 1 / 0.42);
|
|
242
|
+
}
|
|
243
|
+
static findResultByJ(hueRadians, chroma, y) {
|
|
244
|
+
let j = 11 * Math.sqrt(y);
|
|
245
|
+
const viewingConditions = ViewingConditions.DEFAULT, tInnerCoeff = 1 / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), p1 = 0.25 * (Math.cos(hueRadians + 2) + 3.8) * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb, hSin = Math.sin(hueRadians), hCos = Math.cos(hueRadians);
|
|
246
|
+
for (let iterationRound = 0; iterationRound < 5; iterationRound++) {
|
|
247
|
+
const jNormalized = j / 100, alpha = 0 === chroma || 0 === j ? 0 : chroma / Math.sqrt(jNormalized), t = Math.pow(alpha * tInnerCoeff, 1 / 0.9), p2 = viewingConditions.aw * Math.pow(jNormalized, 1 / viewingConditions.c / viewingConditions.z) / viewingConditions.nbb, gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin), a = gamma * hCos, b = gamma * hSin, rA = (460 * p2 + 451 * a + 288 * b) / 1403, gA = (460 * p2 - 891 * a - 261 * b) / 1403, bA = (460 * p2 - 220 * a - 6300 * b) / 1403, linrgb = matrixMultiply([_HctSolver.inverseChromaticAdaptation(rA), _HctSolver.inverseChromaticAdaptation(gA), _HctSolver.inverseChromaticAdaptation(bA)], _HctSolver.LINRGB_FROM_SCALED_DISCOUNT);
|
|
248
|
+
if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0) return 0;
|
|
249
|
+
const kR = _HctSolver.Y_FROM_LINRGB[0], kG = _HctSolver.Y_FROM_LINRGB[1], kB = _HctSolver.Y_FROM_LINRGB[2], fnj = kR * linrgb[0] + kG * linrgb[1] + kB * linrgb[2];
|
|
250
|
+
if (fnj <= 0) return 0;
|
|
251
|
+
if (4 === iterationRound || Math.abs(fnj - y) < 2e-3) return linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01 ? 0 : argbFromLinrgb(linrgb);
|
|
252
|
+
j -= (fnj - y) * j / (2 * fnj);
|
|
253
|
+
}
|
|
254
|
+
return 0;
|
|
255
|
+
}
|
|
256
|
+
static solveToInt(hueDegrees, chroma, lstar) {
|
|
257
|
+
if (chroma < 1e-4 || lstar < 1e-4 || lstar > 99.9999) return argbFromLstar(lstar);
|
|
258
|
+
const hueRadians = (hueDegrees = sanitizeDegreesDouble(hueDegrees)) / 180 * Math.PI, y = yFromLstar(lstar), exactAnswer = _HctSolver.findResultByJ(hueRadians, chroma, y);
|
|
259
|
+
if (0 !== exactAnswer) return exactAnswer;
|
|
260
|
+
return argbFromLinrgb(_HctSolver.bisectToLimit(y, hueRadians));
|
|
261
|
+
}
|
|
262
|
+
static solveToCam(hueDegrees, chroma, lstar) {
|
|
263
|
+
return Cam16.fromInt(_HctSolver.solveToInt(hueDegrees, chroma, lstar));
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
HctSolver.SCALED_DISCOUNT_FROM_LINRGB = [[0.001200833568784504, 0.002389694492170889, 2795742885861124e-19], [5891086651375999e-19, 0.0029785502573438758, 3270666104008398e-19], [10146692491640572e-20, 5364214359186694e-19, 0.0032979401770712076]], HctSolver.LINRGB_FROM_SCALED_DISCOUNT = [[1373.2198709594231, -1100.4251190754821, -7.278681089101213], [-271.815969077903, 559.6580465940733, -32.46047482791194], [1.9622899599665666, -57.173814538844006, 308.7233197812385]], HctSolver.Y_FROM_LINRGB = [0.2126, 0.7152, 0.0722], HctSolver.CRITICAL_PLANES = [0.015176349177441876, 0.045529047532325624, 0.07588174588720938, 0.10623444424209313, 0.13658714259697685, 0.16693984095186062, 0.19729253930674434, 0.2276452376616281, 0.2579979360165119, 0.28835063437139563, 0.3188300904430532, 0.350925934958123, 0.3848314933096426, 0.42057480301049466, 0.458183274052838, 0.4976837250274023, 0.5391024159806381, 0.5824650784040898, 0.6277969426914107, 0.6751227633498623, 0.7244668422128921, 0.775853049866786, 0.829304845476233, 0.8848452951698498, 0.942497089126609, 1.0022825574869039, 1.0642236851973577, 1.1283421258858297, 1.1946592148522128, 1.2631959812511864, 1.3339731595349034, 1.407011200216447, 1.4823302800086415, 1.5599503113873272, 1.6398909516233677, 1.7221716113234105, 1.8068114625156377, 1.8938294463134073, 1.9832442801866852, 2.075074464868551, 2.1693382909216234, 2.2660538449872063, 2.36523901573795, 2.4669114995532007, 2.5710888059345764, 2.6777882626779785, 2.7870270208169257, 2.898822059350997, 3.0131901897720907, 3.1301480604002863, 3.2497121605402226, 3.3718988244681087, 3.4967242352587946, 3.624204428461639, 3.754355295633311, 3.887192587735158, 4.022731918402185, 4.160988767090289, 4.301978482107941, 4.445716283538092, 4.592217266055746, 4.741496401646282, 4.893568542229298, 5.048448422192488, 5.20615066083972, 5.3666897647573375, 5.5300801301023865, 5.696336044816294, 5.865471690767354, 6.037501145825082, 6.212438385869475, 6.390297286737924, 6.571091626112461, 6.7548350853498045, 6.941541251256611, 7.131223617812143, 7.323895587840543, 7.5195704746346665, 7.7182615035334345, 7.919981813454504, 8.124744458384042, 8.332562408825165, 8.543448553206703, 8.757415699253682, 8.974476575321063, 9.194643831691977, 9.417930041841839, 9.644347703669503, 9.873909240696694, 10.106627003236781, 10.342513269534024, 10.58158024687427, 10.8238400726681, 11.069304815507364, 11.317986476196008, 11.569896988756009, 11.825048221409341, 12.083451977536606, 12.345119996613247, 12.610063955123938, 12.878295467455942, 13.149826086772048, 13.42466730586372, 13.702830557985108, 13.984327217668513, 14.269168601521828, 14.55736596900856, 14.848930523210871, 15.143873411576273, 15.44220572664832, 15.743938506781891, 16.04908273684337, 16.35764934889634, 16.66964922287304, 16.985093187232053, 17.30399201960269, 17.62635644741625, 17.95219714852476, 18.281524751807332, 18.614349837764564, 18.95068293910138, 19.290534541298456, 19.633915083172692, 19.98083495742689, 20.331304511189067, 20.685334046541502, 21.042933821039977, 21.404114048223256, 21.76888489811322, 22.137256497705877, 22.50923893145328, 22.884842241736916, 23.264076429332462, 23.6469514538663, 24.033477234264016, 24.42366364919083, 24.817520537484558, 25.21505769858089, 25.61628489293138, 26.021211842414342, 26.429848230738664, 26.842203703840827, 27.258287870275353, 27.678110301598522, 28.10168053274597, 28.529008062403893, 28.96010235337422, 29.39497283293396, 29.83362889318845, 30.276079891419332, 30.722335150426627, 31.172403958865512, 31.62629557157785, 32.08401920991837, 32.54558406207592, 33.010999283389665, 33.4802739966603, 33.953417292456834, 34.430438229418264, 34.911345834551085, 35.39614910352207, 35.88485700094671, 36.37747846067349, 36.87402238606382, 37.37449765026789, 37.87891309649659, 38.38727753828926, 38.89959975977785, 39.41588851594697, 39.93615253289054, 40.460400508064545, 40.98864111053629, 41.520882981230194, 42.05713473317016, 42.597404951718396, 43.141702194811224, 43.6900349931913, 44.24241185063697, 44.798841244188324, 45.35933162437017, 45.92389141541209, 46.49252901546552, 47.065252796817916, 47.64207110610409, 48.22299226451468, 48.808024568002054, 49.3971762874833, 49.9904556690408, 50.587870934119984, 51.189430279724725, 51.79514187861014, 52.40501387947288, 53.0190544071392, 53.637271562750364, 54.259673423945976, 54.88626804504493, 55.517063457223934, 56.15206766869424, 56.79128866487574, 57.43473440856916, 58.08241284012621, 58.734331877617365, 59.39049941699807, 60.05092333227251, 60.715611475655585, 61.38457167773311, 62.057811747619894, 62.7353394731159, 63.417162620860914, 64.10328893648692, 64.79372614476921, 65.48848194977529, 66.18756403501224, 66.89098006357258, 67.59873767827808, 68.31084450182222, 69.02730813691093, 69.74813616640164, 70.47333615344107, 71.20291564160104, 71.93688215501312, 72.67524319850172, 73.41800625771542, 74.16517879925733, 74.9167682708136, 75.67278210128072, 76.43322770089146, 77.1981124613393, 77.96744375590167, 78.74122893956174, 79.51947534912904, 80.30219030335869, 81.08938110306934, 81.88105503125999, 82.67721935322541, 83.4778813166706, 84.28304815182372, 85.09272707154808, 85.90692527145302, 86.72564993000343, 87.54890820862819, 88.3767072518277, 89.2090541872801, 90.04595612594655, 90.88742016217518, 91.73345337380438, 92.58406282226491, 93.43925555268066, 94.29903859396902, 95.16341895893969, 96.03240364439274, 96.9059996312159, 97.78421388448044, 98.6670533535366, 99.55452497210776];
|
|
267
|
+
var Hct = class _Hct {
|
|
268
|
+
static from(hue, chroma, tone) {
|
|
269
|
+
return new _Hct(HctSolver.solveToInt(hue, chroma, tone));
|
|
270
|
+
}
|
|
271
|
+
static fromInt(argb) {
|
|
272
|
+
return new _Hct(argb);
|
|
273
|
+
}
|
|
274
|
+
toInt() {
|
|
275
|
+
return this.argb;
|
|
276
|
+
}
|
|
277
|
+
get hue() {
|
|
278
|
+
return this.internalHue;
|
|
279
|
+
}
|
|
280
|
+
set hue(newHue) {
|
|
281
|
+
this.setInternalState(HctSolver.solveToInt(newHue, this.internalChroma, this.internalTone));
|
|
282
|
+
}
|
|
283
|
+
get chroma() {
|
|
284
|
+
return this.internalChroma;
|
|
285
|
+
}
|
|
286
|
+
set chroma(newChroma) {
|
|
287
|
+
this.setInternalState(HctSolver.solveToInt(this.internalHue, newChroma, this.internalTone));
|
|
288
|
+
}
|
|
289
|
+
get tone() {
|
|
290
|
+
return this.internalTone;
|
|
291
|
+
}
|
|
292
|
+
set tone(newTone) {
|
|
293
|
+
this.setInternalState(HctSolver.solveToInt(this.internalHue, this.internalChroma, newTone));
|
|
294
|
+
}
|
|
295
|
+
constructor(argb) {
|
|
296
|
+
this.argb = argb;
|
|
297
|
+
const cam = Cam16.fromInt(argb);
|
|
298
|
+
this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
|
|
299
|
+
}
|
|
300
|
+
setInternalState(argb) {
|
|
301
|
+
const cam = Cam16.fromInt(argb);
|
|
302
|
+
this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
|
|
303
|
+
}
|
|
304
|
+
inViewingConditions(vc) {
|
|
305
|
+
const viewedInVc = Cam16.fromInt(this.toInt()).xyzInViewingConditions(vc), recastInVc = Cam16.fromXyzInViewingConditions(viewedInVc[0], viewedInVc[1], viewedInVc[2], ViewingConditions.make());
|
|
306
|
+
return _Hct.from(recastInVc.hue, recastInVc.chroma, lstarFromY(viewedInVc[1]));
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
var Blend = class _Blend {
|
|
310
|
+
static harmonize(designColor, sourceColor) {
|
|
311
|
+
const fromHct = Hct.fromInt(designColor), toHct = Hct.fromInt(sourceColor), differenceDegrees$1 = differenceDegrees(fromHct.hue, toHct.hue), rotationDegrees = Math.min(0.5 * differenceDegrees$1, 15), outputHue = sanitizeDegreesDouble(fromHct.hue + rotationDegrees * rotationDirection(fromHct.hue, toHct.hue));
|
|
312
|
+
return Hct.from(outputHue, fromHct.chroma, fromHct.tone).toInt();
|
|
313
|
+
}
|
|
314
|
+
static hctHue(from, to, amount) {
|
|
315
|
+
const ucs = _Blend.cam16Ucs(from, to, amount), ucsCam = Cam16.fromInt(ucs), fromCam = Cam16.fromInt(from);
|
|
316
|
+
return Hct.from(ucsCam.hue, fromCam.chroma, lstarFromArgb(from)).toInt();
|
|
317
|
+
}
|
|
318
|
+
static cam16Ucs(from, to, amount) {
|
|
319
|
+
const fromCam = Cam16.fromInt(from), toCam = Cam16.fromInt(to), fromJ = fromCam.jstar, fromA = fromCam.astar, fromB = fromCam.bstar, jstar = fromJ + (toCam.jstar - fromJ) * amount, astar = fromA + (toCam.astar - fromA) * amount, bstar = fromB + (toCam.bstar - fromB) * amount;
|
|
320
|
+
return Cam16.fromUcs(jstar, astar, bstar).toInt();
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
var Contrast = class _Contrast {
|
|
324
|
+
static ratioOfTones(toneA, toneB) {
|
|
325
|
+
return toneA = clampDouble(0, 100, toneA), toneB = clampDouble(0, 100, toneB), _Contrast.ratioOfYs(yFromLstar(toneA), yFromLstar(toneB));
|
|
326
|
+
}
|
|
327
|
+
static ratioOfYs(y1, y2) {
|
|
328
|
+
const lighter = y1 > y2 ? y1 : y2;
|
|
329
|
+
return (lighter + 5) / ((lighter === y2 ? y1 : y2) + 5);
|
|
330
|
+
}
|
|
331
|
+
static lighter(tone, ratio) {
|
|
332
|
+
if (tone < 0 || tone > 100) return -1;
|
|
333
|
+
const darkY = yFromLstar(tone), lightY = ratio * (darkY + 5) - 5, realContrast = _Contrast.ratioOfYs(lightY, darkY), delta = Math.abs(realContrast - ratio);
|
|
334
|
+
if (realContrast < ratio && delta > 0.04) return -1;
|
|
335
|
+
const returnValue = lstarFromY(lightY) + 0.4;
|
|
336
|
+
return returnValue < 0 || returnValue > 100 ? -1 : returnValue;
|
|
337
|
+
}
|
|
338
|
+
static darker(tone, ratio) {
|
|
339
|
+
if (tone < 0 || tone > 100) return -1;
|
|
340
|
+
const lightY = yFromLstar(tone), darkY = (lightY + 5) / ratio - 5, realContrast = _Contrast.ratioOfYs(lightY, darkY), delta = Math.abs(realContrast - ratio);
|
|
341
|
+
if (realContrast < ratio && delta > 0.04) return -1;
|
|
342
|
+
const returnValue = lstarFromY(darkY) - 0.4;
|
|
343
|
+
return returnValue < 0 || returnValue > 100 ? -1 : returnValue;
|
|
344
|
+
}
|
|
345
|
+
static lighterUnsafe(tone, ratio) {
|
|
346
|
+
const lighterSafe = _Contrast.lighter(tone, ratio);
|
|
347
|
+
return lighterSafe < 0 ? 100 : lighterSafe;
|
|
348
|
+
}
|
|
349
|
+
static darkerUnsafe(tone, ratio) {
|
|
350
|
+
const darkerSafe = _Contrast.darker(tone, ratio);
|
|
351
|
+
return darkerSafe < 0 ? 0 : darkerSafe;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var DislikeAnalyzer = class _DislikeAnalyzer {
|
|
355
|
+
static isDisliked(hct) {
|
|
356
|
+
const huePasses = Math.round(hct.hue) >= 90 && Math.round(hct.hue) <= 111, chromaPasses = Math.round(hct.chroma) > 16, tonePasses = Math.round(hct.tone) < 65;
|
|
357
|
+
return huePasses && chromaPasses && tonePasses;
|
|
358
|
+
}
|
|
359
|
+
static fixIfDisliked(hct) {
|
|
360
|
+
return _DislikeAnalyzer.isDisliked(hct) ? Hct.from(hct.hue, hct.chroma, 70) : hct;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
var DynamicColor = class _DynamicColor {
|
|
364
|
+
static fromPalette(args) {
|
|
365
|
+
return new _DynamicColor(args.name ?? "", args.palette, args.tone, args.isBackground ?? false, args.background, args.secondBackground, args.contrastCurve, args.toneDeltaPair);
|
|
366
|
+
}
|
|
367
|
+
constructor(name, palette, tone, isBackground, background, secondBackground, contrastCurve, toneDeltaPair) {
|
|
368
|
+
if (this.name = name, this.palette = palette, this.tone = tone, this.isBackground = isBackground, this.background = background, this.secondBackground = secondBackground, this.contrastCurve = contrastCurve, this.toneDeltaPair = toneDeltaPair, this.hctCache = /* @__PURE__ */ new Map(), !background && secondBackground) throw new Error(`Color ${name} has secondBackgrounddefined, but background is not defined.`);
|
|
369
|
+
if (!background && contrastCurve) throw new Error(`Color ${name} has contrastCurvedefined, but background is not defined.`);
|
|
370
|
+
if (background && !contrastCurve) throw new Error(`Color ${name} has backgrounddefined, but contrastCurve is not defined.`);
|
|
371
|
+
}
|
|
372
|
+
getArgb(scheme) {
|
|
373
|
+
return this.getHct(scheme).toInt();
|
|
374
|
+
}
|
|
375
|
+
getHct(scheme) {
|
|
376
|
+
const cachedAnswer = this.hctCache.get(scheme);
|
|
377
|
+
if (null != cachedAnswer) return cachedAnswer;
|
|
378
|
+
const tone = this.getTone(scheme), answer = this.palette(scheme).getHct(tone);
|
|
379
|
+
return this.hctCache.size > 4 && this.hctCache.clear(), this.hctCache.set(scheme, answer), answer;
|
|
380
|
+
}
|
|
381
|
+
getTone(scheme) {
|
|
382
|
+
const decreasingContrast = scheme.contrastLevel < 0;
|
|
383
|
+
if (this.toneDeltaPair) {
|
|
384
|
+
const toneDeltaPair = this.toneDeltaPair(scheme), roleA = toneDeltaPair.roleA, roleB = toneDeltaPair.roleB, delta = toneDeltaPair.delta, polarity = toneDeltaPair.polarity, stayTogether = toneDeltaPair.stayTogether, bgTone = this.background(scheme).getTone(scheme), aIsNearer = "nearer" === polarity || "lighter" === polarity && !scheme.isDark || "darker" === polarity && scheme.isDark, nearer = aIsNearer ? roleA : roleB, farther = aIsNearer ? roleB : roleA, amNearer = this.name === nearer.name, expansionDir = scheme.isDark ? 1 : -1, nContrast = nearer.contrastCurve.getContrast(scheme.contrastLevel), fContrast = farther.contrastCurve.getContrast(scheme.contrastLevel), nInitialTone = nearer.tone(scheme);
|
|
385
|
+
let nTone = Contrast.ratioOfTones(bgTone, nInitialTone) >= nContrast ? nInitialTone : _DynamicColor.foregroundTone(bgTone, nContrast);
|
|
386
|
+
const fInitialTone = farther.tone(scheme);
|
|
387
|
+
let fTone = Contrast.ratioOfTones(bgTone, fInitialTone) >= fContrast ? fInitialTone : _DynamicColor.foregroundTone(bgTone, fContrast);
|
|
388
|
+
return decreasingContrast && (nTone = _DynamicColor.foregroundTone(bgTone, nContrast), fTone = _DynamicColor.foregroundTone(bgTone, fContrast)), (fTone - nTone) * expansionDir >= delta || (fTone = clampDouble(0, 100, nTone + delta * expansionDir), (fTone - nTone) * expansionDir >= delta || (nTone = clampDouble(0, 100, fTone - delta * expansionDir))), 50 <= nTone && nTone < 60 ? expansionDir > 0 ? (nTone = 60, fTone = Math.max(fTone, nTone + delta * expansionDir)) : (nTone = 49, fTone = Math.min(fTone, nTone + delta * expansionDir)) : 50 <= fTone && fTone < 60 && (stayTogether ? expansionDir > 0 ? (nTone = 60, fTone = Math.max(fTone, nTone + delta * expansionDir)) : (nTone = 49, fTone = Math.min(fTone, nTone + delta * expansionDir)) : fTone = expansionDir > 0 ? 60 : 49), amNearer ? nTone : fTone;
|
|
389
|
+
}
|
|
390
|
+
{
|
|
391
|
+
let answer = this.tone(scheme);
|
|
392
|
+
if (null == this.background) return answer;
|
|
393
|
+
const bgTone = this.background(scheme).getTone(scheme), desiredRatio = this.contrastCurve.getContrast(scheme.contrastLevel);
|
|
394
|
+
if (Contrast.ratioOfTones(bgTone, answer) >= desiredRatio || (answer = _DynamicColor.foregroundTone(bgTone, desiredRatio)), decreasingContrast && (answer = _DynamicColor.foregroundTone(bgTone, desiredRatio)), this.isBackground && 50 <= answer && answer < 60 && (answer = Contrast.ratioOfTones(49, bgTone) >= desiredRatio ? 49 : 60), this.secondBackground) {
|
|
395
|
+
const [bg1, bg2] = [this.background, this.secondBackground], [bgTone1, bgTone2] = [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)], [upper, lower] = [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)];
|
|
396
|
+
if (Contrast.ratioOfTones(upper, answer) >= desiredRatio && Contrast.ratioOfTones(lower, answer) >= desiredRatio) return answer;
|
|
397
|
+
const lightOption = Contrast.lighter(upper, desiredRatio), darkOption = Contrast.darker(lower, desiredRatio), availables = [];
|
|
398
|
+
-1 !== lightOption && availables.push(lightOption), -1 !== darkOption && availables.push(darkOption);
|
|
399
|
+
return _DynamicColor.tonePrefersLightForeground(bgTone1) || _DynamicColor.tonePrefersLightForeground(bgTone2) ? lightOption < 0 ? 100 : lightOption : 1 === availables.length ? availables[0] : darkOption < 0 ? 0 : darkOption;
|
|
400
|
+
}
|
|
401
|
+
return answer;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
static foregroundTone(bgTone, ratio) {
|
|
405
|
+
const lighterTone = Contrast.lighterUnsafe(bgTone, ratio), darkerTone = Contrast.darkerUnsafe(bgTone, ratio), lighterRatio = Contrast.ratioOfTones(lighterTone, bgTone), darkerRatio = Contrast.ratioOfTones(darkerTone, bgTone);
|
|
406
|
+
if (_DynamicColor.tonePrefersLightForeground(bgTone)) {
|
|
407
|
+
const negligibleDifference = Math.abs(lighterRatio - darkerRatio) < 0.1 && lighterRatio < ratio && darkerRatio < ratio;
|
|
408
|
+
return lighterRatio >= ratio || lighterRatio >= darkerRatio || negligibleDifference ? lighterTone : darkerTone;
|
|
409
|
+
}
|
|
410
|
+
return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone : lighterTone;
|
|
411
|
+
}
|
|
412
|
+
static tonePrefersLightForeground(tone) {
|
|
413
|
+
return Math.round(tone) < 60;
|
|
414
|
+
}
|
|
415
|
+
static toneAllowsLightForeground(tone) {
|
|
416
|
+
return Math.round(tone) <= 49;
|
|
417
|
+
}
|
|
418
|
+
static enableLightForeground(tone) {
|
|
419
|
+
return _DynamicColor.tonePrefersLightForeground(tone) && !_DynamicColor.toneAllowsLightForeground(tone) ? 49 : tone;
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
var Variant;
|
|
423
|
+
!function(Variant2) {
|
|
424
|
+
Variant2[Variant2.MONOCHROME = 0] = "MONOCHROME", Variant2[Variant2.NEUTRAL = 1] = "NEUTRAL", Variant2[Variant2.TONAL_SPOT = 2] = "TONAL_SPOT", Variant2[Variant2.VIBRANT = 3] = "VIBRANT", Variant2[Variant2.EXPRESSIVE = 4] = "EXPRESSIVE", Variant2[Variant2.FIDELITY = 5] = "FIDELITY", Variant2[Variant2.CONTENT = 6] = "CONTENT", Variant2[Variant2.RAINBOW = 7] = "RAINBOW", Variant2[Variant2.FRUIT_SALAD = 8] = "FRUIT_SALAD";
|
|
425
|
+
}(Variant || (Variant = {}));
|
|
426
|
+
var ContrastCurve = class {
|
|
427
|
+
constructor(low, normal, medium, high) {
|
|
428
|
+
this.low = low, this.normal = normal, this.medium = medium, this.high = high;
|
|
429
|
+
}
|
|
430
|
+
getContrast(contrastLevel) {
|
|
431
|
+
return contrastLevel <= -1 ? this.low : contrastLevel < 0 ? lerp(this.low, this.normal, (contrastLevel - -1) / 1) : contrastLevel < 0.5 ? lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5) : contrastLevel < 1 ? lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5) : this.high;
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
var ToneDeltaPair = class {
|
|
435
|
+
constructor(roleA, roleB, delta, polarity, stayTogether) {
|
|
436
|
+
this.roleA = roleA, this.roleB = roleB, this.delta = delta, this.polarity = polarity, this.stayTogether = stayTogether;
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
function isFidelity(scheme) {
|
|
440
|
+
return scheme.variant === Variant.FIDELITY || scheme.variant === Variant.CONTENT;
|
|
441
|
+
}
|
|
442
|
+
function isMonochrome(scheme) {
|
|
443
|
+
return scheme.variant === Variant.MONOCHROME;
|
|
444
|
+
}
|
|
445
|
+
function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
|
|
446
|
+
let answer = tone, closestToChroma = Hct.from(hue, chroma, tone);
|
|
447
|
+
if (closestToChroma.chroma < chroma) {
|
|
448
|
+
let chromaPeak = closestToChroma.chroma;
|
|
449
|
+
for (; closestToChroma.chroma < chroma; ) {
|
|
450
|
+
answer += byDecreasingTone ? -1 : 1;
|
|
451
|
+
const potentialSolution = Hct.from(hue, chroma, answer);
|
|
452
|
+
if (chromaPeak > potentialSolution.chroma) break;
|
|
453
|
+
if (Math.abs(potentialSolution.chroma - chroma) < 0.4) break;
|
|
454
|
+
Math.abs(potentialSolution.chroma - chroma) < Math.abs(closestToChroma.chroma - chroma) && (closestToChroma = potentialSolution), chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return answer;
|
|
458
|
+
}
|
|
459
|
+
function viewingConditionsForAlbers(scheme) {
|
|
460
|
+
return ViewingConditions.make(void 0, void 0, scheme.isDark ? 30 : 80, void 0, void 0);
|
|
461
|
+
}
|
|
462
|
+
function performAlbers(prealbers, scheme) {
|
|
463
|
+
const albersd = prealbers.inViewingConditions(viewingConditionsForAlbers(scheme));
|
|
464
|
+
return DynamicColor.tonePrefersLightForeground(prealbers.tone) && !DynamicColor.toneAllowsLightForeground(albersd.tone) ? DynamicColor.enableLightForeground(prealbers.tone) : DynamicColor.enableLightForeground(albersd.tone);
|
|
465
|
+
}
|
|
466
|
+
var MaterialDynamicColors = class _MaterialDynamicColors {
|
|
467
|
+
static highestSurface(s) {
|
|
468
|
+
return s.isDark ? _MaterialDynamicColors.surfaceBright : _MaterialDynamicColors.surfaceDim;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
MaterialDynamicColors.contentAccentToneDelta = 15, MaterialDynamicColors.primaryPaletteKeyColor = DynamicColor.fromPalette({
|
|
472
|
+
name: "primary_palette_key_color",
|
|
473
|
+
palette: (s) => s.primaryPalette,
|
|
474
|
+
tone: (s) => s.primaryPalette.keyColor.tone
|
|
475
|
+
}), MaterialDynamicColors.secondaryPaletteKeyColor = DynamicColor.fromPalette({
|
|
476
|
+
name: "secondary_palette_key_color",
|
|
477
|
+
palette: (s) => s.secondaryPalette,
|
|
478
|
+
tone: (s) => s.secondaryPalette.keyColor.tone
|
|
479
|
+
}), MaterialDynamicColors.tertiaryPaletteKeyColor = DynamicColor.fromPalette({
|
|
480
|
+
name: "tertiary_palette_key_color",
|
|
481
|
+
palette: (s) => s.tertiaryPalette,
|
|
482
|
+
tone: (s) => s.tertiaryPalette.keyColor.tone
|
|
483
|
+
}), MaterialDynamicColors.neutralPaletteKeyColor = DynamicColor.fromPalette({
|
|
484
|
+
name: "neutral_palette_key_color",
|
|
485
|
+
palette: (s) => s.neutralPalette,
|
|
486
|
+
tone: (s) => s.neutralPalette.keyColor.tone
|
|
487
|
+
}), MaterialDynamicColors.neutralVariantPaletteKeyColor = DynamicColor.fromPalette({
|
|
488
|
+
name: "neutral_variant_palette_key_color",
|
|
489
|
+
palette: (s) => s.neutralVariantPalette,
|
|
490
|
+
tone: (s) => s.neutralVariantPalette.keyColor.tone
|
|
491
|
+
}), MaterialDynamicColors.background = DynamicColor.fromPalette({
|
|
492
|
+
name: "background",
|
|
493
|
+
palette: (s) => s.neutralPalette,
|
|
494
|
+
tone: (s) => s.isDark ? 6 : 98,
|
|
495
|
+
isBackground: true
|
|
496
|
+
}), MaterialDynamicColors.onBackground = DynamicColor.fromPalette({
|
|
497
|
+
name: "on_background",
|
|
498
|
+
palette: (s) => s.neutralPalette,
|
|
499
|
+
tone: (s) => s.isDark ? 90 : 10,
|
|
500
|
+
background: (s) => MaterialDynamicColors.background,
|
|
501
|
+
contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
|
|
502
|
+
}), MaterialDynamicColors.surface = DynamicColor.fromPalette({
|
|
503
|
+
name: "surface",
|
|
504
|
+
palette: (s) => s.neutralPalette,
|
|
505
|
+
tone: (s) => s.isDark ? 6 : 98,
|
|
506
|
+
isBackground: true
|
|
507
|
+
}), MaterialDynamicColors.surfaceDim = DynamicColor.fromPalette({
|
|
508
|
+
name: "surface_dim",
|
|
509
|
+
palette: (s) => s.neutralPalette,
|
|
510
|
+
tone: (s) => s.isDark ? 6 : 87,
|
|
511
|
+
isBackground: true
|
|
512
|
+
}), MaterialDynamicColors.surfaceBright = DynamicColor.fromPalette({
|
|
513
|
+
name: "surface_bright",
|
|
514
|
+
palette: (s) => s.neutralPalette,
|
|
515
|
+
tone: (s) => s.isDark ? 24 : 98,
|
|
516
|
+
isBackground: true
|
|
517
|
+
}), MaterialDynamicColors.surfaceContainerLowest = DynamicColor.fromPalette({
|
|
518
|
+
name: "surface_container_lowest",
|
|
519
|
+
palette: (s) => s.neutralPalette,
|
|
520
|
+
tone: (s) => s.isDark ? 4 : 100,
|
|
521
|
+
isBackground: true
|
|
522
|
+
}), MaterialDynamicColors.surfaceContainerLow = DynamicColor.fromPalette({
|
|
523
|
+
name: "surface_container_low",
|
|
524
|
+
palette: (s) => s.neutralPalette,
|
|
525
|
+
tone: (s) => s.isDark ? 10 : 96,
|
|
526
|
+
isBackground: true
|
|
527
|
+
}), MaterialDynamicColors.surfaceContainer = DynamicColor.fromPalette({
|
|
528
|
+
name: "surface_container",
|
|
529
|
+
palette: (s) => s.neutralPalette,
|
|
530
|
+
tone: (s) => s.isDark ? 12 : 94,
|
|
531
|
+
isBackground: true
|
|
532
|
+
}), MaterialDynamicColors.surfaceContainerHigh = DynamicColor.fromPalette({
|
|
533
|
+
name: "surface_container_high",
|
|
534
|
+
palette: (s) => s.neutralPalette,
|
|
535
|
+
tone: (s) => s.isDark ? 17 : 92,
|
|
536
|
+
isBackground: true
|
|
537
|
+
}), MaterialDynamicColors.surfaceContainerHighest = DynamicColor.fromPalette({
|
|
538
|
+
name: "surface_container_highest",
|
|
539
|
+
palette: (s) => s.neutralPalette,
|
|
540
|
+
tone: (s) => s.isDark ? 22 : 90,
|
|
541
|
+
isBackground: true
|
|
542
|
+
}), MaterialDynamicColors.onSurface = DynamicColor.fromPalette({
|
|
543
|
+
name: "on_surface",
|
|
544
|
+
palette: (s) => s.neutralPalette,
|
|
545
|
+
tone: (s) => s.isDark ? 90 : 10,
|
|
546
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
547
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
548
|
+
}), MaterialDynamicColors.surfaceVariant = DynamicColor.fromPalette({
|
|
549
|
+
name: "surface_variant",
|
|
550
|
+
palette: (s) => s.neutralVariantPalette,
|
|
551
|
+
tone: (s) => s.isDark ? 30 : 90,
|
|
552
|
+
isBackground: true
|
|
553
|
+
}), MaterialDynamicColors.onSurfaceVariant = DynamicColor.fromPalette({
|
|
554
|
+
name: "on_surface_variant",
|
|
555
|
+
palette: (s) => s.neutralVariantPalette,
|
|
556
|
+
tone: (s) => s.isDark ? 80 : 30,
|
|
557
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
558
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
559
|
+
}), MaterialDynamicColors.inverseSurface = DynamicColor.fromPalette({
|
|
560
|
+
name: "inverse_surface",
|
|
561
|
+
palette: (s) => s.neutralPalette,
|
|
562
|
+
tone: (s) => s.isDark ? 90 : 20
|
|
563
|
+
}), MaterialDynamicColors.inverseOnSurface = DynamicColor.fromPalette({
|
|
564
|
+
name: "inverse_on_surface",
|
|
565
|
+
palette: (s) => s.neutralPalette,
|
|
566
|
+
tone: (s) => s.isDark ? 20 : 95,
|
|
567
|
+
background: (s) => MaterialDynamicColors.inverseSurface,
|
|
568
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
569
|
+
}), MaterialDynamicColors.outline = DynamicColor.fromPalette({
|
|
570
|
+
name: "outline",
|
|
571
|
+
palette: (s) => s.neutralVariantPalette,
|
|
572
|
+
tone: (s) => s.isDark ? 60 : 50,
|
|
573
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
574
|
+
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
|
|
575
|
+
}), MaterialDynamicColors.outlineVariant = DynamicColor.fromPalette({
|
|
576
|
+
name: "outline_variant",
|
|
577
|
+
palette: (s) => s.neutralVariantPalette,
|
|
578
|
+
tone: (s) => s.isDark ? 30 : 80,
|
|
579
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
580
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7)
|
|
581
|
+
}), MaterialDynamicColors.shadow = DynamicColor.fromPalette({
|
|
582
|
+
name: "shadow",
|
|
583
|
+
palette: (s) => s.neutralPalette,
|
|
584
|
+
tone: (s) => 0
|
|
585
|
+
}), MaterialDynamicColors.scrim = DynamicColor.fromPalette({
|
|
586
|
+
name: "scrim",
|
|
587
|
+
palette: (s) => s.neutralPalette,
|
|
588
|
+
tone: (s) => 0
|
|
589
|
+
}), MaterialDynamicColors.surfaceTint = DynamicColor.fromPalette({
|
|
590
|
+
name: "surface_tint",
|
|
591
|
+
palette: (s) => s.primaryPalette,
|
|
592
|
+
tone: (s) => s.isDark ? 80 : 40,
|
|
593
|
+
isBackground: true
|
|
594
|
+
}), MaterialDynamicColors.primary = DynamicColor.fromPalette({
|
|
595
|
+
name: "primary",
|
|
596
|
+
palette: (s) => s.primaryPalette,
|
|
597
|
+
tone: (s) => isMonochrome(s) ? s.isDark ? 100 : 0 : s.isDark ? 80 : 40,
|
|
598
|
+
isBackground: true,
|
|
599
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
600
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
601
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 15, "nearer", false)
|
|
602
|
+
}), MaterialDynamicColors.onPrimary = DynamicColor.fromPalette({
|
|
603
|
+
name: "on_primary",
|
|
604
|
+
palette: (s) => s.primaryPalette,
|
|
605
|
+
tone: (s) => isMonochrome(s) ? s.isDark ? 10 : 90 : s.isDark ? 20 : 100,
|
|
606
|
+
background: (s) => MaterialDynamicColors.primary,
|
|
607
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
608
|
+
}), MaterialDynamicColors.primaryContainer = DynamicColor.fromPalette({
|
|
609
|
+
name: "primary_container",
|
|
610
|
+
palette: (s) => s.primaryPalette,
|
|
611
|
+
tone: (s) => isFidelity(s) ? performAlbers(s.sourceColorHct, s) : isMonochrome(s) ? s.isDark ? 85 : 25 : s.isDark ? 30 : 90,
|
|
612
|
+
isBackground: true,
|
|
613
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
614
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
615
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 15, "nearer", false)
|
|
616
|
+
}), MaterialDynamicColors.onPrimaryContainer = DynamicColor.fromPalette({
|
|
617
|
+
name: "on_primary_container",
|
|
618
|
+
palette: (s) => s.primaryPalette,
|
|
619
|
+
tone: (s) => isFidelity(s) ? DynamicColor.foregroundTone(MaterialDynamicColors.primaryContainer.tone(s), 4.5) : isMonochrome(s) ? s.isDark ? 0 : 100 : s.isDark ? 90 : 10,
|
|
620
|
+
background: (s) => MaterialDynamicColors.primaryContainer,
|
|
621
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
622
|
+
}), MaterialDynamicColors.inversePrimary = DynamicColor.fromPalette({
|
|
623
|
+
name: "inverse_primary",
|
|
624
|
+
palette: (s) => s.primaryPalette,
|
|
625
|
+
tone: (s) => s.isDark ? 40 : 80,
|
|
626
|
+
background: (s) => MaterialDynamicColors.inverseSurface,
|
|
627
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
628
|
+
}), MaterialDynamicColors.secondary = DynamicColor.fromPalette({
|
|
629
|
+
name: "secondary",
|
|
630
|
+
palette: (s) => s.secondaryPalette,
|
|
631
|
+
tone: (s) => s.isDark ? 80 : 40,
|
|
632
|
+
isBackground: true,
|
|
633
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
634
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
635
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 15, "nearer", false)
|
|
636
|
+
}), MaterialDynamicColors.onSecondary = DynamicColor.fromPalette({
|
|
637
|
+
name: "on_secondary",
|
|
638
|
+
palette: (s) => s.secondaryPalette,
|
|
639
|
+
tone: (s) => isMonochrome(s) ? s.isDark ? 10 : 100 : s.isDark ? 20 : 100,
|
|
640
|
+
background: (s) => MaterialDynamicColors.secondary,
|
|
641
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
642
|
+
}), MaterialDynamicColors.secondaryContainer = DynamicColor.fromPalette({
|
|
643
|
+
name: "secondary_container",
|
|
644
|
+
palette: (s) => s.secondaryPalette,
|
|
645
|
+
tone: (s) => {
|
|
646
|
+
const initialTone = s.isDark ? 30 : 90;
|
|
647
|
+
if (isMonochrome(s)) return s.isDark ? 30 : 85;
|
|
648
|
+
if (!isFidelity(s)) return initialTone;
|
|
649
|
+
let answer = findDesiredChromaByTone(s.secondaryPalette.hue, s.secondaryPalette.chroma, initialTone, !s.isDark);
|
|
650
|
+
return answer = performAlbers(s.secondaryPalette.getHct(answer), s), answer;
|
|
651
|
+
},
|
|
652
|
+
isBackground: true,
|
|
653
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
654
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
655
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 15, "nearer", false)
|
|
656
|
+
}), MaterialDynamicColors.onSecondaryContainer = DynamicColor.fromPalette({
|
|
657
|
+
name: "on_secondary_container",
|
|
658
|
+
palette: (s) => s.secondaryPalette,
|
|
659
|
+
tone: (s) => isFidelity(s) ? DynamicColor.foregroundTone(MaterialDynamicColors.secondaryContainer.tone(s), 4.5) : s.isDark ? 90 : 10,
|
|
660
|
+
background: (s) => MaterialDynamicColors.secondaryContainer,
|
|
661
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
662
|
+
}), MaterialDynamicColors.tertiary = DynamicColor.fromPalette({
|
|
663
|
+
name: "tertiary",
|
|
664
|
+
palette: (s) => s.tertiaryPalette,
|
|
665
|
+
tone: (s) => isMonochrome(s) ? s.isDark ? 90 : 25 : s.isDark ? 80 : 40,
|
|
666
|
+
isBackground: true,
|
|
667
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
668
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
669
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 15, "nearer", false)
|
|
670
|
+
}), MaterialDynamicColors.onTertiary = DynamicColor.fromPalette({
|
|
671
|
+
name: "on_tertiary",
|
|
672
|
+
palette: (s) => s.tertiaryPalette,
|
|
673
|
+
tone: (s) => isMonochrome(s) ? s.isDark ? 10 : 90 : s.isDark ? 20 : 100,
|
|
674
|
+
background: (s) => MaterialDynamicColors.tertiary,
|
|
675
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
676
|
+
}), MaterialDynamicColors.tertiaryContainer = DynamicColor.fromPalette({
|
|
677
|
+
name: "tertiary_container",
|
|
678
|
+
palette: (s) => s.tertiaryPalette,
|
|
679
|
+
tone: (s) => {
|
|
680
|
+
if (isMonochrome(s)) return s.isDark ? 60 : 49;
|
|
681
|
+
if (!isFidelity(s)) return s.isDark ? 30 : 90;
|
|
682
|
+
const albersTone = performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.tone), s), proposedHct = s.tertiaryPalette.getHct(albersTone);
|
|
683
|
+
return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
684
|
+
},
|
|
685
|
+
isBackground: true,
|
|
686
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
687
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
688
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 15, "nearer", false)
|
|
689
|
+
}), MaterialDynamicColors.onTertiaryContainer = DynamicColor.fromPalette({
|
|
690
|
+
name: "on_tertiary_container",
|
|
691
|
+
palette: (s) => s.tertiaryPalette,
|
|
692
|
+
tone: (s) => isMonochrome(s) ? s.isDark ? 0 : 100 : isFidelity(s) ? DynamicColor.foregroundTone(MaterialDynamicColors.tertiaryContainer.tone(s), 4.5) : s.isDark ? 90 : 10,
|
|
693
|
+
background: (s) => MaterialDynamicColors.tertiaryContainer,
|
|
694
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
695
|
+
}), MaterialDynamicColors.error = DynamicColor.fromPalette({
|
|
696
|
+
name: "error",
|
|
697
|
+
palette: (s) => s.errorPalette,
|
|
698
|
+
tone: (s) => s.isDark ? 80 : 40,
|
|
699
|
+
isBackground: true,
|
|
700
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
701
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
702
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 15, "nearer", false)
|
|
703
|
+
}), MaterialDynamicColors.onError = DynamicColor.fromPalette({
|
|
704
|
+
name: "on_error",
|
|
705
|
+
palette: (s) => s.errorPalette,
|
|
706
|
+
tone: (s) => s.isDark ? 20 : 100,
|
|
707
|
+
background: (s) => MaterialDynamicColors.error,
|
|
708
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
709
|
+
}), MaterialDynamicColors.errorContainer = DynamicColor.fromPalette({
|
|
710
|
+
name: "error_container",
|
|
711
|
+
palette: (s) => s.errorPalette,
|
|
712
|
+
tone: (s) => s.isDark ? 30 : 90,
|
|
713
|
+
isBackground: true,
|
|
714
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
715
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
716
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 15, "nearer", false)
|
|
717
|
+
}), MaterialDynamicColors.onErrorContainer = DynamicColor.fromPalette({
|
|
718
|
+
name: "on_error_container",
|
|
719
|
+
palette: (s) => s.errorPalette,
|
|
720
|
+
tone: (s) => s.isDark ? 90 : 10,
|
|
721
|
+
background: (s) => MaterialDynamicColors.errorContainer,
|
|
722
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
723
|
+
}), MaterialDynamicColors.primaryFixed = DynamicColor.fromPalette({
|
|
724
|
+
name: "primary_fixed",
|
|
725
|
+
palette: (s) => s.primaryPalette,
|
|
726
|
+
tone: (s) => isMonochrome(s) ? 40 : 90,
|
|
727
|
+
isBackground: true,
|
|
728
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
729
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
730
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, "lighter", true)
|
|
731
|
+
}), MaterialDynamicColors.primaryFixedDim = DynamicColor.fromPalette({
|
|
732
|
+
name: "primary_fixed_dim",
|
|
733
|
+
palette: (s) => s.primaryPalette,
|
|
734
|
+
tone: (s) => isMonochrome(s) ? 30 : 80,
|
|
735
|
+
isBackground: true,
|
|
736
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
737
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
738
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, "lighter", true)
|
|
739
|
+
}), MaterialDynamicColors.onPrimaryFixed = DynamicColor.fromPalette({
|
|
740
|
+
name: "on_primary_fixed",
|
|
741
|
+
palette: (s) => s.primaryPalette,
|
|
742
|
+
tone: (s) => isMonochrome(s) ? 100 : 10,
|
|
743
|
+
background: (s) => MaterialDynamicColors.primaryFixedDim,
|
|
744
|
+
secondBackground: (s) => MaterialDynamicColors.primaryFixed,
|
|
745
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
746
|
+
}), MaterialDynamicColors.onPrimaryFixedVariant = DynamicColor.fromPalette({
|
|
747
|
+
name: "on_primary_fixed_variant",
|
|
748
|
+
palette: (s) => s.primaryPalette,
|
|
749
|
+
tone: (s) => isMonochrome(s) ? 90 : 30,
|
|
750
|
+
background: (s) => MaterialDynamicColors.primaryFixedDim,
|
|
751
|
+
secondBackground: (s) => MaterialDynamicColors.primaryFixed,
|
|
752
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
753
|
+
}), MaterialDynamicColors.secondaryFixed = DynamicColor.fromPalette({
|
|
754
|
+
name: "secondary_fixed",
|
|
755
|
+
palette: (s) => s.secondaryPalette,
|
|
756
|
+
tone: (s) => isMonochrome(s) ? 80 : 90,
|
|
757
|
+
isBackground: true,
|
|
758
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
759
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
760
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, "lighter", true)
|
|
761
|
+
}), MaterialDynamicColors.secondaryFixedDim = DynamicColor.fromPalette({
|
|
762
|
+
name: "secondary_fixed_dim",
|
|
763
|
+
palette: (s) => s.secondaryPalette,
|
|
764
|
+
tone: (s) => isMonochrome(s) ? 70 : 80,
|
|
765
|
+
isBackground: true,
|
|
766
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
767
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
768
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, "lighter", true)
|
|
769
|
+
}), MaterialDynamicColors.onSecondaryFixed = DynamicColor.fromPalette({
|
|
770
|
+
name: "on_secondary_fixed",
|
|
771
|
+
palette: (s) => s.secondaryPalette,
|
|
772
|
+
tone: (s) => 10,
|
|
773
|
+
background: (s) => MaterialDynamicColors.secondaryFixedDim,
|
|
774
|
+
secondBackground: (s) => MaterialDynamicColors.secondaryFixed,
|
|
775
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
776
|
+
}), MaterialDynamicColors.onSecondaryFixedVariant = DynamicColor.fromPalette({
|
|
777
|
+
name: "on_secondary_fixed_variant",
|
|
778
|
+
palette: (s) => s.secondaryPalette,
|
|
779
|
+
tone: (s) => isMonochrome(s) ? 25 : 30,
|
|
780
|
+
background: (s) => MaterialDynamicColors.secondaryFixedDim,
|
|
781
|
+
secondBackground: (s) => MaterialDynamicColors.secondaryFixed,
|
|
782
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
783
|
+
}), MaterialDynamicColors.tertiaryFixed = DynamicColor.fromPalette({
|
|
784
|
+
name: "tertiary_fixed",
|
|
785
|
+
palette: (s) => s.tertiaryPalette,
|
|
786
|
+
tone: (s) => isMonochrome(s) ? 40 : 90,
|
|
787
|
+
isBackground: true,
|
|
788
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
789
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
790
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, "lighter", true)
|
|
791
|
+
}), MaterialDynamicColors.tertiaryFixedDim = DynamicColor.fromPalette({
|
|
792
|
+
name: "tertiary_fixed_dim",
|
|
793
|
+
palette: (s) => s.tertiaryPalette,
|
|
794
|
+
tone: (s) => isMonochrome(s) ? 30 : 80,
|
|
795
|
+
isBackground: true,
|
|
796
|
+
background: (s) => MaterialDynamicColors.highestSurface(s),
|
|
797
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
798
|
+
toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, "lighter", true)
|
|
799
|
+
}), MaterialDynamicColors.onTertiaryFixed = DynamicColor.fromPalette({
|
|
800
|
+
name: "on_tertiary_fixed",
|
|
801
|
+
palette: (s) => s.tertiaryPalette,
|
|
802
|
+
tone: (s) => isMonochrome(s) ? 100 : 10,
|
|
803
|
+
background: (s) => MaterialDynamicColors.tertiaryFixedDim,
|
|
804
|
+
secondBackground: (s) => MaterialDynamicColors.tertiaryFixed,
|
|
805
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
806
|
+
}), MaterialDynamicColors.onTertiaryFixedVariant = DynamicColor.fromPalette({
|
|
807
|
+
name: "on_tertiary_fixed_variant",
|
|
808
|
+
palette: (s) => s.tertiaryPalette,
|
|
809
|
+
tone: (s) => isMonochrome(s) ? 90 : 30,
|
|
810
|
+
background: (s) => MaterialDynamicColors.tertiaryFixedDim,
|
|
811
|
+
secondBackground: (s) => MaterialDynamicColors.tertiaryFixed,
|
|
812
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
813
|
+
});
|
|
814
|
+
var TonalPalette = class _TonalPalette {
|
|
815
|
+
static fromInt(argb) {
|
|
816
|
+
const hct = Hct.fromInt(argb);
|
|
817
|
+
return _TonalPalette.fromHct(hct);
|
|
818
|
+
}
|
|
819
|
+
static fromHct(hct) {
|
|
820
|
+
return new _TonalPalette(hct.hue, hct.chroma, hct);
|
|
821
|
+
}
|
|
822
|
+
static fromHueAndChroma(hue, chroma) {
|
|
823
|
+
return new _TonalPalette(hue, chroma, _TonalPalette.createKeyColor(hue, chroma));
|
|
824
|
+
}
|
|
825
|
+
constructor(hue, chroma, keyColor) {
|
|
826
|
+
this.hue = hue, this.chroma = chroma, this.keyColor = keyColor, this.cache = /* @__PURE__ */ new Map();
|
|
827
|
+
}
|
|
828
|
+
static createKeyColor(hue, chroma) {
|
|
829
|
+
let smallestDeltaHct = Hct.from(hue, chroma, 50), smallestDelta = Math.abs(smallestDeltaHct.chroma - chroma);
|
|
830
|
+
for (let delta = 1; delta < 50; delta += 1) {
|
|
831
|
+
if (Math.round(chroma) === Math.round(smallestDeltaHct.chroma)) return smallestDeltaHct;
|
|
832
|
+
const hctAdd = Hct.from(hue, chroma, 50 + delta), hctAddDelta = Math.abs(hctAdd.chroma - chroma);
|
|
833
|
+
hctAddDelta < smallestDelta && (smallestDelta = hctAddDelta, smallestDeltaHct = hctAdd);
|
|
834
|
+
const hctSubtract = Hct.from(hue, chroma, 50 - delta), hctSubtractDelta = Math.abs(hctSubtract.chroma - chroma);
|
|
835
|
+
hctSubtractDelta < smallestDelta && (smallestDelta = hctSubtractDelta, smallestDeltaHct = hctSubtract);
|
|
836
|
+
}
|
|
837
|
+
return smallestDeltaHct;
|
|
838
|
+
}
|
|
839
|
+
tone(tone) {
|
|
840
|
+
let argb = this.cache.get(tone);
|
|
841
|
+
return void 0 === argb && (argb = Hct.from(this.hue, this.chroma, tone).toInt(), this.cache.set(tone, argb)), argb;
|
|
842
|
+
}
|
|
843
|
+
getHct(tone) {
|
|
844
|
+
return Hct.fromInt(this.tone(tone));
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
var CorePalette = class _CorePalette {
|
|
848
|
+
static of(argb) {
|
|
849
|
+
return new _CorePalette(argb, false);
|
|
850
|
+
}
|
|
851
|
+
static contentOf(argb) {
|
|
852
|
+
return new _CorePalette(argb, true);
|
|
853
|
+
}
|
|
854
|
+
static fromColors(colors) {
|
|
855
|
+
return _CorePalette.createPaletteFromColors(false, colors);
|
|
856
|
+
}
|
|
857
|
+
static contentFromColors(colors) {
|
|
858
|
+
return _CorePalette.createPaletteFromColors(true, colors);
|
|
859
|
+
}
|
|
860
|
+
static createPaletteFromColors(content, colors) {
|
|
861
|
+
const palette = new _CorePalette(colors.primary, content);
|
|
862
|
+
if (colors.secondary) {
|
|
863
|
+
const p = new _CorePalette(colors.secondary, content);
|
|
864
|
+
palette.a2 = p.a1;
|
|
865
|
+
}
|
|
866
|
+
if (colors.tertiary) {
|
|
867
|
+
const p = new _CorePalette(colors.tertiary, content);
|
|
868
|
+
palette.a3 = p.a1;
|
|
869
|
+
}
|
|
870
|
+
if (colors.error) {
|
|
871
|
+
const p = new _CorePalette(colors.error, content);
|
|
872
|
+
palette.error = p.a1;
|
|
873
|
+
}
|
|
874
|
+
if (colors.neutral) {
|
|
875
|
+
const p = new _CorePalette(colors.neutral, content);
|
|
876
|
+
palette.n1 = p.n1;
|
|
877
|
+
}
|
|
878
|
+
if (colors.neutralVariant) {
|
|
879
|
+
const p = new _CorePalette(colors.neutralVariant, content);
|
|
880
|
+
palette.n2 = p.n2;
|
|
881
|
+
}
|
|
882
|
+
return palette;
|
|
883
|
+
}
|
|
884
|
+
constructor(argb, isContent) {
|
|
885
|
+
const hct = Hct.fromInt(argb), hue = hct.hue, chroma = hct.chroma;
|
|
886
|
+
isContent ? (this.a1 = TonalPalette.fromHueAndChroma(hue, chroma), this.a2 = TonalPalette.fromHueAndChroma(hue, chroma / 3), this.a3 = TonalPalette.fromHueAndChroma(hue + 60, chroma / 2), this.n1 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 12, 4)), this.n2 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 6, 8))) : (this.a1 = TonalPalette.fromHueAndChroma(hue, Math.max(48, chroma)), this.a2 = TonalPalette.fromHueAndChroma(hue, 16), this.a3 = TonalPalette.fromHueAndChroma(hue + 60, 24), this.n1 = TonalPalette.fromHueAndChroma(hue, 4), this.n2 = TonalPalette.fromHueAndChroma(hue, 8)), this.error = TonalPalette.fromHueAndChroma(25, 84);
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
var Scheme = class _Scheme {
|
|
890
|
+
get primary() {
|
|
891
|
+
return this.props.primary;
|
|
892
|
+
}
|
|
893
|
+
get onPrimary() {
|
|
894
|
+
return this.props.onPrimary;
|
|
895
|
+
}
|
|
896
|
+
get primaryContainer() {
|
|
897
|
+
return this.props.primaryContainer;
|
|
898
|
+
}
|
|
899
|
+
get onPrimaryContainer() {
|
|
900
|
+
return this.props.onPrimaryContainer;
|
|
901
|
+
}
|
|
902
|
+
get secondary() {
|
|
903
|
+
return this.props.secondary;
|
|
904
|
+
}
|
|
905
|
+
get onSecondary() {
|
|
906
|
+
return this.props.onSecondary;
|
|
907
|
+
}
|
|
908
|
+
get secondaryContainer() {
|
|
909
|
+
return this.props.secondaryContainer;
|
|
910
|
+
}
|
|
911
|
+
get onSecondaryContainer() {
|
|
912
|
+
return this.props.onSecondaryContainer;
|
|
913
|
+
}
|
|
914
|
+
get tertiary() {
|
|
915
|
+
return this.props.tertiary;
|
|
916
|
+
}
|
|
917
|
+
get onTertiary() {
|
|
918
|
+
return this.props.onTertiary;
|
|
919
|
+
}
|
|
920
|
+
get tertiaryContainer() {
|
|
921
|
+
return this.props.tertiaryContainer;
|
|
922
|
+
}
|
|
923
|
+
get onTertiaryContainer() {
|
|
924
|
+
return this.props.onTertiaryContainer;
|
|
925
|
+
}
|
|
926
|
+
get error() {
|
|
927
|
+
return this.props.error;
|
|
928
|
+
}
|
|
929
|
+
get onError() {
|
|
930
|
+
return this.props.onError;
|
|
931
|
+
}
|
|
932
|
+
get errorContainer() {
|
|
933
|
+
return this.props.errorContainer;
|
|
934
|
+
}
|
|
935
|
+
get onErrorContainer() {
|
|
936
|
+
return this.props.onErrorContainer;
|
|
937
|
+
}
|
|
938
|
+
get background() {
|
|
939
|
+
return this.props.background;
|
|
940
|
+
}
|
|
941
|
+
get onBackground() {
|
|
942
|
+
return this.props.onBackground;
|
|
943
|
+
}
|
|
944
|
+
get surface() {
|
|
945
|
+
return this.props.surface;
|
|
946
|
+
}
|
|
947
|
+
get onSurface() {
|
|
948
|
+
return this.props.onSurface;
|
|
949
|
+
}
|
|
950
|
+
get surfaceVariant() {
|
|
951
|
+
return this.props.surfaceVariant;
|
|
952
|
+
}
|
|
953
|
+
get onSurfaceVariant() {
|
|
954
|
+
return this.props.onSurfaceVariant;
|
|
955
|
+
}
|
|
956
|
+
get outline() {
|
|
957
|
+
return this.props.outline;
|
|
958
|
+
}
|
|
959
|
+
get outlineVariant() {
|
|
960
|
+
return this.props.outlineVariant;
|
|
961
|
+
}
|
|
962
|
+
get shadow() {
|
|
963
|
+
return this.props.shadow;
|
|
964
|
+
}
|
|
965
|
+
get scrim() {
|
|
966
|
+
return this.props.scrim;
|
|
967
|
+
}
|
|
968
|
+
get inverseSurface() {
|
|
969
|
+
return this.props.inverseSurface;
|
|
970
|
+
}
|
|
971
|
+
get inverseOnSurface() {
|
|
972
|
+
return this.props.inverseOnSurface;
|
|
973
|
+
}
|
|
974
|
+
get inversePrimary() {
|
|
975
|
+
return this.props.inversePrimary;
|
|
976
|
+
}
|
|
977
|
+
static light(argb) {
|
|
978
|
+
return _Scheme.lightFromCorePalette(CorePalette.of(argb));
|
|
979
|
+
}
|
|
980
|
+
static dark(argb) {
|
|
981
|
+
return _Scheme.darkFromCorePalette(CorePalette.of(argb));
|
|
982
|
+
}
|
|
983
|
+
static lightContent(argb) {
|
|
984
|
+
return _Scheme.lightFromCorePalette(CorePalette.contentOf(argb));
|
|
985
|
+
}
|
|
986
|
+
static darkContent(argb) {
|
|
987
|
+
return _Scheme.darkFromCorePalette(CorePalette.contentOf(argb));
|
|
988
|
+
}
|
|
989
|
+
static lightFromCorePalette(core) {
|
|
990
|
+
return new _Scheme({
|
|
991
|
+
primary: core.a1.tone(40),
|
|
992
|
+
onPrimary: core.a1.tone(100),
|
|
993
|
+
primaryContainer: core.a1.tone(90),
|
|
994
|
+
onPrimaryContainer: core.a1.tone(10),
|
|
995
|
+
secondary: core.a2.tone(40),
|
|
996
|
+
onSecondary: core.a2.tone(100),
|
|
997
|
+
secondaryContainer: core.a2.tone(90),
|
|
998
|
+
onSecondaryContainer: core.a2.tone(10),
|
|
999
|
+
tertiary: core.a3.tone(40),
|
|
1000
|
+
onTertiary: core.a3.tone(100),
|
|
1001
|
+
tertiaryContainer: core.a3.tone(90),
|
|
1002
|
+
onTertiaryContainer: core.a3.tone(10),
|
|
1003
|
+
error: core.error.tone(40),
|
|
1004
|
+
onError: core.error.tone(100),
|
|
1005
|
+
errorContainer: core.error.tone(90),
|
|
1006
|
+
onErrorContainer: core.error.tone(10),
|
|
1007
|
+
background: core.n1.tone(99),
|
|
1008
|
+
onBackground: core.n1.tone(10),
|
|
1009
|
+
surface: core.n1.tone(99),
|
|
1010
|
+
onSurface: core.n1.tone(10),
|
|
1011
|
+
surfaceVariant: core.n2.tone(90),
|
|
1012
|
+
onSurfaceVariant: core.n2.tone(30),
|
|
1013
|
+
outline: core.n2.tone(50),
|
|
1014
|
+
outlineVariant: core.n2.tone(80),
|
|
1015
|
+
shadow: core.n1.tone(0),
|
|
1016
|
+
scrim: core.n1.tone(0),
|
|
1017
|
+
inverseSurface: core.n1.tone(20),
|
|
1018
|
+
inverseOnSurface: core.n1.tone(95),
|
|
1019
|
+
inversePrimary: core.a1.tone(80)
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
static darkFromCorePalette(core) {
|
|
1023
|
+
return new _Scheme({
|
|
1024
|
+
primary: core.a1.tone(80),
|
|
1025
|
+
onPrimary: core.a1.tone(20),
|
|
1026
|
+
primaryContainer: core.a1.tone(30),
|
|
1027
|
+
onPrimaryContainer: core.a1.tone(90),
|
|
1028
|
+
secondary: core.a2.tone(80),
|
|
1029
|
+
onSecondary: core.a2.tone(20),
|
|
1030
|
+
secondaryContainer: core.a2.tone(30),
|
|
1031
|
+
onSecondaryContainer: core.a2.tone(90),
|
|
1032
|
+
tertiary: core.a3.tone(80),
|
|
1033
|
+
onTertiary: core.a3.tone(20),
|
|
1034
|
+
tertiaryContainer: core.a3.tone(30),
|
|
1035
|
+
onTertiaryContainer: core.a3.tone(90),
|
|
1036
|
+
error: core.error.tone(80),
|
|
1037
|
+
onError: core.error.tone(20),
|
|
1038
|
+
errorContainer: core.error.tone(30),
|
|
1039
|
+
onErrorContainer: core.error.tone(80),
|
|
1040
|
+
background: core.n1.tone(10),
|
|
1041
|
+
onBackground: core.n1.tone(90),
|
|
1042
|
+
surface: core.n1.tone(10),
|
|
1043
|
+
onSurface: core.n1.tone(90),
|
|
1044
|
+
surfaceVariant: core.n2.tone(30),
|
|
1045
|
+
onSurfaceVariant: core.n2.tone(80),
|
|
1046
|
+
outline: core.n2.tone(60),
|
|
1047
|
+
outlineVariant: core.n2.tone(30),
|
|
1048
|
+
shadow: core.n1.tone(0),
|
|
1049
|
+
scrim: core.n1.tone(0),
|
|
1050
|
+
inverseSurface: core.n1.tone(90),
|
|
1051
|
+
inverseOnSurface: core.n1.tone(20),
|
|
1052
|
+
inversePrimary: core.a1.tone(40)
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
constructor(props) {
|
|
1056
|
+
this.props = props;
|
|
1057
|
+
}
|
|
1058
|
+
toJSON() {
|
|
1059
|
+
return {
|
|
1060
|
+
...this.props
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
function hexFromArgb(argb) {
|
|
1065
|
+
const r = redFromArgb(argb), g = greenFromArgb(argb), b = blueFromArgb(argb), outParts = [r.toString(16), g.toString(16), b.toString(16)];
|
|
1066
|
+
for (const [i, part] of outParts.entries()) 1 === part.length && (outParts[i] = "0" + part);
|
|
1067
|
+
return "#" + outParts.join("");
|
|
1068
|
+
}
|
|
1069
|
+
function argbFromHex(hex2) {
|
|
1070
|
+
const isThree = 3 === (hex2 = hex2.replace("#", "")).length, isSix = 6 === hex2.length, isEight = 8 === hex2.length;
|
|
1071
|
+
if (!isThree && !isSix && !isEight) throw new Error("unexpected hex " + hex2);
|
|
1072
|
+
let r = 0, g = 0, b = 0;
|
|
1073
|
+
return isThree ? (r = parseIntHex(hex2.slice(0, 1).repeat(2)), g = parseIntHex(hex2.slice(1, 2).repeat(2)), b = parseIntHex(hex2.slice(2, 3).repeat(2))) : isSix ? (r = parseIntHex(hex2.slice(0, 2)), g = parseIntHex(hex2.slice(2, 4)), b = parseIntHex(hex2.slice(4, 6))) : isEight && (r = parseIntHex(hex2.slice(2, 4)), g = parseIntHex(hex2.slice(4, 6)), b = parseIntHex(hex2.slice(6, 8))), (255 << 24 | (255 & r) << 16 | (255 & g) << 8 | 255 & b) >>> 0;
|
|
1074
|
+
}
|
|
1075
|
+
function parseIntHex(value) {
|
|
1076
|
+
return parseInt(value, 16);
|
|
1077
|
+
}
|
|
1078
|
+
function themeFromSourceColor(source, customColors) {
|
|
1079
|
+
if (customColors === void 0) {
|
|
1080
|
+
customColors = [];
|
|
1081
|
+
}
|
|
1082
|
+
const palette = CorePalette.of(source);
|
|
1083
|
+
return {
|
|
1084
|
+
source,
|
|
1085
|
+
schemes: {
|
|
1086
|
+
light: Scheme.light(source),
|
|
1087
|
+
dark: Scheme.dark(source)
|
|
1088
|
+
},
|
|
1089
|
+
palettes: {
|
|
1090
|
+
primary: palette.a1,
|
|
1091
|
+
secondary: palette.a2,
|
|
1092
|
+
tertiary: palette.a3,
|
|
1093
|
+
neutral: palette.n1,
|
|
1094
|
+
neutralVariant: palette.n2,
|
|
1095
|
+
error: palette.error
|
|
1096
|
+
},
|
|
1097
|
+
customColors: customColors.map((c) => customColor(source, c))
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
function customColor(source, color) {
|
|
1101
|
+
let value = color.value;
|
|
1102
|
+
const from = value, to = source;
|
|
1103
|
+
color.blend && (value = Blend.harmonize(from, to));
|
|
1104
|
+
const tones = CorePalette.of(value).a1;
|
|
1105
|
+
return {
|
|
1106
|
+
color,
|
|
1107
|
+
value,
|
|
1108
|
+
light: {
|
|
1109
|
+
color: tones.tone(40),
|
|
1110
|
+
onColor: tones.tone(100),
|
|
1111
|
+
colorContainer: tones.tone(90),
|
|
1112
|
+
onColorContainer: tones.tone(10)
|
|
1113
|
+
},
|
|
1114
|
+
dark: {
|
|
1115
|
+
color: tones.tone(80),
|
|
1116
|
+
onColor: tones.tone(20),
|
|
1117
|
+
colorContainer: tones.tone(30),
|
|
1118
|
+
onColorContainer: tones.tone(90)
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
// node_modules/framework7/shared/material-colors.js
|
|
1124
|
+
function toRGBA(d) {
|
|
1125
|
+
const r = Math.round;
|
|
1126
|
+
const l = d.length;
|
|
1127
|
+
const rgba = {};
|
|
1128
|
+
if (d.slice(0, 3).toLowerCase() === "rgb") {
|
|
1129
|
+
d = d.replace(" ", "").split(",");
|
|
1130
|
+
rgba[0] = parseInt(d[0].slice(d[3].toLowerCase() === "a" ? 5 : 4), 10);
|
|
1131
|
+
rgba[1] = parseInt(d[1], 10);
|
|
1132
|
+
rgba[2] = parseInt(d[2], 10);
|
|
1133
|
+
rgba[3] = d[3] ? parseFloat(d[3]) : -1;
|
|
1134
|
+
} else {
|
|
1135
|
+
if (l < 6) d = parseInt(String(d[1]) + d[1] + d[2] + d[2] + d[3] + d[3] + (l > 4 ? String(d[4]) + d[4] : ""), 16);
|
|
1136
|
+
else d = parseInt(d.slice(1), 16);
|
|
1137
|
+
rgba[0] = d >> 16 & 255;
|
|
1138
|
+
rgba[1] = d >> 8 & 255;
|
|
1139
|
+
rgba[2] = d & 255;
|
|
1140
|
+
rgba[3] = l === 9 || l === 5 ? r((d >> 24 & 255) / 255 * 1e4) / 1e4 : -1;
|
|
1141
|
+
}
|
|
1142
|
+
return rgba;
|
|
1143
|
+
}
|
|
1144
|
+
function blend(from, to, p) {
|
|
1145
|
+
if (p === void 0) {
|
|
1146
|
+
p = 0.5;
|
|
1147
|
+
}
|
|
1148
|
+
const r = Math.round;
|
|
1149
|
+
from = from.trim();
|
|
1150
|
+
to = to.trim();
|
|
1151
|
+
const b = p < 0;
|
|
1152
|
+
p = b ? p * -1 : p;
|
|
1153
|
+
const f = toRGBA(from);
|
|
1154
|
+
const t = toRGBA(to);
|
|
1155
|
+
if (to[0] === "r") {
|
|
1156
|
+
return "rgb" + (to[3] === "a" ? "a(" : "(") + r((t[0] - f[0]) * p + f[0]) + "," + r((t[1] - f[1]) * p + f[1]) + "," + r((t[2] - f[2]) * p + f[2]) + (f[3] < 0 && t[3] < 0 ? "" : "," + (f[3] > -1 && t[3] > -1 ? r(((t[3] - f[3]) * p + f[3]) * 1e4) / 1e4 : t[3] < 0 ? f[3] : t[3])) + ")";
|
|
1157
|
+
}
|
|
1158
|
+
return "#" + (4294967296 + (f[3] > -1 && t[3] > -1 ? r(((t[3] - f[3]) * p + f[3]) * 255) : t[3] > -1 ? r(t[3] * 255) : f[3] > -1 ? r(f[3] * 255) : 255) * 16777216 + r((t[0] - f[0]) * p + f[0]) * 65536 + r((t[1] - f[1]) * p + f[1]) * 256 + r((t[2] - f[2]) * p + f[2])).toString(16).slice(f[3] > -1 || t[3] > -1 ? 1 : 3);
|
|
1159
|
+
}
|
|
1160
|
+
var materialColors = function(hexColor) {
|
|
1161
|
+
if (hexColor === void 0) {
|
|
1162
|
+
hexColor = "";
|
|
1163
|
+
}
|
|
1164
|
+
const theme = themeFromSourceColor(argbFromHex(`#${hexColor.replace("#", "")}`));
|
|
1165
|
+
[0.05, 0.08, 0.11, 0.12, 0.14].forEach((amount, index) => {
|
|
1166
|
+
theme.schemes.light.props[`surface${index + 1}`] = argbFromHex(blend(hexFromArgb(theme.schemes.light.props.surface), hexFromArgb(theme.schemes.light.props.primary), amount));
|
|
1167
|
+
theme.schemes.dark.props[`surface${index + 1}`] = argbFromHex(blend(hexFromArgb(theme.schemes.dark.props.surface), hexFromArgb(theme.schemes.dark.props.primary), amount));
|
|
1168
|
+
});
|
|
1169
|
+
const name = (n) => {
|
|
1170
|
+
return n.split("").map((char) => char.toUpperCase() === char && char !== "-" && char !== "7" ? `-${char.toLowerCase()}` : char).join("");
|
|
1171
|
+
};
|
|
1172
|
+
const shouldSkip = (prop) => {
|
|
1173
|
+
const skip = ["tertiary", "shadow", "scrim", "error", "background"];
|
|
1174
|
+
return skip.filter((v) => prop.toLowerCase().includes(v)).length > 0;
|
|
1175
|
+
};
|
|
1176
|
+
const light = {};
|
|
1177
|
+
const dark = {};
|
|
1178
|
+
Object.keys(theme.schemes.light.props).forEach((prop) => {
|
|
1179
|
+
if (shouldSkip(prop)) return;
|
|
1180
|
+
light[name(`--f7-md-${prop}`)] = hexFromArgb(theme.schemes.light.props[prop]);
|
|
1181
|
+
});
|
|
1182
|
+
Object.keys(theme.schemes.dark.props).forEach((prop) => {
|
|
1183
|
+
if (shouldSkip(prop)) return;
|
|
1184
|
+
dark[name(`--f7-md-${prop}`)] = hexFromArgb(theme.schemes.dark.props[prop]);
|
|
1185
|
+
});
|
|
1186
|
+
return {
|
|
1187
|
+
light,
|
|
1188
|
+
dark
|
|
1189
|
+
};
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
// node_modules/framework7/shared/utils.js
|
|
1193
|
+
var mdPreloaderContent = `
|
|
1194
|
+
<span class="preloader-inner">
|
|
1195
|
+
<svg viewBox="0 0 36 36">
|
|
1196
|
+
<circle cx="18" cy="18" r="16"></circle>
|
|
1197
|
+
</svg>
|
|
1198
|
+
</span>
|
|
1199
|
+
`.trim();
|
|
1200
|
+
var iosPreloaderContent = `
|
|
1201
|
+
<span class="preloader-inner">
|
|
1202
|
+
${[0, 1, 2, 3, 4, 5, 6, 7].map(() => '<span class="preloader-inner-line"></span>').join("")}
|
|
1203
|
+
</span>
|
|
1204
|
+
`.trim();
|
|
1205
|
+
function colorHexToRgb(hex2) {
|
|
1206
|
+
const h = hex2.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => r + r + g + g + b + b);
|
|
1207
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h);
|
|
1208
|
+
return result ? result.slice(1).map((n) => parseInt(n, 16)) : null;
|
|
1209
|
+
}
|
|
1210
|
+
function colorRgbToHex(r, g, b) {
|
|
1211
|
+
const result = [r, g, b].map((n) => {
|
|
1212
|
+
const hex2 = n.toString(16);
|
|
1213
|
+
return hex2.length === 1 ? `0${hex2}` : hex2;
|
|
1214
|
+
}).join("");
|
|
1215
|
+
return `#${result}`;
|
|
1216
|
+
}
|
|
1217
|
+
function colorRgbToHsl(r, g, b) {
|
|
1218
|
+
r /= 255;
|
|
1219
|
+
g /= 255;
|
|
1220
|
+
b /= 255;
|
|
1221
|
+
const max = Math.max(r, g, b);
|
|
1222
|
+
const min = Math.min(r, g, b);
|
|
1223
|
+
const d = max - min;
|
|
1224
|
+
let h;
|
|
1225
|
+
if (d === 0) h = 0;
|
|
1226
|
+
else if (max === r) h = (g - b) / d % 6;
|
|
1227
|
+
else if (max === g) h = (b - r) / d + 2;
|
|
1228
|
+
else if (max === b) h = (r - g) / d + 4;
|
|
1229
|
+
const l = (min + max) / 2;
|
|
1230
|
+
const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
1231
|
+
if (h < 0) h = 360 / 60 + h;
|
|
1232
|
+
return [h * 60, s, l];
|
|
1233
|
+
}
|
|
1234
|
+
function colorHslToRgb(h, s, l) {
|
|
1235
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
1236
|
+
const hp = h / 60;
|
|
1237
|
+
const x = c * (1 - Math.abs(hp % 2 - 1));
|
|
1238
|
+
let rgb1;
|
|
1239
|
+
if (Number.isNaN(h) || typeof h === "undefined") {
|
|
1240
|
+
rgb1 = [0, 0, 0];
|
|
1241
|
+
} else if (hp <= 1) rgb1 = [c, x, 0];
|
|
1242
|
+
else if (hp <= 2) rgb1 = [x, c, 0];
|
|
1243
|
+
else if (hp <= 3) rgb1 = [0, c, x];
|
|
1244
|
+
else if (hp <= 4) rgb1 = [0, x, c];
|
|
1245
|
+
else if (hp <= 5) rgb1 = [x, 0, c];
|
|
1246
|
+
else if (hp <= 6) rgb1 = [c, 0, x];
|
|
1247
|
+
const m = l - c / 2;
|
|
1248
|
+
return rgb1.map((n) => Math.max(0, Math.min(255, Math.round(255 * (n + m)))));
|
|
1249
|
+
}
|
|
1250
|
+
var getShadeTintColors = (rgb) => {
|
|
1251
|
+
const hsl = colorRgbToHsl(...rgb);
|
|
1252
|
+
const hslShade = [hsl[0], hsl[1], Math.max(0, hsl[2] - 0.08)];
|
|
1253
|
+
const hslTint = [hsl[0], hsl[1], Math.max(0, hsl[2] + 0.08)];
|
|
1254
|
+
const shade = colorRgbToHex(...colorHslToRgb(...hslShade));
|
|
1255
|
+
const tint = colorRgbToHex(...colorHslToRgb(...hslTint));
|
|
1256
|
+
return {
|
|
1257
|
+
shade,
|
|
1258
|
+
tint
|
|
1259
|
+
};
|
|
1260
|
+
};
|
|
1261
|
+
function colorThemeCSSProperties() {
|
|
1262
|
+
let hex2;
|
|
1263
|
+
let rgb;
|
|
1264
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
1265
|
+
args[_key3] = arguments[_key3];
|
|
1266
|
+
}
|
|
1267
|
+
if (args.length === 1) {
|
|
1268
|
+
hex2 = args[0];
|
|
1269
|
+
rgb = colorHexToRgb(hex2);
|
|
1270
|
+
} else if (args.length === 3) {
|
|
1271
|
+
rgb = args;
|
|
1272
|
+
hex2 = colorRgbToHex(...rgb);
|
|
1273
|
+
}
|
|
1274
|
+
if (!rgb) return {};
|
|
1275
|
+
const {
|
|
1276
|
+
light,
|
|
1277
|
+
dark
|
|
1278
|
+
} = materialColors(hex2);
|
|
1279
|
+
const shadeTintIos = getShadeTintColors(rgb);
|
|
1280
|
+
const shadeTintMdLight = getShadeTintColors(colorHexToRgb(light["--f7-md-primary"]));
|
|
1281
|
+
const shadeTintMdDark = getShadeTintColors(colorHexToRgb(dark["--f7-md-primary"]));
|
|
1282
|
+
Object.keys(light).forEach((key) => {
|
|
1283
|
+
if (key.includes("surface-")) {
|
|
1284
|
+
light[`${key}-rgb`] = colorHexToRgb(light[key]);
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
Object.keys(dark).forEach((key) => {
|
|
1288
|
+
if (key.includes("surface-")) {
|
|
1289
|
+
dark[`${key}-rgb`] = colorHexToRgb(dark[key]);
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
return {
|
|
1293
|
+
ios: {
|
|
1294
|
+
"--f7-theme-color": "var(--f7-ios-primary)",
|
|
1295
|
+
"--f7-theme-color-rgb": "var(--f7-ios-primary-rgb)",
|
|
1296
|
+
"--f7-theme-color-shade": "var(--f7-ios-primary-shade)",
|
|
1297
|
+
"--f7-theme-color-tint": "var(--f7-ios-primary-tint)"
|
|
1298
|
+
},
|
|
1299
|
+
md: {
|
|
1300
|
+
"--f7-theme-color": "var(--f7-md-primary)",
|
|
1301
|
+
"--f7-theme-color-rgb": "var(--f7-md-primary-rgb)",
|
|
1302
|
+
"--f7-theme-color-shade": "var(--f7-md-primary-shade)",
|
|
1303
|
+
"--f7-theme-color-tint": "var(--f7-md-primary-tint)"
|
|
1304
|
+
},
|
|
1305
|
+
light: {
|
|
1306
|
+
"--f7-ios-primary": hex2,
|
|
1307
|
+
"--f7-ios-primary-shade": shadeTintIos.shade,
|
|
1308
|
+
"--f7-ios-primary-tint": shadeTintIos.tint,
|
|
1309
|
+
"--f7-ios-primary-rgb": rgb.join(", "),
|
|
1310
|
+
"--f7-md-primary-shade": shadeTintMdLight.shade,
|
|
1311
|
+
"--f7-md-primary-tint": shadeTintMdLight.tint,
|
|
1312
|
+
"--f7-md-primary-rgb": colorHexToRgb(light["--f7-md-primary"]).join(", "),
|
|
1313
|
+
...light
|
|
1314
|
+
},
|
|
1315
|
+
dark: {
|
|
1316
|
+
"--f7-md-primary-shade": shadeTintMdDark.shade,
|
|
1317
|
+
"--f7-md-primary-tint": shadeTintMdDark.tint,
|
|
1318
|
+
"--f7-md-primary-rgb": colorHexToRgb(dark["--f7-md-primary"]).join(", "),
|
|
1319
|
+
...dark
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// entry.mjs
|
|
1325
|
+
function toCss(props) {
|
|
1326
|
+
const fmt = (v) => Array.isArray(v) ? v.join(", ") : v;
|
|
1327
|
+
const block = (sel, obj) => !obj || !Object.keys(obj).length ? "" : `${sel} {
|
|
1328
|
+
${Object.entries(obj).map(([k, v]) => ` ${k}: ${fmt(v)};`).join("\n")}
|
|
1329
|
+
}
|
|
1330
|
+
`;
|
|
1331
|
+
return [
|
|
1332
|
+
block(":root", props.light),
|
|
1333
|
+
block(".ios", props.ios),
|
|
1334
|
+
block(".md", props.md),
|
|
1335
|
+
block(".dark", props.dark)
|
|
1336
|
+
].join("");
|
|
1337
|
+
}
|
|
1338
|
+
var hex = process.argv[2];
|
|
1339
|
+
if (!/^#[0-9a-fA-F]{6}$/.test(hex || "")) {
|
|
1340
|
+
console.error("usage: node f7-color-theme.mjs '#rrggbb'");
|
|
1341
|
+
process.exit(1);
|
|
1342
|
+
}
|
|
1343
|
+
console.log(`/* Framework7 theme palette generated from ${hex} by framework7's own`);
|
|
1344
|
+
console.log(` colorThemeCSSProperties() (via f7-color-theme.mjs). */`);
|
|
1345
|
+
console.log(toCss(colorThemeCSSProperties(hex)));
|