"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[8673],{8673:(e,t,s)=>{s.r(t),s.d(t,{default:()=>S});var i=s(9822);function r(e,t){return t-Math.floor(t/e)*e}var a=s(9705),n=s(4235),o=s(1481),h=s(7836);function d(e,t,s){var i;return(t="symbol"==typeof(i=function(e,t){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var i=s.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(t))?i:i+"")in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class c{constructor(e,t,s){this.target=e,this.onUpdate=t,this.channel=s,d(this,"requestStates",new Map),d(this,"requestStatesByCallback",new Map),d(this,"pendingPayloads",[]),d(this,"pendingTransferables",[]),d(this,"postMessagesOnTickEnd",(0,h.Fe)((()=>{const{channel:e}=this,t=this.pendingPayloads,s=this.pendingTransferables;this.pendingPayloads=[],this.pendingTransferables=[],this.target.postMessage({channel:e,payloads:t},s)})))}destroy(){}init(){for(var e=arguments.length,t=new Array(e),s=0;s{Object.assign(h,{resolve:e,reject:t})}));if("function"==typeof o.args[o.args.length-1]){o.withCallback=!0;const e=o.args.pop();h.callback=e,s.set(e,h)}return t.set(a,h),d.catch((()=>{})).finally((()=>{t.delete(a),h.callback&&s.delete(h.callback)})),this.postMessageOnTickEnd(o,i),d}cancelCallback(e){e.isCanceled=!0;const{messageId:t}=this.requestStatesByCallback.get(e)||{};t&&this.postMessageOnTickEnd({type:"cancelProgress",messageId:t})}onMessage(e){const{requestStates:t,channel:s}=this;e.channel===s&&e.payloads.forEach((e=>{if("update"===e.type&&this.onUpdate&&this.onUpdate(e.update),"methodResponse"===e.type){const s=t.get(e.messageId);s&&(e.error?s.reject(e.error):s.resolve(e.response))}else if("methodCallback"===e.type){const s=t.get(e.messageId);s?.callback?.(...e.callbackArgs)}else if("unhandledError"===e.type)throw new Error(e.error?.message)}))}postMessageOnTickEnd(e,t){this.pendingPayloads.push(e),t&&this.pendingTransferables.push(...t),this.postMessagesOnTickEnd()}}const l=Math.min(navigator.hardwareConcurrency||4,4);let m;var g=s(2393),p=s(6644);function u(e,t,s){var i;return(t="symbol"==typeof(i=function(e,t){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var i=s.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(t))?i:i+"")in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const f=Symbol("WAITING"),v=g.Ni||g.pz?.75:1,y=g.Ni?.5:.75,w=24,x=g.Yw?2:4,I=(o.W75?[]:(m||(m=new Array(l).fill(void 0).map((()=>{const e=new Worker(new URL(s.p+s.u(2976),s.b)),t=function(e,t,s){const i=new c(e,void 0,"media");function r(e){let{data:t}=e;i.onMessage(t)}return e.addEventListener("message",r),i.destroy=()=>{e.removeEventListener("message",r)},i}(e);return{worker:e,connector:t}}))),m)).map((e=>{let{connector:t}=e;return t})),F=new Map,C=new WeakMap;let b=-1;class M{static init(){for(var e=arguments.length,t=new Array(e),s=0;s4&&void 0!==arguments[4]?arguments[4]:(0,n.A)(),a=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0,h=arguments.length>7?arguments[7]:void 0,d=arguments.length>8?arguments[8]:void 0;this.tgsUrl=e,this.container=t,this.renderId=s,this.params=i,this.customColor=a,this.onLoad=o,this.onEnded=h,this.onLoop=d,u(this,"views",new Map),u(this,"imgSize",void 0),u(this,"imageData",void 0),u(this,"msPerFrame",1e3/60),u(this,"reduceFactor",1),u(this,"cacheModulo",void 0),u(this,"workerIndex",void 0),u(this,"frames",[]),u(this,"framesCount",void 0),u(this,"isAnimating",!1),u(this,"isWaiting",!0),u(this,"isEnded",!1),u(this,"isDestroyed",!1),u(this,"isRendererInited",!1),u(this,"approxFrameIndex",0),u(this,"prevFrameIndex",-1),u(this,"stopFrameIndex",0),u(this,"speed",1),u(this,"direction",1),u(this,"lastRenderAt",void 0),this.addView(r,t,o,i.coords),this.initConfig(),this.initRenderer()}removeView(e){const{canvas:t,ctx:s,isSharedCanvas:i,coords:r}=this.views.get(e);i?s.clearRect(r.x,r.y,this.imgSize,this.imgSize):t.remove(),this.views.delete(e),this.views.size||this.destroy()}isPlaying(){return this.isAnimating||this.isWaiting}play(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0;t&&(this.views.get(t).isPaused=!1),this.isEnded&&e&&(this.approxFrameIndex=Math.floor(0)),this.stopFrameIndex=void 0,this.direction=1,this.doPlay()}pause(e){this.lastRenderAt=void 0,(!e||(this.views.get(e).isPaused=!0,Array.from(this.views.values()).every((e=>{let{isPaused:t}=e;return t}))))&&(this.isWaiting?this.stopFrameIndex=this.approxFrameIndex:this.isAnimating=!1,this.params.isLowPriority||(this.frames=this.frames.map(((e,t)=>t===this.prevFrameIndex?e:void(e&&e!==f&&e.close())))))}playSegment(e){let[t,s]=e,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0;r&&(this.views.get(r).isPaused=!1);const a=Math.round(this.approxFrameIndex);this.stopFrameIndex=Math.floor(s/this.reduceFactor),(a!==s||i)&&(this.approxFrameIndex=Math.floor(t/this.reduceFactor)),this.direction=t{i.dataset.isJustCleaned="false"}))}s.coords={x:Math.round((t?.x||0)*n),y:Math.round((t?.y||0)*o)};const h=this.getFrame(this.prevFrameIndex)||this.getFrame(Math.round(this.approxFrameIndex));h&&h!==f&&r.drawImage(h,s.coords.x,s.coords.y)}addView(e,t,s,i){const r=this.calcSizeFactor();let a;if(t instanceof HTMLDivElement){if(!(t.parentNode instanceof HTMLElement))throw new Error("[RLottie] Container is not mounted");const{size:i}=this.params;a=Math.round(i*r),this.imgSize||(this.imgSize=a,this.imageData=new ImageData(a,a)),(0,p.RK)((()=>{const r=document.createElement("canvas"),n=r.getContext("2d");r.classList.add("rlottie-canvas"),r.style.width=`${i}px`,r.style.height=`${i}px`,r.width=a,r.height=a,t.appendChild(r),this.views.set(e,{canvas:r,ctx:n,onLoad:s})}))}else{if(!t.isConnected)throw new Error("[RLottie] Shared canvas is not mounted");const n=t,o=n.getContext("2d");a=Math.round(this.params.size*r),this.imgSize||(this.imgSize=a,this.imageData=new ImageData(a,a));const[h,d]=P(n,r);this.views.set(e,{canvas:n,ctx:o,isSharedCanvas:!0,coords:{x:Math.round(i.x*h),y:Math.round(i.y*d)},onLoad:s})}this.isRendererInited&&this.doPlay()}calcSizeFactor(){const{size:e,isLowPriority:t,quality:s=(t&&(!e||e>w)?y:v)}=this.params;return Math.max(window.devicePixelRatio*s,1)}destroy(){this.isDestroyed=!0,this.pause(),this.clearCache(),this.destroyRenderer(),F.delete(this.renderId)}clearCache(){this.frames.forEach((e=>{e&&e!==f&&e.close()})),this.imageData=void 0,this.frames=[]}initConfig(){const{isLowPriority:e}=this.params;this.cacheModulo=e?0:x}setColor(e){this.customColor=e}initRenderer(){this.workerIndex=r(l,++b),I[this.workerIndex].request({name:"rlottie:init",args:[this.renderId,this.tgsUrl,this.imgSize,this.params.isLowPriority||!1,this.customColor,this.onRendererInit.bind(this)]})}destroyRenderer(){I[this.workerIndex].request({name:"rlottie:destroy",args:[this.renderId]})}onRendererInit(e,t,s){this.isRendererInited=!0,this.reduceFactor=e,this.msPerFrame=t,this.framesCount=s,this.isWaiting&&this.doPlay()}changeData(e){this.pause(),this.tgsUrl=e,this.initConfig(),I[this.workerIndex].request({name:"rlottie:changeData",args:[this.renderId,this.tgsUrl,this.params.isLowPriority||!1,this.onChangeData.bind(this)]})}onChangeData(e,t,s){this.reduceFactor=e,this.msPerFrame=t,this.framesCount=s,this.isWaiting=!1,this.isAnimating=!1,this.doPlay()}doPlay(){this.framesCount&&(this.isDestroyed||this.isAnimating||(this.isWaiting||(this.lastRenderAt=void 0),this.isEnded=!1,this.isAnimating=!0,this.isWaiting=!1,(0,i.i0)((()=>{if(this.isDestroyed)return!1;if(!this.isAnimating&&Array.from(this.views.values()).every((e=>{let{isLoaded:t}=e;return t})))return!1;const e=Math.round(this.approxFrameIndex),t=this.getFrame(e);if(!t||t===f)return t||this.requestFrame(e),this.isAnimating=!1,this.isWaiting=!0,!1;this.cacheModulo&&e%this.cacheModulo==0&&this.cleanupPrevFrame(e),e!==this.prevFrameIndex&&(this.views.forEach((e=>{const{ctx:s,isLoaded:i,isPaused:r,coords:{x:a,y:n}={},onLoad:o}=e;i&&r||(s.clearRect(a||0,n||0,this.imgSize,this.imgSize),s.drawImage(t,a||0,n||0)),i||(e.isLoaded=!0,o?.())})),this.prevFrameIndex=e);const s=Date.now(),i=this.lastRenderAt?this.msPerFrame/(s-this.lastRenderAt):1,r=this.direction*this.speed/i,a=Math.round(this.approxFrameIndex+r);if(this.lastRenderAt=s,r>0&&(e===this.framesCount-1||a>this.framesCount-1)){if(this.params.noLoop)return this.isAnimating=!1,this.isEnded=!0,this.onEnded?.(),!1;this.onLoop?.(),this.approxFrameIndex=0}else if(r<0&&(0===e||a<0)){if(this.params.noLoop)return this.isAnimating=!1,this.isEnded=!0,this.onEnded?.(),!1;this.onLoop?.(),this.approxFrameIndex=this.framesCount-1}else{if(void 0!==this.stopFrameIndex&&(e===this.stopFrameIndex||r>0&&a>this.stopFrameIndex||r<0&&a{e.width=s,e.height=i,t.resolve()}))}return[s,i]}const S=M}}]); //# sourceMappingURL=8673.1b6dd8d303b0535cc1f8.js.map