nuvox 0.1.3 → 0.1.5

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tokens/contract.ts","../src/tokens/themes/light.ts","../src/tokens/themes/dark.ts","../src/tokens/themes/glass.ts","../src/tokens/themes/dark-glass.ts","../src/tokens/themes/minimalism.ts","../src/tokens/themes/brutalism.ts","../src/tokens/themes/neobrutalism.ts","../src/tokens/themes/cyberpunk.ts","../src/tokens/themes/gradient.ts","../src/tokens/themes/material.ts","../src/tokens/themes/skeuomorphism.ts","../src/tokens/registry.ts","../src/tokens/accents/indigo.ts","../src/tokens/accents/violet.ts","../src/tokens/accents/teal.ts","../src/tokens/accents/rose.ts","../src/tokens/accents/amber.ts","../src/tokens/accents/emerald.ts","../src/tokens/accents/copper.ts","../src/tokens/accents/graphite.ts","../src/tokens/accents/magenta.ts","../src/tokens/accents.ts","../src/core/field.ts","../src/core/colorpicker.ts","../src/core/table.ts","../src/core/code-highlight.ts","../src/core/rich-text.ts"],"sourcesContent":["// ============================================================\n// TOKEN CONTRACT\n//\n// This is the single most important file in the foundation.\n//\n// Every theme (light, dark, glass, cyberpunk, whatever comes\n// next) must produce an object that satisfies ThemeTokens.\n// TypeScript enforces this at compile time via `defineTheme()`\n// below — leave out a single key and the build fails with a\n// clear error naming the missing key.\n//\n// In the old codebase, themes were hand-written CSS files.\n// Nothing checked that cyberpunk.css defined every variable\n// brutalism.css did. A missing token didn't error — it just\n// silently fell back to nothing, and you only found out by\n// looking at the rendered page.\n//\n// Here, themes are TypeScript objects. CSS is *generated* from\n// them (see generate-css.ts), never hand-authored. There is\n// exactly one source of truth per theme, and it cannot be\n// incomplete.\n// ============================================================\n\n// ============================================================\n// A theme controls SHAPE, not brand color: radius, shadow style,\n// motion curves, border treatment, glass/gradient/glow effects,\n// and the neutral/semantic palette needed for legibility (a dark\n// theme's background/text MUST differ from light's — that's a\n// contrast requirement, not a brand choice). It does NOT define\n// `color.brand` — that's a separate, orthogonal axis (see\n// accents.ts) that a consumer picks independently of which theme\n// is active, and can override per-component exactly like `theme`\n// can. success/danger/warning/info stay theme-defined (their\n// exact shade can differ per theme for contrast, but their\n// meaning — green reads as success, red as danger — must not be\n// user-customizable away from that).\n// ============================================================\n\nexport interface ColorScale {\n 50: string; 100: string; 200: string; 300: string; 400: string;\n 500: string; 600: string; 700: string; 800: string; 900: string;\n}\n\nexport interface SemanticColor {\n light: string;\n subtle: string;\n base: string;\n dark: string;\n deeper: string;\n}\n\nexport interface ThemeTokens {\n meta: {\n name: string;\n label: string;\n /** Short description of the visual identity — kept out of CSS, used in docs/registry UI. */\n description: string;\n };\n\n color: {\n neutral: ColorScale & { 0: string; 950: string };\n success: SemanticColor;\n danger: SemanticColor;\n warning: SemanticColor;\n info: SemanticColor;\n /** Page/app background, not component surface. */\n background: string;\n /** Default component surface (card, input, modal body). */\n surface: string;\n /** Elevated surface (popover, dropdown, tooltip). */\n surfaceRaised: string;\n border: string;\n borderFocus: string;\n text: string;\n textMuted: string;\n textInverse: string;\n };\n\n radius: {\n sm: string; md: string; lg: string; xl: string; \"2xl\": string; full: string;\n };\n\n spacing: {\n xs: string; sm: string; md: string; lg: string; xl: string; \"2xl\": string;\n };\n\n typography: {\n fontSans: string;\n fontMono: string;\n sizeXs: string; sizeSm: string; sizeMd: string; sizeLg: string; sizeXl: string;\n weightNormal: string; weightMedium: string; weightBold: string;\n lineHeightTight: string; lineHeightNormal: string;\n };\n\n shadow: {\n xs: string; sm: string; md: string; lg: string; xl: string; \"2xl\": string;\n inner: string;\n };\n\n elevation: {\n /** z-index steps — must be consistent across every portal-based component. */\n dropdown: number;\n popover: number;\n modal: number;\n toast: number;\n tooltip: number;\n };\n\n motion: {\n durationFast: string;\n durationNormal: string;\n durationSlow: string;\n easeStandard: string;\n easeEmphasized: string;\n /** Set to '0.01ms' by a reduced-motion-aware theme variant if needed. */\n durationInstant: string;\n };\n\n border: {\n widthThin: string;\n widthMedium: string;\n widthThick: string;\n style: string;\n };\n\n effects: {\n /**\n * CSS `backdrop-filter: blur()` amount, e.g. \"16px\" or \"0px\".\n * Every non-glass theme sets this to \"0px\" — an explicit zero,\n * not an absent field, so `defineTheme`'s completeness check\n * still catches an accidentally-forgotten theme. Translucent\n * `color.surface`/`color.border` values (glass, dark-glass) are\n * only actually visible as \"glass\" when something behind them\n * is blurred; without this, a translucent white surface over a\n * plain page background is indistinguishable from opaque white.\n */\n backdropBlur: string;\n };\n}\n\n/**\n * Identity function with a strict parameter type.\n * Its only job is to make an incomplete theme a compile error\n * at the call site, with TypeScript naming the exact missing key.\n */\nexport function defineTheme(tokens: ThemeTokens): ThemeTokens {\n return tokens;\n}\n\n/** Every top-level and nested key path, used by the completeness test. */\nexport const TOKEN_CATEGORIES = [\n \"meta\", \"color\", \"radius\", \"spacing\", \"typography\", \"shadow\", \"elevation\", \"motion\", \"border\", \"effects\",\n] as const;\n\n/**\n * Every required leaf path, hardcoded independently of any\n * theme instance. This is deliberately NOT derived from\n * whichever theme happens to register first — that would make\n * the very first theme registered the unverified \"trust me\"\n * reference. Every path listed here corresponds 1:1 to a field\n * in ThemeTokens; if you add a field to the contract, add its\n * path here too (a mismatch here is caught by\n * registry.test.ts's cross-check against `light`).\n */\nexport const REQUIRED_TOKEN_PATHS = [\n \"meta.name\", \"meta.label\", \"meta.description\",\n ...[\"0\", \"50\", \"100\", \"200\", \"300\", \"400\", \"500\", \"600\", \"700\", \"800\", \"900\", \"950\"].map((k) => `color.neutral.${k}`),\n ...([\"success\", \"danger\", \"warning\", \"info\"] as const).flatMap((c) =>\n [\"light\", \"subtle\", \"base\", \"dark\", \"deeper\"].map((k) => `color.${c}.${k}`)\n ),\n \"color.background\", \"color.surface\", \"color.surfaceRaised\", \"color.border\", \"color.borderFocus\",\n \"color.text\", \"color.textMuted\", \"color.textInverse\",\n \"radius.sm\", \"radius.md\", \"radius.lg\", \"radius.xl\", \"radius.2xl\", \"radius.full\",\n \"spacing.xs\", \"spacing.sm\", \"spacing.md\", \"spacing.lg\", \"spacing.xl\", \"spacing.2xl\",\n \"typography.fontSans\", \"typography.fontMono\",\n \"typography.sizeXs\", \"typography.sizeSm\", \"typography.sizeMd\", \"typography.sizeLg\", \"typography.sizeXl\",\n \"typography.weightNormal\", \"typography.weightMedium\", \"typography.weightBold\",\n \"typography.lineHeightTight\", \"typography.lineHeightNormal\",\n \"shadow.xs\", \"shadow.sm\", \"shadow.md\", \"shadow.lg\", \"shadow.xl\", \"shadow.2xl\", \"shadow.inner\",\n \"elevation.dropdown\", \"elevation.popover\", \"elevation.modal\", \"elevation.toast\", \"elevation.tooltip\",\n \"motion.durationFast\", \"motion.durationNormal\", \"motion.durationSlow\",\n \"motion.easeStandard\", \"motion.easeEmphasized\", \"motion.durationInstant\",\n \"border.widthThin\", \"border.widthMedium\", \"border.widthThick\", \"border.style\",\n \"effects.backdropBlur\",\n] as const;\n\nfunction getAtPath(obj: unknown, path: string): unknown {\n return path.split(\".\").reduce<unknown>((acc, key) => {\n if (acc === null || typeof acc !== \"object\") return undefined;\n return (acc as Record<string, unknown>)[key];\n }, obj);\n}\n\n/** Returns every required path that is missing or empty on the given theme-like object. */\nexport function findMissingTokenPaths(theme: unknown): string[] {\n return REQUIRED_TOKEN_PATHS.filter((path) => {\n const value = getAtPath(theme, path);\n return value === null || value === undefined || value === \"\";\n });\n}\n","import { defineTheme } from \"../contract\";\n\nexport const light = defineTheme({\n meta: {\n name: \"light\",\n label: \"Light\",\n description: \"Default, neutral, high-legibility surface.\",\n },\n color: {\n neutral: {\n 0: \"#ffffff\", 50: \"#f9fafb\", 100: \"#f3f4f6\", 200: \"#e5e7eb\", 300: \"#d1d5db\",\n 400: \"#9ca3af\", 500: \"#6b7280\", 600: \"#4b5563\", 700: \"#374151\", 800: \"#1f2937\",\n 900: \"#111827\", 950: \"#030712\",\n },\n success: { light: \"#d1fae5\", subtle: \"#a7f3d0\", base: \"#10b981\", dark: \"#059669\", deeper: \"#064e3b\" },\n danger: { light: \"#fee2e2\", subtle: \"#fecaca\", base: \"#ef4444\", dark: \"#dc2626\", deeper: \"#7f1d1d\" },\n warning: { light: \"#fef3c7\", subtle: \"#fde68a\", base: \"#f59e0b\", dark: \"#d97706\", deeper: \"#78350f\" },\n info: { light: \"#dbeafe\", subtle: \"#bfdbfe\", base: \"#3b82f6\", dark: \"#2563eb\", deeper: \"#1e3a5f\" },\n background: \"#ffffff\",\n surface: \"#ffffff\",\n surfaceRaised: \"#ffffff\",\n border: \"#e5e7eb\",\n // Neutral, not brand-tied — the actual focus-ring color\n // interactive components use is the picked accent\n // (--color-brand-500/600), not this. This exists for\n // non-branded emphasis borders.\n borderFocus: \"#9ca3af\",\n text: \"#111827\",\n textMuted: \"#6b7280\",\n textInverse: \"#ffffff\",\n },\n radius: { sm: \"6px\", md: \"10px\", lg: \"14px\", xl: \"18px\", \"2xl\": \"24px\", full: \"9999px\" },\n spacing: { xs: \"4px\", sm: \"8px\", md: \"12px\", lg: \"16px\", xl: \"24px\", \"2xl\": \"32px\" },\n typography: {\n fontSans: \"'Inter', system-ui, sans-serif\",\n fontMono: \"'JetBrains Mono', monospace\",\n sizeXs: \"12px\", sizeSm: \"14px\", sizeMd: \"16px\", sizeLg: \"18px\", sizeXl: \"22px\",\n weightNormal: \"400\", weightMedium: \"500\", weightBold: \"700\",\n lineHeightTight: \"1.2\", lineHeightNormal: \"1.5\",\n },\n shadow: {\n xs: \"0 1px 2px rgba(0,0,0,0.05)\",\n sm: \"0 2px 6px rgba(0,0,0,0.06)\",\n md: \"0 4px 12px rgba(0,0,0,0.08)\",\n lg: \"0 10px 24px rgba(0,0,0,0.10)\",\n xl: \"0 20px 40px rgba(0,0,0,0.12)\",\n \"2xl\": \"0 28px 56px rgba(0,0,0,0.16)\",\n inner: \"inset 0 1px 2px rgba(0,0,0,0.05)\",\n },\n elevation: { dropdown: 1000, popover: 1100, modal: 1200, toast: 1300, tooltip: 1400 },\n motion: {\n durationFast: \"120ms\", durationNormal: \"200ms\", durationSlow: \"320ms\",\n easeStandard: \"cubic-bezier(0.4, 0, 0.2, 1)\", easeEmphasized: \"cubic-bezier(0.2, 0, 0, 1)\",\n durationInstant: \"0ms\",\n },\n border: { widthThin: \"1px\", widthMedium: \"1.5px\", widthThick: \"2px\", style: \"solid\" },\n effects: { backdropBlur: \"0px\" },\n});\n","import { defineTheme } from \"../contract\";\n\nexport const dark = defineTheme({\n meta: {\n name: \"dark\",\n label: \"Dark\",\n description: \"Low-glare surface for extended use.\",\n },\n color: {\n neutral: {\n 0: \"#030712\", 50: \"#111827\", 100: \"#1f2937\", 200: \"#374151\", 300: \"#4b5563\",\n 400: \"#6b7280\", 500: \"#9ca3af\", 600: \"#d1d5db\", 700: \"#e5e7eb\", 800: \"#f3f4f6\",\n 900: \"#f9fafb\", 950: \"#ffffff\",\n },\n success: { light: \"#064e3b\", subtle: \"#065f46\", base: \"#34d399\", dark: \"#6ee7b7\", deeper: \"#d1fae5\" },\n danger: { light: \"#7f1d1d\", subtle: \"#991b1b\", base: \"#f87171\", dark: \"#fca5a5\", deeper: \"#fee2e2\" },\n warning: { light: \"#78350f\", subtle: \"#92400e\", base: \"#fbbf24\", dark: \"#fcd34d\", deeper: \"#fef3c7\" },\n info: { light: \"#1e3a5f\", subtle: \"#1e40af\", base: \"#60a5fa\", dark: \"#93c5fd\", deeper: \"#dbeafe\" },\n background: \"#0b0f19\",\n surface: \"#131826\",\n surfaceRaised: \"#1c2333\",\n border: \"#2a3143\",\n borderFocus: \"#6b7280\",\n text: \"#f3f4f6\",\n textMuted: \"#9ca3af\",\n textInverse: \"#111827\",\n },\n radius: { sm: \"6px\", md: \"10px\", lg: \"14px\", xl: \"18px\", \"2xl\": \"24px\", full: \"9999px\" },\n spacing: { xs: \"4px\", sm: \"8px\", md: \"12px\", lg: \"16px\", xl: \"24px\", \"2xl\": \"32px\" },\n typography: {\n fontSans: \"'Inter', system-ui, sans-serif\",\n fontMono: \"'JetBrains Mono', monospace\",\n sizeXs: \"12px\", sizeSm: \"14px\", sizeMd: \"16px\", sizeLg: \"18px\", sizeXl: \"22px\",\n weightNormal: \"400\", weightMedium: \"500\", weightBold: \"700\",\n lineHeightTight: \"1.2\", lineHeightNormal: \"1.5\",\n },\n shadow: {\n xs: \"0 1px 2px rgba(0,0,0,0.4)\",\n sm: \"0 2px 6px rgba(0,0,0,0.45)\",\n md: \"0 4px 12px rgba(0,0,0,0.5)\",\n lg: \"0 10px 24px rgba(0,0,0,0.55)\",\n xl: \"0 20px 40px rgba(0,0,0,0.6)\",\n \"2xl\": \"0 28px 56px rgba(0,0,0,0.65)\",\n inner: \"inset 0 1px 2px rgba(0,0,0,0.4)\",\n },\n elevation: { dropdown: 1000, popover: 1100, modal: 1200, toast: 1300, tooltip: 1400 },\n motion: {\n durationFast: \"120ms\", durationNormal: \"200ms\", durationSlow: \"320ms\",\n easeStandard: \"cubic-bezier(0.4, 0, 0.2, 1)\", easeEmphasized: \"cubic-bezier(0.2, 0, 0, 1)\",\n durationInstant: \"0ms\",\n },\n border: { widthThin: \"1px\", widthMedium: \"1.5px\", widthThick: \"2px\", style: \"solid\" },\n effects: { backdropBlur: \"0px\" },\n});\n","import { defineTheme } from \"../contract\";\n\nexport const glass = defineTheme({\n meta: {\n name: \"glass\",\n label: \"Glass\",\n description: \"Translucent, softly rounded, floating surfaces. Needs a rich background behind it.\",\n },\n color: {\n neutral: {\n 0: \"#ffffff\", 50: \"#f9fafb\", 100: \"#f3f4f6\", 200: \"#e5e7eb\", 300: \"#d1d5db\",\n 400: \"#9ca3af\", 500: \"#6b7280\", 600: \"#4b5563\", 700: \"#374151\", 800: \"#1f2937\",\n 900: \"#111827\", 950: \"#030712\",\n },\n success: { light: \"#d1fae5\", subtle: \"#a7f3d0\", base: \"#10b981\", dark: \"#059669\", deeper: \"#064e3b\" },\n danger: { light: \"#fee2e2\", subtle: \"#fecaca\", base: \"#ef4444\", dark: \"#dc2626\", deeper: \"#7f1d1d\" },\n warning: { light: \"#fef3c7\", subtle: \"#fde68a\", base: \"#f59e0b\", dark: \"#d97706\", deeper: \"#78350f\" },\n info: { light: \"#dbeafe\", subtle: \"#bfdbfe\", base: \"#3b82f6\", dark: \"#2563eb\", deeper: \"#1e3a5f\" },\n background: \"transparent\",\n surface: \"rgba(255,255,255,0.55)\",\n surfaceRaised: \"rgba(255,255,255,0.75)\",\n // Was rgba(255,255,255,0.35) — translucent WHITE. Composited on\n // a plain white page (the theme's own meta.description admits it\n // \"needs a rich background behind it,\" but most consumers won't\n // add one), that resolves to literal #ffffff — a 1.0:1 contrast\n // ratio, i.e. actually invisible, which is the reported vanished\n // Progress-track border. A neutral slate tint stays visible\n // against both a plain white AND a plain black fallback backdrop\n // (measured ~2.1-2.3:1 either way) — short of full 3:1 UI-contrast\n // on both extremes at once, but a large improvement over 1.0, and\n // still reads as a soft glass edge over an actual rich backdrop.\n border: \"rgba(100,116,139,0.6)\",\n borderFocus: \"#9ca3af\",\n text: \"#111827\",\n textMuted: \"rgba(17,24,39,0.65)\",\n textInverse: \"#ffffff\",\n },\n // Notably rounder than light/dark — this is a shape difference, not just color.\n radius: { sm: \"10px\", md: \"16px\", lg: \"22px\", xl: \"28px\", \"2xl\": \"36px\", full: \"9999px\" },\n spacing: { xs: \"4px\", sm: \"8px\", md: \"12px\", lg: \"16px\", xl: \"24px\", \"2xl\": \"32px\" },\n typography: {\n fontSans: \"'Inter', system-ui, sans-serif\",\n fontMono: \"'JetBrains Mono', monospace\",\n sizeXs: \"12px\", sizeSm: \"14px\", sizeMd: \"16px\", sizeLg: \"18px\", sizeXl: \"22px\",\n weightNormal: \"400\", weightMedium: \"500\", weightBold: \"700\",\n lineHeightTight: \"1.2\", lineHeightNormal: \"1.5\",\n },\n shadow: {\n xs: \"0 2px 8px rgba(0,0,0,0.06)\",\n sm: \"0 4px 16px rgba(0,0,0,0.08)\",\n md: \"0 8px 32px rgba(0,0,0,0.10)\",\n lg: \"0 16px 48px rgba(0,0,0,0.12)\",\n xl: \"0 24px 64px rgba(0,0,0,0.14)\",\n \"2xl\": \"0 32px 80px rgba(0,0,0,0.18)\",\n inner: \"inset 0 1px 0 rgba(255,255,255,0.4)\",\n },\n elevation: { dropdown: 1000, popover: 1100, modal: 1200, toast: 1300, tooltip: 1400 },\n motion: {\n // Slightly slower/softer than light/dark — matches \"everything floats\".\n durationFast: \"160ms\", durationNormal: \"260ms\", durationSlow: \"400ms\",\n easeStandard: \"cubic-bezier(0.25, 0.1, 0.25, 1)\", easeEmphasized: \"cubic-bezier(0.16, 1, 0.3, 1)\",\n durationInstant: \"0ms\",\n },\n border: { widthThin: \"1px\", widthMedium: \"1px\", widthThick: \"1.5px\", style: \"solid\" },\n effects: { backdropBlur: \"16px\" },\n});","import { defineTheme } from \"../contract\";\nimport { dark } from \"./dark\";\n\nexport const darkGlass = defineTheme({\n ...dark,\n meta: {\n name: \"dark-glass\",\n label: \"Dark Glass\",\n description: \"Translucent glass panels floating over a dark background.\",\n },\n color: {\n ...dark.color,\n background: \"#05070d\",\n surface: \"rgba(255,255,255,0.06)\",\n surfaceRaised: \"rgba(255,255,255,0.10)\",\n border: \"rgba(255,255,255,0.12)\",\n },\n radius: { sm: \"10px\", md: \"16px\", lg: \"22px\", xl: \"28px\", \"2xl\": \"36px\", full: \"9999px\" },\n shadow: {\n xs: \"0 2px 8px rgba(0,0,0,0.5)\", sm: \"0 4px 16px rgba(0,0,0,0.55)\", md: \"0 8px 32px rgba(0,0,0,0.6)\",\n lg: \"0 16px 48px rgba(0,0,0,0.65)\", xl: \"0 24px 64px rgba(0,0,0,0.7)\", \"2xl\": \"0 32px 80px rgba(0,0,0,0.75)\",\n inner: \"inset 0 1px 0 rgba(255,255,255,0.08)\",\n },\n motion: { ...dark.motion, durationFast: \"160ms\", durationNormal: \"260ms\", durationSlow: \"400ms\" },\n effects: { backdropBlur: \"18px\" },\n});\n","import { defineTheme } from \"../contract\";\nimport { light } from \"./light\";\n\nexport const minimalism = defineTheme({\n ...light,\n meta: {\n name: \"minimalism\",\n label: \"Minimalism\",\n description: \"Reduced to essentials — thin borders, flat surfaces, no shadow, tight radius.\",\n },\n color: {\n ...light.color,\n border: \"#e2e2e2\", surface: \"#ffffff\", surfaceRaised: \"#ffffff\",\n },\n radius: { sm: \"2px\", md: \"3px\", lg: \"4px\", xl: \"6px\", \"2xl\": \"8px\", full: \"9999px\" },\n shadow: { xs: \"none\", sm: \"none\", md: \"none\", lg: \"none\", xl: \"none\", \"2xl\": \"none\", inner: \"none\" },\n border: { widthThin: \"1px\", widthMedium: \"1px\", widthThick: \"1px\", style: \"solid\" },\n effects: { backdropBlur: \"0px\" },\n});\n","import { defineTheme } from \"../contract\";\nimport { light } from \"./light\";\n\nexport const brutalism = defineTheme({\n ...light,\n meta: {\n name: \"brutalism\",\n label: \"Brutalism\",\n description: \"Raw, unstyled web aesthetic — square corners, zero shadow, monospace type.\",\n },\n color: {\n ...light.color,\n background: \"#ffffff\", surface: \"#ffffff\", surfaceRaised: \"#ffffff\",\n border: \"#000000\", borderFocus: \"#ff0000\", text: \"#000000\",\n },\n radius: { sm: \"0px\", md: \"0px\", lg: \"0px\", xl: \"0px\", \"2xl\": \"0px\", full: \"0px\" },\n typography: { ...light.typography, fontSans: \"'Courier New', monospace\", fontMono: \"'Courier New', monospace\" },\n shadow: { xs: \"none\", sm: \"none\", md: \"none\", lg: \"none\", xl: \"none\", \"2xl\": \"none\", inner: \"none\" },\n border: { widthThin: \"1px\", widthMedium: \"2px\", widthThick: \"3px\", style: \"solid\" },\n motion: { ...light.motion, durationFast: \"0ms\", durationNormal: \"0ms\", durationSlow: \"0ms\" },\n effects: { backdropBlur: \"0px\" },\n});\n","import { defineTheme } from \"../contract\";\nimport { light } from \"./light\";\n\nexport const neobrutalism = defineTheme({\n ...light,\n meta: {\n name: \"neobrutalism\",\n label: \"Neo Brutalism\",\n description: \"Bold black borders, flat offset shadows, saturated color blocks.\",\n },\n color: {\n ...light.color,\n background: \"#fef3c7\", surface: \"#ffffff\", surfaceRaised: \"#ffffff\",\n border: \"#000000\", borderFocus: \"#000000\",\n // light.color.warning.light (#fef3c7) is identical to this\n // theme's own background — every warning Alert/Badge/etc. was\n // rendering invisibly on the page. Bumped to the next step in\n // the same warm-amber family (matches light.color.warning.subtle)\n // so it stays on-theme but is actually visible against the page.\n warning: { ...light.color.warning, light: \"#fde68a\" },\n },\n radius: { sm: \"4px\", md: \"6px\", lg: \"8px\", xl: \"10px\", \"2xl\": \"12px\", full: \"9999px\" },\n shadow: {\n xs: \"2px 2px 0 #000000\", sm: \"3px 3px 0 #000000\", md: \"4px 4px 0 #000000\",\n lg: \"6px 6px 0 #000000\", xl: \"8px 8px 0 #000000\", \"2xl\": \"10px 10px 0 #000000\",\n inner: \"inset 2px 2px 0 #000000\",\n },\n border: { widthThin: \"2px\", widthMedium: \"3px\", widthThick: \"4px\", style: \"solid\" },\n motion: { ...light.motion, durationFast: \"80ms\", durationNormal: \"140ms\", durationSlow: \"200ms\", easeStandard: \"linear\", easeEmphasized: \"linear\" },\n effects: { backdropBlur: \"0px\" },\n});","import { defineTheme } from \"../contract\";\nimport { dark } from \"./dark\";\n\nexport const cyberpunk = defineTheme({\n ...dark,\n meta: {\n name: \"cyberpunk\",\n label: \"Cyberpunk\",\n description: \"Neon-on-black, glowing edges, high-saturation magenta/cyan accents.\",\n },\n color: {\n ...dark.color,\n background: \"#0a0014\", surface: \"#12001f\", surfaceRaised: \"#1a0230\",\n border: \"#ff2bd6\", borderFocus: \"#00f0ff\", text: \"#e8faff\", textMuted: \"#9a8cc9\",\n },\n radius: { sm: \"2px\", md: \"4px\", lg: \"6px\", xl: \"8px\", \"2xl\": \"10px\", full: \"9999px\" },\n shadow: {\n xs: \"0 0 6px rgba(255,43,214,0.5)\", sm: \"0 0 12px rgba(255,43,214,0.55)\",\n md: \"0 0 20px rgba(0,240,255,0.5)\", lg: \"0 0 32px rgba(0,240,255,0.55)\",\n xl: \"0 0 48px rgba(255,43,214,0.6)\", \"2xl\": \"0 0 64px rgba(0,240,255,0.65)\",\n inner: \"inset 0 0 8px rgba(255,43,214,0.4)\",\n },\n border: { widthThin: \"1px\", widthMedium: \"1.5px\", widthThick: \"2px\", style: \"solid\" },\n motion: { ...dark.motion, easeStandard: \"cubic-bezier(0.83,0,0.17,1)\", easeEmphasized: \"cubic-bezier(0.9,0,0.1,1)\" },\n effects: { backdropBlur: \"0px\" },\n});\n","import { defineTheme } from \"../contract\";\nimport { light } from \"./light\";\n\nexport const gradient = defineTheme({\n ...light,\n meta: {\n name: \"gradient\",\n label: \"Gradient\",\n description: \"Vibrant, colorful transitions across surfaces and accents.\",\n },\n color: {\n ...light.color,\n background: \"linear-gradient(135deg, #667eea 0%, #764ba2 100%)\",\n surface: \"linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,255,255,0.75))\",\n surfaceRaised: \"#ffffff\",\n border: \"rgba(118,75,162,0.25)\",\n borderFocus: \"#764ba2\",\n // text/textMuted were still light theme's values (#111827 /\n // #6b7280) — fine on the near-white `surface`, but components\n // that render straight on `background` (Timeline, Pagination,\n // Tabs — all used with no wrapping surface in this library's own\n // docs examples) sat directly on the purple gradient instead.\n // Measured contrast against the gradient's darker stop\n // (#764ba2): text 2.79:1, textMuted a barely-there 1.32:1 — the\n // reported \"nearly invisible\" text. Darkened both; textMuted\n // still can't clear 4.5:1 against the darkest point of this\n // specific gradient with a single flat color (nothing dark\n // enough to do that stays legible as \"muted\" against the near-\n // white surface too), so this is the best available compromise\n // within a single global text/textMuted pair, not a full fix —\n // worth knowing if it still reads as low-contrast on the\n // darkest corner of the gradient.\n text: \"#000000\",\n textMuted: \"#2e2440\",\n },\n radius: { sm: \"12px\", md: \"18px\", lg: \"24px\", xl: \"32px\", \"2xl\": \"40px\", full: \"9999px\" },\n shadow: {\n xs: \"0 2px 10px rgba(118,75,162,0.15)\", sm: \"0 4px 20px rgba(118,75,162,0.18)\",\n md: \"0 8px 30px rgba(118,75,162,0.22)\", lg: \"0 16px 40px rgba(118,75,162,0.26)\",\n xl: \"0 24px 56px rgba(118,75,162,0.3)\", \"2xl\": \"0 32px 72px rgba(118,75,162,0.35)\",\n inner: \"inset 0 1px 0 rgba(255,255,255,0.5)\",\n },\n motion: { ...light.motion, durationNormal: \"240ms\", durationSlow: \"380ms\" },\n effects: { backdropBlur: \"0px\" },\n});","import { defineTheme } from \"../contract\";\nimport { light } from \"./light\";\n\nexport const material = defineTheme({\n ...light,\n meta: {\n name: \"material\",\n label: \"Material\",\n description: \"Google Material Design-inspired elevation shadows and motion curves.\",\n },\n color: {\n ...light.color,\n surface: \"#ffffff\", background: \"#fafafa\",\n },\n radius: { sm: \"4px\", md: \"8px\", lg: \"12px\", xl: \"16px\", \"2xl\": \"28px\", full: \"9999px\" },\n typography: { ...light.typography, fontSans: \"'Roboto', system-ui, sans-serif\" },\n shadow: {\n xs: \"0 1px 2px rgba(0,0,0,0.24)\",\n sm: \"0 1px 4px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.12)\",\n md: \"0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)\",\n lg: \"0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)\",\n xl: \"0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)\",\n \"2xl\": \"0 19px 38px rgba(0,0,0,0.3), 0 15px 12px rgba(0,0,0,0.22)\",\n inner: \"inset 0 1px 2px rgba(0,0,0,0.12)\",\n },\n motion: { ...light.motion, easeStandard: \"cubic-bezier(0.4,0,0.2,1)\", easeEmphasized: \"cubic-bezier(0.0,0,0.2,1)\" },\n effects: { backdropBlur: \"0px\" },\n});\n","import { defineTheme } from \"../contract\";\nimport { light } from \"./light\";\n\nexport const skeuomorphism = defineTheme({\n ...light,\n meta: {\n name: \"skeuomorphism\",\n label: \"Skeuomorphism\",\n description: \"Realistic depth — soft embossed surfaces mimicking physical material.\",\n },\n color: {\n ...light.color,\n background: \"#e8e4da\", surface: \"#f0ece2\", surfaceRaised: \"#f7f4ec\",\n border: \"#c9c2b0\", text: \"#3a3226\",\n },\n radius: { sm: \"8px\", md: \"12px\", lg: \"18px\", xl: \"24px\", \"2xl\": \"32px\", full: \"9999px\" },\n shadow: {\n xs: \"inset 0 1px 1px rgba(255,255,255,0.8), 0 1px 3px rgba(58,50,38,0.25)\",\n sm: \"inset 0 1px 1px rgba(255,255,255,0.8), 0 2px 6px rgba(58,50,38,0.28)\",\n md: \"inset 0 1px 1px rgba(255,255,255,0.8), 0 4px 10px rgba(58,50,38,0.3)\",\n lg: \"inset 0 1px 1px rgba(255,255,255,0.8), 0 8px 18px rgba(58,50,38,0.32)\",\n xl: \"inset 0 1px 1px rgba(255,255,255,0.8), 0 14px 28px rgba(58,50,38,0.35)\",\n \"2xl\": \"inset 0 1px 1px rgba(255,255,255,0.8), 0 20px 40px rgba(58,50,38,0.38)\",\n inner: \"inset 0 2px 4px rgba(58,50,38,0.3)\",\n },\n motion: { ...light.motion, durationNormal: \"220ms\", easeStandard: \"cubic-bezier(0.34,1.56,0.64,1)\" },\n effects: { backdropBlur: \"0px\" },\n});\n","import type { ThemeTokens } from \"./contract\";\nimport { findMissingTokenPaths } from \"./contract\";\nimport { light } from \"./themes/light\";\nimport { dark } from \"./themes/dark\";\nimport { glass } from \"./themes/glass\";\nimport { darkGlass } from \"./themes/dark-glass\";\nimport { minimalism } from \"./themes/minimalism\";\nimport { brutalism } from \"./themes/brutalism\";\nimport { neobrutalism } from \"./themes/neobrutalism\";\nimport { cyberpunk } from \"./themes/cyberpunk\";\nimport { gradient } from \"./themes/gradient\";\nimport { material } from \"./themes/material\";\nimport { skeuomorphism } from \"./themes/skeuomorphism\";\n\nconst registry = new Map<string, ThemeTokens>();\n\n/**\n * Checks the theme against REQUIRED_TOKEN_PATHS — a fixed list\n * hardcoded in contract.ts, not derived from whichever theme\n * happens to register first. This is the runtime safety net for\n * themes that bypass the TypeScript-level defineTheme() check\n * (e.g. loaded from JSON at runtime rather than authored as a\n * .ts file in this repo). A theme that fails this throws\n * immediately on registration, not silently at render time on\n * whichever component hits the missing key first.\n */\nfunction assertComplete(theme: ThemeTokens): void {\n const missing = findMissingTokenPaths(theme);\n if (missing.length > 0) {\n throw new Error(\n `Theme \"${theme.meta?.name ?? \"unknown\"}\" is missing/empty required token(s): ${missing.join(\", \")}`\n );\n }\n}\n\nexport function registerTheme(theme: ThemeTokens): void {\n assertComplete(theme);\n registry.set(theme.meta.name, theme);\n}\n\nexport function getTheme(name: string): ThemeTokens | undefined {\n return registry.get(name);\n}\n\nexport function listThemes(): ThemeTokens[] {\n return Array.from(registry.values());\n}\n\n// Built-in themes register on import. Third-party/future themes\n// (Cyberpunk, Neo Brutal, Aurora, ...) call registerTheme() the\n// same way from wherever they're defined — no other file needs\n// to change.\nregisterTheme(light);\nregisterTheme(dark);\nregisterTheme(glass);\nregisterTheme(darkGlass);\nregisterTheme(minimalism);\nregisterTheme(brutalism);\nregisterTheme(neobrutalism);\nregisterTheme(cyberpunk);\nregisterTheme(gradient);\nregisterTheme(material);\nregisterTheme(skeuomorphism);\n","import type { AccentDefinition } from \"../accents\";\n\nexport const indigo: AccentDefinition = {\n name: \"indigo\",\n label: \"Indigo\",\n scale: {\n 50: \"#f0f4ff\", 100: \"#e0e8ff\", 200: \"#c7d5fe\", 300: \"#a5b4fc\", 400: \"#818cf8\",\n 500: \"#6366f1\", 600: \"#4f46e5\", 700: \"#4338ca\", 800: \"#3730a3\", 900: \"#312e81\",\n },\n};\n","import type { AccentDefinition } from \"../accents\";\n\nexport const violet: AccentDefinition = {\n name: \"violet\",\n label: \"Violet\",\n scale: {\n 50: \"#faf5ff\", 100: \"#f3e8ff\", 200: \"#e9d5ff\", 300: \"#d8b4fe\", 400: \"#c084fc\",\n 500: \"#a855f7\", 600: \"#9333ea\", 700: \"#7e22ce\", 800: \"#6b21a8\", 900: \"#581c87\",\n },\n};\n","import type { AccentDefinition } from \"../accents\";\n\nexport const teal: AccentDefinition = {\n name: \"teal\",\n label: \"Teal\",\n scale: {\n 50: \"#f0fdfa\", 100: \"#ccfbf1\", 200: \"#99f6e4\", 300: \"#5eead4\", 400: \"#2dd4bf\",\n 500: \"#14b8a6\", 600: \"#0d9488\", 700: \"#0f766e\", 800: \"#115e59\", 900: \"#134e4a\",\n },\n};\n","import type { AccentDefinition } from \"../accents\";\n\nexport const rose: AccentDefinition = {\n name: \"rose\",\n label: \"Rose\",\n scale: {\n 50: \"#fff1f2\", 100: \"#ffe4e6\", 200: \"#fecdd3\", 300: \"#fda4af\", 400: \"#fb7185\",\n 500: \"#f43f5e\", 600: \"#e11d48\", 700: \"#be123c\", 800: \"#9f1239\", 900: \"#881337\",\n },\n};\n","import type { AccentDefinition } from \"../accents\";\n\nexport const amber: AccentDefinition = {\n name: \"amber\",\n label: \"Amber\",\n scale: {\n 50: \"#fffbeb\", 100: \"#fef3c7\", 200: \"#fde68a\", 300: \"#fcd34d\", 400: \"#fbbf24\",\n 500: \"#f59e0b\", 600: \"#d97706\", 700: \"#b45309\", 800: \"#92400e\", 900: \"#78350f\",\n },\n};\n","import type { AccentDefinition } from \"../accents\";\n\nexport const emerald: AccentDefinition = {\n name: \"emerald\",\n label: \"Emerald\",\n scale: {\n 50: \"#ecfdf5\", 100: \"#d1fae5\", 200: \"#a7f3d0\", 300: \"#6ee7b7\", 400: \"#34d399\",\n 500: \"#10b981\", 600: \"#059669\", 700: \"#047857\", 800: \"#065f46\", 900: \"#064e3b\",\n },\n};\n","import type { AccentDefinition } from \"../accents\";\n\nexport const copper: AccentDefinition = {\n name: \"copper\",\n label: \"Copper\",\n scale: {\n 50: \"#fdf6ec\", 100: \"#faebd2\", 200: \"#f3d3a0\", 300: \"#e9b56b\",\n 400: \"#d99a45\", 500: \"#b9752c\", 600: \"#9c5d24\", 700: \"#7d4a1f\", 800: \"#623a1c\", 900: \"#4e2f19\",\n },\n};\n","import type { AccentDefinition } from \"../accents\";\n\nexport const graphite: AccentDefinition = {\n name: \"graphite\",\n label: \"Graphite\",\n scale: {\n 50: \"#fafafa\", 100: \"#f0f0f0\", 200: \"#e0e0e0\", 300: \"#c7c7c7\", 400: \"#a3a3a3\",\n 500: \"#525252\", 600: \"#404040\", 700: \"#262626\", 800: \"#171717\", 900: \"#0a0a0a\",\n },\n};\n","import type { AccentDefinition } from \"../accents\";\n\nexport const magenta: AccentDefinition = {\n name: \"magenta\",\n label: \"Magenta\",\n scale: {\n 50: \"#ffe0fb\", 100: \"#ffb3f5\", 200: \"#ff80ee\", 300: \"#ff4de6\", 400: \"#ff26e0\",\n 500: \"#ff00d9\", 600: \"#e600c4\", 700: \"#cc00af\", 800: \"#b3009a\", 900: \"#800070\",\n },\n};\n","import type { ColorScale } from \"./contract\";\n\n// ============================================================\n// ACCENT COLORS\n//\n// This is the axis a consumer actually picks their brand color\n// from — completely independent of which theme (shape/structure)\n// is active. \"Our brand is teal\" should work whether the app is\n// using the light theme, the cyberpunk theme, or any other —\n// the theme still controls radius/shadow/motion/glass-or-not,\n// the accent controls hue.\n//\n// Mirrors tokens/registry.ts's shape deliberately (registerX /\n// getX / listX) so the two systems are learned once, not twice.\n// ============================================================\n\nexport interface AccentDefinition {\n name: string;\n label: string;\n scale: ColorScale;\n}\n\nconst registry = new Map<string, AccentDefinition>();\n\nfunction assertCompleteScale(def: AccentDefinition): void {\n const missing = ([\"50\", \"100\", \"200\", \"300\", \"400\", \"500\", \"600\", \"700\", \"800\", \"900\"] as const).filter(\n (k) => !def.scale[k as unknown as keyof ColorScale]\n );\n if (missing.length > 0) {\n throw new Error(`Accent \"${def.name}\" is missing scale step(s): ${missing.join(\", \")}`);\n }\n}\n\nexport function registerAccent(def: AccentDefinition): void {\n assertCompleteScale(def);\n registry.set(def.name, def);\n}\n\nexport function getAccent(name: string): AccentDefinition | undefined {\n return registry.get(name);\n}\n\nexport function listAccents(): AccentDefinition[] {\n return Array.from(registry.values());\n}\n\n// Built-in accents register on import. A consumer's own custom\n// brand accent registers the same way — registerAccent() with a\n// name/label/scale, called from wherever they define it.\nimport { indigo } from \"./accents/indigo\";\nimport { violet } from \"./accents/violet\";\nimport { teal } from \"./accents/teal\";\nimport { rose } from \"./accents/rose\";\nimport { amber } from \"./accents/amber\";\nimport { emerald } from \"./accents/emerald\";\nimport { copper } from \"./accents/copper\";\nimport { graphite } from \"./accents/graphite\";\nimport { magenta } from \"./accents/magenta\";\n\nregisterAccent(indigo);\nregisterAccent(violet);\nregisterAccent(teal);\nregisterAccent(rose);\nregisterAccent(amber);\nregisterAccent(emerald);\nregisterAccent(copper);\nregisterAccent(graphite);\nregisterAccent(magenta);\n\nexport const DEFAULT_ACCENT = \"indigo\";\n","import type { Size } from \"./types\";\n\n// ============================================================\n// Category B (form/input primitives) shared shape.\n//\n// BUILDING-COMPONENTS.md's Category B note: \"Standard props every\n// component in this category should share: value/defaultValue,\n// onChange, disabled, error (or invalid), placeholder where\n// applicable. Decide this shape once, here, rather than letting\n// Input and NumberInput drift (the old color/radius drift, one\n// category up).\" This module is that one decision, applied by\n// every field-based component (Input, Textarea, Checkbox, Radio,\n// Toggle, and any future one) instead of each re-deriving it.\n// ============================================================\n\nexport interface FieldProps {\n disabled?: boolean;\n required?: boolean;\n /** Whether the field is in an invalid/error state. */\n error?: boolean;\n size?: Size;\n}\n\nexport interface FieldState {\n isDisabled: boolean;\n isRequired: boolean;\n isInvalid: boolean;\n size: Size;\n}\n\nexport function resolveFieldState(props: FieldProps): FieldState {\n return {\n // ?? throughout, never || (CONTRACT.md Rule 3) — `error={false}`\n // or `disabled={false}` must not be silently discarded.\n isDisabled: props.disabled ?? false,\n isRequired: props.required ?? false,\n isInvalid: props.error ?? false,\n size: props.size ?? \"md\",\n };\n}\n\n/**\n * Category B's accessibility baseline (BUILDING-COMPONENTS.md):\n * aria-invalid and aria-describedby (for an error/helper message)\n * on every field component, not just the ones an author happened\n * to remember.\n */\nexport function getFieldAriaProps(state: FieldState, describedBy?: string) {\n return {\n \"aria-invalid\": state.isInvalid ? (true as const) : undefined,\n \"aria-required\": state.isRequired ? (true as const) : undefined,\n \"aria-describedby\": describedBy,\n };\n}\n","import { resolveFieldState, getFieldAriaProps, type FieldProps, type FieldState } from \"./field\";\n\n// ============================================================\n// COLOR PICKER — pure core (Category D: Input's field shape +\n// Popover, with the popover panel composing a preset swatch grid and\n// a custom saturation/hue panel — see react/ColorPicker.tsx's own\n// header for why both, rather than the native <input type=\"color\">\n// an earlier version of this file used). This module owns the field\n// concerns: hex normalization/parsing (now including `rgb(...)`/\n// `hsl(...)` function-notation strings, since the field can display\n// either depending on which format tab is active) and swatch/dial\n// classes and ARIA — the same split datepicker.ts draws between\n// \"field concerns\" and the grid widget's own math (there, Calendar's;\n// here, the swatch grid's and the custom panel's).\n// ============================================================\n\nexport type ColorPickerVariant = \"both\" | \"presets\" | \"custom\";\n\nexport interface ColorPickerCoreProps extends FieldProps {\n /** Preset swatches offered in the popover, as hex strings. Defaults to DEFAULT_PRESETS. */\n presets?: string[];\n /**\n * Which part(s) of the popover to show. `\"both\"` (default) is the\n * preset grid plus the custom saturation/hue panel underneath it.\n * `\"presets\"` shows only the grid — a fixed palette with no\n * arbitrary-color escape hatch. `\"custom\"` shows only the\n * saturation/hue panel — no preset shortcuts at all.\n */\n variant?: ColorPickerVariant;\n}\n\nexport interface ColorPickerState extends FieldState {\n presets: string[];\n variant: ColorPickerVariant;\n}\n\nexport const DEFAULT_PRESETS: string[] = [\n \"#ef4444\",\n \"#f97316\",\n \"#f59e0b\",\n \"#eab308\",\n \"#84cc16\",\n \"#22c55e\",\n \"#10b981\",\n \"#14b8a6\",\n \"#06b6d4\",\n \"#3b82f6\",\n \"#6366f1\",\n \"#8b5cf6\",\n \"#a855f7\",\n \"#d946ef\",\n \"#ec4899\",\n \"#6b7280\",\n \"#171717\",\n \"#ffffff\",\n];\n\nexport function resolveColorPickerState(props: ColorPickerCoreProps): ColorPickerState {\n return {\n ...resolveFieldState(props),\n presets: props.presets ?? DEFAULT_PRESETS,\n variant: props.variant ?? \"both\",\n };\n}\n\n// --- hex parsing / normalization -----------------------------------\n\nconst HEX_RE = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;\n\n/** Whether `text` is a recognizable 3- or 6-digit hex color, with or without a leading `#`. */\nexport function isValidHex(text: string): boolean {\n return HEX_RE.test(text.trim());\n}\n\n/**\n * Normalizes any accepted hex input (`\"f00\"`, `\"#f00\"`, `\"ff0000\"`,\n * `\"#FF0000\"`) into a canonical lowercase `#rrggbb` string, or `null`\n * if it isn't a valid hex color at all. The single source of truth\n * every call site (typed-text commit, swatch click, the native color\n * input's own onChange) normalizes through, the same role\n * isDateSelectable/isTimeSelectable play for their fields.\n */\nexport function normalizeHex(text: string): string | null {\n const trimmed = text.trim();\n const match = trimmed.match(HEX_RE);\n if (!match) return null;\n let hex = match[1].toLowerCase();\n if (hex.length === 3) {\n hex = hex\n .split(\"\")\n .map((c) => c + c)\n .join(\"\");\n }\n return `#${hex}`;\n}\n\n/** Whether two hex strings (however formatted) represent the same color. */\nexport function isSameColor(a: string | null | undefined, b: string | null | undefined): boolean {\n if (!a || !b) return a === b;\n const na = normalizeHex(a);\n const nb = normalizeHex(b);\n return na !== null && na === nb;\n}\n\n/** Rough perceived-lightness check, used only to decide a checkmark's contrast color on a selected swatch — not a color-science API. */\nexport function isLightColor(hex: string): boolean {\n const normalized = normalizeHex(hex);\n if (!normalized) return true;\n const r = parseInt(normalized.slice(1, 3), 16);\n const g = parseInt(normalized.slice(3, 5), 16);\n const b = parseInt(normalized.slice(5, 7), 16);\n const luma = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\n return luma > 0.6;\n}\n\n// --- classes ------------------------------------------------------\n\nexport function getSwatchClasses(input: { isSelected: boolean; isActive: boolean }): string {\n return [\n \"nx-colorpicker__swatch-option\",\n input.isSelected && \"nx-colorpicker__swatch-option--selected\",\n input.isActive && \"nx-colorpicker__swatch-option--active\",\n ]\n .filter(Boolean)\n .join(\" \");\n}\n\n// --- ARIA -----------------------------------------------------\n\nexport function getSwatchGridAriaProps(label: string) {\n return { role: \"listbox\" as const, \"aria-label\": label };\n}\n\nexport function getSwatchAriaProps(input: { isSelected: boolean; isFocusable: boolean; label: string }) {\n return {\n role: \"option\" as const,\n \"aria-selected\": input.isSelected,\n \"aria-label\": input.label,\n tabIndex: input.isFocusable ? 0 : -1,\n };\n}\n\nexport function getFieldTriggerAriaProps(state: FieldState, describedBy?: string) {\n return getFieldAriaProps(state, describedBy);\n}\n\n// --- custom panel: color space conversions --------------------------\n// The typed hex field and preset grid only ever need hex in/out, but\n// the custom panel (saturation/value area + hue slider + RGB/HSL\n// fields) needs to move between hex, RGB, HSV, and HSL freely. HSV\n// drives the SV area/hue slider (the natural space for a \"pick a hue,\n// then a shade of it\" 2D control); RGB/HSL are only ever produced for\n// display in their own format tab and round-tripped back through hex\n// on edit, so hex stays the single canonical value ColorPicker's\n// public onChange emits (Rule 10 — the public shape doesn't change).\n\nexport interface RGB {\n r: number;\n g: number;\n b: number;\n}\n\nexport interface HSV {\n h: number;\n s: number;\n v: number;\n}\n\nexport interface HSL {\n h: number;\n s: number;\n l: number;\n}\n\nexport type ColorFormat = \"hex\" | \"rgb\" | \"hsl\";\n\nexport const COLOR_FORMATS: ColorFormat[] = [\"hex\", \"rgb\", \"hsl\"];\n\nfunction clampNum(n: number, min: number, max: number): number {\n return Math.min(Math.max(n, min), max);\n}\n\n/** Hex (any accepted shape, see `normalizeHex`) to 0-255 RGB channels, or `null` if not a valid hex color. */\nexport function hexToRgb(hex: string): RGB | null {\n const normalized = normalizeHex(hex);\n if (!normalized) return null;\n return {\n r: parseInt(normalized.slice(1, 3), 16),\n g: parseInt(normalized.slice(3, 5), 16),\n b: parseInt(normalized.slice(5, 7), 16),\n };\n}/** 0-255 RGB channels (rounded, clamped) to canonical lowercase `#rrggbb`. */\nexport function rgbToHex({ r, g, b }: RGB): string {\n const channel = (n: number) => clampNum(Math.round(n), 0, 255).toString(16).padStart(2, \"0\");\n return `#${channel(r)}${channel(g)}${channel(b)}`;\n}\n\n/** 0-255 RGB to HSV (`h` in 0-360, `s`/`v` in 0-100). */\nexport function rgbToHsv({ r, g, b }: RGB): HSV {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const d = max - min;\n let h = 0;\n if (d !== 0) {\n if (max === rn) h = ((gn - bn) / d) % 6;\n else if (max === gn) h = (bn - rn) / d + 2;\n else h = (rn - gn) / d + 4;\n h *= 60;\n if (h < 0) h += 360;\n }\n const s = max === 0 ? 0 : d / max;\n return { h, s: s * 100, v: max * 100 };\n}\n\n/** HSV (`h` in 0-360, `s`/`v` in 0-100) to 0-255 RGB. */\nexport function hsvToRgb({ h, s, v }: HSV): RGB {\n const s1 = clampNum(s, 0, 100) / 100;\n const v1 = clampNum(v, 0, 100) / 100;\n const hh = (((h % 360) + 360) % 360) / 60;\n const c = v1 * s1;\n const x = c * (1 - Math.abs((hh % 2) - 1));\n const m = v1 - c;\n let [r1, g1, b1] = [0, 0, 0];\n if (hh < 1) [r1, g1, b1] = [c, x, 0];\n else if (hh < 2) [r1, g1, b1] = [x, c, 0];\n else if (hh < 3) [r1, g1, b1] = [0, c, x];\n else if (hh < 4) [r1, g1, b1] = [0, x, c];\n else if (hh < 5) [r1, g1, b1] = [x, 0, c];\n else [r1, g1, b1] = [c, 0, x];\n return { r: (r1 + m) * 255, g: (g1 + m) * 255, b: (b1 + m) * 255 };\n}\n\n/** 0-255 RGB to HSL (`h` in 0-360, `s`/`l` in 0-100). */\nexport function rgbToHsl({ r, g, b }: RGB): HSL {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n const d = max - min;\n let h = 0,\n s = 0;\n if (d !== 0) {\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n if (max === rn) h = ((gn - bn) / d) % 6;\n else if (max === gn) h = (bn - rn) / d + 2;\n else h = (rn - gn) / d + 4;\n h *= 60;\n if (h < 0) h += 360;\n }\n return { h, s: s * 100, l: l * 100 };\n}\n\n/** HSL (`h` in 0-360, `s`/`l` in 0-100) to 0-255 RGB. */\nexport function hslToRgb({ h, s, l }: HSL): RGB {\n const s1 = clampNum(s, 0, 100) / 100;\n const l1 = clampNum(l, 0, 100) / 100;\n const c = (1 - Math.abs(2 * l1 - 1)) * s1;\n const hh = (((h % 360) + 360) % 360) / 60;\n const x = c * (1 - Math.abs((hh % 2) - 1));\n const m = l1 - c / 2;\n let [r1, g1, b1] = [0, 0, 0];\n if (hh < 1) [r1, g1, b1] = [c, x, 0];\n else if (hh < 2) [r1, g1, b1] = [x, c, 0];\n else if (hh < 3) [r1, g1, b1] = [0, c, x];\n else if (hh < 4) [r1, g1, b1] = [0, x, c];\n else if (hh < 5) [r1, g1, b1] = [x, 0, c];\n else [r1, g1, b1] = [c, 0, x];\n return { r: (r1 + m) * 255, g: (g1 + m) * 255, b: (b1 + m) * 255 };\n}\n\n/** Hex to HSV, or `null` if not a valid hex color — the SV-area/hue-slider's read side. */\nexport function hexToHsv(hex: string): HSV | null {\n const rgb = hexToRgb(hex);\n return rgb ? rgbToHsv(rgb) : null;\n}\n\n/** HSV to canonical hex — the SV-area/hue-slider's write side. */\nexport function hsvToHex(hsv: HSV): string {\n return rgbToHex(hsvToRgb(hsv));\n}\n\n/** HSL to canonical hex — the HSL format tab's write side. */\nexport function hslToHex(hsl: HSL): string {\n return rgbToHex(hslToRgb(hsl));\n}\n\n// --- typed-field text: parsing whichever format is on screen, and\n// producing that format back out --------------------------------\n// The field's displayed text now follows whichever format tab is\n// active in the custom panel (hex/rgb/hsl) rather than always\n// showing hex, so it needs to accept typed `rgb(...)`/`hsla(...)`\n// text back, not just hex — otherwise a person editing the field\n// while \"RGB\" is selected would have their own format rejected.\n\nconst RGB_FUNCTION_RE = /^rgba?\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*(?:,\\s*[\\d.]+\\s*)?\\)$/i;\nconst HSL_FUNCTION_RE = /^hsla?\\(\\s*(-?\\d{1,3})\\s*,\\s*(\\d{1,3})%\\s*,\\s*(\\d{1,3})%\\s*(?:,\\s*[\\d.]+\\s*)?\\)$/i;\n\n/** Parses hex OR `rgb(a)(...)`/`hsl(a)(...)` function-notation text into normalized hex, or `null` if it's none of those. */\nexport function parseColorInput(text: string): string | null {\n const trimmed = text.trim();\n const hex = normalizeHex(trimmed);\n if (hex) return hex;\n\n const rgbMatch = trimmed.match(RGB_FUNCTION_RE);\n if (rgbMatch) {\n const [, r, g, b] = rgbMatch;\n return rgbToHex({ r: clampNum(Number(r), 0, 255), g: clampNum(Number(g), 0, 255), b: clampNum(Number(b), 0, 255) });\n }\n\n const hslMatch = trimmed.match(HSL_FUNCTION_RE);\n if (hslMatch) {\n const [, h, s, l] = hslMatch;\n return hslToHex({ h: clampNum(Number(h), 0, 360), s: clampNum(Number(s), 0, 100), l: clampNum(Number(l), 0, 100) });\n }\n\n return null;\n}\n\n/** Renders hex as text in the given format — the field's display-side counterpart to `parseColorInput`, so what's shown always matches whichever format tab is currently active. */\nexport function formatColorValue(hex: string, format: ColorFormat): string {\n if (format === \"hex\") return hex;\n const rgb = hexToRgb(hex);\n if (!rgb) return hex;\n if (format === \"rgb\") return `rgb(${Math.round(rgb.r)}, ${Math.round(rgb.g)}, ${Math.round(rgb.b)})`;\n const hsl = rgbToHsl(rgb);\n return `hsl(${Math.round(hsl.h)}, ${Math.round(hsl.s)}%, ${Math.round(hsl.l)}%)`;\n}\n\n/** Arrow-key deltas for the 2D saturation/value area (Shift for a larger step) — Home/End/PageUp/PageDown aren't meaningful on a 2D surface, so only the four arrows are handled, same spirit as Slider's own keyboard set restricted to what the control actually has. */\nexport function getSvKeyboardDelta(key: string, coarse: boolean): { ds: number; dv: number } | null {\n const step = coarse ? 10 : 2;\n switch (key) {\n case \"ArrowLeft\":\n return { ds: -step, dv: 0 };\n case \"ArrowRight\":\n return { ds: step, dv: 0 };\n case \"ArrowUp\":\n return { ds: 0, dv: step };\n case \"ArrowDown\":\n return { ds: 0, dv: -step };\n default:\n return null;\n }\n}\n\n/** Clamps a saturation or value percentage into 0-100. Exported so the SV area's pointer/keyboard handlers share one clamp rather than each re-deriving it. */\nexport function clampPercent(n: number): number {\n return clampNum(n, 0, 100);\n}\n\n// --- custom panel: classes / ARIA -----------------------------------\n\nexport function getFormatTabClasses(isActive: boolean): string {\n return [\"nx-colorpicker__format-tab\", isActive && \"nx-colorpicker__format-tab--active\"].filter(Boolean).join(\" \");\n}\n\nexport function getFormatTablistAriaProps(label: string) {\n return { role: \"tablist\" as const, \"aria-label\": label };\n}\n\nexport function getFormatTabAriaProps(isActive: boolean) {\n return { role: \"tab\" as const, \"aria-selected\": isActive, tabIndex: isActive ? 0 : -1 };\n}\n\nexport function getSvThumbAriaProps(saturation: number, value: number) {\n return {\n role: \"slider\" as const,\n \"aria-label\": \"Color saturation and brightness\",\n \"aria-valuetext\": `Saturation ${Math.round(saturation)}%, brightness ${Math.round(value)}%`,\n tabIndex: 0,\n };\n}","import type { Size } from \"./types\";\n\n// ============================================================\n// TABLE — pure core (Category F: complex/stateful).\n//\n// Per BUILDING-COMPONENTS.md's own note for this component: \"sort\n// state should be lifted to props the consumer can control, not\n// trapped inside the component\" — the same controlled-value shape\n// Input/Slider/NumberInput already use. Table itself holds no sort\n// or selection state; TableHead's `sortDirection` is a prop the\n// consumer supplies, and getNextSortDirection is exported so the\n// consumer's onSort handler doesn't have to reinvent the standard\n// asc → desc → unsorted cycle. Row SELECTION is intentionally not\n// modeled here at all — TableRow just renders whatever `selected`\n// boolean it's given, and a table with checkboxes composes the real\n// Checkbox component (Rule 12) rather than Table reimplementing a\n// second one. getSelectAllState is the one piece of selection logic\n// that's genuinely shared/non-trivial (the tri-state \"select all\"\n// checkbox's own state, computed from a count) — pulled out here so\n// it's unit-tested the same way everything else pure is.\n// ============================================================\n\nexport interface TableCoreProps {\n size?: Size;\n /** Alternating row background. Default false. */\n striped?: boolean;\n /** Borders around every cell, not just horizontal row rules. Default false. */\n bordered?: boolean;\n /** Keeps the header visible while the body scrolls — only has something to stick within if an ancestor bounds the table's height (e.g. a wrapping div with max-height). Default false. */\n stickyHeader?: boolean;\n}\n\nexport interface TableState {\n size: Size;\n striped: boolean;\n bordered: boolean;\n stickyHeader: boolean;\n}\n\nexport function resolveTableState(props: TableCoreProps): TableState {\n return {\n size: props.size ?? \"md\",\n striped: props.striped ?? false,\n bordered: props.bordered ?? false,\n stickyHeader: props.stickyHeader ?? false,\n };\n}\n\nexport function getWrapperClasses(className?: string): string {\n return [\"nx-table-wrapper\", className].filter(Boolean).join(\" \");\n}\n\nexport function getTableClasses(state: TableState, className?: string): string {\n return [\n \"nx-table\",\n `nx-table--${state.size}`,\n state.striped && \"nx-table--striped\",\n state.bordered && \"nx-table--bordered\",\n state.stickyHeader && \"nx-table--sticky-header\",\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n}\n\nexport function getRowClasses(selected: boolean, clickable: boolean, className?: string): string {\n return [\n \"nx-table__row\",\n selected && \"nx-table__row--selected\",\n clickable && \"nx-table__row--clickable\",\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n}\n\nexport function getHeadCellClasses(sortable: boolean, className?: string): string {\n return [\"nx-table__head-cell\", sortable && \"nx-table__head-cell--sortable\", className].filter(Boolean).join(\" \");\n}\n\nexport function getCellClasses(className?: string): string {\n return [\"nx-table__cell\", className].filter(Boolean).join(\" \");\n}\n\n// --- Sorting ----------------------------------------------------\n\nexport type SortDirection = \"asc\" | \"desc\" | null;\n\n/** The conventional 3-state cycle a sortable header click steps through: unsorted → asc → desc → unsorted. */\nexport function getNextSortDirection(current: SortDirection): SortDirection {\n if (current === null) return \"asc\";\n if (current === \"asc\") return \"desc\";\n return null;\n}\n\nexport function getSortAriaProps(direction: SortDirection) {\n return {\n \"aria-sort\":\n direction === \"asc\" ? (\"ascending\" as const) : direction === \"desc\" ? (\"descending\" as const) : (\"none\" as const),\n };\n}\n\n// --- Selection ----------------------------------------------------\n\nexport type SelectAllState = \"none\" | \"some\" | \"all\";\n\n/** The tri-state a \"select all\" header checkbox should show, computed from how many of the total rows are currently selected. */\nexport function getSelectAllState(totalCount: number, selectedCount: number): SelectAllState {\n if (totalCount <= 0 || selectedCount <= 0) return \"none\";\n if (selectedCount >= totalCount) return \"all\";\n return \"some\";\n}","// ============================================================\r\n// CODE-HIGHLIGHT — shared primitive (like floating.ts / collection.ts),\r\n// not owned by CodeBlock alone. Two responsibilities:\r\n//\r\n// 1. A tiny rule-based tokenizer (`nuvoxHighlight`) covering a\r\n// CURATED set of common languages. This is deliberately NOT a\r\n// real parser — no AST, no language-server-grade accuracy. It's\r\n// the same \"ordered regex rules, first match wins\" technique\r\n// Prism/highlight.js use, scoped down to what a doc-site/component\r\n// library actually needs — pushed further than a first pass\r\n// (regex-literal disambiguation, template-literal interpolation,\r\n// decorators, CSS pseudo-classes/custom properties, Python\r\n// f-strings) but still not chasing full-grammar accuracy.\r\n// Anything outside the curated list (or any pattern a grammar\r\n// doesn't anticipate) safely degrades to unhighlighted plain\r\n// text — it never throws.\r\n//\r\n// 2. The `HighlightEngine` escape hatch: CodeBlock's `highlighter`\r\n// prop accepts any function matching this exact signature. A\r\n// consumer who needs full-language, TextMate-grade accuracy can\r\n// wire in Shiki/Prism themselves — this file, and Nuvox, never\r\n// import one.\r\n//\r\n// Zero runtime dependencies: plain RegExp only.\r\n// ============================================================\r\n\r\nexport interface CodeToken {\r\n type: string;\r\n content: string;\r\n}\r\n\r\nexport type CodeLine = CodeToken[];\r\n\r\n/**\r\n * The shape any tokenizer must satisfy to plug into CodeBlock via its\r\n * `highlighter` prop — including `nuvoxHighlight` itself. A consumer\r\n * wiring in Shiki/Prism just needs to adapt that engine's output to\r\n * this shape once.\r\n */\r\nexport type HighlightEngine = (code: string, language: string) => CodeLine[];\r\n\r\ninterface GrammarRule {\r\n type: string;\r\n /** Must use the sticky (\"y\") flag, never \"g\" — see tokenizeFlat(). */\r\n pattern?: RegExp;\r\n /**\r\n * Escape hatch for the handful of cases a single regex genuinely\r\n * can't express: template-literal interpolation (needs to\r\n * recursively tokenize an arbitrary-depth `${...}` expression) and\r\n * regex-literal-vs-division disambiguation (needs to look at the\r\n * PREVIOUS token, which a stateless regex can't do). Returns the\r\n * number of source characters consumed and the token(s) to emit,\r\n * or null if this rule doesn't apply at `index`.\r\n */\r\n match?: (source: string, index: number, tokensSoFar: CodeToken[]) => { length: number; tokens: CodeToken[] } | null;\r\n}\r\n\r\ninterface Grammar {\r\n rules: GrammarRule[];\r\n}\r\n\r\n// ---- the tokenizer loop -----------------------------------------\r\n\r\n/**\r\n * Walks `source` left to right. At each position, tries every rule in\r\n * order and takes the first one that matches AT that exact position\r\n * (order = precedence, not \"longest match\" — this is why comments and\r\n * strings are always listed before keywords in every grammar below:\r\n * `// return` must not tokenize \"return\" as a keyword).\r\n *\r\n * Anything no rule matches is consumed one character at a time as a\r\n * \"plain\" token (merged with any preceding plain token) — this is\r\n * what makes the whole thing safe to run on code with syntax the\r\n * grammar never anticipated: it degrades to unstyled text instead of\r\n * throwing or mis-highlighting.\r\n */\r\nfunction tokenizeFlat(source: string, grammar: Grammar): CodeToken[] {\r\n const tokens: CodeToken[] = [];\r\n const n = source.length;\r\n let i = 0;\r\n\r\n outer: while (i < n) {\r\n for (const rule of grammar.rules) {\r\n if (rule.pattern) {\r\n rule.pattern.lastIndex = i;\r\n const m = rule.pattern.exec(source);\r\n if (m && m.index === i && m[0].length > 0) {\r\n tokens.push({ type: rule.type, content: m[0] });\r\n i += m[0].length;\r\n continue outer;\r\n }\r\n } else if (rule.match) {\r\n const result = rule.match(source, i, tokens);\r\n if (result && result.length > 0) {\r\n tokens.push(...result.tokens);\r\n i += result.length;\r\n continue outer;\r\n }\r\n }\r\n }\r\n const ch = source[i];\r\n const last = tokens[tokens.length - 1];\r\n if (last && last.type === \"plain\") last.content += ch;\r\n else tokens.push({ type: \"plain\", content: ch });\r\n i++;\r\n }\r\n\r\n return tokens;\r\n}\r\n\r\n/**\r\n * Splits a flat token stream into per-line arrays, breaking multi-line\r\n * tokens (block comments, template literals, triple-quoted strings)\r\n * at their internal newlines so each line's tokens can be rendered\r\n * independently (line numbers, per-line highlighting).\r\n */\r\nfunction splitIntoLines(tokens: CodeToken[]): CodeLine[] {\r\n const lines: CodeLine[] = [[]];\r\n for (const tok of tokens) {\r\n const parts = tok.content.split(\"\\n\");\r\n parts.forEach((part, idx) => {\r\n if (part.length > 0) lines[lines.length - 1].push({ type: tok.type, content: part });\r\n if (idx < parts.length - 1) lines.push([]);\r\n });\r\n }\r\n return lines;\r\n}\r\n\r\nconst KEYWORD = (words: string) => new RegExp(`\\\\b(?:${words})\\\\b`, \"y\");\r\n\r\n// ---- custom matchers shared by JS/TS/JSX/TSX ------------------------\r\n\r\n/**\r\n * Template literals need special handling a single regex can't do:\r\n * `${...}` interpolations can nest arbitrarily deep and contain\r\n * completely arbitrary JS, which should itself be highlighted (an\r\n * interpolated `${user.name}` should color `user`/`name` normally,\r\n * not render as inert string text). This scans the literal by hand,\r\n * recursing into tokenizeFlat for each interpolation's contents.\r\n */\r\nfunction matchTemplateLiteral(\r\n source: string,\r\n start: number,\r\n jsGrammar: Grammar\r\n): { length: number; tokens: CodeToken[] } | null {\r\n if (source[start] !== \"`\") return null;\r\n\r\n const tokens: CodeToken[] = [{ type: \"string\", content: \"`\" }];\r\n let i = start + 1;\r\n let buf = \"\";\r\n const flush = () => {\r\n if (buf) {\r\n tokens.push({ type: \"string\", content: buf });\r\n buf = \"\";\r\n }\r\n };\r\n\r\n while (i < source.length) {\r\n const ch = source[i];\r\n if (ch === \"\\\\\" && i + 1 < source.length) {\r\n buf += ch + source[i + 1];\r\n i += 2;\r\n continue;\r\n }\r\n if (ch === \"`\") {\r\n flush();\r\n tokens.push({ type: \"string\", content: \"`\" });\r\n i++;\r\n return { length: i - start, tokens };\r\n }\r\n if (ch === \"$\" && source[i + 1] === \"{\") {\r\n flush();\r\n tokens.push({ type: \"punctuation\", content: \"${\" });\r\n i += 2;\r\n const exprStart = i;\r\n let depth = 1;\r\n while (i < source.length && depth > 0) {\r\n if (source[i] === \"{\") depth++;\r\n else if (source[i] === \"}\") depth--;\r\n if (depth > 0) i++;\r\n }\r\n const exprSource = source.slice(exprStart, i);\r\n tokens.push(...tokenizeFlat(exprSource, jsGrammar));\r\n if (i < source.length) {\r\n tokens.push({ type: \"punctuation\", content: \"}\" });\r\n i++;\r\n }\r\n continue;\r\n }\r\n buf += ch;\r\n i++;\r\n }\r\n\r\n // Unterminated template literal (adversarial/malformed input) — flush\r\n // what we have rather than throwing or scanning past the end.\r\n flush();\r\n return { length: i - start, tokens };\r\n}\r\n\r\nconst REGEX_EXPRESSION_KEYWORDS = new Set([\r\n \"return\", \"typeof\", \"instanceof\", \"in\", \"of\", \"new\", \"delete\", \"void\", \"throw\", \"case\", \"do\", \"else\", \"yield\", \"await\",\r\n]);\r\n\r\n/**\r\n * `/` is ambiguous in JS: division (`a / b`) vs. a regex literal\r\n * (`/ab+c/gi`). A stateless regex can't tell these apart — it depends\r\n * on what came before. Heuristic, based on the last non-whitespace\r\n * SOURCE CHARACTER (not the last emitted token — this grammar doesn't\r\n * tokenize every operator into its own type, so `=`, `+`, `<` etc.\r\n * all end up folded into generic \"plain\" tokens alongside identifier\r\n * text, which made a token-type-based version of this check\r\n * indistinguishable between \"after `x`\" and \"after `=`\"): a regex is\r\n * only valid where an EXPRESSION is expected, i.e. NOT immediately\r\n * after an identifier/number, `)`, `]`, or a closing quote — all of\r\n * which mean the previous thing was a complete value, so `/` must be\r\n * division — UNLESS that preceding word is itself an\r\n * expression-position keyword (`return /foo/`, `typeof /foo/`, ...).\r\n */\r\nfunction matchRegexLiteral(source: string, start: number): { length: number; tokens: CodeToken[] } | null {\r\n if (source[start] !== \"/\" || source[start + 1] === \"/\" || source[start + 1] === \"*\") return null;\r\n\r\n let j = start - 1;\r\n while (j >= 0 && /\\s/.test(source[j])) j--;\r\n if (j >= 0) {\r\n const prevChar = source[j];\r\n const looksLikeValueEnd = /[)\\]}\\w$]/.test(prevChar) || prevChar === '\"' || prevChar === \"'\" || prevChar === \"`\";\r\n if (looksLikeValueEnd) {\r\n const wordBefore = source.slice(0, j + 1).match(/([A-Za-z_$][\\w$]*)$/)?.[1];\r\n if (!(wordBefore && REGEX_EXPRESSION_KEYWORDS.has(wordBefore))) return null;\r\n }\r\n }\r\n\r\n let i = start + 1;\r\n let inClass = false;\r\n while (i < source.length) {\r\n const ch = source[i];\r\n if (ch === \"\\\\\") {\r\n i += 2;\r\n continue;\r\n }\r\n if (ch === \"\\n\") return null; // regex literals never span lines — bail to \"division\" reading\r\n if (ch === \"[\") inClass = true;\r\n else if (ch === \"]\") inClass = false;\r\n else if (ch === \"/\" && !inClass) {\r\n i++;\r\n break;\r\n }\r\n i++;\r\n }\r\n if (source[i - 1] !== \"/\") return null; // never found a closing slash\r\n\r\n while (i < source.length && /[a-z]/i.test(source[i])) i++;\r\n return { length: i - start, tokens: [{ type: \"regex\", content: source.slice(start, i) }] };\r\n}\r\n\r\nfunction buildJsGrammar(withTags: boolean): Grammar {\r\n const grammar: Grammar = { rules: [] };\r\n const rules = grammar.rules;\r\n\r\n if (withTags) {\r\n rules.push({ type: \"tag\", pattern: /<\\/?[A-Za-z][\\w.-]*/y });\r\n }\r\n\r\n rules.push(\r\n { type: \"comment\", pattern: /\\/\\/[^\\n]*|\\/\\*[\\s\\S]*?\\*\\//y },\r\n { type: \"string\", pattern: /\"(?:[^\"\\\\\\n]|\\\\.)*\"|'(?:[^'\\\\\\n]|\\\\.)*'/y },\r\n { type: \"custom-template\", match: (src, idx) => matchTemplateLiteral(src, idx, grammar) },\r\n { type: \"custom-regex\", match: (src, idx) => matchRegexLiteral(src, idx) },\r\n { type: \"decorator\", pattern: /@[A-Za-z_$][\\w$]*/y },\r\n { type: \"boolean\", pattern: KEYWORD(\"true|false|null|undefined\") },\r\n {\r\n type: \"keyword\",\r\n pattern: KEYWORD(\r\n \"const|let|var|function|return|if|else|for|while|do|switch|case|default|break|continue|\" +\r\n \"class|extends|super|new|this|typeof|instanceof|in|of|try|catch|finally|throw|async|await|\" +\r\n \"yield|import|export|from|as|void|delete|static|get|set|\" +\r\n \"interface|type|enum|implements|public|private|protected|readonly|namespace|declare|\" +\r\n \"abstract|is|keyof|infer|satisfies\"\r\n ),\r\n },\r\n {\r\n type: \"builtin\",\r\n pattern: KEYWORD(\r\n \"console|Math|JSON|Promise|Array|Object|Map|Set|WeakMap|WeakSet|String|Number|Boolean|Symbol|\" +\r\n \"Error|Date|RegExp|Reflect|Proxy|globalThis|Infinity|NaN|BigInt|fetch|localStorage|sessionStorage\"\r\n ),\r\n },\r\n { type: \"number\", pattern: /\\b0[xX][0-9a-fA-F]+\\b|\\b\\d+\\.?\\d*(?:[eE][+-]?\\d+)?n?\\b/y },\r\n { type: \"function\", pattern: /[A-Za-z_$][\\w$]*(?=\\s*\\()/y },\r\n { type: \"punctuation\", pattern: /[{}()[\\];,.:?]/y }\r\n );\r\n return grammar;\r\n}\r\n\r\nconst jsGrammar = buildJsGrammar(false);\r\nconst jsxGrammar = buildJsGrammar(true);\r\n\r\nconst jsonGrammar: Grammar = {\r\n rules: [\r\n { type: \"string\", pattern: /\"(?:[^\"\\\\\\n]|\\\\.)*\"/y },\r\n { type: \"boolean\", pattern: KEYWORD(\"true|false|null\") },\r\n { type: \"number\", pattern: /-?\\b\\d+\\.?\\d*(?:[eE][+-]?\\d+)?\\b/y },\r\n { type: \"punctuation\", pattern: /[{}[\\]:,]/y },\r\n ],\r\n};\r\n\r\nconst cssGrammar: Grammar = {\r\n rules: [\r\n { type: \"comment\", pattern: /\\/\\*[\\s\\S]*?\\*\\//y },\r\n { type: \"string\", pattern: /\"(?:[^\"\\\\\\n]|\\\\.)*\"|'(?:[^'\\\\\\n]|\\\\.)*'/y },\r\n { type: \"keyword\", pattern: /!important\\b/y },\r\n { type: \"atrule\", pattern: /@[a-zA-Z-]+/y },\r\n // Custom-property declarations/usage (--brand-color, var(--x)) —\r\n // checked before the generic hex-color/selector rules below.\r\n { type: \"variable\", pattern: /--[a-zA-Z_][\\w-]*/y },\r\n { type: \"function\", pattern: /\\b(?:var|calc|rgba?|hsla?|clamp|minmax|repeat|url|translate[XYZ]?|rotate[XYZ]?|scale[XYZ]?|linear-gradient|radial-gradient)(?=\\()/y },\r\n // Pseudo-classes/elements (:hover, ::before) before the plain \":\" punctuation.\r\n { type: \"pseudo\", pattern: /::?[a-zA-Z-]+/y },\r\n // Hex colors before the generic \"#name\" id-selector pattern below.\r\n { type: \"builtin\", pattern: /#[0-9a-fA-F]{3,8}\\b/y },\r\n { type: \"selector\", pattern: /[.#][a-zA-Z_-][\\w-]*/y },\r\n { type: \"property\", pattern: /[a-zA-Z-]+(?=\\s*:)/y },\r\n { type: \"number\", pattern: /-?\\d+\\.?\\d*(?:px|em|rem|%|vh|vw|s|ms|deg|fr)?\\b/y },\r\n { type: \"punctuation\", pattern: /[{}:;,()]/y },\r\n ],\r\n};\r\n\r\nconst htmlGrammar: Grammar = {\r\n rules: [\r\n { type: \"comment\", pattern: /<!--[\\s\\S]*?-->/y },\r\n { type: \"keyword\", pattern: /<!DOCTYPE[^>]*>/iy },\r\n { type: \"tag\", pattern: /<\\/?[a-zA-Z][\\w:-]*/y },\r\n { type: \"attrName\", pattern: /[a-zA-Z-]+(?=\\s*=)/y },\r\n { type: \"string\", pattern: /\"(?:[^\"\\\\\\n]|\\\\.)*\"|'(?:[^'\\\\\\n]|\\\\.)*'/y },\r\n { type: \"builtin\", pattern: /&[a-zA-Z#0-9]+;/y },\r\n { type: \"punctuation\", pattern: /[<>=/]/y },\r\n ],\r\n};\r\n\r\nconst bashGrammar: Grammar = {\r\n rules: [\r\n { type: \"comment\", pattern: /#[^\\n]*/y },\r\n { type: \"string\", pattern: /\"(?:[^\"\\\\\\n]|\\\\.)*\"|'[^'\\n]*'/y },\r\n { type: \"variable\", pattern: /\\$\\{?\\w+\\}?/y },\r\n {\r\n type: \"keyword\",\r\n pattern: KEYWORD(\r\n \"if|then|else|elif|fi|for|do|done|while|case|esac|function|return|exit|export|local|\" +\r\n \"echo|cd|sudo|npm|yarn|pnpm|git|mkdir|rm|cp|mv|cat|grep|sed|awk\"\r\n ),\r\n },\r\n { type: \"number\", pattern: /\\b\\d+\\b/y },\r\n { type: \"function\", pattern: /(?<=^|\\s)--?[a-zA-Z][\\w-]*/y },\r\n { type: \"punctuation\", pattern: /[|&;()]/y },\r\n ],\r\n};\r\n\r\nconst pythonGrammar: Grammar = {\r\n rules: [\r\n { type: \"comment\", pattern: /#[^\\n]*/y },\r\n { type: \"decorator\", pattern: /@[A-Za-z_][\\w.]*/y },\r\n {\r\n // f/r/b/u string prefixes (f\"...\", rb'...', etc.) before plain strings.\r\n type: \"string\",\r\n pattern: /[rRbBfFuU]{0,2}(?:\"\"\"[\\s\\S]*?\"\"\"|'''[\\s\\S]*?'''|\"(?:[^\"\\\\\\n]|\\\\.)*\"|'(?:[^'\\\\\\n]|\\\\.)*')/y,\r\n },\r\n { type: \"boolean\", pattern: KEYWORD(\"True|False|None\") },\r\n {\r\n type: \"keyword\",\r\n pattern: KEYWORD(\r\n \"def|return|if|elif|else|for|while|in|not|and|or|is|import|from|as|class|try|except|\" +\r\n \"finally|raise|with|lambda|yield|pass|break|continue|global|nonlocal|assert|del|\" +\r\n \"async|await|self\"\r\n ),\r\n },\r\n { type: \"builtin\", pattern: KEYWORD(\"print|len|range|str|int|float|list|dict|set|tuple|type|isinstance|super|open|input|enumerate|zip|map|filter|sorted|sum|min|max|any|all\") },\r\n { type: \"number\", pattern: /\\b\\d+\\.?\\d*\\b/y },\r\n { type: \"function\", pattern: /[A-Za-z_]\\w*(?=\\s*\\()/y },\r\n { type: \"punctuation\", pattern: /[:,.()[\\]{}]/y },\r\n ],\r\n};\r\n\r\nconst markdownGrammar: Grammar = {\r\n rules: [\r\n { type: \"comment\", pattern: /```[\\s\\S]*?```/y },\r\n { type: \"keyword\", pattern: /^#{1,6}[^\\n]*/my },\r\n { type: \"punctuation\", pattern: /^(?:-{3,}|\\*{3,}|_{3,})$/my },\r\n { type: \"function\", pattern: /`[^`\\n]+`/y },\r\n { type: \"builtin\", pattern: /\\*\\*[^*\\n]+\\*\\*/y },\r\n { type: \"variable\", pattern: /~~[^~\\n]+~~/y },\r\n { type: \"string\", pattern: /\\*[^*\\n]+\\*/y },\r\n { type: \"tag\", pattern: /!?\\[[^\\]\\n]*\\]\\([^)\\n]*\\)/y },\r\n { type: \"punctuation\", pattern: /^[-*+]\\s|^\\d+\\.\\s/my },\r\n ],\r\n};\r\n\r\nconst yamlGrammar: Grammar = {\r\n rules: [\r\n { type: \"comment\", pattern: /#[^\\n]*/y },\r\n { type: \"property\", pattern: /^[ \\t]*[\\w.-]+(?=\\s*:)/my },\r\n { type: \"string\", pattern: /\"(?:[^\"\\\\\\n]|\\\\.)*\"|'[^'\\n]*'/y },\r\n { type: \"boolean\", pattern: KEYWORD(\"true|false|null|yes|no|on|off|True|False|Null\") },\r\n { type: \"number\", pattern: /-?\\b\\d+\\.?\\d*\\b/y },\r\n { type: \"variable\", pattern: /[&*][\\w-]+/y },\r\n { type: \"punctuation\", pattern: /[:\\-[\\]{},]/y },\r\n ],\r\n};\r\n\r\nconst sqlGrammar: Grammar = {\r\n rules: [\r\n { type: \"comment\", pattern: /--[^\\n]*|\\/\\*[\\s\\S]*?\\*\\//y },\r\n { type: \"string\", pattern: /'(?:[^'\\\\\\n]|\\\\.)*'/y },\r\n {\r\n type: \"keyword\",\r\n pattern: new RegExp(\r\n \"\\\\b(?:SELECT|FROM|WHERE|INSERT|INTO|VALUES|UPDATE|SET|DELETE|CREATE|TABLE|ALTER|DROP|\" +\r\n \"JOIN|INNER|LEFT|RIGHT|OUTER|ON|GROUP|BY|ORDER|HAVING|LIMIT|OFFSET|AS|AND|OR|NOT|NULL|\" +\r\n \"IS|IN|LIKE|BETWEEN|DISTINCT|UNION|ALL|EXISTS|CASE|WHEN|THEN|ELSE|END|PRIMARY|KEY|\" +\r\n \"FOREIGN|REFERENCES|DEFAULT|CONSTRAINT|INDEX|VIEW|WITH)\\\\b\",\r\n \"iy\"\r\n ),\r\n },\r\n { type: \"number\", pattern: /\\b\\d+\\.?\\d*\\b/y },\r\n { type: \"function\", pattern: /\\b[A-Za-z_]\\w*(?=\\s*\\()/y },\r\n { type: \"punctuation\", pattern: /[(),;.*=<>!]/y },\r\n ],\r\n};\r\n\r\nconst GRAMMARS: Record<string, Grammar> = {\r\n javascript: jsGrammar,\r\n typescript: jsGrammar,\r\n jsx: jsxGrammar,\r\n tsx: jsxGrammar,\r\n json: jsonGrammar,\r\n css: cssGrammar,\r\n html: htmlGrammar,\r\n bash: bashGrammar,\r\n python: pythonGrammar,\r\n markdown: markdownGrammar,\r\n yaml: yamlGrammar,\r\n sql: sqlGrammar,\r\n};\r\n\r\n/** Aliases → canonical grammar key. Anything not listed here (and not\r\n * a canonical key itself) falls back to plain, unhighlighted text. */\r\nconst ALIASES: Record<string, string> = {\r\n js: \"javascript\",\r\n mjs: \"javascript\",\r\n cjs: \"javascript\",\r\n ts: \"typescript\",\r\n sh: \"bash\",\r\n shell: \"bash\",\r\n zsh: \"bash\",\r\n py: \"python\",\r\n md: \"markdown\",\r\n htm: \"html\",\r\n yml: \"yaml\",\r\n};\r\n\r\n/** Human-readable labels for CodeBlock's default header — overridable via the `filename` prop. */\r\nexport const LANGUAGE_LABELS: Record<string, string> = {\r\n javascript: \"JavaScript\",\r\n typescript: \"TypeScript\",\r\n jsx: \"JSX\",\r\n tsx: \"TSX\",\r\n json: \"JSON\",\r\n css: \"CSS\",\r\n html: \"HTML\",\r\n bash: \"Shell\",\r\n python: \"Python\",\r\n markdown: \"Markdown\",\r\n yaml: \"YAML\",\r\n sql: \"SQL\",\r\n plaintext: \"Plain text\",\r\n};\r\n\r\nfunction normalizeLanguage(language: string): string {\r\n const lower = language.trim().toLowerCase();\r\n return ALIASES[lower] ?? lower;\r\n}\r\n\r\n/**\r\n * The built-in, zero-dependency highlighter. Unknown languages (and\r\n * any grammar that somehow throws on malformed/adversarial input)\r\n * degrade to a single unhighlighted \"plain\" token per line rather\r\n * than surfacing an error — see this module's header for why that's\r\n * the deliberate scope boundary here rather than expanding grammar\r\n * coverage indefinitely.\r\n */\r\nexport const nuvoxHighlight: HighlightEngine = (code, language) => {\r\n const key = normalizeLanguage(language ?? \"plaintext\");\r\n const grammar = GRAMMARS[key];\r\n if (!grammar) return splitIntoLines([{ type: \"plain\", content: code }]);\r\n try {\r\n return splitIntoLines(tokenizeFlat(code, grammar));\r\n } catch {\r\n return splitIntoLines([{ type: \"plain\", content: code }]);\r\n }\r\n};\r\n\r\nexport { normalizeLanguage };\r\n","// ============================================================\r\n// RICH-TEXT — the largest component in the library by design\r\n// surface, scoped down deliberately (see project chat history this\r\n// was designed in). This is NOT a ProseMirror-style document model:\r\n// no schema, no plugin system, no collaborative editing. It's a\r\n// contentEditable + Selection/Range layer covering the common\r\n// denominator of every popular WYSIWYG toolbar (bold/italic/\r\n// underline/strike/code, headings, blockquote, lists, links) —\r\n// closer to Quill/Mantine-RTE's ambition than to Tiptap/ProseMirror's.\r\n//\r\n// Deliberately NOT using document.execCommand — deprecated and\r\n// inconsistent across browsers. Every mutation below is direct\r\n// Selection/Range/DOM manipulation instead, which is why these\r\n// functions can live here (no React/JSX) rather than in the .tsx\r\n// layer: they only need web-platform DOM APIs, the same class of\r\n// dependency core/calendar.ts already takes on Intl/Date. A future\r\n// Vue/Svelte adapter reuses every function in this file unchanged.\r\n//\r\n// Known, deliberate v1 scope limits (documented rather than silently\r\n// broken):\r\n// - List creation/removal operates one block at a time — selecting\r\n// three paragraphs and listifying them doesn't yet merge them\r\n// into a single <ul>.\r\n// - Nested/overlapping marks in complex selections aren't\r\n// guaranteed to unwrap perfectly; the common case (a selection\r\n// fully inside one mark, or none) is what's tested and relied on.\r\n// - \"Type-then-format\" (toggle a mark with the cursor collapsed, so\r\n// it applies to what you type NEXT) works via an invisible\r\n// zero-width-space caret marker inserted at the cursor — the same\r\n// technique small hand-rolled contentEditable editors commonly\r\n// use in place of the browser's native (execCommand-only) typing\r\n// state. If a mark is toggled on and the user never types\r\n// anything before moving on, an empty marked element with just\r\n// that invisible character can linger in the DOM — harmless\r\n// (invisible, produces no visible artifact) but real markup\r\n// clutter if untouched, which is why RichTextEditor sweeps them\r\n// on blur via `stripEmptyMarkers` before the value is read.\r\n// ============================================================\r\n\r\nimport type { Size } from \"./types\";\r\n\r\n// ---- command model ------------------------------------------------\r\n\r\nexport type RichTextMark = \"bold\" | \"italic\" | \"underline\" | \"strike\" | \"code\";\r\nexport type RichTextBlock = \"paragraph\" | \"h1\" | \"h2\" | \"h3\" | \"blockquote\" | \"bulletList\" | \"orderedList\";\r\nexport type RichTextCommand =\r\n | RichTextMark\r\n | RichTextBlock\r\n | \"link\"\r\n | \"unlink\"\r\n | \"textColor\"\r\n | \"clearTextColor\"\r\n | \"highlight\"\r\n | \"clearHighlight\";\r\n\r\nexport const MARK_TAGS: Record<RichTextMark, string> = {\r\n bold: \"STRONG\",\r\n italic: \"EM\",\r\n underline: \"U\",\r\n strike: \"S\",\r\n code: \"CODE\",\r\n};\r\n\r\nexport const BLOCK_TAGS: Record<RichTextBlock, string> = {\r\n paragraph: \"P\",\r\n h1: \"H1\",\r\n h2: \"H2\",\r\n h3: \"H3\",\r\n blockquote: \"BLOCKQUOTE\",\r\n bulletList: \"UL\",\r\n orderedList: \"OL\",\r\n};\r\n\r\nconst BLOCK_TAG_NAMES = new Set([\"P\", \"H1\", \"H2\", \"H3\", \"BLOCKQUOTE\", \"DIV\"]);\r\n\r\nexport function isMark(command: RichTextCommand): command is RichTextMark {\r\n return command in MARK_TAGS;\r\n}\r\n\r\nexport function isBlock(command: RichTextCommand): command is RichTextBlock {\r\n return command in BLOCK_TAGS;\r\n}\r\n\r\n/**\r\n * The interface a rendering engine must satisfy to plug into\r\n * `<RichTextEditor engine={...}>` in place of the built-in\r\n * contentEditable engine — the escape hatch described in the\r\n * project's design discussion. A consumer needing full-schema\r\n * editing can hand-write a thin adapter over Tiptap/ProseMirror\r\n * satisfying this shape; Nuvox itself never imports either.\r\n */\r\nexport interface EditorEngine {\r\n getHTML(): string;\r\n setHTML(html: string): void;\r\n exec(command: RichTextCommand, value?: string): void;\r\n isActive(command: RichTextCommand): boolean;\r\n canUndo(): boolean;\r\n canRedo(): boolean;\r\n undo(): void;\r\n redo(): void;\r\n}\r\n\r\n/** Given ancestor tag names (any order) around a selection, is `command` currently active? */\r\nexport function isCommandActive(ancestorTags: string[], command: RichTextCommand): boolean {\r\n if (command === \"link\") return ancestorTags.includes(\"A\");\r\n if (command === \"unlink\") return false;\r\n if (isMark(command)) return ancestorTags.includes(MARK_TAGS[command]);\r\n if (isBlock(command)) return ancestorTags.includes(BLOCK_TAGS[command]);\r\n return false;\r\n}\r\n\r\n// ---- DOM command execution -----------------------------------------\r\n// Every function below takes `root` (the contentEditable element) as\r\n// its scope boundary, so ancestor walks never escape into the rest\r\n// of the page.\r\n\r\nfunction closestWithinRoot(node: Node | null, tag: string, root: HTMLElement): HTMLElement | null {\r\n let n: Node | null = node;\r\n while (n && n !== root) {\r\n if (n.nodeType === Node.ELEMENT_NODE && (n as Element).tagName === tag) return n as HTMLElement;\r\n n = n.parentNode;\r\n }\r\n return null;\r\n}\r\n\r\nfunction closestBlock(node: Node | null, root: HTMLElement): HTMLElement | null {\r\n let n: Node | null = node && node.nodeType === Node.ELEMENT_NODE ? node : node?.parentNode ?? null;\r\n while (n && n !== root) {\r\n if (n.nodeType === Node.ELEMENT_NODE && BLOCK_TAG_NAMES.has((n as Element).tagName)) return n as HTMLElement;\r\n n = n.parentNode;\r\n }\r\n return null;\r\n}\r\n\r\nfunction unwrapElement(el: HTMLElement): void {\r\n const parent = el.parentNode;\r\n if (!parent) return;\r\n while (el.firstChild) parent.insertBefore(el.firstChild, el);\r\n parent.removeChild(el);\r\n}\r\n\r\nfunction replaceTag(el: HTMLElement, tag: string): HTMLElement {\r\n const next = document.createElement(tag);\r\n while (el.firstChild) next.appendChild(el.firstChild);\r\n el.parentNode?.replaceChild(next, el);\r\n return next;\r\n}\r\n\r\nfunction selectNodeContents(node: Node, collapseToEnd = false): void {\r\n const sel = window.getSelection();\r\n if (!sel) return;\r\n const range = document.createRange();\r\n range.selectNodeContents(node);\r\n if (collapseToEnd) range.collapse(false);\r\n sel.removeAllRanges();\r\n sel.addRange(range);\r\n}\r\n\r\nconst ZERO_WIDTH_SPACE = \"\\u200B\";\r\n\r\n/** Selects (collapsed) right after position `offset` inside an already-attached marker text node. */\r\nfunction selectAtMarker(sel: Selection, marker: Text, offset: number): void {\r\n const range = document.createRange();\r\n range.setStart(marker, offset);\r\n range.collapse(true);\r\n sel.removeAllRanges();\r\n sel.addRange(range);\r\n}\r\n\r\n/**\r\n * Collapsed-selection version of a mark toggle: with no text\r\n * selected, \"toggling bold\" can't wrap anything — instead it starts\r\n * (or exits) a marked element at the cursor by inserting an invisible\r\n * zero-width-space marker inside (or right after) it and placing the\r\n * caret at that marker, so the NEXT characters the user types land\r\n * inside (or outside) the mark naturally. This is the same technique\r\n * small hand-rolled contentEditable editors use in place of the\r\n * browser's native (execCommand-only) typing state.\r\n */\r\nfunction togglePendingMark(root: HTMLElement, tag: string): void {\r\n const sel = window.getSelection();\r\n if (!sel || sel.rangeCount === 0) return;\r\n const range = sel.getRangeAt(0);\r\n\r\n const existing = closestWithinRoot(range.startContainer, tag, root);\r\n if (existing) {\r\n // Already typing inside this mark — exit it.\r\n const marker = document.createTextNode(ZERO_WIDTH_SPACE);\r\n existing.parentNode?.insertBefore(marker, existing.nextSibling);\r\n selectAtMarker(sel, marker, 1);\r\n return;\r\n }\r\n\r\n const wrapper = document.createElement(tag);\r\n const marker = document.createTextNode(ZERO_WIDTH_SPACE);\r\n wrapper.appendChild(marker);\r\n range.insertNode(wrapper);\r\n selectAtMarker(sel, marker, 1);\r\n}\r\n\r\nfunction toggleMark(root: HTMLElement, tag: string): void {\r\n const sel = window.getSelection();\r\n if (!sel || sel.rangeCount === 0) return;\r\n if (sel.isCollapsed) {\r\n togglePendingMark(root, tag);\r\n return;\r\n }\r\n const range = sel.getRangeAt(0);\r\n\r\n const existing = closestWithinRoot(range.commonAncestorContainer, tag, root);\r\n if (existing) {\r\n unwrapElement(existing);\r\n return;\r\n }\r\n\r\n const wrapper = document.createElement(tag);\r\n wrapper.appendChild(range.extractContents());\r\n range.insertNode(wrapper);\r\n selectNodeContents(wrapper);\r\n}\r\n\r\n/**\r\n * Sweeps every mark/color element under `root` whose entire content\r\n * is just the invisible caret marker character AND that no longer\r\n * contains the live caret — i.e. the user toggled a mark on and then\r\n * moved on without typing into it. Called on blur, before the value\r\n * is read/persisted, so `getHTML()`/`onChange` never surface the\r\n * marker as visible clutter. Returns whether anything was removed\r\n * (so the caller knows whether to re-commit the value).\r\n */\r\n/**\r\n * Re-applies a previously-captured Range to the document selection.\r\n * Needed because opening a Popover (Link, text color, highlight)\r\n * moves focus into its content for accessibility (Rule 12's shared\r\n * `useOverlayBehavior` autoFocus) — which resets `window.getSelection()`\r\n * away from the contentEditable region. Toolbar controls that open a\r\n * popover capture the range on trigger click (before focus moves) and\r\n * restore it here immediately before calling `exec`, so the command\r\n * still applies to what the user actually selected instead of\r\n * whatever collapsed selection is left after the popover took focus.\r\n */\r\nexport function restoreSelection(range: Range): void {\r\n const sel = window.getSelection();\r\n if (!sel) return;\r\n sel.removeAllRanges();\r\n sel.addRange(range);\r\n}\r\n\r\nexport function stripEmptyMarkers(root: HTMLElement): boolean {\r\n // Keyed off real DOM focus, not window.getSelection() — blurring an\r\n // element does not reliably clear/move the document Selection (in\r\n // most browsers it just keeps pointing at the old range), so using\r\n // the stale selection as the \"still being edited\" signal would mean\r\n // a marker never gets swept on an ordinary blur, which is the one\r\n // place this is actually meant to run.\r\n const isRootFocused = typeof document !== \"undefined\" && root.contains(document.activeElement);\r\n const sel = isRootFocused ? window.getSelection() : null;\r\n const caretNode = sel && sel.rangeCount > 0 ? sel.getRangeAt(0).startContainer : null;\r\n const candidateTags = [...Object.values(MARK_TAGS), \"SPAN\"];\r\n let changed = false;\r\n for (const tag of candidateTags) {\r\n for (const el of Array.from(root.getElementsByTagName(tag))) {\r\n if (el.textContent === ZERO_WIDTH_SPACE && !(caretNode && el.contains(caretNode))) {\r\n el.remove();\r\n changed = true;\r\n }\r\n }\r\n }\r\n return changed;\r\n}\r\n\r\nfunction setBlockTag(root: HTMLElement, targetTag: string): void {\r\n const sel = window.getSelection();\r\n if (!sel || sel.rangeCount === 0) return;\r\n const block = closestBlock(sel.getRangeAt(0).startContainer, root);\r\n if (!block) return;\r\n const next = replaceTag(block, block.tagName === targetTag ? \"P\" : targetTag);\r\n selectNodeContents(next, true);\r\n}\r\n\r\nfunction toggleList(root: HTMLElement, listTag: \"UL\" | \"OL\"): void {\r\n const sel = window.getSelection();\r\n if (!sel || sel.rangeCount === 0) return;\r\n const range = sel.getRangeAt(0);\r\n\r\n const li = closestWithinRoot(range.startContainer, \"LI\", root);\r\n if (li && li.parentElement?.tagName === listTag) {\r\n const list = li.parentElement;\r\n const p = document.createElement(\"P\");\r\n while (li.firstChild) p.appendChild(li.firstChild);\r\n list.parentNode?.replaceChild(p, list);\r\n selectNodeContents(p, true);\r\n return;\r\n }\r\n\r\n const block = closestBlock(range.startContainer, root);\r\n if (!block) return;\r\n const list = document.createElement(listTag);\r\n const item = document.createElement(\"LI\");\r\n while (block.firstChild) item.appendChild(block.firstChild);\r\n list.appendChild(item);\r\n block.parentNode?.replaceChild(list, block);\r\n selectNodeContents(item, true);\r\n}\r\n\r\nfunction setLink(root: HTMLElement, url: string): void {\r\n const sel = window.getSelection();\r\n if (!sel || sel.rangeCount === 0 || sel.isCollapsed) return;\r\n const range = sel.getRangeAt(0);\r\n const existing = closestWithinRoot(range.commonAncestorContainer, \"A\", root);\r\n if (existing) {\r\n existing.setAttribute(\"href\", url);\r\n return;\r\n }\r\n const a = document.createElement(\"A\");\r\n a.setAttribute(\"href\", url);\r\n a.setAttribute(\"rel\", \"noopener noreferrer\");\r\n a.appendChild(range.extractContents());\r\n range.insertNode(a);\r\n selectNodeContents(a);\r\n}\r\n\r\nfunction unlink(root: HTMLElement): void {\r\n const sel = window.getSelection();\r\n if (!sel || sel.rangeCount === 0) return;\r\n const a = closestWithinRoot(sel.getRangeAt(0).commonAncestorContainer, \"A\", root);\r\n if (a) unwrapElement(a);\r\n}\r\n\r\n// ---- text color / highlight ---------------------------------------\r\n// Unlike marks (a fixed tag toggled on/off), a color is a value —\r\n// applying it means \"set/replace\", and \"active\" isn't a boolean the\r\n// same way bold is. Implemented as a <span style=\"...\"> rather than a\r\n// dedicated tag; re-coloring an already-colored selection updates the\r\n// existing span's style in place instead of nesting spans endlessly.\r\n\r\nfunction findStyledSpanWithinRoot(node: Node | null, property: string, root: HTMLElement): HTMLElement | null {\r\n let n: Node | null = node;\r\n while (n && n !== root) {\r\n if (n.nodeType === Node.ELEMENT_NODE) {\r\n const el = n as HTMLElement;\r\n if (el.tagName === \"SPAN\" && el.style.getPropertyValue(property)) return el;\r\n }\r\n n = n.parentNode;\r\n }\r\n return null;\r\n}\r\n\r\nfunction setInlineStyle(root: HTMLElement, property: \"color\" | \"background-color\", value: string): void {\r\n const sel = window.getSelection();\r\n if (!sel || sel.rangeCount === 0) return;\r\n const range = sel.getRangeAt(0);\r\n\r\n if (sel.isCollapsed) {\r\n const existing = findStyledSpanWithinRoot(range.startContainer, property, root);\r\n if (existing) {\r\n existing.style.setProperty(property, value);\r\n return;\r\n }\r\n const wrapper = document.createElement(\"span\");\r\n wrapper.style.setProperty(property, value);\r\n const marker = document.createTextNode(ZERO_WIDTH_SPACE);\r\n wrapper.appendChild(marker);\r\n range.insertNode(wrapper);\r\n selectAtMarker(sel, marker, 1);\r\n return;\r\n }\r\n\r\n const existing = findStyledSpanWithinRoot(range.commonAncestorContainer, property, root);\r\n if (existing) {\r\n existing.style.setProperty(property, value);\r\n return;\r\n }\r\n const wrapper = document.createElement(\"span\");\r\n wrapper.style.setProperty(property, value);\r\n wrapper.appendChild(range.extractContents());\r\n range.insertNode(wrapper);\r\n selectNodeContents(wrapper);\r\n}\r\n\r\nfunction clearInlineStyle(root: HTMLElement, property: \"color\" | \"background-color\"): void {\r\n const sel = window.getSelection();\r\n if (!sel || sel.rangeCount === 0) return;\r\n const el = findStyledSpanWithinRoot(sel.getRangeAt(0).commonAncestorContainer, property, root);\r\n if (!el) return;\r\n el.style.removeProperty(property);\r\n if (!el.getAttribute(\"style\")) unwrapElement(el);\r\n}\r\n\r\n/**\r\n * The single dispatch point the React layer's `exec()` calls into.\r\n * Mutates the DOM under `root` directly and leaves selection in a\r\n * sensible place; does NOT itself read the result back out (the\r\n * caller reads `root.innerHTML` afterward) or manage history (the\r\n * caller decides when a checkpoint is worth recording).\r\n */\r\nexport function execRichTextCommand(root: HTMLElement, command: RichTextCommand, value?: string): void {\r\n if (isMark(command)) toggleMark(root, MARK_TAGS[command]);\r\n else if (command === \"bulletList\") toggleList(root, \"UL\");\r\n else if (command === \"orderedList\") toggleList(root, \"OL\");\r\n else if (isBlock(command)) setBlockTag(root, BLOCK_TAGS[command]);\r\n else if (command === \"link\" && value) setLink(root, value);\r\n else if (command === \"unlink\") unlink(root);\r\n else if (command === \"textColor\" && value) setInlineStyle(root, \"color\", value);\r\n else if (command === \"clearTextColor\") clearInlineStyle(root, \"color\");\r\n else if (command === \"highlight\" && value) setInlineStyle(root, \"background-color\", value);\r\n else if (command === \"clearHighlight\") clearInlineStyle(root, \"background-color\");\r\n}\r\n\r\n/**\r\n * Walks the current selection's ancestor chain (bounded by `root`)\r\n * and returns every command that's currently active — what the\r\n * toolbar buttons should render as \"pressed\". Returns an empty set\r\n * outside a browser (SSR) rather than throwing.\r\n */\r\nexport function getActiveCommands(root: HTMLElement): Set<RichTextCommand> {\r\n const result = new Set<RichTextCommand>();\r\n if (typeof window === \"undefined\") return result;\r\n const sel = window.getSelection();\r\n if (!sel || sel.rangeCount === 0) return result;\r\n\r\n const tags: string[] = [];\r\n let node: Node | null = sel.anchorNode;\r\n while (node && node !== root) {\r\n if (node.nodeType === Node.ELEMENT_NODE) tags.push((node as Element).tagName);\r\n node = node.parentNode;\r\n }\r\n\r\n const commands: RichTextCommand[] = [...(Object.keys(MARK_TAGS) as RichTextMark[]), ...(Object.keys(BLOCK_TAGS) as RichTextBlock[]), \"link\"];\r\n for (const command of commands) {\r\n if (isCommandActive(tags, command)) result.add(command);\r\n }\r\n return result;\r\n}\r\n\r\n// ---- sanitize --------------------------------------------------\r\n// Applied to any HTML entering the editor from OUTSIDE user typing:\r\n// pasted content, and an externally-supplied `value`/`defaultValue`.\r\n// Content the user types via the toolbar/keyboard is already\r\n// constructed from this module's own allow-listed tags, so it never\r\n// needs to pass back through this.\r\n\r\nconst ALLOWED_TAGS = new Set([\r\n \"P\", \"BR\", \"STRONG\", \"B\", \"EM\", \"I\", \"U\", \"S\", \"STRIKE\", \"CODE\", \"A\",\r\n \"H1\", \"H2\", \"H3\", \"BLOCKQUOTE\", \"UL\", \"OL\", \"LI\", \"SPAN\",\r\n]);\r\n\r\nconst ALLOWED_ATTRS: Record<string, string[]> = {\r\n A: [\"href\"],\r\n SPAN: [\"style\"],\r\n};\r\n\r\n/** style=\"\" is only ever produced by RichTextEditor's own text-color/highlight\r\n * commands, both of which set exactly one of these two properties to a\r\n * color value — so incoming style attributes (pasted content, an\r\n * externally-supplied value) are held to that same shape rather than\r\n * passed through verbatim, which would otherwise be an open styling\r\n * (and, for older/legacy CSS features, injection) surface. */\r\nconst ALLOWED_STYLE_PROPS = new Set([\"color\", \"background-color\"]);\r\nconst SAFE_COLOR_VALUE = /^(#[0-9a-fA-F]{3,8}|rgb\\(\\s*\\d+\\s*,\\s*\\d+\\s*,\\s*\\d+\\s*\\)|rgba\\(\\s*\\d+\\s*,\\s*\\d+\\s*,\\s*\\d+\\s*,\\s*[\\d.]+\\s*\\)|hsl\\([^();]*\\)|hsla\\([^();]*\\)|[a-zA-Z]+)$/;\r\n\r\nfunction sanitizeStyleAttr(value: string): string {\r\n const out: string[] = [];\r\n for (const decl of value.split(\";\")) {\r\n const colon = decl.indexOf(\":\");\r\n if (colon === -1) continue;\r\n const prop = decl.slice(0, colon).trim().toLowerCase();\r\n const val = decl.slice(colon + 1).trim();\r\n if (ALLOWED_STYLE_PROPS.has(prop) && SAFE_COLOR_VALUE.test(val)) {\r\n out.push(`${prop}: ${val}`);\r\n }\r\n }\r\n return out.join(\"; \");\r\n}\r\n\r\n/** Tags whose entire contents are dropped (not unwrapped) — never worth keeping the text of. */\r\nconst STRIP_ENTIRELY = new Set([\"SCRIPT\", \"STYLE\", \"IFRAME\", \"OBJECT\", \"EMBED\"]);\r\n\r\nfunction sanitizeElement(el: Element): void {\r\n for (const child of Array.from(el.childNodes)) {\r\n if (child.nodeType === Node.TEXT_NODE) continue;\r\n\r\n if (child.nodeType !== Node.ELEMENT_NODE) {\r\n child.parentNode?.removeChild(child);\r\n continue;\r\n }\r\n\r\n const childEl = child as Element;\r\n\r\n if (STRIP_ENTIRELY.has(childEl.tagName)) {\r\n childEl.parentNode?.removeChild(childEl);\r\n continue;\r\n }\r\n\r\n if (!ALLOWED_TAGS.has(childEl.tagName)) {\r\n // Clean its subtree first, THEN unwrap — otherwise disallowed\r\n // tags nested inside a disallowed tag never get visited.\r\n sanitizeElement(childEl);\r\n const parent = childEl.parentNode;\r\n while (childEl.firstChild) parent?.insertBefore(childEl.firstChild, childEl);\r\n parent?.removeChild(childEl);\r\n continue;\r\n }\r\n\r\n const allowedAttrs = ALLOWED_ATTRS[childEl.tagName] ?? [];\r\n for (const attr of Array.from(childEl.attributes)) {\r\n const name = attr.name.toLowerCase();\r\n if (!allowedAttrs.includes(name)) {\r\n childEl.removeAttribute(attr.name);\r\n continue;\r\n }\r\n if (name === \"style\") {\r\n const cleaned = sanitizeStyleAttr(attr.value);\r\n if (cleaned) childEl.setAttribute(\"style\", cleaned);\r\n else childEl.removeAttribute(\"style\");\r\n }\r\n }\r\n if (childEl.tagName === \"A\") {\r\n const href = childEl.getAttribute(\"href\") ?? \"\";\r\n const safe = /^https?:\\/\\//i.test(href) || href.startsWith(\"/\") || href.startsWith(\"#\") || href.startsWith(\"mailto:\");\r\n if (!safe) childEl.removeAttribute(\"href\");\r\n childEl.setAttribute(\"rel\", \"noopener noreferrer\");\r\n childEl.setAttribute(\"target\", \"_blank\");\r\n }\r\n\r\n sanitizeElement(childEl);\r\n }\r\n}\r\n\r\n/**\r\n * Strips any tag/attribute not on the allow-list. Uses DOMParser — a\r\n * web-platform API, not a React dependency; see this module's header\r\n * for why that's still \"framework-agnostic core\" the same way\r\n * core/calendar.ts's use of Intl/Date is. Never throws; returns an\r\n * empty string if DOMParser isn't available rather than passing\r\n * unsanitized markup through.\r\n */\r\nexport function sanitizeHtml(html: string): string {\r\n if (typeof DOMParser === \"undefined\") return \"\";\r\n const doc = new DOMParser().parseFromString(html, \"text/html\");\r\n sanitizeElement(doc.body);\r\n return doc.body.innerHTML;\r\n}\r\n\r\n// ---- undo/redo history ------------------------------------------\r\n\r\nexport interface RichTextHistory {\r\n past: string[];\r\n future: string[];\r\n}\r\n\r\nconst HISTORY_LIMIT = 100;\r\n\r\nexport function createHistory(): RichTextHistory {\r\n return { past: [], future: [] };\r\n}\r\n\r\n/** Records `previousValue` as a checkpoint to return to. Caller decides checkpoint granularity (e.g. word boundaries). */\r\nexport function pushHistory(history: RichTextHistory, previousValue: string): RichTextHistory {\r\n return { past: [...history.past, previousValue].slice(-HISTORY_LIMIT), future: [] };\r\n}\r\n\r\nexport function undoHistory(\r\n history: RichTextHistory,\r\n currentValue: string\r\n): { history: RichTextHistory; value: string } | null {\r\n if (history.past.length === 0) return null;\r\n const value = history.past[history.past.length - 1];\r\n return {\r\n history: { past: history.past.slice(0, -1), future: [currentValue, ...history.future] },\r\n value,\r\n };\r\n}\r\n\r\nexport function redoHistory(\r\n history: RichTextHistory,\r\n currentValue: string\r\n): { history: RichTextHistory; value: string } | null {\r\n if (history.future.length === 0) return null;\r\n const value = history.future[0];\r\n return {\r\n history: { past: [...history.past, currentValue], future: history.future.slice(1) },\r\n value,\r\n };\r\n}\r\n\r\n// ---- props/state (Rule 1/3 conventions) --------------------------\r\n\r\nexport interface RichTextEditorCoreProps {\r\n disabled?: boolean;\r\n readOnly?: boolean;\r\n placeholder?: string;\r\n size?: Size;\r\n}\r\n\r\nexport interface RichTextEditorState {\r\n isDisabled: boolean;\r\n isReadOnly: boolean;\r\n placeholder: string;\r\n size: Size;\r\n}\r\n\r\nexport function resolveRichTextEditorState(props: RichTextEditorCoreProps): RichTextEditorState {\r\n return {\r\n isDisabled: props.disabled ?? false,\r\n isReadOnly: props.readOnly ?? false,\r\n placeholder: props.placeholder ?? \"\",\r\n size: props.size ?? \"md\",\r\n };\r\n}\r\n\r\nexport function getRichTextEditorClasses(state: RichTextEditorState): string {\r\n return [\r\n \"nx-rich-text\",\r\n `nx-rich-text--${state.size}`,\r\n state.isDisabled && \"nx-rich-text--disabled\",\r\n state.isReadOnly && \"nx-rich-text--readonly\",\r\n ]\r\n .filter(Boolean)\r\n .join(\" \");\r\n}\r\n"],"mappings":";AAiJO,SAAS,YAAY,QAAkC;AAC5D,SAAO;AACT;AAGO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAU;AAAA,EAAW;AAAA,EAAc;AAAA,EAAU;AAAA,EAAa;AAAA,EAAU;AAAA,EAAU;AACjG;AAYO,IAAM,uBAAuB;AAAA,EAClC;AAAA,EAAa;AAAA,EAAc;AAAA,EAC3B,GAAG,CAAC,KAAK,MAAM,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,EAAE,IAAI,CAAC,MAAM,iBAAiB,CAAC,EAAE;AAAA,EACpH,GAAI,CAAC,WAAW,UAAU,WAAW,MAAM,EAAY;AAAA,IAAQ,CAAC,MAC9D,CAAC,SAAS,UAAU,QAAQ,QAAQ,QAAQ,EAAE,IAAI,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE;AAAA,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