"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames3=_interopRequireDefault(require("../helpers/libs/classNames")),_eventsMixin=_interopRequireDefault(require("../helpers/mixins/eventsMixin")),_colors=require("../helpers/colors");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,o){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0===o)return("string"===t?String:Number)(e);o=o.call(e,t||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}(0,_baseComponent.default)({useField:!0,behaviors:[(0,_eventsMixin.default)()],relations:{"../field/index":{type:"ancestor"}},properties:{prefixCls:{type:String,value:"wux-switch"},value:{type:Boolean,value:!1,observer:function(e){this.hasFieldDecorator||this.updated(e)}},disabled:{type:Boolean,value:!1},loading:{type:Boolean,value:!1},color:{type:String,value:"balanced",observer:"updateStyle"},checkedText:{type:String,value:""},uncheckedText:{type:String,value:""}},data:{inputStyle:"",inputChecked:!1},computed:{classes:["prefixCls, inputChecked, disabled, loading, color",function(e,t,o,r,i){return{wrap:(0,_classNames3.default)(e,_defineProperty(_defineProperty(_defineProperty({},"".concat(e,"--").concat(i),i),"".concat(e,"--checked"),t),"".concat(e,"--disabled"),o||r)),input:(0,_classNames3.default)("".concat(e,"__input"),_defineProperty(_defineProperty({},"".concat(e,"__input--checked"),t),"".concat(e,"__input--disabled"),o||r)),text:"".concat(e,"__text"),spin:"".concat(e,"__spin")}}]},methods:{updated:function(e){this.data.inputChecked!==e&&this.setData({inputChecked:e})},onTap:function(e){var t=this.data,o=t.inputChecked,r=t.disabled,t=t.loading;r||t||this.triggerEvent("change",{value:!o})},updateStyle:function(e){e=(0,_colors.isPresetColor)(e),e="border-color: ".concat(e,"; background-color: ").concat(e,";");this.setData({inputStyle:e})}},attached:function(){this.updateStyle(this.data.color)}});