import{j as o,a_ as D,b0 as F,aZ as M}from"./dd6e34a1-2dce-4b2f-a506-c3a3a97e6a60.BtGh0rES.js";import{a as S}from"./f1826ddd-a2d8-4fce-af3d-c958dcb59062.CC2qRq32.js";import{u as W}from"./index.Dpnr-RGW.js";import{p as G}from"../../index.js";import"./bedc3458-6184-4e7f-bdf2-1a32ce9d7bc1.BX5SC7r6.js";import"./209d2e31-398d-4115-83ca-f4e360d8f14c.DB_X1qgl.js";import"./c4f8119f-a26b-4cdd-9922-48b96c4c3f7c.NIGUFBhG.js";import"./b7a206fb-30c2-4638-9063-0e98f38a14e0.CABIgbxA.js";import"./53ad9472-c185-4918-b159-c74d9c5aa814.ClFOar0Y.js";import"./67cae666-16ae-4928-a3d7-31b63441b60a.De5D-E6y.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};
