"use strict";(self.webpackChunkparsizteb=self.webpackChunkparsizteb||[]).push([[457],{17457:(e,t,r)=>{r.d(t,{LiveAudioVisualizer:()=>l});var n,o=r(65043),s={exports:{}},a={};s.exports=function(){if(n)return a;n=1;var e=o,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,r,n){var o,a={},c=null,u=null;for(o in void 0!==n&&(c=""+n),void 0!==r.key&&(c=""+r.key),void 0!==r.ref&&(u=r.ref),r)s.call(r,o)&&!l.hasOwnProperty(o)&&(a[o]=r[o]);if(e&&e.defaultProps)for(o in r=e.defaultProps)void 0===a[o]&&(a[o]=r[o]);return{$$typeof:t,type:e,key:c,ref:u,props:a,_owner:i.current}}return a.Fragment=r,a.jsx=c,a.jsxs=c,a}();var i=s.exports;const l=e=>{let{mediaRecorder:t,width:r="100%",height:n="100%",barWidth:s=2,gap:a=1,backgroundColor:l="transparent",barColor:c="rgb(160, 198, 255)",fftSize:u=1024,maxDecibels:f=-10,minDecibels:h=-90,smoothingTimeConstant:d=.4}=e;const[p]=(0,o.useState)((()=>new AudioContext)),[g,m]=(0,o.useState)(),y=(0,o.useRef)(null);(0,o.useEffect)((()=>{if(!t.stream)return;const e=p.createAnalyser();m(e),e.fftSize=u,e.minDecibels=h,e.maxDecibels=f,e.smoothingTimeConstant=d,p.createMediaStreamSource(t.stream).connect(e)}),[t.stream]),(0,o.useEffect)((()=>{(null!=g?g:"recording"===t.state)&&b()}),[g,t.state]);const b=(0,o.useCallback)((()=>{if(!g)return;const e=new Uint8Array(null==g?void 0:g.frequencyBinCount);"recording"===t.state?(null==g||g.getByteFrequencyData(e),_(e),requestAnimationFrame(b)):"paused"===t.state?_(e):"inactive"===t.state&&"closed"!==p.state&&p.close()}),[g]),_=e=>{if(!y.current)return;const t=((e,t,r,n)=>{let o=t/(r+n),s=Math.floor(e.length/o);o>e.length&&(o=e.length,s=1);const a=[];for(let i=0;i<o;i++){let t=0;for(let r=0;r<s&&i*s+r<e.length;r++)t+=e[i*s+r];a.push(t/s)}return a})(e,y.current.width,s,a);((e,t,r,n,o,s)=>{const a=t.height/2,i=t.getContext("2d");i&&(i.clearRect(0,0,t.width,t.height),"transparent"!==o&&(i.fillStyle=o,i.fillRect(0,0,t.width,t.height)),e.forEach(((e,t)=>{i.fillStyle=s;const o=t*(r+n),l=a-e/2,c=r,u=e||1;i.beginPath(),i.roundRect(o,l,c,u,50),i.fill()})))})(t,y.current,s,a,l,c)};return i.jsx("canvas",{ref:y,width:r,height:n,style:{aspectRatio:"unset"}})}}}]);
//# sourceMappingURL=457.c5aaa0ad.chunk.js.map