"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/libs/classNames")),_utils=require("./utils");function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ownKeys(e,t){var o,n=Object.keys(e);return Object.getOwnPropertySymbols&&(o=Object.getOwnPropertySymbols(e),t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)),n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(o),!0).forEach(function(t){_defineProperty(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"==_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0===o)return("string"===e?String:Number)(t);o=o.call(t,e||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}var _toptips=null;(0,_baseComponent.default)({useFunc:!0,data:_utils.defaults,computed:{classes:["prefixCls, icon",function(t,e){e=e||"cancel";return{wrap:(0,_classNames2.default)(t),content:(0,_classNames2.default)("".concat(t,"__content"),_defineProperty({},"".concat(t,"__content--").concat(e),e)),icon:"".concat(t,"__icon"),text:"".concat(t,"__text")}}]},methods:{hide:function(){if(this.removed)return!1;this.removed=!0,_toptips&&(clearTimeout(_toptips.timeout),_toptips=null),this.$$setData({in:!1}),"function"==typeof this.fns.success&&this.fns.success()},show:function(){function t(){_toptips&&_toptips.hide.call(o)}var o=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},r=new Promise(function(t){var e=o.$$mergeOptionsAndBindMethods(Object.assign({},_utils.defaults,n));o.removed=!1,o.$$setData(_objectSpread({in:!0},e)),_toptips&&(clearTimeout(_toptips.timeout),_toptips=null),(_toptips={hide:o.hide}).timeout=setTimeout(function(){return o.hide(),t(!0)},e.duration)});return t.then=function(t,e){return r.then(t,e)},t.promise=r,t},success:function(){return this.show(Object.assign(_objectSpread(_objectSpread({},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}),{},{icon:"success"})))},info:function(){return this.show(Object.assign(_objectSpread(_objectSpread({},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}),{},{icon:"info"})))},warn:function(){return this.show(Object.assign(_objectSpread(_objectSpread({},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}),{},{icon:"warn"})))},error:function(){return this.show(Object.assign(_objectSpread(_objectSpread({},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}),{},{icon:"cancel"})))}}});