function a(t) {
  let e = "pending", n;
  const s = t().then((r) => {
    e = "success", n = r;
  }).catch((r) => {
    e = "error", n = r;
  });
  return {
    read() {
      switch (e) {
        case "success":
        case "error":
          return n;
        case "pending":
          throw s;
      }
    }
  };
}
const o = /* @__PURE__ */ new Map();
function c(t) {
  let e = o.get(t);
  return e || (e = a(
    () => new Promise((n, s) => {
      const r = document.createElement("img");
      r.src = t, r.addEventListener("load", () => n(t)), r.addEventListener("error", () => s(new Error(`Failed to load image ${t}`)));
    })
  ), o.set(t, e), e);
}
export {
  c as suspendImageLoad
};
