jiuyiUniapp/jiuyi/node_modules/@tencentcloud/call-uikit-wechat/tuicall-uikit-vue.es.js

2577 lines
122 KiB
JavaScript
Raw Normal View History

2024-12-18 15:46:27 +08:00
(function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
import { EVENT as C, TUICallEngine as at } from "tuicall-engine-wx";
import { TUICore as te, TUIConstants as B, TUILogin as it } from "@tencentcloud/tui-core";
import Ge from "@tencentcloud/chat";
var n = /* @__PURE__ */ ((r) => (r.CALL = "call", r.CUSTOM = "custom", r))(n || {}), g = /* @__PURE__ */ ((r) => (r[r.UNKNOWN = 0] = "UNKNOWN", r[r.AUDIO = 1] = "AUDIO", r[r.VIDEO = 2] = "VIDEO", r))(g || {}), F = /* @__PURE__ */ ((r) => (r.UNKNOWN = "unknown", r.CALLEE = "callee", r.CALLER = "caller", r))(F || {}), h = /* @__PURE__ */ ((r) => (r.IDLE = "idle", r.CALLING = "calling", r.CONNECTED = "connected", r))(h || {}), ne = /* @__PURE__ */ ((r) => (r.CONTAIN = "contain", r.COVER = "cover", r.FILL = "fill", r))(ne || {}), oe = /* @__PURE__ */ ((r) => (r.RESOLUTION_480P = "480p", r.RESOLUTION_720P = "720p", r.RESOLUTION_1080P = "1080p", r))(oe || {}), be = /* @__PURE__ */ ((r) => (r.EN = "en", r["ZH-CN"] = "zh-cn", r.JA_JP = "ja_JP", r))(be || {});
const T = {
IDLE: "idle",
BE_INVITED: "be-invited",
DIALING_C2C: "dialing-c2c",
DIALING_GROUP: "dialing-group",
CALLING_C2C_AUDIO: "calling-c2c-audio",
CALLING_C2C_VIDEO: "calling-c2c-video",
CALLING_GROUP_AUDIO: "calling-group-audio",
CALLING_GROUP_VIDEO: "calling-group-video"
}, rt = {
unknown: 0,
audio: 1,
video: 2
/* VIDEO */
};
var m = /* @__PURE__ */ ((r) => (r.EAR = "ear", r.SPEAKER = "speaker", r))(m || {}), se = /* @__PURE__ */ ((r) => (r[r.FRONT = 0] = "FRONT", r[r.BACK = 1] = "BACK", r))(se || {}), H = /* @__PURE__ */ ((r) => (r.Camera = "camera", r.Microphone = "microphone", r.SwitchCamera = "switchCamera", r.InviteUser = "inviteUser", r))(H || {}), q = /* @__PURE__ */ ((r) => (r.Open = "open", r.Close = "close", r))(q || {}), ke = /* @__PURE__ */ ((r) => (r.LocalInLargeView = "local", r.RemoteInLargeView = "remote", r))(ke || {}), J = /* @__PURE__ */ ((r) => (r[r.INVITE = 1] = "INVITE", r[r.CANCEL_INVITE = 2] = "CANCEL_INVITE", r[r.ACCEPT_INVITE = 3] = "ACCEPT_INVITE", r[r.REJECT_INVITE = 4] = "REJECT_INVITE", r[r.INVITE_TIMEOUT = 5] = "INVITE_TIMEOUT", r))(J || {});
const me = {
SWITCH_TO_AUDIO_CALL_FAILED: 60001,
SWITCH_TO_VIDEO_CALL_FAILED: 60002,
MICROPHONE_UNAVAILABLE: 60003,
CAMERA_UNAVAILABLE: 60004,
BAN_DEVICE: 60005,
NOT_SUPPORTED_WEBRTC: 60006,
ERROR_BLACKLIST: 20007
}, lt = {
SWITCH_TO_AUDIO_CALL_FAILED: "switchToAudioCall-call-failed",
SWITCH_TO_VIDEO_CALL_FAILED: "switchToVideoCall-call-failed",
MICROPHONE_UNAVAILABLE: "microphone-unavailable",
CAMERA_UNAVAILABLE: "camera-unavailable",
BAN_DEVICE: "ban-device",
NOT_SUPPORTED_WEBRTC: "not-supported-webrtc",
ERROR_BLACKLIST: "blacklist-user-tips"
};
var Ye = /* @__PURE__ */ ((r) => (r[r.NORMAL = 0] = "NORMAL", r[r.RELEASE = 1] = "RELEASE", r[r.WARNING = 2] = "WARNING", r[r.ERROR = 3] = "ERROR", r[r.NONE = 4] = "NONE", r))(Ye || {});
const Ce = {
CALL_STATUS: "callStatus",
CALL_ROLE: "callRole",
CALL_MEDIA_TYPE: "callMediaType",
LOCAL_USER_INFO: "localUserInfo",
LOCAL_USER_INFO_EXCLUDE_VOLUMN: "localUserInfoExcludeVolume",
REMOTE_USER_INFO_LIST: "remoteUserInfoList",
REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST: "remoteUserInfoExcludeVolumeList",
CALLER_USER_INFO: "callerUserInfo",
IS_GROUP: "isGroup",
CALL_DURATION: "callDuration",
CALL_TIPS: "callTips",
TOAST_INFO: "toastInfo",
IS_MINIMIZED: "isMinimized",
ENABLE_FLOAT_WINDOW: "enableFloatWindow",
BIG_SCREEN_USER_ID: "bigScreenUserId",
LANGUAGE: "language",
IS_CLICKABLE: "isClickable",
DISPLAY_MODE: "displayMode",
VIDEO_RESOLUTION: "videoResolution",
PUSHER: "pusher",
PLAYER: "player",
IS_EAR_PHONE: "isEarPhone",
IS_MUTE_SPEAKER: "isMuteSpeaker",
SHOW_PERMISSION_TIP: "SHOW_PERMISSION_TIP",
NETWORK_STATUS: "NetWorkStatus",
GROUP_ID: "groupID",
ROOM_ID: "roomID",
ROOM_ID_TYPE: "roomIdType",
SHOW_SELECT_USER: "showSelectUser",
IS_SHOW_ENABLE_VIRTUAL_BACKGROUND: "isShowEnableVirtualBackground",
ENABLE_VIRTUAL_BACKGROUND: "enableVirtualBackground",
GROUP_CALL_MEMBERS: "groupCallMembers",
PUSHER_ID: "pusherId"
}, nt = {
INNER_ATTR_KIT_INFO: "inner_attr_kit_info"
}, ot = {
INITIAL_PUSHER: "initialPusher",
NEW_PUSHER: "newPusher"
}, a = {
PREFIX: "【CallService】",
AUDIO: "audio",
VIDEO: "video",
LOCAL_VIDEO: "localVideo",
ERROR: "error",
TIMEOUT: "timeout",
RAF: "raf",
INTERVAL: "interval",
DEFAULT: "default",
BOOLEAN: "boolean",
STRING: "string",
NUMBER: "number",
OBJECT: "object",
ARRAY: "array",
FUNCTION: "function",
UNDEFINED: "undefined",
UNKNOWN: "unknown",
ALL: "all",
MYSELF: "myself",
DEVICE_LIST: "deviceList",
CAMERA_POSITION: "cameraPosition",
CUSTOM_UI_CONFIG: "customUIConfig",
...ot,
...Ce,
...nt
}, st = "https://web.sdk.qcloud.com/component/TUIKit/assets/call.png", At = "https://web.sdk.qcloud.com/component/TUIKit/assets/call-video-reverse.svg", Fe = 2147483647, ye = 4;
var Ue = /* @__PURE__ */ ((r) => (r[r.TUI_CALL_KIT = 14] = "TUI_CALL_KIT", r[r.TIM_CALL_KIT = 15] = "TIM_CALL_KIT", r))(Ue || {}), pe = /* @__PURE__ */ ((r) => (r[r.NUMBER_ROOM_ID = 1] = "NUMBER_ROOM_ID", r[r.STRING_ROOM_ID = 2] = "STRING_ROOM_ID", r))(pe || {});
function ct() {
wx.hideKeyboard && wx.hideKeyboard({
complete: () => {
}
});
}
function ut() {
wx.getSystemInfoSync().platform === "devtools" && wx.showModal({
icon: "none",
title: "运行环境提醒",
content: "微信开发者工具不支持原生推拉流组件(即 <live-pusher> 和 <live-player> 标签),请使用真机调试或者扫码预览。",
showCancel: !1
});
}
function He() {
ct(), ut();
}
async function It(r, e) {
try {
He();
const t = {
microphone: !0,
camera: r === g.VIDEO
};
return await e._tuiCallEngine.deviceCheck(t) ? h.CALLING : h.IDLE;
} catch (t) {
return console.debug(t), h.IDLE;
}
}
function Ct(r) {
(r == null ? void 0 : r.code) === -1002 && wx.showModal({
icon: "none",
title: "error",
content: (r == null ? void 0 : r.message) || "",
showCancel: !1
});
}
function Et() {
wx.showModal({
icon: "none",
title: "权限提示",
content: "当前小程序 appid 不具备 <live-pusher> 和 <live-player> 的使用权限,您将无法正常使用实时通话能力,请使用企业小程序账号申请权限后再进行开发体验",
showCancel: !1
});
}
const dt = {
// 按钮文案
hangup: "Hang up",
reject: "Decline",
accept: "Accept",
camera: "Camera",
microphone: "Microphone",
speaker: "speaker",
"open camera": "Open Camera",
"close camera": "Close Camera",
"open microphone": "Open Microphone",
"close microphone": "Close Microphone",
"video-to-audio": "Switch to audio",
"virtual-background": "Blur Background",
// 通话结果
"other side reject call": "other side reject call",
"reject call": "Reject Call",
cancel: "Cancel Call",
"other side line busy": "other side line busy",
"in busy": "in busy",
"call timeout": "call timeout",
"no response from the other side": "no response from the other side",
"end call": "end call",
// 通话提示语
"caller calling message": "Awaiting response",
"callee calling video message": "invites you to a video call",
"callee calling audio message": "invites you to a voice call",
"no microphone access": "no microphone access",
"no camera access": "no camera access",
"invite member": "Invite Member",
"Invited group call": "invites you to a group call",
waiting: "Calling...",
me: "(me)",
// 弹出层文案
"browser-authorization": "Browser authorization",
"mac-privacy": "System Preferences -> Security and Privacy -> Privacy",
"win-privacy": "Setting -> Privacy and Security -> App permissions",
"mac-preferences": "Open System Preferences",
"win-preferences": "Open Setting",
"Please enter userID": "Please enter userID",
"View more": "View more",
"people selected": "people selected",
"Select all": "Select all",
Cancel: "Cancel",
Done: "Done",
"exist group call": "A group call already exists in the current group",
// UI3.0 新增
"camera enabled": "Camera On",
"camera disabled": "Camera Off",
"microphone enabled": "Unmuted",
"microphone disabled": "Muted",
"speaker enabled": "Speaker On",
"speaker disabled": "Speaker Off",
"open speaker": "Turn on speaker",
"close speaker": "Turn off speaker",
"wait to be called": "Waiting",
answered: "Connected",
"people in the call": " other(s) in the call",
"failed to obtain speakers": "failed to obtain speakers",
"you have a new call": "You have a new call",
"switch camera": "Switch",
join: "Join",
"people on the call": "people on the call",
"Supports a maximum of 9 people for simultaneous calls": "Supports a maximum of 9 people for simultaneous calls",
you: "(you)",
"The network is poor during your current call": "The network is poor during your current call",
"The other user network is poor during the current call": "The other party's network is poor during the current call",
"TUICallKit init is not complete": "TUICallKit init is not complete. You need to use this API after the init API is finished.",
// combine chat
"Video call": "Video call",
"Voice call": "Voice call",
"Call End": "Call End",
"Switch voice call": "Switch voice call",
"Switch video call": "Switch video call",
"Call duration": "Duration",
"Call Cancel": "Canceled",
"Other Side Cancel": "Call canceled by caller",
Decline: "Declined",
"Other Side Decline": "Call declined by user",
"No answer": "Call not answered",
"Other Side No Answer": "Call wasn't answered",
Answered: "Answered",
"Other Side Line Busy": "Line busy",
"Line Busy": "Line busy. Call not received.",
// 待废弃文案
"Those involved": "Those involved in the call are",
call: "call",
"video-call": "video call",
"audio-call": "audio call",
search: "search",
"search-result": "search result",
"no-user": "user not found",
"member-not-added": "member not added",
"input-phone-userID": "phone number or userID",
"not-login": "not logged in",
"login-status-expire": "login status is invalid, please refresh the page and try again",
"experience-multi-call": "experience multi-person calls, please download the full-featured demo: ",
"not-support-multi-call": "multi-person call interface is not open",
userID: "userID",
"already-enter": "entered the call",
"camera-opened": "Camera on",
"camera-closed": "Camera off",
"microphone-opened": "Mic on",
"microphone-closed": "Mic off",
timeout: "timeout",
"kick out": "kick out",
"image-resolution": "Resolution",
"default-image-resolution": "Default",
"invited-person": "Invite",
"be-rejected": "Call declined, ",
"be-no-response": "No response, ",
"be-line-busy": "Line busy, ",
"be-canceled": "The call is canceled, ",
"voice-call-end": "Voice call ended",
"video-call-end": "Video call ended",
"method-call-failed": "Failed to sync the operation",
"failed-to-obtain-permission": "Failed to obtain permissions",
"environment-detection-failed": "Failed to check the environment",
"switchToAudioCall-call-failed": "switch to audio call method failed",
"switchToVideoCall-call-failed": "switch to video call method failed",
"microphone-unavailable": "No mic found",
"camera-unavailable": "No camera found",
"ban-device": "Device access denied",
"not-supported-webrtc": "Your current environment does not support WebRTC",
"blacklist-user-tips": "The identifier is in blacklist. Failed to send this message!",
"is-already-calling": "TUICallKit is already on a call",
"need-init": "Before initiating a call with TUICallKit, ensure that the TUICallKitServer.init() method has executed successfully. ",
"can't call yourself": "Can't call yourself",
// eslint-disable-line
"Use-phone-and-computer": "Use your mobile phone and computer to experience video calls",
"Wechat scan right QR code": "Wechat scan right QR code",
"Scan the QR code above": "Scan the QR code above",
"accept-error": "Accept failed",
"accept-device-error": "Accept failed, unable to auth calling device",
"call-error": "Start call failed"
}, ht = {
// 按钮文案
hangup: "挂断",
reject: "拒绝",
accept: "接受",
camera: "摄像头",
microphone: "麦克风",
speaker: "扬声器",
"open camera": "打开摄像头",
"close camera": "关闭摄像头",
"open microphone": "打开麦克风",
"close microphone": "关闭麦克风",
"video-to-audio": "转语音通话",
"virtual-background": "模糊背景",
// 通话结果
"other side reject call": "对方已拒绝",
"reject call": "拒绝通话",
cancel: "取消通话",
"other side line busy": "对方忙线",
"in busy": "正在忙",
"call timeout": "呼叫超时",
"end call": "结束通话",
// 通话提示语
"caller calling message": "等待对方接受邀请",
"callee calling video message": "邀请你视频通话",
"callee calling audio message": "邀请你语音通话",
"no microphone access": "没有麦克风权限",
"no camera access": "没有摄像头权限",
"invite member": "邀请成员",
"Invited group call": "邀请你加入多人通话",
"Those involved": "参与通话的有:",
waiting: "等待接听...",
me: "(我)",
// 弹出层文案
"browser-authorization": "浏览器授权",
"mac-privacy": "系统偏好设置 -> 安全与隐私 -> 隐私",
"win-privacy": "设置 -> 隐私和安全性 -> 应用权限",
"mac-preferences": "打开系统偏好设置",
"win-preferences": "打开系统设置",
"Please enter userID": "请输入 userID",
"View more": "查看更多",
"people selected": "人已选中",
"Select all": "全选",
Cancel: "取消",
Done: "完成",
"exist group call": "当前群组中已经存在群组通话",
// UI3.0 新增
"camera enabled": "摄像头已开",
"camera disabled": "摄像头已关",
"microphone enabled": "麦克风已开",
"microphone disabled": "麦克风已关",
"speaker enabled": "扬声器已开",
"speaker disabled": "扬声器已关",
"open speaker": "开启扬声器",
"close speaker": "关闭扬声器",
"wait to be called": "等待接听",
answered: "已接通",
"people in the call": "人参与通话",
"failed to obtain speakers": "无法获取扬声器",
"you have a new call": "您有一个新的通话",
"switch camera": "翻转",
join: "加入",
"people on the call": "人正在通话",
"Supports a maximum of 9 people for simultaneous calls": "最多支持9人同时通话",
you: "(你)",
"The network is poor during your current call": "当前通话你的网络不佳",
"The other user network is poor during the current call": "当前通话对方网络不佳",
"TUICallKit init is not complete": "TUICallKit 初始化登录未完成,需要在 init 完成后使用此 API",
// combine chat
"Video call": "发起视频通话",
"Voice call": "发起语音通话",
"Call End": "通话结束",
"Switch voice call": "切换语音通话",
"Switch video call": "切换视频通话",
"Call duration": "通话时长",
"Call Cancel": "已取消",
"Other Side Cancel": "对方已取消",
Decline: "已拒绝",
"Other Side Decline": "对方已拒绝",
"No answer": "超时无应答",
"Other Side No Answer": "对方无应答",
Answered: "已接听",
"Other Side Line Busy": "对方忙线中",
"Line Busy": "忙线无应答",
// 待废弃文案
timeout: "超时",
"kick out": "被踢",
call: "通话",
"video-call": "视频通话",
"audio-call": "音频通话",
search: "搜索",
"search-result": "搜索结果",
"Wechat scan right QR code": "微信扫右二维码",
"Use-phone-and-computer": "用手机与电脑互打体验视频通话",
"Scan the QR code above": "扫描上方二维码",
"no-user": "未搜索到用户",
"member-not-added": "未添加成员",
"not-login": "未登录",
"login-status-expire": "登录状态已失效,请刷新网页重试",
"experience-multi-call": "体验多人通话请下载全功能demo:",
"not-support-multi-call": "多人通话接口未开放",
"input-phone-userID": "请输入手机号/用户ID",
userID: "用户ID",
"already-enter": "已经进入当前通话",
"image-resolution": "分辨率",
"default-image-resolution": "默认分辨率",
"invited-person": "添加成员",
"be-rejected": "对方已拒绝,",
"be-no-response": "对方无应答,",
"be-line-busy": "对方忙线中,",
"be-canceled": "对方已取消",
"voice-call-end": "语音通话结束",
"video-call-end": "视频通话结束",
"method-call-failed": "同步操作失败",
"failed-to-obtain-permission": "权限获取失败",
"environment-detection-failed": "环境检测失败",
"switchToAudioCall-call-failed": "切语音调用失败",
"switchToVideoCall-call-failed": "切视频调用失败",
"microphone-unavailable": "没有可用的麦克风设备",
"camera-unavailable": "没有可用的摄像头设备",
"ban-device": "用户禁止使用设备",
"not-supported-webrtc": "当前环境不支持 WebRTC",
"blacklist-user-tips": "发起通话失败,被对方拉入黑名单,禁止发起!",
"is-already-calling": "TUICallKit 已在通话状态",
"need-init": "TUICallKit 发起通话前需保证 TUICallKitServer.init() 方法执行成功",
"can't call yourself": "不能呼叫自己",
// eslint-disable-line
"accept-error": "接通失败",
"accept-device-error": "接通失败,通话设备获取失败",
"call-error": "发起通话失败"
}, Lt = {
// 按钮文案
hangup: "通話終了",
reject: "拒否",
accept: "応答",
camera: "カメラ",
microphone: "マイク",
speaker: "スピーカー",
"virtual-background": "ボケ背景",
// 通话结果
"other side reject call": "通話が拒否されました",
"reject call": "通話拒否",
cancel: "通話をキャンセル",
"other side line busy": "相手が通話中です",
"in busy": "通話中",
"call timeout": "呼び出しタイムアウト",
"end call": "通話終了",
// 通话提示语
"caller calling message": "応答を待っています",
"callee calling video message": "ビデオ通話に招待されました",
"callee calling audio message": "音声通話に招待されました",
"no microphone access": "マイクにアクセスできません",
"no camera access": "カメラにアクセスできません",
"invite member": "メンバーを招待する",
// 弹出层文案
"browser-authorization": "ブラウザ認証",
"mac-privacy": "システム環境設定 -> セキュリティとプライバシー ->プライバシー",
"win-privacy": "設定 -> セキュリティとプライバシー ->アプリのアクセス許可",
"mac-preferences": "システム環境設定を開く",
"win-preferences": "システム設定を開く",
"Please enter userID": "ユーザーIDを入力してください",
"View more": "もっと見る",
"people selected": "人が選択されました",
"Select all": "すべて選択",
Cancel: "キャンセル",
Done: "完了",
"exist group call": "現在のグループには既にグループ通話が存在しています",
// combine chat
"Video call": "ビデオ通話を開始",
"Voice call": "音声通話を開始",
"Call End": "通話終了",
"Switch audio call": "音声通話に切り替える",
"Switch video call": "ビデオ通話に切り替える",
"Call duration": "通話時間",
"Call Cancel": "通話をキャンセルする",
"Other Side Cancel": "相手がキャンセルしました",
Decline: "通話を拒否する",
"Other Side Decline": "相手が拒否しました",
"No answer": "無応答",
"Other Side No Answer": "相手からの返答はありません",
Answered: "応答しました",
"Other Side Line Busy": "相手は現在忙しくて対応できません",
"Line Busy": "忙しいので応答できません",
// UI3.0文案
"open camera": "オープンカメラ",
"close camera": "カメラを閉じる",
"open microphone": "オープンマイク",
"close microphone": "マイクを閉じる",
"camera enabled": "カメラオン",
"camera disabled": "カメラオフ",
"microphone enabled": "マイクオン",
"microphone disabled": "マイクオフ",
"speaker enabled": "スピーカーオン",
"speaker disabled": "スピーカーオフ",
"open speaker": "スピーカーをオンにする",
"close speaker": "スピーカーの電源を切ります",
"wait to be called": "待機中",
answered: "接続済み",
"people in the call": "通話に参加している人たち",
"failed to obtain speakers": "スピーカーが見つかりません",
"you have a new call": "新しい通話があります",
"switch camera": "切り替え",
join: "参加する",
"people on the call": "人が通話中です",
"Supports a maximum of 9 people for simultaneous calls": "最大で9人まで同時通話が可能です",
you: "(あなた)",
"The network is poor during your current call": "現在の通話で、あなたのネットワークは不良です",
"The other user network is poor during the current call": "現在の通話で、相手側のネットワークが不良です",
"TUICallKit init is not complete": "TUICallKitの初期化ログインが完了していません。init が完了した後にこのAPIを使用する必要があります。",
// 待废弃文案
timeout: "タイムアウト",
"kick out": "キックアウトされました",
"Invited group call": "グループ通話に招待されました。",
"Those involved": "参加者:",
call: "通話",
"video-call": "ビデオ通話",
"audio-call": "音声通話",
search: "検索",
"search-result": "検索結果",
"Wechat scan right QR code": "WeChatで右側にあるQRコードを読み取ります。",
"Use-phone-and-computer": "携帯電話とコンピュータを使用してビデオ通話を体験してください",
"Scan the QR code above": "上のQRコードを読み取ります。",
"no-user": "ユーザーが見つかりませんでした",
"member-not-added": "メンバーが追加されていません",
"not-login": "ログインしていません",
"login-status-expire": "ログインの有効期限が過ぎています。ページを更新してもう一度お試しください",
"experience-multi-call": "複数人で同時に音声通話できるグループ通話機能を体験するには、全機能のデモをダウンロードしてください",
"not-support-multi-call": "グループ通話インターフェイスが開いていません",
"input-phone-userID": "携帯電話番号/ユーザーIDを入力してください",
userID: "ユーザーID",
"already-enter": "すでに通話に参加しています",
waiting: "応答を待っています...",
"camera-opened": "カメラがオンになっています",
"camera-closed": "カメラがオフになっています",
"microphone-opened": "マイクがオンになっています",
"microphone-closed": "マイクがオフになっています",
"image-resolution": "解像度",
"default-image-resolution": "デフォルト解像度",
"invited-person": "メンバーを招待",
"video-to-audio": "音声通話に切り替えます",
me: "(自分)",
"be-rejected": "通話が拒否されました, ",
"be-no-response": "応答なし, ",
"be-line-busy": "相手が通話中です, ",
"be-canceled": "相手が通話をキャンセルしました",
"voice-call-end": "音声通話が終了しました",
"video-call-end": "ビデオ通話が終了しました",
"method-call-failed": "操作の同期に失敗しました",
"failed-to-obtain-permission": "権限の取得に失敗しました",
"environment-detection-failed": "環境の検出に失敗しました",
"switchToAudioCall-call-failed": "音声通話に切り替えることはできません",
"switchToVideoCall-call-failed": "ビデオ通話に切り替えることはできません",
"microphone-unavailable": "使用できるマイクがありません",
"camera-unavailable": "使用できるカメラがありません",
"ban-device": "デバイスへのアクセスが拒否されました",
"not-supported-webrtc": "現在の環境はWebRTCをサポートしていません",
"blacklist-user-tips": "ユーザーはブラックリストに登録され、通話が開始できませんでした",
"is-already-calling": "TUICallKit はすでに通話中です",
"need-init": "TUICallKitで通話を開始する前に、TUICallKitServer.init() メソッドが正常に実行されたことを確認してください。",
"can't call yourself": "自分に電話をかけることができません",
"accept-error": "接続できませんでした",
"accept-device-error": "接続できませんでした。発信側デバイスを認証できません",
"call-error": "通話が開始できませんでした"
}, O = {
OTHER_SIDE: "other side",
CANCEL: "cancel",
OTHER_SIDE_REJECT_CALL: "other side reject call",
REJECT_CALL: "reject call",
OTHER_SIDE_LINE_BUSY: "other side line busy",
IN_BUSY: "in busy",
CALL_TIMEOUT: "call timeout",
END_CALL: "end call",
TIMEOUT: "timeout",
KICK_OUT: "kick out",
CALLER_CALLING_MSG: "caller calling message",
CALLER_GROUP_CALLING_MSG: "wait to be called",
CALLEE_CALLING_VIDEO_MSG: "callee calling video message",
CALLEE_CALLING_AUDIO_MSG: "callee calling audio message",
NO_MICROPHONE_DEVICE_PERMISSION: "no microphone access",
NO_CAMERA_DEVICE_PERMISSION: "no camera access",
EXIST_GROUP_CALL: "exist group call",
LOCAL_NETWORK_IS_POOR: "The network is poor during your current call",
REMOTE_NETWORK_IS_POOR: "The other user network is poor during the current call"
}, Me = {
en: dt,
"zh-cn": ht,
ja_JP: Lt
};
function S(r) {
var i;
const e = A.getData(n.CALL, a.LANGUAGE);
for (const l in Me)
if (l === e) {
const o = Me[l];
for (const s in o)
if (s === r)
return o[s];
}
const t = (i = r.en) == null ? void 0 : i.key;
return console.error(`${a.PREFIX}translation is not found: ${r}.`), t;
}
const Ee = typeof wx < "u" && typeof wx.getSystemInfoSync == "function" && !!wx.getSystemInfoSync().fontSizeSetting, xe = typeof uni < "u" && typeof uni > "u", ve = Ee || xe, Je = typeof uni < "u", We = function() {
return (typeof uni < "u" || typeof window < "u") && !ve;
}(), gt = function() {
return Ee ? wx : Je ? uni : window;
}(), b = We && window && window.navigator && window.navigator.userAgent || "", ft = /Android/i.test(b), Dt = /(?:Windows Phone)/.test(b), _t = /(?:SymbianOS)/.test(b), St = /iPad/i.test(b) || /iPhone/i.test(b) || /iPod/i.test(b), ze = ft || Dt || _t || St, Oe = We && !ze, pt = Oe && b.includes("Windows NT"), Bt = Oe && b.includes("Mac");
let qe = class ie {
constructor() {
this.global = gt, this.isPC = !1, this.isH5 = !1, this.isWeChat = !1, this.isApp = !1, this.isUniPlatform = !1, this.isOfficial = !1, this.isWIN = !1, this.isMAC = !1, this.initEnv();
}
/**
* 获取 TUIGlobal 实例
* @returns {TUIGlobal}
*/
static getInstance() {
return ie.instance || (ie.instance = new ie()), ie.instance;
}
initEnv() {
this.isPC = Oe, this.isH5 = ze, this.isWeChat = Ee, this.isApp = xe && !Ee, this.isUniPlatform = Je, this.isWIN = pt, this.isMAC = Bt;
}
initOfficial(e) {
this.isOfficial = e === 1400187352 || e === 1400188366;
}
};
const Ne = function(r) {
return typeof r === a.UNDEFINED;
}, Xe = function(r) {
if (typeof r !== a.OBJECT || r === null)
return !1;
const e = Object.getPrototypeOf(r);
if (e === null)
return !0;
let t = e;
for (; Object.getPrototypeOf(t) !== null; )
t = Object.getPrototypeOf(t);
return e === t;
}, je = function(r) {
return typeof Array.isArray === a.FUNCTION ? Array.isArray(r) : Object.prototype.toString.call(r).match(/^\[object (.*)\]$/)[1].toLowerCase() === a.ARRAY;
}, Be = function(r) {
return typeof r === a.STRING;
}, wt = function(r) {
return typeof r === a.BOOLEAN;
}, Ze = function(r) {
return (
// eslint-disable-next-line
r !== null && (typeof r === a.NUMBER && !isNaN(r - 0) || typeof r === a.OBJECT && r.constructor === Number)
);
};
function $e(r) {
const e = Math.floor(r / 3600), t = Math.floor(r % 3600 / 60), i = Math.floor(r % 60);
let l = e > 9 ? `${e}` : `0${e}`;
return l += t > 9 ? `:${t}` : `:0${t}`, l += i > 9 ? `:${i}` : `:0${i}`, l;
}
function Ut(r) {
if (typeof r === a.STRING)
try {
return !!JSON.parse(r);
} catch (e) {
return console.debug(e), !1;
}
return !1;
}
const ce = function(r) {
return !r || !Ut(r) ? r : JSON.parse(r);
};
function Qe(r) {
return (r == null ? void 0 : r.message.indexOf("is ongoing, please avoid repeated calls")) !== -1;
}
function Ot(r) {
const { message: e } = r;
return e.indexOf("NotAllowedError: Permission denied") !== -1;
}
function fe() {
return Date.now();
}
const Nt = function(r) {
return typeof r === a.FUNCTION;
}, Rt = () => {
if (qe.getInstance().isWeChat)
return "zh-cn";
const r = ((navigator == null ? void 0 : navigator.language) || (navigator == null ? void 0 : navigator.userLanguage) || "").substr(0, 2);
let e = "en";
switch (r) {
case "zh":
e = "zh-cn";
break;
case "ja":
e = "ja_JP";
break;
default:
e = "en";
}
return e;
}, Tt = function(r) {
return Object.prototype.toString.call(r).match(/^\[object (.*)\]$/)[1].toLowerCase();
};
function Gt(r, e, t) {
if (!r.hasOwnProperty(e))
return r;
const i = {};
return Object.keys(r).forEach((l) => {
l === e ? i[t] = r[l] : i[l] = r[l];
}), i;
}
const mt = "data:audio/mpeg;base64,SUQzAwAAAAAAGFRYWFgAAAAOAAAAVFhYWABpc29taXNvMv/zNGQAAqwAvnihCAADQAF4CUAQAFYAg3Lh8u+XUD5///wx//wQOAhKAgb/////xOoH4g8Hz4Pq8RoAbdTgMsMt9hcb990EP//zNGQQBPDjEgDItAAFWcIoAYoQAN9P/03QQ//umn//91SXL5uXP+pf8WYTvzgJPAQ+p/7f///1//6f///WH///F4BtJhNFkP/zNGQGA/jjNADHiAAEQDJcAYkQAGWrn6vw6ljfPtj/////////9Pv9sL/mL/QezSepgwrimv07//////y3u602OiyhOYb+LP/zNGQIBKTBKADoCACDoCZMAckAAKHKCUIAFsqGZXtSZ/////////Sn/Vy3nVUOJBqSX2UAkQxBddzv//////yq3lcgaTmTQ//zNGQHA9SrJgA8AliD4C5IAApYAKh3FKlMunKHm8H/2//77vkdqB2xfsXaHiDKBGtFKqONF3/////Z9VXClT5ND+syHkjBq//zNGQLBITJIAA8AmQEiDI4AAjSAGa1Vffm3ff/1/0//11tvZpAaIw3dBiIrjJgHQrGVWmdBU1f/////oDqEKrV1OpBUTjQtv/zNGQHAsjDKAAwAl4D0Co8AAmCBHIQNtld6fm0+/VigZzuMnGZlkAMLMJFv/////33UIWeFQkKsaceBsangecHzYXKI//////zNGQUA4QjKAA3CAID8CpEABMCBPfuStx4FQVHYMgKcO6jIJh//////9uIlspQkGQ2YyZscAV83Bv/////ncL6BEiWHyA2K//zNEQbAogfJgAx5hAEwDJcCAsEBtICgF3/////WJaIuuqMCCVGucgkrtwiwBO//////pW4YFRWQhaRRhZZnVwGhf////+ocv/zNEQmApgVJAANjwAFkC5YCApeAolD4kQb+EQJYNKwLWGmc6sqMBwJvf////6tDEOWDgFJk1VywKMGoM2f////+N1JmgJuPv/zNGQuA4AbJAAl5hIDwC48AAIGBEho7wTL5b6kSO7IUAA5uDABYNNjGDBSJEN//////xtQsszVy27IcWBbQkLgzv7YmZYW///zNGQ2AqzFNAgcA1+D8CZIAAhMAP/3/rozCAsBjIqCY/DBWMfQZp1f/////0F6phXSNisgAJjo6icT2vpvM/Vf9v///97eu//zNGRDA4gdJgBhghIDwCZAABGMAFVWERbCdaMYNCKs///2f//QMOBhFBEL+ykPDBIJgp1sjvOMAd/////1OEsNl3MST2Q0Yf/zNGRKA2DJKAAsBWYD8Co8AAmEBLDHj+M/IhcksnAgg6G+qLIYz5etEeeW8HZsorBzgkAa1AWMPfu/////LaYPuAABp7iKXP/zNGRSA3glKgQJ6QACOCZMAAmGAYUAPF9exl35wz/9DIK2KUmQgYlTwgEEWkm3f////6IVoMJPBkKdWoQnDLurGiesVhdx6f/zNGRgAqizNAQsA20D4B5QAAmEAP/+vjlaZ1RwqBVMJYhaM4sYnFlVf/////6qAEghRzo0nRKQQRlI/EAPkCE6srVAiTUt/f/zNGRuAwCzQMwkAmwDsCpUAAmEAD3e5qf+yS5UwJFzQ145RxpgyI1QrkYnFjlaFdmklTcdAYL/rpcl7an3N18alNr+8+Tjqf/zNGR6BAjHKgQ8AmoDUDZUAADGBHMxO4R8koQnxNohhQoHS/XVF40p6jdPQ7qEIfuLKpUDOmf////2TGDwwTzkh0sePBMWCv/zNGR/BGwnMDxhhhIDyEJQAHpMISk//////0K1gsLiN1WF6ShLE4o14ccxglb//9P/4q5FQOpJkMGwZxhY7oDQW//////sWv/zNGR/A8zBKgRkA22CsC5QABvEAaoDMZE4OYXHboRqlgfr85KzbMjSIgKRUEILJNuHBYDoH//////qgPyBJdUEsYVyTSAteP/zNGSIAzQjLAQ9gxIDwDZMAAmKBLmvo0L///b/2iiK48qOD4gBjCxhQ7AbaCjzm/////+utNUXkYSLUD1SBQS8MECruBT57f/zNGSSA6AhJgAl5gQD0DZIABDGBN5qjnO4MkB4hZ7dh4ffb/////8g+xYWYFUYeDYyhC18k+tOcH4z9f9slvls1HAAcxB95//zNGSYAri9MAgwA16D0CJIADpGANGJmAqH6X//////V13vmwnBdjKbx6RrmMrau4F7wPrWv/p//76f+k81B8eKBCgyNya5jf/zNGSmA9AjJAA97AID6DZEACjEBIYDAEG3//////y7mAIq1aOwiF0rtiCEZJNHhm85SBFNJn63f//b8hnQytnEhqioQHLMDP/zNGSqAwy/KgQ8Al6DoCpAAApCBK3qJ6KDBVDgKb/////8c2bq7lAgjFKFNzoDGD2f6DnQpO1rBdGPZq/////t/X/jKy3bUv/zNGS2A2DBKAQ8A2yDqC5EAAMGBBNFy1AzuLARQspDWGjQiDQGf//6avV6pGJBLsfDuI/14WvXP9v///T7IkQkctXkHygJAf/zNGS/BIzLJgA8B2YD4CJQAAhKAHBkdgIRgDqoaE/////9QxgQTKqB+vY/RzDLHYYoY0Y0Xj30gb+zdF///5/2R//z9La1HP/zNGS+BMTHIAAwBWaDyCZAAAhMAD9/SSaHQTkQS2EGSh02NjgJZbYoOt//9yv/8/SlAVEdCjJAdiSKMLieMEgRojWdrsPvhP/zNGS7BUzJHgBh4hYC+CZAAAGMAJbWjunv1dnJf7va5R0APyBgh0RKxyBAj////7E+vUryN6fWmQZjSKkWZIC6sb+aU/Ohk//zNES3A1y5IgA8AliF6DpIABMGBJf//8ZkvsiuL/fvOBkwbBoLBjMY+qgy8Irx3Co4gCeyz//7v/8vftKVDjBg3fp8qFcj1f/zNGS3BOTJIgA8KF4FoD40ABJMBIl0NQ+MxtVQRi20lr36O0rSbvflAUFCIUaRQdNtE5j+LeXB7TUNPFjP/+hav/2LjkHX4//zNGSsBDglJDg95iAD6CZAAAiMAFUAkEkY1LkZoHjlPbtusbU/vCkLlJ480wHkKcof9//UhWSZfAmf5ovuC6XqRor/2dmBIv/zNGStBaTDGgA8I1yD0DI4AADEBAALgw4c8ByDxLPorWktBluaGYNjx0HnzMPFj///95hxUHn/4eQcxif/+Pk0BwAsZ+nw+v/zNGSjBSAdIDiniAAFECo0AUYQANZQWuOefHOA9WA39Khw2NjPM0C+khp7n//////vN2P87mF5r2c6F607H8ZeEyB6CZZV7P/zNGSYB6C9NGTMNAAJ6XZUAY04AIg84IPMLROUTmsw/7hJxOjVupv+kI+3/30oWQecIbC042klckMcsgOSKovRrkbhKj0HUf/zNGRmB5i7VADpmAAFCDqUKc0QAOKmnvZmHi4Ye/VFxY8eaKC2EntAYFAHH4AoHK/UjViBLV//63AJjdI0XtwGkifICyqmi//zNGRIBSw7btwFgyMD6ALqWAhETu2ZOWicEhAiswV/hPFBGEqauoaRW3V54HwcFxIkk6KAAcADyHB0AIv/9dYcMzfqHQ111v/zNGRCBcxXZSwV4yID0Iq6YAGEQckgAG2n4fkUQuw23aCbLDMdqFwtlXh63MmhYuoS17LCLjXNAUUAfACgdZy78phH///11f/zNGQ3BOQxfywBJgcDwALuWAAEAmgxd7v9LaPcBg1L81hTvD0CHIluDY0XFot+LevrYw7WIAQBcKdMOj136pAOA48FlaCiKP/zNGQzA/wdi3wgJhED2DKmQABUAFsyYl7gxBmYOtXykChn+aEhu72l/8Ysza/SIQAB6KABLXByn9drV1/Q3Z+v+1to0Exr8//zNGQ2A5wvYMQLAiADwDKyWABOAOAYUtUAgZPn19TSzma6m/p90nQUCACboP6YFq/o98Z4CSkYi23WySBvXAHAVZ1SRY5U1//zNGQ9A8AbiywIJhEDgIq9wBAGacvvqgOV6a1LfZXW/iMWDACgS2qwzv9VuB2ttwgg0C3bhahyHlma
class Ft {
constructor() {
this._bellContext = null, this._isMuteBell = !1, this._calleeBellFilePath = Pe, this._callRole = F.UNKNOWN, this._callStatus = h.IDLE, this._handleAudioInterruptionBegin = async () => {
await this.stop();
}, this._handleAudioInterruptionEnd = async () => {
this._callStatus !== h.CALLING ? await this.stop() : await this.play();
}, this._bellContext = wx.createInnerAudioContext(), this._addListenBellContextEvent(), this._bellContext.loop = !0;
}
setBellSrc() {
const e = wx.getFileSystemManager();
try {
let t = mt;
this._callRole === F.CALLEE && (t = this._calleeBellFilePath || Pe), e.readFileSync(t, "utf8", 0), this._bellContext.src = t;
} catch (t) {
console.warn(`${a.PREFIX}Failed to setBellSrc, ${t}`);
}
}
setBellProperties(e) {
this._callRole = e.callRole || this._callRole, this._callStatus = e.callStatus || this._callStatus, this._calleeBellFilePath = e.calleeBellFilePath || this._calleeBellFilePath, this._isMuteBell = Ne(e.isMuteBell) ? this._isMuteBell : e.isMuteBell;
}
async play() {
try {
if (this._callStatus !== h.CALLING)
return;
this.setBellSrc(), this._callRole === F.CALLEE && !this._isMuteBell && await this._bellContext.play(), this._callRole === F.CALLER && await this._bellContext.play();
} catch (e) {
console.warn(`${a.PREFIX}Failed to play audio file, ${e}`);
}
}
async stop() {
try {
this._bellContext.stop();
} catch (e) {
console.warn(`${a.PREFIX}Failed to stop audio file, ${e}`);
}
}
async setBellMute(e) {
this._callStatus !== h.CALLING && this._callRole !== F.CALLEE || (e ? await this.stop() : await this.play());
}
destroy() {
try {
this._isMuteBell = !1, this._calleeBellFilePath = "", this._callRole = F.UNKNOWN, this._callStatus = h.IDLE, this == null || this._removeListenBellContextEvent(), this._bellContext.destroy(), this._bellContext = null;
} catch (e) {
console.warn(`${a.PREFIX}Failed to destroy, ${e}`);
}
}
_addListenBellContextEvent() {
wx.onAudioInterruptionBegin(this._handleAudioInterruptionBegin), wx.onAudioInterruptionEnd(this._handleAudioInterruptionEnd);
}
_removeListenBellContextEvent() {
wx.offAudioInterruptionBegin(this._handleAudioInterruptionBegin), wx.offAudioInterruptionEnd(this._handleAudioInterruptionEnd);
}
}
function w() {
return function(r, e, t) {
const i = t.value, l = /* @__PURE__ */ new Set();
return t.value = async function(...o) {
var s, u;
if (l.has(this)) {
console.warn(`${a.PREFIX}previous ${e}() is ongoing, please avoid repeated calls`), (u = (s = this == null ? void 0 : this.getTUICallEngineInstance()) == null ? void 0 : s.reportLog) == null || u.call(s, {
name: "TUICallKit.avoidRepeatedCall.fail",
data: { name: e },
error: `previous ${e}() is ongoing`
});
return;
}
try {
l.add(this);
const c = await i.apply(this, o);
return l.delete(this), c;
} catch (c) {
throw l.delete(this), c;
}
}, t;
};
}
const ae = a.PREFIX + "API";
function y(r) {
return function(e, t, i) {
let l = i.value;
return i.value = function(...o) {
return yt.call(this, r, o, t), l.apply(this, o);
}, i;
};
}
function yt(r, e, t) {
try {
if (e[0].SDKAppID || (r = Gt(r, "SDKAppID", "sdkAppID")), je(r))
for (let i = 0; i < r.length; i++)
Ve.call(this, {
...r[i],
value: e[i],
name: t
});
else
for (const i in r)
r.hasOwnProperty(i) && Ve.call(this, {
...r[i],
value: e[0][i],
name: t,
key: i
});
} catch (i) {
throw console.error(i), i;
}
}
function Ve({ required: r, rules: e, range: t, value: i, allowEmpty: l, name: o, key: s }) {
if (Ne(i)) {
if (r)
throw new Error(`${ae}<${o}>: ${s} is required.`);
return;
}
const u = e.some((E) => E === Tt(i));
let c = "";
if (!u) {
for (let E = 0; E < e.length; E++) {
let I = e[E];
I = I.replace(I[0], I[0].toUpperCase()), c += `${I}/`;
}
throw c = c.substring(0, c.length - 1), new Error(`${ae}<${o}>: ${s} must be ${c}, current ${s} is ${typeof i}.`);
}
if (l === !1 && Be(i) && i.trim() === "")
throw new Error(`${ae}<${o}>: ${s} is blank.`);
if (je(t) && t && t.indexOf(i) === -1)
throw new Error(`${ae}<${o}>: ${s} error, only be ${t}, current ${s} is ${i}.`);
if (Be(t) && t.indexOf("~") !== -1) {
const E = t.split("~");
if (i < +E[0] || i > +E[1] || Ze(i) && Number.isNaN(i))
throw new Error(`${ae}<${o}>: ${s} error, only be ${t}, current ${s} is ${i}.`);
}
}
const M = {
init: {
SDKAppID: {
required: !0,
rules: [a.NUMBER],
allowEmpty: !1
},
userID: {
required: !0,
rules: [a.STRING],
allowEmpty: !1
},
userSig: {
required: !0,
rules: [a.STRING],
allowEmpty: !1
},
tim: {
required: !1,
rules: [a.OBJECT]
}
},
call: {
userID: {
required: !0,
rules: [a.STRING],
allowEmpty: !1
},
type: {
required: !0,
rules: [a.NUMBER],
range: [1, 2],
allowEmpty: !1
},
roomID: {
required: !1,
rules: [a.NUMBER],
// 仅支持数字房间号, 后续会支持字符串房间号
range: `0~${Fe}`,
allowEmpty: !1
},
strRoomID: {
required: !1,
rules: [a.STRING],
allowEmpty: !0
},
userData: {
required: !1,
rules: [a.STRING],
allowEmpty: !1
},
timeout: {
required: !1,
rules: [a.NUMBER],
allowEmpty: !1
}
},
groupCall: {
userIDList: {
required: !0,
rules: [a.ARRAY],
allowEmpty: !1
},
type: {
required: !0,
rules: [a.NUMBER],
range: [1, 2],
allowEmpty: !1
},
groupID: {
required: !0,
rules: [a.STRING],
allowEmpty: !1
},
roomID: {
required: !1,
rules: [a.NUMBER],
// 仅支持数字房间号, 后续会支持字符串房间号
range: `0~${Fe}`,
allowEmpty: !1
},
strRoomID: {
required: !1,
rules: [a.STRING],
allowEmpty: !0
},
timeout: {
required: !1,
rules: [a.NUMBER],
allowEmpty: !1
},
userData: {
required: !1,
rules: [a.STRING],
allowEmpty: !1
},
offlinePushInfo: {
required: !1,
rules: [a.OBJECT],
allowEmpty: !1
}
},
joinInGroupCall: {
type: {
required: !0,
rules: [a.NUMBER],
range: [1, 2],
allowEmpty: !1
},
groupID: {
required: !0,
rules: [a.STRING],
allowEmpty: !1
},
roomID: {
required: !0,
rules: [a.NUMBER],
allowEmpty: !1
},
strRoomID: {
required: !1,
rules: [a.STRING],
allowEmpty: !0
}
},
inviteUser: {
userIDList: {
required: !0,
rules: [a.ARRAY],
allowEmpty: !1
}
},
setSelfInfo: {
nickName: {
required: !1,
rules: [a.STRING],
allowEmpty: !1
},
avatar: {
required: !1,
rules: [a.STRING],
allowEmpty: !1
}
},
enableFloatWindow: [
{
key: "enable",
required: !1,
rules: [a.BOOLEAN],
allowEmpty: !1
}
],
enableAIVoice: [
{
key: "enable",
required: !0,
rules: [a.BOOLEAN],
allowEmpty: !1
}
],
enableMuteMode: [
{
key: "enable",
required: !0,
rules: [a.BOOLEAN],
allowEmpty: !1
}
],
setCallingBell: [
{
key: "filePath",
required: !1,
rules: [a.STRING],
allowEmpty: !0
}
],
setLanguage: [
{
key: "language",
required: !0,
rules: [a.STRING],
allowEmpty: !1
}
],
setVideoDisplayMode: [
{
key: "displayMode",
required: !0,
rules: [a.STRING],
range: [ne.CONTAIN, ne.COVER, ne.FILL],
allowEmpty: !1
}
],
setVideoResolution: [
{
key: "resolution",
required: !0,
rules: [a.STRING],
range: [oe.RESOLUTION_1080P, oe.RESOLUTION_480P, oe.RESOLUTION_720P],
allowEmpty: !1
}
]
};
function Le(r) {
return function(e, t, i) {
let l = i.value;
return i.value = function(...o) {
return Mt.call(this, r, o, t), l.apply(this, o);
}, i;
};
}
function Mt(r) {
if (r != null && r.engineInstance && !this._tuiCallEngine) {
const e = `${a.PREFIX} ${S("TUICallKit init is not complete")}`;
throw console.error(e), e;
}
}
function de(r) {
if (typeof r != "object" || r === null)
return r;
let e = Array.isArray(r) ? [] : {};
for (let t in r)
r.hasOwnProperty(t) && (e[t] = de(r[t]));
return e;
}
class vt {
constructor() {
this.defaultStore = {
callStatus: h.IDLE,
callRole: F.UNKNOWN,
callMediaType: g.UNKNOWN,
localUserInfo: { userId: "" },
localUserInfoExcludeVolume: { userId: "" },
remoteUserInfoList: [],
remoteUserInfoExcludeVolumeList: [],
callerUserInfo: { userId: "" },
isGroup: !1,
callDuration: "00:00:00",
// 通话时长
callTips: "",
// 通话提示的信息. 例如: '等待谁接听', 'xxx 拒绝通话', 'xxx 挂断通话'
toastInfo: { text: "" },
// 远端用户挂断、拒绝、超时、忙线等的 toast 提示信息
isMinimized: !1,
// 用来记录当前是否悬浮窗模式
enableFloatWindow: !1,
// 开启/关闭悬浮窗功能设置为false通话界面左上角的悬浮窗按钮会隐藏
bigScreenUserId: "",
// 当前大屏幕显示的 userID 用户
language: Rt(),
// en, zh-cn
isClickable: !1,
// 是否可点击, 用于按钮增加 loading 效果,不可点击
deviceList: { cameraList: [], microphoneList: [], currentCamera: {}, currentMicrophone: {} },
showPermissionTip: !1,
netWorkQualityList: [],
// 显示网络状态差的提示
isMuteSpeaker: !1,
groupID: "",
roomID: 0,
roomIdType: 0,
cameraPosition: se.FRONT,
// 前置或后置值为front, back
groupCallMembers: [],
// chat 群会话在的通话中的成员
// TUICallKit 组件上的属性
displayMode: ne.COVER,
// 设置预览远端的画面显示模式
videoResolution: oe.RESOLUTION_480P,
showSelectUser: !1,
// 小程序相关属性
pusher: {},
player: [],
isEarPhone: !1,
// 是否是听筒, 默认: false
pusherId: a.INITIAL_PUSHER,
// 重新渲染 live-Pusher 的标识位
// 是否开启虚拟背景, 目前仅 web 支持
isShowEnableVirtualBackground: !1,
// 是否显示虚拟背景图标, 默认: false
enableVirtualBackground: !1,
// 是否开启虚拟背景, 默认: false
// customUIConfig
customUIConfig: {
button: {},
viewBackground: {},
layoutMode: ke.RemoteInLargeView
}
}, this.store = de(this.defaultStore), this.prevStore = de(this.defaultStore);
}
update(e, t) {
switch (e) {
case a.CALL_TIPS:
const i = this.getData(e);
this.prevStore[e] = i;
default:
this.store[e] = t;
}
}
getPrevData(e) {
return e ? this.prevStore[e] : this.prevStore;
}
getData(e) {
return e ? this.store[e] : this.store;
}
// reset call store
reset(e = []) {
e.length === 0 && (e = Object.keys(this.store));
const t = e.reduce((i, l) => ({ ...i, [l]: this.defaultStore[l] }), {});
this.store = {
...this.defaultStore,
...this.store,
...t
};
}
}
let ge = class re {
constructor() {
this.timerId = -1, this.storeMap = {
[n.CALL]: new vt()
}, this.task = {};
}
/**
* 获取 TUIStore 实例
* @returns {TUIStore}
*/
static getInstance() {
return re.instance || (re.instance = new re()), re.instance;
}
/**
* UI 组件注册监听回调
* @param {StoreName} storeName store 名称
* @param {IOptions} options 监听信息
* @param {Object} params 扩展参数
* @param {String} params.notifyRangeWhenWatch 注册时监听时的通知范围, 'all' - 通知所有注册该 key 的监听; 'myself' - 通知本次注册该 key 的监听; 默认不通知
*/
watch(e, t, i) {
this.task[e] || (this.task[e] = {});
const l = this.task[e];
Object.keys(t).forEach((o) => {
const s = t[o];
l[o] || (l[o] = /* @__PURE__ */ new Map()), l[o].set(s, 1);
const { notifyRangeWhenWatch: u } = i || {};
if (u === a.ALL && this.notify(e, o), u === a.MYSELF) {
const c = this.getData(e, o);
s.call(this, c);
}
});
}
/**
* UI 取消组件监听回调
* @param {StoreName} storeName store 名称
* @param {IOptions} options 监听信息,包含需要取消的回掉等
*/
unwatch(e, t) {
if (!this.task[e])
return;
const i = this.task[e];
Object.keys(t).forEach((l) => {
i[l].delete(t[l]);
});
}
/**
* 通用 store 数据更新messageList 的变更需要单独处理
* @param {StoreName} storeName store 名称
* @param {string} key 变更的 key
* @param {unknown} data 变更的数据
*/
update(e, t, i) {
var l;
(Be(i) || Ze(i) || wt(i)) && this.storeMap[e].store[t] === i || ((l = this.storeMap[e]) == null || l.update(t, i), this.notify(e, t));
}
/**
* 获取 Store 的上一个状态值
* @param {StoreName} storeName store 名称
* @param {string} key 待获取的 key
* @returns {Any}
*/
getPrevData(e, t) {
var i;
return (i = this.storeMap[e]) == null ? void 0 : i.getPrevData(t);
}
/**
* 获取 Store 数据
* @param {StoreName} storeName store 名称
* @param {string} key 待获取的 key
* @returns {Any}
*/
getData(e, t) {
var i;
return (i = this.storeMap[e]) == null ? void 0 : i.getData(t);
}
/**
* UI 组件注册监听回调
* @param {StoreName} storeName store 名称
* @param {string} key 变更的 key
*/
notify(e, t) {
if (!this.task[e])
return;
const i = this.task[e];
if (i[t]) {
const l = i[t], o = this.getData(e, t);
for (const [s] of l.entries())
s.call(this, o);
}
}
reset(e, t = [], i = !1) {
if (e in this.storeMap) {
const l = this.storeMap[e];
t.length === 0 && (t = Object.keys(l == null ? void 0 : l.store)), l.reset(t), i && t.forEach((o) => {
this.notify(e, o);
});
}
}
// 批量修改多个 key-value
updateStore(e, t) {
const i = t || n.CALL;
Object.keys(e).forEach((l) => {
this.update(i, l, e[l]);
});
}
};
const p = ge.getInstance();
function we(r, e) {
const t = {
userId: r,
nick: "",
avatar: "",
remark: "",
displayUserInfo: "",
isAudioAvailable: !1,
isVideoAvailable: !1,
isEnter: !1,
domId: e || r
};
return e ? t : { ...t, isEnter: !1 };
}
async function Qt(r, e) {
var i, l, o, s, u;
let t = we(r, a.LOCAL_VIDEO);
try {
if (!e)
return t;
const c = await e.getMyProfile(), E = p == null ? void 0 : p.getData(n.CALL, a.LOCAL_USER_INFO);
return (c == null ? void 0 : c.code) === 0 && (t = {
...t,
...E,
userId: (i = c == null ? void 0 : c.data) == null ? void 0 : i.userID,
nick: (l = c == null ? void 0 : c.data) == null ? void 0 : l.nick,
avatar: (o = c == null ? void 0 : c.data) == null ? void 0 : o.avatar,
displayUserInfo: ((s = c == null ? void 0 : c.data) == null ? void 0 : s.nick) || ((u = c == null ? void 0 : c.data) == null ? void 0 : u.userID)
}), t;
} catch (c) {
return console.error(`${a.PREFIX}getMyProfile failed, error: ${c}.`), t;
}
}
async function Ae(r, e) {
let t = r.map((i) => we(i));
try {
if (!e)
return t;
const i = await e.getFriendProfile({ userIDList: r });
if (i.code === 0) {
const { friendList: l = [], failureUserIDList: o = [] } = i.data;
let s = o.map((I) => I.userID);
if (o.length > 0) {
const I = await e.getUserProfile({ userIDList: o.map((L) => L.userID) });
(I == null ? void 0 : I.code) === 0 && (s = (I == null ? void 0 : I.data) || []);
}
const u = p == null ? void 0 : p.getData(n.CALL, a.REMOTE_USER_INFO_LIST), c = l.map((I) => I.userID), E = s.map((I) => I.userID);
t = r.map((I) => {
var j, Z, $, ee, x, Re, Te;
const L = we(I), f = c.indexOf(I), U = E.indexOf(I);
let N = "", G = "", X = "", P = "";
f !== -1 && (N = ((j = l[f]) == null ? void 0 : j.remark) || "", G = (($ = (Z = l[f]) == null ? void 0 : Z.profile) == null ? void 0 : $.nick) || "", X = N || G || L.userId || "", P = ((x = (ee = l[f]) == null ? void 0 : ee.profile) == null ? void 0 : x.avatar) || ""), U !== -1 && (G = ((Re = s[U]) == null ? void 0 : Re.nick) || "", X = G || L.userId || "", P = ((Te = s[U]) == null ? void 0 : Te.avatar) || "");
const R = u.find((tt) => tt.userId === I) || {};
return { ...L, ...R, remark: N, nick: G, displayUserInfo: X, avatar: P };
});
}
return t;
} catch (i) {
return console.error(`${a.PREFIX}getRemoteUserProfile failed, error: ${i}.`), t;
}
}
function K(r, e, t) {
const i = p.getData(n.CALL, a.IS_GROUP);
let l = `${S(r)}`;
return i && (l = e ? `${e} ${l}` : l, l = t ? `${l} ${t}` : l), l;
}
function ue() {
const r = p.getData(n.CALL, a.CALL_STATUS);
if (r === h.IDLE)
return T.IDLE;
const e = p.getData(n.CALL, a.IS_GROUP);
if (r === h.CALLING)
return e ? T.DIALING_GROUP : T.DIALING_C2C;
const t = p.getData(n.CALL, a.CALL_MEDIA_TYPE);
return e ? t === g.AUDIO ? T.CALLING_GROUP_AUDIO : T.CALLING_GROUP_VIDEO : t === g.AUDIO ? T.CALLING_C2C_AUDIO : T.CALLING_C2C_VIDEO;
}
async function Pt(r, e, t, i) {
let l = [];
try {
const o = await e.getGroupMemberList({ groupID: r, count: t, offset: i });
if (o.code === 0)
return o.data.memberList || l;
} catch (o) {
return console.error(`${a.PREFIX}getGroupMember failed, error: ${o}.`), l;
}
}
async function Vt(r, e) {
let t = {};
try {
return (await e.getGroupProfile({ groupID: r })).data.group || t;
} catch (i) {
return console.warn(`${a.PREFIX}getGroupProfile failed, error: ${i}.`), t;
}
}
function et(r, e) {
r === 0 && e ? (p.update(n.CALL, a.ROOM_ID, e), p.update(n.CALL, a.ROOM_ID_TYPE, pe.STRING_ROOM_ID)) : (p.update(n.CALL, a.ROOM_ID, r), p.update(n.CALL, a.ROOM_ID_TYPE, pe.NUMBER_ROOM_ID));
}
function Q(r) {
return (r == null ? void 0 : r.data) || {};
}
function De(r) {
if (r.length === 0)
return;
let e = p.getData(n.CALL, a.REMOTE_USER_INFO_LIST);
r.forEach((t) => {
e = e.filter((i) => i.userId !== t);
}), p.update(n.CALL, a.REMOTE_USER_INFO_LIST, e), p.update(n.CALL, a.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, e);
}
function _e(r, e, t) {
if (Ot(r)) {
let i = "";
e === g.AUDIO && (i = K(O.NO_MICROPHONE_DEVICE_PERMISSION)), e === g.VIDEO && (i = K(O.NO_CAMERA_DEVICE_PERMISSION)), i && p.update(n.CALL, a.TOAST_INFO, { text: i, type: a.ERROR }), console.error(`${a.PREFIX}call failed, error: ${r.message}.`);
}
}
function k(r, e) {
let t = p.getData(n.CALL, a.LOCAL_USER_INFO);
e === a.AUDIO && (t = { ...t, isAudioAvailable: r }), e === a.VIDEO && (t = { ...t, isVideoAvailable: r }), p.update(n.CALL, a.LOCAL_USER_INFO, t), p.update(n.CALL, a.LOCAL_USER_INFO_EXCLUDE_VOLUMN, t);
}
class he {
static generateTaskID() {
return this.currentTaskID++;
}
/**
*
* @param {string} taskName 'interval' 'timeout'
* @param {function} callback
* @param {object} options include:
* @param {number} options.delay millisecond
* @param {number} options.count 定时器回调执行次数0 无限次 or n次
* @param {boolean} options.backgroundTask 在页面静默后是否继续执行定时器
*/
static run(e = a.TIMEOUT, t, i) {
e === a.INTERVAL ? i = { delay: 2e3, count: 0, backgroundTask: !0, ...i } : i = { delay: 2e3, count: 0, backgroundTask: !0, ...i }, Xe(t) && (i = { ...i, ...t }), Nt(e) && (t = e, e = a.TIMEOUT);
const l = {
taskID: this.generateTaskID(),
loopCount: 0,
intervalID: null,
timeoutID: null,
taskName: e,
callback: t,
...i
};
return this.taskMap.set(l.taskID, l), e === a.INTERNAL ? this.interval(l) : this.timeout(l), l.taskID;
}
/**
* 定时循环执行回调函数
* 可以指定循环的时间间隔
* 可以指定循环次数
* @param {object} taskItem
* @param {function} callback
* @param {*} delay
* @param {*} count
* @returns ID
*/
static interval(e) {
const t = () => {
e.callback(), e.loopCount += 1, this.isBreakLoop(e);
};
return e.intervalID = setInterval(t, e.delay);
}
/**
* 延迟执行回调
* count = 0,循环
* count = n, 执行n次
* @param {object} taskItem
*
*/
static timeout(e) {
const t = () => {
if (e.callback(), e.loopCount += 1, !this.isBreakLoop(e))
return e.timeoutID = setTimeout(t, e.delay);
};
return e.timeoutID = setTimeout(t, e.delay);
}
static hasTask(e) {
return this.taskMap.has(e);
}
static clearTask(e) {
if (!this.taskMap.has(e))
return !0;
const { intervalID: t, timeoutID: i, onVisibilitychange: l } = this.taskMap.get(e);
return t && clearInterval(t), i && clearTimeout(i), l && document.removeEventListener("visibilitychange", l), this.taskMap.delete(e), !0;
}
/**
* 1. 如果已移除出定时队列退出当前任务
* 2. 如果当前任务已满足次数限制则退出当前任务
* @param {object} taskItem
* @returns
*/
static isBreakLoop(e) {
return this.taskMap.has(e.taskID) ? e.count !== 0 && e.loopCount >= e.count ? (this.clearTask(e.taskID), !0) : !1 : !0;
}
}
he.taskMap = /* @__PURE__ */ new Map();
he.currentTaskID = 1;
const Kt = function(r) {
if (r === null || typeof r > "u")
return !0;
if (typeof r == "boolean")
return !1;
if (typeof r == "number")
return r === 0;
if (typeof r == "string" || typeof r == "function" || Array.isArray(r))
return r.length === 0;
if (r instanceof Error)
return r.message === "";
if (Xe(r)) {
for (const e in r)
if (Object.prototype.hasOwnProperty.call(r, e))
return !1;
return !0;
}
return !1;
}, Se = "_local_user_id";
class Y {
constructor() {
this._viewConfig = {
viewBackground: {
local: {},
remote: {}
}
}, this._isSetViewBackgroundConfig = { remote: !1, local: !1 }, this._tuiCallEngine = null, this._tuiStore = null;
}
static getInstance() {
return Y.instance || (Y.instance = new Y()), Y.instance;
}
_updateViewBackground() {
var i, l, o;
const e = (i = this._tuiStore) == null ? void 0 : i.getData(n.CALL, a.CUSTOM_UI_CONFIG), { userId: t } = (l = this._tuiStore) == null ? void 0 : l.getData(n.CALL, a.LOCAL_USER_INFO);
Object.keys(this._viewConfig.viewBackground.remote).includes(t) && delete this._viewConfig.viewBackground.remote[t], (o = this._tuiStore) == null || o.update(
n.CALL,
a.CUSTOM_UI_CONFIG,
{
...e,
viewBackground: {
...this._viewConfig.viewBackground.remote,
...this._viewConfig.viewBackground.local
}
}
);
}
setEngineInstance(e) {
this._tuiCallEngine = e;
}
setTUIStore(e) {
this._tuiStore = e;
}
updateViewBackgroundUserId(e) {
var t, i;
if (e === "local") {
const { userId: l } = (t = this._tuiStore) == null ? void 0 : t.getData(n.CALL, a.LOCAL_USER_INFO);
if (Object.keys(this._viewConfig.viewBackground.remote).includes(l) && (delete this._viewConfig.viewBackground.remote[l], this._updateViewBackground()), !this._isSetViewBackgroundConfig.local)
return;
const o = this._viewConfig.viewBackground.local, s = o[l] || o[Se];
o[l] = o[Se], this._viewConfig.viewBackground.local = { [l]: s }, this._updateViewBackground();
} else {
let l = this._viewConfig.viewBackground.remote;
this._isSetViewBackgroundConfig.remote && Object.keys(l).includes("*") && (((i = this._tuiStore) == null ? void 0 : i.getData(n.CALL, a.REMOTE_USER_INFO_LIST)).map((u) => u.userId).forEach((u) => {
Object.keys(l).includes(u) || (l[u] = l["*"]);
}), this._viewConfig.viewBackground.remote = l, this._updateViewBackground());
}
}
hideFeatureButton(e) {
var i, l, o, s, u;
(l = (i = this._tuiCallEngine) == null ? void 0 : i.reportLog) == null || l.call(i, {
name: "TUICallKit.hideFeatureButton.start",
data: { buttonName: e }
});
const t = (o = this._tuiStore) == null ? void 0 : o.getData(n.CALL, a.CUSTOM_UI_CONFIG);
(u = this._tuiStore) == null || u.update(
n.CALL,
a.CUSTOM_UI_CONFIG,
{
...t,
button: {
...t.button,
[e]: { ...((s = t.button) == null ? void 0 : s[e]) || {}, show: !1 }
}
}
);
}
setLocalViewBackgroundImage(e) {
var i, l, o;
(l = (i = this._tuiCallEngine) == null ? void 0 : i.reportLog) == null || l.call(i, {
name: "TUICallKit.setLocalViewBackgroundImage.start",
data: { url: e }
}), this._isSetViewBackgroundConfig.local = !0;
let { userId: t } = (o = this._tuiStore) == null ? void 0 : o.getData(n.CALL, a.LOCAL_USER_INFO);
Kt(t) && (t = Se), this._viewConfig.viewBackground.local = { [t]: e }, this._updateViewBackground();
}
setRemoteViewBackgroundImage(e, t) {
var i, l;
(l = (i = this._tuiCallEngine) == null ? void 0 : i.reportLog) == null || l.call(i, {
name: "TUICallKit.setRemoteViewBackgroundImage.start",
data: { userId: e, url: t }
}), this._isSetViewBackgroundConfig.remote = !0, e === "*" && (this._viewConfig.viewBackground.remote = {}), this._viewConfig.viewBackground.remote[e] = t, this._updateViewBackground();
}
setLayoutMode(e) {
var i, l;
(l = (i = this._tuiCallEngine) == null ? void 0 : i.reportLog) == null || l.call(i, {
name: "TUICallKit.setLayoutMode.start",
data: { layoutMode: e }
});
const t = this._tuiStore.getData(n.CALL, a.CUSTOM_UI_CONFIG);
this._tuiStore.update(
n.CALL,
a.CUSTOM_UI_CONFIG,
{
...t,
layoutMode: e
}
);
}
setCameraDefaultState(e) {
var i, l;
(l = (i = this._tuiCallEngine) == null ? void 0 : i.reportLog) == null || l.call(i, {
name: "TUICallKit.setCameraDefaultState.start",
data: { isOpen: e }
});
const t = de(this._tuiStore.getData(n.CALL, a.CUSTOM_UI_CONFIG));
Object.keys(t.button).includes(H.Camera) || (t.button[H.Camera] = {}), t.button[H.Camera].state = e ? q.Open : q.Close, this._tuiStore.update(n.CALL, a.CUSTOM_UI_CONFIG, t);
}
}
const Ie = ge.getInstance(), v = {
audioCall: () => S("Voice call"),
videoCall: () => S("Video call"),
switchToAudio: () => S("Switch audio call"),
switchToVideo: () => S("Switch video call"),
hangup: ({ callDuration: r }) => `${S("Call duration")}${r}`
};
class W {
constructor(e) {
var t, i, l;
this._callService = e.callService, te.registerEvent(B.TUILogin.EVENT.LOGIN_STATE_CHANGED, B.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS, this), (t = B.TUIChat) != null && t.EVENT && te.registerEvent((i = B.TUIChat.EVENT) == null ? void 0 : i.CHAT_STATE_CHANGED, (l = B.TUIChat.EVENT_SUB_KEY) == null ? void 0 : l.CHAT_OPENED, this), te.registerService(B.TUICalling.SERVICE.NAME, this), te.registerExtension(B.TUIChat.EXTENSION.INPUT_MORE.EXT_ID, this);
}
static getInstance(e) {
return W.instance || (W.instance = new W(e)), W.instance;
}
// ================ 【】 ================
/**
* message on screen
* @param {Any} params Parameters for message up-screening
*/
callTUIService(e) {
const { message: t } = e || {};
te.callService({
serviceName: B.TUIChat.SERVICE.NAME,
method: B.TUIChat.SERVICE.METHOD.UPDATE_MESSAGE_LIST,
params: { message: t }
});
}
/**
* tuicore getExtension
* @param {String} extensionID extension id
* @param {Any} params tuicore pass parameters
* @returns {Any[]} return extension
*/
onGetExtension(e, t) {
var i, l;
if (e === B.TUIChat.EXTENSION.INPUT_MORE.EXT_ID) {
if ((l = (i = this._callService.getTUICallEngineInstance()) == null ? void 0 : i.reportLog) == null || l.call(i, { name: "TUICallKit.onGetExtension", data: { extensionID: e, params: t } }), Ne(t))
return [];
if ([B.TUIChat.TYPE.ROOM, B.TUIChat.TYPE.CUSTOMER_SERVICE].includes(t.chatType))
return [];
let o = [];
const s = {
weight: 1e3,
text: "语音通话",
icon: st,
data: {
name: "voiceCall"
},
listener: {
onClicked: async (c) => await this._handleTUICoreOnClick(c, c.type || g.AUDIO)
}
}, u = {
weight: 900,
text: "视频通话",
icon: At,
data: {
name: "videoCall"
},
listener: {
onClicked: async (c) => await this._handleTUICoreOnClick(c, c.type || g.VIDEO)
}
};
return t != null && t.chatType ? o = [s, u] : (!(t != null && t.filterVoice) && o.push(s), !(t != null && t.filterVideo) && o.push(u)), o;
}
}
async onCall(e, t) {
e === B.TUICalling.SERVICE.METHOD.START_CALL && await this._handleTUICoreOnClick(t, t.type);
}
/**
* tuicore notify event manager
* @param {String} eventName event name
* @param {String} subKey sub key
* @param {Any} options tuicore event parameters
*/
async onNotifyEvent(e, t, i) {
var l, o, s, u, c, E, I, L;
try {
if (e === B.TUILogin.EVENT.LOGIN_STATE_CHANGED)
if (t === B.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS) {
const { chat: f, userID: U, userSig: N, SDKAppID: G } = it.getContext();
await ((l = this._callService) == null ? void 0 : l.init({ tim: f, userID: U, userSig: N, sdkAppID: G, isFromChat: !0, component: Ue.TIM_CALL_KIT })), (o = this._callService) == null || o.setIsFromChat(!0), (s = this._callService) == null || s.setLogLevel(Ye.NORMAL), this._addListenChatEvent();
} else
t === B.TUILogin.EVENT_SUB_KEY.USER_LOGOUT_SUCCESS && (this._removeListenChatEvent(), await ((u = this._callService) == null ? void 0 : u.destroyed()));
if ((c = B.TUIChat) != null && c.EVENT && e === B.TUIChat.EVENT.CHAT_STATE_CHANGED && t === B.TUIChat.EVENT_SUB_KEY.CHAT_OPENED) {
if ((E = this._callService) == null || E.setCurrentGroupId((i == null ? void 0 : i.groupID) || ""), Ie.getData(n.CALL, a.CALL_STATUS) !== h.IDLE)
return;
const f = (I = this._callService) == null ? void 0 : I.getCurrentGroupId(), U = f ? await this.getGroupAttributes((L = this._callService) == null ? void 0 : L.getTim(), f) : {};
await this.updateStoreBasedOnGroupAttributes(U);
}
} catch (f) {
console.error(`${a.PREFIX}TUICore onNotifyEvent failed, error: ${f}.`);
}
}
// Handling the chat+call scenario, data required for the joinInGroupCall API: update store / clear relevant store data
async updateStoreBasedOnGroupAttributes(e) {
var t, i, l, o;
(l = (i = (t = this._callService) == null ? void 0 : t.getTUICallEngineInstance()) == null ? void 0 : i.reportLog) == null || l.call(i, {
name: "TUICallKit.getJoinGroupCallInfo.success",
data: { groupAttributes: e }
});
try {
const {
group_id: s = "",
room_id: u = 0,
room_id_type: c = 0,
call_media_type: E = a.UNKNOWN,
// @ts-ignore
user_list: I
// The default value of the user list returned by the background is null
} = e[a.INNER_ATTR_KIT_INFO] ? JSON.parse(e[a.INNER_ATTR_KIT_INFO]) : {};
let L = (I || []).map((U) => U.userid);
L = L.length && await Ae(L, (o = this._callService) == null ? void 0 : o.getTim());
const f = {
[a.GROUP_ID]: s,
[a.GROUP_CALL_MEMBERS]: L,
[a.ROOM_ID]: u,
[a.CALL_MEDIA_TYPE]: rt[E],
[a.ROOM_ID_TYPE]: c
};
Ie.updateStore(f, n.CALL);
} catch (s) {
console.warn(`${a.PREFIX}updateStoreBasedOnGroupAttributes fail, error: ${s}`);
}
}
// Get group attribute
async getGroupAttributes(e, t) {
if (!t)
return {};
try {
const { data: i } = await e.getGroupAttributes({
groupID: t,
keyList: []
});
return (i == null ? void 0 : i.groupAttributes) || {};
} catch (i) {
return console.warn(`${a.PREFIX}getGroupAttributes fail: ${i}`), {};
}
}
isLineBusy(e) {
var l;
const t = ce(e.payload.data), i = ce(t == null ? void 0 : t.data);
return (i == null ? void 0 : i.line_busy) === "line_busy" || (i == null ? void 0 : i.line_busy) === "" || ((l = i == null ? void 0 : i.data) == null ? void 0 : l.message) === "lineBusy";
}
async getCallKitMessage(e, t) {
var f, U, N, G;
const i = ce(e.payload.data);
if ((i == null ? void 0 : i.businessID) !== 1)
return {};
let l = "";
const o = ce(i == null ? void 0 : i.data), s = o.call_type, u = i.inviteeList, c = (f = o == null ? void 0 : o.data) == null ? void 0 : f.inviter, E = Ie.getData(n.CALL, a.LOCAL_USER_INFO).userId, I = c === E, L = (U = o == null ? void 0 : o.data) == null ? void 0 : U.cmd;
switch (i == null ? void 0 : i.actionType) {
case J.INVITE: {
l = v[L]({ callDuration: $e(o == null ? void 0 : o.call_end) });
break;
}
case J.CANCEL_INVITE:
l = S(I ? "Call Cancel" : "Other Side Cancel");
break;
case J.ACCEPT_INVITE:
["switchToAudio", "switchToVideo"].includes(L) ? l = (N = v == null ? void 0 : v[L]) == null ? void 0 : N.call(v) : l = S("Answered");
break;
case J.REJECT_INVITE:
this.isLineBusy(e) ? l = S(I ? "Line Busy" : "Other Side Line Busy") : l = S(I ? "Other Side Decline" : "Decline");
break;
case J.INVITE_TIMEOUT:
["switchToAudio", "switchToVideo"].includes(L) ? l = (G = v == null ? void 0 : v[L]) == null ? void 0 : G.call(v) : l = S(I ? "Other Side No Answer" : "No answer");
break;
}
return { messageCardContent: l, callMediaType: s, inviteeList: u };
}
// =========================【chat: event listening】=========================
_addListenChatEvent() {
var e, t;
if (!((e = this._callService) != null && e.getTim())) {
console.warn(`${a.PREFIX}add tim event listener failed, tim is empty.`);
return;
}
(t = this._callService) == null || t.getTim().on(Ge.EVENT.GROUP_ATTRIBUTES_UPDATED, this._handleGroupAttributesUpdated, this);
}
_removeListenChatEvent() {
var e, t;
if (!((e = this._callService) != null && e.getTim())) {
console.warn(`${a.PREFIX}remove tim event listener failed, tim is empty.`);
return;
}
(t = this._callService) == null || t.getTim().off(Ge.EVENT.GROUP_ATTRIBUTES_UPDATED, this._handleGroupAttributesUpdated, this);
}
/**
* chat start audio/video call via click
* @param {Any} options Parameters passed in when clicking on an audio/video call from chat
* @param {CallMediaType} type call media type. 0 - audio; 1 - video.
*/
async _handleTUICoreOnClick(e, t) {
var i, l;
try {
const { groupID: o, userIDList: s = [], ...u } = e;
o ? await ((i = this._callService) == null ? void 0 : i.groupCall({ groupID: o, userIDList: s, type: t, ...u })) : s.length === 1 && await ((l = this._callService) == null ? void 0 : l.call({ userID: s[0], type: t, ...u }));
} catch (o) {
console.debug(o);
}
}
async _handleGroupAttributesUpdated(e) {
var o;
if (Ie.getData(n.CALL, a.CALL_STATUS) !== h.IDLE)
return;
const t = (e == null ? void 0 : e.data) || {}, { groupID: i = "", groupAttributes: l = {} } = t;
i === ((o = this._callService) == null ? void 0 : o.getCurrentGroupId()) && await this.updateStoreBasedOnGroupAttributes(l);
}
}
const d = ge.getInstance(), bt = Y.getInstance();
class z {
constructor(e) {
this._callService = e.callService;
}
static getInstance(e) {
return z.instance || (z.instance = new z(e)), z.instance;
}
addListenTuiCallEngineEvent() {
var t;
const e = (t = this._callService) == null ? void 0 : t.getTUICallEngineInstance();
if (!e) {
console.warn(`${a.PREFIX}add engine event listener failed, engine is empty.`);
return;
}
e.on(C.ERROR, this._handleError, this), e.on(C.INVITED, this._handleNewInvitationReceived, this), e.on(C.USER_ACCEPT, this._handleUserAccept, this), e.on(C.USER_ENTER, this._handleUserEnter, this), e.on(C.USER_LEAVE, this._handleUserLeave, this), e.on(C.REJECT, this._handleInviteeReject, this), e.on(C.NO_RESP, this._handleNoResponse, this), e.on(C.LINE_BUSY, this._handleLineBusy, this), e.on(C.CALLING_CANCEL, this._handleCallingCancel, this), e.on(C.SDK_READY, this._handleSDKReady, this), e.on(C.KICKED_OUT, this._handleKickedOut, this), e.on(C.MESSAGE_SENT_BY_ME, this._messageSentByMe, this), C.CALL_MESSAGE && e.on(C.CALL_MESSAGE, this._handleCallMessage, this), C.ON_USER_NETWORK_QUALITY_CHANGED && e.on(C.ON_USER_NETWORK_QUALITY_CHANGED, this._handleNetworkQuality, this), e.on(C.CALL_END, this._handleCallingEnd, this), e.on(C.CALL_MODE, this._handleCallTypeChange, this), e.on(C.USER_UPDATE, this._handleUserUpdate, this);
}
removeListenTuiCallEngineEvent() {
var t;
const e = (t = this._callService) == null ? void 0 : t.getTUICallEngineInstance();
e.off(C.ERROR, this._handleError, this), e.off(C.INVITED, this._handleNewInvitationReceived, this), e.off(C.USER_ACCEPT, this._handleUserAccept, this), e.off(C.USER_ENTER, this._handleUserEnter, this), e.off(C.USER_LEAVE, this._handleUserLeave, this), e.off(C.REJECT, this._handleInviteeReject, this), e.off(C.NO_RESP, this._handleNoResponse, this), e.off(C.LINE_BUSY, this._handleLineBusy, this), e.off(C.CALLING_CANCEL, this._handleCallingCancel, this), e.off(C.SDK_READY, this._handleSDKReady, this), e.off(C.KICKED_OUT, this._handleKickedOut, this), e.off(C.MESSAGE_SENT_BY_ME, this._messageSentByMe, this), C.ON_USER_NETWORK_QUALITY_CHANGED && e.off(C.ON_USER_NETWORK_QUALITY_CHANGED, this._handleNetworkQuality, this), e.off(C.CALL_END, this._handleCallingEnd, this), e.off(C.CALL_MODE, this._handleCallTypeChange, this), e.off(C.USER_UPDATE, this._handleUserUpdate, this);
}
_callerChangeToConnected() {
var i;
const e = d.getData(n.CALL, a.CALL_ROLE);
d.getData(n.CALL, a.CALL_STATUS) === h.CALLING && e === F.CALLER && (d.update(n.CALL, a.CALL_STATUS, h.CONNECTED), (i = this._callService) == null || i.startTimer());
}
_unNormalEventsManager(e, t) {
var o;
console.log(`${a.PREFIX}${t} event data: ${JSON.stringify(e)}.`);
const i = d.getData(n.CALL, a.IS_GROUP), l = d.getData(n.CALL, a.REMOTE_USER_INFO_LIST);
switch (t) {
case C.REJECT:
case C.LINE_BUSY: {
const { userID: s } = Q(e);
let u = t === C.REJECT ? O.OTHER_SIDE_REJECT_CALL : O.OTHER_SIDE_LINE_BUSY, c = K(u);
if (i) {
const E = (l.find((I) => I.userId === s) || {}).displayUserInfo || s;
u = t === C.REJECT ? O.REJECT_CALL : O.IN_BUSY, c = K(u, E);
}
d.update(n.CALL, a.TOAST_INFO, { text: c }), s && De([s]);
break;
}
case C.NO_RESP: {
const { userIDList: s = [] } = Q(e), u = i ? O.TIMEOUT : O.CALL_TIMEOUT, c = s.map((I) => (l.find((f) => f.userId === I) || {}).displayUserInfo || I), E = i ? K(u, c.join()) : K(u);
d.update(n.CALL, a.TOAST_INFO, { text: E }), s.length > 0 && De(s);
break;
}
case C.CALLING_CANCEL: {
(o = this._callService) == null || o._resetCallStore();
break;
}
}
}
_handleError(e) {
var s;
const { code: t, message: i } = e || {}, l = Object.values(me).indexOf(t);
let o = "";
if (l !== -1) {
const u = Object.keys(me)[l];
o = S(lt[u]), o && d.update(n.CALL, a.TOAST_INFO, { text: o, type: a.ERROR });
}
(s = this._callService) == null || s.executeExternalAfterCalling(), console.error(`${a.PREFIX}_handleError, errorCode: ${t}; errorMessage: ${o || i}.`);
}
async _handleNewInvitationReceived(e) {
var j, Z, $, ee;
console.log(`${a.PREFIX}onCallReceived event data: ${JSON.stringify(e)}.`);
const { sponsor: t = "", isFromGroup: i, callMediaType: l, inviteData: o = {}, calleeIdList: s = [], groupID: u = "", roomID: c, strRoomID: E } = Q(e), I = d.getData(n.CALL, a.LOCAL_USER_INFO), L = [t, ...s.filter((x) => x !== I.userId)], f = l || o.callType, U = f === g.AUDIO ? O.CALLEE_CALLING_AUDIO_MSG : O.CALLEE_CALLING_VIDEO_MSG;
let N = {
[a.CALL_ROLE]: F.CALLEE,
[a.IS_GROUP]: i,
[a.CALL_STATUS]: h.CALLING,
[a.CALL_MEDIA_TYPE]: f,
[a.CALL_TIPS]: S(U),
[a.CALLER_USER_INFO]: { userId: t },
[a.GROUP_ID]: u
};
He();
const G = { enableCamera: f === g.VIDEO, enableMic: !0 };
N = { ...N, [a.PUSHER]: G };
const X = {
microphone: !0,
camera: f === g.VIDEO
};
this._callService._preDevicePermission = await this._callService._tuiCallEngine.deviceCheck(X), et(c, E), d.updateStore(N, n.CALL), (j = this._callService) == null || j.executeExternalBeforeCalling(), (Z = this._callService) != null && Z.statusChanged && (($ = this._callService) == null || $.statusChanged({ oldStatus: T.IDLE, newStatus: T.BE_INVITED }));
const P = await Ae(L, (ee = this._callService) == null ? void 0 : ee.getTim()), [R] = P.filter((x) => x.userId === t);
P.length > 0 && d.updateStore({
[a.REMOTE_USER_INFO_LIST]: P,
[a.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST]: P,
[a.CALLER_USER_INFO]: {
userId: t,
nick: (R == null ? void 0 : R.nick) || "",
avatar: (R == null ? void 0 : R.avatar) || "",
displayUserInfo: (R == null ? void 0 : R.remark) || (R == null ? void 0 : R.nick) || t
}
}, n.CALL);
}
_handleUserAccept(e) {
this._callerChangeToConnected(), d.update(n.CALL, a.TOAST_INFO, S("answered")), console.log(`${a.PREFIX}accept event data: ${JSON.stringify(e)}.`);
}
async _handleUserEnter(e) {
var s;
this._callerChangeToConnected();
const { userID: t, data: i } = Q(e);
i != null && i.playerList && d.update(n.CALL, a.PLAYER, i.playerList);
let l = d.getData(n.CALL, a.REMOTE_USER_INFO_LIST);
if (!l.find((u) => (u == null ? void 0 : u.userId) === t)) {
l.push({ userId: t }), l.length > 0 && (d.update(n.CALL, a.REMOTE_USER_INFO_LIST, l), d.update(n.CALL, a.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, l));
const [u] = await Ae([t], (s = this._callService) == null ? void 0 : s.getTim());
l = d.getData(n.CALL, a.REMOTE_USER_INFO_LIST), l.forEach((c) => {
(c == null ? void 0 : c.userId) === t && (c = Object.assign(c, u));
});
}
l = l.map((u) => (u.userId === t && (u.isEnter = !0), u)), l.length > 0 && (d.update(n.CALL, a.REMOTE_USER_INFO_LIST, l), d.update(n.CALL, a.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, l), bt.updateViewBackgroundUserId("remote")), console.log(`${a.PREFIX}userEnter event data: ${JSON.stringify(e)}.`);
}
_handleUserLeave(e) {
console.log(`${a.PREFIX}userLeave event data: ${JSON.stringify(e)}.`);
const { data: t, userID: i } = Q(e);
if (t != null && t.playerList && d.update(n.CALL, a.PLAYER, t.playerList), d.getData(n.CALL, a.IS_GROUP)) {
const o = (d.getData(n.CALL, a.REMOTE_USER_INFO_LIST).find((u) => u.userId === i) || {}).displayUserInfo || i, s = K(O.END_CALL, o);
d.update(n.CALL, a.TOAST_INFO, { text: s });
}
i && De([i]);
}
_handleInviteeReject(e) {
this._unNormalEventsManager(e, C.REJECT);
}
_handleNoResponse(e) {
this._unNormalEventsManager(e, C.NO_RESP);
}
_handleLineBusy(e) {
this._unNormalEventsManager(e, C.LINE_BUSY);
}
_handleCallingCancel(e) {
var t;
(t = this._callService) == null || t.executeExternalAfterCalling(), this._unNormalEventsManager(e, C.CALLING_CANCEL);
}
_handleCallingEnd(e) {
var t, i;
console.log(`${a.PREFIX}callEnd event data: ${JSON.stringify(e)}.`), (t = this._callService) == null || t.executeExternalAfterCalling(), (i = this._callService) == null || i._resetCallStore();
}
// SDK_READY 后才能调用 tim 接口, 否则登录后立刻获取导致调用接口失败. v2.27.4+、v3 接口 login 后会抛出 SDK_READY
async _handleSDKReady(e) {
var i, l, o;
let t = d.getData(n.CALL, a.LOCAL_USER_INFO);
t = await Qt(t.userId, (i = this._callService) == null ? void 0 : i.getTim()), (o = this._callService) == null || o.setDefaultOfflinePushInfo({ ...(l = this._callService) == null ? void 0 : l.getDefaultOfflinePushInfo(), title: t == null ? void 0 : t.displayUserInfo }), d.update(n.CALL, a.LOCAL_USER_INFO, t), d.update(n.CALL, a.LOCAL_USER_INFO_EXCLUDE_VOLUMN, t);
}
_handleKickedOut(e) {
var t, i, l;
console.log(`${a.PREFIX}kickOut event data: ${JSON.stringify(e)}.`), (t = this._callService) != null && t.kickedOut && ((i = this._callService) == null || i.kickedOut(e)), d.update(n.CALL, a.CALL_TIPS, K(O.KICK_OUT)), (l = this._callService) == null || l._resetCallStore();
}
_messageSentByMe(e) {
var i, l;
const t = e == null ? void 0 : e.data;
(i = this._callService) != null && i.onMessageSentByMe && ((l = this._callService) == null || l.onMessageSentByMe(t));
}
_handleCallMessage(e) {
const t = Q(e);
this._callService._chatCombine.callTUIService({ message: t });
}
_handleCallTypeChange(e) {
var l;
const { newCallType: t, type: i } = Q(e);
d.update(n.CALL, a.CALL_MEDIA_TYPE, t || i), (l = this._callService) == null || l.setSoundMode(m.EAR);
}
_handleNetworkQuality(e) {
const { networkQualityList: t = [] } = Q(e);
d.update(n.CALL, a.NETWORK_STATUS, t);
const i = d.getData(n.CALL, a.IS_GROUP), l = d.getData(n.CALL, a.LOCAL_USER_INFO), o = d.getData(n.CALL, a.REMOTE_USER_INFO_LIST);
if (!i) {
if (t.find((c) => {
var E;
return ((E = o[0]) == null ? void 0 : E.userId) === (c == null ? void 0 : c.userId) && (c == null ? void 0 : c.quality) >= ye;
})) {
d.update(n.CALL, a.CALL_TIPS, S(O.REMOTE_NETWORK_IS_POOR));
return;
}
if (t.find((c) => (l == null ? void 0 : l.userId) === (c == null ? void 0 : c.userId) && (c == null ? void 0 : c.quality) >= ye)) {
d.update(n.CALL, a.CALL_TIPS, S(O.LOCAL_NETWORK_IS_POOR));
return;
}
}
}
// ==========================【 miniProgram 私有事件】==========================
_handleUserUpdate(e) {
const t = Q(e);
t != null && t.pusher && d.update(n.CALL, a.PUSHER, t.pusher), t != null && t.playerList && d.update(n.CALL, a.PLAYER, t.playerList);
}
}
var kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, _ = (r, e, t, i) => {
for (var l = i > 1 ? void 0 : i ? Yt(e, t) : e, o = r.length - 1, s; o >= 0; o--)
(s = r[o]) && (l = (i ? s(e, t, l) : s(l)) || l);
return i && l && kt(e, t, l), l;
};
const zt = qe.getInstance(), A = ge.getInstance(), V = Y.getInstance();
V.setTUIStore(A);
const Ke = "3.3.6", D = class le {
constructor() {
this._tim = null, this._TUICore = null, this._timerId = -1, this._startTimeStamp = fe(), this._bellContext = null, this._isFromChat = !1, this._currentGroupId = "", this._preDevicePermission = !1, this._defaultOfflinePushInfo = {
title: "",
description: S("you have a new call")
}, this._permissionCheckTimer = null, this._chatCombine = null, this._engineEventHandler = null, this._handleCallStatusChange = async (e) => {
var t, i, l, o;
try {
const s = {
callRole: A.getData(n.CALL, a.CALL_ROLE),
callStatus: A.getData(n.CALL, a.CALL_STATUS)
};
if (this._bellContext.setBellProperties(s), e === h.CALLING)
await ((t = this == null ? void 0 : this._bellContext) == null ? void 0 : t.play());
else {
if (e === h.CONNECTED) {
const u = A.getData(n.CALL, a.IS_GROUP), c = A.getData(n.CALL, a.CALL_MEDIA_TYPE), E = A.getData(n.CALL, a.REMOTE_USER_INFO_LIST), I = u ? T.DIALING_GROUP : T.DIALING_C2C;
A.update(n.CALL, a.CALL_TIPS, ""), this.statusChanged && this.statusChanged({ oldStatus: I, newStatus: ue() }), !u && c === g.VIDEO && this.switchScreen(E[0].domId);
}
if (e === h.IDLE && this._isFromChat) {
const u = this._currentGroupId ? await ((i = this._chatCombine) == null ? void 0 : i.getGroupAttributes(this._tim, this._currentGroupId)) : {};
await ((l = this._chatCombine) == null ? void 0 : l.updateStoreBasedOnGroupAttributes(u, A, this));
}
await ((o = this == null ? void 0 : this._bellContext) == null ? void 0 : o.stop());
}
} catch (s) {
console.warn(`${a.PREFIX}handleCallStatusChange, ${s}.`);
}
}, console.log(`${a.PREFIX}version: ${Ke}`), this._watchTUIStore(), this._engineEventHandler = z.getInstance({ callService: this }), this._chatCombine = W.getInstance({ callService: this });
}
static getInstance() {
return le.instance || (le.instance = new le()), le.instance;
}
async init(e) {
var t, i;
try {
if (this._tuiCallEngine)
return;
let { userID: l, tim: o, userSig: s, sdkAppID: u, SDKAppID: c, isFromChat: E, component: I = Ue.TUI_CALL_KIT } = e;
this._TUICore && (u = this._TUICore.SDKAppID, o = this._TUICore.tim), this._tim = o, console.log(`${a.PREFIX}init sdkAppId: ${u || c}, userId: ${l}`), this._tuiCallEngine = at.createInstance({
tim: o,
// @ts-ignore
sdkAppID: u || c,
// 兼容传入 SDKAppID 的问题
callkitVersion: Ke,
chat: E || !1,
component: I
}), V.setEngineInstance(this._tuiCallEngine), this._addListenTuiCallEngineEvent(), this._bellContext = new Ft(), A.update(n.CALL, a.LOCAL_USER_INFO, { userId: l }), A.update(n.CALL, a.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { userId: l }), V.updateViewBackgroundUserId("local"), await this._tuiCallEngine.login({ userID: l, userSig: s, assetsPath: "" });
const L = A.getData(n.CALL, a.CUSTOM_UI_CONFIG);
(i = (t = this._tuiCallEngine) == null ? void 0 : t.reportLog) == null || i.call(t, {
name: "TUICallkit.init",
data: {
uiConfig: L
}
});
} catch (l) {
throw console.error(`${a.PREFIX}init failed, error: ${l}.`), l;
}
}
// component destroy
async destroyed() {
var e;
try {
const t = A.getData(n.CALL, a.CALL_STATUS);
if (t !== h.IDLE)
throw new Error(`please destroyed when status is idle, current status: ${t}`);
this._tuiCallEngine && (this._removeListenTuiCallEngineEvent(), await this._tuiCallEngine.destroyInstance(), this._tuiCallEngine = null), (e = this._bellContext) == null || e.destroy(), this._bellContext = null;
} catch (t) {
throw console.error(`${a.PREFIX}destroyed failed, error: ${t}.`), t;
}
}
async call(e) {
if (A.getData(n.CALL, a.CALL_STATUS) === h.IDLE)
try {
const { type: t, userID: i, offlinePushInfo: l } = e;
if (A.getData(n.CALL, a.CALL_STATUS) !== h.IDLE)
return;
await this._updateCallStoreBeforeCall(t, [{ userId: i }]), this.executeExternalBeforeCalling(), e.offlinePushInfo = { ...this._defaultOfflinePushInfo, ...l };
const o = await this._tuiCallEngine.call(e);
await this._updateCallStoreAfterCall([i], o);
} catch (t) {
this._handleCallError(t, "call");
}
}
async groupCall(e) {
if (A.getData(n.CALL, a.CALL_STATUS) === h.IDLE)
try {
const { userIDList: t, type: i, groupID: l, offlinePushInfo: o } = e;
if (A.getData(n.CALL, a.CALL_STATUS) !== h.IDLE)
return;
const s = t.map((c) => ({ userId: c }));
await this._updateCallStoreBeforeCall(i, s, l), this.executeExternalBeforeCalling(), e.offlinePushInfo = { ...this._defaultOfflinePushInfo, ...o };
const u = await this._tuiCallEngine.groupCall(e);
await this._updateCallStoreAfterCall(t, u);
} catch (t) {
this._handleCallError(t, "groupCall");
}
}
async inviteUser(e) {
if (A.getData(n.CALL, a.CALL_STATUS) !== h.IDLE)
try {
const { userIDList: t } = e;
let i = await Ae(t, this.getTim());
const l = A.getData(n.CALL, a.REMOTE_USER_INFO_LIST);
A.update(n.CALL, a.REMOTE_USER_INFO_LIST, [...l, ...i]), A.update(n.CALL, a.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, [...l, ...i]), this._tuiCallEngine && await this._tuiCallEngine.inviteUser(e);
} catch (t) {
throw console.error(`${a.PREFIX}inviteUser failed, error: ${t}.`), this._resetCallStore(), t;
}
}
async joinInGroupCall(e) {
if (A.getData(n.CALL, a.CALL_STATUS) !== h.CONNECTED)
try {
const t = {
[a.CALL_ROLE]: F.CALLEE,
[a.IS_GROUP]: !0,
[a.CALL_STATUS]: h.CONNECTED,
[a.CALL_MEDIA_TYPE]: e.type,
[a.GROUP_ID]: e.groupID,
[a.ROOM_ID]: e.roomID
};
A.updateStore(t, n.CALL);
const i = await this._tuiCallEngine.joinInGroupCall(e), l = this._getFeatureButtonDefaultState(H.Camera) === q.Close;
e.type === g.VIDEO && !l && await this.openCamera(a.LOCAL_VIDEO), A.update(n.CALL, a.IS_CLICKABLE, !0), this.startTimer(), A.update(n.CALL, a.PUSHER, i), this.setSoundMode(e.type === g.AUDIO ? m.EAR : m.SPEAKER);
const o = A.getData(n.CALL, a.LOCAL_USER_INFO);
A.update(n.CALL, a.LOCAL_USER_INFO, { ...o, isEnter: !0 }), A.update(n.CALL, a.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { ...o, isEnter: !0 }), k(!0, a.AUDIO);
} catch (t) {
this._handleCallError(t, "joinInGroupCall");
}
}
// ===============================【其它对外接口】===============================
getTUICallEngineInstance() {
return (this == null ? void 0 : this._tuiCallEngine) || null;
}
setLogLevel(e) {
var t;
(t = this == null ? void 0 : this._tuiCallEngine) == null || t.setLogLevel(e);
}
setLanguage(e) {
e && Object.values(be).includes(e) && A.update(n.CALL, a.LANGUAGE, e);
}
enableFloatWindow(e) {
A.update(n.CALL, a.ENABLE_FLOAT_WINDOW, e);
}
async setSelfInfo(e) {
const { nickName: t, avatar: i } = e;
try {
await this._tuiCallEngine.setSelfInfo(t, i);
} catch (l) {
console.error(`${a.PREFIX}setSelfInfo failed, error: ${l}.`);
}
}
async enableVirtualBackground(e) {
A.update(n.CALL, a.IS_SHOW_ENABLE_VIRTUAL_BACKGROUND, e);
}
async setCallingBell(e) {
const t = { calleeBellFilePath: e };
this._bellContext.setBellProperties(t);
}
async enableMuteMode(e) {
try {
const t = { isMuteBell: e };
this._bellContext.setBellProperties(t), await this._bellContext.setBellMute(e);
} catch (t) {
console.warn(`${a.PREFIX}enableMuteMode failed, error: ${t}.`);
}
}
hideFeatureButton(e) {
V.hideFeatureButton(e);
}
setLocalViewBackgroundImage(e) {
V.setLocalViewBackgroundImage(e);
}
setRemoteViewBackgroundImage(e, t) {
V.setRemoteViewBackgroundImage(e, t);
}
setLayoutMode(e) {
V.setLayoutMode(e);
}
setCameraDefaultState(e) {
V.setCameraDefaultState(e);
}
async accept() {
var t, i, l, o, s, u;
const e = A.getData(n.CALL, a.CALL_STATUS);
if ((i = (t = this._tuiCallEngine) == null ? void 0 : t.reportLog) == null || i.call(t, {
name: "TUICallKit.accept.start",
data: { callStatus: e }
}), e !== h.CONNECTED)
try {
const E = {
microphone: !0,
camera: A.getData(n.CALL, a.CALL_MEDIA_TYPE) === g.VIDEO
}, I = await this._tuiCallEngine.deviceCheck(E);
I && !this._preDevicePermission && (A.update(n.CALL, a.PUSHER_ID, a.NEW_PUSHER), this._preDevicePermission = I);
const L = await this._tuiCallEngine.accept();
if (L) {
A.update(n.CALL, a.CALL_STATUS, h.CONNECTED), (o = this._chatCombine) == null || o.callTUIService({ message: (l = L == null ? void 0 : L.data) == null ? void 0 : l.message }), A.update(n.CALL, a.IS_CLICKABLE, !0), this.startTimer();
const f = A.getData(n.CALL, a.CALL_MEDIA_TYPE), U = this._getFeatureButtonDefaultState(H.Camera) === q.Close;
f === g.VIDEO && !U && await this.openCamera(a.LOCAL_VIDEO), L.pusher && A.update(n.CALL, a.PUSHER, L.pusher), this.setSoundMode(f === g.AUDIO ? m.EAR : m.SPEAKER);
const N = A.getData(n.CALL, a.LOCAL_USER_INFO);
A.update(n.CALL, a.LOCAL_USER_INFO, { ...N, isEnter: !0 }), A.update(n.CALL, a.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { ...N, isEnter: !0 }), k(!0, a.AUDIO);
}
} catch (c) {
if ((u = (s = this._tuiCallEngine) == null ? void 0 : s.reportLog) == null || u.call(s, {
name: "TUICallKit.accept.fail",
level: "error",
error: c
}), Qe(c))
return;
_e(c, g.AUDIO, this._tuiCallEngine), this._resetCallStore();
}
}
async hangup() {
if (A.getData(n.CALL, a.CALL_STATUS) !== h.IDLE) {
try {
const e = await this._tuiCallEngine.hangup();
e == null || e.forEach((t) => {
var i, l;
(t == null ? void 0 : t.code) === 0 && ((l = this._chatCombine) == null || l.callTUIService({ message: (i = t == null ? void 0 : t.data) == null ? void 0 : i.message }));
});
} catch (e) {
console.debug(e);
}
this._resetCallStore();
}
}
async reject() {
var e, t;
if (A.getData(n.CALL, a.CALL_STATUS) !== h.IDLE) {
try {
const i = await this._tuiCallEngine.reject();
(i == null ? void 0 : i.code) === 0 && ((t = this._chatCombine) == null || t.callTUIService({ message: (e = i == null ? void 0 : i.data) == null ? void 0 : e.message }));
} catch (i) {
console.debug(i);
}
this._resetCallStore();
}
}
async openCamera(e) {
try {
await this._tuiCallEngine.openCamera(), k(!0, a.VIDEO);
} catch (t) {
_e(t, g.VIDEO, this._tuiCallEngine), console.error(`${a.PREFIX}openCamera error: ${t}.`);
}
}
async closeCamera() {
try {
await this._tuiCallEngine.closeCamera(), k(!1, a.VIDEO);
} catch (e) {
console.error(`${a.PREFIX}closeCamera error: ${e}.`);
}
}
async openMicrophone() {
try {
await this._tuiCallEngine.openMicrophone(), k(!0, a.AUDIO);
} catch (e) {
console.error(`${a.PREFIX}openMicrophone failed, error: ${e}.`);
}
}
async closeMicrophone() {
try {
await this._tuiCallEngine.closeMicrophone(), k(!1, a.AUDIO);
} catch (e) {
console.error(`${a.PREFIX}closeMicrophone failed, error: ${e}.`);
}
}
switchScreen(e) {
e && A.update(n.CALL, a.BIG_SCREEN_USER_ID, e);
}
async switchCallMediaType() {
var e, t;
try {
const i = A.getData(n.CALL, a.CALL_MEDIA_TYPE);
if (i === g.AUDIO) {
console.warn(`${a.PREFIX}switchCallMediaType failed, ${i} not support.`);
return;
}
const l = await this._tuiCallEngine.switchCallMediaType(g.AUDIO);
(l == null ? void 0 : l.code) === 0 && ((t = this._chatCombine) == null || t.callTUIService({ message: (e = l == null ? void 0 : l.data) == null ? void 0 : e.message })), A.update(n.CALL, a.CALL_MEDIA_TYPE, g.AUDIO);
const s = A.getData(n.CALL, a.IS_GROUP) ? T.CALLING_GROUP_VIDEO : T.CALLING_C2C_VIDEO, u = ue();
this.statusChanged && this.statusChanged({ oldStatus: s, newStatus: u }), this.setSoundMode(m.EAR);
} catch (i) {
console.error(`${a.PREFIX}switchCallMediaType failed, error: ${i}.`);
}
}
async switchCamera() {
const t = A.getData(n.CALL, a.CAMERA_POSITION) === se.BACK ? se.FRONT : se.BACK;
try {
await this._tuiCallEngine.switchCamera(t), A.update(n.CALL, a.CAMERA_POSITION, t);
} catch (i) {
console.error(`${a.PREFIX}_switchCamera failed, error: ${i}.`);
}
}
setSoundMode(e) {
var t;
try {
let i = A.getData(n.CALL, a.IS_EAR_PHONE);
const l = e || (i ? m.SPEAKER : m.EAR);
(t = this._tuiCallEngine) == null || t.selectAudioPlaybackDevice(l), e ? i = e === m.EAR : i = !i, A.update(n.CALL, a.IS_EAR_PHONE, i);
} catch (i) {
console.error(`${a.PREFIX}setSoundMode failed, error: ${i}.`);
}
}
async setBlurBackground(e) {
try {
A.update(n.CALL, a.ENABLE_VIRTUAL_BACKGROUND, e);
} catch (t) {
console.error(`${a.PREFIX}_setBlurBackground failed, error: ${t}.`);
}
}
// ==========================【TUICallEngine 事件处理】==========================
_addListenTuiCallEngineEvent() {
this._engineEventHandler.addListenTuiCallEngineEvent();
}
_removeListenTuiCallEngineEvent() {
this._engineEventHandler.removeListenTuiCallEngineEvent();
}
setCallback(e) {
const { beforeCalling: t, afterCalling: i, onMinimized: l, onMessageSentByMe: o, kickedOut: s, statusChanged: u } = e;
t && (this.beforeCalling = t), i && (this.afterCalling = i), l && (this.onMinimized = l), o && (this.onMessageSentByMe = o), s && (this.kickedOut = s), u && (this.statusChanged = u);
}
toggleMinimize() {
const e = A.getData(n.CALL, a.IS_MINIMIZED);
A.update(n.CALL, a.IS_MINIMIZED, !e), console.log(`${a.PREFIX}toggleMinimize: ${e} -> ${!e}.`), this.onMinimized && this.onMinimized(e, !e);
}
executeExternalBeforeCalling() {
this.beforeCalling && this.beforeCalling();
}
executeExternalAfterCalling() {
this.afterCalling && this.afterCalling();
}
// =========================【 miniProgram 公共方法】=========================
// 处理用户异常退出的情况,处理了右滑退出,以及返回退出的情况。
async handleExceptionExit() {
try {
if (A.getData(n.CALL, a.CALL_STATUS) === h.IDLE)
return;
this._resetCallStore(), await this._tuiCallEngine.handleExceptionExit();
} catch (e) {
console.error(`${a.PREFIX} handleExceptionExit failed, error: ${e}.`);
}
}
// 处理 pusher 内部错误,没有 live-pusher 能力时做出弹窗提示。
handlePusherError(e) {
var t;
((t = e == null ? void 0 : e.detail) == null ? void 0 : t.errMsg) === "fail:access denied" && Et();
}
setVideoDisplayMode(e) {
A.update(n.CALL, a.DISPLAY_MODE, e);
}
async setVideoResolution(e) {
var t;
try {
if (!e)
return;
A.update(n.CALL, a.VIDEO_RESOLUTION, e), await ((t = this._tuiCallEngine) == null ? void 0 : t.setVideoQuality(e));
} catch (i) {
console.warn(`${a.PREFIX}setVideoResolution failed, error: ${i}.`);
}
}
// 通话时长更新
startTimer() {
this._timerId === -1 && (this._startTimeStamp = fe(), this._timerId = he.run(a.TIMEOUT, this._updateCallDuration.bind(this), { delay: 1e3 }));
}
// =========================【private methods for service use】=========================
// 处理 “呼叫” 抛出的异常
_handleCallError(e, t) {
if (this._permissionCheckTimer && clearInterval(this._permissionCheckTimer), !Qe(e))
throw Ct(e), _e(e, g.AUDIO, this._tuiCallEngine), console.error(`${a.PREFIX}${t} failed, error: ${e}.`), this._resetCallStore(), e;
}
async _updateCallStoreBeforeCall(e, t, i) {
const l = i || A.getData(n.CALL, a.IS_MINIMIZED) ? O.CALLER_GROUP_CALLING_MSG : O.CALLER_CALLING_MSG;
let o = {
[a.CALL_MEDIA_TYPE]: e,
[a.CALL_ROLE]: F.CALLER,
[a.REMOTE_USER_INFO_LIST]: t,
[a.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST]: t,
[a.IS_GROUP]: !!i,
[a.CALL_TIPS]: S(l),
[a.GROUP_ID]: i
};
const s = { enableCamera: e === g.VIDEO, enableMic: !0 };
o = { ...o, [a.PUSHER]: s }, A.updateStore(o, n.CALL);
const u = await It(e, this);
console.log(`${a.PREFIX}mini beforeCall return callStatus: ${u}.`), A.update(n.CALL, a.CALL_STATUS, u);
const c = await Ae(t.map((L) => L.userId), this.getTim());
c.length > 0 && (A.update(n.CALL, a.REMOTE_USER_INFO_LIST, c), A.update(n.CALL, a.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, c));
const E = {
microphone: !0,
camera: e === g.VIDEO
};
let I = await this._tuiCallEngine.deviceCheck(E);
I || (this._permissionCheckTimer && clearInterval(this._permissionCheckTimer), this._permissionCheckTimer = setInterval(async () => {
I = await this._tuiCallEngine.deviceCheck(E), I && this._permissionCheckTimer && (clearInterval(this._permissionCheckTimer), A.update(n.CALL, a.CALL_STATUS, h.CALLING));
}, 500));
}
async _updateCallStoreAfterCall(e, t) {
var i, l;
if (t) {
A.update(n.CALL, a.IS_CLICKABLE, !0), et(t == null ? void 0 : t.roomID, t == null ? void 0 : t.strRoomID);
const o = A.getData(n.CALL, a.CALL_MEDIA_TYPE);
(l = this._chatCombine) == null || l.callTUIService({ message: (i = t == null ? void 0 : t.data) == null ? void 0 : i.message }), t.pusher && A.update(n.CALL, a.PUSHER, t.pusher), this.setSoundMode(o === g.AUDIO ? m.EAR : m.SPEAKER), A.update(n.CALL, a.CALL_STATUS, h.CALLING);
const s = this._getFeatureButtonDefaultState(H.Camera) === q.Close;
o === g.VIDEO && !s && await this.openCamera(a.LOCAL_VIDEO);
const u = A.getData(n.CALL, a.LOCAL_USER_INFO);
A.update(n.CALL, a.LOCAL_USER_INFO, { ...u, isEnter: !0 }), A.update(n.CALL, a.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { ...u, isEnter: !0 }), k(!0, a.AUDIO);
} else
this._permissionCheckTimer && clearInterval(this._permissionCheckTimer), this._permissionCheckTimer = null, this._resetCallStore();
}
_getFeatureButtonDefaultState(e) {
var i;
const { button: t } = A.getData(n.CALL, a.CUSTOM_UI_CONFIG);
return (i = t == null ? void 0 : t[e]) == null ? void 0 : i.state;
}
_updateCallDuration() {
const e = Math.round((fe() - this._startTimeStamp) / 1e3), t = $e(e);
A.update(n.CALL, a.CALL_DURATION, t);
}
_stopTimer() {
this._timerId !== -1 && (he.clearTask(this._timerId), this._timerId = -1);
}
_resetCallStore() {
const e = ue();
this._stopTimer();
let t = Object.keys(Ce).filter((o) => {
switch (Ce[o]) {
case a.CALL_STATUS:
case a.LANGUAGE:
case a.IS_GROUP:
case a.DISPLAY_MODE:
case a.VIDEO_RESOLUTION:
case a.ENABLE_FLOAT_WINDOW:
case a.LOCAL_USER_INFO:
case a.IS_SHOW_ENABLE_VIRTUAL_BACKGROUND:
case a.LOCAL_USER_INFO_EXCLUDE_VOLUMN:
return !1;
default:
return !0;
}
});
t = t.map((o) => Ce[o]), A.reset(n.CALL, t), A.getData(n.CALL, a.CALL_STATUS) !== h.IDLE && A.reset(n.CALL, [a.CALL_STATUS], !0), A.reset(n.CALL, [a.IS_MINIMIZED], !0), A.reset(n.CALL, [a.IS_EAR_PHONE], !0), A.reset(n.CALL, [a.ENABLE_VIRTUAL_BACKGROUND], !0), A.update(n.CALL, a.LOCAL_USER_INFO, {
...A.getData(n.CALL, a.LOCAL_USER_INFO),
isVideoAvailable: !1,
isAudioAvailable: !1
}), A.update(n.CALL, a.LOCAL_USER_INFO_EXCLUDE_VOLUMN, {
...A.getData(n.CALL, a.LOCAL_USER_INFO_EXCLUDE_VOLUMN),
isVideoAvailable: !1,
isAudioAvailable: !1
}), A.update(n.CALL, a.REMOTE_USER_INFO_LIST, []), A.update(n.CALL, a.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, []);
const l = ue();
e !== l && this.statusChanged && this.statusChanged({ oldStatus: e, newStatus: l });
}
// =========================【Calling the Chat SDK APi】=========================
// 获取群成员
async getGroupMemberList(e, t) {
const i = A.getData(n.CALL, a.GROUP_ID);
return await Pt(i, this.getTim(), e, t);
}
// 获取群信息
async getGroupProfile() {
const e = A.getData(n.CALL, a.GROUP_ID);
return await Vt(e, this.getTim());
}
_watchTUIStore() {
A == null || A.watch(n.CALL, {
[a.CALL_STATUS]: this._handleCallStatusChange
});
}
_unwatchTUIStore() {
A == null || A.unwatch(n.CALL, {
[a.CALL_STATUS]: this._handleCallStatusChange
});
}
// =========================【融合 chat 】=========================
bindTUICore(e) {
this._TUICore = e;
}
// =========================【set、get methods】=========================
getTim() {
var e, t;
return this._tim ? this._tim : this._tuiCallEngine ? ((e = this._tuiCallEngine) == null ? void 0 : e.tim) || ((t = this._tuiCallEngine) == null ? void 0 : t.getTim()) : (console.warn(`${a.PREFIX}getTim warning: _tuiCallEngine Instance is not available.`), null);
}
setIsFromChat(e) {
this._isFromChat = e;
}
setCurrentGroupId(e) {
this._currentGroupId = e;
}
getCurrentGroupId() {
return this._currentGroupId;
}
setDefaultOfflinePushInfo(e) {
this._defaultOfflinePushInfo = e;
}
getDefaultOfflinePushInfo() {
return this._defaultOfflinePushInfo;
}
async getCallMessage(e) {
return await this._chatCombine.getCallKitMessage(e, this.getTim());
}
};
_([
w(),
y(M.init)
], D.prototype, "init", 1);
_([
w(),
y(M.call),
Le({ engineInstance: !0 })
], D.prototype, "call", 1);
_([
w(),
y(M.groupCall),
Le({ engineInstance: !0 })
], D.prototype, "groupCall", 1);
_([
w(),
y(M.inviteUser),
Le({ engineInstance: !0 })
], D.prototype, "inviteUser", 1);
_([
w(),
y(M.joinInGroupCall),
Le({ engineInstance: !0 })
], D.prototype, "joinInGroupCall", 1);
_([
y(M.setLanguage)
], D.prototype, "setLanguage", 1);
_([
y(M.enableFloatWindow)
], D.prototype, "enableFloatWindow", 1);
_([
y(M.setSelfInfo)
], D.prototype, "setSelfInfo", 1);
_([
y(M.setCallingBell)
], D.prototype, "setCallingBell", 1);
_([
y(M.enableMuteMode)
], D.prototype, "enableMuteMode", 1);
_([
w()
], D.prototype, "accept", 1);
_([
w()
], D.prototype, "hangup", 1);
_([
w()
], D.prototype, "reject", 1);
_([
w()
], D.prototype, "openCamera", 1);
_([
w()
], D.prototype, "closeCamera", 1);
_([
w()
], D.prototype, "openMicrophone", 1);
_([
w()
], D.prototype, "closeMicrophone", 1);
_([
w()
], D.prototype, "switchScreen", 1);
_([
w()
], D.prototype, "switchCallMediaType", 1);
_([
w()
], D.prototype, "switchCamera", 1);
_([
w()
], D.prototype, "setSoundMode", 1);
_([
w()
], D.prototype, "setBlurBackground", 1);
_([
y(M.setVideoDisplayMode)
], D.prototype, "setVideoDisplayMode", 1);
_([
y(M.setVideoResolution)
], D.prototype, "setVideoResolution", 1);
let Ht = D;
const qt = Ht.getInstance(), Xt = "3.3.6";
export {
g as CallMediaType,
F as CallRole,
H as FeatureButton,
ke as LayoutMode,
a as NAME,
T as STATUS,
n as StoreName,
qt as TUICallKitServer,
zt as TUIGlobal,
A as TUIStore,
Xt as Version,
ne as VideoDisplayMode,
oe as VideoResolution,
S as t,
V as uiDesign
};