import { jsx as _jsx } from "react/jsx-runtime";
import { SquarePlus } from "lucide-react";
const defaultIconSize = 16;
export async function getPlaceholderCommands(placeholders, editContext, providerContext) {
    const externalCommands = (await Promise.all((editContext.configuration.placeholderCommands?.providers ?? []).map((provider) => provider(placeholders, editContext, providerContext)))).flat();
    return externalCommands.filter((command) => command !== null);
}
export function openPlaceholderSettingsCommandProvider(placeholders, editContext, providerContext) {
    if (providerContext?.surface !== "componentTree")
        return [];
    if (editContext.isMobile)
        return [];
    if (placeholders.length !== 1)
        return [];
    const placeholder = placeholders[0];
    if (!placeholder?.placeholderSettingsItem)
        return [];
    return [
        {
            id: "open-placeholder-settings",
            label: "Open placeholder settings",
            icon: _jsx(SquarePlus, { size: defaultIconSize }),
            disabled: () => false,
            visibilityScopes: ["componentTree"],
            execute: async (context) => {
                const selectedPlaceholder = context.data?.placeholders?.[0] ?? placeholder;
                const settingsItem = selectedPlaceholder.placeholderSettingsItem;
                if (!settingsItem)
                    return;
                await context.editContext.loadItem(settingsItem, {
                    openInNewSlot: true,
                });
            },
        },
    ];
}
//# sourceMappingURL=placeholderCommands.js.map