'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { useModal } from '@faceless-ui/modal';
import React from 'react';
import { useAuth } from '../../providers/Auth/index.js';
import { SelectAllStatus, useSelection } from '../../providers/Selection/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { ListSelectionButton } from '../ListSelection/index.js';
import { UnpublishManyDrawerContent } from './DrawerContent.js';
export const UnpublishMany = (props)=>{
    const { count, selectAll, selectedIDs, toggleAll } = useSelection();
    return /*#__PURE__*/ _jsxDEV(UnpublishMany_v4, {
        ...props,
        count: count,
        ids: selectedIDs,
        onSuccess: ()=>toggleAll(),
        selectAll: selectAll === SelectAllStatus.AllAvailable
    }, void 0, false, {
        fileName: "src/elements/UnpublishMany/index.tsx",
        lineNumber: 21,
        columnNumber: 5
    }, this);
};
export const UnpublishMany_v4 = /**
     * When multiple UnpublishMany components are rendered on the page, this will differentiate them.
     */ (props)=>{
    const { collection, collection: { slug, versions } = {}, count, ids, modalPrefix, onSuccess, selectAll, where } = props;
    const { t } = useTranslation();
    const { permissions } = useAuth();
    const { toggleModal } = useModal();
    const collectionPermissions = permissions?.collections?.[slug];
    const hasPermission = collectionPermissions?.update;
    const drawerSlug = `${modalPrefix ? `${modalPrefix}-` : ''}unpublish-${slug}`;
    if (!versions?.drafts || count === 0 || !hasPermission) {
        return null;
    }
    return /*#__PURE__*/ _jsxDEV(React.Fragment, {
        children: [
            /*#__PURE__*/ _jsxDEV(ListSelectionButton, {
                "aria-label": t('version:unpublish'),
                onClick: ()=>{
                    toggleModal(drawerSlug);
                },
                children: t('version:unpublish')
            }, void 0, false, {
                fileName: "src/elements/UnpublishMany/index.tsx",
                lineNumber: 70,
                columnNumber: 7
            }, this),
            /*#__PURE__*/ _jsxDEV(UnpublishManyDrawerContent, {
                collection: collection,
                drawerSlug: drawerSlug,
                ids: ids,
                onSuccess: onSuccess,
                selectAll: selectAll,
                where: where
            }, void 0, false, {
                fileName: "src/elements/UnpublishMany/index.tsx",
                lineNumber: 78,
                columnNumber: 7
            }, this)
        ]
    }, void 0, true, {
        fileName: "src/elements/UnpublishMany/index.tsx",
        lineNumber: 69,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map