import type { Metadata } from "next";
import { headers } from "next/headers";

export async function generateMetadata(): Promise<Metadata> {
  const headersList = await headers();
  const acceptLanguage = headersList.get("accept-language") || "";
  const lang = acceptLanguage.includes("zh") ? "zh" : "en";

  const titles = {
    en: "Texture Atlas Generator - Create Sprite Sheets Online",
    zh: "纹理图集生成器 - 在线创建精灵图",
  };

  const descriptions = {
    en: "Generate texture atlases and sprite sheets for game development. Pack multiple sprites into a single texture atlas with JSON data export. All processing happens locally in your browser.",
    zh: "为游戏开发生成纹理图集和精灵图。将多个精灵打包到单个纹理图集中，支持导出 JSON 数据。所有处理都在您的浏览器本地进行。",
  };

  const keywords = {
    en: [
      "texture atlas",
      "sprite sheet",
      "game development",
      "sprite packer",
      "texture packing",
      "game assets",
      "sprite generator",
      "JSON export",
      "browser-based",
    ],
    zh: [
      "纹理图集",
      "精灵图",
      "游戏开发",
      "精灵打包",
      "纹理打包",
      "游戏资产",
      "精灵生成器",
      "JSON导出",
      "浏览器端",
    ],
  };

  return {
    title: titles[lang],
    description: descriptions[lang],
    keywords: keywords[lang],
    openGraph: {
      title: titles[lang],
      description: descriptions[lang],
      type: "website",
    },
    twitter: {
      title: titles[lang],
      description: descriptions[lang],
      card: "summary_large_image",
    },
  };
}

export default function TextureAtlasLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return children;
}
