import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState, useEffect } from "react";
import { Dialog, DialogContent, DialogTitle } from "../components/ui/dialog";
import { useEditContext } from "../editor/client/editContext";
import { NewPage } from "./NewPage";
import { OpenPage } from "./OpenPage";
export function NewPageDialog(props) {
    const [visible, setVisible] = useState(false);
    useEffect(() => {
        setVisible(true);
    }, []);
    const handleClose = () => {
        setVisible(false);
        props.onClose(null);
    };
    return (_jsx(Dialog, { open: visible, onOpenChange: (open) => {
            if (!open)
                handleClose();
        }, children: _jsxs(DialogContent, { className: "bg-neutral-grey-5 overflow-hidden border-none p-0 shadow-2xl", style: { width: "94vw", maxWidth: "1400px", height: "90vh" }, children: [_jsx(DialogTitle, { className: "sr-only", children: "Create New Page" }), _jsx(NewPage, { onClose: handleClose })] }) }));
}
export function OpenPageDialog(props) {
    const [visible, setVisible] = useState(false);
    const editContext = useEditContext();
    useEffect(() => {
        setVisible(true);
    }, []);
    const handleClose = () => {
        setVisible(false);
        props.onClose(null);
    };
    const handleNavigateToNewPage = () => {
        handleClose();
        // Use a small timeout to let the dialog close animation finish before opening the next one
        setTimeout(() => {
            editContext?.openDialog(NewPageDialog, {});
        }, 100);
    };
    return (_jsx(Dialog, { open: visible, onOpenChange: (open) => {
            if (!open)
                handleClose();
        }, children: _jsxs(DialogContent, { className: "bg-neutral-grey-5 overflow-hidden border-none p-0 shadow-2xl", style: { width: "94vw", maxWidth: "1400px", height: "90vh" }, children: [_jsx(DialogTitle, { className: "sr-only", children: "Open Page" }), _jsx(OpenPage, { onClose: handleClose, onNavigateToNewPage: handleNavigateToNewPage })] }) }));
}
//# sourceMappingURL=DialogWrappers.js.map