'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var _tslib = require('./_tslib-9c546438.js');
var jsxRuntime = require('@emotion/react/jsx-runtime');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var TabProvider = function (_a) {
    var children = _a.children, props = _tslib.__rest(_a, ["children"]);
    var _b = React__default['default'].useState(props.activeTabId || ''), activeTabId = _b[0], setActiveTabId = _b[1];
    var handleChange = React__default['default'].useCallback(function (id) {
        setActiveTabId(id);
        if (props.onChange) {
            props.onChange(id);
        }
    }, [props.onChange]);
    var derivedActiveTabId = props.activeTabId !== undefined ? props.activeTabId : activeTabId;
    var contextValue = React__default['default'].useMemo(function () { return ({
        activeTabId: derivedActiveTabId,
        onChange: handleChange,
    }); }, [derivedActiveTabId, handleChange]);
    return (jsxRuntime.jsx(TabContext.Provider, _tslib.__assign({ value: contextValue }, { children: children }), void 0));
};
var TabContext = React__default['default'].createContext(null);

exports.TabContext = TabContext;
exports.TabProvider = TabProvider;
//# sourceMappingURL=TabProvider.js.map
