"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                                */
;/* empty css                                                                        */
;/* empty css                                                                     */
;/* empty css                                                                  */
;/* empty css                                                                     */
;/* empty css                                                                           */
;/* empty css                                                                     */
const Vue = require("vue");
const common = require("../../../utils/common.js");
const index = require("../../../../../../node_modules/element-plus/es/components/select/index.js");
const _sfc_main = /* @__PURE__ */ Object.assign({
  inheritAttrs: false
}, {
  __name: "Select",
  props: {
    config: {
      type: Object,
      required: true
    },
    modelValue: {
      type: null,
      default: ""
    },
    placeholder: {
      type: String,
      default: ""
    },
    disabled: {
      type: Boolean,
      default: false
    },
    readonly: {
      type: Boolean,
      default: false
    },
    multiple: {
      type: Boolean,
      default: false
    },
    clearable: {
      type: Boolean,
      default: true
    },
    filterable: {
      type: Boolean,
      default: false
    },
    optionConfig: {
      type: Object,
      default: () => ({})
    }
  },
  emits: ["update:modelValue", "change"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const formData = Vue.inject("formData", null);
    const fieldsData = Vue.inject("fieldsData", []);
    const hiddenFields = Vue.inject("hiddenFields", []);
    const emit = __emit;
    const inputValue = Vue.computed({
      get: () => props.modelValue,
      set: (val) => {
        emit("update:modelValue", val);
        emit("change", val);
      }
    });
    const options = Vue.computed(() => {
      if (!props.optionConfig) return [];
      return props.optionConfig.options || [];
    });
    function handlerChange(val) {
      common.setFormDataByFieldMapping(
        val,
        props.multiple,
        options.value,
        props.optionConfig.fieldMapping,
        formData,
        [...(fieldsData == null ? void 0 : fieldsData.value) || [], ...(hiddenFields == null ? void 0 : hiddenFields.value) || []]
      );
    }
    return (_ctx, _cache) => {
      const _component_el_option = index.ElOption;
      const _component_el_select = index.ElSelect;
      return Vue.openBlock(), Vue.createBlock(_component_el_select, Vue.mergeProps({
        modelValue: inputValue.value,
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
      }, Vue.toHandlers(__props.config.eventHandlers), {
        placeholder: __props.placeholder,
        disabled: __props.disabled,
        multiple: __props.multiple,
        clearable: __props.clearable,
        filterable: __props.filterable,
        style: [{ "width": "100%" }, {
          pointerEvents: __props.readonly ? "none" : "auto"
        }],
        onChange: handlerChange
      }), {
        default: Vue.withCtx(() => [
          (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(options.value, (option) => {
            return Vue.openBlock(), Vue.createBlock(_component_el_option, {
              key: option.value,
              label: option.label,
              value: option.value,
              disabled: option.disabled
            }, null, 8, ["label", "value", "disabled"]);
          }), 128))
        ]),
        _: 1
      }, 16, ["modelValue", "placeholder", "disabled", "multiple", "clearable", "filterable", "style"]);
    };
  }
});
exports.default = _sfc_main;
