import "../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                       */
/* empty css                                                               */
/* empty css                                                            */
/* empty css                                                         */
/* empty css                                                            */
/* empty css                                                                  */
/* empty css                                                            */
/* empty css                                                            */
import { computed, createElementBlock, openBlock, Fragment, createVNode, unref, isRef, withCtx, renderList, createBlock, createTextVNode } from "vue";
import { Plus as plus_default } from "../../../node_modules/@element-plus/icons-vue/dist/index.mjs";
import "../store/index.mjs";
import { useDialogDialog } from "../packages/dialog/useDialogDialog.mjs";
import { useDialogGlobalDialog } from "../packages/dialogGlobal/useDialogGlobalDialog.mjs";
import { ElSelect, ElOption } from "../../../node_modules/element-plus/es/components/select/index.mjs";
import { ElButton } from "../../../node_modules/element-plus/es/components/button/index.mjs";
const _sfc_main = {
  __name: "DialogSelect",
  props: {
    modelValue: {
      type: [String, Number],
      default: ""
    },
    loading: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: "default"
    },
    dialogOptions: {
      type: Array,
      default: []
    },
    isGlobal: {
      type: Boolean,
      default: false
    }
  },
  emits: ["update:modelValue", "change"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const modelValue = computed({
      get: () => props.modelValue,
      set: (val) => emit("update:modelValue", val)
    });
    function handleDialogChange(dialogId) {
      emit("change", dialogId);
    }
    const { dialogDialogVisible, openDialogDialog, DialogDialog } = useDialogDialog();
    const {
      dialogGlobalDialogVisible,
      openDialogGlobalDialog,
      DialogGlobalDialog
    } = useDialogGlobalDialog();
    function handleAddDialog() {
      if (props.isGlobal) {
        openDialogGlobalDialog();
      } else {
        openDialogDialog();
      }
    }
    return (_ctx, _cache) => {
      const _component_el_option = ElOption;
      const _component_el_button = ElButton;
      const _component_el_select = ElSelect;
      return openBlock(), createElementBlock(Fragment, null, [
        createVNode(_component_el_select, {
          ref: "selectRef",
          modelValue: unref(modelValue),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(modelValue) ? modelValue.value = $event : null),
          placeholder: "请选择弹层",
          filterable: "",
          style: { "width": "100%" },
          teleported: false,
          loading: __props.loading,
          size: __props.size,
          clearable: "",
          onChange: handleDialogChange
        }, {
          footer: withCtx(() => [
            createVNode(_component_el_button, {
              type: "primary",
              size: "small",
              icon: unref(plus_default),
              link: "",
              onClick: handleAddDialog
            }, {
              default: withCtx(() => _cache[3] || (_cache[3] = [
                createTextVNode(" 新增弹层 ")
              ])),
              _: 1
            }, 8, ["icon"])
          ]),
          default: withCtx(() => [
            (openBlock(true), createElementBlock(Fragment, null, renderList(__props.dialogOptions, (dialog) => {
              return openBlock(), createBlock(_component_el_option, {
                key: dialog.id,
                label: dialog.name,
                value: dialog.id
              }, null, 8, ["label", "value"]);
            }), 128))
          ]),
          _: 1
        }, 8, ["modelValue", "loading", "size"]),
        createVNode(unref(DialogDialog), {
          modelValue: unref(dialogDialogVisible),
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(dialogDialogVisible) ? dialogDialogVisible.value = $event : null)
        }, null, 8, ["modelValue"]),
        createVNode(unref(DialogGlobalDialog), {
          modelValue: unref(dialogGlobalDialogVisible),
          "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(dialogGlobalDialogVisible) ? dialogGlobalDialogVisible.value = $event : null)
        }, null, 8, ["modelValue"])
      ], 64);
    };
  }
};
export {
  _sfc_main as default
};
