import Component from './Component'
import type { GlitchComponentMetadata } from './types'

export default Component

export const metadata: GlitchComponentMetadata = {
  name: 'demographic-wave',
  displayName: 'Demographic Wave',
  version: '1.0.0',
  paramSchema: {
    startYear: {
      type: 'range',
      label: 'Start Year',
      default: 1946,
      min: 1946,
      max: 2028,
      step: 1
    },
    endYear: {
      type: 'range',
      label: 'End Year',
      default: 2038,
      min: 1964,
      max: 2038,
      step: 1
    },
    animationSpeed: {
      type: 'range',
      label: 'Animation Speed',
      default: 1,
      min: 0.25,
      max: 3,
      step: 0.25
    },
    waveScale: {
      type: 'range',
      label: 'Boomer Wave Scale',
      default: 1.15,
      min: 0.2,
      max: 1.8,
      step: 0.05
    },
    startEqualized: {
      type: 'boolean',
      label: 'Start Equalized',
      default: false
    }
  },
  defaultParams: {
    startYear: 1946,
    endYear: 2038,
    animationSpeed: 1,
    waveScale: 1.15,
    startEqualized: false
  }
}

export type {
  GlitchComponentProps,
  GlitchComponentConfig,
  GlitchComponentResult,
  GlitchTheme,
  GlitchHostBridge
} from './types'

if (typeof window !== 'undefined') {
  type GCRegistry = Record<string, { default: typeof Component; metadata: GlitchComponentMetadata }>
  ;(window as unknown as { GlitchComponents: GCRegistry }).GlitchComponents ??= {}
  ;(window as unknown as { GlitchComponents: GCRegistry }).GlitchComponents[metadata.name] = { default: Component, metadata }
}
