import { getCreateAndSwitchToNewVersionCommand } from "../commands/createVersionCommand";
import { getItemDescriptor } from "../utils";
export const confirmCreateVersion = (editContext, language) => {
    const currentItem = editContext.currentItemDescriptor;
    editContext.confirm({
        message: "This page has no version in language " +
            language.name +
            " (" +
            language.languageCode +
            "). Do you want to create a new version?",
        header: "Create Language Version?",
        acceptLabel: "Create version",
        rejectLabel: "Switch without creating",
        rejectButtonVariant: "outline",
        actionsLayout: "single-row",
        showCancel: true,
        accept: async () => {
            await editContext?.executeCommand({
                command: getCreateAndSwitchToNewVersionCommand({
                    language: language.languageCode,
                }),
            });
        },
        reject: () => {
            // Switch to the language without creating a new version
            if (currentItem) {
                editContext.loadItem({
                    ...getItemDescriptor(currentItem),
                    language: language.languageCode,
                    version: 0,
                });
            }
        },
    });
};
//# sourceMappingURL=itemutils.js.map