'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React, { Fragment, useCallback } from 'react';
import { DeleteMany } from '../../../elements/DeleteMany/index.js';
import { EditMany_v4 } from '../../../elements/EditMany/index.js';
import { ListSelection_v4, ListSelectionButton } from '../../../elements/ListSelection/index.js';
import { PublishMany_v4 } from '../../../elements/PublishMany/index.js';
import { RestoreMany } from '../../../elements/RestoreMany/index.js';
import { UnpublishMany_v4 } from '../../../elements/UnpublishMany/index.js';
import { SelectAllStatus, useSelection } from '../../../providers/Selection/index.js';
import { useTranslation } from '../../../providers/Translation/index.js';
export const ListSelection = ({ collectionConfig, disableBulkDelete, disableBulkEdit, label, modalPrefix, showSelectAllAcrossPages = true, viewType, where })=>{
    const { count, selectAll, selectedIDs, toggleAll, totalDocs } = useSelection();
    const { t } = useTranslation();
    const onActionSuccess = useCallback(()=>toggleAll(), [
        toggleAll
    ]);
    if (count === 0) {
        return null;
    }
    const isTrashView = collectionConfig?.trash && viewType === 'trash';
    return /*#__PURE__*/ _jsxDEV(ListSelection_v4, {
        count: count,
        ListActions: [
            selectAll !== SelectAllStatus.AllAvailable && count < totalDocs && showSelectAllAcrossPages !== false ? /*#__PURE__*/ _jsxDEV(ListSelectionButton, {
                "aria-label": t('general:selectAll', {
                    count: `(${totalDocs})`,
                    label
                }),
                id: "select-all-across-pages",
                onClick: ()=>toggleAll(true),
                children: t('general:selectAll', {
                    count: `(${totalDocs})`,
                    label: ''
                })
            }, "select-all", false, {
                fileName: "src/views/List/ListSelection/index.tsx",
                lineNumber: 54,
                columnNumber: 11
            }, void 0) : null
        ].filter(Boolean),
        SelectionActions: [
            !disableBulkEdit && !isTrashView && /*#__PURE__*/ _jsxDEV(Fragment, {
                children: [
                    /*#__PURE__*/ _jsxDEV(EditMany_v4, {
                        collection: collectionConfig,
                        count: count,
                        ids: selectedIDs,
                        modalPrefix: modalPrefix,
                        onSuccess: onActionSuccess,
                        selectAll: selectAll === SelectAllStatus.AllAvailable,
                        where: where
                    }, void 0, false, {
                        fileName: "src/views/List/ListSelection/index.tsx",
                        lineNumber: 67,
                        columnNumber: 13
                    }, void 0),
                    /*#__PURE__*/ _jsxDEV(PublishMany_v4, {
                        collection: collectionConfig,
                        count: count,
                        ids: selectedIDs,
                        modalPrefix: modalPrefix,
                        onSuccess: onActionSuccess,
                        selectAll: selectAll === SelectAllStatus.AllAvailable,
                        where: where
                    }, void 0, false, {
                        fileName: "src/views/List/ListSelection/index.tsx",
                        lineNumber: 76,
                        columnNumber: 13
                    }, void 0),
                    /*#__PURE__*/ _jsxDEV(UnpublishMany_v4, {
                        collection: collectionConfig,
                        count: count,
                        ids: selectedIDs,
                        modalPrefix: modalPrefix,
                        onSuccess: onActionSuccess,
                        selectAll: selectAll === SelectAllStatus.AllAvailable,
                        where: where
                    }, void 0, false, {
                        fileName: "src/views/List/ListSelection/index.tsx",
                        lineNumber: 85,
                        columnNumber: 13
                    }, void 0)
                ]
            }, "bulk-actions", true, {
                fileName: "src/views/List/ListSelection/index.tsx",
                lineNumber: 66,
                columnNumber: 11
            }, void 0),
            isTrashView && /*#__PURE__*/ _jsxDEV(RestoreMany, {
                collection: collectionConfig,
                viewType: viewType
            }, "bulk-restore", false, {
                fileName: "src/views/List/ListSelection/index.tsx",
                lineNumber: 97,
                columnNumber: 11
            }, void 0),
            !disableBulkDelete && /*#__PURE__*/ _jsxDEV(DeleteMany, {
                collection: collectionConfig,
                modalPrefix: modalPrefix,
                viewType: viewType
            }, "bulk-delete", false, {
                fileName: "src/views/List/ListSelection/index.tsx",
                lineNumber: 100,
                columnNumber: 11
            }, void 0)
        ].filter(Boolean)
    }, void 0, false, {
        fileName: "src/views/List/ListSelection/index.tsx",
        lineNumber: 48,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map