import { BootstrapConfig } from './bootstrap-config.model';
import { DEFAULT_HEADER_CONFIG } from './header-config.model';
import { DEFAULT_MARKETPLACE_FEATURES_CONFIG } from './features-config.model';
import { DEFAULT_PLATFORM_MODULES_CONFIG } from './platform-modules.model';

/**
 * Whole-object fallback rendered whenever the backend reports
 * `published: false` for the resolved marketplace (no published revision
 * yet). Every feature flag is on so it doubles as a full-surface product
 * demo. See docs/superpowers/specs/2026-08-22-frontend-default-bootstrap-design.md.
 */
export const DEFAULT_BOOTSTRAP: BootstrapConfig = {
  schemaVersion: '1.0.0',
  generatedAt: new Date(0).toISOString(),
  published: false,

  tenant: {
    id: 'tenant-default-unpublished',
    slug: 'default',
    code: 'DEFAULT',
    host: 'default.local',
    name: 'Marketplace',
    websiteBaseUrl: 'https://marketplace.local',
    builderBaseUrl: 'https://builder.marketplace.local',
    backofficeBaseUrl: 'https://backoffice.marketplace.local',
    defaultLocale: 'en',
    supportedLocales: ['en'],
    defaultCurrency: 'USD',
    supportedCurrencies: ['USD'],
    timezone: 'UTC',
  },

  branding: {
    brandName: 'Marketplace',
    legalName: 'Marketplace',
    slogan: 'Your store, coming soon',
    logoUrl: '/icons/icon-192x192.png',
    logoCompactUrl: '/icons/icon-192x192.png',
    faviconUrl: '/favicon.ico',
    appIconUrl: '/icons/icon-192x192.png',
    supportEmail: 'support@marketplace.local',
  },

  theme: {
    themeId: 'default-light',
    mode: 'light',
    palette: {
      primary: '#497671',
      secondary: '#a1b4b5',
      accent: '#a7ceca',
      success: '#10b981',
      warning: '#f59e0b',
      danger: '#ef4444',
      info: '#3b82f6',
      textPrimary: '#1e3c38',
      textSecondary: '#667a77',
      backgroundPrimary: '#ffffff',
      backgroundSecondary: '#f5f5f5',
      border: '#d3dad9',
    },
    typography: {
      primaryFontFamily: 'DM Sans, sans-serif',
      headingFontFamily: 'DM Sans, sans-serif',
      baseFontSize: 16,
    },
    spacing: { unit: 4, scale: [0, 4, 8, 12, 16, 24, 32, 48] },
    borderRadiusScale: { sm: '8px', md: '12px', lg: '16px', xl: '22px' },
    shadows: {
      sm: '0 2px 8px rgba(0,0,0,0.1)',
      md: '0 4px 12px rgba(0,0,0,0.15)',
      lg: '0 12px 32px rgba(73,118,113,0.2)',
    },
    iconSet: 'default',
  },

  company: {
    companyName: 'Marketplace',
    address: { country: '', city: '' },
    contacts: { email: 'support@marketplace.local' },
  },

  featureFlags: {
    wishlist: true,
    compare: true,
    reviews: true,
    questions: true,
    comments: true,
    recommendations: true,
    blog: true,
    chat: true,
    analytics: true,
    notifications: true,
    coupons: true,
    loyalty: true,
    giftCards: true,
    invoices: true,
  },
  features: DEFAULT_MARKETPLACE_FEATURES_CONFIG,

  apiEndpoints: {
    bootstrap: { path: '/bootstrap', method: 'GET', timeoutMs: 10000 },
    website: {},
    builder: {},
    backoffice: {},
  },

  localization: {
    defaultLocale: 'en',
    supportedLocales: ['en'],
    currencyByLocale: { en: 'USD' },
    dictionaries: [{ locale: 'en', dictionaryUrl: '/assets/i18n/en.json', version: '1.0.0' }],
  },

  seo: {
    default: { title: 'Marketplace', description: 'Your store, coming soon', robots: 'noindex,nofollow' },
    byPageKey: {
      home: { title: 'Marketplace - Home', description: 'Your store, coming soon', robots: 'noindex,nofollow' },
    },
  },

  permissions: { definitions: [], roles: [] },

  header: DEFAULT_HEADER_CONFIG,

  navigation: {
    header: [
      { id: 'nav-home', labelKey: 'nav.home', route: '/', icon: 'home', order: 1 },
      { id: 'nav-search', labelKey: 'nav.search', route: '/search', icon: 'search', order: 2 },
      { id: 'nav-cart', labelKey: 'nav.cart', route: '/cart', icon: 'cart', order: 3 },
    ],
    footer: [
      { id: 'footer-about', labelKey: 'nav.about', route: '/about-us', order: 1 },
      { id: 'footer-contacts', labelKey: 'nav.contacts', route: '/contacts', order: 2 },
    ],
  },

  footer: {
    paymentIcons: [],
    copyrightText: { en: '© 2026 Marketplace. All rights reserved.' },
    legalPageKeys: ['about-us', 'privacy-policy', 'terms-of-service'],
  },

  staticPages: {
    'about-us': {
      id: 'about-us',
      slug: 'about-us',
      route: '/about-us',
      title: { en: 'About Us' },
      html: { en: '<h2>About Us</h2><p>This marketplace has not published its storefront yet.</p>' },
    },
    'privacy-policy': {
      id: 'privacy-policy',
      slug: 'privacy-policy',
      route: '/privacy-policy',
      title: { en: 'Privacy Policy' },
      html: { en: '<h2>Privacy Policy</h2><p>Placeholder content until publish.</p>' },
    },
    'terms-of-service': {
      id: 'terms-of-service',
      slug: 'terms-of-service',
      route: '/terms-of-service',
      title: { en: 'Terms of Service' },
      html: { en: '<h2>Terms of Service</h2><p>Placeholder content until publish.</p>' },
    },
  },

  pages: [
    {
      id: 'page-home',
      key: 'home',
      title: 'Home',
      route: { path: '/', exact: true },
      layout: { type: 'default' },
      seoKey: 'home',
      visible: true,
      sections: [
        {
          id: 'section-hero',
          type: 'hero',
          order: 1,
          layout: { strategy: 'hero', columns: 1, gap: '1.5rem', align: 'stretch' },
          visibility: { desktop: true, tablet: true, mobile: true },
          visible: true,
          widgets: [
            {
              id: 'widget-hero-main',
              type: 'hero',
              version: '1.0.0',
              order: 1,
              padding: '0.5rem 0',
              visibility: { desktop: true, tablet: true, mobile: true },
              visible: true,
              props: {
                title: { en: 'Welcome to Marketplace' },
                subtitle: { en: 'This storefront has not been published yet' },
                ctaLabel: { en: 'Learn more' },
              },
            },
          ],
        },
        {
          id: 'section-categories',
          type: 'categories',
          order: 2,
          layout: { strategy: 'grid', columns: 1, gap: '1.5rem', align: 'stretch' },
          visibility: { desktop: true, tablet: true, mobile: true },
          visible: true,
          widgets: [
            {
              id: 'widget-categories-root',
              type: 'categories',
              version: '1.0.0',
              order: 1,
              padding: '0.25rem 0',
              visibility: { desktop: true, tablet: true, mobile: true },
              visible: true,
              props: { title: 'Categories', source: 'root', emptyMessage: 'No categories available' },
            },
          ],
        },
      ],
    },
  ],

  modules: DEFAULT_PLATFORM_MODULES_CONFIG,
};
