import { dir } from "i18next"; import { Inter } from "next/font/google"; import localFont from "next/font/local"; import { headers, cookies } from "next/headers"; import React from "react"; import { getLocale } from "@calcom/features/auth/lib/getLocale"; import { IconSprites } from "@calcom/ui/components/icon"; import { NotificationSoundHandler } from "@calcom/web/components/notification-sound-handler"; import "../styles/globals.css"; import { SpeculationRules } from "./SpeculationRules"; import { Providers } from "./providers"; const interFont = Inter({ subsets: ["latin"], variable: "--font-inter", preload: true, display: "swap" }); const calFont = localFont({ src: "../fonts/CalSans-SemiBold.woff2", variable: "--font-cal", preload: true, display: "block", weight: "600", }); export const viewport = { width: "device-width", initialScale: 1.0, maximumScale: 1.0, userScalable: false, viewportFit: "cover", themeColor: [ { media: "(prefers-color-scheme: light)", color: "#f9fafb", }, { media: "(prefers-color-scheme: dark)", color: "#1C1C1C", }, ], }; export const metadata = { icons: { icon: "/favicon.ico", apple: "/api/logo?type=apple-touch-icon", other: [ { rel: "icon-mask", url: "/safari-pinned-tab.svg", color: "#000000", }, { url: "/api/logo?type=favicon-16", sizes: "16x16", type: "image/png", }, { url: "/api/logo?type=favicon-32", sizes: "32x32", type: "image/png", }, ], }, manifest: "/site.webmanifest", other: { "application-TileColor": "#ff0000", }, twitter: { site: "@calcom", creator: "@calcom", card: "summary_large_image", }, robots: { index: true, follow: true, }, }; const getInitialProps = async (url: string) => { const { pathname, searchParams } = new URL(url); const isEmbed = pathname.endsWith("/embed") || (searchParams?.get("embedType") ?? null) !== null; const embedColorScheme = searchParams?.get("ui.color-scheme"); const req = { headers: await headers(), cookies: await cookies() }; const newLocale = await getLocale(req); const direction = dir(newLocale); return { isEmbed, embedColorScheme, locale: newLocale, direction }; }; const getFallbackProps = () => ({ locale: "en", direction: "ltr", isEmbed: false, embedColorScheme: false, }); export default async function RootLayout({ children }: { children: React.ReactNode }) { const h = await headers(); const fullUrl = h.get("x-url") ?? ""; const nonce = h.get("x-csp") ?? ""; const isSSG = !fullUrl; const { locale, direction, isEmbed, embedColorScheme } = isSSG ? getFallbackProps() : await getInitialProps(fullUrl); return (