"""
Text Texture Generator - Operators Module
Contains all Blender operators for text texture generation and management.
"""

from ..utils.constants import is_full_version
from .generation_ops import *

__all__ = []

# Import all operator classes and add to __all__
from .generation_ops import (
    TEXT_TEXTURE_OT_generate,
    TEXT_TEXTURE_OT_preview,
    TEXT_TEXTURE_OT_generate_shader,
    TEXT_TEXTURE_OT_generate_plane,
    TEXT_TEXTURE_OT_reset_settings,
)

# Conditional imports for modules that might not exist in free version
try:
    pass
    from .preset_ops import *
    from .preset_ops import (
        TEXT_TEXTURE_OT_save_preset,
        TEXT_TEXTURE_OT_save_preset_enter,
        TEXT_TEXTURE_OT_clear_preset_search,
        TEXT_TEXTURE_OT_load_preset,
        TEXT_TEXTURE_OT_delete_preset,
        TEXT_TEXTURE_OT_refresh_presets,
        TEXT_TEXTURE_OT_export_presets,
        TEXT_TEXTURE_OT_import_presets,
        TEXT_TEXTURE_OT_show_migration_report,
    )
    PRESET_OPERATORS = [
        'TEXT_TEXTURE_OT_save_preset',
        'TEXT_TEXTURE_OT_save_preset_enter',
        'TEXT_TEXTURE_OT_clear_preset_search',
        'TEXT_TEXTURE_OT_load_preset',
        'TEXT_TEXTURE_OT_delete_preset',
        'TEXT_TEXTURE_OT_refresh_presets',
        'TEXT_TEXTURE_OT_export_presets',
        'TEXT_TEXTURE_OT_import_presets',
        'TEXT_TEXTURE_OT_show_migration_report',
    ]
except ImportError:
    pass
    # preset_ops module not available (free version)
    PRESET_OPERATORS = []

try:
    pass
    from .text_editor_ops import *
    from .text_editor_ops import (
        TEXT_TEXTURE_OT_edit_text,
    )
    TEXT_EDITOR_OPERATORS = [
        'TEXT_TEXTURE_OT_edit_text',
    ]
except ImportError as e:
    import sys
    print(f"WARNING: text_editor_ops import failed in operators/__init__.py: {e}", file=sys.stderr)

    class TEXT_TEXTURE_OT_edit_text:
        """Fallback stub when text editor operator is unavailable."""
        bl_idname = "text_texture.edit_text"
        bl_label = "Edit Text (Unavailable)"
        bl_description = "Text editor feature unavailable in this build"
        bl_options = {'REGISTER'}

        @classmethod
        def poll(cls, context):
            return False

        def execute(self, context):
            raise RuntimeError("Text editor feature is unavailable in this build.")

    TEXT_EDITOR_OPERATORS = ['TEXT_TEXTURE_OT_edit_text']

try:
    pass
    from .utility_ops import *
    from .utility_ops import (
        TEXT_TEXTURE_OT_refresh_preview,
        TEXT_TEXTURE_OT_view_preview_zoom,
        TEXT_TEXTURE_OT_open_panel,
        TEXT_TEXTURE_OT_refresh_fonts,
        TEXT_TEXTURE_OT_add_overlay,
        TEXT_TEXTURE_OT_remove_overlay,
        TEXT_TEXTURE_OT_set_anchor_point,
        TEXT_TEXTURE_OT_sync_margins,
        TEXT_TEXTURE_OT_duplicate_overlay,
        TEXT_TEXTURE_OT_delete_overlay,
        TEXT_TEXTURE_OT_move_overlay,
        TEXT_TEXTURE_OT_recover_data,
    )
    UTILITY_OPERATORS = [
        'TEXT_TEXTURE_OT_refresh_preview',
        'TEXT_TEXTURE_OT_view_preview_zoom',
        'TEXT_TEXTURE_OT_open_panel',
        'TEXT_TEXTURE_OT_refresh_fonts',
        'TEXT_TEXTURE_OT_add_overlay',
        'TEXT_TEXTURE_OT_remove_overlay',
        'TEXT_TEXTURE_OT_set_anchor_point',
        'TEXT_TEXTURE_OT_sync_margins',
        'TEXT_TEXTURE_OT_duplicate_overlay',
        'TEXT_TEXTURE_OT_delete_overlay',
        'TEXT_TEXTURE_OT_move_overlay',
        'TEXT_TEXTURE_OT_recover_data',
    ]
except ImportError:
    pass
    # utility_ops module not available (free version)
    UTILITY_OPERATORS = []

__all__.extend([
    # Generation operators
    'TEXT_TEXTURE_OT_generate',
    'TEXT_TEXTURE_OT_preview',
    'TEXT_TEXTURE_OT_generate_shader',
    'TEXT_TEXTURE_OT_generate_plane',
    'TEXT_TEXTURE_OT_reset_settings',
])

# Add preset operators if available
__all__.extend(PRESET_OPERATORS)

# Add text editor operators if available
__all__.extend(TEXT_EDITOR_OPERATORS)
__all__.extend(UTILITY_OPERATORS)
