def compile_unevaluated_page(
    route: str,
    page: UnevaluatedPage,
    state: type[BaseState] | None = None,
    style: ComponentStyle | None = None,
    theme: Component | None = None,
) -> tuple[Component, bool]:
    """Compiles an uncompiled page into a component and adds meta information.

    Args:
        route: The route of the page.
        page: The uncompiled page object.
        state: The state of the app.
        style: The style of the page.
        theme: The theme of the page.

    Returns:
        The compiled component and whether state should be enabled.

    Raises:
        Exception: If an error occurs while evaluating the page.
    """
    try:
        # Generate the component if it is a callable.
        component = into_component(page.component)

        component._add_style_recursive(style or {}, theme)

        enable_state = False
        # Ensure state is enabled if this page uses state.
        if state is None:
            if page.on_load or component._has_stateful_event_triggers():
                enable_state = True
            else:
                for var in component._get_vars(include_children=True):
                    var_data = var._get_all_var_data()
                    if not var_data:
                        continue
                    if not var_data.state:
                        continue
                    enable_state = True
                    break

        from reflex.app import OverlayFragment
        from reflex.utils.format import make_default_page_title

        component = OverlayFragment.create(component)

        meta_args = {
            "title": (
                page.title
                if page.title is not None
                else make_default_page_title(get_config().app_name, route)
            ),
            "image": page.image,
            "meta": page.meta,
        }

        if page.description is not None:
            meta_args["description"] = page.description

        # Add meta information to the component.
        utils.add_meta(
            component,
            **meta_args,
        )

    except Exception as e:
        if sys.version_info >= (3, 11):
            e.add_note(f"Happened while evaluating page {route!r}")
        raise
    else:
        return component, enable_state
Compiles an uncompiled page into a component and adds meta information.

    Args:
        route: The route of the page.
        page: The uncompiled page object.
        state: The state of the app.
        style: The style of the page.
        theme: The theme of the page.

    Returns:
        The compiled component and whether state should be enabled.

    Raises:
        Exception: If an error occurs while evaluating the page.
    
reflex/compiler/compiler.py