var $5R8yz$reactariamergeProps = require("react-aria/mergeProps");
var $5R8yz$reactariaprivateutilsmergeRefs = require("react-aria/private/utils/mergeRefs");
var $5R8yz$react = require("react");
var $5R8yz$reactariaprivateutilsuseLayoutEffect = require("react-aria/private/utils/useLayoutEffect");
var $5R8yz$reactariauseObjectRef = require("react-aria/useObjectRef");


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}

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

$parcel$export(module.exports, "DEFAULT_SLOT", function () { return $048d76b84370f141$export$c62b8e45d58ddad9; });
$parcel$export(module.exports, "Provider", function () { return $048d76b84370f141$export$2881499e37b75b9a; });
$parcel$export(module.exports, "useRenderProps", function () { return $048d76b84370f141$export$4d86445c2cf5e3; });
$parcel$export(module.exports, "composeRenderProps", function () { return $048d76b84370f141$export$c245e6201fed2f75; });
$parcel$export(module.exports, "useSlottedContext", function () { return $048d76b84370f141$export$fabf2dc03a41866e; });
$parcel$export(module.exports, "useContextProps", function () { return $048d76b84370f141$export$29f1550f4b0d4415; });
$parcel$export(module.exports, "useSlot", function () { return $048d76b84370f141$export$9d4c57ee4c6ffdd8; });
$parcel$export(module.exports, "removeDataAttributes", function () { return $048d76b84370f141$export$ef03459518577ad4; });
$parcel$export(module.exports, "dom", function () { return $048d76b84370f141$export$df3a06d6289f983e; });
/*
 * Copyright 2022 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 $048d76b84370f141$export$c62b8e45d58ddad9 = Symbol('default');
function $048d76b84370f141$export$2881499e37b75b9a({ values: values, children: children }) {
    for (let [Context, value] of values)// @ts-ignore
    children = /*#__PURE__*/ (0, ($parcel$interopDefault($5R8yz$react))).createElement(Context.Provider, {
        value: value
    }, children);
    return children;
}
function $048d76b84370f141$export$4d86445c2cf5e3(props) {
    let { className: className, style: style, children: children, defaultClassName: defaultClassName, defaultChildren: defaultChildren, defaultStyle: defaultStyle, values: values, render: render } = props;
    return (0, $5R8yz$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': '',
            render: render ? (props)=>render(props, values) : undefined
        };
    }, [
        className,
        style,
        children,
        defaultClassName,
        defaultChildren,
        defaultStyle,
        values,
        render
    ]);
}
function $048d76b84370f141$export$c245e6201fed2f75(// https://stackoverflow.com/questions/60898079/typescript-type-t-or-function-t-usage
value, wrap) {
    return (renderProps)=>wrap(typeof value === 'function' ? value(renderProps) : value, renderProps);
}
function $048d76b84370f141$export$fabf2dc03a41866e(context, slot) {
    let ctx = (0, $5R8yz$react.useContext)(context);
    if (slot === null) // An explicit `null` slot means don't use context.
    return null;
    if (ctx && typeof ctx === 'object' && 'slots' in ctx && ctx.slots) {
        let slotKey = slot || $048d76b84370f141$export$c62b8e45d58ddad9;
        if (!ctx.slots[slotKey]) {
            let availableSlots = new Intl.ListFormat().format(Object.keys(ctx.slots).map((p)=>`"${p}"`));
            let errorMessage = slot ? `Invalid slot "${slot}".` : 'A slot prop is required.';
            throw new Error(`${errorMessage} Valid slot names are ${availableSlots}.`);
        }
        return ctx.slots[slotKey];
    }
    // @ts-ignore
    return ctx;
}
function $048d76b84370f141$export$29f1550f4b0d4415(props, ref, context) {
    let ctx = $048d76b84370f141$export$fabf2dc03a41866e(context, props.slot) || {};
    let { ref: contextRef, ...contextProps } = ctx;
    let mergedRef = (0, $5R8yz$reactariauseObjectRef.useObjectRef)((0, $5R8yz$react.useMemo)(()=>(0, $5R8yz$reactariaprivateutilsmergeRefs.mergeRefs)(ref, contextRef), [
        ref,
        contextRef
    ]));
    let mergedProps = (0, $5R8yz$reactariamergeProps.mergeProps)(contextProps, props);
    // mergeProps does not merge `style`. Adding this there might be a breaking change.
    if ('style' in contextProps && contextProps.style && 'style' in props && props.style) {
        if (typeof contextProps.style === 'function' || typeof props.style === 'function') // @ts-ignore
        mergedProps.style = (renderProps)=>{
            let contextStyle = typeof contextProps.style === 'function' ? contextProps.style(renderProps) : contextProps.style;
            let defaultStyle = {
                ...renderProps.defaultStyle,
                ...contextStyle
            };
            let style = typeof props.style === 'function' ? props.style({
                ...renderProps,
                defaultStyle: defaultStyle
            }) : props.style;
            return {
                ...defaultStyle,
                ...style
            };
        };
        else // @ts-ignore
        mergedProps.style = {
            ...contextProps.style,
            ...props.style
        };
    }
    return [
        mergedProps,
        mergedRef
    ];
}
function $048d76b84370f141$export$9d4c57ee4c6ffdd8(initialState = true) {
    // Initial state is typically based on the parent having an aria-label or aria-labelledby.
    // If it does, this value should be false so that we don't update the state and cause a rerender when we go through the layoutEffect
    let [hasSlot, setHasSlot] = (0, $5R8yz$react.useState)(initialState);
    let hasRun = (0, $5R8yz$react.useRef)(false);
    // A callback ref which will run when the slotted element mounts.
    // This should happen before the useLayoutEffect below.
    let ref = (0, $5R8yz$react.useCallback)((el)=>{
        hasRun.current = true;
        setHasSlot(!!el);
    }, []);
    // If the callback hasn't been called, then reset to false.
    (0, $5R8yz$reactariaprivateutilsuseLayoutEffect.useLayoutEffect)(()=>{
        if (!hasRun.current) setHasSlot(false);
    }, []);
    return [
        ref,
        hasSlot
    ];
}
function $048d76b84370f141$export$ef03459518577ad4(props) {
    const prefix = /^(data-.*)$/;
    let filteredProps = {};
    for(const prop in props)if (!prefix.test(prop)) filteredProps[prop] = props[prop];
    return filteredProps;
}
function $048d76b84370f141$var$DOMElement(ElementType, props, forwardedRef) {
    let { render: render, ...otherProps } = props;
    let elementRef = (0, $5R8yz$react.useRef)(null);
    let ref = (0, $5R8yz$react.useMemo)(()=>(0, $5R8yz$reactariaprivateutilsmergeRefs.mergeRefs)(forwardedRef, elementRef), [
        forwardedRef,
        elementRef
    ]);
    (0, $5R8yz$reactariaprivateutilsuseLayoutEffect.useLayoutEffect)(()=>{
        if (process.env.NODE_ENV !== 'production' && render) {
            if (!elementRef.current) console.warn('Ref was not connected to DOM element returned by custom `render` function. Did you forget to pass through or merge the `ref`?');
            else if (elementRef.current.localName !== ElementType) console.warn(`Unexpected DOM element returned by custom \`render\` function. Expected <${ElementType}>, got <${elementRef.current.localName}>. This may break the component behavior and accessibility.`);
        }
    }, [
        ElementType,
        render
    ]);
    let domProps = {
        ...otherProps,
        ref: ref
    };
    if (render) return render(domProps, undefined);
    return /*#__PURE__*/ (0, ($parcel$interopDefault($5R8yz$react))).createElement(ElementType, domProps);
}
const $048d76b84370f141$var$domComponentCache = {};
const $048d76b84370f141$export$df3a06d6289f983e = new Proxy({}, {
    get (target, elementType) {
        if (typeof elementType !== 'string') return undefined;
        let res = $048d76b84370f141$var$domComponentCache[elementType];
        if (!res) {
            res = /*#__PURE__*/ (0, $5R8yz$react.forwardRef)($048d76b84370f141$var$DOMElement.bind(null, elementType));
            $048d76b84370f141$var$domComponentCache[elementType] = res;
        }
        return res;
    }
});


//# sourceMappingURL=utils.cjs.map
