"""Shopee 市場活動 read-only adapter skeleton。"""

from services.market_intel.adapters.base import (
    AdapterSafetyPolicy,
    CampaignSource,
    MarketIntelAdapter,
)


class ShopeeMarketAdapter(MarketIntelAdapter):
    platform_code = "shopee"
    platform_name = "Shopee 蝦皮購物"
    base_url = "https://shopee.tw"
    campaign_url_keywords = (
        "shopee.tw",
        "/mall",
        "campaign",
        "event",
        "flash_sale",
        "promotion",
        "sale",
    )
    campaign_text_keywords = (
        "shopee",
        "蝦皮",
        "商城",
        "活動",
        "優惠",
        "折扣",
        "特價",
        "限時",
        "品牌",
        "免運",
    )
    safety_policy = AdapterSafetyPolicy(
        request_interval_sec=4.0,
        timeout_sec=25,
        max_pages_per_run=3,
    )

    def campaign_sources(self):
        return (
            CampaignSource(
                source_key="shopee_home",
                name="Shopee 蝦皮首頁入口",
                url="https://shopee.tw/",
                campaign_type="homepage_campaign",
                notes="只保存公開首頁入口；不得登入、碰會員券、購物車或反爬繞過。",
            ),
            CampaignSource(
                source_key="shopee_mall",
                name="Shopee Mall 商城入口",
                url="https://shopee.tw/mall",
                campaign_type="brand_mall",
                notes="只作為商城/品牌活動 discovery 起點；正式抓取需另開 feature flag。",
            ),
        )
