import type { WidgetComponent } from "../types/widget";
import { Clock, clockSchema } from "./Clock";
import { CryptoPrice, cryptoPriceSchema } from "./CryptoPrice";
import { Weather, weatherSchema } from "./Weather";
import { StoicQuote, stoicQuoteSchema } from "./StoicQuote";

export const widgetRegistry: Record<string, WidgetComponent> = {
  "crypto-price": {
    schema: cryptoPriceSchema,
    Component: CryptoPrice,
  },
  clock: {
    schema: clockSchema,
    Component: Clock,
  },
  weather: {
    schema: weatherSchema,
    Component: Weather,
  },
  "stoic-quote": {
    schema: stoicQuoteSchema,
    Component: StoicQuote,
  },
};

export function getWidget(type: string): WidgetComponent | undefined {
  return widgetRegistry[type];
}

export function getAvailableWidgets(): string[] {
  return Object.keys(widgetRegistry);
}
