"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseBottomSheetCTADoubleButton = exports.BaseBottomSheetCTASingleButton = exports.BaseBottomSheetBody = exports.BaseBottomSheetHeader = exports.BaseBottomSheetComp = exports.BaseBottomSheet = void 0;
const hooks_1 = require("../../../hooks");
const react_1 = __importStar(require("react"));
const Styled = __importStar(require("./index.styled"));
const SingleButton_1 = require("../../Button/SingleButton");
const DoubleButton_1 = require("../../Button/DoubleButton");
const style_constants_1 = require("../../../constants/style.constants");
const OverlayRoot_1 = require("../../OverlayRoot");
const BaseBottomSheetCTASingleButton = (props) => (react_1.default.createElement(Styled.FooterWrapper, null,
    react_1.default.createElement(SingleButton_1.SingleButton, Object.assign({}, props))));
exports.BaseBottomSheetCTASingleButton = BaseBottomSheetCTASingleButton;
const BaseBottomSheetCTADoubleButton = (props) => (react_1.default.createElement(Styled.FooterWrapper, null,
    react_1.default.createElement(DoubleButton_1.DoubleButton, Object.assign({}, props))));
exports.BaseBottomSheetCTADoubleButton = BaseBottomSheetCTADoubleButton;
const BaseBottomSheetBody = (_a) => {
    var { children } = _a, styleProps = __rest(_a, ["children"]);
    const ref = (0, react_1.useRef)(null);
    (0, react_1.useEffect)(() => {
        var _a;
        (_a = ref.current) === null || _a === void 0 ? void 0 : _a.scroll(0, 0);
    }, []);
    return (react_1.default.createElement(Styled.ChildrenWrapper, Object.assign({ ref: ref }, styleProps), children));
};
exports.BaseBottomSheetBody = BaseBottomSheetBody;
const BaseBottomSheetHeader = ({ children }) => (react_1.default.createElement(Styled.HeaderWrapper, null, children));
exports.BaseBottomSheetHeader = BaseBottomSheetHeader;
const BaseBottomSheetComp = ({ visible, onMaskClick, className, zIndex = style_constants_1.zIndex.modal, minHeight, children, }) => {
    const [vh, setVh] = (0, react_1.useState)(0);
    const checkVh = (0, react_1.useCallback)(() => {
        setVh(window === null || window === void 0 ? void 0 : window.innerHeight);
    }, []);
    (0, react_1.useEffect)(() => {
        checkVh();
    }, [checkVh]);
    (0, hooks_1.useResize)(checkVh);
    (0, hooks_1.useOverlayPreventScroll)(visible);
    if (!visible) {
        return null;
    }
    return (react_1.default.createElement(OverlayRoot_1.OverlayRoot, { visible: visible, className: className, onClick: onMaskClick, zIndex: zIndex },
        react_1.default.createElement(Styled.ContentWrapper, null,
            react_1.default.createElement(Styled.Content, { visible: visible, zIndex: zIndex, minHeight: minHeight, vh: vh }, children))));
};
exports.BaseBottomSheetComp = BaseBottomSheetComp;
const BaseBottomSheet = Object.assign(BaseBottomSheetComp, {
    SingleButton: BaseBottomSheetCTASingleButton,
    DoubleButton: BaseBottomSheetCTADoubleButton,
    Body: BaseBottomSheetBody,
    Header: BaseBottomSheetHeader,
});
exports.BaseBottomSheet = BaseBottomSheet;
