"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var styled_components_1 = __importDefault(require("@xstyled/styled-components"));
var Tab_1 = __importDefault(require("./Tab"));
var Frame_1 = __importDefault(require("../Frame"));
var Navbar = styled_components_1.default(Frame_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  display: flex;\n  padding: 0;\n  margin: 0;\n  border: none;\n  box-shadow: none;\n  background-color: unset;\n"], ["\n  display: flex;\n  padding: 0;\n  margin: 0;\n  border: none;\n  box-shadow: none;\n  background-color: unset;\n"])));
var NavContainer = styled_components_1.default(Frame_1.default)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n  padding: 12;\n  box-shadow: out;\n"], ["\n  padding: 12;\n  box-shadow: out;\n"])));
NavContainer.displayName = 'NavContainer';
var If = function (_a) {
    var condition = _a.condition, children = _a.children;
    return condition && children;
};
var Tabs = function (_a) {
    var children = _a.children, style = _a.style, defaultActiveTab = _a.defaultActiveTab, onChange = _a.onChange, rest = __rest(_a, ["children", "style", "defaultActiveTab", "onChange"]);
    var firstTab = React.Children.toArray(children)[0];
    var _b = React.useState(defaultActiveTab || firstTab.props.title), activeTab = _b[0], setActiveTab = _b[1];
    return (React.createElement(React.Fragment, null,
        React.createElement(Navbar, __assign({ style: style }, rest, { as: "ol" }), React.Children.map(children, function (child) {
            var _a = child.props, title = _a.title, disabled = _a.disabled;
            return (React.createElement(Tab_1.default, __assign({ key: title }, child.props, { activeTab: activeTab, onClick: function (e) {
                    if (!disabled) {
                        if (onChange) {
                            onChange(title, e);
                        }
                        setActiveTab(title);
                    }
                } })));
        })),
        React.createElement(NavContainer, { style: style }, React.Children.map(children, function (child) { return (React.createElement(If, { condition: child.props.title === activeTab }, child.props.children)); }))));
};
exports.default = Tabs;
var templateObject_1, templateObject_2;
//# sourceMappingURL=Tabs.js.map