const BRAND_DOMAINS = /* @__PURE__ */ new Set([
  // "Next" clothing brand (Q2 false-match next.js queries)
  "next.co.uk",
  "www.next.co.uk",
  "next.us",
  "www.next.us",
  "next.de",
  "www.next.de",
  "next.ie",
  "www.next.ie",
  "next.com",
  // Big-box retailers
  "amazon.com",
  "www.amazon.com",
  "amazon.co.uk",
  "www.amazon.co.uk",
  "walmart.com",
  "www.walmart.com",
  "target.com",
  "www.target.com",
  "bestbuy.com",
  "www.bestbuy.com",
  "costco.com",
  "kohls.com",
  "macys.com",
  "nordstrom.com",
  "jcpenney.com",
  // General marketplaces
  "ebay.com",
  "www.ebay.com",
  "etsy.com",
  "www.etsy.com",
  "aliexpress.com",
  "wayfair.com",
  // Generic-name brands seen in bench captures
  "stars.com",
  "lists.app"
]);
const COMMERCIAL_TLD_RE = /\.(?:shop|store|deals|sale|boutique|fashion|wedding|beauty|salon)$/i;
const DB_LIBRARY_TERMS = /* @__PURE__ */ new Set([
  "pgvector",
  "hnsw",
  "postgres",
  "postgresql",
  "redis",
  "mongodb",
  "mongo",
  "mysql",
  "mariadb",
  "sqlite",
  "cockroachdb",
  "cockroach",
  "tigerdata",
  "timescale",
  "elasticsearch",
  "opensearch",
  "clickhouse",
  "duckdb",
  "neon",
  "crunchydata",
  "supabase",
  "planetscale",
  "cassandra",
  "dynamodb",
  "kafka",
  "rabbitmq",
  "qdrant",
  "weaviate",
  "pinecone",
  "milvus",
  "chroma",
  "vespa"
]);
const MDN_HTML_ELEMENT_PATH_RE = /\/web\/html\/element\//i;
const BRAND_PENALTY = 0.2;
const MDN_ELEMENT_DRIFT_PENALTY = 0.1;
function urlParts(url) {
  try {
    const u = new URL(url);
    return { host: u.hostname.toLowerCase(), path: u.pathname };
  } catch {
    return null;
  }
}
function isBrandHost(host) {
  if (BRAND_DOMAINS.has(host)) return true;
  if (COMMERCIAL_TLD_RE.test(host)) return true;
  return false;
}
function tokenize(s) {
  return s.toLowerCase().replace(/[^a-z0-9]+/g, " ").split(/\s+/).filter(Boolean);
}
function queryMentionsDbTerm(query) {
  const tokens = tokenize(query);
  for (const t of tokens) {
    if (DB_LIBRARY_TERMS.has(t)) return true;
  }
  return false;
}
function domainQualityScore(url, vertical, query) {
  const parts = urlParts(url);
  if (!parts) return 1;
  const { host, path } = parts;
  if (host === "developer.mozilla.org" && vertical === "code" && MDN_HTML_ELEMENT_PATH_RE.test(path) && queryMentionsDbTerm(query)) {
    return MDN_ELEMENT_DRIFT_PENALTY;
  }
  if (isBrandHost(host)) {
    return BRAND_PENALTY;
  }
  return 1;
}
export {
  domainQualityScore
};
//# sourceMappingURL=domain-quality.js.map