(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"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.useTabContext = exports.TabProvider = void 0;
    var tslib_1 = require("tslib");
    var react_1 = (0, tslib_1.__importStar)(require("react"));
    var TabContext = (0, react_1.createContext)(null);
    TabContext.displayName = "TabContext";
    var TabProvider = function (_a) {
        var children = _a.children, value = _a.value, isLazy = _a.isLazy;
        var _b = (0, tslib_1.__read)((0, react_1.useState)(value), 2), selectedValue = _b[0], setSelectedValue = _b[1];
        var handleChange = function (currentValue) {
            setSelectedValue(currentValue);
        };
        var context = (0, react_1.useMemo)(function () { return ({
            value: selectedValue,
            onChange: handleChange,
            isLazy: isLazy
        }); }, [selectedValue]);
        (0, react_1.useEffect)(function () {
            setSelectedValue(value);
        }, []);
        return react_1.default.createElement(TabContext.Provider, { value: context }, children);
    };
    exports.TabProvider = TabProvider;
    var useTabContext = function () {
        return (0, react_1.useContext)(TabContext);
    };
    exports.useTabContext = useTabContext;
});
