import*as React from"react";import Notification from"rc-notification";import Icon from"../icon";var defaultDuration=3,defaultTop=void 0,messageInstance=void 0,key=1,prefixCls="dt-message",getContainer=void 0;function getMessageInstance(e){messageInstance?e(messageInstance):Notification.newInstance({prefixCls:prefixCls,transitionName:"move-up",style:{top:defaultTop},getContainer:getContainer},function(n){messageInstance?e(messageInstance):(messageInstance=n,e(n))})}function notice(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:defaultDuration,t=arguments[2],o=arguments[3],i={info:"info-circle",success:"check-circle",error:"close-circle",warning:"exclamation-circle",loading:"loading"}[t];"function"==typeof n&&(o=n,n=defaultDuration);var a=key++;return getMessageInstance(function(c){c.notice({key:a,duration:n,style:{},content:React.createElement("div",{className:prefixCls+"-custom-content "+prefixCls+"-"+t},React.createElement(Icon,{type:i}),React.createElement("span",null,e)),onClose:o})}),function(){messageInstance&&messageInstance.removeNotice(a)}}export default{info:function(e,n,t){return notice(e,n,"info",t)},success:function(e,n,t){return notice(e,n,"success",t)},error:function(e,n,t){return notice(e,n,"error",t)},warn:function(e,n,t){return notice(e,n,"warning",t)},warning:function(e,n,t){return notice(e,n,"warning",t)},loading:function(e,n,t){return notice(e,n,"loading",t)},config:function(e){void 0!==e.top&&(defaultTop=e.top,messageInstance=null),void 0!==e.duration&&(defaultDuration=e.duration),void 0!==e.prefixCls&&(prefixCls=e.prefixCls),void 0!==e.getContainer&&(getContainer=e.getContainer)},destroy:function(){messageInstance&&(messageInstance.destroy(),messageInstance=null)}};