@starasia/theme 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx as w, jsxs as G } from "react/jsx-runtime";
2
- import { createContext as de, useState as M, useMemo as T, useEffect as _, useRef as be, useCallback as E, useContext as ne } from "react";
3
- const fe = (e, r) => {
1
+ import { jsx as w, jsxs as q } from "react/jsx-runtime";
2
+ import { createContext as ke, useState as C, useMemo as G, useEffect as R, useRef as pe, useCallback as M, useContext as le } from "react";
3
+ const ve = (e, r) => {
4
4
  if (typeof document > "u")
5
5
  return;
6
6
  const a = document.getElementById(r);
@@ -10,7 +10,7 @@ const fe = (e, r) => {
10
10
  const s = document.createElement("style");
11
11
  s.id = r, s.textContent = e, document.head.appendChild(s);
12
12
  }
13
- }, ue = (e) => {
13
+ }, ge = (e) => {
14
14
  if (typeof document > "u")
15
15
  return null;
16
16
  const r = document.getElementById(e);
@@ -19,7 +19,7 @@ const fe = (e, r) => {
19
19
  const a = document.createElement("style");
20
20
  return a.id = e, document.head.appendChild(a), a;
21
21
  };
22
- function U(e) {
22
+ function I(e) {
23
23
  let r = e.trim().replace(/^#/, "");
24
24
  r.length === 3 && (r = r.split("").map((s) => s + s).join("")), r.length === 8 && (r = r.slice(0, 6));
25
25
  const a = parseInt(r, 16);
@@ -29,71 +29,74 @@ function U(e) {
29
29
  b: (a & 255) / 255
30
30
  };
31
31
  }
32
- const j = (e) => Math.max(0, Math.min(255, Math.round(e * 255))).toString(16).padStart(2, "0");
33
- function ke({ r: e, g: r, b: a }) {
34
- return `#${j(e)}${j(r)}${j(a)}`;
32
+ const U = (e) => Math.max(0, Math.min(255, Math.round(e * 255))).toString(16).padStart(2, "0");
33
+ function ye({ r: e, g: r, b: a }) {
34
+ return `#${U(e)}${U(r)}${U(a)}`;
35
35
  }
36
- const x = (e) => e <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4), B = (e) => e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055;
37
- function pe(e, r, a) {
38
- const s = 0.4122214708 * e + 0.5363325363 * r + 0.0514459929 * a, c = 0.2119034982 * e + 0.6806995451 * r + 0.1073969566 * a, o = 0.0883024619 * e + 0.2817188376 * r + 0.6299787005 * a, l = Math.cbrt(s), d = Math.cbrt(c), n = Math.cbrt(o);
36
+ const x = (e) => e <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4), J = (e) => e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055;
37
+ function me(e, r, a) {
38
+ const s = 0.4122214708 * e + 0.5363325363 * r + 0.0514459929 * a, c = 0.2119034982 * e + 0.6806995451 * r + 0.1073969566 * a, o = 0.0883024619 * e + 0.2817188376 * r + 0.6299787005 * a, n = Math.cbrt(s), b = Math.cbrt(c), t = Math.cbrt(o);
39
39
  return {
40
- L: 0.2104542553 * l + 0.793617785 * d - 0.0040720468 * n,
41
- a: 1.9779984951 * l - 2.428592205 * d + 0.4505937099 * n,
42
- b: 0.0259040371 * l + 0.7827717662 * d - 0.808675766 * n
40
+ L: 0.2104542553 * n + 0.793617785 * b - 0.0040720468 * t,
41
+ a: 1.9779984951 * n - 2.428592205 * b + 0.4505937099 * t,
42
+ b: 0.0259040371 * n + 0.7827717662 * b - 0.808675766 * t
43
43
  };
44
44
  }
45
- function ve(e, r, a) {
46
- const s = e + 0.3963377774 * r + 0.2158037573 * a, c = e - 0.1055613458 * r - 0.0638541728 * a, o = e - 0.0894841775 * r - 1.291485548 * a, l = s * s * s, d = c * c * c, n = o * o * o;
45
+ function he(e, r, a) {
46
+ const s = e + 0.3963377774 * r + 0.2158037573 * a, c = e - 0.1055613458 * r - 0.0638541728 * a, o = e - 0.0894841775 * r - 1.291485548 * a, n = s * s * s, b = c * c * c, t = o * o * o;
47
47
  return {
48
- r: 4.0767416621 * l - 3.3077115913 * d + 0.2309699292 * n,
49
- g: -1.2684380046 * l + 2.6097574011 * d - 0.3413193965 * n,
50
- b: -0.0041960863 * l - 0.7034186147 * d + 1.707614701 * n
48
+ r: 4.0767416621 * n - 3.3077115913 * b + 0.2309699292 * t,
49
+ g: -1.2684380046 * n + 2.6097574011 * b - 0.3413193965 * t,
50
+ b: -0.0041960863 * n - 0.7034186147 * b + 1.707614701 * t
51
51
  };
52
52
  }
53
- function ge({ r: e, g: r, b: a }) {
54
- const { L: s, a: c, b: o } = pe(
53
+ function we({ r: e, g: r, b: a }) {
54
+ const { L: s, a: c, b: o } = me(
55
55
  x(e),
56
56
  x(r),
57
57
  x(a)
58
- ), l = Math.sqrt(c * c + o * o);
59
- let d = Math.atan2(o, c) * 180 / Math.PI;
60
- return d < 0 && (d += 360), { l: s, c: l, h: d };
58
+ ), n = Math.sqrt(c * c + o * o);
59
+ let b = Math.atan2(o, c) * 180 / Math.PI;
60
+ return b < 0 && (b += 360), { l: s, c: n, h: b };
61
61
  }
62
- const J = (e) => ge(U(e)), W = ({ r: e, g: r, b: a }, s = 1e-4) => e >= -s && e <= 1 + s && r >= -s && r <= 1 + s && a >= -s && a <= 1 + s;
63
- function ye({ l: e, c: r, h: a }) {
64
- const s = a * Math.PI / 180, c = (l) => ve(e, l * Math.cos(s), l * Math.sin(s));
62
+ const S = (e) => we(I(e)), ee = ({ r: e, g: r, b: a }, s = 1e-4) => e >= -s && e <= 1 + s && r >= -s && r <= 1 + s && a >= -s && a <= 1 + s;
63
+ function xe({ l: e, c: r, h: a }) {
64
+ const s = a * Math.PI / 180, c = (n) => he(e, n * Math.cos(s), n * Math.sin(s));
65
65
  let o = c(r);
66
- if (!W(o)) {
67
- let l = 0, d = r;
68
- for (let n = 0; n < 20; n++) {
69
- const f = (l + d) / 2;
70
- o = c(f), W(o) ? l = f : d = f;
66
+ if (!ee(o)) {
67
+ let n = 0, b = r;
68
+ for (let t = 0; t < 20; t++) {
69
+ const i = (n + b) / 2;
70
+ o = c(i), ee(o) ? n = i : b = i;
71
71
  }
72
- o = c(l);
72
+ o = c(n);
73
73
  }
74
74
  return {
75
- r: Math.min(1, Math.max(0, B(o.r))),
76
- g: Math.min(1, Math.max(0, B(o.g))),
77
- b: Math.min(1, Math.max(0, B(o.b)))
75
+ r: Math.min(1, Math.max(0, J(o.r))),
76
+ g: Math.min(1, Math.max(0, J(o.g))),
77
+ b: Math.min(1, Math.max(0, J(o.b)))
78
78
  };
79
79
  }
80
- const te = (e) => ke(ye(e));
81
- function K({ r: e, g: r, b: a }) {
80
+ const j = (e) => ye(xe(e));
81
+ function W({ r: e, g: r, b: a }) {
82
82
  return 0.2126 * x(e) + 0.7152 * x(r) + 0.0722 * x(a);
83
83
  }
84
- function me(e, r) {
85
- const a = K(U(e)), s = K(U(r)), c = Math.max(a, s), o = Math.min(a, s);
84
+ function Se(e, r) {
85
+ const a = W(I(e)), s = W(I(r)), c = Math.max(a, s), o = Math.min(a, s);
86
86
  return (c + 0.05) / (o + 0.05);
87
87
  }
88
- function Q(e, r = ["#ffffff", "#1e1f21"]) {
88
+ function K(e, r = ["#ffffff", "#1e1f21"]) {
89
89
  let a = r[0], s = -1;
90
90
  for (const c of r) {
91
- const o = me(e, c);
91
+ const o = Se(e, c);
92
92
  o > s && (s = o, a = c);
93
93
  }
94
94
  return a;
95
95
  }
96
- const V = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"], X = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "1000", "1100"], Z = {
96
+ function Ee(e) {
97
+ return W(I(e)) < 0.4;
98
+ }
99
+ const Q = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"], V = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "1000", "1100"], O = {
97
100
  brand: {
98
101
  L: [0.9434, 0.8816, 0.7612, 0.6375, 0.5179, 0.4415, 0.2695, 0.2429, 0.2155, 0.1878],
99
102
  C: [0.0143, 0.031, 0.0645, 0.1017, 0.1394, 0.1429, 0.086, 0.0761, 0.066, 0.0549]
@@ -114,29 +117,40 @@ const V = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"],
114
117
  L: [0.9673, 0.9003, 0.8504, 0.8055, 0.7624, 0.6961, 0.5244, 0.3979, 0.2567, 0.2201],
115
118
  C: [0.0205, 0.0679, 0.0991, 0.1284, 0.1495, 0.1346, 0.0998, 0.0731, 0.0415, 0.0332]
116
119
  }
117
- }, he = [1, 0.9791, 0.9577, 0.9007, 0.7857, 0.6501, 0.6028, 0.5383, 0.4389, 0.36, 0.2856, 0.239], we = [0.2127, 0.2401, 0.3133, 0.3673, 0.4198, 0.5093, 0.603, 0.682, 0.7408, 0.8102, 0.8546, 0.9153], xe = 0.02;
118
- function q(e, r) {
119
- const { c: a, h: s } = J(e), c = Math.max(...r.C) || 1;
120
+ }, Me = [1, 0.9791, 0.9577, 0.9007, 0.7857, 0.6501, 0.6028, 0.5383, 0.4389, 0.36, 0.2856, 0.239], Ce = [0.2127, 0.2401, 0.3133, 0.3673, 0.4198, 0.5093, 0.603, 0.682, 0.7408, 0.8102, 0.8546, 0.9153], Ae = 0.02;
121
+ function B(e, r) {
122
+ const { c: a, h: s } = S(e), c = Math.max(...r.C) || 1;
120
123
  return r.L.map(
121
- (o, l) => te({ l: o, c: a * (r.C[l] / c), h: s })
124
+ (o, n) => j({ l: o, c: a * (r.C[n] / c), h: s })
122
125
  );
123
126
  }
124
- function ee(e, r) {
125
- const { c: a, h: s } = J(e), c = Math.min(a, xe), o = r.length;
126
- return r.map((l, d) => {
127
- const n = d / (o - 1), f = 1 - Math.abs(2 * n - 1);
128
- return te({ l, c: c * f, h: s });
127
+ function re(e, r) {
128
+ const { c: a, h: s } = S(e), c = Math.min(a, Ae), o = r.length;
129
+ return r.map((n, b) => {
130
+ const t = b / (o - 1), i = 1 - Math.abs(2 * t - 1);
131
+ return j({ l: n, c: c * i, h: s });
132
+ });
133
+ }
134
+ function ae(e, r, a, s, c = 0.018) {
135
+ const o = S(e).l, n = S(r).l;
136
+ return Array.from({ length: a }, (b, t) => {
137
+ if (t === 0)
138
+ return e;
139
+ if (t === a - 1)
140
+ return r;
141
+ const i = t / (a - 1), p = o + (n - o) * i, f = 1 - Math.abs(2 * i - 1);
142
+ return j({ l: p, c: c * f, h: s });
129
143
  });
130
144
  }
131
- function Ye(e, r) {
145
+ function Qe(e, r) {
132
146
  let a = e[0], s = 1 / 0;
133
147
  for (const c of e) {
134
- const o = Math.abs(J(c).l - r);
148
+ const o = Math.abs(S(c).l - r);
135
149
  o < s && (s = o, a = c);
136
150
  }
137
151
  return a;
138
152
  }
139
- const Se = [
153
+ const ie = [
140
154
  { token: "--sa-text-primary", recipe: "var(--sa-color-gray-1000, #292a2e)", scale: "gray" },
141
155
  { token: "--sa-text-primary-inverse", recipe: "var(--sa-color-gray-50, #ffffff)", scale: "gray" },
142
156
  { token: "--sa-text-on-brand", recipe: "var(--sa-color-gray-50, #ffffff)", scale: "gray" },
@@ -319,7 +333,7 @@ const Se = [
319
333
  { token: "--sa-text-on-accent", recipe: "var(--sa-color-gray-1100, #1e1f21)", scale: "gray" },
320
334
  { token: "--sa-icon-accent", recipe: "var(--sa-color-amber-700, #a8690b)", scale: "amber" },
321
335
  { token: "--sa-border-accent", recipe: "var(--sa-color-amber-500, #f5a524)", scale: "amber" }
322
- ], Ee = [
336
+ ], de = [
323
337
  { token: "--sa-text-primary", recipe: "var(--sa-color-dark-1100, #e2e3e4)", scale: "dark" },
324
338
  { token: "--sa-text-primary-inverse", recipe: "var(--sa-color-gray-1100, #1e1f21)", scale: "gray" },
325
339
  { token: "--sa-text-brand", recipe: "var(--sa-color-brand-300, #668cc9)", scale: "brand" },
@@ -497,7 +511,34 @@ const Se = [
497
511
  { token: "--sa-text-accent", recipe: "var(--sa-color-amber-400, #ffb63f)", scale: "amber" },
498
512
  { token: "--sa-icon-accent", recipe: "var(--sa-color-amber-400, #ffb63f)", scale: "amber" },
499
513
  { token: "--sa-border-accent", recipe: "var(--sa-color-amber-400, #ffb63f)", scale: "amber" }
500
- ], Me = ["--sa-background-brand", "--sa-background-brand-hover", "--sa-background-brand-pressed"], ze = {
514
+ ];
515
+ function Le(e, r) {
516
+ const a = e.match(/var\(--sa-color-([a-z]+)-(\d+),\s*([^)]+)\)/);
517
+ if (!a)
518
+ return e;
519
+ const [, s, c, o] = a, n = r[s];
520
+ if (!n)
521
+ return o.trim();
522
+ const t = (n.length === 12 ? V : Q).indexOf(c);
523
+ return t >= 0 ? n[t] : o.trim();
524
+ }
525
+ function _e(e) {
526
+ const r = e.base, a = Ee(r), s = S(r), c = j({
527
+ l: a ? 0.96 : 0.22,
528
+ c: Math.min(s.c * 0.5, 0.02),
529
+ h: s.h
530
+ }), o = a ? c : r, n = a ? r : c, b = ae(o, n, 12, s.h), t = ae(n, o, 12, s.h), i = B(e.brand, O.brand), p = { gray: b, dark: t, brand: i };
531
+ ["error", "success", "info", "warning"].forEach((k) => {
532
+ const h = e[k];
533
+ h && (p[k] = B(h, O[k]));
534
+ });
535
+ const f = a ? de : ie, u = {};
536
+ for (const k of f)
537
+ k.token !== "--sa-text-on-brand" && (u[k.token] = Le(k.recipe, p));
538
+ const v = a ? i[4] : i[6];
539
+ return u["--sa-background-brand"] = v, u["--sa-background-brand-hover"] = a ? i[3] : i[7], u["--sa-background-brand-pressed"] = a ? i[5] : i[8], u["--sa-text-on-brand"] = K(v), { tokens: u, isDark: a, brand: i, gray: b };
540
+ }
541
+ const Ve = {
501
542
  name: "starasia",
502
543
  brand: "#1a4fa0",
503
544
  neutral: "#7d818a",
@@ -507,65 +548,90 @@ const Se = [
507
548
  warning: "#ed9f30",
508
549
  radius: 8,
509
550
  font: { body: "Inter" }
510
- }, re = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"', Ce = 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace', m = (e) => Math.round(e * 10) / 10;
511
- function R(e, r, a, s) {
551
+ }, se = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"', $e = 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace', m = (e) => Math.round(e * 10) / 10;
552
+ function D(e, r, a, s) {
512
553
  s.forEach((c, o) => {
513
554
  e[`--sa-color-${r}-${c}`] = a[o];
514
555
  });
515
556
  }
516
- function Ae(e, r = {}) {
517
- var k, p, y;
557
+ function Re(e, r = {}) {
518
558
  const a = r.as ?? "root";
519
559
  if (a === "skin" && !r.name)
520
560
  throw new Error('buildTheme: options.name wajib saat as:"skin"');
521
- const s = a === "skin" ? `[data-skin="${r.name}"]` : r.selector ?? ":root", c = r.darkPrimary ?? !0, o = {}, l = {}, d = { brand: [] }, n = /* @__PURE__ */ new Set(["brand"]), f = q(e.brand, Z.brand);
522
- if (d.brand = f, R(o, "brand", f, V), o["--sa-text-on-brand"] = Q(f[6]), ["error", "success", "info", "warning"].forEach((b) => {
523
- const v = e[b];
524
- if (!v)
561
+ const s = a === "skin" ? `[data-skin="${r.name}"]` : r.selector ?? ":root";
562
+ if (e.base)
563
+ return De(e, s);
564
+ const c = r.darkPrimary ?? !0, o = {}, n = {}, b = { brand: [] }, t = /* @__PURE__ */ new Set(["brand"]), i = B(e.brand, O.brand);
565
+ if (b.brand = i, D(o, "brand", i, Q), o["--sa-text-on-brand"] = K(i[6]), ["error", "success", "info", "warning"].forEach((f) => {
566
+ const u = e[f];
567
+ if (!u)
525
568
  return;
526
- const u = q(v, Z[b]);
527
- d[b] = u, R(o, b, u, V), n.add(b);
569
+ const v = B(u, O[f]);
570
+ b[f] = v, D(o, f, v, Q), t.add(f);
528
571
  }), e.neutral) {
529
- const b = ee(e.neutral, he), v = ee(e.neutral, we);
530
- d.gray = b, d.dark = v, R(o, "gray", b, X), R(o, "dark", v, X), n.add("gray"), n.add("dark");
572
+ const f = re(e.neutral, Me), u = re(e.neutral, Ce);
573
+ b.gray = f, b.dark = u, D(o, "gray", f, V), D(o, "dark", u, V), t.add("gray"), t.add("dark");
531
574
  }
532
- if (typeof e.radius == "number") {
533
- const b = e.radius;
534
- o["--sa-radii-xs"] = `${m(b * 0.5)}px`, o["--sa-radii-sm"] = `${m(b * 0.75)}px`, o["--sa-radii-md"] = `${m(b)}px`, o["--sa-radii-lg"] = `${m(b * 1.5)}px`, o["--sa-radii-xl"] = `${m(b * 1.75)}px`, o["--sa-radii-2xl"] = `${m(b * 2)}px`, o["--sa-radii-rounded"] = `${m(b)}px`;
575
+ if (be(o, e), c) {
576
+ const f = i[4];
577
+ n["--sa-background-brand"] = f, n["--sa-background-brand-hover"] = i[3], n["--sa-background-brand-pressed"] = i[5], n["--sa-text-on-brand"] = K(f);
535
578
  }
536
- if ((k = e.font) != null && k.body && (o["--sa-font-family"] = `"${e.font.body}", ${re}`), (p = e.font) != null && p.heading && (o["--sa-font-family-heading"] = `"${e.font.heading}", ${re}`), (y = e.font) != null && y.mono && (o["--sa-font-family-mono"] = `"${e.font.mono}", ${Ce}`), c) {
537
- const b = f[4];
538
- l["--sa-background-brand"] = b, l["--sa-background-brand-hover"] = f[3], l["--sa-background-brand-pressed"] = f[5], l["--sa-text-on-brand"] = Q(b);
579
+ return { css: a === "skin" ? Ie(s, o, n, t) : Ne(s, o, n), rootTokens: o, darkTokens: n, ramps: b };
580
+ }
581
+ function be(e, r) {
582
+ var a, s, c;
583
+ if (typeof r.radius == "number") {
584
+ const o = r.radius;
585
+ e["--sa-radii-xs"] = `${m(o * 0.5)}px`, e["--sa-radii-sm"] = `${m(o * 0.75)}px`, e["--sa-radii-md"] = `${m(o)}px`, e["--sa-radii-lg"] = `${m(o * 1.5)}px`, e["--sa-radii-xl"] = `${m(o * 1.75)}px`, e["--sa-radii-2xl"] = `${m(o * 2)}px`, e["--sa-radii-rounded"] = `${m(o)}px`;
539
586
  }
540
- return { css: a === "skin" ? _e(s, o, l, n) : Le(s, o, l), rootTokens: o, darkTokens: l, ramps: d };
587
+ (a = r.font) != null && a.body && (e["--sa-font-family"] = `"${r.font.body}", ${se}`), (s = r.font) != null && s.heading && (e["--sa-font-family-heading"] = `"${r.font.heading}", ${se}`), (c = r.font) != null && c.mono && (e["--sa-font-family-mono"] = `"${r.font.mono}", ${$e}`);
588
+ }
589
+ function De(e, r) {
590
+ const { tokens: a, brand: s, gray: c } = _e({
591
+ base: e.base,
592
+ brand: e.brand,
593
+ error: e.error,
594
+ success: e.success,
595
+ info: e.info,
596
+ warning: e.warning
597
+ });
598
+ be(a, e);
599
+ const o = `${r},
600
+ ${r}[data-theme="dark"]`;
601
+ return {
602
+ css: A(o, a),
603
+ rootTokens: a,
604
+ darkTokens: {},
605
+ ramps: { brand: s, gray: c }
606
+ };
541
607
  }
542
- function D(e, r) {
608
+ function A(e, r) {
543
609
  const a = Object.entries(r).map(([s, c]) => ` ${s}: ${c};`);
544
610
  return a.length ? `${e} {
545
611
  ${a.join(`
546
612
  `)}
547
613
  }` : "";
548
614
  }
549
- function Le(e, r, a) {
615
+ function Ne(e, r, a) {
550
616
  const s = e === ":root" ? '[data-theme="dark"]' : `${e}[data-theme="dark"], ${e} [data-theme="dark"]`;
551
- return [D(e, r), D(s, a)].filter(Boolean).join(`
617
+ return [A(e, r), A(s, a)].filter(Boolean).join(`
552
618
 
553
619
  `);
554
620
  }
555
- function _e(e, r, a, s) {
621
+ function Ie(e, r, a, s) {
556
622
  const c = {};
557
- for (const n of Se)
558
- n.scale && s.has(n.scale) && n.token !== "--sa-text-on-brand" && (c[n.token] = n.recipe);
559
- const o = {};
560
- for (const n of Ee)
561
- n.scale && s.has(n.scale) && n.token !== "--sa-text-on-brand" && !Me.includes(n.token) && (o[n.token] = n.recipe);
562
- const l = { ...r, ...c }, d = { ...o, ...a };
563
- return [D(e, l), D(`${e}[data-theme="dark"]`, d)].filter(Boolean).join(`
623
+ for (const t of ie)
624
+ t.scale && s.has(t.scale) && t.token !== "--sa-text-on-brand" && (c[t.token] = t.recipe);
625
+ const o = { ...r, ...c }, n = {};
626
+ for (const t of de)
627
+ (t.scale && s.has(t.scale) || t.token in o) && (n[t.token] = t.recipe);
628
+ const b = { ...n, ...a };
629
+ return [A(e, o), A(`${e}[data-theme="dark"]`, b)].filter(Boolean).join(`
564
630
 
565
631
  `);
566
632
  }
567
- const C = "sa-theme";
568
- function $(e = C) {
633
+ const L = "sa-theme";
634
+ function N(e = L) {
569
635
  try {
570
636
  if (typeof localStorage > "u")
571
637
  return null;
@@ -575,7 +641,7 @@ function $(e = C) {
575
641
  return null;
576
642
  }
577
643
  }
578
- function Re(e, r = C) {
644
+ function Oe(e, r = L) {
579
645
  try {
580
646
  if (typeof localStorage > "u")
581
647
  return;
@@ -583,7 +649,7 @@ function Re(e, r = C) {
583
649
  } catch {
584
650
  }
585
651
  }
586
- function $e(e = C) {
652
+ function Be(e = L) {
587
653
  try {
588
654
  if (typeof localStorage > "u")
589
655
  return;
@@ -591,7 +657,7 @@ function $e(e = C) {
591
657
  } catch {
592
658
  }
593
659
  }
594
- function De(e) {
660
+ function je(e) {
595
661
  if (e === "system")
596
662
  try {
597
663
  return typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
@@ -600,22 +666,22 @@ function De(e) {
600
666
  }
601
667
  return e;
602
668
  }
603
- function F(e) {
669
+ function H(e) {
604
670
  if (typeof document > "u")
605
671
  return;
606
672
  const r = document.documentElement;
607
- De(e) === "dark" ? r.setAttribute("data-theme", "dark") : r.removeAttribute("data-theme");
673
+ je(e) === "dark" ? r.setAttribute("data-theme", "dark") : r.removeAttribute("data-theme");
608
674
  }
609
- function ae(e) {
675
+ function oe(e) {
610
676
  if (typeof document > "u")
611
677
  return;
612
678
  const r = document.documentElement;
613
679
  e ? r.setAttribute("data-skin", e) : r.removeAttribute("data-skin");
614
680
  }
615
- function Ge(e = C) {
681
+ function Xe(e = L) {
616
682
  return "(function(){try{var p=JSON.parse(localStorage.getItem(" + JSON.stringify(e) + ")||'{}');var d=document.documentElement;var m=p.mode==='system'?((window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches)?'dark':'light'):p.mode;if(m==='dark')d.setAttribute('data-theme','dark');if(p.skin)d.setAttribute('data-skin',p.skin);}catch(e){}})();";
617
683
  }
618
- const Ne = {
684
+ const Fe = {
619
685
  raw: {
620
686
  white: {
621
687
  900: "255, 255, 255"
@@ -714,7 +780,7 @@ const Ne = {
714
780
  tertiary: "230, 237, 246"
715
781
  }
716
782
  }
717
- }, Ie = {
783
+ }, Te = {
718
784
  radii: {
719
785
  none: "0",
720
786
  xs: "0.25rem",
@@ -772,7 +838,7 @@ const Ne = {
772
838
  inner: "inset 0 2px 4px 0 #0000000d",
773
839
  card: "0px 4px 35px 0px #7090b040"
774
840
  }
775
- }, Oe = {
841
+ }, Pe = {
776
842
  fontSizes: {
777
843
  xs: "0.625rem",
778
844
  sm: "0.75rem",
@@ -812,11 +878,11 @@ const Ne = {
812
878
  relaxed: 1.625,
813
879
  loose: 2
814
880
  }
815
- }, le = {
816
- colors: Ne,
817
- metrics: Ie,
818
- font: Oe
819
- }, Y = de({
881
+ }, fe = {
882
+ colors: Fe,
883
+ metrics: Te,
884
+ font: Pe
885
+ }, X = ke({
820
886
  theme: void 0,
821
887
  setTheme: () => {
822
888
  },
@@ -829,20 +895,20 @@ const Ne = {
829
895
  },
830
896
  resetTheme: () => {
831
897
  }
832
- }), je = "sa-theme-style", H = "sa-theme-seed-style";
833
- function Be(e) {
898
+ }), Ue = "sa-theme-style", Y = "sa-theme-seed-style";
899
+ function Je(e) {
834
900
  const r = e.split(",").map((a) => Number(a.trim()));
835
901
  return r.length !== 3 || r.some((a) => !Number.isFinite(a) || a < 0 || a > 255) ? null : "#" + r.map((a) => Math.round(a).toString(16).padStart(2, "0")).join("");
836
902
  }
837
- var oe, ce;
838
- const Fe = ((ce = (oe = le.colors) == null ? void 0 : oe.raw) == null ? void 0 : ce.blue) ?? {}, se = (e) => (e ?? "").replace(/\s+/g, "");
839
- function He(e) {
903
+ var ne, te;
904
+ const He = ((te = (ne = fe.colors) == null ? void 0 : ne.raw) == null ? void 0 : te.blue) ?? {}, ce = (e) => (e ?? "").replace(/\s+/g, "");
905
+ function Ye(e) {
840
906
  if (!e)
841
907
  return "";
842
908
  const r = /* @__PURE__ */ new Set(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), a = Object.entries(e).filter(([s]) => r.has(s)).filter(
843
- ([s, c]) => se(c) !== se(Fe[s])
909
+ ([s, c]) => ce(c) !== ce(He[s])
844
910
  ).map(([s, c]) => {
845
- const o = Be(c);
911
+ const o = Je(c);
846
912
  return o ? ` --sa-color-brand-${s}: ${o};` : "";
847
913
  }).filter(Boolean).join(`
848
914
  `);
@@ -850,185 +916,185 @@ function He(e) {
850
916
  ${a}
851
917
  }` : "";
852
918
  }
853
- function We({
919
+ function Ze({
854
920
  value: e,
855
921
  seed: r,
856
922
  persist: a = !0,
857
- storageKey: s = C,
923
+ storageKey: s = L,
858
924
  manageAttributes: c = !1,
859
925
  children: o
860
926
  }) {
861
- const [l, d] = M(e), n = r !== void 0, [f, h] = M(() => {
862
- if (n)
927
+ const [n, b] = C(e), t = r !== void 0, [i, p] = C(() => {
928
+ if (t)
863
929
  return r;
864
930
  if (a) {
865
- const i = $(s);
866
- if (i != null && i.seed)
867
- return i.seed;
931
+ const d = N(s);
932
+ if (d != null && d.seed)
933
+ return d.seed;
868
934
  }
869
935
  return null;
870
- }), k = n ? r : f, p = T(
871
- () => k ? JSON.stringify(k) : "",
872
- [k]
936
+ }), f = t ? r : i, u = G(
937
+ () => f ? JSON.stringify(f) : "",
938
+ [f]
873
939
  );
874
- _(() => {
940
+ R(() => {
875
941
  if (typeof document > "u")
876
942
  return;
877
- if (!p) {
878
- const t = document.getElementById(H);
879
- t && (t.textContent = "");
943
+ if (!u) {
944
+ const l = document.getElementById(Y);
945
+ l && (l.textContent = "");
880
946
  return;
881
947
  }
882
- const { css: i } = Ae(JSON.parse(p));
883
- fe(i, H);
884
- }, [p]), _(() => {
885
- var t;
948
+ const { css: d } = Re(JSON.parse(u));
949
+ ve(d, Y);
950
+ }, [u]), R(() => {
951
+ var l;
886
952
  if (!c || !a)
887
953
  return;
888
- const i = $(s);
889
- if (i && (i.mode && F(i.mode), i.skin !== void 0 && ae(i.skin), i.mode === "system" && typeof window < "u")) {
890
- const g = window.matchMedia("(prefers-color-scheme: dark)"), S = () => F("system");
891
- return (t = g.addEventListener) == null || t.call(g, "change", S), () => {
892
- var z;
893
- return (z = g.removeEventListener) == null ? void 0 : z.call(g, "change", S);
954
+ const d = N(s);
955
+ if (d && (d.mode && H(d.mode), d.skin !== void 0 && oe(d.skin), d.mode === "system" && typeof window < "u")) {
956
+ const g = window.matchMedia("(prefers-color-scheme: dark)"), E = () => H("system");
957
+ return (l = g.addEventListener) == null || l.call(g, "change", E), () => {
958
+ var Z;
959
+ return (Z = g.removeEventListener) == null ? void 0 : Z.call(g, "change", E);
894
960
  };
895
961
  }
896
962
  }, [c, a, s]);
897
- const y = T(
898
- () => l ? JSON.stringify(l) : "",
899
- [l]
900
- ), b = be(null);
901
- _(() => {
902
- var g, S;
903
- b.current || (b.current = ue(je));
904
- const i = b.current;
905
- if (!i)
963
+ const v = G(
964
+ () => n ? JSON.stringify(n) : "",
965
+ [n]
966
+ ), k = pe(null);
967
+ R(() => {
968
+ var g, E;
969
+ k.current || (k.current = ge(Ue));
970
+ const d = k.current;
971
+ if (!d)
906
972
  return;
907
- const t = y ? JSON.parse(y) : void 0;
908
- i.textContent = t ? He((S = (g = t == null ? void 0 : t.colors) == null ? void 0 : g.raw) == null ? void 0 : S.blue) : "";
909
- }, [y]), _(() => () => {
910
- b.current && (b.current.textContent = "");
973
+ const l = v ? JSON.parse(v) : void 0;
974
+ d.textContent = l ? Ye((E = (g = l == null ? void 0 : l.colors) == null ? void 0 : g.raw) == null ? void 0 : E.blue) : "";
975
+ }, [v]), R(() => () => {
976
+ k.current && (k.current.textContent = "");
911
977
  }, []);
912
- const v = (i) => {
913
- i && d(i);
914
- }, u = E(
915
- (i) => {
978
+ const h = (d) => {
979
+ d && b(d);
980
+ }, y = M(
981
+ (d) => {
916
982
  if (!a)
917
983
  return;
918
- const t = $(s) || {};
919
- Re({ ...t, ...i }, s);
984
+ const l = N(s) || {};
985
+ Oe({ ...l, ...d }, s);
920
986
  },
921
987
  [a, s]
922
- ), I = E(
923
- (i) => {
924
- n || (h(i), u({ seed: i }));
988
+ ), T = M(
989
+ (d) => {
990
+ t || (p(d), y({ seed: d }));
925
991
  },
926
- [n, u]
927
- ), O = E(
928
- (i) => {
929
- F(i), u({ mode: i });
992
+ [t, y]
993
+ ), P = M(
994
+ (d) => {
995
+ H(d), y({ mode: d });
930
996
  },
931
- [u]
932
- ), A = E(
933
- (i) => {
934
- ae(i), u({ skin: i });
997
+ [y]
998
+ ), _ = M(
999
+ (d) => {
1000
+ oe(d), y({ skin: d });
935
1001
  },
936
- [u]
937
- ), L = E(() => {
938
- if (n || h(null), $e(s), typeof document < "u") {
939
- const i = document.getElementById(H);
940
- i && (i.textContent = "");
1002
+ [y]
1003
+ ), $ = M(() => {
1004
+ if (t || p(null), Be(s), typeof document < "u") {
1005
+ const d = document.getElementById(Y);
1006
+ d && (d.textContent = "");
941
1007
  }
942
- }, [n, s]);
1008
+ }, [t, s]);
943
1009
  return /* @__PURE__ */ w(
944
- Y.Provider,
1010
+ X.Provider,
945
1011
  {
946
1012
  value: {
947
- theme: l,
948
- setTheme: v,
949
- seed: k,
950
- setSeed: I,
951
- setMode: O,
952
- setSkin: A,
953
- resetTheme: L
1013
+ theme: n,
1014
+ setTheme: h,
1015
+ seed: f,
1016
+ setSeed: T,
1017
+ setMode: P,
1018
+ setSkin: _,
1019
+ resetTheme: $
954
1020
  },
955
1021
  children: o
956
1022
  }
957
1023
  );
958
1024
  }
959
- const Pe = [
1025
+ const ze = [
960
1026
  { name: null, label: "Default" },
961
1027
  { name: "tech", label: "Tech" }
962
- ], Te = [
1028
+ ], Ge = [
963
1029
  { value: "light", label: "Light" },
964
1030
  { value: "dark", label: "Dark" },
965
1031
  { value: "system", label: "System" }
966
1032
  ];
967
- function Ke({
968
- skins: e = Pe,
1033
+ function qe({
1034
+ skins: e = ze,
969
1035
  showMode: r = !0,
970
1036
  allowCustom: a = !1,
971
1037
  storageKey: s,
972
1038
  className: c,
973
1039
  style: o
974
1040
  }) {
975
- var i;
976
- const { setMode: l, setSkin: d, setSeed: n } = ne(Y), f = typeof window < "u" ? $(s) : null, [h, k] = M(
977
- (f == null ? void 0 : f.mode) ?? (typeof document < "u" && document.documentElement.getAttribute("data-theme") === "dark" ? "dark" : "light")
978
- ), [p, y] = M(
979
- (f == null ? void 0 : f.skin) ?? (typeof document < "u" ? document.documentElement.getAttribute("data-skin") : null)
980
- ), [b, v] = M(((i = f == null ? void 0 : f.seed) == null ? void 0 : i.brand) ?? "#1a4fa0"), u = (t) => {
981
- k(t), l(t);
982
- }, I = (t) => {
983
- y(t), d(t);
984
- }, O = (t) => {
985
- v(t), n({ brand: t });
986
- }, A = {
1041
+ var d;
1042
+ const { setMode: n, setSkin: b, setSeed: t } = le(X), i = typeof window < "u" ? N(s) : null, [p, f] = C(
1043
+ (i == null ? void 0 : i.mode) ?? (typeof document < "u" && document.documentElement.getAttribute("data-theme") === "dark" ? "dark" : "light")
1044
+ ), [u, v] = C(
1045
+ (i == null ? void 0 : i.skin) ?? (typeof document < "u" ? document.documentElement.getAttribute("data-skin") : null)
1046
+ ), [k, h] = C(((d = i == null ? void 0 : i.seed) == null ? void 0 : d.brand) ?? "#1a4fa0"), y = (l) => {
1047
+ f(l), n(l);
1048
+ }, T = (l) => {
1049
+ v(l), b(l);
1050
+ }, P = (l) => {
1051
+ h(l), t({ brand: l });
1052
+ }, _ = {
987
1053
  display: "inline-flex",
988
1054
  gap: 4,
989
1055
  padding: 4,
990
1056
  borderRadius: "var(--sa-radii-md)",
991
1057
  background: "var(--sa-background-neutral)"
992
- }, L = (t) => ({
1058
+ }, $ = (l) => ({
993
1059
  border: "none",
994
1060
  cursor: "pointer",
995
1061
  fontSize: 12,
996
1062
  fontWeight: 500,
997
1063
  padding: "4px 10px",
998
1064
  borderRadius: "var(--sa-radii-sm)",
999
- background: t ? "var(--sa-background-primary)" : "transparent",
1000
- color: t ? "var(--sa-text-primary)" : "var(--sa-text-subtle)",
1001
- boxShadow: t ? "var(--sa-shadow-sm)" : "none"
1065
+ background: l ? "var(--sa-background-primary)" : "transparent",
1066
+ color: l ? "var(--sa-text-primary)" : "var(--sa-text-subtle)",
1067
+ boxShadow: l ? "var(--sa-shadow-sm)" : "none"
1002
1068
  });
1003
- return /* @__PURE__ */ G(
1069
+ return /* @__PURE__ */ q(
1004
1070
  "div",
1005
1071
  {
1006
1072
  className: c,
1007
1073
  style: { display: "flex", gap: 12, flexWrap: "wrap", alignItems: "center", ...o },
1008
1074
  children: [
1009
- r && /* @__PURE__ */ w("div", { role: "group", "aria-label": "Mode", style: A, children: Te.map((t) => /* @__PURE__ */ w(
1075
+ r && /* @__PURE__ */ w("div", { role: "group", "aria-label": "Mode", style: _, children: Ge.map((l) => /* @__PURE__ */ w(
1010
1076
  "button",
1011
1077
  {
1012
1078
  type: "button",
1013
- "aria-pressed": h === t.value,
1014
- style: L(h === t.value),
1015
- onClick: () => u(t.value),
1016
- children: t.label
1079
+ "aria-pressed": p === l.value,
1080
+ style: $(p === l.value),
1081
+ onClick: () => y(l.value),
1082
+ children: l.label
1017
1083
  },
1018
- t.value
1084
+ l.value
1019
1085
  )) }),
1020
- e.length > 0 && /* @__PURE__ */ w("div", { role: "group", "aria-label": "Skin", style: A, children: e.map((t) => /* @__PURE__ */ w(
1086
+ e.length > 0 && /* @__PURE__ */ w("div", { role: "group", "aria-label": "Skin", style: _, children: e.map((l) => /* @__PURE__ */ w(
1021
1087
  "button",
1022
1088
  {
1023
1089
  type: "button",
1024
- "aria-pressed": p === t.name,
1025
- style: L(p === t.name),
1026
- onClick: () => I(t.name),
1027
- children: t.label
1090
+ "aria-pressed": u === l.name,
1091
+ style: $(u === l.name),
1092
+ onClick: () => T(l.name),
1093
+ children: l.label
1028
1094
  },
1029
- t.name ?? "default"
1095
+ l.name ?? "default"
1030
1096
  )) }),
1031
- a && /* @__PURE__ */ G(
1097
+ a && /* @__PURE__ */ q(
1032
1098
  "label",
1033
1099
  {
1034
1100
  style: {
@@ -1044,8 +1110,8 @@ function Ke({
1044
1110
  "input",
1045
1111
  {
1046
1112
  type: "color",
1047
- value: b,
1048
- onChange: (t) => O(t.target.value),
1113
+ value: k,
1114
+ onChange: (l) => P(l.target.value),
1049
1115
  "aria-label": "Custom brand color",
1050
1116
  style: {
1051
1117
  width: 28,
@@ -1065,86 +1131,88 @@ function Ke({
1065
1131
  }
1066
1132
  );
1067
1133
  }
1068
- const P = le, ie = (e, r) => {
1134
+ const z = fe, ue = (e, r) => {
1069
1135
  const a = {};
1070
1136
  return Object.keys(e).forEach((s) => {
1071
1137
  if (e != null && e[s] && typeof (e == null ? void 0 : e[s]) == "object") {
1072
1138
  a[s] = {
1073
1139
  ...e == null ? void 0 : e[s],
1074
1140
  ...r == null ? void 0 : r[s],
1075
- ...ie(e == null ? void 0 : e[s], r == null ? void 0 : r[s])
1141
+ ...ue(e == null ? void 0 : e[s], r == null ? void 0 : r[s])
1076
1142
  };
1077
1143
  return;
1078
1144
  }
1079
1145
  a[s] = (r == null ? void 0 : r[s]) || (e == null ? void 0 : e[s]);
1080
1146
  }), a;
1081
1147
  };
1082
- function N() {
1083
- const e = ne(Y), r = T(
1148
+ function F() {
1149
+ const e = le(X), r = G(
1084
1150
  () => ({
1085
- ...P,
1151
+ ...z,
1086
1152
  ...e.theme,
1087
- ...ie(P, e.theme)
1153
+ ...ue(z, e.theme)
1088
1154
  }),
1089
- [e.theme, P]
1155
+ [e.theme, z]
1090
1156
  );
1091
1157
  return { ...e, theme: r };
1092
1158
  }
1093
- function Qe() {
1094
- const { theme: e } = N();
1159
+ function er() {
1160
+ const { theme: e } = F();
1095
1161
  return e.colors;
1096
1162
  }
1097
- function Ve() {
1163
+ function rr() {
1098
1164
  var r;
1099
- const { theme: e } = N();
1165
+ const { theme: e } = F();
1100
1166
  return (r = e.metrics) == null ? void 0 : r.spacing;
1101
1167
  }
1102
- function Xe() {
1168
+ function ar() {
1103
1169
  var r;
1104
- const { theme: e } = N();
1170
+ const { theme: e } = F();
1105
1171
  return (r = e.metrics) == null ? void 0 : r.radii;
1106
1172
  }
1107
- function Ze() {
1173
+ function sr() {
1108
1174
  var r;
1109
- const { theme: e } = N();
1175
+ const { theme: e } = F();
1110
1176
  return (r = e == null ? void 0 : e.metrics) == null ? void 0 : r.shadows;
1111
1177
  }
1112
- function qe(e) {
1178
+ function or(e) {
1113
1179
  return e;
1114
1180
  }
1115
1181
  export {
1116
- C as DEFAULT_STORAGE_KEY,
1117
- Z as LADDERS,
1118
- we as NEUTRAL_LADDER_DARK,
1119
- he as NEUTRAL_LADDER_GRAY,
1120
- ze as SA_DEFAULT_SEED,
1121
- V as SCALE_KEYS_10,
1122
- X as SCALE_KEYS_12,
1123
- Y as ThemeContext,
1124
- We as ThemeProvider,
1125
- Ke as ThemeSwitcher,
1126
- F as applyMode,
1127
- ae as applySkin,
1128
- Ae as buildTheme,
1129
- $e as clearPref,
1130
- me as contrastRatio,
1131
- qe as createTheme,
1132
- J as hexToOklch,
1133
- U as hexToRgb,
1134
- ee as neutralRamp,
1135
- te as oklchToHex,
1136
- Ye as pickByLightness,
1137
- Q as pickTextOn,
1138
- q as rampFromSeed,
1139
- $ as readPref,
1140
- De as resolveMode,
1141
- ke as rgbToHex,
1142
- ge as rgbToOklch,
1143
- Ge as themeBootScript,
1144
- Qe as useColor,
1145
- Xe as useRadius,
1146
- Ze as useShadow,
1147
- Ve as useSpacing,
1148
- N as useTheme,
1149
- Re as writePref
1182
+ L as DEFAULT_STORAGE_KEY,
1183
+ O as LADDERS,
1184
+ Ce as NEUTRAL_LADDER_DARK,
1185
+ Me as NEUTRAL_LADDER_GRAY,
1186
+ Ve as SA_DEFAULT_SEED,
1187
+ Q as SCALE_KEYS_10,
1188
+ V as SCALE_KEYS_12,
1189
+ X as ThemeContext,
1190
+ Ze as ThemeProvider,
1191
+ qe as ThemeSwitcher,
1192
+ H as applyMode,
1193
+ oe as applySkin,
1194
+ Re as buildTheme,
1195
+ Be as clearPref,
1196
+ Se as contrastRatio,
1197
+ or as createTheme,
1198
+ S as hexToOklch,
1199
+ I as hexToRgb,
1200
+ Ee as isDarkColor,
1201
+ re as neutralRamp,
1202
+ j as oklchToHex,
1203
+ Qe as pickByLightness,
1204
+ K as pickTextOn,
1205
+ ae as rampBetween,
1206
+ B as rampFromSeed,
1207
+ N as readPref,
1208
+ je as resolveMode,
1209
+ ye as rgbToHex,
1210
+ we as rgbToOklch,
1211
+ Xe as themeBootScript,
1212
+ er as useColor,
1213
+ ar as useRadius,
1214
+ sr as useShadow,
1215
+ rr as useSpacing,
1216
+ F as useTheme,
1217
+ Oe as writePref
1150
1218
  };