import { useVuiContext } from "../core/vuiProvider/context.js";
import Box from "../box/box.js";
import Input from "../input/input.js";
import Dialog from "./dialog.js";
import { jsx } from "react/jsx-runtime";

//#region src/dialog/useDialog.tsx
const useDialog = () => {
	const { setPortalSlot } = useVuiContext();
	const showConfirm = (title, message) => new Promise((resolve) => setPortalSlot(/* @__PURE__ */ jsx(Dialog, {
		body: message,
		cancelButton: {
			onClick: () => {
				resolve(false);
				setPortalSlot(null);
			},
			text: "Cancel"
		},
		closeButton: false,
		isOpen: true,
		submitButton: {
			onClick: () => {
				resolve(true);
				setPortalSlot(null);
			},
			text: "Confirm"
		},
		title
	})));
	const showPrompt = (title, value = "") => new Promise((resolve) => {
		let inputValue = value;
		setPortalSlot(/* @__PURE__ */ jsx(Dialog, {
			body: /* @__PURE__ */ jsx(Box, {
				px: 3,
				py: 2,
				children: /* @__PURE__ */ jsx(Input, {
					onChange: (e) => inputValue = e.target.value,
					value
				})
			}),
			cancelButton: {
				onClick: () => {
					resolve(false);
					setPortalSlot(null);
				},
				text: "Cancel"
			},
			closeButton: false,
			isOpen: true,
			submitButton: {
				onClick: () => {
					resolve(inputValue);
					setPortalSlot(null);
				},
				text: "Submit"
			},
			title
		}));
	});
	return {
		showConfirm,
		showPrompt
	};
};

//#endregion
export { useDialog };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=useDialog.js.map