function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import { useHeaderHeight } from '@react-navigation/elements';
import React from 'react';
import { KeyboardAvoidingView, ScrollView } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useTheme } from '../../contexts/theme';
const useSafeHeaderHeight = () => {
  try {
    return useHeaderHeight();
  } catch {
    return 100;
  }
};

/**
 * A wrapper component that provides keyboard-aware scrolling and safe area handling.
 *
 * This component creates a full-screen container with safe area insets and optional
 * keyboard avoidance behavior. It's designed to be used as a top-level wrapper for
 * screen content that may contain input fields or other interactive elements.
 *
 * @param children - The content to render inside the keyboard view
 * @param keyboardAvoiding - Whether to enable keyboard avoidance behavior. When true,
 *   the view will automatically adjust its content when the keyboard appears. Defaults to true.
 * @param scrollViewProps - Additional props to pass to the internal ScrollView component
 */
const KeyboardView = ({
  children,
  keyboardAvoiding = true,
  scrollViewProps
}) => {
  const {
    ColorPalette
  } = useTheme();
  const headerHeight = useSafeHeaderHeight();
  return /*#__PURE__*/React.createElement(SafeAreaView, {
    style: {
      flex: 1,
      backgroundColor: ColorPalette.brand.primaryBackground
    },
    edges: ['bottom', 'left', 'right']
  }, keyboardAvoiding ? /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
    style: {
      flex: 1
    },
    keyboardVerticalOffset: headerHeight,
    behavior: "padding"
  }, /*#__PURE__*/React.createElement(ScrollView, _extends({
    contentContainerStyle: {
      flexGrow: 1
    },
    keyboardShouldPersistTaps: 'handled'
  }, scrollViewProps), children)) : /*#__PURE__*/React.createElement(ScrollView, {
    contentContainerStyle: {
      flexGrow: 1
    },
    keyboardShouldPersistTaps: 'handled'
  }, children));
};
export default KeyboardView;
//# sourceMappingURL=KeyboardView.js.map