mezon-light-sdk 1.0.7 → 1.0.8
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.cjs.js +1 -1
- package/dist/index.esm.mjs +1 -1
- package/dist/src/api.gen.d.ts +3 -0
- package/dist/src/api.gen.d.ts.map +1 -1
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/session.d.ts +3 -2
- package/dist/src/session.d.ts.map +1 -1
- package/dist/src/types.d.ts +2 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var An=Object.create;var se=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var Mn=Object.getOwnPropertyNames,Fe=Object.getOwnPropertySymbols,In=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable;var Ke=(e,n,t)=>n in e?se(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,xe=(e,n)=>{for(var t in n||(n={}))Ye.call(n,t)&&Ke(e,t,n[t]);if(Fe)for(var t of Fe(n))Nn.call(n,t)&&Ke(e,t,n[t]);return e};var Rn=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},Ge=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of Mn(n))!Ye.call(e,a)&&a!==t&&se(e,a,{get:()=>n[a],enumerable:!(r=xn(n,a))||r.enumerable});return e};var D=(e,n,t)=>(t=e!=null?An(In(e)):{},Ge(n||!e||!e.__esModule?se(t,"default",{value:e,enumerable:!0}):t,e)),On=e=>Ge(se({},"__esModule",{value:!0}),e);var g=(e,n,t)=>new Promise((r,a)=>{var i=c=>{try{l(t.next(c))}catch(d){a(d)}},o=c=>{try{l(t.throw(c))}catch(d){a(d)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);l((t=t.apply(e,n)).next())});var Bn={};Rn(Bn,{AuthenticationError:()=>X,CHANNEL_TYPE_DM:()=>U,CHANNEL_TYPE_GROUP:()=>L,CLAN_DM:()=>A,DEFAULT_SERVER_KEY:()=>J,LightClient:()=>Ee,LightSocket:()=>Ae,MEZON_GW_URL:()=>pe,SOCKET_READY_MAX_RETRY:()=>me,SOCKET_READY_RETRY_DELAY:()=>ge,STREAM_MODE_DM:()=>ye,STREAM_MODE_GROUP:()=>ke,SessionError:()=>he,SocketError:()=>O});module.exports=On(Bn);var pe="https://gw.mezon.ai",me=20,ge=100,A="0",U=3,L=2,ye=4,ke=3,J="DefaultServerKey";var Me=D(require("js-base64")),oe=class e{constructor(n,t,r,a,i,o){this.created=r;this.api_url=a;this.id_token=i;this.token=n,this.refresh_token=t,this.id_token=i,this.api_url=a,this.created_at=Math.floor(new Date().getTime()/1e3),this.is_remember=o,this.update(n,t,o)}isexpired(n){return this.expires_at-n<=0}isrefreshexpired(n){return this.refresh_expires_at-n<=0}update(n,t,r){let a=n.split(".");if(a.length!=3)throw"jwt is not valid.";let i=JSON.parse(Me.atob(a[1])),o=Math.floor(parseInt(i.exp));if(t){let l=t.split(".");if(l.length!=3)throw"refresh jwt is not valid.";let c=JSON.parse(Me.atob(l[1])),d=Math.floor(parseInt(c.exp));this.refresh_expires_at=d,this.refresh_token=t,this.is_remember=r}this.token=n,this.expires_at=o,this.username=i.usn,this.user_id=i.uid,this.vars=i.vrs}static restore(n,t,r,a){return new e(n,t,!1,r,"",a)}};var Ie=D(require("long")),f=D(require("protobufjs/minimal"));function Xe(){return{created:!1,token:"",refresh_token:"",user_id:"0",is_remember:!1,api_url:"",id_token:""}}var Re={encode(e,n=f.default.Writer.create()){return e.created!==!1&&n.uint32(8).bool(e.created),e.token!==""&&n.uint32(18).string(e.token),e.refresh_token!==""&&n.uint32(26).string(e.refresh_token),e.user_id!=="0"&&n.uint32(32).int64(e.user_id),e.is_remember!==!1&&n.uint32(40).bool(e.is_remember),e.api_url!==""&&n.uint32(50).string(e.api_url),e.id_token!==""&&n.uint32(58).string(e.id_token),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Xe();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.created=t.bool();continue;case 2:if(i!==18)break;a.token=t.string();continue;case 3:if(i!==26)break;a.refresh_token=t.string();continue;case 4:if(i!==32)break;a.user_id=m(t.int64());continue;case 5:if(i!==40)break;a.is_remember=t.bool();continue;case 6:if(i!==50)break;a.api_url=t.string();continue;case 7:if(i!==58)break;a.id_token=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{created:s(e.created)?globalThis.Boolean(e.created):!1,token:s(e.token)?globalThis.String(e.token):"",refresh_token:s(e.refresh_token)?globalThis.String(e.refresh_token):"",user_id:s(e.user_id)?globalThis.String(e.user_id):"0",is_remember:s(e.is_remember)?globalThis.Boolean(e.is_remember):!1,api_url:s(e.api_url)?globalThis.String(e.api_url):"",id_token:s(e.id_token)?globalThis.String(e.id_token):""}},toJSON(e){let n={};return e.created!==!1&&(n.created=e.created),e.token!==""&&(n.token=e.token),e.refresh_token!==""&&(n.refresh_token=e.refresh_token),e.user_id!=="0"&&(n.user_id=e.user_id),e.is_remember!==!1&&(n.is_remember=e.is_remember),e.api_url!==""&&(n.api_url=e.api_url),e.id_token!==""&&(n.id_token=e.id_token),n},create(e){return Re.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c;let n=Xe();return n.created=(t=e.created)!=null?t:!1,n.token=(r=e.token)!=null?r:"",n.refresh_token=(a=e.refresh_token)!=null?a:"",n.user_id=(i=e.user_id)!=null?i:"0",n.is_remember=(o=e.is_remember)!=null?o:!1,n.api_url=(l=e.api_url)!=null?l:"",n.id_token=(c=e.id_token)!=null?c:"",n}};function Ze(){return{token:"",vars:{},is_remember:!1}}var Se={encode(e,n=f.default.Writer.create()){return e.token!==""&&n.uint32(10).string(e.token),Object.entries(e.vars).forEach(([t,r])=>{Ne.encode({key:t,value:r},n.uint32(18).fork()).ldelim()}),e.is_remember!==!1&&n.uint32(24).bool(e.is_remember),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Ze();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.token=t.string();continue;case 2:if(i!==18)break;let o=Ne.decode(t,t.uint32());o.value!==void 0&&(a.vars[o.key]=o.value);continue;case 3:if(i!==24)break;a.is_remember=t.bool();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{token:s(e.token)?globalThis.String(e.token):"",vars:Dn(e.vars)?Object.entries(e.vars).reduce((n,[t,r])=>(n[t]=String(r),n),{}):{},is_remember:s(e.is_remember)?globalThis.Boolean(e.is_remember):!1}},toJSON(e){let n={};if(e.token!==""&&(n.token=e.token),e.vars){let t=Object.entries(e.vars);t.length>0&&(n.vars={},t.forEach(([r,a])=>{n.vars[r]=a}))}return e.is_remember!==!1&&(n.is_remember=e.is_remember),n},create(e){return Se.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a;let n=Ze();return n.token=(t=e.token)!=null?t:"",n.vars=Object.entries((r=e.vars)!=null?r:{}).reduce((i,[o,l])=>(l!==void 0&&(i[o]=globalThis.String(l)),i),{}),n.is_remember=(a=e.is_remember)!=null?a:!1,n}};function $e(){return{key:"",value:""}}var Ne={encode(e,n=f.default.Writer.create()){return e.key!==""&&n.uint32(10).string(e.key),e.value!==""&&n.uint32(18).string(e.value),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=$e();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.key=t.string();continue;case 2:if(i!==18)break;a.value=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{key:s(e.key)?globalThis.String(e.key):"",value:s(e.value)?globalThis.String(e.value):""}},toJSON(e){let n={};return e.key!==""&&(n.key=e.key),e.value!==""&&(n.value=e.value),n},create(e){return Ne.fromPartial(e!=null?e:{})},fromPartial(e){var t,r;let n=$e();return n.key=(t=e.key)!=null?t:"",n.value=(r=e.value)!=null?r:"",n}};function Qe(){return{clan_id:"0",parent_id:"0",channel_id:"0",category_id:"0",type:0,channel_label:"",channel_private:0,user_ids:[],app_id:"0"}}var ve={encode(e,n=f.default.Writer.create()){e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.parent_id!=="0"&&n.uint32(16).int64(e.parent_id),e.channel_id!=="0"&&n.uint32(24).int64(e.channel_id),e.category_id!=="0"&&n.uint32(32).int64(e.category_id),e.type!==0&&n.uint32(40).int32(e.type),e.channel_label!==""&&n.uint32(50).string(e.channel_label),e.channel_private!==0&&n.uint32(56).int32(e.channel_private),n.uint32(66).fork();for(let t of e.user_ids)n.int64(t);return n.ldelim(),e.app_id!=="0"&&n.uint32(72).int64(e.app_id),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Qe();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=m(t.int64());continue;case 2:if(i!==16)break;a.parent_id=m(t.int64());continue;case 3:if(i!==24)break;a.channel_id=m(t.int64());continue;case 4:if(i!==32)break;a.category_id=m(t.int64());continue;case 5:if(i!==40)break;a.type=t.int32();continue;case 6:if(i!==50)break;a.channel_label=t.string();continue;case 7:if(i!==56)break;a.channel_private=t.int32();continue;case 8:if(i===64){a.user_ids.push(m(t.int64()));continue}if(i===66){let o=t.uint32()+t.pos;for(;t.pos<o;)a.user_ids.push(m(t.int64()));continue}break;case 9:if(i!==72)break;a.app_id=m(t.int64());continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:s(e.clan_id)?globalThis.String(e.clan_id):"0",parent_id:s(e.parent_id)?globalThis.String(e.parent_id):"0",channel_id:s(e.channel_id)?globalThis.String(e.channel_id):"0",category_id:s(e.category_id)?globalThis.String(e.category_id):"0",type:s(e.type)?globalThis.Number(e.type):0,channel_label:s(e.channel_label)?globalThis.String(e.channel_label):"",channel_private:s(e.channel_private)?globalThis.Number(e.channel_private):0,user_ids:globalThis.Array.isArray(e==null?void 0:e.user_ids)?e.user_ids.map(n=>globalThis.String(n)):[],app_id:s(e.app_id)?globalThis.String(e.app_id):"0"}},toJSON(e){var t;let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.parent_id!=="0"&&(n.parent_id=e.parent_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.category_id!=="0"&&(n.category_id=e.category_id),e.type!==0&&(n.type=Math.round(e.type)),e.channel_label!==""&&(n.channel_label=e.channel_label),e.channel_private!==0&&(n.channel_private=Math.round(e.channel_private)),(t=e.user_ids)!=null&&t.length&&(n.user_ids=e.user_ids),e.app_id!=="0"&&(n.app_id=e.app_id),n},create(e){return ve.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_;let n=Qe();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.parent_id=(r=e.parent_id)!=null?r:"0",n.channel_id=(a=e.channel_id)!=null?a:"0",n.category_id=(i=e.category_id)!=null?i:"0",n.type=(o=e.type)!=null?o:0,n.channel_label=(l=e.channel_label)!=null?l:"",n.channel_private=(c=e.channel_private)!=null?c:0,n.user_ids=((d=e.user_ids)==null?void 0:d.map(p=>p))||[],n.app_id=(_=e.app_id)!=null?_:"0",n}};function je(){return{clan_id:"0",parent_id:"0",channel_id:"0",category_id:"0",category_name:"",type:0,creator_id:"0",channel_label:"",channel_private:0,avatars:[],user_ids:[],last_sent_message:void 0,last_seen_message:void 0,onlines:[],meeting_code:"",count_mess_unread:0,active:0,last_pin_message:"",usernames:[],creator_name:"",create_time_seconds:0,update_time_seconds:0,display_names:[],channel_avatar:"",clan_name:"",app_id:"0",is_mute:!1,age_restricted:0,topic:"",e2ee:0,member_count:0}}var Oe={encode(e,n=f.default.Writer.create()){e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.parent_id!=="0"&&n.uint32(16).int64(e.parent_id),e.channel_id!=="0"&&n.uint32(24).int64(e.channel_id),e.category_id!=="0"&&n.uint32(32).int64(e.category_id),e.category_name!==""&&n.uint32(42).string(e.category_name),e.type!==0&&n.uint32(48).int32(e.type),e.creator_id!=="0"&&n.uint32(56).int64(e.creator_id),e.channel_label!==""&&n.uint32(66).string(e.channel_label),e.channel_private!==0&&n.uint32(72).int32(e.channel_private);for(let t of e.avatars)n.uint32(82).string(t);n.uint32(90).fork();for(let t of e.user_ids)n.int64(t);n.ldelim(),e.last_sent_message!==void 0&&S.encode(e.last_sent_message,n.uint32(98).fork()).ldelim(),e.last_seen_message!==void 0&&S.encode(e.last_seen_message,n.uint32(106).fork()).ldelim(),n.uint32(114).fork();for(let t of e.onlines)n.bool(t);n.ldelim(),e.meeting_code!==""&&n.uint32(122).string(e.meeting_code),e.count_mess_unread!==0&&n.uint32(128).int32(e.count_mess_unread),e.active!==0&&n.uint32(136).int32(e.active),e.last_pin_message!==""&&n.uint32(146).string(e.last_pin_message);for(let t of e.usernames)n.uint32(154).string(t);e.creator_name!==""&&n.uint32(162).string(e.creator_name),e.create_time_seconds!==0&&n.uint32(168).uint32(e.create_time_seconds),e.update_time_seconds!==0&&n.uint32(176).uint32(e.update_time_seconds);for(let t of e.display_names)n.uint32(186).string(t);return e.channel_avatar!==""&&n.uint32(194).string(e.channel_avatar),e.clan_name!==""&&n.uint32(202).string(e.clan_name),e.app_id!=="0"&&n.uint32(208).int64(e.app_id),e.is_mute!==!1&&n.uint32(216).bool(e.is_mute),e.age_restricted!==0&&n.uint32(224).int32(e.age_restricted),e.topic!==""&&n.uint32(234).string(e.topic),e.e2ee!==0&&n.uint32(240).int32(e.e2ee),e.member_count!==0&&n.uint32(248).int32(e.member_count),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=je();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=m(t.int64());continue;case 2:if(i!==16)break;a.parent_id=m(t.int64());continue;case 3:if(i!==24)break;a.channel_id=m(t.int64());continue;case 4:if(i!==32)break;a.category_id=m(t.int64());continue;case 5:if(i!==42)break;a.category_name=t.string();continue;case 6:if(i!==48)break;a.type=t.int32();continue;case 7:if(i!==56)break;a.creator_id=m(t.int64());continue;case 8:if(i!==66)break;a.channel_label=t.string();continue;case 9:if(i!==72)break;a.channel_private=t.int32();continue;case 10:if(i!==82)break;a.avatars.push(t.string());continue;case 11:if(i===88){a.user_ids.push(m(t.int64()));continue}if(i===90){let o=t.uint32()+t.pos;for(;t.pos<o;)a.user_ids.push(m(t.int64()));continue}break;case 12:if(i!==98)break;a.last_sent_message=S.decode(t,t.uint32());continue;case 13:if(i!==106)break;a.last_seen_message=S.decode(t,t.uint32());continue;case 14:if(i===112){a.onlines.push(t.bool());continue}if(i===114){let o=t.uint32()+t.pos;for(;t.pos<o;)a.onlines.push(t.bool());continue}break;case 15:if(i!==122)break;a.meeting_code=t.string();continue;case 16:if(i!==128)break;a.count_mess_unread=t.int32();continue;case 17:if(i!==136)break;a.active=t.int32();continue;case 18:if(i!==146)break;a.last_pin_message=t.string();continue;case 19:if(i!==154)break;a.usernames.push(t.string());continue;case 20:if(i!==162)break;a.creator_name=t.string();continue;case 21:if(i!==168)break;a.create_time_seconds=t.uint32();continue;case 22:if(i!==176)break;a.update_time_seconds=t.uint32();continue;case 23:if(i!==186)break;a.display_names.push(t.string());continue;case 24:if(i!==194)break;a.channel_avatar=t.string();continue;case 25:if(i!==202)break;a.clan_name=t.string();continue;case 26:if(i!==208)break;a.app_id=m(t.int64());continue;case 27:if(i!==216)break;a.is_mute=t.bool();continue;case 28:if(i!==224)break;a.age_restricted=t.int32();continue;case 29:if(i!==234)break;a.topic=t.string();continue;case 30:if(i!==240)break;a.e2ee=t.int32();continue;case 31:if(i!==248)break;a.member_count=t.int32();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:s(e.clan_id)?globalThis.String(e.clan_id):"0",parent_id:s(e.parent_id)?globalThis.String(e.parent_id):"0",channel_id:s(e.channel_id)?globalThis.String(e.channel_id):"0",category_id:s(e.category_id)?globalThis.String(e.category_id):"0",category_name:s(e.category_name)?globalThis.String(e.category_name):"",type:s(e.type)?globalThis.Number(e.type):0,creator_id:s(e.creator_id)?globalThis.String(e.creator_id):"0",channel_label:s(e.channel_label)?globalThis.String(e.channel_label):"",channel_private:s(e.channel_private)?globalThis.Number(e.channel_private):0,avatars:globalThis.Array.isArray(e==null?void 0:e.avatars)?e.avatars.map(n=>globalThis.String(n)):[],user_ids:globalThis.Array.isArray(e==null?void 0:e.user_ids)?e.user_ids.map(n=>globalThis.String(n)):[],last_sent_message:s(e.last_sent_message)?S.fromJSON(e.last_sent_message):void 0,last_seen_message:s(e.last_seen_message)?S.fromJSON(e.last_seen_message):void 0,onlines:globalThis.Array.isArray(e==null?void 0:e.onlines)?e.onlines.map(n=>globalThis.Boolean(n)):[],meeting_code:s(e.meeting_code)?globalThis.String(e.meeting_code):"",count_mess_unread:s(e.count_mess_unread)?globalThis.Number(e.count_mess_unread):0,active:s(e.active)?globalThis.Number(e.active):0,last_pin_message:s(e.last_pin_message)?globalThis.String(e.last_pin_message):"",usernames:globalThis.Array.isArray(e==null?void 0:e.usernames)?e.usernames.map(n=>globalThis.String(n)):[],creator_name:s(e.creator_name)?globalThis.String(e.creator_name):"",create_time_seconds:s(e.create_time_seconds)?globalThis.Number(e.create_time_seconds):0,update_time_seconds:s(e.update_time_seconds)?globalThis.Number(e.update_time_seconds):0,display_names:globalThis.Array.isArray(e==null?void 0:e.display_names)?e.display_names.map(n=>globalThis.String(n)):[],channel_avatar:s(e.channel_avatar)?globalThis.String(e.channel_avatar):"",clan_name:s(e.clan_name)?globalThis.String(e.clan_name):"",app_id:s(e.app_id)?globalThis.String(e.app_id):"0",is_mute:s(e.is_mute)?globalThis.Boolean(e.is_mute):!1,age_restricted:s(e.age_restricted)?globalThis.Number(e.age_restricted):0,topic:s(e.topic)?globalThis.String(e.topic):"",e2ee:s(e.e2ee)?globalThis.Number(e.e2ee):0,member_count:s(e.member_count)?globalThis.Number(e.member_count):0}},toJSON(e){var t,r,a,i,o;let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.parent_id!=="0"&&(n.parent_id=e.parent_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.category_id!=="0"&&(n.category_id=e.category_id),e.category_name!==""&&(n.category_name=e.category_name),e.type!==0&&(n.type=Math.round(e.type)),e.creator_id!=="0"&&(n.creator_id=e.creator_id),e.channel_label!==""&&(n.channel_label=e.channel_label),e.channel_private!==0&&(n.channel_private=Math.round(e.channel_private)),(t=e.avatars)!=null&&t.length&&(n.avatars=e.avatars),(r=e.user_ids)!=null&&r.length&&(n.user_ids=e.user_ids),e.last_sent_message!==void 0&&(n.last_sent_message=S.toJSON(e.last_sent_message)),e.last_seen_message!==void 0&&(n.last_seen_message=S.toJSON(e.last_seen_message)),(a=e.onlines)!=null&&a.length&&(n.onlines=e.onlines),e.meeting_code!==""&&(n.meeting_code=e.meeting_code),e.count_mess_unread!==0&&(n.count_mess_unread=Math.round(e.count_mess_unread)),e.active!==0&&(n.active=Math.round(e.active)),e.last_pin_message!==""&&(n.last_pin_message=e.last_pin_message),(i=e.usernames)!=null&&i.length&&(n.usernames=e.usernames),e.creator_name!==""&&(n.creator_name=e.creator_name),e.create_time_seconds!==0&&(n.create_time_seconds=Math.round(e.create_time_seconds)),e.update_time_seconds!==0&&(n.update_time_seconds=Math.round(e.update_time_seconds)),(o=e.display_names)!=null&&o.length&&(n.display_names=e.display_names),e.channel_avatar!==""&&(n.channel_avatar=e.channel_avatar),e.clan_name!==""&&(n.clan_name=e.clan_name),e.app_id!=="0"&&(n.app_id=e.app_id),e.is_mute!==!1&&(n.is_mute=e.is_mute),e.age_restricted!==0&&(n.age_restricted=Math.round(e.age_restricted)),e.topic!==""&&(n.topic=e.topic),e.e2ee!==0&&(n.e2ee=Math.round(e.e2ee)),e.member_count!==0&&(n.member_count=Math.round(e.member_count)),n},create(e){return Oe.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p,y,M,I,N,C,Z,$,Q,j,ee,ne,te,ie,ae,re,qe,we,Ve,ze;let n=je();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.parent_id=(r=e.parent_id)!=null?r:"0",n.channel_id=(a=e.channel_id)!=null?a:"0",n.category_id=(i=e.category_id)!=null?i:"0",n.category_name=(o=e.category_name)!=null?o:"",n.type=(l=e.type)!=null?l:0,n.creator_id=(c=e.creator_id)!=null?c:"0",n.channel_label=(d=e.channel_label)!=null?d:"",n.channel_private=(_=e.channel_private)!=null?_:0,n.avatars=((p=e.avatars)==null?void 0:p.map(E=>E))||[],n.user_ids=((y=e.user_ids)==null?void 0:y.map(E=>E))||[],n.last_sent_message=e.last_sent_message!==void 0&&e.last_sent_message!==null?S.fromPartial(e.last_sent_message):void 0,n.last_seen_message=e.last_seen_message!==void 0&&e.last_seen_message!==null?S.fromPartial(e.last_seen_message):void 0,n.onlines=((M=e.onlines)==null?void 0:M.map(E=>E))||[],n.meeting_code=(I=e.meeting_code)!=null?I:"",n.count_mess_unread=(N=e.count_mess_unread)!=null?N:0,n.active=(C=e.active)!=null?C:0,n.last_pin_message=(Z=e.last_pin_message)!=null?Z:"",n.usernames=(($=e.usernames)==null?void 0:$.map(E=>E))||[],n.creator_name=(Q=e.creator_name)!=null?Q:"",n.create_time_seconds=(j=e.create_time_seconds)!=null?j:0,n.update_time_seconds=(ee=e.update_time_seconds)!=null?ee:0,n.display_names=((ne=e.display_names)==null?void 0:ne.map(E=>E))||[],n.channel_avatar=(te=e.channel_avatar)!=null?te:"",n.clan_name=(ie=e.clan_name)!=null?ie:"",n.app_id=(ae=e.app_id)!=null?ae:"0",n.is_mute=(re=e.is_mute)!=null?re:!1,n.age_restricted=(qe=e.age_restricted)!=null?qe:0,n.topic=(we=e.topic)!=null?we:"",n.e2ee=(Ve=e.e2ee)!=null?Ve:0,n.member_count=(ze=e.member_count)!=null?ze:0,n}};function m(e){return e.toString()}f.default.util.Long!==Ie.default&&(f.default.util.Long=Ie.default,f.default.configure());function Dn(e){return typeof e=="object"&&e!==null}function s(e){return e!=null}function en(){return{clan_id:"0",channel_id:"0",message_id:"0",code:0,sender_id:"0",username:"",avatar:"",content:"",channel_label:"",clan_logo:"",category_name:"",display_name:"",clan_nick:"",clan_avatar:"",reactions:new Uint8Array(0),mentions:new Uint8Array(0),attachments:new Uint8Array(0),references:new Uint8Array(0),referenced_message:new Uint8Array(0),create_time_seconds:0,update_time_seconds:0,mode:0,hide_editted:!1,is_public:!1,topic_id:"0"}}var W={encode(e,n=f.default.Writer.create()){return e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.channel_id!=="0"&&n.uint32(16).int64(e.channel_id),e.message_id!=="0"&&n.uint32(24).int64(e.message_id),e.code!==0&&n.uint32(32).int32(e.code),e.sender_id!=="0"&&n.uint32(40).int64(e.sender_id),e.username!==""&&n.uint32(50).string(e.username),e.avatar!==""&&n.uint32(58).string(e.avatar),e.content!==""&&n.uint32(66).string(e.content),e.channel_label!==""&&n.uint32(74).string(e.channel_label),e.clan_logo!==""&&n.uint32(82).string(e.clan_logo),e.category_name!==""&&n.uint32(90).string(e.category_name),e.display_name!==""&&n.uint32(98).string(e.display_name),e.clan_nick!==""&&n.uint32(106).string(e.clan_nick),e.clan_avatar!==""&&n.uint32(114).string(e.clan_avatar),e.reactions.length!==0&&n.uint32(122).bytes(e.reactions),e.mentions.length!==0&&n.uint32(130).bytes(e.mentions),e.attachments.length!==0&&n.uint32(138).bytes(e.attachments),e.references.length!==0&&n.uint32(146).bytes(e.references),e.referenced_message.length!==0&&n.uint32(154).bytes(e.referenced_message),e.create_time_seconds!==0&&n.uint32(160).uint32(e.create_time_seconds),e.update_time_seconds!==0&&n.uint32(168).uint32(e.update_time_seconds),e.mode!==0&&n.uint32(176).int32(e.mode),e.hide_editted!==!1&&n.uint32(184).bool(e.hide_editted),e.is_public!==!1&&n.uint32(192).bool(e.is_public),e.topic_id!=="0"&&n.uint32(200).int64(e.topic_id),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=en();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=m(t.int64());continue;case 2:if(i!==16)break;a.channel_id=m(t.int64());continue;case 3:if(i!==24)break;a.message_id=m(t.int64());continue;case 4:if(i!==32)break;a.code=t.int32();continue;case 5:if(i!==40)break;a.sender_id=m(t.int64());continue;case 6:if(i!==50)break;a.username=t.string();continue;case 7:if(i!==58)break;a.avatar=t.string();continue;case 8:if(i!==66)break;a.content=t.string();continue;case 9:if(i!==74)break;a.channel_label=t.string();continue;case 10:if(i!==82)break;a.clan_logo=t.string();continue;case 11:if(i!==90)break;a.category_name=t.string();continue;case 12:if(i!==98)break;a.display_name=t.string();continue;case 13:if(i!==106)break;a.clan_nick=t.string();continue;case 14:if(i!==114)break;a.clan_avatar=t.string();continue;case 15:if(i!==122)break;a.reactions=t.bytes();continue;case 16:if(i!==130)break;a.mentions=t.bytes();continue;case 17:if(i!==138)break;a.attachments=t.bytes();continue;case 18:if(i!==146)break;a.references=t.bytes();continue;case 19:if(i!==154)break;a.referenced_message=t.bytes();continue;case 20:if(i!==160)break;a.create_time_seconds=t.uint32();continue;case 21:if(i!==168)break;a.update_time_seconds=t.uint32();continue;case 22:if(i!==176)break;a.mode=t.int32();continue;case 23:if(i!==184)break;a.hide_editted=t.bool();continue;case 24:if(i!==192)break;a.is_public=t.bool();continue;case 25:if(i!==200)break;a.topic_id=m(t.int64());continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:s(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:s(e.channel_id)?globalThis.String(e.channel_id):"0",message_id:s(e.message_id)?globalThis.String(e.message_id):"0",code:s(e.code)?globalThis.Number(e.code):0,sender_id:s(e.sender_id)?globalThis.String(e.sender_id):"0",username:s(e.username)?globalThis.String(e.username):"",avatar:s(e.avatar)?globalThis.String(e.avatar):"",content:s(e.content)?globalThis.String(e.content):"",channel_label:s(e.channel_label)?globalThis.String(e.channel_label):"",clan_logo:s(e.clan_logo)?globalThis.String(e.clan_logo):"",category_name:s(e.category_name)?globalThis.String(e.category_name):"",display_name:s(e.display_name)?globalThis.String(e.display_name):"",clan_nick:s(e.clan_nick)?globalThis.String(e.clan_nick):"",clan_avatar:s(e.clan_avatar)?globalThis.String(e.clan_avatar):"",reactions:s(e.reactions)?le(e.reactions):new Uint8Array(0),mentions:s(e.mentions)?le(e.mentions):new Uint8Array(0),attachments:s(e.attachments)?le(e.attachments):new Uint8Array(0),references:s(e.references)?le(e.references):new Uint8Array(0),referenced_message:s(e.referenced_message)?le(e.referenced_message):new Uint8Array(0),create_time_seconds:s(e.create_time_seconds)?globalThis.Number(e.create_time_seconds):0,update_time_seconds:s(e.update_time_seconds)?globalThis.Number(e.update_time_seconds):0,mode:s(e.mode)?globalThis.Number(e.mode):0,hide_editted:s(e.hide_editted)?globalThis.Boolean(e.hide_editted):!1,is_public:s(e.is_public)?globalThis.Boolean(e.is_public):!1,topic_id:s(e.topic_id)?globalThis.String(e.topic_id):"0"}},toJSON(e){let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.message_id!=="0"&&(n.message_id=e.message_id),e.code!==0&&(n.code=Math.round(e.code)),e.sender_id!=="0"&&(n.sender_id=e.sender_id),e.username!==""&&(n.username=e.username),e.avatar!==""&&(n.avatar=e.avatar),e.content!==""&&(n.content=e.content),e.channel_label!==""&&(n.channel_label=e.channel_label),e.clan_logo!==""&&(n.clan_logo=e.clan_logo),e.category_name!==""&&(n.category_name=e.category_name),e.display_name!==""&&(n.display_name=e.display_name),e.clan_nick!==""&&(n.clan_nick=e.clan_nick),e.clan_avatar!==""&&(n.clan_avatar=e.clan_avatar),e.reactions.length!==0&&(n.reactions=ce(e.reactions)),e.mentions.length!==0&&(n.mentions=ce(e.mentions)),e.attachments.length!==0&&(n.attachments=ce(e.attachments)),e.references.length!==0&&(n.references=ce(e.references)),e.referenced_message.length!==0&&(n.referenced_message=ce(e.referenced_message)),e.create_time_seconds!==0&&(n.create_time_seconds=Math.round(e.create_time_seconds)),e.update_time_seconds!==0&&(n.update_time_seconds=Math.round(e.update_time_seconds)),e.mode!==0&&(n.mode=Math.round(e.mode)),e.hide_editted!==!1&&(n.hide_editted=e.hide_editted),e.is_public!==!1&&(n.is_public=e.is_public),e.topic_id!=="0"&&(n.topic_id=e.topic_id),n},create(e){return W.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p,y,M,I,N,C,Z,$,Q,j,ee,ne,te,ie,ae,re;let n=en();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.message_id=(a=e.message_id)!=null?a:"0",n.code=(i=e.code)!=null?i:0,n.sender_id=(o=e.sender_id)!=null?o:"0",n.username=(l=e.username)!=null?l:"",n.avatar=(c=e.avatar)!=null?c:"",n.content=(d=e.content)!=null?d:"",n.channel_label=(_=e.channel_label)!=null?_:"",n.clan_logo=(p=e.clan_logo)!=null?p:"",n.category_name=(y=e.category_name)!=null?y:"",n.display_name=(M=e.display_name)!=null?M:"",n.clan_nick=(I=e.clan_nick)!=null?I:"",n.clan_avatar=(N=e.clan_avatar)!=null?N:"",n.reactions=(C=e.reactions)!=null?C:new Uint8Array(0),n.mentions=(Z=e.mentions)!=null?Z:new Uint8Array(0),n.attachments=($=e.attachments)!=null?$:new Uint8Array(0),n.references=(Q=e.references)!=null?Q:new Uint8Array(0),n.referenced_message=(j=e.referenced_message)!=null?j:new Uint8Array(0),n.create_time_seconds=(ee=e.create_time_seconds)!=null?ee:0,n.update_time_seconds=(ne=e.update_time_seconds)!=null?ne:0,n.mode=(te=e.mode)!=null?te:0,n.hide_editted=(ie=e.hide_editted)!=null?ie:!1,n.is_public=(ae=e.is_public)!=null?ae:!1,n.topic_id=(re=e.topic_id)!=null?re:"0",n}};function nn(){return{id:"0",timestamp_seconds:0,sender_id:"0",content:""}}var S={encode(e,n=f.default.Writer.create()){return e.id!=="0"&&n.uint32(8).int64(e.id),e.timestamp_seconds!==0&&n.uint32(16).uint32(e.timestamp_seconds),e.sender_id!=="0"&&n.uint32(24).int64(e.sender_id),e.content!==""&&n.uint32(34).string(e.content),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=nn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.id=m(t.int64());continue;case 2:if(i!==16)break;a.timestamp_seconds=t.uint32();continue;case 3:if(i!==24)break;a.sender_id=m(t.int64());continue;case 4:if(i!==34)break;a.content=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{id:s(e.id)?globalThis.String(e.id):"0",timestamp_seconds:s(e.timestamp_seconds)?globalThis.Number(e.timestamp_seconds):0,sender_id:s(e.sender_id)?globalThis.String(e.sender_id):"0",content:s(e.content)?globalThis.String(e.content):""}},toJSON(e){let n={};return e.id!=="0"&&(n.id=e.id),e.timestamp_seconds!==0&&(n.timestamp_seconds=Math.round(e.timestamp_seconds)),e.sender_id!=="0"&&(n.sender_id=e.sender_id),e.content!==""&&(n.content=e.content),n},create(e){return S.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i;let n=nn();return n.id=(t=e.id)!=null?t:"0",n.timestamp_seconds=(r=e.timestamp_seconds)!=null?r:0,n.sender_id=(a=e.sender_id)!=null?a:"0",n.content=(i=e.content)!=null?i:"",n}};function tn(){return{id:"0",user_id:"0",username:"",role_id:"0",rolename:"",create_time_seconds:0,s:0,e:0}}var B={encode(e,n=f.default.Writer.create()){return e.id!=="0"&&n.uint32(8).int64(e.id),e.user_id!=="0"&&n.uint32(16).int64(e.user_id),e.username!==""&&n.uint32(26).string(e.username),e.role_id!=="0"&&n.uint32(32).int64(e.role_id),e.rolename!==""&&n.uint32(42).string(e.rolename),e.create_time_seconds!==0&&n.uint32(48).uint32(e.create_time_seconds),e.s!==0&&n.uint32(56).int32(e.s),e.e!==0&&n.uint32(64).int32(e.e),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=tn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.id=m(t.int64());continue;case 2:if(i!==16)break;a.user_id=m(t.int64());continue;case 3:if(i!==26)break;a.username=t.string();continue;case 4:if(i!==32)break;a.role_id=m(t.int64());continue;case 5:if(i!==42)break;a.rolename=t.string();continue;case 6:if(i!==48)break;a.create_time_seconds=t.uint32();continue;case 7:if(i!==56)break;a.s=t.int32();continue;case 8:if(i!==64)break;a.e=t.int32();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{id:s(e.id)?globalThis.String(e.id):"0",user_id:s(e.user_id)?globalThis.String(e.user_id):"0",username:s(e.username)?globalThis.String(e.username):"",role_id:s(e.role_id)?globalThis.String(e.role_id):"0",rolename:s(e.rolename)?globalThis.String(e.rolename):"",create_time_seconds:s(e.create_time_seconds)?globalThis.Number(e.create_time_seconds):0,s:s(e.s)?globalThis.Number(e.s):0,e:s(e.e)?globalThis.Number(e.e):0}},toJSON(e){let n={};return e.id!=="0"&&(n.id=e.id),e.user_id!=="0"&&(n.user_id=e.user_id),e.username!==""&&(n.username=e.username),e.role_id!=="0"&&(n.role_id=e.role_id),e.rolename!==""&&(n.rolename=e.rolename),e.create_time_seconds!==0&&(n.create_time_seconds=Math.round(e.create_time_seconds)),e.s!==0&&(n.s=Math.round(e.s)),e.e!==0&&(n.e=Math.round(e.e)),n},create(e){return B.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d;let n=tn();return n.id=(t=e.id)!=null?t:"0",n.user_id=(r=e.user_id)!=null?r:"0",n.username=(a=e.username)!=null?a:"",n.role_id=(i=e.role_id)!=null?i:"0",n.rolename=(o=e.rolename)!=null?o:"",n.create_time_seconds=(l=e.create_time_seconds)!=null?l:0,n.s=(c=e.s)!=null?c:0,n.e=(d=e.e)!=null?d:0,n}};function an(){return{filename:"",size:0,url:"",filetype:"",width:0,height:0,thumbnail:"",duration:0}}var v={encode(e,n=f.default.Writer.create()){return e.filename!==""&&n.uint32(10).string(e.filename),e.size!==0&&n.uint32(16).int32(e.size),e.url!==""&&n.uint32(26).string(e.url),e.filetype!==""&&n.uint32(34).string(e.filetype),e.width!==0&&n.uint32(40).int32(e.width),e.height!==0&&n.uint32(48).int32(e.height),e.thumbnail!==""&&n.uint32(58).string(e.thumbnail),e.duration!==0&&n.uint32(64).int32(e.duration),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=an();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.filename=t.string();continue;case 2:if(i!==16)break;a.size=t.int32();continue;case 3:if(i!==26)break;a.url=t.string();continue;case 4:if(i!==34)break;a.filetype=t.string();continue;case 5:if(i!==40)break;a.width=t.int32();continue;case 6:if(i!==48)break;a.height=t.int32();continue;case 7:if(i!==58)break;a.thumbnail=t.string();continue;case 8:if(i!==64)break;a.duration=t.int32();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{filename:s(e.filename)?globalThis.String(e.filename):"",size:s(e.size)?globalThis.Number(e.size):0,url:s(e.url)?globalThis.String(e.url):"",filetype:s(e.filetype)?globalThis.String(e.filetype):"",width:s(e.width)?globalThis.Number(e.width):0,height:s(e.height)?globalThis.Number(e.height):0,thumbnail:s(e.thumbnail)?globalThis.String(e.thumbnail):"",duration:s(e.duration)?globalThis.Number(e.duration):0}},toJSON(e){let n={};return e.filename!==""&&(n.filename=e.filename),e.size!==0&&(n.size=Math.round(e.size)),e.url!==""&&(n.url=e.url),e.filetype!==""&&(n.filetype=e.filetype),e.width!==0&&(n.width=Math.round(e.width)),e.height!==0&&(n.height=Math.round(e.height)),e.thumbnail!==""&&(n.thumbnail=e.thumbnail),e.duration!==0&&(n.duration=Math.round(e.duration)),n},create(e){return v.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d;let n=an();return n.filename=(t=e.filename)!=null?t:"",n.size=(r=e.size)!=null?r:0,n.url=(a=e.url)!=null?a:"",n.filetype=(i=e.filetype)!=null?i:"",n.width=(o=e.width)!=null?o:0,n.height=(l=e.height)!=null?l:0,n.thumbnail=(c=e.thumbnail)!=null?c:"",n.duration=(d=e.duration)!=null?d:0,n}};function rn(){return{message_id:"0",message_ref_id:"0",content:"",has_attachment:!1,ref_type:0,message_sender_id:"0",message_sender_username:"",mesages_sender_avatar:"",message_sender_clan_nick:"",message_sender_display_name:""}}var H={encode(e,n=f.default.Writer.create()){return e.message_id!=="0"&&n.uint32(8).int64(e.message_id),e.message_ref_id!=="0"&&n.uint32(16).int64(e.message_ref_id),e.content!==""&&n.uint32(26).string(e.content),e.has_attachment!==!1&&n.uint32(32).bool(e.has_attachment),e.ref_type!==0&&n.uint32(40).int32(e.ref_type),e.message_sender_id!=="0"&&n.uint32(48).int64(e.message_sender_id),e.message_sender_username!==""&&n.uint32(58).string(e.message_sender_username),e.mesages_sender_avatar!==""&&n.uint32(66).string(e.mesages_sender_avatar),e.message_sender_clan_nick!==""&&n.uint32(74).string(e.message_sender_clan_nick),e.message_sender_display_name!==""&&n.uint32(82).string(e.message_sender_display_name),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=rn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.message_id=m(t.int64());continue;case 2:if(i!==16)break;a.message_ref_id=m(t.int64());continue;case 3:if(i!==26)break;a.content=t.string();continue;case 4:if(i!==32)break;a.has_attachment=t.bool();continue;case 5:if(i!==40)break;a.ref_type=t.int32();continue;case 6:if(i!==48)break;a.message_sender_id=m(t.int64());continue;case 7:if(i!==58)break;a.message_sender_username=t.string();continue;case 8:if(i!==66)break;a.mesages_sender_avatar=t.string();continue;case 9:if(i!==74)break;a.message_sender_clan_nick=t.string();continue;case 10:if(i!==82)break;a.message_sender_display_name=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{message_id:s(e.message_id)?globalThis.String(e.message_id):"0",message_ref_id:s(e.message_ref_id)?globalThis.String(e.message_ref_id):"0",content:s(e.content)?globalThis.String(e.content):"",has_attachment:s(e.has_attachment)?globalThis.Boolean(e.has_attachment):!1,ref_type:s(e.ref_type)?globalThis.Number(e.ref_type):0,message_sender_id:s(e.message_sender_id)?globalThis.String(e.message_sender_id):"0",message_sender_username:s(e.message_sender_username)?globalThis.String(e.message_sender_username):"",mesages_sender_avatar:s(e.mesages_sender_avatar)?globalThis.String(e.mesages_sender_avatar):"",message_sender_clan_nick:s(e.message_sender_clan_nick)?globalThis.String(e.message_sender_clan_nick):"",message_sender_display_name:s(e.message_sender_display_name)?globalThis.String(e.message_sender_display_name):""}},toJSON(e){let n={};return e.message_id!=="0"&&(n.message_id=e.message_id),e.message_ref_id!=="0"&&(n.message_ref_id=e.message_ref_id),e.content!==""&&(n.content=e.content),e.has_attachment!==!1&&(n.has_attachment=e.has_attachment),e.ref_type!==0&&(n.ref_type=Math.round(e.ref_type)),e.message_sender_id!=="0"&&(n.message_sender_id=e.message_sender_id),e.message_sender_username!==""&&(n.message_sender_username=e.message_sender_username),e.mesages_sender_avatar!==""&&(n.mesages_sender_avatar=e.mesages_sender_avatar),e.message_sender_clan_nick!==""&&(n.message_sender_clan_nick=e.message_sender_clan_nick),e.message_sender_display_name!==""&&(n.message_sender_display_name=e.message_sender_display_name),n},create(e){return H.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p;let n=rn();return n.message_id=(t=e.message_id)!=null?t:"0",n.message_ref_id=(r=e.message_ref_id)!=null?r:"0",n.content=(a=e.content)!=null?a:"",n.has_attachment=(i=e.has_attachment)!=null?i:!1,n.ref_type=(o=e.ref_type)!=null?o:0,n.message_sender_id=(l=e.message_sender_id)!=null?l:"0",n.message_sender_username=(c=e.message_sender_username)!=null?c:"",n.mesages_sender_avatar=(d=e.mesages_sender_avatar)!=null?d:"",n.message_sender_clan_nick=(_=e.message_sender_clan_nick)!=null?_:"",n.message_sender_display_name=(p=e.message_sender_display_name)!=null?p:"",n}};function sn(){return{attachments:[]}}var De={encode(e,n=f.default.Writer.create()){for(let t of e.attachments)v.encode(t,n.uint32(10).fork()).ldelim();return n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=sn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.attachments.push(v.decode(t,t.uint32()));continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{attachments:globalThis.Array.isArray(e==null?void 0:e.attachments)?e.attachments.map(n=>v.fromJSON(n)):[]}},toJSON(e){var t;let n={};return(t=e.attachments)!=null&&t.length&&(n.attachments=e.attachments.map(r=>v.toJSON(r))),n},create(e){return De.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=sn();return n.attachments=((t=e.attachments)==null?void 0:t.map(r=>v.fromPartial(r)))||[],n}};function le(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{let n=globalThis.atob(e),t=new Uint8Array(n.length);for(let r=0;r<n.length;++r)t[r]=n.charCodeAt(r);return t}}function ce(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{let n=[];return e.forEach(t=>{n.push(globalThis.String.fromCharCode(t))}),globalThis.btoa(n.join(""))}}function on(){return{filename:"",filetype:"",size:0,width:0,height:0}}var Te={encode(e,n=f.default.Writer.create()){return e.filename!==""&&n.uint32(10).string(e.filename),e.filetype!==""&&n.uint32(18).string(e.filetype),e.size!==0&&n.uint32(24).int32(e.size),e.width!==0&&n.uint32(32).int32(e.width),e.height!==0&&n.uint32(40).int32(e.height),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=on();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.filename=t.string();continue;case 2:if(i!==18)break;a.filetype=t.string();continue;case 3:if(i!==24)break;a.size=t.int32();continue;case 4:if(i!==32)break;a.width=t.int32();continue;case 5:if(i!==40)break;a.height=t.int32();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{filename:s(e.filename)?globalThis.String(e.filename):"",filetype:s(e.filetype)?globalThis.String(e.filetype):"",size:s(e.size)?globalThis.Number(e.size):0,width:s(e.width)?globalThis.Number(e.width):0,height:s(e.height)?globalThis.Number(e.height):0}},toJSON(e){let n={};return e.filename!==""&&(n.filename=e.filename),e.filetype!==""&&(n.filetype=e.filetype),e.size!==0&&(n.size=Math.round(e.size)),e.width!==0&&(n.width=Math.round(e.width)),e.height!==0&&(n.height=Math.round(e.height)),n},create(e){return Te.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o;let n=on();return n.filename=(t=e.filename)!=null?t:"",n.filetype=(r=e.filetype)!=null?r:"",n.size=(a=e.size)!=null?a:0,n.width=(i=e.width)!=null?i:0,n.height=(o=e.height)!=null?o:0,n}};function ln(){return{filename:"",url:""}}var Ue={encode(e,n=f.default.Writer.create()){return e.filename!==""&&n.uint32(10).string(e.filename),e.url!==""&&n.uint32(18).string(e.url),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=ln();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.filename=t.string();continue;case 2:if(i!==18)break;a.url=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{filename:s(e.filename)?globalThis.String(e.filename):"",url:s(e.url)?globalThis.String(e.url):""}},toJSON(e){let n={};return e.filename!==""&&(n.filename=e.filename),e.url!==""&&(n.url=e.url),n},create(e){return Ue.fromPartial(e!=null?e:{})},fromPartial(e){var t,r;let n=ln();return n.filename=(t=e.filename)!=null?t:"",n.url=(r=e.url)!=null?r:"",n}};function de(e,n,t){let r=xe({method:e},n);if(r.headers=xe({},n.headers),typeof XMLHttpRequest!="undefined"){let a=Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype,"withCredentials");a!=null&&a.set||(r.credentials="cocos-ignore")}return Object.keys(r.headers).includes("Accept")||(r.headers.Accept="application/proto"),Object.keys(r.headers).includes("Content-Type")||(r.headers["Content-Type"]="application/proto"),Object.keys(r.headers).forEach(a=>{r.headers[a]||delete r.headers[a]}),t&&(r.body=t),r}function Ce(e){if(e==null)return{t:e};let n;if(e instanceof Uint8Array)n=new TextDecoder().decode(e);else if(typeof e=="string")n=e;else return typeof e=="object"?e:{t:e};if(!n||n===""||n==="[]")return{t:n};try{return JSON.parse(n)}catch(t){try{let r=n.replace(/\n/g,"\\n").replace(/\r/g,"\\r");return JSON.parse(r)}catch(r){return console.error("JSON Parse failed completely:",{original:n,error:r}),{t:n}}}}var Un=e=>!e||e===null||e===void 0||e===""||e==="[]";function dn(e){if(Un(e))return;let n=e[0];if(n===91||n===123)return Ce(e);try{let r=e,a=new Uint8Array(r);return De.decode(a)}catch(r){return Ce(e)}}var Le=require("js-base64");var _e=class{constructor(n,t,r){this.serverKey=n;this.timeoutMs=t;this.basePath=r}setBasePath(n){this.basePath=n}authenticateIdToken(n,t,r,a={}){if(r==null)throw new Error("'body' is a required parameter but is null or undefined.");let i="/v2/account/authenticate/idtoken",o=new Map,l="";l=JSON.stringify(r||{});let c=this.buildFullUrl(this.basePath,i,o),d=de("POST",a,l);return n&&(d.headers.Authorization="Basic "+(0,Le.encode)(n+":"+t)),Promise.race([fetch(c,d).then(_=>{if(_.status==204)return _;if(_.status>=200&&_.status<300)return _.json();throw _}),new Promise((_,p)=>setTimeout(p,this.timeoutMs,"Request timed out."))])}sessionRefresh(n,t,r,a={}){if(r==null)throw new Error("'body' is a required parameter but is null or undefined.");let i="/mezon.api.Mezon/SessionRefresh",o=new Map,c=Se.encode(Se.fromPartial(r)).finish(),d=this.buildFullUrl(this.basePath,i,o),_=de("POST",a,"");return _.body=c,n&&(_.headers.Authorization="Basic "+(0,Le.encode)(n+":"+t)),Promise.race([fetch(d,_).then(p=>g(this,null,function*(){if(p.status==204)return{};if(p.status>=200&&p.status<300){let y=yield p.arrayBuffer();return Re.decode(new Uint8Array(y))}else throw p})),new Promise((p,y)=>setTimeout(()=>y(new Error("Request timed out.")),this.timeoutMs))])}createChannelDesc(n,t,r={}){if(t==null)throw new Error("'body' is a required parameter but is null or undefined.");let a="/mezon.api.Mezon/CreateChannelDesc",i=new Map,l=ve.encode(ve.fromPartial(t)).finish(),c=this.buildFullUrl(this.basePath,a,i),d=de("POST",r,"");return d.body=l,n&&(d.headers.Authorization="Bearer "+n),Promise.race([fetch(c,d).then(_=>g(this,null,function*(){if(_.status==204)return{};if(_.status>=200&&_.status<300){let p=yield _.arrayBuffer();return Oe.decode(new Uint8Array(p))}else throw _})),new Promise((_,p)=>setTimeout(()=>p(new Error("Request timed out.")),this.timeoutMs))])}uploadAttachmentFile(n,t,r={}){if(t==null)throw new Error("'body' is a required parameter but is null or undefined.");let a="/mezon.api.Mezon/UploadAttachmentFile",i=new Map,l=Te.encode(Te.fromPartial(t)).finish(),c=this.buildFullUrl(this.basePath,a,i),d=de("POST",r,"");return d.body=l,n&&(d.headers.Authorization="Bearer "+n),Promise.race([fetch(c,d).then(_=>g(this,null,function*(){if(_.status==204)return{};if(_.status>=200&&_.status<300){let p=yield _.arrayBuffer();return Ue.decode(new Uint8Array(p))}else throw _})),new Promise((_,p)=>setTimeout(()=>p(new Error("Request timed out.")),this.timeoutMs))])}buildFullUrl(n,t,r){let a=n+t+"?";for(let[i,o]of r)o instanceof Array?a+=o.reduce((l,c)=>l+encodeURIComponent(i)+"="+encodeURIComponent(c)+"&",""):o!=null&&(a+=encodeURIComponent(i)+"="+encodeURIComponent(o)+"&");return a}};var We=D(require("long")),h=D(require("protobufjs/minimal"));var Je=D(require("long")),P=D(require("protobufjs/minimal"));function _n(){return{value:!1}}var be={encode(e,n=P.default.Writer.create()){return e.value!==!1&&n.uint32(8).bool(e.value),n},decode(e,n){let t=e instanceof P.default.Reader?e:P.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=_n();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.value=t.bool();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{value:fn(e.value)?globalThis.Boolean(e.value):!1}},toJSON(e){let n={};return e.value!==!1&&(n.value=e.value),n},create(e){return be.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=_n();return n.value=(t=e.value)!=null?t:!1,n}};function un(){return{value:""}}var Pe={encode(e,n=P.default.Writer.create()){return e.value!==""&&n.uint32(10).string(e.value),n},decode(e,n){let t=e instanceof P.default.Reader?e:P.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=un();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.value=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{value:fn(e.value)?globalThis.String(e.value):""}},toJSON(e){let n={};return e.value!==""&&(n.value=e.value),n},create(e){return Pe.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=un();return n.value=(t=e.value)!=null?t:"",n}};P.default.util.Long!==Je.default&&(P.default.util.Long=Je.default,P.default.configure());function fn(e){return e!=null}function hn(){return{cid:"",channel:void 0,channel_join:void 0,channel_leave:void 0,channel_message:void 0,channel_message_ack:void 0,channel_message_send:void 0,error:void 0,ping:void 0,pong:void 0}}var ue={encode(e,n=h.default.Writer.create()){return e.cid!==""&&n.uint32(10).string(e.cid),e.channel!==void 0&&q.encode(e.channel,n.uint32(18).fork()).ldelim(),e.channel_join!==void 0&&w.encode(e.channel_join,n.uint32(34).fork()).ldelim(),e.channel_leave!==void 0&&V.encode(e.channel_leave,n.uint32(42).fork()).ldelim(),e.channel_message!==void 0&&W.encode(e.channel_message,n.uint32(50).fork()).ldelim(),e.channel_message_ack!==void 0&&z.encode(e.channel_message_ack,n.uint32(58).fork()).ldelim(),e.channel_message_send!==void 0&&F.encode(e.channel_message_send,n.uint32(66).fork()).ldelim(),e.error!==void 0&&K.encode(e.error,n.uint32(98).fork()).ldelim(),e.ping!==void 0&&Y.encode(e.ping,n.uint32(178).fork()).ldelim(),e.pong!==void 0&&G.encode(e.pong,n.uint32(186).fork()).ldelim(),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=hn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.cid=t.string();continue;case 2:if(i!==18)break;a.channel=q.decode(t,t.uint32());continue;case 4:if(i!==34)break;a.channel_join=w.decode(t,t.uint32());continue;case 5:if(i!==42)break;a.channel_leave=V.decode(t,t.uint32());continue;case 6:if(i!==50)break;a.channel_message=W.decode(t,t.uint32());continue;case 7:if(i!==58)break;a.channel_message_ack=z.decode(t,t.uint32());continue;case 8:if(i!==66)break;a.channel_message_send=F.decode(t,t.uint32());continue;case 12:if(i!==98)break;a.error=K.decode(t,t.uint32());continue;case 22:if(i!==178)break;a.ping=Y.decode(t,t.uint32());continue;case 23:if(i!==186)break;a.pong=G.decode(t,t.uint32());continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{cid:u(e.cid)?globalThis.String(e.cid):"",channel:u(e.channel)?q.fromJSON(e.channel):void 0,channel_join:u(e.channel_join)?w.fromJSON(e.channel_join):void 0,channel_leave:u(e.channel_leave)?V.fromJSON(e.channel_leave):void 0,channel_message:u(e.channel_message)?W.fromJSON(e.channel_message):void 0,channel_message_ack:u(e.channel_message_ack)?z.fromJSON(e.channel_message_ack):void 0,channel_message_send:u(e.channel_message_send)?F.fromJSON(e.channel_message_send):void 0,error:u(e.error)?K.fromJSON(e.error):void 0,ping:u(e.ping)?Y.fromJSON(e.ping):void 0,pong:u(e.pong)?G.fromJSON(e.pong):void 0}},toJSON(e){let n={};return e.cid!==""&&(n.cid=e.cid),e.channel!==void 0&&(n.channel=q.toJSON(e.channel)),e.channel_join!==void 0&&(n.channel_join=w.toJSON(e.channel_join)),e.channel_leave!==void 0&&(n.channel_leave=V.toJSON(e.channel_leave)),e.channel_message!==void 0&&(n.channel_message=W.toJSON(e.channel_message)),e.channel_message_ack!==void 0&&(n.channel_message_ack=z.toJSON(e.channel_message_ack)),e.channel_message_send!==void 0&&(n.channel_message_send=F.toJSON(e.channel_message_send)),e.error!==void 0&&(n.error=K.toJSON(e.error)),e.ping!==void 0&&(n.ping=Y.toJSON(e.ping)),e.pong!==void 0&&(n.pong=G.toJSON(e.pong)),n},create(e){return ue.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=hn();return n.cid=(t=e.cid)!=null?t:"",n.channel=e.channel!==void 0&&e.channel!==null?q.fromPartial(e.channel):void 0,n.channel_join=e.channel_join!==void 0&&e.channel_join!==null?w.fromPartial(e.channel_join):void 0,n.channel_leave=e.channel_leave!==void 0&&e.channel_leave!==null?V.fromPartial(e.channel_leave):void 0,n.channel_message=e.channel_message!==void 0&&e.channel_message!==null?W.fromPartial(e.channel_message):void 0,n.channel_message_ack=e.channel_message_ack!==void 0&&e.channel_message_ack!==null?z.fromPartial(e.channel_message_ack):void 0,n.channel_message_send=e.channel_message_send!==void 0&&e.channel_message_send!==null?F.fromPartial(e.channel_message_send):void 0,n.error=e.error!==void 0&&e.error!==null?K.fromPartial(e.error):void 0,n.ping=e.ping!==void 0&&e.ping!==null?Y.fromPartial(e.ping):void 0,n.pong=e.pong!==void 0&&e.pong!==null?G.fromPartial(e.pong):void 0,n}};function pn(){return{id:"0",presences:[],self:void 0,chanel_label:"",clan_logo:"",category_name:""}}var q={encode(e,n=h.default.Writer.create()){e.id!=="0"&&n.uint32(8).int64(e.id);for(let t of e.presences)b.encode(t,n.uint32(18).fork()).ldelim();return e.self!==void 0&&b.encode(e.self,n.uint32(26).fork()).ldelim(),e.chanel_label!==""&&n.uint32(34).string(e.chanel_label),e.clan_logo!==""&&n.uint32(42).string(e.clan_logo),e.category_name!==""&&n.uint32(50).string(e.category_name),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=pn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.id=T(t.int64());continue;case 2:if(i!==18)break;a.presences.push(b.decode(t,t.uint32()));continue;case 3:if(i!==26)break;a.self=b.decode(t,t.uint32());continue;case 4:if(i!==34)break;a.chanel_label=t.string();continue;case 5:if(i!==42)break;a.clan_logo=t.string();continue;case 6:if(i!==50)break;a.category_name=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{id:u(e.id)?globalThis.String(e.id):"0",presences:globalThis.Array.isArray(e==null?void 0:e.presences)?e.presences.map(n=>b.fromJSON(n)):[],self:u(e.self)?b.fromJSON(e.self):void 0,chanel_label:u(e.chanel_label)?globalThis.String(e.chanel_label):"",clan_logo:u(e.clan_logo)?globalThis.String(e.clan_logo):"",category_name:u(e.category_name)?globalThis.String(e.category_name):""}},toJSON(e){var t;let n={};return e.id!=="0"&&(n.id=e.id),(t=e.presences)!=null&&t.length&&(n.presences=e.presences.map(r=>b.toJSON(r))),e.self!==void 0&&(n.self=b.toJSON(e.self)),e.chanel_label!==""&&(n.chanel_label=e.chanel_label),e.clan_logo!==""&&(n.clan_logo=e.clan_logo),e.category_name!==""&&(n.category_name=e.category_name),n},create(e){return q.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o;let n=pn();return n.id=(t=e.id)!=null?t:"0",n.presences=((r=e.presences)==null?void 0:r.map(l=>b.fromPartial(l)))||[],n.self=e.self!==void 0&&e.self!==null?b.fromPartial(e.self):void 0,n.chanel_label=(a=e.chanel_label)!=null?a:"",n.clan_logo=(i=e.clan_logo)!=null?i:"",n.category_name=(o=e.category_name)!=null?o:"",n}};function mn(){return{clan_id:"0",channel_id:"0",channel_type:0,is_public:!1}}var w={encode(e,n=h.default.Writer.create()){return e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.channel_id!=="0"&&n.uint32(16).int64(e.channel_id),e.channel_type!==0&&n.uint32(24).int32(e.channel_type),e.is_public!==!1&&n.uint32(32).bool(e.is_public),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=mn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=T(t.int64());continue;case 2:if(i!==16)break;a.channel_id=T(t.int64());continue;case 3:if(i!==24)break;a.channel_type=t.int32();continue;case 4:if(i!==32)break;a.is_public=t.bool();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:u(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:u(e.channel_id)?globalThis.String(e.channel_id):"0",channel_type:u(e.channel_type)?globalThis.Number(e.channel_type):0,is_public:u(e.is_public)?globalThis.Boolean(e.is_public):!1}},toJSON(e){let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.channel_type!==0&&(n.channel_type=Math.round(e.channel_type)),e.is_public!==!1&&(n.is_public=e.is_public),n},create(e){return w.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i;let n=mn();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.channel_type=(a=e.channel_type)!=null?a:0,n.is_public=(i=e.is_public)!=null?i:!1,n}};function gn(){return{clan_id:"0",channel_id:"0",channel_type:0,is_public:!1}}var V={encode(e,n=h.default.Writer.create()){return e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.channel_id!=="0"&&n.uint32(16).int64(e.channel_id),e.channel_type!==0&&n.uint32(24).int32(e.channel_type),e.is_public!==!1&&n.uint32(32).bool(e.is_public),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=gn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=T(t.int64());continue;case 2:if(i!==16)break;a.channel_id=T(t.int64());continue;case 3:if(i!==24)break;a.channel_type=t.int32();continue;case 4:if(i!==32)break;a.is_public=t.bool();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:u(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:u(e.channel_id)?globalThis.String(e.channel_id):"0",channel_type:u(e.channel_type)?globalThis.Number(e.channel_type):0,is_public:u(e.is_public)?globalThis.Boolean(e.is_public):!1}},toJSON(e){let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.channel_type!==0&&(n.channel_type=Math.round(e.channel_type)),e.is_public!==!1&&(n.is_public=e.is_public),n},create(e){return V.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i;let n=gn();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.channel_type=(a=e.channel_type)!=null?a:0,n.is_public=(i=e.is_public)!=null?i:!1,n}};function yn(){return{channel_id:"0",message_id:"0",code:0,username:"",create_time_seconds:0,update_time_seconds:0,persistent:void 0,clan_logo:"",category_name:""}}var z={encode(e,n=h.default.Writer.create()){return e.channel_id!=="0"&&n.uint32(8).int64(e.channel_id),e.message_id!=="0"&&n.uint32(16).int64(e.message_id),e.code!==0&&n.uint32(24).int32(e.code),e.username!==""&&n.uint32(34).string(e.username),e.create_time_seconds!==0&&n.uint32(40).uint32(e.create_time_seconds),e.update_time_seconds!==0&&n.uint32(48).uint32(e.update_time_seconds),e.persistent!==void 0&&be.encode({value:e.persistent},n.uint32(58).fork()).ldelim(),e.clan_logo!==""&&n.uint32(66).string(e.clan_logo),e.category_name!==""&&n.uint32(74).string(e.category_name),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=yn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.channel_id=T(t.int64());continue;case 2:if(i!==16)break;a.message_id=T(t.int64());continue;case 3:if(i!==24)break;a.code=t.int32();continue;case 4:if(i!==34)break;a.username=t.string();continue;case 5:if(i!==40)break;a.create_time_seconds=t.uint32();continue;case 6:if(i!==48)break;a.update_time_seconds=t.uint32();continue;case 7:if(i!==58)break;a.persistent=be.decode(t,t.uint32()).value;continue;case 8:if(i!==66)break;a.clan_logo=t.string();continue;case 9:if(i!==74)break;a.category_name=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{channel_id:u(e.channel_id)?globalThis.String(e.channel_id):"0",message_id:u(e.message_id)?globalThis.String(e.message_id):"0",code:u(e.code)?globalThis.Number(e.code):0,username:u(e.username)?globalThis.String(e.username):"",create_time_seconds:u(e.create_time_seconds)?globalThis.Number(e.create_time_seconds):0,update_time_seconds:u(e.update_time_seconds)?globalThis.Number(e.update_time_seconds):0,persistent:u(e.persistent)?!!e.persistent:void 0,clan_logo:u(e.clan_logo)?globalThis.String(e.clan_logo):"",category_name:u(e.category_name)?globalThis.String(e.category_name):""}},toJSON(e){let n={};return e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.message_id!=="0"&&(n.message_id=e.message_id),e.code!==0&&(n.code=Math.round(e.code)),e.username!==""&&(n.username=e.username),e.create_time_seconds!==0&&(n.create_time_seconds=Math.round(e.create_time_seconds)),e.update_time_seconds!==0&&(n.update_time_seconds=Math.round(e.update_time_seconds)),e.persistent!==void 0&&(n.persistent=e.persistent),e.clan_logo!==""&&(n.clan_logo=e.clan_logo),e.category_name!==""&&(n.category_name=e.category_name),n},create(e){return z.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_;let n=yn();return n.channel_id=(t=e.channel_id)!=null?t:"0",n.message_id=(r=e.message_id)!=null?r:"0",n.code=(a=e.code)!=null?a:0,n.username=(i=e.username)!=null?i:"",n.create_time_seconds=(o=e.create_time_seconds)!=null?o:0,n.update_time_seconds=(l=e.update_time_seconds)!=null?l:0,n.persistent=(c=e.persistent)!=null?c:void 0,n.clan_logo=(d=e.clan_logo)!=null?d:"",n.category_name=(_=e.category_name)!=null?_:"",n}};function kn(){return{clan_id:"0",channel_id:"0",content:"",mentions:[],attachments:[],references:[],mode:0,anonymous_message:!1,mention_everyone:!1,avatar:"",is_public:!1,code:0,topic_id:"0",id:"0"}}var F={encode(e,n=h.default.Writer.create()){e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.channel_id!=="0"&&n.uint32(16).int64(e.channel_id),e.content!==""&&n.uint32(26).string(e.content);for(let t of e.mentions)B.encode(t,n.uint32(34).fork()).ldelim();for(let t of e.attachments)v.encode(t,n.uint32(42).fork()).ldelim();for(let t of e.references)H.encode(t,n.uint32(50).fork()).ldelim();return e.mode!==0&&n.uint32(56).int32(e.mode),e.anonymous_message!==!1&&n.uint32(64).bool(e.anonymous_message),e.mention_everyone!==!1&&n.uint32(72).bool(e.mention_everyone),e.avatar!==""&&n.uint32(82).string(e.avatar),e.is_public!==!1&&n.uint32(88).bool(e.is_public),e.code!==0&&n.uint32(96).int32(e.code),e.topic_id!=="0"&&n.uint32(104).int64(e.topic_id),e.id!=="0"&&n.uint32(112).int64(e.id),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=kn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=T(t.int64());continue;case 2:if(i!==16)break;a.channel_id=T(t.int64());continue;case 3:if(i!==26)break;a.content=t.string();continue;case 4:if(i!==34)break;a.mentions.push(B.decode(t,t.uint32()));continue;case 5:if(i!==42)break;a.attachments.push(v.decode(t,t.uint32()));continue;case 6:if(i!==50)break;a.references.push(H.decode(t,t.uint32()));continue;case 7:if(i!==56)break;a.mode=t.int32();continue;case 8:if(i!==64)break;a.anonymous_message=t.bool();continue;case 9:if(i!==72)break;a.mention_everyone=t.bool();continue;case 10:if(i!==82)break;a.avatar=t.string();continue;case 11:if(i!==88)break;a.is_public=t.bool();continue;case 12:if(i!==96)break;a.code=t.int32();continue;case 13:if(i!==104)break;a.topic_id=T(t.int64());continue;case 14:if(i!==112)break;a.id=T(t.int64());continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:u(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:u(e.channel_id)?globalThis.String(e.channel_id):"0",content:u(e.content)?globalThis.String(e.content):"",mentions:globalThis.Array.isArray(e==null?void 0:e.mentions)?e.mentions.map(n=>B.fromJSON(n)):[],attachments:globalThis.Array.isArray(e==null?void 0:e.attachments)?e.attachments.map(n=>v.fromJSON(n)):[],references:globalThis.Array.isArray(e==null?void 0:e.references)?e.references.map(n=>H.fromJSON(n)):[],mode:u(e.mode)?globalThis.Number(e.mode):0,anonymous_message:u(e.anonymous_message)?globalThis.Boolean(e.anonymous_message):!1,mention_everyone:u(e.mention_everyone)?globalThis.Boolean(e.mention_everyone):!1,avatar:u(e.avatar)?globalThis.String(e.avatar):"",is_public:u(e.is_public)?globalThis.Boolean(e.is_public):!1,code:u(e.code)?globalThis.Number(e.code):0,topic_id:u(e.topic_id)?globalThis.String(e.topic_id):"0",id:u(e.id)?globalThis.String(e.id):"0"}},toJSON(e){var t,r,a;let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.content!==""&&(n.content=e.content),(t=e.mentions)!=null&&t.length&&(n.mentions=e.mentions.map(i=>B.toJSON(i))),(r=e.attachments)!=null&&r.length&&(n.attachments=e.attachments.map(i=>v.toJSON(i))),(a=e.references)!=null&&a.length&&(n.references=e.references.map(i=>H.toJSON(i))),e.mode!==0&&(n.mode=Math.round(e.mode)),e.anonymous_message!==!1&&(n.anonymous_message=e.anonymous_message),e.mention_everyone!==!1&&(n.mention_everyone=e.mention_everyone),e.avatar!==""&&(n.avatar=e.avatar),e.is_public!==!1&&(n.is_public=e.is_public),e.code!==0&&(n.code=Math.round(e.code)),e.topic_id!=="0"&&(n.topic_id=e.topic_id),e.id!=="0"&&(n.id=e.id),n},create(e){return F.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p,y,M,I,N;let n=kn();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.content=(a=e.content)!=null?a:"",n.mentions=((i=e.mentions)==null?void 0:i.map(C=>B.fromPartial(C)))||[],n.attachments=((o=e.attachments)==null?void 0:o.map(C=>v.fromPartial(C)))||[],n.references=((l=e.references)==null?void 0:l.map(C=>H.fromPartial(C)))||[],n.mode=(c=e.mode)!=null?c:0,n.anonymous_message=(d=e.anonymous_message)!=null?d:!1,n.mention_everyone=(_=e.mention_everyone)!=null?_:!1,n.avatar=(p=e.avatar)!=null?p:"",n.is_public=(y=e.is_public)!=null?y:!1,n.code=(M=e.code)!=null?M:0,n.topic_id=(I=e.topic_id)!=null?I:"0",n.id=(N=e.id)!=null?N:"0",n}};function Sn(){return{code:0,message:"",context:{}}}var K={encode(e,n=h.default.Writer.create()){return e.code!==0&&n.uint32(8).int32(e.code),e.message!==""&&n.uint32(18).string(e.message),Object.entries(e.context).forEach(([t,r])=>{Be.encode({key:t,value:r},n.uint32(26).fork()).ldelim()}),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Sn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.code=t.int32();continue;case 2:if(i!==18)break;a.message=t.string();continue;case 3:if(i!==26)break;let o=Be.decode(t,t.uint32());o.value!==void 0&&(a.context[o.key]=o.value);continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{code:u(e.code)?globalThis.Number(e.code):0,message:u(e.message)?globalThis.String(e.message):"",context:Ln(e.context)?Object.entries(e.context).reduce((n,[t,r])=>(n[t]=String(r),n),{}):{}}},toJSON(e){let n={};if(e.code!==0&&(n.code=Math.round(e.code)),e.message!==""&&(n.message=e.message),e.context){let t=Object.entries(e.context);t.length>0&&(n.context={},t.forEach(([r,a])=>{n.context[r]=a}))}return n},create(e){return K.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a;let n=Sn();return n.code=(t=e.code)!=null?t:0,n.message=(r=e.message)!=null?r:"",n.context=Object.entries((a=e.context)!=null?a:{}).reduce((i,[o,l])=>(l!==void 0&&(i[o]=globalThis.String(l)),i),{}),n}};function vn(){return{key:"",value:""}}var Be={encode(e,n=h.default.Writer.create()){return e.key!==""&&n.uint32(10).string(e.key),e.value!==""&&n.uint32(18).string(e.value),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=vn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.key=t.string();continue;case 2:if(i!==18)break;a.value=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{key:u(e.key)?globalThis.String(e.key):"",value:u(e.value)?globalThis.String(e.value):""}},toJSON(e){let n={};return e.key!==""&&(n.key=e.key),e.value!==""&&(n.value=e.value),n},create(e){return Be.fromPartial(e!=null?e:{})},fromPartial(e){var t,r;let n=vn();return n.key=(t=e.key)!=null?t:"",n.value=(r=e.value)!=null?r:"",n}};function Tn(){return{}}var Y={encode(e,n=h.default.Writer.create()){return n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Tn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{}},toJSON(e){return{}},create(e){return Y.fromPartial(e!=null?e:{})},fromPartial(e){return Tn()}};function Cn(){return{}}var G={encode(e,n=h.default.Writer.create()){return n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Cn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{}},toJSON(e){return{}},create(e){return G.fromPartial(e!=null?e:{})},fromPartial(e){return Cn()}};function bn(){return{user_id:"0",session_id:"",username:"",status:void 0,is_mobile:!1,user_status:""}}var b={encode(e,n=h.default.Writer.create()){return e.user_id!=="0"&&n.uint32(8).int64(e.user_id),e.session_id!==""&&n.uint32(18).string(e.session_id),e.username!==""&&n.uint32(26).string(e.username),e.status!==void 0&&Pe.encode({value:e.status},n.uint32(34).fork()).ldelim(),e.is_mobile!==!1&&n.uint32(40).bool(e.is_mobile),e.user_status!==""&&n.uint32(50).string(e.user_status),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=bn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.user_id=T(t.int64());continue;case 2:if(i!==18)break;a.session_id=t.string();continue;case 3:if(i!==26)break;a.username=t.string();continue;case 4:if(i!==34)break;a.status=Pe.decode(t,t.uint32()).value;continue;case 5:if(i!==40)break;a.is_mobile=t.bool();continue;case 6:if(i!==50)break;a.user_status=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{user_id:u(e.user_id)?globalThis.String(e.user_id):"0",session_id:u(e.session_id)?globalThis.String(e.session_id):"",username:u(e.username)?globalThis.String(e.username):"",status:u(e.status)?String(e.status):void 0,is_mobile:u(e.is_mobile)?globalThis.Boolean(e.is_mobile):!1,user_status:u(e.user_status)?globalThis.String(e.user_status):""}},toJSON(e){let n={};return e.user_id!=="0"&&(n.user_id=e.user_id),e.session_id!==""&&(n.session_id=e.session_id),e.username!==""&&(n.username=e.username),e.status!==void 0&&(n.status=e.status),e.is_mobile!==!1&&(n.is_mobile=e.is_mobile),e.user_status!==""&&(n.user_status=e.user_status),n},create(e){return b.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l;let n=bn();return n.user_id=(t=e.user_id)!=null?t:"0",n.session_id=(r=e.session_id)!=null?r:"",n.username=(a=e.username)!=null?a:"",n.status=(i=e.status)!=null?i:void 0,n.is_mobile=(o=e.is_mobile)!=null?o:!1,n.user_status=(l=e.user_status)!=null?l:"",n}};function T(e){return e.toString()}h.default.util.Long!==We.default&&(h.default.util.Long=We.default,h.default.configure());function Ln(e){return typeof e=="object"&&e!==null}function u(e){return e!=null}var R=class{constructor(){}get onClose(){return this._socket.onclose}set onClose(n){this._socket.onclose=n}get onError(){return this._socket.onerror}set onError(n){this._socket.onerror=n}get onMessage(){return this._socket.onmessage}set onMessage(n){n?this._socket.onmessage=t=>{let r=t.data,a=new Uint8Array(r),i=ue.decode(a);i.channel_message&&i.channel_message.code==null&&(i.channel_message.code=0),n(i)}:n=null}get onOpen(){return this._socket.onopen}set onOpen(n){this._socket.onopen=n}isOpen(){var n;return((n=this._socket)==null?void 0:n.readyState)==WebSocket.OPEN}close(){var n;(n=this._socket)==null||n.close(),this._socket=void 0}connect(n,t,r,a,i,o,l){l&&l.addEventListener("abort",()=>{this.close()});let c=r?`:${r}`:"",d=`${n}${t}${c}/ws?lang=en&status=${encodeURIComponent(a.toString())}&token=${encodeURIComponent(i)}&format=protobuf&platform=${encodeURIComponent(o)}`;this._socket=new WebSocket(d),this._socket.binaryType="arraybuffer"}send(n){let r=ue.encode(ue.fromPartial(n)).finish();this._socket.send(r)}};var Pn=!1,k={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected"},x=class x{constructor(n,t,r=!1,a=!1,i=new R,o=x.DefaultSendTimeoutMs){this.host=n;this.port=t;this.useSSL=r;this.verbose=a;this.adapter=i;this.sendTimeoutMs=o;this.cIds={},this.nextCid=1,this._heartbeatTimeoutMs=x.DefaultHeartbeatTimeoutMs,this._connectionState=k.DISCONNECTED}generatecid(){let n=this.nextCid.toString();return++this.nextCid,n}isOpen(){return this._connectionState===k.CONNECTED}connect(n,t=!1,r="",a=x.DefaultConnectTimeoutMs,i){if(this._connectionState===k.CONNECTED)return Promise.resolve(n);if(this._connectionState===k.CONNECTING&&this._connectPromise)return this._connectPromise;this.clearConnectTimeout(),this._connectionState=k.CONNECTING;let o=this.useSSL?"wss://":"ws://";this.adapter.connect(o,this.host,this.port,t,n.token,r,i),this.adapter.onClose=c=>{this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.clearConnectTimeout(),this.ondisconnect(c)},this.adapter.onMessage=c=>g(this,null,function*(){if(this.verbose&&window&&window.console&&console.log("Response: %o",JSON.stringify(c)),c.cid){let d=this.cIds[c.cid];if(!d){this.verbose&&window&&window.console&&console.error("No promise executor for message: %o",c);return}delete this.cIds[c.cid],c.error?d.reject(c.error):d.resolve(c)}else if(c.channel_message){let d=Wn(c);this.onchannelmessage(d)}else this.verbose&&window&&window.console&&console.log("Unrecognized message received: %o",c)});let l=new Promise((c,d)=>{this.adapter.onOpen=_=>{this.verbose&&window&&window.console&&console.log(_);let p=Pn;Pn=!0,this.clearConnectTimeout(),this._connectionState=k.CONNECTED,this.startHeartbeatLoop(),this._connectPromise=void 0,c(n),p&&this.onreconnect(_)},this.adapter.onError=_=>{this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.clearConnectTimeout(),this.onerror(_),this._connectPromise=void 0,this.adapter.close(),d(_)},this._connectTimeoutTimer=setTimeout(()=>{this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.adapter.close(),this._connectPromise=void 0,d("The socket timed out when trying to connect."),this._connectTimeoutTimer=void 0},a)});return this._connectPromise=l,this._connectPromise}disconnect(n=!0){this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.adapter.isOpen()&&this.adapter.close(),n&&this.ondisconnect({})}setHeartbeatTimeoutMs(n){this._heartbeatTimeoutMs=n}getHeartbeatTimeoutMs(){return this._heartbeatTimeoutMs}onreconnect(n){this.verbose&&window&&window.console&&console.log(n)}ondisconnect(n){this.verbose&&window&&window.console&&console.log(n)}onerror(n){this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.verbose&&window&&window.console&&console.log(n)}onheartbeattimeout(){this.verbose&&window&&window.console&&console.log("Heartbeat timeout.")}onchannelmessage(n){this.verbose&&window&&window.console&&console.log(n)}send(n,t=x.DefaultSendTimeoutMs){let r=n;return new Promise((a,i)=>{var o,l;if(!this.adapter.isOpen())i("Socket connection has not been established yet.");else{r.channel_message_send?r.channel_message_send.content=JSON.stringify(r.channel_message_send.content):r.channel_message_update?r.channel_message_update.content=JSON.stringify(r.channel_message_update.content):r.ephemeral_message_send?r.ephemeral_message_send.message.content=JSON.stringify((o=r.ephemeral_message_send.message)==null?void 0:o.content):r.quick_menu_event&&(r.quick_menu_event.message.content=JSON.stringify((l=r.quick_menu_event.message)==null?void 0:l.content));let c=this.generatecid();this.cIds[c]={resolve:a,reject:i},t!==1/0&&t>0&&setTimeout(()=>{i("The socket timed out while waiting for a response.")},t),r.cid=c,this.adapter.send(r)}})}joinChat(n,t,r,a){return g(this,null,function*(){return(yield this.send({channel_join:{clan_id:n,channel_id:t,channel_type:r,is_public:a}})).channel})}leaveChat(n,t,r,a){return g(this,null,function*(){return this.send({channel_leave:{clan_id:n,channel_id:t,channel_type:r,is_public:a}})})}writeChatMessage(n,t,r,a,i,o,l,c,d,_,p){return g(this,null,function*(){return(yield this.send({channel_message_send:{clan_id:n,channel_id:t,mode:r,is_public:a,content:i,reactions:[],mentions:[],attachments:o,references:[],anonymous_message:l,mention_everyone:c,avatar:d,code:_,topic_id:p}},1/0)).channel_message_ack})}pingPong(){return g(this,null,function*(){if(!this.isOpen()){this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop();return}try{yield this.send({ping:{}},this._heartbeatTimeoutMs)}catch(n){this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.adapter.isOpen()&&(window&&window.console&&console.error("Server unreachable from heartbeat."),this.onheartbeattimeout(),this.adapter.close());return}this.startHeartbeatLoop()})}startHeartbeatLoop(){this.stopHeartbeatLoop(),this._heartbeatTimer=setTimeout(()=>this.pingPong(),this._heartbeatTimeoutMs)}stopHeartbeatLoop(){this._heartbeatTimer!==void 0&&(clearTimeout(this._heartbeatTimer),this._heartbeatTimer=void 0)}clearConnectTimeout(){this._connectTimeoutTimer!==void 0&&(clearTimeout(this._connectTimeoutTimer),this._connectTimeoutTimer=void 0)}};x.DefaultHeartbeatTimeoutMs=1e4,x.DefaultSendTimeoutMs=1e4,x.DefaultConnectTimeoutMs=3e4;var fe=x;function Wn(e){var n,t;try{n=Ce(e.channel_message.content)}catch(a){console.log("content is invalid",a)}try{t=dn(e.channel_message.attachments)}catch(a){console.log("attachments is invalid",a)}var r={id:e.id||e.channel_message.message_id,avatar:e.channel_message.avatar,channel_id:e.channel_message.channel_id,mode:e.channel_message.mode,channel_label:e.channel_message.channel_label,clan_id:e.channel_message.clan_id,code:e.channel_message.code,message_id:e.channel_message.message_id,sender_id:e.channel_message.sender_id,update_time:e.channel_message.update_time,clan_logo:e.channel_message.clan_logo,category_name:e.channel_message.category_name,username:e.channel_message.username,clan_nick:e.channel_message.clan_nick,clan_avatar:e.channel_message.clan_avatar,display_name:e.channel_message.display_name,content:n,attachments:t==null?void 0:t.attachments,hide_editted:e.channel_message.hide_editted,is_public:e.channel_message.is_public,create_time_seconds:e.channel_message.create_time_seconds,update_time_seconds:e.channel_message.update_time_seconds,topic_id:e.channel_message.topic_id};return r}var X=class extends Error{constructor(t,r){super(t!=null?t:"Authentication failed.");this.statusCode=r;this.name="AuthenticationError"}},he=class extends Error{constructor(n){super(n!=null?n:"Session error."),this.name="SessionError"}};function He(e){let n=new URL(e);return`${n.protocol==="https:"?"https://":"http://"}${n.hostname}:${n.port}`}var Ee=class e{constructor(n,t,r){this.refreshTokenPromise=null;this._session=n,this._client=t,this._userId=r}get userId(){return this._userId}get session(){return this._session}get client(){return this._client}static initClient(n){let{token:t,refresh_token:r,api_url:a,user_id:i,serverkey:o}=n;if(!t||!r||!a||!i)throw new he("Missing required fields: token, refresh_token, api_url, and user_id are all required");let l=oe.restore(t,r,a,!0),c=new _e(o||J,7e3,He(a));return new e(l,c,i)}static authenticate(n){return g(this,null,function*(){let{id_token:t,user_id:r,username:a,serverkey:i=J,gateway_url:o=pe}=n,l=new _e(i||J,7e3,He(o)),c={id_token:t,user_id:r,username:a},d=yield l.authenticateIdToken(i,"",c);if(!d)throw new X("Authentication failed: No response from server.");if(!d.token||!d.refresh_token||!d.api_url||!d.user_id)throw new X("Invalid authentication response: missing required fields");let _=oe.restore(d.token,d.refresh_token,d.api_url,!0);return l.setBasePath(He(d.api_url)),new e(_,l,d.user_id)})}createDM(n){return g(this,null,function*(){let t={type:3,channel_private:1,user_ids:[n]};return this._client.createChannelDesc(this._session.token,t)})}createGroupDM(n){return g(this,null,function*(){if(n.length===0)throw new Error("At least one user ID is required for a group DM");let t={type:2,channel_private:1,user_ids:n};return this._client.createChannelDesc(this._session.token,t)})}uploadAttachment(n){return g(this,null,function*(){return this._client.uploadAttachmentFile(this._session.token,n)})}refreshSession(){return g(this,null,function*(){return this._session?(this._session.created&&this._session.expires_at-this._session.created_at<70&&console.warn("Session lifetime too short, please set '--session.token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session"),this._session.created&&this._session.refresh_expires_at-this._session.created_at<3700&&console.warn("Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session"),this.refreshTokenPromise?this.refreshTokenPromise:(this.refreshTokenPromise=new Promise((n,t)=>g(this,null,function*(){try{let r=yield this.client.sessionRefresh(this._client.serverKey||J,"",{token:this._session.refresh_token,vars:this._session.vars,is_remember:this._session.is_remember});this._session.update(r.token,r.refresh_token,r.is_remember||!1),this.onRefreshSession(r),n(this._session)}catch(r){console.error("Session refresh failed:",r),t(r)}finally{this.refreshTokenPromise=null}})),this.refreshTokenPromise)):(console.error("Cannot refresh a null session."),this._session)})}createSocket(n=!1,t=new R,r=fe.DefaultSendTimeoutMs){let a=new URL(this._client.basePath),{host:i,port:o,useSSL:l}={host:a.hostname,port:a.port||(a.protocol==="https:"?"443":"80"),useSSL:a.protocol==="https:"};return new fe(i,o,l,n,t,r)}onRefreshSession(n){console.log(`Token refresh occurred. Token: ${n.token}`)}isSessionExpired(){return this._session.isexpired(Date.now()/1e3)}isRefreshSessionExpired(){return this._session.isrefreshexpired(Date.now()/1e3)}getToken(){return this._session.token}getRefreshToken(){return this._session.refresh_token}getSession(){return this.session}exportSession(){return{token:this._session.token,refresh_token:this._session.refresh_token,api_url:this._session.api_url||"",user_id:this._userId}}};var O=class extends Error{constructor(n){super(n),this.name="SocketError"}};function En(r){return g(this,arguments,function*(e,n=20,t=100){var l;let a=0,i=t,o=e;for(;a<n;){if((l=o.adapter)!=null&&l.isOpen())return;yield new Promise(c=>setTimeout(c,i)),i*=2,a++}throw new O(`Socket failed to connect after ${n} attempts (total wait: ~${Math.pow(2,n)*t}ms)`)})}var Ae=class{constructor(n,t){this._client=n;this._session=t;this._socket=null;this._isConnected=!1;this._messageHandlers=[]}get isConnected(){return this._isConnected}get socket(){if(!this._socket)throw new O("Socket is not connected. Call connect() first.");return this._socket}connect(){return g(this,arguments,function*(n={}){if(this._isConnected)throw new O("Socket is already connected. Call disconnect() first.");let{onError:t,onDisconnect:r,verbose:a=!1}=n;this._errorHandler=t,this._disconnectHandler=r,this._socket=this._client.createSocket(a,new R),this._socket.onerror=i=>{var o;(o=this._errorHandler)==null||o.call(this,i)},this._socket.ondisconnect=()=>{var i;this._isConnected=!1,(i=this._disconnectHandler)==null||i.call(this)},this._socket.onchannelmessage=i=>{var o;if(!i){(o=this._errorHandler)==null||o.call(this,new O("Received null or undefined channel message"));return}this._messageHandlers.forEach(l=>{try{l(i)}catch(c){console.error("Error in message handler:",c)}})},yield this._socket.connect(this._session,!0,"0"),this._isConnected=!0})}disconnect(){this._socket&&(this._socket.disconnect(!0),this._socket=null,this._isConnected=!1)}setChannelMessageHandler(n){this.onChannelMessage(n)}onChannelMessage(n){return this._messageHandlers.push(n),()=>{let t=this._messageHandlers.indexOf(n);t!==-1&&this._messageHandlers.splice(t,1)}}joinDMChannel(n){return g(this,null,function*(){yield En(this.socket),yield this.socket.joinChat(A,n,3,!1)})}joinGroupChannel(n){return g(this,null,function*(){yield En(this.socket),yield this.socket.joinChat(A,n,2,!1)})}leaveDMChannel(n){return g(this,null,function*(){yield this.socket.leaveChat(A,n,3,!1)})}leaveGroupChannel(n){return g(this,null,function*(){yield this.socket.leaveChat(A,n,2,!1)})}sendDM(n){return g(this,null,function*(){let{channelId:t,content:r,attachments:a,hideLink:i=!1}=n;yield this.socket.writeChatMessage(A,t,4,!1,r,a,!1,i,"",0)})}sendGroup(n){return g(this,null,function*(){let{channelId:t,content:r,attachments:a,hideLink:i=!1}=n;yield this.socket.writeChatMessage(A,t,3,!1,r,a,!1,i,"",0)})}setErrorHandler(n){this._errorHandler=n,this._socket&&(this._socket.onerror=n)}};
|
|
1
|
+
"use strict";var An=Object.create;var se=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var Mn=Object.getOwnPropertyNames,Fe=Object.getOwnPropertySymbols,In=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable;var Ke=(e,n,t)=>n in e?se(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,xe=(e,n)=>{for(var t in n||(n={}))Ye.call(n,t)&&Ke(e,t,n[t]);if(Fe)for(var t of Fe(n))Nn.call(n,t)&&Ke(e,t,n[t]);return e};var Rn=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},Ge=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of Mn(n))!Ye.call(e,a)&&a!==t&&se(e,a,{get:()=>n[a],enumerable:!(r=xn(n,a))||r.enumerable});return e};var D=(e,n,t)=>(t=e!=null?An(In(e)):{},Ge(n||!e||!e.__esModule?se(t,"default",{value:e,enumerable:!0}):t,e)),On=e=>Ge(se({},"__esModule",{value:!0}),e);var g=(e,n,t)=>new Promise((r,a)=>{var i=c=>{try{l(t.next(c))}catch(d){a(d)}},o=c=>{try{l(t.throw(c))}catch(d){a(d)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);l((t=t.apply(e,n)).next())});var Bn={};Rn(Bn,{AuthenticationError:()=>X,CHANNEL_TYPE_DM:()=>U,CHANNEL_TYPE_GROUP:()=>L,CLAN_DM:()=>A,DEFAULT_SERVER_KEY:()=>J,LightClient:()=>Ee,LightSocket:()=>Ae,MEZON_GW_URL:()=>pe,SOCKET_READY_MAX_RETRY:()=>me,SOCKET_READY_RETRY_DELAY:()=>ge,STREAM_MODE_DM:()=>ye,STREAM_MODE_GROUP:()=>ke,SessionError:()=>he,SocketError:()=>O});module.exports=On(Bn);var pe="https://gw.mezon.ai",me=20,ge=100,A="0",U=3,L=2,ye=4,ke=3,J="DefaultServerKey";var Me=D(require("js-base64")),oe=class e{constructor(n,t,r,a,i,o,l){this.created=r;this.api_url=a;this.ws_url=i;this.id_token=o;this.token=n,this.refresh_token=t,this.id_token=o,this.api_url=a,this.ws_url=i,this.created_at=Math.floor(new Date().getTime()/1e3),this.is_remember=l,this.update(n,t,l)}isexpired(n){return this.expires_at-n<=0}isrefreshexpired(n){return this.refresh_expires_at-n<=0}update(n,t,r){let a=n.split(".");if(a.length!=3)throw"jwt is not valid.";let i=JSON.parse(Me.atob(a[1])),o=Math.floor(parseInt(i.exp));if(t){let l=t.split(".");if(l.length!=3)throw"refresh jwt is not valid.";let c=JSON.parse(Me.atob(l[1])),d=Math.floor(parseInt(c.exp));this.refresh_expires_at=d,this.refresh_token=t,this.is_remember=r}this.token=n,this.expires_at=o,this.username=i.usn,this.user_id=i.uid,this.vars=i.vrs}static restore(n,t,r,a,i){return new e(n,t,!1,r,a,"",i)}};var Ie=D(require("long")),f=D(require("protobufjs/minimal"));function Xe(){return{created:!1,token:"",refresh_token:"",user_id:"0",is_remember:!1,api_url:"",id_token:""}}var Re={encode(e,n=f.default.Writer.create()){return e.created!==!1&&n.uint32(8).bool(e.created),e.token!==""&&n.uint32(18).string(e.token),e.refresh_token!==""&&n.uint32(26).string(e.refresh_token),e.user_id!=="0"&&n.uint32(32).int64(e.user_id),e.is_remember!==!1&&n.uint32(40).bool(e.is_remember),e.api_url!==""&&n.uint32(50).string(e.api_url),e.id_token!==""&&n.uint32(58).string(e.id_token),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Xe();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.created=t.bool();continue;case 2:if(i!==18)break;a.token=t.string();continue;case 3:if(i!==26)break;a.refresh_token=t.string();continue;case 4:if(i!==32)break;a.user_id=m(t.int64());continue;case 5:if(i!==40)break;a.is_remember=t.bool();continue;case 6:if(i!==50)break;a.api_url=t.string();continue;case 7:if(i!==58)break;a.id_token=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{created:s(e.created)?globalThis.Boolean(e.created):!1,token:s(e.token)?globalThis.String(e.token):"",refresh_token:s(e.refresh_token)?globalThis.String(e.refresh_token):"",user_id:s(e.user_id)?globalThis.String(e.user_id):"0",is_remember:s(e.is_remember)?globalThis.Boolean(e.is_remember):!1,api_url:s(e.api_url)?globalThis.String(e.api_url):"",id_token:s(e.id_token)?globalThis.String(e.id_token):""}},toJSON(e){let n={};return e.created!==!1&&(n.created=e.created),e.token!==""&&(n.token=e.token),e.refresh_token!==""&&(n.refresh_token=e.refresh_token),e.user_id!=="0"&&(n.user_id=e.user_id),e.is_remember!==!1&&(n.is_remember=e.is_remember),e.api_url!==""&&(n.api_url=e.api_url),e.id_token!==""&&(n.id_token=e.id_token),n},create(e){return Re.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c;let n=Xe();return n.created=(t=e.created)!=null?t:!1,n.token=(r=e.token)!=null?r:"",n.refresh_token=(a=e.refresh_token)!=null?a:"",n.user_id=(i=e.user_id)!=null?i:"0",n.is_remember=(o=e.is_remember)!=null?o:!1,n.api_url=(l=e.api_url)!=null?l:"",n.id_token=(c=e.id_token)!=null?c:"",n}};function Ze(){return{token:"",vars:{},is_remember:!1}}var Se={encode(e,n=f.default.Writer.create()){return e.token!==""&&n.uint32(10).string(e.token),Object.entries(e.vars).forEach(([t,r])=>{Ne.encode({key:t,value:r},n.uint32(18).fork()).ldelim()}),e.is_remember!==!1&&n.uint32(24).bool(e.is_remember),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Ze();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.token=t.string();continue;case 2:if(i!==18)break;let o=Ne.decode(t,t.uint32());o.value!==void 0&&(a.vars[o.key]=o.value);continue;case 3:if(i!==24)break;a.is_remember=t.bool();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{token:s(e.token)?globalThis.String(e.token):"",vars:Dn(e.vars)?Object.entries(e.vars).reduce((n,[t,r])=>(n[t]=String(r),n),{}):{},is_remember:s(e.is_remember)?globalThis.Boolean(e.is_remember):!1}},toJSON(e){let n={};if(e.token!==""&&(n.token=e.token),e.vars){let t=Object.entries(e.vars);t.length>0&&(n.vars={},t.forEach(([r,a])=>{n.vars[r]=a}))}return e.is_remember!==!1&&(n.is_remember=e.is_remember),n},create(e){return Se.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a;let n=Ze();return n.token=(t=e.token)!=null?t:"",n.vars=Object.entries((r=e.vars)!=null?r:{}).reduce((i,[o,l])=>(l!==void 0&&(i[o]=globalThis.String(l)),i),{}),n.is_remember=(a=e.is_remember)!=null?a:!1,n}};function $e(){return{key:"",value:""}}var Ne={encode(e,n=f.default.Writer.create()){return e.key!==""&&n.uint32(10).string(e.key),e.value!==""&&n.uint32(18).string(e.value),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=$e();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.key=t.string();continue;case 2:if(i!==18)break;a.value=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{key:s(e.key)?globalThis.String(e.key):"",value:s(e.value)?globalThis.String(e.value):""}},toJSON(e){let n={};return e.key!==""&&(n.key=e.key),e.value!==""&&(n.value=e.value),n},create(e){return Ne.fromPartial(e!=null?e:{})},fromPartial(e){var t,r;let n=$e();return n.key=(t=e.key)!=null?t:"",n.value=(r=e.value)!=null?r:"",n}};function Qe(){return{clan_id:"0",parent_id:"0",channel_id:"0",category_id:"0",type:0,channel_label:"",channel_private:0,user_ids:[],app_id:"0"}}var ve={encode(e,n=f.default.Writer.create()){e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.parent_id!=="0"&&n.uint32(16).int64(e.parent_id),e.channel_id!=="0"&&n.uint32(24).int64(e.channel_id),e.category_id!=="0"&&n.uint32(32).int64(e.category_id),e.type!==0&&n.uint32(40).int32(e.type),e.channel_label!==""&&n.uint32(50).string(e.channel_label),e.channel_private!==0&&n.uint32(56).int32(e.channel_private),n.uint32(66).fork();for(let t of e.user_ids)n.int64(t);return n.ldelim(),e.app_id!=="0"&&n.uint32(72).int64(e.app_id),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Qe();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=m(t.int64());continue;case 2:if(i!==16)break;a.parent_id=m(t.int64());continue;case 3:if(i!==24)break;a.channel_id=m(t.int64());continue;case 4:if(i!==32)break;a.category_id=m(t.int64());continue;case 5:if(i!==40)break;a.type=t.int32();continue;case 6:if(i!==50)break;a.channel_label=t.string();continue;case 7:if(i!==56)break;a.channel_private=t.int32();continue;case 8:if(i===64){a.user_ids.push(m(t.int64()));continue}if(i===66){let o=t.uint32()+t.pos;for(;t.pos<o;)a.user_ids.push(m(t.int64()));continue}break;case 9:if(i!==72)break;a.app_id=m(t.int64());continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:s(e.clan_id)?globalThis.String(e.clan_id):"0",parent_id:s(e.parent_id)?globalThis.String(e.parent_id):"0",channel_id:s(e.channel_id)?globalThis.String(e.channel_id):"0",category_id:s(e.category_id)?globalThis.String(e.category_id):"0",type:s(e.type)?globalThis.Number(e.type):0,channel_label:s(e.channel_label)?globalThis.String(e.channel_label):"",channel_private:s(e.channel_private)?globalThis.Number(e.channel_private):0,user_ids:globalThis.Array.isArray(e==null?void 0:e.user_ids)?e.user_ids.map(n=>globalThis.String(n)):[],app_id:s(e.app_id)?globalThis.String(e.app_id):"0"}},toJSON(e){var t;let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.parent_id!=="0"&&(n.parent_id=e.parent_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.category_id!=="0"&&(n.category_id=e.category_id),e.type!==0&&(n.type=Math.round(e.type)),e.channel_label!==""&&(n.channel_label=e.channel_label),e.channel_private!==0&&(n.channel_private=Math.round(e.channel_private)),(t=e.user_ids)!=null&&t.length&&(n.user_ids=e.user_ids),e.app_id!=="0"&&(n.app_id=e.app_id),n},create(e){return ve.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_;let n=Qe();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.parent_id=(r=e.parent_id)!=null?r:"0",n.channel_id=(a=e.channel_id)!=null?a:"0",n.category_id=(i=e.category_id)!=null?i:"0",n.type=(o=e.type)!=null?o:0,n.channel_label=(l=e.channel_label)!=null?l:"",n.channel_private=(c=e.channel_private)!=null?c:0,n.user_ids=((d=e.user_ids)==null?void 0:d.map(p=>p))||[],n.app_id=(_=e.app_id)!=null?_:"0",n}};function je(){return{clan_id:"0",parent_id:"0",channel_id:"0",category_id:"0",category_name:"",type:0,creator_id:"0",channel_label:"",channel_private:0,avatars:[],user_ids:[],last_sent_message:void 0,last_seen_message:void 0,onlines:[],meeting_code:"",count_mess_unread:0,active:0,last_pin_message:"",usernames:[],creator_name:"",create_time_seconds:0,update_time_seconds:0,display_names:[],channel_avatar:"",clan_name:"",app_id:"0",is_mute:!1,age_restricted:0,topic:"",e2ee:0,member_count:0}}var Oe={encode(e,n=f.default.Writer.create()){e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.parent_id!=="0"&&n.uint32(16).int64(e.parent_id),e.channel_id!=="0"&&n.uint32(24).int64(e.channel_id),e.category_id!=="0"&&n.uint32(32).int64(e.category_id),e.category_name!==""&&n.uint32(42).string(e.category_name),e.type!==0&&n.uint32(48).int32(e.type),e.creator_id!=="0"&&n.uint32(56).int64(e.creator_id),e.channel_label!==""&&n.uint32(66).string(e.channel_label),e.channel_private!==0&&n.uint32(72).int32(e.channel_private);for(let t of e.avatars)n.uint32(82).string(t);n.uint32(90).fork();for(let t of e.user_ids)n.int64(t);n.ldelim(),e.last_sent_message!==void 0&&S.encode(e.last_sent_message,n.uint32(98).fork()).ldelim(),e.last_seen_message!==void 0&&S.encode(e.last_seen_message,n.uint32(106).fork()).ldelim(),n.uint32(114).fork();for(let t of e.onlines)n.bool(t);n.ldelim(),e.meeting_code!==""&&n.uint32(122).string(e.meeting_code),e.count_mess_unread!==0&&n.uint32(128).int32(e.count_mess_unread),e.active!==0&&n.uint32(136).int32(e.active),e.last_pin_message!==""&&n.uint32(146).string(e.last_pin_message);for(let t of e.usernames)n.uint32(154).string(t);e.creator_name!==""&&n.uint32(162).string(e.creator_name),e.create_time_seconds!==0&&n.uint32(168).uint32(e.create_time_seconds),e.update_time_seconds!==0&&n.uint32(176).uint32(e.update_time_seconds);for(let t of e.display_names)n.uint32(186).string(t);return e.channel_avatar!==""&&n.uint32(194).string(e.channel_avatar),e.clan_name!==""&&n.uint32(202).string(e.clan_name),e.app_id!=="0"&&n.uint32(208).int64(e.app_id),e.is_mute!==!1&&n.uint32(216).bool(e.is_mute),e.age_restricted!==0&&n.uint32(224).int32(e.age_restricted),e.topic!==""&&n.uint32(234).string(e.topic),e.e2ee!==0&&n.uint32(240).int32(e.e2ee),e.member_count!==0&&n.uint32(248).int32(e.member_count),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=je();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=m(t.int64());continue;case 2:if(i!==16)break;a.parent_id=m(t.int64());continue;case 3:if(i!==24)break;a.channel_id=m(t.int64());continue;case 4:if(i!==32)break;a.category_id=m(t.int64());continue;case 5:if(i!==42)break;a.category_name=t.string();continue;case 6:if(i!==48)break;a.type=t.int32();continue;case 7:if(i!==56)break;a.creator_id=m(t.int64());continue;case 8:if(i!==66)break;a.channel_label=t.string();continue;case 9:if(i!==72)break;a.channel_private=t.int32();continue;case 10:if(i!==82)break;a.avatars.push(t.string());continue;case 11:if(i===88){a.user_ids.push(m(t.int64()));continue}if(i===90){let o=t.uint32()+t.pos;for(;t.pos<o;)a.user_ids.push(m(t.int64()));continue}break;case 12:if(i!==98)break;a.last_sent_message=S.decode(t,t.uint32());continue;case 13:if(i!==106)break;a.last_seen_message=S.decode(t,t.uint32());continue;case 14:if(i===112){a.onlines.push(t.bool());continue}if(i===114){let o=t.uint32()+t.pos;for(;t.pos<o;)a.onlines.push(t.bool());continue}break;case 15:if(i!==122)break;a.meeting_code=t.string();continue;case 16:if(i!==128)break;a.count_mess_unread=t.int32();continue;case 17:if(i!==136)break;a.active=t.int32();continue;case 18:if(i!==146)break;a.last_pin_message=t.string();continue;case 19:if(i!==154)break;a.usernames.push(t.string());continue;case 20:if(i!==162)break;a.creator_name=t.string();continue;case 21:if(i!==168)break;a.create_time_seconds=t.uint32();continue;case 22:if(i!==176)break;a.update_time_seconds=t.uint32();continue;case 23:if(i!==186)break;a.display_names.push(t.string());continue;case 24:if(i!==194)break;a.channel_avatar=t.string();continue;case 25:if(i!==202)break;a.clan_name=t.string();continue;case 26:if(i!==208)break;a.app_id=m(t.int64());continue;case 27:if(i!==216)break;a.is_mute=t.bool();continue;case 28:if(i!==224)break;a.age_restricted=t.int32();continue;case 29:if(i!==234)break;a.topic=t.string();continue;case 30:if(i!==240)break;a.e2ee=t.int32();continue;case 31:if(i!==248)break;a.member_count=t.int32();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:s(e.clan_id)?globalThis.String(e.clan_id):"0",parent_id:s(e.parent_id)?globalThis.String(e.parent_id):"0",channel_id:s(e.channel_id)?globalThis.String(e.channel_id):"0",category_id:s(e.category_id)?globalThis.String(e.category_id):"0",category_name:s(e.category_name)?globalThis.String(e.category_name):"",type:s(e.type)?globalThis.Number(e.type):0,creator_id:s(e.creator_id)?globalThis.String(e.creator_id):"0",channel_label:s(e.channel_label)?globalThis.String(e.channel_label):"",channel_private:s(e.channel_private)?globalThis.Number(e.channel_private):0,avatars:globalThis.Array.isArray(e==null?void 0:e.avatars)?e.avatars.map(n=>globalThis.String(n)):[],user_ids:globalThis.Array.isArray(e==null?void 0:e.user_ids)?e.user_ids.map(n=>globalThis.String(n)):[],last_sent_message:s(e.last_sent_message)?S.fromJSON(e.last_sent_message):void 0,last_seen_message:s(e.last_seen_message)?S.fromJSON(e.last_seen_message):void 0,onlines:globalThis.Array.isArray(e==null?void 0:e.onlines)?e.onlines.map(n=>globalThis.Boolean(n)):[],meeting_code:s(e.meeting_code)?globalThis.String(e.meeting_code):"",count_mess_unread:s(e.count_mess_unread)?globalThis.Number(e.count_mess_unread):0,active:s(e.active)?globalThis.Number(e.active):0,last_pin_message:s(e.last_pin_message)?globalThis.String(e.last_pin_message):"",usernames:globalThis.Array.isArray(e==null?void 0:e.usernames)?e.usernames.map(n=>globalThis.String(n)):[],creator_name:s(e.creator_name)?globalThis.String(e.creator_name):"",create_time_seconds:s(e.create_time_seconds)?globalThis.Number(e.create_time_seconds):0,update_time_seconds:s(e.update_time_seconds)?globalThis.Number(e.update_time_seconds):0,display_names:globalThis.Array.isArray(e==null?void 0:e.display_names)?e.display_names.map(n=>globalThis.String(n)):[],channel_avatar:s(e.channel_avatar)?globalThis.String(e.channel_avatar):"",clan_name:s(e.clan_name)?globalThis.String(e.clan_name):"",app_id:s(e.app_id)?globalThis.String(e.app_id):"0",is_mute:s(e.is_mute)?globalThis.Boolean(e.is_mute):!1,age_restricted:s(e.age_restricted)?globalThis.Number(e.age_restricted):0,topic:s(e.topic)?globalThis.String(e.topic):"",e2ee:s(e.e2ee)?globalThis.Number(e.e2ee):0,member_count:s(e.member_count)?globalThis.Number(e.member_count):0}},toJSON(e){var t,r,a,i,o;let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.parent_id!=="0"&&(n.parent_id=e.parent_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.category_id!=="0"&&(n.category_id=e.category_id),e.category_name!==""&&(n.category_name=e.category_name),e.type!==0&&(n.type=Math.round(e.type)),e.creator_id!=="0"&&(n.creator_id=e.creator_id),e.channel_label!==""&&(n.channel_label=e.channel_label),e.channel_private!==0&&(n.channel_private=Math.round(e.channel_private)),(t=e.avatars)!=null&&t.length&&(n.avatars=e.avatars),(r=e.user_ids)!=null&&r.length&&(n.user_ids=e.user_ids),e.last_sent_message!==void 0&&(n.last_sent_message=S.toJSON(e.last_sent_message)),e.last_seen_message!==void 0&&(n.last_seen_message=S.toJSON(e.last_seen_message)),(a=e.onlines)!=null&&a.length&&(n.onlines=e.onlines),e.meeting_code!==""&&(n.meeting_code=e.meeting_code),e.count_mess_unread!==0&&(n.count_mess_unread=Math.round(e.count_mess_unread)),e.active!==0&&(n.active=Math.round(e.active)),e.last_pin_message!==""&&(n.last_pin_message=e.last_pin_message),(i=e.usernames)!=null&&i.length&&(n.usernames=e.usernames),e.creator_name!==""&&(n.creator_name=e.creator_name),e.create_time_seconds!==0&&(n.create_time_seconds=Math.round(e.create_time_seconds)),e.update_time_seconds!==0&&(n.update_time_seconds=Math.round(e.update_time_seconds)),(o=e.display_names)!=null&&o.length&&(n.display_names=e.display_names),e.channel_avatar!==""&&(n.channel_avatar=e.channel_avatar),e.clan_name!==""&&(n.clan_name=e.clan_name),e.app_id!=="0"&&(n.app_id=e.app_id),e.is_mute!==!1&&(n.is_mute=e.is_mute),e.age_restricted!==0&&(n.age_restricted=Math.round(e.age_restricted)),e.topic!==""&&(n.topic=e.topic),e.e2ee!==0&&(n.e2ee=Math.round(e.e2ee)),e.member_count!==0&&(n.member_count=Math.round(e.member_count)),n},create(e){return Oe.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p,y,M,I,N,C,Z,$,Q,j,ee,ne,te,ie,ae,re,we,qe,Ve,ze;let n=je();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.parent_id=(r=e.parent_id)!=null?r:"0",n.channel_id=(a=e.channel_id)!=null?a:"0",n.category_id=(i=e.category_id)!=null?i:"0",n.category_name=(o=e.category_name)!=null?o:"",n.type=(l=e.type)!=null?l:0,n.creator_id=(c=e.creator_id)!=null?c:"0",n.channel_label=(d=e.channel_label)!=null?d:"",n.channel_private=(_=e.channel_private)!=null?_:0,n.avatars=((p=e.avatars)==null?void 0:p.map(E=>E))||[],n.user_ids=((y=e.user_ids)==null?void 0:y.map(E=>E))||[],n.last_sent_message=e.last_sent_message!==void 0&&e.last_sent_message!==null?S.fromPartial(e.last_sent_message):void 0,n.last_seen_message=e.last_seen_message!==void 0&&e.last_seen_message!==null?S.fromPartial(e.last_seen_message):void 0,n.onlines=((M=e.onlines)==null?void 0:M.map(E=>E))||[],n.meeting_code=(I=e.meeting_code)!=null?I:"",n.count_mess_unread=(N=e.count_mess_unread)!=null?N:0,n.active=(C=e.active)!=null?C:0,n.last_pin_message=(Z=e.last_pin_message)!=null?Z:"",n.usernames=(($=e.usernames)==null?void 0:$.map(E=>E))||[],n.creator_name=(Q=e.creator_name)!=null?Q:"",n.create_time_seconds=(j=e.create_time_seconds)!=null?j:0,n.update_time_seconds=(ee=e.update_time_seconds)!=null?ee:0,n.display_names=((ne=e.display_names)==null?void 0:ne.map(E=>E))||[],n.channel_avatar=(te=e.channel_avatar)!=null?te:"",n.clan_name=(ie=e.clan_name)!=null?ie:"",n.app_id=(ae=e.app_id)!=null?ae:"0",n.is_mute=(re=e.is_mute)!=null?re:!1,n.age_restricted=(we=e.age_restricted)!=null?we:0,n.topic=(qe=e.topic)!=null?qe:"",n.e2ee=(Ve=e.e2ee)!=null?Ve:0,n.member_count=(ze=e.member_count)!=null?ze:0,n}};function m(e){return e.toString()}f.default.util.Long!==Ie.default&&(f.default.util.Long=Ie.default,f.default.configure());function Dn(e){return typeof e=="object"&&e!==null}function s(e){return e!=null}function en(){return{clan_id:"0",channel_id:"0",message_id:"0",code:0,sender_id:"0",username:"",avatar:"",content:"",channel_label:"",clan_logo:"",category_name:"",display_name:"",clan_nick:"",clan_avatar:"",reactions:new Uint8Array(0),mentions:new Uint8Array(0),attachments:new Uint8Array(0),references:new Uint8Array(0),referenced_message:new Uint8Array(0),create_time_seconds:0,update_time_seconds:0,mode:0,hide_editted:!1,is_public:!1,topic_id:"0"}}var W={encode(e,n=f.default.Writer.create()){return e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.channel_id!=="0"&&n.uint32(16).int64(e.channel_id),e.message_id!=="0"&&n.uint32(24).int64(e.message_id),e.code!==0&&n.uint32(32).int32(e.code),e.sender_id!=="0"&&n.uint32(40).int64(e.sender_id),e.username!==""&&n.uint32(50).string(e.username),e.avatar!==""&&n.uint32(58).string(e.avatar),e.content!==""&&n.uint32(66).string(e.content),e.channel_label!==""&&n.uint32(74).string(e.channel_label),e.clan_logo!==""&&n.uint32(82).string(e.clan_logo),e.category_name!==""&&n.uint32(90).string(e.category_name),e.display_name!==""&&n.uint32(98).string(e.display_name),e.clan_nick!==""&&n.uint32(106).string(e.clan_nick),e.clan_avatar!==""&&n.uint32(114).string(e.clan_avatar),e.reactions.length!==0&&n.uint32(122).bytes(e.reactions),e.mentions.length!==0&&n.uint32(130).bytes(e.mentions),e.attachments.length!==0&&n.uint32(138).bytes(e.attachments),e.references.length!==0&&n.uint32(146).bytes(e.references),e.referenced_message.length!==0&&n.uint32(154).bytes(e.referenced_message),e.create_time_seconds!==0&&n.uint32(160).uint32(e.create_time_seconds),e.update_time_seconds!==0&&n.uint32(168).uint32(e.update_time_seconds),e.mode!==0&&n.uint32(176).int32(e.mode),e.hide_editted!==!1&&n.uint32(184).bool(e.hide_editted),e.is_public!==!1&&n.uint32(192).bool(e.is_public),e.topic_id!=="0"&&n.uint32(200).int64(e.topic_id),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=en();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=m(t.int64());continue;case 2:if(i!==16)break;a.channel_id=m(t.int64());continue;case 3:if(i!==24)break;a.message_id=m(t.int64());continue;case 4:if(i!==32)break;a.code=t.int32();continue;case 5:if(i!==40)break;a.sender_id=m(t.int64());continue;case 6:if(i!==50)break;a.username=t.string();continue;case 7:if(i!==58)break;a.avatar=t.string();continue;case 8:if(i!==66)break;a.content=t.string();continue;case 9:if(i!==74)break;a.channel_label=t.string();continue;case 10:if(i!==82)break;a.clan_logo=t.string();continue;case 11:if(i!==90)break;a.category_name=t.string();continue;case 12:if(i!==98)break;a.display_name=t.string();continue;case 13:if(i!==106)break;a.clan_nick=t.string();continue;case 14:if(i!==114)break;a.clan_avatar=t.string();continue;case 15:if(i!==122)break;a.reactions=t.bytes();continue;case 16:if(i!==130)break;a.mentions=t.bytes();continue;case 17:if(i!==138)break;a.attachments=t.bytes();continue;case 18:if(i!==146)break;a.references=t.bytes();continue;case 19:if(i!==154)break;a.referenced_message=t.bytes();continue;case 20:if(i!==160)break;a.create_time_seconds=t.uint32();continue;case 21:if(i!==168)break;a.update_time_seconds=t.uint32();continue;case 22:if(i!==176)break;a.mode=t.int32();continue;case 23:if(i!==184)break;a.hide_editted=t.bool();continue;case 24:if(i!==192)break;a.is_public=t.bool();continue;case 25:if(i!==200)break;a.topic_id=m(t.int64());continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:s(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:s(e.channel_id)?globalThis.String(e.channel_id):"0",message_id:s(e.message_id)?globalThis.String(e.message_id):"0",code:s(e.code)?globalThis.Number(e.code):0,sender_id:s(e.sender_id)?globalThis.String(e.sender_id):"0",username:s(e.username)?globalThis.String(e.username):"",avatar:s(e.avatar)?globalThis.String(e.avatar):"",content:s(e.content)?globalThis.String(e.content):"",channel_label:s(e.channel_label)?globalThis.String(e.channel_label):"",clan_logo:s(e.clan_logo)?globalThis.String(e.clan_logo):"",category_name:s(e.category_name)?globalThis.String(e.category_name):"",display_name:s(e.display_name)?globalThis.String(e.display_name):"",clan_nick:s(e.clan_nick)?globalThis.String(e.clan_nick):"",clan_avatar:s(e.clan_avatar)?globalThis.String(e.clan_avatar):"",reactions:s(e.reactions)?le(e.reactions):new Uint8Array(0),mentions:s(e.mentions)?le(e.mentions):new Uint8Array(0),attachments:s(e.attachments)?le(e.attachments):new Uint8Array(0),references:s(e.references)?le(e.references):new Uint8Array(0),referenced_message:s(e.referenced_message)?le(e.referenced_message):new Uint8Array(0),create_time_seconds:s(e.create_time_seconds)?globalThis.Number(e.create_time_seconds):0,update_time_seconds:s(e.update_time_seconds)?globalThis.Number(e.update_time_seconds):0,mode:s(e.mode)?globalThis.Number(e.mode):0,hide_editted:s(e.hide_editted)?globalThis.Boolean(e.hide_editted):!1,is_public:s(e.is_public)?globalThis.Boolean(e.is_public):!1,topic_id:s(e.topic_id)?globalThis.String(e.topic_id):"0"}},toJSON(e){let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.message_id!=="0"&&(n.message_id=e.message_id),e.code!==0&&(n.code=Math.round(e.code)),e.sender_id!=="0"&&(n.sender_id=e.sender_id),e.username!==""&&(n.username=e.username),e.avatar!==""&&(n.avatar=e.avatar),e.content!==""&&(n.content=e.content),e.channel_label!==""&&(n.channel_label=e.channel_label),e.clan_logo!==""&&(n.clan_logo=e.clan_logo),e.category_name!==""&&(n.category_name=e.category_name),e.display_name!==""&&(n.display_name=e.display_name),e.clan_nick!==""&&(n.clan_nick=e.clan_nick),e.clan_avatar!==""&&(n.clan_avatar=e.clan_avatar),e.reactions.length!==0&&(n.reactions=ce(e.reactions)),e.mentions.length!==0&&(n.mentions=ce(e.mentions)),e.attachments.length!==0&&(n.attachments=ce(e.attachments)),e.references.length!==0&&(n.references=ce(e.references)),e.referenced_message.length!==0&&(n.referenced_message=ce(e.referenced_message)),e.create_time_seconds!==0&&(n.create_time_seconds=Math.round(e.create_time_seconds)),e.update_time_seconds!==0&&(n.update_time_seconds=Math.round(e.update_time_seconds)),e.mode!==0&&(n.mode=Math.round(e.mode)),e.hide_editted!==!1&&(n.hide_editted=e.hide_editted),e.is_public!==!1&&(n.is_public=e.is_public),e.topic_id!=="0"&&(n.topic_id=e.topic_id),n},create(e){return W.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p,y,M,I,N,C,Z,$,Q,j,ee,ne,te,ie,ae,re;let n=en();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.message_id=(a=e.message_id)!=null?a:"0",n.code=(i=e.code)!=null?i:0,n.sender_id=(o=e.sender_id)!=null?o:"0",n.username=(l=e.username)!=null?l:"",n.avatar=(c=e.avatar)!=null?c:"",n.content=(d=e.content)!=null?d:"",n.channel_label=(_=e.channel_label)!=null?_:"",n.clan_logo=(p=e.clan_logo)!=null?p:"",n.category_name=(y=e.category_name)!=null?y:"",n.display_name=(M=e.display_name)!=null?M:"",n.clan_nick=(I=e.clan_nick)!=null?I:"",n.clan_avatar=(N=e.clan_avatar)!=null?N:"",n.reactions=(C=e.reactions)!=null?C:new Uint8Array(0),n.mentions=(Z=e.mentions)!=null?Z:new Uint8Array(0),n.attachments=($=e.attachments)!=null?$:new Uint8Array(0),n.references=(Q=e.references)!=null?Q:new Uint8Array(0),n.referenced_message=(j=e.referenced_message)!=null?j:new Uint8Array(0),n.create_time_seconds=(ee=e.create_time_seconds)!=null?ee:0,n.update_time_seconds=(ne=e.update_time_seconds)!=null?ne:0,n.mode=(te=e.mode)!=null?te:0,n.hide_editted=(ie=e.hide_editted)!=null?ie:!1,n.is_public=(ae=e.is_public)!=null?ae:!1,n.topic_id=(re=e.topic_id)!=null?re:"0",n}};function nn(){return{id:"0",timestamp_seconds:0,sender_id:"0",content:""}}var S={encode(e,n=f.default.Writer.create()){return e.id!=="0"&&n.uint32(8).int64(e.id),e.timestamp_seconds!==0&&n.uint32(16).uint32(e.timestamp_seconds),e.sender_id!=="0"&&n.uint32(24).int64(e.sender_id),e.content!==""&&n.uint32(34).string(e.content),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=nn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.id=m(t.int64());continue;case 2:if(i!==16)break;a.timestamp_seconds=t.uint32();continue;case 3:if(i!==24)break;a.sender_id=m(t.int64());continue;case 4:if(i!==34)break;a.content=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{id:s(e.id)?globalThis.String(e.id):"0",timestamp_seconds:s(e.timestamp_seconds)?globalThis.Number(e.timestamp_seconds):0,sender_id:s(e.sender_id)?globalThis.String(e.sender_id):"0",content:s(e.content)?globalThis.String(e.content):""}},toJSON(e){let n={};return e.id!=="0"&&(n.id=e.id),e.timestamp_seconds!==0&&(n.timestamp_seconds=Math.round(e.timestamp_seconds)),e.sender_id!=="0"&&(n.sender_id=e.sender_id),e.content!==""&&(n.content=e.content),n},create(e){return S.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i;let n=nn();return n.id=(t=e.id)!=null?t:"0",n.timestamp_seconds=(r=e.timestamp_seconds)!=null?r:0,n.sender_id=(a=e.sender_id)!=null?a:"0",n.content=(i=e.content)!=null?i:"",n}};function tn(){return{id:"0",user_id:"0",username:"",role_id:"0",rolename:"",create_time_seconds:0,s:0,e:0}}var B={encode(e,n=f.default.Writer.create()){return e.id!=="0"&&n.uint32(8).int64(e.id),e.user_id!=="0"&&n.uint32(16).int64(e.user_id),e.username!==""&&n.uint32(26).string(e.username),e.role_id!=="0"&&n.uint32(32).int64(e.role_id),e.rolename!==""&&n.uint32(42).string(e.rolename),e.create_time_seconds!==0&&n.uint32(48).uint32(e.create_time_seconds),e.s!==0&&n.uint32(56).int32(e.s),e.e!==0&&n.uint32(64).int32(e.e),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=tn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.id=m(t.int64());continue;case 2:if(i!==16)break;a.user_id=m(t.int64());continue;case 3:if(i!==26)break;a.username=t.string();continue;case 4:if(i!==32)break;a.role_id=m(t.int64());continue;case 5:if(i!==42)break;a.rolename=t.string();continue;case 6:if(i!==48)break;a.create_time_seconds=t.uint32();continue;case 7:if(i!==56)break;a.s=t.int32();continue;case 8:if(i!==64)break;a.e=t.int32();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{id:s(e.id)?globalThis.String(e.id):"0",user_id:s(e.user_id)?globalThis.String(e.user_id):"0",username:s(e.username)?globalThis.String(e.username):"",role_id:s(e.role_id)?globalThis.String(e.role_id):"0",rolename:s(e.rolename)?globalThis.String(e.rolename):"",create_time_seconds:s(e.create_time_seconds)?globalThis.Number(e.create_time_seconds):0,s:s(e.s)?globalThis.Number(e.s):0,e:s(e.e)?globalThis.Number(e.e):0}},toJSON(e){let n={};return e.id!=="0"&&(n.id=e.id),e.user_id!=="0"&&(n.user_id=e.user_id),e.username!==""&&(n.username=e.username),e.role_id!=="0"&&(n.role_id=e.role_id),e.rolename!==""&&(n.rolename=e.rolename),e.create_time_seconds!==0&&(n.create_time_seconds=Math.round(e.create_time_seconds)),e.s!==0&&(n.s=Math.round(e.s)),e.e!==0&&(n.e=Math.round(e.e)),n},create(e){return B.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d;let n=tn();return n.id=(t=e.id)!=null?t:"0",n.user_id=(r=e.user_id)!=null?r:"0",n.username=(a=e.username)!=null?a:"",n.role_id=(i=e.role_id)!=null?i:"0",n.rolename=(o=e.rolename)!=null?o:"",n.create_time_seconds=(l=e.create_time_seconds)!=null?l:0,n.s=(c=e.s)!=null?c:0,n.e=(d=e.e)!=null?d:0,n}};function an(){return{filename:"",size:0,url:"",filetype:"",width:0,height:0,thumbnail:"",duration:0}}var v={encode(e,n=f.default.Writer.create()){return e.filename!==""&&n.uint32(10).string(e.filename),e.size!==0&&n.uint32(16).int32(e.size),e.url!==""&&n.uint32(26).string(e.url),e.filetype!==""&&n.uint32(34).string(e.filetype),e.width!==0&&n.uint32(40).int32(e.width),e.height!==0&&n.uint32(48).int32(e.height),e.thumbnail!==""&&n.uint32(58).string(e.thumbnail),e.duration!==0&&n.uint32(64).int32(e.duration),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=an();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.filename=t.string();continue;case 2:if(i!==16)break;a.size=t.int32();continue;case 3:if(i!==26)break;a.url=t.string();continue;case 4:if(i!==34)break;a.filetype=t.string();continue;case 5:if(i!==40)break;a.width=t.int32();continue;case 6:if(i!==48)break;a.height=t.int32();continue;case 7:if(i!==58)break;a.thumbnail=t.string();continue;case 8:if(i!==64)break;a.duration=t.int32();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{filename:s(e.filename)?globalThis.String(e.filename):"",size:s(e.size)?globalThis.Number(e.size):0,url:s(e.url)?globalThis.String(e.url):"",filetype:s(e.filetype)?globalThis.String(e.filetype):"",width:s(e.width)?globalThis.Number(e.width):0,height:s(e.height)?globalThis.Number(e.height):0,thumbnail:s(e.thumbnail)?globalThis.String(e.thumbnail):"",duration:s(e.duration)?globalThis.Number(e.duration):0}},toJSON(e){let n={};return e.filename!==""&&(n.filename=e.filename),e.size!==0&&(n.size=Math.round(e.size)),e.url!==""&&(n.url=e.url),e.filetype!==""&&(n.filetype=e.filetype),e.width!==0&&(n.width=Math.round(e.width)),e.height!==0&&(n.height=Math.round(e.height)),e.thumbnail!==""&&(n.thumbnail=e.thumbnail),e.duration!==0&&(n.duration=Math.round(e.duration)),n},create(e){return v.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d;let n=an();return n.filename=(t=e.filename)!=null?t:"",n.size=(r=e.size)!=null?r:0,n.url=(a=e.url)!=null?a:"",n.filetype=(i=e.filetype)!=null?i:"",n.width=(o=e.width)!=null?o:0,n.height=(l=e.height)!=null?l:0,n.thumbnail=(c=e.thumbnail)!=null?c:"",n.duration=(d=e.duration)!=null?d:0,n}};function rn(){return{message_id:"0",message_ref_id:"0",content:"",has_attachment:!1,ref_type:0,message_sender_id:"0",message_sender_username:"",mesages_sender_avatar:"",message_sender_clan_nick:"",message_sender_display_name:""}}var H={encode(e,n=f.default.Writer.create()){return e.message_id!=="0"&&n.uint32(8).int64(e.message_id),e.message_ref_id!=="0"&&n.uint32(16).int64(e.message_ref_id),e.content!==""&&n.uint32(26).string(e.content),e.has_attachment!==!1&&n.uint32(32).bool(e.has_attachment),e.ref_type!==0&&n.uint32(40).int32(e.ref_type),e.message_sender_id!=="0"&&n.uint32(48).int64(e.message_sender_id),e.message_sender_username!==""&&n.uint32(58).string(e.message_sender_username),e.mesages_sender_avatar!==""&&n.uint32(66).string(e.mesages_sender_avatar),e.message_sender_clan_nick!==""&&n.uint32(74).string(e.message_sender_clan_nick),e.message_sender_display_name!==""&&n.uint32(82).string(e.message_sender_display_name),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=rn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.message_id=m(t.int64());continue;case 2:if(i!==16)break;a.message_ref_id=m(t.int64());continue;case 3:if(i!==26)break;a.content=t.string();continue;case 4:if(i!==32)break;a.has_attachment=t.bool();continue;case 5:if(i!==40)break;a.ref_type=t.int32();continue;case 6:if(i!==48)break;a.message_sender_id=m(t.int64());continue;case 7:if(i!==58)break;a.message_sender_username=t.string();continue;case 8:if(i!==66)break;a.mesages_sender_avatar=t.string();continue;case 9:if(i!==74)break;a.message_sender_clan_nick=t.string();continue;case 10:if(i!==82)break;a.message_sender_display_name=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{message_id:s(e.message_id)?globalThis.String(e.message_id):"0",message_ref_id:s(e.message_ref_id)?globalThis.String(e.message_ref_id):"0",content:s(e.content)?globalThis.String(e.content):"",has_attachment:s(e.has_attachment)?globalThis.Boolean(e.has_attachment):!1,ref_type:s(e.ref_type)?globalThis.Number(e.ref_type):0,message_sender_id:s(e.message_sender_id)?globalThis.String(e.message_sender_id):"0",message_sender_username:s(e.message_sender_username)?globalThis.String(e.message_sender_username):"",mesages_sender_avatar:s(e.mesages_sender_avatar)?globalThis.String(e.mesages_sender_avatar):"",message_sender_clan_nick:s(e.message_sender_clan_nick)?globalThis.String(e.message_sender_clan_nick):"",message_sender_display_name:s(e.message_sender_display_name)?globalThis.String(e.message_sender_display_name):""}},toJSON(e){let n={};return e.message_id!=="0"&&(n.message_id=e.message_id),e.message_ref_id!=="0"&&(n.message_ref_id=e.message_ref_id),e.content!==""&&(n.content=e.content),e.has_attachment!==!1&&(n.has_attachment=e.has_attachment),e.ref_type!==0&&(n.ref_type=Math.round(e.ref_type)),e.message_sender_id!=="0"&&(n.message_sender_id=e.message_sender_id),e.message_sender_username!==""&&(n.message_sender_username=e.message_sender_username),e.mesages_sender_avatar!==""&&(n.mesages_sender_avatar=e.mesages_sender_avatar),e.message_sender_clan_nick!==""&&(n.message_sender_clan_nick=e.message_sender_clan_nick),e.message_sender_display_name!==""&&(n.message_sender_display_name=e.message_sender_display_name),n},create(e){return H.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p;let n=rn();return n.message_id=(t=e.message_id)!=null?t:"0",n.message_ref_id=(r=e.message_ref_id)!=null?r:"0",n.content=(a=e.content)!=null?a:"",n.has_attachment=(i=e.has_attachment)!=null?i:!1,n.ref_type=(o=e.ref_type)!=null?o:0,n.message_sender_id=(l=e.message_sender_id)!=null?l:"0",n.message_sender_username=(c=e.message_sender_username)!=null?c:"",n.mesages_sender_avatar=(d=e.mesages_sender_avatar)!=null?d:"",n.message_sender_clan_nick=(_=e.message_sender_clan_nick)!=null?_:"",n.message_sender_display_name=(p=e.message_sender_display_name)!=null?p:"",n}};function sn(){return{attachments:[]}}var De={encode(e,n=f.default.Writer.create()){for(let t of e.attachments)v.encode(t,n.uint32(10).fork()).ldelim();return n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=sn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.attachments.push(v.decode(t,t.uint32()));continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{attachments:globalThis.Array.isArray(e==null?void 0:e.attachments)?e.attachments.map(n=>v.fromJSON(n)):[]}},toJSON(e){var t;let n={};return(t=e.attachments)!=null&&t.length&&(n.attachments=e.attachments.map(r=>v.toJSON(r))),n},create(e){return De.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=sn();return n.attachments=((t=e.attachments)==null?void 0:t.map(r=>v.fromPartial(r)))||[],n}};function le(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{let n=globalThis.atob(e),t=new Uint8Array(n.length);for(let r=0;r<n.length;++r)t[r]=n.charCodeAt(r);return t}}function ce(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{let n=[];return e.forEach(t=>{n.push(globalThis.String.fromCharCode(t))}),globalThis.btoa(n.join(""))}}function on(){return{filename:"",filetype:"",size:0,width:0,height:0}}var Te={encode(e,n=f.default.Writer.create()){return e.filename!==""&&n.uint32(10).string(e.filename),e.filetype!==""&&n.uint32(18).string(e.filetype),e.size!==0&&n.uint32(24).int32(e.size),e.width!==0&&n.uint32(32).int32(e.width),e.height!==0&&n.uint32(40).int32(e.height),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=on();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.filename=t.string();continue;case 2:if(i!==18)break;a.filetype=t.string();continue;case 3:if(i!==24)break;a.size=t.int32();continue;case 4:if(i!==32)break;a.width=t.int32();continue;case 5:if(i!==40)break;a.height=t.int32();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{filename:s(e.filename)?globalThis.String(e.filename):"",filetype:s(e.filetype)?globalThis.String(e.filetype):"",size:s(e.size)?globalThis.Number(e.size):0,width:s(e.width)?globalThis.Number(e.width):0,height:s(e.height)?globalThis.Number(e.height):0}},toJSON(e){let n={};return e.filename!==""&&(n.filename=e.filename),e.filetype!==""&&(n.filetype=e.filetype),e.size!==0&&(n.size=Math.round(e.size)),e.width!==0&&(n.width=Math.round(e.width)),e.height!==0&&(n.height=Math.round(e.height)),n},create(e){return Te.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o;let n=on();return n.filename=(t=e.filename)!=null?t:"",n.filetype=(r=e.filetype)!=null?r:"",n.size=(a=e.size)!=null?a:0,n.width=(i=e.width)!=null?i:0,n.height=(o=e.height)!=null?o:0,n}};function ln(){return{filename:"",url:""}}var Ue={encode(e,n=f.default.Writer.create()){return e.filename!==""&&n.uint32(10).string(e.filename),e.url!==""&&n.uint32(18).string(e.url),n},decode(e,n){let t=e instanceof f.default.Reader?e:f.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=ln();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.filename=t.string();continue;case 2:if(i!==18)break;a.url=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{filename:s(e.filename)?globalThis.String(e.filename):"",url:s(e.url)?globalThis.String(e.url):""}},toJSON(e){let n={};return e.filename!==""&&(n.filename=e.filename),e.url!==""&&(n.url=e.url),n},create(e){return Ue.fromPartial(e!=null?e:{})},fromPartial(e){var t,r;let n=ln();return n.filename=(t=e.filename)!=null?t:"",n.url=(r=e.url)!=null?r:"",n}};function de(e,n,t){let r=xe({method:e},n);if(r.headers=xe({},n.headers),typeof XMLHttpRequest!="undefined"){let a=Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype,"withCredentials");a!=null&&a.set||(r.credentials="cocos-ignore")}return Object.keys(r.headers).includes("Accept")||(r.headers.Accept="application/proto"),Object.keys(r.headers).includes("Content-Type")||(r.headers["Content-Type"]="application/proto"),Object.keys(r.headers).forEach(a=>{r.headers[a]||delete r.headers[a]}),t&&(r.body=t),r}function Ce(e){if(e==null)return{t:e};let n;if(e instanceof Uint8Array)n=new TextDecoder().decode(e);else if(typeof e=="string")n=e;else return typeof e=="object"?e:{t:e};if(!n||n===""||n==="[]")return{t:n};try{return JSON.parse(n)}catch(t){try{let r=n.replace(/\n/g,"\\n").replace(/\r/g,"\\r");return JSON.parse(r)}catch(r){return console.error("JSON Parse failed completely:",{original:n,error:r}),{t:n}}}}var Un=e=>!e||e===null||e===void 0||e===""||e==="[]";function dn(e){if(Un(e))return;let n=e[0];if(n===91||n===123)return Ce(e);try{let r=e,a=new Uint8Array(r);return De.decode(a)}catch(r){return Ce(e)}}var Le=require("js-base64");var _e=class{constructor(n,t,r){this.serverKey=n;this.timeoutMs=t;this.basePath=r}setBasePath(n){this.basePath=n}authenticateIdToken(n,t,r,a={}){if(r==null)throw new Error("'body' is a required parameter but is null or undefined.");let i="/v2/account/authenticate/idtoken",o=new Map,l="";l=JSON.stringify(r||{});let c=this.buildFullUrl(this.basePath,i,o),d=de("POST",a,l);return n&&(d.headers.Authorization="Basic "+(0,Le.encode)(n+":"+t)),Promise.race([fetch(c,d).then(_=>{if(_.status==204)return _;if(_.status>=200&&_.status<300)return _.json();throw _}),new Promise((_,p)=>setTimeout(p,this.timeoutMs,"Request timed out."))])}sessionRefresh(n,t,r,a={}){if(r==null)throw new Error("'body' is a required parameter but is null or undefined.");let i="/mezon.api.Mezon/SessionRefresh",o=new Map,c=Se.encode(Se.fromPartial(r)).finish(),d=this.buildFullUrl(this.basePath,i,o),_=de("POST",a,"");return _.body=c,n&&(_.headers.Authorization="Basic "+(0,Le.encode)(n+":"+t)),Promise.race([fetch(d,_).then(p=>g(this,null,function*(){if(p.status==204)return{};if(p.status>=200&&p.status<300){let y=yield p.arrayBuffer();return Re.decode(new Uint8Array(y))}else throw p})),new Promise((p,y)=>setTimeout(()=>y(new Error("Request timed out.")),this.timeoutMs))])}createChannelDesc(n,t,r={}){if(t==null)throw new Error("'body' is a required parameter but is null or undefined.");let a="/mezon.api.Mezon/CreateChannelDesc",i=new Map,l=ve.encode(ve.fromPartial(t)).finish(),c=this.buildFullUrl(this.basePath,a,i),d=de("POST",r,"");return d.body=l,n&&(d.headers.Authorization="Bearer "+n),Promise.race([fetch(c,d).then(_=>g(this,null,function*(){if(_.status==204)return{};if(_.status>=200&&_.status<300){let p=yield _.arrayBuffer();return Oe.decode(new Uint8Array(p))}else throw _})),new Promise((_,p)=>setTimeout(()=>p(new Error("Request timed out.")),this.timeoutMs))])}uploadAttachmentFile(n,t,r={}){if(t==null)throw new Error("'body' is a required parameter but is null or undefined.");let a="/mezon.api.Mezon/UploadAttachmentFile",i=new Map,l=Te.encode(Te.fromPartial(t)).finish(),c=this.buildFullUrl(this.basePath,a,i),d=de("POST",r,"");return d.body=l,n&&(d.headers.Authorization="Bearer "+n),Promise.race([fetch(c,d).then(_=>g(this,null,function*(){if(_.status==204)return{};if(_.status>=200&&_.status<300){let p=yield _.arrayBuffer();return Ue.decode(new Uint8Array(p))}else throw _})),new Promise((_,p)=>setTimeout(()=>p(new Error("Request timed out.")),this.timeoutMs))])}buildFullUrl(n,t,r){let a=n+t+"?";for(let[i,o]of r)o instanceof Array?a+=o.reduce((l,c)=>l+encodeURIComponent(i)+"="+encodeURIComponent(c)+"&",""):o!=null&&(a+=encodeURIComponent(i)+"="+encodeURIComponent(o)+"&");return a}};var We=D(require("long")),h=D(require("protobufjs/minimal"));var Je=D(require("long")),P=D(require("protobufjs/minimal"));function _n(){return{value:!1}}var be={encode(e,n=P.default.Writer.create()){return e.value!==!1&&n.uint32(8).bool(e.value),n},decode(e,n){let t=e instanceof P.default.Reader?e:P.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=_n();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.value=t.bool();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{value:fn(e.value)?globalThis.Boolean(e.value):!1}},toJSON(e){let n={};return e.value!==!1&&(n.value=e.value),n},create(e){return be.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=_n();return n.value=(t=e.value)!=null?t:!1,n}};function un(){return{value:""}}var Pe={encode(e,n=P.default.Writer.create()){return e.value!==""&&n.uint32(10).string(e.value),n},decode(e,n){let t=e instanceof P.default.Reader?e:P.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=un();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.value=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{value:fn(e.value)?globalThis.String(e.value):""}},toJSON(e){let n={};return e.value!==""&&(n.value=e.value),n},create(e){return Pe.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=un();return n.value=(t=e.value)!=null?t:"",n}};P.default.util.Long!==Je.default&&(P.default.util.Long=Je.default,P.default.configure());function fn(e){return e!=null}function hn(){return{cid:"",channel:void 0,channel_join:void 0,channel_leave:void 0,channel_message:void 0,channel_message_ack:void 0,channel_message_send:void 0,error:void 0,ping:void 0,pong:void 0}}var ue={encode(e,n=h.default.Writer.create()){return e.cid!==""&&n.uint32(10).string(e.cid),e.channel!==void 0&&w.encode(e.channel,n.uint32(18).fork()).ldelim(),e.channel_join!==void 0&&q.encode(e.channel_join,n.uint32(34).fork()).ldelim(),e.channel_leave!==void 0&&V.encode(e.channel_leave,n.uint32(42).fork()).ldelim(),e.channel_message!==void 0&&W.encode(e.channel_message,n.uint32(50).fork()).ldelim(),e.channel_message_ack!==void 0&&z.encode(e.channel_message_ack,n.uint32(58).fork()).ldelim(),e.channel_message_send!==void 0&&F.encode(e.channel_message_send,n.uint32(66).fork()).ldelim(),e.error!==void 0&&K.encode(e.error,n.uint32(98).fork()).ldelim(),e.ping!==void 0&&Y.encode(e.ping,n.uint32(178).fork()).ldelim(),e.pong!==void 0&&G.encode(e.pong,n.uint32(186).fork()).ldelim(),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=hn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.cid=t.string();continue;case 2:if(i!==18)break;a.channel=w.decode(t,t.uint32());continue;case 4:if(i!==34)break;a.channel_join=q.decode(t,t.uint32());continue;case 5:if(i!==42)break;a.channel_leave=V.decode(t,t.uint32());continue;case 6:if(i!==50)break;a.channel_message=W.decode(t,t.uint32());continue;case 7:if(i!==58)break;a.channel_message_ack=z.decode(t,t.uint32());continue;case 8:if(i!==66)break;a.channel_message_send=F.decode(t,t.uint32());continue;case 12:if(i!==98)break;a.error=K.decode(t,t.uint32());continue;case 22:if(i!==178)break;a.ping=Y.decode(t,t.uint32());continue;case 23:if(i!==186)break;a.pong=G.decode(t,t.uint32());continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{cid:u(e.cid)?globalThis.String(e.cid):"",channel:u(e.channel)?w.fromJSON(e.channel):void 0,channel_join:u(e.channel_join)?q.fromJSON(e.channel_join):void 0,channel_leave:u(e.channel_leave)?V.fromJSON(e.channel_leave):void 0,channel_message:u(e.channel_message)?W.fromJSON(e.channel_message):void 0,channel_message_ack:u(e.channel_message_ack)?z.fromJSON(e.channel_message_ack):void 0,channel_message_send:u(e.channel_message_send)?F.fromJSON(e.channel_message_send):void 0,error:u(e.error)?K.fromJSON(e.error):void 0,ping:u(e.ping)?Y.fromJSON(e.ping):void 0,pong:u(e.pong)?G.fromJSON(e.pong):void 0}},toJSON(e){let n={};return e.cid!==""&&(n.cid=e.cid),e.channel!==void 0&&(n.channel=w.toJSON(e.channel)),e.channel_join!==void 0&&(n.channel_join=q.toJSON(e.channel_join)),e.channel_leave!==void 0&&(n.channel_leave=V.toJSON(e.channel_leave)),e.channel_message!==void 0&&(n.channel_message=W.toJSON(e.channel_message)),e.channel_message_ack!==void 0&&(n.channel_message_ack=z.toJSON(e.channel_message_ack)),e.channel_message_send!==void 0&&(n.channel_message_send=F.toJSON(e.channel_message_send)),e.error!==void 0&&(n.error=K.toJSON(e.error)),e.ping!==void 0&&(n.ping=Y.toJSON(e.ping)),e.pong!==void 0&&(n.pong=G.toJSON(e.pong)),n},create(e){return ue.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=hn();return n.cid=(t=e.cid)!=null?t:"",n.channel=e.channel!==void 0&&e.channel!==null?w.fromPartial(e.channel):void 0,n.channel_join=e.channel_join!==void 0&&e.channel_join!==null?q.fromPartial(e.channel_join):void 0,n.channel_leave=e.channel_leave!==void 0&&e.channel_leave!==null?V.fromPartial(e.channel_leave):void 0,n.channel_message=e.channel_message!==void 0&&e.channel_message!==null?W.fromPartial(e.channel_message):void 0,n.channel_message_ack=e.channel_message_ack!==void 0&&e.channel_message_ack!==null?z.fromPartial(e.channel_message_ack):void 0,n.channel_message_send=e.channel_message_send!==void 0&&e.channel_message_send!==null?F.fromPartial(e.channel_message_send):void 0,n.error=e.error!==void 0&&e.error!==null?K.fromPartial(e.error):void 0,n.ping=e.ping!==void 0&&e.ping!==null?Y.fromPartial(e.ping):void 0,n.pong=e.pong!==void 0&&e.pong!==null?G.fromPartial(e.pong):void 0,n}};function pn(){return{id:"0",presences:[],self:void 0,chanel_label:"",clan_logo:"",category_name:""}}var w={encode(e,n=h.default.Writer.create()){e.id!=="0"&&n.uint32(8).int64(e.id);for(let t of e.presences)b.encode(t,n.uint32(18).fork()).ldelim();return e.self!==void 0&&b.encode(e.self,n.uint32(26).fork()).ldelim(),e.chanel_label!==""&&n.uint32(34).string(e.chanel_label),e.clan_logo!==""&&n.uint32(42).string(e.clan_logo),e.category_name!==""&&n.uint32(50).string(e.category_name),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=pn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.id=T(t.int64());continue;case 2:if(i!==18)break;a.presences.push(b.decode(t,t.uint32()));continue;case 3:if(i!==26)break;a.self=b.decode(t,t.uint32());continue;case 4:if(i!==34)break;a.chanel_label=t.string();continue;case 5:if(i!==42)break;a.clan_logo=t.string();continue;case 6:if(i!==50)break;a.category_name=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{id:u(e.id)?globalThis.String(e.id):"0",presences:globalThis.Array.isArray(e==null?void 0:e.presences)?e.presences.map(n=>b.fromJSON(n)):[],self:u(e.self)?b.fromJSON(e.self):void 0,chanel_label:u(e.chanel_label)?globalThis.String(e.chanel_label):"",clan_logo:u(e.clan_logo)?globalThis.String(e.clan_logo):"",category_name:u(e.category_name)?globalThis.String(e.category_name):""}},toJSON(e){var t;let n={};return e.id!=="0"&&(n.id=e.id),(t=e.presences)!=null&&t.length&&(n.presences=e.presences.map(r=>b.toJSON(r))),e.self!==void 0&&(n.self=b.toJSON(e.self)),e.chanel_label!==""&&(n.chanel_label=e.chanel_label),e.clan_logo!==""&&(n.clan_logo=e.clan_logo),e.category_name!==""&&(n.category_name=e.category_name),n},create(e){return w.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o;let n=pn();return n.id=(t=e.id)!=null?t:"0",n.presences=((r=e.presences)==null?void 0:r.map(l=>b.fromPartial(l)))||[],n.self=e.self!==void 0&&e.self!==null?b.fromPartial(e.self):void 0,n.chanel_label=(a=e.chanel_label)!=null?a:"",n.clan_logo=(i=e.clan_logo)!=null?i:"",n.category_name=(o=e.category_name)!=null?o:"",n}};function mn(){return{clan_id:"0",channel_id:"0",channel_type:0,is_public:!1}}var q={encode(e,n=h.default.Writer.create()){return e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.channel_id!=="0"&&n.uint32(16).int64(e.channel_id),e.channel_type!==0&&n.uint32(24).int32(e.channel_type),e.is_public!==!1&&n.uint32(32).bool(e.is_public),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=mn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=T(t.int64());continue;case 2:if(i!==16)break;a.channel_id=T(t.int64());continue;case 3:if(i!==24)break;a.channel_type=t.int32();continue;case 4:if(i!==32)break;a.is_public=t.bool();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:u(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:u(e.channel_id)?globalThis.String(e.channel_id):"0",channel_type:u(e.channel_type)?globalThis.Number(e.channel_type):0,is_public:u(e.is_public)?globalThis.Boolean(e.is_public):!1}},toJSON(e){let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.channel_type!==0&&(n.channel_type=Math.round(e.channel_type)),e.is_public!==!1&&(n.is_public=e.is_public),n},create(e){return q.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i;let n=mn();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.channel_type=(a=e.channel_type)!=null?a:0,n.is_public=(i=e.is_public)!=null?i:!1,n}};function gn(){return{clan_id:"0",channel_id:"0",channel_type:0,is_public:!1}}var V={encode(e,n=h.default.Writer.create()){return e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.channel_id!=="0"&&n.uint32(16).int64(e.channel_id),e.channel_type!==0&&n.uint32(24).int32(e.channel_type),e.is_public!==!1&&n.uint32(32).bool(e.is_public),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=gn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=T(t.int64());continue;case 2:if(i!==16)break;a.channel_id=T(t.int64());continue;case 3:if(i!==24)break;a.channel_type=t.int32();continue;case 4:if(i!==32)break;a.is_public=t.bool();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:u(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:u(e.channel_id)?globalThis.String(e.channel_id):"0",channel_type:u(e.channel_type)?globalThis.Number(e.channel_type):0,is_public:u(e.is_public)?globalThis.Boolean(e.is_public):!1}},toJSON(e){let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.channel_type!==0&&(n.channel_type=Math.round(e.channel_type)),e.is_public!==!1&&(n.is_public=e.is_public),n},create(e){return V.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i;let n=gn();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.channel_type=(a=e.channel_type)!=null?a:0,n.is_public=(i=e.is_public)!=null?i:!1,n}};function yn(){return{channel_id:"0",message_id:"0",code:0,username:"",create_time_seconds:0,update_time_seconds:0,persistent:void 0,clan_logo:"",category_name:""}}var z={encode(e,n=h.default.Writer.create()){return e.channel_id!=="0"&&n.uint32(8).int64(e.channel_id),e.message_id!=="0"&&n.uint32(16).int64(e.message_id),e.code!==0&&n.uint32(24).int32(e.code),e.username!==""&&n.uint32(34).string(e.username),e.create_time_seconds!==0&&n.uint32(40).uint32(e.create_time_seconds),e.update_time_seconds!==0&&n.uint32(48).uint32(e.update_time_seconds),e.persistent!==void 0&&be.encode({value:e.persistent},n.uint32(58).fork()).ldelim(),e.clan_logo!==""&&n.uint32(66).string(e.clan_logo),e.category_name!==""&&n.uint32(74).string(e.category_name),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=yn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.channel_id=T(t.int64());continue;case 2:if(i!==16)break;a.message_id=T(t.int64());continue;case 3:if(i!==24)break;a.code=t.int32();continue;case 4:if(i!==34)break;a.username=t.string();continue;case 5:if(i!==40)break;a.create_time_seconds=t.uint32();continue;case 6:if(i!==48)break;a.update_time_seconds=t.uint32();continue;case 7:if(i!==58)break;a.persistent=be.decode(t,t.uint32()).value;continue;case 8:if(i!==66)break;a.clan_logo=t.string();continue;case 9:if(i!==74)break;a.category_name=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{channel_id:u(e.channel_id)?globalThis.String(e.channel_id):"0",message_id:u(e.message_id)?globalThis.String(e.message_id):"0",code:u(e.code)?globalThis.Number(e.code):0,username:u(e.username)?globalThis.String(e.username):"",create_time_seconds:u(e.create_time_seconds)?globalThis.Number(e.create_time_seconds):0,update_time_seconds:u(e.update_time_seconds)?globalThis.Number(e.update_time_seconds):0,persistent:u(e.persistent)?!!e.persistent:void 0,clan_logo:u(e.clan_logo)?globalThis.String(e.clan_logo):"",category_name:u(e.category_name)?globalThis.String(e.category_name):""}},toJSON(e){let n={};return e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.message_id!=="0"&&(n.message_id=e.message_id),e.code!==0&&(n.code=Math.round(e.code)),e.username!==""&&(n.username=e.username),e.create_time_seconds!==0&&(n.create_time_seconds=Math.round(e.create_time_seconds)),e.update_time_seconds!==0&&(n.update_time_seconds=Math.round(e.update_time_seconds)),e.persistent!==void 0&&(n.persistent=e.persistent),e.clan_logo!==""&&(n.clan_logo=e.clan_logo),e.category_name!==""&&(n.category_name=e.category_name),n},create(e){return z.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_;let n=yn();return n.channel_id=(t=e.channel_id)!=null?t:"0",n.message_id=(r=e.message_id)!=null?r:"0",n.code=(a=e.code)!=null?a:0,n.username=(i=e.username)!=null?i:"",n.create_time_seconds=(o=e.create_time_seconds)!=null?o:0,n.update_time_seconds=(l=e.update_time_seconds)!=null?l:0,n.persistent=(c=e.persistent)!=null?c:void 0,n.clan_logo=(d=e.clan_logo)!=null?d:"",n.category_name=(_=e.category_name)!=null?_:"",n}};function kn(){return{clan_id:"0",channel_id:"0",content:"",mentions:[],attachments:[],references:[],mode:0,anonymous_message:!1,mention_everyone:!1,avatar:"",is_public:!1,code:0,topic_id:"0",id:"0"}}var F={encode(e,n=h.default.Writer.create()){e.clan_id!=="0"&&n.uint32(8).int64(e.clan_id),e.channel_id!=="0"&&n.uint32(16).int64(e.channel_id),e.content!==""&&n.uint32(26).string(e.content);for(let t of e.mentions)B.encode(t,n.uint32(34).fork()).ldelim();for(let t of e.attachments)v.encode(t,n.uint32(42).fork()).ldelim();for(let t of e.references)H.encode(t,n.uint32(50).fork()).ldelim();return e.mode!==0&&n.uint32(56).int32(e.mode),e.anonymous_message!==!1&&n.uint32(64).bool(e.anonymous_message),e.mention_everyone!==!1&&n.uint32(72).bool(e.mention_everyone),e.avatar!==""&&n.uint32(82).string(e.avatar),e.is_public!==!1&&n.uint32(88).bool(e.is_public),e.code!==0&&n.uint32(96).int32(e.code),e.topic_id!=="0"&&n.uint32(104).int64(e.topic_id),e.id!=="0"&&n.uint32(112).int64(e.id),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=kn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.clan_id=T(t.int64());continue;case 2:if(i!==16)break;a.channel_id=T(t.int64());continue;case 3:if(i!==26)break;a.content=t.string();continue;case 4:if(i!==34)break;a.mentions.push(B.decode(t,t.uint32()));continue;case 5:if(i!==42)break;a.attachments.push(v.decode(t,t.uint32()));continue;case 6:if(i!==50)break;a.references.push(H.decode(t,t.uint32()));continue;case 7:if(i!==56)break;a.mode=t.int32();continue;case 8:if(i!==64)break;a.anonymous_message=t.bool();continue;case 9:if(i!==72)break;a.mention_everyone=t.bool();continue;case 10:if(i!==82)break;a.avatar=t.string();continue;case 11:if(i!==88)break;a.is_public=t.bool();continue;case 12:if(i!==96)break;a.code=t.int32();continue;case 13:if(i!==104)break;a.topic_id=T(t.int64());continue;case 14:if(i!==112)break;a.id=T(t.int64());continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{clan_id:u(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:u(e.channel_id)?globalThis.String(e.channel_id):"0",content:u(e.content)?globalThis.String(e.content):"",mentions:globalThis.Array.isArray(e==null?void 0:e.mentions)?e.mentions.map(n=>B.fromJSON(n)):[],attachments:globalThis.Array.isArray(e==null?void 0:e.attachments)?e.attachments.map(n=>v.fromJSON(n)):[],references:globalThis.Array.isArray(e==null?void 0:e.references)?e.references.map(n=>H.fromJSON(n)):[],mode:u(e.mode)?globalThis.Number(e.mode):0,anonymous_message:u(e.anonymous_message)?globalThis.Boolean(e.anonymous_message):!1,mention_everyone:u(e.mention_everyone)?globalThis.Boolean(e.mention_everyone):!1,avatar:u(e.avatar)?globalThis.String(e.avatar):"",is_public:u(e.is_public)?globalThis.Boolean(e.is_public):!1,code:u(e.code)?globalThis.Number(e.code):0,topic_id:u(e.topic_id)?globalThis.String(e.topic_id):"0",id:u(e.id)?globalThis.String(e.id):"0"}},toJSON(e){var t,r,a;let n={};return e.clan_id!=="0"&&(n.clan_id=e.clan_id),e.channel_id!=="0"&&(n.channel_id=e.channel_id),e.content!==""&&(n.content=e.content),(t=e.mentions)!=null&&t.length&&(n.mentions=e.mentions.map(i=>B.toJSON(i))),(r=e.attachments)!=null&&r.length&&(n.attachments=e.attachments.map(i=>v.toJSON(i))),(a=e.references)!=null&&a.length&&(n.references=e.references.map(i=>H.toJSON(i))),e.mode!==0&&(n.mode=Math.round(e.mode)),e.anonymous_message!==!1&&(n.anonymous_message=e.anonymous_message),e.mention_everyone!==!1&&(n.mention_everyone=e.mention_everyone),e.avatar!==""&&(n.avatar=e.avatar),e.is_public!==!1&&(n.is_public=e.is_public),e.code!==0&&(n.code=Math.round(e.code)),e.topic_id!=="0"&&(n.topic_id=e.topic_id),e.id!=="0"&&(n.id=e.id),n},create(e){return F.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p,y,M,I,N;let n=kn();return n.clan_id=(t=e.clan_id)!=null?t:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.content=(a=e.content)!=null?a:"",n.mentions=((i=e.mentions)==null?void 0:i.map(C=>B.fromPartial(C)))||[],n.attachments=((o=e.attachments)==null?void 0:o.map(C=>v.fromPartial(C)))||[],n.references=((l=e.references)==null?void 0:l.map(C=>H.fromPartial(C)))||[],n.mode=(c=e.mode)!=null?c:0,n.anonymous_message=(d=e.anonymous_message)!=null?d:!1,n.mention_everyone=(_=e.mention_everyone)!=null?_:!1,n.avatar=(p=e.avatar)!=null?p:"",n.is_public=(y=e.is_public)!=null?y:!1,n.code=(M=e.code)!=null?M:0,n.topic_id=(I=e.topic_id)!=null?I:"0",n.id=(N=e.id)!=null?N:"0",n}};function Sn(){return{code:0,message:"",context:{}}}var K={encode(e,n=h.default.Writer.create()){return e.code!==0&&n.uint32(8).int32(e.code),e.message!==""&&n.uint32(18).string(e.message),Object.entries(e.context).forEach(([t,r])=>{Be.encode({key:t,value:r},n.uint32(26).fork()).ldelim()}),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Sn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.code=t.int32();continue;case 2:if(i!==18)break;a.message=t.string();continue;case 3:if(i!==26)break;let o=Be.decode(t,t.uint32());o.value!==void 0&&(a.context[o.key]=o.value);continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{code:u(e.code)?globalThis.Number(e.code):0,message:u(e.message)?globalThis.String(e.message):"",context:Ln(e.context)?Object.entries(e.context).reduce((n,[t,r])=>(n[t]=String(r),n),{}):{}}},toJSON(e){let n={};if(e.code!==0&&(n.code=Math.round(e.code)),e.message!==""&&(n.message=e.message),e.context){let t=Object.entries(e.context);t.length>0&&(n.context={},t.forEach(([r,a])=>{n.context[r]=a}))}return n},create(e){return K.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a;let n=Sn();return n.code=(t=e.code)!=null?t:0,n.message=(r=e.message)!=null?r:"",n.context=Object.entries((a=e.context)!=null?a:{}).reduce((i,[o,l])=>(l!==void 0&&(i[o]=globalThis.String(l)),i),{}),n}};function vn(){return{key:"",value:""}}var Be={encode(e,n=h.default.Writer.create()){return e.key!==""&&n.uint32(10).string(e.key),e.value!==""&&n.uint32(18).string(e.value),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=vn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==10)break;a.key=t.string();continue;case 2:if(i!==18)break;a.value=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{key:u(e.key)?globalThis.String(e.key):"",value:u(e.value)?globalThis.String(e.value):""}},toJSON(e){let n={};return e.key!==""&&(n.key=e.key),e.value!==""&&(n.value=e.value),n},create(e){return Be.fromPartial(e!=null?e:{})},fromPartial(e){var t,r;let n=vn();return n.key=(t=e.key)!=null?t:"",n.value=(r=e.value)!=null?r:"",n}};function Tn(){return{}}var Y={encode(e,n=h.default.Writer.create()){return n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Tn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{}},toJSON(e){return{}},create(e){return Y.fromPartial(e!=null?e:{})},fromPartial(e){return Tn()}};function Cn(){return{}}var G={encode(e,n=h.default.Writer.create()){return n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Cn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{}},toJSON(e){return{}},create(e){return G.fromPartial(e!=null?e:{})},fromPartial(e){return Cn()}};function bn(){return{user_id:"0",session_id:"",username:"",status:void 0,is_mobile:!1,user_status:""}}var b={encode(e,n=h.default.Writer.create()){return e.user_id!=="0"&&n.uint32(8).int64(e.user_id),e.session_id!==""&&n.uint32(18).string(e.session_id),e.username!==""&&n.uint32(26).string(e.username),e.status!==void 0&&Pe.encode({value:e.status},n.uint32(34).fork()).ldelim(),e.is_mobile!==!1&&n.uint32(40).bool(e.is_mobile),e.user_status!==""&&n.uint32(50).string(e.user_status),n},decode(e,n){let t=e instanceof h.default.Reader?e:h.default.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=bn();for(;t.pos<r;){let i=t.uint32();switch(i>>>3){case 1:if(i!==8)break;a.user_id=T(t.int64());continue;case 2:if(i!==18)break;a.session_id=t.string();continue;case 3:if(i!==26)break;a.username=t.string();continue;case 4:if(i!==34)break;a.status=Pe.decode(t,t.uint32()).value;continue;case 5:if(i!==40)break;a.is_mobile=t.bool();continue;case 6:if(i!==50)break;a.user_status=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{user_id:u(e.user_id)?globalThis.String(e.user_id):"0",session_id:u(e.session_id)?globalThis.String(e.session_id):"",username:u(e.username)?globalThis.String(e.username):"",status:u(e.status)?String(e.status):void 0,is_mobile:u(e.is_mobile)?globalThis.Boolean(e.is_mobile):!1,user_status:u(e.user_status)?globalThis.String(e.user_status):""}},toJSON(e){let n={};return e.user_id!=="0"&&(n.user_id=e.user_id),e.session_id!==""&&(n.session_id=e.session_id),e.username!==""&&(n.username=e.username),e.status!==void 0&&(n.status=e.status),e.is_mobile!==!1&&(n.is_mobile=e.is_mobile),e.user_status!==""&&(n.user_status=e.user_status),n},create(e){return b.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l;let n=bn();return n.user_id=(t=e.user_id)!=null?t:"0",n.session_id=(r=e.session_id)!=null?r:"",n.username=(a=e.username)!=null?a:"",n.status=(i=e.status)!=null?i:void 0,n.is_mobile=(o=e.is_mobile)!=null?o:!1,n.user_status=(l=e.user_status)!=null?l:"",n}};function T(e){return e.toString()}h.default.util.Long!==We.default&&(h.default.util.Long=We.default,h.default.configure());function Ln(e){return typeof e=="object"&&e!==null}function u(e){return e!=null}var R=class{constructor(){}get onClose(){return this._socket.onclose}set onClose(n){this._socket.onclose=n}get onError(){return this._socket.onerror}set onError(n){this._socket.onerror=n}get onMessage(){return this._socket.onmessage}set onMessage(n){n?this._socket.onmessage=t=>{let r=t.data,a=new Uint8Array(r),i=ue.decode(a);i.channel_message&&i.channel_message.code==null&&(i.channel_message.code=0),n(i)}:n=null}get onOpen(){return this._socket.onopen}set onOpen(n){this._socket.onopen=n}isOpen(){var n;return((n=this._socket)==null?void 0:n.readyState)==WebSocket.OPEN}close(){var n;(n=this._socket)==null||n.close(),this._socket=void 0}connect(n,t,r,a,i,o,l){l&&l.addEventListener("abort",()=>{this.close()});let c=r?`:${r}`:"",d=`${n}${t}${c}/ws?lang=en&status=${encodeURIComponent(a.toString())}&token=${encodeURIComponent(i)}&format=protobuf&platform=${encodeURIComponent(o)}`;this._socket=new WebSocket(d),this._socket.binaryType="arraybuffer"}send(n){let r=ue.encode(ue.fromPartial(n)).finish();this._socket.send(r)}};var Pn=!1,k={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected"},x=class x{constructor(n,t,r=!1,a=!1,i=new R,o=x.DefaultSendTimeoutMs){this.host=n;this.port=t;this.useSSL=r;this.verbose=a;this.adapter=i;this.sendTimeoutMs=o;this.cIds={},this.nextCid=1,this._heartbeatTimeoutMs=x.DefaultHeartbeatTimeoutMs,this._connectionState=k.DISCONNECTED}generatecid(){let n=this.nextCid.toString();return++this.nextCid,n}isOpen(){return this._connectionState===k.CONNECTED}connect(n,t=!1,r="",a=x.DefaultConnectTimeoutMs,i){if(this._connectionState===k.CONNECTED)return Promise.resolve(n);if(this._connectionState===k.CONNECTING&&this._connectPromise)return this._connectPromise;this.clearConnectTimeout(),this._connectionState=k.CONNECTING;let o=this.useSSL?"wss://":"ws://";this.adapter.connect(o,this.host,this.port,t,n.token,r,i),this.adapter.onClose=c=>{this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.clearConnectTimeout(),this.ondisconnect(c)},this.adapter.onMessage=c=>g(this,null,function*(){if(this.verbose&&window&&window.console&&console.log("Response: %o",JSON.stringify(c)),c.cid){let d=this.cIds[c.cid];if(!d){this.verbose&&window&&window.console&&console.error("No promise executor for message: %o",c);return}delete this.cIds[c.cid],c.error?d.reject(c.error):d.resolve(c)}else if(c.channel_message){let d=Wn(c);this.onchannelmessage(d)}else this.verbose&&window&&window.console&&console.log("Unrecognized message received: %o",c)});let l=new Promise((c,d)=>{this.adapter.onOpen=_=>{this.verbose&&window&&window.console&&console.log(_);let p=Pn;Pn=!0,this.clearConnectTimeout(),this._connectionState=k.CONNECTED,this.startHeartbeatLoop(),this._connectPromise=void 0,c(n),p&&this.onreconnect(_)},this.adapter.onError=_=>{this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.clearConnectTimeout(),this.onerror(_),this._connectPromise=void 0,this.adapter.close(),d(_)},this._connectTimeoutTimer=setTimeout(()=>{this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.adapter.close(),this._connectPromise=void 0,d("The socket timed out when trying to connect."),this._connectTimeoutTimer=void 0},a)});return this._connectPromise=l,this._connectPromise}disconnect(n=!0){this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.adapter.isOpen()&&this.adapter.close(),n&&this.ondisconnect({})}setHeartbeatTimeoutMs(n){this._heartbeatTimeoutMs=n}getHeartbeatTimeoutMs(){return this._heartbeatTimeoutMs}onreconnect(n){this.verbose&&window&&window.console&&console.log(n)}ondisconnect(n){this.verbose&&window&&window.console&&console.log(n)}onerror(n){this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.verbose&&window&&window.console&&console.log(n)}onheartbeattimeout(){this.verbose&&window&&window.console&&console.log("Heartbeat timeout.")}onchannelmessage(n){this.verbose&&window&&window.console&&console.log(n)}send(n,t=x.DefaultSendTimeoutMs){let r=n;return new Promise((a,i)=>{var o,l;if(!this.adapter.isOpen())i("Socket connection has not been established yet.");else{r.channel_message_send?r.channel_message_send.content=JSON.stringify(r.channel_message_send.content):r.channel_message_update?r.channel_message_update.content=JSON.stringify(r.channel_message_update.content):r.ephemeral_message_send?r.ephemeral_message_send.message.content=JSON.stringify((o=r.ephemeral_message_send.message)==null?void 0:o.content):r.quick_menu_event&&(r.quick_menu_event.message.content=JSON.stringify((l=r.quick_menu_event.message)==null?void 0:l.content));let c=this.generatecid();this.cIds[c]={resolve:a,reject:i},t!==1/0&&t>0&&setTimeout(()=>{i("The socket timed out while waiting for a response.")},t),r.cid=c,this.adapter.send(r)}})}joinChat(n,t,r,a){return g(this,null,function*(){return(yield this.send({channel_join:{clan_id:n,channel_id:t,channel_type:r,is_public:a}})).channel})}leaveChat(n,t,r,a){return g(this,null,function*(){return this.send({channel_leave:{clan_id:n,channel_id:t,channel_type:r,is_public:a}})})}writeChatMessage(n,t,r,a,i,o,l,c,d,_,p){return g(this,null,function*(){return(yield this.send({channel_message_send:{clan_id:n,channel_id:t,mode:r,is_public:a,content:i,reactions:[],mentions:[],attachments:o,references:[],anonymous_message:l,mention_everyone:c,avatar:d,code:_,topic_id:p}},1/0)).channel_message_ack})}pingPong(){return g(this,null,function*(){if(!this.isOpen()){this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop();return}try{yield this.send({ping:{}},this._heartbeatTimeoutMs)}catch(n){this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.adapter.isOpen()&&(window&&window.console&&console.error("Server unreachable from heartbeat."),this.onheartbeattimeout(),this.adapter.close());return}this.startHeartbeatLoop()})}startHeartbeatLoop(){this.stopHeartbeatLoop(),this._heartbeatTimer=setTimeout(()=>this.pingPong(),this._heartbeatTimeoutMs)}stopHeartbeatLoop(){this._heartbeatTimer!==void 0&&(clearTimeout(this._heartbeatTimer),this._heartbeatTimer=void 0)}clearConnectTimeout(){this._connectTimeoutTimer!==void 0&&(clearTimeout(this._connectTimeoutTimer),this._connectTimeoutTimer=void 0)}};x.DefaultHeartbeatTimeoutMs=1e4,x.DefaultSendTimeoutMs=1e4,x.DefaultConnectTimeoutMs=3e4;var fe=x;function Wn(e){var n,t;try{n=Ce(e.channel_message.content)}catch(a){console.log("content is invalid",a)}try{t=dn(e.channel_message.attachments)}catch(a){console.log("attachments is invalid",a)}var r={id:e.id||e.channel_message.message_id,avatar:e.channel_message.avatar,channel_id:e.channel_message.channel_id,mode:e.channel_message.mode,channel_label:e.channel_message.channel_label,clan_id:e.channel_message.clan_id,code:e.channel_message.code,message_id:e.channel_message.message_id,sender_id:e.channel_message.sender_id,update_time:e.channel_message.update_time,clan_logo:e.channel_message.clan_logo,category_name:e.channel_message.category_name,username:e.channel_message.username,clan_nick:e.channel_message.clan_nick,clan_avatar:e.channel_message.clan_avatar,display_name:e.channel_message.display_name,content:n,attachments:t==null?void 0:t.attachments,hide_editted:e.channel_message.hide_editted,is_public:e.channel_message.is_public,create_time_seconds:e.channel_message.create_time_seconds,update_time_seconds:e.channel_message.update_time_seconds,topic_id:e.channel_message.topic_id};return r}var X=class extends Error{constructor(t,r){super(t!=null?t:"Authentication failed.");this.statusCode=r;this.name="AuthenticationError"}},he=class extends Error{constructor(n){super(n!=null?n:"Session error."),this.name="SessionError"}};function He(e){let n=new URL(e);return`${n.protocol==="https:"?"https://":"http://"}${n.hostname}:${n.port}`}var Ee=class e{constructor(n,t,r){this.refreshTokenPromise=null;this._session=n,this._client=t,this._userId=r}get userId(){return this._userId}get session(){return this._session}get client(){return this._client}static initClient(n){let{token:t,refresh_token:r,api_url:a,ws_url:i,user_id:o,serverkey:l}=n;if(!t||!r||!a||!i||!o)throw new he("Missing required fields: token, refresh_token, api_url, ws_url, and user_id are all required");let c=oe.restore(t,r,a,i,!0),d=new _e(l||J,7e3,He(a));return new e(c,d,o)}static authenticate(n){return g(this,null,function*(){let{id_token:t,user_id:r,username:a,serverkey:i=J,gateway_url:o=pe}=n,l=new _e(i||J,7e3,He(o)),c={id_token:t,user_id:r,username:a},d=yield l.authenticateIdToken(i,"",c);if(!d)throw new X("Authentication failed: No response from server.");if(!d.token||!d.refresh_token||!d.api_url||!d.ws_url||!d.user_id)throw new X("Invalid authentication response: missing required fields");let _=oe.restore(d.token,d.refresh_token,d.api_url,d.ws_url,!0);return l.setBasePath(He(d.api_url)),new e(_,l,d.user_id)})}createDM(n){return g(this,null,function*(){let t={type:3,channel_private:1,user_ids:[n]};return this._client.createChannelDesc(this._session.token,t)})}createGroupDM(n){return g(this,null,function*(){if(n.length===0)throw new Error("At least one user ID is required for a group DM");let t={type:2,channel_private:1,user_ids:n};return this._client.createChannelDesc(this._session.token,t)})}uploadAttachment(n){return g(this,null,function*(){return this._client.uploadAttachmentFile(this._session.token,n)})}refreshSession(){return g(this,null,function*(){return this._session?(this._session.created&&this._session.expires_at-this._session.created_at<70&&console.warn("Session lifetime too short, please set '--session.token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session"),this._session.created&&this._session.refresh_expires_at-this._session.created_at<3700&&console.warn("Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session"),this.refreshTokenPromise?this.refreshTokenPromise:(this.refreshTokenPromise=new Promise((n,t)=>g(this,null,function*(){try{let r=yield this.client.sessionRefresh(this._client.serverKey||J,"",{token:this._session.refresh_token,vars:this._session.vars,is_remember:this._session.is_remember});this._session.update(r.token,r.refresh_token,r.is_remember||!1),this.onRefreshSession(r),n(this._session)}catch(r){console.error("Session refresh failed:",r),t(r)}finally{this.refreshTokenPromise=null}})),this.refreshTokenPromise)):(console.error("Cannot refresh a null session."),this._session)})}createSocket(n=!1,t=new R,r=fe.DefaultSendTimeoutMs){let{host:a,port:i,useSSL:o}={host:this._session.ws_url,port:"443",useSSL:!0};return new fe(a,i,o,n,t,r)}onRefreshSession(n){console.log(`Token refresh occurred. Token: ${n.token}`)}isSessionExpired(){return this._session.isexpired(Date.now()/1e3)}isRefreshSessionExpired(){return this._session.isrefreshexpired(Date.now()/1e3)}getToken(){return this._session.token}getRefreshToken(){return this._session.refresh_token}getSession(){return this.session}exportSession(){return{token:this._session.token,refresh_token:this._session.refresh_token,api_url:this._session.api_url||"",ws_url:this._session.ws_url||"",user_id:this._userId}}};var O=class extends Error{constructor(n){super(n),this.name="SocketError"}};function En(r){return g(this,arguments,function*(e,n=20,t=100){var l;let a=0,i=t,o=e;for(;a<n;){if((l=o.adapter)!=null&&l.isOpen())return;yield new Promise(c=>setTimeout(c,i)),i*=2,a++}throw new O(`Socket failed to connect after ${n} attempts (total wait: ~${Math.pow(2,n)*t}ms)`)})}var Ae=class{constructor(n,t){this._client=n;this._session=t;this._socket=null;this._isConnected=!1;this._messageHandlers=[]}get isConnected(){return this._isConnected}get socket(){if(!this._socket)throw new O("Socket is not connected. Call connect() first.");return this._socket}connect(){return g(this,arguments,function*(n={}){if(this._isConnected)throw new O("Socket is already connected. Call disconnect() first.");let{onError:t,onDisconnect:r,verbose:a=!1}=n;this._errorHandler=t,this._disconnectHandler=r,this._socket=this._client.createSocket(a,new R),this._socket.onerror=i=>{var o;(o=this._errorHandler)==null||o.call(this,i)},this._socket.ondisconnect=()=>{var i;this._isConnected=!1,(i=this._disconnectHandler)==null||i.call(this)},this._socket.onchannelmessage=i=>{var o;if(!i){(o=this._errorHandler)==null||o.call(this,new O("Received null or undefined channel message"));return}this._messageHandlers.forEach(l=>{try{l(i)}catch(c){console.error("Error in message handler:",c)}})},yield this._socket.connect(this._session,!0,"0"),this._isConnected=!0})}disconnect(){this._socket&&(this._socket.disconnect(!0),this._socket=null,this._isConnected=!1)}setChannelMessageHandler(n){this.onChannelMessage(n)}onChannelMessage(n){return this._messageHandlers.push(n),()=>{let t=this._messageHandlers.indexOf(n);t!==-1&&this._messageHandlers.splice(t,1)}}joinDMChannel(n){return g(this,null,function*(){yield En(this.socket),yield this.socket.joinChat(A,n,3,!1)})}joinGroupChannel(n){return g(this,null,function*(){yield En(this.socket),yield this.socket.joinChat(A,n,2,!1)})}leaveDMChannel(n){return g(this,null,function*(){yield this.socket.leaveChat(A,n,3,!1)})}leaveGroupChannel(n){return g(this,null,function*(){yield this.socket.leaveChat(A,n,2,!1)})}sendDM(n){return g(this,null,function*(){let{channelId:t,content:r,attachments:a,hideLink:i=!1}=n;yield this.socket.writeChatMessage(A,t,4,!1,r,a,!1,i,"",0)})}sendGroup(n){return g(this,null,function*(){let{channelId:t,content:r,attachments:a,hideLink:i=!1}=n;yield this.socket.writeChatMessage(A,t,3,!1,r,a,!1,i,"",0)})}setErrorHandler(n){this._errorHandler=n,this._socket&&(this._socket.onerror=n)}};
|