"""
Project:    Shuffle & Skirmish Market Scraper
Author:     Edward Middleton-Smith
            Shuffle & Skirmish

Technology: Business Objects
Feature:    The Game Collection Product Scraper Class
"""

# Internal
from product_scraper import Product_Scraper
# External

class The_Game_Collection_Product_Scraper(Product_Scraper):
    NAME_DOMAIN_THE_GAME_COLLECTION: str = 'The Game Collection'

    def __init__(self):
        super().__init__(domain = self.NAME_DOMAIN_THE_GAME_COLLECTION)

    @classmethod
    def parse_cost(cls, cost_text):
        return super().parse_cost(cost_text = cost_text)
        
    async def scrape_cost_and_active_playwright(self, browser, url):
        page_load_element_selector = '#main-content'
        cost_selector = '#main-content .shopify-section .container .product .product-info .price strong'
        active_selector = '#main-content .shopify-section .container .product .product-info product-form form.js-product-form-main button[type="submit"]'
        cost_text, active = await super().scrape_cost_and_active_playwright(
              browser = browser
            , url = url
            , page_load_element_selector = page_load_element_selector
            , cost_selector = cost_selector
            , active_selector = active_selector
            , invalid_active_statuses = ['Sold out']
        )
        cost = self.parse_cost(cost_text = cost_text)
        return cost, active
