"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _create = _interopRequireDefault(require("../utils/create"));

var _relation = require("../mixins/relation");

var _router = require("../utils/router");

var _default = (0, _create.default)({
  render: function render() {
    var _vm = this;

    var _h = _vm.$createElement;

    var _c = _vm._self._c || _h;

    return _vm.parents.animated ? _c('div', {
      class: _vm.b('pane-wrapper', {
        inactive: !_vm.isActive
      }),
      attrs: {
        "role": "tabpanel",
        "aria-hidden": !_vm.isActive
      }
    }, [_c('div', {
      class: _vm.b('pane')
    }, [_vm.shouldRender ? _vm._t("default") : _vm._e()], 2)]) : _c('div', {
      directives: [{
        name: "show",
        rawName: "v-show",
        value: _vm.parents.scrollspy || _vm.isActive,
        expression: "parents.scrollspy || isActive"
      }],
      class: _vm.b('pane'),
      attrs: {
        "role": "tabpanel"
      }
    }, [_vm.shouldRender ? _vm._t("default") : _vm._e()], 2);
  },
  name: "tab",
  mixins: [(0, _relation.ChildrenMixin)("vmTabs")],
  props: (0, _extends2.default)({}, _router.routeProps, {
    dot: Boolean,
    name: [Number, String],
    info: [Number, String],
    badge: [Number, String],
    title: String,
    titleStyle: null,
    disabled: Boolean
  }),
  watch: {
    title: function title() {
      this.parents.setLine();
    },
    inited: function inited(val) {
      var _this = this;

      if (this.parents.lazyRender && val) {
        this.$nextTick(function () {
          _this.parents.$emit("rendered", _this.computedName, _this.title);
        });
      }
    }
  },
  data: function data() {
    return {
      inited: false
    };
  },
  computed: {
    shouldRender: function shouldRender() {
      return this.inited || this.parents.scrollspy || !this.parents.lazyRender;
    },
    computedName: function computedName() {
      return this.name || this.index;
    },
    isActive: function isActive() {
      var active = this.computedName === this.parents.currentName;

      if (active) {
        this.inited = true;
      }

      return active;
    }
  }
});

exports.default = _default;