PageSourceSearch

https://earo.ai/_next/static/chunks/0e21q2-60_3ph.js

js earo.ai collected 2026-10-05 13:43:00 UTC 47,145 bytes, 75 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,71796,t=>{"use strict";var e=t.i(43476),i=t.i(59544),r=t.i(75157),s=t.i(37727),n=t.i(71645),a=t.i(19477);let o=(0,n.createContext)(null);t.s(["ShareModalProvider",0,function({children:t}){let[l,h]=(0,n.useState)(!1),[u,d]=(0,n.useState)(null),[c,p]=(0,n.useState)(!1),[m,g]=(0,n.useState)(null),f=(0,n.useCallback)(()=>{h(!1),d(null),p(!1),g(null)},[]),v=(0,n.useCallback)(t=>{d(t),p(!1),g(null),h(!0)},[]);(0,n.useEffect)(()=>{if(!l)return;let t=t=>{"Escape"===t.key&&f()};document.addEventListener("keydown",t);let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",t),document.body.style.overflow=e}},[l,f]);let b=t=>{var e,i;let r,s;return u?.jobId?(e=u.jobId,i=u.recommendedVersion||"1",r=window.location?.origin?window.location.origin:"http://localhost:5001",s=new URLSearchParams({v:"2",recommendedVersion:i,utm_source:t,utm_medium:"share",utm_campaign:"ad_share"}),`${r}/share/${encodeURIComponent(e)}?${s.toString()}`):""},y=t=>`Hey, check out this audio ad. It took me 5 minutes to make. Should run with it? 
2${b(t)}`,x=async()=>{let t=b("copy_link");if(t){g(null);try{await navigator.clipboard.writeText(t),p(!0),(0,a.trackShareAd)({method:"copy_link",jobId:u?.jobId,adName:u?.adName}),setTimeout(()=>p(!1),1200)}catch{g("Couldn't copy. Please select and copy the link manually.")}}},C=(0,n.useMemo)(()=>({openShareModal:v,closeShareModal:f}),[v,f]);return(0,e.jsxs)(o.Provider,{value:C,children:[t,l&&u?.jobId&&(0,e.jsxs)("div",{className:"fixed inset-0 z-[210] flex items-center justify-center p-4",role:"dialog","aria-modal":"true","aria-labelledby":"share-modal-title",children:[(0,e.jsx)("button",{type:"button",className:"absolute inset-0 bg-black/50","aria-label":"Close",onClick:f}),(0,e.jsxs)("div",{className:"relative w-full max-w-[520px] rounded-[20px] bg-white p-6 md:p-8 shadow-xl border border-[#E5E7EB]",children:[(0,e.jsx)("button",{type:"button",onClick:f,className:"absolute top-4 end-4 rounded-lg p-2 text-[#6B7280] hover:bg-[#F3F4F6] hover:text-[#111827] transition-colors","aria-label":"Close",children:(0,e.jsx)(s.X,{className:"w-5 h-5",strokeWidth:2})}),(0,e.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("h2",{id:"share-modal-title",className:"text-[#111827] font-bold text-[22px] leading-tight tracking-[-0.02em]",children:"Share your ad"}),(0,e.jsx)("p",{className:"text-[#6B7280] text-sm md:text-base font-[450]",children:"Share this unique link. Anyone with the link can open it."})]}),m&&(0,e.jsx)("p",{className:"text-[#B91C1C] text-sm font-medium",role:"alert",children:m}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,e.jsx)("a",{className:(0,r.cn)((0,i.buttonVariants)({variant:"primary",size:"md"}),"md:hidden"),href:`https://wa.me/?text=${encodeURIComponent(y("whatsapp"))}`,target:"_blank",rel:"noreferrer",onClick:()=>(0,a.trackShareAd)({method:"whatsapp",jobId:u?.jobId,adName:u?.adName}),children:"WhatsApp"}),(0,e.jsx)("a",{className:(0,r.cn)((0,i.buttonVariants)({variant:"secondary",size:"md"}),"hidden md:inline-flex"),href:`https://wa.me/?text=${encodeURIComponent(y("whatsapp"))}`,target:"_blank",rel:"noreferrer",onClick:()=>(0,a.trackShareAd)({method:"whatsapp",jobId:u?.jobId,adName:u?.adName}),children:"WhatsApp"}),(0,e.jsx)("a",{className:(0,r.cn)((0,i.buttonVariants)({variant:"secondary",size:"md"})),href:`mailto:?subject=${encodeURIComponent(u?.adName?.trim()?`Ad: ${u.adName}`:"My ad")}&body=${encodeURIComponent(y("email"))}`,onClick:()=>(0,a.trackShareAd)({method:"email",jobId:u?.jobId,adName:u?.adName}),children:"Email"}),(0,e.jsx)("button",{type:"button",className:(0,r.cn)((0,i.buttonVariants)({variant:"secondary",size:"md"}),"md:hidden"),onClick:x,children:c?"Copied":"Copy link"}),(0,e.jsx)("button",{type:"button",className:(0,r.cn)((0,i.buttonVariants)({variant:"primary",size:"md"}),"hidden md:inline-flex"),onClick:x,children:c?"Copied":"Copy link"})]})]})]})]})]})},"useShareModal",0,function(){let t=(0,n.useContext)(o);if(!t)throw Error("useShareModal must be used within ShareModalProvider");return t},"useShareModalOptional",0,function(){return(0,n.useContext)(o)}])},6716,t=>{"use strict";var e=t.i(43476),i=t.i(98871);t.i(47167);let r=new Set;var s=t.i(75157),n=t.i(19477),a=t.i(71645);
2function o(t,e,i,r){return new(i||(i=Promise))(function(s,n){function a(t){try{l(r.next(t))}catch(t){n(t)}}function o(t){try{l(r.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?s(t.value):((e=t.value)instanceof i?e:new i(function(t){t(e)})).then(a,o)}l((r=r.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class l{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),null==i?void 0:i.once){let i=(...r)=>{this.un(t,i),e(...r)};return this.listeners[t].add(i),()=>this.un(t,i)}return this.listeners[t].add(e),()=>this.un(t,e)}un(t,e){var i;null==(i=this.listeners[t])||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(t=>t(...e))}}let h={decode:function(t,e){return o(this,void 0,void 0,function*(){let i=new AudioContext({sampleRate:e});try{return yield i.decodeAudioData(t)}finally{i.close()}})},createBuffer:function(t,e){if(!t||0===t.length)throw Error("channelData must be a non-empty array");if(e<=0)throw Error("duration must be greater than 0");if("number"==typeof t[0]&&(t=[t]),!t[0]||0===t[0].length)throw Error("channelData must contain non-empty channel arrays");!function(t){let e=t[0];if(e.some(t=>t>1||t<-1)){let i=e.length,r=0;for(let t=0;t<i;t++){let i=Math.abs(e[t]);i>r&&(r=i)}for(let e of t)for(let t=0;t<i;t++)e[t]/=r}}(t);let i=t.map(t=>t instanceof Float32Array?t:Float32Array.from(t));return{duration:e,length:i[0].length,sampleRate:i[0].length/e,numberOfChannels:i.length,getChannelData:t=>{let e=i[t];if(!e)throw Error(`Channel ${t} not found`);return e},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function u(t,e,i){let r=function t(e,i){let r=i.xmlns?document.createElementNS(i.xmlns,e):document.createElement(e);for(let[e,s]of Object.entries(i))if("children"===e&&s)for(let[e,i]of Object.entries(s))i instanceof Node?r.appendChild(i):"string"==typeof i?r.appendChild(document.createTextNode(i)):r.appendChild(t(e,i));else"style"===e?Object.assign(r.style,s):"textContent"===e?r.textContent=s:r.setAttribute(e,s.toString());return r}(t,e||{});return null==i||i.appendChild(r),r}var d=Object.freeze({__proto__:null,createElement:u,default:u});let c={fetchBlob:function(t,e,i){return o(this,void 0,void 0,function*(){let r=yield fetch(t,i);if(r.status>=400)throw Error(`Failed to fetch ${t}: ${r.status} (${r.statusText})`);return function(t,e){o(this,void 0,void 0,function*(){if(!t.body||!t.headers)return;let i=t.body.getReader(),r=Number(t.headers.get("Content-Length"))||0,s=0,n=t=>{e(Math.round((s+=(null==t?void 0:t.length)||0)/r*100))};try{for(;;){let t=yield i.read();if(t.done)break;n(t.value)}}catch(t){console.warn("Progress tracking error:",t)}})}(r.clone(),e),r.blob()})}};function p(t){let e=t,i=new Set;return{get value(){return e},set(t){Object.is(e,t)||(e=t,i.forEach(t=>t(e)))},update(t){this.set(t(e))},subscribe:t=>(i.add(t),()=>i.delete(t))}}function m(t,e){let i=p(t());return e.forEach(e=>e.subscribe(()=>{let e=t();Object.is(i.value,e)||i.set(e)})),{get value(){return i.value},subscribe:t=>i.subscribe(t)}}function g(t,e){let i,r=()=>{i&&(i(),i=void 0),i=t()},s=e.map(t=>t.subscribe(r));return r(),()=>{i&&(i(),i=void 0),s.forEach(t=>t())}}class f extends l{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(t){super(),this.isExternalMedia=!1,this.reactiveMediaEventCleanups=[],t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),this._isPlaying=p(!1),this._currentTime=p(0),this._duration=p(0),this._volume=p(this.media.volume),this._muted=p(this.media.muted),this._playbackRate=p(this.media.playbackRate||1),this._seeking=p(!1),this.setupReactiveMediaEvents(),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),null!=t.playbackRate&&this.onMediaEvent("canplay",()=>{null!=t.playbackRate&&(this.media.playbackRate=t.playbackRate)},{once:!0})}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",()=>{this._isPlaying.set(!0)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",()=>{this._isPlaying.set(!1)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",()=>{this._isPlaying.set(!1)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",()=>{this._currentTime.set(this.media.currentTime)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",()=>{this._duration.set(this.media.duration||0)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",()=>{this._duration.set(this.media.duration||0)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",()=>{this._seeking.set(!0)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",()=>{this._seeking.set(!1)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",()=>{this._volume.set(this.media.volume),this._muted.set(this.media.muted)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",()=>{this._playbackRate.set(this.media.playbackRate)}))}onMediaEvent(t,e,i){return this.media.addEventListener(t,e,i),()=>this.media.removeEventListener(t,e,i)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){let t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return""!==this.media.canPlayType(t)}setSrc(t,e){let i=this.getSrc();if(t&&i===t)return;this.revokeSrc();let r=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;if(i&&this.media.removeAttribute("src"),r||t)try{this.media.src=r}catch(e){this.media.src=t}}destroy(){this.reactiveMediaEventCleanups.forEach(t=>t()),this.reactiveMediaEventCleanups=[],this.isExternalMedia||(this.media.pause(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load(),this.media.remove())}setMediaElement(t){this.reactiveMediaEventCleanups.forEach(t=>t()),this.reactiveMediaEventCleanups=[],this.media=t,this.setupReactiveMediaEvents()}play(){return o(this,void 0,void 0,function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;throw t}})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,e){null!=e&&(this.media.preservesPitch=e),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}
2function v(t,e,i){let r=e-t.left,s=i-t.top;return[r/t.width,s/t.height]}function b(t){return!!(t.barWidth||t.barGap||t.barAlign)}function y(t,e){if(!b(e))return t;let i=e.barWidth||.5,r=i+(e.barGap||i/2);return 0===r?t:Math.floor(t/r)*r}function x({scrollLeft:t,totalWidth:e,numCanvases:i}){if(0===e)return[0];let r=Math.floor(t/e*i);return[r-1,r,r+1]}function C(t){let e=t._cleanup;"function"==typeof e&&e()}class S extends l{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.dragStream=null,this.scrollStream=null,this.subscriptions=[],this.options=t;const i=this.parentFromOptionsContainer(t.container);this.parent=i;const[r,s]=this.initHtml();i.appendChild(r),this.container=r,this.scrollContainer=s.querySelector(".scroll"),this.wrapper=s.querySelector(".wrapper"),this.canvasWrapper=s.querySelector(".canvases"),this.progressWrapper=s.querySelector(".progress"),this.cursor=s.querySelector(".cursor"),e&&s.appendChild(e),this.initEvents()}parentFromOptionsContainer(t){let e;if("string"==typeof t?e=document.querySelector(t):t instanceof HTMLElement&&(e=t),!e)throw Error("Container not found");return e}initEvents(){var t;let e,i,r,s;this.wrapper.addEventListener("click",t=>{let[e,i]=v(this.wrapper.getBoundingClientRect(),t.clientX,t.clientY);this.emit("click",e,i)}),this.wrapper.addEventListener("dblclick",t=>{let[e,i]=v(this.wrapper.getBoundingClientRect(),t.clientX,t.clientY);this.emit("dblclick",e,i)}),!0!==this.options.dragToSeek&&"object"!=typeof this.options.dragToSeek||this.initDrag(),this.scrollStream=(i=m(()=>(function(t){let{scrollLeft:e,scrollWidth:i,clientWidth:r}=t;return 0===i?{startX:0,endX:1}:{startX:Math.max(0,Math.min(1,e/i)),endX:Math.max(0,Math.min(1,(e+r)/i))}})(e.value),[e=p({scrollLeft:(t=this.scrollContainer).scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})]),r=m(()=>{var t;return{left:(t=e.value).scrollLeft,right:t.scrollLeft+t.clientWidth}},[e]),s=()=>{e.set({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})},t.addEventListener("scroll",s,{passive:!0}),{scrollData:e,percentages:i,bounds:r,cleanup:()=>{t.removeEventListener("scroll",s),C(e)}});let n=g(()=>{let{startX:t,endX:e}=this.scrollStream.percentages.value,{left:i,right:r}=this.scrollStream.bounds.value;this.emit("scroll",t,e,i,r)},[this.scrollStream.percentages,this.scrollStream.bounds]);if(this.subscriptions.push(n),"function"==typeof ResizeObserver){let t=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{t().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){let t=this.parent.clientWidth;t===this.lastContainerWidth&&"auto"!==this.options.height||(this.lastContainerWidth=t,this.reRender(),this.emit("resize"))}initDrag(){if(this.dragStream)return;this.dragStream=function(t,e={}){let{threshold:i=3,mouseButton:r=0,touchDelay:s=100}=e,n=p(null),a=new Map,o=matchMedia("(pointer: coarse)").matches,l=()=>{},h=e=>{if(e.button!==r||(a.set(e.pointerId,e),a.size>1))return;let h=e.clientX,u=e.clientY,d=!1,c=Date.now(),{left:p,top:m}=t.getBoundingClientRect(),g=t=>{if(t.defaultPrevented||a.size>1||o&&Date.now()-c<s)return;let e=t.clientX,r=t.clientY,l=e-h,g=r-u;(d||Math.abs(l)>i||Math.abs(g)>i)&&(t.preventDefault(),t.stopPropagation(),d||(n.set({type:"start",x:h-p,y:u-m}),d=!0),n.set({type:"move",x:e-p,y:r-m,deltaX:l,deltaY:g}),h=e,u=r)},f=t=>{if(a.delete(t.pointerId),d){let e=t.clientX,i=t.clientY;n.set({type:"end",x:e-p,y:i-m})}l()},v=t=>{a.delete(t.pointerId),t.relatedTarget&&t.relatedTarget!==document.documentElement||f(t)},b=t=>{d&&(t.stopPropagation(),t.preventDefault())},y=t=>{t.defaultPrevented||a.size>1||d&&t.preventDefault()};document.addEventListener("pointermove",g),document.addEventListener("pointerup",f),document.addEventListener("pointerout",v),document.addEventListener("pointercancel",v),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("click",b,{capture:!0}),l=()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",f),document.removeEventListener("pointerout",v),document.removeEventListener("pointercancel",v),document.removeEventListener("touchmove",y),setTimeout(()=>{document.removeEventListener("click",b,{capture:!0})},10)}};return t.addEventListener("pointerdown",h),{signal:n,cleanup:()=>
2{l(),t.removeEventListener("pointerdown",h),a.clear(),C(n)}}}(this.wrapper);let t=g(()=>{var t;let e=this.dragStream.signal.value;if(!e)return;let i=this.wrapper.getBoundingClientRect().width,r=(t=e.x/i)<0?0:t>1?1:t;"start"===e.type?(this.isDragging=!0,this.emit("dragstart",r)):"move"===e.type?this.emit("drag",r):"end"===e.type&&(this.isDragging=!1,this.emit("dragend",r))},[this.dragStream.signal]);this.subscriptions.push(t)}initHtml(){let t=document.createElement("div"),e=t.attachShadow({mode:"open"}),i=this.options.cspNonce&&"string"==typeof this.options.cspNonce?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=`
3      <style${i?` nonce="${i}"`:""}>
4        :host {
5          user-select: none;
6          min-width: 1px;
7        }
8        :host audio {
9          display: block;
10          width: 100%;
11        }
12        :host .scroll {
13          overflow-x: auto;
14          overflow-y: hidden;
15          width: 100%;
16          position: relative;
17        }
18        :host .noScrollbar {
19          scrollbar-color: transparent;
20          scrollbar-width: none;
21        }
22        :host .noScrollbar::-webkit-scrollbar {
23          display: none;
24          -webkit-appearance: none;
25        }
26        :host .wrapper {
27          position: relative;
28          overflow: visible;
29          z-index: 2;
30        }
31        :host .canvases {
32          min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;
33          pointer-events: none;
34        }
35        :host .canvases > div {
36          position: relative;
37        }
38        :host canvas {
39          display: block;
40          position: absolute;
41          top: 0;
42          image-rendering: pixelated;
43        }
44        :host .progress {
45          pointer-events: none;
46          position: absolute;
47          z-index: 2;
48          top: 0;
49          left: 0;
50          width: 0;
51          height: 100%;
52          overflow: hidden;
53        }
54        :host .progress > div {
55          position: relative;
56        }
57        :host .cursor {
58          pointer-events: none;
59          position: absolute;
60          z-index: 5;
61          top: 0;
62          left: 0;
63          height: 100%;
64          border-radius: 2px;
65        }
66      </style>
67
68      <div class="scroll" part="scroll">
69        <div class="wrapper" part="wrapper">
70          <div class="canvases" part="canvases"></div>
71          <div class="progress" part="progress"></div>
72          <div class="cursor" part="cursor"></div>
73        </div>
74      </div>
75    `,[t,e]}setOptions(t){var e;if(this.options.container!==t.container){let e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}!0===t.dragToSeek||"object"==typeof this.options.dragToSeek?this.initDrag():(null==(e=this.dragStream)||e.cleanup(),this.dragStream=null),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){let{scrollWidth:e}=this.scrollContainer;this.setScroll(e*t)}destroy(){var t;this.subscriptions.forEach(t=>t()),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),null==(t=this.unsubscribeOnScroll)||t.forEach(t=>t()),this.unsubscribeOnScroll=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}createDelay(t=10){let e,i,r=()=>{e&&(clearTimeout(e),e=void 0),i&&(i(),i=void 0)};return this.timeouts.push(r),()=>new Promise((s,n)=>{r(),i=n,e=setTimeout(()=>{e=void 0,i=void 0,s()},t)})}getHeight(t,e){var i;let r=(null==(i=this.audioData)?void 0:i.numberOfChannels)||1;return function({optionsHeight:t,optionsSplitChannels:e,parentHeight:i,numberOfChannels:r,defaultHeight:s=128}){if(null==t)return s;let n=Number(t);if(!isNaN(n))return n;if("auto"===t){let t=i||s;return(null==e?void 0:e.every(t=>!t.overlay))?t/r:t}return s}({optionsHeight:t,optionsSplitChannels:e,parentHeight:this.parent.clientHeight,numberOfChannels:r,defaultHeight:128})}convertColorValues(t,e){return function(t,e,i){if(!Array.isArray(t))return t||"";if(0===t.length)return"#999";if(t.length<2)return t[0]||"";let r=document.createElement("canvas"),s=r.getContext("2d"),n=null!=i?i:r.height*e,a=s.createLinearGradient(0,0,0,n||e),o=1/(t.length-1);return t.forEach((t,e)=>{a.addColorStop(e*o,t)}),a}(t,this.getPixelRatio(),null==e?void 0:e.canvas.height)}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,e,i,r){let{width:s,height:n}=i.canvas,{halfHeight:a,barWidth:o,barRadius:l,barIndexScale:h,barSpacing:u,barMinHeight:d}=function({width:t,height:e,length:i,options:r,pixelRatio:s}){let n=r.barWidth?r.barWidth*s:1,a=r.barGap?r.barGap*s:r.barWidth?n/2:0,o=n+a||1;return{halfHeight:e/2,barWidth:n,barGap:a,barRadius:r.barRadius||0,barMinHeight:r.barMinHeight?r.barMinHeight*s:0,barIndexScale:i>0?t/o/i:0,barSpacing:o}}({width:s,height:n,length:(t[0]||[]).length,options:e,pixelRatio:this.getPixelRatio()}),c=function({channelData:t,barIndexScale:e,barSpacing:i,barWidth:r,halfHeight:s,vScale:n,canvasHeight:a,barAlign:o,barMinHeight:l}){let h=t[0]||[],u=t[1]||h,d=h.length,c=[],p=0,m=0,g=0;for(let t=0;t<=d;t++){let d=Math.round(t*e);if(d>p){let{topHeight:t,totalHeight:e}=function({maxTop:t,maxBottom:e,halfHeight:i,vScale:r,barMinHeight:s=0,barAlign:n}){let a=Math.round(t*i*r),o=a+Math.round(e*i*r)||1;return o<s&&(o=s,n||(a=o/2)),{topHeight:a,totalHeight:o}}
75({maxTop:m,maxBottom:g,halfHeight:s,vScale:n,barMinHeight:l,barAlign:o}),h=function({barAlign:t,halfHeight:e,topHeight:i,totalHeight:r,canvasHeight:s}){return"top"===t?0:"bottom"===t?s-r:e-i}({barAlign:o,halfHeight:s,topHeight:t,totalHeight:e,canvasHeight:a});c.push({x:p*i,y:h,width:r,height:e}),p=d,m=0,g=0}let f=Math.abs(h[t]||0),v=Math.abs(u[t]||0);f>m&&(m=f),v>g&&(g=v)}return c}({channelData:t,barIndexScale:h,barSpacing:u,barWidth:o,halfHeight:a,vScale:r,canvasHeight:n,barAlign:e.barAlign,barMinHeight:d});for(let t of(i.beginPath(),c))l&&"roundRect"in i?i.roundRect(t.x,t.y,t.width,t.height,l):i.rect(t.x,t.y,t.width,t.height);i.fill(),i.closePath()}renderLineWaveform(t,e,i,r){let{width:s,height:n}=i.canvas,a=function({channelData:t,width:e,height:i,vScale:r}){let s=i/2,n=t[0]||[];return[n,t[1]||n].map((t,i)=>{let n=t.length,a=n?e/n:0,o=0===i?-1:1,l=[{x:0,y:s}],h=0,u=0;for(let e=0;e<=n;e++){let i=Math.round(e*a);if(i>h){let t=s+(Math.round(u*s*r)||1)*o;l.push({x:h,y:t}),h=i,u=0}let n=Math.abs(t[e]||0);n>u&&(u=n)}return l.push({x:h,y:s}),l})}({channelData:t,width:s,height:n,vScale:r});for(let t of(i.beginPath(),a))if(t.length){i.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++){let r=t[e];i.lineTo(r.x,r.y)}}i.fill(),i.closePath()}renderWaveform(t,e,i){if(i.fillStyle=this.convertColorValues(e.waveColor,i),e.renderFunction)return void e.renderFunction(t,i);let r=function({channelData:t,barHeight:e,normalize:i,maxPeak:r}){var s;let n=e||1;if(!i)return n;let a=t[0];if(!a||0===a.length)return n;let o=null!=r?r:0;if(!r)for(let t=0;t<a.length;t++){let e=Math.abs(null!=(s=a[t])?s:0);e>o&&(o=e)}return o?n/o:n}({channelData:t,barHeight:e.barHeight,normalize:e.normalize,maxPeak:e.maxPeak});b(e)?this.renderBarWaveform(t,e,i,r):this.renderLineWaveform(t,e,i,r)}renderSingleCanvas(t,e,i,r,s,n,a){let o=this.getPixelRatio(),l=document.createElement("canvas");l.width=Math.round(i*o),l.height=Math.round(r*o),l.style.width=`${i}px`,l.style.height=`${r}px`,l.style.left=`${Math.round(s)}px`,n.appendChild(l);let h=l.getContext("2d");if(e.renderFunction?(h.fillStyle=this.convertColorValues(e.waveColor,h),e.renderFunction(t,h)):this.renderWaveform(t,e,h),l.width>0&&l.height>0){let t=l.cloneNode(),i=t.getContext("2d");i.drawImage(l,0,0),i.globalCompositeOperation="source-in",i.fillStyle=this.convertColorValues(e.progressColor,i),i.fillRect(0,0,l.width,l.height),a.appendChild(t)}}renderMultiCanvas(t,e,i,r,s,n){let a=this.getPixelRatio(),{clientWidth:o}=this.scrollContainer,l=i/a,h=function({clientWidth:t,totalWidth:e,options:i}){return y(Math.min(8e3,t,e),i)}({clientWidth:o,totalWidth:l,options:e}),u={};if(0===h)return;let d=i=>{if(i<0||i>=c||u[i])return;u[i]=!0;let a=i*h,o=Math.min(l-a,h);if((o=y(o,e))<=0)return;let d=function({channelData:t,offset:e,clampedWidth:i,totalWidth:r}){return t.map(t=>{let s=Math.floor(e/r*t.length),n=Math.floor((e+i)/r*t.length);return t.slice(s,n)})}({channelData:t,offset:a,clampedWidth:o,totalWidth:l});this.renderSingleCanvas(d,e,o,r,a,s,n)},c=Math.ceil(l/h);if(!this.isScrollable){for(let t=0;t<c;t++)d(t);return}if(x({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:l,numCanvases:c}).forEach(t=>d(t)),c>1){let t=this.on("scroll",()=>{let{scrollLeft:t}=this.scrollContainer;Object.keys(u).length>10&&(s.innerHTML="",n.innerHTML="",u={}),x({scrollLeft:t,totalWidth:l,numCanvases:c}).forEach(t=>d(t))});this.unsubscribeOnScroll.push(t)}}renderChannel(t,e,i,r){var{overlay:s}=e,n=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&0>e.indexOf(r)&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)0>e.indexOf(r[s])&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(i[r[s]]=t[r[s]])}return i}(e,["overlay"]);let a=document.createElement("div"),o=this.getHeight(n.height,n.splitChannels);a.style.height=`${o}px`,s&&r>0&&(a.style.marginTop=`-${o}px`),this.canvasWrapper.style.minHeight=`${o}px`,this.canvasWrapper.appendChild(a);let l=a.cloneNode();this.progressWrapper.appendChild(l),this.renderMultiCanvas(t,n,i,o,a,l)}render(t){return o(this,void 0,void 0,function*(){var e;
75this.timeouts.forEach(t=>t()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",null!=this.options.width&&(this.scrollContainer.style.width="number"==typeof this.options.width?`${this.options.width}px`:this.options.width);let i=this.getPixelRatio(),r=this.scrollContainer.clientWidth,{scrollWidth:s,isScrollable:n,useParentWidth:a,width:o}=function({duration:t,minPxPerSec:e=0,parentWidth:i,fillParent:r,pixelRatio:s}){let n=Math.ceil(t*e),a=n>i,o=!!(r&&!a);return{scrollWidth:n,isScrollable:a,useParentWidth:o,width:(o?i:n)*s}}({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:r,fillParent:this.options.fillParent,pixelRatio:i});if(this.isScrollable=n,this.wrapper.style.width=a?"100%":`${s}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let i=0;i<t.numberOfChannels;i++){let r=Object.assign(Object.assign({},this.options),null==(e=this.options.splitChannels)?void 0:e[i]);this.renderChannel([t.getChannelData(i)],r,o,i)}else{let e=[t.getChannelData(0)];t.numberOfChannels>1&&e.push(t.getChannelData(1)),this.renderChannel(e,this.options,o,0)}Promise.resolve().then(()=>
75this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(t=>t()),this.unsubscribeOnScroll=[],!this.audioData)return;let{scrollWidth:t}=this.scrollContainer,{right:e}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){let t,{right:i}=this.progressWrapper.getBoundingClientRect(),r=((t=2*(i-e))<0?Math.floor(t):Math.ceil(t))/2;this.scrollContainer.scrollLeft+=r}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){var i;let{scrollLeft:r,scrollWidth:s,clientWidth:n}=this.scrollContainer,a=t*s,o=r+n,l=n/2;if(this.isDragging)a+30>o?this.scrollContainer.scrollLeft+=30:a-30<r&&(this.scrollContainer.scrollLeft-=30);else{(a<r||a>o)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?l:0));let t=a-r-l;if(e&&this.options.autoCenter&&t>0){let e=null==(i=this.audioData)?void 0:i.duration;if(void 0===e||e<=0)return void(this.scrollContainer.scrollLeft+=t);this.scrollContainer.scrollLeft+=s/e<=600?Math.min(t,10):t}}}renderProgress(t,e){if(isNaN(t))return;let i=100*t;this.canvasWrapper.style.clipPath=`polygon(${i}% 0%, 100% 0%, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0&&this.scrollIntoView(t,e)}exportImage(t,e,i){return o(this,void 0,void 0,function*(){let r=this.canvasWrapper.querySelectorAll("canvas");if(!r.length)throw Error("No waveform data");return"dataURL"===i?Promise.resolve(Array.from(r).map(i=>i.toDataURL(t,e))):Promise.all(Array.from(r).map(i=>new Promise((r,s)=>{i.toBlob(t=>{t?r(t):s(Error("Could not export image"))},t,e)})))})}}class w extends l{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;let t=()=>
75{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class k extends l{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playbackPosition=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return o(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){(this.currentSrc=t,this._duration=void 0,t)?fetch(t).then(e=>{if(e.status>=400)throw Error(`Failed to fetch ${t}: ${e.status} (${e.statusText})`);return e.arrayBuffer()}).then(e=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(e)).then(e=>{this.currentSrc===t&&(this.buffer=e,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())}).catch(t=>{console.error("WebAudioPlayer load error:",t)}):(this.buffer=null,this.emit("emptied"))}_play(){if(!this.paused)return;this.paused=!1,this.bufferNode&&(this.bufferNode.onended=null,this.bufferNode.disconnect()),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let t=this.playbackPosition;(t>=this.duration||t<0)&&(t=0,this.playbackPosition=0),this.bufferNode.start(this.audioContext.currentTime,t),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,null==(t=this.bufferNode)||t.stop(),this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return o(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){let e=t-this.currentTime,i=this.bufferNode;null==i||i.stop(this.audioContext.currentTime+e),null==i||i.addEventListener("ended",()=>{i===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return o(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){let e=!this.paused;e&&this._pause(),this._playbackRate=t,e&&this._play(),this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){let e=!this.paused;e&&this._pause(),this.playbackPosition=t,e&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,e;return null!=(t=this._duration)?t:(null==(e=this.buffer)?void 0:e.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){let t=[];if(!this.buffer)return t;let e=this.buffer.numberOfChannels;for(let i=0;i<e;i++)t.push(this.buffer.getChannelData(i));return t}removeAttribute(t){switch(t){case"src":this.src="";break;case"playbackRate":this.playbackRate=0;break;case"currentTime":this.currentTime=0;break;case"duration":this.duration=0;break;case"volume":this.volume=0;break;case"muted":this.muted=!1}}}let E={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class P extends f{static create(t){return new P(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const e=t.media||("WebAudio"===t.backend?new k:void 0);
75super({media:e,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.reactiveCleanups=[],this.options=Object.assign({},E,t);const{state:i,actions:r}=function(t){var e,i,r,s,n,a;let o=null!=(e=null==t?void 0:t.currentTime)?e:p(0),l=null!=(i=null==t?void 0:t.duration)?i:p(0),h=null!=(r=null==t?void 0:t.isPlaying)?r:p(!1),u=null!=(s=null==t?void 0:t.isSeeking)?s:p(!1),d=null!=(n=null==t?void 0:t.volume)?n:p(1),c=null!=(a=null==t?void 0:t.playbackRate)?a:p(1),g=p(null),f=p(null),v=p(""),b=p(0),y=p(0),x=m(()=>!h.value,[h]),C=m(()=>null!==g.value,[g]),S=m(()=>C.value&&l.value>0,[C,l]),w=m(()=>o.value,[o]),k=m(()=>l.value>0?o.value/l.value:0,[o,l]);return{state:{currentTime:o,duration:l,isPlaying:h,isPaused:x,isSeeking:u,volume:d,playbackRate:c,audioBuffer:g,peaks:f,url:v,zoom:b,scrollPosition:y,canPlay:C,isReady:S,progress:w,progressPercent:k},actions:{setCurrentTime:t=>{let e=Math.max(0,Math.min(l.value||1/0,t));o.set(e)},setDuration:t=>{l.set(Math.max(0,t))},setPlaying:t=>{h.set(t)},setSeeking:t=>{u.set(t)},setVolume:t=>{let e=Math.max(0,Math.min(1,t));d.set(e)},setPlaybackRate:t=>{let e=Math.max(.1,Math.min(16,t));c.set(e)},setAudioBuffer:t=>{g.set(t),t&&l.set(t.duration)},setPeaks:t=>{f.set(t)},setUrl:t=>{v.set(t)},setZoom:t=>{b.set(Math.max(0,t))},setScrollPosition:t=>{y.set(Math.max(0,t))}}}}({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=i,this.wavesurferActions=r,this.timer=new w;const s=e?void 0:this.getMediaElement();this.renderer=new S(this.options,s),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const n=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");let{peaks:t,duration:e}=this.options;(n||t&&e)&&this.load(n,t,e).catch(t=>{this.emit("error",t instanceof Error?t:Error(String(t)))})})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){let t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),null!=this.stopAtPosition&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}initReactiveState(){var t,e;let i,r,s;this.reactiveCleanups.push((t=this.wavesurferState,e={emit:this.emit.bind(this)},(i=[]).push(g(()=>{let i=t.isPlaying.value;e.emit(i?"play":"pause")},[t.isPlaying])),i.push(g(()=>{let i=t.currentTime.value;e.emit("timeupdate",i),t.isPlaying.value&&e.emit("audioprocess",i)},[t.currentTime,t.isPlaying])),i.push(g(()=>{t.isSeeking.value&&e.emit("seeking",t.currentTime.value)},[t.isSeeking,t.currentTime])),r=!1,i.push(g(()=>{t.isReady.value&&!r&&(r=!0,e.emit("ready",t.duration.value))},[t.isReady,t.duration])),s=!1,i.push(g(()=>{let i=t.isPlaying.value,r=t.currentTime.value,n=t.duration.value,a=n>0&&r>=n;s&&!i&&a&&e.emit("finish"),s=i&&a},[t.isPlaying,t.currentTime,t.duration])),i.push(g(()=>{let i=t.zoom.value;i>0&&e.emit("zoom",i)},[t.zoom])),()=>{i.forEach(t=>t())}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{let t=this.updateProgress();this.emit("timeupdate",t)}),this.onMediaEvent("play",()=>{this.emit("play"),this.timer.start()}),this.onMediaEvent("pause",()=>{this.emit("pause"),this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("emptied",()=>{this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("ended",()=>{this.emit("timeupdate",this.getDuration()),this.emit("finish"),this.stopAtPosition=null}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}),this.onMediaEvent("error",()=>{var t;this.emit("error",null!=(t=this.getMediaElement().error)?t:Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,e)=>
75{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,e))}),this.renderer.on("dblclick",(t,e)=>{this.emit("dblclick",t,e)}),this.renderer.on("scroll",(t,e,i,r)=>{let s=this.getDuration();this.emit("scroll",t*s,e*s,i,r)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}),this.renderer.on("resize",()=>{this.emit("resize")}));{let t,e=this.renderer.on("drag",e=>{var i;if(!this.options.interact)return;this.renderer.renderProgress(e),clearTimeout(t);let r=0,s=this.options.dragToSeek;this.isPlaying()?r=0:!0===s?r=200:s&&"object"==typeof s&&(r=null!=(i=s.debounceTime)?i:200),t=setTimeout(()=>{this.seekTo(e)},r),this.emit("interaction",e*this.getDuration()),this.emit("drag",e)});this.subscriptions.push(()=>{clearTimeout(t),e()})}}initPlugins(){var t;(null==(t=this.options.plugins)?void 0:t.length)&&this.options.plugins.forEach(t=>{this.registerPlugin(t)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=h.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=h.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),null!=t.mediaControls&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);let e=t.once("destroy",()=>{this.plugins=this.plugins.filter(e=>e!==t),this.subscriptions=this.subscriptions.filter(t=>t!==e)});return this.subscriptions.push(e),t}unregisterPlugin(t){this.plugins=this.plugins.filter(e=>e!==t),t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){let e=t/this.getDuration();this.renderer.setScrollPercentage(e)}getActivePlugins(){return this.plugins}loadAudio(t,e,i,r){return o(this,void 0,void 0,function*(){var s;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,null==(s=this.abortController)||s.abort(),this.abortController=null,!e&&!i){let i=this.options.fetchParams||{};window.AbortController&&!i.signal&&(this.abortController=new AbortController,i.signal=this.abortController.signal);let r=t=>this.emit("loading",t);e=yield c.fetchBlob(t,r,i);let s=this.options.blobMimeType;s&&(e=new Blob([e],{type:s}))}this.setSrc(t,e);let n=yield new Promise(t=>{let e=r||this.getDuration();e?t(e):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>t(this.getDuration()),{once:!0}))});if(!t&&!e){let t=this.getMediaElement();t instanceof k&&(t.duration=n)}if(i)this.decodedData=h.createBuffer(i,n||0);else if(e){let t=yield e.arrayBuffer();this.decodedData=yield h.decode(t,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,e,i){return o(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,e,i)}catch(t){throw this.emit("error",t),t}})}loadBlob(t,e,i){return o(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,e,i)}catch(t){throw this.emit("error",t),t}})}zoom(t){if(!this.decodedData)throw Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:e=8e3,precision:i=1e4}={}){if(!this.decodedData)throw Error("The audio has not been decoded yet");let r=Math.min(t,this.decodedData.numberOfChannels),s=[];for(let t=0;t<r;t++){let r=this.decodedData.getChannelData(t),n=[],a=r.length/e;for(let t=0;t<e;t++){let e=r.slice(Math.floor(t*a),Math.ceil((t+1)*a)),s=0;for(let t=0;t<e.length;t++){let i=e[t];Math.abs(i)>Math.abs(s)&&(s=i)}n.push(Math.round(s*i)/i)}s.push(n)}return s}getDuration(){let t=super.getDuration()||0;return(0===t||t===1/0)&&this.decodedData&&(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit
75("timeupdate",t)}seekTo(t){let e=this.getDuration()*t;this.setTime(e)}play(t,e){let i=Object.create(null,{play:{get:()=>super.play}});return o(this,void 0,void 0,function*(){null!=t&&this.setTime(t);let r=yield i.play.call(this);return null!=e&&(this.media instanceof k?this.media.stopAt(e):this.stopAtPosition=e),r})}playPause(){return o(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return o(this,arguments,void 0,function*(t="image/png",e=1,i="dataURL"){return this.renderer.exportImage(t,e,i)})}destroy(){var t;this.emit("destroy"),null==(t=this.abortController)||t.abort(),this.plugins.forEach(t=>t.destroy()),this.subscriptions.forEach(t=>t()),this.unsubscribePlayerEvents(),this.reactiveCleanups.forEach(t=>t()),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}P.BasePlugin=class extends l{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},P.dom=d;var M=t.i(4570);function R(t){if(!Number.isFinite(t)||t<0)return"0:00";let e=Math.floor(t/60),i=Math.floor(t%60);return`${e}:${i.toString().padStart(2,"0")}`}t.s(["default",0,function({sample:t,className:o=""}){let l=(0,a.useRef)(null),h=(0,a.useRef)(null),u=(0,a.useRef)(null),[d,c]=(0,a.useState)(!1),[p,m]=(0,a.useState)(0),[g,f]=(0,a.useState)(0),[v,b]=(0,a.useState)(!1),y=t.audioUrl?.trim()??"",x=(0,a.useMemo)(()=>(function(t){let e=t.trim();if(!e)return"";try{if(e.startsWith("/")&&!e.startsWith("//"))return e;let t=new URL(e);if("http:"!==t.protocol&&"https:"!==t.protocol)return e;let i="http://localhost:5001".trim();if(i)try{if(t.origin===new URL(i).origin)return e}catch{}if(t.origin===window.location.origin)return e;return`/api/audio-proxy?url=${encodeURIComponent(e)}`}catch{return e}})(y),[y]),C=y.length>0;(0,a.useEffect)(()=>{let t=l.current;if(!t||"u"<typeof IntersectionObserver)return void b(!0);let e=new IntersectionObserver(t=>{t.some(t=>t.isIntersecting)&&(b(!0),e.disconnect())},{rootMargin:"200px"});return e.observe(t),()=>e.disconnect()},[]),(0,a.useEffect)(()=>{if(!C||!v||!h.current){c(!1),m(0),f(0);return}let e=h.current,i=P.create({container:e,url:x,height:24,waveColor:"#D1D5DC",progressColor:"#36AB45",cursorColor:"#36AB45",cursorWidth:2,barWidth:1,barGap:1,barRadius:1,dragToSeek:!0,normalize:!0});return u.current=i,r.add(i),i.on("play",()=>{for(let t of r)t!==i&&t.isPlaying()&&t.pause();c(!0),t.id&&(0,n.trackAudioPlay)({id:t.id,title:t.title})}),i.on("pause",()=>c(!1)),i.on("finish",()=>c(!1)),i.on("ready",t=>f(t)),i.on("timeupdate",t=>m(t)),()=>{r.delete(i),i.destroy(),u.current=null}},[y,C,x,v,t.id,t.title]);let S=(0,a.useCallback)(()=>{if(!u.current)return;let e=u.current.isPlaying();u.current.playPause(),M.default.capture("sample_ad_played",{action:e?"pause":"play",title:t.title,reach:t.reach})},[t.title,t.reach]),w=g>0?`${R(p)} / ${R(g)}`:R(p);return(0,e.jsxs)("div",{ref:l,className:(0,s.cn)("w-full max-w-full lg:max-w-[320px] flex flex-row items-center justify-start rounded-[16px] p-4 gap-4 bg-white border border-[#D8D9DB] min-w-0",o),children:[(0,e.jsx)("button",{type:"button",disabled:!C,"aria-label":d?"Pause":"Play",onClick:S,className:(0,s.cn)("shrink-0 rounded-full p-0.5 text-[#111827] outline-none focus-visible:ring-2 focus-visible:ring-[#36AB45] focus-visible:ring-offset-1",C&&"hover:opacity-80",!C&&"cursor-not-allowed opacity-40"),children:d?(0,e.jsx)(i.PauseIcon,{className:"w-10 h-10"}):(0,e.jsx)(i.PlayIcon,{className:"w-10 h-10"})}),(0,e.jsxs)("div",{className:"w-full flex flex-col gap-2 min-w-0 flex-1",children:[(t.title||t.reach)&&(0,e.jsxs)("div",{className:"w-full flex flex-row items-center justify-between gap-1",children:[t.title&&(0,e.jsx)("span",{className:"text-[#111827] font-bold text-sm truncate",children:t.title}),t.reach&&(0,e.jsxs)("span",{className:"bg-[#E6F4EA] text-[#36AB45] font-bold text-[10px] leading-[15px] py-0.5 px-2 rounded-[4px] shrink-0",children:["+",(0,s.formatCompactNumber)(+t.reach,"en-US")," reach"]})]}),(0,e.jsxs)("div",{className:"w-full flex flex-row items-center justify-between gap-2 min-w-0",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0 max-h-[36px]",children:C&&v?(0,e.jsx)("div",{ref:h,className:"w-full",role:"img","aria-label":`Waveform for ${t.title}`}):(0,e.jsx)("div",{className:"w-full h-9 flex items-end justify-center gap-0.5 opacity-50","aria-hidden":!0,
75children:Array.from({length:32}).map((t,i)=>(0,e.jsx)("div",{className:"w-0.5 rounded-full bg-[#D1D5DC]",style:{height:`${8+13*i%20}px`}},i))})}),(0,e.jsx)("span",{className:"text-[#9CA3AF] text-[10px] leading-[15px] font-[450] shrink-0 tabular-nums",children:w})]})]})]})}],6716)}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.