@sanity/ui 3.0.0-static.26 → 3.0.0-static.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/_chunks-cjs/_visual-editing.cjs +197 -197
  2. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  3. package/dist/_chunks-es/_visual-editing.js +199 -199
  4. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  5. package/dist/_visual-editing.d.cts +1 -0
  6. package/dist/_visual-editing.d.ts +1 -0
  7. package/dist/css.cjs +1 -1
  8. package/dist/css.d.cts +1 -1
  9. package/dist/css.d.ts +1 -1
  10. package/dist/css.js +1 -1
  11. package/dist/index.cjs +141 -141
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +1 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +143 -143
  16. package/dist/index.js.map +1 -1
  17. package/dist/theme.cjs +2605 -1075
  18. package/dist/theme.cjs.map +1 -1
  19. package/dist/theme.d.cts +1 -1
  20. package/dist/theme.d.ts +1 -1
  21. package/dist/theme.js +2689 -1159
  22. package/dist/theme.js.map +1 -1
  23. package/dist/ui.css +1 -1
  24. package/exports/_visual-editing.ts +1 -1
  25. package/package.json +13 -26
  26. package/src/core/components/dialog/dialog.tsx +2 -9
  27. package/src/core/components/dialog/dialogCard.tsx +2 -1
  28. package/src/core/components/index.ts +1 -0
  29. package/src/core/components/menu/menu.tsx +1 -2
  30. package/src/core/components/toast/toastLayer.tsx +1 -2
  31. package/src/core/components/toast/toastProvider.tsx +1 -1
  32. package/src/core/{utils → components}/virtualList/__workshop__/index.ts +1 -1
  33. package/src/core/primitives/badge/badge.tsx +2 -1
  34. package/src/core/primitives/index.ts +3 -0
  35. package/src/core/{utils → primitives}/layer/__workshop__/index.ts +1 -1
  36. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +1 -0
  37. package/src/core/primitives/popover/popover.tsx +2 -1
  38. package/src/core/primitives/popover/popoverLayer.tsx +2 -1
  39. package/src/core/primitives/stack/stack.tsx +1 -0
  40. package/src/core/primitives/switch/switch.tsx +1 -1
  41. package/src/core/primitives/tooltip/tooltip.tsx +2 -1
  42. package/src/core/primitives/tooltip/tooltipLayer.tsx +2 -1
  43. package/src/core/utils/getElementRef.ts +1 -0
  44. package/src/core/utils/index.ts +0 -4
  45. package/src/css/primitives/avatar/avatar.css.ts +5 -0
  46. package/src/css/primitives/badge/badge.css.ts +2 -1
  47. package/src/css/primitives/label/label.css.ts +1 -0
  48. package/src/css/props/width/types.ts +1 -1
  49. package/src/css/props/width/width.css.ts +3 -0
  50. package/src/theme/v2/build/buildTheme.test.ts +8 -8
  51. package/src/theme/v2/build/buildTheme.ts +32 -7
  52. /package/src/core/{utils → components}/virtualList/__workshop__/changingProps.tsx +0 -0
  53. /package/src/core/{utils → components}/virtualList/__workshop__/elementScroll.tsx +0 -0
  54. /package/src/core/{utils → components}/virtualList/__workshop__/infiniteList.tsx +0 -0
  55. /package/src/core/{utils → components}/virtualList/__workshop__/windowScrolll.tsx +0 -0
  56. /package/src/core/{utils → components}/virtualList/index.ts +0 -0
  57. /package/src/core/{utils → components}/virtualList/virtualList.tsx +0 -0
  58. /package/src/core/{utils → primitives}/arrow/arrow.tsx +0 -0
  59. /package/src/core/{utils → primitives}/arrow/cmds.ts +0 -0
  60. /package/src/core/{utils → primitives}/arrow/index.ts +0 -0
  61. /package/src/core/{utils → primitives}/layer/__workshop__/_debug.tsx +0 -0
  62. /package/src/core/{utils → primitives}/layer/__workshop__/multipleRoots.tsx +0 -0
  63. /package/src/core/{utils → primitives}/layer/__workshop__/nested.tsx +0 -0
  64. /package/src/core/{utils → primitives}/layer/__workshop__/responsiveZOffset.tsx +0 -0
  65. /package/src/core/{utils → primitives}/layer/getLayerContext.test.ts +0 -0
  66. /package/src/core/{utils → primitives}/layer/getLayerContext.ts +0 -0
  67. /package/src/core/{utils → primitives}/layer/index.ts +0 -0
  68. /package/src/core/{utils → primitives}/layer/layer.test.tsx +0 -0
  69. /package/src/core/{utils → primitives}/layer/layer.tsx +0 -0
  70. /package/src/core/{utils → primitives}/layer/layerCard.tsx +0 -0
  71. /package/src/core/{utils → primitives}/layer/layerContext.ts +0 -0
  72. /package/src/core/{utils → primitives}/layer/layerProvider.tsx +0 -0
  73. /package/src/core/{utils → primitives}/layer/types.ts +0 -0
  74. /package/src/core/{utils → primitives}/layer/useLayer.ts +0 -0
  75. /package/src/core/{utils → primitives}/srOnly/index.ts +0 -0
  76. /package/src/core/{utils → primitives}/srOnly/srOnly.tsx +0 -0
