export type Section = "private" | "business";

export const COMPANY_NAME = "place4bees";

/** Fixed canonical domain: all pages consolidate their SEO signal here, even
 * though the site also resolves on hhonig.de (see Layout.astro). */
export const PRIMARY_DOMAIN = "https://place4bees.com";

interface SectionConfig {
  label: string;
  tagline: string;
  /** Stable, host-independent path for this section's homepage. Always link
   * here internally (never to bare "/") so switching sections behaves the
   * same regardless of which domain a visitor is on. */
  homeHref: string;
  nav: { label: string; href: string }[];
}

export const sections: Record<Section, SectionConfig> = {
  private: {
    label: "Privatkunden",
    tagline: "Regionaler Honig aus Hamburg",
    homeHref: "/privatkunden",
    nav: [
      { label: "Shop", href: "/shop" },
      { label: "Über uns", href: "/ueber-uns" },
      { label: "Kontakt", href: "/kontakt" },
    ],
  },
  business: {
    label: "Business",
    tagline: "Eigene Bienen vor Ort. Professionell betreut. Nachhaltig erlebbar.",
    homeHref: "/business",
    nav: [
      { label: "Ihr Projekt", href: "/business/ihr-projekt" },
      { label: "Über uns", href: "/business/ueber-uns" },
      { label: "Philosophie", href: "/business/philosophie" },
      { label: "Presse", href: "/business/presse" },
      { label: "Angebot", href: "/business/angebot" },
      { label: "Anfrage", href: "/business/anfrage" },
      { label: "Kontakt", href: "/business/kontakt" },
    ],
  },
};

export function sectionForPath(pathname: string): Section {
  return pathname.startsWith("/business") ? "business" : "private";
}

/** hhonig.de defaults to the private/B2C section, place4bees.com to business. */
export function isBusinessHost(hostname: string): boolean {
  return hostname.includes("place4bees");
}

/** Resolves the active section for a request, accounting for the host-based
 * default that only applies at the bare "/" root. */
export function resolveSection(pathname: string, hostname: string): Section {
  if (pathname.startsWith("/business")) return "business";
  if (pathname === "/" && isBusinessHost(hostname)) return "business";
  return "private";
}
