"""State getters for the verify step from InteractionContext"""

# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/components/helpers.ipynb.

# %% auto #0
__all__ = []

# %% ../../nbs/components/helpers.ipynb #verify-helpers-exports
from typing import Optional

from cjm_fasthtml_interactions.core.context import InteractionContext

from ..models import VerifyStepState

# %% ../../nbs/components/helpers.ipynb #verify-helpers-getters
def _get_verify_state(
    ctx:InteractionContext  # Interaction context with state
) -> VerifyStepState:  # Typed verify step state
    """Get the full verify step state from context."""
    step_states = ctx.state.get("step_states", {})
    return step_states.get("verify", {})

def _get_document_id(
    ctx:InteractionContext  # Interaction context with state
) -> Optional[str]:  # Document UUID or None if not set
    """Get the document ID to verify from context."""
    state = _get_verify_state(ctx)
    return state.get("document_id")

def _get_media_path(
    ctx:InteractionContext  # Interaction context with state
) -> Optional[str]:  # Media path or None if not set
    """Get the media path for display context."""
    state = _get_verify_state(ctx)
    return state.get("media_path")

# %% ../../nbs/components/helpers.ipynb #verify-helpers-cross
def _get_document_id_from_review(
    ctx:InteractionContext  # Interaction context with state
) -> Optional[str]:  # Document UUID or None if not found
    """Get the document ID from review step state (fallback)."""
    step_states = ctx.state.get("step_states", {})
    review_state = step_states.get("review", {})
    return review_state.get("document_id")

def _get_document_id_any(
    ctx:InteractionContext  # Interaction context with state
) -> Optional[str]:  # Document UUID or None if not found anywhere
    """Get document ID from verify state, falling back to review state."""
    doc_id = _get_document_id(ctx)
    if doc_id is None:
        doc_id = _get_document_id_from_review(ctx)
    return doc_id
