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 += ' sd1';
    rules += ' Ub1';
    rules += ' qb1';
    rules += ' gH1';
    rules += ' ob1';
    rules += ' nb1';
    rules += ' kb1';
    rules += ' jb1';
    if (!width) rules += ' ZJ1';
    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 += ' _Lf1';
    else rules += ' _Le1';
    rules += ' Oh1';
    rules += ' Olc1';
    rules += ' _Mc1';
    rules += ' _Kd1';
    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';
    }
    if (props.size === "XL") {
        rules += ' xb1';
        rules += ' _xa1';
    } else if (props.size === "L") {
        rules += ' xb1';
        rules += ' _xa1';
    } else if (props.size === "S") {
        rules += ' xb1';
        rules += ' _xa1';
    } else if (props.size === "XS") {
        rules += ' xb1';
        rules += ' _xa1';
    } else {
        rules += ' xb1';
        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.isDisabled) rules += ' pp1';
    else if (props.isSelected) {
        if (props.isPressed) rules += ' po1';
        else if (props.isFocusVisible) rules += ' po1';
        else if (props.isHovered) rules += ' po1';
        else rules += ' pt1';
    } else {
        if (props.isPressed) rules += ' pt1';
        else if (props.isFocusVisible) rules += ' pt1';
        else if (props.isHovered) rules += ' pt1';
        else rules += ' pv1';
    }
    if (props.isSelected) rules += ' ple1';
    else if (props.isDisabled) rules += ' plc1';
    else rules += ' plb1';
    rules += ' sd1';
    rules += ' eb1';
    rules += ' _oa1';
    rules += ' Sv1';
    rules += ' SgLWx3bd1';
    rules += ' Rv1';
    rules += ' RgLWx3bd1';
    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';
    rules += ' oj1';
    rules += ' nj1';
    rules += ' kj1';
    rules += ' jj1';
    rules += ' qc1';
    rules += ' qsd1';
    rules += ' -Qg41Lb-IAxCW0c1';
    rules += ' -Qg41Lb-gLWx3bIy1';
    rules += ' FRuFGYc1';
    rules += ' _Ca1';
    if (!position) rules += ' _Pc1';
    rules += ' _yb1';
    if (props.isJustified) {
        if (!flexGrow) rules += ' _ub1';
    }
    if (props.isJustified) {
        if (!flexBasis) rules += ' _sb1';
    }
    if (!flexShrink) rules += ' _va1';
    rules += ' _7c1';
    rules += ' __ca1';
    rules += ' _4c1';
    rules += ' g91';
    rules += ' _je1';
    rules += ' -_8sjo0b-t5ZbAob1';
    if (props.isSelected) {
        if (!zIndex) rules += ' _9b1';
    } else if (!zIndex) rules += ' _9c1';
    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';
    return rules;
};
const $e33225559d5e019f$var$slider = function anonymous(props) {
    let rules = " ";
    rules += ' gX1';
    if (props.isDisabled) rules += ' gld1';
    else rules += ' gle1';
    rules += ' Wr1';
    rules += ' _Er1';
    rules += ' Za1';
    rules += ' Fb1';
    rules += ' _qg1';
    rules += ' Yx6BKnd1';
    rules += ' Ydklsgce1';
    rules += ' Xc1';
    rules += ' _2a1';
    rules += ' _Pa1';
    rules += ' _oa1';
    rules += ' _jf1';
    rules += ' _kc1';
    rules += ' hc1';
    rules += ' mc1';
    rules += ' lc1';
    if (props.isDisabled) rules += ' iq1';
    else rules += ' in1';
    if (props.isDisabled) rules += ' ilc1';
    else rules += ' ild1';
    rules += ' oc1';
    rules += ' nc1';
    rules += ' kc1';
    rules += ' jc1';
    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: " _Ja1 _va1"
                                    })
                                }
                            ],
                            [
                                (0, $4JHQR$reactariacomponents.TextContext),
                                {
                                    slots: {
                                        [(0, $4JHQR$reactariacomponents.DEFAULT_SLOT)]: {}
                                    }
                                }
                            ],
                            [
                                (0, $6367bc87eb7d24ad$exports.TextContext),
                                {
                                    styles: " _Jb1 _Nc1 Pc1 _Yb1 _7c1"
                                }
                            ]
                        ],
                        children: /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)("div", {
                            ref: divRef,
                            style: (0, $2061c83559b50a66$exports.pressScale)(divRef)({
                                isPressed: isPressed
                            }),
                            className: " sd1 Uc1 Usd1 qc1 qsd1 Yd1 Xb1 _2b1 eb1 Na1",
                            children: typeof props.children === 'string' ? /*#__PURE__*/ (0, $4JHQR$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), {
                                children: props.children
                            }) : props.children
                        })
                    })
                ]
            })
    });
});


//# sourceMappingURL=SegmentedControl.cjs.map
