"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const select = require("../../select/src/select.js");
const index = require("../../select/index.js");
const tree = require("../../tree/src/tree.js");
const index$1 = require("../../tree/index.js");
const select$1 = require("./select.js");
const tree$1 = require("./tree.js");
const cacheOptions = require("./cache-options.js");
const vue = require("vue");
const pick = require("../../../../../lodash-es/pick.js");
var tree_select_vue_vue_type_script_lang_default = vue.defineComponent({
  name: "ElTreeSelect",
  inheritAttrs: false,
  props: {
    ...select.selectProps,
    ...tree.treeProps,
    cacheData: {
      type: Array,
      default: () => []
    }
  },
  setup(props, context) {
    const { slots, expose, emit, attrs } = context;
    const childAttrs = {
      ...attrs,
      onChange: void 0
    };
    const select2 = vue.ref();
    const tree2 = vue.ref();
    const key = vue.computed(() => props.nodeKey || props.valueKey || "value");
    const selectProps = select$1.useSelect(props, {
      attrs,
      emit
    }, {
      select: select2,
      tree: tree2,
      key
    });
    const { cacheOptions: cacheOptions$1, ...treeProps } = tree$1.useTree(props, {
      attrs: childAttrs,
      slots,
      emit
    }, {
      select: select2,
      tree: tree2,
      key
    });
    const methods = vue.reactive({});
    expose(methods);
    vue.onMounted(() => {
      Object.assign(methods, {
        ...pick.default(tree2.value, [
          "filter",
          "updateKeyChildren",
          "getCheckedNodes",
          "setCheckedNodes",
          "getCheckedKeys",
          "setCheckedKeys",
          "setChecked",
          "getHalfCheckedNodes",
          "getHalfCheckedKeys",
          "getCurrentKey",
          "getCurrentNode",
          "setCurrentKey",
          "setCurrentNode",
          "getNode",
          "remove",
          "append",
          "insertBefore",
          "insertAfter"
        ]),
        ...pick.default(select2.value, [
          "focus",
          "blur",
          "selectedLabel"
        ]),
        treeRef: tree2.value,
        selectRef: select2.value
      });
    });
    return () => vue.h(
      index.ElSelect,
      /**
      * 1. The `props` is processed into `Refs`, but `v-bind` and
      * render function props cannot read `Refs`, so use `reactive`
      * unwrap the `Refs` and keep reactive.
      * 2. The keyword `ref` requires `Ref`, but `reactive` broke it,
      * so use function.
      */
      vue.reactive({
        ...selectProps,
        ref: (ref) => select2.value = ref
      }),
      {
        ...slots,
        default: () => [vue.h(cacheOptions.default, { data: cacheOptions$1.value }), vue.h(index$1.ElTree, vue.reactive({
          ...treeProps,
          ref: (ref) => tree2.value = ref
        }))]
      }
    );
  }
});
exports.default = tree_select_vue_vue_type_script_lang_default;
