var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(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);
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
import React from 'react';
import { ThemeContext } from '../../lib/theming/ThemeContext.js';
import { SpinnerIcon } from '../../internal/SpinnerIcon/SpinnerIcon.js';
import { CommonWrapper } from '../../internal/CommonWrapper/index.js';
import { rootNode } from '../../lib/rootNode/index.js';
import { createPropsGetter } from '../../lib/createPropsGetter.js';
import { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';
import { getStyles } from './Spinner.styles.js';
var types = ['big', 'mini', 'normal'];
export var SpinnerDataTids = {
    root: 'Spinner__root',
};
/**
 * `Spinner` — это зацикленный индикатор, не отображающий прогресс выполнения задачи.
 */
var Spinner = /** @class */ (function (_super) {
    __extends(Spinner, _super);
    function Spinner() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.getProps = createPropsGetter(Spinner_1.defaultProps);
        _this.renderSpinner = function (type, dimmed, inline) {
            var _a;
            return (React.createElement(SpinnerIcon, { size: type, className: _this.cx((_a = {},
                    _a[_this.styles.circle(_this.theme)] = !dimmed && !_this.props.color,
                    _a[_this.styles.circleDimmedColor(_this.theme)] = dimmed,
                    _a[_this.styles.circleWithoutColorAnimation()] = dimmed || !!_this.props.color,
                    _a)), width: _this.props.width, color: _this.props.color, inline: inline }));
        };
        _this.renderCaption = function (type, caption) { return (React.createElement("span", { className: _this.cx(_this.styles[type](_this.theme), _this.styles.captionColor(_this.theme)) }, caption)); };
        return _this;
    }
    Spinner_1 = Spinner;
    Spinner.prototype.render = function () {
        var _this = this;
        this.styles = getStyles(this.emotion);
        return (React.createElement(ThemeContext.Consumer, null, function (theme) {
            _this.theme = theme;
            return _this.renderMain();
        }));
    };
    Spinner.prototype.renderMain = function () {
        var _a = this.props, _b = _a.caption, caption = _b === void 0 ? null : _b, dimmed = _a.dimmed, inline = _a.inline;
        var type = this.getProps().type;
        return (React.createElement(CommonWrapper, __assign({ rootNodeRef: this.setRootNode }, this.props),
            React.createElement("div", { "data-tid": SpinnerDataTids.root, className: this.styles.spinner() },
                React.createElement("span", { className: this.styles.inner() }, this.renderSpinner(type, dimmed, inline)),
                caption && this.renderCaption(type, caption))));
    };
    var Spinner_1;
    Spinner.__KONTUR_REACT_UI__ = 'Spinner';
    Spinner.displayName = 'Spinner';
    Spinner.defaultProps = {
        type: 'normal',
    };
    Spinner.Types = Object.assign.apply(Object, __spreadArray([{}], types.map(function (type) {
        var _a;
        return (_a = {}, _a[type] = type, _a);
    }), false));
    Spinner = Spinner_1 = __decorate([
        withRenderEnvironment,
        rootNode
    ], Spinner);
    return Spinner;
}(React.Component));
export { Spinner };
//# sourceMappingURL=Spinner.js.map