'use strict';require('./es.array.map-4cfed4ef.js'),require('./es.array.concat-bb8715dc.js'),require('./es.object.to-string-f27a75a8.js'),require('./es.regexp.to-string-5606f728.js');var normalizeComponent=require('./normalize-component-d9981c57.js');require('./export-61511812.js'),require('./array-iteration-f8b4483d.js'),require('./function-bind-context-e4685306.js'),require('./array-species-create-c414c2ec.js'),require('./array-method-has-species-support-983ac207.js'),require('./create-property-240c71a5.js'),require('./classof-819fc780.js'),require('./regexp-flags-abc49c4a.js');//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

/**
 * accessible tab switch buttons
 */
var script = {
  name: 'BaseSwitchButton',
  model: {
    prop: 'activeTab',
    event: 'switch'
  },
  props: {
    /**
     * specify the tabs as array of object with value and label properties
     */
    options: {
      type: Array,
      default: function _default() {
        return [{
          label: 'tab',
          value: 'tab'
        }];
      }
    },

    /**
     * set the currently active tab (specify the value of the object not the label)
     *
     * @model
     */
    activeTab: {
      type: String,
      default: function _default() {
        return this.options[0] ? this.options[0].value : 'tab';
      }
    },

    /**
     * set a label for the switches, not visible but needed for accessibility
     */
    label: {
      type: String,
      required: true
    }
  },
  data: function data() {
    return {
      selectedOption: this.activeTab
    };
  },
  computed: {
    // to ensure a unique id (made problems on field duplication)
    optionIds: function optionIds() {
      var _this = this;

      return this.options.map(function (option) {
        return _this.generateId(option.value);
      });
    }
  },
  watch: {
    selectedOption: function selectedOption(val) {
      /**
       * Event emitted on options switch, value of options object is emitted
       *
       * @event switch
       * @type { string }
       */
      this.$emit('switch', val);
    },
    activeTab: function activeTab(val) {
      if (val !== this.selectedOption) {
        this.selectedOption = val;
      }
    }
  },
  methods: {
    generateId: function generateId(value) {
      return "".concat(value).concat(Math.floor(Math.random() * 1000000).toString());
    }
  }
};/* script */
var __vue_script__ = script;
/* template */

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c('fieldset', {
    staticClass: "base-switch-buttons"
  }, [_vm._ssrNode("<legend class=\"hide\" data-v-d6b32f4e>" + _vm._ssrEscape("\n    " + _vm._s(_vm.label) + "\n  ") + "</legend> "), _vm._l(_vm.options, function (option, index) {
    return [_vm._ssrNode("<input" + _vm._ssrAttr("id", _vm.optionIds[index]) + _vm._ssrAttr("tabindex", option.value === _vm.selectedOption ? 0 : -1) + _vm._ssrAttr("aria-checked", option.value === _vm.selectedOption) + _vm._ssrAttr("name", _vm.label) + " type=\"radio\"" + _vm._ssrAttr("checked", option.value === _vm.selectedOption) + _vm._ssrAttr("value", option.value) + _vm._ssrAttr("checked", _vm._q(_vm.selectedOption, option.value)) + _vm._ssrClass(null, ['hide', 'base-switch-button-input', {
      'base-switch-button-input-active': option.value === _vm.selectedOption
    }]) + " data-v-d6b32f4e> "), _vm._ssrNode("<label" + _vm._ssrAttr("for", _vm.optionIds[index]) + " class=\"base-switch-button-label\" data-v-d6b32f4e>", "</label>", [_vm._ssrNode(_vm._ssrEscape("\n      " + _vm._s(option.label) + "\n      ") + " "), _vm._t("right-of-text", null, {
      "value": option.value
    })], 2)];
  })], 2);
};

var __vue_staticRenderFns__ = [];
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = "data-v-d6b32f4e";
/* module identifier */

var __vue_module_identifier__ = "data-v-d6b32f4e";
/* functional template */

var __vue_is_functional_template__ = false;
/* style inject */

/* style inject SSR */

/* style inject shadow dom */

var __vue_component__ = /*#__PURE__*/normalizeComponent.n({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);

var BaseSwitchButton = __vue_component__;exports["default"]=BaseSwitchButton;