const BASE_URL = 'https://banatie.app';

const ORGANIZATION = {
  '@type': 'Organization' as const,
  name: 'Banatie',
  url: BASE_URL,
};

export type BreadcrumbItem = {
  name: string;
  path: string;
};

export const createBreadcrumbSchema = (items: BreadcrumbItem[]) => ({
  '@context': 'https://schema.org',
  '@type': 'BreadcrumbList',
  itemListElement: items.map((item, index) => ({
    '@type': 'ListItem',
    position: index + 1,
    name: item.name,
    item: `${BASE_URL}${item.path}`,
  })),
});

export const createTechArticleSchema = (page: { title: string; description: string; path: string }) => ({
  '@context': 'https://schema.org',
  '@type': 'TechArticle',
  headline: page.title,
  description: page.description,
  author: ORGANIZATION,
  publisher: {
    ...ORGANIZATION,
    logo: { '@type': 'ImageObject', url: `${BASE_URL}/logo-square.png` },
  },
  mainEntityOfPage: { '@type': 'WebPage', '@id': `${BASE_URL}${page.path}` },
  image: `${BASE_URL}/og-image.png`,
});

export const HOW_TO_SCHEMA = {
  '@context': 'https://schema.org',
  '@type': 'HowTo',
  name: 'How to Generate Your First AI Image with Banatie API',
  description: 'Generate your first AI image in a few simple steps using Banatie REST API.',
  step: [
    {
      '@type': 'HowToStep',
      name: 'Get API Key',
      text: 'Sign up at banatie.app to receive your API key within 24 hours.',
    },
    {
      '@type': 'HowToStep',
      name: 'Make API Request',
      text: 'Send a POST request to /api/v1/generations with your prompt.',
    },
    {
      '@type': 'HowToStep',
      name: 'Use Your Image',
      text: 'The response contains a CDN URL ready for production use.',
    },
  ],
};

export const API_REFERENCE_SCHEMA = {
  '@context': 'https://schema.org',
  '@type': 'TechArticle',
  headline: 'Banatie API Reference',
  description: 'Complete REST API documentation',
  about: {
    '@type': 'WebAPI',
    name: 'Banatie Image Generation API',
    documentation: `${BASE_URL}/docs/api/`,
    provider: ORGANIZATION,
  },
};