package/dist/theme.js CHANGED
@@ -1,4 +1,4 @@
1
- import { hues, white as white$1, black as black$1, COLOR_HUES, COLOR_TINTS } from "@sanity/color";
1
+ import { COLOR_HUES, COLOR_TINTS, color, hues, white as white$1, black as black$1 } from "@sanity/color";
2
2
  const defaultThemeConfig = {
3
3
  avatar: {
4
4
  sizes: [{
@@ -119,15 +119,27 @@ const defaultThemeConfig = {
119
119
  width: 1
120
120
  }
121
121
  }
122
+ },
123
+ style: {
124
+ button: {
125
+ root: {
126
+ transition: "background-color 100ms,border-color 100ms,color 100ms"
127
+ }
128
+ }
129
+ // card: {
130
+ // root: {
131
+ // transition: 'background-color 100ms,border-color 100ms,color 100ms',
132
+ // },
133
+ // },
122
134
  }
123
135
  };
124
136
  function is_v2(themeProp) {
125
137
  return themeProp._version === 2;
126
138
  }
127
- function themeColor_v0_v2_9(color) {
128
- if ("neutral" in color.badge)
129
- return color;
130
- const colors2 = color;
139
+ function themeColor_v0_v2_9(color2) {
140
+ if ("neutral" in color2.badge)
141
+ return color2;
142
+ const colors2 = color2;
131
143
  return {
132
144
  ...colors2,
133
145
  badge: {
@@ -381,7 +393,7 @@ function v0_v2(v0) {
381
393
  const {
382
394
  avatar,
383
395
  button,
384
- color,
396
+ color: color2,
385
397
  container,
386
398
  fonts: font,
387
399
  input,
@@ -404,24 +416,24 @@ function v0_v2(v0) {
404
416
  card: defaultThemeConfig.card,
405
417
  color: {
406
418
  light: {
407
- transparent: themeColor_v0_v2(color.light.transparent),
408
- default: themeColor_v0_v2(color.light.default),
409
- neutral: themeColor_v0_v2(color.light.transparent),
410
- primary: themeColor_v0_v2(color.light.primary),
411
- suggest: themeColor_v0_v2(color.light.primary),
412
- positive: themeColor_v0_v2(color.light.positive),
413
- caution: themeColor_v0_v2(color.light.caution),
414
- critical: themeColor_v0_v2(color.light.critical)
419
+ transparent: themeColor_v0_v2(color2.light.transparent),
420
+ default: themeColor_v0_v2(color2.light.default),
421
+ neutral: themeColor_v0_v2(color2.light.transparent),
422
+ primary: themeColor_v0_v2(color2.light.primary),
423
+ suggest: themeColor_v0_v2(color2.light.primary),
424
+ positive: themeColor_v0_v2(color2.light.positive),
425
+ caution: themeColor_v0_v2(color2.light.caution),
426
+ critical: themeColor_v0_v2(color2.light.critical)
415
427
  },
416
428
  dark: {
417
- transparent: themeColor_v0_v2(color.dark.transparent),
418
- default: themeColor_v0_v2(color.dark.default),
419
- neutral: themeColor_v0_v2(color.dark.transparent),
420
- primary: themeColor_v0_v2(color.dark.primary),
421
- suggest: themeColor_v0_v2(color.dark.primary),
422
- positive: themeColor_v0_v2(color.dark.positive),
423
- caution: themeColor_v0_v2(color.dark.caution),
424
- critical: themeColor_v0_v2(color.dark.critical)
429
+ transparent: themeColor_v0_v2(color2.dark.transparent),
430
+ default: themeColor_v0_v2(color2.dark.default),
431
+ neutral: themeColor_v0_v2(color2.dark.transparent),
432
+ primary: themeColor_v0_v2(color2.dark.primary),
433
+ suggest: themeColor_v0_v2(color2.dark.primary),
434
+ positive: themeColor_v0_v2(color2.dark.positive),
435
+ caution: themeColor_v0_v2(color2.dark.caution),
436
+ critical: themeColor_v0_v2(color2.dark.critical)
425
437
  }
426
438
  },
427
439
  container,
@@ -458,7 +470,7 @@ function v2_v0(v2, v3) {
458
470
  const {
459
471
  avatar,
460
472
  button,
461
- color,
473
+ color: color2,
462
474
  container,
463
475
  font: fonts,
464
476
  input,
@@ -475,20 +487,20 @@ function v2_v0(v2, v3) {
475
487
  container,
476
488
  color: {
477
489
  light: {
478
- transparent: themeColor_v2_v0(color.light.transparent),
479
- default: themeColor_v2_v0(color.light.default),
480
- primary: themeColor_v2_v0(color.light.primary),
481
- positive: themeColor_v2_v0(color.light.positive),
482
- caution: themeColor_v2_v0(color.light.caution),
483
- critical: themeColor_v2_v0(color.light.critical)
490
+ transparent: themeColor_v2_v0(color2.light.transparent),
491
+ default: themeColor_v2_v0(color2.light.default),
492
+ primary: themeColor_v2_v0(color2.light.primary),
493
+ positive: themeColor_v2_v0(color2.light.positive),
494
+ caution: themeColor_v2_v0(color2.light.caution),
495
+ critical: themeColor_v2_v0(color2.light.critical)
484
496
  },
485
497
  dark: {
486
- transparent: themeColor_v2_v0(color.dark.transparent),
487
- default: themeColor_v2_v0(color.dark.default),
488
- primary: themeColor_v2_v0(color.dark.primary),
489
- positive: themeColor_v2_v0(color.dark.positive),
490
- caution: themeColor_v2_v0(color.dark.caution),
491
- critical: themeColor_v2_v0(color.dark.critical)
498
+ transparent: themeColor_v2_v0(color2.dark.transparent),
499
+ default: themeColor_v2_v0(color2.dark.default),
500
+ primary: themeColor_v2_v0(color2.dark.primary),
501
+ positive: themeColor_v2_v0(color2.dark.positive),
502
+ caution: themeColor_v2_v0(color2.dark.caution),
503
+ critical: themeColor_v2_v0(color2.dark.critical)
492
504
  }
493
505
  },
494
506
  focusRing: input.text.focusRing,
@@ -1096,13 +1108,13 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
1096
1108
  state,
1097
1109
  tone
1098
1110
  }) => {
1099
- const color = colors[tone];
1111
+ const color2 = colors[tone];
1100
1112
  return state === "hovered" ? {
1101
- bg: dark ? color.light : color.dark,
1102
- bg2: dark ? color.light : color.dark,
1103
- border: dark ? color.lighter : color.darker,
1104
- fg: dark ? color.darkest : color.lightest,
1105
- icon: dark ? color.darkest : color.lightest,
1113
+ bg: dark ? color2.light : color2.dark,
1114
+ bg2: dark ? color2.light : color2.dark,
1115
+ border: dark ? color2.lighter : color2.darker,
1116
+ fg: dark ? color2.darkest : color2.lightest,
1117
+ icon: dark ? color2.darkest : color2.lightest,
1106
1118
  muted: {
1107
1119
  fg: black
1108
1120
  },
@@ -1118,11 +1130,11 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
1118
1130
  },
1119
1131
  skeleton: base.skeleton
1120
1132
  } : {
1121
- bg: color.base,
1122
- bg2: color.base,
1123
- border: dark ? color.light : color.dark,
1124
- fg: dark ? color.darkest : color.lightest,
1125
- icon: dark ? color.darkest : color.lightest,
1133
+ bg: color2.base,
1134
+ bg2: color2.base,
1135
+ border: dark ? color2.light : color2.dark,
1136
+ fg: dark ? color2.darkest : color2.lightest,
1137
+ icon: dark ? color2.darkest : color2.lightest,
1126
1138
  muted: {
1127
1139
  fg: black
1128
1140
  },
@@ -1145,13 +1157,13 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
1145
1157
  state,
1146
1158
  tone
1147
1159
  }) => {
1148
- const color = colors[tone];
1160
+ const color2 = colors[tone];
1149
1161
  return state === "hovered" ? {
1150
- bg: dark ? color.darker : color.lighter,
1151
- bg2: dark ? color.darker : color.lighter,
1152
- border: dark ? color.lighter : color.darker,
1153
- fg: dark ? color.lightest : color.darkest,
1154
- icon: dark ? color.lightest : color.darkest,
1162
+ bg: dark ? color2.darker : color2.lighter,
1163
+ bg2: dark ? color2.darker : color2.lighter,
1164
+ border: dark ? color2.lighter : color2.darker,
1165
+ fg: dark ? color2.lightest : color2.darkest,
1166
+ icon: dark ? color2.lightest : color2.darkest,
1155
1167
  muted: {
1156
1168
  fg: black
1157
1169
  },
@@ -1167,11 +1179,11 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
1167
1179
  },
1168
1180
  skeleton: base.skeleton
1169
1181
  } : {
1170
- bg: dark ? color.darkest : color.lightest,
1171
- bg2: dark ? color.darkest : color.lightest,
1172
- border: dark ? color.darker : color.lighter,
1173
- fg: dark ? color.lighter : color.darker,
1174
- icon: dark ? color.lighter : color.darker,
1182
+ bg: dark ? color2.darkest : color2.lightest,
1183
+ bg2: dark ? color2.darkest : color2.lightest,
1184
+ border: dark ? color2.darker : color2.lighter,
1185
+ fg: dark ? color2.lighter : color2.darker,
1186
+ icon: dark ? color2.lighter : color2.darker,
1175
1187
  muted: {
1176
1188
  fg: black
1177
1189
  },
@@ -1706,494 +1718,437 @@ function _createColor(opts, dark, name) {
1706
1718
  muted
1707
1719
  };
1708
1720
  }
1709
- const AVATAR_SIZE = [0, 1, 2, 3], CONTAINER_SCALE = [0, 1, 2, 3, 4, 5], CONTAINER = [...CONTAINER_SCALE, "auto"], RADIUS = [0, 1, 2, 3, 4, 5, 6], SPACE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], FONT_CODE_SIZE = [0, 1, 2, 3, 4], FONT_HEADING_SIZE = [0, 1, 2, 3, 4, 5], FONT_LABEL_SIZE = [0, 1, 2, 3, 4, 5], FONT_TEXT_SIZE = [0, 1, 2, 3, 4], SHADOW = [0, 1, 2, 3, 4, 5], HUES = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"], TINTS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950], RE_PERCENTAGE = /^([0-9]+)%/, RE_OPACITY = /^(1|0\.[0-9]+)?/;
1710
- function _parseColorToken(str, options) {
1711
- const {
1712
- defaultHue
1713
- } = options;
1714
- let cursor = 0;
1715
- return parseColorNode();
1716
- function _consume(s) {
1717
- if (str.startsWith(s, cursor))
1718
- return cursor += s.length, s;
1719
- }
1720
- function _peek() {
1721
- return str[cursor];
1722
- }
1723
- function parseColorNode() {
1724
- ignoreWhitespace();
1725
- let v = _consume("black") || _consume("white");
1726
- if (v)
1727
- return {
1728
- type: "color",
1729
- name: v,
1730
- opacity: parseOpacity() ?? 1,
1731
- mix: parseMix() ?? 1
1732
- };
1733
- for (const hue of HUES)
1734
- if (v = _consume(String(hue)), v) {
1735
- if (_peek() !== "-")
1736
- throw new Error('Expected "-" after hue key');
1737
- cursor += 1;
1738
- const tint2 = parseTint();
1739
- if (!tint2)
1740
- throw new Error("Expected tint after hue");
1741
- return {
1742
- type: "tint",
1743
- hue,
1744
- tint: tint2,
1745
- opacity: parseOpacity() ?? 1,
1746
- mix: parseMix() ?? 1
1747
- };
1748
- }
1749
- const tint = parseTint();
1750
- if (tint)
1751
- return {
1752
- type: "tint",
1753
- hue: defaultHue,
1754
- tint,
1755
- opacity: parseOpacity() ?? 1,
1756
- mix: parseMix() ?? 1
1757
- };
1758
- if (str === "inherit")
1759
- return {
1760
- type: "inherit"
1761
- };
1762
- throw new Error(`Invalid color: ${str}`);
1763
- }
1764
- function parseTint() {
1765
- ignoreWhitespace();
1766
- let v = Number(str.slice(cursor, cursor + 3));
1767
- if (TINTS.includes(v))
1768
- return cursor += 3, v;
1769
- if (v = Number(str.slice(cursor, cursor + 2)), TINTS.includes(v))
1770
- return cursor += 2, v;
1771
- }
1772
- function parseMix() {
1773
- ignoreWhitespace();
1774
- const match = RE_PERCENTAGE.exec(str.slice(cursor));
1775
- if (match)
1776
- return cursor += match[0].length, parseFloat(match[1]) / 100;
1777
- }
1778
- function parseOpacity() {
1779
- if (ignoreWhitespace(), _peek() === "/") {
1780
- cursor += 1;
1781
- const match = RE_OPACITY.exec(str.slice(cursor));
1782
- if (match)
1783
- return cursor += match[0].length, parseFloat(match[1]);
1784
- cursor -= 1;
1785
- }
1786
- }
1787
- function ignoreWhitespace() {
1788
- for (; _peek() === " "; )
1789
- cursor++;
1790
- }
1791
- }
1792
- const defaultThemeFonts = {
1721
+ const defaultThemeFonts$1 = {
1793
1722
  code: {
1794
1723
  family: "ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace",
1795
- weight: {
1724
+ weights: {
1796
1725
  regular: 400,
1797
1726
  medium: 500,
1798
1727
  semibold: 600,
1799
1728
  bold: 700
1800
1729
  },
1801
- scale: [{
1730
+ sizes: [{
1802
1731
  ascenderHeight: 4,
1803
1732
  descenderHeight: 4,
1804
1733
  fontSize: 10,
1805
1734
  iconSize: 17,
1806
1735
  lineHeight: 15,
1807
- letterSpacing: 0,
1808
- customIconSize: 12
1736
+ letterSpacing: 0
1809
1737
  }, {
1810
1738
  ascenderHeight: 5,
1811
1739
  descenderHeight: 5,
1812
1740
  fontSize: 13,
1813
1741
  iconSize: 21,
1814
1742
  lineHeight: 19,
1815
- letterSpacing: 0,
1816
- customIconSize: 16
1743
+ letterSpacing: 0
1817
1744
  }, {
1818
1745
  ascenderHeight: 6,
1819
1746
  descenderHeight: 6,
1820
1747
  fontSize: 16,
1821
1748
  iconSize: 25,
1822
1749
  lineHeight: 23,
1823
- letterSpacing: 0,
1824
- customIconSize: 20
1750
+ letterSpacing: 0
1825
1751
  }, {
1826
1752
  ascenderHeight: 7,
1827
1753
  descenderHeight: 7,
1828
1754
  fontSize: 19,
1829
1755
  iconSize: 29,
1830
1756
  lineHeight: 27,
1831
- letterSpacing: 0,
1832
- customIconSize: 24
1757
+ letterSpacing: 0
1833
1758
  }, {
1834
1759
  ascenderHeight: 8,
1835
1760
  descenderHeight: 8,
1836
1761
  fontSize: 22,
1837
1762
  iconSize: 33,
1838
1763
  lineHeight: 31,
1839
- letterSpacing: 0,
1840
- customIconSize: 28
1764
+ letterSpacing: 0
1841
1765
  }]
1842
1766
  },
1843
1767
  heading: {
1844
1768
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
1845
- featureSettings: "'liga' 1, 'calt' 1, 'ss01' 1, 'ss03' 1, 'zero' 1",
1846
- weight: {
1769
+ weights: {
1847
1770
  regular: 600,
1848
1771
  medium: 700,
1849
1772
  semibold: 800,
1850
1773
  bold: 900
1851
1774
  },
1852
- scale: [{
1775
+ sizes: [{
1853
1776
  ascenderHeight: 5,
1854
1777
  descenderHeight: 5,
1855
1778
  fontSize: 13,
1856
1779
  iconSize: 17,
1857
1780
  lineHeight: 19,
1858
- letterSpacing: 0,
1859
- customIconSize: 12
1781
+ letterSpacing: 0
1860
1782
  }, {
1861
1783
  ascenderHeight: 6,
1862
1784
  descenderHeight: 6,
1863
1785
  fontSize: 16,
1864
1786
  iconSize: 25,
1865
1787
  lineHeight: 23,
1866
- letterSpacing: 0,
1867
- customIconSize: 20
1788
+ letterSpacing: 0
1868
1789
  }, {
1869
1790
  ascenderHeight: 7,
1870
1791
  descenderHeight: 7,
1871
1792
  fontSize: 21,
1872
1793
  iconSize: 33,
1873
1794
  lineHeight: 29,
1874
- letterSpacing: -0.25,
1875
- customIconSize: 28
1795
+ letterSpacing: -0.25
1876
1796
  }, {
1877
1797
  ascenderHeight: 8,
1878
1798
  descenderHeight: 8,
1879
1799
  fontSize: 27,
1880
1800
  iconSize: 41,
1881
1801
  lineHeight: 35,
1882
- letterSpacing: -0.5,
1883
- customIconSize: 36
1802
+ letterSpacing: -0.5
1884
1803
  }, {
1885
1804
  ascenderHeight: 9.5,
1886
1805
  descenderHeight: 8.5,
1887
1806
  fontSize: 33,
1888
1807
  iconSize: 49,
1889
1808
  lineHeight: 41,
1890
- letterSpacing: -1,
1891
- customIconSize: 44
1809
+ letterSpacing: -1
1892
1810
  }, {
1893
1811
  ascenderHeight: 10.5,
1894
1812
  descenderHeight: 9.5,
1895
1813
  fontSize: 38,
1896
1814
  iconSize: 53,
1897
1815
  lineHeight: 47,
1898
- letterSpacing: -1,
1899
- customIconSize: 48
1816
+ letterSpacing: -1
1900
1817
  }]
1901
1818
  },
1902
1819
  label: {
1903
1820
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
1904
- weight: {
1821
+ weights: {
1905
1822
  regular: 500,
1906
1823
  medium: 600,
1907
1824
  semibold: 700,
1908
1825
  bold: 800
1909
1826
  },
1910
- scale: [{
1827
+ sizes: [{
1911
1828
  ascenderHeight: 2,
1912
1829
  descenderHeight: 2,
1913
1830
  fontSize: 8.1,
1914
1831
  iconSize: 13,
1915
1832
  lineHeight: 10,
1916
- letterSpacing: 0.5,
1917
- customIconSize: 8
1833
+ letterSpacing: 0.5
1918
1834
  }, {
1919
1835
  ascenderHeight: 1.5,
1920
1836
  descenderHeight: 2.5,
1921
1837
  fontSize: 9.5,
1922
1838
  iconSize: 15,
1923
1839
  lineHeight: 11,
1924
- letterSpacing: 0.5,
1925
- customIconSize: 10
1840
+ letterSpacing: 0.5
1926
1841
  }, {
1927
1842
  ascenderHeight: 2,
1928
1843
  descenderHeight: 2,
1929
1844
  fontSize: 10.8,
1930
1845
  iconSize: 17,
1931
1846
  lineHeight: 12,
1932
- letterSpacing: 0.5,
1933
- customIconSize: 12
1847
+ letterSpacing: 0.5
1934
1848
  }, {
1935
1849
  ascenderHeight: 2,
1936
1850
  descenderHeight: 2,
1937
1851
  fontSize: 12.25,
1938
1852
  iconSize: 19,
1939
1853
  lineHeight: 13,
1940
- letterSpacing: 0.5,
1941
- customIconSize: 14
1854
+ letterSpacing: 0.5
1942
1855
  }, {
1943
1856
  ascenderHeight: 1.5,
1944
1857
  descenderHeight: 2.5,
1945
1858
  fontSize: 13.6,
1946
1859
  iconSize: 21,
1947
1860
  lineHeight: 14,
1948
- letterSpacing: 0.5,
1949
- customIconSize: 16
1861
+ letterSpacing: 0.5
1950
1862
  }, {
1951
1863
  ascenderHeight: 2,
1952
1864
  descenderHeight: 2,
1953
1865
  fontSize: 15,
1954
1866
  iconSize: 23,
1955
1867
  lineHeight: 15,
1956
- letterSpacing: 0.5,
1957
- customIconSize: 18
1868
+ letterSpacing: 0.5
1958
1869
  }]
1959
1870
  },
1960
1871
  text: {
1961
1872
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
1962
- weight: {
1873
+ weights: {
1963
1874
  regular: 400,
1964
1875
  medium: 500,
1965
1876
  semibold: 600,
1966
1877
  bold: 700
1967
1878
  },
1968
- scale: [{
1879
+ sizes: [{
1969
1880
  ascenderHeight: 4,
1970
1881
  descenderHeight: 4,
1971
1882
  fontSize: 10,
1972
1883
  iconSize: 17,
1973
1884
  lineHeight: 15,
1974
- letterSpacing: 0,
1975
- customIconSize: 12
1885
+ letterSpacing: 0
1976
1886
  }, {
1977
1887
  ascenderHeight: 5,
1978
1888
  descenderHeight: 5,
1979
1889
  fontSize: 13,
1980
1890
  iconSize: 21,
1981
1891
  lineHeight: 19,
1982
- letterSpacing: 0,
1983
- customIconSize: 16
1892
+ letterSpacing: 0
1984
1893
  }, {
1985
1894
  ascenderHeight: 6,
1986
1895
  descenderHeight: 6,
1987
1896
  fontSize: 15,
1988
1897
  iconSize: 25,
1989
1898
  lineHeight: 23,
1990
- letterSpacing: 0,
1991
- customIconSize: 20
1899
+ letterSpacing: 0
1992
1900
  }, {
1993
1901
  ascenderHeight: 7,
1994
1902
  descenderHeight: 7,
1995
1903
  fontSize: 18,
1996
1904
  iconSize: 29,
1997
1905
  lineHeight: 27,
1998
- letterSpacing: 0,
1999
- customIconSize: 24
1906
+ letterSpacing: 0
2000
1907
  }, {
2001
1908
  ascenderHeight: 8,
2002
1909
  descenderHeight: 8,
2003
1910
  fontSize: 21,
2004
1911
  iconSize: 33,
2005
1912
  lineHeight: 31,
2006
- letterSpacing: 0,
2007
- customIconSize: 28
1913
+ letterSpacing: 0
2008
1914
  }]
2009
1915
  }
2010
- }, defaultTokens = {
2011
- color: {
2012
- "*": {
2013
- backdrop: ["gray-100/0.5", "black/0.5"],
2014
- code: {
2015
- bg: ["50", "950"],
2016
- fg: ["700", "300"],
2017
- token: {
2018
- atrule: ["purple-600", "purple-400"],
2019
- attrName: ["green-600", "green-400"],
2020
- attrValue: ["yellow-600", "yellow-400"],
2021
- attribute: ["yellow-600", "yellow-400"],
2022
- boolean: ["purple-600", "purple-400"],
2023
- builtin: ["purple-600", "purple-400"],
2024
- cdata: ["yellow-600", "yellow-400"],
2025
- char: ["yellow-600", "yellow-400"],
2026
- class: ["orange-600", "orange-400"],
2027
- className: ["cyan-600", "cyan-400"],
2028
- comment: ["gray-400", "gray-600"],
2029
- constant: ["purple-600", "purple-400"],
2030
- deleted: ["red-600", "red-400"],
2031
- entity: ["red-600", "red-400"],
2032
- function: ["green-600", "green-400"],
2033
- hexcode: ["blue-600", "blue-400"],
2034
- id: ["purple-600", "purple-400"],
2035
- important: ["purple-600", "purple-400"],
2036
- inserted: ["green-600", "green-400"],
2037
- keyword: ["magenta-600", "magenta-400"],
2038
- number: ["purple-600", "purple-400"],
2039
- operator: ["magenta-600", "magenta-400"],
2040
- prolog: ["gray-600", "gray-400"],
2041
- property: ["blue-600", "blue-400"],
2042
- pseudoClass: ["yellow-600", "yellow-400"],
2043
- pseudoElement: ["yellow-600", "yellow-400"],
2044
- punctuation: ["gray-600", "gray-400"],
2045
- regex: ["blue-600", "blue-400"],
2046
- selector: ["red-600", "red-400"],
2047
- string: ["yellow-600", "yellow-400"],
2048
- symbol: ["purple-600", "purple-400"],
2049
- tag: ["red-600", "red-400"],
2050
- unit: ["orange-600", "orange-400"],
2051
- url: ["red-600", "red-400"],
2052
- variable: ["red-600", "red-400"]
2053
- }
2054
- },
2055
- focusRing: ["blue-500", "blue-500"],
2056
- link: {
2057
- fg: ["blue-600", "blue-400"]
2058
- },
2059
- shadow: {
2060
- outline: ["600/0.3", "500/0.4"],
2061
- umbra: ["600/0.1", "black/0.2"],
2062
- penumbra: ["600/0.07", "black/0.14"],
2063
- ambient: ["600/0.06", "black/0.12"]
2064
- },
2065
- skeleton: {
2066
- from: ["200 70%", "800 35%"],
2067
- to: ["200 40%", "800 50%"]
2068
- },
2069
- variant: {
2070
- tinted: {
2071
- "*": {
2072
- bg: {
2073
- 0: ["100 75%", "900 75%"],
2074
- 4: ["300", "700"]
2075
- },
2076
- border: {
2077
- 0: ["200", "700 50%"],
2078
- 4: ["300 75%", "500"]
2079
- },
2080
- fg: {
2081
- 0: ["900", "100"],
2082
- 4: ["700", "300"]
2083
- }
2084
- },
2085
- primary: {
2086
- _hue: "blue",
2087
- bg: {
2088
- 0: ["inherit", "inherit"]
2089
- }
2090
- },
2091
- suggest: {
2092
- _hue: "purple",
2093
- bg: {
2094
- 0: ["inherit", "inherit"]
2095
- }
2096
- },
2097
- positive: {
2098
- _hue: "green",
2099
- bg: {
2100
- 0: ["inherit", "inherit"]
2101
- }
2102
- },
2103
- caution: {
2104
- _hue: "yellow",
2105
- bg: {
2106
- 0: ["inherit", "inherit"]
2107
- }
2108
- },
2109
- critical: {
2110
- _hue: "red",
2111
- bg: {
2112
- 0: ["inherit", "inherit"]
2113
- }
2114
- }
2115
- },
2116
- solid: {
2117
- "*": {
2118
- bg: {
2119
- 0: ["500", "400"],
2120
- 4: ["600", "300"]
2121
- },
2122
- border: {
2123
- 0: ["400", "200"],
2124
- 4: ["500", "100"]
2125
- },
2126
- fg: {
2127
- 0: ["white", "black"],
2128
- 4: ["200", "700"]
2129
- }
2130
- },
2131
- default: {
2132
- bg: {
2133
- 0: ["800", "200"],
2134
- 4: ["black", "white"]
2135
- },
2136
- border: {
2137
- 0: ["700", "300"],
2138
- 4: ["800", "200"]
2139
- }
2140
- },
2141
- primary: {
2142
- _hue: "blue"
2143
- },
2144
- suggest: {
2145
- _hue: "purple"
2146
- },
2147
- positive: {
2148
- _hue: "green"
2149
- },
2150
- caution: {
2151
- _hue: "yellow"
2152
- },
2153
- critical: {
2154
- _hue: "red"
2155
- }
1916
+ }, THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = [
1917
+ "transparent",
1918
+ "default",
1919
+ "neutral",
1920
+ "primary",
1921
+ // deprecated
1922
+ "suggest",
1923
+ "positive",
1924
+ "caution",
1925
+ "critical"
1926
+ ], THEME_COLOR_STATE_TONES = [
1927
+ "default",
1928
+ "neutral",
1929
+ "primary",
1930
+ // deprecated
1931
+ "suggest",
1932
+ "positive",
1933
+ "caution",
1934
+ "critical"
1935
+ ], THEME_COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"], THEME_COLOR_BUTTON_MODES = ["default", "ghost", "bleed"], THEME_COLOR_INPUT_MODES = ["default", "invalid"], THEME_COLOR_INPUT_STATES = ["enabled", "hovered", "readOnly", "disabled"], THEME_COLOR_AVATAR_COLORS = COLOR_HUES;
1936
+ function isColorBlendModeValue(str) {
1937
+ return THEME_COLOR_BLEND_MODES.includes(str);
1938
+ }
1939
+ function isColorHueKey(str) {
1940
+ return COLOR_HUES.includes(str);
1941
+ }
1942
+ function isColorTintKey(str) {
1943
+ return COLOR_TINTS.includes(str);
1944
+ }
1945
+ function isColorButtonMode(str) {
1946
+ return THEME_COLOR_BUTTON_MODES.includes(str);
1947
+ }
1948
+ const COLOR_CONFIG_STATE_KEYS = ["_hue", "bg", "fg", "border", "focusRing", "muted/fg", "accent/fg", "link/fg", "code/bg", "code/fg", "skeleton/from", "skeleton/to", "status/dot", "status/icon"], COLOR_CONFIG_CARD_KEYS = [...COLOR_CONFIG_STATE_KEYS, "_hue", "bg", "fg", "border", "focusRing", "shadow/outline", "shadow/umbra", "shadow/penumbra", "shadow/ambient"], COLOR_CONFIG_BLEND_KEYS = ["_blend"], COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
1949
+ function isColorConfigBaseTone(str) {
1950
+ return COLOR_CONFIG_CARD_TONES.includes(str);
1951
+ }
1952
+ function isColorConfigBaseKey(str) {
1953
+ return COLOR_CONFIG_CARD_KEYS.includes(str);
1954
+ }
1955
+ function isColorConfigStateKey(str) {
1956
+ return COLOR_CONFIG_STATE_KEYS.includes(str);
1957
+ }
1958
+ function isColorConfigStateTone(str) {
1959
+ return COLOR_CONFIG_STATE_TONES.includes(str);
1960
+ }
1961
+ function isColorConfigBlendKey(str) {
1962
+ return COLOR_CONFIG_BLEND_KEYS.includes(str);
1963
+ }
1964
+ function isColorValue(str) {
1965
+ return str === "black" || str === "white";
1966
+ }
1967
+ function isColorOpacityValue(str) {
1968
+ return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
1969
+ }
1970
+ function isColorMixPercentValue(str) {
1971
+ return /^\d+%$/.test(str);
1972
+ }
1973
+ function parseTokenValue(str) {
1974
+ const segments = str.split("/");
1975
+ let nextSegment = segments.shift() || "";
1976
+ const [segment0, segment0mix] = nextSegment.split(" ");
1977
+ if (isColorTintKey(segment0)) {
1978
+ const tint = segment0, segment1 = segments.shift() || "";
1979
+ if (isColorMixPercentValue(segment0mix)) {
1980
+ const mix2 = Number(segment0mix.slice(0, -1)) / 100;
1981
+ return {
1982
+ type: "color",
1983
+ tint,
1984
+ mix: mix2
1985
+ };
1986
+ }
1987
+ if (isColorOpacityValue(segment1)) {
1988
+ const opacity = Number(segment1);
1989
+ return {
1990
+ type: "color",
1991
+ tint,
1992
+ opacity
1993
+ };
1994
+ }
1995
+ return {
1996
+ type: "color",
1997
+ tint
1998
+ };
1999
+ }
2000
+ if (isColorValue(segment0)) {
2001
+ const key = segment0, segment1 = segments.shift() || "";
2002
+ if (isColorMixPercentValue(segment0mix)) {
2003
+ const mix2 = Number(segment0mix.slice(0, -1)) / 100;
2004
+ return {
2005
+ type: "color",
2006
+ key,
2007
+ mix: mix2
2008
+ };
2009
+ }
2010
+ if (isColorOpacityValue(segment1)) {
2011
+ const opacity = Number(segment1);
2012
+ return {
2013
+ type: "color",
2014
+ key,
2015
+ opacity
2016
+ };
2017
+ }
2018
+ return {
2019
+ type: "color",
2020
+ key
2021
+ };
2022
+ }
2023
+ if (isColorHueKey(segment0)) {
2024
+ const hue = segment0;
2025
+ nextSegment = segments.shift() || "";
2026
+ const [segment1, segment1mix] = nextSegment.split(" ");
2027
+ if (isColorTintKey(segment1)) {
2028
+ const tint = segment1, segment2 = segments.shift() || "";
2029
+ if (isColorMixPercentValue(segment1mix)) {
2030
+ const mix2 = Number(segment1mix.slice(0, -1)) / 100;
2031
+ return {
2032
+ type: "color",
2033
+ hue,
2034
+ tint,
2035
+ mix: mix2
2036
+ };
2037
+ }
2038
+ if (isColorOpacityValue(segment2)) {
2039
+ const opacity = Number(segment2);
2040
+ return {
2041
+ type: "color",
2042
+ hue,
2043
+ tint,
2044
+ opacity
2045
+ };
2046
+ }
2047
+ return {
2048
+ type: "color",
2049
+ hue,
2050
+ tint
2051
+ };
2052
+ }
2053
+ return {
2054
+ type: "hue",
2055
+ value: hue
2056
+ };
2057
+ }
2058
+ if (isColorBlendModeValue(segment0))
2059
+ return {
2060
+ type: "blendMode",
2061
+ value: segment0
2062
+ };
2063
+ }
2064
+ function compileColorTokenValue(node) {
2065
+ let key = "";
2066
+ return node.key === "black" || node.key === "white" ? key = node.key : key = `${node.hue}/${node.tint}`, node.mix !== void 0 ? `${key} ${node.mix * 100}%` : (node.opacity !== void 0 && (key += `/${node.opacity}`), key);
2067
+ }
2068
+ const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
2069
+ function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
2070
+ const {
2071
+ hue,
2072
+ scheme
2073
+ } = context, node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
2074
+ if (!node || node.type !== "color")
2075
+ throw new Error(`Invalid color token: ${value[0]}`);
2076
+ return compileColorTokenValue({
2077
+ ...node,
2078
+ hue: node.hue || hue
2079
+ });
2080
+ }
2081
+ const defaultColorTokens = {
2082
+ base: {
2083
+ "*": {
2084
+ _blend: ["multiply", "screen"],
2085
+ accent: {
2086
+ fg: ["purple/600", "purple/400"]
2087
+ },
2088
+ avatar: {
2089
+ "*": {
2090
+ _blend: ["screen", "multiply"],
2091
+ bg: ["500", "400"],
2092
+ fg: ["white", "black"]
2093
+ }
2094
+ },
2095
+ backdrop: ["gray/200/0.5", "black/0.5"],
2096
+ badge: {
2097
+ "*": {
2098
+ bg: ["100", "900"],
2099
+ fg: ["600", "400"],
2100
+ icon: ["500", "500"],
2101
+ dot: ["500", "500"]
2102
+ },
2103
+ positive: {
2104
+ bg: ["200 50%", "900"],
2105
+ fg: ["600", "500"]
2106
+ },
2107
+ caution: {
2108
+ bg: ["200 50%", "900"],
2109
+ fg: ["600", "500"]
2156
2110
  }
2111
+ },
2112
+ bg: ["50", "950"],
2113
+ border: ["200", "800"],
2114
+ code: {
2115
+ bg: ["50", "950"],
2116
+ fg: ["600", "400"]
2117
+ },
2118
+ fg: ["800", "200"],
2119
+ focusRing: ["blue/500", "blue/500"],
2120
+ icon: ["600", "400"],
2121
+ kbd: {
2122
+ bg: ["white", "black"],
2123
+ fg: ["600", "400"],
2124
+ border: ["200", "800"]
2125
+ },
2126
+ link: {
2127
+ fg: ["blue/600", "blue/300"]
2128
+ },
2129
+ muted: {
2130
+ bg: ["50", "950"],
2131
+ fg: ["700 75%", "300 75%"]
2132
+ },
2133
+ shadow: {
2134
+ outline: ["500/0.3", "500/0.4"],
2135
+ umbra: ["gray/500/0.1", "black/0.2"],
2136
+ penumbra: ["gray/500/0.07", "black/0.14"],
2137
+ ambient: ["gray/500/0.06", "black/0.12"]
2138
+ },
2139
+ skeleton: {
2140
+ from: ["100", "900"],
2141
+ to: ["100 50%", "900 50%"]
2157
2142
  }
2158
2143
  },
2159
2144
  transparent: {
2160
- variant: {
2161
- tinted: {
2162
- "*": {
2163
- bg: {
2164
- 0: ["gray-50", "black"],
2165
- 4: ["200", "800"]
2166
- },
2167
- border: {
2168
- 0: ["200 50%", "800 50%"],
2169
- 4: ["300", "600"]
2170
- },
2171
- fg: {
2172
- 0: ["black", "100"],
2173
- 4: ["700", "400"]
2174
- }
2175
- }
2176
- }
2177
- }
2145
+ bg: ["50", "black"]
2178
2146
  },
2179
2147
  default: {
2180
- variant: {
2181
- tinted: {
2182
- "*": {
2183
- bg: {
2184
- 0: ["white", "950"],
2185
- 4: ["200", "800"]
2186
- },
2187
- border: {
2188
- 0: ["200 50%", "800 50%"],
2189
- 4: ["300 75%", "600"]
2190
- },
2191
- fg: {
2192
- 0: ["black", "white"],
2193
- 4: ["600", "400"]
2194
- }
2195
- }
2196
- }
2148
+ bg: ["white", "950"],
2149
+ fg: ["800", "200"],
2150
+ muted: {
2151
+ fg: ["600", "400"]
2197
2152
  }
2198
2153
  },
2199
2154
  primary: {
@@ -2203,722 +2158,1277 @@ const defaultThemeFonts = {
2203
2158
  _hue: "purple"
2204
2159
  },
2205
2160
  positive: {
2206
- _hue: "green"
2161
+ _hue: "green",
2162
+ shadow: {
2163
+ outline: ["500/0.4", "500/0.4"]
2164
+ }
2207
2165
  },
2208
2166
  caution: {
2209
- _hue: "yellow"
2167
+ _hue: "yellow",
2168
+ shadow: {
2169
+ outline: ["600/0.3", "500/0.4"]
2170
+ }
2210
2171
  },
2211
2172
  critical: {
2212
2173
  _hue: "red"
2213
2174
  }
2214
- }
2215
- };
2216
- function merge(...records) {
2217
- return records.filter(Boolean).reduce(_merge, {});
2218
- }
2219
- function _merge(acc, source) {
2220
- for (const key of Object.keys(source)) {
2221
- const prevValue = acc[key], nextValue = source[key];
2222
- isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
2223
- }
2224
- return acc;
2225
- }
2226
- function isRecord(value) {
2227
- return value !== null && typeof value == "object" && !Array.isArray(value);
2228
- }
2229
- const defaultElementTokens = {
2230
- bg: {
2231
- 0: ["950", "50"],
2232
- 4: ["700", "300"]
2233
- },
2234
- border: {
2235
- 0: ["700", "300"],
2236
- 4: ["400", "600"]
2237
2175
  },
2238
- fg: {
2239
- 0: ["100", "900"],
2240
- 4: ["400", "600"]
2241
- }
2242
- };
2243
- function resolveTokens(tokens = {}) {
2244
- return {
2245
- color: {
2246
- "*": resolveCardColorTokens(tokens.color?.["*"]),
2247
- ...THEME_COLOR_CARD_TONES.reduce((acc, tone) => ({
2248
- ...acc,
2249
- [tone]: resolveCardColorTokens(merge(tokens.color?.["*"], tokens.color?.[tone]))
2250
- }), {})
2251
- }
2252
- };
2253
- }
2254
- function resolveCardColorTokens(tokens) {
2255
- return {
2256
- _hue: tokens?._hue ?? "gray",
2257
- avatar: {
2258
- gray: {
2259
- _hue: tokens?.avatar?.gray?._hue ?? "gray",
2260
- bg: tokens?.avatar?.gray?.bg ?? ["500", "400"],
2261
- fg: tokens?.avatar?.gray?.fg ?? ["white", "900"]
2176
+ button: {
2177
+ default: {
2178
+ "*": {
2179
+ "*": {
2180
+ _blend: ["screen", "multiply"],
2181
+ accent: {
2182
+ fg: ["purple/300", "purple/700"]
2183
+ },
2184
+ avatar: {
2185
+ "*": {
2186
+ _blend: ["screen", "multiply"],
2187
+ bg: ["500", "400"],
2188
+ fg: ["white", "black"]
2189
+ }
2190
+ },
2191
+ badge: {
2192
+ "*": {
2193
+ bg: ["900", "100"],
2194
+ fg: ["400", "600"],
2195
+ dot: ["500", "500"],
2196
+ icon: ["500", "500"]
2197
+ }
2198
+ },
2199
+ bg: ["500", "400"],
2200
+ border: ["500/0", "400/0"],
2201
+ code: {
2202
+ bg: ["500 20%", "400 20%"],
2203
+ fg: ["200", "600"]
2204
+ },
2205
+ fg: ["white", "black"],
2206
+ icon: ["100 70%", "900 70%"],
2207
+ kbd: {
2208
+ bg: ["black", "white"],
2209
+ fg: ["200", "600"],
2210
+ border: ["800", "200"]
2211
+ },
2212
+ link: {
2213
+ fg: ["blue/200", "blue/600"]
2214
+ },
2215
+ muted: {
2216
+ bg: ["950", "50"],
2217
+ fg: ["100 70%", "900 70%"]
2218
+ },
2219
+ skeleton: {
2220
+ from: ["900", "100"],
2221
+ to: ["900 50%", "100 50%"]
2222
+ }
2223
+ },
2224
+ hovered: {
2225
+ bg: ["600", "300"],
2226
+ border: ["700/0", "300/0"]
2227
+ },
2228
+ pressed: {
2229
+ bg: ["700", "300"]
2230
+ },
2231
+ selected: {
2232
+ bg: ["700", "300"]
2233
+ },
2234
+ disabled: {
2235
+ _hue: "gray",
2236
+ accent: {
2237
+ fg: ["100 70%", "900 70%"]
2238
+ },
2239
+ avatar: {
2240
+ "*": {
2241
+ _blend: ["screen", "multiply"],
2242
+ bg: ["gray/500", "gray/400"],
2243
+ fg: ["white", "black"]
2244
+ }
2245
+ },
2246
+ badge: {
2247
+ "*": {
2248
+ bg: ["gray/700", "gray/300"],
2249
+ fg: ["white", "black"],
2250
+ dot: ["white", "black"],
2251
+ icon: ["white", "black"]
2252
+ }
2253
+ },
2254
+ bg: ["300", "600"],
2255
+ code: {
2256
+ bg: ["950", "50"],
2257
+ fg: ["300", "600"]
2258
+ },
2259
+ fg: ["300", "600"],
2260
+ muted: {
2261
+ bg: ["950", "50"],
2262
+ fg: ["300", "600"]
2263
+ },
2264
+ kbd: {
2265
+ bg: ["black", "white"],
2266
+ fg: ["white", "black"],
2267
+ border: ["700", "300"]
2268
+ },
2269
+ link: {
2270
+ fg: ["100 70%", "900 70%"]
2271
+ }
2272
+ }
2262
2273
  },
2263
- blue: {
2264
- _hue: tokens?.avatar?.blue?._hue ?? "blue",
2265
- bg: tokens?.avatar?.blue?.bg ?? ["500", "400"],
2266
- fg: tokens?.avatar?.blue?.fg ?? ["white", "900"]
2274
+ default: {
2275
+ "*": {
2276
+ avatar: {
2277
+ "*": {
2278
+ _blend: ["screen", "multiply"],
2279
+ bg: ["500", "400"],
2280
+ fg: ["white", "black"]
2281
+ }
2282
+ },
2283
+ bg: ["800", "200"],
2284
+ muted: {
2285
+ bg: ["950", "50"],
2286
+ fg: ["400", "600"]
2287
+ }
2288
+ },
2289
+ hovered: {
2290
+ bg: ["900", "100"]
2291
+ },
2292
+ pressed: {
2293
+ bg: ["black", "white"]
2294
+ },
2295
+ selected: {
2296
+ bg: ["black", "white"]
2297
+ }
2298
+ }
2299
+ },
2300
+ ghost: {
2301
+ "*": {
2302
+ "*": {
2303
+ _blend: ["multiply", "screen"],
2304
+ accent: {
2305
+ fg: ["purple/700 60%", "purple/300 70%"]
2306
+ },
2307
+ avatar: {
2308
+ "*": {
2309
+ _blend: ["screen", "multiply"],
2310
+ bg: ["500", "400"],
2311
+ fg: ["white", "black"]
2312
+ }
2313
+ },
2314
+ badge: {
2315
+ "*": {
2316
+ bg: ["100", "900"],
2317
+ fg: ["600", "400"],
2318
+ dot: ["500", "500"],
2319
+ icon: ["500", "500"]
2320
+ }
2321
+ },
2322
+ bg: ["50", "950"],
2323
+ border: ["100", "900"],
2324
+ code: {
2325
+ bg: ["500 10%", "400 10%"],
2326
+ fg: ["700 60%", "400 60%"]
2327
+ },
2328
+ fg: ["600", "400"],
2329
+ icon: ["700 60%", "300 60%"],
2330
+ kbd: {
2331
+ bg: ["white", "black"],
2332
+ fg: ["600", "400"],
2333
+ border: ["200", "800"]
2334
+ },
2335
+ link: {
2336
+ fg: ["blue/700 60%", "blue/300 60%"]
2337
+ },
2338
+ muted: {
2339
+ bg: ["100", "950"],
2340
+ fg: ["700 60%", "300 60%"]
2341
+ },
2342
+ skeleton: {
2343
+ from: ["100", "900"],
2344
+ to: ["100 50%", "900 50%"]
2345
+ }
2346
+ },
2347
+ hovered: {
2348
+ bg: ["100", "900"],
2349
+ fg: ["700", "300"]
2350
+ },
2351
+ pressed: {
2352
+ bg: ["200", "800"],
2353
+ fg: ["800", "200"]
2354
+ },
2355
+ selected: {
2356
+ bg: ["200", "800"],
2357
+ fg: ["800", "200"]
2358
+ },
2359
+ disabled: {
2360
+ _hue: "gray",
2361
+ accent: {
2362
+ fg: ["200", "800"]
2363
+ },
2364
+ avatar: {
2365
+ "*": {
2366
+ _blend: ["screen", "multiply"],
2367
+ bg: ["gray/100", "gray/900"],
2368
+ fg: ["white", "black"]
2369
+ }
2370
+ },
2371
+ badge: {
2372
+ "*": {
2373
+ _hue: "gray",
2374
+ bg: ["50", "950"],
2375
+ fg: ["gray/200", "gray/800"],
2376
+ dot: ["gray/200", "gray/800"],
2377
+ icon: ["gray/200", "gray/800"]
2378
+ }
2379
+ },
2380
+ border: ["100", "900"],
2381
+ code: {
2382
+ bg: ["50", "950"],
2383
+ fg: ["200", "800"]
2384
+ },
2385
+ fg: ["400", "600"],
2386
+ icon: ["300", "700"],
2387
+ muted: {
2388
+ fg: ["300", "700"]
2389
+ },
2390
+ kbd: {
2391
+ bg: ["white", "black"],
2392
+ fg: ["200", "800"],
2393
+ border: ["100", "900"]
2394
+ },
2395
+ link: {
2396
+ fg: ["200", "800"]
2397
+ }
2398
+ }
2267
2399
  },
2268
- purple: {
2269
- _hue: tokens?.avatar?.purple?._hue ?? "purple",
2270
- bg: tokens?.avatar?.purple?.bg ?? ["500", "400"],
2271
- fg: tokens?.avatar?.purple?.fg ?? ["white", "900"]
2400
+ positive: {
2401
+ "*": {
2402
+ border: ["600 20%", "800"]
2403
+ }
2272
2404
  },
2273
- magenta: {
2274
- _hue: tokens?.avatar?.magenta?._hue ?? "magenta",
2275
- bg: tokens?.avatar?.magenta?.bg ?? ["500", "400"],
2276
- fg: tokens?.avatar?.magenta?.fg ?? ["white", "900"]
2405
+ caution: {
2406
+ "*": {
2407
+ border: ["600 20%", "800"]
2408
+ }
2409
+ }
2410
+ },
2411
+ bleed: {
2412
+ "*": {
2413
+ "*": {
2414
+ _blend: ["multiply", "screen"],
2415
+ accent: {
2416
+ fg: ["purple/700 70%", "purple/300 70%"]
2417
+ },
2418
+ avatar: {
2419
+ "*": {
2420
+ _blend: ["screen", "multiply"],
2421
+ bg: ["500", "400"],
2422
+ fg: ["white", "black"]
2423
+ }
2424
+ },
2425
+ badge: {
2426
+ "*": {
2427
+ bg: ["100", "900"],
2428
+ fg: ["600", "400"],
2429
+ dot: ["500", "500"],
2430
+ icon: ["500", "500"]
2431
+ }
2432
+ },
2433
+ bg: ["white", "black"],
2434
+ border: ["white/0", "black/0"],
2435
+ code: {
2436
+ bg: ["50", "950"],
2437
+ fg: ["700 75%", "300 75%"]
2438
+ },
2439
+ fg: ["700", "300"],
2440
+ icon: ["700 75%", "300 75%"],
2441
+ kbd: {
2442
+ bg: ["white", "black"],
2443
+ fg: ["700", "300"],
2444
+ border: ["200", "800"]
2445
+ },
2446
+ link: {
2447
+ fg: ["blue/700 70%", "blue/300 70%"]
2448
+ },
2449
+ muted: {
2450
+ bg: ["100", "950"],
2451
+ fg: ["700 75%", "300 75%"]
2452
+ },
2453
+ skeleton: {
2454
+ from: ["100", "900"],
2455
+ to: ["100 50%", "900 50%"]
2456
+ }
2457
+ },
2458
+ hovered: {
2459
+ bg: ["50", "900"],
2460
+ fg: ["800", "200"],
2461
+ icon: ["800 70%", "300 70%"]
2462
+ },
2463
+ pressed: {
2464
+ bg: ["100", "800"],
2465
+ fg: ["800", "200"],
2466
+ icon: ["800 70%", "200 70%"]
2467
+ },
2468
+ selected: {
2469
+ bg: ["100", "900"],
2470
+ fg: ["800", "200"],
2471
+ icon: ["800 60%", "200 60%"]
2472
+ },
2473
+ disabled: {
2474
+ _hue: "gray",
2475
+ accent: {
2476
+ fg: ["200", "800"]
2477
+ },
2478
+ avatar: {
2479
+ "*": {
2480
+ _blend: ["screen", "multiply"],
2481
+ bg: ["gray/100", "gray/900"],
2482
+ fg: ["white", "black"]
2483
+ }
2484
+ },
2485
+ badge: {
2486
+ "*": {
2487
+ _hue: "gray",
2488
+ bg: ["50", "950"],
2489
+ fg: ["gray/200", "gray/800"],
2490
+ dot: ["gray/200", "gray/800"],
2491
+ icon: ["gray/200", "gray/800"]
2492
+ }
2493
+ },
2494
+ code: {
2495
+ bg: ["50", "950"],
2496
+ fg: ["200", "800"]
2497
+ },
2498
+ fg: ["400", "600"],
2499
+ icon: ["300", "700"],
2500
+ muted: {
2501
+ fg: ["400", "600"]
2502
+ },
2503
+ kbd: {
2504
+ bg: ["white", "black"],
2505
+ fg: ["200", "800"],
2506
+ border: ["100", "900"]
2507
+ },
2508
+ link: {
2509
+ fg: ["200", "800"]
2510
+ }
2511
+ }
2512
+ }
2513
+ }
2514
+ },
2515
+ input: {
2516
+ "*": {
2517
+ "*": {
2518
+ _blend: ["multiply", "screen"],
2519
+ bg: ["white", "black"],
2520
+ border: ["200", "700"],
2521
+ fg: ["black", "200"],
2522
+ muted: {
2523
+ bg: ["50", "950"]
2524
+ },
2525
+ placeholder: ["400", "600"]
2277
2526
  },
2278
- red: {
2279
- _hue: tokens?.avatar?.red?._hue ?? "red",
2280
- bg: tokens?.avatar?.red?.bg ?? ["500", "400"],
2281
- fg: tokens?.avatar?.red?.fg ?? ["white", "900"]
2527
+ hovered: {
2528
+ border: ["300", "700"]
2282
2529
  },
2283
- orange: {
2284
- _hue: tokens?.avatar?.orange?._hue ?? "orange",
2285
- bg: tokens?.avatar?.orange?.bg ?? ["500", "400"],
2286
- fg: tokens?.avatar?.orange?.fg ?? ["white", "900"]
2530
+ readOnly: {
2531
+ bg: ["50", "950"],
2532
+ border: ["200", "800"],
2533
+ fg: ["800", "200"]
2287
2534
  },
2288
- yellow: {
2289
- _hue: tokens?.avatar?.yellow?._hue ?? "yellow",
2290
- bg: tokens?.avatar?.yellow?.bg ?? ["500", "400"],
2291
- fg: tokens?.avatar?.yellow?.fg ?? ["white", "900"]
2535
+ disabled: {
2536
+ bg: ["50", "950"],
2537
+ fg: ["400", "600"],
2538
+ border: ["100", "900"],
2539
+ placeholder: ["200", "800 50%"]
2540
+ }
2541
+ },
2542
+ invalid: {
2543
+ "*": {
2544
+ _hue: "red",
2545
+ bg: ["100", "950"]
2546
+ }
2547
+ }
2548
+ },
2549
+ selectable: {
2550
+ "*": {
2551
+ "*": {
2552
+ _blend: ["multiply", "screen"],
2553
+ accent: {
2554
+ fg: ["purple/700 70%", "purple/300 70%"]
2555
+ },
2556
+ avatar: {
2557
+ "*": {
2558
+ _blend: ["screen", "multiply"],
2559
+ bg: ["500", "400"],
2560
+ fg: ["white", "black"]
2561
+ }
2562
+ },
2563
+ badge: {
2564
+ "*": {
2565
+ bg: ["100", "900"],
2566
+ fg: ["600", "400"],
2567
+ dot: ["500", "500"],
2568
+ icon: ["500", "500"]
2569
+ }
2570
+ },
2571
+ bg: ["white", "black"],
2572
+ border: ["200", "800"],
2573
+ code: {
2574
+ bg: ["50", "950"],
2575
+ fg: ["600", "400"]
2576
+ },
2577
+ fg: ["700", "300"],
2578
+ icon: ["700 75%", "300 75%"],
2579
+ kbd: {
2580
+ bg: ["white", "black"],
2581
+ fg: ["600", "400"],
2582
+ border: ["200", "800"]
2583
+ },
2584
+ link: {
2585
+ fg: ["blue/700 70%", "blue/300 70%"]
2586
+ },
2587
+ muted: {
2588
+ bg: ["50", "950"],
2589
+ fg: ["700 75%", "300 75%"]
2590
+ },
2591
+ skeleton: {
2592
+ from: ["100", "900"],
2593
+ to: ["100 50%", "900 50%"]
2594
+ }
2292
2595
  },
2293
- green: {
2294
- _hue: tokens?.avatar?.green?._hue ?? "green",
2295
- bg: tokens?.avatar?.green?.bg ?? ["500", "400"],
2296
- fg: tokens?.avatar?.green?.fg ?? ["white", "900"]
2596
+ hovered: {
2597
+ bg: ["50", "950"]
2297
2598
  },
2298
- cyan: {
2299
- _hue: tokens?.avatar?.cyan?._hue ?? "cyan",
2300
- bg: tokens?.avatar?.cyan?.bg ?? ["500", "400"],
2301
- fg: tokens?.avatar?.cyan?.fg ?? ["white", "900"]
2599
+ pressed: {
2600
+ bg: ["100", "900"]
2601
+ },
2602
+ selected: {
2603
+ _blend: ["screen", "multiply"],
2604
+ accent: {
2605
+ fg: ["purple/300", "purple/700"]
2606
+ },
2607
+ avatar: {
2608
+ "*": {
2609
+ _blend: ["multiply", "screen"],
2610
+ bg: ["white", "black"],
2611
+ fg: ["black", "white"]
2612
+ }
2613
+ },
2614
+ badge: {
2615
+ "*": {
2616
+ bg: ["900", "100"],
2617
+ fg: ["400", "600"],
2618
+ dot: ["500", "500"],
2619
+ icon: ["500", "500"]
2620
+ }
2621
+ },
2622
+ bg: ["500", "400"],
2623
+ border: ["500 20%", "400 20%"],
2624
+ code: {
2625
+ bg: ["500 20%", "400 20%"],
2626
+ fg: ["200", "600"]
2627
+ },
2628
+ fg: ["white", "black"],
2629
+ icon: ["100 70%", "900 70%"],
2630
+ kbd: {
2631
+ bg: ["black", "white"],
2632
+ fg: ["200", "600"],
2633
+ border: ["800", "200"]
2634
+ },
2635
+ link: {
2636
+ fg: ["blue/200", "blue/600"]
2637
+ },
2638
+ muted: {
2639
+ bg: ["500 10%", "400 10%"],
2640
+ fg: ["100 70%", "900 70%"]
2641
+ },
2642
+ skeleton: {
2643
+ from: ["900", "100"],
2644
+ to: ["900 50%", "100 50%"]
2645
+ }
2646
+ },
2647
+ disabled: {
2648
+ _hue: "gray",
2649
+ accent: {
2650
+ fg: ["200", "800"]
2651
+ },
2652
+ avatar: {
2653
+ "*": {
2654
+ _blend: ["screen", "multiply"],
2655
+ bg: ["gray/100", "gray/900"],
2656
+ fg: ["white", "black"]
2657
+ }
2658
+ },
2659
+ badge: {
2660
+ "*": {
2661
+ _hue: "gray",
2662
+ bg: ["50", "950"],
2663
+ fg: ["gray/200", "gray/800"],
2664
+ dot: ["gray/200", "gray/800"],
2665
+ icon: ["gray/200", "gray/800"]
2666
+ }
2667
+ },
2668
+ border: ["100", "900"],
2669
+ code: {
2670
+ bg: ["50", "950"],
2671
+ fg: ["200", "800"]
2672
+ },
2673
+ fg: ["200", "800"],
2674
+ icon: ["200", "800"],
2675
+ kbd: {
2676
+ bg: ["white", "black"],
2677
+ fg: ["200", "800"],
2678
+ border: ["100", "900"]
2679
+ },
2680
+ link: {
2681
+ fg: ["200", "800"]
2682
+ },
2683
+ muted: {
2684
+ bg: ["50 50%", "950 50%"],
2685
+ fg: ["200", "800"]
2686
+ }
2302
2687
  }
2303
2688
  },
2304
- backdrop: tokens?.backdrop ?? ["100", "900"],
2305
- code: {
2306
- bg: tokens?.code?.bg ?? ["50", "950"],
2307
- fg: tokens?.code?.fg ?? ["600", "400"],
2308
- token: {
2309
- atrule: tokens?.code?.token?.atrule ?? ["600", "400"],
2310
- attribute: tokens?.code?.token?.attribute ?? ["600", "400"],
2311
- attrName: tokens?.code?.token?.attrName ?? ["600", "400"],
2312
- attrValue: tokens?.code?.token?.attrValue ?? ["600", "400"],
2313
- boolean: tokens?.code?.token?.boolean ?? ["600", "400"],
2314
- builtin: tokens?.code?.token?.builtin ?? ["600", "400"],
2315
- cdata: tokens?.code?.token?.cdata ?? ["600", "400"],
2316
- char: tokens?.code?.token?.char ?? ["600", "400"],
2317
- class: tokens?.code?.token?.class ?? ["600", "400"],
2318
- className: tokens?.code?.token?.className ?? ["600", "400"],
2319
- comment: tokens?.code?.token?.comment ?? ["400", "600"],
2320
- constant: tokens?.code?.token?.constant ?? ["600", "400"],
2321
- deleted: tokens?.code?.token?.deleted ?? ["600", "400"],
2322
- doctype: tokens?.code?.token?.doctype ?? ["600", "400"],
2323
- entity: tokens?.code?.token?.entity ?? ["600", "400"],
2324
- function: tokens?.code?.token?.function ?? ["600", "400"],
2325
- hexcode: tokens?.code?.token?.hexcode ?? ["600", "400"],
2326
- id: tokens?.code?.token?.id ?? ["600", "400"],
2327
- important: tokens?.code?.token?.important ?? ["600", "400"],
2328
- inserted: tokens?.code?.token?.inserted ?? ["600", "400"],
2329
- keyword: tokens?.code?.token?.keyword ?? ["600", "400"],
2330
- number: tokens?.code?.token?.number ?? ["600", "400"],
2331
- operator: tokens?.code?.token?.operator ?? ["600", "400"],
2332
- prolog: tokens?.code?.token?.prolog ?? ["600", "400"],
2333
- property: tokens?.code?.token?.property ?? ["600", "400"],
2334
- pseudoClass: tokens?.code?.token?.pseudoClass ?? ["600", "400"],
2335
- pseudoElement: tokens?.code?.token?.pseudoElement ?? ["600", "400"],
2336
- punctuation: tokens?.code?.token?.punctuation ?? ["600", "400"],
2337
- regex: tokens?.code?.token?.regex ?? ["600", "400"],
2338
- selector: tokens?.code?.token?.selector ?? ["600", "400"],
2339
- string: tokens?.code?.token?.string ?? ["600", "400"],
2340
- symbol: tokens?.code?.token?.symbol ?? ["600", "400"],
2341
- tag: tokens?.code?.token?.tag ?? ["600", "400"],
2342
- unit: tokens?.code?.token?.unit ?? ["600", "400"],
2343
- url: tokens?.code?.token?.url ?? ["600", "400"],
2344
- variable: tokens?.code?.token?.variable ?? ["600", "400"]
2689
+ default: {
2690
+ selected: {
2691
+ _hue: "blue"
2345
2692
  }
2346
2693
  },
2347
- focusRing: tokens?.focusRing ?? ["500", "500"],
2348
- link: {
2349
- fg: tokens?.link?.fg ?? ["600", "400"]
2350
- },
2351
- shadow: {
2352
- outline: tokens?.shadow?.outline ?? ["500", "500"],
2353
- umbra: tokens?.shadow?.umbra ?? ["500", "500"],
2354
- penumbra: tokens?.shadow?.penumbra ?? ["500", "500"],
2355
- ambient: tokens?.shadow?.ambient ?? ["500", "500"]
2356
- },
2357
- skeleton: {
2358
- from: tokens?.skeleton?.from ?? ["100", "900"],
2359
- to: tokens?.skeleton?.to ?? ["50", "950"]
2360
- },
2361
- variant: {
2362
- solid: {
2363
- "*": resolveElementTokens(tokens?.variant?.solid?.["*"]),
2364
- ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.solid?.["*"], tokens?.variant?.solid?.[tone])), acc), {})
2365
- },
2366
- tinted: {
2367
- "*": resolveElementTokens(tokens?.variant?.tinted?.["*"]),
2368
- ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.tinted?.["*"], tokens?.variant?.tinted?.[tone])), acc), {})
2694
+ critical: {
2695
+ disabled: {
2696
+ bg: ["50 50%", "950 50%"]
2369
2697
  }
2370
2698
  }
2699
+ },
2700
+ syntax: {
2701
+ atrule: ["purple/600", "purple/400"],
2702
+ attrName: ["green/600", "green/400"],
2703
+ attrValue: ["yellow/600", "yellow/400"],
2704
+ attribute: ["yellow/600", "yellow/400"],
2705
+ boolean: ["purple/600", "purple/400"],
2706
+ builtin: ["purple/600", "purple/400"],
2707
+ cdata: ["yellow/600", "yellow/400"],
2708
+ char: ["yellow/600", "yellow/400"],
2709
+ class: ["orange/600", "orange/400"],
2710
+ className: ["cyan/600", "cyan/400"],
2711
+ comment: ["gray/400", "gray/600"],
2712
+ constant: ["purple/600", "purple/400"],
2713
+ deleted: ["red/600", "red/400"],
2714
+ entity: ["red/600", "red/400"],
2715
+ function: ["green/600", "green/400"],
2716
+ hexcode: ["blue/600", "blue/400"],
2717
+ id: ["purple/600", "purple/400"],
2718
+ important: ["purple/600", "purple/400"],
2719
+ inserted: ["yellow/600", "yellow/400"],
2720
+ keyword: ["magenta/600", "magenta/400"],
2721
+ number: ["purple/600", "purple/400"],
2722
+ operator: ["magenta/600", "magenta/400"],
2723
+ property: ["blue/600", "blue/400"],
2724
+ pseudoClass: ["yellow/600", "yellow/400"],
2725
+ pseudoElement: ["yellow/600", "yellow/400"],
2726
+ punctuation: ["gray/600", "gray/400"],
2727
+ regex: ["blue/600", "blue/400"],
2728
+ selector: ["red/600", "red/400"],
2729
+ string: ["yellow/600", "yellow/400"],
2730
+ symbol: ["purple/600", "purple/400"],
2731
+ tag: ["red/600", "red/400"],
2732
+ unit: ["orange/600", "orange/400"],
2733
+ url: ["red/600", "red/400"],
2734
+ variable: ["red/600", "red/400"]
2735
+ }
2736
+ };
2737
+ function isRecord$1(value) {
2738
+ return !!(value && typeof value == "object" && !Array.isArray(value));
2739
+ }
2740
+ function merge$1(...records) {
2741
+ const _records = records.filter(Boolean);
2742
+ return _records.length === 0 ? {} : _records.reduce(_merge$1, {});
2743
+ }
2744
+ function _merge$1(acc, source) {
2745
+ for (const key of Object.keys(source)) {
2746
+ const prevValue = acc[key], nextValue = source[key];
2747
+ isRecord$1(prevValue) && isRecord$1(nextValue) ? acc[key] = merge$1(prevValue, nextValue) : acc[key] = nextValue;
2748
+ }
2749
+ return acc;
2750
+ }
2751
+ function resolveColorTokens(inputTokens) {
2752
+ const tokens = merge$1(defaultColorTokens, inputTokens);
2753
+ return {
2754
+ base: resolveBaseColorTokens(tokens),
2755
+ button: resolveButtonColorTokens(tokens),
2756
+ input: resolveInputColorTokens(tokens),
2757
+ selectable: resolveSelectableColorTokens(tokens),
2758
+ syntax: tokens.syntax
2371
2759
  };
2372
2760
  }
2373
- function resolveElementTokens(tokens) {
2761
+ function resolveBaseColorTokens(sparseTokens) {
2762
+ const tokens = {};
2763
+ for (const tone of THEME_COLOR_CARD_TONES)
2764
+ tokens[tone] = resolveBaseColorTones(sparseTokens, tone);
2765
+ return tokens;
2766
+ }
2767
+ function resolveBaseColorTones(inputTokens, tone) {
2768
+ const spec = merge$1(inputTokens?.base?.["*"], inputTokens?.base?.[tone]), hue = spec._hue || inputTokens?.base?.[tone]?._hue || "gray";
2374
2769
  return {
2375
- _hue: tokens?._hue ?? "gray",
2376
- bg: {
2377
- 0: tokens?.bg?.[0] ?? defaultElementTokens.bg[0],
2378
- 4: tokens?.bg?.[4] ?? defaultElementTokens.bg[4]
2379
- },
2380
- border: {
2381
- 0: tokens?.border?.[0] ?? defaultElementTokens.border[0],
2382
- 4: tokens?.border?.[4] ?? defaultElementTokens.border[4]
2383
- },
2384
- fg: {
2385
- 0: tokens?.fg?.[0] ?? defaultElementTokens.fg[0],
2386
- 4: tokens?.fg?.[4] ?? defaultElementTokens.fg[4]
2387
- }
2770
+ ...spec,
2771
+ _hue: hue,
2772
+ avatar: COLOR_HUES.reduce((acc, hue2) => ({
2773
+ ...acc,
2774
+ [hue2]: merge$1({
2775
+ _hue: hue2
2776
+ }, spec.avatar?.["*"], spec.avatar?.[hue2])
2777
+ }), {}),
2778
+ badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
2779
+ ...acc,
2780
+ [tone2]: {
2781
+ _hue: inputTokens?.base?.[tone2]?._hue || hue,
2782
+ ...spec.badge?.["*"],
2783
+ ...spec.badge?.[tone2]
2784
+ }
2785
+ }), {})
2388
2786
  };
2389
2787
  }
2390
- function buildTheme_v3(options) {
2391
- const {
2392
- v2
2393
- } = options ?? {}, tokens = resolveTokens(options?.tokens ?? defaultTokens);
2788
+ function resolveButtonColorTokens(inputTokens) {
2789
+ const tokens = {};
2790
+ for (const mode of THEME_COLOR_BUTTON_MODES)
2791
+ tokens[mode] = resolveButtonToneColorTokens(inputTokens, mode);
2792
+ return tokens;
2793
+ }
2794
+ function resolveButtonToneColorTokens(inputTokens, mode) {
2795
+ const tokens = {};
2796
+ for (const tone of THEME_COLOR_STATE_TONES)
2797
+ tokens[tone] = resolveButtonModeColorTokens(inputTokens, mode, tone);
2798
+ return tokens;
2799
+ }
2800
+ function resolveButtonModeColorTokens(inputTokens, mode, tone) {
2801
+ const tokens = {};
2802
+ for (const state of THEME_COLOR_STATES)
2803
+ tokens[state] = resolveButtonStateColorTokens(inputTokens, tone, mode, state);
2804
+ return tokens;
2805
+ }
2806
+ function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
2807
+ const spec = merge$1(inputTokens?.button?.[mode]?.["*"]?.["*"], inputTokens?.button?.[mode]?.[tone]?.["*"], inputTokens?.button?.[mode]?.["*"]?.[state], inputTokens?.button?.[mode]?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
2394
2808
  return {
2395
- _version: 3,
2396
- _tokens: tokens,
2397
- avatar: v2?.avatar ?? defaultThemeConfig.avatar,
2398
- button: v2?.button ?? defaultThemeConfig.button,
2399
- card: v2?.card ?? defaultThemeConfig.card,
2400
- color: tokens.color,
2401
- container: v2?.container ?? defaultThemeConfig.container,
2402
- font: defaultThemeFonts,
2403
- input: v2?.input ?? defaultThemeConfig.input,
2404
- layer: v2?.layer ?? defaultThemeConfig.layer,
2405
- media: v2?.media ?? defaultThemeConfig.media,
2406
- palette: {
2407
- black: black$1,
2408
- white: white$1,
2409
- hues
2410
- },
2411
- // TODO
2412
- radius: v2?.radius ?? defaultThemeConfig.radius,
2413
- // TODO
2414
- shadow: v2?.shadow ?? defaultThemeConfig.shadow,
2415
- // TODO
2416
- space: v2?.space ?? defaultThemeConfig.space
2809
+ ...spec,
2810
+ _hue: hue,
2811
+ avatar: COLOR_HUES.reduce((acc, hue2) => ({
2812
+ ...acc,
2813
+ [hue2]: merge$1({
2814
+ _hue: hue2
2815
+ }, spec.avatar?.["*"], spec.avatar?.[hue2])
2816
+ }), {}),
2817
+ badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
2818
+ ...acc,
2819
+ [tone2]: {
2820
+ _hue: inputTokens?.base?.[tone2]?._hue || hue,
2821
+ ...spec.badge?.["*"],
2822
+ ...spec.badge?.[tone2]
2823
+ }
2824
+ }), {})
2417
2825
  };
2418
2826
  }
2419
- const COLOR_VARIANTS = ["tinted", "solid"], AVATAR_COLORS = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"];
2420
- function renderColor(colorToken, options) {
2421
- const {
2422
- defaultHue,
2423
- palette
2424
- } = options, color = _parseColorToken(colorToken, {
2425
- defaultHue
2426
- });
2427
- return color.type === "color" ? palette[color.name].hex : color.type === "tint" ? palette.hues[color.hue][color.tint].hex : "#000";
2827
+ function resolveInputColorTokens(inputTokens) {
2828
+ const tokens = {};
2829
+ for (const mode of THEME_COLOR_INPUT_MODES)
2830
+ tokens[mode] = resolveInputModeColorTokens(inputTokens, mode);
2831
+ return tokens;
2428
2832
  }
2429
- function themeColor_v3_v2(options) {
2430
- const {
2431
- color,
2432
- dark,
2433
- palette
2434
- } = options, i = dark ? 1 : 0, defaultHue = color._hue, colorOptions = {
2435
- defaultHue,
2436
- palette
2833
+ function resolveInputModeColorTokens(inputTokens, mode) {
2834
+ const states = {};
2835
+ for (const state of THEME_COLOR_INPUT_STATES)
2836
+ states[state] = resolveInputStateColorTokens(inputTokens, mode, state);
2837
+ return states;
2838
+ }
2839
+ function resolveInputStateColorTokens(inputTokens, mode, state) {
2840
+ const spec = merge$1(inputTokens?.input?.["*"]?.["*"], inputTokens?.input?.[mode]?.["*"], inputTokens?.input?.["*"]?.[state], inputTokens?.input?.[mode]?.[state]), hue = spec._hue || inputTokens?.input?.[mode]?._hue;
2841
+ return {
2842
+ ...spec,
2843
+ _hue: hue
2844
+ };
2845
+ }
2846
+ function resolveSelectableColorTokens(inputTokens) {
2847
+ const tokens = {};
2848
+ for (const tone of THEME_COLOR_STATE_TONES)
2849
+ tokens[tone] = resolveSelectableToneColorTokens(inputTokens, tone);
2850
+ return tokens;
2851
+ }
2852
+ function resolveSelectableToneColorTokens(inputTokens, tone) {
2853
+ const states = {
2854
+ _hue: inputTokens?.selectable?.[tone]?._hue || inputTokens?.base?.[tone]?._hue
2437
2855
  };
2856
+ for (const state of THEME_COLOR_STATES)
2857
+ states[state] = resolveSelectableStateColorTokens(inputTokens, tone, state);
2858
+ return states;
2859
+ }
2860
+ function resolveSelectableStateColorTokens(inputTokens, tone, state) {
2861
+ const spec = merge$1(inputTokens?.selectable?.["*"]?.["*"], inputTokens?.selectable?.[tone]?.["*"], inputTokens?.selectable?.["*"]?.[state], inputTokens?.selectable?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
2438
2862
  return {
2439
- _blend: "screen",
2440
- _dark: dark,
2441
- ...buildColorState({
2442
- cardColor: color,
2443
- dark,
2444
- palette,
2445
- state: "enabled",
2446
- tone: "default",
2447
- variant: "tinted"
2448
- }),
2449
- backdrop: renderColor(color.backdrop[i], colorOptions),
2450
- button: THEME_COLOR_BUTTON_MODES.reduce((modes, mode) => (modes[mode] = THEME_COLOR_STATE_TONES.reduce((tones2, tone) => (tones2[tone] = THEME_COLOR_STATES.reduce((states, state) => (states[state] = buildColorState({
2451
- cardColor: color,
2452
- dark,
2453
- palette,
2454
- state,
2455
- tone,
2456
- variant: mode === "default" ? "solid" : "tinted"
2457
- }), mode === "bleed" && (states[state].border = "transparent"), states), {}), tones2), {}), modes), {}),
2458
- focusRing: renderColor(color.focusRing[i], colorOptions),
2459
- input: THEME_COLOR_INPUT_MODES.reduce((modes, mode) => (modes[mode] = THEME_COLOR_INPUT_STATES.reduce((states, state) => (states[state] = buildInputState(color.variant.tinted.default, {
2460
- dark,
2461
- defaultHue,
2462
- palette
2463
- }), states), {}), modes), {}),
2464
- selectable: THEME_COLOR_STATE_TONES.reduce((tones2, tone) => (tones2[tone] = THEME_COLOR_STATES.reduce((states, state) => (states[state] = buildColorState({
2465
- cardColor: color,
2466
- dark,
2467
- palette,
2468
- state,
2469
- tone,
2470
- variant: "tinted"
2471
- }), states), {}), tones2), {}),
2472
- shadow: {
2473
- outline: renderColor(color.shadow.outline[i], colorOptions),
2474
- umbra: renderColor(color.shadow.umbra[i], colorOptions),
2475
- penumbra: renderColor(color.shadow.penumbra[i], colorOptions),
2476
- ambient: renderColor(color.shadow.ambient[i], colorOptions)
2477
- },
2478
- syntax: {
2479
- atrule: renderColor(color.code.token.atrule[i], colorOptions),
2480
- attrName: renderColor(color.code.token.attrName[i], colorOptions),
2481
- attrValue: renderColor(color.code.token.attrValue[i], colorOptions),
2482
- attribute: renderColor(color.code.token.attribute[i], colorOptions),
2483
- boolean: renderColor(color.code.token.boolean[i], colorOptions),
2484
- builtin: renderColor(color.code.token.builtin[i], colorOptions),
2485
- cdata: renderColor(color.code.token.cdata[i], colorOptions),
2486
- char: renderColor(color.code.token.char[i], colorOptions),
2487
- class: renderColor(color.code.token.class[i], colorOptions),
2488
- className: renderColor(color.code.token.className[i], colorOptions),
2489
- comment: renderColor(color.code.token.comment[i], colorOptions),
2490
- constant: renderColor(color.code.token.constant[i], colorOptions),
2491
- deleted: renderColor(color.code.token.deleted[i], colorOptions),
2492
- doctype: renderColor(color.code.token.doctype[i], colorOptions),
2493
- entity: renderColor(color.code.token.entity[i], colorOptions),
2494
- function: renderColor(color.code.token.function[i], colorOptions),
2495
- hexcode: renderColor(color.code.token.hexcode[i], colorOptions),
2496
- id: renderColor(color.code.token.id[i], colorOptions),
2497
- important: renderColor(color.code.token.important[i], colorOptions),
2498
- inserted: renderColor(color.code.token.inserted[i], colorOptions),
2499
- keyword: renderColor(color.code.token.keyword[i], colorOptions),
2500
- number: renderColor(color.code.token.number[i], colorOptions),
2501
- operator: renderColor(color.code.token.operator[i], colorOptions),
2502
- prolog: renderColor(color.code.token.prolog[i], colorOptions),
2503
- property: renderColor(color.code.token.property[i], colorOptions),
2504
- pseudoClass: renderColor(color.code.token.pseudoClass[i], colorOptions),
2505
- pseudoElement: renderColor(color.code.token.pseudoElement[i], colorOptions),
2506
- punctuation: renderColor(color.code.token.punctuation[i], colorOptions),
2507
- regex: renderColor(color.code.token.regex[i], colorOptions),
2508
- selector: renderColor(color.code.token.selector[i], colorOptions),
2509
- string: renderColor(color.code.token.string[i], colorOptions),
2510
- symbol: renderColor(color.code.token.symbol[i], colorOptions),
2511
- tag: renderColor(color.code.token.tag[i], colorOptions),
2512
- unit: renderColor(color.code.token.unit[i], colorOptions),
2513
- url: renderColor(color.code.token.url[i], colorOptions),
2514
- variable: renderColor(color.code.token.variable[i], colorOptions)
2515
- }
2863
+ ...spec,
2864
+ _hue: hue,
2865
+ avatar: COLOR_HUES.reduce((acc, hue2) => ({
2866
+ ...acc,
2867
+ [hue2]: merge$1({
2868
+ _hue: hue2
2869
+ }, spec.avatar?.["*"], spec.avatar?.[hue2])
2870
+ }), {}),
2871
+ badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
2872
+ ...acc,
2873
+ [tone2]: {
2874
+ _hue: inputTokens?.base?.[tone2]?._hue || hue,
2875
+ ...spec.badge?.["*"],
2876
+ ...spec.badge?.[tone2]
2877
+ }
2878
+ }), {})
2516
2879
  };
2517
2880
  }
2518
- const stateShades = {
2519
- enabled: {
2520
- bg: [0, 1, 2],
2521
- border: [0, 1, 2],
2522
- fg: [0, 1, 2]
2523
- },
2524
- hovered: {
2525
- bg: [1, 2, 3],
2526
- border: [1, 2, 3],
2527
- fg: [1, 2, 3]
2528
- },
2529
- pressed: {
2530
- bg: [2, 3, 4],
2531
- border: [2, 3, 4],
2532
- fg: [2, 3, 4]
2533
- },
2534
- selected: {
2535
- bg: [3, 4, 4],
2536
- border: [3, 4, 4],
2537
- fg: [3, 4, 4]
2538
- },
2539
- disabled: {
2540
- bg: [4, 4, 4],
2541
- border: [4, 4, 4],
2542
- fg: [4, 4, 4]
2543
- }
2544
- };
2545
- function mix$1(tokens, index, options) {
2881
+ function buildColorTheme(config) {
2882
+ const resolvedConfig = {
2883
+ color: resolveColorTokens(config?.color)
2884
+ };
2885
+ return {
2886
+ light: buildColorScheme({
2887
+ scheme: "light"
2888
+ }, resolvedConfig),
2889
+ dark: buildColorScheme({
2890
+ scheme: "dark"
2891
+ }, resolvedConfig)
2892
+ };
2893
+ }
2894
+ function buildColorScheme(options, config) {
2546
2895
  const {
2547
- dark,
2548
- defaultHue,
2549
- palette
2550
- } = options, colorOptions = {
2551
- defaultHue,
2552
- palette
2553
- }, i = dark ? 1 : 0, from = renderColor(tokens[0][i], colorOptions), to = renderColor(tokens[4][i], colorOptions);
2554
- return index === 0 ? from : index === 4 ? to : `color-mix(in oklch, ${from}, ${to} ${index * 25}%)`;
2896
+ scheme
2897
+ } = options, colorScheme = {};
2898
+ for (const tone of THEME_COLOR_CARD_TONES)
2899
+ colorScheme[tone] = buildCardColorTheme({
2900
+ scheme,
2901
+ tone
2902
+ }, config);
2903
+ return colorScheme;
2555
2904
  }
2556
- function buildColorState(options) {
2905
+ function buildCardColorTheme(options, config) {
2557
2906
  const {
2558
- cardColor,
2559
- dark,
2560
- palette,
2561
- state,
2562
- tone,
2563
- variant
2564
- } = options, color = cardColor.variant[variant][tone], shades = stateShades[state], defaultHue = cardColor._hue, colorOptions = {
2565
- defaultHue,
2566
- palette
2567
- }, i = dark ? 1 : 0;
2907
+ scheme,
2908
+ tone
2909
+ } = options, tokens = config?.color?.base?.[tone], context = {
2910
+ hue: tokens?._hue || "gray",
2911
+ scheme
2912
+ };
2568
2913
  return {
2914
+ _blend: (tokens?._blend || ["multiply", "screen"])[scheme === "light" ? 0 : 1],
2915
+ _dark: scheme === "dark",
2569
2916
  accent: {
2570
- fg: renderColor(color.fg[4][i], colorOptions)
2571
- },
2572
- avatar: {
2573
- gray: {
2574
- bg: renderColor(cardColor.avatar.gray.bg[i], colorOptions),
2575
- fg: renderColor(cardColor.avatar.gray.fg[i], colorOptions)
2576
- },
2577
- blue: {
2578
- bg: renderColor(cardColor.avatar.blue.bg[i], colorOptions),
2579
- fg: renderColor(cardColor.avatar.blue.fg[i], colorOptions)
2580
- },
2581
- purple: {
2582
- bg: renderColor(cardColor.avatar.purple.bg[i], colorOptions),
2583
- fg: renderColor(cardColor.avatar.purple.fg[i], colorOptions)
2584
- },
2585
- magenta: {
2586
- bg: renderColor(cardColor.avatar.magenta.bg[i], colorOptions),
2587
- fg: renderColor(cardColor.avatar.magenta.fg[i], colorOptions)
2588
- },
2589
- red: {
2590
- bg: renderColor(cardColor.avatar.red.bg[i], colorOptions),
2591
- fg: renderColor(cardColor.avatar.red.fg[i], colorOptions)
2592
- },
2593
- orange: {
2594
- bg: renderColor(cardColor.avatar.orange.bg[i], colorOptions),
2595
- fg: renderColor(cardColor.avatar.orange.fg[i], colorOptions)
2596
- },
2597
- yellow: {
2598
- bg: renderColor(cardColor.avatar.yellow.bg[i], colorOptions),
2599
- fg: renderColor(cardColor.avatar.yellow.fg[i], colorOptions)
2600
- },
2601
- green: {
2602
- bg: renderColor(cardColor.avatar.green.bg[i], colorOptions),
2603
- fg: renderColor(cardColor.avatar.green.fg[i], colorOptions)
2604
- },
2605
- cyan: {
2606
- bg: renderColor(cardColor.avatar.cyan.bg[i], colorOptions),
2607
- fg: renderColor(cardColor.avatar.cyan.fg[i], colorOptions)
2608
- }
2917
+ fg: resolveColorTokenValue(context, tokens?.accent?.fg)
2609
2918
  },
2610
- // avatar: cardColor.avatar,
2611
- badge: THEME_COLOR_STATE_TONES.reduce((tones2, tone2) => (tones2[tone2] = {
2612
- bg: mix$1(color.bg, 1, {
2613
- dark,
2614
- defaultHue,
2615
- palette
2616
- }),
2617
- fg: mix$1(color.fg, 1, {
2618
- dark,
2619
- defaultHue,
2620
- palette
2621
- }),
2622
- dot: mix$1(color.fg, 3, {
2623
- dark,
2624
- defaultHue,
2625
- palette
2626
- }),
2627
- icon: mix$1(color.fg, 3, {
2628
- dark,
2629
- defaultHue,
2630
- palette
2631
- })
2632
- }, tones2), {}),
2633
- bg: mix$1(color.bg, shades.bg[0], {
2634
- dark,
2635
- defaultHue,
2636
- palette
2637
- }),
2638
- border: mix$1(color.border, shades.border[0], {
2639
- dark,
2640
- defaultHue,
2641
- palette
2642
- }),
2643
- fg: mix$1(color.fg, shades.fg[0], {
2644
- dark,
2645
- defaultHue,
2646
- palette
2647
- }),
2919
+ avatar: buildAvatarColorTheme({
2920
+ scheme
2921
+ }, tokens),
2922
+ backdrop: resolveColorTokenValue(context, tokens?.backdrop),
2923
+ badge: buildBadgeColorTheme(tokens?.badge, {
2924
+ scheme
2925
+ }, config),
2926
+ bg: resolveColorTokenValue(context, tokens?.bg),
2927
+ border: resolveColorTokenValue(context, tokens?.border),
2928
+ button: buildButtonColorTheme({
2929
+ scheme,
2930
+ tone
2931
+ }, config),
2648
2932
  code: {
2649
- bg: mix$1(color.bg, shades.bg[1], {
2650
- dark,
2651
- defaultHue,
2652
- palette
2653
- }),
2654
- fg: mix$1(color.fg, shades.fg[2], {
2655
- dark,
2656
- defaultHue,
2657
- palette
2658
- })
2933
+ bg: resolveColorTokenValue(context, tokens?.code?.bg),
2934
+ fg: resolveColorTokenValue(context, tokens?.code?.fg)
2659
2935
  },
2660
- icon: mix$1(color.fg, shades.fg[2], {
2661
- dark,
2662
- defaultHue,
2663
- palette
2664
- }),
2936
+ fg: resolveColorTokenValue(context, tokens?.fg),
2937
+ focusRing: resolveColorTokenValue(context, tokens?.focusRing),
2938
+ icon: resolveColorTokenValue(context, tokens?.icon),
2939
+ input: buildInputColorTheme({
2940
+ scheme,
2941
+ tone
2942
+ }, config),
2665
2943
  kbd: {
2666
- bg: mix$1(color.bg, 0, {
2667
- dark,
2668
- defaultHue,
2669
- palette
2670
- }),
2671
- fg: mix$1(color.fg, 0, {
2672
- dark,
2673
- defaultHue,
2674
- palette
2675
- }),
2676
- border: mix$1(color.bg, 0, {
2677
- dark,
2678
- defaultHue,
2679
- palette
2680
- })
2944
+ bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
2945
+ fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
2946
+ border: resolveColorTokenValue(context, tokens?.kbd?.border)
2681
2947
  },
2682
2948
  link: {
2683
- fg: mix$1(color.fg, shades.fg[2], {
2684
- dark,
2685
- defaultHue,
2686
- palette
2687
- })
2949
+ fg: resolveColorTokenValue(context, tokens?.link?.fg)
2688
2950
  },
2689
2951
  muted: {
2690
- bg: mix$1(color.bg, shades.bg[1], {
2691
- dark,
2692
- defaultHue,
2693
- palette
2694
- }),
2695
- fg: mix$1(color.fg, shades.fg[2], {
2696
- dark,
2697
- defaultHue,
2698
- palette
2699
- })
2952
+ bg: resolveColorTokenValue(context, tokens?.muted?.bg),
2953
+ fg: resolveColorTokenValue(context, tokens?.muted?.fg)
2700
2954
  },
2955
+ selectable: buildSelectableColorTheme({
2956
+ scheme,
2957
+ tone
2958
+ }, config),
2959
+ shadow: buildShadowColorTheme({
2960
+ scheme,
2961
+ tone
2962
+ }, config),
2701
2963
  skeleton: {
2702
- from: renderColor(cardColor.skeleton.from[i], colorOptions),
2703
- to: renderColor(cardColor.skeleton.to[i], colorOptions)
2704
- }
2964
+ from: resolveColorTokenValue(context, tokens?.skeleton?.from),
2965
+ to: resolveColorTokenValue(context, tokens?.skeleton?.to)
2966
+ },
2967
+ syntax: buildSyntaxColorTheme({
2968
+ scheme
2969
+ }, config)
2705
2970
  };
2706
2971
  }
2707
- function buildInputState(colorElement, options) {
2972
+ function buildShadowColorTheme(options, config) {
2708
2973
  const {
2709
- dark,
2710
- defaultHue,
2711
- palette
2712
- } = options, colorOptions = {
2713
- defaultHue,
2714
- palette
2715
- }, i = dark ? 1 : 0;
2716
- return {
2717
- bg: renderColor(colorElement.bg[0][i], colorOptions),
2718
- border: renderColor(colorElement.bg[0][i], colorOptions),
2719
- fg: renderColor(colorElement.fg[0][i], colorOptions),
2720
- muted: {
2721
- bg: renderColor(colorElement.bg[0][i], colorOptions)
2722
- },
2723
- placeholder: renderColor(colorElement.fg[0][i], colorOptions)
2974
+ scheme,
2975
+ tone
2976
+ } = options, tokens = config?.color?.base?.[tone], context = {
2977
+ hue: tokens?._hue || "gray",
2978
+ scheme
2724
2979
  };
2725
- }
2726
- function v3_v2(theme_v3) {
2727
- const palette = theme_v3.palette;
2728
2980
  return {
2729
- _version: 2,
2730
- avatar: theme_v3.avatar,
2731
- button: theme_v3.button,
2732
- card: theme_v3.card,
2733
- color: {
2734
- dark: {
2735
- transparent: themeColor_v3_v2({
2736
- color: theme_v3.color.transparent,
2737
- dark: !0,
2738
- palette
2739
- }),
2740
- default: themeColor_v3_v2({
2741
- color: theme_v3.color.default,
2742
- dark: !0,
2743
- palette
2744
- }),
2745
- neutral: themeColor_v3_v2({
2746
- color: theme_v3.color.neutral,
2747
- dark: !0,
2748
- palette
2749
- }),
2750
- primary: themeColor_v3_v2({
2751
- color: theme_v3.color.primary,
2752
- dark: !0,
2753
- palette
2754
- }),
2755
- suggest: themeColor_v3_v2({
2756
- color: theme_v3.color.suggest,
2757
- dark: !0,
2758
- palette
2759
- }),
2760
- positive: themeColor_v3_v2({
2761
- color: theme_v3.color.positive,
2762
- dark: !0,
2763
- palette
2764
- }),
2765
- caution: themeColor_v3_v2({
2766
- color: theme_v3.color.caution,
2767
- dark: !0,
2768
- palette
2769
- }),
2770
- critical: themeColor_v3_v2({
2771
- color: theme_v3.color.critical,
2772
- dark: !0,
2773
- palette
2774
- })
2775
- },
2776
- light: {
2777
- transparent: themeColor_v3_v2({
2778
- color: theme_v3.color.transparent,
2779
- dark: !1,
2780
- palette
2781
- }),
2782
- default: themeColor_v3_v2({
2783
- color: theme_v3.color.default,
2784
- dark: !1,
2785
- palette
2786
- }),
2787
- neutral: themeColor_v3_v2({
2788
- color: theme_v3.color.neutral,
2789
- dark: !1,
2790
- palette
2791
- }),
2792
- primary: themeColor_v3_v2({
2793
- color: theme_v3.color.primary,
2794
- dark: !1,
2795
- palette
2796
- }),
2797
- suggest: themeColor_v3_v2({
2798
- color: theme_v3.color.suggest,
2799
- dark: !1,
2800
- palette
2801
- }),
2802
- positive: themeColor_v3_v2({
2803
- color: theme_v3.color.positive,
2804
- dark: !1,
2805
- palette
2806
- }),
2807
- caution: themeColor_v3_v2({
2808
- color: theme_v3.color.caution,
2809
- dark: !1,
2810
- palette
2811
- }),
2812
- critical: themeColor_v3_v2({
2813
- color: theme_v3.color.critical,
2814
- dark: !1,
2815
- palette
2816
- })
2817
- }
2818
- },
2819
- container: theme_v3.container,
2820
- font: {
2821
- code: {
2822
- family: theme_v3.font.code.family,
2823
- weights: theme_v3.font.code.weight,
2824
- sizes: theme_v3.font.code.scale
2825
- },
2826
- heading: {
2827
- family: theme_v3.font.heading.family,
2828
- weights: theme_v3.font.heading.weight,
2829
- sizes: theme_v3.font.heading.scale
2830
- },
2831
- label: {
2832
- family: theme_v3.font.label.family,
2833
- weights: theme_v3.font.label.weight,
2834
- sizes: theme_v3.font.label.scale
2835
- },
2836
- text: {
2837
- family: theme_v3.font.text.family,
2838
- weights: theme_v3.font.text.weight,
2839
- sizes: theme_v3.font.text.scale
2840
- }
2841
- },
2842
- input: theme_v3.input,
2843
- layer: theme_v3.layer,
2844
- media: theme_v3.media,
2845
- radius: Object.values(theme_v3.radius),
2846
- shadow: Object.values(theme_v3.shadow),
2847
- space: Object.values(theme_v3.space)
2981
+ outline: resolveColorTokenValue(context, tokens?.shadow?.outline),
2982
+ umbra: resolveColorTokenValue(context, tokens?.shadow?.umbra),
2983
+ penumbra: resolveColorTokenValue(context, tokens?.shadow?.penumbra),
2984
+ ambient: resolveColorTokenValue(context, tokens?.shadow?.ambient)
2848
2985
  };
2849
2986
  }
2850
- function buildTheme(_config) {
2851
- const v3 = buildTheme_v3({
2852
- v2: _config
2853
- });
2854
- return v2_v0(v3_v2(v3), v3);
2855
- }
2856
- function mixChannel(b, s, weight) {
2857
- const delta = (s - b) * weight;
2858
- return b + delta;
2859
- }
2860
- function mix(b, s, weight) {
2987
+ function buildAvatarColorTheme(options, stateTokens) {
2988
+ const {
2989
+ scheme
2990
+ } = options;
2861
2991
  return {
2862
- r: mixChannel(b.r, s.r, weight),
2863
- g: mixChannel(b.g, s.g, weight),
2864
- b: mixChannel(b.b, s.b, weight)
2992
+ gray: _buildAvatarColorTheme({
2993
+ color: "gray",
2994
+ scheme
2995
+ }, stateTokens),
2996
+ blue: _buildAvatarColorTheme({
2997
+ color: "blue",
2998
+ scheme
2999
+ }, stateTokens),
3000
+ purple: _buildAvatarColorTheme({
3001
+ color: "purple",
3002
+ scheme
3003
+ }, stateTokens),
3004
+ magenta: _buildAvatarColorTheme({
3005
+ color: "magenta",
3006
+ scheme
3007
+ }, stateTokens),
3008
+ red: _buildAvatarColorTheme({
3009
+ color: "red",
3010
+ scheme
3011
+ }, stateTokens),
3012
+ orange: _buildAvatarColorTheme({
3013
+ color: "orange",
3014
+ scheme
3015
+ }, stateTokens),
3016
+ yellow: _buildAvatarColorTheme({
3017
+ color: "yellow",
3018
+ scheme
3019
+ }, stateTokens),
3020
+ green: _buildAvatarColorTheme({
3021
+ color: "green",
3022
+ scheme
3023
+ }, stateTokens),
3024
+ cyan: _buildAvatarColorTheme({
3025
+ color: "cyan",
3026
+ scheme
3027
+ }, stateTokens)
2865
3028
  };
2866
3029
  }
2867
- function multiplyChannel(b, s) {
2868
- return b * s;
2869
- }
2870
- function multiply(b, s) {
2871
- return {
2872
- r: multiplyChannel(b.r / 255, s.r / 255) * 255,
2873
- g: multiplyChannel(b.g / 255, s.g / 255) * 255,
2874
- b: multiplyChannel(b.b / 255, s.b / 255) * 255
3030
+ function _buildAvatarColorTheme(options, stateTokens) {
3031
+ const {
3032
+ color: color2,
3033
+ scheme
3034
+ } = options, tokens = stateTokens?.avatar?.[color2], context = {
3035
+ hue: tokens?._hue || "gray",
3036
+ scheme
2875
3037
  };
2876
- }
2877
- function screenChannel(b, s) {
2878
- return b + s - b * s;
2879
- }
2880
- function screen(b, s) {
2881
3038
  return {
2882
- r: screenChannel(b.r / 255, s.r / 255) * 255,
2883
- g: screenChannel(b.g / 255, s.g / 255) * 255,
2884
- b: screenChannel(b.b / 255, s.b / 255) * 255
3039
+ _blend: (tokens?._blend || ["screen", "multiply"])[scheme === "light" ? 0 : 1],
3040
+ bg: resolveColorTokenValue(context, tokens?.bg),
3041
+ fg: resolveColorTokenValue(context, tokens?.fg)
2885
3042
  };
2886
3043
  }
2887
- function clamp(a, min = 0, max = 1) {
2888
- return Math.min(max, Math.max(min, a));
2889
- }
2890
- function round(value) {
2891
- return Math.round(value);
3044
+ function buildBadgeColorTheme(tokens, options, config) {
3045
+ const {
3046
+ scheme
3047
+ } = options, colorBadge = {};
3048
+ for (const tone of THEME_COLOR_STATE_TONES)
3049
+ colorBadge[tone] = _buildBadgeColorTheme(tokens, {
3050
+ scheme,
3051
+ tone
3052
+ }, config);
3053
+ return colorBadge;
2892
3054
  }
2893
- function hexToRgb(hex) {
2894
- if (hex.length === 4) {
2895
- const hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
2896
- return {
2897
- r: parseInt(hexR + hexR, 16),
2898
- g: parseInt(hexG + hexG, 16),
2899
- b: parseInt(hexB + hexB, 16)
2900
- };
2901
- }
2902
- return {
2903
- r: parseInt(hex.slice(1, 3), 16),
2904
- g: parseInt(hex.slice(3, 5), 16),
2905
- b: parseInt(hex.slice(5, 7), 16)
3055
+ function _buildBadgeColorTheme(parentTokens, options, config) {
3056
+ const {
3057
+ scheme,
3058
+ tone
3059
+ } = options, tokens = parentTokens?.[tone], context = {
3060
+ hue: tokens?._hue || config?.color?.base?.[tone]?._hue || "gray",
3061
+ scheme
2906
3062
  };
2907
- }
2908
- function rgbaToRGBA(rgba2) {
2909
- const values = rgba2.replace(/rgba\(|\)/g, "").split(",");
2910
3063
  return {
2911
- r: parseInt(values[0]),
2912
- g: parseInt(values[1]),
2913
- b: parseInt(values[2]),
2914
- a: parseFloat(values[3])
3064
+ bg: resolveColorTokenValue(context, tokens?.bg),
3065
+ fg: resolveColorTokenValue(context, tokens?.fg),
3066
+ dot: resolveColorTokenValue(context, tokens?.dot),
3067
+ icon: resolveColorTokenValue(context, tokens?.icon)
2915
3068
  };
2916
3069
  }
2917
- function rgbToHex(color) {
2918
- const r = round(clamp(Math.round(color.r), 0, 255)), g = round(clamp(Math.round(color.g), 0, 255)), b = round(clamp(Math.round(color.b), 0, 255));
2919
- return "a" in color ? `rgba(${r},${g},${b},${color.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
3070
+ function buildButtonColorTheme(options, config) {
3071
+ const {
3072
+ scheme,
3073
+ tone: cardTone
3074
+ } = options, modes = {};
3075
+ for (const mode of THEME_COLOR_BUTTON_MODES)
3076
+ modes[mode] = buildButtonTonesColorTheme({
3077
+ cardTone,
3078
+ scheme,
3079
+ mode
3080
+ }, config);
3081
+ return modes;
2920
3082
  }
2921
- function rgbToHsl({
3083
+ function buildButtonTonesColorTheme(options, config) {
3084
+ const {
3085
+ cardTone,
3086
+ mode,
3087
+ scheme
3088
+ } = options, tones2 = {};
3089
+ for (const tone of THEME_COLOR_STATE_TONES)
3090
+ tones2[tone] = buildButtonStatesColorTheme({
3091
+ cardTone,
3092
+ mode,
3093
+ scheme,
3094
+ tone
3095
+ }, config);
3096
+ return tones2;
3097
+ }
3098
+ function buildButtonStatesColorTheme(options, config) {
3099
+ const {
3100
+ cardTone,
3101
+ mode,
3102
+ scheme,
3103
+ tone
3104
+ } = options, states = {};
3105
+ for (const state of THEME_COLOR_STATES)
3106
+ states[state] = buildButtonStateColorTheme({
3107
+ cardTone,
3108
+ mode,
3109
+ tone,
3110
+ scheme,
3111
+ state
3112
+ }, config);
3113
+ return states;
3114
+ }
3115
+ function buildButtonStateColorTheme(options, config) {
3116
+ const {
3117
+ cardTone,
3118
+ mode,
3119
+ tone,
3120
+ scheme,
3121
+ state
3122
+ } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.button?.[mode]?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3123
+ hue,
3124
+ scheme
3125
+ };
3126
+ return {
3127
+ _blend: blendMode[scheme === "light" ? 0 : 1],
3128
+ accent: {
3129
+ fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3130
+ },
3131
+ avatar: buildAvatarColorTheme({
3132
+ scheme
3133
+ }, tokens),
3134
+ badge: buildBadgeColorTheme(tokens?.badge, {
3135
+ scheme
3136
+ }, config),
3137
+ bg: resolveColorTokenValue(context, tokens?.bg),
3138
+ border: resolveColorTokenValue(context, tokens?.border),
3139
+ code: {
3140
+ bg: resolveColorTokenValue(context, tokens?.code?.bg),
3141
+ fg: resolveColorTokenValue(context, tokens?.code?.fg)
3142
+ },
3143
+ fg: resolveColorTokenValue(context, tokens?.fg),
3144
+ icon: resolveColorTokenValue(context, tokens?.icon),
3145
+ muted: {
3146
+ bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3147
+ fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3148
+ },
3149
+ kbd: {
3150
+ bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3151
+ fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3152
+ border: resolveColorTokenValue(context, tokens?.kbd?.border)
3153
+ },
3154
+ link: {
3155
+ fg: resolveColorTokenValue(context, tokens?.link?.fg)
3156
+ },
3157
+ skeleton: {
3158
+ from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3159
+ to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3160
+ }
3161
+ };
3162
+ }
3163
+ function buildInputColorTheme(options, config) {
3164
+ const {
3165
+ scheme,
3166
+ tone
3167
+ } = options;
3168
+ return {
3169
+ default: buildInputStatesColorTheme({
3170
+ mode: "default",
3171
+ scheme,
3172
+ tone
3173
+ }, config),
3174
+ invalid: buildInputStatesColorTheme({
3175
+ mode: "invalid",
3176
+ scheme,
3177
+ tone
3178
+ }, config)
3179
+ };
3180
+ }
3181
+ function buildInputStatesColorTheme(options, config) {
3182
+ const {
3183
+ mode,
3184
+ scheme,
3185
+ tone
3186
+ } = options;
3187
+ return {
3188
+ enabled: buildInputStateColorTheme({
3189
+ mode,
3190
+ scheme,
3191
+ state: "enabled",
3192
+ cardTone: tone
3193
+ }, config),
3194
+ hovered: buildInputStateColorTheme({
3195
+ mode,
3196
+ scheme,
3197
+ state: "hovered",
3198
+ cardTone: tone
3199
+ }, config),
3200
+ readOnly: buildInputStateColorTheme({
3201
+ mode,
3202
+ scheme,
3203
+ state: "readOnly",
3204
+ cardTone: tone
3205
+ }, config),
3206
+ disabled: buildInputStateColorTheme({
3207
+ mode,
3208
+ scheme,
3209
+ state: "disabled",
3210
+ cardTone: tone
3211
+ }, config)
3212
+ };
3213
+ }
3214
+ function buildInputStateColorTheme(options, config) {
3215
+ const {
3216
+ cardTone,
3217
+ mode,
3218
+ scheme,
3219
+ state
3220
+ } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.input?.[mode]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3221
+ hue,
3222
+ scheme
3223
+ };
3224
+ return {
3225
+ _blend: blendMode[scheme === "light" ? 0 : 1],
3226
+ bg: resolveColorTokenValue(context, tokens?.bg),
3227
+ border: resolveColorTokenValue(context, tokens?.border),
3228
+ fg: resolveColorTokenValue(context, tokens?.fg),
3229
+ muted: {
3230
+ bg: resolveColorTokenValue(context, tokens?.muted?.bg)
3231
+ },
3232
+ placeholder: resolveColorTokenValue(context, tokens?.placeholder)
3233
+ };
3234
+ }
3235
+ function buildSelectableColorTheme(options, config) {
3236
+ const {
3237
+ scheme,
3238
+ tone: cardTone
3239
+ } = options, tones2 = {};
3240
+ for (const tone of THEME_COLOR_STATE_TONES)
3241
+ tones2[tone] = buildSelectableStatesColorTheme({
3242
+ cardTone,
3243
+ scheme,
3244
+ tone
3245
+ }, config);
3246
+ return tones2;
3247
+ }
3248
+ function buildSelectableStatesColorTheme(options, config) {
3249
+ const {
3250
+ cardTone,
3251
+ scheme,
3252
+ tone
3253
+ } = options, states = {};
3254
+ for (const state of THEME_COLOR_STATES)
3255
+ states[state] = buildSelectableStateColorTheme({
3256
+ cardTone,
3257
+ tone,
3258
+ scheme,
3259
+ state
3260
+ }, config);
3261
+ return states;
3262
+ }
3263
+ function buildSelectableStateColorTheme(options, config) {
3264
+ const {
3265
+ cardTone,
3266
+ scheme,
3267
+ state,
3268
+ tone
3269
+ } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.selectable?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3270
+ hue,
3271
+ scheme
3272
+ };
3273
+ return {
3274
+ _blend: blendMode[scheme === "light" ? 0 : 1],
3275
+ accent: {
3276
+ fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3277
+ },
3278
+ avatar: buildAvatarColorTheme({
3279
+ scheme
3280
+ }, tokens),
3281
+ badge: buildBadgeColorTheme(tokens?.badge, {
3282
+ scheme
3283
+ }, config),
3284
+ bg: resolveColorTokenValue(context, tokens?.bg),
3285
+ border: resolveColorTokenValue(context, tokens?.border),
3286
+ code: {
3287
+ bg: resolveColorTokenValue(context, tokens?.code?.bg),
3288
+ fg: resolveColorTokenValue(context, tokens?.code?.fg)
3289
+ },
3290
+ fg: resolveColorTokenValue(context, tokens?.fg),
3291
+ icon: resolveColorTokenValue(context, tokens?.icon),
3292
+ muted: {
3293
+ bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3294
+ fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3295
+ },
3296
+ kbd: {
3297
+ bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3298
+ fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3299
+ border: resolveColorTokenValue(context, tokens?.kbd?.border)
3300
+ },
3301
+ link: {
3302
+ fg: resolveColorTokenValue(context, tokens?.link?.fg)
3303
+ },
3304
+ skeleton: {
3305
+ from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3306
+ to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3307
+ }
3308
+ };
3309
+ }
3310
+ function buildSyntaxColorTheme(options, config) {
3311
+ const {
3312
+ scheme
3313
+ } = options, tokens = config?.color?.syntax, context = {
3314
+ hue: "gray",
3315
+ scheme
3316
+ };
3317
+ return {
3318
+ atrule: resolveColorTokenValue(context, tokens?.atrule),
3319
+ attrName: resolveColorTokenValue(context, tokens?.attrName),
3320
+ attrValue: resolveColorTokenValue(context, tokens?.attrValue),
3321
+ attribute: resolveColorTokenValue(context, tokens?.attribute),
3322
+ boolean: resolveColorTokenValue(context, tokens?.boolean),
3323
+ builtin: resolveColorTokenValue(context, tokens?.builtin),
3324
+ cdata: resolveColorTokenValue(context, tokens?.cdata),
3325
+ char: resolveColorTokenValue(context, tokens?.char),
3326
+ class: resolveColorTokenValue(context, tokens?.class),
3327
+ className: resolveColorTokenValue(context, tokens?.className),
3328
+ comment: resolveColorTokenValue(context, tokens?.comment),
3329
+ constant: resolveColorTokenValue(context, tokens?.constant),
3330
+ deleted: resolveColorTokenValue(context, tokens?.deleted),
3331
+ doctype: resolveColorTokenValue(context, tokens?.doctype),
3332
+ entity: resolveColorTokenValue(context, tokens?.entity),
3333
+ function: resolveColorTokenValue(context, tokens?.function),
3334
+ hexcode: resolveColorTokenValue(context, tokens?.hexcode),
3335
+ id: resolveColorTokenValue(context, tokens?.id),
3336
+ important: resolveColorTokenValue(context, tokens?.important),
3337
+ inserted: resolveColorTokenValue(context, tokens?.inserted),
3338
+ keyword: resolveColorTokenValue(context, tokens?.keyword),
3339
+ number: resolveColorTokenValue(context, tokens?.number),
3340
+ operator: resolveColorTokenValue(context, tokens?.operator),
3341
+ prolog: resolveColorTokenValue(context, tokens?.prolog),
3342
+ property: resolveColorTokenValue(context, tokens?.property),
3343
+ pseudoClass: resolveColorTokenValue(context, tokens?.pseudoClass),
3344
+ pseudoElement: resolveColorTokenValue(context, tokens?.pseudoElement),
3345
+ punctuation: resolveColorTokenValue(context, tokens?.punctuation),
3346
+ regex: resolveColorTokenValue(context, tokens?.regex),
3347
+ selector: resolveColorTokenValue(context, tokens?.selector),
3348
+ string: resolveColorTokenValue(context, tokens?.string),
3349
+ symbol: resolveColorTokenValue(context, tokens?.symbol),
3350
+ tag: resolveColorTokenValue(context, tokens?.tag),
3351
+ unit: resolveColorTokenValue(context, tokens?.unit),
3352
+ url: resolveColorTokenValue(context, tokens?.url),
3353
+ variable: resolveColorTokenValue(context, tokens?.variable)
3354
+ };
3355
+ }
3356
+ const defaultColorPalette = color;
3357
+ function mixChannel(b, s, weight) {
3358
+ const delta = (s - b) * weight;
3359
+ return b + delta;
3360
+ }
3361
+ function mix(b, s, weight) {
3362
+ return {
3363
+ r: mixChannel(b.r, s.r, weight),
3364
+ g: mixChannel(b.g, s.g, weight),
3365
+ b: mixChannel(b.b, s.b, weight)
3366
+ };
3367
+ }
3368
+ function multiplyChannel(b, s) {
3369
+ return b * s;
3370
+ }
3371
+ function multiply(b, s) {
3372
+ return {
3373
+ r: multiplyChannel(b.r / 255, s.r / 255) * 255,
3374
+ g: multiplyChannel(b.g / 255, s.g / 255) * 255,
3375
+ b: multiplyChannel(b.b / 255, s.b / 255) * 255
3376
+ };
3377
+ }
3378
+ function screenChannel(b, s) {
3379
+ return b + s - b * s;
3380
+ }
3381
+ function screen(b, s) {
3382
+ return {
3383
+ r: screenChannel(b.r / 255, s.r / 255) * 255,
3384
+ g: screenChannel(b.g / 255, s.g / 255) * 255,
3385
+ b: screenChannel(b.b / 255, s.b / 255) * 255
3386
+ };
3387
+ }
3388
+ function lerp(x, y, a) {
3389
+ return x * (1 - a) + y * a;
3390
+ }
3391
+ function invlerp(x, y, a) {
3392
+ return clamp((a - x) / (y - x));
3393
+ }
3394
+ function clamp(a, min = 0, max = 1) {
3395
+ return Math.min(max, Math.max(min, a));
3396
+ }
3397
+ function range(x1, y1, x2, y2, a) {
3398
+ return lerp(x2, y2, invlerp(x1, y1, a));
3399
+ }
3400
+ function round(value) {
3401
+ return Math.round(value);
3402
+ }
3403
+ function hexToRgb(hex) {
3404
+ if (hex.length === 4) {
3405
+ const hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
3406
+ return {
3407
+ r: parseInt(hexR + hexR, 16),
3408
+ g: parseInt(hexG + hexG, 16),
3409
+ b: parseInt(hexB + hexB, 16)
3410
+ };
3411
+ }
3412
+ return {
3413
+ r: parseInt(hex.slice(1, 3), 16),
3414
+ g: parseInt(hex.slice(3, 5), 16),
3415
+ b: parseInt(hex.slice(5, 7), 16)
3416
+ };
3417
+ }
3418
+ function rgbaToRGBA(rgba2) {
3419
+ const values = rgba2.replace(/rgba\(|\)/g, "").split(",");
3420
+ return {
3421
+ r: parseInt(values[0]),
3422
+ g: parseInt(values[1]),
3423
+ b: parseInt(values[2]),
3424
+ a: parseFloat(values[3])
3425
+ };
3426
+ }
3427
+ function rgbToHex(color2) {
3428
+ const r = round(clamp(Math.round(color2.r), 0, 255)), g = round(clamp(Math.round(color2.g), 0, 255)), b = round(clamp(Math.round(color2.b), 0, 255));
3429
+ return "a" in color2 ? `rgba(${r},${g},${b},${color2.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
3430
+ }
3431
+ function rgbToHsl({
2922
3432
  r,
2923
3433
  g,
2924
3434
  b
@@ -2961,21 +3471,21 @@ function parseHsl(str) {
2961
3471
  l: parseFloat(res[5])
2962
3472
  };
2963
3473
  }
2964
- function parseColor(color) {
2965
- if (!color) return {
3474
+ function parseColor(color2) {
3475
+ if (!color2) return {
2966
3476
  r: 0,
2967
3477
  g: 0,
2968
3478
  b: 0
2969
3479
  };
2970
- if (typeof color != "string")
3480
+ if (typeof color2 != "string")
2971
3481
  throw new Error("parseColor: expected a string");
2972
- if (isHex(color))
2973
- return hexToRgb(color);
2974
- if (color.startsWith("hsl("))
2975
- return hslToRgb(parseHsl(color));
2976
- if (color.startsWith("rgba("))
2977
- return rgbaToRGBA(color);
2978
- throw new Error(`parseColor: unexpected color format: "${color}"`);
3482
+ if (isHex(color2))
3483
+ return hexToRgb(color2);
3484
+ if (color2.startsWith("hsl("))
3485
+ return hslToRgb(parseHsl(color2));
3486
+ if (color2.startsWith("rgba("))
3487
+ return rgbaToRGBA(color2);
3488
+ throw new Error(`parseColor: unexpected color format: "${color2}"`);
2979
3489
  }
2980
3490
  function getContrastRatio(bg, fg) {
2981
3491
  const rgb1 = parseColor(bg), rgb2 = parseColor(fg), c1 = rgb_lrgb(rgb1), c2 = rgb_lrgb(rgb2), l1 = lrgb_luminance(c1), l2 = lrgb_luminance(c2);
@@ -2994,161 +3504,1181 @@ function rgb_lrgb1(v) {
2994
3504
  function lrgb_luminance([r, g, b]) {
2995
3505
  return 0.2126 * r + 0.7152 * g + 0.0722 * b;
2996
3506
  }
2997
- function rgba(color, a) {
2998
- if (typeof color == "string" && color.startsWith("var("))
2999
- return `color-mix(in srgb, transparent, ${color} ${a * 100}%)`;
3000
- const rgb = parseColor(color);
3507
+ function rgba(color2, a) {
3508
+ if (typeof color2 == "string" && color2.startsWith("var("))
3509
+ return `color-mix(in srgb, transparent, ${color2} ${a * 100}%)`;
3510
+ const rgb = parseColor(color2);
3001
3511
  return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
3002
3512
  }
3003
- const THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = [
3004
- "transparent",
3005
- "default",
3006
- "neutral",
3007
- "primary",
3008
- // deprecated
3009
- "suggest",
3010
- "positive",
3011
- "caution",
3012
- "critical"
3013
- ], THEME_COLOR_STATE_TONES = [
3014
- "default",
3015
- "neutral",
3016
- "primary",
3017
- // deprecated
3018
- "suggest",
3019
- "positive",
3020
- "caution",
3021
- "critical"
3022
- ], THEME_COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"], THEME_COLOR_BUTTON_MODES = ["default", "ghost", "bleed"], THEME_COLOR_INPUT_MODES = ["default", "invalid"], THEME_COLOR_INPUT_STATES = ["enabled", "hovered", "readOnly", "disabled"], THEME_COLOR_AVATAR_COLORS = COLOR_HUES;
3023
- function isColorBlendModeValue(str) {
3024
- return THEME_COLOR_BLEND_MODES.includes(str);
3513
+ const RGB_RANGE = [0, 255];
3514
+ function mixThemeColor(value, options) {
3515
+ const {
3516
+ blendMode
3517
+ } = options, color2 = parseColor(value), black2 = parseColor(options.black), white2 = parseColor(options.white), bg = options.bg ? parseColor(options.bg) : blendMode === "multiply" ? white2 : black2, paletteRange = {
3518
+ r: [black2.r, white2.r],
3519
+ g: [black2.g, white2.g],
3520
+ b: [black2.b, white2.b]
3521
+ }, convertedBgColor = {
3522
+ r: clamp(range(...paletteRange.r, ...RGB_RANGE, bg.r), ...RGB_RANGE),
3523
+ g: clamp(range(...paletteRange.g, ...RGB_RANGE, bg.g), ...RGB_RANGE),
3524
+ b: clamp(range(...paletteRange.b, ...RGB_RANGE, bg.b), ...RGB_RANGE)
3525
+ }, convertedColor = {
3526
+ r: clamp(range(...paletteRange.r, ...RGB_RANGE, color2.r), ...RGB_RANGE),
3527
+ g: clamp(range(...paletteRange.g, ...RGB_RANGE, color2.g), ...RGB_RANGE),
3528
+ b: clamp(range(...paletteRange.b, ...RGB_RANGE, color2.b), ...RGB_RANGE)
3529
+ }, resultColor = blendMode === "multiply" ? multiply(convertedBgColor, convertedColor) : screen(convertedBgColor, convertedColor), v = {
3530
+ r: clamp(range(...RGB_RANGE, ...paletteRange.r, resultColor.r), ...paletteRange.r),
3531
+ g: clamp(range(...RGB_RANGE, ...paletteRange.g, resultColor.g), ...paletteRange.g),
3532
+ b: clamp(range(...RGB_RANGE, ...paletteRange.b, resultColor.b), ...paletteRange.b)
3533
+ };
3534
+ return rgbToHex(v);
3025
3535
  }
3026
- function isColorHueKey(str) {
3027
- return COLOR_HUES.includes(str);
3536
+ function renderColorValue(str, options) {
3537
+ const {
3538
+ bg,
3539
+ blendMode,
3540
+ colorPalette
3541
+ } = options;
3542
+ if (bg === "white")
3543
+ throw new Error("Cannot blend with white background");
3544
+ const node = parseTokenValue(str);
3545
+ if (!node || node.type !== "color")
3546
+ throw new Error(`Invalid color token value: ${str}`);
3547
+ let hex = "";
3548
+ if (node.key === "black" && (hex = renderColorHex(colorPalette.black)), node.key === "white" && (hex = renderColorHex(colorPalette.white)), node.hue && node.tint && (hex = renderColorHex(colorPalette[node.hue][node.tint])), !hex)
3549
+ throw new Error(`Invalid color token value: ${str}`);
3550
+ const hexBeforeMix = hex, mixOptions = {
3551
+ blendMode,
3552
+ bg,
3553
+ black: renderColorHex(colorPalette.black),
3554
+ // opacity: node.opacity,
3555
+ white: renderColorHex(colorPalette.white)
3556
+ };
3557
+ try {
3558
+ if (hex = mixThemeColor(hex, mixOptions), bg && node.mix !== void 0) {
3559
+ const from = hexToRgb(bg), to = hexToRgb(hex);
3560
+ hex = rgbToHex(mix(from, to, node.mix));
3561
+ }
3562
+ } catch (err) {
3563
+ throw console.warn("could not blend", hex, mixOptions), err;
3564
+ }
3565
+ return hex === "#aN" && (console.warn(`invalid color token value: ${str}`), hex = hexBeforeMix), node.opacity !== void 0 && (hex = rgba(hex, node.opacity)), hex;
3028
3566
  }
3029
- function isColorTintKey(str) {
3030
- return COLOR_TINTS.includes(str);
3567
+ function renderColorHex(color2) {
3568
+ return typeof color2 == "string" ? color2 : color2.hex;
3031
3569
  }
3032
- function isColorButtonMode(str) {
3033
- return THEME_COLOR_BUTTON_MODES.includes(str);
3570
+ function renderThemeColorSchemes(value, config) {
3571
+ const colorPalette = config?.palette ?? defaultColorPalette;
3572
+ return {
3573
+ light: renderThemeColorScheme(colorPalette, value.light),
3574
+ dark: renderThemeColorScheme(colorPalette, value.dark)
3575
+ };
3034
3576
  }
3035
- const COLOR_CONFIG_STATE_KEYS = ["_hue", "bg", "fg", "border", "focusRing", "muted/fg", "accent/fg", "link/fg", "code/bg", "code/fg", "skeleton/from", "skeleton/to", "status/dot", "status/icon"], COLOR_CONFIG_CARD_KEYS = [...COLOR_CONFIG_STATE_KEYS, "_hue", "bg", "fg", "border", "focusRing", "shadow/outline", "shadow/umbra", "shadow/penumbra", "shadow/ambient"], COLOR_CONFIG_BLEND_KEYS = ["_blend"], COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
3036
- function isColorConfigBaseTone(str) {
3037
- return COLOR_CONFIG_CARD_TONES.includes(str);
3577
+ function renderThemeColorScheme(colorPalette, value) {
3578
+ const toneEntries = Object.entries(value), [, transparentTone] = toneEntries.find(([k]) => k === "transparent"), [, defaultTone] = toneEntries.find(([k]) => k === "default"), renderedTransparentTone = renderThemeColor(transparentTone, {
3579
+ colorPalette
3580
+ }), renderedDefaultTone = renderThemeColor(defaultTone, {
3581
+ colorPalette
3582
+ }), bg = renderedDefaultTone.bg;
3583
+ if (bg === "white")
3584
+ throw new Error("Cannot blend with white background");
3585
+ return Object.fromEntries([["transparent", renderedTransparentTone], ["default", renderedDefaultTone], ...toneEntries.filter(([k]) => k !== "default" && k !== "transparent").map(([k, v]) => [k, renderThemeColor(v, {
3586
+ bg,
3587
+ colorPalette
3588
+ })])]);
3038
3589
  }
3039
- function isColorConfigBaseKey(str) {
3040
- return COLOR_CONFIG_CARD_KEYS.includes(str);
3590
+ function renderThemeColor(value, options) {
3591
+ const {
3592
+ colorPalette,
3593
+ bg
3594
+ } = options, blendMode = value._blend || "multiply", baseBg = renderColorValue(value.bg, {
3595
+ colorPalette,
3596
+ bg,
3597
+ blendMode
3598
+ }), colorOptions = {
3599
+ colorPalette,
3600
+ bg: baseBg,
3601
+ blendMode
3602
+ }, button = renderThemeColorButton(value.button, {
3603
+ baseBg,
3604
+ blendMode,
3605
+ colorPalette
3606
+ }), selectable = renderThemeColorSelectable(value.selectable, {
3607
+ colorPalette,
3608
+ baseBg,
3609
+ blendMode
3610
+ }), shadow = {
3611
+ outline: renderColorValue(value.shadow.outline, colorOptions),
3612
+ umbra: renderColorValue(value.shadow.umbra, {
3613
+ ...colorOptions,
3614
+ bg: void 0,
3615
+ colorPalette: {
3616
+ ...colorPalette,
3617
+ black: "#000000"
3618
+ }
3619
+ }),
3620
+ penumbra: renderColorValue(value.shadow.penumbra, {
3621
+ ...colorOptions,
3622
+ bg: void 0,
3623
+ colorPalette: {
3624
+ ...colorPalette,
3625
+ black: "#000000"
3626
+ }
3627
+ }),
3628
+ ambient: renderColorValue(value.shadow.ambient, {
3629
+ ...colorOptions,
3630
+ bg: void 0,
3631
+ colorPalette: {
3632
+ ...colorPalette,
3633
+ black: "#000000"
3634
+ }
3635
+ })
3636
+ };
3637
+ return {
3638
+ _blend: blendMode,
3639
+ _dark: value._dark,
3640
+ accent: {
3641
+ fg: renderColorValue(value.accent.fg, colorOptions)
3642
+ },
3643
+ avatar: renderThemeColorAvatar(value.avatar, {
3644
+ baseBg,
3645
+ colorPalette,
3646
+ blendMode
3647
+ }),
3648
+ backdrop: renderColorValue(value.backdrop, colorOptions),
3649
+ badge: renderThemeColorBadge(value.badge, {
3650
+ baseBg,
3651
+ colorPalette,
3652
+ blendMode
3653
+ }),
3654
+ bg: baseBg,
3655
+ border: renderColorValue(value.border, colorOptions),
3656
+ button,
3657
+ code: {
3658
+ bg: renderColorValue(value.code.bg, colorOptions),
3659
+ fg: renderColorValue(value.code.fg, colorOptions)
3660
+ },
3661
+ fg: renderColorValue(value.fg, colorOptions),
3662
+ focusRing: renderColorValue(value.focusRing, colorOptions),
3663
+ icon: renderColorValue(value.icon, colorOptions),
3664
+ input: renderThemeColorInput(value.input, {
3665
+ baseBg,
3666
+ colorPalette,
3667
+ blendMode
3668
+ }),
3669
+ kbd: renderThemeColorKBD(value.kbd, {
3670
+ baseBg,
3671
+ colorPalette,
3672
+ blendMode
3673
+ }),
3674
+ link: {
3675
+ fg: renderColorValue(value.link.fg, colorOptions)
3676
+ },
3677
+ muted: {
3678
+ bg: renderColorValue(value.muted.bg, colorOptions),
3679
+ fg: renderColorValue(value.muted.fg, colorOptions)
3680
+ },
3681
+ shadow,
3682
+ skeleton: {
3683
+ from: renderColorValue(value.skeleton.from, colorOptions),
3684
+ to: renderColorValue(value.skeleton.to, colorOptions)
3685
+ },
3686
+ syntax: renderSyntaxColorTheme(value.syntax, {
3687
+ baseBg,
3688
+ colorPalette,
3689
+ blendMode
3690
+ }),
3691
+ selectable
3692
+ };
3041
3693
  }
3042
- function isColorConfigStateKey(str) {
3043
- return COLOR_CONFIG_STATE_KEYS.includes(str);
3694
+ function renderThemeColorKBD(value, options) {
3695
+ const {
3696
+ baseBg,
3697
+ blendMode,
3698
+ colorPalette
3699
+ } = options, rootOptions = {
3700
+ bg: baseBg,
3701
+ blendMode,
3702
+ colorPalette
3703
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3704
+ bg,
3705
+ blendMode,
3706
+ colorPalette
3707
+ };
3708
+ return {
3709
+ bg,
3710
+ fg: renderColorValue(value.fg, colorOptions),
3711
+ border: renderColorValue(value.border, colorOptions)
3712
+ };
3044
3713
  }
3045
- function isColorConfigStateTone(str) {
3046
- return COLOR_CONFIG_STATE_TONES.includes(str);
3714
+ function renderThemeColorAvatar(value, options) {
3715
+ const colorAvatar = {};
3716
+ for (const hue of COLOR_HUES)
3717
+ colorAvatar[hue] = renderThemeColorAvatarColor(value[hue], options);
3718
+ return colorAvatar;
3047
3719
  }
3048
- function isColorConfigBlendKey(str) {
3049
- return COLOR_CONFIG_BLEND_KEYS.includes(str);
3720
+ function renderThemeColorAvatarColor(value, options) {
3721
+ const {
3722
+ baseBg,
3723
+ blendMode: rootBlendMode,
3724
+ colorPalette
3725
+ } = options, blendMode = value._blend || "multiply", rootOptions = {
3726
+ bg: baseBg,
3727
+ blendMode: rootBlendMode,
3728
+ colorPalette
3729
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3730
+ bg,
3731
+ blendMode,
3732
+ colorPalette
3733
+ };
3734
+ return {
3735
+ _blend: blendMode,
3736
+ bg,
3737
+ fg: renderColorValue(value.fg, colorOptions)
3738
+ };
3050
3739
  }
3051
- function isColorValue(str) {
3052
- return str === "black" || str === "white";
3740
+ function renderThemeColorBadge(value, options) {
3741
+ const colorBadge = {};
3742
+ for (const tone of THEME_COLOR_STATE_TONES)
3743
+ colorBadge[tone] = renderThemeColorBadgeColor(value[tone], options);
3744
+ return colorBadge;
3053
3745
  }
3054
- function isColorOpacityValue(str) {
3055
- return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
3746
+ function renderThemeColorBadgeColor(value, options) {
3747
+ const {
3748
+ baseBg,
3749
+ blendMode: rootBlendMode,
3750
+ colorPalette
3751
+ } = options, blendMode = rootBlendMode, rootOptions = {
3752
+ bg: baseBg,
3753
+ blendMode: rootBlendMode,
3754
+ colorPalette
3755
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3756
+ bg,
3757
+ blendMode,
3758
+ colorPalette
3759
+ };
3760
+ return {
3761
+ bg,
3762
+ dot: renderColorValue(value.dot, colorOptions),
3763
+ fg: renderColorValue(value.fg, colorOptions),
3764
+ icon: renderColorValue(value.icon, colorOptions)
3765
+ };
3056
3766
  }
3057
- function isColorMixPercentValue(str) {
3058
- return /^\d+%$/.test(str);
3767
+ function renderThemeColorButton(value, options) {
3768
+ return {
3769
+ default: renderThemeColorButtonTones(value.default, options),
3770
+ ghost: renderThemeColorButtonTones(value.ghost, options),
3771
+ bleed: renderThemeColorButtonTones(value.bleed, options)
3772
+ };
3059
3773
  }
3060
- function parseTokenValue(str) {
3061
- const segments = str.split("/");
3062
- let nextSegment = segments.shift() || "";
3063
- const [segment0, segment0mix] = nextSegment.split(" ");
3064
- if (isColorTintKey(segment0)) {
3065
- const tint = segment0, segment1 = segments.shift() || "";
3066
- if (isColorMixPercentValue(segment0mix)) {
3067
- const mix2 = Number(segment0mix.slice(0, -1)) / 100;
3068
- return {
3069
- type: "color",
3070
- tint,
3071
- mix: mix2
3072
- };
3073
- }
3074
- if (isColorOpacityValue(segment1)) {
3075
- const opacity = Number(segment1);
3076
- return {
3077
- type: "color",
3078
- tint,
3079
- opacity
3080
- };
3774
+ function renderThemeColorButtonTones(value, options) {
3775
+ const colorButtonMode = {};
3776
+ for (const tone of THEME_COLOR_STATE_TONES)
3777
+ colorButtonMode[tone] = renderThemeColorButtonStates(value[tone], options);
3778
+ return colorButtonMode;
3779
+ }
3780
+ function renderThemeColorButtonStates(value, options) {
3781
+ return {
3782
+ enabled: renderThemeColorState(value.enabled, options),
3783
+ hovered: renderThemeColorState(value.hovered, options),
3784
+ pressed: renderThemeColorState(value.pressed, options),
3785
+ selected: renderThemeColorState(value.selected, options),
3786
+ disabled: renderThemeColorState(value.disabled, options)
3787
+ };
3788
+ }
3789
+ function renderThemeColorState(value, options) {
3790
+ const {
3791
+ baseBg,
3792
+ blendMode: rootBlendMode,
3793
+ colorPalette
3794
+ } = options, blendMode = value._blend || "multiply", rootOptions = {
3795
+ bg: baseBg,
3796
+ blendMode: rootBlendMode,
3797
+ colorPalette
3798
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3799
+ bg,
3800
+ blendMode,
3801
+ colorPalette
3802
+ };
3803
+ return {
3804
+ _blend: blendMode,
3805
+ accent: {
3806
+ fg: renderColorValue(value.accent.fg, colorOptions)
3807
+ },
3808
+ avatar: renderThemeColorAvatar(value.avatar, {
3809
+ baseBg: bg,
3810
+ colorPalette,
3811
+ blendMode
3812
+ }),
3813
+ badge: renderThemeColorBadge(value.badge, {
3814
+ baseBg: bg,
3815
+ colorPalette,
3816
+ blendMode
3817
+ }),
3818
+ bg,
3819
+ border: renderColorValue(value.border, colorOptions),
3820
+ code: {
3821
+ bg: renderColorValue(value.code.bg, colorOptions),
3822
+ fg: renderColorValue(value.code.fg, colorOptions)
3823
+ },
3824
+ fg: renderColorValue(value.fg, colorOptions),
3825
+ icon: renderColorValue(value.icon, colorOptions),
3826
+ link: {
3827
+ fg: renderColorValue(value.link.fg, colorOptions)
3828
+ },
3829
+ muted: {
3830
+ bg: renderColorValue(value.muted.bg, colorOptions),
3831
+ fg: renderColorValue(value.muted.fg, colorOptions)
3832
+ },
3833
+ kbd: {
3834
+ bg: renderColorValue(value.kbd.bg, colorOptions),
3835
+ fg: renderColorValue(value.kbd.fg, colorOptions),
3836
+ border: renderColorValue(value.kbd.border, colorOptions)
3837
+ },
3838
+ skeleton: {
3839
+ from: renderColorValue(value.skeleton?.from, colorOptions),
3840
+ to: renderColorValue(value.skeleton?.to, colorOptions)
3081
3841
  }
3082
- return {
3083
- type: "color",
3084
- tint
3085
- };
3842
+ };
3843
+ }
3844
+ function renderThemeColorInput(value, options) {
3845
+ return {
3846
+ default: renderInputStatesColorTheme(value.default, options),
3847
+ invalid: renderInputStatesColorTheme(value.invalid, options)
3848
+ };
3849
+ }
3850
+ function renderInputStatesColorTheme(value, options) {
3851
+ return {
3852
+ enabled: renderInputStateColorTheme(value.enabled, options),
3853
+ hovered: renderInputStateColorTheme(value.hovered, options),
3854
+ readOnly: renderInputStateColorTheme(value.readOnly, options),
3855
+ disabled: renderInputStateColorTheme(value.disabled, options)
3856
+ };
3857
+ }
3858
+ function renderInputStateColorTheme(value, options) {
3859
+ const {
3860
+ baseBg,
3861
+ blendMode: rootBlendMode,
3862
+ colorPalette
3863
+ } = options, blendMode = value._blend || "multiply", rootOptions = {
3864
+ colorPalette,
3865
+ bg: baseBg,
3866
+ blendMode: rootBlendMode
3867
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3868
+ colorPalette,
3869
+ bg,
3870
+ blendMode
3871
+ };
3872
+ return {
3873
+ _blend: blendMode,
3874
+ bg,
3875
+ border: renderColorValue(value.border, colorOptions),
3876
+ fg: renderColorValue(value.fg, colorOptions),
3877
+ muted: {
3878
+ bg: renderColorValue(value.muted.bg, colorOptions)
3879
+ },
3880
+ placeholder: renderColorValue(value.placeholder, colorOptions)
3881
+ };
3882
+ }
3883
+ function renderThemeColorSelectable(value, options) {
3884
+ const colorSelectable = {};
3885
+ for (const tone of THEME_COLOR_STATE_TONES)
3886
+ colorSelectable[tone] = renderThemeColorSelectableStates(value[tone], options);
3887
+ return colorSelectable;
3888
+ }
3889
+ function renderThemeColorSelectableStates(value, options) {
3890
+ return {
3891
+ enabled: renderThemeColorState(value.enabled, options),
3892
+ hovered: renderThemeColorState(value.hovered, options),
3893
+ pressed: renderThemeColorState(value.pressed, options),
3894
+ selected: renderThemeColorState(value.selected, options),
3895
+ disabled: renderThemeColorState(value.disabled, options)
3896
+ };
3897
+ }
3898
+ function renderSyntaxColorTheme(value, options) {
3899
+ const {
3900
+ colorPalette,
3901
+ baseBg,
3902
+ blendMode
3903
+ } = options, colorOptions = {
3904
+ colorPalette,
3905
+ bg: baseBg,
3906
+ blendMode
3907
+ };
3908
+ return {
3909
+ atrule: renderColorValue(value.atrule, colorOptions),
3910
+ attrName: renderColorValue(value.attrName, colorOptions),
3911
+ attrValue: renderColorValue(value.attrValue, colorOptions),
3912
+ attribute: renderColorValue(value.attribute, colorOptions),
3913
+ boolean: renderColorValue(value.boolean, colorOptions),
3914
+ builtin: renderColorValue(value.builtin, colorOptions),
3915
+ cdata: renderColorValue(value.cdata, colorOptions),
3916
+ char: renderColorValue(value.char, colorOptions),
3917
+ class: renderColorValue(value.class, colorOptions),
3918
+ className: renderColorValue(value.className, colorOptions),
3919
+ comment: renderColorValue(value.comment, colorOptions),
3920
+ constant: renderColorValue(value.constant, colorOptions),
3921
+ deleted: renderColorValue(value.deleted, colorOptions),
3922
+ doctype: renderColorValue(value.doctype, colorOptions),
3923
+ entity: renderColorValue(value.entity, colorOptions),
3924
+ function: renderColorValue(value.function, colorOptions),
3925
+ hexcode: renderColorValue(value.hexcode, colorOptions),
3926
+ id: renderColorValue(value.id, colorOptions),
3927
+ important: renderColorValue(value.important, colorOptions),
3928
+ inserted: renderColorValue(value.inserted, colorOptions),
3929
+ keyword: renderColorValue(value.keyword, colorOptions),
3930
+ number: renderColorValue(value.number, colorOptions),
3931
+ operator: renderColorValue(value.operator, colorOptions),
3932
+ prolog: renderColorValue(value.prolog, colorOptions),
3933
+ property: renderColorValue(value.property, colorOptions),
3934
+ pseudoClass: renderColorValue(value.pseudoClass, colorOptions),
3935
+ pseudoElement: renderColorValue(value.pseudoElement, colorOptions),
3936
+ punctuation: renderColorValue(value.punctuation, colorOptions),
3937
+ regex: renderColorValue(value.regex, colorOptions),
3938
+ selector: renderColorValue(value.selector, colorOptions),
3939
+ string: renderColorValue(value.string, colorOptions),
3940
+ symbol: renderColorValue(value.symbol, colorOptions),
3941
+ tag: renderColorValue(value.tag, colorOptions),
3942
+ unit: renderColorValue(value.unit, colorOptions),
3943
+ url: renderColorValue(value.url, colorOptions),
3944
+ variable: renderColorValue(value.variable, colorOptions)
3945
+ };
3946
+ }
3947
+ function buildTheme(config) {
3948
+ const colorTheme = buildColorTheme(config), v2 = {
3949
+ _version: 2,
3950
+ avatar: config?.avatar ?? defaultThemeConfig.avatar,
3951
+ button: config?.button ?? defaultThemeConfig.button,
3952
+ card: config?.card ?? defaultThemeConfig.card,
3953
+ // How colors are generated:
3954
+ // 1. Merge custom tokens with default tokens
3955
+ // 2. Generate tree of color keys (gray/500, black, white, etc.)
3956
+ // 3. Apply mixing and render to hex values
3957
+ // render(build(mergeWithDefaults()))
3958
+ color: renderThemeColorSchemes(colorTheme, config),
3959
+ container: config?.container ?? defaultThemeConfig.container,
3960
+ font: config?.font ?? defaultThemeFonts$1,
3961
+ input: config?.input ?? defaultThemeConfig.input,
3962
+ layer: config?.layer ?? defaultThemeConfig.layer,
3963
+ media: config?.media ?? defaultThemeConfig.media,
3964
+ radius: config?.radius ?? defaultThemeConfig.radius,
3965
+ shadow: config?.shadow ?? defaultThemeConfig.shadow,
3966
+ space: config?.space ?? defaultThemeConfig.space,
3967
+ style: config?.style ?? defaultThemeConfig.style
3968
+ };
3969
+ return v2_v0(v2);
3970
+ }
3971
+ const AVATAR_SIZE = [0, 1, 2, 3], CONTAINER_SCALE = [0, 1, 2, 3, 4, 5], CONTAINER = [...CONTAINER_SCALE, "auto"], RADIUS = [0, 1, 2, 3, 4, 5, 6], SPACE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], FONT_CODE_SIZE = [0, 1, 2, 3, 4], FONT_HEADING_SIZE = [0, 1, 2, 3, 4, 5], FONT_LABEL_SIZE = [0, 1, 2, 3, 4, 5], FONT_TEXT_SIZE = [0, 1, 2, 3, 4], SHADOW = [0, 1, 2, 3, 4, 5], HUES = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"], TINTS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950], RE_PERCENTAGE = /^([0-9]+)%/, RE_OPACITY = /^(1|0\.[0-9]+)?/;
3972
+ function _parseColorToken(str, options) {
3973
+ const {
3974
+ defaultHue
3975
+ } = options;
3976
+ let cursor = 0;
3977
+ return parseColorNode();
3978
+ function _consume(s) {
3979
+ if (str.startsWith(s, cursor))
3980
+ return cursor += s.length, s;
3086
3981
  }
3087
- if (isColorValue(segment0)) {
3088
- const key = segment0, segment1 = segments.shift() || "";
3089
- if (isColorMixPercentValue(segment0mix)) {
3090
- const mix2 = Number(segment0mix.slice(0, -1)) / 100;
3091
- return {
3092
- type: "color",
3093
- key,
3094
- mix: mix2
3095
- };
3096
- }
3097
- if (isColorOpacityValue(segment1)) {
3098
- const opacity = Number(segment1);
3982
+ function _peek() {
3983
+ return str[cursor];
3984
+ }
3985
+ function parseColorNode() {
3986
+ ignoreWhitespace();
3987
+ let v = _consume("black") || _consume("white");
3988
+ if (v)
3099
3989
  return {
3100
3990
  type: "color",
3101
- key,
3102
- opacity
3991
+ name: v,
3992
+ opacity: parseOpacity() ?? 1,
3993
+ mix: parseMix() ?? 1
3103
3994
  };
3104
- }
3105
- return {
3106
- type: "color",
3107
- key
3108
- };
3109
- }
3110
- if (isColorHueKey(segment0)) {
3111
- const hue = segment0;
3112
- nextSegment = segments.shift() || "";
3113
- const [segment1, segment1mix] = nextSegment.split(" ");
3114
- if (isColorTintKey(segment1)) {
3115
- const tint = segment1, segment2 = segments.shift() || "";
3116
- if (isColorMixPercentValue(segment1mix)) {
3117
- const mix2 = Number(segment1mix.slice(0, -1)) / 100;
3118
- return {
3119
- type: "color",
3120
- hue,
3121
- tint,
3122
- mix: mix2
3123
- };
3124
- }
3125
- if (isColorOpacityValue(segment2)) {
3126
- const opacity = Number(segment2);
3995
+ for (const hue of HUES)
3996
+ if (v = _consume(String(hue)), v) {
3997
+ if (_peek() !== "-")
3998
+ throw new Error('Expected "-" after hue key');
3999
+ cursor += 1;
4000
+ const tint2 = parseTint();
4001
+ if (!tint2)
4002
+ throw new Error("Expected tint after hue");
3127
4003
  return {
3128
- type: "color",
4004
+ type: "tint",
3129
4005
  hue,
3130
- tint,
3131
- opacity
4006
+ tint: tint2,
4007
+ opacity: parseOpacity() ?? 1,
4008
+ mix: parseMix() ?? 1
3132
4009
  };
3133
4010
  }
4011
+ const tint = parseTint();
4012
+ if (tint)
3134
4013
  return {
3135
- type: "color",
3136
- hue,
3137
- tint
4014
+ type: "tint",
4015
+ hue: defaultHue,
4016
+ tint,
4017
+ opacity: parseOpacity() ?? 1,
4018
+ mix: parseMix() ?? 1
3138
4019
  };
4020
+ if (str === "inherit")
4021
+ return {
4022
+ type: "inherit"
4023
+ };
4024
+ throw new Error(`Invalid color: ${str}`);
4025
+ }
4026
+ function parseTint() {
4027
+ ignoreWhitespace();
4028
+ let v = Number(str.slice(cursor, cursor + 3));
4029
+ if (TINTS.includes(v))
4030
+ return cursor += 3, v;
4031
+ if (v = Number(str.slice(cursor, cursor + 2)), TINTS.includes(v))
4032
+ return cursor += 2, v;
4033
+ }
4034
+ function parseMix() {
4035
+ ignoreWhitespace();
4036
+ const match = RE_PERCENTAGE.exec(str.slice(cursor));
4037
+ if (match)
4038
+ return cursor += match[0].length, parseFloat(match[1]) / 100;
4039
+ }
4040
+ function parseOpacity() {
4041
+ if (ignoreWhitespace(), _peek() === "/") {
4042
+ cursor += 1;
4043
+ const match = RE_OPACITY.exec(str.slice(cursor));
4044
+ if (match)
4045
+ return cursor += match[0].length, parseFloat(match[1]);
4046
+ cursor -= 1;
3139
4047
  }
3140
- return {
3141
- type: "hue",
3142
- value: hue
3143
- };
3144
4048
  }
3145
- if (isColorBlendModeValue(segment0))
3146
- return {
3147
- type: "blendMode",
3148
- value: segment0
3149
- };
4049
+ function ignoreWhitespace() {
4050
+ for (; _peek() === " "; )
4051
+ cursor++;
4052
+ }
4053
+ }
4054
+ const defaultThemeFonts = {
4055
+ code: {
4056
+ family: "ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace",
4057
+ weight: {
4058
+ regular: 400,
4059
+ medium: 500,
4060
+ semibold: 600,
4061
+ bold: 700
4062
+ },
4063
+ scale: [{
4064
+ ascenderHeight: 4,
4065
+ descenderHeight: 4,
4066
+ fontSize: 10,
4067
+ iconSize: 17,
4068
+ lineHeight: 15,
4069
+ letterSpacing: 0,
4070
+ customIconSize: 12
4071
+ }, {
4072
+ ascenderHeight: 5,
4073
+ descenderHeight: 5,
4074
+ fontSize: 13,
4075
+ iconSize: 21,
4076
+ lineHeight: 19,
4077
+ letterSpacing: 0,
4078
+ customIconSize: 16
4079
+ }, {
4080
+ ascenderHeight: 6,
4081
+ descenderHeight: 6,
4082
+ fontSize: 16,
4083
+ iconSize: 25,
4084
+ lineHeight: 23,
4085
+ letterSpacing: 0,
4086
+ customIconSize: 20
4087
+ }, {
4088
+ ascenderHeight: 7,
4089
+ descenderHeight: 7,
4090
+ fontSize: 19,
4091
+ iconSize: 29,
4092
+ lineHeight: 27,
4093
+ letterSpacing: 0,
4094
+ customIconSize: 24
4095
+ }, {
4096
+ ascenderHeight: 8,
4097
+ descenderHeight: 8,
4098
+ fontSize: 22,
4099
+ iconSize: 33,
4100
+ lineHeight: 31,
4101
+ letterSpacing: 0,
4102
+ customIconSize: 28
4103
+ }]
4104
+ },
4105
+ heading: {
4106
+ family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
4107
+ featureSettings: "'liga' 1, 'calt' 1, 'ss01' 1, 'ss03' 1, 'zero' 1",
4108
+ weight: {
4109
+ regular: 600,
4110
+ medium: 700,
4111
+ semibold: 800,
4112
+ bold: 900
4113
+ },
4114
+ scale: [{
4115
+ ascenderHeight: 5,
4116
+ descenderHeight: 5,
4117
+ fontSize: 13,
4118
+ iconSize: 17,
4119
+ lineHeight: 19,
4120
+ letterSpacing: 0,
4121
+ customIconSize: 12
4122
+ }, {
4123
+ ascenderHeight: 6,
4124
+ descenderHeight: 6,
4125
+ fontSize: 16,
4126
+ iconSize: 25,
4127
+ lineHeight: 23,
4128
+ letterSpacing: 0,
4129
+ customIconSize: 20
4130
+ }, {
4131
+ ascenderHeight: 7,
4132
+ descenderHeight: 7,
4133
+ fontSize: 21,
4134
+ iconSize: 33,
4135
+ lineHeight: 29,
4136
+ letterSpacing: -0.25,
4137
+ customIconSize: 28
4138
+ }, {
4139
+ ascenderHeight: 8,
4140
+ descenderHeight: 8,
4141
+ fontSize: 27,
4142
+ iconSize: 41,
4143
+ lineHeight: 35,
4144
+ letterSpacing: -0.5,
4145
+ customIconSize: 36
4146
+ }, {
4147
+ ascenderHeight: 9.5,
4148
+ descenderHeight: 8.5,
4149
+ fontSize: 33,
4150
+ iconSize: 49,
4151
+ lineHeight: 41,
4152
+ letterSpacing: -1,
4153
+ customIconSize: 44
4154
+ }, {
4155
+ ascenderHeight: 10.5,
4156
+ descenderHeight: 9.5,
4157
+ fontSize: 38,
4158
+ iconSize: 53,
4159
+ lineHeight: 47,
4160
+ letterSpacing: -1,
4161
+ customIconSize: 48
4162
+ }]
4163
+ },
4164
+ label: {
4165
+ family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
4166
+ weight: {
4167
+ regular: 500,
4168
+ medium: 600,
4169
+ semibold: 700,
4170
+ bold: 800
4171
+ },
4172
+ scale: [{
4173
+ ascenderHeight: 2,
4174
+ descenderHeight: 2,
4175
+ fontSize: 8.1,
4176
+ iconSize: 13,
4177
+ lineHeight: 10,
4178
+ letterSpacing: 0.5,
4179
+ customIconSize: 8
4180
+ }, {
4181
+ ascenderHeight: 1.5,
4182
+ descenderHeight: 2.5,
4183
+ fontSize: 9.5,
4184
+ iconSize: 15,
4185
+ lineHeight: 11,
4186
+ letterSpacing: 0.5,
4187
+ customIconSize: 10
4188
+ }, {
4189
+ ascenderHeight: 2,
4190
+ descenderHeight: 2,
4191
+ fontSize: 10.8,
4192
+ iconSize: 17,
4193
+ lineHeight: 12,
4194
+ letterSpacing: 0.5,
4195
+ customIconSize: 12
4196
+ }, {
4197
+ ascenderHeight: 2,
4198
+ descenderHeight: 2,
4199
+ fontSize: 12.25,
4200
+ iconSize: 19,
4201
+ lineHeight: 13,
4202
+ letterSpacing: 0.5,
4203
+ customIconSize: 14
4204
+ }, {
4205
+ ascenderHeight: 1.5,
4206
+ descenderHeight: 2.5,
4207
+ fontSize: 13.6,
4208
+ iconSize: 21,
4209
+ lineHeight: 14,
4210
+ letterSpacing: 0.5,
4211
+ customIconSize: 16
4212
+ }, {
4213
+ ascenderHeight: 2,
4214
+ descenderHeight: 2,
4215
+ fontSize: 15,
4216
+ iconSize: 23,
4217
+ lineHeight: 15,
4218
+ letterSpacing: 0.5,
4219
+ customIconSize: 18
4220
+ }]
4221
+ },
4222
+ text: {
4223
+ family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
4224
+ weight: {
4225
+ regular: 400,
4226
+ medium: 500,
4227
+ semibold: 600,
4228
+ bold: 700
4229
+ },
4230
+ scale: [{
4231
+ ascenderHeight: 4,
4232
+ descenderHeight: 4,
4233
+ fontSize: 10,
4234
+ iconSize: 17,
4235
+ lineHeight: 15,
4236
+ letterSpacing: 0,
4237
+ customIconSize: 12
4238
+ }, {
4239
+ ascenderHeight: 5,
4240
+ descenderHeight: 5,
4241
+ fontSize: 13,
4242
+ iconSize: 21,
4243
+ lineHeight: 19,
4244
+ letterSpacing: 0,
4245
+ customIconSize: 16
4246
+ }, {
4247
+ ascenderHeight: 6,
4248
+ descenderHeight: 6,
4249
+ fontSize: 15,
4250
+ iconSize: 25,
4251
+ lineHeight: 23,
4252
+ letterSpacing: 0,
4253
+ customIconSize: 20
4254
+ }, {
4255
+ ascenderHeight: 7,
4256
+ descenderHeight: 7,
4257
+ fontSize: 18,
4258
+ iconSize: 29,
4259
+ lineHeight: 27,
4260
+ letterSpacing: 0,
4261
+ customIconSize: 24
4262
+ }, {
4263
+ ascenderHeight: 8,
4264
+ descenderHeight: 8,
4265
+ fontSize: 21,
4266
+ iconSize: 33,
4267
+ lineHeight: 31,
4268
+ letterSpacing: 0,
4269
+ customIconSize: 28
4270
+ }]
4271
+ }
4272
+ }, defaultTokens = {
4273
+ color: {
4274
+ "*": {
4275
+ backdrop: ["gray-100/0.5", "black/0.5"],
4276
+ code: {
4277
+ bg: ["50", "950"],
4278
+ fg: ["700", "300"],
4279
+ token: {
4280
+ atrule: ["purple-600", "purple-400"],
4281
+ attrName: ["green-600", "green-400"],
4282
+ attrValue: ["yellow-600", "yellow-400"],
4283
+ attribute: ["yellow-600", "yellow-400"],
4284
+ boolean: ["purple-600", "purple-400"],
4285
+ builtin: ["purple-600", "purple-400"],
4286
+ cdata: ["yellow-600", "yellow-400"],
4287
+ char: ["yellow-600", "yellow-400"],
4288
+ class: ["orange-600", "orange-400"],
4289
+ className: ["cyan-600", "cyan-400"],
4290
+ comment: ["gray-400", "gray-600"],
4291
+ constant: ["purple-600", "purple-400"],
4292
+ deleted: ["red-600", "red-400"],
4293
+ entity: ["red-600", "red-400"],
4294
+ function: ["green-600", "green-400"],
4295
+ hexcode: ["blue-600", "blue-400"],
4296
+ id: ["purple-600", "purple-400"],
4297
+ important: ["purple-600", "purple-400"],
4298
+ inserted: ["green-600", "green-400"],
4299
+ keyword: ["magenta-600", "magenta-400"],
4300
+ number: ["purple-600", "purple-400"],
4301
+ operator: ["magenta-600", "magenta-400"],
4302
+ prolog: ["gray-600", "gray-400"],
4303
+ property: ["blue-600", "blue-400"],
4304
+ pseudoClass: ["yellow-600", "yellow-400"],
4305
+ pseudoElement: ["yellow-600", "yellow-400"],
4306
+ punctuation: ["gray-600", "gray-400"],
4307
+ regex: ["blue-600", "blue-400"],
4308
+ selector: ["red-600", "red-400"],
4309
+ string: ["yellow-600", "yellow-400"],
4310
+ symbol: ["purple-600", "purple-400"],
4311
+ tag: ["red-600", "red-400"],
4312
+ unit: ["orange-600", "orange-400"],
4313
+ url: ["red-600", "red-400"],
4314
+ variable: ["red-600", "red-400"]
4315
+ }
4316
+ },
4317
+ focusRing: ["blue-500", "blue-500"],
4318
+ link: {
4319
+ fg: ["blue-600", "blue-400"]
4320
+ },
4321
+ shadow: {
4322
+ outline: ["600/0.3", "500/0.4"],
4323
+ umbra: ["600/0.1", "black/0.2"],
4324
+ penumbra: ["600/0.07", "black/0.14"],
4325
+ ambient: ["600/0.06", "black/0.12"]
4326
+ },
4327
+ skeleton: {
4328
+ from: ["200 70%", "800 35%"],
4329
+ to: ["200 40%", "800 50%"]
4330
+ },
4331
+ variant: {
4332
+ tinted: {
4333
+ "*": {
4334
+ bg: {
4335
+ 0: ["100 75%", "900 75%"],
4336
+ 4: ["300", "700"]
4337
+ },
4338
+ border: {
4339
+ 0: ["200", "700 50%"],
4340
+ 4: ["300 75%", "500"]
4341
+ },
4342
+ fg: {
4343
+ 0: ["900", "100"],
4344
+ 4: ["700", "300"]
4345
+ }
4346
+ },
4347
+ primary: {
4348
+ _hue: "blue",
4349
+ bg: {
4350
+ 0: ["inherit", "inherit"]
4351
+ }
4352
+ },
4353
+ suggest: {
4354
+ _hue: "purple",
4355
+ bg: {
4356
+ 0: ["inherit", "inherit"]
4357
+ }
4358
+ },
4359
+ positive: {
4360
+ _hue: "green",
4361
+ bg: {
4362
+ 0: ["inherit", "inherit"]
4363
+ }
4364
+ },
4365
+ caution: {
4366
+ _hue: "yellow",
4367
+ bg: {
4368
+ 0: ["inherit", "inherit"]
4369
+ }
4370
+ },
4371
+ critical: {
4372
+ _hue: "red",
4373
+ bg: {
4374
+ 0: ["inherit", "inherit"]
4375
+ }
4376
+ }
4377
+ },
4378
+ solid: {
4379
+ "*": {
4380
+ bg: {
4381
+ 0: ["500", "400"],
4382
+ 4: ["600", "300"]
4383
+ },
4384
+ border: {
4385
+ 0: ["400", "200"],
4386
+ 4: ["500", "100"]
4387
+ },
4388
+ fg: {
4389
+ 0: ["white", "black"],
4390
+ 4: ["200", "700"]
4391
+ }
4392
+ },
4393
+ default: {
4394
+ bg: {
4395
+ 0: ["800", "200"],
4396
+ 4: ["black", "white"]
4397
+ },
4398
+ border: {
4399
+ 0: ["700", "300"],
4400
+ 4: ["800", "200"]
4401
+ }
4402
+ },
4403
+ primary: {
4404
+ _hue: "blue"
4405
+ },
4406
+ suggest: {
4407
+ _hue: "purple"
4408
+ },
4409
+ positive: {
4410
+ _hue: "green"
4411
+ },
4412
+ caution: {
4413
+ _hue: "yellow"
4414
+ },
4415
+ critical: {
4416
+ _hue: "red"
4417
+ }
4418
+ }
4419
+ }
4420
+ },
4421
+ transparent: {
4422
+ variant: {
4423
+ tinted: {
4424
+ "*": {
4425
+ bg: {
4426
+ 0: ["gray-50", "black"],
4427
+ 4: ["200", "800"]
4428
+ },
4429
+ border: {
4430
+ 0: ["200 50%", "800 50%"],
4431
+ 4: ["300", "600"]
4432
+ },
4433
+ fg: {
4434
+ 0: ["black", "100"],
4435
+ 4: ["700", "400"]
4436
+ }
4437
+ }
4438
+ }
4439
+ }
4440
+ },
4441
+ default: {
4442
+ variant: {
4443
+ tinted: {
4444
+ "*": {
4445
+ bg: {
4446
+ 0: ["white", "950"],
4447
+ 4: ["200", "800"]
4448
+ },
4449
+ border: {
4450
+ 0: ["200 50%", "800 50%"],
4451
+ 4: ["300 75%", "600"]
4452
+ },
4453
+ fg: {
4454
+ 0: ["black", "white"],
4455
+ 4: ["600", "400"]
4456
+ }
4457
+ }
4458
+ }
4459
+ }
4460
+ },
4461
+ primary: {
4462
+ _hue: "blue"
4463
+ },
4464
+ suggest: {
4465
+ _hue: "purple"
4466
+ },
4467
+ positive: {
4468
+ _hue: "green"
4469
+ },
4470
+ caution: {
4471
+ _hue: "yellow"
4472
+ },
4473
+ critical: {
4474
+ _hue: "red"
4475
+ }
4476
+ }
4477
+ };
4478
+ function merge(...records) {
4479
+ return records.filter(Boolean).reduce(_merge, {});
4480
+ }
4481
+ function _merge(acc, source) {
4482
+ for (const key of Object.keys(source)) {
4483
+ const prevValue = acc[key], nextValue = source[key];
4484
+ isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
4485
+ }
4486
+ return acc;
4487
+ }
4488
+ function isRecord(value) {
4489
+ return value !== null && typeof value == "object" && !Array.isArray(value);
4490
+ }
4491
+ const defaultElementTokens = {
4492
+ bg: {
4493
+ 0: ["950", "50"],
4494
+ 4: ["700", "300"]
4495
+ },
4496
+ border: {
4497
+ 0: ["700", "300"],
4498
+ 4: ["400", "600"]
4499
+ },
4500
+ fg: {
4501
+ 0: ["100", "900"],
4502
+ 4: ["400", "600"]
4503
+ }
4504
+ };
4505
+ function resolveTokens(tokens = {}) {
4506
+ return {
4507
+ color: {
4508
+ "*": resolveCardColorTokens(tokens.color?.["*"]),
4509
+ ...THEME_COLOR_CARD_TONES.reduce((acc, tone) => ({
4510
+ ...acc,
4511
+ [tone]: resolveCardColorTokens(merge(tokens.color?.["*"], tokens.color?.[tone]))
4512
+ }), {})
4513
+ }
4514
+ };
4515
+ }
4516
+ function resolveCardColorTokens(tokens) {
4517
+ return {
4518
+ _hue: tokens?._hue ?? "gray",
4519
+ avatar: {
4520
+ gray: {
4521
+ _hue: tokens?.avatar?.gray?._hue ?? "gray",
4522
+ bg: tokens?.avatar?.gray?.bg ?? ["500", "400"],
4523
+ fg: tokens?.avatar?.gray?.fg ?? ["white", "900"]
4524
+ },
4525
+ blue: {
4526
+ _hue: tokens?.avatar?.blue?._hue ?? "blue",
4527
+ bg: tokens?.avatar?.blue?.bg ?? ["500", "400"],
4528
+ fg: tokens?.avatar?.blue?.fg ?? ["white", "900"]
4529
+ },
4530
+ purple: {
4531
+ _hue: tokens?.avatar?.purple?._hue ?? "purple",
4532
+ bg: tokens?.avatar?.purple?.bg ?? ["500", "400"],
4533
+ fg: tokens?.avatar?.purple?.fg ?? ["white", "900"]
4534
+ },
4535
+ magenta: {
4536
+ _hue: tokens?.avatar?.magenta?._hue ?? "magenta",
4537
+ bg: tokens?.avatar?.magenta?.bg ?? ["500", "400"],
4538
+ fg: tokens?.avatar?.magenta?.fg ?? ["white", "900"]
4539
+ },
4540
+ red: {
4541
+ _hue: tokens?.avatar?.red?._hue ?? "red",
4542
+ bg: tokens?.avatar?.red?.bg ?? ["500", "400"],
4543
+ fg: tokens?.avatar?.red?.fg ?? ["white", "900"]
4544
+ },
4545
+ orange: {
4546
+ _hue: tokens?.avatar?.orange?._hue ?? "orange",
4547
+ bg: tokens?.avatar?.orange?.bg ?? ["500", "400"],
4548
+ fg: tokens?.avatar?.orange?.fg ?? ["white", "900"]
4549
+ },
4550
+ yellow: {
4551
+ _hue: tokens?.avatar?.yellow?._hue ?? "yellow",
4552
+ bg: tokens?.avatar?.yellow?.bg ?? ["500", "400"],
4553
+ fg: tokens?.avatar?.yellow?.fg ?? ["white", "900"]
4554
+ },
4555
+ green: {
4556
+ _hue: tokens?.avatar?.green?._hue ?? "green",
4557
+ bg: tokens?.avatar?.green?.bg ?? ["500", "400"],
4558
+ fg: tokens?.avatar?.green?.fg ?? ["white", "900"]
4559
+ },
4560
+ cyan: {
4561
+ _hue: tokens?.avatar?.cyan?._hue ?? "cyan",
4562
+ bg: tokens?.avatar?.cyan?.bg ?? ["500", "400"],
4563
+ fg: tokens?.avatar?.cyan?.fg ?? ["white", "900"]
4564
+ }
4565
+ },
4566
+ backdrop: tokens?.backdrop ?? ["100", "900"],
4567
+ code: {
4568
+ bg: tokens?.code?.bg ?? ["50", "950"],
4569
+ fg: tokens?.code?.fg ?? ["600", "400"],
4570
+ token: {
4571
+ atrule: tokens?.code?.token?.atrule ?? ["600", "400"],
4572
+ attribute: tokens?.code?.token?.attribute ?? ["600", "400"],
4573
+ attrName: tokens?.code?.token?.attrName ?? ["600", "400"],
4574
+ attrValue: tokens?.code?.token?.attrValue ?? ["600", "400"],
4575
+ boolean: tokens?.code?.token?.boolean ?? ["600", "400"],
4576
+ builtin: tokens?.code?.token?.builtin ?? ["600", "400"],
4577
+ cdata: tokens?.code?.token?.cdata ?? ["600", "400"],
4578
+ char: tokens?.code?.token?.char ?? ["600", "400"],
4579
+ class: tokens?.code?.token?.class ?? ["600", "400"],
4580
+ className: tokens?.code?.token?.className ?? ["600", "400"],
4581
+ comment: tokens?.code?.token?.comment ?? ["400", "600"],
4582
+ constant: tokens?.code?.token?.constant ?? ["600", "400"],
4583
+ deleted: tokens?.code?.token?.deleted ?? ["600", "400"],
4584
+ doctype: tokens?.code?.token?.doctype ?? ["600", "400"],
4585
+ entity: tokens?.code?.token?.entity ?? ["600", "400"],
4586
+ function: tokens?.code?.token?.function ?? ["600", "400"],
4587
+ hexcode: tokens?.code?.token?.hexcode ?? ["600", "400"],
4588
+ id: tokens?.code?.token?.id ?? ["600", "400"],
4589
+ important: tokens?.code?.token?.important ?? ["600", "400"],
4590
+ inserted: tokens?.code?.token?.inserted ?? ["600", "400"],
4591
+ keyword: tokens?.code?.token?.keyword ?? ["600", "400"],
4592
+ number: tokens?.code?.token?.number ?? ["600", "400"],
4593
+ operator: tokens?.code?.token?.operator ?? ["600", "400"],
4594
+ prolog: tokens?.code?.token?.prolog ?? ["600", "400"],
4595
+ property: tokens?.code?.token?.property ?? ["600", "400"],
4596
+ pseudoClass: tokens?.code?.token?.pseudoClass ?? ["600", "400"],
4597
+ pseudoElement: tokens?.code?.token?.pseudoElement ?? ["600", "400"],
4598
+ punctuation: tokens?.code?.token?.punctuation ?? ["600", "400"],
4599
+ regex: tokens?.code?.token?.regex ?? ["600", "400"],
4600
+ selector: tokens?.code?.token?.selector ?? ["600", "400"],
4601
+ string: tokens?.code?.token?.string ?? ["600", "400"],
4602
+ symbol: tokens?.code?.token?.symbol ?? ["600", "400"],
4603
+ tag: tokens?.code?.token?.tag ?? ["600", "400"],
4604
+ unit: tokens?.code?.token?.unit ?? ["600", "400"],
4605
+ url: tokens?.code?.token?.url ?? ["600", "400"],
4606
+ variable: tokens?.code?.token?.variable ?? ["600", "400"]
4607
+ }
4608
+ },
4609
+ focusRing: tokens?.focusRing ?? ["500", "500"],
4610
+ link: {
4611
+ fg: tokens?.link?.fg ?? ["600", "400"]
4612
+ },
4613
+ shadow: {
4614
+ outline: tokens?.shadow?.outline ?? ["500", "500"],
4615
+ umbra: tokens?.shadow?.umbra ?? ["500", "500"],
4616
+ penumbra: tokens?.shadow?.penumbra ?? ["500", "500"],
4617
+ ambient: tokens?.shadow?.ambient ?? ["500", "500"]
4618
+ },
4619
+ skeleton: {
4620
+ from: tokens?.skeleton?.from ?? ["100", "900"],
4621
+ to: tokens?.skeleton?.to ?? ["50", "950"]
4622
+ },
4623
+ variant: {
4624
+ solid: {
4625
+ "*": resolveElementTokens(tokens?.variant?.solid?.["*"]),
4626
+ ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.solid?.["*"], tokens?.variant?.solid?.[tone])), acc), {})
4627
+ },
4628
+ tinted: {
4629
+ "*": resolveElementTokens(tokens?.variant?.tinted?.["*"]),
4630
+ ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.tinted?.["*"], tokens?.variant?.tinted?.[tone])), acc), {})
4631
+ }
4632
+ }
4633
+ };
4634
+ }
4635
+ function resolveElementTokens(tokens) {
4636
+ return {
4637
+ _hue: tokens?._hue ?? "gray",
4638
+ bg: {
4639
+ 0: tokens?.bg?.[0] ?? defaultElementTokens.bg[0],
4640
+ 4: tokens?.bg?.[4] ?? defaultElementTokens.bg[4]
4641
+ },
4642
+ border: {
4643
+ 0: tokens?.border?.[0] ?? defaultElementTokens.border[0],
4644
+ 4: tokens?.border?.[4] ?? defaultElementTokens.border[4]
4645
+ },
4646
+ fg: {
4647
+ 0: tokens?.fg?.[0] ?? defaultElementTokens.fg[0],
4648
+ 4: tokens?.fg?.[4] ?? defaultElementTokens.fg[4]
4649
+ }
4650
+ };
4651
+ }
4652
+ function buildTheme_v3(options) {
4653
+ const {
4654
+ v2
4655
+ } = options ?? {}, tokens = resolveTokens(options?.tokens ?? defaultTokens);
4656
+ return {
4657
+ _version: 3,
4658
+ _tokens: tokens,
4659
+ avatar: v2?.avatar ?? defaultThemeConfig.avatar,
4660
+ button: v2?.button ?? defaultThemeConfig.button,
4661
+ card: v2?.card ?? defaultThemeConfig.card,
4662
+ color: tokens.color,
4663
+ container: v2?.container ?? defaultThemeConfig.container,
4664
+ font: defaultThemeFonts,
4665
+ input: v2?.input ?? defaultThemeConfig.input,
4666
+ layer: v2?.layer ?? defaultThemeConfig.layer,
4667
+ media: v2?.media ?? defaultThemeConfig.media,
4668
+ palette: {
4669
+ black: black$1,
4670
+ white: white$1,
4671
+ hues
4672
+ },
4673
+ // TODO
4674
+ radius: v2?.radius ?? defaultThemeConfig.radius,
4675
+ // TODO
4676
+ shadow: v2?.shadow ?? defaultThemeConfig.shadow,
4677
+ // TODO
4678
+ space: v2?.space ?? defaultThemeConfig.space
4679
+ };
3150
4680
  }
3151
- const cache = /* @__PURE__ */ new WeakMap();
4681
+ const COLOR_VARIANTS = ["tinted", "solid"], AVATAR_COLORS = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"], cache = /* @__PURE__ */ new WeakMap();
3152
4682
  function getTheme_v2(theme) {
3153
4683
  if (theme.sanity.v2?._resolved) return theme.sanity.v2;
3154
4684
  const cached_v2 = cache.get(theme);