"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useIOFontDynamicScale = exports.useBoldTextEnabled = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _fonts = require("./fonts");
/**
 * Query whether a bold text is currently enabled. The result is true
 * when bold text is enabled and false otherwise.
 */
const useBoldTextEnabled = () => {
  const [boldTextEnabled, setBoldTextEnabled] = (0, _react.useState)(false);
  (0, _react.useEffect)(() => {
    if (_reactNative.Platform.OS !== "web") {
      const boldTextChangedSubscription = _reactNative.AccessibilityInfo.addEventListener("boldTextChanged", isBoldTextEnabled => {
        setBoldTextEnabled(isBoldTextEnabled);
      });
      _reactNative.AccessibilityInfo.isBoldTextEnabled().then(isBoldTextEnabled => {
        setBoldTextEnabled(isBoldTextEnabled);
      }).catch(_ => false);
      return () => {
        boldTextChangedSubscription.remove();
      };
    }
    return;
  }, []);
  return boldTextEnabled;
};

/**
 * Returns a font size multiplier based on the font scale of the device,
 * but limited to the `IOMaxFontSizeMultiplier` value.
 * @returns number
 */
exports.useBoldTextEnabled = useBoldTextEnabled;
const useIOFontDynamicScale = () => {
  const {
    fontScale
  } = (0, _reactNative.useWindowDimensions)();
  const hugeFontEnabled = fontScale >= 1.35;
  const dynamicFontScale = Math.min(fontScale, _fonts.IOMaxFontSizeMultiplier);
  /* We make the spacing dynamic based on the font scale, but we multiply
    this value to limit the amount of scaling applied to the spacing */
  const spacingScaleMultiplier = dynamicFontScale <= _fonts.IOMaxFontSizeMultiplier ? 1 : 0.8;
  return {
    hugeFontEnabled,
    dynamicFontScale,
    spacingScaleMultiplier
  };
};
exports.useIOFontDynamicScale = useIOFontDynamicScale;
//# sourceMappingURL=accessibility.js.map