"""
Import helper module for Chatterbox UI.

This module provides a function to add the project root to the Python path,
which helps resolve import issues when running scripts from different locations.
"""

import sys
import os
from pathlib import Path

def setup_python_path():
    """
    Add the project root to the Python path.
    This allows imports to work correctly regardless of where the script is run from.
    """
    # Get the project root (parent of the directory containing this file)
    project_root = Path(__file__).resolve().parent
    
    # Add the project root to the Python path if it's not already there
    if str(project_root) not in sys.path:
        sys.path.insert(0, str(project_root))
        print(f"Added {project_root} to Python path")
    
    # Set environment variable for other modules to use
    os.environ["PROJECT_ROOT"] = str(project_root)
    
    return project_root

# Run setup when this module is imported
project_root = setup_python_path()