// Utils
import mixins from "../../../lib/utils/mixins"; // Mixins

import findParent from "../../../lib/mixins/find-parent";
export default mixins(findParent).extend({
  name: 'w-tab',
  props: {
    title: String,
    disabled: Boolean
  },
  data: function data() {
    return {
      inited: false
    };
  },
  computed: {
    index: function index() {
      return this.parent.tabs.indexOf(this) >= 0 ? this.parent.tabs.indexOf(this) : 0;
    },
    selected: function selected() {
      return this.index === this.parent.currentActive;
    }
  },
  created: function created() {
    this.findParent('w-tabs');
  },
  mounted: function mounted() {
    var tabs = this.parent.tabs;
    var index = this.parent.$slots.default.indexOf(this.$vnode);
    tabs.splice(index === -1 ? tabs.length : index, 0, this);

    if (this.$slots.title) {
      this.parent.renderTitle(this.$refs.title, this.index);
    }
  },
  beforeDestroy: function beforeDestroy() {
    this.parent.tabs.splice(this.index, 1);
  },
  watch: {
    'parent.currentActive': function parentCurrentActive() {
      this.inited = this.inited || this.selected;
    },
    title: function title() {
      this.parent.setLine();
    }
  },
  render: function render() {
    var h = arguments[0];
    return h("div", {
      "class": "wv-tab__pane",
      "directives": [{
        name: "show",
        value: this.selected || this.parent.animated
      }]
    }, [this.inited && this.$slots.default, this.$slots.title && h("div", {
      "ref": "title"
    }, [this.$slots.title])]);
  }
});
//# sourceMappingURL=WTab.js.map