var $16c7f9b22cce3838$exports = require("./Button.cjs");
var $048d76b84370f141$exports = require("./utils.cjs");
var $f7b82bedbb70abac$exports = require("./Collection.cjs");
var $d5d46822336ca1e1$exports = require("./Label.cjs");
var $537333b300f7e667$exports = require("./ListBox.cjs");
var $433949643203e332$exports = require("./Autocomplete.cjs");
var $61557b2a9b2862a8$exports = require("./SelectionIndicator.cjs");
var $9a60bd90621ebc78$exports = require("./SharedElementTransition.cjs");
var $cab7d9a238d19c33$exports = require("./Text.cjs");
var $9dmNy$reactariauseTagGroup = require("react-aria/useTagGroup");
var $9dmNy$reactariaprivatecollectionsCollectionBuilder = require("react-aria/private/collections/CollectionBuilder");
var $9dmNy$reactariaprivateutilsfilterDOMProps = require("react-aria/private/utils/filterDOMProps");
var $9dmNy$reactariaprivatecollectionsBaseCollection = require("react-aria/private/collections/BaseCollection");
var $9dmNy$reactstatelyuseListState = require("react-stately/useListState");
var $9dmNy$reactariamergeProps = require("react-aria/mergeProps");
var $9dmNy$react = require("react");
var $9dmNy$reactariauseFocusRing = require("react-aria/useFocusRing");
var $9dmNy$reactariauseHover = require("react-aria/useHover");
var $9dmNy$reactariauseObjectRef = require("react-aria/useObjectRef");


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}

function $parcel$export(e, n, v, s) {
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}

$parcel$export(module.exports, "TagGroupContext", function () { return $c5db5fc82b83c4a1$export$5b07b5dd2cbd96e3; });
$parcel$export(module.exports, "TagListContext", function () { return $c5db5fc82b83c4a1$export$e755ce3685dd0ca9; });
$parcel$export(module.exports, "TagGroup", function () { return $c5db5fc82b83c4a1$export$67ea30858aaf75e3; });
$parcel$export(module.exports, "TagList", function () { return $c5db5fc82b83c4a1$export$f9fef0f55402315b; });
$parcel$export(module.exports, "Tag", function () { return $c5db5fc82b83c4a1$export$3288d34c523a1192; });
/*
 * Copyright 2022 Adobe. All rights reserved.
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */ 


















