'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React from 'react';
import { ChevronIcon } from '../../../icons/Chevron/index.js';
import { useConfig } from '../../../providers/Config/index.js';
import { useTranslation } from '../../../providers/Translation/index.js';
import { Button } from '../../Button/index.js';
import { EditManyBulkUploads } from '../EditMany/index.js';
import { useFormsManager } from '../FormsManager/index.js';
import './index.scss';
const baseClass = 'bulk-upload--actions-bar';
export function ActionsBar({ collectionConfig }) {
    const { activeIndex, forms, setActiveIndex } = useFormsManager();
    const { t } = useTranslation();
    return /*#__PURE__*/ _jsxDEV("div", {
        className: baseClass,
        children: [
            /*#__PURE__*/ _jsxDEV("div", {
                className: `${baseClass}__navigation`,
                children: [
                    /*#__PURE__*/ _jsxDEV("p", {
                        className: `${baseClass}__locationText`,
                        children: [
                            /*#__PURE__*/ _jsxDEV("strong", {
                                children: activeIndex + 1
                            }, void 0, false, {
                                fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                                lineNumber: 29,
                                columnNumber: 11
                            }, this),
                            ` ${t('general:of')} `,
                            /*#__PURE__*/ _jsxDEV("strong", {
                                children: forms.length
                            }, void 0, false, {
                                fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                                lineNumber: 31,
                                columnNumber: 11
                            }, this)
                        ]
                    }, void 0, true, {
                        fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                        lineNumber: 28,
                        columnNumber: 9
                    }, this),
                    /*#__PURE__*/ _jsxDEV("div", {
                        className: `${baseClass}__controls`,
                        children: [
                            /*#__PURE__*/ _jsxDEV(Button, {
                                "aria-label": t('general:previous'),
                                buttonStyle: "none",
                                onClick: ()=>{
                                    const nextIndex = activeIndex - 1;
                                    if (nextIndex < 0) {
                                        setActiveIndex(forms.length - 1);
                                    } else {
                                        setActiveIndex(nextIndex);
                                    }
                                },
                                type: "button",
                                children: /*#__PURE__*/ _jsxDEV(ChevronIcon, {
                                    direction: "left"
                                }, void 0, false, {
                                    fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                                    lineNumber: 48,
                                    columnNumber: 13
                                }, this)
                            }, void 0, false, {
                                fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                                lineNumber: 35,
                                columnNumber: 11
                            }, this),
                            /*#__PURE__*/ _jsxDEV(Button, {
                                "aria-label": t('general:next'),
                                buttonStyle: "none",
                                onClick: ()=>{
                                    const nextIndex = activeIndex + 1;
                                    if (nextIndex === forms.length) {
                                        setActiveIndex(0);
                                    } else {
                                        setActiveIndex(nextIndex);
                                    }
                                },
                                type: "button",
                                children: /*#__PURE__*/ _jsxDEV(ChevronIcon, {
                                    direction: "right"
                                }, void 0, false, {
                                    fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                                    lineNumber: 63,
                                    columnNumber: 13
                                }, this)
                            }, void 0, false, {
                                fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                                lineNumber: 50,
                                columnNumber: 11
                            }, this)
                        ]
                    }, void 0, true, {
                        fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                        lineNumber: 34,
                        columnNumber: 9
                    }, this),
                    /*#__PURE__*/ _jsxDEV(EditManyBulkUploads, {
                        collection: collectionConfig
                    }, void 0, false, {
                        fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                        lineNumber: 66,
                        columnNumber: 9
                    }, this)
                ]
            }, void 0, true, {
                fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                lineNumber: 27,
                columnNumber: 7
            }, this),
            /*#__PURE__*/ _jsxDEV(Actions, {
                className: `${baseClass}__saveButtons`
            }, void 0, false, {
                fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                lineNumber: 69,
                columnNumber: 7
            }, this)
        ]
    }, void 0, true, {
        fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
        lineNumber: 26,
        columnNumber: 5
    }, this);
}
export function Actions({ className }) {
    const { getEntityConfig } = useConfig();
    const { t } = useTranslation();
    const { collectionSlug, hasPublishPermission, hasSavePermission, saveAllDocs } = useFormsManager();
    const collectionConfig = getEntityConfig({
        collectionSlug
    });
    return /*#__PURE__*/ _jsxDEV("div", {
        className: [
            `${baseClass}__buttons`,
            className
        ].filter(Boolean).join(' '),
        children: [
            collectionConfig?.versions?.drafts && hasSavePermission ? /*#__PURE__*/ _jsxDEV(Button, {
                buttonStyle: "secondary",
                onClick: ()=>void saveAllDocs({
                        overrides: {
                            _status: 'draft'
                        }
                    }),
                children: t('version:saveDraft')
            }, void 0, false, {
                fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                lineNumber: 87,
                columnNumber: 9
            }, this) : null,
            collectionConfig?.versions?.drafts && hasPublishPermission ? /*#__PURE__*/ _jsxDEV(Button, {
                onClick: ()=>void saveAllDocs({
                        overrides: {
                            _status: 'published'
                        }
                    }),
                children: t('version:publish')
            }, void 0, false, {
                fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                lineNumber: 95,
                columnNumber: 9
            }, this) : null,
            !collectionConfig?.versions?.drafts && hasSavePermission ? /*#__PURE__*/ _jsxDEV(Button, {
                onClick: ()=>void saveAllDocs(),
                children: t('general:save')
            }, void 0, false, {
                fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
                lineNumber: 101,
                columnNumber: 9
            }, this) : null
        ]
    }, void 0, true, {
        fileName: "src/elements/BulkUpload/ActionsBar/index.tsx",
        lineNumber: 85,
        columnNumber: 5
    }, this);
}

//# sourceMappingURL=index.js.map