# Generated by Copilot
# Maintained by Dinesh Kumar C (https://github.com/Dinesh210805/blender-mcp)
# Forked from original work by Siddharth Ahuja (https://github.com/ahujasid/blender-mcp)

"""Response models for Blender MCP."""

from dataclasses import dataclass
from typing import Any, Dict, Optional, Union
import json


@dataclass
class MCPResponse:
    """Standard response format for MCP operations."""
    
    success: bool
    data: Optional[Dict[str, Any]] = None
    message: Optional[str] = None
    error_code: Optional[str] = None
    
    def to_json(self) -> str:
        """Convert response to JSON string."""
        return json.dumps({
            'success': self.success,
            'data': self.data,
            'message': self.message,
            'error_code': self.error_code
        }, indent=2)
    
    @classmethod
    def success_response(cls, data: Optional[Dict[str, Any]] = None, message: Optional[str] = None) -> "MCPResponse":
        """Create a success response."""
        return cls(success=True, data=data, message=message)
    
    @classmethod
    def error_response(cls, message: str, error_code: Optional[str] = None, data: Optional[Dict[str, Any]] = None) -> "MCPResponse":
        """Create an error response."""
        return cls(success=False, message=message, error_code=error_code, data=data)


@dataclass
class BlenderObjectInfo:
    """Information about a Blender object."""
    
    name: str
    type: str
    location: list[float]
    rotation: list[float]
    scale: list[float]
    visible: bool
    materials: list[str]
    world_bounding_box: Optional[Dict[str, list[float]]] = None
    
    def to_dict(self) -> Dict[str, Any]:
        """Convert to dictionary."""
        result = {
            'name': self.name,
            'type': self.type,
            'location': self.location,
            'rotation': self.rotation,
            'scale': self.scale,
            'visible': self.visible,
            'materials': self.materials
        }
        if self.world_bounding_box:
            result['world_bounding_box'] = self.world_bounding_box
        return result


@dataclass
class AssetDownloadResult:
    """Result of asset download operation."""
    
    success: bool
    asset_id: str
    asset_type: str
    message: str
    imported_objects: Optional[list[str]] = None
    material_name: Optional[str] = None
    maps: Optional[list[str]] = None
    error: Optional[str] = None
    
    def to_dict(self) -> Dict[str, Any]:
        """Convert to dictionary."""
        result = {
            'success': self.success,
            'asset_id': self.asset_id,
            'asset_type': self.asset_type,
            'message': self.message
        }
        
        if self.imported_objects:
            result['imported_objects'] = self.imported_objects
        if self.material_name:
            result['material_name'] = self.material_name
        if self.maps:
            result['maps'] = self.maps
        if self.error:
            result['error'] = self.error
            
        return result
