(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "tslib", "react", "../typography/P1", "../hooks/useStateProps", "./style"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var tslib_1 = require("tslib");
    var react_1 = (0, tslib_1.__importStar)(require("react"));
    var P1_1 = (0, tslib_1.__importDefault)(require("../typography/P1"));
    var useStateProps_1 = require("../hooks/useStateProps");
    var style_1 = require("./style");
    var Cluster = react_1.default.forwardRef(function (_a, ref) {
        var className = _a.className, isDisabled = _a.isDisabled, children = _a.children, onClick = _a.onClick, props = (0, tslib_1.__rest)(_a, ["className", "isDisabled", "children", "onClick"]);
        var _b = (0, tslib_1.__read)((0, useStateProps_1.useStateProps)(props.isPressed), 2), isPressed = _b[0], setIsPressed = _b[1];
        var _c = (0, tslib_1.__read)((0, react_1.useState)("phoenix"), 2), textType = _c[0], setTextType = _c[1];
        var handleClick = function (event) {
            setIsPressed(!isPressed);
            onClick === null || onClick === void 0 ? void 0 : onClick(event);
        };
        (0, react_1.useEffect)(function () {
            if (isDisabled || isPressed) {
                setTextType("cygnus");
            }
            else {
                setTextType("phoenix");
            }
        }, [isPressed, isDisabled]);
        var handleMouseLeave = function () {
            if (!isDisabled && !isPressed) {
                setTextType("phoenix");
            }
        };
        return (react_1.default.createElement(style_1.ClusterStyled, (0, tslib_1.__assign)({ onMouseOver: function () { return setTextType("cygnus"); }, onMouseLeave: handleMouseLeave, className: className, onClick: handleClick, isPressed: isPressed, isDisabled: isDisabled, ref: ref }, props),
            react_1.default.createElement(P1_1.default, { type: textType }, children)));
    });
    Cluster.displayName = "Cluster";
    exports.default = Cluster;
});
