import{j as o,a_ as D,b0 as F,aZ as M}from"./63ff95b2-66eb-44bc-9357-13bf0b6d2fdf.BR30HtGv.js";import{a as S}from"./fbeaa824-f437-454f-ac47-7e24750bb32e.CC2qRq32.js";import{u as W}from"./index.jk7Nhd-O.js";import{p as G}from"../../index.js";import"./a62532da-bf11-485a-a43d-6a7b59b6a676.BVMidMd3.js";import"./5d669d12-c308-4594-b591-ef72fd34318c.CXmqblNO.js";import"./c415272e-9906-47be-a8c5-650457d64658.NIGUFBhG.js";import"./eb66d478-621e-4013-9b4f-c75719438dea.Cd_XWJzp.js";import"./c547856f-5009-45d1-bf41-7fccaf12121a.CfuHre9V.js";import"./d09e2553-bdd0-4775-8cad-0ef1791a1348.Dy-I0Pa_.js";var O=function(f,v,t,c){function n(r){return r instanceof t?r:new t(function(a){a(r)})}return new(t||(t=Promise))(function(r,a){function l(i){try{e(c.next(i))}catch(m){a(m)}}function s(i){try{e(c.throw(i))}catch(m){a(m)}}function e(i){i.done?r(i.value):n(i.value).then(l,s)}e((c=c.apply(f,v||[])).next())})},P=function(f,v){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},c,n,r,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(e){return function(i){return s([e,i])}}function s(e){if(c)throw new TypeError("Generator is already executing.");for(;a&&(a=0,e[0]&&(t=0)),t;)try{if(c=1,n&&(r=e[0]&2?n.return:e[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,e[1])).done)return r;switch(n=0,r&&(e=[e[0]&2,r.value]),e[0]){case 0:case 1:r=e;break;case 4:return t.label++,{value:e[1],done:!1};case 5:t.label++,n=e[1],e=[0];continue;case 7:e=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(e[0]===6||e[0]===2)){t=0;continue}if(e[0]===3&&(!r||e[1]>r[0]&&e[1]<r[3])){t.label=e[1];break}if(e[0]===6&&t.label<r[1]){t.label=r[1],r=e;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(e);break}r[2]&&t.ops.pop(),t.trys.pop();continue}e=v.call(f,t)}catch(i){e=[6,i],n=0}finally{c=r=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}};function $(f){var v=this,t=f.id,c=W().getContainer,n=c(t)(),r=n.stopRecording,a=n.resumeRecording,l=n.pauseRecording,s=n.recordingStatus,e=n.stream,i=n.timer,m=n.finalizarRecording,C=S.useRef(null);S.useEffect(function(){if(e){var h=new AudioContext,d=h.createAnalyser();d.fftSize=512;var y=d.frequencyBinCount,R=new Uint8Array(y),z=h.createMediaStreamSource(e);z.connect(d);var b=C.current,u=b.getContext("2d");if(u){var w=b.width,g=b.height,T=12,N=getComputedStyle(document.documentElement),E=N.getPropertyValue("--audio-control-incoming").trim(),I=function(){return O(v,void 0,void 0,function(){var _,x,p,k,j;return P(this,function(q){for(d.getByteTimeDomainData(R),u.clearRect(0,0,w,g),u.lineWidth=2,u.strokeStyle=E,u.beginPath(),_=w*1/y,x=0,p=0;p<y;p++)k=(R[p]-128)/128,j=k*g/2*T+g/2,p===0?u.moveTo(x,j):u.lineTo(x,j),x+=_;return u.lineTo(w,g/2),u.stroke(),[2]})})},B=setInterval(function(){s!=="paused"&&I()},1e3);return function(){clearInterval(B),h.close()}}}},[e,s]);function A(){var h=Math.floor(i/60),d=i%60;return"".concat(h,":").concat(d<10?"0":"").concat(d)}return o.jsxs("div",{className:"flex gap-2 items-center w-fit p-2 border border-solid border-[var(--conversation-header-border)] m-auto mb-2 rounded-lg bg-[var(--background-default)]",children:[o.jsx("div",{className:"cursor-pointer pulse",onClick:r,children:o.jsx(D,{size:16})}),o.jsx("div",{className:"flex text-[var(--audio-progress-metadata)]",children:o.jsx("span",{children:A()})}),o.jsx("div",{children:o.jsx("canvas",{ref:C,width:112,height:"25"})}),s==="recording"&&o.jsx("div",{className:"cursor-pointer pulse text-red-500",onClick:l,children:o.jsx(F,{size:18})}),s==="paused"&&o.jsx("div",{className:"cursor-pointer pulse text-red-500",onClick:a,children:o.jsx(M,{size:18})}),s!=="paused"&&o.jsx("div",{className:"cursor-pointer pulse text-green-500",onClick:m,children:o.jsx(G,{size:18})})]})}export{$ as default};
