import { jsxs as _jsxs } from "react/jsx-runtime";
import { useEffect, useState } from "react";
import { useEditContext } from "../client/editContext";
export function NoLayout() {
    const [lastPageItem, setLastPageItem] = useState(null);
    const editContext = useEditContext();
    useEffect(() => {
        const updateLastPage = async () => {
            if (!editContext)
                return;
            const pageViewContext = editContext?.getActiveSlotContext()?.primaryPageViewContext;
            if (!pageViewContext?.pageItemDescriptor)
                return;
            const lastPage = await editContext.itemsRepository.getItem(pageViewContext.pageItemDescriptor);
            if (lastPage)
                setLastPageItem(lastPage);
        };
        updateLastPage();
    }, [editContext?.currentItemDescriptor]);
    return (_jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center text-sm", children: ["Item has no layout.", lastPageItem && (_jsxs("div", { className: "cursor-pointer p-2 hover:underline", onClick: () => editContext?.loadItem(lastPageItem.descriptor), children: ["Load ", lastPageItem?.name, "?"] }))] }));
}
//# sourceMappingURL=NoLayout.js.map