import "./ColorSlider.css";
import {ColorHandle as $b4f7db7c45cd3de9$export$92862704de639678} from "./ColorHandle.mjs";
import {FieldLabel as $9afd80978c252040$export$1acdcf5a973a8414} from "./Field.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
import {jsx as $3i9ps$jsx, jsxs as $3i9ps$jsxs, Fragment as $3i9ps$Fragment} from "react/jsx-runtime";
import {useLocale as $3i9ps$useLocale, ColorSlider as $3i9ps$ColorSlider, SliderOutput as $3i9ps$SliderOutput, SliderTrack as $3i9ps$SliderTrack} from "react-aria-components";
import {createContext as $3i9ps$createContext, forwardRef as $3i9ps$forwardRef, useRef as $3i9ps$useRef} from "react";
import {useDOMRef as $3i9ps$useDOMRef} from "@react-spectrum/utils";

/*
 * 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 $495db619596088aa$export$717b2c0a523a0b53 = /*#__PURE__*/ (0, $3i9ps$createContext)(null);
const $495db619596088aa$export$44fd664bcca5b6fb = /*#__PURE__*/ (0, $3i9ps$forwardRef)(function ColorSlider(props, ref) {
    [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $495db619596088aa$export$717b2c0a523a0b53);
    let { UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, styles: styles } = props;
    let containerRef = (0, $3i9ps$useDOMRef)(ref);
    let trackRef = (0, $3i9ps$useRef)(null);
    let { direction: direction, locale: locale } = (0, $3i9ps$useLocale)();
    return /*#__PURE__*/ (0, $3i9ps$jsx)((0, $3i9ps$ColorSlider), {
        ...props,
        ref: containerRef,
        style: UNSAFE_style,
        // The visual label is hidden when vertical, so make it an aria-label instead.
        "aria-label": props['aria-label'] || (props.orientation === 'vertical' ? props.label : undefined),
        className: (renderProps)=>UNSAFE_className + 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];
                }
                if (props.orientation === "horizontal") {
                    if (!width) rules += ' Zr12';
                }
                if (props.orientation === "vertical") rules += ' Fs12';
                if (props.orientation === "vertical") rules += ' sb12';
                else if (props.orientation === "horizontal") rules += ' se12';
                rules += ' Dxumf9b12';
                rules += ' CmAQJSd12';
                rules += ' Ub12';
                return rules;
            }(renderProps, styles),
        children: ({ isDisabled: isDisabled, orientation: orientation, state: state })=>/*#__PURE__*/ (0, $3i9ps$jsxs)((0, $3i9ps$Fragment), {
                children: [
                    orientation === 'horizontal' && (props.label || props.label === undefined && !props['aria-label'] && !props['aria-labelledby']) && // If no external label, aria-label or aria-labelledby is provided,
                    // default to displaying the localized channel value.
                    // Specifically check if label is undefined. If label is `null` then display no visible label.
                    // A default aria-label is provided by useColorSlider in that case.
                    /*#__PURE__*/ (0, $3i9ps$jsx)((0, $9afd80978c252040$export$1acdcf5a973a8414), {
                        isDisabled: isDisabled,
                        contextualHelp: props.contextualHelp,
                        children: props.label || state.value.getChannelName(props.channel, locale)
                    }),
                    orientation === 'horizontal' && /*#__PURE__*/ (0, $3i9ps$jsx)((0, $3i9ps$SliderOutput), {
                        className: function anonymous(props) {
                            let rules = " ";
                            rules += ' zChk6v12';
                            rules += ' yChk6v12';
                            rules += ' BChk6v12';
                            rules += ' AChk6v12';
                            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 rules += ' pv12';
                            rules += ' ri12';
                            return rules;
                        }
                    }),
                    /*#__PURE__*/ (0, $3i9ps$jsx)((0, $3i9ps$SliderTrack), {
                        ref: trackRef,
                        style: ({ defaultStyle: defaultStyle, isDisabled: isDisabled })=>({
                                background: isDisabled ? undefined : `${defaultStyle.background}, repeating-conic-gradient(#E1E1E1 0% 25%, white 0% 50%) 50% / 16px 16px`
                            }),
                        className: function anonymous(props) {
                            let rules = " ";
                            rules += ' zCPUPs12';
                            rules += ' yCPUPs12';
                            rules += ' BCPUPs12';
                            rules += ' ACPUPs12';
                            if (props.orientation === "vertical") rules += ' Zo12';
                            else if (props.orientation === "horizontal") rules += ' Za12';
                            if (props.orientation === "vertical") rules += ' Fb12';
                            else if (props.orientation === "horizontal") rules += ' Fp12';
                            rules += ' ob12';
                            rules += ' nb12';
                            rules += ' kb12';
                            rules += ' jb12';
                            rules += ' Oi12';
                            rules += ' Ola12';
                            rules += ' _Mb12';
                            rules += ' _Ka12';
                            if (props.isDisabled) rules += ' _Le12';
                            else rules += ' _Lf12';
                            if (props.isDisabled) rules += ' gH12';
                            return rules;
                        },
                        children: /*#__PURE__*/ (0, $3i9ps$jsx)((0, $b4f7db7c45cd3de9$export$92862704de639678), {
                            containerRef: trackRef,
                            getPosition: ()=>{
                                let thumbLeft = direction === 'ltr' ? state.getThumbPercent(0) : 1 - state.getThumbPercent(0);
                                let x = state.orientation === 'horizontal' ? thumbLeft : 0.5;
                                let y = state.orientation === 'horizontal' ? 0.5 : 1 - state.getThumbPercent(0);
                                return {
                                    x: x,
                                    y: y
                                };
                            }
                        })
                    })
                ]
            })
    });
});


export {$495db619596088aa$export$717b2c0a523a0b53 as ColorSliderContext, $495db619596088aa$export$44fd664bcca5b6fb as ColorSlider};
//# sourceMappingURL=ColorSlider.mjs.map
