require("./ColorSwatch.css");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $7Qhsa$reactjsxruntime = require("react/jsx-runtime");
var $7Qhsa$reactariacomponents = require("react-aria-components");
var $7Qhsa$react = require("react");
var $7Qhsa$reactspectrumutils = require("@react-spectrum/utils");


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

$parcel$export(module.exports, "ColorSwatchContext", () => $8b1ea085cefae738$export$83cc445538396800);
$parcel$export(module.exports, "InternalColorSwatchContext", () => $8b1ea085cefae738$export$2d9e1fe7b5c0ceb6);
$parcel$export(module.exports, "ColorSwatch", () => $8b1ea085cefae738$export$cae13e90592f246a);
/*
 * 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 $8b1ea085cefae738$export$83cc445538396800 = /*#__PURE__*/ (0, $7Qhsa$react.createContext)(null);
const $8b1ea085cefae738$export$2d9e1fe7b5c0ceb6 = /*#__PURE__*/ (0, $7Qhsa$react.createContext)(null);
const $8b1ea085cefae738$export$cae13e90592f246a = /*#__PURE__*/ (0, $7Qhsa$react.forwardRef)(function ColorSwatch(props, ref) {
    [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $8b1ea085cefae738$export$83cc445538396800);
    let domRef = (0, $7Qhsa$reactspectrumutils.useDOMRef)(ref);
    let ctx = (0, $7Qhsa$react.useContext)($8b1ea085cefae738$export$2d9e1fe7b5c0ceb6);
    let { size: size = ctx?.size || 'M', rounding: rounding = ctx?.rounding || 'default', color: color } = props;
    let nonNullValue = color || '#fff0';
    color = (0, $7Qhsa$react.useMemo)(()=>typeof nonNullValue === 'string' ? (0, $7Qhsa$reactariacomponents.parseColor)(nonNullValue) : nonNullValue, [
        nonNullValue
    ]);
    let swatch = /*#__PURE__*/ (0, $7Qhsa$reactjsxruntime.jsx)((0, $7Qhsa$reactariacomponents.ColorSwatch), {
        ...props,
        color: color,
        ref: domRef,
        style: ({ color: color })=>({
                // TODO: should there be a distinction between transparent and no value (e.g. null)?
                background: color.getChannelValue('alpha') > 0 ? `linear-gradient(${color}, ${color}), repeating-conic-gradient(#e6e6e6 0% 25%, white 0% 50%) 0% 50% / 16px 16px` : 'linear-gradient(to bottom right, transparent calc(50% - 2px), var(--slash-color) calc(50% - 2px) calc(50% + 2px), transparent calc(50% + 2px)) no-repeat'
            }),
        className: function anonymous(props, overrides) {
            let rules = " ";
            let width = false;
            let height = 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|F|M|K)[^\s]+/g);
            for (let p of matches){
                if (p[1] === "Z") width = true;
                if (p[1] === "F") height = true;
                rules += p[0];
            }
            if (props.size === "L") {
                if (!width) rules += ' Zw1';
            } else if (props.size === "M") {
                if (!width) rules += ' ZC1';
            } else if (props.size === "S") {
                if (!width) rules += ' Zo1';
            } else if (props.size === "XS") {
                if (!width) rules += ' Zu1';
            }
            if (props.size === "L") {
                if (!height) rules += ' Fv1';
            } else if (props.size === "M") {
                if (!height) rules += ' Fx1';
            } else if (props.size === "S") {
                if (!height) rules += ' Fp1';
            } else if (props.size === "XS") {
                if (!height) rules += ' Ft1';
            }
            if (props.rounding === "full") rules += ' og1';
            else if (props.rounding === "none") rules += ' od1';
            else if (props.rounding === "default") rules += ' oa1';
            if (props.rounding === "full") rules += ' ng1';
            else if (props.rounding === "none") rules += ' nd1';
            else if (props.rounding === "default") rules += ' na1';
            if (props.rounding === "full") rules += ' kg1';
            else if (props.rounding === "none") rules += ' kd1';
            else if (props.rounding === "default") rules += ' ka1';
            if (props.rounding === "full") rules += ' jg1';
            else if (props.rounding === "none") rules += ' jd1';
            else if (props.rounding === "default") rules += ' ja1';
            rules += ' iz1';
            rules += ' _kb1';
            rules += ' hb1';
            rules += ' mb1';
            rules += ' lb1';
            rules += ' _jf1';
            rules += ' _oa1';
            rules += ' _yb1';
            rules += ' -_8LZfRc-pq1';
            return rules;
        }({
            size: size,
            rounding: rounding
        }, props.styles)
    });
    // ColorSwatchPicker needs to wrap the swatch in a ListBoxItem.
    if (ctx) return ctx.useWrapper(swatch, color, rounding);
    return swatch;
});


//# sourceMappingURL=ColorSwatch.cjs.map
