const VALID_BROWSER_TYPES = /* @__PURE__ */ new Set(["chromium", "firefox", "webkit"]);
const DEFAULT_BROWSER_TYPES = ["chromium"];
function warn(msg, data) {
  const line = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), level: "warn", msg, module: "fetch", data });
  process.stderr.write(line + "\n");
}
function parseBrowserTypes(input) {
  if (!input || typeof input !== "string") {
    return [...DEFAULT_BROWSER_TYPES];
  }
  const trimmed = input.trim();
  if (trimmed.length === 0) {
    return [...DEFAULT_BROWSER_TYPES];
  }
  const parts = trimmed.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
  if (parts.length === 0) {
    return [...DEFAULT_BROWSER_TYPES];
  }
  const seen = /* @__PURE__ */ new Set();
  const valid = [];
  const invalid = [];
  for (const part of parts) {
    if (!VALID_BROWSER_TYPES.has(part)) {
      invalid.push(part);
      continue;
    }
    if (seen.has(part)) {
      continue;
    }
    seen.add(part);
    valid.push(part);
  }
  if (invalid.length > 0) {
    warn("ignored invalid browser types", { invalid, valid: [...valid] });
  }
  if (valid.length === 0) {
    warn("no valid browser types found, falling back to chromium", { input });
    return [...DEFAULT_BROWSER_TYPES];
  }
  return valid;
}
export {
  parseBrowserTypes
};
//# sourceMappingURL=browser-types.js.map