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 { safeUseId } from "../../utils";
import { base as viewCSS } from "./variations/_view/base";
import { base as sizeCSS } from "./variations/_size/base";
import { SpinnerSvg } from "./SpinnerSvg";
import { SpinnerWrapper, base } from "./Spinner.styles";
import { useInnerProps } from "./hooks";
export var spinnerRoot = function spinnerRoot(Root) {
    return /*#__PURE__*/ forwardRef(function(props, ref) {
        var id = props.id, rest = _object_without_properties(props, [
            "id"
        ]);
        var innerProps = useInnerProps(props, {
            wrapperWidth: 'auto',
            wrapperHeight: 'auto',
            svgWidth: 'var(--plasma-spinner-size)',
            svgHeight: 'var(--plasma-spinner-size)',
            color: 'currentColor'
        });
        var uniqId = safeUseId;
        var innerId = id || uniqId();
        return /*#__PURE__*/ React.createElement(Root, _object_spread({
            ref: ref,
            id: innerId
        }, rest), /*#__PURE__*/ React.createElement(SpinnerWrapper, {
            width: innerProps.wrapperWidth,
            height: innerProps.wrapperHeight
        }, /*#__PURE__*/ React.createElement(SpinnerSvg, {
            id: innerId,
            width: innerProps.svgWidth,
            height: innerProps.svgHeight,
            color: innerProps.color
        })));
    });
};
export var spinnerConfig = {
    name: 'Spinner',
    tag: 'div',
    layout: spinnerRoot,
    base: base,
    variations: {
        size: {
            css: sizeCSS
        },
        view: {
            css: viewCSS
        }
    },
    defaults: {
        size: 'm',
        view: 'accent'
    }
};
