import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { WandSparkles } from "lucide-react";
import { useState } from "react";
import { Dialog, DialogContent } from "../../components/ui/dialog";
import { StyledDialogTitle } from "../../components/ui/styled-dialog-title";
import { TemplateStructureInlineEditor, } from "./TemplateStructureInlineEditor";
export function TemplateBuilderDialog({ item, parentItem, initialName, initialBaseTemplates, onClose, }) {
    const isCreateMode = !!parentItem && !item;
    const [isOpen, setIsOpen] = useState(false);
    if (isCreateMode && parentItem) {
        return (_jsx(Dialog, { open: true, onOpenChange: (open) => !open && onClose?.(null), children: _jsxs(DialogContent, { className: "flex h-[90vh] w-[98vw] max-w-[1800px] flex-col gap-0 p-0", children: [_jsx(StyledDialogTitle, { icon: _jsx(WandSparkles, { strokeWidth: 1 }), title: "Create Template" }), _jsx("div", { className: "min-h-0 flex-1 overflow-hidden p-4", children: _jsx(TemplateStructureInlineEditor, { parentItem: parentItem, initialName: initialName, initialBaseTemplates: initialBaseTemplates, onCreated: (createdItem) => onClose?.(createdItem), onClose: () => onClose?.(null) }) })] }) }));
    }
    if (!item)
        return null;
    return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "bg-feedback-blue hover:bg-feedback-blue fixed right-6 bottom-6 z-30 inline-flex h-12 w-12 items-center justify-center rounded-full text-white shadow-lg transition hover:scale-[1.03]", onClick: () => setIsOpen(true), title: "Open template builder", "aria-label": "Open template builder", children: _jsx(WandSparkles, { strokeWidth: 1, className: "h-5 w-5" }) }), _jsx(Dialog, { open: isOpen, onOpenChange: setIsOpen, children: _jsxs(DialogContent, { className: "flex h-[90vh] w-[98vw] max-w-[1800px] flex-col gap-0 p-0", children: [_jsx(StyledDialogTitle, { icon: _jsx(WandSparkles, { strokeWidth: 1 }), title: "Template Builder" }), _jsx("div", { className: "min-h-0 flex-1 overflow-hidden p-4", children: _jsx(TemplateStructureInlineEditor, { item: item, onClose: () => setIsOpen(false) }) })] }) })] }));
}
//# sourceMappingURL=TemplateBuilderDialog.js.map