import clsx from 'clsx';
import React, { forwardRef } from 'react';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

var __assign = function() {
    __assign = Object.assign || function __assign(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};

function __rest(s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
}

var Button = forwardRef(function (_a, ref) {
    var _b;
    var _c = _a.size, size = _c === void 0 ? "lg" : _c, _d = _a.kind, kind = _d === void 0 ? "display" : _d, _e = _a.color, color = _e === void 0 ? "blue" : _e, _f = _a.variation, variation = _f === void 0 ? "fill" : _f, _g = _a.anchor, anchor = _g === void 0 ? false : _g, props = __rest(_a, ["size", "kind", "color", "variation", "anchor"]);
    var as = (anchor ? "a" : "button");
    if (anchor) {
        props.tabIndex = props.tabIndex ? props.tabIndex : 0;
    }
    else {
        props.tabIndex = props.tabIndex ? props.tabIndex : undefined;
    }
    props.className = clsx((_b = {},
        _b[props.className || ""] = !!props.className,
        _b["ds-button"] = true,
        _b["ds-button-" + size] = true,
        _b["ds-button-" + kind] = true,
        _b["ds-button-" + color] = true,
        _b["ds-button-" + variation] = true,
        _b));
    return React.createElement(as, __assign({ ref: ref }, props));
});

var Heading = function (_a) {
    var _b;
    var _c = _a.level, level = _c === void 0 ? 3 : _c, _d = _a.poster, poster = _d === void 0 ? false : _d, as = _a.as, theme = _a.theme, props = __rest(_a, ["level", "poster", "as", "theme"]);
    var As = (as ? as : poster ? "h1" : "h" + level);
    props.className = clsx((_b = {},
        _b[props.className || ""] = !!props.className,
        _b["ds-heading"] = true,
        _b["ds-heading-" + level] = !poster,
        _b["ds-poster-" + level] = poster,
        _b["ds-theme--" + theme] = !!theme,
        _b));
    return React.createElement(As, __assign({}, props));
};

var Paragraph = function (_a) {
    var _b;
    var _c = _a.level, level = _c === void 0 ? 3 : _c, _d = _a.leading, leading = _d === void 0 ? "body" : _d, props = __rest(_a, ["level", "leading"]);
    return (React.createElement("p", __assign({}, props, { className: clsx((_b = {},
            _b[props.className || ""] = !!props.className,
            _b["ds-paragraph"] = true,
            _b["ds-paragraph-" + level] = true,
            _b["ds-paragraph--" + leading] = true,
            _b)) })));
};

var ThemeProvider = function (_a) {
    var _b;
    var _c = _a.type, type = _c === void 0 ? "base" : _c, _d = _a.as, as = _d === void 0 ? "div" : _d, props = __rest(_a, ["type", "as"]);
    props.className = clsx((_b = {},
        _b[props.className] = !!props.className,
        _b["ds-theme"] = true,
        _b["ds-theme--" + type] = true,
        _b));
    return React.createElement(as, __assign({}, props));
};

export { Button, Heading, Paragraph, ThemeProvider };
