'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { getTranslation } from '@payloadcms/translations';
import { FieldLabel } from '../../../fields/FieldLabel/index.js';
import { useConfig } from '../../../providers/Config/index.js';
import { useTranslation } from '../../../providers/Translation/index.js';
import { useListDrawerContext } from '../../ListDrawer/Provider.js';
import { ReactSelect } from '../../ReactSelect/index.js';
import { listHeaderClass } from '../index.js';
const drawerBaseClass = 'list-drawer';
export const DrawerRelationshipSelect = ()=>{
    const { i18n, t } = useTranslation();
    const { config: { collections }, getEntityConfig } = useConfig();
    const { enabledCollections, selectedOption, setSelectedOption } = useListDrawerContext();
    const enabledCollectionConfigs = collections.filter(({ slug })=>enabledCollections.includes(slug));
    if (enabledCollectionConfigs.length > 1) {
        const activeCollectionConfig = getEntityConfig({
            collectionSlug: selectedOption.value
        });
        return /*#__PURE__*/ _jsxDEV("div", {
            className: `${drawerBaseClass}__select-collection-wrap`,
            children: [
                /*#__PURE__*/ _jsxDEV(FieldLabel, {
                    label: t('upload:selectCollectionToBrowse')
                }, void 0, false, {
                    fileName: "src/elements/ListHeader/DrawerRelationshipSelect/index.tsx",
                    lineNumber: 29,
                    columnNumber: 9
                }, this),
                /*#__PURE__*/ _jsxDEV(ReactSelect, {
                    className: `${listHeaderClass}__select-collection`,
                    isClearable: false,
                    onChange: setSelectedOption,
                    options: enabledCollectionConfigs.map((coll)=>({
                            label: getTranslation(coll.labels.singular, i18n),
                            value: coll.slug
                        })),
                    value: {
                        label: getTranslation(activeCollectionConfig?.labels.singular, i18n),
                        value: activeCollectionConfig?.slug
                    }
                }, void 0, false, {
                    fileName: "src/elements/ListHeader/DrawerRelationshipSelect/index.tsx",
                    lineNumber: 30,
                    columnNumber: 9
                }, this)
            ]
        }, void 0, true, {
            fileName: "src/elements/ListHeader/DrawerRelationshipSelect/index.tsx",
            lineNumber: 28,
            columnNumber: 7
        }, this);
    }
    return null;
};

//# sourceMappingURL=index.js.map