require("./SegmentedControl.css");
var $e991cbcdf82ced71$exports = require("./CenterBaseline.cjs");
var $bde97c91243ed164$exports = require("../icons/Icon.cjs");
var $2061c83559b50a66$exports = require("./pressScale.cjs");
var $6367bc87eb7d24ad$exports = require("./Content.cjs");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $4JHQR$reactjsxruntime = require("react/jsx-runtime");
var $4JHQR$reactariacomponents = require("react-aria-components");
var $4JHQR$react = require("react");
var $4JHQR$reactspectrumutils = require("@react-spectrum/utils");
var $4JHQR$reactariautils = require("@react-aria/utils");


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

$parcel$export(module.exports, "SegmentedControlContext", () => $e33225559d5e019f$export$c083c44d8a07dd35);
$parcel$export(module.exports, "SegmentedControl", () => $e33225559d5e019f$export$668709c620d0b8e2);
$parcel$export(module.exports, "SegmentedControlItem", () => $e33225559d5e019f$export$4fc12f2742e8cf3f);
/*
 * 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 $e33225559d5e019f$export$c083c44d8a07dd35 = /*#__PURE__*/ (0, $4JHQR$react.createContext)(null);
const $e33225559d5e019f$var$segmentedControl = function anonymous(props, overrides) {
    let rules = " ";
    let width = 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] === "Z") width = true;
        rules += p[0];
    }
    rules += ' sd12';
    rules += ' Ub12';
    rules += ' qb12';
    rules += ' gH12';
    rules += ' ob12';
    rules += ' nb12';
    rules += ' kb12';
    rules += ' jb12';
    if (!width) rules += ' ZJ12';
    return rules;
};
const $e33225559d5e019f$var$controlItem = function anonymous(props, overrides) {
    let rules = " ";
    let minWidth = false;
    let position = false;
    let flexGrow = false;
    let flexBasis = false;
    let flexShrink = 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] === "_u") flexGrow = true;
        if (p[1] === "_s") flexBasis = true;
        if (p[1] === "_v") flexShrink = true;
        if (p[1] === "_9") zIndex = true;
        rules += p[0];
    }
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    rules += ' Oh12';
    rules += ' _Mc12';
    rules += ' _Kd12';
    if (props.size === "XL") {
        rules += ' uk12';
        rules += ' ucJ9TBTb12';
        rules += ' ud3Euai12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "L") {
        rules += ' uk12';
        rules += ' ucJ9TBTb12';
        rules += ' ud3Euai12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "S") {
        rules += ' uk12';
        rules += ' ucJ9TBTb12';
        rules += ' ud3Euai12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "XS") {
        rules += ' uk12';
        rules += ' ucJ9TBTb12';
        rules += ' ud3Euai12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else {
        rules += ' uk12';
        rules += ' ucJ9TBTb12';
        rules += ' ud3Euai12';
        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';
    }
    if (props.size === "XL") {
        rules += ' xb12';
        rules += ' _xa12';
    } else if (props.size === "L") {
        rules += ' xb12';
        rules += ' _xa12';
    } else if (props.size === "S") {
        rules += ' xb12';
        rules += ' _xa12';
    } else if (props.size === "XS") {
        rules += ' xb12';
        rules += ' _xa12';
    } else {
        rules += ' xb12';
        rules += ' _xa12';
    }
    if (props.size === "XL") {
        rules += ' _Fd12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "L") {
        rules += ' _Fd12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "S") {
        rules += ' _Fd12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "XS") {
        rules += ' _Fd12';
        rules += ' _FnuYUweb12';
    } else {
        rules += ' _Fd12';
        rules += ' _FnuYUweb12';
    }
    if (props.isDisabled) rules += ' pp12';
    else if (props.isSelected) {
        if (props.isPressed) rules += ' po12';
        else if (props.isFocusVisible) rules += ' po12';
        else if (props.isHovered) rules += ' po12';
        else rules += ' pt12';
    } else {
        if (props.isPressed) rules += ' pt12';
        else if (props.isFocusVisible) rules += ' pt12';
        else if (props.isHovered) rules += ' pt12';
        else rules += ' pv12';
    }
    if (props.isSelected) rules += ' ple12';
    else if (props.isDisabled) rules += ' plc12';
    else rules += ' plb12';
    rules += ' sd12';
    rules += ' eb12';
    rules += ' _oa12';
    rules += ' Sv12';
    rules += ' SgLWx3bd12';
    rules += ' Rv12';
    rules += ' RgLWx3bd12';
    if (props.size === "XL") {
        if (!minWidth) rules += ' Nl12';
    } else if (props.size === "L") {
        if (!minWidth) rules += ' Nj12';
    } else if (props.size === "S") {
        if (!minWidth) rules += ' Nf12';
    } else if (props.size === "XS") {
        if (!minWidth) rules += ' Ne12';
    } else if (!minWidth) rules += ' Nk12';
    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';
    rules += ' oj12';
    rules += ' nj12';
    rules += ' kj12';
    rules += ' jj12';
    rules += ' qc12';
    rules += ' qsd12';
    rules += ' -Qg41Lb-IAxCW0c12';
    rules += ' -Qg41Lb-gLWx3bIy12';
    rules += ' FRuFGYc12';
    rules += ' _Ca12';
    if (!position) rules += ' _Pc12';
    rules += ' _yb12';
    if (props.isJustified) {
        if (!flexGrow) rules += ' _ub12';
    }
    if (props.isJustified) {
        if (!flexBasis) rules += ' _sb12';
    }
    if (!flexShrink) rules += ' _va12';
    rules += ' _7c12';
    rules += ' __ca12';
    rules += ' _4c12';
    rules += ' g912';
    rules += ' _je12';
    rules += ' -_8sjo0b-t5ZbAob12';
    if (props.isSelected) {
        if (!zIndex) rules += ' _9b12';
    } else if (!zIndex) rules += ' _9c12';
    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';
    return rules;
};
const $e33225559d5e019f$var$slider = function anonymous(props) {
    let rules = " ";
    rules += ' gX12';
    if (props.isDisabled) rules += ' gld12';
    else rules += ' gle12';
    rules += ' Wr12';
    rules += ' _Er12';
    rules += ' Za12';
    rules += ' Fb12';
    rules += ' _qg12';
    rules += ' Yx6BKnd12';
    rules += ' Ydklsgce12';
    rules += ' Xc12';
    rules += ' _2a12';
    rules += ' _Pa12';
    rules += ' _oa12';
    rules += ' _jf12';
    rules += ' _kc12';
    rules += ' hc12';
    rules += ' mc12';
    rules += ' lc12';
    if (props.isDisabled) rules += ' iq12';
    else rules += ' in12';
    if (props.isDisabled) rules += ' ilc12';
    else rules += ' ild12';
    rules += ' oc12';
    rules += ' nc12';
    rules += ' kc12';
    rules += ' jc12';
    return rules;
};
const $e33225559d5e019f$var$InternalSegmentedControlContext = /*#__PURE__*/ (0, $4JHQR$react.createContext)({});
const $e33225559d5e019f$export$668709c620d0b8e2 = /*#__PURE__*/ (0, $4JHQR$react.forwardRef)(function SegmentedControl(props, ref) {
    [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $e33225559d5e019f$export$c083c44d8a07dd35);
    let { defaultSelectedKey: defaultSelectedKey, selectedKey: selectedKey, onSelectionChange: onSelectionChange } = props;
    let domRef = (0, $4JHQR$reactspectrumutils.useDOMRef)(ref);
    let onChange = (values)=>{
        if (onSelectionChange) {
            let firstKey = values.values().next().value;
            if (firstKey != null) onSelectionChange(firstKey);
        }
    };
    return /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)((0, $4JHQR$reactariacomponents.ToggleButtonGroup), {
        ...props,
        selectedKeys: selectedKey != null ? [
            selectedKey
        ] : undefined,
        defaultSelectedKeys: defaultSelectedKey != null ? [
            defaultSelectedKey
        ] : undefined,
        disallowEmptySelection: true,
        ref: domRef,
        orientation: "horizontal",
        style: props.UNSAFE_style,
        onSelectionChange: onChange,
        className: (props.UNSAFE_className || '') + $e33225559d5e019f$var$segmentedControl(null, props.styles),
        "aria-label": props['aria-label'],
        children: /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)($e33225559d5e019f$var$DefaultSelectionTracker, {
            defaultValue: defaultSelectedKey,
            value: selectedKey,
            isJustified: props.isJustified,
            children: props.children
        })
    });
});
function $e33225559d5e019f$var$DefaultSelectionTracker(props) {
    let state = (0, $4JHQR$react.useContext)((0, $4JHQR$reactariacomponents.ToggleGroupStateContext));
    let isRegistered = (0, $4JHQR$react.useRef)(!(props.defaultValue == null && props.value == null));
    // default select the first available item
    let register = (0, $4JHQR$react.useCallback)((value)=>{
        if (state && !isRegistered.current) {
            isRegistered.current = true;
            state.toggleKey(value);
        }
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, []);
    return /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)((0, $4JHQR$reactariacomponents.Provider), {
        values: [
            [
                $e33225559d5e019f$var$InternalSegmentedControlContext,
                {
                    register: register,
                    isJustified: props.isJustified
                }
            ]
        ],
        children: props.children
    });
}
const $e33225559d5e019f$export$4fc12f2742e8cf3f = /*#__PURE__*/ (0, $4JHQR$react.forwardRef)(function SegmentedControlItem(props, ref) {
    let domRef = (0, $4JHQR$reactspectrumutils.useFocusableRef)(ref);
    let divRef = (0, $4JHQR$react.useRef)(null);
    let { register: register, isJustified: isJustified } = (0, $4JHQR$react.useContext)($e33225559d5e019f$var$InternalSegmentedControlContext);
    (0, $4JHQR$reactariautils.useLayoutEffect)(()=>{
        register?.(props.id);
    }, [
        register,
        props.id
    ]);
    return /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)((0, $4JHQR$reactariacomponents.ToggleButton), {
        ...props,
        ref: domRef,
        style: props.UNSAFE_style,
        className: (renderProps)=>(props.UNSAFE_className || '') + $e33225559d5e019f$var$controlItem({
                ...renderProps,
                isJustified: isJustified
            }, props.styles),
        children: ({ isPressed: isPressed, isDisabled: isDisabled })=>/*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsxs)((0, $4JHQR$reactjsxruntime.Fragment), {
                children: [
                    /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)((0, $4JHQR$reactariacomponents.SelectionIndicator), {
                        className: $e33225559d5e019f$var$slider({
                            isDisabled: isDisabled
                        })
                    }),
                    /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)((0, $4JHQR$reactariacomponents.Provider), {
                        values: [
                            [
                                (0, $bde97c91243ed164$exports.IconContext),
                                {
                                    render: (0, $e991cbcdf82ced71$exports.centerBaseline)({
                                        slot: 'icon',
                                        styles: " _Ja12 _va12"
                                    })
                                }
                            ],
                            [
                                (0, $4JHQR$reactariacomponents.TextContext),
                                {
                                    slots: {
                                        [(0, $4JHQR$reactariacomponents.DEFAULT_SLOT)]: {}
                                    }
                                }
                            ],
                            [
                                (0, $6367bc87eb7d24ad$exports.TextContext),
                                {
                                    styles: " _Jb12 _Nc12 Pc12 _Yb12 _7c12"
                                }
                            ]
                        ],
                        children: /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)("div", {
                            ref: divRef,
                            style: (0, $2061c83559b50a66$exports.pressScale)(divRef)({
                                isPressed: isPressed
                            }),
                            className: " sd12 Uc12 Usd12 qc12 qsd12 Yd12 Xb12 _2b12 eb12 Na12",
                            children: typeof props.children === 'string' ? /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), {
                                children: props.children
                            }) : props.children
                        })
                    })
                ]
            })
    });
});


//# sourceMappingURL=SegmentedControl.cjs.map
