xtro-edge-chatbolt 1.0.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.
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ChatBolt={})}(this,function(e){"use strict";const t=Object.create(null);t.open="0",t.close="1",t.ping="2",t.pong="3",t.message="4",t.upgrade="5",t.noop="6";const n=Object.create(null);Object.keys(t).forEach(e=>{n[t[e]]=e});const s={type:"error",data:"parser error"},r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),i="function"==typeof ArrayBuffer,o=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,a=({type:e,data:n},s,a)=>r&&n instanceof Blob?s?a(n):c(n,a):i&&(n instanceof ArrayBuffer||o(n))?s?a(n):c(new Blob([n]),a):a(t[e]+(n||"")),c=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function l(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let h;const p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)u[p.charCodeAt(e)]=e;const d="function"==typeof ArrayBuffer,g=(e,t)=>{if("string"!=typeof e)return{type:"message",data:f(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:b(e.substring(1),t)};return n[r]?e.length>1?{type:n[r],data:e.substring(1)}:{type:n[r]}:s},b=(e,t)=>{if(d){const n=(e=>{let t,n,s,r,i,o=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);const l=new ArrayBuffer(o),h=new Uint8Array(l);for(t=0;t<a;t+=4)n=u[e.charCodeAt(t)],s=u[e.charCodeAt(t+1)],r=u[e.charCodeAt(t+2)],i=u[e.charCodeAt(t+3)],h[c++]=n<<2|s>>4,h[c++]=(15&s)<<4|r>>2,h[c++]=(3&r)<<6|63&i;return l})(e);return f(n,t)}return{base64:!0,data:e}},f=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,m=String.fromCharCode(30);function k(){return new TransformStream({transform(e,t){!function(e,t){r&&e.data instanceof Blob?e.data.arrayBuffer().then(l).then(t):i&&(e.data instanceof ArrayBuffer||o(e.data))?t(l(e.data)):a(e,!1,e=>{h||(h=new TextEncoder),t(h.encode(e))})}(e,n=>{const s=n.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const e=new DataView(r.buffer);e.setUint8(0,126),e.setUint16(1,s)}else{r=new Uint8Array(9);const e=new DataView(r.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(s))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)})}})}let x;function y(e){return e.reduce((e,t)=>e+t.length,0)}function w(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let s=0;for(let r=0;r<t;r++)n[r]=e[0][s++],s===e[0].length&&(e.shift(),s=0);return e.length&&s<e[0].length&&(e[0]=e[0].slice(s)),n}function v(e){if(e)return function(e){for(var t in v.prototype)e[t]=v.prototype[t];return e}(e)}v.prototype.on=v.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},v.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},v.prototype.off=v.prototype.removeListener=v.prototype.removeAllListeners=v.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,s=this._callbacks["$"+e];if(!s)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var r=0;r<s.length;r++)if((n=s[r])===t||n.fn===t){s.splice(r,1);break}return 0===s.length&&delete this._callbacks["$"+e],this},v.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(n){s=0;for(var r=(n=n.slice(0)).length;s<r;++s)n[s].apply(this,t)}return this},v.prototype.emitReserved=v.prototype.emit,v.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},v.prototype.hasListeners=function(e){return!!this.listeners(e).length};const _="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),T="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function R(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const S=T.setTimeout,E=T.clearTimeout;function A(e,t){t.useNativeTimers?(e.setTimeoutFn=S.bind(T),e.clearTimeoutFn=E.bind(T)):(e.setTimeoutFn=T.setTimeout.bind(T),e.clearTimeoutFn=T.clearTimeout.bind(T))}function C(e){return"string"==typeof e?function(e){let t=0,n=0;for(let s=0,r=e.length;s<r;s++)t=e.charCodeAt(s),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(s++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))}function B(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class $ extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class O extends v{constructor(e){super(),this.writable=!1,A(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 $(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=g(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(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&443!==Number(this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}class z extends O{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const 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){((e,t)=>{const n=e.split(m),s=[];for(let e=0;e<n.length;e++){const r=g(n[e],t);if(s.push(r),"error"===r.type)break}return s})(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const n=e.length,s=new Array(n);let r=0;e.forEach((e,i)=>{a(e,!1,e=>{s[i]=e,++r===n&&t(s.join(m))})})})(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=B()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}let L=!1;try{L="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const P=L;function I(){}class q extends z{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){const 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}}class N extends v{constructor(e,t,n){super(),this.createRequest=e,A(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=void 0!==n.data?n.data:null,this._create()}_create(){var e;const t=R(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(e){}if("POST"===this._method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this._opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(n.getResponseHeader("set-cookie"))),4===n.readyState&&(200===n.status||1223===n.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof n.status?n.status:0)},0))},n.send(this._data)}catch(e){return void this.setTimeoutFn(()=>{this._onError(e)},0)}"undefined"!=typeof document&&(this._index=N.requestsCount++,N.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=I,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete N.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(N.requestsCount=0,N.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",M);else if("function"==typeof addEventListener){addEventListener("onpagehide"in T?"pagehide":"unload",M,!1)}function M(){for(let e in N.requests)N.requests.hasOwnProperty(e)&&N.requests[e].abort()}const D=function(){const e=j({xdomain:!1});return e&&null!==e.responseType}();function j(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||P))return new XMLHttpRequest}catch(e){}if(!t)try{return new(T[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}const F="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class U extends O{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=F?{}:R(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++){const n=e[t],s=t===e.length-1;a(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch(e){}s&&_(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=B()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const H=T.WebSocket||T.MozWebSocket;const V={websocket:class extends U{createSocket(e,t,n){return F?new H(e,t,n):t?new H(e,t):new H(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends O{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=>{const t=function(e,t){x||(x=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(a,c){for(n.push(a);;){if(0===r){if(y(n)<1)break;const e=w(n,1);o=!(128&~e[0]),i=127&e[0],r=i<126?3:126===i?1:2}else if(1===r){if(y(n)<2)break;const e=w(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(y(n)<8)break;const e=w(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),o=t.getUint32(0);if(o>Math.pow(2,21)-1){c.enqueue(s);break}i=o*Math.pow(2,32)+t.getUint32(4),r=3}else{if(y(n)<i)break;const e=w(n,i);c.enqueue(g(o?e:x.decode(e),t)),r=0}if(0===i||i>e){c.enqueue(s);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=k();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],s=t===e.length-1;this._writer.write(n).then(()=>{s&&_(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}},polling:class extends q{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=D&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new N(j,this.uri(),e)}}},W=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Q=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Z(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),s=e.indexOf("]");-1!=n&&-1!=s&&(e=e.substring(0,n)+e.substring(n,s).replace(/:/g,";")+e.substring(s,e.length));let r=W.exec(e||""),i={},o=14;for(;o--;)i[Q[o]]=r[o]||"";return-1!=n&&-1!=s&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=function(e,t){const n=/\/{2,9}/g,s=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||s.splice(0,1);"/"==t.slice(-1)&&s.splice(s.length-1,1);return s}(0,i.path),i.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,s){t&&(n[t]=s)}),n}(0,i.query),i}const K="function"==typeof addEventListener&&"function"==typeof removeEventListener,Y=[];K&&addEventListener("offline",()=>{Y.forEach(e=>e())},!1);class G extends v{constructor(e,t){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const n=Z(e);t.hostname=n.host,t.secure="https"===n.protocol||"wss"===n.protocol,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=Z(t.host).host);A(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{const 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?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},n=e.split("&");for(let e=0,s=n.length;e<s;e++){let s=n[e].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}(this.opts.query)),K&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Y.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const 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(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const e=this.opts.rememberUpgrade&&G.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}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",G.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)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":const t=new 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(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const 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,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const n=this.writeBuffer[t].data;if(n&&(e+=C(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,_(()=>{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,s){if("function"==typeof t&&(s=t,t=void 0),"function"==typeof n&&(s=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const r={type:e,data:t,options:n};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),s&&this.once("flush",s),this.flush()}close(){const 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"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(G.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),K&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=Y.indexOf(this._offlineEventListener);-1!==e&&Y.splice(e,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}G.protocol=4;class X extends G{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&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;G.priorWebsocketSuccess=!1;const s=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",e=>{if(!n)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;G.priorWebsocketSuccess="websocket"===t.name,this.transport.pause(()=>{n||"closed"!==this.readyState&&(l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}}))};function r(){n||(n=!0,l(),t.close(),t=null)}const i=e=>{const n=new Error("probe error: "+e);n.transport=t.name,r(),this.emitReserved("upgradeError",n)};function o(){i("transport closed")}function a(){i("socket closed")}function c(e){t&&e.name!==t.name&&r()}const l=()=>{t.removeListener("open",s),t.removeListener("error",i),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",s),t.once("error",i),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}let J=class extends X{constructor(e,t={}){const n="object"==typeof e?e:t;(!n.transports||n.transports&&"string"==typeof n.transports[0])&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(e=>V[e]).filter(e=>!!e)),super(e,n)}};const ee="function"==typeof ArrayBuffer,te=Object.prototype.toString,ne="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===te.call(Blob),se="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===te.call(File);function re(e){return ee&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||ne&&e instanceof Blob||se&&e instanceof File}function ie(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(ie(e[t]))return!0;return!1}if(re(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return ie(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&ie(e[t]))return!0;return!1}function oe(e){const t=[],n=e.data,s=e;return s.data=ae(n,t),s.attachments=t.length,{packet:s,buffers:t}}function ae(e,t){if(!e)return e;if(re(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let s=0;s<e.length;s++)n[s]=ae(e[s],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=ae(e[s],t));return n}return e}function ce(e,t){return e.data=le(e.data,t),delete e.attachments,e}function le(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=le(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=le(e[n],t));return e}const he=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var pe;!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"}(pe||(pe={}));class ue extends v{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===pe.BINARY_EVENT;n||t.type===pe.BINARY_ACK?(t.type=n?pe.EVENT:pe.ACK,this.reconstructor=new de(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!re(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===pe[n.type])throw new Error("unknown packet type "+n.type);if(n.type===pe.BINARY_EVENT||n.type===pe.BINARY_ACK){const s=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const r=e.substring(s,t);if(r!=Number(r)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(r)}if("/"===e.charAt(t+1)){const s=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(s,t)}else n.nsp="/";const s=e.charAt(t+1);if(""!==s&&Number(s)==s){const s=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){const s=this.tryParse(e.substr(t));if(!ue.isPayloadValid(n.type,s))throw new Error("invalid payload");n.data=s}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case pe.CONNECT:return ge(t);case pe.DISCONNECT:return void 0===t;case pe.CONNECT_ERROR:return"string"==typeof t||ge(t);case pe.EVENT:case pe.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===he.indexOf(t[0]));case pe.ACK:case pe.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class de{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=ce(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function ge(e){return"[object Object]"===Object.prototype.toString.call(e)}var be=Object.freeze({__proto__:null,Decoder:ue,Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==pe.EVENT&&e.type!==pe.ACK||!ie(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===pe.EVENT?pe.BINARY_EVENT:pe.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==pe.BINARY_EVENT&&e.type!==pe.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=oe(e),n=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(n),s}},get PacketType(){return pe}});function fe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const me=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ke extends v{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;const e=this.io;this.subs=[fe(e,"open",this.onopen.bind(this)),fe(e,"packet",this.onpacket.bind(this)),fe(e,"error",this.onerror.bind(this)),fe(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,s,r;if(me.hasOwnProperty(e))throw new 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;const i={type:pe.EVENT,data:t,options:{}};if(i.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,n=t.pop();this._registerAckCallback(e,n),i.id=e}const o=null===(s=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===s?void 0:s.writable,a=this.connected&&!(null===(r=this.io.engine)||void 0===r?void 0:r._hasPingExpired());return this.flags.volatile&&!o||(a?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i)),this.flags={},this}_registerAckCallback(e,t){var n;const s=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===s)return void(this.acks[e]=t);const 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,new Error("operation has timed out"))},s),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,s)=>{const r=(e,t)=>e?s(e):n(t);r.withError=!0,t.push(r),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...s)=>{this._queue[0];return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...s)),n.pending=!1,this._drainQueue()}),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const 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(){"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:pe.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)){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case pe.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new 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 pe.EVENT:case pe.BINARY_EVENT:this.onevent(e);break;case pe.ACK:case pe.BINARY_ACK:this.onack(e);break;case pe.DISCONNECT:this.ondisconnect();break;case pe.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&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){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...s){n||(n=!0,t.packet({type:pe.ACK,id:e,data:s}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(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()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:pe.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){const 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){const 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){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function xe(e){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}xe.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},xe.prototype.reset=function(){this.attempts=0},xe.prototype.setMin=function(e){this.ms=e},xe.prototype.setMax=function(e){this.max=e},xe.prototype.setJitter=function(e){this.jitter=e};class ye extends v{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,A(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new xe({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const s=t.parser||be;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new J(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const s=fe(t,"open",function(){n.onopen(),e&&e()}),r=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},i=fe(t,"error",r);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn(()=>{s(),r(new Error("timeout")),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(s),this.subs.push(i),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(fe(e,"ping",this.onping.bind(this)),fe(e,"data",this.ondata.bind(this)),fe(e,"error",this.onerror.bind(this)),fe(e,"close",this.onclose.bind(this)),fe(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){_(()=>{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 ke(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const 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(),null===(n=this.engine)||void 0===n||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;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const 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(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const we={};function ve(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let s=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),s=Z(e)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const r=-1!==s.host.indexOf(":")?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+r+":"+s.port+t,s.href=s.protocol+"://"+r+(n&&n.port===s.port?"":":"+s.port),s}(e,(t=t||{}).path||"/socket.io"),s=n.source,r=n.id,i=n.path,o=we[r]&&i in we[r].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new ye(s,t):(we[r]||(we[r]=new ye(s,t)),a=we[r]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}function _e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}Object.assign(ve,{Manager:ye,Socket:ke,io:ve,connect:ve});var Te={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Re(e){Te=e}var Se={exec:()=>null};function Ee(e,t=""){let n="string"==typeof e?e:e.source,s={replace:(e,t)=>{let r="string"==typeof t?t:t.source;return r=r.replace(Ce.caret,"$1"),n=n.replace(e,r),s},getRegex:()=>new RegExp(n,t)};return s}var Ae=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ce={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},Be=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,$e=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Oe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ze=Ee(Oe).replace(/bull/g,$e).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Le=Ee(Oe).replace(/bull/g,$e).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Pe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ie=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qe=Ee(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ie).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ne=Ee(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,$e).getRegex(),Me="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",De=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,je=Ee("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",De).replace("tag",Me).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Fe=Ee(Pe).replace("hr",Be).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Me).getRegex(),Ue={blockquote:Ee(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Fe).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:qe,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:Be,html:je,lheading:ze,list:Ne,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Fe,table:Se,text:/^[^\n]+/},He=Ee("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Be).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Me).getRegex(),Ve={...Ue,lheading:Le,table:He,paragraph:Ee(Pe).replace("hr",Be).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",He).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Me).getRegex()},We={...Ue,html:Ee("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",De).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Se,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ee(Pe).replace("hr",Be).replace("heading"," *#{1,6} *[^\n]").replace("lheading",ze).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Qe=/^( {2,}|\\)\n(?!\s*$)/,Ze=/[\p{P}\p{S}]/u,Ke=/[\s\p{P}\p{S}]/u,Ye=/[^\s\p{P}\p{S}]/u,Ge=Ee(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ke).getRegex(),Xe=/(?!~)[\p{P}\p{S}]/u,Je=/(?![*_])[\p{P}\p{S}]/u,et=Ee(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ae?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),tt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,nt=Ee(tt,"u").replace(/punct/g,Ze).getRegex(),st=Ee(tt,"u").replace(/punct/g,Xe).getRegex(),rt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",it=Ee(rt,"gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Ke).replace(/punct/g,Ze).getRegex(),ot=Ee(rt,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Xe).getRegex(),at=Ee("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Ke).replace(/punct/g,Ze).getRegex(),ct=Ee(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Je).getRegex(),lt=Ee("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|[*_])/u).replace(/punctSpace/g,/(?![*_])[\s\p{P}\p{S}]/u).replace(/punct/g,Je).getRegex(),ht=Ee(/\\(punct)/,"gu").replace(/punct/g,Ze).getRegex(),pt=Ee(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ut=Ee(De).replace("(?:--\x3e|$)","--\x3e").getRegex(),dt=Ee("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ut).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),gt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,bt=Ee(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",gt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ft=Ee(/^!?\[(label)\]\[(ref)\]/).replace("label",gt).replace("ref",Ie).getRegex(),mt=Ee(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ie).getRegex(),kt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,xt={_backpedal:Se,anyPunctuation:ht,autolink:pt,blockSkip:et,br:Qe,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:Se,delLDelim:Se,delRDelim:Se,emStrongLDelim:nt,emStrongRDelimAst:it,emStrongRDelimUnd:at,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:bt,nolink:mt,punctuation:Ge,reflink:ft,reflinkSearch:Ee("reflink|nolink(?!\\()","g").replace("reflink",ft).replace("nolink",mt).getRegex(),tag:dt,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:Se},yt={...xt,link:Ee(/^!?\[(label)\]\((.*?)\)/).replace("label",gt).getRegex(),reflink:Ee(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",gt).getRegex()},wt={...xt,emStrongRDelimAst:ot,emStrongLDelim:st,delLDelim:ct,delRDelim:lt,url:Ee(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",kt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Ee(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",kt).getRegex()},vt={...wt,br:Ee(Qe).replace("{2,}","*").getRegex(),text:Ee(wt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},_t={normal:Ue,gfm:Ve,pedantic:We},Tt={normal:xt,gfm:wt,breaks:vt,pedantic:yt},Rt={"&":"&","<":"<",">":">",'"':""","'":"'"},St=e=>Rt[e];function Et(e,t){if(t){if(Ce.escapeTest.test(e))return e.replace(Ce.escapeReplace,St)}else if(Ce.escapeTestNoEncode.test(e))return e.replace(Ce.escapeReplaceNoEncode,St);return e}function At(e){try{e=encodeURI(e).replace(Ce.percentDecode,"%")}catch{return null}return e}function Ct(e,t){let n=e.replace(Ce.findPipe,(e,t,n)=>{let s=!1,r=t;for(;--r>=0&&"\\"===n[r];)s=!s;return s?"|":" |"}).split(Ce.splitPipe),s=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(Ce.slashPipe,"|");return n}function Bt(e,t,n){let s=e.length;if(0===s)return"";let r=0;for(;r<s;){if(e.charAt(s-r-1)!==t)break;r++}return e.slice(0,s-r)}function $t(e,t=0){let n=t,s="";for(let t of e)if("\t"===t){let e=4-n%4;s+=" ".repeat(e),n+=e}else s+=t,n++;return s}function Ot(e,t,n,s,r){let i=t.href,o=t.title||null,a=e[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let c={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:i,title:o,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,c}var zt=class{options;rules;lexer;constructor(e){this.options=e||Te}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Bt(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(null===s)return t;let r=s[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[s]=t;return s.length>=r.length?e.slice(r.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Bt(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Bt(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Bt(t[0],"\n").split("\n"),n="",s="",r=[];for(;e.length>0;){let t,i=!1,o=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))o.push(e[t]),i=!0;else{if(i)break;o.push(e[t])}e=e.slice(t);let a=o.join("\n"),c=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,s=s?`${s}\n${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,r,!0),this.lexer.state.top=l,0===e.length)break;let h=r.at(-1);if("code"===h?.type)break;if("blockquote"===h?.type){let t=h,i=t.raw+"\n"+e.join("\n"),o=this.blockquote(i);r[r.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,s=s.substring(0,s.length-t.text.length)+o.text;break}if("list"===h?.type){let t=h,i=t.raw+"\n"+e.join("\n"),o=this.list(i);r[r.length-1]=o,n=n.substring(0,n.length-h.raw.length)+o.raw,s=s.substring(0,s.length-t.raw.length)+o.raw,e=i.substring(r.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:r,text:s}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let i=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,s="",a="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;s=t[0],e=e.substring(s.length);let c=$t(t[2].split("\n",1)[0],t[1].length),l=e.split("\n",1)[0],h=!c.trim(),p=0;if(this.options.pedantic?(p=2,a=c.trimStart()):h?p=t[1].length+1:(p=c.search(this.rules.other.nonSpaceChar),p=p>4?1:p,a=c.slice(p),p+=t[1].length),h&&this.rules.other.blankLine.test(l)&&(s+=l+"\n",e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),r=this.rules.other.fencesBeginRegex(p),i=this.rules.other.headingBeginRegex(p),o=this.rules.other.htmlBeginRegex(p),u=this.rules.other.blockquoteBeginRegex(p);for(;e;){let d,g=e.split("\n",1)[0];if(l=g,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting," "),d=l):d=l.replace(this.rules.other.tabCharGlobal," "),r.test(l)||i.test(l)||o.test(l)||u.test(l)||t.test(l)||n.test(l))break;if(d.search(this.rules.other.nonSpaceChar)>=p||!l.trim())a+="\n"+d.slice(p);else{if(h||c.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||r.test(c)||i.test(c)||n.test(c))break;a+="\n"+l}h=!l.trim(),s+=g+"\n",e=e.substring(g.length+1),c=d.slice(p)}}r.loose||(o?r.loose=!0:this.rules.other.doubleBlankLine.test(s)&&(o=!0)),r.items.push({type:"list_item",raw:s,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),r.raw+=s}let a=r.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),r.raw=r.raw.trimEnd();for(let e of r.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.checked,r.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!r.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));r.loose=n}}if(r.loose)for(let e of r.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:s}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ct(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],i={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let e of s)this.rules.other.tableAlignRight.test(e)?i.align.push("right"):this.rules.other.tableAlignCenter.test(e)?i.align.push("center"):this.rules.other.tableAlignLeft.test(e)?i.align.push("left"):i.align.push(null);for(let e=0;e<n.length;e++)i.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:i.align[e]});for(let e of r)i.rows.push(Ct(e,i.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:i.align[t]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Bt(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let s=0;s<e.length;s++)if("\\"===e[s])s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],s="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],s=e[3])}else s=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Ot(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Ot(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!s[1]&&!s[2]||!n||this.rules.inline.punctuation.exec(n))){let n,r,i=[...s[0]].length-1,o=i,a=0,c="*"===s[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+i);null!=(s=c.exec(t));){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n)continue;if(r=[...n].length,s[3]||s[4]){o+=r;continue}if((s[5]||s[6])&&i%3&&!((i+r)%3)){a+=r;continue}if(o-=r,o>0)continue;r=Math.min(r,r+o+a);let t=[...s[0]][0].length,c=e.slice(0,i+s.index+t+r);if(Math.min(i,r)%2){let e=c.slice(1,-1);return{type:"em",raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:"strong",raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),s=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&s&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let s=this.rules.inline.delLDelim.exec(e);if(s&&(!s[1]||!n||this.rules.inline.punctuation.exec(n))){let n,r,i=[...s[0]].length-1,o=i,a=this.rules.inline.delRDelim;for(a.lastIndex=0,t=t.slice(-1*e.length+i);null!=(s=a.exec(t));){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n||(r=[...n].length,r!==i))continue;if(s[3]||s[4]){o+=r;continue}if(o-=r,o>0)continue;r=Math.min(r,r+o);let t=[...s[0]][0].length,a=e.slice(0,i+s.index+t+r),c=a.slice(i,-i);return{type:"del",raw:a,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let s;do{s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(s!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},Lt=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Te,this.options.tokenizer=this.options.tokenizer||new zt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Ce,block:_t.normal,inline:Tt.normal};this.options.pedantic?(t.block=_t.pedantic,t.inline=Tt.pedantic):this.options.gfm&&(t.block=_t.gfm,this.options.breaks?t.inline=Tt.breaks:t.inline=Tt.gfm),this.tokenizer.rules=t}static get rules(){return{block:_t,inline:Tt}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Ce.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(Ce.tabCharGlobal," ").replace(Ce.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(n=>!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let n=t.at(-1);1===s.raw.length&&void 0!==n?n.raw+="\n":t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.text,this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},t.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let r=e;if(this.options.extensions?.startBlock){let t,n=1/0,s=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},s),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(this.state.top&&(s=this.tokenizer.paragraph(r))){let i=t.at(-1);n&&"paragraph"===i?.type?(i.raw+=(i.raw.endsWith("\n")?"":"\n")+s.raw,i.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):t.push(s),n=r.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,s=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(s));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(s));)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(s));)n=r[2]?r[2].length:0,s=s.slice(0,r.index+n)+"["+"a".repeat(r[0].length-n-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let i=!1,o="";for(;e;){let n;if(i||(o=""),i=!1,this.options.extensions?.inline?.some(s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let s=t.at(-1);"text"===n.type&&"text"===s?.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,s,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e,s,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let r=e;if(this.options.extensions?.startInline){let t,n=1/0,s=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},s),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(r)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),i=!0;let s=t.at(-1);"text"===s?.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},Pt=class{options;parser;constructor(e){this.options=e||Te}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(Ce.notSpaceStart)?.[0],r=e.replace(Ce.endingNewline,"")+"\n";return s?'<pre><code class="language-'+Et(s)+'">'+(n?r:Et(r,!0))+"</code></pre>\n":"<pre><code>"+(n?r:Et(r,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,s="";for(let t=0;t<e.items.length;t++){let n=e.items[t];s+=this.listitem(n)}let r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+s+"</"+r+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let s="";for(let t=0;t<e.rows.length;t++){let r=e.rows[t];n="";for(let e=0;e<r.length;e++)n+=this.tablecell(r[e]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+s+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Et(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),r=At(e);if(null===r)return s;let i='<a href="'+(e=r)+'"';return t&&(i+=' title="'+Et(t)+'"'),i+=">"+s+"</a>",i}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=At(e);if(null===r)return Et(n);let i=`<img src="${e=r}" alt="${Et(n)}"`;return t&&(i+=` title="${Et(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Et(e.text)}},It=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},qt=class e{options;renderer;textRenderer;constructor(e){this.options=e||Te,this.options.renderer=this.options.renderer||new Pt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new It}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let s=e[n];if(this.options.extensions?.renderers?.[s.type]){let e=s,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let r=s;switch(r.type){case"space":t+=this.renderer.space(r);break;case"hr":t+=this.renderer.hr(r);break;case"heading":t+=this.renderer.heading(r);break;case"code":t+=this.renderer.code(r);break;case"table":t+=this.renderer.table(r);break;case"blockquote":t+=this.renderer.blockquote(r);break;case"list":t+=this.renderer.list(r);break;case"checkbox":t+=this.renderer.checkbox(r);break;case"html":t+=this.renderer.html(r);break;case"def":t+=this.renderer.def(r);break;case"paragraph":t+=this.renderer.paragraph(r);break;case"text":t+=this.renderer.text(r);break;default:{let e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){let n="";for(let s=0;s<e.length;s++){let r=e[s];if(this.options.extensions?.renderers?.[r.type]){let e=this.options.extensions.renderers[r.type].call({parser:this},r);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=e||"";continue}}let i=r;switch(i.type){case"escape":case"text":n+=t.text(i);break;case"html":n+=t.html(i);break;case"link":n+=t.link(i);break;case"image":n+=t.image(i);break;case"checkbox":n+=t.checkbox(i);break;case"strong":n+=t.strong(i);break;case"em":n+=t.em(i);break;case"codespan":n+=t.codespan(i);break;case"br":n+=t.br(i);break;case"del":n+=t.del(i);break;default:{let e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},Nt=class{options;block;constructor(e){this.options=e||Te}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Lt.lex:Lt.lexInline}provideParser(){return this.block?qt.parse:qt.parseInline}},Mt=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=qt;Renderer=Pt;TextRenderer=It;Lexer=Lt;Tokenizer=zt;Hooks=Nt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let e=s;for(let s of e.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of e.rows)for(let e of s)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=s;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=s;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(s=>{let r=e[s].flat(1/0);n=n.concat(this.walkTokens(r,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=n.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Pt(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let s=n,r=e.renderer[s],i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new zt(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let s=n,r=e.tokenizer[s],i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Nt;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let s=n,r=e.hooks[s],i=t[s];Nt.passThroughHooks.has(n)?t[s]=e=>{if(this.defaults.async&&Nt.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await r.call(t,e);return i.call(t,n)})();let s=r.call(t,e);return i.call(t,s)}:t[s]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await r.apply(t,e);return!1===n&&(n=await i.apply(t,e)),n})();let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,s=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(s.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Lt.lex(e,t??this.defaults)}parser(e,t){return qt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},r={...this.defaults,...s},i=this.onError(!!r.silent,!!r.async);if(!0===this.defaults.async&&!1===s.async)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return i(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let n=r.hooks?await r.hooks.preprocess(t):t,s=await(r.hooks?await r.hooks.provideLexer():e?Lt.lex:Lt.lexInline)(n,r),i=r.hooks?await r.hooks.processAllTokens(s):s;r.walkTokens&&await Promise.all(this.walkTokens(i,r.walkTokens));let o=await(r.hooks?await r.hooks.provideParser():e?qt.parse:qt.parseInline)(i,r);return r.hooks?await r.hooks.postprocess(o):o})().catch(i);try{r.hooks&&(t=r.hooks.preprocess(t));let n=(r.hooks?r.hooks.provideLexer():e?Lt.lex:Lt.lexInline)(t,r);r.hooks&&(n=r.hooks.processAllTokens(n)),r.walkTokens&&this.walkTokens(n,r.walkTokens);let s=(r.hooks?r.hooks.provideParser():e?qt.parse:qt.parseInline)(n,r);return r.hooks&&(s=r.hooks.postprocess(s)),s}catch(e){return i(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Et(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Dt(e,t){return Mt.parse(e,t)}Dt.options=Dt.setOptions=function(e){return Mt.setOptions(e),Dt.defaults=Mt.defaults,Re(Dt.defaults),Dt},Dt.getDefaults=_e,Dt.defaults=Te,Dt.use=function(...e){return Mt.use(...e),Dt.defaults=Mt.defaults,Re(Dt.defaults),Dt},Dt.walkTokens=function(e,t){return Mt.walkTokens(e,t)},Dt.parseInline=Mt.parseInline,Dt.Parser=qt,Dt.parser=qt.parse,Dt.Renderer=Pt,Dt.TextRenderer=It,Dt.Lexer=Lt,Dt.lexer=Lt.lex,Dt.Tokenizer=zt,Dt.Hooks=Nt,Dt.parse=Dt,Dt.options,Dt.setOptions,Dt.use,Dt.walkTokens,Dt.parseInline,qt.parse,Lt.lex;!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}("/* ═══════════════════════════════════════════════════════════════════════════\n ChatBolt Widget — Premium Clean Design\n ═══════════════════════════════════════════════════════════════════════════ */\n\n@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');\n\n.cb-widget {\n --cb-accent: #6366f1;\n --cb-accent-rgb: 99,102,241;\n --cb-accent-glow: rgba(99,102,241,0.32);\n --cb-accent-ring: rgba(99,102,241,0.16);\n --cb-grad: linear-gradient(135deg, rgba(99,102,241,1) 0%, rgba(139,92,246,1) 100%);\n --cb-grad-soft: linear-gradient(135deg, rgba(99,102,241,0.9) 0%, rgba(139,92,246,0.8) 100%);\n\n /* Surface tokens — light */\n --cb-window-bg: #ffffff;\n --cb-text: #111827;\n --cb-text-2: #4B5563;\n --cb-text-3: #9CA3AF;\n --cb-msg-bot-bg: #F3F4F6;\n --cb-msg-bot-bd: transparent;\n --cb-input-bg: #ffffff;\n --cb-input-bd: #E5E7EB;\n --cb-divider: #F3F4F6;\n --cb-z: 2147483647;\n\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 14px;\n line-height: 1.5;\n color: var(--cb-text);\n}\n\n.cb-widget * { box-sizing: border-box; margin: 0; padding: 0; }\n\n/* ── Dark theme ─────────────────────────────────────────────────────────── */\n.cb-widget.cb-dark {\n --cb-window-bg: #111827;\n --cb-text: #F9FAFB;\n --cb-text-2: #9CA3AF;\n --cb-text-3: #6B7280;\n --cb-msg-bot-bg: #1F2937;\n --cb-msg-bot-bd: transparent;\n --cb-input-bg: #1F2937;\n --cb-input-bd: #374151;\n --cb-divider: #1F2937;\n}\n\n/* ══ TRIGGER ════════════════════════════════════════════════════════════════ */\n.cb-trigger {\n position: fixed;\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: var(--cb-grad);\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: var(--cb-z);\n outline: none;\n transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease;\n box-shadow:\n 0 6px 24px var(--cb-accent-glow),\n 0 2px 8px rgba(0,0,0,0.14),\n inset 0 1px 0 rgba(255,255,255,0.28);\n}\n\n/* Spinning glow ring */\n.cb-trigger::before {\n content: '';\n position: absolute;\n inset: -7px;\n border-radius: 50%;\n background: conic-gradient(from 0deg, rgba(var(--cb-accent-rgb),1), rgba(var(--cb-accent-rgb),0.4), rgba(var(--cb-accent-rgb),1));\n opacity: 0.38;\n animation: cb-spin 4s linear infinite;\n mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), black calc(100% - 2.5px));\n -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), black calc(100% - 2.5px));\n}\n\n/* Inner shimmer */\n.cb-trigger::after {\n content: '';\n position: absolute;\n inset: 0;\n border-radius: 50%;\n background: linear-gradient(145deg, rgba(255,255,255,0.25) 0%, transparent 55%);\n pointer-events: none;\n}\n\n@keyframes cb-spin { to { transform: rotate(360deg); } }\n\n.cb-trigger:hover {\n transform: scale(1.1);\n box-shadow:\n 0 0 0 5px var(--cb-accent-ring),\n 0 12px 32px var(--cb-accent-glow),\n inset 0 1px 0 rgba(255,255,255,0.28);\n}\n.cb-trigger:active { transform: scale(0.93); }\n\n.cb-trigger svg {\n width: 24px; height: 24px; fill: none;\n stroke: white; stroke-width: 2;\n stroke-linecap: round; stroke-linejoin: round;\n position: relative; z-index: 1;\n transition: opacity .25s, transform .35s cubic-bezier(.34,1.56,.64,1);\n}\n\n/* Icon swap */\n.cb-trigger .cb-icon-chat { opacity: 1; transform: scale(1) rotate(0deg); }\n.cb-trigger .cb-icon-close { opacity: 0; transform: scale(0.4) rotate(-90deg); position: absolute; }\n.cb-trigger.cb-open .cb-icon-chat { opacity: 0; transform: scale(0.4) rotate(90deg); }\n.cb-trigger.cb-open .cb-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }\n\n/* Position */\n.cb-pos-bottom-right .cb-trigger { bottom: 24px; right: 24px; }\n.cb-pos-bottom-left .cb-trigger { bottom: 24px; left: 24px; }\n.cb-pos-top-right .cb-trigger { top: 24px; right: 24px; }\n.cb-pos-top-left .cb-trigger { top: 24px; left: 24px; }\n\n/* ── Badge ─────────────────────────────────────────────────────────────────── */\n.cb-badge {\n position: absolute;\n top: -2px; right: -2px;\n background: linear-gradient(135deg, #ef4444, #f97316);\n color: white;\n font-size: 10px; font-weight: 700;\n min-width: 20px; height: 20px;\n border-radius: 10px;\n display: flex; align-items: center; justify-content: center;\n padding: 0 5px;\n border: 2px solid white;\n z-index: 2;\n animation: cb-badge-in .4s cubic-bezier(.34,1.56,.64,1) both;\n}\n@keyframes cb-badge-in { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1) rotate(0); } }\n\n/* ══ WINDOW ═════════════════════════════════════════════════════════════════ */\n.cb-window {\n position: fixed;\n width: 400px;\n height: 640px;\n background: var(--cb-window-bg);\n border-radius: 24px;\n border: 1px solid rgba(0,0,0,0.08);\n box-shadow:\n 0 32px 80px rgba(0,0,0,0.18),\n 0 8px 24px rgba(0,0,0,0.10),\n 0 0 0 1px rgba(255,255,255,0.6) inset;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n z-index: calc(var(--cb-z) - 1);\n transition: opacity .3s cubic-bezier(.4,0,.2,1),\n transform .3s cubic-bezier(.4,0,.2,1);\n}\n\n.cb-widget.cb-dark .cb-window {\n border-color: rgba(255,255,255,0.08);\n box-shadow:\n 0 32px 80px rgba(0,0,0,0.55),\n 0 8px 24px rgba(0,0,0,0.35),\n 0 0 0 1px rgba(255,255,255,0.06) inset;\n}\n\n.cb-window.cb-hidden {\n opacity: 0;\n pointer-events: none;\n transform: translateY(20px) scale(0.95);\n}\n\n.cb-pos-bottom-right .cb-window { bottom: 96px; right: 24px; }\n.cb-pos-bottom-left .cb-window { bottom: 96px; left: 24px; }\n.cb-pos-top-right .cb-window { top: 96px; right: 24px; }\n.cb-pos-top-left .cb-window { top: 96px; left: 24px; }\n\n/* ══ HEADER ════════════════════════════════════════════════════════════════ */\n.cb-header {\n flex-shrink: 0;\n height: 76px;\n padding: 0 18px;\n display: flex;\n align-items: center;\n gap: 13px;\n background: var(--cb-grad);\n position: relative;\n overflow: hidden;\n}\n\n/* Decorative blobs */\n.cb-header-blob2 {\n position: absolute;\n width: 200px; height: 200px;\n background: rgba(255,255,255,0.07);\n border-radius: 50%;\n top: -100px; right: -40px;\n pointer-events: none;\n}\n\n.cb-header::before {\n content: '';\n position: absolute;\n width: 140px; height: 140px;\n background: rgba(255,255,255,0.05);\n border-radius: 50%;\n bottom: -80px; left: 20px;\n pointer-events: none;\n}\n\n/* Bottom shimmer */\n.cb-header::after {\n content: '';\n position: absolute; bottom: 0; left: 0; right: 0; height: 1px;\n background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);\n pointer-events: none;\n}\n\n/* Avatar */\n.cb-header-avatar {\n width: 46px; height: 46px;\n border-radius: 50%;\n background: rgba(255,255,255,0.18);\n border: 2px solid rgba(255,255,255,0.40);\n display: flex; align-items: center; justify-content: center;\n flex-shrink: 0; overflow: hidden;\n box-shadow: 0 4px 14px rgba(0,0,0,0.20), inset 0 1px 0 rgba(255,255,255,0.30);\n position: relative; z-index: 1;\n}\n.cb-header-avatar img { width: 100%; height: 100%; object-fit: cover; }\n.cb-header-avatar svg { width: 22px; height: 22px; fill: white; }\n\n.cb-header-info { flex: 1; min-width: 0; position: relative; z-index: 1; }\n\n.cb-header-title {\n font-size: 15.5px; font-weight: 700;\n color: white; letter-spacing: -0.015em;\n white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n}\n\n.cb-header-status {\n display: flex; align-items: center; gap: 6px; margin-top: 3px;\n}\n\n.cb-status-dot {\n width: 7px; height: 7px; border-radius: 50%;\n background: #4ade80;\n box-shadow: 0 0 6px rgba(74,222,128,0.8);\n position: relative; flex-shrink: 0;\n}\n.cb-status-dot::after {\n content: '';\n position: absolute; inset: -4px; border-radius: 50%;\n background: rgba(74,222,128,0.28);\n animation: cb-live 2s ease-out infinite;\n}\n@keyframes cb-live {\n 0% { transform: scale(1); opacity: .8; }\n 100% { transform: scale(2.5); opacity: 0; }\n}\n\n.cb-header-subtitle {\n font-size: 11.5px; color: rgba(255,255,255,0.78); font-weight: 500;\n white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n}\n\n/* Close button */\n.cb-close-btn {\n width: 34px; height: 34px; border-radius: 50%;\n background: rgba(255,255,255,0.16);\n border: 1.5px solid rgba(255,255,255,0.24);\n cursor: pointer; display: flex; align-items: center; justify-content: center;\n transition: background .2s, transform .2s;\n position: relative; z-index: 1; flex-shrink: 0;\n}\n.cb-close-btn:hover { background: rgba(255,255,255,0.28); transform: scale(1.08); }\n.cb-close-btn svg { width: 14px; height: 14px; stroke: white; stroke-width: 2.5; fill: none; stroke-linecap: round; }\n\n/* ══ MESSAGES ═══════════════════════════════════════════════════════════════ */\n.cb-messages {\n flex: 1;\n overflow-y: auto;\n padding: 20px 16px 10px;\n display: flex; flex-direction: column;\n gap: 2px;\n scroll-behavior: smooth;\n background: var(--cb-window-bg);\n}\n\n.cb-messages::-webkit-scrollbar { width: 3px; }\n.cb-messages::-webkit-scrollbar-track { background: transparent; }\n.cb-messages::-webkit-scrollbar-thumb {\n background: rgba(var(--cb-accent-rgb), 0.18);\n border-radius: 2px;\n}\n\n/* Message rows */\n.cb-msg {\n display: flex; gap: 10px; align-items: flex-end;\n max-width: 85%;\n animation: cb-msg-in .3s cubic-bezier(.34,1.56,.64,1) both;\n}\n@keyframes cb-msg-in {\n from { opacity: 0; transform: translateY(12px) scale(0.96); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n}\n\n.cb-msg.cb-user { align-self: flex-end; flex-direction: row-reverse; }\n.cb-msg.cb-bot { align-self: flex-start; }\n.cb-msg.cb-first-in-group { margin-top: 14px; }\n\n/* Avatars */\n.cb-msg-avatar {\n width: 32px; height: 32px; border-radius: 50%;\n display: flex; align-items: center; justify-content: center;\n flex-shrink: 0; overflow: hidden;\n}\n.cb-msg.cb-bot .cb-msg-avatar {\n background: var(--cb-grad);\n box-shadow: 0 3px 12px var(--cb-accent-glow);\n}\n.cb-msg.cb-user .cb-msg-avatar {\n background: var(--cb-grad);\n box-shadow: 0 3px 12px var(--cb-accent-glow);\n}\n.cb-msg.cb-grouped .cb-msg-avatar { visibility: hidden; }\n.cb-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }\n.cb-msg-avatar svg { width: 17px; height: 17px; fill: white; }\n\n/* Bubble content wrapper */\n.cb-msg-content { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n\n/* Bot bubble — clean card style */\n.cb-msg-bubble {\n padding: 11px 15px;\n border-radius: 20px;\n font-size: 13.5px; line-height: 1.6;\n white-space: pre-wrap; word-break: break-word;\n}\n\n.cb-msg.cb-bot .cb-msg-bubble {\n background: var(--cb-msg-bot-bg);\n border: none;\n color: var(--cb-text);\n border-bottom-left-radius: 6px;\n box-shadow: none;\n}\n\n/* User bubble — solid gradient */\n.cb-msg.cb-user .cb-msg-bubble {\n background: var(--cb-grad);\n border: none;\n color: white;\n border-bottom-right-radius: 6px;\n box-shadow: 0 4px 16px var(--cb-accent-glow);\n}\n\n/* Timestamp */\n.cb-msg-time {\n font-size: 10px; color: var(--cb-text-3); padding: 0 4px;\n}\n.cb-msg.cb-user .cb-msg-time { text-align: right; }\n\n/* Inline code */\n.cb-msg.cb-bot .cb-msg-bubble code { background: rgba(var(--cb-accent-rgb),0.10); color: var(--cb-accent); }\n.cb-msg.cb-user .cb-msg-bubble code { background: rgba(255,255,255,0.20); color: white; }\n\n/* ── Typing dots ─────────────────────────────────────────────────────────── */\n.cb-typing-wrap {\n display: flex; gap: 10px; align-items: flex-end;\n align-self: flex-start; margin-top: 14px;\n animation: cb-msg-in .3s ease both;\n}\n\n.cb-typing {\n display: flex; gap: 5px; align-items: center;\n padding: 13px 18px;\n background: var(--cb-msg-bot-bg);\n border-radius: 20px; border-bottom-left-radius: 6px;\n}\n\n.cb-typing span {\n width: 7px; height: 7px; border-radius: 50%;\n background: var(--cb-accent);\n animation: cb-bounce 1.4s ease-in-out infinite;\n flex-shrink: 0;\n opacity: 0.65;\n}\n.cb-typing span:nth-child(1) { animation-delay: 0s; }\n.cb-typing span:nth-child(2) { animation-delay: 0.18s; opacity: 0.82; }\n.cb-typing span:nth-child(3) { animation-delay: 0.36s; opacity: 1; }\n\n@keyframes cb-bounce {\n 0%, 55%, 100% { transform: translateY(0) scale(1); }\n 28% { transform: translateY(-7px) scale(1.1); }\n}\n\n/* ══ INPUT AREA ════════════════════════════════════════════════════════════ */\n.cb-input-area {\n flex-shrink: 0;\n padding: 14px 16px 16px;\n border-top: 1.5px solid var(--cb-divider);\n background: var(--cb-window-bg);\n display: flex; gap: 10px; align-items: flex-end;\n}\n\n.cb-input-wrap {\n flex: 1;\n display: flex; align-items: flex-end;\n background: var(--cb-input-bg);\n border: 1.5px solid var(--cb-input-bd);\n border-radius: 999px;\n padding: 0 18px;\n min-height: 48px;\n transition: border-color .2s, box-shadow .2s;\n}\n\n.cb-input-wrap:focus-within {\n border-color: rgba(var(--cb-accent-rgb), 0.5);\n box-shadow: 0 0 0 3px var(--cb-accent-ring);\n}\n\n.cb-input {\n flex: 1; border: none; background: transparent;\n padding: 13px 0;\n font-size: 13.5px; font-family: inherit;\n resize: none; outline: none;\n max-height: 100px;\n color: var(--cb-text);\n line-height: 1.45;\n overflow-y: auto;\n}\n.cb-input::placeholder { color: var(--cb-text-3); }\n\n/* Send button */\n.cb-send-btn {\n width: 48px; height: 48px;\n border-radius: 50%;\n background: var(--cb-grad);\n border: none; cursor: pointer;\n display: flex; align-items: center; justify-content: center;\n flex-shrink: 0;\n transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s, opacity .2s;\n box-shadow: 0 4px 16px var(--cb-accent-glow);\n outline: none;\n}\n\n.cb-send-btn:hover {\n transform: scale(1.08);\n box-shadow: 0 8px 24px var(--cb-accent-glow);\n}\n.cb-send-btn:active { transform: scale(0.92); }\n.cb-send-btn:disabled {\n opacity: 0.35; cursor: not-allowed;\n transform: none; box-shadow: none;\n}\n.cb-send-btn svg {\n width: 17px; height: 17px;\n fill: none; stroke: white; stroke-width: 2;\n stroke-linecap: round; stroke-linejoin: round;\n position: relative; z-index: 1;\n}\n\n/* ══ FOOTER ════════════════════════════════════════════════════════════════ */\n.cb-footer {\n flex-shrink: 0;\n text-align: center;\n padding: 7px 0 12px;\n font-size: 10.5px;\n color: var(--cb-text-3);\n display: flex; align-items: center; justify-content: center; gap: 5px;\n letter-spacing: 0.01em;\n background: var(--cb-window-bg);\n}\n\n.cb-footer-dot {\n display: inline-block;\n width: 5px; height: 5px;\n border-radius: 50%;\n background: rgba(var(--cb-accent-rgb), 0.45);\n flex-shrink: 0;\n}\n\n.cb-footer a {\n color: var(--cb-accent);\n text-decoration: none;\n font-weight: 700;\n letter-spacing: 0.02em;\n background: var(--cb-grad);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n background-clip: text;\n}\n.cb-footer a:hover { opacity: .75; }\n\n/* ══ MARKDOWN — bot bubble ══════════════════════════════════════════════ */\n.cb-bot .cb-msg-bubble p { margin: 0 0 6px; }\n.cb-bot .cb-msg-bubble p:last-child { margin-bottom: 0; }\n.cb-bot .cb-msg-bubble strong,\n.cb-bot .cb-msg-bubble b { font-weight: 700; color: #111827; }\n.cb-bot .cb-msg-bubble em,\n.cb-bot .cb-msg-bubble i { font-style: italic; }\n.cb-bot .cb-msg-bubble h1,\n.cb-bot .cb-msg-bubble h2,\n.cb-bot .cb-msg-bubble h3 { font-weight: 700; margin: 8px 0 4px; color: #111827; line-height: 1.3; }\n.cb-bot .cb-msg-bubble h1 { font-size: 15px; }\n.cb-bot .cb-msg-bubble h2 { font-size: 14px; }\n.cb-bot .cb-msg-bubble h3 { font-size: 13.5px; }\n.cb-bot .cb-msg-bubble ul,\n.cb-bot .cb-msg-bubble ol { margin: 4px 0 6px 16px; padding: 0; }\n.cb-bot .cb-msg-bubble li { margin-bottom: 3px; line-height: 1.55; }\n.cb-bot .cb-msg-bubble code {\n background: #EEF2FF;\n border-radius: 4px;\n padding: 1px 5px;\n font-family: 'Courier New', monospace;\n font-size: 12px;\n color: var(--cb-accent);\n}\n.cb-bot .cb-msg-bubble pre {\n background: #1e293b;\n border-radius: 10px;\n padding: 10px 14px;\n overflow-x: auto;\n margin: 6px 0;\n}\n.cb-bot .cb-msg-bubble pre code {\n background: none; border: none; padding: 0; color: #93c5fd; font-size: 12px;\n}\n.cb-bot .cb-msg-bubble blockquote {\n border-left: 3px solid var(--cb-accent);\n padding: 3px 10px;\n margin: 6px 0;\n color: #64748b;\n background: rgba(var(--cb-accent-rgb), 0.05);\n border-radius: 0 6px 6px 0;\n}\n.cb-bot .cb-msg-bubble a { color: var(--cb-accent); text-decoration: underline; }\n.cb-bot .cb-msg-bubble hr { border: none; border-top: 1px solid #e5e7eb; margin: 8px 0; }\n.cb-bot .cb-msg-bubble table { border-collapse: collapse; width: 100%; margin: 6px 0; font-size: 12px; }\n.cb-bot .cb-msg-bubble th { background: #f3f4f6; font-weight: 600; padding: 5px 8px; border: 1px solid #e5e7eb; }\n.cb-bot .cb-msg-bubble td { padding: 4px 8px; border: 1px solid #e5e7eb; }\n\n/* Dark mode */\n.cb-dark .cb-bot .cb-msg-bubble strong,\n.cb-dark .cb-bot .cb-msg-bubble b { color: #F9FAFB; }\n.cb-dark .cb-bot .cb-msg-bubble h1,\n.cb-dark .cb-bot .cb-msg-bubble h2,\n.cb-dark .cb-bot .cb-msg-bubble h3 { color: #F9FAFB; }\n.cb-dark .cb-bot .cb-msg-bubble code { background: #1e293b; color: #93c5fd; }\n.cb-dark .cb-bot .cb-msg-bubble blockquote { color: #9CA3AF; }\n.cb-dark .cb-bot .cb-msg-bubble th { background: #1F2937; border-color: #374151; }\n.cb-dark .cb-bot .cb-msg-bubble td { border-color: #374151; }\n.cb-dark .cb-bot .cb-msg-bubble hr { border-color: #374151; }\n\n/* ══ MOBILE ════════════════════════════════════════════════════════════════ */\n@media (max-width: 480px) {\n .cb-window {\n width: 100dvw !important; height: 100dvh !important;\n border-radius: 0 !important;\n top: 0 !important; left: 0 !important;\n right: 0 !important; bottom: 0 !important;\n }\n}\n"),Dt.setOptions({breaks:!0,gfm:!0});const jt={chat:'<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>\n </svg>',close:'<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round">\n <line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>\n </svg>',send:'<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <line x1="22" y1="2" x2="11" y2="13"/>\n <polygon points="22 2 15 22 11 13 2 9 22 2"/>\n </svg>',bot:'<svg viewBox="0 0 24 24" fill="white">\n <path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7H3a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2zM7.5 14a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm9 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zM3 21v-2h18v2H3z"/>\n </svg>',user:'<svg viewBox="0 0 24 24" fill="white">\n <path d="M12 12c2.7 0 4.8-2.1 4.8-4.8S14.7 2.4 12 2.4 7.2 4.5 7.2 7.2 9.3 12 12 12zm0 2.4c-3.2 0-9.6 1.6-9.6 4.8v2.4h19.2v-2.4c0-3.2-6.4-4.8-9.6-4.8z"/>\n </svg>'};class Ft{constructor(e){this.socket=null,this.messages=[],this.conversationId=null,this.isOpen=!1,this.isTyping=!1,this.unreadCount=0,this.lastRole=null,this.config=Object.assign({serverUrl:"http://localhost:3000",position:"bottom-right",theme:"auto",accentColor:"#6366f1",placeholder:"Message…",title:"AI Assistant",subtitle:"Online · Powered by XtroEdge",botAvatar:"",triggerIcon:"",autoOpen:!1,greetingMessage:"Hi there! 👋 How can I help you today?",zIndex:2147483647,conversationId:"",showBranding:!0,gradientEndColor:""},e),this.config.conversationId&&(this.conversationId=this.config.conversationId),this.buildDOM(),this.applyTheme(),this.connectSocket(),this.config.autoOpen?setTimeout(()=>this.open(),600):this.config.greetingMessage&&this.addMessage("assistant",this.config.greetingMessage,!0)}buildDOM(){this.container=document.createElement("div"),this.container.className=`cb-widget cb-pos-${this.config.position}`;const e=this.config.accentColor.replace("#",""),t=parseInt(e.slice(0,2),16),n=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16),r=`${t},${n},${s}`;this.container.style.setProperty("--cb-accent",this.config.accentColor),this.container.style.setProperty("--cb-accent-rgb",r);const i=this.config.gradientEndColor?this.config.gradientEndColor.replace("#",""):null,o=i?parseInt(i.slice(0,2),16):t,a=i?parseInt(i.slice(2,4),16):Math.max(0,n-20),c=i?parseInt(i.slice(4,6),16):Math.min(255,s+20);this.container.style.setProperty("--cb-grad",`linear-gradient(135deg, rgba(${r},1) 0%, rgba(${o},${a},${c},1) 100%)`),this.container.style.setProperty("--cb-grad-soft",`linear-gradient(135deg, rgba(${r},0.82) 0%, rgba(${o},${a},${c},0.68) 100%)`),this.container.style.setProperty("--cb-accent-glow",`rgba(${r},0.35)`),this.container.style.setProperty("--cb-accent-ring",`rgba(${r},0.18)`),this.container.style.setProperty("--cb-z",String(this.config.zIndex));const l=this.config.botAvatar?`<img src="${this.config.botAvatar}" alt="bot">`:jt.bot;this.container.innerHTML=`\n <button class="cb-trigger" aria-label="Open chat">\n <span class="cb-icon-chat">${jt.chat}</span>\n <span class="cb-icon-close">${jt.close}</span>\n <span class="cb-badge" style="display:none">0</span>\n </button>\n\n <div class="cb-window cb-hidden" role="dialog" aria-label="${this.esc(this.config.title)} chat">\n <div class="cb-header">\n <div class="cb-header-blob2"></div>\n <div class="cb-header-avatar">${l}</div>\n <div class="cb-header-info">\n <div class="cb-header-title">${this.esc(this.config.title)}</div>\n <div class="cb-header-status">\n <div class="cb-status-dot"></div>\n <span class="cb-header-subtitle">${this.esc(this.config.subtitle)}</span>\n </div>\n </div>\n <button class="cb-close-btn" aria-label="Close">${jt.close}</button>\n </div>\n\n <div class="cb-messages" role="log" aria-live="polite"></div>\n\n <div class="cb-input-area">\n <div class="cb-input-wrap">\n <textarea class="cb-input" rows="1"\n placeholder="${this.esc(this.config.placeholder)}"\n aria-label="Message input"></textarea>\n </div>\n <button class="cb-send-btn" aria-label="Send">${jt.send}</button>\n </div>\n\n ${!1!==this.config.showBranding?'<div class="cb-footer">\n <span class="cb-footer-dot"></span>\n Powered by <a href="#" target="_blank" rel="noopener">ChatBolt</a>\n </div>':""}\n </div>\n `,document.body.appendChild(this.container),this.trigger=this.container.querySelector(".cb-trigger"),this.window=this.container.querySelector(".cb-window"),this.messagesEl=this.container.querySelector(".cb-messages"),this.inputEl=this.container.querySelector(".cb-input"),this.sendBtn=this.container.querySelector(".cb-send-btn"),this.badgeEl=this.container.querySelector(".cb-badge"),this.typingEl=document.createElement("div"),this.typingEl.className="cb-typing-wrap",this.typingEl.innerHTML=`\n <div class="cb-msg-avatar">${l}</div>\n <div class="cb-typing"><span></span><span></span><span></span></div>`,this.trigger.addEventListener("click",()=>this.toggle()),this.container.querySelector(".cb-close-btn").addEventListener("click",()=>this.close()),this.sendBtn.addEventListener("click",()=>this.send()),this.inputEl.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.send())}),this.inputEl.addEventListener("input",()=>this.autoResize())}autoResize(){this.inputEl.style.height="auto",this.inputEl.style.height=Math.min(this.inputEl.scrollHeight,100)+"px"}applyTheme(){const e="dark"===this.config.theme||"auto"===this.config.theme&&window.matchMedia("(prefers-color-scheme: dark)").matches;this.container.classList.toggle("cb-dark",e),"auto"===this.config.theme&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>{this.container.classList.toggle("cb-dark",e.matches)})}connectSocket(){this.socket=ve(`${this.config.serverUrl}/chat`,{transports:["websocket"],auth:{apiKey:this.config.apiKey},reconnectionAttempts:5,reconnectionDelay:2e3}),this.socket.on("connect",()=>console.log("[ChatBolt] Connected")),this.socket.on("chat:response",e=>{this.conversationId=e.conversationId,this.hideTyping(),this.addMessage("assistant",e.message),this.isOpen||this.showBadge()}),this.socket.on("chat:error",e=>{this.hideTyping(),this.addMessage("assistant",`Something went wrong: ${e.message}`)}),this.socket.on("disconnect",()=>console.log("[ChatBolt] Disconnected"))}send(){var e;const t=this.inputEl.value.trim();t&&!this.isTyping&&(this.addMessage("user",t),this.inputEl.value="",this.inputEl.style.height="auto",this.sendBtn.disabled=!0,this.showTyping(),null===(e=this.socket)||void 0===e||e.emit("chat:message",{message:t,conversationId:this.conversationId||void 0,contextParams:this.config.contextParams||void 0}))}addMessage(e,t,n=!1){const s={id:Date.now().toString(),role:e,content:t,createdAt:new Date};this.messages.push(s);const r=this.lastRole===e;this.lastRole=e;const i=document.createElement("div");i.className=`cb-msg ${"user"===e?"cb-user":"cb-bot"}${r?" cb-grouped":" cb-first-in-group"}`;const o="user"===e?`<div class="cb-msg-avatar">${jt.user}</div>`:`<div class="cb-msg-avatar">${this.config.botAvatar?`<img src="${this.config.botAvatar}" alt="bot">`:jt.bot}</div>`;var a;i.innerHTML=`\n ${o}\n <div class="cb-msg-content">\n <div class="cb-msg-bubble">${this.renderContent(t,e)}</div>\n ${r?"":`<span class="cb-msg-time">${a=s.createdAt,a.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}</span>`}\n </div>`,this.messagesEl.appendChild(i),this.scrollBottom()}renderContent(e,t="assistant"){return"user"===t?this.esc(e).replace(/\n/g,"<br>"):Dt.parse(e)}showTyping(){this.isTyping=!0,this.messagesEl.appendChild(this.typingEl),this.scrollBottom()}hideTyping(){var e;this.isTyping=!1,this.sendBtn.disabled=!1,null===(e=this.typingEl.parentElement)||void 0===e||e.removeChild(this.typingEl)}scrollBottom(){requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight})}showBadge(){this.unreadCount++,this.badgeEl.textContent=this.unreadCount>9?"9+":String(this.unreadCount),this.badgeEl.style.display="flex"}clearBadge(){this.unreadCount=0,this.badgeEl.style.display="none"}open(){this.isOpen=!0,this.window.classList.remove("cb-hidden"),this.trigger.classList.add("cb-open"),this.clearBadge(),setTimeout(()=>this.inputEl.focus(),250),this.scrollBottom()}close(){this.isOpen=!1,this.window.classList.add("cb-hidden"),this.trigger.classList.remove("cb-open")}toggle(){this.isOpen?this.close():this.open()}destroy(){var e;null===(e=this.socket)||void 0===e||e.disconnect(),this.container.remove()}esc(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}}const Ut={init:e=>(Ut._instance&&Ut._instance.destroy(),Ut._instance=new Ft(e),Ut._instance)};if("undefined"!=typeof window){window.ChatBolt=Ut;const e=()=>{window.ChatBoltConfig&&Ut.init(window.ChatBoltConfig)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}e.ChatBoltWidget=Ft,e.default=Ut,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
|
+
//# sourceMappingURL=chatbolt-widget.umd.js.map
|