'use strict';

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

var __chunk_1 = require('./chunk-cc325129.js');
var __chunk_2 = require('./chunk-d8f887e2.js');
var __chunk_3 = require('./chunk-39b0a5eb.js');
var __chunk_5 = require('./chunk-22e9253e.js');

var checkSvgIcon = "<svg width=\"10\" height=\"8\" viewBox=\"0 0 10 8\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M3.75 7.4375L0.625 4.3375L1.61875 3.35625L3.75 5.46875L8.38125 0.875L9.375 1.8625L3.75 7.4375Z\" fill=\"white\"/>\n</svg>\n";

var script = {
  name: 'VCheckbox',
  props: {
    name: {
      type: String,
      default: 'checkbox'
    },
    value: {
      type: [String, Boolean],
      default: false
    },
    modelValue: {
      type: null,
      default: false
    },
    trueValue: {
      type: null,
      default: true
    },
    falseValue: {
      type: null,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    error: {
      type: String,
      default: null
    }
  },
  data: function data() {
    return {
      isFocused: false,
      checkSvgIcon: checkSvgIcon
    };
  },
  computed: {
    isChecked: function isChecked() {
      var isListHandling = this.modelValue instanceof Array;

      if (isListHandling) {
        return this.modelValue.includes(this.value);
      }

      return this.modelValue === this.trueValue;
    },
    checkboxCssClass: function checkboxCssClass() {
      return Object.assign(this.themeCssClass, {
        'is-checked': this.isChecked,
        'is-focused': this.isFocused,
        'is-disabled': this.disabled || this.isDisabled,
        'is-error': this.error
      });
    }
  },
  methods: {
    handleChange: function handleChange(event) {
      var checked = event.target.checked;
      var isListHandling = this.modelValue instanceof Array;

      if (!isListHandling) {
        this.$emit('change', checked ? this.trueValue : this.falseValue);
        return;
      }

      var newValue = __chunk_2._toConsumableArray(this.modelValue);

      if (this.modelValue.includes(this.value)) {
        newValue.splice(newValue.indexOf(this.value), 1);
      } else {
        newValue.push(this.value);
      }

      this.$emit('change', newValue);
    }
  },
  mixins: [__chunk_2.ThemeMixin, __chunk_5.IsDisabledMixin],
  components: {
    IconAtom: __chunk_3.IconAtom
  },
  model: {
    prop: 'modelValue',
    event: 'change'
  }
};

/* 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('label',{staticClass:"v-checkbox",class:_vm.checkboxCssClass},[_c('icon-atom',{staticClass:"v-checkbox-frame",domProps:{"innerHTML":_vm._s(_vm.checkSvgIcon)}}),_vm._v(" "),_c('input',{staticClass:"v-checkbox-control",class:{ 'is-danger': _vm.error },attrs:{"disabled":_vm.disabled,"name":_vm.name,"type":"checkbox"},domProps:{"checked":_vm.isChecked,"value":_vm.value},on:{"change":_vm.handleChange,"focus":function($event){_vm.isFocused = true;},"blur":function($event){_vm.isFocused = false;}}}),_vm._v(" "),_c('span',{staticClass:"v-checkbox-label"},[_vm._t("default")],2)],1)};
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 VCheckbox = __chunk_1.__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
  );

exports.default = VCheckbox;
