// Shared types for the /pricing.json endpoint payload (`PricingController::showJson`).
// `provider_price_id` is intentionally absent from `PriceRow` — the controller
// strips it from the public payload; only the admin Billing surface needs it.

export type Period = 'monthly' | 'yearly';

export type CurrencyRow = {
    id: number;
    code: string;
    symbol: string;
    name: string;
    is_default: boolean;
};

export type PlanFeatures = {
    can_export?: boolean;
    project_limit?: number | null;
    can_use_premium_kits?: boolean;
    can_use_ai?: boolean;
    /** null = unlimited monthly AI tokens; a number caps the workspace. */
    ai_tokens_monthly?: number | null;
    [key: string]: unknown;
};

export type PlanRow = {
    id: number;
    key: string;
    name: string;
    description: string | null;
    features: PlanFeatures | null;
    project_limit: number | null;
    can_export: boolean;
    /** null = unlimited storage. Surfaced denormalized at the top level
     *  alongside project_limit / can_export for cheap read access in
     *  the bullet renderer. */
    storage_bytes_limit: number | null;
    /** Team seat cap — owner + admins + editors (viewers are free +
     *  unlimited). null = unlimited seats. Optional for callers that build a
     *  PlanRow without it (Admin/Tenants). */
    max_seats?: number | null;
};

export type PriceRow = {
    id: number;
    plan_id: number;
    currency_id: number;
    gateway_key: string;
    period: Period;
    amount_minor: number;
    is_active: boolean;
};

export type ProviderRow = {
    key: string;
    label: string;
};

export type CurrentSubscription = {
    plan_key: string | null;
    provider_key: string;
    period: Period;
    currency_id: number | null;
};

export type PricingPayload = {
    currencies: CurrencyRow[];
    plans: PlanRow[];
    prices: PriceRow[];
    activeProviders: ProviderRow[];
    defaultCurrency: string;
    currentSubscription: CurrentSubscription | null;
};
