"""
This file is generated by generator/run.py based on the Chrome DevTools Protocol.


https://chromedevtools.github.io/devtools-protocol/tot/Preload/

***************************************************
                    Events
***************************************************
"""
from __future__ import annotations

from cdpkit.protocol._types import (
    Network,
    Page,
    Preload,
)
from cdpkit.protocol.base import CDPEvent


class RuleSetUpdated(CDPEvent):
    """ Upsert. Currently, it is only emitted when a rule set added. """

    ruleSet: Preload.RuleSet


class RuleSetRemoved(CDPEvent):

    id: Preload.RuleSetId


class PreloadEnabledStateUpdated(CDPEvent):
    """ Fired when a preload enabled state is updated. """

    disabledByPreference: bool
    disabledByDataSaver: bool
    disabledByBatterySaver: bool
    disabledByHoldbackPrefetchSpeculationRules: bool
    disabledByHoldbackPrerenderSpeculationRules: bool


class PrefetchStatusUpdated(CDPEvent):
    """ Fired when a prefetch attempt is updated. """

    key: Preload.PreloadingAttemptKey
    pipelineId: Preload.PreloadPipelineId
    initiatingFrameId: Page.FrameId
    prefetchUrl: str
    status: Preload.PreloadingStatus
    prefetchStatus: Preload.PrefetchStatus
    requestId: Network.RequestId


class PrerenderStatusUpdated(CDPEvent):
    """ Fired when a prerender attempt is updated. """

    key: Preload.PreloadingAttemptKey
    pipelineId: Preload.PreloadPipelineId
    status: Preload.PreloadingStatus
    prerenderStatus: Preload.PrerenderFinalStatus | None = None
    disallowedMojoInterface: str | None = None
    mismatchedHeaders: list[Preload.PrerenderMismatchedHeaders] | None = None


class PreloadingAttemptSourcesUpdated(CDPEvent):
    """ Send a list of sources for all preloading attempts in a document. """

    loaderId: Network.LoaderId
    preloadingAttemptSources: list[Preload.PreloadingAttemptSource]
