"use strict";var e=Object.defineProperty,t=(t,s,r)=>(((t,s,r)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r})(t,"symbol"!=typeof s?s+"":s,r),r);const s=require("../../common/vendor.js"),r=require("./utils/index.js"),c=class e{constructor(){t(this,"customerServiceAccounts"),console.log("TUICustomerServer.init ok"),s.R.registerService(s.E.TUICustomerServicePlugin.SERVICE.NAME,this),s.R.registerExtension(s.E.TUIContact.EXTENSION.CONTACT_LIST.EXT_ID,this),this.customerServiceAccounts=["@customer_service_account"]}static getInstance(){return e.instance||(e.instance=new e),e.instance}setCustomerServiceAccounts(e){this.customerServiceAccounts=e}getCustomerServiceAccounts(){return this.customerServiceAccounts}isCustomerConversation(e){const t=e&&e.slice(3)||"";return this.customerServiceAccounts.indexOf(t)>-1}isCustomerServicePluginMessage(e){return!(!e||!this.isCustomerConversation(e.conversationID))&&(r.isCustomerServiceMessage(e)||r.isMessageInvisible(e))}onGetExtension(e){if(e===s.E.TUIContact.EXTENSION.CONTACT_LIST.EXT_ID)return[{weight:0,icon:"",text:"客服号",data:{name:"customer",accountList:this.customerServiceAccounts}}]}onCall(e,t){if(e===s.E.TUICustomerServicePlugin.SERVICE.METHOD.ACTIVE_CONVERSATION)this.isCustomerConversation(t.conversationID)&&(s.R.callService({serviceName:s.E.TUIChat.SERVICE.NAME,method:s.E.TUIChat.SERVICE.METHOD.SET_CHAT_TYPE,params:{chatType:"customerService"}}),s.R.callService({serviceName:s.E.TUIChat.SERVICE.NAME,method:s.E.TUIChat.SERVICE.METHOD.SEND_CUSTOM_MESSAGE,params:{to:t.conversationID.slice(3),conversationType:"C2C",payload:{data:JSON.stringify({src:"7",customerServicePlugin:0})}}}))}};t(c,"instance");let i=c;exports.TUICustomerServer=i;
