(()=>{var e,t,n={14423:(e,t,n)=>{"use strict";var s={};n.r(s),n.d(s,{Type:()=>Un,clear:()=>xn,fetch:()=>Bn,remove:()=>Tn,save:()=>Dn});var a={};n.r(a),n.d(a,{acceptBotUrlAuth:()=>ho,acceptCall:()=>Fo,acceptLinkUrlAuth:()=>_o,acceptPhoneCall:()=>bd,addChatMembers:()=>js,answerCallbackButton:()=>to,blockContact:()=>hr,changeSessionSettings:()=>er,changeSessionTtl:()=>tr,checkChatUsername:()=>Ui,checkPassword:()=>Ji,checkUsername:()=>rr,clearDraft:()=>gs,clearPassword:()=>Qi,clearRecentStickers:()=>mi,closePoll:()=>Ma,confirmCall:()=>qo,confirmPhoneCall:()=>yd,createChannel:()=>hs,createGroupCall:()=>Ro,createGroupChat:()=>vs,createPhoneCallState:()=>pd,decodePhoneCallData:()=>_d,deleteChannel:()=>ws,deleteChat:()=>ys,deleteChatFolder:()=>ks,deleteChatMember:()=>Ws,deleteChatUser:()=>_s,deleteContact:()=>ai,deleteExportedChatInvite:()=>Ni,deleteHistory:()=>_a,deleteMessages:()=>ha,deleteProfilePhoto:()=>lr,deleteRevokedExportedChatInvites:()=>Fi,deleteScheduledMessages:()=>ma,destroy:()=>jn,destroyPhoneCallState:()=>hd,discardCall:()=>To,discardGroupCall:()=>Ao,disconnect:()=>Wn,downloadMedia:()=>Yn,editChatFolder:()=>Ms,editChatPhoto:()=>As,editExportedChatInvite:()=>xi,editGroupCallParticipant:()=>So,editGroupCallTitle:()=>Io,editMessage:()=>ua,encodePhoneCallData:()=>md,exportChatInvite:()=>Vi,exportGroupCallInvite:()=>Po,faveSticker:()=>pi,fetchAnimatedEmojiEffects:()=>wi,fetchAnimatedEmojis:()=>bi,fetchAppConfig:()=>Nr,fetchAuthorizations:()=>_r,fetchBlockedContacts:()=>pr,fetchChannelStatistics:()=>Yr,fetchChat:()=>us,fetchChatFolders:()=>Ps,fetchChatInviteImporters:()=>qi,fetchChatSettings:()=>ds,fetchChats:()=>os,fetchCommonChats:()=>Xa,fetchContactList:()=>ei,fetchContentSettings:()=>xr,fetchCountryList:()=>qr,fetchCurrentUser:()=>ts,fetchCustomEmoji:()=>yi,fetchCustomEmojiSets:()=>di,fetchEmojiKeywords:()=>Ri,fetchExportedChatInvites:()=>Ti,fetchExtendedMedia:()=>Ra,fetchFavoriteStickers:()=>li,fetchFeaturedEmojiStickers:()=>gi,fetchFeaturedStickers:()=>fi,fetchFullChat:()=>rs,fetchFullUser:()=>Qa,fetchGlobalPrivacySettings:()=>Lr,fetchGroupCallParticipants:()=>Co,fetchGroupStatistics:()=>Zr,fetchGroupsForDiscussion:()=>Hs,fetchInlineBot:()=>so,fetchInlineBotResults:()=>ao,fetchLangPack:()=>kr,fetchLangStrings:()=>Rr,fetchLanguages:()=>Mr,fetchMembers:()=>Gs,fetchMessage:()=>oa,fetchMessagePublicForwards:()=>td,fetchMessageReactions:()=>jr,fetchMessageReactionsList:()=>Wr,fetchMessageStatistics:()=>ed,fetchMessages:()=>ia,fetchNearestCountry:()=>Ya,fetchNotificationExceptions:()=>Sr,fetchNotificationSettings:()=>Ir,fetchPinnedMessages:()=>xa,fetchPremiumGifts:()=>vi,fetchPremiumPromo:()=>Qo,fetchPrivacySettings:()=>Er,fetchProfilePhotos:()=>ii,fetchRecentStickers:()=>ui,fetchRecommendedChatFolders:()=>Cs,fetchSavedGifs:()=>Si,fetchScheduledHistory:()=>Ba,fetchSeenBy:()=>Va,fetchSendAs:()=>Na,fetchSponsoredMessages:()=>qa,fetchStatisticsAsyncGraph:()=>nd,fetchStickerSets:()=>ci,fetchStickers:()=>_i,fetchStickersForEmoji:()=>ki,fetchTemporaryPaymentPassword:()=>Xo,fetchTopInlineBots:()=>no,fetchTopUsers:()=>Za,fetchUnreadMentions:()=>Oa,fetchUnreadReactions:()=>Ka,fetchUsers:()=>ti,fetchWallpapers:()=>fr,fetchWebAuthorizations:()=>wr,fetchWebPagePreview:()=>Pa,findFirstMessageIdAfterDate:()=>Ua,forwardMessages:()=>Ea,getAvailableReactions:()=>Kr,getChatByPhoneNumber:()=>Us,getChatByUsername:()=>Bs,getDhConfig:()=>Do,getGroupCall:()=>vo,getPasswordInfo:()=>Wi,getPaymentForm:()=>$o,getReceipt:()=>Jo,hideAllChatJoinRequests:()=>Gi,hideChatJoinRequest:()=>Li,hideChatReportPanel:()=>Hi,importChatInvite:()=>Ys,importContact:()=>ni,installStickerSet:()=>Pi,joinChannel:()=>ms,joinGroupCall:()=>ko,joinGroupCallPresentation:()=>Eo,leaveChannel:()=>bs,leaveGroupCall:()=>Mo,leaveGroupCallPresentation:()=>Bo,loadAttachBots:()=>fo,loadPollOptionResults:()=>ka,markMessageListRead:()=>wa,markMessagesRead:()=>va,migrateChat:()=>Ks,openChatByInvite:()=>zs,pinMessage:()=>ga,prolongWebView:()=>uo,provideAuthCode:()=>An,provideAuthPassword:()=>Sn,provideAuthPhoneNumber:()=>vn,provideAuthRegistration:()=>In,provideRecoveryEmailCode:()=>Zi,readAllMentions:()=>Ga,readAllReactions:()=>Ha,receivedCall:()=>No,registerDevice:()=>Ur,removeRecentSticker:()=>hi,repairFileReference:()=>ss,reportMessages:()=>ya,reportPeer:()=>Yo,reportProfilePhoto:()=>Zo,reportSpam:()=>oi,requestBotUrlAuth:()=>po,requestCall:()=>xo,requestChatUpdate:()=>ls,requestLinkUrlAuth:()=>mo,requestPhoneCall:()=>wd,requestSimpleWebView:()=>co,requestThreadInfoUpdate:()=>Aa,requestWebView:()=>ro,rescheduleMessage:()=>la,restartAuth:()=>Pn,restartAuthWithQr:()=>Cn,saveDefaultSendAs:()=>Fa,saveDraft:()=>fs,saveGif:()=>Ii,searchChats:()=>cs,searchGifs:()=>Mi,searchMessagesGlobal:()=>Ia,searchMessagesLocal:()=>Sa,searchStickers:()=>Ai,sendEmojiInteraction:()=>Or,sendInlineBotResult:()=>io,sendMessage:()=>da,sendMessageAction:()=>ba,sendPaymentForm:()=>Wo,sendPollVote:()=>Ca,sendReaction:()=>zr,sendScheduledMessages:()=>Da,sendSignalingData:()=>Lo,sendWatchingEmojiInteraction:()=>Hr,sendWebViewData:()=>lo,setCallRating:()=>Vo,setChatEnabledReactions:()=>Zs,setChatUsername:()=>Bi,setDefaultReaction:()=>$r,setDiscussionGroup:()=>Os,setPrivacySettings:()=>Dr,sortChatFolders:()=>Rs,startBot:()=>oo,terminateAllAuthorizations:()=>br,terminateAllWebAuthorizations:()=>Ar,terminateAuthorization:()=>yr,terminateWebAuthorization:()=>vr,toggleAttachBot:()=>go,toggleChatArchived:()=>Is,toggleChatPinned:()=>Ss,toggleDialogUnread:()=>Es,toggleGroupCallStartSubscription:()=>Uo,toggleIsProtected:()=>ea,toggleJoinRequest:()=>Js,toggleJoinToSend:()=>$s,togglePreHistoryHidden:()=>Ts,toggleSignatures:()=>Ls,transcribeAudio:()=>za,unblockContact:()=>mr,uninstallStickerSet:()=>Ci,unpinAllMessages:()=>pa,unregisterDevice:()=>Br,updateChatAbout:()=>qs,updateChatAdmin:()=>Ns,updateChatDefaultBannedRights:()=>xs,updateChatMemberBannedRights:()=>Vs,updateChatMutedState:()=>ps,updateChatTitle:()=>Fs,updateContact:()=>si,updateContactSignUpNotification:()=>Pr,updateContentSettings:()=>Vr,updateGlobalPrivacySettings:()=>Gr,updateIsOnline:()=>Tr,updateNotificationSettings:()=>Cr,updatePassword:()=>Xi,updatePrivateLink:()=>Di,updateProfile:()=>or,updateProfilePhoto:()=>cr,updateRecoveryEmail:()=>Yi,updateUsername:()=>dr,uploadProfilePhoto:()=>ur,uploadWallpaper:()=>gr,validateRequestedInfo:()=>jo,viewSponsoredMessage:()=>La});const i=("undefined"!=typeof window&&window.innerHeight,Math.round(425)),o=new Set(["newMessage","newScheduledMessage","deleteMessages","deleteScheduledMessages","deleteHistory"]),r="video/quicktime",d=new Set(["image/png","image/gif","image/jpeg"]),c=new Set(["video/mp4"]),u=new Set(["audio/mp3","audio/ogg","audio/wav","audio/mpeg","audio/flac","audio/aac","audio/m4a","audio/mp4","audio/x-m4a"]),l=(new Set([...d,...c]),new Set(["AU","BD","CA","CO","EG","HN","IE","IN","JO","MX","MY","NI","NZ","PH","PK","SA","SV","US"]),"777000"),f={uploadMaxFileparts:[4e3,8e3],stickersFaved:[5,10],savedGifs:[200,400],dialogFiltersChats:[100,200],dialogFilters:[10,20],dialogFolderPinned:[5,10],captionLength:[1024,2048],channels:[500,1e3],channelsPublic:[10,20],aboutLength:[70,140]};let g,p;var h=n(13522);function m(e,t){return e.reduce(((e,n)=>(e[n[t]]=n,e)),{})}function _(e,t){return t.reduce(((t,n)=>(t[n]=e[n],t)),{})}let y,b;!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.Spoiler="MessageEntitySpoiler",e.CustomEmoji="MessageEntityCustomEmoji",e.Unknown="MessageEntityUnknown"}(y||(y={})),function(e){e[e.BlobUrl=0]="BlobUrl",e[e.Progressive=1]="Progressive",e[e.Stream=2]="Stream",e[e.DownloadUrl=3]="DownloadUrl",e[e.Text=4]="Text"}(b||(b={}));var w=n(48960);function v(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image/jpeg";const s=t?"":`data:${n};base64,`;return`${s}${btoa(String.fromCharCode(...e))}`}function A(e){const{flags:t,CONSTRUCTOR_ID:n,SUBCLASS_OF_ID:s,className:a,classType:i,getBytes:o,...r}=e;return r}function S(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 I={w:100,h:100};function P(e,t){if(!e||!e.length)return;const n=e.find((e=>e instanceof h.Api.PhotoStrippedSize));if(!n)return;const s=e.filter((e=>e instanceof h.Api.PhotoSize)),{w:a,h:i}=s.length?s[s.length-1]:I,{bytes:o}=n;return{dataUri:v(t&&"image/jpeg"!==t?o:(0,w.strippedPhotoToJpg)(o),void 0,t),width:a,height:i}}function C(e){const t=e.sizes.filter((e=>e instanceof h.Api.PhotoSize||e instanceof h.Api.PhotoSizeProgressive)).map(k);return{id:String(e.id),thumbnail:P(e.sizes),sizes:t,...e.videoSizes&&{videoSizes:e.videoSizes.map(M),isVideo:!0}}}function M(e){const{videoStartTs:t,size:n,h:s,w:a,type:i}=e;return{videoStartTs:t,size:n,height:s,width:a,type:i}}function k(e){const{w:t,h:n,type:s}=e;return{width:t,height:n,type:s}}const R={localMessages:{},chats:{},users:{},messages:{},documents:{},stickerSets:{},photos:{},webDocuments:{}},E=R,U=E;function B(){Object.assign(E,R)}const D="application/x-tgsticker",T="video/webm";function x(e,t){var n;if(e instanceof h.Api.DocumentEmpty)return;const{mimeType:s,videoThumbs:a}=e,i=e.attributes.find((e=>e instanceof h.Api.DocumentAttributeSticker)),o=e.attributes.find((e=>e instanceof h.Api.DocumentAttributeCustomEmoji)),r=(s===D||s===T)&&e.attributes.find((e=>e instanceof h.Api.DocumentAttributeFilename));if(!i&&!o&&!r)return;const d=s===D,c=s===T,u=Boolean(o),l=e.attributes.find((e=>e instanceof h.Api.DocumentAttributeImageSize)),f=e.attributes.find((e=>e instanceof h.Api.DocumentAttributeVideo)),g=l||f,p=i||o,m=(w=null==p?void 0:p.stickerset)instanceof h.Api.InputStickerSetID?{id:String(w.id),accessHash:String(w.accessHash)}:w instanceof h.Api.InputStickerSetShortName?{shortName:w.shortName}:{isMissing:!0},_=null==p?void 0:p.alt,y=Boolean(null===(n=null==o?void 0:o.free)||void 0===n||n),b=e.thumbs&&e.thumbs.find((e=>e instanceof h.Api.PhotoCachedSize));var w;if(!(s!==T||self.isWebmSupported||b||e.thumbs&&e.thumbs.find((e=>e instanceof h.Api.PhotoSize))))return;const A=e.thumbs&&e.thumbs.find((e=>e instanceof h.Api.PhotoPathSize)),I=b?function(e){const{w:t,h:n,bytes:s}=e;return{dataUri:v(s,void 0,"image/webp"),width:t,height:n}}(b):A&&g?function(e,t){const{w:n,h:s}=t;return{dataUri:`data:image/svg+xml;utf8,${S(e.bytes,n,s)}`,width:n,height:s}}(A,g):void 0,{w:P,h:C}=b||g||{},M=!t&&(null==a?void 0:a.some((e=>{let{type:t}=e;return"f"===t})));return{id:String(e.id),stickerSetInfo:m,emoji:_,isCustomEmoji:u,isLottie:d,isVideo:c,width:P,height:C,thumbnail:I,hasEffect:M,isFree:y}}function V(e){const{archived:t,animated:n,installedDate:s,videos:a,id:i,accessHash:o,title:r,thumbs:d,count:c,shortName:u,emojis:l,thumbDocumentId:f}=e;return{archived:t,isLottie:n,isVideos:a,isEmoji:l,installedDate:s,id:String(i),accessHash:String(o),title:r,hasThumbnail:Boolean((null==d?void 0:d.length)||f),count:c,shortName:u}}function N(e){const t=V(e.set),n=q(e instanceof h.Api.StickerSetCovered?[e.cover]:e instanceof h.Api.StickerSetMultiCovered?e.covers:e.documents);return e instanceof h.Api.StickerSetFullCovered?{...t,stickers:n,packs:F(e.packs)}:{...t,covers:n}}function F(e){return e.reduce(((e,t)=>{let{emoticon:n,documents:s}=t;return e[n]=s.map((e=>x(U.documents[String(e)]))).filter(Boolean),e}),{})}function q(e){return e.map((e=>{if(e instanceof h.Api.Document){const t=x(e);if(t)return U.documents[String(e.id)]=e,t}})).filter(Boolean)}function L(e,t){let n=0;const s=new Array(t),a=e.length/t,i=e[0],o=e[e.length-1];for(let u=0;u1&&void 0!==arguments[1]&&arguments[1];const n=W(e.id,"user");!t&&U.users[n]||(U.users[n]=e)}function ee(e){e.forEach((e=>{e instanceof h.Api.User&&e.photo?Z(e):(e instanceof h.Api.Chat||e instanceof h.Api.Channel)&&e.photo&&function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=W(e.id,e instanceof h.Api.Chat?"chat":"channel");t&&U.chats[n]||(U.chats[n]=e)}(e)}))}function te(e){return String.fromCharCode(...e)}function ne(e){return J.from(e,"binary")}function se(e){return"number"==typeof e?function(e){return e>0?"user":e<=-1e9?"channel":"chat"}(e):e.startsWith("-")?e.length>=11?"channel":"chat":"user"}function ae(e){const t=se(e);return"user"===t?new h.Api.PeerUser({userId:Pe(e,"user")}):"channel"===t?new h.Api.PeerChannel({channelId:Pe(e,"channel")}):new h.Api.PeerChat({chatId:Pe(e,"chat")})}function ie(e,t){const n=se(e);return"user"===n?new h.Api.InputPeerUser({userId:Pe(e,"user"),accessHash:H()(t)}):"channel"===n?new h.Api.InputPeerChannel({channelId:Pe(e,"channel"),accessHash:H()(t)}):new h.Api.InputPeerChat({chatId:Pe(e,"chat")})}function oe(e){const t=se(e);let n;var s;if("user"===t){if(n=null===(s=U.users[e])||void 0===s?void 0:s.accessHash,!n)return}else if("channel"===t){var a;if(n=null===(a=U.chats[e])||void 0===a?void 0:a.accessHash,!n)return}return ie(e,String(n))}function re(e,t){const n=se(e);return"user"===n?new h.Api.InputUser({userId:Pe(e,"user"),accessHash:H()(t)}):"channel"===n?new h.Api.InputChannel({channelId:Pe(e,"channel"),accessHash:H()(t)}):Pe(e,"chat")}function de(e,t){return new h.Api.InputStickerSetID({id:H()(e),accessHash:H()(t)})}function ce(e){const t=U.documents[e.id];if(t)return new h.Api.InputDocument(_(t,["id","accessHash","fileReference"]))}function ue(e){const t=ce(e);if(t)return new h.Api.InputMediaDocument({id:t})}function le(e){var t,n;let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new h.Api.InputMediaPoll({poll:new h.Api.Poll({id:H()(e.id),publicVoters:e.summary.isPublic,question:e.summary.question,answers:e.summary.answers.map((e=>{let{text:t,option:n}=e;return new h.Api.PollAnswer({text:t,option:ne(n)})})),quiz:e.summary.quiz,multipleChoice:e.summary.multipleChoice,closeDate:e.summary.closeDate,closePeriod:e.summary.closePeriod,closed:!!s||e.summary.closed}),correctAnswers:null===(t=e.results.results)||void 0===t?void 0:t.filter((e=>e.isCorrect)).map((e=>ne(e.option))),solution:e.results.solution,solutionEntities:null===(n=e.results.solutionEntities)||void 0===n?void 0:n.map(he)})}function fe(){return(0,O.readBigIntFromBuffer)((0,O.generateRandomBytes)(8),!0,!0)}function ge(){return(0,O.readBigIntFromBuffer)((0,O.generateRandomBytes)(4),!0,!0).toJSNumber()}function pe(e,t,n){return new h.Api.Message({id:e,peerId:ae(t),fromId:ae(t),media:n.media})}function he(e){const{type:t,offset:n,length:s}=e,a="userId"in e?U.users[e.userId]:void 0;switch(t){case y.Bold:return new h.Api.MessageEntityBold({offset:n,length:s});case y.Italic:return new h.Api.MessageEntityItalic({offset:n,length:s});case y.Underline:return new h.Api.MessageEntityUnderline({offset:n,length:s});case y.Strike:return new h.Api.MessageEntityStrike({offset:n,length:s});case y.Code:return new h.Api.MessageEntityCode({offset:n,length:s});case y.Pre:return new h.Api.MessageEntityPre({offset:n,length:s,language:e.language||""});case y.Blockquote:return new h.Api.MessageEntityBlockquote({offset:n,length:s});case y.TextUrl:return new h.Api.MessageEntityTextUrl({offset:n,length:s,url:e.url});case y.Url:return new h.Api.MessageEntityUrl({offset:n,length:s});case y.Hashtag:return new h.Api.MessageEntityHashtag({offset:n,length:s});case y.MentionName:return new h.Api.InputMessageEntityMentionName({offset:n,length:s,userId:new h.Api.InputUser({userId:H()(a.id),accessHash:a.accessHash})});case y.Spoiler:return new h.Api.MessageEntitySpoiler({offset:n,length:s});case y.CustomEmoji:return new h.Api.MessageEntityCustomEmoji({offset:n,length:s,documentId:H()(e.documentId)});default:return new h.Api.MessageEntityUnknown({offset:n,length:s})}}function me(e){const{media:t}=e;return!!t&&(t instanceof h.Api.MessageMediaPhoto||t instanceof h.Api.MessageMediaDocument||t instanceof h.Api.MessageMediaWebPage&&t.webpage instanceof h.Api.WebPage&&(t.webpage.photo instanceof h.Api.Photo||t.webpage.document instanceof h.Api.Document&&t.webpage.document.mimeType.startsWith("video"))||t instanceof h.Api.MessageMediaGame&&(t.game.document instanceof h.Api.Document||t.game.photo instanceof h.Api.Photo)||t instanceof h.Api.MessageMediaInvoice&&(t.photo||t.extendedMedia))}function _e(e){const t=U.photos[null==e?void 0:e.id];if(t)return new h.Api.InputPhoto(_(t,["id","accessHash","fileReference"]))}function ye(e){let{phone:t,firstName:n,lastName:s}=e;return new h.Api.InputPhoneContact({clientId:H()(1),phone:t,firstName:n,lastName:s})}function be(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return new h.Api.ChatBannedRights({...e,untilDate:t})}function we(e){return new h.Api.ChatAdminRights(e)}function ve(e){const{shippingAddress:t}=e;return new h.Api.PaymentRequestedInfo({...e,shippingAddress:t?new h.Api.PostAddress(t):void 0})}function Ae(e){switch(e){case"phoneNumber":return new h.Api.InputPrivacyKeyPhoneNumber;case"lastSeen":return new h.Api.InputPrivacyKeyStatusTimestamp;case"profilePhoto":return new h.Api.InputPrivacyKeyProfilePhoto;case"forwards":return new h.Api.InputPrivacyKeyForwards;case"chatInvite":return new h.Api.InputPrivacyKeyChatInvite;case"phoneCall":return new h.Api.InputPrivacyKeyPhoneCall;case"phoneP2P":return new h.Api.InputPrivacyKeyPhoneP2P;case"voiceMessages":return new h.Api.InputPrivacyKeyVoiceMessages}}function Se(e){switch(e){case"spam":return new h.Api.InputReportReasonSpam;case"violence":return new h.Api.InputReportReasonViolence;case"childAbuse":return new h.Api.InputReportReasonChildAbuse;case"pornography":return new h.Api.InputReportReasonPornography;case"copyright":return new h.Api.InputReportReasonCopyright;case"fake":return new h.Api.InputReportReasonFake;case"geoIrrelevant":return new h.Api.InputReportReasonGeoIrrelevant;case"illegalDrugs":return new h.Api.InputReportReasonIllegalDrugs;case"personalDetails":return new h.Api.InputReportReasonPersonalDetails;case"other":return new h.Api.InputReportReasonOther}}function Ie(e){return new h.Api.DataJSON({data:JSON.stringify(e)})}function Pe(e,t){return"number"==typeof e?H()(Math.abs(e)):"user"===t?H()(e):H()(e.slice(1))}function Ce(e){return new h.Api.InputGroupCall({id:H()(e.id),accessHash:H()(e.accessHash)})}function Me(e){let{id:t,accessHash:n}=e;return new h.Api.InputPhoneCall({id:H()(t),accessHash:H()(n)})}function ke(e){return"slug"in e?new h.Api.InputInvoiceSlug({slug:e.slug}):new h.Api.InputInvoiceMessage({peer:ie(e.chat.id,e.chat.accessHash),msgId:e.messageId})}function Re(e){return e?new h.Api.ReactionEmoji({emoticon:e}):new h.Api.ReactionEmpty}function Ee(e){const{self:t,min:n,about:s,date:a,versioned:i,canSelfUnmute:o,justJoined:r,left:d,muted:c,mutedByYou:u,source:l,volume:f,volumeByAdmin:g,videoJoined:p,peer:h,video:m,presentation:_,raiseHandRating:y}=e;return{isSelf:t,isMin:n,canSelfUnmute:o,isLeft:d,isMuted:c,isMutedByMe:u,hasJustJoined:r,isVolumeByAdmin:g,isVersioned:i,isVideoJoined:p,about:s,source:l,raiseHandRating:null==y?void 0:y.toString(),volume:f,date:new Date(a),isUser:z(h),id:$(h),video:m?Ue(m):void 0,presentation:_?Ue(_):void 0}}function Ue(e){const{audioSource:t,endpoint:n,paused:s,sourceGroups:a}=e;return{audioSource:t,endpoint:n,isPaused:s,sourceGroups:a.map(Be)}}function Be(e){return{semantics:e.semantics,sources:e.sources}}function De(e){const{id:t,accessHash:n}=e;if(e instanceof h.Api.GroupCallDiscarded)return{connectionState:"discarded",id:t.toString(),accessHash:n.toString(),participantsCount:0,version:0,participants:{}};const{version:s,participantsCount:a,streamDcId:i,scheduleDate:o,canChangeJoinMuted:r,joinMuted:d,canStartVideo:c,scheduleStartSubscribed:u}=e;return{connectionState:"disconnected",isLoaded:!0,id:t.toString(),accessHash:n.toString(),version:s,participantsCount:a,streamDcId:i,scheduleDate:o,canChangeJoinMuted:r,joinMuted:d,canStartVideo:c,scheduleStartSubscribed:u,participants:{}}}function Te(e){const{id:t}=e;let n={id:t.toString()};if(e instanceof h.Api.PhoneCallAccepted||e instanceof h.Api.PhoneCallWaiting||e instanceof h.Api.PhoneCall||e instanceof h.Api.PhoneCallRequested){const{accessHash:t,adminId:s,date:a,video:i,participantId:o,protocol:r}=e;n={...n,accessHash:t.toString(),adminId:s.toString(),participantId:o.toString(),date:a,isVideo:i,protocol:Ne(r)}}if(e instanceof h.Api.PhoneCall){const{p2pAllowed:t,gAOrB:s,keyFingerprint:a,connections:i,startDate:o}=e;n={...n,state:"active",gAOrB:Array.from(s),keyFingerprint:a.toString(),startDate:o,p2pAllowed:t,connections:i.map(Ve).filter(Boolean)}}return e instanceof h.Api.PhoneCallDiscarded&&(n={...n,state:"discarded",duration:e.duration,reason:xe(e.reason),needRating:e.needRating,needDebug:e.needDebug}),e instanceof h.Api.PhoneCallWaiting&&(n={...n,state:"waiting",receiveDate:e.receiveDate}),e instanceof h.Api.PhoneCallAccepted&&(n={...n,state:"accepted",gB:Array.from(e.gB)}),e instanceof h.Api.PhoneCallRequested&&(n={...n,state:"requested",gAHash:Array.from(e.gAHash)}),n}function xe(e){return e instanceof h.Api.PhoneCallDiscardReasonMissed?"missed":e instanceof h.Api.PhoneCallDiscardReasonBusy?"busy":e instanceof h.Api.PhoneCallDiscardReasonHangup?"hangup":"disconnect"}function Ve(e){if(e instanceof h.Api.PhoneConnectionWebrtc){const{username:t,password:n,turn:s,stun:a,ip:i,ipv6:o,port:r}=e;return{username:t,password:n,isTurn:s,isStun:a,ip:i,ipv6:o,port:r}}}function Ne(e){const{libraryVersions:t,minLayer:n,maxLayer:s,udpP2p:a,udpReflector:i}=e;return{libraryVersions:t,minLayer:n,maxLayer:s,isUdpP2p:a,isUdpReflector:i}}function Fe(){return new h.Api.PhoneCallProtocol({libraryVersions:["4.0.0"],minLayer:92,maxLayer:92,udpReflector:!0,udpP2p:!0})}String.fromCharCode(8205);const qe=/(?:\ud83d\udc68\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffc-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb\udffd-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb-\udffd\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb-\udffe]|\ud83d\udc68\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc68\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc68\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffc-\udfff]|\ud83e\uddd1\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb\udffd-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb-\udffd\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83e\udef1\ud83c\udffb\u200d\ud83e\udef2\ud83c[\udffc-\udfff]|\ud83e\udef1\ud83c\udffc\u200d\ud83e\udef2\ud83c[\udffb\udffd-\udfff]|\ud83e\udef1\ud83c\udffd\u200d\ud83e\udef2\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\udef1\ud83c\udffe\u200d\ud83e\udef2\ud83c[\udffb-\udffd\udfff]|\ud83e\udef1\ud83c\udfff\u200d\ud83e\udef2\ud83c[\udffb-\udffe]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1|\ud83d\udc6b\ud83c[\udffb-\udfff]|\ud83d\udc6c\ud83c[\udffb-\udfff]|\ud83d\udc6d\ud83c[\udffb-\udfff]|\ud83d\udc8f\ud83c[\udffb-\udfff]|\ud83d\udc91\ud83c[\udffb-\udfff]|\ud83e\udd1d\ud83c[\udffb-\udfff]|\ud83d[\udc6b-\udc6d\udc8f\udc91]|\ud83e\udd1d)|(?:\ud83d[\udc68\udc69]|\ud83e\uddd1)(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf7c\udf84\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddaf-\uddb3\uddbc\uddbd])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc70\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddcd-\uddcf\uddd4\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83d\ude36\u200d\ud83c\udf2b\ufe0f|\u2764\ufe0f\u200d\ud83d\udd25|\u2764\ufe0f\u200d\ud83e\ude79|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc15\u200d\ud83e\uddba|\ud83d\udc3b\u200d\u2744\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83d\ude2e\u200d\ud83d\udca8|\ud83d\ude35\u200d\ud83d\udcab|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f|\ud83d\udc08\u200d\u2b1b)|[#*0-9]\ufe0f?\u20e3|(?:[ยฉยฎ\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26a7\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd0c\udd0f\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\udd77\uddb5\uddb6\uddb8\uddb9\uddbb\uddcd-\uddcf\uddd1-\udddd\udec3-\udec5\udef0-\udef6]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udc8e\udc90\udc92-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\uded5-\uded7\udedd-\udedf\udeeb\udeec\udef4-\udefc\udfe0-\udfeb\udff0]|\ud83e[\udd0d\udd0e\udd10-\udd17\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd3f-\udd45\udd47-\udd76\udd78-\uddb4\uddb7\uddba\uddbc-\uddcc\uddd0\uddde-\uddff\ude70-\ude74\ude78-\ude7c\ude80-\ude86\ude90-\udeac\udeb0-\udeba\udec0-\udec2\uded0-\uded9\udee0-\udee7]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g,Le=new RegExp(`^(?:${qe.source})+$`,""),Ge=e=>{const t=e.split("\n"),n=t.join("");if(n.length>800)return!1;if(!Boolean(n.match(Le)))return!1;const s=t.map((e=>{let t=0;for(;qe.exec(e);)if(t++,t>100)return qe.lastIndex=0,-1;return t}));let a=t.length;for(let e=0;ea&&(a=s[e])}return a},He="temp";let Oe=0;const Ke=()=>parseFloat(`${Date.now()}.${Oe++}`);let ze;function je(e){const{fromId:t,message:n,entities:s,startParam:a,channelPost:i,chatInvite:o,chatInviteHash:r,randomId:d,recommended:c}=e,u=t?$(t):void 0,l=o?o instanceof h.Api.ChatInvite?o.title:o.chat instanceof h.Api.ChatEmpty?void 0:o.chat.title:void 0;return{randomId:te(d),isBot:!!t&&z(t),text:tt(n,s),expiresAt:Math.round(Date.now()/1e3)+3e5,isRecommended:Boolean(c),...u&&{chatId:u},...r&&{chatInviteHash:r},...o&&{chatInviteTitle:l},...a&&{startParam:a},...i&&{channelPostId:i}}}function We(e){const t=Q(e);if(t&&(e instanceof h.Api.Message||e instanceof h.Api.MessageService))return $e(t,e)}function $e(e,t){const n=t.fromId?$(t.fromId):void 0,s=t.peerId?$(t.peerId):void 0,a=!n&&e===ze,i=t.out&&!t.post||a&&!t.fwdFrom,o=et(t),r=t.action&&function(e,t,n,s,a){if(e instanceof h.Api.MessageActionEmpty)return;let i,o,r,d,c;const u=[];let l,f,g,p="other";const m="users"in e?e.users&&e.users.map((e=>W(e,"user"))):"userId"in e&&[W(e.userId,"user")]||[];let _;if(e instanceof h.Api.MessageActionChatCreate)c="Notification.CreatedChatWithTitle",u.push("%action_origin%",e.title),p="chatCreate";else if(e instanceof h.Api.MessageActionChatEditTitle)s?(c="Channel.MessageTitleUpdated",u.push(e.title)):(c="Notification.ChangedGroupName",u.push("%action_origin%",e.title));else if(e instanceof h.Api.MessageActionChatEditPhoto)s?c="Channel.MessagePhotoUpdated":(c="Notification.ChangedGroupPhoto",u.push("%action_origin%"));else if(e instanceof h.Api.MessageActionChatDeletePhoto)c=s?"Channel.MessagePhotoRemoved":"Group.MessagePhotoRemoved";else if(e instanceof h.Api.MessageActionChatAddUser)!t||m.includes(t)?(c="Notification.JoinedChat",u.push("%target_user%")):(c="Notification.Invited",u.push("%action_origin%","%target_user%"));else if(e instanceof h.Api.MessageActionChatDeleteUser)!t||m.includes(t)?(c="Notification.LeftChat",u.push("%target_user%")):(c="Notification.Kicked",u.push("%action_origin%","%target_user%"));else if(e instanceof h.Api.MessageActionChatJoinedByLink)c="Notification.JoinedGroupByLink",u.push("%action_origin%");else if(e instanceof h.Api.MessageActionChannelCreate)c="Notification.CreatedChannel";else if(e instanceof h.Api.MessageActionChatMigrateTo)_=$(e),c="Migrated to %target_chat%",u.push("%target_chat%");else if(e instanceof h.Api.MessageActionChannelMigrateFrom)_=$(e),c="Migrated from %target_chat%",u.push("%target_chat%");else if(e instanceof h.Api.MessageActionPinMessage)c="Chat.Service.Group.UpdatedPinnedMessage1",u.push("%action_origin%","%message%");else if(e instanceof h.Api.MessageActionHistoryClear)c="HistoryCleared",p="historyClear";else if(e instanceof h.Api.MessageActionPhoneCall){const t=Boolean(e.duration);if(c=[t?"ChatList.Service":"Chat",e.video?"VideoCall":"Call",a?t?"outgoing":"Outgoing":t?"incoming":"Incoming"].join("."),t){const t=Math.max(Math.round(e.duration/60),1);u.push(`${t} min${t>1?"s":""}`)}i={isOutgoing:a,isVideo:e.video,duration:e.duration,reason:xe(e.reason)}}else if(e instanceof h.Api.MessageActionInviteToGroupCall)c="Notification.VoiceChatInvitation",o={id:e.call.id.toString(),accessHash:e.call.accessHash.toString()},u.push("%action_origin%","%target_user%");else if(e instanceof h.Api.MessageActionContactSignUp)c="Notification.Joined",u.push("%action_origin%"),p="contactSignUp";else if(e instanceof h.Api.MessageActionPaymentSent)r=Number(e.totalAmount),d=e.currency,c="PaymentSuccessfullyPaid",n&&m.push(n),u.push("%payment_amount%","%target_user%","%product%");else if(e instanceof h.Api.MessageActionGroupCall)if(e.duration){const t=Math.max(Math.round(e.duration/60),1);c="Notification.VoiceChatEnded",u.push(`${t} min${t>1?"s":""}`)}else c="Notification.VoiceChatStartedChannel",o={id:e.call.id.toString(),accessHash:e.call.accessHash.toString()};else e instanceof h.Api.MessageActionBotAllowed?(c="Chat.Service.BotPermissionAllowed",u.push(e.domain)):e instanceof h.Api.MessageActionCustomAction?c=e.message:e instanceof h.Api.MessageActionChatJoinedByRequest?(c="ChatService.UserJoinedGroupByRequest",u.push("%action_origin%")):e instanceof h.Api.MessageActionGameScore?(c=t===ze?"ActionYouScoredInGame":"ActionUserScoredInGame",u.push("%score%"),f=e.score):e instanceof h.Api.MessageActionWebViewDataSent?(c="Notification.WebAppSentData",u.push(e.text)):e instanceof h.Api.MessageActionGiftPremium?(c=a?"ActionGiftOutbound":"ActionGiftInbound",a?u.push("%gift_payment_amount%"):u.push("%action_origin%","%gift_payment_amount%"),n&&m.push(n),d=e.currency,r=e.amount.toJSNumber(),g=e.months):c="ChatList.UnsupportedMessage";return"photo"in e&&e.photo instanceof h.Api.Photo&&(Y(e.photo),l=C(e.photo)),{text:c,type:p,targetUserIds:m,targetChatId:_,photo:l,amount:r,currency:d,translationValues:u,call:o,phoneCall:i,score:f,months:g}}(t.action,n,s,Boolean(t.post),i);r&&(o.action=r);const d=t.media instanceof h.Api.MessageMediaInvoice&&Boolean(t.media.extendedMedia),{replyToMsgId:c,replyToTopId:u,replyToPeerId:l}=t.replyTo||{},f=t.editDate&&!t.editHide,{inlineButtons:g,keyboardButtons:p,keyboardPlaceholder:m,isKeyboardSingleUse:_}=function(e,t){const{replyMarkup:n,media:s}=e;if(!n)return s instanceof h.Api.MessageMediaWebPage&&s.webpage instanceof h.Api.WebPage&&"telegram_message"===s.webpage.type?{inlineButtons:[[{type:"url",text:"Show Message",url:s.webpage.url}]]}:void 0;if(!(n instanceof h.Api.ReplyKeyboardMarkup||n instanceof h.Api.ReplyInlineMarkup))return;const a=n.rows.map((e=>{let{buttons:n}=e;return n.map((e=>{const{text:n}=e;if(e instanceof h.Api.KeyboardButton)return{type:"command",text:n};if(e instanceof h.Api.KeyboardButtonUrl)return e.url.includes("?startgroup=")?{type:"unsupported",text:n}:{type:"url",text:n,url:e.url};if(e instanceof h.Api.KeyboardButtonCallback)return e.requiresPassword?{type:"unsupported",text:n}:{type:"callback",text:n,data:te(e.data)};if(e instanceof h.Api.KeyboardButtonRequestPoll)return{type:"requestPoll",text:n,isQuiz:e.quiz};if(e instanceof h.Api.KeyboardButtonRequestPhone)return{type:"requestPhone",text:n};if(e instanceof h.Api.KeyboardButtonBuy){if(s instanceof h.Api.MessageMediaInvoice&&s.receiptMsgId)return{type:"receipt",text:"PaymentReceipt",receiptMessageId:s.receiptMsgId};if(t)return;return{type:"buy",text:n}}return e instanceof h.Api.KeyboardButtonGame?{type:"game",text:n}:e instanceof h.Api.KeyboardButtonSwitchInline?{type:"switchBotInline",text:n,query:e.query,isSamePeer:e.samePeer}:e instanceof h.Api.KeyboardButtonUserProfile?{type:"userProfile",text:n,userId:e.userId.toString()}:e instanceof h.Api.KeyboardButtonSimpleWebView?{type:"simpleWebView",text:n,url:e.url}:e instanceof h.Api.KeyboardButtonWebView?{type:"webView",text:n,url:e.url}:e instanceof h.Api.KeyboardButtonUrlAuth?{type:"urlAuth",text:n,url:e.url,buttonId:e.buttonId}:{type:"unsupported",text:n}})).filter(Boolean)}));return a.every((e=>!e.length))?void 0:{[n instanceof h.Api.ReplyKeyboardMarkup?"keyboardButtons":"inlineButtons"]:a,...n instanceof h.Api.ReplyKeyboardMarkup&&{keyboardPlaceholder:n.placeholder,isKeyboardSingleUse:n.singleUse}}}(t,d)||{},y=t.fwdFrom&&function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=e.savedFromPeer&&$(e.savedFromPeer),s=e.fromId&&$(e.fromId);return{date:e.date,isChannelPost:Boolean(e.channelPost),channelPostId:e.channelPost,isLinkedChannelPost:Boolean(e.channelPost&&n&&!t),fromChatId:n||s,fromMessageId:e.savedFromMsgId||e.channelPost,senderUserId:s,hiddenUserName:e.fromName,adminTitle:e.postAuthor}}(t.fwdFrom,a),{replies:b,mediaUnread:w,postAuthor:v}=t,A=t.groupedId&&String(t.groupedId),S=Boolean(A)&&!(o.document||o.audio||o.sticker),I=t.replyMarkup instanceof h.Api.ReplyKeyboardHide,P=t.noforwards||d,M=!t.noforwards,k=o.text&&Ge(o.text.text);return{id:t.id,chatId:e,isOutgoing:i,content:o,date:t.date,senderId:n||t.out&&t.post&&ze||e,views:t.views,forwards:t.forwards,isFromScheduled:t.fromScheduled,isSilent:t.silent,reactions:t.reactions&&Je(t.reactions),...k&&{emojiOnlyCount:k},...c&&{replyToMessageId:c},...l&&{replyToChatId:$(l)},...u&&{replyToTopMessageId:u},...y&&{forwardInfo:y},...f&&{isEdited:f},...t.editDate&&{editDate:t.editDate},...w&&{isMediaUnread:w},...t.mentioned&&w&&{hasUnreadMention:!0},...t.mentioned&&{isMentioned:!0},...A&&{groupedId:A,isInAlbum:S},inlineButtons:g,...p&&{keyboardButtons:p,keyboardPlaceholder:m,isKeyboardSingleUse:_},...I&&{shouldHideKeyboardButtons:I},...t.viaBotId&&{viaBotId:W(t.viaBotId,"user")},...(null==b?void 0:b.comments)&&{threadInfo:mt(b,t.id,e)},...v&&{adminTitle:v},isProtected:P,isForwardingAllowed:M}}function Je(e){const{recentReactions:t,results:n,canSeeList:s}=e;return{canSeeList:s,results:n.map(Qe).filter(Boolean),recentReactions:null==t?void 0:t.map(Xe).filter(Boolean)}}function Qe(e){const{chosenOrder:t,count:n,reaction:s}=e,a=Ye(s);if(a)return{isChosen:void 0!==t,count:n,reaction:a}}function Xe(e){const{peerId:t,reaction:n,big:s,unread:a}=e,i=Ye(n);if(i)return{userId:$(t),reaction:i,isUnread:a,isBig:s}}function Ye(e){if(e instanceof h.Api.ReactionEmoji)return e.emoticon}function Ze(e){const{selectAnimation:t,staticIcon:n,reaction:s,title:a,inactive:i,aroundAnimation:o,centerIcon:r,effectAnimation:d,activateAnimation:c,premium:u}=e;return{selectAnimation:it(t),activateAnimation:it(c),effectAnimation:it(d),staticIcon:it(n),aroundAnimation:o?it(o):void 0,centerIcon:r?it(r):void 0,reaction:s,title:a,isInactive:i,isPremium:u}}function et(e){var t;let n={};e.media&&(n={...st(e.media)});const s=e.media instanceof h.Api.MessageMediaUnsupported;return!e.message||s||n.sticker||n.poll||n.contact||null!==(t=n.video)&&void 0!==t&&t.isRound||(n={...n,text:tt(e.message,e.entities)}),n}function tt(e,t){return{text:e,...t&&{entities:t.map(ht)}}}function nt(e){if(e instanceof h.Api.DraftMessageEmpty)return;const{message:t,entities:n,replyToMsgId:s,date:a}=e;return{formattedText:t?tt(t,n):void 0,replyingToId:s,date:a}}function st(e){if("ttlSeconds"in e&&e.ttlSeconds)return;if("extendedMedia"in e&&e.extendedMedia instanceof h.Api.MessageExtendedMedia)return st(e.extendedMedia.media);const t=function(e){if(e instanceof h.Api.MessageMediaDocument&&e.document&&e.document instanceof h.Api.Document)return x(e.document,e.nopremium)}(e);if(t)return{sticker:t};const n=function(e){if(e instanceof h.Api.MessageMediaPhoto&&e.photo&&e.photo instanceof h.Api.Photo)return C(e.photo)}(e);if(n)return{photo:n};const s=function(e){if(e instanceof h.Api.MessageMediaDocument&&e.document instanceof h.Api.Document&&e.document.mimeType.startsWith("video"))return at(e.document)}(e);if(s)return{video:s};const a=function(e){if(!(e instanceof h.Api.MessageMediaDocument&&e.document&&e.document instanceof h.Api.Document))return;const t=e.document.attributes.find((e=>e instanceof h.Api.DocumentAttributeAudio));if(!t||t.voice)return;const n=e.document.thumbs&&e.document.thumbs.filter((e=>e instanceof h.Api.PhotoSize)).map((e=>k(e)));return{id:String(e.document.id),fileName:ut(e.document,"audio"),thumbnailSizes:n,size:e.document.size.toJSNumber(),..._(e.document,["mimeType"]),..._(t,["duration","performer","title"])}}(e);if(a)return{audio:a};const i=function(e){if(!(e instanceof h.Api.MessageMediaDocument&&e.document&&e.document instanceof h.Api.Document))return;const t=e.document.attributes.find((e=>e instanceof h.Api.DocumentAttributeAudio));if(!t||!t.voice)return;const{duration:n,waveform:s}=t;return{id:String(e.document.id),duration:n,waveform:s?Array.from(s):void 0}}(e);if(i)return{voice:i};const o=function(e){if(e instanceof h.Api.MessageMediaDocument&&e.document)return it(e.document)}(e);if(o)return{document:o};const r=function(e){if(!(e instanceof h.Api.MessageMediaContact))return;const{firstName:t,lastName:n,phoneNumber:s,userId:a}=e;return{firstName:t,lastName:n,phoneNumber:s,userId:W(a,"user")}}(e);if(r)return{contact:r};const d=function(e){if(e instanceof h.Api.MessageMediaPoll)return rt(e.poll,e.results)}(e);if(d)return{poll:d};const c=ct(e);if(c)return{webPage:c};const u=function(e){if(e instanceof h.Api.MessageMediaInvoice)return function(e){const{description:t,title:n,photo:s,test:a,totalAmount:i,currency:o,receiptMsgId:r,extendedMedia:d}=e,c=d instanceof h.Api.MessageExtendedMediaPreview?ft(d):void 0;return{title:n,text:t,photo:gt(s),receiptMsgId:r,amount:Number(i),currency:o,isTest:a,extendedMedia:c}}(e)}(e);if(u)return{invoice:u};const l=function(e){return e instanceof h.Api.MessageMediaGeo?function(e){const t=ot(e.geo);return t&&{type:"geo",geo:t}}(e):e instanceof h.Api.MessageMediaVenue?function(e){const{geo:t,title:n,provider:s,address:a,venueId:i,venueType:o}=e,r=ot(t);return r&&{type:"venue",geo:r,title:n,provider:s,address:a,venueId:i,venueType:o}}(e):e instanceof h.Api.MessageMediaGeoLive?function(e){const{geo:t,period:n,heading:s}=e,a=ot(t);return a&&{type:"geoLive",geo:a,period:n,heading:s}}(e):void 0}(e);if(l)return{location:l};const f=function(e){if(e instanceof h.Api.MessageMediaGame)return function(e){const{id:t,accessHash:n,shortName:s,title:a,description:i,photo:o,document:r}=e.game,d=o instanceof h.Api.Photo?C(o):void 0,c=r instanceof h.Api.Document?it(r):void 0;return{id:t.toString(),accessHash:n.toString(),shortName:s,title:a,description:i,photo:d,document:c}}(e)}(e);return f?{game:f}:void 0}function at(e){if(e instanceof h.Api.DocumentEmpty)return;const{id:t,mimeType:n,thumbs:s,size:a,attributes:i}=e;if("video/webm"===n&&!self.isWebmSupported)return;if(n===r&&!self.isMovSupported)return;const o=i.find((e=>e instanceof h.Api.DocumentAttributeVideo));if(!o)return;const d=i.find((e=>e instanceof h.Api.DocumentAttributeAnimated)),{duration:c,w:u,h:l,supportsStreaming:f=!1,roundMessage:g=!1}=o;return{id:String(t),mimeType:n,duration:c,fileName:ut(e,"video"),width:u,height:l,supportsStreaming:f,isRound:g,isGif:Boolean(d),thumbnail:P(s),size:a.toJSNumber()}}function it(e){if(!(e instanceof h.Api.Document))return;const{id:t,size:n,mimeType:s,date:a,thumbs:i,attributes:o}=e,r=i&&P(i);let u,l;const f=i&&i.find((e=>e instanceof h.Api.PhotoSize));if(f)if(l={width:f.w,height:f.h},d.has(s)){u="photo";const e=o.find((e=>e instanceof h.Api.DocumentAttributeImageSize));if(e){const{w:t,h:n}=e;l={width:t,height:n}}}else if(c.has(s)){u="video";const e=o.find((e=>e instanceof h.Api.DocumentAttributeVideo));if(e){const{w:t,h:n}=e;l={width:t,height:n}}}return{id:String(t),size:n.toJSNumber(),mimeType:s,timestamp:a,fileName:ut(e),thumbnail:r,mediaType:u,mediaSize:l}}function ot(e){if(e instanceof h.Api.GeoPointEmpty)return;const{long:t,lat:n,accuracyRadius:s,accessHash:a}=e;return{long:t,lat:n,accessHash:a.toString(),accuracyRadius:s}}function rt(e,t){const{id:n,answers:s}=e,a=s.map((e=>({text:e.text,option:te(e.option)})));return{id:String(n),summary:{isPublic:e.publicVoters,..._(e,["closed","multipleChoice","quiz","question","closePeriod","closeDate"]),answers:a},results:dt(t)}}function dt(e){const{results:t,totalVoters:n,recentVoters:s,solution:a,solutionEntities:i,min:o}=e,r=t&&t.map((e=>{let{option:t,chosen:n,correct:s,voters:a}=e;return{isChosen:n,isCorrect:s,option:te(t),votersCount:a}}));return{isMin:o,totalVoters:n,recentVoterIds:null==s?void 0:s.map((e=>W(e,"user"))),results:r,solution:a,...i&&{solutionEntities:i.map(ht)}}}function ct(e){if(!(e instanceof h.Api.MessageMediaWebPage&&e.webpage instanceof h.Api.WebPage))return;const{id:t,photo:n,document:s}=e.webpage;let a;return s instanceof h.Api.Document&&s.mimeType.startsWith("video/")&&(a=at(s)),{id:Number(t),..._(e.webpage,["url","displayUrl","type","siteName","title","description","duration"]),photo:n instanceof h.Api.Photo?C(n):void 0,document:!a&&s?it(s):void 0,video:a}}function ut(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"file";const{mimeType:n,attributes:s}=e,a=s.find((e=>e instanceof h.Api.DocumentAttributeFilename));if(a)return a.fileName;const i=n.split("/")[1];return`${t}${String(e.id)}.${i}`}function lt(e){const{filename:t,blobUrl:n,previewBlobUrl:s,mimeType:a,size:i}=e;if(e.quick){if(d.has(a)){const{width:t,height:s}=e.quick;return{photo:{id:He,sizes:[],thumbnail:{width:t,height:s,dataUri:""},blobUrl:n}}}if(c.has(a)){const{width:o,height:r,duration:d}=e.quick;return{video:{id:He,mimeType:a,duration:d||0,fileName:t,width:o,height:r,blobUrl:n,...s&&{thumbnail:{width:o,height:r,dataUri:s}},size:i}}}}if(e.voice){const{duration:t,waveform:n}=e.voice,{data:s}=L(n,63);return{voice:{id:He,duration:t,waveform:s}}}if(u.has(a)){const{duration:n,performer:s,title:o}=e.audio||{};return{audio:{id:He,mimeType:a,fileName:t,size:i,duration:n||0,title:o,performer:s}}}return{document:{mimeType:a,fileName:t,size:i,...s&&{previewBlobUrl:s}}}}function ft(e){const{w:t,h:n,thumb:s,videoDuration:a}=e;return{width:t,height:n,duration:a,thumbnail:s?P([s]):void 0}}function gt(e){if(!e)return;const{url:t,size:n,mimeType:s}=e,a=e instanceof h.Api.WebDocument?e.accessHash.toString():void 0,i=e.attributes.find((e=>e instanceof h.Api.DocumentAttributeImageSize));return{url:t,accessHash:a,size:n,mimeType:s,dimensions:i&&{width:i.w,height:i.h}}}function pt(e,t){return{poll:{id:String(t),summary:_(e.summary,["question","answers"]),results:{}}}}function ht(e){const{className:t,offset:n,length:s}=e;return e instanceof h.Api.MessageEntityMentionName?{type:y.MentionName,offset:n,length:s,userId:W(e.userId,"user")}:e instanceof h.Api.MessageEntityTextUrl?{type:y.TextUrl,offset:n,length:s,url:e.url}:e instanceof h.Api.MessageEntityPre?{type:y.Pre,offset:n,length:s,language:e.language}:e instanceof h.Api.MessageEntityCustomEmoji?{type:y.CustomEmoji,offset:n,length:s,documentId:e.documentId.toString()}:{type:t,offset:n,length:s}}function mt(e,t,n){const{channelId:s,replies:a,maxId:i,readMaxId:o,recentRepliers:r}=e;if(!s)return;const d=W(s,"channel");return"-777"!==d?{threadId:t,...n!==d?{chatId:d,originChannelId:n}:{chatId:n},messagesCount:a,lastMessageId:i,lastReadInboxMessageId:o,...r&&{recentReplierIds:r.map($)}}:void 0}const _t=e=>Math.floor(Date.now()/1e3)+e;function yt(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=Boolean("min"in e&&e.min),s="accessHash"in e&&String(e.accessHash),a="photo"in e&&e.photo&&"hasVideo"in e.photo&&e.photo.hasVideo,i="photo"in e&&e.photo&&kt(e.photo),o=Boolean("signatures"in e&&e.signatures),r=Boolean("hasLink"in e&&e.hasLink),d=Boolean("scam"in e&&e.scam),c=Boolean("fake"in e&&e.fake),u=Boolean("joinToSend"in e&&e.joinToSend),l=Boolean("joinRequest"in e&&e.joinRequest);return{isMin:n,hasPrivateLink:r,isSignaturesShown:o,...s&&{accessHash:s},hasVideoAvatar:a,...i&&{avatarHash:i},..."username"in e&&{username:e.username},..."verified"in e&&{isVerified:e.verified},..."callActive"in e&&{isCallActive:e.callActive},..."callNotEmpty"in e&&{isCallNotEmpty:e.callNotEmpty},..."date"in e&&{joinDate:e.date},..."participantsCount"in e&&void 0!==e.participantsCount&&{membersCount:e.participantsCount},..."noforwards"in e&&{isProtected:Boolean(e.noforwards)},...t&&{isSupport:!0},...wt(e),..."creator"in e&&{isCreator:e.creator},...vt(e),...At(e),fakeType:d?"scam":c?"fake":void 0,isJoinToSend:u,isJoinRequest:l}}function bt(e,t,n){const{peer:s,folderId:a,unreadMark:i,unreadCount:o,unreadMentionsCount:r,unreadReactionsCount:d,notifySettings:{silent:c,muteUntil:u},readOutboxMaxId:l,readInboxMaxId:f,draft:g}=e,p=c||"number"==typeof u&&_t(n){let{platform:t}=e;return"all"===t}));return t?_(t,["reason","text"]):void 0}(e.restrictionReason):void 0;n&&Object.assign(t,{isRestricted:!0,restrictionReason:n})}return e instanceof h.Api.Chat&&Object.assign(t,{isNotJoined:e.left}),e instanceof h.Api.Channel&&Object.assign(t,{isNotJoined:e.left}),t}function At(e){return!("migratedTo"in e)||!e.migratedTo||e.migratedTo instanceof h.Api.InputChannelEmpty?{}:{migratedTo:{chatId:$(e.migratedTo),...e.migratedTo instanceof h.Api.InputChannel&&{accessHash:String(e.migratedTo.accessHash)}}}}function St(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(e instanceof h.Api.ChatEmpty||e instanceof h.Api.UserEmpty))return{id:W(e.id,e instanceof h.Api.User?"user":"chat"),type:It(e),title:e instanceof h.Api.User?Mt(e):e.title,...yt(e,t)}}function It(e){return e instanceof h.Api.User||e instanceof h.Api.UserEmpty?"chatTypePrivate":e instanceof h.Api.Chat||e instanceof h.Api.ChatForbidden||e instanceof h.Api.ChatEmpty?"chatTypeBasicGroup":e.megagroup?"chatTypeSuperGroup":"chatTypeChannel"}function Pt(e){return z(e)?`user${e.userId}`:j(e)?`chat${e.chatId}`:`chat${e.channelId}`}function Ct(e,t){return z(e)?Mt(t):t.title}function Mt(e){return e.firstName?`${e.firstName}${e.lastName?` ${e.lastName}`:""}`:e.lastName||void 0}function kt(e){if("photoId"in e)return String(e.photoId)}function Rt(e){return{userId:e instanceof h.Api.ChannelParticipantBanned||e instanceof h.Api.ChannelParticipantLeft?$(e.peer):W(e.userId,"user"),inviterId:"inviterId"in e?W(e.inviterId,"user"):void 0,joinedDate:"date"in e?e.date:void 0,kickedByUserId:"kickedBy"in e?W(e.kickedBy,"user"):void 0,promotedByUserId:"promotedBy"in e?W(e.promotedBy,"user"):void 0,bannedRights:"bannedRights"in e?A(e.bannedRights):void 0,adminRights:"adminRights"in e?A(e.adminRights):void 0,customTitle:"rank"in e?e.rank:void 0,...(e instanceof h.Api.ChannelParticipantAdmin||e instanceof h.Api.ChatParticipantAdmin)&&{isAdmin:!0},...(e instanceof h.Api.ChannelParticipantCreator||e instanceof h.Api.ChatParticipantCreator)&&{isOwner:!0}}}function Et(e){return e instanceof h.Api.ChatParticipants||e instanceof h.Api.channels.ChannelParticipants?e.participants.map(Rt).filter(Boolean):void 0}function Ut(e,t){let n,s="";if(!(e.action instanceof h.Api.SendMessageCancelAction)){if(e.action instanceof h.Api.SendMessageTypingAction)s="lng_user_typing";else if(e.action instanceof h.Api.SendMessageRecordVideoAction)s="lng_send_action_record_video";else if(e.action instanceof h.Api.SendMessageUploadVideoAction)s="lng_send_action_upload_video";else if(e.action instanceof h.Api.SendMessageRecordAudioAction)s="lng_send_action_record_audio";else if(e.action instanceof h.Api.SendMessageUploadAudioAction)s="lng_send_action_upload_audio";else if(e.action instanceof h.Api.SendMessageUploadPhotoAction)s="lng_send_action_upload_photo";else if(e.action instanceof h.Api.SendMessageUploadDocumentAction)s="lng_send_action_upload_file";else if(e.action instanceof h.Api.SendMessageGeoLocationAction)s="selecting a location to share";else if(e.action instanceof h.Api.SendMessageChooseContactAction)s="selecting a contact to share";else if(e.action instanceof h.Api.SendMessageGamePlayAction)s="lng_playing_game";else if(e.action instanceof h.Api.SendMessageRecordRoundAction)s="lng_send_action_record_round";else if(e.action instanceof h.Api.SendMessageUploadRoundAction)s="lng_send_action_upload_round";else if(e.action instanceof h.Api.SendMessageChooseStickerAction)s="lng_send_action_choose_sticker";else{if(e.action instanceof h.Api.SpeakingInGroupCallAction)return;if(e.action instanceof h.Api.SendMessageEmojiInteractionSeen)s="lng_user_action_watching_animations",n=e.action.emoticon;else if(e.action instanceof h.Api.SendMessageEmojiInteraction)return}return{action:s,...n&&{emoji:n},...!(e instanceof h.Api.UpdateUserTyping)&&{userId:$(e.fromId)},timestamp:Date.now()+1e3*t}}}function Bt(e){return{...(t=e,n=["id","title","emoticon","contacts","nonContacts","groups","bots","excludeMuted","excludeRead","excludeArchived"],n.reduce(((e,n)=>(t[n]&&(e[n]=t[n]),e)),{})),channels:e.broadcasts,pinnedChatIds:e.pinnedPeers.map($).filter(Boolean),includedChatIds:e.includePeers.map($).filter(Boolean),excludedChatIds:e.excludePeers.map($).filter(Boolean)};var t,n}function Dt(e){let{filter:t,description:n}=e;if(t instanceof h.Api.DialogFilter)return{...Bt(t),description:n}}function Tt(e){return e.reduce(((e,t)=>{const n=W(t.userId,"user");return t.commands&&(e=e.concat(t.commands.map((e=>({botId:n,...A(e)}))))),e}),[])}function xt(e){const{revoked:t,date:n,expireDate:s,link:a,permanent:i,startDate:o,usage:r,usageLimit:d,requested:c,requestNeeded:u,title:l,adminId:f}=e;return{isRevoked:t,date:n,expireDate:s,link:a,isPermanent:i,startDate:o,usage:r,usageLimit:d,isRequestNeeded:u,requested:c,title:l,adminId:W(f,"user")}}function Vt(e){let{autoarchived:t,reportSpam:n,addContact:s,blockContact:a}=e;return{isAutoArchived:Boolean(t),canReportSpam:Boolean(n),canAddContact:Boolean(s),canBlockContact:Boolean(a)}}function Nt(e){return e instanceof h.Api.ChatReactionsAll?["๐","๐","โค","๐ฅ","๐ฅฐ","๐","๐","๐ค","๐คฏ","๐ฑ","๐คฌ","๐ข","๐","๐คฉ","๐คฎ","๐ฉ","๐","๐","๐","๐คก","๐ฅฑ","๐ฅด","๐","๐ณ","โคโ๐ฅ","๐","๐ญ","๐ฏ","๐คฃ","โก","๐","๐","๐","๐คจ","๐","๐","๐พ","๐","๐","๐","๐ด","๐ญ","๐ค","๐ป","๐จโ๐ป","๐","๐"]:e instanceof h.Api.ChatReactionsSome?e.reactions.map(Ye).filter(Boolean):void 0}function Ft(e){return{id:$(e.peer),isPremium:e.premiumRequired}}function qt(e){return{id:e.botId.toString(),hasSettings:e.hasSettings,shortName:e.shortName,peerTypes:e.peerTypes.map(Lt),icons:e.icons.map(Gt).filter(Boolean)}}function Lt(e){return e instanceof h.Api.AttachMenuPeerTypeBotPM?"bots":e instanceof h.Api.AttachMenuPeerTypePM?"users":e instanceof h.Api.AttachMenuPeerTypeChat?"chats":e instanceof h.Api.AttachMenuPeerTypeBroadcast?"channels":e instanceof h.Api.AttachMenuPeerTypeSameBotPM?"self":void 0}function Gt(e){if(!(e.icon instanceof h.Api.Document))return;const t=it(e.icon);return t?(U.documents[String(e.icon.id)]=e.icon,{name:e.name,document:t}):void 0}function Ht(e,t){const{description:n,descriptionPhoto:s,descriptionDocument:a,userId:i,commands:o,menuButton:r}=e,d=i&&W(i,"user"),c=s instanceof h.Api.Photo?C(s):void 0,u=a instanceof h.Api.Document?at(a):void 0,l=null==o?void 0:o.map((e=>function(e,t){return{botId:e,...A(t)}}(d||t,e)));return{botId:d||t,description:n,gif:u,photo:c,menuButton:Ot(r),commands:null!=l&&l.length?l:void 0}}function Ot(e){return e instanceof h.Api.BotMenuButton?{type:"webApp",text:e.text,url:e.url}:{type:"commands"}}function Kt(e){const{fullUser:{about:t,commonChatsCount:n,pinnedMsgId:s,botInfo:a,blocked:i,profilePhoto:o,voiceMessagesForbidden:r,premiumGifts:d},users:c}=e,u=zt(c[0]);return{...u,fullInfo:{...o instanceof h.Api.Photo&&{profilePhoto:C(o)},bio:t,commonChatsCount:n,pinnedMessageId:s,isBlocked:Boolean(i),noVoiceMessages:r,...d&&{premiumGifts:d.map((e=>function(e){const{months:t,currency:n,amount:s,botUrl:a}=e;return{months:t,currency:n,amount:s.toJSNumber(),botUrl:a}}(e)))},...a&&{botInfo:Ht(a,u.id)}}}}function zt(e){if(!(e instanceof h.Api.User))return;const{id:t,firstName:n,lastName:s,fake:a,scam:i}=e,o=e.photo instanceof h.Api.UserProfilePhoto?Boolean(e.photo.hasVideo):void 0,r=e.photo instanceof h.Api.UserProfilePhoto?String(e.photo.photoId):void 0,d=(c=e).bot?"userTypeBot":c.deleted?"userTypeDeleted":"userTypeRegular";var c;return{id:W(t,"user"),isMin:Boolean(e.min),fakeType:i?"scam":a?"fake":void 0,...e.self&&{isSelf:!0},isPremium:Boolean(e.premium),...e.verified&&{isVerified:!0},...(e.contact||e.mutualContact)&&{isContact:!0},type:d,...n&&{firstName:n},..."userTypeBot"===d&&{canBeInvitedToGroup:!e.botNochats},...s&&{lastName:s},username:e.username||"",phoneNumber:e.phone||"",noStatus:!e.status,...e.accessHash&&{accessHash:String(e.accessHash)},...r&&{avatarHash:r},...e.emojiStatus&&{emojiStatus:Wt(e.emojiStatus)},hasVideoAvatar:o,...e.bot&&e.botInlinePlaceholder&&{botPlaceholder:e.botInlinePlaceholder},...e.bot&&e.botAttachMenu&&{isAttachBot:e.botAttachMenu}}}function jt(e){return!e||e instanceof h.Api.UserStatusEmpty?{type:"userStatusEmpty"}:e instanceof h.Api.UserStatusOnline?{type:"userStatusOnline",expires:e.expires}:e instanceof h.Api.UserStatusOffline?{type:"userStatusOffline",wasOnline:e.wasOnline}:e instanceof h.Api.UserStatusRecently?{type:"userStatusRecently"}:e instanceof h.Api.UserStatusLastWeek?{type:"userStatusLastWeek"}:{type:"userStatusLastMonth"}}function Wt(e){return e instanceof h.Api.EmojiStatus?{documentId:e.documentId.toString()}:e instanceof h.Api.EmojiStatusUntil?{documentId:e.documentId.toString(),until:e.until}:void 0}function $t(e){const t={},n=[];return e.forEach((e=>{const s=zt(e);s&&(n.push(s),"status"in e&&(t[s.id]=jt(e.status)))})),{users:n,userStatusesById:t}}function Jt(e){if(e instanceof h.Api.WallPaperNoFile)return;const{slug:t}=e,n=it(e.document);return n?{slug:t,document:n}:void 0}function Qt(e){return{isCurrent:Boolean(e.current),isOfficialApp:Boolean(e.officialApp),isPasswordPending:Boolean(e.passwordPending),hash:String(e.hash),areCallsEnabled:!e.callRequestsDisabled,areSecretChatsEnabled:!e.encryptedRequestsDisabled,..._(e,["deviceModel","platform","systemVersion","appName","appVersion","dateCreated","dateActive","ip","country","region"])}}function Xt(e){return{hash:String(e.hash),botId:W(e.botId,"user"),..._(e,["platform","browser","dateCreated","dateActive","ip","region","domain"])}}function Yt(e){let t,n,s,a,i;return e.forEach((e=>{e instanceof h.Api.PrivacyValueAllowAll?t=t||"everybody":e instanceof h.Api.PrivacyValueAllowContacts?t=t||"contacts":e instanceof h.Api.PrivacyValueDisallowContacts?t=t||"nonContacts":e instanceof h.Api.PrivacyValueDisallowAll?t=t||"nobody":e instanceof h.Api.PrivacyValueAllowUsers?n=e.users.map((e=>W(e,"user"))):e instanceof h.Api.PrivacyValueDisallowUsers?a=e.users.map((e=>W(e,"user"))):e instanceof h.Api.PrivacyValueAllowChatParticipants?s=e.chats.map((e=>W(e,"chat"))):e instanceof h.Api.PrivacyValueDisallowChatParticipants&&(i=e.chats.map((e=>W(e,"chat"))))})),t||(t="nobody"),{visibility:t,allowUserIds:n||[],allowChatIds:s||[],blockUserIds:a||[],blockChatIds:i||[]}}function Zt(e,t,n){const{silent:s,muteUntil:a,showPreviews:i,otherSound:o}=e,r=Boolean(o&&!(o instanceof h.Api.NotificationSoundNone));return{chatId:$(t),isMuted:s||"number"==typeof a&&_t(n)(e[t.key]=tn(t.value),e)),{})}function nn(e){if(e instanceof h.Api.UrlAuthResultRequest){const{bot:t,domain:n,requestWriteAccess:s}=e,a=zt(t);if(!a)return;return Z(t),{type:"request",domain:n,shouldRequestWriteAccess:s,bot:a}}return e instanceof h.Api.UrlAuthResultAccepted?{type:"accepted",url:e.url}:e instanceof h.Api.UrlAuthResultDefault?{type:"default"}:void 0}let sn;const an=new Set;let on=0,rn=!1;function dn(e){e.filter((e=>e instanceof h.Api.User)).map(zt).forEach((e=>{e&&sn({"@type":"updateUser",id:e.id,user:e})})),e.filter((e=>e instanceof h.Api.Chat||e instanceof h.Api.ChatForbidden||e instanceof h.Api.Channel||e instanceof h.Api.ChannelForbidden)).map((e=>St(e))).forEach((e=>{e&&sn({"@type":"updateChat",id:e.id,chat:e})}))}function cn(e,t){if(e instanceof h.connection.UpdateServerTimeOffset)on=e.timeOffset;else if(e instanceof h.connection.UpdateConnectionState){let t;switch(e.state){case h.connection.UpdateConnectionState.disconnected:t="connectionStateConnecting";break;case h.connection.UpdateConnectionState.broken:t="connectionStateBroken";break;case h.connection.UpdateConnectionState.connected:default:t="connectionStateReady"}sn({"@type":"updateConnectionState",connectionState:t})}else if(e instanceof h.Api.UpdateNewMessage||e instanceof h.Api.UpdateNewScheduledMessage||e instanceof h.Api.UpdateNewChannelMessage||e instanceof h.Api.UpdateShortChatMessage||e instanceof h.Api.UpdateShortMessage){let t,s;if(e instanceof h.Api.UpdateShortChatMessage)t=$e(W((i=e).chatId,"chat"),{...i,fromId:ae(W(i.fromId,"user"))});else if(e instanceof h.Api.UpdateShortMessage)t=function(e){return $e(W(e.userId,"user"),{...e,fromId:ae(e.out?ze:W(e.userId,"user"))})}(e);else{var n;if(e.message instanceof h.Api.MessageEmpty)return;e.message instanceof h.Api.Message&&me(e.message)&&X(e.message),t=We(e.message),s="replyMarkup"in e.message&&(null===(n=e.message)||void 0===n?void 0:n.replyMarkup)instanceof h.Api.ReplyKeyboardForceReply&&(!e.message.replyMarkup.selective||t.isMentioned)}const a=e._entities;if(a&&(ee(a),dn(a)),e instanceof h.Api.UpdateNewScheduledMessage?sn({"@type":an.has(t.id)?"updateScheduledMessage":"newScheduledMessage",id:t.id,chatId:t.chatId,message:t}):sn({"@type":an.has(t.id)?"updateMessage":"newMessage",id:t.id,chatId:t.chatId,message:t,shouldForceReply:s}),e.message instanceof h.Api.MessageService){const{action:n}=e.message;if(n instanceof h.Api.MessageActionPaymentSent)sn({"@type":"updatePaymentStateCompleted",slug:n.invoiceSlug});else if(n instanceof h.Api.MessageActionChatEditTitle)sn({"@type":"updateChat",id:t.chatId,chat:{title:n.title}});else if(n instanceof h.Api.MessageActionChatEditPhoto){const s=function(e){if(e instanceof h.Api.PhotoEmpty)return new h.Api.ChatPhotoEmpty;const{dcId:t,id:n}=e;return new h.Api.ChatPhoto({dcId:t,photoId:n})}(n.photo),a=kt(s),i=Q(e.message);U.chats[i]&&(U.chats[i].photo=s),Y(n.photo),a&&sn({"@type":"updateChat",id:t.chatId,chat:{avatarHash:a},...n.photo instanceof h.Api.Photo&&{newProfilePhoto:C(n.photo)}})}else if(n instanceof h.Api.MessageActionChatDeletePhoto){const n=Q(e.message);U.chats[n]&&(U.chats[n].photo=new h.Api.ChatPhotoEmpty),sn({"@type":"updateChat",id:t.chatId,chat:{avatarHash:void 0}})}else n instanceof h.Api.MessageActionChatDeleteUser?e._entities&&e._entities.some((e=>e instanceof h.Api.User&&Boolean(e.self)&&e.id===n.userId))&&sn({"@type":"updateChat",id:t.chatId,chat:{isForbidden:!0,isNotJoined:!0}}):n instanceof h.Api.MessageActionChatAddUser?e._entities&&e._entities.some((e=>e instanceof h.Api.User&&Boolean(e.self)&&n.users.includes(e.id)))&&sn({"@type":"updateChatJoin",id:t.chatId}):n instanceof h.Api.MessageActionGroupCall&&!n.duration&&n.call&&sn({"@type":"updateGroupCallChatId",chatId:t.chatId,call:{id:n.call.id.toString(),accessHash:n.call.accessHash.toString()}})}}else if(e instanceof h.Api.UpdateEditMessage||e instanceof h.Api.UpdateEditChannelMessage){if(e.message instanceof h.Api.MessageEmpty)return;e.message instanceof h.Api.Message&&me(e.message)&&X(e.message);const t=We(e.message);sn({"@type":"updateMessage",id:t.id,chatId:t.chatId,message:t})}else if(e instanceof h.Api.UpdateMessageReactions)sn({"@type":"updateMessageReactions",id:e.msgId,chatId:$(e.peer),reactions:Je(e.reactions)});else if(e instanceof h.Api.UpdateMessageExtendedMedia){let t,n;if(e.extendedMedia instanceof h.Api.MessageExtendedMedia&&(t=st(e.extendedMedia.media)),e.extendedMedia instanceof h.Api.MessageExtendedMediaPreview&&(n=ft(e.extendedMedia)),!t&&!n)return;const s=$(e.peer);!function(e,t,n){const s=U.messages[`${e}-${t}`];if(s instanceof h.Api.Message&&s.media){if(n instanceof h.Api.MessageExtendedMediaPreview){if(!(s.media instanceof h.Api.MessageMediaInvoice))return;s.media.extendedMedia=n}n instanceof h.Api.MessageExtendedMedia&&(s.media=n.media)}}(s,e.msgId,e.extendedMedia),sn({"@type":"updateMessageExtendedMedia",id:e.msgId,chatId:s,media:t,preview:n})}else if(e instanceof h.Api.UpdateDeleteMessages)sn({"@type":"deleteMessages",ids:e.messages});else if(e instanceof h.Api.UpdateDeleteScheduledMessages)sn({"@type":"deleteScheduledMessages",ids:e.messages,chatId:$(e.peer)});else if(e instanceof h.Api.UpdateDeleteChannelMessages){const t=W(e.channelId,"channel"),n=e.messages,s=n.filter((e=>U.messages[`${t}-${e}`])),a=n.filter((e=>!U.messages[`${t}-${e}`])),i=n.map((e=>{const n=U.messages[`${t}-${e}`];return n&&n instanceof h.Api.MessageService&&"photo"in n.action?String(n.action.photo.id):void 0})).filter(Boolean);s.length&&sn({"@type":"deleteMessages",ids:s,chatId:t}),i.length&&sn({"@type":"deleteProfilePhotos",ids:i,chatId:t}),a.length&&setTimeout((()=>{sn({"@type":"deleteMessages",ids:a,chatId:t})}),1e3)}else if(e instanceof h.Api.UpdateServiceNotification)if(e.popup)sn({"@type":"error",error:{message:e.message}});else{const t=function(e,t){const n=Ke(),s=et(e);return{id:n,chatId:l,date:e.inboxDate||t,content:s,isOutgoing:!1}}(e,Date.now()/1e3+on);me(e)&&X(pe(t.id,t.chatId,e)),sn({"@type":"updateServiceNotification",message:t})}else if((t instanceof h.Api.messages.SendMessage||t instanceof h.Api.messages.SendMedia||t instanceof h.Api.messages.SendMultiMedia||t instanceof h.Api.messages.ForwardMessages)&&(e instanceof h.Api.UpdateMessageID||e instanceof h.Api.UpdateShortSentMessage)){let n;"randomId"in e?n=e.randomId:"randomId"in t&&(n=t.randomId);const s=n&&U.localMessages[String(n)];if(!s)throw new Error("Local message not found");let a;if(e instanceof h.Api.UpdateShortSentMessage){s.content.text&&e.entities&&(a={text:tt(s.content.text.text,e.entities)}),e.media&&(a={...a,...st(e.media)});const t=pe(e.id,s.chatId,e);me(t)&&X(t)}an.add(e.id);const i="date"in e&&1e3*e.datee instanceof h.Api.DialogPeer)).map((e=>$(e.peer))):[];sn({"@type":"updatePinnedChatIds",ids:t,folderId:e.folderId||void 0})}else if(e instanceof h.Api.UpdateFolderPeers)e.folderPeers.forEach((e=>{const{folderId:t,peer:n}=e;sn({"@type":"updateChatListType",id:$(n),folderId:t})}));else if(e instanceof h.Api.UpdateDialogFilter){const{id:t,filter:n}=e,s=n instanceof h.Api.DialogFilter?Bt(n):void 0;sn({"@type":"updateChatFolder",id:t,folder:s})}else if(e instanceof h.Api.UpdateDialogFilterOrder)sn({"@type":"updateChatFoldersOrder",orderedIds:e.order});else if(e instanceof h.Api.UpdateChatParticipants){const t=Et(e.participants);sn({"@type":"updateChatMembers",id:W(e.participants.chatId,"chat"),replacedMembers:t})}else if(e instanceof h.Api.UpdateChatParticipantAdd){const t=Rt(_(e,["userId","inviterId","date"]));sn({"@type":"updateChatMembers",id:W(e.chatId,"chat"),addedMember:t})}else if(e instanceof h.Api.UpdateChatParticipantDelete)sn({"@type":"updateChatMembers",id:W(e.chatId,"chat"),deletedMemberId:W(e.userId,"user")});else if(e instanceof h.Api.UpdatePinnedMessages||e instanceof h.Api.UpdatePinnedChannelMessages){const t=e instanceof h.Api.UpdatePinnedMessages?$(e.peer):W(e.channelId,"channel");sn({"@type":"updatePinnedIds",chatId:t,messageIds:e.messages,isPinned:e.pinned})}else if(e instanceof h.Api.UpdateNotifySettings&&e.peer instanceof h.Api.NotifyPeer)sn({"@type":"updateNotifyExceptions",...Zt(e.notifySettings,e.peer.peer,on)});else if(e instanceof h.Api.UpdateUserTyping||e instanceof h.Api.UpdateChatUserTyping){const t=e instanceof h.Api.UpdateUserTyping?W(e.userId,"user"):W(e.chatId,"chat");e.action instanceof h.Api.SendMessageEmojiInteraction?sn({"@type":"updateStartEmojiInteraction",id:t,emoji:e.action.emoticon,messageId:e.action.msgId,interaction:(a=JSON.parse(e.action.interaction.data),{timestamps:a.a.map((e=>e.t))})}):sn({"@type":"updateChatTypingStatus",id:t,typingStatus:Ut(e,on)})}else if(e instanceof h.Api.UpdateChannelUserTyping){const t=W(e.channelId,"channel");sn({"@type":"updateChatTypingStatus",id:t,typingStatus:Ut(e,on)})}else if(e instanceof h.Api.UpdateChannel){const{_entities:n}=e;if(!n)return;const s=n.find((e=>e instanceof h.Api.Channel||e instanceof h.Api.ChannelForbidden));if(s instanceof h.Api.Channel){if(rn)return void(rn=!1);t instanceof h.Api.messages.ToggleNoForwards&&(rn=!0,setTimeout((()=>{rn=!1}),2e3));const n=St(s);n&&(sn({"@type":"updateChat",id:n.id,chat:n}),sn({"@type":n.isNotJoined?"updateChatLeave":"updateChatJoin",id:W(e.channelId,"channel")}))}else if(s instanceof h.Api.ChannelForbidden){const t=W(e.channelId,"channel");sn({"@type":"updateChat",id:t,chat:{isRestricted:!0}}),sn({"@type":"updateChatLeave",id:t})}else 0===n.length&&sn({"@type":"resetMessages",id:W(e.channelId,"channel")})}else if(e instanceof h.Api.UpdateDialogUnreadMark&&e.peer instanceof h.Api.DialogPeer)sn({"@type":"updateChat",id:$(e.peer.peer),chat:{hasUnreadMark:e.unread}});else if(e instanceof h.Api.UpdateChatDefaultBannedRights)sn({"@type":"updateChat",id:$(e.peer),chat:{defaultBannedRights:A(e.defaultBannedRights)}});else if(e instanceof h.Api.UpdateUserStatus)sn({"@type":"updateUserStatus",userId:W(e.userId,"user"),status:jt(e.status)});else if(e instanceof h.Api.UpdateUserEmojiStatus){const t=Wt(e.emojiStatus);sn({"@type":"updateUserEmojiStatus",userId:W(e.userId,"user"),emojiStatus:t})}else if(e instanceof h.Api.UpdateUserName){const t=W(e.userId,"user"),n=U.users[t],s=null!=n&&n.mutualContact&&!n.self?_(e,["username"]):_(e,["firstName","lastName","username"]);sn({"@type":"updateUser",id:t,user:s})}else if(e instanceof h.Api.UpdateUserPhoto){const{userId:t,photo:n}=e,s=W(t,"user"),a=kt(n);U.users[s]&&(U.users[s].photo=n),sn({"@type":"updateUser",id:s,user:{avatarHash:a}})}else if(e instanceof h.Api.UpdateUserPhone){const{userId:t,phone:n}=e;sn({"@type":"updateUser",id:W(t,"user"),user:{phoneNumber:n}})}else if(e instanceof h.Api.UpdatePeerSettings){const{_entities:t,settings:n}=e;if(!t)return;null!=t&&t.length&&(t.filter((e=>e instanceof h.Api.User&&!e.contact)).forEach((e=>{sn({"@type":"deleteContact",id:W(e.id,"user")})})),t.filter((e=>e instanceof h.Api.User&&e.contact)).map(zt).forEach((e=>{e&&sn({"@type":"updateUser",id:e.id,user:{...e,...n&&{settings:Vt(n)}}})})))}else if(e instanceof h.Api.UpdateNotifySettings){const{notifySettings:{showPreviews:t,silent:n,muteUntil:s},peer:{className:a}}=e,i="NotifyUsers"===a?"contact":"NotifyChats"===a?"group":"NotifyBroadcasts"===a?"broadcast":void 0;if(!i)return;sn({"@type":"updateNotifySettings",peerType:i,isSilent:Boolean(n||"number"==typeof s&&Date.now()+1e3*on<1e3*s),shouldShowPreviews:Boolean(t)})}else if(e instanceof h.Api.UpdatePeerBlocked)sn({"@type":"updatePeerBlocked",id:$(e.peerId),isBlocked:e.blocked});else if(e instanceof h.Api.UpdatePrivacy){const t=function(e){switch(e.className){case"PrivacyKeyPhoneNumber":return"phoneNumber";case"PrivacyKeyStatusTimestamp":return"lastSeen";case"PrivacyKeyProfilePhoto":return"profilePhoto";case"PrivacyKeyPhoneCall":return"phoneCall";case"PrivacyKeyPhoneP2P":return"phoneP2P";case"PrivacyKeyForwards":return"forwards";case"PrivacyKeyVoiceMessages":return"voiceMessages";case"PrivacyKeyChatInvite":return"chatInvite"}}(e.key);t&&sn({"@type":"updatePrivacy",key:t,rules:Yt(e.rules)})}else if(e instanceof h.Api.UpdateDraftMessage)sn({"@type":"draftMessage",chatId:$(e.peer),...nt(e.draft)});else if(e instanceof h.Api.UpdateContactsReset)sn({"@type":"updateResetContactList"});else if(e instanceof h.Api.UpdateFavedStickers)sn({"@type":"updateFavoriteStickers"});else if(e instanceof h.Api.UpdateRecentStickers)sn({"@type":"updateRecentStickers"});else if(e instanceof h.Api.UpdateStickerSets)sn({"@type":"updateStickerSets"});else if(e instanceof h.Api.UpdateStickerSetsOrder)sn({"@type":"updateStickerSetsOrder",order:e.order.map((e=>e.toString())),isCustomEmoji:e.emojis});else if(e instanceof h.Api.UpdateNewStickerSet){if(e.stickerset instanceof h.Api.messages.StickerSet){const t=V(e.stickerset.set);sn({"@type":"updateStickerSet",id:t.id,stickerSet:t})}}else if(e instanceof h.Api.UpdateSavedGifs)sn({"@type":"updateSavedGifs"});else if(e instanceof h.Api.UpdateGroupCall)sn({"@type":"updateGroupCall",call:De(e.call)});else if(e instanceof h.Api.UpdateGroupCallConnection)sn({"@type":"updateGroupCallConnection",data:JSON.parse(e.params.data),presentation:Boolean(e.presentation)});else if(e instanceof h.Api.UpdateGroupCallParticipants){const t=e._entities;t&&(ee(t),dn(t)),sn({"@type":"updateGroupCallParticipants",groupCallId:(s=e.call,s.id.toString()),participants:e.participants.map(Ee)})}else if(e instanceof h.Api.UpdatePendingJoinRequests){const t=e._entities;t&&(ee(t),dn(t)),sn({"@type":"updatePendingJoinRequests",chatId:$(e.peer),recentRequesterIds:e.recentRequesters.map((e=>W(e,"user"))),requestsPending:e.requestsPending})}else if(e instanceof h.Api.UpdatePhoneCall){const t=e._entities;t&&(ee(t),dn(t)),sn({"@type":"updatePhoneCall",call:Te(e.phoneCall)})}else if(e instanceof h.Api.UpdatePhoneCallSignalingData)sn({"@type":"updatePhoneCallSignalingData",callId:e.phoneCallId.toString(),data:Array.from(e.data)});else if(e instanceof h.Api.UpdateWebViewResultSent){const{queryId:t}=e;sn({"@type":"updateWebViewResultSent",queryId:t.toString()})}else if(e instanceof h.Api.UpdateBotMenuButton){const{botId:t,button:n}=e,s=W(t,"user");sn({"@type":"updateBotMenuButton",botId:s,button:Ot(n)})}else if(e instanceof h.Api.UpdateTranscribedAudio){const t=e._entities;t&&(ee(t),dn(t)),sn({"@type":"updateTranscribedAudio",transcriptionId:e.transcriptionId.toString(),text:e.text,isPending:e.pending})}else if(e instanceof h.Api.UpdateConfig){const t=e._entities;t&&(ee(t),dn(t))}var s,a,i}const un={PHONE_NUMBER_INVALID:"Invalid phone number.",PHONE_CODE_INVALID:"Invalid code.",PASSWORD_HASH_INVALID:"Incorrect password.",PHONE_PASSWORD_FLOOD:"Limit exceeded. Please try again later.",PHONE_NUMBER_BANNED:"This phone number is banned."},ln={};let fn;function gn(){fn({"@type":"updateWebAuthTokenFailed"})}function pn(){return fn(wn("authorizationStateWaitPhoneNumber")),new Promise(((e,t)=>{ln.resolve=e,ln.reject=t}))}function hn(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return fn({...wn("authorizationStateWaitCode"),isCodeViaApp:e}),new Promise(((e,t)=>{ln.resolve=e,ln.reject=t}))}function mn(e){return fn({...wn("authorizationStateWaitPassword"),hint:e}),new Promise((e=>{ln.resolve=e}))}function _n(){return fn(wn("authorizationStateWaitRegistration")),new Promise((e=>{ln.resolve=e}))}function yn(e){return fn({...wn("authorizationStateWaitQrCode"),qrCode:{token:btoa(String.fromCharCode(...e.token)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),expires:e.expires}}),new Promise(((e,t)=>{ln.reject=t}))}function bn(e){let t;if(e instanceof h.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=un[e.message];t||(t="Unexpected Error"),fn({"@type":"updateAuthorizationError",message:t})}function wn(e){return{"@type":"updateAuthorizationState",authorizationState:e}}function vn(e){ln.resolve&&ln.resolve(e)}function An(e){ln.resolve&&ln.resolve(e)}function Sn(e){ln.resolve&&ln.resolve(e)}function In(e){const{firstName:t,lastName:n}=e;ln.resolve&&ln.resolve([t,n])}function Pn(){ln.reject&&ln.reject(new Error("RESTART_AUTH"))}function Cn(){ln.reject&&ln.reject(new Error("RESTART_AUTH_WITH_QR"))}var Mn=n(78742),kn=n.n(Mn),Rn=n(89832);const En=self.caches;let Un;async function Bn(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(En)try{const a=new Request(t.replace(/:/g,"_")),i=await En.open(e),o=await i.match(a);if(!o)return;const r=o.headers.get("Content-Type");switch(n){case Un.Text:return await o.text();case Un.Blob:{if(t.startsWith("avatar")&&r&&r.startsWith("text"))return;const e=await o.blob(),n=!e.type||!s&&e.type.includes("html");let a=e.type||r;return n&&a?(s||(a=a.replace(/html/gi,"")),new Blob([e],{type:a})):e}case Un.Json:return await o.json();case Un.ArrayBuffer:return await o.arrayBuffer();default:return}}catch(e){return void console.warn(e)}}async function Dn(e,t,n){if(En)try{const s="string"==typeof n||n instanceof Blob||n instanceof ArrayBuffer?n:JSON.stringify(n),a=new Request(t.replace(/:/g,"_")),i=new Response(s),o=await En.open(e);return await o.put(a,i)}catch(e){return void console.warn(e)}}async function Tn(e,t){try{if(!En)return;const n=await En.open(e);return await n.delete(t)}catch(e){return void console.warn(e)}}async function xn(e){try{if(!En)return;return await En.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",e[e.ArrayBuffer=3]="ArrayBuffer"}(Un||(Un={}));const Vn=new Set(["msg","sticker","gif","wallpaper","photo","webDocument","document","videoAvatar"]);async function Nn(e,t,n,a){let{url:i,mediaFormat:o,start:r,end:d,isHtmlAllowed:c}=e;const{data:u,mimeType:l,fullSize:f}=await async function(e,t,n,s,a,i,o,r){const d=qn(e);if(!d)return;const{entityType:c,entityId:u,sizeType:l,params:f,mediaMatchType:g}=d;if(!n)return Promise.reject(new Error("ERROR: Client is not connected"));if("staticMap"===c){const e=u,n=new URLSearchParams(f),s=n.get("long"),a=n.get("lat"),i=n.get("w"),o=n.get("h"),r=n.get("zoom"),d=n.get("scale"),c=n.get("accuracy_radius");return{mimeType:"image/png",data:await t.downloadStaticMap(e,s,a,i,o,r,d,c)}}let p;switch(c){case"channel":case"chat":p=U.chats[u];break;case"user":p=U.users[u];break;case"msg":p=U.messages[u];break;case"sticker":case"gif":case"wallpaper":case"document":p=U.documents[u];break;case"videoAvatar":case"photo":p=U.photos[u];break;case"stickerSet":p=U.stickerSets[u];break;case"webDocument":p=U.webDocuments[u]}if(p){if(Vn.has(c)){o===b.Stream&&(s.acceptsBuffer=!0);const e=await t.downloadMedia(p,{sizeType:l,start:a,end:i,progressCallback:s,workers:16});let n,d;return p instanceof h.Api.Message?(n=function(e,t){if(e&&e.media)return e.media instanceof h.Api.MessageMediaPhoto?"image/jpeg":e.media instanceof h.Api.MessageMediaGeo||e.media instanceof h.Api.MessageMediaVenue||e.media instanceof h.Api.MessageMediaGeoLive?"image/png":e.media instanceof h.Api.MessageMediaDocument&&e.media.document instanceof h.Api.Document?t?e.media.document.attributes.some((e=>e instanceof h.Api.DocumentAttributeSticker))?"image/webp":"image/jpeg":e.media.document.mimeType:e.media instanceof h.Api.MessageMediaWebPage&&e.media.webpage instanceof h.Api.WebPage&&e.media.webpage.document instanceof h.Api.Document?t?"image/jpeg":e.media.webpage.document.mimeType:void 0}(p,l),p.media instanceof h.Api.MessageMediaDocument&&p.media.document instanceof h.Api.Document&&(d=p.media.document.size.toJSNumber()),p.media instanceof h.Api.MessageMediaWebPage&&p.media.webpage instanceof h.Api.WebPage&&p.media.webpage.document instanceof h.Api.Document&&(d=p.media.webpage.document.size.toJSNumber())):p instanceof h.Api.Photo?n="videoAvatar"===c?"video/mp4":"image/jpeg":"sticker"===c&&l?n="image/webp":"webDocument"===c?(n=p.mimeType,d=p.size):(n=p.mimeType,d=p.size.toJSNumber()),!r&&n&&(n=n.replace(/html/gi,"")),{mimeType:n,data:e,fullSize:d}}if("stickerSet"===c){const e=await t.downloadStickerSetThumb(p);return{mimeType:Fn(e),data:e}}{const e=await t.downloadProfilePhoto(p,"profile"===g);return{mimeType:Fn(e),data:e}}}}(i,t,n,a,r,d,o,c)||{};if(!u)return;const g=await async function(e,t,n){switch(t){case b.BlobUrl:return new Blob([e],{type:n});case b.Text:return e.toString();case b.Progressive:case b.DownloadUrl:return e.buffer}}(u,o,l);if(!g)return;const p=o!==b.Progressive&&(o!==b.BlobUrl||g.size<=524288);return s&&p&&Dn(i.startsWith("avatar")?"tt-media-avatars":"tt-media",i,g),{prepared:o===b.Progressive?"":(m=g,m instanceof Blob?URL.createObjectURL(m):m),arrayBuffer:o===b.Progressive?g:void 0,mimeType:l,fullSize:f};var m}function Fn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"image/jpeg";if(e.length<4)return t;let n=t;const s=e.subarray(0,4).reduce(((e,t)=>e+t.toString(16)),"");switch(s){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}function qn(e){const t=e.startsWith("staticMap")?e.match(/(staticMap):([0-9-]+)(\?.+)/):e.startsWith("webDocument")?e.match(/(webDocument):(.+)/):e.match(/(avatar|profile|photo|msg|stickerSet|sticker|wallpaper|gif|document|videoAvatar)([-\d\w./]+)(?::\d+)?(\?size=\w+)?/);if(!t)return;const n=t[1],s=t[2];let a;const i=t[3],o=(null==i?void 0:i.replace("?size=",""))||void 0;return a="avatar"===t[1]||"profile"===t[1]?se(s):t[1],{mediaMatchType:n,entityType:a,entityId:s,sizeType:o,params:i}}Rn.Logger.setLevel("warn");const Ln={build:e=>e};let Gn,Hn,On,Kn=!1;function zn(e){let{isPremium:t}=e;Hn.setIsPremium(t)}async function jn(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e||await Qn(new h.Api.auth.LogOut),B(),await Hn.destroy()}async function Wn(){await Hn.disconnect()}function $n(e){Gn({"@type":"updateSession",sessionData:e})}function Jn(e){if(e instanceof h.connection.UpdateConnectionState)Kn=e.state===h.connection.UpdateConnectionState.connected;else if(e instanceof h.Api.UpdatesTooLong)!async function(){try{await Qn(new h.Api.users.GetFullUser({id:new h.Api.InputUserSelf}),void 0,!0)}catch(e){"AUTH_KEY_UNREGISTERED"===e.message&&Gn({"@type":"updateConnectionState",connectionState:"connectionStateBroken"})}}();else if(e instanceof h.connection.UpdateServerTimeOffset)Gn({"@type":"updateServerTimeOffset",serverTimeOffset:e.timeOffset});else if(e instanceof h.Api.UpdateConfig){var t;const n=null===(t=e._entities)||void 0===t?void 0:t.find((e=>e instanceof h.Api.User&&W(e.id,"user")===On));if(!(n instanceof h.Api.User))return;zn({isPremium:Boolean(n.premium)})}}async function Qn(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4?arguments[4]:void 0;if(Kn)try{const n=await Hn.invoke(e,a);return s||Xn(e,n),t?n&&!0:n}catch(t){if(n)throw t;return void ns(t,e)}}function Xn(e,t){let n,s;t instanceof h.Api.UpdatesCombined||t instanceof h.Api.Updates?n=t:"object"==typeof t&&"updates"in t&&(t.updates instanceof h.Api.Updates||t.updates instanceof h.Api.UpdatesCombined)?n=t.updates:(t instanceof h.Api.UpdateShortMessage||t instanceof h.Api.UpdateShortChatMessage||t instanceof h.Api.UpdateShort||t instanceof h.Api.UpdateShortSentMessage)&&(s=t),n?(function(e){const t=[...e.users,...e.chats];e.updates.forEach((e=>{t&&(e._entities=t)}))}(n),n.updates.forEach((t=>{cn(t,e)}))):s&&cn(s,e)}function Yn(e,t){return Nn(e,Hn,Kn,t).catch((async n=>{if(n.message.startsWith("FILE_REFERENCE"))return await ss({url:e.url})?Nn(e,Hn,Kn,t):void 0}))}function Zn(e,t){return Hn.uploadFile({file:e,onProgress:t,workers:16})}function es(e){return Hn.updateTwoFaSettings(e)}async function ts(){const e=await Qn(new h.Api.users.GetFullUser({id:new h.Api.InputUserSelf}));if(!(e&&e.users[0]instanceof h.Api.User))return;const t=e.users[0];t.photo instanceof h.Api.Photo&&(U.photos[t.photo.id.toString()]=t.photo),U.users[W(t.id,"user")]=t;const n=Kt(e);var s;s=n.id,ze=s,function(e){fn({"@type":"updateCurrentUser",currentUser:e})}(n),On=n.id,zn({isPremium:Boolean(n.isPremium)})}function ns(e,t){const n=e.message.startsWith("A wait of")&&(t instanceof h.Api.messages.SendMessage||t instanceof h.Api.messages.SendMedia||t instanceof h.Api.messages.SendMultiMedia),{message:s}=e;Gn({"@type":"error",error:{message:s,isSlowMode:n,hasErrorKey:!0}})}async function ss(e){let{url:t}=e;const n=qn(t);if(!n)return;const{entityType:s,entityId:a,mediaMatchType:i}=n;if("file"===i)return!1;if("msg"===s){const e=U.messages[a],t=e.id,n="channelId"in e.peerId?new h.Api.InputChannel({channelId:e.peerId.channelId,accessHash:U.chats[W(e.peerId.channelId,"channel")].accessHash}):void 0,s=await Qn(n?new h.Api.channels.GetMessages({channel:n,id:[new h.Api.InputMessageID({id:t})]}):new h.Api.messages.GetMessages({id:[new h.Api.InputMessageID({id:t})]}));if(!s||s instanceof h.Api.messages.MessagesNotModified)return!1;const i=s.messages[0];return!(i instanceof h.Api.MessageEmpty||(X(i),0))}return!1}const as=2**31-1;let is;async function os(e){let{limit:t,offsetDate:n,archived:s,withPinned:a,serverTimeOffset:i,lastLocalServiceMessage:o}=e;const r=await Qn(new h.Api.messages.GetDialogs({offsetPeer:new h.Api.InputPeerEmpty,limit:t,offsetDate:n,folderId:s?1:void 0,...a&&{excludePinned:!0}})),d=a?await Qn(new h.Api.messages.GetPinnedDialogs({folderId:s?1:void 0})):void 0;if(!r||r instanceof h.Api.messages.DialogsNotModified)return;d&&Xs(d),Xs(r);const c=m((d?d.messages:[]).concat(r.messages).map(We).filter(Boolean),"chatId"),u={...d&&Qs(d),...Qs(r)},f=[],g={},p={},_=(d?d.dialogs:[]).concat(r.dialogs),y=[];_.forEach((e=>{if(!(e instanceof h.Api.Dialog)||!s&&1===e.folderId||s&&1!==e.folderId)return;const t=bt(e,u[Pt(e.peer)],i);if(t.id===l&&o&&(!c[t.id]||o.date>c[t.id].date)?t.lastMessage=o:t.lastMessage=c[t.id],t.isListed=!0,f.push(t),a&&e.pinned&&y.push(t.id),e.draft){const{formattedText:n,replyingToId:s}=nt(e.draft)||{};n&&(g[t.id]=n),s&&(p[t.id]=s)}}));const b=f.map((e=>e.id)),{users:w,userStatusesById:v}=$t(((null==d?void 0:d.users)||[]).concat(r.users));let A;return A=r instanceof h.Api.messages.DialogsSlice?r.count:b.length,{chatIds:b,chats:f,users:w,userStatusesById:v,draftsById:g,replyingToById:p,orderedPinnedIds:a?y:void 0,totalChatCount:A}}function rs(e){const{id:t,accessHash:n,adminRights:s}=e;return re(t,n)instanceof h.Api.InputChannel?async function(e,t,n){var s;const a=await Qn(new h.Api.channels.GetFullChannel({channel:re(e,t)}));if(!(a&&a.fullChat instanceof h.Api.ChannelFull))return;const{about:i,onlineCount:o,exportedInvite:r,slowmodeSeconds:d,slowmodeNextSendDate:c,migratedFromChatId:u,migratedFromMaxId:l,canViewParticipants:f,canViewStats:g,linkedChatId:p,hiddenPrehistory:m,call:_,botInfo:y,availableReactions:b,defaultSendAs:w,requestsPending:v,recentRequesters:A,statsDc:S,participantsCount:I,stickerset:P,chatPhoto:M}=a.fullChat;M instanceof h.Api.Photo&&(U.photos[M.id.toString()]=M);const k=r instanceof h.Api.ChatInviteExported?r.link:void 0,{members:R,users:E,userStatusesById:B}=f&&await Gs(e,t)||{},{members:D,users:T,userStatusesById:x}=f&&n&&await Gs(e,t,"kicked")||{},{members:N,users:F,userStatusesById:q}=f&&n&&await Gs(e,t,"admin")||{},L=y?Tt(y):void 0;if((null==a||null===(s=a.chats)||void 0===s?void 0:s.length)>1){Xs(a);const[,e]=a.chats,t=St(e);t&&is({"@type":"updateChat",id:t.id,chat:t})}const G={...B,...x,...q};return{fullInfo:{...M instanceof h.Api.Photo&&{profilePhoto:C(M)},about:i,onlineCount:o,inviteLink:k,slowMode:d?{seconds:d,nextSendDate:c}:void 0,migratedFrom:u?{chatId:W(u,"chat"),maxMessageId:l}:void 0,canViewMembers:f,canViewStatistics:g,isPreHistoryHidden:m,members:R,kickedMembers:D,adminMembers:N,groupCallId:_?String(_.id):void 0,linkedChatId:p?W(p,"chat"):void 0,botCommands:L,enabledReactions:Nt(b),sendAsId:w?$(w):void 0,requestsPending:v,recentRequesterIds:null==A?void 0:A.map((e=>W(e,"user"))),statisticsDcId:S,stickerSet:P?V(P):void 0},users:[...E||[],...T||[],...F||[]],userStatusesById:G,groupCall:_?{chatId:e,isLoaded:!1,id:_.id.toString(),accessHash:null==_?void 0:_.accessHash.toString(),participants:{},version:0,participantsCount:0,connectionState:"disconnected"}:void 0,membersCount:I}}(t,n,s):async function(e){const t=await Qn(new h.Api.messages.GetFullChat({chatId:re(e)}));if(!(t&&t.fullChat instanceof h.Api.ChatFull))return;Xs(t);const{about:n,participants:s,exportedInvite:a,botInfo:i,call:o,availableReactions:r,recentRequesters:d,requestsPending:c,chatPhoto:u}=t.fullChat;u instanceof h.Api.Photo&&(U.photos[u.id.toString()]=u);const l=Et(s),f=l?l.filter((e=>{let{isAdmin:t,isOwner:n}=e;return t||n})):void 0,g=i?Tt(i):void 0,{users:p,userStatusesById:m}=$t(t.users);return{fullInfo:{...u instanceof h.Api.Photo&&{profilePhoto:C(u)},about:n,members:l,adminMembers:f,canViewMembers:!0,botCommands:g,...a instanceof h.Api.ChatInviteExported&&{inviteLink:a.link},groupCallId:null==o?void 0:o.id.toString(),enabledReactions:Nt(r),requestsPending:c,recentRequesterIds:null==d?void 0:d.map((e=>W(e,"user")))},users:p,userStatusesById:m,groupCall:o?{chatId:e,isLoaded:!1,id:o.id.toString(),accessHash:o.accessHash.toString(),connectionState:"disconnected",participantsCount:0,version:0,participants:{}}:void 0,membersCount:null==l?void 0:l.length}}(t)}async function ds(e){const{id:t,accessHash:n}=e,s=await Qn(new h.Api.messages.GetPeerSettings({peer:ie(t,n)}));if(s)return Vt(s.settings)}async function cs(e){let{query:t}=e;const n=await Qn(new h.Api.contacts.Search({q:t}));if(!n)return;Xs(n);const s=n.myResults.map($),a=n.chats.concat(n.users).map((e=>St(e))).filter(Boolean),i=n.users.map(zt).filter((e=>Boolean(e)&&!e.isSelf));return{localChats:a.filter((e=>s.includes(e.id))),localUsers:i.filter((e=>s.includes(e.id))),globalChats:a.filter((e=>!s.includes(e.id))),globalUsers:i.filter((e=>!s.includes(e.id)))}}async function us(e){let t,{type:n,user:s}=e;if("self"===n||"user"===n){const e=await Qn(new h.Api.users.GetUsers({id:["user"===n&&s?re(s.id,s.accessHash):new h.Api.InputUserSelf]}));if(!e||!e.length)return;[t]=e}else if("support"===n){const e=await Qn(new h.Api.help.GetSupport);if(!e||!e.user)return;t=e.user}const a=St(t,"support"===n);if(a)return is({"@type":"updateChat",id:a.id,chat:a}),{chatId:a.id}}async function ls(e){let{chat:t,serverTimeOffset:n,lastLocalMessage:s,noLastMessage:a}=e;const{id:i,accessHash:o}=t,r=await Qn(new h.Api.messages.GetPeerDialogs({peers:[new h.Api.InputDialogPeer({peer:ie(i,o)})]}));if(!r)return;const d=r.dialogs[0];if(!(d&&d instanceof h.Api.Dialog))return;const c=Qs(r)[Pt(d.peer)];if(!c)return;Xs(r);const u=We(r.messages[0]),l=s&&(!u||s.date>u.date)?s:u;is({"@type":"updateChat",id:i,chat:{...bt(d,c,n),...!a&&{lastMessage:l}}})}function fs(e){let{chat:t,text:n,entities:s,replyToMsgId:a}=e;return Qn(new h.Api.messages.SaveDraft({peer:ie(t.id,t.accessHash),message:n,...s&&{entities:s.map(he)},replyToMsgId:a}))}function gs(e){return Qn(new h.Api.messages.SaveDraft({peer:ie(e.id,e.accessHash),message:""}))}async function ps(e){let{chat:t,isMuted:n,serverTimeOffset:s}=e;await Qn(new h.Api.account.UpdateNotifySettings({peer:new h.Api.InputNotifyPeer({peer:ie(t.id,t.accessHash)}),settings:new h.Api.InputPeerNotifySettings({muteUntil:n?as:0})})),is({"@type":"updateNotifyExceptions",chatId:t.id,isMuted:n}),ls({chat:t,serverTimeOffset:s,noLastMessage:!0})}async function hs(e){let{title:t,about:n="",users:s}=e,a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=await Qn(new h.Api.channels.CreateChannel({broadcast:!0,title:t,about:n}),void 0,!0);if(!(i instanceof h.Api.Updates))return;const o=i.chats[0];if(!(o&&o instanceof h.Api.Channel))return;const r=St(o);if(null!=s&&s.length)try{await Qn(new h.Api.channels.InviteToChannel({channel:re(r.id,r.accessHash),users:s.map((e=>{let{id:t,accessHash:n}=e;return re(t,n)}))}),void 0,a)}catch(e){}return r}function ms(e){let{channelId:t,accessHash:n}=e;return Qn(new h.Api.channels.JoinChannel({channel:re(t,n)}),!0,!0)}function _s(e){let{chat:t,user:n}=e;if("chatTypeBasicGroup"===t.type)return Qn(new h.Api.messages.DeleteChatUser({chatId:re(t.id,t.accessHash),userId:re(n.id,n.accessHash)}),!0)}function ys(e){let{chatId:t}=e;return Qn(new h.Api.messages.DeleteChat({chatId:re(t)}),!0)}function bs(e){let{channelId:t,accessHash:n}=e;return Qn(new h.Api.channels.LeaveChannel({channel:re(t,n)}),!0)}function ws(e){let{channelId:t,accessHash:n}=e;return Qn(new h.Api.channels.DeleteChannel({channel:re(t,n)}),!0)}async function vs(e){let{title:t,users:n}=e;const s=await Qn(new h.Api.messages.CreateChat({title:t,users:n.map((e=>{let{id:t,accessHash:n}=e;return re(t,n)}))}),void 0,!0);if(!(s instanceof h.Api.Updates))return;const a=s.chats[0];return a&&a instanceof h.Api.Chat?St(a):void 0}async function As(e){let{chatId:t,accessHash:n,photo:s}=e;const a=await Zn(s),i=re(t,n);return Qn(i instanceof h.Api.InputChannel?new h.Api.channels.EditPhoto({channel:i,photo:new h.Api.InputChatUploadedPhoto({file:a})}):new h.Api.messages.EditChatPhoto({chatId:i,photo:new h.Api.InputChatUploadedPhoto({file:a})}),!0)}async function Ss(e){let{chat:t,shouldBePinned:n}=e;const{id:s,accessHash:a}=t;await Qn(new h.Api.messages.ToggleDialogPin({peer:new h.Api.InputDialogPeer({peer:ie(s,a)}),pinned:n||void 0}))&&is({"@type":"updateChatPinned",id:t.id,isPinned:n})}function Is(e){let{chat:t,folderId:n}=e;const{id:s,accessHash:a}=t;return Qn(new h.Api.folders.EditPeerFolders({folderPeers:[new h.Api.InputFolderPeer({peer:ie(s,a),folderId:n})]}),!0)}async function Ps(){const e=await Qn(new h.Api.messages.GetDialogFilters);if(!e)return;const t=e.findIndex((e=>e instanceof h.Api.DialogFilterDefault)),n=e.filter((e=>e instanceof h.Api.DialogFilter)),s=n.map((e=>{let{id:t}=e;return t}));return-1!==t&&s.splice(t,0,0),{byId:m(n.map(Bt),"id"),orderedIds:s}}async function Cs(){const e=await Qn(new h.Api.messages.GetSuggestedDialogFilters);if(e)return e.map(Dt).filter(Boolean)}async function Ms(e){let{id:t,folderUpdate:n}=e;const s=function(e){const{emoticon:t,contacts:n,nonContacts:s,groups:a,channels:i,bots:o,excludeArchived:r,excludeMuted:d,excludeRead:c,pinnedChatIds:u,includedChatIds:l,excludedChatIds:f}=e,g=u?u.map(oe).filter(Boolean):[],p=l?l.map(oe).filter(Boolean):[],m=f?f.map(oe).filter(Boolean):[];return new h.Api.DialogFilter({id:e.id,title:e.title,emoticon:t||void 0,contacts:n||void 0,nonContacts:s||void 0,groups:a||void 0,bots:o||void 0,excludeArchived:r||void 0,excludeMuted:d||void 0,excludeRead:c||void 0,broadcasts:i||void 0,pinnedPeers:g,includePeers:p,excludePeers:m})}(n);await Qn(new h.Api.messages.UpdateDialogFilter({id:t,filter:s}))&&is({"@type":"updateChatFolder",id:t,folder:n})}async function ks(e){const t=await Qn(new h.Api.messages.UpdateDialogFilter({id:e,filter:void 0})),n=await Cs();t&&is({"@type":"updateChatFolder",id:e,folder:void 0}),n&&is({"@type":"updateRecommendedChatFolders",folders:n})}function Rs(e){return Qn(new h.Api.messages.UpdateDialogFiltersOrder({order:e}))}async function Es(e){let{chat:t,hasUnreadMark:n}=e;const{id:s,accessHash:a}=t;await Qn(new h.Api.messages.MarkDialogUnread({peer:new h.Api.InputDialogPeer({peer:ie(s,a)}),unread:n||void 0}))&&is({"@type":"updateChat",id:t.id,chat:{hasUnreadMark:n}})}async function Us(e){return Ds(await Qn(new h.Api.contacts.ResolvePhone({phone:e})))}async function Bs(e){return Ds(await Qn(new h.Api.contacts.ResolveUsername({username:e})))}function Ds(e){if(!e)return;const{users:t,chats:n}=e,s=n.length?St(n[0]):St(t[0]);return s?(Xs(e),{chat:s,user:zt(t[0])}):void 0}function Ts(e){let{chat:t,isEnabled:n}=e;const{id:s,accessHash:a}=t,i=re(s,a);return Qn(new h.Api.channels.TogglePreHistoryHidden({channel:i,enabled:n}),!0)}function xs(e){let{chat:t,bannedRights:n}=e;const{id:s,accessHash:a}=t,i=ie(s,a);return Qn(new h.Api.messages.EditChatDefaultBannedRights({peer:i,bannedRights:be(n)}),!0)}function Vs(e){let{chat:t,user:n,bannedRights:s,untilDate:a}=e;const i=re(t.id,t.accessHash),o=ie(n.id,n.accessHash);return Qn(new h.Api.channels.EditBanned({channel:i,participant:o,bannedRights:be(s,a)}),!0)}function Ns(e){let{chat:t,user:n,adminRights:s,customTitle:a=""}=e;const i=re(t.id,t.accessHash),o=re(n.id,n.accessHash);return Qn(new h.Api.channels.EditAdmin({channel:i,userId:o,adminRights:we(s),rank:a}),!0)}async function Fs(e,t){const n=re(e.id,e.accessHash);await Qn(n instanceof h.Api.InputChannel?new h.Api.channels.EditTitle({channel:n,title:t}):new h.Api.messages.EditChatTitle({chatId:n,title:t}),!0)}async function qs(e,t){await Qn(new h.Api.messages.EditChatAbout({peer:ie(e.id,e.accessHash),about:t}))&&is({"@type":"updateChatFullInfo",id:e.id,fullInfo:{about:t}})}function Ls(e){let{chat:t,isEnabled:n}=e;const{id:s,accessHash:a}=t,i=re(s,a);return Qn(new h.Api.channels.ToggleSignatures({channel:i,enabled:n}),!0)}async function Gs(e,t){let n,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"recent",a=arguments.length>3?arguments[3]:void 0;switch(s){case"kicked":n=new h.Api.ChannelParticipantsKicked({q:""});break;case"admin":n=new h.Api.ChannelParticipantsAdmins;break;default:n=new h.Api.ChannelParticipantsRecent}const i=await Qn(new h.Api.channels.GetParticipants({channel:re(e,t),filter:n,offset:a,limit:200}));if(!i||i instanceof h.Api.channels.ChannelParticipantsNotModified)return;Xs(i);const{users:o,userStatusesById:r}=$t(i.users);return{members:Et(i),users:o,userStatusesById:r}}async function Hs(){const e=await Qn(new h.Api.channels.GetGroupsForDiscussion);if(e)return Xs(e),e.chats.map((e=>St(e)))}function Os(e){let{channel:t,chat:n}=e;return Qn(new h.Api.channels.SetDiscussionGroup({broadcast:ie(t.id,t.accessHash),group:n?ie(n.id,n.accessHash):new h.Api.InputChannelEmpty}),!0)}async function Ks(e){const t=await Qn(new h.Api.messages.MigrateChat({chatId:re(e.id)}),void 0,!0);if(t&&t instanceof h.Api.Updates)return Xs(t),St(t.chats[1])}async function zs(e){const t=await Qn(new h.Api.messages.CheckChatInvite({hash:e}));if(!t)return;let n;if(t instanceof h.Api.ChatInvite){const{photo:n,participantsCount:s,title:a,channel:i,requestNeeded:o,about:r,megagroup:d}=t;n instanceof h.Api.Photo&&Y(t.photo),is({"@type":"showInvite",data:{title:a,about:r,hash:e,participantsCount:s,isChannel:i&&!d,isRequestNeeded:o,...n instanceof h.Api.Photo&&{photo:C(n)}}})}else n=St(t.chat),n&&is({"@type":"updateChat",id:n.id,chat:n});return n?{chatId:n.id}:void 0}async function js(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{return"chatTypeChannel"===e.type||"chatTypeSuperGroup"===e.type?await Qn(new h.Api.channels.InviteToChannel({channel:re(e.id,e.accessHash),users:t.map((e=>re(e.id,e.accessHash)))}),!0,n):await Promise.all(t.map((t=>Qn(new h.Api.messages.AddChatUser({chatId:re(e.id),userId:re(t.id,t.accessHash)}),!0,n))))}catch(e){return}}function Ws(e,t){return"chatTypeChannel"===e.type||"chatTypeSuperGroup"===e.type?Vs({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:as}):Qn(new h.Api.messages.DeleteChatUser({chatId:re(e.id),userId:re(t.id,t.accessHash)}),!0)}function $s(e,t){return Qn(new h.Api.channels.ToggleJoinToSend({channel:re(e.id,e.accessHash),enabled:t}),!0)}function Js(e,t){return Qn(new h.Api.channels.ToggleJoinRequest({channel:re(e.id,e.accessHash),enabled:t}),!0)}function Qs(e){var t,n;const s={};return null===(t=e.chats)||void 0===t||t.forEach((e=>{s[`chat${e.id}`]=e})),null===(n=e.users)||void 0===n||n.forEach((e=>{s[`user${e.id}`]=e})),s}function Xs(e){"users"in e&&ee(e.users),"chats"in e&&ee(e.chats),"messages"in e&&e.messages.forEach((e=>{e instanceof h.Api.Message&&me(e)&&X(e)}))}async function Ys(e){let{hash:t}=e;const n=await Qn(new h.Api.messages.ImportChatInvite({hash:t}));if(n instanceof h.Api.Updates&&n.chats.length)return St(n.chats[0])}function Zs(e){let{chat:t,enabledReactions:n}=e;return Qn(new h.Api.messages.SetChatAvailableReactions({peer:ie(t.id,t.accessHash),availableReactions:(s=n,new h.Api.ChatReactionsSome({reactions:s.map(Re)}))}),!0);var s}function ea(e){let{chat:t,isProtected:n}=e;const{id:s,accessHash:a}=t;return Qn(new h.Api.messages.ToggleNoForwards({peer:ie(s,a),enabled:n}),!0)}function ta(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}async function na(e,t){const n=await async function(e){return(await fetch(e)).blob()}(e);return function(e,t){return new File([e],t,{lastModified:Date.now(),type:e.type})}(n,t)}"undefined"==typeof File&&(self.File=class extends Blob{constructor(e,t,n){if(n){const{type:t,...s}=n;super(e,{type:t}),ta(this,"name",void 0),Object.assign(this,s)}else super(e),ta(this,"name",void 0);this.name=t}});var sa=n(48764).Buffer;let aa;async function ia(e){let{chat:t,threadId:n,...s}=e;const a=-1===n?h.Api.messages.GetHistory:h.Api.messages.GetReplies;let i;try{i=await Qn(new a({peer:ie(t.id,t.accessHash),...-1!==n&&{msgId:n},...s}),void 0,!0)}catch(e){"CHANNEL_PRIVATE"===e.message&&aa({"@type":"updateChat",id:t.id,chat:{isRestricted:!0}})}if(!i||i instanceof h.Api.messages.MessagesNotModified||!i.messages)return;Ta(i);const o=i.messages.map(We).filter(Boolean),r=i.users.map(zt).filter(Boolean),d=i.chats.map((e=>St(e))).filter(Boolean),c=o.map((e=>{let{threadInfo:t}=e;return t})).filter(Boolean);return{messages:o,users:r,chats:d,threadInfos:c}}async function oa(e){let{chat:t,messageId:n}=e;const s="channel"===se(t.id);let a;try{a=await Qn(s?new h.Api.channels.GetMessages({channel:re(t.id,t.accessHash),id:[new h.Api.InputMessageID({id:n})]}):new h.Api.messages.GetMessages({id:[new h.Api.InputMessageID({id:n})]}),void 0,!0)}catch(e){const{message:t}=e;"CHANNEL_PRIVATE"!==t&&aa({"@type":"error",error:{message:t,isSlowMode:!1,hasErrorKey:!0}})}if(!a||a instanceof h.Api.messages.MessagesNotModified)return;const i=a.messages[0];if(!i)return;if(i instanceof h.Api.MessageEmpty)return"MESSAGE_DELETED";const o=i&&We(i);return o?(i instanceof h.Api.Message&&X(i),{message:o,users:a.users.map(zt).filter(Boolean)}):void 0}let ra=Promise.resolve();function da(e,t){let{chat:n,text:s,entities:a,replyingTo:i,replyingToTopId:o,attachment:r,sticker:d,gif:c,poll:u,contact:l,isSilent:f,scheduledAt:g,groupedId:p,noWebPage:m,sendAs:_,serverTimeOffset:y}=e;const b=function(e,t,n,s,a,i,o,r,d,c,u,l,f){let g=arguments.length>13&&void 0!==arguments[13]?arguments[13]:0;const p=Ke(),h=i&<(i),m="chatTypeChannel"===e.type,_=t&&Ge(t);return{id:p,chatId:e.id,content:{...t&&{text:{text:t,entities:n}},...h,...o&&{sticker:o},...r&&{video:r},...d&&pt(d,p),...c&&{contact:c}},date:l||Math.round(Date.now()/1e3)+g,isOutgoing:!m,senderId:(null==f?void 0:f.id)||ze,..._&&{emojiOnlyCount:_},...s&&{replyToMessageId:s},...a&&{replyToTopMessageId:a},...u&&{groupedId:u,...h&&(h.photo||h.video)&&{isInAlbum:!0}},...l&&{isScheduled:!0},isForwardingAllowed:!0}}(n,s,a,i,o,r,d,c,u,l,p,g,_,y);aa({"@type":b.isScheduled?"newScheduledMessage":"newMessage",id:b.id,chatId:n.id,message:b}),setTimeout((()=>{aa({"@type":b.isScheduled?"updateScheduledMessage":"updateMessage",id:b.id,chatId:n.id,message:{sendingState:"messageSendingStatePending"}})}),1e3);const w=fe();if(U.localMessages[String(w)]=b,p)return function(e,t,n,s){let{chat:a,text:i,entities:o,replyingTo:r,attachment:d,groupedId:c,isSilent:u,scheduledAt:l,sendAs:f}=e,g=-1;ca[c]||(ca[c]={counter:0,singleMediaByIndex:{}}),g=ca[c].counter++;const p=ra;return ra=(async()=>{let e;try{e=await fa(n,d,s)}catch(e){return ca[c].counter--,void await p}const m=await async function(e,t){const n=await Qn(new h.Api.messages.UploadMedia({peer:e,media:t}));if(n instanceof h.Api.MessageMediaPhoto&&n.photo&&n.photo instanceof h.Api.Photo){const{photo:{id:e,accessHash:t,fileReference:s}}=n;return new h.Api.InputMediaPhoto({id:new h.Api.InputPhoto({id:e,accessHash:t,fileReference:s})})}if(n instanceof h.Api.MessageMediaDocument&&n.document&&n.document instanceof h.Api.Document){const{document:{id:e,accessHash:t,fileReference:s}}=n;return new h.Api.InputMediaDocument({id:new h.Api.InputDocument({id:e,accessHash:t,fileReference:s})})}}(ie(a.id,a.accessHash),e);if(await p,!m)return void ca[c].counter--;if(ca[c].singleMediaByIndex[g]=new h.Api.InputSingleMedia({media:m,randomId:t,message:i||"",entities:o?o.map(he):void 0}),Object.keys(ca[c].singleMediaByIndex).length{let e;if(r)try{e=await fa(b,r,t)}catch(e){return void await v}else d?e=ue(d):c?e=ue(c):u?e=function(e,t){const{summary:n,quiz:s}=e,a=new h.Api.Poll({id:t,publicVoters:n.isPublic,question:n.question,answers:n.answers.map((e=>{let{text:t,option:n}=e;return new h.Api.PollAnswer({text:t,option:ne(n)})})),quiz:n.quiz,multipleChoice:n.multipleChoice});if(!s)return new h.Api.InputMediaPoll({poll:a});const i=s.correctAnswers.map(ne),{solution:o}=s,r=s.solutionEntities?s.solutionEntities.map(he):[];return new h.Api.InputMediaPoll({poll:a,correctAnswers:i,...o&&{solution:o,solutionEntities:r}})}(u,w):l&&(e=new h.Api.InputMediaContact({phoneNumber:l.phoneNumber,firstName:l.firstName,lastName:l.lastName,vcard:""}));await v;const o=e?h.Api.messages.SendMedia:h.Api.messages.SendMessage;await Qn(new o({clearDraft:!0,message:s||"",entities:a?a.map(he):void 0,peer:ie(n.id,n.accessHash),randomId:w,...f&&{silent:f},...g&&{scheduleDate:g},...i&&{replyToMsgId:i},...e&&{media:e},...m&&{noWebpage:m},..._&&{sendAs:ie(_.id,_.accessHash)}}),!0)})(),ra}const ca={};async function ua(e){let{chat:t,message:n,text:s,entities:a,noWebPage:i,serverTimeOffset:o}=e;const r=1e3*n.date>Date.now()+1e3*o,d=s?Ge(s):void 0,c={content:{...n.content,...s&&{text:{text:s,entities:a}}},emojiOnlyCount:d||void 0};aa({"@type":r?"updateScheduledMessage":"updateMessage",id:n.id,chatId:t.id,message:c}),U.localMessages[n.id]={...n,...c};const u=a&&a.map(he);await Qn(new h.Api.messages.EditMessage({message:s||"",entities:u,peer:ie(t.id,t.accessHash),id:n.id,...r&&{scheduleDate:n.date},...i&&{noWebpage:i}}),!0)}async function la(e){let{chat:t,message:n,scheduledAt:s}=e;await Qn(new h.Api.messages.EditMessage({peer:ie(t.id,t.accessHash),id:n.id,scheduleDate:s}),!0)}async function fa(e,t,n){const{filename:s,blobUrl:a,mimeType:i,quick:o,voice:r,audio:u,previewBlobUrl:l}=t,f=t=>{n.isCanceled?f.isCanceled=!0:n(t,e.id)},g=await na(a,s),p=await Zn(g,f),m=l&&await na(l,s),_=m?await Zn(m):void 0,y=[new h.Api.DocumentAttributeFilename({fileName:s})];if(o){if(d.has(i))return new h.Api.InputMediaUploadedPhoto({file:p});if(c.has(i)){const{width:e,height:t,duration:n}=o;void 0!==n&&y.push(new h.Api.DocumentAttributeVideo({duration:n,w:e,h:t,supportsStreaming:!0}))}}if(u){const{duration:e,title:t,performer:n}=u;y.push(new h.Api.DocumentAttributeAudio({duration:e,title:t,performer:n}))}if(r){const{duration:e,waveform:t}=r,{data:n}=L(t,63);y.push(new h.Api.DocumentAttributeAudio({voice:!0,duration:e,waveform:sa.from(n)}))}return new h.Api.InputMediaUploadedDocument({file:p,mimeType:i,attributes:y,thumb:_})}async function ga(e){let{chat:t,messageId:n,isUnpin:s,isOneSide:a,isSilent:i}=e;await Qn(new h.Api.messages.UpdatePinnedMessage({peer:ie(t.id,t.accessHash),id:n,...s&&{unpin:!0},...a&&{pmOneside:!0},...i&&{silent:!0}}),!0)}async function pa(e){let{chat:t}=e;await Qn(new h.Api.messages.UnpinAllMessages({peer:ie(t.id,t.accessHash)}),!0)}async function ha(e){let{chat:t,messageIds:n,shouldDeleteForAll:s}=e;const a="channel"===se(t.id);await Qn(a?new h.Api.channels.DeleteMessages({channel:re(t.id,t.accessHash),id:n}):new h.Api.messages.DeleteMessages({id:n,...s&&{revoke:!0}}))&&aa({"@type":"deleteMessages",ids:n,...a&&{chatId:t.id}})}async function ma(e){let{chat:t,messageIds:n}=e;await Qn(new h.Api.messages.DeleteScheduledMessages({peer:ie(t.id,t.accessHash),id:n}))&&aa({"@type":"deleteScheduledMessages",ids:n,chatId:t.id})}async function _a(e){let{chat:t,shouldDeleteForAll:n}=e;const s="channel"===se(t.id),a=await Qn(s?new h.Api.channels.DeleteHistory({channel:re(t.id,t.accessHash)}):new h.Api.messages.DeleteHistory({peer:ie(t.id,t.accessHash),...n&&{revoke:!0},...!n&&{just_clear:!0}}));a&&("offset"in a&&a.offset?await _a({chat:t,shouldDeleteForAll:n}):aa({"@type":"deleteHistory",chatId:t.id}))}async function ya(e){let{peer:t,messageIds:n,reason:s,description:a}=e;return await Qn(new h.Api.messages.Report({peer:ie(t.id,t.accessHash),id:n,reason:Se(s),message:a}))}async function ba(e){let{peer:t,threadId:n,action:s}=e;const a=function(e){switch(e.type){case"cancel":return new h.Api.SendMessageCancelAction;case"typing":return new h.Api.SendMessageTypingAction;case"recordAudio":return new h.Api.SendMessageRecordAudioAction;case"chooseSticker":return new h.Api.SendMessageChooseStickerAction;case"playingGame":return new h.Api.SendMessageGamePlayAction}}(s);if(a)try{return await Qn(new h.Api.messages.SetTyping({peer:ie(t.id,t.accessHash),topMsgId:n,action:a}),void 0,!0)}catch(e){}}async function wa(e){let{chat:t,threadId:n,maxId:s,serverTimeOffset:a}=e;const i="channel"===se(t.id);i&&-1===n?await Qn(new h.Api.channels.ReadHistory({channel:re(t.id,t.accessHash),maxId:s})):i?await Qn(new h.Api.messages.ReadDiscussion({peer:ie(t.id,t.accessHash),msgId:n,readMaxId:s})):await Qn(new h.Api.messages.ReadHistory({peer:ie(t.id,t.accessHash),maxId:s})),-1===n?ls({chat:t,serverTimeOffset:a,noLastMessage:!0}):Aa({chat:t,threadId:n})}async function va(e){let{chat:t,messageIds:n}=e;const s="channel"===se(t.id);await Qn(s?new h.Api.channels.ReadMessageContents({channel:re(t.id,t.accessHash),id:n}):new h.Api.messages.ReadMessageContents({id:n})),aa({...s?{"@type":"updateChannelMessages",channelId:t.id}:{"@type":"updateCommonBoxMessages"},ids:n,messageUpdate:{hasUnreadMention:!1,isMediaUnread:!1}})}async function Aa(e){let{chat:t,threadId:n}=e;const[s,a]=await Promise.all([Qn(new h.Api.messages.GetDiscussionMessage({peer:ie(t.id,t.accessHash),msgId:n})),Qn(new h.Api.messages.GetReplies({peer:ie(t.id,t.accessHash),msgId:n,offsetId:1,addOffset:-1,limit:1}))]);if(!s||!s.messages.length)return;const i=Q(s.messages[0]);return i?(aa({"@type":"updateThreadInfo",chatId:i,threadId:n,threadInfo:{threadId:n,topMessageId:s.messages[s.messages.length-1].id,lastReadInboxMessageId:s.readInboxMaxId,messagesCount:a instanceof h.Api.messages.ChannelMessages?a.count:void 0},firstMessageId:a&&"messages"in a&&a.messages.length?a.messages[0].id:void 0}),s.chats.map((e=>St(e))).filter(Boolean).forEach((e=>{aa({"@type":"updateChat",id:e.id,chat:e,noTopChatsRequest:!0})})),{discussionChatId:i}):void 0}async function Sa(e){let t,{chat:n,type:s,query:a,topMessageId:i,minDate:o,maxDate:r,...d}=e;switch(s){case"media":t=new h.Api.InputMessagesFilterPhotoVideo;break;case"documents":t=new h.Api.InputMessagesFilterDocument;break;case"links":t=new h.Api.InputMessagesFilterUrl;break;case"audio":t=new h.Api.InputMessagesFilterMusic;break;case"voice":t=new h.Api.InputMessagesFilterRoundVoice;break;case"profilePhoto":t=new h.Api.InputMessagesFilterChatPhotos;break;default:t=new h.Api.InputMessagesFilterEmpty}const c=await Qn(new h.Api.messages.Search({peer:ie(n.id,n.accessHash),filter:t,q:a||"",topMsgId:i,minDate:o,maxDate:r,...d}));if(!c||c instanceof h.Api.messages.MessagesNotModified||!c.messages)return;Ta(c);const u=c.chats.map((e=>St(e))).filter(Boolean),l=c.users.map(zt).filter(Boolean),f=c.messages.map(We).filter(Boolean);let g,p=f.length;return(c instanceof h.Api.messages.MessagesSlice||c instanceof h.Api.messages.ChannelMessages)&&(p=c.count,f.length&&(g=f[f.length-1].id)),{chats:u,users:l,messages:f,totalCount:p,nextOffsetId:g}}async function Ia(e){let t,{query:n,offsetRate:s=0,limit:a,type:i="text",minDate:o,maxDate:r}=e;switch(i){case"media":t=new h.Api.InputMessagesFilterPhotoVideo;break;case"documents":t=new h.Api.InputMessagesFilterDocument;break;case"links":t=new h.Api.InputMessagesFilterUrl;break;case"audio":t=new h.Api.InputMessagesFilterMusic;break;case"voice":t=new h.Api.InputMessagesFilterRoundVoice;break;default:if(!(n||r&&o))return;t=new h.Api.InputMessagesFilterEmpty}const d=await Qn(new h.Api.messages.SearchGlobal({q:n,offsetRate:s,offsetPeer:new h.Api.InputPeerEmpty,limit:a,filter:t,folderId:0,minDate:o,maxDate:r}));if(!d||d instanceof h.Api.messages.MessagesNotModified||!d.messages)return;Ta({chats:d.chats,users:d.users,messages:d.messages});const c=d.chats.map((e=>St(e))).filter(Boolean),u=d.users.map(zt).filter(Boolean),l=d.messages.map(We).filter(Boolean);let f,g=l.length;return(d instanceof h.Api.messages.MessagesSlice||d instanceof h.Api.messages.ChannelMessages)&&(g=d.count,l.length&&(f=l[l.length-1].id)),{messages:l,users:u,chats:c,totalCount:g,nextRate:"nextRate"in d&&d.nextRate?d.nextRate:f}}async function Pa(e){let{message:t}=e;const n=await Qn(new h.Api.messages.GetWebPagePreview({message:t}));return n&&ct(n)}async function Ca(e){let{chat:t,messageId:n,options:s}=e;const{id:a,accessHash:i}=t;await Qn(new h.Api.messages.SendVote({peer:ie(a,i),msgId:n,options:s.map(ne)}),!0)}async function Ma(e){let{chat:t,messageId:n,poll:s}=e;const{id:a,accessHash:i}=t;await Qn(new h.Api.messages.EditMessage({peer:ie(a,i),id:n,media:le(s,!0)}))}async function ka(e){let{chat:t,messageId:n,option:s,offset:a,limit:i,shouldResetVoters:o}=e;const{id:r,accessHash:d}=t,c=await Qn(new h.Api.messages.GetPollVotes({peer:ie(r,d),id:n,...s&&{option:ne(s)},...a&&{offset:a},...i&&{limit:i}}));if(!c)return;Ta({chats:[],users:c.users,messages:[]});const u=c.users.map(zt).filter(Boolean),l=c.votes.map((e=>({userId:e.userId,date:e.date})));return{count:c.count,votes:l,users:u,nextOffset:c.nextOffset,shouldResetVoters:o}}async function Ra(e){let{chat:t,ids:n}=e;await Qn(new h.Api.messages.GetExtendedMedia({peer:ie(t.id,t.accessHash),id:n}))}async function Ea(e){let{fromChat:t,toChat:n,messages:s,serverTimeOffset:a,isSilent:i,scheduledAt:o,sendAs:r,withMyScore:d,noAuthors:c,noCaptions:u,isCurrentUserPremium:l}=e;const f=s.map((e=>{let{id:t}=e;return t})),g=s.map(fe);s.forEach(((e,t)=>{const s=function(e,t,n,s,a,i,o){var r;const d=Ke(),{content:c,chatId:u,id:l,senderId:f,groupedId:g,isInAlbum:p}=t,h=c.audio,m=e.id===ze&&(u!==e.id||t.forwardInfo)&&!h,_=Object.keys(c).length>1&&c.text&&i,b=!o,w=null!==(r=c.text)&&void 0!==r&&r.entities&&b?{text:c.text.text,entities:c.text.entities.filter((e=>e.type!==y.CustomEmoji))}:c.text,v=c.text&&Ge(c.text.text),A={...c,text:_?void 0:w};return{id:d,chatId:e.id,content:A,date:s||Math.round(Date.now()/1e3)+n,isOutgoing:!m&&"chatTypeChannel"!==e.type,senderId:ze,sendingState:"messageSendingStatePending",groupedId:g,isInAlbum:p,...v&&{emojiOnlyCount:v},...t.chatId!==ze&&!h&&!a&&{forwardInfo:{date:t.date,isChannelPost:!1,fromChatId:u,fromMessageId:l,senderUserId:f}},...t.chatId===ze&&!a&&{forwardInfo:t.forwardInfo},...s&&{isScheduled:!0},isForwardingAllowed:!0}}(n,e,a,o,c,u,l);U.localMessages[String(g[t])]=s,aa({"@type":s.isScheduled?"newScheduledMessage":"newMessage",id:s.id,chatId:n.id,message:s})})),await Qn(new h.Api.messages.ForwardMessages({fromPeer:ie(t.id,t.accessHash),toPeer:ie(n.id,n.accessHash),randomId:g,id:f,withMyScore:d||void 0,silent:i||void 0,dropAuthor:c||void 0,dropMediaCaptions:u||void 0,...o&&{scheduleDate:o},...r&&{sendAs:ie(r.id,r.accessHash)}}),!0)}async function Ua(e){let{chat:t,timestamp:n}=e;const s=await Qn(new h.Api.messages.GetHistory({peer:ie(t.id,t.accessHash),offsetDate:n,addOffset:-1,limit:1}));if(s&&!(s instanceof h.Api.messages.MessagesNotModified)&&s.messages&&s.messages.length)return s.messages[0].id}async function Ba(e){let{chat:t}=e;const{id:n,accessHash:s}=t,a=await Qn(new h.Api.messages.GetScheduledHistory({peer:ie(n,s)}));if(a&&!(a instanceof h.Api.messages.MessagesNotModified)&&a.messages)return Ta(a),{messages:a.messages.map(We).filter(Boolean)}}async function Da(e){let{chat:t,ids:n}=e;const{id:s,accessHash:a}=t;await Qn(new h.Api.messages.SendScheduledMessages({peer:ie(s,a),id:n}),!0)}function Ta(e){ee(e.users),ee(e.chats),e.messages.forEach((e=>{(e instanceof h.Api.Message&&me(e)||e instanceof h.Api.MessageService&&function(e){return"photo"in e.action&&e.action.photo instanceof h.Api.Photo}(e))&&X(e)}))}async function xa(e){let{chat:t}=e;const n=await Qn(new h.Api.messages.Search({peer:ie(t.id,t.accessHash),filter:new h.Api.InputMessagesFilterPinned,q:"",limit:50}));if(!n||n instanceof h.Api.messages.MessagesNotModified||!n.messages)return;Ta(n);const s=n.chats.map((e=>St(e))).filter(Boolean),a=n.users.map(zt).filter(Boolean);return{messages:n.messages.map(We).filter(Boolean),users:a,chats:s}}async function Va(e){let{chat:t,messageId:n}=e;const s=await Qn(new h.Api.messages.GetMessageReadParticipants({peer:ie(t.id,t.accessHash),msgId:n}));return s?s.map(String):void 0}async function Na(e){let{chat:t}=e;const n=await Qn(new h.Api.channels.GetSendAs({peer:ie(t.id,t.accessHash)}));if(n)return ee(n.users),ee(n.chats),{users:n.users.map(zt).filter(Boolean),chats:n.chats.map((e=>St(e))).filter(Boolean),sendAs:n.peers.map(Ft)}}function Fa(e){let{sendAs:t,chat:n}=e;return Qn(new h.Api.messages.SaveDefaultSendAs({peer:ie(n.id,n.accessHash),sendAs:ie(t.id,t.accessHash)}))}async function qa(e){let{chat:t}=e;const n=await Qn(new h.Api.channels.GetSponsoredMessages({channel:ie(t.id,t.accessHash)}));if(n&&n.messages.length)return Ta(n),{messages:n.messages.map(je).filter(Boolean),users:n.users.map(zt).filter(Boolean),chats:n.chats.map((e=>St(e))).filter(Boolean)}}async function La(e){let{chat:t,random:n}=e;await Qn(new h.Api.channels.ViewSponsoredMessage({channel:ie(t.id,t.accessHash),randomId:ne(n)}))}function Ga(e){let{chat:t}=e;return Qn(new h.Api.messages.ReadMentions({peer:ie(t.id,t.accessHash)}),!0)}function Ha(e){let{chat:t}=e;return Qn(new h.Api.messages.ReadReactions({peer:ie(t.id,t.accessHash)}),!0)}async function Oa(e){let{chat:t,...n}=e;const s=await Qn(new h.Api.messages.GetUnreadMentions({peer:ie(t.id,t.accessHash),limit:100,...n}));if(s&&!(s instanceof h.Api.messages.MessagesNotModified)&&s.messages)return Ta(s),{messages:s.messages.map(We).filter(Boolean),users:s.users.map(zt).filter(Boolean),chats:s.chats.map((e=>St(e))).filter(Boolean)}}async function Ka(e){let{chat:t,...n}=e;const s=await Qn(new h.Api.messages.GetUnreadReactions({peer:ie(t.id,t.accessHash),limit:100,...n}));if(s&&!(s instanceof h.Api.messages.MessagesNotModified)&&s.messages)return Ta(s),{messages:s.messages.map(We).filter(Boolean),users:s.users.map(zt).filter(Boolean),chats:s.chats.map((e=>St(e))).filter(Boolean)}}async function za(e){let{chat:t,messageId:n}=e;const s=await Qn(new h.Api.messages.TranscribeAudio({msgId:n,peer:ie(t.id,t.accessHash)}));if(s)return aa({"@type":"updateTranscribedAudio",isPending:s.pending,transcriptionId:s.transcriptionId.toString(),text:s.text}),s.transcriptionId.toString()}let ja,Wa,$a,Ja;async function Qa(e){let{id:t,accessHash:n}=e;const s=re(t,n);if(!(s instanceof h.Api.InputUser))return;const a=await Qn(new h.Api.users.GetFullUser({id:s}));if(!a)return;a.fullUser.profilePhoto instanceof h.Api.Photo&&(U.photos[a.fullUser.profilePhoto.id.toString()]=a.fullUser.profilePhoto);const i=a.fullUser.botInfo;(null==i?void 0:i.descriptionPhoto)instanceof h.Api.Photo&&(U.photos[i.descriptionPhoto.id.toString()]=i.descriptionPhoto),(null==i?void 0:i.descriptionDocument)instanceof h.Api.Document&&(U.documents[i.descriptionDocument.id.toString()]=i.descriptionDocument);const o=Kt(a);return ja({"@type":"updateUser",id:t,user:{fullInfo:o.fullInfo}}),o}async function Xa(e,t,n){const s=await Qn(new h.Api.messages.GetCommonChats({userId:re(e,t),maxId:n?Pe(n,se(n)):void 0,limit:100}));if(!s)return;ri(s);const a=[],i=[];return s.chats.forEach((e=>{const t=St(e);t&&(i.push(t),a.push(t.id))})),{chats:i,chatIds:a,isFullyLoaded:a.length<100}}async function Ya(){const e=await Qn(new h.Api.help.GetNearestDc);return null==e?void 0:e.country}async function Za(){const e=await Qn(new h.Api.contacts.GetTopPeers({correspondents:!0}));if(!(e instanceof h.Api.contacts.TopPeers))return;const t=e.users.map(zt).filter((e=>Boolean(e)&&!e.isSelf));return{ids:t.map((e=>{let{id:t}=e;return t})),users:t}}async function ei(){const e=await Qn(new h.Api.contacts.GetContacts({hash:H()("0")}));if(!e||e instanceof h.Api.contacts.ContactsNotModified)return;e.users.forEach((e=>{e instanceof h.Api.User&&Z(e,!0)}));const{users:t,userStatusesById:n}=$t(e.users);return{users:t,userStatusesById:n,chats:e.users.map((e=>St(e))).filter(Boolean)}}async function ti(e){let{users:t}=e;const n=await Qn(new h.Api.users.GetUsers({id:t.map((e=>{let{id:t,accessHash:n}=e;return ie(t,n)}))}));if(n&&n.length)return n.forEach((e=>{e instanceof h.Api.User&&Z(e,!0)})),$t(n)}async function ni(e){let{phone:t,firstName:n,lastName:s}=e;const a=await Qn(new h.Api.contacts.ImportContacts({contacts:[ye({phone:t||"",firstName:n||"",lastName:s||""})]}));return a instanceof h.Api.contacts.ImportedContacts&&a.users.length&&Z(a.users[0]),null!=a&&a.imported.length?W(a.imported[0].userId,"user"):void 0}function si(e){let{id:t,accessHash:n,phoneNumber:s="",firstName:a="",lastName:i="",shouldSharePhoneNumber:o=!1}=e;return Qn(new h.Api.contacts.AddContact({id:re(t,n),firstName:a,lastName:i,phone:s,...o&&{addPhonePrivacyException:o}}),!0)}async function ai(e){let{id:t,accessHash:n}=e;const s=re(t,n);s instanceof h.Api.InputUser&&await Qn(new h.Api.contacts.DeleteContacts({id:[s]}))&&ja({"@type":"deleteContact",id:t})}async function ii(e,t){if(e){const{id:t,accessHash:n}=e,s=await Qn(new h.Api.photos.GetUserPhotos({userId:re(t,n),limit:40,offset:0,maxId:H()("0")}));if(!s)return;return ri(s),{photos:s.photos.filter((e=>e instanceof h.Api.Photo)).map(C)}}const n=await Sa({chat:t,type:"profilePhoto",limit:40});if(!n)return;const{messages:s,users:a}=n;return{photos:s.map((e=>e.content.action.photo)).filter(Boolean),users:a}}function oi(e){const{id:t,accessHash:n}=e;return Qn(new h.Api.messages.ReportSpam({peer:ie(t,n)}),!0)}function ri(e){"chats"in e&&ee(e.chats),"photos"in e&&e.photos.forEach(Y)}async function di(e){let{hash:t="0"}=e;const n=await Qn(new h.Api.messages.GetEmojiStickers({hash:H()(t)}));if(n&&!(n instanceof h.Api.messages.AllStickersNotModified))return n.sets.forEach((e=>{var t;(null!==(t=e.thumbs)&&void 0!==t&&t.length||e.thumbDocumentId)&&(U.stickerSets[String(e.id)]=e)})),{hash:String(n.hash),sets:n.sets.map(V)}}async function ci(e){let{hash:t="0"}=e;const n=await Qn(new h.Api.messages.GetAllStickers({hash:H()(t)}));if(n&&!(n instanceof h.Api.messages.AllStickersNotModified))return n.sets.forEach((e=>{var t;null!==(t=e.thumbs)&&void 0!==t&&t.length&&(U.stickerSets[String(e.id)]=e)})),{hash:String(n.hash),sets:n.sets.map(V)}}async function ui(e){let{hash:t="0"}=e;const n=await Qn(new h.Api.messages.GetRecentStickers({hash:H()(t)}));if(n&&!(n instanceof h.Api.messages.RecentStickersNotModified))return{hash:String(n.hash),stickers:q(n.stickers.slice(0,20))}}async function li(e){let{hash:t="0"}=e;const n=await Qn(new h.Api.messages.GetFavedStickers({hash:H()(t)}));if(n&&!(n instanceof h.Api.messages.FavedStickersNotModified))return{hash:String(n.hash),stickers:q(n.stickers)}}async function fi(e){let{hash:t="0"}=e;const n=await Qn(new h.Api.messages.GetFeaturedStickers({hash:H()(t)}));if(n&&!(n instanceof h.Api.messages.FeaturedStickersNotModified))return{hash:String(n.hash),isPremium:Boolean(n.premium),sets:n.sets.map(N)}}async function gi(){const e=await Qn(new h.Api.messages.GetFeaturedEmojiStickers({hash:H()(0)}));if(e&&!(e instanceof h.Api.messages.FeaturedStickersNotModified))return e.sets.forEach((e=>{let{set:t}=e;t.thumbDocumentId&&(U.stickerSets[String(t.id)]=t)})),{isPremium:Boolean(e.premium),sets:e.sets.map(N)}}async function pi(e){let{sticker:t,unfave:n}=e;const s=new h.Api.messages.FaveSticker({id:ce(t),unfave:n});await Qn(s)&&Wa({"@type":"updateFavoriteStickers"})}function hi(e){let{sticker:t}=e;return Qn(new h.Api.messages.SaveRecentSticker({id:ce(t),unsave:!0}))}function mi(){return Qn(new h.Api.messages.ClearRecentStickers)}async function _i(e){let{stickerSetInfo:t}=e;if("isMissing"in t)return;const n=await Qn(new h.Api.messages.GetStickerSet({stickerset:"id"in t?de(t.id,t.accessHash):(s=t.shortName,new h.Api.InputStickerSetShortName({shortName:s}))}));var s;return n instanceof h.Api.messages.StickerSet?(U.stickerSets[String(n.set.id)]=n.set,{set:V(n.set),stickers:q(n.documents),packs:F(n.packs)}):void 0}async function yi(e){let{documentId:t}=e;if(!t.length)return;const n=await Qn(new h.Api.messages.GetCustomEmojiDocuments({documentId:t.map((e=>H()(e)))}));return n?q(n):void 0}async function bi(){const e=await Qn(new h.Api.messages.GetStickerSet({stickerset:new h.Api.InputStickerSetAnimatedEmoji}));if(e instanceof h.Api.messages.StickerSet)return{set:V(e.set),stickers:q(e.documents)}}async function wi(){const e=await Qn(new h.Api.messages.GetStickerSet({stickerset:new h.Api.InputStickerSetAnimatedEmojiAnimations}));if(e instanceof h.Api.messages.StickerSet)return{set:V(e.set),stickers:q(e.documents)}}async function vi(){const e=await Qn(new h.Api.messages.GetStickerSet({stickerset:new h.Api.InputStickerSetPremiumGifts}));if(e instanceof h.Api.messages.StickerSet)return{set:V(e.set),stickers:q(e.documents)}}async function Ai(e){let{query:t,hash:n="0"}=e;const s=await Qn(new h.Api.messages.SearchStickerSets({q:t,hash:H()(n)}));if(s&&!(s instanceof h.Api.messages.FoundStickerSetsNotModified))return{hash:String(s.hash),sets:s.sets.map(N)}}async function Si(e){let{hash:t="0"}=e;const n=await Qn(new h.Api.messages.GetSavedGifs({hash:H()(t)}));if(n&&!(n instanceof h.Api.messages.SavedGifsNotModified))return{hash:String(n.hash),gifs:Ei(n.gifs)}}function Ii(e){let{gif:t,shouldUnsave:n}=e;return Qn(new h.Api.messages.SaveGif({id:ce(t),unsave:n}),!0)}async function Pi(e){let{stickerSetId:t,accessHash:n}=e;await Qn(new h.Api.messages.InstallStickerSet({stickerset:de(t,n)}))&&Wa({"@type":"updateStickerSet",id:t,stickerSet:{installedDate:Date.now()}})}async function Ci(e){let{stickerSetId:t,accessHash:n}=e;await Qn(new h.Api.messages.UninstallStickerSet({stickerset:de(t,n)}))&&Wa({"@type":"updateStickerSet",id:t,stickerSet:{installedDate:void 0}})}async function Mi(e){let{query:t,offset:n=""}=e;if(!$a){const e=await Qn(new h.Api.help.GetConfig);if(!e)return;const t=await Qn(new h.Api.contacts.ResolveUsername({username:e.gifSearchUsername}));if(!(t&&t.users[0]instanceof h.Api.User))return;$a=new h.Api.InputUser({userId:t.peer.userId,accessHash:t.users[0].accessHash})}const s=await Qn(new h.Api.messages.GetInlineBotResults({bot:$a,peer:new h.Api.InputPeerEmpty,query:t,offset:n}));if(!s)return;const a=s.results.map((e=>{if(e instanceof h.Api.BotInlineMediaResult)return e.document})).filter(Boolean);return{nextOffset:s.nextOffset,gifs:Ei(a)}}async function ki(e){let{emoji:t,hash:n="0"}=e;const s=await Qn(new h.Api.messages.GetStickers({emoticon:t,hash:H()(n)}));if(s&&!(s instanceof h.Api.messages.StickersNotModified))return{stickers:q(s.stickers),hash:String(s.hash)}}async function Ri(e){let{language:t,fromVersion:n}=e;const s=await Qn(new h.Api.messages.GetEmojiKeywordsDifference({langCode:t,fromVersion:n}));if(s)return{language:s.langCode,version:s.version,keywords:s.keywords.reduce(((e,t)=>(e[t.keyword]=t.emoticons,e)),{})}}function Ei(e){return e.map((e=>{if(e instanceof h.Api.Document){const t=at(e);if(t)return U.documents[String(e.id)]=e,t}})).filter(Boolean)}function Ui(e){let{username:t}=e;return Qn(new h.Api.channels.CheckUsername({channel:new h.Api.InputChannelEmpty,username:t}),void 0,!0).catch((e=>{if("USERNAME_INVALID"===e.message)return!1;throw e}))}async function Bi(e){let{chat:t,username:n}=e;await Qn(new h.Api.channels.UpdateUsername({channel:re(t.id,t.accessHash),username:n}))&&Ja({"@type":"updateChat",id:t.id,chat:{username:n}})}async function Di(e){let{chat:t,usageLimit:n,expireDate:s}=e;const a=await Qn(new h.Api.messages.ExportChatInvite({peer:ie(t.id,t.accessHash),usageLimit:n,expireDate:s}));if(a instanceof h.Api.ChatInviteExported)return Ja({"@type":"updateChatFullInfo",id:t.id,fullInfo:{inviteLink:a.link}}),a.link}async function Ti(e){let{peer:t,admin:n,limit:s=0,isRevoked:a}=e;const i=await Qn(new h.Api.messages.GetExportedChatInvites({peer:ie(t.id,t.accessHash),adminId:re(n.id,n.accessHash),limit:s,revoked:a||void 0}));if(i)return ee(i.users),i.invites.filter((e=>e instanceof h.Api.ChatInviteExported)).map(xt)}async function xi(e){let{peer:t,isRevoked:n,link:s,expireDate:a,usageLimit:i,isRequestNeeded:o,title:r}=e;const d=await Qn(new h.Api.messages.EditExportedChatInvite({link:s,peer:ie(t.id,t.accessHash),expireDate:a,usageLimit:o?void 0:i,requestNeeded:o,title:r,revoked:n||void 0}));if(d){if(ee(d.users),d instanceof h.Api.messages.ExportedChatInvite&&d.invite instanceof h.Api.ChatInviteExported){const e=xt(d.invite);return{oldInvite:e,newInvite:e}}if(d instanceof h.Api.messages.ExportedChatInviteReplaced&&d.invite instanceof h.Api.ChatInviteExported&&d.newInvite instanceof h.Api.ChatInviteExported)return{oldInvite:xt(d.invite),newInvite:xt(d.newInvite)}}}async function Vi(e){let{peer:t,expireDate:n,usageLimit:s,isRequestNeeded:a,title:i}=e;const o=await Qn(new h.Api.messages.ExportChatInvite({peer:ie(t.id,t.accessHash),expireDate:n,usageLimit:a?void 0:s,requestNeeded:a||void 0,title:i}));if(o instanceof h.Api.ChatInviteExported)return xt(o)}async function Ni(e){let{peer:t,link:n}=e;return await Qn(new h.Api.messages.DeleteExportedChatInvite({peer:ie(t.id,t.accessHash),link:n}))}async function Fi(e){let{peer:t,admin:n}=e;return await Qn(new h.Api.messages.DeleteRevokedExportedChatInvites({peer:ie(t.id,t.accessHash),adminId:re(n.id,n.accessHash)}))}async function qi(e){let{peer:t,link:n,offsetDate:s=0,offsetUser:a,limit:i=0,isRequested:o}=e;const r=await Qn(new h.Api.messages.GetChatInviteImporters({peer:ie(t.id,t.accessHash),link:n,offsetDate:s,offsetUser:a?re(a.id,a.accessHash):new h.Api.InputUserEmpty,limit:i,requested:o||void 0}));if(!r)return;const d=r.users.map((e=>zt(e))).filter(Boolean);return ee(r.users),{importers:r.importers.map((e=>function(e){const{userId:t,date:n,about:s,requested:a}=e;return{userId:W(t,"user"),date:n,about:s,isRequested:a}}(e))),users:m(d,"id")}}function Li(e){let{peer:t,user:n,isApproved:s}=e;return Qn(new h.Api.messages.HideChatJoinRequest({peer:ie(t.id,t.accessHash),userId:re(n.id,n.accessHash),approved:s||void 0}),!0)}function Gi(e){let{peer:t,isApproved:n,link:s}=e;return Qn(new h.Api.messages.HideAllChatJoinRequests({peer:ie(t.id,t.accessHash),approved:n||void 0,link:s}),!0)}function Hi(e){const{id:t,accessHash:n}=e;return Qn(new h.Api.messages.HidePeerSettingsBar({peer:ie(t,n)}))}const Oi={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"},Ki={};let zi,ji;async function Wi(){const e=await Qn(new h.Api.account.GetPassword);if(!e)return;const{hint:t,hasPassword:n}=e;return{hint:t,hasPassword:n}}function $i(e){return zi({"@type":"updateTwoFaStateWaitCode",length:e}),new Promise(((e,t)=>{Ki.resolve=e,Ki.reject=t}))}async function Ji(e){try{return await es({isCheckPassword:!0,currentPassword:e}),!0}catch(e){return eo(e),!1}}async function Qi(e){try{return await es({currentPassword:e}),!0}catch(e){return eo(e),!1}}async function Xi(e,t,n,s){try{return await es({currentPassword:e,newPassword:t,hint:n,email:s,emailCodeCallback:$i,onEmailCodeError:eo}),!0}catch(e){return eo(e),!1}}async function Yi(e,t){try{return await es({currentPassword:e,newPassword:e,email:t,emailCodeCallback:$i,onEmailCodeError:eo}),!0}catch(e){return eo(e),!1}}function Zi(e){Ki.resolve(e)}function eo(e){let t;if(e instanceof h.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=Oi[e.message];t||(t="Unexpected Error"),zi({"@type":"updateTwoFaError",message:t})}async function to(e){let{chatId:t,accessHash:n,messageId:s,data:a,isGame:i}=e;const o=await Qn(new h.Api.messages.GetBotCallbackAnswer({peer:ie(t,n),msgId:s,data:a?ne(a):void 0,game:i||void 0}));return o?A(o):void 0}async function no(){const e=await Qn(new h.Api.contacts.GetTopPeers({botsInline:!0}));if(!(e instanceof h.Api.contacts.TopPeers))return;const t=e.users.map(zt).filter(Boolean);return{ids:t.map((e=>{let{id:t}=e;return t})),users:t}}async function so(e){let{username:t}=e;const n=await Qn(new h.Api.contacts.ResolveUsername({username:t}));if(n&&n.users[0]instanceof h.Api.User&&n.users[0].bot&&n.users[0].botInlinePlaceholder)return Z(n.users[0]),{user:zt(n.users[0]),chat:St(n.users[0])}}async function ao(e){let{bot:t,chat:n,query:s,offset:a=""}=e;const i=await Qn(new h.Api.messages.GetInlineBotResults({bot:ie(t.id,t.accessHash),peer:ie(n.id,n.accessHash),query:s,offset:a}));var o,r,d,c,u;if(i)return ee(i.users),{isGallery:Boolean(i.gallery),help:t.botPlaceholder,nextOffset:(c=t.username,u=i.nextOffset,"gif"===c&&"0"===u?"":u),switchPm:(d=i.switchPm,d?_(d,["text","startParam"]):void 0),users:i.users.map(zt).filter(Boolean),results:(o=String(i.queryId),r=i.results,r.map((e=>{return e instanceof h.Api.BotInlineMediaResult?(e.document instanceof h.Api.Document&&(t=e.document,U.documents[String(t.id)]=t),e.photo instanceof h.Api.Photo&&(n=e.photo,U.photos[String(n.id)]=n),function(e,t){const{id:n,type:s,title:a,description:i,photo:o,document:r}=e;return{id:n,queryId:t,type:s,title:a,description:i,..."sticker"===s&&r instanceof h.Api.Document&&{sticker:x(r)},...o instanceof h.Api.Photo&&{photo:C(o)},..."gif"===s&&r instanceof h.Api.Document&&{gif:at(r)},..."video"===s&&r instanceof h.Api.Document&&{thumbnail:P(r.thumbs)}}}(e,o)):(e.thumb&&(s=e.thumb,U.webDocuments[s.url]=s),function(e,t){const{id:n,type:s,title:a,description:i,url:o,thumb:r}=e;return{id:n,queryId:t,type:s,title:a,description:i,url:o,webThumbnail:gt(r)}}(e,o));var t,n,s})))}}async function io(e){let{chat:t,resultId:n,queryId:s,replyingTo:a,sendAs:i,isSilent:o,scheduleDate:r}=e;const d=fe();await Qn(new h.Api.messages.SendInlineBotResult({clearDraft:!0,randomId:d,queryId:H()(s),peer:ie(t.id,t.accessHash),id:n,scheduleDate:r,...o&&{silent:!0},...a&&{replyToMsgId:a},...i&&{sendAs:ie(i.id,i.accessHash)}}),!0)}async function oo(e){let{bot:t,startParam:n}=e;const s=fe();await Qn(new h.Api.messages.StartBot({bot:ie(t.id,t.accessHash),peer:ie(t.id,t.accessHash),randomId:s,startParam:n}),!0)}async function ro(e){let{isSilent:t,peer:n,bot:s,url:a,startParam:i,replyToMessageId:o,theme:r,sendAs:d,isFromBotMenu:c}=e;const u=await Qn(new h.Api.messages.RequestWebView({silent:t||void 0,peer:ie(n.id,n.accessHash),bot:ie(s.id,s.accessHash),replyToMsgId:o,url:a,startParam:i,themeParams:r?Ie(r):void 0,fromBotMenu:c||void 0,platform:"webz",...d&&{sendAs:ie(d.id,d.accessHash)}}));if(u instanceof h.Api.WebViewResultUrl)return{url:u.url,queryId:u.queryId.toString()}}async function co(e){let{bot:t,url:n,theme:s}=e;const a=await Qn(new h.Api.messages.RequestSimpleWebView({url:n,bot:ie(t.id,t.accessHash),themeParams:s?Ie(s):void 0,platform:"webz"}));return null==a?void 0:a.url}function uo(e){let{isSilent:t,peer:n,bot:s,queryId:a,replyToMessageId:i,sendAs:o}=e;return Qn(new h.Api.messages.ProlongWebView({silent:t||void 0,peer:ie(n.id,n.accessHash),bot:ie(s.id,s.accessHash),queryId:H()(a),replyToMsgId:i,...o&&{sendAs:ie(o.id,o.accessHash)}}))}async function lo(e){let{bot:t,buttonText:n,data:s}=e;const a=fe();await Qn(new h.Api.messages.SendWebViewData({bot:ie(t.id,t.accessHash),buttonText:n,data:s,randomId:a}),!0)}async function fo(e){let{hash:t}=e;const n=await Qn(new h.Api.messages.GetAttachMenuBots({hash:t?H()(t):void 0}));if(n instanceof h.Api.AttachMenuBots)return ee(n.users),{hash:n.hash.toString(),bots:m(n.bots.map(qt),"id")}}function go(e){let{bot:t,isEnabled:n}=e;return Qn(new h.Api.messages.ToggleBotInAttachMenu({bot:ie(t.id,t.accessHash),enabled:n}))}async function po(e){let{chat:t,buttonId:n,messageId:s}=e;const a=await Qn(new h.Api.messages.RequestUrlAuth({peer:ie(t.id,t.accessHash),buttonId:n,msgId:s}));if(!a)return;const i=nn(a);return"request"===(null==i?void 0:i.type)&&ji({"@type":"updateUser",id:i.bot.id,user:i.bot}),i}async function ho(e){let{chat:t,messageId:n,buttonId:s,isWriteAllowed:a}=e;const i=await Qn(new h.Api.messages.AcceptUrlAuth({peer:ie(t.id,t.accessHash),msgId:n,buttonId:s,writeAllowed:a||void 0}));if(!i)return;const o=nn(i);return"request"===(null==o?void 0:o.type)&&ji({"@type":"updateUser",id:o.bot.id,user:o.bot}),o}async function mo(e){let{url:t}=e;const n=await Qn(new h.Api.messages.RequestUrlAuth({url:t}));if(!n)return;const s=nn(n);return"request"===(null==s?void 0:s.type)&&ji({"@type":"updateUser",id:s.bot.id,user:s.bot}),s}async function _o(e){let{url:t,isWriteAllowed:n}=e;const s=await Qn(new h.Api.messages.AcceptUrlAuth({url:t,writeAllowed:n||void 0}));if(!s)return;const a=nn(s);return"request"===(null==a?void 0:a.type)&&ji({"@type":"updateUser",id:a.bot.id,user:a.bot}),a}var yo=n(48764).Buffer;let bo,wo;async function vo(e){let{call:t}=e;const n=await Qn(new h.Api.phone.GetGroupCall({call:Ce(t)}));if(!n)return;ee(n.users),ee(n.chats);const s=n.users.map(zt).filter(Boolean),a=n.chats.map((e=>St(e))).filter(Boolean);return{groupCall:De(n.call),users:s,chats:a}}function Ao(e){let{call:t}=e;return Qn(new h.Api.phone.DiscardGroupCall({call:Ce(t)}),!0)}function So(e){let{call:t,participant:n,muted:s,presentationPaused:a,videoStopped:i,videoPaused:o,volume:r,raiseHand:d}=e;return Qn(new h.Api.phone.EditGroupCallParticipant({call:Ce(t),participant:ie(n.id,n.accessHash),...void 0!==i&&{videoStopped:i},...void 0!==o&&{videoPaused:o},...void 0!==s&&{muted:s},...void 0!==a&&{presentationPaused:a},...void 0!==d&&{raiseHand:d},...void 0!==r&&{volume:r}}),!0)}function Io(e){let{groupCall:t,title:n}=e;return Qn(new h.Api.phone.EditGroupCallTitle({title:n,call:Ce(t)}),!0)}async function Po(e){let{call:t,canSelfUnmute:n}=e;const s=await Qn(new h.Api.phone.ExportGroupCallInvite({canSelfUnmute:n||void 0,call:Ce(t)}));if(s)return s.link}async function Co(e){let{call:t,offset:n}=e;const s=await Qn(new h.Api.phone.GetGroupParticipants({call:Ce(t),ids:[],sources:[],offset:n||"",limit:100}));if(!s)return;ee(s.users),ee(s.chats);const a=s.users.map(zt).filter(Boolean),i=s.chats.map((e=>St(e))).filter(Boolean);return bo({"@type":"updateGroupCallParticipants",groupCallId:t.id,participants:s.participants.map(Ee),nextOffset:s.nextOffset}),{users:a,chats:i}}function Mo(e){let{call:t}=e;return Qn(new h.Api.phone.LeaveGroupCall({call:Ce(t)}),!0)}async function ko(e){let{call:t,inviteHash:n,params:s}=e;const a=await Qn(new h.Api.phone.JoinGroupCall({call:Ce(t),joinAs:new h.Api.InputPeerSelf,muted:!0,videoStopped:!0,params:new h.Api.DataJSON({data:JSON.stringify(s)}),inviteHash:n}));if(a&&a instanceof h.Api.Updates){const e=a.updates.find((e=>e instanceof h.Api.UpdateGroupCall));if(!(e instanceof h.Api.UpdateGroupCall))return;return De(e.call)}}async function Ro(e){let{peer:t}=e;const n=ge(),s=await Qn(new h.Api.phone.CreateGroupCall({peer:ie(t.id,t.accessHash),randomId:n}));if(s&&s instanceof h.Api.Updates){const e=s.updates[0];if(e instanceof h.Api.UpdateGroupCall)return De(e.call)}}function Eo(e){let{call:t,params:n}=e;return Qn(new h.Api.phone.JoinGroupCallPresentation({call:Ce(t),params:new h.Api.DataJSON({data:JSON.stringify(n)})}),!0)}function Uo(e){let{call:t,subscribed:n}=e;return Qn(new h.Api.phone.ToggleGroupCallStartSubscription({call:Ce(t),subscribed:n}),!0)}function Bo(e){let{call:t}=e;return Qn(new h.Api.phone.LeaveGroupCallPresentation({call:Ce(t)}),!0)}async function Do(){const e=await Qn(new h.Api.messages.GetDhConfig({}));if(e&&!(e instanceof h.Api.messages.DhConfigNotModified))return{g:e.g,p:Array.from(e.p),random:Array.from(e.random)}}function To(e){let{call:t,isBusy:n}=e;return Qn(new h.Api.phone.DiscardCall({peer:Me(t),reason:n?new h.Api.PhoneCallDiscardReasonBusy:new h.Api.PhoneCallDiscardReasonHangup}),!0)}async function xo(e){let{user:t,gAHash:n,isVideo:s}=e;const a=await Qn(new h.Api.phone.RequestCall({randomId:ge(),userId:ie(t.id,t.accessHash),gAHash:yo.from(n),...s&&{video:!0},protocol:Fe()}));if(!a)return!1;const i=Te(a.phoneCall);return bo({"@type":"updatePhoneCall",call:i}),!0}function Vo(e){let{call:t,rating:n,comment:s}=e;return Qn(new h.Api.phone.SetCallRating({rating:n,peer:Me(t),comment:s}),!0)}function No(e){let{call:t}=e;return Qn(new h.Api.phone.ReceivedCall({peer:Me(t)}))}async function Fo(e){let{call:t,gB:n}=e;const s=await Qn(new h.Api.phone.AcceptCall({peer:Me(t),gB:yo.from(n),protocol:Fe()}));s&&(t=Te(s.phoneCall),bo({"@type":"updatePhoneCall",call:t}))}async function qo(e){let{call:t,gA:n,keyFingerprint:s}=e;const a=await Qn(new h.Api.phone.ConfirmCall({peer:Me(t),gA:yo.from(n),keyFingerprint:H()(s),protocol:Fe()}));a&&(t=Te(a.phoneCall),bo({"@type":"updatePhoneCall",call:t}))}function Lo(e){let{data:t,call:n}=e;return Qn(new h.Api.phone.SendSignalingData({data:yo.from(t),peer:Me(n)}))}function Go(e){if(e)return Object.values(e).map((e=>({id:e.id,title:e.title,amount:e.prices.reduce(((e,t)=>e+t.amount.toJSNumber()),0),prices:e.prices.map((e=>{let{label:t,amount:n}=e;return{label:t,amount:n.toJSNumber()}}))})))}function Ho(e){const{formId:t,canSaveCredentials:n,passwordMissing:s,providerId:a,nativeProvider:i,nativeParams:o,savedInfo:r,invoice:d,savedCredentials:c}=e,{test:u,nameRequested:l,phoneRequested:f,emailRequested:g,shippingAddressRequested:p,flexible:h,phoneToProvider:m,emailToProvider:_,currency:y,prices:b}=d,w=b.map((e=>{let{label:t,amount:n}=e;return{label:t,amount:n.toJSNumber()}})),{shippingAddress:v}=r||{},S=r?A(r):void 0;S&&v&&(S.shippingAddress=A(v));const I=o?JSON.parse(o.data):{};return{canSaveCredentials:n,isPasswordMissing:s,formId:String(t),providerId:String(a),nativeProvider:i,savedInfo:S,invoiceContainer:{isTest:u,isNameRequested:l,isPhoneRequested:f,isEmailRequested:g,isShippingAddressRequested:p,isFlexible:h,shouldSendPhoneToProvider:m,shouldSendEmailToProvider:_,currency:y,prices:w},nativeParams:{needCardholderName:Boolean(null==I?void 0:I.need_cardholder_name),needCountry:Boolean(null==I?void 0:I.need_country),needZip:Boolean(null==I?void 0:I.need_zip),publishableKey:null==I?void 0:I.publishable_key,publicToken:null==I?void 0:I.public_token},...c&&{savedCredentials:(P=c,P.map((e=>{let{id:t,title:n}=e;return{id:t,title:n}})))}};var P}function Oo(e){const{invoice:t,description:n,title:s,photo:a}=e,{test:i,currency:o,prices:r,recurring:d,recurringTermsUrl:c,maxTipAmount:u,suggestedTipAmounts:l}=t,f=r.reduce(((e,t)=>e+t.amount.toJSNumber()),0);return{text:n,title:s,photo:gt(a),amount:f,currency:o,isTest:i,isRecurring:d,recurringTermsUrl:c,maxTipAmount:null==u?void 0:u.toJSNumber(),...l&&{suggestedTipAmounts:l.map((e=>e.toJSNumber()))}}}function Ko(e){const{statusText:t,statusEntities:n,videos:s,videoSections:a,periodOptions:i}=e;return{statusText:t,statusEntities:n.map((e=>ht(e))),videoSections:a,videos:s.map(it).filter(Boolean),options:i.map(zo)}}function zo(e){const{current:t,canPurchaseUpgrade:n,currency:s,amount:a,botUrl:i,months:o}=e;return{isCurrent:t,canPurchaseUpgrade:n,currency:s,amount:a.toString(),botUrl:i,months:o}}async function jo(e){let{inputInvoice:t,requestInfo:n,shouldSave:s}=e;const a=await Qn(new h.Api.payments.ValidateRequestedInfo({invoice:ke(t),save:s||void 0,info:ve(n)}));if(!a)return;const{id:i,shippingOptions:o}=a;return i?{id:i,shippingOptions:Go(o)}:void 0}async function Wo(e){let{inputInvoice:t,formId:n,requestedInfoId:s,shippingOptionId:a,credentials:i,savedCredentialId:o,temporaryPassword:r,tipAmount:d}=e;const c=r&&o?new h.Api.InputPaymentCredentialsSaved({id:o,tmpPassword:ne(r)}):new h.Api.InputPaymentCredentials({save:i.save,data:new h.Api.DataJSON({data:JSON.stringify(i.data)})}),u=await Qn(new h.Api.payments.SendPaymentForm({formId:H()(n),invoice:ke(t),requestedInfoId:s,shippingOptionId:a,credentials:c,...d&&{tipAmount:H()(d)}}));if(!(u instanceof h.Api.payments.PaymentVerificationNeeded))return Boolean(u);wo({"@type":"updatePaymentVerificationNeeded",url:u.url})}async function $o(e){const t=await Qn(new h.Api.payments.GetPaymentForm({invoice:ke(e)}));if(t)return t.photo&&(U.webDocuments[t.photo.url]=t.photo),ee(t.users),{form:Ho(t),invoice:Oo(t)}}async function Jo(e,t){const n=await Qn(new h.Api.payments.GetPaymentReceipt({peer:ie(e.id,e.accessHash),msgId:t}));if(n)return function(e){const{invoice:t,info:n,shipping:s,currency:a,totalAmount:i,credentialsTitle:o,tipAmount:r}=e,{shippingAddress:d,phone:c,name:u}=n||{},{prices:l}=t,f=l.map((e=>{let{label:t,amount:n}=e;return{label:t,amount:n.toJSNumber()}}));let g,p;return s&&(g=s.prices.map((e=>{let{label:t,amount:n}=e;return{label:t,amount:n.toJSNumber()}})),p=s.title),{currency:a,prices:f,info:{shippingAddress:d,phone:c,name:u},totalAmount:i.toJSNumber(),credentialsTitle:o,shippingPrices:g,shippingMethod:p,tipAmount:r?r.toJSNumber():0}}(n)}async function Qo(){const e=await Qn(new h.Api.help.GetPremiumPromo);if(!e)return;ee(e.users);const t=e.users.map(zt).filter(Boolean);return e.videos.forEach((e=>{e instanceof h.Api.Document&&(U.documents[e.id.toString()]=e)})),{promo:Ko(e),users:t}}async function Xo(e){const t=await function(e,t){return function(e,t){return Hn.getTmpPassword(e,t)}(e,t)}(e);if(t)return"error"in t?t:{value:te(t.tmpPassword),validUntil:t.validUntil}}async function Yo(e){let{peer:t,reason:n,description:s}=e;return await Qn(new h.Api.account.ReportPeer({peer:ie(t.id,t.accessHash),reason:Se(n),message:s}))}async function Zo(e){let{peer:t,photo:n,reason:s,description:a}=e;const i=_e(n);if(i)return await Qn(new h.Api.account.ReportProfilePhoto({peer:ie(t.id,t.accessHash),photoId:i,reason:Se(s),message:a}))}async function er(e){let{hash:t,areCallsEnabled:n,areSecretChatsEnabled:s}=e;return await Qn(new h.Api.account.ChangeAuthorizationSettings({hash:H()(t),...void 0!==n?{callRequestsDisabled:!n}:void 0,...void 0!==s?{encryptedRequestsDisabled:!s}:void 0}))}async function tr(e){let{days:t}=e;return await Qn(new h.Api.account.SetAuthorizationTTL({authorizationTtlDays:t}))}var nr=n(48764).Buffer;function sr(e){const{emojies_sounds:t}=e;return t?Object.keys(t).reduce(((e,n)=>{const s=t[n];return U.documents[s.id]=new h.Api.Document({id:H()(s.id),accessHash:H()(s.access_hash),dcId:1,mimeType:"audio/ogg",fileReference:nr.from(atob(s.file_reference_base64.replace(/-/g,"+").replace(/_/g,"/"))),size:H()(0)}),e[n]=s.id,e}),{}):{}}function ar(e,t,n){return[e[`${t}_default`]||f[n][0],e[`${t}_premium`]||f[n][1]]}const ir=["ar","fa","id","ko","uz","en"];function or(e){let{firstName:t,lastName:n,about:s}=e;return Qn(new h.Api.account.UpdateProfile({firstName:t||"",lastName:n||"",about:s||""}),!0)}function rr(e){return Qn(new h.Api.account.CheckUsername({username:e}),void 0,!0).catch((e=>{if("USERNAME_INVALID"===e.message)return!1;throw e}))}function dr(e){return Qn(new h.Api.account.UpdateUsername({username:e}),!0)}async function cr(e){const t=await Zn(e);return Qn(new h.Api.photos.UploadProfilePhoto({file:t}),!0)}async function ur(e){const t=await Zn(e);await Qn(new h.Api.photos.UploadProfilePhoto({file:t}))}async function lr(e){const t=_e(e);if(!t)return!1;const n=await Qn(new h.Api.photos.DeletePhotos({id:[t]}),!0);return n&&delete U.photos[e.id],n}async function fr(){const e=await Qn(new h.Api.account.GetWallPapers({hash:H()("0")}));if(!e||e instanceof h.Api.account.WallPapersNotModified)return;const t=e.wallpapers.filter((e=>e instanceof h.Api.WallPaper&&e.document instanceof h.Api.Document&&!e.pattern&&"application/x-tgwallpattern"!==e.document.mimeType));return t.forEach((e=>{U.documents[String(e.document.id)]=e.document})),{wallpapers:t.map(Jt).filter(Boolean)}}async function gr(e){const t=await Zn(e),n=await Qn(new h.Api.account.UploadWallPaper({file:t,mimeType:e.type,settings:new h.Api.WallPaperSettings}));if(!(n&&n instanceof h.Api.WallPaper))return;const s=Jt(n);return s?(U.documents[String(n.document.id)]=n.document,{wallpaper:s}):void 0}async function pr(){const e=await Qn(new h.Api.contacts.GetBlocked({limit:100}));if(e)return Fr(e),{users:e.users.map(zt).filter(Boolean),chats:e.chats.map((e=>St(e))).filter(Boolean),blockedIds:e.blocked.map((e=>$(e.peerId))),totalCount:e instanceof h.Api.contacts.BlockedSlice?e.count:e.blocked.length}}function hr(e,t){return Qn(new h.Api.contacts.Block({id:ie(e,t)}))}function mr(e,t){return Qn(new h.Api.contacts.Unblock({id:ie(e,t)}))}async function _r(){const e=await Qn(new h.Api.account.GetAuthorizations);if(e)return{authorizations:m(e.authorizations.map(Qt),"hash"),ttlDays:e.authorizationTtlDays}}function yr(e){return Qn(new h.Api.account.ResetAuthorization({hash:H()(e)}))}function br(){return Qn(new h.Api.auth.ResetAuthorizations)}async function wr(){const e=await Qn(new h.Api.account.GetWebAuthorizations);if(e)return m(e.authorizations.map(Xt),"hash")}function vr(e){return Qn(new h.Api.account.ResetWebAuthorization({hash:H()(e)}))}function Ar(){return Qn(new h.Api.account.ResetWebAuthorizations)}async function Sr(e){let{serverTimeOffset:t}=e;const n=await Qn(new h.Api.account.GetNotifyExceptions({compareSound:!0}),void 0,void 0,!0);if(n instanceof h.Api.Updates||n instanceof h.Api.UpdatesCombined)return Fr(n),n.updates.reduce(((e,n)=>n instanceof h.Api.UpdateNotifySettings&&n.peer instanceof h.Api.NotifyPeer?(e.push(Zt(n.notifySettings,n.peer.peer,t)),e):e),[])}async function Ir(e){let{serverTimeOffset:t}=e;const[n,s,a,i]=await Promise.all([Qn(new h.Api.account.GetContactSignUpNotification),Qn(new h.Api.account.GetNotifySettings({peer:new h.Api.InputNotifyUsers})),Qn(new h.Api.account.GetNotifySettings({peer:new h.Api.InputNotifyChats})),Qn(new h.Api.account.GetNotifySettings({peer:new h.Api.InputNotifyBroadcasts}))]);if(!s||!a||!i)return!1;const{silent:o,muteUntil:r,showPreviews:d}=s,{silent:c,muteUntil:u,showPreviews:l}=a,{silent:f,muteUntil:g,showPreviews:p}=i;return{hasContactJoinedNotifications:!n,hasPrivateChatsNotifications:!(o||"number"==typeof r&&_t(t)Qn(new h.Api.langpack.GetLangPack({langPack:e,langCode:ir.includes(n)?`${n}-raw`:n})))))).filter(Boolean).map((e=>m(e.strings.map(A),"key")));if(s.length)return{langPack:Object.assign({},...s.reverse())}}async function Rr(e){let{langPack:t,langCode:n,keys:s}=e;const a=await Qn(new h.Api.langpack.GetStrings({langPack:t,langCode:ir.includes(n)?`${n}-raw`:n,keys:s}));if(a)return a.map(A)}async function Er(e){const t=Ae(e),n=await Qn(new h.Api.account.GetPrivacy({key:t}));if(n)return Fr(n),Yt(n.rules)}function Ur(e){const t=Hn.session.getAuthKey().getKey();return Qn(new h.Api.account.RegisterDevice({tokenType:10,secret:t,appSandbox:!1,otherUids:[],token:e}))}function Br(e){return Qn(new h.Api.account.UnregisterDevice({tokenType:10,otherUids:[],token:e}))}async function Dr(e,t){const n=Ae(e),s=[];switch(t.allowedUsers&&s.push(new h.Api.InputPrivacyValueAllowUsers({users:t.allowedUsers.map((e=>{let{id:t,accessHash:n}=e;return re(t,n)}))})),t.allowedChats&&s.push(new h.Api.InputPrivacyValueAllowChatParticipants({chats:t.allowedChats.map((e=>{let{id:t}=e;return re(t)}))})),t.blockedUsers&&s.push(new h.Api.InputPrivacyValueDisallowUsers({users:t.blockedUsers.map((e=>{let{id:t,accessHash:n}=e;return re(t,n)}))})),t.blockedChats&&s.push(new h.Api.InputPrivacyValueDisallowChatParticipants({chats:t.blockedChats.map((e=>{let{id:t}=e;return re(t)}))})),t.visibility){case"everybody":s.push(new h.Api.InputPrivacyValueAllowAll);break;case"contacts":s.push(new h.Api.InputPrivacyValueAllowContacts);break;case"nonContacts":s.push(new h.Api.InputPrivacyValueDisallowContacts);break;case"nobody":s.push(new h.Api.InputPrivacyValueDisallowAll)}const a=await Qn(new h.Api.account.SetPrivacy({key:n,rules:s}));if(a)return Fr(a),Yt(a.rules)}async function Tr(e){await Qn(new h.Api.account.UpdateStatus({offline:!e}))}async function xr(){const e=await Qn(new h.Api.account.GetContentSettings);if(e)return{isSensitiveEnabled:Boolean(e.sensitiveEnabled),canChangeSensitive:Boolean(e.sensitiveCanChange)}}function Vr(e){return Qn(new h.Api.account.SetContentSettings({sensitiveEnabled:e||void 0}))}async function Nr(){const e=await Qn(new h.Api.help.GetAppConfig);if(e)return function(e){const t=tn(e);return{defaultReaction:t.reactions_default,emojiSounds:sr(t),seenByMaxChatMembers:t.chat_read_mark_size_threshold,seenByExpiresAt:t.chat_read_mark_expire_period,autologinDomains:t.autologin_domains||[],autologinToken:t.autologin_token||"",urlAuthDomains:t.url_auth_domains||[],premiumBotUsername:t.premium_bot_username,premiumInvoiceSlug:t.premium_invoice_slug,premiumPromoOrder:t.premium_promo_order,isPremiumPurchaseBlocked:t.premium_purchase_blocked,defaultEmojiStatusesStickerSetId:t.default_emoji_statuses_stickerset_id,limits:{uploadMaxFileparts:ar(t,"upload_max_fileparts","uploadMaxFileparts"),stickersFaved:ar(t,"stickers_faved_limit","stickersFaved"),savedGifs:ar(t,"saved_gifs_limit","savedGifs"),dialogFiltersChats:ar(t,"dialog_filters_chats_limit","dialogFiltersChats"),dialogFilters:ar(t,"dialog_filters_limit","dialogFilters"),dialogFolderPinned:ar(t,"dialogs_pinned_limit","dialogFolderPinned"),captionLength:ar(t,"caption_length_limit","captionLength"),channels:ar(t,"channels_limit","channels"),channelsPublic:ar(t,"channels_public_limit","channelsPublic"),aboutLength:ar(t,"about_length_limit","aboutLength")}}}(e)}function Fr(e){ee(e.users),ee(e.chats)}async function qr(e){let{langCode:t="en"}=e;const n=await Qn(new h.Api.help.GetCountriesList({langCode:t}));if(n instanceof h.Api.help.CountriesList)return function(e){const t=e.filter((e=>{let{hidden:t}=e;return!t}));return{phoneCodes:t.map((e=>e.countryCodes.map((t=>en(e,t))))).flat().sort(((e,t)=>e.name?e.name.localeCompare(t.name):e.defaultName.localeCompare(t.defaultName))),general:t.map((e=>en(e,e.countryCodes[0]))).sort(((e,t)=>e.name?e.name.localeCompare(t.name):e.defaultName.localeCompare(t.defaultName)))}}(n.countries)}async function Lr(){const e=await Qn(new h.Api.account.GetGlobalPrivacySettings);if(e)return{shouldArchiveAndMuteNewNonContact:Boolean(e.archiveAndMuteNewNoncontactPeers)}}async function Gr(e){let{shouldArchiveAndMuteNewNonContact:t}=e;const n=await Qn(new h.Api.account.SetGlobalPrivacySettings({settings:new h.Api.GlobalPrivacySettings({archiveAndMuteNewNoncontactPeers:t})}));if(n)return{shouldArchiveAndMuteNewNonContact:Boolean(n.archiveAndMuteNewNoncontactPeers)}}function Hr(e){let{chat:t,emoticon:n}=e;return Qn(new h.Api.messages.SetTyping({peer:ie(t.id,t.accessHash),action:new h.Api.SendMessageEmojiInteractionSeen({emoticon:n})}))}function Or(e){let{chat:t,emoticon:n,messageId:s,timestamps:a}=e;return Qn(new h.Api.messages.SetTyping({peer:ie(t.id,t.accessHash),action:new h.Api.SendMessageEmojiInteraction({emoticon:n,msgId:s,interaction:new h.Api.DataJSON({data:JSON.stringify({v:1,a:a.map((e=>({t:e,i:1})))})})})}))}async function Kr(){const e=await Qn(new h.Api.messages.GetAvailableReactions({}));if(e&&!(e instanceof h.Api.messages.AvailableReactionsNotModified))return e.reactions.forEach((e=>{e.staticIcon instanceof h.Api.Document&&(U.documents[String(e.staticIcon.id)]=e.staticIcon),e.selectAnimation instanceof h.Api.Document&&(U.documents[String(e.selectAnimation.id)]=e.selectAnimation),e.aroundAnimation instanceof h.Api.Document&&(U.documents[String(e.aroundAnimation.id)]=e.aroundAnimation),e.centerIcon instanceof h.Api.Document&&(U.documents[String(e.centerIcon.id)]=e.centerIcon)})),e.reactions.map(Ze)}function zr(e){let{chat:t,messageId:n,reaction:s}=e;return Qn(new h.Api.messages.SendReaction({...s&&{reaction:[Re(s)]},peer:ie(t.id,t.accessHash),msgId:n}),!0)}function jr(e){let{ids:t,chat:n}=e;return Qn(new h.Api.messages.GetMessagesReactions({id:t,peer:ie(n.id,n.accessHash)}),!0)}async function Wr(e){let{chat:t,messageId:n,reaction:s,offset:a}=e;const i=await Qn(new h.Api.messages.GetMessageReactionsList({peer:ie(t.id,t.accessHash),id:n,...s&&{reaction:Re(s)},limit:100,...a&&{offset:a}}));if(!i)return;ee(i.users);const{nextOffset:o,reactions:r,count:d}=i;return{users:i.users.map(zt).filter(Boolean),nextOffset:o,reactions:r.map(Xe).filter(Boolean),count:d}}function $r(e){let{reaction:t}=e;return Qn(new h.Api.messages.SetDefaultReaction({reaction:Re(t)}))}function Jr(e,t){if(e.error)return;const n=JSON.parse(e.json.data),[s,...a]=n.columns,i=n.y_scaled;return{type:t?"area":n.types.y0,zoomToken:e.zoomToken,labelFormatter:n.xTickFormatter,tooltipFormatter:n.xTooltipFormatter,labels:s.slice(1),hideCaption:!n.subchart.show,hasSecondYAxis:i,isStacked:n.stacked&&!i,isPercentage:t,datasets:a.map((e=>{const t=e[0];return{name:n.names[t],color:(s=n.colors[t],s.substring(s.indexOf("#"))),values:e.slice(1)};var s})),...Qr(n.subchart.defaultZoom,s.slice(1))}}function Qr(e,t){const[n,s]=e;let a=0,i=t.length-1;return t.forEach(((e,t)=>{!a&&e>=n&&(a=t),!i&&e>=s&&(i=t)})),{minimapRange:{begin:Math.max(0,a/(t.length-1)),end:Math.min(1,i/(t.length-1))},labelFromIndex:a,labelToIndex:i}}function Xr(e){let{current:t,previous:n}=e;const s=t-n;return{current:t,change:s,...n&&{percentage:(s?Math.abs(s)/n*100:0).toFixed(2)}}}async function Yr(e){let{chat:t}=e;const n=await Qn(new h.Api.stats.GetBroadcastStats({channel:re(t.id,t.accessHash)}),void 0,void 0,void 0,t.fullInfo.statisticsDcId);var s,a;if(n)return{growthGraph:Jr((s=n).growthGraph),followersGraph:Jr(s.followersGraph),muteGraph:Jr(s.muteGraph),topHoursGraph:Jr(s.topHoursGraph),languagesGraph:s.languagesGraph.token,viewsBySourceGraph:s.viewsBySourceGraph.token,newFollowersBySourceGraph:s.newFollowersBySourceGraph.token,interactionsGraph:s.interactionsGraph.token,followers:Xr(s.followers),viewsPerPost:Xr(s.viewsPerPost),sharesPerPost:Xr(s.sharesPerPost),enabledNotifications:(a=s.enabledNotifications,{percentage:(a.part/a.total*100).toFixed(2)}),recentTopMessages:s.recentMessageInteractions}}async function Zr(e){let{chat:t}=e;const n=await Qn(new h.Api.stats.GetMegagroupStats({channel:re(t.id,t.accessHash)}),void 0,void 0,void 0,t.fullInfo.statisticsDcId);var s,a;if(n)return{growthGraph:Jr((s=n).growthGraph),membersGraph:Jr(s.membersGraph),topHoursGraph:Jr(s.topHoursGraph),languagesGraph:s.languagesGraph.token,messagesGraph:s.messagesGraph.token,actionsGraph:s.actionsGraph.token,period:(a=s.period,{maxDate:a.maxDate,minDate:a.minDate}),members:Xr(s.members),viewers:Xr(s.viewers),messages:Xr(s.messages),posters:Xr(s.posters)}}async function ed(e){let{chat:t,messageId:n}=e;const s=await Qn(new h.Api.stats.GetMessageStats({channel:re(t.id,t.accessHash),msgId:n}),void 0,void 0,void 0,t.fullInfo.statisticsDcId);if(s)return{viewsGraph:Jr(s.viewsGraph)}}async function td(e){let{chat:t,messageId:n,dcId:s}=e;const a=await Qn(new h.Api.stats.GetMessagePublicForwards({channel:re(t.id,t.accessHash),msgId:n,offsetPeer:new h.Api.InputPeerEmpty}),void 0,void 0,void 0,s);if(a)return"chats"in a&&ee(a.chats),function(e){if(e&&"messages"in e)return e.messages.map((t=>{const n=W(t.peerId.channelId,"channel"),s=e.chats.find((e=>W(e.id,"channel")===n));return{messageId:t.id,views:t.views,title:s.title,chat:{id:n,type:"chatTypeChannel",username:s.username,avatarHash:kt(s.photo)}}}))}(a)}async function nd(e){let{token:t,x:n,isPercentage:s,dcId:a}=e;const i=await Qn(new h.Api.stats.LoadAsyncGraph({token:t,...n&&{x:H()(n)}}),void 0,void 0,void 0,a);if(i)return Jr(i,s)}var sd=n(59109),ad=n.n(sd),id=n(96748),od=n.n(id),rd=n(13302),dd=n.n(rd),cd=n(48764).Buffer;function ud(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let ld,fd;class gd{constructor(e){this.isOutgoing=e,ud(this,"state",void 0),ud(this,"seq",0),ud(this,"gA",void 0),ud(this,"gB",void 0),ud(this,"p",void 0),ud(this,"random",void 0),ud(this,"waitForState",void 0),ud(this,"resolveState",void 0),this.waitForState=new Promise((e=>{this.resolveState=e}))}async requestCall(e){let{p:t,g:n,random:s}=e;const a=K().readBigIntFromBuffer(cd.from(t),!1),i=K().readBigIntFromBuffer(cd.from(s),!1),o=K().modExp(H()(n),i,a);this.gA=o,this.p=a,this.random=i;const r=await K().sha256(K().getByteArray(o));return Array.from(r)}acceptCall(e){let{p:t,g:n,random:s}=e;const a=K().readBigIntFromBuffer(t,!1),i=K().readBigIntFromBuffer(s,!1),o=K().modExp(H()(n),i,a);return this.gB=o,this.p=a,this.random=i,Array.from(K().getByteArray(o))}async confirmCall(e,t,n){this.isOutgoing?this.gB=K().readBigIntFromBuffer(cd.from(e),!1):this.gA=K().readBigIntFromBuffer(cd.from(e),!1);const s=K().modExp(this.isOutgoing?this.gB:this.gA,this.random,this.p),a=await K().sha1(K().getByteArray(s)),i=K().readBigIntFromBuffer(a.slice(-8).reverse(),!1),o=await async function(e,t,n,s){const a=await K().sha256(cd.concat([new Uint8Array(e),new Uint8Array(t)])),i=[],o=s.length-1;for(let e=0;e!==a.byteLength;e+=8){const t=(r=a.subarray(e,e+8),H()(r[0]).and(127).shiftLeft(56).or(H()(r[1]).shiftLeft(48)).or(H()(r[2]).shiftLeft(40)).or(H()(r[3]).shiftLeft(32)).or(H()(r[4]).shiftLeft(24)).or(H()(r[5]).shiftLeft(16)).or(H()(r[6]).shiftLeft(8)).or(H()(r[7]))).modPow(1,o).toJSNumber(),d=s[t],c=s[t+1]-d;i.push(String.fromCharCode(...n.subarray(d,d+c)))}var r;return i.join("")}(K().getByteArray(s),K().getByteArray(this.gA),t,n),r=new(dd());return await r.setKey(K().getByteArray(s)),this.state=new(ad())(r,new(od()),!0,this.isOutgoing),this.resolveState(),{gA:Array.from(K().getByteArray(this.gA)),keyFingerprint:i.toString(),emojis:o}}async encode(e){if(!this.state)return;const t=new Uint32Array(1);t[0]=this.seq++;const n=await this.state.encryptMessageData(cd.concat([K().convertToLittle(t),cd.from(e)]));return Array.from(n)}async decode(e){if(!this.state)return this.waitForState.then((()=>this.decode(e)));const t=await this.state.decryptMessageData(cd.from(e));return JSON.parse(t.toString())}}function pd(e){ld=new gd(...e)}function hd(){ld=void 0}function md(e){return ld.encode(...e)}function _d(e){return ld.decode(...e)}function yd(e){return ld.confirmCall(...e)}function bd(e){return ld.acceptCall(...e)}function wd(e){return ld.requestCall(...e)}async function vd(e,t){fd=e,function(e){sn=e}(Cd),function(e){fn=e}(Cd),function(e){is=e}(Cd),function(e){aa=e}(Cd),function(e){ja=e}(Cd),function(e){Wa=e}(Cd),function(e){Ja=e}(Cd),function(e){zi=e}(Cd),function(e){ji=e}(Cd),function(e){bo=e}(Cd),function(e){wo=e}(Cd),await async function(e,t){Gn=e;const{userAgent:n,platform:s,sessionData:a,isTest:i,isMovSupported:o,isWebmSupported:d,maxBufferSize:u,webAuthToken:l,dcId:f}=t,g=new h.sessions.CallbackSession(a,$n);self.isMovSupported=o,o&&c.add(r),self.isWebmSupported=d,self.maxBufferSize=u,Hn=new(kn())(g,"2496","8da85b0d5bfe62527e5b244c209159c3",{deviceModel:navigator.userAgent||n||"Unknown UserAgent",systemVersion:s||"Unknown platform",appVersion:"1.55.14 Z",useWSS:!0,additionalDcsDisabled:!1,testServers:i,dcId:f}),Hn.addEventHandler(Jn,Ln),Hn.addEventHandler(cn,Ln);try{try{await Hn.start({phoneNumber:pn,phoneCode:hn,password:mn,firstAndLastNames:_n,qrCode:yn,onError:bn,initialMethod:"iOS"===s||"Android"===s?"phoneNumber":"qrCode",shouldThrowIfUnauthorized:Boolean(a),webAuthToken:l,webAuthTokenFailed:gn})}catch(e){if(console.error(e),"Disconnect"!==e.message&&"Cannot send requests while disconnected"!==e.message)return void Gn({"@type":"updateConnectionState",connectionState:"connectionStateBroken"})}fn(wn("authorizationStateReady")),$n(g.getSessionData()),Gn({"@type":"updateApiReady"}),ts()}catch(e){throw e}}(Cd,t)}const Ad=function(e,t){let n,s=!1;return function(){for(var a=arguments.length,i=new Array(a),o=0;o{s=!1,t(...n)})))}}((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];g?t?p.push(e):g.push(e):(g=t?[]:[e],p=t?[e]:[],Promise.resolve().then((()=>{const e=g,t=p;g=void 0,p=void 0,t.forEach((e=>e())),e.forEach((e=>e()))})))}),(function(e){if(!Pd||e!==Id)return;const t=Pd;Pd=void 0,t.forEach(fd)}));let Sd,Id,Pd;function Cd(e){Pd?Pd.push(e):Pd=[e],Sd&&!o.has(e["@type"])||(Sd=function(e,t){let n,s,a,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(){s=!0;for(var o=arguments.length,r=new Array(o),d=0;d{if(!s)return self.clearInterval(n),void(n=void 0);s=!1,e(...a)}),t))}}(Ad,i,!0),Id=Math.random()),Sd(Id)}self.onerror=e=>{console.error(e),Rd({type:"unhandledError",error:{message:e.error.message||"Uncaught exception in worker"}})},self.addEventListener("unhandledrejection",(e=>{console.error(e),Rd({type:"unhandledError",error:{message:e.reason.message||"Uncaught rejection in worker"}})}));const Md=new Map;function kd(e){Rd({type:"update",update:e})}function Rd(e,t){t?postMessage(e,[t]):postMessage(e)}onmessage=async e=>{const{data:t}=e;switch(t.type){case"initApi":await vd(kd,t.args[0]);break;case"callMethod":{const{messageId:e,name:n,args:s,withCallback:i}=t;try{if(e&&i){const t=function(){for(var t=arguments.length,n=new Array(t),s=0;s1?t-1:0),s=1;s{var s=n(48764).Buffer;const a=n(24736),i=n(66842);function o(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=s.from(e);const o=i.length;t&&(i=i.reverse());let r=a(i.toString("hex"),16);return n&&Math.floor(r.toString("2").length/8)>=o&&(r=r.subtract(a(2).pow(a(8*o)))),r}function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const n=a(e),i=[];for(let e=0;e2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const o=(e=a(e)).bitLength(),r=Math.ceil(o/8);if(t0&&void 0!==arguments[0])||arguments[0];return o(c(8),!0,e)},mod:function(e,t){return(e%t+t)%t},crc32:function(e){l||(l=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}()),s.isBuffer(e)||(e=s.from(e));let t=-1;for(let n=0;n>>8}return(-1^t)>>>0},generateRandomBytes:c,generateKeyDataFromNonce:async function(e,t){e=r(e,16),t=r(t,32);const[n,a,i]=await Promise.all([u(s.concat([t,e])),u(s.concat([e,t])),u(s.concat([t,t]))]);return{key:s.concat([n,a.slice(0,12)]),iv:s.concat([a.slice(12,20),i,t.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 s=a.one,i=e;for(;t.greater(a.zero);){const e=t.remainder(a(2));t=t.divide(a(2)),e.eq(a.one)&&(s=s.multiply(i),s=s.remainder(n)),i=i.multiply(i),i=i.remainder(n)}return s},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){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=e.toString(2).length,s=Math.floor((n+8-1)/8);return d(a(e),s,!1,t)},toSignedLittleBuffer:r,convertToLittle:function(e){const t=s.alloc(4*e.length);for(let n=0;n{e=t})),resolve:e}}}},59674:(e,t,n)=>{var s=n(48764).Buffer;const a=n(24736),{constructors:i}=n(57404),{readBigIntFromBuffer:o,readBufferFromBigInt:r,sha256:d,bigIntMod:c,modExp:u,generateRandomBytes:l}=n(89618),f=n(66842);function g(e,t){if(!s.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(t))throw new Error("Changing passwords unsupported")}function p(e){return s.concat([s.alloc(256-e.length),e])}function h(e){return r(e,256,!1)}function m(e,t){const n=t.subtract(e);return!(n.lesser(a(0))||n.bitLength()<1984||e.bitLength()<1984||Math.floor((e.bitLength()+7)/8)>256)}function _(e,t){const n=Math.min(e.length,t.length);for(let s=0;s{for(;;){const e=l(256),t=o(e,!1),n=u(a(b),t,f);if(m(n,f)){const e=h(n),i=o(await d(s.concat([e,I])),!1);if(i.greater(a(0)))return[t,e,i]}}})(),U=c(w.subtract(M),f);if(!m(U,f))throw new Error("bad gB");const B=E.multiply(v),D=k.add(B),T=u(U,D,f),[x,V,N,F,q]=await Promise.all([d(h(T)),d(A),d(S),d(n.salt1),d(n.salt2)]),L=await d(s.concat([_(V,N),F,q,R,I,x]));return new i.InputCheckPasswordSRP({srpId:e.srpId,A:s.from(R),M1:L})},computeDigest:async function(e,t){try{g(e.p,e.g)}catch(e){throw new Error("bad p/g in password")}return h(u(a(e.g),o(await y(e,t),!1),o(e.p,!1)))}}},48960:(e,t,n)=>{var s=n(48764).Buffer;const{constructors:a}=n(57404),i=s.from("ffd8ffe000104a46494600010100000100010000ffdb004300281c1e231e19282321232d2b28303c64413c37373c7b585d4964918099968f808c8aa0b4e6c3a0aadaad8a8cc8ffcbdaeef5ffffff9bc1fffffffaffe6fdfff8ffdb0043012b2d2d3c353c76414176f8a58ca5f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8ffc00011080000000003012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00","hex"),o=s.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){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];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 a.User){if(t.isSelf&&n)return new a.InputPeerSelf;if(void 0===t.accessHash&&s)throw new Error("User without accessHash or min info cannot be input");return new a.InputPeerUser({userId:t.id,accessHash:t.accessHash})}if(t instanceof a.Chat||t instanceof a.ChatEmpty||t instanceof a.ChatForbidden)return new a.InputPeerChat({chatId:t.id});if(t instanceof a.Channel){if(void 0===t.accessHash&&s)throw new TypeError("Channel without accessHash or min info cannot be input");return new a.InputPeerChannel({channelId:t.id,accessHash:t.accessHash})}return t instanceof a.ChannelForbidden?new a.InputPeerChannel({channelId:t.id,accessHash:t.accessHash}):t instanceof a.InputUser?new a.InputPeerUser({userId:t.userId,accessHash:t.accessHash}):t instanceof a.InputChannel?new a.InputPeerChannel({channelId:t.channelId,accessHash:t.accessHash}):t instanceof a.UserEmpty?new a.InputPeerEmpty:t instanceof a.UserFull?e(t.user):t instanceof a.ChatFull?new a.InputPeerChat({chatId:t.id}):t instanceof a.PeerChat?new a.InputPeerChat(t.chatId):void r(t,"InputPeer")},getDisplayName:function(e){return e instanceof a.User?e.lastName&&e.firstName?`${e.firstName} ${e.lastName}`:e.firstName?e.firstName:e.lastName?e.lastName:"":e instanceof a.Chat||e instanceof a.Channel?e.title:""},getDownloadPartSize:function(e){if(e<=104857600)return 128;if(e<=786432e3)return 256;if(e<=2097152e3)return 512;if(e<=4194304e3)return 1024;throw new Error("File size too large")},getUploadPartSize:function(e){if(e<=104857600)return 128;if(e<=786432e3)return 256;if(e<=2097152e3)return 512;if(e<=4194304e3)return 512;throw new Error("File size too large")},strippedPhotoToJpg:function(e){if(e.length<3||1!==e[0])return e;const t=s.from(i);return t[164]=e[1],t[166]=e[2],s.concat([t,e.slice(3),o])},getDC:function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];switch(e){case 1:return{id:1,ipAddress:`zws1${t?"-1":""}.web.telegram.org`,port:443};case 2:return{id:2,ipAddress:`zws2${t?"-1":""}.web.telegram.org`,port:443};case 3:return{id:3,ipAddress:`zws3${t?"-1":""}.web.telegram.org`,port:443};case 4:return{id:4,ipAddress:`zws4${t?"-1":""}.web.telegram.org`,port:443};case 5:return{id:5,ipAddress:`zws5${t?"-1":""}.web.telegram.org`,port:443};default:throw new Error(`Cannot find the DC with the ID of ${e}`)}}}},61472:e=>{e.exports="0.0.2"},70243:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getTmpPassword:()=>l,updateTwoFaSettings:()=>u});var s=n(77150),a=n.n(s),i=n(89618),o=n(59674),r=n(87873),d=n.n(r),c=n(48764).Buffer;async function u(e,t){let{isCheckPassword:n,currentPassword:s,newPassword:r,hint:u="",email:l,emailCodeCallback:f,onEmailCodeError:g}=t;if(!r&&!s)throw new Error("Neither `currentPassword` nor `newPassword` is present");if(l&&(!f||!g))throw new Error("`email` present without `emailCodeCallback` and `onEmailCodeError`");const p=await e.invoke(new(a().account.GetPassword));p.newAlgo instanceof a().PasswordKdfAlgoUnknown||(p.newAlgo.salt1=c.concat([p.newAlgo.salt1,(0,i.generateRandomBytes)(32)])),!p.hasPassword&&s&&(s=void 0);const h=s?await(0,o.computeCheck)(p,s):new(a().InputCheckPasswordEmpty);if(n)await e.invoke(new(a().auth.CheckPassword)({password:h}));else try{await e.invoke(new(a().account.UpdatePasswordSettings)({password:h,newSettings:new(a().account.PasswordInputSettings)({newAlgo:p.newAlgo,newPasswordHash:r?await(0,o.computeDigest)(p.newAlgo,r):c.alloc(0),hint:u,email:l,newSecureSettings:void 0})}))}catch(t){if(!(t instanceof d().EmailUnconfirmedError))throw t;for(;;)try{const n=await f(t.codeLength);if(!n)throw new Error("Code is empty");await e.invoke(new(a().account.ConfirmPasswordEmail)({code:n}));break}catch(e){g(e)}}}async function l(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60;const s=await e.invoke(new(a().account.GetPassword));if(!s)return;const i=await(0,o.computeCheck)(s,t);try{return await e.invoke(new(a().account.GetTmpPassword)({password:i,period:n}))}catch(e){if("PASSWORD_HASH_INVALID"===e.message)return{error:e.message};throw e}}},78742:(e,t,n)=>{var s=n(48764).Buffer;const a=n(67435),i=n(96748),{sleep:o}=n(89618),r=n(87873),d=n(33995),c=n(89618),u=n(48960),l=n(59270),{LAYER:f}=n(70845),{constructors:g,requests:p}=n(57404),{ConnectionTCPObfuscated:h,MTProtoSender:m,UpdateConnectionState:_}=n(18415),{authFlow:y,checkAuthorization:b}=n(21545),{downloadFile:w}=n(52288),{uploadFile:v}=n(74766),{updateTwoFaSettings:A,getTmpPassword:S}=n(70243),I=131072,P=["u","v","w","y","d","x","c","m","b","a","s","f"];class C{constructor(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:C.DEFAULT_OPTIONS;if(!t||!n)throw Error('Your API ID or Hash are invalid. Please read "Requirements" on README.md');const o={...C.DEFAULT_OPTIONS,...s};if(this.apiId=t,this.apiHash=n,this.defaultDcId=o.dcId||2,this._useIPV6=o.useIPV6,"string"==typeof o.baseLogger?this._log=new i:this._log=o.baseLogger,"string"!=typeof e&&e){if(!(e instanceof l))throw new Error("The given session must be str or a session instance")}else try{throw new Error("not implemented")}catch(t){e=new d}this.floodSleepLimit=o.floodSleepLimit,this._eventBuilders=[],this._phoneCodeHash={},this.session=e,this.apiId=parseInt(t,10),this.apiHash=n,this._requestRetries=o.requestRetries,this._connectionRetries=o.connectionRetries,this._retryDelay=o.retryDelay||0,o.proxy&&this._log.warn("proxies are not supported"),this._proxy=o.proxy,this._timeout=o.timeout,this._autoReconnect=o.autoReconnect,this._connection=o.connection,this._floodWaitedRequests={},this._initWith=e=>new p.InvokeWithLayer({layer:f,query:new p.InitConnection({apiId:this.apiId,deviceModel:o.deviceModel||a.type().toString()||"Unknown",systemVersion:o.systemVersion||a.release().toString()||"1.0",appVersion:o.appVersion||"1.0",langCode:o.langCode,langPack:"",systemLangCode:o.systemLangCode,query:e,proxy:void 0})}),this._args=o,this._config=void 0,this.phoneCodeHashes=[],this._exportedSenderPromises={},this._waitingForAuthKey={},this._exportedSenderReleaseTimeouts={},this._additionalDcsDisabled=o.additionalDcsDisabled,this._loopStarted=!1,this._isSwitchingDc=!1,this._destroyed=!1}async connect(){await this._initSession(),void 0===this._sender&&(this._sender=new m(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})),this._sender.userDisconnected=!1,this._sender._user_connected=!1,this._sender.isReconnecting=!1,this._sender._disconnected=!0;const e=new this._connection(this.session.serverAddress,this.session.port,this.session.dcId,this._log,this._args.testServers);await this._sender.connect(e)?(this.session.setAuthKey(this._sender.authKey),await this._sender.send(this._initWith(new p.help.GetConfig({}))),this._loopStarted||(this._updateLoop(),this._loopStarted=!0),this._isSwitchingDc=!1):this._loopStarted||(this._updateLoop(),this._loopStarted=!0)}async _initSession(){if(await this.session.load(),!this.session.serverAddress||this.session.serverAddress.includes(":")!==this._useIPV6){const e=u.getDC(this.defaultDcId);this.session.setDC(this.defaultDcId,e.ipAddress,this._args.useWSS?443:80)}}async _updateLoop(){let e;for(;!this._destroyed;)if(await c.sleep(3e3),this._sender.isReconnecting||this._isSwitchingDc)e=void 0;else{try{const t=()=>this._sender.send(new p.PingDelayDisconnect({pingId:c.getRandomInt(Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),disconnectDelay:6e4})),n=Date.now(),s=e?n-e:void 0;if(!s||s<5e3)await U((()=>E(t,5e3)),3,100);else{let e=setTimeout((()=>{this._handleUpdate(new _(_.disconnected)),e=void 0}),1e3);await E(t,3e3),e&&(clearTimeout(e),e=void 0),this._handleUpdate(new _(_.connected))}e=Date.now()}catch(t){if(console.warn(t),e=void 0,this._sender.isReconnecting||this._isSwitchingDc)continue;await this.disconnect(),await this.connect()}if((new Date).getTime()-this._lastRequest>18e5){try{await this.invoke(new p.updates.GetState)}catch(e){}e=void 0}}await this.disconnect()}async disconnect(){this._sender&&await this._sender.disconnect(),await Promise.all(Object.values(this._exportedSenderPromises).map((e=>Object.values(e).map((e=>e&&e.then((e=>{if(e)return e.disconnect()})))))).flat()),this._exportedSenderPromises={},this._waitingForAuthKey={}}async destroy(){this._destroyed=!0;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),this._isSwitchingDc=!0,await this.disconnect(),this.connect()}_authKeyCallback(e,t){this.session.setAuthKey(e,t)}async _cleanupExportedSender(e,t){this.session.dcId!==e&&this.session.setAuthKey(void 0,e);const n=await this._exportedSenderPromises[e][t];delete this._exportedSenderPromises[e][t],await n.disconnect()}async _connectSender(e,t){let n,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=Boolean(e.authKey.getKey());if(!a)if(this._waitingForAuthKey[t]){await this._waitingForAuthKey[t];const n=this.session.getAuthKey(t);await e.authKey.setKey(n.getKey()),a=Boolean(e.authKey.getKey())}else this._waitingForAuthKey[t]=new Promise((e=>{n=e}));const i=u.getDC(t,a);for(;;)try{if(await e.connect(new this._connection(i.ipAddress,i.port,t,this._log,this._args.testServers,!!a&&s)),this.session.dcId!==t&&!e._authenticated){this._log.info(`Exporting authorization for data center ${i.ipAddress}`);const n=await this.invoke(new p.auth.ExportAuthorization({dcId:t})),s=this._initWith(new p.auth.ImportAuthorization({id:n.id,bytes:n.bytes}));await e.send(s),e._authenticated=!0}return e.dcId=t,e.userDisconnected=!1,n&&(n(),delete this._waitingForAuthKey[t]),e}catch(t){console.error(t),await c.sleep(1e3),await e.disconnect()}}async _borrowExportedSender(e,t,n,s,a){if(this._additionalDcsDisabled)return;const i=s||0;let o;this._exportedSenderPromises[e]||(this._exportedSenderPromises[e]={}),this._exportedSenderPromises[e][i]&&!t||(this._exportedSenderPromises[e][i]=this._connectSender(n||this._createExportedSender(e,i),e,a));try{if(o=await this._exportedSenderPromises[e][i],!o.isConnected())return o.isConnecting?(await c.sleep(1e3),this._borrowExportedSender(e,!1,o,i,a)):this._borrowExportedSender(e,!0,o,i,a)}catch(t){return console.error(t),this._borrowExportedSender(e,!0,void 0,i,a)}return this._exportedSenderReleaseTimeouts[e]||(this._exportedSenderReleaseTimeouts[e]={}),this._exportedSenderReleaseTimeouts[e][i]&&(clearTimeout(this._exportedSenderReleaseTimeouts[e][i]),this._exportedSenderReleaseTimeouts[e][i]=void 0),this._exportedSenderReleaseTimeouts[e][i]=setTimeout((()=>{this._exportedSenderReleaseTimeouts[e][i]=void 0,o.disconnect()}),3e4),o}_createExportedSender(e,t){return new m(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._cleanupExportedSender(e,t)})}getSender(e,t,n){return e?this._borrowExportedSender(e,void 0,void 0,t,n):Promise.resolve(this._sender)}downloadFile(e){return w(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}downloadMedia(e,t){let n;if(n=e instanceof g.Message?e.media:e,"string"==typeof n)throw new Error("not implemented");return n instanceof g.MessageMediaWebPage&&n.webpage instanceof g.WebPage&&(n=n.webpage.document||n.webpage.photo),n instanceof g.MessageMediaPhoto||n instanceof g.Photo?this._downloadPhoto(n,t):n instanceof g.MessageMediaDocument||n instanceof g.Document?this._downloadDocument(n,t):n instanceof g.MessageMediaContact?this._downloadContact(n,t):n instanceof g.WebDocument||n instanceof g.WebDocumentNoProxy?this._downloadWebDocument(n,t):void 0}downloadProfilePhoto(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=t?"x":"m";let s,a,i;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 g.UserProfilePhoto||s instanceof g.ChatPhoto)return a=s.dcId,i=new g.InputPeerPhotoFileLocation({peer:u.getInputPeer(e),photoId:s.photoId,big:t}),this.downloadFile(i,{dcId:a})}downloadStickerSetThumb(e){var t;if(!(null!==(t=e.thumbs)&&void 0!==t&&t.length||e.thumbDocumentId))return;const{thumbVersion:n}=e;return e.thumbDocumentId?this.invoke(new g.messages.GetCustomEmojiDocuments({documentId:[e.thumbDocumentId]})).then((e=>{const t=e[0];return this.downloadFile(new g.InputDocumentFileLocation({id:t.id,accessHash:t.accessHash,fileReference:t.fileReference,thumbSize:""}),{fileSize:t.size.toJSNumber(),dcId:t.dcId})})):this.downloadFile(new g.InputStickerSetThumb({stickerset:new g.InputStickerSetID({id:e.id,accessHash:e.accessHash}),thumbVersion:n}),{dcId:e.thumbDcId})}_pickFileSize(e,t){if(!t||!e||!e.length)return;let n;for(let s=P.indexOf(t);se.type===P[s])),n)return n}_downloadCachedPhotoSize(e){let t;return t=e instanceof g.PhotoStrippedSize?u.strippedPhotoToJpg(e.bytes):e.bytes,t}_downloadPhoto(e,t){if(e instanceof g.MessageMediaPhoto&&(e=e.photo),!(e instanceof g.Photo))return;const n="u"===t.sizeType||"v"===t.sizeType,s=this._pickFileSize(n?[...e.videoSizes,...e.sizes]:e.sizes,t.sizeType);return!s||s instanceof g.PhotoSizeEmpty?void 0:s instanceof g.PhotoCachedSize||s instanceof g.PhotoStrippedSize?this._downloadCachedPhotoSize(s):this.downloadFile(new g.InputPhotoFileLocation({id:e.id,accessHash:e.accessHash,fileReference:e.fileReference,thumbSize:s.type}),{dcId:e.dcId,fileSize:s.size||Math.max(...s.sizes||[]),progressCallback:t.progressCallback})}_downloadDocument(e,t){if(e instanceof g.MessageMediaDocument&&(e=e.document),!(e instanceof g.Document))return;let n;if(t.sizeType){if(n=e.thumbs?this._pickFileSize([...e.videoThumbs||[],...e.thumbs],t.sizeType):void 0,!n&&e.mimeType.startsWith("video/"))return;if(n&&(n instanceof g.PhotoCachedSize||n instanceof g.PhotoStrippedSize))return this._downloadCachedPhotoSize(n)}return this.downloadFile(new g.InputDocumentFileLocation({id:e.id,accessHash:e.accessHash,fileReference:e.fileReference,thumbSize:n?n.type:""}),{fileSize:n?n.size:e.size.toJSNumber(),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){if(e.url&&!("accessHash"in e)){const t=await fetch(e.url).then((e=>e.arrayBuffer()));return s.from(t)}try{const t=[];let n=0;for(;;){const s=new p.upload.GetWebFile({location:new g.InputWebFileLocation({url:e.url,accessHash:e.accessHash}),offset:n,limit:I}),a=await this._borrowExportedSender(4),i=await a.send(s);if(n+=131072,!i.bytes.length)break;if(t.push(i.bytes),i.bytes.length0&&void 0!==arguments[0]?arguments[0]:{update:void 0,others:void 0,channelId:void 0,ptsDate:void 0};for(const[t,n]of this._eventBuilders){const s=t.build(e.update);s&&await n(s)}}isConnected(){return!(!this._sender||!this._sender.isConnected())}}var M,k,R;function E(e,t){let n=!1;return Promise.race([e(),c.sleep(t).then((()=>n?void 0:Promise.reject(new Error("TIMEOUT"))))]).finally((()=>{n=!0}))}async function U(e,t,n){for(let s=0;s{"use strict";n.r(t),n.d(t,{authFlow:()=>u,checkAuthorization:()=>f,signInUserWithPreferredMethod:()=>l});var s=n(77150),a=n.n(s),i=n(48960),o=n.n(i),r=n(89618),d=n(59674);const c="phoneNumber";async function u(e,t,n){let s;s="botAuthToken"in n?await async function(e,t,n){const{apiId:s,apiHash:i}=t,{botAuthToken:o}=n,{user:r}=await e.invoke(new(a().auth.ImportBotAuthorization)({apiId:s,apiHash:i,botAuthToken:o}));return r}(e,t,n):"webAuthToken"in n&&n.webAuthToken?await async function(e,t,n){try{const{apiId:s,apiHash:i}=t,o=await e.invoke(new(a().auth.ImportWebTokenAuthorization)({webAuthToken:n.webAuthToken,apiId:s,apiHash:i}));if(o instanceof a().auth.Authorization)return o.user;throw new Error("SIGN_UP_REQUIRED")}catch(s){return n.webAuthTokenFailed(),e._log.error(`Failed to login with web token: ${s}`),"SESSION_PASSWORD_NEEDED"===s.message?m(e,0,n):l(e,t,{...n,webAuthToken:void 0})}}(e,t,n):await l(e,t,n),e._log.info("Signed in successfully as",o().getDisplayName(s))}async function l(e,t,n){const{initialMethod:s=c}=n;return"phoneNumber"===s?g(e,t,n):p(e,t,n)}async function f(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{return await e.invoke(new(a().updates.GetState)),!0}catch(e){if("Disconnect"===e.message||t)throw e;return!1}}async function g(e,t,n){let s,i,o,r=!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 a=await h(e,t,s,n.forceSMS);if(i=a.phoneCodeHash,r=a.isCodeViaApp,"string"!=typeof i)throw new Error("Failed to retrieve phone code hash");break}catch(e){if("function"!=typeof n.phoneNumber)throw e;n.onError(e)}let d,c=!1;for(;;)try{try{o=await n.phoneCode(r)}catch(s){if("RESTART_AUTH"===s.message)return g(e,t,n)}if(!o)throw new Error("Code is empty");const u=await e.invoke(new(a().auth.SignIn)({phoneNumber:s,phoneCodeHash:i,phoneCode:o}));if(u instanceof a().auth.AuthorizationSignUpRequired){c=!0,d=u.termsOfService;break}return u.user}catch(t){if("SESSION_PASSWORD_NEEDED"===t.message)return m(e,0,n);n.onError(t)}if(c)for(;;)try{const[t,o]=await n.firstAndLastNames();if(!t)throw new Error("First name is required");const{user:r}=await e.invoke(new(a().auth.SignUp)({phoneNumber:s,phoneCodeHash:i,firstName:t,lastName:o}));return d&&await e.invoke(new(a().help.AcceptTermsOfService)({id:d.id})),r}catch(e){n.onError(e)}return n.onError(new Error("Auth failed")),g(e,t,n)}async function p(e,t,n){let s=!1;const i=(async()=>{for(;!s;){const t=await e.invoke(new(a().auth.ExportLoginToken)({apiId:Number("2496"),apiHash:"8da85b0d5bfe62527e5b244c209159c3",exceptIds:[]}));if(!(t instanceof a().auth.LoginToken))throw new Error("Unexpected");const{token:s,expires:i}=t;await Promise.race([n.qrCode({token:s,expires:i}),(0,r.sleep)(3e4)])}})(),o=new Promise((t=>{e.addEventHandler((e=>{e instanceof a().UpdateLoginToken&&t()}),{build:e=>e})}));try{await Promise.race([o,i])}catch(s){if("RESTART_AUTH"===s.message)return await g(e,t,n);throw s}finally{s=!0}try{const t=await e.invoke(new(a().auth.ExportLoginToken)({apiId:Number("2496"),apiHash:"8da85b0d5bfe62527e5b244c209159c3",exceptIds:[]}));if(t instanceof a().auth.LoginTokenSuccess&&t.authorization instanceof a().auth.Authorization)return t.authorization.user;if(t instanceof a().auth.LoginTokenMigrateTo){await e._switchDC(t.dcId);const n=await e.invoke(new(a().auth.ImportLoginToken)({token:t.token}));if(n instanceof a().auth.LoginTokenSuccess&&n.authorization instanceof a().auth.Authorization)return n.authorization.user}}catch(t){if("SESSION_PASSWORD_NEEDED"===t.message)return m(e,0,n);throw t}throw void 0}async function h(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{const{apiId:i,apiHash:o}=t,r=await e.invoke(new(a().auth.SendCode)({phoneNumber:n,apiId:i,apiHash:o,settings:new(a().CodeSettings)}));if(!s||r.type instanceof a().auth.SentCodeTypeSms)return{phoneCodeHash:r.phoneCodeHash,isCodeViaApp:r.type instanceof a().auth.SentCodeTypeApp};const d=await e.invoke(new(a().auth.ResendCode)({phoneNumber:n,phoneCodeHash:r.phoneCodeHash}));return{phoneCodeHash:d.phoneCodeHash,isCodeViaApp:d.type instanceof a().auth.SentCodeTypeApp}}catch(a){if("AUTH_RESTART"===a.message)return h(e,t,n,s);throw a}}async function m(e,t,n){for(;;)try{const t=await e.invoke(new(a().account.GetPassword)),s=await n.password(t.hint);if(!s)throw new Error("Password is empty");const i=await(0,d.computeCheck)(t,s),{user:o}=await e.invoke(new(a().auth.CheckPassword)({password:i}));return o}catch(e){n.onError(e)}}},52288:(e,t,n)=>{"use strict";n.r(t),n.d(t,{downloadFile:()=>m});var s=n(24736),a=n.n(s),i=n(77150),o=n.n(i),r=n(89618),d=n(48960),c=n(87873),u=n.n(c),l=n(48764).Buffer;function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const g=1048576;class p{constructor(e){this.maxWorkers=e,f(this,"deferreds",[]),f(this,"activeWorkers",0)}requestWorker(){if(this.activeWorkers===this.maxWorkers){const e=(0,r.createDeferred)();return this.deferreds.push(e),e.promise}return this.activeWorkers++,Promise.resolve()}releaseWorker(){this.deferreds.length&&this.activeWorkers===this.maxWorkers?this.deferreds.shift().resolve():this.activeWorkers--}}class h{constructor(e){f(this,"type",void 0),f(this,"size",void 0),f(this,"buffer",void 0),f(this,"largeFile",void 0),f(this,"largeFileAccessHandle",void 0),this.size=e,this.type=e&&e>self.maxBufferSize?"opfs":"memory"}async init(){if("opfs"===this.type){var e;if(null===(e=FileSystemFileHandle)||void 0===e||!e.prototype.createSyncAccessHandle)throw new Error("`createSyncAccessHandle` is not available. Cannot download files larger than 2GB.");const t=await navigator.storage.getDirectory(),n=await t.getDirectoryHandle("downloads",{create:!0});this.largeFile=await n.getFileHandle(Math.random().toString(),{create:!0}),this.largeFileAccessHandle=await this.largeFile.createSyncAccessHandle()}else this.buffer=this.size?l.alloc(this.size):l.alloc(0)}write(e,t){if("opfs"===this.type)this.largeFileAccessHandle.write(e,{at:t});else if(this.size)for(let n=0;n=this.buffer.length)return;this.buffer.writeUInt8(e[n],t+n)}else this.buffer=l.concat([this.buffer,e])}getData(){return"opfs"===this.type?this.largeFile.getFile():Promise.resolve(this.buffer)}}async function m(e,t,n){const{dcId:s}=n;for(let a=0;a<5;a++)try{return await y(e,t,n)}catch(t){if(4===a||!t.message.startsWith("SESSION_REVOKED"))throw t;await e._cleanupExportedSender(s)}}const _=Array(6).fill(void 0).map((()=>new p(10)));async function y(e,t,n){let{partSizeKb:s,end:i}=n;const{fileSize:c}=n,l=Boolean(e.isPremium),{dcId:f,progressCallback:p,start:m=0}=n;i=i&&i=10485760&&!w;let A;if(y%4096!=0)throw new Error("The part size must be evenly divisible by 4096");e._log.info(`Downloading file in chunks of ${y} bytes`);const S=new h(i-m+1),I=[];let P=m;const C=_.map((e=>e.activeWorkers));let M=C.indexOf(Math.min(...C)),k=!1,R=0;for(p&&p(R),await S.init();;){let n=y,s=!1;Math.floor(P/g)!==Math.floor((P+n-1)/g)&&(n=g-P%g,s=!0);const d=v?M%(l?6:3):0;if(await _[d].requestWorker(),A&&await A.promise,w&&(A=(0,r.createDeferred)()),k){_[d].releaseWorker();break}if(I.push((async c=>{for(;;){let g;try{g=await e.getSender(f,d,l);const u=await Promise.race([g.send(new(o().upload.GetFile)({location:t,offset:a()(c),limit:n,precise:s||void 0})),(0,r.sleep)(6e4).then((()=>f===e.session.dcId?Promise.reject(new Error("USER_CANCELED")):Promise.reject(new Error("SESSION_REVOKED"))))]);if(p){if(p.isCanceled)throw new Error("USER_CANCELED");R+=1/b,p(R)}return!i&&u.bytes.lengthi)break}return await Promise.all(I),S.getData()}},74766:(e,t,n)=>{"use strict";n.r(t),n.d(t,{uploadFile:()=>u});var s=n(77150),a=n.n(s),i=n(89618),o=n(48960),r=n(87873),d=n.n(r),c=n(48764).Buffer;async function u(e,t){const{file:n,onProgress:s}=t;let{workers:r}=t;const{name:u,size:l}=n,f=(0,i.readBigIntFromBuffer)((0,i.generateRandomBytes)(8),!0,!0),g=l>10485760,p=1024*(0,o.getUploadPartSize)(l),h=Math.floor((l+p-1)/p);await e.getSender(e.session.dcId),r&&l||(r=1),r>=h&&(r=h);let m=0;s&&s(m);for(let t=0;th&&(u=h);for(let r=t;r{for(;;){let o;try{o=await e.getSender(e.session.dcId);const s=await n.arrayBuffer();await o.send(g?new(a().upload.SaveBigFilePart)({fileId:f,filePart:t,fileTotalParts:h,bytes:c.from(s)}):new(a().upload.SaveFilePart)({fileId:f,filePart:t,bytes:c.from(s)}))}catch(e){if(o&&!o.isConnected()){await(0,i.sleep)(1e3);continue}if(e instanceof d().FloodWaitError){await(0,i.sleep)(1e3*e.seconds);continue}throw e}if(s){if(s.isCanceled)throw new Error("USER_CANCELED");m+=1/h,s(m)}break}})(r,t))}await Promise.all(o)}return g?new(a().InputFileBig)({id:f,parts:h,name:u}):new(a().InputFile)({id:f,parts:h,name:u,md5Checksum:""})}},13302:(e,t,n)=>{var s=n(48764).Buffer;const{sha1:a,toSignedLittleBuffer:i,readBufferFromBigInt:o,readBigIntFromBuffer:r}=n(89618),d=n(35544),{sleep:c}=n(89618);class u{constructor(e,t){if(!t||!e)return;this._key=e,this._hash=t;const n=new d(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 a(this._key);const t=new d(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,t){e=i(e,32);const n=s.alloc(1);n.writeUInt8(t,0);const d=s.concat([e,s.concat([n,o(this.auxHash,8,!0)])]),c=(await a(d)).slice(4,20);return r(c,!0,!0)}equals(e){return e instanceof this.constructor&&this._key&&e.getKey()&&e.getKey().equals(this._key)}}e.exports=u},55830:(e,t,n)=>{var s=n(48764).Buffer;const a=n(66842);e.exports=class{constructor(e,t){if(!s.isBuffer(e)||!s.isBuffer(t)||16!==t.length)throw new Error("Key and iv need to be a buffer");this.cipher=a.createCipheriv("AES-256-CTR",e,t)}encrypt(e){return s.from(this.cipher.update(e))}}},89636:(e,t,n)=>{const s=n(24736),{modExp:a}=n(89618);class i{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)),o=s.randBetween(s(1),e.minus(1));let r,d=s.one,c=s.one,u=s.one,l=s.zero,f=s.zero;for(;d.eq(s.one);){l=t;for(let i=0;s(i).lesser(c);i++)t=a(t,s(2),e).add(n).remainder(e);for(r=s.zero;r.lesser(c)&&d.eq(s.one);){f=t;const g=s.min(o,c.minus(r));for(let i=0;s(i).lesser(g);i++)t=a(t,s(2),e).add(n).remainder(e),u=u.multiply(l.minus(t).abs()).remainder(e);d=i.gcd(u,e),r=r.add(o)}c=c.multiply(2)}if(d.eq(e))for(;f=a(f,s(2),e).add(n).remainder(e),d=i.gcd(l.minus(f).abs(),e),!d.greater(1););const g=d;return u=e.divide(d),g{var s=n(48764).Buffer;const{IGE:a}=n(28136),i=n(89618);e.exports=class{constructor(e,t){this.ige=new a(e,t)}decryptIge(e){return i.convertToLittle(this.ige.decrypt(e))}encryptIge(e){const t=e.length%16;return t&&(e=s.concat([e,i.generateRandomBytes(16-t)])),i.convertToLittle(this.ige.encrypt(e))}}},74121:(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++]=a>>16&255,t[n++]=a>>8&255,t[n++]=255&a}return t.buffer}function a(e){return e.buffer}function i(e){const t=new Uint8Array(e),n=new Uint32Array(t.length/4);for(let e=0;ec,ab2iBig:()=>o,ab2iLow:()=>i,i2ab:()=>d,i2abBig:()=>a,i2abLow:()=>s,isBigEndian:()=>r});const r=1===new Uint8Array(new Uint32Array([16909060]))[0],d=r?a:s,c=r?o:i},66842:(e,t,n)=>{var s=n(48764).Buffer;const a=n(28136).default,{i2ab:i,ab2i:o}=n(74121),{getWords:r}=n(77760);class d{constructor(e){this.setBytes(e)}setBytes(e){e=s.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 d||(t=new d(t)),this._counter=t,this._remainingCounter=void 0,this._remainingCounterIndex=16,this._aes=new a(r(e))}update(e){return this.encrypt(e)}encrypt(e){const t=s.from(e);for(let e=0;e{"use strict";function s(e,t){return e.charCodeAt(t)<<24^e.charCodeAt(t+1)<<16^e.charCodeAt(t+2)<<8^e.charCodeAt(t+3)}function a(e){if(e instanceof Uint32Array)return e;if("string"==typeof e){if(e.length%4!=0)for(let t=e.length%4;t<=4;t++)e+="\0x00";const t=new Uint32Array(e.length/4);for(let n=0;n2&&void 0!==arguments[2]?arguments[2]:e;for(let s=0;sa,s2i:()=>s,xor:()=>i})},48187:e=>{class t extends Error{constructor(){super("The read operation was cancelled.")}}class n 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 s 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 i extends Error{constructor(){for(var e=arguments.length,t=new Array(e),n=0;n{function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class n extends Error{constructor(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;super("RPCError {0}: {1}{2}".replace("{0}",s).replace("{1}",e).replace("{2}",n._fmtRequest(t))),this.code=s,this.message=e}static _fmtRequest(e){return e?` (caused by ${e.className})`:""}}e.exports={RPCError:n,InvalidDCError:class extends n{constructor(e,t,n){super(t,e,n),this.code=n||303,this.message=t||"ERROR_SEE_OTHER"}},BadRequestError:class extends n{constructor(){super(...arguments),t(this,"code",400),t(this,"message","BAD_REQUEST")}},UnauthorizedError:class extends n{constructor(){super(...arguments),t(this,"code",401),t(this,"message","UNAUTHORIZED")}},ForbiddenError:class extends n{constructor(){super(...arguments),t(this,"code",403),t(this,"message","FORBIDDEN")}},NotFoundError:class extends n{constructor(){super(...arguments),t(this,"code",404),t(this,"message","NOT_FOUND")}},AuthKeyError:class extends n{constructor(){super(...arguments),t(this,"code",406),t(this,"message","AUTH_KEY")}},FloodError:class extends n{constructor(){super(...arguments),t(this,"code",420),t(this,"message","FLOOD")}},ServerError:class extends n{constructor(){super(...arguments),t(this,"code",500),t(this,"message","INTERNAL")}},TimedOutError:class extends n{constructor(){super(...arguments),t(this,"code",503),t(this,"message","Timeout")}}}},65651:(e,t,n)=>{const{RPCError:s,InvalidDCError:a,FloodError:i,BadRequestError:o}=n(86952);class r extends a{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 d extends a{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 c extends i{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 u extends i{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 i{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 i{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 g extends a{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 p extends a{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 o{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+)/,g],[/FLOOD_TEST_PHONE_WAIT_(\d+)/,f],[/FLOOD_WAIT_(\d+)/,u],[/MSG_WAIT_(.*)/,l],[/PHONE_MIGRATE_(\d+)/,d],[/SLOWMODE_WAIT_(\d+)/,c],[/USER_MIGRATE_(\d+)/,r],[/NETWORK_MIGRATE_(\d+)/,p],[/EMAIL_UNCONFIRMED_(\d+)/,h]];e.exports={rpcErrorRe:m,FileMigrateError:g,FloodTestPhoneWaitError:f,FloodWaitError:u,PhoneMigrateError:d,SlowModeWaitError:c,UserMigrateError:r,NetworkMigrateError:p,MsgWaitError:l,EmailUnconfirmedError:h}},87873:(e,t,n)=>{const{RPCError:s}=n(86952),{rpcErrorRe:a}=n(65651),i=n(48187),o=n(86952),r=n(65651);e.exports={RPCMessageToError:function(e,t){for(const[n,s]of a){const a=e.errorMessage.match(n);if(a)return new s({request:t,capture:2===a.length?parseInt(a[1],10):void 0})}return new s(e.errorMessage,t)},...i,...o,...r}},26316:()=>{},43903:(e,t,n)=>{const{EventBuilder:s}=n(80663);e.exports=class extends s{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{types:void 0,func:void 0};super(),e.types?this.types=e.types:this.types=!0}build(e){return e}}},80663:e=>{e.exports={EventBuilder:class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{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){}}}},33182:(e,t,n)=>{const s=n(26316),a=n(43903);class i extends Error{}e.exports={NewMessage:s,StopPropagation:i,Raw:a}},16151:e=>{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}}},35544:(e,t,n)=>{const{TypeNotFoundError:s}=n(48187),{coreObjects:a}=n(92058),{tlobjects:i}=n(70845),{readBigIntFromBuffer:o}=n(89618);e.exports=class{constructor(e){this.stream=e,this._last=void 0,this.offset=0}readByte(){return this.read(1)[0]}readInt(){let e;return e=arguments.length>0&&void 0!==arguments[0]&&!arguments[0]?this.stream.readUInt32LE(this.offset):this.stream.readInt32LE(this.offset),this.offset+=4,e}readLong(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.readLargeInt(64,e)}readFloat(){return this.read(4).readFloatLE(0)}readDouble(){return this.read(8).readDoubleLE(0)}readLargeInt(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=this.read(Math.floor(e/8));return o(n,!0,t)}read(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-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=i[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;n{var s=n(48764).Buffer;e.exports=class{constructor(e){this._stream=e}write(e){this._stream=s.concat([this._stream,e])}getValue(){return this._stream}}},96748:e=>{let t;class n{constructor(e){t||(t=e||"debug"),this.isBrowser="undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs,this.isBrowser?this.colors={start:"%c",warn:"color : #ff00ff",info:"color : #ffff00",debug:"color : #00ffff",error:"color : #ff0000",end:""}:this.colors={start:"[2m",warn:"[35m",info:"[33m",debug:"[36m",error:"[31m",end:"[0m"},this.messageFormat="[%t] [%l] - [%m]"}static setLevel(e){t=e}canSend(e){return n.levels.indexOf(t)>=n.levels.indexOf(e)}warn(e){"debug"===t&&console.error((new Error).stack),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){"debug"===t&&console.error((new Error).stack),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,n,s){t&&this.canSend(e)&&(this.isBrowser?console.log(this.colors.start+this.format(n,e),s):console.log(s+this.format(n,e)+this.colors.end))}}var s,a,i;i=["error","warn","info","debug"],(a="levels")in(s=n)?Object.defineProperty(s,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):s[a]=i,e.exports=n},36411:(e,t,n)=>{var s=n(48764).Buffer;const a=n(63254),i=n(40355),o=n(96472),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&&1658238041!==e.request.CONSTRUCTOR_ID&&(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,t=new o(s.alloc(0));const n=[];let r=0;for(;this._queue.length&&n.length<=a.MAXIMUM_LENGTH;){const e=this._queue.shift();if(r+=e.data.length+i.SIZE_OVERHEAD,r<=a.MAXIMUM_SIZE){let s;e.after&&(s=e.after.msgId),e.msgId=await this._state.writeDataAsMessage(t,e.data,"request"===e.request.classType,s),this._log.debug(`Assigned msgId = ${e.msgId} to ${e.request.className||e.request.constructor.name}`),n.push(e)}else{if(n.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"),r=0}}if(n.length){if(n.length>1){const i=s.alloc(8);i.writeUInt32LE(a.CONSTRUCTOR_ID,0),i.writeInt32LE(n.length,4),e=s.concat([i,t.getValue()]),t=new o(s.alloc(0));const r=await this._state.writeDataAsMessage(t,e,!1);for(const e of n)e.containerId=r}return e=t.getValue(),{batch:n,data:e}}}rejectAll(){this._pendingStates.forEach((e=>{e.reject(new Error("Disconnect"))}))}}},7214:(e,t,n)=>{var s=n(48764).Buffer;const{Mutex:a}=n(48125),i=new a,o=n(45840).w3cwebsocket,r=new Error("WebSocket was closed");e.exports=class{constructor(e){this.client=void 0,this.closed=!0,this.disconnectedCallback=e}async readExactly(e){let t=s.alloc(0);for(;;){const n=await this.read(e);if(t=s.concat([t,n]),!(e-=n.length))return t}}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=s.alloc(0),this.canRead=new Promise((e=>{this.resolveRead=e})),e}getWebSocketLink(e,t,n,s){return 443===t?`wss://${e}:${t}/apiws${n?"_test":""}${s?"_premium":""}`:`ws://${e}:${t}/apiws${n?"_test":""}${s?"_premium":""}`}connect(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return this.stream=s.alloc(0),this.canRead=new Promise((e=>{this.resolveRead=e})),this.closed=!1,this.website=this.getWebSocketLink(t,e,n,a),this.client=new o(this.website,"binary"),new Promise(((e,n)=>{this.client.onopen=()=>{this.receive(),e(this)},this.client.onerror=e=>{console.error("WebSocket error",e),n(e)},this.client.onclose=e=>{const{code:n,reason:s,wasClean:a}=e;1e3!==n&&console.error(`Socket ${t} closed. Code: ${n}, reason: ${s}, was clean: ${a}`),this.resolveRead(!1),this.closed=!0,this.disconnectedCallback&&this.disconnectedCallback()},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=>{await i.runExclusive((async()=>{const t=e.data instanceof ArrayBuffer?s.from(e.data):s.from(await new Response(e.data).arrayBuffer());this.stream=s.concat([this.stream,t]),this.resolveRead(!0)}))}}}},89832:(e,t,n)=>{const s=n(96748),a=n(96472),i=n(35544),o=n(7214),r=n(36411),d=n(16151);e.exports={BinaryWriter:a,BinaryReader:i,MessagePacker:r,AsyncQueue:d,Logger:s,PromisedWebSockets:o}},13522:(e,t,n)=>{const s=n(77150),a=n(78742),i=n(18415),o=n(57404),r=n(61472),d=n(33182),c=n(48960),u=n(87873),l=n(15886),f=n(89832),g=n(89618);e.exports={Api:s,TelegramClient:a,sessions:l,connection:i,extensions:f,tl:o,version:r,events:d,utils:c,errors:u,helpers:g}},59870:(e,t,n)=>{"use strict";n.r(t),n.d(t,{doAuthentication:()=>m});var s=n(77150),a=n.n(s),i=n(87873),o=n(24736),r=n.n(o);n(89618),n(48764).Buffer;const d=[{fingerprint:r()("-3414540481677951611"),n:r()("29379598170669337022986177149456128565388431120058863768162556424047512191330847455146576344487764408661701890505066208632169112269581063774293102577308490531282748465986139880977280302242772832972539403531316010870401287642763009136156734339538042419388722777357134487746169093539093850251243897188928735903389451772730245253062963384108812842079887538976360465290946139638691491496062099570836476454855996319192747663615955633778034897140982517446405334423701359108810182097749467210509584293428076654573384828809574217079944388301239431309115013843331317877374435868468779972014486325557807783825502498215169806323"),e:65537},{fingerprint:r()("-5595554452916591101"),n:r()("25342889448840415564971689590713473206898847759084779052582026594546022463853940585885215951168491965708222649399180603818074200620463776135424884632162512403163793083921641631564740959529419359595852941166848940585952337613333022396096584117954892216031229237302943701877588456738335398602461675225081791820393153757504952636234951323237820036543581047826906120927972487366805292115792231423684261262330394324750785450942589751755390156647751460719351439969059949569615302809050721500330239005077889855323917509948255722081644689442127297605422579707142646660768825302832201908302295573257427896031830742328565032949"),e:65537}].reduce(((e,t)=>{let{fingerprint:n,...s}=t;return e.set(n.toString(),s),e}),new Map);var c=n(48764).Buffer;const u=n(24736),l=n(32608),f=n(13302),g=n(89636),p=n(89618),h=n(35544);async function m(e,t){let n=p.generateRandomBytes(16);const s=p.readBigIntFromBuffer(n,!1,!0),o=await e.send(new(a().ReqPqMulti)({nonce:s}));if(t.debug("Starting authKey generation step 1"),!(o instanceof a().ResPQ))throw new i.SecurityError(`Step 1 answer was ${o}`);if(o.nonce.neq(s))throw new i.SecurityError("Step 1 invalid nonce from server");const r=p.readBigIntFromBuffer(o.pq,!1,!0);t.debug("Finished authKey generation step 1");const{p:m,q:_}=g.factorize(r),y=p.getByteArray(m),b=p.getByteArray(_);n=p.generateRandomBytes(32);const w=p.readBigIntFromBuffer(n,!0,!0),v=new(a().PQInnerData)({pq:p.getByteArray(r),p:y,q:b,nonce:o.nonce,serverNonce:o.serverNonce,newNonce:w}).getBytes();if(v.length>144)throw new i.SecurityError("Step 1 invalid nonce from server");let A,S;for(const e of o.serverPublicKeyFingerprints)if(S=d.get(e.toString()),void 0!==S){A=e;break}if(void 0===A||void 0===S)throw new i.SecurityError("Step 2 could not find a valid key for fingerprints");const I=p.generateRandomBytes(192-v.length),P=c.concat([v,I]),C=c.from(P).reverse();let M;for(let e=0;e<20;e++){const e=p.generateRandomBytes(32),n=await p.sha256(c.concat([e,P])),s=c.concat([C,n]),a=new l(e,c.alloc(32)).encryptIge(s),i=p.bufferXor(e,await p.sha256(a)),o=c.concat([i,a]),r=p.readBigIntFromBuffer(o,!1,!1);if(r.greaterOrEquals(S.n)){t.debug("Aes key greater than RSA. retrying");continue}const d=p.modExp(r,u(S.e),S.n);M=p.readBufferFromBigInt(d,256,!1,!1);break}if(void 0===M)throw new i.SecurityError("Step 2 could create a secure encrypted key");t.debug("Step 2 : Generated a secure aes encrypted data");const k=await e.send(new(a().ReqDHParams)({nonce:o.nonce,serverNonce:o.serverNonce,p:y,q:b,publicKeyFingerprint:A,encryptedData:M}));if(!(k instanceof a().ServerDHParamsOk||k instanceof a().ServerDHParamsFail))throw new Error(`Step 2.1 answer was ${k}`);if(k.nonce.neq(o.nonce))throw new i.SecurityError("Step 2 invalid nonce from server");if(k.serverNonce.neq(o.serverNonce))throw new i.SecurityError("Step 2 invalid server nonce from server");if(k instanceof a().ServerDHParamsFail){const e=await p.sha1(p.toSignedLittleBuffer(w,32).slice(4,20)),t=p.readBigIntFromBuffer(e,!0,!0);if(k.newNonceHash.neq(t))throw new i.SecurityError("Step 2 invalid DH fail nonce from server")}if(!(k instanceof a().ServerDHParamsOk))throw new Error(`Step 2.2 answer was ${k}`);t.debug("Finished authKey generation step 2"),t.debug("Starting authKey generation step 3");const{key:R,iv:E}=await p.generateKeyDataFromNonce(o.serverNonce,w);if(k.encryptedAnswer.length%16!=0)throw new i.SecurityError("Step 3 AES block size mismatch");const U=new l(R,E),B=U.decryptIge(k.encryptedAnswer),D=new h(B);D.read(20);const T=D.tgReadObject();if(!(T instanceof a().ServerDHInnerData))throw new Error(`Step 3 answer was ${T}`);if(T.nonce.neq(o.nonce))throw new i.SecurityError("Step 3 Invalid nonce in encrypted answer");if(T.serverNonce.neq(o.serverNonce))throw new i.SecurityError("Step 3 Invalid server nonce in encrypted answer");const x=p.readBigIntFromBuffer(T.dhPrime,!1,!1),V=p.readBigIntFromBuffer(T.gA,!1,!1),N=T.serverTime-Math.floor((new Date).getTime()/1e3),F=p.readBigIntFromBuffer(p.generateRandomBytes(256),!1,!1),q=p.modExp(u(T.g),F,x),L=p.modExp(V,F,x),G=new(a().ClientDHInnerData)({nonce:o.nonce,serverNonce:o.serverNonce,retryId:u.zero,gB:p.getByteArray(q,!1)}).getBytes(),H=c.concat([await p.sha1(G),G]),O=U.encryptIge(H),K=await e.send(new(a().SetClientDHParams)({nonce:o.nonce,serverNonce:o.serverNonce,encryptedData:O})),z=[a().DhGenOk,a().DhGenRetry,a().DhGenFail];if(!(K instanceof z[0]||K instanceof z[1]||K instanceof z[2]))throw new Error(`Step 3.1 answer was ${K}`);const{name:j}=K.constructor;if(K.nonce.neq(o.nonce))throw new i.SecurityError(`Step 3 invalid ${j} nonce from server`);if(K.serverNonce.neq(o.serverNonce))throw new i.SecurityError(`Step 3 invalid ${j} server nonce from server`);const W=new f;await W.setKey(p.getByteArray(L));const $=1+["DhGenOk","DhGenRetry","DhGenFail"].indexOf(K.className),J=await W.calcNewNonceHash(w,$);if(K[`newNonceHash${$}`].neq(J))throw new i.SecurityError("Step 3 invalid new nonce hash");if(!(K instanceof a().DhGenOk))throw new Error(`Step 3.2 answer was ${K}`);return t.debug("Finished authKey generation step 3"),{authKey:W,timeOffset:N}}},45585:(e,t,n)=>{var s=n(48764).Buffer;const a=n(24736),i=n(59109),o=n(35544),{InvalidBufferError:r}=n(48187),{toSignedLittleBuffer:d}=n(89618);e.exports=class{constructor(e,t){this._state=new i(e,t),this._connection=e}async send(e){let t=e.getBytes(),n=this._state._getNewMsgId();const i=d(n,8),c=s.alloc(4);c.writeInt32LE(t.length,0);const u=s.concat([s.concat([s.alloc(8),i,c]),t]);if(await this._connection.send(u),t=await this._connection.recv(),t.length<8)throw new r(t);const l=new o(t);if(l.readLong().neq(a(0)))throw new Error("Bad authKeyId");if(n=l.readLong(),n.eq(a(0)))throw new Error("Bad msgId");if(l.readInt()<=0)throw new Error("Bad length");return l.tgReadObject()}}},74046:(e,t,n)=>{const{RPCError:s}=n(87873),a=n(45585),i=n(59109),o=n(89618),r=n(13302),{doAuthentication:d}=n(59870),c=n(52301),u=n(63254),l=n(68963),f=n(44287),{MsgsAck:g,upload:p,MsgsStateInfo:h,Pong:m}=n(57404).constructors,_=n(36411),y=n(35544),{UpdateConnectionState:b,UpdateServerTimeOffset:w}=n(68744),{BadMessageError:v}=n(48187),{BadServerSalt:A,BadMsgNotification:S,MsgDetailedInfo:I,MsgNewDetailedInfo:P,NewSessionCreated:C,FutureSalts:M,MsgsStateReq:k,MsgResendReq:R,MsgsAllInfo:E}=n(57404).constructors,{SecurityError:U}=n(48187),{InvalidBufferError:B}=n(48187),{LogOut:D}=n(57404).requests.auth,{RPCMessageToError:T}=n(87873),{TypeNotFoundError:x}=n(48187);class V{constructor(e,t){const n={...V.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.isReconnecting=!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 _(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),[l.CONSTRUCTOR_ID]:this._handleGzipPacked.bind(this),[m.CONSTRUCTOR_ID]:this._handlePong.bind(this),[A.CONSTRUCTOR_ID]:this._handleBadServerSalt.bind(this),[S.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),[g.CONSTRUCTOR_ID]:this._handleAck.bind(this),[M.CONSTRUCTOR_ID]:this._handleFutureSalts.bind(this),[k.CONSTRUCTOR_ID]:this._handleStateForgotten.bind(this),[R.CONSTRUCTOR_ID]:this._handleStateForgotten.bind(this),[E.CONSTRUCTOR_ID]:this._handleMsgAll.bind(this)}}async connect(e,t){if(this.userDisconnected=!1,this._user_connected&&!t)return this._log.info("User is already connected!"),!1;this.isConnecting=!0,this._connection=e;for(let e=0;e=10&&this._last_acks.shift(),this._pending_ack.clear()}this._log.debug(`Waiting for messages to send...${this.isReconnecting}`);const e=await this._send_queue.get();if(this.isReconnecting)return;if(!e)continue;let{data:t}=e;const{batch:n}=e;this._log.debug(`Encrypting ${n.length} message(s) in ${t.length} bytes for sending`),t=await this._state.encryptMessageData(t);try{await this._connection.send(t)}catch(e){return this._log.error(e),void this._log.info("Connection closed while sending data")}for(const e of n)if(Array.isArray(e))for(const t of e)"request"===t.request.classType&&(this._pending_state[t.msgId]=t);else"request"===e.request.classType&&(this._pending_state[e.msgId]=e);this._log.debug("Encrypted messages put in a queue to be sent")}}async _recvLoop(){let e,t;for(;this._user_connected&&!this.isReconnecting;){this._log.debug("Receiving items from the network...");try{e=await this._connection.recv()}catch(e){return void(this.userDisconnected||(this._log.error(e),this._log.warn("Connection closed while receiving data"),this.reconnect()))}try{t=await this._state.decryptMessageData(e)}catch(e){if(e instanceof x){this._log.info(`Type ${e.invalidConstructorId} not found, remaining data ${e.remaining}`);continue}if(e instanceof U){this._log.warn(`Security error while unpacking a received message: ${e}`);continue}return e instanceof B?void(404===e.code?this._handleBadAuthKey():(this._log.warn(`Invalid buffer ${e.code} for dc ${this._dcId}`),this.reconnect())):(this._log.error("Unhandled error while receiving data"),this._log.error(e),void this.reconnect())}try{await this._processMessage(t)}catch(e){e instanceof s?"AUTH_KEY_UNREGISTERED"===e.message&&this._handleBadAuthKey(!0):(this._log.error("Unhandled error while receiving data"),this._log.error(e))}}}_handleBadAuthKey(e){e&&this._isMainSender||(this._log.warn(`Broken authorization key for dc ${this._dcId}, resetting...`),this._isMainSender&&this._updateCallback?this._updateCallback(new b(b.broken)):!this._isMainSender&&this._onConnectionBreak&&this._onConnectionBreak(this._dcId))}async _processMessage(e){this._pending_ack.add(e.msgId),e.obj=await e.obj;let t=this._handlers[e.obj.CONSTRUCTOR_ID];t||(t=this._handleUpdate.bind(this)),await t(e)}_popStates(e){let t=this._pending_state[e];if(t)return this._pending_state[e].deferred.resolve(),delete this._pending_state[e],[t];const n=[];for(t of Object.values(this._pending_state))t.containerId&&t.containerId.equals(e)&&n.push(t.msgId);if(n.length){const e=[];for(const t of n)e.push(this._pending_state[t]),this._pending_state[t].deferred.resolve(),delete this._pending_state[t];return e}for(const t of this._last_acks)if(t.msgId===e)return[t];return[]}_handleRPCResult(e){const t=e.obj,n=this._pending_state[t.reqMsgId];if(n&&(n.deferred.resolve(),delete this._pending_state[t.reqMsgId]),this._log.debug(`Handling RPC result for message ${t.reqMsgId}`),!n)try{if(!(new y(t.body).tgReadObject()instanceof p.File))throw new x("Not an upload.File")}catch(e){if(this._log.error(e),e instanceof x)return void this._log.info(`Received response without parent request: ${t.body}`);throw e}if(t.error){const e=T(t.error,n.request);throw this._send_queue.append(new f(new g({msgIds:[n.msgId]}))),n.reject(e),e}try{const e=new y(t.body),s=n.request.readResult(e);n.resolve(s)}catch(e){throw n.reject(e),e}}async _handleContainer(e){this._log.debug("Handling container");for(const t of e.obj.messages)await this._processMessage(t)}async _handleGzipPacked(e){this._log.debug("Handling gzipped data");const t=new y(e.obj.data);e.obj=t.tgReadObject(),await this._processMessage(e)}_handleUpdate(e){2331323052===e.obj.SUBCLASS_OF_ID?(this._log.debug(`Handling update ${e.obj.className}`),this._updateCallback&&this._updateCallback(e.obj)):this._log.warn(`Note: ${e.obj.className} is not an update, not dispatching it`)}_handlePong(e){const t=e.obj,n=this._state.updateTimeOffset(e.msgId);this._updateCallback&&this._updateCallback(new w(n)),this._log.debug(`Handling pong for message ${t.msgId}`);const s=this._pending_state[t.msgId];this._pending_state[t.msgId].deferred.resolve(),delete this._pending_state[t.msgId],s&&s.resolve(t)}_handleBadServerSalt(e){const t=e.obj;this._log.debug(`Handling bad salt for message ${t.badMsgId}`),this._state.salt=t.newServerSalt;const n=this._popStates(t.badMsgId);this._send_queue.extend(n),this._log.debug(`${n.length} message(s) will be resent`)}_handleBadNotification(e){const t=e.obj,n=this._popStates(t.badMsgId);if(this._log.debug(`Handling bad msg ${JSON.stringify(t)}`),[16,17].includes(t.errorCode)){const t=this._state.updateTimeOffset(e.msgId);this._updateCallback&&this._updateCallback(new w(t)),this._log.info(`System clock is wrong, set time offset to ${t}s`)}else if(32===t.errorCode)this._state._sequence+=64;else{if(33!==t.errorCode){for(const e of n)e.reject(new v(e.request,t.errorCode));return}this._state._sequence-=16}this._send_queue.extend(n),this._log.debug(`${n.length} messages will be resent due to bad msg`)}_handleDetailedInfo(e){const t=e.obj.answerMsgId;this._log.debug(`Handling detailed info for message ${t}`),this._pending_ack.add(t)}_handleNewDetailedInfo(e){const t=e.obj.answerMsgId;this._log.debug(`Handling new detailed info for message ${t}`),this._pending_ack.add(t)}_handleNewSessionCreated(e){this._log.debug("Handling new session created"),this._state.salt=e.obj.serverSalt}_handleAck(e){const t=e.obj;this._log.debug(`Handling acknowledge for ${t.msgIds}`);for(const e of t.msgIds){const t=this._pending_state[e];t&&t.request instanceof D&&(this._pending_state[e].deferred.resolve(),delete this._pending_state[e],t.resolve(!0))}}_handleFutureSalts(e){this._log.debug(`Handling future salts for message ${e.msgId}`);const t=this._pending_state[e.msgId];t&&(this._pending_state[e].deferred.resolve(),delete this._pending_state[e],t.resolve(e.obj))}_handleStateForgotten(e){this._send_queue.append(new f(new h(e.msgId,String.fromCharCode(1).repeat(e.obj.msgIds))))}_handleMsgAll(e){}reconnect(){this._user_connected&&!this.isReconnecting&&(this.isReconnecting=!0,o.sleep(1e3).then((()=>{this._log.info("Started reconnecting"),this._reconnect()})))}async _reconnect(){this._log.debug("Closing current connection...");try{await this._disconnect()}catch(e){this._log.warn(e)}this._send_queue.append(void 0),this._state.reset();const e=new this._connection.constructor(this._connection._ip,this._connection._port,this._connection._dcId,this._connection._log,this._connection._testServers);await this.connect(e,!0),this.isReconnecting=!1;for(const e of Object.values(this._pending_state))e.deferred.resolve();this._pending_state={},this._autoReconnectCallback&&await this._autoReconnectCallback()}}var N,F,q;q={logger:void 0,retries:1/0,delay:2e3,autoReconnect:!0,connectTimeout:void 0,authKeyCallback:void 0,updateCallback:void 0,autoReconnectCallback:void 0,isMainSender:void 0,onConnectionBreak:void 0},(F="DEFAULT_OPTIONS")in(N=V)?Object.defineProperty(N,F,{value:q,enumerable:!0,configurable:!0,writable:!0}):N[F]=q,e.exports=V},59109:(e,t,n)=>{var s=n(48764).Buffer;const a=n(24736),i=n(28136),o=n(89618),r=n(32608),d=n(35544),c=n(68963),{TLMessage:u}=n(92058),{SecurityError:l,InvalidBufferError:f}=n(48187),{InvokeAfterMsg:g}=n(57404).requests,{toSignedLittleBuffer:p}=n(89618);e.exports=class{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.authKey=e,this._log=t,this._isCall=n,this._isOutgoing=s,this.timeOffset=0,this.salt=0,this.id=void 0,this._sequence=void 0,this._lastMsgId=void 0,this.msgIds=[],this.reset()}reset(){this.id=o.generateRandomLong(!0),this._sequence=0,this._lastMsgId=a(0),this.msgIds=[]}updateMessageId(e){e.msgId=this._getNewMsgId()}async _calcKey(e,t,n){const a=this._isCall?128+(this._isOutgoing^n?8:0):!0===n?0:8,[i,r]=await Promise.all([o.sha256(s.concat([t,e.slice(a,a+36)])),o.sha256(s.concat([e.slice(a+40,a+76),t]))]),d=s.concat([i.slice(0,8),r.slice(8,24),i.slice(24,32)]);return this._isCall?{key:d,iv:s.concat([r.slice(0,4),i.slice(8,16),r.slice(24,28)])}:{key:d,iv:s.concat([r.slice(0,8),i.slice(8,24),r.slice(24,32)])}}async writeDataAsMessage(e,t,n,a){const i=this._getNewMsgId(),o=this._getSeqNo(n);let r;r=a?await c.gzipIfSmaller(n,new g(a,{getBytes:()=>t}).getBytes()):await c.gzipIfSmaller(n,t);const d=s.alloc(4);d.writeInt32LE(o,0);const u=s.alloc(4);u.writeInt32LE(r.length,0);const l=p(i,8);return e.write(s.concat([l,d,u])),e.write(r),i}async encryptMessageData(e){if(await this.authKey.waitForKey(),this._isCall){const t=128+(this._isOutgoing?0:8),n=e.length;e=s.from(e),n%4!=0&&(e=s.concat([e,s.from(new Array(4-n%4).fill(32))]));const a=(await o.sha256(s.concat([this.authKey.getKey().slice(88+t,88+t+32),s.from(e)]))).slice(8,24),{iv:r,key:d}=await this._calcKey(this.authKey.getKey(),a,!0);return e=o.convertToLittle(new i.CTR(d,r).encrypt(e)),s.concat([a,e])}{const t=p(this.salt,8),n=p(this.id,8);e=s.concat([s.concat([t,n]),e]);const a=o.generateRandomBytes(o.mod(-(e.length+12),16)+12),i=(await o.sha256(s.concat([this.authKey.getKey().slice(88,120),e,a]))).slice(8,24),{iv:d,key:c}=await this._calcKey(this.authKey.getKey(),i,!0),u=o.readBufferFromBigInt(this.authKey.keyId,8);return s.concat([u,i,new r(c,d).encryptIge(s.concat([e,a]))])}}async decryptMessageData(e){if(e.length<8)throw new f(e);if(e.length<0)throw new l("Server replied with negative length");if(e.length%4!=0&&!this._isCall)throw new l("Server replied with length not divisible by 4");if(!this._isCall&&o.readBigIntFromBuffer(e.slice(0,8)).neq(this.authKey.keyId))throw new l("Server replied with an invalid auth key");const t=this._isCall?e.slice(0,16):e.slice(8,24),n=this._isCall?128+(this.isOutgoing?8:0):void 0,{iv:a,key:c}=await this._calcKey(this.authKey.getKey(),t,!1);if(this._isCall){const t=(e=e.slice(16)).length;e=s.concat([e,s.from(new Array(4-t%4).fill(0))]),e=(e=o.convertToLittle(new i.CTR(c,a).decrypt(e))).slice(0,t)}else e=new r(c,a).decryptIge(this._isCall?e.slice(16):e.slice(24));const g=this._isCall?await o.sha256(s.concat([this.authKey.getKey().slice(88+n,88+n+32),e])):await o.sha256(s.concat([this.authKey.getKey().slice(96,128),e]));if(!this._isCall&&!t.equals(g.slice(8,24)))throw new l("Received msg_key doesn't match with expected one");const p=new d(e);if(this._isCall)return p.readInt(!1),p.read(e.length-4);{if(p.readLong(),!p.readLong().eq(this.id))throw new l("Server replied with a wrong session ID");const t=p.readLong();if(this.msgIds.includes(t.toString()))throw new l("Duplicate msgIds");this.msgIds.length>500&&this.msgIds.shift(),this.msgIds.push(t.toString());const n=p.readInt(),s=p.readInt(),a=e.length-s;if(a<12||a>1024)throw new l("Server replied with the wrong message padding");const i=p.tgReadObject();return new u(t,n,i)}}_getNewMsgId(){const e=(new Date).getTime()/1e3+this.timeOffset,t=Math.floor(1e9*(e-Math.floor(e)));let n=a(Math.floor(e)).shiftLeft(a(32)).or(a(t).shiftLeft(a(2)));return this._lastMsgId.greaterOrEquals(n)&&(n=this._lastMsgId.add(a(4))),this._lastMsgId=n,n}updateTimeOffset(e){const t=this._getNewMsgId(),n=this.timeOffset,s=Math.floor((new Date).getTime()/1e3),i=e.shiftRight(a(32));return this.timeOffset=i-s,this.timeOffset!==n&&(this._lastMsgId=a(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}}},44287:(e,t,n)=>{const{createDeferred:s}=n(89618);e.exports=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.containerId=void 0,this.msgId=void 0,this.request=e,this.data=e.getBytes(),this.after=t,this.result=void 0,this.pending=n,this.deferred=s(),this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}isReady(){const e=this.pending[this.after.id];return!e||e.deferred.promise}}},34353:(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 a=n(7214),i=n(16151);class o{constructor(e,t,n,o,r,d){s(this,"PacketCodecClass",void 0),this._ip=e,this._port=t,this._dcId=n,this._log=o,this._testServers=r,this._isPremium=d,this._connected=!1,this._sendTask=void 0,this._recvTask=void 0,this._codec=void 0,this._obfuscation=void 0,this._sendArray=new i,this._recvArray=new i,this.socket=new a(this.disconnectCallback.bind(this))}async disconnectCallback(){await this.disconnect(!0)}async _connect(){this._log.debug("Connecting"),this._codec=new this.PacketCodecClass(this),await this.socket.connect(this._port,this._ip,this._testServers,this._isPremium),this._log.debug("Finished connecting"),await this._initConn()}async connect(){await this._connect(),this._connected=!0,this._sendTask||(this._sendTask=this._sendLoop()),this._recvTask=this._recvLoop()}async disconnect(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._connected&&(this._connected=!1,this._recvArray.push(void 0),e||await this.socket.close())}async send(e){if(!this._connected)throw new Error("Not connected");await this._sendArray.push(e)}async recv(){for(;this._connected;){const e=await this._recvArray.pop();if(e)return e}throw new Error("Not connected")}async _sendLoop(){try{for(;this._connected;){const e=await this._sendArray.pop();if(!e)return void(this._sendTask=void 0);await this._send(e)}}catch(e){this._log.info("The server closed the connection while sending")}}async _recvLoop(){let e;for(;this._connected;){try{if(e=await this._recv(),!e)throw new Error("no data received")}catch(e){return this._log.info("connection closed"),void this.disconnect()}await this._recvArray.push(e)}}async _initConn(){this._codec.tag&&await this.socket.write(this._codec.tag)}_send(e){const t=this._codec.encodePacket(e);this.socket.write(t)}_recv(){return this._codec.readPacket(this.socket)}toString(){return`${this._ip}:${this._port}/${this.constructor.name.replace("Connection","")}`}}e.exports={Connection:o,PacketCodec:class{constructor(e){this._conn=e}encodePacket(e){throw new Error("Not Implemented")}readPacket(e){throw new Error("Not Implemented")}},ObfuscatedConnection:class extends o{constructor(){super(...arguments),s(this,"ObfuscatedIO",void 0)}_initConn(){this._obfuscation=new this.ObfuscatedIO(this),this.socket.write(this._obfuscation.header)}_send(e){this._obfuscation.write(this._codec.encodePacket(e))}_recv(){return this._codec.readPacket(this._obfuscation)}}}},26302:(e,t,n)=>{var s=n(48764).Buffer;function a(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(24736),{readBufferFromBigInt:o}=n(89618),{Connection:r,PacketCodec:d}=n(34353);class c extends d{constructor(e){super(e),this.tag=c.tag,this.obfuscateTag=c.obfuscateTag}encodePacket(e){let t=e.length>>2;if(t<127){const e=s.alloc(1);e.writeUInt8(t,0),t=e}else t=s.concat([s.from("7f","hex"),o(i(t),3)]);return s.concat([t,e])}async readPacket(e){let t=(await e.read(1))[0];return t>=127&&(t=s.concat([await e.read(3),s.alloc(1)]).readInt32LE(0)),e.read(t<<2)}}a(c,"tag",s.from("ef","hex")),a(c,"obfuscateTag",s.from("efefefef","hex")),e.exports={ConnectionTCPAbridged:class extends r{constructor(){super(...arguments),a(this,"PacketCodecClass",c)}},AbridgedPacketCodec:c}},5484:()=>{},72986:(e,t,n)=>{var s=n(48764).Buffer;function a(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(89618),{ObfuscatedConnection:o}=n(34353),{AbridgedPacketCodec:r}=n(26302),d=n(55830);class c{constructor(e){a(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 t=[s.from("50567247","hex"),s.from("474554","hex"),s.from("504f5354","hex"),s.from("eeeeeeee","hex")];let n;for(;;)if(n=i(64),239!==n[0]&&!n.slice(4,8).equals(s.alloc(4))){let e=!0;for(const s of t)if(s.equals(n.slice(0,4))){e=!1;break}if(e)break}n=n.toJSON().data;const a=s.from(n.slice(8,56)).reverse(),o=s.from(n.slice(8,40)),r=s.from(n.slice(40,56)),c=s.from(a.slice(0,32)),u=s.from(a.slice(32,48)),l=new d(o,r),f=new d(c,u);return n=s.concat([s.from(n.slice(0,56)),e.obfuscateTag,s.from(n.slice(60))]),n=s.concat([s.from(n.slice(0,56)),s.from(l.encrypt(n).slice(56,64)),s.from(n.slice(64))]),{random:n,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 o{constructor(){super(...arguments),a(this,"ObfuscatedIO",c),a(this,"PacketCodecClass",r)}}}},30417:(e,t,n)=>{const{Connection:s}=n(34353),{ConnectionTCPFull:a}=n(5484),{ConnectionTCPAbridged:i}=n(26302),{ConnectionTCPObfuscated:o}=n(72986);e.exports={Connection:s,ConnectionTCPFull:a,ConnectionTCPAbridged:i,ConnectionTCPObfuscated:o}},18415:(e,t,n)=>{const s=n(45585),a=n(74046),{Connection:i,ConnectionTCPFull:o,ConnectionTCPAbridged:r,ConnectionTCPObfuscated:d}=n(30417),{UpdateConnectionState:c,UpdateServerTimeOffset:u}=n(68744);e.exports={Connection:i,ConnectionTCPFull:o,ConnectionTCPAbridged:r,ConnectionTCPObfuscated:d,MTProtoPlainSender:s,MTProtoSender:a,UpdateConnectionState:c,UpdateServerTimeOffset:u}},68744:e=>{function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class n{constructor(e,t){this.state=e,this.origin=t}}t(n,"disconnected",-1),t(n,"connected",1),t(n,"broken",0),e.exports={UpdateConnectionState:n,UpdateServerTimeOffset:class{constructor(e){this.timeOffset=e}}}},59270:e=>{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")}}},926:(e,t,n)=>{const s=n(28753),a="GramJs";e.exports=class extends s{async _delete(){const e=new Request(this._storageKey);return(await self.caches.open(a)).delete(e)}async _fetchFromCache(){const e=new Request(this._storageKey),t=await self.caches.open(a),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(a)).put(t,n)}}},80007:(e,t,n)=>{var s=n(48764).Buffer;const a=n(33995),i=n(13302),o=n(48960);e.exports=class extends a{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:t,hashes:n}=this._sessionData,{ipAddress:a,port:r}=o.getDC(e);this.setDC(e,a,r,!0),await Promise.all(Object.keys(t).map((async e=>{const a="string"==typeof t[e]?s.from(t[e],"hex"):s.from(t[e]);if(n[e]){const t="string"==typeof n[e]?s.from(n[e],"hex"):s.from(n[e]);this._authKeys[e]=new i(a,t)}else this._authKeys[e]=new i,await this._authKeys[e].setKey(a,!0)})))}setDC(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this._dcId=e,this._serverAddress=t,this._port=n,delete this._authKeys[e],s||this._onUpdate()}getAuthKey(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._dcId;return this._authKeys[e]}setAuthKey(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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)}}},45945:(e,t,n)=>{const s=n(24678),a=n(28753);e.exports=class extends a{_delete(){return s.del(`GramJs:${this._storageKey}`)}_fetchFromCache(){return s.get(`GramJs:${this._storageKey}`)}_saveToCache(e){return s.set(`GramJs:${this._storageKey}`,e)}}},31753:(e,t,n)=>{const s=n(28753);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)}}},33995:(e,t,n)=>{const s=n(59270);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}}},28753:(e,t,n)=>{var s=n(48764).Buffer;const a=n(33995),i=n(13302),o=n(48960);e.exports=class extends a{constructor(e){super(),this._authKeys={},e&&e.startsWith("session:")?this._sessionString=e:e&&(this._storageKey=e)}get authKey(){throw new Error("Not supported")}set authKey(e){throw new Error("Not supported")}async load(){if(this._sessionString)await this._loadFromSessionString();else if(this._storageKey)try{const e=await this._fetchFromCache(),{mainDcId:t,keys:n,hashes:a}=JSON.parse(e),{ipAddress:r,port:d}=o.getDC(t);this.setDC(t,r,d,!0),Object.keys(n).forEach((e=>{n[e]&&a[e]&&(this._authKeys[e]=new i(s.from(n[e].data),s.from(a[e].data)))}))}catch(e){console.warn("Failed to retrieve or parse session from storage"),console.warn(e)}}setDC(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._dcId;return this._authKeys[e]}setAuthKey(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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,t]=this._sessionString.split(":"),n=Number(e),{ipAddress:a,port:r}=o.getDC(n);this.setDC(n,a,r);const d=new i;await d.setKey(s.from(t,"hex"),!0),this.setAuthKey(d,n)}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")}}},12433:(e,t,n)=>{var s=n(48764).Buffer;const a=n(33995),i=n(13302),o=n(35544);class r extends a{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;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 o(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 s.from(e,"base64")}async load(){this._key&&(this._authKey=new i,await this._authKey.setKey(this._key))}save(){if(!this.authKey)return"";const e=s.from([this.dcId]),t=s.from(this.serverAddress),n=s.alloc(2);n.writeInt16BE(t.length,0);const a=s.alloc(2);return a.writeInt16BE(this.port,0),"1"+r.encode(s.concat([e,n,t,a,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},15886:(e,t,n)=>{const s=n(33995),a=n(12433),i=n(926),o=n(31753),r=n(45945),d=n(80007);e.exports={Memory:s,StringSession:a,CacheApiSession:i,LocalStorageSession:o,IdbSession:r,CallbackSession:d}},70845:(e,t,n)=>{const s=n(77150),a={};for(const e of Object.values(s))if(e.CONSTRUCTOR_ID)a[e.CONSTRUCTOR_ID]=e;else for(const t of Object.values(e))a[t.CONSTRUCTOR_ID]=t;e.exports={LAYER:147,tlobjects:a}},77150:(e,t,n)=>{var s=n(48764).Buffer;function a(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:o,serializeDate:r}=n(51436),{toSignedLittleBuffer:d}=n(89618),c=n(84779),u=n(48106),l="undefined"!=typeof self&&void 0!==self.localStorage,f="GramJs:apiCache";function g(e){const t=i(e),n=[],s=[];for(const e of t)e.isFunction?s.push(e):n.push(e);return[n,s]}function p(e,t){switch(t){case"int":{const t=s.alloc(4);return t.writeInt32LE(e,0),t}case"long":return d(e,8);case"int128":return d(e,16);case"int256":return d(e,32);case"double":{const t=s.alloc(8);return t.writeDoubleLE(e,0),t}case"string":case"bytes":return o(e);case"Bool":return e?s.from("b5757299","hex"):s.from("379779bc","hex");case"true":return s.alloc(0);case"date":return r(e);default:return e.getBytes()}}function h(e,t){if(t.isVector){t.useVectorId&&e.readInt();const n=[],s=e.readInt();t.isVector=!1;for(let a=0;a{this[e]=t[e]}))}static fromReader(e){const t={};for(const n in d)if(d.hasOwnProperty(n)){const s=d[n];if(s.isFlag){const a=t[`flags${s.flagGroup>1?s.flagGroup:""}`]&1<p(t,d[e].type)))))}else if(d[e].flagIndicator)if(Object.values(d).some((e=>e.isFlag))){let e=0;for(const t in d)d[t].isFlag&&(!1===this[t]&&"true"===d[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}(m("constructor",e.constructors),m("request",e.requests))}()},84779:e=>{e.exports="boolFalse#bc799737 = Bool;\nboolTrue#997275b5 = Bool;\ntrue#3fedd339 = True;\nvector#1cb5c415 {t:Type} # [ t ] = Vector t;\nerror#c4b9f9bb code:int text:string = Error;\nnull#56730bcc = Null;\ninputPeerEmpty#7f3b18ea = InputPeer;\ninputPeerSelf#7da07ec9 = InputPeer;\ninputPeerChat#35a95cb9 chat_id:long = InputPeer;\ninputPeerUser#dde8a54c user_id:long access_hash:long = InputPeer;\ninputPeerChannel#27bcbbfc channel_id:long access_hash:long = InputPeer;\ninputPeerUserFromMessage#a87b0a1c peer:InputPeer msg_id:int user_id:long = InputPeer;\ninputPeerChannelFromMessage#bd2a0840 peer:InputPeer msg_id:int channel_id:long = InputPeer;\ninputUserEmpty#b98886cf = InputUser;\ninputUserSelf#f7c1b13f = InputUser;\ninputUser#f21158c6 user_id:long access_hash:long = InputUser;\ninputUserFromMessage#1da448e2 peer:InputPeer msg_id:int user_id:long = InputUser;\ninputPhoneContact#f392b7f4 client_id:long phone:string first_name:string last_name:string = InputContact;\ninputFile#f52ff27f id:long parts:int name:string md5_checksum:string = InputFile;\ninputFileBig#fa4f0bb5 id:long parts:int name:string = InputFile;\ninputMediaEmpty#9664f57f = InputMedia;\ninputMediaUploadedPhoto#1e287d04 flags:# file:InputFile stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia;\ninputMediaPhoto#b3ba0635 flags:# id:InputPhoto ttl_seconds:flags.0?int = InputMedia;\ninputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia;\ninputMediaContact#f8ab7dfb phone_number:string first_name:string last_name:string vcard:string = InputMedia;\ninputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true force_file:flags.4?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia;\ninputMediaDocument#33473058 flags:# id:InputDocument ttl_seconds:flags.0?int query:flags.1?string = InputMedia;\ninputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia;\ninputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = InputMedia;\ninputMediaDocumentExternal#fb52dc99 flags:# url:string ttl_seconds:flags.0?int = InputMedia;\ninputMediaGame#d33f43f3 id:InputGame = InputMedia;\ninputMediaInvoice#8eb5a6d5 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON start_param:flags.1?string extended_media:flags.2?InputMedia = InputMedia;\ninputMediaGeoLive#971fa843 flags:# stopped:flags.0?true geo_point:InputGeoPoint heading:flags.2?int period:flags.1?int proximity_notification_radius:flags.3?int = InputMedia;\ninputMediaPoll#f94e5f1 flags:# poll:Poll correct_answers:flags.0?Vector solution:flags.1?string solution_entities:flags.1?Vector = InputMedia;\ninputMediaDice#e66fbf7b emoticon:string = InputMedia;\ninputChatPhotoEmpty#1ca48f57 = InputChatPhoto;\ninputChatUploadedPhoto#c642724e flags:# file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double = InputChatPhoto;\ninputChatPhoto#8953ad37 id:InputPhoto = InputChatPhoto;\ninputGeoPointEmpty#e4c123d6 = InputGeoPoint;\ninputGeoPoint#48222faf flags:# lat:double long:double accuracy_radius:flags.0?int = InputGeoPoint;\ninputPhotoEmpty#1cd7bf0d = InputPhoto;\ninputPhoto#3bb3b94a id:long access_hash:long file_reference:bytes = InputPhoto;\ninputFileLocation#dfdaabe1 volume_id:long local_id:int secret:long file_reference:bytes = InputFileLocation;\ninputEncryptedFileLocation#f5235d55 id:long access_hash:long = InputFileLocation;\ninputDocumentFileLocation#bad07584 id:long access_hash:long file_reference:bytes thumb_size:string = InputFileLocation;\ninputSecureFileLocation#cbc7ee28 id:long access_hash:long = InputFileLocation;\ninputTakeoutFileLocation#29be5899 = InputFileLocation;\ninputPhotoFileLocation#40181ffe id:long access_hash:long file_reference:bytes thumb_size:string = InputFileLocation;\ninputPhotoLegacyFileLocation#d83466f3 id:long access_hash:long file_reference:bytes volume_id:long local_id:int secret:long = InputFileLocation;\ninputPeerPhotoFileLocation#37257e99 flags:# big:flags.0?true peer:InputPeer photo_id:long = InputFileLocation;\ninputStickerSetThumb#9d84f3db stickerset:InputStickerSet thumb_version:int = InputFileLocation;\ninputGroupCallStream#598a92a flags:# call:InputGroupCall time_ms:long scale:int video_channel:flags.0?int video_quality:flags.0?int = InputFileLocation;\npeerUser#59511722 user_id:long = Peer;\npeerChat#36c6019a chat_id:long = Peer;\npeerChannel#a2a5371e channel_id:long = Peer;\nstorage.fileUnknown#aa963b05 = storage.FileType;\nstorage.filePartial#40bc6f52 = storage.FileType;\nstorage.fileJpeg#7efe0e = storage.FileType;\nstorage.fileGif#cae1aadf = storage.FileType;\nstorage.filePng#a4f63c0 = storage.FileType;\nstorage.filePdf#ae1e508d = storage.FileType;\nstorage.fileMp3#528a0677 = storage.FileType;\nstorage.fileMov#4b09ebbc = storage.FileType;\nstorage.fileMp4#b3cea0e4 = storage.FileType;\nstorage.fileWebp#1081464c = storage.FileType;\nuserEmpty#d3bc4b7a id:long = User;\nuser#5d99adee flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus = User;\nuserProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;\nuserProfilePhoto#82d1f706 flags:# has_video:flags.0?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto;\nuserStatusEmpty#9d05049 = UserStatus;\nuserStatusOnline#edb93949 expires:int = UserStatus;\nuserStatusOffline#8c703f was_online:int = UserStatus;\nuserStatusRecently#e26f42f1 = UserStatus;\nuserStatusLastWeek#7bf09fc = UserStatus;\nuserStatusLastMonth#77ebc742 = UserStatus;\nchatEmpty#29562865 id:long = Chat;\nchat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5?true call_active:flags.23?true call_not_empty:flags.24?true noforwards:flags.25?true id:long title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat;\nchatForbidden#6592a1a7 id:long title:string = Chat;\nchannel#8261ac61 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat;\nchannelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat;\nchatFull#c9d31138 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions = ChatFull;\nchannelFull#f2355507 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions = ChatFull;\nchatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant;\nchatParticipantCreator#e46bcee4 user_id:long = ChatParticipant;\nchatParticipantAdmin#a0933f5b user_id:long inviter_id:long date:int = ChatParticipant;\nchatParticipantsForbidden#8763d3e1 flags:# chat_id:long self_participant:flags.0?ChatParticipant = ChatParticipants;\nchatParticipants#3cbc93f8 chat_id:long participants:Vector version:int = ChatParticipants;\nchatPhotoEmpty#37c1011c = ChatPhoto;\nchatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = ChatPhoto;\nmessageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message;\nmessage#38116ee0 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message;\nmessageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction ttl_period:flags.25?int = Message;\nmessageMediaEmpty#3ded6320 = MessageMedia;\nmessageMediaPhoto#695150d7 flags:# photo:flags.0?Photo ttl_seconds:flags.2?int = MessageMedia;\nmessageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia;\nmessageMediaContact#70322949 phone_number:string first_name:string last_name:string vcard:string user_id:long = MessageMedia;\nmessageMediaUnsupported#9f84f49e = MessageMedia;\nmessageMediaDocument#9cb070d7 flags:# nopremium:flags.3?true document:flags.0?Document ttl_seconds:flags.2?int = MessageMedia;\nmessageMediaWebPage#a32dd600 webpage:WebPage = MessageMedia;\nmessageMediaVenue#2ec0533f geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string = MessageMedia;\nmessageMediaGame#fdb19008 game:Game = MessageMedia;\nmessageMediaInvoice#f6a548d3 flags:# shipping_address_requested:flags.1?true test:flags.3?true title:string description:string photo:flags.0?WebDocument receipt_msg_id:flags.2?int currency:string total_amount:long start_param:string extended_media:flags.4?MessageExtendedMedia = MessageMedia;\nmessageMediaGeoLive#b940c666 flags:# geo:GeoPoint heading:flags.0?int period:int proximity_notification_radius:flags.1?int = MessageMedia;\nmessageMediaPoll#4bd6e798 poll:Poll results:PollResults = MessageMedia;\nmessageMediaDice#3f7ee58b value:int emoticon:string = MessageMedia;\nmessageActionEmpty#b6aef7b0 = MessageAction;\nmessageActionChatCreate#bd47cbad title:string users:Vector = MessageAction;\nmessageActionChatEditTitle#b5a1ce5a title:string = MessageAction;\nmessageActionChatEditPhoto#7fcb13a8 photo:Photo = MessageAction;\nmessageActionChatDeletePhoto#95e3fbef = MessageAction;\nmessageActionChatAddUser#15cefd00 users:Vector = MessageAction;\nmessageActionChatDeleteUser#a43f30cc user_id:long = MessageAction;\nmessageActionChatJoinedByLink#31224c3 inviter_id:long = MessageAction;\nmessageActionChannelCreate#95d2ac92 title:string = MessageAction;\nmessageActionChatMigrateTo#e1037f92 channel_id:long = MessageAction;\nmessageActionChannelMigrateFrom#ea3948e9 title:string chat_id:long = MessageAction;\nmessageActionPinMessage#94bd38ed = MessageAction;\nmessageActionHistoryClear#9fbab604 = MessageAction;\nmessageActionGameScore#92a72876 game_id:long score:int = MessageAction;\nmessageActionPaymentSentMe#8f31b327 flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long payload:bytes info:flags.0?PaymentRequestedInfo shipping_option_id:flags.1?string charge:PaymentCharge = MessageAction;\nmessageActionPaymentSent#96163f56 flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long invoice_slug:flags.0?string = MessageAction;\nmessageActionPhoneCall#80e11a7f flags:# video:flags.2?true call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction;\nmessageActionScreenshotTaken#4792929b = MessageAction;\nmessageActionCustomAction#fae69f56 message:string = MessageAction;\nmessageActionBotAllowed#abe9affe domain:string = MessageAction;\nmessageActionSecureValuesSentMe#1b287353 values:Vector credentials:SecureCredentialsEncrypted = MessageAction;\nmessageActionSecureValuesSent#d95c6154 types:Vector = MessageAction;\nmessageActionContactSignUp#f3f25f76 = MessageAction;\nmessageActionGeoProximityReached#98e0d697 from_id:Peer to_id:Peer distance:int = MessageAction;\nmessageActionGroupCall#7a0d7f42 flags:# call:InputGroupCall duration:flags.0?int = MessageAction;\nmessageActionInviteToGroupCall#502f92f7 call:InputGroupCall users:Vector = MessageAction;\nmessageActionSetMessagesTTL#aa1afbfd period:int = MessageAction;\nmessageActionGroupCallScheduled#b3a07661 call:InputGroupCall schedule_date:int = MessageAction;\nmessageActionSetChatTheme#aa786345 emoticon:string = MessageAction;\nmessageActionChatJoinedByRequest#ebbca3cb = MessageAction;\nmessageActionWebViewDataSentMe#47dd8079 text:string data:string = MessageAction;\nmessageActionWebViewDataSent#b4c38cb5 text:string = MessageAction;\nmessageActionGiftPremium#aba0f5c6 currency:string amount:long months:int = MessageAction;\ndialog#a8edd0f5 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog;\ndialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;\nphotoEmpty#2331b22d id:long = Photo;\nphoto#fb197a65 flags:# has_stickers:flags.0?true id:long access_hash:long file_reference:bytes date:int sizes:Vector video_sizes:flags.1?Vector dc_id:int = Photo;\nphotoSizeEmpty#e17e23c type:string = PhotoSize;\nphotoSize#75c78e60 type:string w:int h:int size:int = PhotoSize;\nphotoCachedSize#21e1ad6 type:string w:int h:int bytes:bytes = PhotoSize;\nphotoStrippedSize#e0b0bc2e type:string bytes:bytes = PhotoSize;\nphotoSizeProgressive#fa3efb95 type:string w:int h:int sizes:Vector = PhotoSize;\nphotoPathSize#d8214d41 type:string bytes:bytes = PhotoSize;\ngeoPointEmpty#1117dd5f = GeoPoint;\ngeoPoint#b2a2f663 flags:# long:double lat:double access_hash:long accuracy_radius:flags.0?int = GeoPoint;\nauth.sentCode#5e002502 flags:# type:auth.SentCodeType phone_code_hash:string next_type:flags.1?auth.CodeType timeout:flags.2?int = auth.SentCode;\nauth.authorization#33fb7bb8 flags:# setup_password_required:flags.1?true otherwise_relogin_days:flags.1?int tmp_sessions:flags.0?int user:User = auth.Authorization;\nauth.authorizationSignUpRequired#44747e9a flags:# terms_of_service:flags.0?help.TermsOfService = auth.Authorization;\nauth.exportedAuthorization#b434e2b8 id:long bytes:bytes = auth.ExportedAuthorization;\ninputNotifyPeer#b8bc5b0c peer:InputPeer = InputNotifyPeer;\ninputNotifyUsers#193b4417 = InputNotifyPeer;\ninputNotifyChats#4a95e84e = InputNotifyPeer;\ninputNotifyBroadcasts#b1db7c7e = InputNotifyPeer;\ninputPeerNotifySettings#df1f002b flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound = InputPeerNotifySettings;\npeerNotifySettings#a83b0426 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int ios_sound:flags.3?NotificationSound android_sound:flags.4?NotificationSound other_sound:flags.5?NotificationSound = PeerNotifySettings;\npeerSettings#a518110d flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true request_chat_broadcast:flags.10?true geo_distance:flags.6?int request_chat_title:flags.9?string request_chat_date:flags.9?int = PeerSettings;\nwallPaper#a437c3ed id:long flags:# creator:flags.0?true default:flags.1?true pattern:flags.3?true dark:flags.4?true access_hash:long slug:string document:Document settings:flags.2?WallPaperSettings = WallPaper;\nwallPaperNoFile#e0804116 id:long flags:# default:flags.1?true dark:flags.4?true settings:flags.2?WallPaperSettings = WallPaper;\ninputReportReasonSpam#58dbcab8 = ReportReason;\ninputReportReasonViolence#1e22c78d = ReportReason;\ninputReportReasonPornography#2e59d922 = ReportReason;\ninputReportReasonChildAbuse#adf44ee3 = ReportReason;\ninputReportReasonOther#c1e4a2b1 = ReportReason;\ninputReportReasonCopyright#9b89f93a = ReportReason;\ninputReportReasonGeoIrrelevant#dbd4feed = ReportReason;\ninputReportReasonFake#f5ddd6e7 = ReportReason;\ninputReportReasonIllegalDrugs#a8eb2be = ReportReason;\ninputReportReasonPersonalDetails#9ec7863d = ReportReason;\nuserFull#c4b1fc3f flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true id:long about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector = UserFull;\ncontact#145ade0b user_id:long mutual:Bool = Contact;\nimportedContact#c13e3c50 user_id:long client_id:long = ImportedContact;\ncontactStatus#16d9703b user_id:long status:UserStatus = ContactStatus;\ncontacts.contactsNotModified#b74ba9d2 = contacts.Contacts;\ncontacts.contacts#eae87e42 contacts:Vector saved_count:int users:Vector = contacts.Contacts;\ncontacts.importedContacts#77d01c3b imported:Vector popular_invites:Vector retry_contacts:Vector users:Vector = contacts.ImportedContacts;\ncontacts.blocked#ade1591 blocked:Vector chats:Vector users:Vector = contacts.Blocked;\ncontacts.blockedSlice#e1664194 count:int blocked:Vector chats:Vector users:Vector = contacts.Blocked;\nmessages.dialogs#15ba6c40 dialogs:Vector