# Copyright (c) CloudZero - ALL RIGHTS RESERVED - PROPRIETARY AND CONFIDENTIAL
# Unauthorized copying of this file and/or project, via any medium is strictly prohibited.
# Direct all questions to legal@cloudzero.com

from aws_lambda_powertools.event_handler.api_gateway import CORSConfig


class WebCORSConfig(CORSConfig):
    """
    CloudZero Web CORS configuration for API Gateway responses.

    Extends AWS PowerTools CORSConfig with CloudZero-specific default values
    for allowed origins and other CORS settings suitable for CloudZero web applications.
    """

    def __init__(
        self,
        allow_origin: str | None = None,
        extra_origins: list[str] | None = None,
        allow_headers: list[str] | None = None,
        expose_headers: list[str] | None = None,
        max_age: int | None = None,
        allow_credentials: bool = False,
    ):
        """
        Initialize CloudZero Web CORS configuration.

        Args:
            allow_origin: Primary allowed origin. Defaults to 'app.cloudzero.com'.
            extra_origins: Additional allowed origins. Defaults to ['demo.cloudzero.com'].
            allow_headers: List of allowed request headers.
            expose_headers: List of headers to expose to the client.
            max_age: Maximum age for preflight cache in seconds.
            allow_credentials: Whether to allow credentials in CORS requests.
        """
        super().__init__(
            allow_origin if allow_origin is not None else 'app.cloudzero.com',
            extra_origins if extra_origins is not None else ['demo.cloudzero.com'],
            allow_headers,
            expose_headers,
            max_age,
            allow_credentials,
        )
