mezon-light-sdk 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.mjs +1 -1
- package/dist/{api.gen.d.ts → src/api.gen.d.ts} +16 -0
- package/dist/src/api.gen.d.ts.map +1 -0
- package/dist/{client.d.ts → src/client.d.ts} +22 -1
- package/dist/src/client.d.ts.map +1 -0
- package/dist/{constants.d.ts → src/constants.d.ts} +1 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/{google → src/google}/protobuf/wrappers.d.ts +1 -0
- package/dist/src/google/protobuf/wrappers.d.ts.map +1 -0
- package/dist/{index.d.ts → src/index.d.ts} +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/{proto → src/proto}/api.d.ts +37 -0
- package/dist/src/proto/api.d.ts.map +1 -0
- package/dist/{proto → src/proto}/realtime.d.ts +1 -0
- package/dist/src/proto/realtime.d.ts.map +1 -0
- package/dist/{session.d.ts → src/session.d.ts} +1 -0
- package/dist/src/session.d.ts.map +1 -0
- package/dist/{socket.d.ts → src/socket.d.ts} +1 -0
- package/dist/src/socket.d.ts.map +1 -0
- package/dist/{socket.gen.d.ts → src/socket.gen.d.ts} +1 -0
- package/dist/src/socket.gen.d.ts.map +1 -0
- package/dist/{types.d.ts → src/types.d.ts} +1 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/{utils.d.ts → src/utils.d.ts} +1 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/{web_socket_adapter_pb.d.ts → src/web_socket_adapter_pb.d.ts} +1 -0
- package/dist/src/web_socket_adapter_pb.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
package/dist/index.esm.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var kn=Object.defineProperty;var Je=Object.getOwnPropertySymbols;var Sn=Object.prototype.hasOwnProperty,vn=Object.prototype.propertyIsEnumerable;var We=(e,n,i)=>n in e?kn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i,_e=(e,n)=>{for(var i in n||(n={}))Sn.call(n,i)&&We(e,i,n[i]);if(Je)for(var i of Je(n))vn.call(n,i)&&We(e,i,n[i]);return e};var g=(e,n,i)=>new Promise((r,a)=>{var t=c=>{try{l(i.next(c))}catch(d){a(d)}},o=c=>{try{l(i.throw(c))}catch(d){a(d)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(t,o);l((i=i.apply(e,n)).next())});var ke="https://gw.mezon.ai",Se=20,ve=100,I="0",J=3,W=2,Te=4,Ce=3,H="DefaultServerKey";import*as be from"js-base64";var ae=class e{constructor(n,i,r,a,t,o){this.created=r;this.api_url=a;this.id_token=t;this.token=n,this.refresh_token=i,this.id_token=t,this.api_url=a,this.created_at=Math.floor(new Date().getTime()/1e3),this.is_remember=o,this.update(n,i,o)}isexpired(n){return this.expires_at-n<=0}isrefreshexpired(n){return this.refresh_expires_at-n<=0}update(n,i,r){let a=n.split(".");if(a.length!=3)throw"jwt is not valid.";let t=JSON.parse(be.atob(a[1])),o=Math.floor(parseInt(t.exp));if(i){let l=i.split(".");if(l.length!=3)throw"refresh jwt is not valid.";let c=JSON.parse(be.atob(l[1])),d=Math.floor(parseInt(c.exp));this.refresh_expires_at=d,this.refresh_token=i,this.is_remember=r}this.token=n,this.expires_at=o,this.username=t.usn,this.user_id=t.uid,this.vars=t.vrs}static restore(n,i,r,a){return new e(n,i,!1,r,"",a)}};import He from"long";import f from"protobufjs/minimal";function Be(){return{created:!1,token:"",refresh_token:"",user_id:"0",is_remember:!1,api_url:"",id_token:""}}var Pe={encode(e,n=f.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 i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=Be();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.created=i.bool();continue;case 2:if(t!==18)break;a.token=i.string();continue;case 3:if(t!==26)break;a.refresh_token=i.string();continue;case 4:if(t!==32)break;a.user_id=m(i.int64());continue;case 5:if(t!==40)break;a.is_remember=i.bool();continue;case 6:if(t!==50)break;a.api_url=i.string();continue;case 7:if(t!==58)break;a.id_token=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&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 Pe.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a,t,o,l,c;let n=Be();return n.created=(i=e.created)!=null?i:!1,n.token=(r=e.token)!=null?r:"",n.refresh_token=(a=e.refresh_token)!=null?a:"",n.user_id=(t=e.user_id)!=null?t:"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 we(){return{token:"",vars:{},is_remember:!1}}var ue={encode(e,n=f.Writer.create()){return e.token!==""&&n.uint32(10).string(e.token),Object.entries(e.vars).forEach(([i,r])=>{Ee.encode({key:i,value:r},n.uint32(18).fork()).ldelim()}),e.is_remember!==!1&&n.uint32(24).bool(e.is_remember),n},decode(e,n){let i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=we();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;a.token=i.string();continue;case 2:if(t!==18)break;let o=Ee.decode(i,i.uint32());o.value!==void 0&&(a.vars[o.key]=o.value);continue;case 3:if(t!==24)break;a.is_remember=i.bool();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{token:s(e.token)?globalThis.String(e.token):"",vars:Tn(e.vars)?Object.entries(e.vars).reduce((n,[i,r])=>(n[i]=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 i=Object.entries(e.vars);i.length>0&&(n.vars={},i.forEach(([r,a])=>{n.vars[r]=a}))}return e.is_remember!==!1&&(n.is_remember=e.is_remember),n},create(e){return ue.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a;let n=we();return n.token=(i=e.token)!=null?i:"",n.vars=Object.entries((r=e.vars)!=null?r:{}).reduce((t,[o,l])=>(l!==void 0&&(t[o]=globalThis.String(l)),t),{}),n.is_remember=(a=e.is_remember)!=null?a:!1,n}};function qe(){return{key:"",value:""}}var Ee={encode(e,n=f.Writer.create()){return e.key!==""&&n.uint32(10).string(e.key),e.value!==""&&n.uint32(18).string(e.value),n},decode(e,n){let i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=qe();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;a.key=i.string();continue;case 2:if(t!==18)break;a.value=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&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 Ee.fromPartial(e!=null?e:{})},fromPartial(e){var i,r;let n=qe();return n.key=(i=e.key)!=null?i:"",n.value=(r=e.value)!=null?r:"",n}};function Ve(){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 fe={encode(e,n=f.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 i of e.user_ids)n.int64(i);return n.ldelim(),e.app_id!=="0"&&n.uint32(72).int64(e.app_id),n},decode(e,n){let i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=Ve();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.clan_id=m(i.int64());continue;case 2:if(t!==16)break;a.parent_id=m(i.int64());continue;case 3:if(t!==24)break;a.channel_id=m(i.int64());continue;case 4:if(t!==32)break;a.category_id=m(i.int64());continue;case 5:if(t!==40)break;a.type=i.int32();continue;case 6:if(t!==50)break;a.channel_label=i.string();continue;case 7:if(t!==56)break;a.channel_private=i.int32();continue;case 8:if(t===64){a.user_ids.push(m(i.int64()));continue}if(t===66){let o=i.uint32()+i.pos;for(;i.pos<o;)a.user_ids.push(m(i.int64()));continue}break;case 9:if(t!==72)break;a.app_id=m(i.int64());continue}if((t&7)===4||t===0)break;i.skipType(t&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 i;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)),(i=e.user_ids)!=null&&i.length&&(n.user_ids=e.user_ids),e.app_id!=="0"&&(n.app_id=e.app_id),n},create(e){return fe.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a,t,o,l,c,d,u;let n=Ve();return n.clan_id=(i=e.clan_id)!=null?i:"0",n.parent_id=(r=e.parent_id)!=null?r:"0",n.channel_id=(a=e.channel_id)!=null?a:"0",n.category_id=(t=e.category_id)!=null?t:"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=(u=e.app_id)!=null?u:"0",n}};function Fe(){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 Me={encode(e,n=f.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 i of e.avatars)n.uint32(82).string(i);n.uint32(90).fork();for(let i of e.user_ids)n.int64(i);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 i of e.onlines)n.bool(i);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 i of e.usernames)n.uint32(154).string(i);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 i of e.display_names)n.uint32(186).string(i);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 i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=Fe();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.clan_id=m(i.int64());continue;case 2:if(t!==16)break;a.parent_id=m(i.int64());continue;case 3:if(t!==24)break;a.channel_id=m(i.int64());continue;case 4:if(t!==32)break;a.category_id=m(i.int64());continue;case 5:if(t!==42)break;a.category_name=i.string();continue;case 6:if(t!==48)break;a.type=i.int32();continue;case 7:if(t!==56)break;a.creator_id=m(i.int64());continue;case 8:if(t!==66)break;a.channel_label=i.string();continue;case 9:if(t!==72)break;a.channel_private=i.int32();continue;case 10:if(t!==82)break;a.avatars.push(i.string());continue;case 11:if(t===88){a.user_ids.push(m(i.int64()));continue}if(t===90){let o=i.uint32()+i.pos;for(;i.pos<o;)a.user_ids.push(m(i.int64()));continue}break;case 12:if(t!==98)break;a.last_sent_message=S.decode(i,i.uint32());continue;case 13:if(t!==106)break;a.last_seen_message=S.decode(i,i.uint32());continue;case 14:if(t===112){a.onlines.push(i.bool());continue}if(t===114){let o=i.uint32()+i.pos;for(;i.pos<o;)a.onlines.push(i.bool());continue}break;case 15:if(t!==122)break;a.meeting_code=i.string();continue;case 16:if(t!==128)break;a.count_mess_unread=i.int32();continue;case 17:if(t!==136)break;a.active=i.int32();continue;case 18:if(t!==146)break;a.last_pin_message=i.string();continue;case 19:if(t!==154)break;a.usernames.push(i.string());continue;case 20:if(t!==162)break;a.creator_name=i.string();continue;case 21:if(t!==168)break;a.create_time_seconds=i.uint32();continue;case 22:if(t!==176)break;a.update_time_seconds=i.uint32();continue;case 23:if(t!==186)break;a.display_names.push(i.string());continue;case 24:if(t!==194)break;a.channel_avatar=i.string();continue;case 25:if(t!==202)break;a.clan_name=i.string();continue;case 26:if(t!==208)break;a.app_id=m(i.int64());continue;case 27:if(t!==216)break;a.is_mute=i.bool();continue;case 28:if(t!==224)break;a.age_restricted=i.int32();continue;case 29:if(t!==234)break;a.topic=i.string();continue;case 30:if(t!==240)break;a.e2ee=i.int32();continue;case 31:if(t!==248)break;a.member_count=i.int32();continue}if((t&7)===4||t===0)break;i.skipType(t&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 i,r,a,t,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)),(i=e.avatars)!=null&&i.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),(t=e.usernames)!=null&&t.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 Me.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a,t,o,l,c,d,u,p,y,N,x,A,C,z,X,Z,$,Q,j,ee,ne,ie,te,Oe,De,Ue,Le;let n=Fe();return n.clan_id=(i=e.clan_id)!=null?i:"0",n.parent_id=(r=e.parent_id)!=null?r:"0",n.channel_id=(a=e.channel_id)!=null?a:"0",n.category_id=(t=e.category_id)!=null?t:"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=(u=e.channel_private)!=null?u: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=((N=e.onlines)==null?void 0:N.map(E=>E))||[],n.meeting_code=(x=e.meeting_code)!=null?x:"",n.count_mess_unread=(A=e.count_mess_unread)!=null?A:0,n.active=(C=e.active)!=null?C:0,n.last_pin_message=(z=e.last_pin_message)!=null?z:"",n.usernames=((X=e.usernames)==null?void 0:X.map(E=>E))||[],n.creator_name=(Z=e.creator_name)!=null?Z:"",n.create_time_seconds=($=e.create_time_seconds)!=null?$:0,n.update_time_seconds=(Q=e.update_time_seconds)!=null?Q:0,n.display_names=((j=e.display_names)==null?void 0:j.map(E=>E))||[],n.channel_avatar=(ee=e.channel_avatar)!=null?ee:"",n.clan_name=(ne=e.clan_name)!=null?ne:"",n.app_id=(ie=e.app_id)!=null?ie:"0",n.is_mute=(te=e.is_mute)!=null?te:!1,n.age_restricted=(Oe=e.age_restricted)!=null?Oe:0,n.topic=(De=e.topic)!=null?De:"",n.e2ee=(Ue=e.e2ee)!=null?Ue:0,n.member_count=(Le=e.member_count)!=null?Le:0,n}};function m(e){return e.toString()}f.util.Long!==He&&(f.util.Long=He,f.configure());function Tn(e){return typeof e=="object"&&e!==null}function s(e){return e!=null}function Ge(){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 O={encode(e,n=f.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 i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=Ge();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.clan_id=m(i.int64());continue;case 2:if(t!==16)break;a.channel_id=m(i.int64());continue;case 3:if(t!==24)break;a.message_id=m(i.int64());continue;case 4:if(t!==32)break;a.code=i.int32();continue;case 5:if(t!==40)break;a.sender_id=m(i.int64());continue;case 6:if(t!==50)break;a.username=i.string();continue;case 7:if(t!==58)break;a.avatar=i.string();continue;case 8:if(t!==66)break;a.content=i.string();continue;case 9:if(t!==74)break;a.channel_label=i.string();continue;case 10:if(t!==82)break;a.clan_logo=i.string();continue;case 11:if(t!==90)break;a.category_name=i.string();continue;case 12:if(t!==98)break;a.display_name=i.string();continue;case 13:if(t!==106)break;a.clan_nick=i.string();continue;case 14:if(t!==114)break;a.clan_avatar=i.string();continue;case 15:if(t!==122)break;a.reactions=i.bytes();continue;case 16:if(t!==130)break;a.mentions=i.bytes();continue;case 17:if(t!==138)break;a.attachments=i.bytes();continue;case 18:if(t!==146)break;a.references=i.bytes();continue;case 19:if(t!==154)break;a.referenced_message=i.bytes();continue;case 20:if(t!==160)break;a.create_time_seconds=i.uint32();continue;case 21:if(t!==168)break;a.update_time_seconds=i.uint32();continue;case 22:if(t!==176)break;a.mode=i.int32();continue;case 23:if(t!==184)break;a.hide_editted=i.bool();continue;case 24:if(t!==192)break;a.is_public=i.bool();continue;case 25:if(t!==200)break;a.topic_id=m(i.int64());continue}if((t&7)===4||t===0)break;i.skipType(t&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)?re(e.reactions):new Uint8Array(0),mentions:s(e.mentions)?re(e.mentions):new Uint8Array(0),attachments:s(e.attachments)?re(e.attachments):new Uint8Array(0),references:s(e.references)?re(e.references):new Uint8Array(0),referenced_message:s(e.referenced_message)?re(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=se(e.reactions)),e.mentions.length!==0&&(n.mentions=se(e.mentions)),e.attachments.length!==0&&(n.attachments=se(e.attachments)),e.references.length!==0&&(n.references=se(e.references)),e.referenced_message.length!==0&&(n.referenced_message=se(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 O.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a,t,o,l,c,d,u,p,y,N,x,A,C,z,X,Z,$,Q,j,ee,ne,ie,te;let n=Ge();return n.clan_id=(i=e.clan_id)!=null?i:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.message_id=(a=e.message_id)!=null?a:"0",n.code=(t=e.code)!=null?t: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=(u=e.channel_label)!=null?u:"",n.clan_logo=(p=e.clan_logo)!=null?p:"",n.category_name=(y=e.category_name)!=null?y:"",n.display_name=(N=e.display_name)!=null?N:"",n.clan_nick=(x=e.clan_nick)!=null?x:"",n.clan_avatar=(A=e.clan_avatar)!=null?A:"",n.reactions=(C=e.reactions)!=null?C:new Uint8Array(0),n.mentions=(z=e.mentions)!=null?z:new Uint8Array(0),n.attachments=(X=e.attachments)!=null?X:new Uint8Array(0),n.references=(Z=e.references)!=null?Z:new Uint8Array(0),n.referenced_message=($=e.referenced_message)!=null?$:new Uint8Array(0),n.create_time_seconds=(Q=e.create_time_seconds)!=null?Q:0,n.update_time_seconds=(j=e.update_time_seconds)!=null?j:0,n.mode=(ee=e.mode)!=null?ee:0,n.hide_editted=(ne=e.hide_editted)!=null?ne:!1,n.is_public=(ie=e.is_public)!=null?ie:!1,n.topic_id=(te=e.topic_id)!=null?te:"0",n}};function Ke(){return{id:"0",timestamp_seconds:0,sender_id:"0",content:""}}var S={encode(e,n=f.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 i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=Ke();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.id=m(i.int64());continue;case 2:if(t!==16)break;a.timestamp_seconds=i.uint32();continue;case 3:if(t!==24)break;a.sender_id=m(i.int64());continue;case 4:if(t!==34)break;a.content=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&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 i,r,a,t;let n=Ke();return n.id=(i=e.id)!=null?i:"0",n.timestamp_seconds=(r=e.timestamp_seconds)!=null?r:0,n.sender_id=(a=e.sender_id)!=null?a:"0",n.content=(t=e.content)!=null?t:"",n}};function Ye(){return{id:"0",user_id:"0",username:"",role_id:"0",rolename:"",create_time_seconds:0,s:0,e:0}}var D={encode(e,n=f.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 i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=Ye();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.id=m(i.int64());continue;case 2:if(t!==16)break;a.user_id=m(i.int64());continue;case 3:if(t!==26)break;a.username=i.string();continue;case 4:if(t!==32)break;a.role_id=m(i.int64());continue;case 5:if(t!==42)break;a.rolename=i.string();continue;case 6:if(t!==48)break;a.create_time_seconds=i.uint32();continue;case 7:if(t!==56)break;a.s=i.int32();continue;case 8:if(t!==64)break;a.e=i.int32();continue}if((t&7)===4||t===0)break;i.skipType(t&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 D.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a,t,o,l,c,d;let n=Ye();return n.id=(i=e.id)!=null?i:"0",n.user_id=(r=e.user_id)!=null?r:"0",n.username=(a=e.username)!=null?a:"",n.role_id=(t=e.role_id)!=null?t:"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 ze(){return{filename:"",size:0,url:"",filetype:"",width:0,height:0,thumbnail:"",duration:0}}var v={encode(e,n=f.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 i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=ze();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;a.filename=i.string();continue;case 2:if(t!==16)break;a.size=i.int32();continue;case 3:if(t!==26)break;a.url=i.string();continue;case 4:if(t!==34)break;a.filetype=i.string();continue;case 5:if(t!==40)break;a.width=i.int32();continue;case 6:if(t!==48)break;a.height=i.int32();continue;case 7:if(t!==58)break;a.thumbnail=i.string();continue;case 8:if(t!==64)break;a.duration=i.int32();continue}if((t&7)===4||t===0)break;i.skipType(t&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 i,r,a,t,o,l,c,d;let n=ze();return n.filename=(i=e.filename)!=null?i:"",n.size=(r=e.size)!=null?r:0,n.url=(a=e.url)!=null?a:"",n.filetype=(t=e.filetype)!=null?t:"",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 Xe(){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 U={encode(e,n=f.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 i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=Xe();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.message_id=m(i.int64());continue;case 2:if(t!==16)break;a.message_ref_id=m(i.int64());continue;case 3:if(t!==26)break;a.content=i.string();continue;case 4:if(t!==32)break;a.has_attachment=i.bool();continue;case 5:if(t!==40)break;a.ref_type=i.int32();continue;case 6:if(t!==48)break;a.message_sender_id=m(i.int64());continue;case 7:if(t!==58)break;a.message_sender_username=i.string();continue;case 8:if(t!==66)break;a.mesages_sender_avatar=i.string();continue;case 9:if(t!==74)break;a.message_sender_clan_nick=i.string();continue;case 10:if(t!==82)break;a.message_sender_display_name=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&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 U.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a,t,o,l,c,d,u,p;let n=Xe();return n.message_id=(i=e.message_id)!=null?i:"0",n.message_ref_id=(r=e.message_ref_id)!=null?r:"0",n.content=(a=e.content)!=null?a:"",n.has_attachment=(t=e.has_attachment)!=null?t:!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=(u=e.message_sender_clan_nick)!=null?u:"",n.message_sender_display_name=(p=e.message_sender_display_name)!=null?p:"",n}};function Ze(){return{attachments:[]}}var Ne={encode(e,n=f.Writer.create()){for(let i of e.attachments)v.encode(i,n.uint32(10).fork()).ldelim();return n},decode(e,n){let i=e instanceof f.Reader?e:f.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=Ze();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;a.attachments.push(v.decode(i,i.uint32()));continue}if((t&7)===4||t===0)break;i.skipType(t&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 i;let n={};return(i=e.attachments)!=null&&i.length&&(n.attachments=e.attachments.map(r=>v.toJSON(r))),n},create(e){return Ne.fromPartial(e!=null?e:{})},fromPartial(e){var i;let n=Ze();return n.attachments=((i=e.attachments)==null?void 0:i.map(r=>v.fromPartial(r)))||[],n}};function re(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{let n=globalThis.atob(e),i=new Uint8Array(n.length);for(let r=0;r<n.length;++r)i[r]=n.charCodeAt(r);return i}}function se(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{let n=[];return e.forEach(i=>{n.push(globalThis.String.fromCharCode(i))}),globalThis.btoa(n.join(""))}}function pe(e,n,i){let r=_e({method:e},n);if(r.headers=_e({},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]}),i&&(r.body=i),r}function he(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(i){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 Cn=e=>!e||e===null||e===void 0||e===""||e==="[]";function Qe(e){if(Cn(e))return;let n=e[0];if(n===91||n===123)return he(e);try{let r=e,a=new Uint8Array(r);return Ne.decode(a)}catch(r){return he(e)}}import{encode as je}from"js-base64";var oe=class{constructor(n,i,r){this.serverKey=n;this.timeoutMs=i;this.basePath=r}setBasePath(n){this.basePath=n}authenticateIdToken(n,i,r,a={}){if(r==null)throw new Error("'body' is a required parameter but is null or undefined.");let t="/v2/account/authenticate/idtoken",o=new Map,l="";l=JSON.stringify(r||{});let c=this.buildFullUrl(this.basePath,t,o),d=pe("POST",a,l);return n&&(d.headers.Authorization="Basic "+je(n+":"+i)),Promise.race([fetch(c,d).then(u=>{if(u.status==204)return u;if(u.status>=200&&u.status<300)return u.json();throw u}),new Promise((u,p)=>setTimeout(p,this.timeoutMs,"Request timed out."))])}sessionRefresh(n,i,r,a={}){if(r==null)throw new Error("'body' is a required parameter but is null or undefined.");let t="/mezon.api.Mezon/SessionRefresh",o=new Map,c=ue.encode(ue.fromPartial(r)).finish(),d=this.buildFullUrl(this.basePath,t,o),u=pe("POST",a,"");return u.body=c,n&&(u.headers.Authorization="Basic "+je(n+":"+i)),Promise.race([fetch(d,u).then(p=>g(this,null,function*(){if(p.status==204)return{};if(p.status>=200&&p.status<300){let y=yield p.arrayBuffer();return Pe.decode(new Uint8Array(y))}else throw p})),new Promise((p,y)=>setTimeout(()=>y(new Error("Request timed out.")),this.timeoutMs))])}createChannelDesc(n,i,r={}){if(i==null)throw new Error("'body' is a required parameter but is null or undefined.");let a="/mezon.api.Mezon/CreateChannelDesc",t=new Map,l=fe.encode(fe.fromPartial(i)).finish(),c=this.buildFullUrl(this.basePath,a,t),d=pe("POST",r,"");return d.body=l,n&&(d.headers.Authorization="Bearer "+n),Promise.race([fetch(c,d).then(u=>g(this,null,function*(){if(u.status==204)return{};if(u.status>=200&&u.status<300){let p=yield u.arrayBuffer();return Me.decode(new Uint8Array(p))}else throw u})),new Promise((u,p)=>setTimeout(()=>p(new Error("Request timed out.")),this.timeoutMs))])}buildFullUrl(n,i,r){let a=n+i+"?";for(let[t,o]of r)o instanceof Array?a+=o.reduce((l,c)=>l+encodeURIComponent(t)+"="+encodeURIComponent(c)+"&",""):o!=null&&(a+=encodeURIComponent(t)+"="+encodeURIComponent(o)+"&");return a}};import rn from"long";import h from"protobufjs/minimal";import en from"long";import P from"protobufjs/minimal";function nn(){return{value:!1}}var me={encode(e,n=P.Writer.create()){return e.value!==!1&&n.uint32(8).bool(e.value),n},decode(e,n){let i=e instanceof P.Reader?e:P.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=nn();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.value=i.bool();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{value:an(e.value)?globalThis.Boolean(e.value):!1}},toJSON(e){let n={};return e.value!==!1&&(n.value=e.value),n},create(e){return me.fromPartial(e!=null?e:{})},fromPartial(e){var i;let n=nn();return n.value=(i=e.value)!=null?i:!1,n}};function tn(){return{value:""}}var ge={encode(e,n=P.Writer.create()){return e.value!==""&&n.uint32(10).string(e.value),n},decode(e,n){let i=e instanceof P.Reader?e:P.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=tn();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;a.value=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{value:an(e.value)?globalThis.String(e.value):""}},toJSON(e){let n={};return e.value!==""&&(n.value=e.value),n},create(e){return ge.fromPartial(e!=null?e:{})},fromPartial(e){var i;let n=tn();return n.value=(i=e.value)!=null?i:"",n}};P.util.Long!==en&&(P.util.Long=en,P.configure());function an(e){return e!=null}function sn(){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 le={encode(e,n=h.Writer.create()){return e.cid!==""&&n.uint32(10).string(e.cid),e.channel!==void 0&&B.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&&q.encode(e.channel_leave,n.uint32(42).fork()).ldelim(),e.channel_message!==void 0&&O.encode(e.channel_message,n.uint32(50).fork()).ldelim(),e.channel_message_ack!==void 0&&V.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&&G.encode(e.error,n.uint32(98).fork()).ldelim(),e.ping!==void 0&&K.encode(e.ping,n.uint32(178).fork()).ldelim(),e.pong!==void 0&&Y.encode(e.pong,n.uint32(186).fork()).ldelim(),n},decode(e,n){let i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=sn();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;a.cid=i.string();continue;case 2:if(t!==18)break;a.channel=B.decode(i,i.uint32());continue;case 4:if(t!==34)break;a.channel_join=w.decode(i,i.uint32());continue;case 5:if(t!==42)break;a.channel_leave=q.decode(i,i.uint32());continue;case 6:if(t!==50)break;a.channel_message=O.decode(i,i.uint32());continue;case 7:if(t!==58)break;a.channel_message_ack=V.decode(i,i.uint32());continue;case 8:if(t!==66)break;a.channel_message_send=F.decode(i,i.uint32());continue;case 12:if(t!==98)break;a.error=G.decode(i,i.uint32());continue;case 22:if(t!==178)break;a.ping=K.decode(i,i.uint32());continue;case 23:if(t!==186)break;a.pong=Y.decode(i,i.uint32());continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{cid:_(e.cid)?globalThis.String(e.cid):"",channel:_(e.channel)?B.fromJSON(e.channel):void 0,channel_join:_(e.channel_join)?w.fromJSON(e.channel_join):void 0,channel_leave:_(e.channel_leave)?q.fromJSON(e.channel_leave):void 0,channel_message:_(e.channel_message)?O.fromJSON(e.channel_message):void 0,channel_message_ack:_(e.channel_message_ack)?V.fromJSON(e.channel_message_ack):void 0,channel_message_send:_(e.channel_message_send)?F.fromJSON(e.channel_message_send):void 0,error:_(e.error)?G.fromJSON(e.error):void 0,ping:_(e.ping)?K.fromJSON(e.ping):void 0,pong:_(e.pong)?Y.fromJSON(e.pong):void 0}},toJSON(e){let n={};return e.cid!==""&&(n.cid=e.cid),e.channel!==void 0&&(n.channel=B.toJSON(e.channel)),e.channel_join!==void 0&&(n.channel_join=w.toJSON(e.channel_join)),e.channel_leave!==void 0&&(n.channel_leave=q.toJSON(e.channel_leave)),e.channel_message!==void 0&&(n.channel_message=O.toJSON(e.channel_message)),e.channel_message_ack!==void 0&&(n.channel_message_ack=V.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=G.toJSON(e.error)),e.ping!==void 0&&(n.ping=K.toJSON(e.ping)),e.pong!==void 0&&(n.pong=Y.toJSON(e.pong)),n},create(e){return le.fromPartial(e!=null?e:{})},fromPartial(e){var i;let n=sn();return n.cid=(i=e.cid)!=null?i:"",n.channel=e.channel!==void 0&&e.channel!==null?B.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?q.fromPartial(e.channel_leave):void 0,n.channel_message=e.channel_message!==void 0&&e.channel_message!==null?O.fromPartial(e.channel_message):void 0,n.channel_message_ack=e.channel_message_ack!==void 0&&e.channel_message_ack!==null?V.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?G.fromPartial(e.error):void 0,n.ping=e.ping!==void 0&&e.ping!==null?K.fromPartial(e.ping):void 0,n.pong=e.pong!==void 0&&e.pong!==null?Y.fromPartial(e.pong):void 0,n}};function on(){return{id:"0",presences:[],self:void 0,chanel_label:"",clan_logo:"",category_name:""}}var B={encode(e,n=h.Writer.create()){e.id!=="0"&&n.uint32(8).int64(e.id);for(let i of e.presences)b.encode(i,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 i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=on();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.id=T(i.int64());continue;case 2:if(t!==18)break;a.presences.push(b.decode(i,i.uint32()));continue;case 3:if(t!==26)break;a.self=b.decode(i,i.uint32());continue;case 4:if(t!==34)break;a.chanel_label=i.string();continue;case 5:if(t!==42)break;a.clan_logo=i.string();continue;case 6:if(t!==50)break;a.category_name=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{id:_(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:_(e.self)?b.fromJSON(e.self):void 0,chanel_label:_(e.chanel_label)?globalThis.String(e.chanel_label):"",clan_logo:_(e.clan_logo)?globalThis.String(e.clan_logo):"",category_name:_(e.category_name)?globalThis.String(e.category_name):""}},toJSON(e){var i;let n={};return e.id!=="0"&&(n.id=e.id),(i=e.presences)!=null&&i.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 B.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a,t,o;let n=on();return n.id=(i=e.id)!=null?i:"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=(t=e.clan_logo)!=null?t:"",n.category_name=(o=e.category_name)!=null?o:"",n}};function ln(){return{clan_id:"0",channel_id:"0",channel_type:0,is_public:!1}}var w={encode(e,n=h.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 i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=ln();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.clan_id=T(i.int64());continue;case 2:if(t!==16)break;a.channel_id=T(i.int64());continue;case 3:if(t!==24)break;a.channel_type=i.int32();continue;case 4:if(t!==32)break;a.is_public=i.bool();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{clan_id:_(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:_(e.channel_id)?globalThis.String(e.channel_id):"0",channel_type:_(e.channel_type)?globalThis.Number(e.channel_type):0,is_public:_(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 i,r,a,t;let n=ln();return n.clan_id=(i=e.clan_id)!=null?i:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.channel_type=(a=e.channel_type)!=null?a:0,n.is_public=(t=e.is_public)!=null?t:!1,n}};function cn(){return{clan_id:"0",channel_id:"0",channel_type:0,is_public:!1}}var q={encode(e,n=h.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 i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=cn();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.clan_id=T(i.int64());continue;case 2:if(t!==16)break;a.channel_id=T(i.int64());continue;case 3:if(t!==24)break;a.channel_type=i.int32();continue;case 4:if(t!==32)break;a.is_public=i.bool();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{clan_id:_(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:_(e.channel_id)?globalThis.String(e.channel_id):"0",channel_type:_(e.channel_type)?globalThis.Number(e.channel_type):0,is_public:_(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 i,r,a,t;let n=cn();return n.clan_id=(i=e.clan_id)!=null?i:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.channel_type=(a=e.channel_type)!=null?a:0,n.is_public=(t=e.is_public)!=null?t:!1,n}};function dn(){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 V={encode(e,n=h.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&&me.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 i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=dn();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.channel_id=T(i.int64());continue;case 2:if(t!==16)break;a.message_id=T(i.int64());continue;case 3:if(t!==24)break;a.code=i.int32();continue;case 4:if(t!==34)break;a.username=i.string();continue;case 5:if(t!==40)break;a.create_time_seconds=i.uint32();continue;case 6:if(t!==48)break;a.update_time_seconds=i.uint32();continue;case 7:if(t!==58)break;a.persistent=me.decode(i,i.uint32()).value;continue;case 8:if(t!==66)break;a.clan_logo=i.string();continue;case 9:if(t!==74)break;a.category_name=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{channel_id:_(e.channel_id)?globalThis.String(e.channel_id):"0",message_id:_(e.message_id)?globalThis.String(e.message_id):"0",code:_(e.code)?globalThis.Number(e.code):0,username:_(e.username)?globalThis.String(e.username):"",create_time_seconds:_(e.create_time_seconds)?globalThis.Number(e.create_time_seconds):0,update_time_seconds:_(e.update_time_seconds)?globalThis.Number(e.update_time_seconds):0,persistent:_(e.persistent)?!!e.persistent:void 0,clan_logo:_(e.clan_logo)?globalThis.String(e.clan_logo):"",category_name:_(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 V.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a,t,o,l,c,d,u;let n=dn();return n.channel_id=(i=e.channel_id)!=null?i:"0",n.message_id=(r=e.message_id)!=null?r:"0",n.code=(a=e.code)!=null?a:0,n.username=(t=e.username)!=null?t:"",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=(u=e.category_name)!=null?u:"",n}};function _n(){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.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 i of e.mentions)D.encode(i,n.uint32(34).fork()).ldelim();for(let i of e.attachments)v.encode(i,n.uint32(42).fork()).ldelim();for(let i of e.references)U.encode(i,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 i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=_n();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.clan_id=T(i.int64());continue;case 2:if(t!==16)break;a.channel_id=T(i.int64());continue;case 3:if(t!==26)break;a.content=i.string();continue;case 4:if(t!==34)break;a.mentions.push(D.decode(i,i.uint32()));continue;case 5:if(t!==42)break;a.attachments.push(v.decode(i,i.uint32()));continue;case 6:if(t!==50)break;a.references.push(U.decode(i,i.uint32()));continue;case 7:if(t!==56)break;a.mode=i.int32();continue;case 8:if(t!==64)break;a.anonymous_message=i.bool();continue;case 9:if(t!==72)break;a.mention_everyone=i.bool();continue;case 10:if(t!==82)break;a.avatar=i.string();continue;case 11:if(t!==88)break;a.is_public=i.bool();continue;case 12:if(t!==96)break;a.code=i.int32();continue;case 13:if(t!==104)break;a.topic_id=T(i.int64());continue;case 14:if(t!==112)break;a.id=T(i.int64());continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{clan_id:_(e.clan_id)?globalThis.String(e.clan_id):"0",channel_id:_(e.channel_id)?globalThis.String(e.channel_id):"0",content:_(e.content)?globalThis.String(e.content):"",mentions:globalThis.Array.isArray(e==null?void 0:e.mentions)?e.mentions.map(n=>D.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=>U.fromJSON(n)):[],mode:_(e.mode)?globalThis.Number(e.mode):0,anonymous_message:_(e.anonymous_message)?globalThis.Boolean(e.anonymous_message):!1,mention_everyone:_(e.mention_everyone)?globalThis.Boolean(e.mention_everyone):!1,avatar:_(e.avatar)?globalThis.String(e.avatar):"",is_public:_(e.is_public)?globalThis.Boolean(e.is_public):!1,code:_(e.code)?globalThis.Number(e.code):0,topic_id:_(e.topic_id)?globalThis.String(e.topic_id):"0",id:_(e.id)?globalThis.String(e.id):"0"}},toJSON(e){var i,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),(i=e.mentions)!=null&&i.length&&(n.mentions=e.mentions.map(t=>D.toJSON(t))),(r=e.attachments)!=null&&r.length&&(n.attachments=e.attachments.map(t=>v.toJSON(t))),(a=e.references)!=null&&a.length&&(n.references=e.references.map(t=>U.toJSON(t))),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 i,r,a,t,o,l,c,d,u,p,y,N,x,A;let n=_n();return n.clan_id=(i=e.clan_id)!=null?i:"0",n.channel_id=(r=e.channel_id)!=null?r:"0",n.content=(a=e.content)!=null?a:"",n.mentions=((t=e.mentions)==null?void 0:t.map(C=>D.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=>U.fromPartial(C)))||[],n.mode=(c=e.mode)!=null?c:0,n.anonymous_message=(d=e.anonymous_message)!=null?d:!1,n.mention_everyone=(u=e.mention_everyone)!=null?u:!1,n.avatar=(p=e.avatar)!=null?p:"",n.is_public=(y=e.is_public)!=null?y:!1,n.code=(N=e.code)!=null?N:0,n.topic_id=(x=e.topic_id)!=null?x:"0",n.id=(A=e.id)!=null?A:"0",n}};function un(){return{code:0,message:"",context:{}}}var G={encode(e,n=h.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(([i,r])=>{xe.encode({key:i,value:r},n.uint32(26).fork()).ldelim()}),n},decode(e,n){let i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=un();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.code=i.int32();continue;case 2:if(t!==18)break;a.message=i.string();continue;case 3:if(t!==26)break;let o=xe.decode(i,i.uint32());o.value!==void 0&&(a.context[o.key]=o.value);continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{code:_(e.code)?globalThis.Number(e.code):0,message:_(e.message)?globalThis.String(e.message):"",context:bn(e.context)?Object.entries(e.context).reduce((n,[i,r])=>(n[i]=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 i=Object.entries(e.context);i.length>0&&(n.context={},i.forEach(([r,a])=>{n.context[r]=a}))}return n},create(e){return G.fromPartial(e!=null?e:{})},fromPartial(e){var i,r,a;let n=un();return n.code=(i=e.code)!=null?i:0,n.message=(r=e.message)!=null?r:"",n.context=Object.entries((a=e.context)!=null?a:{}).reduce((t,[o,l])=>(l!==void 0&&(t[o]=globalThis.String(l)),t),{}),n}};function fn(){return{key:"",value:""}}var xe={encode(e,n=h.Writer.create()){return e.key!==""&&n.uint32(10).string(e.key),e.value!==""&&n.uint32(18).string(e.value),n},decode(e,n){let i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=fn();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;a.key=i.string();continue;case 2:if(t!==18)break;a.value=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{key:_(e.key)?globalThis.String(e.key):"",value:_(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 xe.fromPartial(e!=null?e:{})},fromPartial(e){var i,r;let n=fn();return n.key=(i=e.key)!=null?i:"",n.value=(r=e.value)!=null?r:"",n}};function hn(){return{}}var K={encode(e,n=h.Writer.create()){return n},decode(e,n){let i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=hn();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{}},toJSON(e){return{}},create(e){return K.fromPartial(e!=null?e:{})},fromPartial(e){return hn()}};function pn(){return{}}var Y={encode(e,n=h.Writer.create()){return n},decode(e,n){let i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=pn();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{}},toJSON(e){return{}},create(e){return Y.fromPartial(e!=null?e:{})},fromPartial(e){return pn()}};function mn(){return{user_id:"0",session_id:"",username:"",status:void 0,is_mobile:!1,user_status:""}}var b={encode(e,n=h.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&&ge.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 i=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?i.len:i.pos+n,a=mn();for(;i.pos<r;){let t=i.uint32();switch(t>>>3){case 1:if(t!==8)break;a.user_id=T(i.int64());continue;case 2:if(t!==18)break;a.session_id=i.string();continue;case 3:if(t!==26)break;a.username=i.string();continue;case 4:if(t!==34)break;a.status=ge.decode(i,i.uint32()).value;continue;case 5:if(t!==40)break;a.is_mobile=i.bool();continue;case 6:if(t!==50)break;a.user_status=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return a},fromJSON(e){return{user_id:_(e.user_id)?globalThis.String(e.user_id):"0",session_id:_(e.session_id)?globalThis.String(e.session_id):"",username:_(e.username)?globalThis.String(e.username):"",status:_(e.status)?String(e.status):void 0,is_mobile:_(e.is_mobile)?globalThis.Boolean(e.is_mobile):!1,user_status:_(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 i,r,a,t,o,l;let n=mn();return n.user_id=(i=e.user_id)!=null?i:"0",n.session_id=(r=e.session_id)!=null?r:"",n.username=(a=e.username)!=null?a:"",n.status=(t=e.status)!=null?t: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.util.Long!==rn&&(h.util.Long=rn,h.configure());function bn(e){return typeof e=="object"&&e!==null}function _(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=i=>{let r=i.data,a=new Uint8Array(r),t=le.decode(a);t.channel_message&&t.channel_message.code==null&&(t.channel_message.code=0),n(t)}: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,i,r,a,t,o,l){l&&l.addEventListener("abort",()=>{this.close()});let c=`${n}${i}:${r}/ws?lang=en&status=${encodeURIComponent(a.toString())}&token=${encodeURIComponent(t)}&format=protobuf&platform=${encodeURIComponent(o)}`;this._socket=new WebSocket(c),this._socket.binaryType="arraybuffer"}send(n){let r=le.encode(le.fromPartial(n)).finish();this._socket.send(r)}};var gn=!1,k={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected"},M=class M{constructor(n,i,r=!1,a=!1,t=new R,o=M.DefaultSendTimeoutMs){this.host=n;this.port=i;this.useSSL=r;this.verbose=a;this.adapter=t;this.sendTimeoutMs=o;this.cIds={},this.nextCid=1,this._heartbeatTimeoutMs=M.DefaultHeartbeatTimeoutMs,this._connectionState=k.DISCONNECTED}generatecid(){let n=this.nextCid.toString();return++this.nextCid,n}isOpen(){return this._connectionState===k.CONNECTED}connect(n,i=!1,r="",a=M.DefaultConnectTimeoutMs,t){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,i,n.token,r,t),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=Pn(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=u=>{this.verbose&&window&&window.console&&console.log(u);let p=gn;gn=!0,this.clearConnectTimeout(),this._connectionState=k.CONNECTED,this.startHeartbeatLoop(),this._connectPromise=void 0,c(n),p&&this.onreconnect(u)},this.adapter.onError=u=>{this._connectionState=k.DISCONNECTED,this.stopHeartbeatLoop(),this.clearConnectTimeout(),this.onerror(u),this._connectPromise=void 0,this.adapter.close(),d(u)},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,i=M.DefaultSendTimeoutMs){let r=n;return new Promise((a,t)=>{var o,l;if(!this.adapter.isOpen())t("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:t},i!==1/0&&i>0&&setTimeout(()=>{t("The socket timed out while waiting for a response.")},i),r.cid=c,this.adapter.send(r)}})}joinChat(n,i,r,a){return g(this,null,function*(){return(yield this.send({channel_join:{clan_id:n,channel_id:i,channel_type:r,is_public:a}})).channel})}leaveChat(n,i,r,a){return g(this,null,function*(){return this.send({channel_leave:{clan_id:n,channel_id:i,channel_type:r,is_public:a}})})}writeChatMessage(n,i,r,a,t,o,l,c,d,u,p){return g(this,null,function*(){return(yield this.send({channel_message_send:{clan_id:n,channel_id:i,mode:r,is_public:a,content:t,reactions:[],mentions:[],attachments:o,references:[],anonymous_message:l,mention_everyone:c,avatar:d,code:u,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)}};M.DefaultHeartbeatTimeoutMs=1e4,M.DefaultSendTimeoutMs=1e4,M.DefaultConnectTimeoutMs=3e4;var ce=M;function Pn(e){var n,i;try{n=he(e.channel_message.content)}catch(a){console.log("content is invalid",a)}try{i=Qe(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:i==null?void 0:i.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 de=class extends Error{constructor(i,r){super(i!=null?i:"Authentication failed.");this.statusCode=r;this.name="AuthenticationError"}},ye=class extends Error{constructor(n){super(n!=null?n:"Session error."),this.name="SessionError"}};function Ae(e){let n=new URL(e);return`${n.protocol==="https:"?"https://":"http://"}${n.hostname}:${n.port}`}var Ie=class e{constructor(n,i,r){this.refreshTokenPromise=null;this._session=n,this._client=i,this._userId=r}get userId(){return this._userId}get session(){return this._session}get client(){return this._client}static initClient(n){let{token:i,refresh_token:r,api_url:a,user_id:t,serverkey:o}=n;if(!i||!r||!a||!t)throw new ye("Missing required fields: token, refresh_token, api_url, and user_id are all required");let l=ae.restore(i,r,a,!0),c=new oe(o||H,7e3,Ae(a));return new e(l,c,t)}static authenticate(n){return g(this,null,function*(){let{id_token:i,user_id:r,username:a,serverkey:t=H,gateway_url:o=ke}=n,l=new oe(t||H,7e3,Ae(o)),c={id_token:i,user_id:r,username:a},d=yield l.authenticateIdToken(t,"",c);if(!d)throw new de("Authentication failed: No response from server.");if(!d.token||!d.refresh_token||!d.api_url||!d.user_id)throw new de("Invalid authentication response: missing required fields");let u=ae.restore(d.token,d.refresh_token,d.api_url,!0);return l.setBasePath(Ae(d.api_url)),new e(u,l,d.user_id)})}createDM(n){return g(this,null,function*(){let i={type:3,channel_private:1,user_ids:[n]};return this._client.createChannelDesc(this._session.token,i)})}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 i={type:2,channel_private:1,user_ids:n};return this._client.createChannelDesc(this._session.token,i)})}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,i)=>g(this,null,function*(){try{let r=yield this.client.sessionRefresh(this._client.serverKey||H,"",{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),i(r)}finally{this.refreshTokenPromise=null}})),this.refreshTokenPromise)):(console.error("Cannot refresh a null session."),this._session)})}createSocket(n=!1,i=new R,r=ce.DefaultSendTimeoutMs){let a=new URL(this._client.basePath),{host:t,port:o,useSSL:l}={host:a.hostname,port:a.port||(a.protocol==="https:"?"443":"80"),useSSL:a.protocol==="https:"};return new ce(t,o,l,n,i,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 L=class extends Error{constructor(n){super(n),this.name="SocketError"}};function yn(r){return g(this,arguments,function*(e,n=20,i=100){var l;let a=0,t=i,o=e;for(;a<n;){if((l=o.adapter)!=null&&l.isOpen())return;yield new Promise(c=>setTimeout(c,t)),t*=2,a++}throw new L(`Socket failed to connect after ${n} attempts (total wait: ~${Math.pow(2,n)*i}ms)`)})}var Re=class{constructor(n,i){this._client=n;this._session=i;this._socket=null;this._isConnected=!1;this._messageHandlers=[]}get isConnected(){return this._isConnected}get socket(){if(!this._socket)throw new L("Socket is not connected. Call connect() first.");return this._socket}connect(){return g(this,arguments,function*(n={}){if(this._isConnected)throw new L("Socket is already connected. Call disconnect() first.");let{onError:i,onDisconnect:r,verbose:a=!1}=n;this._errorHandler=i,this._disconnectHandler=r,this._socket=this._client.createSocket(a,new R),this._socket.onerror=t=>{var o;(o=this._errorHandler)==null||o.call(this,t)},this._socket.ondisconnect=()=>{var t;this._isConnected=!1,(t=this._disconnectHandler)==null||t.call(this)},this._socket.onchannelmessage=t=>{var o;if(!t){(o=this._errorHandler)==null||o.call(this,new L("Received null or undefined channel message"));return}this._messageHandlers.forEach(l=>{try{l(t)}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 i=this._messageHandlers.indexOf(n);i!==-1&&this._messageHandlers.splice(i,1)}}joinDMChannel(n){return g(this,null,function*(){yield yn(this.socket),yield this.socket.joinChat(I,n,3,!1)})}joinGroupChannel(n){return g(this,null,function*(){yield yn(this.socket),yield this.socket.joinChat(I,n,2,!1)})}leaveDMChannel(n){return g(this,null,function*(){yield this.socket.leaveChat(I,n,3,!1)})}leaveGroupChannel(n){return g(this,null,function*(){yield this.socket.leaveChat(I,n,2,!1)})}sendDM(n){return g(this,null,function*(){let{channelId:i,content:r,attachments:a,hideLink:t=!1}=n;yield this.socket.writeChatMessage(I,i,4,!1,r,a,!1,t,"",0)})}sendGroup(n){return g(this,null,function*(){let{channelId:i,content:r,attachments:a,hideLink:t=!1}=n;yield this.socket.writeChatMessage(I,i,3,!1,r,a,!1,t,"",0)})}setErrorHandler(n){this._errorHandler=n,this._socket&&(this._socket.onerror=n)}};export{de as AuthenticationError,J as CHANNEL_TYPE_DM,W as CHANNEL_TYPE_GROUP,I as CLAN_DM,H as DEFAULT_SERVER_KEY,Ie as LightClient,Re as LightSocket,ke as MEZON_GW_URL,Se as SOCKET_READY_MAX_RETRY,ve as SOCKET_READY_RETRY_DELAY,Te as STREAM_MODE_DM,Ce as STREAM_MODE_GROUP,ye as SessionError,L as SocketError};
|
|
1
|
+
var Cn=Object.defineProperty;var Be=Object.getOwnPropertySymbols;var bn=Object.prototype.hasOwnProperty,Pn=Object.prototype.propertyIsEnumerable;var He=(e,n,t)=>n in e?Cn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ke=(e,n)=>{for(var t in n||(n={}))bn.call(n,t)&&He(e,t,n[t]);if(Be)for(var t of Be(n))Pn.call(n,t)&&He(e,t,n[t]);return 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 Se="https://gw.mezon.ai",ve=20,Te=100,N="0",J=3,W=2,Ce=4,be=3,B="DefaultServerKey";import*as Pe from"js-base64";var ae=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(Pe.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(Pe.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)}};import qe from"long";import f from"protobufjs/minimal";function we(){return{created:!1,token:"",refresh_token:"",user_id:"0",is_remember:!1,api_url:"",id_token:""}}var Ae={encode(e,n=f.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.Reader?e:f.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=we();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 Ae.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c;let n=we();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 Ve(){return{token:"",vars:{},is_remember:!1}}var ue={encode(e,n=f.Writer.create()){return e.token!==""&&n.uint32(10).string(e.token),Object.entries(e.vars).forEach(([t,r])=>{Ee.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.Reader?e:f.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Ve();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=Ee.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:En(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 ue.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a;let n=Ve();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 ze(){return{key:"",value:""}}var Ee={encode(e,n=f.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.Reader?e:f.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.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 Ee.fromPartial(e!=null?e:{})},fromPartial(e){var t,r;let n=ze();return n.key=(t=e.key)!=null?t:"",n.value=(r=e.value)!=null?r:"",n}};function Fe(){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 fe={encode(e,n=f.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.Reader?e:f.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Fe();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 fe.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_;let n=Fe();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 Ke(){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 xe={encode(e,n=f.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.Reader?e:f.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Ke();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 xe.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p,y,x,M,I,C,G,X,Z,$,Q,j,ee,ne,te,ie,Ue,Le,Je,We;let n=Ke();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(P=>P))||[],n.user_ids=((y=e.user_ids)==null?void 0:y.map(P=>P))||[],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=((x=e.onlines)==null?void 0:x.map(P=>P))||[],n.meeting_code=(M=e.meeting_code)!=null?M:"",n.count_mess_unread=(I=e.count_mess_unread)!=null?I:0,n.active=(C=e.active)!=null?C:0,n.last_pin_message=(G=e.last_pin_message)!=null?G:"",n.usernames=((X=e.usernames)==null?void 0:X.map(P=>P))||[],n.creator_name=(Z=e.creator_name)!=null?Z:"",n.create_time_seconds=($=e.create_time_seconds)!=null?$:0,n.update_time_seconds=(Q=e.update_time_seconds)!=null?Q:0,n.display_names=((j=e.display_names)==null?void 0:j.map(P=>P))||[],n.channel_avatar=(ee=e.channel_avatar)!=null?ee:"",n.clan_name=(ne=e.clan_name)!=null?ne:"",n.app_id=(te=e.app_id)!=null?te:"0",n.is_mute=(ie=e.is_mute)!=null?ie:!1,n.age_restricted=(Ue=e.age_restricted)!=null?Ue:0,n.topic=(Le=e.topic)!=null?Le:"",n.e2ee=(Je=e.e2ee)!=null?Je:0,n.member_count=(We=e.member_count)!=null?We:0,n}};function m(e){return e.toString()}f.util.Long!==qe&&(f.util.Long=qe,f.configure());function En(e){return typeof e=="object"&&e!==null}function s(e){return e!=null}function Ye(){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 O={encode(e,n=f.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.Reader?e:f.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Ye();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)?re(e.reactions):new Uint8Array(0),mentions:s(e.mentions)?re(e.mentions):new Uint8Array(0),attachments:s(e.attachments)?re(e.attachments):new Uint8Array(0),references:s(e.references)?re(e.references):new Uint8Array(0),referenced_message:s(e.referenced_message)?re(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=se(e.reactions)),e.mentions.length!==0&&(n.mentions=se(e.mentions)),e.attachments.length!==0&&(n.attachments=se(e.attachments)),e.references.length!==0&&(n.references=se(e.references)),e.referenced_message.length!==0&&(n.referenced_message=se(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 O.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p,y,x,M,I,C,G,X,Z,$,Q,j,ee,ne,te,ie;let n=Ye();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=(x=e.display_name)!=null?x:"",n.clan_nick=(M=e.clan_nick)!=null?M:"",n.clan_avatar=(I=e.clan_avatar)!=null?I:"",n.reactions=(C=e.reactions)!=null?C:new Uint8Array(0),n.mentions=(G=e.mentions)!=null?G:new Uint8Array(0),n.attachments=(X=e.attachments)!=null?X:new Uint8Array(0),n.references=(Z=e.references)!=null?Z:new Uint8Array(0),n.referenced_message=($=e.referenced_message)!=null?$:new Uint8Array(0),n.create_time_seconds=(Q=e.create_time_seconds)!=null?Q:0,n.update_time_seconds=(j=e.update_time_seconds)!=null?j:0,n.mode=(ee=e.mode)!=null?ee:0,n.hide_editted=(ne=e.hide_editted)!=null?ne:!1,n.is_public=(te=e.is_public)!=null?te:!1,n.topic_id=(ie=e.topic_id)!=null?ie:"0",n}};function Ge(){return{id:"0",timestamp_seconds:0,sender_id:"0",content:""}}var S={encode(e,n=f.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.Reader?e:f.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=Ge();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=Ge();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 Xe(){return{id:"0",user_id:"0",username:"",role_id:"0",rolename:"",create_time_seconds:0,s:0,e:0}}var D={encode(e,n=f.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.Reader?e:f.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.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 D.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d;let n=Xe();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 Ze(){return{filename:"",size:0,url:"",filetype:"",width:0,height:0,thumbnail:"",duration:0}}var v={encode(e,n=f.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.Reader?e:f.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.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=Ze();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 $e(){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 U={encode(e,n=f.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.Reader?e:f.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!==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 U.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p;let n=$e();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 Qe(){return{attachments:[]}}var Me={encode(e,n=f.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.Reader?e:f.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!==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 Me.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=Qe();return n.attachments=((t=e.attachments)==null?void 0:t.map(r=>v.fromPartial(r)))||[],n}};function re(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 se(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 je(){return{filename:"",filetype:"",size:0,width:0,height:0}}var he={encode(e,n=f.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.Reader?e:f.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!==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 he.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o;let n=je();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 en(){return{filename:"",url:""}}var Ie={encode(e,n=f.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.Reader?e:f.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!==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 Ie.fromPartial(e!=null?e:{})},fromPartial(e){var t,r;let n=en();return n.filename=(t=e.filename)!=null?t:"",n.url=(r=e.url)!=null?r:"",n}};function oe(e,n,t){let r=ke({method:e},n);if(r.headers=ke({},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 pe(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 An=e=>!e||e===null||e===void 0||e===""||e==="[]";function tn(e){if(An(e))return;let n=e[0];if(n===91||n===123)return pe(e);try{let r=e,a=new Uint8Array(r);return Me.decode(a)}catch(r){return pe(e)}}import{encode as an}from"js-base64";var le=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=oe("POST",a,l);return n&&(d.headers.Authorization="Basic "+an(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=ue.encode(ue.fromPartial(r)).finish(),d=this.buildFullUrl(this.basePath,i,o),_=oe("POST",a,"");return _.body=c,n&&(_.headers.Authorization="Basic "+an(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 Ae.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=fe.encode(fe.fromPartial(t)).finish(),c=this.buildFullUrl(this.basePath,a,i),d=oe("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 xe.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=he.encode(he.fromPartial(t)).finish(),c=this.buildFullUrl(this.basePath,a,i),d=oe("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 Ie.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}};import cn from"long";import h from"protobufjs/minimal";import rn from"long";import E from"protobufjs/minimal";function sn(){return{value:!1}}var me={encode(e,n=E.Writer.create()){return e.value!==!1&&n.uint32(8).bool(e.value),n},decode(e,n){let t=e instanceof E.Reader?e:E.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.value=t.bool();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{value:ln(e.value)?globalThis.Boolean(e.value):!1}},toJSON(e){let n={};return e.value!==!1&&(n.value=e.value),n},create(e){return me.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=sn();return n.value=(t=e.value)!=null?t:!1,n}};function on(){return{value:""}}var ge={encode(e,n=E.Writer.create()){return e.value!==""&&n.uint32(10).string(e.value),n},decode(e,n){let t=e instanceof E.Reader?e:E.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.value=t.string();continue}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{value:ln(e.value)?globalThis.String(e.value):""}},toJSON(e){let n={};return e.value!==""&&(n.value=e.value),n},create(e){return ge.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=on();return n.value=(t=e.value)!=null?t:"",n}};E.util.Long!==rn&&(E.util.Long=rn,E.configure());function ln(e){return e!=null}function dn(){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 ce={encode(e,n=h.Writer.create()){return e.cid!==""&&n.uint32(10).string(e.cid),e.channel!==void 0&&H.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&&w.encode(e.channel_leave,n.uint32(42).fork()).ldelim(),e.channel_message!==void 0&&O.encode(e.channel_message,n.uint32(50).fork()).ldelim(),e.channel_message_ack!==void 0&&V.encode(e.channel_message_ack,n.uint32(58).fork()).ldelim(),e.channel_message_send!==void 0&&z.encode(e.channel_message_send,n.uint32(66).fork()).ldelim(),e.error!==void 0&&F.encode(e.error,n.uint32(98).fork()).ldelim(),e.ping!==void 0&&K.encode(e.ping,n.uint32(178).fork()).ldelim(),e.pong!==void 0&&Y.encode(e.pong,n.uint32(186).fork()).ldelim(),n},decode(e,n){let t=e instanceof h.Reader?e:h.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=dn();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=H.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=w.decode(t,t.uint32());continue;case 6:if(i!==50)break;a.channel_message=O.decode(t,t.uint32());continue;case 7:if(i!==58)break;a.channel_message_ack=V.decode(t,t.uint32());continue;case 8:if(i!==66)break;a.channel_message_send=z.decode(t,t.uint32());continue;case 12:if(i!==98)break;a.error=F.decode(t,t.uint32());continue;case 22:if(i!==178)break;a.ping=K.decode(t,t.uint32());continue;case 23:if(i!==186)break;a.pong=Y.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)?H.fromJSON(e.channel):void 0,channel_join:u(e.channel_join)?q.fromJSON(e.channel_join):void 0,channel_leave:u(e.channel_leave)?w.fromJSON(e.channel_leave):void 0,channel_message:u(e.channel_message)?O.fromJSON(e.channel_message):void 0,channel_message_ack:u(e.channel_message_ack)?V.fromJSON(e.channel_message_ack):void 0,channel_message_send:u(e.channel_message_send)?z.fromJSON(e.channel_message_send):void 0,error:u(e.error)?F.fromJSON(e.error):void 0,ping:u(e.ping)?K.fromJSON(e.ping):void 0,pong:u(e.pong)?Y.fromJSON(e.pong):void 0}},toJSON(e){let n={};return e.cid!==""&&(n.cid=e.cid),e.channel!==void 0&&(n.channel=H.toJSON(e.channel)),e.channel_join!==void 0&&(n.channel_join=q.toJSON(e.channel_join)),e.channel_leave!==void 0&&(n.channel_leave=w.toJSON(e.channel_leave)),e.channel_message!==void 0&&(n.channel_message=O.toJSON(e.channel_message)),e.channel_message_ack!==void 0&&(n.channel_message_ack=V.toJSON(e.channel_message_ack)),e.channel_message_send!==void 0&&(n.channel_message_send=z.toJSON(e.channel_message_send)),e.error!==void 0&&(n.error=F.toJSON(e.error)),e.ping!==void 0&&(n.ping=K.toJSON(e.ping)),e.pong!==void 0&&(n.pong=Y.toJSON(e.pong)),n},create(e){return ce.fromPartial(e!=null?e:{})},fromPartial(e){var t;let n=dn();return n.cid=(t=e.cid)!=null?t:"",n.channel=e.channel!==void 0&&e.channel!==null?H.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?w.fromPartial(e.channel_leave):void 0,n.channel_message=e.channel_message!==void 0&&e.channel_message!==null?O.fromPartial(e.channel_message):void 0,n.channel_message_ack=e.channel_message_ack!==void 0&&e.channel_message_ack!==null?V.fromPartial(e.channel_message_ack):void 0,n.channel_message_send=e.channel_message_send!==void 0&&e.channel_message_send!==null?z.fromPartial(e.channel_message_send):void 0,n.error=e.error!==void 0&&e.error!==null?F.fromPartial(e.error):void 0,n.ping=e.ping!==void 0&&e.ping!==null?K.fromPartial(e.ping):void 0,n.pong=e.pong!==void 0&&e.pong!==null?Y.fromPartial(e.pong):void 0,n}};function _n(){return{id:"0",presences:[],self:void 0,chanel_label:"",clan_logo:"",category_name:""}}var H={encode(e,n=h.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.Reader?e:h.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.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 H.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o;let n=_n();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 un(){return{clan_id:"0",channel_id:"0",channel_type:0,is_public:!1}}var q={encode(e,n=h.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.Reader?e:h.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!==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=un();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 fn(){return{clan_id:"0",channel_id:"0",channel_type:0,is_public:!1}}var w={encode(e,n=h.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.Reader?e:h.Reader.create(e),r=n===void 0?t.len:t.pos+n,a=fn();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=fn();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 hn(){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 V={encode(e,n=h.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&&me.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.Reader?e:h.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!==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=me.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 V.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_;let n=hn();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 pn(){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 z={encode(e,n=h.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)D.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)U.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.Reader?e:h.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.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(D.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(U.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=>D.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=>U.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=>D.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=>U.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 z.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a,i,o,l,c,d,_,p,y,x,M,I;let n=pn();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=>D.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=>U.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=(x=e.code)!=null?x:0,n.topic_id=(M=e.topic_id)!=null?M:"0",n.id=(I=e.id)!=null?I:"0",n}};function mn(){return{code:0,message:"",context:{}}}var F={encode(e,n=h.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])=>{Ne.encode({key:t,value:r},n.uint32(26).fork()).ldelim()}),n},decode(e,n){let t=e instanceof h.Reader?e:h.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.code=t.int32();continue;case 2:if(i!==18)break;a.message=t.string();continue;case 3:if(i!==26)break;let o=Ne.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:xn(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 F.fromPartial(e!=null?e:{})},fromPartial(e){var t,r,a;let n=mn();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 gn(){return{key:"",value:""}}var Ne={encode(e,n=h.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.Reader?e:h.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!==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 Ne.fromPartial(e!=null?e:{})},fromPartial(e){var t,r;let n=gn();return n.key=(t=e.key)!=null?t:"",n.value=(r=e.value)!=null?r:"",n}};function yn(){return{}}var K={encode(e,n=h.Writer.create()){return n},decode(e,n){let t=e instanceof h.Reader?e:h.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){}if((i&7)===4||i===0)break;t.skipType(i&7)}return a},fromJSON(e){return{}},toJSON(e){return{}},create(e){return K.fromPartial(e!=null?e:{})},fromPartial(e){return yn()}};function kn(){return{}}var Y={encode(e,n=h.Writer.create()){return n},decode(e,n){let t=e instanceof h.Reader?e:h.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){}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 kn()}};function Sn(){return{user_id:"0",session_id:"",username:"",status:void 0,is_mobile:!1,user_status:""}}var b={encode(e,n=h.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&&ge.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.Reader?e:h.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.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=ge.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=Sn();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.util.Long!==cn&&(h.util.Long=cn,h.configure());function xn(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=ce.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=ce.encode(ce.fromPartial(n)).finish();this._socket.send(r)}};var vn=!1,k={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected"},A=class A{constructor(n,t,r=!1,a=!1,i=new R,o=A.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=A.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=A.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=In(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=vn;vn=!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=A.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)}};A.DefaultHeartbeatTimeoutMs=1e4,A.DefaultSendTimeoutMs=1e4,A.DefaultConnectTimeoutMs=3e4;var de=A;function In(e){var n,t;try{n=pe(e.channel_message.content)}catch(a){console.log("content is invalid",a)}try{t=tn(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 _e=class extends Error{constructor(t,r){super(t!=null?t:"Authentication failed.");this.statusCode=r;this.name="AuthenticationError"}},ye=class extends Error{constructor(n){super(n!=null?n:"Session error."),this.name="SessionError"}};function Re(e){let n=new URL(e);return`${n.protocol==="https:"?"https://":"http://"}${n.hostname}:${n.port}`}var Oe=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 ye("Missing required fields: token, refresh_token, api_url, and user_id are all required");let l=ae.restore(t,r,a,!0),c=new le(o||B,7e3,Re(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=B,gateway_url:o=Se}=n,l=new le(i||B,7e3,Re(o)),c={id_token:t,user_id:r,username:a},d=yield l.authenticateIdToken(i,"",c);if(!d)throw new _e("Authentication failed: No response from server.");if(!d.token||!d.refresh_token||!d.api_url||!d.user_id)throw new _e("Invalid authentication response: missing required fields");let _=ae.restore(d.token,d.refresh_token,d.api_url,!0);return l.setBasePath(Re(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||B,"",{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=de.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 de(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 L=class extends Error{constructor(n){super(n),this.name="SocketError"}};function Tn(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 L(`Socket failed to connect after ${n} attempts (total wait: ~${Math.pow(2,n)*t}ms)`)})}var De=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 L("Socket is not connected. Call connect() first.");return this._socket}connect(){return g(this,arguments,function*(n={}){if(this._isConnected)throw new L("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 L("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 Tn(this.socket),yield this.socket.joinChat(N,n,3,!1)})}joinGroupChannel(n){return g(this,null,function*(){yield Tn(this.socket),yield this.socket.joinChat(N,n,2,!1)})}leaveDMChannel(n){return g(this,null,function*(){yield this.socket.leaveChat(N,n,3,!1)})}leaveGroupChannel(n){return g(this,null,function*(){yield this.socket.leaveChat(N,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(N,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(N,t,3,!1,r,a,!1,i,"",0)})}setErrorHandler(n){this._errorHandler=n,this._socket&&(this._socket.onerror=n)}};export{_e as AuthenticationError,J as CHANNEL_TYPE_DM,W as CHANNEL_TYPE_GROUP,N as CLAN_DM,B as DEFAULT_SERVER_KEY,Oe as LightClient,De as LightSocket,Se as MEZON_GW_URL,ve as SOCKET_READY_MAX_RETRY,Te as SOCKET_READY_RETRY_DELAY,Ce as STREAM_MODE_DM,be as STREAM_MODE_GROUP,ye as SessionError,L as SocketError};
|
|
@@ -134,6 +134,19 @@ export interface AuthenticationIdTokenResponse {
|
|
|
134
134
|
/** User ID of the authenticated user */
|
|
135
135
|
user_id: string;
|
|
136
136
|
}
|
|
137
|
+
/** */
|
|
138
|
+
export interface ApiUploadAttachment {
|
|
139
|
+
filename?: string;
|
|
140
|
+
url?: string;
|
|
141
|
+
}
|
|
142
|
+
/** */
|
|
143
|
+
export interface ApiUploadAttachmentRequest {
|
|
144
|
+
filename?: string;
|
|
145
|
+
filetype?: string;
|
|
146
|
+
height?: number;
|
|
147
|
+
size?: number;
|
|
148
|
+
width?: number;
|
|
149
|
+
}
|
|
137
150
|
export declare class MezonApi {
|
|
138
151
|
readonly serverKey: string;
|
|
139
152
|
readonly timeoutMs: number;
|
|
@@ -146,5 +159,8 @@ export declare class MezonApi {
|
|
|
146
159
|
sessionRefresh(basicAuthUsername: string, basicAuthPassword: string, body: ApiSessionRefreshRequest, options?: any): Promise<ApiSession>;
|
|
147
160
|
/** Create a new channel with the current user as the owner. */
|
|
148
161
|
createChannelDesc(bearerToken: string, body: ApiCreateChannelDescRequest, options?: any): Promise<ApiChannelDescription>;
|
|
162
|
+
/** Upload attachment */
|
|
163
|
+
uploadAttachmentFile(bearerToken: string, body: ApiUploadAttachmentRequest, options?: any): Promise<ApiUploadAttachment>;
|
|
149
164
|
buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>): string;
|
|
150
165
|
}
|
|
166
|
+
//# sourceMappingURL=api.gen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.gen.d.ts","sourceRoot":"","sources":["../../src/api.gen.ts"],"names":[],"mappings":"AAOA,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAE7B,EAAE,EAAE,MAAM,CAAC;IAEX,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAE,MAAM,CAAC;IAEnB,aAAa,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,MAAM,CAAC;IAEb,OAAO,EAAE,MAAM,CAAC;IAEhB,WAAW,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAE1C,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE9B,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,SAAS,EAAE,MAAM,CAAC;IAElB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,OAAO;AACP,MAAM,WAAW,oBAAoB;IAEnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,4DAA4D;AAC5D,MAAM,WAAW,wBAAwB;IAEvC,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,sDAAsD;AACtD,MAAM,WAAW,UAAU;IAEzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,OAAO;AACP,MAAM,WAAW,qBAAqB;IAEpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;IAE5C,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;IAE5C,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzB,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE1B,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAEzB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAExB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,OAAO;AACP,MAAM,WAAW,uBAAuB;IAEtC,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,OAAO,CAAC,EAAE,UAAU,CAAC;IAErB,QAAQ,CAAC,EAAE,UAAU,CAAC;IAEtB,SAAS,CAAC,EAAE,UAAU,CAAC;IAEvB,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,oCAAoC;AACpC,MAAM,WAAW,2BAA2B;IAE1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,6BAA6B;IAC5C,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,OAAO;AACP,MAAM,WAAW,mBAAmB;IAElC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,OAAO;AACP,MAAM,WAAW,0BAA0B;IAEzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,QAAQ;IAEP,QAAQ,CAAC,SAAS,EAAE,MAAM;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM;IADlE,QAAQ,EAAE,MAAM,CAAC;gBACI,SAAS,EAAE,MAAM,EAAW,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAIpF,WAAW,CAAC,QAAQ,EAAE,MAAM;IAI5B,+DAA+D;IAC/D,mBAAmB,CACjB,iBAAiB,EAAE,MAAM,EACzB,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,wBAAwB,EAC9B,OAAO,GAAE,GAAQ,GAChB,OAAO,CAAC,6BAA6B,CAAC;IA8BzC,uGAAuG;IACvG,cAAc,CACZ,iBAAiB,EAAE,MAAM,EACzB,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,wBAAwB,EAC9B,OAAO,GAAE,GAAQ,GAChB,OAAO,CAAC,UAAU,CAAC;IAgCtB,+DAA+D;IAC/D,iBAAiB,CACf,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,GAAQ,GAChB,OAAO,CAAC,qBAAqB,CAAC;IAgCjC,wBAAwB;IACxB,oBAAoB,CAClB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,0BAA0B,EAChC,OAAO,GAAE,GAAQ,GAChB,OAAO,CAAC,mBAAmB,CAAC;IAsC/B,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;CAiB/E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Session } from "./session";
|
|
2
|
-
import { ApiSession, MezonApi, ApiChannelDescription } from "./api.gen";
|
|
2
|
+
import { ApiSession, MezonApi, ApiChannelDescription, ApiUploadAttachment, ApiUploadAttachmentRequest } from "./api.gen";
|
|
3
3
|
import { ClientInitConfig, AuthenticateConfig } from "./types";
|
|
4
4
|
import { WebSocketAdapter } from "./web_socket_adapter_pb";
|
|
5
5
|
import { Socket } from "./socket.gen";
|
|
@@ -87,6 +87,26 @@ export declare class LightClient {
|
|
|
87
87
|
* @returns A promise that resolves to the created channel descriptor
|
|
88
88
|
*/
|
|
89
89
|
createGroupDM(userIds: string[]): Promise<ApiChannelDescription>;
|
|
90
|
+
/**
|
|
91
|
+
* Uploads an attachment file to Mezon server.
|
|
92
|
+
* Returns the URL of the uploaded file which can be used in messages.
|
|
93
|
+
*
|
|
94
|
+
* @param request - Upload request containing file metadata (filename, filetype, size, width, height)
|
|
95
|
+
* @returns A promise that resolves to the upload result with file URL
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const result = await client.uploadAttachment({
|
|
100
|
+
* filename: 'image.png',
|
|
101
|
+
* filetype: 'image/png',
|
|
102
|
+
* size: 1024,
|
|
103
|
+
* width: 800,
|
|
104
|
+
* height: 600
|
|
105
|
+
* });
|
|
106
|
+
* console.log('Uploaded file URL:', result.url);
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
uploadAttachment(request: ApiUploadAttachmentRequest): Promise<ApiUploadAttachment>;
|
|
90
110
|
/**
|
|
91
111
|
* Refreshes the current session using the refresh token.
|
|
92
112
|
* Call this before the session expires to maintain connectivity.
|
|
@@ -134,3 +154,4 @@ export declare class LightClient {
|
|
|
134
154
|
*/
|
|
135
155
|
exportSession(): ClientInitConfig;
|
|
136
156
|
}
|
|
157
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAA4B,UAAU,EAAE,QAAQ,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAEnJ,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAsB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAiB,MAAM,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aACE,UAAU,CAAC,EAAE,MAAM;gBAArD,OAAO,CAAC,EAAE,MAAM,EAAkB,UAAU,CAAC,EAAE,MAAM,YAAA;CAIlE;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,CAAC,EAAE,MAAM;CAI7B;AAWD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAW;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,uEAAuE;IACvE,OAAO,CAAC,mBAAmB,CAAiC;IAE5D,OAAO;IAMP;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,QAAQ,CAErB;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,WAAW;IAaxD;;;;;;OAMG;WACU,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAwB3E;;;;;OAKG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAS9D;;;;;OAKG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAatE;;;;;;;;;;;;;;;;;;OAkBG;IACG,gBAAgB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAIzF;;;;;OAKG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IA2CxC,wDAAwD;IACxD,YAAY,CACV,OAAO,GAAE,OAAe,EACxB,OAAO,GAAE,gBAA2C,EACpD,aAAa,GAAE,MAA2C,GACzD,MAAM;IAUT;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;IAI3C;;;;OAIG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;;;;OAKG;IACH,uBAAuB,IAAI,OAAO;IAIlC;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;;;OAIG;IACH,aAAa,IAAI,gBAAgB;CAQlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,eAAO,MAAM,YAAY,wBAAwB,CAAC;AAElD,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,4FAA4F;AAC5F,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,uCAAuC;AACvC,eAAO,MAAM,OAAO,MAAM,CAAC;AAE3B,uCAAuC;AACvC,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,sCAAsC;AACtC,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,6CAA6C;AAC7C,eAAO,MAAM,kBAAkB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../../../src/google/protobuf/wrappers.ts"],"names":[],"mappings":"AAQA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAErC,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,sBAAsB;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAYD,eAAO,MAAM,UAAU;oBACL,UAAU,WAAU,GAAG,CAAC,MAAM,GAAyB,GAAG,CAAC,MAAM;kBAOnE,GAAG,CAAC,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,UAAU;qBAuBlD,GAAG,GAAG,UAAU;oBAIjB,UAAU,GAAG,OAAO;WAQ7B,CAAC,SAAS,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,UAAU;gBAG7D,CAAC,SAAS,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,UAAU;CAKhF,CAAC;AAMF,eAAO,MAAM,SAAS;oBACJ,SAAS,WAAU,GAAG,CAAC,MAAM,GAAyB,GAAG,CAAC,MAAM;kBAOlE,GAAG,CAAC,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,SAAS;qBAuBjD,GAAG,GAAG,SAAS;oBAIhB,SAAS,GAAG,OAAO;WAQ5B,CAAC,SAAS,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,SAAS;gBAG3D,CAAC,SAAS,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,SAAS;CAK9E,CAAC;AAMF,eAAO,MAAM,WAAW;oBACN,WAAW,WAAU,GAAG,CAAC,MAAM,GAAyB,GAAG,CAAC,MAAM;kBAOpE,GAAG,CAAC,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,WAAW;qBAuBnD,GAAG,GAAG,WAAW;oBAIlB,WAAW,GAAG,OAAO;WAQ9B,CAAC,SAAS,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,WAAW;gBAG/D,CAAC,SAAS,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,WAAW;CAKlF,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GAC9C,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,CAAC;AAEf,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AACpD,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GACrD,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,CAAC"}
|
|
@@ -3,3 +3,4 @@ export type { ClientInitConfig, AuthenticateConfig, SendMessagePayload, } from "
|
|
|
3
3
|
export { LightClient, AuthenticationError, SessionError, } from './client';
|
|
4
4
|
export { LightSocket, SocketError, } from './socket';
|
|
5
5
|
export type { SocketConnectOptions, ChannelMessageHandler, } from './socket';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,wBAAwB,EACxB,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,YAAY,GACb,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,WAAW,EACX,WAAW,GACZ,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,UAAU,CAAC"}
|
|
@@ -378,4 +378,41 @@ export declare const MessageAttachmentList: {
|
|
|
378
378
|
create<I extends Exact<DeepPartial<MessageAttachmentList>, I>>(base?: I): MessageAttachmentList;
|
|
379
379
|
fromPartial<I extends Exact<DeepPartial<MessageAttachmentList>, I>>(object: I): MessageAttachmentList;
|
|
380
380
|
};
|
|
381
|
+
/** */
|
|
382
|
+
export interface UploadAttachmentRequest {
|
|
383
|
+
/** The name of file that need to upload */
|
|
384
|
+
filename: string;
|
|
385
|
+
/** The type of file that need to upload */
|
|
386
|
+
filetype: string;
|
|
387
|
+
/** The size of file that need to upload */
|
|
388
|
+
size: number;
|
|
389
|
+
/** width */
|
|
390
|
+
width: number;
|
|
391
|
+
/** Height */
|
|
392
|
+
height: number;
|
|
393
|
+
}
|
|
394
|
+
/** */
|
|
395
|
+
export interface UploadAttachment {
|
|
396
|
+
/** The name of file that need to upload */
|
|
397
|
+
filename: string;
|
|
398
|
+
/** The url */
|
|
399
|
+
url: string;
|
|
400
|
+
}
|
|
401
|
+
export declare const UploadAttachmentRequest: {
|
|
402
|
+
encode(message: UploadAttachmentRequest, writer?: _m0.Writer): _m0.Writer;
|
|
403
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): UploadAttachmentRequest;
|
|
404
|
+
fromJSON(object: any): UploadAttachmentRequest;
|
|
405
|
+
toJSON(message: UploadAttachmentRequest): unknown;
|
|
406
|
+
create<I extends Exact<DeepPartial<UploadAttachmentRequest>, I>>(base?: I): UploadAttachmentRequest;
|
|
407
|
+
fromPartial<I extends Exact<DeepPartial<UploadAttachmentRequest>, I>>(object: I): UploadAttachmentRequest;
|
|
408
|
+
};
|
|
409
|
+
export declare const UploadAttachment: {
|
|
410
|
+
encode(message: UploadAttachment, writer?: _m0.Writer): _m0.Writer;
|
|
411
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): UploadAttachment;
|
|
412
|
+
fromJSON(object: any): UploadAttachment;
|
|
413
|
+
toJSON(message: UploadAttachment): unknown;
|
|
414
|
+
create<I extends Exact<DeepPartial<UploadAttachment>, I>>(base?: I): UploadAttachment;
|
|
415
|
+
fromPartial<I extends Exact<DeepPartial<UploadAttachment>, I>>(object: I): UploadAttachment;
|
|
416
|
+
};
|
|
381
417
|
export {};
|
|
418
|
+
//# sourceMappingURL=api.d.ts.map
|