bitmax-crm-widget 1.5.0 β 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";var e=require("react");function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e,t,n,r,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,o)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var s=e.apply(t,r);function a(e){n(s,o,i,a,c,"next",e)}function c(e){n(s,o,i,a,c,"throw",e)}a(void 0)})}}function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=p(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw i}}}}function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof a?r:a,u=Object.create(c.prototype);return l(u,"_invoke",function(n,r,o){var i,a,c,l=0,u=o||[],d=!1,p={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,a=0,c=e,p.n=n,s}};function h(n,r){for(a=n,c=r,t=0;!d&&l&&!o&&t<u.length;t++){var o,i=u[t],h=p.p,m=i[2];n>3?(o=m===r)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=h&&((o=n<2&&h<i[1])?(a=0,p.v=r,p.n=i[1]):h<m&&(o=n<3||i[0]>r||r>m)&&(i[4]=n,i[5]=r,p.n=m,a=0))}if(o||n>1)return s;throw d=!0,r}return function(o,u,m){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,m),a=u,c=m;(t=a<2?e:c)||!d;){i||(a?a<3?(a>1&&(p.n=-1),h(a,c)):p.n=c:p.v=c);try{if(l=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(d=p.n<0)?c:n.call(r,p))!==s)break}catch(t){i=e,a=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,o,i),!0),u}var s={};function a(){}function u(){}function d(){}t=Object.getPrototypeOf;var p=[][r]?t(t([][r]())):(l(t={},r,function(){return this}),t),h=d.prototype=a.prototype=Object.create(p);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,l(e,o,"GeneratorFunction")),e.prototype=Object.create(h),e}return u.prototype=d,l(h,"constructor",d),l(d,"constructor",u),u.displayName="GeneratorFunction",l(d,o,"GeneratorFunction"),l(h),l(h,o,"Generator"),l(h,r,function(){return this}),l(h,"toString",function(){return"[object Generator]"}),(c=function(){return{w:i,m:m}})()}function l(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}l=function(e,t,n,r){function i(t,n){l(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},l(e,t,n,r)}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,s,a=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}const h=Object.create(null);h.open="0",h.close="1",h.ping="2",h.pong="3",h.message="4",h.upgrade="5",h.noop="6";const m=Object.create(null);Object.keys(h).forEach(e=>{m[h[e]]=e});const f={type:"error",data:"parser error"},g="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),y="function"==typeof ArrayBuffer,b=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,x=({type:e,data:t},n,r)=>g&&t instanceof Blob?n?r(t):v(t,r):y&&(t instanceof ArrayBuffer||b(t))?n?r(t):v(new Blob([t]),r):r(h[e]+(t||"")),v=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function E(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let w;const k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",C="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)C[k.charCodeAt(e)]=e;const S="function"==typeof ArrayBuffer,A=(e,t)=>{if("string"!=typeof e)return{type:"message",data:N(e,t)};const n=e.charAt(0);if("b"===n)return{type:"message",data:_(e.substring(1),t)};return m[n]?e.length>1?{type:m[n],data:e.substring(1)}:{type:m[n]}:f},_=(e,t)=>{if(S){const n=(e=>{let t,n,r,o,i,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);const l=new ArrayBuffer(s),u=new Uint8Array(l);for(t=0;t<a;t+=4)n=C[e.charCodeAt(t)],r=C[e.charCodeAt(t+1)],o=C[e.charCodeAt(t+2)],i=C[e.charCodeAt(t+3)],u[c++]=n<<2|r>>4,u[c++]=(15&r)<<4|o>>2,u[c++]=(3&o)<<6|63&i;return l})(e);return N(n,t)}return{base64:!0,data:e}},N=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,R=String.fromCharCode(30);function B(){return new TransformStream({transform(e,t){!function(e,t){g&&e.data instanceof Blob?e.data.arrayBuffer().then(E).then(t):y&&(e.data instanceof ArrayBuffer||b(e.data))?t(E(e.data)):x(e,!1,e=>{w||(w=new TextEncoder),t(w.encode(e))})}(e,n=>{const r=n.length;let o;if(r<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,r);else if(r<65536){o=new Uint8Array(3);const e=new DataView(o.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{o=new Uint8Array(9);const e=new DataView(o.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(o[0]|=128),t.enqueue(o),t.enqueue(n)})}})}let T;function O(e){return e.reduce((e,t)=>e+t.length,0)}function F(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let o=0;o<t;o++)n[o]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function L(e){if(e)return function(e){for(var t in L.prototype)e[t]=L.prototype[t];return e}(e)}L.prototype.on=L.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},L.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},L.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},L.prototype.emitReserved=L.prototype.emit,L.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},L.prototype.hasListeners=function(e){return!!this.listeners(e).length};const j="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),I="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function z(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const P=I.setTimeout,M=I.clearTimeout;function D(e,t){t.useNativeTimers?(e.setTimeoutFn=P.bind(I),e.clearTimeoutFn=M.bind(I)):(e.setTimeoutFn=I.setTimeout.bind(I),e.clearTimeoutFn=I.clearTimeout.bind(I))}function U(e){return"string"==typeof e?function(e){let t=0,n=0;for(let r=0,o=e.length;r<o;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))}function q(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class H extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class W extends L{constructor(e){super(),this.writable=!1,D(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 H(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=A(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&&Number(443!==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 V extends W{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(R),r=[];for(let e=0;e<n.length;e++){const o=A(n[e],t);if(r.push(o),"error"===o.type)break}return r})(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,r=new Array(n);let o=0;e.forEach((e,i)=>{x(e,!1,e=>{r[i]=e,++o===n&&t(r.join(R))})})})(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]=q()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}let K=!1;try{K="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const G=K;function Y(){}class J extends V{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 $ extends L{constructor(e,t,n){super(),this.createRequest=e,D(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=z(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=$.requestsCount++,$.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=Y,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete $.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($.requestsCount=0,$.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",X);else if("function"==typeof addEventListener){addEventListener("onpagehide"in I?"pagehide":"unload",X,!1)}function X(){for(let e in $.requests)$.requests.hasOwnProperty(e)&&$.requests[e].abort()}const Q=function(){const e=Z({xdomain:!1});return e&&null!==e.responseType}();function Z(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||G))return new XMLHttpRequest}catch(e){}if(!t)try{return new(I[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}const ee="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class te extends W{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=ee?{}:z(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],r=t===e.length-1;x(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch(e){}r&&j(()=>{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]=q()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const ne=I.WebSocket||I.MozWebSocket;const re={websocket:class extends te{createSocket(e,t,n){return ee?new ne(e,t,n):t?new ne(e,t):new ne(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends W{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){T||(T=new TextDecoder);const n=[];let r=0,o=-1,i=!1;return new TransformStream({transform(s,a){for(n.push(s);;){if(0===r){if(O(n)<1)break;const e=F(n,1);i=!(128&~e[0]),o=127&e[0],r=o<126?3:126===o?1:2}else if(1===r){if(O(n)<2)break;const e=F(n,2);o=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(O(n)<8)break;const e=F(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),i=t.getUint32(0);if(i>Math.pow(2,21)-1){a.enqueue(f);break}o=i*Math.pow(2,32)+t.getUint32(4),r=3}else{if(O(n)<o)break;const e=F(n,o);a.enqueue(A(i?e:T.decode(e),t)),r=0}if(0===o||o>e){a.enqueue(f);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=B();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const o=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),o())}).catch(e=>{})};o();const i={type:"open"};this.query.sid&&(i.data=`{"sid":"${this.query.sid}"}`),this._writer.write(i).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&j(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}},polling:class extends J{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=Q&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new $(Z,this.uri(),e)}}},oe=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ie=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function se(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let o=oe.exec(e||""),i={},s=14;for(;s--;)i[ie[s]]=o[s]||"";return-1!=n&&-1!=r&&(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,r=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||r.splice(0,1);"/"==t.slice(-1)&&r.splice(r.length-1,1);return r}(0,i.path),i.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}(0,i.query),i}const ae="function"==typeof addEventListener&&"function"==typeof removeEventListener,ce=[];ae&&addEventListener("offline",()=>{ce.forEach(e=>e())},!1);class le extends L{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=se(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=se(t.host).host);D(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,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}(this.opts.query)),ae&&(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"})},ce.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&&le.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",le.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+=U(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,j(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const o={type:e,data:t,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),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(le.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(),ae&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=ce.indexOf(this._offlineEventListener);-1!==e&&ce.splice(e,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}le.protocol=4;class ue extends le{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;le.priorWebsocketSuccess=!1;const r=()=>{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;le.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 o(){n||(n=!0,l(),t.close(),t=null)}const i=e=>{const n=new Error("probe error: "+e);n.transport=t.name,o(),this.emitReserved("upgradeError",n)};function s(){i("transport closed")}function a(){i("socket closed")}function c(e){t&&e.name!==t.name&&o()}const l=()=>{t.removeListener("open",r),t.removeListener("error",i),t.removeListener("close",s),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",i),t.once("close",s),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 de=class extends ue{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=>re[e]).filter(e=>!!e)),super(e,n)}};const pe="function"==typeof ArrayBuffer,he=Object.prototype.toString,me="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===he.call(Blob),fe="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===he.call(File);function ge(e){return pe&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||me&&e instanceof Blob||fe&&e instanceof File}function ye(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(ye(e[t]))return!0;return!1}if(ge(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return ye(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&ye(e[t]))return!0;return!1}function be(e){const t=[],n=e.data,r=e;return r.data=xe(n,t),r.attachments=t.length,{packet:r,buffers:t}}function xe(e,t){if(!e)return e;if(ge(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 r=0;r<e.length;r++)n[r]=xe(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=xe(e[r],t));return n}return e}function ve(e,t){return e.data=Ee(e.data,t),delete e.attachments,e}function Ee(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]=Ee(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Ee(e[n],t));return e}const we=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var ke;!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"}(ke||(ke={}));function Ce(e){return"[object Object]"===Object.prototype.toString.call(e)}class Se extends L{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===ke.BINARY_EVENT;n||t.type===ke.BINARY_ACK?(t.type=n?ke.EVENT:ke.ACK,this.reconstructor=new Ae(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!ge(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===ke[n.type])throw new Error("unknown packet type "+n.type);if(n.type===ke.BINARY_EVENT||n.type===ke.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const o=e.substring(r,t);if(o!=Number(o)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(o)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=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(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!Se.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case ke.CONNECT:return Ce(t);case ke.DISCONNECT:return void 0===t;case ke.CONNECT_ERROR:return"string"==typeof t||Ce(t);case ke.EVENT:case ke.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===we.indexOf(t[0]));case ke.ACK:case ke.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Ae{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=ve(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var _e=Object.freeze({__proto__:null,Decoder:Se,Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==ke.EVENT&&e.type!==ke.ACK||!ye(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===ke.EVENT?ke.BINARY_EVENT:ke.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==ke.BINARY_EVENT&&e.type!==ke.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=be(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},get PacketType(){return ke},protocol:5});function Ne(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Re=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Be extends L{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=[Ne(e,"open",this.onopen.bind(this)),Ne(e,"packet",this.onpacket.bind(this)),Ne(e,"error",this.onerror.bind(this)),Ne(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,r,o;if(Re.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:ke.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 s=null===(r=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===r?void 0:r.writable,a=this.connected&&!(null===(o=this.io.engine)||void 0===o?void 0:o._hasPingExpired());return this.flags.volatile&&!s||(a?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i)),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const o=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"))},r),i=(...e)=>{this.io.clearTimeoutFn(o),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{const o=(e,t)=>e?r(e):n(t);o.withError=!0,t.push(o),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,...r)=>{if(n!==this._queue[0])return;return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...r)),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:ke.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 ke.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 ke.EVENT:case ke.BINARY_EVENT:this.onevent(e);break;case ke.ACK:case ke.BINARY_ACK:this.onack(e);break;case ke.DISCONNECT:this.ondisconnect();break;case ke.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(...r){n||(n=!0,t.packet({type:ke.ACK,id:e,data:r}))}}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.emitReserved("connect"),this._drainQueue(!0)}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:ke.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 Te(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}Te.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)},Te.prototype.reset=function(){this.attempts=0},Te.prototype.setMin=function(e){this.ms=e},Te.prototype.setMax=function(e){this.max=e},Te.prototype.setJitter=function(e){this.jitter=e};class Oe extends L{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,D(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 Te({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||_e;this.encoder=new r.Encoder,this.decoder=new r.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 de(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=Ne(t,"open",function(){n.onopen(),e&&e()}),o=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},i=Ne(t,"error",o);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn(()=>{r(),o(new Error("timeout")),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),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(Ne(e,"ping",this.onping.bind(this)),Ne(e,"data",this.ondata.bind(this)),Ne(e,"error",this.onerror.bind(this)),Ne(e,"close",this.onclose.bind(this)),Ne(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){j(()=>{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 Be(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 Fe={};function Le(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let r=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),r=se(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),r=n.source,o=n.id,i=n.path,s=Fe[o]&&i in Fe[o].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||s?a=new Oe(r,t):(Fe[o]||(Fe[o]=new Oe(r,t)),a=Fe[o]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}function je(e,t){return function(){return e.apply(t,arguments)}}Object.assign(Le,{Manager:Oe,Socket:Be,io:Le,connect:Le});const{toString:Ie}=Object.prototype,{getPrototypeOf:ze}=Object,{iterator:Pe,toStringTag:Me}=Symbol,De=(e=>t=>{const n=Ie.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ue=e=>(e=e.toLowerCase(),t=>De(t)===e),qe=e=>t=>typeof t===e,{isArray:He}=Array,We=qe("undefined");function Ve(e){return null!==e&&!We(e)&&null!==e.constructor&&!We(e.constructor)&&Ye(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=Ue("ArrayBuffer");const Ge=qe("string"),Ye=qe("function"),Je=qe("number"),$e=e=>null!==e&&"object"==typeof e,Xe=e=>{if("object"!==De(e))return!1;const t=ze(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Me in e||Pe in e)},Qe=Ue("Date"),Ze=Ue("File"),et=Ue("Blob"),tt=Ue("FileList"),nt=Ue("URLSearchParams"),[rt,ot,it,st]=["ReadableStream","Request","Response","Headers"].map(Ue);function at(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),He(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Ve(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let s;for(r=0;r<i;r++)s=o[r],t.call(null,e[s],s,e)}}function ct(e,t){if(Ve(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const lt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,ut=e=>!We(e)&&e!==lt;const dt=(pt="undefined"!=typeof Uint8Array&&ze(Uint8Array),e=>pt&&e instanceof pt);var pt;const ht=Ue("HTMLFormElement"),mt=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ft=Ue("RegExp"),gt=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};at(n,(n,o)=>{let i;!1!==(i=t(n,o,e))&&(r[o]=i||n)}),Object.defineProperties(e,r)};const yt=Ue("AsyncFunction"),bt=(xt="function"==typeof setImmediate,vt=Ye(lt.postMessage),xt?setImmediate:vt?(Et=`axios@${Math.random()}`,wt=[],lt.addEventListener("message",({source:e,data:t})=>{e===lt&&t===Et&&wt.length&&wt.shift()()},!1),e=>{wt.push(e),lt.postMessage(Et,"*")}):e=>setTimeout(e));var xt,vt,Et,wt;const kt="undefined"!=typeof queueMicrotask?queueMicrotask.bind(lt):"undefined"!=typeof process&&process.nextTick||bt;var Ct={isArray:He,isArrayBuffer:Ke,isBuffer:Ve,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||Ye(e.append)&&("formdata"===(t=De(e))||"object"===t&&Ye(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Ke(e.buffer),t},isString:Ge,isNumber:Je,isBoolean:e=>!0===e||!1===e,isObject:$e,isPlainObject:Xe,isEmptyObject:e=>{if(!$e(e)||Ve(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:rt,isRequest:ot,isResponse:it,isHeaders:st,isUndefined:We,isDate:Qe,isFile:Ze,isBlob:et,isRegExp:ft,isFunction:Ye,isStream:e=>$e(e)&&Ye(e.pipe),isURLSearchParams:nt,isTypedArray:dt,isFileList:tt,forEach:at,merge:function e(){const{caseless:t,skipUndefined:n}=ut(this)&&this||{},r={},o=(o,i)=>{const s=t&&ct(r,i)||i;Xe(r[s])&&Xe(o)?r[s]=e(r[s],o):Xe(o)?r[s]=e({},o):He(o)?r[s]=o.slice():n&&We(o)||(r[s]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&at(arguments[e],o);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(at(t,(t,r)=>{n&&Ye(t)?e[r]=je(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,i,s;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&ze(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:De,kindOfTest:Ue,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(He(e))return e;let t=e.length;if(!Je(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Pe]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:ht,hasOwnProperty:mt,hasOwnProp:mt,reduceDescriptors:gt,freezeMethods:e=>{gt(e,(t,n)=>{if(Ye(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];Ye(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return He(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:ct,global:lt,isContextDefined:ut,isSpecCompliantForm:function(e){return!!(e&&Ye(e.append)&&"FormData"===e[Me]&&e[Pe])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if($e(e)){if(t.indexOf(e)>=0)return;if(Ve(e))return e;if(!("toJSON"in e)){t[r]=e;const o=He(e)?[]:{};return at(e,(e,t)=>{const i=n(e,r+1);!We(i)&&(o[t]=i)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:yt,isThenable:e=>e&&($e(e)||Ye(e))&&Ye(e.then)&&Ye(e.catch),setImmediate:bt,asap:kt,isIterable:e=>null!=e&&Ye(e[Pe])};function St(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}Ct.inherits(St,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ct.toJSONObject(this.config),code:this.code,status:this.status}}});const At=St.prototype,_t={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{_t[e]={value:e}}),Object.defineProperties(St,_t),Object.defineProperty(At,"isAxiosError",{value:!0}),St.from=(e,t,n,r,o,i)=>{const s=Object.create(At);Ct.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",c=null==t&&e?e.code:t;return St.call(s,a,c,n,r,o),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",i&&Object.assign(s,i),s};function Nt(e){return Ct.isPlainObject(e)||Ct.isArray(e)}function Rt(e){return Ct.endsWith(e,"[]")?e.slice(0,-2):e}function Bt(e,t,n){return e?e.concat(t).map(function(e,t){return e=Rt(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Tt=Ct.toFlatObject(Ct,{},null,function(e){return/^is[A-Z]/.test(e)});function Ot(e,t,n){if(!Ct.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Ct.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Ct.isUndefined(t[e])})).metaTokens,o=n.visitor||l,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Ct.isSpecCompliantForm(t);if(!Ct.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Ct.isDate(e))return e.toISOString();if(Ct.isBoolean(e))return e.toString();if(!a&&Ct.isBlob(e))throw new St("Blob is not supported. Use a Buffer instead.");return Ct.isArrayBuffer(e)||Ct.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(Ct.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Ct.isArray(e)&&function(e){return Ct.isArray(e)&&!e.some(Nt)}(e)||(Ct.isFileList(e)||Ct.endsWith(n,"[]"))&&(a=Ct.toArray(e)))return n=Rt(n),a.forEach(function(e,r){!Ct.isUndefined(e)&&null!==e&&t.append(!0===s?Bt([n],r,i):null===s?n:n+"[]",c(e))}),!1;return!!Nt(e)||(t.append(Bt(o,n,i),c(e)),!1)}const u=[],d=Object.assign(Tt,{defaultVisitor:l,convertValue:c,isVisitable:Nt});if(!Ct.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Ct.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),Ct.forEach(n,function(n,i){!0===(!(Ct.isUndefined(n)||null===n)&&o.call(t,n,Ct.isString(i)?i.trim():i,r,d))&&e(n,r?r.concat(i):[i])}),u.pop()}}(e),t}function Ft(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Lt(e,t){this._pairs=[],e&&Ot(e,this,t)}const jt=Lt.prototype;function It(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function zt(e,t,n){if(!t)return e;const r=n&&n.encode||It;Ct.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let i;if(i=o?o(t,n):Ct.isURLSearchParams(t)?t.toString():new Lt(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}jt.append=function(e,t){this._pairs.push([e,t])},jt.toString=function(e){const t=e?function(t){return e.call(this,t,Ft)}:Ft;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class Pt{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ct.forEach(this.handlers,function(t){null!==t&&e(t)})}}var Mt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Dt={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Lt,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Ut="undefined"!=typeof window&&"undefined"!=typeof document,qt="object"==typeof navigator&&navigator||void 0,Ht=Ut&&(!qt||["ReactNative","NativeScript","NS"].indexOf(qt.product)<0),Wt="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Vt=Ut&&window.location.href||"http://localhost";var Kt={...Object.freeze({__proto__:null,hasBrowserEnv:Ut,hasStandardBrowserEnv:Ht,hasStandardBrowserWebWorkerEnv:Wt,navigator:qt,origin:Vt}),...Dt};function Gt(e){function t(e,n,r,o){let i=e[o++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=o>=e.length;if(i=!i&&Ct.isArray(r)?r.length:i,a)return Ct.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!s;r[i]&&Ct.isObject(r[i])||(r[i]=[]);return t(e,n,r[i],o)&&Ct.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}(r[i])),!s}if(Ct.isFormData(e)&&Ct.isFunction(e.entries)){const n={};return Ct.forEachEntry(e,(e,r)=>{t(function(e){return Ct.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const Yt={transitional:Mt,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=Ct.isObject(e);o&&Ct.isHTMLForm(e)&&(e=new FormData(e));if(Ct.isFormData(e))return r?JSON.stringify(Gt(e)):e;if(Ct.isArrayBuffer(e)||Ct.isBuffer(e)||Ct.isStream(e)||Ct.isFile(e)||Ct.isBlob(e)||Ct.isReadableStream(e))return e;if(Ct.isArrayBufferView(e))return e.buffer;if(Ct.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Ot(e,new Kt.classes.URLSearchParams,{visitor:function(e,t,n,r){return Kt.isNode&&Ct.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((i=Ct.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Ot(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(Ct.isString(e))try{return(t||JSON.parse)(e),Ct.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Yt.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Ct.isResponse(e)||Ct.isReadableStream(e))return e;if(e&&Ct.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw St.from(e,St.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Kt.classes.FormData,Blob:Kt.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ct.forEach(["delete","get","head","post","put","patch"],e=>{Yt.headers[e]={}});const Jt=Ct.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const $t=Symbol("internals");function Xt(e){return e&&String(e).trim().toLowerCase()}function Qt(e){return!1===e||null==e?e:Ct.isArray(e)?e.map(Qt):String(e)}function Zt(e,t,n,r,o){return Ct.isFunction(r)?r.call(this,t,n):(o&&(t=n),Ct.isString(t)?Ct.isString(r)?-1!==t.indexOf(r):Ct.isRegExp(r)?r.test(t):void 0:void 0)}let en=class{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Xt(t);if(!o)throw new Error("header name must be a non-empty string");const i=Ct.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=Qt(e))}const i=(e,t)=>Ct.forEach(e,(e,n)=>o(e,n,t));if(Ct.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(Ct.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Jt[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(Ct.isObject(e)&&Ct.isIterable(e)){let n,r,o={};for(const t of e){if(!Ct.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?Ct.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}i(o,t)}else null!=e&&o(t,e,n);return this}get(e,t){if(e=Xt(e)){const n=Ct.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Ct.isFunction(t))return t.call(this,e,n);if(Ct.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Xt(e)){const n=Ct.findKey(this,e);return!(!n||void 0===this[n]||t&&!Zt(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Xt(e)){const o=Ct.findKey(n,e);!o||t&&!Zt(0,n[o],o,t)||(delete n[o],r=!0)}}return Ct.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!Zt(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return Ct.forEach(this,(r,o)=>{const i=Ct.findKey(n,o);if(i)return t[i]=Qt(r),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();s!==o&&delete t[o],t[s]=Qt(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ct.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Ct.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[$t]=this[$t]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Xt(e);t[r]||(!function(e,t){const n=Ct.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return Ct.isArray(e)?e.forEach(r):r(e),this}};function tn(e,t){const n=this||Yt,r=t||n,o=en.from(r.headers);let i=r.data;return Ct.forEach(e,function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function nn(e){return!(!e||!e.__CANCEL__)}function rn(e,t,n){St.call(this,null==e?"canceled":e,St.ERR_CANCELED,t,n),this.name="CanceledError"}function on(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new St("Request failed with status code "+n.status,[St.ERR_BAD_REQUEST,St.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}en.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ct.reduceDescriptors(en.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Ct.freezeMethods(en),Ct.inherits(rn,St,{__CANCEL__:!0});const sn=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=r[s];o||(o=c),n[i]=a,r[i]=c;let u=s,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),c-o<t)return;const p=l&&c-l;return p?Math.round(1e3*d/p):void 0}}(50,250);return function(e,t){let n,r,o=0,i=1e3/t;const s=(t,i=Date.now())=>{o=i,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=i?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},i-a)))},()=>n&&s(n)]}(n=>{const i=n.loaded,s=n.lengthComputable?n.total:void 0,a=i-r,c=o(a);r=i;e({loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&i<=s?(s-i)/c:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},an=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},cn=e=>(...t)=>Ct.asap(()=>e(...t));var ln=Kt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Kt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Kt.origin),Kt.navigator&&/(msie|trident)/i.test(Kt.navigator.userAgent)):()=>!0,un=Kt.hasStandardBrowserEnv?{write(e,t,n,r,o,i,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Ct.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),Ct.isString(r)&&a.push(`path=${r}`),Ct.isString(o)&&a.push(`domain=${o}`),!0===i&&a.push("secure"),Ct.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function dn(e,t,n){let r=!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const pn=e=>e instanceof en?{...e}:e;function hn(e,t){t=t||{};const n={};function r(e,t,n,r){return Ct.isPlainObject(e)&&Ct.isPlainObject(t)?Ct.merge.call({caseless:r},e,t):Ct.isPlainObject(t)?Ct.merge({},t):Ct.isArray(t)?t.slice():t}function o(e,t,n,o){return Ct.isUndefined(t)?Ct.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function i(e,t){if(!Ct.isUndefined(t))return r(void 0,t)}function s(e,t){return Ct.isUndefined(t)?Ct.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}const c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>o(pn(e),pn(t),0,!0)};return Ct.forEach(Object.keys({...e,...t}),function(r){const i=c[r]||o,s=i(e[r],t[r],r);Ct.isUndefined(s)&&i!==a||(n[r]=s)}),n}var mn=e=>{const t=hn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=en.from(s),t.url=zt(dn(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Ct.isFormData(n))if(Kt.hasStandardBrowserEnv||Kt.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Ct.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(Kt.hasStandardBrowserEnv&&(r&&Ct.isFunction(r)&&(r=r(t)),r||!1!==r&&ln(t.url))){const e=o&&i&&un.read(i);e&&s.set(o,e)}return t};var fn="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=mn(e);let o=r.data;const i=en.from(r.headers).normalize();let s,a,c,l,u,{responseType:d,onUploadProgress:p,onDownloadProgress:h}=r;function m(){l&&l(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let f=new XMLHttpRequest;function g(){if(!f)return;const r=en.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());on(function(e){t(e),m()},function(e){n(e),m()},{data:d&&"text"!==d&&"json"!==d?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:r,config:e,request:f}),f=null}f.open(r.method.toUpperCase(),r.url,!0),f.timeout=r.timeout,"onloadend"in f?f.onloadend=g:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(g)},f.onabort=function(){f&&(n(new St("Request aborted",St.ECONNABORTED,e,f)),f=null)},f.onerror=function(t){const r=new St(t&&t.message?t.message:"Network Error",St.ERR_NETWORK,e,f);r.event=t||null,n(r),f=null},f.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||Mt;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new St(t,o.clarifyTimeoutError?St.ETIMEDOUT:St.ECONNABORTED,e,f)),f=null},void 0===o&&i.setContentType(null),"setRequestHeader"in f&&Ct.forEach(i.toJSON(),function(e,t){f.setRequestHeader(t,e)}),Ct.isUndefined(r.withCredentials)||(f.withCredentials=!!r.withCredentials),d&&"json"!==d&&(f.responseType=r.responseType),h&&([c,u]=sn(h,!0),f.addEventListener("progress",c)),p&&f.upload&&([a,l]=sn(p),f.upload.addEventListener("progress",a),f.upload.addEventListener("loadend",l)),(r.cancelToken||r.signal)&&(s=t=>{f&&(n(!t||t.type?new rn(null,e,f):t),f.abort(),f=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===Kt.protocols.indexOf(y)?n(new St("Unsupported protocol "+y+":",St.ERR_BAD_REQUEST,e)):f.send(o||null)})};const gn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof St?t:new rn(t instanceof Error?t.message:t))}};let i=t&&setTimeout(()=>{i=null,o(new St(`timeout ${t} of ms exceeded`,St.ETIMEDOUT))},t);const s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=()=>Ct.asap(s),a}},yn=function*(e,t){let n=e.byteLength;if(n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},bn=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},xn=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of bn(e))yield*yn(n,t)}(e,t);let i,s=0,a=e=>{i||(i=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return a(),void e.close();let i=r.byteLength;if(n){let e=s+=i;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},{isFunction:vn}=Ct,En=(({Request:e,Response:t})=>({Request:e,Response:t}))(Ct.global),{ReadableStream:wn,TextEncoder:kn}=Ct.global,Cn=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Sn=e=>{e=Ct.merge.call({skipUndefined:!0},En,e);const{fetch:t,Request:n,Response:r}=e,o=t?vn(t):"function"==typeof fetch,i=vn(n),s=vn(r);if(!o)return!1;const a=o&&vn(wn),c=o&&("function"==typeof kn?(l=new kn,e=>l.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var l;const u=i&&a&&Cn(()=>{let e=!1;const t=new n(Kt.origin,{body:new wn,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),d=s&&a&&Cn(()=>Ct.isReadableStream(new r("").body)),p={stream:d&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!p[e]&&(p[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new St(`Response type '${e}' is not supported`,St.ERR_NOT_SUPPORT,n)})});const h=async(e,t)=>{const r=Ct.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Ct.isBlob(e))return e.size;if(Ct.isSpecCompliantForm(e)){const t=new n(Kt.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ct.isArrayBufferView(e)||Ct.isArrayBuffer(e)?e.byteLength:(Ct.isURLSearchParams(e)&&(e+=""),Ct.isString(e)?(await c(e)).byteLength:void 0)})(t):r};return async e=>{let{url:o,method:s,data:a,signal:c,cancelToken:l,timeout:m,onDownloadProgress:f,onUploadProgress:g,responseType:y,headers:b,withCredentials:x="same-origin",fetchOptions:v}=mn(e),E=t||fetch;y=y?(y+"").toLowerCase():"text";let w=gn([c,l&&l.toAbortSignal()],m),k=null;const C=w&&w.unsubscribe&&(()=>{w.unsubscribe()});let S;try{if(g&&u&&"get"!==s&&"head"!==s&&0!==(S=await h(b,a))){let e,t=new n(o,{method:"POST",body:a,duplex:"half"});if(Ct.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,n]=an(S,sn(cn(g)));a=xn(t.body,65536,e,n)}}Ct.isString(x)||(x=x?"include":"omit");const t=i&&"credentials"in n.prototype,c={...v,signal:w,method:s.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:t?x:void 0};k=i&&new n(o,c);let l=await(i?E(k,v):E(o,c));const m=d&&("stream"===y||"response"===y);if(d&&(f||m&&C)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=l[t]});const t=Ct.toFiniteNumber(l.headers.get("content-length")),[n,o]=f&&an(t,sn(cn(f),!0))||[];l=new r(xn(l.body,65536,n,()=>{o&&o(),C&&C()}),e)}y=y||"text";let A=await p[Ct.findKey(p,y)||"text"](l,e);return!m&&C&&C(),await new Promise((t,n)=>{on(t,n,{data:A,headers:en.from(l.headers),status:l.status,statusText:l.statusText,config:e,request:k})})}catch(t){if(C&&C(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new St("Network Error",St.ERR_NETWORK,e,k),{cause:t.cause||t});throw St.from(t,t&&t.code,e,k)}}},An=new Map,_n=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:o}=t,i=[r,o,n];let s,a,c=i.length,l=An;for(;c--;)s=i[c],a=l.get(s),void 0===a&&l.set(s,a=c?new Map:Sn(t)),l=a;return a};_n();const Nn={http:null,xhr:fn,fetch:{get:_n}};Ct.forEach(Nn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Rn=e=>`- ${e}`,Bn=e=>Ct.isFunction(e)||null===e||!1===e;var Tn={getAdapter:function(e,t){e=Ct.isArray(e)?e:[e];const{length:n}=e;let r,o;const i={};for(let s=0;s<n;s++){let n;if(r=e[s],o=r,!Bn(r)&&(o=Nn[(n=String(r)).toLowerCase()],void 0===o))throw new St(`Unknown adapter '${n}'`);if(o&&(Ct.isFunction(o)||(o=o.get(t))))break;i[n||"#"+s]=o}if(!o){const e=Object.entries(i).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new St("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(Rn).join("\n"):" "+Rn(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return o},adapters:Nn};function On(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new rn(null,e)}function Fn(e){On(e),e.headers=en.from(e.headers),e.data=tn.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Tn.getAdapter(e.adapter||Yt.adapter,e)(e).then(function(t){return On(e),t.data=tn.call(e,e.transformResponse,t),t.headers=en.from(t.headers),t},function(t){return nn(t)||(On(e),t&&t.response&&(t.response.data=tn.call(e,e.transformResponse,t.response),t.response.headers=en.from(t.response.headers))),Promise.reject(t)})}const Ln="1.13.2",jn={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{jn[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const In={};jn.transitional=function(e,t,n){function r(e,t){return"[Axios v"+Ln+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,i)=>{if(!1===e)throw new St(r(o," has been removed"+(t?" in "+t:"")),St.ERR_DEPRECATED);return t&&!In[o]&&(In[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}},jn.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var zn={assertOptions:function(e,t,n){if("object"!=typeof e)throw new St("options must be an object",St.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],s=t[i];if(s){const t=e[i],n=void 0===t||s(t,i,e);if(!0!==n)throw new St("option "+i+" must be "+n,St.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new St("Unknown option "+i,St.ERR_BAD_OPTION)}},validators:jn};const Pn=zn.validators;let Mn=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Pt,response:new Pt}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=hn(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&zn.assertOptions(n,{silentJSONParsing:Pn.transitional(Pn.boolean),forcedJSONParsing:Pn.transitional(Pn.boolean),clarifyTimeoutError:Pn.transitional(Pn.boolean)},!1),null!=r&&(Ct.isFunction(r)?t.paramsSerializer={serialize:r}:zn.assertOptions(r,{encode:Pn.function,serialize:Pn.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),zn.assertOptions(t,{baseUrl:Pn.spelling("baseURL"),withXsrfToken:Pn.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&Ct.merge(o.common,o[t.method]);o&&Ct.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=en.concat(i,o);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const c=[];let l;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let u,d=0;if(!a){const e=[Fn.bind(this),void 0];for(e.unshift(...s),e.push(...c),u=e.length,l=Promise.resolve(t);d<u;)l=l.then(e[d++],e[d++]);return l}u=s.length;let p=t;for(;d<u;){const e=s[d++],t=s[d++];try{p=e(p)}catch(e){t.call(this,e);break}}try{l=Fn.call(this,p)}catch(e){return Promise.reject(e)}for(d=0,u=c.length;d<u;)l=l.then(c[d++],c[d++]);return l}getUri(e){return zt(dn((e=hn(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Ct.forEach(["delete","get","head","options"],function(e){Mn.prototype[e]=function(t,n){return this.request(hn(n||{},{method:e,url:t,data:(n||{}).data}))}}),Ct.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(hn(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Mn.prototype[e]=t(),Mn.prototype[e+"Form"]=t(!0)});const Dn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Dn).forEach(([e,t])=>{Dn[t]=e});const Un=function e(t){const n=new Mn(t),r=je(Mn.prototype.request,n);return Ct.extend(r,Mn.prototype,n,{allOwnKeys:!0}),Ct.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(hn(t,n))},r}(Yt);Un.Axios=Mn,Un.CanceledError=rn,Un.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new rn(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},Un.isCancel=nn,Un.VERSION=Ln,Un.toFormData=Ot,Un.AxiosError=St,Un.Cancel=Un.CanceledError,Un.all=function(e){return Promise.all(e)},Un.spread=function(e){return function(t){return e.apply(null,t)}},Un.isAxiosError=function(e){return Ct.isObject(e)&&!0===e.isAxiosError},Un.mergeConfig=hn,Un.AxiosHeaders=en,Un.formToJSON=e=>Gt(Ct.isHTMLForm(e)?new FormData(e):e),Un.getAdapter=Tn.getAdapter,Un.HttpStatusCode=Dn,Un.default=Un;const{Axios:qn,AxiosError:Hn,CanceledError:Wn,isCancel:Vn,CancelToken:Kn,VERSION:Gn,all:Yn,Cancel:Jn,isAxiosError:$n,spread:Xn,toFormData:Qn,AxiosHeaders:Zn,HttpStatusCode:er,formToJSON:tr,getAdapter:nr,mergeConfig:rr}=Un;var or=function(t){var n=t.apiKey,o=t.apiUrl,i=t.primaryColor,s=void 0===i?"#4F46E5":i,l=t.userData,p=void 0===l?null:l,h=t.theme,m=void 0===h?"light":h,f=t.onClose,g=u(e.useState("create"),2),y=g[0],b=g[1],x=u(e.useState([]),2),v=x[0],E=x[1],w=u(e.useState(null),2),k=w[0],C=w[1],S=u(e.useState([]),2),A=S[0],_=S[1],N=u(e.useState(!1),2),R=N[0],B=N[1],T=u(e.useState(""),2),O=T[0],F=T[1],L=u(e.useState(""),2),j=L[0],I=L[1],z=u(e.useState([]),2),P=z[0],M=z[1],D=u(e.useState(null),2),U=D[0],q=D[1],H=u(e.useState(!1),2);H[0],H[1];var W=u(e.useState(""),2);W[0],W[1];var V=u(e.useState("success"),2);V[0],V[1];var K=u(e.useState([]),2),G=K[0],Y=K[1],J=e.useRef(null),$=e.useRef(null),X=u(e.useState({subject:"",message:"",htmlMessage:"",priority:"medium",category:"general",attachments:[]}),2),Q=X[0],Z=X[1],ee="dark"===m||"auto"===m&&window.matchMedia("(prefers-color-scheme: dark)").matches,te=function(e){q(e),setTimeout(function(){return q(null)},4e3)},ne=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"success",n=Date.now(),r={id:n,message:e,type:t};Y(function(e){return[].concat(d(e),[r])}),setTimeout(function(){Y(function(e){return e.filter(function(e){return e.id!==n})})},4e3)},re=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;document.execCommand(e,!1,n),null===(t=$.current)||void 0===t||t.focus()},oe=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Array.from(e.target.files),r=t?P.length:Q.attachments.length;if(r+n.length>10)return te("You can only select up to 10 files total. You have ".concat(r," files already selected and are trying to add ").concat(n.length," more.")),void(e.target.value="");var o=n.filter(function(e){return e.size<=10485760?!!["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/svg+xml","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel.sheet.macroEnabled.12","text/csv","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/rtf","application/rtf","application/zip","application/x-zip-compressed","application/x-rar-compressed","application/x-7z-compressed"].includes(e.type)||(te('File "'.concat(e.name,'" is not supported. Allowed: Images, PDF, Word, Excel, PowerPoint, Text files, Archives (ZIP, RAR, 7Z).')),!1):(te('File "'.concat(e.name,'" is too large. Maximum size is 10MB per file.')),!1)});t?M(function(e){return[].concat(d(e),d(o))}):Z(function(e){return a(a({},e),{},{attachments:[].concat(d(e.attachments),d(o))})}),e.target.value=""},ie=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?M(function(t){return t.filter(function(t,n){return n!==e})}):Z(function(t){return a(a({},t),{},{attachments:t.attachments.filter(function(t,n){return n!==e})})})};e.useEffect(function(){"create"===y||k||se()},[y]),e.useEffect(function(){k?(_([]),ae(k.ticketId)):_([])},[k]);var se=function(){var e=r(c().m(function e(){var t,r,i;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(B(!0),e.p=1,(t=p||{email:localStorage.getItem("chatGuestEmail"),name:localStorage.getItem("chatGuestName")}).email){e.n=2;break}return console.error("No customer email available"),ne("Please provide your email to view tickets","error"),B(!1),e.a(2);case 2:return e.n=3,Un.get("".concat(o,"/api/v1/email-ticketing/tickets"),{headers:{"x-api-key":n},params:{status:"all",customerEmail:t.email},timeout:3e4});case 3:(r=e.v).data.success&&E(r.data.data.tickets||[]),e.n=5;break;case 4:e.p=4,i=e.v,console.error("Error fetching tickets:",i),ne("Failed to load tickets","error");case 5:return e.p=5,B(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),ae=function(){var e=r(c().m(function e(t){var r,i,s,a;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return B(!0),e.p=1,r=p||{email:localStorage.getItem("chatGuestEmail")||"guest@example.com",name:localStorage.getItem("chatGuestName")||"Guest User"},console.log("Fetching messages for ticket:",t,"user:",r.email),e.n=2,Un.get("".concat(o,"/api/v1/email-ticketing/tickets/").concat(t,"/messages"),{headers:{"x-api-key":n},params:{customerEmail:r.email},timeout:3e4});case 2:i=e.v,console.log("Messages response:",i.data),i.data.success&&(_(i.data.messages||[]),console.log("Set messages:",(null===(s=i.data.messages)||void 0===s?void 0:s.length)||0)),e.n=4;break;case 3:e.p=3,a=e.v,console.error("Error fetching messages:",a),_([]);case 4:return e.p=4,B(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(t){return e.apply(this,arguments)}}(),ce=function(){var e=r(c().m(function e(t){var r,i,s,a,l,u;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),B(!0),e.p=1,(r=p||{email:localStorage.getItem("chatGuestEmail"),name:localStorage.getItem("chatGuestName")||"Guest User"}).email){e.n=2;break}return ne("β You can't raise ticket without login","error"),B(!1),e.a(2);case 2:return(i=r.email)&&"guest@example.com"!==i&&localStorage.setItem("chatGuestEmail",i),(s=new FormData).append("subject",Q.subject),s.append("message",Q.message),s.append("html",Q.htmlMessage),s.append("priority",Q.priority),s.append("category",Q.category),s.append("customerEmail",i),s.append("customerName",r.name),Q.attachments.forEach(function(e){s.append("attachments",e)}),e.n=3,Un.post("".concat(o,"/api/v1/email-ticketing/tickets"),s,{headers:{"x-api-key":n},timeout:3e4});case 3:a=e.v,console.log("Ticket creation response:",a.data),a.data.success&&(ne("β
Ticket created successfully!","success"),Z({subject:"",message:"",htmlMessage:"",priority:"medium",category:"general",attachments:[]}),$.current&&($.current.innerHTML=""),b("myTickets")),e.n=5;break;case 4:e.p=4,u=e.v,console.error("Error creating ticket:",u),"ECONNABORTED"===u.code?ne("β±οΈ Server timeout. The server may be waking up. Please wait a moment and try again.","error"):u.response?ne("β Failed to create ticket: ".concat((null===(l=u.response.data)||void 0===l?void 0:l.message)||"Server error"),"error"):u.request?ne("β Cannot reach server. Please check your connection or try again later.","error"):ne("β Failed to create ticket. Please try again.","error");case 5:return e.p=5,B(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),le=function(){var e=r(c().m(function e(t){var r,i,s,a;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),O.trim()||0!==P.length){e.n=1;break}return e.a(2);case 1:return B(!0),e.p=2,r=p||{email:localStorage.getItem("chatGuestEmail"),name:localStorage.getItem("chatGuestName")},(i=new FormData).append("ticketId",k.ticketId),i.append("message",O),i.append("html",j),i.append("senderType","customer"),i.append("customerEmail",r.email),P.forEach(function(e){i.append("attachments",e)}),e.n=3,Un.post("".concat(o,"/api/v1/email-ticketing/tickets/widget/reply"),i,{headers:{"x-api-key":n},timeout:3e4});case 3:e.v.data.success&&(ne("β
Reply sent successfully!","success"),F(""),I(""),M([]),$.current&&($.current.innerHTML=""),setTimeout(function(){ae(k.ticketId)},500)),e.n=5;break;case 4:e.p=4,a=e.v,console.error("Error sending reply:",a),"ECONNABORTED"===a.code?ne("β±οΈ Request timeout. Server may be starting up. Please try again in 30 seconds.","error"):a.response?ne("β Failed to send reply: ".concat((null===(s=a.response.data)||void 0===s?void 0:s.message)||"Server error"),"error"):a.request?ne("β Cannot reach server. Please check your connection.","error"):ne("β Failed to send reply. Please try again.","error");case 5:return e.p=5,B(!1),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ue=function(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},de=function(e){switch(e){case"open":return"#10B981";case"pending":return"#F59E0B";default:return"#6B7280"}},pe=function(e){switch(e){case"high":return"#EF4444";case"medium":return"#F59E0B";case"low":return"#10B981";default:return"#6B7280"}},he=function(t){return t.startsWith("image/")?e.createElement("svg",{style:{width:"20px",height:"20px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})):e.createElement("svg",{style:{width:"20px",height:"20px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"}))},me=function(t){var n=t.onCommand,r=t.showSendButton,o=void 0!==r&&r,i=t.onSend,a=void 0===i?null:i,c=t.isLoading,l=void 0!==c&&c,u=t.canSend,d=void 0!==u&&u;return e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px",borderBottom:ee?"1px solid #374151":"1px solid #E5E7EB",backgroundColor:ee?"#1F2937":"#F9FAFB"}},e.createElement("div",{style:{display:"flex",gap:"4px",alignItems:"center"}},e.createElement("button",{type:"button",onClick:function(){return n("bold")},style:fe,title:"Bold"},e.createElement("strong",null,"B")),e.createElement("button",{type:"button",onClick:function(){return n("italic")},style:fe,title:"Italic"},e.createElement("em",null,"I")),e.createElement("button",{type:"button",onClick:function(){return n("underline")},style:fe,title:"Underline"},e.createElement("u",null,"U")),e.createElement("button",{type:"button",onClick:function(){return n("strikeThrough")},style:fe,title:"Strikethrough"},e.createElement("s",null,"S")),e.createElement("div",{style:{width:"1px",backgroundColor:ee?"#374151":"#E5E7EB",height:"20px",margin:"0 4px"}}),e.createElement("button",{type:"button",onClick:function(){return n("justifyLeft")},style:fe,title:"Align Left"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"}))),e.createElement("button",{type:"button",onClick:function(){return n("justifyCenter")},style:fe,title:"Align Center"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"}))),e.createElement("button",{type:"button",onClick:function(){return n("justifyRight")},style:fe,title:"Align Right"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"}))),e.createElement("div",{style:{width:"1px",backgroundColor:ee?"#374151":"#E5E7EB",height:"20px",margin:"0 4px"}}),e.createElement("button",{type:"button",onClick:function(){return n("insertUnorderedList")},style:fe,title:"Bullet List"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"}))),e.createElement("button",{type:"button",onClick:function(){return n("insertOrderedList")},style:fe,title:"Numbered List"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"}))),e.createElement("div",{style:{width:"1px",backgroundColor:ee?"#374151":"#E5E7EB",height:"20px",margin:"0 4px"}}),e.createElement("button",{type:"button",onClick:function(){return n("indent")},style:fe,title:"Increase Indent"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"}))),e.createElement("button",{type:"button",onClick:function(){return n("outdent")},style:fe,title:"Decrease Indent"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M3 21h18v-2H3v2zM3 8l4 4 4-4H3zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"}))),e.createElement("div",{style:{width:"1px",backgroundColor:ee?"#374151":"#E5E7EB",height:"20px",margin:"0 4px"}}),e.createElement("button",{type:"button",onClick:function(){return n("insertHorizontalRule")},style:fe,title:"Insert Line"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"}))),e.createElement("button",{type:"button",onClick:function(){var e;return null===(e=J.current)||void 0===e?void 0:e.click()},style:fe,title:"Attach File"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})))),o&&e.createElement("button",{type:"button",onClick:a,disabled:l||!d,style:{padding:"6px 16px",fontSize:"12px",fontWeight:600,color:"#fff",backgroundColor:s,border:"none",borderRadius:"6px",cursor:l||!d?"not-allowed":"pointer",opacity:l||!d?.5:1,display:"flex",alignItems:"center",gap:"4px",transition:"all 0.2s"},title:l?"Sending...":"Send Reply"},l?e.createElement(e.Fragment,null,e.createElement("svg",{style:{width:"12px",height:"12px",animation:"spin 1s linear infinite"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})),"Sending..."):e.createElement(e.Fragment,null,e.createElement("svg",{style:{width:"12px",height:"12px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})),"Send")))},fe={background:"none",border:"none",padding:"6px 10px",borderRadius:"4px",cursor:"pointer",color:ee?"#F9FAFB":"#111827",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"};return e.createElement(e.Fragment,null,e.createElement("style",null,"\n .ticket-message-content ul,\n .ticket-message-content ol {\n margin-left: 1.5rem;\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n }\n .ticket-message-content ul {\n list-style-type: disc;\n }\n .ticket-message-content ol {\n list-style-type: decimal;\n }\n .ticket-message-content li {\n margin-bottom: 0.25rem;\n }\n .ticket-editor[contenteditable] {\n max-width: 100%;\n word-break: break-word;\n overflow-wrap: break-word;\n }\n .ticket-editor ul,\n .ticket-editor ol {\n margin-left: 1.5rem;\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n }\n .ticket-editor ul {\n list-style-type: disc;\n }\n .ticket-editor ol {\n list-style-type: decimal;\n }\n .ticket-editor li {\n margin-bottom: 0.25rem;\n }\n .ticket-editor:empty:before {\n content: attr(placeholder);\n color: #9CA3AF;\n pointer-events: none;\n }\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n @keyframes modalAppear {\n from { \n transform: scale(0.9);\n opacity: 0;\n }\n to { \n transform: scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromRight {\n from {\n transform: translateX(100%);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n }\n @keyframes slideOutToRight {\n from {\n transform: translateX(0);\n opacity: 1;\n }\n to {\n transform: translateX(100%);\n opacity: 0;\n }\n }\n "),e.createElement("div",{style:{position:"fixed",inset:0,backgroundColor:ee?"#111827":"#F9FAFB",zIndex:999999,display:"flex",flexDirection:"column",overflow:"hidden"}},e.createElement("div",{style:{backgroundColor:ee?"#1F2937":"#fff",borderBottom:ee?"1px solid #374151":"1px solid #E5E7EB",padding:"8px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"}},e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},e.createElement("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:s,display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("svg",{style:{width:"20px",height:"20px",color:"#fff"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"}))),e.createElement("div",null,e.createElement("h1",{style:{margin:0,fontSize:"20px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"Support Tickets"),e.createElement("p",{style:{margin:"2px 0 0 0",fontSize:"13px",color:ee?"#9CA3AF":"#6B7280"}},"Manage your support requests"))),e.createElement("button",{onClick:f,style:{background:"none",border:"none",cursor:"pointer",padding:"8px",borderRadius:"8px",display:"flex",color:ee?"#9CA3AF":"#6B7280"}},e.createElement("svg",{style:{width:"24px",height:"24px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),e.createElement("div",{style:{flex:1,display:"flex",overflow:"hidden"}},e.createElement("div",{style:{width:"200px",backgroundColor:ee?"#1F2937":"#fff",borderRight:ee?"1px solid #374151":"1px solid #E5E7EB",display:"flex",flexDirection:"column",padding:"16px 0"}},e.createElement("button",{onClick:function(){b("create"),C(null)},style:{padding:"12px 20px",border:"none",backgroundColor:"create"===y?"".concat(s,"15"):"transparent",cursor:"pointer",fontSize:"14px",fontWeight:500,color:"create"===y?s:ee?"#D1D5DB":"#6B7280",textAlign:"left",borderLeft:"create"===y?"3px solid ".concat(s):"3px solid transparent",transition:"all 0.2s"}},"Create Ticket"),e.createElement("button",{onClick:function(){b("myTickets"),C(null)},style:{padding:"12px 20px",border:"none",backgroundColor:"myTickets"===y?"".concat(s,"15"):"transparent",cursor:"pointer",fontSize:"14px",fontWeight:500,color:"myTickets"===y?s:ee?"#D1D5DB":"#6B7280",textAlign:"left",borderLeft:"myTickets"===y?"3px solid ".concat(s):"3px solid transparent",transition:"all 0.2s"}},"My Tickets")),e.createElement("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},"create"===y&&e.createElement("div",{style:{flex:1,overflow:"auto",padding:"24px"}},e.createElement("div",{style:{maxWidth:"800px",margin:"0 auto"}},null!=p&&p.email||localStorage.getItem("chatGuestEmail")?e.createElement("div",{style:{backgroundColor:ee?"#1F2937":"#fff",borderRadius:"12px",padding:"24px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:ee?"1px solid #374151":"1px solid #E5E7EB"}},e.createElement("h2",{style:{margin:"0 0 16px 0",fontSize:"18px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"Create New Support Ticket"),e.createElement("form",{onSubmit:ce},e.createElement("div",{style:{marginBottom:"16px"}},e.createElement("label",{style:{display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:ee?"#F9FAFB":"#111827"}},"Subject *"),e.createElement("input",{type:"text",name:"subject",value:Q.subject,onChange:function(e){return Z(function(t){return a(a({},t),{},{subject:e.target.value})})},required:!0,placeholder:"Brief description of your issue",style:{width:"100%",padding:"10px 12px",fontSize:"14px",borderRadius:"8px",border:ee?"1px solid #374151":"1px solid #D1D5DB",backgroundColor:ee?"#111827":"#fff",color:ee?"#F9FAFB":"#111827",outline:"none"}})),e.createElement("div",{style:{marginBottom:"16px"}},e.createElement("label",{style:{display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:ee?"#F9FAFB":"#111827"}},"Description *"),e.createElement("div",{style:{border:ee?"1px solid #374151":"1px solid #D1D5DB",borderRadius:"8px",overflow:"hidden"}},e.createElement(me,{onCommand:re}),e.createElement("div",{ref:$,className:"ticket-editor",contentEditable:!0,onInput:function(e){var t=e.target.innerHTML,n=e.target.innerText;Z(function(e){return a(a({},e),{},{htmlMessage:t,message:n})})},placeholder:"Provide detailed information about your issue...",style:{minHeight:"150px",maxHeight:"300px",overflowY:"auto",padding:"12px",fontSize:"14px",color:ee?"#F9FAFB":"#111827",backgroundColor:ee?"#111827":"#fff",outline:"none"}}),e.createElement("input",{ref:J,type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.xlsm,.csv,.ppt,.pptx,.txt,.rtf,.zip,.rar,.7z",onChange:function(e){return oe(e,!1)},style:{display:"none"}}),Q.attachments.length>0&&e.createElement("div",{style:{padding:"8px 12px",borderTop:ee?"1px solid #374151":"1px solid #E5E7EB",display:"flex",flexWrap:"wrap",gap:"8px"}},Q.attachments.map(function(t,n){return e.createElement("div",{key:n,style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"6px",backgroundColor:ee?"#374151":"#F3F4F6",fontSize:"12px",color:ee?"#F9FAFB":"#111827"}},he(t.type),e.createElement("span",null,t.name),e.createElement("button",{type:"button",onClick:function(){return ie(n,!1)},style:{background:"none",border:"none",cursor:"pointer",padding:"2px",color:"#EF4444"}},"Γ"))})))),e.createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",marginBottom:"20px"}},e.createElement("div",null,e.createElement("label",{style:{display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:ee?"#F9FAFB":"#111827"}},"Priority"),e.createElement("select",{value:Q.priority,onChange:function(e){return Z(function(t){return a(a({},t),{},{priority:e.target.value})})},style:{width:"100%",padding:"10px 12px",fontSize:"14px",borderRadius:"8px",border:ee?"1px solid #374151":"1px solid #D1D5DB",backgroundColor:ee?"#111827":"#fff",color:ee?"#F9FAFB":"#111827"}},e.createElement("option",{value:"low"},"Low"),e.createElement("option",{value:"medium"},"Medium"),e.createElement("option",{value:"high"},"High"))),e.createElement("div",null,e.createElement("label",{style:{display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:ee?"#F9FAFB":"#111827"}},"Category"),e.createElement("select",{value:Q.category,onChange:function(e){return Z(function(t){return a(a({},t),{},{category:e.target.value})})},style:{width:"100%",padding:"10px 12px",fontSize:"14px",borderRadius:"8px",border:ee?"1px solid #374151":"1px solid #D1D5DB",backgroundColor:ee?"#111827":"#fff",color:ee?"#F9FAFB":"#111827"}},e.createElement("option",{value:"general"},"General"),e.createElement("option",{value:"technical"},"Technical Issue"),e.createElement("option",{value:"billing"},"Billing"),e.createElement("option",{value:"feature"},"Feature Request"),e.createElement("option",{value:"bug"},"Bug Report")))),e.createElement("button",{type:"submit",disabled:R||!Q.subject||!Q.message,style:{width:"100%",padding:"12px 24px",fontSize:"14px",fontWeight:600,color:"#fff",backgroundColor:s,border:"none",borderRadius:"8px",cursor:R?"not-allowed":"pointer",opacity:!R&&Q.subject&&Q.message?1:.5}},R?"Creating Ticket...":"Submit Ticket"))):e.createElement("div",{style:{backgroundColor:ee?"#1F2937":"#fff",borderRadius:"12px",padding:"48px 24px",textAlign:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:ee?"1px solid #374151":"1px solid #E5E7EB"}},e.createElement("div",{style:{width:"80px",height:"80px",margin:"0 auto 24px",borderRadius:"50%",backgroundColor:"#FEE2E2",display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("svg",{style:{width:"40px",height:"40px",color:"#EF4444"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"}))),e.createElement("h2",{style:{margin:"0 0 12px 0",fontSize:"20px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"Login Required"),e.createElement("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:ee?"#9CA3AF":"#6B7280",lineHeight:"1.5"}},"You can't raise ticket without login. Please login to your account to create support tickets.")))),"myTickets"===y&&e.createElement("div",{style:{flex:1,display:"flex",overflow:"hidden"}},e.createElement("div",{style:{width:"320px",borderRight:ee?"1px solid #374151":"1px solid #E5E7EB",backgroundColor:ee?"#1F2937":"#F9FAFB",display:"flex",flexDirection:"column",overflow:"hidden"}},e.createElement("div",{style:{padding:"16px",borderBottom:ee?"1px solid #374151":"1px solid #E5E7EB",flexShrink:0}},e.createElement("h3",{style:{margin:0,fontSize:"14px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"My Tickets")),e.createElement("div",{style:{flex:1,overflow:"auto"}},R?e.createElement("div",{style:{textAlign:"center",padding:"40px",color:ee?"#9CA3AF":"#6B7280"}},"Loading tickets..."):0===v.length?e.createElement("div",{style:{textAlign:"center",padding:"40px"}},e.createElement("p",{style:{margin:0,fontSize:"14px",color:ee?"#9CA3AF":"#6B7280"}},"No tickets found")):e.createElement("div",{style:{padding:"8px"}},v.map(function(t){var n=t.hasUnreadMessages||t.lastActivityAt&&new Date(t.lastActivityAt)>new Date(t.lastViewedAt||0),r=k&&k._id===t._id;return e.createElement("div",{key:t._id,onClick:function(){return C(t)},style:{padding:"12px",marginBottom:"8px",borderRadius:"8px",cursor:"pointer",backgroundColor:r?ee?"#374151":"#fff":ee?"#1F2937":"#fff",border:r?"2px solid ".concat(s):n?"2px solid ".concat(s,"40"):ee?"1px solid #374151":"1px solid #E5E7EB",transition:"all 0.2s",position:"relative"}},n&&e.createElement("div",{style:{position:"absolute",top:"8px",right:"8px",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"#EF4444"}}),e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}},e.createElement("h4",{style:{margin:0,fontSize:"13px",fontWeight:r?700:600,color:ee?"#F9FAFB":"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1}},t.subject),e.createElement("button",{onClick:function(e){e.stopPropagation(),k&&k._id===t._id?ae(t.ticketId):se()},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",color:ee?"#9CA3AF":"#6B7280",display:"flex",alignItems:"center",opacity:.7,transition:"all 0.2s"},onMouseEnter:function(e){e.target.style.opacity="1",e.target.style.backgroundColor=ee?"#374151":"#F3F4F6"},onMouseLeave:function(e){e.target.style.opacity="0.7",e.target.style.backgroundColor="transparent"},title:"Refresh"},e.createElement("svg",{style:{width:"14px",height:"14px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})))),e.createElement("p",{style:{margin:"0 0 8px 0",fontSize:"11px",color:ee?"#9CA3AF":"#6B7280"}},t.ticketId),e.createElement("p",{style:{margin:"0 0 6px 0",fontSize:"11px",color:ee?"#9CA3AF":"#6B7280"}},ue(t.createdAt)),e.createElement("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap"}},e.createElement("span",{style:{padding:"2px 6px",fontSize:"10px",fontWeight:500,borderRadius:"4px",backgroundColor:"".concat(de(t.status),"20"),color:de(t.status)}},t.status),e.createElement("span",{style:{padding:"2px 6px",fontSize:"10px",fontWeight:500,borderRadius:"4px",backgroundColor:"".concat(pe(t.priority),"20"),color:pe(t.priority)}},t.priority)))})))),k?e.createElement("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},e.createElement("div",{style:{padding:"8px 16px",borderBottom:ee?"1px solid #374151":"1px solid #E5E7EB",backgroundColor:ee?"#1F2937":"#fff"}},e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},e.createElement("div",{style:{flex:1}},e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"2px"}},e.createElement("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},k.subject),e.createElement("span",{style:{padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",backgroundColor:"".concat(de(k.status),"20"),color:de(k.status)}},k.status)),e.createElement("p",{style:{margin:0,fontSize:"13px",color:ee?"#9CA3AF":"#6B7280"}},k.ticketId)),e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},e.createElement("button",{onClick:function(){return ae(k.ticketId)},style:{background:"none",border:"none",cursor:"pointer",padding:"8px",borderRadius:"6px",color:ee?"#9CA3AF":"#6B7280",display:"flex",alignItems:"center",opacity:.8,transition:"all 0.2s"},onMouseEnter:function(e){e.target.style.opacity="1",e.target.style.backgroundColor=ee?"#374151":"#F3F4F6"},onMouseLeave:function(e){e.target.style.opacity="0.8",e.target.style.backgroundColor="transparent"},title:"Refresh conversation"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"}))),e.createElement("button",{onClick:function(){return C(null)},style:{background:"none",border:"none",cursor:"pointer",padding:"8px",borderRadius:"6px",color:ee?"#9CA3AF":"#6B7280",display:"flex",alignItems:"center",opacity:.8,transition:"all 0.2s"},onMouseEnter:function(e){e.target.style.opacity="1",e.target.style.backgroundColor=ee?"#374151":"#F3F4F6"},onMouseLeave:function(e){e.target.style.opacity="0.8",e.target.style.backgroundColor="transparent"},title:"Close"},e.createElement("svg",{style:{width:"18px",height:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))))),e.createElement("div",{style:{flex:1,overflow:"auto",padding:"16px 24px"}},R?e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px 20px",color:ee?"#9CA3AF":"#6B7280"}},e.createElement("div",{style:{width:"20px",height:"20px",border:"2px solid ".concat(s),borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite",marginRight:"10px"}}),O.trim()||P.length>0?"Sending reply...":"Loading conversation..."):0===A.length?e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px 20px",color:ee?"#9CA3AF":"#6B7280",textAlign:"center"}},"No messages in this conversation yet."):A.map(function(t,n){var i;return e.createElement("div",{key:t._id||n,style:{marginBottom:"16px",width:"100%"}},e.createElement("div",{style:{width:"100%",backgroundColor:"customer"===t.senderType?ee?"#1E3A8A20":"#DBEAFE":ee?"#1F2937":"#F3F4F6",borderRadius:"8px",padding:"12px",border:ee?"customer"===t.senderType?"1px solid #1E40AF":"1px solid #374151":"customer"===t.senderType?"1px solid #93C5FD":"1px solid #E5E7EB"}},e.createElement("div",{style:{fontSize:"12px",color:ee?"#9CA3AF":"#6B7280",marginBottom:"8px",display:"flex",justifyContent:"space-between",alignItems:"center",fontWeight:500}},e.createElement("span",null,"customer"===t.senderType?t.senderName||"You":((null===(i=t.sender)||void 0===i?void 0:i.alias)||t.senderName||"AGENT").toUpperCase()),e.createElement("span",null,ue(t.createdAt))),e.createElement("div",{className:"ticket-message-content",style:{color:ee?"#F9FAFB":"#111827",fontSize:"14px",lineHeight:"1.5",wordBreak:"break-word",overflowWrap:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:t.html||t.message}}),t.attachments&&t.attachments.length>0&&e.createElement("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"}},t.attachments.map(function(t,n){return e.createElement("div",{key:n,style:{border:ee?"1px solid #374151":"1px solid #E5E7EB",borderRadius:"8px",overflow:"hidden"}},e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",backgroundColor:ee?"#111827":"#F9FAFB"}},e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px",flex:1,minWidth:0}},he(t.contentType),e.createElement("span",{style:{fontSize:"12px",color:ee?"#F9FAFB":"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},t.filename),t.size&&e.createElement("span",{style:{color:ee?"#9CA3AF":"#6B7280",fontSize:"12px",flexShrink:0}},"(",(t.size/1024).toFixed(1)," KB)")),e.createElement("button",{onClick:function(){var e=r(c().m(function e(n){var r,i,s,a;return c().w(function(e){for(;;)switch(e.n){case 0:n.preventDefault(),n.stopPropagation();try{r=String(t.filename||"download").replace(/\s+/g,"_").replace(/[^a-zA-Z0-9._-]/g,"_"),t.url&&t.url.includes("cloudinary.com")?(i="".concat(o,"/api/v1/email-ticketing/attachments/download?filename=").concat(encodeURIComponent(r),"&url=").concat(encodeURIComponent(t.url)),(s=document.createElement("a")).href=i,s.rel="noopener",document.body.appendChild(s),s.click(),document.body.removeChild(s)):t.url&&((a=document.createElement("a")).href=t.url,a.download=r,a.rel="noopener",document.body.appendChild(a),a.click(),document.body.removeChild(a))}catch(e){console.error("Download failed:",e),window.open(t.url,"_blank","noopener,noreferrer")}case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),style:{marginLeft:"8px",padding:"4px 8px",fontSize:"12px",backgroundColor:s,color:"#fff",borderRadius:"4px",border:"none",cursor:"pointer",flexShrink:0,transition:"all 0.2s"},onMouseEnter:function(e){return e.target.style.backgroundColor="".concat(s,"dd")},onMouseLeave:function(e){return e.target.style.backgroundColor=s}},"Download")))}))))})),"closed"!==k.status&&e.createElement("div",{style:{borderTop:ee?"1px solid #374151":"1px solid #E5E7EB",backgroundColor:ee?"#1F2937":"#fff",padding:"16px 24px"}},e.createElement("div",{style:{border:ee?"1px solid #374151":"1px solid #E5E7EB",borderRadius:"8px",overflow:"hidden"}},e.createElement(me,{onCommand:re,showSendButton:!0,onSend:function(e){e.preventDefault(),le(e)},isLoading:R,canSend:O.trim()||P.length>0}),e.createElement("div",{ref:$,className:"ticket-editor",contentEditable:!0,onInput:function(e){var t=e.target.innerHTML,n=e.target.innerText;I(t),F(n)},placeholder:"Type your reply...",style:{minHeight:"100px",maxHeight:"200px",overflowY:"auto",padding:"12px",fontSize:"14px",color:ee?"#F9FAFB":"#111827",backgroundColor:ee?"#111827":"#fff",outline:"none"}}),e.createElement("input",{ref:J,type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.xlsm,.csv,.ppt,.pptx,.txt,.rtf,.zip,.rar,.7z",onChange:function(e){return oe(e,!0)},style:{display:"none"}}),P.length>0&&e.createElement("div",{style:{padding:"8px 12px",borderTop:ee?"1px solid #374151":"1px solid #E5E7EB",display:"flex",flexWrap:"wrap",gap:"8px"}},P.map(function(t,n){return e.createElement("div",{key:n,style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"6px",backgroundColor:ee?"#374151":"#F3F4F6",fontSize:"12px",color:ee?"#F9FAFB":"#111827"}},he(t.type),e.createElement("span",null,t.name),e.createElement("button",{type:"button",onClick:function(){return ie(n,!0)},style:{background:"none",border:"none",cursor:"pointer",padding:"2px",color:"#EF4444"}},"Γ"))}))))):e.createElement("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:ee?"#111827":"#F9FAFB"}},e.createElement("div",{style:{textAlign:"center",padding:"40px"}},e.createElement("svg",{style:{width:"64px",height:"64px",margin:"0 auto 16px",color:ee?"#374151":"#D1D5DB"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})),e.createElement("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"Select a ticket"),e.createElement("p",{style:{margin:0,fontSize:"14px",color:ee?"#9CA3AF":"#6B7280"}},"Choose a ticket from the list to view details")))),!1)),U&&e.createElement("div",{style:{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,padding:"20px"}},e.createElement("div",{style:{backgroundColor:ee?"#1f2937":"#ffffff",color:ee?"#f9fafb":"#111827",borderRadius:"16px",padding:"32px 40px",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.3)",maxWidth:"500px",width:"100%",textAlign:"center",border:ee?"1px solid #374151":"1px solid #e5e7eb",position:"relative",transform:"scale(1)",animation:"modalAppear 0.3s ease-out"}},e.createElement("div",{style:{width:"64px",height:"64px",borderRadius:"50%",backgroundColor:"#fef2f2",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 20px",border:"3px solid #fee2e2"}},e.createElement("svg",{style:{width:"32px",height:"32px",color:"#ef4444"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"}))),e.createElement("h3",{style:{color:"#ef4444",fontSize:"20px",fontWeight:"700",marginBottom:"12px",margin:"0 0 12px 0"}},"File Upload Limit Exceeded"),e.createElement("p",{style:{fontSize:"16px",lineHeight:"1.6",color:ee?"#d1d5db":"#6b7280",marginBottom:"24px",margin:"0 0 24px 0"}},U),e.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"center"}},e.createElement("button",{onClick:function(){return q(null)},style:{padding:"12px 32px",backgroundColor:"#ef4444",color:"white",border:"none",borderRadius:"8px",fontSize:"16px",fontWeight:"600",cursor:"pointer",transition:"all 0.2s",boxShadow:"0 4px 12px rgba(239, 68, 68, 0.3)"},onMouseOver:function(e){e.target.style.backgroundColor="#dc2626",e.target.style.transform="translateY(-1px)",e.target.style.boxShadow="0 6px 16px rgba(239, 68, 68, 0.4)"},onMouseOut:function(e){e.target.style.backgroundColor="#ef4444",e.target.style.transform="translateY(0)",e.target.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.3)"}},"Understood")))),G.length>0&&e.createElement("div",{style:{position:"fixed",bottom:"20px",right:"20px",zIndex:10001,display:"flex",flexDirection:"column",gap:"12px",pointerEvents:"none"}},G.map(function(t){return e.createElement("div",{key:t.id,style:{backgroundColor:ee?"#1f2937":"#ffffff",color:ee?"#f9fafb":"#111827",padding:"16px 20px",borderRadius:"12px",boxShadow:"0 8px 25px rgba(0, 0, 0, 0.15)",border:"2px solid ".concat("success"===t.type?"#10b981":"#ef4444"),minWidth:"300px",maxWidth:"400px",animation:"slideInFromRight 0.3s ease-out",display:"flex",alignItems:"center",gap:"12px",pointerEvents:"auto"}},e.createElement("div",{style:{width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"success"===t.type?"#10b981":"#ef4444",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},"success"===t.type?e.createElement("svg",{style:{width:"14px",height:"14px",color:"white"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})):e.createElement("svg",{style:{width:"14px",height:"14px",color:"white"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M6 18L18 6M6 6l12 12"}))),e.createElement("div",{style:{flex:1,fontSize:"14px",fontWeight:"500",lineHeight:"1.4"}},t.message),e.createElement("button",{onClick:function(){return Y(function(e){return e.filter(function(e){return e.id!==t.id})})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",color:ee?"#9ca3af":"#6b7280",flexShrink:0,opacity:.7,transition:"opacity 0.2s"},onMouseEnter:function(e){return e.target.style.opacity="1"},onMouseLeave:function(e){return e.target.style.opacity="0.7"}},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))))}))))};function ir(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}ir(".camera-capture-wrapper{animation:slideUp .4s cubic-bezier(.4,0,.2,1);background:#fff;border:2px solid #e5e7eb;border-radius:16px;box-shadow:0 8px 32px rgba(0,0,0,.12);margin:20px 0;max-width:100%;overflow:hidden;width:100%}@keyframes slideUp{0%{opacity:0;transform:translateY(40px)}to{opacity:1;transform:translateY(0)}}.camera-header-banner{align-items:center;background:linear-gradient(135deg,#6366f1,#8b5cf6);display:flex;justify-content:space-between;padding:16px 20px}.camera-header-content{align-items:center;display:flex;gap:14px}.camera-icon-badge{align-items:center;backdrop-filter:blur(10px);background:hsla(0,0%,100%,.2);border-radius:12px;display:flex;font-size:24px;height:48px;justify-content:center;width:48px}.camera-header-text{color:#fff}.camera-title{font-size:18px;font-weight:700;letter-spacing:-.5px;margin:0}.camera-subtitle{font-size:13px;font-weight:400;margin:4px 0 0;opacity:.9}.camera-close-button{align-items:center;backdrop-filter:blur(10px);background:hsla(0,0%,100%,.15);border:none;border-radius:8px;color:#fff;cursor:pointer;display:flex;font-size:20px;height:36px;justify-content:center;transition:all .2s;width:36px}.camera-close-button:hover{background:hsla(0,0%,100%,.25);transform:scale(1.05)}.camera-view-container{background:#000;max-height:500px;min-height:400px;overflow:hidden;position:relative}.camera-loading-state{align-items:center;color:#fff;display:flex;flex-direction:column;height:400px;justify-content:center}.loading-spinner{animation:spin 1s linear infinite;border:4px solid hsla(0,0%,100%,.2);border-radius:50%;border-top-color:#fff;height:48px;margin-bottom:16px;width:48px}@keyframes spin{to{transform:rotate(1turn)}}.camera-error-state{align-items:center;color:#fff;display:flex;flex-direction:column;height:400px;justify-content:center;padding:40px;text-align:center}.error-icon-large{font-size:64px;margin-bottom:16px;opacity:.5}.error-message{font-size:16px;line-height:1.5;margin-bottom:24px}.retry-button{background:#6366f1;border:none;border-radius:8px;color:#fff;cursor:pointer;font-size:15px;font-weight:600;padding:12px 28px;transition:all .2s}.retry-button:hover{background:#4f46e5;transform:scale(1.05)}.camera-live-mode{height:100%;min-height:400px;position:relative;width:100%}.camera-video-feed{display:block;height:100%;object-fit:cover;width:100%}.camera-overlay{bottom:0;left:0;pointer-events:none;position:absolute;right:0;top:0}.camera-frame{aspect-ratio:4/3;border:3px solid hsla(0,0%,100%,.5);border-radius:16px;box-shadow:0 0 0 2000px rgba(0,0,0,.3);left:50%;max-width:350px;position:absolute;top:50%;transform:translate(-50%,-50%);width:80%}.camera-preview-mode{background:#000;min-height:400px;position:relative;width:100%}.preview-image-wrapper{align-items:center;display:flex;height:100%;justify-content:center;position:relative;width:100%}.preview-image{display:block;max-height:500px;max-width:100%;object-fit:contain}.preview-badge{backdrop-filter:blur(10px);background:rgba(99,102,241,.95);border-radius:20px;color:#fff;font-size:13px;font-weight:600;padding:8px 16px;position:absolute;right:16px;top:16px}.camera-action-section{background:#fff;padding:24px 20px}.preview-actions{display:grid;gap:12px;grid-template-columns:1fr 1fr}.action-button{align-items:center;border:none;border-radius:12px;cursor:pointer;display:flex;font-family:inherit;font-size:16px;font-weight:600;gap:10px;justify-content:center;padding:16px 24px;transition:all .2s}.button-icon{font-size:20px}.retake-button{background:#f3f4f6;border:2px solid #e5e7eb;color:#374151}.retake-button:hover{background:#e5e7eb;box-shadow:0 4px 12px rgba(0,0,0,.1);transform:translateY(-2px)}.submit-button{background:linear-gradient(135deg,#10b981,#059669);box-shadow:0 4px 16px rgba(16,185,129,.3);color:#fff}.submit-button:hover{box-shadow:0 6px 20px rgba(16,185,129,.4);transform:translateY(-2px)}.camera-actions{align-items:center;display:flex;gap:16px;justify-content:space-between}.flip-camera-button{align-items:center;background:#f3f4f6;border:2px solid #e5e7eb;border-radius:50%;cursor:pointer;display:flex;flex-direction:column;height:64px;justify-content:center;transition:all .2s;width:64px}.flip-camera-button:hover:not(:disabled){background:#e5e7eb;transform:scale(1.05)}.flip-camera-button:disabled{cursor:not-allowed;opacity:.4}.flip-icon{font-size:24px}.flip-text{color:#6b7280;font-size:11px;font-weight:600;margin-top:2px}.capture-button-main{align-items:center;background:#fff;border:4px solid #6366f1;border-radius:50%;box-shadow:0 4px 20px rgba(99,102,241,.3);cursor:pointer;display:flex;height:80px;justify-content:center;position:relative;transition:all .2s;width:80px}.capture-button-main:hover:not(:disabled){box-shadow:0 6px 24px rgba(99,102,241,.4);transform:scale(1.08)}.capture-button-main:active:not(:disabled){transform:scale(.95)}.capture-button-main:disabled{cursor:not-allowed;opacity:.4}.capture-button-inner{align-items:center;display:flex;height:100%;justify-content:center;position:relative;width:100%}.capture-ring{animation:pulse 2s ease-in-out infinite;border:3px solid #6366f1;border-radius:50%;height:68px;position:absolute;width:68px}@keyframes pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.7;transform:scale(1.1)}}.capture-center{background:linear-gradient(135deg,#6366f1,#8b5cf6);border-radius:50%;height:56px;width:56px}.placeholder-space{width:64px}.camera-instructions{background:#f9fafb;border-top:1px solid #e5e7eb;padding:16px 20px;text-align:center}.camera-instructions p{color:#6b7280;font-size:14px;font-weight:500;margin:0}.camera-instructions.success{background:#ecfdf5;border-top-color:#d1fae5}.camera-instructions.success p{color:#059669}@media (max-width:768px){.camera-capture-wrapper{border-radius:12px;margin:12px 0}.camera-header-banner{padding:14px 16px}.camera-icon-badge{font-size:20px;height:42px;width:42px}.camera-title{font-size:16px}.camera-subtitle{font-size:12px}.camera-view-container{max-height:400px;min-height:350px}.camera-live-mode{min-height:350px}.camera-action-section{padding:20px 16px}.action-button{font-size:15px;padding:14px 20px}.capture-button-main{height:72px;width:72px}.capture-ring{height:60px;width:60px}.capture-center{height:48px;width:48px}}@media (max-width:480px){.camera-capture-wrapper{border-radius:10px;margin:8px 0}.camera-header-banner{padding:12px 14px}.camera-icon-badge{border-radius:10px;font-size:18px;height:38px;width:38px}.camera-title{font-size:15px}.camera-subtitle{font-size:11px}.camera-close-button{font-size:18px;height:32px;width:32px}.camera-view-container{max-height:350px;min-height:300px}.camera-live-mode{min-height:300px}.camera-action-section{padding:18px 14px}.action-button{font-size:14px;padding:13px 18px}.button-icon{font-size:18px}.flip-camera-button{height:56px;width:56px}.flip-icon{font-size:20px}.capture-button-main{height:68px;width:68px}.capture-ring{height:56px;width:56px}.capture-center{height:44px;width:44px}.placeholder-space{width:56px}.camera-instructions{padding:14px 16px}.camera-instructions p{font-size:13px}}");var sr=function(t){var n=t.onCapture,o=t.onClose,i=t.requesterName,s=void 0===i?"Agent":i,a=u(e.useState(null),2),l=a[0],d=a[1],p=u(e.useState(null),2),h=p[0],m=p[1],f=u(e.useState(!1),2),g=f[0],y=f[1],b=u(e.useState("environment"),2),x=b[0],v=b[1],E=u(e.useState(null),2),w=E[0],k=E[1],C=u(e.useState(!0),2),S=C[0],A=C[1],_=e.useRef(null),N=e.useRef(null);e.useEffect(function(){return R(),function(){B()}},[x]);var R=function(){var e=r(c().m(function e(){var t,n;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,k(null),A(!0),e.n=1,navigator.mediaDevices.getUserMedia({video:{facingMode:x,width:{ideal:1920},height:{ideal:1080}},audio:!1});case 1:t=e.v,d(t),_.current&&(_.current.srcObject=t),y(!0),A(!1),e.n=3;break;case 2:e.p=2,n=e.v,console.error("Camera access error:",n),k("Camera access denied. Please allow camera permissions."),y(!1),A(!1);case 3:return e.a(2)}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}(),B=function(){l&&(l.getTracks().forEach(function(e){return e.stop()}),d(null),y(!1))},T=function(){B(),o&&o()};return e.createElement("div",{className:"camera-capture-wrapper"},e.createElement("div",{className:"camera-header-banner"},e.createElement("div",{className:"camera-header-content"},e.createElement("div",{className:"camera-icon-badge"},"πΈ"),e.createElement("div",{className:"camera-header-text"},e.createElement("h3",{className:"camera-title"},"Camera Capture"),e.createElement("p",{className:"camera-subtitle"},s," requested a photo"))),e.createElement("button",{className:"camera-close-button",onClick:T},e.createElement("span",null,"β"))),e.createElement("div",{className:"camera-view-container"},w?e.createElement("div",{className:"camera-error-state"},e.createElement("div",{className:"error-icon-large"},"π·"),e.createElement("p",{className:"error-message"},w),e.createElement("button",{className:"retry-button",onClick:R},"π Try Again")):S?e.createElement("div",{className:"camera-loading-state"},e.createElement("div",{className:"loading-spinner"}),e.createElement("p",null,"Loading camera...")):h?e.createElement("div",{className:"camera-preview-mode"},e.createElement("div",{className:"preview-image-wrapper"},e.createElement("img",{src:h,alt:"Captured",className:"preview-image"}),e.createElement("div",{className:"preview-badge"},"Preview"))):e.createElement("div",{className:"camera-live-mode"},e.createElement("video",{ref:_,autoPlay:!0,playsInline:!0,muted:!0,className:"camera-video-feed"}),e.createElement("div",{className:"camera-overlay"},e.createElement("div",{className:"camera-frame"})),e.createElement("canvas",{ref:N,style:{display:"none"}}))),e.createElement("div",{className:"camera-action-section"},h?e.createElement("div",{className:"preview-actions"},e.createElement("button",{className:"action-button retake-button",onClick:function(){m(null),R()}},e.createElement("span",{className:"button-icon"},"π"),e.createElement("span",{className:"button-text"},"Retake")),e.createElement("button",{className:"action-button submit-button",onClick:function(){h&&n&&(n(h),T())}},e.createElement("span",{className:"button-icon"},"β"),e.createElement("span",{className:"button-text"},"Submit Photo"))):e.createElement("div",{className:"camera-actions"},e.createElement("button",{className:"flip-camera-button",onClick:function(){v(function(e){return"user"===e?"environment":"user"})},disabled:!g},e.createElement("span",{className:"flip-icon"},"π"),e.createElement("span",{className:"flip-text"},"Flip")),e.createElement("button",{className:"capture-button-main",onClick:function(){if(_.current&&N.current){var e=_.current,t=N.current,n=t.getContext("2d");t.width=e.videoWidth,t.height=e.videoHeight,n.drawImage(e,0,0,t.width,t.height);var r=t.toDataURL("image/jpeg",.95);m(r),B()}},disabled:!g},e.createElement("div",{className:"capture-button-inner"},e.createElement("div",{className:"capture-ring"}),e.createElement("div",{className:"capture-center"}))),e.createElement("div",{className:"placeholder-space"}))),!h&&!w&&e.createElement("div",{className:"camera-instructions"},e.createElement("p",null,"πΈ Position and tap the button to capture")),h&&e.createElement("div",{className:"camera-instructions success"},e.createElement("p",null,"β Photo captured! Review and submit or retake")))};ir(".crm-widget-container{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.crm-chat-button{align-items:center;animation:crm-pulse 2s ease-in-out infinite;border:none;border-radius:50%;box-shadow:0 10px 25px rgba(79,70,229,.4),0 0 0 0 rgba(79,70,229,.4);color:#fff;cursor:pointer;display:flex;font-size:24px;height:64px;justify-content:center;position:fixed;transition:all .3s cubic-bezier(.4,0,.2,1);width:64px}.crm-chat-button:hover{animation:none;box-shadow:0 15px 35px rgba(79,70,229,.5),0 0 0 8px rgba(79,70,229,.1);transform:scale(1.1)}@keyframes crm-pulse{0%,to{box-shadow:0 10px 25px rgba(79,70,229,.4),0 0 0 0 rgba(79,70,229,.4)}50%{box-shadow:0 10px 25px rgba(79,70,229,.4),0 0 0 8px rgba(79,70,229,0)}}.crm-icon{height:32px;width:32px}.crm-icon-sm{height:24px;width:24px}.crm-spin{animation:crm-spin 1s linear infinite}@keyframes crm-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.crm-badge{align-items:center;background-color:#ef4444;border-radius:50%;color:#fff;display:flex;font-size:12px;font-weight:600;height:20px;justify-content:center;position:absolute;right:-4px;top:-4px;width:20px}.crm-bottom-6{bottom:24px}.crm-right-6{right:24px}.crm-left-6{left:24px}.crm-top-6{top:24px}.crm-chat-window{background:#fff;border:1px solid #e5e7eb;border-radius:16px;box-shadow:0 20px 50px rgba(0,0,0,.3);display:flex;flex-direction:column;height:600px;max-width:448px;overflow:hidden;position:fixed;width:100%}.crm-chat-window.crm-dark{background:#1f2937;border-color:#374151}.crm-chat-window.crm-bottom-6{bottom:100px}.crm-chat-window.crm-right-6{right:24px}.crm-chat-window.crm-left-6{left:24px}.crm-chat-window.crm-top-6{top:100px}@media (max-width:640px){.crm-chat-window{border-radius:0;bottom:0!important;height:100vh;left:0!important;max-width:100%;right:0!important;top:0!important}}.crm-header{align-items:center;color:#fff;display:flex;justify-content:space-between;padding:16px 24px}.crm-header-content{align-items:center;display:flex;gap:12px}.crm-avatar{align-items:center;background:#fff;border-radius:50%;box-shadow:0 4px 12px rgba(0,0,0,.1);display:flex;font-size:20px;height:40px;justify-content:center;transition:transform .2s;width:40px}.crm-avatar:hover{transform:scale(1.05)}.crm-title{font-size:18px;font-weight:600;margin:0}.crm-status{align-items:center;display:flex;font-size:14px;gap:8px;opacity:.9}.crm-status-dot{border-radius:50%;height:8px;width:8px}.crm-status-dot.crm-online{background-color:#10b981}.crm-status-dot.crm-offline{background-color:#ef4444}.crm-close-btn{background:hsla(0,0%,100%,.2);border:none;border-radius:50%;color:#fff;cursor:pointer;padding:8px;transition:background .2s}.crm-close-btn:hover{background:hsla(0,0%,100%,.3)}.crm-new-query-btn{align-items:center;background:hsla(0,0%,100%,.2);border:none;border-radius:50%;color:#fff;cursor:pointer;display:flex;justify-content:center;padding:8px;transition:all .2s}.crm-new-query-btn:hover{background:hsla(0,0%,100%,.3);transform:scale(1.05)}.crm-messages{background:#f9fafb;display:flex;flex:1;flex-direction:column;gap:16px;overflow-y:auto;padding:16px}.crm-dark .crm-messages{background:#111827}.crm-welcome-message{background:#fff;border:1px solid #e5e7eb;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,.1);padding:16px}.crm-dark .crm-welcome-message{background:#1f2937;border-color:#374151;color:#d1d5db}.crm-welcome-message p{color:#374151;font-size:14px;margin:0}.crm-dark .crm-welcome-message p{color:#d1d5db}.crm-message{display:flex}.crm-message-guest{justify-content:flex-end}.crm-message-agent{justify-content:flex-start}.crm-message-system{justify-content:center}.crm-message-bubble{border-radius:16px;box-shadow:0 1px 2px rgba(0,0,0,.1);max-width:75%;padding:10px 16px}.crm-message-guest .crm-message-bubble{border-bottom-right-radius:4px;color:#fff}.crm-message-agent .crm-message-bubble{background:#fff;border:1px solid #e5e7eb;border-bottom-left-radius:4px;color:#1f2937}.crm-dark .crm-message-agent .crm-message-bubble{background:#1f2937;border-color:#374151;color:#f3f4f6}.crm-agent-name{font-size:12px;font-weight:500;margin:0 0 4px;opacity:.7}.crm-message-text{font-size:14px;line-height:1.5;margin:0;white-space:pre-wrap;word-break:break-word}.crm-message-time{font-size:11px;margin:4px 0 0;opacity:.7}.crm-typing-indicator{display:flex;gap:4px;padding:4px 0}.crm-typing-dot{animation:typing 1.4s infinite;background:#9ca3af;border-radius:50%;height:8px;width:8px}.crm-typing-dot:nth-child(2){animation-delay:.2s}.crm-typing-dot:nth-child(3){animation-delay:.4s}@keyframes typing{0%,60%,to{transform:translateY(0)}30%{transform:translateY(-10px)}}.crm-input-container{background:#fff;border-top:1px solid #e5e7eb;padding:16px}.crm-dark .crm-input-container{background:#1f2937;border-color:#374151}.crm-input-wrapper{align-items:flex-end;display:flex;gap:8px}.crm-input{background:#f9fafb;border:1px solid #d1d5db;border-radius:12px;color:#1f2937;flex:1;font-family:inherit;font-size:14px;max-height:120px;min-height:48px;padding:12px 16px;resize:none}.crm-input:focus{border-color:#6366f1;box-shadow:0 0 0 3px rgba(99,102,241,.1);outline:none}.crm-input:disabled{cursor:not-allowed;opacity:.5}.crm-dark .crm-input{background:#111827;border-color:#4b5563;color:#f3f4f6}.crm-dark .crm-input::placeholder{color:#6b7280}.crm-send-btn{align-items:center;border:none;border-radius:12px;color:#fff;cursor:pointer;display:flex;flex-shrink:0;justify-content:center;padding:12px;transition:all .2s}.crm-send-btn:hover:not(:disabled){box-shadow:0 4px 12px rgba(0,0,0,.2)}.crm-send-btn:disabled{cursor:not-allowed;opacity:.5}.crm-input-hint{color:#9ca3af;font-size:11px;margin:8px 0 0;text-align:center}.crm-dark .crm-input-hint{color:#6b7280}.crm-messages::-webkit-scrollbar{width:6px}.crm-messages::-webkit-scrollbar-track{background:transparent}.crm-messages::-webkit-scrollbar-thumb{background:#d1d5db;border-radius:3px}.crm-dark .crm-messages::-webkit-scrollbar-thumb{background:#4b5563}.crm-messages::-webkit-scrollbar-thumb:hover{background:#9ca3af}");exports.ChatCRMWidget=function(t){var n=t.apiKey,i=t.apiUrl,s=void 0===i?"https://chat-crm-backend-7mzo.onrender.com":i,a=t.primaryColor,l=void 0===a?"#4F46E5":a,p=t.position,h=void 0===p?"bottom-right":p,m=t.userData,f=void 0===m?null:m,g=t.welcomeMessage,y=void 0===g?"π Welcome! How can we help you today?":g,b=t.companyName,x=void 0===b?"Support":b,v=t.autoOpen,E=void 0!==v&&v,w=t.showNotifications,k=void 0===w||w,C=t.playSound,S=void 0!==C&&C,A=t.theme,_=void 0===A?"light":A,N=t.zIndex,R=void 0===N?9999:N,B=u(e.useState(E),2),T=B[0],O=B[1],F=u(e.useState([]),2),L=F[0],j=F[1],I=u(e.useState(""),2),z=I[0],P=I[1],M=u(e.useState(null),2),D=M[0],U=M[1],q=u(e.useState(null),2);q[0];var H=q[1],W=u(e.useState(null),2),V=W[0],K=W[1],G=u(e.useState(!1),2),Y=G[0],J=G[1],$=u(e.useState(!1),2),X=$[0],Q=$[1],Z=u(e.useState(!1),2),ee=Z[0],te=Z[1],ne=u(e.useState(!1),2),re=ne[0],oe=ne[1],ie=u(e.useState("Support Agent"),2),se=ie[0],ae=ie[1],ce=u(e.useState(0),2),le=ce[0],ue=ce[1],de=u(e.useState(!1),2),pe=de[0],he=de[1],me=u(e.useState("active"),2),fe=me[0],ge=me[1],ye=u(e.useState(null),2),be=ye[0],xe=ye[1],ve=u(e.useState(!1),2),Ee=ve[0],we=ve[1],ke=u(e.useState(!1),2),Ce=ke[0],Se=ke[1],Ae=u(e.useState(null),2),_e=Ae[0],Ne=Ae[1],Re=u(e.useState(null),2),Be=Re[0],Te=Re[1],Oe=e.useRef(null),Fe=e.useRef(null),je=u(e.useState(!1),2),Ie=je[0],ze=je[1],Pe=u(e.useState(0),2),Me=Pe[0],De=Pe[1],Ue=u(e.useState(""),2),qe=Ue[0],He=Ue[1],We=u(e.useState(!1),2),Ve=We[0],Ke=We[1],Ge=u(e.useState(!1),2),Ye=Ge[0],Je=Ge[1],$e=u(e.useState(!1),2),Xe=$e[0],Qe=$e[1],Ze=u(e.useState(null),2),et=Ze[0],tt=Ze[1],nt=u(e.useState([]),2),rt=nt[0],ot=nt[1],it=e.useRef(!1),st=e.useRef(null),at=e.useRef(null),ct=e.useRef(null),lt=e.useRef(null);e.useEffect(function(){var e=function(e){if(T){var t=at.current,n=ct.current,r=lt.current;!t||t.contains(e.target)||!n||n.contains(e.target)||r&&r.contains(e.target)||(O(!1),Qe(!1))}};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[T]);e.useEffect(function(){var e;null===(e=st.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[L]),e.useEffect(function(){return function(){D&&D.disconnect()}},[D]);var ut=function(){if(f)return{name:f.name||"Guest User",email:f.email||null,phone:f.phone||null,userId:f.userId||null};var e=function(){for(var e={name:null,email:null,phone:null},t=function(e){var t,n;return e?"META"===e.tagName?e.getAttribute("content")||null:"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value||e.getAttribute("value")||e.getAttribute("placeholder")||null:e.getAttribute("data-name")||e.getAttribute("data-user-name")||e.getAttribute("data-full-name")||e.getAttribute("data-display-name")||e.getAttribute("data-email")||e.getAttribute("data-phone")||(null===(t=e.textContent)||void 0===t?void 0:t.trim())||(null===(n=e.innerText)||void 0===n?void 0:n.trim())||null:null},n=null,r=null,i=null,s=0,a=['[name="firstName"], [name="firstname"], [name="FirstName"], [name="FIRSTNAME"]','[name="lastName"], [name="lastname"], [name="LastName"], [name="LASTNAME"]','[name="fullName"], [name="fullname"], [name="FullName"], [name="FULLNAME"]','[name="userName"], [name="username"], [name="UserName"], [name="USERNAME"]','[name="displayName"], [name="display_name"]','[name="name"], [name="Name"], [name="NAME"]',"#firstName, #firstname, #FirstName, #FIRSTNAME","#lastName, #lastname, #LastName, #LASTNAME","#fullName, #fullname, #FullName, #FULLNAME","#userName, #username, #UserName, #USERNAME","#displayName, #display_name","#name, #Name, #NAME",".firstName, .firstname, .FirstName, .FIRSTNAME",".lastName, .lastname, .LastName, .LASTNAME",".fullName, .fullname, .FullName, .FULLNAME",".userName, .username, .UserName, .USERNAME",".displayName, .display_name",".name, .Name, .NAME","[data-name], [data-user-name], [data-full-name], [data-display-name]",".profile-name, .user-name, .username, .full-name",".header-name, .nav-name, .account-name",'meta[name="user-name"], meta[property="user:name"]'];s<a.length;s++){var c=a[s];try{var l,u=o(document.querySelectorAll(c));try{for(u.s();!(l=u.n()).done;){var d=t(l.value);d&&d.length>1&&"Guest User"!==d&&(c.toLowerCase().includes("firstname")&&!n?n=d:c.toLowerCase().includes("lastname")&&!r?r=d:(c.toLowerCase().includes("fullname")||c.toLowerCase().includes("username")||c.toLowerCase().includes("displayname")||c.toLowerCase().includes("name"))&&!i&&(i=d))}}catch(e){u.e(e)}finally{u.f()}}catch(e){}}n&&r?e.name="".concat(n," ").concat(r):n?e.name=n:r?e.name=r:i&&(e.name=i);for(var p=0,h=['[name="email"], [name="Email"], [name="EMAIL"]','[type="email"]',"#email, #Email, #EMAIL",".email, .Email, .EMAIL","[data-email]",'meta[name="user-email"], meta[property="user:email"]'];p<h.length;p++){var m=h[p];try{var f=t(document.querySelector(m));if(f&&f.includes("@")){e.email=f;break}}catch(e){}}for(var g=0,y=['[name="phone"], [name="Phone"], [name="PHONE"]','[name="phoneNumber"], [name="phone_number"]','[type="tel"]',"#phone, #Phone, #PHONE",".phone, .Phone, .PHONE","[data-phone]"];g<y.length;g++){var b=y[g];try{var x=t(document.querySelector(b));if(x&&/[\d\+\-\(\)\s]{10,}/.test(x)){e.phone=x;break}}catch(e){}}return e}();return{name:e.name||localStorage.getItem("chatGuestName")||"Guest User",email:e.email||localStorage.getItem("chatGuestEmail")||null,phone:e.phone||localStorage.getItem("chatGuestPhone")||null,userId:localStorage.getItem("chatUserId")||null}},dt=function(){var e=r(c().m(function e(){var t,r,o,i,a,l,u;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return t=ut(),Q(!0),e.p=1,console.log("π Creating new conversation for first message..."),e.n=2,Un.post("".concat(s,"/api/v1/webhook/guest-conversation"),{apiKey:n,guestName:t.name,guestEmail:t.email,guestPhone:t.phone,customUserId:t.userId});case 2:if(!(r=e.v).data.success){e.n=3;break}return o=r.data,i=o.conversationId,a=o.petitionId,l=o.queryId,H(l),K(i),he(!0),localStorage.setItem("chatGuestId",l),localStorage.setItem("chatConversationId",i),localStorage.setItem("chatPetitionId",a),t.email&&localStorage.setItem("chatGuestEmail",t.email),t.name&&localStorage.setItem("chatGuestName",t.name),t.phone&&localStorage.setItem("chatGuestPhone",t.phone),console.log("β
Conversation created:",{petitionId:a,queryId:l}),e.a(2,{newConvId:i,petitionId:a});case 3:throw new Error("Failed to create conversation");case 4:throw e.p=4,u=e.v,console.error("β Create conversation error:",u),u;case 5:return e.p=5,Q(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),pt=function(){var e=r(c().m(function e(t){var r,o;return c().w(function(e){for(;;)if(0===e.n)return r=t.convId,o=t.petitionId,te(!0),e.a(2,new Promise(function(e,t){try{var i,a=Le("".concat(s,"/widget"),{query:{conversationId:r,petitionId:o,apiKey:n},transports:["websocket","polling"]});a.on("connect",function(){J(!0),te(!1),console.log("β
Connected to Chat CRM Widget Namespace"),e(a)}),a.on("connect_error",function(e){te(!1),console.error("β Socket connect_error:",(null==e?void 0:e.message)||e)}),a.on("error",function(e){console.error("β Socket error:",e)}),a.on("disconnect",function(){J(!1),console.log("β Disconnected from Chat CRM")}),a.on("new-message",function(e){console.log("π¨ Received new-message:",e);var t={message:e.message||e.text||"",sender:e.sender||"agent",senderName:e.senderName||"Support Agent",timestamp:e.timestamp||new Date,read:!1};j(function(e){var n=[].concat(d(e),[t]);return"guest"!==t.sender&&t.message&&(t.message.toLowerCase().includes("requested a photo")||t.message.toLowerCase().includes("send a photo")||t.message.toLowerCase().includes("send photo"))&&ot(function(e){var t=n.length-1;return e.includes(t)?e:[].concat(d(e),[t])}),n}),ae((e.senderName||"Support Agent").toUpperCase()),oe(!1),!T&&k&&(ue(function(e){return e+1}),S&>())}),a.on("query-accepted",function(e){console.log("β
Query accepted by agent:",e);var t=(e.agentName||"Support Agent").toUpperCase();ae(t),ge("active"),j(function(e){return[].concat(d(e),[{message:"".concat(t," has accepted your query and will assist you now."),sender:"system",timestamp:new Date,read:!0}])})}),a.on("query-transferred",function(e){console.log("π Query transferred:",e);var t=(e.toAgentName||"Support Agent").toUpperCase();ae(t),j(function(e){return[].concat(d(e),[{message:"Your query has been escalated and will be assisted shortly.",sender:"system",timestamp:new Date,read:!0}])})}),a.on("query-resolved",function(e){console.log("β
Query resolved:",e),ge("resolved"),it.current?console.log("π Skipping duplicate resolved system message"):(it.current=!0,j(function(e){return[].concat(d(e),[{message:"β
This query has been resolved by the agent.",sender:"system",timestamp:new Date,read:!0}])}))}),a.on("request-feedback",function(e){console.log("π Feedback requested:",e),ze(!0)}),a.on("request-camera-snapshot",function(e){console.log("πΈ Snapshot request received:",e);try{var t,n=localStorage.getItem("chatPetitionId");if(console.log("πΈ Checking petitionId match:",{received:null==e?void 0:e.petitionId,stored:n}),null!=e&&e.petitionId&&n&&e.petitionId===n)console.log("β
PetitionId match - showing camera"),xe({requesterName:e.requesterName||(null===(t=e.requester)||void 0===t?void 0:t.name)||"Agent",at:Date.now()});else console.log("β PetitionId mismatch or missing")}catch(e){console.error("Snapshot request error:",e)}}),a.on("query-reopened",function(e){console.log("π Query reopened:",e),ge("active"),it.current=!1}),a.on("agent-typing",function(e){e.isTyping?(oe(!0),ae(e.agentName||"Support Agent"),i&&clearTimeout(i),i=setTimeout(function(){oe(!1)},3e3)):(oe(!1),i&&clearTimeout(i))}),U(a)}catch(e){te(!1),t(e)}}))},e)}));return function(t){return e.apply(this,arguments)}}(),ht=function(){var e=r(c().m(function e(){var t,n,r,o,i,s,a,l,u,p;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(z.trim()&&"resolved"!==fe){e.n=1;break}return e.a(2);case 1:if(D&&localStorage.getItem("chatPetitionId")&&(t=localStorage.getItem("chatPetitionId"),D.emit("customer-typing",{petitionId:t,isTyping:!1})),n=ut(),r=z.trim(),o=Date.now(),j(function(e){return[].concat(d(e),[{message:r,sender:"guest",senderName:n.name||"Guest User",read:!0,timestamp:new Date,tempId:o}])}),P(""),e.p=2,i=localStorage.getItem("chatPetitionId"),s=V||localStorage.getItem("chatConversationId"),i&&s){e.n=4;break}return e.n=3,dt();case 3:a=e.v,s=a.newConvId,i=a.petitionId;case 4:if((l=D)&&Y){e.n=6;break}try{D&&D.disconnect()}catch(e){}return e.n=5,pt({convId:s,petitionId:i});case 5:l=e.v;case 6:u={conversationId:s,petitionId:i,message:r,senderName:n.name||"Guest User",senderType:"Customer",timestamp:new Date},console.log("π€ Sending message:",u),l.emit("widget-message",u),e.n=8;break;case 7:e.p=7,p=e.v,console.error("β Send message error:",p),j(function(e){return e.filter(function(e){return e.tempId!==o})}),alert("Failed to send message. Please try again.");case 8:return e.a(2)}},e,null,[[2,7]])}));return function(){return e.apply(this,arguments)}}(),mt=function(){localStorage.removeItem("chatGuestId"),localStorage.removeItem("chatConversationId"),localStorage.removeItem("chatPetitionId"),D&&D.disconnect(),U(null),H(null),K(null),J(!1),he(!1),ge("active"),it.current=!1,j([]),P(""),ze(!1),De(0),He(""),Ke(!1),console.log("π Starting new query...")},ft=function(e){if("ticket"===e&&!((null==f?void 0:f.email)||localStorage.getItem("chatGuestEmail")))return tt(e),void Qe(!1);tt(e),Qe(!1)},gt=function(){var e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),n=e.createGain();t.connect(n),n.connect(e.destination),t.frequency.value=800,t.type="sine",n.gain.value=.1,t.start(),setTimeout(function(){return t.stop()},200)},yt=function(){var e=r(c().m(function e(){var t,n;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,navigator.mediaDevices.getUserMedia({video:{facingMode:"user"}});case 1:t=e.v,Ne(t),Oe.current&&(Oe.current.srcObject=t,Oe.current.play()),e.n=3;break;case 2:e.p=2,n=e.v,console.error("Camera access error:",n),alert("Camera access denied. Please allow camera permissions."),vt();case 3:return e.a(2)}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}(),bt=function(){var e=r(c().m(function e(){return c().w(function(e){for(;;)switch(e.n){case 0:return Te(null),e.n=1,yt();case 1:return e.a(2)}},e)}));return function(){return e.apply(this,arguments)}}(),xt=function(){var e=r(c().m(function e(){var t,r,o,i,a,l,u,p,h;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(Be){e.n=1;break}return e.a(2);case 1:return we(!0),e.p=2,e.n=3,fetch(Be).then(function(e){return e.blob()});case 3:return r=e.v,o=localStorage.getItem("chatPetitionId"),i=new FormData,a="snapshot-".concat(o,"-").concat(Date.now(),".png"),i.append("screenshot",r,a),i.append("petitionId",o),i.append("apiKey",n),i.append("metadata",JSON.stringify({source:"widget",requesterName:null==be?void 0:be.requesterName})),e.n=4,Un.post("".concat(s,"/api/v1/webhook/upload-snapshot"),i,{headers:{"Content-Type":"multipart/form-data"}});case 4:if(l=e.v,!(u=null==l||null===(t=l.data)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.imageUrl)){e.n=5;break}return p=new Date,j(function(e){return[].concat(d(e),[{message:"πΈ Screenshot: ".concat(u),sender:"guest",senderName:"You",timestamp:p,read:!0}])}),e.n=5,Un.post("".concat(s,"/api/v1/webhook/send-message"),{apiKey:n,petitionId:o,message:"πΈ Screenshot: ".concat(u),senderName:"Guest User"});case 5:vt(),e.n=7;break;case 6:e.p=6,h=e.v,console.error("Widget capture error:",h),alert("Failed to upload photo. Please try again.");case 7:return e.p=7,we(!1),e.f(7);case 8:return e.a(2)}},e,null,[[2,6,7,8]])}));return function(){return e.apply(this,arguments)}}(),vt=function(){_e&&(_e.getTracks().forEach(function(e){return e.stop()}),Ne(null)),Se(!1),Te(null),xe(null)};e.useEffect(function(){console.log("πΈ Snapshot useEffect triggered:",{snapshotRequest:be,showCamera:Ce}),be&&!Ce&&(console.log("πΈ Setting showCamera to true and initializing camera"),Se(!0),setTimeout(function(){console.log("πΈ Calling initializeCamera"),yt()},100))},[be,Ce]),e.useEffect(function(){console.log("πΈ Video ref useEffect:",{showCamera:Ce,hasVideoRef:!!Oe.current,currentStream:_e,capturedImage:Be}),Ce&&Oe.current&&!_e&&!Be&&(console.log("πΈ Reinitializing camera from video ref useEffect"),yt())},[Ce,Oe.current]);var Et=function(){var e={"bottom-right":"crm-bottom-6 crm-right-6","bottom-left":"crm-bottom-6 crm-left-6","top-right":"crm-top-6 crm-right-6","top-left":"crm-top-6 crm-left-6"};return e[h]||e["bottom-right"]},wt="dark"===_||"auto"===_&&window.matchMedia("(prefers-color-scheme: dark)").matches;return e.createElement("div",{className:"crm-widget-container",style:{zIndex:R}},e.createElement("button",{ref:ct,onClick:function(){O(function(e){var t=!e;return t?(ue(0),Qe(!0),tt(null)):(Qe(!1),tt(null)),t})},className:"crm-chat-button ".concat(Et()),style:{background:"linear-gradient(135deg, ".concat(l," 0%, #6366f1 100%)")},"aria-label":T?"Close help":"Help & Support",title:"Help & Support"},T&&!Xe?e.createElement("svg",{className:"crm-icon",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})):e.createElement("svg",{className:"crm-icon",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M18 3a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3h-5l-5 3v-3H6a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3h12z"}),e.createElement("circle",{cx:"9",cy:"10",r:"1",fill:"currentColor"}),e.createElement("circle",{cx:"12",cy:"10",r:"1",fill:"currentColor"}),e.createElement("circle",{cx:"15",cy:"10",r:"1",fill:"currentColor"}),e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 14c.5.5 1.5 1 3 1s2.5-.5 3-1"})),!T&&le>0&&e.createElement("span",{className:"crm-badge"},le)),T&&Xe&&e.createElement("div",{ref:lt,className:"crm-menu-popup ".concat(Et()," ").concat(wt?"crm-dark":""),style:{position:"fixed",bottom:h.includes("bottom")?"90px":"auto",top:h.includes("top")?"90px":"auto",right:h.includes("right")?"24px":"auto",left:h.includes("left")?"24px":"auto",width:"280px",backgroundColor:wt?"#1F2937":"#fff",borderRadius:"12px",boxShadow:"0 10px 40px rgba(0,0,0,0.15)",border:wt?"1px solid #374151":"1px solid #E5E7EB",overflow:"hidden",zIndex:R+1}},e.createElement("div",{style:{padding:"16px",borderBottom:wt?"1px solid #374151":"1px solid #E5E7EB"}},e.createElement("h3",{style:{margin:0,fontSize:"16px",fontWeight:600,color:wt?"#F9FAFB":"#111827"}},"Help & Support"),e.createElement("p",{style:{margin:"4px 0 0 0",fontSize:"13px",color:wt?"#9CA3AF":"#6B7280"}},"How can we assist you today?")),e.createElement("div",{style:{padding:"8px"}},e.createElement("button",{onClick:function(){return ft("query")},className:"crm-menu-option",style:{width:"100%",padding:"12px",display:"flex",alignItems:"center",gap:"12px",border:"none",borderRadius:"8px",backgroundColor:"transparent",cursor:"pointer",transition:"all 0.2s",textAlign:"left"},onMouseEnter:function(e){return e.currentTarget.style.backgroundColor=wt?"#374151":"#F3F4F6"},onMouseLeave:function(e){return e.currentTarget.style.backgroundColor="transparent"}},e.createElement("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:l,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},e.createElement("svg",{style:{width:"20px",height:"20px",color:"#fff"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"}))),e.createElement("div",{style:{flex:1}},e.createElement("p",{style:{margin:0,fontSize:"14px",fontWeight:600,color:wt?"#F9FAFB":"#111827"}},"Start Query"),e.createElement("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:wt?"#9CA3AF":"#6B7280"}},"Chat with our support team")),e.createElement("svg",{style:{width:"16px",height:"16px",color:wt?"#9CA3AF":"#6B7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}))),e.createElement("button",{onClick:function(){return ft("ticket")},className:"crm-menu-option",style:{width:"100%",padding:"12px",display:"flex",alignItems:"center",gap:"12px",border:"none",borderRadius:"8px",backgroundColor:"transparent",cursor:"pointer",transition:"all 0.2s",textAlign:"left",marginTop:"4px"},onMouseEnter:function(e){return e.currentTarget.style.backgroundColor=wt?"#374151":"#F3F4F6"},onMouseLeave:function(e){return e.currentTarget.style.backgroundColor="transparent"}},e.createElement("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:"#10B981",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},e.createElement("svg",{style:{width:"20px",height:"20px",color:"#fff"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"}))),e.createElement("div",{style:{flex:1}},e.createElement("p",{style:{margin:0,fontSize:"14px",fontWeight:600,color:wt?"#F9FAFB":"#111827"}},"Raise Ticket"),e.createElement("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:wt?"#9CA3AF":"#6B7280"}},"Submit a support ticket")),e.createElement("svg",{style:{width:"16px",height:"16px",color:wt?"#9CA3AF":"#6B7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}))))),T&&"query"===et&&e.createElement("div",{ref:at,className:"crm-chat-window ".concat(Et()," ").concat(wt?"crm-dark":""),style:{position:"relative"}},e.createElement("div",{className:"crm-header",style:{backgroundColor:l}},e.createElement("div",{className:"crm-header-content"},e.createElement("button",{onClick:function(){tt(null),Qe(!0)},className:"crm-back-btn",title:"Back to Menu",style:{background:"none",border:"none",color:"#fff",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",marginRight:"8px"}},e.createElement("svg",{className:"crm-icon-sm",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"}))),e.createElement("div",{className:"crm-avatar"},e.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:l,strokeWidth:"2"},e.createElement("path",{d:"M12 2a4 4 0 0 1 4 4v2a4 4 0 0 1-8 0V6a4 4 0 0 1 4-4z"}),e.createElement("path",{d:"M12 14v8"}),e.createElement("path",{d:"M8 22h8"}),e.createElement("path",{d:"M8 14c-2 0-3 1-3 3v1c0 2 1 3 3 3h8c2 0 3-1 3-3v-1c0-2-1-3-3-3H8z"}))),e.createElement("div",null,e.createElement("h3",{className:"crm-title"},x),e.createElement("div",{className:"crm-status"},e.createElement("div",{className:"crm-status-dot ".concat(Y?"crm-online":"crm-offline")}),e.createElement("span",null,"resolved"===fe?e.createElement("span",{style:{color:"#10B981"}},"β Resolved"):"Support Agent"!==se?e.createElement("span",null,"π¬ ",se):Y?"Online":ee?"Connectingβ¦":"Ready")))),e.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},e.createElement("button",{onClick:mt,className:"crm-new-query-btn",title:"Start New Query"},e.createElement("svg",{className:"crm-icon-sm",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"}))),e.createElement("button",{onClick:function(){O(!1),Qe(!1),tt(null)},className:"crm-close-btn"},e.createElement("svg",{className:"crm-icon-sm",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))))),Ce&&e.createElement("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:wt?"#1F2937":"#fff",zIndex:9999,display:"flex",flexDirection:"column",padding:"16px",overflow:"auto"}},e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"}},e.createElement("h3",{style:{margin:0,fontSize:"16px",fontWeight:600,color:wt?"#E5E7EB":"#111827"}},"πΈ Camera Capture"),e.createElement("button",{onClick:vt,style:{background:"none",border:"none",fontSize:"24px",cursor:"pointer",padding:"0",color:wt?"#9CA3AF":"#6B7280"}},"Γ")),e.createElement("p",{style:{fontSize:"14px",color:wt?"#9CA3AF":"#6B7280",marginBottom:"12px"}},(null==be?void 0:be.requesterName)||"Agent"," requested a photo"),e.createElement("div",{style:{width:"100%",height:"300px",display:"flex",alignItems:"center",justifyContent:"center",background:"#000",borderRadius:"8px",overflow:"hidden",marginBottom:"12px",position:"relative"}},Be?e.createElement("img",{src:Be,alt:"Captured",style:{width:"100%",height:"100%",objectFit:"contain"}}):e.createElement(e.Fragment,null,e.createElement("video",{ref:Oe,autoPlay:!0,playsInline:!0,muted:!0,style:{width:"100%",height:"100%",objectFit:"cover",display:_e?"block":"none"}}),!_e&&e.createElement("div",{style:{position:"absolute",color:"#fff",textAlign:"center"}},e.createElement("div",{style:{fontSize:"14px",marginBottom:"8px"}},"Initializing camera..."),e.createElement("div",{style:{fontSize:"24px"}},"πΉ"))),e.createElement("canvas",{ref:Fe,style:{display:"none"}})),e.createElement("div",{style:{display:"flex",gap:"8px",justifyContent:"center"}},Be?e.createElement(e.Fragment,null,e.createElement("button",{onClick:bt,className:"crm-close-btn",style:{padding:"12px 24px",fontSize:"14px",fontWeight:600}},"π Retake"),e.createElement("button",{onClick:xt,className:"crm-send-btn",style:{backgroundColor:l,padding:"12px 24px",fontSize:"14px",fontWeight:600},disabled:Ee},Ee?"β³ Uploading...":"β
Submit")):e.createElement("button",{onClick:function(){if(Oe.current&&Fe.current){var e=Oe.current,t=Fe.current;t.width=e.videoWidth||640,t.height=e.videoHeight||480,t.getContext("2d").drawImage(e,0,0,t.width,t.height);var n=t.toDataURL("image/png");Te(n),_e&&(_e.getTracks().forEach(function(e){return e.stop()}),Ne(null))}},className:"crm-send-btn",style:{backgroundColor:l,padding:"12px 24px",fontSize:"14px",fontWeight:600}},"πΈ Capture"))),e.createElement("div",{className:"crm-messages"},!pe&&0===L.length&&e.createElement("div",{className:"crm-welcome-message"},e.createElement("p",null,y),e.createElement("p",{style:{fontSize:"0.875rem",marginTop:"8px",opacity:.7}},"π Start typing to begin your conversation")),L.map(function(t,n){return e.createElement(e.Fragment,{key:n},e.createElement("div",{className:"crm-message ".concat("guest"===t.sender?"crm-message-guest":"system"===t.sender?"crm-message-system":"crm-message-agent")},e.createElement("div",{className:"crm-message-bubble",style:"guest"===t.sender?{backgroundColor:l}:"system"===t.sender?{backgroundColor:"#F3F4F6",color:"#374151",border:"1px solid #E5E7EB"}:{}},"agent"===t.sender&&e.createElement("p",{className:"crm-agent-name"},(t.senderName||se).toUpperCase()),function(){var n=String(t.message||""),r=n.match(/https?:[^\s]+\.(?:png|jpg|jpeg|gif|webp)/i);if(r){var o=r[0],i=n.replace(o,"").trim();return e.createElement("div",null,i&&e.createElement("p",{className:"crm-message-text",style:{opacity:.85}},i),e.createElement("img",{src:o,alt:"snapshot",style:{maxWidth:"240px",maxHeight:"180px",borderRadius:"8px",border:"1px solid #E5E7EB",display:"block"}}))}return e.createElement("p",{className:"crm-message-text"},n)}(),e.createElement("p",{className:"crm-message-time"},(o=t.timestamp,new Date(o).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}))))),"guest"!==t.sender&&t.message&&(t.message.toLowerCase().includes("requested a photo")||t.message.toLowerCase().includes("send a photo")||t.message.toLowerCase().includes("send photo"))&&rt.includes(n)&&e.createElement("div",{style:{width:"100%",marginTop:"12px",marginBottom:"12px"}},e.createElement(sr,{onCapture:function(){var e=r(c().m(function e(t){var r;return c().w(function(e){for(;;)switch(e.n){case 0:try{r={message:"πΈ Photo sent",sender:"guest",timestamp:Date.now()},j(function(e){return[].concat(d(e),[r])}),D&&D.emit("chatMessage",{conversationId:V,message:"πΈ Photo sent",image:t}),ot(function(e){return e.filter(function(e){return e!==n})})}catch(e){console.error("Failed to send photo:",e)}case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),onClose:function(){ot(function(e){return e.filter(function(e){return e!==n})})},requesterName:t.senderName||se})));var o}),re&&e.createElement("div",{className:"crm-message crm-message-agent"},e.createElement("div",{className:"crm-message-bubble"},e.createElement("div",{className:"crm-typing-indicator"},e.createElement("div",{className:"crm-typing-dot"}),e.createElement("div",{className:"crm-typing-dot"}),e.createElement("div",{className:"crm-typing-dot"})))),Ie&&!Ve&&e.createElement("div",{className:"crm-message crm-message-system"},e.createElement("div",{className:"crm-feedback-form",style:{backgroundColor:"#F9FAFB",padding:"16px",borderRadius:"12px",border:"1px solid #E5E7EB"}},e.createElement("p",{style:{fontWeight:"600",marginBottom:"12px",color:"#111827"}},"β Rate Your Experience"),e.createElement("div",{style:{display:"flex",gap:"8px",marginBottom:"12px",justifyContent:"center"}},[1,2,3,4,5].map(function(t){return e.createElement("button",{key:t,onClick:function(){return De(t)},style:{background:"none",border:"none",cursor:"pointer",fontSize:"32px",padding:"0",transition:"transform 0.2s",filter:Me>=t?"none":"grayscale(100%)"},onMouseEnter:function(e){return e.currentTarget.style.transform="scale(1.2)"},onMouseLeave:function(e){return e.currentTarget.style.transform="scale(1)"}},Me>=t?"β":"β")})),e.createElement("textarea",{value:qe,onChange:function(e){return He(e.target.value)},placeholder:"Share your thoughts (optional)...",rows:"3",style:{width:"100%",padding:"8px 12px",border:"1px solid #D1D5DB",borderRadius:"8px",fontSize:"14px",fontFamily:"inherit",resize:"none",marginBottom:"12px"}}),e.createElement("button",{onClick:function(){if(Me&&!Ve&&!Ye){Je(!0);var e=localStorage.getItem("chatPetitionId");D&&e?(D.emit("submit-feedback",{petitionId:e,rating:Me,comment:qe.trim()}),console.log("π€ Feedback submitted:",{rating:Me,comment:qe}),Ke(!0),Je(!1),setTimeout(function(){ze(!1)},2e3)):Je(!1)}},disabled:!Me||Ye,style:{width:"100%",padding:"10px",backgroundColor:Me?l:"#D1D5DB",color:"white",border:"none",borderRadius:"8px",fontSize:"14px",fontWeight:"600",cursor:Me?"pointer":"not-allowed",transition:"all 0.2s"}},Ye?"Submitting...":"Submit Feedback"))),Ve&&e.createElement("div",{className:"crm-message crm-message-system"},e.createElement("div",{className:"crm-message-bubble",style:{backgroundColor:"#D1FAE5",color:"#065F46",border:"1px solid #A7F3D0"}},e.createElement("p",{className:"crm-message-text"},"β
Thank you for your feedback!"))),e.createElement("div",{ref:st})),e.createElement("div",{className:"crm-input-container"},"resolved"===fe?e.createElement("button",{onClick:mt,className:"crm-send-btn",style:{backgroundColor:l,width:"100%",padding:"12px",fontSize:"14px",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",border:"none",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s"}},e.createElement("svg",{style:{width:"18px",height:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})),"New Query"):e.createElement("div",{className:"crm-input-wrapper"},e.createElement("textarea",{value:z,onChange:function(e){var t=e.target.value;if(P(t),t.trim()&&D&&localStorage.getItem("chatPetitionId")){var n=localStorage.getItem("chatPetitionId"),r=ut();D.emit("customer-typing",{petitionId:n,userName:r.name||"Customer",isTyping:!0})}},onKeyPress:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),ht())},placeholder:"Type your message...",rows:"1",className:"crm-input"}),e.createElement("button",{onClick:ht,disabled:!z.trim()||X,className:"crm-send-btn",style:{backgroundColor:l}},X?e.createElement("svg",{className:"crm-icon-sm crm-spin",fill:"none",viewBox:"0 0 24 24"},e.createElement("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.createElement("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})):e.createElement("svg",{className:"crm-icon-sm",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})))),"resolved"!==fe&&e.createElement("p",{className:"crm-input-hint"},pe?"Press Enter to send β’ Shift+Enter for new line":"Send your first message to start conversation"))),"ticket"===et&&e.createElement(or,{apiKey:n,apiUrl:s,primaryColor:l,userData:ut(),theme:_,onClose:function(){tt(null),Qe(!0)}}))},exports.TicketBoard=or;
|
|
3
|
+
var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof a?r:a,u=Object.create(c.prototype);return l(u,"_invoke",function(n,r,o){var i,a,c,l=0,u=o||[],d=!1,p={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,a=0,c=e,p.n=n,s}};function h(n,r){for(a=n,c=r,t=0;!d&&l&&!o&&t<u.length;t++){var o,i=u[t],h=p.p,m=i[2];n>3?(o=m===r)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=h&&((o=n<2&&h<i[1])?(a=0,p.v=r,p.n=i[1]):h<m&&(o=n<3||i[0]>r||r>m)&&(i[4]=n,i[5]=r,p.n=m,a=0))}if(o||n>1)return s;throw d=!0,r}return function(o,u,m){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,m),a=u,c=m;(t=a<2?e:c)||!d;){i||(a?a<3?(a>1&&(p.n=-1),h(a,c)):p.n=c:p.v=c);try{if(l=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(d=p.n<0)?c:n.call(r,p))!==s)break}catch(t){i=e,a=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,o,i),!0),u}var s={};function a(){}function u(){}function d(){}t=Object.getPrototypeOf;var p=[][r]?t(t([][r]())):(l(t={},r,function(){return this}),t),h=d.prototype=a.prototype=Object.create(p);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,l(e,o,"GeneratorFunction")),e.prototype=Object.create(h),e}return u.prototype=d,l(h,"constructor",d),l(d,"constructor",u),u.displayName="GeneratorFunction",l(d,o,"GeneratorFunction"),l(h),l(h,o,"Generator"),l(h,r,function(){return this}),l(h,"toString",function(){return"[object Generator]"}),(c=function(){return{w:i,m:m}})()}function l(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}l=function(e,t,n,r){function i(t,n){l(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},l(e,t,n,r)}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,s,a=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}const h=Object.create(null);h.open="0",h.close="1",h.ping="2",h.pong="3",h.message="4",h.upgrade="5",h.noop="6";const m=Object.create(null);Object.keys(h).forEach(e=>{m[h[e]]=e});const f={type:"error",data:"parser error"},g="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),y="function"==typeof ArrayBuffer,b=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,x=({type:e,data:t},n,r)=>g&&t instanceof Blob?n?r(t):v(t,r):y&&(t instanceof ArrayBuffer||b(t))?n?r(t):v(new Blob([t]),r):r(h[e]+(t||"")),v=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function E(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let w;const k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",C="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)C[k.charCodeAt(e)]=e;const S="function"==typeof ArrayBuffer,A=(e,t)=>{if("string"!=typeof e)return{type:"message",data:N(e,t)};const n=e.charAt(0);if("b"===n)return{type:"message",data:_(e.substring(1),t)};return m[n]?e.length>1?{type:m[n],data:e.substring(1)}:{type:m[n]}:f},_=(e,t)=>{if(S){const n=(e=>{let t,n,r,o,i,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);const l=new ArrayBuffer(s),u=new Uint8Array(l);for(t=0;t<a;t+=4)n=C[e.charCodeAt(t)],r=C[e.charCodeAt(t+1)],o=C[e.charCodeAt(t+2)],i=C[e.charCodeAt(t+3)],u[c++]=n<<2|r>>4,u[c++]=(15&r)<<4|o>>2,u[c++]=(3&o)<<6|63&i;return l})(e);return N(n,t)}return{base64:!0,data:e}},N=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,R=String.fromCharCode(30);function B(){return new TransformStream({transform(e,t){!function(e,t){g&&e.data instanceof Blob?e.data.arrayBuffer().then(E).then(t):y&&(e.data instanceof ArrayBuffer||b(e.data))?t(E(e.data)):x(e,!1,e=>{w||(w=new TextEncoder),t(w.encode(e))})}(e,n=>{const r=n.length;let o;if(r<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,r);else if(r<65536){o=new Uint8Array(3);const e=new DataView(o.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{o=new Uint8Array(9);const e=new DataView(o.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(o[0]|=128),t.enqueue(o),t.enqueue(n)})}})}let T;function O(e){return e.reduce((e,t)=>e+t.length,0)}function F(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let o=0;o<t;o++)n[o]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function L(e){if(e)return function(e){for(var t in L.prototype)e[t]=L.prototype[t];return e}(e)}L.prototype.on=L.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},L.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},L.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},L.prototype.emitReserved=L.prototype.emit,L.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},L.prototype.hasListeners=function(e){return!!this.listeners(e).length};const j="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),I="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function z(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const P=I.setTimeout,M=I.clearTimeout;function D(e,t){t.useNativeTimers?(e.setTimeoutFn=P.bind(I),e.clearTimeoutFn=M.bind(I)):(e.setTimeoutFn=I.setTimeout.bind(I),e.clearTimeoutFn=I.clearTimeout.bind(I))}function U(e){return"string"==typeof e?function(e){let t=0,n=0;for(let r=0,o=e.length;r<o;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))}function q(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class H extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class W extends L{constructor(e){super(),this.writable=!1,D(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 H(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=A(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&&Number(443!==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 V extends W{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(R),r=[];for(let e=0;e<n.length;e++){const o=A(n[e],t);if(r.push(o),"error"===o.type)break}return r})(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,r=new Array(n);let o=0;e.forEach((e,i)=>{x(e,!1,e=>{r[i]=e,++o===n&&t(r.join(R))})})})(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]=q()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}let K=!1;try{K="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const G=K;function Y(){}class J extends V{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 $ extends L{constructor(e,t,n){super(),this.createRequest=e,D(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=z(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=$.requestsCount++,$.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=Y,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete $.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($.requestsCount=0,$.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",X);else if("function"==typeof addEventListener){addEventListener("onpagehide"in I?"pagehide":"unload",X,!1)}function X(){for(let e in $.requests)$.requests.hasOwnProperty(e)&&$.requests[e].abort()}const Q=function(){const e=Z({xdomain:!1});return e&&null!==e.responseType}();function Z(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||G))return new XMLHttpRequest}catch(e){}if(!t)try{return new(I[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}const ee="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class te extends W{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=ee?{}:z(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],r=t===e.length-1;x(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch(e){}r&&j(()=>{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]=q()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const ne=I.WebSocket||I.MozWebSocket;const re={websocket:class extends te{createSocket(e,t,n){return ee?new ne(e,t,n):t?new ne(e,t):new ne(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends W{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){T||(T=new TextDecoder);const n=[];let r=0,o=-1,i=!1;return new TransformStream({transform(s,a){for(n.push(s);;){if(0===r){if(O(n)<1)break;const e=F(n,1);i=!(128&~e[0]),o=127&e[0],r=o<126?3:126===o?1:2}else if(1===r){if(O(n)<2)break;const e=F(n,2);o=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(O(n)<8)break;const e=F(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),i=t.getUint32(0);if(i>Math.pow(2,21)-1){a.enqueue(f);break}o=i*Math.pow(2,32)+t.getUint32(4),r=3}else{if(O(n)<o)break;const e=F(n,o);a.enqueue(A(i?e:T.decode(e),t)),r=0}if(0===o||o>e){a.enqueue(f);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=B();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const o=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),o())}).catch(e=>{})};o();const i={type:"open"};this.query.sid&&(i.data=`{"sid":"${this.query.sid}"}`),this._writer.write(i).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&j(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}},polling:class extends J{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=Q&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new $(Z,this.uri(),e)}}},oe=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ie=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function se(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let o=oe.exec(e||""),i={},s=14;for(;s--;)i[ie[s]]=o[s]||"";return-1!=n&&-1!=r&&(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,r=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||r.splice(0,1);"/"==t.slice(-1)&&r.splice(r.length-1,1);return r}(0,i.path),i.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}(0,i.query),i}const ae="function"==typeof addEventListener&&"function"==typeof removeEventListener,ce=[];ae&&addEventListener("offline",()=>{ce.forEach(e=>e())},!1);class le extends L{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=se(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=se(t.host).host);D(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,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}(this.opts.query)),ae&&(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"})},ce.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&&le.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",le.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+=U(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,j(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const o={type:e,data:t,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),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(le.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(),ae&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=ce.indexOf(this._offlineEventListener);-1!==e&&ce.splice(e,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}le.protocol=4;class ue extends le{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;le.priorWebsocketSuccess=!1;const r=()=>{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;le.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 o(){n||(n=!0,l(),t.close(),t=null)}const i=e=>{const n=new Error("probe error: "+e);n.transport=t.name,o(),this.emitReserved("upgradeError",n)};function s(){i("transport closed")}function a(){i("socket closed")}function c(e){t&&e.name!==t.name&&o()}const l=()=>{t.removeListener("open",r),t.removeListener("error",i),t.removeListener("close",s),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",i),t.once("close",s),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 de=class extends ue{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=>re[e]).filter(e=>!!e)),super(e,n)}};const pe="function"==typeof ArrayBuffer,he=Object.prototype.toString,me="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===he.call(Blob),fe="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===he.call(File);function ge(e){return pe&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||me&&e instanceof Blob||fe&&e instanceof File}function ye(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(ye(e[t]))return!0;return!1}if(ge(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return ye(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&ye(e[t]))return!0;return!1}function be(e){const t=[],n=e.data,r=e;return r.data=xe(n,t),r.attachments=t.length,{packet:r,buffers:t}}function xe(e,t){if(!e)return e;if(ge(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 r=0;r<e.length;r++)n[r]=xe(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=xe(e[r],t));return n}return e}function ve(e,t){return e.data=Ee(e.data,t),delete e.attachments,e}function Ee(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]=Ee(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Ee(e[n],t));return e}const we=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var ke;!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"}(ke||(ke={}));function Ce(e){return"[object Object]"===Object.prototype.toString.call(e)}class Se extends L{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===ke.BINARY_EVENT;n||t.type===ke.BINARY_ACK?(t.type=n?ke.EVENT:ke.ACK,this.reconstructor=new Ae(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!ge(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===ke[n.type])throw new Error("unknown packet type "+n.type);if(n.type===ke.BINARY_EVENT||n.type===ke.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const o=e.substring(r,t);if(o!=Number(o)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(o)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=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(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!Se.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case ke.CONNECT:return Ce(t);case ke.DISCONNECT:return void 0===t;case ke.CONNECT_ERROR:return"string"==typeof t||Ce(t);case ke.EVENT:case ke.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===we.indexOf(t[0]));case ke.ACK:case ke.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Ae{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=ve(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var _e=Object.freeze({__proto__:null,Decoder:Se,Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==ke.EVENT&&e.type!==ke.ACK||!ye(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===ke.EVENT?ke.BINARY_EVENT:ke.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==ke.BINARY_EVENT&&e.type!==ke.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=be(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},get PacketType(){return ke},protocol:5});function Ne(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Re=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Be extends L{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=[Ne(e,"open",this.onopen.bind(this)),Ne(e,"packet",this.onpacket.bind(this)),Ne(e,"error",this.onerror.bind(this)),Ne(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,r,o;if(Re.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:ke.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 s=null===(r=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===r?void 0:r.writable,a=this.connected&&!(null===(o=this.io.engine)||void 0===o?void 0:o._hasPingExpired());return this.flags.volatile&&!s||(a?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i)),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const o=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"))},r),i=(...e)=>{this.io.clearTimeoutFn(o),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{const o=(e,t)=>e?r(e):n(t);o.withError=!0,t.push(o),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,...r)=>{if(n!==this._queue[0])return;return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...r)),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:ke.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 ke.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 ke.EVENT:case ke.BINARY_EVENT:this.onevent(e);break;case ke.ACK:case ke.BINARY_ACK:this.onack(e);break;case ke.DISCONNECT:this.ondisconnect();break;case ke.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(...r){n||(n=!0,t.packet({type:ke.ACK,id:e,data:r}))}}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.emitReserved("connect"),this._drainQueue(!0)}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:ke.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 Te(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}Te.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)},Te.prototype.reset=function(){this.attempts=0},Te.prototype.setMin=function(e){this.ms=e},Te.prototype.setMax=function(e){this.max=e},Te.prototype.setJitter=function(e){this.jitter=e};class Oe extends L{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,D(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 Te({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||_e;this.encoder=new r.Encoder,this.decoder=new r.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 de(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=Ne(t,"open",function(){n.onopen(),e&&e()}),o=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},i=Ne(t,"error",o);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn(()=>{r(),o(new Error("timeout")),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),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(Ne(e,"ping",this.onping.bind(this)),Ne(e,"data",this.ondata.bind(this)),Ne(e,"error",this.onerror.bind(this)),Ne(e,"close",this.onclose.bind(this)),Ne(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){j(()=>{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 Be(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 Fe={};function Le(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let r=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),r=se(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),r=n.source,o=n.id,i=n.path,s=Fe[o]&&i in Fe[o].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||s?a=new Oe(r,t):(Fe[o]||(Fe[o]=new Oe(r,t)),a=Fe[o]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}function je(e,t){return function(){return e.apply(t,arguments)}}Object.assign(Le,{Manager:Oe,Socket:Be,io:Le,connect:Le});const{toString:Ie}=Object.prototype,{getPrototypeOf:ze}=Object,{iterator:Pe,toStringTag:Me}=Symbol,De=(e=>t=>{const n=Ie.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ue=e=>(e=e.toLowerCase(),t=>De(t)===e),qe=e=>t=>typeof t===e,{isArray:He}=Array,We=qe("undefined");function Ve(e){return null!==e&&!We(e)&&null!==e.constructor&&!We(e.constructor)&&Ye(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=Ue("ArrayBuffer");const Ge=qe("string"),Ye=qe("function"),Je=qe("number"),$e=e=>null!==e&&"object"==typeof e,Xe=e=>{if("object"!==De(e))return!1;const t=ze(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Me in e||Pe in e)},Qe=Ue("Date"),Ze=Ue("File"),et=Ue("Blob"),tt=Ue("FileList"),nt=Ue("URLSearchParams"),[rt,ot,it,st]=["ReadableStream","Request","Response","Headers"].map(Ue);function at(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),He(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Ve(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let s;for(r=0;r<i;r++)s=o[r],t.call(null,e[s],s,e)}}function ct(e,t){if(Ve(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const lt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,ut=e=>!We(e)&&e!==lt;const dt=(pt="undefined"!=typeof Uint8Array&&ze(Uint8Array),e=>pt&&e instanceof pt);var pt;const ht=Ue("HTMLFormElement"),mt=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ft=Ue("RegExp"),gt=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};at(n,(n,o)=>{let i;!1!==(i=t(n,o,e))&&(r[o]=i||n)}),Object.defineProperties(e,r)};const yt=Ue("AsyncFunction"),bt=(xt="function"==typeof setImmediate,vt=Ye(lt.postMessage),xt?setImmediate:vt?(Et=`axios@${Math.random()}`,wt=[],lt.addEventListener("message",({source:e,data:t})=>{e===lt&&t===Et&&wt.length&&wt.shift()()},!1),e=>{wt.push(e),lt.postMessage(Et,"*")}):e=>setTimeout(e));var xt,vt,Et,wt;const kt="undefined"!=typeof queueMicrotask?queueMicrotask.bind(lt):"undefined"!=typeof process&&process.nextTick||bt;var Ct={isArray:He,isArrayBuffer:Ke,isBuffer:Ve,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||Ye(e.append)&&("formdata"===(t=De(e))||"object"===t&&Ye(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Ke(e.buffer),t},isString:Ge,isNumber:Je,isBoolean:e=>!0===e||!1===e,isObject:$e,isPlainObject:Xe,isEmptyObject:e=>{if(!$e(e)||Ve(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:rt,isRequest:ot,isResponse:it,isHeaders:st,isUndefined:We,isDate:Qe,isFile:Ze,isBlob:et,isRegExp:ft,isFunction:Ye,isStream:e=>$e(e)&&Ye(e.pipe),isURLSearchParams:nt,isTypedArray:dt,isFileList:tt,forEach:at,merge:function e(){const{caseless:t,skipUndefined:n}=ut(this)&&this||{},r={},o=(o,i)=>{const s=t&&ct(r,i)||i;Xe(r[s])&&Xe(o)?r[s]=e(r[s],o):Xe(o)?r[s]=e({},o):He(o)?r[s]=o.slice():n&&We(o)||(r[s]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&at(arguments[e],o);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(at(t,(t,r)=>{n&&Ye(t)?e[r]=je(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,i,s;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&ze(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:De,kindOfTest:Ue,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(He(e))return e;let t=e.length;if(!Je(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Pe]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:ht,hasOwnProperty:mt,hasOwnProp:mt,reduceDescriptors:gt,freezeMethods:e=>{gt(e,(t,n)=>{if(Ye(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];Ye(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return He(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:ct,global:lt,isContextDefined:ut,isSpecCompliantForm:function(e){return!!(e&&Ye(e.append)&&"FormData"===e[Me]&&e[Pe])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if($e(e)){if(t.indexOf(e)>=0)return;if(Ve(e))return e;if(!("toJSON"in e)){t[r]=e;const o=He(e)?[]:{};return at(e,(e,t)=>{const i=n(e,r+1);!We(i)&&(o[t]=i)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:yt,isThenable:e=>e&&($e(e)||Ye(e))&&Ye(e.then)&&Ye(e.catch),setImmediate:bt,asap:kt,isIterable:e=>null!=e&&Ye(e[Pe])};function St(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}Ct.inherits(St,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ct.toJSONObject(this.config),code:this.code,status:this.status}}});const At=St.prototype,_t={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{_t[e]={value:e}}),Object.defineProperties(St,_t),Object.defineProperty(At,"isAxiosError",{value:!0}),St.from=(e,t,n,r,o,i)=>{const s=Object.create(At);Ct.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",c=null==t&&e?e.code:t;return St.call(s,a,c,n,r,o),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",i&&Object.assign(s,i),s};function Nt(e){return Ct.isPlainObject(e)||Ct.isArray(e)}function Rt(e){return Ct.endsWith(e,"[]")?e.slice(0,-2):e}function Bt(e,t,n){return e?e.concat(t).map(function(e,t){return e=Rt(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Tt=Ct.toFlatObject(Ct,{},null,function(e){return/^is[A-Z]/.test(e)});function Ot(e,t,n){if(!Ct.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Ct.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Ct.isUndefined(t[e])})).metaTokens,o=n.visitor||l,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Ct.isSpecCompliantForm(t);if(!Ct.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Ct.isDate(e))return e.toISOString();if(Ct.isBoolean(e))return e.toString();if(!a&&Ct.isBlob(e))throw new St("Blob is not supported. Use a Buffer instead.");return Ct.isArrayBuffer(e)||Ct.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(Ct.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Ct.isArray(e)&&function(e){return Ct.isArray(e)&&!e.some(Nt)}(e)||(Ct.isFileList(e)||Ct.endsWith(n,"[]"))&&(a=Ct.toArray(e)))return n=Rt(n),a.forEach(function(e,r){!Ct.isUndefined(e)&&null!==e&&t.append(!0===s?Bt([n],r,i):null===s?n:n+"[]",c(e))}),!1;return!!Nt(e)||(t.append(Bt(o,n,i),c(e)),!1)}const u=[],d=Object.assign(Tt,{defaultVisitor:l,convertValue:c,isVisitable:Nt});if(!Ct.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Ct.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),Ct.forEach(n,function(n,i){!0===(!(Ct.isUndefined(n)||null===n)&&o.call(t,n,Ct.isString(i)?i.trim():i,r,d))&&e(n,r?r.concat(i):[i])}),u.pop()}}(e),t}function Ft(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Lt(e,t){this._pairs=[],e&&Ot(e,this,t)}const jt=Lt.prototype;function It(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function zt(e,t,n){if(!t)return e;const r=n&&n.encode||It;Ct.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let i;if(i=o?o(t,n):Ct.isURLSearchParams(t)?t.toString():new Lt(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}jt.append=function(e,t){this._pairs.push([e,t])},jt.toString=function(e){const t=e?function(t){return e.call(this,t,Ft)}:Ft;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class Pt{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ct.forEach(this.handlers,function(t){null!==t&&e(t)})}}var Mt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Dt={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Lt,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Ut="undefined"!=typeof window&&"undefined"!=typeof document,qt="object"==typeof navigator&&navigator||void 0,Ht=Ut&&(!qt||["ReactNative","NativeScript","NS"].indexOf(qt.product)<0),Wt="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Vt=Ut&&window.location.href||"http://localhost";var Kt={...Object.freeze({__proto__:null,hasBrowserEnv:Ut,hasStandardBrowserEnv:Ht,hasStandardBrowserWebWorkerEnv:Wt,navigator:qt,origin:Vt}),...Dt};function Gt(e){function t(e,n,r,o){let i=e[o++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=o>=e.length;if(i=!i&&Ct.isArray(r)?r.length:i,a)return Ct.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!s;r[i]&&Ct.isObject(r[i])||(r[i]=[]);return t(e,n,r[i],o)&&Ct.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}(r[i])),!s}if(Ct.isFormData(e)&&Ct.isFunction(e.entries)){const n={};return Ct.forEachEntry(e,(e,r)=>{t(function(e){return Ct.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const Yt={transitional:Mt,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=Ct.isObject(e);o&&Ct.isHTMLForm(e)&&(e=new FormData(e));if(Ct.isFormData(e))return r?JSON.stringify(Gt(e)):e;if(Ct.isArrayBuffer(e)||Ct.isBuffer(e)||Ct.isStream(e)||Ct.isFile(e)||Ct.isBlob(e)||Ct.isReadableStream(e))return e;if(Ct.isArrayBufferView(e))return e.buffer;if(Ct.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Ot(e,new Kt.classes.URLSearchParams,{visitor:function(e,t,n,r){return Kt.isNode&&Ct.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((i=Ct.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Ot(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(Ct.isString(e))try{return(t||JSON.parse)(e),Ct.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Yt.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Ct.isResponse(e)||Ct.isReadableStream(e))return e;if(e&&Ct.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw St.from(e,St.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Kt.classes.FormData,Blob:Kt.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ct.forEach(["delete","get","head","post","put","patch"],e=>{Yt.headers[e]={}});const Jt=Ct.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const $t=Symbol("internals");function Xt(e){return e&&String(e).trim().toLowerCase()}function Qt(e){return!1===e||null==e?e:Ct.isArray(e)?e.map(Qt):String(e)}function Zt(e,t,n,r,o){return Ct.isFunction(r)?r.call(this,t,n):(o&&(t=n),Ct.isString(t)?Ct.isString(r)?-1!==t.indexOf(r):Ct.isRegExp(r)?r.test(t):void 0:void 0)}let en=class{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Xt(t);if(!o)throw new Error("header name must be a non-empty string");const i=Ct.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=Qt(e))}const i=(e,t)=>Ct.forEach(e,(e,n)=>o(e,n,t));if(Ct.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(Ct.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Jt[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(Ct.isObject(e)&&Ct.isIterable(e)){let n,r,o={};for(const t of e){if(!Ct.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?Ct.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}i(o,t)}else null!=e&&o(t,e,n);return this}get(e,t){if(e=Xt(e)){const n=Ct.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Ct.isFunction(t))return t.call(this,e,n);if(Ct.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Xt(e)){const n=Ct.findKey(this,e);return!(!n||void 0===this[n]||t&&!Zt(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Xt(e)){const o=Ct.findKey(n,e);!o||t&&!Zt(0,n[o],o,t)||(delete n[o],r=!0)}}return Ct.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!Zt(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return Ct.forEach(this,(r,o)=>{const i=Ct.findKey(n,o);if(i)return t[i]=Qt(r),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();s!==o&&delete t[o],t[s]=Qt(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ct.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Ct.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[$t]=this[$t]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Xt(e);t[r]||(!function(e,t){const n=Ct.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return Ct.isArray(e)?e.forEach(r):r(e),this}};function tn(e,t){const n=this||Yt,r=t||n,o=en.from(r.headers);let i=r.data;return Ct.forEach(e,function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function nn(e){return!(!e||!e.__CANCEL__)}function rn(e,t,n){St.call(this,null==e?"canceled":e,St.ERR_CANCELED,t,n),this.name="CanceledError"}function on(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new St("Request failed with status code "+n.status,[St.ERR_BAD_REQUEST,St.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}en.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ct.reduceDescriptors(en.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Ct.freezeMethods(en),Ct.inherits(rn,St,{__CANCEL__:!0});const sn=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=r[s];o||(o=c),n[i]=a,r[i]=c;let u=s,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),c-o<t)return;const p=l&&c-l;return p?Math.round(1e3*d/p):void 0}}(50,250);return function(e,t){let n,r,o=0,i=1e3/t;const s=(t,i=Date.now())=>{o=i,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=i?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},i-a)))},()=>n&&s(n)]}(n=>{const i=n.loaded,s=n.lengthComputable?n.total:void 0,a=i-r,c=o(a);r=i;e({loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&i<=s?(s-i)/c:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},an=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},cn=e=>(...t)=>Ct.asap(()=>e(...t));var ln=Kt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Kt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Kt.origin),Kt.navigator&&/(msie|trident)/i.test(Kt.navigator.userAgent)):()=>!0,un=Kt.hasStandardBrowserEnv?{write(e,t,n,r,o,i,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Ct.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),Ct.isString(r)&&a.push(`path=${r}`),Ct.isString(o)&&a.push(`domain=${o}`),!0===i&&a.push("secure"),Ct.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function dn(e,t,n){let r=!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const pn=e=>e instanceof en?{...e}:e;function hn(e,t){t=t||{};const n={};function r(e,t,n,r){return Ct.isPlainObject(e)&&Ct.isPlainObject(t)?Ct.merge.call({caseless:r},e,t):Ct.isPlainObject(t)?Ct.merge({},t):Ct.isArray(t)?t.slice():t}function o(e,t,n,o){return Ct.isUndefined(t)?Ct.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function i(e,t){if(!Ct.isUndefined(t))return r(void 0,t)}function s(e,t){return Ct.isUndefined(t)?Ct.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}const c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>o(pn(e),pn(t),0,!0)};return Ct.forEach(Object.keys({...e,...t}),function(r){const i=c[r]||o,s=i(e[r],t[r],r);Ct.isUndefined(s)&&i!==a||(n[r]=s)}),n}var mn=e=>{const t=hn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=en.from(s),t.url=zt(dn(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Ct.isFormData(n))if(Kt.hasStandardBrowserEnv||Kt.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Ct.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(Kt.hasStandardBrowserEnv&&(r&&Ct.isFunction(r)&&(r=r(t)),r||!1!==r&&ln(t.url))){const e=o&&i&&un.read(i);e&&s.set(o,e)}return t};var fn="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=mn(e);let o=r.data;const i=en.from(r.headers).normalize();let s,a,c,l,u,{responseType:d,onUploadProgress:p,onDownloadProgress:h}=r;function m(){l&&l(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let f=new XMLHttpRequest;function g(){if(!f)return;const r=en.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());on(function(e){t(e),m()},function(e){n(e),m()},{data:d&&"text"!==d&&"json"!==d?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:r,config:e,request:f}),f=null}f.open(r.method.toUpperCase(),r.url,!0),f.timeout=r.timeout,"onloadend"in f?f.onloadend=g:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(g)},f.onabort=function(){f&&(n(new St("Request aborted",St.ECONNABORTED,e,f)),f=null)},f.onerror=function(t){const r=new St(t&&t.message?t.message:"Network Error",St.ERR_NETWORK,e,f);r.event=t||null,n(r),f=null},f.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||Mt;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new St(t,o.clarifyTimeoutError?St.ETIMEDOUT:St.ECONNABORTED,e,f)),f=null},void 0===o&&i.setContentType(null),"setRequestHeader"in f&&Ct.forEach(i.toJSON(),function(e,t){f.setRequestHeader(t,e)}),Ct.isUndefined(r.withCredentials)||(f.withCredentials=!!r.withCredentials),d&&"json"!==d&&(f.responseType=r.responseType),h&&([c,u]=sn(h,!0),f.addEventListener("progress",c)),p&&f.upload&&([a,l]=sn(p),f.upload.addEventListener("progress",a),f.upload.addEventListener("loadend",l)),(r.cancelToken||r.signal)&&(s=t=>{f&&(n(!t||t.type?new rn(null,e,f):t),f.abort(),f=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===Kt.protocols.indexOf(y)?n(new St("Unsupported protocol "+y+":",St.ERR_BAD_REQUEST,e)):f.send(o||null)})};const gn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof St?t:new rn(t instanceof Error?t.message:t))}};let i=t&&setTimeout(()=>{i=null,o(new St(`timeout ${t} of ms exceeded`,St.ETIMEDOUT))},t);const s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=()=>Ct.asap(s),a}},yn=function*(e,t){let n=e.byteLength;if(n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},bn=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},xn=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of bn(e))yield*yn(n,t)}(e,t);let i,s=0,a=e=>{i||(i=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return a(),void e.close();let i=r.byteLength;if(n){let e=s+=i;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},{isFunction:vn}=Ct,En=(({Request:e,Response:t})=>({Request:e,Response:t}))(Ct.global),{ReadableStream:wn,TextEncoder:kn}=Ct.global,Cn=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Sn=e=>{e=Ct.merge.call({skipUndefined:!0},En,e);const{fetch:t,Request:n,Response:r}=e,o=t?vn(t):"function"==typeof fetch,i=vn(n),s=vn(r);if(!o)return!1;const a=o&&vn(wn),c=o&&("function"==typeof kn?(l=new kn,e=>l.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var l;const u=i&&a&&Cn(()=>{let e=!1;const t=new n(Kt.origin,{body:new wn,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),d=s&&a&&Cn(()=>Ct.isReadableStream(new r("").body)),p={stream:d&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!p[e]&&(p[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new St(`Response type '${e}' is not supported`,St.ERR_NOT_SUPPORT,n)})});const h=async(e,t)=>{const r=Ct.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Ct.isBlob(e))return e.size;if(Ct.isSpecCompliantForm(e)){const t=new n(Kt.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ct.isArrayBufferView(e)||Ct.isArrayBuffer(e)?e.byteLength:(Ct.isURLSearchParams(e)&&(e+=""),Ct.isString(e)?(await c(e)).byteLength:void 0)})(t):r};return async e=>{let{url:o,method:s,data:a,signal:c,cancelToken:l,timeout:m,onDownloadProgress:f,onUploadProgress:g,responseType:y,headers:b,withCredentials:x="same-origin",fetchOptions:v}=mn(e),E=t||fetch;y=y?(y+"").toLowerCase():"text";let w=gn([c,l&&l.toAbortSignal()],m),k=null;const C=w&&w.unsubscribe&&(()=>{w.unsubscribe()});let S;try{if(g&&u&&"get"!==s&&"head"!==s&&0!==(S=await h(b,a))){let e,t=new n(o,{method:"POST",body:a,duplex:"half"});if(Ct.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,n]=an(S,sn(cn(g)));a=xn(t.body,65536,e,n)}}Ct.isString(x)||(x=x?"include":"omit");const t=i&&"credentials"in n.prototype,c={...v,signal:w,method:s.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:t?x:void 0};k=i&&new n(o,c);let l=await(i?E(k,v):E(o,c));const m=d&&("stream"===y||"response"===y);if(d&&(f||m&&C)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=l[t]});const t=Ct.toFiniteNumber(l.headers.get("content-length")),[n,o]=f&&an(t,sn(cn(f),!0))||[];l=new r(xn(l.body,65536,n,()=>{o&&o(),C&&C()}),e)}y=y||"text";let A=await p[Ct.findKey(p,y)||"text"](l,e);return!m&&C&&C(),await new Promise((t,n)=>{on(t,n,{data:A,headers:en.from(l.headers),status:l.status,statusText:l.statusText,config:e,request:k})})}catch(t){if(C&&C(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new St("Network Error",St.ERR_NETWORK,e,k),{cause:t.cause||t});throw St.from(t,t&&t.code,e,k)}}},An=new Map,_n=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:o}=t,i=[r,o,n];let s,a,c=i.length,l=An;for(;c--;)s=i[c],a=l.get(s),void 0===a&&l.set(s,a=c?new Map:Sn(t)),l=a;return a};_n();const Nn={http:null,xhr:fn,fetch:{get:_n}};Ct.forEach(Nn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Rn=e=>`- ${e}`,Bn=e=>Ct.isFunction(e)||null===e||!1===e;var Tn={getAdapter:function(e,t){e=Ct.isArray(e)?e:[e];const{length:n}=e;let r,o;const i={};for(let s=0;s<n;s++){let n;if(r=e[s],o=r,!Bn(r)&&(o=Nn[(n=String(r)).toLowerCase()],void 0===o))throw new St(`Unknown adapter '${n}'`);if(o&&(Ct.isFunction(o)||(o=o.get(t))))break;i[n||"#"+s]=o}if(!o){const e=Object.entries(i).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new St("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(Rn).join("\n"):" "+Rn(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return o},adapters:Nn};function On(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new rn(null,e)}function Fn(e){On(e),e.headers=en.from(e.headers),e.data=tn.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Tn.getAdapter(e.adapter||Yt.adapter,e)(e).then(function(t){return On(e),t.data=tn.call(e,e.transformResponse,t),t.headers=en.from(t.headers),t},function(t){return nn(t)||(On(e),t&&t.response&&(t.response.data=tn.call(e,e.transformResponse,t.response),t.response.headers=en.from(t.response.headers))),Promise.reject(t)})}const Ln="1.13.2",jn={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{jn[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const In={};jn.transitional=function(e,t,n){function r(e,t){return"[Axios v"+Ln+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,i)=>{if(!1===e)throw new St(r(o," has been removed"+(t?" in "+t:"")),St.ERR_DEPRECATED);return t&&!In[o]&&(In[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}},jn.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var zn={assertOptions:function(e,t,n){if("object"!=typeof e)throw new St("options must be an object",St.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],s=t[i];if(s){const t=e[i],n=void 0===t||s(t,i,e);if(!0!==n)throw new St("option "+i+" must be "+n,St.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new St("Unknown option "+i,St.ERR_BAD_OPTION)}},validators:jn};const Pn=zn.validators;let Mn=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Pt,response:new Pt}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=hn(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&zn.assertOptions(n,{silentJSONParsing:Pn.transitional(Pn.boolean),forcedJSONParsing:Pn.transitional(Pn.boolean),clarifyTimeoutError:Pn.transitional(Pn.boolean)},!1),null!=r&&(Ct.isFunction(r)?t.paramsSerializer={serialize:r}:zn.assertOptions(r,{encode:Pn.function,serialize:Pn.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),zn.assertOptions(t,{baseUrl:Pn.spelling("baseURL"),withXsrfToken:Pn.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&Ct.merge(o.common,o[t.method]);o&&Ct.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=en.concat(i,o);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const c=[];let l;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let u,d=0;if(!a){const e=[Fn.bind(this),void 0];for(e.unshift(...s),e.push(...c),u=e.length,l=Promise.resolve(t);d<u;)l=l.then(e[d++],e[d++]);return l}u=s.length;let p=t;for(;d<u;){const e=s[d++],t=s[d++];try{p=e(p)}catch(e){t.call(this,e);break}}try{l=Fn.call(this,p)}catch(e){return Promise.reject(e)}for(d=0,u=c.length;d<u;)l=l.then(c[d++],c[d++]);return l}getUri(e){return zt(dn((e=hn(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Ct.forEach(["delete","get","head","options"],function(e){Mn.prototype[e]=function(t,n){return this.request(hn(n||{},{method:e,url:t,data:(n||{}).data}))}}),Ct.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(hn(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Mn.prototype[e]=t(),Mn.prototype[e+"Form"]=t(!0)});const Dn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Dn).forEach(([e,t])=>{Dn[t]=e});const Un=function e(t){const n=new Mn(t),r=je(Mn.prototype.request,n);return Ct.extend(r,Mn.prototype,n,{allOwnKeys:!0}),Ct.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(hn(t,n))},r}(Yt);Un.Axios=Mn,Un.CanceledError=rn,Un.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new rn(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},Un.isCancel=nn,Un.VERSION=Ln,Un.toFormData=Ot,Un.AxiosError=St,Un.Cancel=Un.CanceledError,Un.all=function(e){return Promise.all(e)},Un.spread=function(e){return function(t){return e.apply(null,t)}},Un.isAxiosError=function(e){return Ct.isObject(e)&&!0===e.isAxiosError},Un.mergeConfig=hn,Un.AxiosHeaders=en,Un.formToJSON=e=>Gt(Ct.isHTMLForm(e)?new FormData(e):e),Un.getAdapter=Tn.getAdapter,Un.HttpStatusCode=Dn,Un.default=Un;const{Axios:qn,AxiosError:Hn,CanceledError:Wn,isCancel:Vn,CancelToken:Kn,VERSION:Gn,all:Yn,Cancel:Jn,isAxiosError:$n,spread:Xn,toFormData:Qn,AxiosHeaders:Zn,HttpStatusCode:er,formToJSON:tr,getAdapter:nr,mergeConfig:rr}=Un;var or=function(t){var n=t.apiKey,o=t.apiUrl,i=t.primaryColor,s=void 0===i?"#4F46E5":i,l=t.userData,p=void 0===l?null:l,h=t.theme,m=void 0===h?"light":h,f=t.onClose,g=u(e.useState("create"),2),y=g[0],b=g[1],x=u(e.useState([]),2),v=x[0],E=x[1],w=u(e.useState(null),2),k=w[0],C=w[1],S=u(e.useState([]),2),A=S[0],_=S[1],N=u(e.useState(!1),2),R=N[0],B=N[1],T=u(e.useState(""),2),O=T[0],F=T[1],L=u(e.useState(""),2),j=L[0],I=L[1],z=u(e.useState([]),2),P=z[0],M=z[1],D=u(e.useState(null),2),U=D[0],q=D[1],H=u(e.useState(!1),2);H[0],H[1];var W=u(e.useState(""),2);W[0],W[1];var V=u(e.useState("success"),2);V[0],V[1];var K=u(e.useState([]),2),G=K[0],Y=K[1],J=e.useRef(null),$=e.useRef(null),X=u(e.useState({subject:"",message:"",htmlMessage:"",priority:"medium",category:"general",attachments:[]}),2),Q=X[0],Z=X[1],ee="dark"===m||"auto"===m&&window.matchMedia("(prefers-color-scheme: dark)").matches,te=function(e){q(e),setTimeout(function(){return q(null)},4e3)},ne=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"success",n=Date.now(),r={id:n,message:e,type:t};Y(function(e){return[].concat(d(e),[r])}),setTimeout(function(){Y(function(e){return e.filter(function(e){return e.id!==n})})},4e3)},re=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;document.execCommand(e,!1,n),null===(t=$.current)||void 0===t||t.focus()},oe=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Array.from(e.target.files),r=t?P.length:Q.attachments.length;if(r+n.length>10)return te("You can only select up to 10 files total. You have ".concat(r," files already selected and are trying to add ").concat(n.length," more.")),void(e.target.value="");var o=n.filter(function(e){return e.size<=10485760?!!["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/svg+xml","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel.sheet.macroEnabled.12","text/csv","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/rtf","application/rtf","application/zip","application/x-zip-compressed","application/x-rar-compressed","application/x-7z-compressed"].includes(e.type)||(te('File "'.concat(e.name,'" is not supported. Allowed: Images, PDF, Word, Excel, PowerPoint, Text files, Archives (ZIP, RAR, 7Z).')),!1):(te('File "'.concat(e.name,'" is too large. Maximum size is 10MB per file.')),!1)});t?M(function(e){return[].concat(d(e),d(o))}):Z(function(e){return a(a({},e),{},{attachments:[].concat(d(e.attachments),d(o))})}),e.target.value=""},ie=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?M(function(t){return t.filter(function(t,n){return n!==e})}):Z(function(t){return a(a({},t),{},{attachments:t.attachments.filter(function(t,n){return n!==e})})})};e.useEffect(function(){"create"===y||k||se()},[y]),e.useEffect(function(){k?(_([]),ae(k.ticketId)):_([])},[k]);var se=function(){var e=r(c().m(function e(){var t,r,i;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(B(!0),e.p=1,(t=p||{email:localStorage.getItem("chatGuestEmail"),name:localStorage.getItem("chatGuestName")}).email){e.n=2;break}return console.error("No customer email available"),ne("Please provide your email to view tickets","error"),B(!1),e.a(2);case 2:return e.n=3,Un.get("".concat(o,"/api/v1/email-ticketing/tickets"),{headers:{"x-api-key":n},params:{status:"all",customerEmail:t.email},timeout:3e4});case 3:(r=e.v).data.success&&E(r.data.data.tickets||[]),e.n=5;break;case 4:e.p=4,i=e.v,console.error("Error fetching tickets:",i),ne("Failed to load tickets","error");case 5:return e.p=5,B(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),ae=function(){var e=r(c().m(function e(t){var r,i,s,a;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return B(!0),e.p=1,r=p||{email:localStorage.getItem("chatGuestEmail")||"guest@example.com",name:localStorage.getItem("chatGuestName")||"Guest User"},console.log("Fetching messages for ticket:",t,"user:",r.email),e.n=2,Un.get("".concat(o,"/api/v1/email-ticketing/tickets/").concat(t,"/messages"),{headers:{"x-api-key":n},params:{customerEmail:r.email},timeout:3e4});case 2:i=e.v,console.log("Messages response:",i.data),i.data.success&&(_(i.data.messages||[]),console.log("Set messages:",(null===(s=i.data.messages)||void 0===s?void 0:s.length)||0)),e.n=4;break;case 3:e.p=3,a=e.v,console.error("Error fetching messages:",a),_([]);case 4:return e.p=4,B(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(t){return e.apply(this,arguments)}}(),ce=function(){var e=r(c().m(function e(t){var r,i,s,a,l,u;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),B(!0),e.p=1,(r=p||{email:localStorage.getItem("chatGuestEmail"),name:localStorage.getItem("chatGuestName")||"Guest User"}).email){e.n=2;break}return ne("β You can't raise ticket without login","error"),B(!1),e.a(2);case 2:return(i=r.email)&&"guest@example.com"!==i&&localStorage.setItem("chatGuestEmail",i),(s=new FormData).append("subject",Q.subject),s.append("message",Q.message),s.append("html",Q.htmlMessage),s.append("priority",Q.priority),s.append("category",Q.category),s.append("customerEmail",i),s.append("customerName",r.name),Q.attachments.forEach(function(e){s.append("attachments",e)}),e.n=3,Un.post("".concat(o,"/api/v1/email-ticketing/tickets"),s,{headers:{"x-api-key":n},timeout:3e4});case 3:a=e.v,console.log("Ticket creation response:",a.data),a.data.success&&(ne("β
Ticket created successfully!","success"),Z({subject:"",message:"",htmlMessage:"",priority:"medium",category:"general",attachments:[]}),$.current&&($.current.innerHTML=""),b("myTickets")),e.n=5;break;case 4:e.p=4,u=e.v,console.error("Error creating ticket:",u),"ECONNABORTED"===u.code?ne("β±οΈ Server timeout. The server may be waking up. Please wait a moment and try again.","error"):u.response?ne("β Failed to create ticket: ".concat((null===(l=u.response.data)||void 0===l?void 0:l.message)||"Server error"),"error"):u.request?ne("β Cannot reach server. Please check your connection or try again later.","error"):ne("β Failed to create ticket. Please try again.","error");case 5:return e.p=5,B(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),le=function(){var e=r(c().m(function e(t){var r,i,s,a;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),O.trim()||0!==P.length){e.n=1;break}return e.a(2);case 1:return B(!0),e.p=2,r=p||{email:localStorage.getItem("chatGuestEmail"),name:localStorage.getItem("chatGuestName")},(i=new FormData).append("ticketId",k.ticketId),i.append("message",O),i.append("html",j),i.append("senderType","customer"),i.append("customerEmail",r.email),P.forEach(function(e){i.append("attachments",e)}),e.n=3,Un.post("".concat(o,"/api/v1/email-ticketing/tickets/widget/reply"),i,{headers:{"x-api-key":n},timeout:3e4});case 3:e.v.data.success&&(ne("β
Reply sent successfully!","success"),F(""),I(""),M([]),$.current&&($.current.innerHTML=""),setTimeout(function(){ae(k.ticketId)},500)),e.n=5;break;case 4:e.p=4,a=e.v,console.error("Error sending reply:",a),"ECONNABORTED"===a.code?ne("β±οΈ Request timeout. Server may be starting up. Please try again in 30 seconds.","error"):a.response?ne("β Failed to send reply: ".concat((null===(s=a.response.data)||void 0===s?void 0:s.message)||"Server error"),"error"):a.request?ne("β Cannot reach server. Please check your connection.","error"):ne("β Failed to send reply. Please try again.","error");case 5:return e.p=5,B(!1),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ue=function(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},de=function(e){switch(e){case"open":return"#10B981";case"pending":return"#F59E0B";default:return"#6B7280"}},pe=function(e){switch(e){case"high":return"#EF4444";case"medium":return"#F59E0B";case"low":return"#10B981";default:return"#6B7280"}},he=function(t){return t.startsWith("image/")?e.createElement("svg",{style:{width:"20px",height:"20px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})):e.createElement("svg",{style:{width:"20px",height:"20px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"}))},me=function(t){var n=t.onCommand,r=t.showSendButton,o=void 0!==r&&r,i=t.onSend,a=void 0===i?null:i,c=t.isLoading,l=void 0!==c&&c,u=t.canSend,d=void 0!==u&&u;return e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px",borderBottom:ee?"1px solid #374151":"1px solid #E5E7EB",backgroundColor:ee?"#1F2937":"#F9FAFB"}},e.createElement("div",{style:{display:"flex",gap:"4px",alignItems:"center"}},e.createElement("button",{type:"button",onClick:function(){return n("bold")},style:fe,title:"Bold"},e.createElement("strong",null,"B")),e.createElement("button",{type:"button",onClick:function(){return n("italic")},style:fe,title:"Italic"},e.createElement("em",null,"I")),e.createElement("button",{type:"button",onClick:function(){return n("underline")},style:fe,title:"Underline"},e.createElement("u",null,"U")),e.createElement("button",{type:"button",onClick:function(){return n("strikeThrough")},style:fe,title:"Strikethrough"},e.createElement("s",null,"S")),e.createElement("div",{style:{width:"1px",backgroundColor:ee?"#374151":"#E5E7EB",height:"20px",margin:"0 4px"}}),e.createElement("button",{type:"button",onClick:function(){return n("justifyLeft")},style:fe,title:"Align Left"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"}))),e.createElement("button",{type:"button",onClick:function(){return n("justifyCenter")},style:fe,title:"Align Center"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"}))),e.createElement("button",{type:"button",onClick:function(){return n("justifyRight")},style:fe,title:"Align Right"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"}))),e.createElement("div",{style:{width:"1px",backgroundColor:ee?"#374151":"#E5E7EB",height:"20px",margin:"0 4px"}}),e.createElement("button",{type:"button",onClick:function(){return n("insertUnorderedList")},style:fe,title:"Bullet List"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"}))),e.createElement("button",{type:"button",onClick:function(){return n("insertOrderedList")},style:fe,title:"Numbered List"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"}))),e.createElement("div",{style:{width:"1px",backgroundColor:ee?"#374151":"#E5E7EB",height:"20px",margin:"0 4px"}}),e.createElement("button",{type:"button",onClick:function(){return n("indent")},style:fe,title:"Increase Indent"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"}))),e.createElement("button",{type:"button",onClick:function(){return n("outdent")},style:fe,title:"Decrease Indent"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{d:"M3 21h18v-2H3v2zM3 8l4 4 4-4H3zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"}))),e.createElement("div",{style:{width:"1px",backgroundColor:ee?"#374151":"#E5E7EB",height:"20px",margin:"0 4px"}}),e.createElement("button",{type:"button",onClick:function(){return n("insertHorizontalRule")},style:fe,title:"Insert Line"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"}))),e.createElement("button",{type:"button",onClick:function(){var e;return null===(e=J.current)||void 0===e?void 0:e.click()},style:fe,title:"Attach File"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})))),o&&e.createElement("button",{type:"button",onClick:a,disabled:l||!d,style:{padding:"6px 16px",fontSize:"12px",fontWeight:600,color:"#fff",backgroundColor:s,border:"none",borderRadius:"6px",cursor:l||!d?"not-allowed":"pointer",opacity:l||!d?.5:1,display:"flex",alignItems:"center",gap:"4px",transition:"all 0.2s"},title:l?"Sending...":"Send Reply"},l?e.createElement(e.Fragment,null,e.createElement("svg",{style:{width:"12px",height:"12px",animation:"spin 1s linear infinite"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})),"Sending..."):e.createElement(e.Fragment,null,e.createElement("svg",{style:{width:"12px",height:"12px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})),"Send")))},fe={background:"none",border:"none",padding:"6px 10px",borderRadius:"4px",cursor:"pointer",color:ee?"#F9FAFB":"#111827",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"};return e.createElement(e.Fragment,null,e.createElement("style",null,"\n .ticket-message-content ul,\n .ticket-message-content ol {\n margin-left: 1.5rem;\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n }\n .ticket-message-content ul {\n list-style-type: disc;\n }\n .ticket-message-content ol {\n list-style-type: decimal;\n }\n .ticket-message-content li {\n margin-bottom: 0.25rem;\n }\n .ticket-editor[contenteditable] {\n max-width: 100%;\n word-break: break-word;\n overflow-wrap: break-word;\n }\n .ticket-editor ul,\n .ticket-editor ol {\n margin-left: 1.5rem;\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n }\n .ticket-editor ul {\n list-style-type: disc;\n }\n .ticket-editor ol {\n list-style-type: decimal;\n }\n .ticket-editor li {\n margin-bottom: 0.25rem;\n }\n .ticket-editor:empty:before {\n content: attr(placeholder);\n color: #9CA3AF;\n pointer-events: none;\n }\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n @keyframes modalAppear {\n from { \n transform: scale(0.9);\n opacity: 0;\n }\n to { \n transform: scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromRight {\n from {\n transform: translateX(100%);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n }\n @keyframes slideOutToRight {\n from {\n transform: translateX(0);\n opacity: 1;\n }\n to {\n transform: translateX(100%);\n opacity: 0;\n }\n }\n "),e.createElement("div",{style:{position:"fixed",inset:0,backgroundColor:ee?"#111827":"#F9FAFB",zIndex:999999,display:"flex",flexDirection:"column",overflow:"hidden"}},e.createElement("div",{style:{backgroundColor:ee?"#1F2937":"#fff",borderBottom:ee?"1px solid #374151":"1px solid #E5E7EB",padding:"8px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"}},e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},e.createElement("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:s,display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("svg",{style:{width:"20px",height:"20px",color:"#fff"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"}))),e.createElement("div",null,e.createElement("h1",{style:{margin:0,fontSize:"20px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"Support Tickets"),e.createElement("p",{style:{margin:"2px 0 0 0",fontSize:"13px",color:ee?"#9CA3AF":"#6B7280"}},"Manage your support requests"))),e.createElement("button",{onClick:f,style:{background:"none",border:"none",cursor:"pointer",padding:"8px",borderRadius:"8px",display:"flex",color:ee?"#9CA3AF":"#6B7280"}},e.createElement("svg",{style:{width:"24px",height:"24px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),e.createElement("div",{style:{flex:1,display:"flex",overflow:"hidden"}},e.createElement("div",{style:{width:"200px",backgroundColor:ee?"#1F2937":"#fff",borderRight:ee?"1px solid #374151":"1px solid #E5E7EB",display:"flex",flexDirection:"column",padding:"16px 0"}},e.createElement("button",{onClick:function(){b("create"),C(null)},style:{padding:"12px 20px",border:"none",backgroundColor:"create"===y?"".concat(s,"15"):"transparent",cursor:"pointer",fontSize:"14px",fontWeight:500,color:"create"===y?s:ee?"#D1D5DB":"#6B7280",textAlign:"left",borderLeft:"create"===y?"3px solid ".concat(s):"3px solid transparent",transition:"all 0.2s"}},"Create Ticket"),e.createElement("button",{onClick:function(){b("myTickets"),C(null)},style:{padding:"12px 20px",border:"none",backgroundColor:"myTickets"===y?"".concat(s,"15"):"transparent",cursor:"pointer",fontSize:"14px",fontWeight:500,color:"myTickets"===y?s:ee?"#D1D5DB":"#6B7280",textAlign:"left",borderLeft:"myTickets"===y?"3px solid ".concat(s):"3px solid transparent",transition:"all 0.2s"}},"My Tickets")),e.createElement("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},"create"===y&&e.createElement("div",{style:{flex:1,overflow:"auto",padding:"24px"}},e.createElement("div",{style:{maxWidth:"800px",margin:"0 auto"}},null!=p&&p.email||localStorage.getItem("chatGuestEmail")?e.createElement("div",{style:{backgroundColor:ee?"#1F2937":"#fff",borderRadius:"12px",padding:"24px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:ee?"1px solid #374151":"1px solid #E5E7EB"}},e.createElement("h2",{style:{margin:"0 0 16px 0",fontSize:"18px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"Create New Support Ticket"),e.createElement("form",{onSubmit:ce},e.createElement("div",{style:{marginBottom:"16px"}},e.createElement("label",{style:{display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:ee?"#F9FAFB":"#111827"}},"Subject *"),e.createElement("input",{type:"text",name:"subject",value:Q.subject,onChange:function(e){return Z(function(t){return a(a({},t),{},{subject:e.target.value})})},required:!0,placeholder:"Brief description of your issue",style:{width:"100%",padding:"10px 12px",fontSize:"14px",borderRadius:"8px",border:ee?"1px solid #374151":"1px solid #D1D5DB",backgroundColor:ee?"#111827":"#fff",color:ee?"#F9FAFB":"#111827",outline:"none"}})),e.createElement("div",{style:{marginBottom:"16px"}},e.createElement("label",{style:{display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:ee?"#F9FAFB":"#111827"}},"Description *"),e.createElement("div",{style:{border:ee?"1px solid #374151":"1px solid #D1D5DB",borderRadius:"8px",overflow:"hidden"}},e.createElement(me,{onCommand:re}),e.createElement("div",{ref:$,className:"ticket-editor",contentEditable:!0,onInput:function(e){var t=e.target.innerHTML,n=e.target.innerText;Z(function(e){return a(a({},e),{},{htmlMessage:t,message:n})})},placeholder:"Provide detailed information about your issue...",style:{minHeight:"150px",maxHeight:"300px",overflowY:"auto",padding:"12px",fontSize:"14px",color:ee?"#F9FAFB":"#111827",backgroundColor:ee?"#111827":"#fff",outline:"none"}}),e.createElement("input",{ref:J,type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.xlsm,.csv,.ppt,.pptx,.txt,.rtf,.zip,.rar,.7z",onChange:function(e){return oe(e,!1)},style:{display:"none"}}),Q.attachments.length>0&&e.createElement("div",{style:{padding:"8px 12px",borderTop:ee?"1px solid #374151":"1px solid #E5E7EB",display:"flex",flexWrap:"wrap",gap:"8px"}},Q.attachments.map(function(t,n){return e.createElement("div",{key:n,style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"6px",backgroundColor:ee?"#374151":"#F3F4F6",fontSize:"12px",color:ee?"#F9FAFB":"#111827"}},he(t.type),e.createElement("span",null,t.name),e.createElement("button",{type:"button",onClick:function(){return ie(n,!1)},style:{background:"none",border:"none",cursor:"pointer",padding:"2px",color:"#EF4444"}},"Γ"))})))),e.createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",marginBottom:"20px"}},e.createElement("div",null,e.createElement("label",{style:{display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:ee?"#F9FAFB":"#111827"}},"Priority"),e.createElement("select",{value:Q.priority,onChange:function(e){return Z(function(t){return a(a({},t),{},{priority:e.target.value})})},style:{width:"100%",padding:"10px 12px",fontSize:"14px",borderRadius:"8px",border:ee?"1px solid #374151":"1px solid #D1D5DB",backgroundColor:ee?"#111827":"#fff",color:ee?"#F9FAFB":"#111827"}},e.createElement("option",{value:"low"},"Low"),e.createElement("option",{value:"medium"},"Medium"),e.createElement("option",{value:"high"},"High"))),e.createElement("div",null,e.createElement("label",{style:{display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:ee?"#F9FAFB":"#111827"}},"Category"),e.createElement("select",{value:Q.category,onChange:function(e){return Z(function(t){return a(a({},t),{},{category:e.target.value})})},style:{width:"100%",padding:"10px 12px",fontSize:"14px",borderRadius:"8px",border:ee?"1px solid #374151":"1px solid #D1D5DB",backgroundColor:ee?"#111827":"#fff",color:ee?"#F9FAFB":"#111827"}},e.createElement("option",{value:"general"},"General"),e.createElement("option",{value:"technical"},"Technical Issue"),e.createElement("option",{value:"billing"},"Billing"),e.createElement("option",{value:"feature"},"Feature Request"),e.createElement("option",{value:"bug"},"Bug Report")))),e.createElement("button",{type:"submit",disabled:R||!Q.subject||!Q.message,style:{width:"100%",padding:"12px 24px",fontSize:"14px",fontWeight:600,color:"#fff",backgroundColor:s,border:"none",borderRadius:"8px",cursor:R?"not-allowed":"pointer",opacity:!R&&Q.subject&&Q.message?1:.5}},R?"Creating Ticket...":"Submit Ticket"))):e.createElement("div",{style:{backgroundColor:ee?"#1F2937":"#fff",borderRadius:"12px",padding:"48px 24px",textAlign:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:ee?"1px solid #374151":"1px solid #E5E7EB"}},e.createElement("div",{style:{width:"80px",height:"80px",margin:"0 auto 24px",borderRadius:"50%",backgroundColor:"#FEE2E2",display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("svg",{style:{width:"40px",height:"40px",color:"#EF4444"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"}))),e.createElement("h2",{style:{margin:"0 0 12px 0",fontSize:"20px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"Login Required"),e.createElement("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:ee?"#9CA3AF":"#6B7280",lineHeight:"1.5"}},"You can't raise ticket without login. Please login to your account to create support tickets.")))),"myTickets"===y&&e.createElement("div",{style:{flex:1,display:"flex",overflow:"hidden"}},e.createElement("div",{style:{width:"320px",borderRight:ee?"1px solid #374151":"1px solid #E5E7EB",backgroundColor:ee?"#1F2937":"#F9FAFB",display:"flex",flexDirection:"column",overflow:"hidden"}},e.createElement("div",{style:{padding:"16px",borderBottom:ee?"1px solid #374151":"1px solid #E5E7EB",flexShrink:0}},e.createElement("h3",{style:{margin:0,fontSize:"14px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"My Tickets")),e.createElement("div",{style:{flex:1,overflow:"auto"}},R?e.createElement("div",{style:{textAlign:"center",padding:"40px",color:ee?"#9CA3AF":"#6B7280"}},"Loading tickets..."):0===v.length?e.createElement("div",{style:{textAlign:"center",padding:"40px"}},e.createElement("p",{style:{margin:0,fontSize:"14px",color:ee?"#9CA3AF":"#6B7280"}},"No tickets found")):e.createElement("div",{style:{padding:"8px"}},v.map(function(t){var n=t.hasUnreadMessages||t.lastActivityAt&&new Date(t.lastActivityAt)>new Date(t.lastViewedAt||0),r=k&&k._id===t._id;return e.createElement("div",{key:t._id,onClick:function(){return C(t)},style:{padding:"12px",marginBottom:"8px",borderRadius:"8px",cursor:"pointer",backgroundColor:r?ee?"#374151":"#fff":ee?"#1F2937":"#fff",border:r?"2px solid ".concat(s):n?"2px solid ".concat(s,"40"):ee?"1px solid #374151":"1px solid #E5E7EB",transition:"all 0.2s",position:"relative"}},n&&e.createElement("div",{style:{position:"absolute",top:"8px",right:"8px",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"#EF4444"}}),e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}},e.createElement("h4",{style:{margin:0,fontSize:"13px",fontWeight:r?700:600,color:ee?"#F9FAFB":"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1}},t.subject),e.createElement("button",{onClick:function(e){e.stopPropagation(),k&&k._id===t._id?ae(t.ticketId):se()},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",color:ee?"#9CA3AF":"#6B7280",display:"flex",alignItems:"center",opacity:.7,transition:"all 0.2s"},onMouseEnter:function(e){e.target.style.opacity="1",e.target.style.backgroundColor=ee?"#374151":"#F3F4F6"},onMouseLeave:function(e){e.target.style.opacity="0.7",e.target.style.backgroundColor="transparent"},title:"Refresh"},e.createElement("svg",{style:{width:"14px",height:"14px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})))),e.createElement("p",{style:{margin:"0 0 8px 0",fontSize:"11px",color:ee?"#9CA3AF":"#6B7280"}},t.ticketId),e.createElement("p",{style:{margin:"0 0 6px 0",fontSize:"11px",color:ee?"#9CA3AF":"#6B7280"}},ue(t.createdAt)),e.createElement("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap"}},e.createElement("span",{style:{padding:"2px 6px",fontSize:"10px",fontWeight:500,borderRadius:"4px",backgroundColor:"".concat(de(t.status),"20"),color:de(t.status)}},t.status),e.createElement("span",{style:{padding:"2px 6px",fontSize:"10px",fontWeight:500,borderRadius:"4px",backgroundColor:"".concat(pe(t.priority),"20"),color:pe(t.priority)}},t.priority)))})))),k?e.createElement("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},e.createElement("div",{style:{padding:"8px 16px",borderBottom:ee?"1px solid #374151":"1px solid #E5E7EB",backgroundColor:ee?"#1F2937":"#fff"}},e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},e.createElement("div",{style:{flex:1}},e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"2px"}},e.createElement("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},k.subject),e.createElement("span",{style:{padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",backgroundColor:"".concat(de(k.status),"20"),color:de(k.status)}},k.status)),e.createElement("p",{style:{margin:0,fontSize:"13px",color:ee?"#9CA3AF":"#6B7280"}},k.ticketId)),e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},e.createElement("button",{onClick:function(){return ae(k.ticketId)},style:{background:"none",border:"none",cursor:"pointer",padding:"8px",borderRadius:"6px",color:ee?"#9CA3AF":"#6B7280",display:"flex",alignItems:"center",opacity:.8,transition:"all 0.2s"},onMouseEnter:function(e){e.target.style.opacity="1",e.target.style.backgroundColor=ee?"#374151":"#F3F4F6"},onMouseLeave:function(e){e.target.style.opacity="0.8",e.target.style.backgroundColor="transparent"},title:"Refresh conversation"},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"}))),e.createElement("button",{onClick:function(){return C(null)},style:{background:"none",border:"none",cursor:"pointer",padding:"8px",borderRadius:"6px",color:ee?"#9CA3AF":"#6B7280",display:"flex",alignItems:"center",opacity:.8,transition:"all 0.2s"},onMouseEnter:function(e){e.target.style.opacity="1",e.target.style.backgroundColor=ee?"#374151":"#F3F4F6"},onMouseLeave:function(e){e.target.style.opacity="0.8",e.target.style.backgroundColor="transparent"},title:"Close"},e.createElement("svg",{style:{width:"18px",height:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))))),e.createElement("div",{style:{flex:1,overflow:"auto",padding:"16px 24px"}},R?e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px 20px",color:ee?"#9CA3AF":"#6B7280"}},e.createElement("div",{style:{width:"20px",height:"20px",border:"2px solid ".concat(s),borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite",marginRight:"10px"}}),O.trim()||P.length>0?"Sending reply...":"Loading conversation..."):0===A.length?e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px 20px",color:ee?"#9CA3AF":"#6B7280",textAlign:"center"}},"No messages in this conversation yet."):A.map(function(t,n){var i;return e.createElement("div",{key:t._id||n,style:{marginBottom:"16px",width:"100%"}},e.createElement("div",{style:{width:"100%",backgroundColor:"customer"===t.senderType?ee?"#1E3A8A20":"#DBEAFE":ee?"#1F2937":"#F3F4F6",borderRadius:"8px",padding:"12px",border:ee?"customer"===t.senderType?"1px solid #1E40AF":"1px solid #374151":"customer"===t.senderType?"1px solid #93C5FD":"1px solid #E5E7EB"}},e.createElement("div",{style:{fontSize:"12px",color:ee?"#9CA3AF":"#6B7280",marginBottom:"8px",display:"flex",justifyContent:"space-between",alignItems:"center",fontWeight:500}},e.createElement("span",null,"customer"===t.senderType?t.senderName||"You":((null===(i=t.sender)||void 0===i?void 0:i.alias)||t.senderName||"AGENT").toUpperCase()),e.createElement("span",null,ue(t.createdAt))),e.createElement("div",{className:"ticket-message-content",style:{color:ee?"#F9FAFB":"#111827",fontSize:"14px",lineHeight:"1.5",wordBreak:"break-word",overflowWrap:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:t.html||t.message}}),t.attachments&&t.attachments.length>0&&e.createElement("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"}},t.attachments.map(function(t,n){return e.createElement("div",{key:n,style:{border:ee?"1px solid #374151":"1px solid #E5E7EB",borderRadius:"8px",overflow:"hidden"}},e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",backgroundColor:ee?"#111827":"#F9FAFB"}},e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px",flex:1,minWidth:0}},he(t.contentType),e.createElement("span",{style:{fontSize:"12px",color:ee?"#F9FAFB":"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},t.filename),t.size&&e.createElement("span",{style:{color:ee?"#9CA3AF":"#6B7280",fontSize:"12px",flexShrink:0}},"(",(t.size/1024).toFixed(1)," KB)")),e.createElement("button",{onClick:function(){var e=r(c().m(function e(n){var r,i,s,a;return c().w(function(e){for(;;)switch(e.n){case 0:n.preventDefault(),n.stopPropagation();try{r=String(t.filename||"download").replace(/\s+/g,"_").replace(/[^a-zA-Z0-9._-]/g,"_"),t.url&&t.url.includes("cloudinary.com")?(i="".concat(o,"/api/v1/email-ticketing/attachments/download?filename=").concat(encodeURIComponent(r),"&url=").concat(encodeURIComponent(t.url)),(s=document.createElement("a")).href=i,s.rel="noopener",document.body.appendChild(s),s.click(),document.body.removeChild(s)):t.url&&((a=document.createElement("a")).href=t.url,a.download=r,a.rel="noopener",document.body.appendChild(a),a.click(),document.body.removeChild(a))}catch(e){console.error("Download failed:",e),window.open(t.url,"_blank","noopener,noreferrer")}case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),style:{marginLeft:"8px",padding:"4px 8px",fontSize:"12px",backgroundColor:s,color:"#fff",borderRadius:"4px",border:"none",cursor:"pointer",flexShrink:0,transition:"all 0.2s"},onMouseEnter:function(e){return e.target.style.backgroundColor="".concat(s,"dd")},onMouseLeave:function(e){return e.target.style.backgroundColor=s}},"Download")))}))))})),"closed"!==k.status&&e.createElement("div",{style:{borderTop:ee?"1px solid #374151":"1px solid #E5E7EB",backgroundColor:ee?"#1F2937":"#fff",padding:"16px 24px"}},e.createElement("div",{style:{border:ee?"1px solid #374151":"1px solid #E5E7EB",borderRadius:"8px",overflow:"hidden"}},e.createElement(me,{onCommand:re,showSendButton:!0,onSend:function(e){e.preventDefault(),le(e)},isLoading:R,canSend:O.trim()||P.length>0}),e.createElement("div",{ref:$,className:"ticket-editor",contentEditable:!0,onInput:function(e){var t=e.target.innerHTML,n=e.target.innerText;I(t),F(n)},placeholder:"Type your reply...",style:{minHeight:"100px",maxHeight:"200px",overflowY:"auto",padding:"12px",fontSize:"14px",color:ee?"#F9FAFB":"#111827",backgroundColor:ee?"#111827":"#fff",outline:"none"}}),e.createElement("input",{ref:J,type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.xlsm,.csv,.ppt,.pptx,.txt,.rtf,.zip,.rar,.7z",onChange:function(e){return oe(e,!0)},style:{display:"none"}}),P.length>0&&e.createElement("div",{style:{padding:"8px 12px",borderTop:ee?"1px solid #374151":"1px solid #E5E7EB",display:"flex",flexWrap:"wrap",gap:"8px"}},P.map(function(t,n){return e.createElement("div",{key:n,style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"6px",backgroundColor:ee?"#374151":"#F3F4F6",fontSize:"12px",color:ee?"#F9FAFB":"#111827"}},he(t.type),e.createElement("span",null,t.name),e.createElement("button",{type:"button",onClick:function(){return ie(n,!0)},style:{background:"none",border:"none",cursor:"pointer",padding:"2px",color:"#EF4444"}},"Γ"))}))))):e.createElement("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:ee?"#111827":"#F9FAFB"}},e.createElement("div",{style:{textAlign:"center",padding:"40px"}},e.createElement("svg",{style:{width:"64px",height:"64px",margin:"0 auto 16px",color:ee?"#374151":"#D1D5DB"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})),e.createElement("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:600,color:ee?"#F9FAFB":"#111827"}},"Select a ticket"),e.createElement("p",{style:{margin:0,fontSize:"14px",color:ee?"#9CA3AF":"#6B7280"}},"Choose a ticket from the list to view details")))),!1)),U&&e.createElement("div",{style:{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,padding:"20px"}},e.createElement("div",{style:{backgroundColor:ee?"#1f2937":"#ffffff",color:ee?"#f9fafb":"#111827",borderRadius:"16px",padding:"32px 40px",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.3)",maxWidth:"500px",width:"100%",textAlign:"center",border:ee?"1px solid #374151":"1px solid #e5e7eb",position:"relative",transform:"scale(1)",animation:"modalAppear 0.3s ease-out"}},e.createElement("div",{style:{width:"64px",height:"64px",borderRadius:"50%",backgroundColor:"#fef2f2",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 20px",border:"3px solid #fee2e2"}},e.createElement("svg",{style:{width:"32px",height:"32px",color:"#ef4444"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"}))),e.createElement("h3",{style:{color:"#ef4444",fontSize:"20px",fontWeight:"700",marginBottom:"12px",margin:"0 0 12px 0"}},"File Upload Limit Exceeded"),e.createElement("p",{style:{fontSize:"16px",lineHeight:"1.6",color:ee?"#d1d5db":"#6b7280",marginBottom:"24px",margin:"0 0 24px 0"}},U),e.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"center"}},e.createElement("button",{onClick:function(){return q(null)},style:{padding:"12px 32px",backgroundColor:"#ef4444",color:"white",border:"none",borderRadius:"8px",fontSize:"16px",fontWeight:"600",cursor:"pointer",transition:"all 0.2s",boxShadow:"0 4px 12px rgba(239, 68, 68, 0.3)"},onMouseOver:function(e){e.target.style.backgroundColor="#dc2626",e.target.style.transform="translateY(-1px)",e.target.style.boxShadow="0 6px 16px rgba(239, 68, 68, 0.4)"},onMouseOut:function(e){e.target.style.backgroundColor="#ef4444",e.target.style.transform="translateY(0)",e.target.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.3)"}},"Understood")))),G.length>0&&e.createElement("div",{style:{position:"fixed",bottom:"20px",right:"20px",zIndex:10001,display:"flex",flexDirection:"column",gap:"12px",pointerEvents:"none"}},G.map(function(t){return e.createElement("div",{key:t.id,style:{backgroundColor:ee?"#1f2937":"#ffffff",color:ee?"#f9fafb":"#111827",padding:"16px 20px",borderRadius:"12px",boxShadow:"0 8px 25px rgba(0, 0, 0, 0.15)",border:"2px solid ".concat("success"===t.type?"#10b981":"#ef4444"),minWidth:"300px",maxWidth:"400px",animation:"slideInFromRight 0.3s ease-out",display:"flex",alignItems:"center",gap:"12px",pointerEvents:"auto"}},e.createElement("div",{style:{width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"success"===t.type?"#10b981":"#ef4444",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},"success"===t.type?e.createElement("svg",{style:{width:"14px",height:"14px",color:"white"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})):e.createElement("svg",{style:{width:"14px",height:"14px",color:"white"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M6 18L18 6M6 6l12 12"}))),e.createElement("div",{style:{flex:1,fontSize:"14px",fontWeight:"500",lineHeight:"1.4"}},t.message),e.createElement("button",{onClick:function(){return Y(function(e){return e.filter(function(e){return e.id!==t.id})})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",color:ee?"#9ca3af":"#6b7280",flexShrink:0,opacity:.7,transition:"opacity 0.2s"},onMouseEnter:function(e){return e.target.style.opacity="1"},onMouseLeave:function(e){return e.target.style.opacity="0.7"}},e.createElement("svg",{style:{width:"16px",height:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))))}))))};function ir(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}ir(".camera-capture-wrapper{animation:slideUp .4s cubic-bezier(.4,0,.2,1);background:#fff;border:2px solid #e5e7eb;border-radius:16px;box-shadow:0 8px 32px rgba(0,0,0,.12);margin:12px 0;max-width:100%;overflow:hidden;position:relative;width:100%;z-index:1}@keyframes slideUp{0%{opacity:0;transform:translateY(40px)}to{opacity:1;transform:translateY(0)}}.camera-header-banner{align-items:center;background:linear-gradient(135deg,#6366f1,#8b5cf6);display:flex;justify-content:space-between;padding:16px 20px}.camera-header-content{align-items:center;display:flex;gap:14px}.camera-icon-badge{align-items:center;backdrop-filter:blur(10px);background:hsla(0,0%,100%,.2);border-radius:12px;display:flex;font-size:24px;height:48px;justify-content:center;width:48px}.camera-header-text{color:#fff}.camera-title{font-size:18px;font-weight:700;letter-spacing:-.5px;margin:0}.camera-subtitle{font-size:13px;font-weight:400;margin:4px 0 0;opacity:.9}.camera-close-button{align-items:center;backdrop-filter:blur(10px);background:hsla(0,0%,100%,.15);border:none;border-radius:8px;color:#fff;cursor:pointer;display:flex;font-size:20px;height:36px;justify-content:center;transition:all .2s;width:36px}.camera-close-button:hover{background:hsla(0,0%,100%,.25);transform:scale(1.05)}.camera-view-container{background:#000;max-height:500px;min-height:400px;overflow:hidden;position:relative}.camera-loading-state{align-items:center;color:#fff;display:flex;flex-direction:column;height:400px;justify-content:center}.loading-spinner{animation:spin 1s linear infinite;border:4px solid hsla(0,0%,100%,.2);border-radius:50%;border-top-color:#fff;height:48px;margin-bottom:16px;width:48px}@keyframes spin{to{transform:rotate(1turn)}}.camera-error-state{align-items:center;color:#fff;display:flex;flex-direction:column;height:400px;justify-content:center;padding:40px;text-align:center}.error-icon-large{font-size:64px;margin-bottom:16px;opacity:.5}.error-message{font-size:16px;line-height:1.5;margin-bottom:24px}.retry-button{background:#6366f1;border:none;border-radius:8px;color:#fff;cursor:pointer;font-size:15px;font-weight:600;padding:12px 28px;transition:all .2s}.retry-button:hover{background:#4f46e5;transform:scale(1.05)}.camera-live-mode{height:100%;min-height:400px;position:relative;width:100%}.camera-video-feed{display:block;height:100%;object-fit:cover;width:100%}.camera-overlay{bottom:0;left:0;pointer-events:none;position:absolute;right:0;top:0}.camera-frame{aspect-ratio:4/3;border:3px solid hsla(0,0%,100%,.5);border-radius:16px;box-shadow:0 0 0 2000px rgba(0,0,0,.3);left:50%;max-width:350px;position:absolute;top:50%;transform:translate(-50%,-50%);width:80%}.camera-preview-mode{background:#000;min-height:400px;position:relative;width:100%}.preview-image-wrapper{align-items:center;display:flex;height:100%;justify-content:center;position:relative;width:100%}.preview-image{display:block;max-height:500px;max-width:100%;object-fit:contain}.preview-badge{backdrop-filter:blur(10px);background:rgba(99,102,241,.95);border-radius:20px;color:#fff;font-size:13px;font-weight:600;padding:8px 16px;position:absolute;right:16px;top:16px}.camera-action-section{background:#fff;padding:24px 20px}.preview-actions{display:grid;gap:12px;grid-template-columns:1fr 1fr}.action-button{align-items:center;border:none;border-radius:12px;cursor:pointer;display:flex;font-family:inherit;font-size:16px;font-weight:600;gap:10px;justify-content:center;padding:16px 24px;transition:all .2s}.button-icon{font-size:20px}.retake-button{background:#f3f4f6;border:2px solid #e5e7eb;color:#374151}.retake-button:hover{background:#e5e7eb;box-shadow:0 4px 12px rgba(0,0,0,.1);transform:translateY(-2px)}.submit-button{background:linear-gradient(135deg,#10b981,#059669);box-shadow:0 4px 16px rgba(16,185,129,.3);color:#fff}.submit-button:hover{box-shadow:0 6px 20px rgba(16,185,129,.4);transform:translateY(-2px)}.camera-actions{align-items:center;display:flex;gap:16px;justify-content:space-between}.flip-camera-button{align-items:center;background:#f3f4f6;border:2px solid #e5e7eb;border-radius:50%;cursor:pointer;display:flex;flex-direction:column;height:64px;justify-content:center;transition:all .2s;width:64px}.flip-camera-button:hover:not(:disabled){background:#e5e7eb;transform:scale(1.05)}.flip-camera-button:disabled{cursor:not-allowed;opacity:.4}.flip-icon{font-size:24px}.flip-text{color:#6b7280;font-size:11px;font-weight:600;margin-top:2px}.capture-button-main{align-items:center;background:#fff;border:4px solid #6366f1;border-radius:50%;box-shadow:0 4px 20px rgba(99,102,241,.3);cursor:pointer;display:flex;height:80px;justify-content:center;position:relative;transition:all .2s;width:80px}.capture-button-main:hover:not(:disabled){box-shadow:0 6px 24px rgba(99,102,241,.4);transform:scale(1.08)}.capture-button-main:active:not(:disabled){transform:scale(.95)}.capture-button-main:disabled{cursor:not-allowed;opacity:.4}.capture-button-inner{align-items:center;display:flex;height:100%;justify-content:center;position:relative;width:100%}.capture-ring{animation:pulse 2s ease-in-out infinite;border:3px solid #6366f1;border-radius:50%;height:68px;position:absolute;width:68px}@keyframes pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.7;transform:scale(1.1)}}.capture-center{background:linear-gradient(135deg,#6366f1,#8b5cf6);border-radius:50%;height:56px;width:56px}.placeholder-space{width:64px}.camera-instructions{background:#f9fafb;border-top:1px solid #e5e7eb;padding:16px 20px;text-align:center}.camera-instructions p{color:#6b7280;font-size:14px;font-weight:500;margin:0}.camera-instructions.success{background:#ecfdf5;border-top-color:#d1fae5}.camera-instructions.success p{color:#059669}@media (max-width:768px){.camera-capture-wrapper{border-radius:12px;margin:12px 0}.camera-header-banner{padding:14px 16px}.camera-icon-badge{font-size:20px;height:42px;width:42px}.camera-title{font-size:16px}.camera-subtitle{font-size:12px}.camera-view-container{max-height:400px;min-height:350px}.camera-live-mode{min-height:350px}.camera-action-section{padding:20px 16px}.action-button{font-size:15px;padding:14px 20px}.capture-button-main{height:72px;width:72px}.capture-ring{height:60px;width:60px}.capture-center{height:48px;width:48px}}@media (max-width:480px){.camera-capture-wrapper{border-radius:10px;margin:8px 0}.camera-header-banner{padding:12px 14px}.camera-icon-badge{border-radius:10px;font-size:18px;height:38px;width:38px}.camera-title{font-size:15px}.camera-subtitle{font-size:11px}.camera-close-button{font-size:18px;height:32px;width:32px}.camera-view-container{max-height:350px;min-height:300px}.camera-live-mode{min-height:300px}.camera-action-section{padding:18px 14px}.action-button{font-size:14px;padding:13px 18px}.button-icon{font-size:18px}.flip-camera-button{height:56px;width:56px}.flip-icon{font-size:20px}.capture-button-main{height:68px;width:68px}.capture-ring{height:56px;width:56px}.capture-center{height:44px;width:44px}.placeholder-space{width:56px}.camera-instructions{padding:14px 16px}.camera-instructions p{font-size:13px}}");var sr=function(t){var n=t.onCapture,o=t.onClose,i=t.requesterName,s=void 0===i?"Agent":i,a=u(e.useState(null),2),l=a[0],d=a[1],p=u(e.useState(null),2),h=p[0],m=p[1],f=u(e.useState(!1),2),g=f[0],y=f[1],b=u(e.useState("environment"),2),x=b[0],v=b[1],E=u(e.useState(null),2),w=E[0],k=E[1],C=u(e.useState(!0),2),S=C[0],A=C[1],_=e.useRef(null),N=e.useRef(null);e.useEffect(function(){return R(),function(){B()}},[x]);var R=function(){var e=r(c().m(function e(){var t,n;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,k(null),A(!0),e.n=1,navigator.mediaDevices.getUserMedia({video:{facingMode:x,width:{ideal:1920},height:{ideal:1080}},audio:!1});case 1:t=e.v,d(t),_.current&&(_.current.srcObject=t),y(!0),A(!1),e.n=3;break;case 2:e.p=2,n=e.v,console.error("Camera access error:",n),k("Camera access denied. Please allow camera permissions."),y(!1),A(!1);case 3:return e.a(2)}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}(),B=function(){l&&(l.getTracks().forEach(function(e){return e.stop()}),d(null),y(!1))},T=function(){B(),o&&o()};return e.createElement("div",{className:"camera-capture-wrapper"},e.createElement("div",{className:"camera-header-banner"},e.createElement("div",{className:"camera-header-content"},e.createElement("div",{className:"camera-icon-badge"},"πΈ"),e.createElement("div",{className:"camera-header-text"},e.createElement("h3",{className:"camera-title"},"Camera Capture"),e.createElement("p",{className:"camera-subtitle"},s," requested a photo"))),e.createElement("button",{className:"camera-close-button",onClick:T},e.createElement("span",null,"β"))),e.createElement("div",{className:"camera-view-container"},w?e.createElement("div",{className:"camera-error-state"},e.createElement("div",{className:"error-icon-large"},"π·"),e.createElement("p",{className:"error-message"},w),e.createElement("button",{className:"retry-button",onClick:R},"π Try Again")):S?e.createElement("div",{className:"camera-loading-state"},e.createElement("div",{className:"loading-spinner"}),e.createElement("p",null,"Loading camera...")):h?e.createElement("div",{className:"camera-preview-mode"},e.createElement("div",{className:"preview-image-wrapper"},e.createElement("img",{src:h,alt:"Captured",className:"preview-image"}),e.createElement("div",{className:"preview-badge"},"Preview"))):e.createElement("div",{className:"camera-live-mode"},e.createElement("video",{ref:_,autoPlay:!0,playsInline:!0,muted:!0,className:"camera-video-feed"}),e.createElement("div",{className:"camera-overlay"},e.createElement("div",{className:"camera-frame"})),e.createElement("canvas",{ref:N,style:{display:"none"}}))),e.createElement("div",{className:"camera-action-section"},h?e.createElement("div",{className:"preview-actions"},e.createElement("button",{className:"action-button retake-button",onClick:function(){m(null),R()}},e.createElement("span",{className:"button-icon"},"π"),e.createElement("span",{className:"button-text"},"Retake")),e.createElement("button",{className:"action-button submit-button",onClick:function(){h&&n&&(n(h),T())}},e.createElement("span",{className:"button-icon"},"β"),e.createElement("span",{className:"button-text"},"Submit Photo"))):e.createElement("div",{className:"camera-actions"},e.createElement("button",{className:"flip-camera-button",onClick:function(){v(function(e){return"user"===e?"environment":"user"})},disabled:!g},e.createElement("span",{className:"flip-icon"},"π"),e.createElement("span",{className:"flip-text"},"Flip")),e.createElement("button",{className:"capture-button-main",onClick:function(){if(_.current&&N.current){var e=_.current,t=N.current,n=t.getContext("2d");t.width=e.videoWidth,t.height=e.videoHeight,n.drawImage(e,0,0,t.width,t.height);var r=t.toDataURL("image/jpeg",.95);m(r),B()}},disabled:!g},e.createElement("div",{className:"capture-button-inner"},e.createElement("div",{className:"capture-ring"}),e.createElement("div",{className:"capture-center"}))),e.createElement("div",{className:"placeholder-space"}))),!h&&!w&&e.createElement("div",{className:"camera-instructions"},e.createElement("p",null,"πΈ Position and tap the button to capture")),h&&e.createElement("div",{className:"camera-instructions success"},e.createElement("p",null,"β Photo captured! Review and submit or retake")))};ir(".crm-widget-container{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.crm-chat-button{align-items:center;animation:crm-pulse 2s ease-in-out infinite;border:none;border-radius:50%;box-shadow:0 10px 25px rgba(79,70,229,.4),0 0 0 0 rgba(79,70,229,.4);color:#fff;cursor:pointer;display:flex;font-size:24px;height:64px;justify-content:center;position:fixed;transition:all .3s cubic-bezier(.4,0,.2,1);width:64px}.crm-chat-button:hover{animation:none;box-shadow:0 15px 35px rgba(79,70,229,.5),0 0 0 8px rgba(79,70,229,.1);transform:scale(1.1)}@keyframes crm-pulse{0%,to{box-shadow:0 10px 25px rgba(79,70,229,.4),0 0 0 0 rgba(79,70,229,.4)}50%{box-shadow:0 10px 25px rgba(79,70,229,.4),0 0 0 8px rgba(79,70,229,0)}}.crm-icon{height:32px;width:32px}.crm-icon-sm{height:24px;width:24px}.crm-spin{animation:crm-spin 1s linear infinite}@keyframes crm-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.crm-badge{align-items:center;background-color:#ef4444;border-radius:50%;color:#fff;display:flex;font-size:12px;font-weight:600;height:20px;justify-content:center;position:absolute;right:-4px;top:-4px;width:20px}.crm-bottom-6{bottom:24px}.crm-right-6{right:24px}.crm-left-6{left:24px}.crm-top-6{top:24px}.crm-chat-window{background:#fff;border:1px solid #e5e7eb;border-radius:16px;box-shadow:0 20px 50px rgba(0,0,0,.3);display:flex;flex-direction:column;height:600px;max-width:448px;overflow:hidden;position:fixed;width:100%}.crm-chat-window.crm-dark{background:#1f2937;border-color:#374151}.crm-chat-window.crm-bottom-6{bottom:100px}.crm-chat-window.crm-right-6{right:24px}.crm-chat-window.crm-left-6{left:24px}.crm-chat-window.crm-top-6{top:100px}@media (max-width:640px){.crm-chat-window{border-radius:0;bottom:0!important;height:100vh;left:0!important;max-width:100%;right:0!important;top:0!important}}.crm-header{align-items:center;color:#fff;display:flex;justify-content:space-between;padding:16px 24px}.crm-header-content{align-items:center;display:flex;gap:12px}.crm-avatar{align-items:center;background:#fff;border-radius:50%;box-shadow:0 4px 12px rgba(0,0,0,.1);display:flex;font-size:20px;height:40px;justify-content:center;transition:transform .2s;width:40px}.crm-avatar:hover{transform:scale(1.05)}.crm-title{font-size:18px;font-weight:600;margin:0}.crm-status{align-items:center;display:flex;font-size:14px;gap:8px;opacity:.9}.crm-status-dot{border-radius:50%;height:8px;width:8px}.crm-status-dot.crm-online{background-color:#10b981}.crm-status-dot.crm-offline{background-color:#ef4444}.crm-close-btn{background:hsla(0,0%,100%,.2);border:none;border-radius:50%;color:#fff;cursor:pointer;padding:8px;transition:background .2s}.crm-close-btn:hover{background:hsla(0,0%,100%,.3)}.crm-new-query-btn{align-items:center;background:hsla(0,0%,100%,.2);border:none;border-radius:50%;color:#fff;cursor:pointer;display:flex;justify-content:center;padding:8px;transition:all .2s}.crm-new-query-btn:hover{background:hsla(0,0%,100%,.3);transform:scale(1.05)}.crm-messages{background:#f9fafb;display:flex;flex:1;flex-direction:column;gap:16px;overflow-y:auto;padding:16px}.crm-dark .crm-messages{background:#111827}.crm-welcome-message{background:#fff;border:1px solid #e5e7eb;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,.1);padding:16px}.crm-dark .crm-welcome-message{background:#1f2937;border-color:#374151;color:#d1d5db}.crm-welcome-message p{color:#374151;font-size:14px;margin:0}.crm-dark .crm-welcome-message p{color:#d1d5db}.crm-message{display:flex}.crm-message-guest{justify-content:flex-end}.crm-message-agent{justify-content:flex-start}.crm-message-system{justify-content:center}.crm-message-bubble{border-radius:16px;box-shadow:0 1px 2px rgba(0,0,0,.1);max-width:75%;padding:10px 16px}.crm-message-guest .crm-message-bubble{border-bottom-right-radius:4px;color:#fff}.crm-message-agent .crm-message-bubble{background:#fff;border:1px solid #e5e7eb;border-bottom-left-radius:4px;color:#1f2937}.crm-dark .crm-message-agent .crm-message-bubble{background:#1f2937;border-color:#374151;color:#f3f4f6}.crm-agent-name{font-size:12px;font-weight:500;margin:0 0 4px;opacity:.7}.crm-message-text{font-size:14px;line-height:1.5;margin:0;white-space:pre-wrap;word-break:break-word}.crm-message-time{font-size:11px;margin:4px 0 0;opacity:.7}.crm-typing-indicator{display:flex;gap:4px;padding:4px 0}.crm-typing-dot{animation:typing 1.4s infinite;background:#9ca3af;border-radius:50%;height:8px;width:8px}.crm-typing-dot:nth-child(2){animation-delay:.2s}.crm-typing-dot:nth-child(3){animation-delay:.4s}@keyframes typing{0%,60%,to{transform:translateY(0)}30%{transform:translateY(-10px)}}.crm-input-container{background:#fff;border-top:1px solid #e5e7eb;padding:16px}.crm-dark .crm-input-container{background:#1f2937;border-color:#374151}.crm-input-wrapper{align-items:flex-end;display:flex;gap:8px}.crm-input{background:#f9fafb;border:1px solid #d1d5db;border-radius:12px;color:#1f2937;flex:1;font-family:inherit;font-size:14px;max-height:120px;min-height:48px;padding:12px 16px;resize:none}.crm-input:focus{border-color:#6366f1;box-shadow:0 0 0 3px rgba(99,102,241,.1);outline:none}.crm-input:disabled{cursor:not-allowed;opacity:.5}.crm-dark .crm-input{background:#111827;border-color:#4b5563;color:#f3f4f6}.crm-dark .crm-input::placeholder{color:#6b7280}.crm-send-btn{align-items:center;border:none;border-radius:12px;color:#fff;cursor:pointer;display:flex;flex-shrink:0;justify-content:center;padding:12px;transition:all .2s}.crm-send-btn:hover:not(:disabled){box-shadow:0 4px 12px rgba(0,0,0,.2)}.crm-send-btn:disabled{cursor:not-allowed;opacity:.5}.crm-input-hint{color:#9ca3af;font-size:11px;margin:8px 0 0;text-align:center}.crm-dark .crm-input-hint{color:#6b7280}.crm-messages::-webkit-scrollbar{width:6px}.crm-messages::-webkit-scrollbar-track{background:transparent}.crm-messages::-webkit-scrollbar-thumb{background:#d1d5db;border-radius:3px}.crm-dark .crm-messages::-webkit-scrollbar-thumb{background:#4b5563}.crm-messages::-webkit-scrollbar-thumb:hover{background:#9ca3af}");exports.ChatCRMWidget=function(t){var n=t.apiKey,i=t.apiUrl,s=void 0===i?"https://chat-crm-backend-7mzo.onrender.com":i,a=t.primaryColor,l=void 0===a?"#4F46E5":a,p=t.position,h=void 0===p?"bottom-right":p,m=t.userData,f=void 0===m?null:m,g=t.welcomeMessage,y=void 0===g?"π Welcome! How can we help you today?":g,b=t.companyName,x=void 0===b?"Support":b,v=t.autoOpen,E=void 0!==v&&v,w=t.showNotifications,k=void 0===w||w,C=t.playSound,S=void 0!==C&&C,A=t.theme,_=void 0===A?"light":A,N=t.zIndex,R=void 0===N?9999:N,B=u(e.useState(E),2),T=B[0],O=B[1],F=u(e.useState([]),2),L=F[0],j=F[1],I=u(e.useState(""),2),z=I[0],P=I[1],M=u(e.useState(null),2),D=M[0],U=M[1],q=u(e.useState(null),2);q[0];var H=q[1],W=u(e.useState(null),2),V=W[0],K=W[1],G=u(e.useState(!1),2),Y=G[0],J=G[1],$=u(e.useState(!1),2),X=$[0],Q=$[1],Z=u(e.useState(!1),2),ee=Z[0],te=Z[1],ne=u(e.useState(!1),2),re=ne[0],oe=ne[1],ie=u(e.useState("Support Agent"),2),se=ie[0],ae=ie[1],ce=u(e.useState(0),2),le=ce[0],ue=ce[1],de=u(e.useState(!1),2),pe=de[0],he=de[1],me=u(e.useState("active"),2),fe=me[0],ge=me[1],ye=u(e.useState(null),2),be=ye[0],xe=ye[1],ve=u(e.useState(!1),2),Ee=ve[0],we=ve[1],ke=u(e.useState(!1),2),Ce=ke[0],Se=ke[1],Ae=u(e.useState(null),2),_e=Ae[0],Ne=Ae[1],Re=u(e.useState(null),2),Be=Re[0],Te=Re[1],Oe=e.useRef(null),Fe=e.useRef(null),je=u(e.useState(!1),2),Ie=je[0],ze=je[1],Pe=u(e.useState(0),2),Me=Pe[0],De=Pe[1],Ue=u(e.useState(""),2),qe=Ue[0],He=Ue[1],We=u(e.useState(!1),2),Ve=We[0],Ke=We[1],Ge=u(e.useState(!1),2),Ye=Ge[0],Je=Ge[1],$e=u(e.useState(!1),2),Xe=$e[0],Qe=$e[1],Ze=u(e.useState(null),2),et=Ze[0],tt=Ze[1],nt=u(e.useState([]),2),rt=nt[0],ot=nt[1],it=e.useRef(!1),st=e.useRef(null),at=e.useRef(null),ct=e.useRef(null),lt=e.useRef(null);e.useEffect(function(){var e=function(e){if(T){var t=at.current,n=ct.current,r=lt.current;!t||t.contains(e.target)||!n||n.contains(e.target)||r&&r.contains(e.target)||(O(!1),Qe(!1))}};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[T]);e.useEffect(function(){var e;null===(e=st.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[L]),e.useEffect(function(){return function(){D&&D.disconnect()}},[D]);var ut=function(){if(f)return{name:f.name||"Guest User",email:f.email||null,phone:f.phone||null,userId:f.userId||null};var e=function(){for(var e={name:null,email:null,phone:null},t=function(e){var t,n;return e?"META"===e.tagName?e.getAttribute("content")||null:"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value||e.getAttribute("value")||e.getAttribute("placeholder")||null:e.getAttribute("data-name")||e.getAttribute("data-user-name")||e.getAttribute("data-full-name")||e.getAttribute("data-display-name")||e.getAttribute("data-email")||e.getAttribute("data-phone")||(null===(t=e.textContent)||void 0===t?void 0:t.trim())||(null===(n=e.innerText)||void 0===n?void 0:n.trim())||null:null},n=null,r=null,i=null,s=0,a=['[name="firstName"], [name="firstname"], [name="FirstName"], [name="FIRSTNAME"]','[name="lastName"], [name="lastname"], [name="LastName"], [name="LASTNAME"]','[name="fullName"], [name="fullname"], [name="FullName"], [name="FULLNAME"]','[name="userName"], [name="username"], [name="UserName"], [name="USERNAME"]','[name="displayName"], [name="display_name"]','[name="name"], [name="Name"], [name="NAME"]',"#firstName, #firstname, #FirstName, #FIRSTNAME","#lastName, #lastname, #LastName, #LASTNAME","#fullName, #fullname, #FullName, #FULLNAME","#userName, #username, #UserName, #USERNAME","#displayName, #display_name","#name, #Name, #NAME",".firstName, .firstname, .FirstName, .FIRSTNAME",".lastName, .lastname, .LastName, .LASTNAME",".fullName, .fullname, .FullName, .FULLNAME",".userName, .username, .UserName, .USERNAME",".displayName, .display_name",".name, .Name, .NAME","[data-name], [data-user-name], [data-full-name], [data-display-name]",".profile-name, .user-name, .username, .full-name",".header-name, .nav-name, .account-name",'meta[name="user-name"], meta[property="user:name"]'];s<a.length;s++){var c=a[s];try{var l,u=o(document.querySelectorAll(c));try{for(u.s();!(l=u.n()).done;){var d=t(l.value);d&&d.length>1&&"Guest User"!==d&&(c.toLowerCase().includes("firstname")&&!n?n=d:c.toLowerCase().includes("lastname")&&!r?r=d:(c.toLowerCase().includes("fullname")||c.toLowerCase().includes("username")||c.toLowerCase().includes("displayname")||c.toLowerCase().includes("name"))&&!i&&(i=d))}}catch(e){u.e(e)}finally{u.f()}}catch(e){}}n&&r?e.name="".concat(n," ").concat(r):n?e.name=n:r?e.name=r:i&&(e.name=i);for(var p=0,h=['[name="email"], [name="Email"], [name="EMAIL"]','[type="email"]',"#email, #Email, #EMAIL",".email, .Email, .EMAIL","[data-email]",'meta[name="user-email"], meta[property="user:email"]'];p<h.length;p++){var m=h[p];try{var f=t(document.querySelector(m));if(f&&f.includes("@")){e.email=f;break}}catch(e){}}for(var g=0,y=['[name="phone"], [name="Phone"], [name="PHONE"]','[name="phoneNumber"], [name="phone_number"]','[type="tel"]',"#phone, #Phone, #PHONE",".phone, .Phone, .PHONE","[data-phone]"];g<y.length;g++){var b=y[g];try{var x=t(document.querySelector(b));if(x&&/[\d\+\-\(\)\s]{10,}/.test(x)){e.phone=x;break}}catch(e){}}return e}();return{name:e.name||localStorage.getItem("chatGuestName")||"Guest User",email:e.email||localStorage.getItem("chatGuestEmail")||null,phone:e.phone||localStorage.getItem("chatGuestPhone")||null,userId:localStorage.getItem("chatUserId")||null}},dt=function(){var e=r(c().m(function e(){var t,r,o,i,a,l,u;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return t=ut(),Q(!0),e.p=1,console.log("π Creating new conversation for first message..."),e.n=2,Un.post("".concat(s,"/api/v1/webhook/guest-conversation"),{apiKey:n,guestName:t.name,guestEmail:t.email,guestPhone:t.phone,customUserId:t.userId});case 2:if(!(r=e.v).data.success){e.n=3;break}return o=r.data,i=o.conversationId,a=o.petitionId,l=o.queryId,H(l),K(i),he(!0),localStorage.setItem("chatGuestId",l),localStorage.setItem("chatConversationId",i),localStorage.setItem("chatPetitionId",a),t.email&&localStorage.setItem("chatGuestEmail",t.email),t.name&&localStorage.setItem("chatGuestName",t.name),t.phone&&localStorage.setItem("chatGuestPhone",t.phone),console.log("β
Conversation created:",{petitionId:a,queryId:l}),e.a(2,{newConvId:i,petitionId:a});case 3:throw new Error("Failed to create conversation");case 4:throw e.p=4,u=e.v,console.error("β Create conversation error:",u),u;case 5:return e.p=5,Q(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),pt=function(){var e=r(c().m(function e(t){var r,o;return c().w(function(e){for(;;)if(0===e.n)return r=t.convId,o=t.petitionId,te(!0),e.a(2,new Promise(function(e,t){try{var i,a=Le("".concat(s,"/widget"),{query:{conversationId:r,petitionId:o,apiKey:n},transports:["websocket","polling"]});a.on("connect",function(){J(!0),te(!1),console.log("β
Connected to Chat CRM Widget Namespace"),e(a)}),a.on("connect_error",function(e){te(!1),console.error("β Socket connect_error:",(null==e?void 0:e.message)||e)}),a.on("error",function(e){console.error("β Socket error:",e)}),a.on("disconnect",function(){J(!1),console.log("β Disconnected from Chat CRM")}),a.on("new-message",function(e){console.log("π¨ Received new-message:",e);var t={message:e.message||e.text||"",sender:e.sender||"agent",senderName:e.senderName||"Support Agent",timestamp:e.timestamp||new Date,read:!1};j(function(e){var n=[].concat(d(e),[t]);return"guest"!==t.sender&&t.message&&(t.message.toLowerCase().includes("requested a photo")||t.message.toLowerCase().includes("send a photo")||t.message.toLowerCase().includes("send photo"))&&ot(function(e){var t=n.length-1;return e.includes(t)?e:[].concat(d(e),[t])}),n}),ae((e.senderName||"Support Agent").toUpperCase()),oe(!1),!T&&k&&(ue(function(e){return e+1}),S&>())}),a.on("query-accepted",function(e){console.log("β
Query accepted by agent:",e);var t=(e.agentName||"Support Agent").toUpperCase();ae(t),ge("active"),j(function(e){return[].concat(d(e),[{message:"".concat(t," has accepted your query and will assist you now."),sender:"system",timestamp:new Date,read:!0}])})}),a.on("query-transferred",function(e){console.log("π Query transferred:",e);var t=(e.toAgentName||"Support Agent").toUpperCase();ae(t),j(function(e){return[].concat(d(e),[{message:"Your query has been escalated and will be assisted shortly.",sender:"system",timestamp:new Date,read:!0}])})}),a.on("query-resolved",function(e){console.log("β
Query resolved:",e),ge("resolved"),it.current?console.log("π Skipping duplicate resolved system message"):(it.current=!0,j(function(e){return[].concat(d(e),[{message:"β
This query has been resolved by the agent.",sender:"system",timestamp:new Date,read:!0}])}))}),a.on("request-feedback",function(e){console.log("π Feedback requested:",e),ze(!0)}),a.on("request-camera-snapshot",function(e){console.log("πΈ Snapshot request received:",e);try{var t,n=localStorage.getItem("chatPetitionId");if(console.log("πΈ Checking petitionId match:",{received:null==e?void 0:e.petitionId,stored:n}),null!=e&&e.petitionId&&n&&e.petitionId===n)console.log("β
PetitionId match - showing camera"),xe({requesterName:e.requesterName||(null===(t=e.requester)||void 0===t?void 0:t.name)||"Agent",at:Date.now()});else console.log("β PetitionId mismatch or missing")}catch(e){console.error("Snapshot request error:",e)}}),a.on("query-reopened",function(e){console.log("π Query reopened:",e),ge("active"),it.current=!1}),a.on("agent-typing",function(e){e.isTyping?(oe(!0),ae(e.agentName||"Support Agent"),i&&clearTimeout(i),i=setTimeout(function(){oe(!1)},3e3)):(oe(!1),i&&clearTimeout(i))}),U(a)}catch(e){te(!1),t(e)}}))},e)}));return function(t){return e.apply(this,arguments)}}(),ht=function(){var e=r(c().m(function e(){var t,n,r,o,i,s,a,l,u,p;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(z.trim()&&"resolved"!==fe){e.n=1;break}return e.a(2);case 1:if(D&&localStorage.getItem("chatPetitionId")&&(t=localStorage.getItem("chatPetitionId"),D.emit("customer-typing",{petitionId:t,isTyping:!1})),n=ut(),r=z.trim(),o=Date.now(),j(function(e){return[].concat(d(e),[{message:r,sender:"guest",senderName:n.name||"Guest User",read:!0,timestamp:new Date,tempId:o}])}),P(""),e.p=2,i=localStorage.getItem("chatPetitionId"),s=V||localStorage.getItem("chatConversationId"),i&&s){e.n=4;break}return e.n=3,dt();case 3:a=e.v,s=a.newConvId,i=a.petitionId;case 4:if((l=D)&&Y){e.n=6;break}try{D&&D.disconnect()}catch(e){}return e.n=5,pt({convId:s,petitionId:i});case 5:l=e.v;case 6:u={conversationId:s,petitionId:i,message:r,senderName:n.name||"Guest User",senderType:"Customer",timestamp:new Date},console.log("π€ Sending message:",u),l.emit("widget-message",u),e.n=8;break;case 7:e.p=7,p=e.v,console.error("β Send message error:",p),j(function(e){return e.filter(function(e){return e.tempId!==o})}),alert("Failed to send message. Please try again.");case 8:return e.a(2)}},e,null,[[2,7]])}));return function(){return e.apply(this,arguments)}}(),mt=function(){localStorage.removeItem("chatGuestId"),localStorage.removeItem("chatConversationId"),localStorage.removeItem("chatPetitionId"),D&&D.disconnect(),U(null),H(null),K(null),J(!1),he(!1),ge("active"),it.current=!1,j([]),P(""),ze(!1),De(0),He(""),Ke(!1),console.log("π Starting new query...")},ft=function(e){if("ticket"===e&&!((null==f?void 0:f.email)||localStorage.getItem("chatGuestEmail")))return tt(e),void Qe(!1);tt(e),Qe(!1)},gt=function(){var e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),n=e.createGain();t.connect(n),n.connect(e.destination),t.frequency.value=800,t.type="sine",n.gain.value=.1,t.start(),setTimeout(function(){return t.stop()},200)},yt=function(){var e=r(c().m(function e(){var t,n;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,navigator.mediaDevices.getUserMedia({video:{facingMode:"user"}});case 1:t=e.v,Ne(t),Oe.current&&(Oe.current.srcObject=t,Oe.current.play()),e.n=3;break;case 2:e.p=2,n=e.v,console.error("Camera access error:",n),alert("Camera access denied. Please allow camera permissions."),vt();case 3:return e.a(2)}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}(),bt=function(){var e=r(c().m(function e(){return c().w(function(e){for(;;)switch(e.n){case 0:return Te(null),e.n=1,yt();case 1:return e.a(2)}},e)}));return function(){return e.apply(this,arguments)}}(),xt=function(){var e=r(c().m(function e(){var t,r,o,i,a,l,u,p,h;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(Be){e.n=1;break}return e.a(2);case 1:return we(!0),e.p=2,e.n=3,fetch(Be).then(function(e){return e.blob()});case 3:return r=e.v,o=localStorage.getItem("chatPetitionId"),i=new FormData,a="snapshot-".concat(o,"-").concat(Date.now(),".png"),i.append("screenshot",r,a),i.append("petitionId",o),i.append("apiKey",n),i.append("metadata",JSON.stringify({source:"widget",requesterName:null==be?void 0:be.requesterName})),e.n=4,Un.post("".concat(s,"/api/v1/webhook/upload-snapshot"),i,{headers:{"Content-Type":"multipart/form-data"}});case 4:if(l=e.v,!(u=null==l||null===(t=l.data)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.imageUrl)){e.n=5;break}return p=new Date,j(function(e){return[].concat(d(e),[{message:"πΈ Screenshot: ".concat(u),sender:"guest",senderName:"You",timestamp:p,read:!0}])}),e.n=5,Un.post("".concat(s,"/api/v1/webhook/send-message"),{apiKey:n,petitionId:o,message:"πΈ Screenshot: ".concat(u),senderName:"Guest User"});case 5:vt(),e.n=7;break;case 6:e.p=6,h=e.v,console.error("Widget capture error:",h),alert("Failed to upload photo. Please try again.");case 7:return e.p=7,we(!1),e.f(7);case 8:return e.a(2)}},e,null,[[2,6,7,8]])}));return function(){return e.apply(this,arguments)}}(),vt=function(){_e&&(_e.getTracks().forEach(function(e){return e.stop()}),Ne(null)),Se(!1),Te(null),xe(null)};e.useEffect(function(){console.log("πΈ Snapshot useEffect triggered:",{snapshotRequest:be,showCamera:Ce}),be&&!Ce&&(console.log("πΈ Setting showCamera to true and initializing camera"),Se(!0),setTimeout(function(){console.log("πΈ Calling initializeCamera"),yt()},100))},[be,Ce]),e.useEffect(function(){console.log("πΈ Video ref useEffect:",{showCamera:Ce,hasVideoRef:!!Oe.current,currentStream:_e,capturedImage:Be}),Ce&&Oe.current&&!_e&&!Be&&(console.log("πΈ Reinitializing camera from video ref useEffect"),yt())},[Ce,Oe.current]);var Et=function(){var e={"bottom-right":"crm-bottom-6 crm-right-6","bottom-left":"crm-bottom-6 crm-left-6","top-right":"crm-top-6 crm-right-6","top-left":"crm-top-6 crm-left-6"};return e[h]||e["bottom-right"]},wt="dark"===_||"auto"===_&&window.matchMedia("(prefers-color-scheme: dark)").matches;return e.createElement("div",{className:"crm-widget-container",style:{zIndex:R}},e.createElement("button",{ref:ct,onClick:function(){O(function(e){var t=!e;return t?(ue(0),Qe(!0),tt(null)):(Qe(!1),tt(null)),t})},className:"crm-chat-button ".concat(Et()),style:{background:"linear-gradient(135deg, ".concat(l," 0%, #6366f1 100%)")},"aria-label":T?"Close help":"Help & Support",title:"Help & Support"},T&&!Xe?e.createElement("svg",{className:"crm-icon",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})):e.createElement("svg",{className:"crm-icon",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M18 3a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3h-5l-5 3v-3H6a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3h12z"}),e.createElement("circle",{cx:"9",cy:"10",r:"1",fill:"currentColor"}),e.createElement("circle",{cx:"12",cy:"10",r:"1",fill:"currentColor"}),e.createElement("circle",{cx:"15",cy:"10",r:"1",fill:"currentColor"}),e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 14c.5.5 1.5 1 3 1s2.5-.5 3-1"})),!T&&le>0&&e.createElement("span",{className:"crm-badge"},le)),T&&Xe&&e.createElement("div",{ref:lt,className:"crm-menu-popup ".concat(Et()," ").concat(wt?"crm-dark":""),style:{position:"fixed",bottom:h.includes("bottom")?"90px":"auto",top:h.includes("top")?"90px":"auto",right:h.includes("right")?"24px":"auto",left:h.includes("left")?"24px":"auto",width:"280px",backgroundColor:wt?"#1F2937":"#fff",borderRadius:"12px",boxShadow:"0 10px 40px rgba(0,0,0,0.15)",border:wt?"1px solid #374151":"1px solid #E5E7EB",overflow:"hidden",zIndex:R+1}},e.createElement("div",{style:{padding:"16px",borderBottom:wt?"1px solid #374151":"1px solid #E5E7EB"}},e.createElement("h3",{style:{margin:0,fontSize:"16px",fontWeight:600,color:wt?"#F9FAFB":"#111827"}},"Help & Support"),e.createElement("p",{style:{margin:"4px 0 0 0",fontSize:"13px",color:wt?"#9CA3AF":"#6B7280"}},"How can we assist you today?")),e.createElement("div",{style:{padding:"8px"}},e.createElement("button",{onClick:function(){return ft("query")},className:"crm-menu-option",style:{width:"100%",padding:"12px",display:"flex",alignItems:"center",gap:"12px",border:"none",borderRadius:"8px",backgroundColor:"transparent",cursor:"pointer",transition:"all 0.2s",textAlign:"left"},onMouseEnter:function(e){return e.currentTarget.style.backgroundColor=wt?"#374151":"#F3F4F6"},onMouseLeave:function(e){return e.currentTarget.style.backgroundColor="transparent"}},e.createElement("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:l,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},e.createElement("svg",{style:{width:"20px",height:"20px",color:"#fff"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"}))),e.createElement("div",{style:{flex:1}},e.createElement("p",{style:{margin:0,fontSize:"14px",fontWeight:600,color:wt?"#F9FAFB":"#111827"}},"Start Query"),e.createElement("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:wt?"#9CA3AF":"#6B7280"}},"Chat with our support team")),e.createElement("svg",{style:{width:"16px",height:"16px",color:wt?"#9CA3AF":"#6B7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}))),e.createElement("button",{onClick:function(){return ft("ticket")},className:"crm-menu-option",style:{width:"100%",padding:"12px",display:"flex",alignItems:"center",gap:"12px",border:"none",borderRadius:"8px",backgroundColor:"transparent",cursor:"pointer",transition:"all 0.2s",textAlign:"left",marginTop:"4px"},onMouseEnter:function(e){return e.currentTarget.style.backgroundColor=wt?"#374151":"#F3F4F6"},onMouseLeave:function(e){return e.currentTarget.style.backgroundColor="transparent"}},e.createElement("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:"#10B981",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},e.createElement("svg",{style:{width:"20px",height:"20px",color:"#fff"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"}))),e.createElement("div",{style:{flex:1}},e.createElement("p",{style:{margin:0,fontSize:"14px",fontWeight:600,color:wt?"#F9FAFB":"#111827"}},"Raise Ticket"),e.createElement("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:wt?"#9CA3AF":"#6B7280"}},"Submit a support ticket")),e.createElement("svg",{style:{width:"16px",height:"16px",color:wt?"#9CA3AF":"#6B7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}))))),T&&"query"===et&&e.createElement("div",{ref:at,className:"crm-chat-window ".concat(Et()," ").concat(wt?"crm-dark":""),style:{position:"relative"}},e.createElement("div",{className:"crm-header",style:{backgroundColor:l}},e.createElement("div",{className:"crm-header-content"},e.createElement("button",{onClick:function(){tt(null),Qe(!0)},className:"crm-back-btn",title:"Back to Menu",style:{background:"none",border:"none",color:"#fff",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",marginRight:"8px"}},e.createElement("svg",{className:"crm-icon-sm",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"}))),e.createElement("div",{className:"crm-avatar"},e.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:l,strokeWidth:"2"},e.createElement("path",{d:"M12 2a4 4 0 0 1 4 4v2a4 4 0 0 1-8 0V6a4 4 0 0 1 4-4z"}),e.createElement("path",{d:"M12 14v8"}),e.createElement("path",{d:"M8 22h8"}),e.createElement("path",{d:"M8 14c-2 0-3 1-3 3v1c0 2 1 3 3 3h8c2 0 3-1 3-3v-1c0-2-1-3-3-3H8z"}))),e.createElement("div",null,e.createElement("h3",{className:"crm-title"},x),e.createElement("div",{className:"crm-status"},e.createElement("div",{className:"crm-status-dot ".concat(Y?"crm-online":"crm-offline")}),e.createElement("span",null,"resolved"===fe?e.createElement("span",{style:{color:"#10B981"}},"β Resolved"):"Support Agent"!==se?e.createElement("span",null,"π¬ ",se):Y?"Online":ee?"Connectingβ¦":"Ready")))),e.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},e.createElement("button",{onClick:mt,className:"crm-new-query-btn",title:"Start New Query"},e.createElement("svg",{className:"crm-icon-sm",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"}))),e.createElement("button",{onClick:function(){O(!1),Qe(!1),tt(null)},className:"crm-close-btn"},e.createElement("svg",{className:"crm-icon-sm",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))))),Ce&&e.createElement("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:wt?"#1F2937":"#fff",zIndex:9999,display:"flex",flexDirection:"column",padding:"16px",overflow:"auto"}},e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"}},e.createElement("h3",{style:{margin:0,fontSize:"16px",fontWeight:600,color:wt?"#E5E7EB":"#111827"}},"πΈ Camera Capture"),e.createElement("button",{onClick:vt,style:{background:"none",border:"none",fontSize:"24px",cursor:"pointer",padding:"0",color:wt?"#9CA3AF":"#6B7280"}},"Γ")),e.createElement("p",{style:{fontSize:"14px",color:wt?"#9CA3AF":"#6B7280",marginBottom:"12px"}},(null==be?void 0:be.requesterName)||"Agent"," requested a photo"),e.createElement("div",{style:{width:"100%",height:"300px",display:"flex",alignItems:"center",justifyContent:"center",background:"#000",borderRadius:"8px",overflow:"hidden",marginBottom:"12px",position:"relative"}},Be?e.createElement("img",{src:Be,alt:"Captured",style:{width:"100%",height:"100%",objectFit:"contain"}}):e.createElement(e.Fragment,null,e.createElement("video",{ref:Oe,autoPlay:!0,playsInline:!0,muted:!0,style:{width:"100%",height:"100%",objectFit:"cover",display:_e?"block":"none"}}),!_e&&e.createElement("div",{style:{position:"absolute",color:"#fff",textAlign:"center"}},e.createElement("div",{style:{fontSize:"14px",marginBottom:"8px"}},"Initializing camera..."),e.createElement("div",{style:{fontSize:"24px"}},"πΉ"))),e.createElement("canvas",{ref:Fe,style:{display:"none"}})),e.createElement("div",{style:{display:"flex",gap:"8px",justifyContent:"center"}},Be?e.createElement(e.Fragment,null,e.createElement("button",{onClick:bt,className:"crm-close-btn",style:{padding:"12px 24px",fontSize:"14px",fontWeight:600}},"π Retake"),e.createElement("button",{onClick:xt,className:"crm-send-btn",style:{backgroundColor:l,padding:"12px 24px",fontSize:"14px",fontWeight:600},disabled:Ee},Ee?"β³ Uploading...":"β
Submit")):e.createElement("button",{onClick:function(){if(Oe.current&&Fe.current){var e=Oe.current,t=Fe.current;t.width=e.videoWidth||640,t.height=e.videoHeight||480,t.getContext("2d").drawImage(e,0,0,t.width,t.height);var n=t.toDataURL("image/png");Te(n),_e&&(_e.getTracks().forEach(function(e){return e.stop()}),Ne(null))}},className:"crm-send-btn",style:{backgroundColor:l,padding:"12px 24px",fontSize:"14px",fontWeight:600}},"πΈ Capture"))),e.createElement("div",{className:"crm-messages"},!pe&&0===L.length&&e.createElement("div",{className:"crm-welcome-message"},e.createElement("p",null,y),e.createElement("p",{style:{fontSize:"0.875rem",marginTop:"8px",opacity:.7}},"π Start typing to begin your conversation")),L.map(function(t,n){return e.createElement(e.Fragment,{key:n},e.createElement("div",{className:"crm-message ".concat("guest"===t.sender?"crm-message-guest":"system"===t.sender?"crm-message-system":"crm-message-agent")},e.createElement("div",{className:"crm-message-bubble",style:"guest"===t.sender?{backgroundColor:l}:"system"===t.sender?{backgroundColor:"#F3F4F6",color:"#374151",border:"1px solid #E5E7EB"}:{}},"agent"===t.sender&&e.createElement("p",{className:"crm-agent-name"},(t.senderName||se).toUpperCase()),function(){var n=String(t.message||""),r=n.match(/https?:[^\s]+\.(?:png|jpg|jpeg|gif|webp)/i);if(r){var o=r[0],i=n.replace(o,"").trim();return e.createElement("div",null,i&&e.createElement("p",{className:"crm-message-text",style:{opacity:.85}},i),e.createElement("img",{src:o,alt:"snapshot",style:{maxWidth:"240px",maxHeight:"180px",borderRadius:"8px",border:"1px solid #E5E7EB",display:"block"}}))}return e.createElement("p",{className:"crm-message-text"},n)}(),e.createElement("p",{className:"crm-message-time"},(o=t.timestamp,new Date(o).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}))))),"guest"!==t.sender&&t.message&&(t.message.toLowerCase().includes("requested a photo")||t.message.toLowerCase().includes("send a photo")||t.message.toLowerCase().includes("send photo"))&&rt.includes(n)&&e.createElement("div",{style:{width:"100%",position:"relative",zIndex:1}},e.createElement(sr,{onCapture:function(){var e=r(c().m(function e(t){var r;return c().w(function(e){for(;;)switch(e.n){case 0:try{r={message:"πΈ Photo sent",sender:"guest",timestamp:Date.now()},j(function(e){return[].concat(d(e),[r])}),D&&D.emit("chatMessage",{conversationId:V,message:"πΈ Photo sent",image:t}),ot(function(e){return e.filter(function(e){return e!==n})})}catch(e){console.error("Failed to send photo:",e)}case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),onClose:function(){ot(function(e){return e.filter(function(e){return e!==n})})},requesterName:t.senderName||se})));var o}),re&&e.createElement("div",{className:"crm-message crm-message-agent"},e.createElement("div",{className:"crm-message-bubble"},e.createElement("div",{className:"crm-typing-indicator"},e.createElement("div",{className:"crm-typing-dot"}),e.createElement("div",{className:"crm-typing-dot"}),e.createElement("div",{className:"crm-typing-dot"})))),Ie&&!Ve&&e.createElement("div",{className:"crm-message crm-message-system"},e.createElement("div",{className:"crm-feedback-form",style:{backgroundColor:"#F9FAFB",padding:"16px",borderRadius:"12px",border:"1px solid #E5E7EB"}},e.createElement("p",{style:{fontWeight:"600",marginBottom:"12px",color:"#111827"}},"β Rate Your Experience"),e.createElement("div",{style:{display:"flex",gap:"8px",marginBottom:"12px",justifyContent:"center"}},[1,2,3,4,5].map(function(t){return e.createElement("button",{key:t,onClick:function(){return De(t)},style:{background:"none",border:"none",cursor:"pointer",fontSize:"32px",padding:"0",transition:"transform 0.2s",filter:Me>=t?"none":"grayscale(100%)"},onMouseEnter:function(e){return e.currentTarget.style.transform="scale(1.2)"},onMouseLeave:function(e){return e.currentTarget.style.transform="scale(1)"}},Me>=t?"β":"β")})),e.createElement("textarea",{value:qe,onChange:function(e){return He(e.target.value)},placeholder:"Share your thoughts (optional)...",rows:"3",style:{width:"100%",padding:"8px 12px",border:"1px solid #D1D5DB",borderRadius:"8px",fontSize:"14px",fontFamily:"inherit",resize:"none",marginBottom:"12px"}}),e.createElement("button",{onClick:function(){if(Me&&!Ve&&!Ye){Je(!0);var e=localStorage.getItem("chatPetitionId");D&&e?(D.emit("submit-feedback",{petitionId:e,rating:Me,comment:qe.trim()}),console.log("π€ Feedback submitted:",{rating:Me,comment:qe}),Ke(!0),Je(!1),setTimeout(function(){ze(!1)},2e3)):Je(!1)}},disabled:!Me||Ye,style:{width:"100%",padding:"10px",backgroundColor:Me?l:"#D1D5DB",color:"white",border:"none",borderRadius:"8px",fontSize:"14px",fontWeight:"600",cursor:Me?"pointer":"not-allowed",transition:"all 0.2s"}},Ye?"Submitting...":"Submit Feedback"))),Ve&&e.createElement("div",{className:"crm-message crm-message-system"},e.createElement("div",{className:"crm-message-bubble",style:{backgroundColor:"#D1FAE5",color:"#065F46",border:"1px solid #A7F3D0"}},e.createElement("p",{className:"crm-message-text"},"β
Thank you for your feedback!"))),e.createElement("div",{ref:st})),e.createElement("div",{className:"crm-input-container"},"resolved"===fe?e.createElement("button",{onClick:mt,className:"crm-send-btn",style:{backgroundColor:l,width:"100%",padding:"12px",fontSize:"14px",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",border:"none",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s"}},e.createElement("svg",{style:{width:"18px",height:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})),"New Query"):e.createElement("div",{className:"crm-input-wrapper"},e.createElement("textarea",{value:z,onChange:function(e){var t=e.target.value;if(P(t),t.trim()&&D&&localStorage.getItem("chatPetitionId")){var n=localStorage.getItem("chatPetitionId"),r=ut();D.emit("customer-typing",{petitionId:n,userName:r.name||"Customer",isTyping:!0})}},onKeyPress:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),ht())},placeholder:"Type your message...",rows:"1",className:"crm-input"}),e.createElement("button",{onClick:ht,disabled:!z.trim()||X,className:"crm-send-btn",style:{backgroundColor:l}},X?e.createElement("svg",{className:"crm-icon-sm crm-spin",fill:"none",viewBox:"0 0 24 24"},e.createElement("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.createElement("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})):e.createElement("svg",{className:"crm-icon-sm",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})))),"resolved"!==fe&&e.createElement("p",{className:"crm-input-hint"},pe?"Press Enter to send β’ Shift+Enter for new line":"Send your first message to start conversation"))),"ticket"===et&&e.createElement(or,{apiKey:n,apiUrl:s,primaryColor:l,userData:ut(),theme:_,onClose:function(){tt(null),Qe(!0)}}))},exports.TicketBoard=or;
|
|
4
4
|
//# sourceMappingURL=index.js.map
|