/*! For license information please see 0abca03f983496b34bf4.worker.js.LICENSE.txt */ !function(e){var t={};function n(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(s,i,function(t){return e[t]}.bind(null,i));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=113)}([function(e,t,n){const s=n(6),i=n(83),a=n(60),r=n(24),o=n(101),c=n(102),u=n(21),d=n(16),l=n(106),f=n(43),p=n(8);e.exports={Api:s,TelegramClient:i,sessions:l,connection:a,extensions:f,tl:r,version:o,events:c,utils:u,errors:d,helpers:p}},function(e,t,n){"use strict";n.d(t,"f",(function(){return k})),n.d(t,"a",(function(){return E})),n.d(t,"b",(function(){return O})),n.d(t,"e",(function(){return R})),n.d(t,"g",(function(){return D})),n.d(t,"c",(function(){return B})),n.d(t,"i",(function(){return x})),n.d(t,"h",(function(){return j})),n.d(t,"d",(function(){return N}));var s={};n.r(s),n.d(s,"Type",(function(){return m})),n.d(s,"fetch",(function(){return b})),n.d(s,"save",(function(){return y})),n.d(s,"clear",(function(){return _}));var i=n(0),a=n(43),r=n(4),o=n(18),c=n(28),u=n(9),d=n(42),l=n(13),f=n(5),p=n(2),g=n(35);const h=self.caches;let m;async function b(e,t,n){if(h)try{const s=new Request(t.replace(/:/g,"_")),i=await h.open(e),a=await i.match(s);if(!a)return;switch(n){case m.Text:return await a.text();case m.Blob:{const e=await a.blob();if("sticker"===t.substr(0,7))return new Blob([e],{type:"image/webp"});if(!e.type){const t=a.headers.get("Content-Type");if(t)return new Blob([e],{type:t})}return e}case m.Json:return await a.json();default:return}}catch(e){return void console.warn(e)}}async function y(e,t,n){if(h)try{const s="string"==typeof n||n instanceof Blob?n:JSON.stringify(n),i=new Request(t.replace(/:/g,"_")),a=new Response(s),r=await h.open(e);return await r.put(i,a)}catch(e){return void console.warn(e)}}async function _(e){try{if(!h)return;return await h.delete(e)}catch(e){return void console.warn(e)}}!function(e){e[e.Text=0]="Text",e[e.Blob=1]="Blob",e[e.Json=2]="Json"}(m||(m={}));const w=new Set(["msg","sticker","gif","wallpaper","photo","webDocument"]);async function v({url:e,mediaFormat:t,start:n,end:a},o,c,u){const{data:h,mimeType:m,fullSize:b}=await async function(e,t,n,s,a,o,c){const u=e.startsWith("webDocument")?e.match(/(webDocument):(.+)/):e.match(/(avatar|profile|photo|msg|stickerSet|sticker|wallpaper|gif|file)([-\d\w./]+)(\?size=\w+)?/);if(!u)return;if("file"===u[1]){const e=await fetch(u[2]);return{data:await e.arrayBuffer()}}if(!n)return Promise.reject(new Error("ERROR: Client is not connected"));let d,g=u[2];const h=u[3]?u[3].replace("?size=",""):void 0;let m;"avatar"===u[1]||"profile"===u[1]?(d=Object(p.t)(Number(g)),g=Math.abs(Number(g))):d=u[1];switch(d){case"channel":case"chat":m=f.a.chats[g];break;case"user":m=f.a.users[g];break;case"msg":m=f.a.messages[g];break;case"sticker":case"gif":case"wallpaper":m=f.a.documents[g];break;case"photo":m=f.a.photos[g];break;case"stickerSet":m=f.a.stickerSets[g];break;case"webDocument":m=f.a.webDocuments[g]}if(!m)return;if(w.has(d)){c===l.ApiMediaFormat.Stream&&(s.acceptsBuffer=!0);const e=await t.downloadMedia(m,{sizeType:h,start:a,end:o,progressCallback:s,workers:r.k});let n,u;return m instanceof i.Api.Message?(n=function(e,t){if(!e||!e.media)return;if(e.media instanceof i.Api.MessageMediaPhoto)return"image/jpeg";if(e.media instanceof i.Api.MessageMediaDocument&&e.media.document instanceof i.Api.Document)return t?e.media.document.attributes.some(e=>e instanceof i.Api.DocumentAttributeSticker)?"image/webp":"image/jpeg":e.media.document.mimeType;if(e.media instanceof i.Api.MessageMediaWebPage&&e.media.webpage instanceof i.Api.WebPage&&e.media.webpage.document instanceof i.Api.Document)return e.media.webpage.document.mimeType;return}(m,h),m.media instanceof i.Api.MessageMediaDocument&&m.media.document instanceof i.Api.Document&&(u=m.media.document.size),m.media instanceof i.Api.MessageMediaWebPage&&m.media.webpage instanceof i.Api.WebPage&&m.media.webpage.document instanceof i.Api.Document&&(u=m.media.webpage.document.size)):m instanceof i.Api.Photo?n="image/jpeg":"sticker"===d&&h?n="image/webp":"webDocument"===d?n=m.mimeType:(n=m.mimeType,u=m.size),{mimeType:n,data:e,fullSize:u}}if("stickerSet"===d){const e=await t.downloadStickerSetThumb(m);return{mimeType:c===l.ApiMediaFormat.Lottie?"application/json":A(e),data:e}}{const e=await t.downloadProfilePhoto(m,"profile"===u[1]);return{mimeType:A(e),data:e}}}(e,o,c,u,n,a,t)||{};if(!h)return;const _=await async function(e,t,n){switch(t){case l.ApiMediaFormat.DataUri:return Object(g.a)(new Blob([e],{type:n}));case l.ApiMediaFormat.BlobUrl:return new Blob([e],{type:n});case l.ApiMediaFormat.Lottie:{const t=Object(d.inflate)(e,{to:"string"});return JSON.parse(t)}case l.ApiMediaFormat.Progressive:return e.buffer}return}(h,t,m);if(!_)return;const v=t!==l.ApiMediaFormat.Progressive&&(t!==l.ApiMediaFormat.BlobUrl||_.size<=r.o);if(!r.n&&s&&v){y(e.startsWith("avatar")?r.q:r.p,e,_)}return{prepared:t===l.ApiMediaFormat.Progressive?"":function(e){if(e instanceof Blob)return URL.createObjectURL(e);return e}(_),arrayBuffer:t===l.ApiMediaFormat.Progressive?_:void 0,mimeType:m,fullSize:b}}function A(e,t="image/jpeg"){if(e.length<4)return t;let n=t;switch(e.subarray(0,4).reduce((e,t)=>e+t.toString(16),"")){case"89504e47":n="image/png";break;case"47494638":n="image/gif";break;case"ffd8ffe0":case"ffd8ffe1":case"ffd8ffe2":case"ffd8ffe3":case"ffd8ffe8":n="image/jpeg";break;case"52494646":n="image/webp"}return n}var I=n(12);a.Logger.setLevel(r.h?"debug":"warn");const P={build:e=>e};let C,S,M=!1;async function k(e,t){r.g&&console.log(">>> START INIT API"),C=e;const{userAgent:n,platform:s,sessionData:a}=t,u=new i.sessions.CallbackSession(a,U);S=new i.TelegramClient(u,"2496","8da85b0d5bfe62527e5b244c209159c3",{deviceModel:navigator.userAgent||n||"Unknown UserAgent",appVersion:r.d+" Z",useWSS:!0,additionalDcsDisabled:r.l}),S.addEventHandler(T,P),S.addEventHandler(c.b,P);try{r.g&&console.log("[GramJs/client] CONNECTING");try{await S.start({phoneNumber:o.g,phoneCode:o.e,password:o.f,firstAndLastNames:o.i,qrCode:o.h,onError:o.b,initialMethod:"iOS"===s||"Android"===s?"phoneNumber":"qrCode"})}catch(e){return void C({"@type":"updateConnectionState",connectionState:"connectionStateBroken"})}r.g&&(console.log(">>> FINISH INIT API"),console.log("[GramJs/client] CONNECTED")),Object(o.c)(),U(u.getSessionData()),C({"@type":"updateApiReady"}),N()}catch(e){throw r.g&&console.log("[GramJs/client] CONNECTING ERROR",e),e}}async function E(){await D(new i.Api.auth.LogOut),await S.destroy()}async function O(){await S.disconnect()}function R(){return S}function U(e){C({"@type":"updateSession",sessionData:e})}function T(e){e instanceof i.connection.UpdateConnectionState?M=e.state===i.connection.UpdateConnectionState.connected:e instanceof i.Api.UpdatesTooLong?async function(){try{await D(new i.Api.users.GetFullUser({id:new i.Api.InputUserSelf}),void 0,!0)}catch(e){"AUTH_KEY_UNREGISTERED"===e.message&&C({"@type":"updateConnectionState",connectionState:"connectionStateBroken"})}}():e instanceof i.connection.UpdateServerTimeOffset&&C({"@type":"updateServerTimeOffset",serverTimeOffset:e.timeOffset})}async function D(e,t=!1,n=!1){if(M)try{r.g&&console.log("[GramJs/client] INVOKE "+e.className);const n=await S.invoke(e);if(r.g&&console.log("[GramJs/client] INVOKE RESPONSE "+e.className,n),t){let t;n instanceof i.Api.Updates||n instanceof i.Api.UpdatesCombined?t=n:"updates"in n&&(n.updates instanceof i.Api.Updates||n.updates instanceof i.Api.UpdatesCombined)&&(t=n.updates),t?(!function(e){const t=[...e.users,...e.chats];e.updates.forEach(e=>{t&&(e._entities=t)})}(t),t.updates.forEach(t=>{Object(c.b)(t,e)})):n instanceof i.Api.UpdatesTooLong||Object(c.b)(n,e)}return n}catch(t){if(r.g&&(console.log("[GramJs/client] INVOKE ERROR "+e.className),console.error(t)),function(e,t){const n=e.message.startsWith("A wait of")&&(t instanceof i.Api.messages.SendMessage||t instanceof i.Api.messages.SendMedia||t instanceof i.Api.messages.SendMultiMedia),{message:s}=e;C({"@type":"error",error:{message:s,isSlowMode:n,hasErrorKey:!0}})}(t,e),n)throw t;return}else r.g&&console.warn(`[GramJs/client] INVOKE ERROR ${e.className}: Client is not connected`)}function B(e,t){return v(e,S,M,t)}function x(e,t){return S.uploadFile({file:e,onProgress:t,workers:r.x})}function j(e){return S.updateTwoFaSettings(e)}async function N(){const e=await D(new i.Api.users.GetFullUser({id:new i.Api.InputUserSelf}));if(!(e&&e.user instanceof i.Api.User))return;f.a.users[e.user.id]=e.user;const t=Object(I.b)(e);Object(u.o)(t.id),Object(o.d)(t)}},function(e,t,n){"use strict";(function(e){n.d(t,"t",(function(){return d})),n.d(t,"p",(function(){return l})),n.d(t,"i",(function(){return f})),n.d(t,"g",(function(){return g})),n.d(t,"m",(function(){return h})),n.d(t,"f",(function(){return m})),n.d(t,"h",(function(){return b})),n.d(t,"j",(function(){return y})),n.d(t,"d",(function(){return _})),n.d(t,"s",(function(){return w})),n.d(t,"n",(function(){return v})),n.d(t,"o",(function(){return A})),n.d(t,"r",(function(){return I})),n.d(t,"u",(function(){return P})),n.d(t,"v",(function(){return C})),n.d(t,"c",(function(){return S})),n.d(t,"e",(function(){return M})),n.d(t,"b",(function(){return k})),n.d(t,"a",(function(){return E})),n.d(t,"q",(function(){return O})),n.d(t,"k",(function(){return R})),n.d(t,"l",(function(){return U}));var s=n(15),i=n.n(s),a=n(0),r=n(8),o=n(13),c=n(5),u=n(14);function d(e){return e>0?"user":e<=-1e9?"channel":"chat"}function l(e){return e>0?new a.Api.PeerUser({userId:e}):e<=-1e9?new a.Api.PeerChannel({channelId:-e}):new a.Api.PeerChat({chatId:-e})}function f(e,t){return e>0||e<=-1e9?e>0?new a.Api.InputPeerUser({userId:e,accessHash:i()(t)}):new a.Api.InputPeerChannel({channelId:-e,accessHash:i()(t)}):new a.Api.InputPeerChat({chatId:-e})}function p(e){if(e>0){const{accessHash:t}=c.a.users[e]||{};return t?new a.Api.InputPeerUser({userId:e,accessHash:t}):void 0}if(e<=-1e9){const{accessHash:t}=c.a.chats[-e]||{};return t?new a.Api.InputPeerChannel({channelId:-e,accessHash:t}):void 0}return new a.Api.InputPeerChat({chatId:-e})}function g(e,t){return e>0?new a.Api.InputUser({userId:e,accessHash:i()(t)}):e<=-1e9?new a.Api.InputChannel({channelId:-e,accessHash:i()(t)}):-e}function h(e,t){return new a.Api.InputStickerSetID({id:i()(e),accessHash:i()(t)})}function m(e){const t=c.a.documents[e.id];if(t)return new a.Api.InputDocument(Object(u.b)(t,["id","accessHash","fileReference"]))}function b(e){const t=m(e);if(t)return new a.Api.InputMediaDocument({id:t})}function y(t,n){const{summary:s,quiz:i}=t,r=new a.Api.Poll({id:n,publicVoters:s.isPublic,question:s.question,answers:s.answers.map(({text:t,option:n})=>new a.Api.PollAnswer({text:t,option:e.from(n)})),quiz:s.quiz,multipleChoice:s.multipleChoice});if(!i)return new a.Api.InputMediaPoll({poll:r});const o=i.correctAnswers.map(t=>e.from(t)),{solution:c}=i,u=i.solutionEntities?i.solutionEntities.map(A):[];return new a.Api.InputMediaPoll({poll:r,correctAnswers:o,...c&&{solution:c,solutionEntities:u}})}function _(e){const{emoticon:t,contacts:n,nonContacts:s,groups:i,channels:r,bots:o,excludeArchived:c,excludeMuted:u,excludeRead:d,pinnedChatIds:l,includedChatIds:f,excludedChatIds:g}=e,h=l?l.map(p).filter(Boolean):[],m=f?f.map(p).filter(Boolean):[],b=g?g.map(p).filter(Boolean):[];return new a.Api.DialogFilter({id:e.id,title:e.title,emoticon:t||void 0,contacts:n||void 0,nonContacts:s||void 0,groups:i||void 0,bots:o||void 0,excludeArchived:c||void 0,excludeMuted:u||void 0,excludeRead:d||void 0,broadcasts:r||void 0,pinnedPeers:h,includePeers:m,excludePeers:b})}function w(){return Object(r.readBigIntFromBuffer)(Object(r.generateRandomBytes)(8),!0,!0)}function v(e,t,n){return new a.Api.Message({id:e,peerId:l(t),fromId:l(t),media:n.media})}function A(e){const{type:t,offset:n,length:s,url:i,userId:r}=e,u=r?c.a.users[r]:void 0;switch(t){case o.ApiMessageEntityTypes.Bold:return new a.Api.MessageEntityBold({offset:n,length:s});case o.ApiMessageEntityTypes.Italic:return new a.Api.MessageEntityItalic({offset:n,length:s});case o.ApiMessageEntityTypes.Underline:return new a.Api.MessageEntityUnderline({offset:n,length:s});case o.ApiMessageEntityTypes.Strike:return new a.Api.MessageEntityStrike({offset:n,length:s});case o.ApiMessageEntityTypes.Code:return new a.Api.MessageEntityCode({offset:n,length:s});case o.ApiMessageEntityTypes.Pre:return new a.Api.MessageEntityPre({offset:n,length:s,language:""});case o.ApiMessageEntityTypes.Blockquote:return new a.Api.MessageEntityBlockquote({offset:n,length:s});case o.ApiMessageEntityTypes.TextUrl:return new a.Api.MessageEntityTextUrl({offset:n,length:s,url:i});case o.ApiMessageEntityTypes.Url:return new a.Api.MessageEntityUrl({offset:n,length:s});case o.ApiMessageEntityTypes.Hashtag:return new a.Api.MessageEntityHashtag({offset:n,length:s});case o.ApiMessageEntityTypes.MentionName:return new a.Api.InputMessageEntityMentionName({offset:n,length:s,userId:new a.Api.InputUser({userId:r,accessHash:u.accessHash})});default:return new a.Api.MessageEntityUnknown({offset:n,length:s})}}function I(e){let t=0;return e.forEach(e=>{t=(20261*t&2147483647)+e&2147483647}),t}function P(e){const{media:t}=e;return!!t&&(t instanceof a.Api.MessageMediaPhoto||t instanceof a.Api.MessageMediaDocument||t instanceof a.Api.MessageMediaWebPage&&t.webpage instanceof a.Api.WebPage&&(t.webpage.photo instanceof a.Api.Photo||t.webpage.document instanceof a.Api.Document&&t.webpage.document.mimeType.startsWith("video")))}function C(e){return"photo"in e.action&&e.action.photo instanceof a.Api.Photo}function S(e){if(e instanceof a.Api.PhotoEmpty)return new a.Api.ChatPhotoEmpty;const{dcId:t,id:n}=e;return new a.Api.ChatPhoto({dcId:t,photoId:n})}function M({phone:e,firstName:t,lastName:n}){return new a.Api.InputPhoneContact({clientId:i()(1),phone:e,firstName:t,lastName:n})}function k(e,t=0){return new a.Api.ChatBannedRights({...e,untilDate:t})}function E(e){return new a.Api.ChatAdminRights(e)}function O(e){const{shippingAddress:t}=e;return new a.Api.PaymentRequestedInfo({...e,shippingAddress:t?new a.Api.PostAddress(t):void 0})}function R(e){switch(e){case"phoneNumber":return new a.Api.InputPrivacyKeyPhoneNumber;case"lastSeen":return new a.Api.InputPrivacyKeyStatusTimestamp;case"profilePhoto":return new a.Api.InputPrivacyKeyProfilePhoto;case"forwards":return new a.Api.InputPrivacyKeyForwards;case"chatInvite":return new a.Api.InputPrivacyKeyChatInvite}}function U(e){switch(e){case"spam":return new a.Api.InputReportReasonSpam;case"violence":return new a.Api.InputReportReasonViolence;case"childAbuse":return new a.Api.InputReportReasonChildAbuse;case"pornography":return new a.Api.InputReportReasonPornography;case"copyright":return new a.Api.InputReportReasonCopyright;case"fake":return new a.Api.InputReportReasonFake;case"geoIrrelevant":return new a.Api.InputReportReasonGeoIrrelevant;case"other":return new a.Api.InputReportReasonOther}}}).call(this,n(11).Buffer)},function(e,t,n){"use strict";n.d(t,"c",(function(){return u})),n.d(t,"d",(function(){return p})),n.d(t,"j",(function(){return g})),n.d(t,"i",(function(){return h})),n.d(t,"k",(function(){return b})),n.d(t,"e",(function(){return w})),n.d(t,"f",(function(){return v})),n.d(t,"g",(function(){return A})),n.d(t,"h",(function(){return I})),n.d(t,"a",(function(){return P})),n.d(t,"b",(function(){return C}));var s=n(0),i=n(14);function a(e){return e.hasOwnProperty("userId")}function r(e){return e.hasOwnProperty("chatId")}var o=n(20);function c(e,t=!1){const n=Boolean("min"in e&&e.min),i="accessHash"in e&&String(e.accessHash),a="photo"in e&&e.photo&&w(e.photo),r=Boolean("signatures"in e&&e.signatures);return{isMin:n,hasPrivateLink:Boolean("hasLink"in e&&e.hasLink),isSignaturesShown:r,...i&&{accessHash:i},...a&&{avatarHash:a},...(e instanceof s.Api.Channel||e instanceof s.Api.User)&&{username:e.username},..."verified"in e&&{isVerified:e.verified},..."callActive"in e&&{isCallActive:e.callActive},..."callNotEmpty"in e&&{isCallNotEmpty:e.callNotEmpty},...(e instanceof s.Api.Chat||e instanceof s.Api.Channel)&&{...e.participantsCount&&{membersCount:e.participantsCount},joinDate:e.date},...t&&{isSupport:!0},...d(e),..."creator"in e&&{isCreator:e.creator},...l(e),...f(e)}}function u(e,t,n){const{peer:i,folderId:a,unreadMark:r,unreadCount:o,unreadMentionsCount:u,notifySettings:{silent:d,muteUntil:l},readOutboxMaxId:f,readInboxMaxId:p,draft:h}=e,b=d||"number"==typeof l&&Date.now()+1e3*n<1e3*l;return{id:g(i),...a&&{folderId:a},type:m(t),title:y(i,t),lastReadOutboxMessageId:f,lastReadInboxMessageId:p,unreadCount:o,unreadMentionsCount:u,isMuted:b,...r&&{hasUnreadMark:!0},...h instanceof s.Api.DraftMessage&&{draftDate:h.date},...c(t)}}function d(e){return e instanceof s.Api.Chat||e instanceof s.Api.Channel?{adminRights:Object(o.b)(e.adminRights),currentUserBannedRights:e instanceof s.Api.Channel?Object(o.b)(e.bannedRights):void 0,defaultBannedRights:Object(o.b)(e.defaultBannedRights)}:{}}function l(e){if(e instanceof s.Api.ChatForbidden||e instanceof s.Api.ChannelForbidden)return{isRestricted:!0};const t={};if("restricted"in e){const n=e.restricted?function(e){if(!e)return;const t=e.find(({platform:e})=>"all"===e);return t?Object(i.b)(t,["reason","text"]):void 0}(e.restrictionReason):void 0;n&&Object.assign(t,{isRestricted:!0,restrictionReason:n})}return e instanceof s.Api.Chat&&Object.assign(t,{isNotJoined:e.left,isRestricted:e.kicked}),e instanceof s.Api.Channel&&Object.assign(t,{isNotJoined:e.left}),t}function f(e){return e instanceof s.Api.Chat&&e.migratedTo&&!(e.migratedTo instanceof s.Api.InputChannelEmpty)?{migratedTo:{chatId:g(e.migratedTo),...e.migratedTo instanceof s.Api.InputChannel&&{accessHash:e.migratedTo.accessHash.toString()}}}:{}}function p(e,t=!1,n=!1){if(e instanceof s.Api.Chat||e instanceof s.Api.Channel||e instanceof s.Api.User||n&&(e instanceof s.Api.ChatForbidden||e instanceof s.Api.ChannelForbidden))return{id:e instanceof s.Api.User?e.id:-e.id,type:m(e),title:e instanceof s.Api.User?_(e):e.title,...c(e,t)}}function g(e){return a(e)?e.userId:r(e)?-e.chatId:-e.channelId}function h(e){return function(e){return e.hasOwnProperty("userId")}(e)?e.userId:function(e){return e.hasOwnProperty("chatId")}(e)?-e.chatId:function(e){return e.hasOwnProperty("channelId")}(e)?-e.channelId:void 0}function m(e){return e instanceof s.Api.User||e instanceof s.Api.UserEmpty?"chatTypePrivate":e instanceof s.Api.Chat||e instanceof s.Api.ChatForbidden||e instanceof s.Api.ChatEmpty?"chatTypeBasicGroup":e.megagroup?"chatTypeSuperGroup":"chatTypeChannel"}function b(e){return a(e)?"user"+e.userId:r(e)?"chat"+e.chatId:"chat"+e.channelId}function y(e,t){return a(e)?_(t):t.title}function _(e){return e.firstName?`${e.firstName}${e.lastName?" "+e.lastName:""}`:e.lastName||void 0}function w(e){if("photoId"in e)return e.photoId.toString()}function v(e){return{userId:e instanceof s.Api.ChannelParticipantBanned||e instanceof s.Api.ChannelParticipantLeft?g(e.peer):e.userId,inviterId:"inviterId"in e?e.inviterId:void 0,joinedDate:"date"in e?e.date:void 0,kickedByUserId:"kickedBy"in e?e.kickedBy:void 0,promotedByUserId:"promotedBy"in e?e.promotedBy:void 0,bannedRights:"bannedRights"in e?Object(o.b)(e.bannedRights):void 0,adminRights:"adminRights"in e?Object(o.b)(e.adminRights):void 0,customTitle:"rank"in e?e.rank:void 0,...(e instanceof s.Api.ChannelParticipantAdmin||e instanceof s.Api.ChatParticipantAdmin)&&{isAdmin:!0},...(e instanceof s.Api.ChannelParticipantCreator||e instanceof s.Api.ChatParticipantCreator)&&{isOwner:!0}}}function A(e){return e instanceof s.Api.ChatParticipants||e instanceof s.Api.channels.ChannelParticipants?e.participants.map(v).filter(Boolean):void 0}function I(e,t){let n="";if(!(e.action instanceof s.Api.SendMessageCancelAction))return e.action instanceof s.Api.SendMessageTypingAction?n="lng_user_typing":e.action instanceof s.Api.SendMessageRecordVideoAction?n="lng_send_action_record_video":e.action instanceof s.Api.SendMessageUploadVideoAction?n="lng_send_action_upload_video":e.action instanceof s.Api.SendMessageRecordAudioAction?n="lng_send_action_record_audio":e.action instanceof s.Api.SendMessageUploadAudioAction?n="lng_send_action_upload_audio":e.action instanceof s.Api.SendMessageUploadPhotoAction?n="lng_send_action_upload_photo":e.action instanceof s.Api.SendMessageUploadDocumentAction?n="lng_send_action_upload_file":e.action instanceof s.Api.SendMessageGeoLocationAction?n="selecting a location to share":e.action instanceof s.Api.SendMessageChooseContactAction?n="selecting a contact to share":e.action instanceof s.Api.SendMessageGamePlayAction?n="lng_playing_game":e.action instanceof s.Api.SendMessageRecordRoundAction?n="lng_send_action_record_round":e.action instanceof s.Api.SendMessageUploadRoundAction&&(n="lng_send_action_upload_round"),{action:n,...!(e instanceof s.Api.UpdateUserTyping)&&{userId:g(e.fromId)},timestamp:Date.now()+1e3*t}}function P(e){return{...Object(i.c)(e,["id","title","emoticon","contacts","nonContacts","groups","bots","excludeMuted","excludeRead","excludeArchived"]),channels:e.broadcasts,pinnedChatIds:e.pinnedPeers.map(h).filter(Boolean),includedChatIds:e.includePeers.map(h).filter(Boolean),excludedChatIds:e.excludePeers.map(h).filter(Boolean)}}function C({filter:e,description:t}){return{...P(e),description:t}}},function(e,t,n){"use strict";n.d(t,"d",(function(){return s})),n.d(t,"g",(function(){return i})),n.d(t,"l",(function(){return a})),n.d(t,"h",(function(){return r})),n.d(t,"n",(function(){return o})),n.d(t,"p",(function(){return c})),n.d(t,"q",(function(){return u})),n.d(t,"o",(function(){return d})),n.d(t,"k",(function(){return l})),n.d(t,"x",(function(){return f})),n.d(t,"r",(function(){return p})),n.d(t,"t",(function(){return g})),n.d(t,"f",(function(){return h})),n.d(t,"u",(function(){return m})),n.d(t,"m",(function(){return b})),n.d(t,"c",(function(){return y})),n.d(t,"b",(function(){return _})),n.d(t,"v",(function(){return w})),n.d(t,"s",(function(){return v})),n.d(t,"w",(function(){return A})),n.d(t,"a",(function(){return I})),n.d(t,"e",(function(){return P})),n.d(t,"j",(function(){return C})),n.d(t,"i",(function(){return S}));const s="1.6.1",i=!1,a=!1,r=!1,o=!1,c="tt-media",u="tt-media-avatars",d=524288,l=16,f=16,p=("undefined"!=typeof window&&window.innerHeight,200),g=50,h=100,m=40,b=1e9,y=Math.round(425),_=new Set(["newMessage","newScheduledMessage","deleteMessages","deleteScheduledMessages","deleteHistory"]),w=20,v="MEMOJI_STICKER",A=(new Set(["image/png","image/gif","image/jpeg","video/mp4","video/avi","video/quicktime"]),777e3),I=0,P=1,C=777,S="android"},function(e,t,n){"use strict";t.a={localMessages:{},chats:{},users:{},messages:{},documents:{},stickerSets:{},photos:{},webDocuments:{}}},function(e,t,n){(function(t){function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const{parseTl:i,serializeBytes:a,serializeDate:r}=n(46),{toSignedLittleBuffer:o}=n(8),c=n(81),u=n(82),d="undefined"!=typeof self&&void 0!==self.localStorage;function l(e){const t=i(e,109),n=[],s=[];for(const e of t)e.isFunction?s.push(e):n.push(e);return[n,s]}function f(e,n){switch(n){case"int":{const n=t.alloc(4);return n.writeInt32LE(e,0),n}case"long":return o(e,8);case"int128":return o(e,16);case"int256":return o(e,32);case"double":{const n=t.alloc(8);return n.writeDoubleLE(e,0),n}case"string":return a(e);case"Bool":return e?t.from("b5757299","hex"):t.from("379779bc","hex");case"true":return t.alloc(0);case"bytes":return a(e);case"date":return r(e);default:return e.getBytes()}}function p(e,t){if(t.isVector){t.useVectorId&&e.readInt();const n=[],s=e.readInt();t.isVector=!1;for(let i=0;i{this[e]=t[e]})}static fromReader(e){const t={};for(const n in c)if(c.hasOwnProperty(n)){const s=c[n];if(s.isFlag){if("true"===s.type){t[n]=Boolean(t.flags&1<f(t,c[e].type))))}else if(c[e].flagIndicator)if(Object.values(c).some(e=>e.isFlag)){let e=0;for(const t in c)c[t].isFlag&&(!1===this[t]&&"true"===c[t].type||void 0===this[t]?e|=0:e|=1</);if(n){t.readInt();const e=[],s=t.readInt();if("int"===n[1])for(let n=0;n{"function"!=typeof t[e]&&n[e]?Object.assign(n[e],t[e]):n[e]=t[e]}),n}(g("constructor",e.constructors),g("request",e.requests))}()}).call(this,n(11).Buffer)},function(e,t,n){"use strict";n.d(t,"u",(function(){return g})),n.d(t,"n",(function(){return h})),n.d(t,"o",(function(){return m})),n.d(t,"B",(function(){return b})),n.d(t,"l",(function(){return y})),n.d(t,"z",(function(){return _})),n.d(t,"A",(function(){return w})),n.d(t,"b",(function(){return v})),n.d(t,"M",(function(){return A})),n.d(t,"c",(function(){return I})),n.d(t,"v",(function(){return P})),n.d(t,"i",(function(){return C})),n.d(t,"f",(function(){return S})),n.d(t,"w",(function(){return M})),n.d(t,"e",(function(){return k})),n.d(t,"d",(function(){return E})),n.d(t,"k",(function(){return O})),n.d(t,"E",(function(){return R})),n.d(t,"D",(function(){return U})),n.d(t,"m",(function(){return T})),n.d(t,"r",(function(){return D})),n.d(t,"j",(function(){return B})),n.d(t,"g",(function(){return x})),n.d(t,"F",(function(){return j})),n.d(t,"s",(function(){return N})),n.d(t,"G",(function(){return V})),n.d(t,"K",(function(){return F})),n.d(t,"L",(function(){return L})),n.d(t,"J",(function(){return q})),n.d(t,"N",(function(){return H})),n.d(t,"I",(function(){return G})),n.d(t,"H",(function(){return z})),n.d(t,"q",(function(){return K})),n.d(t,"p",(function(){return W})),n.d(t,"C",(function(){return $})),n.d(t,"x",(function(){return J})),n.d(t,"y",(function(){return Z})),n.d(t,"a",(function(){return Y})),n.d(t,"h",(function(){return Q})),n.d(t,"t",(function(){return te}));var s=n(0),i=n(4),a=n(1),r=n(3),o=n(9),c=n(12),u=n(14),d=n(5),l=n(2),f=n(17);let p;function g(e){p=e}async function h({limit:e,offsetDate:t,archived:n,withPinned:d,serverTimeOffset:l}){const f=await Object(a.g)(new s.Api.messages.GetDialogs({offsetPeer:new s.Api.InputPeerEmpty,limit:e,offsetDate:t,folderId:n?i.e:void 0,...d&&{excludePinned:!0}})),p=d?await Object(a.g)(new s.Api.messages.GetPinnedDialogs({folderId:n?i.e:void 0})):void 0;if(!f||f instanceof s.Api.messages.DialogsNotModified)return;p&&ee(p),ee(f);const g=Object(u.a)((p?p.messages:[]).concat(f.messages).map(o.b).filter(Boolean),"chatId"),h={...p&&X(p),...X(f)},m=[],b={},y={},_=(p?p.dialogs:[]).concat(f.dialogs),w=[];_.forEach(e=>{if(!(e instanceof s.Api.Dialog)||!n&&e.folderId===i.e||n&&e.folderId!==i.e)return;const t=h[Object(r.k)(e.peer)],a=Object(r.c)(e,t,l);if(a.lastMessage=g[a.id],m.push(a),d&&e.pinned&&w.push(a.id),e.draft){const{formattedText:t,replyingToId:n}=Object(o.h)(e.draft)||{};t&&(b[a.id]=t),n&&(y[a.id]=n)}});const v=(p?p.users:[]).concat(f.users).map(c.a).filter(Boolean),A=m.map(e=>e.id);let I;return I=f instanceof s.Api.messages.DialogsSlice?f.count:A.length,{chatIds:A,chats:m,users:v,draftsById:b,replyingToById:y,orderedPinnedIds:d?w:void 0,totalChatCount:I}}function m(e){const{id:t,accessHash:n,adminRights:i}=e;return Object(l.g)(t,n)instanceof s.Api.InputChannel?async function(e,t,n){const i=await Object(a.g)(new s.Api.channels.GetFullChannel({channel:Object(l.g)(e,t)}));if(!(i&&i.fullChat instanceof s.Api.ChannelFull))return;const{about:o,onlineCount:c,exportedInvite:u,slowmodeSeconds:d,slowmodeNextSendDate:f,migratedFromChatId:p,migratedFromMaxId:g,canViewParticipants:h,linkedChatId:m,hiddenPrehistory:b,call:y}=i.fullChat,_=u instanceof s.Api.ChatInviteExported?u.link:void 0,{members:w,users:v}=h&&await K(e,t)||{},{members:A,users:I}=h&&n&&await K(e,t,"kicked")||{},{members:P,users:C}=h&&n&&await K(e,t,"admin")||{};return{fullInfo:{about:o,onlineCount:c,inviteLink:_,slowMode:d?{seconds:d,nextSendDate:f}:void 0,migratedFrom:p?{chatId:Object(r.j)({chatId:p}),maxMessageId:g}:void 0,canViewMembers:h,isPreHistoryHidden:b,members:w,kickedMembers:A,adminMembers:P,groupCallId:y?y.id.toString():void 0,linkedChatId:m?Object(r.j)({chatId:m}):void 0},users:[...v||[],...I||[],...C||[]]}}(t,n,i):async function(e){const t=await Object(a.g)(new s.Api.messages.GetFullChat({chatId:Object(l.g)(e)}));if(!(t&&t.fullChat instanceof s.Api.ChatFull))return;ee(t);const{about:n,participants:i,exportedInvite:o}=t.fullChat,u=Object(r.g)(i),d=u?u.filter(({isAdmin:e,isOwner:t})=>e||t):void 0;return{fullInfo:{about:n,members:u,adminMembers:d,canViewMembers:!0,...o&&{inviteLink:o.link}},users:t.users.map(c.a).filter(Boolean)}}(t)}async function b({query:e}){const t=await Object(a.g)(new s.Api.contacts.Search({q:e}));if(!t)return;ee(t);const n=t.myResults.map(r.j),i=t.chats.concat(t.users).map(e=>Object(r.d)(e)).filter(Boolean),o=t.users.map(c.a).filter(e=>!!e&&!e.isSelf);return{localChats:i.filter(e=>n.includes(e.id)),localUsers:o.filter(e=>n.includes(e.id)),globalChats:i.filter(e=>!n.includes(e.id)),globalUsers:o.filter(e=>!n.includes(e.id))}}async function y({type:e,user:t}){let n;if("self"===e||"user"===e){const i=await Object(a.g)(new s.Api.users.GetUsers({id:["user"===e&&t?Object(l.g)(t.id,t.accessHash):new s.Api.InputUserSelf]}));if(!i||!i.length)return;[n]=i}else if("support"===e){const e=await Object(a.g)(new s.Api.help.GetSupport);if(!e||!e.user)return;n=e.user}const i=Object(r.d)(n,"support"===e);if(i)return p({"@type":"updateChat",id:i.id,chat:i}),{chatId:i.id}}async function _({chat:e,serverTimeOffset:t}){const{id:n,accessHash:i}=e,c=await Object(a.g)(new s.Api.messages.GetPeerDialogs({peers:[new s.Api.InputDialogPeer({peer:Object(l.i)(n,i)})]}));if(!c)return;const u=c.dialogs[0];if(!(u&&u instanceof s.Api.Dialog))return;const d=X(c)[Object(r.k)(u.peer)];if(!d)return;ee(c);const f=Object(o.b)(c.messages[0]);p({"@type":"updateChat",id:n,chat:{...Object(r.c)(u,d,t),lastMessage:f}})}function w({chat:e,text:t,entities:n,replyToMsgId:i}){return Object(a.g)(new s.Api.messages.SaveDraft({peer:Object(l.i)(e.id,e.accessHash),message:t,...n&&{entities:n.map(l.o)},replyToMsgId:i}))}function v(e){return Object(a.g)(new s.Api.messages.SaveDraft({peer:Object(l.i)(e.id,e.accessHash),message:""}))}async function A({chat:e,isMuted:t,serverTimeOffset:n}){await Object(a.g)(new s.Api.account.UpdateNotifySettings({peer:new s.Api.InputNotifyPeer({peer:Object(l.i)(e.id,e.accessHash)}),settings:new s.Api.InputPeerNotifySettings({muteUntil:t?2**31-1:0})})),p({"@type":"updateNotifyExceptions",chatId:e.id,isMuted:t}),_({chat:e,serverTimeOffset:n})}async function I({title:e,about:t,users:n}){const o=await Object(a.g)(new s.Api.channels.CreateChannel({broadcast:!0,title:e,about:t}),!0);if(!(o instanceof s.Api.Updates))return void(i.g&&console.error("Unexpected channel creation update",o));const c=o.chats[0];if(!(c&&c instanceof s.Api.Channel))return void(i.g&&console.error("Created channel not found",o));const u=Object(r.d)(c);return await Object(a.g)(new s.Api.channels.InviteToChannel({channel:Object(l.g)(u.id,u.accessHash),users:n.map(({id:e,accessHash:t})=>Object(l.g)(e,t))})),u}function P({channelId:e,accessHash:t}){return Object(a.g)(new s.Api.channels.JoinChannel({channel:Object(l.g)(e,t)}),!0)}function C({chat:e,user:t}){if("chatTypeBasicGroup"===e.type)return Object(a.g)(new s.Api.messages.DeleteChatUser({chatId:Object(l.g)(e.id,e.accessHash),userId:Object(l.g)(t.id,t.accessHash)}),!0)}function S({chatId:e}){return Object(a.g)(new s.Api.messages.DeleteChat({chatId:Object(l.g)(e)}),!0)}function M({channelId:e,accessHash:t}){return Object(a.g)(new s.Api.channels.LeaveChannel({channel:Object(l.g)(e,t)}),!0)}function k({channelId:e,accessHash:t}){return Object(a.g)(new s.Api.channels.DeleteChannel({channel:Object(l.g)(e,t)}),!0)}async function E({title:e,users:t}){const n=await Object(a.g)(new s.Api.messages.CreateChat({title:e,users:t.map(({id:e,accessHash:t})=>Object(l.g)(e,t))}),!0);if(!(n instanceof s.Api.Updates))return void(i.g&&console.error("Unexpected chat creation update",n));const o=n.chats[0];if(o&&o instanceof s.Api.Chat)return Object(r.d)(o);i.g&&console.error("Created chat not found",n)}async function O({chatId:e,accessHash:t,photo:n}){const i=await Object(a.i)(n),r=Object(l.g)(e,t);return Object(a.g)(r instanceof s.Api.InputChannel?new s.Api.channels.EditPhoto({channel:r,photo:new s.Api.InputChatUploadedPhoto({file:i})}):new s.Api.messages.EditChatPhoto({chatId:r,photo:new s.Api.InputChatUploadedPhoto({file:i})}),!0)}async function R({chat:e,shouldBePinned:t}){const{id:n,accessHash:i}=e;await Object(a.g)(new s.Api.messages.ToggleDialogPin({peer:new s.Api.InputDialogPeer({peer:Object(l.i)(n,i)}),pinned:t||void 0}))&&p({"@type":"updateChatPinned",id:e.id,isPinned:t})}function U({chat:e,folderId:t}){const{id:n,accessHash:i}=e;return Object(a.g)(new s.Api.folders.EditPeerFolders({folderPeers:[new s.Api.InputFolderPeer({peer:Object(l.i)(n,i),folderId:t})]}),!0)}async function T(){const e=await Object(a.g)(new s.Api.messages.GetDialogFilters);if(e)return{byId:Object(u.a)(e.map(r.a),"id"),orderedIds:e.map(({id:e})=>e)}}async function D(){const e=await Object(a.g)(new s.Api.messages.GetSuggestedDialogFilters);if(e)return e.map(r.b)}async function B({id:e,folderUpdate:t}){const n=Object(l.d)(t);await Object(a.g)(new s.Api.messages.UpdateDialogFilter({id:e,filter:n}))&&p({"@type":"updateChatFolder",id:e,folder:t})}async function x(e){const t=await Object(a.g)(new s.Api.messages.UpdateDialogFilter({id:e,filter:void 0})),n=await D();t&&p({"@type":"updateChatFolder",id:e,folder:void 0}),n&&p({"@type":"updateRecommendedChatFolders",folders:n})}async function j({chat:e,hasUnreadMark:t}){const{id:n,accessHash:i}=e;await Object(a.g)(new s.Api.messages.MarkDialogUnread({peer:new s.Api.InputDialogPeer({peer:Object(l.i)(n,i)}),unread:t||void 0}))&&p({"@type":"updateChat",id:e.id,chat:{hasUnreadMark:t}})}async function N(e){const t=await Object(a.g)(new s.Api.contacts.ResolveUsername({username:e}));if(!t)return;const{users:n,chats:i}=t,o=i.length?Object(r.d)(i[0]):Object(r.d)(n[0]);return o?(ee(t),o):void 0}function V({chat:e,isEnabled:t}){const{id:n,accessHash:i}=e,r=Object(l.g)(n,i);return Object(a.g)(new s.Api.channels.TogglePreHistoryHidden({channel:r,enabled:t}),!0)}function F({chat:e,bannedRights:t}){const{id:n,accessHash:i}=e,r=Object(l.i)(n,i);return Object(a.g)(new s.Api.messages.EditChatDefaultBannedRights({peer:r,bannedRights:Object(l.b)(t)}),!0)}function L({chat:e,user:t,bannedRights:n,untilDate:i}){const r=Object(l.g)(e.id,e.accessHash),o=Object(l.i)(t.id,t.accessHash);return Object(a.g)(new s.Api.channels.EditBanned({channel:r,participant:o,bannedRights:Object(l.b)(n,i)}),!0)}function q({chat:e,user:t,adminRights:n,customTitle:i=""}){const r=Object(l.g)(e.id,e.accessHash),o=Object(l.g)(t.id,t.accessHash);return Object(a.g)(new s.Api.channels.EditAdmin({channel:r,userId:o,adminRights:Object(l.a)(n),rank:i}),!0)}async function H(e,t){const n=Object(l.g)(e.id,e.accessHash);await Object(a.g)(n instanceof s.Api.InputChannel?new s.Api.channels.EditTitle({channel:n,title:t}):new s.Api.messages.EditChatTitle({chatId:n,title:t}),!0)}async function G(e,t){await Object(a.g)(new s.Api.messages.EditChatAbout({peer:Object(l.i)(e.id,e.accessHash),about:t}))&&p({"@type":"updateChatFullInfo",id:e.id,fullInfo:{about:t}})}function z({chat:e,isEnabled:t}){const{id:n,accessHash:i}=e,r=Object(l.g)(n,i);return Object(a.g)(new s.Api.channels.ToggleSignatures({channel:r,enabled:t}),!0)}async function K(e,t,n="recent",o){let u;switch(n){case"kicked":u=new s.Api.ChannelParticipantsKicked({q:""});break;case"admin":u=new s.Api.ChannelParticipantsAdmins;break;default:u=new s.Api.ChannelParticipantsRecent}const d=await Object(a.g)(new s.Api.channels.GetParticipants({channel:Object(l.g)(e,t),filter:u,offset:o,limit:i.r}));if(d&&!(d instanceof s.Api.channels.ChannelParticipantsNotModified))return ee(d),{members:Object(r.g)(d),users:d.users.map(c.a).filter(Boolean)}}async function W(){const e=await Object(a.g)(new s.Api.channels.GetGroupsForDiscussion);if(e)return ee(e),e.chats.map(e=>Object(r.d)(e))}function $({channel:e,chat:t}){return Object(a.g)(new s.Api.channels.SetDiscussionGroup({broadcast:Object(l.i)(e.id,e.accessHash),group:t?Object(l.i)(t.id,t.accessHash):new s.Api.InputChannelEmpty}))}async function J(e){const t=await Object(a.g)(new s.Api.messages.MigrateChat({chatId:Object(l.g)(e.id)}),!0);if(t&&t instanceof s.Api.Updates)return ee(t),Object(r.d)(t.chats[1]);i.g&&console.error("Unexpected channel creation update",t)}async function Z(e){const t=await Object(a.g)(new s.Api.messages.CheckChatInvite({hash:e}));if(!t)return;let n;return t instanceof s.Api.ChatInvite?p({"@type":"showInvite",data:{title:t.title,hash:e,participantsCount:t.participantsCount,isChannel:t.channel}}):(n=Object(r.d)(t.chat),n&&p({"@type":"updateChat",id:n.id,chat:n})),n?{chatId:n.id}:void 0}function Y(e,t){return"chatTypeChannel"===e.type||"chatTypeSuperGroup"===e.type?Object(a.g)(new s.Api.channels.InviteToChannel({channel:Object(l.g)(e.id,e.accessHash),users:t.map(e=>Object(l.g)(e.id,e.accessHash))}),!0):Promise.all(t.map(t=>Object(a.g)(new s.Api.messages.AddChatUser({chatId:Object(l.g)(e.id),userId:Object(l.g)(t.id,t.accessHash)}),!0)))}function Q(e,t){return"chatTypeChannel"===e.type||"chatTypeSuperGroup"===e.type?L({chat:e,user:t,bannedRights:{viewMessages:!0,sendMessages:!0,sendMedia:!0,sendStickers:!0,sendGifs:!0,sendGames:!0,sendInline:!0,embedLinks:!0,sendPolls:!0,changeInfo:!0,inviteUsers:!0,pinMessages:!0},untilDate:2**31-1}):Object(a.g)(new s.Api.messages.DeleteChatUser({chatId:Object(l.g)(e.id),userId:Object(l.g)(t.id,t.accessHash)}),!0)}function X(e){const t={};return e.chats.forEach(e=>{t["chat"+e.id]=e}),e.users.forEach(e=>{t["user"+e.id]=e}),t}function ee(e){"users"in e&&e.users.forEach(e=>{e instanceof s.Api.User&&(d.a.users[e.id]=e)}),"chats"in e&&e.chats.forEach(e=>{(e instanceof s.Api.Chat||e instanceof s.Api.Channel)&&(d.a.chats[e.id]=e)}),"messages"in e&&e.messages.forEach(e=>{e instanceof s.Api.Message&&Object(l.u)(e)&&Object(f.a)(e)})}async function te({hash:e}){const t=await Object(a.g)(new s.Api.messages.ImportChatInvite({hash:e}),!0);if(!(t instanceof s.Api.Updates&&t.chats.length))return;return Object(r.d)(t.chats[0])}},function(e,t,n){(function(t){const s=n(15),i=n(36);function a(e,n=!0,i=!1){let a=t.from(e);const r=a.length;n&&(a=a.reverse());let o=s(a.toString("hex"),16);return i&&Math.floor(o.toString("2").length/8)>=r&&(o=o.subtract(s(2).pow(s(8*r)))),o}function r(e,n=8){const i=s(e),a=[];for(let e=0;e>>1:e>>>1;t[n]=e}return t}()),t.isBuffer(e)||(e=t.from(e));let n=-1;for(let t=0;t>>8}return(-1^n)>>>0},generateRandomBytes:c,generateKeyDataFromNonce:async function(e,n){e=r(e,16),n=r(n,32);const[s,i,a]=await Promise.all([u(t.concat([n,e])),u(t.concat([e,n])),u(t.concat([n,n]))]);return{key:t.concat([s,i.slice(0,12)]),iv:t.concat([i.slice(12,20),a,n.slice(0,4)])}},sha1:u,sha256:function(e){const t=i.createHash("sha256");return t.update(e),t.digest()},bigIntMod:function(e,t){return e.remainder(t).add(t).remainder(t)},modExp:function(e,t,n){e=e.remainder(n);let i=s.one,a=e;for(;t.greater(s.zero);){const e=t.remainder(s(2));t=t.divide(s(2)),e.eq(s.one)&&(i=i.multiply(a),i=i.remainder(n)),a=a.multiply(a),a=a.remainder(n)}return i},getRandomInt:function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e},sleep:e=>new Promise(t=>setTimeout(t,e)),getByteArray:function(e,t=!1){const n=e.toString(2).length,i=Math.floor((n+8-1)/8);return o(s(e),i,!1,t)},toSignedLittleBuffer:r,convertToLittle:function(e){const n=t.alloc(4*e.length);for(let t=0;t{e=t}),resolve:e}}}}).call(this,n(11).Buffer)},function(e,t,n){"use strict";n.d(t,"o",(function(){return m})),n.d(t,"b",(function(){return b})),n.d(t,"d",(function(){return y})),n.d(t,"e",(function(){return _})),n.d(t,"c",(function(){return w})),n.d(t,"j",(function(){return A})),n.d(t,"h",(function(){return I})),n.d(t,"i",(function(){return P})),n.d(t,"m",(function(){return C})),n.d(t,"a",(function(){return S})),n.d(t,"k",(function(){return M})),n.d(t,"l",(function(){return k})),n.d(t,"n",(function(){return E})),n.d(t,"g",(function(){return R})),n.d(t,"f",(function(){return U}));var s=n(0),i=n(4),a=n(14),r=n(3),o=n(22),c=n(19),u=n(34);const d={USD:"$",EUR:"€",GBP:"£",JPY:"¥",RUB:"₽",UAH:"₴",INR:"₹",AED:"د.إ"};function l(e){return e&&d[e]||""}var f=n(2),p=n(17);let g,h=i.m;function m(e){g=e}function b(e){const t=Object(p.c)(e);if(t&&(e instanceof s.Api.Message||e instanceof s.Api.MessageService))return v(t,e)}function y(e){return v(Object(r.j)({userId:e.userId}),{...e,fromId:Object(f.p)(e.out?g:e.userId)})}function _(e){return v(Object(r.j)({chatId:e.chatId}),{...e,fromId:Object(f.p)(e.fromId)})}function w(e,t){const n=h++;let s={};return e.media&&(s={...P(e.media)}),!e.message||s.sticker||s.poll||s.contact||(s={...s,text:A(e.message,e.entities)}),{id:n,chatId:i.w,date:e.inboxDate||t,content:s,isOutgoing:!1}}function v(e,t){const n=t.fromId?Object(r.j)(t.fromId):void 0,i=!n&&e===g,a=t.out&&!t.post||i&&!t.fwdFrom;let o={};t.media&&(o={...P(t.media)}),!t.message||o.sticker||o.poll||o.contact||(o={...o,text:A(t.message,t.entities)});const u=t.action&&function(e,t,n,i){if(e instanceof s.Api.MessageActionEmpty)return;let a="";const o=[];let u,d="other";const f="users"in e?e.users&&e.users:"userId"in e&&[e.userId]||[];let g;if(e instanceof s.Api.MessageActionChatCreate)a="Notification.CreatedChatWithTitle",o.push("%action_origin%",e.title);else if(e instanceof s.Api.MessageActionChatEditTitle)n?(a="Channel.MessageTitleUpdated",o.push(e.title)):(a="Notification.ChangedGroupName",o.push("%action_origin%",e.title));else if(e instanceof s.Api.MessageActionChatEditPhoto)n?a="Channel.MessagePhotoUpdated":(a="Notification.ChangedGroupPhoto",o.push("%action_origin%"));else if(e instanceof s.Api.MessageActionChatDeletePhoto)a=n?"Channel.MessagePhotoRemoved":"Group.MessagePhotoRemoved";else if(e instanceof s.Api.MessageActionChatAddUser)!t||f.includes(t)?(a="Notification.JoinedChat",o.push("%target_user%")):(a="Notification.Invited",o.push("%action_origin%","%target_user%"));else if(e instanceof s.Api.MessageActionChatDeleteUser)!t||f.includes(t)?(a="Notification.LeftChat",o.push("%target_user%")):(a="Notification.Kicked",o.push("%action_origin%","%target_user%"));else if(e instanceof s.Api.MessageActionChatJoinedByLink)a="Notification.JoinedGroupByLink",o.push("%action_origin%");else if(e instanceof s.Api.MessageActionChannelCreate)a="Notification.CreatedChannel";else if(e instanceof s.Api.MessageActionChatMigrateTo)g=Object(r.j)(e),a="Migrated to %target_chat%",o.push("%target_chat%");else if(e instanceof s.Api.MessageActionChannelMigrateFrom)g=Object(r.j)(e),a="Migrated from %target_chat%",o.push("%target_chat%");else if(e instanceof s.Api.MessageActionPinMessage)a="Notification.PinnedTextMessage",o.push("%action_origin%","%message%");else if(e instanceof s.Api.MessageActionHistoryClear)a="HistoryCleared",d="historyClear";else if(e instanceof s.Api.MessageActionPhoneCall){const t=Boolean(e.duration);if(a=[t?"ChatList.Service":"Chat",e.video?"VideoCall":"Call",i?t?"outgoing":"Outgoing":t?"incoming":"Incoming"].join("."),t){const t=Math.max(Math.round(e.duration/60),1);o.push(`${t} min${t>1?"s":""}`)}}else if(e instanceof s.Api.MessageActionContactSignUp)a="Notification.Joined",o.push("%action_origin%");else if(e instanceof s.Api.MessageActionPaymentSent){const t=l(e.currency),n=(Number(e.totalAmount)/100).toFixed(2);a="Notification.PaymentSent",o.push(t,n,"%product%")}else if(e instanceof s.Api.MessageActionGroupCall)if(e.duration){const t=Math.max(Math.round(e.duration/60),1);a="Notification.VoiceChatEnded",o.push(`${t} min${t>1?"s":""}`)}else a="Notification.VoiceChatStartedChannel";else a="ChatList.UnsupportedMessage";"photo"in e&&e.photo instanceof s.Api.Photo&&(Object(p.b)(e.photo),u=Object(c.a)(e.photo));return{text:a,type:d,targetUserIds:f,targetChatId:g,photo:u,translationValues:o}}(t.action,n,Boolean(t.post),a);u&&(o.action=u);const{replyToMsgId:d,replyToTopId:f}=t.replyTo||{},h=t.editDate&&!t.editHide,{inlineButtons:m,keyboardButtons:b}=function(e){const{id:t,replyMarkup:n,media:i}=e;if(!n)return i instanceof s.Api.MessageMediaWebPage&&i.webpage instanceof s.Api.WebPage&&"telegram_message"===i.webpage.type?{inlineButtons:[[{type:"url",text:"Show Message",messageId:t,value:i.webpage.url}]]}:void 0;if(!(n instanceof s.Api.ReplyKeyboardMarkup||n instanceof s.Api.ReplyInlineMarkup))return;const a=n.rows.map(({buttons:e})=>e.map(e=>{let n,a,{text:r}=e;return e instanceof s.Api.KeyboardButton?(n="command",a=r):e instanceof s.Api.KeyboardButtonUrl?(n="url",a=e.url):e instanceof s.Api.KeyboardButtonCallback?(n="callback",a=String(e.data)):e instanceof s.Api.KeyboardButtonRequestPoll?n="requestPoll":e instanceof s.Api.KeyboardButtonBuy?(i instanceof s.Api.MessageMediaInvoice&&i.receiptMsgId&&(r="Receipt",a=i.receiptMsgId),n="buy"):n="NOT_SUPPORTED",{type:n,text:r,messageId:t,value:a}}));return{[n instanceof s.Api.ReplyKeyboardMarkup?"keyboardButtons":"inlineButtons"]:a}}(t)||{},y=t.fwdFrom&&function(e,t=!1){const n=e.savedFromPeer&&Object(r.j)(e.savedFromPeer),s=e.fromId&&Object(r.j)(e.fromId);return{isChannelPost:Boolean(e.channelPost),isLinkedChannelPost:Boolean(e.channelPost&&n&&!t),fromChatId:n||s,fromMessageId:e.channelPost||e.savedFromMsgId,senderUserId:s,hiddenUserName:e.fromName,adminTitle:e.postAuthor}}(t.fwdFrom,i),{replies:_,mediaUnread:w,postAuthor:v}=t,I=t.groupedId&&t.groupedId.toString(),C=Boolean(I)&&!(o.document||o.audio),S=t.replyMarkup instanceof s.Api.ReplyKeyboardHide;return{id:t.id,chatId:e,isOutgoing:a,content:o,date:t.date,senderId:n||t.out&&t.post&&g||e,views:t.views,isFromScheduled:t.fromScheduled,...d&&{replyToMessageId:d},...f&&{replyToTopMessageId:f},...y&&{forwardInfo:y},...h&&{isEdited:h},...w&&{isMediaUnread:w},...t.mentioned&&w&&{hasUnreadMention:!0},...I&&{groupedId:I,isInAlbum:C},inlineButtons:m,...b&&{keyboardButtons:b},...S&&{shouldHideKeyboardButtons:S},...t.viaBotId&&{viaBotId:t.viaBotId},..._&&_.comments&&{threadInfo:B(_,t.id,e)},...v&&{adminTitle:v}}}function A(e,t){return{text:e,...t&&{entities:t.map(D)}}}function I(e){if(e instanceof s.Api.DraftMessageEmpty)return;const{message:t,entities:n,replyToMsgId:i,date:a}=e;return{formattedText:t?A(t,n):void 0,replyingToId:i,date:a}}function P(e){const t=function(e){if(!(e instanceof s.Api.MessageMediaDocument&&e.document&&e.document instanceof s.Api.Document))return;return Object(o.a)(e.document)}(e);if(t)return{sticker:t};const n=function(e){if(!(e instanceof s.Api.MessageMediaPhoto&&e.photo&&e.photo instanceof s.Api.Photo))return;if(e.ttlSeconds)return;return Object(c.a)(e.photo)}(e);if(n)return{photo:n};const i=function(e){if(!(e instanceof s.Api.MessageMediaDocument&&e.document instanceof s.Api.Document&&e.document.mimeType.startsWith("video")))return;return C(e.document)}(e);if(i)return{video:i};const r=function(e){if(!(e instanceof s.Api.MessageMediaDocument&&e.document&&e.document instanceof s.Api.Document))return;const t=e.document.attributes.find(e=>e instanceof s.Api.DocumentAttributeAudio);if(!t||t.voice)return;return{fileName:O(e.document,"audio"),...Object(a.b)(e.document,["size","mimeType"]),...Object(a.b)(t,["duration","performer","title"])}}(e);if(r)return{audio:r};const u=function(e){if(!(e instanceof s.Api.MessageMediaDocument&&e.document&&e.document instanceof s.Api.Document))return;const t=e.document.attributes.find(e=>e instanceof s.Api.DocumentAttributeAudio);if(!t||!t.voice)return;const{duration:n,waveform:i}=t;return{duration:n,waveform:i?Array.from(i):void 0}}(e);if(u)return{voice:u};const d=function(e){if(!(e instanceof s.Api.MessageMediaDocument&&e.document))return;if(e.ttlSeconds)return;return S(e.document)}(e);if(d)return{document:d};const f=function(e){if(!(e instanceof s.Api.MessageMediaContact))return;return Object(a.b)(e,["firstName","lastName","phoneNumber","userId"])}(e);if(f)return{contact:f};const p=function(e){if(!(e instanceof s.Api.MessageMediaPoll))return;return M(e.poll,e.results)}(e);if(p)return{poll:p};const g=E(e);if(g)return{webPage:g};const h=function(e){if(!(e instanceof s.Api.MessageMediaInvoice))return;return function(e){const{description:t,title:n,photo:s,test:i,totalAmount:a,currency:r,receiptMsgId:o}=e,c=l(r);return{text:t,title:n,photoUrl:s&&s.url,receiptMsgId:o,description:`${c}${(Number(a)/100).toFixed(2)} ${i?"TEST INVOICE":""}`}}(e)}(e);return h?{invoice:h}:void 0}function C(e){if(e instanceof s.Api.DocumentEmpty)return;const{id:t,mimeType:n,thumbs:i,size:a,attributes:r}=e,o=r.find(e=>e instanceof s.Api.DocumentAttributeVideo);if(!o)return;const u=r.find(e=>e instanceof s.Api.DocumentAttributeAnimated),{duration:d,w:l,h:f,supportsStreaming:p=!1,roundMessage:g=!1}=o;return{id:String(t),mimeType:n,duration:d,fileName:O(e,"video"),width:l,height:f,supportsStreaming:p,isRound:g,isGif:Boolean(u),thumbnail:Object(c.d)(i),size:a}}function S(e){if(!(e instanceof s.Api.Document))return;const{id:t,size:n,mimeType:i,date:a,thumbs:r,attributes:o}=e,u=r&&Object(c.d)(r);let d,l;const f=r&&r.find(e=>e instanceof s.Api.PhotoSize);if(f)if(l={width:f.w,height:f.h},i.startsWith("image/")){d="photo";const e=o.find(e=>e instanceof s.Api.DocumentAttributeImageSize);if(e){const{w:t,h:n}=e;l={width:t,height:n}}}else i.startsWith("video/")&&(d="video");return{id:String(t),size:n,mimeType:i,timestamp:a,fileName:O(e),thumbnail:u,mediaType:d,mediaSize:l}}function M(e,t){const{id:n,answers:s}=e,i=s.map(e=>({text:e.text,option:String.fromCharCode(...e.option)}));return{id:n.toString(),summary:{isPublic:e.publicVoters,...Object(a.b)(e,["closed","multipleChoice","quiz","question","closePeriod","closeDate"]),answers:i},results:k(t)}}function k(e){const{results:t,totalVoters:n,recentVoters:s,solution:i,solutionEntities:a}=e;return{totalVoters:n,recentVoterIds:s,results:t&&t.map(({option:e,chosen:t,correct:n,voters:s})=>({isChosen:t,isCorrect:n,option:String.fromCharCode(...e),votersCount:s})),solution:i,...a&&{solutionEntities:a.map(D)}}}function E(e){if(!(e instanceof s.Api.MessageMediaWebPage&&e.webpage instanceof s.Api.WebPage))return;const{id:t,photo:n,document:i}=e.webpage;let r;return i instanceof s.Api.Document&&i.mimeType.startsWith("video/")&&(r=C(i)),{id:Number(t),...Object(a.b)(e.webpage,["url","displayUrl","type","siteName","title","description","duration"]),photo:n instanceof s.Api.Photo?Object(c.a)(n):void 0,document:!r&&i?S(i):void 0,video:r}}function O(e,t="file"){const{mimeType:n,attributes:i}=e,a=i.find(e=>e instanceof s.Api.DocumentAttributeFilename);if(a)return a.fileName;const r=n.split("/")[1];return`${t}${String(e.id)}.${r}`}function R(e,t,n,s,i,a,r,o,c,d,l=0){const f=h++,p=i&&function(e){const{filename:t,blobUrl:n,previewBlobUrl:s,mimeType:i,size:a}=e;if(e.quick){const{width:r,height:o,duration:c}=e.quick;return i.startsWith("image/")?{photo:{id:"temp",sizes:[],thumbnail:{width:r,height:o,dataUri:""},blobUrl:n}}:{video:{id:"temp",mimeType:i,duration:c||0,fileName:t,width:r,height:o,blobUrl:n,...s&&{thumbnail:{width:r,height:o,dataUri:s}},size:a}}}if(e.voice){const{duration:t,waveform:n}=e.voice,{data:s}=Object(u.a)(n,63);return{voice:{duration:t,waveform:s}}}return i.startsWith("audio/")?{audio:{mimeType:i,fileName:t,size:a,duration:200}}:{document:{mimeType:i,fileName:t,size:a,...s&&{previewBlobUrl:s}}}}(i),m="chatTypeChannel"===e.type;return{id:f,chatId:e.id,content:{...t&&{text:{text:t,entities:n}},...p,...a&&{sticker:a},...r&&{video:r},...o&&T(o,f)},date:d||Math.round(Date.now()/1e3)+l,isOutgoing:!m,senderId:g,...s&&{replyToMessageId:s},...c&&{groupedId:c,...p&&(p.photo||p.video)&&{isInAlbum:!0}},...d&&{isScheduled:!0}}}function U(e,t,n){const s=h++,{content:i,chatId:a,id:r,senderId:o,groupedId:c,isInAlbum:u}=t,d=i.audio,l=e.id===g&&(a!==e.id||t.forwardInfo)&&!d;return{id:s,chatId:e.id,content:i,date:Math.round(Date.now()/1e3)+n,isOutgoing:!l&&"chatTypeChannel"!==e.type,senderId:g,sendingState:"messageSendingStatePending",...o!==g&&!d&&{forwardInfo:{isChannelPost:!1,fromChatId:a,fromMessageId:r,senderUserId:o}},groupedId:c,isInAlbum:u}}function T(e,t){return{poll:{id:t.toString(),summary:Object(a.b)(e.summary,["question","answers"]),results:{}}}}function D(e){const{className:t,offset:n,length:s}=e;return{type:t,offset:n,length:s,..."userId"in e&&"number"==typeof e.userId&&{userId:e.userId},..."url"in e&&{url:e.url}}}function B(e,t,n){const{channelId:s,replies:a,maxId:o,readMaxId:c,recentRepliers:u}=e;if(s===i.j)return;return{threadId:t,...n!==s?{chatId:Object(r.j)({channelId:s}),originChannelId:n}:{chatId:n},messagesCount:a,lastMessageId:o,lastReadInboxMessageId:c,...u&&{recentReplierIds:u.map(r.j)}}}},function(e,t,n){"use strict";(function(e){n.d(t,"m",(function(){return b})),n.d(t,"g",(function(){return y})),n.d(t,"e",(function(){return _})),n.d(t,"w",(function(){return v})),n.d(t,"d",(function(){return I})),n.d(t,"t",(function(){return P})),n.d(t,"q",(function(){return S})),n.d(t,"z",(function(){return M})),n.d(t,"b",(function(){return k})),n.d(t,"c",(function(){return E})),n.d(t,"a",(function(){return O})),n.d(t,"r",(function(){return R})),n.d(t,"o",(function(){return U})),n.d(t,"p",(function(){return T})),n.d(t,"s",(function(){return D})),n.d(t,"v",(function(){return B})),n.d(t,"u",(function(){return x})),n.d(t,"j",(function(){return j})),n.d(t,"x",(function(){return N})),n.d(t,"n",(function(){return V})),n.d(t,"l",(function(){return F})),n.d(t,"k",(function(){return L})),n.d(t,"i",(function(){return q})),n.d(t,"y",(function(){return H})),n.d(t,"f",(function(){return G})),n.d(t,"h",(function(){return K}));var s=n(0),i=n(13),a=n(4),r=n(1),o=n(9),c=n(12),u=n(2),d=n(5),l=n(3),f=n(35),p=n(17),g=n(34),h=n(7);let m;function b(e){m=e}async function y({chat:e,threadId:t,...n}){const a=t===i.MAIN_THREAD_ID?s.Api.messages.GetHistory:s.Api.messages.GetReplies;let d;try{d=await Object(r.g)(new a({peer:Object(u.i)(e.id,e.accessHash),...t!==i.MAIN_THREAD_ID&&{msgId:t},...n}),void 0,!0)}catch(t){"CHANNEL_PRIVATE"===t.message&&m({"@type":"updateChat",id:e.id,chat:{isRestricted:!0}})}if(!d||d instanceof s.Api.messages.MessagesNotModified||!d.messages)return;z(d);const f=d.messages.map(o.b).filter(Boolean),p=d.users.map(c.a).filter(Boolean),g=d.chats.map(e=>Object(l.d)(e)).filter(Boolean),h=f.map(({threadInfo:e})=>e).filter(Boolean);return{messages:f,users:p,chats:g,threadInfos:h}}async function _({chat:e,messageId:t}){const n="channel"===Object(u.t)(e.id),a=await Object(r.g)(n?new s.Api.channels.GetMessages({channel:Object(u.g)(e.id,e.accessHash),id:[new s.Api.InputMessageID({id:t})]}):new s.Api.messages.GetMessages({id:[new s.Api.InputMessageID({id:t})]}));if(!a||a instanceof s.Api.messages.MessagesNotModified)return;const d=a.messages[0];if(!d)return;if(d instanceof s.Api.MessageEmpty)return i.MESSAGE_DELETED;const l=d&&Object(o.b)(d);if(!l)return;d instanceof s.Api.Message&&Object(p.a)(d);return{message:l,users:a.users.map(c.a).filter(Boolean)}}let w=Promise.resolve();function v({chat:e,text:t,entities:n,replyingTo:i,attachment:c,sticker:l,gif:f,poll:p,isSilent:g,scheduledAt:h,groupedId:b,noWebPage:y,serverTimeOffset:_},v){const I=Object(o.g)(e,t,n,i,c,l,f,p,b,h,_);m({"@type":I.isScheduled?"newScheduledMessage":"newMessage",id:I.id,chatId:e.id,message:I}),setTimeout(()=>{m({"@type":I.isScheduled?"updateScheduledMessage":"updateMessage",id:I.id,chatId:e.id,message:{sendingState:"messageSendingStatePending"}})},1e3);const P=Object(u.s)();if(d.a.localMessages[P.toString()]=I,b)return function({chat:e,text:t,entities:n,replyingTo:i,attachment:o,groupedId:c,isSilent:d,scheduledAt:l},f,p,g){let h=-1;A[c]||(A[c]={counter:0,singleMediaByIndex:{}});h=A[c].counter++;const m=w;return w=(async()=>{let b;try{b=await C(p,o,g)}catch(e){return a.g&&console.warn(e),A[c].counter--,void await m}const y=await async function(e,t){const n=await Object(r.g)(new s.Api.messages.UploadMedia({peer:e,media:t}));if(n instanceof s.Api.MessageMediaPhoto&&n.photo&&n.photo instanceof s.Api.Photo){const{photo:{id:e,accessHash:t,fileReference:i}}=n;return new s.Api.InputMediaPhoto({id:new s.Api.InputPhoto({id:e,accessHash:t,fileReference:i})})}if(n instanceof s.Api.MessageMediaDocument&&n.document&&n.document instanceof s.Api.Document){const{document:{id:e,accessHash:t,fileReference:i}}=n;return new s.Api.InputMediaDocument({id:new s.Api.InputDocument({id:e,accessHash:t,fileReference:i})})}return}(Object(u.i)(e.id,e.accessHash),b);if(await m,!y)return A[c].counter--,void(a.g&&console.warn("Failed to upload grouped media"));if(A[c].singleMediaByIndex[h]=new s.Api.InputSingleMedia({media:y,randomId:f,message:t||"",entities:n?n.map(u.o):void 0}),Object.keys(A[c].singleMediaByIndex).length{let o;if(c)try{o=await C(I,c,v)}catch(e){return a.g&&console.warn(e),void await S}else l?o=Object(u.h)(l):f?o=Object(u.h)(f):p&&(o=Object(u.j)(p,P));await S;const d=o?s.Api.messages.SendMedia:s.Api.messages.SendMessage;await Object(r.g)(new d({clearDraft:!0,message:t||"",entities:n?n.map(u.o):void 0,peer:Object(u.i)(e.id,e.accessHash),randomId:P,...g&&{silent:g},...h&&{scheduleDate:h},...i&&{replyToMsgId:i},...o&&{media:o},...y&&{noWebpage:y}}),!0)})(),w}const A={};async function I({chat:e,message:t,text:n,entities:i,noWebPage:a,serverTimeOffset:o}){const c=1e3*t.date>Date.now()+1e3*o,l={content:{...t.content,...n&&{text:{text:n,entities:i}}}};m({"@type":c?"updateScheduledMessage":"updateMessage",id:t.id,chatId:e.id,message:l}),d.a.localMessages[t.id]={...t,...l};const f=i&&i.map(u.o);await Object(r.g)(new s.Api.messages.EditMessage({message:n||"",entities:f,peer:Object(u.i)(e.id,e.accessHash),id:t.id,...c&&{scheduleDate:t.date},...a&&{noWebpage:a}}),!0)}async function P({chat:e,message:t,scheduledAt:n}){await Object(r.g)(new s.Api.messages.EditMessage({peer:Object(u.i)(e.id,e.accessHash),id:t.id,scheduleDate:n}),!0)}async function C(t,n,i){const{filename:a,blobUrl:o,mimeType:c,quick:u,voice:d}=n,l=await Object(f.b)(o,a),p=e=>{i.isCanceled?p.isCanceled=!0:i(e,t.id)},h=await Object(r.i)(l,p),m=[new s.Api.DocumentAttributeFilename({fileName:a})];if(u){if(c.startsWith("image/"))return new s.Api.InputMediaUploadedPhoto({file:h});{const{width:e,height:t,duration:n}=u;void 0!==n&&m.push(new s.Api.DocumentAttributeVideo({duration:n,w:e,h:t}))}}if(d){const{duration:t,waveform:n}=d,{data:i}=Object(g.a)(n,63);m.push(new s.Api.DocumentAttributeAudio({voice:!0,duration:t,waveform:e.from(i)}))}return new s.Api.InputMediaUploadedDocument({file:h,mimeType:c,attributes:m})}async function S({chat:e,messageId:t,isUnpin:n,isOneSide:i,isSilent:a}){await Object(r.g)(new s.Api.messages.UpdatePinnedMessage({peer:Object(u.i)(e.id,e.accessHash),id:t,...n&&{unpin:!0},...i&&{pmOneside:!0},...a&&{silent:!0}}),!0)}async function M({chat:e}){await Object(r.g)(new s.Api.messages.UnpinAllMessages({peer:Object(u.i)(e.id,e.accessHash)}),!0)}async function k({chat:e,messageIds:t,shouldDeleteForAll:n}){const i="channel"===Object(u.t)(e.id);await Object(r.g)(i?new s.Api.channels.DeleteMessages({channel:Object(u.g)(e.id,e.accessHash),id:t}):new s.Api.messages.DeleteMessages({id:t,...n&&{revoke:!0}}))&&m({"@type":"deleteMessages",ids:t,...i&&{chatId:e.id}})}async function E({chat:e,messageIds:t}){await Object(r.g)(new s.Api.messages.DeleteScheduledMessages({peer:Object(u.i)(e.id,e.accessHash),id:t}))&&m({"@type":"deleteScheduledMessages",ids:t,chatId:e.id})}async function O({chat:e,shouldDeleteForAll:t,maxId:n}){const i="channel"===Object(u.t)(e.id);await Object(r.g)(i?new s.Api.channels.DeleteHistory({channel:Object(u.g)(e.id,e.accessHash),maxId:n}):new s.Api.messages.DeleteHistory({peer:Object(u.i)(e.id,e.accessHash),...t&&{revoke:!0},...!t&&{just_clear:!0},maxId:n}))&&m({"@type":"deleteHistory",chatId:e.id})}async function R({peer:e,messageIds:t,reason:n,description:i}){return await Object(r.g)(new s.Api.messages.Report({peer:Object(u.i)(e.id,e.accessHash),id:t,reason:Object(u.l)(n),message:i}))}async function U({chat:e,threadId:t,maxId:n,serverTimeOffset:a}){const o="channel"===Object(u.t)(e.id);o&&t===i.MAIN_THREAD_ID?await Object(r.g)(new s.Api.channels.ReadHistory({channel:Object(u.g)(e.id,e.accessHash),maxId:n})):o?await Object(r.g)(new s.Api.messages.ReadDiscussion({peer:Object(u.i)(e.id,e.accessHash),msgId:t,readMaxId:n})):await Object(r.g)(new s.Api.messages.ReadHistory({peer:Object(u.i)(e.id,e.accessHash),maxId:n})),t===i.MAIN_THREAD_ID?Object(h.z)({chat:e,serverTimeOffset:a}):D({chat:e,threadId:t})}async function T({chat:e,messageIds:t}){const n="channel"===Object(u.t)(e.id);await Object(r.g)(n?new s.Api.channels.ReadMessageContents({channel:Object(u.g)(e.id,e.accessHash),id:t}):new s.Api.messages.ReadMessageContents({id:t})),m({...n?{"@type":"updateChannelMessages",channelId:e.id}:{"@type":"updateCommonBoxMessages"},ids:t,messageUpdate:{hasUnreadMention:!1,isMediaUnread:!1}})}async function D({chat:e,threadId:t}){const[n,i]=await Promise.all([Object(r.g)(new s.Api.messages.GetDiscussionMessage({peer:Object(u.i)(e.id,e.accessHash),msgId:t})),Object(r.g)(new s.Api.messages.GetReplies({peer:Object(u.i)(e.id,e.accessHash),msgId:t,offsetId:1,addOffset:-1,limit:1}))]);if(!n||!n.messages.length)return;const a=Object(p.c)(n.messages[0]);if(!a)return;m({"@type":"updateThreadInfo",chatId:a,threadId:t,threadInfo:{topMessageId:n.messages[n.messages.length-1].id,lastReadInboxMessageId:n.readInboxMaxId,messagesCount:i instanceof s.Api.messages.ChannelMessages?i.count:void 0},firstMessageId:i&&"messages"in i&&i.messages.length?i.messages[0].id:void 0});n.chats.map(e=>Object(l.d)(e)).filter(Boolean).forEach(e=>{m({"@type":"updateChat",id:e.id,chat:e,noTopChatsRequest:!0})})}async function B({chatOrUser:e,type:t,query:n,topMessageId:i,minDate:a,maxDate:d,...l}){let f;switch(t){case"media":f=new s.Api.InputMessagesFilterPhotoVideo;break;case"documents":f=new s.Api.InputMessagesFilterDocument;break;case"links":f=new s.Api.InputMessagesFilterUrl;break;case"audio":f=new s.Api.InputMessagesFilterMusic;break;case"voice":f=new s.Api.InputMessagesFilterVoice;break;case"profilePhoto":f=new s.Api.InputMessagesFilterChatPhotos;break;case"text":default:f=new s.Api.InputMessagesFilterEmpty}const p=await Object(r.g)(new s.Api.messages.Search({peer:Object(u.i)(e.id,e.accessHash),filter:f,q:n||"",topMsgId:i,minDate:a,maxDate:d,...l}));if(!p||p instanceof s.Api.messages.MessagesNotModified||!p.messages)return;z(p);const g=p.messages.map(o.b).filter(Boolean),h=p.users.map(c.a).filter(Boolean);let m,b=g.length;return(p instanceof s.Api.messages.MessagesSlice||p instanceof s.Api.messages.ChannelMessages)&&(b=p.count,g.length&&(m=g[g.length-1].id)),{messages:g,users:h,totalCount:b,nextOffsetId:m}}async function x({query:e,offsetRate:t=0,limit:n,type:i="text",minDate:u,maxDate:d}){let f;switch(i){case"media":f=new s.Api.InputMessagesFilterPhotoVideo;break;case"documents":f=new s.Api.InputMessagesFilterDocument;break;case"links":f=new s.Api.InputMessagesFilterUrl;break;case"audio":f=new s.Api.InputMessagesFilterMusic;break;case"voice":f=new s.Api.InputMessagesFilterVoice;break;case"text":default:if(!(e||d&&u))return;f=new s.Api.InputMessagesFilterEmpty}const p=await Object(r.g)(new s.Api.messages.SearchGlobal({q:e,offsetRate:t,offsetPeer:new s.Api.InputPeerEmpty,limit:n,filter:f,folderId:a.a,minDate:u,maxDate:d}));if(!p||p instanceof s.Api.messages.MessagesNotModified||!p.messages)return;z({chats:p.chats,users:p.users,messages:p.messages});const g=p.chats.map(e=>Object(l.d)(e)).filter(Boolean),h=p.users.map(c.a).filter(Boolean),m=p.messages.map(o.b).filter(Boolean);let b,y=m.length;return(p instanceof s.Api.messages.MessagesSlice||p instanceof s.Api.messages.ChannelMessages)&&(y=p.count,m.length&&(b=m[m.length-1].id)),{messages:m,users:h,chats:g,totalCount:y,nextRate:"nextRate"in p&&p.nextRate?p.nextRate:b}}async function j({message:e}){const t=await Object(r.g)(new s.Api.messages.GetWebPagePreview({message:e}));return t&&Object(o.n)(t)}async function N({chat:t,messageId:n,options:i}){const{id:a,accessHash:o}=t;await Object(r.g)(new s.Api.messages.SendVote({peer:Object(u.i)(a,o),msgId:n,options:i.map(t=>e.from(t))}),!0)}async function V({chat:t,messageId:n,option:i,offset:a,limit:o,shouldResetVoters:d}){const{id:l,accessHash:f}=t,p=await Object(r.g)(new s.Api.messages.GetPollVotes({peer:Object(u.i)(l,f),id:n,...i&&{option:e.from(i)},...a&&{offset:a},...o&&{limit:o}}));if(!p)return;z({chats:[],users:p.users,messages:[]});const g=p.users.map(c.a).filter(Boolean),h=p.votes.map(e=>({userId:e.userId,date:e.date}));return{count:p.count,votes:h,users:g,nextOffset:p.nextOffset,shouldResetVoters:d}}async function F({fromChat:e,toChat:t,messages:n,serverTimeOffset:i}){const a=n.map(({id:e})=>e),c=n.map(u.s);n.forEach((e,n)=>{const s=Object(o.f)(t,e,i);d.a.localMessages[String(c[n])]=s,m({"@type":"newMessage",id:s.id,chatId:t.id,message:s})}),await Object(r.g)(new s.Api.messages.ForwardMessages({fromPeer:Object(u.i)(e.id,e.accessHash),toPeer:Object(u.i)(t.id,t.accessHash),randomId:c,id:a}),!0)}async function L({chat:e,timestamp:t}){const n=await Object(r.g)(new s.Api.messages.GetHistory({peer:Object(u.i)(e.id,e.accessHash),offsetDate:t,addOffset:-1,limit:1}));if(n&&!(n instanceof s.Api.messages.MessagesNotModified)&&n.messages&&n.messages.length)return n.messages[0].id}async function q({chat:e,hash:t=0}){const{id:n,accessHash:i}=e,a=await Object(r.g)(new s.Api.messages.GetScheduledHistory({peer:Object(u.i)(n,i),hash:t}));if(!a||a instanceof s.Api.messages.MessagesNotModified||!a.messages)return;z(a);const c=a.messages.map(o.b).filter(Boolean);return{messages:c,hash:Object(u.r)(c.map(e=>e.id))}}async function H({chat:e,ids:t}){const{id:n,accessHash:i}=e;await Object(r.g)(new s.Api.messages.SendScheduledMessages({peer:Object(u.i)(n,i),id:t}),!0)}function G({chat:e,message:t}){return Object(r.g)(new s.Api.channels.ExportMessageLink({id:t.id,channel:Object(u.g)(e.id,e.accessHash),...t.isInAlbum&&{grouped:!0},...t.threadInfo&&t.threadInfo.topMessageId!==t.id&&{thread:!0}}))}function z(e){e.users.forEach(e=>{e instanceof s.Api.User&&(d.a.users[e.id]=e)}),e.chats.forEach(e=>{(e instanceof s.Api.Chat||e instanceof s.Api.Channel)&&(d.a.chats[e.id]=e)}),e.messages.forEach(e=>{(e instanceof s.Api.Message&&Object(u.u)(e)||e instanceof s.Api.MessageService&&Object(u.v)(e))&&Object(p.a)(e)})}async function K({chat:e}){const t=await Object(r.g)(new s.Api.messages.Search({peer:Object(u.i)(e.id,e.accessHash),filter:new s.Api.InputMessagesFilterPinned,q:"",limit:a.t}));if(!t||t instanceof s.Api.messages.MessagesNotModified||!t.messages)return;z(t);return{messages:t.messages.map(o.b).filter(Boolean),users:t.users.map(c.a).filter(Boolean),chats:t.chats.map(e=>Object(l.d)(e)).filter(Boolean)}}}).call(this,n(11).Buffer)},function(e,t,n){"use strict";(function(e){var s=n(75),i=n(76),a=n(77);function r(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(r()=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return L(e).length;default:if(s)return F(e).length;t=(""+t).toLowerCase(),s=!0}}function h(e,t,n){var s=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return E(this,t,n);case"utf8":case"utf-8":return S(this,t,n);case"ascii":return M(this,t,n);case"latin1":case"binary":return k(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(s)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0}}function m(e,t,n){var s=e[t];e[t]=e[n],e[n]=s}function b(e,t,n,s,i){if(0===e.length)return-1;if("string"==typeof n?(s=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,s)),c.isBuffer(t))return 0===t.length?-1:y(e,t,n,s,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,s,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,s,i){var a,r=1,o=e.length,c=t.length;if(void 0!==s&&("ucs2"===(s=String(s).toLowerCase())||"ucs-2"===s||"utf16le"===s||"utf-16le"===s)){if(e.length<2||t.length<2)return-1;r=2,o/=2,c/=2,n/=2}function u(e,t){return 1===r?e[t]:e.readUInt16BE(t*r)}if(i){var d=-1;for(a=n;ao&&(n=o-c),a=n;a>=0;a--){for(var l=!0,f=0;fi&&(s=i):s=i;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");s>a/2&&(s=a/2);for(var r=0;r>8,i=n%256,a.push(i),a.push(s);return a}(t,e.length-n),e,n,s)}function C(e,t,n){return 0===t&&n===e.length?s.fromByteArray(e):s.fromByteArray(e.slice(t,n))}function S(e,t,n){n=Math.min(e.length,n);for(var s=[],i=t;i239?4:u>223?3:u>191?2:1;if(i+l<=n)switch(l){case 1:u<128&&(d=u);break;case 2:128==(192&(a=e[i+1]))&&(c=(31&u)<<6|63&a)>127&&(d=c);break;case 3:a=e[i+1],r=e[i+2],128==(192&a)&&128==(192&r)&&(c=(15&u)<<12|(63&a)<<6|63&r)>2047&&(c<55296||c>57343)&&(d=c);break;case 4:a=e[i+1],r=e[i+2],o=e[i+3],128==(192&a)&&128==(192&r)&&128==(192&o)&&(c=(15&u)<<18|(63&a)<<12|(63&r)<<6|63&o)>65535&&c<1114112&&(d=c)}null===d?(d=65533,l=1):d>65535&&(d-=65536,s.push(d>>>10&1023|55296),d=56320|1023&d),s.push(d),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",s=0;for(;s0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},c.prototype.compare=function(e,t,n,s,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===s&&(s=0),void 0===i&&(i=this.length),t<0||n>e.length||s<0||i>this.length)throw new RangeError("out of range index");if(s>=i&&t>=n)return 0;if(s>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var a=(i>>>=0)-(s>>>=0),r=(n>>>=0)-(t>>>=0),o=Math.min(a,r),u=this.slice(s,i),d=e.slice(t,n),l=0;li)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var a=!1;;)switch(s){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return v(this,e,t,n);case"latin1":case"binary":return A(this,e,t,n);case"base64":return I(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),a=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function M(e,t,n){var s="";n=Math.min(e.length,n);for(var i=t;is)&&(n=s);for(var i="",a=t;an)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,n,s,i,a){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function T(e,t,n,s){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-n,2);i>>8*(s?i:1-i)}function D(e,t,n,s){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-n,4);i>>8*(s?i:3-i)&255}function B(e,t,n,s,i,a){if(n+s>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function x(e,t,n,s,a){return a||B(e,0,n,4),i.write(e,t,n,s,23,4),n+4}function j(e,t,n,s,a){return a||B(e,0,n,8),i.write(e,t,n,s,52,8),n+8}c.prototype.slice=function(e,t){var n,s=this.length;if((e=~~e)<0?(e+=s)<0&&(e=0):e>s&&(e=s),(t=void 0===t?s:~~t)<0?(t+=s)<0&&(t=0):t>s&&(t=s),t0&&(i*=256);)s+=this[e+--t]*i;return s},c.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var s=this[e],i=1,a=0;++a=(i*=128)&&(s-=Math.pow(2,8*t)),s},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var s=t,i=1,a=this[e+--s];s>0&&(i*=256);)a+=this[e+--s]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},c.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,s){(e=+e,t|=0,n|=0,s)||U(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):T(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):T(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,s){if(e=+e,t|=0,!s){var i=Math.pow(2,8*n-1);U(this,e,t,n,i-1,-i)}var a=0,r=1,o=0;for(this[t]=255&e;++a>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,s){if(e=+e,t|=0,!s){var i=Math.pow(2,8*n-1);U(this,e,t,n,i-1,-i)}var a=n-1,r=1,o=0;for(this[t+a]=255&e;--a>=0&&(r*=256);)e<0&&0===o&&0!==this[t+a+1]&&(o=1),this[t+a]=(e/r>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):T(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):T(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return x(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return x(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,s){if(n||(n=0),s||0===s||(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s=this.length)throw new RangeError("sourceStart out of bounds");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t=0;--i)e[i+t]=this[i+n];else if(a<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(a=t;a55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(r+1===s){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function L(e){return s.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,n,s){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(45))},function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return a})),n.d(t,"c",(function(){return r}));var s=n(0);function i(e){const{about:t,commonChatsCount:n,pinnedMsgId:s,botInfo:i}=e;return{...a(e.user),fullInfo:{bio:t,commonChatsCount:n,pinnedMessageId:s,...i&&{botDescription:i.description}}}}function a(e){if(!(e instanceof s.Api.User))return;const{id:t,firstName:n,lastName:i}=e,a=e.photo instanceof s.Api.UserProfilePhoto?String(e.photo.photoId):void 0,o=function(e){if(e.bot)return"userTypeBot";if(e.deleted)return"userTypeDeleted";return"userTypeRegular"}(e);return{id:t,isMin:Boolean(e.min),...e.self&&{isSelf:!0},...e.verified&&{isVerified:!0},...(e.contact||e.mutualContact)&&{isContact:!0},type:o,...n&&{firstName:n},..."userTypeBot"===o&&{canBeInvitedToGroup:!e.botNochats},...i&&{lastName:i},username:e.username||"",phoneNumber:e.phone||"",status:r(e.status),...e.accessHash&&{accessHash:String(e.accessHash)},...a&&{avatarHash:a},...e.bot&&e.botInlinePlaceholder&&{botPlaceholder:e.botInlinePlaceholder}}}function r(e){return!e||e instanceof s.Api.UserStatusEmpty?{type:"userStatusEmpty"}:e instanceof s.Api.UserStatusOnline?{type:"userStatusOnline",expires:e.expires}:e instanceof s.Api.UserStatusOffline?{type:"userStatusOffline",wasOnline:e.wasOnline}:e instanceof s.Api.UserStatusRecently?{type:"userStatusRecently"}:e instanceof s.Api.UserStatusLastWeek?{type:"userStatusLastWeek"}:{type:"userStatusLastMonth"}}},function(e,t,n){"use strict";var s=n(65);n.o(s,"ApiMediaFormat")&&n.d(t,"ApiMediaFormat",(function(){return s.ApiMediaFormat})),n.o(s,"ApiMessageEntityTypes")&&n.d(t,"ApiMessageEntityTypes",(function(){return s.ApiMessageEntityTypes})),n.o(s,"MAIN_THREAD_ID")&&n.d(t,"MAIN_THREAD_ID",(function(){return s.MAIN_THREAD_ID})),n.o(s,"MESSAGE_DELETED")&&n.d(t,"MESSAGE_DELETED",(function(){return s.MESSAGE_DELETED}));var i=n(66);n.o(i,"ApiMediaFormat")&&n.d(t,"ApiMediaFormat",(function(){return i.ApiMediaFormat})),n.o(i,"ApiMessageEntityTypes")&&n.d(t,"ApiMessageEntityTypes",(function(){return i.ApiMessageEntityTypes})),n.o(i,"MAIN_THREAD_ID")&&n.d(t,"MAIN_THREAD_ID",(function(){return i.MAIN_THREAD_ID})),n.o(i,"MESSAGE_DELETED")&&n.d(t,"MESSAGE_DELETED",(function(){return i.MESSAGE_DELETED}));var a=n(67);n.d(t,"ApiMessageEntityTypes",(function(){return a.a})),n.d(t,"MAIN_THREAD_ID",(function(){return a.b})),n.d(t,"MESSAGE_DELETED",(function(){return a.c}));var r=n(68);n.o(r,"ApiMediaFormat")&&n.d(t,"ApiMediaFormat",(function(){return r.ApiMediaFormat}));var o=n(69);n.d(t,"ApiMediaFormat",(function(){return o.a}));n(70),n(71),n(72),n(73)},function(e,t,n){"use strict";function s(e,t){return e.reduce((e,n)=>(e[n[t]]=n,e),{})}function i(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function a(e,t){return t.reduce((t,n)=>(e[n]&&(t[n]=e[n]),t),{})}n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return a}))},function(e,t,n){(function(e){var s,i=function(e){"use strict";var t=1e7,n=9007199254740992,s=l(n),a="function"==typeof BigInt;function r(e,t,n,s){return void 0===e?r[0]:void 0!==t&&(10!=+t||n)?F(e,t,n,s):z(e)}function o(e,t){this.value=e,this.sign=t,this.isSmall=!1}function c(e){this.value=e,this.sign=e<0,this.isSmall=!0}function u(e){this.value=e}function d(e){return-n0?Math.floor(e):Math.ceil(e)}function m(e,n){var s,i,a=e.length,r=n.length,o=new Array(a),c=0,u=t;for(i=0;i=u?1:0,o[i]=s-c*u;for(;i0&&o.push(c),o}function b(e,t){return e.length>=t.length?m(e,t):m(t,e)}function y(e,n){var s,i,a=e.length,r=new Array(a),o=t;for(i=0;i0;)r[i++]=n%o,n=Math.floor(n/o);return r}function _(e,t){var n,s,i=e.length,a=t.length,r=new Array(i),o=0;for(n=0;n0;)r[i++]=c%o,c=Math.floor(c/o);return r}function I(e,t){for(var n=[];t-- >0;)n.push(0);return n.concat(e)}function P(e,n,s){return new o(e=0;--n)i=(a=1e7*i+e[n])-(s=h(a/t))*t,o[n]=0|s;return[o,0|i]}function M(e,n){var s,i=z(n);if(a)return[new u(e.value/i.value),new u(e.value%i.value)];var d,m=e.value,b=i.value;if(0===b)throw new Error("Cannot divide by zero");if(e.isSmall)return i.isSmall?[new c(h(m/b)),new c(m%b)]:[r[0],e];if(i.isSmall){if(1===b)return[e,r[0]];if(-1==b)return[e.negate(),r[0]];var y=Math.abs(b);if(y=0;i--){for(s=p-1,y[i+l]!==m&&(s=Math.floor((y[i+l]*p+y[i+l-1])/m)),a=0,r=0,c=_.length,o=0;oc&&(i=1e7*(i+1)),n=Math.ceil(i/a);do{if(k(r=A(t,n),d)<=0)break;n--}while(n);u.push(n),d=_(d,r)}return u.reverse(),[f(u),f(d)]}(m,b))[0];var I=e.sign!==i.sign,P=s[1],C=e.sign;return"number"==typeof d?(I&&(d=-d),d=new c(d)):d=new o(d,I),"number"==typeof P?(C&&(P=-P),P=new c(P)):P=new o(P,C),[d,P]}function k(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}function E(e){var t=e.abs();return!t.isUnit()&&(!!(t.equals(2)||t.equals(3)||t.equals(5))||!(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))&&(!!t.lesser(49)||void 0))}function O(e,t){for(var n,s,a,r=e.prev(),o=r,c=0;o.isEven();)o=o.divide(2),c++;e:for(s=0;s=0?s=_(e,t):(s=_(t,e),n=!n),"number"==typeof(s=f(s))?(n&&(s=-s),new c(s)):new o(s,n)}(n,s,this.sign)},o.prototype.minus=o.prototype.subtract,c.prototype.subtract=function(e){var t=z(e),n=this.value;if(n<0!==t.sign)return this.add(t.negate());var s=t.value;return t.isSmall?new c(n-s):w(s,Math.abs(n),n>=0)},c.prototype.minus=c.prototype.subtract,u.prototype.subtract=function(e){return new u(this.value-z(e).value)},u.prototype.minus=u.prototype.subtract,o.prototype.negate=function(){return new o(this.value,!this.sign)},c.prototype.negate=function(){var e=this.sign,t=new c(-this.value);return t.sign=!e,t},u.prototype.negate=function(){return new u(-this.value)},o.prototype.abs=function(){return new o(this.value,!1)},c.prototype.abs=function(){return new c(Math.abs(this.value))},u.prototype.abs=function(){return new u(this.value>=0?this.value:-this.value)},o.prototype.multiply=function(e){var n,s,i,a=z(e),c=this.value,u=a.value,d=this.sign!==a.sign;if(a.isSmall){if(0===u)return r[0];if(1===u)return this;if(-1===u)return this.negate();if((n=Math.abs(u))0?function e(t,n){var s=Math.max(t.length,n.length);if(s<=30)return v(t,n);s=Math.ceil(s/2);var i=t.slice(s),a=t.slice(0,s),r=n.slice(s),o=n.slice(0,s),c=e(a,o),u=e(i,r),d=e(b(a,i),b(o,r)),l=b(b(c,I(_(_(d,c),u),s)),I(u,2*s));return p(l),l}(c,u):v(c,u),d)},o.prototype.times=o.prototype.multiply,c.prototype._multiplyBySmall=function(e){return d(e.value*this.value)?new c(e.value*this.value):P(Math.abs(e.value),l(Math.abs(this.value)),this.sign!==e.sign)},o.prototype._multiplyBySmall=function(e){return 0===e.value?r[0]:1===e.value?this:-1===e.value?this.negate():P(Math.abs(e.value),this.value,this.sign!==e.sign)},c.prototype.multiply=function(e){return z(e)._multiplyBySmall(this)},c.prototype.times=c.prototype.multiply,u.prototype.multiply=function(e){return new u(this.value*z(e).value)},u.prototype.times=u.prototype.multiply,o.prototype.square=function(){return new o(C(this.value),!1)},c.prototype.square=function(){var e=this.value*this.value;return d(e)?new c(e):new o(C(l(Math.abs(this.value))),!1)},u.prototype.square=function(e){return new u(this.value*this.value)},o.prototype.divmod=function(e){var t=M(this,e);return{quotient:t[0],remainder:t[1]}},u.prototype.divmod=c.prototype.divmod=o.prototype.divmod,o.prototype.divide=function(e){return M(this,e)[0]},u.prototype.over=u.prototype.divide=function(e){return new u(this.value/z(e).value)},c.prototype.over=c.prototype.divide=o.prototype.over=o.prototype.divide,o.prototype.mod=function(e){return M(this,e)[1]},u.prototype.mod=u.prototype.remainder=function(e){return new u(this.value%z(e).value)},c.prototype.remainder=c.prototype.mod=o.prototype.remainder=o.prototype.mod,o.prototype.pow=function(e){var t,n,s,i=z(e),a=this.value,o=i.value;if(0===o)return r[1];if(0===a)return r[0];if(1===a)return r[1];if(-1===a)return i.isEven()?r[1]:r[-1];if(i.sign)return r[0];if(!i.isSmall)throw new Error("The exponent "+i.toString()+" is too large.");if(this.isSmall&&d(t=Math.pow(a,o)))return new c(h(t));for(n=this,s=r[1];!0&o&&(s=s.times(n),--o),0!==o;)o/=2,n=n.square();return s},c.prototype.pow=o.prototype.pow,u.prototype.pow=function(e){var t=z(e),n=this.value,s=t.value,i=BigInt(0),a=BigInt(1),o=BigInt(2);if(s===i)return r[1];if(n===i)return r[0];if(n===a)return r[1];if(n===BigInt(-1))return t.isEven()?r[1]:r[-1];if(t.isNegative())return new u(i);for(var c=this,d=r[1];(s&a)===a&&(d=d.times(c),--s),s!==i;)s/=o,c=c.square();return d},o.prototype.modPow=function(e,t){if(e=z(e),(t=z(t)).isZero())throw new Error("Cannot take modPow with modulus 0");var n=r[1],s=this.mod(t);for(e.isNegative()&&(e=e.multiply(r[-1]),s=s.modInv(t));e.isPositive();){if(s.isZero())return r[0];e.isOdd()&&(n=n.multiply(s).mod(t)),e=e.divide(2),s=s.square().mod(t)}return n},u.prototype.modPow=c.prototype.modPow=o.prototype.modPow,o.prototype.compareAbs=function(e){var t=z(e),n=this.value,s=t.value;return t.isSmall?1:k(n,s)},c.prototype.compareAbs=function(e){var t=z(e),n=Math.abs(this.value),s=t.value;return t.isSmall?n===(s=Math.abs(s))?0:n>s?1:-1:-1},u.prototype.compareAbs=function(e){var t=this.value,n=z(e).value;return(t=t>=0?t:-t)===(n=n>=0?n:-n)?0:t>n?1:-1},o.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=z(e),n=this.value,s=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:k(n,s)*(this.sign?-1:1)},o.prototype.compareTo=o.prototype.compare,c.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=z(e),n=this.value,s=t.value;return t.isSmall?n==s?0:n>s?1:-1:n<0!==t.sign?n<0?-1:1:n<0?1:-1},c.prototype.compareTo=c.prototype.compare,u.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=this.value,n=z(e).value;return t===n?0:t>n?1:-1},u.prototype.compareTo=u.prototype.compare,o.prototype.equals=function(e){return 0===this.compare(e)},u.prototype.eq=u.prototype.equals=c.prototype.eq=c.prototype.equals=o.prototype.eq=o.prototype.equals,o.prototype.notEquals=function(e){return 0!==this.compare(e)},u.prototype.neq=u.prototype.notEquals=c.prototype.neq=c.prototype.notEquals=o.prototype.neq=o.prototype.notEquals,o.prototype.greater=function(e){return this.compare(e)>0},u.prototype.gt=u.prototype.greater=c.prototype.gt=c.prototype.greater=o.prototype.gt=o.prototype.greater,o.prototype.lesser=function(e){return this.compare(e)<0},u.prototype.lt=u.prototype.lesser=c.prototype.lt=c.prototype.lesser=o.prototype.lt=o.prototype.lesser,o.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},u.prototype.geq=u.prototype.greaterOrEquals=c.prototype.geq=c.prototype.greaterOrEquals=o.prototype.geq=o.prototype.greaterOrEquals,o.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},u.prototype.leq=u.prototype.lesserOrEquals=c.prototype.leq=c.prototype.lesserOrEquals=o.prototype.leq=o.prototype.lesserOrEquals,o.prototype.isEven=function(){return 0==(1&this.value[0])},c.prototype.isEven=function(){return 0==(1&this.value)},u.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},o.prototype.isOdd=function(){return 1==(1&this.value[0])},c.prototype.isOdd=function(){return 1==(1&this.value)},u.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},o.prototype.isPositive=function(){return!this.sign},c.prototype.isPositive=function(){return this.value>0},u.prototype.isPositive=c.prototype.isPositive,o.prototype.isNegative=function(){return this.sign},c.prototype.isNegative=function(){return this.value<0},u.prototype.isNegative=c.prototype.isNegative,o.prototype.isUnit=function(){return!1},c.prototype.isUnit=function(){return 1===Math.abs(this.value)},u.prototype.isUnit=function(){return this.abs().value===BigInt(1)},o.prototype.isZero=function(){return!1},c.prototype.isZero=function(){return 0===this.value},u.prototype.isZero=function(){return this.value===BigInt(0)},o.prototype.isDivisibleBy=function(e){var t=z(e);return!t.isZero()&&(!!t.isUnit()||(0===t.compareAbs(2)?this.isEven():this.mod(t).isZero()))},u.prototype.isDivisibleBy=c.prototype.isDivisibleBy=o.prototype.isDivisibleBy,o.prototype.isPrime=function(e){var t=E(this);if(void 0!==t)return t;var n=this.abs(),s=n.bitLength();if(s<=64)return O(n,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var a=Math.log(2)*s.toJSNumber(),r=Math.ceil(!0===e?2*Math.pow(a,2):a),o=[],c=0;c-n?new c(e-1):new o(s,!0)},u.prototype.prev=function(){return new u(this.value-BigInt(1))};for(var R=[1];2*R[R.length-1]<=t;)R.push(2*R[R.length-1]);var U=R.length,T=R[U-1];function D(e){return Math.abs(e)<=t}function B(e,t,n){t=z(t);for(var s=e.isNegative(),a=t.isNegative(),r=s?e.not():e,o=a?t.not():t,c=0,u=0,d=null,l=null,f=[];!r.isZero()||!o.isZero();)c=(d=M(r,T))[1].toJSNumber(),s&&(c=T-1-c),u=(l=M(o,T))[1].toJSNumber(),a&&(u=T-1-u),r=d[0],o=l[0],f.push(n(c,u));for(var p=0!==n(s?1:0,a?1:0)?i(-1):i(0),g=f.length-1;g>=0;g-=1)p=p.multiply(T).add(i(f[g]));return p}o.prototype.shiftLeft=function(e){var t=z(e).toJSNumber();if(!D(t))throw new Error(String(t)+" is too large for shifting.");if(t<0)return this.shiftRight(-t);var n=this;if(n.isZero())return n;for(;t>=U;)n=n.multiply(T),t-=U-1;return n.multiply(R[t])},u.prototype.shiftLeft=function(e){return e=z(e),new u(this.value<=U;){if(s.isZero()||s.isNegative()&&s.isUnit())return s;s=(t=M(s,T))[1].isNegative()?t[0].prev():t[0],n-=U-1}return(t=M(s,R[n]))[1].isNegative()?t[0].prev():t[0]},u.prototype.shiftRight=function(e){return e=z(e),new u(this.value>>e.value)},c.prototype.shiftRight=o.prototype.shiftRight,o.prototype.not=function(){return this.negate().prev()},u.prototype.not=c.prototype.not=o.prototype.not,o.prototype.and=function(e){return B(this,e,(function(e,t){return e&t}))},u.prototype.and=c.prototype.and=o.prototype.and,o.prototype.or=function(e){return B(this,e,(function(e,t){return e|t}))},u.prototype.or=c.prototype.or=o.prototype.or,o.prototype.xor=function(e){return B(this,e,(function(e,t){return e^t}))},u.prototype.xor=c.prototype.xor=o.prototype.xor;function x(e){var n=e.value,s="number"==typeof n?n|1<<30:"bigint"==typeof n?n|BigInt(1<<30):n[0]+n[1]*t|1073758208;return s&-s}function j(e,t){return e=z(e),t=z(t),e.greater(t)?e:t}function N(e,t){return e=z(e),t=z(t),e.lesser(t)?e:t}function V(e,t){if(e=z(e).abs(),t=z(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var n,s,i=r[1];e.isEven()&&t.isEven();)n=N(x(e),x(t)),e=e.divide(n),t=t.divide(n),i=i.multiply(n);for(;e.isEven();)e=e.divide(x(e));do{for(;t.isEven();)t=t.divide(x(t));e.greater(t)&&(s=t,t=e,e=s),t=t.subtract(e)}while(!t.isZero());return i.isUnit()?e:e.multiply(i)}o.prototype.bitLength=function(){var e=this;return e.compareTo(i(0))<0&&(e=e.negate().subtract(i(1))),0===e.compareTo(i(0))?i(0):i(function e(t,n){if(n.compareTo(t)<=0){var s=e(t,n.square(n)),a=s.p,r=s.e,o=a.multiply(n);return o.compareTo(t)<=0?{p:o,e:2*r+1}:{p:a,e:2*r}}return{p:i(1),e:0}}(e,i(2)).e).add(i(1))},u.prototype.bitLength=c.prototype.bitLength=o.prototype.bitLength;var F=function(e,t,n,s){n=n||"0123456789abcdefghijklmnopqrstuvwxyz",e=String(e),s||(e=e.toLowerCase(),n=n.toLowerCase());var i,a=e.length,r=Math.abs(t),o={};for(i=0;i=r)){if("1"===d&&1===r)continue;throw new Error(d+" is not a valid digit in base "+t+".")}}t=z(t);var c=[],u="-"===e[0];for(i=u?1:0;i"!==e[i]&&i=0;s--)i=i.add(e[s].times(a)),a=a.times(t);return n?i.negate():i}function q(e,t){if((t=i(t)).isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var n=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return n.unshift([1]),{value:[].concat.apply([],n),isNegative:!1}}var s=!1;if(e.isNegative()&&t.isPositive()&&(s=!0,e=e.abs()),t.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:s};for(var a,r=[],o=e;o.isNegative()||o.compareAbs(t)>=0;){a=o.divmod(t),o=a.quotient;var c=a.remainder;c.isNegative()&&(c=t.minus(c).abs(),o=o.next()),r.push(c.toJSNumber())}return r.push(o.toJSNumber()),{value:r.reverse(),isNegative:s}}function H(e,t,n){var s=q(e,t);return(s.isNegative?"-":"")+s.value.map((function(e){return function(e,t){return e<(t=t||"0123456789abcdefghijklmnopqrstuvwxyz").length?t[e]:"<"+e+">"}(e,n)})).join("")}function G(e){if(d(+e)){var t=+e;if(t===h(t))return a?new u(BigInt(t)):new c(t);throw new Error("Invalid integer: "+e)}var n="-"===e[0];n&&(e=e.slice(1));var s=e.split(/e/i);if(s.length>2)throw new Error("Invalid integer: "+s.join("e"));if(2===s.length){var i=s[1];if("+"===i[0]&&(i=i.slice(1)),(i=+i)!==h(i)||!d(i))throw new Error("Invalid integer: "+i+" is not a valid exponent.");var r=s[0],l=r.indexOf(".");if(l>=0&&(i-=r.length-l-1,r=r.slice(0,l)+r.slice(l+1)),i<0)throw new Error("Cannot include negative exponent part for integers");e=r+=new Array(i+1).join("0")}if(!/^([0-9][0-9]*)$/.test(e))throw new Error("Invalid integer: "+e);if(a)return new u(BigInt(n?"-"+e:e));for(var f=[],g=e.length,m=g-7;g>0;)f.push(+e.slice(m,g)),(m-=7)<0&&(m=0),g-=7;return p(f),new o(f,n)}function z(e){return"number"==typeof e?function(e){if(a)return new u(BigInt(e));if(d(e)){if(e!==h(e))throw new Error(e+" is not an integer.");return new c(e)}return G(e.toString())}(e):"string"==typeof e?G(e):"bigint"==typeof e?new u(e):e}o.prototype.toArray=function(e){return q(this,e)},c.prototype.toArray=function(e){return q(this,e)},u.prototype.toArray=function(e){return q(this,e)},o.prototype.toString=function(e,t){if(void 0===e&&(e=10),10!==e)return H(this,e,t);for(var n,s=this.value,i=s.length,a=String(s[--i]);--i>=0;)n=String(s[i]),a+="0000000".slice(n.length)+n;return(this.sign?"-":"")+a},c.prototype.toString=function(e,t){return void 0===e&&(e=10),10!=e?H(this,e,t):String(this.value)},u.prototype.toString=c.prototype.toString,u.prototype.toJSON=o.prototype.toJSON=c.prototype.toJSON=function(){return this.toString()},o.prototype.valueOf=function(){return parseInt(this.toString(),10)},o.prototype.toJSNumber=o.prototype.valueOf,c.prototype.valueOf=function(){return this.value},c.prototype.toJSNumber=c.prototype.valueOf,u.prototype.valueOf=u.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};for(var K=0;K<1e3;K++)r[K]=z(K),K>0&&(r[-K]=z(-K));return r.one=r[1],r.zero=r[0],r.minusOne=r[-1],r.max=j,r.min=N,r.gcd=V,r.lcm=function(e,t){return e=z(e).abs(),t=z(t).abs(),e.divide(V(e,t)).multiply(t)},r.isInstance=function(e){return e instanceof o||e instanceof c||e instanceof u},r.randBetween=function(e,n,s){e=z(e),n=z(n);var i=s||Math.random,a=N(e,n),o=j(e,n).subtract(a).add(1);if(o.isSmall)return a.add(Math.floor(i()*o));for(var c=q(o,t).value,u=[],d=!0,l=0;l{r.resolve=e,r.reject=t})}function d(e=!1){return o({...b("authorizationStateWaitCode"),isCodeViaApp:e}),new Promise((e,t)=>{r.resolve=e,r.reject=t})}function l(e){return o({...b("authorizationStateWaitPassword"),hint:e}),new Promise(e=>{r.resolve=e})}function f(){return o(b("authorizationStateWaitRegistration")),new Promise(e=>{r.resolve=e})}function p(e){return o({...b("authorizationStateWaitQrCode"),qrCode:{token:btoa(String.fromCharCode(...e.token)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),expires:e.expires}}),new Promise((e,t)=>{r.reject=t})}function g(e){let t;if(e instanceof s.errors.FloodWaitError){const n=Math.ceil(Number(e.seconds)/60/60);t="Too many attempts. Try again in "+(n>1?n+" hours":"an hour")}else t=a[e.message];t||(t="Unexpected Error",i.g&&console.error(e)),o({"@type":"updateAuthorizationError",message:t})}function h(){o(b("authorizationStateReady"))}function m(e){o({"@type":"updateCurrentUser",currentUser:e})}function b(e){return{"@type":"updateAuthorizationState",authorizationState:e}}function y(e){r.resolve&&r.resolve(e)}function _(e){r.resolve&&r.resolve(e)}function w(e){r.resolve&&r.resolve(e)}function v(e){const{firstName:t,lastName:n}=e;r.resolve&&r.resolve([t,n])}function A(){r.reject&&r.reject(new Error("RESTART_AUTH"))}function I(){r.reject&&r.reject(new Error("RESTART_AUTH_WITH_QR"))}},function(e,t,n){"use strict";n.d(t,"d",(function(){return c})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return d})),n.d(t,"a",(function(){return l}));var s=n(0),i=n(21),a=n(20);function r(e,t,n){return''.replace("{{path}}",function(e){let t="M";const n=e.length;for(let s=0;s=192?t+="AACAAAAHAAALMAAAQASTAVAAAZaacaaaahaaalmaaaqastava.az0123456789-,"[n-128-64]:(n>=128?t+=",":n>=64&&(t+="-"),t+=String(63&n))}return t+="z",t}(e)).replace("{{width}}",String(t)).replace("{{height}}",String(n))}const o={w:100,h:100};function c(e,t){if(!e||!e.length)return;const n=e.find(e=>e instanceof s.Api.PhotoStrippedSize);if(!n)return;const r=e.filter(e=>e instanceof s.Api.PhotoSize),{w:c,h:u}=r&&r.length?r[r.length-1]:o,{bytes:d}=n;return{dataUri:Object(a.a)(t&&"image/jpeg"!==t?d:Object(i.strippedPhotoToJpg)(d),void 0,t),width:c,height:u}}function u(e){const{w:t,h:n,bytes:s}=e;return{dataUri:Object(a.a)(s,void 0,"image/webp"),width:t,height:n}}function d(e,t){const{w:n,h:s}=t;return{dataUri:"data:image/svg+xml;utf8,"+r(e.bytes,n,s),width:n,height:s}}function l(e){const t=e.sizes.filter(e=>e instanceof s.Api.PhotoSize||e instanceof s.Api.PhotoSizeProgressive).map(f);return{id:String(e.id),thumbnail:c(e.sizes),sizes:t}}function f(e){const{w:t,h:n,type:s}=e;return{width:t,height:n,type:s}}},function(e,t,n){"use strict";function s(e,t=!1,n="image/jpeg"){return`${t?"":`data:${n};base64,`}${btoa(String.fromCharCode(...e))}`}function i(e){if(!e)return;const{flags:t,CONSTRUCTOR_ID:n,SUBCLASS_OF_ID:s,className:i,classType:a,...r}=e;return r}n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return i}))},function(e,t,n){(function(t){const{constructors:s}=n(24),i=t.from("ffd8ffe000104a46494600010100000100010000ffdb004300281c1e231e19282321232d2b28303c64413c37373c7b585d4964918099968f808c8aa0b4e6c3a0aadaad8a8cc8ffcbdaeef5ffffff9bc1fffffffaffe6fdfff8ffdb0043012b2d2d3c353c76414176f8a58ca5f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8ffc00011080000000003012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00","hex"),a=t.from("ffd9","hex");function r(e,t){throw new Error(`Cannot cast ${e.className} to any kind of ${t}`)}e.exports={getMessageId:function(e){if(void 0!==e){if("number"==typeof e)return e;if(2030045667===e.SUBCLASS_OF_ID)return e.id;throw new Error("Invalid message type: "+e.constructor.name)}},getInputPeer:function e(t,n=!0,i=!0){if(void 0===t.SUBCLASS_OF_ID){if(n&&"inputEntity"in t)return t.inputEntity;if("entity"in t)return e(t.entity);r(t,"InputPeer")}if(3374092470===t.SUBCLASS_OF_ID)return t;if(t instanceof s.User){if(t.isSelf&&n)return new s.InputPeerSelf;if(void 0===t.accessHash&&i)throw new Error("User without accessHash or min info cannot be input");return new s.InputPeerUser({userId:t.id,accessHash:t.accessHash})}if(t instanceof s.Chat||t instanceof s.ChatEmpty||t instanceof s.ChatForbidden)return new s.InputPeerChat({chatId:t.id});if(t instanceof s.Channel){if(void 0===t.accessHash&&i)throw new TypeError("Channel without accessHash or min info cannot be input");return new s.InputPeerChannel({channelId:t.id,accessHash:t.accessHash})}return t instanceof s.ChannelForbidden?new s.InputPeerChannel({channelId:t.id,accessHash:t.accessHash}):t instanceof s.InputUser?new s.InputPeerUser({userId:t.userId,accessHash:t.accessHash}):t instanceof s.InputChannel?new s.InputPeerChannel({channelId:t.channelId,accessHash:t.accessHash}):t instanceof s.UserEmpty?new s.InputPeerEmpty:t instanceof s.UserFull?e(t.user):t instanceof s.ChatFull?new s.InputPeerChat({chatId:t.id}):t instanceof s.PeerChat?new s.InputPeerChat(t.chatId):void r(t,"InputPeer")},getDisplayName:function(e){return e instanceof s.User?e.lastName&&e.firstName?`${e.firstName} ${e.lastName}`:e.firstName?e.firstName:e.lastName?e.lastName:"":e instanceof s.Chat||e instanceof s.Channel?e.title:""},getAppropriatedPartSize:function(e){if(e<=104857600)return 128;if(e<=786432e3)return 256;if(e<=1572864e3)return 512;throw new Error("File size too large")},strippedPhotoToJpg:function(e){if(e.length<3||1!==e[0])return e;const n=t.from(i);return n[164]=e[1],n[166]=e[2],t.concat([n,e.slice(3),a])},getDC:function(e){switch(e){case 1:return{id:1,ipAddress:"zws1.web.telegram.org",port:443};case 2:return{id:2,ipAddress:"zws2.web.telegram.org",port:443};case 3:return{id:3,ipAddress:"zws3.web.telegram.org",port:443};case 4:return{id:4,ipAddress:"zws4.web.telegram.org",port:443};case 5:return{id:5,ipAddress:"zws5.web.telegram.org",port:443};default:throw new Error("Cannot find the DC with the ID of "+e)}}}}).call(this,n(11).Buffer)},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return c})),n.d(t,"c",(function(){return u}));var s=n(0),i=n(4),a=n(19),r=n(5);function o(e){if(e instanceof s.Api.DocumentEmpty)return;const t=e.attributes.find(e=>e instanceof s.Api.DocumentAttributeSticker),n="application/x-tgsticker"===e.mimeType&&e.attributes.find(e=>e instanceof s.Api.DocumentAttributeFilename);if(!t&&!n)return;const r=e.attributes.find(e=>e instanceof s.Api.DocumentAttributeImageSize),o=t&&t.stickerset instanceof s.Api.InputStickerSetID?t.stickerset:void 0,c=t?t.alt:void 0,u="application/x-tgsticker"===e.mimeType,d=e.thumbs&&e.thumbs.find(e=>e instanceof s.Api.PhotoCachedSize),l=e.thumbs&&e.thumbs.find(e=>e instanceof s.Api.PhotoPathSize),f=d?Object(a.b)(d):l&&r?Object(a.c)(l,r):void 0,{w:p,h:g}=d||r||{};return{id:String(e.id),stickerSetId:o?String(o.id):i.s,stickerSetAccessHash:o&&String(o.accessHash),emoji:c,isAnimated:u,width:p,height:g,thumbnail:f}}function c(e){const{archived:t,animated:n,installedDate:s,id:i,accessHash:a,title:r,thumbs:o,count:c,hash:u}=e;return{archived:t,isAnimated:n,installedDate:s,id:String(i),accessHash:String(a),title:r,hasThumbnail:Boolean(o&&o.length),count:c,hash:u}}function u(e){const t=c(e.set),n=e instanceof s.Api.StickerSetMultiCovered?e.covers:[e.cover];return t.covers=[],n.forEach(e=>{if(e instanceof s.Api.Document){const n=o(e);n&&(t.covers.push(n),r.a.documents[String(e.id)]=e)}}),t}},function(e,t,n){"use strict";n.d(t,"c",(function(){return o})),n.d(t,"b",(function(){return c})),n.d(t,"d",(function(){return u})),n.d(t,"e",(function(){return d})),n.d(t,"a",(function(){return l}));var s=n(0),i=n(9),a=n(3),r=n(14);function o(e){if(e instanceof s.Api.WallPaperNoFile)return;const{slug:t}=e,n=Object(i.a)(e.document);return n?{slug:t,document:n}:void 0}function c(e){return{isCurrent:Boolean(e.current),isOfficialApp:Boolean(e.officialApp),isPasswordPending:Boolean(e.passwordPending),hash:String(e.hash),...Object(r.b)(e,["deviceModel","platform","systemVersion","appName","appVersion","dateCreated","dateActive","ip","country","region"])}}function u(e){switch(e.className){case"PrivacyKeyPhoneNumber":return"phoneNumber";case"PrivacyKeyStatusTimestamp":return"lastSeen";case"PrivacyKeyProfilePhoto":return"profilePhoto";case"PrivacyKeyForwards":return"forwards";case"PrivacyKeyChatInvite":return"chatInvite"}}function d(e){let t,n,i,a,r;return e.forEach(e=>{e instanceof s.Api.PrivacyValueAllowAll?t=t||"everybody":e instanceof s.Api.PrivacyValueAllowContacts?t=t||"contacts":e instanceof s.Api.PrivacyValueDisallowContacts?t=t||"nonContacts":e instanceof s.Api.PrivacyValueDisallowAll?t=t||"nobody":e instanceof s.Api.PrivacyValueAllowUsers?n=e.users:e instanceof s.Api.PrivacyValueDisallowUsers?a=e.users:e instanceof s.Api.PrivacyValueAllowChatParticipants?i=e.chats.map(e=>-e):e instanceof s.Api.PrivacyValueDisallowChatParticipants&&(r=e.chats.map(e=>-e))}),t||(t="nobody"),{visibility:t,allowUserIds:n||[],allowChatIds:i||[],blockUserIds:a||[],blockChatIds:r||[]}}function l(e,t,n){const{silent:s,muteUntil:i,showPreviews:r,sound:o}=e;return{chatId:Object(a.j)(t),isMuted:s||"number"==typeof i&&Date.now()+1e3*n<1e3*i,...""===o&&{isSilent:!0},...void 0!==r&&{shouldShowPreviews:Boolean(r)}}}},function(e,t,n){const s=n(6),{serializeBytes:i,serializeDate:a}=n(46);e.exports={constructors:s,requests:s,serializeBytes:i,serializeDate:a}},function(e,t){class n extends Error{constructor(){super("The read operation was cancelled.")}}class s extends Error{constructor(e,t){super(`Could not find a matching Constructor ID for the TLObject that was supposed to be\n read with ID ${e}. Most likely, a TLObject was trying to be read when\n it should not be read. Remaining bytes: ${t.length}`),"undefined"!=typeof alert&&alert("Missing MTProto Entity: Please, make sure to add TL definition for ID "+e),this.invalidConstructorId=e,this.remaining=t}}class i extends Error{constructor(e,t){super(`Invalid checksum (${e} when ${t} was expected). This packet should be skipped.`),this.checksum=e,this.validChecksum=t}}class a extends Error{constructor(e){let t;4===e.length?(t=-e.readInt32LE(0),super(`Invalid response buffer (HTTP code ${t})`)):super(`Invalid response buffer (too short ${e})`),this.code=t,this.payload=e}}class r extends Error{constructor(...e){e.length||(e=["A security check failed."]),super(...e)}}class o extends Error{constructor(e,t){let n=o.ErrorMessages[t]||`Unknown error code (this should not happen): ${t}.`;n+=" Caused by "+e.className,super(n),this.message=n,this.code=t}}var c,u,d;d={16:"msg_id too low (most likely, client time is wrong it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted).",17:"msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id).",18:"Incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4).",19:"Container msg_id is the same as msg_id of a previously received message (this must never happen).",20:"Message too old, and it cannot be verified whether the server has received a message with this msg_id or not.",32:"msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno).",33:"msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno).",34:"An even msg_seqno expected (irrelevant message), but odd received.",35:"Odd msg_seqno expected (relevant message), but even received.",48:"Incorrect server salt (in this case, the bad_server_salt response is received with the correct salt, and the message is to be re-sent with it).",64:"Invalid container."},(u="ErrorMessages")in(c=o)?Object.defineProperty(c,u,{value:d,enumerable:!0,configurable:!0,writable:!0}):c[u]=d,e.exports={ReadCancelledError:n,TypeNotFoundError:s,InvalidChecksumError:i,InvalidBufferError:a,SecurityError:r,CdnFileTamperedError:class extends r{constructor(){super("The CDN file has been altered and its download cancelled.")}},BadMessageError:o}},function(e,t,n){const{TypeNotFoundError:s}=n(25),{coreObjects:i}=n(56),{tlobjects:a}=n(51),{readBigIntFromBuffer:r}=n(8);e.exports=class{constructor(e){this.stream=e,this._last=void 0,this.offset=0}readByte(){return this.read(1)[0]}readInt(e=!0){let t;return t=e?this.stream.readInt32LE(this.offset):this.stream.readUInt32LE(this.offset),this.offset+=4,t}readLong(e=!0){return this.readLargeInt(64,e)}readFloat(){return this.read(4).readFloatLE(0)}readDouble(){return this.read(8).readDoubleLE(0)}readLargeInt(e,t=!0){const n=this.read(Math.floor(e/8));return r(n,!0,t)}read(e=-1){-1===e&&(e=this.stream.length-this.offset);const t=this.stream.slice(this.offset,this.offset+e);if(this.offset+=e,t.length!==e)throw Error(`No more data left to read (need ${e}, got ${t.length}: ${t}); last read ${this._last}`);return this._last=t,t}getBuffer(){return this.stream}tgReadBytes(){const e=this.readByte();let t,n;254===e?(n=this.readByte()|this.readByte()<<8|this.readByte()<<16,t=n%4):(n=e,t=(n+1)%4);const s=this.read(n);return t>0&&(t=4-t,this.read(t)),s}tgReadString(){return this.tgReadBytes().toString("utf-8")}tgReadBool(){const e=this.readInt(!1);if(2574415285===e)return!0;if(3162085175===e)return!1;throw new Error("Invalid boolean code "+e.toString("16"))}tgReadDate(){const e=this.readInt();return new Date(1e3*e)}tgReadObject(){const e=this.readInt(!1);let t=a[e];if(void 0===t){if(2574415285===e)return!0;if(3162085175===e)return!1;if(481674261===e){const e=[],t=this.readInt();for(let n=0;ne);return{hash:Object(c.r)(s),ids:s,users:n}}async function h({username:e}){const t=await Object(o.g)(new a.Api.contacts.ResolveUsername({username:e}));if(t&&t.users[0]instanceof a.Api.User&&t.users[0].bot&&t.users[0].botInlinePlaceholder)return y(t.users[0]),{user:Object(u.a)(t.users[0]),chat:Object(l.d)(t.users[0])}}async function m({bot:e,chat:t,query:n,offset:s=""}){const i=await Object(o.g)(new a.Api.messages.GetInlineBotResults({bot:Object(c.i)(e.id,e.accessHash),peer:Object(c.i)(t.id,t.accessHash),query:n,offset:s}));var l,p,g;if(i)return i.users.map(y),{isGallery:Boolean(i.gallery),help:e.botPlaceholder,nextOffset:i.nextOffset,switchPm:(g=i.switchPm,g?Object(f.b)(g,["text","startParam"]):void 0),users:i.users.map(u.a).filter(Boolean),results:(l=String(i.queryId),p=i.results,p.map(e=>{return e instanceof a.Api.BotInlineMediaResult?(e.document instanceof a.Api.Document&&function(e){r.a.documents[String(e.id)]=e}(e.document),e.photo instanceof a.Api.Photo&&(t=e.photo,r.a.photos[String(t.id)]=t),Object(d.a)(e,l)):(e.thumb&&(n=e.thumb,r.a.webDocuments[n.url]=n),Object(d.b)(e,l));var t,n}))}}async function b({chat:e,resultId:t,queryId:n,replyingTo:s}){const r=Object(c.s)();await Object(o.g)(new a.Api.messages.SendInlineBotResult({clearDraft:!0,randomId:r,queryId:i()(n),peer:Object(c.i)(e.id,e.accessHash),id:t,...s&&{replyToMsgId:s}}),!0)}function y(e){r.a.users[e.id]=e}}).call(this,n(11).Buffer)},function(e,t,n){"use strict";n.d(t,"a",(function(){return m})),n.d(t,"b",(function(){return _}));var s=n(0),i=n(14),a=n(9),r=n(3),o=n(12),c=n(2),u=n(5),d=n(20),l=n(4),f=n(17),p=n(23),g=n(19);let h;function m(e){h=e}const b=new Set;let y=0;function _(e,t){if(e instanceof s.connection.UpdateServerTimeOffset)y=e.timeOffset;else if(e instanceof s.connection.UpdateConnectionState){let t;switch(e.state){case s.connection.UpdateConnectionState.disconnected:t="connectionStateConnecting";break;case s.connection.UpdateConnectionState.broken:t="connectionStateBroken";break;case s.connection.UpdateConnectionState.connected:default:t="connectionStateReady"}h({"@type":"updateConnectionState",connectionState:t})}else if(e instanceof s.Api.UpdateNewMessage||e instanceof s.Api.UpdateNewScheduledMessage||e instanceof s.Api.UpdateNewChannelMessage||e instanceof s.Api.UpdateShortChatMessage||e instanceof s.Api.UpdateShortMessage||e instanceof s.Api.UpdateServiceNotification){let t;if(e instanceof s.Api.UpdateShortChatMessage)t=Object(a.e)(e);else if(e instanceof s.Api.UpdateShortMessage)t=Object(a.d)(e);else if(e instanceof s.Api.UpdateServiceNotification){const n=Date.now()/1e3+y;t=Object(a.c)(e,n),Object(c.u)(e)&&Object(f.a)(Object(c.n)(t.id,t.chatId,e))}else{if(e.message instanceof s.Api.MessageEmpty)return void(l.g&&console.error("Unexpected update:",e.className,e));e.message instanceof s.Api.Message&&Object(c.u)(e.message)&&Object(f.a)(e.message),t=Object(a.b)(e.message)}const n=e._entities;if(n&&n.length&&(n.filter(e=>e instanceof s.Api.User).map(o.a).forEach(e=>{e&&h({"@type":"updateUser",id:e.id,user:e})}),n.filter(e=>e instanceof s.Api.Chat||e instanceof s.Api.Channel).map(e=>Object(r.d)(e)).forEach(e=>{e&&h({"@type":"updateChat",id:e.id,chat:e})})),e instanceof s.Api.UpdateNewScheduledMessage?h({"@type":b.has(t.id)?"updateScheduledMessage":"newScheduledMessage",id:t.id,chatId:t.chatId,message:t}):h({"@type":b.has(t.id)?"updateMessage":"newMessage",id:t.id,chatId:t.chatId,message:t}),e.message instanceof s.Api.MessageService){const{action:n}=e.message;if(n instanceof s.Api.MessageActionChatEditTitle)h({"@type":"updateChat",id:t.chatId,chat:{title:n.title}});else if(n instanceof s.Api.MessageActionChatEditPhoto){const i=Object(c.c)(n.photo),a=Object(r.e)(i),o=Math.abs(Object(f.c)(e.message));u.a.chats[o]&&(u.a.chats[o].photo=i),Object(f.b)(n.photo),a&&h({"@type":"updateChat",id:t.chatId,chat:{avatarHash:a},...n.photo instanceof s.Api.Photo&&{newProfilePhoto:Object(g.a)(n.photo)}})}else if(n instanceof s.Api.MessageActionChatDeletePhoto){const n=Math.abs(Object(f.c)(e.message));u.a.chats[n]&&(u.a.chats[n].photo=new s.Api.ChatPhotoEmpty),h({"@type":"updateChat",id:t.chatId,chat:{avatarHash:void 0}})}else n instanceof s.Api.MessageActionChatDeleteUser?e._entities&&e._entities.some(e=>e instanceof s.Api.User&&!!e.self&&e.id===n.userId)&&(h({"@type":"updateChat",id:t.chatId,chat:{isRestricted:!0}}),h({"@type":"updateChatLeave",id:t.chatId})):n instanceof s.Api.MessageActionChatAddUser&&e._entities&&e._entities.some(e=>e instanceof s.Api.User&&!!e.self&&n.users.includes(e.id))&&h({"@type":"updateChatJoin",id:t.chatId})}}else if(e instanceof s.Api.UpdateEditMessage||e instanceof s.Api.UpdateEditChannelMessage){if(e.message instanceof s.Api.MessageEmpty)return void(l.g&&console.error("Unexpected update:",e.className,e));e.message instanceof s.Api.Message&&Object(c.u)(e.message)&&Object(f.a)(e.message);const t=Object(a.b)(e.message);h({"@type":"updateMessage",id:t.id,chatId:t.chatId,message:t})}else if(e instanceof s.Api.UpdateDeleteMessages)h({"@type":"deleteMessages",ids:e.messages});else if(e instanceof s.Api.UpdateDeleteScheduledMessages)h({"@type":"deleteScheduledMessages",ids:e.messages,chatId:Object(r.i)(e.peer)});else if(e instanceof s.Api.UpdateDeleteChannelMessages){const t=Object(r.j)({channelId:e.channelId}),n=e.messages,i=n.filter(e=>u.a.messages[`${t}-${e}`]),a=n.filter(e=>!u.a.messages[`${t}-${e}`]),o=n.map(e=>{const n=u.a.messages[`${t}-${e}`];return n&&n instanceof s.Api.MessageService&&"photo"in n.action?String(n.action.photo.id):void 0}).filter(Boolean);i.length&&h({"@type":"deleteMessages",ids:i,chatId:t}),o.length&&h({"@type":"deleteProfilePhotos",ids:o,chatId:t}),a.length&&setTimeout(()=>{h({"@type":"deleteMessages",ids:a,chatId:t})},1e3)}else if((t instanceof s.Api.messages.SendMessage||t instanceof s.Api.messages.SendMedia||t instanceof s.Api.messages.SendMultiMedia||t instanceof s.Api.messages.ForwardMessages)&&(e instanceof s.Api.UpdateMessageID||e instanceof s.Api.UpdateShortSentMessage)){let n;"randomId"in e?n=e.randomId:"randomId"in t&&(n=t.randomId);const i=n&&u.a.localMessages[n.toString()];if(!i)throw new Error("Local message not found");let r;if(e instanceof s.Api.UpdateShortSentMessage){i.content.text&&e.entities&&(r={text:Object(a.j)(i.content.text.text,e.entities)}),e.media&&(r={...r,...Object(a.i)(e.media)});const t=Object(c.n)(e.id,i.chatId,e);Object(c.u)(t)&&Object(f.a)(t)}b.add(e.id);const o="date"in e&&1e3*e.dateString.fromCharCode(...e))});else if(e instanceof s.Api.UpdateChannelMessageViews)h({"@type":"updateMessage",chatId:Object(r.j)({channelId:e.channelId}),id:e.id,message:{views:e.views}});else if(e instanceof s.Api.UpdateReadHistoryInbox)h({"@type":"updateChatInbox",id:Object(r.j)(e.peer),chat:{lastReadInboxMessageId:e.maxId,unreadCount:e.stillUnreadCount}});else if(e instanceof s.Api.UpdateReadHistoryOutbox)h({"@type":"updateChat",id:Object(r.j)(e.peer),chat:{lastReadOutboxMessageId:e.maxId}});else if(e instanceof s.Api.UpdateReadChannelInbox)h({"@type":"updateChat",id:Object(r.j)({channelId:e.channelId}),chat:{lastReadInboxMessageId:e.maxId,unreadCount:e.stillUnreadCount}});else if(e instanceof s.Api.UpdateReadChannelOutbox)h({"@type":"updateChat",id:Object(r.j)({channelId:e.channelId}),chat:{lastReadOutboxMessageId:e.maxId}});else if(e instanceof s.Api.UpdateDialogPinned&&e.peer instanceof s.Api.DialogPeer)h({"@type":"updateChatPinned",id:Object(r.j)(e.peer.peer),isPinned:e.pinned||!1});else if(e instanceof s.Api.UpdatePinnedDialogs){const t=e.order?e.order.filter(e=>e instanceof s.Api.DialogPeer).map(e=>Object(r.j)(e.peer)):[];h({"@type":"updatePinnedChatIds",ids:t,folderId:e.folderId||void 0})}else if(e instanceof s.Api.UpdateFolderPeers)e.folderPeers.forEach(e=>{const{folderId:t,peer:n}=e;h({"@type":"updateChatListType",id:Object(r.j)(n),folderId:t})});else if(e instanceof s.Api.UpdateDialogFilter){const{id:t,filter:n}=e,s=n?Object(r.a)(n):void 0;h({"@type":"updateChatFolder",id:t,folder:s})}else if(e instanceof s.Api.UpdateDialogFilterOrder)h({"@type":"updateChatFoldersOrder",orderedIds:e.order});else if(e instanceof s.Api.UpdateChatParticipants){const t=Object(r.g)(e.participants);h({"@type":"updateChatMembers",id:Object(r.j)({chatId:e.participants.chatId}),replacedMembers:t})}else if(e instanceof s.Api.UpdateChatParticipantAdd){const t=Object(r.f)(Object(i.b)(e,["userId","inviterId","date"]));h({"@type":"updateChatMembers",id:Object(r.j)({chatId:e.chatId}),addedMember:t})}else if(e instanceof s.Api.UpdateChatParticipantDelete){const{userId:t}=e;h({"@type":"updateChatMembers",id:Object(r.j)({chatId:e.chatId}),deletedMemberId:t})}else if(e instanceof s.Api.UpdatePinnedMessages||e instanceof s.Api.UpdatePinnedChannelMessages){const t=e instanceof s.Api.UpdatePinnedMessages?e.peer:{channelId:e.channelId},n=Object(r.j)(t);h({"@type":"updatePinnedIds",chatId:n,messageIds:e.messages,isPinned:e.pinned})}else if(e instanceof s.Api.UpdateNotifySettings&&e.peer instanceof s.Api.NotifyPeer)h({"@type":"updateNotifyExceptions",...Object(p.a)(e.notifySettings,e.peer.peer,y)});else if(e instanceof s.Api.UpdateUserTyping||e instanceof s.Api.UpdateChatUserTyping){const t=e instanceof s.Api.UpdateUserTyping?e.userId:Object(r.j)({chatId:e.chatId});h({"@type":"updateChatTypingStatus",id:t,typingStatus:Object(r.h)(e,y)})}else if(e instanceof s.Api.UpdateChannelUserTyping){const t=Object(r.j)({channelId:e.channelId});h({"@type":"updateChatTypingStatus",id:t,typingStatus:Object(r.h)(e,y)})}else if(e instanceof s.Api.UpdateChannel){const{_entities:t}=e;if(!t)return;const n=t.find(e=>e instanceof s.Api.Channel||e instanceof s.Api.ChannelForbidden);if(n instanceof s.Api.Channel){const t=Object(r.d)(n);t&&(h({"@type":"updateChat",id:t.id,chat:t}),h({"@type":t.isNotJoined?"updateChatLeave":"updateChatJoin",id:Object(r.j)({channelId:e.channelId})}))}else if(n instanceof s.Api.ChannelForbidden){const t=Object(r.j)({channelId:e.channelId});h({"@type":"updateChat",id:t,chat:{isRestricted:!0}}),h({"@type":"updateChatLeave",id:t})}else 0===t.length&&h({"@type":"resetMessages",id:Object(r.j)({chatId:e.channelId})})}else if(e instanceof s.Api.UpdateDialogUnreadMark&&e.peer instanceof s.Api.DialogPeer)h({"@type":"updateChat",id:Object(r.j)(e.peer.peer),chat:{hasUnreadMark:e.unread}});else if(e instanceof s.Api.UpdateChatDefaultBannedRights)h({"@type":"updateChat",id:Object(r.j)(e.peer),chat:{defaultBannedRights:Object(d.b)(e.defaultBannedRights)}});else if(e instanceof s.Api.UpdateUserStatus){const{userId:t,status:n}=e;h({"@type":"updateUserStatus",userId:t,status:Object(o.c)(n)})}else if(e instanceof s.Api.UpdateUserName){const t=u.a.users[e.userId],n=t&&t.mutualContact&&!t.self?Object(i.b)(e,["username"]):Object(i.b)(e,["firstName","lastName","username"]);h({"@type":"updateUser",id:e.userId,user:n})}else if(e instanceof s.Api.UpdateUserPhoto){const{userId:t,photo:n}=e,s=Object(r.e)(n);u.a.users[t]&&(u.a.users[t].photo=n),h({"@type":"updateUser",id:t,user:{avatarHash:s}})}else if(e instanceof s.Api.UpdateUserPhone){const{userId:t,phone:n}=e;h({"@type":"updateUser",id:t,user:{phoneNumber:n}})}else if(e instanceof s.Api.UpdatePeerSettings){const{_entities:t}=e;if(!t)return;t&&t.length&&(t.filter(e=>e instanceof s.Api.User&&!e.contact).forEach(e=>{h({"@type":"deleteUser",id:e.id})}),t.filter(e=>e instanceof s.Api.User&&e.contact).map(o.a).forEach(e=>{e&&h({"@type":"updateUser",id:e.id,user:e})}))}else if(e instanceof s.Api.UpdateNotifySettings){const{notifySettings:{showPreviews:t,silent:n,muteUntil:s},peer:{className:i}}=e,a="NotifyUsers"===i?"contact":"NotifyChats"===i?"group":"NotifyBroadcasts"===i?"broadcast":void 0;if(!a)return;h({"@type":"updateNotifySettings",peerType:a,isSilent:Boolean(n||"number"==typeof s&&Date.now()+1e3*y<1e3*s),shouldShowPreviews:Boolean(t)})}else if(e instanceof s.Api.UpdatePeerBlocked)h({"@type":"updatePeerBlocked",id:Object(r.j)(e.peerId),isBlocked:e.blocked});else if(e instanceof s.Api.UpdatePrivacy){const t=Object(p.d)(e.key);t&&h({"@type":"updatePrivacy",key:t,rules:Object(p.e)(e.rules)})}else if(e instanceof s.Api.UpdateDraftMessage)h({"@type":"draftMessage",chatId:Object(r.j)(e.peer),...Object(a.h)(e.draft)});else if(e instanceof s.Api.UpdateContactsReset)h({"@type":"updateResetContactList"});else if(e instanceof s.Api.UpdateFavedStickers)h({"@type":"updateFavoriteStickers"});else if(l.g){const t="object"==typeof e&&"className"in e?e.className:e;console.warn("[GramJs/updater] Unexpected update:",t)}}},function(e,t,n){const s=n(50);e.exports=class extends s{constructor(){super(),this._serverAddress=void 0,this._dcId=0,this._port=void 0,this._takeoutId=void 0,this._entities=new Set,this._updateStates={}}get dcId(){return this._dcId}get serverAddress(){return this._serverAddress}get port(){return this._port}get authKey(){return this._authKey}set authKey(e){this._authKey=e}setDC(e,t,n){this._dcId=0|e,this._serverAddress=t,this._port=n}}},function(e,t,n){(function(t){const{sha1:s,toSignedLittleBuffer:i,readBufferFromBigInt:a,readBigIntFromBuffer:r}=n(8),o=n(26),{sleep:c}=n(8);class u{constructor(e,t){if(!t||!e)return;this._key=e,this._hash=t;const n=new o(t);this.auxHash=n.readLong(!1),n.read(4),this.keyId=n.readLong(!1)}async setKey(e){if(!e)return this._key=void 0,this.auxHash=void 0,this.keyId=void 0,void(this._hash=void 0);if(e instanceof u)return this._key=e._key,this.auxHash=e.auxHash,this.keyId=e.keyId,void(this._hash=e._hash);this._key=e,this._hash=await s(this._key);const t=new o(this._hash);this.auxHash=t.readLong(!1),t.read(4),this.keyId=t.readLong(!1)}async waitForKey(){for(;!this.keyId;)await c(20)}getKey(){return this._key}async calcNewNonceHash(e,n){e=i(e,32);const o=t.alloc(1);o.writeUInt8(n,0);const c=t.concat([e,t.concat([o,a(this.auxHash,8,!0)])]),u=(await s(c)).slice(4,20);return r(u,!0,!0)}equals(e){return e instanceof this.constructor&&this._key&&e.getKey()&&e.getKey().equals(this._key)}}e.exports=u}).call(this,n(11).Buffer)},function(e,t,n){"use strict";function s(e,t,n=!0){let s,i,a;return(...r)=>{i=!0,a=r,s||(n&&(i=!1,e(...a)),s=self.setInterval(()=>{if(!i)return self.clearInterval(s),void(s=void 0);i=!1,e(...a)},t))}}function i(e){return a(r,e)}function a(e,t){let n,s=!1;return(...i)=>{n=i,s||(s=!0,e(()=>{s=!1,t(...n)}))}}function r(e){Promise.resolve().then(e)}n.d(t,"b",(function(){return s})),n.d(t,"c",(function(){return i})),n.d(t,"a",(function(){return o}));const o=e=>new Promise(t=>{setTimeout(()=>t(),e)})},function(e,t,n){(function(t){const s=n(15),{constructors:i}=n(24),{readBigIntFromBuffer:a,readBufferFromBigInt:r,sha256:o,bigIntMod:c,modExp:u,generateRandomBytes:d}=n(8),l=n(36);function f(e,n){if(!t.from([199,28,174,185,198,177,201,4,142,108,82,47,112,241,63,115,152,13,64,35,142,62,33,193,73,52,208,55,86,61,147,15,72,25,138,10,167,193,64,88,34,148,147,210,37,48,244,219,250,51,111,110,10,201,37,19,149,67,174,212,76,206,124,55,32,253,81,246,148,88,112,90,198,140,212,254,107,107,19,171,220,151,70,81,41,105,50,132,84,241,143,175,140,89,95,100,36,119,254,150,187,42,148,29,91,205,29,74,200,204,73,136,7,8,250,155,55,142,60,79,58,144,96,190,230,124,249,164,164,166,149,129,16,81,144,126,22,39,83,181,107,15,107,65,13,186,116,216,168,75,42,20,179,20,78,14,241,40,71,84,253,23,237,149,13,89,101,180,185,221,70,88,45,177,23,141,22,156,107,196,101,176,214,255,156,163,146,143,239,91,154,228,228,24,252,21,232,62,190,160,248,127,169,255,94,237,112,5,13,237,40,73,244,123,249,89,217,86,133,12,233,41,133,31,13,129,21,246,53,177,5,238,46,78,21,208,75,36,84,191,111,79,173,240,52,177,4,3,17,156,216,227,185,47,204,91]).equals(e)||![3,4,5,7].includes(n))throw new Error("Changing passwords unsupported")}function p(e){return t.concat([t.alloc(256-e.length),e])}function g(e){return r(e,256,!1)}function h(e,t){const n=t.subtract(e);return!(n.lesser(s(0))||n.bitLength()<1984||e.bitLength()<1984||Math.floor((e.bitLength()+7)/8)>256)}function m(e,t){const n=Math.min(e.length,t.length);for(let s=0;s{for(;;){const e=d(256),n=a(e,!1),i=u(s(_),n,y);if(h(i,y)){const e=g(i),r=a(await o(t.concat([e,P])),!1);if(r.greater(s(0)))return[n,e,r]}}})(),R=c(w.subtract(M),y);if(!h(R,y))throw new Error("bad gB");const U=O.multiply(v),T=k.add(U),D=u(R,T,y),[B,x,j,N,V]=await Promise.all([o(g(D)),o(A),o(I),o(r.salt1),o(r.salt2)]),F=await o(t.concat([m(x,j),N,V,E,P,B]));return new i.InputCheckPasswordSRP({srpId:e.srpId,A:t.from(E),M1:F})},computeDigest:async function(e,t){try{f(e.p,e.g)}catch(e){throw new Error("bad p/g in password")}return g(u(s(e.g),a(await b(e,t),!1),a(e.p,!1)))}}}).call(this,n(11).Buffer)},function(e,t,n){(function(t){function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const{inflate:i}=n(42),{serializeBytes:a}=n(24);class r{constructor(e){this.data=e,this.CONSTRUCTOR_ID=812830625,this.classType="constructor"}static async gzipIfSmaller(e,t){if(e&&t.length>512){const e=await new r(t).toBytes();if(e.length{const s=new FileReader;s.onload=e=>{const{result:s}=e.target||{};"string"==typeof s&&t(s),n(new Error("Failed to read blob"))},s.onerror=n,s.readAsDataURL(e)})}async function a(e,t){return function(e,t){return new File([e],t,{lastModified:Date.now(),type:e.type})}(await async function(e){return(await fetch(e)).blob()}(e),t)}},function(e,t,n){(function(t){const s=n(47).default,{i2ab:i,ab2i:a}=n(79),{getWords:r}=n(80);class o{constructor(e){this.setBytes(e)}setBytes(e){e=t.from(e),this._counter=e}increment(){for(let e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}}}class c{constructor(e,t){t instanceof o||(t=new o(t)),this._counter=t,this._remainingCounter=void 0,this._remainingCounterIndex=16,this._aes=new s(r(e))}update(e){return this.encrypt(e)}encrypt(e){const n=t.from(e);for(let e=0;e{s[e]&&r[e]&&(this._authKeys[e]=new i(t.from(s[e].data),t.from(r[e].data)))})}catch(e){console.warn("Failed to retrieve or parse session from storage"),console.warn(e)}}setDC(e,t,n,s=!1){this._dcId=e,this._serverAddress=t,this._port=n,delete this._authKeys[e],s||this._updateStorage()}async save(){return this._storageKey||(this._storageKey="GramJs-session-"+Date.now()),await this._updateStorage(),this._storageKey}getAuthKey(e=this._dcId){return this._authKeys[e]}setAuthKey(e,t=this._dcId){this._authKeys[t]=e,this._updateStorage()}getSessionData(e){const t={mainDcId:this._dcId,keys:{},hashes:{}};return Object.keys(this._authKeys).forEach(n=>{const s=this._authKeys[n];s._key&&(t.keys[n]=e?s._key.toString("hex"):s._key,t.hashes[n]=e?s._hash.toString("hex"):s._hash)}),t}async _loadFromSessionString(){const[,e,n]=this._sessionString.split(":"),s=Number(e),{ipAddress:r,port:o}=a.getDC(s);this.setDC(s,r,o);const c=new i;await c.setKey(t.from(n,"hex"),!0),this.setAuthKey(c,s)}async _updateStorage(){if(this._storageKey)try{await this._saveToCache(JSON.stringify(this.getSessionData()))}catch(e){console.warn("Failed to update session in storage"),console.warn(e)}}async delete(){try{return await this._delete()}catch(e){console.warn("Failed to delete session from storage"),console.warn(e)}}_delete(){throw new Error("Not Implemented")}_fetchFromCache(){throw new Error("Not Implemented")}_saveToCache(e){throw new Error("Not Implemented")}}}).call(this,n(11).Buffer)},function(e,t,n){e.exports=function e(t,n,s){function i(r,o){if(!n[r]){if(!t[r]){if(a)return a(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[r]={exports:{}};t[r][0].call(u.exports,(function(e){return i(t[r][1][e]||e)}),u,u.exports,e,t,n,s)}return n[r].exports}for(var a=!1,r=0;r=252?6:o>=248?5:o>=240?4:o>=224?3:o>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&a||!e.subarray&&i))return String.fromCharCode.apply(null,s.shrinkBuf(e,t));for(var n="",r=0;r>>6,t[r++]=128|63&n):n<65536?(t[r++]=224|n>>>12,t[r++]=128|n>>>6&63,t[r++]=128|63&n):(t[r++]=240|n>>>18,t[r++]=128|n>>>12&63,t[r++]=128|n>>>6&63,t[r++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new s.Buf8(e.length),n=0,i=t.length;n4)u[s++]=65533,n+=a-1;else{for(i&=2===a?31:3===a?15:7;a>1&&n1?u[s++]=65533:i<65536?u[s++]=i:(i-=65536,u[s++]=55296|i>>10&1023,u[s++]=56320|1023&i)}return c(u,s)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+r[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,s){for(var i=65535&e|0,a=e>>>16&65535|0,r=0;0!==n;){n-=r=n>2e3?2e3:n;do{a=a+(i=i+t[s++]|0)|0}while(--r);i%=65521,a%=65521}return i|a<<16|0}},{}],4:[function(e,t,n){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,n){"use strict";var s=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var a=s,r=i+n;e^=-1;for(var o=i;o>>8^a[255&(e^t[o])];return-1^e}},{}],6:[function(e,t,n){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,n){"use strict";t.exports=function(e,t){var n,s,i,a,r,o,c,u,d,l,f,p,g,h,m,b,y,_,w,v,A,I,P,C,S;n=e.state,s=e.next_in,C=e.input,i=s+(e.avail_in-5),a=e.next_out,S=e.output,r=a-(t-e.avail_out),o=a+(e.avail_out-257),c=n.dmax,u=n.wsize,d=n.whave,l=n.wnext,f=n.window,p=n.hold,g=n.bits,h=n.lencode,m=n.distcode,b=(1<>>=w=_>>>24,g-=w,0==(w=_>>>16&255))S[a++]=65535&_;else{if(!(16&w)){if(0==(64&w)){_=h[(65535&_)+(p&(1<>>=w,g-=w),g<15&&(p+=C[s++]<>>=w=_>>>24,g-=w,!(16&(w=_>>>16&255))){if(0==(64&w)){_=m[(65535&_)+(p&(1<c){e.msg="invalid distance too far back",n.mode=30;break e}if(p>>>=w,g-=w,A>(w=a-r)){if((w=A-w)>d&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(I=0,P=f,0===l){if(I+=u-w,w2;)S[a++]=P[I++],S[a++]=P[I++],S[a++]=P[I++],v-=3;v&&(S[a++]=P[I++],v>1&&(S[a++]=P[I++]))}else{I=a-A;do{S[a++]=S[I++],S[a++]=S[I++],S[a++]=S[I++],v-=3}while(v>2);v&&(S[a++]=S[I++],v>1&&(S[a++]=S[I++]))}break}}break}}while(s>3,p&=(1<<(g-=v<<3))-1,e.next_in=s,e.next_out=a,e.avail_in=s>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function d(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new s.Buf32(852),t.distcode=t.distdyn=new s.Buf32(592),t.sane=1,t.back=-1,0):-2}function l(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,d(e)):-2}function f(e,t){var n,s;return e&&e.state?(s=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?-2:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=n,s.wbits=t,l(e))):-2}function p(e,t){var n,s;return e?(s=new u,e.state=s,s.window=null,0!==(n=f(e,t))&&(e.state=null),n):-2}var g,h,m=!0;function b(e){if(m){var t;for(g=new s.Buf32(512),h=new s.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(o(1,e.lens,0,288,g,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;o(2,e.lens,0,32,h,0,e.work,{bits:5}),m=!1}e.lencode=g,e.lenbits=9,e.distcode=h,e.distbits=5}function y(e,t,n,i){var a,r=e.state;return null===r.window&&(r.wsize=1<=r.wsize?(s.arraySet(r.window,t,n-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):((a=r.wsize-r.wnext)>i&&(a=i),s.arraySet(r.window,t,n-i,a,r.wnext),(i-=a)?(s.arraySet(r.window,t,n-i,i,0),r.wnext=i,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave>>8&255,n.check=a(n.check,B,2,0),h=0,m=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&h)<<8)+(h>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&h)){e.msg="unknown compression method",n.mode=30;break}if(m-=4,O=8+(15&(h>>>=4)),0===n.wbits)n.wbits=O;else if(O>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(B[0]=255&h,B[1]=h>>>8&255,n.check=a(n.check,B,2,0)),h=0,m=0,n.mode=3;case 3:for(;m<32;){if(0===p)break e;p--,h+=u[l++]<>>8&255,B[2]=h>>>16&255,B[3]=h>>>24&255,n.check=a(n.check,B,4,0)),h=0,m=0,n.mode=4;case 4:for(;m<16;){if(0===p)break e;p--,h+=u[l++]<>8),512&n.flags&&(B[0]=255&h,B[1]=h>>>8&255,n.check=a(n.check,B,2,0)),h=0,m=0,n.mode=5;case 5:if(1024&n.flags){for(;m<16;){if(0===p)break e;p--,h+=u[l++]<>>8&255,n.check=a(n.check,B,2,0)),h=0,m=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((v=n.length)>p&&(v=p),v&&(n.head&&(O=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),s.arraySet(n.head.extra,u,l,v,O)),512&n.flags&&(n.check=a(n.check,u,v,l)),p-=v,l+=v,n.length-=v),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;v=0;do{O=u[l+v++],n.head&&O&&n.length<65536&&(n.head.name+=String.fromCharCode(O))}while(O&&v>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;m<32;){if(0===p)break e;p--,h+=u[l++]<>>=7&m,m-=7&m,n.mode=27;break}for(;m<3;){if(0===p)break e;p--,h+=u[l++]<>>=1)){case 0:n.mode=14;break;case 1:if(b(n),n.mode=20,6===t){h>>>=2,m-=2;break e}break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}h>>>=2,m-=2;break;case 14:for(h>>>=7&m,m-=7&m;m<32;){if(0===p)break e;p--,h+=u[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&h,h=0,m=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(v=n.length){if(v>p&&(v=p),v>g&&(v=g),0===v)break e;s.arraySet(d,u,l,v,f),p-=v,l+=v,g-=v,f+=v,n.length-=v;break}n.mode=12;break;case 17:for(;m<14;){if(0===p)break e;p--,h+=u[l++]<>>=5,m-=5,n.ndist=1+(31&h),h>>>=5,m-=5,n.ncode=4+(15&h),h>>>=4,m-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have>>=3,m-=3}for(;n.have<19;)n.lens[x[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,U={bits:n.lenbits},R=o(0,n.lens,0,19,n.lencode,0,n.work,U),n.lenbits=U.bits,R){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,S=65535&D,!((P=D>>>24)<=m);){if(0===p)break e;p--,h+=u[l++]<>>=P,m-=P,n.lens[n.have++]=S;else{if(16===S){for(T=P+2;m>>=P,m-=P,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}O=n.lens[n.have-1],v=3+(3&h),h>>>=2,m-=2}else if(17===S){for(T=P+3;m>>=P)),h>>>=3,m-=3}else{for(T=P+7;m>>=P)),h>>>=7,m-=7}if(n.have+v>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;v--;)n.lens[n.have++]=O}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,U={bits:n.lenbits},R=o(1,n.lens,0,n.nlen,n.lencode,0,n.work,U),n.lenbits=U.bits,R){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,U={bits:n.distbits},R=o(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,U),n.distbits=U.bits,R){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(p>=6&&g>=258){e.next_out=f,e.avail_out=g,e.next_in=l,e.avail_in=p,n.hold=h,n.bits=m,r(e,w),f=e.next_out,d=e.output,g=e.avail_out,l=e.next_in,u=e.input,p=e.avail_in,h=n.hold,m=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;C=(D=n.lencode[h&(1<>>16&255,S=65535&D,!((P=D>>>24)<=m);){if(0===p)break e;p--,h+=u[l++]<>M)])>>>16&255,S=65535&D,!(M+(P=D>>>24)<=m);){if(0===p)break e;p--,h+=u[l++]<>>=M,m-=M,n.back+=M}if(h>>>=P,m-=P,n.back+=P,n.length=S,0===C){n.mode=26;break}if(32&C){n.back=-1,n.mode=12;break}if(64&C){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&C,n.mode=22;case 22:if(n.extra){for(T=n.extra;m>>=n.extra,m-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;C=(D=n.distcode[h&(1<>>16&255,S=65535&D,!((P=D>>>24)<=m);){if(0===p)break e;p--,h+=u[l++]<>M)])>>>16&255,S=65535&D,!(M+(P=D>>>24)<=m);){if(0===p)break e;p--,h+=u[l++]<>>=M,m-=M,n.back+=M}if(h>>>=P,m-=P,n.back+=P,64&C){e.msg="invalid distance code",n.mode=30;break}n.offset=S,n.extra=15&C,n.mode=24;case 24:if(n.extra){for(T=n.extra;m>>=n.extra,m-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===g)break e;if(v=w-g,n.offset>v){if((v=n.offset-v)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}v>n.wnext?(v-=n.wnext,A=n.wsize-v):A=n.wnext-v,v>n.length&&(v=n.length),I=n.window}else I=d,A=f-n.offset,v=n.length;v>g&&(v=g),g-=v,n.length-=v;do{d[f++]=I[A++]}while(--v);0===n.length&&(n.mode=21);break;case 26:if(0===g)break e;d[f++]=n.length,g--,n.mode=21;break;case 27:if(n.wrap){for(;m<32;){if(0===p)break e;p--,h|=u[l++]<=1&&0===B[S];S--);if(M>S&&(M=S),0===S)return u[d++]=20971520,u[d++]=20971520,f.bits=1,0;for(C=1;C0&&(0===e||1!==S))return-1;for(x[1]=0,I=1;I<15;I++)x[I+1]=x[I]+B[I];for(P=0;P852||2===e&&R>592)return 1;for(;;){_=I-E,l[P]y?(w=j[N+l[P]],v=T[D+l[P]]):(w=96,v=0),p=1<>E)+(g-=p)]=_<<24|w<<16|v|0}while(0!==g);for(p=1<>=1;if(0!==p?(U&=p-1,U+=p):U=0,P++,0==--B[I]){if(I===S)break;I=t[n+l[P]]}if(I>M&&(U&m)!==h){for(0===E&&(E=M),b+=C,O=1<<(k=I-E);k+E852||2===e&&R>592)return 1;u[h=U&m]=M<<24|k<<16|b-d|0}}return 0!==U&&(u[b+U]=I-E<<24|64<<16|0),f.bits=M,0}},{"../utils/common":1}],10:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/inflate.js":[function(e,t,n){"use strict";var s=e("./zlib/inflate"),i=e("./utils/common"),a=e("./utils/strings"),r=e("./zlib/constants"),o=e("./zlib/messages"),c=e("./zlib/zstream"),u=e("./zlib/gzheader"),d=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var n=s.inflateInit2(this.strm,t.windowBits);if(n!==r.Z_OK)throw new Error(o[n]);if(this.header=new u,s.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=a.string2buf(t.dictionary):"[object ArrayBuffer]"===d.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=s.inflateSetDictionary(this.strm,t.dictionary))!==r.Z_OK))throw new Error(o[n])}function f(e,t){var n=new l(t);if(n.push(e,!0),n.err)throw n.msg||o[n.err];return n.result}l.prototype.push=function(e,t){var n,o,c,u,l,f=this.strm,p=this.options.chunkSize,g=this.options.dictionary,h=!1;if(this.ended)return!1;o=t===~~t?t:!0===t?r.Z_FINISH:r.Z_NO_FLUSH,"string"==typeof e?f.input=a.binstring2buf(e):"[object ArrayBuffer]"===d.call(e)?f.input=new Uint8Array(e):f.input=e,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new i.Buf8(p),f.next_out=0,f.avail_out=p),(n=s.inflate(f,r.Z_NO_FLUSH))===r.Z_NEED_DICT&&g&&(n=s.inflateSetDictionary(this.strm,g)),n===r.Z_BUF_ERROR&&!0===h&&(n=r.Z_OK,h=!1),n!==r.Z_STREAM_END&&n!==r.Z_OK)return this.onEnd(n),this.ended=!0,!1;f.next_out&&(0!==f.avail_out&&n!==r.Z_STREAM_END&&(0!==f.avail_in||o!==r.Z_FINISH&&o!==r.Z_SYNC_FLUSH)||("string"===this.options.to?(c=a.utf8border(f.output,f.next_out),u=f.next_out-c,l=a.buf2string(f.output,c),f.next_out=u,f.avail_out=p-u,u&&i.arraySet(f.output,f.output,c,u,0),this.onData(l)):this.onData(i.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(h=!0)}while((f.avail_in>0||0===f.avail_out)&&n!==r.Z_STREAM_END);return n===r.Z_STREAM_END&&(o=r.Z_FINISH),o===r.Z_FINISH?(n=s.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===r.Z_OK):o!==r.Z_SYNC_FLUSH||(this.onEnd(r.Z_OK),f.avail_out=0,!0)},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){e===r.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=l,n.inflate=f,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,f(e,t)},n.ungzip=f},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")},function(e,t,n){const s=n(48),i=n(59),a=n(26),r=n(61),o=n(58),c=n(62);e.exports={BinaryWriter:i,BinaryReader:a,MessagePacker:o,AsyncQueue:c,Logger:s,PromisedWebSockets:r}},function(e,t,n){"use strict";n.d(t,"b",(function(){return c})),n.d(t,"a",(function(){return u}));var s=n(0),i=n(14),a=n(19),r=n(9),o=n(22);function c(e,t){const{id:n,type:s,title:i,description:a,url:r,thumb:o}=e;return{id:n,queryId:t,type:s,title:i,description:a,url:r,webThumbnail:d(o)}}function u(e,t){const{id:n,type:i,title:c,description:u,photo:d,document:l}=e;return{id:n,queryId:t,type:i,title:c,description:u,..."sticker"===i&&l instanceof s.Api.Document&&{sticker:Object(o.a)(l)},...d instanceof s.Api.Photo&&{photo:Object(a.a)(d)},..."gif"===i&&l instanceof s.Api.Document&&{gif:Object(r.m)(l)},..."video"===i&&l instanceof s.Api.Document&&{thumbnail:Object(a.d)(l.thumbs)}}}function d(e){return e?Object(i.b)(e,["url","mimeType"]):void 0}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){const n=e=>e.replace(/(?:^|_)([a-z])/g,(e,t)=>t.toUpperCase()).replace(/_/g,""),s=e=>e.replace(/([-_][a-z])/g,e=>e.toUpperCase().replace("-","").replace("_","")),i=new Set([3162085175,2574415285,1072550713,3300522427,1450380236]),a=new Set([85337187,2211011308,2851430293,1013613780,1459478408,3504867164,3045658042,1715713620,3608339646,4110704415,812830625]);let r;function o(e){r||(r=function(){let e;const t=[];for(let n=0;n<256;n++){e=n;for(let t=0;t<8;t++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}()),t.isBuffer(e)||(e=t.from(e));let n=-1;for(let t=0;t>>8}return(-1^n)>>>0}const c=(e,t,n=[])=>{e.flags.includes("g")||(e=new RegExp(e.source,"g"));const s=e.exec(t);return s&&(n.push(s.slice(1)),c(e,t,n)),n},u=(e,i)=>{const a=e.match(/([\w.]+)(?:#([0-9a-fA-F]+))?(?:\s{?\w+:[\w\d<>#.?!]+}?)*\s=\s([\w\d<>#.?]+);$/);if(!a)throw new Error("Cannot parse TLObject "+e);const r=c(/({)?(\w+):([\w\d<>#.?!]+)}?/,e),u={name:a[1],constructorId:parseInt(a[2],16),argsConfig:{},subclassOfId:o(a[3]),result:a[3],isFunction:i,namespace:void 0};if(!u.constructorId){const e="";let n;n=Object.values(u.argsConfig).length?" "+Object.keys(u.argsConfig).map(e=>e.toString()).join(" "):"";const s=`${u.name}${e}${n} = ${u.result}`.replace(/(:|\?)bytes /g,"$1string ").replace(/|{|}/g,"").replace(/ \w+:flags\.\d+\?true/g,"");"inputMediaInvoice"===u.name&&u.name,u.constructorId=o(t.from(s,"utf8"))}for(const[e,t,n]of r)void 0===e&&(u.argsConfig[s(t)]=d(t,n));return u.name.includes(".")&&([u.namespace,u.name]=u.name.split(/\.(.+)/)),u.name=n(u.name),u};function d(e,t){e="self"===e?"is_self":e;const n={isVector:!1,isFlag:!1,skipConstructorId:!1,flagIndex:-1,flagIndicator:!0,type:void 0,useVectorId:void 0};if("#"!==t){n.flagIndicator=!1,n.type=t.replace(/^!+/,"");const e=n.type.match(/flags.(\d+)\?([\w<>.]+)/);e&&(n.isFlag=!0,n.flagIndex=Number(e[1]),[,,n.type]=e);const s=n.type.match(/[Vv]ector<([\w\d.]+)>/);s&&(n.isVector=!0,n.useVectorId="V"===n.type.charAt(0),[,n.type]=s),/^[a-z]$/.test(n.type.split(".").pop().charAt(0))&&(n.skipConstructorId=!0)}return n}e.exports={findAll:c,parseTl:function*(e,t,n=[],s=i){(n||[]).reduce((e,t)=>({...e,[t.name]:t}),{});const r=[],o={},c={},d=e;let l=!1;for(let e of d.split("\n")){const t=e.indexOf("//");if(-1!==t&&(e=e.slice(0,t)),e=e.trim(),!e)continue;const n=e.match(/---(\w+)---/);if(n){const[,e]=n;l="functions"===e}else try{const t=u(e,l);if(s.has(t.constructorId))continue;r.push(t),t.isFunction||(c[t.result]||(c[t.result]=[]),o[t.name]=t,c[t.result].push(t))}catch(e){if(!e.toString().includes("vector#1cb5c415"))throw e}}for(const e of r)if(a.has(e.constructorId))for(const t in e.argsConfig)"string"===e.argsConfig[t].type&&(e.argsConfig[t].type="bytes");for(const e of r)yield e},buildArgConfig:d,fromLine:u,CORE_TYPES:i,serializeDate:function(e){if(!e)return t.alloc(4).fill(0);if(e instanceof Date&&(e=Math.floor((Date.now()-e.getTime())/1e3)),"number"==typeof e){const n=t.alloc(4);return n.writeInt32LE(e,0),n}throw Error(`Cannot interpret "${e}" as a date`)},serializeBytes:function(e){if(!(e instanceof t)){if("string"!=typeof e)throw Error("Bytes or str expected, not "+e.constructor.name);e=t.from(e)}const n=[];let s;return e.length<254?(s=(e.length+1)%4,0!==s&&(s=4-s),n.push(t.from([e.length])),n.push(e)):(s=e.length%4,0!==s&&(s=4-s),n.push(t.from([254,e.length%256,(e.length>>8)%256,(e.length>>16)%256])),n.push(e)),n.push(t.alloc(s).fill(0)),t.concat(n)},snakeToCamelCase:n,variableSnakeToCamelCase:s}}).call(this,n(11).Buffer)},function(e,t,n){"use strict";n.r(t),n.d(t,"CTR",(function(){return b})),n.d(t,"IGE",(function(){return m}));var s=new Uint8Array(256),i=new Uint8Array(256),a=new Uint32Array(256),r=new Uint32Array(256),o=new Uint32Array(256),c=new Uint32Array(256),u=new Uint32Array(256),d=new Uint32Array(256),l=new Uint32Array(256),f=new Uint32Array(256);function p(e){if(e instanceof Uint32Array)return e;if("string"==typeof e){if(e.length%4!=0)for(var t=e.length%4;t<=4;t++)e+="\0x00";var n=new Uint32Array(e.length/4);for(t=0;t>7),m[h[_]^_]=_;for(;!s[b];b^=e||1)n=(n=y^y<<1^y<<2^y<<3^y<<4)>>8^255&n^99,s[b]=n,i[n]=b,g=16843009*h[t=h[e=h[b]]]^65537*t^257*e^16843008*b,p=257*h[n]^16843008*n,a[b]=p=p<<24^p>>>8,r[b]=p=p<<24^p>>>8,o[b]=p=p<<24^p>>>8,c[b]=p=p<<24^p>>>8,u[n]=g=g<<24^g>>>8,d[n]=g=g<<24^g>>>8,l[n]=g=g<<24^g>>>8,f[n]=g=g<<24^g>>>8,y=m[y]||1}();var h=function(){function e(e){var t=p(e);if(4!==t.length&&6!==t.length&&8!==t.length)throw new Error("Invalid key size");this.encKey=new Uint32Array(4*t.length+28),this.decKey=new Uint32Array(4*t.length+28),this.encKey.set(t);for(var n,i=1,a=t.length;a<4*t.length+28;a++)n=this.encKey[a-1],(a%t.length==0||8===t.length&&a%t.length==4)&&(n=s[n>>>24]<<24^s[n>>16&255]<<16^s[n>>8&255]<<8^s[255&n],a%t.length==0&&(n=n<<8^n>>>24^i<<24,i=i<<1^283*(i>>7))),this.encKey[a]=this.encKey[a-t.length]^n;for(var r=0;a;r++,a--)n=this.encKey[3&r?a:a-4],this.decKey[r]=a<=4||r<4?n:u[s[n>>>24]]^d[s[n>>16&255]]^l[s[n>>8&255]]^f[s[255&n]]}return e.prototype.encrypt=function(e){for(var t,n,i,u=p(e),d=new Uint32Array(4),l=u[0]^this.encKey[0],f=u[1]^this.encKey[1],g=u[2]^this.encKey[2],h=u[3]^this.encKey[3],m=this.encKey.length/4-2,b=4,y=0;y>>24]^r[f>>16&255]^o[g>>8&255]^c[255&h]^this.encKey[b],n=a[f>>>24]^r[g>>16&255]^o[h>>8&255]^c[255&l]^this.encKey[b+1],i=a[g>>>24]^r[h>>16&255]^o[l>>8&255]^c[255&f]^this.encKey[b+2],h=a[h>>>24]^r[l>>16&255]^o[f>>8&255]^c[255&g]^this.encKey[b+3],l=t,f=n,g=i,b+=4;for(y=0;y<4;y++)d[y]=s[l>>>24]<<24^s[f>>16&255]<<16^s[g>>8&255]<<8^s[255&h]^this.encKey[b++],t=l,l=f,f=g,g=h,h=t;return d},e.prototype.decrypt=function(e){for(var t,n,s,a=p(e),r=new Uint32Array(4),o=a[0]^this.decKey[0],c=a[3]^this.decKey[1],g=a[2]^this.decKey[2],h=a[1]^this.decKey[3],m=this.decKey.length/4-2,b=4,y=0;y>>24]^d[c>>16&255]^l[g>>8&255]^f[255&h]^this.decKey[b],n=u[c>>>24]^d[g>>16&255]^l[h>>8&255]^f[255&o]^this.decKey[b+1],s=u[g>>>24]^d[h>>16&255]^l[o>>8&255]^f[255&c]^this.decKey[b+2],h=u[h>>>24]^d[o>>16&255]^l[c>>8&255]^f[255&g]^this.decKey[b+3],o=t,c=n,g=s,b+=4;for(y=0;y<4;y++)r[3&-y]=i[o>>>24]<<24^i[c>>16&255]<<16^i[g>>8&255]<<8^i[255&h]^this.decKey[b++],t=o,o=c,c=g,g=h,h=t;return r},e}(),m=function(){function e(e,t,n){void 0===n&&(n=16),this.key=p(e),this.iv=p(t),this.cipher=new h(e),this.blockSize=n/4}return e.prototype.encrypt=function(e,t){for(var n=p(e),s=t||new Uint32Array(n.length),i=this.iv.subarray(this.blockSize,this.iv.length),a=this.iv.subarray(0,this.blockSize),r=new Uint32Array(this.blockSize),o=0;o=this.blockSize&&this.incrementCounter(),i&&(a-=i,i=0)}return this.offset=(this.offset+n.length%4)%4,s},e.prototype.decrypt=function(e,t){return this.encrypt(e,t)},e.prototype.incrementCounter=function(){for(var e=this.counter.length-1;e>=0&&!(++this.counter[e]<4294967295);e--);},e}();t.default=h},function(e,t,n){(function(t){let n;class s{constructor(e){n||(n=e||"debug"),this.isBrowser=void 0===t||"renderer"===t.type||!0===t.browser||t.__nwjs,this.isBrowser?this.colors={start:"%c",warn:"color : #ff00ff",info:"color : #ffff00",debug:"color : #00ffff",error:"color : #ff0000",end:""}:this.colors={start:"",warn:"",info:"",debug:"",error:"",end:""},this.messageFormat="[%t] [%l] - [%m]"}static setLevel(e){n=e}canSend(e){return s.levels.indexOf(n)>=s.levels.indexOf(e)}warn(e){this._log("warn",e,this.colors.warn)}info(e){this._log("info",e,this.colors.info)}debug(e){this._log("debug",e,this.colors.debug)}error(e){this._log("error",e,this.colors.error)}format(e,t){return this.messageFormat.replace("%t",(new Date).toISOString()).replace("%l",t.toUpperCase()).replace("%m",e)}_log(e,t,s){n&&this.canSend(e)&&(this.isBrowser?console.log(this.colors.start+this.format(t,e),s):console.log(s+this.format(t,e)+this.colors.end))}}var i,a,r;r=["error","warn","info","debug"],(a="levels")in(i=s)?Object.defineProperty(i,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[a]=r,e.exports=s}).call(this,n(85))},function(e,t,n){const{RPCError:s,InvalidDCError:i,FloodError:a,BadRequestError:r}=n(37);class o extends i{constructor(e){const t=Number(e.capture||0);super(`The user whose identity is being used to execute queries is associated with DC ${t}${s._fmtRequest(e.request)}`),this.message=`The user whose identity is being used to execute queries is associated with DC ${t}${s._fmtRequest(e.request)}`,this.newDc=t}}class c extends i{constructor(e){const t=Number(e.capture||0);super(`The phone number a user is trying to use for authorization is associated with DC ${t}${s._fmtRequest(e.request)}`),this.message=`The phone number a user is trying to use for authorization is associated with DC ${t}${s._fmtRequest(e.request)}`,this.newDc=t}}class u extends a{constructor(e){const t=Number(e.capture||0);super(`A wait of ${t} seconds is required before sending another message in this chat${s._fmtRequest(e.request)}`),this.message=`A wait of ${t} seconds is required before sending another message in this chat${s._fmtRequest(e.request)}`,this.seconds=t}}class d extends a{constructor(e){const t=Number(e.capture||0);super(`A wait of ${t} seconds is required${s._fmtRequest(e.request)}`),this.message=`A wait of ${t} seconds is required${s._fmtRequest(e.request)}`,this.seconds=t}}class l extends a{constructor(e){super("Message failed to be sent."+s._fmtRequest(e.request)),this.message="Message failed to be sent."+s._fmtRequest(e.request)}}class f extends a{constructor(e){const t=Number(e.capture||0);super(`A wait of ${t} seconds is required in the test servers${s._fmtRequest(e.request)}`),this.message=`A wait of ${t} seconds is required in the test servers${s._fmtRequest(e.request)}`,this.seconds=t}}class p extends i{constructor(e){const t=Number(e.capture||0);super(`The file to be accessed is currently stored in DC ${t}${s._fmtRequest(e.request)}`),this.message=`The file to be accessed is currently stored in DC ${t}${s._fmtRequest(e.request)}`,this.newDc=t}}class g extends i{constructor(e){const t=Number(e.capture||0);super(`The source IP address is associated with DC ${t}${s._fmtRequest(e.request)}`),this.message=`The source IP address is associated with DC ${t}${s._fmtRequest(e.request)}`,this.newDc=t}}class h extends r{constructor(e){const t=Number(e.capture||0);super(`Email unconfirmed, the length of the code must be ${t}${s._fmtRequest(e.request)}`),this.message=`Email unconfirmed, the length of the code must be ${t}${s._fmtRequest(e.request)}`,this.codeLength=t}}const m=[[/FILE_MIGRATE_(\d+)/,p],[/FLOOD_TEST_PHONE_WAIT_(\d+)/,f],[/FLOOD_WAIT_(\d+)/,d],[/MSG_WAIT_(.*)/,l],[/PHONE_MIGRATE_(\d+)/,c],[/SLOWMODE_WAIT_(\d+)/,u],[/USER_MIGRATE_(\d+)/,o],[/NETWORK_MIGRATE_(\d+)/,g],[/EMAIL_UNCONFIRMED_(\d+)/,h]];e.exports={rpcErrorRe:m,FileMigrateError:p,FloodTestPhoneWaitError:f,FloodWaitError:d,PhoneMigrateError:c,SlowModeWaitError:u,UserMigrateError:o,NetworkMigrateError:g,MsgWaitError:l,EmailUnconfirmedError:h}},function(e,t){e.exports=class{get dcId(){throw new Error("Not Implemented")}get serverAddress(){throw new Error("Not Implemented")}get port(){throw new Error("Not Implemented")}get authKey(){throw new Error("Not Implemented")}set authKey(e){throw new Error("Not Implemented")}setDC(e,t,n){throw new Error("Not implemented")}save(){throw new Error("Not Implemented")}delete(){throw new Error("Not Implemented")}}},function(e,t,n){const s=n(6),i={};for(const e of Object.values(s))if(e.CONSTRUCTOR_ID)i[e.CONSTRUCTOR_ID]=e;else for(const t of Object.values(e))i[t.CONSTRUCTOR_ID]=t;e.exports={LAYER:131,tlobjects:i}},function(e,t,n){const s=n(53),i=n(54),a=n(8),r=n(30),{doAuthentication:o}=n(86),c=n(57),u=n(39),d=n(33),l=n(88),{MsgsAck:f,upload:p,MsgsStateInfo:g,Pong:h}=n(24).constructors,m=n(58),b=n(26),{UpdateConnectionState:y,UpdateServerTimeOffset:_}=n(60),{BadMessageError:w}=n(25),{BadServerSalt:v,BadMsgNotification:A,MsgDetailedInfo:I,MsgNewDetailedInfo:P,NewSessionCreated:C,FutureSalts:S,MsgsStateReq:M,MsgResendReq:k,MsgsAllInfo:E}=n(24).constructors,{SecurityError:O}=n(25),{InvalidBufferError:R}=n(25),{LogOut:U}=n(24).requests.auth,{RPCMessageToError:T}=n(16),{TypeNotFoundError:D}=n(25);class B{constructor(e,t){const n={...B.DEFAULT_OPTIONS,...t};this._connection=void 0,this._log=n.logger,this._dcId=n.dcId,this._retries=n.retries,this._delay=n.delay,this._autoReconnect=n.autoReconnect,this._connectTimeout=n.connectTimeout,this._authKeyCallback=n.authKeyCallback,this._updateCallback=n.updateCallback,this._autoReconnectCallback=n.autoReconnectCallback,this._isMainSender=n.isMainSender,this._onConnectionBreak=n.onConnectionBreak,this.userDisconnected=!1,this._user_connected=!1,this._reconnecting=!1,this._disconnected=!0,this._send_loop_handle=void 0,this._recv_loop_handle=void 0,this.authKey=e||new r,this._state=new i(this.authKey,this._log),this._send_queue=new m(this._state,this._log),this._pending_state={},this._pending_ack=new Set,this._last_acks=[],this._handlers={[c.CONSTRUCTOR_ID]:this._handleRPCResult.bind(this),[u.CONSTRUCTOR_ID]:this._handleContainer.bind(this),[d.CONSTRUCTOR_ID]:this._handleGzipPacked.bind(this),[h.CONSTRUCTOR_ID]:this._handlePong.bind(this),[v.CONSTRUCTOR_ID]:this._handleBadServerSalt.bind(this),[A.CONSTRUCTOR_ID]:this._handleBadNotification.bind(this),[I.CONSTRUCTOR_ID]:this._handleDetailedInfo.bind(this),[P.CONSTRUCTOR_ID]:this._handleNewDetailedInfo.bind(this),[C.CONSTRUCTOR_ID]:this._handleNewSessionCreated.bind(this),[f.CONSTRUCTOR_ID]:this._handleAck.bind(this),[S.CONSTRUCTOR_ID]:this._handleFutureSalts.bind(this),[M.CONSTRUCTOR_ID]:this._handleStateForgotten.bind(this),[k.CONSTRUCTOR_ID]:this._handleStateForgotten.bind(this),[E.CONSTRUCTOR_ID]:this._handleMsgAll.bind(this)}}async connect(e,t){if(this._user_connected&&!t)return this._log.info("User is already connected!"),!1;this._connection=e;for(let e=0;en}).getBytes()):await o.gzipIfSmaller(s,n);const u=t.alloc(4);u.writeInt32LE(r,0);const d=t.alloc(4);d.writeInt32LE(c.length,0);const p=f(a,8);return e.write(t.concat([p,u,d])),e.write(c),a}async encryptMessageData(e){await this.authKey.waitForKey();const n=f(this.salt,8),s=f(this.id,8);e=t.concat([t.concat([n,s]),e]);const r=i.generateRandomBytes(i.mod(-(e.length+12),16)+12),o=(await i.sha256(t.concat([this.authKey.getKey().slice(88,120),e,r]))).slice(8,24),{iv:c,key:u}=await this._calcKey(this.authKey.getKey(),o,!0),d=i.readBufferFromBigInt(this.authKey.keyId,8);return t.concat([d,o,new a(u,c).encryptIge(t.concat([e,r]))])}async decryptMessageData(e){if(e.length<8)throw new d(e);if(e.length<0)throw new u("Server replied with negative length");if(e.length%4!=0)throw new u("Server replied with length not divisible by 4");if(i.readBigIntFromBuffer(e.slice(0,8)).neq(this.authKey.keyId))throw new u("Server replied with an invalid auth key");const n=e.slice(8,24),{iv:s,key:o}=await this._calcKey(this.authKey.getKey(),n,!1);e=new a(o,s).decryptIge(e.slice(24));const l=await i.sha256(t.concat([this.authKey.getKey().slice(96,128),e]));if(!n.equals(l.slice(8,24)))throw new u("Received msg_key doesn't match with expected one");const f=new r(e);f.readLong();if(!f.readLong().eq(this.id))throw new u("Server replied with a wrong session ID");const p=f.readLong(),g=f.readInt(),h=f.readInt(),m=e.length-h;if(m<12||m>1024)throw new u("Server replied with the wrong message padding");const b=f.tgReadObject();return new c(p,g,b)}_getNewMsgId(){const e=(new Date).getTime()/1e3+this.timeOffset,t=Math.floor(1e9*(e-Math.floor(e)));let n=s(Math.floor(e)).shiftLeft(s(32)).or(s(t).shiftLeft(s(2)));return this._lastMsgId.greaterOrEquals(n)&&(n=this._lastMsgId.add(s(4))),this._lastMsgId=n,n}updateTimeOffset(e){const t=this._getNewMsgId(),n=this.timeOffset,i=Math.floor((new Date).getTime()/1e3),a=e.shiftRight(s(32));return this.timeOffset=a-i,this.timeOffset!==n&&(this._lastMsgId=s(0),this._log.debug(`Updated time offset (old offset ${n}, bad ${t}, good ${e}, new ${this.timeOffset})`)),this.timeOffset}_getSeqNo(e){if(e){const e=2*this._sequence+1;return this._sequence+=1,e}return 2*this._sequence}}}).call(this,n(11).Buffer)},function(e,t,n){(function(t){const{IGE:s}=n(47),i=n(8);e.exports=class{constructor(e,t){this.ige=new s(e,t)}decryptIge(e){return i.convertToLittle(this.ige.decrypt(e))}encryptIge(e){const n=e.length%16;return n&&(e=t.concat([e,i.generateRandomBytes(16-n)])),i.convertToLittle(this.ige.encrypt(e))}}}).call(this,n(11).Buffer)},function(e,t,n){const s=n(38),i=n(57),a=n(39),r=n(33),o={[i.CONSTRUCTOR_ID]:i,[r.CONSTRUCTOR_ID]:r,[a.CONSTRUCTOR_ID]:a};e.exports={TLMessage:s,RPCResult:i,MessageContainer:a,GZIPPacked:r,coreObjects:o}},function(e,t,n){function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const{RpcError:i}=n(24).constructors,a=n(33);class r{constructor(e,t,n){this.CONSTRUCTOR_ID=4082920705,this.reqMsgId=e,this.body=t,this.error=n,this.classType="constructor"}static async fromReader(e){const t=e.readLong(),n=e.readInt(!1);return n===i.CONSTRUCTOR_ID?new r(t,void 0,i.fromReader(e)):n===a.CONSTRUCTOR_ID?new r(t,(await a.fromReader(e)).data):(e.seek(-4),new r(t,e.read(),void 0))}}s(r,"CONSTRUCTOR_ID",4082920705),s(r,"classType","constructor"),e.exports=r},function(e,t,n){(function(t){const s=n(39),i=n(38),a=n(59),r=["messages.SendMessage","messages.SendMedia","messages.SendMultiMedia","messages.ForwardMessages","messages.SendInlineBotResult"];e.exports=class{constructor(e,t){this._state=e,this._queue=[],this._pendingStates=[],this._ready=new Promise(e=>{this.setReady=e}),this._log=t}values(){return this._queue}append(e){if(e&&r.includes(e.request.className))for(let t=this._queue.length-1;t>=0;t--)if(r.includes(this._queue[t].request.className)){e.after=this._queue[t];break}this._queue.push(e),this.setReady(!0),e&&(this._pendingStates.push(e),e.promise.catch(()=>{}).finally(()=>{this._pendingStates=this._pendingStates.filter(t=>t!==e)}))}extend(e){for(const t of e)this._queue.push(t);this.setReady(!0)}async get(){if(this._queue.length||(this._ready=new Promise(e=>{this.setReady=e}),await this._ready),!this._queue[this._queue.length-1])return void(this._queue=[]);let e,n=new a(t.alloc(0));const r=[];let o=0;for(;this._queue.length&&r.length<=s.MAXIMUM_LENGTH;){const e=this._queue.shift();if(o+=e.data.length+i.SIZE_OVERHEAD,o<=s.MAXIMUM_SIZE){let t;e.after&&(t=e.after.msgId),e.msgId=await this._state.writeDataAsMessage(n,e.data,"request"===e.request.classType,t),this._log.debug(`Assigned msgId = ${e.msgId} to ${e.request.className||e.request.constructor.name}`),r.push(e)}else{if(r.length){this._queue.unshift(e);break}this._log.warn(`Message payload for ${e.request.className||e.request.constructor.name} is too long ${e.data.length} and cannot be sent`),e.reject("Request Payload is too big"),o=0}}if(r.length){if(r.length>1){const i=t.alloc(8);i.writeUInt32LE(s.CONSTRUCTOR_ID,0),i.writeInt32LE(r.length,4),e=t.concat([i,n.getValue()]),n=new a(t.alloc(0));const o=await this._state.writeDataAsMessage(n,e,!1);for(const e of r)e.containerId=o}return e=n.getValue(),{batch:r,data:e}}}rejectAll(){this._pendingStates.forEach(e=>{e.reject(new Error("Disconnect"))})}}}).call(this,n(11).Buffer)},function(e,t,n){(function(t){e.exports=class{constructor(e){this._stream=e}write(e){this._stream=t.concat([this._stream,e])}getValue(){return this._stream}}}).call(this,n(11).Buffer)},function(e,t,n){function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const i=n(53),a=n(52);class r{constructor(e){this.state=e}}s(r,"disconnected",-1),s(r,"connected",1),s(r,"broken",0);const{Connection:o,ConnectionTCPFull:c,ConnectionTCPAbridged:u,ConnectionTCPObfuscated:d}=n(89);e.exports={Connection:o,ConnectionTCPFull:c,ConnectionTCPAbridged:u,ConnectionTCPObfuscated:d,MTProtoPlainSender:i,MTProtoSender:a,UpdateConnectionState:r,UpdateServerTimeOffset:class{constructor(e){this.timeOffset=e}}}},function(e,t,n){(function(t){const{Mutex:s}=n(90),i=new s,a=n(92).w3cwebsocket,r=new Error("WebSocket was closed");e.exports=class{constructor(){this.client=void 0,this.closed=!0}async readExactly(e){let n=t.alloc(0);for(;;){const s=await this.read(e);if(n=t.concat([n,s]),!(e-=s.length))return n}}async read(e){if(this.closed)throw r;if(await this.canRead,this.closed)throw r;const t=this.stream.slice(0,e);return this.stream=this.stream.slice(e),0===this.stream.length&&(this.canRead=new Promise(e=>{this.resolveRead=e})),t}async readAll(){if(this.closed||!await this.canRead)throw r;const e=this.stream;return this.stream=t.alloc(0),this.canRead=new Promise(e=>{this.resolveRead=e}),e}getWebSocketLink(e,t){return 443===t?`wss://${e}:${t}/apiws`:`ws://${e}:${t}/apiws`}connect(e,n){return this.stream=t.alloc(0),this.canRead=new Promise(e=>{this.resolveRead=e}),this.closed=!1,this.website=this.getWebSocketLink(n,e),this.client=new a(this.website,"binary"),new Promise((e,t)=>{this.client.onopen=()=>{this.receive(),e(this)},this.client.onerror=e=>{t(e)},this.client.onclose=()=>{this.resolveRead(!1),this.closed=!0},self.addEventListener("offline",async()=>{await this.close(),this.resolveRead(!1)})})}write(e){if(this.closed)throw r;this.client.send(e)}async close(){await this.client.close(),this.closed=!0}receive(){this.client.onmessage=async e=>{const n=await i.acquire();try{const s=e.data instanceof ArrayBuffer?t.from(e.data):t.from(await new Response(e.data).arrayBuffer());this.stream=t.concat([this.stream,s]),this.resolveRead(!0)}finally{n()}}}}}).call(this,n(11).Buffer)},function(e,t){e.exports=class{constructor(){this._queue=[],this.canGet=new Promise(e=>{this.resolveGet=e}),this.canPush=!0}async push(e){await this.canPush,this._queue.push(e),this.resolveGet(!0),this.canPush=new Promise(e=>{this.resolvePush=e})}async pop(){await this.canGet;const e=this._queue.pop();return this.resolvePush(!0),this.canGet=new Promise(e=>{this.resolveGet=e}),e}}},function(e,t,n){(function(t){function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const i=n(15),{readBufferFromBigInt:a}=n(8),{Connection:r,PacketCodec:o}=n(40);class c extends o{constructor(e){super(e),this.tag=c.tag,this.obfuscateTag=c.obfuscateTag}encodePacket(e){let n=e.length>>2;if(n<127){const e=t.alloc(1);e.writeUInt8(n,0),n=e}else n=t.concat([t.from("7f","hex"),a(i(n),3)]);return t.concat([n,e])}async readPacket(e){let n=(await e.read(1))[0];return n>=127&&(n=t.concat([await e.read(3),t.alloc(1)]).readInt32LE(0)),e.read(n<<2)}}s(c,"tag",t.from("ef","hex")),s(c,"obfuscateTag",t.from("efefefef","hex"));e.exports={ConnectionTCPAbridged:class extends r{constructor(...e){super(...e),s(this,"PacketCodecClass",c)}},AbridgedPacketCodec:c}}).call(this,n(11).Buffer)},function(e,t,n){(function(t){function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const{generateRandomBytes:i}=n(8),{ObfuscatedConnection:a}=n(40),{AbridgedPacketCodec:r}=n(63),o=n(96);class c{constructor(e){s(this,"header",void 0),this.connection=e.socket;const t=this.initHeader(e.PacketCodecClass);this.header=t.random,this._encrypt=t.encryptor,this._decrypt=t.decryptor}initHeader(e){const n=[t.from("50567247","hex"),t.from("474554","hex"),t.from("504f5354","hex"),t.from("eeeeeeee","hex")];let s;for(;;)if(s=i(64),239!==s[0]&&!s.slice(4,8).equals(t.alloc(4))){let e=!0;for(const t of n)if(t.equals(s.slice(0,4))){e=!1;break}if(e)break}s=s.toJSON().data;const a=t.from(s.slice(8,56)).reverse(),r=t.from(s.slice(8,40)),c=t.from(s.slice(40,56)),u=t.from(a.slice(0,32)),d=t.from(a.slice(32,48)),l=new o(r,c),f=new o(u,d);return s=t.concat([t.from(s.slice(0,56)),e.obfuscateTag,t.from(s.slice(60))]),s=t.concat([t.from(s.slice(0,56)),t.from(l.encrypt(s).slice(56,64)),t.from(s.slice(64))]),{random:s,encryptor:l,decryptor:f}}async read(e){const t=await this.connection.readExactly(e);return this._decrypt.encrypt(t)}write(e){this.connection.write(this._encrypt.encrypt(e))}}e.exports={ConnectionTCPObfuscated:class extends a{constructor(...e){super(...e),s(this,"ObfuscatedIO",c),s(this,"PacketCodecClass",r)}}}}).call(this,n(11).Buffer)},function(e,t){},function(e,t){},function(e,t,n){"use strict";let s;n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return a})),function(e){e.Bold="MessageEntityBold",e.Blockquote="MessageEntityBlockquote",e.BotCommand="MessageEntityBotCommand",e.Cashtag="MessageEntityCashtag",e.Code="MessageEntityCode",e.Email="MessageEntityEmail",e.Hashtag="MessageEntityHashtag",e.Italic="MessageEntityItalic",e.MentionName="MessageEntityMentionName",e.Mention="MessageEntityMention",e.Phone="MessageEntityPhone",e.Pre="MessageEntityPre",e.Strike="MessageEntityStrike",e.TextUrl="MessageEntityTextUrl",e.Url="MessageEntityUrl",e.Underline="MessageEntityUnderline",e.Unknown="MessageEntityUnknown"}(s||(s={}));const i=-1,a="MESSAGE_DELETED"},function(e,t){},function(e,t,n){"use strict";let s;n.d(t,"a",(function(){return s})),function(e){e[e.DataUri=0]="DataUri",e[e.BlobUrl=1]="BlobUrl",e[e.Lottie=2]="Lottie",e[e.Progressive=3]="Progressive",e[e.Stream=4]="Stream"}(s||(s={}))},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return r}));var s=n(15),i=n.n(s);n(8);const a=[{fingerprint:i()("-3414540481677951611"),n:i()("29379598170669337022986177149456128565388431120058863768162556424047512191330847455146576344487764408661701890505066208632169112269581063774293102577308490531282748465986139880977280302242772832972539403531316010870401287642763009136156734339538042419388722777357134487746169093539093850251243897188928735903389451772730245253062963384108812842079887538976360465290946139638691491496062099570836476454855996319192747663615955633778034897140982517446405334423701359108810182097749467210509584293428076654573384828809574217079944388301239431309115013843331317877374435868468779972014486325557807783825502498215169806323"),e:65537}],r=new Map;a.forEach(({fingerprint:e,...t})=>{r.set(e.toString(),t)})}).call(this,n(11).Buffer)},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],s=t[1];return 3*(n+s)/4-s},t.toByteArray=function(e){var t,n,s=u(e),r=s[0],o=s[1],c=new a(function(e,t,n){return 3*(t+n)/4-n}(0,r,o)),d=0,l=o>0?r-4:r;for(n=0;n>16&255,c[d++]=t>>8&255,c[d++]=255&t;2===o&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,c[d++]=255&t);1===o&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,c[d++]=t>>8&255,c[d++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,a=[],r=0,o=n-i;ro?o:r+16383));1===i?(t=e[n-1],a.push(s[t>>2]+s[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],a.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return a.join("")};for(var s=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,c=r.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function d(e,t,n){for(var i,a,r=[],o=t;o>18&63]+s[a>>12&63]+s[a>>6&63]+s[63&a]);return r.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,s,i){var a,r,o=8*i-s-1,c=(1<>1,d=-7,l=n?i-1:0,f=n?-1:1,p=e[t+l];for(l+=f,a=p&(1<<-d)-1,p>>=-d,d+=o;d>0;a=256*a+e[t+l],l+=f,d-=8);for(r=a&(1<<-d)-1,a>>=-d,d+=s;d>0;r=256*r+e[t+l],l+=f,d-=8);if(0===a)a=1-u;else{if(a===c)return r?NaN:1/0*(p?-1:1);r+=Math.pow(2,s),a-=u}return(p?-1:1)*r*Math.pow(2,a-s)},t.write=function(e,t,n,s,i,a){var r,o,c,u=8*a-i-1,d=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=s?0:a-1,g=s?1:-1,h=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,r=d):(r=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-r))<1&&(r--,c*=2),(t+=r+l>=1?f/c:f*Math.pow(2,1-l))*c>=2&&(r++,c/=2),r+l>=d?(o=0,r=d):r+l>=1?(o=(t*c-1)*Math.pow(2,i),r+=l):(o=t*Math.pow(2,l-1)*Math.pow(2,i),r=0));i>=8;e[n+p]=255&o,p+=g,o/=256,i-=8);for(r=r<0;e[n+p]=255&r,p+=g,r/=256,u-=8);e[n+p-g]|=128*h}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";function s(e){const t=new Uint8Array(4*e.length);let n=0;for(let s=0;s>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=255&i}return t.buffer}function i(e){return e.buffer}function a(e){const t=new Uint8Array(e),n=new Uint32Array(t.length/4);for(let e=0;enew p.InvokeWithLayer({layer:l,query:new p.InitConnection({apiId:this.apiId,deviceModel:r.deviceModel||s.type().toString()||"Unknown",systemVersion:r.systemVersion||s.release().toString()||"1.0",appVersion:r.appVersion||"1.0",langCode:r.langCode,langPack:"",systemLangCode:r.systemLangCode,query:e,proxy:void 0})}),this._args=r,this._config=void 0,this.phoneCodeHashes=[],this._borrowedSenderPromises={},this._borrowedSenderReleaseTimeouts={},this._additionalDcsDisabled=r.additionalDcsDisabled}async connect(){await this._initSession(),this._sender=new g(this.session.getAuthKey(),{logger:this._log,dcId:this.session.dcId,retries:this._connectionRetries,delay:this._retryDelay,autoReconnect:this._autoReconnect,connectTimeout:this._timeout,authKeyCallback:this._authKeyCallback.bind(this),updateCallback:this._handleUpdate.bind(this),isMainSender:!0});const e=new this._connection(this.session.serverAddress,this.session.port,this.session.dcId,this._log);await this._sender.connect(e),this.session.setAuthKey(this._sender.authKey),await this._sender.send(this._initWith(new p.help.GetConfig({}))),this._updateLoop()}async _initSession(){await this.session.load(),this.session.serverAddress&&this.session.serverAddress.includes(":")===this._useIPV6||this.session.setDC(2,this._useIPV6?"[2001:67c:4e8:f002::a]":"venus.web.telegram.org",this._args.useWSS?443:80)}async _updateLoop(){for(;this.isConnected();){await c.sleep(3e3);try{await S(()=>{return e=this._sender.send(new p.PingDelayDisconnect({pingId:c.getRandomInt(Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),disconnectDelay:6e4})),t=5e3,Promise.race([e,c.sleep(t).then(()=>Promise.reject(new Error("TIMEOUT")))]);var e,t},3,100)}catch(e){return console.warn(e),await this.disconnect(),void this.connect()}if((new Date).getTime()-this._lastRequest>18e5)try{await this.invoke(new p.updates.GetState)}catch(e){}}}async disconnect(){this._sender&&await this._sender.disconnect(),await Promise.all(Object.values(this._borrowedSenderPromises).map(e=>e&&e.then(e=>{if(e)return e.disconnect()}))),this._borrowedSenderPromises={}}async destroy(){try{await this.disconnect()}catch(e){}this.session.delete(),this._eventBuilders=[]}async _switchDC(e){this._log.info("Reconnecting to new data center "+e);const t=u.getDC(e);return this.session.setDC(e,t.ipAddress,t.port),await this._sender.authKey.setKey(void 0),this.session.setAuthKey(void 0),await this.disconnect(),this.connect()}_authKeyCallback(e,t){this.session.setAuthKey(e,t)}_cleanupBorrowedSender(e){this._borrowedSenderPromises[e]=void 0}_borrowExportedSender(e){if(!this._additionalDcsDisabled)return this._borrowedSenderPromises[e]||(this._borrowedSenderPromises[e]=this._createExportedSender(e)),this._borrowedSenderPromises[e].then(t=>t?(this._borrowedSenderReleaseTimeouts[e]&&(clearTimeout(this._borrowedSenderReleaseTimeouts[e]),this._borrowedSenderReleaseTimeouts[e]=void 0),this._borrowedSenderReleaseTimeouts[e]=setTimeout(()=>{this._borrowedSenderReleaseTimeouts[e]=void 0,this._borrowedSenderPromises[e]=void 0,t.disconnect()},3e4),t):(this._borrowedSenderPromises[e]=void 0,this._borrowExportedSender(e)))}async _createExportedSender(e){const t=u.getDC(e),n=new g(this.session.getAuthKey(e),{logger:this._log,dcId:e,retries:this._connectionRetries,delay:this._retryDelay,autoReconnect:this._autoReconnect,connectTimeout:this._timeout,authKeyCallback:this._authKeyCallback.bind(this),isMainSender:e===this.session.dcId,onConnectionBreak:this._cleanupBorrowedSender.bind(this)});for(let s=0;s<5;s++)try{if(await n.connect(new this._connection(t.ipAddress,t.port,e,this._log)),this.session.dcId!==e){this._log.info("Exporting authorization for data center "+t.ipAddress);const s=await this.invoke(new p.auth.ExportAuthorization({dcId:e})),i=this._initWith(new p.auth.ImportAuthorization({id:s.id,bytes:s.bytes}));await n.send(i)}return n.dcId=e,n}catch(e){await n.disconnect()}}downloadFile(e,t={}){return y(this,e,t)}downloadMedia(e,t){let n;if(n=e instanceof f.Message?e.media:e,"string"==typeof n)throw new Error("not implemented");return n instanceof f.MessageMediaWebPage&&n.webpage instanceof f.WebPage&&(n=n.webpage.document||n.webpage.photo),n instanceof f.MessageMediaPhoto||n instanceof f.Photo?this._downloadPhoto(n,t):n instanceof f.MessageMediaDocument||n instanceof f.Document?this._downloadDocument(n,t):n instanceof f.MessageMediaContact?this._downloadContact(n,t):n instanceof f.WebDocument||n instanceof f.WebDocumentNoProxy?this._downloadWebDocument(n,t):void 0}downloadProfilePhoto(e,t=!1){const n=t?"x":"m";let s,i,a;if([765557111,3316604308,524706233,3566872215].includes(e.SUBCLASS_OF_ID)){if(!e.photo){if(!e.chatPhoto)return;return this._downloadPhoto(e.chatPhoto,{sizeType:n})}s=e.photo}else s=e;if(s instanceof f.UserProfilePhoto||s instanceof f.ChatPhoto)return i=s.dcId,a=new f.InputPeerPhotoFileLocation({peer:u.getInputPeer(e),photoId:s.photoId,big:t}),this.downloadFile(a,{dcId:i})}downloadStickerSetThumb(e){if(!e.thumbs||!e.thumbs.length)return;const{thumbVersion:t}=e;return this.downloadFile(new f.InputStickerSetThumb({stickerset:new f.InputStickerSetID({id:e.id,accessHash:e.accessHash}),thumbVersion:t}),{dcId:e.thumbDcId})}_pickFileSize(e,t){if(!t||!e||!e.length)return;let n;for(let s=v.indexOf(t);se.type===v[s]),n)return n}_downloadCachedPhotoSize(e){let t;return t=e instanceof f.PhotoStrippedSize?u.strippedPhotoToJpg(e.bytes):e.bytes,t}_downloadPhoto(e,t){if(e instanceof f.MessageMediaPhoto&&(e=e.photo),!(e instanceof f.Photo))return;const n=this._pickFileSize(e.sizes,t.sizeType);return!n||n instanceof f.PhotoSizeEmpty?void 0:n instanceof f.PhotoCachedSize||n instanceof f.PhotoStrippedSize?this._downloadCachedPhotoSize(n):this.downloadFile(new f.InputPhotoFileLocation({id:e.id,accessHash:e.accessHash,fileReference:e.fileReference,thumbSize:n.type}),{dcId:e.dcId,fileSize:n.size,progressCallback:t.progressCallback})}_downloadDocument(e,t){if(e instanceof f.MessageMediaDocument&&(e=e.document),!(e instanceof f.Document))return;let n;if(t.sizeType){if(n=e.thumbs?this._pickFileSize(e.thumbs,t.sizeType):void 0,!n&&e.mimeType.startsWith("video/"))return;if(n&&(n instanceof f.PhotoCachedSize||n instanceof f.PhotoStrippedSize))return this._downloadCachedPhotoSize(n)}return this.downloadFile(new f.InputDocumentFileLocation({id:e.id,accessHash:e.accessHash,fileReference:e.fileReference,thumbSize:n?n.type:""}),{fileSize:n?n.size:e.size,progressCallback:t.progressCallback,start:t.start,end:t.end,dcId:e.dcId,workers:t.workers})}_downloadContact(e,t){throw new Error("not implemented")}async _downloadWebDocument(e){try{const n=[];let s=0;for(;;){const t=new p.upload.GetWebFile({location:new f.InputWebFileLocation({url:e.url,accessHash:e.accessHash}),offset:s,limit:131072}),i=await this._borrowExportedSender(4),a=await i.send(t);if(s+=131072,!a.bytes.length)break;if(n.push(a.bytes),a.bytes.length<131072)break}return t.concat(n)}catch(e){if("WEBFILE_NOT_AVAILABLE"===e.message)return t.alloc(0);throw e}}async invoke(e){if("request"!==e.classType)throw new Error("You can only invoke MTProtoRequests");this._lastRequest=(new Date).getTime();let t=0;for(t=0;t1)for(var n=1;n144)throw new a.SecurityError("Step 1 invalid nonce from server");let A,I;for(const e of g.serverPublicKeyFingerprints)if(I=r.a.get(e.toString()),void 0!==I){A=e;break}if(void 0===A||void 0===I)throw new a.SecurityError("Step 2 could not find a valid key for fingerprints");const P=l.generateRandomBytes(192-v.length),C=e.concat([v,P]),S=e.from(C).reverse();let M;for(let t=0;t<20;t++){const t=l.generateRandomBytes(32),s=await l.sha256(e.concat([t,C])),i=e.concat([S,s]),a=new c(t,e.alloc(32)).encryptIge(i),r=l.bufferXor(t,await l.sha256(a)),u=e.concat([r,a]),d=l.readBigIntFromBuffer(u,!1,!1);if(d.greaterOrEquals(I.n)){n.debug("Aes key greater than RSA. retrying");continue}const f=l.modExp(d,o(I.e),I.n);M=l.readBufferFromBigInt(f,256,!1,!1);break}if(void 0===M)throw new a.SecurityError("Step 2 could create a secure encrypted key");n.debug("Step 2 : Generated a secure aes encrypted data");const k=await t.send(new i.a.ReqDHParams({nonce:g.nonce,serverNonce:g.serverNonce,p:y,q:_,publicKeyFingerprint:A,encryptedData:M}));if(!(k instanceof i.a.ServerDHParamsOk||k instanceof i.a.ServerDHParamsFail))throw new Error("Step 2.1 answer was "+k);if(k.nonce.neq(g.nonce))throw new a.SecurityError("Step 2 invalid nonce from server");if(k.serverNonce.neq(g.serverNonce))throw new a.SecurityError("Step 2 invalid server nonce from server");if(k instanceof i.a.ServerDHParamsFail){const e=await l.sha1(l.toSignedLittleBuffer(w,32).slice(4,20)),t=l.readBigIntFromBuffer(e,!0,!0);if(k.newNonceHash.neq(t))throw new a.SecurityError("Step 2 invalid DH fail nonce from server")}if(!(k instanceof i.a.ServerDHParamsOk))throw new Error("Step 2.2 answer was "+k);n.debug("Finished authKey generation step 2"),n.debug("Starting authKey generation step 3");const{key:E,iv:O}=await l.generateKeyDataFromNonce(g.serverNonce,w);if(k.encryptedAnswer.length%16!=0)throw new a.SecurityError("Step 3 AES block size mismatch");const R=new c(E,O),U=R.decryptIge(k.encryptedAnswer),T=new f(U);T.read(20);const D=T.tgReadObject();if(!(D instanceof i.a.ServerDHInnerData))throw new Error("Step 3 answer was "+D);if(D.nonce.neq(g.nonce))throw new a.SecurityError("Step 3 Invalid nonce in encrypted answer");if(D.serverNonce.neq(g.serverNonce))throw new a.SecurityError("Step 3 Invalid server nonce in encrypted answer");const B=l.readBigIntFromBuffer(D.dhPrime,!1,!1),x=l.readBigIntFromBuffer(D.gA,!1,!1),j=D.serverTime-Math.floor((new Date).getTime()/1e3),N=l.readBigIntFromBuffer(l.generateRandomBytes(256),!1,!1),V=l.modExp(o(D.g),N,B),F=l.modExp(x,N,B),L=new i.a.ClientDHInnerData({nonce:g.nonce,serverNonce:g.serverNonce,retryId:o.zero,gB:l.getByteArray(V,!1)}).getBytes(),q=e.concat([await l.sha1(L),L]),H=R.encryptIge(q),G=await t.send(new i.a.SetClientDHParams({nonce:g.nonce,serverNonce:g.serverNonce,encryptedData:H})),z=[i.a.DhGenOk,i.a.DhGenRetry,i.a.DhGenFail];if(!(G instanceof z[0]||G instanceof z[1]||G instanceof z[2]))throw new Error("Step 3.1 answer was "+G);const{name:K}=G.constructor;if(G.nonce.neq(g.nonce))throw new a.SecurityError(`Step 3 invalid ${K} nonce from server`);if(G.serverNonce.neq(g.serverNonce))throw new a.SecurityError(`Step 3 invalid ${K} server nonce from server`);const W=new u;await W.setKey(l.getByteArray(F));const $=1+["DhGenOk","DhGenRetry","DhGenFail"].indexOf(G.className),J=await W.calcNewNonceHash(w,$);if(G["newNonceHash"+$].neq(J))throw new a.SecurityError("Step 3 invalid new nonce hash");if(!(G instanceof i.a.DhGenOk))throw new Error("Step 3.2 answer was "+G);return n.debug("Finished authKey generation step 3"),{authKey:W,timeOffset:j}}}.call(this,n(11).Buffer)},function(e,t,n){const s=n(15),{modExp:i}=n(8);class a{static gcd(e,t){for(;t.neq(s.zero);){const n=t;t=e.remainder(t),e=n}return e}static factorize(e){if(e.remainder(2).equals(s.zero))return{p:s(2),q:e.divide(s(2))};let t=s.randBetween(s(1),e.minus(1));const n=s.randBetween(s(1),e.minus(1)),r=s.randBetween(s(1),e.minus(1));let o,c=s.one,u=s.one,d=s.one,l=s.zero,f=s.zero;for(;c.eq(s.one);){l=t;for(let a=0;s(a).lesser(u);a++)t=i(t,s(2),e).add(n).remainder(e);for(o=s.zero;o.lesser(u)&&c.eq(s.one);){f=t;const p=s.min(r,u.minus(o));for(let a=0;s(a).lesser(p);a++)t=i(t,s(2),e).add(n).remainder(e),d=d.multiply(l.minus(t).abs()).remainder(e);c=a.gcd(d,e),o=o.add(r)}u=u.multiply(2)}if(c.eq(e))for(;f=i(f,s(2),e).add(n).remainder(e),c=a.gcd(l.minus(f).abs(),e),!c.greater(1););const p=c;return d=e.divide(c),p{this.resolve=e,this.reject=t})}isReady(){const e=this.pending[this.after.id];return!e||e.deferred.promise}}},function(e,t,n){const{Connection:s}=n(40),{ConnectionTCPFull:i}=n(95),{ConnectionTCPAbridged:a}=n(63),{ConnectionTCPObfuscated:r}=n(64);e.exports={Connection:s,ConnectionTCPFull:i,ConnectionTCPAbridged:a,ConnectionTCPObfuscated:r}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=n(91);t.Mutex=s.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(){this._queue=[],this._pending=!1}return e.prototype.isLocked=function(){return this._pending},e.prototype.acquire=function(){var e=this,t=new Promise((function(t){return e._queue.push(t)}));return this._pending||this._dispatchNext(),t},e.prototype.runExclusive=function(e){return this.acquire().then((function(t){var n;try{n=e()}catch(e){throw t(),e}return Promise.resolve(n).then((function(e){return t(),e}),(function(e){throw t(),e}))}))},e.prototype._dispatchNext=function(){this._queue.length>0?(this._pending=!0,this._queue.shift()(this._dispatchNext.bind(this))):this._pending=!1},e}();t.default=s},function(e,t,n){(function(t){var s=function(){return this||void 0===t?this:t}(),i=s.WebSocket||s.MozWebSocket,a=n(93);function r(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(r,e,{get:function(){return i[e]}})})),e.exports={w3cwebsocket:i?r:null,version:a}}).call(this,n(45))},function(e,t,n){e.exports=n(94).version},function(e){e.exports=JSON.parse('{"_args":[["websocket@1.0.30","/Users/alexander/dev/telegram-tt"]],"_from":"websocket@1.0.30","_id":"websocket@1.0.30","_inBundle":false,"_integrity":"sha512-aO6klgaTdSMkhfl5VVJzD5fm+Srhh5jLYbS15+OiI1sN6h/RU/XW6WN9J1uVIpUKNmsTvT3Hs35XAFjn9NMfOw==","_location":"/websocket","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"websocket@1.0.30","name":"websocket","escapedName":"websocket","rawSpec":"1.0.30","saveSpec":null,"fetchSpec":"1.0.30"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/websocket/-/websocket-1.0.30.tgz","_spec":"1.0.30","_where":"/Users/alexander/dev/telegram-tt","author":{"name":"Brian McKelvey","email":"theturtle32@gmail.com","url":"https://github.com/theturtle32"},"browser":"lib/browser.js","bugs":{"url":"https://github.com/theturtle32/WebSocket-Node/issues"},"config":{"verbose":false},"contributors":[{"name":"Iñaki Baz Castillo","email":"ibc@aliax.net","url":"http://dev.sipdoc.net"}],"dependencies":{"debug":"^2.2.0","nan":"^2.14.0","typedarray-to-buffer":"^3.1.5","yaeti":"^0.0.6"},"description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","devDependencies":{"buffer-equal":"^1.0.0","faucet":"^0.0.1","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint":"^2.0.0","jshint-stylish":"^2.2.1","tape":"^4.9.1"},"directories":{"lib":"./lib"},"engines":{"node":">=0.10.0"},"homepage":"https://github.com/theturtle32/WebSocket-Node","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"license":"Apache-2.0","main":"index","name":"websocket","repository":{"type":"git","url":"git+https://github.com/theturtle32/WebSocket-Node.git"},"scripts":{"gulp":"gulp","install":"(node-gyp rebuild 2> builderror.log) || (exit 0)","test":"faucet test/unit"},"version":"1.0.30"}')},function(e,t){},function(e,t,n){(function(t){const s=n(36);e.exports=class{constructor(e,n){if(!t.isBuffer(e)||!t.isBuffer(n)||16!==n.length)throw new Error("Key and iv need to be a buffer");this.cipher=s.createCipheriv("AES-256-CTR",e,n)}encrypt(e){return t.from(this.cipher.update(e))}}}).call(this,n(11).Buffer)},function(e,t,n){"use strict";n.r(t),n.d(t,"authFlow",(function(){return d})),n.d(t,"checkAuthorization",(function(){return l}));var s=n(6),i=n.n(s),a=n(21),r=n.n(a),o=n(8),c=n(32);const u="phoneNumber";async function d(e,t,n){let s;if("botAuthToken"in n)s=await async function(e,t,n){const{apiId:s,apiHash:a}=t,{botAuthToken:r}=n,{user:o}=await e.invoke(new i.a.auth.ImportBotAuthorization({apiId:s,apiHash:a,botAuthToken:r}));return o}(e,t,n);else{const{initialMethod:i=u}=n;s="phoneNumber"===i?await f(e,t,n):await p(e,t,n)}e._log.info("Signed in successfully as",r.a.getDisplayName(s))}async function l(e){try{return await e.invoke(new i.a.updates.GetState),!0}catch(e){return!1}}async function f(e,t,n){let s,a,r,o=!1;for(;;)try{if("function"==typeof n.phoneNumber)try{s=await n.phoneNumber()}catch(s){if("RESTART_AUTH_WITH_QR"===s.message)return p(e,t,n);throw s}else s=n.phoneNumber;const i=await g(e,t,s,n.forceSMS);if(a=i.phoneCodeHash,o=i.isCodeViaApp,"string"!=typeof a)throw new Error("Failed to retrieve phone code hash");break}catch(e){if("function"!=typeof n.phoneNumber)throw e;n.onError(e)}let c,u=!1;for(;;)try{try{r=await n.phoneCode(o)}catch(s){if("RESTART_AUTH"===s.message)return f(e,t,n)}if(!r)throw new Error("Code is empty");const d=await e.invoke(new i.a.auth.SignIn({phoneNumber:s,phoneCodeHash:a,phoneCode:r}));if(d instanceof i.a.auth.AuthorizationSignUpRequired){u=!0,c=d.termsOfService;break}return d.user}catch(s){if("SESSION_PASSWORD_NEEDED"===s.message)return h(e,t,n);n.onError(s)}if(u)for(;;)try{const[t,r]=await n.firstAndLastNames();if(!t)throw new Error("First name is required");const{user:o}=await e.invoke(new i.a.auth.SignUp({phoneNumber:s,phoneCodeHash:a,firstName:t,lastName:r}));return c&&await e.invoke(new i.a.help.AcceptTermsOfService({id:c.id})),o}catch(e){n.onError(e)}return n.onError(new Error("Auth failed")),f(e,t,n)}async function p(e,t,n){let s=!1;const a=(async()=>{for(;!s;){const t=await e.invoke(new i.a.auth.ExportLoginToken({apiId:Number("2496"),apiHash:"8da85b0d5bfe62527e5b244c209159c3",exceptIds:[]}));if(!(t instanceof i.a.auth.LoginToken))throw new Error("Unexpected");const{token:s,expires:a}=t;await Promise.race([n.qrCode({token:s,expires:a}),Object(o.sleep)(3e4)])}})(),r=new Promise(t=>{e.addEventHandler(e=>{e instanceof i.a.UpdateLoginToken&&t()},{build:e=>e})});try{await Promise.race([r,a])}catch(s){if("RESTART_AUTH"===s.message)return f(e,t,n);throw s}finally{s=!0}try{const t=await e.invoke(new i.a.auth.ExportLoginToken({apiId:Number("2496"),apiHash:"8da85b0d5bfe62527e5b244c209159c3",exceptIds:[]}));if(t instanceof i.a.auth.LoginTokenSuccess&&t.authorization instanceof i.a.auth.Authorization)return t.authorization.user;if(t instanceof i.a.auth.LoginTokenMigrateTo){await e._switchDC(t.dcId);const n=await e.invoke(new i.a.auth.ImportLoginToken({token:t.token}));if(n instanceof i.a.auth.LoginTokenSuccess&&n.authorization instanceof i.a.auth.Authorization)return n.authorization.user}}catch(s){if("SESSION_PASSWORD_NEEDED"===s.message)return h(e,t,n);throw s}throw void 0}async function g(e,t,n,s=!1){try{const{apiId:a,apiHash:r}=t,o=await e.invoke(new i.a.auth.SendCode({phoneNumber:n,apiId:a,apiHash:r,settings:new i.a.CodeSettings}));if(!s||o.type instanceof i.a.auth.SentCodeTypeSms)return{phoneCodeHash:o.phoneCodeHash,isCodeViaApp:o.type instanceof i.a.auth.SentCodeTypeApp};const c=await e.invoke(new i.a.auth.ResendCode({phoneNumber:n,phoneCodeHash:o.phoneCodeHash}));return{phoneCodeHash:c.phoneCodeHash,isCodeViaApp:c.type instanceof i.a.auth.SentCodeTypeApp}}catch(i){if("AUTH_RESTART"===i.message)return g(e,t,n,s);throw i}}async function h(e,t,n){for(;;)try{const t=await e.invoke(new i.a.account.GetPassword),s=await n.password(t.hint);if(!s)throw new Error("Password is empty");const a=await Object(c.computeCheck)(t,s),{user:r}=await e.invoke(new i.a.auth.CheckPassword({password:a}));return r}catch(e){n.onError(e)}}},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"downloadFile",(function(){return u}));var s=n(6),i=n.n(s),a=n(21),r=n(8);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class c{constructor(e){this.maxWorkers=e,o(this,"deferred",void 0),o(this,"activeWorkers",0)}requestWorker(){return this.activeWorkers++,this.activeWorkers>this.maxWorkers?(this.deferred=Object(r.createDeferred)(),this.deferred.promise):Promise.resolve()}releaseWorker(){this.activeWorkers--,this.deferred&&this.activeWorkers<=this.maxWorkers&&this.deferred.resolve()}}async function u(t,n,s){let{partSizeKb:o,end:u}=s;const{fileSize:d,workers:l=1}=s,{dcId:f,progressCallback:p,start:g=0}=s;u=u&&u{try{const s=await Promise.race([await b.send(new i.a.upload.GetFile({location:n,offset:w,limit:e,precise:t||void 0})),Object(r.sleep)(15e3).then(()=>Promise.reject(new Error("REQUEST_TIMEOUT")))]);if(p){if(p.isCanceled)throw new Error("USER_CANCELED");A+=1/m,p(A)}return!u&&s.bytes.lengthu)break}const I=(await Promise.all(_)).filter(Boolean),P=u?u+1-g:void 0;return e.concat(I,P)}}.call(this,n(11).Buffer)},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"uploadFile",(function(){return o}));var s=n(6),i=n.n(s),a=n(8),r=n(21);async function o(t,n){const{file:s,onProgress:o}=n;let{workers:c}=n;const{name:u,size:d}=s,l=Object(a.readBigIntFromBuffer)(Object(a.generateRandomBytes)(8),!0,!0),f=d>10485760,p=1024*Object(r.getAppropriatedPartSize)(d),g=Math.floor((d+p-1)/p),h=e.from(await function(e){return new Response(e).arrayBuffer()}(s)),m=await t._borrowExportedSender(t.session.dcId);c&&d||(c=1),c>=g&&(c=g);let b=0;o&&o(b);for(let e=0;eg&&(n=g);for(let s=e;s{if(await m.send(f?new i.a.upload.SaveBigFilePart({fileId:l,filePart:s,fileTotalParts:g,bytes:e}):new i.a.upload.SaveFilePart({fileId:l,filePart:s,bytes:e})),o){if(o.isCanceled)throw new Error("USER_CANCELED");b+=1/g,o(b)}})())}try{await Promise.race([await Promise.all(t),Object(a.sleep)(15e3*c).then(()=>Promise.reject(new Error("TIMEOUT")))])}catch(t){if("TIMEOUT"===t.message){console.warn("Upload timeout. Retrying..."),e-=c;continue}throw t}}return f?new i.a.InputFileBig({id:l,parts:g,name:u}):new i.a.InputFile({id:l,parts:g,name:u,md5Checksum:""})}}.call(this,n(11).Buffer)},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"updateTwoFaSettings",(function(){return u}));var s=n(6),i=n.n(s),a=n(8),r=n(32),o=n(16),c=n.n(o);async function u(t,{isCheckPassword:n,currentPassword:s,newPassword:o,hint:u="",email:d,emailCodeCallback:l,onEmailCodeError:f}){if(!o&&!s)throw new Error("Neither `currentPassword` nor `newPassword` is present");if(d&&(!l||!f))throw new Error("`email` present without `emailCodeCallback` and `onEmailCodeError`");const p=await t.invoke(new i.a.account.GetPassword);p.newAlgo instanceof i.a.PasswordKdfAlgoUnknown||(p.newAlgo.salt1=e.concat([p.newAlgo.salt1,Object(a.generateRandomBytes)(32)])),!p.hasPassword&&s&&(s=void 0);const g=s?await Object(r.computeCheck)(p,s):new i.a.InputCheckPasswordEmpty;if(n)await t.invoke(new i.a.auth.CheckPassword({password:g}));else try{await t.invoke(new i.a.account.UpdatePasswordSettings({password:g,newSettings:new i.a.account.PasswordInputSettings({newAlgo:p.newAlgo,newPasswordHash:o?await Object(r.computeDigest)(p.newAlgo,o):e.alloc(0),hint:u,email:d,newSecureSettings:void 0})}))}catch(e){if(!(e instanceof c.a.EmailUnconfirmedError))throw e;for(;;)try{const n=await l(e.codeLength);if(!n)throw new Error("Code is empty");await t.invoke(new i.a.account.ConfirmPasswordEmail({code:n}));break}catch(e){f(e)}}}}.call(this,n(11).Buffer)},function(e,t){e.exports="0.0.2"},function(e,t,n){const s=n(103),i=n(104);class a extends Error{}e.exports={NewMessage:s,StopPropagation:a,Raw:i}},function(e,t){},function(e,t,n){const{EventBuilder:s}=n(105);e.exports=class extends s{constructor(e={types:void 0,func:void 0}){super(),e.types?this.types=e.types:this.types=!0}build(e){return e}}},function(e,t){e.exports={EventBuilder:class{constructor(e={chats:void 0,blacklistChats:void 0,func:void 0}){this.chats=e.chats,this.blacklistChats=Boolean(e.blacklistChats),this.resolved=!1,this.func=e.func}build(e){}}}},function(e,t,n){const s=n(29),i=n(107),a=n(108),r=n(109),o=n(110),c=n(112);e.exports={Memory:s,StringSession:i,CacheApiSession:a,LocalStorageSession:r,IdbSession:o,CallbackSession:c}},function(e,t,n){(function(t){const s=n(29),i=n(30),a=n(26);class r extends s{constructor(e){if(super(),e){if("1"!==e[0])throw new Error("Not a valid string");e=e.slice(1);const t=r.decode(e),n=new a(t);this._dcId=n.read(1).readUInt8(0);const s=n.read(2).readInt16BE(0);this._serverAddress=String(n.read(s)),this._port=n.read(2).readInt16BE(0),this._key=n.read(-1)}}static encode(e){return e.toString("base64")}static decode(e){return t.from(e,"base64")}async load(){this._key&&(this._authKey=new i,await this._authKey.setKey(this._key))}save(){if(!this.authKey)return"";const e=t.from([this.dcId]),n=t.from(this.serverAddress),s=t.alloc(2);s.writeInt16BE(n.length,0);const i=t.alloc(2);return i.writeInt16BE(this.port,0),"1"+r.encode(t.concat([e,s,n,i,this.authKey.getKey()]))}getAuthKey(e){if(!e||e===this.dcId)return this.authKey}setAuthKey(e,t){t&&t!==this.dcId||(this.authKey=e)}}e.exports=r}).call(this,n(11).Buffer)},function(e,t,n){const s=n(41);e.exports=class extends s{async _delete(){const e=new Request(this._storageKey);return(await self.caches.open("GramJs")).delete(e)}async _fetchFromCache(){const e=new Request(this._storageKey),t=await self.caches.open("GramJs"),n=await t.match(e);return n?n.text():void 0}async _saveToCache(e){const t=new Request(this._storageKey),n=new Response(e);return(await self.caches.open("GramJs")).put(t,n)}}},function(e,t,n){const s=n(41);e.exports=class extends s{_delete(){return localStorage.removeItem(this._storageKey)}_fetchFromCache(){return localStorage.getItem(this._storageKey)}_saveToCache(e){return localStorage.setItem(this._storageKey,e)}}},function(e,t,n){const s=n(111),i=n(41);e.exports=class extends i{_delete(){return s.del("GramJs:"+this._storageKey)}_fetchFromCache(){return s.get("GramJs:"+this._storageKey)}_saveToCache(e){return s.set("GramJs:"+this._storageKey,e)}}},function(e,t,n){"use strict";function s(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function i(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const i=s(n);return(e,n)=>i.then(s=>n(s.transaction(t,e).objectStore(t)))}let a;function r(){return a||(a=i("keyval-store","keyval")),a}function o(e,t=r()){return t("readonly",t=>s(t.get(e)))}function c(e,t,n=r()){return n("readwrite",n=>(n.put(t,e),s(n.transaction)))}function u(e,t=r()){return t("readwrite",t=>(e.forEach(e=>t.put(e[1],e[0])),s(t.transaction)))}function d(e,t=r()){return t("readonly",t=>Promise.all(e.map(e=>s(t.get(e)))))}function l(e,t,n=r()){return n("readwrite",n=>new Promise((i,a)=>{n.get(e).onsuccess=function(){try{n.put(t(this.result),e),i(s(n.transaction))}catch(e){a(e)}}}))}function f(e,t=r()){return t("readwrite",t=>(t.delete(e),s(t.transaction)))}function p(e=r()){return e("readwrite",e=>(e.clear(),s(e.transaction)))}function g(e,t){return e("readonly",e=>(e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},s(e.transaction)))}function h(e=r()){const t=[];return g(e,e=>t.push(e.key)).then(()=>t)}function m(e=r()){const t=[];return g(e,e=>t.push(e.value)).then(()=>t)}function b(e=r()){const t=[];return g(e,e=>t.push([e.key,e.value])).then(()=>t)}n.r(t),n.d(t,"clear",(function(){return p})),n.d(t,"createStore",(function(){return i})),n.d(t,"del",(function(){return f})),n.d(t,"entries",(function(){return b})),n.d(t,"get",(function(){return o})),n.d(t,"getMany",(function(){return d})),n.d(t,"keys",(function(){return h})),n.d(t,"promisifyRequest",(function(){return s})),n.d(t,"set",(function(){return c})),n.d(t,"setMany",(function(){return u})),n.d(t,"update",(function(){return l})),n.d(t,"values",(function(){return m}))},function(e,t,n){(function(t){const s=n(29),i=n(30),a=n(21);e.exports=class extends s{constructor(e,t){super(),this._sessionData=e,this._callback=t,this._authKeys={}}get authKey(){throw new Error("Not supported")}set authKey(e){throw new Error("Not supported")}async load(){if(!this._sessionData)return;const{mainDcId:e,keys:n,hashes:s}=this._sessionData,{ipAddress:r,port:o}=a.getDC(e);this.setDC(e,r,o,!0),await Promise.all(Object.keys(n).map(async e=>{const a="string"==typeof n[e]?t.from(n[e],"hex"):t.from(n[e]);if(s[e]){const n="string"==typeof s[e]?t.from(s[e],"hex"):t.from(s[e]);this._authKeys[e]=new i(a,n)}else this._authKeys[e]=new i,await this._authKeys[e].setKey(a,!0)}))}setDC(e,t,n,s=!1){this._dcId=e,this._serverAddress=t,this._port=n,delete this._authKeys[e],s||this._onUpdate()}getAuthKey(e=this._dcId){return this._authKeys[e]}setAuthKey(e,t=this._dcId){this._authKeys[t]=e,this._onUpdate()}getSessionData(){const e={mainDcId:this._dcId,keys:{},hashes:{}};return Object.keys(this._authKeys).forEach(t=>{const n=this._authKeys[t];n&&n._key&&(e.keys[t]=n._key.toString("hex"),e.hashes[t]=n._hash.toString("hex"))}),e}_onUpdate(){this._callback(this.getSessionData())}delete(){this._callback(void 0)}}}).call(this,n(11).Buffer)},function(e,t,n){"use strict";n.r(t);var s={};n.r(s),n.d(s,"destroy",(function(){return p.a})),n.d(s,"disconnect",(function(){return p.b})),n.d(s,"downloadMedia",(function(){return p.c})),n.d(s,"fetchCurrentUser",(function(){return p.d})),n.d(s,"provideAuthPhoneNumber",(function(){return o.l})),n.d(s,"provideAuthCode",(function(){return o.j})),n.d(s,"provideAuthPassword",(function(){return o.k})),n.d(s,"provideAuthRegistration",(function(){return o.m})),n.d(s,"restartAuth",(function(){return o.n})),n.d(s,"restartAuthWithQr",(function(){return o.o})),n.d(s,"fetchChats",(function(){return c.n})),n.d(s,"fetchFullChat",(function(){return c.o})),n.d(s,"searchChats",(function(){return c.B})),n.d(s,"requestChatUpdate",(function(){return c.z})),n.d(s,"saveDraft",(function(){return c.A})),n.d(s,"clearDraft",(function(){return c.b})),n.d(s,"fetchChat",(function(){return c.l})),n.d(s,"updateChatMutedState",(function(){return c.M})),n.d(s,"createChannel",(function(){return c.c})),n.d(s,"joinChannel",(function(){return c.v})),n.d(s,"deleteChatUser",(function(){return c.i})),n.d(s,"deleteChat",(function(){return c.f})),n.d(s,"leaveChannel",(function(){return c.w})),n.d(s,"deleteChannel",(function(){return c.e})),n.d(s,"createGroupChat",(function(){return c.d})),n.d(s,"editChatPhoto",(function(){return c.k})),n.d(s,"toggleChatPinned",(function(){return c.E})),n.d(s,"toggleChatArchived",(function(){return c.D})),n.d(s,"toggleDialogUnread",(function(){return c.F})),n.d(s,"fetchChatFolders",(function(){return c.m})),n.d(s,"editChatFolder",(function(){return c.j})),n.d(s,"deleteChatFolder",(function(){return c.g})),n.d(s,"fetchRecommendedChatFolders",(function(){return c.r})),n.d(s,"getChatByUsername",(function(){return c.s})),n.d(s,"togglePreHistoryHidden",(function(){return c.G})),n.d(s,"updateChatDefaultBannedRights",(function(){return c.K})),n.d(s,"updateChatMemberBannedRights",(function(){return c.L})),n.d(s,"updateChatTitle",(function(){return c.N})),n.d(s,"updateChatAbout",(function(){return c.I})),n.d(s,"toggleSignatures",(function(){return c.H})),n.d(s,"updateChatAdmin",(function(){return c.J})),n.d(s,"fetchGroupsForDiscussion",(function(){return c.p})),n.d(s,"setDiscussionGroup",(function(){return c.C})),n.d(s,"migrateChat",(function(){return c.x})),n.d(s,"openChatByInvite",(function(){return c.y})),n.d(s,"fetchMembers",(function(){return c.q})),n.d(s,"importChatInvite",(function(){return c.t})),n.d(s,"addChatMembers",(function(){return c.a})),n.d(s,"deleteChatMember",(function(){return c.h})),n.d(s,"fetchMessages",(function(){return u.g})),n.d(s,"fetchMessage",(function(){return u.e})),n.d(s,"sendMessage",(function(){return u.w})),n.d(s,"pinMessage",(function(){return u.q})),n.d(s,"unpinAllMessages",(function(){return u.z})),n.d(s,"deleteMessages",(function(){return u.b})),n.d(s,"deleteHistory",(function(){return u.a})),n.d(s,"markMessageListRead",(function(){return u.o})),n.d(s,"markMessagesRead",(function(){return u.p})),n.d(s,"requestThreadInfoUpdate",(function(){return u.s})),n.d(s,"searchMessagesLocal",(function(){return u.v})),n.d(s,"searchMessagesGlobal",(function(){return u.u})),n.d(s,"fetchWebPagePreview",(function(){return u.j})),n.d(s,"editMessage",(function(){return u.d})),n.d(s,"forwardMessages",(function(){return u.l})),n.d(s,"loadPollOptionResults",(function(){return u.n})),n.d(s,"sendPollVote",(function(){return u.x})),n.d(s,"findFirstMessageIdAfterDate",(function(){return u.k})),n.d(s,"fetchPinnedMessages",(function(){return u.h})),n.d(s,"fetchScheduledHistory",(function(){return u.i})),n.d(s,"sendScheduledMessages",(function(){return u.y})),n.d(s,"rescheduleMessage",(function(){return u.t})),n.d(s,"deleteScheduledMessages",(function(){return u.c})),n.d(s,"fetchMessageLink",(function(){return u.f})),n.d(s,"reportMessages",(function(){return u.r})),n.d(s,"fetchFullUser",(function(){return v})),n.d(s,"fetchNearestCountry",(function(){return A})),n.d(s,"fetchTopUsers",(function(){return I})),n.d(s,"fetchContactList",(function(){return P})),n.d(s,"fetchUsers",(function(){return C})),n.d(s,"updateContact",(function(){return S})),n.d(s,"deleteUser",(function(){return M})),n.d(s,"fetchProfilePhotos",(function(){return k})),n.d(s,"fetchStickerSets",(function(){return D})),n.d(s,"fetchRecentStickers",(function(){return B})),n.d(s,"fetchFavoriteStickers",(function(){return x})),n.d(s,"fetchFeaturedStickers",(function(){return j})),n.d(s,"faveSticker",(function(){return N})),n.d(s,"fetchStickers",(function(){return V})),n.d(s,"fetchSavedGifs",(function(){return q})),n.d(s,"searchStickers",(function(){return L})),n.d(s,"installStickerSet",(function(){return H})),n.d(s,"uninstallStickerSet",(function(){return G})),n.d(s,"searchGifs",(function(){return z})),n.d(s,"fetchAnimatedEmojis",(function(){return F})),n.d(s,"fetchStickersForEmoji",(function(){return K})),n.d(s,"fetchEmojiKeywords",(function(){return W})),n.d(s,"checkChatUsername",(function(){return Z})),n.d(s,"setChatUsername",(function(){return Y})),n.d(s,"updatePrivateLink",(function(){return Q})),n.d(s,"updateProfile",(function(){return ge})),n.d(s,"checkUsername",(function(){return he})),n.d(s,"updateUsername",(function(){return me})),n.d(s,"fetchBlockedContacts",(function(){return ve})),n.d(s,"blockContact",(function(){return Ae})),n.d(s,"unblockContact",(function(){return Ie})),n.d(s,"updateProfilePhoto",(function(){return be})),n.d(s,"uploadProfilePhoto",(function(){return ye})),n.d(s,"fetchWallpapers",(function(){return _e})),n.d(s,"uploadWallpaper",(function(){return we})),n.d(s,"fetchAuthorizations",(function(){return Pe})),n.d(s,"terminateAuthorization",(function(){return Ce})),n.d(s,"terminateAllAuthorizations",(function(){return Se})),n.d(s,"fetchNotificationExceptions",(function(){return Me})),n.d(s,"fetchNotificationSettings",(function(){return ke})),n.d(s,"updateContactSignUpNotification",(function(){return Ee})),n.d(s,"updateNotificationSettings",(function(){return Oe})),n.d(s,"fetchLanguages",(function(){return Re})),n.d(s,"fetchLangPack",(function(){return Ue})),n.d(s,"fetchPrivacySettings",(function(){return Te})),n.d(s,"setPrivacySettings",(function(){return xe})),n.d(s,"registerDevice",(function(){return De})),n.d(s,"unregisterDevice",(function(){return Be})),n.d(s,"updateIsOnline",(function(){return je})),n.d(s,"fetchContentSettings",(function(){return Ne})),n.d(s,"updateContentSettings",(function(){return Ve})),n.d(s,"getPasswordInfo",(function(){return ne})),n.d(s,"checkPassword",(function(){return ie})),n.d(s,"clearPassword",(function(){return ae})),n.d(s,"updatePassword",(function(){return re})),n.d(s,"updateRecoveryEmail",(function(){return oe})),n.d(s,"provideRecoveryEmailCode",(function(){return ce})),n.d(s,"answerCallbackButton",(function(){return Le.a})),n.d(s,"fetchTopInlineBots",(function(){return Le.d})),n.d(s,"fetchInlineBot",(function(){return Le.b})),n.d(s,"fetchInlineBotResults",(function(){return Le.c})),n.d(s,"sendInlineBotResult",(function(){return Le.e})),n.d(s,"validateRequestedInfo",(function(){return He})),n.d(s,"sendPaymentForm",(function(){return Ge})),n.d(s,"getPaymentForm",(function(){return ze})),n.d(s,"getReceipt",(function(){return Ke}));var i=n(4),a=n(31),r=n(28),o=n(18),c=n(7),u=n(10),d=n(15),l=n.n(d),f=n(0),p=n(1),g=n(2),h=n(12),m=n(3),b=n(19),y=n(5),_=n(17);let w;async function v({id:e,accessHash:t}){const n=Object(g.g)(e,t);if(!(n instanceof f.Api.InputUser))return;const s=await Object(p.g)(new f.Api.users.GetFullUser({id:n}));if(!s)return;const i=Object(h.b)(s);w({"@type":"updateUser",id:e,user:{fullInfo:i.fullInfo}})}async function A(){const e=await Object(p.g)(new f.Api.help.GetNearestDc);return e?e.country:void 0}async function I({hash:e=0}){const t=await Object(p.g)(new f.Api.contacts.GetTopPeers({hash:e,correspondents:!0}));if(!(t instanceof f.Api.contacts.TopPeers))return;const n=t.users.map(h.a).filter(e=>!!e&&!e.isSelf),s=n.map(({id:e})=>e);return{hash:Object(g.r)(s),ids:s,users:n}}async function P({hash:e=0}){const t=await Object(p.g)(new f.Api.contacts.GetContacts({hash:e}));if(t&&!(t instanceof f.Api.contacts.ContactsNotModified))return t.users.forEach(e=>{e instanceof f.Api.User&&(y.a.users[e.id]=e)}),{hash:Object(g.r)([t.savedCount,...t.contacts.map(({userId:e})=>e)]),users:t.users.map(h.a).filter(Boolean),chats:t.users.map(e=>Object(m.d)(e)).filter(Boolean)}}async function C({users:e}){const t=await Object(p.g)(new f.Api.users.GetUsers({id:e.map(({id:e,accessHash:t})=>Object(g.i)(e,t))}));if(t&&t.length)return t.forEach(e=>{e instanceof f.Api.User&&(y.a.users[e.id]=e)}),t.map(h.a).filter(Boolean)}function S({phone:e,firstName:t,lastName:n}){return Object(p.g)(new f.Api.contacts.ImportContacts({contacts:[Object(g.e)({phone:e||"",firstName:t||"",lastName:n||""})]}))}async function M({id:e,accessHash:t}){const n=Object(g.g)(e,t);if(!(n instanceof f.Api.InputUser))return;await Object(p.g)(new f.Api.contacts.DeleteContacts({id:[n]}))&&w({"@type":"deleteUser",id:e})}async function k(e,t){if(e){const{id:t,accessHash:n}=e,s=await Object(p.g)(new f.Api.photos.GetUserPhotos({userId:Object(g.g)(t,n),limit:i.u,offset:0,maxId:l()("0")}));if(!s)return;return function(e){e.photos.forEach(_.b)}(s),{photos:s.photos.filter(e=>e instanceof f.Api.Photo).map(b.a)}}const n=await Object(u.v)({chatOrUser:t,type:"profilePhoto",limit:i.u});if(!n)return;const{messages:s,users:a}=n;return{photos:s.map(e=>e.content.action.photo).filter(Boolean),users:a}}var E=n(22),O=n(9);let R,U,T;async function D({hash:e}){const t=await Object(p.g)(new f.Api.messages.GetAllStickers({hash:e}));if(t&&!(t instanceof f.Api.messages.AllStickersNotModified))return t.sets.forEach(e=>{e.thumbs&&e.thumbs.length&&(y.a.stickerSets[String(e.id)]=e)}),{hash:t.hash,sets:t.sets.map(E.b)}}async function B({hash:e}){const t=await Object(p.g)(new f.Api.messages.GetRecentStickers({hash:e}));if(t&&!(t instanceof f.Api.messages.RecentStickersNotModified))return{hash:t.hash,stickers:$(t.stickers.slice(0,i.v))}}async function x({hash:e}){const t=await Object(p.g)(new f.Api.messages.GetFavedStickers({hash:e}));if(t&&!(t instanceof f.Api.messages.FavedStickersNotModified))return{hash:t.hash,stickers:$(t.stickers)}}async function j({hash:e}){const t=await Object(p.g)(new f.Api.messages.GetFeaturedStickers({hash:e}));if(t&&!(t instanceof f.Api.messages.FeaturedStickersNotModified))return{hash:t.hash,sets:t.sets.map(E.c)}}async function N({sticker:e,unfave:t}){const n=new f.Api.messages.FaveSticker({id:Object(g.f)(e),unfave:t});await Object(p.g)(n)&&R({"@type":"updateFavoriteStickers"})}async function V({stickerSetId:e,accessHash:t}){const n=await Object(p.g)(new f.Api.messages.GetStickerSet({stickerset:Object(g.m)(e,t)}));var s;if(n)return{set:Object(E.b)(n.set),stickers:$(n.documents),packs:(s=n.packs,s.reduce((e,{emoticon:t,documents:n})=>(e[t]=n.map(e=>Object(E.a)(y.a.documents[String(e)])).filter(Boolean),e),{}))}}async function F(){const e=await Object(p.g)(new f.Api.messages.GetStickerSet({stickerset:new f.Api.InputStickerSetAnimatedEmoji}));if(e)return{set:Object(E.b)(e.set),stickers:$(e.documents)}}async function L({query:e,hash:t}){const n=await Object(p.g)(new f.Api.messages.SearchStickerSets({q:e,hash:t}));if(n&&!(n instanceof f.Api.messages.FoundStickerSetsNotModified))return{hash:n.hash,sets:n.sets.map(E.c)}}async function q({hash:e}){const t=await Object(p.g)(new f.Api.messages.GetSavedGifs({hash:e}));if(t&&!(t instanceof f.Api.messages.SavedGifsNotModified))return{hash:t.hash,gifs:J(t.gifs)}}async function H({stickerSetId:e,accessHash:t}){await Object(p.g)(new f.Api.messages.InstallStickerSet({stickerset:Object(g.m)(e,t)}))&&R({"@type":"updateStickerSet",id:e,stickerSet:{installedDate:Date.now()}})}async function G({stickerSetId:e,accessHash:t}){await Object(p.g)(new f.Api.messages.UninstallStickerSet({stickerset:Object(g.m)(e,t)}))&&R({"@type":"updateStickerSet",id:e,stickerSet:{installedDate:void 0}})}async function z({query:e,offset:t=""}){if(!U){const e=await Object(p.g)(new f.Api.help.GetConfig);if(!e)return;const t=await Object(p.g)(new f.Api.contacts.ResolveUsername({username:e.gifSearchUsername}));if(!(t&&t.users[0]instanceof f.Api.User))return;U=new f.Api.InputUser({userId:t.peer.userId,accessHash:t.users[0].accessHash})}const n=await Object(p.g)(new f.Api.messages.GetInlineBotResults({bot:U,peer:new f.Api.InputPeerEmpty,query:e,offset:t}));if(!n)return;const s=n.results.map(e=>{if(e instanceof f.Api.BotInlineMediaResult)return e.document}).filter(Boolean);return{nextOffset:n.nextOffset,gifs:J(s)}}async function K({emoji:e,hash:t=0}){const n=await Object(p.g)(new f.Api.messages.GetStickers({emoticon:e,hash:t}));if(n&&!(n instanceof f.Api.messages.StickersNotModified))return{stickers:$(n.stickers),hash:n.hash}}async function W({language:e,fromVersion:t}){const n=await Object(p.g)(new f.Api.messages.GetEmojiKeywordsDifference({langCode:e,fromVersion:t}));if(n)return{language:n.langCode,version:n.version,keywords:n.keywords.reduce((e,t)=>(e[t.keyword]=t.emoticons,e),{})}}function $(e){return e.map(e=>{if(e instanceof f.Api.Document){const t=Object(E.a)(e);if(t)return y.a.documents[String(e.id)]=e,t}}).filter(Boolean)}function J(e){return e.map(e=>{if(e instanceof f.Api.Document){const t=Object(O.m)(e);if(t)return y.a.documents[String(e.id)]=e,t}}).filter(Boolean)}async function Z({username:e}){try{return await Object(p.g)(new f.Api.channels.CheckUsername({channel:new f.Api.InputChannelEmpty,username:e}),void 0,!0)}catch(e){return!1}}async function Y({chat:e,username:t}){await Object(p.g)(new f.Api.channels.UpdateUsername({channel:Object(g.g)(e.id,e.accessHash),username:t}))&&T({"@type":"updateChat",id:e.id,chat:{username:t}})}async function Q({chat:e}){const t=await Object(p.g)(new f.Api.messages.ExportChatInvite({peer:Object(g.i)(e.id,e.accessHash)}));t&&t instanceof f.Api.ChatInviteExported&&T({"@type":"updateChatFullInfo",id:e.id,fullInfo:{inviteLink:t.link}})}const X={EMAIL_UNCONFIRMED:"Email unconfirmed",EMAIL_HASH_EXPIRED:"Email hash expired",NEW_SALT_INVALID:"The new salt is invalid",NEW_SETTINGS_INVALID:"The new password settings are invalid",CODE_INVALID:"Invalid Code",PASSWORD_HASH_INVALID:"Invalid Password"},ee={};let te;async function ne(){const e=await Object(p.g)(new f.Api.account.GetPassword);if(!e)return;const{hint:t,hasPassword:n}=e;return{hint:t,hasPassword:n}}function se(e){return te({"@type":"updateTwoFaStateWaitCode",length:e}),new Promise((e,t)=>{ee.resolve=e,ee.reject=t})}async function ie(e){try{return await Object(p.h)({isCheckPassword:!0,currentPassword:e}),!0}catch(e){return ue(e),!1}}async function ae(e){try{return await Object(p.h)({currentPassword:e}),!0}catch(e){return ue(e),!1}}async function re(e,t,n,s){try{return await Object(p.h)({currentPassword:e,newPassword:t,hint:n,email:s,emailCodeCallback:se,onEmailCodeError:ue}),!0}catch(e){return ue(e),!1}}async function oe(e,t){try{return await Object(p.h)({currentPassword:e,newPassword:e,email:t,emailCodeCallback:se,onEmailCodeError:ue}),!0}catch(e){return ue(e),!1}}function ce(e){ee.resolve(e)}function ue(e){let t;if(e instanceof f.errors.FloodWaitError){const n=Math.ceil(Number(e.seconds)/60/60);t="Too many attempts. Try again in "+(n>1?n+" hours":"an hour")}else t=X[e.message];t||(t="Unexpected Error",i.g&&console.error(e)),te({"@type":"updateTwoFaError",message:t})}var de=n(23),le=n(20),fe=n(14);const pe=["ar","fa"];function ge({firstName:e,lastName:t,about:n}){return Object(p.g)(new f.Api.account.UpdateProfile({firstName:e||"",lastName:t||"",about:n||""}))}function he(e){return Object(p.g)(new f.Api.account.CheckUsername({username:e}))}function me(e){return Object(p.g)(new f.Api.account.UpdateUsername({username:e}))}async function be(e){const t=await Object(p.i)(e);return Object(p.g)(new f.Api.photos.UploadProfilePhoto({file:t}))}async function ye(e){const t=await Object(p.i)(e);await Object(p.g)(new f.Api.photos.UploadProfilePhoto({file:t}))}async function _e(e){const t=await Object(p.g)(new f.Api.account.GetWallPapers({hash:e}));if(!t||t instanceof f.Api.account.WallPapersNotModified)return;const n=t.wallpapers.filter(e=>e instanceof f.Api.WallPaper&&e.document instanceof f.Api.Document&&(!e.pattern&&"application/x-tgwallpattern"!==e.document.mimeType));return n.forEach(e=>{y.a.documents[String(e.document.id)]=e.document}),{hash:t.hash,wallpapers:n.map(de.c).filter(Boolean)}}async function we(e){const t=await Object(p.i)(e),n=await Object(p.g)(new f.Api.account.UploadWallPaper({file:t,mimeType:e.type,settings:new f.Api.WallPaperSettings}));if(!(n&&n instanceof f.Api.WallPaper))return;const s=Object(de.c)(n);return s?(y.a.documents[String(n.document.id)]=n.document,{wallpaper:s}):void 0}async function ve(){const e=await Object(p.g)(new f.Api.contacts.GetBlocked({limit:i.f}));if(e)return Fe(e),{users:e.users.map(h.a).filter(Boolean),chats:e.chats.map(e=>Object(m.d)(e,void 0,!0)).filter(Boolean),blockedIds:e.blocked.map(e=>Object(m.j)(e.peerId)),totalCount:e instanceof f.Api.contacts.BlockedSlice?e.count:e.blocked.length}}function Ae(e){return Object(p.g)(new f.Api.contacts.Block({id:Object(g.p)(e)}))}function Ie(e,t){return Object(p.g)(new f.Api.contacts.Unblock({id:Object(g.i)(e,t)}))}async function Pe(){const e=await Object(p.g)(new f.Api.account.GetAuthorizations);if(e)return e.authorizations.map(de.b)}function Ce(e){return Object(p.g)(new f.Api.account.ResetAuthorization({hash:l()(e)}))}function Se(){return Object(p.g)(new f.Api.auth.ResetAuthorizations)}async function Me({serverTimeOffset:e}){const t=await Object(p.g)(new f.Api.account.GetNotifyExceptions({compareSound:!0}));if(t instanceof f.Api.Updates||t instanceof f.Api.UpdatesCombined)return Fe(t),t.updates.reduce((t,n)=>n instanceof f.Api.UpdateNotifySettings&&n.peer instanceof f.Api.NotifyPeer?(t.push(Object(de.a)(n.notifySettings,n.peer.peer,e)),t):t,[])}async function ke({serverTimeOffset:e}){const[t,n,s,i]=await Promise.all([Object(p.g)(new f.Api.account.GetContactSignUpNotification),Object(p.g)(new f.Api.account.GetNotifySettings({peer:new f.Api.InputNotifyUsers})),Object(p.g)(new f.Api.account.GetNotifySettings({peer:new f.Api.InputNotifyChats})),Object(p.g)(new f.Api.account.GetNotifySettings({peer:new f.Api.InputNotifyBroadcasts}))]);if(!n||!s||!i)return!1;const{silent:a,muteUntil:r,showPreviews:o}=n,{silent:c,muteUntil:u,showPreviews:d}=s,{silent:l,muteUntil:g,showPreviews:h}=i;return{hasContactJoinedNotifications:!t,hasPrivateChatsNotifications:!(a||"number"==typeof r&&Date.now()+1e3*e<1e3*r),hasPrivateChatsMessagePreview:o,hasGroupNotifications:!(c||"number"==typeof u&&Date.now()+1e3*e<1e3*u),hasGroupMessagePreview:d,hasBroadcastNotifications:!(l||"number"==typeof g&&Date.now()+1e3*e<1e3*g),hasBroadcastMessagePreview:h}}function Ee(e){return Object(p.g)(new f.Api.account.SetContactSignUpNotification({silent:e}))}function Oe(e,{isSilent:t,shouldShowPreviews:n}){let s;s="contact"===e?new f.Api.InputNotifyUsers:"group"===e?new f.Api.InputNotifyChats:new f.Api.InputNotifyBroadcasts;const i={showPreviews:n,silent:t,muteUntil:t?2**31-1:0};return Object(p.g)(new f.Api.account.UpdateNotifySettings({peer:s,settings:new f.Api.InputPeerNotifySettings(i)}))}async function Re(){const e=await Object(p.g)(new f.Api.langpack.GetLanguages({langPack:i.i}));if(e)return e.map(le.b)}async function Ue({sourceLangPacks:e,langCode:t}){const n=(await Promise.all(e.map(e=>Object(p.g)(new f.Api.langpack.GetLangPack({langPack:e,langCode:pe.includes(t)?t+"-raw":t}))))).filter(Boolean).map(e=>Object(fe.a)(e.strings.map(le.b),"key"));if(n.length)return{langPack:Object.assign({},...n.reverse())}}async function Te(e){const t=Object(g.k)(e),n=await Object(p.g)(new f.Api.account.GetPrivacy({key:t}));if(n)return Fe(n),Object(de.e)(n.rules)}function De(e){const t=Object(p.e)().session.getAuthKey().getKey();return Object(p.g)(new f.Api.account.RegisterDevice({tokenType:10,secret:t,appSandbox:!1,otherUids:[],token:e}))}function Be(e){return Object(p.g)(new f.Api.account.UnregisterDevice({tokenType:10,otherUids:[],token:e}))}async function xe(e,t){const n=Object(g.k)(e),s=[];switch(t.allowedUsers&&s.push(new f.Api.InputPrivacyValueAllowUsers({users:t.allowedUsers.map(({id:e,accessHash:t})=>Object(g.i)(e,t))})),t.allowedChats&&s.push(new f.Api.InputPrivacyValueAllowChatParticipants({chats:t.allowedChats.map(({id:e})=>-e)})),t.blockedUsers&&s.push(new f.Api.InputPrivacyValueDisallowUsers({users:t.blockedUsers.map(({id:e,accessHash:t})=>Object(g.i)(e,t))})),t.blockedChats&&s.push(new f.Api.InputPrivacyValueDisallowChatParticipants({chats:t.blockedChats.map(({id:e})=>-e)})),t.visibility){case"everybody":s.push(new f.Api.InputPrivacyValueAllowAll);break;case"contacts":s.push(new f.Api.InputPrivacyValueAllowContacts);break;case"nonContacts":s.push(new f.Api.InputPrivacyValueDisallowContacts);break;case"nobody":s.push(new f.Api.InputPrivacyValueDisallowAll)}const i=await Object(p.g)(new f.Api.account.SetPrivacy({key:n,rules:s}));if(i)return Fe(i),Object(de.e)(i.rules)}async function je(e){await Object(p.g)(new f.Api.account.UpdateStatus({offline:!e}))}async function Ne(){const e=await Object(p.g)(new f.Api.account.GetContentSettings);if(e)return{isSensitiveEnabled:Boolean(e.sensitiveEnabled),canChangeSensitive:Boolean(e.sensitiveCanChange)}}function Ve(e){return Object(p.g)(new f.Api.account.SetContentSettings({sensitiveEnabled:e||void 0}))}function Fe(e){e.users.forEach(e=>{e instanceof f.Api.User&&(y.a.users[e.id]=e)}),e.chats.forEach(e=>{(e instanceof f.Api.Chat||e instanceof f.Api.Channel)&&(y.a.chats[e.id]=e)})}var Le=n(27);function qe(e){if(e)return Object.values(e).map(e=>({id:e.id,title:e.title,amount:e.prices.reduce((e,t)=>e+Number(t.amount.value),0),prices:e.prices.map(({label:e,amount:t})=>({label:e,amount:Number(t.value)}))}))}async function He({messageId:e,requestInfo:t,shouldSave:n}){const s=await Object(p.g)(new f.Api.payments.ValidateRequestedInfo({msgId:e,save:n||void 0,info:Object(g.q)(t)}));if(!s)return;const{id:i,shippingOptions:a}=s;return i?{id:i,shippingOptions:qe(a)}:void 0}function Ge({messageId:e,requestedInfoId:t,shippingOptionId:n,credentials:s}){return Object(p.g)(new f.Api.payments.SendPaymentForm({msgId:e,requestedInfoId:t,shippingOptionId:n,credentials:new f.Api.InputPaymentCredentials({save:s.save,data:new f.Api.DataJSON({data:JSON.stringify(s.data)})})}),!0)}async function ze({messageId:e}){const t=await Object(p.g)(new f.Api.payments.GetPaymentForm({msgId:e}));if(t)return function(e){const{canSaveCredentials:t,passwordMissing:n,providerId:s,nativeProvider:i,nativeParams:a,savedInfo:r,invoice:o}=e,{test:c,nameRequested:u,phoneRequested:d,emailRequested:l,shippingAddressRequested:f,flexible:p,phoneToProvider:g,emailToProvider:h,currency:m,prices:b}=o,y=b.map(({label:e,amount:t})=>({label:e,amount:Number(t.value)})),_=a?JSON.parse(a.data):{};return{canSaveCredentials:t,passwordMissing:n,providerId:s,nativeProvider:i,savedInfo:r,invoice:{test:c,nameRequested:u,phoneRequested:d,emailRequested:l,shippingAddressRequested:f,flexible:p,phoneToProvider:g,emailToProvider:h,currency:m,prices:y},nativeParams:{needCardholderName:_.need_cardholder_name,needCountry:_.need_country,needZip:_.need_zip,publishableKey:_.publishable_key}}}(t)}async function Ke(e){const t=await Object(p.g)(new f.Api.payments.GetPaymentReceipt({msgId:e}));if(t)return function(e){const{invoice:t,info:n,shipping:s,currency:i,totalAmount:a,credentialsTitle:r}=e,{shippingAddress:o,phone:c,name:u}=n||{},{prices:d}=t,l=d.map(({label:e,amount:t})=>({label:e,amount:Number(t.value)}));let f,p;return s&&(f=s.prices.map(({label:e,amount:t})=>({label:e,amount:Number(t.value)})),p=s.title),{currency:i,prices:l,info:{shippingAddress:o,phone:c,name:u},totalAmount:Number(a.value),credentialsTitle:r,shippingPrices:f,shippingMethod:p}}(t)}let We;async function $e(e,t){We=e,Object(r.a)(Xe),Object(o.a)(Xe),Object(c.u)(Xe),Object(u.m)(Xe),function(e){w=e}(Xe),function(e){R=e}(Xe),function(e){T=e}(Xe),function(e){te=e}(Xe),await Object(p.f)(Xe,t)}const Je=Object(a.c)((function(e){if(!Qe||e!==Ye)return;const t=Qe;Qe=void 0,t.forEach(We)}));let Ze,Ye,Qe;function Xe(e){Qe?Qe.push(e):Qe=[e],Ze&&!i.b.has(e["@type"])||(Ze=Object(a.b)(Je,i.c,!0),Ye=Math.random()),Ze(Ye)}self.onerror=e=>{console.error(e),nt({type:"unhandledError",error:{message:e.error.message||"Uncaught exception in worker"}})},self.addEventListener("unhandledrejection",e=>{console.error(e),nt({type:"unhandledError",error:{message:e.reason.message||"Uncaught rejection in worker"}})});const et=new Map;function tt(e){nt({type:"update",update:e})}function nt(e,t){t?postMessage(e,[t]):postMessage(e)}i.g&&console.log(">>> FINISH LOAD WORKER"),onmessage=async e=>{const{data:t}=e;switch(t.type){case"initApi":await $e(tt,t.args[0]);break;case"callMethod":{const{messageId:e,name:n,args:a}=t;try{if(e){const t=(...t)=>{const n=t[t.length-1];nt({type:"methodCallback",messageId:e,callbackArgs:t},n instanceof ArrayBuffer?n:void 0)};et.set(e,t),a.push(t)}const t=await function(e,...t){return s[e](...t)}(n,...a),{arrayBuffer:i}="object"==typeof t&&"arrayBuffer"in t&&t||{};e&&nt({type:"methodResponse",messageId:e,response:t},i)}catch(t){i.g&&console.error(t),e&&nt({type:"methodResponse",messageId:e,error:{message:t.message}})}e&&et.delete(e);break}case"cancelProgress":{const e=et.get(t.messageId);e&&(e.isCanceled=!0);break}}}}]); //# sourceMappingURL=0abca03f983496b34bf4.worker.js.map