"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "NavBar", {
    enumerable: true,
    get: function() {
        return NavBar;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _define_property = require("@swc/helpers/_/_define_property");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _react = /*#__PURE__*/ _interop_require_default._(require("react"));
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _components = require("@tarojs/components");
var _index = require("../configprovider/index");
var _typings = require("../../utils/typings");
var _index1 = /*#__PURE__*/ _interop_require_default._(require("../safearea/index"));
var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
    left: '',
    right: '',
    back: '',
    fixed: false,
    safeAreaInsetTop: false,
    placeholder: false,
    zIndex: 10
});
var NavBar = function NavBar(props) {
    var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), right = _$_object_spread.right, left = _$_object_spread.left, title = _$_object_spread.title, className = _$_object_spread.className, style = _$_object_spread.style, back = _$_object_spread.back, fixed = _$_object_spread.fixed, safeAreaInsetTop = _$_object_spread.safeAreaInsetTop, placeholder = _$_object_spread.placeholder, zIndex = _$_object_spread.zIndex, onBackClick = _$_object_spread.onBackClick;
    var classPrefix = 'nut-navbar';
    var rtl = (0, _index.useRtl)();
    var children = Array.isArray(props.children) ? props.children : [
        props.children
    ];
    var styles = function styles() {
        return (0, _object_spread_props._)((0, _object_spread._)({}, style), {
            zIndex: zIndex
        });
    };
    var renderLeft = function renderLeft() {
        var _obj, _obj1;
        return /*#__PURE__*/ _react.default.createElement(_components.View, {
            className: (0, _classnames.default)((_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-left"), true), (0, _define_property._)(_obj, "".concat(classPrefix, "-left-maxwidth"), title), (0, _define_property._)(_obj, "".concat(classPrefix, "-left-hidden"), !left && !back), (0, _define_property._)(_obj, "".concat(classPrefix, "-left-rtl"), rtl), _obj))
        }, back ? /*#__PURE__*/ _react.default.createElement(_components.View, {
            className: (0, _classnames.default)((_obj1 = {}, (0, _define_property._)(_obj1, "".concat(classPrefix, "-left-back"), true), (0, _define_property._)(_obj1, "".concat(classPrefix, "-left-back-children"), left), (0, _define_property._)(_obj1, "".concat(classPrefix, "-left-back-children-rtl"), left && rtl), _obj1)),
            onClick: function onClick(e) {
                return onBackClick(e);
            }
        }, back) : null, left);
    };
    var renderContent = function renderContent() {
        var _obj;
        return /*#__PURE__*/ _react.default.createElement(_components.View, {
            className: (0, _classnames.default)((_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-title"), true), (0, _define_property._)(_obj, "".concat(classPrefix, "-title-center"), title), _obj))
        }, title || children);
    };
    var renderRight = function renderRight() {
        var _obj;
        return /*#__PURE__*/ _react.default.createElement(_components.View, {
            className: (0, _classnames.default)((_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-right"), true), (0, _define_property._)(_obj, "".concat(classPrefix, "-right-maxwidth"), title), (0, _define_property._)(_obj, "".concat(classPrefix, "-right-rtl"), rtl), _obj))
        }, right);
    };
    var renderWrapper = function renderWrapper() {
        return /*#__PURE__*/ _react.default.createElement(_components.View, {
            className: cls,
            style: styles()
        }, renderLeft(), renderContent(), renderRight());
    };
    var _obj;
    var classes = (0, _classnames.default)((_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-fixed"), fixed), (0, _define_property._)(_obj, "".concat(classPrefix, "-safe-area-inset-top"), safeAreaInsetTop), (0, _define_property._)(_obj, "".concat(classPrefix, "-rtl"), rtl), _obj));
    var cls = (0, _classnames.default)(classPrefix, classes, className, (0, _define_property._)({}, "".concat(classPrefix, "-title-wrapper"), title));
    return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, safeAreaInsetTop && /*#__PURE__*/ _react.default.createElement(_index1.default, {
        position: "top"
    }), fixed && placeholder ? /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-placeholder")
    }, renderWrapper()) : renderWrapper());
};
NavBar.displayName = 'NutNavBar';
