"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Notification;
const web_1 = require("@react-spring/web");
const react_1 = __importStar(require("react"));
const Icon_1 = __importStar(require("./Icon/Icon"));
const Color_1 = require("../../util/Color");
function Notification(props) {
    const { icon, children } = props.data;
    const [goAway, setGoAway] = (0, react_1.useState)(false);
    const right = (0, web_1.useSpring)({
        delay: 1200,
        config: { mass: 50, tension: 170, friction: 200 },
        to: {
            right: '0',
        },
        from: {
            right: '100%',
        },
        onRest: () => setGoAway(true),
    });
    const outAnim = (0, web_1.useSpring)({
        from: {
            opacity: 1,
        },
        to: {
            opacity: goAway ? 0 : 1,
        },
        onRest: () => { var _a; return props.data.id && ((_a = props.onRemove) === null || _a === void 0 ? void 0 : _a.call(props, props.data.id)); },
    });
    const iconOnClickHandler = () => {
        setGoAway(true);
    };
    return (react_1.default.createElement(web_1.animated.div, { className: "c-notification a-bounce-down-left", style: outAnim },
        react_1.default.createElement("div", { className: "c-notification__inner" },
            react_1.default.createElement(web_1.animated.div, { className: "c-notification__timer", style: { right: right.right } }),
            react_1.default.createElement("div", { className: "u-flex" },
                react_1.default.createElement("div", { className: "u-flex__item" },
                    react_1.default.createElement(Icon_1.default, { icon: icon, color: Color_1.Color.Accent }),
                    react_1.default.createElement("div", { className: "u-inline u-marg-left" }, children)),
                react_1.default.createElement(Icon_1.default, { icon: Icon_1.IconType.Close, size: "24px", onClick: iconOnClickHandler })))));
}
//# sourceMappingURL=Notification.js.map