"use strict";

import { StyleSheet, View } from "react-native";
import { useIOTheme, useIOThemeContext } from "../../context";
import { IOColors, IOSpacing, IOVisualCostants } from "../../core";
import { IOButton } from "../buttons";
import { useBottomMargins } from "./hooks/useBottomMargins";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const styles = StyleSheet.create({
  buttonContainer: {
    paddingHorizontal: IOVisualCostants.appMarginDefault,
    width: "100%",
    flexShrink: 0
  },
  buttonWrapper: {
    flex: 1
  },
  blockShadow: {
    shadowColor: IOColors.black,
    shadowOffset: {
      width: 0,
      height: -4
    },
    shadowOpacity: 0.1,
    shadowRadius: 32,
    elevation: 10 // Prop supported on Android only
  }
});
export const FooterActionsInline = ({
  startAction,
  endAction,
  excludeSafeAreaMargins = false,
  fixed = true,
  onMeasure,
  testID
}) => {
  const theme = useIOTheme();
  const {
    themeType
  } = useIOThemeContext();
  const {
    bottomMargin
  } = useBottomMargins(false, excludeSafeAreaMargins);

  /* Margin between `solid` and `outline` variant */
  const spaceBetweenActions = 16;
  /* Top padding applied above the actions */
  const topSpacingValue = 16;
  const topSpacing = fixed ? topSpacingValue : 0;

  /* Background color should be app main background
     (both light and dark themes) */
  const HEADER_BG_COLOR = IOColors[theme["appBackground-primary"]];
  const getActionBlockMeasurements = event => {
    const {
      height
    } = event.nativeEvent.layout;
    /* Height of the safe bottom area, applied to the ScrollView:
       Actions + Screen end margin */
    const safeBottomAreaHeight = bottomMargin + height + IOSpacing.screenEndMargin;
    onMeasure?.({
      safeBottomAreaHeight
    });
  };
  return /*#__PURE__*/_jsx(View, {
    style: [{
      width: "100%",
      paddingBottom: bottomMargin
    }, fixed ? {
      position: "absolute",
      bottom: 0,
      backgroundColor: HEADER_BG_COLOR
    } : {
      marginTop: IOSpacing.screenEndMargin
    }, /* Apply shadow only on light theme OR if fixed */
    fixed || themeType === "light" ? styles.blockShadow : {}, /* Apply bottom border only on dark theme */
    themeType === "dark" && {
      borderTopColor: IOColors[theme["divider-bottomBar"]],
      borderTopWidth: 1
    }],
    testID: testID,
    children: /*#__PURE__*/_jsx(View, {
      style: [styles.buttonContainer, {
        paddingTop: topSpacing
      }],
      onLayout: getActionBlockMeasurements,
      pointerEvents: "box-none",
      children: /*#__PURE__*/_jsxs(View, {
        style: {
          flexDirection: "row",
          gap: spaceBetweenActions
        },
        children: [/*#__PURE__*/_jsx(View, {
          style: styles.buttonWrapper,
          children: /*#__PURE__*/_jsx(IOButton, {
            variant: "outline",
            fullWidth: true,
            ...startAction
          })
        }), /*#__PURE__*/_jsx(View, {
          style: styles.buttonWrapper,
          children: /*#__PURE__*/_jsx(IOButton, {
            variant: "solid",
            fullWidth: true,
            ...endAction
          })
        })]
      })
    })
  });
};
//# sourceMappingURL=FooterActionsInline.js.map