"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                                                            */
;/* empty css                                                            */
const Vue = require("vue");
const index$2 = require("../../../node_modules/@element-plus/icons-vue/dist/index.js");
const common = require("../packages/utils/common.js");
const useDataSourceDialog = require("../packages/dataSource/useDataSourceDialog.js");
const index = require("../../../node_modules/element-plus/es/components/select/index.js");
const index$1 = require("../../../node_modules/element-plus/es/components/button/index.js");
const _sfc_main = {
  __name: "DataSourceSelect",
  props: {
    modelValue: {
      type: [String, Number],
      default: ""
    }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const modelValue = Vue.computed({
      get: () => props.modelValue,
      set: (val) => emit("update:modelValue", val)
    });
    const { dataSourceDialogVisible, openDataSourceDialog, DataSourceDialog } = useDataSourceDialog.useDataSourceDialog();
    const dataSources = Vue.computed(() => {
      return common.getEditConfigDataSources();
    });
    const selectRef = Vue.ref(null);
    const handleAddDataSource = () => {
      var _a;
      (_a = selectRef.value) == null ? void 0 : _a.blur();
      openDataSourceDialog();
    };
    return (_ctx, _cache) => {
      const _component_el_option = index.ElOption;
      const _component_el_button = index$1.ElButton;
      const _component_el_select = index.ElSelect;
      return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
        Vue.createVNode(_component_el_select, {
          ref_key: "selectRef",
          ref: selectRef,
          modelValue: Vue.unref(modelValue),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(modelValue) ? modelValue.value = $event : null),
          placeholder: "请选择数据源",
          filterable: "",
          style: { "width": "100%" },
          teleported: false
        }, {
          footer: Vue.withCtx(() => [
            Vue.createVNode(_component_el_button, {
              type: "primary",
              size: "small",
              icon: Vue.unref(index$2.Plus),
              link: "",
              onClick: handleAddDataSource
            }, {
              default: Vue.withCtx(() => _cache[2] || (_cache[2] = [
                Vue.createTextVNode(" 新增数据源 ")
              ])),
              _: 1
            }, 8, ["icon"])
          ]),
          default: Vue.withCtx(() => [
            (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(dataSources), (dataSource) => {
              return Vue.openBlock(), Vue.createBlock(_component_el_option, {
                key: dataSource.id,
                label: dataSource.name,
                value: dataSource.id
              }, null, 8, ["label", "value"]);
            }), 128))
          ]),
          _: 1
        }, 8, ["modelValue"]),
        Vue.createVNode(Vue.unref(DataSourceDialog), {
          modelValue: Vue.unref(dataSourceDialogVisible),
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => Vue.isRef(dataSourceDialogVisible) ? dataSourceDialogVisible.value = $event : null)
        }, null, 8, ["modelValue"])
      ], 64);
    };
  }
};
exports.default = _sfc_main;
