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

Technology: Business Objects
Feature:    Chaos Cards Product Scraper Class
"""

# Internal
from product_scraper import Product_Scraper
# External

class Chaos_Cards_Product_Scraper(Product_Scraper):
    NAME_DOMAIN_CHAOS_CARDS: str = 'Chaos Cards'

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

    @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):
        cost_selector = '.price_inc > span:nth-child(2)'
        active_selector = '.product__right > form > ul.prod_det_fields.left.product-section.product-section--stock > li.prod_det_stock > div:nth-child(1) > div:nth-child(2)'
        cost_text, active = await super().scrape_cost_and_active_playwright(
              browser = browser
            , url = url
            , page_load_element_selector = cost_selector
            , cost_selector = cost_selector
            , active_selector = active_selector
            , invalid_active_statuses = ["Out of stock", "Coming soon"]
        )
        cost = self.parse_cost(cost_text = cost_text)
        return cost, active
