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 { base as viewCSS } from "./variations/_view/base";
import { base as sizeCSS } from "./variations/_size/base";
import { base, StyledSVG, StyledBackgroundCircle, StyledProgressCircle, StyledContent } from "./ProgressBarCircular.styles";
import { classes } from "./ProgressBarCircular.tokens";
export var progressBarCircularRoot = function progressBarCircularRoot(Root) {
    return /*#__PURE__*/ forwardRef(function(props, ref) {
        var _props_value = props.value, value = _props_value === void 0 ? 0 : _props_value, _props_maxValue = props.maxValue, maxValue = _props_maxValue === void 0 ? 100 : _props_maxValue, size = props.size, view = props.view, children = props.children, className = props.className, strokeSize = props.strokeSize, _props_hasTrack = props.hasTrack, hasTrack = _props_hasTrack === void 0 ? true : _props_hasTrack, rest = _object_without_properties(props, [
            "value",
            "maxValue",
            "size",
            "view",
            "children",
            "className",
            "strokeSize",
            "hasTrack"
        ]);
        var clampedValue = Math.min(Math.max(value, 0), maxValue);
        var percentage = clampedValue / maxValue * 100;
        var center = 50;
        return /*#__PURE__*/ React.createElement(Root, _object_spread({
            ref: ref,
            view: view,
            size: size,
            className: className
        }, rest), /*#__PURE__*/ React.createElement(StyledSVG, {
            width: "100%",
            height: "100%",
            viewBox: "0 0 100 100",
            className: classes.svg
        }, hasTrack && /*#__PURE__*/ React.createElement(StyledBackgroundCircle, {
            customStrokeWidth: strokeSize,
            cx: center,
            cy: center,
            className: classes.backgroundCircle
        }), /*#__PURE__*/ React.createElement(StyledProgressCircle, {
            cx: center,
            cy: center,
            customStrokeWidth: strokeSize,
            className: classes.progressCircle,
            percent: percentage,
            transform: "rotate(-90 50 50)"
        })), children && /*#__PURE__*/ React.createElement(StyledContent, {
            className: classes.content
        }, children));
    });
};
export var progressBarCircularConfig = {
    name: 'ProgressBarCircular',
    tag: 'div',
    layout: progressBarCircularRoot,
    base: base,
    variations: {
        view: {
            css: viewCSS
        },
        size: {
            css: sizeCSS
        }
    },
    defaults: {
        view: 'primary',
        size: 'm'
    }
};
