"""Sample package for professional source governance review."""

from copy import deepcopy

from services.market_intel.mcp_fetch_candidate_queue_writer_run_readiness import (
    ARTIFACT_PREFIX,
)


_SAMPLE_PROFESSIONAL_SOURCE_GOVERNANCE_PACKAGE = {
    "operator_source_governance": {
        "governance_id": "market-intel-professional-source-governance-sample",
        "governance_scope": "market_intel_public_campaign_source_governance",
        "policy_version": "source_governance_v1",
        "source_contract_version": "market_source_contract_v1",
        "sources": [
            {
                "platform_code": "momo",
                "source_key": "momo_edm",
                "source_url": "https://www.momoshop.com.tw/edm/cmmedm.jsp",
                "canonical_url": "https://www.momoshop.com.tw/edm/cmmedm.jsp",
                "robots_url": "https://www.momoshop.com.tw/robots.txt",
                "sitemap_url": "https://www.momoshop.com.tw/sitemap.xml",
                "lastmod_source": "sitemap_or_http_last_modified",
                "robots_policy_checked": True,
                "robots_allowed": True,
                "tos_public_page_checked": True,
                "login_required": False,
                "member_or_order_data": False,
                "cart_order_or_pii": False,
                "anti_bot_bypass_required": False,
                "structured_data_preferred": True,
                "json_ld_first": True,
                "dom_selector_fallback_allowed": True,
                "structured_data_types": ["ItemList", "Product", "Offer"],
                "selector_version": "momo_campaign_source_v1",
                "crawl_delay_seconds": 2.5,
                "max_requests_per_run": 12,
                "public_cache_ttl_hours": 24,
                "evidence_artifact_path": (
                    ARTIFACT_PREFIX + "professional-source-governance-momo-edm.json"
                ),
                "provenance_required": True,
                "snapshot_hash_required": True,
                "idempotency_key_strategy": (
                    "platform_code:source_key:canonical_url_hash"
                ),
            },
            {
                "platform_code": "momo",
                "source_key": "momo_flash_sale",
                "source_url": "https://www.momoshop.com.tw/category/DgrpCategory.jsp?d_code=2142500000",
                "canonical_url": "https://www.momoshop.com.tw/category/DgrpCategory.jsp?d_code=2142500000",
                "robots_url": "https://www.momoshop.com.tw/robots.txt",
                "sitemap_url": "https://www.momoshop.com.tw/sitemap.xml",
                "lastmod_source": "sitemap_or_http_last_modified",
                "robots_policy_checked": True,
                "robots_allowed": True,
                "tos_public_page_checked": True,
                "login_required": False,
                "member_or_order_data": False,
                "cart_order_or_pii": False,
                "anti_bot_bypass_required": False,
                "structured_data_preferred": True,
                "json_ld_first": True,
                "dom_selector_fallback_allowed": True,
                "structured_data_types": ["ItemList", "Product", "Offer"],
                "selector_version": "momo_flash_sale_source_v1",
                "crawl_delay_seconds": 2.5,
                "max_requests_per_run": 10,
                "public_cache_ttl_hours": 12,
                "evidence_artifact_path": (
                    ARTIFACT_PREFIX
                    + "professional-source-governance-momo-flash-sale.json"
                ),
                "provenance_required": True,
                "snapshot_hash_required": True,
                "idempotency_key_strategy": (
                    "platform_code:source_key:canonical_url_hash"
                ),
            },
            {
                "platform_code": "pchome",
                "source_key": "pchome_home",
                "source_url": "https://24h.pchome.com.tw/",
                "canonical_url": "https://24h.pchome.com.tw/",
                "robots_url": "https://24h.pchome.com.tw/robots.txt",
                "sitemap_url": "https://24h.pchome.com.tw/sitemap.xml",
                "lastmod_source": "sitemap_or_http_last_modified",
                "robots_policy_checked": True,
                "robots_allowed": True,
                "tos_public_page_checked": True,
                "login_required": False,
                "member_or_order_data": False,
                "cart_order_or_pii": False,
                "anti_bot_bypass_required": False,
                "structured_data_preferred": True,
                "json_ld_first": True,
                "dom_selector_fallback_allowed": True,
                "structured_data_types": ["ItemList", "Product", "Offer"],
                "selector_version": "pchome_campaign_source_v1",
                "crawl_delay_seconds": 2.0,
                "max_requests_per_run": 10,
                "public_cache_ttl_hours": 24,
                "evidence_artifact_path": (
                    ARTIFACT_PREFIX + "professional-source-governance-pchome-home.json"
                ),
                "provenance_required": True,
                "snapshot_hash_required": True,
                "idempotency_key_strategy": (
                    "platform_code:source_key:canonical_url_hash"
                ),
            },
            {
                "platform_code": "pchome",
                "source_key": "pchome_region_beauty",
                "source_url": "https://24h.pchome.com.tw/region/DA",
                "canonical_url": "https://24h.pchome.com.tw/region/DA",
                "robots_url": "https://24h.pchome.com.tw/robots.txt",
                "sitemap_url": "https://24h.pchome.com.tw/sitemap.xml",
                "lastmod_source": "sitemap_or_http_last_modified",
                "robots_policy_checked": True,
                "robots_allowed": True,
                "tos_public_page_checked": True,
                "login_required": False,
                "member_or_order_data": False,
                "cart_order_or_pii": False,
                "anti_bot_bypass_required": False,
                "structured_data_preferred": True,
                "json_ld_first": True,
                "dom_selector_fallback_allowed": True,
                "structured_data_types": ["ItemList", "Product", "Offer"],
                "selector_version": "pchome_region_beauty_source_v1",
                "crawl_delay_seconds": 2.0,
                "max_requests_per_run": 8,
                "public_cache_ttl_hours": 24,
                "evidence_artifact_path": (
                    ARTIFACT_PREFIX
                    + "professional-source-governance-pchome-region-beauty.json"
                ),
                "provenance_required": True,
                "snapshot_hash_required": True,
                "idempotency_key_strategy": (
                    "platform_code:source_key:canonical_url_hash"
                ),
            },
            {
                "platform_code": "coupang",
                "source_key": "coupang_home",
                "source_url": "https://www.tw.coupang.com/",
                "canonical_url": "https://www.tw.coupang.com/",
                "robots_url": "https://www.tw.coupang.com/robots.txt",
                "sitemap_url": "https://www.tw.coupang.com/sitemap.xml",
                "lastmod_source": "sitemap_or_http_last_modified",
                "robots_policy_checked": True,
                "robots_allowed": True,
                "tos_public_page_checked": True,
                "login_required": False,
                "member_or_order_data": False,
                "cart_order_or_pii": False,
                "anti_bot_bypass_required": False,
                "structured_data_preferred": True,
                "json_ld_first": True,
                "dom_selector_fallback_allowed": True,
                "structured_data_types": ["ItemList", "Product", "Offer"],
                "selector_version": "coupang_tw_campaign_source_v1",
                "crawl_delay_seconds": 3.0,
                "max_requests_per_run": 8,
                "public_cache_ttl_hours": 24,
                "evidence_artifact_path": (
                    ARTIFACT_PREFIX
                    + "professional-source-governance-coupang-home.json"
                ),
                "provenance_required": True,
                "snapshot_hash_required": True,
                "idempotency_key_strategy": (
                    "platform_code:source_key:canonical_url_hash"
                ),
            },
            {
                "platform_code": "coupang",
                "source_key": "coupang_global",
                "source_url": "https://www.tw.coupang.com/categories/beauty",
                "canonical_url": "https://www.tw.coupang.com/categories/beauty",
                "robots_url": "https://www.tw.coupang.com/robots.txt",
                "sitemap_url": "https://www.tw.coupang.com/sitemap.xml",
                "lastmod_source": "sitemap_or_http_last_modified",
                "robots_policy_checked": True,
                "robots_allowed": True,
                "tos_public_page_checked": True,
                "login_required": False,
                "member_or_order_data": False,
                "cart_order_or_pii": False,
                "anti_bot_bypass_required": False,
                "structured_data_preferred": True,
                "json_ld_first": True,
                "dom_selector_fallback_allowed": True,
                "structured_data_types": ["ItemList", "Product", "Offer"],
                "selector_version": "coupang_global_source_v1",
                "crawl_delay_seconds": 3.0,
                "max_requests_per_run": 6,
                "public_cache_ttl_hours": 24,
                "evidence_artifact_path": (
                    ARTIFACT_PREFIX
                    + "professional-source-governance-coupang-global.json"
                ),
                "provenance_required": True,
                "snapshot_hash_required": True,
                "idempotency_key_strategy": (
                    "platform_code:source_key:canonical_url_hash"
                ),
            },
            {
                "platform_code": "shopee",
                "source_key": "shopee_home",
                "source_url": "https://shopee.tw/",
                "canonical_url": "https://shopee.tw/",
                "robots_url": "https://shopee.tw/robots.txt",
                "sitemap_url": "https://shopee.tw/sitemap.xml",
                "lastmod_source": "sitemap_or_http_last_modified",
                "robots_policy_checked": True,
                "robots_allowed": True,
                "tos_public_page_checked": True,
                "login_required": False,
                "member_or_order_data": False,
                "cart_order_or_pii": False,
                "anti_bot_bypass_required": False,
                "structured_data_preferred": True,
                "json_ld_first": True,
                "dom_selector_fallback_allowed": True,
                "structured_data_types": ["ItemList", "Product", "Offer"],
                "selector_version": "shopee_home_source_v1",
                "crawl_delay_seconds": 3.0,
                "max_requests_per_run": 6,
                "public_cache_ttl_hours": 24,
                "evidence_artifact_path": (
                    ARTIFACT_PREFIX
                    + "professional-source-governance-shopee-home.json"
                ),
                "provenance_required": True,
                "snapshot_hash_required": True,
                "idempotency_key_strategy": (
                    "platform_code:source_key:canonical_url_hash"
                ),
            },
            {
                "platform_code": "shopee",
                "source_key": "shopee_mall",
                "source_url": "https://shopee.tw/mall",
                "canonical_url": "https://shopee.tw/mall",
                "robots_url": "https://shopee.tw/robots.txt",
                "sitemap_url": "https://shopee.tw/sitemap.xml",
                "lastmod_source": "sitemap_or_http_last_modified",
                "robots_policy_checked": True,
                "robots_allowed": True,
                "tos_public_page_checked": True,
                "login_required": False,
                "member_or_order_data": False,
                "cart_order_or_pii": False,
                "anti_bot_bypass_required": False,
                "structured_data_preferred": True,
                "json_ld_first": True,
                "dom_selector_fallback_allowed": True,
                "structured_data_types": ["ItemList", "Product", "Offer"],
                "selector_version": "shopee_mall_campaign_source_v1",
                "crawl_delay_seconds": 3.0,
                "max_requests_per_run": 6,
                "public_cache_ttl_hours": 24,
                "evidence_artifact_path": (
                    ARTIFACT_PREFIX
                    + "professional-source-governance-shopee-mall.json"
                ),
                "provenance_required": True,
                "snapshot_hash_required": True,
                "idempotency_key_strategy": (
                    "platform_code:source_key:canonical_url_hash"
                ),
            },
        ],
        "operator_confirmations": {
            "human_reviewed_source_policy": True,
            "robots_and_tos_checked_by_operator": True,
            "public_pages_only": True,
            "no_login_or_member_data": True,
            "no_cart_order_or_pii": True,
            "no_antibot_bypass": True,
            "structured_data_first": True,
            "provenance_required": True,
            "no_api_network_fetch": True,
            "no_database_write": True,
            "no_scheduler_attach": True,
            "no_secret_payload": True,
        },
        "api_uses_external_network": False,
        "api_fetches_robots_txt": False,
        "api_fetches_sitemap": False,
        "api_fetches_source_url": False,
        "api_opens_database_connection": False,
        "api_writes_database": False,
        "api_writes_file": False,
        "scheduler_attached": False,
    }
}


def build_sample_professional_source_governance_package():
    return deepcopy(_SAMPLE_PROFESSIONAL_SOURCE_GOVERNANCE_PACKAGE)
