export type SpecType =
  | 'tokens'
  | 'recipes'
  | 'patterns'
  | 'conditions'
  | 'keyframes'
  | 'semantic-tokens'
  | 'mixins'
  | 'color-palette'
  | 'themes'

interface Examples {
  functionExamples: string[]
}

export interface TokenValue {
  name: string
  value: any
  description?: string
  deprecated?: boolean | string
  cssVar?: string
}

export interface TokenGroupDefinition extends Examples {
  type: string
  values: TokenValue[]
  tokenFunctionExamples: string[]
}

export interface TokenSpec {
  type: 'tokens'
  data: TokenGroupDefinition[]
}

export interface SemanticTokenValue {
  name: string
  values: Array<{ value: string; condition?: string }>
  description?: string
  deprecated?: boolean | string
  cssVar?: string
}

export interface SemanticTokenGroupDefinition extends Examples {
  type: string
  values: SemanticTokenValue[]
  tokenFunctionExamples: string[]
}

export interface SemanticTokenSpec {
  type: 'semantic-tokens'
  data: SemanticTokenGroupDefinition[]
}

export interface RecipeSpecDefinition extends Examples {
  name: string
  description?: string
  variants: Record<string, string[]>
  defaultVariants: Record<string, any>
}

export interface RecipeSpec {
  type: 'recipes'
  data: RecipeSpecDefinition[]
}

export interface PatternSpecProperty {
  name: string
  type: string
  description?: string
  required?: boolean
  defaultValue?: any
}

export interface PatternSpecDefinition extends Examples {
  name: string
  description?: string
  properties: PatternSpecProperty[]
}

export interface PatternSpec {
  type: 'patterns'
  data: PatternSpecDefinition[]
}

export interface ConditionSpecDefinition extends Examples {
  name: string
  value: string
}

export interface ConditionSpec {
  type: 'conditions'
  data: ConditionSpecDefinition[]
}

export interface KeyframeSpecDefinition extends Examples {
  name: string
}

export interface KeyframeSpec {
  type: 'keyframes'
  data: KeyframeSpecDefinition[]
}

export interface MixinSpecDefinition extends Examples {
  name: string
  description?: string
}

export interface MixinSpec {
  type: 'mixins'
  data: MixinSpecDefinition[]
}

export interface ColorPaletteSpec {
  type: 'color-palette'
  data: {
    values: string[]
    functionExamples: string[]
  }
}

export interface ThemeTokenValue {
  name: string
  values: Array<{ value: string; condition?: string }>
  description?: string
  deprecated?: boolean | string
  cssVar?: string
}

export interface ThemeTokenGroupDefinition extends Examples {
  type: string
  values: ThemeTokenValue[]
  tokenFunctionExamples: string[]
}

export interface ThemeSpecDefinition {
  name: string
  tokens: ThemeTokenGroupDefinition[]
  semanticTokens: ThemeTokenGroupDefinition[]
}

export interface ThemesSpec {
  type: 'themes'
  data: ThemeSpecDefinition[]
}

export type SpecFile =
  | TokenSpec
  | SemanticTokenSpec
  | RecipeSpec
  | PatternSpec
  | ConditionSpec
  | KeyframeSpec
  | MixinSpec
  | ColorPaletteSpec
  | ThemesSpec

export interface SpecTypeMap {
  tokens: TokenSpec
  'semantic-tokens': SemanticTokenSpec
  recipes: RecipeSpec
  patterns: PatternSpec
  conditions: ConditionSpec
  keyframes: KeyframeSpec
  mixins: MixinSpec
  'color-palette': ColorPaletteSpec
  themes: ThemesSpec
}
