import "./TagGroup.css";
import {ActionButton as $da878a05ab4a403e$export$cfc7921d29ef7b80} from "./ActionButton.mjs";
import $e17a4836f4b6cc28$export$2e2bcd8739ae039 from "../icons/AlertTriangle.mjs";
import {AvatarContext as $3ffa2cd930156220$export$a20dad690e1279e2} from "./Avatar.mjs";
import {centerBaseline as $1f4b04be3f24aae3$export$9d7e2342a7e53afa, CenterBaseline as $1f4b04be3f24aae3$export$768dac55bb57081d} from "./CenterBaseline.mjs";
import {ClearButton as $f6a62e6e68437458$export$13ec83e50bf04290} from "./ClearButton.mjs";
import {FieldLabel as $9afd80978c252040$export$1acdcf5a973a8414, helpTextStyles as $9afd80978c252040$export$13b1fd5431595bf6} from "./Field.mjs";
import {FormContext as $9b916426527cebe7$export$c24727297075ec6a, useFormProps as $9b916426527cebe7$export$a6b5be5c6b451665} from "./Form.mjs";
import {IconContext as $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed} from "../icons/Icon.mjs";
import {ImageContext as $dbd6f0b2503b938c$export$8151eb379fcf2442} from "./Image.mjs";
import $kY5I6$intlStringsmjs from "./intlStrings.mjs";
import {pressScale as $10ea7662e51a285b$export$56e8cba416805d8d} from "./pressScale.mjs";
import {Text as $8e847109a6ab556d$export$5f1af8db9871e1d6, TextContext as $8e847109a6ab556d$export$9afb8bc826b033ea} from "./Content.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
import {jsx as $kY5I6$jsx, jsxs as $kY5I6$jsxs, Fragment as $kY5I6$Fragment} from "react/jsx-runtime";
import {useLocale as $kY5I6$useLocale, TagGroup as $kY5I6$TagGroup, Provider as $kY5I6$Provider, TextContext as $kY5I6$TextContext, ButtonContext as $kY5I6$ButtonContext, TagList as $kY5I6$TagList, useSlottedContext as $kY5I6$useSlottedContext, Tag as $kY5I6$Tag, composeRenderProps as $kY5I6$composeRenderProps} from "react-aria-components";
import {CollectionBuilder as $kY5I6$CollectionBuilder, Collection as $kY5I6$Collection} from "@react-aria/collections";
import {createContext as $kY5I6$createContext, forwardRef as $kY5I6$forwardRef, useRef as $kY5I6$useRef, useState as $kY5I6$useState, useContext as $kY5I6$useContext, useMemo as $kY5I6$useMemo, useEffect as $kY5I6$useEffect} from "react";
import {flushSync as $kY5I6$flushSync} from "react-dom";
import {useEffectEvent as $kY5I6$useEffectEvent, useResizeObserver as $kY5I6$useResizeObserver, useLayoutEffect as $kY5I6$useLayoutEffect, inertValue as $kY5I6$inertValue, useId as $kY5I6$useId} from "@react-aria/utils";
import {useDOMRef as $kY5I6$useDOMRef} from "@react-spectrum/utils";
import {useLocalizedStringFormatter as $kY5I6$useLocalizedStringFormatter} from "@react-aria/i18n";


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}
/*
 * Copyright 2024 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 $1d63bfab43d9ffe1$export$5b07b5dd2cbd96e3 = /*#__PURE__*/ (0, $kY5I6$createContext)(null);
