/**
 * 呼叫中心电话工具条常量定义
 * author: easycallcenter365@126.com
 * 2025-04-08
 */

/**
 * 座席状态枚举
 */
export const AgentStatusEnum = {
  /** 刚刚上线，尚未就绪中 */
  JUST_LOGIN: 1,
  /** 空闲 */
  FREE: 2,
  /** 忙碌 */
  BUSY: 3,
  /** 小休 */
  BUSY_REST: 31,
  /** 线下会议 */
  BUSY_MEETING: 32,
  /** 培训 */
  BUSY_TRAINING: 33,
  /** 通话中 */
  INCALL: 4,
  /** 话后处理，填写表单中 */
  FILL_FORM: 5,
  /** 电话会议中 */
  CONFERENCE: 6
};

/**
 * 视频级别配置
 */
export const VideoLevels = {
  SMOOTH: { levelId: '42e00b', description: '流畅' },
  SMOOTH2: { levelId: '42e00c', description: '流畅+' },
  SMOOTH3: { levelId: '42e00d', description: '流畅++' },
  CLEAR: { levelId: '42e014', description: '清晰' },
  CLEAR2: { levelId: '42e015', description: '清晰+' },
  CLEAR3: { levelId: '42e016', description: '清晰++' },
  HD: { levelId: '42e01e', description: '高清' },
  HD2: { levelId: '42e01f', description: '高清+' }
};

/**
 * 系统事件列表 - 基础事件
 */
export const EventList = {
  /** 当音频通话已建立 */
  ON_AUDIO_CALL_CONNECTED: '100',
  /** 当视频通话已建立 */
  ON_VIDEO_CALL_CONNECTED: '101',
  /** websocketServer 连接成功 */
  WS_CONNECTED: '200',
  /** 当前用户已在其他设备登录 */
  USER_LOGIN_ON_OTHER_DEVICE: '201',
  /** 用户下线 */
  WS_DISCONNECTED: '202',
  /** 通话状态发生改变 [监听的数据] */
  CALL_SESSION_STATUS_DATA_CHANGED: '203',
  /** 坐席状态列表发生改变 */
  AGENT_STATUS_DATA_CHANGED: '205',
  /** 请求参数错误 */
  REQUEST_ARGS_ERROR: '400',
  /** unauthorized */
  UNAUTHORIZED: '401',
  /** 服务器内部错误 */
  SERVER_ERROR: '500',
  /** 语音编码不匹配 */
  SERVER_ERROR_AUDIO_CODEC_NOT_MATCH: '501',
  /** 主叫接通 */
  CALLER_ANSWERED: '600',
  /** 主叫挂断 */
  CALLER_HANGUP: '601',
  /** 主叫忙; 上一通电话未挂机 */
  CALLER_BUSY: '602',
  /** 主叫未登录 */
  CALLER_NOT_LOGIN: '603',
  /** 主叫应答超时 */
  CALLER_RESPOND_TIMEOUT: '604',
  /** 被叫接通 */
  CALLEE_ANSWERED: '605',
  /** 被叫挂断 */
  CALLEE_HANGUP: '606',
  /** 被叫振铃 */
  CALLEE_RINGING: '607',
  /** 座席状态改变 */
  STATUS_CHANGED: '608',
  /** 一个完整的外呼任务结束：[可能尝试了一个或多个网关] */
  OUTBOUND_FINISHED: '611',
  /** 预测外呼，分配的来电 */
  PREDICTIVE_CALL_INBOUND: '612',
  /** ACD 队列分配的新来电 */
  NEW_INBOUND_CALL: '613',
  /** 当前业务组实时排队人数 */
  ACD_GROUP_QUEUE_NUMBER: '615',
  /** 收到转接的来电请求 */
  TRANSFER_CALL_RECV: 616,
  /** 锁定坐席失败 */
  LOCK_AGENT_FAIL: 617,
  /** 通话已经转接成功 */
  TRANSFER_CALL_SUCCESS: 618,
  /** 产生 asr 语音识别结果 */
  ASR_RESULT_GENERATE: 619,
  /** ASR 语音识别流程结束（坐席侧） */
  ASR_PROCESS_END_AGENT: 620,
  /** ASR 语音识别流程结束（客户侧） */
  ASR_PROCESS_END_CUSTOMER: 621,
  /** ASR 语音识别流程开始 */
  ASR_PROCESS_STARTED: 622,
  /** customer call session hold */
  CUSTOMER_CHANNEL_HOLD: 623,
  /** customer call session unHold */
  CUSTOMER_CHANNEL_UNHOLD: 624,
  /** customer call session on hold is hangup */
  CUSTOMER_ON_HOLD_HANGUP: 625,
  /** inner consultation request */
  INNER_CONSULTATION_REQUEST: 626,
  /** customer call session on call-wait */
  CUSTOMER_CHANNEL_CALL_WAIT: 627,
  /** customer call session off call-wait */
  CUSTOMER_CHANNEL_OFF_CALL_WAIT: 628,
  /** customer call session on call-wait is hangup */
  CUSTOMER_ON_CALL_WAIT_HANGUP: 629,
  /** extension on line event */
  EXTENSION_ON_LINE: 630,
  /** extension off line event */
  EXTENSION_OFF_LINE: 631,
  /** Notify the agent that the call consultation has started */
  INNER_CONSULTATION_START: 632,
  /** Notify the agent that the call consultation has stopped */
  INNER_CONSULTATION_STOP: 633,
  /** 多人电话会议，重复的被叫 */
  CONFERENCE_REPEAT_CALEE: 660,
  /** 多人电话会议，呼叫成员超时 */
  CONFERENCE_CALL_MODERATOR_TIMEOUT: 661,
  /** 多人电话会议，成员接通 */
  CONFERENCE_MEMBER_ANSWERED: 662,
  /** 多人电话会议，成员挂机 */
  CONFERENCE_MEMBER_HANGUP: 663,
  /** 多人电话会议，成员禁言成功 */
  CONFERENCE_MEMBER_MUTED_SUCCESS: 666,
  /** 多人电话会议，成员禁言失败 */
  CONFERENCE_MEMBER_MUTED_FAILED: 665,
  /** 多人电话会议，成员解除禁言成功 */
  CONFERENCE_MEMBER_UNMUTED_SUCCESS: 667,
  /** 多人电话会议，成员解除禁言失败 */
  CONFERENCE_MEMBER_UNMUTED_FAILED: 668,
  /** 多人电话会议，会议成员不存在，无法执行相关操作 */
  CONFERENCE_MEMBER_NOT_EXISTS: '669',
  /** 多人电话会议，主持人重置会议 */
  CONFERENCE_MODERATOR_RESET: '670',
  /** 多人电话会议，主持人接通 */
  CONFERENCE_MODERATOR_ANSWERED: '671',
  /** 多人电话会议，主持人挂机，会议结束 */
  CONFERENCE_MODERATOR_HANGUP: '672',
  /** 成员视频禁用成功 */
  CONFERENCE_MEMBER_VMUTED_SUCCESS: '674',
  /** 成员解除视频禁用成功 */
  CONFERENCE_MEMBER_UNVMUTED_SUCCESS: '676',
  /** 成员解除视频禁用失败 */
  CONFERENCE_MEMBER_UNVMUTED_FAILED: '677',
  /** 成功把通话转接到多人视频会议 */
  CONFERENCE_TRANSFER_SUCCESS_FROM_EXISTED_CALL: '678',
  /** outbound start event */
  OUTBOUND_START: '679'
};

