import { defineComponent, ref, watchEffect, openBlock, createElementBlock, createElementVNode, toDisplayString, createVNode } from "vue";
import { v as _sfc_main$1 } from "./index2.js";
import "vant";
import "@wltech/svg";
import "dayjs";
import "qs";
import "vuedraggable";
import "vue-router";
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = { class: "rf-select-wrap" };
const __default__ = {
  name: "RfSelect"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    modelValue: { default: "" },
    options: { default: null }
  },
  emits: ["update:modelValue", "onSelect", "onClose"],
  setup(__props, { emit }) {
    const props = __props;
    const popUpVisible = ref(false);
    const fieldValue = ref("");
    const fieldIndex = ref(0);
    const onClose = () => {
      popUpVisible.value = false;
      emit("onClose");
    };
    const onShow = () => popUpVisible.value = true;
    const onConfirm = (val, indexs, { selectedOptions: item }) => {
      fieldValue.value = item.text;
      emit("update:modelValue", item.text);
      emit("onSelect", item);
    };
    watchEffect(() => {
      fieldValue.value = props.modelValue;
      fieldIndex.value = props.options.findIndex((ele) => ele === props.modelValue);
      fieldIndex.value = fieldIndex.value === -1 ? 0 : fieldIndex.value;
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", {
          class: "chosed-value",
          onClick: onShow
        }, toDisplayString(fieldValue.value), 1),
        createVNode(_sfc_main$1, {
          modelValue: popUpVisible.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => popUpVisible.value = $event),
          columns: __props.options,
          pickerDefaultValue: fieldIndex.value,
          onOnClose: onClose,
          onOnConfirm: onConfirm
        }, null, 8, ["modelValue", "columns", "pickerDefaultValue"])
      ]);
    };
  }
});
export { _sfc_main as default };
