"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ModalBSHeader = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _core = require("../../core");
var _buttons = require("../buttons");
var _typography = require("../typography");
var _jsxRuntime = require("react/jsx-runtime");
const styles = _reactNative.StyleSheet.create({
  container: {
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "space-between",
    paddingHorizontal: _core.IOVisualCostants.appMarginDefault,
    paddingTop: _core.IOVisualCostants.appMarginDefault,
    paddingBottom: _core.IOVisualCostants.appMarginDefault,
    backgroundColor: _core.IOColors.white
  }
});
/**
 * A header for a modals and bottom sheet.
 * @param title - The title of the modal.
 * @param onClose - The function to call when the close button is pressed.
 * @param closeAccessibilityLabel - The accessibility label for the close button.
 *
 */
const ModalBSHeader = ({
  title,
  onClose,
  closeAccessibilityLabel
}) => {
  const headerRef = /*#__PURE__*/(0, _react.createRef)();
  (0, _react.useLayoutEffect)(() => {
    const reactNode = (0, _reactNative.findNodeHandle)(headerRef.current);
    if (reactNode !== null) {
      _reactNative.AccessibilityInfo.setAccessibilityFocus(reactNode);
    }
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
    style: styles.container,
    ref: headerRef,
    children: [/*#__PURE__*/(0, _react.isValidElement)(title) ? title : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: {
        flex: 1
      },
      accessible: true,
      accessibilityRole: "header",
      accessibilityLabel: typeof title === "string" ? title : undefined,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.H4, {
        children: title
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_buttons.IconButton, {
      color: "neutral",
      onPress: onClose,
      icon: "closeMedium",
      accessibilityLabel: closeAccessibilityLabel
    })]
  });
};
exports.ModalBSHeader = ModalBSHeader;
//# sourceMappingURL=ModalBSHeader.js.map