import { computed, ref } from "vue";
import { getCurrentInstance } from "@veno-ui/utils";
import { propIsDefined as _propIsDefined } from "../../utils";
function useProxiedModel(props, prop, defaultValue, transformIn = (v) => v, transformOut = (v) => v) {
  const vm = getCurrentInstance("useProxiedModel");
  const propIsDefined = computed(() => {
    return typeof props[prop] !== "undefined" && vm.vnode && _propIsDefined(vm.vnode, prop);
  });
  const internal = ref(
    typeof props[prop] === "undefined" ? defaultValue : props[prop]
  );
  return computed({
    get() {
      if (propIsDefined.value) {
        return transformIn(props[prop]);
      } else {
        return transformIn(internal.value);
      }
    },
    set(newValue) {
      internal.value = transformOut(newValue);
      vm.emit(`update:${prop}`, internal.value);
    }
  });
}
export {
  useProxiedModel
};
//# sourceMappingURL=index.mjs.map
