function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
import React, { forwardRef } from "react";
import { css } from "styled-components";
import { base as viewCSS } from "./_view/base";
import { base as disabledCSS } from "./_disabled/base";
import { base as focusedCSS } from "./_focused/base";
var base = css([
    "position:relative;text-decoration:none;transition:color 0.15s ease-in;::before{content:'';position:absolute;inset:0;opacity:0.4;}"
]);
export var linkRoot = function linkRoot(Root) {
    return /*#__PURE__*/ forwardRef(function(props, ref) {
        var children = props.children, disabled = props.disabled, target = props.target, href = props.href, rel = props.rel, rest = _object_without_properties(props, [
            "children",
            "disabled",
            "target",
            "href",
            "rel"
        ]);
        var forwardProps = {
            disabled: disabled,
            target: target,
            href: disabled ? undefined : href,
            // NOTE: https://developer.chrome.com/docs/lighthouse/best-practices/external-anchors-use-rel-noopener/
            rel: target === '_blank' ? 'noopener noreferrer' : rel
        };
        return /*#__PURE__*/ React.createElement(Root, _object_spread({
            ref: ref
        }, forwardProps, rest), children);
    });
};
export var linkConfig = {
    name: 'Link',
    tag: 'a',
    layout: linkRoot,
    base: base,
    variations: {
        view: {
            css: viewCSS
        },
        disabled: {
            css: disabledCSS,
            attrs: true
        },
        focused: {
            css: focusedCSS
        }
    },
    defaults: {
        view: 'primary',
        size: 'm'
    }
};
