// 假设 FocusHandledResult 枚举定义如下
enum FocusHandledResult {
    System,
    Self,
    Forward
}

// 假设 Button 类型定义如下
class Button {
    // 这里简单模拟按钮的点击事件触发方法
    click() {
        console.log('Button clicked');
    }
}

// 假设 FocusManager 类定义如下
class FocusManager {
    static SetFocusHandled(btn: Button, handler: (sender: Button, e: any) => FocusHandledResult) {
        // 这里简单模拟设置焦点处理方法
        console.log('Focus handled method set');
    }
}

class ButtonHelper {
    static ButtonFocusHandled = (sender: Button, e: any): FocusHandledResult => {
        if (!sender) return FocusHandledResult.System;

        if (e.key === 'Enter' || e.key === ' ') {
            return FocusHandledResult.Self;
        }

        return FocusHandledResult.System;
    };

    static ButtonAutoMoveFocusHandled = (sender: Button, e: any): FocusHandledResult => {
        if (!sender) return FocusHandledResult.System;

        if (e.key === 'Enter') {
            sender.click();
            return FocusHandledResult.Forward;
        }

        return FocusHandledResult.System;
    };

    static setIsAutoMoveFocus(btn: Button, value: boolean) {
        if (!btn) {
            throw new Error('只能给Button控件设置此属性');
        }

        if (value) {
            FocusManager.SetFocusHandled(btn, ButtonHelper.ButtonAutoMoveFocusHandled);
        } else {
            FocusManager.SetFocusHandled(btn, ButtonHelper.ButtonFocusHandled);
        }
    }
}

export { ButtonHelper, FocusHandledResult };