{"version":3,"sources":["../src/color-mode-context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\"\nimport { ColorModeContextType } from \"./color-mode-types\"\n\nexport const ColorModeContext = createContext({} as ColorModeContextType)\n\nColorModeContext.displayName = \"ColorModeContext\"\n\n/**\n * React hook that reads from `ColorModeProvider` context\n * Returns the color mode and function to toggle it\n */\nexport function useColorMode() {\n const context = useContext(ColorModeContext)\n if (context === undefined) {\n throw new Error(\"useColorMode must be used within a ColorModeProvider\")\n }\n return context\n}\n\n/**\n * Change value based on color mode.\n *\n * @param light the light mode value\n * @param dark the dark mode value\n *\n * @example\n *\n * ```js\n * const Icon = useColorModeValue(MoonIcon, SunIcon)\n * ```\n */\nexport function useColorModeValue(\n light: TLight,\n dark: TDark,\n) {\n const { colorMode } = useColorMode()\n return colorMode === \"dark\" ? dark : light\n}\n"],"mappings":";;;AAAA,SAAS,eAAe,kBAAkB;AAGnC,IAAM,mBAAmB,cAAc,CAAC,CAAyB;AAExE,iBAAiB,cAAc;AAMxB,SAAS,eAAe;AAC7B,QAAM,UAAU,WAAW,gBAAgB;AAC3C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AACA,SAAO;AACT;AAcO,SAAS,kBACd,OACA,MACA;AACA,QAAM,EAAE,UAAU,IAAI,aAAa;AACnC,SAAO,cAAc,SAAS,OAAO;AACvC;","names":[]}