'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var normalizeComponent = require('./normalize-component-6fa50395.js');
var ThemeMixin = require('./ThemeMixin-a2f817cd.js');
var svgAtom = require('./svg-atom-d2541b7d.js');
var iconAtom = require('./icon-atom-65241b51.js');
require('./hover-atom-17a12a07.js');
require('./tooltip-atom-8f536df5.js');
var fieldAtom = require('./field-atom-fe4b7c7b.js');
var errorAtom = require('./error-atom-2f5dc7b9.js');
var labelMolecule = require('./label-molecule-9793dd9f.js');
var descriptionAtom = require('./description-atom-34b2b8a7.js');

var script = {
  name: 'SelectAtom',
  inheritAttrs: false,
  props: {
    value: {
      type: [String, Number],
      default: null
    },
    options: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    skin: {
      type: String,
      default: 'primary',
      validator: function validator(value) {
        return ['primary', 'secondary'].indexOf(value) !== -1;
      }
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    normalizedOptions: function normalizedOptions() {
      return this.options.reduce(function (acc, item) {
        if (item instanceof Object) {
          return acc.concat(item);
        }

        return acc.concat({
          val: item,
          key: item,
          text: item
        });
      }, []);
    },
    listeners: function listeners() {
      var _this = this;

      return Object.assign(this.$listeners, {
        input: function input(event) {
          _this.$emit('input', event.target.value);
        }
      });
    },
    selectAtomCssClass: function selectAtomCssClass() {
      return ThemeMixin._objectSpread2(ThemeMixin._objectSpread2({}, this.themeCssClass), {}, ThemeMixin._defineProperty({
        'is-error': this.$attrs['is-error'],
        'is-disabled': this.disabled
      }, "skin-".concat(this.skin), true));
    }
  },
  mixins: [ThemeMixin.ThemeMixin]
};

/* script */
const __vue_script__ = script;

/* template */
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('span',{staticClass:"select-atom",class:_vm.selectAtomCssClass},[_c('select',_vm._g(_vm._b({staticClass:"select-atom-control",attrs:{"disabled":_vm.disabled},domProps:{"value":_vm.value}},'select',_vm.$attrs,false),_vm.listeners),_vm._l((_vm.normalizedOptions),function(item){return _c('option',{key:item.key || item.val || item,domProps:{"value":item.val}},[_vm._v("\n      "+_vm._s(item.text)+"\n    ")])}),0),_vm._v(" "),_vm._t("default")],2)};
var __vue_staticRenderFns__ = [];

  /* style */
  const __vue_inject_styles__ = undefined;
  /* scoped */
  const __vue_scope_id__ = undefined;
  /* module identifier */
  const __vue_module_identifier__ = undefined;
  /* functional template */
  const __vue_is_functional_template__ = false;
  /* style inject */
  
  /* style inject SSR */
  

  
  var SelectAtom = normalizeComponent.__vue_normalize__(
    { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
    __vue_inject_styles__,
    __vue_script__,
    __vue_scope_id__,
    __vue_is_functional_template__,
    __vue_module_identifier__,
    undefined,
    undefined
  );

//
var script$1 = {
  name: 'VSelect',
  inheritAttrs: false,
  props: {
    label: {
      type: String,
      default: null
    },
    tooltipLabel: {
      type: String,
      default: ''
    },
    value: {
      type: [String, Number],
      default: null
    },
    error: {
      type: String,
      default: null
    },
    description: {
      type: String,
      default: null
    },
    options: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    skin: {
      type: String,
      default: 'primary'
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    isError: function isError() {
      return !!this.error;
    }
  },
  components: {
    LabelMolecule: labelMolecule.LabelMolecule,
    IconAtom: iconAtom.IconAtom,
    SelectAtom: SelectAtom,
    FieldAtom: fieldAtom.FieldAtom,
    ErrorAtom: errorAtom.ErrorAtom,
    DescriptionAtom: descriptionAtom.DescriptionAtom,
    SvgAtom: svgAtom.SvgAtom
  },
  model: {
    event: 'input',
    prop: 'value'
  }
};

/* script */
const __vue_script__$1 = script$1;

/* template */
var __vue_render__$1 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('field-atom',{staticClass:"v-select"},[(_vm.label)?_c('label-molecule',{attrs:{"label":_vm.label,"tooltip-label":_vm.tooltipLabel,"disabled":_vm.disabled}}):_vm._e(),_vm._v(" "),(_vm.description)?_c('description-atom',_vm._b({attrs:{"description":_vm.description}},'description-atom',_vm.$attrs,false)):_vm._e(),_vm._v(" "),_c('select-atom',_vm._g(_vm._b({attrs:{"value":_vm.value,"is-error":_vm.isError,"options":_vm.options,"skin":_vm.skin,"disabled":_vm.disabled}},'select-atom',_vm.$attrs,false),_vm.$listeners),[(_vm.isError)?_c('icon-atom',{staticClass:"v-select-icon-error",attrs:{"is-error":_vm.isError}},[_c('svg-atom',{attrs:{"name":"error"}})],1):_vm._e()],1),_vm._v(" "),(_vm.isError)?_c('error-atom',{attrs:{"error":_vm.error}}):_vm._e()],1)};
var __vue_staticRenderFns__$1 = [];

  /* style */
  const __vue_inject_styles__$1 = undefined;
  /* scoped */
  const __vue_scope_id__$1 = undefined;
  /* module identifier */
  const __vue_module_identifier__$1 = undefined;
  /* functional template */
  const __vue_is_functional_template__$1 = false;
  /* style inject */
  
  /* style inject SSR */
  

  
  var VSelect = normalizeComponent.__vue_normalize__(
    { render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
    __vue_inject_styles__$1,
    __vue_script__$1,
    __vue_scope_id__$1,
    __vue_is_functional_template__$1,
    __vue_module_identifier__$1,
    undefined,
    undefined
  );

exports.default = VSelect;
