import{j as o,a_ as D,b0 as F,aZ as M}from"./6abd3f6d-5915-464f-a3cb-3d9768f2f00b.DKbqw7xL.js";import{a as S}from"./ba47b11f-93c3-40d9-92d3-517b5cac37d2.DiKAzxfG.js";import{u as W}from"./index.tGFXcEwc.js";import{p as G}from"../../index.js";import"./3ed4cd0f-ec07-4e31-afc1-ce64ffcd5464.JPR2e1ux.js";import"./cd158c8f-89d5-4587-a0da-70a28122abb6.Cy8NaIIt.js";import"./ab0fa902-5fd7-4602-ba29-02cd60ac750c.B9ygI19o.js";import"./dcfdaf80-13ac-4e1c-8d28-18700a0c1a10.DgRnpLVA.js";import"./99e57599-182b-45aa-ad77-ab31b4543d77.CoxT2IFn.js";import"./4e27391c-200b-4f29-9b56-e5be298e1644.IOPnwoYa.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};
