import './es.array.map-6e99e953.js';
import './es.array.filter-2c1d67da.js';
import './es.object.to-string-363bb00e.js';
import './es.array.includes-429b943f.js';
import './es.string.includes-7cd9db5f.js';
import BaseButton from './BaseButton-48b540ba.js';
import { n as normalizeComponent } from './normalize-component-f552f2b0.js';
import './export-ca205aa3.js';
import './array-iteration-174e15bc.js';
import './function-bind-context-b3fabf77.js';
import './array-species-create-734a2b2d.js';
import './array-method-has-species-support-4880738d.js';
import './classof-efe356f2.js';
import './object-keys-2117de4f.js';
import './is-regexp-2d7aa8f2.js';
import './es.symbol.description-ff7a02e9.js';
import './set-to-string-tag-8223b960.js';
import './utils-1ee736f4.js';
import './typeof-6c6d8d7a.js';
import './unsupportedIterableToArray-577176bf.js';
import './es.array.join-6d270396.js';
import './array-method-is-strict-b717b087.js';
import './regexp-exec-abstract-f3a4fb3d.js';
import './string-multibyte-2334bbf7.js';
import './regexp-flags-0e12a922.js';
import './es.string.split-e8138ba0.js';
import './es.array.slice-8edbe7ac.js';
import './create-property-64305cbf.js';
import './es.regexp.to-string-60b34f50.js';
import './es.string.replace-71289216.js';
import './es.array.sort-429613bb.js';
import './web.dom-collections.for-each-88fb2ed7.js';
import './dom-iterables-b6f5ef3b.js';
import './es.object.keys-8d50ea2f.js';
import './BaseIcon-97f2c0df.js';
import 'vue-svgicon';
import './BaseBoxTooltip-01bd0121.js';

/**
 * component to enable display of selected items and a select all
 */

var script = {
  name: 'BaseSelectOptions',
  components: {
    BaseButton: BaseButton
  },
  props: {
    /**
     * specify the text displayed for number of selected entries
     * x {selectText}
     */
    selectedNumberText: {
      type: String,
      default: 'entries selected'
    },

    /**
     * the text displayed for select / deselect all
     */
    selectText: {
      type: String,
      default: 'All'
    },

    /**
     * the text displayed for select / deselect all
     */
    deselectText: {
      type: String,
      default: 'None'
    },

    /**
     * provide a list of currently visible entries
     */
    list: {
      type: Array,
      default: function _default() {
        return [];
      }
    },

    /**
     * provide a list of selected entries
     */
    selectedList: {
      type: Array,
      default: function _default() {
        return [];
      }
    },

    /**
     * disable the button by setting this prop to true
     */
    selectAllDisabled: {
      type: Boolean,
      default: false
    },

    /**
     * By default, the "All/None" button appears on the right, and the counter of
     * selected items appears on the left. Set this to `true` to reverse the order.
     */
    reverse: {
      type: Boolean,
      default: false
    }
  },
  data: function data() {
    return {
      selectedInt: false,
      // used to change the flex direction of select options from 'row' to 'row-reverse' (#1692)
      flexDirection: 'row'
    };
  },
  computed: {
    numberSelected: function numberSelected() {
      return this.selectedList.length;
    },
    allSelected: function allSelected() {
      // not just calc comparing selectedList with list because with pagination
      // selectedList can contain entries that are currently not incluced in list
      var idList = this.selectedList.length && this.selectedList[0].id ? this.selectedList.map(function (entry) {
        return entry.id;
      }) : this.selectedList;
      var unselectedLength = this.list.filter(function (entry) {
        return !idList.includes(entry.id);
      }).length;
      return unselectedLength === 0;
    }
  },
  watch: {
    allSelected: {
      handler: function handler(val) {
        if (val !== this.selectedInt) {
          this.selectedInt = val;
        }
      },
      immediate: true
    }
  },
  created: function created() {
    // swap position of select options based on the 'reverse' prop (#1692)
    this.flexDirection = this.reverse ? 'row-reverse' : 'row';
  },
  methods: {
    select: function select() {
      this.selectedInt = !this.selectedInt;
      /**
       * emitted on select all button click
       *
       * @event selected
       * @param {boolean} selectedInt
       */

      this.$emit('selected', this.selectedInt);
    }
  }
};

/* 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('div', {
    staticClass: "base-select-options",
    style: {
      '--direction': _vm.flexDirection
    }
  }, [_c('div', {
    staticClass: "base-select-options__number-selected"
  }, [_vm._t("selectedText", function () {
    return [_vm._v("\n      " + _vm._s(_vm.numberSelected + " " + _vm.selectedNumberText) + "\n    ")];
  })], 2), _vm._v(" "), _c('BaseButton', {
    staticClass: "base-select-options__select-button",
    attrs: {
      "text": _vm.allSelected ? _vm.deselectText : _vm.selectText,
      "disabled": _vm.selectAllDisabled,
      "button-style": "secondary"
    },
    on: {
      "clicked": _vm.select
    }
  })], 1);
};

var __vue_staticRenderFns__ = [];
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

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

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = false;
/* style inject */

/* style inject SSR */

/* style inject shadow dom */

var __vue_component__ = /*#__PURE__*/normalizeComponent({
  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 BaseSelectOptions = __vue_component__;

export { BaseSelectOptions as default };
