"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDialog = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const box_1 = require("../box");
const core_1 = require("../core");
const dialog_1 = require("../dialog");
const input_1 = require("../input");
const useDialog = () => {
    const { setPortalSlot } = (0, core_1.useVuiContext)();
    const showConfirm = (title, message) => new Promise(resolve => setPortalSlot((0, jsx_runtime_1.jsx)(dialog_1.Dialog, { body: message, cancelButton: {
            onClick: () => {
                resolve(false);
                setPortalSlot(null);
            },
            text: 'Cancel',
        }, closeButton: false, isOpen: true, submitButton: {
            onClick: () => {
                resolve(true);
                setPortalSlot(null);
            },
            text: 'Confirm',
        }, title: title })));
    const showPrompt = (title, value = '') => new Promise(resolve => {
        let inputValue = value;
        setPortalSlot((0, jsx_runtime_1.jsx)(dialog_1.Dialog, { body: (0, jsx_runtime_1.jsx)(box_1.Box, { px: 3, py: 2, children: (0, jsx_runtime_1.jsx)(input_1.Input, { onChange: e => (inputValue = e.target.value), value: value }) }), cancelButton: {
                onClick: () => {
                    resolve(false);
                    setPortalSlot(null);
                },
                text: 'Cancel',
            }, closeButton: false, isOpen: true, submitButton: {
                onClick: () => {
                    resolve(inputValue);
                    setPortalSlot(null);
                },
                text: 'Submit',
            }, title: title }));
    });
    return { showConfirm, showPrompt };
};
exports.useDialog = useDialog;
//# sourceMappingURL=useDialog.js.map