"""
自动同步相关配置收集
"""
from .interaction import UserInteraction

class SyncConfigCollector:
    def __init__(self, interaction: UserInteraction):
        self.ia = interaction

    def configure_sync(self, defaults: dict = None) -> dict:
        prefill = defaults or {}
        if prefill is None:
            prefill = {}
        self.ia.colored_print(f"\n🔄 配置自动同步设置...")
        sync_enabled = prefill.get('enabled', False)
        default_choice = "1" if sync_enabled else "2"
        self.ia.colored_print("1. 启用自动同步\n2. 不使用自动同步")
        choice = self.ia.smart_input("选择", default=default_choice)
        if choice != "1":
            return {}
        sync_config = {}
        sync_config['remote_workspace'] = self.ia.smart_input("远程工作目录", default=prefill.get('remote_workspace', '/home/Code') or '/home/Code')
        sync_config['ftp_port'] = self.ia.smart_input("FTP端口", default=str(prefill.get('ftp_port', 8021) or 8021))
        sync_config['ftp_user'] = self.ia.smart_input("FTP用户名", default=prefill.get('ftp_user', 'ftpuser') or 'ftpuser')
        sync_config['ftp_password'] = self.ia.smart_input("FTP密码", default=prefill.get('ftp_password', 'sync_password') or 'sync_password')
        sync_config['local_workspace'] = self.ia.smart_input("本地工作目录 (空表示当前目录)", default=prefill.get('local_workspace', '') or '')
        return sync_config
