require("./ActionButton.css");
var $7a26131f6144af2b$exports = require("./ActionButtonGroup.cjs");
var $38071d9ce246d4cf$exports = require("./Avatar.cjs");
var $e991cbcdf82ced71$exports = require("./CenterBaseline.cjs");
var $bde97c91243ed164$exports = require("../icons/Icon.cjs");
var $053b76ed3d29e13b$exports = require("./Image.cjs");
var $4526404114e78c80$exports = require("./intlStrings.cjs");
var $cd7301fb33ba8690$exports = require("./NotificationBadge.cjs");
var $2061c83559b50a66$exports = require("./pressScale.cjs");
var $1c116ea4b0d2d023$exports = require("./ProgressCircle.cjs");
var $5eb75e0c130e0669$exports = require("../icons/Skeleton.cjs");
var $6367bc87eb7d24ad$exports = require("./Content.cjs");
var $bfa4962d90c8af48$exports = require("./Form.cjs");
var $25d06cf8d4e72761$exports = require("./Button.cjs");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $9ZEgK$reactjsxruntime = require("react/jsx-runtime");
var $9ZEgK$reactariacomponents = require("react-aria-components");
var $9ZEgK$react = require("react");
var $9ZEgK$reactspectrumutils = require("@react-spectrum/utils");
var $9ZEgK$reactariai18n = require("@react-aria/i18n");


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, "btnStyles", () => $6e265ff388155b91$export$446543cff2a0f496);
$parcel$export(module.exports, "ActionButtonContext", () => $6e265ff388155b91$export$2ff682723a46d413);
$parcel$export(module.exports, "ActionButton", () => $6e265ff388155b91$export$cfc7921d29ef7b80);
/*
 * 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 $6e265ff388155b91$var$iconOnly = ':has([slot=icon], [slot=avatar]):not(:has([data-rsp-slot=text]))';
const $6e265ff388155b91$var$avatarOnly = ':has([slot=avatar]):not(:has([slot=icon], [data-rsp-slot=text]))';
const $6e265ff388155b91$var$textOnly = ':has([data-rsp-slot=text]):not(:has([slot=icon], [slot=avatar]))';
const $6e265ff388155b91$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 $6e265ff388155b91$export$446543cff2a0f496 = function anonymous(props, overrides) {
    let rules = " ";
    let minWidth = false;
    let position = false;
    let flexShrink = false;
    let flexGrow = false;
    let flexBasis = 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] === "_P") position = true;
        if (p[1] === "_v") flexShrink = true;
        if (p[1] === "_u") flexGrow = true;
        if (p[1] === "_s") flexBasis = true;
        if (p[1] === "_9") zIndex = true;
        rules += p[0];
    }
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    if (props.isStaticColor) rules += ' Oe12';
    else rules += ' Oh12';
    rules += ' Olc12';
    rules += ' _Mc12';
    rules += ' _Kd12';
    if (props.staticColor === "white") rules += ' -Ovbhqd-gcwrnr12';
    else if (props.staticColor === "black") rules += ' -Ovbhqd-g4hn3s12';
    if (props.size === "XL") {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "L") {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "S") {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "XS") {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else {
        rules += ' uk12';
        rules += ' uch12';
        rules += ' udi12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    }
    if (props.size === "XL") {
        rules += ' -_6BNtrc-e12';
        rules += ' vx12';
    } else if (props.size === "L") {
        rules += ' -_6BNtrc-d12';
        rules += ' vx12';
    } else if (props.size === "S") {
        rules += ' -_6BNtrc-b12';
        rules += ' vx12';
    } else if (props.size === "XS") {
        rules += ' -_6BNtrc-a12';
        rules += ' vx12';
    } else {
        rules += ' -_6BNtrc-c12';
        rules += ' vx12';
    }
    rules += ' xc12';
    rules += ' _xa12';
    rules += ' xezxGHbg12';
    rules += ' _xezxGHba12';
    if (props.size === "XL") {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "L") {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "S") {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "XS") {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    } else {
        rules += ' _Fd12';
        rules += ' _FezxGHba12';
        rules += ' _FnuYUweb12';
    }
    if (props.isStaticColor) {
        if (props.isDisabled) rules += ' pi12';
        else if (props.isSelected) rules += ' ph12';
        else {
            if (props.isPressed) rules += ' pk12';
            else if (props.isFocusVisible) rules += ' pk12';
            else if (props.isHovered) rules += ' pk12';
            else rules += ' pj12';
        }
    } else if (props.isDisabled) rules += ' pp12';
    else if (props.isSelected) {
        if (props.isEmphasized) rules += ' px12';
        else rules += ' pr12';
    } else {
        if (props.isPressed) rules += ' po12';
        else if (props.isFocusVisible) rules += ' po12';
        else if (props.isHovered) rules += ' po12';
        else rules += ' pt12';
    }
    if (props.isDisabled) rules += ' plc12';
    else if (props.isSelected) rules += ' ple12';
    else rules += ' plb12';
    rules += ' sd12';
    rules += ' eb12';
    rules += ' _oa12';
    rules += ' SMBFGYc12';
    rules += ' Rv12';
    rules += ' RgLWx3bd12';
    rules += ' RsAUsHd12';
    if (!minWidth) rules += ' N7yFGYc12';
    if (props.size === "XL") rules += ' -SFnbic-_JaP8ec12';
    else if (props.size === "L") rules += ' -SFnbic-_J0K2hn12';
    else if (props.size === "S") rules += ' -SFnbic-_JJOW22b12';
    else if (props.size === "XS") rules += ' -SFnbic-_JICefdd12';
    else rules += ' -SFnbic-_Jb12';
    rules += ' -Bu7z1c-ob12';
    if (props.density === "compact") {
        rules += ' od12';
        rules += ' obj12';
    } else rules += ' oj12';
    if (props.density === "compact") {
        if (props.orientation === "vertical") rules += ' nbj12';
        else if (props.orientation === "horizontal") rules += ' nkj12';
        else rules += ' nd12';
    } else rules += ' nj12';
    if (props.density === "compact") {
        if (props.orientation === "vertical") rules += ' kkj12';
        else if (props.orientation === "horizontal") rules += ' kbj12';
        else rules += ' kd12';
    } else rules += ' kj12';
    if (props.density === "compact") {
        rules += ' jd12';
        rules += ' jkj12';
    } else rules += ' jj12';
    rules += ' qc12';
    rules += ' qsd12';
    rules += ' -Qg41Lb-IAxCW0c12';
    rules += ' -Qg41Lb-y5UFLdIy12';
    rules += ' -Qg41Lb-sAUsHIy12';
    rules += ' FRuFGYc12';
    if (!position) rules += ' _Pc12';
    rules += ' _Ca12';
    if (props.isInGroup) {
        if (!flexShrink) rules += ' _va12';
    } else if (!flexShrink) rules += ' _vb12';
    if (props.isJustified) {
        if (!flexGrow) rules += ' _ub12';
    }
    if (props.isJustified) {
        if (!flexBasis) rules += ' _sb12';
    }
    rules += ' _4c12';
    rules += ' Yd12';
    rules += ' Xb12';
    rules += ' _2b12';
    rules += ' _yb12';
    rules += ' gqMFGYc12';
    rules += ' -_8sjo0b-t5ZbAob12';
    rules += ' _je12';
    if (props.isFocusVisible) {
        if (!zIndex) rules += ' _9d12';
    }
    rules += ' __ca12';
    rules += ' -B5H9Ae-WXN7eQb12';
    rules += ' -B5H9Ae-wAP22cWr12';
    rules += ' -SqFa4c-ZuUmpre12';
    rules += ' -dcAs1c-ZaYffXd12';
    rules += ' -dcAs1c-y5UFLdZt9HF512';
    rules += ' -dcAs1c-wAP22cZa12';
    if (props.size === "XL") rules += ' -F_-Fz12';
    else if (props.size === "L") rules += ' -F_-Fv12';
    else if (props.size === "S") rules += ' -F_-Fp12';
    else if (props.size === "XS") rules += ' -F_-Fn12';
    else rules += ' -F_-Fx12';
    if (props.isStaticColor) {
        if (props.isSelected) {
            if (props.isDisabled) {
                if (props.isQuiet) rules += ' -g_-g912';
                else rules += ' -g_-gf12';
            } else {
                if (props.isPressed) rules += ' -g_-gj12';
                else if (props.isFocusVisible) rules += ' -g_-gj12';
                else if (props.isHovered) rules += ' -g_-gj12';
                else rules += ' -g_-gi12';
            }
        } else if (props.isPressed) rules += ' -g_-gg12';
        else if (props.isFocusVisible) rules += ' -g_-gg12';
        else if (props.isHovered) rules += ' -g_-gg12';
        else if (props.isQuiet) rules += ' -g_-g912';
        else rules += ' -g_-gf12';
    } else if (props.isSelected) {
        if (props.isDisabled) {
            if (props.isQuiet) rules += ' -g_-g912';
            else rules += ' -g_-gH12';
        } else if (props.isEmphasized) {
            if (props.isFocusVisible) rules += ' -g_-gUgARdd12';
            else if (props.isPressed) rules += ' -g_-gUgARdd12';
            else if (props.isHovered) rules += ' -g_-gUgARdd12';
            else rules += ' -g_-g5qAiPc12';
        } else {
            if (props.isPressed) rules += ' -g_-gu12';
            else if (props.isFocusVisible) rules += ' -g_-gu12';
            else if (props.isHovered) rules += ' -g_-gu12';
            else rules += ' -g_-g012';
        }
    } else {
        if (props.isPressed) rules += ' -g_-gF12';
        else if (props.isFocusVisible) rules += ' -g_-gF12';
        else if (props.isHovered) rules += ' -g_-gF12';
        else if (props.isQuiet) rules += ' -g_-g912';
        else rules += ' -g_-gH12';
    }
    if (props.isSelected) {
        if (props.isDisabled) rules += ' -g_-lgb12';
        else rules += ' -g_-lge12';
    } else rules += ' -g_-lgb12';
    rules += ' -S_-Sv12';
    rules += ' -S_-gLWx3bSd12';
    rules += ' -S_-sAUsHSd12';
    if (props.size === "XL") rules += ' -N_-Nl12';
    else if (props.size === "L") rules += ' -N_-Nj12';
    else if (props.size === "S") rules += ' -N_-Nf12';
    else if (props.size === "XS") rules += ' -N_-Ne12';
    else rules += ' -N_-Nk12';
    return rules;
};
// Matching icon sizes. TBD.
const $6e265ff388155b91$var$avatarSize = {
    XS: 14,
    S: 16,
    M: 20,
    L: 22,
    X: 26
};
const $6e265ff388155b91$export$2ff682723a46d413 = /*#__PURE__*/ (0, $9ZEgK$react.createContext)(null);
const $6e265ff388155b91$export$cfc7921d29ef7b80 = /*#__PURE__*/ (0, $9ZEgK$react.forwardRef)(function ActionButton(props1, ref) {
    [props1, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props1, ref, $6e265ff388155b91$export$2ff682723a46d413);
    props1 = (0, $bfa4962d90c8af48$exports.useFormProps)(props1);
    let stringFormatter = (0, $9ZEgK$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4526404114e78c80$exports))), '@react-spectrum/s2');
    let { isPending: isPending = false } = props1;
    let domRef = (0, $9ZEgK$reactspectrumutils.useFocusableRef)(ref);
    let overlayTriggerState = (0, $9ZEgK$react.useContext)((0, $9ZEgK$reactariacomponents.OverlayTriggerStateContext));
    let ctx = (0, $9ZEgK$reactariacomponents.useSlottedContext)((0, $7a26131f6144af2b$exports.ActionButtonGroupContext));
    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' } = ctx || {};
    let { isProgressVisible: isProgressVisible } = (0, $25d06cf8d4e72761$exports.usePendingState)(isPending);
    return /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsx)((0, $9ZEgK$reactariacomponents.Button), {
        ...props1,
        ref: domRef,
        style: (0, $2061c83559b50a66$exports.pressScale)(domRef, props1.UNSAFE_style),
        className: (renderProps)=>(props1.UNSAFE_className || '') + $6e265ff388155b91$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, $9ZEgK$reactjsxruntime.jsx)((0, $9ZEgK$reactjsxruntime.Fragment), {
                children: /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsxs)((0, $9ZEgK$reactariacomponents.Provider), {
                    values: [
                        [
                            (0, $5eb75e0c130e0669$exports.SkeletonContext),
                            null
                        ],
                        [
                            (0, $6367bc87eb7d24ad$exports.TextContext),
                            {
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' _Jb12';
                                    rules += ' _Nc12';
                                    rules += ' Pc12';
                                    rules += ' _Yb12';
                                    rules += ' _7c12';
                                    if (props.isProgressVisible) rules += ' _6b12';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $bde97c91243ed164$exports.IconContext),
                            {
                                render: (0, $e991cbcdf82ced71$exports.centerBaseline)({
                                    slot: 'icon',
                                    styles: " _Ja12"
                                }),
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' ZuUmpre12';
                                    rules += ' FuUmpre12';
                                    rules += ' I67logd12';
                                    rules += ' _va12';
                                    if (props.isProgressVisible) rules += ' _6b12';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $38071d9ce246d4cf$exports.AvatarContext),
                            {
                                size: $6e265ff388155b91$var$avatarSize[size],
                                styles: " I67logd12 _va12 _Ja12"
                            }
                        ],
                        [
                            (0, $053b76ed3d29e13b$exports.ImageContext),
                            {
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    if (props.isProgressVisible) rules += ' _6b12';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ],
                        [
                            (0, $cd7301fb33ba8690$exports.NotificationBadgeContext),
                            {
                                staticColor: staticColor,
                                size: props1.size === 'XS' ? undefined : props1.size,
                                isDisabled: isDisabled,
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    rules += ' _Pa12';
                                    rules += ' WtedXZc12';
                                    rules += ' _A1IiWH12';
                                    rules += ' JlZStSb12';
                                    rules += ' IlZStSb12';
                                    if (props.isProgressVisible) rules += ' _6b12';
                                    return rules;
                                }({
                                    isProgressVisible: isProgressVisible
                                })
                            }
                        ]
                    ],
                    children: [
                        typeof props1.children === 'string' ? /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), {
                            children: props1.children
                        }) : props1.children,
                        isPending && /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsx)("div", {
                            className: function anonymous(props) {
                                let rules = " ";
                                rules += ' _Pa12';
                                rules += ' WF12';
                                rules += ' _EF12';
                                rules += ' _Zc12';
                                if (props.isProgressVisible) rules += ' _6c12';
                                else rules += ' _6b12';
                                return rules;
                            }({
                                isProgressVisible: isProgressVisible,
                                isPending: isPending
                            }),
                            children: /*#__PURE__*/ (0, $9ZEgK$reactjsxruntime.jsx)((0, $1c116ea4b0d2d023$exports.ProgressCircle), {
                                isIndeterminate: true,
                                "aria-label": stringFormatter.format('button.pending'),
                                size: "S",
                                staticColor: staticColor,
                                styles: function anonymous(props) {
                                    let rules = " ";
                                    if (props.size === "XL") rules += ' Zo12';
                                    else if (props.size === "L") rules += ' Zm12';
                                    else if (props.size === "M") rules += ' Zl12';
                                    else if (props.size === "S") rules += ' Zk12';
                                    else if (props.size === "XS") rules += ' Zj12';
                                    if (props.size === "XL") rules += ' Fp12';
                                    else if (props.size === "L") rules += ' Fn12';
                                    else if (props.size === "M") rules += ' Fm12';
                                    else if (props.size === "S") rules += ' Fl12';
                                    else if (props.size === "XS") rules += ' Fk12';
                                    return rules;
                                }({
                                    size: size
                                })
                            })
                        })
                    ]
                })
            })
    });
});


//# sourceMappingURL=ActionButton.cjs.map
