@protonradio/proton-ui 0.7.2 → 0.7.4

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/package.json CHANGED
@@ -1,91 +1,91 @@
1
- {
2
- "name": "@protonradio/proton-ui",
3
- "version": "0.7.2",
4
- "description": "",
5
- "main": "./dist/proton-ui.umd.js",
6
- "module": "./dist/proton-ui.es.js",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.es.js",
11
- "require": "./dist/index.cjs.js"
12
- },
13
- "./styles": "./dist/style.css",
14
- "./utils": {
15
- "types": "./dist/utils.d.ts",
16
- "import": "./dist/utils.es.js",
17
- "require": "./dist/utils.cjs.js"
18
- },
19
- "./constants": {
20
- "types": "./dist/constants.d.ts",
21
- "import": "./dist/constants.es.js",
22
- "require": "./dist/constants.cjs.js"
23
- }
24
- },
25
- "typesVersions": {
26
- "*": {
27
- "*": [
28
- "./dist/index.d.ts"
29
- ],
30
- "constants": [
31
- "./dist/constants.d.ts"
32
- ],
33
- "utils": [
34
- "./dist/utils.d.ts"
35
- ]
36
- }
37
- },
38
- "scripts": {
39
- "dev": "vite",
40
- "build": "vite build",
41
- "preview": "vite preview",
42
- "storybook": "storybook dev -p 6006",
43
- "build-storybook": "storybook build",
44
- "test": "jest",
45
- "dev-test": "jest --watch",
46
- "prepare": "vite build",
47
- "chromatic": "npx chromatic --exit-once-uploaded flag --force-rebuild --project-token=$CHROMATIC_PROJECT_TOKEN",
48
- "omlet:analyze": "npx @omlet/cli analyze"
49
- },
50
- "files": [
51
- "dist"
52
- ],
53
- "author": "",
54
- "license": "MIT",
55
- "dependencies": {
56
- "@storybook/cli": "^8.4.2",
57
- "color2k": "^2.0.3",
58
- "react": "^18.3.1",
59
- "react-aria": "^3.35.1",
60
- "react-aria-components": "^1.4.1",
61
- "react-dom": "^18.3.1",
62
- "react-stately": "^3.33.0"
63
- },
64
- "devDependencies": {
65
- "@chromatic-com/storybook": "^3.2.2",
66
- "@storybook/addon-a11y": "^8.4.2",
67
- "@storybook/addon-essentials": "^8.4.2",
68
- "@storybook/addon-interactions": "^8.4.2",
69
- "@storybook/addon-links": "^8.4.2",
70
- "@storybook/addon-onboarding": "^8.4.2",
71
- "@storybook/blocks": "^8.4.2",
72
- "@storybook/react": "^8.4.2",
73
- "@storybook/react-vite": "^8.4.2",
74
- "@storybook/test": "^8.4.2",
75
- "@testing-library/jest-dom": "^6.6.3",
76
- "@testing-library/react": "^16.0.1",
77
- "@testing-library/user-event": "^14.5.2",
78
- "@types/jest": "^29.5.14",
79
- "@vitejs/plugin-react": "^4.3.3",
80
- "colorthief": "^2.6.0",
81
- "jest": "^29.7.0",
82
- "jest-environment-jsdom": "^29.7.0",
83
- "lightningcss": "^1.28.1",
84
- "react-docgen-typescript": "^2.2.2",
85
- "storybook": "^8.4.2",
86
- "ts-jest": "^29.2.5",
87
- "ts-node": "^10.9.2",
88
- "vite": "^5.4.10",
89
- "vite-plugin-dts": "^4.3.0"
90
- }
91
- }
1
+ {
2
+ "name": "@protonradio/proton-ui",
3
+ "version": "0.7.4",
4
+ "description": "",
5
+ "main": "./dist/proton-ui.umd.js",
6
+ "module": "./dist/proton-ui.es.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.es.js",
11
+ "require": "./dist/index.cjs.js"
12
+ },
13
+ "./styles": "./dist/style.css",
14
+ "./utils": {
15
+ "types": "./dist/utils.d.ts",
16
+ "import": "./dist/utils.es.js",
17
+ "require": "./dist/utils.cjs.js"
18
+ },
19
+ "./constants": {
20
+ "types": "./dist/constants.d.ts",
21
+ "import": "./dist/constants.es.js",
22
+ "require": "./dist/constants.cjs.js"
23
+ }
24
+ },
25
+ "typesVersions": {
26
+ "*": {
27
+ "*": [
28
+ "./dist/index.d.ts"
29
+ ],
30
+ "constants": [
31
+ "./dist/constants.d.ts"
32
+ ],
33
+ "utils": [
34
+ "./dist/utils.d.ts"
35
+ ]
36
+ }
37
+ },
38
+ "scripts": {
39
+ "dev": "vite",
40
+ "build": "vite build",
41
+ "preview": "vite preview",
42
+ "storybook": "storybook dev -p 6006",
43
+ "build-storybook": "storybook build",
44
+ "test": "jest",
45
+ "dev-test": "jest --watch",
46
+ "prepare": "vite build",
47
+ "chromatic": "npx chromatic --exit-once-uploaded flag --force-rebuild --project-token=$CHROMATIC_PROJECT_TOKEN",
48
+ "omlet:analyze": "npx @omlet/cli analyze"
49
+ },
50
+ "files": [
51
+ "dist"
52
+ ],
53
+ "author": "",
54
+ "license": "MIT",
55
+ "dependencies": {
56
+ "@storybook/cli": "^8.4.2",
57
+ "color2k": "^2.0.3",
58
+ "react": "^18.3.1",
59
+ "react-aria": "^3.35.1",
60
+ "react-aria-components": "^1.4.1",
61
+ "react-dom": "^18.3.1",
62
+ "react-stately": "^3.33.0"
63
+ },
64
+ "devDependencies": {
65
+ "@chromatic-com/storybook": "^3.2.2",
66
+ "@storybook/addon-a11y": "^8.4.2",
67
+ "@storybook/addon-essentials": "^8.4.2",
68
+ "@storybook/addon-interactions": "^8.4.2",
69
+ "@storybook/addon-links": "^8.4.2",
70
+ "@storybook/addon-onboarding": "^8.4.2",
71
+ "@storybook/blocks": "^8.4.2",
72
+ "@storybook/react": "^8.4.2",
73
+ "@storybook/react-vite": "^8.4.2",
74
+ "@storybook/test": "^8.4.2",
75
+ "@testing-library/jest-dom": "^6.6.3",
76
+ "@testing-library/react": "^16.0.1",
77
+ "@testing-library/user-event": "^14.5.2",
78
+ "@types/jest": "^29.5.14",
79
+ "@vitejs/plugin-react": "^4.3.3",
80
+ "colorthief": "^2.6.0",
81
+ "jest": "^29.7.0",
82
+ "jest-environment-jsdom": "^29.7.0",
83
+ "lightningcss": "^1.28.1",
84
+ "react-docgen-typescript": "^2.2.2",
85
+ "storybook": "^8.4.2",
86
+ "ts-jest": "^29.2.5",
87
+ "ts-node": "^10.9.2",
88
+ "vite": "^5.4.10",
89
+ "vite-plugin-dts": "^4.3.0"
90
+ }
91
+ }
@@ -1,145 +0,0 @@
1
- import { B as P, G as e } from "./colors-Dwh4VIMR.mjs";
2
- import { toRgba as n, transparentize as U, saturate as C, desaturate as h, getScale as u, adjustHue as N, darken as M, lighten as S, hasBadContrast as l, getLuminance as T } from "color2k";
3
- const y = {
4
- BRAND: {
5
- PRIMARY: P.PRIMARY,
6
- PRIMARY_LIGHT: P.PRIMARY_LIGHT,
7
- SECONDARY: P.SECONDARY
8
- },
9
- PRIMARY: {
10
- PRIMARY_SUPER_DARK: e.GRAY_SUPER_DARK,
11
- PRIMARY_DARK: e.GRAY_DARK,
12
- PRIMARY_MEDIUM: e.GRAY_MEDIUM,
13
- PRIMARY_MEDIUM_LIGHT: e.GRAY_MEDIUM_LIGHT,
14
- PRIMARY_LIGHT: e.GRAY_LIGHT,
15
- PRIMARY_LIGHTEST: e.GRAY_LIGHTEST,
16
- PRIMARY_SUPER_LIGHT: e.GRAY_SUPER_LIGHT
17
- },
18
- SECONDARY: {
19
- SECONDARY_SUPER_DARK: e.GRAY_SUPER_DARK,
20
- SECONDARY_DARK: e.GRAY_DARK,
21
- SECONDARY_MEDIUM: e.GRAY_MEDIUM,
22
- SECONDARY_MEDIUM_LIGHT: e.GRAY_MEDIUM_LIGHT,
23
- SECONDARY_LIGHT: e.GRAY_LIGHT,
24
- SECONDARY_LIGHTEST: e.GRAY_LIGHTEST,
25
- SECONDARY_SUPER_LIGHT: e.GRAY_SUPER_LIGHT
26
- }
27
- // Success, Warning & Danger palettes go here...
28
- }, m = (t, R) => R === void 0 ? `rgb(${t[0]}, ${t[1]}, ${t[2]})` : `rgba(${t[0]}, ${t[1]}, ${t[2]}, ${R})`, g = (t, R) => n(U(t, R)), Y = (t, R) => n(C(t, R)), r = (t, R) => n(h(t, R)), f = (t, R = !0) => {
29
- const a = m(t), I = u("#FFFFFF", a, "#000000"), s = Array.from({ length: 12 }, (c, i) => {
30
- const G = I(i / 11);
31
- return r(G, 85e-4);
32
- }), A = R ? s.map(
33
- (c) => Y(L(c), 5e-3)
34
- ) : s, H = n(Y(N(a, 180), 1)), d = u("#FFFFFF", H, "#000000"), D = Array.from({ length: 12 }, (c, i) => {
35
- const G = d(i / 11);
36
- return r(G, 0.1);
37
- }), E = R ? D.map(
38
- (c) => r(L(c), 0.22)
39
- ) : D;
40
- return {
41
- BRAND: {
42
- PRIMARY: r(o(A[5]), 0.125),
43
- PRIMARY_LIGHT: r(
44
- _(A[5]),
45
- 0.1
46
- ),
47
- SECONDARY: r(E[4], 0.02)
48
- },
49
- PRIMARY: {
50
- //backgrounds
51
- PRIMARY_SUPER_DARK: o(s[9]),
52
- PRIMARY_DARK: o(s[8]),
53
- //interactive components
54
- PRIMARY_MEDIUM: n(
55
- M(
56
- r(o(A[7]), 0.18),
57
- 0.05
58
- )
59
- ),
60
- //borders and seperators
61
- PRIMARY_MEDIUM_LIGHT: _(A[6]),
62
- //solid colors
63
- PRIMARY_LIGHT: Y(_(A[5]), 0.2),
64
- //accessible text
65
- PRIMARY_LIGHTEST: n(
66
- S(Y(_(A[3]), 0.2), 0.1)
67
- ),
68
- PRIMARY_SUPER_LIGHT: n(S(A[0], 0.2))
69
- },
70
- SECONDARY: {
71
- //backgrounds
72
- SECONDARY_SUPER_DARK: o(D[10]),
73
- SECONDARY_DARK: o(D[9]),
74
- // interactive components
75
- SECONDARY_MEDIUM: n(
76
- M(
77
- r(o(E[7]), 0.35),
78
- 0.1
79
- )
80
- ),
81
- //borders and seperators
82
- SECONDARY_MEDIUM_LIGHT: _(E[6]),
83
- //solid colors
84
- SECONDARY_LIGHT: Y(
85
- _(E[5]),
86
- 0.1
87
- ),
88
- //accessible text
89
- SECONDARY_LIGHTEST: n(
90
- S(
91
- Y(_(E[3]), 0.2),
92
- 0.1
93
- )
94
- ),
95
- SECONDARY_SUPER_LIGHT: n(S(E[0], 0.2))
96
- }
97
- };
98
- }, _ = (t) => {
99
- for (; l(t, "readable", e.GRAY_DARK); )
100
- t = S(t, 0.01);
101
- return n(t);
102
- }, o = (t) => {
103
- for (; l(e.GRAY_SUPER_LIGHT, "readable", t); )
104
- t = M(t, 0.01);
105
- return n(t);
106
- }, L = (t) => {
107
- let R = t, a = T(n(R)), I = 0;
108
- const s = 6;
109
- for (; a < 0.16 && I < s; )
110
- I++, R = S(R, 0.1), a = T(n(R));
111
- for (; a > 0.6 && I < s; )
112
- I++, R = M(R, 0.1), a = T(n(R));
113
- return n(R);
114
- }, p = (t) => typeof t == "string" || t instanceof String;
115
- function w(...t) {
116
- return t.filter(p).join(" ");
117
- }
118
- const O = (t) => {
119
- if (/^https?:\/\//.test(t)) {
120
- const R = document.createElement("a");
121
- return R.href = t, R.hostname;
122
- }
123
- return window.location.hostname;
124
- }, $ = (t) => {
125
- const R = window.location.hostname, a = O(t);
126
- return R !== a;
127
- }, v = (t, R) => {
128
- if (t.metaKey || t.altKey || t.ctrlKey || t.shiftKey || t.button && t.button !== 0)
129
- return;
130
- t.preventDefault();
131
- const a = R.startsWith("/") ? R : `/${R}`;
132
- window.history.pushState({}, "", a), window.dispatchEvent(new PopStateEvent("popstate"));
133
- };
134
- export {
135
- y as D,
136
- m as a,
137
- w as c,
138
- r as d,
139
- f as g,
140
- v as h,
141
- $ as i,
142
- Y as s,
143
- g as t
144
- };
145
- //# sourceMappingURL=utils-D9D3Fg9O.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-D9D3Fg9O.mjs","sources":["../src/utils/color.ts","../src/utils/utils.ts"],"sourcesContent":["import { COLORS } from \"../constants\";\nimport {\n adjustHue,\n getScale,\n saturate as _saturate,\n transparentize as _transparentize,\n desaturate as _desaturate,\n hasBadContrast,\n getLuminance,\n lighten,\n darken,\n toRgba,\n} from \"color2k\";\n\nexport type RGBArray = [number, number, number];\n\nexport type Palette = {\n BRAND: {\n PRIMARY: string;\n PRIMARY_LIGHT: string;\n SECONDARY: string;\n };\n PRIMARY: {\n //backgrounds\n PRIMARY_SUPER_DARK: string;\n PRIMARY_DARK: string;\n //interactive components\n PRIMARY_MEDIUM: string;\n //borders and seperators\n PRIMARY_MEDIUM_LIGHT: string;\n //solid colors\n PRIMARY_LIGHT: string;\n //accessible text\n PRIMARY_LIGHTEST: string;\n PRIMARY_SUPER_LIGHT: string;\n };\n SECONDARY: {\n //backgrounds\n SECONDARY_SUPER_DARK: string;\n SECONDARY_DARK: string;\n //interactive components\n SECONDARY_MEDIUM: string;\n //borders and seperators\n SECONDARY_MEDIUM_LIGHT: string;\n //solid colors\n SECONDARY_LIGHT: string;\n //accessible text\n SECONDARY_LIGHTEST: string;\n SECONDARY_SUPER_LIGHT: string;\n };\n};\n\nexport const DEFAULT_PALETTE: Palette = {\n BRAND: {\n PRIMARY: COLORS.BRAND.PRIMARY,\n PRIMARY_LIGHT: COLORS.BRAND.PRIMARY_LIGHT,\n SECONDARY: COLORS.BRAND.SECONDARY,\n },\n PRIMARY: {\n PRIMARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\n PRIMARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\n PRIMARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\n PRIMARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\n PRIMARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\n PRIMARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\n PRIMARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\n },\n SECONDARY: {\n SECONDARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\n SECONDARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\n SECONDARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\n SECONDARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\n SECONDARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\n SECONDARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\n SECONDARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\n },\n // Success, Warning & Danger palettes go here...\n};\n\n/**\n * Converts an RGB array to a CSS string representation.\n * @param rgb - The RGB array to convert.\n * @param opacity - Optional opacity value.\n * @returns A CSS string representation of the RGB array, using `rgb()`, or `rgba()` if an opacity value is provided.\n */\nexport const arrayToRgbString = (rgb: RGBArray, opacity?: number): string => {\n return opacity === undefined\n ? `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`\n : `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${opacity})`;\n};\n\n/**\n * Transparentizes an input color.\n *\n * @param color - The color string to transparentize.\n * @param amount - The amount to increase the opacity of the color by, given as a decimal between 0 and 1.\n * @returns An RGBA color string.\n */\nexport const transparentize = (color: string, amount: number): string => {\n return toRgba(_transparentize(color, amount));\n};\n\n/**\n * Saturates a color.\n *\n * @param color - Input color\n * @param amount - The amount to saturate, given as a decimal between 0 and 1\n * @returns An RGBA color string.\n */\nexport const saturate = (color: string, amount: number): string => {\n return toRgba(_saturate(color, amount));\n};\n\n/**\n * Desaturates a color.\n *\n * @param color - Input color\n * @param amount - The amount to desaturate, given as a decimal between 0 and 1\n * @returns An RGBA color string.\n */\nexport const desaturate = (color: string, amount: number): string => {\n return toRgba(_desaturate(color, amount));\n};\n\n/**\n * Generates a complete color palette based on a primary color input.\n * The palette includes primary and secondary color scales with varying shades.\n *\n * @param primaryColor - The base RGB color array to generate the palette from\n * @param adjustForLuminance - Whether to adjust the generated colors for better luminance/contrast. Defaults to true.\n * @returns A Palette object containing:\n * - BRAND colors (primary, light primary, and secondary)\n * - PRIMARY scale (7 shades from super dark to super light)\n * - SECONDARY scale (7 shades from super dark to super light)\n *\n * The function:\n * 1. Creates a 12-color scale from white to the primary color to black\n * 2. Generates a complementary secondary color by shifting the hue 180 degrees\n * 3. Creates another 12-color scale for the secondary color\n * 4. Maps specific positions from these scales to create the final palette structure\n */\nexport const generatePalette = (\n primaryColor: RGBArray,\n adjustForLuminance: boolean = true\n): Palette => {\n const primaryRgba = arrayToRgbString(primaryColor);\n\n const primaryScaleFunc = getScale(\"#FFFFFF\", primaryRgba, \"#000000\");\n const primaryScale = Array.from({ length: 12 }, (_, i) => {\n const color = primaryScaleFunc(i / 11);\n return desaturate(color, 0.0085);\n });\n\n const adjustedPrimaryScale = adjustForLuminance\n ? primaryScale.map((color) =>\n saturate(adjustBrightnessForLuminance(color), 0.005)\n )\n : primaryScale;\n\n const secondaryColor = toRgba(saturate(adjustHue(primaryRgba, 180), 1));\n\n const secondaryScaleFunc = getScale(\"#FFFFFF\", secondaryColor, \"#000000\");\n const secondaryScale = Array.from({ length: 12 }, (_, i) => {\n const color = secondaryScaleFunc(i / 11);\n return desaturate(color, 0.1);\n });\n\n const adjustedSecondaryScale = adjustForLuminance\n ? secondaryScale.map((color) =>\n desaturate(adjustBrightnessForLuminance(color), 0.22)\n )\n : secondaryScale;\n\n return {\n BRAND: {\n PRIMARY: desaturate(darkenForContrast(adjustedPrimaryScale[5]), 0.125),\n PRIMARY_LIGHT: desaturate(\n lightenForContrast(adjustedPrimaryScale[5]),\n 0.1\n ),\n SECONDARY: desaturate(adjustedSecondaryScale[4], 0.02),\n },\n PRIMARY: {\n //backgrounds\n PRIMARY_SUPER_DARK: darkenForContrast(primaryScale[9]),\n PRIMARY_DARK: darkenForContrast(primaryScale[8]),\n //interactive components\n PRIMARY_MEDIUM: toRgba(\n darken(\n desaturate(darkenForContrast(adjustedPrimaryScale[7]), 0.18),\n 0.05\n )\n ),\n //borders and seperators\n PRIMARY_MEDIUM_LIGHT: lightenForContrast(adjustedPrimaryScale[6]),\n //solid colors\n PRIMARY_LIGHT: saturate(lightenForContrast(adjustedPrimaryScale[5]), 0.2),\n //accessible text\n PRIMARY_LIGHTEST: toRgba(\n lighten(saturate(lightenForContrast(adjustedPrimaryScale[3]), 0.2), 0.1)\n ),\n PRIMARY_SUPER_LIGHT: toRgba(lighten(adjustedPrimaryScale[0], 0.2)),\n },\n SECONDARY: {\n //backgrounds\n SECONDARY_SUPER_DARK: darkenForContrast(secondaryScale[10]),\n SECONDARY_DARK: darkenForContrast(secondaryScale[9]),\n // interactive components\n SECONDARY_MEDIUM: toRgba(\n darken(\n desaturate(darkenForContrast(adjustedSecondaryScale[7]), 0.35),\n 0.1\n )\n ),\n //borders and seperators\n SECONDARY_MEDIUM_LIGHT: lightenForContrast(adjustedSecondaryScale[6]),\n //solid colors\n SECONDARY_LIGHT: saturate(\n lightenForContrast(adjustedSecondaryScale[5]),\n 0.1\n ),\n //accessible text\n SECONDARY_LIGHTEST: toRgba(\n lighten(\n saturate(lightenForContrast(adjustedSecondaryScale[3]), 0.2),\n 0.1\n )\n ),\n SECONDARY_SUPER_LIGHT: toRgba(lighten(adjustedSecondaryScale[0], 0.2)),\n },\n };\n};\n\nconst lightenForContrast = (color: string): string => {\n while (hasBadContrast(color, \"readable\", COLORS.GRAYSCALE.GRAY_DARK)) {\n color = lighten(color, 0.01);\n }\n return toRgba(color);\n};\n\nconst darkenForContrast = (color: string): string => {\n while (hasBadContrast(COLORS.GRAYSCALE.GRAY_SUPER_LIGHT, \"readable\", color)) {\n color = darken(color, 0.01);\n }\n return toRgba(color);\n};\n\nconst adjustBrightnessForLuminance = (color: string): string => {\n let currentColor = color;\n let currentLuminance = getLuminance(toRgba(currentColor));\n let adjustmentAttempts = 0;\n const MAX_ATTEMPTS = 6;\n\n while (currentLuminance < 0.16 && adjustmentAttempts < MAX_ATTEMPTS) {\n adjustmentAttempts++;\n currentColor = lighten(currentColor, 0.1);\n currentLuminance = getLuminance(toRgba(currentColor));\n }\n\n while (currentLuminance > 0.6 && adjustmentAttempts < MAX_ATTEMPTS) {\n adjustmentAttempts++;\n currentColor = darken(currentColor, 0.1);\n currentLuminance = getLuminance(toRgba(currentColor));\n }\n\n return toRgba(currentColor);\n};\n","const isString = (x: unknown): boolean =>\n typeof x === \"string\" || x instanceof String;\n\nexport function csx(...classnames: unknown[]): string {\n return classnames.filter(isString).join(\" \");\n}\n\n/**\n * [getLinkHost] - get the host of a link.\n * Referenced from is-url-external npm package\n * https://github.com/mrded/is-url-external/blob/master/index.js\n */\nconst getLinkHost = (url) => {\n if (/^https?:\\/\\//.test(url)) {\n // Absolute URL.\n // The easy way to parse an URL, is to create <a> element.\n // @see: https://gist.github.com/jlong/2428561\n const parser = document.createElement(\"a\");\n parser.href = url;\n return parser.hostname;\n }\n return window.location.hostname;\n};\n\n/**\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\n */\nexport const isUrlExternal = (url) => {\n const host = window.location.hostname;\n const linkHost = getLinkHost(url);\n\n return host !== linkHost;\n};\n\n/**\n * Handles internal navigation clicks by preventing default browser behavior and\n * programmatically updating the URL and history state.\n *\n * @param e - The click event from the anchor element\n * @param to - The destination path to navigate to\n *\n * @remarks\n * - Converts relative paths to absolute by prepending \"/\" if needed\n * - Updates browser history using pushState and dispatches a popstate event\n */\nexport const handleInternalNavigation = (\n e: React.MouseEvent<HTMLAnchorElement>,\n to: string\n) => {\n // Don't handle navigation if modifier keys are pressed\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\n return;\n }\n\n // Don't handle middle clicks or right clicks\n if (e.button && e.button !== 0) {\n return;\n }\n\n e.preventDefault();\n\n // Handle relative paths\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\n window.history.pushState({}, \"\", resolvedPath);\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\n};\n"],"names":["DEFAULT_PALETTE","COLORS.BRAND","COLORS.GRAYSCALE","arrayToRgbString","rgb","opacity","transparentize","color","amount","toRgba","_transparentize","saturate","_saturate","desaturate","_desaturate","generatePalette","primaryColor","adjustForLuminance","primaryRgba","primaryScaleFunc","getScale","primaryScale","_","adjustedPrimaryScale","adjustBrightnessForLuminance","secondaryColor","adjustHue","secondaryScaleFunc","secondaryScale","adjustedSecondaryScale","darkenForContrast","lightenForContrast","darken","lighten","hasBadContrast","currentColor","currentLuminance","getLuminance","adjustmentAttempts","MAX_ATTEMPTS","isString","x","csx","classnames","getLinkHost","url","parser","isUrlExternal","host","linkHost","handleInternalNavigation","e","to","resolvedPath"],"mappings":";;AAoDO,MAAMA,IAA2B;AAAA,EACtC,OAAO;AAAA,IACL,SAASC,EAAa;AAAA,IACtB,eAAeA,EAAa;AAAA,IAC5B,WAAWA,EAAa;AAAA,EAC1B;AAAA,EACA,SAAS;AAAA,IACP,oBAAoBC,EAAiB;AAAA,IACrC,cAAcA,EAAiB;AAAA,IAC/B,gBAAgBA,EAAiB;AAAA,IACjC,sBAAsBA,EAAiB;AAAA,IACvC,eAAeA,EAAiB;AAAA,IAChC,kBAAkBA,EAAiB;AAAA,IACnC,qBAAqBA,EAAiB;AAAA,EACxC;AAAA,EACA,WAAW;AAAA,IACT,sBAAsBA,EAAiB;AAAA,IACvC,gBAAgBA,EAAiB;AAAA,IACjC,kBAAkBA,EAAiB;AAAA,IACnC,wBAAwBA,EAAiB;AAAA,IACzC,iBAAiBA,EAAiB;AAAA,IAClC,oBAAoBA,EAAiB;AAAA,IACrC,uBAAuBA,EAAiB;AAAA,EAC1C;AAAA;AAEF,GAQaC,IAAmB,CAACC,GAAeC,MACvCA,MAAY,SACf,OAAOD,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,MACnC,QAAQA,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,KAAKA,EAAI,CAAC,CAAC,KAAKC,CAAO,KAUzCC,IAAiB,CAACC,GAAeC,MACrCC,EAAOC,EAAgBH,GAAOC,CAAM,CAAC,GAUjCG,IAAW,CAACJ,GAAeC,MAC/BC,EAAOG,EAAUL,GAAOC,CAAM,CAAC,GAU3BK,IAAa,CAACN,GAAeC,MACjCC,EAAOK,EAAYP,GAAOC,CAAM,CAAC,GAoB7BO,IAAkB,CAC7BC,GACAC,IAA8B,OAClB;AACN,QAAAC,IAAcf,EAAiBa,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@
1
- "use strict";const n=require("./colors-BdogYmJi.js"),R=require("color2k"),l={BRAND:{PRIMARY:n.BRAND.PRIMARY,PRIMARY_LIGHT:n.BRAND.PRIMARY_LIGHT,SECONDARY:n.BRAND.SECONDARY},PRIMARY:{PRIMARY_SUPER_DARK:n.GRAYSCALE.GRAY_SUPER_DARK,PRIMARY_DARK:n.GRAYSCALE.GRAY_DARK,PRIMARY_MEDIUM:n.GRAYSCALE.GRAY_MEDIUM,PRIMARY_MEDIUM_LIGHT:n.GRAYSCALE.GRAY_MEDIUM_LIGHT,PRIMARY_LIGHT:n.GRAYSCALE.GRAY_LIGHT,PRIMARY_LIGHTEST:n.GRAYSCALE.GRAY_LIGHTEST,PRIMARY_SUPER_LIGHT:n.GRAYSCALE.GRAY_SUPER_LIGHT},SECONDARY:{SECONDARY_SUPER_DARK:n.GRAYSCALE.GRAY_SUPER_DARK,SECONDARY_DARK:n.GRAYSCALE.GRAY_DARK,SECONDARY_MEDIUM:n.GRAYSCALE.GRAY_MEDIUM,SECONDARY_MEDIUM_LIGHT:n.GRAYSCALE.GRAY_MEDIUM_LIGHT,SECONDARY_LIGHT:n.GRAYSCALE.GRAY_LIGHT,SECONDARY_LIGHTEST:n.GRAYSCALE.GRAY_LIGHTEST,SECONDARY_SUPER_LIGHT:n.GRAYSCALE.GRAY_SUPER_LIGHT}},D=(t,e)=>e===void 0?`rgb(${t[0]}, ${t[1]}, ${t[2]})`:`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${e})`,u=(t,e)=>R.toRgba(R.transparentize(t,e)),Y=(t,e)=>R.toRgba(R.saturate(t,e)),A=(t,e)=>R.toRgba(R.desaturate(t,e)),P=(t,e=!0)=>{const a=D(t),_=R.getScale("#FFFFFF",a,"#000000"),r=Array.from({length:12},(I,c)=>{const i=_(c/11);return A(i,.0085)}),o=e?r.map(I=>Y(L(I),.005)):r,M=R.toRgba(Y(R.adjustHue(a,180),1)),T=R.getScale("#FFFFFF",M,"#000000"),G=Array.from({length:12},(I,c)=>{const i=T(c/11);return A(i,.1)}),S=e?G.map(I=>A(L(I),.22)):G;return{BRAND:{PRIMARY:A(E(o[5]),.125),PRIMARY_LIGHT:A(s(o[5]),.1),SECONDARY:A(S[4],.02)},PRIMARY:{PRIMARY_SUPER_DARK:E(r[9]),PRIMARY_DARK:E(r[8]),PRIMARY_MEDIUM:R.toRgba(R.darken(A(E(o[7]),.18),.05)),PRIMARY_MEDIUM_LIGHT:s(o[6]),PRIMARY_LIGHT:Y(s(o[5]),.2),PRIMARY_LIGHTEST:R.toRgba(R.lighten(Y(s(o[3]),.2),.1)),PRIMARY_SUPER_LIGHT:R.toRgba(R.lighten(o[0],.2))},SECONDARY:{SECONDARY_SUPER_DARK:E(G[10]),SECONDARY_DARK:E(G[9]),SECONDARY_MEDIUM:R.toRgba(R.darken(A(E(S[7]),.35),.1)),SECONDARY_MEDIUM_LIGHT:s(S[6]),SECONDARY_LIGHT:Y(s(S[5]),.1),SECONDARY_LIGHTEST:R.toRgba(R.lighten(Y(s(S[3]),.2),.1)),SECONDARY_SUPER_LIGHT:R.toRgba(R.lighten(S[0],.2))}}},s=t=>{for(;R.hasBadContrast(t,"readable",n.GRAYSCALE.GRAY_DARK);)t=R.lighten(t,.01);return R.toRgba(t)},E=t=>{for(;R.hasBadContrast(n.GRAYSCALE.GRAY_SUPER_LIGHT,"readable",t);)t=R.darken(t,.01);return R.toRgba(t)},L=t=>{let e=t,a=R.getLuminance(R.toRgba(e)),_=0;const r=6;for(;a<.16&&_<r;)_++,e=R.lighten(e,.1),a=R.getLuminance(R.toRgba(e));for(;a>.6&&_<r;)_++,e=R.darken(e,.1),a=R.getLuminance(R.toRgba(e));return R.toRgba(e)},g=t=>typeof t=="string"||t instanceof String;function C(...t){return t.filter(g).join(" ")}const d=t=>{if(/^https?:\/\//.test(t)){const e=document.createElement("a");return e.href=t,e.hostname}return window.location.hostname},H=t=>{const e=window.location.hostname,a=d(t);return e!==a},h=(t,e)=>{if(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.button&&t.button!==0)return;t.preventDefault();const a=e.startsWith("/")?e:`/${e}`;window.history.pushState({},"",a),window.dispatchEvent(new PopStateEvent("popstate"))};exports.DEFAULT_PALETTE=l;exports.arrayToRgbString=D;exports.csx=C;exports.desaturate=A;exports.generatePalette=P;exports.handleInternalNavigation=h;exports.isUrlExternal=H;exports.saturate=Y;exports.transparentize=u;
2
- //# sourceMappingURL=utils-DbIphMSk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-DbIphMSk.js","sources":["../src/utils/color.ts","../src/utils/utils.ts"],"sourcesContent":["import { COLORS } from \"../constants\";\nimport {\n adjustHue,\n getScale,\n saturate as _saturate,\n transparentize as _transparentize,\n desaturate as _desaturate,\n hasBadContrast,\n getLuminance,\n lighten,\n darken,\n toRgba,\n} from \"color2k\";\n\nexport type RGBArray = [number, number, number];\n\nexport type Palette = {\n BRAND: {\n PRIMARY: string;\n PRIMARY_LIGHT: string;\n SECONDARY: string;\n };\n PRIMARY: {\n //backgrounds\n PRIMARY_SUPER_DARK: string;\n PRIMARY_DARK: string;\n //interactive components\n PRIMARY_MEDIUM: string;\n //borders and seperators\n PRIMARY_MEDIUM_LIGHT: string;\n //solid colors\n PRIMARY_LIGHT: string;\n //accessible text\n PRIMARY_LIGHTEST: string;\n PRIMARY_SUPER_LIGHT: string;\n };\n SECONDARY: {\n //backgrounds\n SECONDARY_SUPER_DARK: string;\n SECONDARY_DARK: string;\n //interactive components\n SECONDARY_MEDIUM: string;\n //borders and seperators\n SECONDARY_MEDIUM_LIGHT: string;\n //solid colors\n SECONDARY_LIGHT: string;\n //accessible text\n SECONDARY_LIGHTEST: string;\n SECONDARY_SUPER_LIGHT: string;\n };\n};\n\nexport const DEFAULT_PALETTE: Palette = {\n BRAND: {\n PRIMARY: COLORS.BRAND.PRIMARY,\n PRIMARY_LIGHT: COLORS.BRAND.PRIMARY_LIGHT,\n SECONDARY: COLORS.BRAND.SECONDARY,\n },\n PRIMARY: {\n PRIMARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\n PRIMARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\n PRIMARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\n PRIMARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\n PRIMARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\n PRIMARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\n PRIMARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\n },\n SECONDARY: {\n SECONDARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\n SECONDARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\n SECONDARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\n SECONDARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\n SECONDARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\n SECONDARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\n SECONDARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\n },\n // Success, Warning & Danger palettes go here...\n};\n\n/**\n * Converts an RGB array to a CSS string representation.\n * @param rgb - The RGB array to convert.\n * @param opacity - Optional opacity value.\n * @returns A CSS string representation of the RGB array, using `rgb()`, or `rgba()` if an opacity value is provided.\n */\nexport const arrayToRgbString = (rgb: RGBArray, opacity?: number): string => {\n return opacity === undefined\n ? `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`\n : `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${opacity})`;\n};\n\n/**\n * Transparentizes an input color.\n *\n * @param color - The color string to transparentize.\n * @param amount - The amount to increase the opacity of the color by, given as a decimal between 0 and 1.\n * @returns An RGBA color string.\n */\nexport const transparentize = (color: string, amount: number): string => {\n return toRgba(_transparentize(color, amount));\n};\n\n/**\n * Saturates a color.\n *\n * @param color - Input color\n * @param amount - The amount to saturate, given as a decimal between 0 and 1\n * @returns An RGBA color string.\n */\nexport const saturate = (color: string, amount: number): string => {\n return toRgba(_saturate(color, amount));\n};\n\n/**\n * Desaturates a color.\n *\n * @param color - Input color\n * @param amount - The amount to desaturate, given as a decimal between 0 and 1\n * @returns An RGBA color string.\n */\nexport const desaturate = (color: string, amount: number): string => {\n return toRgba(_desaturate(color, amount));\n};\n\n/**\n * Generates a complete color palette based on a primary color input.\n * The palette includes primary and secondary color scales with varying shades.\n *\n * @param primaryColor - The base RGB color array to generate the palette from\n * @param adjustForLuminance - Whether to adjust the generated colors for better luminance/contrast. Defaults to true.\n * @returns A Palette object containing:\n * - BRAND colors (primary, light primary, and secondary)\n * - PRIMARY scale (7 shades from super dark to super light)\n * - SECONDARY scale (7 shades from super dark to super light)\n *\n * The function:\n * 1. Creates a 12-color scale from white to the primary color to black\n * 2. Generates a complementary secondary color by shifting the hue 180 degrees\n * 3. Creates another 12-color scale for the secondary color\n * 4. Maps specific positions from these scales to create the final palette structure\n */\nexport const generatePalette = (\n primaryColor: RGBArray,\n adjustForLuminance: boolean = true\n): Palette => {\n const primaryRgba = arrayToRgbString(primaryColor);\n\n const primaryScaleFunc = getScale(\"#FFFFFF\", primaryRgba, \"#000000\");\n const primaryScale = Array.from({ length: 12 }, (_, i) => {\n const color = primaryScaleFunc(i / 11);\n return desaturate(color, 0.0085);\n });\n\n const adjustedPrimaryScale = adjustForLuminance\n ? primaryScale.map((color) =>\n saturate(adjustBrightnessForLuminance(color), 0.005)\n )\n : primaryScale;\n\n const secondaryColor = toRgba(saturate(adjustHue(primaryRgba, 180), 1));\n\n const secondaryScaleFunc = getScale(\"#FFFFFF\", secondaryColor, \"#000000\");\n const secondaryScale = Array.from({ length: 12 }, (_, i) => {\n const color = secondaryScaleFunc(i / 11);\n return desaturate(color, 0.1);\n });\n\n const adjustedSecondaryScale = adjustForLuminance\n ? secondaryScale.map((color) =>\n desaturate(adjustBrightnessForLuminance(color), 0.22)\n )\n : secondaryScale;\n\n return {\n BRAND: {\n PRIMARY: desaturate(darkenForContrast(adjustedPrimaryScale[5]), 0.125),\n PRIMARY_LIGHT: desaturate(\n lightenForContrast(adjustedPrimaryScale[5]),\n 0.1\n ),\n SECONDARY: desaturate(adjustedSecondaryScale[4], 0.02),\n },\n PRIMARY: {\n //backgrounds\n PRIMARY_SUPER_DARK: darkenForContrast(primaryScale[9]),\n PRIMARY_DARK: darkenForContrast(primaryScale[8]),\n //interactive components\n PRIMARY_MEDIUM: toRgba(\n darken(\n desaturate(darkenForContrast(adjustedPrimaryScale[7]), 0.18),\n 0.05\n )\n ),\n //borders and seperators\n PRIMARY_MEDIUM_LIGHT: lightenForContrast(adjustedPrimaryScale[6]),\n //solid colors\n PRIMARY_LIGHT: saturate(lightenForContrast(adjustedPrimaryScale[5]), 0.2),\n //accessible text\n PRIMARY_LIGHTEST: toRgba(\n lighten(saturate(lightenForContrast(adjustedPrimaryScale[3]), 0.2), 0.1)\n ),\n PRIMARY_SUPER_LIGHT: toRgba(lighten(adjustedPrimaryScale[0], 0.2)),\n },\n SECONDARY: {\n //backgrounds\n SECONDARY_SUPER_DARK: darkenForContrast(secondaryScale[10]),\n SECONDARY_DARK: darkenForContrast(secondaryScale[9]),\n // interactive components\n SECONDARY_MEDIUM: toRgba(\n darken(\n desaturate(darkenForContrast(adjustedSecondaryScale[7]), 0.35),\n 0.1\n )\n ),\n //borders and seperators\n SECONDARY_MEDIUM_LIGHT: lightenForContrast(adjustedSecondaryScale[6]),\n //solid colors\n SECONDARY_LIGHT: saturate(\n lightenForContrast(adjustedSecondaryScale[5]),\n 0.1\n ),\n //accessible text\n SECONDARY_LIGHTEST: toRgba(\n lighten(\n saturate(lightenForContrast(adjustedSecondaryScale[3]), 0.2),\n 0.1\n )\n ),\n SECONDARY_SUPER_LIGHT: toRgba(lighten(adjustedSecondaryScale[0], 0.2)),\n },\n };\n};\n\nconst lightenForContrast = (color: string): string => {\n while (hasBadContrast(color, \"readable\", COLORS.GRAYSCALE.GRAY_DARK)) {\n color = lighten(color, 0.01);\n }\n return toRgba(color);\n};\n\nconst darkenForContrast = (color: string): string => {\n while (hasBadContrast(COLORS.GRAYSCALE.GRAY_SUPER_LIGHT, \"readable\", color)) {\n color = darken(color, 0.01);\n }\n return toRgba(color);\n};\n\nconst adjustBrightnessForLuminance = (color: string): string => {\n let currentColor = color;\n let currentLuminance = getLuminance(toRgba(currentColor));\n let adjustmentAttempts = 0;\n const MAX_ATTEMPTS = 6;\n\n while (currentLuminance < 0.16 && adjustmentAttempts < MAX_ATTEMPTS) {\n adjustmentAttempts++;\n currentColor = lighten(currentColor, 0.1);\n currentLuminance = getLuminance(toRgba(currentColor));\n }\n\n while (currentLuminance > 0.6 && adjustmentAttempts < MAX_ATTEMPTS) {\n adjustmentAttempts++;\n currentColor = darken(currentColor, 0.1);\n currentLuminance = getLuminance(toRgba(currentColor));\n }\n\n return toRgba(currentColor);\n};\n","const isString = (x: unknown): boolean =>\n typeof x === \"string\" || x instanceof String;\n\nexport function csx(...classnames: unknown[]): string {\n return classnames.filter(isString).join(\" \");\n}\n\n/**\n * [getLinkHost] - get the host of a link.\n * Referenced from is-url-external npm package\n * https://github.com/mrded/is-url-external/blob/master/index.js\n */\nconst getLinkHost = (url) => {\n if (/^https?:\\/\\//.test(url)) {\n // Absolute URL.\n // The easy way to parse an URL, is to create <a> element.\n // @see: https://gist.github.com/jlong/2428561\n const parser = document.createElement(\"a\");\n parser.href = url;\n return parser.hostname;\n }\n return window.location.hostname;\n};\n\n/**\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\n */\nexport const isUrlExternal = (url) => {\n const host = window.location.hostname;\n const linkHost = getLinkHost(url);\n\n return host !== linkHost;\n};\n\n/**\n * Handles internal navigation clicks by preventing default browser behavior and\n * programmatically updating the URL and history state.\n *\n * @param e - The click event from the anchor element\n * @param to - The destination path to navigate to\n *\n * @remarks\n * - Converts relative paths to absolute by prepending \"/\" if needed\n * - Updates browser history using pushState and dispatches a popstate event\n */\nexport const handleInternalNavigation = (\n e: React.MouseEvent<HTMLAnchorElement>,\n to: string\n) => {\n // Don't handle navigation if modifier keys are pressed\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\n return;\n }\n\n // Don't handle middle clicks or right clicks\n if (e.button && e.button !== 0) {\n return;\n }\n\n e.preventDefault();\n\n // Handle relative paths\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\n window.history.pushState({}, \"\", resolvedPath);\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\n};\n"],"names":["DEFAULT_PALETTE","COLORS.BRAND","COLORS.GRAYSCALE","arrayToRgbString","rgb","opacity","transparentize","color","amount","toRgba","_transparentize","saturate","_saturate","desaturate","_desaturate","generatePalette","primaryColor","adjustForLuminance","primaryRgba","primaryScaleFunc","getScale","primaryScale","_","i","adjustedPrimaryScale","adjustBrightnessForLuminance","secondaryColor","adjustHue","secondaryScaleFunc","secondaryScale","adjustedSecondaryScale","darkenForContrast","lightenForContrast","darken","lighten","hasBadContrast","currentColor","currentLuminance","getLuminance","adjustmentAttempts","MAX_ATTEMPTS","isString","x","csx","classnames","getLinkHost","url","parser","isUrlExternal","host","linkHost","handleInternalNavigation","e","to","resolvedPath"],"mappings":"0EAoDaA,EAA2B,CACtC,MAAO,CACL,QAASC,EAAa,MAAA,QACtB,cAAeA,EAAa,MAAA,cAC5B,UAAWA,EAAa,MAAA,SAC1B,EACA,QAAS,CACP,mBAAoBC,EAAiB,UAAA,gBACrC,aAAcA,EAAiB,UAAA,UAC/B,eAAgBA,EAAiB,UAAA,YACjC,qBAAsBA,EAAiB,UAAA,kBACvC,cAAeA,EAAiB,UAAA,WAChC,iBAAkBA,EAAiB,UAAA,cACnC,oBAAqBA,EAAiB,UAAA,gBACxC,EACA,UAAW,CACT,qBAAsBA,EAAiB,UAAA,gBACvC,eAAgBA,EAAiB,UAAA,UACjC,iBAA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