"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_utils=require("../popup-select/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 n,o=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)),o}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,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 n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}var defaults={prefixCls:"wux-select",value:"",options:[],multiple:!1,max:-1,notFoundContent:_utils.notFoundContent,virtualized:!1,toolbar:{title:"请选择",cancelText:"取消",confirmText:"确定"},onChange:function(){},onConfirm:function(){},onCancel:function(){}};function runCallbacks(t,e,n){var e=e.value,o=n.data,r=o.options,o=o.multiple,r=(0,_utils.flattenOptions)(r),o=(0,_utils.getSelectIndex)(r,e,o);"function"==typeof n.fns[t]&&n.fns[t].call(n,e,o,r)}(0,_baseComponent.default)({useFunc:!0,data:defaults,methods:{open:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=this.$$mergeOptionsAndBindMethods(Object.assign({},defaults,t,{max:t.max?parseInt(t.max):-1,notFoundContent:(0,_utils.getNotFoundContent)(t.notFoundContent)}));this.$$setData(_objectSpread({visible:!0},t))},close:function(t){this.select=this.select||this.querySelector("#wux-popup-select"),this.select&&this.select.close(t)},onConfirm:function(t){return runCallbacks("onConfirm",t.detail,this)},onCancel:function(t){return runCallbacks("onCancel",t.detail,this)},onValueChange:function(t){return runCallbacks("onChange",t.detail,this)},onVisibleChange:function(t){this.$$setData({visible:t.detail.visible})}}});