typestyles 0.2.0 → 0.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/css.ts","../src/sheet.ts","../src/registry.ts","../src/styles.ts","../src/tokens.ts","../src/keyframes.ts","../src/color.ts","../src/component.ts","../src/global.ts","../src/vars.ts","../src/index.ts"],"names":["registeredNamespaces","alpha"],"mappings":";;;;;;;;;AAMO,SAAS,YAAY,IAAA,EAAsB;AAEhD,EAAA,IAAI,IAAA,CAAK,UAAA,CAAW,IAAI,CAAA,EAAG;AACzB,IAAA,OAAO,GAAA,GAAM,KAAK,OAAA,CAAQ,QAAA,EAAU,CAAC,CAAA,KAAM,GAAA,GAAM,CAAA,CAAE,WAAA,EAAa,CAAA;AAAA,EAClE;AACA,EAAA,OAAO,IAAA,CAAK,QAAQ,QAAA,EAAU,CAAC,MAAM,GAAA,GAAM,CAAA,CAAE,aAAa,CAAA;AAC5D;AAKA,SAAS,cAAA,CAAe,MAAc,KAAA,EAAgC;AACpE,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,IAAI,KAAA,KAAU,GAAG,OAAO,GAAA;AAExB,IAAA,IAAI,mBAAmB,GAAA,CAAI,IAAI,CAAA,EAAG,OAAO,OAAO,KAAK,CAAA;AACrD,IAAA,OAAO,KAAA,GAAQ,IAAA;AAAA,EACjB;AACA,EAAA,OAAO,KAAA;AACT;AAEA,IAAM,kBAAA,uBAAyB,GAAA,CAAI;AAAA,EACjC,yBAAA;AAAA,EACA,mBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,eAAA;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,MAAA,GAAS;AAAA,EACpB,MAAA,EAAQ,YAAA;AAAA,EACR,GAAA,EAAK,SAAA;AAAA,EACL;AACF;AAiBO,IAAM,SAAA,GAAY;AAAA,EACvB,MAAA,EAAQ;AACV;AAiBO,IAAM,KAAA,GAAQ","file":"index.cjs","sourcesContent":["import type { CSSProperties } from './types.js';\n\n/**\n * Convert a camelCase CSS property name to kebab-case.\n * Handles vendor prefixes (ms, webkit, moz) correctly.\n */\nexport function toKebabCase(prop: string): string {\n // Handle ms- prefix specially (no leading dash in camelCase)\n if (prop.startsWith('ms')) {\n return '-' + prop.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n }\n return prop.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n}\n\n/**\n * Serialize a single CSS value. Numbers are treated as px for most properties.\n */\nfunction serializeValue(prop: string, value: string | number): string {\n if (typeof value === 'number') {\n if (value === 0) return '0';\n // Unitless properties that shouldn't get 'px'\n if (unitlessProperties.has(prop)) return String(value);\n return value + 'px';\n }\n return value;\n}\n\nconst unitlessProperties = new Set([\n 'animationIterationCount',\n 'borderImageOutset',\n 'borderImageSlice',\n 'borderImageWidth',\n 'columnCount',\n 'columns',\n 'flex',\n 'flexGrow',\n 'flexPositive',\n 'flexShrink',\n 'flexNegative',\n 'flexOrder',\n 'fontWeight',\n 'gridArea',\n 'gridColumn',\n 'gridColumnEnd',\n 'gridColumnSpan',\n 'gridColumnStart',\n 'gridRow',\n 'gridRowEnd',\n 'gridRowSpan',\n 'gridRowStart',\n 'lineClamp',\n 'lineHeight',\n 'opacity',\n 'order',\n 'orphans',\n 'tabSize',\n 'widows',\n 'zIndex',\n 'zoom',\n 'fillOpacity',\n 'floodOpacity',\n 'stopOpacity',\n 'strokeDasharray',\n 'strokeDashoffset',\n 'strokeMiterlimit',\n 'strokeOpacity',\n 'strokeWidth',\n]);\n\n/**\n * Represents a generated CSS rule.\n */\nexport interface CSSRule {\n /** Unique key for deduplication */\n key: string;\n /** The CSS rule string */\n css: string;\n}\n\n/**\n * Serialize a style definition object into CSS rule(s) for a given selector.\n */\nexport function serializeStyle(\n selector: string,\n properties: CSSProperties\n): CSSRule[] {\n const rules: CSSRule[] = [];\n const declarations: string[] = [];\n\n for (const [prop, value] of Object.entries(properties)) {\n if (value == null) continue;\n\n if (prop.startsWith('&')) {\n // Nested selector: replace & with the parent selector\n const nestedSelector = prop.replace(/&/g, selector);\n rules.push(\n ...serializeStyle(nestedSelector, value as CSSProperties)\n );\n } else if (prop.startsWith('@')) {\n // At-rule: wrap the serialized content in the at-rule\n const innerRules = serializeStyle(selector, value as CSSProperties);\n for (const inner of innerRules) {\n rules.push({\n key: `${prop}:${inner.key}`,\n css: `${prop} { ${inner.css} }`,\n });\n }\n } else {\n // Regular CSS property\n const kebabProp = toKebabCase(prop);\n declarations.push(\n `${kebabProp}: ${serializeValue(prop, value as string | number)}`\n );\n }\n }\n\n // Add the base rule with all plain declarations\n if (declarations.length > 0) {\n rules.unshift({\n key: selector,\n css: `${selector} { ${declarations.join('; ')}; }`,\n });\n }\n\n return rules;\n}\n","const STYLE_ELEMENT_ID = 'typestyles';\n\n/**\n * Tracks which CSS rules have been inserted to avoid duplicates.\n */\nconst insertedRules = new Set<string>();\n\n/**\n * Buffer of CSS rules waiting to be flushed.\n */\nlet pendingRules: string[] = [];\n\n/**\n * All CSS rules ever registered (for SSR extraction).\n * Unlike pendingRules (which is cleared on flush), this retains every rule\n * so getRegisteredCss() can return the full stylesheet at any point.\n */\nconst allRules: string[] = [];\n\n/**\n * Whether a flush is scheduled.\n */\nlet flushScheduled = false;\n\n/**\n * The managed <style> element, lazily created.\n */\nlet styleElement: HTMLStyleElement | null = null;\n\n/**\n * When in SSR collection mode, CSS is captured here instead of injected.\n */\nlet ssrBuffer: string[] | null = null;\n\n/**\n * Whether we're running in a browser environment.\n */\nconst isBrowser =\n typeof document !== 'undefined' && typeof window !== 'undefined';\n\nfunction getStyleElement(): HTMLStyleElement {\n if (styleElement) return styleElement;\n\n // Check for an existing element (e.g., from SSR)\n const existing = document.getElementById(\n STYLE_ELEMENT_ID\n ) as HTMLStyleElement | null;\n if (existing) {\n styleElement = existing;\n return styleElement;\n }\n\n // Create a new one\n styleElement = document.createElement('style');\n styleElement.id = STYLE_ELEMENT_ID;\n document.head.appendChild(styleElement);\n return styleElement;\n}\n\nfunction flush(): void {\n flushScheduled = false;\n if (pendingRules.length === 0) return;\n\n const rules = pendingRules;\n pendingRules = [];\n\n if (ssrBuffer) {\n ssrBuffer.push(...rules);\n return;\n }\n\n if (!isBrowser) return;\n\n const el = getStyleElement();\n const sheet = el.sheet;\n\n if (sheet) {\n for (const rule of rules) {\n try {\n sheet.insertRule(rule, sheet.cssRules.length);\n } catch {\n // Fallback: append as text (handles edge cases with certain selectors)\n el.appendChild(document.createTextNode(rule));\n }\n }\n } else {\n // Sheet not available yet, append as text\n el.appendChild(document.createTextNode(rules.join('\\n')));\n }\n}\n\nfunction scheduleFlush(): void {\n if (flushScheduled) return;\n flushScheduled = true;\n\n if (ssrBuffer) {\n // In SSR mode, flush synchronously\n flush();\n return;\n }\n\n if (isBrowser) {\n // Use microtask for fast, batched insertion\n queueMicrotask(flush);\n }\n}\n\n/**\n * Insert a CSS rule. Deduplicates by rule key.\n */\nexport function insertRule(key: string, css: string): void {\n if (insertedRules.has(key)) return;\n insertedRules.add(key);\n pendingRules.push(css);\n allRules.push(css);\n scheduleFlush();\n}\n\n/**\n * Insert multiple CSS rules at once.\n */\nexport function insertRules(rules: Array<{ key: string; css: string }>): void {\n let added = false;\n for (const { key, css } of rules) {\n if (insertedRules.has(key)) continue;\n insertedRules.add(key);\n pendingRules.push(css);\n allRules.push(css);\n added = true;\n }\n if (added) scheduleFlush();\n}\n\n/**\n * Replace a CSS rule (used for HMR). Removes the old rule and inserts the new one.\n */\nexport function replaceRule(key: string, css: string): void {\n if (!isBrowser) return;\n\n insertedRules.delete(key);\n\n // Remove existing rule from the sheet if possible\n const el = getStyleElement();\n const sheet = el.sheet;\n if (sheet) {\n for (let i = sheet.cssRules.length - 1; i >= 0; i--) {\n // We can't reliably match by key in CSSOM, so for HMR we fall back to\n // clearing and re-inserting. This is fine since HMR is dev-only.\n }\n }\n\n insertRule(key, css);\n}\n\n/**\n * Start collecting CSS for SSR. Returns a function to stop collection and get the CSS.\n */\nexport function startCollection(): () => string {\n ssrBuffer = [];\n return () => {\n const css = ssrBuffer ? ssrBuffer.join('\\n') : '';\n ssrBuffer = null;\n return css;\n };\n}\n\n/**\n * Return all registered CSS as a string.\n *\n * Unlike `collectStyles`, this doesn't require wrapping a render function.\n * It simply returns every CSS rule that has been registered via\n * `styles.create`, `tokens.create`, `keyframes.create`, etc.\n *\n * Ideal for SSR frameworks that need the CSS separately from the render\n * pass (e.g. TanStack Start's `head()`, Next.js metadata, Remix links).\n *\n * @example\n * ```ts\n * import { getRegisteredCss } from 'typestyles/server';\n *\n * // In a route's head/meta function:\n * export const head = () => ({\n * styles: [{ id: 'typestyles', children: getRegisteredCss() }],\n * });\n * ```\n */\nexport function getRegisteredCss(): string {\n return allRules.join('\\n');\n}\n\n/**\n * Reset all state (useful for testing).\n */\nexport function reset(): void {\n insertedRules.clear();\n pendingRules = [];\n allRules.length = 0;\n flushScheduled = false;\n ssrBuffer = null;\n if (isBrowser && styleElement) {\n styleElement.remove();\n styleElement = null;\n }\n}\n\n/**\n * Flush all pending rules synchronously. Used for SSR and testing.\n */\nexport function flushSync(): void {\n flush();\n}\n\n/**\n * Invalidate all dedup keys that start with the given prefix.\n * Also removes matching rules from the live stylesheet.\n * Used for HMR — allows modules to re-register their styles after editing.\n */\nexport function invalidatePrefix(prefix: string): void {\n for (const key of insertedRules) {\n if (key.startsWith(prefix)) {\n insertedRules.delete(key);\n }\n }\n\n if (!isBrowser) return;\n\n const el = styleElement;\n if (!el) return;\n const sheet = el.sheet;\n if (!sheet) return;\n\n for (let i = sheet.cssRules.length - 1; i >= 0; i--) {\n const rule = sheet.cssRules[i];\n if (ruleMatchesPrefix(rule, prefix)) {\n sheet.deleteRule(i);\n }\n }\n}\n\n/**\n * Invalidate a list of exact keys or prefixes.\n * Each entry in `keys` is treated as an exact key match.\n * Each entry in `prefixes` is treated as a prefix match.\n * Used for HMR to invalidate all styles from a module at once.\n */\nexport function invalidateKeys(keys: string[], prefixes: string[]): void {\n for (const key of keys) {\n insertedRules.delete(key);\n }\n for (const prefix of prefixes) {\n for (const key of insertedRules) {\n if (key.startsWith(prefix)) {\n insertedRules.delete(key);\n }\n }\n }\n\n if (!isBrowser) return;\n\n const el = styleElement;\n if (!el) return;\n const sheet = el.sheet;\n if (!sheet) return;\n\n const keySet = new Set(keys);\n for (let i = sheet.cssRules.length - 1; i >= 0; i--) {\n const rule = sheet.cssRules[i];\n let shouldRemove = false;\n\n for (const prefix of prefixes) {\n if (ruleMatchesPrefix(rule, prefix)) {\n shouldRemove = true;\n break;\n }\n }\n\n if (!shouldRemove) {\n // Check exact key matches — for tokens/themes/keyframes,\n // we match based on rule content patterns\n const ruleText = rule.cssText;\n for (const key of keySet) {\n if (ruleMatchesKey(ruleText, key)) {\n shouldRemove = true;\n break;\n }\n }\n }\n\n if (shouldRemove) {\n sheet.deleteRule(i);\n }\n }\n}\n\nfunction ruleMatchesPrefix(rule: CSSRule, prefix: string): boolean {\n if (prefix.startsWith('font-face:')) {\n const family = prefix.slice('font-face:'.length).split(':')[0];\n // CSSFontFaceRule has type 5 and cssText contains @font-face\n if (rule.cssText.includes('@font-face')) {\n return (\n rule.cssText.includes(`\"${family}\"`) || rule.cssText.includes(`'${family}'`)\n );\n }\n return false;\n }\n if ('selectorText' in rule) {\n return (rule as CSSStyleRule).selectorText.startsWith(prefix);\n }\n if ('name' in rule && prefix.startsWith('keyframes:')) {\n return (rule as CSSKeyframesRule).name === prefix.slice('keyframes:'.length);\n }\n // For at-rules wrapping style rules, check inner rules\n if ('cssRules' in rule) {\n const innerRules = (rule as CSSGroupingRule).cssRules;\n for (let i = 0; i < innerRules.length; i++) {\n if (ruleMatchesPrefix(innerRules[i], prefix)) return true;\n }\n }\n return false;\n}\n\nfunction ruleMatchesKey(cssText: string, key: string): boolean {\n if (key.startsWith('tokens:')) {\n // tokens:color -> :root rule with --color- custom properties\n const namespace = key.slice('tokens:'.length);\n return cssText.includes(`:root`) && cssText.includes(`--${namespace}-`);\n }\n if (key.startsWith('theme:')) {\n // theme:dark -> .theme-dark selector\n const name = key.slice('theme:'.length);\n return cssText.includes(`.theme-${name}`);\n }\n if (key.startsWith('keyframes:')) {\n const name = key.slice('keyframes:'.length);\n return cssText.includes(`@keyframes ${name}`);\n }\n return false;\n}\n","/**\n * Shared registry for detecting duplicate namespace registrations.\n */\nexport const registeredNamespaces = new Set<string>();\n","import type { CSSProperties, SelectorFunction, StyleDefinitions } from './types.js';\nimport { serializeStyle } from './css.js';\nimport { insertRules } from './sheet.js';\nimport { registeredNamespaces } from './registry.js';\n\n/**\n * Create a style group and return a selector function.\n *\n * The selector function accepts variant names and returns a composed\n * class name string. Class names are deterministic and human-readable:\n * `{namespace}-{variant}`.\n *\n * @example\n * ```ts\n * const button = createStyles('button', {\n * base: { padding: '8px 16px', fontSize: '14px' },\n * primary: { backgroundColor: '#0066ff', color: '#fff' },\n * large: { padding: '12px 24px', fontSize: '16px' },\n * });\n *\n * button('base', 'primary') // \"button-base button-primary\"\n * button('base', isLarge && 'large') // conditional application\n * ```\n */\nexport function createStyles<K extends string>(\n namespace: string,\n definitions: StyleDefinitions & Record<K, CSSProperties>,\n): SelectorFunction<K> {\n // Development-mode duplicate detection\n if (process.env.NODE_ENV !== 'production') {\n if (registeredNamespaces.has(namespace)) {\n console.warn(\n `[typestyles] styles.create('${namespace}', ...) called more than once. ` +\n `This will cause class name collisions. Each namespace should be unique.`,\n );\n }\n }\n registeredNamespaces.add(namespace);\n\n // Generate and inject CSS for all variants\n const rules: Array<{ key: string; css: string }> = [];\n\n for (const [variant, properties] of Object.entries(definitions)) {\n const className = `${namespace}-${variant}`;\n const selector = `.${className}`;\n const variantRules = serializeStyle(selector, properties as CSSProperties);\n rules.push(...variantRules);\n }\n\n insertRules(rules);\n\n // Return the selector function\n const selectorFn = (...variants: (K | false | null | undefined)[]): string => {\n return variants\n .filter(Boolean)\n .map((v) => `${namespace}-${v as string}`)\n .join(' ');\n };\n\n return selectorFn as SelectorFunction<K>;\n}\n\n/**\n * Compose multiple selector functions or class strings into one.\n * Returns a new SelectorFunction that calls all inputs and joins results.\n *\n * @example\n * ```ts\n * const base = styles.create('base', { padding: '8px' });\n * const primary = styles.create('primary', { color: 'blue' });\n * const button = styles.compose(base, primary);\n *\n * button('padding', 'color'); // \"base-padding primary-color\"\n * ```\n */\ntype AnySelectorFunction = {\n (...args: any[]): string;\n};\n\nexport function compose(\n ...selectors: Array<AnySelectorFunction | string | false | null | undefined>\n): AnySelectorFunction {\n const validSelectors = selectors.filter(Boolean) as Array<AnySelectorFunction | string>;\n\n return (...args: any[]): string => {\n const classNames: string[] = [];\n\n for (const selector of validSelectors) {\n if (typeof selector === 'string') {\n classNames.push(selector);\n } else {\n const result = selector(...args);\n if (result) classNames.push(result);\n }\n }\n\n return classNames.join(' ');\n };\n}\n","import type { TokenValues, TokenRef, ThemeOverrides } from './types.js';\nimport { insertRule } from './sheet.js';\n\n/**\n * Registry tracking which token namespaces have been created,\n * so tokens.use() can provide warnings in development.\n */\nconst registeredNamespaces = new Set<string>();\n\n/**\n * Create a proxy-based token reference for a namespace.\n * Property access returns var(--{namespace}-{key}).\n */\nfunction createTokenProxy<T extends TokenValues>(namespace: string): TokenRef<T> {\n return new Proxy({} as TokenRef<T>, {\n get(_target, prop: string) {\n return `var(--${namespace}-${prop})`;\n },\n });\n}\n\n/**\n * Create design tokens as CSS custom properties.\n *\n * Generates a :root rule with the custom properties and returns\n * a typed object where property access yields var() references.\n *\n * @example\n * ```ts\n * const color = createTokens('color', {\n * primary: '#0066ff',\n * secondary: '#6b7280',\n * });\n *\n * color.primary // \"var(--color-primary)\"\n * ```\n */\nexport function createTokens<T extends TokenValues>(\n namespace: string,\n values: T\n): TokenRef<T> {\n registeredNamespaces.add(namespace);\n\n // Generate CSS custom property declarations\n const declarations = Object.entries(values)\n .map(([key, value]) => `--${namespace}-${key}: ${value}`)\n .join('; ');\n\n const css = `:root { ${declarations}; }`;\n insertRule(`tokens:${namespace}`, css);\n\n return createTokenProxy<T>(namespace);\n}\n\n/**\n * Reference tokens defined elsewhere without injecting CSS.\n *\n * Returns a typed proxy that produces var() references.\n * Useful for consuming shared tokens from a different module.\n *\n * @example\n * ```ts\n * const color = useTokens('color');\n * color.primary // \"var(--color-primary)\"\n * ```\n */\nexport function useTokens<T extends TokenValues = TokenValues>(\n namespace: string\n): TokenRef<T> {\n if (\n process.env.NODE_ENV !== 'production' &&\n registeredNamespaces.size > 0 &&\n !registeredNamespaces.has(namespace)\n ) {\n console.warn(\n `[typestyles] tokens.use('${namespace}') references a namespace that hasn't been created yet. ` +\n `Make sure tokens.create('${namespace}', ...) is called before using these tokens.`\n );\n }\n\n return createTokenProxy<T>(namespace);\n}\n\n/**\n * Create a theme class that overrides token values.\n *\n * Returns a class name string. Apply it to any element to override\n * token values for that subtree via CSS custom property cascading.\n *\n * @example\n * ```ts\n * const dark = createTheme('dark', {\n * color: { primary: '#66b3ff', surface: '#1a1a2e' },\n * });\n *\n * <div className={dark}> // class=\"theme-dark\"\n * ```\n */\nexport function createTheme(name: string, overrides: ThemeOverrides): string {\n const className = `theme-${name}`;\n\n const declarations: string[] = [];\n for (const [namespace, values] of Object.entries(overrides)) {\n for (const [key, value] of Object.entries(values)) {\n if (value != null) {\n declarations.push(`--${namespace}-${key}: ${value}`);\n }\n }\n }\n\n const css = `.${className} { ${declarations.join('; ')}; }`;\n insertRule(`theme:${name}`, css);\n\n return className;\n}\n","import type { CSSProperties } from './types.js';\nimport { toKebabCase } from './css.js';\nimport { insertRule } from './sheet.js';\n\n/**\n * A keyframe stop is either 'from', 'to', or a percentage like '50%'.\n */\nexport type KeyframeStops = Record<string, CSSProperties>;\n\n/**\n * Serialize CSS declarations for a single keyframe stop (no nesting/at-rules).\n */\nfunction serializeDeclarations(properties: CSSProperties): string {\n const declarations: string[] = [];\n\n for (const [prop, value] of Object.entries(properties)) {\n if (value == null) continue;\n // Keyframe stops only contain plain properties — skip nested selectors/at-rules\n if (prop.startsWith('&') || prop.startsWith('@')) continue;\n\n const kebabProp = toKebabCase(prop);\n const serialized =\n typeof value === 'number' ? (value === 0 ? '0' : value + 'px') : value;\n declarations.push(`${kebabProp}: ${serialized}`);\n }\n\n return declarations.join('; ');\n}\n\n/**\n * Create a CSS @keyframes animation and return its name.\n *\n * The returned string is the animation name — use it directly in\n * `animation` shorthand or `animationName`.\n *\n * @example\n * ```ts\n * const fadeIn = keyframes.create('fadeIn', {\n * from: { opacity: 0 },\n * to: { opacity: 1 },\n * });\n *\n * const card = styles.create('card', {\n * base: { animation: `${fadeIn} 300ms ease` },\n * });\n * ```\n *\n * @example\n * ```ts\n * const bounce = keyframes.create('bounce', {\n * '0%': { transform: 'translateY(0)' },\n * '50%': { transform: 'translateY(-20px)' },\n * '100%': { transform: 'translateY(0)' },\n * });\n * ```\n */\nexport function createKeyframes(name: string, stops: KeyframeStops): string {\n const stopsCSS = Object.entries(stops)\n .map(([stop, properties]) => {\n const decls = serializeDeclarations(properties as CSSProperties);\n return `${stop} { ${decls}; }`;\n })\n .join(' ');\n\n const css = `@keyframes ${name} { ${stopsCSS} }`;\n insertRule(`keyframes:${name}`, css);\n\n return name;\n}\n","/**\n * Type-safe helpers for CSS color functions.\n *\n * Each function returns a plain CSS string — no runtime color math.\n * Works naturally with token references since tokens are strings too.\n */\n\ntype ColorValue = string | number;\n\n/** Color spaces supported by color-mix(). */\nexport type ColorMixSpace =\n | 'srgb'\n | 'srgb-linear'\n | 'display-p3'\n | 'a98-rgb'\n | 'prophoto-rgb'\n | 'rec2020'\n | 'lab'\n | 'oklab'\n | 'xyz'\n | 'xyz-d50'\n | 'xyz-d65'\n | 'hsl'\n | 'hwb'\n | 'lch'\n | 'oklch';\n\n/**\n * `rgb(r g b)` or `rgb(r g b / a)`\n *\n * @example\n * ```ts\n * color.rgb(0, 102, 255) // \"rgb(0 102 255)\"\n * color.rgb(0, 102, 255, 0.5) // \"rgb(0 102 255 / 0.5)\"\n * ```\n */\nexport function rgb(r: ColorValue, g: ColorValue, b: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `rgb(${r} ${g} ${b} / ${alpha})`;\n return `rgb(${r} ${g} ${b})`;\n}\n\n/**\n * `hsl(h s l)` or `hsl(h s l / a)`\n *\n * @example\n * ```ts\n * color.hsl(220, '100%', '50%') // \"hsl(220 100% 50%)\"\n * color.hsl(220, '100%', '50%', 0.8) // \"hsl(220 100% 50% / 0.8)\"\n * ```\n */\nexport function hsl(h: ColorValue, s: ColorValue, l: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `hsl(${h} ${s} ${l} / ${alpha})`;\n return `hsl(${h} ${s} ${l})`;\n}\n\n/**\n * `oklch(L C h)` or `oklch(L C h / a)`\n *\n * @example\n * ```ts\n * color.oklch(0.7, 0.15, 250) // \"oklch(0.7 0.15 250)\"\n * color.oklch(0.7, 0.15, 250, 0.5) // \"oklch(0.7 0.15 250 / 0.5)\"\n * ```\n */\nexport function oklch(l: ColorValue, c: ColorValue, h: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `oklch(${l} ${c} ${h} / ${alpha})`;\n return `oklch(${l} ${c} ${h})`;\n}\n\n/**\n * `oklab(L a b)` or `oklab(L a b / alpha)`\n *\n * @example\n * ```ts\n * color.oklab(0.7, -0.1, -0.1) // \"oklab(0.7 -0.1 -0.1)\"\n * color.oklab(0.7, -0.1, -0.1, 0.5) // \"oklab(0.7 -0.1 -0.1 / 0.5)\"\n * ```\n */\nexport function oklab(l: ColorValue, a: ColorValue, b: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `oklab(${l} ${a} ${b} / ${alpha})`;\n return `oklab(${l} ${a} ${b})`;\n}\n\n/**\n * `lab(L a b)` or `lab(L a b / alpha)`\n *\n * @example\n * ```ts\n * color.lab('50%', 40, -20) // \"lab(50% 40 -20)\"\n * ```\n */\nexport function lab(l: ColorValue, a: ColorValue, b: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `lab(${l} ${a} ${b} / ${alpha})`;\n return `lab(${l} ${a} ${b})`;\n}\n\n/**\n * `lch(L C h)` or `lch(L C h / alpha)`\n *\n * @example\n * ```ts\n * color.lch('50%', 80, 250) // \"lch(50% 80 250)\"\n * ```\n */\nexport function lch(l: ColorValue, c: ColorValue, h: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `lch(${l} ${c} ${h} / ${alpha})`;\n return `lch(${l} ${c} ${h})`;\n}\n\n/**\n * `hwb(h w b)` or `hwb(h w b / alpha)`\n *\n * @example\n * ```ts\n * color.hwb(220, '10%', '0%') // \"hwb(220 10% 0%)\"\n * ```\n */\nexport function hwb(h: ColorValue, w: ColorValue, b: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `hwb(${h} ${w} ${b} / ${alpha})`;\n return `hwb(${h} ${w} ${b})`;\n}\n\n/**\n * `color-mix(in colorspace, color1 p1%, color2 p2%)`\n *\n * Mixes two colors in the given color space. Percentages are optional.\n *\n * @example\n * ```ts\n * color.mix('red', 'blue') // \"color-mix(in srgb, red, blue)\"\n * color.mix('red', 'blue', 30) // \"color-mix(in srgb, red 30%, blue)\"\n * color.mix(theme.primary, 'white', 20) // \"color-mix(in srgb, var(--theme-primary) 20%, white)\"\n * color.mix('red', 'blue', 50, 'oklch') // \"color-mix(in oklch, red 50%, blue)\"\n * ```\n */\nexport function mix(\n color1: string,\n color2: string,\n percentage?: number,\n colorSpace: ColorMixSpace = 'srgb'\n): string {\n const c1 = percentage != null ? `${color1} ${percentage}%` : color1;\n return `color-mix(in ${colorSpace}, ${c1}, ${color2})`;\n}\n\n/**\n * `light-dark(lightColor, darkColor)`\n *\n * Uses the `light-dark()` CSS function that resolves based on\n * the computed `color-scheme` of the element.\n *\n * @example\n * ```ts\n * color.lightDark('#111', '#eee') // \"light-dark(#111, #eee)\"\n * color.lightDark(theme.textLight, theme.textDark) // \"light-dark(var(--theme-textLight), var(--theme-textDark))\"\n * ```\n */\nexport function lightDark(lightColor: string, darkColor: string): string {\n return `light-dark(${lightColor}, ${darkColor})`;\n}\n\n/**\n * Adjust the alpha/opacity of any color using `color-mix()`.\n *\n * This is a common pattern: mixing a color with transparent to change opacity.\n * Works with any color value including token references.\n *\n * @example\n * ```ts\n * color.alpha('red', 0.5) // \"color-mix(in srgb, red 50%, transparent)\"\n * color.alpha(theme.primary, 0.2) // \"color-mix(in srgb, var(--theme-primary) 20%, transparent)\"\n * color.alpha('#0066ff', 0.8, 'oklch') // \"color-mix(in oklch, #0066ff 80%, transparent)\"\n * ```\n */\nexport function alpha(\n colorValue: string,\n opacity: number,\n colorSpace: ColorMixSpace = 'srgb'\n): string {\n const percentage = Math.round(opacity * 100);\n return `color-mix(in ${colorSpace}, ${colorValue} ${percentage}%, transparent)`;\n}\n","import type { CSSProperties, VariantDefinitions, ComponentConfig, ComponentFunction } from './types.js';\nimport { serializeStyle } from './css.js';\nimport { insertRules } from './sheet.js';\nimport { registeredNamespaces } from './registry.js';\n\n/**\n * Create a multi-variant component style and return a selector function.\n *\n * Class naming convention:\n * base → `{namespace}-base`\n * variants.intent.primary → `{namespace}-intent-primary`\n * compoundVariants[0] → `{namespace}-compound-0`\n *\n * @example\n * ```ts\n * const button = styles.component('button', {\n * base: { padding: '8px 16px' },\n * variants: {\n * intent: {\n * primary: { backgroundColor: '#0066ff', color: '#fff' },\n * ghost: { backgroundColor: 'transparent', border: '1px solid currentColor' },\n * },\n * size: {\n * sm: { fontSize: '12px' },\n * lg: { fontSize: '18px' },\n * },\n * },\n * compoundVariants: [\n * { variants: { intent: 'primary', size: 'lg' }, style: { fontWeight: 700 } },\n * ],\n * defaultVariants: { intent: 'primary', size: 'sm' },\n * });\n *\n * button() // \"button-base button-intent-primary button-size-sm\"\n * button({ intent: 'ghost' }) // \"button-base button-intent-ghost button-size-sm\"\n * button({ intent: 'primary', size: 'lg' }) // includes compound class\n * ```\n */\nexport function createComponent<V extends VariantDefinitions>(\n namespace: string,\n config: ComponentConfig<V>\n): ComponentFunction<V> {\n const { base, variants = {} as V, compoundVariants = [], defaultVariants = {} } = config;\n\n // Development-mode duplicate detection\n if (process.env.NODE_ENV !== 'production') {\n if (registeredNamespaces.has(namespace)) {\n console.warn(\n `[typestyles] styles.component('${namespace}', ...) called more than once. ` +\n `This will cause class name collisions. Each namespace should be unique.`\n );\n }\n }\n registeredNamespaces.add(namespace);\n\n const rules: Array<{ key: string; css: string }> = [];\n\n // 1. Inject CSS for base\n if (base) {\n rules.push(...serializeStyle(`.${namespace}-base`, base));\n }\n\n // 2. Inject CSS for each variant option\n for (const [dimension, options] of Object.entries(variants)) {\n for (const [option, properties] of Object.entries(options as Record<string, CSSProperties>)) {\n const className = `.${namespace}-${dimension}-${option}`;\n rules.push(...serializeStyle(className, properties));\n }\n }\n\n // 3. Inject CSS for each compound variant\n (compoundVariants as Array<{ variants: Record<string, unknown>; style: CSSProperties }>).forEach(\n (cv, index) => {\n const className = `.${namespace}-compound-${index}`;\n rules.push(...serializeStyle(className, cv.style));\n }\n );\n\n insertRules(rules);\n\n // 4. Return the selector function\n return ((selections: Record<string, unknown> = {}) => {\n const classes: string[] = [];\n\n if (base) classes.push(`${namespace}-base`);\n\n // Resolve final selections (explicit overrides defaultVariants)\n const resolvedSelections: Record<string, unknown> = {};\n for (const dimension of Object.keys(variants)) {\n resolvedSelections[dimension] =\n selections[dimension] ?? (defaultVariants as Record<string, unknown>)[dimension];\n }\n\n // Apply variant classes\n for (const dimension of Object.keys(variants)) {\n const selected = resolvedSelections[dimension];\n if (selected != null && selected !== false) {\n classes.push(`${namespace}-${dimension}-${String(selected)}`);\n }\n }\n\n // Apply compound variant classes\n (compoundVariants as Array<{ variants: Record<string, unknown>; style: CSSProperties }>).forEach(\n (cv, index) => {\n const matches = Object.entries(cv.variants).every(\n ([k, v]) => resolvedSelections[k] === v\n );\n if (matches) classes.push(`${namespace}-compound-${index}`);\n }\n );\n\n return classes.join(' ');\n }) as ComponentFunction<V>;\n}\n","import type { CSSProperties, FontFaceProps } from './types.js';\nimport { serializeStyle } from './css.js';\nimport { insertRule, insertRules } from './sheet.js';\n\n/**\n * Apply styles to an arbitrary CSS selector.\n *\n * Use for CSS resets, body/root defaults, third-party elements, or any\n * selector that isn't tied to a specific component class.\n *\n * @example\n * ```ts\n * global.style('body', { margin: 0, fontFamily: 'sans-serif' });\n * global.style('a:hover', { textDecoration: 'underline' });\n * global.style('*, *::before, *::after', { boxSizing: 'border-box' });\n * ```\n */\nexport function globalStyle(selector: string, properties: CSSProperties): void {\n const rules = serializeStyle(selector, properties);\n insertRules(rules);\n}\n\n/**\n * Declare a `@font-face` rule to load a custom font.\n *\n * Multiple weights/styles of the same family can be registered by calling\n * this function multiple times with different `src` values — each call is\n * deduplicated by `family + src`.\n *\n * @example\n * ```ts\n * global.fontFace('Inter', {\n * src: \"url('/fonts/Inter-Regular.woff2') format('woff2')\",\n * fontWeight: 400,\n * fontStyle: 'normal',\n * fontDisplay: 'swap',\n * });\n *\n * global.fontFace('Inter', {\n * src: \"url('/fonts/Inter-Bold.woff2') format('woff2')\",\n * fontWeight: 700,\n * fontStyle: 'normal',\n * fontDisplay: 'swap',\n * });\n * ```\n */\nexport function globalFontFace(family: string, props: FontFaceProps): void {\n const decls: string[] = [`font-family: \"${family}\"`, `src: ${props.src}`];\n if (props.fontWeight != null) decls.push(`font-weight: ${props.fontWeight}`);\n if (props.fontStyle) decls.push(`font-style: ${props.fontStyle}`);\n if (props.fontDisplay) decls.push(`font-display: ${props.fontDisplay}`);\n if (props.fontStretch) decls.push(`font-stretch: ${props.fontStretch}`);\n if (props.unicodeRange) decls.push(`unicode-range: ${props.unicodeRange}`);\n const css = `@font-face { ${decls.join('; ')}; }`;\n // Key includes src for uniqueness (multiple weights per family)\n insertRule(`font-face:${family}:${props.src}`, css);\n}\n","import type { CSSVarRef } from './types.js';\n\nlet counter = 0;\n\n/** Reset the counter. Used in tests only. */\nexport function __resetVarCounter(): void {\n counter = 0;\n}\n\n/**\n * Create a unique CSS custom property reference.\n *\n * Returns a `var(--ts-N)` string that can be used anywhere a CSS value is\n * accepted. Use assignVars() to set its value per element via inline styles.\n *\n * @example\n * ```ts\n * const cardBg = createVar();\n *\n * const card = styles.create('card', {\n * base: { background: cardBg, padding: '16px' },\n * });\n *\n * // Consumer sets the variable per instance:\n * <div className={card('base')} style={assignVars({ [cardBg]: '#ff0099' })} />\n * ```\n */\nexport function createVar(): CSSVarRef {\n const name = `--ts-${++counter}`;\n return `var(${name})` as CSSVarRef;\n}\n\n/**\n * Build a CSS custom property assignment map from var refs to values.\n *\n * The returned object is safe to spread into a React (or any framework)\n * inline `style` prop.\n *\n * @example\n * ```ts\n * assignVars({ [cardBg]: '#ff0099' })\n * // → { '--ts-1': '#ff0099' }\n * ```\n */\nexport function assignVars(\n vars: Partial<Record<CSSVarRef, string>>\n): Record<string, string> {\n const result: Record<string, string> = {};\n for (const [varRef, value] of Object.entries(vars)) {\n if (value == null) continue;\n // Strip \"var(\" prefix and \")\" suffix to get the raw property name\n const match = varRef.match(/^var\\((--[^)]+)\\)$/);\n if (match) result[match[1]] = value;\n }\n return result;\n}\n","import { createStyles, compose } from './styles.js';\nimport { createTokens, useTokens, createTheme } from './tokens.js';\nimport { createKeyframes } from './keyframes.js';\nimport * as colorFns from './color.js';\nimport { getRegisteredCss, insertRules, reset, flushSync } from './sheet.js';\nimport { createComponent } from './component.js';\nimport { globalStyle, globalFontFace } from './global.js';\nimport { createVar, assignVars } from './vars.js';\n\nexport type {\n CSSProperties,\n CSSValue,\n StyleDefinitions,\n SelectorFunction,\n TokenValues,\n TokenRef,\n ThemeOverrides,\n KeyframeStops,\n VariantDefinitions,\n ComponentConfig,\n ComponentFunction,\n FontFaceProps,\n CSSVarRef,\n RecipeVariants,\n} from './types.js';\n\nexport { createVar, assignVars };\n\nexport type { ColorMixSpace } from './color.js';\n\n/**\n * Style creation API.\n *\n * @example\n * ```ts\n * const button = styles.create('button', {\n * base: { padding: '8px 16px' },\n * primary: { backgroundColor: '#0066ff' },\n * });\n *\n * <button className={button('base', 'primary')}>\n * ```\n */\nexport const styles = {\n create: createStyles,\n component: createComponent,\n compose,\n} as const;\n\n/**\n * Global CSS API for arbitrary selectors and font-face declarations.\n *\n * @example\n * ```ts\n * global.style('body', { margin: 0 });\n * global.fontFace('Inter', { src: \"url('/Inter.woff2') format('woff2')\", fontWeight: 400 });\n * ```\n */\nexport const global = {\n style: globalStyle,\n fontFace: globalFontFace,\n} as const;\n\n/**\n * Design token API using CSS custom properties.\n *\n * @example\n * ```ts\n * const color = tokens.create('color', {\n * primary: '#0066ff',\n * });\n *\n * color.primary // \"var(--color-primary)\"\n * ```\n */\nexport const tokens = {\n create: createTokens,\n use: useTokens,\n createTheme,\n} as const;\n\n/**\n * Keyframe animation API.\n *\n * @example\n * ```ts\n * const fadeIn = keyframes.create('fadeIn', {\n * from: { opacity: 0 },\n * to: { opacity: 1 },\n * });\n *\n * const card = styles.create('card', {\n * base: { animation: `${fadeIn} 300ms ease` },\n * });\n * ```\n */\nexport const keyframes = {\n create: createKeyframes,\n} as const;\n\n/**\n * Type-safe CSS color function helpers.\n *\n * Each function returns a plain CSS color string — no runtime color math.\n * Composes naturally with token references.\n *\n * @example\n * ```ts\n * color.rgb(0, 102, 255) // \"rgb(0 102 255)\"\n * color.oklch(0.7, 0.15, 250) // \"oklch(0.7 0.15 250)\"\n * color.mix(theme.primary, 'white', 20) // \"color-mix(in srgb, var(--theme-primary) 20%, white)\"\n * color.alpha(theme.primary, 0.5) // \"color-mix(in srgb, var(--theme-primary) 50%, transparent)\"\n * color.lightDark('#111', '#eee') // \"light-dark(#111, #eee)\"\n * ```\n */\nexport const color = colorFns;\n\n/**\n * Return all registered CSS as a string (for SSR).\n *\n * Returns every CSS rule registered via `styles.create`, `tokens.create`,\n * `keyframes.create`, etc. Use this in your SSR head/meta function to\n * inject styles into the document.\n *\n * This is safe to import on the client — it has no server-specific\n * dependencies and will simply return whatever CSS has been registered.\n *\n * @example\n * ```ts\n * import { getRegisteredCss } from 'typestyles';\n *\n * // In a route's head function (e.g. TanStack Start):\n * export const Route = createRootRoute({\n * head: () => ({\n * styles: [{ id: 'typestyles', children: getRegisteredCss() }],\n * }),\n * });\n * ```\n */\nexport { getRegisteredCss };\n\n/**\n * Insert multiple CSS rules into the stylesheet.\n *\n * This is a low-level API used internally by typestyles and by packages\n * like @typestyles/props. You typically won't need to use this directly.\n *\n * @example\n * ```ts\n * import { insertRules } from 'typestyles';\n *\n * insertRules([\n * { key: '.my-class', css: '.my-class { color: red; }' },\n * { key: '.another', css: '.another { padding: 8px; }' },\n * ]);\n * ```\n */\nexport { insertRules };\n\n/**\n * Testing utilities for clearing the stylesheet and flushing pending rules.\n * These are primarily intended for use in tests.\n *\n * @example\n * ```ts\n * import { reset, flushSync } from 'typestyles';\n *\n * // In a test beforeEach:\n * beforeEach(() => {\n * reset(); // Clear all registered CSS\n * });\n *\n * // To synchronously flush pending rules:\n * flushSync();\n * ```\n */\nexport { reset, flushSync };\n"]}
1
+ {"version":3,"sources":["../src/css.ts","../src/sheet.ts","../src/registry.ts","../src/class-naming.ts","../src/styles.ts","../src/tokens.ts","../src/keyframes.ts","../src/color.ts","../src/component.ts","../src/global.ts","../src/vars.ts","../src/index.ts"],"names":["current","variants","registeredNamespaces","alpha"],"mappings":";;;;;;;;;AAMO,SAAS,YAAY,IAAA,EAAsB;AAEhD,EAAA,IAAI,IAAA,CAAK,UAAA,CAAW,IAAI,CAAA,EAAG;AACzB,IAAA,OAAO,GAAA,GAAM,KAAK,OAAA,CAAQ,QAAA,EAAU,CAAC,CAAA,KAAM,GAAA,GAAM,CAAA,CAAE,WAAA,EAAa,CAAA;AAAA,EAClE;AACA,EAAA,OAAO,IAAA,CAAK,QAAQ,QAAA,EAAU,CAAC,MAAM,GAAA,GAAM,CAAA,CAAE,aAAa,CAAA;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AAA;AAAA,EACR,KAAA,EAAO,WAAA;AAAA,EACP,SAAA,EAAW,eAAA;AAAA,EACX,SAAA,EAAW,eAAA;AAAA,EACX,SAAA,EAAW,qBAAA;AAAA,EACX;AACF;AAWO,IAAM,MAAA,GAAS;AAAA,EACpB,KAAA,EAAO,WAAA;AAAA,EACP,QAAA,EAAU;AACZ;AAcO,IAAM,MAAA,GAAS;AAAA,EACpB,MAAA,EAAQ,YAAA;AAAA,EACR,GAAA,EAAK,SAAA;AAAA,EACL;AACF;AAiBO,IAAM,SAAA,GAAY;AAAA,EACvB,MAAA,EAAQ;AACV;AAiBO,IAAM,KAAA,GAAQ","file":"index.cjs","sourcesContent":["import type { CSSProperties } from './types.js';\n\n/**\n * Convert a camelCase CSS property name to kebab-case.\n * Handles vendor prefixes (ms, webkit, moz) correctly.\n */\nexport function toKebabCase(prop: string): string {\n // Handle ms- prefix specially (no leading dash in camelCase)\n if (prop.startsWith('ms')) {\n return '-' + prop.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n }\n return prop.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n}\n\n/**\n * Serialize a single CSS value. Numbers are treated as px for most properties.\n */\nfunction serializeValue(prop: string, value: string | number): string {\n if (typeof value === 'number') {\n if (value === 0) return '0';\n // Unitless properties that shouldn't get 'px'\n if (unitlessProperties.has(prop)) return String(value);\n return value + 'px';\n }\n return value;\n}\n\nconst unitlessProperties = new Set([\n 'animationIterationCount',\n 'borderImageOutset',\n 'borderImageSlice',\n 'borderImageWidth',\n 'columnCount',\n 'columns',\n 'flex',\n 'flexGrow',\n 'flexPositive',\n 'flexShrink',\n 'flexNegative',\n 'flexOrder',\n 'fontWeight',\n 'gridArea',\n 'gridColumn',\n 'gridColumnEnd',\n 'gridColumnSpan',\n 'gridColumnStart',\n 'gridRow',\n 'gridRowEnd',\n 'gridRowSpan',\n 'gridRowStart',\n 'lineClamp',\n 'lineHeight',\n 'opacity',\n 'order',\n 'orphans',\n 'tabSize',\n 'widows',\n 'zIndex',\n 'zoom',\n 'fillOpacity',\n 'floodOpacity',\n 'stopOpacity',\n 'strokeDasharray',\n 'strokeDashoffset',\n 'strokeMiterlimit',\n 'strokeOpacity',\n 'strokeWidth',\n]);\n\n/**\n * Represents a generated CSS rule.\n */\nexport interface CSSRule {\n /** Unique key for deduplication */\n key: string;\n /** The CSS rule string */\n css: string;\n}\n\n/**\n * Serialize a style definition object into CSS rule(s) for a given selector.\n */\nexport function serializeStyle(selector: string, properties: CSSProperties): CSSRule[] {\n const rules: CSSRule[] = [];\n const declarations: string[] = [];\n\n for (const [prop, value] of Object.entries(properties)) {\n if (value == null) continue;\n\n const nestedSelector = resolveNestedSelector(selector, prop);\n if (nestedSelector) {\n rules.push(...serializeStyle(nestedSelector, value as CSSProperties));\n } else if (prop.startsWith('@')) {\n // At-rule: wrap the serialized content in the at-rule\n const innerRules = serializeStyle(selector, value as CSSProperties);\n for (const inner of innerRules) {\n rules.push({\n key: `${prop}:${inner.key}`,\n css: `${prop} { ${inner.css} }`,\n });\n }\n } else {\n // Regular CSS property\n const kebabProp = toKebabCase(prop);\n declarations.push(`${kebabProp}: ${serializeValue(prop, value as string | number)}`);\n }\n }\n\n // Add the base rule with all plain declarations\n if (declarations.length > 0) {\n rules.unshift({\n key: selector,\n css: `${selector} { ${declarations.join('; ')}; }`,\n });\n }\n\n return rules;\n}\n\nfunction resolveNestedSelector(parentSelector: string, key: string): string | null {\n if (key.startsWith('&')) {\n return key.replace(/&/g, parentSelector);\n }\n\n // Support attribute selectors without requiring \"&\", including selector lists:\n // '[data-state=\"open\"], [aria-expanded=\"true\"]'\n if (key.startsWith('[')) {\n const parts = splitSelectorList(key);\n return parts.map((part) => `${parentSelector}${part.trimStart()}`).join(', ');\n }\n\n return null;\n}\n\nfunction splitSelectorList(selector: string): string[] {\n const result: string[] = [];\n let current = '';\n let bracketDepth = 0;\n let parenDepth = 0;\n let quote: '\"' | \"'\" | null = null;\n\n for (let i = 0; i < selector.length; i++) {\n const char = selector[i];\n const prev = i > 0 ? selector[i - 1] : '';\n\n if (quote) {\n current += char;\n if (char === quote && prev !== '\\\\') {\n quote = null;\n }\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n quote = char;\n current += char;\n continue;\n }\n\n if (char === '[') bracketDepth++;\n if (char === ']') bracketDepth = Math.max(0, bracketDepth - 1);\n if (char === '(') parenDepth++;\n if (char === ')') parenDepth = Math.max(0, parenDepth - 1);\n\n if (char === ',' && bracketDepth === 0 && parenDepth === 0) {\n result.push(current.trim());\n current = '';\n continue;\n }\n\n current += char;\n }\n\n if (current.trim()) {\n result.push(current.trim());\n }\n\n return result;\n}\n","const STYLE_ELEMENT_ID = 'typestyles';\n\n/**\n * Tracks which CSS rules have been inserted to avoid duplicates.\n */\nconst insertedRules = new Set<string>();\n\n/**\n * Whether runtime DOM insertion is disabled (for build-time/zero-runtime mode).\n * The Vite plugin (mode: 'build') defines __TYPESTYLES_RUNTIME_DISABLED__ as the\n * string \"true\" at build time, so this is true in production and no <style> is created.\n */\ndeclare const __TYPESTYLES_RUNTIME_DISABLED__: string | undefined;\nconst RUNTIME_DISABLED =\n typeof __TYPESTYLES_RUNTIME_DISABLED__ !== 'undefined' &&\n __TYPESTYLES_RUNTIME_DISABLED__ === 'true';\n\n/**\n * Buffer of CSS rules waiting to be flushed.\n */\nlet pendingRules: string[] = [];\n\n/**\n * All CSS rules ever registered (for SSR extraction).\n * Unlike pendingRules (which is cleared on flush), this retains every rule\n * so getRegisteredCss() can return the full stylesheet at any point.\n */\nconst allRules: string[] = [];\n\n/**\n * Whether a flush is scheduled.\n */\nlet flushScheduled = false;\n\n/**\n * The managed <style> element, lazily created.\n */\nlet styleElement: HTMLStyleElement | null = null;\n\n/**\n * When in SSR collection mode, CSS is captured here instead of injected.\n */\nlet ssrBuffer: string[] | null = null;\n\n/**\n * Whether we're running in a browser environment.\n */\nconst isBrowser =\n typeof document !== 'undefined' && typeof window !== 'undefined';\n\nfunction getStyleElement(): HTMLStyleElement {\n if (styleElement) return styleElement;\n\n // Check for an existing element (e.g., from SSR)\n const existing = document.getElementById(\n STYLE_ELEMENT_ID\n ) as HTMLStyleElement | null;\n if (existing) {\n styleElement = existing;\n return styleElement;\n }\n\n // Create a new one\n styleElement = document.createElement('style');\n styleElement.id = STYLE_ELEMENT_ID;\n document.head.appendChild(styleElement);\n return styleElement;\n}\n\nfunction flush(): void {\n flushScheduled = false;\n if (pendingRules.length === 0) return;\n\n const rules = pendingRules;\n pendingRules = [];\n\n if (ssrBuffer) {\n ssrBuffer.push(...rules);\n return;\n }\n\n if (!isBrowser || RUNTIME_DISABLED) return;\n\n const el = getStyleElement();\n const sheet = el.sheet;\n\n if (sheet) {\n for (const rule of rules) {\n try {\n sheet.insertRule(rule, sheet.cssRules.length);\n } catch {\n // Fallback: append as text (handles edge cases with certain selectors)\n el.appendChild(document.createTextNode(rule));\n }\n }\n } else {\n // Sheet not available yet, append as text\n el.appendChild(document.createTextNode(rules.join('\\n')));\n }\n}\n\nfunction scheduleFlush(): void {\n if (flushScheduled) return;\n flushScheduled = true;\n\n if (ssrBuffer) {\n // In SSR mode, flush synchronously\n flush();\n return;\n }\n\n if (isBrowser && !RUNTIME_DISABLED) {\n // Use microtask for fast, batched insertion\n queueMicrotask(flush);\n }\n}\n\n/**\n * Insert a CSS rule. Deduplicates by rule key.\n */\nexport function insertRule(key: string, css: string): void {\n if (insertedRules.has(key)) return;\n insertedRules.add(key);\n allRules.push(css);\n if (RUNTIME_DISABLED && !ssrBuffer) return;\n pendingRules.push(css);\n scheduleFlush();\n}\n\n/**\n * Insert multiple CSS rules at once.\n */\nexport function insertRules(rules: Array<{ key: string; css: string }>): void {\n let added = false;\n for (const { key, css } of rules) {\n if (insertedRules.has(key)) continue;\n insertedRules.add(key);\n allRules.push(css);\n if (!RUNTIME_DISABLED || ssrBuffer) {\n pendingRules.push(css);\n added = true;\n }\n }\n if (added) scheduleFlush();\n}\n\n/**\n * Replace a CSS rule (used for HMR). Removes the old rule and inserts the new one.\n */\nexport function replaceRule(key: string, css: string): void {\n if (!isBrowser || RUNTIME_DISABLED) return;\n\n insertedRules.delete(key);\n\n // Remove existing rule from the sheet if possible\n const el = getStyleElement();\n const sheet = el.sheet;\n if (sheet) {\n for (let i = sheet.cssRules.length - 1; i >= 0; i--) {\n // We can't reliably match by key in CSSOM, so for HMR we fall back to\n // clearing and re-inserting. This is fine since HMR is dev-only.\n }\n }\n\n insertRule(key, css);\n}\n\n/**\n * Start collecting CSS for SSR. Returns a function to stop collection and get the CSS.\n */\nexport function startCollection(): () => string {\n ssrBuffer = [];\n return () => {\n const css = ssrBuffer ? ssrBuffer.join('\\n') : '';\n ssrBuffer = null;\n return css;\n };\n}\n\n/**\n * Return all registered CSS as a string.\n *\n * Unlike `collectStyles`, this doesn't require wrapping a render function.\n * It simply returns every CSS rule that has been registered via\n * `styles.create`, `tokens.create`, `keyframes.create`, etc.\n *\n * Ideal for SSR frameworks that need the CSS separately from the render\n * pass (e.g. TanStack Start's `head()`, Next.js metadata, Remix links).\n *\n * @example\n * ```ts\n * import { getRegisteredCss } from 'typestyles/server';\n *\n * // In a route's head/meta function:\n * export const head = () => ({\n * styles: [{ id: 'typestyles', children: getRegisteredCss() }],\n * });\n * ```\n */\nexport function getRegisteredCss(): string {\n return allRules.join('\\n');\n}\n\n/**\n * Reset all state (useful for testing).\n */\nexport function reset(): void {\n insertedRules.clear();\n pendingRules = [];\n allRules.length = 0;\n flushScheduled = false;\n ssrBuffer = null;\n if (isBrowser && styleElement) {\n styleElement.remove();\n styleElement = null;\n }\n}\n\n/**\n * Flush all pending rules synchronously. Used for SSR and testing.\n */\nexport function flushSync(): void {\n flush();\n}\n\n/**\n * Invalidate all dedup keys that start with the given prefix.\n * Also removes matching rules from the live stylesheet.\n * Used for HMR — allows modules to re-register their styles after editing.\n */\nexport function invalidatePrefix(prefix: string): void {\n for (const key of insertedRules) {\n if (key.startsWith(prefix)) {\n insertedRules.delete(key);\n }\n }\n\n if (!isBrowser) return;\n\n const el = styleElement;\n if (!el) return;\n const sheet = el.sheet;\n if (!sheet) return;\n\n for (let i = sheet.cssRules.length - 1; i >= 0; i--) {\n const rule = sheet.cssRules[i];\n if (ruleMatchesPrefix(rule, prefix)) {\n sheet.deleteRule(i);\n }\n }\n}\n\n/**\n * Invalidate a list of exact keys or prefixes.\n * Each entry in `keys` is treated as an exact key match.\n * Each entry in `prefixes` is treated as a prefix match.\n * Used for HMR to invalidate all styles from a module at once.\n */\nexport function invalidateKeys(keys: string[], prefixes: string[]): void {\n for (const key of keys) {\n insertedRules.delete(key);\n }\n for (const prefix of prefixes) {\n for (const key of insertedRules) {\n if (key.startsWith(prefix)) {\n insertedRules.delete(key);\n }\n }\n }\n\n if (!isBrowser) return;\n\n const el = styleElement;\n if (!el) return;\n const sheet = el.sheet;\n if (!sheet) return;\n\n const keySet = new Set(keys);\n for (let i = sheet.cssRules.length - 1; i >= 0; i--) {\n const rule = sheet.cssRules[i];\n let shouldRemove = false;\n\n for (const prefix of prefixes) {\n if (ruleMatchesPrefix(rule, prefix)) {\n shouldRemove = true;\n break;\n }\n }\n\n if (!shouldRemove) {\n // Check exact key matches — for tokens/themes/keyframes,\n // we match based on rule content patterns\n const ruleText = rule.cssText;\n for (const key of keySet) {\n if (ruleMatchesKey(ruleText, key)) {\n shouldRemove = true;\n break;\n }\n }\n }\n\n if (shouldRemove) {\n sheet.deleteRule(i);\n }\n }\n}\n\nfunction ruleMatchesPrefix(rule: CSSRule, prefix: string): boolean {\n if (prefix.startsWith('font-face:')) {\n const family = prefix.slice('font-face:'.length).split(':')[0];\n // CSSFontFaceRule has type 5 and cssText contains @font-face\n if (rule.cssText.includes('@font-face')) {\n return (\n rule.cssText.includes(`\"${family}\"`) || rule.cssText.includes(`'${family}'`)\n );\n }\n return false;\n }\n if ('selectorText' in rule) {\n return (rule as CSSStyleRule).selectorText.startsWith(prefix);\n }\n if ('name' in rule && prefix.startsWith('keyframes:')) {\n return (rule as CSSKeyframesRule).name === prefix.slice('keyframes:'.length);\n }\n // For at-rules wrapping style rules, check inner rules\n if ('cssRules' in rule) {\n const innerRules = (rule as CSSGroupingRule).cssRules;\n for (let i = 0; i < innerRules.length; i++) {\n if (ruleMatchesPrefix(innerRules[i], prefix)) return true;\n }\n }\n return false;\n}\n\nfunction ruleMatchesKey(cssText: string, key: string): boolean {\n if (key.startsWith('tokens:')) {\n // tokens:color -> :root rule with --color- custom properties\n const namespace = key.slice('tokens:'.length);\n return cssText.includes(`:root`) && cssText.includes(`--${namespace}-`);\n }\n if (key.startsWith('theme:')) {\n // theme:dark -> .theme-dark selector\n const name = key.slice('theme:'.length);\n return cssText.includes(`.theme-${name}`);\n }\n if (key.startsWith('keyframes:')) {\n const name = key.slice('keyframes:'.length);\n return cssText.includes(`@keyframes ${name}`);\n }\n return false;\n}\n","/**\n * Shared registry for detecting duplicate namespace registrations.\n */\nexport const registeredNamespaces = new Set<string>();\n","import type { CSSProperties } from './types.js';\n\n/**\n * How generated class names are formed for `styles.create`, `styles.class`,\n * `styles.component`, and related APIs.\n *\n * - `semantic` — readable names like `button-base`, `button-intent-primary` (default).\n * - `hashed` — stable hash from namespace, variant segment, and declarations, with a short namespace slug for debugging.\n * - `atomic` — hash-only names (shortest); same collision properties as `hashed` when `scopeId` differs.\n */\nexport type ClassNamingMode = 'semantic' | 'hashed' | 'atomic';\n\nexport type ClassNamingConfig = {\n mode: ClassNamingMode;\n /** Prefix for hashed / atomic output and for `hashClass`. Default `ts`. */\n prefix: string;\n /**\n * Optional package or app id mixed into hash input so identical logical\n * names from different packages do not produce the same class string.\n */\n scopeId: string;\n};\n\nconst defaultConfig: ClassNamingConfig = {\n mode: 'semantic',\n prefix: 'ts',\n scopeId: '',\n};\n\nlet current: ClassNamingConfig = { ...defaultConfig };\n\nexport function getClassNamingConfig(): Readonly<ClassNamingConfig> {\n return current;\n}\n\n/**\n * Set global class naming options. Call once at app or package entry\n * (e.g. design-system `index.ts`) for per-package adoption in a monorepo.\n */\nexport function configureClassNaming(partial: Partial<ClassNamingConfig>): void {\n current = { ...current, ...partial };\n}\n\n/** Restore defaults (primarily for tests). */\nexport function resetClassNaming(): void {\n current = { ...defaultConfig };\n}\n\nexport function stableSerialize(value: unknown): string {\n if (value === null) return 'null';\n if (typeof value !== 'object') return JSON.stringify(value);\n if (Array.isArray(value)) return `[${value.map((v) => stableSerialize(v)).join(',')}]`;\n\n const entries = Object.entries(value as Record<string, unknown>)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${JSON.stringify(k)}:${stableSerialize(v)}`);\n\n return `{${entries.join(',')}}`;\n}\n\nexport function hashString(input: string): string {\n let hash = 0x811c9dc5;\n for (let i = 0; i < input.length; i++) {\n hash ^= input.charCodeAt(i);\n hash = Math.imul(hash, 0x01000193);\n }\n return (hash >>> 0).toString(36);\n}\n\nexport function sanitizeClassSegment(label: string): string {\n const normalized = label.trim().toLowerCase().replace(/[^a-z0-9-]/g, '-');\n return normalized.replace(/-+/g, '-').replace(/^-|-$/g, '') || 'style';\n}\n\n/** `styles.class(name, …)` */\nexport function buildSingleClassName(name: string, properties: CSSProperties): string {\n const cfg = getClassNamingConfig();\n if (cfg.mode === 'semantic') return name;\n\n const payload = stableSerialize({\n ...(cfg.scopeId ? { scope: cfg.scopeId } : {}),\n namespace: name,\n suffix: '',\n properties,\n });\n const h = hashString(payload);\n if (cfg.mode === 'atomic') return `${cfg.prefix}-${h}`;\n return `${cfg.prefix}-${sanitizeClassSegment(name)}-${h}`;\n}\n\n/**\n * `styles.create` / `styles.component` / slot recipes: logical namespace plus\n * a variant segment (`base`, `intent-primary`, `root-trigger-primary`, …).\n */\nexport function buildRecipeClassName(\n namespace: string,\n suffix: string,\n properties: CSSProperties,\n): string {\n const cfg = getClassNamingConfig();\n if (cfg.mode === 'semantic') return `${namespace}-${suffix}`;\n\n const payload = stableSerialize({\n ...(cfg.scopeId ? { scope: cfg.scopeId } : {}),\n namespace,\n suffix,\n properties,\n });\n const h = hashString(payload);\n if (cfg.mode === 'atomic') return `${cfg.prefix}-${h}`;\n return `${cfg.prefix}-${sanitizeClassSegment(namespace)}-${h}`;\n}\n","import type {\n CSSProperties,\n CSSPropertiesWithUtils,\n SelectorFunction,\n StyleDefinitions,\n StyleDefinitionsWithUtils,\n StyleUtils,\n} from './types.js';\nimport { serializeStyle } from './css.js';\nimport { insertRules } from './sheet.js';\nimport { registeredNamespaces } from './registry.js';\nimport {\n buildRecipeClassName,\n buildSingleClassName,\n getClassNamingConfig,\n hashString,\n sanitizeClassSegment,\n stableSerialize,\n} from './class-naming.js';\n\n/**\n * Create a single class with the given styles. Returns the class name string.\n * Use this when you don't need variants — just a class with typed CSS properties.\n *\n * @example\n * ```ts\n * const card = styles.class('card', {\n * padding: '1rem',\n * borderRadius: '0.5rem',\n * backgroundColor: 'white',\n * '&:hover': { boxShadow: '0 4px 6px rgb(0 0 0 / 0.1)' },\n * });\n *\n * <div className={card} /> // class=\"card\"\n * ```\n */\nexport function createClass(name: string, properties: CSSProperties): string {\n if (process.env.NODE_ENV !== 'production') {\n if (registeredNamespaces.has(name)) {\n console.warn(\n `[typestyles] styles.class('${name}', ...) called more than once. ` +\n `This will cause class name collisions. Each class name should be unique.`,\n );\n }\n }\n registeredNamespaces.add(name);\n\n const className = buildSingleClassName(name, properties);\n const selector = `.${className}`;\n const rules = serializeStyle(selector, properties);\n insertRules(rules);\n\n return className;\n}\n\n/**\n * Create a deterministic hashed class from a style object.\n * The same style object shape+values always returns the same class name.\n *\n * Optional `label` is appended as a readable prefix for debugging.\n *\n * @example\n * ```ts\n * const button = styles.hashClass({\n * padding: '8px 12px',\n * borderRadius: '8px',\n * });\n *\n * const danger = styles.hashClass(\n * { backgroundColor: 'red', color: 'white' },\n * 'danger'\n * );\n * ```\n */\nexport function createHashClass(properties: CSSProperties, label?: string): string {\n const cfg = getClassNamingConfig();\n const serialized =\n cfg.scopeId !== ''\n ? stableSerialize({ scope: cfg.scopeId, properties })\n : stableSerialize(properties);\n const hash = hashString(serialized);\n const className = label\n ? `${cfg.prefix}-${sanitizeClassSegment(label)}-${hash}`\n : `${cfg.prefix}-${hash}`;\n const selector = `.${className}`;\n const rules = serializeStyle(selector, properties);\n insertRules(rules);\n return className;\n}\n\n/**\n * Create a style group and return a selector function.\n *\n * **Two-argument form** (definitions object with 'base' and variants):\n * ```ts\n * const button = styles.create('button', {\n * base: { padding: '8px 16px' },\n * primary: { backgroundColor: '#0066ff' },\n * });\n * button('base', 'primary') // \"button-base button-primary\"\n * ```\n *\n * **Three-argument form** (base styles + variants, no 'base' key needed):\n * ```ts\n * const button = styles.create('button',\n * { padding: '8px 16px', borderRadius: '6px' }, // base styles\n * {\n * default: { backgroundColor: '#0066ff', color: '#fff' },\n * outline: { border: '1px solid', backgroundColor: 'transparent' },\n * large: { padding: '12px 24px' },\n * }\n * );\n * button('default') // \"button-base button-default\" — base always included\n * button('outline', 'large') // \"button-base button-outline button-large\"\n * ```\n */\nexport function createStyles<K extends string>(\n namespace: string,\n definitions: StyleDefinitions & Record<K, CSSProperties>,\n): SelectorFunction<K>;\nexport function createStyles(\n namespace: string,\n base: CSSProperties,\n variants: Record<string, CSSProperties>,\n): SelectorFunction<string>;\nexport function createStyles(\n namespace: string,\n baseOrDefinitions: CSSProperties | (StyleDefinitions & Record<string, CSSProperties>),\n variants?: Record<string, CSSProperties>,\n): SelectorFunction<string> {\n const definitions: StyleDefinitions & Record<string, CSSProperties> =\n variants !== undefined\n ? { base: baseOrDefinitions as CSSProperties, ...variants }\n : (baseOrDefinitions as StyleDefinitions & Record<string, CSSProperties>);\n\n const withBase = variants !== undefined;\n // Development-mode duplicate detection\n if (process.env.NODE_ENV !== 'production') {\n if (registeredNamespaces.has(namespace)) {\n console.warn(\n `[typestyles] styles.create('${namespace}', ...) called more than once. ` +\n `This will cause class name collisions. Each namespace should be unique.`,\n );\n }\n }\n registeredNamespaces.add(namespace);\n\n // Generate and inject CSS for all variants\n const rules: Array<{ key: string; css: string }> = [];\n const variantToClass: Record<string, string> = {};\n\n for (const [variant, properties] of Object.entries(definitions)) {\n const props = properties as CSSProperties;\n const className = buildRecipeClassName(namespace, variant, props);\n variantToClass[variant] = className;\n const selector = `.${className}`;\n const variantRules = serializeStyle(selector, props);\n rules.push(...variantRules);\n }\n\n insertRules(rules);\n\n // Return the selector function\n const selectorFn = (...variants: (string | false | null | undefined)[]): string => {\n const filtered = variants.filter(Boolean);\n const classes = withBase\n ? ['base', ...filtered.filter((v) => v !== 'base')]\n : filtered;\n return classes.map((v) => variantToClass[v as string] ?? '').filter(Boolean).join(' ');\n };\n\n return selectorFn as SelectorFunction<string>;\n}\n\n/**\n * Compose multiple selector functions or class strings into one.\n * Returns a new SelectorFunction that calls all inputs and joins results.\n *\n * @example\n * ```ts\n * const base = styles.create('base', { padding: '8px' });\n * const primary = styles.create('primary', { color: 'blue' });\n * const button = styles.compose(base, primary);\n *\n * button('padding', 'color'); // \"base-padding primary-color\"\n * ```\n */\ntype AnySelectorFunction = {\n (...args: unknown[]): string;\n};\n\nexport function compose(\n ...selectors: Array<AnySelectorFunction | string | false | null | undefined>\n): AnySelectorFunction {\n const validSelectors = selectors.filter(Boolean) as Array<AnySelectorFunction | string>;\n\n return (...args: unknown[]): string => {\n const classNames: string[] = [];\n\n for (const selector of validSelectors) {\n if (typeof selector === 'string') {\n classNames.push(selector);\n } else {\n const result = selector(...args);\n if (result) classNames.push(result);\n }\n }\n\n return classNames.join(' ');\n };\n}\n\nexport type StylesWithUtilsApi<U extends StyleUtils> = {\n class: (name: string, properties: CSSPropertiesWithUtils<U>) => string;\n hashClass: (properties: CSSPropertiesWithUtils<U>, label?: string) => string;\n create: {\n <K extends string>(\n namespace: string,\n definitions: StyleDefinitionsWithUtils<U> & Record<K, CSSPropertiesWithUtils<U>>,\n ): SelectorFunction<K>;\n (\n namespace: string,\n base: CSSPropertiesWithUtils<U>,\n variants: Record<string, CSSPropertiesWithUtils<U>>,\n ): SelectorFunction<string>;\n };\n compose: typeof compose;\n};\n\n/**\n * Create a utility-aware styles API, similar to Stitches' `utils`.\n *\n * @example\n * ```ts\n * const u = createStylesWithUtils({\n * marginX: (value: string | number) => ({ marginLeft: value, marginRight: value }),\n * size: (value: string | number) => ({ width: value, height: value }),\n * });\n *\n * const card = u.class('card', {\n * size: 40,\n * marginX: 16,\n * });\n * ```\n */\nexport function createStylesWithUtils<U extends StyleUtils>(utils: U): StylesWithUtilsApi<U> {\n const apply = (properties: CSSPropertiesWithUtils<U>): CSSProperties =>\n expandStyleWithUtils(properties, utils);\n\n function create<K extends string>(\n namespace: string,\n definitions: StyleDefinitionsWithUtils<U> & Record<K, CSSPropertiesWithUtils<U>>,\n ): SelectorFunction<K>;\n function create(\n namespace: string,\n base: CSSPropertiesWithUtils<U>,\n variants: Record<string, CSSPropertiesWithUtils<U>>,\n ): SelectorFunction<string>;\n function create(\n namespace: string,\n baseOrDefinitions:\n | CSSPropertiesWithUtils<U>\n | (StyleDefinitionsWithUtils<U> & Record<string, CSSPropertiesWithUtils<U>>),\n variants?: Record<string, CSSPropertiesWithUtils<U>>,\n ): SelectorFunction<string> {\n if (variants !== undefined) {\n const transformedVariants = Object.fromEntries(\n Object.entries(variants).map(([variant, properties]) => [variant, apply(properties)]),\n );\n return createStyles(namespace, apply(baseOrDefinitions as CSSPropertiesWithUtils<U>), transformedVariants);\n }\n\n const transformedDefinitions = Object.fromEntries(\n Object.entries(\n baseOrDefinitions as StyleDefinitionsWithUtils<U> & Record<string, CSSPropertiesWithUtils<U>>,\n ).map(([variant, properties]) => [variant, apply(properties)]),\n ) as StyleDefinitions & Record<string, CSSProperties>;\n\n return createStyles(namespace, transformedDefinitions);\n }\n\n return {\n class: (name, properties) => createClass(name, apply(properties)),\n hashClass: (properties, label) => createHashClass(apply(properties), label),\n create,\n compose,\n };\n}\n\nfunction expandStyleWithUtils<U extends StyleUtils>(\n properties: CSSPropertiesWithUtils<U>,\n utils: U,\n): CSSProperties {\n const expanded: CSSProperties = {};\n\n for (const [key, value] of Object.entries(properties as Record<string, unknown>)) {\n if (value == null) continue;\n\n if (key.startsWith('&') || key.startsWith('[') || key.startsWith('@')) {\n if (isObject(value)) {\n assignStyleEntry(\n expanded,\n key,\n expandStyleWithUtils(value as CSSPropertiesWithUtils<U>, utils),\n );\n }\n continue;\n }\n\n if (Object.prototype.hasOwnProperty.call(utils, key)) {\n const utilFn = utils[key as keyof U] as unknown as (arg: unknown) => CSSProperties;\n const utilResult = utilFn(value);\n const normalized = expandStyleWithUtils(utilResult as CSSPropertiesWithUtils<U>, utils);\n for (const [utilKey, utilValue] of Object.entries(normalized as Record<string, unknown>)) {\n assignStyleEntry(expanded, utilKey, utilValue);\n }\n continue;\n }\n\n assignStyleEntry(expanded, key, value);\n }\n\n return expanded;\n}\n\nfunction assignStyleEntry(target: CSSProperties, key: string, value: unknown): void {\n const targetRecord = target as Record<string, unknown>;\n\n if (isObject(value)) {\n const existing = targetRecord[key];\n if (isObject(existing)) {\n targetRecord[key] = mergeStyleObjects(\n existing as CSSProperties,\n value as CSSProperties,\n );\n return;\n }\n targetRecord[key] = value;\n return;\n }\n\n targetRecord[key] = value;\n}\n\nfunction mergeStyleObjects(base: CSSProperties, next: CSSProperties): CSSProperties {\n const merged: CSSProperties = { ...base };\n\n for (const [key, value] of Object.entries(next as Record<string, unknown>)) {\n assignStyleEntry(merged, key, value);\n }\n\n return merged;\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","import type { TokenValues, TokenRef, ThemeOverrides } from './types.js';\nimport { insertRule } from './sheet.js';\n\n/**\n * Registry tracking which token namespaces have been created,\n * so tokens.use() can provide warnings in development.\n */\nconst registeredNamespaces = new Set<string>();\n\n/**\n * Create a proxy-based token reference for a namespace.\n * Property access returns var(--{namespace}-{key}).\n */\nfunction createTokenProxy<T extends TokenValues>(namespace: string): TokenRef<T> {\n return new Proxy({} as TokenRef<T>, {\n get(_target, prop: string) {\n return `var(--${namespace}-${prop})`;\n },\n });\n}\n\n/**\n * Create design tokens as CSS custom properties.\n *\n * Generates a :root rule with the custom properties and returns\n * a typed object where property access yields var() references.\n *\n * @example\n * ```ts\n * const color = createTokens('color', {\n * primary: '#0066ff',\n * secondary: '#6b7280',\n * });\n *\n * color.primary // \"var(--color-primary)\"\n * ```\n */\nexport function createTokens<T extends TokenValues>(\n namespace: string,\n values: T\n): TokenRef<T> {\n registeredNamespaces.add(namespace);\n\n // Generate CSS custom property declarations\n const declarations = Object.entries(values)\n .map(([key, value]) => `--${namespace}-${key}: ${value}`)\n .join('; ');\n\n const css = `:root { ${declarations}; }`;\n insertRule(`tokens:${namespace}`, css);\n\n return createTokenProxy<T>(namespace);\n}\n\n/**\n * Reference tokens defined elsewhere without injecting CSS.\n *\n * Returns a typed proxy that produces var() references.\n * Useful for consuming shared tokens from a different module.\n *\n * @example\n * ```ts\n * const color = useTokens('color');\n * color.primary // \"var(--color-primary)\"\n * ```\n */\nexport function useTokens<T extends TokenValues = TokenValues>(\n namespace: string\n): TokenRef<T> {\n if (\n process.env.NODE_ENV !== 'production' &&\n registeredNamespaces.size > 0 &&\n !registeredNamespaces.has(namespace)\n ) {\n console.warn(\n `[typestyles] tokens.use('${namespace}') references a namespace that hasn't been created yet. ` +\n `Make sure tokens.create('${namespace}', ...) is called before using these tokens.`\n );\n }\n\n return createTokenProxy<T>(namespace);\n}\n\n/**\n * Create a theme class that overrides token values.\n *\n * Returns a class name string. Apply it to any element to override\n * token values for that subtree via CSS custom property cascading.\n *\n * @example\n * ```ts\n * const dark = createTheme('dark', {\n * color: { primary: '#66b3ff', surface: '#1a1a2e' },\n * });\n *\n * <div className={dark}> // class=\"theme-dark\"\n * ```\n */\nexport function createTheme(name: string, overrides: ThemeOverrides): string {\n const className = `theme-${name}`;\n\n const declarations: string[] = [];\n for (const [namespace, values] of Object.entries(overrides)) {\n for (const [key, value] of Object.entries(values)) {\n if (value != null) {\n declarations.push(`--${namespace}-${key}: ${value}`);\n }\n }\n }\n\n const css = `.${className} { ${declarations.join('; ')}; }`;\n insertRule(`theme:${name}`, css);\n\n return className;\n}\n","import type { CSSProperties } from './types.js';\nimport { toKebabCase } from './css.js';\nimport { insertRule } from './sheet.js';\n\n/**\n * A keyframe stop is either 'from', 'to', or a percentage like '50%'.\n */\nexport type KeyframeStops = Record<string, CSSProperties>;\n\n/**\n * Serialize CSS declarations for a single keyframe stop (no nesting/at-rules).\n */\nfunction serializeDeclarations(properties: CSSProperties): string {\n const declarations: string[] = [];\n\n for (const [prop, value] of Object.entries(properties)) {\n if (value == null) continue;\n // Keyframe stops only contain plain properties — skip nested selectors/at-rules\n if (prop.startsWith('&') || prop.startsWith('@')) continue;\n\n const kebabProp = toKebabCase(prop);\n const serialized =\n typeof value === 'number' ? (value === 0 ? '0' : value + 'px') : value;\n declarations.push(`${kebabProp}: ${serialized}`);\n }\n\n return declarations.join('; ');\n}\n\n/**\n * Create a CSS @keyframes animation and return its name.\n *\n * The returned string is the animation name — use it directly in\n * `animation` shorthand or `animationName`.\n *\n * @example\n * ```ts\n * const fadeIn = keyframes.create('fadeIn', {\n * from: { opacity: 0 },\n * to: { opacity: 1 },\n * });\n *\n * const card = styles.create('card', {\n * base: { animation: `${fadeIn} 300ms ease` },\n * });\n * ```\n *\n * @example\n * ```ts\n * const bounce = keyframes.create('bounce', {\n * '0%': { transform: 'translateY(0)' },\n * '50%': { transform: 'translateY(-20px)' },\n * '100%': { transform: 'translateY(0)' },\n * });\n * ```\n */\nexport function createKeyframes(name: string, stops: KeyframeStops): string {\n const stopsCSS = Object.entries(stops)\n .map(([stop, properties]) => {\n const decls = serializeDeclarations(properties as CSSProperties);\n return `${stop} { ${decls}; }`;\n })\n .join(' ');\n\n const css = `@keyframes ${name} { ${stopsCSS} }`;\n insertRule(`keyframes:${name}`, css);\n\n return name;\n}\n","/**\n * Type-safe helpers for CSS color functions.\n *\n * Each function returns a plain CSS string — no runtime color math.\n * Works naturally with token references since tokens are strings too.\n */\n\ntype ColorValue = string | number;\n\n/** Color spaces supported by color-mix(). */\nexport type ColorMixSpace =\n | 'srgb'\n | 'srgb-linear'\n | 'display-p3'\n | 'a98-rgb'\n | 'prophoto-rgb'\n | 'rec2020'\n | 'lab'\n | 'oklab'\n | 'xyz'\n | 'xyz-d50'\n | 'xyz-d65'\n | 'hsl'\n | 'hwb'\n | 'lch'\n | 'oklch';\n\n/**\n * `rgb(r g b)` or `rgb(r g b / a)`\n *\n * @example\n * ```ts\n * color.rgb(0, 102, 255) // \"rgb(0 102 255)\"\n * color.rgb(0, 102, 255, 0.5) // \"rgb(0 102 255 / 0.5)\"\n * ```\n */\nexport function rgb(r: ColorValue, g: ColorValue, b: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `rgb(${r} ${g} ${b} / ${alpha})`;\n return `rgb(${r} ${g} ${b})`;\n}\n\n/**\n * `hsl(h s l)` or `hsl(h s l / a)`\n *\n * @example\n * ```ts\n * color.hsl(220, '100%', '50%') // \"hsl(220 100% 50%)\"\n * color.hsl(220, '100%', '50%', 0.8) // \"hsl(220 100% 50% / 0.8)\"\n * ```\n */\nexport function hsl(h: ColorValue, s: ColorValue, l: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `hsl(${h} ${s} ${l} / ${alpha})`;\n return `hsl(${h} ${s} ${l})`;\n}\n\n/**\n * `oklch(L C h)` or `oklch(L C h / a)`\n *\n * @example\n * ```ts\n * color.oklch(0.7, 0.15, 250) // \"oklch(0.7 0.15 250)\"\n * color.oklch(0.7, 0.15, 250, 0.5) // \"oklch(0.7 0.15 250 / 0.5)\"\n * ```\n */\nexport function oklch(l: ColorValue, c: ColorValue, h: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `oklch(${l} ${c} ${h} / ${alpha})`;\n return `oklch(${l} ${c} ${h})`;\n}\n\n/**\n * `oklab(L a b)` or `oklab(L a b / alpha)`\n *\n * @example\n * ```ts\n * color.oklab(0.7, -0.1, -0.1) // \"oklab(0.7 -0.1 -0.1)\"\n * color.oklab(0.7, -0.1, -0.1, 0.5) // \"oklab(0.7 -0.1 -0.1 / 0.5)\"\n * ```\n */\nexport function oklab(l: ColorValue, a: ColorValue, b: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `oklab(${l} ${a} ${b} / ${alpha})`;\n return `oklab(${l} ${a} ${b})`;\n}\n\n/**\n * `lab(L a b)` or `lab(L a b / alpha)`\n *\n * @example\n * ```ts\n * color.lab('50%', 40, -20) // \"lab(50% 40 -20)\"\n * ```\n */\nexport function lab(l: ColorValue, a: ColorValue, b: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `lab(${l} ${a} ${b} / ${alpha})`;\n return `lab(${l} ${a} ${b})`;\n}\n\n/**\n * `lch(L C h)` or `lch(L C h / alpha)`\n *\n * @example\n * ```ts\n * color.lch('50%', 80, 250) // \"lch(50% 80 250)\"\n * ```\n */\nexport function lch(l: ColorValue, c: ColorValue, h: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `lch(${l} ${c} ${h} / ${alpha})`;\n return `lch(${l} ${c} ${h})`;\n}\n\n/**\n * `hwb(h w b)` or `hwb(h w b / alpha)`\n *\n * @example\n * ```ts\n * color.hwb(220, '10%', '0%') // \"hwb(220 10% 0%)\"\n * ```\n */\nexport function hwb(h: ColorValue, w: ColorValue, b: ColorValue, alpha?: ColorValue): string {\n if (alpha != null) return `hwb(${h} ${w} ${b} / ${alpha})`;\n return `hwb(${h} ${w} ${b})`;\n}\n\n/**\n * `color-mix(in colorspace, color1 p1%, color2 p2%)`\n *\n * Mixes two colors in the given color space. Percentages are optional.\n *\n * @example\n * ```ts\n * color.mix('red', 'blue') // \"color-mix(in srgb, red, blue)\"\n * color.mix('red', 'blue', 30) // \"color-mix(in srgb, red 30%, blue)\"\n * color.mix(theme.primary, 'white', 20) // \"color-mix(in srgb, var(--theme-primary) 20%, white)\"\n * color.mix('red', 'blue', 50, 'oklch') // \"color-mix(in oklch, red 50%, blue)\"\n * ```\n */\nexport function mix(\n color1: string,\n color2: string,\n percentage?: number,\n colorSpace: ColorMixSpace = 'srgb'\n): string {\n const c1 = percentage != null ? `${color1} ${percentage}%` : color1;\n return `color-mix(in ${colorSpace}, ${c1}, ${color2})`;\n}\n\n/**\n * `light-dark(lightColor, darkColor)`\n *\n * Uses the `light-dark()` CSS function that resolves based on\n * the computed `color-scheme` of the element.\n *\n * @example\n * ```ts\n * color.lightDark('#111', '#eee') // \"light-dark(#111, #eee)\"\n * color.lightDark(theme.textLight, theme.textDark) // \"light-dark(var(--theme-textLight), var(--theme-textDark))\"\n * ```\n */\nexport function lightDark(lightColor: string, darkColor: string): string {\n return `light-dark(${lightColor}, ${darkColor})`;\n}\n\n/**\n * Adjust the alpha/opacity of any color using `color-mix()`.\n *\n * This is a common pattern: mixing a color with transparent to change opacity.\n * Works with any color value including token references.\n *\n * @example\n * ```ts\n * color.alpha('red', 0.5) // \"color-mix(in srgb, red 50%, transparent)\"\n * color.alpha(theme.primary, 0.2) // \"color-mix(in srgb, var(--theme-primary) 20%, transparent)\"\n * color.alpha('#0066ff', 0.8, 'oklch') // \"color-mix(in oklch, #0066ff 80%, transparent)\"\n * ```\n */\nexport function alpha(\n colorValue: string,\n opacity: number,\n colorSpace: ColorMixSpace = 'srgb'\n): string {\n const percentage = Math.round(opacity * 100);\n return `color-mix(in ${colorSpace}, ${colorValue} ${percentage}%, transparent)`;\n}\n","import type {\n CSSProperties,\n VariantDefinitions,\n ComponentConfig,\n ComponentFunction,\n SlotComponentConfig,\n SlotComponentFunction,\n SlotVariantDefinitions,\n} from './types.js';\nimport { serializeStyle } from './css.js';\nimport { insertRules } from './sheet.js';\nimport { registeredNamespaces } from './registry.js';\nimport { buildRecipeClassName } from './class-naming.js';\n\n/**\n * Create a multi-variant component style and return a selector function.\n *\n * Class naming convention (default `semantic` mode; see `configureClassNaming`):\n * base → `{namespace}-base`\n * variants.intent.primary → `{namespace}-intent-primary`\n * compoundVariants[0] → `{namespace}-compound-0`\n *\n * @example\n * ```ts\n * const button = styles.component('button', {\n * base: { padding: '8px 16px' },\n * variants: {\n * intent: {\n * primary: { backgroundColor: '#0066ff', color: '#fff' },\n * ghost: { backgroundColor: 'transparent', border: '1px solid currentColor' },\n * },\n * size: {\n * sm: { fontSize: '12px' },\n * lg: { fontSize: '18px' },\n * },\n * },\n * compoundVariants: [\n * { variants: { intent: 'primary', size: 'lg' }, style: { fontWeight: 700 } },\n * ],\n * defaultVariants: { intent: 'primary', size: 'sm' },\n * });\n *\n * button() // \"button-base button-intent-primary button-size-sm\"\n * button({ intent: 'ghost' }) // \"button-base button-intent-ghost button-size-sm\"\n * button({ intent: 'primary', size: 'lg' }) // includes compound class\n * ```\n */\nexport function createComponent<V extends VariantDefinitions>(\n namespace: string,\n config: ComponentConfig<V>,\n): ComponentFunction<V>;\n\nexport function createComponent<S extends string, V extends SlotVariantDefinitions<S>>(\n namespace: string,\n config: SlotComponentConfig<S, V>,\n): SlotComponentFunction<S, V>;\nexport function createComponent(\n namespace: string,\n config: ComponentConfig<VariantDefinitions> | SlotComponentConfig<string, SlotVariantDefinitions<string>>,\n): ComponentFunction<VariantDefinitions> | SlotComponentFunction<string, SlotVariantDefinitions<string>> {\n if ('slots' in config) {\n return createSlotComponent(\n namespace,\n config as SlotComponentConfig<string, SlotVariantDefinitions<string>>,\n );\n }\n return createSingleComponent(namespace, config as ComponentConfig<VariantDefinitions>);\n}\n\nfunction createSingleComponent<V extends VariantDefinitions>(\n namespace: string,\n config: ComponentConfig<V>,\n): ComponentFunction<V> {\n const { base, variants = {} as V, compoundVariants = [], defaultVariants = {} } = config;\n\n // Development-mode duplicate detection\n if (process.env.NODE_ENV !== 'production') {\n if (registeredNamespaces.has(namespace)) {\n console.warn(\n `[typestyles] styles.component('${namespace}', ...) called more than once. ` +\n `This will cause class name collisions. Each namespace should be unique.`\n );\n }\n }\n registeredNamespaces.add(namespace);\n\n const rules: Array<{ key: string; css: string }> = [];\n\n let baseClassName: string | undefined;\n const variantClassByKey: Record<string, string> = {};\n const compoundClassByIndex: string[] = [];\n\n // 1. Inject CSS for base\n if (base) {\n baseClassName = buildRecipeClassName(namespace, 'base', base);\n rules.push(...serializeStyle(`.${baseClassName}`, base));\n }\n\n // 2. Inject CSS for each variant option\n for (const [dimension, options] of Object.entries(variants)) {\n for (const [option, properties] of Object.entries(options as Record<string, CSSProperties>)) {\n const segment = `${dimension}-${option}`;\n const className = buildRecipeClassName(namespace, segment, properties);\n variantClassByKey[segment] = className;\n rules.push(...serializeStyle(`.${className}`, properties));\n }\n }\n\n // 3. Inject CSS for each compound variant\n (compoundVariants as Array<{ variants: Record<string, unknown>; style: CSSProperties }>).forEach(\n (cv, index) => {\n const className = buildRecipeClassName(namespace, `compound-${index}`, cv.style);\n compoundClassByIndex[index] = className;\n rules.push(...serializeStyle(`.${className}`, cv.style));\n }\n );\n\n insertRules(rules);\n\n // 4. Return the selector function\n return ((selections: Record<string, unknown> = {}) => {\n const classes: string[] = [];\n\n if (base && baseClassName) classes.push(baseClassName);\n\n // Resolve final selections (explicit overrides defaultVariants)\n const resolvedSelections: Record<string, unknown> = {};\n for (const [dimension, options] of Object.entries(variants)) {\n const optionMap = options as Record<string, CSSProperties>;\n const explicit = selections[dimension];\n const fallback = (defaultVariants as Record<string, unknown>)[dimension];\n resolvedSelections[dimension] = normalizeSelection(explicit ?? fallback, optionMap);\n }\n\n // Apply variant classes\n for (const [dimension, options] of Object.entries(variants)) {\n const selected = resolvedSelections[dimension];\n const optionMap = options as Record<string, CSSProperties>;\n const selectedKey = normalizeSelection(selected, optionMap);\n if (selectedKey != null) {\n const variantKey = `${dimension}-${selectedKey}`;\n const cn = variantClassByKey[variantKey];\n if (cn) classes.push(cn);\n }\n }\n\n // Apply compound variant classes\n (compoundVariants as Array<{ variants: Record<string, unknown>; style: CSSProperties }>).forEach(\n (cv, index) => {\n const matches = Object.entries(cv.variants).every(([k, expected]) => {\n const options = (variants as Record<string, Record<string, CSSProperties>>)[k];\n if (!options) return false;\n\n const selected = normalizeSelection(resolvedSelections[k], options);\n if (selected == null) return false;\n\n if (Array.isArray(expected)) {\n return expected.some((value) => normalizeSelection(value, options) === selected);\n }\n\n return normalizeSelection(expected, options) === selected;\n });\n if (matches) {\n const cn = compoundClassByIndex[index];\n if (cn) classes.push(cn);\n }\n }\n );\n\n return classes.join(' ');\n }) as ComponentFunction<V>;\n}\n\nfunction normalizeSelection(\n value: unknown,\n options: Record<string, unknown>,\n): string | undefined {\n if (value == null) return undefined;\n\n if (typeof value === 'boolean') {\n const boolKey = String(value);\n if (Object.prototype.hasOwnProperty.call(options, boolKey)) return boolKey;\n // Preserve existing behavior: false acts as an opt-out when no \"false\" variant is defined.\n if (value === false) return undefined;\n return boolKey;\n }\n\n return String(value);\n}\n\nfunction createSlotComponent<S extends string, V extends SlotVariantDefinitions<S>>(\n namespace: string,\n config: SlotComponentConfig<S, V>,\n): SlotComponentFunction<S, V> {\n const { slots, base = {}, variants = {} as V, compoundVariants = [], defaultVariants = {} } = config;\n\n // Development-mode duplicate detection\n if (process.env.NODE_ENV !== 'production') {\n if (registeredNamespaces.has(namespace)) {\n console.warn(\n `[typestyles] styles.component('${namespace}', ...) called more than once. ` +\n `This will cause class name collisions. Each namespace should be unique.`\n );\n }\n }\n registeredNamespaces.add(namespace);\n\n const rules: Array<{ key: string; css: string }> = [];\n\n const baseClassBySlot: Record<string, string> = {};\n for (const [slot, properties] of Object.entries(base as Record<string, CSSProperties>)) {\n const className = buildRecipeClassName(namespace, slot, properties);\n baseClassBySlot[slot] = className;\n rules.push(...serializeStyle(`.${className}`, properties));\n }\n\n const variantClassByKey: Record<string, string> = {};\n for (const [dimension, options] of Object.entries(variants)) {\n for (const [option, slotStyles] of Object.entries(options as Record<string, Record<string, CSSProperties>>)) {\n for (const [slot, properties] of Object.entries(slotStyles)) {\n const segment = `${slot}-${dimension}-${option}`;\n const className = buildRecipeClassName(namespace, segment, properties);\n variantClassByKey[segment] = className;\n rules.push(...serializeStyle(`.${className}`, properties));\n }\n }\n }\n\n const slotCompoundClassByKey: Record<string, string> = {};\n (compoundVariants as Array<{ variants: Record<string, unknown>; style: Record<string, CSSProperties> }>).forEach(\n (cv, index) => {\n for (const [slot, properties] of Object.entries(cv.style)) {\n const segment = `${slot}-compound-${index}`;\n const className = buildRecipeClassName(namespace, segment, properties);\n slotCompoundClassByKey[`${slot}::${index}`] = className;\n rules.push(...serializeStyle(`.${className}`, properties));\n }\n }\n );\n\n insertRules(rules);\n\n return ((selections: Record<string, unknown> = {}) => {\n const classes = Object.fromEntries((slots as readonly string[]).map((slot) => [slot, [] as string[]])) as Record<\n string,\n string[]\n >;\n\n const resolvedSelections: Record<string, unknown> = {};\n for (const [dimension, options] of Object.entries(variants)) {\n const optionMap = options as Record<string, unknown>;\n const explicit = selections[dimension];\n const fallback = (defaultVariants as Record<string, unknown>)[dimension];\n resolvedSelections[dimension] = normalizeSelection(explicit ?? fallback, optionMap);\n }\n\n for (const slot of Object.keys(base as Record<string, CSSProperties>)) {\n const cn = baseClassBySlot[slot];\n if (cn && classes[slot]) classes[slot].push(cn);\n }\n\n for (const [dimension, options] of Object.entries(variants)) {\n const optionMap = options as Record<string, Record<string, CSSProperties>>;\n const selected = normalizeSelection(resolvedSelections[dimension], optionMap);\n if (selected == null) continue;\n const slotStyles = optionMap[selected];\n if (!slotStyles) continue;\n\n for (const slot of Object.keys(slotStyles)) {\n const segment = `${slot}-${dimension}-${selected}`;\n const cn = variantClassByKey[segment];\n if (cn && classes[slot]) classes[slot].push(cn);\n }\n }\n\n (compoundVariants as Array<{ variants: Record<string, unknown>; style: Record<string, CSSProperties> }>).forEach(\n (cv, index) => {\n const matches = Object.entries(cv.variants).every(([k, expected]) => {\n const options = (variants as Record<string, Record<string, unknown>>)[k];\n if (!options) return false;\n\n const selected = normalizeSelection(resolvedSelections[k], options);\n if (selected == null) return false;\n\n if (Array.isArray(expected)) {\n return expected.some((value) => normalizeSelection(value, options) === selected);\n }\n\n return normalizeSelection(expected, options) === selected;\n });\n\n if (!matches) return;\n\n for (const slot of Object.keys(cv.style)) {\n const cn = slotCompoundClassByKey[`${slot}::${index}`];\n if (cn && classes[slot]) classes[slot].push(cn);\n }\n }\n );\n\n return Object.fromEntries(\n (slots as readonly string[]).map((slot) => [slot, classes[slot].join(' ')])\n ) as Record<S, string>;\n }) as SlotComponentFunction<S, V>;\n}\n","import type { CSSProperties, FontFaceProps } from './types.js';\nimport { serializeStyle } from './css.js';\nimport { insertRule, insertRules } from './sheet.js';\n\n/**\n * Apply styles to an arbitrary CSS selector.\n *\n * Use for CSS resets, body/root defaults, third-party elements, or any\n * selector that isn't tied to a specific component class.\n *\n * @example\n * ```ts\n * global.style('body', { margin: 0, fontFamily: 'sans-serif' });\n * global.style('a:hover', { textDecoration: 'underline' });\n * global.style('*, *::before, *::after', { boxSizing: 'border-box' });\n * ```\n */\nexport function globalStyle(selector: string, properties: CSSProperties): void {\n const rules = serializeStyle(selector, properties);\n insertRules(rules);\n}\n\n/**\n * Declare a `@font-face` rule to load a custom font.\n *\n * Multiple weights/styles of the same family can be registered by calling\n * this function multiple times with different `src` values — each call is\n * deduplicated by `family + src`.\n *\n * @example\n * ```ts\n * global.fontFace('Inter', {\n * src: \"url('/fonts/Inter-Regular.woff2') format('woff2')\",\n * fontWeight: 400,\n * fontStyle: 'normal',\n * fontDisplay: 'swap',\n * });\n *\n * global.fontFace('Inter', {\n * src: \"url('/fonts/Inter-Bold.woff2') format('woff2')\",\n * fontWeight: 700,\n * fontStyle: 'normal',\n * fontDisplay: 'swap',\n * });\n * ```\n */\nexport function globalFontFace(family: string, props: FontFaceProps): void {\n const decls: string[] = [`font-family: \"${family}\"`, `src: ${props.src}`];\n if (props.fontWeight != null) decls.push(`font-weight: ${props.fontWeight}`);\n if (props.fontStyle) decls.push(`font-style: ${props.fontStyle}`);\n if (props.fontDisplay) decls.push(`font-display: ${props.fontDisplay}`);\n if (props.fontStretch) decls.push(`font-stretch: ${props.fontStretch}`);\n if (props.unicodeRange) decls.push(`unicode-range: ${props.unicodeRange}`);\n const css = `@font-face { ${decls.join('; ')}; }`;\n // Key includes src for uniqueness (multiple weights per family)\n insertRule(`font-face:${family}:${props.src}`, css);\n}\n","import type { CSSVarRef } from './types.js';\n\nlet counter = 0;\n\n/** Reset the counter. Used in tests only. */\nexport function __resetVarCounter(): void {\n counter = 0;\n}\n\n/**\n * Create a unique CSS custom property reference.\n *\n * Returns a `var(--ts-N)` string that can be used anywhere a CSS value is\n * accepted. Use assignVars() to set its value per element via inline styles.\n *\n * @example\n * ```ts\n * const cardBg = createVar();\n *\n * const card = styles.create('card', {\n * base: { background: cardBg, padding: '16px' },\n * });\n *\n * // Consumer sets the variable per instance:\n * <div className={card('base')} style={assignVars({ [cardBg]: '#ff0099' })} />\n * ```\n */\nexport function createVar(): CSSVarRef {\n const name = `--ts-${++counter}`;\n return `var(${name})` as CSSVarRef;\n}\n\n/**\n * Build a CSS custom property assignment map from var refs to values.\n *\n * The returned object is safe to spread into a React (or any framework)\n * inline `style` prop.\n *\n * @example\n * ```ts\n * assignVars({ [cardBg]: '#ff0099' })\n * // → { '--ts-1': '#ff0099' }\n * ```\n */\nexport function assignVars(\n vars: Partial<Record<CSSVarRef, string>>\n): Record<string, string> {\n const result: Record<string, string> = {};\n for (const [varRef, value] of Object.entries(vars)) {\n if (value == null) continue;\n // Strip \"var(\" prefix and \")\" suffix to get the raw property name\n const match = varRef.match(/^var\\((--[^)]+)\\)$/);\n if (match) result[match[1]] = value;\n }\n return result;\n}\n","import { createStyles, createClass, createHashClass, compose, createStylesWithUtils } from './styles.js';\nimport { createTokens, useTokens, createTheme } from './tokens.js';\nimport { createKeyframes } from './keyframes.js';\nimport * as colorFns from './color.js';\nimport { getRegisteredCss, insertRules, reset, flushSync } from './sheet.js';\nimport { createComponent } from './component.js';\nimport { globalStyle, globalFontFace } from './global.js';\nimport { createVar, assignVars } from './vars.js';\n\nexport type { ClassNamingConfig, ClassNamingMode } from './class-naming.js';\nexport { configureClassNaming, getClassNamingConfig, resetClassNaming } from './class-naming.js';\n\nexport type {\n CSSProperties,\n CSSValue,\n StyleDefinitions,\n StyleDefinitionsWithUtils,\n CSSPropertiesWithUtils,\n StyleUtils,\n SelectorFunction,\n TokenValues,\n TokenRef,\n ThemeOverrides,\n KeyframeStops,\n VariantDefinitions,\n ComponentConfig,\n ComponentFunction,\n SlotStyles,\n SlotVariantDefinitions,\n SlotComponentConfig,\n SlotComponentFunction,\n FontFaceProps,\n CSSVarRef,\n ComponentVariants,\n} from './types.js';\n\nexport { createVar, assignVars };\n\nexport type { ColorMixSpace } from './color.js';\n\n/**\n * Style creation API.\n *\n * @example\n * ```ts\n * const button = styles.create('button', {\n * base: { padding: '8px 16px' },\n * primary: { backgroundColor: '#0066ff' },\n * });\n *\n * const hashed = styles.hashClass({ display: 'inline-flex' }, 'button');\n *\n * <button className={`${button('base', 'primary')} ${hashed}`}>\n * ```\n */\nexport const styles = {\n create: createStyles,\n class: createClass,\n hashClass: createHashClass,\n component: createComponent,\n withUtils: createStylesWithUtils,\n compose,\n} as const;\n\n/**\n * Global CSS API for arbitrary selectors and font-face declarations.\n *\n * @example\n * ```ts\n * global.style('body', { margin: 0 });\n * global.fontFace('Inter', { src: \"url('/Inter.woff2') format('woff2')\", fontWeight: 400 });\n * ```\n */\nexport const global = {\n style: globalStyle,\n fontFace: globalFontFace,\n} as const;\n\n/**\n * Design token API using CSS custom properties.\n *\n * @example\n * ```ts\n * const color = tokens.create('color', {\n * primary: '#0066ff',\n * });\n *\n * color.primary // \"var(--color-primary)\"\n * ```\n */\nexport const tokens = {\n create: createTokens,\n use: useTokens,\n createTheme,\n} as const;\n\n/**\n * Keyframe animation API.\n *\n * @example\n * ```ts\n * const fadeIn = keyframes.create('fadeIn', {\n * from: { opacity: 0 },\n * to: { opacity: 1 },\n * });\n *\n * const card = styles.create('card', {\n * base: { animation: `${fadeIn} 300ms ease` },\n * });\n * ```\n */\nexport const keyframes = {\n create: createKeyframes,\n} as const;\n\n/**\n * Type-safe CSS color function helpers.\n *\n * Each function returns a plain CSS color string — no runtime color math.\n * Composes naturally with token references.\n *\n * @example\n * ```ts\n * color.rgb(0, 102, 255) // \"rgb(0 102 255)\"\n * color.oklch(0.7, 0.15, 250) // \"oklch(0.7 0.15 250)\"\n * color.mix(theme.primary, 'white', 20) // \"color-mix(in srgb, var(--theme-primary) 20%, white)\"\n * color.alpha(theme.primary, 0.5) // \"color-mix(in srgb, var(--theme-primary) 50%, transparent)\"\n * color.lightDark('#111', '#eee') // \"light-dark(#111, #eee)\"\n * ```\n */\nexport const color = colorFns;\n\n/**\n * Return all registered CSS as a string (for SSR).\n *\n * Returns every CSS rule registered via `styles.create`, `tokens.create`,\n * `keyframes.create`, etc. Use this in your SSR head/meta function to\n * inject styles into the document.\n *\n * This is safe to import on the client — it has no server-specific\n * dependencies and will simply return whatever CSS has been registered.\n *\n * @example\n * ```ts\n * import { getRegisteredCss } from 'typestyles';\n *\n * // In a route's head function (e.g. TanStack Start):\n * export const Route = createRootRoute({\n * head: () => ({\n * styles: [{ id: 'typestyles', children: getRegisteredCss() }],\n * }),\n * });\n * ```\n */\nexport { getRegisteredCss };\n\n/**\n * Insert multiple CSS rules into the stylesheet.\n *\n * This is a low-level API used internally by typestyles and by packages\n * like @typestyles/props. You typically won't need to use this directly.\n *\n * @example\n * ```ts\n * import { insertRules } from 'typestyles';\n *\n * insertRules([\n * { key: '.my-class', css: '.my-class { color: red; }' },\n * { key: '.another', css: '.another { padding: 8px; }' },\n * ]);\n * ```\n */\nexport { insertRules };\n\n/**\n * Testing utilities for clearing the stylesheet and flushing pending rules.\n * These are primarily intended for use in tests.\n *\n * @example\n * ```ts\n * import { reset, flushSync } from 'typestyles';\n *\n * // In a test beforeEach:\n * beforeEach(() => {\n * reset(); // Clear all registered CSS\n * });\n *\n * // To synchronously flush pending rules:\n * flushSync();\n * ```\n */\nexport { reset, flushSync };\n"]}