if(!document.querySelector("#bitgetChatFrame")){let f=!1;const b={lang:"en",domain:""},p={ar:"ar",de:"de",en:"en","en-GB":"en",es:"es","es-ES":"es",es:"es",fr:"fr",in:"id",id:"id",it:"it",ja:"ja",ko:"ko",ko_KR:"ko",nl:"nl",pl:"pl",pt:"pt","pt-PT":"pt",pt:"pt",ru:"ru",sv:"sv",th:"th",tr:"tr",uk:"uk",uz:"uz",vi:"vi","zh-CN":"zh","zh-TW":"zh-tw"},C=()=>{if(!window)return!1;if(window.control)return!0;if(!window.control&&!window.webkit)return!1;try{return window.webkit.messageHandlers.transDomainConfig.postMessage(null),!0}catch(t){console.log("error===>",t)}return!1},v=()=>{let t=navigator.userAgent,e=["Android","iPhone","SymbianOS","Windows Phone","rv:1.2.3.4","windows mobile","midp"],i=!0;for(let o=0;o=0){i=!1;break}return i},x=()=>{const t=document.createElement("style"),e=document.head||document.getElementsByTagName("head")[0];t.type="text/css",t.rel="stylesheet";const i="#ada-button-frame{display:none !important;}";try{t.appendChild(document.createTextNode(i))}catch{t.styleSheet.cssText=i}window.requestAnimationFrame(()=>{e.appendChild(t)})},g=()=>{var t;if(f){(t=window==null?void 0:window.adaEmbed)==null||t.getInfo().then(e=>{var i;e.isDrawerOpen||((i=window==null?void 0:window.adaEmbed)==null||i.toggle(!0),n.style.zIndex="-1",n.style.visibility="hidden",window.adaEmbed.setLanguage(p[d.lang]))});return}n.style.zIndex="999998",n.style.visibility="visible",n.contentWindow.postMessage({source:"customerChat",action:"openChat",data:d},"*")},E=()=>{const t=document.createElement("img"),e=document.createElement("div");e.id="bitget-chat-button",e.style.width="44px",e.style.height="44px",e.style.borderRadius="44px",e.style.position="fixed",e.style.right="24px",e.style.bottom="24px",e.style.border="0",e.style.outline="none",e.style.cursor="pointer",e.style.zIndex="10001",e.style.backgroundColor="rgb(0, 240, 255)",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",t.alt="Ada Logo",t.src="https://img.bitgetimg.com/image/third/ada.svg",e.appendChild(t),h.append(e);let i=!1,o=0,m=0;const s=function(a){a=a||window.event,a.preventDefault(),i=!1,o=a.clientX-e.offsetLeft,m=a.clientY-e.offsetTop,document.addEventListener("mousemove",r),document.addEventListener("mouseup",u)},r=function(a){i=!0,a=a||window.event,a.preventDefault();let l=a.clientX-o,c=a.clientY-m;e.style.left=l+"px",e.style.top=c+"px",l<0?l=0:l>window.innerWidth-e.offsetWidth&&(l=window.innerWidth-e.offsetWidth),c<0?c=0:c>window.innerHeight-e.offsetHeight&&(c=window.innerHeight-e.offsetHeight),e.style.left=l+"px",e.style.top=c+"px"},u=function(){document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",u)},y=function(){i||g()};e.addEventListener("click",y),d.needDrag&&e.addEventListener("mousedown",s)},d=Object.assign({},b),h=document.createElement("div");h.id="bitgetChatEntry";const n=document.createElement("iframe");n.id="bitgetChatFrame",n.style="position: fixed; right: 0; bottom:0; width: 375px; height: 90%; visibility: hidden; margin-right: 24px; margin-bottom:24px; max-height: 725px; border: none; outline: none; background: transparent; z-index: -1;",n.onload=()=>{var t=new Event("bitgetChatReady");window.dispatchEvent(t)};const w=t=>{const[e,i]=t;if(e==="config")return Object.assign(d,i),!0};for(;window.customerChatChip&&window.customerChatChip.length;)w(window.customerChatChip.shift());window.customerChatChip._nativePush=window.customerChatChip.push,window.customerChatChip.push=(...t)=>{const[e,i]=t[0];if(i.open){g();return}if(i.close){n.contentWindow.postMessage({source:"customerChat",action:"closeChat",data:d},"*"),n.style.zIndex="-1",n.style.visibility="hidden";return}if(i.hidden){try{const o=document.getElementById("bitgetChatEntry");o.style.display="none"}catch{}return}if(i.show){n.src||(n.src=d.domain+"/#/ada/?time="+Date.now());try{const o=document.getElementById("bitgetChatEntry");o.style.display="block"}catch{}return}w(...t)?i.position||n.contentWindow.postMessage({source:"customerChat",action:"updateConfig",data:d},"*"):window.customerChatChip._nativePush(...t)},C()||(n.src=d.domain+"/#/ada/?time="+Date.now()),window.addEventListener("message",t=>{var e;if(typeof t.data=="object"){const{source:i}=t.data;if(i==="customerChat"){const{action:o,data:m}=t.data;if(o==="openAda"&&(n.style.zIndex="-1",n.style.visibility="hidden",(e=window==null?void 0:window.adaEmbed)==null||e.getInfo().then(s=>{var u;if(s.isDrawerOpen)return;(u=window==null?void 0:window.adaEmbed)==null||u.toggle(!0),f=!0;const r=p[d.lang];try{setTimeout(()=>{window.adaEmbed.setLanguage(r)},2e3),setTimeout(()=>{window.adaEmbed.setLanguage(r)},4e3),setTimeout(()=>{window.adaEmbed.setLanguage(r)},6e3),setTimeout(()=>{window.adaEmbed.setLanguage(r)},8e3)}catch{}})),o==="close"&&(n.style.zIndex="-1",n.style.visibility="hidden"),o==="toLogin"){const s=m;location.href=`${s}/login?from=${encodeURIComponent(location.pathname)}&source=events`}if(o==="init"){E();const s=v();n.style.width=s?"375px":"100%",n.style.height=s?"90%":"100%",n.style.marginBottom=s?"24px":"0",n.style.marginRight=s?"24px":"0",n.style.maxHeight=s?"725px":"unset",n.contentWindow.postMessage({source:"customerChat",action:"updateConfig",data:d},"*")}}}},!1),x(),h.append(n),document.body.append(h)}