import "./ActionButton.css";
import {ActionButtonGroupContext as $10401bdc118cbc90$export$33f5f2f2cb85d743} from "./ActionButtonGroup.mjs";
import {AvatarContext as $3ffa2cd930156220$export$a20dad690e1279e2} from "./Avatar.mjs";
import {centerBaseline as $1f4b04be3f24aae3$export$9d7e2342a7e53afa} from "./CenterBaseline.mjs";
import {IconContext as $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed} from "../icons/Icon.mjs";
import {ImageContext as $dbd6f0b2503b938c$export$8151eb379fcf2442} from "./Image.mjs";
import $hl1Zj$intlStringsmjs from "./intlStrings.mjs";
import {NotificationBadgeContext as $bfb270fb056fefc5$export$9ab75c96ebaa396c} from "./NotificationBadge.mjs";
import {pressScale as $10ea7662e51a285b$export$56e8cba416805d8d} from "./pressScale.mjs";
import {ProgressCircle as $41ddd91dbbf0c389$export$c79b9d6b4cc92af7} from "./ProgressCircle.mjs";
import {SkeletonContext as $5ad421ec19460c48$export$74e166679b1f49ee} from "../icons/Skeleton.mjs";
import {Text as $8e847109a6ab556d$export$5f1af8db9871e1d6, TextContext as $8e847109a6ab556d$export$9afb8bc826b033ea} from "./Content.mjs";
import {useFormProps as $9b916426527cebe7$export$a6b5be5c6b451665} from "./Form.mjs";
import {usePendingState as $067ea9f64ccd4e8e$export$edc9ced5c3e5ff00} from "./Button.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
import {jsx as $hl1Zj$jsx, Fragment as $hl1Zj$Fragment, jsxs as $hl1Zj$jsxs} from "react/jsx-runtime";
import {OverlayTriggerStateContext as $hl1Zj$OverlayTriggerStateContext, useSlottedContext as $hl1Zj$useSlottedContext, Button as $hl1Zj$Button, Provider as $hl1Zj$Provider} from "react-aria-components";
import {createContext as $hl1Zj$createContext, forwardRef as $hl1Zj$forwardRef, useContext as $hl1Zj$useContext} from "react";
import {useFocusableRef as $hl1Zj$useFocusableRef} from "@react-spectrum/utils";
import {useLocalizedStringFormatter as $hl1Zj$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.
 */ 


















// These styles handle both ActionButton and ToggleButton
const $da878a05ab4a403e$var$iconOnly = ':has([slot=icon], [slot=avatar]):not(:has([data-rsp-slot=text]))';
const $da878a05ab4a403e$var$avatarOnly = ':has([slot=avatar]):not(:has([slot=icon], [data-rsp-slot=text]))';
const $da878a05ab4a403e$var$textOnly = ':has([data-rsp-slot=text]):not(:has([slot=icon], [slot=avatar]))';
const $da878a05ab4a403e$var$controlStyle = {
    font: {
        "default": "ui",
        size: {
            XS: "ui-xs",
            S: "ui-sm",
            L: "ui-lg",
            XL: "ui-xl"
        }
    },
    display: "flex",
    alignItems: "center",
    boxSizing: "border-box",
    paddingX: {
        "default": "edge-to-text",
        ":has([slot=icon]):not(:has([data-rsp-slot=text]))": 0
    },
    minWidth: {
        "default": 32,
        size: {
            XS: 20,
            S: 24,
            L: 40,
            XL: 48
        }
    },
    "--size": {
        type: "order",
        value: {
            "default": 1,
            size: {
                XS: 0.7901234567901234,
                S: 0.8888888888888888,
                L: 1.125,
                XL: 1.265625
            }
        }
    },
    "--radius": {
        type: "borderTopStartRadius",
        value: "default"
    },
    borderRadius: "round(var(--radius) * var(--size), 1px)",
    columnGap: "text-to-visual",
    "--iconMargin": {
        type: "marginStart",
        value: {
            "default": "[-0.14285714285714285em]",
            ":has([slot=icon]):not(:has([data-rsp-slot=text]))": 0
        }
    },
    height: {
        "default": 32,
        size: {
            XS: 20,
            S: 24,
            L: 40,
            XL: 48
        }
    }
};
const $da878a05ab4a403e$export$446543cff2a0f496 = function anonymous(props, overrides) {
    let rules = " ";
    let minWidth = false;
    let flexShrink = false;
    let flexGrow = false;
    let flexBasis = false;
    let width = false;
    let position = false;
    let zIndex = false;
    let matches = (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] === "N") minWidth = true;
        if (p[1] === "_v") flexShrink = true;
        if (p[1] === "_u") flexGrow = true;
        if (p[1] === "_s") flexBasis = true;
        if (p[1] === "Z") width = true;
        if (p[1] === "_P") position = true;
        if (p[1] === "_9") zIndex = true;
        rules += p[0];
    }
    if (props.isFocusVisible) rules += ' _Lf1';
    else rules += ' _Le1';
    if (props.isStaticColor) rules += ' Oe1';
    else rules += ' Oh1';
    rules += ' Olc1';
    rules += ' _Mc1';
    rules += ' _Kd1';
    if (props.staticColor === "white") rules += ' -Ovbhqd-gcwrnr1';
    else if (props.staticColor === "black") rules += ' -Ovbhqd-g4hn3s1';
    if (props.size === "XL") {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    } else if (props.size === "L") {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    } else if (props.size === "S") {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    } else if (props.size === "XS") {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    } else {
        rules += ' uk1';
        rules += ' ucJ9TBTb1';
        rules += ' ud3Euai1';
        rules += ' uea1';
        rules += ' ugb1';
        rules += ' uhd1';
        rules += ' uje1';
        rules += ' u2NhKxcl1';
        rules += ' uic1';
    }
    if (props.size === "XL") {
        rules += ' -_6BNtrc-e1';
        rules += ' vx1';
    } else if (props.size === "L") {
        rules += ' -_6BNtrc-d1';
        rules += ' vx1';
    } else if (props.size === "S") {
        rules += ' -_6BNtrc-b1';
        rules += ' vx1';
    } else if (props.size === "XS") {
        rules += ' -_6BNtrc-a1';
        rules += ' vx1';
    } else {
        rules += ' -_6BNtrc-c1';
        rules += ' vx1';
    }
    rules += ' xc1';
    rules += ' _xa1';
    if (props.size === "XL") {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    } else if (props.size === "L") {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    } else if (props.size === "S") {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    } else if (props.size === "XS") {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    } else {
        rules += ' _Fd1';
        rules += ' _FnuYUweb1';
    }
    if (props.isStaticColor) {
        if (props.isDisabled) rules += ' pi1';
        else if (props.isSelected) rules += ' ph1';
        else {
            if (props.isPressed) rules += ' pk1';
            else if (props.isFocusVisible) rules += ' pk1';
            else if (props.isHovered) rules += ' pk1';
            else rules += ' pj1';
        }
    } else if (props.isDisabled) rules += ' pp1';
    else if (props.isSelected) {
        if (props.isEmphasized) rules += ' px1';
        else rules += ' pr1';
    } else {
        if (props.isPressed) rules += ' po1';
        else if (props.isFocusVisible) rules += ' po1';
        else if (props.isHovered) rules += ' po1';
        else rules += ' pt1';
    }
    if (props.isDisabled) rules += ' plc1';
    else if (props.isSelected) rules += ' ple1';
    else rules += ' plb1';
    rules += ' se1';
    rules += ' eb1';
    rules += ' _oa1';
    rules += ' Sv1';
    rules += ' SgLWx3bd1';
    rules += ' SsAUsHd1';
    rules += ' Rv1';
    rules += ' RgLWx3bd1';
    rules += ' RsAUsHd1';
    if (props.size === "XL") {
        if (!minWidth) rules += ' Nl1';
    } else if (props.size === "L") {
        if (!minWidth) rules += ' Nj1';
    } else if (props.size === "S") {
        if (!minWidth) rules += ' Nf1';
    } else if (props.size === "XS") {
        if (!minWidth) rules += ' Ne1';
    } else if (!minWidth) rules += ' Nk1';
    if (props.size === "XL") rules += ' -SFnbic-_JaP8ec1';
    else if (props.size === "L") rules += ' -SFnbic-_J0K2hn1';
    else if (props.size === "S") rules += ' -SFnbic-_JJOW22b1';
    else if (props.size === "XS") rules += ' -SFnbic-_JICefdd1';
    else rules += ' -SFnbic-_Jb1';
    rules += ' -Bu7z1c-ob1';
    if (props.density === "compact") {
        rules += ' od1';
        rules += ' obj1';
    } else rules += ' oj1';
    if (props.density === "compact") {
        if (props.orientation === "vertical") rules += ' nbj1';
        else if (props.orientation === "horizontal") rules += ' nkj1';
        else rules += ' nd1';
    } else rules += ' nj1';
    if (props.density === "compact") {
        if (props.orientation === "vertical") rules += ' kkj1';
        else if (props.orientation === "horizontal") rules += ' kbj1';
        else rules += ' kd1';
    } else rules += ' kj1';
    if (props.density === "compact") {
        rules += ' jd1';
        rules += ' jkj1';
    } else rules += ' jj1';
    rules += ' qc1';
    rules += ' qsd1';
    rules += ' -Qg41Lb-IAxCW0c1';
    rules += ' -Qg41Lb-y5UFLdIy1';
    rules += ' -Qg41Lb-sAUsHIy1';
    rules += ' FRuFGYc1';
    rules += ' _Ca1';
    if (props.isInGroup) {
        if (!flexShrink) rules += ' _va1';
    } else if (!flexShrink) rules += ' _vb1';
    if (props.isJustified) {
        if (!flexGrow) rules += ' _ub1';
    }
    if (props.isJustified) {
        if (!flexBasis) rules += ' _sb1';
    }
    if (!width) rules += ' ZJ1';
    rules += ' _4c1';
    rules += ' Yd1';
    rules += ' Xb1';
    rules += ' _2b1';
    rules += ' _yb1';
    if (!position) rules += ' _Pc1';
    rules += ' CjpxCZ1';
    rules += ' Cy5UFLd2sgPTb1';
    rules += ' CwAP22cUolIUb1';
    rules += ' DZQmDFe1';
    rules += ' Dy5UFLdQgYBrc1';
    rules += ' DwAP22cQgYBrc1';
    rules += ' gqMFGYc1';
    rules += ' -_8sjo0b-t5ZbAob1';
    rules += ' _je1';
    if (props.isFocusVisible) {
        if (!zIndex) rules += ' _9d1';
    }
    rules += ' __ca1';
    rules += ' -B5H9Ae-WXN7eQb1';
    rules += ' -B5H9Ae-wAP22cWr1';
    rules += ' -SqFa4c-ZuUmpre1';
    rules += ' -dcAs1c-ZaP94G1';
    rules += ' -dcAs1c-wAP22cZa1';
    if (props.size === "XL") rules += ' -F_-Fz1';
    else if (props.size === "L") rules += ' -F_-Fv1';
    else if (props.size === "S") rules += ' -F_-Fp1';
    else if (props.size === "XS") rules += ' -F_-Fn1';
    else rules += ' -F_-Fx1';
    if (props.isStaticColor) {
        if (props.isSelected) {
            if (props.isDisabled) {
                if (props.isQuiet) rules += ' -g_-g91';
                else rules += ' -g_-gf1';
            } else {
                if (props.isPressed) rules += ' -g_-gj1';
                else if (props.isFocusVisible) rules += ' -g_-gj1';
                else if (props.isHovered) rules += ' -g_-gj1';
                else rules += ' -g_-gi1';
            }
        } else if (props.isPressed) rules += ' -g_-gg1';
        else if (props.isFocusVisible) rules += ' -g_-gg1';
        else if (props.isHovered) rules += ' -g_-gg1';
        else if (props.isQuiet) rules += ' -g_-g91';
        else rules += ' -g_-gf1';
    } else if (props.isSelected) {
        if (props.isDisabled) {
            if (props.isQuiet) rules += ' -g_-g91';
            else rules += ' -g_-gH1';
        } else if (props.isEmphasized) {
            if (props.isFocusVisible) rules += ' -g_-gUgARdd1';
            else if (props.isPressed) rules += ' -g_-gUgARdd1';
            else if (props.isHovered) rules += ' -g_-gUgARdd1';
            else rules += ' -g_-g5qAiPc1';
        } else {
            if (props.isPressed) rules += ' -g_-gu1';
            else if (props.isFocusVisible) rules += ' -g_-gu1';
            else if (props.isHovered) rules += ' -g_-gu1';
            else rules += ' -g_-g01';
        }
    } else {
        if (props.isPressed) rules += ' -g_-gF1';
        else if (props.isFocusVisible) rules += ' -g_-gF1';
        else if (props.isHovered) rules += ' -g_-gF1';
        else if (props.isQuiet) rules += ' -g_-g91';
        else rules += ' -g_-gH1';
    }
    if (props.isSelected) {
        if (props.isDisabled) rules += ' -g_-lgb1';
        else rules += ' -g_-lge1';
    } else rules += ' -g_-lgb1';
    return rules;
};
// Matching icon sizes. TBD.
const $da878a05ab4a403e$var$avatarSize = {
    XS: 14,
    S: 16,
    M: 20,
    L: 22,
    XL: 26
};
const $da878a05ab4a403e$export$2ff682723a46d413 = /*#__PURE__*/ (0, $hl1Zj$createContext)(null);
const $da878a05ab4a403e$export$cfc7921d29ef7b80 = /*#__PURE__*/ (0, $hl1Zj$forwardRef)(function ActionButton(props1, ref) {
    [props1, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props1, ref, $da878a05ab4a403e$export$2ff682723a46d413);
    props1 = (0, $9b916426527cebe7$export$a6b5be5c6b451665)(props1);
    let stringFormatter = (0, $hl1Zj$useLocalizedStringFormatter)((0, ($parcel$interopDefault($hl1Zj$intlStringsmjs))), '@react-spectrum/s2');
    let { isPending: isPending = false } = props1;
    let domRef = (0, $hl1Zj$useFocusableRef)(ref);
    let overlayTriggerState = (0, $hl1Zj$useContext)((0, $hl1Zj$OverlayTriggerStateContext));
    let ctx = (0, $hl1Zj$useSlottedContext)((0, $10401bdc118cbc90$export$33f5f2f2cb85d743));
    let isInGroup = !!ctx;
    let { density: density = 'regular', isJustified: isJustified, orientation: orientation = 'horizontal', staticColor: staticColor = props1.staticColor, isQuiet: isQuiet = props1.isQuiet, size: size = props1.size || 'M', isDisabled: isDisabled } = ctx || {};
    let { isProgressVisible: isProgressVisible } = (0, $067ea9f64ccd4e8e$export$edc9ced5c3e5ff00)(isPending);
    return /*#__PURE__*/ (0, $hl1Zj$jsx)((0, $hl1Zj$Button), {
        ...props1,
        isDisabled: props1.isDisabled ?? isDisabled,
        ref: domRef,
        style: (0, $10ea7662e51a285b$export$56e8cba416805d8d)(domRef, props1.UNSAFE_style),
        className: (renderProps)=>(props1.UNSAFE_className || '') + $da878a05ab4a403e$export$446543cff2a0f496({
                ...renderProps,
                // Retain hover styles when an overlay is open.
                isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,
                isDisabled: renderProps.isDisabled || isProgressVisible,
                staticColor: staticColor,
                isStaticColor: !!staticColor,
                size: size,
                isQuiet: isQuiet,
                density: density,
                isJustified: isJustified,
                orientation: orientation,
                isInGroup: isInGroup
            }, props1.styles),
        children: ({ isDisabled: isDisabled })=>/*#__PURE__*/ (0, $hl1Zj$jsx)((0, $hl1Zj$Fragment), {
                children: /*#__PURE__*/ (0, $hl1Zj$jsxs)((0, $hl1Zj$Provider), {
                    values: [
                        [
                            (0, $5ad421ec19460c48$export$74e166679b1f49ee),
                            null
                        ],
                        [
                            (0, $8e847109a6ab556d$export$9afb8bc826b033ea),
                            {
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' zYoLErc1';
                                    rules += ' yYoLErc1';
                                    rules += ' BYoLErc1';
                                    rules += ' AYoLErc1';
                                    rules += ' _Nc1';
                                    rules += ' Pc1';
                                    rules += ' _Yb1';
                                    rules += ' _7c1';
                                    if (props.isProgressVisible) rules += ' _6b1';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed),
                            {
                                render: (0, $1f4b04be3f24aae3$export$9d7e2342a7e53afa)({
                                    slot: 'icon',
                                    styles: " z2U5Crc1 y2U5Crc1 B2U5Crc1 A2U5Crc1"
                                }),
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' ZuUmpre1';
                                    rules += ' FuUmpre1';
                                    rules += ' I67logd1';
                                    if (props.isProgressVisible) rules += ' _6b1';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $3ffa2cd930156220$export$a20dad690e1279e2),
                            {
                                size: $da878a05ab4a403e$var$avatarSize[size],
                                styles: " I67logd1 z2U5Crc1 y2U5Crc1 B2U5Crc1 A2U5Crc1"
                            }
                        ],
                        [
                            (0, $dbd6f0b2503b938c$export$8151eb379fcf2442),
                            {
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    if (props.isProgressVisible) rules += ' _6b1';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $bfb270fb056fefc5$export$9ab75c96ebaa396c),
                            {
                                staticColor: staticColor,
                                size: props1.size === 'XS' ? undefined : props1.size,
                                isDisabled: isDisabled,
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' _Pa1';
                                    rules += ' WtedXZc1';
                                    rules += ' JlZStSb1';
                                    rules += ' Ijgro3c1';
                                    rules += ' z2mU1';
                                    rules += ' _A1IiWH1';
                                    if (props.isProgressVisible) rules += ' _6b1';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ]
                    ],
                    children: [
                        typeof props1.children === 'string' ? /*#__PURE__*/ (0, $hl1Zj$jsx)((0, $8e847109a6ab556d$export$5f1af8db9871e1d6), {
                            children: props1.children
                        }) : props1.children,
                        isPending && /*#__PURE__*/ (0, $hl1Zj$jsx)("div", {
                            className: function anonymous(props) {
                                let rules = " ";
                                rules += ' _Pa1';
                                rules += ' WF1';
                                rules += ' _EF1';
                                rules += ' _Zc1';
                                if (props.isProgressVisible) rules += ' _6c1';
                                else rules += ' _6b1';
                                return rules;
                            }({
                                isProgressVisible: isProgressVisible,
                                isPending: isPending
                            }),
                            children: /*#__PURE__*/ (0, $hl1Zj$jsx)((0, $41ddd91dbbf0c389$export$c79b9d6b4cc92af7), {
                                isIndeterminate: true,
                                "aria-label": stringFormatter.format('button.pending'),
                                size: "S",
                                staticColor: staticColor,
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    if (props.size === "XL") rules += ' Zo1';
                                    else if (props.size === "L") rules += ' Zm1';
                                    else if (props.size === "M") rules += ' Zl1';
                                    else if (props.size === "S") rules += ' Zk1';
                                    else if (props.size === "XS") rules += ' Zj1';
                                    if (props.size === "XL") rules += ' Fp1';
                                    else if (props.size === "L") rules += ' Fn1';
                                    else if (props.size === "M") rules += ' Fm1';
                                    else if (props.size === "S") rules += ' Fl1';
                                    else if (props.size === "XS") rules += ' Fk1';
                                    return rules;
                                }({
                                    size: size
                                })
                            })
                        })
                    ]
                })
            })
    });
});


export {$da878a05ab4a403e$export$446543cff2a0f496 as btnStyles, $da878a05ab4a403e$export$2ff682723a46d413 as ActionButtonContext, $da878a05ab4a403e$export$cfc7921d29ef7b80 as ActionButton};
//# sourceMappingURL=ActionButton.mjs.map
