function o(e) {
  const r = import.meta.url;
  return new URL(e, r).href;
}
const c = [
  {
    fileName: "UI.js",
    href: o("./UI.js"),
    rel: "modulepreload"
  },
  {
    fileName: "UI.runtime.js",
    href: o("./UI.runtime.js"),
    rel: "modulepreload"
  },
  {
    fileName: "ApiBase.js",
    href: o("./ApiBase.js"),
    rel: "modulepreload"
  },
  {
    fileName: "index_browser.js",
    href: o("./index_browser.js"),
    rel: "modulepreload"
  },
  {
    fileName: "office.core.js",
    href: o("./office.core.js"),
    rel: "modulepreload"
  },
  {
    fileName: "office.locale.js",
    href: o("./office.locale.js"),
    rel: "modulepreload"
  },
  {
    fileName: "compat-globals.js",
    href: o("./compat-globals.js"),
    rel: "modulepreload"
  },
  {
    fileName: "locale-assets/locale.js",
    href: o("./locale-assets/locale.js"),
    rel: "modulepreload"
  },
  {
    fileName: "worker/index.js",
    href: o("./worker/index.js"),
    rel: "modulepreload"
  },
  {
    fileName: "worker/wasm/bootloader.js",
    href: o("./worker/wasm/bootloader.js"),
    rel: "modulepreload"
  },
  {
    fileName: "vendor/zepto.min.js",
    href: o("./vendor/zepto.min.js"),
    rel: "preload",
    as: "script"
  },
  {
    fileName: "vendor/xregexp-all-min.js",
    href: o("./vendor/xregexp-all-min.js"),
    rel: "preload",
    as: "script"
  },
  {
    fileName: "vendor/js.cookie.min.js",
    href: o("./vendor/js.cookie.min.js"),
    rel: "preload",
    as: "script"
  },
  {
    fileName: "vendor/md5.min.js",
    href: o("./vendor/md5.min.js"),
    rel: "preload",
    as: "script"
  },
  {
    fileName: "style.css",
    href: o("./style.css"),
    rel: "preload",
    as: "style"
  }
], p = [
  {
    fileName: "mountDocxApp.js",
    href: o("./mountDocxApp.js"),
    rel: "modulepreload"
  },
  {
    fileName: "mountXlsxApp.js",
    href: o("./mountXlsxApp.js"),
    rel: "modulepreload"
  },
  {
    fileName: "mountPptxApp.js",
    href: o("./mountPptxApp.js"),
    rel: "modulepreload"
  }
], i = /* @__PURE__ */ new Map();
let a = null, s = null;
function d() {
  return typeof document < "u";
}
function w() {
  var r, l;
  return a ?? (d() ? (a = !!((l = (r = document.createElement("link").relList) == null ? void 0 : r.supports) != null && l.call(r, "modulepreload")), a) : (a = !1, a));
}
function h(e) {
  return Array.from(document.querySelectorAll("link")).some((r) => r.href !== e ? !1 : r.rel === "modulepreload" || r.rel === "preload" || r.rel === "stylesheet");
}
function j(e) {
  return Array.from(document.scripts).some((r) => r.src === e);
}
function k(e, r) {
  return !!(h(r) || e.as === "script" && j(r));
}
function y(e, r) {
  return k(e, r) ? Promise.resolve() : new Promise((l, t) => {
    const n = document.createElement("link");
    n.rel = e.rel, n.href = r, n.dataset.officeSdkPreload = e.fileName, e.as && (n.as = e.as), e.rel === "modulepreload" && (n.crossOrigin = "anonymous"), n.addEventListener("load", () => l(), { once: !0 }), n.addEventListener(
      "error",
      () => t(new Error(`failed to preload ${e.fileName}`)),
      { once: !0 }
    ), (document.head ?? document.documentElement).appendChild(n);
  });
}
async function u(e) {
  if (typeof fetch != "function")
    return;
  const r = await fetch(e, {
    mode: "cors",
    credentials: "same-origin"
  });
  if (!r.ok && r.status !== 0)
    throw new Error(`failed to preload ${e}: ${r.status}`);
}
function N(e) {
  const r = `${e.rel}:${e.href}`;
  if (i.has(r))
    return i.get(r);
  const l = (async () => {
    if (d()) {
      if (e.rel === "modulepreload" && !w()) {
        await u(e.href);
        return;
      }
      try {
        await y(e, e.href);
      } catch {
        await u(e.href);
      }
    }
  })().catch((t) => {
    `${e.fileName}`;
  });
  return i.set(r, l), l;
}
async function m(e) {
  await Promise.all(e.map((r) => N(r)));
}
function A(e) {
  return new Promise((r) => {
    if (typeof window < "u" && "requestIdleCallback" in window) {
      window.requestIdleCallback(
        () => {
          e().finally(r);
        },
        { timeout: 1200 }
      );
      return;
    }
    setTimeout(() => {
      e().finally(r);
    }, 150);
  });
}
function x(e = {}) {
  const r = e.workerUrl ? new URL(e.workerUrl, import.meta.url).href : new URL(
    /* @vite-ignore */
    "./worker/index.js",
    import.meta.url
  ).href, l = new URL("./", r);
  return {
    workerUrl: r,
    bootloaderUrl: new URL("./wasm/bootloader.js", l).href,
    wasmUrl: new URL("./wasm/canvaskit.wasm", l).href
  };
}
function f() {
  return s || (s = (async () => {
    await m(c), d() && await A(() => m(p));
  })()), s;
}
function U() {
  return f();
}
async function v(e = {}) {
  return await f(), x(e);
}
const P = f();
export {
  P as default,
  f as preloadOfficeSdk,
  v as preloadOfficeSdkRuntime,
  P as preloadTask,
  U as primeOfficeSdkRuntimePreload
};
