import { isJsonEqual as c, deepClone as i } from "@milaboratories/helpers";
import { ref as l, watch as t } from "vue";
function n(m, d, e) {
  const a = l(), u = t(
    m,
    (r) => {
      c(r, a.value) || (a.value = i(r));
    },
    {
      deep: !0,
      immediate: !0
      // always initialize cachedValue
    }
  );
  return t(
    () => a.value,
    // `as T` is safe as we always initialize cachedValue
    d,
    // separate watch so that `onWatcherCleanup` would only be triggerred here
    {
      // standard vue `WatchOptions` conform to `WatchCachedOptions` interface,
      // so construct new options to remove unsupported entries
      deep: !0,
      immediate: e == null ? void 0 : e.immediate
    }
  ), u;
}
export {
  n as watchCached
};
//# sourceMappingURL=watchCached.js.map
