"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[941],{7941:(t,e,i)=>{i.r(e),i.d(e,{default:()=>g});var s=i(7361),n=i(6926);function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class a{constructor(t){this.worker=t,r(this,"requestStates",new Map),r(this,"requestStatesByCallback",new Map),this.subscribe()}request(t){const{worker:e,requestStates:i,requestStatesByCallback:s}=this,r=(0,n.Z)(i),a={type:"callMethod",messageId:r,...t},h={messageId:r},o=new Promise(((t,e)=>{Object.assign(h,{resolve:t,reject:e})}));if("function"==typeof a.args[a.args.length-1]){const t=a.args.pop();h.callback=t,s.set(t,h)}return i.set(r,h),o.catch((()=>{})).finally((()=>{i.delete(r),h.callback&&s.delete(h.callback)})),e.postMessage(a),o}cancelCallback(t){t.isCanceled=!0;const{messageId:e}=this.requestStatesByCallback.get(t)||{};e&&this.worker.postMessage({type:"cancelProgress",messageId:e})}subscribe(){const{worker:t,requestStates:e}=this;t.addEventListener("message",(({data:t})=>{if("methodResponse"===t.type){const i=e.get(t.messageId);i&&(t.error?i.reject(t.error):i.resolve(t.response))}else if("methodCallback"===t.type){const i=e.get(t.messageId);i&&i.callback&&i.callback(...t.callbackArgs)}else if("unhandledError"===t.type)throw t.error}))}}var h=i(9933),o=i(3570);function d(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const c=s.wB?.75:1,u=.75,m=s.s$?2:4,l=new Array(4).fill(void 0).map((()=>new a(new Worker(new URL(i.p+i.u(354),i.b)))));let p=-1;const g=class{constructor(t,e,i,s={},n){this.id=t,this.container=e,this.animationData=i,this.params=s,this.onLoad=n,d(this,"imgSize",void 0),d(this,"key",void 0),d(this,"msPerFrame",void 0),d(this,"reduceFactor",void 0),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(((e,i)=>i===t?e: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,e]){this.approxFrameIndex=Math.floor(t/this.reduceFactor),this.stopFrameIndex=Math.floor(e/this.reduceFactor),this.direction=t{if(this.isDestroyed)return!1;if(!this.isAnimating&&this.isOnLoadFired)return!1;const t=Math.round(this.approxFrameIndex),e=this.getChunkIndex(t);if(!this.chunks[e])return this.requestChunk(e),this.isAnimating=!1,this.isWaiting=!0,!1;if(this.cacheModulo&&e%this.cacheModulo==0&&this.cleanupPrevChunk(e),this.requestNextChunk(e),t!==this.prevFrameIndex){const e=this.getFrame(t);if(!e)return this.isAnimating=!1,this.isWaiting=!0,!1;const i=new ImageData(new Uint8ClampedArray(e),this.imgSize,this.imgSize);this.ctx.putImageData(i,0,0),this.onLoad&&!this.isOnLoadFired&&(this.isOnLoadFired=!0,this.onLoad()),this.prevFrameIndex=t}const i=Date.now(),s=this.lastRenderAt?this.msPerFrame/(i-this.lastRenderAt):1,n=Math.min(1,this.direction*this.speed/s),r=Math.round(this.approxFrameIndex+n);if(this.lastRenderAt=i,n>0&&(t===this.framesCount-1||r>this.framesCount-1)){if(this.params.noLoop)return this.isAnimating=!1,!1;this.approxFrameIndex=0}else if(n<0&&(0===t||r<0)){if(this.params.noLoop)return this.isAnimating=!1,!1;this.approxFrameIndex=this.framesCount-1}else{if(void 0!==this.stopFrameIndex&&(t===this.stopFrameIndex||n>0&&r>this.stopFrameIndex||n<0&&r{function s(t,e){return e-Math.floor(e/t)*t}i.d(e,{Z:()=>s})}}]); //# sourceMappingURL=941.74ee93d332e344855ed7.js.map