'use strict';

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

var vue = require('vue');
require('../../../../utils/index.js');
var is = require('../../../../utils/src/is.js');
var selectOptions = require('./selectOptions.js');
var event = require('../../../../utils/src/elementPlus/event.js');

var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{
    name: "GmSelectOptions"
  },
  __name: "SelectOptions",
  props: selectOptions.selectOptionsProps,
  emits: selectOptions.selectOptionsEmits,
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const events = event.getGmEvent(selectOptions.selectOptionsEmits, emit);
    const slots = vue.useSlots();
    const labelOptions = vue.computed(() => {
      return props.options.map((it, i) => {
        const res = {
          label: it[props.optionLabel],
          value: it[props.optionValue]
        };
        if (props.labelKey === true) {
          res.label = `${it.id}. ${res.label}`;
        } else if (props.labelKey === "index") {
          res.label = `${i + 1}. ${res.label}`;
        } else if (is.isString(props.labelKey) && Object.prototype.hasOwnProperty.call(it, props.labelKey)) {
          res.label = `${it[props.labelKey]}. ${res.label}`;
        }
        return res;
      });
    });
    return (_ctx, _cache) => {
      const _component_gm_option = vue.resolveComponent("gm-option");
      const _component_gm_select = vue.resolveComponent("gm-select");
      return vue.openBlock(), vue.createBlock(
        _component_gm_select,
        vue.mergeProps(props, vue.toHandlers(vue.unref(events))),
        vue.createSlots({
          default: vue.withCtx(() => [
            (vue.openBlock(true), vue.createElementBlock(
              vue.Fragment,
              null,
              vue.renderList(labelOptions.value, (item, index) => {
                return vue.openBlock(), vue.createBlock(_component_gm_option, {
                  key: index,
                  label: item.label,
                  value: item.value
                }, null, 8, ["label", "value"]);
              }),
              128
              /* KEYED_FRAGMENT */
            ))
          ]),
          _: 2
          /* DYNAMIC */
        }, [
          vue.unref(slots).header ? {
            name: "header",
            fn: vue.withCtx(() => [
              vue.renderSlot(_ctx.$slots, "header")
            ]),
            key: "0"
          } : void 0,
          vue.unref(slots).footer ? {
            name: "footer",
            fn: vue.withCtx(() => [
              vue.renderSlot(_ctx.$slots, "footer")
            ]),
            key: "1"
          } : void 0,
          vue.unref(slots).prefix ? {
            name: "prefix",
            fn: vue.withCtx(() => [
              vue.renderSlot(_ctx.$slots, "prefix")
            ]),
            key: "2"
          } : void 0,
          vue.unref(slots).empty ? {
            name: "empty",
            fn: vue.withCtx(() => [
              vue.renderSlot(_ctx.$slots, "empty")
            ]),
            key: "3"
          } : void 0,
          vue.unref(slots).tag ? {
            name: "tag",
            fn: vue.withCtx(() => [
              vue.renderSlot(_ctx.$slots, "tag")
            ]),
            key: "4"
          } : void 0,
          vue.unref(slots).loading ? {
            name: "loading",
            fn: vue.withCtx(() => [
              vue.renderSlot(_ctx.$slots, "loading")
            ]),
            key: "5"
          } : void 0,
          vue.unref(slots).label ? {
            name: "label",
            fn: vue.withCtx((slotValue) => [
              vue.renderSlot(_ctx.$slots, "label", vue.normalizeProps(vue.guardReactiveProps(slotValue)))
            ]),
            key: "6"
          } : void 0
        ]),
        1040
        /* FULL_PROPS, DYNAMIC_SLOTS */
      );
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=SelectOptions.vue2.js.map
