@cyclone-ui/theme-builder 0.0.41 → 0.0.43

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  # Changelog for Cyclone UI - Theme Builder
4
4
 
5
+ ## [0.0.43](https://github.com/storm-software/cyclone-ui/releases/tag/theme-builder%400.0.43) (11/06/2026)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **theme-builder:** Resolve issue generating color token variants ([bd2fc29c9](https://github.com/storm-software/cyclone-ui/commit/bd2fc29c9))
10
+
11
+ ## [0.0.42](https://github.com/storm-software/cyclone-ui/releases/tag/theme-builder%400.0.42) (11/06/2026)
12
+
13
+ ### Features
14
+
15
+ - **stepper:** Added the `details` property to `Stepper` component ([5d3ffa8f5](https://github.com/storm-software/cyclone-ui/commit/5d3ffa8f5))
16
+ - **monorepo:** Reduced the amount of tokens by removing extra theme border colors ([f01400d25](https://github.com/storm-software/cyclone-ui/commit/f01400d25))
17
+ - **kbd:** Added the `Kbd` keybord display components ([c8c84cb3e](https://github.com/storm-software/cyclone-ui/commit/c8c84cb3e))
18
+
5
19
  ## [0.0.39](https://github.com/storm-software/cyclone-ui/releases/tag/theme-builder%400.0.39) (11/05/2026)
6
20
 
7
21
  ### Features
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@razorwind/core/plugin");const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`group`,`semantic`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function b(e){if(Array.isArray(e))return e.map(e=>b(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function ne(e,t){if(t===`shadow`)return b(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function x(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function re(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=x(e,t);return`$value`in e?{...e,$value:ne(e.$value,n)}:{...e}}function S(e,t){if(Array.isArray(e))return e.map(e=>S(e,t));if(!i(e))return e;if(a(e))return re(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:S(i,n);return o}const ie={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function oe(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function se(e){if(i(e)&&i(e.color))return oe(e.color.$description)}const ce={name:`active`,brightness:1.45,useContrastPrimitive:!0},le={name:`active`,brightness:1.25},ue={name:`active`,brightness:1.125},de={name:`active`,brightness:1.4},fe={name:`active`,brightness:1.8,useContrastPrimitive:!0},C={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[ce,w,T],saturated:[le,C,T]},pe={lowSaturation:[ue,w,T],saturated:E.saturated},me={name:`inactive`,brightness:.9},D={...T,opacity:.675,saturation:.925},O={lowSaturation:[{name:`active`,brightness:1.3},me,D],saturated:[{name:`active`,brightness:1.25},me,D]},he=[`shadows`];function k(e){return Object.entries(e).filter(e=>!he.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const A={lowSaturation:[fe,w,T],saturated:[de,C,T]},ge={primary:E,secondary:pe,link:E,outline:A},_e={foreground:{lowSaturation:[{name:`hovered`,brightness:1.25},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.25},...O.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...O.saturated]}},ve={outline:A},j=7.5,M=.01;function ye(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function be(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function N(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=be(t,i[1]);if(a&&`$value`in a)return N(a.$value,t,n)}function P(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function xe(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&x(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=N(e.color,t);return n?{...e,color:P(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function Se(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of k(t)){let t=`{color.${e}.primary}`,i=e=>L(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[L(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),L(t,7)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),L(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function U(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function W(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function G(e,t){let n=W(e),r=W(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function K(e){let t=G(e,`#FAFAFA`);return t>=2?`#FAFAFA`:G(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*M),d=H(l,r,i,a),G(d,f)>=j)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*M),f=H(u,r,i,a),G(d,f)>=j)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function Ee(e,t){return t===`dark`?q(e):t===`light`?!J(e):B(e).lightness>=.5}function De(e,t){return!Ee(e,t)}const Oe=B(`#fefefe`).lightness,ke=B(`#262626`).lightness;function q(e){return B(e).lightness>=(R(e)?Oe:.75)}function J(e){return B(e).lightness<=(R(e)?ke:.25)}function Y(e){return e.name===`hovered`||e.name===`active`}function X(e,t){return t===`dark`?q(e):t===`light`&&J(e)}function Ae(e,t,n){return De(e,n)?t:2-t}function Z(e,t){return e.useContrastPrimitive&&t?ie[t]:void 0}function je(e,t,n){if(t.name===`hovered`&&Z(t,n)&&X(e,n))return n===`dark`?-.25:.25}function Me(e,t,n){let r=Z(t,n);return r&&n&&t.name===`active`&&X(e,n)?ae[n]:r}function Ne(e,t,n){return t.brightness===void 0?1:Z(t,n)?Y(t)?1:t.brightness:Ae(e,t.brightness,n)}function Pe(e,t,n){let r=je(e,t,n),i=r===void 0?Me(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&Y(t))&&(a=U(a,Ne(a,t,n))):a=Ce(e,r),t.saturation!==void 0&&!z(e)&&(a=we(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:P(a,t.opacity):xe(a,t.fadeOver,t.opacity??1)}function Fe(e,t,n){let r=[],i=je(t,e,n),a=Me(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&Y(e))r.push(n&&a!==ie[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=Ne(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Ie(e,t,n,r){let i=Fe(n,t,r),a=Pe(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Q(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ye(r))continue;let s=e[r];if(!a(s))continue;let c=x(s);if(c&&c!==`color`)continue;let l=N(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=oe(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Ie(s,l,e,p))}}return o}function Le(e,t,n,r){let i=t.primary,o=a(i)&&N(i.$value,n),c=a(i)&&x(i);if(!a(i)||!o||c&&c!==`color`)return t;let l={...t};l.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},t.group===`status`&&(l.outline??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} border and divider color (matches primary)`}),l[`on-primary`]??={...i,$type:`color`,$value:K(o),$description:`Generated text and icon color on ${e} primary backgrounds`},l.backdrop??={...i,$type:`color`,$value:P(U(o,.375),.45),$description:`Generated ${e} overlay backdrop color (primary, 30% darker at 75% opacity)`};let u;if(r&&!(`secondary`in t)){let t=Te(o,r);l.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},u=t.onMuted??o}else if(a(t.secondary)){let e=N(t.secondary.$value,n);u=e&&K(e)}u&&!(`on-secondary`in t)&&(l[`on-secondary`]={...i,$type:`color`,$value:u,$description:`Generated text and icon color on ${e} secondary backgrounds`});let d=!(`border`in t)&&a(l.secondary)&&N(l.secondary.$value,n);if(d){let{lightness:t,chroma:n,hue:a,alpha:o}=B(d),c=r===`light`?-1:1;l.border={...i,$type:`color`,$value:H(s(t*(1+c*.15)),n,a,o),$description:`Generated ${e} border color for secondary backgrounds (secondary, 15% ${c>0?`brighter`:`darker`})`}}for(let[e,t]of Object.entries(ge))l=Q(l,n,t,e,r);for(let[t,n]of Object.entries(l))a(n)&&(l[t]={theme:e,group:e,...n});return l}function Re(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function ze(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function $(e,t,n,o){if(Array.isArray(e))return e.map(e=>$(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:$(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=ze(c);for(let[e,n]of k(c))c[e]=Le(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?_e[n.group]:void 0;r&&(c=Q(c,t,r,e,o))}}for(let[e,n]of Object.entries(ve))a(c[e])&&(c=Q(c,t,n,e,o));return n===`color`?Re(c):c}function Be(e){let t=S(e),n=Se($(t,t,void 0,se(t)));return F(n,n)}var Ve=(0,e.definePlugin)(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:Be}]}));exports.default=Ve,exports.tamaguiPreprocessor=Be;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@razorwind/core/plugin");const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`group`,`semantic`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function b(e){if(Array.isArray(e))return e.map(e=>b(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function ne(e,t){if(t===`shadow`)return b(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function x(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function re(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=x(e,t);return`$value`in e?{...e,$value:ne(e.$value,n)}:{...e}}function S(e,t){if(Array.isArray(e))return e.map(e=>S(e,t));if(!i(e))return e;if(a(e))return re(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:S(i,n);return o}const C={dark:`#ffffff`,light:`#0c0c0d`},ie={dark:`#ffffff`,light:`#000000`};function w(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function ae(e){if(i(e)&&i(e.color))return w(e.color.$description)}const oe={name:`active`,brightness:1.45,useContrastPrimitive:!0},se={name:`active`,brightness:1.25},ce={name:`active`,brightness:1.175},le={name:`active`,brightness:1.8,useContrastPrimitive:!0},T={name:`inactive`,brightness:.8},E={name:`inactive`,brightness:.5,useContrastPrimitive:!0},D={name:`disabled`,opacity:.15,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},O={lowSaturation:[oe,E,D],saturated:[se,T,D]},ue={lowSaturation:[ce,T,D],saturated:O.saturated},k={name:`inactive`,brightness:.9},de={...D,opacity:.25,saturation:.925},fe={lowSaturation:[{name:`active`,brightness:1.3},k,de],saturated:[{name:`active`,brightness:1.25},k,de]},pe=[`shadows`];function A(e){return Object.entries(e).filter(e=>!pe.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const me={lowSaturation:[{name:`hovered`,brightness:1.4},le,E,D],saturated:[{name:`hovered`,brightness:1.2},{name:`active`,brightness:1.4},T,D]},j={lowSaturation:[{name:`hovered`,brightness:1.25},...O.lowSaturation],saturated:[{name:`hovered`,brightness:1.125},...O.saturated]},he={primary:j,secondary:{lowSaturation:[{name:`hovered`,brightness:1.08},...ue.lowSaturation],saturated:j.saturated},link:j},ge={foreground:{lowSaturation:[{name:`hovered`,brightness:1.25},...O.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...O.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.15},...fe.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...fe.saturated]}},_e={hairline:me},M=7.5,N=.01;function ve(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ye(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function P(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ye(t,i[1]);if(a&&`$value`in a)return P(a.$value,t,n)}function F(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function be(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function I(e,t,n=!1){if(Array.isArray(e))return e.map(e=>I(e,t,n));if(!i(e))return e;if(n&&a(e)&&x(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=P(e.color,t);return n?{...e,color:F(n,z(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=I(a,t,n||i.toLowerCase()===`ring`);return r}const L={value:0,unit:`px`};function R(e,t){return{color:e,offsetX:L,offsetY:L,blur:L,spread:{value:t,unit:`px`}}}function xe(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of A(t)){let t=`{color.${e}.primary}`,i=e=>R(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[R(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[R(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),R(t,7)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),R(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function z(e){return V(e).chroma<.02}function B(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function V(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function H({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function U(e,t,n,r){if(H(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;H(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function Se(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=V(e);return g(s(n*t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=V(e);return g(s(n+t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=V(e);return g(n,r*s(t),i,a)}function W(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function G(e,t){let n=W(e),r=W(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function K(e){let t=G(e,`#FAFAFA`);return t>=2?`#FAFAFA`:G(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=V(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*N),d=U(l,r,i,a),G(d,f)>=M)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*N),f=U(u,r,i,a),G(d,f)>=M)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}const Ee=V(`#fefefe`).lightness,De=V(`#262626`).lightness;function Oe(e){return V(e).lightness>=(z(e)?Ee:.75)}function ke(e){return V(e).lightness<=(z(e)?De:.25)}function q(e){return e.name===`hovered`||e.name===`active`}function J(e,t){return t===`dark`?Oe(e):t===`light`&&ke(e)}function Y(e,t){return t??(V(e).lightness>=.5?`light`:`dark`)}function X(e,t){let{lightness:n}=V(e);return t===`light`?1-n:n}function Z(e,t,n){let{chroma:r,hue:i,alpha:a}=V(e);return U(s(n===`light`?1-t:t),r,i,a)}function Ae(e,t,n){return t.name===`hovered`&&J(e,n)}function je(e,t,n){return(t.brightness??1)>=1!==Ae(e,t,n)}function Me(e,t,n){let r=X(e,n),i=(Ae(e,t,n)?r:V(e).lightness)*Math.abs((t.brightness??1)-1);return Z(e,je(e,t,n)?r+Math.min(i,(1-r)/2):r-i,n)}function Ne(e,t){return e.useContrastPrimitive&&t?C[t]:void 0}function Pe(e,t,n){if(t.name===`hovered`&&Ne(t,n)&&J(e,n))return n===`dark`?-.25:.25}function Fe(e,t,n){let r=Ne(t,n);return r&&n&&t.name===`active`&&J(e,n)?ie[n]:r}function Ie(e,t,n){let r=Pe(e,t,n),i=r===void 0?Fe(e,t,n):void 0,a=Y(e,n),o=i??e;return r===void 0?t.brightness!==void 0&&!(i&&q(t))&&(o=i?Z(i,X(i,a)*t.brightness,a):Me(e,t,a)):o=Ce(e,r),t.saturation!==void 0&&!B(e)&&(o=we(o,t.saturation),t.fadeOver===void 0)?o:t.fadeOver===void 0?t.opacity===void 0?o:F(o,t.opacity):be(o,t.fadeOver,t.opacity??1)}function Le(e,t,n){let r=[],i=Pe(t,e,n),a=Fe(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&q(e))r.push(n&&a!==C[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=Y(t,n);r.push(a?`${Math.round(e.brightness*100)}% of the ${i} contrast primitive's brightness`:`${Math.round(Math.abs(e.brightness-1)*100)}% ${je(t,e,i)?`brighter`:`less bright`}`)}return e.saturation!==void 0&&!B(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||B(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Re(e,t,n,r){let i=Le(n,t,r),a=Ie(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Q(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ve(r))continue;let s=e[r];if(!a(s))continue;let c=x(s);if(c&&c!==`color`)continue;let l=P(s.$value,t);if(!l)continue;let u=z(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=w(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Re(s,l,e,p))}let m=`${r}-active`,h=o[m];if(!(m in e)&&a(h)&&typeof h.$value==`string`){let e=Y(l,p),n=Math.max(...[l,o[`${r}-hovered`]?.$value,o[`${r}-inactive`]?.$value].map(e=>P(e,t)).filter(e=>e!==void 0).map(t=>X(t,e)));X(h.$value,e)<n&&(o[m]={...h,$value:Z(h.$value,n,e)})}}return o}function ze(e,t,n,r){let i=t.primary,o=a(i)&&P(i.$value,n),c=a(i)&&x(i);if(!a(i)||!o||c&&c!==`color`)return t;let l={...t};l.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},l[`on-primary`]??={...i,$type:`color`,$value:K(o),$description:`Generated text and icon color on ${e} primary backgrounds`},l.backdrop??={...i,$type:`color`,$value:F(Se(o,.375),.15),$description:`Generated ${e} overlay backdrop color (primary, 30% darker at 75% opacity)`};let u;if(r&&!(`secondary`in t)){let t=Te(o,r);l.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},u=t.onMuted??o}else if(a(t.secondary)){let e=P(t.secondary.$value,n);u=e&&K(e)}u&&!(`on-secondary`in t)&&(l[`on-secondary`]={...i,$type:`color`,$value:u,$description:`Generated text and icon color on ${e} secondary backgrounds`});let d=!(`border`in t)&&a(l.secondary)&&P(l.secondary.$value,n);if(d){let{lightness:t,chroma:n,hue:a,alpha:o}=V(d),c=r===`light`?-1:1;l.border={...i,$type:`color`,$value:U(s(t*(1+c*.25)),n,a,o),$description:`Generated ${e} border color for secondary backgrounds (secondary, 25% ${c>0?`brighter`:`darker`})`}}for(let[e,t]of Object.entries(he))l=Q(l,n,t,e,r);for(let[t,n]of Object.entries(l))a(n)&&(l[t]={theme:e,group:e,...n});return l}function Be(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function Ve(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function $(e,t,n,o){if(Array.isArray(e))return e.map(e=>$(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:$(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=Ve(c);for(let[e,n]of A(c))c[e]=ze(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?ge[n.group]:void 0;r&&(c=Q(c,t,r,e,o))}}for(let[e,n]of Object.entries(_e))a(c[e])&&(c=Q(c,t,n,e,o));return n===`color`?Be(c):c}function He(e){let t=S(e),n=xe($(t,t,void 0,ae(t)));return I(n,n)}var Ue=(0,e.definePlugin)(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:He}]}));exports.default=Ue,exports.tamaguiPreprocessor=He;
@@ -2,24 +2,25 @@ import { PreprocessedTokens } from "style-dictionary/types";
2
2
  /**
3
3
  * Style Dictionary preprocessor: rewrite color `$value`s (and nested shadow
4
4
  * colors) to hex so generators emit `#rrggbb` / `#rrggbbaa` instead of
5
- * `oklch()`. Root colors (emphasis, ink, subtle, outline, backgrounds)
5
+ * `oklch()`. Root colors (emphasis, ink, subtle, hairline, backgrounds)
6
6
  * stay in the root light and dark themes without rings. For each color group
7
7
  * with a `primary` token (except excluded groups), a missing `secondary` background and `on-primary` /
8
8
  * `on-secondary` text colors are generated, a missing `border` is derived from
9
9
  * `secondary` (15% brighter, or darker in light themes), then hovered, active, inactive,
10
- * and disabled variants are added to the outline, `foreground` and
10
+ * and disabled variants are added to the `hairline`, `foreground` and
11
11
  * `background` group colors, and each theme color group's `primary`, `secondary`
12
- * `link` and `outline` (`link`, and `outline` in `status` groups, default to
13
- * `primary` when missing).
12
+ * and `link` (`link` defaults to `primary` when missing).
14
13
  * Low-saturation colors derive their states from the parent theme's contrast
15
14
  * primitive (backgrounds use a half-strength shift of their own lightness; hovered
16
15
  * colors already near that primitive shift toward the middle, while active
17
16
  * ones become pure white or black); saturated
18
- * colors scale their own lightness. Foreground and background hovered states
19
- * take a smaller step than their active states. Tokens in a theme color group get the
17
+ * colors scale their own lightness. "Brighter" means lighter in dark themes and
18
+ * darker in light themes: active states are never less bright than the normal,
19
+ * hovered, or inactive states, and hovered states take a smaller step than
20
+ * active (reversing only for colors near the contrast primitive). Tokens in a theme color group get the
20
21
  * group name as `theme` and `group`, unless already set; root state and `on-*`
21
- * tokens get their main token name as `group` (e.g. `outline-active` →
22
- * `outline`).
22
+ * tokens get their main token name as `group` (e.g. `hairline-active` →
23
+ * `hairline`).
23
24
  * Finally, focus rings are generated for each theme color group.
24
25
  */
25
26
  declare function tamaguiPreprocessor(dictionary: PreprocessedTokens): PreprocessedTokens;
@@ -1 +1 @@
1
- {"version":3,"file":"preprocessor.d.cts","names":[],"sources":["../src/preprocessor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;iBA0kDgB,oBACd,YAAY,qBACX"}
1
+ {"version":3,"file":"preprocessor.d.cts","names":[],"sources":["../src/preprocessor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;iBAwqDgB,oBACd,YAAY,qBACX"}
@@ -2,24 +2,25 @@ import { PreprocessedTokens } from "style-dictionary/types";
2
2
  /**
3
3
  * Style Dictionary preprocessor: rewrite color `$value`s (and nested shadow
4
4
  * colors) to hex so generators emit `#rrggbb` / `#rrggbbaa` instead of
5
- * `oklch()`. Root colors (emphasis, ink, subtle, outline, backgrounds)
5
+ * `oklch()`. Root colors (emphasis, ink, subtle, hairline, backgrounds)
6
6
  * stay in the root light and dark themes without rings. For each color group
7
7
  * with a `primary` token (except excluded groups), a missing `secondary` background and `on-primary` /
8
8
  * `on-secondary` text colors are generated, a missing `border` is derived from
9
9
  * `secondary` (15% brighter, or darker in light themes), then hovered, active, inactive,
10
- * and disabled variants are added to the outline, `foreground` and
10
+ * and disabled variants are added to the `hairline`, `foreground` and
11
11
  * `background` group colors, and each theme color group's `primary`, `secondary`
12
- * `link` and `outline` (`link`, and `outline` in `status` groups, default to
13
- * `primary` when missing).
12
+ * and `link` (`link` defaults to `primary` when missing).
14
13
  * Low-saturation colors derive their states from the parent theme's contrast
15
14
  * primitive (backgrounds use a half-strength shift of their own lightness; hovered
16
15
  * colors already near that primitive shift toward the middle, while active
17
16
  * ones become pure white or black); saturated
18
- * colors scale their own lightness. Foreground and background hovered states
19
- * take a smaller step than their active states. Tokens in a theme color group get the
17
+ * colors scale their own lightness. "Brighter" means lighter in dark themes and
18
+ * darker in light themes: active states are never less bright than the normal,
19
+ * hovered, or inactive states, and hovered states take a smaller step than
20
+ * active (reversing only for colors near the contrast primitive). Tokens in a theme color group get the
20
21
  * group name as `theme` and `group`, unless already set; root state and `on-*`
21
- * tokens get their main token name as `group` (e.g. `outline-active` →
22
- * `outline`).
22
+ * tokens get their main token name as `group` (e.g. `hairline-active` →
23
+ * `hairline`).
23
24
  * Finally, focus rings are generated for each theme color group.
24
25
  */
25
26
  declare function tamaguiPreprocessor(dictionary: PreprocessedTokens): PreprocessedTokens;
@@ -1,2 +1,2 @@
1
- import{definePlugin as e}from"@razorwind/core/plugin";const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`group`,`semantic`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function b(e){if(Array.isArray(e))return e.map(e=>b(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function ne(e,t){if(t===`shadow`)return b(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function x(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function re(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=x(e,t);return`$value`in e?{...e,$value:ne(e.$value,n)}:{...e}}function S(e,t){if(Array.isArray(e))return e.map(e=>S(e,t));if(!i(e))return e;if(a(e))return re(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:S(i,n);return o}const ie={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function oe(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function se(e){if(i(e)&&i(e.color))return oe(e.color.$description)}const ce={name:`active`,brightness:1.45,useContrastPrimitive:!0},le={name:`active`,brightness:1.25},ue={name:`active`,brightness:1.125},de={name:`active`,brightness:1.4},fe={name:`active`,brightness:1.8,useContrastPrimitive:!0},C={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[ce,w,T],saturated:[le,C,T]},pe={lowSaturation:[ue,w,T],saturated:E.saturated},me={name:`inactive`,brightness:.9},D={...T,opacity:.675,saturation:.925},O={lowSaturation:[{name:`active`,brightness:1.3},me,D],saturated:[{name:`active`,brightness:1.25},me,D]},he=[`shadows`];function k(e){return Object.entries(e).filter(e=>!he.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const A={lowSaturation:[fe,w,T],saturated:[de,C,T]},ge={primary:E,secondary:pe,link:E,outline:A},_e={foreground:{lowSaturation:[{name:`hovered`,brightness:1.25},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.25},...O.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...O.saturated]}},ve={outline:A},j=7.5,M=.01;function ye(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function be(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function N(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=be(t,i[1]);if(a&&`$value`in a)return N(a.$value,t,n)}function P(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function xe(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&x(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=N(e.color,t);return n?{...e,color:P(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function Se(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of k(t)){let t=`{color.${e}.primary}`,i=e=>L(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[L(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),L(t,7)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),L(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function U(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function W(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function G(e,t){let n=W(e),r=W(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function K(e){let t=G(e,`#FAFAFA`);return t>=2?`#FAFAFA`:G(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*M),d=H(l,r,i,a),G(d,f)>=j)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*M),f=H(u,r,i,a),G(d,f)>=j)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function Ee(e,t){return t===`dark`?q(e):t===`light`?!J(e):B(e).lightness>=.5}function De(e,t){return!Ee(e,t)}const Oe=B(`#fefefe`).lightness,ke=B(`#262626`).lightness;function q(e){return B(e).lightness>=(R(e)?Oe:.75)}function J(e){return B(e).lightness<=(R(e)?ke:.25)}function Y(e){return e.name===`hovered`||e.name===`active`}function X(e,t){return t===`dark`?q(e):t===`light`&&J(e)}function Ae(e,t,n){return De(e,n)?t:2-t}function Z(e,t){return e.useContrastPrimitive&&t?ie[t]:void 0}function je(e,t,n){if(t.name===`hovered`&&Z(t,n)&&X(e,n))return n===`dark`?-.25:.25}function Me(e,t,n){let r=Z(t,n);return r&&n&&t.name===`active`&&X(e,n)?ae[n]:r}function Ne(e,t,n){return t.brightness===void 0?1:Z(t,n)?Y(t)?1:t.brightness:Ae(e,t.brightness,n)}function Pe(e,t,n){let r=je(e,t,n),i=r===void 0?Me(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&Y(t))&&(a=U(a,Ne(a,t,n))):a=Ce(e,r),t.saturation!==void 0&&!z(e)&&(a=we(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:P(a,t.opacity):xe(a,t.fadeOver,t.opacity??1)}function Fe(e,t,n){let r=[],i=je(t,e,n),a=Me(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&Y(e))r.push(n&&a!==ie[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=Ne(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Ie(e,t,n,r){let i=Fe(n,t,r),a=Pe(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Q(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ye(r))continue;let s=e[r];if(!a(s))continue;let c=x(s);if(c&&c!==`color`)continue;let l=N(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=oe(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Ie(s,l,e,p))}}return o}function Le(e,t,n,r){let i=t.primary,o=a(i)&&N(i.$value,n),c=a(i)&&x(i);if(!a(i)||!o||c&&c!==`color`)return t;let l={...t};l.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},t.group===`status`&&(l.outline??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} border and divider color (matches primary)`}),l[`on-primary`]??={...i,$type:`color`,$value:K(o),$description:`Generated text and icon color on ${e} primary backgrounds`},l.backdrop??={...i,$type:`color`,$value:P(U(o,.375),.45),$description:`Generated ${e} overlay backdrop color (primary, 30% darker at 75% opacity)`};let u;if(r&&!(`secondary`in t)){let t=Te(o,r);l.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},u=t.onMuted??o}else if(a(t.secondary)){let e=N(t.secondary.$value,n);u=e&&K(e)}u&&!(`on-secondary`in t)&&(l[`on-secondary`]={...i,$type:`color`,$value:u,$description:`Generated text and icon color on ${e} secondary backgrounds`});let d=!(`border`in t)&&a(l.secondary)&&N(l.secondary.$value,n);if(d){let{lightness:t,chroma:n,hue:a,alpha:o}=B(d),c=r===`light`?-1:1;l.border={...i,$type:`color`,$value:H(s(t*(1+c*.15)),n,a,o),$description:`Generated ${e} border color for secondary backgrounds (secondary, 15% ${c>0?`brighter`:`darker`})`}}for(let[e,t]of Object.entries(ge))l=Q(l,n,t,e,r);for(let[t,n]of Object.entries(l))a(n)&&(l[t]={theme:e,group:e,...n});return l}function Re(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function ze(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function $(e,t,n,o){if(Array.isArray(e))return e.map(e=>$(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:$(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=ze(c);for(let[e,n]of k(c))c[e]=Le(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?_e[n.group]:void 0;r&&(c=Q(c,t,r,e,o))}}for(let[e,n]of Object.entries(ve))a(c[e])&&(c=Q(c,t,n,e,o));return n===`color`?Re(c):c}function Be(e){let t=S(e),n=Se($(t,t,void 0,se(t)));return F(n,n)}var Ve=e(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:Be}]}));export{Ve as default,Be as tamaguiPreprocessor};
1
+ import{definePlugin as e}from"@razorwind/core/plugin";const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`group`,`semantic`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function b(e){if(Array.isArray(e))return e.map(e=>b(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function ne(e,t){if(t===`shadow`)return b(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function x(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function re(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=x(e,t);return`$value`in e?{...e,$value:ne(e.$value,n)}:{...e}}function S(e,t){if(Array.isArray(e))return e.map(e=>S(e,t));if(!i(e))return e;if(a(e))return re(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:S(i,n);return o}const C={dark:`#ffffff`,light:`#0c0c0d`},ie={dark:`#ffffff`,light:`#000000`};function w(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function ae(e){if(i(e)&&i(e.color))return w(e.color.$description)}const oe={name:`active`,brightness:1.45,useContrastPrimitive:!0},se={name:`active`,brightness:1.25},ce={name:`active`,brightness:1.175},le={name:`active`,brightness:1.8,useContrastPrimitive:!0},T={name:`inactive`,brightness:.8},E={name:`inactive`,brightness:.5,useContrastPrimitive:!0},D={name:`disabled`,opacity:.15,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},O={lowSaturation:[oe,E,D],saturated:[se,T,D]},ue={lowSaturation:[ce,T,D],saturated:O.saturated},k={name:`inactive`,brightness:.9},de={...D,opacity:.25,saturation:.925},fe={lowSaturation:[{name:`active`,brightness:1.3},k,de],saturated:[{name:`active`,brightness:1.25},k,de]},pe=[`shadows`];function A(e){return Object.entries(e).filter(e=>!pe.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const me={lowSaturation:[{name:`hovered`,brightness:1.4},le,E,D],saturated:[{name:`hovered`,brightness:1.2},{name:`active`,brightness:1.4},T,D]},j={lowSaturation:[{name:`hovered`,brightness:1.25},...O.lowSaturation],saturated:[{name:`hovered`,brightness:1.125},...O.saturated]},he={primary:j,secondary:{lowSaturation:[{name:`hovered`,brightness:1.08},...ue.lowSaturation],saturated:j.saturated},link:j},ge={foreground:{lowSaturation:[{name:`hovered`,brightness:1.25},...O.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...O.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.15},...fe.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...fe.saturated]}},_e={hairline:me},M=7.5,N=.01;function ve(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ye(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function P(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ye(t,i[1]);if(a&&`$value`in a)return P(a.$value,t,n)}function F(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function be(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function I(e,t,n=!1){if(Array.isArray(e))return e.map(e=>I(e,t,n));if(!i(e))return e;if(n&&a(e)&&x(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=P(e.color,t);return n?{...e,color:F(n,z(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=I(a,t,n||i.toLowerCase()===`ring`);return r}const L={value:0,unit:`px`};function R(e,t){return{color:e,offsetX:L,offsetY:L,blur:L,spread:{value:t,unit:`px`}}}function xe(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of A(t)){let t=`{color.${e}.primary}`,i=e=>R(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[R(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[R(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),R(t,7)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),R(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function z(e){return V(e).chroma<.02}function B(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function V(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function H({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function U(e,t,n,r){if(H(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;H(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function Se(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=V(e);return g(s(n*t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=V(e);return g(s(n+t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=V(e);return g(n,r*s(t),i,a)}function W(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function G(e,t){let n=W(e),r=W(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function K(e){let t=G(e,`#FAFAFA`);return t>=2?`#FAFAFA`:G(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=V(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*N),d=U(l,r,i,a),G(d,f)>=M)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*N),f=U(u,r,i,a),G(d,f)>=M)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}const Ee=V(`#fefefe`).lightness,De=V(`#262626`).lightness;function Oe(e){return V(e).lightness>=(z(e)?Ee:.75)}function ke(e){return V(e).lightness<=(z(e)?De:.25)}function q(e){return e.name===`hovered`||e.name===`active`}function J(e,t){return t===`dark`?Oe(e):t===`light`&&ke(e)}function Y(e,t){return t??(V(e).lightness>=.5?`light`:`dark`)}function X(e,t){let{lightness:n}=V(e);return t===`light`?1-n:n}function Z(e,t,n){let{chroma:r,hue:i,alpha:a}=V(e);return U(s(n===`light`?1-t:t),r,i,a)}function Ae(e,t,n){return t.name===`hovered`&&J(e,n)}function je(e,t,n){return(t.brightness??1)>=1!==Ae(e,t,n)}function Me(e,t,n){let r=X(e,n),i=(Ae(e,t,n)?r:V(e).lightness)*Math.abs((t.brightness??1)-1);return Z(e,je(e,t,n)?r+Math.min(i,(1-r)/2):r-i,n)}function Ne(e,t){return e.useContrastPrimitive&&t?C[t]:void 0}function Pe(e,t,n){if(t.name===`hovered`&&Ne(t,n)&&J(e,n))return n===`dark`?-.25:.25}function Fe(e,t,n){let r=Ne(t,n);return r&&n&&t.name===`active`&&J(e,n)?ie[n]:r}function Ie(e,t,n){let r=Pe(e,t,n),i=r===void 0?Fe(e,t,n):void 0,a=Y(e,n),o=i??e;return r===void 0?t.brightness!==void 0&&!(i&&q(t))&&(o=i?Z(i,X(i,a)*t.brightness,a):Me(e,t,a)):o=Ce(e,r),t.saturation!==void 0&&!B(e)&&(o=we(o,t.saturation),t.fadeOver===void 0)?o:t.fadeOver===void 0?t.opacity===void 0?o:F(o,t.opacity):be(o,t.fadeOver,t.opacity??1)}function Le(e,t,n){let r=[],i=Pe(t,e,n),a=Fe(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&q(e))r.push(n&&a!==C[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=Y(t,n);r.push(a?`${Math.round(e.brightness*100)}% of the ${i} contrast primitive's brightness`:`${Math.round(Math.abs(e.brightness-1)*100)}% ${je(t,e,i)?`brighter`:`less bright`}`)}return e.saturation!==void 0&&!B(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||B(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Re(e,t,n,r){let i=Le(n,t,r),a=Ie(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Q(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ve(r))continue;let s=e[r];if(!a(s))continue;let c=x(s);if(c&&c!==`color`)continue;let l=P(s.$value,t);if(!l)continue;let u=z(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=w(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Re(s,l,e,p))}let m=`${r}-active`,h=o[m];if(!(m in e)&&a(h)&&typeof h.$value==`string`){let e=Y(l,p),n=Math.max(...[l,o[`${r}-hovered`]?.$value,o[`${r}-inactive`]?.$value].map(e=>P(e,t)).filter(e=>e!==void 0).map(t=>X(t,e)));X(h.$value,e)<n&&(o[m]={...h,$value:Z(h.$value,n,e)})}}return o}function ze(e,t,n,r){let i=t.primary,o=a(i)&&P(i.$value,n),c=a(i)&&x(i);if(!a(i)||!o||c&&c!==`color`)return t;let l={...t};l.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},l[`on-primary`]??={...i,$type:`color`,$value:K(o),$description:`Generated text and icon color on ${e} primary backgrounds`},l.backdrop??={...i,$type:`color`,$value:F(Se(o,.375),.15),$description:`Generated ${e} overlay backdrop color (primary, 30% darker at 75% opacity)`};let u;if(r&&!(`secondary`in t)){let t=Te(o,r);l.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},u=t.onMuted??o}else if(a(t.secondary)){let e=P(t.secondary.$value,n);u=e&&K(e)}u&&!(`on-secondary`in t)&&(l[`on-secondary`]={...i,$type:`color`,$value:u,$description:`Generated text and icon color on ${e} secondary backgrounds`});let d=!(`border`in t)&&a(l.secondary)&&P(l.secondary.$value,n);if(d){let{lightness:t,chroma:n,hue:a,alpha:o}=V(d),c=r===`light`?-1:1;l.border={...i,$type:`color`,$value:U(s(t*(1+c*.25)),n,a,o),$description:`Generated ${e} border color for secondary backgrounds (secondary, 25% ${c>0?`brighter`:`darker`})`}}for(let[e,t]of Object.entries(he))l=Q(l,n,t,e,r);for(let[t,n]of Object.entries(l))a(n)&&(l[t]={theme:e,group:e,...n});return l}function Be(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function Ve(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function $(e,t,n,o){if(Array.isArray(e))return e.map(e=>$(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:$(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=Ve(c);for(let[e,n]of A(c))c[e]=ze(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?ge[n.group]:void 0;r&&(c=Q(c,t,r,e,o))}}for(let[e,n]of Object.entries(_e))a(c[e])&&(c=Q(c,t,n,e,o));return n===`color`?Be(c):c}function He(e){let t=S(e),n=xe($(t,t,void 0,ae(t)));return I(n,n)}var Ue=e(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:He}]}));export{Ue as default,He as tamaguiPreprocessor};
2
2
  //# sourceMappingURL=preprocessor.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"preprocessor.mjs","names":["HEX_RE","OKLCH_RE","RESERVED_KEYS","isPlainObject","value","isTokenNode","isAlias","trimmed","clamp01","toSrgb","clipped","channel","fromSrgb","hexChannel","srgbHexChannel","alphaHex","alpha","expandHex","hex","digit","colorValueToHex","expanded","parseAlpha","red","parseComponent","green","blue","oklchToLinearSrgb","hueRad","hue","a","chroma","b","l_","lightness","m_","s_","l3","m3","s3","oklchToHex","parsed","oklchStringToHex","match","oklchObjectToHex","convertColor","convertShadow","layer","color","convertValue","type","resolveType","token","inheritedType","mapTokenNode","walk","node","item","groupType","result","key","CONTRAST_PRIMITIVES","PURE_CONTRAST_COLORS","parentThemeFromDescription","description","theme","parentThemeFromDictionary","dictionary","LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_ACTIVE","SUBTLE_LOW_SATURATION_COLOR_STATE_ACTIVE","HAIRLINE_COLOR_STATE_ACTIVE","INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_INACTIVE","LOW_SATURATION_COLOR_STATE_INACTIVE","COLOR_STATE_DISABLED","DEFAULT_COLOR_STATE_VARIANTS","SUBTLE_COLOR_STATE_VARIANTS","BACKGROUND_COLOR_STATE_INACTIVE","BACKGROUND_COLOR_STATE_DISABLED","BACKGROUND_COLOR_STATE_VARIANTS","NONE_THEME_COLOR_KEYS","themeColorGroups","entry","OUTLINE_COLOR_STATE_VARIANTS","THEME_COLOR_STATE_VARIANTS","COLOR_STATE_TOKEN_GROUPS","COLOR_STATE_VARIANTS","MINIMUM_SUBTLE_CONTRAST_RATIO","SUBTLE_COLOR_LIGHTNESS_STEP","isStateVariantKey","getTokenAtPath","tree","part","path","resolveColorHex","direct","ref","seen","applyOpacity","rgb","opacity","applyFadeOver","foreground","base","background","offset","applyRingOpacity","inRingGroup","applyToLayer","isLowSaturation","index","ZERO","ringLayer","spread","addMissingRingTokens","ring","changed","name","ringColor","gap","variants","hexToOklch","isGreyscale","l","m","s","isInSrgbGamut","oklchToGamutMappedHex","minimumChroma","maximumChroma","candidateChroma","applyBrightness","factor","applyLightnessShift","shift","applySaturation","relativeLuminance","contrastRatio","firstLuminance","first","secondLuminance","second","lighter","darker","createOnColor","whiteContrast","createMutedColor","secondaryDirection","parentTheme","onMutedDirection","secondaryLightness","onMutedLightness","secondary","onMuted","isLightColor","isWhiteColor","isBlackColor","isDarkColor","LOW_SATURATION_WHITE_LIGHTNESS","LOW_SATURATION_BLACK_LIGHTNESS","isInteractionState","variant","isNearContrastPrimitive","directedBrightnessFactor","contrastPrimitive","contrastSideLightnessShift","stateContrastColor","primitive","stateBrightnessFactor","applyStateTransform","transformed","variantDetail","details","percent","createStateToken","detail","source","addColorStateTokens","group","names","onlyKey","baseVariants","hasHovered","tokenVariants","tokenParentTheme","variantKey","addThemeColorGroupTokens","onSecondary","pair","secondaryHex","direction","addColorTokenGroups","root","populateEmptyBrandTheme","brand","injectColorStateVariants","childKey","withStates","tokenKey","tamaguiPreprocessor","converted","withRings","preprocessor_default","definePlugin"],"sources":[],"mappings":""}
1
+ {"version":3,"file":"preprocessor.mjs","names":["HEX_RE","OKLCH_RE","RESERVED_KEYS","isPlainObject","value","isTokenNode","isAlias","trimmed","clamp01","toSrgb","clipped","channel","fromSrgb","hexChannel","srgbHexChannel","alphaHex","alpha","expandHex","hex","digit","colorValueToHex","expanded","parseAlpha","red","parseComponent","green","blue","oklchToLinearSrgb","hueRad","hue","a","chroma","b","l_","lightness","m_","s_","l3","m3","s3","oklchToHex","parsed","oklchStringToHex","match","oklchObjectToHex","convertColor","convertShadow","layer","color","convertValue","type","resolveType","token","inheritedType","mapTokenNode","walk","node","item","groupType","result","key","CONTRAST_PRIMITIVES","PURE_CONTRAST_COLORS","parentThemeFromDescription","description","theme","parentThemeFromDictionary","dictionary","LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_ACTIVE","SUBTLE_LOW_SATURATION_COLOR_STATE_ACTIVE","INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_INACTIVE","LOW_SATURATION_COLOR_STATE_INACTIVE","COLOR_STATE_DISABLED","DEFAULT_COLOR_STATE_VARIANTS","SUBTLE_COLOR_STATE_VARIANTS","BACKGROUND_COLOR_STATE_INACTIVE","BACKGROUND_COLOR_STATE_DISABLED","BACKGROUND_COLOR_STATE_VARIANTS","NONE_THEME_COLOR_KEYS","themeColorGroups","entry","HAIRLINE_COLOR_STATE_VARIANTS","THEME_COLOR_STATE_HOVERED_VARIANTS","THEME_COLOR_STATE_VARIANTS","COLOR_STATE_TOKEN_GROUPS","COLOR_STATE_VARIANTS","MINIMUM_SUBTLE_CONTRAST_RATIO","SUBTLE_COLOR_LIGHTNESS_STEP","isStateVariantKey","getTokenAtPath","tree","part","path","resolveColorHex","direct","ref","seen","applyOpacity","rgb","opacity","applyFadeOver","foreground","base","background","offset","applyRingOpacity","inRingGroup","applyToLayer","isLowSaturation","index","ZERO","ringLayer","spread","addMissingRingTokens","ring","changed","name","ringColor","gap","variants","hexToOklch","isGreyscale","l","m","s","isInSrgbGamut","oklchToGamutMappedHex","minimumChroma","maximumChroma","candidateChroma","applyBrightness","factor","applyLightnessShift","shift","applySaturation","relativeLuminance","contrastRatio","firstLuminance","first","secondLuminance","second","lighter","darker","createOnColor","whiteContrast","createMutedColor","secondaryDirection","parentTheme","onMutedDirection","secondaryLightness","onMutedLightness","secondary","onMuted","LOW_SATURATION_WHITE_LIGHTNESS","LOW_SATURATION_BLACK_LIGHTNESS","isWhiteColor","isBlackColor","isInteractionState","variant","isNearContrastPrimitive","stateTheme","themeBrightness","withThemeBrightness","brightness","isReversedState","isBrighterState","applyStateBrightness","step","contrastPrimitive","contrastSideLightnessShift","stateContrastColor","primitive","applyStateTransform","transformed","variantDetail","details","createStateToken","detail","source","addColorStateTokens","group","names","onlyKey","baseVariants","hasHovered","tokenVariants","tokenParentTheme","variantKey","activeKey","active","floor","addThemeColorGroupTokens","onSecondary","pair","secondaryHex","direction","addColorTokenGroups","root","populateEmptyBrandTheme","brand","injectColorStateVariants","childKey","withStates","tokenKey","tamaguiPreprocessor","converted","withRings","preprocessor_default","definePlugin"],"sources":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyclone-ui/theme-builder",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -401,8 +401,10 @@ interface ColorStateVariant {
401
401
  /** Multiplier applied to OKLCH chroma for non-greyscale colors. */
402
402
  saturation?: number;
403
403
  /**
404
- * Multiplier applied to OKLCH lightness (e.g. 1.1 = 10%). State direction
405
- * is determined by the source color and its parent theme.
404
+ * Multiplier applied to OKLCH lightness (e.g. 1.1 = 10%). Values above 1 are
405
+ * brighter: lighter in dark themes, darker in light themes. Active states
406
+ * are never less bright than the color's normal, hovered, or inactive states;
407
+ * hovered states reverse for colors already near the contrast primitive.
406
408
  */
407
409
  brightness?: number;
408
410
  /** Resolve state colors from the parent theme's contrast primitive. */
@@ -463,12 +465,7 @@ const COLOR_STATE_ACTIVE: ColorStateVariant = {
463
465
 
464
466
  const SUBTLE_LOW_SATURATION_COLOR_STATE_ACTIVE: ColorStateVariant = {
465
467
  name: "active",
466
- brightness: 1.125
467
- };
468
-
469
- const HAIRLINE_COLOR_STATE_ACTIVE: ColorStateVariant = {
470
- name: "active",
471
- brightness: 1.4
468
+ brightness: 1.175
472
469
  };
473
470
 
474
471
  const INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE: ColorStateVariant = {
@@ -490,7 +487,7 @@ const LOW_SATURATION_COLOR_STATE_INACTIVE: ColorStateVariant = {
490
487
 
491
488
  const COLOR_STATE_DISABLED: ColorStateVariant = {
492
489
  name: "disabled",
493
- opacity: 0.35,
490
+ opacity: 0.15,
494
491
  saturation: 0.85,
495
492
  fadeOver: "oklch(0.3839 0.0045 286.26)"
496
493
  };
@@ -510,10 +507,14 @@ const DEFAULT_COLOR_STATE_VARIANTS: ColorStateVariants = {
510
507
  saturated: [COLOR_STATE_ACTIVE, COLOR_STATE_INACTIVE, COLOR_STATE_DISABLED]
511
508
  };
512
509
 
510
+ /**
511
+ * Subtle (secondary) colors dim their own lightness when inactive; the
512
+ * contrast primitive's mid-grey would be brighter than these backgrounds.
513
+ */
513
514
  const SUBTLE_COLOR_STATE_VARIANTS: ColorStateVariants = {
514
515
  lowSaturation: [
515
516
  SUBTLE_LOW_SATURATION_COLOR_STATE_ACTIVE,
516
- LOW_SATURATION_COLOR_STATE_INACTIVE,
517
+ COLOR_STATE_INACTIVE,
517
518
  COLOR_STATE_DISABLED
518
519
  ],
519
520
  saturated: DEFAULT_COLOR_STATE_VARIANTS.saturated
@@ -530,7 +531,7 @@ const BACKGROUND_COLOR_STATE_INACTIVE: ColorStateVariant = {
530
531
 
531
532
  const BACKGROUND_COLOR_STATE_DISABLED: ColorStateVariant = {
532
533
  ...COLOR_STATE_DISABLED,
533
- opacity: 0.675,
534
+ opacity: 0.25,
534
535
  saturation: 0.925
535
536
  };
536
537
 
@@ -564,25 +565,52 @@ function themeColorGroups(
564
565
  );
565
566
  }
566
567
 
567
- const OUTLINE_COLOR_STATE_VARIANTS: ColorStateVariants = {
568
+ const HAIRLINE_COLOR_STATE_VARIANTS: ColorStateVariants = {
568
569
  lowSaturation: [
570
+ { name: "hovered", brightness: 1.4 },
569
571
  INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE,
570
572
  LOW_SATURATION_COLOR_STATE_INACTIVE,
571
573
  COLOR_STATE_DISABLED
572
574
  ],
573
575
  saturated: [
574
- HAIRLINE_COLOR_STATE_ACTIVE,
576
+ { name: "hovered", brightness: 1.2 },
577
+ {
578
+ name: "active",
579
+ brightness: 1.4
580
+ },
575
581
  COLOR_STATE_INACTIVE,
576
582
  COLOR_STATE_DISABLED
577
583
  ]
578
584
  };
579
585
 
586
+ /**
587
+ * Theme color group hovered states take about half the step of active, and
588
+ * never jump to the contrast primitive (so they stay distinct from active).
589
+ */
590
+ const THEME_COLOR_STATE_HOVERED_VARIANTS: ColorStateVariants = {
591
+ lowSaturation: [
592
+ { name: "hovered", brightness: 1.25 },
593
+ ...DEFAULT_COLOR_STATE_VARIANTS.lowSaturation
594
+ ],
595
+ saturated: [
596
+ { name: "hovered", brightness: 1.125 },
597
+ ...DEFAULT_COLOR_STATE_VARIANTS.saturated
598
+ ]
599
+ };
600
+
601
+ const SUBTLE_COLOR_STATE_HOVERED_VARIANTS: ColorStateVariants = {
602
+ lowSaturation: [
603
+ { name: "hovered", brightness: 1.08 },
604
+ ...SUBTLE_COLOR_STATE_VARIANTS.lowSaturation
605
+ ],
606
+ saturated: THEME_COLOR_STATE_HOVERED_VARIANTS.saturated
607
+ };
608
+
580
609
  /** State variants for the tokens inside each theme color group. */
581
610
  const THEME_COLOR_STATE_VARIANTS: Record<string, ColorStateVariants> = {
582
- primary: DEFAULT_COLOR_STATE_VARIANTS,
583
- secondary: SUBTLE_COLOR_STATE_VARIANTS,
584
- link: DEFAULT_COLOR_STATE_VARIANTS,
585
- outline: OUTLINE_COLOR_STATE_VARIANTS
611
+ primary: THEME_COLOR_STATE_HOVERED_VARIANTS,
612
+ secondary: SUBTLE_COLOR_STATE_HOVERED_VARIANTS,
613
+ link: THEME_COLOR_STATE_HOVERED_VARIANTS
586
614
  };
587
615
 
588
616
  /**
@@ -602,7 +630,7 @@ const FOREGROUND_COLOR_STATE_VARIANTS: ColorStateVariants = {
602
630
 
603
631
  const BACKGROUND_COLOR_STATE_HOVERED_VARIANTS: ColorStateVariants = {
604
632
  lowSaturation: [
605
- { name: "hovered", brightness: 1.25 },
633
+ { name: "hovered", brightness: 1.15 },
606
634
  ...BACKGROUND_COLOR_STATE_VARIANTS.lowSaturation
607
635
  ],
608
636
  saturated: [
@@ -619,7 +647,7 @@ const COLOR_STATE_TOKEN_GROUPS: Record<string, ColorStateVariants> = {
619
647
 
620
648
  /** Standalone color tokens that receive state variants. */
621
649
  const COLOR_STATE_VARIANTS: Record<string, ColorStateVariants> = {
622
- outline: OUTLINE_COLOR_STATE_VARIANTS
650
+ hairline: HAIRLINE_COLOR_STATE_VARIANTS
623
651
  };
624
652
 
625
653
  /** OKLCH chroma below which a color uses the low-saturation state variants. */
@@ -633,9 +661,9 @@ const SUBTLE_COLOR_LIGHTNESS_STEP = 0.01;
633
661
  const MAX_SUBTLE_COLOR_ADJUSTMENTS = 100;
634
662
  const SUBTLE_COLOR_GAMUT_SEARCH_ITERATIONS = 32;
635
663
  const BACKDROP_BRIGHTNESS = 0.375;
636
- const BACKDROP_OPACITY = 0.45;
664
+ const BACKDROP_OPACITY = 0.15;
637
665
  /** OKLCH lightness step for the rim around `secondary` backgrounds (brighter in dark, darker in light themes). */
638
- const BORDER_LIGHTNESS_STEP = 0.15;
666
+ const BORDER_LIGHTNESS_STEP = 0.25;
639
667
  /** OKLCH lightness shift for hovered colors already near the contrast primitive. */
640
668
  const CONTRAST_SIDE_ACTIVE_LIGHTNESS_SHIFT = 0.25;
641
669
 
@@ -1047,22 +1075,6 @@ function createMutedColor(
1047
1075
  throw new Error(`Unable to generate an accessible secondary pair for ${hex}`);
1048
1076
  }
1049
1077
 
1050
- function isLightColor(hex: string, parentTheme?: ParentTheme): boolean {
1051
- if (parentTheme === "dark") {
1052
- return isWhiteColor(hex);
1053
- }
1054
-
1055
- if (parentTheme === "light") {
1056
- return !isBlackColor(hex);
1057
- }
1058
-
1059
- return hexToOklch(hex).lightness >= 0.5;
1060
- }
1061
-
1062
- function isDarkColor(hex: string, parentTheme?: ParentTheme): boolean {
1063
- return !isLightColor(hex, parentTheme);
1064
- }
1065
-
1066
1078
  /** Low-saturation colors only count as white / black past ≈ #dddddd / #262626. */
1067
1079
  const LOW_SATURATION_WHITE_LIGHTNESS = hexToOklch("#fefefe").lightness;
1068
1080
  const LOW_SATURATION_BLACK_LIGHTNESS = hexToOklch("#262626").lightness;
@@ -1095,13 +1107,83 @@ function isNearContrastPrimitive(
1095
1107
  : parentTheme === "light" && isBlackColor(hex);
1096
1108
  }
1097
1109
 
1098
- /** Resolve a state multiplier from the source color and parent theme. */
1099
- function directedBrightnessFactor(
1110
+ /** Without a parent theme, dark colors brighten like a dark theme (and vice versa). */
1111
+ function stateTheme(hex: string, parentTheme?: ParentTheme): ParentTheme {
1112
+ return parentTheme ?? (hexToOklch(hex).lightness >= 0.5 ? "light" : "dark");
1113
+ }
1114
+
1115
+ /** Brightness is OKLCH lightness in dark themes and its inverse in light themes. */
1116
+ function themeBrightness(hex: string, parentTheme: ParentTheme): number {
1117
+ const { lightness } = hexToOklch(hex);
1118
+
1119
+ return parentTheme === "light" ? 1 - lightness : lightness;
1120
+ }
1121
+
1122
+ function withThemeBrightness(
1100
1123
  hex: string,
1101
- factor: number,
1102
- parentTheme?: ParentTheme
1103
- ): number {
1104
- return isDarkColor(hex, parentTheme) ? factor : 2 - factor;
1124
+ brightness: number,
1125
+ parentTheme: ParentTheme
1126
+ ): string {
1127
+ const { chroma, hue, alpha } = hexToOklch(hex);
1128
+
1129
+ return oklchToGamutMappedHex(
1130
+ clamp01(parentTheme === "light" ? 1 - brightness : brightness),
1131
+ chroma,
1132
+ hue,
1133
+ alpha
1134
+ );
1135
+ }
1136
+
1137
+ /**
1138
+ * Only hovered states reverse, for colors already near the contrast primitive
1139
+ * (which can't get meaningfully brighter); active states never become less
1140
+ * bright.
1141
+ */
1142
+ function isReversedState(
1143
+ hex: string,
1144
+ variant: ColorStateVariant,
1145
+ parentTheme: ParentTheme
1146
+ ): boolean {
1147
+ return (
1148
+ variant.name === "hovered" && isNearContrastPrimitive(hex, parentTheme)
1149
+ );
1150
+ }
1151
+
1152
+ function isBrighterState(
1153
+ hex: string,
1154
+ variant: ColorStateVariant,
1155
+ parentTheme: ParentTheme
1156
+ ): boolean {
1157
+ return (
1158
+ (variant.brightness ?? 1) >= 1 !==
1159
+ isReversedState(hex, variant, parentTheme)
1160
+ );
1161
+ }
1162
+
1163
+ /**
1164
+ * Step `hex` by the state's `brightness` (a multiple of its OKLCH lightness).
1165
+ * Brighter steps stop halfway to pure white / black so bright colors keep
1166
+ * their hue instead of blowing out. Reversed steps scale with brightness so
1167
+ * pure black still moves in light themes.
1168
+ */
1169
+ function applyStateBrightness(
1170
+ hex: string,
1171
+ variant: ColorStateVariant,
1172
+ parentTheme: ParentTheme
1173
+ ): string {
1174
+ const brightness = themeBrightness(hex, parentTheme);
1175
+ const step =
1176
+ (isReversedState(hex, variant, parentTheme)
1177
+ ? brightness
1178
+ : hexToOklch(hex).lightness) * Math.abs((variant.brightness ?? 1) - 1);
1179
+
1180
+ return withThemeBrightness(
1181
+ hex,
1182
+ isBrighterState(hex, variant, parentTheme)
1183
+ ? brightness + Math.min(step, (1 - brightness) / 2)
1184
+ : brightness - step,
1185
+ parentTheme
1186
+ );
1105
1187
  }
1106
1188
 
1107
1189
  function contrastPrimitive(
@@ -1156,22 +1238,6 @@ function stateContrastColor(
1156
1238
  : primitive;
1157
1239
  }
1158
1240
 
1159
- function stateBrightnessFactor(
1160
- hex: string,
1161
- variant: ColorStateVariant,
1162
- parentTheme?: ParentTheme
1163
- ): number {
1164
- if (variant.brightness === undefined) {
1165
- return 1;
1166
- }
1167
-
1168
- if (contrastPrimitive(variant, parentTheme)) {
1169
- return isInteractionState(variant) ? 1 : variant.brightness;
1170
- }
1171
-
1172
- return directedBrightnessFactor(hex, variant.brightness, parentTheme);
1173
- }
1174
-
1175
1241
  function applyStateTransform(
1176
1242
  hex: string,
1177
1243
  variant: ColorStateVariant,
@@ -1182,6 +1248,7 @@ function applyStateTransform(
1182
1248
  shift === undefined
1183
1249
  ? stateContrastColor(hex, variant, parentTheme)
1184
1250
  : undefined;
1251
+ const theme = stateTheme(hex, parentTheme);
1185
1252
  let transformed = primitive ?? hex;
1186
1253
 
1187
1254
  if (shift !== undefined) {
@@ -1190,10 +1257,15 @@ function applyStateTransform(
1190
1257
  variant.brightness !== undefined &&
1191
1258
  !(primitive && isInteractionState(variant))
1192
1259
  ) {
1193
- transformed = applyBrightness(
1194
- transformed,
1195
- stateBrightnessFactor(transformed, variant, parentTheme)
1196
- );
1260
+ // Non-interaction states scale the primitive's brightness directly
1261
+ // (e.g. inactive at 50% is mid-grey in both dark and light themes).
1262
+ transformed = primitive
1263
+ ? withThemeBrightness(
1264
+ primitive,
1265
+ themeBrightness(primitive, theme) * variant.brightness,
1266
+ theme
1267
+ )
1268
+ : applyStateBrightness(hex, variant, theme);
1197
1269
  }
1198
1270
 
1199
1271
  if (variant.saturation !== undefined && !isGreyscale(hex)) {
@@ -1234,11 +1306,12 @@ function variantDetail(
1234
1306
  : `${parentTheme} contrast primitive`
1235
1307
  );
1236
1308
  } else if (variant.brightness !== undefined) {
1237
- const factor = stateBrightnessFactor(hex, variant, parentTheme);
1238
- const percent = Math.round((factor - 1) * 100);
1309
+ const theme = stateTheme(hex, parentTheme);
1239
1310
 
1240
1311
  details.push(
1241
- percent >= 0 ? `${percent}% brighter` : `${Math.abs(percent)}% darker`
1312
+ primitive
1313
+ ? `${Math.round(variant.brightness * 100)}% of the ${theme} contrast primitive's brightness`
1314
+ : `${Math.round(Math.abs(variant.brightness - 1) * 100)}% ${isBrighterState(hex, variant, theme) ? "brighter" : "less bright"}`
1242
1315
  );
1243
1316
  }
1244
1317
 
@@ -1336,6 +1409,34 @@ function addColorStateTokens(
1336
1409
  tokenParentTheme
1337
1410
  );
1338
1411
  }
1412
+
1413
+ // Generated active states are never less bright than the color or its
1414
+ // hovered / inactive states.
1415
+ const activeKey = `${name}-active`;
1416
+ const active = result[activeKey];
1417
+ if (
1418
+ !(activeKey in group) &&
1419
+ isTokenNode(active) &&
1420
+ typeof active.$value === "string"
1421
+ ) {
1422
+ const theme = stateTheme(hex, tokenParentTheme);
1423
+ const floor = Math.max(
1424
+ ...[
1425
+ hex,
1426
+ result[`${name}-hovered`]?.$value,
1427
+ result[`${name}-inactive`]?.$value
1428
+ ]
1429
+ .map(value => resolveColorHex(value, tree))
1430
+ .filter((value): value is string => value !== undefined)
1431
+ .map(value => themeBrightness(value, theme))
1432
+ );
1433
+ if (themeBrightness(active.$value, theme) < floor) {
1434
+ result[activeKey] = {
1435
+ ...active,
1436
+ $value: withThemeBrightness(active.$value, floor, theme)
1437
+ };
1438
+ }
1439
+ }
1339
1440
  }
1340
1441
 
1341
1442
  return result;
@@ -1344,12 +1445,11 @@ function addColorStateTokens(
1344
1445
  /**
1345
1446
  * Fill in a theme color group (`color.danger`, …): generate a missing
1346
1447
  * `secondary` low-emphasis background from `primary` and the parent theme,
1347
- * missing `link` color and, for `status` groups, `outline` color (both
1348
- * aliasing `primary`), `on-primary` /
1448
+ * a missing `link` color (aliasing `primary`), `on-primary` /
1349
1449
  * `on-secondary` text colors, a `backdrop` overlay color (`primary` 30% darker
1350
1450
  * at 75% opacity, no state variants), a `border` color (`secondary` 15% brighter, or
1351
1451
  * 15% darker in light themes, no state variants), and state variants for `primary`, `secondary`,
1352
- * `link` and `outline`. Every token in the group gets the group name as
1452
+ * and `link`. Every token in the group gets the group name as
1353
1453
  * its `theme` and `group`, so Tamagui places it in that child theme (e.g.
1354
1454
  * `danger.on-primary` → `onPrimary` in the `danger` theme).
1355
1455
  */
@@ -1373,14 +1473,7 @@ function addThemeColorGroupTokens(
1373
1473
  $value: `{color.${name}.primary}`,
1374
1474
  $description: `Generated ${name} hyperlink text color (matches primary)`
1375
1475
  };
1376
- if (group.group === "status") {
1377
- result.outline ??= {
1378
- ...token,
1379
- $type: "color",
1380
- $value: `{color.${name}.primary}`,
1381
- $description: `Generated ${name} border and divider color (matches primary)`
1382
- };
1383
- }
1476
+
1384
1477
  result["on-primary"] ??= {
1385
1478
  ...token,
1386
1479
  $type: "color",
@@ -1457,7 +1550,7 @@ function addThemeColorGroupTokens(
1457
1550
 
1458
1551
  /**
1459
1552
  * Add a `group` (the main token name) to each state and `on-*` color token
1460
- * that does not define one, e.g. `outline-active` → `outline`.
1553
+ * that does not define one, e.g. `hairline-active` → `hairline`.
1461
1554
  */
1462
1555
  function addColorTokenGroups(
1463
1556
  group: Record<string, unknown>
@@ -1588,24 +1681,25 @@ function injectColorStateVariants(
1588
1681
  /**
1589
1682
  * Style Dictionary preprocessor: rewrite color `$value`s (and nested shadow
1590
1683
  * colors) to hex so generators emit `#rrggbb` / `#rrggbbaa` instead of
1591
- * `oklch()`. Root colors (emphasis, ink, subtle, outline, backgrounds)
1684
+ * `oklch()`. Root colors (emphasis, ink, subtle, hairline, backgrounds)
1592
1685
  * stay in the root light and dark themes without rings. For each color group
1593
1686
  * with a `primary` token (except excluded groups), a missing `secondary` background and `on-primary` /
1594
1687
  * `on-secondary` text colors are generated, a missing `border` is derived from
1595
1688
  * `secondary` (15% brighter, or darker in light themes), then hovered, active, inactive,
1596
- * and disabled variants are added to the outline, `foreground` and
1689
+ * and disabled variants are added to the `hairline`, `foreground` and
1597
1690
  * `background` group colors, and each theme color group's `primary`, `secondary`
1598
- * `link` and `outline` (`link`, and `outline` in `status` groups, default to
1599
- * `primary` when missing).
1691
+ * and `link` (`link` defaults to `primary` when missing).
1600
1692
  * Low-saturation colors derive their states from the parent theme's contrast
1601
1693
  * primitive (backgrounds use a half-strength shift of their own lightness; hovered
1602
1694
  * colors already near that primitive shift toward the middle, while active
1603
1695
  * ones become pure white or black); saturated
1604
- * colors scale their own lightness. Foreground and background hovered states
1605
- * take a smaller step than their active states. Tokens in a theme color group get the
1696
+ * colors scale their own lightness. "Brighter" means lighter in dark themes and
1697
+ * darker in light themes: active states are never less bright than the normal,
1698
+ * hovered, or inactive states, and hovered states take a smaller step than
1699
+ * active (reversing only for colors near the contrast primitive). Tokens in a theme color group get the
1606
1700
  * group name as `theme` and `group`, unless already set; root state and `on-*`
1607
- * tokens get their main token name as `group` (e.g. `outline-active` →
1608
- * `outline`).
1701
+ * tokens get their main token name as `group` (e.g. `hairline-active` →
1702
+ * `hairline`).
1609
1703
  * Finally, focus rings are generated for each theme color group.
1610
1704
  */
1611
1705
  export function tamaguiPreprocessor(