import 'package:fis_common/event/event_type.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:flyinsono/managers/interfaces/entities/patient_Info.dart';
import 'package:flyinsono/managers/interfaces/entities/consultation_member.dart';
import 'package:flyinsono/managers/interfaces/entities/live_consultation.dart';
import 'entities/invitee_consulation_info.dart';

abstract class ILiveConsultationManager {
  ///缓存会诊信息
  LiveConsultation? liveConsultation;

  /// 白板数据接收
  final FEventHandler<String> onWhiteboardDataReceive = FEventHandler<String>();

  ///开始会诊通知事件 11
  final FEventHandler<LiveConsultation> onInviteLiveConsultation =
      FEventHandler<LiveConsultation>();

  ///会诊过程中邀请成员的通知(通知被邀请者) 8
  final FEventHandler<LiveConsultation> onInviteeInLiveConsultation =
      FEventHandler<LiveConsultation>();

  ///取消会诊过程中邀请成员的通知(通知被邀请者) 7
  final FEventHandler<LiveConsultation> onCancelInvitingConsultation =
      FEventHandler<LiveConsultation>();

  ///邀请者接受会诊通知事件（通知发起者）12
  final FEventHandler<LiveConsultation> onAcceptConsultation =
      FEventHandler<LiveConsultation>();

  ///邀请者拒绝会诊事件（通知发起者） 13
  final FEventHandler<LiveConsultation> onRejectConsultation =
      FEventHandler<LiveConsultation>();

  ///邀请者取消接听会诊事件（通知发起者） 7
  final FEventHandler<LiveConsultation> onCancelConsultation =
      FEventHandler<LiveConsultation>();

  ///关闭会诊事件（通知所有成员） 16
  final FEventHandler<LiveConsultation> onCloseConsultation =
      FEventHandler<LiveConsultation>();

  ///成员加入会诊事件（通知所有成员）-
  final FEventHandler<LiveConsultation> onAcceptLiveConsultation =
      FEventHandler<LiveConsultation>();

  ///缓存未处理的设备参数通知
  DeviceParametersNotification? cacheDeviceParametersNotification;

  ///成员加入会诊事件（通知所有成员）
  final FEventHandler<LiveConsultation> onJoinConsultation =
      FEventHandler<LiveConsultation>();

  ///成员加入会诊事件（通知所有成员） 被邀请者进入房间通知
  final FEventHandler<LiveConsultation> onJoinInConsultation =
      FEventHandler<LiveConsultation>();

  ///成员离开会诊事件（通知所有成员）19
  final FEventHandler<LiveConsultation> onLeaveConsultation =
      FEventHandler<LiveConsultation>();

  ///某个成员网络不佳通知事件（通知所有成员） 18
  final FEventHandler<LiveConsultation> onNetworkErrConsultation =
      FEventHandler<LiveConsultation>();

  /// 设备探头应用和参数信息通知事件 35
  final FEventHandler<DeviceParametersNotification>
      onDeviceParametersNotification =
      FEventHandler<DeviceParametersNotification>();

  /// 68 取消呼叫 to 客户端
  final FEventHandler<CancelInvitingInLiveCourseNotification>
      onCancelInvitingInLiveCourseNotification =
      FEventHandler<CancelInvitingInLiveCourseNotification>();

  ///会诊提醒通知
  final FEventHandler<InviteeConsulationInfo> onRemindConsultation =
      FEventHandler<InviteeConsulationInfo>();

  ///邀请者拒绝会诊事件（通知发起者）
  final FEventHandler<InviteeConsulationInfo> onRejectApplayConsultation =
      FEventHandler<InviteeConsulationInfo>();

  ///批准申请会诊通知
  final FEventHandler<InviteeConsulationInfo> onApprovalApplayConsultation =
      FEventHandler<InviteeConsulationInfo>();

  ///申请会诊通知
  final FEventHandler<InviteeConsulationInfo> onApplayConsultation =
      FEventHandler<InviteeConsulationInfo>();

  ///受邀请人通知（通知受邀请人）
  final FEventHandler<InviteeConsulationInfo> onInviteeConsultation =
      FEventHandler<InviteeConsulationInfo>();

  ///受邀请人同意通知（通知发起邀请的人）
  final FEventHandler<InviteeConsulationInfo> onInviteeApproveConsultation =
      FEventHandler<InviteeConsulationInfo>();