const $c5db5fc82b83c4a1$export$5b07b5dd2cbd96e3 = /*#__PURE__*/ (0, $9dmNy$react.createContext)(null);
const $c5db5fc82b83c4a1$export$e755ce3685dd0ca9 = /*#__PURE__*/ (0, $9dmNy$react.createContext)(null);
const $c5db5fc82b83c4a1$export$67ea30858aaf75e3 = /*#__PURE__*/ (0, $9dmNy$react.forwardRef)(function TagGroup(props, ref) {
    [props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, $c5db5fc82b83c4a1$export$5b07b5dd2cbd96e3);
    return /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement((0, $537333b300f7e667$exports.ListStateContext).Provider, {
        value: null
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement((0, $9dmNy$reactariaprivatecollectionsCollectionBuilder.CollectionBuilder), {
        content: props.children
    }, (collection)=>/*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement($c5db5fc82b83c4a1$var$TagGroupInner, {
            props: props,
            forwardedRef: ref,
            collection: collection
        })));
});
function $c5db5fc82b83c4a1$var$TagGroupInner({ props: props, forwardedRef: ref, collection: collection }) {
    let tagListRef = (0, $9dmNy$react.useRef)(null);
    // Extract the user provided id so it doesn't clash with the collection id provided by Autocomplete
    let { id: id, ...otherProps } = props;
    [otherProps, tagListRef] = (0, $048d76b84370f141$exports.useContextProps)(otherProps, tagListRef, (0, $433949643203e332$exports.SelectableCollectionContext));
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    let { filter: filter, shouldUseVirtualFocus: shouldUseVirtualFocus, ...DOMCollectionProps } = otherProps;
    let [labelRef, label] = (0, $048d76b84370f141$exports.useSlot)(!props['aria-label'] && !props['aria-labelledby']);
    let tagGroupState = (0, $9dmNy$reactstatelyuseListState.useListState)({
        ...DOMCollectionProps,
        children: undefined,
        collection: collection
    });
    let filteredState = (0, $9dmNy$reactstatelyuseListState.UNSTABLE_useFilteredListState)(tagGroupState, filter);
    // Prevent DOM props from going to two places.
    let domProps = (0, $9dmNy$reactariaprivateutilsfilterDOMProps.filterDOMProps)(otherProps, {
        global: true
    });
    let domPropOverrides = Object.fromEntries(Object.entries(domProps).map(([k, val])=>[
            k,
            k === 'id' ? val : undefined
        ]));
    let { gridProps: gridProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $9dmNy$reactariauseTagGroup.useTagGroup)({
        ...DOMCollectionProps,
        ...domPropOverrides,
        label: label
    }, filteredState, tagListRef);
    return /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
        render: props.render,
        ...domProps,
        id: id,
        ref: ref,
        slot: props.slot || undefined,
        className: props.className ?? 'react-aria-TagGroup',
        style: props.style
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement((0, $048d76b84370f141$exports.Provider), {
        values: [
            [
                (0, $d5d46822336ca1e1$exports.LabelContext),
                {
                    ...labelProps,
                    elementType: 'span',
                    ref: labelRef
                }
            ],
            [
                $c5db5fc82b83c4a1$export$e755ce3685dd0ca9,
                {
                    ...gridProps,
                    ref: tagListRef
                }
            ],
            [
                (0, $537333b300f7e667$exports.ListStateContext),
                filteredState
            ],
            [
                (0, $cab7d9a238d19c33$exports.TextContext),
                {
                    slots: {
                        description: descriptionProps,
                        errorMessage: errorMessageProps
                    }
                }
            ]
        ]
    }, props.children));
}
const $c5db5fc82b83c4a1$export$f9fef0f55402315b = /*#__PURE__*/ (0, $9dmNy$react.forwardRef)(function TagList(props, ref) {
    let state = (0, $9dmNy$react.useContext)((0, $537333b300f7e667$exports.ListStateContext));
    return state ? /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement($c5db5fc82b83c4a1$var$TagListInner, {
        props: props,
        forwardedRef: ref
    }) : /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement((0, $9dmNy$reactariaprivatecollectionsCollectionBuilder.Collection), props);
});
function $c5db5fc82b83c4a1$var$TagListInner({ props: props, forwardedRef: forwardedRef }) {
    let state = (0, $9dmNy$react.useContext)((0, $537333b300f7e667$exports.ListStateContext));
    let { CollectionRoot: CollectionRoot } = (0, $9dmNy$react.useContext)((0, $f7b82bedbb70abac$exports.CollectionRendererContext));
    let [gridProps, ref] = (0, $048d76b84370f141$exports.useContextProps)({}, forwardedRef, $c5db5fc82b83c4a1$export$e755ce3685dd0ca9);
    let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $9dmNy$reactariauseFocusRing.useFocusRing)();
    let renderValues = {
        isEmpty: state.collection.size === 0,
        isFocused: isFocused,
        isFocusVisible: isFocusVisible,
        state: state
    };
    let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
        ...props,
        children: undefined,
        defaultClassName: 'react-aria-TagList',
        values: renderValues
    });
    let persistedKeys = (0, $f7b82bedbb70abac$exports.usePersistedKeys)(state.selectionManager.focusedKey);
    let DOMProps = (0, $9dmNy$reactariaprivateutilsfilterDOMProps.filterDOMProps)(props, {
        global: true
    });
    return /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
        ...(0, $9dmNy$reactariamergeProps.mergeProps)(DOMProps, renderProps, gridProps, focusProps),
        ref: ref,
        "data-empty": state.collection.size === 0 || undefined,
        "data-focused": isFocused || undefined,
        "data-focus-visible": isFocusVisible || undefined
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement((0, $9a60bd90621ebc78$exports.SharedElementTransition), null, state.collection.size === 0 && props.renderEmptyState ? props.renderEmptyState(renderValues) : /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement(CollectionRoot, {
        collection: state.collection,
        persistedKeys: persistedKeys
    })));
}
const $c5db5fc82b83c4a1$export$3288d34c523a1192 = /*#__PURE__*/ (0, $9dmNy$reactariaprivatecollectionsCollectionBuilder.createLeafComponent)((0, $9dmNy$reactariaprivatecollectionsBaseCollection.ItemNode), (props, forwardedRef, item)=>{
    let state = (0, $9dmNy$react.useContext)((0, $537333b300f7e667$exports.ListStateContext));
    let ref = (0, $9dmNy$reactariauseObjectRef.useObjectRef)(forwardedRef);
    let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $9dmNy$reactariauseFocusRing.useFocusRing)({
        within: false
    });
    let { rowProps: rowProps, gridCellProps: gridCellProps, removeButtonProps: removeButtonProps, ...states } = (0, $9dmNy$reactariauseTagGroup.useTag)({
        item: item
    }, state, ref);
    let { hoverProps: hoverProps, isHovered: isHovered } = (0, $9dmNy$reactariauseHover.useHover)({
        isDisabled: !states.allowsSelection && !states.hasAction,
        onHoverStart: item.props.onHoverStart,
        onHoverChange: item.props.onHoverChange,
        onHoverEnd: item.props.onHoverEnd
    });
    let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
        ...props,
        id: undefined,
        children: item.rendered,
        defaultClassName: 'react-aria-Tag',
        values: {
            ...states,
            isFocusVisible: isFocusVisible,
            isHovered: isHovered,
            selectionMode: state.selectionManager.selectionMode,
            selectionBehavior: state.selectionManager.selectionBehavior
        }
    });
    (0, $9dmNy$react.useEffect)(()=>{
        if (!item.textValue && process.env.NODE_ENV !== 'production') console.warn('A `textValue` prop is required for <Tag> elements with non-plain text children for accessibility.');
    }, [
        item.textValue
    ]);
    let DOMProps = (0, $9dmNy$reactariaprivateutilsfilterDOMProps.filterDOMProps)(props, {
        global: true
    });
    delete DOMProps.id;
    delete DOMProps.onClick;
    return /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
        ref: ref,
        ...(0, $9dmNy$reactariamergeProps.mergeProps)(DOMProps, renderProps, rowProps, focusProps, hoverProps),
        "data-selected": states.isSelected || undefined,
        "data-disabled": states.isDisabled || undefined,
        "data-hovered": isHovered || undefined,
        "data-focused": states.isFocused || undefined,
        "data-focus-visible": isFocusVisible || undefined,
        "data-pressed": states.isPressed || undefined,
        "data-allows-removing": states.allowsRemoving || undefined,
        "data-selection-mode": state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement("div", {
        ...gridCellProps,
        style: {
            display: 'contents'
        }
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($9dmNy$react))).createElement((0, $048d76b84370f141$exports.Provider), {
        values: [
            [
                (0, $16c7f9b22cce3838$exports.ButtonContext),
                {
                    slots: {
                        remove: removeButtonProps
                    }
                }
            ],
            [
                (0, $f7b82bedbb70abac$exports.CollectionRendererContext),
                (0, $f7b82bedbb70abac$exports.DefaultCollectionRenderer)
            ],
            [
                (0, $61557b2a9b2862a8$exports.SelectionIndicatorContext),
                {
                    isSelected: states.isSelected
                }
            ]
        ]
    }, renderProps.children)));
});


//# sourceMappingURL=TagGroup.cjs.map
