"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    ApModal: ()=>ApModal
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const Close_namespaceObject = require("@mui/icons-material/Close");
var Close_default = /*#__PURE__*/ __webpack_require__.n(Close_namespaceObject);
const material_namespaceObject = require("@mui/material");
const apollo_core_namespaceObject = require("@uipath/apollo-core");
var apollo_core_default = /*#__PURE__*/ __webpack_require__.n(apollo_core_namespaceObject);
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const index_cjs_namespaceObject = require("../ap-button/index.cjs");
const external_ap_icon_button_index_cjs_namespaceObject = require("../ap-icon-button/index.cjs");
const external_ap_typography_index_cjs_namespaceObject = require("../ap-typography/index.cjs");
const getSizeWidth = (size)=>{
    switch(size){
        case 'small':
            return '480px';
        case 'medium':
            return '600px';
        case 'large':
            return '800px';
        default:
            return '480px';
    }
};
const ApModal = /*#__PURE__*/ external_react_default().forwardRef((props, ref)=>{
    const { header, message, size = 'small', open, preventClose, hideCloseButton, primaryAction, secondaryAction, closeButtonId, onClose, children, ...rest } = props;
    const handleClose = (0, external_react_namespaceObject.useCallback)((event, reason)=>{
        if (preventClose) return;
        onClose?.(event, reason);
    }, [
        preventClose,
        onClose
    ]);
    const handleCloseButtonClick = (0, external_react_namespaceObject.useCallback)(()=>{
        if (preventClose) return;
        onClose?.({}, 'closeButtonClick');
    }, [
        preventClose,
        onClose
    ]);
    const hasActions = primaryAction || secondaryAction;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(material_namespaceObject.Modal, {
        ref: ref,
        disablePortal: true,
        open: open,
        onClose: handleClose,
        ...rest,
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(material_namespaceObject.Box, {
            sx: {
                position: 'absolute',
                top: '50%',
                left: '50%',
                transform: 'translate(-50%, -50%)',
                width: getSizeWidth(size),
                backgroundColor: 'var(--color-background)',
                borderRadius: apollo_core_default().Border.BorderRadiusS,
                padding: apollo_core_default().Spacing.SpacingL,
                boxShadow: apollo_core_default().Shadow.ShadowDp8,
                '&:focus-visible, &:focus': {
                    outline: 'none'
                }
            },
            children: [
                header && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(material_namespaceObject.Box, {
                    sx: {
                        paddingTop: apollo_core_default().Padding.PadXl,
                        paddingBottom: apollo_core_default().Padding.PadL,
                        display: 'flex',
                        alignItems: 'center'
                    },
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ap_typography_index_cjs_namespaceObject.ApTypography, {
                        variant: apollo_core_default().FontVariantToken.fontSizeH4Bold,
                        color: "var(--color-foreground)",
                        children: header
                    })
                }),
                !hideCloseButton && !preventClose && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(material_namespaceObject.Box, {
                    sx: {
                        position: 'absolute',
                        right: '10px',
                        top: '10px'
                    },
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ap_icon_button_index_cjs_namespaceObject.ApIconButton, {
                        size: "small",
                        id: closeButtonId,
                        color: "secondary",
                        onClick: handleCloseButtonClick,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Close_default(), {
                            sx: {
                                width: apollo_core_default().Icon.IconXs,
                                height: apollo_core_default().Icon.IconXs
                            }
                        })
                    })
                }),
                message ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ap_typography_index_cjs_namespaceObject.ApTypography, {
                    variant: apollo_core_default().FontVariantToken.fontSizeM,
                    color: "var(--color-foreground)",
                    children: message
                }) : children,
                hasActions && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(material_namespaceObject.Box, {
                    sx: {
                        display: 'flex',
                        justifyContent: 'flex-end',
                        paddingTop: apollo_core_default().Spacing.SpacingM
                    },
                    children: [
                        secondaryAction && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApButton, {
                            variant: "secondary",
                            id: secondaryAction.id,
                            label: secondaryAction.label,
                            disabled: secondaryAction.disabled,
                            loading: secondaryAction.loading,
                            onClick: secondaryAction.onClick
                        }),
                        primaryAction && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(material_namespaceObject.Box, {
                            sx: {
                                paddingLeft: apollo_core_default().Padding.PadL
                            },
                            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApButton, {
                                variant: "primary",
                                id: primaryAction.id,
                                label: primaryAction.label,
                                disabled: primaryAction.disabled,
                                loading: primaryAction.loading,
                                onClick: primaryAction.onClick
                            })
                        })
                    ]
                })
            ]
        })
    });
});
ApModal.displayName = 'ApModal';
exports.ApModal = __webpack_exports__.ApModal;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "ApModal"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
