mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-14 18:27:10 +01:00
2 lines
7.9 KiB
JavaScript
2 lines
7.9 KiB
JavaScript
|
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[941],{7941:(t,i,e)=>{e.r(i),e.d(i,{default:()=>p});var s=e(7361),n=e(6926);function a(t,i,e){return i in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,t}class h{constructor(t){this.worker=t,a(this,"requestStates",new Map),a(this,"requestStatesByCallback",new Map),this.subscribe()}request(t){const{worker:i,requestStates:e,requestStatesByCallback:s}=this,a=(0,n.Z)(e),h={type:"callMethod",messageId:a,...t},r={messageId:a},o=new Promise(((t,i)=>{Object.assign(r,{resolve:t,reject:i})}));if("function"==typeof h.args[h.args.length-1]){const t=h.args.pop();r.callback=t,s.set(t,r)}return e.set(a,r),o.catch((()=>{})).finally((()=>{e.delete(a),r.callback&&s.delete(r.callback)})),i.postMessage(h),o}cancelCallback(t){t.isCanceled=!0;const{messageId:i}=this.requestStatesByCallback.get(t)||{};i&&this.worker.postMessage({type:"cancelProgress",messageId:i})}subscribe(){const{worker:t,requestStates:i}=this;t.addEventListener("message",(t=>{let{data:e}=t;if("methodResponse"===e.type){const t=i.get(e.messageId);t&&(e.error?t.reject(e.error):t.resolve(e.response))}else if("methodCallback"===e.type){var s;const t=i.get(e.messageId);null==t||null===(s=t.callback)||void 0===s||s.call(t,...e.callbackArgs)}else if("unhandledError"===e.type){var n;throw new Error(null===(n=e.error)||void 0===n?void 0:n.message)}}))}}var r=e(9933),o=e(3570);function d(t,i,e){return i in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,t}const c=s.wB?.75:1,u=s.wZ?.5:.75,l=s.s$?2:4,m=new Array(4).fill(void 0).map((()=>new h(new Worker(new URL(e.p+e.u(354),e.b)))));let g=-1;const p=class{constructor(t,i,e,s={},n,a,h){this.id=t,this.container=i,this.animationData=e,this.params=s,this.onLoad=n,this.customColor=a,this.onEnded=h,d(this,"imgSize",void 0),d(this,"key",void 0),d(this,"msPerFrame",1e3/60),d(this,"reduceFactor",1),d(this,"cacheModulo",void 0),d(this,"chunkSize",void 0),d(this,"workerIndex",void 0),d(this,"chunks",[]),d(this,"framesCount",void 0),d(this,"chunksCount",void 0),d(this,"canvas",document.createElement("canvas")),d(this,"ctx",this.canvas.getContext("2d")),d(this,"isAnimating",!1),d(this,"isWaiting",!0),d(this,"isOnLoadFired",!1),d(this,"isDestroyed",!1),d(this,"approxFrameIndex",0),d(this,"prevFrameIndex",-1),d(this,"stopFrameIndex",0),d(this,"speed",1),d(this,"direction",1),d(this,"lastRenderAt",void 0),this.initContainer(),this.initConfig(),this.initRenderer()}isPlaying(){return this.isAnimating||this.isWaiting}play(){this.stopFrameIndex=void 0,this.direction=1,this.doPlay()}pause(){this.isWaiting?this.stopFrameIndex=this.approxFrameIndex:this.isAnimating=!1;const t=this.getChunkIndex(this.approxFrameIndex);this.chunks=this.chunks.map(((i,e)=>e===t?i:void 0))}goToAndPlay(t){this.approxFrameIndex=Math.floor(t/this.reduceFactor),this.stopFrameIndex=void 0,this.direction=1,this.doPlay()}goToAndStop(t){this.approxFrameIndex=Math.floor(t/this.reduceFactor),this.stopFrameIndex=Math.floor(t/this.reduceFactor),this.direction=1,this.doPlay()}playSegment(t){let[i,e]=t;this.approxFrameIndex=Math.floor(i/this.reduceFactor),this.stopFrameIndex=Math.floor(e/this.reduceFactor),this.direction=i<e?1:-1,this.doPlay()}setSpeed(t){this.speed=t}destroy(){this.isDestroyed=!0,this.pause(),this.destroyRenderer(),this.destroyContainer()}initContainer(){if(!(this.container.parentNode instanceof HTMLElement))throw new Error("[RLottie] Container is not mounted");let{size:t}=this.params;if(!t&&(t=this.container.offsetWidth||parseInt(this.container.style.width,10)||this.container.parentNode.offsetWidth,!t))throw new Error("[RLottie] Failed to detect width from container");this.canvas.style.width=`${t}px`,this.canvas.style.height=`${t}px`;const{isLowPriority:i,quality:e=(i?u:c)}=this.params,n=Math.round(t*Math.max(s.cL*e,1));this.canvas.width=n,this.canvas.height=n,this.container.appendChild(this.canvas),this.imgSize=n}initConfig(){this.key=`${this.id}_${this.imgSize}`;const{isLowPriority:t}=this.params;this.cacheModu
|
||
|
//# sourceMappingURL=941.367e239e47c825643813.js.map
|