import { defaultSerializeError } from "./router.js";
const TSR_DEFERRED_PROMISE = /* @__PURE__ */ Symbol.for("TSR_DEFERRED_PROMISE");
function defer(_promise, options) {
  const promise = _promise;
  if (promise[TSR_DEFERRED_PROMISE]) {
    return promise;
  }
  promise[TSR_DEFERRED_PROMISE] = { status: "pending" };
  promise.then((data) => {
    promise[TSR_DEFERRED_PROMISE].status = "success";
    promise[TSR_DEFERRED_PROMISE].data = data;
  }).catch((error) => {
    promise[TSR_DEFERRED_PROMISE].status = "error";
    promise[TSR_DEFERRED_PROMISE].error = {
      data: (options?.serializeError ?? defaultSerializeError)(error),
      __isServerError: true
    };
  });
  return promise;
}
export {
  TSR_DEFERRED_PROMISE,
  defer
};//# sourceMappingURL=https://main.vscode-cdn.net/sourcemaps/def9583aef9852ff94cb0dea16ede9bb6b095b30/node_modules/@tanstack/router-core/dist/esm/defer.js.map
