"""TS-generated CreateActionResult for cross-implementation compatibility testing.

This module provides the CreateActionResult JSON that was generated by TypeScript
implementation, used to verify Python produces identical results.

Reference: go-wallet-toolbox/pkg/internal/testabilities/tsgenerated/create_action_result.go
"""

import json
from pathlib import Path
from typing import Any

# Path to the JSON file (same directory)
_JSON_FILE = Path(__file__).parent / "create_action_result.json"


def load_create_action_result() -> dict[str, Any]:
    """Load the TS-generated CreateActionResult from JSON file.

    Returns:
        dict: The CreateActionResult as a Python dict
    """
    with open(_JSON_FILE) as f:
        return json.load(f)


def create_action_result_json() -> str:
    """Get the CreateActionResult as a JSON string.

    This is equivalent to Go's CreateActionResultJSON() function.

    Returns:
        str: The CreateActionResult as a JSON string
    """
    with open(_JSON_FILE) as f:
        return f.read()


# Lazy-loaded cached result
_CREATE_ACTION_RESULT: dict[str, Any] | None = None


def _get_create_action_result() -> dict[str, Any]:
    """Get cached CreateActionResult (lazy load)."""
    global _CREATE_ACTION_RESULT
    if _CREATE_ACTION_RESULT is None:
        _CREATE_ACTION_RESULT = load_create_action_result()
    return _CREATE_ACTION_RESULT


# Module-level constant (loads on first access via property)
class _CreateActionResultProxy:
    """Proxy to provide module-level constant access."""

    def __getitem__(self, key: str) -> Any:
        return _get_create_action_result()[key]

    def __repr__(self) -> str:
        return repr(_get_create_action_result())

    def __eq__(self, other: Any) -> bool:
        return _get_create_action_result() == other

    def get(self, key: str, default: Any = None) -> Any:
        return _get_create_action_result().get(key, default)

    def keys(self):
        return _get_create_action_result().keys()

    def values(self):
        return _get_create_action_result().values()

    def items(self):
        return _get_create_action_result().items()


CREATE_ACTION_RESULT = _CreateActionResultProxy()