/**
 * 系统事件列表 - 带文本信息的事件
 */
export const EventListWithTextInfo = {
  WS_CONNECTED: {
    code: 200,
    msg: '已签入',
    btn_text: [{ id: '#onLineBtn', name: '签出' }],
    enabled_btn: ['#setFree', '#callBtn', '#onLineBtn', '#consultationBtn']
  },
  WS_DISCONNECTED: {
    code: 202,
    msg: '服务器连接断开',
    btn_text: [{ id: '#onLineBtn', name: '签入' }],
    enabled_btn: ['#onLineBtn']
  },
  USER_LOGIN_ON_OTHER_DEVICE: {
    code: 201,
    msg: '用户已在其他设备登录',
    btn_text: [{ id: '#onLineBtn', name: '签入' }],
    enabled_btn: ['#onLineBtn']
  },
  REQUEST_ARGS_ERROR: {
    code: 400,
    msg: '客户端请求参数错误',
    btn_text: [],
    enabled_btn: []
  },
  SERVER_ERROR: {
    code: 500,
    msg: '服务器内部错误',
    btn_text: [],
    enabled_btn: []
  },
  CALLER_ANSWERED: {
    code: 600,
    msg: '分机已接通',
    btn_text: [],
    enabled_btn: ['#resetStatus', '#hangUpBtn', '#transferBtn', '#holdBtn', '#consultationBtn']
  },
  CALLER_HANGUP: {
    code: 601,
    msg: '分机已挂断',
    btn_text: [],
    enabled_btn: ['#onLineBtn', '#resetStatus', '#callBtn', '#setFree', '#consultationBtn']
  },
  CALLER_BUSY: {
    code: 602,
    msg: '分机忙，上一通电话未挂断',
    btn_text: [],
    enabled_btn: ['#onLineBtn', '#resetStatus', '#callBtn', '#setFree', '#consultationBtn']
  },
  CALLER_NOT_LOGIN: {
    code: 603,
    msg: '分机未登录，请检查',
    btn_text: [],
    enabled_btn: ['#onLineBtn', '#resetStatus', '#callBtn', '#setFree', '#consultationBtn']
  },
  CALLER_RESPOND_TIMEOUT: {
    code: 604,
    msg: '分机未应答超时，请重新打开分机',
    btn_text: [],
    enabled_btn: ['#onLineBtn', '#resetStatus', '#callBtn', '#setFree', '#consultationBtn']
  },
  CALLEE_ANSWERED: {
    code: 605,
    msg: '被叫已接通',
    btn_text: [],
    enabled_btn: ['#resetStatus', '#hangUpBtn', '#transferBtn', '#holdBtn', '#consultationBtn']
  },
  CALLEE_HANGUP: {
    code: 606,
    msg: '通话结束',
    btn_text: [],
    enabled_btn: ['#onLineBtn', '#resetStatus', '#callBtn', '#setFree', '#consultationBtn']
  },
  CALLEE_RINGING: {
    code: 607,
    msg: '被叫振铃中',
    btn_text: [],
    enabled_btn: ['#resetStatus', '#hangUpBtn', '#transferBtn', '#consultationBtn']
  },
  STATUS_CHANGED: {
    code: 608,
    msg: '状态已改变',
    btn_text: [],
    enabled_btn: []
  },
  FREE: {
    code: 0,
    msg: '空闲',
    btn_text: [],
    enabled_btn: ['#setBusy', '#onLineBtn', '#consultationBtn']
  },
  BUSY: {
    code: 1,
    msg: '忙碌',
    btn_text: [],
    enabled_btn: ['#setFree', '#onLineBtn', '#callBtn', '#consultationBtn']
  },
  CUSTOMER_CHANNEL_HOLD: {
    code: 623,
    msg: '通话已保持.',
    btn_text: [],
    enabled_btn: ['#setFree', '#callBtn', '#unHoldBtn', '#consultationBtn']
  },
  CUSTOMER_CHANNEL_UNHOLD: {
    code: 624,
    msg: '通话已接回.',
    btn_text: [],
    enabled_btn: ['#hangUpBtn', '#holdBtn']
  }
};

