"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_react=require("react"),React=_interopRequireWildcard(_react),_reactDom=require("react-dom"),ReactDOM=_interopRequireWildcard(_reactDom),_rcAnimate=require("rc-animate"),_rcAnimate2=_interopRequireDefault(_rcAnimate),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_omit=require("omit.js"),_omit2=_interopRequireDefault(_omit),_icon=require("../icon"),_icon2=_interopRequireDefault(_icon),_CheckableTag=require("./CheckableTag"),_CheckableTag2=_interopRequireDefault(_CheckableTag);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var __rest=function(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(a=Object.getOwnPropertySymbols(e);l<a.length;l++)t.indexOf(a[l])<0&&(r[a[l]]=e[a[l]])}return r},Tag=function(e){function t(e){(0,_classCallCheck3.default)(this,t);var a=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return a.close=function(e){var t=a.props.onClose;if(t&&t(e),!e.defaultPrevented){var r=ReactDOM.findDOMNode(a);r.style.width=r.getBoundingClientRect().width+"px",r.style.width=r.getBoundingClientRect().width+"px",a.setState({closing:!0})}},a.animationEnd=function(e,t){if(!t&&!a.state.closed){a.setState({closed:!0,closing:!1});var r=a.props.afterClose;r&&r()}},a.state={closing:!1,closed:!1},a}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(t,[{key:"isPresetColor",value:function(e){return!!e&&/^(pink|red|yellow|orange|cyan|green|blue|purple|geekblue|magenta|volcano|gold|lime)(-inverse)?$/.test(e)}},{key:"render",value:function(){var e,t=this.props,r=t.prefixCls,a=t.closable,l=t.color,n=t.className,o=t.children,i=t.style,s=t.angle,c=__rest(t,["prefixCls","closable","color","className","children","style","angle"]),u=a?React.createElement(_icon2.default,{type:"close",onClick:this.close}):"",_=this.isPresetColor(l),d=(0,_classnames2.default)(r,(e={},(0,_defineProperty3.default)(e,r+"-"+l,_),(0,_defineProperty3.default)(e,r+"-has-color",l&&!_),(0,_defineProperty3.default)(e,r+"-close",this.state.closing),(0,_defineProperty3.default)(e,r+"-with-angle",s&&l),e),n),p=(0,_omit2.default)(c,["onClose","afterClose"]),f=_?{}:{borderLeftColor:l,borderTopColor:l},h=(0,_extends3.default)({backgroundColor:l&&!_?l:null},i),m=this.state.closed?null:React.createElement("div",(0,_extends3.default)({"data-show":!this.state.closing},p,{className:d,style:h}),o,u,s&&l?React.createElement("div",{className:r+"-angle",style:f}):null);return React.createElement(_rcAnimate2.default,{component:"",showProp:"data-show",transitionName:r+"-zoom",transitionAppear:!0,onEnd:this.animationEnd},m)}}]),t}(React.Component);(exports.default=Tag).CheckableTag=_CheckableTag2.default,Tag.defaultProps={prefixCls:"dt-tag",closable:!1},module.exports=exports.default;