"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[417],{81417:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var n=r(23892),s=r(85848),l=r(66668);function i(e){let{samples:t,duration:r,currentTime:l,onSeek:i,height:a=80}=e,u=(0,s.useRef)(null),o=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(!u.current)return;let e=u.current,r=e.getContext("2d"),n=e.width,s=e.height;r.clearRect(0,0,n,s);let l=Math.floor(t.length/n);r.strokeStyle=getComputedStyle(e).getPropertyValue("--chart-default-fill").trim()||"#3b82f6",r.lineWidth=1.5,r.beginPath();for(let e=0;e<n;e++){let n=s/2*(1-(t[e*l]||0));0===e?r.moveTo(e,n):r.lineTo(e,n)}r.stroke(),r.strokeStyle="hsl(var(--border))",r.lineWidth=1,r.beginPath(),r.moveTo(0,s/2),r.lineTo(n,s/2),r.stroke()},[t]),(0,s.useEffect)(()=>{if(!o.current)return;let e=o.current,t=e.getContext("2d"),n=e.width,s=e.height;t.clearRect(0,0,n,s);let i=l/r*n;t.strokeStyle="red",t.lineWidth=2,t.beginPath(),t.moveTo(i,0),t.lineTo(i,s),t.stroke()},[r,l]),(0,n.jsxs)("div",{className:"w-full space-y-2",children:[(0,n.jsxs)("div",{className:"relative w-full cursor-pointer rounded overflow-hidden bg-muted/20 border border-border",style:{height:a},onClick:function(e){if(!u.current)return;let t=u.current.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*r;i(Math.max(0,Math.min(r,n)))},children:[(0,n.jsx)("canvas",{ref:u,width:800,height:a,className:"absolute inset-0 w-full h-full"}),(0,n.jsx)("canvas",{ref:o,width:800,height:a,className:"absolute inset-0 w-full h-full pointer-events-none"})]}),(0,n.jsx)("div",{className:"text-center text-sm text-muted-foreground",children:"Waveform"})]})}r(89116);var a=r(65102),u=r(70621),o=r(56211),d=r(18607);function c(e){let{audioUrl:t,autoPlay:r=!1}=e,c=(0,s.useRef)(null),[m,h]=(0,s.useState)(0),{audioData:f}=(0,u.s)(t),x=(0,d.uk)(t)||"Failed to get name",g=e=>{var t,r;(null==(r=c.current)||null==(t=r.audio)?void 0:t.current)&&(c.current.audio.current.currentTime=e)};return f?(0,n.jsxs)("div",{className:"p-4 w-full space-y-4",children:[(0,n.jsx)("div",{className:"flex items-center justify-between gap-4 px-2 py-1.5 bg-muted/30 rounded border border-border",children:(0,n.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,n.jsx)(o.A,{value:t,className:"shrink-0"}),(0,n.jsxs)("span",{className:"text-sm font-mono truncate text-muted-foreground",title:x,children:[x," •"]})]}),(0,n.jsx)("div",{className:"flex items-center gap-3 text-sm text-muted-foreground shrink-0",children:(0,n.jsxs)("span",{children:[f.duration.toFixed(2),"s"]})})]})}),(0,n.jsx)(l.A,{ref:c,src:t,autoPlay:r,autoPlayAfterSrcChange:!1,showJumpControls:!1,customAdditionalControls:[],layout:"horizontal-reverse",listenInterval:100,onListen:()=>{var e,t;(null==(t=c.current)||null==(e=t.audio)?void 0:e.current)&&h(c.current.audio.current.currentTime)}}),(0,n.jsx)(i,{samples:f.samples,duration:f.duration,currentTime:m,onSeek:g,height:80}),(0,n.jsx)(a.A,{samples:f.samples,duration:f.duration,currentTime:m,onSeek:g,height:180})]}):(0,n.jsx)("div",{className:"p-4 w-full flex items-center justify-center h-[500px]",children:(0,n.jsxs)("div",{className:"flex flex-col items-center space-y-3",children:[(0,n.jsx)("div",{className:"w-12 h-12 border-4 border-muted-foreground border-t-transparent rounded-full animate-spin"}),(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading audio..."})]})})}}}]);