"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 (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnimationInOut = void 0;
var react_1 = __importStar(require("react"));
var resize_observer_1 = __importDefault(require("@react-hook/resize-observer"));
var AnimationInOut_style_1 = __importDefault(require("./AnimationInOut.style"));
function AnimationInOut(_a) {
    var _b = _a.visible, visible = _b === void 0 ? true : _b, children = _a.children, _c = _a.keepFirstAnimation, keepFirstAnimation = _c === void 0 ? false : _c, _d = _a.durationIn, durationIn = _d === void 0 ? 300 : _d, _e = _a.durationOut, durationOut = _e === void 0 ? 300 : _e, _f = _a.animationOut, animationOut = _f === void 0 ? 'fade' : _f, _g = _a.animationIn, animationIn = _g === void 0 ? 'fade' : _g;
    var ref = (0, react_1.useRef)();
    var _h = (0, react_1.useState)(0), height = _h[0], setHeight = _h[1];
    var _j = (0, react_1.useState)(!keepFirstAnimation), enableFirstAnimation = _j[0], setEnableFirstAnimation = _j[1];
    (0, resize_observer_1.default)(ref, function (entry) { return setHeight(entry.contentRect.height); });
    (0, react_1.useLayoutEffect)(function () {
        var _a;
        setHeight((_a = ref.current) === null || _a === void 0 ? void 0 : _a.clientHeight);
    }, []);
    (0, react_1.useLayoutEffect)(function () {
        if (!visible) {
            setEnableFirstAnimation(true);
        }
    }, [visible]);
    return (react_1.default.createElement(AnimationInOut_style_1.default, { className: "animation-in-out", visible: visible, durationIn: enableFirstAnimation ? (Array.isArray(durationIn) ? durationIn : [durationIn]) : [0], durationOut: enableFirstAnimation ? (Array.isArray(durationOut) ? durationOut : [durationOut]) : [0], animationOut: Array.isArray(animationOut) ? animationOut : [animationOut], animationIn: Array.isArray(animationIn) ? animationIn : [animationIn], style: { height: height } },
        react_1.default.createElement("div", { ref: ref }, children)));
}
exports.AnimationInOut = AnimationInOut;
//# sourceMappingURL=AnimationInOut.js.map