"""
Synthetic dataset provider for legacy xwnode_console tests.
"""

from __future__ import annotations

import random
from typing import Any


def load_all_collections(seed: int = 42) -> dict[str, list[dict[str, Any]]]:
    """
    Build deterministic in-memory collections used by legacy console tests.
    """
    rng = random.Random(seed)

    users = [
        {
            "id": idx + 1,
            "name": f"User {idx + 1}",
            "age": rng.randint(18, 75),
            "country": rng.choice(["US", "DE", "IN", "JP", "BR"]),
        }
        for idx in range(50)
    ]

    categories = ["electronics", "home", "books", "sports", "beauty"]
    products = [
        {
            "id": idx + 1,
            "name": f"Product {idx + 1}",
            "price": round(rng.uniform(5.0, 250.0), 2),
            "category": categories[idx % len(categories)],
        }
        for idx in range(100)
    ]

    orders = [
        {
            "id": idx + 1,
            "user_id": rng.randint(1, 50),
            "product_id": rng.randint(1, 100),
            "quantity": rng.randint(1, 5),
            "status": rng.choice(["created", "paid", "shipped", "delivered"]),
        }
        for idx in range(200)
    ]

    posts = [
        {
            "id": idx + 1,
            "user_id": rng.randint(1, 50),
            "title": f"Post {idx + 1}",
            "likes": rng.randint(0, 1000),
        }
        for idx in range(30)
    ]

    events = [
        {
            "id": idx + 1,
            "type": rng.choice(["click", "view", "purchase", "signup"]),
            "user_id": rng.randint(1, 50),
            "value": round(rng.uniform(0.0, 100.0), 2),
        }
        for idx in range(500)
    ]

    return {
        "users": users,
        "products": products,
        "orders": orders,
        "posts": posts,
        "events": events,
    }

