"""
Constants and default shapes for SignalProcessor.
"""

# Empty return shapes (no data)
EMPTY_ACTIVITY_SIGNALS = {
    "total_events": 0,
    "screen_visits": {},
    "top_searches": [],
    "temporal_distribution": {"hour": {}, "day": {}},
    "filters": {
        "pure_veg_count": 0,
        "offers_count": 0,
        "fast_delivery_count": 0,
        "rating_4plus_count": 0,
    },
    "platform_usage": {},
    "recency": {"recent_activity_ratio_7d": 0},
    "stability": {"activity_volume_low": True},
}

EMPTY_ORDER_SIGNALS = {
    "metrics": {"total_orders": 0, "total_spent": 0, "avg_order_value": 0},
    "loyalty": {"unique_restaurants_count": 0, "top_restaurants": [], "reorder_ratio": 0},
    "inventory": {"top_items": [], "total_items_ordered": 0},
    "financial": {"coupon_order_count": 0, "coupon_ratio": 0},
    "velocity": {"avg_days_between_orders": None, "last_order_days_ago": None},
    "concentration": {"top_restaurant_share": 0, "top_item_share": 0},
    "stability": {"order_volume_low": True},
    "item_pairs": [],
    "category_pairs": [],
    "order_temporal": {"hour": {}, "day": {}},
    "location_order": [],
    "location_time": {"by_hour": [], "by_day": []},
    "location_triplet": [],
    "location_significant": False,
}

EMPTY_IMPRESSION_SIGNALS = {
    "total_impressions": 0,
    "unique_restaurants_seen": 0,
    "screen_exposure": {},
}

EMPTY_SENTIMENT_SIGNALS = {
    "review_count": 0,
    "avg_rating": 0,
    "rating_distribution": {},
    "text_evidence": {
        "positive_keyword_count": 0,
        "negative_keyword_count": 0,
        "total_word_count": 0,
    },
}

# Location significance thresholds
MIN_ORDERS_WITH_LOCATION = 4
MIN_DISTINCT_LOCATIONS = 4
MIN_LOCATION_TIME_PAIRS = 4

# Top-N for aggregations
TOP_SEARCHES_N = 3
TOP_RESTAURANTS_N = 3
TOP_ITEMS_N = 3
TOP_ITEM_PAIRS_N = 10
TOP_CATEGORY_PAIRS_N = 10
TOP_LOCATION_ORDER_N = 10
TOP_LOCATION_TIME_N = 10
TOP_LOCATION_TRIPLET_N = 10

# Volume thresholds
ACTIVITY_VOLUME_LOW_THRESHOLD = 20
ORDER_VOLUME_LOW_THRESHOLD = 5

# Sentiment keyword evidence (lowercase)
POSITIVE_KEYWORDS = frozenset(["good", "great", "excellent", "tasty", "delicious", "fast"])
NEGATIVE_KEYWORDS = frozenset(["bad", "poor", "slow", "cold", "wrong", "missing"])

# Date parse format
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