/**
 * 电话工具条按钮列表
 */
export const PhoneButtons = [
  '#setFree', '#setBusy', '#callBtn', '#hangUpBtn', '#resetStatus',
  '#onLineBtn', '#transferBtn', '#holdBtn', '#unHoldBtn', '#consultationBtn'
];

/**
 * 置忙子状态选项
 */
export const BusySubStatusOptions = [
  { value: '3', label: '置忙' },
  { value: '31', label: '小休' },
  { value: '32', label: '会议' },
  { value: '33', label: '培训' }
];

/**
 * 视频文件列表
 */
export const VideoFileList = [
  { value: '', label: '请选择视频' },
  { value: '/usr/local/freeswitchvideo/share/freeswitch/sounds/bank.mp4', label: '客服实例视频' },
  { value: '/usr/local/freeswitchvideo/share/freeswitch/sounds/conference.mp4', label: '多方会议视频' },
  { value: '/usr/local/freeswitchvideo/share/freeswitch/sounds/15-seconds.mp4', label: '15-seconds-demo' }
];

/**
 * 会议布局选项
 */
export const ConferenceLayouts = [
  { value: '2x2', label: '2x2' },
  { value: '3x3', label: '3x3' },
  { value: '1up_top_left+3', label: '一主三从' }
];

/**
 * 会议模板选项
 */
export const ConferenceTemplates = [
  { value: '480p', label: '480x640' },
  { value: '720p', label: '720x1080' },
  { value: 'default', label: 'default' }
];

/**
 * 会议类型选项
 */
export const ConferenceCallTypes = [
  { value: 'audio', label: '音频' }
];

/**
 * 默认配置
 */
export const DefaultConfig = {
  //scriptServer: '129.28.164.235',
  scriptServer: '127.0.0.1',
  scriptServerPort: '8899',
  extNum: '1001',//分机号
  opNum: 'admin',//用户登录账号
  userName: 'admin',//用户姓名
  groupId: '1',// 业务组 id
  extPassword: '0406f9d44bb8fe195a1ee2557bbeebf7',
  skillLevel: 9,//技能等级
  ipccServerUrl: 'sip.ylrzcloud.com',

  // 功能开关配置
  featureSwitches: {
    //基础外呼
    call: true,         // 外呼
    hold: true,         // 保持
    hangup: true,       // 挂机
    reset: true,        // 强置
    signInOut: true,     // 签出签入

    //进阶功能
    setBusy: false,      // 置忙-可外呼
    setFree: false,      // 置闲-可接呼入的电话
    transfer: false,     // 转接
    consultation: false, // 咨询
    conference: false,   // 会议
  }
};
