UNPKG

@tencentcloud/ai-desk-customer-wechat

Version:

AI Desk customer UIKit for wechat mini program

3 lines (2 loc) 2.16 kB
"use strict";const o=require("../constant.js");function _(t){if(typeof t=="string")try{return!!JSON.parse(t)}catch{return!1}return!1}function s(t){return _(t)?JSON.parse(t):t}function O(t){var i;const n=s((i=t==null?void 0:t.payload)==null?void 0:i.data);return Number(n==null?void 0:n.customerServicePlugin)===0||Number(n==null?void 0:n.chatbotPlugin)===1}const C=t=>{var r;const n=t.type===o.TYPES.MSG_CUSTOM,i=s((r=t==null?void 0:t.payload)==null?void 0:r.data);return n&&(i.src===o.CUSTOM_MESSAGE_SRC.TRANSFER_TO_TASK_FLOW||i.src===o.CUSTOM_MESSAGE_SRC.TRANSFER_TO_HUMAN)&&!i.description},p=t=>{var r;const n=(t==null?void 0:t.type)===o.TYPES.MSG_CUSTOM,i=s((r=t==null?void 0:t.payload)==null?void 0:r.data);return n&&(i==null?void 0:i.src)===o.CUSTOM_MESSAGE_SRC.THINKING&&(i==null?void 0:i.thinkingStatus)===0},f=t=>{const n=t.time*1e3,i=60*1e3;return!(Date.now()-n>i)},E=t=>{const n=t.type===o.TYPES.MSG_CUSTOM,i=s(t.payload.data);return n&&i.src===o.CUSTOM_MESSAGE_SRC.ROBOT_MSG&&i.subtype==="welcome_msg"},a=t=>{var M,S;const n=s((M=t==null?void 0:t.payload)==null?void 0:M.data),i=["feedback","updateBotStatus"],r=(t==null?void 0:t.type)===o.TYPES.MSG_CUSTOM,T=(t==null?void 0:t.type)===o.TYPES.MSG_GROUP_TIP,c=(n==null?void 0:n.src)&&!o.WHITE_LIST.includes(n==null?void 0:n.src),u=(n==null?void 0:n.src)!==null&&(n==null?void 0:n.src)===o.CUSTOM_MESSAGE_SRC.MULTI_FORM&&t.flow==="out",e=(n==null?void 0:n.src)===o.CUSTOM_MESSAGE_SRC.ROBOT&&i.indexOf((S=n==null?void 0:n.content)==null?void 0:S.command)!==-1;return r&&(c||e||u)||T},l=t=>["zh","zh-TW","en","id","vi","ja","fil","ru"].indexOf(t)!==-1,G=()=>{var t;return typeof window<"u"?((t=window.navigator)==null?void 0:t.cookieEnabled)&&localStorage:!1},R=(t,n)=>{G()&&localStorage.removeItem(`TIM_${t}_${n}_conversationMap`)};exports.JSONToObject=s;exports.clearChatStorage=R;exports.isCustomerServiceMessage=O;exports.isMessageInvisible=a;exports.isSupportedLang=l;exports.isThinkingMessage=p;exports.isThinkingMessageOverTime=f;exports.isTransferMessageWithoutDesc=C;exports.isWelcomeMessage=E; //# sourceMappingURL=../../../.sourcemap/mp-weixin/ai-desk-customer-uniapp/utils/index.js.map