import { __rest } from '../../../../_virtual/_tslib.js';
import React__default, { useState } from 'react';
import { BottomSheetHeader } from '../bottomSheetHeader/index.js';
import { BottomSheetWrapper, MainContentWrapper, PullTab, CustomHeaderWrapper, InnerWrapper } from '../../styles.js';
import { BottomSheetBody } from '../bottomSheetBody/index.js';
import { BottomSheetFooter } from '../bottomSheetFooter/index.js';
import ButtonSheetImage from '../bottomSheetImage/index.js';
import { getId } from '../../../../utils/index.js';

const BottomSheetContent = (_a) => {
    var { headerTitle, headerContentModifiers, headerControlsModifiers, hasPullTab, icon, dismissAction, primaryAction, stackedActionButtons, pinnedFooter = false, pinnedHeader = false, hasBodyPadding = true, isOpened = false, shouldCloseOnEsc = true, shouldCloseOnOverlayClick = true, children, bottomSheetRoot, height, width, imgValues, position = 'center', onClose, customHeader, customFooter, onPullTabClick, bodyRef } = _a, props = __rest(_a, ["headerTitle", "headerContentModifiers", "headerControlsModifiers", "hasPullTab", "icon", "dismissAction", "primaryAction", "stackedActionButtons", "pinnedFooter", "pinnedHeader", "hasBodyPadding", "isOpened", "shouldCloseOnEsc", "shouldCloseOnOverlayClick", "children", "bottomSheetRoot", "height", "width", "imgValues", "position", "onClose", "customHeader", "customFooter", "onPullTabClick", "bodyRef"]);
    const [bottomSheetHeight, setBottomSheetHeight] = useState(height);
    const appendId = getId(props['id']);
    const expandBottomSheet = () => setBottomSheetHeight((prevState) => prevState === '100%' ? height : '100%');
    return (React__default.createElement(BottomSheetWrapper, { isOpened: isOpened, height: bottomSheetHeight, width: width, hasPullTab: hasPullTab, stackedActionButtons: stackedActionButtons, position: position, "data-testid": `${props['data-testid']}-bottom-sheet-wrapper`, id: appendId('wrapper') },
        React__default.createElement(MainContentWrapper, { id: appendId('wrapper') },
            hasPullTab && (React__default.createElement(PullTab, { hasPullTab: hasPullTab, onClick: onPullTabClick || expandBottomSheet, "data-testid": `${props['data-testid']}-bottom-sheet-pull-tab`, id: appendId('pull-tab') })),
            (headerContentModifiers === 'empty' &&
                headerControlsModifiers === 'default') ||
                (imgValues === null || imgValues === void 0 ? void 0 : imgValues.asHeader) ||
                customHeader !== undefined ? null : (React__default.createElement(BottomSheetHeader, { headerTitle: headerTitle, onClose: onClose, hasPullTab: hasPullTab, headerContentModifiers: headerContentModifiers, headerControlsModifiers: headerControlsModifiers, pinnedHeader: pinnedHeader, icon: icon, "data-testid": props['data-testid'], "data-trackid": props['data-trackid'], "aria-label": props['aria-label'], id: appendId('header') })),
            customHeader && (React__default.createElement(CustomHeaderWrapper, { id: appendId('custom-header-wrapper') }, customHeader)),
            (imgValues === null || imgValues === void 0 ? void 0 : imgValues.imgSrc) && (imgValues === null || imgValues === void 0 ? void 0 : imgValues.asHeader) && (React__default.createElement(ButtonSheetImage, { imgValues: imgValues, onClose: onClose, headerControlsModifiers: headerControlsModifiers })),
            React__default.createElement(InnerWrapper, { pinnedHeader: pinnedHeader, pinnedFooter: pinnedFooter, id: appendId('inner-wrapper') },
                (imgValues === null || imgValues === void 0 ? void 0 : imgValues.imgSrc) && !(imgValues === null || imgValues === void 0 ? void 0 : imgValues.asHeader) && (React__default.createElement(ButtonSheetImage, { imgValues: imgValues, onClose: onClose, headerControlsModifiers: headerControlsModifiers })),
                children && (React__default.createElement(BottomSheetBody, { pinnedFooter: pinnedFooter, dismissAction: dismissAction, stackedActionButtons: stackedActionButtons, hasBodyPadding: hasBodyPadding, "data-testid": props['data-testid'], "data-trackid": props['data-trackid'], "aria-label": props['aria-label'], bodyRef: bodyRef, id: appendId('body') }, children)),
                primaryAction && !customFooter && (React__default.createElement(BottomSheetFooter, { primaryAction: primaryAction, dismissAction: dismissAction, stackedActionButtons: stackedActionButtons, pinnedFooter: pinnedFooter, "data-testid": props['data-testid'], "data-trackid": props['data-trackid'], "aria-label": props['aria-label'], id: appendId('footer') })),
                customFooter))));
};

export { BottomSheetContent };
