@onedeskpro/chatbot-core 0.1.0 โ 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -12
- package/dist/index.cjs +327 -36
- package/dist/index.d.cts +103 -10
- package/dist/index.d.ts +103 -10
- package/dist/index.iife.js +327 -36
- package/dist/index.js +2973 -558
- package/package.json +13 -7
package/dist/index.iife.js
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
var OnedeskProChatbot=function(h){"use strict";function S(i){return typeof i=="object"&&i!==null&&typeof i.message=="string"}class f{constructor(t){this.baseUrl=t.baseUrl.replace(/\/$/,""),this.apiKey=t.apiKey,this.timeoutMs=t.timeoutMs??3e4}fail(t,e,n,s){const a={statusCode:e,message:t,code:n,timestamp:new Date().toISOString(),path:s};throw Object.assign(new Error(t),{apiError:a,status:e})}async request(t,e,n,s){const a=new URL(`${this.baseUrl}${e}`);if(s)for(const[u,P]of Object.entries(s))a.searchParams.set(u,P);const l={"Content-Type":"application/json","X-API-Key":this.apiKey},r=new AbortController,o=setTimeout(()=>r.abort(),this.timeoutMs);let c;try{c=await fetch(a.toString(),{method:t,headers:l,signal:r.signal,...n!==void 0?{body:JSON.stringify(n)}:{}})}catch(u){r.signal.aborted&&this.fail(`Request timed out after ${this.timeoutMs}ms.`,0,"TIMEOUT",e),this.fail(u instanceof Error?u.message:"Network request failed.",0,"NETWORK_ERROR",e)}finally{clearTimeout(o)}const d=await c.text();let p=null;if(d)try{p=JSON.parse(d)}catch{p=null}if(!c.ok){if(S(p))throw Object.assign(new Error(p.message),{apiError:p,status:c.status});this.fail(`Request failed with status ${c.status} ${c.statusText}`.trim(),c.status,"HTTP_ERROR",e)}return p===null&&this.fail("The server returned an empty or malformed response.",c.status,"BAD_RESPONSE",e),p.data}async sendMessage(t){return this.request("POST","/sdk/chat",t)}async fetchHistory(t){return this.request("GET","/sdk/chat-history",void 0,{sessionId:t})}async fetchConfig(){return this.request("GET","/sdk/config")}}const x="https://api.onedeskpro.com";class w{constructor(){this._listeners={}}on(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),()=>this.off(t,e)}off(t,e){const n=this._listeners[t];n&&(this._listeners[t]=n.filter(s=>s!==e))}emit(t,...e){const n=this._listeners[t];if(n)for(const s of n)s(...e)}removeAllListeners(){for(const t of Object.keys(this._listeners))delete this._listeners[t]}}const y="onedeskpro_chatbot_session_id";function M(i){try{return typeof window<"u"?window.localStorage.getItem(i):null}catch{return null}}function I(i,t){try{typeof window<"u"&&window.localStorage.setItem(i,t)}catch{}}class v{constructor(){this.sessionId=null}init(t){if(t)return this.sessionId=t,this.persist(),this.sessionId;const e=M(y);return e?this.sessionId=e:(this.sessionId=this.generateId(),this.persist()),this.sessionId}get(){return this.sessionId}reset(){return this.sessionId=this.generateId(),this.persist(),this.sessionId}persist(){this.sessionId&&I(y,this.sessionId)}generateId(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}}function _(i,t){const e=`
|
|
1
|
+
var OnedeskProChatbot=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},r=3e4;function i(e){return typeof e==`object`&&!!e&&typeof e.message==`string`}function a(e){return e instanceof Error&&`apiError`in e&&`status`in e&&typeof e.status==`number`&&i(e.apiError)}var o=class{constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,``),this.apiKey=e.apiKey,this.timeoutMs=e.timeoutMs??3e4}fail(e,t,n,r){let i={statusCode:t,message:e,code:n,timestamp:new Date().toISOString(),path:r};throw Object.assign(Error(e),{apiError:i,status:t})}async request(e,t,n,r,a){let o=new URL(`${this.baseUrl}${t}`);if(r)for(let[e,t]of Object.entries(r))o.searchParams.set(e,t);let s={"Content-Type":`application/json`,"X-API-Key":this.apiKey,...a},c=new AbortController,l=setTimeout(()=>c.abort(),this.timeoutMs),u;try{u=await fetch(o.toString(),{method:e,headers:s,signal:c.signal,...n===void 0?{}:{body:JSON.stringify(n)}})}catch(e){c.signal.aborted&&this.fail(`Request timed out after ${this.timeoutMs}ms.`,0,`TIMEOUT`,t),this.fail(e instanceof Error?e.message:`Network request failed.`,0,`NETWORK_ERROR`,t)}finally{clearTimeout(l)}let d=await u.text(),f=null;if(d)try{f=JSON.parse(d)}catch{f=null}if(!u.ok){if(i(f))throw Object.assign(Error(f.message),{apiError:f,status:u.status});this.fail(`Request failed with status ${u.status} ${u.statusText}`.trim(),u.status,`HTTP_ERROR`,t)}return f===null&&this.fail(`The server returned an empty or malformed response.`,u.status,`BAD_RESPONSE`,t),f.data}async identify(e){return this.request(`POST`,`/sdk/identify`,e)}async verifyVisitor(e){return this.request(`GET`,`/sdk/visitor`,void 0,void 0,{"X-Visitor-Token":e})}async sendMessage(e){return this.request(`POST`,`/sdk/chat`,e)}async fetchConfig(){return this.request(`GET`,`/sdk/config`)}async requestHuman(e){return this.request(`POST`,`/sdk/human-request`,{visitorToken:e})}async fetchTicketStatus(e){return this.request(`GET`,`/sdk/ticket-status`,void 0,void 0,{"X-Visitor-Token":e})}},s=`https://api.onedeskpro.com`,c=class{constructor(){this._listeners={}}on(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),()=>this.off(e,t)}off(e,t){let n=this._listeners[e];n&&(this._listeners[e]=n.filter(e=>e!==t))}emit(e,...t){let n=this._listeners[e];if(n)for(let e of n)e(...t)}removeAllListeners(){for(let e of Object.keys(this._listeners))delete this._listeners[e]}},l=Object.create(null);l.open=`0`,l.close=`1`,l.ping=`2`,l.pong=`3`,l.message=`4`,l.upgrade=`5`,l.noop=`6`;var u=Object.create(null);Object.keys(l).forEach(e=>{u[l[e]]=e});var d={type:`error`,data:`parser error`},f=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,ee=typeof ArrayBuffer==`function`,te=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,p=({type:e,data:t},n,r)=>f&&t instanceof Blob?n?r(t):m(t,r):ee&&(t instanceof ArrayBuffer||te(t))?n?r(t):m(new Blob([t]),r):r(l[e]+(t||``)),m=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function h(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var g;function ne(e,t){if(f&&e.data instanceof Blob)return e.data.arrayBuffer().then(h).then(t);if(ee&&(e.data instanceof ArrayBuffer||te(e.data)))return t(h(e.data));p(e,!1,e=>{g||=new TextEncoder,t(g.encode(e))})}var re=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,_=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)_[re.charCodeAt(e)]=e;var ie=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=_[e.charCodeAt(r)],o=_[e.charCodeAt(r+1)],s=_[e.charCodeAt(r+2)],c=_[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},ae=typeof ArrayBuffer==`function`,v=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:se(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:oe(e.substring(1),t)}:u[n]?e.length>1?{type:u[n],data:e.substring(1)}:{type:u[n]}:d},oe=(e,t)=>ae?se(ie(e),t):{base64:!0,data:e},se=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},y=``,ce=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{p(e,!1,e=>{r[a]=e,++i===n&&t(r.join(y))})})},le=(e,t)=>{let n=e.split(y),r=[];for(let e=0;e<n.length;e++){let i=v(n[e],t);if(r.push(i),i.type===`error`)break}return r};function ue(){return new TransformStream({transform(e,t){ne(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var de;function b(e){return e.reduce((e,t)=>e+t.length,0)}function x(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function fe(e,t){de||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(b(n)<1)break;let e=x(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(b(n)<2)break;let e=x(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(b(n)<8)break;let e=x(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(d);break}i=a*2**32+t.getUint32(4),r=3}else{if(b(n)<i)break;let e=x(n,i);s.enqueue(v(a?e:de.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(d);break}}}})}function S(e){if(e)return pe(e)}function pe(e){for(var t in S.prototype)e[t]=S.prototype[t];return e}S.prototype.on=S.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},S.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},S.prototype.off=S.prototype.removeListener=S.prototype.removeAllListeners=S.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},S.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},S.prototype.emitReserved=S.prototype.emit,S.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},S.prototype.hasListeners=function(e){return!!this.listeners(e).length};var C=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),w=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),me=`arraybuffer`;function he(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var ge=w.setTimeout,_e=w.clearTimeout;function T(e,t){t.useNativeTimers?(e.setTimeoutFn=ge.bind(w),e.clearTimeoutFn=_e.bind(w)):(e.setTimeoutFn=w.setTimeout.bind(w),e.clearTimeoutFn=w.clearTimeout.bind(w))}var ve=1.33;function ye(e){return typeof e==`string`?be(e):Math.ceil((e.byteLength||e.size)*ve)}function be(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function xe(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Se(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function Ce(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var we=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},E=class extends S{constructor(e){super(),this.writable=!1,T(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new we(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=v(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=Se(e);return t.length?`?`+t:``}},Te=class extends E{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){le(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,ce(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=xe()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Ee=!1;try{Ee=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var De=Ee;function Oe(){}var ke=class extends Te{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},D=class e extends S{constructor(e,t,n){super(),this.createRequest=e,T(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=he(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(this._xhr!==void 0&&this._xhr!==null){if(this._xhr.onreadystatechange=Oe,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(D.requestsCount=0,D.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,Ae);else if(typeof addEventListener==`function`){let e=`onpagehide`in w?`pagehide`:`unload`;addEventListener(e,Ae,!1)}}function Ae(){for(let e in D.requests)D.requests.hasOwnProperty(e)&&D.requests[e].abort()}var je=(function(){let e=O({xdomain:!1});return e&&e.responseType!==null})(),Me=class extends ke{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=je&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new D(O,this.uri(),e)}};function O(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||De))return new XMLHttpRequest}catch{}if(!t)try{return new w[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var Ne=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,Pe=class extends E{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Ne?{}:he(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;p(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&C(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=xe()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},k=w.WebSocket||w.MozWebSocket,Fe={websocket:class extends Pe{createSocket(e,t,n){return Ne?new k(e,t,n):t?new k(e,t):new k(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends E{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=fe(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=ue();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&C(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:Me},Ie=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Le=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function A(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=Ie.exec(e||``),a={},o=14;for(;o--;)a[Le[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=Re(a,a.path),a.queryKey=ze(a,a.query),a}function Re(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function ze(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var j=typeof addEventListener==`function`&&typeof removeEventListener==`function`,M=[];j&&addEventListener(`offline`,()=>{M.forEach(e=>e())},!1);var N=class e extends S{constructor(e,t){if(super(),this.binaryType=me,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=A(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=A(t.host).host);T(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=Ce(this.opts.query)),j&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},M.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data)}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=ye(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,C(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),j&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=M.indexOf(this._offlineEventListener);e!==-1&&M.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};N.protocol=4;var Be=class extends N{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;N.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n){if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;N.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},Ve=class extends Be{constructor(e,t={}){let n=typeof e==`object`,r=n?{...e}:{...t};(!r.transports||r.transports&&typeof r.transports[0]==`string`)&&(r.transports=(r.transports||[`polling`,`websocket`,`webtransport`]).map(e=>Fe[e]).filter(e=>!!e)),super(n?r:e,r)}};Ve.protocol;function He(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=A(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var Ue=typeof ArrayBuffer==`function`,We=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Ge=Object.prototype.toString,Ke=typeof Blob==`function`||typeof Blob<`u`&&Ge.call(Blob)===`[object BlobConstructor]`,qe=typeof File==`function`||typeof File<`u`&&Ge.call(File)===`[object FileConstructor]`;function P(e){return Ue&&(e instanceof ArrayBuffer||We(e))||Ke&&e instanceof Blob||qe&&e instanceof File}function F(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(F(e[t]))return!0;return!1}if(P(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return F(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&F(e[t]))return!0;return!1}function Je(e){let t=[],n=e.data,r=e;return r.data=I(n,t),r.attachments=t.length,{packet:r,buffers:t}}function I(e,t,n){if(!e)return e;if(P(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=I(e[r],t);return n}if(typeof e==`object`&&!(e instanceof Date)){if(e.toJSON&&typeof e.toJSON==`function`&&!n)return I(e.toJSON(),t,!0);let r={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=I(e[n],t));return r}return e}function Ye(e,t){return e.data=L(e.data,t),delete e.attachments,e}function L(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=L(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=L(e[n],t));return e}var Xe=n({Decoder:()=>Qe,Encoder:()=>Ze,PacketType:()=>z,isPacketValid:()=>rt,protocol:()=>5}),R=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],z;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(z||={});var Ze=class{constructor(e){this.replacer=e}encode(e){return(e.type===z.EVENT||e.type===z.ACK)&&F(e)?this.encodeAsBinary({type:e.type===z.EVENT?z.BINARY_EVENT:z.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===z.BINARY_EVENT||e.type===z.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=Je(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Qe=class e extends S{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===z.BINARY_EVENT;n||t.type===z.BINARY_ACK?(t.type=n?z.EVENT:z.ACK,this.reconstructor=new $e(t)):super.emitReserved(`decoded`,t)}else if(P(e)||e.base64){if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`)}else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(z[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===z.BINARY_EVENT||r.type===z.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!B(a)||a<1)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&t.charAt(n)!==`,`&&n!==t.length;);r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case z.CONNECT:return V(t);case z.DISCONNECT:return t===void 0;case z.CONNECT_ERROR:return typeof t==`string`||V(t);case z.EVENT:case z.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&R.indexOf(t[0])===-1);case z.ACK:case z.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},$e=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=Ye(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function et(e){return typeof e==`string`}var B=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function tt(e){return e===void 0||B(e)}function V(e){return Object.prototype.toString.call(e)===`[object Object]`}function nt(e,t){switch(e){case z.CONNECT:return t===void 0||V(t);case z.DISCONNECT:return t===void 0;case z.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&R.indexOf(t[0])===-1);case z.ACK:return Array.isArray(t);case z.CONNECT_ERROR:return typeof t==`string`||V(t);default:return!1}}function rt(e){return et(e.nsp)&&tt(e.id)&&nt(e.type,e.data)}function H(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var it=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),U=class extends S{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[H(e,`open`,this.onopen.bind(this)),H(e,`packet`,this.onpacket.bind(this)),H(e,`error`,this.onerror.bind(this)),H(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(it.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:z.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];(!t.pending||e)&&(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:z.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case z.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case z.EVENT:case z.BINARY_EVENT:this.onevent(e);break;case z.ACK:case z.BINARY_ACK:this.onack(e);break;case z.DISCONNECT:this.ondisconnect();break;case z.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t)}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:z.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:z.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function W(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}W.prototype.duration=function(){var e=this.ms*this.factor**+this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},W.prototype.reset=function(){this.attempts=0},W.prototype.setMin=function(e){this.ms=e},W.prototype.setMax=function(e){this.max=e},W.prototype.setJitter=function(e){this.jitter=e};var G=class extends S{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,T(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new W({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||Xe;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new Ve(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=H(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=H(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(H(e,`ping`,this.onping.bind(this)),H(e,`data`,this.ondata.bind(this)),H(e,`error`,this.onerror.bind(this)),H(e,`close`,this.onclose.bind(this)),H(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){C(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new U(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},K={};function q(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=He(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=K[i]&&a in K[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new G(r,t):(K[i]||(K[i]=new G(r,t)),c=K[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(q,{Manager:G,Socket:U,io:q,connect:q});function at(e){let t=e.replace(/\/$/,``);try{return`${new URL(t).origin}/sdk`}catch{return`${t}/sdk`}}var ot=class{constructor(){this.socket=null}get connected(){return this.socket?.connected??!1}connect(e){this.disconnect();let t=at(e.baseUrl);this.socket=q(t,{auth:{apiKey:e.apiKey,visitorToken:e.visitorToken},transports:[`websocket`,`polling`],autoConnect:!0,reconnection:!0});let n=!1;this.socket.on(`connect`,()=>{n?e.onReconnect?.():n=!0}),this.socket.on(`ticket:status`,t=>{e.onTicketStatus?.(t)}),this.socket.on(`message:receive`,t=>{e.onMessageReceive?.(t)}),this.socket.on(`connect_error`,t=>{e.onConnectError?.(t)})}disconnect(){this.socket&&=(this.socket.removeAllListeners(),this.socket.disconnect(),null)}},J=`onedeskpro_visitor_token`;function st(e){try{return typeof window<`u`?window.localStorage.getItem(e):null}catch{return null}}function ct(e,t){try{typeof window<`u`&&window.localStorage.setItem(e,t)}catch{}}function lt(e){try{typeof window<`u`&&window.localStorage.removeItem(e)}catch{}}var ut=class{constructor(){this.token=null,this.storageKey=J}setScope(e){this.storageKey=e?.trim()?`${J}:${e.trim()}`:J,this.token=st(this.storageKey)}get(){return this.token??st(this.storageKey)}set(e){this.token=e,ct(this.storageKey,e)}clear(){this.token=null,lt(this.storageKey)}},Y=[{iso:`BD`,name:`Bangladesh`,dial:`880`,flag:`๐ง๐ฉ`},{iso:`US`,name:`United States`,dial:`1`,flag:`๐บ๐ธ`},{iso:`GB`,name:`United Kingdom`,dial:`44`,flag:`๐ฌ๐ง`},{iso:`IN`,name:`India`,dial:`91`,flag:`๐ฎ๐ณ`},{iso:`PK`,name:`Pakistan`,dial:`92`,flag:`๐ต๐ฐ`},{iso:`AE`,name:`United Arab Emirates`,dial:`971`,flag:`๐ฆ๐ช`},{iso:`SA`,name:`Saudi Arabia`,dial:`966`,flag:`๐ธ๐ฆ`},{iso:`CA`,name:`Canada`,dial:`1`,flag:`๐จ๐ฆ`},{iso:`AU`,name:`Australia`,dial:`61`,flag:`๐ฆ๐บ`},{iso:`DE`,name:`Germany`,dial:`49`,flag:`๐ฉ๐ช`},{iso:`FR`,name:`France`,dial:`33`,flag:`๐ซ๐ท`},{iso:`IT`,name:`Italy`,dial:`39`,flag:`๐ฎ๐น`},{iso:`ES`,name:`Spain`,dial:`34`,flag:`๐ช๐ธ`},{iso:`NL`,name:`Netherlands`,dial:`31`,flag:`๐ณ๐ฑ`},{iso:`SE`,name:`Sweden`,dial:`46`,flag:`๐ธ๐ช`},{iso:`NO`,name:`Norway`,dial:`47`,flag:`๐ณ๐ด`},{iso:`DK`,name:`Denmark`,dial:`45`,flag:`๐ฉ๐ฐ`},{iso:`FI`,name:`Finland`,dial:`358`,flag:`๐ซ๐ฎ`},{iso:`IE`,name:`Ireland`,dial:`353`,flag:`๐ฎ๐ช`},{iso:`CH`,name:`Switzerland`,dial:`41`,flag:`๐จ๐ญ`},{iso:`AT`,name:`Austria`,dial:`43`,flag:`๐ฆ๐น`},{iso:`BE`,name:`Belgium`,dial:`32`,flag:`๐ง๐ช`},{iso:`PT`,name:`Portugal`,dial:`351`,flag:`๐ต๐น`},{iso:`PL`,name:`Poland`,dial:`48`,flag:`๐ต๐ฑ`},{iso:`CZ`,name:`Czechia`,dial:`420`,flag:`๐จ๐ฟ`},{iso:`RO`,name:`Romania`,dial:`40`,flag:`๐ท๐ด`},{iso:`HU`,name:`Hungary`,dial:`36`,flag:`๐ญ๐บ`},{iso:`GR`,name:`Greece`,dial:`30`,flag:`๐ฌ๐ท`},{iso:`TR`,name:`Turkey`,dial:`90`,flag:`๐น๐ท`},{iso:`RU`,name:`Russia`,dial:`7`,flag:`๐ท๐บ`},{iso:`UA`,name:`Ukraine`,dial:`380`,flag:`๐บ๐ฆ`},{iso:`CN`,name:`China`,dial:`86`,flag:`๐จ๐ณ`},{iso:`JP`,name:`Japan`,dial:`81`,flag:`๐ฏ๐ต`},{iso:`KR`,name:`South Korea`,dial:`82`,flag:`๐ฐ๐ท`},{iso:`SG`,name:`Singapore`,dial:`65`,flag:`๐ธ๐ฌ`},{iso:`MY`,name:`Malaysia`,dial:`60`,flag:`๐ฒ๐พ`},{iso:`ID`,name:`Indonesia`,dial:`62`,flag:`๐ฎ๐ฉ`},{iso:`TH`,name:`Thailand`,dial:`66`,flag:`๐น๐ญ`},{iso:`VN`,name:`Vietnam`,dial:`84`,flag:`๐ป๐ณ`},{iso:`PH`,name:`Philippines`,dial:`63`,flag:`๐ต๐ญ`},{iso:`HK`,name:`Hong Kong`,dial:`852`,flag:`๐ญ๐ฐ`},{iso:`TW`,name:`Taiwan`,dial:`886`,flag:`๐น๐ผ`},{iso:`NZ`,name:`New Zealand`,dial:`64`,flag:`๐ณ๐ฟ`},{iso:`ZA`,name:`South Africa`,dial:`27`,flag:`๐ฟ๐ฆ`},{iso:`NG`,name:`Nigeria`,dial:`234`,flag:`๐ณ๐ฌ`},{iso:`KE`,name:`Kenya`,dial:`254`,flag:`๐ฐ๐ช`},{iso:`EG`,name:`Egypt`,dial:`20`,flag:`๐ช๐ฌ`},{iso:`MA`,name:`Morocco`,dial:`212`,flag:`๐ฒ๐ฆ`},{iso:`BR`,name:`Brazil`,dial:`55`,flag:`๐ง๐ท`},{iso:`MX`,name:`Mexico`,dial:`52`,flag:`๐ฒ๐ฝ`},{iso:`AR`,name:`Argentina`,dial:`54`,flag:`๐ฆ๐ท`},{iso:`CL`,name:`Chile`,dial:`56`,flag:`๐จ๐ฑ`},{iso:`CO`,name:`Colombia`,dial:`57`,flag:`๐จ๐ด`},{iso:`PE`,name:`Peru`,dial:`51`,flag:`๐ต๐ช`},{iso:`IL`,name:`Israel`,dial:`972`,flag:`๐ฎ๐ฑ`},{iso:`QA`,name:`Qatar`,dial:`974`,flag:`๐ถ๐ฆ`},{iso:`KW`,name:`Kuwait`,dial:`965`,flag:`๐ฐ๐ผ`},{iso:`BH`,name:`Bahrain`,dial:`973`,flag:`๐ง๐ญ`},{iso:`OM`,name:`Oman`,dial:`968`,flag:`๐ด๐ฒ`},{iso:`LK`,name:`Sri Lanka`,dial:`94`,flag:`๐ฑ๐ฐ`},{iso:`NP`,name:`Nepal`,dial:`977`,flag:`๐ณ๐ต`}],dt=Y.find(e=>e.iso===`BD`)??Y[0];function ft(e,t){let n=t.trim();if(n.startsWith(`+`)){let e=n.replace(/\D/g,``);return e?`+${e}`:``}let r=n.replace(/\D/g,``);return!r||(r=r.replace(/^0+/,``),!r)?``:`+${e}${r}`}function pt(e,t){let n=`
|
|
2
2
|
--ttcb-bg: #ffffff;
|
|
3
3
|
--ttcb-bg-secondary: #f3f4f6;
|
|
4
4
|
--ttcb-text: #111827;
|
|
5
5
|
--ttcb-text-muted: #6b7280;
|
|
6
6
|
--ttcb-border: #e5e7eb;
|
|
7
|
-
--ttcb-user-bubble: ${
|
|
7
|
+
--ttcb-user-bubble: ${e};
|
|
8
8
|
--ttcb-user-text: #ffffff;
|
|
9
9
|
--ttcb-ai-bubble: #f3f4f6;
|
|
10
10
|
--ttcb-ai-text: #111827;
|
|
11
11
|
--ttcb-input-bg: #ffffff;
|
|
12
12
|
--ttcb-shadow: 0 20px 60px rgba(0,0,0,0.15);
|
|
13
|
-
|
|
13
|
+
--ttcb-online: #22c55e;
|
|
14
|
+
--ttcb-hint: #9ca3af;
|
|
15
|
+
`,r=`
|
|
14
16
|
--ttcb-bg: #1f2937;
|
|
15
17
|
--ttcb-bg-secondary: #111827;
|
|
16
18
|
--ttcb-text: #f9fafb;
|
|
17
19
|
--ttcb-text-muted: #9ca3af;
|
|
18
20
|
--ttcb-border: #374151;
|
|
19
|
-
--ttcb-user-bubble: ${
|
|
21
|
+
--ttcb-user-bubble: ${e};
|
|
20
22
|
--ttcb-user-text: #ffffff;
|
|
21
23
|
--ttcb-ai-bubble: #374151;
|
|
22
24
|
--ttcb-ai-text: #f9fafb;
|
|
23
25
|
--ttcb-input-bg: #111827;
|
|
24
26
|
--ttcb-shadow: 0 20px 60px rgba(0,0,0,0.4);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
--ttcb-online: #22c55e;
|
|
28
|
+
--ttcb-hint: #9ca3af;
|
|
29
|
+
`,i;return i=t===`dark`?`:host { ${r} }`:t===`light`?`:host { ${n} }`:`
|
|
30
|
+
:host { ${n} }
|
|
31
|
+
@media (prefers-color-scheme: dark) { :host { ${r} } }
|
|
28
32
|
`,`
|
|
29
|
-
${
|
|
33
|
+
${i}
|
|
30
34
|
|
|
31
35
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
32
36
|
|
|
@@ -34,7 +38,7 @@ var OnedeskProChatbot=function(h){"use strict";function S(i){return typeof i=="o
|
|
|
34
38
|
position: fixed;
|
|
35
39
|
width: 56px; height: 56px;
|
|
36
40
|
border-radius: 50%;
|
|
37
|
-
background: ${
|
|
41
|
+
background: ${e};
|
|
38
42
|
border: none; cursor: pointer;
|
|
39
43
|
display: flex; align-items: center; justify-content: center;
|
|
40
44
|
box-shadow: 0 4px 20px rgba(0,0,0,0.2);
|
|
@@ -48,7 +52,7 @@ var OnedeskProChatbot=function(h){"use strict";function S(i){return typeof i=="o
|
|
|
48
52
|
|
|
49
53
|
.ttcb-panel {
|
|
50
54
|
position: fixed;
|
|
51
|
-
width: 380px;
|
|
55
|
+
width: 380px;
|
|
52
56
|
background: var(--ttcb-bg);
|
|
53
57
|
border: 1px solid var(--ttcb-border);
|
|
54
58
|
border-radius: 16px;
|
|
@@ -56,9 +60,17 @@ var OnedeskProChatbot=function(h){"use strict";function S(i){return typeof i=="o
|
|
|
56
60
|
box-shadow: var(--ttcb-shadow);
|
|
57
61
|
overflow: hidden;
|
|
58
62
|
z-index: 9998;
|
|
59
|
-
transition: opacity 0.2s ease, transform 0.25s ease;
|
|
63
|
+
transition: opacity 0.2s ease, transform 0.25s ease, height 0.2s ease;
|
|
60
64
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
61
65
|
}
|
|
66
|
+
.ttcb-panel.ttcb-mode-chat {
|
|
67
|
+
height: 560px;
|
|
68
|
+
}
|
|
69
|
+
.ttcb-panel.ttcb-mode-form,
|
|
70
|
+
.ttcb-panel.ttcb-mode-compact {
|
|
71
|
+
height: auto;
|
|
72
|
+
max-height: min(560px, calc(100vh - 100px));
|
|
73
|
+
}
|
|
62
74
|
.ttcb-panel.bottom-right { bottom: 92px; right: 24px; }
|
|
63
75
|
.ttcb-panel.bottom-left { bottom: 92px; left: 24px; }
|
|
64
76
|
.ttcb-panel.hidden {
|
|
@@ -73,28 +85,98 @@ var OnedeskProChatbot=function(h){"use strict";function S(i){return typeof i=="o
|
|
|
73
85
|
background: var(--ttcb-bg);
|
|
74
86
|
flex-shrink: 0;
|
|
75
87
|
}
|
|
88
|
+
.ttcb-avatar-wrap {
|
|
89
|
+
flex-shrink: 0;
|
|
90
|
+
}
|
|
76
91
|
.ttcb-avatar {
|
|
77
|
-
width:
|
|
78
|
-
background: ${
|
|
92
|
+
width: 40px; height: 40px; border-radius: 10px;
|
|
93
|
+
background: ${e};
|
|
79
94
|
display: flex; align-items: center; justify-content: center;
|
|
80
|
-
flex-shrink: 0;
|
|
81
95
|
}
|
|
82
|
-
.ttcb-avatar svg { width:
|
|
83
|
-
.ttcb-header-
|
|
84
|
-
|
|
96
|
+
.ttcb-avatar svg { width: 22px; height: 22px; fill: #fff; }
|
|
97
|
+
.ttcb-header-main {
|
|
98
|
+
flex: 1; min-width: 0;
|
|
99
|
+
display: flex; flex-direction: column; gap: 4px;
|
|
100
|
+
}
|
|
101
|
+
.ttcb-header-title-row {
|
|
102
|
+
display: flex; align-items: center; gap: 6px;
|
|
103
|
+
}
|
|
104
|
+
.ttcb-header-title {
|
|
105
|
+
font-weight: 700; font-size: 15px; color: var(--ttcb-text);
|
|
106
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
107
|
+
}
|
|
108
|
+
.ttcb-verified {
|
|
109
|
+
width: 16px; height: 16px; color: ${e};
|
|
110
|
+
flex-shrink: 0; display: flex;
|
|
111
|
+
}
|
|
112
|
+
.ttcb-verified svg { width: 16px; height: 16px; }
|
|
113
|
+
.ttcb-header-meta {
|
|
114
|
+
display: flex; align-items: center; gap: 8px;
|
|
115
|
+
font-size: 12px; color: var(--ttcb-text-muted);
|
|
116
|
+
}
|
|
117
|
+
.ttcb-meta-online {
|
|
118
|
+
display: inline-flex; align-items: center; gap: 5px;
|
|
119
|
+
color: var(--ttcb-online); font-weight: 500;
|
|
120
|
+
}
|
|
121
|
+
.ttcb-meta-online::before {
|
|
122
|
+
content: '';
|
|
123
|
+
width: 7px; height: 7px; border-radius: 50%;
|
|
124
|
+
background: var(--ttcb-online);
|
|
125
|
+
}
|
|
126
|
+
.ttcb-meta-sep {
|
|
127
|
+
width: 1px; height: 12px; background: var(--ttcb-border);
|
|
128
|
+
}
|
|
129
|
+
.ttcb-meta-replies {
|
|
130
|
+
display: inline-flex; align-items: center; gap: 4px;
|
|
131
|
+
color: var(--ttcb-text-muted);
|
|
132
|
+
}
|
|
133
|
+
.ttcb-meta-replies svg { width: 18px; height: 14px; }
|
|
134
|
+
.ttcb-header-actions {
|
|
135
|
+
display: flex; align-items: center; gap: 3px;
|
|
136
|
+
flex-shrink: 0; align-self: center;
|
|
137
|
+
}
|
|
138
|
+
.ttcb-close-btn, .ttcb-new-session-btn, .ttcb-request-human-btn {
|
|
85
139
|
background: none; border: none; cursor: pointer;
|
|
86
|
-
color: var(--ttcb-text-muted); padding:
|
|
140
|
+
color: var(--ttcb-text-muted); padding: 6px; border-radius: 6px;
|
|
87
141
|
display: flex; align-items: center; justify-content: center;
|
|
88
142
|
}
|
|
89
|
-
.ttcb-close-btn:hover, .ttcb-new-session-btn:hover
|
|
90
|
-
|
|
91
|
-
|
|
143
|
+
.ttcb-close-btn:hover, .ttcb-new-session-btn:hover, .ttcb-request-human-btn:hover {
|
|
144
|
+
background: var(--ttcb-bg-secondary);
|
|
145
|
+
}
|
|
146
|
+
.ttcb-close-btn svg { width: 19px; height: 19px; fill: currentColor; }
|
|
147
|
+
.ttcb-new-session-btn svg,
|
|
148
|
+
.ttcb-request-human-btn svg {
|
|
149
|
+
width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2;
|
|
150
|
+
}
|
|
151
|
+
.ttcb-new-session-btn.hidden, .ttcb-request-human-btn.hidden { display: none; }
|
|
152
|
+
|
|
153
|
+
.ttcb-mode-banner {
|
|
154
|
+
display: none;
|
|
155
|
+
padding: 10px 16px;
|
|
156
|
+
font-size: 12px;
|
|
157
|
+
line-height: 1.4;
|
|
158
|
+
color: var(--ttcb-text-muted);
|
|
159
|
+
background: var(--ttcb-bg-secondary);
|
|
160
|
+
border-top: 1px solid var(--ttcb-border);
|
|
161
|
+
flex-shrink: 0;
|
|
162
|
+
}
|
|
163
|
+
.ttcb-mode-banner.visible { display: block; }
|
|
164
|
+
.ttcb-mode-banner.waiting { color: var(--ttcb-text); }
|
|
165
|
+
.ttcb-mode-banner.closed {
|
|
166
|
+
color: var(--ttcb-text);
|
|
167
|
+
background: color-mix(in srgb, #ef4444 10%, var(--ttcb-bg-secondary));
|
|
168
|
+
}
|
|
169
|
+
.ttcb-mode-banner.human { color: var(--ttcb-text); }
|
|
92
170
|
|
|
93
171
|
.ttcb-messages {
|
|
94
172
|
flex: 1; overflow-y: auto; padding: 16px;
|
|
95
173
|
display: flex; flex-direction: column; gap: 12px;
|
|
96
174
|
scroll-behavior: smooth;
|
|
97
175
|
font-size: 14px;
|
|
176
|
+
min-height: 120px;
|
|
177
|
+
}
|
|
178
|
+
.ttcb-panel.ttcb-mode-compact .ttcb-messages {
|
|
179
|
+
min-height: 160px;
|
|
98
180
|
}
|
|
99
181
|
|
|
100
182
|
.ttcb-empty {
|
|
@@ -144,15 +226,24 @@ var OnedeskProChatbot=function(h){"use strict";function S(i){return typeof i=="o
|
|
|
144
226
|
|
|
145
227
|
.ttcb-msg { display: flex; gap: 8px; max-width: 100%; }
|
|
146
228
|
.ttcb-msg.human { flex-direction: row-reverse; }
|
|
229
|
+
.ttcb-msg-body { display: flex; flex-direction: column; gap: 3px; max-width: 78%; }
|
|
230
|
+
.ttcb-msg.human .ttcb-msg-body { align-items: flex-end; }
|
|
231
|
+
.ttcb-msg-label {
|
|
232
|
+
font-size: 11px; font-weight: 600; color: var(--ttcb-text-muted);
|
|
233
|
+
padding-left: 2px;
|
|
234
|
+
}
|
|
147
235
|
.ttcb-msg-avatar {
|
|
148
236
|
width: 28px; height: 28px; border-radius: 50%;
|
|
149
237
|
background: var(--ttcb-bg-secondary);
|
|
150
238
|
display: flex; align-items: center; justify-content: center;
|
|
151
239
|
flex-shrink: 0; margin-top: 2px;
|
|
152
240
|
}
|
|
241
|
+
/* Offset past the "Agent" label so the avatar lines up with the bubble */
|
|
242
|
+
.ttcb-msg.agent .ttcb-msg-avatar { margin-top: 22px; }
|
|
153
243
|
.ttcb-msg-avatar svg { width: 13px; height: 13px; fill: var(--ttcb-text-muted); }
|
|
244
|
+
.ttcb-msg.agent .ttcb-msg-avatar svg { fill: none; stroke: var(--ttcb-text-muted); stroke-width: 2; }
|
|
154
245
|
.ttcb-bubble {
|
|
155
|
-
max-width:
|
|
246
|
+
max-width: 100%; padding: 9px 13px;
|
|
156
247
|
border-radius: 16px 16px 16px 4px;
|
|
157
248
|
line-height: 1.5;
|
|
158
249
|
color: var(--ttcb-ai-text);
|
|
@@ -165,8 +256,13 @@ var OnedeskProChatbot=function(h){"use strict";function S(i){return typeof i=="o
|
|
|
165
256
|
color: var(--ttcb-user-text);
|
|
166
257
|
border-radius: 16px 16px 4px 16px;
|
|
167
258
|
}
|
|
259
|
+
.ttcb-msg.agent .ttcb-bubble {
|
|
260
|
+
background: var(--ttcb-bg);
|
|
261
|
+
color: var(--ttcb-text);
|
|
262
|
+
border: 1px solid var(--ttcb-border);
|
|
263
|
+
border-radius: 16px 16px 16px 4px;
|
|
264
|
+
}
|
|
168
265
|
|
|
169
|
-
/* Markdown styles inside AI bubble */
|
|
170
266
|
.ttcb-bubble p { margin: 0 0 6px 0; }
|
|
171
267
|
.ttcb-bubble p:last-child { margin-bottom: 0; }
|
|
172
268
|
.ttcb-bubble strong { font-weight: 600; }
|
|
@@ -223,12 +319,12 @@ var OnedeskProChatbot=function(h){"use strict";function S(i){return typeof i=="o
|
|
|
223
319
|
transition: border-color 0.15s;
|
|
224
320
|
font-family: inherit;
|
|
225
321
|
}
|
|
226
|
-
.ttcb-input:focus { border-color: ${
|
|
322
|
+
.ttcb-input:focus { border-color: ${e}; }
|
|
227
323
|
.ttcb-input::placeholder { color: var(--ttcb-text-muted); }
|
|
228
324
|
.ttcb-input:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
229
325
|
.ttcb-send-btn {
|
|
230
326
|
padding: 0 14px; height: 38px;
|
|
231
|
-
background: ${
|
|
327
|
+
background: ${e}; color: #fff;
|
|
232
328
|
border: none; border-radius: 8px; cursor: pointer;
|
|
233
329
|
display: flex; align-items: center; justify-content: center;
|
|
234
330
|
transition: opacity 0.15s; flex-shrink: 0;
|
|
@@ -237,29 +333,224 @@ var OnedeskProChatbot=function(h){"use strict";function S(i){return typeof i=="o
|
|
|
237
333
|
.ttcb-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
238
334
|
.ttcb-send-btn svg { width: 16px; height: 16px; fill: #fff; }
|
|
239
335
|
|
|
336
|
+
.ttcb-identify {
|
|
337
|
+
display: none;
|
|
338
|
+
flex-direction: column;
|
|
339
|
+
gap: 14px;
|
|
340
|
+
padding: 16px 16px 14px;
|
|
341
|
+
overflow-y: auto;
|
|
342
|
+
}
|
|
343
|
+
.ttcb-panel.ttcb-mode-form .ttcb-identify.visible {
|
|
344
|
+
display: flex;
|
|
345
|
+
flex: 0 0 auto;
|
|
346
|
+
}
|
|
347
|
+
.ttcb-identify-form {
|
|
348
|
+
display: flex; flex-direction: column; gap: 14px;
|
|
349
|
+
}
|
|
350
|
+
.ttcb-field { display: flex; flex-direction: column; gap: 6px; }
|
|
351
|
+
.ttcb-field-label-row {
|
|
352
|
+
display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
|
|
353
|
+
}
|
|
354
|
+
.ttcb-label {
|
|
355
|
+
font-size: 13px; font-weight: 600; color: var(--ttcb-text);
|
|
356
|
+
}
|
|
357
|
+
.ttcb-label .ttcb-req { color: #ef4444; font-weight: 600; }
|
|
358
|
+
.ttcb-field-hint {
|
|
359
|
+
font-size: 11px; color: var(--ttcb-hint); font-weight: 400;
|
|
360
|
+
white-space: nowrap;
|
|
361
|
+
}
|
|
362
|
+
.ttcb-input-wrap {
|
|
363
|
+
display: flex; align-items: center; gap: 8px;
|
|
364
|
+
border: 1px solid var(--ttcb-border);
|
|
365
|
+
border-radius: 10px;
|
|
366
|
+
padding: 0 12px;
|
|
367
|
+
background: var(--ttcb-input-bg);
|
|
368
|
+
transition: border-color 0.15s;
|
|
369
|
+
}
|
|
370
|
+
.ttcb-input-wrap:focus-within { border-color: ${e}; }
|
|
371
|
+
.ttcb-input-wrap.disabled { opacity: 0.6; }
|
|
372
|
+
.ttcb-input-icon {
|
|
373
|
+
width: 18px; height: 18px; color: var(--ttcb-text-muted);
|
|
374
|
+
flex-shrink: 0; display: flex;
|
|
375
|
+
}
|
|
376
|
+
.ttcb-input-icon svg { width: 18px; height: 18px; }
|
|
377
|
+
.ttcb-identify-input {
|
|
378
|
+
flex: 1; min-width: 0;
|
|
379
|
+
border: none; outline: none;
|
|
380
|
+
padding: 11px 0;
|
|
381
|
+
font-size: 14px;
|
|
382
|
+
background: transparent;
|
|
383
|
+
color: var(--ttcb-text);
|
|
384
|
+
font-family: inherit;
|
|
385
|
+
}
|
|
386
|
+
.ttcb-identify-input::placeholder { color: var(--ttcb-text-muted); }
|
|
387
|
+
.ttcb-identify-input:disabled { cursor: not-allowed; }
|
|
388
|
+
|
|
389
|
+
.ttcb-phone-row {
|
|
390
|
+
display: flex; align-items: stretch;
|
|
391
|
+
border: 1px solid var(--ttcb-border);
|
|
392
|
+
border-radius: 10px;
|
|
393
|
+
background: var(--ttcb-input-bg);
|
|
394
|
+
overflow: hidden;
|
|
395
|
+
transition: border-color 0.15s;
|
|
396
|
+
}
|
|
397
|
+
.ttcb-phone-row:focus-within { border-color: ${e}; }
|
|
398
|
+
.ttcb-phone-row.disabled { opacity: 0.6; }
|
|
399
|
+
.ttcb-dial-btn {
|
|
400
|
+
display: flex; align-items: center; gap: 4px;
|
|
401
|
+
padding: 0 10px;
|
|
402
|
+
border: none; border-right: 1px solid var(--ttcb-border);
|
|
403
|
+
background: var(--ttcb-bg-secondary);
|
|
404
|
+
cursor: pointer;
|
|
405
|
+
font-family: inherit;
|
|
406
|
+
font-size: 13px;
|
|
407
|
+
font-weight: 500;
|
|
408
|
+
color: var(--ttcb-text);
|
|
409
|
+
flex-shrink: 0;
|
|
410
|
+
}
|
|
411
|
+
.ttcb-dial-btn:disabled { cursor: not-allowed; }
|
|
412
|
+
.ttcb-dial-flag { font-size: 16px; line-height: 1; }
|
|
413
|
+
.ttcb-dial-code { letter-spacing: 0.01em; }
|
|
414
|
+
.ttcb-dial-btn svg {
|
|
415
|
+
width: 14px; height: 14px; color: var(--ttcb-text-muted);
|
|
416
|
+
}
|
|
417
|
+
.ttcb-phone-national {
|
|
418
|
+
flex: 1; min-width: 0;
|
|
419
|
+
border: none; outline: none;
|
|
420
|
+
padding: 11px 12px;
|
|
421
|
+
font-size: 14px;
|
|
422
|
+
background: transparent;
|
|
423
|
+
color: var(--ttcb-text);
|
|
424
|
+
font-family: inherit;
|
|
425
|
+
}
|
|
426
|
+
.ttcb-phone-national::placeholder { color: var(--ttcb-text-muted); }
|
|
427
|
+
|
|
428
|
+
.ttcb-country-popover {
|
|
429
|
+
display: none;
|
|
430
|
+
flex-direction: column;
|
|
431
|
+
border: 1px solid var(--ttcb-border);
|
|
432
|
+
border-radius: 10px;
|
|
433
|
+
background: var(--ttcb-bg);
|
|
434
|
+
box-shadow: 0 8px 24px rgba(0,0,0,0.12);
|
|
435
|
+
max-height: 220px;
|
|
436
|
+
overflow: hidden;
|
|
437
|
+
margin-top: -8px;
|
|
438
|
+
}
|
|
439
|
+
.ttcb-country-popover.open { display: flex; }
|
|
440
|
+
.ttcb-country-search {
|
|
441
|
+
border: none; border-bottom: 1px solid var(--ttcb-border);
|
|
442
|
+
padding: 10px 12px;
|
|
443
|
+
font-size: 13px; outline: none;
|
|
444
|
+
background: var(--ttcb-input-bg);
|
|
445
|
+
color: var(--ttcb-text);
|
|
446
|
+
font-family: inherit;
|
|
447
|
+
}
|
|
448
|
+
.ttcb-country-list {
|
|
449
|
+
overflow-y: auto;
|
|
450
|
+
max-height: 176px;
|
|
451
|
+
}
|
|
452
|
+
.ttcb-country-item {
|
|
453
|
+
display: flex; align-items: center; gap: 8px;
|
|
454
|
+
width: 100%;
|
|
455
|
+
padding: 8px 12px;
|
|
456
|
+
border: none; background: none;
|
|
457
|
+
cursor: pointer;
|
|
458
|
+
font-family: inherit;
|
|
459
|
+
font-size: 13px;
|
|
460
|
+
color: var(--ttcb-text);
|
|
461
|
+
text-align: left;
|
|
462
|
+
}
|
|
463
|
+
.ttcb-country-item:hover,
|
|
464
|
+
.ttcb-country-item[aria-selected="true"] {
|
|
465
|
+
background: var(--ttcb-bg-secondary);
|
|
466
|
+
}
|
|
467
|
+
.ttcb-country-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
468
|
+
.ttcb-country-item-dial { color: var(--ttcb-text-muted); flex-shrink: 0; }
|
|
469
|
+
|
|
470
|
+
.ttcb-identify-error {
|
|
471
|
+
font-size: 12px; color: #ef4444; min-height: 16px;
|
|
472
|
+
margin-top: -4px;
|
|
473
|
+
}
|
|
474
|
+
.ttcb-identify-submit {
|
|
475
|
+
width: 100%; height: 46px;
|
|
476
|
+
background: ${e}; color: #fff;
|
|
477
|
+
border: none; border-radius: 999px; cursor: pointer;
|
|
478
|
+
font-size: 15px; font-weight: 600; font-family: inherit;
|
|
479
|
+
display: flex; align-items: center; justify-content: center; gap: 8px;
|
|
480
|
+
}
|
|
481
|
+
.ttcb-identify-submit svg {
|
|
482
|
+
width: 18px; height: 18px; stroke: #fff; fill: none;
|
|
483
|
+
}
|
|
484
|
+
.ttcb-identify-submit:hover { opacity: 0.92; }
|
|
485
|
+
.ttcb-identify-submit:disabled { opacity: 0.55; cursor: not-allowed; }
|
|
486
|
+
|
|
487
|
+
.ttcb-trust {
|
|
488
|
+
display: flex; align-items: center; justify-content: center; gap: 6px;
|
|
489
|
+
font-size: 11px; color: var(--ttcb-text-muted);
|
|
490
|
+
padding-bottom: 2px;
|
|
491
|
+
}
|
|
492
|
+
.ttcb-trust svg {
|
|
493
|
+
width: 14px; height: 14px;
|
|
494
|
+
stroke: var(--ttcb-online);
|
|
495
|
+
fill: none;
|
|
496
|
+
flex-shrink: 0;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
.ttcb-footer.hidden, .ttcb-messages.hidden { display: none; }
|
|
500
|
+
|
|
240
501
|
@media (max-width: 440px) {
|
|
241
502
|
.ttcb-panel { width: calc(100vw - 16px); right: 8px !important; left: 8px !important; bottom: 84px !important; }
|
|
242
503
|
.ttcb-fab.bottom-right { right: 16px; }
|
|
243
504
|
.ttcb-fab.bottom-left { left: 16px; }
|
|
244
505
|
}
|
|
245
|
-
`}function
|
|
246
|
-
`),
|
|
247
|
-
`),
|
|
506
|
+
`}function X(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function mt(e){let t=[],n=e.replace(/```[\w]*\n?([\s\S]*?)```/g,(e,n)=>{let r=t.length;return t.push(`<pre><code>${X(n.trim())}</code></pre>`),`\x04${r}\x05`});n=n.replace(/`([^`\n]+)`/g,(e,n)=>{let r=t.length;return t.push(`<code>${X(n)}</code>`),`\x02${r}\x03`}),n=X(n);let r=n.split(`
|
|
507
|
+
`),i=[],a=``,o=()=>{a&&=(i.push(`</${a}>`),``)};for(let e of r){let t;(t=e.match(/^### (.+)/))?(o(),i.push(`<h3>${t[1]}</h3>`)):(t=e.match(/^## (.+)/))?(o(),i.push(`<h2>${t[1]}</h2>`)):(t=e.match(/^# (.+)/))?(o(),i.push(`<h1>${t[1]}</h1>`)):(t=e.match(/^[*-] (.+)/))?(a!==`ul`&&(o(),i.push(`<ul>`),a=`ul`),i.push(`<li>${t[1]}</li>`)):(t=e.match(/^\d+\. (.+)/))?(a!==`ol`&&(o(),i.push(`<ol>`),a=`ol`),i.push(`<li>${t[1]}</li>`)):(o(),i.push(e))}return o(),n=i.join(`
|
|
508
|
+
`),n=n.replace(/\*\*(.+?)\*\*/gs,`<strong>$1</strong>`).replace(/__(.+?)__/gs,`<strong>$1</strong>`).replace(/\*(.+?)\*/gs,`<em>$1</em>`).replace(/_(.+?)_/gs,`<em>$1</em>`).replace(/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g,`<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>`),n=n.split(/\n{2,}/).map(e=>{let t=e.trim();return t?/^<(h[1-3]|ul|ol|pre|li)/.test(t)?t:t.split(/(\x04\d+\x05)/g).map(e=>{if(/^\x04\d+\x05$/.test(e))return e;let t=e.trim();return t?`<p>${t.replace(/\n/g,`<br>`)}</p>`:``}).join(``):``}).filter(Boolean).join(``),n=n.replace(/\x04(\d+)\x05/g,(e,n)=>t[+n]??``).replace(/\x02(\d+)\x03/g,(e,n)=>t[+n]??``),n}function ht(){return`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
248
509
|
<path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"/>
|
|
249
|
-
</svg>`}function
|
|
510
|
+
</svg>`}function gt(){return`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
250
511
|
<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/>
|
|
251
|
-
</svg>`}function
|
|
512
|
+
</svg>`}function _t(){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
|
252
513
|
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
|
|
253
514
|
<line x1="12" y1="8" x2="12" y2="14"/>
|
|
254
515
|
<line x1="9" y1="11" x2="15" y2="11"/>
|
|
255
|
-
</svg>`}function
|
|
516
|
+
</svg>`}function vt(){return`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
256
517
|
<path d="M20 2H4C2.9 2 2 2.9 2 4v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/>
|
|
257
|
-
</svg>`}function
|
|
518
|
+
</svg>`}function yt(){return`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
258
519
|
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
|
|
259
|
-
</svg>`}function
|
|
520
|
+
</svg>`}function bt(){return`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
260
521
|
<path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/>
|
|
261
|
-
</svg>`}function
|
|
522
|
+
</svg>`}function Z(){return`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
262
523
|
<path d="M20 9V7c0-1.1-.9-2-2-2h-3c0-1.66-1.34-3-3-3S9 3.34 9 5H6c-1.1 0-2 .9-2 2v2c-1.66 0-3 1.34-3 3s1.34 3 3 3v4c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-4c1.66 0 3-1.34 3-3s-1.34-3-3-3zm-2 10H6V7h12v12zm-9-6c-.83 0-1.5-.67-1.5-1.5S8.17 10 9 10s1.5.67 1.5 1.5S9.83 13 9 13zm6 0c-.83 0-1.5-.67-1.5-1.5S14.17 10 15 10s1.5.67 1.5 1.5S15.83 13 15 13z"/>
|
|
263
|
-
</svg>`}function
|
|
524
|
+
</svg>`}function xt(){return`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
264
525
|
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
|
|
265
|
-
</svg>`}function C(i,t){const e=document.createElement("div");e.className=`ttcb-msg ${t}`;const n=document.createElement("div");n.className="ttcb-msg-avatar",n.innerHTML=t==="human"?H():b();const s=document.createElement("div");return s.className="ttcb-bubble",t==="human"?s.textContent=i:s.innerHTML=L(i),e.appendChild(n),e.appendChild(s),e}function z(){const i=document.createElement("div");i.className="ttcb-msg ai",i.id="ttcb-typing";const t=document.createElement("div");t.className="ttcb-msg-avatar",t.innerHTML=b();const e=document.createElement("div");return e.className="ttcb-typing",e.innerHTML="<span></span><span></span><span></span>",i.appendChild(t),i.appendChild(e),i}class U{constructor(t,e){this.isOpen=!1,this.destroyed=!1,this.position=t.position??"bottom-right",this.callbacks=e,this.mount(t)}mount(t){this.host=document.createElement("div"),this.host.id="onedeskpro-chatbot-host",this.shadow=this.host.attachShadow({mode:"closed"});const e=document.createElement("style");e.textContent=_(t.primaryColor??"#2563EB",t.theme??"auto"),this.shadow.appendChild(e);const n=document.createElement("button");n.className=`ttcb-fab ${this.position}`,n.setAttribute("aria-label","Open chat"),n.innerHTML=O(),n.addEventListener("click",()=>this.toggle()),this.shadow.appendChild(n),this.panel=document.createElement("div"),this.panel.className=`ttcb-panel ${this.position} hidden`,this.panel.setAttribute("role","dialog"),this.panel.setAttribute("aria-modal","true"),this.panel.setAttribute("aria-label",t.chatbotName??"AI Assistant");const s=document.createElement("div");s.className="ttcb-header";const a=document.createElement("div");a.className="ttcb-avatar",a.innerHTML=b();const l=document.createElement("span");l.className="ttcb-header-title",l.textContent=t.chatbotName??"AI Assistant";const r=document.createElement("button");r.className="ttcb-new-session-btn",r.setAttribute("aria-label","New conversation"),r.title="New conversation",r.innerHTML=A(),r.addEventListener("click",()=>this.callbacks.onReset());const o=document.createElement("button");o.className="ttcb-close-btn",o.setAttribute("aria-label","Close chat"),o.innerHTML=B(),o.addEventListener("click",()=>this.close()),s.appendChild(a),s.appendChild(l),s.appendChild(r),s.appendChild(o),this.panel.appendChild(s),this.messagesContainer=document.createElement("div"),this.messagesContainer.className="ttcb-messages",this.messagesContainer.setAttribute("aria-live","polite"),this.messagesContainer.setAttribute("aria-label","Chat messages"),this.panel.appendChild(this.messagesContainer);const c=document.createElement("div");c.className="ttcb-footer";const d=document.createElement("form");d.className="ttcb-form",d.addEventListener("submit",p=>{p.preventDefault(),this.handleSend()}),this.input=document.createElement("input"),this.input.type="text",this.input.className="ttcb-input",this.input.placeholder=t.placeholder??"Type your messageโฆ",this.input.setAttribute("aria-label","Message input"),this.input.setAttribute("autocomplete","off"),this.sendBtn=document.createElement("button"),this.sendBtn.type="submit",this.sendBtn.className="ttcb-send-btn",this.sendBtn.innerHTML=$(),this.sendBtn.setAttribute("aria-label","Send message"),d.appendChild(this.input),d.appendChild(this.sendBtn),c.appendChild(d),this.panel.appendChild(c),this.shadow.appendChild(this.panel),this.attachToDocument(),this.showInitialLoading(),t.autoOpen&&this.open()}attachToDocument(){const t=()=>{this.destroyed||(document.body??document.documentElement).appendChild(this.host)};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}showInitialLoading(){this.messagesContainer.innerHTML="",this.input.disabled=!0,this.sendBtn.disabled=!0;const t=document.createElement("div");t.className="ttcb-initial-loading",t.id="ttcb-initial-loading";const e=document.createElement("div");e.className="ttcb-spinner";const n=document.createElement("p");n.textContent="Loadingโฆ",t.appendChild(e),t.appendChild(n),this.messagesContainer.appendChild(t)}showEmptyState(t){const e=document.createElement("div");e.className="ttcb-empty",e.id="ttcb-empty";const n=document.createElement("div");n.className="ttcb-empty-icon",n.innerHTML=b();const s=document.createElement("p"),a=document.createElement("strong");a.textContent=t,s.appendChild(document.createTextNode("Welcome to ")),s.appendChild(a);const l=document.createElement("p");l.textContent="Ask me anything โ I'm here to help!",l.style.marginTop="6px",l.style.fontSize="12px",e.appendChild(n),e.appendChild(s),e.appendChild(l),this.messagesContainer.appendChild(e)}removeEmptyState(){const t=this.shadow.getElementById("ttcb-empty");t&&t.remove()}handleSend(){const t=this.input.value.trim();t&&(this.input.value="",this.callbacks.onSend(t))}appendMessage(t){this.removeEmptyState();const e="message"in t?t.message:t,n=C(e.content,e.type);this.messagesContainer.appendChild(n),this.scrollToBottom()}setMessages(t){if(this.messagesContainer.innerHTML="",t.length!==0){for(const e of t){const n=C(e.message.content,e.message.type);this.messagesContainer.appendChild(n)}this.scrollToBottom()}}setLoading(t){if(this.sendBtn.disabled=t,this.input.disabled=t,t)this.shadow.getElementById("ttcb-typing")||(this.messagesContainer.appendChild(z()),this.scrollToBottom());else{const e=this.shadow.getElementById("ttcb-typing");e&&e.remove()}}open(){this.isOpen=!0,this.panel.classList.remove("hidden"),this.input.focus(),this.callbacks.onOpen()}close(){this.isOpen=!1,this.panel.classList.add("hidden"),this.callbacks.onClose()}toggle(){this.isOpen?this.close():this.open()}readyToChat(t){this.messagesContainer.innerHTML="",this.input.disabled=!1,this.sendBtn.disabled=!1;const e=this.shadow.querySelector(".ttcb-header-title");e&&t.chatbotName&&(e.textContent=t.chatbotName),t.welcomeMessage?this.appendMessage({type:"ai",content:t.welcomeMessage}):this.showEmptyState(t.chatbotName??"AI Assistant")}showBlocked(t){this.messagesContainer.innerHTML="";const e=document.createElement("div");e.className="ttcb-blocked";const n=document.createElement("div");n.className="ttcb-blocked-icon";const s=document.createElement("p");s.className="ttcb-blocked-title";const a=document.createElement("p");a.className="ttcb-blocked-desc",t==="no-prompt"?(n.innerHTML=E(),s.textContent="Business Context Required",a.textContent="Add a system prompt for this agent in the admin panel."):t==="no-directories"?(n.innerHTML=E(),s.textContent="Knowledge Base Required",a.textContent="Assign at least one knowledge-base directory to this agent in the admin panel."):(n.innerHTML=N(),s.textContent="Chatbot Settings Required",a.textContent="The chatbot has not been configured yet. Please set it up in the admin panel."),e.appendChild(n),e.appendChild(s),e.appendChild(a),this.messagesContainer.appendChild(e)}clearMessages(t){this.messagesContainer.innerHTML="",this.showEmptyState(t)}destroy(){this.destroyed=!0,this.host.remove()}scrollToBottom(){this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight}}const R={apiBaseUrl:x,chatbotName:"AI Assistant",primaryColor:"#2563EB",theme:"auto",position:"bottom-right",welcomeMessage:"",placeholder:"Type your messageโฆ",autoOpen:!1,sessionId:"",requestTimeoutMs:3e4};function j(i){return Object.fromEntries(Object.entries(i).filter(([,t])=>t!==void 0))}let D=0;const k=()=>Date.now()*1e3+D++%1e3;class T{constructor(){this.emitter=new w,this.session=new v,this.widget=null,this.callerSetName=!1,this.initToken=0,this._state={isOpen:!1,isLoading:!1,isReady:!1,blockReason:null,messages:[],sessionId:null,error:null}}setState(t){this._state={...this._state,...t},this.emitter.emit("state-change",this._state)}async init(t){var l,r,o;if(!t.apiKey)throw new Error("[onedeskpro-chatbot] `apiKey` is required to initialise the chatbot.");const e=++this.initToken;(l=this.widget)==null||l.destroy(),this.widget=null,this.callerSetName=t.chatbotName!==void 0,this.options={...R,...j(t)},this.apiClient=new f({baseUrl:this.options.apiBaseUrl,apiKey:this.options.apiKey,timeoutMs:this.options.requestTimeoutMs});const n=this.session.init(this.options.sessionId||void 0);this.setState({sessionId:n}),typeof window<"u"&&typeof document<"u"&&(this.widget=new U(this.options,{onSend:c=>void this.sendMessage(c),onOpen:()=>{this.setState({isOpen:!0}),this.emitter.emit("open")},onClose:()=>{this.setState({isOpen:!1}),this.emitter.emit("close")},onReset:()=>this.resetSession()}));const s=await this.fetchConfig();if(e!==this.initToken)return;s&&!this.callerSetName&&s.agentName.trim()&&(this.options.chatbotName=s.agentName);const a=(s==null?void 0:s.blockReason)??null;if(this.setState({blockReason:a,isReady:a===null}),a)(r=this.widget)==null||r.showBlocked(a);else if((o=this.widget)==null||o.readyToChat(this.options),await this.loadHistory(e),e!==this.initToken)return;this.emitter.emit("ready")}async fetchConfig(){try{return await this.apiClient.fetchConfig()}catch{return null}}async sendMessage(t){var a,l,r,o;const e=this.session.get();if(!this.apiClient||!e)throw new Error("[onedeskpro-chatbot] Call init() before sendMessage().");const n=t.trim();if(!n||this._state.isLoading)return;const s={id:k(),sessionId:e,message:{type:"human",content:n}};this.setState({messages:[...this._state.messages,s],isLoading:!0,error:null}),(a=this.widget)==null||a.appendMessage(s),(l=this.widget)==null||l.setLoading(!0),this.emitter.emit("message",s);try{const c=await this.apiClient.sendMessage({chatInput:n,sessionId:e}),d={id:k(),sessionId:e,message:{type:"ai",content:c.text}};this.setState({messages:[...this._state.messages,d],isLoading:!1}),(r=this.widget)==null||r.appendMessage(d),this.emitter.emit("message",d)}catch(c){const d=c instanceof Error?c:new Error(String(c));this.setState({error:d.message,isLoading:!1}),this.emitter.emit("error",d)}finally{(o=this.widget)==null||o.setLoading(!1)}}async loadHistory(t){var n;const e=this.session.get();if(e)try{const s=await this.apiClient.fetchHistory(e);if(t!==this.initToken)return;this.setState({messages:s}),s.length>0&&((n=this.widget)==null||n.setMessages(s))}catch{}}on(t,e){return this.emitter.on(t,e)}resetSession(){var e;if(!this._state.isReady)return;const t=this.session.reset();this.setState({sessionId:t,messages:[],error:null}),(e=this.widget)==null||e.clearMessages(this.options.chatbotName),this.emitter.emit("session-reset")}open(){var t;(t=this.widget)==null||t.open()}close(){var t;(t=this.widget)==null||t.close()}toggle(){var t;(t=this.widget)==null||t.toggle()}getState(){return{...this._state}}destroy(){var t;this.initToken++,(t=this.widget)==null||t.destroy(),this.widget=null,this.setState({isOpen:!1,isLoading:!1,isReady:!1})}}let m=null;const q={async init(i){return m=new T,await m.init(i),m},getInstance(){return m}};return h.ApiClient=f,h.ChatbotCore=T,h.DEFAULT_API_BASE_URL=x,h.DEFAULT_REQUEST_TIMEOUT_MS=3e4,h.EventEmitter=w,h.OnedeskProChatbot=q,h.SessionManager=v,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}),h}({});
|
|
526
|
+
</svg>`}function St(){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
|
527
|
+
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>
|
|
528
|
+
<circle cx="12" cy="7" r="4"/>
|
|
529
|
+
</svg>`}function Ct(){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
|
530
|
+
<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/>
|
|
531
|
+
<polyline points="22,6 12,13 2,6"/>
|
|
532
|
+
</svg>`}function wt(){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
|
533
|
+
<polyline points="6 9 12 15 18 9"/>
|
|
534
|
+
</svg>`}function Tt(){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
|
535
|
+
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
536
|
+
<polyline points="12 5 19 12 12 19"/>
|
|
537
|
+
</svg>`}function Et(){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
|
538
|
+
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
|
|
539
|
+
<polyline points="9 12 11 14 15 10"/>
|
|
540
|
+
</svg>`}function Dt(){return`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
541
|
+
<circle cx="12" cy="12" r="10" fill="currentColor"/>
|
|
542
|
+
<path d="M9 12l2 2 4-4" fill="none" stroke="#fff" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
543
|
+
</svg>`}function Ot(){return`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
544
|
+
<path fill="#F59E0B" d="M8 2.5l1.1 2.2 2.4.3-1.7 1.7.4 2.4L8 8l-2.2 1.1.4-2.4L4.5 5l2.4-.3L8 2.5z"/>
|
|
545
|
+
<path fill="#F59E0B" d="M16 3.5l.8 1.6 1.8.2-1.3 1.3.3 1.8L16 7.5l-1.6.9.3-1.8-1.3-1.3 1.8-.2L16 3.5z"/>
|
|
546
|
+
<path fill="#FBBF24" d="M12 11.5l1 2 2.2.3-1.6 1.6.4 2.2-2-1.1-2 1.1.4-2.2-1.6-1.6 2.2-.3 1-2z"/>
|
|
547
|
+
</svg>`}function kt(){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
|
548
|
+
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
|
|
549
|
+
<circle cx="9" cy="7" r="4"/>
|
|
550
|
+
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
|
|
551
|
+
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
|
|
552
|
+
</svg>`}function At(e,t){let n=document.createElement(`div`);n.className=`ttcb-msg ${t}`;let r=document.createElement(`div`);r.className=`ttcb-msg-avatar`,r.innerHTML=t===`human`?xt():t===`agent`?St():Z();let i=document.createElement(`div`);if(i.className=`ttcb-msg-body`,t===`agent`){let e=document.createElement(`span`);e.className=`ttcb-msg-label`,e.textContent=`Agent`,i.appendChild(e)}let a=document.createElement(`div`);return a.className=`ttcb-bubble`,t===`human`?a.textContent=e:a.innerHTML=mt(e),i.appendChild(a),n.appendChild(r),n.appendChild(i),n}function jt(){let e=document.createElement(`div`);e.className=`ttcb-msg ai`,e.id=`ttcb-typing`;let t=document.createElement(`div`);t.className=`ttcb-msg-avatar`,t.innerHTML=Z();let n=document.createElement(`div`);return n.className=`ttcb-typing`,n.innerHTML=`<span></span><span></span><span></span>`,e.appendChild(t),e.appendChild(n),e}var Mt=class{constructor(e,t){this.selectedCountry=dt,this.countryOpen=!1,this.isOpen=!1,this.destroyed=!1,this.position=e.position??`bottom-right`,this.callbacks=t,this.mount(e)}mount(e){this.host=document.createElement(`div`),this.host.id=`onedeskpro-chatbot-host`,this.shadow=this.host.attachShadow({mode:`closed`});let t=document.createElement(`style`);t.textContent=pt(e.primaryColor??`#2563EB`,e.theme??`auto`),this.shadow.appendChild(t);let n=document.createElement(`button`);n.className=`ttcb-fab ${this.position}`,n.setAttribute(`aria-label`,`Open chat`),n.innerHTML=vt(),n.addEventListener(`click`,()=>this.toggle()),this.shadow.appendChild(n),this.panel=document.createElement(`div`),this.panel.className=`ttcb-panel ${this.position} hidden ttcb-mode-compact`,this.panel.setAttribute(`role`,`dialog`),this.panel.setAttribute(`aria-modal`,`true`),this.panel.setAttribute(`aria-label`,e.chatbotName??`AI Assistant`),this.panel.appendChild(this.buildHeader(e)),this.identifyContainer=document.createElement(`div`),this.identifyContainer.className=`ttcb-identify`,this.buildIdentifyForm(this.identifyContainer),this.panel.appendChild(this.identifyContainer),this.messagesContainer=document.createElement(`div`),this.messagesContainer.className=`ttcb-messages`,this.messagesContainer.setAttribute(`aria-live`,`polite`),this.messagesContainer.setAttribute(`aria-label`,`Chat messages`),this.panel.appendChild(this.messagesContainer),this.modeBanner=document.createElement(`div`),this.modeBanner.className=`ttcb-mode-banner`,this.modeBanner.setAttribute(`role`,`status`),this.panel.appendChild(this.modeBanner),this.footer=document.createElement(`div`),this.footer.className=`ttcb-footer`;let r=document.createElement(`form`);r.className=`ttcb-form`,r.addEventListener(`submit`,e=>{e.preventDefault(),this.handleSend()}),this.input=document.createElement(`input`),this.input.type=`text`,this.input.className=`ttcb-input`,this.input.placeholder=e.placeholder??`Type your messageโฆ`,this.input.setAttribute(`aria-label`,`Message input`),this.input.setAttribute(`autocomplete`,`off`),this.sendBtn=document.createElement(`button`),this.sendBtn.type=`submit`,this.sendBtn.className=`ttcb-send-btn`,this.sendBtn.innerHTML=bt(),this.sendBtn.setAttribute(`aria-label`,`Send message`),r.appendChild(this.input),r.appendChild(this.sendBtn),this.footer.appendChild(r),this.panel.appendChild(this.footer),this.shadow.appendChild(this.panel),this.shadow.addEventListener(`click`,e=>{if(!this.countryOpen)return;let t=e.target;t&&(this.dialBtn.contains(t)||this.countryPopover.contains(t))||this.closeCountryPopover()}),this.attachToDocument(),this.showInitialLoading(),e.autoOpen&&this.open()}buildHeader(e){let t=document.createElement(`div`);t.className=`ttcb-header`;let n=document.createElement(`div`);n.className=`ttcb-avatar-wrap`;let r=document.createElement(`div`);r.className=`ttcb-avatar`,r.innerHTML=Z(),n.appendChild(r);let i=document.createElement(`div`);i.className=`ttcb-header-main`;let a=document.createElement(`div`);a.className=`ttcb-header-title-row`,this.headerTitle=document.createElement(`span`),this.headerTitle.className=`ttcb-header-title`,this.headerTitle.textContent=e.chatbotName??`AI Assistant`;let o=document.createElement(`span`);o.className=`ttcb-verified`,o.setAttribute(`aria-label`,`Verified`),o.innerHTML=Dt(),a.appendChild(this.headerTitle),a.appendChild(o);let s=document.createElement(`div`);s.className=`ttcb-header-meta`;let c=document.createElement(`span`);c.className=`ttcb-meta-online`,c.textContent=`Online`;let l=document.createElement(`span`);l.className=`ttcb-meta-sep`,l.setAttribute(`aria-hidden`,`true`);let u=document.createElement(`span`);u.className=`ttcb-meta-replies`,u.innerHTML=`${Ot()}<span>Replies instantly</span>`,s.appendChild(c),s.appendChild(l),s.appendChild(u),i.appendChild(a),i.appendChild(s);let d=document.createElement(`div`);d.className=`ttcb-header-actions`,this.requestHumanBtn=document.createElement(`button`),this.requestHumanBtn.type=`button`,this.requestHumanBtn.className=`ttcb-request-human-btn hidden`,this.requestHumanBtn.id=`ttcb-request-human-btn`,this.requestHumanBtn.setAttribute(`aria-label`,`Request human agent`),this.requestHumanBtn.title=`Request human agent`,this.requestHumanBtn.innerHTML=kt(),this.requestHumanBtn.addEventListener(`click`,()=>this.callbacks.onRequestHuman()),this.newSessionBtn=document.createElement(`button`),this.newSessionBtn.className=`ttcb-new-session-btn hidden`,this.newSessionBtn.setAttribute(`aria-label`,`New conversation`),this.newSessionBtn.title=`New conversation`,this.newSessionBtn.innerHTML=_t(),this.newSessionBtn.addEventListener(`click`,()=>this.callbacks.onReset());let f=document.createElement(`button`);return f.className=`ttcb-close-btn`,f.setAttribute(`aria-label`,`Close chat`),f.innerHTML=yt(),f.addEventListener(`click`,()=>this.close()),d.appendChild(this.requestHumanBtn),d.appendChild(this.newSessionBtn),d.appendChild(f),t.appendChild(n),t.appendChild(i),t.appendChild(d),t}setPanelMode(e){this.panel.classList.remove(`ttcb-mode-form`,`ttcb-mode-chat`,`ttcb-mode-compact`),this.panel.classList.add(`ttcb-mode-${e}`),e!==`chat`&&(this.requestHumanBtn.classList.add(`hidden`),this.newSessionBtn.classList.add(`hidden`),this.hideModeBanner())}buildIdentifyForm(e){let t=document.createElement(`form`);t.className=`ttcb-identify-form`,t.addEventListener(`submit`,e=>{e.preventDefault(),this.handleIdentifySubmit()}),this.nameInput=this.createIconField(t,{id:`name`,label:`Name`,required:!0,hint:`Required`,placeholder:`Your name`,type:`text`,autocomplete:`name`,icon:St()}),this.createPhoneField(t),this.emailInput=this.createIconField(t,{id:`email`,label:`Email (optional)`,required:!1,hint:`For chat transcript`,placeholder:`Email (optional)`,type:`email`,autocomplete:`email`,icon:Ct()}),this.identifyError=document.createElement(`p`),this.identifyError.className=`ttcb-identify-error`,t.appendChild(this.identifyError),this.identifySubmit=document.createElement(`button`),this.identifySubmit.type=`submit`,this.identifySubmit.className=`ttcb-identify-submit`,this.identifySubmit.innerHTML=`<span>Start Chatting</span>${Tt()}`,t.appendChild(this.identifySubmit),e.appendChild(t);let n=document.createElement(`div`);n.className=`ttcb-trust`,n.innerHTML=`${Et()}<span>Encrypted connection โข No spam, ever</span>`,e.appendChild(n)}createIconField(e,t){let n=document.createElement(`div`);n.className=`ttcb-field`;let r=document.createElement(`div`);r.className=`ttcb-field-label-row`;let i=document.createElement(`label`);i.className=`ttcb-label`,i.htmlFor=`ttcb-${t.id}`,t.required?i.innerHTML=`${t.label.replace(` (optional)`,``)} <span class="ttcb-req">*</span>`:i.textContent=t.label;let a=document.createElement(`span`);a.className=`ttcb-field-hint`,a.textContent=t.hint,r.appendChild(i),r.appendChild(a);let o=document.createElement(`div`);o.className=`ttcb-input-wrap`;let s=document.createElement(`span`);s.className=`ttcb-input-icon`,s.setAttribute(`aria-hidden`,`true`),s.innerHTML=t.icon;let c=document.createElement(`input`);return c.id=`ttcb-${t.id}`,c.name=t.id,c.type=t.type,c.className=`ttcb-identify-input`,c.placeholder=t.placeholder,c.required=t.required,c.autocomplete=t.autocomplete,o.appendChild(s),o.appendChild(c),n.appendChild(r),n.appendChild(o),e.appendChild(n),c}createPhoneField(e){let t=document.createElement(`div`);t.className=`ttcb-field`;let n=document.createElement(`div`);n.className=`ttcb-field-label-row`;let r=document.createElement(`label`);r.className=`ttcb-label`,r.htmlFor=`ttcb-tel`,r.innerHTML=`Phone <span class="ttcb-req">*</span>`;let i=document.createElement(`span`);i.className=`ttcb-field-hint`,i.textContent=`SMS / WhatsApp sync`,n.appendChild(r),n.appendChild(i);let a=document.createElement(`div`);a.className=`ttcb-phone-row`,a.id=`ttcb-phone-row`,this.dialBtn=document.createElement(`button`),this.dialBtn.type=`button`,this.dialBtn.className=`ttcb-dial-btn`,this.dialBtn.setAttribute(`aria-label`,`Select country code`),this.dialBtn.setAttribute(`aria-haspopup`,`listbox`),this.dialBtn.setAttribute(`aria-expanded`,`false`),this.dialFlag=document.createElement(`span`),this.dialFlag.className=`ttcb-dial-flag`,this.dialCode=document.createElement(`span`),this.dialCode.className=`ttcb-dial-code`,this.syncDialButton(),this.dialBtn.appendChild(this.dialFlag),this.dialBtn.appendChild(this.dialCode);let o=document.createElement(`span`);o.setAttribute(`aria-hidden`,`true`),o.innerHTML=wt(),this.dialBtn.appendChild(o),this.dialBtn.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this.toggleCountryPopover()}),this.phoneInput=document.createElement(`input`),this.phoneInput.id=`ttcb-tel`,this.phoneInput.name=`tel`,this.phoneInput.type=`tel`,this.phoneInput.className=`ttcb-phone-national`,this.phoneInput.placeholder=`1712-345678`,this.phoneInput.required=!0,this.phoneInput.autocomplete=`tel-national`,this.phoneInput.setAttribute(`inputmode`,`tel`),a.appendChild(this.dialBtn),a.appendChild(this.phoneInput),this.countryPopover=document.createElement(`div`),this.countryPopover.className=`ttcb-country-popover`,this.countryPopover.setAttribute(`role`,`listbox`),this.countrySearch=document.createElement(`input`),this.countrySearch.type=`search`,this.countrySearch.className=`ttcb-country-search`,this.countrySearch.placeholder=`Search countryโฆ`,this.countrySearch.setAttribute(`aria-label`,`Search countries`),this.countrySearch.addEventListener(`input`,()=>this.renderCountryList()),this.countryList=document.createElement(`div`),this.countryList.className=`ttcb-country-list`,this.countryPopover.appendChild(this.countrySearch),this.countryPopover.appendChild(this.countryList),this.renderCountryList(),t.appendChild(n),t.appendChild(a),t.appendChild(this.countryPopover),e.appendChild(t)}syncDialButton(){this.dialFlag.textContent=this.selectedCountry.flag,this.dialCode.textContent=`+${this.selectedCountry.dial}`}toggleCountryPopover(){this.countryOpen?this.closeCountryPopover():this.openCountryPopover()}openCountryPopover(){this.countryOpen=!0,this.countryPopover.classList.add(`open`),this.dialBtn.setAttribute(`aria-expanded`,`true`),this.countrySearch.value=``,this.renderCountryList(),queueMicrotask(()=>this.countrySearch.focus())}closeCountryPopover(){this.countryOpen=!1,this.countryPopover.classList.remove(`open`),this.dialBtn.setAttribute(`aria-expanded`,`false`)}renderCountryList(){let e=this.countrySearch.value.trim().toLowerCase(),t=Y.filter(t=>!e||t.name.toLowerCase().includes(e)||t.dial.includes(e)||t.iso.toLowerCase().includes(e)||`+${t.dial}`.includes(e));this.countryList.innerHTML=``;for(let e of t){let t=document.createElement(`button`);t.type=`button`,t.className=`ttcb-country-item`,t.setAttribute(`role`,`option`),t.setAttribute(`aria-selected`,e.iso===this.selectedCountry.iso?`true`:`false`),t.innerHTML=`
|
|
553
|
+
<span class="ttcb-dial-flag">${e.flag}</span>
|
|
554
|
+
<span class="ttcb-country-item-name">${e.name}</span>
|
|
555
|
+
<span class="ttcb-country-item-dial">+${e.dial}</span>
|
|
556
|
+
`,t.addEventListener(`click`,()=>{this.selectedCountry=e,this.syncDialButton(),this.closeCountryPopover(),this.phoneInput.focus()}),this.countryList.appendChild(t)}}attachToDocument(){let e=()=>{this.destroyed||(document.body??document.documentElement).appendChild(this.host)};document.body?e():document.addEventListener(`DOMContentLoaded`,e,{once:!0})}showInitialLoading(){this.setPanelMode(`compact`),this.identifyContainer.classList.remove(`visible`),this.messagesContainer.classList.remove(`hidden`),this.footer.classList.add(`hidden`),this.messagesContainer.innerHTML=``,this.input.disabled=!0,this.sendBtn.disabled=!0;let e=document.createElement(`div`);e.className=`ttcb-initial-loading`,e.id=`ttcb-initial-loading`;let t=document.createElement(`div`);t.className=`ttcb-spinner`;let n=document.createElement(`p`);n.textContent=`Loadingโฆ`,e.appendChild(t),e.appendChild(n),this.messagesContainer.appendChild(e)}showEmptyState(e){let t=document.createElement(`div`);t.className=`ttcb-empty`,t.id=`ttcb-empty`;let n=document.createElement(`div`);n.className=`ttcb-empty-icon`,n.innerHTML=Z();let r=document.createElement(`p`),i=document.createElement(`strong`);i.textContent=e,r.appendChild(document.createTextNode(`Welcome to `)),r.appendChild(i);let a=document.createElement(`p`);a.textContent=`Ask me anything โ I'm here to help!`,a.style.marginTop=`6px`,a.style.fontSize=`12px`,t.appendChild(n),t.appendChild(r),t.appendChild(a),this.messagesContainer.appendChild(t)}removeEmptyState(){let e=this.shadow.getElementById(`ttcb-empty`);e&&e.remove()}handleSend(){let e=this.input.value.trim();e&&!this.sendBtn.disabled&&(this.input.value=``,this.callbacks.onSend(e),this.input.focus())}handleIdentifySubmit(){let e=this.nameInput.value.trim(),t=ft(this.selectedCountry.dial,this.phoneInput.value),n=this.emailInput.value.trim();!e||!t?this.showIdentifyError(`Name and phone are required.`):(this.showIdentifyError(``),this.callbacks.onIdentify({name:e,phone:t,...n?{email:n}:{}}))}appendMessage(e){this.removeEmptyState();let t=`message`in e?e.message:e,n=At(t.content,t.type);this.messagesContainer.appendChild(n),this.scrollToBottom()}setMessages(e){if(this.messagesContainer.innerHTML=``,e.length!==0){for(let t of e){let e=At(t.message.content,t.message.type);this.messagesContainer.appendChild(e)}this.scrollToBottom()}}setLoading(e){if(this.sendBtn.disabled=e||this.input.disabled,e)this.shadow.getElementById(`ttcb-typing`)||(this.messagesContainer.appendChild(jt()),this.scrollToBottom()),this.input.focus();else{let e=this.shadow.getElementById(`ttcb-typing`);e&&e.remove(),this.input.disabled||this.input.focus()}}setIdentifyLoading(e){this.identifySubmit.disabled=e,this.nameInput.disabled=e,this.phoneInput.disabled=e,this.emailInput.disabled=e,this.dialBtn.disabled=e,this.shadow.getElementById(`ttcb-phone-row`)?.classList.toggle(`disabled`,e);for(let t of this.identifyContainer.querySelectorAll(`.ttcb-input-wrap`))t.classList.toggle(`disabled`,e);this.identifySubmit.innerHTML=e?`<span>Startingโฆ</span>`:`<span>Start Chatting</span>${Tt()}`,e&&this.closeCountryPopover()}showIdentifyError(e){this.identifyError.textContent=e}open(){this.isOpen=!0,this.panel.classList.remove(`hidden`),this.identifyContainer.classList.contains(`visible`)?this.nameInput.focus():this.input.focus(),this.callbacks.onOpen()}close(){this.isOpen=!1,this.closeCountryPopover(),this.panel.classList.add(`hidden`),this.callbacks.onClose()}toggle(){this.isOpen?this.close():this.open()}showIdentifyForm(e){this.setPanelMode(`form`),e.chatbotName&&(this.headerTitle.textContent=e.chatbotName),this.messagesContainer.classList.add(`hidden`),this.footer.classList.add(`hidden`),this.identifyContainer.classList.add(`visible`),this.showIdentifyError(``),this.setIdentifyLoading(!1)}readyToChat(e){this.setPanelMode(`chat`),this.closeCountryPopover(),this.identifyContainer.classList.remove(`visible`),this.messagesContainer.classList.remove(`hidden`),this.footer.classList.remove(`hidden`),this.messagesContainer.innerHTML=``,e.chatbotName&&(this.headerTitle.textContent=e.chatbotName),e.welcomeMessage?this.appendMessage({type:`ai`,content:e.welcomeMessage}):this.showEmptyState(e.chatbotName??`AI Assistant`),this.setMode(`ai`)}showBlocked(e,t){this.setPanelMode(`compact`),this.closeCountryPopover(),this.identifyContainer.classList.remove(`visible`),this.messagesContainer.classList.remove(`hidden`),this.footer.classList.add(`hidden`),this.messagesContainer.innerHTML=``;let n=document.createElement(`div`);n.className=`ttcb-blocked`;let r=document.createElement(`div`);r.className=`ttcb-blocked-icon`;let i=document.createElement(`p`);i.className=`ttcb-blocked-title`;let a=document.createElement(`p`);a.className=`ttcb-blocked-desc`,e===`no-prompt`?(r.innerHTML=gt(),i.textContent=`Business Context Required`,a.textContent=t??`Add a system prompt for this agent in the admin panel.`):e===`no-agent`?(r.innerHTML=ht(),i.textContent=`Channel Not Connected`,a.textContent=t??`Connect this Website channel under AI Agents โ Connected Channels.`):e===`no-directories`||e===`no-collections`?(r.innerHTML=gt(),i.textContent=`Knowledge Base Required`,a.textContent=t??`Assign at least one knowledge-base collection to this agent in the admin panel.`):(r.innerHTML=ht(),i.textContent=`Chatbot Settings Required`,a.textContent=t??`The chatbot has not been configured yet. Please set it up in the admin panel.`),n.appendChild(r),n.appendChild(i),n.appendChild(a),this.messagesContainer.appendChild(n)}clearMessages(e){this.messagesContainer.innerHTML=``,this.showEmptyState(e)}setMode(e,t){let n=this.panel.classList.contains(`ttcb-mode-chat`),r=t?.agentName,i=t?.canRequestHuman===!0,a=n&&i,o=n&&e===`closed`,s=e===`closed`;this.requestHumanBtn.classList.toggle(`hidden`,!a),this.newSessionBtn.classList.toggle(`hidden`,!o),this.input.disabled=s,s?this.sendBtn.disabled=!0:this.shadow.getElementById(`ttcb-typing`)||(this.sendBtn.disabled=!1),n?e===`waiting`?this.showModeBanner(`Waiting for a human agentโฆ`,`waiting`):e===`closed`?this.showModeBanner(`This conversation is closed`,`closed`):e===`human`&&r?.trim()?this.showModeBanner(`Connected with ${r.trim()}`,`human`):this.hideModeBanner():this.hideModeBanner()}showModeBanner(e,t){this.modeBanner.textContent=e,this.modeBanner.className=`ttcb-mode-banner visible ${t}`}hideModeBanner(){this.modeBanner.textContent=``,this.modeBanner.className=`ttcb-mode-banner`}destroy(){this.destroyed=!0,this.host.remove()}scrollToBottom(){this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight}},Nt={apiBaseUrl:s,chatbotName:`AI Assistant`,primaryColor:`#2563EB`,theme:`auto`,position:`bottom-right`,welcomeMessage:``,placeholder:`Type your messageโฆ`,autoOpen:!1,sessionId:``,requestTimeoutMs:r};function Pt(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var Ft=0,Q=()=>Date.now()*1e3+Ft++%1e3;function It(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.textMessage==`string`&&t.textMessage.trim())return t.textMessage.trim();if(typeof t.content==`string`&&t.content.trim())return t.content.trim();if(t.message&&typeof t.message==`object`){let e=t.message;if(typeof e.content==`string`&&e.content.trim())return e.content.trim();if(typeof e.textMessage==`string`&&e.textMessage.trim())return e.textMessage.trim()}return null}function Lt(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.id==`string`&&t.id)return t.id;if(t.message&&typeof t.message==`object`){let e=t.message;if(typeof e.id==`string`&&e.id)return e.id}return null}var Rt=class{constructor(){this.emitter=new c,this.visitorTokens=new ut,this.widget=null,this.sdkSocket=null,this.callerSetName=!1,this.hasActiveTicket=!1,this.lastPushId=null,this.initToken=0,this._state={isOpen:!1,isLoading:!1,isReady:!1,needsIdentify:!0,blockReason:null,messages:[],visitorToken:null,visitorName:null,error:null,mode:`ai`}}setState(e){this._state={...this._state,...e},this.emitter.emit(`state-change`,this._state)}applyMode(e,t){t?this.syncHasActiveTicket(t):e!==`ai`&&(this.hasActiveTicket=!0),this.setState({mode:e}),this.syncWidgetMode(e,t?.agentName),t&&this.emitter.emit(`ticket-status`,t)}syncHasActiveTicket(e){this.hasActiveTicket=!!(e.conversationId||e.mode!==`ai`)}syncWidgetMode(e,t){this.widget?.setMode(e,{agentName:t,canRequestHuman:e===`ai`&&this.hasActiveTicket})}async init(e){if(!e.apiKey)throw Error("[onedeskpro-chatbot] `apiKey` is required to initialise the chatbot.");let t=++this.initToken;this.disconnectSdkSocket(),this.widget?.destroy(),this.widget=null,this.callerSetName=e.chatbotName!==void 0,this.options={...Nt,...Pt(e)},this.apiClient=new o({baseUrl:this.options.apiBaseUrl,apiKey:this.options.apiKey,timeoutMs:this.options.requestTimeoutMs}),this.hasActiveTicket=!1,this.setState({visitorToken:null,visitorName:null,needsIdentify:!0,messages:[],error:null,mode:`ai`}),typeof window<`u`&&typeof document<`u`&&(this.widget=new Mt(this.options,{onSend:e=>void this.sendMessage(e),onIdentify:e=>void this.submitIdentify(e),onOpen:()=>{this.setState({isOpen:!0}),this.emitter.emit(`open`)},onClose:()=>{this.setState({isOpen:!1}),this.emitter.emit(`close`)},onReset:()=>this.resetSession(),onRequestHuman:()=>void this.requestHuman()}));let n=null,r=null;try{n=await this.apiClient.fetchConfig()}catch(e){r=e}if(t!==this.initToken)return;if(r){this.handleConfigError(r),this.emitter.emit(`ready`);return}if(!n){this.emitter.emit(`ready`);return}!this.callerSetName&&n.agentName.trim()&&(this.options.chatbotName=n.agentName);let i=n.blockReason??null;if(this.setState({blockReason:i,isReady:i===null,error:null}),i)this.widget?.showBlocked(i);else if(this.visitorTokens.setScope(n.agentId),await this.resolveVisitorGate(t),t!==this.initToken)return;this.emitter.emit(`ready`)}handleConfigError(e){let t=a(e)?e:null,n=t?.apiError.message??(e instanceof Error?e.message:`Failed to load chatbot config.`),r=t?.apiError.code,i=t?.status;r===`agent_not_assigned`?(this.setState({isReady:!1,blockReason:`no-agent`,error:n}),this.widget?.showBlocked(`no-agent`)):i===403?(this.setState({isReady:!1,blockReason:null,error:n}),this.widget?.showBlocked(null,n)):this.setState({isReady:!1,blockReason:null,error:n})}async resolveVisitorGate(e){let t=this.visitorTokens.get();if(t){try{let n=await this.apiClient.verifyVisitor(t);if(e!==this.initToken)return;if(n.valid){await this.enterChat(t,n.name,e);return}}catch{}this.visitorTokens.clear()}this.setState({needsIdentify:!0,visitorToken:null,visitorName:null}),this.widget?.showIdentifyForm(this.options)}async enterChat(e,t,n=this.initToken){this.visitorTokens.set(e),this.setState({visitorToken:e,visitorName:t,needsIdentify:!1,messages:[],error:null}),this.widget?.readyToChat(this.options),this.connectSdkSocket(e),await this.restoreTicketStatus(e,n)}connectSdkSocket(e){this.sdkSocket||=new ot,this.sdkSocket.connect({baseUrl:this.options.apiBaseUrl,apiKey:this.options.apiKey,visitorToken:e,onTicketStatus:e=>this.handleTicketStatus(e),onMessageReceive:e=>this.handleMessageReceive(e),onReconnect:()=>{let e=this.visitorTokens.get()??this._state.visitorToken;e&&this.restoreTicketStatus(e,this.initToken)},onConnectError:e=>{this.emitter.emit(`error`,e)}})}disconnectSdkSocket(){this.sdkSocket?.disconnect(),this.sdkSocket=null}async restoreTicketStatus(e,t){try{let n=await this.apiClient.fetchTicketStatus(e);if(t!==this.initToken)return;this.applyMode(n.mode,n)}catch{}}handleTicketStatus(e){e?.mode&&this.applyMode(e.mode,e)}handleMessageReceive(e){if(this._state.mode===`ai`)return;let t=It(e);if(!t)return;let n=Lt(e),r=this._state.messages[this._state.messages.length-1];if(r?.message.content===t&&(r.message.type===`ai`||r.message.type===`agent`&&(!n||n===this.lastPushId)))return;this.lastPushId=n;let i=this.visitorTokens.get()??this._state.visitorToken??``,a={id:Q(),sessionId:i,message:{type:`agent`,content:t}};this.setState({messages:[...this._state.messages,a]}),this.widget?.appendMessage(a),this.emitter.emit(`message`,a)}async submitIdentify(e){if(!this.apiClient||this._state.isLoading||!this._state.isReady)return;let t=e.name.trim(),n=e.phone.trim();if(t&&n){this.setState({isLoading:!0,error:null}),this.widget?.setIdentifyLoading(!0);try{let r=await this.apiClient.identify({name:t,phone:n,...e.email?.trim()?{email:e.email.trim()}:{}});await this.enterChat(r.visitorToken,t)}catch(e){let t=e instanceof Error?e:Error(String(e));this.setState({error:t.message}),this.widget?.showIdentifyError(t.message),this.emitter.emit(`error`,t)}finally{this.setState({isLoading:!1}),this.widget?.setIdentifyLoading(!1)}}}async requestHuman(){if(!this.apiClient||this._state.mode!==`ai`||!this.hasActiveTicket||this._state.isLoading)return;let e=this.visitorTokens.get()??this._state.visitorToken;if(!e)throw Error(`[onedeskpro-chatbot] Identify before requestHuman().`);this.setState({isLoading:!0,error:null});try{let t=await this.apiClient.requestHuman(e);this.applyMode(t.mode,t),this.emitter.emit(`human-requested`)}catch(e){let t=e instanceof Error?e:Error(String(e));this.setState({error:t.message}),this.emitter.emit(`error`,t)}finally{this.setState({isLoading:!1})}}async sendMessage(e){let t=this.visitorTokens.get()??this._state.visitorToken;if(!this.apiClient||!t)throw Error(`[onedeskpro-chatbot] Identify before sendMessage().`);if(this._state.mode===`closed`){this.setState({error:`Conversation is closed`});return}let n=e.trim();if(!n||this._state.isLoading||this._state.needsIdentify)return;let r={id:Q(),sessionId:t,message:{type:`human`,content:n}},i=this._state.mode,a=i===`ai`;this.setState({messages:[...this._state.messages,r],isLoading:!0,error:null}),this.widget?.appendMessage(r),a&&this.widget?.setLoading(!0),this.emitter.emit(`message`,r);try{let e=await this.apiClient.sendMessage({chatInput:n,visitorToken:t});this.hasActiveTicket=!0;let r=e.mode??i,a=[...this._state.messages],o=(e.text??``).trim();if(r!==i&&(this.setState({mode:r}),this.syncWidgetMode(r),this.emitter.emit(`ticket-status`,{mode:r})),o){let t=a[a.length-1];if(t?.message.type!==`agent`&&t?.message.type!==`ai`||t.message.content!==o){let t={id:Q(),sessionId:e.sessionId,message:{type:`ai`,content:o}};a.push(t),this.widget?.appendMessage(t),this.emitter.emit(`message`,t)}}this.setState({messages:a,isLoading:!1,mode:r}),this.syncWidgetMode(r)}catch(e){let t=e instanceof Error?e:Error(String(e));this.setState({error:t.message,isLoading:!1}),this.emitter.emit(`error`,t)}finally{this.widget?.setLoading(!1)}}on(e,t){return this.emitter.on(e,t)}resetSession(){this._state.isReady&&!this._state.needsIdentify&&this._state.mode===`closed`&&(this.hasActiveTicket=!1,this.setState({messages:[],error:null,mode:`ai`}),this.widget?.clearMessages(this.options.chatbotName),this.syncWidgetMode(`ai`),this.emitter.emit(`session-reset`))}open(){this.widget?.open()}close(){this.widget?.close()}toggle(){this.widget?.toggle()}getState(){return{...this._state}}destroy(){this.initToken++,this.disconnectSdkSocket(),this.widget?.destroy(),this.widget=null,this.setState({isOpen:!1,isLoading:!1,isReady:!1,needsIdentify:!0})}},$=null;return e.ApiClient=o,e.ChatbotCore=Rt,e.DEFAULT_API_BASE_URL=s,e.DEFAULT_REQUEST_TIMEOUT_MS=r,e.EventEmitter=c,e.OnedeskProChatbot={async init(e){return $=new Rt,await $.init(e),$},getInstance(){return $}},e.SdkSocket=ot,e.SessionManager=ut,e.isChatbotRequestError=a,e.resolveSdkSocketUrl=at,e})({});
|