/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var Vue = require('vue');
var tabs_tabPanelProps = require('./tab-panel-props.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var config = require('../config.js');
var hooks_useDestroyOnClose = require('../hooks/useDestroyOnClose.js');
require('@babel/runtime/helpers/typeof');

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

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _TabPanel = Vue__default["default"].extend({
  name: "TTabPanel",
  props: _objectSpread({}, tabs_tabPanelProps["default"]),
  inject: {
    parent: {
      "default": null
    }
  },
  computed: {
    active: function active() {
      var _ref = this.parent || {},
          value = _ref.value;

      return this.value === value;
    }
  },
  updated: function updated() {
    var _this$parent,
        _this$parent$updatePa,
        _this = this;

    (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : (_this$parent$updatePa = _this$parent.updatePanels) === null || _this$parent$updatePa === void 0 ? void 0 : _this$parent$updatePa.call(_this$parent, {
      force: true
    });

    if (!this.destroyOnHide) {
      var timer = setTimeout(function () {
        hooks_useDestroyOnClose.updateElement(_this);
        clearTimeout(timer);
      }, 0);
    }
  },
  render: function render() {
    var h = arguments[0];
    var destroyOnHide = this.destroyOnHide,
        active = this.active;
    if (destroyOnHide && !active) return null;
    return h("div", {
      "class": "".concat(config.prefix, "-tab-panel"),
      "directives": [{
        name: "show",
        value: active
      }]
    }, [utils_renderTnode.renderContent(this, "default", "panel")]);
  }
});

exports["default"] = _TabPanel;
//# sourceMappingURL=tab-panel.js.map
