/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var vue = require('vue');
var utils_helper = require('../utils/helper.js');
var hooks_useConfig = require('../hooks/useConfig.js');
var tabs_props = require('./props.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/camelCase');
require('lodash/isUndefined');
require('lodash/isNull');
require('lodash/isArray');
require('lodash/isNumber');
require('lodash/isString');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/isFunction');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-7f0559c3.js');
require('dayjs');

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

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);

var TTabNavBar = vue.defineComponent({
  props: {
    navs: {
      type: Array
    },
    placement: tabs_props["default"].placement,
    value: tabs_props["default"].value
  },
  setup: function setup(props) {
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("tabs");
    var classPrefix = hooks_useConfig.usePrefixClass();
    var navBarClass = vue.computed(function () {
      return ["".concat(COMPONENT_NAME.value, "__bar"), "".concat(classPrefix.value, "-is-").concat(props.placement)];
    });
    var navBarStyle = vue.ref(null);
    var getStyle = function getStyle() {
      var _props$navs$i$el2, _ref3;
      var isVertical = ["left", "right"].includes(props.placement.toLowerCase());
      var _ref = isVertical ? ["height", "top"] : ["width", "left"],
        _ref2 = _slicedToArray__default["default"](_ref, 2),
        sizePropName = _ref2[0],
        offsetPropName = _ref2[1];
      var offset = 0;
      var i = 0;
      for (; i < props.navs.length; i++) {
        var _props$navs$i, _props$navs$i$el;
        if (props.navs[i].props.value === props.value) break;
        offset += ((_props$navs$i = props.navs[i]) === null || _props$navs$i === void 0 ? void 0 : (_props$navs$i$el = _props$navs$i.el) === null || _props$navs$i$el === void 0 ? void 0 : _props$navs$i$el["client".concat(utils_helper.firstUpperCase(sizePropName))]) || 0;
      }
      if (!props.navs[i]) return {};
      return _ref3 = {}, _defineProperty__default["default"](_ref3, offsetPropName, "".concat(offset, "px")), _defineProperty__default["default"](_ref3, sizePropName, "".concat(((_props$navs$i$el2 = props.navs[i].el) === null || _props$navs$i$el2 === void 0 ? void 0 : _props$navs$i$el2["client".concat(utils_helper.firstUpperCase(sizePropName))]) || 0, "px")), _ref3;
    };
    vue.onMounted(function () {
      vue.nextTick(function () {
        navBarStyle.value = getStyle();
      });
    });
    vue.watch([function () {
      return props.navs;
    }, function () {
      return props.value;
    }, function () {
      return props.placement;
    }], function () {
      vue.nextTick(function () {
        navBarStyle.value = getStyle();
      });
    });
    return function () {
      return vue.createVNode("div", {
        "class": navBarClass.value,
        "style": navBarStyle.value
      }, null);
    };
  }
});

exports["default"] = TTabNavBar;
//# sourceMappingURL=tab-nav-bar.js.map
