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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import Vue from 'vue';
import isFunction from 'lodash/isFunction';
import { InfoCircleFilledIcon, CheckCircleFilledIcon, CloseIcon } from 'tdesign-icons-vue';
import { prefix } from '../config.js';
import { renderTNodeJSX, renderContent } from '../utils/render-tnode.js';
import props from './props.js';
import '@babel/runtime/helpers/typeof';

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(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(prefix, "-notification");
var _Notification = Vue.extend({
  name: "TNotification",
  components: {
    InfoCircleFilledIcon: InfoCircleFilledIcon,
    CheckCircleFilledIcon: CheckCircleFilledIcon,
    CloseIcon: CloseIcon
  },
  props: _objectSpread({}, props),
  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(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(prefix, "-is-").concat(this.theme)
        }) : h("info-circle-filled-icon", {
          "class": "".concat(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(prefix, "-message__close"),
        "on": {
          "click": this.close
        }
      }, [renderTNodeJSX(this, "closeBtn", defaultClose)]);
    },
    renderContent: function renderContent$1() {
      var h = this.$createElement;
      return h("div", {
        "class": "".concat(name, "__content")
      }, [renderContent(this, "default", "content")]);
    }
  },
  render: function render(h) {
    var icon = this.renderIcon(h);
    var close = this.renderClose();
    var content = this.renderContent();
    var footer = renderTNodeJSX(this, "footer");
    var title = 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])]);
  }
});

export { _Notification as default };
//# sourceMappingURL=notification.js.map
