@waveform-playlist/browser 5.0.0-alpha.9 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,28 +1,10 @@
1
- "use strict";var wa=Object.create;var Pn=Object.defineProperty;var xa=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var Ia=Object.getPrototypeOf,Sa=Object.prototype.hasOwnProperty;var Aa=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ya(t))!Sa.call(e,a)&&a!==n&&Pn(e,a,{get:()=>t[a],enumerable:!(r=xa(t,a))||r.enumerable});return e};var ka=(e,t,n)=>(n=e!=null?wa(Ia(e)):{},Aa(t||!e||!e.__esModule?Pn(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("tone"),c=require("react"),k=require("styled-components");require("react-dom");var cn=typeof document<"u"?document.currentScript:null;function Fr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Wr=Fr(P),Q=Fr(c);var jt={exports:{}},kt={};var Vn;function $a(){if(Vn)return kt;Vn=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,s){var o=null;if(s!==void 0&&(o=""+s),a.key!==void 0&&(o=""+a.key),"key"in a){s={};for(var l in a)l!=="key"&&(s[l]=a[l])}else s=a;return a=s.ref,{$$typeof:e,type:r,key:o,ref:a!==void 0?a:null,props:s}}return kt.Fragment=t,kt.jsx=n,kt.jsxs=n,kt}var $t={};var jn;function Ra(){return jn||(jn=1,process.env.NODE_ENV!=="production"&&(function(){function e(A){if(A==null)return null;if(typeof A=="function")return A.$$typeof===D?null:A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case g:return"Fragment";case w:return"Profiler";case m:return"StrictMode";case I:return"Suspense";case $:return"SuspenseList";case _:return"Activity"}if(typeof A=="object")switch(typeof A.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),A.$$typeof){case y:return"Portal";case v:return A.displayName||"Context";case x:return(A._context.displayName||"Context")+".Consumer";case S:var j=A.render;return A=A.displayName,A||(A=j.displayName||j.name||"",A=A!==""?"ForwardRef("+A+")":"ForwardRef"),A;case M:return j=A.displayName||null,j!==null?j:e(A.type)||"Memo";case T:j=A._payload,A=A._init;try{return e(A(j))}catch{}}return null}function t(A){return""+A}function n(A){try{t(A);var j=!1}catch{j=!0}if(j){j=console;var H=j.error,U=typeof Symbol=="function"&&Symbol.toStringTag&&A[Symbol.toStringTag]||A.constructor.name||"Object";return H.call(j,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",U),t(A)}}function r(A){if(A===g)return"<>";if(typeof A=="object"&&A!==null&&A.$$typeof===T)return"<...>";try{var j=e(A);return j?"<"+j+">":"<...>"}catch{return"<...>"}}function a(){var A=V.A;return A===null?null:A.getOwner()}function s(){return Error("react-stack-top-frame")}function o(A){if(W.call(A,"key")){var j=Object.getOwnPropertyDescriptor(A,"key").get;if(j&&j.isReactWarning)return!1}return A.key!==void 0}function l(A,j){function H(){Y||(Y=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",j))}H.isReactWarning=!0,Object.defineProperty(A,"key",{get:H,configurable:!0})}function i(){var A=e(this.type);return ee[A]||(ee[A]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),A=this.props.ref,A!==void 0?A:null}function u(A,j,H,U,ge,Be){var ie=H.ref;return A={$$typeof:C,type:A,key:j,props:H,_owner:U},(ie!==void 0?ie:null)!==null?Object.defineProperty(A,"ref",{enumerable:!1,get:i}):Object.defineProperty(A,"ref",{enumerable:!1,value:null}),A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(A,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(A,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ge}),Object.defineProperty(A,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Be}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A}function d(A,j,H,U,ge,Be){var ie=j.children;if(ie!==void 0)if(U)if(O(ie)){for(U=0;U<ie.length;U++)b(ie[U]);Object.freeze&&Object.freeze(ie)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(ie);if(W.call(j,"key")){ie=e(A);var Te=Object.keys(j).filter(function(me){return me!=="key"});U=0<Te.length?"{key: someKey, "+Te.join(": ..., ")+": ...}":"{key: someKey}",oe[ie+U]||(Te=0<Te.length?"{"+Te.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,U,ie,Te,ie),oe[ie+U]=!0)}if(ie=null,H!==void 0&&(n(H),ie=""+H),o(j)&&(n(j.key),ie=""+j.key),"key"in j){H={};for(var ue in j)ue!=="key"&&(H[ue]=j[ue])}else H=j;return ie&&l(H,typeof A=="function"?A.displayName||A.name||"Unknown":A),u(A,ie,H,a(),ge,Be)}function b(A){p(A)?A._store&&(A._store.validated=1):typeof A=="object"&&A!==null&&A.$$typeof===T&&(A._payload.status==="fulfilled"?p(A._payload.value)&&A._payload.value._store&&(A._payload.value._store.validated=1):A._store&&(A._store.validated=1))}function p(A){return typeof A=="object"&&A!==null&&A.$$typeof===C}var f=c,C=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),v=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),D=Symbol.for("react.client.reference"),V=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,O=Array.isArray,N=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(A){return A()}};var Y,ee={},re=f.react_stack_bottom_frame.bind(f,s)(),X=N(r(s)),oe={};$t.Fragment=g,$t.jsx=function(A,j,H){var U=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!1,U?Error("react-stack-top-frame"):re,U?N(r(A)):X)},$t.jsxs=function(A,j,H){var U=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!0,U?Error("react-stack-top-frame"):re,U?N(r(A)):X)}})()),$t}var zn;function Ea(){return zn||(zn=1,process.env.NODE_ENV==="production"?jt.exports=$a():jt.exports=Ra()),jt.exports}var Z=Ea();function On(e,t){const n=new Float32Array(e),r=e-1;for(let a=0;a<e;a++){const s=a/r;n[a]=t?s:1-s}return n}function Da(e,t){const n=new Float32Array(e),r=e-1;for(let a=0;a<e;a++){const s=a/r,o=t?a:e-1-a;n[o]=Math.exp(2*s-1)/Math.E}return n}function Ta(e,t){const n=new Float32Array(e),r=t?Math.PI/2:-Math.PI/2;for(let a=0;a<e;a++)n[a]=Math.sin(Math.PI*a/e-r)/2+.5;return n}function _a(e,t,n=10){const r=new Float32Array(e);for(let a=0;a<e;a++){const s=t?a:e-1-a,o=a/e;r[s]=Math.log(1+n*o)/Math.log(1+n)}return r}function Zr(e,t,n){switch(e){case"linear":return On(t,n);case"exponential":return Da(t,n);case"sCurve":return Ta(t,n);case"logarithmic":return _a(t,n);default:return On(t,n)}}function Nn(e,t,n,r="linear",a=0,s=1){if(!(n<=0))if(r==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Zr(r,1e4,!0),l=new Float32Array(o.length),i=s-a;for(let u=0;u<o.length;u++)l[u]=a+o[u]*i;e.setValueCurveAtTime(l,t,n)}}function Ln(e,t,n,r="linear",a=1,s=0){if(!(n<=0))if(r==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Zr(r,1e4,!1),l=new Float32Array(o.length),i=a-s;for(let u=0;u<o.length;u++)l[u]=s+o[u]*i;e.setValueCurveAtTime(l,t,n)}}var Ma=class{constructor(e){this.activePlayers=0,this.track=e.track,this.volumeNode=new P.Volume(this.gainToDb(e.track.gain)),this.panNode=new P.Panner(e.track.stereoPan),this.muteGain=new P.Gain(e.track.muted?0:1);const t=e.destination||P.getDestination();if(e.effects){const r=e.effects(this.muteGain,t,!1);r&&(this.effectsCleanup=r)}else this.muteGain.connect(t);const n=e.clips||(e.buffer?[{buffer:e.buffer,startTime:0,duration:e.buffer.duration,offset:0,fadeIn:e.track.fadeIn,fadeOut:e.track.fadeOut,gain:1}]:[]);this.clips=n.map(r=>{const a=new P.Player({url:r.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),s=new P.Gain(r.gain);return a.connect(s),s.chain(this.volumeNode,this.panNode,this.muteGain),{player:a,clipInfo:r,fadeGain:s,pausedPosition:0,playStartTime:0}})}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGain:a}=e,s=a.gain._param;s.cancelScheduledValues(0);const o=n-r.offset;if(r.fadeIn&&o<r.fadeIn.duration){const l=r.fadeIn.duration;if(o<=0)Nn(s,t,l,r.fadeIn.type||"linear",0,r.gain);else{const i=l-o,u=o/l,d=r.gain*u;Nn(s,t,i,r.fadeIn.type||"linear",d,r.gain)}}else s.setValueAtTime(r.gain,t);if(r.fadeOut){const i=r.duration-r.fadeOut.duration-o;if(i>0){const u=t+i;Ln(s,u,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(i>-r.fadeOut.duration){const u=-i,d=r.fadeOut.duration-u,b=u/r.fadeOut.duration,p=r.gain*(1-b);Ln(s,t,d,r.fadeOut.type||"linear",p,0)}}}gainToDb(e){return 20*Math.log10(e)}setVolume(e){this.track.gain=e,this.volumeNode.volume.value=this.gainToDb(e)}setPan(e){this.track.stereoPan=e,this.panNode.pan.value=e}setMute(e){this.track.muted=e,this.muteGain.gain.value=e?0:1}setSolo(e){this.track.soloed=e}play(e,t=0,n){this.clips.forEach(r=>{r.player.stop(),r.player.disconnect(),r.player.dispose();const a=new P.Player({url:r.clipInfo.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}});a.connect(r.fadeGain),r.player=a,r.pausedPosition=0}),this.activePlayers=0,this.clips.forEach(r=>{const{player:a,clipInfo:s}=r,o=t,l=s.startTime,i=s.startTime+s.duration;if(o<i){this.activePlayers++;const u=e??P.now();if(r.playStartTime=u,o>=l){const d=o-l+s.offset,b=s.duration-(o-l),p=n?Math.min(n,b):b;r.pausedPosition=d,this.scheduleFades(r,u,d),a.start(u,d,p)}else{const d=l-o,b=n?Math.min(n-d,s.duration):s.duration;d<(n??1/0)?(r.pausedPosition=s.offset,this.scheduleFades(r,u+d,s.offset),a.start(u+d,s.offset,b)):this.activePlayers--}}})}pause(){this.clips.forEach(e=>{if(e.player.state==="started"){const t=(P.now()-e.playStartTime)*e.player.playbackRate;e.pausedPosition=e.pausedPosition+t}e.player.stop()}),this.activePlayers=0}stop(e){const t=e??P.now();this.clips.forEach(n=>{n.player.stop(t),n.pausedPosition=0}),this.activePlayers=0}dispose(){this.effectsCleanup&&this.effectsCleanup(),this.clips.forEach(e=>{e.player.dispose(),e.fadeGain.dispose()}),this.volumeNode.dispose(),this.panNode.dispose(),this.muteGain.dispose()}get id(){return this.track.id}get duration(){if(this.clips.length===0)return 0;const e=this.clips[this.clips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.clips[0]?.clipInfo.buffer}get isPlaying(){return this.clips.some(e=>e.player.state==="started")}get muted(){return this.track.muted}get startTime(){return this.track.startTime}setOnStopCallback(e){this.onStopCallback=e}},Ba=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this.activeTracks=new Map,this.playbackSessionId=0,this.masterVolume=new P.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,P.getDestination(),!1);t&&(this.effectsCleanup=t)}else this.masterVolume.toDestination();e.tracks&&e.tracks.forEach(t=>{this.tracks.set(t.id,t),this.manualMuteState.set(t.id,t.muted)})}gainToDb(e){return 20*Math.log10(e)}async init(){this.isInitialized||(await P.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new Ma(t);return this.tracks.set(n.id,n),this.manualMuteState.set(n.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(n.id),n}applyInitialSoloState(){this.updateSoloMuting()}removeTrack(e){const t=this.tracks.get(e);t&&(t.dispose(),this.tracks.delete(e),this.manualMuteState.delete(e),this.soloedTracks.delete(e))}getTrack(e){return this.tracks.get(e)}play(e,t,n){if(!this.isInitialized){console.warn("TonePlayout not initialized. Call init() first.");return}const r=e??P.now(),a=t??0;this.playbackSessionId++;const s=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const l=o.startTime;if(a>=l){const i=a-l;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r,i,n)}else{const i=l-a;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r+i,0,n)}}),t!==void 0?P.getTransport().start(r,t):P.getTransport().start(r)}pause(){P.getTransport().pause(),this.tracks.forEach(e=>{e.pause()})}stop(){P.getTransport().stop(),this.tracks.forEach(e=>{e.stop()})}setMasterGain(e){this.masterVolume.volume.value=this.gainToDb(e)}setSolo(e,t){const n=this.tracks.get(e);n&&(n.setSolo(t),t?this.soloedTracks.add(e):this.soloedTracks.delete(e),this.updateSoloMuting())}updateSoloMuting(){const e=this.soloedTracks.size>0;this.tracks.forEach((t,n)=>{if(e)if(!this.soloedTracks.has(n))t.setMute(!0);else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}})}setMute(e,t){const n=this.tracks.get(e);n&&(this.manualMuteState.set(e,t),n.setMute(t))}getCurrentTime(){return P.getTransport().seconds}seekTo(e){P.getTransport().seconds=e}dispose(){this.tracks.forEach(e=>{e.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return P.getContext()}get sampleRate(){return P.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},zt=null;function Fa(){return zt||(zt=new P.Context,P.setContext(zt)),zt}async function un(){const e=Fa();e.state!=="running"&&await e.resume()}var Ot={exports:{}},Rt={};var Xn;function Wa(){if(Xn)return Rt;Xn=1;var e=c,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(l,i,u){var d,b={},p=null,f=null;u!==void 0&&(p=""+u),i.key!==void 0&&(p=""+i.key),i.ref!==void 0&&(f=i.ref);for(d in i)r.call(i,d)&&!s.hasOwnProperty(d)&&(b[d]=i[d]);if(l&&l.defaultProps)for(d in i=l.defaultProps,i)b[d]===void 0&&(b[d]=i[d]);return{$$typeof:t,type:l,key:p,ref:f,props:b,_owner:a.current}}return Rt.Fragment=n,Rt.jsx=o,Rt.jsxs=o,Rt}var Et={};var Hn;function Za(){return Hn||(Hn=1,process.env.NODE_ENV!=="production"&&(function(){var e=c,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),i=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),C=Symbol.iterator,y="@@iterator";function g(h){if(h===null||typeof h!="object")return null;var R=C&&h[C]||h[y];return typeof R=="function"?R:null}var m=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(h){{for(var R=arguments.length,F=new Array(R>1?R-1:0),J=1;J<R;J++)F[J-1]=arguments[J];x("error",h,F)}}function x(h,R,F){{var J=m.ReactDebugCurrentFrame,se=J.getStackAddendum();se!==""&&(R+="%s",F=F.concat([se]));var ce=F.map(function(ae){return String(ae)});ce.unshift("Warning: "+R),Function.prototype.apply.call(console[h],console,ce)}}var v=!1,S=!1,I=!1,$=!1,M=!1,T;T=Symbol.for("react.module.reference");function _(h){return!!(typeof h=="string"||typeof h=="function"||h===r||h===s||M||h===a||h===u||h===d||$||h===f||v||S||I||typeof h=="object"&&h!==null&&(h.$$typeof===p||h.$$typeof===b||h.$$typeof===o||h.$$typeof===l||h.$$typeof===i||h.$$typeof===T||h.getModuleId!==void 0))}function D(h,R,F){var J=h.displayName;if(J)return J;var se=R.displayName||R.name||"";return se!==""?F+"("+se+")":F}function V(h){return h.displayName||"Context"}function W(h){if(h==null)return null;if(typeof h.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case a:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof h=="object")switch(h.$$typeof){case l:var R=h;return V(R)+".Consumer";case o:var F=h;return V(F._context)+".Provider";case i:return D(h,h.render,"ForwardRef");case b:var J=h.displayName||null;return J!==null?J:W(h.type)||"Memo";case p:{var se=h,ce=se._payload,ae=se._init;try{return W(ae(ce))}catch{return null}}}return null}var O=Object.assign,N=0,Y,ee,re,X,oe,A,j;function H(){}H.__reactDisabledLog=!0;function U(){{if(N===0){Y=console.log,ee=console.info,re=console.warn,X=console.error,oe=console.group,A=console.groupCollapsed,j=console.groupEnd;var h={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:h,log:h,warn:h,error:h,group:h,groupCollapsed:h,groupEnd:h})}N++}}function ge(){{if(N--,N===0){var h={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},h,{value:Y}),info:O({},h,{value:ee}),warn:O({},h,{value:re}),error:O({},h,{value:X}),group:O({},h,{value:oe}),groupCollapsed:O({},h,{value:A}),groupEnd:O({},h,{value:j})})}N<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Be=m.ReactCurrentDispatcher,ie;function Te(h,R,F){{if(ie===void 0)try{throw Error()}catch(se){var J=se.stack.trim().match(/\n( *(at )?)/);ie=J&&J[1]||""}return`
7
- `+ie+h}}var ue=!1,me;{var gt=typeof WeakMap=="function"?WeakMap:Map;me=new gt}function dt(h,R){if(!h||ue)return"";{var F=me.get(h);if(F!==void 0)return F}var J;ue=!0;var se=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ce;ce=Be.current,Be.current=null,U();try{if(R){var ae=function(){throw Error()};if(Object.defineProperty(ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ae,[])}catch(B){J=B}Reflect.construct(h,[],ae)}else{try{ae.call()}catch(B){J=B}h.call(ae.prototype)}}else{try{throw Error()}catch(B){J=B}h()}}catch(B){if(B&&J&&typeof B.stack=="string"){for(var ne=B.stack.split(`
8
- `),ke=J.stack.split(`
9
- `),pe=ne.length-1,ve=ke.length-1;pe>=1&&ve>=0&&ne[pe]!==ke[ve];)ve--;for(;pe>=1&&ve>=0;pe--,ve--)if(ne[pe]!==ke[ve]){if(pe!==1||ve!==1)do if(pe--,ve--,ve<0||ne[pe]!==ke[ve]){var Me=`
10
- `+ne[pe].replace(" at new "," at ");return h.displayName&&Me.includes("<anonymous>")&&(Me=Me.replace("<anonymous>",h.displayName)),typeof h=="function"&&me.set(h,Me),Me}while(pe>=1&&ve>=0);break}}}finally{ue=!1,Be.current=ce,ge(),Error.prepareStackTrace=se}var lt=h?h.displayName||h.name:"",et=lt?Te(lt):"";return typeof h=="function"&&me.set(h,et),et}function de(h,R,F){return dt(h,!1)}function at(h){var R=h.prototype;return!!(R&&R.isReactComponent)}function ot(h,R,F){if(h==null)return"";if(typeof h=="function")return dt(h,at(h));if(typeof h=="string")return Te(h);switch(h){case u:return Te("Suspense");case d:return Te("SuspenseList")}if(typeof h=="object")switch(h.$$typeof){case i:return de(h.render);case b:return ot(h.type,R,F);case p:{var J=h,se=J._payload,ce=J._init;try{return ot(ce(se),R,F)}catch{}}}return""}var Je=Object.prototype.hasOwnProperty,st={},z=m.ReactDebugCurrentFrame;function Re(h){if(h){var R=h._owner,F=ot(h.type,h._source,R?R.type:null);z.setExtraStackFrame(F)}else z.setExtraStackFrame(null)}function xe(h,R,F,J,se){{var ce=Function.call.bind(Je);for(var ae in h)if(ce(h,ae)){var ne=void 0;try{if(typeof h[ae]!="function"){var ke=Error((J||"React class")+": "+F+" type `"+ae+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof h[ae]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ke.name="Invariant Violation",ke}ne=h[ae](R,ae,J,F,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pe){ne=pe}ne&&!(ne instanceof Error)&&(Re(se),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",J||"React class",F,ae,typeof ne),Re(null)),ne instanceof Error&&!(ne.message in st)&&(st[ne.message]=!0,Re(se),w("Failed %s type: %s",F,ne.message),Re(null))}}}var be=Array.isArray;function Ze(h){return be(h)}function Xe(h){{var R=typeof Symbol=="function"&&Symbol.toStringTag,F=R&&h[Symbol.toStringTag]||h.constructor.name||"Object";return F}}function Pe(h){try{return He(h),!1}catch{return!0}}function He(h){return""+h}function Ge(h){if(Pe(h))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Xe(h)),He(h)}var ft=m.ReactCurrentOwner,At={key:!0,ref:!0,__self:!0,__source:!0},K,te;function he(h){if(Je.call(h,"ref")){var R=Object.getOwnPropertyDescriptor(h,"ref").get;if(R&&R.isReactWarning)return!1}return h.ref!==void 0}function ye(h){if(Je.call(h,"key")){var R=Object.getOwnPropertyDescriptor(h,"key").get;if(R&&R.isReactWarning)return!1}return h.key!==void 0}function Ee(h,R){typeof h.ref=="string"&&ft.current}function Ae(h,R){{var F=function(){K||(K=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",R))};F.isReactWarning=!0,Object.defineProperty(h,"key",{get:F,configurable:!0})}}function le(h,R){{var F=function(){te||(te=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",R))};F.isReactWarning=!0,Object.defineProperty(h,"ref",{get:F,configurable:!0})}}var Ye=function(h,R,F,J,se,ce,ae){var ne={$$typeof:t,type:h,key:R,ref:F,props:ae,_owner:ce};return ne._store={},Object.defineProperty(ne._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ne,"_self",{configurable:!1,enumerable:!1,writable:!1,value:J}),Object.defineProperty(ne,"_source",{configurable:!1,enumerable:!1,writable:!1,value:se}),Object.freeze&&(Object.freeze(ne.props),Object.freeze(ne)),ne};function Ke(h,R,F,J,se){{var ce,ae={},ne=null,ke=null;F!==void 0&&(Ge(F),ne=""+F),ye(R)&&(Ge(R.key),ne=""+R.key),he(R)&&(ke=R.ref,Ee(R,se));for(ce in R)Je.call(R,ce)&&!At.hasOwnProperty(ce)&&(ae[ce]=R[ce]);if(h&&h.defaultProps){var pe=h.defaultProps;for(ce in pe)ae[ce]===void 0&&(ae[ce]=pe[ce])}if(ne||ke){var ve=typeof h=="function"?h.displayName||h.name||"Unknown":h;ne&&Ae(ae,ve),ke&&le(ae,ve)}return Ye(h,ne,ke,se,J,ft.current,ae)}}var ze=m.ReactCurrentOwner,_e=m.ReactDebugCurrentFrame;function Ie(h){if(h){var R=h._owner,F=ot(h.type,h._source,R?R.type:null);_e.setExtraStackFrame(F)}else _e.setExtraStackFrame(null)}var qe;qe=!1;function mt(h){return typeof h=="object"&&h!==null&&h.$$typeof===t}function Bt(){{if(ze.current){var h=W(ze.current.type);if(h)return`
11
-
12
- Check the render method of \``+h+"`."}return""}}function it(h){return""}var Ft={};function ht(h){{var R=Bt();if(!R){var F=typeof h=="string"?h:h.displayName||h.name;F&&(R=`
13
-
14
- Check the top-level render call using <`+F+">.")}return R}}function Wt(h,R){{if(!h._store||h._store.validated||h.key!=null)return;h._store.validated=!0;var F=ht(R);if(Ft[F])return;Ft[F]=!0;var J="";h&&h._owner&&h._owner!==ze.current&&(J=" It was passed a child from "+W(h._owner.type)+"."),Ie(h),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',F,J),Ie(null)}}function Zt(h,R){{if(typeof h!="object")return;if(Ze(h))for(var F=0;F<h.length;F++){var J=h[F];mt(J)&&Wt(J,R)}else if(mt(h))h._store&&(h._store.validated=!0);else if(h){var se=g(h);if(typeof se=="function"&&se!==h.entries)for(var ce=se.call(h),ae;!(ae=ce.next()).done;)mt(ae.value)&&Wt(ae.value,R)}}}function bt(h){{var R=h.type;if(R==null||typeof R=="string")return;var F;if(typeof R=="function")F=R.propTypes;else if(typeof R=="object"&&(R.$$typeof===i||R.$$typeof===b))F=R.propTypes;else return;if(F){var J=W(R);xe(F,h.props,"prop",J,h)}else if(R.PropTypes!==void 0&&!qe){qe=!0;var se=W(R);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",se||"Unknown")}typeof R.getDefaultProps=="function"&&!R.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qe(h){{for(var R=Object.keys(h.props),F=0;F<R.length;F++){var J=R[F];if(J!=="children"&&J!=="key"){Ie(h),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",J),Ie(null);break}}h.ref!==null&&(Ie(h),w("Invalid attribute `ref` supplied to `React.Fragment`."),Ie(null))}}var Fe={};function vt(h,R,F,J,se,ce){{var ae=_(h);if(!ae){var ne="";(h===void 0||typeof h=="object"&&h!==null&&Object.keys(h).length===0)&&(ne+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ke=it();ke?ne+=ke:ne+=Bt();var pe;h===null?pe="null":Ze(h)?pe="array":h!==void 0&&h.$$typeof===t?(pe="<"+(W(h.type)||"Unknown")+" />",ne=" Did you accidentally export a JSX literal instead of a component?"):pe=typeof h,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",pe,ne)}var ve=Ke(h,R,F,se,ce);if(ve==null)return ve;if(ae){var Me=R.children;if(Me!==void 0)if(J)if(Ze(Me)){for(var lt=0;lt<Me.length;lt++)Zt(Me[lt],h);Object.freeze&&Object.freeze(Me)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Zt(Me,h)}if(Je.call(R,"key")){var et=W(h),B=Object.keys(R).filter(function(fe){return fe!=="key"}),L=B.length>0?"{key: someKey, "+B.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[et+L]){var q=B.length>0?"{"+B.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
15
- let props = %s;
16
- <%s {...props} />
17
- React keys must be passed directly to JSX without using spread:
18
- let props = %s;
19
- <%s key={someKey} {...props} />`,L,et,q,et),Fe[et+L]=!0}}return h===r?Qe(ve):bt(ve),ve}}function rn(h,R,F){return vt(h,R,F,!0)}function an(h,R,F){return vt(h,R,F,!1)}var on=an,sn=rn;Et.Fragment=r,Et.jsx=on,Et.jsxs=sn})()),Et}var Gn;function Pa(){return Gn||(Gn=1,process.env.NODE_ENV==="production"?Ot.exports=Wa():Ot.exports=Za()),Ot.exports}var E=Pa();const Va=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ut=Va?c.useLayoutEffect:c.useEffect;function ja(e){const t=c.useRef(e);return Ut(()=>{t.current=e}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}function Pr(e,t){t===void 0&&(t=[e]);const n=c.useRef(e);return Ut(()=>{n.current!==e&&(n.current=e)},t),n}function Ht(e){const t=ja(e),n=c.useRef(null),r=c.useCallback(a=>{a!==n.current&&t?.(a,n.current),n.current=a},[]);return[n,r]}let dn={};function Vr(e,t){return c.useMemo(()=>{const n=dn[e]==null?0:dn[e]+1;return dn[e]=n,e+"-"+n},[e,t])}const Cn=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Cn.Translate.toString(e),Cn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}});var Yn;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Yn||(Yn={}));function Kn(){}const za=Object.freeze({x:0,y:0});var wt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(wt||(wt={}));var Un;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Un||(Un={}));var ct;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(ct||(ct={}));ct.Space,ct.Enter,ct.Esc,ct.Space,ct.Enter,ct.Tab;var Jn;(function(e){e[e.RightClick=2]="RightClick"})(Jn||(Jn={}));var qn;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qn||(qn={}));var Qn;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Qn||(Qn={}));wt.Backward+"",wt.Forward+"",wt.Backward+"",wt.Forward+"";var wn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(wn||(wn={}));var xn;(function(e){e.Optimized="optimized"})(xn||(xn={}));function Oa(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:s}=r;return n[a]=o=>{s(o,t)},n},{}),[e,t])}wn.WhileDragging,xn.Optimized;const Na={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Kn,draggableNodes:new Map,over:null,measureDroppableContainers:Kn},La=c.createContext(Na),Xa=c.createContext({...za,scaleX:1,scaleY:1});var er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(er||(er={}));const Ha=c.createContext(null),tr="button",Ga="Draggable";function fn(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Vr(Ga),{activators:o,activatorEvent:l,active:i,activeNodeRect:u,ariaDescribedById:d,draggableNodes:b,over:p}=c.useContext(La),{role:f=tr,roleDescription:C="draggable",tabIndex:y=0}=a??{},g=i?.id===t,m=c.useContext(g?Xa:Ha),[w,x]=Ht(),[v,S]=Ht(),I=Oa(o,t),$=Pr(n);Ut(()=>(b.set(t,{id:t,key:s,node:w,activatorNode:v,data:$}),()=>{const T=b.get(t);T&&T.key===s&&b.delete(t)}),[b,t]);const M=c.useMemo(()=>({role:f,tabIndex:y,"aria-disabled":r,"aria-pressed":g&&f===tr?!0:void 0,"aria-roledescription":C,"aria-describedby":d.draggable}),[r,f,y,g,C,d.draggable]);return{active:i,activatorEvent:l,activeNodeRect:u,attributes:M,isDragging:g,listeners:r?void 0:I,node:w,over:p,setNodeRef:x,setActivatorNodeRef:S,transform:m}}const Ya=new Map([["bold",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,1,1-18-15.88,20,20,0,0,0,0-26.43,12,12,0,0,1,18-15.86A43.94,43.94,0,0,1,212,128Zm40,0a83.87,83.87,0,0,1-21.39,56,12,12,0,0,1-17.89-16,60,60,0,0,0,0-80,12,12,0,1,1,17.88-16A83.87,83.87,0,0,1,252,128Z"}))],["duotone",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),Q.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["fill",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z"}))],["light",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66Zm50.53-108.85a38,38,0,0,1,0,50.24,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93ZM246,128a77.86,77.86,0,0,1-19.86,52,6,6,0,1,1-8.94-8,66,66,0,0,0,0-88,6,6,0,1,1,8.94-8A77.86,77.86,0,0,1,246,128Z"}))],["regular",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["thin",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M153.76,28.41a4,4,0,0,0-4.22.43L78.63,84H32A12,12,0,0,0,20,96v64a12,12,0,0,0,12,12H78.63l70.91,55.16A4.07,4.07,0,0,0,152,228a3.92,3.92,0,0,0,1.76-.41A4,4,0,0,0,156,224V32A4,4,0,0,0,153.76,28.41ZM28,160V96a4,4,0,0,1,4-4H76v72H32A4,4,0,0,1,28,160Zm120,55.82L84,166V90l64-49.78Zm47-111.61a36,36,0,0,1,0,47.59,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28ZM244,128a75.88,75.88,0,0,1-19.35,50.67,4,4,0,0,1-6-5.34,68,68,0,0,0,0-90.66,4,4,0,0,1,6-5.34A75.88,75.88,0,0,1,244,128Z"}))]]),Ka=new Map([["bold",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,0,1-18-15.88,20,20,0,0,0,0-26.44,12,12,0,0,1,18-15.85A43.94,43.94,0,0,1,212,128Z"}))],["duotone",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),Q.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["fill",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80ZM198,101.56a8,8,0,1,0-12,10.58,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88Z"}))],["light",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66ZM206,128a37.94,37.94,0,0,1-9.5,25.14,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93A38,38,0,0,1,206,128Z"}))],["regular",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["thin",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M153.76,28.41a4,4,0,0,0-4.22.43L78.63,84H32A12,12,0,0,0,20,96v64a12,12,0,0,0,12,12H78.63l70.91,55.16A4.07,4.07,0,0,0,152,228a3.92,3.92,0,0,0,1.76-.41A4,4,0,0,0,156,224V32A4,4,0,0,0,153.76,28.41ZM28,160V96a4,4,0,0,1,4-4H76v72H32A4,4,0,0,1,28,160Zm120,55.82L84,166V90l64-49.78ZM204,128a36,36,0,0,1-9,23.82,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28A36,36,0,0,1,204,128Z"}))]]),Ua=c.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),En=Q.forwardRef((e,t)=>{const{alt:n,color:r,size:a,weight:s,mirrored:o,children:l,weights:i,...u}=e,{color:d="currentColor",size:b,weight:p="regular",mirrored:f=!1,...C}=Q.useContext(Ua);return Q.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:a??b,height:a??b,fill:r??d,viewBox:"0 0 256 256",transform:o||f?"scale(-1, 1)":void 0,...C,...u},!!n&&Q.createElement("title",null,n),l,i.get(s??p))});En.displayName="IconBase";const jr=Q.forwardRef((e,t)=>Q.createElement(En,{ref:t,...e,weights:Ya}));jr.displayName="SpeakerHighIcon";const zr=Q.forwardRef((e,t)=>Q.createElement(En,{ref:t,...e,weights:Ka}));zr.displayName="SpeakerLowIcon";k.span`
1
+ "use strict";var $a=Object.create;var Jt=Object.defineProperty;var Ma=Object.getOwnPropertyDescriptor;var Ra=Object.getOwnPropertyNames;var Ea=Object.getPrototypeOf,Da=Object.prototype.hasOwnProperty;var Ba=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ra(t))!Da.call(e,r)&&r!==n&&Jt(e,r,{get:()=>t[r],enumerable:!(a=Ma(t,r))||a.enumerable});return e};var Ta=(e,t,n)=>(n=e!=null?$a(Ea(e)):{},Ba(t||!e||!e.__esModule?Jt(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("tone"),b=require("react/jsx-runtime"),i=require("react"),S=require("styled-components"),Ee=require("@dnd-kit/core"),Wa=require("@dnd-kit/modifiers");var Bt=typeof document<"u"?document.currentScript:null;function bn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const vn=bn(W),N=bn(i);function qt(e,t){const n=new Float32Array(e),a=e-1;for(let r=0;r<e;r++){const s=r/a;n[r]=t?s:1-s}return n}function _a(e,t){const n=new Float32Array(e),a=e-1;for(let r=0;r<e;r++){const s=r/a,o=t?r:e-1-r;n[o]=Math.exp(2*s-1)/Math.E}return n}function Fa(e,t){const n=new Float32Array(e),a=t?Math.PI/2:-Math.PI/2;for(let r=0;r<e;r++)n[r]=Math.sin(Math.PI*r/e-a)/2+.5;return n}function Za(e,t,n=10){const a=new Float32Array(e);for(let r=0;r<e;r++){const s=t?r:e-1-r,o=r/e;a[s]=Math.log(1+n*o)/Math.log(1+n)}return a}function Cn(e,t,n){switch(e){case"linear":return qt(t,n);case"exponential":return _a(t,n);case"sCurve":return Fa(t,n);case"logarithmic":return Za(t,n);default:return qt(t,n)}}function Qt(e,t,n,a="linear",r=0,s=1){if(!(n<=0))if(a==="linear")e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,t+n);else if(a==="exponential")e.setValueAtTime(Math.max(r,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Cn(a,1e4,!0),l=new Float32Array(o.length),c=s-r;for(let u=0;u<o.length;u++)l[u]=r+o[u]*c;e.setValueCurveAtTime(l,t,n)}}function en(e,t,n,a="linear",r=1,s=0){if(!(n<=0))if(a==="linear")e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,t+n);else if(a==="exponential")e.setValueAtTime(Math.max(r,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Cn(a,1e4,!1),l=new Float32Array(o.length),c=r-s;for(let u=0;u<o.length;u++)l[u]=s+o[u]*c;e.setValueCurveAtTime(l,t,n)}}var Va=class{constructor(e){this.activePlayers=0,this.track=e.track,this.volumeNode=new W.Volume(this.gainToDb(e.track.gain)),this.panNode=new W.Panner(e.track.stereoPan),this.muteGain=new W.Gain(e.track.muted?0:1);const t=e.destination||W.getDestination();if(e.effects){const a=e.effects(this.muteGain,t,!1);a&&(this.effectsCleanup=a)}else this.muteGain.connect(t);const n=e.clips||(e.buffer?[{buffer:e.buffer,startTime:0,duration:e.buffer.duration,offset:0,fadeIn:e.track.fadeIn,fadeOut:e.track.fadeOut,gain:1}]:[]);this.clips=n.map(a=>{const r=new W.Player({url:a.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),s=new W.Gain(a.gain);return r.connect(s),s.chain(this.volumeNode,this.panNode,this.muteGain),{player:r,clipInfo:a,fadeGain:s,pausedPosition:0,playStartTime:0}})}scheduleFades(e,t,n=0){const{clipInfo:a,fadeGain:r}=e,s=r.gain._param;s.cancelScheduledValues(0);const o=n-a.offset;if(a.fadeIn&&o<a.fadeIn.duration){const l=a.fadeIn.duration;if(o<=0)Qt(s,t,l,a.fadeIn.type||"linear",0,a.gain);else{const c=l-o,u=o/l,d=a.gain*u;Qt(s,t,c,a.fadeIn.type||"linear",d,a.gain)}}else s.setValueAtTime(a.gain,t);if(a.fadeOut){const c=a.duration-a.fadeOut.duration-o;if(c>0){const u=t+c;en(s,u,a.fadeOut.duration,a.fadeOut.type||"linear",a.gain,0)}else if(c>-a.fadeOut.duration){const u=-c,d=a.fadeOut.duration-u,v=u/a.fadeOut.duration,p=a.gain*(1-v);en(s,t,d,a.fadeOut.type||"linear",p,0)}}}gainToDb(e){return 20*Math.log10(e)}setVolume(e){this.track.gain=e,this.volumeNode.volume.value=this.gainToDb(e)}setPan(e){this.track.stereoPan=e,this.panNode.pan.value=e}setMute(e){this.track.muted=e,this.muteGain.gain.value=e?0:1}setSolo(e){this.track.soloed=e}play(e,t=0,n){this.clips.forEach(a=>{a.player.stop(),a.player.disconnect(),a.player.dispose();const r=new W.Player({url:a.clipInfo.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}});r.connect(a.fadeGain),a.player=r,a.pausedPosition=0}),this.activePlayers=0,this.clips.forEach(a=>{const{player:r,clipInfo:s}=a,o=t,l=s.startTime,c=s.startTime+s.duration;if(o<c){this.activePlayers++;const u=e??W.now();if(a.playStartTime=u,o>=l){const d=o-l+s.offset,v=s.duration-(o-l),p=n?Math.min(n,v):v;a.pausedPosition=d,this.scheduleFades(a,u,d),r.start(u,d,p)}else{const d=l-o,v=n?Math.min(n-d,s.duration):s.duration;d<(n??1/0)?(a.pausedPosition=s.offset,this.scheduleFades(a,u+d,s.offset),r.start(u+d,s.offset,v)):this.activePlayers--}}})}pause(){this.clips.forEach(e=>{if(e.player.state==="started"){const t=(W.now()-e.playStartTime)*e.player.playbackRate;e.pausedPosition=e.pausedPosition+t}e.player.stop()}),this.activePlayers=0}stop(e){const t=e??W.now();this.clips.forEach(n=>{n.player.stop(t),n.pausedPosition=0}),this.activePlayers=0}dispose(){this.effectsCleanup&&this.effectsCleanup(),this.clips.forEach(e=>{e.player.dispose(),e.fadeGain.dispose()}),this.volumeNode.dispose(),this.panNode.dispose(),this.muteGain.dispose()}get id(){return this.track.id}get duration(){if(this.clips.length===0)return 0;const e=this.clips[this.clips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.clips[0]?.clipInfo.buffer}get isPlaying(){return this.clips.some(e=>e.player.state==="started")}get muted(){return this.track.muted}get startTime(){return this.track.startTime}setOnStopCallback(e){this.onStopCallback=e}},Pa=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this.activeTracks=new Map,this.playbackSessionId=0,this.masterVolume=new W.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,W.getDestination(),!1);t&&(this.effectsCleanup=t)}else this.masterVolume.toDestination();e.tracks&&e.tracks.forEach(t=>{this.tracks.set(t.id,t),this.manualMuteState.set(t.id,t.muted)})}gainToDb(e){return 20*Math.log10(e)}async init(){this.isInitialized||(await W.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new Va(t);return this.tracks.set(n.id,n),this.manualMuteState.set(n.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(n.id),n}applyInitialSoloState(){this.updateSoloMuting()}removeTrack(e){const t=this.tracks.get(e);t&&(t.dispose(),this.tracks.delete(e),this.manualMuteState.delete(e),this.soloedTracks.delete(e))}getTrack(e){return this.tracks.get(e)}play(e,t,n){if(!this.isInitialized){console.warn("TonePlayout not initialized. Call init() first.");return}const a=e??W.now(),r=t??0;this.playbackSessionId++;const s=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const l=o.startTime;if(r>=l){const c=r-l;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(a,c,n)}else{const c=l-r;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(a+c,0,n)}}),t!==void 0?W.getTransport().start(a,t):W.getTransport().start(a)}pause(){W.getTransport().pause(),this.tracks.forEach(e=>{e.pause()})}stop(){W.getTransport().stop(),this.tracks.forEach(e=>{e.stop()})}setMasterGain(e){this.masterVolume.volume.value=this.gainToDb(e)}setSolo(e,t){const n=this.tracks.get(e);n&&(n.setSolo(t),t?this.soloedTracks.add(e):this.soloedTracks.delete(e),this.updateSoloMuting())}updateSoloMuting(){const e=this.soloedTracks.size>0;this.tracks.forEach((t,n)=>{if(e)if(!this.soloedTracks.has(n))t.setMute(!0);else{const a=this.manualMuteState.get(n)??!1;t.setMute(a)}else{const a=this.manualMuteState.get(n)??!1;t.setMute(a)}})}setMute(e,t){const n=this.tracks.get(e);n&&(this.manualMuteState.set(e,t),n.setMute(t))}getCurrentTime(){return W.getTransport().seconds}seekTo(e){W.getTransport().seconds=e}dispose(){this.tracks.forEach(e=>{e.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return W.getContext()}get sampleRate(){return W.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},pt=null;function za(){return pt||(pt=new W.Context,W.setContext(pt)),pt}async function Tt(){const e=za();e.state!=="running"&&await e.resume()}const Ft=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Ft.Translate.toString(e),Ft.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:a}=e;return t+" "+n+"ms "+a}}}),ja=new Map([["bold",N.createElement(N.Fragment,null,N.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,1,1-18-15.88,20,20,0,0,0,0-26.43,12,12,0,0,1,18-15.86A43.94,43.94,0,0,1,212,128Zm40,0a83.87,83.87,0,0,1-21.39,56,12,12,0,0,1-17.89-16,60,60,0,0,0,0-80,12,12,0,1,1,17.88-16A83.87,83.87,0,0,1,252,128Z"}))],["duotone",N.createElement(N.Fragment,null,N.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),N.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["fill",N.createElement(N.Fragment,null,N.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z"}))],["light",N.createElement(N.Fragment,null,N.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66Zm50.53-108.85a38,38,0,0,1,0,50.24,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93ZM246,128a77.86,77.86,0,0,1-19.86,52,6,6,0,1,1-8.94-8,66,66,0,0,0,0-88,6,6,0,1,1,8.94-8A77.86,77.86,0,0,1,246,128Z"}))],["regular",N.createElement(N.Fragment,null,N.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["thin",N.createElement(N.Fragment,null,N.createElement("path",{d:"M153.76,28.41a4,4,0,0,0-4.22.43L78.63,84H32A12,12,0,0,0,20,96v64a12,12,0,0,0,12,12H78.63l70.91,55.16A4.07,4.07,0,0,0,152,228a3.92,3.92,0,0,0,1.76-.41A4,4,0,0,0,156,224V32A4,4,0,0,0,153.76,28.41ZM28,160V96a4,4,0,0,1,4-4H76v72H32A4,4,0,0,1,28,160Zm120,55.82L84,166V90l64-49.78Zm47-111.61a36,36,0,0,1,0,47.59,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28ZM244,128a75.88,75.88,0,0,1-19.35,50.67,4,4,0,0,1-6-5.34,68,68,0,0,0,0-90.66,4,4,0,0,1,6-5.34A75.88,75.88,0,0,1,244,128Z"}))]]),Ha=new Map([["bold",N.createElement(N.Fragment,null,N.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,0,1-18-15.88,20,20,0,0,0,0-26.44,12,12,0,0,1,18-15.85A43.94,43.94,0,0,1,212,128Z"}))],["duotone",N.createElement(N.Fragment,null,N.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),N.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["fill",N.createElement(N.Fragment,null,N.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80ZM198,101.56a8,8,0,1,0-12,10.58,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88Z"}))],["light",N.createElement(N.Fragment,null,N.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66ZM206,128a37.94,37.94,0,0,1-9.5,25.14,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93A38,38,0,0,1,206,128Z"}))],["regular",N.createElement(N.Fragment,null,N.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["thin",N.createElement(N.Fragment,null,N.createElement("path",{d:"M153.76,28.41a4,4,0,0,0-4.22.43L78.63,84H32A12,12,0,0,0,20,96v64a12,12,0,0,0,12,12H78.63l70.91,55.16A4.07,4.07,0,0,0,152,228a3.92,3.92,0,0,0,1.76-.41A4,4,0,0,0,156,224V32A4,4,0,0,0,153.76,28.41ZM28,160V96a4,4,0,0,1,4-4H76v72H32A4,4,0,0,1,28,160Zm120,55.82L84,166V90l64-49.78ZM204,128a36,36,0,0,1-9,23.82,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28A36,36,0,0,1,204,128Z"}))]]),Xa=i.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Pt=N.forwardRef((e,t)=>{const{alt:n,color:a,size:r,weight:s,mirrored:o,children:l,weights:c,...u}=e,{color:d="currentColor",size:v,weight:p="regular",mirrored:f=!1,...C}=N.useContext(Xa);return N.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:r??v,height:r??v,fill:a??d,viewBox:"0 0 256 256",transform:o||f?"scale(-1, 1)":void 0,...C,...u},!!n&&N.createElement("title",null,n),l,c.get(s??p))});Pt.displayName="IconBase";const xn=N.forwardRef((e,t)=>N.createElement(Pt,{ref:t,...e,weights:ja}));xn.displayName="SpeakerHighIcon";const wn=N.forwardRef((e,t)=>N.createElement(Pt,{ref:t,...e,weights:Ha}));wn.displayName="SpeakerLowIcon";S.span`
20
2
  font-family: 'Courier New', Monaco, monospace;
21
3
  font-size: 1rem;
22
4
  font-weight: 600;
23
5
  color: ${e=>e.theme?.textColor||"#333"};
24
6
  user-select: none;
25
- `;var Dn=k.button`
7
+ `;var zt=S.button`
26
8
  display: inline-flex;
27
9
  align-items: center;
28
10
  justify-content: center;
@@ -51,37 +33,37 @@ React keys must be passed directly to JSX without using spread:
51
33
  opacity: 0.6;
52
34
  cursor: not-allowed;
53
35
  }
54
- `;k(Dn)`
36
+ `;S(zt)`
55
37
  padding: 0.25rem 0.5rem;
56
38
  font-size: ${e=>e.theme.fontSizeSmall};
57
- `;k(Dn)`
39
+ `;S(zt)`
58
40
  padding: 0.5rem;
59
41
  min-width: 2.25rem;
60
42
  min-height: 2.25rem;
61
- `;k(Dn)`
43
+ `;S(zt)`
62
44
  padding: 0.25rem;
63
45
  min-width: 1.75rem;
64
46
  min-height: 1.75rem;
65
47
  font-size: ${e=>e.theme.fontSizeSmall};
66
- `;var Jt=k.div`
48
+ `;var wt=S.div`
67
49
  display: inline-flex;
68
50
  align-items: center;
69
51
  gap: 0.5rem;
70
- `,qt=k.input`
52
+ `,yt=S.input`
71
53
  cursor: pointer;
72
54
  accent-color: ${e=>e.theme.inputFocusBorder};
73
55
 
74
56
  &:disabled {
75
57
  cursor: not-allowed;
76
58
  }
77
- `,Qt=k.label`
59
+ `,kt=S.label`
78
60
  margin: 0;
79
61
  cursor: pointer;
80
62
  user-select: none;
81
63
  font-family: ${e=>e.theme.fontFamily};
82
64
  font-size: ${e=>e.theme.fontSize};
83
65
  color: ${e=>e.theme.textColor};
84
- `,Ne=k.button`
66
+ `,Be=S.button`
85
67
  padding: 0.5rem 1rem;
86
68
  background: ${e=>e.theme.buttonBackground||"#007bff"};
87
69
  color: ${e=>e.theme.buttonText||"white"};
@@ -107,7 +89,7 @@ React keys must be passed directly to JSX without using spread:
107
89
  cursor: not-allowed;
108
90
  opacity: 0.6;
109
91
  }
110
- `,Or=k.input`
92
+ `,yn=S.input`
111
93
  padding: 0.5rem 0.75rem;
112
94
  font-family: ${e=>e.theme.fontFamily};
113
95
  font-size: ${e=>e.theme.fontSize};
@@ -131,17 +113,17 @@ React keys must be passed directly to JSX without using spread:
131
113
  opacity: 0.6;
132
114
  cursor: not-allowed;
133
115
  }
134
- `;k(Or)`
116
+ `;S(yn)`
135
117
  padding: 0.25rem 0.5rem;
136
118
  font-size: ${e=>e.theme.fontSizeSmall};
137
- `;var Nr=k.label`
119
+ `;var kn=S.label`
138
120
  font-family: ${e=>e.theme.fontFamily};
139
121
  font-size: ${e=>e.theme.fontSizeSmall};
140
122
  font-weight: 500;
141
123
  color: ${e=>e.theme.textColorMuted};
142
124
  margin-bottom: 0.25rem;
143
125
  display: block;
144
- `;k.label`
126
+ `;S.label`
145
127
  font-family: ${e=>e.theme.fontFamily};
146
128
  font-size: ${e=>e.theme.fontSize};
147
129
  color: ${e=>e.theme.textColor};
@@ -149,7 +131,7 @@ React keys must be passed directly to JSX without using spread:
149
131
  align-items: center;
150
132
  gap: 0.5rem;
151
133
  cursor: pointer;
152
- `;var Ja=k.span`
134
+ `;var Ga=S.span`
153
135
  position: absolute;
154
136
  width: 1px;
155
137
  height: 1px;
@@ -159,7 +141,7 @@ React keys must be passed directly to JSX without using spread:
159
141
  clip: rect(0, 0, 0, 0);
160
142
  white-space: nowrap;
161
143
  border: 0;
162
- `,Tn=k.select`
144
+ `,jt=S.select`
163
145
  padding: 0.5rem 2rem 0.5rem 0.75rem;
164
146
  font-family: ${e=>e.theme.fontFamily};
165
147
  font-size: ${e=>e.theme.fontSize};
@@ -190,10 +172,10 @@ React keys must be passed directly to JSX without using spread:
190
172
  color: ${e=>e.theme.inputText};
191
173
  background-color: ${e=>e.theme.inputBackground};
192
174
  }
193
- `;k(Tn)`
175
+ `;S(jt)`
194
176
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
195
177
  font-size: ${e=>e.theme.fontSizeSmall};
196
- `;var Lr=k.input.attrs({type:"range"})`
178
+ `;var In=S.input.attrs({type:"range"})`
197
179
  -webkit-appearance: none;
198
180
  appearance: none;
199
181
  width: 100%;
@@ -269,7 +251,7 @@ React keys must be passed directly to JSX without using spread:
269
251
  &:disabled::-moz-range-thumb {
270
252
  cursor: not-allowed;
271
253
  }
272
- `,qa=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return E.jsxs(Jt,{className:r,children:[E.jsx(qt,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:a,disabled:n}),E.jsx(Qt,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Xr(e){return typeof e=="object"&&e!==null&&"type"in e}function Gt(e){if(!Xr(e))return e;const t=e.direction==="vertical"?"to bottom":"to right",n=e.stops.map(r=>`${r.color} ${r.offset*100}%`).join(", ");return`linear-gradient(${t}, ${n})`}var Qa={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",timeColor:"#000",timescaleBackgroundColor:"#fff",playheadColor:"#f00",selectionColor:"rgba(255, 105, 180, 0.7)",loopRegionColor:"rgba(59, 130, 246, 0.3)",loopMarkerColor:"#3b82f6",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},eo=1e3;function to(e,t,n,r){if(!Xr(t))return t;let a;t.direction==="vertical"?a=e.createLinearGradient(0,0,0,r):a=e.createLinearGradient(0,0,n,0);for(const s of t.stops)a.addColorStop(s.offset,s.color);return a}var no=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
254
+ `,Na=({checked:e,onChange:t,disabled:n=!1,className:a})=>{const r=s=>{t(s.target.checked)};return b.jsxs(wt,{className:a,children:[b.jsx(yt,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:r,disabled:n}),b.jsx(kt,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Sn(e){return typeof e=="object"&&e!==null&&"type"in e}function Ue(e){if(!Sn(e))return e;const t=e.direction==="vertical"?"to bottom":"to right",n=e.stops.map(a=>`${a.color} ${a.offset*100}%`).join(", ");return`linear-gradient(${t}, ${n})`}var An={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",timeColor:"#000",timescaleBackgroundColor:"#fff",playheadColor:"#f00",selectionColor:"rgba(255, 105, 180, 0.7)",loopRegionColor:"rgba(59, 130, 246, 0.3)",loopMarkerColor:"#3b82f6",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},La=1e3;function Ya(e,t,n,a){if(!Sn(t))return t;let r;t.direction==="vertical"?r=e.createLinearGradient(0,0,0,a):r=e.createLinearGradient(0,0,n,0);for(const s of t.stops)r.addColorStop(s.offset,s.color);return r}var Oa=S.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
273
255
  float: left;
274
256
  position: relative;
275
257
  /* Promote to own compositing layer for smoother scrolling */
@@ -277,15 +259,15 @@ React keys must be passed directly to JSX without using spread:
277
259
  /* Disable image rendering interpolation */
278
260
  image-rendering: pixelated;
279
261
  image-rendering: crisp-edges;
280
- `,ro=k.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
262
+ `,Ka=S.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
281
263
  position: absolute;
282
264
  background: ${e=>e.$waveFillColor};
283
265
  /* Force GPU compositing layer to reduce scroll flickering */
284
266
  transform: translateZ(0);
285
267
  backface-visibility: hidden;
286
- `,ao=e=>{const{data:t,bits:n,length:r,index:a,className:s,devicePixelRatio:o=1,waveHeight:l=80,waveOutlineColor:i="#E0EFF1",waveFillColor:u="grey",barWidth:d=1,barGap:b=0,transparentBackground:p=!1,drawMode:f="inverted"}=e,C=c.useRef([]),y=c.useCallback(S=>{if(S!==null){const I=parseInt(S.dataset.index,10);C.current[I]=S}},[]);c.useLayoutEffect(()=>{const S=C.current,I=d+b;let $=0;for(let M=0;M<S.length;M++){const T=S[M],_=T.getContext("2d"),D=Math.floor(l/2),V=2**(n-1);if(_){_.resetTransform(),_.clearRect(0,0,T.width,T.height),_.imageSmoothingEnabled=!1,_.scale(o,o);const W=T.width/o;let O;f==="normal"?O=u:O=i,_.fillStyle=to(_,O,W,l);const N=$,Y=$+W,ee=Math.floor((N-d+I)/I)*I;for(let re=Math.max(0,ee);re<Y;re+=I){const X=re-N;if(X+d<=0)continue;const oe=re;if(oe*2+1<t.length){const A=t[oe*2]/V,j=t[oe*2+1]/V,H=Math.abs(A*D),U=Math.abs(j*D);f==="normal"?_.fillRect(X,D-U,d,U+H):(_.fillRect(X,0,d,D-U),_.fillRect(X,D+H,d,D-H))}}}$+=T.width/o}},[t,n,l,i,u,o,r,d,b,f]);let g=r,m=0;const w=[];for(;g>0;){const S=Math.min(g,eo),I=E.jsx(no,{$cssWidth:S,width:S*o,height:l*o,$waveHeight:l,"data-index":m,ref:y},`${r}-${m}`);w.push(I),g-=S,m+=1}const v=p?"transparent":Gt(u);return E.jsx(ro,{$index:a,$cssWidth:r,className:s,$waveHeight:l,$waveFillColor:v,children:w})},Hr=22,Gr=k.div`
268
+ `,Ua=e=>{const{data:t,bits:n,length:a,index:r,className:s,devicePixelRatio:o=1,waveHeight:l=80,waveOutlineColor:c="#E0EFF1",waveFillColor:u="grey",barWidth:d=1,barGap:v=0,transparentBackground:p=!1,drawMode:f="inverted"}=e,C=i.useRef([]),y=i.useCallback(w=>{if(w!==null){const k=parseInt(w.dataset.index,10);C.current[k]=w}},[]);i.useLayoutEffect(()=>{const w=C.current,k=d+v;let A=0;for(let M=0;M<w.length;M++){const $=w[M],E=$.getContext("2d"),R=Math.floor(l/2),T=2**(n-1);if(E){E.resetTransform(),E.clearRect(0,0,$.width,$.height),E.imageSmoothingEnabled=!1,E.scale(o,o);const D=$.width/o;let z;f==="normal"?z=u:z=c,E.fillStyle=Ya(E,z,D,l);const V=A,_=A+D,L=Math.floor((V-d+k)/k)*k;for(let X=Math.max(0,L);X<_;X+=k){const F=X-V;if(F+d<=0)continue;const K=X;if(K*2+1<t.length){const ae=t[K*2]/T,te=t[K*2+1]/T,q=Math.abs(ae*R),ne=Math.abs(te*R);f==="normal"?E.fillRect(F,R-ne,d,ne+q):(E.fillRect(F,0,d,R-ne),E.fillRect(F,R+q,d,R-q))}}}A+=$.width/o}},[t,n,l,c,u,o,a,d,v,f]);let m=a,g=0;const I=[];for(;m>0;){const w=Math.min(m,La),k=b.jsx(Oa,{$cssWidth:w,width:w*o,height:l*o,$waveHeight:l,"data-index":g,ref:y},`${a}-${g}`);I.push(k),m-=w,g+=1}const h=p?"transparent":Ue(u);return b.jsx(Ka,{$index:r,$cssWidth:a,className:s,$waveHeight:l,$waveFillColor:h,children:I})},$n=22,Mn=S.div`
287
269
  position: relative;
288
- height: ${Hr}px;
270
+ height: ${$n}px;
289
271
  background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
290
272
  border-bottom: 1px solid ${e=>e.theme.clipHeaderBorderColor};
291
273
  display: flex;
@@ -307,7 +289,7 @@ React keys must be passed directly to JSX without using spread:
307
289
  cursor: grabbing;
308
290
  }
309
291
  `}
310
- `,Yr=k.span`
292
+ `,Rn=S.span`
311
293
  font-size: 11px;
312
294
  font-weight: 600;
313
295
  font-family: ${e=>e.theme.clipHeaderFontFamily};
@@ -315,12 +297,12 @@ React keys must be passed directly to JSX without using spread:
315
297
  white-space: nowrap;
316
298
  overflow: hidden;
317
299
  text-overflow: ellipsis;
318
- `,oo=({trackName:e,isSelected:t=!1})=>E.jsx(Gr,{$isDragging:!1,$interactive:!1,$isSelected:t,children:E.jsx(Yr,{children:e})}),so=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:a=!1,disableDrag:s=!1,dragHandleProps:o})=>{if(s||!o)return E.jsx(oo,{trackName:r,isSelected:a});const{attributes:l,listeners:i,setActivatorNodeRef:u}=o;return E.jsx(Gr,{ref:u,"data-clip-id":e,$interactive:!0,$isSelected:a,...i,...l,children:E.jsx(Yr,{children:r})})},io=8,lo=24,co=k.div`
300
+ `,Ja=({trackName:e,isSelected:t=!1})=>b.jsx(Mn,{$isDragging:!1,$interactive:!1,$isSelected:t,children:b.jsx(Rn,{children:e})}),qa=({clipId:e,trackIndex:t,clipIndex:n,trackName:a,isSelected:r=!1,disableDrag:s=!1,dragHandleProps:o})=>{if(s||!o)return b.jsx(Ja,{trackName:a,isSelected:r});const{attributes:l,listeners:c,setActivatorNodeRef:u}=o;return b.jsx(Mn,{ref:u,"data-clip-id":e,$interactive:!0,$isSelected:r,...c,...l,children:b.jsx(Rn,{children:a})})},Qa=8,er=24,tr=S.div`
319
301
  position: absolute;
320
302
  ${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
321
303
  top: 0;
322
304
  bottom: 0;
323
- width: ${e=>e.$touchOptimized?lo:io}px;
305
+ width: ${e=>e.$touchOptimized?er:Qa}px;
324
306
  cursor: col-resize;
325
307
  user-select: none;
326
308
  z-index: 105; /* Above waveform, below header */
@@ -343,19 +325,19 @@ React keys must be passed directly to JSX without using spread:
343
325
  background: rgba(255, 255, 255, 0.4);
344
326
  ${e=>e.$edge==="left"?"border-left: 2px solid rgba(255, 255, 255, 0.8);":"border-right: 2px solid rgba(255, 255, 255, 0.8);"}
345
327
  }
346
- `,nr=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:a,touchOptimized:s=!1})=>{const[o,l]=c.useState(!1);if(!a)return null;const{attributes:i,listeners:u,setActivatorNodeRef:d,isDragging:b}=a;return E.jsx(co,{ref:d,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:b,$isHovered:o,$touchOptimized:s,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),...u,...i})},uo=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
328
+ `,tn=({clipId:e,trackIndex:t,clipIndex:n,edge:a,dragHandleProps:r,touchOptimized:s=!1})=>{const[o,l]=i.useState(!1);if(!r)return null;const{attributes:c,listeners:u,setActivatorNodeRef:d,isDragging:v}=r;return b.jsx(tr,{ref:d,"data-clip-id":e,"data-boundary-edge":a,$edge:a,$isDragging:v,$isHovered:o,$touchOptimized:s,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),...u,...c})},nr=S.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
347
329
  position: absolute;
348
330
  top: 0;
349
331
  bottom: 0;
350
332
  pointer-events: none;
351
333
  z-index: 50;
352
- `,fo=k.svg`
334
+ `,ar=S.svg`
353
335
  width: 100%;
354
336
  height: 100%;
355
337
  display: block;
356
338
  /* Flip horizontally for fadeOut - makes it mirror of fadeIn */
357
339
  transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
358
- `;function mo(e,t,n="logarithmic"){const r=[],a=Math.max(20,Math.min(e,100));for(let s=0;s<=a;s++){const o=s/a*e,l=s/a;let i;switch(n){case"linear":i=l;break;case"exponential":i=l*l;break;case"sCurve":i=(1-Math.cos(l*Math.PI))/2;break;case"logarithmic":default:i=Math.log10(1+l*9)/Math.log10(10);break}const u=(1-i)*t;r.push(`${o},${u}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var rr=({left:e,width:t,type:n,curveType:r="logarithmic",color:a})=>{const s=k.useTheme();if(t<1)return null;const o=a||s?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return E.jsx(uo,{$left:e,$width:t,$type:n,children:E.jsx(fo,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:E.jsx("path",{d:mo(t,100,r),fill:o})})})},ho=k.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
340
+ `;function rr(e,t,n="logarithmic"){const a=[],r=Math.max(20,Math.min(e,100));for(let s=0;s<=r;s++){const o=s/r*e,l=s/r;let c;switch(n){case"linear":c=l;break;case"exponential":c=l*l;break;case"sCurve":c=(1-Math.cos(l*Math.PI))/2;break;case"logarithmic":default:c=Math.log10(1+l*9)/Math.log10(10);break}const u=(1-c)*t;a.push(`${o},${u}`)}return`M 0,${t} L ${a.join(" L ")} L ${e},0 L 0,0 Z`}var nn=({left:e,width:t,type:n,curveType:a="logarithmic",color:r})=>{const s=S.useTheme();if(t<1)return null;const o=r||s?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return b.jsx(nr,{$left:e,$width:t,$type:n,children:b.jsx(ar,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:b.jsx("path",{d:rr(t,100,a),fill:o})})})},or=S.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
359
341
  position: ${e=>e.$isOverlay?"relative":"absolute"};
360
342
  top: 0;
361
343
  height: ${e=>e.$isOverlay?"auto":"100%"};
@@ -369,20 +351,20 @@ React keys must be passed directly to JSX without using spread:
369
351
  &:hover {
370
352
  background: rgba(255, 255, 255, 0.08);
371
353
  }
372
- `,po=k.div`
354
+ `,sr=S.div`
373
355
  flex: 1;
374
356
  position: relative;
375
357
  overflow: ${e=>e.$isOverlay?"visible":"hidden"};
376
- `,ar=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:a,trackName:s,startSample:o,durationSamples:l,samplesPerPixel:i,showHeader:u=!1,disableHeaderDrag:d=!1,isOverlay:b=!1,isSelected:p=!1,onMouseDown:f,trackId:C,fadeIn:y,fadeOut:g,sampleRate:m=44100,showFades:w=!1,touchOptimized:x=!1})=>{const v=Math.floor(o/i),I=Math.floor((o+l)/i)-v,$=u&&!d&&!b,M=`clip-${r}-${a}`,{attributes:T,listeners:_,setNodeRef:D,setActivatorNodeRef:V,transform:W,isDragging:O}=fn({id:M,data:{clipId:n,trackIndex:r,clipIndex:a},disabled:!$}),N=`clip-boundary-left-${r}-${a}`,{attributes:Y,listeners:ee,setActivatorNodeRef:re,isDragging:X}=fn({id:N,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"left"},disabled:!$}),oe=`clip-boundary-right-${r}-${a}`,{attributes:A,listeners:j,setActivatorNodeRef:H,isDragging:U}=fn({id:oe,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"right"},disabled:!$}),ge=W?{transform:Cn.Translate.toString(W),zIndex:O?100:void 0}:void 0;return E.jsxs(ho,{ref:D,style:ge,className:t,$left:v,$width:I,$isOverlay:b,"data-clip-container":"true","data-track-id":C,onMouseDown:f,children:[u&&E.jsx(so,{clipId:n,trackIndex:r,clipIndex:a,trackName:s,isSelected:p,disableDrag:d,dragHandleProps:$?{attributes:T,listeners:_,setActivatorNodeRef:V}:void 0}),E.jsxs(po,{$isOverlay:b,children:[e,w&&y&&y.duration>0&&E.jsx(rr,{left:0,width:Math.floor(y.duration*m/i),type:"fadeIn",curveType:y.type}),w&&g&&g.duration>0&&E.jsx(rr,{left:I-Math.floor(g.duration*m/i),width:Math.floor(g.duration*m/i),type:"fadeOut",curveType:g.type})]}),u&&!d&&!b&&E.jsxs(E.Fragment,{children:[E.jsx(nr,{clipId:n,trackIndex:r,clipIndex:a,edge:"left",touchOptimized:x,dragHandleProps:{attributes:Y,listeners:ee,setActivatorNodeRef:re,isDragging:X}}),E.jsx(nr,{clipId:n,trackIndex:r,clipIndex:a,edge:"right",touchOptimized:x,dragHandleProps:{attributes:A,listeners:j,setActivatorNodeRef:H,isDragging:U}})]})]})},go=k.div`
358
+ `,Zt=({children:e,className:t,clipId:n,trackIndex:a,clipIndex:r,trackName:s,startSample:o,durationSamples:l,samplesPerPixel:c,showHeader:u=!1,disableHeaderDrag:d=!1,isOverlay:v=!1,isSelected:p=!1,onMouseDown:f,trackId:C,fadeIn:y,fadeOut:m,sampleRate:g=44100,showFades:I=!1,touchOptimized:x=!1})=>{const h=Math.floor(o/c),k=Math.floor((o+l)/c)-h,A=u&&!d&&!v,M=`clip-${a}-${r}`,{attributes:$,listeners:E,setNodeRef:R,setActivatorNodeRef:T,transform:D,isDragging:z}=Ee.useDraggable({id:M,data:{clipId:n,trackIndex:a,clipIndex:r},disabled:!A}),V=`clip-boundary-left-${a}-${r}`,{attributes:_,listeners:L,setActivatorNodeRef:X,isDragging:F}=Ee.useDraggable({id:V,data:{clipId:n,trackIndex:a,clipIndex:r,boundary:"left"},disabled:!A}),K=`clip-boundary-right-${a}-${r}`,{attributes:ae,listeners:te,setActivatorNodeRef:q,isDragging:ne}=Ee.useDraggable({id:K,data:{clipId:n,trackIndex:a,clipIndex:r,boundary:"right"},disabled:!A}),be=D?{transform:Ft.Translate.toString(D),zIndex:z?100:void 0}:void 0;return b.jsxs(or,{ref:R,style:be,className:t,$left:h,$width:k,$isOverlay:v,"data-clip-container":"true","data-track-id":C,onMouseDown:f,children:[u&&b.jsx(qa,{clipId:n,trackIndex:a,clipIndex:r,trackName:s,isSelected:p,disableDrag:d,dragHandleProps:A?{attributes:$,listeners:E,setActivatorNodeRef:T}:void 0}),b.jsxs(sr,{$isOverlay:v,children:[e,I&&y&&y.duration>0&&b.jsx(nn,{left:0,width:Math.floor(y.duration*g/c),type:"fadeIn",curveType:y.type}),I&&m&&m.duration>0&&b.jsx(nn,{left:k-Math.floor(m.duration*g/c),width:Math.floor(m.duration*g/c),type:"fadeOut",curveType:m.type})]}),u&&!d&&!v&&b.jsxs(b.Fragment,{children:[b.jsx(tn,{clipId:n,trackIndex:a,clipIndex:r,edge:"left",touchOptimized:x,dragHandleProps:{attributes:_,listeners:L,setActivatorNodeRef:X,isDragging:F}}),b.jsx(tn,{clipId:n,trackIndex:a,clipIndex:r,edge:"right",touchOptimized:x,dragHandleProps:{attributes:ae,listeners:te,setActivatorNodeRef:q,isDragging:ne}})]})]})},ir=S.div`
377
359
  display: inline-flex;
378
360
  align-items: center;
379
361
  gap: 0.5rem;
380
- `,bo=k(Nr)`
362
+ `,lr=S(kn)`
381
363
  margin: 0;
382
364
  white-space: nowrap;
383
- `,vo=k(Lr)`
365
+ `,cr=S(In)`
384
366
  width: 120px;
385
- `,Co=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(parseFloat(s.target.value)/100)};return E.jsxs(go,{className:r,children:[E.jsx(bo,{htmlFor:"master-gain",children:"Master Volume"}),E.jsx(vo,{min:"0",max:"100",value:e*100,onChange:a,disabled:n,id:"master-gain"})]})};k.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
367
+ `,ur=({volume:e,onChange:t,disabled:n=!1,className:a})=>{const r=s=>{t(parseFloat(s.target.value)/100)};return b.jsxs(ir,{className:a,children:[b.jsx(lr,{htmlFor:"master-gain",children:"Master Volume"}),b.jsx(cr,{min:"0",max:"100",value:e*100,onChange:r,disabled:n,id:"master-gain"})]})};S.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
386
368
  position: absolute;
387
369
  top: 0;
388
370
  left: 0;
@@ -392,7 +374,7 @@ React keys must be passed directly to JSX without using spread:
392
374
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
393
375
  pointer-events: none;
394
376
  will-change: transform;
395
- `;k.div`
377
+ `;S.div`
396
378
  position: absolute;
397
379
  top: 0;
398
380
  left: 0;
@@ -400,7 +382,7 @@ React keys must be passed directly to JSX without using spread:
400
382
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
401
383
  pointer-events: none;
402
384
  will-change: transform;
403
- `;k.div`
385
+ `;S.div`
404
386
  position: absolute;
405
387
  top: -10px;
406
388
  left: -6px;
@@ -409,30 +391,30 @@ React keys must be passed directly to JSX without using spread:
409
391
  border-left: 7px solid transparent;
410
392
  border-right: 7px solid transparent;
411
393
  border-top: 10px solid ${e=>e.$color};
412
- `;k.div`
394
+ `;S.div`
413
395
  position: absolute;
414
396
  top: 0;
415
397
  left: 0;
416
398
  width: 2px;
417
399
  height: 100%;
418
400
  background: ${e=>e.$color};
419
- `;var wo=k.div`
401
+ `;var dr=S.div`
420
402
  overflow-y: hidden;
421
403
  overflow-x: auto;
422
404
  position: relative;
423
- `,xo=k.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
405
+ `,fr=S.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
424
406
  position: relative;
425
407
  background: ${e=>e.$backgroundColor||"transparent"};
426
- `,yo=k.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
408
+ `,mr=S.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
427
409
  background: ${e=>e.$backgroundColor||"white"};
428
410
  width: 100%;
429
411
  position: relative;
430
412
  overflow: hidden; /* Constrain loop region to timescale area */
431
- `,Io=k.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
413
+ `,hr=S.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
432
414
  position: relative;
433
415
  background: ${e=>e.$backgroundColor||"transparent"};
434
416
  width: 100%;
435
- `,So=k.div`
417
+ `,pr=S.div`
436
418
  position: absolute;
437
419
  top: 0;
438
420
  left: 0;
@@ -441,7 +423,7 @@ React keys must be passed directly to JSX without using spread:
441
423
  cursor: crosshair;
442
424
  /* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
443
425
  z-index: ${e=>e.$isSelecting?110:1};
444
- `,Kr=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:a,tracksWidth:s,scrollContainerWidth:o,controlsWidth:l,onTracksClick:i,onTracksMouseDown:u,onTracksMouseMove:d,onTracksMouseUp:b,scrollContainerRef:p,isSelecting:f})=>E.jsx(wo,{"data-scroll-container":"true",ref:p,children:E.jsxs(xo,{$backgroundColor:t,$width:o,children:[r&&E.jsx(yo,{$width:a,$backgroundColor:n,children:r}),E.jsxs(Io,{$width:s,$backgroundColor:t,children:[e,(i||u)&&E.jsx(So,{$controlsWidth:l,$isSelecting:f,onClick:i,onMouseDown:u,onMouseMove:d,onMouseUp:b})]})]})});k.withTheme(Kr);var Ao=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
426
+ `,Ht=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:a,timescaleWidth:r,tracksWidth:s,scrollContainerWidth:o,controlsWidth:l,onTracksClick:c,onTracksMouseDown:u,onTracksMouseMove:d,onTracksMouseUp:v,scrollContainerRef:p,isSelecting:f,"data-playlist-state":C})=>b.jsx(dr,{"data-scroll-container":"true","data-playlist-state":C,ref:p,children:b.jsxs(fr,{$backgroundColor:t,$width:o,children:[a&&b.jsx(mr,{$width:r,$backgroundColor:n,children:a}),b.jsxs(hr,{$width:s,$backgroundColor:t,children:[e,(c||u)&&b.jsx(pr,{$controlsWidth:l,$isSelecting:f,onClick:c,onMouseDown:u,onMouseMove:d,onMouseUp:v})]})]})});S.withTheme(Ht);var gr=S.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
445
427
  position: absolute;
446
428
  top: 0;
447
429
  background: ${e=>e.$color};
@@ -449,14 +431,14 @@ React keys must be passed directly to JSX without using spread:
449
431
  z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
450
432
  pointer-events: none;
451
433
  opacity: 0.3;
452
- `,ko=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:E.jsx(Ao,{$left:e,$width:r,$color:n,"data-selection":!0})};k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
434
+ `,En=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const a=Math.max(0,t-e);return a<=0?null:b.jsx(gr,{$left:e,$width:a,$color:n,"data-selection":!0})};S.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
453
435
  position: absolute;
454
436
  top: 0;
455
437
  background: ${e=>e.$color};
456
438
  height: 100%;
457
439
  z-index: 55; /* Between clips (z-index: 50) and selection (z-index: 60) */
458
440
  pointer-events: none;
459
- `;k.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
441
+ `;S.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
460
442
  position: absolute;
461
443
  top: 0;
462
444
  width: 2px;
@@ -476,7 +458,7 @@ React keys must be passed directly to JSX without using spread:
476
458
  border-top: 8px solid ${e=>e.$color};
477
459
  ${e=>e.$isStart?"border-right: 8px solid transparent;":"border-left: 8px solid transparent;"}
478
460
  }
479
- `;var or=k.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
461
+ `;var an=S.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
480
462
  position: absolute;
481
463
  top: 0;
482
464
  width: 12px;
@@ -513,7 +495,7 @@ React keys must be passed directly to JSX without using spread:
513
495
  &:hover::before {
514
496
  opacity: 1;
515
497
  }
516
- `,$o=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
498
+ `,br=S.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
517
499
  position: absolute;
518
500
  top: 0;
519
501
  height: 100%;
@@ -524,41 +506,41 @@ React keys must be passed directly to JSX without using spread:
524
506
  &:active {
525
507
  cursor: grabbing;
526
508
  }
527
- `,Ro=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopStartChange:a,onLoopEndChange:s,onLoopRegionMove:o,minPosition:l=0,maxPosition:i=1/0})=>{const[u,d]=c.useState(null),b=c.useRef(0),p=c.useRef(0),f=c.useRef(0),C=Math.max(0,t-e),y=c.useCallback((m,w)=>{m.preventDefault(),m.stopPropagation(),d(w),b.current=m.clientX,p.current=w==="start"?e:t;const x=S=>{const I=S.clientX-b.current,$=p.current+I;if(w==="start"){const M=Math.max(l,Math.min(t-10,$));a?.(M)}else{const M=Math.max(e+10,Math.min(i,$));s?.(M)}},v=()=>{d(null),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",v)},[e,t,l,i,a,s]),g=c.useCallback(m=>{m.preventDefault(),m.stopPropagation(),d("region"),b.current=m.clientX,p.current=e,f.current=t;const w=t-e,x=S=>{const I=S.clientX-b.current;let $=p.current+I,M=f.current+I;$<l&&($=l,M=l+w),M>i&&(M=i,$=i-w),o?.($,M)},v=()=>{d(null),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",v)},[e,t,l,i,o]);return C<=0?null:E.jsxs(E.Fragment,{children:[E.jsx($o,{$left:e,$width:C,$color:r,$isDragging:u==="region",onMouseDown:g,"data-loop-region-timescale":!0}),E.jsx(or,{$left:e,$color:n,$isStart:!0,$isDragging:u==="start",onMouseDown:m=>y(m,"start"),"data-loop-marker-handle":"start"}),E.jsx(or,{$left:t,$color:n,$isStart:!1,$isDragging:u==="end",onMouseDown:m=>y(m,"end"),"data-loop-marker-handle":"end"})]})},Eo=k.div.attrs(e=>({style:{left:`${e.$leftOffset||0}px`}}))`
509
+ `,vr=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:a="rgba(59, 130, 246, 0.3)",onLoopStartChange:r,onLoopEndChange:s,onLoopRegionMove:o,minPosition:l=0,maxPosition:c=1/0})=>{const[u,d]=i.useState(null),v=i.useRef(0),p=i.useRef(0),f=i.useRef(0),C=Math.max(0,t-e),y=i.useCallback((g,I)=>{g.preventDefault(),g.stopPropagation(),d(I),v.current=g.clientX,p.current=I==="start"?e:t;const x=w=>{const k=w.clientX-v.current,A=p.current+k;if(I==="start"){const M=Math.max(l,Math.min(t-10,A));r?.(M)}else{const M=Math.max(e+10,Math.min(c,A));s?.(M)}},h=()=>{d(null),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",h)},[e,t,l,c,r,s]),m=i.useCallback(g=>{g.preventDefault(),g.stopPropagation(),d("region"),v.current=g.clientX,p.current=e,f.current=t;const I=t-e,x=w=>{const k=w.clientX-v.current;let A=p.current+k,M=f.current+k;A<l&&(A=l,M=l+I),M>c&&(M=c,A=c-I),o?.(A,M)},h=()=>{d(null),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",h)},[e,t,l,c,o]);return C<=0?null:b.jsxs(b.Fragment,{children:[b.jsx(br,{$left:e,$width:C,$color:a,$isDragging:u==="region",onMouseDown:m,"data-loop-region-timescale":!0}),b.jsx(an,{$left:e,$color:n,$isStart:!0,$isDragging:u==="start",onMouseDown:g=>y(g,"start"),"data-loop-marker-handle":"start"}),b.jsx(an,{$left:t,$color:n,$isStart:!1,$isDragging:u==="end",onMouseDown:g=>y(g,"end"),"data-loop-marker-handle":"end"})]})},Cr=S.div.attrs(e=>({style:{left:`${e.$leftOffset||0}px`}}))`
528
510
  position: absolute;
529
511
  top: 0;
530
512
  right: 0;
531
513
  height: 100%; /* Stay within timescale bounds, don't extend into tracks */
532
514
  cursor: crosshair;
533
515
  z-index: 40; /* Below markers and shading */
534
- `,Do=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopRegionChange:a,minPosition:s=0,maxPosition:o=1/0,controlsOffset:l=0})=>{const[i,u]=c.useState(!1),d=c.useRef(0),b=c.useRef(null),p=t>e,f=c.useCallback(C=>{const y=C.target;if(y.closest("[data-loop-marker-handle]")||y.closest("[data-loop-region-timescale]"))return;C.preventDefault(),u(!0);const g=b.current?.getBoundingClientRect();if(!g)return;const m=C.clientX-g.left,w=Math.max(s,Math.min(o,m));d.current=w,a?.(w,w);const x=S=>{const I=S.clientX-g.left,$=Math.max(s,Math.min(o,I)),M=Math.min(d.current,$),T=Math.max(d.current,$);a?.(M,T)},v=()=>{u(!1),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",v)},[s,o,a]);return E.jsx(Eo,{ref:b,$leftOffset:l,onMouseDown:f,"data-timescale-loop-creator":!0,children:p&&E.jsx(Ro,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:s,maxPosition:o,onLoopStartChange:C=>a?.(C,t),onLoopEndChange:C=>a?.(e,C),onLoopRegionMove:(C,y)=>a?.(C,y)})})};function Dt(e,t){const n=Math.floor(e/3600)%24,r=Math.floor(e/60)%60,a=(e%60).toFixed(t);return String(n).padStart(2,"0")+":"+String(r).padStart(2,"0")+":"+a.padStart(t+3,"0")}function It(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return Dt(e,0);case"hh:mm:ss.u":return Dt(e,1);case"hh:mm:ss.uu":return Dt(e,2);case"hh:mm:ss.uuu":return Dt(e,3);default:return Dt(e,3)}}function Ur(e,t){if(!e)return 0;switch(t){case"seconds":case"thousandths":return parseFloat(e)||0;case"hh:mm:ss":case"hh:mm:ss.u":case"hh:mm:ss.uu":case"hh:mm:ss.uuu":{const n=e.split(":");if(n.length!==3)return 0;const r=parseInt(n[0],10)||0,a=parseInt(n[1],10)||0,s=parseFloat(n[2])||0;return r*3600+a*60+s}default:return 0}}var sr=({id:e,label:t,value:n,format:r,className:a,onChange:s,readOnly:o=!1})=>{const[l,i]=c.useState("");c.useEffect(()=>{const p=It(n,r);i(p)},[n,r,e]);const u=p=>{const f=p.target.value;i(f)},d=()=>{if(s){const p=Ur(l,r);s(p)}i(It(n,r))},b=p=>{p.key==="Enter"&&p.currentTarget.blur()};return E.jsxs(E.Fragment,{children:[E.jsx(Ja,{as:"label",htmlFor:e,children:t}),E.jsx(Or,{type:"text",className:a,id:e,value:l,onChange:u,onBlur:d,onKeyDown:b,readOnly:o})]})},To=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[a,s]=c.useState("hh:mm:ss.uuu");c.useEffect(()=>{const i=document.querySelector(".time-format"),u=()=>{i&&s(i.value)};return i&&(s(i.value),i.addEventListener("change",u)),()=>{i?.removeEventListener("change",u)}},[]);const o=i=>{n&&n(i,t)},l=i=>{n&&n(e,i)};return E.jsxs(E.Fragment,{children:[E.jsx(sr,{id:"audio_start",label:"Start of audio selection",value:e,format:a,className:"audio-start form-control mr-sm-2",onChange:o}),E.jsx(sr,{id:"audio_end",label:"End of audio selection",value:t,format:a,className:"audio-end form-control mr-sm-2",onChange:l})]})};function Xt(){return window.devicePixelRatio}var Jr=c.createContext(Xt()),_o=({children:e})=>{const[t,n]=c.useState(Xt());return matchMedia(`(resolution: ${Xt()}dppx)`).addEventListener("change",()=>{n(Xt())},{once:!0}),E.jsx(Jr.Provider,{value:Math.ceil(t),children:e})},qr=()=>c.useContext(Jr),_n=c.createContext({sampleRate:48e3,samplesPerPixel:1e3,zoomLevels:[1e3,1500,2e3,2500],waveHeight:80,timeScaleHeight:15,controls:{show:!1,width:150},duration:3e4,barWidth:1,barGap:0}),en=()=>c.useContext(_n),Mn=()=>c.useContext(k.ThemeContext),Qr=c.createContext(E.jsx(c.Fragment,{})),Mo=()=>c.useContext(Qr),Bo=0,Fo=!1,Wo=0,Zo=0,Po={progress:Bo,isPlaying:Fo,selectionStart:Wo,selectionEnd:Zo};c.createContext(Po);c.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var Vo=({isSelected:e,transparentBackground:t,...n})=>{const r=Mn(),{waveHeight:a,barWidth:s,barGap:o}=en(),l=qr(),i=e&&r?r.selectedWaveOutlineColor:r?.waveOutlineColor,u=e&&r?r.selectedWaveFillColor:r?.waveFillColor,d=r?.waveformDrawMode||"inverted";return E.jsx(ao,{...n,...r,waveOutlineColor:i,waveFillColor:u,waveHeight:a,devicePixelRatio:l,barWidth:s,barGap:o,transparentBackground:t,drawMode:d})};function jo(e,t,n){return Math.ceil(e*n/t)}function zo(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var Oo=k.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,marginLeft:`${e.$controlWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
516
+ `,xr=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:a="rgba(59, 130, 246, 0.3)",onLoopRegionChange:r,minPosition:s=0,maxPosition:o=1/0,controlsOffset:l=0})=>{const[c,u]=i.useState(!1),d=i.useRef(0),v=i.useRef(null),p=t>e,f=i.useCallback(C=>{const y=C.target;if(y.closest("[data-loop-marker-handle]")||y.closest("[data-loop-region-timescale]"))return;C.preventDefault(),u(!0);const m=v.current?.getBoundingClientRect();if(!m)return;const g=C.clientX-m.left,I=Math.max(s,Math.min(o,g));d.current=I,r?.(I,I);const x=w=>{const k=w.clientX-m.left,A=Math.max(s,Math.min(o,k)),M=Math.min(d.current,A),$=Math.max(d.current,A);r?.(M,$)},h=()=>{u(!1),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",h)},[s,o,r]);return b.jsx(Cr,{ref:v,$leftOffset:l,onMouseDown:f,"data-timescale-loop-creator":!0,children:p&&b.jsx(vr,{startPosition:e,endPosition:t,markerColor:n,regionColor:a,minPosition:s,maxPosition:o,onLoopStartChange:C=>r?.(C,t),onLoopEndChange:C=>r?.(e,C),onLoopRegionMove:(C,y)=>r?.(C,y)})})};function st(e,t){const n=Math.floor(e/3600)%24,a=Math.floor(e/60)%60,r=(e%60).toFixed(t);return String(n).padStart(2,"0")+":"+String(a).padStart(2,"0")+":"+r.padStart(t+3,"0")}function nt(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return st(e,0);case"hh:mm:ss.u":return st(e,1);case"hh:mm:ss.uu":return st(e,2);case"hh:mm:ss.uuu":return st(e,3);default:return st(e,3)}}function Dn(e,t){if(!e)return 0;switch(t){case"seconds":case"thousandths":return parseFloat(e)||0;case"hh:mm:ss":case"hh:mm:ss.u":case"hh:mm:ss.uu":case"hh:mm:ss.uuu":{const n=e.split(":");if(n.length!==3)return 0;const a=parseInt(n[0],10)||0,r=parseInt(n[1],10)||0,s=parseFloat(n[2])||0;return a*3600+r*60+s}default:return 0}}var rn=({id:e,label:t,value:n,format:a,className:r,onChange:s,readOnly:o=!1})=>{const[l,c]=i.useState("");i.useEffect(()=>{const p=nt(n,a);c(p)},[n,a,e]);const u=p=>{const f=p.target.value;c(f)},d=()=>{if(s){const p=Dn(l,a);s(p)}c(nt(n,a))},v=p=>{p.key==="Enter"&&p.currentTarget.blur()};return b.jsxs(b.Fragment,{children:[b.jsx(Ga,{as:"label",htmlFor:e,children:t}),b.jsx(yn,{type:"text",className:r,id:e,value:l,onChange:u,onBlur:d,onKeyDown:v,readOnly:o})]})},wr=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:a})=>{const[r,s]=i.useState("hh:mm:ss.uuu");i.useEffect(()=>{const c=document.querySelector(".time-format"),u=()=>{c&&s(c.value)};return c&&(s(c.value),c.addEventListener("change",u)),()=>{c?.removeEventListener("change",u)}},[]);const o=c=>{n&&n(c,t)},l=c=>{n&&n(e,c)};return b.jsxs(b.Fragment,{children:[b.jsx(rn,{id:"audio_start",label:"Start of audio selection",value:e,format:r,className:"audio-start form-control mr-sm-2",onChange:o}),b.jsx(rn,{id:"audio_end",label:"End of audio selection",value:t,format:r,className:"audio-end form-control mr-sm-2",onChange:l})]})};function vt(){return window.devicePixelRatio}var Bn=i.createContext(vt()),Tn=({children:e})=>{const[t,n]=i.useState(vt());return matchMedia(`(resolution: ${vt()}dppx)`).addEventListener("change",()=>{n(vt())},{once:!0}),b.jsx(Bn.Provider,{value:Math.ceil(t),children:e})},Wn=()=>i.useContext(Bn),It=i.createContext({sampleRate:48e3,samplesPerPixel:1e3,zoomLevels:[1e3,1500,2e3,2500],waveHeight:80,timeScaleHeight:15,controls:{show:!1,width:150},duration:3e4,barWidth:1,barGap:0}),ct=()=>i.useContext(It),ut=()=>i.useContext(S.ThemeContext),Xt=i.createContext(b.jsx(i.Fragment,{})),yr=()=>i.useContext(Xt),kr=0,Ir=!1,Sr=0,Ar=0,$r={progress:kr,isPlaying:Ir,selectionStart:Sr,selectionEnd:Ar};i.createContext($r);i.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var _n=({isSelected:e,transparentBackground:t,...n})=>{const a=ut(),{waveHeight:r,barWidth:s,barGap:o}=ct(),l=Wn(),c=e&&a?a.selectedWaveOutlineColor:a?.waveOutlineColor,u=e&&a?a.selectedWaveFillColor:a?.waveFillColor,d=a?.waveformDrawMode||"inverted";return b.jsx(Ua,{...n,...a,waveOutlineColor:c,waveFillColor:u,waveHeight:r,devicePixelRatio:l,barWidth:s,barGap:o,transparentBackground:t,drawMode:d})};function Mr(e,t,n){return Math.ceil(e*n/t)}function Rr(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var Er=S.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,marginLeft:`${e.$controlWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
535
517
  position: relative;
536
518
  overflow: visible; /* Allow time labels to render above the container */
537
519
  border-bottom: 1px solid ${e=>e.theme.timeColor};
538
520
  box-sizing: border-box;
539
- `,No=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
521
+ `,Dr=S.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
540
522
  position: absolute;
541
523
  left: 0;
542
524
  right: 0;
543
525
  bottom: 0;
544
- `,Lo=k.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
526
+ `,Br=S.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
545
527
  position: absolute;
546
528
  font-size: 0.75rem; /* Smaller font to prevent overflow */
547
529
  white-space: nowrap; /* Prevent text wrapping */
548
530
  color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
549
- `,Xo=e=>{const{theme:{timeColor:t},duration:n,marker:r,bigStep:a,secondStep:s,renderTimestamp:o}=e,l=new Map,i=[],u=c.useRef(null),{sampleRate:d,samplesPerPixel:b,timeScaleHeight:p,controls:{show:f,width:C}}=c.useContext(_n),y=qr();c.useEffect(()=>{if(u.current!==null){const x=u.current,v=x.getContext("2d");if(v){v.resetTransform(),v.clearRect(0,0,x.width,x.height),v.imageSmoothingEnabled=!1,v.fillStyle=t,v.scale(y,y);for(const[S,I]of l.entries()){const $=p-I;v.fillRect(S,$,1,I)}}}},[n,y,t,p,a,s,r,l]);const g=jo(n/1e3,b,d),m=d/b;let w=0;for(let x=0;x<g;x+=m*s/1e3){const v=Math.floor(x);if(w%r===0){const S=w,I=zo(S),$=o?E.jsx(c.Fragment,{children:o(S,v)},`timestamp-${w}`):E.jsx(Lo,{$left:v,children:I},I);i.push($),l.set(v,p)}else w%a===0?l.set(v,Math.floor(p/2)):w%s===0&&l.set(v,Math.floor(p/5));w+=s}return E.jsxs(Oo,{$cssWidth:g,$controlWidth:f?C:0,$timeScaleHeight:p,children:[i,E.jsx(No,{$cssWidth:g,$timeScaleHeight:p,width:g*y,height:p*y,ref:u})]})},Ho=k.withTheme(Xo),Go=k.div`
531
+ `,Tr=e=>{const{theme:{timeColor:t},duration:n,marker:a,bigStep:r,secondStep:s,renderTimestamp:o}=e,l=new Map,c=[],u=i.useRef(null),{sampleRate:d,samplesPerPixel:v,timeScaleHeight:p,controls:{show:f,width:C}}=i.useContext(It),y=Wn();i.useEffect(()=>{if(u.current!==null){const x=u.current,h=x.getContext("2d");if(h){h.resetTransform(),h.clearRect(0,0,x.width,x.height),h.imageSmoothingEnabled=!1,h.fillStyle=t,h.scale(y,y);for(const[w,k]of l.entries()){const A=p-k;h.fillRect(w,A,1,k)}}}},[n,y,t,p,r,s,a,l]);const m=Mr(n/1e3,v,d),g=d/v;let I=0;for(let x=0;x<m;x+=g*s/1e3){const h=Math.floor(x);if(I%a===0){const w=I,k=Rr(w),A=o?b.jsx(i.Fragment,{children:o(w,h)},`timestamp-${I}`):b.jsx(Br,{$left:h,children:k},k);c.push(A),l.set(h,p)}else I%r===0?l.set(h,Math.floor(p/2)):I%s===0&&l.set(h,Math.floor(p/5));I+=s}return b.jsxs(Er,{$cssWidth:m,$controlWidth:f?C:0,$timeScaleHeight:p,children:[c,b.jsx(Dr,{$cssWidth:m,$timeScaleHeight:p,width:m*y,height:p*y,ref:u})]})},Fn=S.withTheme(Tr),Wr=S.div`
550
532
  display: inline-flex;
551
533
  align-items: center;
552
534
  gap: 0.5rem;
553
- `,Yo=[{value:"seconds",label:"seconds"},{value:"thousandths",label:"thousandths"},{value:"hh:mm:ss",label:"hh:mm:ss"},{value:"hh:mm:ss.u",label:"hh:mm:ss + tenths"},{value:"hh:mm:ss.uu",label:"hh:mm:ss + hundredths"},{value:"hh:mm:ss.uuu",label:"hh:mm:ss + milliseconds"}],Ko=({value:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.value)};return E.jsx(Go,{className:r,children:E.jsx(Tn,{className:"time-format",value:e,onChange:a,disabled:n,"aria-label":"Time format selection",children:Yo.map(s=>E.jsx("option",{value:s.value,children:s.label},s.value))})})},Uo=k.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?Hr:0)}px`}}))`
535
+ `,_r=[{value:"seconds",label:"seconds"},{value:"thousandths",label:"thousandths"},{value:"hh:mm:ss",label:"hh:mm:ss"},{value:"hh:mm:ss.u",label:"hh:mm:ss + tenths"},{value:"hh:mm:ss.uu",label:"hh:mm:ss + hundredths"},{value:"hh:mm:ss.uuu",label:"hh:mm:ss + milliseconds"}],Fr=({value:e,onChange:t,disabled:n=!1,className:a})=>{const r=s=>{t(s.target.value)};return b.jsx(Wr,{className:a,children:b.jsx(jt,{className:"time-format",value:e,onChange:r,disabled:n,"aria-label":"Time format selection",children:_r.map(s=>b.jsx("option",{value:s.value,children:s.label},s.value))})})},Zr=S.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?$n:0)}px`}}))`
554
536
  position: relative;
555
537
  display: flex;
556
538
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
557
- `,Jo=k.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
539
+ `,Vr=S.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
558
540
  position: relative;
559
541
  background: ${e=>e.$backgroundColor||"transparent"};
560
542
  flex: 1;
561
- `,qo=k.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
543
+ `,Pr=S.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
562
544
  position: sticky;
563
545
  z-index: 101; /* Above waveform content, below Docusaurus navbar (z-index: 200) */
564
546
  left: 0;
@@ -572,7 +554,7 @@ React keys must be passed directly to JSX without using spread:
572
554
  ${e=>e.$isSelected&&`
573
555
  background: ${e.theme.selectedTrackControlsBackground};
574
556
  `}
575
- `,Qo=({numChannels:e,children:t,className:n,backgroundColor:r,offset:a=0,width:s,hasClipHeaders:o=!1,onClick:l,trackId:i,isSelected:u=!1})=>{const{waveHeight:d,controls:{show:b,width:p}}=en(),f=Mo();return E.jsxs(Uo,{$numChannels:e,className:n,$waveHeight:d,$controlWidth:b?p:0,$width:s,$hasClipHeaders:o,$isSelected:u,children:[E.jsx(qo,{$controlWidth:b?p:0,$isSelected:u,children:f}),E.jsx(Jo,{$controlWidth:b?p:0,$backgroundColor:r,$offset:a,onClick:l,"data-track-id":i,children:t})]})},ir=k.button.attrs({type:"button"})`
557
+ `,Zn=({numChannels:e,children:t,className:n,backgroundColor:a,offset:r=0,width:s,hasClipHeaders:o=!1,onClick:l,trackId:c,isSelected:u=!1})=>{const{waveHeight:d,controls:{show:v,width:p}}=ct(),f=yr();return b.jsxs(Zr,{$numChannels:e,className:n,$waveHeight:d,$controlWidth:v?p:0,$width:s,$hasClipHeaders:o,$isSelected:u,children:[b.jsx(Pr,{$controlWidth:v?p:0,$isSelected:u,children:f}),b.jsx(Vr,{$controlWidth:v?p:0,$backgroundColor:a,$offset:r,onClick:l,"data-track-id":c,children:t})]})},on=S.button.attrs({type:"button"})`
576
558
  display: inline-block;
577
559
  font-family: ${e=>e.theme.fontFamily};
578
560
  font-weight: 500;
@@ -631,7 +613,7 @@ React keys must be passed directly to JSX without using spread:
631
613
  box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
632
614
  }
633
615
  `}
634
- `,es=k.div`
616
+ `,zr=S.div`
635
617
  margin-bottom: 0.3rem;
636
618
 
637
619
  button:not(:first-child) {
@@ -643,7 +625,7 @@ React keys must be passed directly to JSX without using spread:
643
625
  border-top-right-radius: 0;
644
626
  border-bottom-right-radius: 0;
645
627
  }
646
- `,ts=k.div`
628
+ `,jr=S.div`
647
629
  background: transparent;
648
630
  width: 100%;
649
631
  height: 100%;
@@ -656,7 +638,7 @@ React keys must be passed directly to JSX without using spread:
656
638
  text-align: center;
657
639
  border: 1px solid ${e=>e.theme.borderColor};
658
640
  border-radius: ${e=>e.theme.borderRadius};
659
- `,ns=k.header`
641
+ `,Hr=S.header`
660
642
  overflow: hidden;
661
643
  height: 26px;
662
644
  width: 100%;
@@ -667,7 +649,7 @@ React keys must be passed directly to JSX without using spread:
667
649
  font-size: ${e=>e.theme.fontSizeSmall};
668
650
  color: ${e=>e.theme.textColor};
669
651
  background-color: transparent;
670
- `,rs=e=>E.jsx(zr,{weight:"light",...e}),as=e=>E.jsx(jr,{weight:"light",...e}),lr=k(Lr)`
652
+ `,Xr=e=>b.jsx(wn,{weight:"light",...e}),Gr=e=>b.jsx(xn,{weight:"light",...e}),sn=S(In)`
671
653
  width: 75%;
672
654
  height: 5px;
673
655
  background: ${e=>e.theme.sliderTrackColor};
@@ -716,7 +698,7 @@ React keys must be passed directly to JSX without using spread:
716
698
  &:focus::-moz-range-thumb {
717
699
  border: 2px solid ${e=>e.theme.textColor};
718
700
  }
719
- `,cr=k.label`
701
+ `,ln=S.label`
720
702
  width: 100%;
721
703
  display: flex;
722
704
  justify-content: space-between;
@@ -724,12 +706,12 @@ React keys must be passed directly to JSX without using spread:
724
706
  padding: 0 1rem;
725
707
  margin-bottom: 0.2rem;
726
708
  font-size: 14px;
727
- `;k.div`
709
+ `;S.div`
728
710
  display: flex;
729
711
  align-items: center;
730
712
  gap: 0.25rem;
731
713
  padding: 0.5rem 0.5rem 0.25rem 0.5rem;
732
- `;k.span`
714
+ `;S.span`
733
715
  flex: 1;
734
716
  font-weight: 600;
735
717
  font-size: 0.875rem;
@@ -737,7 +719,7 @@ React keys must be passed directly to JSX without using spread:
737
719
  text-overflow: ellipsis;
738
720
  white-space: nowrap;
739
721
  margin: 0 0.25rem;
740
- `;k.button`
722
+ `;S.button`
741
723
  display: flex;
742
724
  align-items: center;
743
725
  justify-content: center;
@@ -762,8 +744,8 @@ React keys must be passed directly to JSX without using spread:
762
744
  &:active {
763
745
  transform: scale(0.9);
764
746
  }
765
- `;function os(e){let t=1/0,n=-1/0;for(let r=0;r<e.length;r++){const a=e[r];t>a&&(t=a),n<a&&(n=a)}return{min:t,max:n}}function ur(e,t){const n=Math.pow(2,t-1),r=e<0?e*n:e*(n-1);return Math.max(-n,Math.min(n-1,r))}function ea(e,t){switch(e){case 8:return new Int8Array(t);case 16:return new Int16Array(t)}}function dr(e,t,n){const r=e.length,a=Math.ceil(r/t),s=ea(n,a*2);for(let o=0;o<a;o++){const l=o*t,i=Math.min((o+1)*t,r),u=e.subarray(l,i),d=os(u),b=ur(d.min,n),p=ur(d.max,n);s[o*2]=b,s[o*2+1]=p}return s}function ss(e,t){const n=e.length,r=1/n,a=e[0].length/2,s=ea(t,a*2);for(let o=0;o<a;o++){let l=0,i=0;for(let u=0;u<n;u++)l+=r*e[u][o*2],i+=r*e[u][o*2+1];s[o*2]=l,s[o*2+1]=i}return[s]}function is(e,t=1e3,n=!0,r=0,a,s=16){if(s!==8&&s!==16)throw new Error("Invalid number of bits specified for peaks. Must be 8 or 16.");let o=[];if("getChannelData"in e){const i=e.numberOfChannels,u=a??e.length;for(let d=0;d<i;d++){const p=e.getChannelData(d).subarray(r,u);o.push(dr(p,t,s))}}else{const i=a??e.length,u=e.subarray(r,i);o.push(dr(u,t,s))}return n&&o.length>1&&(o=ss(o,s)),{length:o[0].length/2,data:o,bits:s}}function ls(e,t=1e3,n=!0,r=8,a=0,s){const o=s!==void 0?a+s:void 0;return is(e,t,n,a,o,r)}function pt(e,t){this._waveformData=e,this._channelIndex=t}pt.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};pt.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};pt.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};pt.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};pt.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};pt.prototype.max_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.max_sample(n));return t};var cs=127,us=-128,ds=32767,fs=-32768;function ms(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function hs(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,a=e.length,s=e.sample_rate,o=e.channels.map(function(D){return new Float32Array(D)}),l=r?o.length:1,i=24,u=ms(a,t),d=e.bits===8?1:2,b=i+u*2*d*l,p=new ArrayBuffer(b),f=new DataView(p),C=0,y=i,g=new Array(l),m=new Array(l),w=0;w<l;w++)g[w]=1/0,m[w]=-1/0;var x=e.bits===8?us:fs,v=e.bits===8?cs:ds;f.setInt32(0,2,!0),f.setUint32(4,e.bits===8,!0),f.setInt32(8,s,!0),f.setInt32(12,t,!0),f.setInt32(16,u,!0),f.setInt32(20,l,!0);for(var S=0;S<a;S++){var I=0;if(l===1){for(var $=0;$<o.length;++$)I+=o[$][S];I=Math.floor(v*I*n/o.length),I<g[0]&&(g[0]=I,g[0]<x&&(g[0]=x)),I>m[0]&&(m[0]=I,m[0]>v&&(m[0]=v))}else for(var M=0;M<l;++M)I=Math.floor(v*o[M][S]*n),I<g[M]&&(g[M]=I,g[M]<x&&(g[M]=x)),I>m[M]&&(m[M]=I,m[M]>v&&(m[M]=v));if(++C===t){for(var T=0;T<l;T++)e.bits===8?(f.setInt8(y++,g[T]),f.setInt8(y++,m[T])):(f.setInt16(y,g[T],!0),f.setInt16(y+2,m[T],!0),y+=4),g[T]=1/0,m[T]=-1/0;C=0}}if(C>0)for(var _=0;_<l;_++)e.bits===8?(f.setInt8(y++,g[_]),f.setInt8(y++,m[_])):(f.setInt16(y,g[_],!0),f.setInt16(y+2,m[_],!0));return p}function Yt(e){"@babel/helpers - typeof";return Yt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(e)}function ps(e){return e&&Yt(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function gs(e){var t=e&&Yt(e)==="object"&&"byteLength"in e;if(t){var n=new DataView(e),r=n.getInt32(0,!0);if(r!==1&&r!==2)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return t}function bs(e){var t=e.data,n=e.channels||1,r=24,a=e.bits===8?1:2,s=e.length*2*n;if(t.length!==s)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=r+t.length*a,l=new ArrayBuffer(o),i=new DataView(l);i.setInt32(0,2,!0),i.setUint32(4,e.bits===8,!0),i.setInt32(8,e.sample_rate,!0),i.setInt32(12,e.samples_per_pixel,!0),i.setInt32(16,e.length,!0),i.setInt32(20,n,!0);var u=r;if(e.bits===8)for(var d=0;d<t.length;d++)i.setInt8(u++,t[d],!0);else for(var b=0;b<t.length;b++)i.setInt16(u,t[b],!0),u+=2;return l}function Ct(e){return e==null}function vs(e,t){var n=atob(e);return n}function Cs(e,t,n){var r=vs(e),a=r.indexOf(`
766
- `,10)+1,s=r.substring(a)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function ws(e,t,n){var r;return function(s){return r=r||Cs(e),new Worker(r,s)}}var xs=ws("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function Oe(e){if(ps(e)&&(e=bs(e)),gs(e)){this._data=new DataView(e),this._offset=this._version()===2?24:20,this._channels=[];for(var t=0;t<this.channels;t++)this._channels[t]=new pt(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var Tt={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function ys(e){var t={scale:e.scale||Tt.scale,bits:e.bits||Tt.bits,amplitude_scale:e.amplitude_scale||Tt.amplitude_scale,split_channels:e.split_channels||Tt.split_channels,disable_worker:e.disable_worker||Tt.disable_worker};return t}function Is(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function ta(e,t,n){var r=Is(e);if(t.disable_worker){var a=hs({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:r});n(void 0,new Oe(a),e)}else{var s=new xs;s.onmessage=function(o){n(void 0,new Oe(o.data),e)},s.postMessage({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:r},r)}}function Ss(e,t,n,r){function a(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var s=e.decodeAudioData(t,function(o){ta(o,n,r)},a);s&&s.catch(a)}Oe.create=function(t){return new Oe(t)};Oe.createFromAudio=function(e,t){var n=ys(e);if(e.audio_context&&e.array_buffer)return Ss(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return ta(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function tn(e){this._inputData=e.waveformData,this._output_samples_per_pixel=e.scale,this._scale=this._inputData.scale,this._input_buffer_size=this._inputData.length;var t=this._input_buffer_size*this._inputData.scale,n=Math.ceil(t/this._output_samples_per_pixel),r=24,a=this._inputData.bits===8?1:2,s=r+n*2*this._inputData.channels*a;this._output_data=new ArrayBuffer(s),this.output_dataview=new DataView(this._output_data),this.output_dataview.setInt32(0,2,!0),this.output_dataview.setUint32(4,this._inputData.bits===8,!0),this.output_dataview.setInt32(8,this._inputData.sample_rate,!0),this.output_dataview.setInt32(12,this._output_samples_per_pixel,!0),this.output_dataview.setInt32(16,n,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new Oe(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var l=0;l<o;++l)this._input_buffer_size>0?(this._min[l]=this._inputData.channel(l).min_sample(this._input_index),this._max[l]=this._inputData.channel(l).max_sample(this._input_index)):(this._min[l]=0,this._max[l]=0);this._min_value=this._inputData.bits===8?-128:-32768,this._max_value=this._inputData.bits===8?127:32767,this._where=0,this._prev_where=0,this._stop=0,this._last_input_index=0}tn.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};tn.prototype.next=function(){for(var e=0,t=1e3,n=this._inputData.channels,r;this._input_index<this._input_buffer_size&&e<t;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var a=0;a<n;++a)r=this._outputWaveformData.channel(a),r.set_min_sample(this._output_index-1,this._min[a]),r.set_max_sample(this._output_index-1,this._max[a]);if(this._last_input_index=this._input_index,this._output_index++,this._where=this.sample_at_pixel(this._output_index),this._prev_where=this.sample_at_pixel(this._output_index-1),this._where!==this._prev_where)for(var s=0;s<n;++s)this._min[s]=this._max_value,this._max[s]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(var o=0;o<n;++o){r=this._inputData.channel(o);var l=r.min_sample(this._input_index);l<this._min[o]&&(this._min[o]=l),l=r.max_sample(this._input_index),l>this._max[o]&&(this._max[o]=l)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var i=0;i<n;++i)r=this._outputWaveformData.channel(i),r.set_min_sample(this._output_index-1,this._min[i]),r.set_max_sample(this._output_index-1,this._max[i]);return!0};tn.prototype.getOutputData=function(){return this._output_data};Oe.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Ct(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Ct(n.scale)&&(typeof n.scale!="number"||n.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!n.scale&&!n.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(n.width&&(n.scale=Math.floor(this.duration*this.sample_rate/n.width)),n.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+n.scale+" too low, minimum: "+this.scale);return n.abortSignal=t.abortSignal,n},resample:function(t){t=this._getResampleOptions(t),t.waveformData=this;for(var n=new tn(t);!n.next(););return new Oe(n.getOutputData())},concat:function(){var t=this,n=Array.prototype.slice.call(arguments);n.forEach(function(a){if(t.channels!==a.channels||t.sample_rate!==a.sample_rate||t.bits!==a.bits||t.scale!==a.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var r=this._concatBuffers.apply(this,n);return Oe.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,a=0,s=[this].concat(t).map(function(m){return m._data.buffer}),o=0;o<s.length;o++){var l=s[o],i=new DataView(l).getInt32(16,!0);r+=l.byteLength-n,a+=i}for(var u=new ArrayBuffer(r),d=new DataView(s[0]),b=new DataView(u),p=0;p<n;p++)b.setUint8(p,d.getUint8(p));b.setInt32(16,a,!0);for(var f=0,C=new Uint8Array(u,n),y=0;y<s.length;y++){var g=s[y];C.set(new Uint8Array(g,n),f),f+=g.byteLength-n}return u},slice:function(t){var n=0,r=0;if(!Ct(t.startIndex)&&!Ct(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Ct(t.startTime)&&!Ct(t.endTime)&&(n=this.at_time(t.startTime),r=this.at_time(t.endTime)),n<0)throw new RangeError("startIndex or startTime must not be negative");if(r<0)throw new RangeError("endIndex or endTime must not be negative");n>this.length&&(n=this.length),r>this.length&&(r=this.length),n>r&&(n=r);var a=r-n,s=24,o=this.bits===8?1:2,l=s+a*2*this.channels*o,i=new ArrayBuffer(l),u=new DataView(i);u.setInt32(0,2,!0),u.setUint32(4,this.bits===8,!0),u.setInt32(8,this.sample_rate,!0),u.setInt32(12,this.scale,!0),u.setInt32(16,a,!0),u.setInt32(20,this.channels,!0);for(var d=0;d<a*this.channels*2;d++){var b=this._at(n*this.channels*2+d);this.bits===8?u.setInt8(s+d,b):u.setInt16(s+d*2,b,!0)}return new Oe(i)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var e=!!this._data.getUint32(4,!0);return e?8:16},get duration(){return this.length*this.scale/this.sample_rate},get pixels_per_second(){return this.sample_rate/this.scale},get seconds_per_pixel(){return this.scale/this.sample_rate},get channels(){return this._version()===2?this._data.getInt32(20,!0):1},channel:function(t){if(t>=0&&t<this._channels.length)return this._channels[t];throw new RangeError("Invalid channel: "+t)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(t){return this.bits===8?this._data.getInt8(this._offset+t):this._data.getInt16(this._offset+t*2,!0)},_set_at:function(t,n){return this.bits===8?this._data.setInt8(this._offset+t,n):this._data.setInt16(this._offset+t*2,n,!0)},at_time:function(t){return Math.floor(t*this.sample_rate/this.scale)},time:function(t){return t*this.scale/this.sample_rate},toJSON:function(){for(var t={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},n=0;n<this.length;n++)for(var r=0;r<this.channels;r++)t.data.push(this.channel(r).min_sample(n)),t.data.push(this.channel(r).max_sample(n));return t},toArrayBuffer:function(){return this._data.buffer}};async function Bn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch waveform data: ${t.statusText}`);if(e.endsWith(".dat")){const r=await t.arrayBuffer();return Oe.create(r)}else{const r=await t.json();return Oe.create(r)}}function na(e,t=0){const n=e.channel(t),r=e.bits,a=n.min_array(),s=n.max_array(),o=a.length,l=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let i=0;i<o;i++)l[i*2]=a[i],l[i*2+1]=s[i];return{data:l,bits:r,length:o,sampleRate:e.sample_rate}}async function As(e,t=0){const n=await Bn(e);return na(n,t)}async function ks(e){const t=await Bn(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function $s(e,t,n=0,r,a){let s=e;if(r!==void 0&&a!==void 0){const p=e.scale,f=Math.floor(r/p),C=Math.ceil((r+a)/p);s=s.slice({startIndex:f,endIndex:C})}s.scale!==t&&(s=s.resample({scale:t}));const o=s.channel(n),l=s.bits,i=o.min_array(),u=o.max_array(),d=i.length,b=l===8?new Int8Array(d*2):new Int16Array(d*2);for(let p=0;p<d;p++)b[p*2]=i[p],b[p*2+1]=u[p];return{data:b,bits:l,length:d}}var fr;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(fr||(fr={}));function mr(){}const Rs=Object.freeze({x:0,y:0});var xt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(xt||(xt={}));var hr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(hr||(hr={}));var ut;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(ut||(ut={}));ut.Space,ut.Enter,ut.Esc,ut.Space,ut.Enter,ut.Tab;var pr;(function(e){e[e.RightClick=2]="RightClick"})(pr||(pr={}));var gr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(gr||(gr={}));var br;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(br||(br={}));xt.Backward+"",xt.Forward+"",xt.Backward+"",xt.Forward+"";var yn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(yn||(yn={}));var In;(function(e){e.Optimized="optimized"})(In||(In={}));function Es(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:s}=r;return n[a]=o=>{s(o,t)},n},{}),[e,t])}yn.WhileDragging,In.Optimized;const Ds={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:mr,draggableNodes:new Map,over:null,measureDroppableContainers:mr},Ts=c.createContext(Ds),_s=c.createContext({...Rs,scaleX:1,scaleY:1});var vr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(vr||(vr={}));const Ms=c.createContext(null),Cr="button",Bs="Draggable";function wr(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Vr(Bs),{activators:o,activatorEvent:l,active:i,activeNodeRect:u,ariaDescribedById:d,draggableNodes:b,over:p}=c.useContext(Ts),{role:f=Cr,roleDescription:C="draggable",tabIndex:y=0}=a??{},g=i?.id===t,m=c.useContext(g?_s:Ms),[w,x]=Ht(),[v,S]=Ht(),I=Es(o,t),$=Pr(n);Ut(()=>(b.set(t,{id:t,key:s,node:w,activatorNode:v,data:$}),()=>{const T=b.get(t);T&&T.key===s&&b.delete(t)}),[b,t]);const M=c.useMemo(()=>({role:f,tabIndex:y,"aria-disabled":r,"aria-pressed":g&&f===Cr?!0:void 0,"aria-roledescription":C,"aria-describedby":d.draggable}),[r,f,y,g,C,d.draggable]);return{active:i,activatorEvent:l,activeNodeRect:u,attributes:M,isDragging:g,listeners:r?void 0:I,node:w,over:p,setNodeRef:x,setActivatorNodeRef:S,transform:m}}function Fs(e){return{id:e.id,start:parseFloat(e.begin),end:parseFloat(e.end),lines:e.lines,lang:e.language}}function Ws(e){return{id:e.id,begin:e.start.toFixed(3),end:e.end.toFixed(3),lines:e.lines,language:e.lang||"en"}}k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
747
+ `;function Nr(e){let t=1/0,n=-1/0;for(let a=0;a<e.length;a++){const r=e[a];t>r&&(t=r),n<r&&(n=r)}return{min:t,max:n}}function cn(e,t){const n=Math.pow(2,t-1),a=e<0?e*n:e*(n-1);return Math.max(-n,Math.min(n-1,a))}function Vn(e,t){switch(e){case 8:return new Int8Array(t);case 16:return new Int16Array(t)}}function un(e,t,n){const a=e.length,r=Math.ceil(a/t),s=Vn(n,r*2);for(let o=0;o<r;o++){const l=o*t,c=Math.min((o+1)*t,a),u=e.subarray(l,c),d=Nr(u),v=cn(d.min,n),p=cn(d.max,n);s[o*2]=v,s[o*2+1]=p}return s}function Lr(e,t){const n=e.length,a=1/n,r=e[0].length/2,s=Vn(t,r*2);for(let o=0;o<r;o++){let l=0,c=0;for(let u=0;u<n;u++)l+=a*e[u][o*2],c+=a*e[u][o*2+1];s[o*2]=l,s[o*2+1]=c}return[s]}function Yr(e,t=1e3,n=!0,a=0,r,s=16){if(s!==8&&s!==16)throw new Error("Invalid number of bits specified for peaks. Must be 8 or 16.");let o=[];if("getChannelData"in e){const c=e.numberOfChannels,u=r??e.length;for(let d=0;d<c;d++){const p=e.getChannelData(d).subarray(a,u);o.push(un(p,t,s))}}else{const c=r??e.length,u=e.subarray(a,c);o.push(un(u,t,s))}return n&&o.length>1&&(o=Lr(o,s)),{length:o[0].length/2,data:o,bits:s}}function Or(e,t=1e3,n=!0,a=8,r=0,s){const o=s!==void 0?r+s:void 0;return Yr(e,t,n,r,o,a)}function Je(e,t){this._waveformData=e,this._channelIndex=t}Je.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};Je.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};Je.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};Je.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};Je.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};Je.prototype.max_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.max_sample(n));return t};var Kr=127,Ur=-128,Jr=32767,qr=-32768;function Qr(e,t){var n=Math.floor(e/t),a=e-n*t;return a>0&&n++,n}function eo(e){for(var t=e.scale,n=e.amplitude_scale,a=e.split_channels,r=e.length,s=e.sample_rate,o=e.channels.map(function(R){return new Float32Array(R)}),l=a?o.length:1,c=24,u=Qr(r,t),d=e.bits===8?1:2,v=c+u*2*d*l,p=new ArrayBuffer(v),f=new DataView(p),C=0,y=c,m=new Array(l),g=new Array(l),I=0;I<l;I++)m[I]=1/0,g[I]=-1/0;var x=e.bits===8?Ur:qr,h=e.bits===8?Kr:Jr;f.setInt32(0,2,!0),f.setUint32(4,e.bits===8,!0),f.setInt32(8,s,!0),f.setInt32(12,t,!0),f.setInt32(16,u,!0),f.setInt32(20,l,!0);for(var w=0;w<r;w++){var k=0;if(l===1){for(var A=0;A<o.length;++A)k+=o[A][w];k=Math.floor(h*k*n/o.length),k<m[0]&&(m[0]=k,m[0]<x&&(m[0]=x)),k>g[0]&&(g[0]=k,g[0]>h&&(g[0]=h))}else for(var M=0;M<l;++M)k=Math.floor(h*o[M][w]*n),k<m[M]&&(m[M]=k,m[M]<x&&(m[M]=x)),k>g[M]&&(g[M]=k,g[M]>h&&(g[M]=h));if(++C===t){for(var $=0;$<l;$++)e.bits===8?(f.setInt8(y++,m[$]),f.setInt8(y++,g[$])):(f.setInt16(y,m[$],!0),f.setInt16(y+2,g[$],!0),y+=4),m[$]=1/0,g[$]=-1/0;C=0}}if(C>0)for(var E=0;E<l;E++)e.bits===8?(f.setInt8(y++,m[E]),f.setInt8(y++,g[E])):(f.setInt16(y,m[E],!0),f.setInt16(y+2,g[E],!0));return p}function Ct(e){"@babel/helpers - typeof";return Ct=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ct(e)}function to(e){return e&&Ct(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function no(e){var t=e&&Ct(e)==="object"&&"byteLength"in e;if(t){var n=new DataView(e),a=n.getInt32(0,!0);if(a!==1&&a!==2)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return t}function ao(e){var t=e.data,n=e.channels||1,a=24,r=e.bits===8?1:2,s=e.length*2*n;if(t.length!==s)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=a+t.length*r,l=new ArrayBuffer(o),c=new DataView(l);c.setInt32(0,2,!0),c.setUint32(4,e.bits===8,!0),c.setInt32(8,e.sample_rate,!0),c.setInt32(12,e.samples_per_pixel,!0),c.setInt32(16,e.length,!0),c.setInt32(20,n,!0);var u=a;if(e.bits===8)for(var d=0;d<t.length;d++)c.setInt8(u++,t[d],!0);else for(var v=0;v<t.length;v++)c.setInt16(u,t[v],!0),u+=2;return l}function tt(e){return e==null}function ro(e,t){var n=atob(e);return n}function oo(e,t,n){var a=ro(e),r=a.indexOf(`
748
+ `,10)+1,s=a.substring(r)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function so(e,t,n){var a;return function(s){return a=a||oo(e),new Worker(a,s)}}var io=so("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function De(e){if(to(e)&&(e=ao(e)),no(e)){this._data=new DataView(e),this._offset=this._version()===2?24:20,this._channels=[];for(var t=0;t<this.channels;t++)this._channels[t]=new Je(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var it={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function lo(e){var t={scale:e.scale||it.scale,bits:e.bits||it.bits,amplitude_scale:e.amplitude_scale||it.amplitude_scale,split_channels:e.split_channels||it.split_channels,disable_worker:e.disable_worker||it.disable_worker};return t}function co(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Pn(e,t,n){var a=co(e);if(t.disable_worker){var r=eo({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:a});n(void 0,new De(r),e)}else{var s=new io;s.onmessage=function(o){n(void 0,new De(o.data),e)},s.postMessage({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:a},a)}}function uo(e,t,n,a){function r(o){o||(o=new DOMException("EncodingError")),a(o),a=function(){}}var s=e.decodeAudioData(t,function(o){Pn(o,n,a)},r);s&&s.catch(r)}De.create=function(t){return new De(t)};De.createFromAudio=function(e,t){var n=lo(e);if(e.audio_context&&e.array_buffer)return uo(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Pn(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function St(e){this._inputData=e.waveformData,this._output_samples_per_pixel=e.scale,this._scale=this._inputData.scale,this._input_buffer_size=this._inputData.length;var t=this._input_buffer_size*this._inputData.scale,n=Math.ceil(t/this._output_samples_per_pixel),a=24,r=this._inputData.bits===8?1:2,s=a+n*2*this._inputData.channels*r;this._output_data=new ArrayBuffer(s),this.output_dataview=new DataView(this._output_data),this.output_dataview.setInt32(0,2,!0),this.output_dataview.setUint32(4,this._inputData.bits===8,!0),this.output_dataview.setInt32(8,this._inputData.sample_rate,!0),this.output_dataview.setInt32(12,this._output_samples_per_pixel,!0),this.output_dataview.setInt32(16,n,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new De(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var l=0;l<o;++l)this._input_buffer_size>0?(this._min[l]=this._inputData.channel(l).min_sample(this._input_index),this._max[l]=this._inputData.channel(l).max_sample(this._input_index)):(this._min[l]=0,this._max[l]=0);this._min_value=this._inputData.bits===8?-128:-32768,this._max_value=this._inputData.bits===8?127:32767,this._where=0,this._prev_where=0,this._stop=0,this._last_input_index=0}St.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};St.prototype.next=function(){for(var e=0,t=1e3,n=this._inputData.channels,a;this._input_index<this._input_buffer_size&&e<t;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var r=0;r<n;++r)a=this._outputWaveformData.channel(r),a.set_min_sample(this._output_index-1,this._min[r]),a.set_max_sample(this._output_index-1,this._max[r]);if(this._last_input_index=this._input_index,this._output_index++,this._where=this.sample_at_pixel(this._output_index),this._prev_where=this.sample_at_pixel(this._output_index-1),this._where!==this._prev_where)for(var s=0;s<n;++s)this._min[s]=this._max_value,this._max[s]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(var o=0;o<n;++o){a=this._inputData.channel(o);var l=a.min_sample(this._input_index);l<this._min[o]&&(this._min[o]=l),l=a.max_sample(this._input_index),l>this._max[o]&&(this._max[o]=l)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var c=0;c<n;++c)a=this._outputWaveformData.channel(c),a.set_min_sample(this._output_index-1,this._min[c]),a.set_max_sample(this._output_index-1,this._max[c]);return!0};St.prototype.getOutputData=function(){return this._output_data};De.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!tt(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!tt(n.scale)&&(typeof n.scale!="number"||n.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!n.scale&&!n.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(n.width&&(n.scale=Math.floor(this.duration*this.sample_rate/n.width)),n.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+n.scale+" too low, minimum: "+this.scale);return n.abortSignal=t.abortSignal,n},resample:function(t){t=this._getResampleOptions(t),t.waveformData=this;for(var n=new St(t);!n.next(););return new De(n.getOutputData())},concat:function(){var t=this,n=Array.prototype.slice.call(arguments);n.forEach(function(r){if(t.channels!==r.channels||t.sample_rate!==r.sample_rate||t.bits!==r.bits||t.scale!==r.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var a=this._concatBuffers.apply(this,n);return De.create(a)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,a=n,r=0,s=[this].concat(t).map(function(g){return g._data.buffer}),o=0;o<s.length;o++){var l=s[o],c=new DataView(l).getInt32(16,!0);a+=l.byteLength-n,r+=c}for(var u=new ArrayBuffer(a),d=new DataView(s[0]),v=new DataView(u),p=0;p<n;p++)v.setUint8(p,d.getUint8(p));v.setInt32(16,r,!0);for(var f=0,C=new Uint8Array(u,n),y=0;y<s.length;y++){var m=s[y];C.set(new Uint8Array(m,n),f),f+=m.byteLength-n}return u},slice:function(t){var n=0,a=0;if(!tt(t.startIndex)&&!tt(t.endIndex)?(n=t.startIndex,a=t.endIndex):!tt(t.startTime)&&!tt(t.endTime)&&(n=this.at_time(t.startTime),a=this.at_time(t.endTime)),n<0)throw new RangeError("startIndex or startTime must not be negative");if(a<0)throw new RangeError("endIndex or endTime must not be negative");n>this.length&&(n=this.length),a>this.length&&(a=this.length),n>a&&(n=a);var r=a-n,s=24,o=this.bits===8?1:2,l=s+r*2*this.channels*o,c=new ArrayBuffer(l),u=new DataView(c);u.setInt32(0,2,!0),u.setUint32(4,this.bits===8,!0),u.setInt32(8,this.sample_rate,!0),u.setInt32(12,this.scale,!0),u.setInt32(16,r,!0),u.setInt32(20,this.channels,!0);for(var d=0;d<r*this.channels*2;d++){var v=this._at(n*this.channels*2+d);this.bits===8?u.setInt8(s+d,v):u.setInt16(s+d*2,v,!0)}return new De(c)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var e=!!this._data.getUint32(4,!0);return e?8:16},get duration(){return this.length*this.scale/this.sample_rate},get pixels_per_second(){return this.sample_rate/this.scale},get seconds_per_pixel(){return this.scale/this.sample_rate},get channels(){return this._version()===2?this._data.getInt32(20,!0):1},channel:function(t){if(t>=0&&t<this._channels.length)return this._channels[t];throw new RangeError("Invalid channel: "+t)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(t){return this.bits===8?this._data.getInt8(this._offset+t):this._data.getInt16(this._offset+t*2,!0)},_set_at:function(t,n){return this.bits===8?this._data.setInt8(this._offset+t,n):this._data.setInt16(this._offset+t*2,n,!0)},at_time:function(t){return Math.floor(t*this.sample_rate/this.scale)},time:function(t){return t*this.scale/this.sample_rate},toJSON:function(){for(var t={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},n=0;n<this.length;n++)for(var a=0;a<this.channels;a++)t.data.push(this.channel(a).min_sample(n)),t.data.push(this.channel(a).max_sample(n));return t},toArrayBuffer:function(){return this._data.buffer}};async function Gt(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch waveform data: ${t.statusText}`);if(e.endsWith(".dat")){const a=await t.arrayBuffer();return De.create(a)}else{const a=await t.json();return De.create(a)}}function zn(e,t=0){const n=e.channel(t),a=e.bits,r=n.min_array(),s=n.max_array(),o=r.length,l=a===8?new Int8Array(o*2):new Int16Array(o*2);for(let c=0;c<o;c++)l[c*2]=r[c],l[c*2+1]=s[c];return{data:l,bits:a,length:o,sampleRate:e.sample_rate}}async function fo(e,t=0){const n=await Gt(e);return zn(n,t)}async function mo(e){const t=await Gt(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function jn(e,t,n=0,a,r){let s=e;if(a!==void 0&&r!==void 0){const p=e.scale,f=Math.floor(a/p),C=Math.ceil((a+r)/p);s=s.slice({startIndex:f,endIndex:C})}s.scale!==t&&(s=s.resample({scale:t}));const o=s.channel(n),l=s.bits,c=o.min_array(),u=o.max_array(),d=c.length,v=l===8?new Int8Array(d*2):new Int16Array(d*2);for(let p=0;p<d;p++)v[p*2]=c[p],v[p*2+1]=u[p];return{data:v,bits:l,length:d}}function Hn(e){return{id:e.id,start:parseFloat(e.begin),end:parseFloat(e.end),lines:e.lines,lang:e.language}}function ho(e){return{id:e.id,begin:e.start.toFixed(3),end:e.end.toFixed(3),lines:e.lines,language:e.lang||"en"}}S.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
767
749
  position: absolute;
768
750
  top: 0;
769
751
  background: ${e=>e.$color};
@@ -779,7 +761,7 @@ React keys must be passed directly to JSX without using spread:
779
761
  opacity: 0.5;
780
762
  border-color: ${e=>e.$color};
781
763
  }
782
- `;k.div`
764
+ `;S.div`
783
765
  position: absolute;
784
766
  bottom: 0;
785
767
  left: 0;
@@ -795,7 +777,7 @@ React keys must be passed directly to JSX without using spread:
795
777
  pointer-events: none;
796
778
  white-space: pre-wrap;
797
779
  word-break: break-word;
798
- `;k.textarea`
780
+ `;S.textarea`
799
781
  position: absolute;
800
782
  bottom: 0;
801
783
  left: 0;
@@ -815,7 +797,7 @@ React keys must be passed directly to JSX without using spread:
815
797
  outline: none;
816
798
  border-color: #4CAF50;
817
799
  }
818
- `;k.div`
800
+ `;S.div`
819
801
  position: absolute;
820
802
  top: 0;
821
803
  left: 0;
@@ -826,7 +808,7 @@ React keys must be passed directly to JSX without using spread:
826
808
  padding: 4px;
827
809
  justify-content: flex-start;
828
810
  align-items: center;
829
- `;k.button`
811
+ `;S.button`
830
812
  background: transparent;
831
813
  border: 1px solid rgba(255, 255, 255, 0.5);
832
814
  color: white;
@@ -848,12 +830,12 @@ React keys must be passed directly to JSX without using spread:
848
830
  &:active {
849
831
  background: rgba(255, 255, 255, 0.3);
850
832
  }
851
- `;var Zs=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
833
+ `;var po=S.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
852
834
  position: absolute;
853
835
  top: 0;
854
836
  height: 100%;
855
837
  pointer-events: none; /* Let events pass through to children */
856
- `,Ps=k.div`
838
+ `,go=S.div`
857
839
  position: absolute;
858
840
  top: 0;
859
841
  left: 0;
@@ -877,7 +859,7 @@ React keys must be passed directly to JSX without using spread:
877
859
  border-width: 3px;
878
860
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
879
861
  }
880
- `,Vs=k.span`
862
+ `,bo=S.span`
881
863
  font-size: 12px;
882
864
  font-weight: 600;
883
865
  color: ${e=>e.theme?.annotationLabelColor||"#2a2a2a"};
@@ -887,7 +869,7 @@ React keys must be passed directly to JSX without using spread:
887
869
  padding: 0 6px;
888
870
  letter-spacing: 0.3px;
889
871
  user-select: none;
890
- `,xr=k.div`
872
+ `,dn=S.div`
891
873
  position: absolute;
892
874
  top: 0;
893
875
  ${e=>e.$position==="left"?"left: -8px":"right: -8px"};
@@ -922,13 +904,13 @@ React keys must be passed directly to JSX without using spread:
922
904
  opacity: 1;
923
905
  background: ${e=>e.theme?.annotationResizeHandleActiveColor||"rgba(0, 0, 0, 0.7)"};
924
906
  }
925
- `,js=({annotationId:e,annotationIndex:t,startPosition:n,endPosition:r,label:a,color:s="#ff9800",isActive:o=!1,onClick:l,editable:i=!0})=>{const u=Math.max(0,r-n),d=`annotation-boundary-start-${t}`,{attributes:b,listeners:p,setActivatorNodeRef:f,isDragging:C}=wr({id:d,data:{annotationId:e,annotationIndex:t,edge:"start"},disabled:!i}),y=`annotation-boundary-end-${t}`,{attributes:g,listeners:m,setActivatorNodeRef:w,isDragging:x}=wr({id:y,data:{annotationId:e,annotationIndex:t,edge:"end"},disabled:!i});if(u<=0)return null;const v=I=>$=>{$.stopPropagation(),I?.($)},S=I=>{I.stopPropagation()};return E.jsxs(Zs,{$left:n,$width:u,children:[E.jsx(Ps,{$color:s,$isActive:o,onClick:l,children:a&&E.jsx(Vs,{children:a})}),i&&E.jsx(xr,{ref:f,$position:"left",$isDragging:C,onClick:S,...p,onPointerDown:v(p?.onPointerDown),...b}),i&&E.jsx(xr,{ref:w,$position:"right",$isDragging:x,onClick:S,...m,onPointerDown:v(m?.onPointerDown),...g})]})},zs=k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
907
+ `,Xn=({annotationId:e,annotationIndex:t,startPosition:n,endPosition:a,label:r,color:s="#ff9800",isActive:o=!1,onClick:l,editable:c=!0})=>{const u=Math.max(0,a-n),d=`annotation-boundary-start-${t}`,{attributes:v,listeners:p,setActivatorNodeRef:f,isDragging:C}=Ee.useDraggable({id:d,data:{annotationId:e,annotationIndex:t,edge:"start"},disabled:!c}),y=`annotation-boundary-end-${t}`,{attributes:m,listeners:g,setActivatorNodeRef:I,isDragging:x}=Ee.useDraggable({id:y,data:{annotationId:e,annotationIndex:t,edge:"end"},disabled:!c});if(u<=0)return null;const h=k=>A=>{A.stopPropagation(),k?.(A)},w=k=>{k.stopPropagation()};return b.jsxs(po,{$left:n,$width:u,children:[b.jsx(go,{$color:s,$isActive:o,onClick:l,children:r&&b.jsx(bo,{children:r})}),c&&b.jsx(dn,{ref:f,$position:"left",$isDragging:C,onClick:w,...p,onPointerDown:h(p?.onPointerDown),...v}),c&&b.jsx(dn,{ref:I,$position:"right",$isDragging:x,onClick:w,...g,onPointerDown:h(g?.onPointerDown),...m})]})},vo=S.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
926
908
  position: relative;
927
909
  display: flex;
928
910
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
929
911
  background: transparent;
930
912
  z-index: 110;
931
- `,Os=k.div`
913
+ `,Co=S.div`
932
914
  position: sticky;
933
915
  z-index: 200;
934
916
  left: 0;
@@ -936,16 +918,16 @@ React keys must be passed directly to JSX without using spread:
936
918
  width: ${e=>e.$controlWidth}px;
937
919
  flex-shrink: 0;
938
920
  background: transparent;
939
- `,Ns=k.div`
921
+ `,xo=S.div`
940
922
  position: relative;
941
923
  flex: 1;
942
924
  padding-left: ${e=>e.$offset||0}px;
943
- `,Ls=({children:e,className:t,height:n=30,offset:r=0,width:a})=>{const{controls:{show:s,width:o}}=en();return E.jsxs(zs,{className:t,$height:n,$controlWidth:s?o:0,$width:a,children:[E.jsx(Os,{$controlWidth:s?o:0}),E.jsx(Ns,{$offset:r,children:e})]})};k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
925
+ `,Gn=({children:e,className:t,height:n=30,offset:a=0,width:r})=>{const{controls:{show:s,width:o}}=ct();return b.jsxs(vo,{className:t,$height:n,$controlWidth:s?o:0,$width:r,children:[b.jsx(Co,{$controlWidth:s?o:0}),b.jsx(xo,{$offset:a,children:e})]})};S.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
944
926
  position: relative;
945
927
  display: flex;
946
928
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
947
929
  background: transparent;
948
- `;k.div`
930
+ `;S.div`
949
931
  position: sticky;
950
932
  z-index: 200;
951
933
  left: 0;
@@ -959,16 +941,16 @@ React keys must be passed directly to JSX without using spread:
959
941
  font-size: 12px;
960
942
  color: ${e=>e.theme?.textColorMuted||"#666"};
961
943
  font-weight: bold;
962
- `;k.div`
944
+ `;S.div`
963
945
  position: relative;
964
946
  flex: 1;
965
947
  padding-left: ${e=>e.$offset||0}px;
966
- `;var Xs=k.div`
948
+ `;var wo=S.div`
967
949
  background: ${e=>e.theme?.backgroundColor||"#fff"};
968
950
  ${e=>e.$height?`height: ${e.$height}px;`:"max-height: 200px;"}
969
951
  overflow-y: auto;
970
952
  padding: 8px;
971
- `,Hs=k.div`
953
+ `,yo=S.div`
972
954
  padding: 12px;
973
955
  margin-bottom: 6px;
974
956
  border-left: 4px solid ${e=>e.$isActive?"#ff9800":"transparent"};
@@ -987,16 +969,16 @@ React keys must be passed directly to JSX without using spread:
987
969
  outline: 2px solid #ff9800;
988
970
  outline-offset: 2px;
989
971
  }
990
- `,Gs=k.div`
972
+ `,ko=S.div`
991
973
  display: flex;
992
974
  justify-content: space-between;
993
975
  align-items: center;
994
976
  margin-bottom: 6px;
995
- `,Ys=k.div`
977
+ `,Io=S.div`
996
978
  display: flex;
997
979
  align-items: center;
998
980
  gap: 8px;
999
- `,Ks=k.span`
981
+ `,So=S.span`
1000
982
  font-size: 11px;
1001
983
  font-weight: 600;
1002
984
  color: ${e=>e.theme?.textColorMuted||"#666"};
@@ -1010,16 +992,16 @@ React keys must be passed directly to JSX without using spread:
1010
992
  outline: 2px solid #ff9800;
1011
993
  background: rgba(255, 152, 0, 0.1);
1012
994
  }
1013
- `,Us=k.span`
995
+ `,Ao=S.span`
1014
996
  font-size: 12px;
1015
997
  font-weight: 500;
1016
998
  color: ${e=>e.theme?.textColorMuted||"#555"};
1017
999
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
1018
1000
  letter-spacing: 0.5px;
1019
- `,Js=k.div`
1001
+ `,$o=S.div`
1020
1002
  display: flex;
1021
1003
  gap: 6px;
1022
- `,qs=k.button`
1004
+ `,Mo=S.button`
1023
1005
  background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
1024
1006
  border: 1px solid ${e=>e.theme?.borderColor||"#ccc"};
1025
1007
  color: ${e=>e.theme?.textColor||"#333"};
@@ -1038,7 +1020,7 @@ React keys must be passed directly to JSX without using spread:
1038
1020
  &:active {
1039
1021
  transform: scale(0.95);
1040
1022
  }
1041
- `,Qs=k.div`
1023
+ `,Ro=S.div`
1042
1024
  font-size: 14px;
1043
1025
  line-height: 1.6;
1044
1026
  color: ${e=>e.theme?.textColor||"#2a2a2a"};
@@ -1053,9 +1035,9 @@ React keys must be passed directly to JSX without using spread:
1053
1035
  outline: 2px solid #ff9800;
1054
1036
  background: rgba(255, 152, 0, 0.1);
1055
1037
  }
1056
- `,ei=({annotations:e,activeAnnotationId:t,shouldScrollToActive:n=!1,editable:r=!1,controls:a=[],annotationListConfig:s,height:o,onAnnotationClick:l,onAnnotationUpdate:i})=>{const u=c.useRef(null),d=c.useRef(null),b=c.useRef(void 0);c.useEffect(()=>{}),c.useEffect(()=>{const m=d.current;if(!m)return;const w=()=>{};return m.addEventListener("scroll",w),()=>m.removeEventListener("scroll",w)},[]),c.useEffect(()=>{t&&u.current&&n&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"}),b.current=t},[t,n]);const p=m=>{if(isNaN(m)||!isFinite(m))return"0:00.000";const w=Math.floor(m/60),x=(m%60).toFixed(3);return`${w}:${x.padStart(6,"0")}`},f=(m,w)=>{if(!r||!i)return;const x=[...e];x[m]={...x[m],lines:w.split(`
1057
- `)},i(x)},C=(m,w)=>{if(!r||!i)return;const x=w.trim();if(!x)return;const v=[...e];v[m]={...v[m],id:x},i(v)},y=(m,w,x)=>{if(!i)return;const v=[...e];m.action(v[x],x,v,s||{}),i(v)},g=m=>m.replace(/\./g," ");return E.jsx(Xs,{ref:d,$height:o,children:e.map((m,w)=>{const x=m.id===t;return E.jsxs(Hs,{ref:x?u:null,$isActive:x,onClick:()=>l?.(m),children:[E.jsxs(Gs,{children:[E.jsxs(Ys,{children:[E.jsx(Ks,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:v=>C(w,v.currentTarget.textContent||""),children:m.id}),E.jsxs(Us,{children:[p(m.start)," - ",p(m.end)]})]}),a.length>0&&E.jsx(Js,{onClick:v=>v.stopPropagation(),children:a.map((v,S)=>E.jsx(qs,{title:v.title,onClick:()=>y(v,m,w),children:v.text?v.text:E.jsx("i",{className:g(v.class||"")})},S))})]}),E.jsx(Qs,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:v=>f(w,v.currentTarget.textContent||""),children:m.lines.join(`
1058
- `)})]},m.id)})})},ti=c.memo(ei),ni=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return E.jsxs(Jt,{className:r,children:[E.jsx(qt,{type:"checkbox",id:"continuous-play",className:"continuous-play",checked:e,onChange:a,disabled:n}),E.jsx(Qt,{htmlFor:"continuous-play",children:"Continuous Play"})]})},ri=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return E.jsxs(Jt,{className:r,children:[E.jsx(qt,{type:"checkbox",id:"link-endpoints",className:"link-endpoints",checked:e,onChange:a,disabled:n}),E.jsx(Qt,{htmlFor:"link-endpoints",children:"Link Endpoints"})]})},ai=({checked:e,onChange:t,className:n})=>E.jsxs(Jt,{className:n,children:[E.jsx(qt,{type:"checkbox",id:"editable-annotations",checked:e,onChange:r=>t(r.target.checked)}),E.jsx(Qt,{htmlFor:"editable-annotations",children:"Editable Annotations"})]}),oi=k.button`
1038
+ `,Eo=({annotations:e,activeAnnotationId:t,shouldScrollToActive:n=!1,scrollActivePosition:a="center",scrollActiveContainer:r="nearest",editable:s=!1,controls:o=[],annotationListConfig:l,height:c,onAnnotationClick:u,onAnnotationUpdate:d,renderAnnotationItem:v})=>{const p=i.useRef(null),f=i.useRef(null),C=i.useRef(void 0);i.useEffect(()=>{}),i.useEffect(()=>{const h=f.current;if(!h)return;const w=()=>{};return h.addEventListener("scroll",w),()=>h.removeEventListener("scroll",w)},[]),i.useEffect(()=>{t&&p.current&&n&&p.current.scrollIntoView({behavior:"smooth",block:a,container:r}),C.current=t},[t,n,a,r]);const y=h=>{if(isNaN(h)||!isFinite(h))return"0:00.000";const w=Math.floor(h/60),k=(h%60).toFixed(3);return`${w}:${k.padStart(6,"0")}`},m=(h,w)=>{if(!s||!d)return;const k=[...e];k[h]={...k[h],lines:w.split(`
1039
+ `)},d(k)},g=(h,w)=>{if(!s||!d)return;const k=w.trim();if(!k)return;const A=[...e];A[h]={...A[h],id:k},d(A)},I=(h,w,k)=>{if(!d)return;const A=[...e];h.action(A[k],k,A,l||{}),d(A)},x=h=>h.replace(/\./g," ");return b.jsx(wo,{ref:f,$height:c,children:e.map((h,w)=>{const k=h.id===t,A=()=>u?.(h);return v?b.jsx("div",{ref:k?p:null,children:v({annotation:h,index:w,isActive:k,onClick:A,formatTime:y})},h.id):b.jsxs(yo,{ref:k?p:null,$isActive:k,onClick:A,children:[b.jsxs(ko,{children:[b.jsxs(Io,{children:[b.jsx(So,{$isEditable:s,contentEditable:s,suppressContentEditableWarning:!0,onBlur:M=>g(w,M.currentTarget.textContent||""),children:h.id}),b.jsxs(Ao,{children:[y(h.start)," - ",y(h.end)]})]}),o.length>0&&b.jsx($o,{onClick:M=>M.stopPropagation(),children:o.map((M,$)=>b.jsx(Mo,{title:M.title,onClick:()=>I(M,h,w),children:M.text?M.text:b.jsx("i",{className:x(M.class||"")})},$))})]}),b.jsx(Ro,{$isEditable:s,contentEditable:s,suppressContentEditableWarning:!0,onBlur:M=>m(w,M.currentTarget.textContent||""),children:h.lines.join(`
1040
+ `)})]},h.id)})})},Nn=i.memo(Eo),Do=({checked:e,onChange:t,disabled:n=!1,className:a})=>{const r=s=>{t(s.target.checked)};return b.jsxs(wt,{className:a,children:[b.jsx(yt,{type:"checkbox",id:"continuous-play",className:"continuous-play",checked:e,onChange:r,disabled:n}),b.jsx(kt,{htmlFor:"continuous-play",children:"Continuous Play"})]})},Bo=({checked:e,onChange:t,disabled:n=!1,className:a})=>{const r=s=>{t(s.target.checked)};return b.jsxs(wt,{className:a,children:[b.jsx(yt,{type:"checkbox",id:"link-endpoints",className:"link-endpoints",checked:e,onChange:r,disabled:n}),b.jsx(kt,{htmlFor:"link-endpoints",children:"Link Endpoints"})]})},To=({checked:e,onChange:t,className:n})=>b.jsxs(wt,{className:n,children:[b.jsx(yt,{type:"checkbox",id:"editable-annotations",checked:e,onChange:a=>t(a.target.checked)}),b.jsx(kt,{htmlFor:"editable-annotations",children:"Editable Annotations"})]}),Wo=S.button`
1059
1041
  padding: 0.5rem 1rem;
1060
1042
  background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
1061
1043
  color: ${e=>e.theme?.textColor||"#333"};
@@ -1081,7 +1063,7 @@ React keys must be passed directly to JSX without using spread:
1081
1063
  opacity: 0.6;
1082
1064
  cursor: not-allowed;
1083
1065
  }
1084
- `,si=({annotations:e,filename:t="annotations.json",disabled:n=!1,className:r,children:a="Download JSON"})=>{const s=()=>{if(e.length===0)return;const o=e.map(b=>Ws(b)),l=JSON.stringify(o,null,2),i=new Blob([l],{type:"application/json"}),u=URL.createObjectURL(i),d=document.createElement("a");d.href=u,d.download=t,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(u)};return E.jsx(oi,{onClick:s,disabled:n||e.length===0,className:r,title:e.length===0?"No annotations to download":"Download the annotations as JSON",children:a})};function ra(){const[e,t]=c.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:a=>It(a,e),parseTime:a=>Ur(a,e)}}const ii=[256,512,1024,2048,4096,8192];function aa({initialSamplesPerPixel:e,zoomLevels:t=ii}){const[n,r]=c.useState(()=>{const u=t.indexOf(e);return u!==-1?u:Math.floor(t.length/2)}),a=t[n],s=n>0,o=n<t.length-1,l=c.useCallback(()=>{r(u=>Math.max(0,u-1))},[]),i=c.useCallback(()=>{r(u=>Math.min(t.length-1,u+1))},[t.length]);return{samplesPerPixel:a,zoomIn:l,zoomOut:i,canZoomIn:s,canZoomOut:o}}function oa({playoutRef:e,initialVolume:t=1,onVolumeChange:n}){const[r,a]=c.useState(t),s=c.useCallback(o=>{a(o),e.current&&e.current.setMasterGain(o),n?.(o)},[e,n]);return{masterVolume:r,setMasterVolume:s}}const li=(e=256)=>{const t=c.useRef(null),n=c.useCallback((r,a,s)=>{const o=new P.Analyser("fft",e);return r.connect(o),r.connect(a),t.current=o,function(){o.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}};function Sn(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:a=1,name:s,color:o,fadeIn:l,fadeOut:i,waveformData:u}=e,d=t?.sampleRate??e.sampleRate??u?.sample_rate,b=t?.length??e.sourceDurationSamples??(u&&d?Math.ceil(u.duration*d):void 0);if(d===void 0)throw new Error("createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");if(b===void 0)throw new Error("createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)");t&&u&&t.sampleRate!==u.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${u.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const p=e.durationSamples??b;return{id:sa(),audioBuffer:t,startSample:n,durationSamples:p,offsetSamples:r,sampleRate:d,sourceDurationSamples:b,gain:a,name:s,color:o,fadeIn:l,fadeOut:i,waveformData:u}}function ci(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:a=1,name:s,color:o,fadeIn:l,fadeOut:i,waveformData:u}=e,d=t?.sampleRate??e.sampleRate??u?.sample_rate;if(d===void 0)throw new Error("createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");const b=t?.duration??e.sourceDuration??u?.duration;if(b===void 0)throw new Error("createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)");t&&u&&t.sampleRate!==u.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${u.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const p=e.duration??b;return Sn({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(p*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(b*d),gain:a,name:s,color:o,fadeIn:l,fadeOut:i,waveformData:u})}function ui(e){const{name:t,clips:n=[],muted:r=!1,soloed:a=!1,volume:s=1,pan:o=0,color:l,height:i}=e;return{id:sa(),name:t,clips:n,muted:r,soloed:a,volume:s,pan:o,color:l,height:i}}function sa(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function di(e,t={}){const{progressive:n=!1}=t,[r,a]=c.useState([]),[s,o]=c.useState(!0),[l,i]=c.useState(null),[u,d]=c.useState(0),b=e.length;return c.useEffect(()=>{if(e.length===0){a([]),o(!1),d(0);return}let p=!1;const f=new Map,C=(g,m,w)=>{const x=w??g.audioBuffer;if(!x&&!g.waveformData)throw new Error(`Track ${m+1}: Must provide src, audioBuffer, or waveformData`);const v=x?.duration??g.waveformData?.duration,S=ci({audioBuffer:x,startTime:g.startTime??0,duration:g.duration??v,offset:g.offset??0,name:g.name||`Track ${m+1}`,fadeIn:g.fadeIn,fadeOut:g.fadeOut,waveformData:g.waveformData});if(isNaN(S.startSample)||isNaN(S.durationSamples)||isNaN(S.offsetSamples))throw console.error("Invalid clip values:",S),new Error(`Invalid clip values for track ${m+1}`);return{...ui({name:g.name||`Track ${m+1}`,clips:[S],muted:g.muted??!1,soloed:g.soloed??!1,volume:g.volume??1,pan:g.pan??0,color:g.color}),effects:g.effects}};return(async()=>{try{o(!0),i(null),d(0);const g=Wr.getContext().rawContext,m=e.map(async(x,v)=>{if(x.audioBuffer){const T=C(x,v,x.audioBuffer);return n&&!p&&(f.set(v,T),d(_=>_+1),a(Array.from({length:e.length},(_,D)=>f.get(D)).filter(_=>_!==void 0))),T}if(!x.src&&x.waveformData){const T=C(x,v);return n&&!p&&(f.set(v,T),d(_=>_+1),a(Array.from({length:e.length},(_,D)=>f.get(D)).filter(_=>_!==void 0))),T}if(!x.src)throw new Error(`Track ${v+1}: Must provide src, audioBuffer, or waveformData`);const S=await fetch(x.src);if(!S.ok)throw new Error(`Failed to fetch ${x.src}: ${S.statusText}`);const I=await S.arrayBuffer(),$=await g.decodeAudioData(I);if(!$||!$.sampleRate||!$.duration)throw new Error(`Invalid audio buffer for ${x.src}`);const M=C(x,v,$);return n&&!p&&(f.set(v,M),d(T=>T+1),a(Array.from({length:e.length},(T,_)=>f.get(_)).filter(T=>T!==void 0))),M}),w=await Promise.all(m);p||(n||(a(w),d(w.length)),o(!1))}catch(g){if(!p){const m=g instanceof Error?g.message:"Unknown error loading audio";i(m),o(!1),console.error("Error loading audio tracks:",g)}}})(),()=>{p=!0}},[e,n]),{tracks:r,loading:s,error:l,loadedCount:u,totalCount:b}}function fi({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r}){const a=c.useRef(null),s=c.useCallback(u=>{const{transform:d,active:b}=u;if(!b?.data?.current)return{...d,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:f,boundary:C}=b.data.current;if(C)return{...d,scaleX:1,scaleY:1};const y=e[p];if(!y)return{...d,scaleX:1,scaleY:1};const g=y.clips[f];if(!g)return{...d,scaleX:1,scaleY:1};const m=g.startSample/r,w=g.durationSamples/r,x=d.x*n/r;let v=m+x;const S=[...y.clips].sort((D,V)=>D.startSample-V.startSample),I=S.findIndex(D=>D===g);v=Math.max(0,v);const $=I>0?S[I-1]:null;if($){const D=($.startSample+$.durationSamples)/r;v=Math.max(v,D)}const M=I<S.length-1?S[I+1]:null;if(M){const D=v+w,V=M.startSample/r;D>V&&(v=V-w)}const _=(v-m)*r/n;return{...d,x:_,scaleX:1,scaleY:1}},[e,n,r]),o=c.useCallback(u=>{const{active:d}=u,{boundary:b}=d.data.current;if(!b){a.current=null;return}const{trackIndex:p,clipIndex:f}=d.data.current,y=e[p]?.clips[f];y&&(a.current={offsetSamples:y.offsetSamples,durationSamples:y.durationSamples,startSample:y.startSample})},[e]),l=c.useCallback(u=>{const{active:d,delta:b}=u,{boundary:p}=d.data.current;if(!p||!a.current)return;const{trackIndex:f,clipIndex:C}=d.data.current,y=b.x*n,g=Math.floor(.1*r),m=a.current,w=e.map((x,v)=>{if(v!==f)return x;const S=[...x.clips].sort((M,T)=>M.startSample-T.startSample),I=S.findIndex(M=>M===x.clips[C]),$=x.clips.map((M,T)=>{if(T!==C)return M;const _=M.sourceDurationSamples;if(p==="left"){let D=Math.floor(y);const V=-m.startSample;D<V&&(D=V);const W=-m.offsetSamples;D<W&&(D=W);const O=I>0?S[I-1]:null;if(O){const oe=O.startSample+O.durationSamples-m.startSample;D<oe&&(D=oe)}const N=m.durationSamples-g;D>N&&(D=N);const Y=m.offsetSamples+D,ee=m.durationSamples-D,re=m.startSample+D;return{...M,offsetSamples:Y,durationSamples:ee,startSample:re}}else{let D=Math.floor(m.durationSamples+y);D=Math.max(g,D),m.offsetSamples+D>_&&(D=_-m.offsetSamples);const V=I<S.length-1?S[I+1]:null;return V&&m.startSample+D>V.startSample&&(D=V.startSample-m.startSample,D=Math.max(g,D)),{...M,durationSamples:D}}});return{...x,clips:$}});t(w)},[e,t,n,r]),i=c.useCallback(u=>{const{active:d,delta:b}=u,{trackIndex:p,clipIndex:f,boundary:C}=d.data.current,y=b.x*n;if(C){a.current=null;return}const g=e.map((m,w)=>{if(w!==p)return m;const x=[...m.clips].sort((I,$)=>I.startSample-$.startSample),v=x.findIndex(I=>I===m.clips[f]),S=m.clips.map((I,$)=>{if($!==f)return I;let M=Math.floor(I.startSample+y);M=Math.max(0,M);const T=v>0?x[v-1]:null;if(T){const D=T.startSample+T.durationSamples;M=Math.max(M,D)}const _=v<x.length-1?x[v+1]:null;return _&&M+I.durationSamples>_.startSample&&(M=_.startSample-I.durationSamples),{...I,startSample:M}});return{...m,clips:S}});t(g)},[e,t,n,r]);return{onDragStart:o,onDragMove:l,onDragEnd:i,collisionModifier:s}}const mn=.01;function mi({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:a,linkEndpoints:s}){const o=c.useRef(null),l=c.useCallback(d=>{const{active:b}=d,p=b.data.current;if(!p||p.annotationIndex===void 0){o.current=null;return}const f=e[p.annotationIndex];f&&(o.current={start:f.start,end:f.end,annotationIndex:p.annotationIndex})},[e]),i=c.useCallback(d=>{const{active:b,delta:p}=d;if(!o.current)return;const f=b.data.current;if(!f)return;const{edge:C,annotationIndex:y}=f,g=o.current,m=p.x*n/r,w=C==="start"?g.start+m:g.end+m,x=hi({annotationIndex:y,newTime:w,isDraggingStart:C==="start",annotations:e,duration:a,linkEndpoints:s});t(x)},[e,t,n,r,a,s]),u=c.useCallback(()=>{o.current=null},[]);return{onDragStart:l,onDragMove:i,onDragEnd:u}}function hi({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:a,linkEndpoints:s}){const o=[...r],l=r[e];if(n){const i=Math.min(l.end-.1,Math.max(0,t)),u=i-l.start;if(o[e]={...l,start:i},s&&e>0){const d=o[e-1];Math.abs(d.end-l.start)<mn?o[e-1]={...d,end:Math.max(d.start+.1,d.end+u)}:i<=d.end&&(o[e]={...o[e],start:d.end})}else!s&&e>0&&i<o[e-1].end&&(o[e-1]={...o[e-1],end:i})}else{const i=Math.max(l.start+.1,Math.min(t,a)),u=i-l.end;if(o[e]={...l,end:i},s&&e<o.length-1){const d=o[e+1];if(Math.abs(d.start-l.end)<mn){const b=d.start+u;o[e+1]={...d,start:Math.min(d.end-.1,b)};let p=e+1;for(;p<o.length-1;){const f=o[p],C=o[p+1];if(Math.abs(C.start-f.end)<mn){const y=f.end-r[p].end;o[p+1]={...C,start:Math.min(C.end-.1,C.start+y)},p++}else break}}else i>=d.start&&(o[e]={...o[e],end:d.start})}else if(!s&&e<o.length-1&&i>o[e+1].start){const d=o[e+1];o[e+1]={...d,start:i};let b=e+1;for(;b<o.length-1;){const p=o[b],f=o[b+1];if(p.end>f.start)o[b+1]={...f,start:p.end},b++;else break}}}return o}function Fn(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ia(e){return"nodeType"in e}function St(e){var t,n;return e?Fn(e)?e:ia(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function pi(e){const{Document:t}=St(e);return e instanceof t}function gi(e){return Fn(e)?!1:e instanceof St(e).HTMLElement}function bi(e){return e instanceof St(e).SVGElement}function nn(e){return e?Fn(e)?e.document:ia(e)?pi(e)?e:gi(e)||bi(e)?e.ownerDocument:document:document:document}function vi(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((s,o)=>{const l=Object.entries(o);for(const[i,u]of l){const d=s[i];d!=null&&(s[i]=d+e*u)}return s},{...t})}}const Ci=vi(-1);function wi(e){return"clientX"in e&&"clientY"in e}function xi(e){if(!e)return!1;const{TouchEvent:t}=St(e.target);return t&&e instanceof t}function yr(e){if(xi(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return wi(e)?{x:e.clientX,y:e.clientY}:null}var Ir;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Ir||(Ir={}));function hn(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function yi(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const An=Object.freeze({x:0,y:0});var yt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(yt||(yt={}));class pn{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var a;(a=this.target)==null||a.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function Ii(e){const{EventTarget:t}=St(e);return e instanceof t?e:nn(e)}function gn(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var nt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(nt||(nt={}));function Sr(e){e.preventDefault()}function Si(e){e.stopPropagation()}var rt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(rt||(rt={}));rt.Space,rt.Enter,rt.Esc,rt.Space,rt.Enter,rt.Tab;function Ar(e){return!!(e&&"distance"in e)}function kr(e){return!!(e&&"delay"in e)}class Wn{constructor(t,n,r){var a;r===void 0&&(r=Ii(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:o}=s;this.props=t,this.events=n,this.document=nn(o),this.documentListeners=new pn(this.document),this.listeners=new pn(r),this.windowListeners=new pn(St(o)),this.initialCoordinates=(a=yr(s))!=null?a:An,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(nt.Resize,this.handleCancel),this.windowListeners.add(nt.DragStart,Sr),this.windowListeners.add(nt.VisibilityChange,this.handleCancel),this.windowListeners.add(nt.ContextMenu,Sr),this.documentListeners.add(nt.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(kr(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Ar(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:a}=this.props;a(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(nt.Click,Si,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(nt.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:a,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!a)return;const i=(n=yr(t))!=null?n:An,u=Ci(a,i);if(!r&&l){if(Ar(l)){if(l.tolerance!=null&&gn(u,l.tolerance))return this.handleCancel();if(gn(u,l.distance))return this.handleStart()}if(kr(l)&&gn(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}t.cancelable&&t.preventDefault(),o(i)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===rt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Ai={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class la extends Wn{constructor(t){const{event:n}=t,r=nn(n.target);super(t,Ai,r)}}la.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const ki={move:{name:"mousemove"},end:{name:"mouseup"}};var kn;(function(e){e[e.RightClick=2]="RightClick"})(kn||(kn={}));class ca extends Wn{constructor(t){super(t,ki,nn(t.event.target))}}ca.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===kn.RightClick?!1:(r?.({event:n}),!0)}}];const bn={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ua extends Wn{constructor(t){super(t,bn)}static setup(){return window.addEventListener(bn.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(bn.move.name,t)};function t(){}}}ua.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:a}=n;return a.length>1?!1:(r?.({event:n}),!0)}}];var $r;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})($r||($r={}));var Rr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Rr||(Rr={}));yt.Backward+"",yt.Forward+"",yt.Backward+"",yt.Forward+"";var $n;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})($n||($n={}));var Rn;(function(e){e.Optimized="optimized"})(Rn||(Rn={}));$n.WhileDragging,Rn.Optimized;({...An});var Er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Er||(Er={}));function $i(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:a=1}=e,s=hn(ca,{activationConstraint:{distance:a}}),o=hn(ua,{activationConstraint:t?{delay:n,tolerance:r}:{distance:a}}),l=hn(la,{activationConstraint:{distance:a}});return yi(...t?[s,o]:[l])}const Ri=e=>{const{tracks:t,onTracksChange:n,sampleRate:r}=e,{currentTimeRef:a}=We(),{selectedTrackId:s}=Le(),o=c.useCallback((i,u,d)=>{const{sampleRate:b,samplesPerPixel:p}=e,f=t[i];if(!f)return!1;const C=f.clips[u];if(!C)return!1;const y=C.startSample/b,g=(C.startSample+C.durationSamples)/b;if(d<=y||d>=g)return console.warn("Split time is outside clip bounds"),!1;const m=Math.round(d*b),w=Math.floor(m/p),x=C.startSample+C.durationSamples,v=w*p,S=C.startSample,I=v-S,$=v,M=x-$,T=v-C.startSample,_=Sn({audioBuffer:C.audioBuffer,startSample:S,durationSamples:I,offsetSamples:C.offsetSamples,sampleRate:C.sampleRate,sourceDurationSamples:C.sourceDurationSamples,gain:C.gain,name:C.name?`${C.name} (1)`:void 0,color:C.color,fadeIn:C.fadeIn,waveformData:C.waveformData}),D=Sn({audioBuffer:C.audioBuffer,startSample:$,durationSamples:M,offsetSamples:C.offsetSamples+T,sampleRate:C.sampleRate,sourceDurationSamples:C.sourceDurationSamples,gain:C.gain,name:C.name?`${C.name} (2)`:void 0,color:C.color,waveformData:C.waveformData,fadeOut:C.fadeOut}),V=[...f.clips];V.splice(u,1,_,D);const W=[...t];return W[i]={...f,clips:V},n(W),!0},[t,n,e]);return{splitClipAtPlayhead:c.useCallback(()=>{if(!s)return console.log("No track selected - click a clip to select a track first"),!1;const i=t.findIndex(b=>b.id===s);if(i===-1)return console.warn("Selected track not found"),!1;const u=t[i],d=a.current??0;for(let b=0;b<u.clips.length;b++){const p=u.clips[b],f=p.startSample/r,C=(p.startSample+p.durationSamples)/r;if(d>f&&d<C)return console.log(`Splitting clip on track "${u.name}" at ${d}s`),o(i,b,d)}return console.log(`No clip found at playhead position on track "${u.name}"`),!1},[t,a,s,o,r]),splitClipAt:o}},Kt=e=>{const{shortcuts:t,enabled:n=!0}=e,r=c.useCallback(a=>{if(!n)return;const s=a.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const o=t.find(l=>{const i=a.key.toLowerCase()===l.key.toLowerCase()||a.key===l.key,u=l.ctrlKey===void 0||a.ctrlKey===l.ctrlKey,d=l.shiftKey===void 0||a.shiftKey===l.shiftKey,b=l.metaKey===void 0||a.metaKey===l.metaKey,p=l.altKey===void 0||a.altKey===l.altKey;return i&&u&&d&&b&&p});o&&(o.preventDefault!==!1&&a.preventDefault(),o.action())},[t,n]);c.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},Ei=e=>{const t=[],n=typeof navigator<"u"&&navigator.platform.includes("Mac");return e.metaKey&&t.push(n?"Cmd":"Ctrl"),e.ctrlKey&&!e.metaKey&&t.push("Ctrl"),e.altKey&&t.push(n?"Option":"Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")},Di=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:a}=We(),{setCurrentTime:s,play:o,pause:l,stop:i}=we(),{playoutRef:u}=De(),d=c.useCallback(()=>{a?l():o()},[a,o,l]),b=c.useCallback(()=>{i()},[i]),p=c.useCallback(()=>{a&&u.current?(u.current.stop(),s(0),o(0)):s(0)},[a,u,s,o]),C=r??[...[{key:" ",action:d,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:b,description:"Stop",preventDefault:!0},{key:"0",action:p,description:"Rewind to start",preventDefault:!0}],...n];return Kt({shortcuts:C,enabled:t}),{rewindToStart:p,togglePlayPause:d,stopPlayback:b,shortcuts:C}},vn=.01,Nt=.01;function Ti({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:a,linkEndpoints:s,continuousPlay:o=!1,enabled:l=!0,scrollContainerRef:i,samplesPerPixel:u,sampleRate:d,controlsWidth:b=0,onPlay:p}){const f=c.useMemo(()=>t?e.findIndex(T=>T.id===t):-1,[e,t]),C=c.useCallback(T=>{if(!i?.current||!u||!d)return;const _=e.find(X=>X.id===T);if(!_)return;const D=i.current,V=D.clientWidth,W=_.start*d/u+b,O=_.end*d/u+b,N=(W+O)/2,Y=D.scrollLeft,ee=Y,re=Y+V;if(W<ee||O>re){const X=Math.max(0,N-V/2);D.scrollTo({left:X,behavior:"smooth"})}},[e,i,u,d,b]);c.useEffect(()=>{t&&i?.current&&u&&d&&C(t)},[t,C,i,u,d]);const y=c.useCallback(T=>{if(f<0)return;const _=e[f],D=Math.max(0,Math.min(_.end-.1,_.start+T)),V=D-_.start,W=[...e];if(W[f]={..._,start:D},s&&f>0){const O=W[f-1];Math.abs(O.end-_.start)<vn&&(W[f-1]={...O,end:Math.max(O.start+.1,O.end+V)})}else if(!s&&f>0){const O=W[f-1];D<O.end&&(W[f-1]={...O,end:D})}n(W)},[e,f,s,n]),g=c.useCallback(T=>{if(f<0)return;const _=e[f],D=Math.max(_.start+.1,Math.min(a,_.end+T)),V=D-_.end,W=[...e];if(W[f]={..._,end:D},s&&f<e.length-1){const O=W[f+1];if(Math.abs(O.start-_.end)<vn){const N=Math.min(O.end-.1,O.start+V);W[f+1]={...O,start:N};let Y=f+1;for(;Y<W.length-1;){const ee=W[Y],re=W[Y+1];if(Math.abs(re.start-e[Y].end)<vn){const X=ee.end-e[Y].end;W[Y+1]={...re,start:Math.min(re.end-.1,re.start+X)},Y++}else break}}}else if(!s&&f<e.length-1){const O=W[f+1];if(D>O.start){W[f+1]={...O,start:D};let N=f+1;for(;N<W.length-1;){const Y=W[N],ee=W[N+1];if(Y.end>ee.start)W[N+1]={...ee,start:Y.end},N++;else break}}}n(W)},[e,f,a,s,n]),m=c.useCallback(()=>{!r||e.length===0||(f<=0?r(e[e.length-1].id):r(e[f-1].id))},[e,f,r]),w=c.useCallback(()=>{!r||e.length===0||(f<0||f>=e.length-1?r(e[0].id):r(e[f+1].id))},[e,f,r]),x=c.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),v=c.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),S=c.useCallback(()=>{r&&r(null)},[r]),I=c.useCallback(()=>{if(f<0||!p)return;const T=e[f],_=o?void 0:T.end-T.start;p(T.start,_)},[e,f,o,p]),$=c.useMemo(()=>[{key:"[",action:()=>y(-Nt),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>y(Nt),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>g(-Nt),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>g(Nt),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:I,description:"Play selected annotation",preventDefault:!0}],[y,g,I]),M=c.useMemo(()=>[{key:"ArrowUp",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:w,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:w,description:"Select next annotation",preventDefault:!0},{key:"Home",action:x,description:"Select first annotation",preventDefault:!0},{key:"End",action:v,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:S,description:"Deselect annotation",preventDefault:!0}],[m,w,x,v,S]);return Kt({shortcuts:$,enabled:l&&f>=0}),Kt({shortcuts:M,enabled:l&&e.length>0&&!!r}),{moveStartBoundary:y,moveEndBoundary:g,selectPrevious:m,selectNext:w,selectFirst:x,selectLast:v,clearSelection:S,scrollToAnnotation:C,playActiveAnnotation:I}}function _i(e){const t=e.reduce((a,s)=>a+s.length,0),n=new Float32Array(t);let r=0;for(const a of e)n.set(a,r),r+=a.length;return n}function Mi(e,t,n,r=1){const a=e.createBuffer(r,t.length,n),s=new Float32Array(t);return a.copyToChannel(s,0),a}function Dr(e,t,n=16){const r=Math.ceil(e.length/t),a=n===8?new Int8Array(r*2):new Int16Array(r*2),s=2**(n-1);for(let o=0;o<r;o++){const l=o*t,i=Math.min(l+t,e.length);let u=0,d=0;for(let b=l;b<i;b++){const p=e[b];p<u&&(u=p),p>d&&(d=p)}a[o*2]=Math.floor(u*s),a[o*2+1]=Math.floor(d*s)}return a}function Bi(e,t,n,r,a=16){const s=2**(a-1),o=r%n;let l=0;if(o>0&&e.length>0){const d=n-o,b=Math.min(d,t.length);let p=e[e.length-2]/s,f=e[e.length-1]/s;for(let m=0;m<b;m++){const w=t[m];w<p&&(p=w),w>f&&(f=w)}const C=new(a===8?Int8Array:Int16Array)(e.length);C.set(e),C[e.length-2]=Math.floor(p*s),C[e.length-1]=Math.floor(f*s),l=b;const y=Dr(t.slice(l),n,a),g=new(a===8?Int8Array:Int16Array)(C.length+y.length);return g.set(C),g.set(y,C.length),g}const i=Dr(t.slice(l),n,a),u=new(a===8?Int8Array:Int16Array)(e.length+i.length);return u.set(e),u.set(i,e.length),u}function Fi(e,t={}){const{channelCount:n=1,samplesPerPixel:r=1024}=t,[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,u]=c.useState(0),[d,b]=c.useState(new Int16Array(0)),[p,f]=c.useState(null),[C,y]=c.useState(null),[g,m]=c.useState(0),[w,x]=c.useState(0),v=16,S=c.useRef(!1),I=c.useRef(null),$=c.useRef(null),M=c.useRef([]),T=c.useRef(0),_=c.useRef(null),D=c.useRef(0),V=c.useRef(!1),W=c.useRef(!1),O=c.useCallback(async()=>{if(!S.current)try{const X=P.getContext(),oe=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw",typeof document>"u"?require("url").pathToFileURL(__filename).href:cn&&cn.tagName.toUpperCase()==="SCRIPT"&&cn.src||new URL("index.js",document.baseURI).href).href;await X.addAudioWorkletModule(oe),S.current=!0}catch(X){throw console.error("Failed to load AudioWorklet module:",X),new Error("Failed to load recording processor")}},[]),N=c.useCallback(async()=>{if(!e){y(new Error("No microphone stream available"));return}try{y(null);const X=P.getContext();X.state==="suspended"&&await X.resume(),await O();const oe=X.createMediaStreamSource(e);$.current=oe;const A=X.createAudioWorkletNode("recording-processor");I.current=A,oe.connect(A),A.port.onmessage=H=>{const{samples:U}=H.data;M.current.push(U),T.current+=U.length,b(ge=>Bi(ge,U,r,T.current-U.length,v))},A.port.postMessage({command:"start",sampleRate:X.sampleRate,channelCount:n}),M.current=[],T.current=0,b(new Int16Array(0)),f(null),m(0),x(0),V.current=!0,W.current=!1,s(!0),l(!1),D.current=performance.now();const j=()=>{if(V.current&&!W.current){const H=(performance.now()-D.current)/1e3;u(H),_.current=requestAnimationFrame(j)}};j()}catch(X){console.error("Failed to start recording:",X),y(X instanceof Error?X:new Error("Failed to start recording"))}},[e,n,r,O,a,o]),Y=c.useCallback(async()=>{if(!a)return null;try{if(I.current){if(I.current.port.postMessage({command:"stop"}),$.current)try{$.current.disconnect(I.current)}catch{}I.current.disconnect()}_.current!==null&&(cancelAnimationFrame(_.current),_.current=null);const X=_i(M.current),A=P.getContext().rawContext,j=Mi(A,X,A.sampleRate,n);return f(j),u(j.duration),V.current=!1,W.current=!1,s(!1),l(!1),m(0),j}catch(X){return console.error("Failed to stop recording:",X),y(X instanceof Error?X:new Error("Failed to stop recording")),null}},[a,n]),ee=c.useCallback(()=>{a&&!o&&(_.current!==null&&(cancelAnimationFrame(_.current),_.current=null),W.current=!0,l(!0))},[a,o]),re=c.useCallback(()=>{if(a&&o){W.current=!1,l(!1),D.current=performance.now()-i*1e3;const X=()=>{if(V.current&&!W.current){const oe=(performance.now()-D.current)/1e3;u(oe),_.current=requestAnimationFrame(X)}};X()}},[a,o,i]);return c.useEffect(()=>()=>{if(I.current){if(I.current.port.postMessage({command:"stop"}),$.current)try{$.current.disconnect(I.current)}catch{}I.current.disconnect()}_.current!==null&&cancelAnimationFrame(_.current)},[]),{isRecording:a,isPaused:o,duration:i,peaks:d,audioBuffer:p,level:g,peakLevel:w,startRecording:N,stopRecording:Y,pauseRecording:ee,resumeRecording:re,error:C}}function Wi(){const[e,t]=c.useState(null),[n,r]=c.useState([]),[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,u]=c.useState(null),d=c.useCallback(async()=>{try{const C=(await navigator.mediaDevices.enumerateDevices()).filter(y=>y.kind==="audioinput").map(y=>({deviceId:y.deviceId,label:y.label||`Microphone ${y.deviceId.slice(0,8)}`,groupId:y.groupId}));r(C)}catch(f){console.error("Failed to enumerate devices:",f),u(f instanceof Error?f:new Error("Failed to enumerate devices"))}},[]),b=c.useCallback(async(f,C)=>{l(!0),u(null);try{e&&e.getTracks().forEach(w=>w.stop());const g={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...C,...f&&{deviceId:{exact:f}}},video:!1},m=await navigator.mediaDevices.getUserMedia(g);t(m),s(!0),await d()}catch(y){console.error("Failed to access microphone:",y),u(y instanceof Error?y:new Error("Failed to access microphone")),s(!1)}finally{l(!1)}},[e,d]),p=c.useCallback(()=>{e&&(e.getTracks().forEach(f=>f.stop()),t(null),s(!1))},[e]);return c.useEffect(()=>(d(),()=>{e&&e.getTracks().forEach(f=>f.stop())}),[]),{stream:e,devices:n,hasPermission:a,isLoading:o,requestAccess:b,stopStream:p,error:i}}function Zi(e,t={}){const{updateRate:n=60,smoothingTimeConstant:r=.8}=t,[a,s]=c.useState(0),[o,l]=c.useState(0),i=c.useRef(null),u=c.useRef(null),d=c.useRef(null),b=()=>l(0);return c.useEffect(()=>{if(!e){s(0),l(0);return}let p=!0;return(async()=>{if(!p)return;const C=P.getContext();if(C.state==="suspended"&&await C.resume(),!p)return;const y=new P.Meter({smoothing:r,context:C});i.current=y;const g=C.createMediaStreamSource(e);u.current=g,P.connect(g,y);const m=1e3/n;let w=0;const x=v=>{if(!(!p||!i.current)){if(v-w>=m){w=v;const S=i.current.getValue(),I=typeof S=="number"?S:S[0],$=Math.max(0,Math.min(1,(I+100)/100));s($),l(M=>Math.max(M,$))}d.current=requestAnimationFrame(x)}};d.current=requestAnimationFrame(x)})(),()=>{if(p=!1,d.current&&(cancelAnimationFrame(d.current),d.current=null),u.current){try{u.current.disconnect()}catch{}u.current=null}i.current&&(i.current.dispose(),i.current=null)}},[e,r,n]),{level:a,peakLevel:o,resetPeak:b}}k.button`
1066
+ `,_o=({annotations:e,filename:t="annotations.json",disabled:n=!1,className:a,children:r="Download JSON"})=>{const s=()=>{if(e.length===0)return;const o=e.map(v=>ho(v)),l=JSON.stringify(o,null,2),c=new Blob([l],{type:"application/json"}),u=URL.createObjectURL(c),d=document.createElement("a");d.href=u,d.download=t,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(u)};return b.jsx(Wo,{onClick:s,disabled:n||e.length===0,className:a,title:e.length===0?"No annotations to download":"Download the annotations as JSON",children:r})};function Ln(){const[e,t]=i.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:r=>nt(r,e),parseTime:r=>Dn(r,e)}}const Fo=[256,512,1024,2048,4096,8192];function Yn({initialSamplesPerPixel:e,zoomLevels:t=Fo}){const[n,a]=i.useState(()=>{const u=t.indexOf(e);return u!==-1?u:Math.floor(t.length/2)}),r=t[n],s=n>0,o=n<t.length-1,l=i.useCallback(()=>{a(u=>Math.max(0,u-1))},[]),c=i.useCallback(()=>{a(u=>Math.min(t.length-1,u+1))},[t.length]);return{samplesPerPixel:r,zoomIn:l,zoomOut:c,canZoomIn:s,canZoomOut:o}}function On({playoutRef:e,initialVolume:t=1,onVolumeChange:n}){const[a,r]=i.useState(t),s=i.useCallback(o=>{r(o),e.current&&e.current.setMasterGain(o),n?.(o)},[e,n]);return{masterVolume:a,setMasterVolume:s}}const Zo=(e=256)=>{const t=i.useRef(null),n=i.useCallback((a,r,s)=>{const o=new W.Analyser("fft",e);return a.connect(o),a.connect(r),t.current=o,function(){o.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}};function Vt(e){const{audioBuffer:t,startSample:n,offsetSamples:a=0,gain:r=1,name:s,color:o,fadeIn:l,fadeOut:c,waveformData:u}=e,d=t?.sampleRate??e.sampleRate??u?.sample_rate,v=t?.length??e.sourceDurationSamples??(u&&d?Math.ceil(u.duration*d):void 0);if(d===void 0)throw new Error("createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");if(v===void 0)throw new Error("createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)");t&&u&&t.sampleRate!==u.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${u.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const p=e.durationSamples??v;return{id:Kn(),audioBuffer:t,startSample:n,durationSamples:p,offsetSamples:a,sampleRate:d,sourceDurationSamples:v,gain:r,name:s,color:o,fadeIn:l,fadeOut:c,waveformData:u}}function Vo(e){const{audioBuffer:t,startTime:n,offset:a=0,gain:r=1,name:s,color:o,fadeIn:l,fadeOut:c,waveformData:u}=e,d=t?.sampleRate??e.sampleRate??u?.sample_rate;if(d===void 0)throw new Error("createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");const v=t?.duration??e.sourceDuration??u?.duration;if(v===void 0)throw new Error("createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)");t&&u&&t.sampleRate!==u.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${u.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const p=e.duration??v;return Vt({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(p*d),offsetSamples:Math.round(a*d),sampleRate:d,sourceDurationSamples:Math.ceil(v*d),gain:r,name:s,color:o,fadeIn:l,fadeOut:c,waveformData:u})}function Po(e){const{name:t,clips:n=[],muted:a=!1,soloed:r=!1,volume:s=1,pan:o=0,color:l,height:c}=e;return{id:Kn(),name:t,clips:n,muted:a,soloed:r,volume:s,pan:o,color:l,height:c}}function Kn(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function zo(e,t={}){const{progressive:n=!1}=t,[a,r]=i.useState([]),[s,o]=i.useState(!0),[l,c]=i.useState(null),[u,d]=i.useState(0),v=e.length;return i.useEffect(()=>{if(e.length===0){r([]),o(!1),d(0);return}let p=!1;const f=new Map,C=(m,g,I)=>{const x=I??m.audioBuffer;if(!x&&!m.waveformData)throw new Error(`Track ${g+1}: Must provide src, audioBuffer, or waveformData`);const h=x?.duration??m.waveformData?.duration,w=Vo({audioBuffer:x,startTime:m.startTime??0,duration:m.duration??h,offset:m.offset??0,name:m.name||`Track ${g+1}`,fadeIn:m.fadeIn,fadeOut:m.fadeOut,waveformData:m.waveformData});if(isNaN(w.startSample)||isNaN(w.durationSamples)||isNaN(w.offsetSamples))throw console.error("Invalid clip values:",w),new Error(`Invalid clip values for track ${g+1}`);return{...Po({name:m.name||`Track ${g+1}`,clips:[w],muted:m.muted??!1,soloed:m.soloed??!1,volume:m.volume??1,pan:m.pan??0,color:m.color}),effects:m.effects}};return(async()=>{try{o(!0),c(null),d(0);const m=vn.getContext().rawContext,g=e.map(async(x,h)=>{if(x.audioBuffer){const $=C(x,h,x.audioBuffer);return n&&!p&&(f.set(h,$),d(E=>E+1),r(Array.from({length:e.length},(E,R)=>f.get(R)).filter(E=>E!==void 0))),$}if(!x.src&&x.waveformData){const $=C(x,h);return n&&!p&&(f.set(h,$),d(E=>E+1),r(Array.from({length:e.length},(E,R)=>f.get(R)).filter(E=>E!==void 0))),$}if(!x.src)throw new Error(`Track ${h+1}: Must provide src, audioBuffer, or waveformData`);const w=await fetch(x.src);if(!w.ok)throw new Error(`Failed to fetch ${x.src}: ${w.statusText}`);const k=await w.arrayBuffer(),A=await m.decodeAudioData(k);if(!A||!A.sampleRate||!A.duration)throw new Error(`Invalid audio buffer for ${x.src}`);const M=C(x,h,A);return n&&!p&&(f.set(h,M),d($=>$+1),r(Array.from({length:e.length},($,E)=>f.get(E)).filter($=>$!==void 0))),M}),I=await Promise.all(g);p||(n||(r(I),d(I.length)),o(!1))}catch(m){if(!p){const g=m instanceof Error?m.message:"Unknown error loading audio";c(g),o(!1),console.error("Error loading audio tracks:",m)}}})(),()=>{p=!0}},[e,n]),{tracks:a,loading:s,error:l,loadedCount:u,totalCount:v}}function jo({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:a}){const r=i.useRef(null),s=i.useCallback(u=>{const{transform:d,active:v}=u;if(!v?.data?.current)return{...d,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:f,boundary:C}=v.data.current;if(C)return{...d,scaleX:1,scaleY:1};const y=e[p];if(!y)return{...d,scaleX:1,scaleY:1};const m=y.clips[f];if(!m)return{...d,scaleX:1,scaleY:1};const g=m.startSample/a,I=m.durationSamples/a,x=d.x*n/a;let h=g+x;const w=[...y.clips].sort((R,T)=>R.startSample-T.startSample),k=w.findIndex(R=>R===m);h=Math.max(0,h);const A=k>0?w[k-1]:null;if(A){const R=(A.startSample+A.durationSamples)/a;h=Math.max(h,R)}const M=k<w.length-1?w[k+1]:null;if(M){const R=h+I,T=M.startSample/a;R>T&&(h=T-I)}const E=(h-g)*a/n;return{...d,x:E,scaleX:1,scaleY:1}},[e,n,a]),o=i.useCallback(u=>{const{active:d}=u,{boundary:v}=d.data.current;if(!v){r.current=null;return}const{trackIndex:p,clipIndex:f}=d.data.current,y=e[p]?.clips[f];y&&(r.current={offsetSamples:y.offsetSamples,durationSamples:y.durationSamples,startSample:y.startSample})},[e]),l=i.useCallback(u=>{const{active:d,delta:v}=u,{boundary:p}=d.data.current;if(!p||!r.current)return;const{trackIndex:f,clipIndex:C}=d.data.current,y=v.x*n,m=Math.floor(.1*a),g=r.current,I=e.map((x,h)=>{if(h!==f)return x;const w=[...x.clips].sort((M,$)=>M.startSample-$.startSample),k=w.findIndex(M=>M===x.clips[C]),A=x.clips.map((M,$)=>{if($!==C)return M;const E=M.sourceDurationSamples;if(p==="left"){let R=Math.floor(y);const T=-g.startSample;R<T&&(R=T);const D=-g.offsetSamples;R<D&&(R=D);const z=k>0?w[k-1]:null;if(z){const K=z.startSample+z.durationSamples-g.startSample;R<K&&(R=K)}const V=g.durationSamples-m;R>V&&(R=V);const _=g.offsetSamples+R,L=g.durationSamples-R,X=g.startSample+R;return{...M,offsetSamples:_,durationSamples:L,startSample:X}}else{let R=Math.floor(g.durationSamples+y);R=Math.max(m,R),g.offsetSamples+R>E&&(R=E-g.offsetSamples);const T=k<w.length-1?w[k+1]:null;return T&&g.startSample+R>T.startSample&&(R=T.startSample-g.startSample,R=Math.max(m,R)),{...M,durationSamples:R}}});return{...x,clips:A}});t(I)},[e,t,n,a]),c=i.useCallback(u=>{const{active:d,delta:v}=u,{trackIndex:p,clipIndex:f,boundary:C}=d.data.current,y=v.x*n;if(C){r.current=null;return}const m=e.map((g,I)=>{if(I!==p)return g;const x=[...g.clips].sort((k,A)=>k.startSample-A.startSample),h=x.findIndex(k=>k===g.clips[f]),w=g.clips.map((k,A)=>{if(A!==f)return k;let M=Math.floor(k.startSample+y);M=Math.max(0,M);const $=h>0?x[h-1]:null;if($){const R=$.startSample+$.durationSamples;M=Math.max(M,R)}const E=h<x.length-1?x[h+1]:null;return E&&M+k.durationSamples>E.startSample&&(M=E.startSample-k.durationSamples),{...k,startSample:M}});return{...g,clips:w}});t(m)},[e,t,n,a]);return{onDragStart:o,onDragMove:l,onDragEnd:c,collisionModifier:s}}const Wt=.01;function Un({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:a,duration:r,linkEndpoints:s}){const o=i.useRef(null),l=i.useCallback(d=>{const{active:v}=d,p=v.data.current;if(!p||p.annotationIndex===void 0){o.current=null;return}const f=e[p.annotationIndex];f&&(o.current={start:f.start,end:f.end,annotationIndex:p.annotationIndex})},[e]),c=i.useCallback(d=>{const{active:v,delta:p}=d;if(!o.current)return;const f=v.data.current;if(!f)return;const{edge:C,annotationIndex:y}=f,m=o.current,g=p.x*n/a,I=C==="start"?m.start+g:m.end+g,x=Ho({annotationIndex:y,newTime:I,isDraggingStart:C==="start",annotations:e,duration:r,linkEndpoints:s});t(x)},[e,t,n,a,r,s]),u=i.useCallback(()=>{o.current=null},[]);return{onDragStart:l,onDragMove:c,onDragEnd:u}}function Ho({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:a,duration:r,linkEndpoints:s}){const o=[...a],l=a[e];if(n){const c=Math.min(l.end-.1,Math.max(0,t)),u=c-l.start;if(o[e]={...l,start:c},s&&e>0){const d=o[e-1];Math.abs(d.end-l.start)<Wt?o[e-1]={...d,end:Math.max(d.start+.1,d.end+u)}:c<=d.end&&(o[e]={...o[e],start:d.end})}else!s&&e>0&&c<o[e-1].end&&(o[e-1]={...o[e-1],end:c})}else{const c=Math.max(l.start+.1,Math.min(t,r)),u=c-l.end;if(o[e]={...l,end:c},s&&e<o.length-1){const d=o[e+1];if(Math.abs(d.start-l.end)<Wt){const v=d.start+u;o[e+1]={...d,start:Math.min(d.end-.1,v)};let p=e+1;for(;p<o.length-1;){const f=o[p],C=o[p+1];if(Math.abs(C.start-f.end)<Wt){const y=f.end-a[p].end;o[p+1]={...C,start:Math.min(C.end-.1,C.start+y)},p++}else break}}else c>=d.start&&(o[e]={...o[e],end:d.start})}else if(!s&&e<o.length-1&&c>o[e+1].start){const d=o[e+1];o[e+1]={...d,start:c};let v=e+1;for(;v<o.length-1;){const p=o[v],f=o[v+1];if(p.end>f.start)o[v+1]={...f,start:p.end},v++;else break}}}return o}function Xo(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:a=5,mouseDistance:r=1}=e,s=Ee.useSensor(Ee.MouseSensor,{activationConstraint:{distance:r}}),o=Ee.useSensor(Ee.TouchSensor,{activationConstraint:t?{delay:n,tolerance:a}:{distance:r}}),l=Ee.useSensor(Ee.PointerSensor,{activationConstraint:{distance:r}});return Ee.useSensors(...t?[s,o]:[l])}const Go=e=>{const{tracks:t,onTracksChange:n,sampleRate:a}=e,{currentTimeRef:r}=Ae(),{selectedTrackId:s}=Te(),o=i.useCallback((c,u,d)=>{const{sampleRate:v,samplesPerPixel:p}=e,f=t[c];if(!f)return!1;const C=f.clips[u];if(!C)return!1;const y=C.startSample/v,m=(C.startSample+C.durationSamples)/v;if(d<=y||d>=m)return console.warn("Split time is outside clip bounds"),!1;const g=Math.round(d*v),I=Math.floor(g/p),x=C.startSample+C.durationSamples,h=I*p,w=C.startSample,k=h-w,A=h,M=x-A,$=h-C.startSample,E=Vt({audioBuffer:C.audioBuffer,startSample:w,durationSamples:k,offsetSamples:C.offsetSamples,sampleRate:C.sampleRate,sourceDurationSamples:C.sourceDurationSamples,gain:C.gain,name:C.name?`${C.name} (1)`:void 0,color:C.color,fadeIn:C.fadeIn,waveformData:C.waveformData}),R=Vt({audioBuffer:C.audioBuffer,startSample:A,durationSamples:M,offsetSamples:C.offsetSamples+$,sampleRate:C.sampleRate,sourceDurationSamples:C.sourceDurationSamples,gain:C.gain,name:C.name?`${C.name} (2)`:void 0,color:C.color,waveformData:C.waveformData,fadeOut:C.fadeOut}),T=[...f.clips];T.splice(u,1,E,R);const D=[...t];return D[c]={...f,clips:T},n(D),!0},[t,n,e]);return{splitClipAtPlayhead:i.useCallback(()=>{if(!s)return console.log("No track selected - click a clip to select a track first"),!1;const c=t.findIndex(v=>v.id===s);if(c===-1)return console.warn("Selected track not found"),!1;const u=t[c],d=r.current??0;for(let v=0;v<u.clips.length;v++){const p=u.clips[v],f=p.startSample/a,C=(p.startSample+p.durationSamples)/a;if(d>f&&d<C)return console.log(`Splitting clip on track "${u.name}" at ${d}s`),o(c,v,d)}return console.log(`No clip found at playhead position on track "${u.name}"`),!1},[t,r,s,o,a]),splitClipAt:o}},xt=e=>{const{shortcuts:t,enabled:n=!0}=e,a=i.useCallback(r=>{if(!n)return;const s=r.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const o=t.find(l=>{const c=r.key.toLowerCase()===l.key.toLowerCase()||r.key===l.key,u=l.ctrlKey===void 0||r.ctrlKey===l.ctrlKey,d=l.shiftKey===void 0||r.shiftKey===l.shiftKey,v=l.metaKey===void 0||r.metaKey===l.metaKey,p=l.altKey===void 0||r.altKey===l.altKey;return c&&u&&d&&v&&p});o&&(o.preventDefault!==!1&&r.preventDefault(),o.action())},[t,n]);i.useEffect(()=>{if(n)return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[a,n])},No=e=>{const t=[],n=typeof navigator<"u"&&navigator.platform.includes("Mac");return e.metaKey&&t.push(n?"Cmd":"Ctrl"),e.ctrlKey&&!e.metaKey&&t.push("Ctrl"),e.altKey&&t.push(n?"Option":"Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")},Lo=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:a}=e,{isPlaying:r}=Ae(),{setCurrentTime:s,play:o,pause:l,stop:c}=me(),{playoutRef:u}=ke(),d=i.useCallback(()=>{r?l():o()},[r,o,l]),v=i.useCallback(()=>{c()},[c]),p=i.useCallback(()=>{r&&u.current?(u.current.stop(),s(0),o(0)):s(0)},[r,u,s,o]),C=a??[...[{key:" ",action:d,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:v,description:"Stop",preventDefault:!0},{key:"0",action:p,description:"Rewind to start",preventDefault:!0}],...n];return xt({shortcuts:C,enabled:t}),{rewindToStart:p,togglePlayPause:d,stopPlayback:v,shortcuts:C}},_t=.01,gt=.01;function Yo({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:a,duration:r,linkEndpoints:s,continuousPlay:o=!1,enabled:l=!0,scrollContainerRef:c,samplesPerPixel:u,sampleRate:d,controlsWidth:v=0,onPlay:p}){const f=i.useMemo(()=>t?e.findIndex($=>$.id===t):-1,[e,t]),C=i.useCallback($=>{if(!c?.current||!u||!d)return;const E=e.find(F=>F.id===$);if(!E)return;const R=c.current,T=R.clientWidth,D=E.start*d/u+v,z=E.end*d/u+v,V=(D+z)/2,_=R.scrollLeft,L=_,X=_+T;if(D<L||z>X){const F=Math.max(0,V-T/2);R.scrollTo({left:F,behavior:"smooth"})}},[e,c,u,d,v]);i.useEffect(()=>{t&&c?.current&&u&&d&&C(t)},[t,C,c,u,d]);const y=i.useCallback($=>{if(f<0)return;const E=e[f],R=Math.max(0,Math.min(E.end-.1,E.start+$)),T=R-E.start,D=[...e];if(D[f]={...E,start:R},s&&f>0){const z=D[f-1];Math.abs(z.end-E.start)<_t&&(D[f-1]={...z,end:Math.max(z.start+.1,z.end+T)})}else if(!s&&f>0){const z=D[f-1];R<z.end&&(D[f-1]={...z,end:R})}n(D)},[e,f,s,n]),m=i.useCallback($=>{if(f<0)return;const E=e[f],R=Math.max(E.start+.1,Math.min(r,E.end+$)),T=R-E.end,D=[...e];if(D[f]={...E,end:R},s&&f<e.length-1){const z=D[f+1];if(Math.abs(z.start-E.end)<_t){const V=Math.min(z.end-.1,z.start+T);D[f+1]={...z,start:V};let _=f+1;for(;_<D.length-1;){const L=D[_],X=D[_+1];if(Math.abs(X.start-e[_].end)<_t){const F=L.end-e[_].end;D[_+1]={...X,start:Math.min(X.end-.1,X.start+F)},_++}else break}}}else if(!s&&f<e.length-1){const z=D[f+1];if(R>z.start){D[f+1]={...z,start:R};let V=f+1;for(;V<D.length-1;){const _=D[V],L=D[V+1];if(_.end>L.start)D[V+1]={...L,start:_.end},V++;else break}}}n(D)},[e,f,r,s,n]),g=i.useCallback(()=>{!a||e.length===0||(f<=0?a(e[e.length-1].id):a(e[f-1].id))},[e,f,a]),I=i.useCallback(()=>{!a||e.length===0||(f<0||f>=e.length-1?a(e[0].id):a(e[f+1].id))},[e,f,a]),x=i.useCallback(()=>{!a||e.length===0||a(e[0].id)},[e,a]),h=i.useCallback(()=>{!a||e.length===0||a(e[e.length-1].id)},[e,a]),w=i.useCallback(()=>{a&&a(null)},[a]),k=i.useCallback(()=>{if(f<0||!p)return;const $=e[f],E=o?void 0:$.end-$.start;p($.start,E)},[e,f,o,p]),A=i.useMemo(()=>[{key:"[",action:()=>y(-gt),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>y(gt),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>m(-gt),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>m(gt),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:k,description:"Play selected annotation",preventDefault:!0}],[y,m,k]),M=i.useMemo(()=>[{key:"ArrowUp",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:I,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:I,description:"Select next annotation",preventDefault:!0},{key:"Home",action:x,description:"Select first annotation",preventDefault:!0},{key:"End",action:h,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:w,description:"Deselect annotation",preventDefault:!0}],[g,I,x,h,w]);return xt({shortcuts:A,enabled:l&&f>=0}),xt({shortcuts:M,enabled:l&&e.length>0&&!!a}),{moveStartBoundary:y,moveEndBoundary:m,selectPrevious:g,selectNext:I,selectFirst:x,selectLast:h,clearSelection:w,scrollToAnnotation:C,playActiveAnnotation:k}}function Oo(e){const t=e.reduce((r,s)=>r+s.length,0),n=new Float32Array(t);let a=0;for(const r of e)n.set(r,a),a+=r.length;return n}function Ko(e,t,n,a=1){const r=e.createBuffer(a,t.length,n),s=new Float32Array(t);return r.copyToChannel(s,0),r}function fn(e,t,n=16){const a=Math.ceil(e.length/t),r=n===8?new Int8Array(a*2):new Int16Array(a*2),s=2**(n-1);for(let o=0;o<a;o++){const l=o*t,c=Math.min(l+t,e.length);let u=0,d=0;for(let v=l;v<c;v++){const p=e[v];p<u&&(u=p),p>d&&(d=p)}r[o*2]=Math.floor(u*s),r[o*2+1]=Math.floor(d*s)}return r}function Uo(e,t,n,a,r=16){const s=2**(r-1),o=a%n;let l=0;if(o>0&&e.length>0){const d=n-o,v=Math.min(d,t.length);let p=e[e.length-2]/s,f=e[e.length-1]/s;for(let g=0;g<v;g++){const I=t[g];I<p&&(p=I),I>f&&(f=I)}const C=new(r===8?Int8Array:Int16Array)(e.length);C.set(e),C[e.length-2]=Math.floor(p*s),C[e.length-1]=Math.floor(f*s),l=v;const y=fn(t.slice(l),n,r),m=new(r===8?Int8Array:Int16Array)(C.length+y.length);return m.set(C),m.set(y,C.length),m}const c=fn(t.slice(l),n,r),u=new(r===8?Int8Array:Int16Array)(e.length+c.length);return u.set(e),u.set(c,e.length),u}function Jo(e,t={}){const{channelCount:n=1,samplesPerPixel:a=1024}=t,[r,s]=i.useState(!1),[o,l]=i.useState(!1),[c,u]=i.useState(0),[d,v]=i.useState(new Int16Array(0)),[p,f]=i.useState(null),[C,y]=i.useState(null),[m,g]=i.useState(0),[I,x]=i.useState(0),h=16,w=i.useRef(!1),k=i.useRef(null),A=i.useRef(null),M=i.useRef([]),$=i.useRef(0),E=i.useRef(null),R=i.useRef(0),T=i.useRef(!1),D=i.useRef(!1),z=i.useCallback(async()=>{if(!w.current)try{const F=W.getContext(),K=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw",typeof document>"u"?require("url").pathToFileURL(__filename).href:Bt&&Bt.tagName.toUpperCase()==="SCRIPT"&&Bt.src||new URL("index.js",document.baseURI).href).href;await F.addAudioWorkletModule(K),w.current=!0}catch(F){throw console.error("Failed to load AudioWorklet module:",F),new Error("Failed to load recording processor")}},[]),V=i.useCallback(async()=>{if(!e){y(new Error("No microphone stream available"));return}try{y(null);const F=W.getContext();F.state==="suspended"&&await F.resume(),await z();const K=F.createMediaStreamSource(e);A.current=K;const ae=F.createAudioWorkletNode("recording-processor");k.current=ae,K.connect(ae),ae.port.onmessage=q=>{const{samples:ne}=q.data;M.current.push(ne),$.current+=ne.length,v(be=>Uo(be,ne,a,$.current-ne.length,h))},ae.port.postMessage({command:"start",sampleRate:F.sampleRate,channelCount:n}),M.current=[],$.current=0,v(new Int16Array(0)),f(null),g(0),x(0),T.current=!0,D.current=!1,s(!0),l(!1),R.current=performance.now();const te=()=>{if(T.current&&!D.current){const q=(performance.now()-R.current)/1e3;u(q),E.current=requestAnimationFrame(te)}};te()}catch(F){console.error("Failed to start recording:",F),y(F instanceof Error?F:new Error("Failed to start recording"))}},[e,n,a,z,r,o]),_=i.useCallback(async()=>{if(!r)return null;try{if(k.current){if(k.current.port.postMessage({command:"stop"}),A.current)try{A.current.disconnect(k.current)}catch{}k.current.disconnect()}E.current!==null&&(cancelAnimationFrame(E.current),E.current=null);const F=Oo(M.current),ae=W.getContext().rawContext,te=Ko(ae,F,ae.sampleRate,n);return f(te),u(te.duration),T.current=!1,D.current=!1,s(!1),l(!1),g(0),te}catch(F){return console.error("Failed to stop recording:",F),y(F instanceof Error?F:new Error("Failed to stop recording")),null}},[r,n]),L=i.useCallback(()=>{r&&!o&&(E.current!==null&&(cancelAnimationFrame(E.current),E.current=null),D.current=!0,l(!0))},[r,o]),X=i.useCallback(()=>{if(r&&o){D.current=!1,l(!1),R.current=performance.now()-c*1e3;const F=()=>{if(T.current&&!D.current){const K=(performance.now()-R.current)/1e3;u(K),E.current=requestAnimationFrame(F)}};F()}},[r,o,c]);return i.useEffect(()=>()=>{if(k.current){if(k.current.port.postMessage({command:"stop"}),A.current)try{A.current.disconnect(k.current)}catch{}k.current.disconnect()}E.current!==null&&cancelAnimationFrame(E.current)},[]),{isRecording:r,isPaused:o,duration:c,peaks:d,audioBuffer:p,level:m,peakLevel:I,startRecording:V,stopRecording:_,pauseRecording:L,resumeRecording:X,error:C}}function qo(){const[e,t]=i.useState(null),[n,a]=i.useState([]),[r,s]=i.useState(!1),[o,l]=i.useState(!1),[c,u]=i.useState(null),d=i.useCallback(async()=>{try{const C=(await navigator.mediaDevices.enumerateDevices()).filter(y=>y.kind==="audioinput").map(y=>({deviceId:y.deviceId,label:y.label||`Microphone ${y.deviceId.slice(0,8)}`,groupId:y.groupId}));a(C)}catch(f){console.error("Failed to enumerate devices:",f),u(f instanceof Error?f:new Error("Failed to enumerate devices"))}},[]),v=i.useCallback(async(f,C)=>{l(!0),u(null);try{e&&e.getTracks().forEach(I=>I.stop());const m={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...C,...f&&{deviceId:{exact:f}}},video:!1},g=await navigator.mediaDevices.getUserMedia(m);t(g),s(!0),await d()}catch(y){console.error("Failed to access microphone:",y),u(y instanceof Error?y:new Error("Failed to access microphone")),s(!1)}finally{l(!1)}},[e,d]),p=i.useCallback(()=>{e&&(e.getTracks().forEach(f=>f.stop()),t(null),s(!1))},[e]);return i.useEffect(()=>(d(),()=>{e&&e.getTracks().forEach(f=>f.stop())}),[]),{stream:e,devices:n,hasPermission:r,isLoading:o,requestAccess:v,stopStream:p,error:c}}function Qo(e,t={}){const{updateRate:n=60,smoothingTimeConstant:a=.8}=t,[r,s]=i.useState(0),[o,l]=i.useState(0),c=i.useRef(null),u=i.useRef(null),d=i.useRef(null),v=()=>l(0);return i.useEffect(()=>{if(!e){s(0),l(0);return}let p=!0;return(async()=>{if(!p)return;const C=W.getContext();if(C.state==="suspended"&&await C.resume(),!p)return;const y=new W.Meter({smoothing:a,context:C});c.current=y;const m=C.createMediaStreamSource(e);u.current=m,W.connect(m,y);const g=1e3/n;let I=0;const x=h=>{if(!(!p||!c.current)){if(h-I>=g){I=h;const w=c.current.getValue(),k=typeof w=="number"?w:w[0],A=Math.max(0,Math.min(1,(k+100)/100));s(A),l(M=>Math.max(M,A))}d.current=requestAnimationFrame(x)}};d.current=requestAnimationFrame(x)})(),()=>{if(p=!1,d.current&&(cancelAnimationFrame(d.current),d.current=null),u.current){try{u.current.disconnect()}catch{}u.current=null}c.current&&(c.current.dispose(),c.current=null)}},[e,a,n]),{level:r,peakLevel:o,resetPeak:v}}S.button`
1085
1067
  padding: 0.5rem 1rem;
1086
1068
  font-size: 0.875rem;
1087
1069
  font-weight: 500;
@@ -1111,7 +1093,7 @@ React keys must be passed directly to JSX without using spread:
1111
1093
  outline: none;
1112
1094
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3);
1113
1095
  }
1114
- `;k.span`
1096
+ `;S.span`
1115
1097
  display: inline-block;
1116
1098
  width: 8px;
1117
1099
  height: 8px;
@@ -1129,13 +1111,13 @@ React keys must be passed directly to JSX without using spread:
1129
1111
  opacity: 0.3;
1130
1112
  }
1131
1113
  }
1132
- `;k(Tn)`
1114
+ `;S(jt)`
1133
1115
  min-width: 200px;
1134
- `;k(Nr)`
1116
+ `;S(kn)`
1135
1117
  display: flex;
1136
1118
  flex-direction: column;
1137
1119
  gap: 0.25rem;
1138
- `;k.div`
1120
+ `;S.div`
1139
1121
  display: flex;
1140
1122
  align-items: center;
1141
1123
  gap: 0.75rem;
@@ -1143,7 +1125,7 @@ React keys must be passed directly to JSX without using spread:
1143
1125
  background: ${e=>e.$isRecording?"#fff3cd":"transparent"};
1144
1126
  border-radius: 0.25rem;
1145
1127
  transition: background 0.2s ease-in-out;
1146
- `;k.div`
1128
+ `;S.div`
1147
1129
  width: 12px;
1148
1130
  height: 12px;
1149
1131
  border-radius: 50%;
@@ -1163,18 +1145,18 @@ React keys must be passed directly to JSX without using spread:
1163
1145
  }
1164
1146
  }
1165
1147
  `}
1166
- `;k.span`
1148
+ `;S.span`
1167
1149
  font-family: 'Courier New', Monaco, monospace;
1168
1150
  font-size: 1rem;
1169
1151
  font-weight: 600;
1170
1152
  color: #495057;
1171
1153
  min-width: 70px;
1172
- `;k.span`
1154
+ `;S.span`
1173
1155
  font-size: 0.75rem;
1174
1156
  font-weight: 500;
1175
1157
  color: ${e=>e.$isPaused?"#ffc107":"#dc3545"};
1176
1158
  text-transform: uppercase;
1177
- `;var Pi=k.div`
1159
+ `;var es=S.div`
1178
1160
  position: relative;
1179
1161
  width: ${e=>e.$width}px;
1180
1162
  height: ${e=>e.$height}px;
@@ -1182,39 +1164,39 @@ React keys must be passed directly to JSX without using spread:
1182
1164
  border-radius: 4px;
1183
1165
  overflow: hidden;
1184
1166
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
1185
- `,Vi=e=>e<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":e<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",ji=k.div.attrs(e=>({style:{width:`${e.$level*100}%`,height:`${e.$height}px`,background:Vi(e.$level),boxShadow:e.$level>.01?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}}))`
1167
+ `,ts=e=>e<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":e<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",ns=S.div.attrs(e=>({style:{width:`${e.$level*100}%`,height:`${e.$height}px`,background:ts(e.$level),boxShadow:e.$level>.01?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}}))`
1186
1168
  position: absolute;
1187
1169
  left: 0;
1188
1170
  top: 0;
1189
1171
  transition: width 0.05s ease-out, background 0.1s ease-out;
1190
- `,zi=k.div.attrs(e=>({style:{left:`${e.$peakLevel*100}%`,height:`${e.$height}px`}}))`
1172
+ `,as=S.div.attrs(e=>({style:{left:`${e.$peakLevel*100}%`,height:`${e.$height}px`}}))`
1191
1173
  position: absolute;
1192
1174
  top: 0;
1193
1175
  width: 2px;
1194
1176
  background: #ecf0f1;
1195
1177
  box-shadow: 0 0 4px rgba(236, 240, 241, 0.8);
1196
1178
  transition: left 0.1s ease-out;
1197
- `,Oi=k.div`
1179
+ `,rs=S.div`
1198
1180
  position: absolute;
1199
1181
  top: 0;
1200
1182
  left: 0;
1201
1183
  width: 100%;
1202
1184
  height: ${e=>e.$height}px;
1203
1185
  pointer-events: none;
1204
- `,Tr=k.div`
1186
+ `,mn=S.div`
1205
1187
  position: absolute;
1206
1188
  left: ${e=>e.$position}%;
1207
1189
  top: 0;
1208
1190
  width: 1px;
1209
1191
  height: ${e=>e.$height}px;
1210
1192
  background: rgba(255, 255, 255, 0.2);
1211
- `,Ni=({level:e,peakLevel:t,width:n=200,height:r=20,className:a})=>{const s=Math.max(0,Math.min(1,e)),o=t!==void 0?Math.max(0,Math.min(1,t)):0;return E.jsxs(Pi,{$width:n,$height:r,className:a,children:[E.jsx(ji,{$level:s,$height:r}),t!==void 0&&o>0&&E.jsx(zi,{$peakLevel:o,$height:r}),E.jsxs(Oi,{$height:r,children:[E.jsx(Tr,{$position:60,$height:r}),E.jsx(Tr,{$position:85,$height:r})]})]})};c.memo(Ni);function Li(e,t,n,r={}){const{currentTime:a=0,audioConstraints:s,...o}=r,[l,i]=c.useState(!1),[u,d]=c.useState(null),{stream:b,devices:p,hasPermission:f,requestAccess:C,error:y}=Wi(),{level:g,peakLevel:m}=Zi(b),{isRecording:w,isPaused:x,duration:v,peaks:S,startRecording:I,stopRecording:$,pauseRecording:M,resumeRecording:T,error:_}=Fi(b,o),D=c.useCallback(async()=>{n&&(l||(await un(),i(!0)),await I())},[n,l,I]),V=c.useCallback(async()=>{const N=await $();if(N&&n){const Y=e.findIndex(H=>H.id===n);if(Y===-1)return;const ee=e[Y],re=Math.floor(a*N.sampleRate);let X=0;if(ee.clips.length>0){const H=ee.clips.map(U=>U.startSample+U.durationSamples);X=Math.max(...H)}const oe=Math.max(re,X),A={id:`clip-${Date.now()}`,audioBuffer:N,startSample:oe,durationSamples:N.length,offsetSamples:0,sampleRate:N.sampleRate,sourceDurationSamples:N.length,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},j=e.map((H,U)=>U===Y?{...H,clips:[...H.clips,A]}:H);t(j)}},[n,e,t,a,$]);c.useEffect(()=>{f&&p.length>0&&u===null&&d(p[0].deviceId)},[f,p.length]);const W=c.useCallback(async()=>{await C(void 0,s),await un(),i(!0)},[C,s]),O=c.useCallback(async N=>{d(N),await C(N,s),await un(),i(!0)},[C,s]);return{isRecording:w,isPaused:x,duration:v,level:g,peakLevel:m,error:y||_,stream:b,devices:p,hasPermission:f,selectedDevice:u,startRecording:D,stopRecording:V,pauseRecording:M,resumeRecording:T,requestMicAccess:W,changeDevice:O,recordingPeaks:S}}const Mt=[{id:"reverb",name:"Reverb",category:"reverb",description:"Simple convolution reverb with adjustable decay time",parameters:[{name:"decay",label:"Decay",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"s"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"freeverb",name:"Freeverb",category:"reverb",description:"Classic Schroeder/Moorer reverb with room size and dampening",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.7},{name:"dampening",label:"Dampening",type:"number",min:0,max:1e4,step:100,default:3e3,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"jcReverb",name:"JC Reverb",category:"reverb",description:"Attempt at Roland JC-120 chorus reverb emulation",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"feedbackDelay",name:"Feedback Delay",category:"delay",description:"Delay line with feedback for echo effects",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"pingPongDelay",name:"Ping Pong Delay",category:"delay",description:"Stereo delay bouncing between left and right channels",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"chorus",name:"Chorus",category:"modulation",description:"Creates thickness by layering detuned copies of the signal",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"Hz"},{name:"delayTime",label:"Delay",type:"number",min:0,max:20,step:.5,default:3.5,unit:"ms"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.7},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"phaser",name:"Phaser",category:"modulation",description:"Classic phaser effect using allpass filters",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:.5,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:6,step:1,default:3},{name:"baseFrequency",label:"Base Freq",type:"number",min:100,max:2e3,step:10,default:350,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"tremolo",name:"Tremolo",category:"modulation",description:"Rhythmic volume modulation",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:4,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"vibrato",name:"Vibrato",category:"modulation",description:"Pitch modulation effect",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:5,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoPanner",name:"Auto Panner",category:"modulation",description:"Automatic left-right panning",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoFilter",name:"Auto Filter",category:"filter",description:"Automated filter sweep with LFO",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:2e3,step:10,default:200,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:.5,max:8,step:.5,default:2.6},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoWah",name:"Auto Wah",category:"filter",description:"Envelope follower filter effect",parameters:[{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:500,step:10,default:100,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:8,step:1,default:6},{name:"sensitivity",label:"Sensitivity",type:"number",min:-40,max:0,step:1,default:0,unit:"dB"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"eq3",name:"3-Band EQ",category:"filter",description:"Three band equalizer with low, mid, and high controls",parameters:[{name:"low",label:"Low",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"mid",label:"Mid",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"high",label:"High",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"lowFrequency",label:"Low Freq",type:"number",min:20,max:500,step:10,default:400,unit:"Hz"},{name:"highFrequency",label:"High Freq",type:"number",min:1e3,max:1e4,step:100,default:2500,unit:"Hz"}]},{id:"distortion",name:"Distortion",category:"distortion",description:"Wave shaping distortion effect",parameters:[{name:"distortion",label:"Drive",type:"number",min:0,max:1,step:.01,default:.4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"bitCrusher",name:"Bit Crusher",category:"distortion",description:"Reduces bit depth for lo-fi digital texture",parameters:[{name:"bits",label:"Bits",type:"number",min:1,max:16,step:1,default:4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"chebyshev",name:"Chebyshev",category:"distortion",description:"Waveshaping distortion using Chebyshev polynomials",parameters:[{name:"order",label:"Order",type:"number",min:1,max:100,step:1,default:50},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"compressor",name:"Compressor",category:"dynamics",description:"Dynamic range compressor",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-60,max:0,step:1,default:-24,unit:"dB"},{name:"ratio",label:"Ratio",type:"number",min:1,max:20,step:.5,default:4},{name:"attack",label:"Attack",type:"number",min:0,max:1,step:.001,default:.003,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"knee",label:"Knee",type:"number",min:0,max:40,step:1,default:30,unit:"dB"}]},{id:"limiter",name:"Limiter",category:"dynamics",description:"Hard limiter to prevent clipping",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-12,max:0,step:.5,default:-6,unit:"dB"}]},{id:"gate",name:"Gate",category:"dynamics",description:"Noise gate to silence signal below threshold",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-100,max:0,step:1,default:-40,unit:"dB"},{name:"attack",label:"Attack",type:"number",min:0,max:.3,step:.001,default:.001,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:.5,step:.01,default:.1,unit:"s"}]},{id:"stereoWidener",name:"Stereo Widener",category:"spatial",description:"Expands or narrows the stereo image",parameters:[{name:"width",label:"Width",type:"number",min:0,max:1,step:.01,default:.5}]}],Zn=e=>Mt.find(t=>t.id===e),Xi=e=>Mt.filter(t=>t.category===e),Hi=[{id:"reverb",name:"Reverb"},{id:"delay",name:"Delay"},{id:"modulation",name:"Modulation"},{id:"filter",name:"Filter"},{id:"distortion",name:"Distortion"},{id:"dynamics",name:"Dynamics"},{id:"spatial",name:"Spatial"}],Gi={reverb:P.Reverb,freeverb:P.Freeverb,jcReverb:P.JCReverb,feedbackDelay:P.FeedbackDelay,pingPongDelay:P.PingPongDelay,chorus:P.Chorus,phaser:P.Phaser,tremolo:P.Tremolo,vibrato:P.Vibrato,autoPanner:P.AutoPanner,autoFilter:P.AutoFilter,autoWah:P.AutoWah,eq3:P.EQ3,distortion:P.Distortion,bitCrusher:P.BitCrusher,chebyshev:P.Chebyshev,compressor:P.Compressor,limiter:P.Limiter,gate:P.Gate,stereoWidener:P.StereoWidener};let Yi=0;const Ki=()=>`effect_${Date.now()}_${++Yi}`;function _t(e,t){const n=Gi[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(o=>{const l=t?.[o.name]??o.default;r[o.name]=l});const a=new n(r),s=Ki();return{effect:a,id:e.id,instanceId:s,dispose(){try{a.disconnect(),a.dispose()}catch{}},setParameter(o,l){o==="wet"&&a.wet?a.wet.value=l:a[o]!==void 0&&(a[o]?.value!==void 0?a[o].value=l:a[o]=l)},getParameter(o){if(o==="wet"&&a.wet)return a.wet.value;if(a[o]!==void 0)return a[o]?.value!==void 0?a[o].value:a[o]},connect(o){a.connect(o)},disconnect(){try{a.disconnect()}catch{}}}}function Ui(e){if(e.length===0)throw new Error("Cannot create effect chain with no effects");for(let t=0;t<e.length-1;t++)e[t].effect.connect(e[t+1].effect);return{input:e[0].effect,output:e[e.length-1].effect,dispose(){e.forEach(t=>t.dispose())}}}function Ji(e=256){const[t,n]=c.useState([]),r=c.useRef(t);r.current=t;const a=c.useRef(new Map),s=c.useRef(null),o=c.useRef(null),l=c.useCallback(g=>{const m=o.current;if(!m)return;const{masterGainNode:w,destination:x,analyserNode:v}=m;try{w.disconnect()}catch{}const S=g.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(S.length===0)w.connect(v),v.connect(x);else{let I=w;S.forEach($=>{try{$.disconnect()}catch{}I.connect($.effect),I=$.effect}),I.connect(v),v.connect(x)}},[]),i=c.useCallback(g=>{const m=Zn(g);if(!m){console.error(`Unknown effect: ${g}`);return}const w={};m.parameters.forEach(S=>{w[S.name]=S.default});const x=_t(m,w);a.current.set(x.instanceId,x);const v={instanceId:x.instanceId,effectId:m.id,definition:m,params:w,bypassed:!1};n(S=>[...S,v])},[]),u=c.useCallback(g=>{const m=a.current.get(g);m&&(m.dispose(),a.current.delete(g)),n(w=>w.filter(x=>x.instanceId!==g))},[]),d=c.useCallback((g,m,w)=>{const x=a.current.get(g);x&&x.setParameter(m,w),n(v=>v.map(S=>S.instanceId===g?{...S,params:{...S.params,[m]:w}}:S))},[]),b=c.useCallback(g=>{const m=r.current.find(v=>v.instanceId===g);if(!m)return;const w=!m.bypassed,x=a.current.get(g);if(x){const v=m.params.wet??1;x.setParameter("wet",w?0:v)}n(v=>v.map(S=>S.instanceId===g?{...S,bypassed:w}:S))},[]),p=c.useCallback((g,m)=>{n(w=>{const x=[...w],[v]=x.splice(g,1);return x.splice(m,0,v),x})},[]),f=c.useCallback(()=>{a.current.forEach(g=>g.dispose()),a.current.clear(),n([])},[]);c.useEffect(()=>{l(t)},[t,l]);const C=c.useCallback((g,m,w)=>{const x=new P.Analyser("fft",e);s.current=x,o.current={masterGainNode:g,destination:m,analyserNode:x};const S=r.current.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(S.length===0)g.connect(x),x.connect(m);else{let I=g;S.forEach($=>{I.connect($.effect),I=$.effect}),I.connect(x),x.connect(m)}return function(){x.dispose(),s.current=null,o.current=null}},[e]);c.useEffect(()=>()=>{a.current.forEach(g=>g.dispose()),a.current.clear()},[]);const y=c.useCallback(()=>{const g=t.filter(m=>!m.bypassed);if(g.length!==0)return(m,w,x)=>{const v=[];for(const S of g){const I=_t(S.definition,S.params);v.push(I)}if(v.length===0)m.connect(w);else{let S=m;v.forEach(I=>{S.connect(I.effect),S=I.effect}),S.connect(w)}return function(){v.forEach(I=>I.dispose())}}},[t]);return{activeEffects:t,availableEffects:Mt,addEffect:i,removeEffect:u,updateParameter:d,toggleBypass:b,reorderEffects:p,clearAllEffects:f,masterEffects:C,createOfflineEffectsFunction:y,analyserRef:s}}function qi(){const[e,t]=c.useState(new Map),n=c.useRef(new Map),r=c.useRef(new Map),a=c.useCallback((f,C)=>{const y=r.current.get(f);if(!y)return;const{graphEnd:g,masterGainNode:m}=y,w=n.current.get(f);try{g.disconnect()}catch{}const x=C.map(v=>w?.get(v.instanceId)).filter(v=>v!==void 0);if(x.length===0)g.connect(m);else{let v=g;x.forEach(S=>{try{S.disconnect()}catch{}v.connect(S.effect),v=S.effect}),v.connect(m)}},[]),s=c.useCallback((f,C)=>{const y=Zn(C);if(!y){console.error(`Unknown effect: ${C}`);return}const g={};y.parameters.forEach(x=>{g[x.name]=x.default});const m=_t(y,g);n.current.has(f)||n.current.set(f,new Map),n.current.get(f).set(m.instanceId,m);const w={instanceId:m.instanceId,effectId:y.id,definition:y,params:g,bypassed:!1};t(x=>{const v=new Map(x),S=v.get(f)||[];return v.set(f,[...S,w]),v})},[]),o=c.useCallback((f,C)=>{const y=n.current.get(f),g=y?.get(C);g&&(g.dispose(),y?.delete(C)),t(m=>{const w=new Map(m),x=w.get(f)||[];return w.set(f,x.filter(v=>v.instanceId!==C)),w})},[]),l=c.useCallback((f,C,y,g)=>{const w=n.current.get(f)?.get(C);w&&w.setParameter(y,g),t(x=>{const v=new Map(x),S=v.get(f)||[];return v.set(f,S.map(I=>I.instanceId===C?{...I,params:{...I.params,[y]:g}}:I)),v})},[]),i=c.useCallback((f,C)=>{const g=(d.current.get(f)||[]).find(v=>v.instanceId===C);if(!g)return;const m=!g.bypassed,x=n.current.get(f)?.get(C);if(x){const v=g.params.wet??1;x.setParameter("wet",m?0:v)}t(v=>{const S=new Map(v),I=S.get(f)||[];return S.set(f,I.map($=>$.instanceId===C?{...$,bypassed:m}:$)),S})},[]),u=c.useCallback(f=>{const C=n.current.get(f);C&&(C.forEach(y=>y.dispose()),C.clear()),t(y=>{const g=new Map(y);return g.set(f,[]),g})},[]),d=c.useRef(e);d.current=e;const b=c.useCallback(f=>(C,y,g)=>{r.current.set(f,{graphEnd:C,masterGainNode:y});const m=d.current.get(f)||[],w=n.current.get(f),x=m.map(v=>w?.get(v.instanceId)).filter(v=>v!==void 0);if(x.length===0)C.connect(y);else{let v=C;x.forEach(S=>{v.connect(S.effect),v=S.effect}),v.connect(y)}return function(){r.current.delete(f)}},[]);c.useEffect(()=>{e.forEach((f,C)=>{a(C,f)})},[e,a]),c.useEffect(()=>()=>{n.current.forEach(f=>{f.forEach(C=>C.dispose()),f.clear()}),n.current.clear()},[]);const p=c.useCallback(f=>{const y=(e.get(f)||[]).filter(g=>!g.bypassed);if(y.length!==0)return(g,m,w)=>{const x=[];for(const v of y){const S=_t(v.definition,v.params);x.push(S)}if(x.length===0)g.connect(m);else{let v=g;x.forEach(S=>{v.connect(S.effect),v=S.effect}),v.connect(m)}return function(){x.forEach(S=>S.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:l,toggleBypass:i,clearTrackEffects:u,getTrackEffectsFunction:b,createOfflineTrackEffectsFunction:p,availableEffects:Mt}}function Qi(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,a=e.sampleRate,s=e.length,o=n/8,l=r*o,i=a*l,u=s*l,d=44,b=d+u,p=new ArrayBuffer(b),f=new DataView(p);Lt(f,0,"RIFF"),f.setUint32(4,b-8,!0),Lt(f,8,"WAVE"),Lt(f,12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,n===32?3:1,!0),f.setUint16(22,r,!0),f.setUint32(24,a,!0),f.setUint32(28,i,!0),f.setUint16(32,l,!0),f.setUint16(34,n,!0),Lt(f,36,"data"),f.setUint32(40,u,!0);const C=[];for(let g=0;g<r;g++)C.push(e.getChannelData(g));let y=d;if(n===16)for(let g=0;g<s;g++)for(let m=0;m<r;m++){const w=C[m][g],x=Math.max(-1,Math.min(1,w)),v=x<0?x*32768:x*32767;f.setInt16(y,v,!0),y+=2}else for(let g=0;g<s;g++)for(let m=0;m<r;m++)f.setFloat32(y,C[m][g],!0),y+=4;return new Blob([p],{type:"audio/wav"})}function Lt(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function el(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}function da(){const[e,t]=c.useState(!1),[n,r]=c.useState(0),[a,s]=c.useState(null);return{exportWav:c.useCallback(async(l,i,u={})=>{const{filename:d="export",mode:b="master",trackIndex:p,autoDownload:f=!0,applyEffects:C=!0,effectsFunction:y,createOfflineTrackEffects:g,bitDepth:m=16,onProgress:w}=u;t(!0),r(0),s(null);try{if(l.length===0)throw new Error("No tracks to export");if(b==="individual"&&(p===void 0||p<0||p>=l.length))throw new Error("Invalid track index for individual export");const x=l[0].clips[0]?.sampleRate||44100;let v=0;for(const D of l)for(const V of D.clips){const W=V.startSample+V.durationSamples;v=Math.max(v,W)}v+=Math.round(x*.1);const S=v/x,I=b==="individual"?[{track:l[p],state:i[p],index:p}]:l.map((D,V)=>({track:D,state:i[V],index:V})),$=i.some(D=>D.soloed),M=!!g;let T;if((y||M)&&C)T=await tl(I,i,$,S,x,y,g,D=>{r(D),w?.(D)});else{const D=new OfflineAudioContext(2,v,x);let V=0;const W=I.reduce((O,{track:N})=>O+N.clips.length,0);for(const{track:O,state:N}of I)if(!(N.muted&&!N.soloed)&&!($&&!N.soloed))for(const Y of O.clips){await rl(D,Y,N,x,C),V++;const ee=V/W*.5;r(ee),w?.(ee)}r(.5),w?.(.5),T=await D.startRendering()}r(.9),w?.(.9);const _=Qi(T,{bitDepth:m});if(r(1),w?.(1),f){const D=b==="individual"?`${d}_${l[p].name}`:d;el(_,`${D}.wav`)}return{audioBuffer:T,blob:_,duration:S}}catch(x){const v=x instanceof Error?x.message:"Export failed";throw s(v),x}finally{t(!1)}},[]),isExporting:e,progress:n,error:a}}async function tl(e,t,n,r,a,s,o,l){const{Offline:i,Volume:u,Gain:d,Panner:b,Player:p,ToneAudioBuffer:f}=await import("tone");l(.1);let C;try{C=await i(async({transport:y,destination:g})=>{const m=new u(0);let w;s?w=s(m,g,!0):m.connect(g);for(const{track:x,state:v}of e){if(v.muted&&!v.soloed||n&&!v.soloed)continue;const S=new u(nl(v.volume)),I=new b(v.pan),$=new d(v.muted?0:1),M=o?.(x.id);M?M($,m,!0):$.connect(m),I.connect($),S.connect(I);for(const T of x.clips){const{audioBuffer:_,startSample:D,durationSamples:V,offsetSamples:W,gain:O,fadeIn:N,fadeOut:Y}=T,ee=D/a,re=V/a,X=W/a,oe=new f(_),A=new p(oe),j=new d(O);if(A.connect(j),j.connect(S),N){const H=ee,U=ee+N.duration,ge=j.gain._param;ge.setValueAtTime(0,H),ge.linearRampToValueAtTime(O,U)}if(Y){const H=ee+re-Y.duration,U=ee+re,ge=j.gain._param;ge.setValueAtTime(O,H),ge.linearRampToValueAtTime(0,U)}A.start(ee,X,re)}}y.start(0)},r,2,a)}catch(y){throw y instanceof Error?y:new Error(`Tone.Offline rendering failed: ${String(y)}`)}return l(.9),C.get()}function nl(e){return 20*Math.log10(Math.max(e,1e-4))}async function rl(e,t,n,r,a){const{audioBuffer:s,startSample:o,durationSamples:l,offsetSamples:i,gain:u,fadeIn:d,fadeOut:b}=t;if(!s){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const p=o/r,f=l/r,C=i/r,y=e.createBufferSource();y.buffer=s;const g=e.createGain(),m=u*n.volume,w=e.createStereoPanner();if(w.pan.value=n.pan,y.connect(g),g.connect(w),w.connect(e.destination),a){if(d?g.gain.setValueAtTime(0,p):g.gain.setValueAtTime(m,p),d){const x=p,v=p+d.duration;_r(g.gain,x,v,0,m,d.type||"linear")}if(b){const x=p+f-b.duration,v=p+f;(!d||d.duration<f-b.duration)&&g.gain.setValueAtTime(m,x),_r(g.gain,x,v,m,0,b.type||"linear")}}else g.gain.setValueAtTime(m,p);y.start(p,C,f)}function _r(e,t,n,r,a,s){const o=n-t;if(!(o<=0))switch(s){case"linear":e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n);break;case"exponential":const l=Math.max(r,1e-4),i=Math.max(a,1e-4);e.setValueAtTime(l,t),e.exponentialRampToValueAtTime(i,n),a===0&&e.setValueAtTime(0,n);break;case"logarithmic":const u=Mr(r,a,256,"logarithmic");e.setValueCurveAtTime(u,t,o);break;case"sCurve":const d=Mr(r,a,256,"sCurve");e.setValueCurveAtTime(d,t,o);break;default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n)}}function Mr(e,t,n,r){const a=new Float32Array(n),s=t-e;for(let o=0;o<n;o++){const l=o/(n-1);let i;r==="logarithmic"?s>0?i=Math.log10(1+l*9)/Math.log10(10):i=1-Math.log10(1+(1-l)*9)/Math.log10(10):i=l*l*(3-2*l),a[o]=e+s*i}return a}const fa=c.createContext(null),ma=c.createContext(null),ha=c.createContext(null),pa=c.createContext(null),ga=c.createContext(null),al=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:a=1024,zoomLevels:s,automaticScroll:o=!1,theme:l,controls:i={show:!1,width:0},annotationList:u,effects:d,onReady:b,onAnnotationUpdate:p,barWidth:f=1,barGap:C=0,progressBarWidth:y,children:g})=>{const m=y??f+C,[w,x]=c.useState([]),[v,S]=c.useState(null),[I,$]=c.useState(!1),[M,T]=c.useState(0),[_,D]=c.useState(0),[V,W]=c.useState([]),[O,N]=c.useState([]),[Y,ee]=c.useState([]),[re,X]=c.useState(0),[oe,A]=c.useState(0),[j,H]=c.useState(null),[U,ge]=c.useState(o),[Be,ie]=c.useState(u?.isContinuousPlay??!1),[Te,ue]=c.useState(u?.linkEndpoints??!0),[me,gt]=c.useState(u?.editable??!1),[dt,de]=c.useState(!1),[at,ot]=c.useState(0),[Je,st]=c.useState(0),z=c.useRef(null),Re=c.useRef(0),xe=c.useRef(0),be=c.useRef(null),Ze=c.useRef(Y),Xe=c.useRef(0),Pe=c.useRef(0),He=c.useRef(null),Ge=c.useRef(null),ft=c.useRef(!1),At=c.useRef(u?.isContinuousPlay??!1),K=c.useRef(null),te=c.useRef(a),he=c.useRef(!1),ye=c.useRef(0),Ee=c.useRef(0),Ae=c.useRef(0),le=c.useRef(0),{timeFormat:Ye,setTimeFormat:Ke,formatTime:ze}=ra(),_e=aa({initialSamplesPerPixel:a,zoomLevels:s}),Ie=_e.samplesPerPixel,{masterVolume:qe,setMasterVolume:mt}=oa({playoutRef:z,initialVolume:1}),Bt=c.useCallback(B=>{At.current=B,ie(B)},[]),it=c.useCallback(B=>{K.current=B,S(B)},[]),Ft=c.useCallback(B=>{he.current=B,de(B)},[]),ht=c.useCallback((B,L)=>{Ae.current=B,le.current=L,ot(B),st(L)},[]),Wt=c.useCallback(()=>{const B=ye.current,L=Ee.current;B!==L&&L>B&&ht(B,L)},[ht]),Zt=c.useCallback(()=>{ht(0,0)},[ht]);c.useEffect(()=>{ft.current=U},[U]),c.useEffect(()=>{Ze.current=Y},[Y]),c.useEffect(()=>{ye.current=re,Ee.current=oe},[re,oe]),c.useEffect(()=>{if(!Ge.current||!V.length)return;const B=Ge.current,L=te.current,q=Ie;if(L===q)return;const fe=i.show?i.width:0,G=B.clientWidth,Ue=B.scrollLeft+G/2-fe,Ce=V[0].sampleRate,Ve=Ue*L/Ce*Ce/q,tt=Math.max(0,Ve+fe-G/2);B.scrollLeft=tt,te.current=q},[Ie,V,i]);const bt=c.useRef(null);c.useEffect(()=>{if(e.length===0){W([]),D(0),ee([]),N([]),z.current&&(z.current.dispose(),z.current=null);return}const B=I,L=xe.current;return z.current&&B&&(z.current.stop(),be.current&&(cancelAnimationFrame(be.current),be.current=null),bt.current={position:L}),(async()=>{try{const fe=[];e.forEach(Ce=>{Ce.clips.length>0&&Ce.clips[0].audioBuffer&&fe.push(Ce.clips[0].audioBuffer)});let G=0;e.forEach(Ce=>{Ce.clips.forEach($e=>{const Ve=$e.sampleRate,Pt=($e.startSample+$e.durationSamples)/Ve;G=Math.max(G,Pt)})}),W(fe),D(G),ee(Ce=>Ce.length===e.length?Ce.map(($e,Ve)=>({...$e,name:e[Ve].name})):e.map($e=>({name:$e.name,muted:$e.muted,soloed:$e.soloed,volume:$e.volume,pan:$e.pan}))),z.current&&z.current.dispose();const Se=new Ba({effects:d}),Ue=Ze.current;e.forEach((Ce,$e)=>{const Ve=Ce.clips.filter(tt=>tt.audioBuffer);if(Ve.length>0){const tt=Ve[0].sampleRate,Pt=Math.min(...Ve.map(je=>je.startSample/tt)),ba=Math.max(...Ve.map(je=>(je.startSample+je.durationSamples)/tt)),Vt=Ue[$e],va={id:`track-${$e}`,name:Ce.name,gain:Vt?.volume??Ce.volume,muted:Vt?.muted??Ce.muted,soloed:Vt?.soloed??Ce.soloed,stereoPan:Vt?.pan??Ce.pan,startTime:Pt,endTime:ba},Ca=Ve.map(je=>{const ln=je.sampleRate;return{buffer:je.audioBuffer,startTime:je.startSample/ln-Pt,duration:je.durationSamples/ln,offset:je.offsetSamples/ln,fadeIn:je.fadeIn,fadeOut:je.fadeOut,gain:je.gain}});Se.addTrack({clips:Ca,track:va,effects:Ce.effects})}}),Se.applyInitialSoloState(),z.current=Se,b?.()}catch(fe){console.error("Error loading audio:",fe)}})(),()=>{be.current&&cancelAnimationFrame(be.current),z.current&&z.current.dispose()}},[e,b,I]),c.useEffect(()=>{if(e.length===0)return;const B=16,L=e.map(q=>q.clips.map(G=>{if(G.waveformData){const Ue=$s(G.waveformData,Ie,0,G.offsetSamples,G.durationSamples);return{clipId:G.id,trackName:q.name,peaks:{length:Ue.length,data:[Ue.data],bits:Ue.bits},startSample:G.startSample,durationSamples:G.durationSamples,fadeIn:G.fadeIn,fadeOut:G.fadeOut}}if(!G.audioBuffer)return console.warn(`Clip "${G.name||G.id}" has neither waveformData nor audioBuffer - rendering empty`),{clipId:G.id,trackName:q.name,peaks:{length:0,data:[],bits:B},startSample:G.startSample,durationSamples:G.durationSamples,fadeIn:G.fadeIn,fadeOut:G.fadeOut};const Se=ls(G.audioBuffer,Ie,n,B,G.offsetSamples,G.durationSamples);return{clipId:G.id,trackName:q.name,peaks:Se,startSample:G.startSample,durationSamples:G.durationSamples,fadeIn:G.fadeIn,fadeOut:G.fadeOut}}));N(L)},[e,Ie,n]),c.useEffect(()=>{if(u?.annotations){const B=u.annotations.map(L=>typeof L.start=="number"?L:Fs(L));x(B)}},[u]);const Qe=c.useCallback(()=>{be.current&&(cancelAnimationFrame(be.current),be.current=null);const B=()=>{const L=P.getContext().currentTime-Xe.current,q=Pe.current+L;if(xe.current=q,T(q),w.length>0){const G=w.find(Se=>q>=Se.start&&q<Se.end);if(At.current){if(G&&G.id!==K.current)it(G.id);else if(!G&&K.current!==null){const Se=w[w.length-1];if(q>=Se.end){z.current&&z.current.stop(),$(!1),xe.current=Re.current,T(Re.current),it(null);return}}}else if(K.current){const Se=w.find(Ue=>Ue.id===K.current);if(Se&&q>=Se.end){z.current&&z.current.stop(),$(!1),xe.current=Re.current,T(Re.current);return}}else G&&it(G.id)}if(ft.current&&Ge.current&&V.length>0){const G=Ge.current,Se=V[0].sampleRate,Ue=q*Se/te.current,Ce=G.clientWidth,$e=i.show?i.width:0,Ve=Ue+$e,tt=Math.max(0,Ve-Ce/2);G.scrollLeft=tt}if(He.current!==null&&q>=He.current){z.current&&z.current.stop(),$(!1),xe.current=He.current,T(He.current),He.current=null;return}const fe=Ae.current!==le.current&&le.current>Ae.current;if(he.current&&fe&&q>=le.current){z.current?.stop();const Se=P.getContext().currentTime;Xe.current=Se,Pe.current=Ae.current,xe.current=Ae.current,z.current?.play(Se,Ae.current),be.current=requestAnimationFrame(B);return}if(q>=_){z.current&&z.current.stop(),$(!1),xe.current=Re.current,T(Re.current),it(null);return}be.current=requestAnimationFrame(B)};be.current=requestAnimationFrame(B)},[_,V,Ie,w,Be]),Fe=c.useCallback(()=>{be.current&&(cancelAnimationFrame(be.current),be.current=null)},[]);c.useEffect(()=>{(async()=>{if(I&&be.current&&z.current)if(Be){const L=xe.current;z.current.stop(),Fe(),await z.current.init(),z.current.setOnPlaybackComplete(()=>{});const fe=P.getContext().currentTime;Xe.current=fe,Pe.current=L,z.current.play(fe,L),Qe()}else Fe(),Qe()})()},[Be,I,Qe,Fe]),c.useEffect(()=>{(async()=>{if(bt.current&&z.current){const{position:L}=bt.current;bt.current=null,await z.current.init(),z.current.setOnPlaybackComplete(()=>{});const fe=P.getContext().currentTime;Xe.current=fe,Pe.current=L,z.current.play(fe,L),$(!0),Qe()}})()},[e,Qe]);const vt=c.useCallback(async(B,L)=>{if(!z.current||V.length===0)return;await z.current.init(),await P.start();const q=B??xe.current;Re.current=q,xe.current=q,z.current.setOnPlaybackComplete(()=>{}),z.current.stop(),Fe();const G=P.getContext().currentTime;Xe.current=G,Pe.current=q,He.current=L!==void 0?q+L:null,z.current.play(G,q,L),$(!0),Qe()},[V.length,Qe,Fe]),rn=c.useCallback(()=>{if(!z.current)return;const B=P.getContext().currentTime-Xe.current,L=Pe.current+B;z.current.pause(),$(!1),Fe(),xe.current=L,T(L)},[Fe]),an=c.useCallback(()=>{z.current&&(z.current.stop(),$(!1),Fe(),xe.current=Re.current,T(Re.current),it(null))},[Fe]),on=c.useCallback(B=>{const L=Math.max(0,Math.min(B,_));xe.current=L,T(L),I&&z.current&&(z.current.stop(),Fe(),vt(L))},[_,I,vt,Fe]),sn=c.useCallback((B,L)=>{const q=[...Y];if(q[B]={...q[B],muted:L},ee(q),z.current){const fe=`track-${B}`;z.current.setMute(fe,L)}},[Y]),h=c.useCallback((B,L)=>{const q=[...Y];if(q[B]={...q[B],soloed:L},ee(q),z.current){const fe=`track-${B}`;z.current.setSolo(fe,L)}},[Y]),R=c.useCallback((B,L)=>{const q=[...Y];if(q[B]={...q[B],volume:L},ee(q),z.current){const fe=`track-${B}`,G=z.current.getTrack(fe);G&&G.setVolume(L)}},[Y]),F=c.useCallback((B,L)=>{const q=[...Y];if(q[B]={...q[B],pan:L},ee(q),z.current){const fe=`track-${B}`,G=z.current.getTrack(fe);G&&G.setPan(L)}},[Y]),J=c.useCallback((B,L)=>{X(B),A(L),xe.current=B,T(B),I&&z.current&&(z.current.stop(),z.current.play(P.getContext().currentTime,B))},[I]),se=c.useCallback(B=>{Ge.current=B},[]),ce=V[0]?.sampleRate||44100,ae=t?30:0,ne=e.length*r+ae,ke={isPlaying:I,currentTime:M,currentTimeRef:xe,playbackStartTimeRef:Xe,audioStartPositionRef:Pe},pe={continuousPlay:Be,linkEndpoints:Te,annotationsEditable:me,isAutomaticScroll:U,isLoopEnabled:dt,annotations:w,activeAnnotationId:v,selectionStart:re,selectionEnd:oe,selectedTrackId:j,loopStart:at,loopEnd:Je},ve={play:vt,pause:rn,stop:an,seekTo:on,setCurrentTime:B=>{xe.current=B,T(B)},setTrackMute:sn,setTrackSolo:h,setTrackVolume:R,setTrackPan:F,setSelection:J,setSelectedTrackId:H,setTimeFormat:Ke,formatTime:ze,zoomIn:_e.zoomIn,zoomOut:_e.zoomOut,setMasterVolume:mt,setAutomaticScroll:B=>{ge(B)},setScrollContainer:se,scrollContainerRef:Ge,setContinuousPlay:Bt,setLinkEndpoints:ue,setAnnotationsEditable:gt,setAnnotations:x,setActiveAnnotationId:it,setLoopEnabled:Ft,setLoopRegion:ht,setLoopRegionFromSelection:Wt,clearLoopRegion:Zt},Me={duration:_,audioBuffers:V,peaksDataArray:O,trackStates:Y,tracks:e,sampleRate:ce,waveHeight:r,timeScaleHeight:ae,minimumPlaylistHeight:ne,controls:i,playoutRef:z,samplesPerPixel:Ie,timeFormat:Ye,masterVolume:qe,canZoomIn:_e.canZoomIn,canZoomOut:_e.canZoomOut,barWidth:f,barGap:C,progressBarWidth:m},lt={...ke,...pe,...ve,...Me},et={...Qa,...l};return Z.jsx(k.ThemeProvider,{theme:et,children:Z.jsx(fa.Provider,{value:ke,children:Z.jsx(ma.Provider,{value:pe,children:Z.jsx(ha.Provider,{value:ve,children:Z.jsx(pa.Provider,{value:Me,children:Z.jsx(ga.Provider,{value:lt,children:g})})})})})})},We=()=>{const e=c.useContext(fa);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Le=()=>{const e=c.useContext(ma);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},we=()=>{const e=c.useContext(ha);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},De=()=>{const e=c.useContext(pa);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e},ol=()=>{const e=c.useContext(ga);if(!e)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return e},sl=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=We(),{selectionStart:r,selectionEnd:a,isLoopEnabled:s}=Le(),{play:o}=we(),l=async()=>{if(r!==a&&a>r)if(s)await o(r);else{const u=a-r;await o(r,u)}else await o(n.current??0)};return Z.jsx(Ne,{onClick:l,disabled:t,className:e,children:"Play"})},il=({className:e})=>{const{isPlaying:t}=We(),{pause:n}=we();return Z.jsx(Ne,{onClick:n,disabled:!t,className:e,children:"Pause"})},ll=({className:e})=>{const{isPlaying:t}=We(),{stop:n}=we();return Z.jsx(Ne,{onClick:n,disabled:!t,className:e,children:"Stop"})},cl=({className:e})=>{const{isPlaying:t}=We(),{play:n,setCurrentTime:r}=we(),{playoutRef:a}=De(),s=()=>{r(0),t&&a.current&&(a.current.stop(),n(0))};return Z.jsx(Ne,{onClick:s,className:e,children:"Rewind"})},ul=({className:e})=>{const{isPlaying:t}=We(),{play:n,setCurrentTime:r}=we(),{duration:a,playoutRef:s}=De(),o=()=>{r(a),t&&s.current&&(s.current.stop(),n(a))};return Z.jsx(Ne,{onClick:o,className:e,children:"Fast Forward"})},dl=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=We(),{play:a,setCurrentTime:s}=we(),{playoutRef:o}=De(),l=()=>{const i=Math.max(0,(n.current??0)-e);s(i),r&&o.current&&(o.current.stop(),a(i))};return Z.jsx(Ne,{onClick:l,className:t,children:"Skip Backward"})},fl=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=We(),{play:a,setCurrentTime:s}=we(),{duration:o,playoutRef:l}=De(),i=()=>{const u=Math.min(o,(n.current??0)+e);s(u),r&&l.current&&(l.current.stop(),a(u))};return Z.jsx(Ne,{onClick:i,className:t,children:"Skip Forward"})},ml=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=Le(),{setLoopEnabled:a,setLoopRegion:s}=we(),{duration:o}=De(),l=n!==r&&r>n,i=()=>{if(!t&&!l){const u=Math.min(10,o*.25);s(0,Math.max(1,u))}a(!t)};return Z.jsx(Ne,{onClick:i,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},hl=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:a}=Le(),{setLoopRegionFromSelection:s,clearLoopRegion:o}=we(),l=t!==n&&n>t,i=r!==a&&a>r,u=()=>{i?o():s()};return Z.jsx(Ne,{onClick:u,disabled:!l&&!i,className:e,title:i?"Clear loop region":l?"Set loop region from selection":"Create a selection first",children:i?"Clear Loop":"Set Loop"})},pl=({className:e,disabled:t})=>{const{zoomIn:n}=we(),{canZoomIn:r}=De();return Z.jsx(Ne,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},gl=({className:e,disabled:t})=>{const{zoomOut:n}=we(),{canZoomOut:r}=De();return Z.jsx(Ne,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},bl=({className:e})=>{const{masterVolume:t}=De(),{setMasterVolume:n}=we();return Z.jsx(Co,{volume:t,onChange:n,className:e})},vl=({className:e})=>{const{timeFormat:t}=De(),{setTimeFormat:n}=we();return Z.jsx(Ko,{value:t,onChange:n,className:e})},Cl=k.span`
1193
+ `,os=({level:e,peakLevel:t,width:n=200,height:a=20,className:r})=>{const s=Math.max(0,Math.min(1,e)),o=t!==void 0?Math.max(0,Math.min(1,t)):0;return b.jsxs(es,{$width:n,$height:a,className:r,children:[b.jsx(ns,{$level:s,$height:a}),t!==void 0&&o>0&&b.jsx(as,{$peakLevel:o,$height:a}),b.jsxs(rs,{$height:a,children:[b.jsx(mn,{$position:60,$height:a}),b.jsx(mn,{$position:85,$height:a})]})]})};i.memo(os);function ss(e,t,n,a={}){const{currentTime:r=0,audioConstraints:s,...o}=a,[l,c]=i.useState(!1),[u,d]=i.useState(null),{stream:v,devices:p,hasPermission:f,requestAccess:C,error:y}=qo(),{level:m,peakLevel:g}=Qo(v),{isRecording:I,isPaused:x,duration:h,peaks:w,startRecording:k,stopRecording:A,pauseRecording:M,resumeRecording:$,error:E}=Jo(v,o),R=i.useCallback(async()=>{n&&(l||(await Tt(),c(!0)),await k())},[n,l,k]),T=i.useCallback(async()=>{const V=await A();if(V&&n){const _=e.findIndex(q=>q.id===n);if(_===-1)return;const L=e[_],X=Math.floor(r*V.sampleRate);let F=0;if(L.clips.length>0){const q=L.clips.map(ne=>ne.startSample+ne.durationSamples);F=Math.max(...q)}const K=Math.max(X,F),ae={id:`clip-${Date.now()}`,audioBuffer:V,startSample:K,durationSamples:V.length,offsetSamples:0,sampleRate:V.sampleRate,sourceDurationSamples:V.length,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},te=e.map((q,ne)=>ne===_?{...q,clips:[...q.clips,ae]}:q);t(te)}},[n,e,t,r,A]);i.useEffect(()=>{f&&p.length>0&&u===null&&d(p[0].deviceId)},[f,p.length]);const D=i.useCallback(async()=>{await C(void 0,s),await Tt(),c(!0)},[C,s]),z=i.useCallback(async V=>{d(V),await C(V,s),await Tt(),c(!0)},[C,s]);return{isRecording:I,isPaused:x,duration:h,level:m,peakLevel:g,error:y||E,stream:v,devices:p,hasPermission:f,selectedDevice:u,startRecording:R,stopRecording:T,pauseRecording:M,resumeRecording:$,requestMicAccess:D,changeDevice:z,recordingPeaks:w}}const dt=[{id:"reverb",name:"Reverb",category:"reverb",description:"Simple convolution reverb with adjustable decay time",parameters:[{name:"decay",label:"Decay",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"s"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"freeverb",name:"Freeverb",category:"reverb",description:"Classic Schroeder/Moorer reverb with room size and dampening",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.7},{name:"dampening",label:"Dampening",type:"number",min:0,max:1e4,step:100,default:3e3,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"jcReverb",name:"JC Reverb",category:"reverb",description:"Attempt at Roland JC-120 chorus reverb emulation",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"feedbackDelay",name:"Feedback Delay",category:"delay",description:"Delay line with feedback for echo effects",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"pingPongDelay",name:"Ping Pong Delay",category:"delay",description:"Stereo delay bouncing between left and right channels",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"chorus",name:"Chorus",category:"modulation",description:"Creates thickness by layering detuned copies of the signal",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"Hz"},{name:"delayTime",label:"Delay",type:"number",min:0,max:20,step:.5,default:3.5,unit:"ms"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.7},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"phaser",name:"Phaser",category:"modulation",description:"Classic phaser effect using allpass filters",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:.5,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:6,step:1,default:3},{name:"baseFrequency",label:"Base Freq",type:"number",min:100,max:2e3,step:10,default:350,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"tremolo",name:"Tremolo",category:"modulation",description:"Rhythmic volume modulation",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:4,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"vibrato",name:"Vibrato",category:"modulation",description:"Pitch modulation effect",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:5,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoPanner",name:"Auto Panner",category:"modulation",description:"Automatic left-right panning",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoFilter",name:"Auto Filter",category:"filter",description:"Automated filter sweep with LFO",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:2e3,step:10,default:200,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:.5,max:8,step:.5,default:2.6},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoWah",name:"Auto Wah",category:"filter",description:"Envelope follower filter effect",parameters:[{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:500,step:10,default:100,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:8,step:1,default:6},{name:"sensitivity",label:"Sensitivity",type:"number",min:-40,max:0,step:1,default:0,unit:"dB"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"eq3",name:"3-Band EQ",category:"filter",description:"Three band equalizer with low, mid, and high controls",parameters:[{name:"low",label:"Low",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"mid",label:"Mid",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"high",label:"High",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"lowFrequency",label:"Low Freq",type:"number",min:20,max:500,step:10,default:400,unit:"Hz"},{name:"highFrequency",label:"High Freq",type:"number",min:1e3,max:1e4,step:100,default:2500,unit:"Hz"}]},{id:"distortion",name:"Distortion",category:"distortion",description:"Wave shaping distortion effect",parameters:[{name:"distortion",label:"Drive",type:"number",min:0,max:1,step:.01,default:.4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"bitCrusher",name:"Bit Crusher",category:"distortion",description:"Reduces bit depth for lo-fi digital texture",parameters:[{name:"bits",label:"Bits",type:"number",min:1,max:16,step:1,default:4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"chebyshev",name:"Chebyshev",category:"distortion",description:"Waveshaping distortion using Chebyshev polynomials",parameters:[{name:"order",label:"Order",type:"number",min:1,max:100,step:1,default:50},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"compressor",name:"Compressor",category:"dynamics",description:"Dynamic range compressor",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-60,max:0,step:1,default:-24,unit:"dB"},{name:"ratio",label:"Ratio",type:"number",min:1,max:20,step:.5,default:4},{name:"attack",label:"Attack",type:"number",min:0,max:1,step:.001,default:.003,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"knee",label:"Knee",type:"number",min:0,max:40,step:1,default:30,unit:"dB"}]},{id:"limiter",name:"Limiter",category:"dynamics",description:"Hard limiter to prevent clipping",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-12,max:0,step:.5,default:-6,unit:"dB"}]},{id:"gate",name:"Gate",category:"dynamics",description:"Noise gate to silence signal below threshold",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-100,max:0,step:1,default:-40,unit:"dB"},{name:"attack",label:"Attack",type:"number",min:0,max:.3,step:.001,default:.001,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:.5,step:.01,default:.1,unit:"s"}]},{id:"stereoWidener",name:"Stereo Widener",category:"spatial",description:"Expands or narrows the stereo image",parameters:[{name:"width",label:"Width",type:"number",min:0,max:1,step:.01,default:.5}]}],Nt=e=>dt.find(t=>t.id===e),is=e=>dt.filter(t=>t.category===e),ls=[{id:"reverb",name:"Reverb"},{id:"delay",name:"Delay"},{id:"modulation",name:"Modulation"},{id:"filter",name:"Filter"},{id:"distortion",name:"Distortion"},{id:"dynamics",name:"Dynamics"},{id:"spatial",name:"Spatial"}],cs={reverb:W.Reverb,freeverb:W.Freeverb,jcReverb:W.JCReverb,feedbackDelay:W.FeedbackDelay,pingPongDelay:W.PingPongDelay,chorus:W.Chorus,phaser:W.Phaser,tremolo:W.Tremolo,vibrato:W.Vibrato,autoPanner:W.AutoPanner,autoFilter:W.AutoFilter,autoWah:W.AutoWah,eq3:W.EQ3,distortion:W.Distortion,bitCrusher:W.BitCrusher,chebyshev:W.Chebyshev,compressor:W.Compressor,limiter:W.Limiter,gate:W.Gate,stereoWidener:W.StereoWidener};let us=0;const ds=()=>`effect_${Date.now()}_${++us}`;function lt(e,t){const n=cs[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const a={};e.parameters.forEach(o=>{const l=t?.[o.name]??o.default;a[o.name]=l});const r=new n(a),s=ds();return{effect:r,id:e.id,instanceId:s,dispose(){try{r.disconnect(),r.dispose()}catch{}},setParameter(o,l){o==="wet"&&r.wet?r.wet.value=l:r[o]!==void 0&&(r[o]?.value!==void 0?r[o].value=l:r[o]=l)},getParameter(o){if(o==="wet"&&r.wet)return r.wet.value;if(r[o]!==void 0)return r[o]?.value!==void 0?r[o].value:r[o]},connect(o){r.connect(o)},disconnect(){try{r.disconnect()}catch{}}}}function fs(e){if(e.length===0)throw new Error("Cannot create effect chain with no effects");for(let t=0;t<e.length-1;t++)e[t].effect.connect(e[t+1].effect);return{input:e[0].effect,output:e[e.length-1].effect,dispose(){e.forEach(t=>t.dispose())}}}function ms(e=256){const[t,n]=i.useState([]),a=i.useRef(t);a.current=t;const r=i.useRef(new Map),s=i.useRef(null),o=i.useRef(null),l=i.useCallback(m=>{const g=o.current;if(!g)return;const{masterGainNode:I,destination:x,analyserNode:h}=g;try{I.disconnect()}catch{}const w=m.map(k=>r.current.get(k.instanceId)).filter(k=>k!==void 0);if(w.length===0)I.connect(h),h.connect(x);else{let k=I;w.forEach(A=>{try{A.disconnect()}catch{}k.connect(A.effect),k=A.effect}),k.connect(h),h.connect(x)}},[]),c=i.useCallback(m=>{const g=Nt(m);if(!g){console.error(`Unknown effect: ${m}`);return}const I={};g.parameters.forEach(w=>{I[w.name]=w.default});const x=lt(g,I);r.current.set(x.instanceId,x);const h={instanceId:x.instanceId,effectId:g.id,definition:g,params:I,bypassed:!1};n(w=>[...w,h])},[]),u=i.useCallback(m=>{const g=r.current.get(m);g&&(g.dispose(),r.current.delete(m)),n(I=>I.filter(x=>x.instanceId!==m))},[]),d=i.useCallback((m,g,I)=>{const x=r.current.get(m);x&&x.setParameter(g,I),n(h=>h.map(w=>w.instanceId===m?{...w,params:{...w.params,[g]:I}}:w))},[]),v=i.useCallback(m=>{const g=a.current.find(h=>h.instanceId===m);if(!g)return;const I=!g.bypassed,x=r.current.get(m);if(x){const h=g.params.wet??1;x.setParameter("wet",I?0:h)}n(h=>h.map(w=>w.instanceId===m?{...w,bypassed:I}:w))},[]),p=i.useCallback((m,g)=>{n(I=>{const x=[...I],[h]=x.splice(m,1);return x.splice(g,0,h),x})},[]),f=i.useCallback(()=>{r.current.forEach(m=>m.dispose()),r.current.clear(),n([])},[]);i.useEffect(()=>{l(t)},[t,l]);const C=i.useCallback((m,g,I)=>{const x=new W.Analyser("fft",e);s.current=x,o.current={masterGainNode:m,destination:g,analyserNode:x};const w=a.current.map(k=>r.current.get(k.instanceId)).filter(k=>k!==void 0);if(w.length===0)m.connect(x),x.connect(g);else{let k=m;w.forEach(A=>{k.connect(A.effect),k=A.effect}),k.connect(x),x.connect(g)}return function(){x.dispose(),s.current=null,o.current=null}},[e]);i.useEffect(()=>()=>{r.current.forEach(m=>m.dispose()),r.current.clear()},[]);const y=i.useCallback(()=>{const m=t.filter(g=>!g.bypassed);if(m.length!==0)return(g,I,x)=>{const h=[];for(const w of m){const k=lt(w.definition,w.params);h.push(k)}if(h.length===0)g.connect(I);else{let w=g;h.forEach(k=>{w.connect(k.effect),w=k.effect}),w.connect(I)}return function(){h.forEach(k=>k.dispose())}}},[t]);return{activeEffects:t,availableEffects:dt,addEffect:c,removeEffect:u,updateParameter:d,toggleBypass:v,reorderEffects:p,clearAllEffects:f,masterEffects:C,createOfflineEffectsFunction:y,analyserRef:s}}function hs(){const[e,t]=i.useState(new Map),n=i.useRef(new Map),a=i.useRef(new Map),r=i.useCallback((f,C)=>{const y=a.current.get(f);if(!y)return;const{graphEnd:m,masterGainNode:g}=y,I=n.current.get(f);try{m.disconnect()}catch{}const x=C.map(h=>I?.get(h.instanceId)).filter(h=>h!==void 0);if(x.length===0)m.connect(g);else{let h=m;x.forEach(w=>{try{w.disconnect()}catch{}h.connect(w.effect),h=w.effect}),h.connect(g)}},[]),s=i.useCallback((f,C)=>{const y=Nt(C);if(!y){console.error(`Unknown effect: ${C}`);return}const m={};y.parameters.forEach(x=>{m[x.name]=x.default});const g=lt(y,m);n.current.has(f)||n.current.set(f,new Map),n.current.get(f).set(g.instanceId,g);const I={instanceId:g.instanceId,effectId:y.id,definition:y,params:m,bypassed:!1};t(x=>{const h=new Map(x),w=h.get(f)||[];return h.set(f,[...w,I]),h})},[]),o=i.useCallback((f,C)=>{const y=n.current.get(f),m=y?.get(C);m&&(m.dispose(),y?.delete(C)),t(g=>{const I=new Map(g),x=I.get(f)||[];return I.set(f,x.filter(h=>h.instanceId!==C)),I})},[]),l=i.useCallback((f,C,y,m)=>{const I=n.current.get(f)?.get(C);I&&I.setParameter(y,m),t(x=>{const h=new Map(x),w=h.get(f)||[];return h.set(f,w.map(k=>k.instanceId===C?{...k,params:{...k.params,[y]:m}}:k)),h})},[]),c=i.useCallback((f,C)=>{const m=(d.current.get(f)||[]).find(h=>h.instanceId===C);if(!m)return;const g=!m.bypassed,x=n.current.get(f)?.get(C);if(x){const h=m.params.wet??1;x.setParameter("wet",g?0:h)}t(h=>{const w=new Map(h),k=w.get(f)||[];return w.set(f,k.map(A=>A.instanceId===C?{...A,bypassed:g}:A)),w})},[]),u=i.useCallback(f=>{const C=n.current.get(f);C&&(C.forEach(y=>y.dispose()),C.clear()),t(y=>{const m=new Map(y);return m.set(f,[]),m})},[]),d=i.useRef(e);d.current=e;const v=i.useCallback(f=>(C,y,m)=>{a.current.set(f,{graphEnd:C,masterGainNode:y});const g=d.current.get(f)||[],I=n.current.get(f),x=g.map(h=>I?.get(h.instanceId)).filter(h=>h!==void 0);if(x.length===0)C.connect(y);else{let h=C;x.forEach(w=>{h.connect(w.effect),h=w.effect}),h.connect(y)}return function(){a.current.delete(f)}},[]);i.useEffect(()=>{e.forEach((f,C)=>{r(C,f)})},[e,r]),i.useEffect(()=>()=>{n.current.forEach(f=>{f.forEach(C=>C.dispose()),f.clear()}),n.current.clear()},[]);const p=i.useCallback(f=>{const y=(e.get(f)||[]).filter(m=>!m.bypassed);if(y.length!==0)return(m,g,I)=>{const x=[];for(const h of y){const w=lt(h.definition,h.params);x.push(w)}if(x.length===0)m.connect(g);else{let h=m;x.forEach(w=>{h.connect(w.effect),h=w.effect}),h.connect(g)}return function(){x.forEach(w=>w.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:l,toggleBypass:c,clearTrackEffects:u,getTrackEffectsFunction:v,createOfflineTrackEffectsFunction:p,availableEffects:dt}}function ps(e,t={}){const{bitDepth:n=16}=t,a=e.numberOfChannels,r=e.sampleRate,s=e.length,o=n/8,l=a*o,c=r*l,u=s*l,d=44,v=d+u,p=new ArrayBuffer(v),f=new DataView(p);bt(f,0,"RIFF"),f.setUint32(4,v-8,!0),bt(f,8,"WAVE"),bt(f,12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,n===32?3:1,!0),f.setUint16(22,a,!0),f.setUint32(24,r,!0),f.setUint32(28,c,!0),f.setUint16(32,l,!0),f.setUint16(34,n,!0),bt(f,36,"data"),f.setUint32(40,u,!0);const C=[];for(let m=0;m<a;m++)C.push(e.getChannelData(m));let y=d;if(n===16)for(let m=0;m<s;m++)for(let g=0;g<a;g++){const I=C[g][m],x=Math.max(-1,Math.min(1,I)),h=x<0?x*32768:x*32767;f.setInt16(y,h,!0),y+=2}else for(let m=0;m<s;m++)for(let g=0;g<a;g++)f.setFloat32(y,C[g][m],!0),y+=4;return new Blob([p],{type:"audio/wav"})}function bt(e,t,n){for(let a=0;a<n.length;a++)e.setUint8(t+a,n.charCodeAt(a))}function gs(e,t){const n=URL.createObjectURL(e),a=document.createElement("a");a.href=n,a.download=t,a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)}function Jn(){const[e,t]=i.useState(!1),[n,a]=i.useState(0),[r,s]=i.useState(null);return{exportWav:i.useCallback(async(l,c,u={})=>{const{filename:d="export",mode:v="master",trackIndex:p,autoDownload:f=!0,applyEffects:C=!0,effectsFunction:y,createOfflineTrackEffects:m,bitDepth:g=16,onProgress:I}=u;t(!0),a(0),s(null);try{if(l.length===0)throw new Error("No tracks to export");if(v==="individual"&&(p===void 0||p<0||p>=l.length))throw new Error("Invalid track index for individual export");const x=l[0].clips[0]?.sampleRate||44100;let h=0;for(const R of l)for(const T of R.clips){const D=T.startSample+T.durationSamples;h=Math.max(h,D)}h+=Math.round(x*.1);const w=h/x,k=v==="individual"?[{track:l[p],state:c[p],index:p}]:l.map((R,T)=>({track:R,state:c[T],index:T})),A=c.some(R=>R.soloed),M=!!m;let $;if((y||M)&&C)$=await bs(k,c,A,w,x,y,m,R=>{a(R),I?.(R)});else{const R=new OfflineAudioContext(2,h,x);let T=0;const D=k.reduce((z,{track:V})=>z+V.clips.length,0);for(const{track:z,state:V}of k)if(!(V.muted&&!V.soloed)&&!(A&&!V.soloed))for(const _ of z.clips){await Cs(R,_,V,x,C),T++;const L=T/D*.5;a(L),I?.(L)}a(.5),I?.(.5),$=await R.startRendering()}a(.9),I?.(.9);const E=ps($,{bitDepth:g});if(a(1),I?.(1),f){const R=v==="individual"?`${d}_${l[p].name}`:d;gs(E,`${R}.wav`)}return{audioBuffer:$,blob:E,duration:w}}catch(x){const h=x instanceof Error?x.message:"Export failed";throw s(h),x}finally{t(!1)}},[]),isExporting:e,progress:n,error:r}}async function bs(e,t,n,a,r,s,o,l){const{Offline:c,Volume:u,Gain:d,Panner:v,Player:p,ToneAudioBuffer:f}=await import("tone");l(.1);let C;try{C=await c(async({transport:y,destination:m})=>{const g=new u(0);let I;s?I=s(g,m,!0):g.connect(m);for(const{track:x,state:h}of e){if(h.muted&&!h.soloed||n&&!h.soloed)continue;const w=new u(vs(h.volume)),k=new v(h.pan),A=new d(h.muted?0:1),M=o?.(x.id);M?M(A,g,!0):A.connect(g),k.connect(A),w.connect(k);for(const $ of x.clips){const{audioBuffer:E,startSample:R,durationSamples:T,offsetSamples:D,gain:z,fadeIn:V,fadeOut:_}=$,L=R/r,X=T/r,F=D/r,K=new f(E),ae=new p(K),te=new d(z);if(ae.connect(te),te.connect(w),V){const q=L,ne=L+V.duration,be=te.gain._param;be.setValueAtTime(0,q),be.linearRampToValueAtTime(z,ne)}if(_){const q=L+X-_.duration,ne=L+X,be=te.gain._param;be.setValueAtTime(z,q),be.linearRampToValueAtTime(0,ne)}ae.start(L,F,X)}}y.start(0)},a,2,r)}catch(y){throw y instanceof Error?y:new Error(`Tone.Offline rendering failed: ${String(y)}`)}return l(.9),C.get()}function vs(e){return 20*Math.log10(Math.max(e,1e-4))}async function Cs(e,t,n,a,r){const{audioBuffer:s,startSample:o,durationSamples:l,offsetSamples:c,gain:u,fadeIn:d,fadeOut:v}=t;if(!s){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const p=o/a,f=l/a,C=c/a,y=e.createBufferSource();y.buffer=s;const m=e.createGain(),g=u*n.volume,I=e.createStereoPanner();if(I.pan.value=n.pan,y.connect(m),m.connect(I),I.connect(e.destination),r){if(d?m.gain.setValueAtTime(0,p):m.gain.setValueAtTime(g,p),d){const x=p,h=p+d.duration;hn(m.gain,x,h,0,g,d.type||"linear")}if(v){const x=p+f-v.duration,h=p+f;(!d||d.duration<f-v.duration)&&m.gain.setValueAtTime(g,x),hn(m.gain,x,h,g,0,v.type||"linear")}}else m.gain.setValueAtTime(g,p);y.start(p,C,f)}function hn(e,t,n,a,r,s){const o=n-t;if(!(o<=0))switch(s){case"linear":e.setValueAtTime(a,t),e.linearRampToValueAtTime(r,n);break;case"exponential":const l=Math.max(a,1e-4),c=Math.max(r,1e-4);e.setValueAtTime(l,t),e.exponentialRampToValueAtTime(c,n),r===0&&e.setValueAtTime(0,n);break;case"logarithmic":const u=pn(a,r,256,"logarithmic");e.setValueCurveAtTime(u,t,o);break;case"sCurve":const d=pn(a,r,256,"sCurve");e.setValueCurveAtTime(d,t,o);break;default:e.setValueAtTime(a,t),e.linearRampToValueAtTime(r,n)}}function pn(e,t,n,a){const r=new Float32Array(n),s=t-e;for(let o=0;o<n;o++){const l=o/(n-1);let c;a==="logarithmic"?s>0?c=Math.log10(1+l*9)/Math.log10(10):c=1-Math.log10(1+(1-l)*9)/Math.log10(10):c=l*l*(3-2*l),r[o]=e+s*c}return r}const qn=i.createContext(null),Qn=i.createContext(null),ea=i.createContext(null),ta=i.createContext(null),na=i.createContext(null),xs=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:a=80,samplesPerPixel:r=1024,zoomLevels:s,automaticScroll:o=!1,theme:l,controls:c={show:!1,width:0},annotationList:u,effects:d,onReady:v,onAnnotationUpdate:p,barWidth:f=1,barGap:C=0,progressBarWidth:y,children:m})=>{const g=y??f+C,[I,x]=i.useState([]),[h,w]=i.useState(null),[k,A]=i.useState(!1),[M,$]=i.useState(0),[E,R]=i.useState(0),[T,D]=i.useState([]),[z,V]=i.useState([]),[_,L]=i.useState([]),[X,F]=i.useState(0),[K,ae]=i.useState(0),[te,q]=i.useState(null),[ne,be]=i.useState(o),[he,Xe]=i.useState(u?.isContinuousPlay??!1),[je,ye]=i.useState(u?.linkEndpoints??!0),[Ge,Y]=i.useState(u?.editable??!1),[le,Q]=i.useState(!1),[J,ce]=i.useState(0),[ve,ee]=i.useState(0),[Ve,He]=i.useState(!1),Z=i.useRef(null),We=i.useRef(0),ue=i.useRef(0),j=i.useRef(null),re=i.useRef(_),de=i.useRef(0),fe=i.useRef(0),xe=i.useRef(null),Pe=i.useRef(null),Ne=i.useRef(!1),qe=i.useRef(u?.isContinuousPlay??!1),Oe=i.useRef(null),at=i.useRef(r),Mt=i.useRef(!1),G=i.useRef(0),U=i.useRef(0),oe=i.useRef(0),pe=i.useRef(0),{timeFormat:Ie,setTimeFormat:_e,formatTime:se}=Ln(),$e=Yn({initialSamplesPerPixel:r,zoomLevels:s}),Se=$e.samplesPerPixel,{masterVolume:Le,setMasterVolume:Ye}=On({playoutRef:Z,initialVolume:1}),Qe=i.useCallback(B=>{qe.current=B,Xe(B)},[]),ze=i.useCallback(B=>{Oe.current=B,w(B)},[]),Rt=i.useCallback(B=>{Mt.current=B,Q(B)},[]),rt=i.useCallback((B,H)=>{oe.current=B,pe.current=H,ce(B),ee(H)},[]),ca=i.useCallback(()=>{const B=G.current,H=U.current;B!==H&&H>B&&rt(B,H)},[rt]),ua=i.useCallback(()=>{rt(0,0)},[rt]);i.useEffect(()=>{Ne.current=ne},[ne]),i.useEffect(()=>{re.current=_},[_]),i.useEffect(()=>{G.current=X,U.current=K},[X,K]),i.useEffect(()=>{if(!Pe.current||!T.length)return;const B=Pe.current,H=at.current,O=Se;if(H===O)return;const ie=c.show?c.width:0,P=B.clientWidth,Ze=B.scrollLeft+P/2-ie,et=T[0].sampleRate,Ce=Ze*H/et*et/O,Me=Math.max(0,Ce+ie-P/2);B.scrollLeft=Me,at.current=O},[Se,T,c]);const ft=i.useRef(null);i.useEffect(()=>{if(He(!1),e.length===0){D([]),R(0),L([]),V([]),Z.current&&(Z.current.dispose(),Z.current=null);return}const B=k,H=ue.current;return Z.current&&B&&(Z.current.stop(),j.current&&(cancelAnimationFrame(j.current),j.current=null),ft.current={position:H}),(async()=>{try{const ie=[];e.forEach(ge=>{ge.clips.length>0&&ge.clips[0].audioBuffer&&ie.push(ge.clips[0].audioBuffer)});let P=0;e.forEach(ge=>{ge.clips.forEach(Ce=>{const Me=Ce.sampleRate,mt=(Ce.startSample+Ce.durationSamples)/Me;P=Math.max(P,mt)})}),D(ie),R(P),L(ge=>ge.length===e.length?ge.map((Ce,Me)=>({...Ce,name:e[Me].name})):e.map(Ce=>({name:Ce.name,muted:Ce.muted,soloed:Ce.soloed,volume:Ce.volume,pan:Ce.pan}))),Z.current&&Z.current.dispose();const we=new Pa({effects:d}),Ze=re.current;e.forEach((ge,Ce)=>{const Me=ge.clips.filter(ot=>ot.audioBuffer);if(Me.length>0){const ot=Me[0].sampleRate,mt=Math.min(...Me.map(Re=>Re.startSample/ot)),Ia=Math.max(...Me.map(Re=>(Re.startSample+Re.durationSamples)/ot)),ht=Ze[Ce],Sa={id:`track-${Ce}`,name:ge.name,gain:ht?.volume??ge.volume,muted:ht?.muted??ge.muted,soloed:ht?.soloed??ge.soloed,stereoPan:ht?.pan??ge.pan,startTime:mt,endTime:Ia},Aa=Me.map(Re=>{const Dt=Re.sampleRate;return{buffer:Re.audioBuffer,startTime:Re.startSample/Dt-mt,duration:Re.durationSamples/Dt,offset:Re.offsetSamples/Dt,fadeIn:Re.fadeIn,fadeOut:Re.fadeOut,gain:Re.gain}});we.addTrack({clips:Aa,track:Sa,effects:ge.effects})}}),we.applyInitialSoloState(),Z.current=we,He(!0);const et=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:P}});window.dispatchEvent(et),v?.()}catch(ie){console.error("Error loading audio:",ie)}})(),()=>{j.current&&cancelAnimationFrame(j.current),Z.current&&Z.current.dispose()}},[e,v,k]),i.useEffect(()=>{if(e.length===0)return;const B=16,H=e.map(O=>O.clips.map(P=>{if(P.waveformData){const Ze=jn(P.waveformData,Se,0,P.offsetSamples,P.durationSamples);return{clipId:P.id,trackName:O.name,peaks:{length:Ze.length,data:[Ze.data],bits:Ze.bits},startSample:P.startSample,durationSamples:P.durationSamples,fadeIn:P.fadeIn,fadeOut:P.fadeOut}}if(!P.audioBuffer)return console.warn(`Clip "${P.name||P.id}" has neither waveformData nor audioBuffer - rendering empty`),{clipId:P.id,trackName:O.name,peaks:{length:0,data:[],bits:B},startSample:P.startSample,durationSamples:P.durationSamples,fadeIn:P.fadeIn,fadeOut:P.fadeOut};const we=Or(P.audioBuffer,Se,n,B,P.offsetSamples,P.durationSamples);return{clipId:P.id,trackName:O.name,peaks:we,startSample:P.startSample,durationSamples:P.durationSamples,fadeIn:P.fadeIn,fadeOut:P.fadeOut}}));V(H)},[e,Se,n]),i.useEffect(()=>{if(u?.annotations){const B=u.annotations.map(H=>typeof H.start=="number"?H:Hn(H));x(B)}},[u]);const Ke=i.useCallback(()=>{j.current&&(cancelAnimationFrame(j.current),j.current=null);const B=()=>{const H=W.getContext().currentTime-de.current,O=fe.current+H;if(ue.current=O,$(O),I.length>0){const P=I.find(we=>O>=we.start&&O<we.end);if(qe.current)P&&P.id!==Oe.current?ze(P.id):!P&&Oe.current!==null&&ze(null);else if(Oe.current){const we=I.find(Ze=>Ze.id===Oe.current);if(we&&O>=we.end){Z.current&&Z.current.stop(),A(!1),ue.current=We.current,$(We.current);return}}else P&&ze(P.id)}if(Ne.current&&Pe.current&&T.length>0){const P=Pe.current,we=T[0].sampleRate,Ze=O*we/at.current,et=P.clientWidth,ge=c.show?c.width:0,Ce=Ze+ge,Me=Math.max(0,Ce-et/2);P.scrollLeft=Me}if(xe.current!==null&&O>=xe.current){Z.current&&Z.current.stop(),A(!1),ue.current=xe.current,$(xe.current),xe.current=null;return}const ie=oe.current!==pe.current&&pe.current>oe.current;if(Mt.current&&ie&&O>=pe.current){Z.current?.stop();const we=W.getContext().currentTime;de.current=we,fe.current=oe.current,ue.current=oe.current,Z.current?.play(we,oe.current),j.current=requestAnimationFrame(B);return}if(O>=E){Z.current&&Z.current.stop(),A(!1),ue.current=We.current,$(We.current),ze(null);return}j.current=requestAnimationFrame(B)};j.current=requestAnimationFrame(B)},[E,T,Se,I,he]),Fe=i.useCallback(()=>{j.current&&(cancelAnimationFrame(j.current),j.current=null)},[]);i.useEffect(()=>{(async()=>{if(k&&j.current&&Z.current)if(he){const H=ue.current;Z.current.stop(),Fe(),await Z.current.init(),Z.current.setOnPlaybackComplete(()=>{});const ie=W.getContext().currentTime;de.current=ie,fe.current=H,Z.current.play(ie,H),Ke()}else Fe(),Ke()})()},[he,k,Ke,Fe]),i.useEffect(()=>{(async()=>{if(ft.current&&Z.current){const{position:H}=ft.current;ft.current=null,await Z.current.init(),Z.current.setOnPlaybackComplete(()=>{});const ie=W.getContext().currentTime;de.current=ie,fe.current=H,Z.current.play(ie,H),A(!0),Ke()}})()},[e,Ke]);const Et=i.useCallback(async(B,H)=>{if(!Z.current||T.length===0)return;await Z.current.init(),await W.start();const O=B??ue.current;We.current=O,ue.current=O,Z.current.setOnPlaybackComplete(()=>{}),Z.current.stop(),Fe();const P=W.getContext().currentTime;de.current=P,fe.current=O,xe.current=H!==void 0?O+H:null,Z.current.play(P,O,H),A(!0),Ke()},[T.length,Ke,Fe]),da=i.useCallback(()=>{if(!Z.current)return;const B=W.getContext().currentTime-de.current,H=fe.current+B;Z.current.pause(),A(!1),Fe(),ue.current=H,$(H)},[Fe]),fa=i.useCallback(()=>{Z.current&&(Z.current.stop(),A(!1),Fe(),ue.current=We.current,$(We.current),ze(null))},[Fe]),ma=i.useCallback(B=>{const H=Math.max(0,Math.min(B,E));ue.current=H,$(H),k&&Z.current&&(Z.current.stop(),Fe(),Et(H))},[E,k,Et,Fe]),ha=i.useCallback((B,H)=>{const O=[..._];if(O[B]={...O[B],muted:H},L(O),Z.current){const ie=`track-${B}`;Z.current.setMute(ie,H)}},[_]),pa=i.useCallback((B,H)=>{const O=[..._];if(O[B]={...O[B],soloed:H},L(O),Z.current){const ie=`track-${B}`;Z.current.setSolo(ie,H)}},[_]),ga=i.useCallback((B,H)=>{const O=[..._];if(O[B]={...O[B],volume:H},L(O),Z.current){const ie=`track-${B}`,P=Z.current.getTrack(ie);P&&P.setVolume(H)}},[_]),ba=i.useCallback((B,H)=>{const O=[..._];if(O[B]={...O[B],pan:H},L(O),Z.current){const ie=`track-${B}`,P=Z.current.getTrack(ie);P&&P.setPan(H)}},[_]),va=i.useCallback((B,H)=>{F(B),ae(H),ue.current=B,$(B),k&&Z.current&&(Z.current.stop(),Z.current.play(W.getContext().currentTime,B))},[k]),Ca=i.useCallback(B=>{Pe.current=B},[]),xa=T[0]?.sampleRate||44100,Lt=t?30:0,wa=e.length*a+Lt,Yt={isPlaying:k,currentTime:M,currentTimeRef:ue,playbackStartTimeRef:de,audioStartPositionRef:fe},Ot={continuousPlay:he,linkEndpoints:je,annotationsEditable:Ge,isAutomaticScroll:ne,isLoopEnabled:le,annotations:I,activeAnnotationId:h,selectionStart:X,selectionEnd:K,selectedTrackId:te,loopStart:J,loopEnd:ve},Kt={play:Et,pause:da,stop:fa,seekTo:ma,setCurrentTime:B=>{ue.current=B,$(B)},setTrackMute:ha,setTrackSolo:pa,setTrackVolume:ga,setTrackPan:ba,setSelection:va,setSelectedTrackId:q,setTimeFormat:_e,formatTime:se,zoomIn:$e.zoomIn,zoomOut:$e.zoomOut,setMasterVolume:Ye,setAutomaticScroll:B=>{be(B)},setScrollContainer:Ca,scrollContainerRef:Pe,setContinuousPlay:Qe,setLinkEndpoints:ye,setAnnotationsEditable:Y,setAnnotations:x,setActiveAnnotationId:ze,setLoopEnabled:Rt,setLoopRegion:rt,setLoopRegionFromSelection:ca,clearLoopRegion:ua},Ut={duration:E,audioBuffers:T,peaksDataArray:z,trackStates:_,tracks:e,sampleRate:xa,waveHeight:a,timeScaleHeight:Lt,minimumPlaylistHeight:wa,controls:c,playoutRef:Z,samplesPerPixel:Se,timeFormat:Ie,masterVolume:Le,canZoomIn:$e.canZoomIn,canZoomOut:$e.canZoomOut,barWidth:f,barGap:C,progressBarWidth:g,isReady:Ve},ya={...Yt,...Ot,...Kt,...Ut},ka={...An,...l};return b.jsx(S.ThemeProvider,{theme:ka,children:b.jsx(qn.Provider,{value:Yt,children:b.jsx(Qn.Provider,{value:Ot,children:b.jsx(ea.Provider,{value:Kt,children:b.jsx(ta.Provider,{value:Ut,children:b.jsx(na.Provider,{value:ya,children:m})})})})})})},Ae=()=>{const e=i.useContext(qn);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Te=()=>{const e=i.useContext(Qn);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},me=()=>{const e=i.useContext(ea);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},ke=()=>{const e=i.useContext(ta);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e},ws=()=>{const e=i.useContext(na);if(!e)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return e};var ys=class{constructor(e){this._playbackRate=1,this.handleEnded=()=>{this.onStopCallback&&this.onStopCallback()},this.handleTimeUpdate=()=>{this.onTimeUpdateCallback&&this.onTimeUpdateCallback(this.audioElement.currentTime)},this._peaks=e.peaks,this._id=e.id??`track-${Date.now()}`,this._name=e.name??"Track",this._playbackRate=e.playbackRate??1,typeof e.source=="string"?(this.audioElement=new Audio(e.source),this.ownsElement=!0):(this.audioElement=e.source,this.ownsElement=!1),this.audioElement.preload="auto",this.audioElement.volume=e.volume??1,this.audioElement.playbackRate=this._playbackRate,"preservesPitch"in this.audioElement?this.audioElement.preservesPitch=!0:"mozPreservesPitch"in this.audioElement?this.audioElement.mozPreservesPitch=!0:"webkitPreservesPitch"in this.audioElement&&(this.audioElement.webkitPreservesPitch=!0),this.audioElement.addEventListener("ended",this.handleEnded),this.audioElement.addEventListener("timeupdate",this.handleTimeUpdate)}play(e=0){this.audioElement.currentTime=e,this.audioElement.play().catch(t=>{console.warn("MediaElementTrack: play() failed:",t)})}pause(){this.audioElement.pause()}stop(){this.audioElement.pause(),this.audioElement.currentTime=0}seekTo(e){this.audioElement.currentTime=Math.max(0,Math.min(e,this.duration))}setVolume(e){this.audioElement.volume=Math.max(0,Math.min(1,e))}setPlaybackRate(e){const t=Math.max(.5,Math.min(2,e));this._playbackRate=t,this.audioElement.playbackRate=t}setMuted(e){this.audioElement.muted=e}setOnStopCallback(e){this.onStopCallback=e}setOnTimeUpdateCallback(e){this.onTimeUpdateCallback=e}dispose(){this.audioElement.removeEventListener("ended",this.handleEnded),this.audioElement.removeEventListener("timeupdate",this.handleTimeUpdate),this.audioElement.pause(),this.ownsElement&&(this.audioElement.src="",this.audioElement.load())}get id(){return this._id}get name(){return this._name}get peaks(){return this._peaks}get currentTime(){return this.audioElement.currentTime}get duration(){return this.audioElement.duration||this._peaks.duration}get isPlaying(){return!this.audioElement.paused&&!this.audioElement.ended}get volume(){return this.audioElement.volume}get playbackRate(){return this._playbackRate}get muted(){return this.audioElement.muted}get element(){return this.audioElement}},ks=class{constructor(e={}){this.track=null,this._isPlaying=!1,this._masterVolume=e.masterVolume??1,this._playbackRate=e.playbackRate??1}async init(){}addTrack(e){return this.track&&(console.warn("MediaElementPlayout: Only one track is supported. Disposing previous track. For multi-track, use TonePlayout."),this.track.dispose()),this.track=new ys({...e,volume:this._masterVolume*(e.volume??1),playbackRate:this._playbackRate}),this.track.setOnStopCallback(()=>{this._isPlaying=!1,this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback()}),this.track}removeTrack(e){this.track&&this.track.id===e&&(this.track.dispose(),this.track=null)}getTrack(e){if(this.track&&this.track.id===e)return this.track}play(e,t,n){if(!this.track){console.warn("MediaElementPlayout: No track to play");return}const a=t??0;if(this._isPlaying=!0,this.track.play(a),n!==void 0){const r=n/this._playbackRate;setTimeout(()=>{this._isPlaying&&(this.pause(),this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())},r*1e3)}}pause(){this.track&&this.track.pause(),this._isPlaying=!1}stop(){this.track&&this.track.stop(),this._isPlaying=!1}seekTo(e){this.track&&this.track.seekTo(e)}getCurrentTime(){return this.track?this.track.currentTime:0}setMasterVolume(e){this._masterVolume=Math.max(0,Math.min(1,e)),this.track&&this.track.setVolume(this._masterVolume)}setPlaybackRate(e){this._playbackRate=Math.max(.5,Math.min(2,e)),this.track&&this.track.setPlaybackRate(this._playbackRate)}setMute(e,t){const n=this.getTrack(e);n&&n.setMuted(t)}setSolo(e,t){console.warn("MediaElementPlayout: Solo is not applicable for single-track playback")}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}dispose(){this.track&&(this.track.dispose(),this.track=null)}get isPlaying(){return this._isPlaying}get masterVolume(){return this._masterVolume}get playbackRate(){return this._playbackRate}get duration(){return this.track?.duration??0}get sampleRate(){return this.track?.peaks.sample_rate??44100}};const aa=i.createContext(null),ra=i.createContext(null),oa=i.createContext(null),sa=i.createContext(null),Is=({track:e,samplesPerPixel:t=1024,waveHeight:n=100,timescale:a=!1,playbackRate:r=1,automaticScroll:s=!1,theme:o,controls:l={show:!1,width:0},annotationList:c,barWidth:u=1,barGap:d=0,progressBarWidth:v,onReady:p,children:f})=>{const C=v??u+d,[y,m]=i.useState(!1),[g,I]=i.useState(0),[x,h]=i.useState(0),[w,k]=i.useState([]),[A,M]=i.useState(r),[$,E]=i.useState([]),[R,T]=i.useState(null),[D,z]=i.useState(c?.isContinuousPlay??!1),[V]=i.useState(t),[_,L]=i.useState(s),X=i.useRef(null),F=i.useRef(0),K=i.useRef(null),ae=i.useRef(D),te=i.useRef(null),q=i.useRef(null),ne=i.useRef(s),be=i.useRef(t);i.useEffect(()=>{ae.current=D},[D]),i.useEffect(()=>{ne.current=_},[_]);const he=i.useCallback(j=>{te.current=j,T(j)},[]),Xe=i.useCallback(j=>{ae.current=j,z(j)},[]),je=i.useCallback(j=>{q.current=j},[]),ye=e.waveformData.sample_rate;i.useEffect(()=>{const j=new ks({playbackRate:r});j.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const re=j.getTrack(j.track?.id??"");return re&&re.setOnTimeUpdateCallback(de=>{F.current=de}),j.setOnPlaybackComplete(()=>{m(!1)}),X.current=j,h(e.waveformData.duration),p?.(),()=>{K.current&&cancelAnimationFrame(K.current),j.dispose()}},[e.source,e.waveformData,e.name,r,p]),i.useEffect(()=>{const j=jn(e.waveformData,V,0,0,Math.ceil(e.waveformData.duration*ye)),re={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:j.length,data:[j.data],bits:j.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*ye)};k([[re]])},[e.waveformData,e.name,V,ye]),i.useEffect(()=>{if(c?.annotations){const j=c.annotations.map(re=>typeof re.start=="number"?re:Hn(re));E(j)}},[c]);const Ge=i.useCallback(()=>{K.current&&cancelAnimationFrame(K.current);const j=()=>{const re=X.current?.getCurrentTime()??0;if(F.current=re,I(re),$.length>0){const de=$.find(fe=>re>=fe.start&&re<fe.end);if(ae.current)de&&de.id!==te.current?he(de.id):!de&&te.current!==null&&he(null);else if(te.current){const fe=$.find(xe=>xe.id===te.current);if(fe&&re>=fe.end){X.current?.stop(),m(!1);return}}else de&&he(de.id)}if(ne.current&&q.current){const de=q.current,fe=re*ye/be.current,xe=de.clientWidth,Pe=l.show?l.width:0,Ne=fe+Pe,qe=Math.max(0,Ne-xe/2);de.scrollLeft=qe}if(re>=x){X.current?.stop(),m(!1),he(null);return}K.current=requestAnimationFrame(j)};K.current=requestAnimationFrame(j)},[x,$,he,ye,l]),Y=i.useCallback(()=>{K.current&&(cancelAnimationFrame(K.current),K.current=null)},[]),le=i.useCallback(j=>{if(!X.current)return;const re=j??F.current;X.current.play(void 0,re),m(!0),Ge()},[Ge]),Q=i.useCallback(()=>{X.current&&(X.current.pause(),m(!1),Y(),I(X.current.getCurrentTime()))},[Y]),J=i.useCallback(()=>{X.current&&(X.current.stop(),m(!1),Y(),F.current=0,I(0),he(null))},[Y,he]),ce=i.useCallback(j=>{const re=Math.max(0,Math.min(j,x));F.current=re,I(re),X.current&&X.current.seekTo(re)},[x]),ve=i.useCallback(j=>{const re=Math.max(.5,Math.min(2,j));M(re),X.current&&X.current.setPlaybackRate(re)},[]),ee=a?30:0,Ve=i.useMemo(()=>({isPlaying:y,currentTime:g,currentTimeRef:F}),[y,g]),He=i.useMemo(()=>({continuousPlay:D,annotations:$,activeAnnotationId:R,playbackRate:A,isAutomaticScroll:_}),[D,$,R,A,_]),Z=i.useMemo(()=>({play:le,pause:Q,stop:J,seekTo:ce,setPlaybackRate:ve,setContinuousPlay:Xe,setAnnotations:E,setActiveAnnotationId:he,setAutomaticScroll:j=>{L(j)},setScrollContainer:je,scrollContainerRef:q}),[le,Q,J,ce,ve,Xe,he,je]),We=i.useMemo(()=>({duration:x,peaksDataArray:w,sampleRate:ye,waveHeight:n,timeScaleHeight:ee,samplesPerPixel:V,playoutRef:X,controls:l,barWidth:u,barGap:d,progressBarWidth:C}),[x,w,ye,n,ee,V,l,u,d,C]),ue={...An,...o};return b.jsx(S.ThemeProvider,{theme:ue,children:b.jsx(aa.Provider,{value:Ve,children:b.jsx(ra.Provider,{value:He,children:b.jsx(oa.Provider,{value:Z,children:b.jsx(sa.Provider,{value:We,children:f})})})})})},At=()=>{const e=i.useContext(aa);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},ia=()=>{const e=i.useContext(ra);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},la=()=>{const e=i.useContext(oa);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},$t=()=>{const e=i.useContext(sa);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},Ss=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=Ae(),{selectionStart:a,selectionEnd:r,isLoopEnabled:s}=Te(),{play:o}=me(),l=async()=>{if(a!==r&&r>a)if(s)await o(a);else{const u=r-a;await o(a,u)}else await o(n.current??0)};return b.jsx(Be,{onClick:l,disabled:t,className:e,children:"Play"})},As=({className:e})=>{const{isPlaying:t}=Ae(),{pause:n}=me();return b.jsx(Be,{onClick:n,disabled:!t,className:e,children:"Pause"})},$s=({className:e})=>{const{isPlaying:t}=Ae(),{stop:n}=me();return b.jsx(Be,{onClick:n,disabled:!t,className:e,children:"Stop"})},Ms=({className:e})=>{const{isPlaying:t}=Ae(),{play:n,setCurrentTime:a}=me(),{playoutRef:r}=ke(),s=()=>{a(0),t&&r.current&&(r.current.stop(),n(0))};return b.jsx(Be,{onClick:s,className:e,children:"Rewind"})},Rs=({className:e})=>{const{isPlaying:t}=Ae(),{play:n,setCurrentTime:a}=me(),{duration:r,playoutRef:s}=ke(),o=()=>{a(r),t&&s.current&&(s.current.stop(),n(r))};return b.jsx(Be,{onClick:o,className:e,children:"Fast Forward"})},Es=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:a}=Ae(),{play:r,setCurrentTime:s}=me(),{playoutRef:o}=ke(),l=()=>{const c=Math.max(0,(n.current??0)-e);s(c),a&&o.current&&(o.current.stop(),r(c))};return b.jsx(Be,{onClick:l,className:t,children:"Skip Backward"})},Ds=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:a}=Ae(),{play:r,setCurrentTime:s}=me(),{duration:o,playoutRef:l}=ke(),c=()=>{const u=Math.min(o,(n.current??0)+e);s(u),a&&l.current&&(l.current.stop(),r(u))};return b.jsx(Be,{onClick:c,className:t,children:"Skip Forward"})},Bs=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:a}=Te(),{setLoopEnabled:r,setLoopRegion:s}=me(),{duration:o}=ke(),l=n!==a&&a>n,c=()=>{if(!t&&!l){const u=Math.min(10,o*.25);s(0,Math.max(1,u))}r(!t)};return b.jsx(Be,{onClick:c,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},Ts=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:a,loopEnd:r}=Te(),{setLoopRegionFromSelection:s,clearLoopRegion:o}=me(),l=t!==n&&n>t,c=a!==r&&r>a,u=()=>{c?o():s()};return b.jsx(Be,{onClick:u,disabled:!l&&!c,className:e,title:c?"Clear loop region":l?"Set loop region from selection":"Create a selection first",children:c?"Clear Loop":"Set Loop"})},Ws=({className:e,disabled:t})=>{const{zoomIn:n}=me(),{canZoomIn:a}=ke();return b.jsx(Be,{variant:"success",onClick:n,disabled:t||!a,className:e,children:"Zoom In"})},_s=({className:e,disabled:t})=>{const{zoomOut:n}=me(),{canZoomOut:a}=ke();return b.jsx(Be,{variant:"success",onClick:n,disabled:t||!a,className:e,children:"Zoom Out"})},Fs=({className:e})=>{const{masterVolume:t}=ke(),{setMasterVolume:n}=me();return b.jsx(ur,{volume:t,onChange:n,className:e})},Zs=({className:e})=>{const{timeFormat:t}=ke(),{setTimeFormat:n}=me();return b.jsx(Fr,{value:t,onChange:n,className:e})},Vs=S.span`
1212
1194
  font-family: 'Courier New', Monaco, monospace;
1213
1195
  font-size: 1rem;
1214
1196
  font-weight: 600;
1215
1197
  color: ${e=>e.theme?.textColor||"#333"};
1216
1198
  user-select: none;
1217
- `,wl=({className:e})=>{const t=c.useRef(null),n=c.useRef(null),{isPlaying:r,currentTimeRef:a,playbackStartTimeRef:s,audioStartPositionRef:o}=We(),{timeFormat:l}=De(),i=l;return c.useEffect(()=>{const u=()=>{if(t.current){let d;if(r){const b=P.getContext().currentTime-(s.current??0);d=(o.current??0)+b}else d=a.current??0;t.current.textContent=It(d,i)}r&&(n.current=requestAnimationFrame(u))};return r?n.current=requestAnimationFrame(u):u(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,i,a,s,o]),c.useEffect(()=>{!r&&t.current&&(t.current.textContent=It(a.current??0,i))}),Z.jsx(Cl,{ref:t,className:e,"aria-label":"Audio position",children:It(a.current??0,i)})},xl=({className:e})=>{const{selectionStart:t,selectionEnd:n}=Le(),{setSelection:r}=we();return Z.jsx(To,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},yl=({className:e})=>{const{isAutomaticScroll:t}=Le(),{setAutomaticScroll:n}=we();return Z.jsx(qa,{checked:t,onChange:n,className:e})},Il=({className:e})=>{const{continuousPlay:t}=Le(),{setContinuousPlay:n}=we();return Z.jsx(ni,{checked:t,onChange:n,className:e})},Sl=({className:e})=>{const{linkEndpoints:t}=Le(),{setLinkEndpoints:n}=we();return Z.jsx(ri,{checked:t,onChange:n,className:e})},Al=({className:e})=>{const{annotationsEditable:t}=Le(),{setAnnotationsEditable:n}=we();return Z.jsx(ai,{checked:t,onChange:n,className:e})},kl=({filename:e,className:t})=>{const{annotations:n}=Le();return Z.jsx(si,{annotations:n,filename:e,className:t})},$l=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:a=16,applyEffects:s=!0,effectsFunction:o,createOfflineTrackEffects:l,className:i,onExportComplete:u,onExportError:d})=>{const{tracks:b,trackStates:p}=De(),{exportWav:f,isExporting:C,progress:y}=da(),g=async()=>{try{const w=await f(b,p,{filename:t,mode:n,trackIndex:r,bitDepth:a,applyEffects:s,effectsFunction:o,createOfflineTrackEffects:l,autoDownload:!0});u?.(w.blob)}catch(w){d?.(w instanceof Error?w:new Error("Export failed"))}},m=C?`Exporting ${Math.round(y*100)}%`:e;return Z.jsx(Ne,{onClick:g,disabled:C||b.length===0,className:i,children:m})},Rl=k.div`
1199
+ `,Ps=({className:e})=>{const t=i.useRef(null),n=i.useRef(null),{isPlaying:a,currentTimeRef:r,playbackStartTimeRef:s,audioStartPositionRef:o}=Ae(),{timeFormat:l}=ke(),c=l;return i.useEffect(()=>{const u=()=>{if(t.current){let d;if(a){const v=W.getContext().currentTime-(s.current??0);d=(o.current??0)+v}else d=r.current??0;t.current.textContent=nt(d,c)}a&&(n.current=requestAnimationFrame(u))};return a?n.current=requestAnimationFrame(u):u(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[a,c,r,s,o]),i.useEffect(()=>{!a&&t.current&&(t.current.textContent=nt(r.current??0,c))}),b.jsx(Vs,{ref:t,className:e,"aria-label":"Audio position",children:nt(r.current??0,c)})},zs=({className:e})=>{const{selectionStart:t,selectionEnd:n}=Te(),{setSelection:a}=me();return b.jsx(wr,{selectionStart:t,selectionEnd:n,onSelectionChange:a,className:e})},js=({className:e})=>{const{isAutomaticScroll:t}=Te(),{setAutomaticScroll:n}=me();return b.jsx(Na,{checked:t,onChange:n,className:e})},Hs=({className:e})=>{const{continuousPlay:t}=Te(),{setContinuousPlay:n}=me();return b.jsx(Do,{checked:t,onChange:n,className:e})},Xs=({className:e})=>{const{linkEndpoints:t}=Te(),{setLinkEndpoints:n}=me();return b.jsx(Bo,{checked:t,onChange:n,className:e})},Gs=({className:e})=>{const{annotationsEditable:t}=Te(),{setAnnotationsEditable:n}=me();return b.jsx(To,{checked:t,onChange:n,className:e})},Ns=({filename:e,className:t})=>{const{annotations:n}=Te();return b.jsx(_o,{annotations:n,filename:e,className:t})},Ls=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:a,bitDepth:r=16,applyEffects:s=!0,effectsFunction:o,createOfflineTrackEffects:l,className:c,onExportComplete:u,onExportError:d})=>{const{tracks:v,trackStates:p}=ke(),{exportWav:f,isExporting:C,progress:y}=Jn(),m=async()=>{try{const I=await f(v,p,{filename:t,mode:n,trackIndex:a,bitDepth:r,applyEffects:s,effectsFunction:o,createOfflineTrackEffects:l,autoDownload:!0});u?.(I.blob)}catch(I){d?.(I instanceof Error?I:new Error("Export failed"))}},g=C?`Exporting ${Math.round(y*100)}%`:e;return b.jsx(Be,{onClick:m,disabled:C||v.length===0,className:c,children:g})},Ys=S.div`
1218
1200
  position: absolute;
1219
1201
  top: 0;
1220
1202
  left: 0;
@@ -1224,9 +1206,9 @@ React keys must be passed directly to JSX without using spread:
1224
1206
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
1225
1207
  pointer-events: none;
1226
1208
  will-change: transform;
1227
- `,El=({color:e="#ff0000",controlsOffset:t=0})=>{const n=c.useRef(null),r=c.useRef(null),{isPlaying:a,currentTimeRef:s,playbackStartTimeRef:o,audioStartPositionRef:l}=We(),{samplesPerPixel:i,sampleRate:u,progressBarWidth:d}=De();return c.useEffect(()=>{const b=()=>{if(n.current){let p;if(a){const C=P.getContext().currentTime-(o.current??0);p=(l.current??0)+C}else p=s.current??0;const f=p*u/i+t;n.current.style.transform=`translate3d(${f}px, 0, 0)`}a&&(r.current=requestAnimationFrame(b))};return a?r.current=requestAnimationFrame(b):b(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[a,u,i,t,s,o,l]),c.useEffect(()=>{if(!a&&n.current){const p=(s.current??0)*u/i+t;n.current.style.transform=`translate3d(${p}px, 0, 0)`}}),Z.jsx(Rl,{ref:n,$color:e,$width:d,"data-playhead":!0})},Dl=k.div`
1209
+ `,Os=({color:e="#ff0000",controlsOffset:t=0})=>{const n=i.useRef(null),a=i.useRef(null),{isPlaying:r,currentTimeRef:s,playbackStartTimeRef:o,audioStartPositionRef:l}=Ae(),{samplesPerPixel:c,sampleRate:u,progressBarWidth:d}=ke();return i.useEffect(()=>{const v=()=>{if(n.current){let p;if(r){const C=W.getContext().currentTime-(o.current??0);p=(l.current??0)+C}else p=s.current??0;const f=p*u/c+t;n.current.style.transform=`translate3d(${f}px, 0, 0)`}r&&(a.current=requestAnimationFrame(v))};return r?a.current=requestAnimationFrame(v):v(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[r,u,c,t,s,o,l]),i.useEffect(()=>{if(!r&&n.current){const p=(s.current??0)*u/c+t;n.current.style.transform=`translate3d(${p}px, 0, 0)`}}),b.jsx(Ys,{ref:n,$color:e,$width:d,"data-playhead":!0})},Ks=S.div`
1228
1210
  position: relative;
1229
- `,Tl=k.div`
1211
+ `,Us=S.div`
1230
1212
  position: absolute;
1231
1213
  top: ${e=>e.$top}px;
1232
1214
  left: 0;
@@ -1238,7 +1220,7 @@ React keys must be passed directly to JSX without using spread:
1238
1220
  transform: translateZ(0);
1239
1221
  backface-visibility: hidden;
1240
1222
  will-change: transform;
1241
- `,_l=k.div`
1223
+ `,Js=S.div`
1242
1224
  position: absolute;
1243
1225
  top: ${e=>e.$top}px;
1244
1226
  left: 0;
@@ -1247,8 +1229,43 @@ React keys must be passed directly to JSX without using spread:
1247
1229
  pointer-events: none;
1248
1230
  z-index: 1;
1249
1231
  will-change: width;
1250
- `,Ml=k.div`
1232
+ `,qs=S.div`
1251
1233
  position: relative;
1252
1234
  z-index: 2;
1253
- `,Br=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=c.useRef(null),a=c.useRef(null),s=Mn(),{waveHeight:o}=en(),{isPlaying:l,currentTimeRef:i,playbackStartTimeRef:u,audioStartPositionRef:d}=We(),{samplesPerPixel:b,sampleRate:p}=De(),f=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";c.useEffect(()=>{const m=()=>{if(r.current){let w;if(l){const I=P.getContext().currentTime-(u.current??0);w=(d.current??0)+I}else w=i.current??0;const x=w*p,v=e+t;let S=0;if(x<=e)S=0;else if(x>=v)S=n.length;else{const I=x-e;S=Math.floor(I/b)}r.current.style.width=`${S}px`}l&&(a.current=requestAnimationFrame(m))};return l?a.current=requestAnimationFrame(m):m(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[l,p,b,e,t,n.length,i,u,d]),c.useEffect(()=>{if(!l&&r.current){const w=(i.current??0)*p,x=e+t;let v=0;if(w<=e)v=0;else if(w>=x)v=n.length;else{const S=w-e;v=Math.floor(S/b)}r.current.style.width=`${v}px`}});const C=s?.waveformDrawMode||"inverted";let y;C==="inverted"?y=n.isSelected&&s?s.selectedWaveFillColor:s?.waveFillColor||"white":y=n.isSelected&&s?s.selectedWaveOutlineColor:s?.waveOutlineColor||"grey";const g=Gt(y);return Z.jsxs(Dl,{children:[Z.jsx(Tl,{$color:g,$height:o,$top:n.index*o,$width:n.length}),Z.jsx(_l,{ref:r,$color:f,$height:o,$top:n.index*o}),Z.jsx(Ml,{children:Z.jsx(Vo,{...n,transparentBackground:!0})})]})},Bl=60,Fl=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:a,annotationTextHeight:s,className:o,showClipHeaders:l=!1,interactiveClips:i=!1,showFades:u=!1,touchOptimized:d=!1,recordingState:b})=>{const p=Mn(),{isPlaying:f,currentTimeRef:C,playbackStartTimeRef:y,audioStartPositionRef:g}=We(),{selectionStart:m,selectionEnd:w,annotations:x,activeAnnotationId:v,annotationsEditable:S,linkEndpoints:I,continuousPlay:$,selectedTrackId:M,loopStart:T,loopEnd:_,isLoopEnabled:D}=Le(),{setAnnotations:V,setActiveAnnotationId:W,setTrackMute:O,setTrackSolo:N,setTrackVolume:Y,setTrackPan:ee,setSelection:re,play:X,setScrollContainer:oe,setSelectedTrackId:A,setCurrentTime:j,setLoopRegion:H}=we(),{audioBuffers:U,peaksDataArray:ge,trackStates:Be,tracks:ie,duration:Te,samplesPerPixel:ue,sampleRate:me,waveHeight:gt,timeScaleHeight:dt,controls:de,playoutRef:at,barWidth:ot,barGap:Je}=De(),[st,z]=c.useState(!1),Re=c.useRef(null),xe=c.useCallback(K=>{Re.current=K,oe(K)},[oe]);let be=U.length>0?Te:Bl;if(b?.isRecording){const te=(b.startSample+b.durationSamples)/me;be=Math.max(be,te+10)}const Ze=Math.floor(be*me/ue),Xe=async K=>{console.log("Annotation clicked:",K.id),W(K.id);const te=$?void 0:K.end-K.start;await X(K.start,te)},Pe=c.useCallback(K=>{if(K>=0&&K<ie.length){const te=ie[K];A(te.id)}},[ie,A]),He=K=>{const te=K.currentTarget.getBoundingClientRect(),he=de.show?de.width:0,Ee=(K.clientX-te.left-he)*ue/me,le=K.clientY-te.top;let Ye=0,Ke=-1;for(let ze=0;ze<ge.length;ze++){const _e=ge[ze],qe=(_e.length>0?Math.max(..._e.map(mt=>mt.peaks.data.length)):1)*gt+(l?22:0);if(le>=Ye&&le<Ye+qe){Ke=ze;break}Ye+=qe}Ke!==-1&&Pe(Ke),z(!0),j(Ee),re(Ee,Ee)},Ge=K=>{if(!st)return;const te=K.currentTarget.getBoundingClientRect(),he=de.show?de.width:0,Ee=(K.clientX-te.left-he)*ue/me,Ae=Math.min(m,Ee),le=Math.max(m,Ee);re(Ae,le)},ft=K=>{if(!st)return;z(!1);const te=K.currentTarget.getBoundingClientRect(),he=de.show?de.width:0,Ee=(K.clientX-te.left-he)*ue/me,Ae=Math.min(m,Ee),le=Math.max(m,Ee);Math.abs(le-Ae)<.1?(j(Ae),f&&at.current?(at.current.stop(),X(Ae)):at.current&&at.current.stop()):re(Ae,le)};return ie.some(K=>K.clips.length>0)&&(U.length===0||ge.length===0)?Z.jsx("div",{className:o,children:"Loading waveform..."}):Z.jsx(_o,{children:Z.jsxs(_n.Provider,{value:{samplesPerPixel:ue,sampleRate:me,zoomLevels:[ue],waveHeight:gt,timeScaleHeight:dt,duration:be,controls:de,barWidth:ot,barGap:Je},children:[Z.jsx(Kr,{theme:p,backgroundColor:Gt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Ze+(de.show?de.width:0),timescaleWidth:Ze,tracksWidth:Ze,controlsWidth:de.show?de.width:0,onTracksMouseDown:He,onTracksMouseMove:Ge,onTracksMouseUp:ft,scrollContainerRef:xe,isSelecting:st,timescale:dt>0?Z.jsxs(Z.Fragment,{children:[Z.jsx(Ho,{duration:be*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:t}),D&&Z.jsx(Do,{startPosition:Math.min(T,_)*me/ue,endPosition:Math.max(T,_)*me/ue,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:Ze,controlsOffset:de.show?de.width:0,onLoopRegionChange:(K,te)=>{const he=K*ue/me,ye=te*ue/me;H(he,ye)}})]}):void 0,children:Z.jsxs(Z.Fragment,{children:[ge.map((K,te)=>{const he=ie[te];if(!he)return null;const ye=Be[te]||{name:`Track ${te+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ee=e?e(te):Z.jsxs(ts,{onClick:()=>Pe(te),children:[Z.jsx(ns,{style:{justifyContent:"center"},children:ye.name||`Track ${te+1}`}),Z.jsxs(es,{children:[Z.jsx(ir,{$variant:ye.muted?"danger":"outline",onClick:()=>O(te,!ye.muted),children:"Mute"}),Z.jsx(ir,{$variant:ye.soloed?"info":"outline",onClick:()=>N(te,!ye.soloed),children:"Solo"})]}),Z.jsxs(cr,{children:[Z.jsx(rs,{}),Z.jsx(lr,{min:"0",max:"1",step:"0.01",value:ye.volume,onChange:le=>Y(te,parseFloat(le.target.value))}),Z.jsx(as,{})]}),Z.jsxs(cr,{children:[Z.jsx("span",{children:"L"}),Z.jsx(lr,{min:"-1",max:"1",step:"0.01",value:ye.pan,onChange:le=>ee(te,parseFloat(le.target.value))}),Z.jsx("span",{children:"R"})]})]}),Ae=K.length>0?Math.max(...K.map(le=>le.peaks.data.length)):1;return Z.jsx(Qr.Provider,{value:Ee,children:Z.jsxs(Qo,{numChannels:Ae,backgroundColor:Gt(p.waveOutlineColor),offset:0,width:Ze,hasClipHeaders:l,trackId:he.id,isSelected:he.id===M,children:[K.map((le,Ye)=>{const Ke=le.peaks,ze=Ke.length;return Z.jsx(ar,{clipId:le.clipId,trackIndex:te,clipIndex:Ye,trackName:le.trackName,startSample:le.startSample,durationSamples:le.durationSamples,samplesPerPixel:ue,showHeader:l,disableHeaderDrag:!i,isSelected:he.id===M,trackId:he.id,fadeIn:le.fadeIn,fadeOut:le.fadeOut,sampleRate:me,showFades:u,touchOptimized:d,onMouseDown:_e=>{_e.target.closest('[role="button"][aria-roledescription="draggable"]')||Pe(te)},children:Ke.data.map((_e,Ie)=>Z.jsx(Br,{index:Ie,data:_e,bits:Ke.bits,length:ze,isSelected:he.id===M,clipStartSample:le.startSample,clipDurationSamples:le.durationSamples},`${te}-${Ye}-${Ie}`))},`${te}-${Ye}`)}),b?.isRecording&&b.trackId===he.id&&b.peaks.length>0&&Z.jsx(ar,{clipId:"recording-preview",trackIndex:te,clipIndex:K.length,trackName:"Recording...",startSample:b.startSample,durationSamples:b.durationSamples,samplesPerPixel:ue,showHeader:l,disableHeaderDrag:!0,isSelected:he.id===M,trackId:he.id,children:Z.jsx(Br,{index:0,data:b.peaks,bits:16,length:Math.floor(b.peaks.length/2),isSelected:he.id===M,clipStartSample:b.startSample,clipDurationSamples:b.durationSamples},`${te}-recording-0`)},`${te}-recording`)]})},he.id)}),x.length>0&&Z.jsx(Ls,{height:30,width:Ze,children:x.map((K,te)=>{const he=K.start*me/ue,ye=K.end*me/ue;return Z.jsx(js,{annotationId:K.id,annotationIndex:te,startPosition:he,endPosition:ye,label:K.id,color:"#ff9800",isActive:K.id===v,onClick:()=>Xe(K),editable:S},K.id)})}),m!==w&&Z.jsx(ko,{startPosition:Math.min(m,w)*me/ue+(de.show?de.width:0),endPosition:Math.max(m,w)*me/ue+(de.show?de.width:0),color:p.selectionColor}),(f||m===w)&&(n?n({position:(C.current??0)*me/ue+(de.show?de.width:0),color:p.playheadColor,isPlaying:f,currentTimeRef:C,playbackStartTimeRef:y,audioStartPositionRef:g,samplesPerPixel:ue,sampleRate:me,controlsOffset:de.show?de.width:0,getAudioContextTime:()=>P.getContext().currentTime}):Z.jsx(El,{color:p.playheadColor,controlsOffset:de.show?de.width:0}))]})}),x.length>0&&Z.jsx(ti,{annotations:x,activeAnnotationId:v??void 0,shouldScrollToActive:!0,editable:S,controls:S?r:void 0,annotationListConfig:{linkEndpoints:I,continuousPlay:$},height:s,onAnnotationUpdate:K=>{V(K)}})]})})};exports.Tone=Wr;exports.AudioPosition=wl;exports.AutomaticScrollCheckbox=yl;exports.ContinuousPlayCheckbox=Il;exports.DownloadAnnotationsButton=kl;exports.EditableCheckbox=Al;exports.ExportWavButton=$l;exports.FastForwardButton=ul;exports.LinkEndpointsCheckbox=Sl;exports.LoopButton=ml;exports.MasterVolumeControl=bl;exports.PauseButton=il;exports.PlayButton=sl;exports.RewindButton=cl;exports.SelectionTimeInputs=xl;exports.SetLoopRegionButton=hl;exports.SkipBackwardButton=dl;exports.SkipForwardButton=fl;exports.StopButton=ll;exports.TimeFormatSelect=vl;exports.Waveform=Fl;exports.WaveformPlaylistProvider=al;exports.ZoomInButton=pl;exports.ZoomOutButton=gl;exports.createEffectChain=Ui;exports.createEffectInstance=_t;exports.effectCategories=Hi;exports.effectDefinitions=Mt;exports.getEffectDefinition=Zn;exports.getEffectsByCategory=Xi;exports.getShortcutLabel=Ei;exports.getWaveformDataMetadata=ks;exports.loadPeaksFromWaveformData=As;exports.loadWaveformData=Bn;exports.useAnnotationDragHandlers=mi;exports.useAnnotationKeyboardControls=Ti;exports.useAudioTracks=di;exports.useClipDragHandlers=fi;exports.useClipSplitting=Ri;exports.useDragSensors=$i;exports.useDynamicEffects=Ji;exports.useExportWav=da;exports.useIntegratedRecording=Li;exports.useKeyboardShortcuts=Kt;exports.useMasterAnalyser=li;exports.useMasterVolume=oa;exports.usePlaybackAnimation=We;exports.usePlaybackShortcuts=Di;exports.usePlaylistControls=we;exports.usePlaylistData=De;exports.usePlaylistState=Le;exports.useTimeFormat=ra;exports.useTrackDynamicEffects=qi;exports.useWaveformPlaylist=ol;exports.useZoomControls=aa;exports.waveformDataToPeaks=na;
1235
+ `,gn=({clipStartSample:e,clipDurationSamples:t,...n})=>{const a=i.useRef(null),r=i.useRef(null),s=ut(),{waveHeight:o}=ct(),{isPlaying:l,currentTimeRef:c,playbackStartTimeRef:u,audioStartPositionRef:d}=Ae(),{samplesPerPixel:v,sampleRate:p}=ke(),f=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";i.useEffect(()=>{const g=()=>{if(a.current){let I;if(l){const k=W.getContext().currentTime-(u.current??0);I=(d.current??0)+k}else I=c.current??0;const x=I*p,h=e+t;let w=0;if(x<=e)w=0;else if(x>=h)w=n.length;else{const k=x-e;w=Math.floor(k/v)}a.current.style.width=`${w}px`}l&&(r.current=requestAnimationFrame(g))};return l?r.current=requestAnimationFrame(g):g(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[l,p,v,e,t,n.length,c,u,d]),i.useEffect(()=>{if(!l&&a.current){const I=(c.current??0)*p,x=e+t;let h=0;if(I<=e)h=0;else if(I>=x)h=n.length;else{const w=I-e;h=Math.floor(w/v)}a.current.style.width=`${h}px`}});const C=s?.waveformDrawMode||"inverted";let y;C==="inverted"?y=n.isSelected&&s?s.selectedWaveFillColor:s?.waveFillColor||"white":y=n.isSelected&&s?s.selectedWaveOutlineColor:s?.waveOutlineColor||"grey";const m=Ue(y);return b.jsxs(Ks,{children:[b.jsx(Us,{$color:m,$height:o,$top:n.index*o,$width:n.length}),b.jsx(Js,{ref:a,$color:f,$height:o,$top:n.index*o}),b.jsx(qs,{children:b.jsx(_n,{...n,transparentBackground:!0})})]})},Qs=60,ei=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:a,annotationListConfig:r,annotationTextHeight:s,renderAnnotationItem:o,getAnnotationBoxLabel:l,scrollActivePosition:c="center",scrollActiveContainer:u="nearest",className:d,showClipHeaders:v=!1,interactiveClips:p=!1,showFades:f=!1,touchOptimized:C=!1,recordingState:y})=>{const m=ut(),{isPlaying:g,currentTimeRef:I,playbackStartTimeRef:x,audioStartPositionRef:h}=Ae(),{selectionStart:w,selectionEnd:k,annotations:A,activeAnnotationId:M,annotationsEditable:$,linkEndpoints:E,continuousPlay:R,selectedTrackId:T,loopStart:D,loopEnd:z,isLoopEnabled:V}=Te(),{setAnnotations:_,setActiveAnnotationId:L,setTrackMute:X,setTrackSolo:F,setTrackVolume:K,setTrackPan:ae,setSelection:te,play:q,setScrollContainer:ne,setSelectedTrackId:be,setCurrentTime:he,setLoopRegion:Xe}=me(),{audioBuffers:je,peaksDataArray:ye,trackStates:Ge,tracks:Y,duration:le,samplesPerPixel:Q,sampleRate:J,waveHeight:ce,timeScaleHeight:ve,controls:ee,playoutRef:Ve,barWidth:He,barGap:Z,isReady:We}=ke(),[ue,j]=i.useState(!1),re=i.useRef(null),de=i.useCallback(G=>{re.current=G,ne(G)},[ne]);let fe=je.length>0?le:Qs;if(y?.isRecording){const U=(y.startSample+y.durationSamples)/J;fe=Math.max(fe,U+10)}const xe=Math.floor(fe*J/Q),Pe=async G=>{console.log("Annotation clicked:",G.id),L(G.id);const U=R?void 0:G.end-G.start;await q(G.start,U)},Ne=i.useCallback(G=>{if(G>=0&&G<Y.length){const U=Y[G];be(U.id)}},[Y,be]),qe=G=>{const U=G.currentTarget.getBoundingClientRect(),oe=ee.show?ee.width:0,Ie=(G.clientX-U.left-oe)*Q/J,se=G.clientY-U.top;let $e=0,Se=-1;for(let Le=0;Le<ye.length;Le++){const Ye=ye[Le],ze=(Ye.length>0?Math.max(...Ye.map(Rt=>Rt.peaks.data.length)):1)*ce+(v?22:0);if(se>=$e&&se<$e+ze){Se=Le;break}$e+=ze}Se!==-1&&Ne(Se),j(!0),he(Ie),te(Ie,Ie)},Oe=G=>{if(!ue)return;const U=G.currentTarget.getBoundingClientRect(),oe=ee.show?ee.width:0,Ie=(G.clientX-U.left-oe)*Q/J,_e=Math.min(w,Ie),se=Math.max(w,Ie);te(_e,se)},at=G=>{if(!ue)return;j(!1);const U=G.currentTarget.getBoundingClientRect(),oe=ee.show?ee.width:0,Ie=(G.clientX-U.left-oe)*Q/J,_e=Math.min(w,Ie),se=Math.max(w,Ie);Math.abs(se-_e)<.1?(he(_e),g&&Ve.current?(Ve.current.stop(),q(_e)):Ve.current&&Ve.current.stop()):te(_e,se)};return Y.some(G=>G.clips.length>0)&&(je.length===0||ye.length===0)?b.jsx("div",{className:d,children:"Loading waveform..."}):b.jsx(Tn,{children:b.jsxs(It.Provider,{value:{samplesPerPixel:Q,sampleRate:J,zoomLevels:[Q],waveHeight:ce,timeScaleHeight:ve,duration:fe,controls:ee,barWidth:He,barGap:Z},children:[b.jsx(Ht,{theme:m,backgroundColor:Ue(m.waveOutlineColor),timescaleBackgroundColor:m.timescaleBackgroundColor,scrollContainerWidth:xe+(ee.show?ee.width:0),timescaleWidth:xe,tracksWidth:xe,controlsWidth:ee.show?ee.width:0,onTracksMouseDown:qe,onTracksMouseMove:Oe,onTracksMouseUp:at,scrollContainerRef:de,isSelecting:ue,"data-playlist-state":We?"ready":"loading",timescale:ve>0?b.jsxs(b.Fragment,{children:[b.jsx(Fn,{duration:fe*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:t}),V&&b.jsx(xr,{startPosition:Math.min(D,z)*J/Q,endPosition:Math.max(D,z)*J/Q,markerColor:m.loopMarkerColor,regionColor:m.loopRegionColor,minPosition:0,maxPosition:xe,controlsOffset:ee.show?ee.width:0,onLoopRegionChange:(G,U)=>{const oe=G*Q/J,pe=U*Q/J;Xe(oe,pe)}})]}):void 0,children:b.jsxs(b.Fragment,{children:[ye.map((G,U)=>{const oe=Y[U];if(!oe)return null;const pe=Ge[U]||{name:`Track ${U+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ie=e?e(U):b.jsxs(jr,{onClick:()=>Ne(U),children:[b.jsx(Hr,{style:{justifyContent:"center"},children:pe.name||`Track ${U+1}`}),b.jsxs(zr,{children:[b.jsx(on,{$variant:pe.muted?"danger":"outline",onClick:()=>X(U,!pe.muted),children:"Mute"}),b.jsx(on,{$variant:pe.soloed?"info":"outline",onClick:()=>F(U,!pe.soloed),children:"Solo"})]}),b.jsxs(ln,{children:[b.jsx(Xr,{}),b.jsx(sn,{min:"0",max:"1",step:"0.01",value:pe.volume,onChange:se=>K(U,parseFloat(se.target.value))}),b.jsx(Gr,{})]}),b.jsxs(ln,{children:[b.jsx("span",{children:"L"}),b.jsx(sn,{min:"-1",max:"1",step:"0.01",value:pe.pan,onChange:se=>ae(U,parseFloat(se.target.value))}),b.jsx("span",{children:"R"})]})]}),_e=G.length>0?Math.max(...G.map(se=>se.peaks.data.length)):1;return b.jsx(Xt.Provider,{value:Ie,children:b.jsxs(Zn,{numChannels:_e,backgroundColor:Ue(m.waveOutlineColor),offset:0,width:xe,hasClipHeaders:v,trackId:oe.id,isSelected:oe.id===T,children:[G.map((se,$e)=>{const Se=se.peaks,Le=Se.length;return b.jsx(Zt,{clipId:se.clipId,trackIndex:U,clipIndex:$e,trackName:se.trackName,startSample:se.startSample,durationSamples:se.durationSamples,samplesPerPixel:Q,showHeader:v,disableHeaderDrag:!p,isSelected:oe.id===T,trackId:oe.id,fadeIn:se.fadeIn,fadeOut:se.fadeOut,sampleRate:J,showFades:f,touchOptimized:C,onMouseDown:Ye=>{Ye.target.closest('[role="button"][aria-roledescription="draggable"]')||Ne(U)},children:Se.data.map((Ye,Qe)=>b.jsx(gn,{index:Qe,data:Ye,bits:Se.bits,length:Le,isSelected:oe.id===T,clipStartSample:se.startSample,clipDurationSamples:se.durationSamples},`${U}-${$e}-${Qe}`))},`${U}-${$e}`)}),y?.isRecording&&y.trackId===oe.id&&y.peaks.length>0&&b.jsx(Zt,{clipId:"recording-preview",trackIndex:U,clipIndex:G.length,trackName:"Recording...",startSample:y.startSample,durationSamples:y.durationSamples,samplesPerPixel:Q,showHeader:v,disableHeaderDrag:!0,isSelected:oe.id===T,trackId:oe.id,children:b.jsx(gn,{index:0,data:y.peaks,bits:16,length:Math.floor(y.peaks.length/2),isSelected:oe.id===T,clipStartSample:y.startSample,clipDurationSamples:y.durationSamples},`${U}-recording-0`)},`${U}-recording`)]})},oe.id)}),A.length>0&&b.jsx(Gn,{height:30,width:xe,children:A.map((G,U)=>{const oe=G.start*J/Q,pe=G.end*J/Q,Ie=l?l(G,U):G.id;return b.jsx(Xn,{annotationId:G.id,annotationIndex:U,startPosition:oe,endPosition:pe,label:Ie,color:"#ff9800",isActive:G.id===M,onClick:()=>Pe(G),editable:$},G.id)})}),w!==k&&b.jsx(En,{startPosition:Math.min(w,k)*J/Q+(ee.show?ee.width:0),endPosition:Math.max(w,k)*J/Q+(ee.show?ee.width:0),color:m.selectionColor}),(g||w===k)&&(n?n({position:(I.current??0)*J/Q+(ee.show?ee.width:0),color:m.playheadColor,isPlaying:g,currentTimeRef:I,playbackStartTimeRef:x,audioStartPositionRef:h,samplesPerPixel:Q,sampleRate:J,controlsOffset:ee.show?ee.width:0,getAudioContextTime:()=>W.getContext().currentTime}):b.jsx(Os,{color:m.playheadColor,controlsOffset:ee.show?ee.width:0}))]})}),A.length>0&&b.jsx(Nn,{annotations:A,activeAnnotationId:M??void 0,shouldScrollToActive:!0,scrollActivePosition:c,scrollActiveContainer:u,editable:$,controls:$?a:void 0,annotationListConfig:{linkEndpoints:E,continuousPlay:R},height:s,renderAnnotationItem:o,onAnnotationUpdate:G=>{_(G)}})]})})},ti=S.div`
1236
+ position: absolute;
1237
+ top: 0;
1238
+ left: 0;
1239
+ width: ${e=>e.$width}px;
1240
+ background: ${e=>e.$color};
1241
+ height: 100%;
1242
+ z-index: 100;
1243
+ pointer-events: none;
1244
+ will-change: transform;
1245
+ `,ni=({color:e="#ff0000",controlsOffset:t=0})=>{const n=i.useRef(null),a=i.useRef(null),{isPlaying:r,currentTimeRef:s}=At(),{samplesPerPixel:o,sampleRate:l,progressBarWidth:c}=$t();return i.useEffect(()=>{const u=()=>{if(n.current){const v=(s.current??0)*l/o+t;n.current.style.transform=`translate3d(${v}px, 0, 0)`}r&&(a.current=requestAnimationFrame(u))};return r?a.current=requestAnimationFrame(u):u(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[r,l,o,t,s]),i.useEffect(()=>{if(!r&&n.current){const d=(s.current??0)*l/o+t;n.current.style.transform=`translate3d(${d}px, 0, 0)`}}),b.jsx(ti,{ref:n,$color:e,$width:c,"data-playhead":!0})},ai=S.div`
1246
+ position: relative;
1247
+ `,ri=S.div`
1248
+ position: absolute;
1249
+ top: ${e=>e.$top}px;
1250
+ left: 0;
1251
+ width: ${e=>e.$width}px;
1252
+ height: ${e=>e.$height}px;
1253
+ background: ${e=>e.$color};
1254
+ z-index: 0;
1255
+ transform: translateZ(0);
1256
+ backface-visibility: hidden;
1257
+ will-change: transform;
1258
+ `,oi=S.div`
1259
+ position: absolute;
1260
+ top: ${e=>e.$top}px;
1261
+ left: 0;
1262
+ height: ${e=>e.$height}px;
1263
+ background: ${e=>e.$color};
1264
+ pointer-events: none;
1265
+ z-index: 1;
1266
+ will-change: width;
1267
+ `,si=S.div`
1268
+ position: relative;
1269
+ z-index: 2;
1270
+ `,ii=({clipStartSample:e,clipDurationSamples:t,...n})=>{const a=i.useRef(null),r=i.useRef(null),s=ut(),{waveHeight:o}=ct(),{isPlaying:l,currentTimeRef:c}=At(),{samplesPerPixel:u,sampleRate:d}=$t(),v=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";i.useEffect(()=>{const y=()=>{if(a.current){const g=(c.current??0)*d,I=e+t;let x=0;if(g<=e)x=0;else if(g>=I)x=n.length;else{const h=g-e;x=Math.floor(h/u)}a.current.style.width=`${x}px`}l&&(r.current=requestAnimationFrame(y))};return l?r.current=requestAnimationFrame(y):y(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[l,d,u,e,t,n.length,c]),i.useEffect(()=>{if(!l&&a.current){const m=(c.current??0)*d,g=e+t;let I=0;if(m<=e)I=0;else if(m>=g)I=n.length;else{const x=m-e;I=Math.floor(x/u)}a.current.style.width=`${I}px`}});const p=s?.waveformDrawMode||"inverted";let f;p==="inverted"?f=s?.selectedWaveFillColor||s?.waveFillColor||"white":f=s?.selectedWaveOutlineColor||s?.waveOutlineColor||"grey";const C=Ue(f);return b.jsxs(ai,{children:[b.jsx(ri,{$color:C,$height:o,$top:n.index*o,$width:n.length}),b.jsx(oi,{ref:a,$color:v,$height:o,$top:n.index*o}),b.jsx(si,{children:b.jsx(_n,{...n,isSelected:!0,transparentBackground:!0})})]})},li=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:n,editable:a=!1,onAnnotationUpdate:r,scrollActivePosition:s="center",scrollActiveContainer:o="nearest",className:l})=>{const c=ut(),{isPlaying:u,currentTimeRef:d}=At(),{annotations:v,activeAnnotationId:p,continuousPlay:f}=ia(),{play:C,seekTo:y,setActiveAnnotationId:m,setAnnotations:g,setScrollContainer:I}=la(),{duration:x,peaksDataArray:h,sampleRate:w,waveHeight:k,timeScaleHeight:A,samplesPerPixel:M,controls:$,playoutRef:E,barWidth:R,barGap:T}=$t(),[D,z]=i.useState(0),[V,_]=i.useState(0),[L,X]=i.useState(!1),F=i.useRef(null),K=i.useCallback(Y=>{F.current=Y,I(Y)},[I]),ae=Math.floor(x*w/M),te=i.useCallback(async Y=>{m(Y.id),C(Y.start)},[m,C]),q=i.useCallback(Y=>{g(Y),r?.(Y)},[g,r]),{onDragStart:ne,onDragMove:be,onDragEnd:he}=Un({annotations:v,onAnnotationsChange:q,samplesPerPixel:M,sampleRate:w,duration:x,linkEndpoints:!0}),Xe=i.useCallback(Y=>{const le=Y.currentTarget.getBoundingClientRect(),Q=$.show?$.width:0,ce=(Y.clientX-le.left-Q)*M/w;X(!0),z(ce),_(ce)},[$,M,w]),je=i.useCallback(Y=>{if(!L)return;const le=Y.currentTarget.getBoundingClientRect(),Q=$.show?$.width:0,ce=(Y.clientX-le.left-Q)*M/w;_(ce)},[L,$,M,w]),ye=i.useCallback(Y=>{if(!L)return;X(!1);const le=Y.currentTarget.getBoundingClientRect(),Q=$.show?$.width:0,ce=(Y.clientX-le.left-Q)*M/w,ve=Math.min(D,ce),ee=Math.max(D,ce);Math.abs(ee-ve)<.1?(y(ve),z(ve),_(ve),u&&E.current&&(E.current.stop(),C(ve))):(z(ve),_(ee))},[L,D,M,w,$,y,u,E,C]);if(h.length===0)return b.jsx("div",{className:l,children:"Loading waveform..."});const Ge=null;return b.jsx(Tn,{children:b.jsxs(It.Provider,{value:{samplesPerPixel:M,sampleRate:w,zoomLevels:[M],waveHeight:k,timeScaleHeight:A,duration:x,controls:$,barWidth:R,barGap:T},children:[b.jsx(Ht,{theme:c,backgroundColor:Ue(c.waveOutlineColor),timescaleBackgroundColor:c.timescaleBackgroundColor,scrollContainerWidth:ae+($.show?$.width:0),timescaleWidth:ae,tracksWidth:ae,controlsWidth:$.show?$.width:0,onTracksMouseDown:Xe,onTracksMouseMove:je,onTracksMouseUp:ye,scrollContainerRef:K,isSelecting:L,timescale:A>0?b.jsx(Fn,{duration:x*1e3,marker:1e4,bigStep:5e3,secondStep:1e3}):void 0,children:b.jsxs(b.Fragment,{children:[h.map((Y,le)=>{const Q=Y.length>0?Math.max(...Y.map(J=>J.peaks.data.length)):1;return b.jsx(Xt.Provider,{value:Ge,children:b.jsx(Zn,{numChannels:Q,backgroundColor:Ue(c.waveOutlineColor),offset:0,width:ae,hasClipHeaders:!1,trackId:`media-element-track-${le}`,isSelected:!0,children:Y.map((J,ce)=>{const ve=J.peaks,ee=ve.length;return b.jsx(Zt,{clipId:J.clipId,trackIndex:le,clipIndex:ce,trackName:J.trackName,startSample:J.startSample,durationSamples:J.durationSamples,samplesPerPixel:M,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${le}`,children:ve.data.map((Ve,He)=>b.jsx(ii,{index:He,data:Ve,bits:ve.bits,length:ee,clipStartSample:J.startSample,clipDurationSamples:J.durationSamples},`${le}-${ce}-${He}`))},`${le}-${ce}`)})})},le)}),v.length>0&&b.jsx(Ee.DndContext,{onDragStart:ne,onDragMove:be,onDragEnd:he,modifiers:a?[Wa.restrictToHorizontalAxis]:[],children:b.jsx(Gn,{height:30,width:ae,children:v.map((Y,le)=>{const Q=Y.start*w/M,J=Y.end*w/M,ce=t?t(Y,le):Y.id;return b.jsx(Xn,{annotationId:Y.id,annotationIndex:le,startPosition:Q,endPosition:J,label:ce,color:"#ff9800",isActive:Y.id===p,onClick:()=>te(Y),editable:a},Y.id)})})}),D!==V&&b.jsx(En,{startPosition:Math.min(D,V)*w/M+($.show?$.width:0),endPosition:Math.max(D,V)*w/M+($.show?$.width:0),color:c.selectionColor}),b.jsx(ni,{color:c.playheadColor,controlsOffset:$.show?$.width:0})]})}),v.length>0&&b.jsx(Nn,{annotations:v,activeAnnotationId:p??void 0,shouldScrollToActive:!0,scrollActivePosition:s,scrollActiveContainer:o,editable:a,annotationListConfig:{linkEndpoints:!0,continuousPlay:f},height:e,onAnnotationUpdate:q,renderAnnotationItem:n})]})})};exports.Tone=vn;exports.AudioPosition=Ps;exports.AutomaticScrollCheckbox=js;exports.ContinuousPlayCheckbox=Hs;exports.DownloadAnnotationsButton=Ns;exports.EditableCheckbox=Gs;exports.ExportWavButton=Ls;exports.FastForwardButton=Rs;exports.LinkEndpointsCheckbox=Xs;exports.LoopButton=Bs;exports.MasterVolumeControl=Fs;exports.MediaElementPlaylistProvider=Is;exports.MediaElementWaveform=li;exports.PauseButton=As;exports.PlayButton=Ss;exports.RewindButton=Ms;exports.SelectionTimeInputs=zs;exports.SetLoopRegionButton=Ts;exports.SkipBackwardButton=Es;exports.SkipForwardButton=Ds;exports.StopButton=$s;exports.TimeFormatSelect=Zs;exports.Waveform=ei;exports.WaveformPlaylistProvider=xs;exports.ZoomInButton=Ws;exports.ZoomOutButton=_s;exports.createEffectChain=fs;exports.createEffectInstance=lt;exports.effectCategories=ls;exports.effectDefinitions=dt;exports.getEffectDefinition=Nt;exports.getEffectsByCategory=is;exports.getShortcutLabel=No;exports.getWaveformDataMetadata=mo;exports.loadPeaksFromWaveformData=fo;exports.loadWaveformData=Gt;exports.useAnnotationDragHandlers=Un;exports.useAnnotationKeyboardControls=Yo;exports.useAudioTracks=zo;exports.useClipDragHandlers=jo;exports.useClipSplitting=Go;exports.useDragSensors=Xo;exports.useDynamicEffects=ms;exports.useExportWav=Jn;exports.useIntegratedRecording=ss;exports.useKeyboardShortcuts=xt;exports.useMasterAnalyser=Zo;exports.useMasterVolume=On;exports.useMediaElementAnimation=At;exports.useMediaElementControls=la;exports.useMediaElementData=$t;exports.useMediaElementState=ia;exports.usePlaybackAnimation=Ae;exports.usePlaybackShortcuts=Lo;exports.usePlaylistControls=me;exports.usePlaylistData=ke;exports.usePlaylistState=Te;exports.useTimeFormat=Ln;exports.useTrackDynamicEffects=hs;exports.useWaveformPlaylist=ws;exports.useZoomControls=Yn;exports.waveformDataToPeaks=zn;
1254
1271
  //# sourceMappingURL=index.js.map