import{j as o}from"./97895ccd-eacb-468d-acaf-a05b0600c661.CCJ6x-uO.js";import{r as S}from"./fba659fd-141b-444a-9949-d1b1c9de2776.BGex24A5.js";import{u as B}from"./index.Bl5s3shC.js";import{aX as D,aZ as F,aW as M}from"./3eb9cf24-1295-46e2-aedf-f7224a9cf267.CiXsu8Tu.js";import{n as G}from"../../index.js";import"./deffac6f-6080-4634-a313-9a9c19cb05b9.C0Zqfgkc.js";import"./4c4f3386-b306-484e-9b07-c37143bd87f7.BexD02x3.js";import"./29195f33-83f4-4a9e-8d49-3174b1e2bbee.D2G3_5-M.js";import"./a68ba3ac-e057-4b8e-9d04-a24b0b99fdb5.-LVU_LFu.js";import"./1943e3b3-b854-4d0d-a6b7-6c00da964781.BNvKqlAS.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=B().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]})})},W=setInterval(function(){s!=="paused"&&I()},1e3);return function(){clearInterval(W),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};
