import { watch as o } from "vue";
import { cloneDeep as a, isEqual as n } from "lodash";
const s = (e, c, u, f) => {
  const i = (t) => {
    if (e.option.default.isDefaultSelect) {
      if (!t && f.value.length > 0) {
        u.value = f.value[0].value;
        return;
      }
      u.value = t;
    } else
      u.value = "";
  };
  o(
    () => e.sources,
    () => {
      e.sources && e.sources.length > 0 && c(e.option);
    },
    {
      deep: !0
    }
  ), o(
    () => a(e.option.default.value),
    (t, l) => {
      n(t, l) || i(t);
    },
    {
      deep: !0
    }
  ), o(
    () => a(e.option.default.isDefaultSelect),
    (t, l) => {
      n(t, l) || i(e.option.default.value);
    },
    {
      deep: !0
    }
  );
};
export {
  s as useWatch
};
