export type ProductFlavor = "zimphony" | "mailmali-google-connect";

const rawProductFlavor = (process.env.NEXT_PUBLIC_PRODUCT_FLAVOR || "zimphony").trim().toLowerCase();

export const productFlavor: ProductFlavor = rawProductFlavor === "mailmali-google-connect" ? "mailmali-google-connect" : "zimphony";

export const isMailMaliFlavor = productFlavor === "mailmali-google-connect";

export type AdminFlavorConfig = {
  flavor: ProductFlavor;
  brandName: "Zimphony Webmail" | "Mail Mali";
  deploymentModel: "installable_package" | "hosted_saas";
  adminVariant: "package_admin" | "mail_mali_domain_admin";
  customerFacingProviderNames: boolean;
  customerFacingPackageWords: boolean;
  quotaSource: "package_config" | "bap";
  billingSource: "none" | "bap";
  mailGatewaySource: "none" | "package_gateway" | "mail_mali_protection";
  orderMoreUrlBase?: string;
};

export const adminFlavorConfig: AdminFlavorConfig = isMailMaliFlavor
  ? {
      flavor: "mailmali-google-connect",
      brandName: "Mail Mali",
      deploymentModel: "hosted_saas",
      adminVariant: "mail_mali_domain_admin",
      customerFacingProviderNames: false,
      customerFacingPackageWords: false,
      quotaSource: "bap",
      billingSource: "bap",
      mailGatewaySource: "mail_mali_protection",
    }
  : {
      flavor: "zimphony",
      brandName: "Zimphony Webmail",
      deploymentModel: "installable_package",
      adminVariant: "package_admin",
      customerFacingProviderNames: true,
      customerFacingPackageWords: true,
      quotaSource: "package_config",
      billingSource: "none",
      mailGatewaySource: "package_gateway",
    };
