import { ref, computed, createBlock, openBlock, unref, isRef } from "vue";
import { Cascader } from "../cascader/index.mjs";
import { getCurrentVueInstance } from "../../../utils/getInstance.mjs";
import api from "../../../api/index.mjs";
const _sfc_main = /* @__PURE__ */ Object.assign({
  inheritAttrs: false
}, {
  __name: "Area",
  props: {
    config: {
      type: Object,
      required: true
    },
    modelValue: {
      type: [String, Number, Array],
      default: ""
    },
    placeholder: {
      type: String,
      default: "请选择"
    },
    disabled: {
      type: Boolean,
      default: false
    },
    readonly: {
      type: Boolean,
      default: false
    },
    multiple: {
      type: Boolean,
      default: false
    },
    showFullPath: {
      type: Boolean,
      default: true
    },
    maxLevel: {
      type: Number,
      default: 10
    },
    checkStrictly: {
      type: Boolean,
      default: false
    }
  },
  emits: ["update:modelValue", "change"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const propsData = ref({
      value: "optCode",
      label: "optName"
    });
    const ctx = getCurrentVueInstance();
    const inputValue = computed({
      get: () => {
        return props.modelValue;
      },
      set: (val) => {
        emit("update:modelValue", val);
        emit("change", val);
      }
    });
    const optionConfig = ref({
      idField: "dicId",
      pidField: "pdicId"
    });
    api.getDataDicArea4Cascader(ctx.$http).then((data) => {
      optionConfig.value.options = data;
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Cascader), {
        modelValue: unref(inputValue),
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(inputValue) ? inputValue.value = $event : null),
        config: __props.config,
        placeholder: __props.placeholder,
        showFullPath: __props.showFullPath,
        disabled: __props.disabled,
        readonly: __props.readonly,
        optionConfig: unref(optionConfig),
        multiple: __props.multiple,
        maxLevel: __props.maxLevel,
        propsData: unref(propsData),
        checkStrictly: __props.checkStrictly
      }, null, 8, ["modelValue", "config", "placeholder", "showFullPath", "disabled", "readonly", "optionConfig", "multiple", "maxLevel", "propsData", "checkStrictly"]);
    };
  }
});
export {
  _sfc_main as default
};
