"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useIOThemeContext = exports.useIOTheme = exports.IOThemes = exports.IOThemeContextProvider = exports.IOThemeContext = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _IOColors = require("../core/IOColors");
var _jsxRuntime = require("react/jsx-runtime");
const IOThemes = exports.IOThemes = {
  light: _IOColors.IOThemeLight,
  dark: _IOColors.IOThemeDark
};
const IOThemeContext = exports.IOThemeContext = /*#__PURE__*/(0, _react.createContext)({
  themeType: _reactNative.Appearance.getColorScheme() ?? "unspecified",
  theme: _reactNative.Appearance.getColorScheme() === "dark" ? IOThemes.dark : IOThemes.light,
  setTheme: () => void 0
});
const useIOThemeContext = () => (0, _react.useContext)(IOThemeContext);
exports.useIOThemeContext = useIOThemeContext;
const useIOTheme = () => useIOThemeContext().theme;
exports.useIOTheme = useIOTheme;
const IOThemeContextProvider = ({
  children,
  theme
}) => {
  const [currentTheme, setCurrentTheme] = (0, _react.useState)(theme ?? "unspecified");
  const resolvedTheme = currentTheme === "unspecified" ? _reactNative.Appearance.getColorScheme() ?? "light" : currentTheme;
  const handleThemeChange = (0, _react.useCallback)(newTheme => {
    setCurrentTheme(newTheme);
  }, []);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(IOThemeContext.Provider, {
    value: {
      themeType: currentTheme,
      theme: resolvedTheme === "dark" ? IOThemes.dark : IOThemes.light,
      setTheme: handleThemeChange
    },
    children: children
  });
};
exports.IOThemeContextProvider = IOThemeContextProvider;
//# sourceMappingURL=IOThemeContextProvider.js.map