import { jsx as _jsx } from "react/jsx-runtime";
import { useState } from "react";
import { SimpleTabs } from "../ui/SimpleTabs";
import { MediaFolderBrowser } from "../media-selector/MediaFolderBrowser";
import { ItemEditor } from "./ItemEditor";
import { useEditContext } from "../client/editContext";
export function MediaFolderEditView({ item }) {
    const [activeTabKey, setActiveTabKey] = useState("media-browser");
    const editContext = useEditContext();
    if (!editContext)
        return null;
    if (!item)
        item = editContext.item;
    if (!item)
        return null;
    const tabPanels = [];
    // Media Browser tab for media folders - First tab
    tabPanels.push({
        label: "Media Browser",
        content: (_jsx("div", { className: "relative flex min-h-0 flex-1 flex-col", children: _jsx("div", { className: "absolute inset-0 min-h-0 overflow-y-auto", children: _jsx(MediaFolderBrowser, { folderId: item.id, language: item.language, onMediaSelected: async (mediaId) => {
                        // Open media selector for the selected media item
                        const result = await editContext.selectMedia({
                            selectedIdPath: `${item.idPath}/${mediaId}`,
                            mode: "images",
                        });
                        if (result) {
                            console.log("Selected media:", result);
                        }
                    } }) }) })),
        id: "media-browser",
    });
    // Content tab - using the standard ItemEditor
    tabPanels.push({
        label: "Content",
        content: (_jsx("div", { className: "relative h-full", children: _jsx(ItemEditor, { item: item }) })),
        id: "content",
    });
    return (_jsx("div", { className: "flex h-full flex-col", children: _jsx(SimpleTabs, { tabs: tabPanels, className: "border-b border-gray-200 bg-gray-50 px-4 pt-2.5 text-sm", activeTab: tabPanels.findIndex((x) => x.id === activeTabKey) || 0, setActiveTab: (index) => setActiveTabKey(tabPanels[index]?.id) }, "media-folder-edit-tabs") }));
}
//# sourceMappingURL=MediaFolderEditView.js.map