// (C) 2021-2026 GoodData Corporation
export function loadNotificationChannelsCount(ctx, settings) {
    const { backend } = ctx;
    if (!(settings?.enableScheduling || settings?.enableAlerting) ||
        ctx.config?.isReadOnly ||
        ctx.config?.isExport ||
        ctx.config?.initialRenderMode === "export") {
        return Promise.resolve(0);
    }
    const typesToLoad = ["smtp", "webhook"];
    if (settings?.enableInPlatformNotifications) {
        typesToLoad.push("inPlatform");
    }
    if (settings?.enableNotificationChannelIdentifiers) {
        return backend
            .organizations()
            .getCurrentOrganization()
            .then((organization) => {
            return organization
                .notificationChannels()
                .getNotificationChannelsQuery()
                .withTypes(typesToLoad)
                .withSize(1)
                .queryIdentifiers();
        })
            .then((result) => result.totalCount ?? 0);
    }
    return backend
        .organizations()
        .getCurrentOrganization()
        .then((organization) => {
        return organization
            .notificationChannels()
            .getNotificationChannelsQuery()
            .withTypes(typesToLoad)
            .withSize(1)
            .query();
    })
        .then((result) => result.totalCount ?? 0);
}
//# sourceMappingURL=loadNotificationChannelsCount.js.map