const $1d63bfab43d9ffe1$var$InternalTagGroupContext = /*#__PURE__*/ (0, $kY5I6$createContext)({});
const $1d63bfab43d9ffe1$export$67ea30858aaf75e3 = /*#__PURE__*/ (0, $kY5I6$forwardRef)(function TagGroup(props, ref) {
    [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $1d63bfab43d9ffe1$export$5b07b5dd2cbd96e3);
    props = (0, $9b916426527cebe7$export$a6b5be5c6b451665)(props);
    let { onRemove: onRemove } = props;
    return /*#__PURE__*/ (0, $kY5I6$jsx)($1d63bfab43d9ffe1$var$InternalTagGroupContext.Provider, {
        value: {
            onRemove: onRemove
        },
        children: /*#__PURE__*/ (0, $kY5I6$jsx)((0, $kY5I6$CollectionBuilder), {
            content: /*#__PURE__*/ (0, $kY5I6$jsx)((0, $kY5I6$Collection), {
                ...props
            }),
            children: (collection)=>/*#__PURE__*/ (0, $kY5I6$jsx)($1d63bfab43d9ffe1$var$TagGroupInner, {
                    props: props,
                    forwardedRef: ref,
                    collection: collection
                })
        })
    });
});
function $1d63bfab43d9ffe1$var$TagGroupInner({ props: { label: label, description: description, labelPosition: labelPosition = 'top', labelAlign: labelAlign = 'start', isEmphasized: isEmphasized, isInvalid: isInvalid, errorMessage: errorMessage, UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, size: size = 'M', ...props }, forwardedRef: ref, collection: collection }) {
    let stringFormatter = (0, $kY5I6$useLocalizedStringFormatter)((0, ($parcel$interopDefault($kY5I6$intlStringsmjs))), '@react-spectrum/s2');
    let { maxRows: maxRows, groupActionLabel: groupActionLabel, onGroupAction: onGroupAction, renderEmptyState: renderEmptyState = ()=>stringFormatter.format('tag.noTags'), ...otherProps } = props;
    let { direction: direction } = (0, $kY5I6$useLocale)();
    let containerRef = (0, $kY5I6$useRef)(null);
    let tagsRef = (0, $kY5I6$useRef)(null);
    let actionsRef = (0, $kY5I6$useRef)(null);
    let hiddenTagsRef = (0, $kY5I6$useRef)(null);
    let [tagState, setTagState] = (0, $kY5I6$useState)({
        visibleTagCount: collection.size,
        showCollapseButton: false
    });
    let [isCollapsed, setIsCollapsed] = (0, $kY5I6$useState)(maxRows != null);
    let { onRemove: onRemove } = (0, $kY5I6$useContext)($1d63bfab43d9ffe1$var$InternalTagGroupContext);
    let isEmpty = collection.size === 0;
    let showCollapseToggleButton = tagState.showCollapseButton || tagState.visibleTagCount < collection.size;
    let formContext = (0, $kY5I6$useContext)((0, $9b916426527cebe7$export$c24727297075ec6a));
    let domRef = (0, $kY5I6$useDOMRef)(ref);
    let allItems = (0, $kY5I6$useMemo)(()=>Array.from(collection), [
        collection
    ]);
    let items = (0, $kY5I6$useMemo)(()=>Array.from(collection).slice(0, !isCollapsed ? collection.size : tagState.visibleTagCount), [
        collection,
        tagState.visibleTagCount,
        isCollapsed
    ]);
    let updateVisibleTagCount = ()=>{
        if (maxRows == null) setTagState({
            visibleTagCount: collection.size,
            showCollapseButton: false
        });
        if (maxRows != null && maxRows > 0) {
            let computeVisibleTagCount = ()=>{
                let currContainerRef = hiddenTagsRef.current;
                let currTagsRef = hiddenTagsRef.current;
                let currActionsRef = actionsRef.current;
                if (!currContainerRef || !currTagsRef || collection.size === 0 || currContainerRef.parentElement == null) return {
                    visibleTagCount: 0,
                    showCollapseButton: false
                };
                // Count rows and show tags until we hit the maxRows.
                // I think this is still a safe assumption, and we don't need to queryAll for role=tag
                let tags = [
                    ...currTagsRef.children
                ];
                let currY = -Infinity;
                let rowCount = 0;
                let index = 0;
                let tagWidths = [];
                for (let tag of tags){
                    let { width: width, y: y } = tag.getBoundingClientRect();
                    if (y !== currY) {
                        currY = y;
                        rowCount++;
                    }
                    if (rowCount > maxRows) break;
                    tagWidths.push(width);
                    index++;
                }
                // Remove tags until there is space for the collapse button and action button (if present) on the last row.
                let buttons = currActionsRef ? [
                    ...currActionsRef.children
                ] : [];
                if (buttons.length > 0 && rowCount >= maxRows) {
                    let buttonsWidth = buttons.reduce((acc, curr)=>acc += curr.getBoundingClientRect().width, 0);
                    let margins = parseFloat(getComputedStyle(buttons[0]).marginInlineStart);
                    buttonsWidth += margins * 2;
                    let end = direction === 'ltr' ? 'right' : 'left';
                    let containerEnd = currContainerRef.parentElement?.getBoundingClientRect()[end] - margins;
                    let lastTagEnd = tags[index - 1]?.getBoundingClientRect()[end];
                    lastTagEnd += margins;
                    let availableWidth = containerEnd - lastTagEnd;
                    while(availableWidth <= buttonsWidth && index > 0){
                        let tagWidth = tagWidths.pop();
                        if (tagWidth != null) availableWidth += tagWidth;
                        index--;
                    }
                }
                return {
                    visibleTagCount: Math.max(index, 1),
                    showCollapseButton: index < collection.size
                };
            };
            let result = computeVisibleTagCount();
            (0, $kY5I6$flushSync)(()=>{
                setTagState(result);
            });
        }
    };
    let updateVisibleTagCountEffect = (0, $kY5I6$useEffectEvent)(updateVisibleTagCount);
    (0, $kY5I6$useResizeObserver)({
        ref: maxRows != null ? containerRef : undefined,
        onResize: updateVisibleTagCount
    });
    (0, $kY5I6$useLayoutEffect)(()=>{
        if (collection.size > 0 && maxRows != null && maxRows > 0) queueMicrotask(updateVisibleTagCountEffect);
    }, [
        collection.size,
        maxRows
    ]);
    (0, $kY5I6$useEffect)(()=>{
        // Recalculate visible tags when fonts are loaded.
        document.fonts?.ready.then(()=>updateVisibleTagCountEffect());
    }, []);
    let handlePressCollapse = ()=>{
        setIsCollapsed((prevCollapsed)=>!prevCollapsed);
    };
    let helpText = null;
    if (!isInvalid && description) helpText = /*#__PURE__*/ (0, $kY5I6$jsx)((0, $8e847109a6ab556d$export$5f1af8db9871e1d6), {
        slot: "description",
        styles: (0, $9afd80978c252040$export$13b1fd5431595bf6)({
            size: size
        }),
        children: description
    });
    else if (isInvalid) helpText = /*#__PURE__*/ (0, $kY5I6$jsxs)("div", {
        className: (0, $9afd80978c252040$export$13b1fd5431595bf6)({
            size: size,
            isInvalid: isInvalid
        }),
        children: [
            /*#__PURE__*/ (0, $kY5I6$jsx)((0, $1f4b04be3f24aae3$export$768dac55bb57081d), {
                children: /*#__PURE__*/ (0, $kY5I6$jsx)((0, $e17a4836f4b6cc28$export$2e2bcd8739ae039), {})
            }),
            /*#__PURE__*/ (0, $kY5I6$jsx)((0, $8e847109a6ab556d$export$5f1af8db9871e1d6), {
                slot: "errorMessage",
                children: errorMessage
            })
        ]
    });
    return /*#__PURE__*/ (0, $kY5I6$jsxs)((0, $kY5I6$TagGroup), {
        ...otherProps,
        ref: domRef,
        style: UNSAFE_style,
        className: UNSAFE_className + function anonymous(props, overrides) {
            let rules = " ";
            let gridColumnStart = false;
            let gridColumnEnd = false;
            let matches = String(overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L)[^\s]+/g);
            for (let p of matches){
                if (p[1] === "z") gridColumnStart = true;
                if (p[1] === "y") gridColumnEnd = true;
                rules += p[0];
            }
            rules += ' se11';
            if (props.isInForm) {
                if (!gridColumnStart) rules += ' z2mU11';
            }
            if (props.isInForm) {
                if (props.labelPosition === "side") {
                    if (!gridColumnEnd) rules += ' yvoofG11';
                }
            }
            if (props.isInForm) rules += ' DLwlgod11';
            else {
                if (props.labelPosition === "side") rules += ' DPlN5qb11';
                else if (props.labelPosition === "top") rules += ' DM8Mfn11';
            }
            if (props.labelPosition === "side") rules += ' EPlN5qb11';
            else if (props.labelPosition === "top") rules += ' E4w1sLc11';
            if (props.labelPosition === "side") rules += ' CbRM95c11';
            else if (props.labelPosition === "top") rules += ' Cxaocre11';
            if (props.size === "XL") {
                rules += ' -_6BNtrc-e11';
                rules += ' vx11';
            } else if (props.size === "L") {
                rules += ' -_6BNtrc-d11';
                rules += ' vx11';
            } else if (props.size === "S") {
                rules += ' -_6BNtrc-b11';
                rules += ' vx11';
            } else if (props.size === "XS") {
                rules += ' -_6BNtrc-a11';
                rules += ' vx11';
            } else {
                rules += ' -_6BNtrc-c11';
                rules += ' vx11';
            }
            rules += ' ea11';
            rules += ' _Fd11';
            rules += ' _FnuYUweb11';
            if (props.size === "XL") rules += ' -BhX7R-Fz11';
            else if (props.size === "L") rules += ' -BhX7R-Fv11';
            else if (props.size === "S") rules += ' -BhX7R-Fp11';
            else if (props.size === "XS") rules += ' -BhX7R-Fn11';
            else rules += ' -BhX7R-Fx11';
            rules += ' -AJjOLd-UVkF0Db11';
            rules += ' qg11';
            rules += ' __ca11';
            return rules;
        }({
            size: size,
            labelPosition: labelPosition,
            isInForm: !!formContext
        }, props.styles),
        children: [
            /*#__PURE__*/ (0, $kY5I6$jsx)((0, $9afd80978c252040$export$1acdcf5a973a8414), {
                size: size,
                labelPosition: labelPosition,
                labelAlign: labelAlign,
                contextualHelp: props.contextualHelp,
                children: label
            }),
            /*#__PURE__*/ (0, $kY5I6$jsx)("div", {
                ref: containerRef,
                className: function anonymous(props) {
                    let rules = " ";
                    rules += ' zXcEWr11';
                    rules += ' yXcEWr11';
                    rules += ' BXcEWr11';
                    rules += ' AXcEWr11';
                    rules += ' Nb11';
                    if (props.isEmpty) rules += ' Iy11';
                    else rules += ' Ib11';
                    if (props.isEmpty) rules += ' Hy11';
                    else rules += ' Hs11';
                    rules += ' _Pc11';
                    return rules;
                }({
                    isEmpty: isEmpty
                }),
                children: /*#__PURE__*/ (0, $kY5I6$jsx)((0, $9b916426527cebe7$export$c24727297075ec6a).Provider, {
                    value: {
                        ...formContext,
                        size: size
                    },
                    children: /*#__PURE__*/ (0, $kY5I6$jsxs)((0, $kY5I6$Provider), {
                        values: [
                            [
                                (0, $kY5I6$TextContext),
                                undefined
                            ],
                            [
                                (0, $kY5I6$ButtonContext),
                                undefined
                            ],
                            [
                                $1d63bfab43d9ffe1$export$5b07b5dd2cbd96e3,
                                {
                                    size: size,
                                    isEmphasized: isEmphasized
                                }
                            ]
                        ],
                        children: [
                            maxRows != null && /*#__PURE__*/ (0, $kY5I6$jsx)("div", {
                                // @ts-ignore
                                inert: (0, $kY5I6$inertValue)(true),
                                ref: hiddenTagsRef,
                                className: " sf11 _wb11 uk11 ucJ9TBTb11 ud3Euai11 uea11 ugb11 uhd11 uje11 u2NhKxcl11 uic11 _Pa11 Wr11 _lr11 _6b11 _Nc11 Pc11 _Ia11",
                                children: allItems.map((item)=>{
                                    // pull off individual props as an allow list, don't want refs or other props getting through
                                    // eslint-disable-next-line @typescript-eslint/no-unused-vars
                                    let { ref: ref, ...itemProps } = item.props;
                                    return /*#__PURE__*/ (0, $kY5I6$jsx)("div", {
                                        style: itemProps.UNSAFE_style,
                                        className: itemProps.className({
                                            size: size,
                                            allowsRemoving: Boolean(onRemove)
                                        }),
                                        children: /*#__PURE__*/ (0, $kY5I6$jsx)($1d63bfab43d9ffe1$var$TagWrapper, {
                                            id: item.key,
                                            textValue: item.textValue,
                                            isInRealDOM: true,
                                            size: size,
                                            allowsRemoving: !!onRemove,
                                            ...itemProps,
                                            children: itemProps.children({
                                                size: size,
                                                allowsRemoving: Boolean(onRemove),
                                                isInCtx: true
                                            })
                                        }, item.key)
                                    }, item.key);
                                })
                            }),
                            /*#__PURE__*/ (0, $kY5I6$jsx)((0, $kY5I6$TagList), {
                                ref: tagsRef,
                                items: items,
                                renderEmptyState: renderEmptyState,
                                className: " sf11 Nb11 uk11 ucJ9TBTb11 ud3Euai11 uea11 ugb11 uhd11 uje11 u2NhKxcl11 uic11 -_6BNtrc-c11 vx11 xb11 _xa11 _Fd11 _FnuYUweb11 pt11",
                                children: (item)=>/*#__PURE__*/ (0, $kY5I6$jsx)($1d63bfab43d9ffe1$export$3288d34c523a1192, {
                                        ...item.props,
                                        id: item.key,
                                        textValue: item.textValue
                                    })
                            }),
                            !isEmpty && (showCollapseToggleButton || groupActionLabel) && /*#__PURE__*/ (0, $kY5I6$jsx)($1d63bfab43d9ffe1$var$ActionGroup, {
                                collection: collection,
                                "aria-label": props['aria-label'],
                                "aria-labelledby": props['aria-labelledby'],
                                actionsRef: actionsRef,
                                tagState: tagState,
                                size: size,
                                isCollapsed: isCollapsed,
                                handlePressCollapse: handlePressCollapse,
                                onGroupAction: onGroupAction,
                                groupActionLabel: groupActionLabel
                            })
                        ]
                    })
                })
            }),
            helpText
        ]
    });
}
function $1d63bfab43d9ffe1$var$ActionGroup(props) {
    let stringFormatter = (0, $kY5I6$useLocalizedStringFormatter)((0, ($parcel$interopDefault($kY5I6$intlStringsmjs))), '@react-spectrum/s2');
    let { actionsRef: actionsRef, tagState: tagState, size: size, isCollapsed: isCollapsed, handlePressCollapse: handlePressCollapse, onGroupAction: onGroupAction, groupActionLabel: groupActionLabel, collection: collection, // directly use aria-labelling from the TagGroup because we can't use the id from the TagList
    // and we can't supply an id to the TagList because it'll cause an issue where all the tag ids flip back
    // and forth with their prefix in an infinite loop
    'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
    let actionsId = (0, $kY5I6$useId)();
    // might need to localize the aria-label which concatenates with this label
    let actionGroupLabel = stringFormatter.format('tag.actions');
    return /*#__PURE__*/ (0, $kY5I6$jsxs)("div", {
        role: "group",
        ref: actionsRef,
        id: actionsId,
        "aria-label": ariaLabel ? `${ariaLabel} ${actionGroupLabel}` : actionGroupLabel,
        "aria-labelledby": ariaLabelledBy ? ariaLabelledBy : undefined,
        className: " sf11",
        children: [
            tagState.showCollapseButton && /*#__PURE__*/ (0, $kY5I6$jsx)((0, $da878a05ab4a403e$export$cfc7921d29ef7b80), {
                isQuiet: true,
                size: size,
                styles: " Js11 Gs11 Is11 Hs11",
                UNSAFE_style: {
                    display: 'inline-flex'
                },
                onPress: handlePressCollapse,
                children: isCollapsed ? stringFormatter.format('tag.showAllButtonLabel', {
                    tagCount: collection.size
                }) : stringFormatter.format('tag.hideButtonLabel')
            }),
            groupActionLabel && onGroupAction && /*#__PURE__*/ (0, $kY5I6$jsx)((0, $da878a05ab4a403e$export$cfc7921d29ef7b80), {
                isQuiet: true,
                size: size,
                styles: " Js11 Gs11 Is11 Hs11",
                UNSAFE_style: {
                    display: 'inline-flex'
                },
                onPress: ()=>onGroupAction?.(),
                children: groupActionLabel
            })
        ]
    });
}
const $1d63bfab43d9ffe1$var$tagStyles = function anonymous(props) {
    let rules = " ";
    if (props.isFocusVisible) rules += ' _Lf11';
    else rules += ' _Le11';
    rules += ' Oh11';
    rules += ' Olc11';
    rules += ' _Mc11';
    rules += ' _Kd11';
    if (props.size === "XL") {
        rules += ' uk11';
        rules += ' ucJ9TBTb11';
        rules += ' ud3Euai11';
        rules += ' uea11';
        rules += ' ugb11';
        rules += ' uhd11';
        rules += ' uje11';
        rules += ' u2NhKxcl11';
        rules += ' uic11';
    } else if (props.size === "L") {
        rules += ' uk11';
        rules += ' ucJ9TBTb11';
        rules += ' ud3Euai11';
        rules += ' uea11';
        rules += ' ugb11';
        rules += ' uhd11';
        rules += ' uje11';
        rules += ' u2NhKxcl11';
        rules += ' uic11';
    } else if (props.size === "S") {
        rules += ' uk11';
        rules += ' ucJ9TBTb11';
        rules += ' ud3Euai11';
        rules += ' uea11';
        rules += ' ugb11';
        rules += ' uhd11';
        rules += ' uje11';
        rules += ' u2NhKxcl11';
        rules += ' uic11';
    } else if (props.size === "XS") {
        rules += ' uk11';
        rules += ' ucJ9TBTb11';
        rules += ' ud3Euai11';
        rules += ' uea11';
        rules += ' ugb11';
        rules += ' uhd11';
        rules += ' uje11';
        rules += ' u2NhKxcl11';
        rules += ' uic11';
    } else {
        rules += ' uk11';
        rules += ' ucJ9TBTb11';
        rules += ' ud3Euai11';
        rules += ' uea11';
        rules += ' ugb11';
        rules += ' uhd11';
        rules += ' uje11';
        rules += ' u2NhKxcl11';
        rules += ' uic11';
    }
    if (props.size === "XL") {
        rules += ' -_6BNtrc-e11';
        rules += ' vx11';
    } else if (props.size === "L") {
        rules += ' -_6BNtrc-d11';
        rules += ' vx11';
    } else if (props.size === "S") {
        rules += ' -_6BNtrc-b11';
        rules += ' vx11';
    } else if (props.size === "XS") {
        rules += ' -_6BNtrc-a11';
        rules += ' vx11';
    } else {
        rules += ' -_6BNtrc-c11';
        rules += ' vx11';
    }
    if (props.size === "XL") {
        rules += ' xb11';
        rules += ' _xa11';
    } else if (props.size === "L") {
        rules += ' xb11';
        rules += ' _xa11';
    } else if (props.size === "S") {
        rules += ' xb11';
        rules += ' _xa11';
    } else if (props.size === "XS") {
        rules += ' xb11';
        rules += ' _xa11';
    } else {
        rules += ' xb11';
        rules += ' _xa11';
    }
    if (props.size === "XL") {
        rules += ' _Fd11';
        rules += ' _FnuYUweb11';
    } else if (props.size === "L") {
        rules += ' _Fd11';
        rules += ' _FnuYUweb11';
    } else if (props.size === "S") {
        rules += ' _Fd11';
        rules += ' _FnuYUweb11';
    } else if (props.size === "XS") {
        rules += ' _Fd11';
        rules += ' _FnuYUweb11';
    } else {
        rules += ' _Fd11';
        rules += ' _FnuYUweb11';
    }
    if (props.isDisabled) rules += ' pp11';
    else if (props.isSelected) {
        if (props.isEmphasized) rules += ' px11';
        else rules += ' pr11';
    } else {
        if (props.isPressed) rules += ' po11';
        else if (props.isFocusVisible) rules += ' po11';
        else if (props.isHovered) rules += ' po11';
        else rules += ' pt11';
    }
    if (props.isDisabled) rules += ' plc11';
    else if (props.isSelected) rules += ' ple11';
    else rules += ' plb11';
    rules += ' sh11';
    rules += ' eb11';
    rules += ' _oa11';
    rules += ' Sv11';
    rules += ' SgLWx3bd11';
    if (props.allowsRemoving) rules += ' Rd11';
    else rules += ' Rv11';
    if (props.size === "XL") rules += ' Nl11';
    else if (props.size === "L") rules += ' Nj11';
    else if (props.size === "S") rules += ' Nf11';
    else if (props.size === "XS") rules += ' Ne11';
    else rules += ' Nk11';
    if (props.size === "XL") rules += ' -SFnbic-_JaP8ec11';
    else if (props.size === "L") rules += ' -SFnbic-_J0K2hn11';
    else if (props.size === "S") rules += ' -SFnbic-_JJOW22b11';
    else if (props.size === "XS") rules += ' -SFnbic-_JICefdd11';
    else rules += ' -SFnbic-_Jb11';
    rules += ' -Bu7z1c-ob11';
    rules += ' oj11';
    rules += ' nj11';
    rules += ' kj11';
    rules += ' jj11';
    rules += ' qc11';
    rules += ' qsd11';
    rules += ' -Qg41Lb-IAxCW0c11';
    rules += ' -Qg41Lb-gLWx3bIy11';
    rules += ' FRuFGYc11';
    rules += ' La11';
    rules += ' _5c11';
    rules += ' _Ca11';
    rules += ' Yd11';
    rules += ' Xb11';
    rules += ' _2b11';
    if (props.isDisabled) rules += ' gH11';
    else if (props.isSelected) {
        if (props.isEmphasized) {
            if (props.isFocusVisible) rules += ' gUgARdd11';
            else if (props.isPressed) rules += ' gUgARdd11';
            else if (props.isHovered) rules += ' gUgARdd11';
            else rules += ' g5qAiPc11';
        } else {
            if (props.isPressed) rules += ' gu11';
            else if (props.isFocusVisible) rules += ' gu11';
            else if (props.isHovered) rules += ' gu11';
            else rules += ' g011';
        }
    } else if (props.isFocusVisible) rules += ' gF11';
    else if (props.isHovered) rules += ' gF11';
    else rules += ' gH11';
    if (props.isSelected) rules += ' gle11';
    else rules += ' glb11';
    rules += ' _je11';
    rules += ' Js11';
    rules += ' Gs11';
    rules += ' Is11';
    rules += ' Hs11';
    if (props.isLink) rules += ' ry11';
    else rules += ' ri11';
    rules += ' -_8sjo0b-t5ZbAob11';
    if (props.size === "XL") rules += ' -F_-Fz11';
    else if (props.size === "L") rules += ' -F_-Fv11';
    else if (props.size === "S") rules += ' -F_-Fp11';
    else if (props.size === "XS") rules += ' -F_-Fn11';
    else rules += ' -F_-Fx11';
    return rules;
};
const $1d63bfab43d9ffe1$var$avatarSize = {
    S: 16,
    M: 20,
    L: 24
};
const $1d63bfab43d9ffe1$export$3288d34c523a1192 = /*#__PURE__*/ (0, $kY5I6$forwardRef)(function Tag({ children: children, textValue: textValue, ...props }, ref) {
    textValue ||= typeof children === 'string' ? children : undefined;
    let ctx = (0, $kY5I6$useSlottedContext)($1d63bfab43d9ffe1$export$5b07b5dd2cbd96e3);
    let isInRealDOM = Boolean(ctx?.size);
    let { size: size, isEmphasized: isEmphasized } = ctx ?? {};
    let domRef = (0, $kY5I6$useDOMRef)(ref);
    let backupRef = (0, $kY5I6$useRef)(null);
    domRef = domRef || backupRef;
    let isLink = props.href != null;
    return /*#__PURE__*/ (0, $kY5I6$jsx)((0, $kY5I6$Tag), {
        textValue: textValue,
        ...props,
        ref: domRef,
        style: (0, $10ea7662e51a285b$export$56e8cba416805d8d)(domRef),
        className: (renderProps)=>$1d63bfab43d9ffe1$var$tagStyles({
                size: size,
                isEmphasized: isEmphasized,
                isLink: isLink,
                ...renderProps
            }),
        children: (0, $kY5I6$composeRenderProps)(children, (children, renderProps)=>/*#__PURE__*/ (0, $kY5I6$jsx)($1d63bfab43d9ffe1$var$TagWrapper, {
                isInRealDOM: isInRealDOM,
                isEmphasized: isEmphasized,
                ...renderProps,
                children: typeof children === 'string' ? /*#__PURE__*/ (0, $kY5I6$jsx)((0, $8e847109a6ab556d$export$5f1af8db9871e1d6), {
                    children: children
                }) : children
            }))
    });
});
function $1d63bfab43d9ffe1$var$TagWrapper({ children: children, isDisabled: isDisabled, allowsRemoving: allowsRemoving, isInRealDOM: isInRealDOM, isEmphasized: isEmphasized, isSelected: isSelected }) {
    let { size: size = 'M' } = (0, $kY5I6$useSlottedContext)($1d63bfab43d9ffe1$export$5b07b5dd2cbd96e3) ?? {};
    return /*#__PURE__*/ (0, $kY5I6$jsxs)((0, $kY5I6$Fragment), {
        children: [
            isInRealDOM && /*#__PURE__*/ (0, $kY5I6$jsx)("div", {
                className: " sd11 Na11 eb11 Uc11 Usd11 qc11 qsd11 _yb11 g911",
                children: /*#__PURE__*/ (0, $kY5I6$jsx)((0, $kY5I6$Provider), {
                    values: [
                        [
                            (0, $8e847109a6ab556d$export$9afb8bc826b033ea),
                            {
                                styles: " _Jb11 _Nc11 Pc11 _Yb11 _7c11"
                            }
                        ],
                        [
                            (0, $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed),
                            {
                                render: (0, $1f4b04be3f24aae3$export$9d7e2342a7e53afa)({
                                    slot: 'icon',
                                    styles: " _Ja11"
                                }),
                                styles: " ZuUmpre11 FuUmpre11 I67logd11 _va11"
                            }
                        ],
                        [
                            (0, $3ffa2cd930156220$export$a20dad690e1279e2),
                            {
                                size: $1d63bfab43d9ffe1$var$avatarSize[size],
                                styles: " _Ja11"
                            }
                        ],
                        [
                            (0, $dbd6f0b2503b938c$export$8151eb379fcf2442),
                            {
                                styles: " ZuUmpre11 FuUmpre11 _va11 _Ja11 fa11 _Ha11 oa11 na11 ka11 ja11"
                            }
                        ]
                    ],
                    children: children
                })
            }),
            !isInRealDOM && children,
            allowsRemoving && isInRealDOM && /*#__PURE__*/ (0, $kY5I6$jsx)((0, $f6a62e6e68437458$export$13ec83e50bf04290), {
                slot: "remove",
                size: size,
                isStaticColor: isEmphasized && isSelected,
                isDisabled: isDisabled
            })
        ]
    });
}


export {$1d63bfab43d9ffe1$export$5b07b5dd2cbd96e3 as TagGroupContext, $1d63bfab43d9ffe1$export$67ea30858aaf75e3 as TagGroup, $1d63bfab43d9ffe1$export$3288d34c523a1192 as Tag};
//# sourceMappingURL=TagGroup.mjs.map