  ///受邀请人拒绝通知（通知发起邀请的人）
  final FEventHandler<InviteeConsulationInfo> onInviteeRejectConsultation =
      FEventHandler<InviteeConsulationInfo>();

  ///开启会诊事件
  final FEventHandler<LiveConsultation> onStartLiveConsultation =
      FEventHandler<LiveConsultation>();

  //成员静音通知
  final FEventHandler<ConsultationMember> onMemberMute =
      FEventHandler<ConsultationMember>();

  //成员静音通知
  final FEventHandler<ConsultationMember> onSwitchVideoPlay =
      FEventHandler<ConsultationMember>();

  ///会诊间改变
  final FEventHandler<LiveConsultation> onChangeConsultation =
      FEventHandler<LiveConsultation>();

  ///会诊间改变，成员不在新的会诊间，需退出
  final FEventHandler<LiveConsultation> onCloseConsultationDueToChange =
      FEventHandler<LiveConsultation>();

  ///主动退出会诊间事件
  final FEventHandler<bool> onExitConsultation = FEventHandler<bool>();
//---------------------------------------方法-----------------------------------

  /// trtc会诊设备重试进入房间
  Future<void> trtcRetryLoadDevice(String consultationCode);

  /// rtmp会诊设备重试进入房间
  Future<void> rtmpRetryLoadDevice(String consultationCode);

  ///会诊心跳
  Future<LiveConsultationHeartRateResult> consultationHeartRateSendOnce(
      String consultationCode);

  ///查询急诊前设备和专家
  Future<QueryEmergencyDataResult> queryEmergencyData();

  ///开始会诊
  Future<LiveConsultation> initiateLiveConsultationAsync(
      String consultationCode,
      {bool checkOnly = false});

  ///接受会诊
  Future<LiveConsultation> acceptLiveConsultationAsync(String consultationCode,
      {bool checkOnly = false});

  ///拒绝会诊
  Future<RejectLiveConsultationResult> rejectLiveConsultationAsync(
      String consultationCode);

  ///查询会诊详情
  Future<ConsultationDetailDTO?> findConsultationDetailAsync(
      String consultationCode);

  // /// 远程调参(已废弃，请勿使用)
  Future<bool?> controlParameterAsync(
    String consultationCode,
    List<AdditionParameterDTO> parameters,
    ControlDeviceParameterEnum controlType,
  );

  ///开启或关闭静音
  Future<MuteLiveConsultationResult> muteLiveConsultationAsync(
      String consultationCode, bool isMute);

  ///设置开启或关闭视频
  Future<SwitchLiveConsultationVideoResult> switchLiveConsultationVideoAsync(
      String consultationCode, bool isOpen);

  ///离开房间
  Future<LeaveLiveConsultationResult> leaveLiveConsultationAsync(
      String consultationCode);

  ///会诊过程邀请其他人
  Future<InviteInLiveConsultationResult> inviteInLiveConsultationAsync(
      String consultationCode, List<String> inviteCode, int roomNo);

  ///取消会诊
  Future<CancelLiveConsultationResult> cancelLiveConsultationAsync(
      String consultationCode);

  ///取消会诊过程邀请中的成员
  Future<CancelInvitingInLiveConsultationResult>
      cancelInvitingInLiveConsultationAsync(
          String consultationCode, List<String> inviteCodes);

  Future<LiveConsultation> joinInLiveConsultationAsync(String consultationCode,
      {bool checkOnly = false});

  ///完善会诊信息
  Future<bool> improveConsultationInfo({
    String? consultationCode,
    String? patientCode,
    List<String>? appointmentScanningPosition,
    String? appointmentDiseaseName,
    String? preliminaryDiagnosis,
    PatientInfo? patientInfo,
  });

  ///获取输出宽度
  double getVideoDeviceInfoWidth(
      {VideoDeviceSourceTypeEnum videoDeviceSourceType =
          VideoDeviceSourceTypeEnum.Desktop,
      required List<VideoDeviceOutputInfo> videoDeviceInfos});

  ///获取输出高度
  double getVideoDeviceInfoHeight(
      {VideoDeviceSourceTypeEnum videoDeviceSourceType =
          VideoDeviceSourceTypeEnum.Desktop,
      required List<VideoDeviceOutputInfo> videoDeviceInfos});

  ///获取即时会诊配置（发起前是否需要填入病人信息）
  Future<GetEmergencySettingResult> getEmergencySettingAsync();
}
