"use strict";

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

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

require("./Message.css");

var _component = require("../_utils/component");

var _Portal = _interopRequireDefault(require("../Portal"));

var _Icon = _interopRequireDefault(require("../Icon"));

var _popupManager = _interopRequireDefault(require("../_utils/popup-manager"));

var _vueNormalizeComponent = _interopRequireDefault(require("../_utils/vue-normalize-component.js"));

/* script */
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var __vue_script__ = {
  name: (0, _component.createComponentName)('message'),
  components: {
    Portal: _Portal.default,
    Icon: _Icon.default
  },
  mixins: [_component.componentMixin],
  props: {
    top: {
      type: String,
      default: '25vh'
    },
    delay: {
      type: Number,
      default: 2000
    },
    showClose: {
      type: Boolean,
      default: true
    },
    onClose: {
      type: [Function, undefined]
    }
  },

  data() {
    return {
      visible: false,
      zIndex: 0
    };
  },

  watch: {
    visible(value, old) {
      if (value && value !== old) {
        this.zIndex = _popupManager.default.getZindex();
      }
    }

  },

  mounted() {
    this.autoClose();
  },

  methods: {
    autoClose() {
      var _this = this;

      if (this.delay) {
        this.timer = setTimeout(function () {
          _this.visible = false;
        }, this.delay);
      }
    },

    clearAutoClose() {
      clearTimeout(this.timer);
    }

  }
};
/* template */

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

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

  return _c("Portal", [_vm.visible ? _c("transition", {
    attrs: {
      name: "gd-message-fade"
    },
    on: {
      "after-leave": _vm.onClose
    }
  }, [_c("div", {
    class: _vm.bem(),
    style: {
      zIndex: _vm.zIndex,
      top: _vm.top
    },
    on: {
      mouseover: _vm.clearAutoClose,
      mouseout: _vm.autoClose
    }
  }, [_c("div", {
    class: _vm.bem("content")
  }, [_vm._t("default", [_vm._v(_vm._s(_vm.message))])], 2), _vm._v(" "), _vm.showClose ? _c("icon", {
    class: _vm.bem("close"),
    attrs: {
      name: "close",
      color: "#AAA"
    },
    nativeOn: {
      click: function click($event) {
        _vm.visible = false;
      }
    }
  }) : _vm._e()], 1)]) : _vm._e()], 1);
};

var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = undefined;
/* module identifier */

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = false;
/* component normalizer */

/* style inject */

/* style inject SSR */
var _default = (0, _vueNormalizeComponent.default)({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);

exports.default = _default;