"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const fs = require("fs");
const path = require("path");
const url = require("url");
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
function _interopNamespaceDefault(e) {
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
  if (e) {
    for (const k in e) {
      if (k !== "default") {
        const d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: () => e[k]
        });
      }
    }
  }
  n.default = e;
  return Object.freeze(n);
}
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
const __dirname$1 = path__namespace.dirname(url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("next-plugin.cjs", document.baseURI).href));
function getServiceWorkerContent() {
  let swFilePath = path__namespace.join(__dirname$1, "__sw__.js");
  if (!fs__namespace.existsSync(swFilePath)) {
    swFilePath = path__namespace.join(__dirname$1, "../dist/__sw__.js");
  }
  if (!fs__namespace.existsSync(swFilePath)) {
    swFilePath = path__namespace.join(__dirname$1, "../public/__sw__.js");
  }
  if (!fs__namespace.existsSync(swFilePath)) {
    throw new Error("Service worker file not found. Make sure almostnode is built.");
  }
  return fs__namespace.readFileSync(swFilePath, "utf-8");
}
function getServiceWorkerPath() {
  let swFilePath = path__namespace.join(__dirname$1, "__sw__.js");
  if (!fs__namespace.existsSync(swFilePath)) {
    swFilePath = path__namespace.join(__dirname$1, "../dist/__sw__.js");
  }
  if (!fs__namespace.existsSync(swFilePath)) {
    swFilePath = path__namespace.join(__dirname$1, "../public/__sw__.js");
  }
  if (!fs__namespace.existsSync(swFilePath)) {
    throw new Error("Service worker file not found. Make sure almostnode is built.");
  }
  return swFilePath;
}
const nextPlugin = { getServiceWorkerContent, getServiceWorkerPath };
exports.default = nextPlugin;
exports.getServiceWorkerContent = getServiceWorkerContent;
exports.getServiceWorkerPath = getServiceWorkerPath;
//# sourceMappingURL=next-plugin.cjs.map
