import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { defineMessages, useIntl } from "react-intl";
import { UiPagedVirtualList, useElementSize } from "@gooddata/sdk-ui-kit";
import { bem } from "../bem.js";
const { b } = bem("gd-ui-ext-notifications-list");
/**
 * Default implementation of the NotificationsList component.
 *
 * @public
 */
export function DefaultNotificationsList({ Notification, NotificationsListEmptyState, NotificationsListErrorState, NotificationSkeletonItem, activeView, status, error, activeNotifications, markNotificationAsRead, onNotificationClick, hasNextPage, loadNextPage, itemHeight, itemsGap, itemPadding, skeletonItemsCount, maxListHeight = 0, closeNotificationsPanel, }) {
    const isError = status === "error";
    const isEmpty = status === "success" && activeNotifications?.length === 0;
    const isLoading = status === "loading" || status === "pending";
    const isSuccess = status === "success" && (activeNotifications?.length ?? 0) > 0;
    const { height, ref } = useElementSize();
    const { formatMessage } = useIntl();
    return (_jsxs("div", { className: b(), ref: (node) => {
            ref.current = node;
        }, role: "list", "aria-label": formatMessage(messages.notificationsListLabel), children: [isError ? _jsx(NotificationsListErrorState, { error: error }) : null, isEmpty ? _jsx(NotificationsListEmptyState, { activeView: activeView }) : null, isLoading || isSuccess ? (_jsx(UiPagedVirtualList, { items: activeNotifications, itemHeight: itemHeight, itemsGap: itemsGap, itemPadding: itemPadding, skeletonItemsCount: skeletonItemsCount, hasNextPage: hasNextPage, loadNextPage: loadNextPage, isLoading: isLoading, maxHeight: Math.max(maxListHeight, height, (itemHeight + itemsGap) * skeletonItemsCount), SkeletonItem: NotificationSkeletonItem, children: (notification) => (_jsx(Notification, { notification: notification, markNotificationAsRead: (id) => {
                        void markNotificationAsRead(id);
                    }, onNotificationClick: onNotificationClick, closeNotificationsPanel: closeNotificationsPanel })) })) : null] }));
}
const messages = defineMessages({
    notificationsListLabel: {
        id: "notifications.panel.notifications.list.label",
    },
});
//# sourceMappingURL=DefaultNotificationsList.js.map