{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ink/theme-provider",
  "title": "Theme Provider",
  "description": "Terminal theme provider, design tokens, and theme helpers.",
  "registryDependencies": [
    "https://termcn.dev/r/ink/theme-default.json",
    "https://termcn.dev/r/ink/types.json",
    "https://termcn.dev/r/ink/use-theme.json"
  ],
  "files": [
    {
      "path": "registry/providers/theme-provider.tsx",
      "content": "import * as React from \"react\";\n\nimport { ThemeContext } from \"@/hooks/use-theme\";\nimport { defaultTheme } from \"@/lib/terminal-themes/default\";\nimport type {\n  AutoThemeProviderProps,\n  Theme,\n  ThemeProviderProps,\n} from \"@/components/ui/types\";\n\nexport type {\n  AutoThemeProviderProps,\n  BorderStyle,\n  BorderTokens,\n  ColorTokens,\n  SpacingTokens,\n  Theme,\n  ThemeProviderProps,\n  TypographyTokens,\n} from \"@/components/ui/types\";\n\nconst getEnv = (name: string): string | undefined =>\n  typeof process !== \"undefined\" && process.env ? process.env[name] : undefined;\n\nexport const detectColorScheme = (): \"dark\" | \"light\" => {\n  const colorFgBg = getEnv(\"COLORFGBG\");\n  if (colorFgBg) {\n    const parts = colorFgBg.split(\";\");\n    const background = Number.parseInt(parts.at(-1) ?? \"0\", 10);\n    if (!Number.isNaN(background)) {\n      return background <= 6 ? \"dark\" : \"light\";\n    }\n  }\n\n  const termBackground = getEnv(\"TERM_BACKGROUND\");\n  if (termBackground === \"light\") {\n    return \"light\";\n  }\n  if (termBackground === \"dark\") {\n    return \"dark\";\n  }\n\n  return \"dark\";\n};\n\nexport const ThemeProvider = ({\n  children,\n  theme = defaultTheme,\n}: ThemeProviderProps) => {\n  const [currentTheme, setCurrentTheme] = React.useState(theme);\n\n  React.useEffect(() => {\n    setCurrentTheme(theme);\n  }, [theme]);\n\n  const themeValue = React.useMemo(\n    () => ({ setTheme: setCurrentTheme, theme: currentTheme }),\n    [currentTheme]\n  );\n\n  return (\n    <ThemeContext.Provider value={themeValue}>{children}</ThemeContext.Provider>\n  );\n};\n\nexport const AutoThemeProvider = ({\n  children,\n  darkTheme,\n  lightTheme,\n}: AutoThemeProviderProps) => {\n  const scheme = detectColorScheme();\n  return (\n    <ThemeProvider theme={scheme === \"dark\" ? darkTheme : lightTheme}>\n      {children}\n    </ThemeProvider>\n  );\n};\n\nexport const createTheme = (\n  overrides: Partial<Theme> & { name: string }\n): Theme => ({\n  ...defaultTheme,\n  ...overrides,\n  border: {\n    ...defaultTheme.border,\n    ...overrides.border,\n  },\n  colors: {\n    ...defaultTheme.colors,\n    ...overrides.colors,\n  },\n  spacing: {\n    ...defaultTheme.spacing,\n    ...overrides.spacing,\n  },\n  typography: {\n    ...defaultTheme.typography,\n    ...overrides.typography,\n  },\n});\n",
      "type": "registry:ui",
      "target": "providers/theme-provider.tsx"
    }
  ],
  "categories": [
    "core"
  ],
  "type": "registry:ui"
}
