diff --git a/composer-bot-extensions/composer-bot-extensions/content.js b/composer-bot-extensions/composer-bot-extensions/content.js index 7768631..c627995 100644 --- a/composer-bot-extensions/composer-bot-extensions/content.js +++ b/composer-bot-extensions/composer-bot-extensions/content.js @@ -3,4 +3,4 @@ const L={GET_CONVERSATIONS:"messages.get-conversations",GET_CONVERSATION:"messag `)}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,...n){const r=new this(e);return n.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[Oe]=this[Oe]={accessors:{}}).accessors,s=this.prototype;function i(o){const l=B(o);r[l]||(On(s,o),r[l]=!0)}return c.isArray(e)?e.forEach(i):i(e),this}};O.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);c.reduceDescriptors(O.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});c.freezeMethods(O);function oe(t,e){const n=this||H,r=e||n,s=O.from(r.headers);let i=r.data;return c.forEach(t,function(l){i=l.call(n,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function Ze(t){return!!(t&&t.__CANCEL__)}function D(t,e,n){w.call(this,t??"canceled",w.ERR_CANCELED,e,n),this.name="CanceledError"}c.inherits(D,w,{__CANCEL__:!0});function et(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new w("Request failed with status code "+n.status,[w.ERR_BAD_REQUEST,w.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function An(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Cn(t,e){t=t||10;const n=new Array(t),r=new Array(t);let s=0,i=0,o;return e=e!==void 0?e:1e3,function(f){const a=Date.now(),u=r[i];o||(o=a),n[s]=f,r[s]=a;let d=i,m=0;for(;d!==s;)m+=n[d++],d=d%t;if(s=(s+1)%t,s===i&&(i=(i+1)%t),a-o{n=u,s=null,i&&(clearTimeout(i),i=null),t.apply(null,a)};return[(...a)=>{const u=Date.now(),d=u-n;d>=r?o(a,u):(s=a,i||(i=setTimeout(()=>{i=null,o(s)},r-d)))},()=>s&&o(s)]}const W=(t,e,n=3)=>{let r=0;const s=Cn(50,250);return xn(i=>{const o=i.loaded,l=i.lengthComputable?i.total:void 0,f=o-r,a=s(f),u=o<=l;r=o;const d={loaded:o,total:l,progress:l?o/l:void 0,bytes:f,rate:a||void 0,estimated:a&&l&&u?(l-o)/a:void 0,event:i,lengthComputable:l!=null,[e?"download":"upload"]:!0};t(d)},n)},Ae=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},Ce=t=>(...e)=>c.asap(()=>t(...e)),Nn=R.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,R.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(R.origin),R.navigator&&/(msie|trident)/i.test(R.navigator.userAgent)):()=>!0,Pn=R.hasStandardBrowserEnv?{write(t,e,n,r,s,i){const o=[t+"="+encodeURIComponent(e)];c.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),c.isString(r)&&o.push("path="+r),c.isString(s)&&o.push("domain="+s),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function In(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Mn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function tt(t,e,n){let r=!In(e);return t&&(r||n==!1)?Mn(t,e):e}const xe=t=>t instanceof O?{...t}:t;function k(t,e){e=e||{};const n={};function r(a,u,d,m){return c.isPlainObject(a)&&c.isPlainObject(u)?c.merge.call({caseless:m},a,u):c.isPlainObject(u)?c.merge({},u):c.isArray(u)?u.slice():u}function s(a,u,d,m){if(c.isUndefined(u)){if(!c.isUndefined(a))return r(void 0,a,d,m)}else return r(a,u,d,m)}function i(a,u){if(!c.isUndefined(u))return r(void 0,u)}function o(a,u){if(c.isUndefined(u)){if(!c.isUndefined(a))return r(void 0,a)}else return r(void 0,u)}function l(a,u,d){if(d in e)return r(a,u);if(d in t)return r(void 0,a)}const f={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:l,headers:(a,u,d)=>s(xe(a),xe(u),d,!0)};return c.forEach(Object.keys(Object.assign({},t,e)),function(u){const d=f[u]||s,m=d(t[u],e[u],u);c.isUndefined(m)&&d!==l||(n[u]=m)}),n}const nt=t=>{const e=k({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:l}=e;e.headers=o=O.from(o),e.url=Ge(tt(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),l&&o.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let f;if(c.isFormData(n)){if(R.hasStandardBrowserEnv||R.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((f=o.getContentType())!==!1){const[a,...u]=f?f.split(";").map(d=>d.trim()).filter(Boolean):[];o.setContentType([a||"multipart/form-data",...u].join("; "))}}if(R.hasStandardBrowserEnv&&(r&&c.isFunction(r)&&(r=r(e)),r||r!==!1&&Nn(e.url))){const a=s&&i&&Pn.read(i);a&&o.set(s,a)}return e},kn=typeof XMLHttpRequest<"u",Ln=kn&&function(t){return new Promise(function(n,r){const s=nt(t);let i=s.data;const o=O.from(s.headers).normalize();let{responseType:l,onUploadProgress:f,onDownloadProgress:a}=s,u,d,m,g,p;function y(){g&&g(),p&&p(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function b(){if(!h)return;const E=O.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),v={data:!l||l==="text"||l==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:E,config:t,request:h};et(function(P){n(P),y()},function(P){r(P),y()},v),h=null}"onloadend"in h?h.onloadend=b:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(b)},h.onabort=function(){h&&(r(new w("Request aborted",w.ECONNABORTED,t,h)),h=null)},h.onerror=function(){r(new w("Network Error",w.ERR_NETWORK,t,h)),h=null},h.ontimeout=function(){let A=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const v=s.transitional||Ye;s.timeoutErrorMessage&&(A=s.timeoutErrorMessage),r(new w(A,v.clarifyTimeoutError?w.ETIMEDOUT:w.ECONNABORTED,t,h)),h=null},i===void 0&&o.setContentType(null),"setRequestHeader"in h&&c.forEach(o.toJSON(),function(A,v){h.setRequestHeader(v,A)}),c.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),l&&l!=="json"&&(h.responseType=s.responseType),a&&([m,p]=W(a,!0),h.addEventListener("progress",m)),f&&h.upload&&([d,g]=W(f),h.upload.addEventListener("progress",d),h.upload.addEventListener("loadend",g)),(s.cancelToken||s.signal)&&(u=E=>{h&&(r(!E||E.type?new D(null,t,h):E),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const S=An(s.url);if(S&&R.protocols.indexOf(S)===-1){r(new w("Unsupported protocol "+S+":",w.ERR_BAD_REQUEST,t));return}h.send(i||null)})},Fn=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,s;const i=function(a){if(!s){s=!0,l();const u=a instanceof Error?a:this.reason;r.abort(u instanceof w?u:new D(u instanceof Error?u.message:u))}};let o=e&&setTimeout(()=>{o=null,i(new w(`timeout ${e} of ms exceeded`,w.ETIMEDOUT))},e);const l=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(a=>{a.unsubscribe?a.unsubscribe(i):a.removeEventListener("abort",i)}),t=null)};t.forEach(a=>a.addEventListener("abort",i));const{signal:f}=r;return f.unsubscribe=()=>c.asap(l),f}},Dn=function*(t,e){let n=t.byteLength;if(n{const s=Bn(t,e);let i=0,o,l=f=>{o||(o=!0,r&&r(f))};return new ReadableStream({async pull(f){try{const{done:a,value:u}=await s.next();if(a){l(),f.close();return}let d=u.byteLength;if(n){let m=i+=d;n(m)}f.enqueue(new Uint8Array(u))}catch(a){throw l(a),a}},cancel(f){return l(f),s.return()}},{highWaterMark:2})},ne=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",rt=ne&&typeof ReadableStream=="function",qn=ne&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),st=(t,...e)=>{try{return!!t(...e)}catch{return!1}},jn=rt&&st(()=>{let t=!1;const e=new Request(R.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),Pe=64*1024,de=rt&&st(()=>c.isReadableStream(new Response("").body)),G={stream:de&&(t=>t.body)};ne&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!G[e]&&(G[e]=c.isFunction(t[e])?n=>n[e]():(n,r)=>{throw new w(`Response type '${e}' is not supported`,w.ERR_NOT_SUPPORT,r)})})})(new Response);const Hn=async t=>{if(t==null)return 0;if(c.isBlob(t))return t.size;if(c.isSpecCompliantForm(t))return(await new Request(R.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(c.isArrayBufferView(t)||c.isArrayBuffer(t))return t.byteLength;if(c.isURLSearchParams(t)&&(t=t+""),c.isString(t))return(await qn(t)).byteLength},Vn=async(t,e)=>{const n=c.toFiniteNumber(t.getContentLength());return n??Hn(e)},$n=ne&&(async t=>{let{url:e,method:n,data:r,signal:s,cancelToken:i,timeout:o,onDownloadProgress:l,onUploadProgress:f,responseType:a,headers:u,withCredentials:d="same-origin",fetchOptions:m}=nt(t);a=a?(a+"").toLowerCase():"text";let g=Fn([s,i&&i.toAbortSignal()],o),p;const y=g&&g.unsubscribe&&(()=>{g.unsubscribe()});let h;try{if(f&&jn&&n!=="get"&&n!=="head"&&(h=await Vn(u,r))!==0){let v=new Request(e,{method:"POST",body:r,duplex:"half"}),N;if(c.isFormData(r)&&(N=v.headers.get("content-type"))&&u.setContentType(N),v.body){const[P,V]=Ae(h,W(Ce(f)));r=Ne(v.body,Pe,P,V)}}c.isString(d)||(d=d?"include":"omit");const b="credentials"in Request.prototype;p=new Request(e,{...m,signal:g,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",credentials:b?d:void 0});let S=await fetch(p,m);const E=de&&(a==="stream"||a==="response");if(de&&(l||E&&y)){const v={};["status","statusText","headers"].forEach(we=>{v[we]=S[we]});const N=c.toFiniteNumber(S.headers.get("content-length")),[P,V]=l&&Ae(N,W(Ce(l),!0))||[];S=new Response(Ne(S.body,Pe,P,()=>{V&&V(),y&&y()}),v)}a=a||"text";let A=await G[c.findKey(G,a)||"text"](S,t);return!E&&y&&y(),await new Promise((v,N)=>{et(v,N,{data:A,headers:O.from(S.headers),status:S.status,statusText:S.statusText,config:t,request:p})})}catch(b){throw y&&y(),b&&b.name==="TypeError"&&/Load failed|fetch/i.test(b.message)?Object.assign(new w("Network Error",w.ERR_NETWORK,t,p),{cause:b.cause||b}):w.from(b,b&&b.code,t,p)}}),he={http:sn,xhr:Ln,fetch:$n};c.forEach(he,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Ie=t=>`- ${t}`,zn=t=>c.isFunction(t)||t===null||t===!1,it={getAdapter:t=>{t=c.isArray(t)?t:[t];const{length:e}=t;let n,r;const s={};for(let i=0;i`adapter ${l} `+(f===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since : `+i.map(Ie).join(` `):" "+Ie(i[0]):"as no adapter specified";throw new w("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r},adapters:he};function ae(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new D(null,t)}function Me(t){return ae(t),t.headers=O.from(t.headers),t.data=oe.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),it.getAdapter(t.adapter||H.adapter)(t).then(function(r){return ae(t),r.data=oe.call(t,t.transformResponse,r),r.headers=O.from(r.headers),r},function(r){return Ze(r)||(ae(t),r&&r.response&&(r.response.data=oe.call(t,t.transformResponse,r.response),r.response.headers=O.from(r.response.headers))),Promise.reject(r)})}const ot="1.10.0",re={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{re[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const ke={};re.transitional=function(e,n,r){function s(i,o){return"[Axios v"+ot+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,l)=>{if(e===!1)throw new w(s(o," has been removed"+(n?" in "+n:"")),w.ERR_DEPRECATED);return n&&!ke[o]&&(ke[o]=!0,console.warn(s(o," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(i,o,l):!0}};re.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function Jn(t,e,n){if(typeof t!="object")throw new w("options must be an object",w.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let s=r.length;for(;s-- >0;){const i=r[s],o=e[i];if(o){const l=t[i],f=l===void 0||o(l,i,t);if(f!==!0)throw new w("option "+i+" must be "+f,w.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new w("Unknown option "+i,w.ERR_BAD_OPTION)}}const K={assertOptions:Jn,validators:re},x=K.validators;let M=class{constructor(e){this.defaults=e||{},this.interceptors={request:new _e,response:new _e}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=` -`+i):r.stack=i}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=k(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&K.assertOptions(r,{silentJSONParsing:x.transitional(x.boolean),forcedJSONParsing:x.transitional(x.boolean),clarifyTimeoutError:x.transitional(x.boolean)},!1),s!=null&&(c.isFunction(s)?n.paramsSerializer={serialize:s}:K.assertOptions(s,{encode:x.function,serialize:x.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),K.assertOptions(n,{baseUrl:x.spelling("baseURL"),withXsrfToken:x.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&c.merge(i.common,i[n.method]);i&&c.forEach(["delete","get","head","post","put","patch","common"],p=>{delete i[p]}),n.headers=O.concat(o,i);const l=[];let f=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(n)===!1||(f=f&&y.synchronous,l.unshift(y.fulfilled,y.rejected))});const a=[];this.interceptors.response.forEach(function(y){a.push(y.fulfilled,y.rejected)});let u,d=0,m;if(!f){const p=[Me.bind(this),void 0];for(p.unshift.apply(p,l),p.push.apply(p,a),m=p.length,u=Promise.resolve(n);d{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(l=>{r.subscribe(l),i=l}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,l){r.reason||(r.reason=new D(i,o,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new at(function(s){e=s}),cancel:e}}};function Kn(t){return function(n){return t.apply(null,n)}}function Wn(t){return c.isObject(t)&&t.isAxiosError===!0}const pe={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};Object.entries(pe).forEach(([t,e])=>{pe[e]=t});function ct(t){const e=new M(t),n=Be(M.prototype.request,e);return c.extend(n,M.prototype,e,{allOwnKeys:!0}),c.extend(n,e,null,{allOwnKeys:!0}),n.create=function(s){return ct(k(t,s))},n}const T=ct(H);T.Axios=M;T.CanceledError=D;T.CancelToken=Xn;T.isCancel=Ze;T.VERSION=ot;T.toFormData=te;T.AxiosError=w;T.Cancel=T.CanceledError;T.all=function(e){return Promise.all(e)};T.spread=Kn;T.isAxiosError=Wn;T.mergeConfig=k;T.AxiosHeaders=O;T.formToJSON=t=>Qe(c.isHTMLForm(t)?new FormData(t):t);T.getAdapter=it.getAdapter;T.HttpStatusCode=pe;T.default=T;const{Axios:nr,AxiosError:rr,CanceledError:sr,isCancel:ir,CancelToken:or,VERSION:ar,all:cr,Cancel:lr,isAxiosError:ur,spread:fr,toFormData:dr,AxiosHeaders:hr,HttpStatusCode:pr,formToJSON:mr,getAdapter:yr,mergeConfig:gr}=T,Le=T.create({baseURL:"https://notable-recently-seagull.ngrok-free.app/api/v1/",headers:{"Content-Type":"application/json"}});class Gn{async sendSingleMessage(e){try{const{data:n}=await Le.post("/messages",e);return console.log("[NestJS] Response (single):",n),n}catch(n){throw console.error("[NestJS] Error (single):",n),n}}async sendBulkMessages(e){try{const{data:n}=await Le.post("/messages/bulk",{data:e});return console.log("[NestJS] Response (bulk):",n),n}catch(n){throw console.error("[NestJS] Error (bulk):",n),n}}}const ce=new Gn;class Yn{MY_NAME="Apactech com";lastMessage;initialHistories=[];elTags={container_scroll:"/html/body/div[1]/div/div/div/div[5]/div[1]/div[1]/div[2]/div[1]/div[1]/div",conatainer_conversations:"/html/body/div[1]/div/div/div/div[5]/div[1]/div[1]/div[2]/div[1]/div[1]/div/div[1]",container_chat:"/html/body/div[1]/div/div/div/div[6]/div[4]/div/div[1]/div/div[1]/div/div/div/div[1]/div/div/div[4]",root_id:'[aria-selected="true"] [id^="chat-list-item"]',room_name:'[data-tid="chat-title"]',close_reply_btn:"/html/body/div[1]/div/div/div/div[6]/div[4]/div/div[1]/div/div[3]/div/div[3]/div/div[2]/div/div[2]/div/div/card/div/div/div[2]/div/div[1]/button",reply_btn:'[aria-label="Reply"]',chat_input:"/html/body/div[1]/div/div/div/div[6]/div[4]/div/div[1]/div/div[3]/div/div[3]/div/div[2]/div/div[2]/div[1]/div"};getCurrentRoomInfo(){const e=document.querySelector(this.elTags.root_id)?.id?.replace("chat-list-item_",""),n=document.querySelector(this.elTags.room_name)?.innerText;return{room_id:e,room_name:n}}_getMessageByEl(e){if(!e)return"";let n=e.innerText||"";const r=e.querySelector("img[data-gallery-src]");if(r)return r.getAttribute("data-gallery-src")||"";const i=Array.from(e.querySelectorAll("img[itemtype]")).map(o=>o.getAttribute("alt")||"").filter(Boolean);return i.length&&(n+=i.join("")),n.trim()}parseMessageElement(e,n=!1){const r=e.querySelector(n?".fui-ChatMyMessage__timestamp":".fui-ChatMessage__timestamp"),s=e.querySelector(n?".fui-ChatMyMessage__author":".fui-ChatMessage__author");if(!r)return null;const i=r.getAttribute("datetime");if(!i)return null;const o=Number.isNaN(r.id.replace("timestamp-",""))?new Date(i).getTime():Number(r.id.replace("timestamp-","")),l=document.querySelector(`#content-${o}`),{room_id:f,room_name:a}=this.getCurrentRoomInfo();return{name:s?.innerText,message:this._getMessageByEl(l),time:o,room_id:f,room_name:a,date_time:new Date(i).getTime()}}extractAllMessages(){const e=Array.from(document.querySelectorAll(".fui-ChatMyMessage")).map(r=>this.parseMessageElement(r,!0)).filter(r=>r!==null),n=Array.from(document.querySelectorAll(".fui-ChatMessage")).map(r=>this.parseMessageElement(r,!1)).filter(r=>r!==null);return console.log({myMessages:e,otherMessages:n}),[...e,...n].sort((r,s)=>r.time-s.time)}handleNewMessage(e){console.log("%c[New incoming message]","color: #007acc;",e)}async detectNewMessages(){const e=this.extractAllMessages(),n=e.findIndex(i=>i.time===this.lastMessage?.time),r=e.slice(n+1);if(r.length===0){console.log("[Monitor] No new messages...");return}const s=r[0];s.name===this.MY_NAME?(console.log("[Monitor] My new message:",s),await ce.sendSingleMessage(s)):(console.log("[Monitor] New incoming message:",s),this.handleNewMessage(s),ce.sendSingleMessage(s)),this.lastMessage=e.pop()}async start(e=1e4){console.log("[Monitor] Starting..."),this.initialHistories=this.extractAllMessages(),this.lastMessage=this.initialHistories.pop(),await ce.sendBulkMessages(this.initialHistories),setInterval(async()=>await this.detectNewMessages(),e)}async _getConversationsInfo(e=this.elTags.conatainer_conversations){const n=document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return n?Array.from(n.children).filter(i=>i.getAttribute("role")==="none").map(i=>{const o=i.id||null,l=`title-chat-list-item_${o}`,a=document.getElementById(l)?.innerText||null;let u=null;return o?.includes("@thread.skype")?u="group":o?.includes("@oneToOne.skype")?u="personal":u="group",{id:o,name:a,type:u}}):(console.log("Không tìm thấy phần tử theo XPath."),[])}async _scrollToBottomByXPath(e=this.elTags.container_scroll,n){const{maxStableRounds:r=5,delay:s=300,maxScrolls:i=100}=n||{},o=document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(!o){console.warn("❌ Không tìm thấy phần tử với XPath:",e);return}return new Promise(l=>{let f=-1,a=0,u=0;const d=setInterval(()=>{const m=o.scrollHeight;o.scrollTop=m,m===f?a++:(a=0,f=m),u++,(a>=r||u>=i)&&(clearInterval(d),l())},s)})}async handleGetConversations(){return await this._scrollToBottomByXPath(),this._getConversationsInfo()}}class Qn{axios=null;constructor(){this.axios=T.create({baseURL:"MyCoolApp",headers:{"Content-Type":"application/json"}})}async send(e){if(!this.axios)return null;const{data:n}=await this.axios({method:"POST",url:"type",data:{message:e}});return n}}const Fe=new Qn;function z(t){return new Promise(e=>setTimeout(e,t))}class Zn{service;port;constructor(e){this.service=new Yn,this.port=e}_forceHeightObserver;getElementByXPath(e){return document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}forceHeight(e,n="100px"){if(!e)return;e.style.setProperty("height",n,"important"),e.style.setProperty("resize","none","important");const r=()=>{e.style.setProperty("height",n,"important")};e.addEventListener("focus",r),e.addEventListener("input",r),e.addEventListener("blur",r);const s=new MutationObserver(()=>{e.style.setProperty("height",n,"important")});s.observe(e,{attributes:!0,attributeFilter:["style"]}),this._forceHeightObserver=s}_clickToConversation(e){const n=document.getElementById(`chat-list-item_${e}`);return n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>n.click(),200)),n?.click()}async _waitForMessagesToAppear(e=1e4){return new Promise((n,r)=>{const s=document.getElementById("chat-pane-list");let i=null;if(!s)return r(new Error("#chat-pane-list not found"));const o=()=>Array.from(s.children),l=()=>{const a=o();a.length>0&&(f.disconnect(),i&&clearTimeout(i),n(a))},f=new MutationObserver(()=>{l()});f.observe(s,{childList:!0,subtree:!0}),l(),i=setTimeout(()=>{f.disconnect(),r(new Error("Timeout waiting for chat messages to appear"))},e)})}async _waitForNewMessages(e,n=1e4){return new Promise((r,s)=>{const i=document.getElementById("chat-pane-list");if(!i)return s(new Error("#chat-pane-list not found"));const o=()=>Array.from(i.children),l=new Set(e);let f=null;const a=new MutationObserver(()=>{const d=o().filter(m=>!l.has(m));d.length>0&&(a.disconnect(),f&&clearTimeout(f),r(d))});a.observe(i,{childList:!0,subtree:!0}),f=setTimeout(()=>{a.disconnect(),s(new Error("Timeout waiting for new messages"))},n)})}async _waitToloadMessages(e=300){return new Promise(n=>{const r=document.getElementById("chat-pane-list");if(!r)throw new Error("#chat-pane-list not found");let s=null,i=[];const o=new MutationObserver(()=>{s&&clearTimeout(s),i=Array.from(r.children),s=setTimeout(()=>{o.disconnect(),n(i)},e)});o.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0})})}_getTypeGeo(){const e=document.querySelector(".ck-placeholder");if(e){const n=e.getBoundingClientRect();return{top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height}}return null}async _rightClickMessage(e){const n=this.service.elTags.container_chat,r=`content-${e}`,s=m=>document.evaluate(m,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,i=30,o=200;let l=0,f=s(n);if(!f){console.error("Wrapper not found:",n);return}let a=f.querySelector(`#${r}`);for(;!a&&l{const s=document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;s?(s.scrollIntoView({behavior:"auto",block:"center"}),setTimeout(()=>{s.click(),n(!0)},100)):(console.warn("Không tìm thấy phần tử:",e),n(!1))})}async getConversations(e){$.add(async()=>{console.log("[Queue] Handling GET_CONVERSATIONS");const n=await this.service.handleGetConversations();this.port.postMessage({type:"socket-response",event:L.RECEIVE_CONVERSATIONS,data:n})})}async getConversation(e){$.add(async()=>{if(console.log("[Queue] Handling GET_CONVERSATION"),!e.data?.id)return;const{room_id:n}=this.service.getCurrentRoomInfo();n!=e.data.id&&(this._clickToConversation(e.data.id),await this._waitForMessagesToAppear(),await this._waitToloadMessages());const r=this.service.extractAllMessages();this.port.postMessage({type:"socket-response",event:L.RECEIVE_CONVERSATION,data:r})})}async sendMessage({data:{conversation_id:e,message:n}}){$.add(async()=>{console.log("[Queue] Handling SEND_MESSAGE");const{room_id:r}=this.service.getCurrentRoomInfo();r!=e&&this._clickToConversation(e),await z(200),await Fe.send(n)})}async replyMessage({data:{conversation_id:e,message:n,time:r}}){$.add(async()=>{console.log("[Queue] Handling REPLY_MESSAGE");const{room_id:s}=this.service.getCurrentRoomInfo();s!=e&&(this._clickToConversation(e),await this._waitForMessagesToAppear(),await this._waitToloadMessages()),this._clickIfExists(this.service.elTags.close_reply_btn),await this._rightClickMessage(r);const i=document.querySelector(this.service.elTags.reply_btn);i&&i.click(),await z(200),console.log({message:n}),await Fe.send(n)})}fixedHeightChatInput(e=20,n=1e3){(()=>{const s=this.getElementByXPath(this.service.elTags.chat_input);s?(this.forceHeight(s,"100px"),console.log("✔ Fixed height applied to chat input")):e>0?setTimeout(()=>this.fixedHeightChatInput(e-1,n),n):console.warn("✘ Element not found with provided XPath after retries")})()}}const lt=chrome.runtime.connect({name:"message"}),U=new Zn(lt);lt.onMessage.addListener(t=>{if(console.log({msg:t}),U.fixedHeightChatInput(),t.type==="socket")switch(t.event){case L.GET_CONVERSATIONS:{U.getConversations(t);break}case L.GET_CONVERSATION:{U.getConversation(t);break}case L.SEND_MESSAGE:{U.sendMessage(t);break}case L.REPLY_MESSAGE:{U.replyMessage(t);break}}}); +`+i):r.stack=i}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=k(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&K.assertOptions(r,{silentJSONParsing:x.transitional(x.boolean),forcedJSONParsing:x.transitional(x.boolean),clarifyTimeoutError:x.transitional(x.boolean)},!1),s!=null&&(c.isFunction(s)?n.paramsSerializer={serialize:s}:K.assertOptions(s,{encode:x.function,serialize:x.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),K.assertOptions(n,{baseUrl:x.spelling("baseURL"),withXsrfToken:x.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&c.merge(i.common,i[n.method]);i&&c.forEach(["delete","get","head","post","put","patch","common"],p=>{delete i[p]}),n.headers=O.concat(o,i);const l=[];let f=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(n)===!1||(f=f&&y.synchronous,l.unshift(y.fulfilled,y.rejected))});const a=[];this.interceptors.response.forEach(function(y){a.push(y.fulfilled,y.rejected)});let u,d=0,m;if(!f){const p=[Me.bind(this),void 0];for(p.unshift.apply(p,l),p.push.apply(p,a),m=p.length,u=Promise.resolve(n);d{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(l=>{r.subscribe(l),i=l}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,l){r.reason||(r.reason=new D(i,o,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new at(function(s){e=s}),cancel:e}}};function Kn(t){return function(n){return t.apply(null,n)}}function Wn(t){return c.isObject(t)&&t.isAxiosError===!0}const pe={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};Object.entries(pe).forEach(([t,e])=>{pe[e]=t});function ct(t){const e=new M(t),n=Be(M.prototype.request,e);return c.extend(n,M.prototype,e,{allOwnKeys:!0}),c.extend(n,e,null,{allOwnKeys:!0}),n.create=function(s){return ct(k(t,s))},n}const T=ct(H);T.Axios=M;T.CanceledError=D;T.CancelToken=Xn;T.isCancel=Ze;T.VERSION=ot;T.toFormData=te;T.AxiosError=w;T.Cancel=T.CanceledError;T.all=function(e){return Promise.all(e)};T.spread=Kn;T.isAxiosError=Wn;T.mergeConfig=k;T.AxiosHeaders=O;T.formToJSON=t=>Qe(c.isHTMLForm(t)?new FormData(t):t);T.getAdapter=it.getAdapter;T.HttpStatusCode=pe;T.default=T;const{Axios:nr,AxiosError:rr,CanceledError:sr,isCancel:ir,CancelToken:or,VERSION:ar,all:cr,Cancel:lr,isAxiosError:ur,spread:fr,toFormData:dr,AxiosHeaders:hr,HttpStatusCode:pr,formToJSON:mr,getAdapter:yr,mergeConfig:gr}=T,Le=T.create({baseURL:"https://notable-recently-seagull.ngrok-free.app/api/v1/",headers:{"Content-Type":"application/json"}});class Gn{async sendSingleMessage(e){try{const{data:n}=await Le.post("/messages",e);return console.log("[NestJS] Response (single):",n),n}catch(n){throw console.error("[NestJS] Error (single):",n),n}}async sendBulkMessages(e){try{const{data:n}=await Le.post("/messages/bulk",{data:e});return console.log("[NestJS] Response (bulk):",n),n}catch(n){throw console.error("[NestJS] Error (bulk):",n),n}}}const ce=new Gn;class Yn{MY_NAME="Apactech com";lastMessage;initialHistories=[];elTags={container_scroll:"/html/body/div[1]/div/div/div/div[5]/div[1]/div[1]/div[2]/div[1]/div[1]/div",conatainer_conversations:"/html/body/div[1]/div/div/div/div[5]/div[1]/div[1]/div[2]/div[1]/div[1]/div/div[1]",container_chat:"/html/body/div[1]/div/div/div/div[6]/div[4]/div/div[1]/div/div[1]/div/div/div/div[1]/div/div/div[4]",root_id:'[aria-selected="true"] [id^="chat-list-item"]',room_name:'[data-tid="chat-title"]',close_reply_btn:"/html/body/div[1]/div/div/div/div[6]/div[4]/div/div[1]/div/div[3]/div/div[3]/div/div[2]/div/div[2]/div/div/card/div/div/div[2]/div/div[1]/button",reply_btn:'[aria-label="Reply"]',chat_input:"/html/body/div[1]/div/div/div/div[6]/div/div[4]/div/div[1]/div/div[3]/div/div[3]/div/div[2]/div/div[2]/div[1]/div"};getCurrentRoomInfo(){const e=document.querySelector(this.elTags.root_id)?.id?.replace("chat-list-item_",""),n=document.querySelector(this.elTags.room_name)?.innerText;return{room_id:e,room_name:n}}_getMessageByEl(e){if(!e)return"";let n=e.innerText||"";const r=e.querySelector("img[data-gallery-src]");if(r)return r.getAttribute("data-gallery-src")||"";const i=Array.from(e.querySelectorAll("img[itemtype]")).map(o=>o.getAttribute("alt")||"").filter(Boolean);return i.length&&(n+=i.join("")),n.trim()}parseMessageElement(e,n=!1){const r=e.querySelector(n?".fui-ChatMyMessage__timestamp":".fui-ChatMessage__timestamp"),s=e.querySelector(n?".fui-ChatMyMessage__author":".fui-ChatMessage__author");if(!r)return null;const i=r.getAttribute("datetime");if(!i)return null;const o=Number.isNaN(r.id.replace("timestamp-",""))?new Date(i).getTime():Number(r.id.replace("timestamp-","")),l=document.querySelector(`#content-${o}`),{room_id:f,room_name:a}=this.getCurrentRoomInfo();return{name:s?.innerText,message:this._getMessageByEl(l),time:o,room_id:f,room_name:a,date_time:new Date(i).getTime()}}extractAllMessages(){const e=Array.from(document.querySelectorAll(".fui-ChatMyMessage")).map(r=>this.parseMessageElement(r,!0)).filter(r=>r!==null),n=Array.from(document.querySelectorAll(".fui-ChatMessage")).map(r=>this.parseMessageElement(r,!1)).filter(r=>r!==null);return console.log({myMessages:e,otherMessages:n}),[...e,...n].sort((r,s)=>r.time-s.time)}handleNewMessage(e){console.log("%c[New incoming message]","color: #007acc;",e)}async detectNewMessages(){const e=this.extractAllMessages(),n=e.findIndex(i=>i.time===this.lastMessage?.time),r=e.slice(n+1);if(r.length===0){console.log("[Monitor] No new messages...");return}const s=r[0];s.name===this.MY_NAME?(console.log("[Monitor] My new message:",s),await ce.sendSingleMessage(s)):(console.log("[Monitor] New incoming message:",s),this.handleNewMessage(s),ce.sendSingleMessage(s)),this.lastMessage=e.pop()}async start(e=1e4){console.log("[Monitor] Starting..."),this.initialHistories=this.extractAllMessages(),this.lastMessage=this.initialHistories.pop(),await ce.sendBulkMessages(this.initialHistories),setInterval(async()=>await this.detectNewMessages(),e)}async _getConversationsInfo(e=this.elTags.conatainer_conversations){const n=document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return n?Array.from(n.children).filter(i=>i.getAttribute("role")==="none").map(i=>{const o=i.id||null,l=`title-chat-list-item_${o}`,a=document.getElementById(l)?.innerText||null;let u=null;return o?.includes("@thread.skype")?u="group":o?.includes("@oneToOne.skype")?u="personal":u="group",{id:o,name:a,type:u}}):(console.log("Không tìm thấy phần tử theo XPath."),[])}async _scrollToBottomByXPath(e=this.elTags.container_scroll,n){const{maxStableRounds:r=5,delay:s=300,maxScrolls:i=100}=n||{},o=document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(!o){console.warn("❌ Không tìm thấy phần tử với XPath:",e);return}return new Promise(l=>{let f=-1,a=0,u=0;const d=setInterval(()=>{const m=o.scrollHeight;o.scrollTop=m,m===f?a++:(a=0,f=m),u++,(a>=r||u>=i)&&(clearInterval(d),l())},s)})}async handleGetConversations(){return await this._scrollToBottomByXPath(),this._getConversationsInfo()}}class Qn{axios=null;constructor(){this.axios=T.create({baseURL:"MyCoolApp",headers:{"Content-Type":"application/json"}})}async send(e){if(!this.axios)return null;const{data:n}=await this.axios({method:"POST",url:"type",data:{message:e}});return n}}const Fe=new Qn;function z(t){return new Promise(e=>setTimeout(e,t))}class Zn{service;port;constructor(e){this.service=new Yn,this.port=e}_forceHeightObserver;getElementByXPath(e){return document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}forceHeight(e,n="100px"){if(!e)return;e.style.setProperty("height",n,"important"),e.style.setProperty("resize","none","important");const r=()=>{e.style.setProperty("height",n,"important")};e.addEventListener("focus",r),e.addEventListener("input",r),e.addEventListener("blur",r);const s=new MutationObserver(()=>{e.style.setProperty("height",n,"important")});s.observe(e,{attributes:!0,attributeFilter:["style"]}),this._forceHeightObserver=s}_clickToConversation(e){const n=document.getElementById(`chat-list-item_${e}`);return n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>n.click(),200)),n?.click()}async _waitForMessagesToAppear(e=1e4){return new Promise((n,r)=>{const s=document.getElementById("chat-pane-list");let i=null;if(!s)return r(new Error("#chat-pane-list not found"));const o=()=>Array.from(s.children),l=()=>{const a=o();a.length>0&&(f.disconnect(),i&&clearTimeout(i),n(a))},f=new MutationObserver(()=>{l()});f.observe(s,{childList:!0,subtree:!0}),l(),i=setTimeout(()=>{f.disconnect(),r(new Error("Timeout waiting for chat messages to appear"))},e)})}async _waitForNewMessages(e,n=1e4){return new Promise((r,s)=>{const i=document.getElementById("chat-pane-list");if(!i)return s(new Error("#chat-pane-list not found"));const o=()=>Array.from(i.children),l=new Set(e);let f=null;const a=new MutationObserver(()=>{const d=o().filter(m=>!l.has(m));d.length>0&&(a.disconnect(),f&&clearTimeout(f),r(d))});a.observe(i,{childList:!0,subtree:!0}),f=setTimeout(()=>{a.disconnect(),s(new Error("Timeout waiting for new messages"))},n)})}async _waitToloadMessages(e=300){return new Promise(n=>{const r=document.getElementById("chat-pane-list");if(!r)throw new Error("#chat-pane-list not found");let s=null,i=[];const o=new MutationObserver(()=>{s&&clearTimeout(s),i=Array.from(r.children),s=setTimeout(()=>{o.disconnect(),n(i)},e)});o.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0})})}_getTypeGeo(){const e=document.querySelector(".ck-placeholder");if(e){const n=e.getBoundingClientRect();return{top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height}}return null}async _rightClickMessage(e){const n=this.service.elTags.container_chat,r=`content-${e}`,s=m=>document.evaluate(m,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,i=30,o=200;let l=0,f=s(n);if(!f){console.error("Wrapper not found:",n);return}let a=f.querySelector(`#${r}`);for(;!a&&l{const s=document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;s?(s.scrollIntoView({behavior:"auto",block:"center"}),setTimeout(()=>{s.click(),n(!0)},100)):(console.warn("Không tìm thấy phần tử:",e),n(!1))})}async getConversations(e){$.add(async()=>{console.log("[Queue] Handling GET_CONVERSATIONS");const n=await this.service.handleGetConversations();this.port.postMessage({type:"socket-response",event:L.RECEIVE_CONVERSATIONS,data:n})})}async getConversation(e){$.add(async()=>{if(console.log("[Queue] Handling GET_CONVERSATION"),!e.data?.id)return;const{room_id:n}=this.service.getCurrentRoomInfo();n!=e.data.id&&(this._clickToConversation(e.data.id),await this._waitForMessagesToAppear(),await this._waitToloadMessages());const r=this.service.extractAllMessages();this.port.postMessage({type:"socket-response",event:L.RECEIVE_CONVERSATION,data:r})})}async sendMessage({data:{conversation_id:e,message:n}}){$.add(async()=>{console.log("[Queue] Handling SEND_MESSAGE");const{room_id:r}=this.service.getCurrentRoomInfo();r!=e&&this._clickToConversation(e),await z(200),await Fe.send(n)})}async replyMessage({data:{conversation_id:e,message:n,time:r}}){$.add(async()=>{console.log("[Queue] Handling REPLY_MESSAGE");const{room_id:s}=this.service.getCurrentRoomInfo();s!=e&&(this._clickToConversation(e),await this._waitForMessagesToAppear(),await this._waitToloadMessages()),this._clickIfExists(this.service.elTags.close_reply_btn),await this._rightClickMessage(r);const i=document.querySelector(this.service.elTags.reply_btn);i&&i.click(),await z(200),console.log({message:n}),await Fe.send(n)})}fixedHeightChatInput(e=20,n=1e3){(()=>{const s=this.getElementByXPath(this.service.elTags.chat_input);s?(this.forceHeight(s,"100px"),console.log("✔ Fixed height applied to chat input")):e>0?setTimeout(()=>this.fixedHeightChatInput(e-1,n),n):console.warn("✘ Element not found with provided XPath after retries")})()}}const lt=chrome.runtime.connect({name:"message"}),U=new Zn(lt);lt.onMessage.addListener(t=>{if(console.log({msg:t}),U.fixedHeightChatInput(),t.type==="socket")switch(t.event){case L.GET_CONVERSATIONS:{U.getConversations(t);break}case L.GET_CONVERSATION:{U.getConversation(t);break}case L.SEND_MESSAGE:{U.sendMessage(t);break}case L.REPLY_MESSAGE:{U.replyMessage(t);break}}});