import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
import { defineComponent, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, Fragment, renderList, createBlock } from 'vue';
import { useTheme } from '../_theme/useTheme';
import getPrefixCls from '../_util/getPrefixCls';
import Checkbox from '../checkbox';
import { UPDATE_MODEL_EVENT, CHANGE_EVENT } from '../_util/constants';
import { useCheckboxGroup } from './useCheckboxGroup';
import { COMPONENT_NAME } from './const';
import { checkboxGroupProps } from './props';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
const prefixCls = getPrefixCls('checkbox-group');
var script = defineComponent({
  name: COMPONENT_NAME,
  components: {
    Checkbox
  },
  props: checkboxGroupProps,
  emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT],
  setup(props, _ref) {
    let {
      emit
    } = _ref;
    useTheme();
    const {
      isFormDisabled
    } = useCheckboxGroup(props, emit);
    const classList = computed(() => [prefixCls, props.vertical && 'is-vertical', (isFormDisabled.value || props.disabled) && 'is-disabled']);
    const optionsRef = computed(() => props.options ? props.options.map(opt => {
      return _objectSpread(_objectSpread({}, opt), {}, {
        value: opt[props.valueField],
        label: opt[props.labelField]
      });
    }) : []);
    return {
      classList,
      optionsRef
    };
  }
});

function render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_Checkbox = resolveComponent("Checkbox");
  return openBlock(), createElementBlock("div", {
    class: normalizeClass(_ctx.classList)
  }, [renderSlot(_ctx.$slots, "default"), (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.optionsRef, opt => {
    return openBlock(), createBlock(_component_Checkbox, {
      key: opt.value,
      value: opt.value,
      label: opt.label,
      disabled: opt.disabled
    }, null, 8 /* PROPS */, ["value", "label", "disabled"]);
  }), 128 /* KEYED_FRAGMENT */))], 2 /* CLASS */);
}

script.render = render;
script.__file = "components/checkbox-group/checkbox-group.vue";

export { script as default };
