require("./NumberField.css");
var $54686c7c3f031ee2$exports = require("./Add.cjs");
var $84c37b7bd5c1374e$exports = require("./Dash.cjs");
var $a0b996a550bb0891$exports = require("./Field.cjs");
var $bfa4962d90c8af48$exports = require("./Form.cjs");
var $2061c83559b50a66$exports = require("./pressScale.cjs");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $fwzUK$reactjsxruntime = require("react/jsx-runtime");
var $fwzUK$reactariacomponents = require("react-aria-components");
var $fwzUK$react = require("react");
var $fwzUK$reactspectrumutils = require("@react-spectrum/utils");
var $fwzUK$reactariautils = require("@react-aria/utils");
var $fwzUK$reactaria = require("react-aria");


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

$parcel$export(module.exports, "NumberFieldContext", () => $a366ef8f467b1cb5$export$b414a48cf5dcbc11);
$parcel$export(module.exports, "NumberField", () => $a366ef8f467b1cb5$export$63c5fa0b2fdccd2e);
/*
 * 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 $a366ef8f467b1cb5$export$b414a48cf5dcbc11 = /*#__PURE__*/ (0, $fwzUK$react.createContext)(null);
const $a366ef8f467b1cb5$var$inputButton = function anonymous(props) {
    let rules = " ";
    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-oa11';
    rules += ' oj11';
    rules += ' nj11';
    rules += ' kj11';
    rules += ' jj11';
    rules += ' sd11';
    rules += ' _Le11';
    rules += ' _Wa11';
    rules += ' _je11';
    rules += ' eb11';
    rules += ' _Ca11';
    if (props.size === "XL") rules += ' ZC11';
    else if (props.size === "L") rules += ' Zo11';
    else if (props.size === "M") rules += ' Zm11';
    else if (props.size === "S") rules += ' Zu11';
    rules += ' Fd11';
    if (props.type === "increment") rules += ' Iy11';
    else rules += ' Iw11';
    rules += ' fa11';
    rules += ' _va11';
    rules += ' Ma11';
    rules += ' Yd11';
    rules += ' Yle11';
    rules += ' Xb11';
    rules += ' Xlb11';
    rules += ' _2b11';
    rules += ' _2lb11';
    if (props.isDisabled) rules += ' gH11';
    else {
        if (props.isPressed) rules += ' gF11';
        else if (props.isFocusVisible) rules += ' gF11';
        else if (props.isHovered) rules += ' gF11';
        else rules += ' gH11';
    }
    if (props.isDisabled) rules += ' gld11';
    else if (props.isHovered) rules += ' gle11';
    else rules += ' glc11';
    if (props.isDisabled) rules += ' pp11';
    else {
        if (props.isPressed) rules += ' po11';
        else if (props.isFocusVisible) rules += ' po11';
        else if (props.isHovered) rules += ' po11';
        else rules += ' pt11';
    }
    rules += ' pla11';
    rules += ' ri11';
    return rules;
};
const $a366ef8f467b1cb5$var$iconStyles = " _va11 -_8sjo0b-t5ZbAob11";
const $a366ef8f467b1cb5$var$stepperContainerStyles = function anonymous(props) {
    let rules = " ";
    rules += ' sd11';
    rules += ' _tc11';
    if (props.size === "XL") rules += ' Ue11';
    else if (props.size === "L") rules += ' Ue11';
    else if (props.size === "M") rules += ' Ub11';
    else if (props.size === "S") rules += ' Ue11';
    if (props.size === "XL") rules += ' qe11';
    else if (props.size === "L") rules += ' qe11';
    else if (props.size === "M") rules += ' qb11';
    else if (props.size === "S") rules += ' qe11';
    if (props.size === "XL") rules += ' HWJpoB11';
    else if (props.size === "L") rules += ' HWJpoB11';
    else if (props.size === "M") rules += ' Hs11';
    else if (props.size === "S") rules += ' Hr11';
    return rules;
};
const $a366ef8f467b1cb5$export$63c5fa0b2fdccd2e = /*#__PURE__*/ (0, $fwzUK$react.forwardRef)(function NumberField(props1, ref) {
    [props1, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props1, ref, $a366ef8f467b1cb5$export$b414a48cf5dcbc11);
    props1 = (0, $bfa4962d90c8af48$exports.useFormProps)(props1);
    let { label: label, contextualHelp: contextualHelp, description: descriptionMessage, errorMessage: errorMessage, hideStepper: hideStepper, isRequired: isRequired, size: size = 'M', labelPosition: labelPosition = 'top', necessityIndicator: necessityIndicator, labelAlign: labelAlign = 'start', UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, ...numberFieldProps } = props1;
    let formContext = (0, $fwzUK$react.useContext)((0, $bfa4962d90c8af48$exports.FormContext));
    let domRef = (0, $fwzUK$react.useRef)(null);
    let inputRef = (0, $fwzUK$react.useRef)(null);
    let decrementButtonRef = (0, $fwzUK$react.useRef)(null);
    let incrementButtonRef = (0, $fwzUK$react.useRef)(null);
    // Expose imperative interface for ref
    (0, $fwzUK$react.useImperativeHandle)(ref, ()=>({
            ...(0, $fwzUK$reactspectrumutils.createFocusableRef)(domRef, inputRef),
            select () {
                if (inputRef.current) inputRef.current.select();
            },
            getInputElement () {
                return inputRef.current;
            }
        }));
    return /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)((0, $fwzUK$reactariacomponents.NumberField), {
        ref: domRef,
        isRequired: isRequired,
        ...numberFieldProps,
        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;
        }({
            isInForm: !!formContext,
            labelPosition: labelPosition,
            size: size
        }, props1.styles),
        children: ({ isDisabled: isDisabled, isInvalid: isInvalid })=>{
            return /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsxs)((0, $fwzUK$reactjsxruntime.Fragment), {
                children: [
                    /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.FieldLabel), {
                        isDisabled: isDisabled,
                        isRequired: isRequired,
                        size: size,
                        labelPosition: labelPosition,
                        labelAlign: labelAlign,
                        necessityIndicator: necessityIndicator,
                        contextualHelp: contextualHelp,
                        children: label
                    }),
                    /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsxs)((0, $a0b996a550bb0891$exports.FieldGroup), {
                        size: size,
                        styles: function anonymous(props) {
                            let rules = " ";
                            rules += ' zXcEWr11';
                            rules += ' yXcEWr11';
                            rules += ' BXcEWr11';
                            rules += ' AXcEWr11';
                            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.isQuiet) rules += ' _qd11';
                            else rules += ' _qtb11';
                            if (props.size === "XL") rules += ' -Anxdcc-Zt11';
                            else if (props.size === "L") rules += ' -Anxdcc-ZStdtne11';
                            else if (props.size === "S") rules += ' -Anxdcc-Zr11';
                            else rules += ' -Anxdcc-Z3fn9H11';
                            rules += ' __v6TNLWb11';
                            rules += ' SMBFGYc11';
                            rules += ' RfBFGYc11';
                            rules += ' -S_-Sv11';
                            if (props.isStepperHidden) rules += ' -R_-Rv11';
                            else rules += ' -R_-Rd11';
                            return rules;
                        }({
                            size: size,
                            isStepperHidden: hideStepper
                        }),
                        children: [
                            /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)((0, $fwzUK$reactariacomponents.InputContext).Consumer, {
                                children: (ctx)=>/*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)((0, $fwzUK$reactariacomponents.InputContext).Provider, {
                                        value: {
                                            ...ctx,
                                            ref: (0, $fwzUK$reactariautils.mergeRefs)(ctx?.ref, inputRef)
                                        },
                                        children: /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.Input), {})
                                    })
                            }),
                            isInvalid && /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.FieldErrorIcon), {
                                isDisabled: isDisabled
                            }),
                            !hideStepper && /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsxs)("div", {
                                className: $a366ef8f467b1cb5$var$stepperContainerStyles({
                                    size: size
                                }),
                                children: [
                                    /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)($a366ef8f467b1cb5$var$StepButton, {
                                        ref: decrementButtonRef,
                                        slot: "decrement",
                                        style: (renderProps)=>(0, $2061c83559b50a66$exports.pressScale)(decrementButtonRef)(renderProps),
                                        className: (renderProps)=>$a366ef8f467b1cb5$var$inputButton({
                                                ...renderProps,
                                                type: 'decrement',
                                                size: size
                                            }),
                                        children: /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)((0, $84c37b7bd5c1374e$exports.default), {
                                            size: size,
                                            className: $a366ef8f467b1cb5$var$iconStyles
                                        })
                                    }),
                                    /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)($a366ef8f467b1cb5$var$StepButton, {
                                        ref: incrementButtonRef,
                                        slot: "increment",
                                        style: (renderProps)=>(0, $2061c83559b50a66$exports.pressScale)(incrementButtonRef)(renderProps),
                                        className: (renderProps)=>$a366ef8f467b1cb5$var$inputButton({
                                                ...renderProps,
                                                type: 'increment',
                                                size: size
                                            }),
                                        children: /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)((0, $54686c7c3f031ee2$exports.default), {
                                            size: size,
                                            className: $a366ef8f467b1cb5$var$iconStyles
                                        })
                                    })
                                ]
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.HelpText), {
                        size: size,
                        isDisabled: isDisabled,
                        isInvalid: isInvalid,
                        description: descriptionMessage,
                        children: errorMessage
                    })
                ]
            });
        }
    });
});
const $a366ef8f467b1cb5$var$additionalButtonHTMLAttributes = new Set([
    'form',
    'formAction',
    'formEncType',
    'formMethod',
    'formNoValidate',
    'formTarget',
    'name',
    'value'
]);
let $a366ef8f467b1cb5$var$StepButton = /*#__PURE__*/ (0, $fwzUK$react.forwardRef)((props, ref)=>{
    [props, ref] = (0, $fwzUK$reactariacomponents.useContextProps)(props, ref, (0, $fwzUK$reactariacomponents.ButtonContext));
    let ctx = props;
    /**
   * Must use div for now because Safari pointer event bugs on disabled form elements.
   * Link https://bugs.webkit.org/show_bug.cgi?id=219188.
   */ let { buttonProps: buttonProps, isPressed: isPressed } = (0, $fwzUK$reactaria.useButton)({
        ...props,
        elementType: 'div'
    }, ref);
    let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $fwzUK$reactaria.useFocusRing)(props);
    let { hoverProps: hoverProps, isHovered: isHovered } = (0, $fwzUK$reactaria.useHover)(props);
    let renderProps = $a366ef8f467b1cb5$var$useRenderProps({
        ...props,
        values: {
            isHovered: isHovered,
            isPressed: isPressed,
            isFocused: isFocused,
            isFocusVisible: isFocusVisible,
            isDisabled: props.isDisabled || false
        },
        defaultClassName: 'react-aria-Button'
    });
    return /*#__PURE__*/ (0, $fwzUK$reactjsxruntime.jsx)("div", {
        ...(0, $fwzUK$reactariautils.filterDOMProps)(props, {
            propNames: $a366ef8f467b1cb5$var$additionalButtonHTMLAttributes
        }),
        ...(0, $fwzUK$reactariautils.mergeProps)(buttonProps, focusProps, hoverProps),
        ...renderProps,
        ref: ref,
        slot: props.slot || undefined,
        "data-disabled": props.isDisabled || undefined,
        "data-pressed": ctx.isPressed || isPressed || undefined,
        "data-hovered": isHovered || undefined,
        "data-focused": isFocused || undefined,
        "data-focus-visible": isFocusVisible || undefined
    });
});
// replace from RAC
function $a366ef8f467b1cb5$var$useRenderProps(props) {
    let { className: className, style: style, children: children, defaultClassName: defaultClassName, defaultChildren: defaultChildren, defaultStyle: defaultStyle, values: values } = props;
    return (0, $fwzUK$react.useMemo)(()=>{
        let computedClassName;
        let computedStyle;
        let computedChildren;
        if (typeof className === 'function') computedClassName = className({
            ...values,
            defaultClassName: defaultClassName
        });
        else computedClassName = className;
        if (typeof style === 'function') computedStyle = style({
            ...values,
            defaultStyle: defaultStyle || {}
        });
        else computedStyle = style;
        if (typeof children === 'function') computedChildren = children({
            ...values,
            defaultChildren: defaultChildren
        });
        else if (children == null) computedChildren = defaultChildren;
        else computedChildren = children;
        return {
            className: computedClassName ?? defaultClassName,
            style: computedStyle || defaultStyle ? {
                ...defaultStyle,
                ...computedStyle
            } : undefined,
            children: computedChildren ?? defaultChildren,
            'data-rac': ''
        };
    }, [
        className,
        style,
        children,
        defaultClassName,
        defaultChildren,
        defaultStyle,
        values
    ]);
}


//# sourceMappingURL=NumberField.cjs.map
