PageSourceSearch

https://flyu.ai/_next/static/chunks/22839-f2ba8524a2113631.js

js flyu.ai collected 2026-10-05 12:53:40 UTC 58,323 bytes, 74 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[22839],{21070:(t,e,i)=>{i.d(e,{A:()=>R});var s=i(95155),n=i(12115);function r(t,e,i,s){return new(i||(i=Promise))(function(n,r){function o(t){try{l(s.next(t))}catch(t){r(t)}}function a(t){try{l(s.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?n(t.value):((e=t.value)instanceof i?e:new i(function(t){t(e)})).then(o,a)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),null==i?void 0:i.once){let i=(...s)=>{this.un(t,i),e(...s)};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 a={decode:function(t,e){return r(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,s=0;for(let t=0;t<i;t++){let i=Math.abs(e[t]);i>s&&(s=i)}for(let e of t)for(let t=0;t<i;t++)e[t]/=s}}(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 l(t,e,i){let s=function t(e,i){let s=i.xmlns?document.createElementNS(i.xmlns,e):document.createElement(e);for(let[e,n]of Object.entries(i))if("children"===e&&n)for(let[e,i]of Object.entries(n))i instanceof Node?s.appendChild(i):"string"==typeof i?s.appendChild(document.createTextNode(i)):s.appendChild(t(e,i));else"style"===e?Object.assign(s.style,n):"textContent"===e?s.textContent=n:s.setAttribute(e,n.toString());return s}(t,e||{});return null==i||i.appendChild(s),s}function h(t){return t instanceof HTMLElement||"object"==typeof t&&null!==t&&t.nodeType===Node.ELEMENT_NODE&&"object"==typeof t.style}var d=Object.freeze({__proto__:null,createElement:l,default:l,isHTMLElement:h});let u={fetchBlob:function(t,e,i){return r(this,void 0,void 0,function*(){var s;let n=yield fetch(t,i);if(n.status>=400)throw Error(`Failed to fetch ${t}: ${n.status} (${n.statusText})`);return function(t,e,i){r(this,void 0,void 0,function*(){var s;if(!t.body||!t.headers)return;let n=t.body.getReader(),r=Number(t.headers.get("Content-Length"))||0,o=0,a=()=>{n.cancel()};if(i){if(i.aborted)return void n.cancel();i.addEventListener("abort",a,{once:!0})}try{for(;;){let t=yield n.read();if(t.done)break;if(o+=(null==(s=t.value)?void 0:s.length)||0,r>0){let t=Math.round(o/r*100);e(t)}}}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;console.warn("Progress tracking error:",t)}finally{i&&i.removeEventListener("abort",a)}})}(n.clone(),e,null!=(s=null==i?void 0:i.signal)?s:void 0),n.blob()})}};function c(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 p(t,e){let i=c(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 m(t,e){let i,s=()=>{i&&(i(),i=void 0),i=t()},n=e.map(t=>t.subscribe(s));return s(),()=>{i&&(i(),i=void 0),n.forEach(t=>t())}}class g extends o{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._ownBlobUrl=null,this.reactiveMediaEventCleanups=[],t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),this._isPlaying=c(!1),this._currentTime=c(0),this._duration=c(0),this._volume=c(this.media.volume),this._muted=c(this.media.muted),this._playbackRate=c(this.media.playbackRate||1),this._seeking=c(!1),this.setupReactiveMediaEvents(),t.mediaControl
1s&&(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(){this._ownBlobUrl&&(URL.revokeObjectURL(this._ownBlobUrl),this._ownBlobUrl=null)}canPlayType(t){return""!==this.media.canPlayType(t)}setSrc(t,e){let i=this.getSrc();if(t&&i===t)return;this.revokeSrc();let s=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;if(s!==t&&(this._ownBlobUrl=s),i&&this.media.removeAttribute("src"),s||t)try{this.media.src=s}catch(e){this.media.src=t}}destroy(){this.reactiveMediaEventCleanups.forEach(t=>t()),this.reactiveMediaEventCleanups=[],this.revokeSrc(),this.unAll(),this.isExternalMedia||(this.media.pause(),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 r(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)}}function v(t,e,i){let s=e-t.left,n=i-t.top;return[s/t.width,n/t.height]}function f(t){return!!(t.barWidth||t.barGap||t.barAlign)}function b(t,e){if(!f(e))return t;let i=e.barWidth||.5,s=i+(e.barGap||i/2);return 0===s?t:Math.floor(t/s)*s}function y({scrollLeft:t,totalWidth:e,numCanvases:i}
1){if(0===e)return[0];let s=Math.floor(t/e*i);return[s-1,s,s+1]}function C(t){let e=t._cleanup;"function"==typeof e&&e()}class E extends o{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.containerInlinePadding=0,this.onClickWrapper=t=>{let[e,i]=v(this.wrapper.getBoundingClientRect(),t.clientX,t.clientY);this.emit("click",e,i)},this.onDblClickWrapper=t=>{let[e,i]=v(this.wrapper.getBoundingClientRect(),t.clientX,t.clientY);this.emit("dblclick",e,i)},this.subscriptions=[],this.options=t;const i=this.parentFromOptionsContainer(t.container);this.parent=i;const[s,n]=this.initHtml();i.appendChild(s),this.container=s,this.scrollContainer=n.querySelector(".scroll"),this.wrapper=n.querySelector(".wrapper"),this.canvasWrapper=n.querySelector(".canvases"),this.progressWrapper=n.querySelector(".progress"),this.cursor=n.querySelector(".cursor"),this.calculateInlinePadding(),e&&n.appendChild(e),this.initEvents()}parentFromOptionsContainer(t){let e;if("string"==typeof t?e=document.querySelector(t):h(t)&&(e=t),!e)throw Error("Container not found");return e}initEvents(){var t;let e,i,s,n;this.wrapper.addEventListener("click",this.onClickWrapper),this.wrapper.addEventListener("dblclick",this.onDblClickWrapper),!0!==this.options.dragToSeek&&"object"!=typeof this.options.dragToSeek||this.initDrag(),this.scrollStream=(i=p(()=>(function(t){let{scrollLeft:e,scrollWidth:i,clientWidth:s}=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+s)/i))}})(e.value),[e=c({scrollLeft:(t=this.scrollContainer).scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})]),s=p(()=>{var t;return{left:(t=e.value).scrollLeft,right:t.scrollLeft+t.clientWidth}},[e]),n=()=>{e.set({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})},t.addEventListener("scroll",n,{passive:!0}),{scrollData:e,percentages:i,bounds:s,cleanup:()=>{t.removeEventListener("scroll",n),C(e)}});let r=m(()=>{let{startX:t,endX:e}=this.scrollStream.percentages.value,{left:i,right:s}=this.scrollStream.bounds.value;this.emit("scroll",t,e,i,s)},[this.scrollStream.percentages,this.scrollStream.bounds]);if(this.subscriptions.push(r),"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;this.calculateInlinePadding(),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:s=0,touchDelay:n=100}=e,r=c(null),o=new Map,a=matchMedia("(pointer: coarse)").matches,l=()=>{},h=e=>{if(e.button!==s||o.has(e.pointerId)||(o.set(e.pointerId,e),o.size>1))return;let h=e.pointerId,d=e.clientX,u=e.clientY,c=!1,p=Date.now(),{left:m,top:g}=t.getBoundingClientRect(),v=t=>{if(t.pointerId!==h||t.defaultPrevented||o.size>1||a&&Date.now()-p<n)return;let e=t.clientX,s=t.clientY,l=e-d,v=s-u;(c||Math.abs(l)>i||Math.abs(v)>i)&&(t.preventDefault(),t.stopPropagation(),c||(r.set({type:"start",x:d-m,y:u-g}),c=!0),r.set({type:"move",x:e-m,y:s-g,deltaX:l,deltaY:v}),d=e,u=s)},f=t=>{if(o.delete(t.pointerId)){if(t.pointerId===h&&c){let e=t.clientX,i=t.clientY;r.set({type:"end",x:e-m,y:i-g})}0===o.size&&l()}},b=t=>{t.relatedTarget&&t.relatedTarget!==document.documentElement||f(t)},y=t=>{c&&(t.stopPropagation(),t.preventDefault())},C=t=>{t.defaultPrevented||o.size>1||c&&t.preventDefault()};document.addEventListener("pointermove",v),document.addEventListener("pointerup",f),document.addEventListener("pointerout",b),document.addEventListener("pointercancel",b),document.addEventListener("touchmove",C,{passive:!1}),document.addEventListener("click",y,{capture:!0}),l=()=>{document.removeEventListener("pointermove",v),document.removeEventListener("pointerup",f),document.removeEventListener("pointerout",b),document.removeEventListener("pointercancel",b),document.removeEventListener("touchmove",C),setTimeout(()=>{document.removeEventListener("click",y,{capture:!0})},10)}};return t.addEventListener("pointerdown",h),{signal:r,cleanup:()=>
1{l(),t.removeEventListener("pointerdown",h),o.clear(),C(r)}}}(this.wrapper);let t=m(()=>{var t;let e=this.dragStream.signal.value;if(!e)return;let i=this.wrapper.getBoundingClientRect().width,s=(t=e.x/i)<0?0:t>1?1:t;"start"===e.type?(this.isDragging=!0,this.emit("dragstart",s)):"move"===e.type?this.emit("drag",s):"end"===e.type&&(this.isDragging=!1,this.emit("dragend",s))},[this.dragStream.signal]);this.subscriptions.push(t)}calculateInlinePadding(){let{paddingLeft:t,paddingRight:e}=getComputedStyle(this.scrollContainer),i=parseFloat(t)+parseFloat(e);this.containerInlinePadding=Number.isNaN(i)?0:i}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=`
2      <style${i?` nonce="${i}"`:""}>
3        :host {
4          user-select: none;
5          min-width: 1px;
6        }
7        :host audio {
8          display: block;
9          width: 100%;
10        }
11        :host .scroll {
12          overflow-x: auto;
13          overflow-y: hidden;
14          width: 100%;
15          position: relative;
16        }
17        :host .noScrollbar {
18          scrollbar-color: transparent;
19          scrollbar-width: none;
20        }
21        :host .noScrollbar::-webkit-scrollbar {
22          display: none;
23          -webkit-appearance: none;
24        }
25        :host .wrapper {
26          position: relative;
27          overflow: visible;
28          z-index: 2;
29        }
30        :host .canvases {
31          min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;
32          pointer-events: none;
33        }
34        :host .canvases > div {
35          position: relative;
36        }
37        :host canvas {
38          display: block;
39          position: absolute;
40          top: 0;
41          image-rendering: pixelated;
42        }
43        :host .progress {
44          pointer-events: none;
45          position: absolute;
46          z-index: 2;
47          top: 0;
48          left: 0;
49          width: 0;
50          height: 100%;
51          overflow: hidden;
52        }
53        :host .progress > div {
54          position: relative;
55        }
56        :host .cursor {
57          pointer-events: none;
58          position: absolute;
59          z-index: 5;
60          top: 0;
61          left: 0;
62          height: 100%;
63          border-radius: 2px;
64        }
65      </style>
66
67      <div class="scroll" part="scroll">
68        <div class="wrapper" part="wrapper">
69          <div class="canvases" part="canvases"></div>
70          <div class="progress" part="progress"></div>
71          <div class="cursor" part="cursor"></div>
72        </div>
73      </div>
74    `,[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-this.containerInlinePadding}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.wrapper.removeEventListener("click",this.onClickWrapper),this.wrapper.removeEventListener("dblclick",this.onDblClickWrapper),this.timeouts.forEach(t=>t()),this.timeouts=[],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,s=()=>{e&&(clearTimeout(e),e=void 0),i&&(i(),i=void 0)};return this.timeouts.push(s),()=>new Promise((n,r)=>{s(),i=r,e=setTimeout(()=>{e=void 0,i=void 0,n()},t)})}getHeight(t,e){var i;let s=(null==(i=this.audioData)?void 0:i.numberOfChannels)||1;return function({optionsHeight:t,optionsSplitChannels:e,parentHeight:i,numberOfChannels:s,defaultHeight:n=128}){if(null==t)return n;let r=Number(t);if(!isNaN(r))return r;if("auto"===t){let t=i||n;return(null==e?void 0:e.every(t=>!t.overlay))?t/s:t}return n}({optionsHeight:t,optionsSplitChannels:e,parentHeight:this.parent.clientHeight,numberOfChannels:s,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 s=document.createElement("canvas"),n=s.getContext("2d");if(!n)return t[0]||"";let r=i||s.height*e,o=n.createLinearGradient(0,0,0,r),a=1/(t.length-1);return t.forEach((t,e)=>{o.addColorStop(e*a,t)}),o}(t,this.getPixelRatio(),null==e?void 0:e.canvas.height)}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,e,i,s){let{width:n,height:r}=i.canvas,{halfHeight:o,barWidth:a,barRadius:l,barIndexScale:h,barSpacing:d,barMinHeight:u}=function({width:t,height:e,length:i,options:s,pixelRatio:n}){let r=s.barWidth?s.barWidth*n:1,o=s.barGap?s.barGap*n:s.barWidth?r/2:0,a=r+o||1;return{halfHeight:e/2,barWidth:r,barGap:o,barRadius:s.barRadius||0,barMinHeight:s.barMinHeight?s.barMinHeight*n:0,barIndexScale:i>0?t/a/i:0,barSpacing:a}}({width:n,height:r,length:(t[0]||[]).length,options:e,pixelRatio:this.getPixelRatio()}),c=function({channelData:t,barIndexScale:e,barSpacing:i,barWidth:s,halfHeight:n,vScale:r,canvasHeight:o,barAlign:a,barMinHeight:l}){let h=t[0]||[],d=t[1]||h,u=h.length,c=[],p=0,m=0,g=0;for(let t=0;t<=u;t++){let u=Math.round(t*e);if(u>p){let{topHeight:t,totalHeight:e}=function({maxTop:t,maxBottom:e,halfHeight:i,vScale:s,barMinHeight:n=0,barAlign:r}){let o=Math.round(t*i*s),a=o+Math.round(e*i*s)||1;return a<n&&(a=n,r||(o=a/2)),{topHeight:o,totalHeight:a}}
74({maxTop:m,maxBottom:g,halfHeight:n,vScale:r,barMinHeight:l,barAlign:a}),h=function({barAlign:t,halfHeight:e,topHeight:i,totalHeight:s,canvasHeight:n}){return"top"===t?0:"bottom"===t?n-s:e-i}({barAlign:a,halfHeight:n,topHeight:t,totalHeight:e,canvasHeight:o});c.push({x:p*i,y:h,width:s,height:e}),p=u,m=0,g=0}let v=Math.abs(h[t]||0),f=Math.abs(d[t]||0);v>m&&(m=v),f>g&&(g=f)}return c}({channelData:t,barIndexScale:h,barSpacing:d,barWidth:a,halfHeight:o,vScale:s,canvasHeight:r,barAlign:e.barAlign,barMinHeight:u});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,s){let{width:n,height:r}=i.canvas,o=function({channelData:t,width:e,height:i,vScale:s}){let n=i/2,r=t[0]||[];return[r,t[1]||r].map((t,i)=>{let r=t.length,o=r?e/r:0,a=0===i?-1:1,l=[{x:0,y:n}],h=0,d=0;for(let e=0;e<=r;e++){let i=Math.round(e*o);if(i>h){let t=n+(Math.round(d*n*s)||1)*a;l.push({x:h,y:t}),h=i,d=0}let r=Math.abs(t[e]||0);r>d&&(d=r)}return l.push({x:h,y:n}),l})}({channelData:t,width:n,height:r,vScale:s});for(let t of(i.beginPath(),o))if(t.length){i.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++){let s=t[e];i.lineTo(s.x,s.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 s=function({channelData:t,barHeight:e,normalize:i,maxPeak:s}){var n;let r=e||1;if(!i)return r;let o=t[0];if(!o||0===o.length)return r;let a=null!=s?s:0;if(!s)for(let t=0;t<o.length;t++){let e=Math.abs(null!=(n=o[t])?n:0);e>a&&(a=e)}return a?r/a:r}({channelData:t,barHeight:e.barHeight,normalize:e.normalize,maxPeak:e.maxPeak});f(e)?this.renderBarWaveform(t,e,i,s):this.renderLineWaveform(t,e,i,s)}renderSingleCanvas(t,e,i,s,n,r,o){let a=this.getPixelRatio(),l=document.createElement("canvas");l.width=Math.round(i*a),l.height=Math.round(s*a),l.style.width=`${i}px`,l.style.height=`${s}px`,l.style.left=`${Math.round(n)}px`,r.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),o.appendChild(t)}}renderMultiCanvas(t,e,i,s,n,r){let o=this.getPixelRatio(),{clientWidth:a}=this.scrollContainer,l=i/o,h=function({clientWidth:t,totalWidth:e,options:i}){return b(Math.min(8e3,t,e),i)}({clientWidth:a,totalWidth:l,options:e}),d={};if(0===h)return;let u=i=>{if(i<0||i>=c||d[i])return;d[i]=!0;let o=i*h,a=Math.min(l-o,h);if((a=b(a,e))<=0)return;let u=function({channelData:t,offset:e,clampedWidth:i,totalWidth:s}){return t.map(t=>{let n=Math.floor(e/s*t.length),r=Math.floor((e+i)/s*t.length);return t.slice(n,r)})}({channelData:t,offset:o,clampedWidth:a,totalWidth:l});this.renderSingleCanvas(u,e,a,s,o,n,r)},c=Math.ceil(l/h);if(!this.isScrollable){for(let t=0;t<c;t++)u(t);return}if(y({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:l,numCanvases:c}).forEach(t=>u(t)),c>1){let t=this.on("scroll",()=>{let{scrollLeft:t}=this.scrollContainer;Object.keys(d).length>10&&(n.innerHTML="",r.innerHTML="",d={}),y({scrollLeft:t,totalWidth:l,numCanvases:c}).forEach(t=>u(t))});this.unsubscribeOnScroll.push(t)}}renderChannel(t,e,i,s){var{overlay:n}=e,r=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&0>e.indexOf(s)&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)0>e.indexOf(s[n])&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]])}return i}(e,["overlay"]);let o=document.createElement("div"),a=this.getHeight(r.height,r.splitChannels);o.style.height=`${a}px`,n&&s>0&&(o.style.marginTop=`-${a}px`),this.canvasWrapper.style.minHeight=`${a}px`,this.canvasWrapper.appendChild(o);let l=o.cloneNode();this.progressWrapper.appendChild(l),this.renderMultiCanvas(t,r,i,a,o,l)}render(t){return r(this,void 0,void 0,function*(){var e;
74this.timeouts.forEach(t=>t()),this.timeouts=[],this.unsubscribeOnScroll.forEach(t=>t()),this.unsubscribeOnScroll=[],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(),s=this.scrollContainer.clientWidth-this.containerInlinePadding,{scrollWidth:n,isScrollable:r,useParentWidth:o,width:a}=function({duration:t,minPxPerSec:e=0,parentWidth:i,fillParent:s,pixelRatio:n}){let r=Math.ceil(t*e),o=r>i,a=!!(s&&!o);return{scrollWidth:r,isScrollable:o,useParentWidth:a,width:(a?i:r)*n}}({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:s,fillParent:this.options.fillParent,pixelRatio:i});if(this.isScrollable=r,this.wrapper.style.width=o?"100%":`${n}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 s=Object.assign(Object.assign({},this.options),null==(e=this.options.splitChannels)?void 0:e[i]);this.renderChannel([t.getChannelData(i)],s,a,i)}else{let e=[t.getChannelData(0)];t.numberOfChannels>1&&e.push(t.getChannelData(1)),this.renderChannel(e,this.options,a,0)}Promise.resolve().then(()=>
74this.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&&this.scrollContainer.scrollLeft)this.scrollContainer.scrollLeft=0;else if(this.isScrollable&&t!==this.scrollContainer.scrollWidth){let t,{right:i}=this.progressWrapper.getBoundingClientRect(),s=((t=2*(i-e))<0?Math.floor(t):Math.ceil(t))/2;this.scrollContainer.scrollLeft+=s}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){var i;let{scrollLeft:s,scrollWidth:n,clientWidth:r}=this.scrollContainer,o=t*n,a=s+r,l=r/2;if(this.isDragging)o+30>a?this.scrollContainer.scrollLeft+=30:o-30<s&&(this.scrollContainer.scrollLeft-=30);else{(o<s||o>a)&&(this.scrollContainer.scrollLeft=o-(this.options.autoCenter?l:0));let t=o-s-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+=n/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 r(this,void 0,void 0,function*(){let s=this.canvasWrapper.querySelectorAll("canvas");if(!s.length)throw Error("No waveform data");return"dataURL"===i?Promise.resolve(Array.from(s).map(i=>i.toDataURL(t,e))):Promise.all(Array.from(s).map(i=>new Promise((s,n)=>{i.toBlob(t=>{t?s(t):n(Error("Could not export image"))},t,e)})))})}}class S extends o{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;let t=()=>
74{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(),this.unAll()}}class w extends o{constructor(t){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._destroyed=!1,function(){let t=globalThis.navigator;if(null==t?void 0:t.audioSession)try{t.audioSession.type="playback"}catch(t){console.warn("Setting navigator.audioSession.type failed:",t)}}(),this.audioContext=t||new AudioContext,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return r(this,void 0,void 0,function*(){})}remove(){this.destroy()}destroy(){if(!this._destroyed){if(this._destroyed=!0,this.currentSrc="",this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}this.bufferNode.disconnect(),this.bufferNode=null}this.gainNode.disconnect(),"function"==typeof this.audioContext.close&&Promise.resolve(this.audioContext.close.call(this.audioContext)).catch(()=>{}),this.buffer=null,this.unAll()}}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.paused&&this.duration-this.currentTime<.01&&(this.pause(),this.emit("ended"))}}_pause(){if(this.paused=!0,this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}}this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return r(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)/this._playbackRate,i=this.bufferNode;null==i||i.stop(this.audioContext.currentTime+e),null==i||i.addEventListener("ended",()=>{i===this.bufferNode&&(this.bufferNode=null,this.pause(),this.playbackPosition=Math.min(t,this.duration),this.emit("timeupdate"))},{once:!0})}setSinkId(t){return r(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 k={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class x extends g{static create(t){return new x(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const e=t.media||("WebAudio"===t.backend?new w:void 0);
74super({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._isDestroyed=!1,this._loadVersion=0,this.reactiveCleanups=[],this.options=Object.assign({},k,t);const{state:i,actions:s}=function(t){var e,i,s,n,r,o;let a=null!=(e=null==t?void 0:t.currentTime)?e:c(0),l=null!=(i=null==t?void 0:t.duration)?i:c(0),h=null!=(s=null==t?void 0:t.isPlaying)?s:c(!1),d=null!=(n=null==t?void 0:t.isSeeking)?n:c(!1),u=null!=(r=null==t?void 0:t.volume)?r:c(1),m=null!=(o=null==t?void 0:t.playbackRate)?o:c(1),g=c(null),v=c(null),f=c(""),b=c(0),y=c(0),C=p(()=>!h.value,[h]),E=p(()=>null!==g.value,[g]),S=p(()=>E.value&&l.value>0,[E,l]),w=p(()=>a.value,[a]),k=p(()=>l.value>0?a.value/l.value:0,[a,l]);return{state:{currentTime:a,duration:l,isPlaying:h,isPaused:C,isSeeking:d,volume:u,playbackRate:m,audioBuffer:g,peaks:v,url:f,zoom:b,scrollPosition:y,canPlay:E,isReady:S,progress:w,progressPercent:k},actions:{setCurrentTime:t=>{let e=Math.max(0,Math.min(l.value||1/0,t));a.set(e)},setDuration:t=>{l.set(Math.max(0,t))},setPlaying:t=>{h.set(t)},setSeeking:t=>{d.set(t)},setVolume:t=>{let e=Math.max(0,Math.min(1,t));u.set(e)},setPlaybackRate:t=>{let e=Math.max(.1,Math.min(16,t));m.set(e)},setAudioBuffer:t=>{g.set(t),t&&l.set(t.duration)},setPeaks:t=>{v.set(t)},setUrl:t=>{f.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=s,this.timer=new S;const n=e?void 0:this.getMediaElement();this.renderer=new E(this.options,n),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");let{peaks:t,duration:e}=this.options;(r||t&&e)&&this.load(r,t,e).catch(()=>{})})}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();if(this.emit("timeupdate",t),this.emit("audioprocess",t),null!=this.stopAtPosition&&this.isPlaying()&&t>=this.stopAtPosition){let t=this.stopAtPosition;this.pause(),this.setTime(t)}}}))}initReactiveState(){var t,e;let i,s,n;this.reactiveCleanups.push((t=this.wavesurferState,e={emit:this.emit.bind(this)},(i=[]).push(m(()=>{let i=t.isPlaying.value;e.emit(i?"play":"pause")},[t.isPlaying])),i.push(m(()=>{let i=t.currentTime.value;e.emit("timeupdate",i),t.isPlaying.value&&e.emit("audioprocess",i)},[t.currentTime,t.isPlaying])),i.push(m(()=>{t.isSeeking.value&&e.emit("seeking",t.currentTime.value)},[t.isSeeking,t.currentTime])),s=!1,i.push(m(()=>{t.isReady.value&&!s&&(s=!0,e.emit("ready",t.duration.value))},[t.isReady,t.duration])),i.push(m(()=>{null===t.audioBuffer.value&&(s=!1)},[t.audioBuffer])),n=!1,i.push(m(()=>{let i=t.isPlaying.value,s=t.currentTime.value,r=t.duration.value,o=r>0&&s>=r;n&&!i&&o&&e.emit("finish"),n=i&&o},[t.isPlaying,t.currentTime,t.duration])),i.push(m(()=>{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;
74this.emit("error",null!=(t=this.getMediaElement().error)?t:Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,e)=>{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,s)=>{let n=this.getDuration();this.emit("scroll",t*n,e*n,i,s)}),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 s=0,n=this.options.dragToSeek;this.isPlaying()?s=0:!0===n?s=200:n&&"object"==typeof n&&(s=null!=(i=n.debounceTime)?i:200),t=setTimeout(()=>{this.seekTo(e)},s),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=a.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=a.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,s){return r(this,void 0,void 0,function*(){var n;let r=++this._loadVersion;if(this._isDestroyed=!1,this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,null==(n=this.abortController)||n.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 s=t=>this.emit("loading",t);if(e=yield u.fetchBlob(t,s,i),this._isDestroyed||r!==this._loadVersion)return;let n=this.options.blobMimeType;n&&(e=new Blob([e],{type:n}))}if(this._isDestroyed||r!==this._loadVersion)return;this.setSrc(t,e);let o=yield new Promise(t=>{let e=s||this.getDuration();e?t(e):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>t(this.getDuration()),{once:!0}))});if(!this._isDestroyed&&r===this._loadVersion){if(!t&&!e){let t=this.getMediaElement();t instanceof w&&(t.duration=o)}if(i)this.decodedData=a.createBuffer(i,o||0);else if(e){let t=yield e.arrayBuffer();if(this._isDestroyed||r!==this._loadVersion)return;this.decodedData=yield a.decode(t,this.options.sampleRate)}this._isDestroyed||r!==this._loadVersion||(this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration()))}})}load(t,e,i){return r(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 r(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");
74this.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 s=Math.min(t,this.decodedData.numberOfChannels),n=[];for(let t=0;t<s;t++){let s=this.decodedData.getChannelData(t),r=[],o=s.length/e;for(let t=0;t<e;t++){let e=s.slice(Math.floor(t*o),Math.ceil((t+1)*o)),n=0;for(let t=0;t<e.length;t++){let i=e[t];Math.abs(i)>Math.abs(n)&&(n=i)}r.push(Math.round(n*i)/i)}n.push(r)}return n}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("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 r(this,void 0,void 0,function*(){null!=t&&this.setTime(t);let s=yield i.play.call(this);return null!=e&&(this.media instanceof w?this.media.stopAt(e):this.stopAtPosition=e),s})}playPause(){return r(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 r(this,arguments,void 0,function*(t="image/png",e=1,i="dataURL"){return this.renderer.exportImage(t,e,i)})}destroy(){var t;this._isDestroyed=!0,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()}}x.BasePlugin=class extends o{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}},x.dom=d;let P=/^on([A-Z])/,M=t=>P.test(t),R=(0,n.memo)(t=>{var e;let i,r=(0,n.useRef)(null),[o,a]=(0,n.useMemo)(()=>{let e=Object.assign({},t),i=Object.assign({},t);for(let t in e)M(t)?delete e[t]:delete i[t];return[e,i]},[t]);return e=function(t,e){let[i,s]=(0,n.useState)(null),r=(0,n.useMemo)(()=>(function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&0>e.indexOf(s)&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)0>e.indexOf(s[n])&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]])}return i})(e,["plugins"]),[e]),o=(0,n.useMemo)(()=>Object.entries(r).flat(),[r]);return(0,n.useEffect)(()=>{if(!(null==t?void 0:t.current))return;let i=x.create(Object.assign(Object.assign({},r),{plugins:e.plugins,container:t.current}));return s(i),()=>{i.destroy()}},[t,e.plugins,...o]),i}(r,o),i=(0,n.useMemo)(()=>Object.entries(a).flat(),[a]),(0,n.useEffect)(()=>{if(!e)return;let t=Object.entries(a);if(!t.length)return;let i=t.map(([t,i])=>{let s=t.replace(P,(t,e)=>e.toLowerCase());return e.on(s,(...t)=>i(e,...t))});return()=>{i.forEach(t=>t())}},[e,...i]),(0,s.jsx)("div",{ref:r})})},91616:(t,e,i)=>{i.d(e,{A:()=>c});class s{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),null==i?void 0:i.once){let i=(...s)=>{this.un(t,i),e(...s)};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))}}class n extends s{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()}
74destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}function r(t,e,i){let s=function t(e,i){let s=i.xmlns?document.createElementNS(i.xmlns,e):document.createElement(e);for(let[e,n]of Object.entries(i))if("children"===e&&n)for(let[e,i]of Object.entries(n))i instanceof Node?s.appendChild(i):"string"==typeof i?s.appendChild(document.createTextNode(i)):s.appendChild(t(e,i));else"style"===e?Object.assign(s.style,n):"textContent"===e?s.textContent=n:s.setAttribute(e,n.toString());return s}(t,e||{});return null==i||i.appendChild(s),s}function o(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 a(t,e){let i,s=()=>{i&&(i(),i=void 0),i=t()},n=e.map(t=>t.subscribe(s));return s(),()=>{i&&(i(),i=void 0),n.forEach(t=>t())}}function l(t,e){let i=o(null),s=t=>{i.set(t)};return t.addEventListener(e,s),i._cleanup=()=>{t.removeEventListener(e,s)},i}function h(t){let e=t._cleanup;"function"==typeof e&&e()}function d(t,e={}){let{threshold:i=3,mouseButton:s=0,touchDelay:n=100}=e,r=o(null),a=new Map,l=matchMedia("(pointer: coarse)").matches,u=()=>{},c=e=>{if(e.button!==s||a.has(e.pointerId)||(a.set(e.pointerId,e),a.size>1))return;let o=e.pointerId,h=e.clientX,d=e.clientY,c=!1,p=Date.now(),{left:m,top:g}=t.getBoundingClientRect(),v=t=>{if(t.pointerId!==o||t.defaultPrevented||a.size>1||l&&Date.now()-p<n)return;let e=t.clientX,s=t.clientY,u=e-h,v=s-d;(c||Math.abs(u)>i||Math.abs(v)>i)&&(t.preventDefault(),t.stopPropagation(),c||(r.set({type:"start",x:h-m,y:d-g}),c=!0),r.set({type:"move",x:e-m,y:s-g,deltaX:u,deltaY:v}),h=e,d=s)},f=t=>{if(a.delete(t.pointerId)){if(t.pointerId===o&&c){let e=t.clientX,i=t.clientY;r.set({type:"end",x:e-m,y:i-g})}0===a.size&&u()}},b=t=>{t.relatedTarget&&t.relatedTarget!==document.documentElement||f(t)},y=t=>{c&&(t.stopPropagation(),t.preventDefault())},C=t=>{t.defaultPrevented||a.size>1||c&&t.preventDefault()};document.addEventListener("pointermove",v),document.addEventListener("pointerup",f),document.addEventListener("pointerout",b),document.addEventListener("pointercancel",b),document.addEventListener("touchmove",C,{passive:!1}),document.addEventListener("click",y,{capture:!0}),u=()=>{document.removeEventListener("pointermove",v),document.removeEventListener("pointerup",f),document.removeEventListener("pointerout",b),document.removeEventListener("pointercancel",b),document.removeEventListener("touchmove",C),setTimeout(()=>{document.removeEventListener("click",y,{capture:!0})},10)}};return t.addEventListener("pointerdown",c),{signal:r,cleanup:()=>{u(),t.removeEventListener("pointerdown",c),a.clear(),h(r)}}}class u extends s{constructor(t,e,i=0){var s,n,r,o,a,l,h,d,u,c;super(),this.totalDuration=e,this.numberOfChannels=i,this.element=null,this.minLength=0,this.maxLength=1/0,this.contentEditable=!1,this.subscriptions=[],this.updatingSide=void 0,this.isRemoved=!1,this.subscriptions=[],this.id=t.id||`region-${Math.random().toString(32).slice(2)}`,this.start=this.clampPosition(t.start),this.end=this.clampPosition(null!=(s=t.end)?s:t.start),this.drag=null==(n=t.drag)||n,this.resize=null==(r=t.resize)||r,this.resizeStart=null==(o=t.resizeStart)||o,this.resizeEnd=null==(a=t.resizeEnd)||a,this.color=null!=(l=t.color)?l:"rgba(0, 0, 0, 0.1)",this.minLength=null!=(h=t.minLength)?h:this.minLength,this.maxLength=null!=(d=t.maxLength)?d:this.maxLength,this.channelIdx=null!=(u=t.channelIdx)?u:-1,this.contentEditable=null!=(c=t.contentEditable)?c:this.contentEditable,this.element=this.initElement(),this.setContent(t.content),this.setPart(),this.renderPosition(),this.initMouseEvents()}clampPosition(t){return Math.max(0,Math.min(this.totalDuration,t))}setPart(){var t;let e=this.start===this.end;null==(t=this.element)||t.setAttribute("part",`${e?"marker":"region"} ${this.id}`)}addResizeHandles(t){let e={position:"absolute",zIndex:"2",width:"6px",height:"100%",top:"0",cursor:"ew-resize",wordBreak:"keep-all"},i=r("div",{part:"region-handle region-handle-left",style:Object.assign(Object.assign({}
74,e),{left:"0",borderLeft:"2px solid rgba(0, 0, 0, 0.5)",borderRadius:"2px 0 0 2px"})},t),s=r("div",{part:"region-handle region-handle-right",style:Object.assign(Object.assign({},e),{right:"0",borderRight:"2px solid rgba(0, 0, 0, 0.5)",borderRadius:"0 2px 2px 0"})},t),n=d(i,{threshold:1}),o=d(s,{threshold:1}),l=a(()=>{let t=n.signal.value;t&&("move"===t.type&&void 0!==t.deltaX?this.onResize(t.deltaX,"start"):"end"===t.type&&this.onEndResizing("start"))},[n.signal]),h=a(()=>{let t=o.signal.value;t&&("move"===t.type&&void 0!==t.deltaX?this.onResize(t.deltaX,"end"):"end"===t.type&&this.onEndResizing("end"))},[o.signal]);this.subscriptions.push(()=>{l(),h(),n.cleanup(),o.cleanup()})}removeResizeHandles(t){let e=t.querySelector('[part*="region-handle-left"]'),i=t.querySelector('[part*="region-handle-right"]');e&&t.removeChild(e),i&&t.removeChild(i)}initElement(){if(this.isRemoved)return null;let t=this.start===this.end,e=0,i=100;this.channelIdx>=0&&this.numberOfChannels>0&&this.channelIdx<this.numberOfChannels&&(e=(i=100/this.numberOfChannels)*this.channelIdx);let s=r("div",{style:{position:"absolute",top:`${e}%`,height:`${i}%`,backgroundColor:t?"none":this.color,borderLeft:t?"2px solid "+this.color:"none",borderRadius:"2px",boxSizing:"border-box",transition:"background-color 0.2s ease",cursor:this.drag?"grab":"default",pointerEvents:"all"}});return!t&&this.resize&&this.addResizeHandles(s),s}renderPosition(){if(!this.element)return;let t=this.start/this.totalDuration,e=(this.totalDuration-this.end)/this.totalDuration;this.element.style.left=100*t+"%",this.element.style.right=100*e+"%"}toggleCursor(t){var e;this.drag&&(null==(e=this.element)?void 0:e.style)&&(this.element.style.cursor=t?"grabbing":"grab")}initMouseEvents(){let{element:t}=this;if(!t)return;let e=l(t,"click"),i=l(t,"mouseenter"),s=l(t,"mouseleave"),n=l(t,"dblclick"),r=l(t,"pointerdown"),o=l(t,"pointerup"),u=e.subscribe(t=>t&&this.emit("click",t)),c=i.subscribe(t=>t&&this.emit("over",t)),p=s.subscribe(t=>t&&this.emit("leave",t)),m=n.subscribe(t=>t&&this.emit("dblclick",t)),g=r.subscribe(t=>t&&this.toggleCursor(!0)),v=o.subscribe(t=>t&&this.toggleCursor(!1));this.subscriptions.push(()=>{u(),c(),p(),m(),g(),v(),h(e),h(i),h(s),h(n),h(r),h(o)});let f=d(t),b=a(()=>{let t=f.signal.value;t&&("start"===t.type?this.toggleCursor(!0):"move"===t.type&&void 0!==t.deltaX?this.onMove(t.deltaX):"end"===t.type&&(this.toggleCursor(!1),this.drag&&this.emit("update-end")))},[f.signal]);this.subscriptions.push(()=>{b(),f.cleanup()}),this.contentEditable&&this.content&&(this.contentClickListener=t=>this.onContentClick(t),this.contentBlurListener=()=>this.onContentBlur(),this.content.addEventListener("click",this.contentClickListener),this.content.addEventListener("blur",this.contentBlurListener))}_onUpdate(t,e,i){var s;if(!(null==(s=this.element)?void 0:s.parentElement))return;let{width:n}=this.element.parentElement.getBoundingClientRect(),r=t/n*this.totalDuration,o=e&&"start"!==e?this.start:this.start+r,a=e&&"end"!==e?this.end:this.end+r,l=void 0!==i;l&&this.updatingSide&&this.updatingSide!==e&&("start"===this.updatingSide?o=i:a=i),o=Math.max(0,o);let h=(a=Math.min(this.totalDuration,a))-o;this.updatingSide=e;let d=h>=this.minLength&&h<=this.maxLength;o<=a&&(d||l)&&(this.start=o,this.end=a,this.renderPosition(),this.emit("update",e))}onMove(t){this.drag&&this._onUpdate(t)}onResize(t,e){this.resize&&(this.resizeStart||"start"!==e)&&(this.resizeEnd||"end"!==e)&&this._onUpdate(t,e)}
74onEndResizing(t){this.resize&&(this.emit("update-end",t),this.updatingSide=void 0)}onContentClick(t){t.stopPropagation(),t.target.focus(),this.emit("click",t)}onContentBlur(){this.emit("update-end")}_setTotalDuration(t){this.totalDuration=t,this.renderPosition()}play(t){this.emit("play",t&&this.end!==this.start?this.end:void 0)}getContent(t=!1){var e;return t?this.content||void 0:this.element instanceof HTMLElement?(null==(e=this.content)?void 0:e.innerHTML)||void 0:""}setContent(t){var e;if(this.element)if(this.content&&this.contentEditable&&(this.contentClickListener&&this.content.removeEventListener("click",this.contentClickListener),this.contentBlurListener&&this.content.removeEventListener("blur",this.contentBlurListener)),null==(e=this.content)||e.remove(),t){if("string"==typeof t){let e=this.start===this.end;this.content=r("div",{style:{padding:`0.2em ${e?.2:.4}em`,display:"inline-block"},textContent:t})}else this.content=t;this.contentEditable&&(this.content.contentEditable="true",this.contentClickListener=t=>this.onContentClick(t),this.contentBlurListener=()=>this.onContentBlur(),this.content.addEventListener("click",this.contentClickListener),this.content.addEventListener("blur",this.contentBlurListener)),this.content.setAttribute("part","region-content"),this.element.appendChild(this.content),this.emit("content-changed")}else this.content=void 0}setOptions(t){var e,i;if(this.element){if(t.color&&(this.color=t.color,this.element.style.backgroundColor=this.color),void 0!==t.drag&&(this.drag=t.drag,this.element.style.cursor=this.drag?"grab":"default"),void 0!==t.start||void 0!==t.end){let s=this.start===this.end;this.start=this.clampPosition(null!=(e=t.start)?e:this.start),this.end=this.clampPosition(null!=(i=t.end)?i:s?this.start:this.end),this.renderPosition(),this.setPart(),this.emit("render")}if(t.content&&this.setContent(t.content),t.id&&(this.id=t.id,this.setPart()),void 0!==t.resize&&t.resize!==this.resize){let e=this.start===this.end;this.resize=t.resize,this.resize&&!e?this.addResizeHandles(this.element):this.removeResizeHandles(this.element)}void 0!==t.resizeStart&&(this.resizeStart=t.resizeStart),void 0!==t.resizeEnd&&(this.resizeEnd=t.resizeEnd)}}remove(){this.isRemoved=!0,this.emit("remove"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.content&&this.contentEditable&&(this.contentClickListener&&(this.content.removeEventListener("click",this.contentClickListener),this.contentClickListener=void 0),this.contentBlurListener&&(this.content.removeEventListener("blur",this.contentBlurListener),this.contentBlurListener=void 0)),this.element&&(this.element.remove(),this.element=null),this.unAll()}}class c extends n{constructor(t){super(t),this.regions=[],this.regionsContainer=this.initRegionsContainer()}static create(t){return new c(t)}onInit(){if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");this.wavesurfer.getWrapper().appendChild(this.regionsContainer),this.subscriptions.push(this.wavesurfer.on("ready",t=>{this.regions.forEach(e=>e._setTotalDuration(t))}));let t=[];this.subscriptions.push(this.wavesurfer.on("timeupdate",e=>{let i=this.regions.filter(t=>t.start<=e&&(t.end===t.start?t.start+.05:t.end)>=e);i.forEach(e=>{t.includes(e)||this.emit("region-in",e)}),t.forEach(t=>{i.includes(t)||this.emit("region-out",t)}),t=i}))}initRegionsContainer(){return r("div",{part:"regions-container",style:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",zIndex:"5",pointerEvents:"none"}})}getRegions(){return this.regions}avoidOverlapping(t){t.content&&!t.isRemoved&&setTimeout(()=>{if(!t.content)return;let e=t.content;e.style.marginTop="0";let i=e.getBoundingClientRect(),s=this.regions.indexOf(t);if(s<0)return;let n=this.regions.slice(0,s).filter(t=>!t.isRemoved).reduce((e,s)=>{if(s===t||!s.content)return e;let n=s.content.getBoundingClientRect();return i.left<n.right&&n.left<i.right&&e.push(n),e},[]).sort((t,e)=>t.top-e.top).reduce((t,e)=>{let s=i.top+t,n=s+i.height;return s<e.bottom&&e.top<n?e.bottom-i.top+2:t},0);e.style.marginTop=`${n}px`},10)}avoidOverlappingAll(){this.regions.forEach(t=>this.avoidOverlapping(t))}adjustScroll(t){var e,i;if(!t.element)return;let s=null==(i=null==(e=this.wavesurfer)?void 0:e.getWrapper())?void 0:i.parentElement;if(!s)return;let{clientWidth:n,scrollWidth:r}=s;if(r<=n)return;let o=s.getBoundingClientRect(),a=t.element.getBoundingClientRect(),l=a.left-o.left,h=a.right-o.left;l<0?s.scrollLeft+=l:h>n&&(s.scrollLeft+=h-n)}virtualAppend(t,e,i){let s=()=>
74{if(!this.wavesurfer)return;let s=this.wavesurfer.getWidth(),n=this.wavesurfer.getScroll(),r=e.clientWidth,o=this.wavesurfer.getDuration(),a=Math.round(t.start/o*r),l=a+(Math.round((t.end-t.start)/o*r)||1)>n&&a<n+s;l&&!i.parentElement?e.appendChild(i):!l&&i.parentElement&&i.remove()};setTimeout(()=>{if(!this.wavesurfer||!t.element)return;s();let e=this.wavesurfer.on("scroll",s),i=this.wavesurfer.on("zoom",s),n=this.wavesurfer.on("resize",s),r=t.on("render",s);this.subscriptions.push(e,i,n,r),t.once("remove",()=>{e(),i(),n(),r()})},0)}saveRegion(t){if(!t.element)return;this.virtualAppend(t,this.regionsContainer,t.element),this.avoidOverlapping(t),this.regions.push(t);let e=[t.on("update",e=>{e||this.adjustScroll(t),this.emit("region-update",t,e)}),t.on("update-end",e=>{this.avoidOverlappingAll(),this.emit("region-updated",t,e)}),t.on("play",e=>{var i;null==(i=this.wavesurfer)||i.play(t.start,e)}),t.on("click",e=>{this.emit("region-clicked",t,e)}),t.on("dblclick",e=>{this.emit("region-double-clicked",t,e)}),t.on("content-changed",()=>{this.emit("region-content-changed",t)}),t.once("remove",()=>{e.forEach(t=>t()),this.regions=this.regions.filter(e=>e!==t),this.emit("region-removed",t)})];this.subscriptions.push(...e),this.emit("region-created",t)}addRegion(t){var e,i;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");let s=this.wavesurfer.getDuration(),n=new u(t,s,null==(i=null==(e=this.wavesurfer)?void 0:e.getDecodedData())?void 0:i.numberOfChannels);return this.emit("region-initialized",n),s?this.saveRegion(n):this.subscriptions.push(this.wavesurfer.once("ready",t=>{n._setTotalDuration(t),this.saveRegion(n)})),n}enableDragSelection(t,e=3){var i;let s=null==(i=this.wavesurfer)?void 0:i.getWrapper();if(!(s&&s instanceof HTMLElement))return()=>{};let n=null,r=0,o=0,l=d(s,{threshold:e}),h=a(()=>{var e,i;let s=l.signal.value;if(s)if("start"===s.type){if(r=s.x,!this.wavesurfer)return;let a=this.wavesurfer.getDuration(),l=null==(i=null==(e=this.wavesurfer)?void 0:e.getDecodedData())?void 0:i.numberOfChannels,{width:h}=this.wavesurfer.getWrapper().getBoundingClientRect();o=r/h*a;let d=s.x/h*a,c=(s.x+5)/h*a;n=new u(Object.assign(Object.assign({},t),{start:d,end:c}),a,l),this.emit("region-initialized",n),n.element&&this.regionsContainer.appendChild(n.element)}else"move"===s.type&&void 0!==s.deltaX?n&&n._onUpdate(s.deltaX,s.x>r?"end":"start",o):"end"===s.type&&n&&(this.saveRegion(n),n.updatingSide=void 0,n=null)},[l.signal]);return()=>{h(),l.cleanup()}}clearRegions(){this.regions.slice().forEach(t=>t.remove()),this.regions=[]}destroy(){this.clearRegions(),super.destroy(),this.regionsContainer.remove()}}}}]);

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.