'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import { ButtonOrLink, } from "./ButtonOrLink.js";
/**
 * Renders a `ButtonOrLink` if one of `href` or `onClick` is passed along with no `as`. Otherwise,
 * renders the element type passed in `as` (defaulting to `span`).
 */
export function MaybeButtonOrLink(props) {
    if ((props.href !== undefined || props.onClick !== undefined) && props.as === undefined) {
        return _jsx(ButtonOrLink, { ...props });
    }
    else {
        const { as: Element = 'span', render, disabled: _disabled, inline: _inline, linkComponent: _linkComponent, type: _type, checked: _checked, href: _href, target: _target, ...otherElementProps } = props;
        const renderState = {
            category: 'other',
            role: props.role ?? 'none',
            disabled: false,
            // The types lie to ensure there's a type error if consumers forget to spread `elementProps` on `Element`
            Element: Element,
            elementProps: {},
        };
        return render ? render(otherElementProps, renderState) : _jsx(Element, { ...otherElementProps });
    }
}
//# sourceMappingURL=MaybeButtonOrLink.js.map