'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { getTranslation } from '@payloadcms/translations';
import React from 'react';
import { useConfig } from '../../../providers/Config/index.js';
import { useFolder } from '../../../providers/Folders/index.js';
import { useTranslation } from '../../../providers/Translation/index.js';
import { Button } from '../../Button/index.js';
import { CheckboxPopup } from '../../CheckboxPopup/index.js';
import './index.scss';
const baseClass = 'collection-type';
export function FilterFolderTypePill() {
    const { activeCollectionFolderSlugs: visibleCollectionSlugs, allCollectionFolderSlugs: folderCollectionSlugs, folderCollectionSlug, refineFolderData } = useFolder();
    const { i18n, t } = useTranslation();
    const { config, getEntityConfig } = useConfig();
    const [allCollectionOptions] = React.useState(()=>{
        return config.collections.reduce((acc, collection)=>{
            if (collection.folders && folderCollectionSlugs.includes(collection.slug)) {
                acc.push({
                    label: getTranslation(collection.labels?.plural, i18n),
                    value: collection.slug
                });
            }
            return acc;
        }, [
            {
                label: getTranslation(getEntityConfig({
                    collectionSlug: folderCollectionSlug
                }).labels?.plural, i18n),
                value: folderCollectionSlug
            }
        ]);
    });
    return /*#__PURE__*/ _jsxDEV(CheckboxPopup, {
        Button: /*#__PURE__*/ _jsxDEV(Button, {
            buttonStyle: "pill",
            el: "div",
            icon: "chevron",
            margin: false,
            size: "small",
            children: [
                visibleCollectionSlugs.length ? /*#__PURE__*/ _jsxDEV("span", {
                    className: `${baseClass}__count`,
                    children: visibleCollectionSlugs.length
                }, void 0, false, {
                    fileName: "src/elements/FolderView/FilterFolderTypePill/index.tsx",
                    lineNumber: 54,
                    columnNumber: 13
                }, void 0) : null,
                t('version:type')
            ]
        }, void 0, true, {
            fileName: "src/elements/FolderView/FilterFolderTypePill/index.tsx",
            lineNumber: 52,
            columnNumber: 9
        }, void 0),
        onChange: ({ selectedValues: relationTo })=>{
            void refineFolderData({
                query: {
                    relationTo
                },
                updateURL: true
            });
        },
        options: allCollectionOptions,
        selectedValues: visibleCollectionSlugs
    }, "relation-to-selection-popup", false, {
        fileName: "src/elements/FolderView/FilterFolderTypePill/index.tsx",
        lineNumber: 50,
        columnNumber: 5
    }, this);
}

//# sourceMappingURL=index.js.map