import { callDefaultFetch } from "./call-default-fetch.js";
import { isClientStateNotFoundResponse, isVersionNotSupportedResponse } from "./error-responses.js";
function getDefaultPusher(rep) {
  async function pusher(requestBody, requestID) {
    const [response, httpRequestInfo] = await callDefaultFetch(
      rep.pushURL,
      rep.auth,
      requestID,
      requestBody
    );
    if (!response) {
      return { httpRequestInfo };
    }
    const rv = {
      httpRequestInfo
    };
    let result;
    try {
      result = await response.json();
    } catch {
      return rv;
    }
    if (isClientStateNotFoundResponse(result) || isVersionNotSupportedResponse(result)) {
      rv.response = result;
    }
    return rv;
  }
  defaultPushers.add(pusher);
  return pusher;
}
const defaultPushers = /* @__PURE__ */ new WeakSet();
function isDefaultPusher(pusher) {
  return defaultPushers.has(pusher);
}
export {
  getDefaultPusher,
  isDefaultPusher
};
//# sourceMappingURL=get-default-pusher.js.map
