/**
 * 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 isFunction = require('lodash/isFunction');
var tdesignIconsVue = require('tdesign-icons-vue');
var config = require('../config.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var notification_props = require('./props.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);
var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);

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 name = "".concat(config.prefix, "-notification");
var _Notification = Vue__default["default"].extend({
  name: "TNotification",
  components: {
    InfoCircleFilledIcon: tdesignIconsVue.InfoCircleFilledIcon,
    CheckCircleFilledIcon: tdesignIconsVue.CheckCircleFilledIcon,
    CloseIcon: tdesignIconsVue.CloseIcon
  },
  props: _objectSpread({}, notification_props["default"]),
  mounted: function mounted() {
    var _this = this;

    if (this.duration > 0) {
      var timer = setTimeout(function () {
        clearTimeout(timer);

        _this.$emit("duration-end");

        if (_this.onDurationEnd) {
          _this.onDurationEnd();
        }
      }, this.duration);
    }
  },
  methods: {
    close: function close(e) {
      this.$emit("close-btn-click", {
        e: e
      });

      if (this.onCloseBtnClick) {
        this.onCloseBtnClick({
          e: e
        });
      }
    },
    renderIcon: function renderIcon(h) {
      var icon;
      if (this.icon === false) return null;

      if (isFunction__default["default"](this.icon)) {
        icon = this.icon(h);
      } else if (this.$scopedSlots.icon) {
        icon = this.$scopedSlots.icon(null);
      } else if (this.theme) {
        var iconType = this.theme === "success" ? h("check-circle-filled-icon", {
          "class": "".concat(config.prefix, "-is-").concat(this.theme)
        }) : h("info-circle-filled-icon", {
          "class": "".concat(config.prefix, "-is-").concat(this.theme)
        });
        icon = h("div", {
          "class": "".concat(name, "__icon")
        }, [iconType]);
      }

      return icon;
    },
    renderClose: function renderClose() {
      var h = this.$createElement;
      var defaultClose = h("close-icon");
      return h("span", {
        "class": "".concat(config.prefix, "-message__close"),
        "on": {
          "click": this.close
        }
      }, [utils_renderTnode.renderTNodeJSX(this, "closeBtn", defaultClose)]);
    },
    renderContent: function renderContent() {
      var h = this.$createElement;
      return h("div", {
        "class": "".concat(name, "__content")
      }, [utils_renderTnode.renderContent(this, "default", "content")]);
    }
  },
  render: function render(h) {
    var icon = this.renderIcon(h);
    var close = this.renderClose();
    var content = this.renderContent();
    var footer = utils_renderTnode.renderTNodeJSX(this, "footer");
    var title = utils_renderTnode.renderTNodeJSX(this, "title");
    return h("div", {
      "class": "".concat(name)
    }, [icon, h("div", {
      "class": "".concat(name, "__main")
    }, [h("div", {
      "class": "".concat(name, "__title__wrap")
    }, [h("span", {
      "class": "".concat(name, "__title")
    }, [title]), close]), content, footer])]);
  }
});

exports["default"] = _Notification;
//# sourceMappingURL=notification.js.map
