telegram-tt/dist/f7cebeddef3b83eedfa4.worker.js

2 lines
364 KiB
JavaScript
Raw Normal View History

2021-04-18 23:17:33 +02:00
/*! For license information please see f7cebeddef3b83eedfa4.worker.js.LICENSE.txt */
2021-04-16 14:02:56 +02:00
!function(e){var t={};function n(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(s,i,function(t){return e[t]}.bind(null,i));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=107)}([function(e,t,n){const s=n(6),i=n(81),a=n(40),r=n(18),o=n(98),c=n(99),u=n(19),l=n(27),d=n(103),f=n(33),p=n(8);e.exports={Api:s,TelegramClient:i,sessions:d,connection:a,extensions:f,tl:r,version:o,events:c,utils:u,errors:l,helpers:p}},function(e,t,n){"use strict";n.d(t,"d",(function(){return C})),n.d(t,"a",(function(){return M})),n.d(t,"e",(function(){return E})),n.d(t,"b",(function(){return R})),n.d(t,"g",(function(){return O})),n.d(t,"f",(function(){return U})),n.d(t,"c",(function(){return T}));var s={};n.r(s),n.d(s,"Type",(function(){return m})),n.d(s,"fetch",(function(){return y})),n.d(s,"save",(function(){return b})),n.d(s,"clear",(function(){return _}));var i=n(0),a=n(33),r=n(4),o=n(16),c=n(26),u=n(9),l=n(42),d=n(10),f=n(5),p=n(2),h=n(35);const g=self.caches;let m;async function y(e,t,n){if(!g)return;const s=new Request(t),i=await g.open(e),a=await i.match(s);if(a)switch(n){case m.Text:return a.text();case m.Blob:{const e=await a.blob();if("sticker"===t.substr(0,7))return new Blob([e],{type:"image/webp"});if(!e.type){const t=a.headers.get("Content-Type");if(t)return new Blob([e],{type:t})}return e}case m.Json:return a.json();default:return}}async function b(e,t,n){if(!g)return;const s="string"==typeof n||n instanceof Blob?n:JSON.stringify(n),i=new Request(t),a=new Response(s);return(await g.open(e)).put(i,a)}function _(e){if(g)return g.delete(e)}async function w({url:e,mediaFormat:t,start:n,end:a},o,c,u){const{data:g,mimeType:m,fullSize:y}=await async function(e,t,n,s,a,o,c){const u=e.match(/(avatar|profile|msg|stickerSet|sticker|wallpaper|gif|file)([-\d\w./]+)(\?size=\w+)?/);if(!u)return;if("file"===u[1]){const e=await fetch(u[2]);return{data:await e.arrayBuffer()}}if(!n)return Promise.reject(new Error("ERROR: Client is not connected"));let l,h=u[2];const g=u[3]?u[3].replace("?size=",""):void 0;let m;"avatar"===u[1]||"profile"===u[1]?(l=Object(p.s)(Number(h)),h=Math.abs(Number(h))):l=u[1];switch(l){case"channel":case"chat":m=f.a.chats[h];break;case"user":m=f.a.users[h];break;case"msg":m=f.a.messages[h];break;case"sticker":case"gif":case"wallpaper":m=f.a.documents[h];break;case"stickerSet":m=f.a.stickerSets[h]}if(!m)return;if("msg"===l||"sticker"===l||"gif"===l||"wallpaper"===l){c===d.ApiMediaFormat.Stream&&(s.acceptsBuffer=!0);const e=await t.downloadMedia(m,{sizeType:g,start:a,end:o,progressCallback:s,workers:r.k});let n,u;return m instanceof i.Api.Message?(n=function(e,t){if(!e||!e.media)return;if(e.media instanceof i.Api.MessageMediaPhoto)return"image/jpeg";if(e.media instanceof i.Api.MessageMediaDocument&&e.media.document instanceof i.Api.Document)return t?e.media.document.attributes.some(e=>e instanceof i.Api.DocumentAttributeSticker)?"image/webp":"image/jpeg":e.media.document.mimeType;return}(m,g),m.media instanceof i.Api.MessageMediaDocument&&m.media.document instanceof i.Api.Document&&(u=m.media.document.size)):"sticker"===l&&g?n="image/webp":(n=m.mimeType,u=m.size),{mimeType:n,data:e,fullSize:u}}if("stickerSet"===l){const e=await t.downloadStickerSetThumb(m);return{mimeType:c===d.ApiMediaFormat.Lottie?"application/json":"image/jpeg",data:e}}{const e=await t.downloadProfilePhoto(m,"profile"===u[1]);return{mimeT