import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Button } from "../../components/ui/button";
import { useState } from "react";
import { Dialog, DialogContent } from "../../components/ui/dialog";
import { StyledDialogTitle } from "../../components/ui/styled-dialog-title";
import DialogButtons from "./DialogButtons";
import { ScrollingContentTree } from "../ScrollingContentTree";
import { rootItemId } from "../../config/config";
import { ArrowRightLeft } from "lucide-react";
export function CopyMoveTargetSelectorDialog(props) {
    if (!props)
        return null;
    const [selectedItem, setSelectedItem] = useState();
    const handleOk = () => {
        props.onClose?.(selectedItem ?? null);
    };
    const handleCancel = () => {
        props.onClose?.(null);
    };
    return (_jsx(Dialog, { open: true, onOpenChange: (open) => {
            if (!open) {
                props.onClose?.(null);
            }
        }, children: _jsxs(DialogContent, { className: "flex flex-col overflow-hidden border-none p-0 shadow-2xl", style: { width: "94vw", maxWidth: "1200px", height: "90vh" }, children: [_jsx(StyledDialogTitle, { icon: _jsx(ArrowRightLeft, { strokeWidth: 1 }), title: props.header }), _jsxs("div", { className: "flex h-full flex-1 flex-col overflow-hidden", children: [_jsx("div", { className: "min-h-0 flex-1 px-6 pt-6 pb-0", children: _jsx("div", { className: "border-border-default relative h-full overflow-hidden rounded-xl border bg-white p-1 shadow-sm", children: _jsx(ScrollingContentTree, { selectedItemId: selectedItem?.id, expandedItemId: props.items[0]?.id, rootItemId: rootItemId, onSelectionChange: async (node) => {
                                        if (!props.items[0])
                                            return;
                                        if (!node[0])
                                            setSelectedItem(null);
                                        else {
                                            const item = await props.editContext.itemsRepository.getItem(node[0]);
                                            setSelectedItem({
                                                id: node[0].id,
                                                version: 0,
                                                language: props.items[0].language,
                                                canCreate: item?.canCreate ?? false,
                                            });
                                        }
                                    } }) }) }), _jsxs(DialogButtons, { hideBorder: true, className: "bg-neutral-grey-5/50 mt-4", children: [_jsx(Button, { onClick: handleCancel, variant: "ghost", children: "Cancel" }), _jsx(Button, { onClick: handleOk, variant: "default", disabled: !selectedItem || !selectedItem.canCreate, className: "min-w-[120px]", children: props.label })] })] })] }) }));
}
//# sourceMappingURL=CopyMoveTargetSelectorDialog.js.map