@waveform-playlist/browser 5.0.0-alpha.6 → 5.0.0-alpha.8
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.d.ts +69 -11
- package/dist/index.js +180 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5046 -4714
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Ca=Object.create;var Pn=Object.defineProperty;var xa=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var ya=Object.getPrototypeOf,Ia=Object.prototype.hasOwnProperty;var Sa=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of wa(t))!Ia.call(e,a)&&a!==n&&Pn(e,a,{get:()=>t[a],enumerable:!(r=xa(t,a))||r.enumerable});return e};var Aa=(e,t,n)=>(n=e!=null?Ca(ya(e)):{},Sa(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),J=Fr(c);var Vt={exports:{}},kt={};var Vn;function ka(){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 i in a)i!=="key"&&(s[i]=a[i])}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 $a(){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===T?null:A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case v:return"Fragment";case C:return"Profiler";case m:return"StrictMode";case I:return"Suspense";case E:return"SuspenseList";case B: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 b:return A.displayName||"Context";case w: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 D:return j=A.displayName||null,j!==null?j:e(A.type)||"Memo";case _: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,K=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.",K),t(A)}}function r(A){if(A===v)return"<>";if(typeof A=="object"&&A!==null&&A.$$typeof===_)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 i(A,j){function H(){G||(G=!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 l(){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,K,be,Be){var ie=H.ref;return A={$$typeof:x,type:A,key:j,props:H,_owner:K},(ie!==void 0?ie:null)!==null?Object.defineProperty(A,"ref",{enumerable:!1,get:l}):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:be}),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,K,be,Be){var ie=j.children;if(ie!==void 0)if(K)if(O(ie)){for(K=0;K<ie.length;K++)g(ie[K]);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 g(ie);if(W.call(j,"key")){ie=e(A);var De=Object.keys(j).filter(function(he){return he!=="key"});K=0<De.length?"{key: someKey, "+De.join(": ..., ")+": ...}":"{key: someKey}",oe[ie+K]||(De=0<De.length?"{"+De.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,Q,ue,ye,ue),oe[ue+Q]=!0)}if(ue=null,G!==void 0&&(n(G),ue=""+G),o(z)&&(n(z.key),ue=""+z.key),"key"in z){G={};for(var le in z)le!=="key"&&(G[le]=z[le])}else G=z;return ue&&i(G,typeof S=="function"?S.displayName||S.name||"Unknown":S),u(S,ue,G,a(),se,fe)}function b(S){p(S)?S._store&&(S._store.validated=1):typeof S=="object"&&S!==null&&S.$$typeof===_&&(S._payload.status==="fulfilled"?p(S._payload.value)&&S._payload.value._store&&(S._payload.value._store.validated=1):S._store&&(S._store.validated=1))}function p(S){return typeof S=="object"&&S!==null&&S.$$typeof===x}var f=c,x=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),g=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),j=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=Object.prototype.hasOwnProperty,X=Array.isArray,Y=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(S){return S()}};var K,te={},re=f.react_stack_bottom_frame.bind(f,s)(),L=Y(r(s)),oe={};mt.Fragment=v,mt.jsx=function(S,z,G){var Q=1e4>j.recentlyCreatedOwnerStacks++;return d(S,z,G,!1,Q?Error("react-stack-top-frame"):re,Q?Y(r(S)):L)},mt.jsxs=function(S,z,G){var Q=1e4>j.recentlyCreatedOwnerStacks++;return d(S,z,G,!0,Q?Error("react-stack-top-frame"):re,Q?Y(r(S)):L)}})()),mt}var _n;function va(){return _n||(_n=1,process.env.NODE_ENV==="production"?Et.exports=ga():Et.exports=ba()),Et.exports}var O=va();function Mn(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 Ca(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 xa(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 wa(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 Rr(e,t,n){switch(e){case"linear":return Mn(t,n);case"exponential":return Ca(t,n);case"sCurve":return xa(t,n);case"logarithmic":return wa(t,n);default:return Mn(t,n)}}function Bn(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=Rr(r,1e4,!0),i=new Float32Array(o.length),l=s-a;for(let u=0;u<o.length;u++)i[u]=a+o[u]*l;e.setValueCurveAtTime(i,t,n)}}function Wn(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=Rr(r,1e4,!1),i=new Float32Array(o.length),l=a-s;for(let u=0;u<o.length;u++)i[u]=s+o[u]*l;e.setValueCurveAtTime(i,t,n)}}var ya=class{constructor(e){this.activePlayers=0,this.track=e.track,this.volumeNode=new V.Volume(this.gainToDb(e.track.gain)),this.panNode=new V.Panner(e.track.stereoPan),this.muteGain=new V.Gain(e.track.muted?0:1);const t=e.destination||V.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 V.Player({url:r.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),s=new V.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 i=r.fadeIn.duration;if(o<=0)Bn(s,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,u=o/i,d=r.gain*u;Bn(s,t,l,r.fadeIn.type||"linear",d,r.gain)}}else s.setValueAtTime(r.gain,t);if(r.fadeOut){const l=r.duration-r.fadeOut.duration-o;if(l>0){const u=t+l;Wn(s,u,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const u=-l,d=r.fadeOut.duration-u,b=u/r.fadeOut.duration,p=r.gain*(1-b);Wn(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){const r=e??V.now();this.isPlaying&&this.stop(),this.activePlayers=0,this.clips.forEach(a=>{const{player:s,clipInfo:o}=a,i=t,l=o.startTime,u=o.startTime+o.duration;if(i<u)if(this.activePlayers++,a.playStartTime=V.now(),i>=l){const d=i-l+o.offset,b=o.duration-(i-l),p=n?Math.min(n,b):b;a.pausedPosition=d,this.scheduleFades(a,r,d),s.start(r,d,p)}else{const d=l-i,b=n?Math.min(n-d,o.duration):o.duration;d<(n??1/0)?(a.pausedPosition=o.offset,this.scheduleFades(a,r+d,o.offset),s.start(r+d,o.offset,b)):this.activePlayers--}})}pause(){this.clips.forEach(e=>{if(e.player.state==="started"){const t=(V.now()-e.playStartTime)*e.player.playbackRate;e.pausedPosition=e.pausedPosition+t}e.player.stop()}),this.activePlayers=0}stop(e){const t=e??V.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}},Ia=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 V.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,V.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 V.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new ya(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??V.now(),a=t??0;this.playbackSessionId++;const s=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const i=o.startTime;if(a>=i){const l=a-i;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,l,n)}else{const l=i-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+l,0,n)}}),t!==void 0?V.getTransport().start(r,t):V.getTransport().start(r)}pause(){V.getTransport().pause(),this.tracks.forEach(e=>{e.pause()})}stop(){V.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 V.getTransport().seconds}seekTo(e){V.getTransport().seconds=e}dispose(){this.tracks.forEach(e=>{e.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return V.getContext()}get sampleRate(){return V.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Tt=null;function Aa(){return Tt||(Tt=new V.Context,V.setContext(Tt)),Tt}async function en(){const e=Aa();e.state!=="running"&&await e.resume()}var Dt={exports:{}},pt={};var Fn;function Sa(){if(Fn)return pt;Fn=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(i,l,u){var d,b={},p=null,f=null;u!==void 0&&(p=""+u),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(b[d]=l[d]);if(i&&i.defaultProps)for(d in l=i.defaultProps,l)b[d]===void 0&&(b[d]=l[d]);return{$$typeof:t,type:i,key:p,ref:f,props:b,_owner:a.current}}return pt.Fragment=n,pt.jsx=o,pt.jsxs=o,pt}var gt={};var Pn;function ka(){return Pn||(Pn=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"),i=Symbol.for("react.context"),l=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"),x=Symbol.iterator,y="@@iterator";function v(h){if(h===null||typeof h!="object")return null;var R=x&&h[x]||h[y];return typeof R=="function"?R:null}var m=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(h){{for(var R=arguments.length,P=new Array(R>1?R-1:0),q=1;q<R;q++)P[q-1]=arguments[q];w("error",h,P)}}function w(h,R,P){{var q=m.ReactDebugCurrentFrame,ie=q.getStackAddendum();ie!==""&&(R+="%s",P=P.concat([ie]));var T=P.map(function(B){return String(B)});T.unshift("Warning: "+R),Function.prototype.apply.call(console[h],console,T)}}var g=!1,A=!1,I=!1,D=!1,F=!1,_;_=Symbol.for("react.module.reference");function M(h){return!!(typeof h=="string"||typeof h=="function"||h===r||h===s||F||h===a||h===u||h===d||D||h===f||g||A||I||typeof h=="object"&&h!==null&&(h.$$typeof===p||h.$$typeof===b||h.$$typeof===o||h.$$typeof===i||h.$$typeof===l||h.$$typeof===_||h.getModuleId!==void 0))}function $(h,R,P){var q=h.displayName;if(q)return q;var ie=R.displayName||R.name||"";return ie!==""?P+"("+ie+")":P}function j(h){return h.displayName||"Context"}function Z(h){if(h==null)return null;if(typeof h.tag=="number"&&C("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 i:var R=h;return j(R)+".Consumer";case o:var P=h;return j(P._context)+".Provider";case l:return $(h,h.render,"ForwardRef");case b:var q=h.displayName||null;return q!==null?q:Z(h.type)||"Memo";case p:{var ie=h,T=ie._payload,B=ie._init;try{return Z(B(T))}catch{return null}}}return null}var X=Object.assign,Y=0,K,te,re,L,oe,S,z;function G(){}G.__reactDisabledLog=!0;function Q(){{if(Y===0){K=console.log,te=console.info,re=console.warn,L=console.error,oe=console.group,S=console.groupCollapsed,z=console.groupEnd;var h={configurable:!0,enumerable:!0,value:G,writable:!0};Object.defineProperties(console,{info:h,log:h,warn:h,error:h,group:h,groupCollapsed:h,groupEnd:h})}Y++}}function se(){{if(Y--,Y===0){var h={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:X({},h,{value:K}),info:X({},h,{value:te}),warn:X({},h,{value:re}),error:X({},h,{value:L}),group:X({},h,{value:oe}),groupCollapsed:X({},h,{value:S}),groupEnd:X({},h,{value:z})})}Y<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var fe=m.ReactCurrentDispatcher,ue;function ye(h,R,P){{if(ue===void 0)try{throw Error()}catch(ie){var q=ie.stack.trim().match(/\n( *(at )?)/);ue=q&&q[1]||""}return`
|
|
7
|
-
`+
|
|
8
|
-
`),U
|
|
9
|
-
`),
|
|
10
|
-
`+
|
|
6
|
+
<%s key={someKey} {...props} />`,K,ie,De,ie),oe[ie+K]=!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&&i(H,typeof A=="function"?A.displayName||A.name||"Unknown":A),u(A,ie,H,a(),be,Be)}function g(A){p(A)?A._store&&(A._store.validated=1):typeof A=="object"&&A!==null&&A.$$typeof===_&&(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===x}var f=c,x=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),b=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),T=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,X=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(A){return A()}};var G,ee={},re=f.react_stack_bottom_frame.bind(f,s)(),L=X(r(s)),oe={};$t.Fragment=v,$t.jsx=function(A,j,H){var K=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!1,K?Error("react-stack-top-frame"):re,K?X(r(A)):L)},$t.jsxs=function(A,j,H){var K=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!0,K?Error("react-stack-top-frame"):re,K?X(r(A)):L)}})()),$t}var zn;function Ra(){return zn||(zn=1,process.env.NODE_ENV==="production"?Vt.exports=ka():Vt.exports=$a()),Vt.exports}var Z=Ra();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 Ea(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 Da(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 Ea(t,n);case"sCurve":return Ta(t,n);case"logarithmic":return Da(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),i=new Float32Array(o.length),l=s-a;for(let u=0;u<o.length;u++)i[u]=a+o[u]*l;e.setValueCurveAtTime(i,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),i=new Float32Array(o.length),l=a-s;for(let u=0;u<o.length;u++)i[u]=s+o[u]*l;e.setValueCurveAtTime(i,t,n)}}var _a=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 i=r.fadeIn.duration;if(o<=0)Nn(s,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,u=o/i,d=r.gain*u;Nn(s,t,l,r.fadeIn.type||"linear",d,r.gain)}}else s.setValueAtTime(r.gain,t);if(r.fadeOut){const l=r.duration-r.fadeOut.duration-o;if(l>0){const u=t+l;Ln(s,u,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const u=-l,d=r.fadeOut.duration-u,g=u/r.fadeOut.duration,p=r.gain*(1-g);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){const r=e??P.now();this.isPlaying&&this.stop(),this.activePlayers=0,this.clips.forEach(a=>{const{player:s,clipInfo:o}=a,i=t,l=o.startTime,u=o.startTime+o.duration;if(i<u)if(this.activePlayers++,a.playStartTime=P.now(),i>=l){const d=i-l+o.offset,g=o.duration-(i-l),p=n?Math.min(n,g):g;a.pausedPosition=d,this.scheduleFades(a,r,d),s.start(r,d,p)}else{const d=l-i,g=n?Math.min(n-d,o.duration):o.duration;d<(n??1/0)?(a.pausedPosition=o.offset,this.scheduleFades(a,r+d,o.offset),s.start(r+d,o.offset,g)):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}},Ma=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 _a(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 i=o.startTime;if(a>=i){const l=a-i;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,l,n)}else{const l=i-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+l,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}},jt=null;function Ba(){return jt||(jt=new P.Context,P.setContext(jt)),jt}async function un(){const e=Ba();e.state!=="running"&&await e.resume()}var zt={exports:{}},Rt={};var Xn;function Fa(){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(i,l,u){var d,g={},p=null,f=null;u!==void 0&&(p=""+u),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(g[d]=l[d]);if(i&&i.defaultProps)for(d in l=i.defaultProps,l)g[d]===void 0&&(g[d]=l[d]);return{$$typeof:t,type:i,key:p,ref:f,props:g,_owner:a.current}}return Rt.Fragment=n,Rt.jsx=o,Rt.jsxs=o,Rt}var Et={};var Hn;function Wa(){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"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),x=Symbol.iterator,y="@@iterator";function v(h){if(h===null||typeof h!="object")return null;var $=x&&h[x]||h[y];return typeof $=="function"?$:null}var m=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(h){{for(var $=arguments.length,F=new Array($>1?$-1:0),U=1;U<$;U++)F[U-1]=arguments[U];w("error",h,F)}}function w(h,$,F){{var U=m.ReactDebugCurrentFrame,se=U.getStackAddendum();se!==""&&($+="%s",F=F.concat([se]));var ce=F.map(function(ae){return String(ae)});ce.unshift("Warning: "+$),Function.prototype.apply.call(console[h],console,ce)}}var b=!1,S=!1,I=!1,E=!1,D=!1,_;_=Symbol.for("react.module.reference");function B(h){return!!(typeof h=="string"||typeof h=="function"||h===r||h===s||D||h===a||h===u||h===d||E||h===f||b||S||I||typeof h=="object"&&h!==null&&(h.$$typeof===p||h.$$typeof===g||h.$$typeof===o||h.$$typeof===i||h.$$typeof===l||h.$$typeof===_||h.getModuleId!==void 0))}function T(h,$,F){var U=h.displayName;if(U)return U;var se=$.displayName||$.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"&&C("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 i:var $=h;return V($)+".Consumer";case o:var F=h;return V(F._context)+".Provider";case l:return T(h,h.render,"ForwardRef");case g:var U=h.displayName||null;return U!==null?U: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,X=0,G,ee,re,L,oe,A,j;function H(){}H.__reactDisabledLog=!0;function K(){{if(X===0){G=console.log,ee=console.info,re=console.warn,L=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})}X++}}function be(){{if(X--,X===0){var h={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},h,{value:G}),info:O({},h,{value:ee}),warn:O({},h,{value:re}),error:O({},h,{value:L}),group:O({},h,{value:oe}),groupCollapsed:O({},h,{value:A}),groupEnd:O({},h,{value:j})})}X<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Be=m.ReactCurrentDispatcher,ie;function De(h,$,F){{if(ie===void 0)try{throw Error()}catch(se){var U=se.stack.trim().match(/\n( *(at )?)/);ie=U&&U[1]||""}return`
|
|
7
|
+
`+ie+h}}var ue=!1,he;{var gt=typeof WeakMap=="function"?WeakMap:Map;he=new gt}function ut(h,$){if(!h||ue)return"";{var F=he.get(h);if(F!==void 0)return F}var U;ue=!0;var se=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ce;ce=Be.current,Be.current=null,K();try{if($){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(M){U=M}Reflect.construct(h,[],ae)}else{try{ae.call()}catch(M){U=M}h.call(ae.prototype)}}else{try{throw Error()}catch(M){U=M}h()}}catch(M){if(M&&U&&typeof M.stack=="string"){for(var ne=M.stack.split(`
|
|
8
|
+
`),ke=U.stack.split(`
|
|
9
|
+
`),pe=ne.length-1,Ce=ke.length-1;pe>=1&&Ce>=0&&ne[pe]!==ke[Ce];)Ce--;for(;pe>=1&&Ce>=0;pe--,Ce--)if(ne[pe]!==ke[Ce]){if(pe!==1||Ce!==1)do if(pe--,Ce--,Ce<0||ne[pe]!==ke[Ce]){var Me=`
|
|
10
|
+
`+ne[pe].replace(" at new "," at ");return h.displayName&&Me.includes("<anonymous>")&&(Me=Me.replace("<anonymous>",h.displayName)),typeof h=="function"&&he.set(h,Me),Me}while(pe>=1&&Ce>=0);break}}}finally{ue=!1,Be.current=ce,be(),Error.prepareStackTrace=se}var it=h?h.displayName||h.name:"",et=it?De(it):"";return typeof h=="function"&&he.set(h,et),et}function de(h,$,F){return ut(h,!1)}function rt(h){var $=h.prototype;return!!($&&$.isReactComponent)}function at(h,$,F){if(h==null)return"";if(typeof h=="function")return ut(h,rt(h));if(typeof h=="string")return De(h);switch(h){case u:return De("Suspense");case d:return De("SuspenseList")}if(typeof h=="object")switch(h.$$typeof){case l:return de(h.render);case g:return at(h.type,$,F);case p:{var U=h,se=U._payload,ce=U._init;try{return at(ce(se),$,F)}catch{}}}return""}var Je=Object.prototype.hasOwnProperty,ot={},z=m.ReactDebugCurrentFrame;function Re(h){if(h){var $=h._owner,F=at(h.type,h._source,$?$.type:null);z.setExtraStackFrame(F)}else z.setExtraStackFrame(null)}function we(h,$,F,U,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((U||"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]($,ae,U,F,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pe){ne=pe}ne&&!(ne instanceof Error)&&(Re(se),C("%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).",U||"React class",F,ae,typeof ne),Re(null)),ne instanceof Error&&!(ne.message in ot)&&(ot[ne.message]=!0,Re(se),C("Failed %s type: %s",F,ne.message),Re(null))}}}var ve=Array.isArray;function Ze(h){return ve(h)}function Le(h){{var $=typeof Symbol=="function"&&Symbol.toStringTag,F=$&&h[Symbol.toStringTag]||h.constructor.name||"Object";return F}}function Pe(h){try{return Xe(h),!1}catch{return!0}}function Xe(h){return""+h}function He(h){if(Pe(h))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Le(h)),Xe(h)}var dt=m.ReactCurrentOwner,At={key:!0,ref:!0,__self:!0,__source:!0},Y,te;function me(h){if(Je.call(h,"ref")){var $=Object.getOwnPropertyDescriptor(h,"ref").get;if($&&$.isReactWarning)return!1}return h.ref!==void 0}function ye(h){if(Je.call(h,"key")){var $=Object.getOwnPropertyDescriptor(h,"key").get;if($&&$.isReactWarning)return!1}return h.key!==void 0}function Ee(h,$){typeof h.ref=="string"&&dt.current}function Ae(h,$){{var F=function(){Y||(Y=!0,C("%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)",$))};F.isReactWarning=!0,Object.defineProperty(h,"key",{get:F,configurable:!0})}}function le(h,$){{var F=function(){te||(te=!0,C("%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)",$))};F.isReactWarning=!0,Object.defineProperty(h,"ref",{get:F,configurable:!0})}}var Ge=function(h,$,F,U,se,ce,ae){var ne={$$typeof:t,type:h,key:$,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:U}),Object.defineProperty(ne,"_source",{configurable:!1,enumerable:!1,writable:!1,value:se}),Object.freeze&&(Object.freeze(ne.props),Object.freeze(ne)),ne};function Ye(h,$,F,U,se){{var ce,ae={},ne=null,ke=null;F!==void 0&&(He(F),ne=""+F),ye($)&&(He($.key),ne=""+$.key),me($)&&(ke=$.ref,Ee($,se));for(ce in $)Je.call($,ce)&&!At.hasOwnProperty(ce)&&(ae[ce]=$[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 Ce=typeof h=="function"?h.displayName||h.name||"Unknown":h;ne&&Ae(ae,Ce),ke&&le(ae,Ce)}return Ge(h,ne,ke,se,U,dt.current,ae)}}var je=m.ReactCurrentOwner,_e=m.ReactDebugCurrentFrame;function Ie(h){if(h){var $=h._owner,F=at(h.type,h._source,$?$.type:null);_e.setExtraStackFrame(F)}else _e.setExtraStackFrame(null)}var qe;qe=!1;function ft(h){return typeof h=="object"&&h!==null&&h.$$typeof===t}function Bt(){{if(je.current){var h=W(je.current.type);if(h)return`
|
|
11
11
|
|
|
12
|
-
Check the render method of \``+h+"`."}return""}}function
|
|
12
|
+
Check the render method of \``+h+"`."}return""}}function st(h){return""}var Ft={};function ht(h){{var $=Bt();if(!$){var F=typeof h=="string"?h:h.displayName||h.name;F&&($=`
|
|
13
13
|
|
|
14
|
-
Check the top-level render call using <`+
|
|
14
|
+
Check the top-level render call using <`+F+">.")}return $}}function Wt(h,$){{if(!h._store||h._store.validated||h.key!=null)return;h._store.validated=!0;var F=ht($);if(Ft[F])return;Ft[F]=!0;var U="";h&&h._owner&&h._owner!==je.current&&(U=" It was passed a child from "+W(h._owner.type)+"."),Ie(h),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',F,U),Ie(null)}}function Zt(h,$){{if(typeof h!="object")return;if(Ze(h))for(var F=0;F<h.length;F++){var U=h[F];ft(U)&&Wt(U,$)}else if(ft(h))h._store&&(h._store.validated=!0);else if(h){var se=v(h);if(typeof se=="function"&&se!==h.entries)for(var ce=se.call(h),ae;!(ae=ce.next()).done;)ft(ae.value)&&Wt(ae.value,$)}}}function bt(h){{var $=h.type;if($==null||typeof $=="string")return;var F;if(typeof $=="function")F=$.propTypes;else if(typeof $=="object"&&($.$$typeof===l||$.$$typeof===g))F=$.propTypes;else return;if(F){var U=W($);we(F,h.props,"prop",U,h)}else if($.PropTypes!==void 0&&!qe){qe=!0;var se=W($);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",se||"Unknown")}typeof $.getDefaultProps=="function"&&!$.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qe(h){{for(var $=Object.keys(h.props),F=0;F<$.length;F++){var U=$[F];if(U!=="children"&&U!=="key"){Ie(h),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",U),Ie(null);break}}h.ref!==null&&(Ie(h),C("Invalid attribute `ref` supplied to `React.Fragment`."),Ie(null))}}var Fe={};function vt(h,$,F,U,se,ce){{var ae=B(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=st();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,C("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 Ce=Ye(h,$,F,se,ce);if(Ce==null)return Ce;if(ae){var Me=$.children;if(Me!==void 0)if(U)if(Ze(Me)){for(var it=0;it<Me.length;it++)Zt(Me[it],h);Object.freeze&&Object.freeze(Me)}else C("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($,"key")){var et=W(h),M=Object.keys($).filter(function(fe){return fe!=="key"}),N=M.length>0?"{key: someKey, "+M.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[et+N]){var q=M.length>0?"{"+M.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX:
|
|
15
15
|
let props = %s;
|
|
16
16
|
<%s {...props} />
|
|
17
17
|
React keys must be passed directly to JSX without using spread:
|
|
18
18
|
let props = %s;
|
|
19
|
-
<%s key={someKey} {...props} />`,Ge,me,ft,me),St[me+Ge]=!0}}return h===r?Kt(ae):Lt(ae),ae}}function Ut(h,R,P){return kt(h,R,P,!0)}function Rt(h,R,P){return kt(h,R,P,!1)}var Jt=Rt,$t=Ut;gt.Fragment=r,gt.jsx=Jt,gt.jsxs=$t})()),gt}var Zn;function Ra(){return Zn||(Zn=1,process.env.NODE_ENV==="production"?Dt.exports=Sa():Dt.exports=ka()),Dt.exports}var E=Ra();const $a=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Vt=$a?c.useLayoutEffect:c.useEffect;function Ea(e){const t=c.useRef(e);return Vt(()=>{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 $r(e,t){t===void 0&&(t=[e]);const n=c.useRef(e);return Vt(()=>{n.current!==e&&(n.current=e)},t),n}function Wt(e){const t=Ea(e),n=c.useRef(null),r=c.useCallback(a=>{a!==n.current&&t?.(a,n.current),n.current=a},[]);return[n,r]}let tn={};function Er(e,t){return c.useMemo(()=>{const n=tn[e]==null?0:tn[e]+1;return tn[e]=n,e+"-"+n},[e,t])}const un=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[un.Translate.toString(e),un.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}});var Vn;(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"})(Vn||(Vn={}));function jn(){}const Ta=Object.freeze({x:0,y:0});var ot;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ot||(ot={}));var zn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(zn||(zn={}));var Ke;(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"})(Ke||(Ke={}));Ke.Space,Ke.Enter,Ke.Esc,Ke.Space,Ke.Enter,Ke.Tab;var On;(function(e){e[e.RightClick=2]="RightClick"})(On||(On={}));var Nn;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Nn||(Nn={}));var Hn;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Hn||(Hn={}));ot.Backward+"",ot.Forward+"",ot.Backward+"",ot.Forward+"";var dn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(dn||(dn={}));var fn;(function(e){e.Optimized="optimized"})(fn||(fn={}));function Da(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])}dn.WhileDragging,fn.Optimized;const _a={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:jn,draggableNodes:new Map,over:null,measureDroppableContainers:jn},Ma=c.createContext(_a),Ba=c.createContext({...Ta,scaleX:1,scaleY:1});var Gn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Gn||(Gn={}));const Wa=c.createContext(null),Xn="button",Fa="Draggable";function nn(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Er(Fa),{activators:o,activatorEvent:i,active:l,activeNodeRect:u,ariaDescribedById:d,draggableNodes:b,over:p}=c.useContext(Ma),{role:f=Xn,roleDescription:x="draggable",tabIndex:y=0}=a??{},v=l?.id===t,m=c.useContext(v?Ba:Wa),[C,w]=Wt(),[g,A]=Wt(),I=Da(o,t),D=$r(n);Vt(()=>(b.set(t,{id:t,key:s,node:C,activatorNode:g,data:D}),()=>{const _=b.get(t);_&&_.key===s&&b.delete(t)}),[b,t]);const F=c.useMemo(()=>({role:f,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&f===Xn?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,f,y,v,x,d.draggable]);return{active:l,activatorEvent:i,activeNodeRect:u,attributes:F,isDragging:v,listeners:r?void 0:I,node:C,over:p,setNodeRef:w,setActivatorNodeRef:A,transform:m}}const Pa=new Map([["bold",ee.createElement(ee.Fragment,null,ee.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",ee.createElement(ee.Fragment,null,ee.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),ee.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",ee.createElement(ee.Fragment,null,ee.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",ee.createElement(ee.Fragment,null,ee.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",ee.createElement(ee.Fragment,null,ee.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",ee.createElement(ee.Fragment,null,ee.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"}))]]),Za=new Map([["bold",ee.createElement(ee.Fragment,null,ee.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",ee.createElement(ee.Fragment,null,ee.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),ee.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",ee.createElement(ee.Fragment,null,ee.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",ee.createElement(ee.Fragment,null,ee.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",ee.createElement(ee.Fragment,null,ee.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",ee.createElement(ee.Fragment,null,ee.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"}))]]),Va=c.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),xn=ee.forwardRef((e,t)=>{const{alt:n,color:r,size:a,weight:s,mirrored:o,children:i,weights:l,...u}=e,{color:d="currentColor",size:b,weight:p="regular",mirrored:f=!1,...x}=ee.useContext(Va);return ee.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,...x,...u},!!n&&ee.createElement("title",null,n),i,l.get(s??p))});xn.displayName="IconBase";const Tr=ee.forwardRef((e,t)=>ee.createElement(xn,{ref:t,...e,weights:Pa}));Tr.displayName="SpeakerHighIcon";const Dr=ee.forwardRef((e,t)=>ee.createElement(xn,{ref:t,...e,weights:Za}));Dr.displayName="SpeakerLowIcon";k.span`
|
|
19
|
+
<%s key={someKey} {...props} />`,N,et,q,et),Fe[et+N]=!0}}return h===r?Qe(Ce):bt(Ce),Ce}}function nn(h,$,F){return vt(h,$,F,!0)}function rn(h,$,F){return vt(h,$,F,!1)}var an=rn,on=nn;Et.Fragment=r,Et.jsx=an,Et.jsxs=on})()),Et}var Gn;function Za(){return Gn||(Gn=1,process.env.NODE_ENV==="production"?zt.exports=Fa():zt.exports=Wa()),zt.exports}var R=Za();const Pa=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Kt=Pa?c.useLayoutEffect:c.useEffect;function Va(e){const t=c.useRef(e);return Kt(()=>{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 Kt(()=>{n.current!==e&&(n.current=e)},t),n}function Xt(e){const t=Va(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 ja=Object.freeze({x:0,y:0});var xt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(xt||(xt={}));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 lt;(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"})(lt||(lt={}));lt.Space,lt.Enter,lt.Esc,lt.Space,lt.Enter,lt.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={}));xt.Backward+"",xt.Forward+"",xt.Backward+"",xt.Forward+"";var xn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(xn||(xn={}));var wn;(function(e){e.Optimized="optimized"})(wn||(wn={}));function za(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])}xn.WhileDragging,wn.Optimized;const Oa={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Kn,draggableNodes:new Map,over:null,measureDroppableContainers:Kn},Na=c.createContext(Oa),La=c.createContext({...ja,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 Xa=c.createContext(null),tr="button",Ha="Draggable";function fn(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Vr(Ha),{activators:o,activatorEvent:i,active:l,activeNodeRect:u,ariaDescribedById:d,draggableNodes:g,over:p}=c.useContext(Na),{role:f=tr,roleDescription:x="draggable",tabIndex:y=0}=a??{},v=l?.id===t,m=c.useContext(v?La:Xa),[C,w]=Xt(),[b,S]=Xt(),I=za(o,t),E=Pr(n);Kt(()=>(g.set(t,{id:t,key:s,node:C,activatorNode:b,data:E}),()=>{const _=g.get(t);_&&_.key===s&&g.delete(t)}),[g,t]);const D=c.useMemo(()=>({role:f,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&f===tr?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,f,y,v,x,d.draggable]);return{active:l,activatorEvent:i,activeNodeRect:u,attributes:D,isDragging:v,listeners:r?void 0:I,node:C,over:p,setNodeRef:w,setActivatorNodeRef:S,transform:m}}const Ga=new Map([["bold",J.createElement(J.Fragment,null,J.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",J.createElement(J.Fragment,null,J.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),J.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",J.createElement(J.Fragment,null,J.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",J.createElement(J.Fragment,null,J.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",J.createElement(J.Fragment,null,J.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",J.createElement(J.Fragment,null,J.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"}))]]),Ya=new Map([["bold",J.createElement(J.Fragment,null,J.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",J.createElement(J.Fragment,null,J.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),J.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",J.createElement(J.Fragment,null,J.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",J.createElement(J.Fragment,null,J.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",J.createElement(J.Fragment,null,J.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",J.createElement(J.Fragment,null,J.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"}))]]),Ka=c.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),En=J.forwardRef((e,t)=>{const{alt:n,color:r,size:a,weight:s,mirrored:o,children:i,weights:l,...u}=e,{color:d="currentColor",size:g,weight:p="regular",mirrored:f=!1,...x}=J.useContext(Ka);return J.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:a??g,height:a??g,fill:r??d,viewBox:"0 0 256 256",transform:o||f?"scale(-1, 1)":void 0,...x,...u},!!n&&J.createElement("title",null,n),i,l.get(s??p))});En.displayName="IconBase";const jr=J.forwardRef((e,t)=>J.createElement(En,{ref:t,...e,weights:Ga}));jr.displayName="SpeakerHighIcon";const zr=J.forwardRef((e,t)=>J.createElement(En,{ref:t,...e,weights:Ya}));zr.displayName="SpeakerLowIcon";k.span`
|
|
20
20
|
font-family: 'Courier New', Monaco, monospace;
|
|
21
21
|
font-size: 1rem;
|
|
22
22
|
font-weight: 600;
|
|
23
23
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
24
24
|
user-select: none;
|
|
25
|
-
`;var
|
|
25
|
+
`;var Tn=k.button`
|
|
26
26
|
display: inline-flex;
|
|
27
27
|
align-items: center;
|
|
28
28
|
justify-content: center;
|
|
@@ -51,30 +51,30 @@ React keys must be passed directly to JSX without using spread:
|
|
|
51
51
|
opacity: 0.6;
|
|
52
52
|
cursor: not-allowed;
|
|
53
53
|
}
|
|
54
|
-
`;k(
|
|
54
|
+
`;k(Tn)`
|
|
55
55
|
padding: 0.25rem 0.5rem;
|
|
56
56
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
57
|
-
`;k(
|
|
57
|
+
`;k(Tn)`
|
|
58
58
|
padding: 0.5rem;
|
|
59
59
|
min-width: 2.25rem;
|
|
60
60
|
min-height: 2.25rem;
|
|
61
|
-
`;k(
|
|
61
|
+
`;k(Tn)`
|
|
62
62
|
padding: 0.25rem;
|
|
63
63
|
min-width: 1.75rem;
|
|
64
64
|
min-height: 1.75rem;
|
|
65
65
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
66
|
-
`;var
|
|
66
|
+
`;var Ut=k.div`
|
|
67
67
|
display: inline-flex;
|
|
68
68
|
align-items: center;
|
|
69
69
|
gap: 0.5rem;
|
|
70
|
-
`,
|
|
70
|
+
`,Jt=k.input`
|
|
71
71
|
cursor: pointer;
|
|
72
72
|
accent-color: ${e=>e.theme.inputFocusBorder};
|
|
73
73
|
|
|
74
74
|
&:disabled {
|
|
75
75
|
cursor: not-allowed;
|
|
76
76
|
}
|
|
77
|
-
`,
|
|
77
|
+
`,qt=k.label`
|
|
78
78
|
margin: 0;
|
|
79
79
|
cursor: pointer;
|
|
80
80
|
user-select: none;
|
|
@@ -107,7 +107,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
107
107
|
cursor: not-allowed;
|
|
108
108
|
opacity: 0.6;
|
|
109
109
|
}
|
|
110
|
-
`,
|
|
110
|
+
`,Or=k.input`
|
|
111
111
|
padding: 0.5rem 0.75rem;
|
|
112
112
|
font-family: ${e=>e.theme.fontFamily};
|
|
113
113
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -131,10 +131,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
131
131
|
opacity: 0.6;
|
|
132
132
|
cursor: not-allowed;
|
|
133
133
|
}
|
|
134
|
-
`;k(
|
|
134
|
+
`;k(Or)`
|
|
135
135
|
padding: 0.25rem 0.5rem;
|
|
136
136
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
137
|
-
`;var
|
|
137
|
+
`;var Nr=k.label`
|
|
138
138
|
font-family: ${e=>e.theme.fontFamily};
|
|
139
139
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
140
140
|
font-weight: 500;
|
|
@@ -149,7 +149,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
149
149
|
align-items: center;
|
|
150
150
|
gap: 0.5rem;
|
|
151
151
|
cursor: pointer;
|
|
152
|
-
`;var
|
|
152
|
+
`;var Ua=k.span`
|
|
153
153
|
position: absolute;
|
|
154
154
|
width: 1px;
|
|
155
155
|
height: 1px;
|
|
@@ -159,7 +159,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
159
159
|
clip: rect(0, 0, 0, 0);
|
|
160
160
|
white-space: nowrap;
|
|
161
161
|
border: 0;
|
|
162
|
-
`,
|
|
162
|
+
`,Dn=k.select`
|
|
163
163
|
padding: 0.5rem 2rem 0.5rem 0.75rem;
|
|
164
164
|
font-family: ${e=>e.theme.fontFamily};
|
|
165
165
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -190,10 +190,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
190
190
|
color: ${e=>e.theme.inputText};
|
|
191
191
|
background-color: ${e=>e.theme.inputBackground};
|
|
192
192
|
}
|
|
193
|
-
`;k(
|
|
193
|
+
`;k(Dn)`
|
|
194
194
|
padding: 0.25rem 1.75rem 0.25rem 0.5rem;
|
|
195
195
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
196
|
-
`;var
|
|
196
|
+
`;var Lr=k.input.attrs({type:"range"})`
|
|
197
197
|
-webkit-appearance: none;
|
|
198
198
|
appearance: none;
|
|
199
199
|
width: 100%;
|
|
@@ -269,7 +269,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
269
269
|
&:disabled::-moz-range-thumb {
|
|
270
270
|
cursor: not-allowed;
|
|
271
271
|
}
|
|
272
|
-
`,
|
|
272
|
+
`,Ja=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return R.jsxs(Ut,{className:r,children:[R.jsx(Jt,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:a,disabled:n}),R.jsx(qt,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Xr(e){return typeof e=="object"&&e!==null&&"type"in e}function Ht(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"},Qa=1e3;function eo(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 to=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
273
273
|
float: left;
|
|
274
274
|
position: relative;
|
|
275
275
|
/* Promote to own compositing layer for smoother scrolling */
|
|
@@ -277,15 +277,15 @@ React keys must be passed directly to JSX without using spread:
|
|
|
277
277
|
/* Disable image rendering interpolation */
|
|
278
278
|
image-rendering: pixelated;
|
|
279
279
|
image-rendering: crisp-edges;
|
|
280
|
-
`,
|
|
280
|
+
`,no=k.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
281
281
|
position: absolute;
|
|
282
282
|
background: ${e=>e.$waveFillColor};
|
|
283
283
|
/* Force GPU compositing layer to reduce scroll flickering */
|
|
284
284
|
transform: translateZ(0);
|
|
285
285
|
backface-visibility: hidden;
|
|
286
|
-
`,
|
|
286
|
+
`,ro=e=>{const{data:t,bits:n,length:r,index:a,className:s,devicePixelRatio:o=1,waveHeight:i=80,waveOutlineColor:l="#E0EFF1",waveFillColor:u="grey",barWidth:d=1,barGap:g=0,transparentBackground:p=!1,drawMode:f="inverted"}=e,x=c.useRef([]),y=c.useCallback(S=>{if(S!==null){const I=parseInt(S.dataset.index,10);x.current[I]=S}},[]);c.useLayoutEffect(()=>{const S=x.current,I=d+g;let E=0;for(let D=0;D<S.length;D++){const _=S[D],B=_.getContext("2d"),T=Math.floor(i/2),V=2**(n-1);if(B){B.resetTransform(),B.clearRect(0,0,_.width,_.height),B.imageSmoothingEnabled=!1,B.scale(o,o);const W=_.width/o;let O;f==="normal"?O=u:O=l,B.fillStyle=eo(B,O,W,i);const X=E,G=E+W,ee=Math.floor((X-d+I)/I)*I;for(let re=Math.max(0,ee);re<G;re+=I){const L=re-X;if(L+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*T),K=Math.abs(j*T);f==="normal"?B.fillRect(L,T-K,d,K+H):(B.fillRect(L,0,d,T-K),B.fillRect(L,T+H,d,T-H))}}}E+=_.width/o}},[t,n,i,l,u,o,r,d,g,f]);let v=r,m=0;const C=[];for(;v>0;){const S=Math.min(v,Qa),I=R.jsx(to,{$cssWidth:S,width:S*o,height:i*o,$waveHeight:i,"data-index":m,ref:y},`${r}-${m}`);C.push(I),v-=S,m+=1}const b=p?"transparent":Ht(u);return R.jsx(no,{$index:a,$cssWidth:r,className:s,$waveHeight:i,$waveFillColor:b,children:C})},Hr=22,Gr=k.div`
|
|
287
287
|
position: relative;
|
|
288
|
-
height: ${
|
|
288
|
+
height: ${Hr}px;
|
|
289
289
|
background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
|
|
290
290
|
border-bottom: 1px solid ${e=>e.theme.clipHeaderBorderColor};
|
|
291
291
|
display: flex;
|
|
@@ -307,7 +307,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
307
307
|
cursor: grabbing;
|
|
308
308
|
}
|
|
309
309
|
`}
|
|
310
|
-
`,
|
|
310
|
+
`,Yr=k.span`
|
|
311
311
|
font-size: 11px;
|
|
312
312
|
font-weight: 600;
|
|
313
313
|
font-family: ${e=>e.theme.clipHeaderFontFamily};
|
|
@@ -315,12 +315,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
315
315
|
white-space: nowrap;
|
|
316
316
|
overflow: hidden;
|
|
317
317
|
text-overflow: ellipsis;
|
|
318
|
-
`,
|
|
318
|
+
`,ao=({trackName:e,isSelected:t=!1})=>R.jsx(Gr,{$isDragging:!1,$interactive:!1,$isSelected:t,children:R.jsx(Yr,{children:e})}),oo=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:a=!1,disableDrag:s=!1,dragHandleProps:o})=>{if(s||!o)return R.jsx(ao,{trackName:r,isSelected:a});const{attributes:i,listeners:l,setActivatorNodeRef:u}=o;return R.jsx(Gr,{ref:u,"data-clip-id":e,$interactive:!0,$isSelected:a,...l,...i,children:R.jsx(Yr,{children:r})})},so=8,io=24,lo=k.div`
|
|
319
319
|
position: absolute;
|
|
320
320
|
${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
|
|
321
321
|
top: 0;
|
|
322
322
|
bottom: 0;
|
|
323
|
-
width: ${e=>e.$touchOptimized?
|
|
323
|
+
width: ${e=>e.$touchOptimized?io:so}px;
|
|
324
324
|
cursor: col-resize;
|
|
325
325
|
user-select: none;
|
|
326
326
|
z-index: 105; /* Above waveform, below header */
|
|
@@ -343,19 +343,19 @@ React keys must be passed directly to JSX without using spread:
|
|
|
343
343
|
background: rgba(255, 255, 255, 0.4);
|
|
344
344
|
${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
345
|
}
|
|
346
|
-
`,
|
|
346
|
+
`,nr=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:a,touchOptimized:s=!1})=>{const[o,i]=c.useState(!1);if(!a)return null;const{attributes:l,listeners:u,setActivatorNodeRef:d,isDragging:g}=a;return R.jsx(lo,{ref:d,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:g,$isHovered:o,$touchOptimized:s,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),...u,...l})},co=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
347
347
|
position: absolute;
|
|
348
348
|
top: 0;
|
|
349
349
|
bottom: 0;
|
|
350
350
|
pointer-events: none;
|
|
351
351
|
z-index: 50;
|
|
352
|
-
`,
|
|
352
|
+
`,uo=k.svg`
|
|
353
353
|
width: 100%;
|
|
354
354
|
height: 100%;
|
|
355
355
|
display: block;
|
|
356
356
|
/* Flip horizontally for fadeOut - makes it mirror of fadeIn */
|
|
357
357
|
transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
|
|
358
|
-
`;function
|
|
358
|
+
`;function fo(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,i=s/a;let l;switch(n){case"linear":l=i;break;case"exponential":l=i*i;break;case"sCurve":l=(1-Math.cos(i*Math.PI))/2;break;case"logarithmic":default:l=Math.log10(1+i*9)/Math.log10(10);break}const u=(1-l)*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 R.jsx(co,{$left:e,$width:t,$type:n,children:R.jsx(uo,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:R.jsx("path",{d:fo(t,100,r),fill:o})})})},ho=k.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
359
359
|
position: ${e=>e.$isOverlay?"relative":"absolute"};
|
|
360
360
|
top: 0;
|
|
361
361
|
height: ${e=>e.$isOverlay?"auto":"100%"};
|
|
@@ -369,20 +369,20 @@ React keys must be passed directly to JSX without using spread:
|
|
|
369
369
|
&:hover {
|
|
370
370
|
background: rgba(255, 255, 255, 0.08);
|
|
371
371
|
}
|
|
372
|
-
`,
|
|
372
|
+
`,mo=k.div`
|
|
373
373
|
flex: 1;
|
|
374
374
|
position: relative;
|
|
375
375
|
overflow: ${e=>e.$isOverlay?"visible":"hidden"};
|
|
376
|
-
`,
|
|
376
|
+
`,ar=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:a,trackName:s,startSample:o,durationSamples:i,samplesPerPixel:l,showHeader:u=!1,disableHeaderDrag:d=!1,isOverlay:g=!1,isSelected:p=!1,onMouseDown:f,trackId:x,fadeIn:y,fadeOut:v,sampleRate:m=44100,showFades:C=!1,touchOptimized:w=!1})=>{const b=Math.floor(o/l),I=Math.floor((o+i)/l)-b,E=u&&!d&&!g,D=`clip-${r}-${a}`,{attributes:_,listeners:B,setNodeRef:T,setActivatorNodeRef:V,transform:W,isDragging:O}=fn({id:D,data:{clipId:n,trackIndex:r,clipIndex:a},disabled:!E}),X=`clip-boundary-left-${r}-${a}`,{attributes:G,listeners:ee,setActivatorNodeRef:re,isDragging:L}=fn({id:X,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"left"},disabled:!E}),oe=`clip-boundary-right-${r}-${a}`,{attributes:A,listeners:j,setActivatorNodeRef:H,isDragging:K}=fn({id:oe,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"right"},disabled:!E}),be=W?{transform:Cn.Translate.toString(W),zIndex:O?100:void 0}:void 0;return R.jsxs(ho,{ref:T,style:be,className:t,$left:b,$width:I,$isOverlay:g,"data-clip-container":"true","data-track-id":x,onMouseDown:f,children:[u&&R.jsx(oo,{clipId:n,trackIndex:r,clipIndex:a,trackName:s,isSelected:p,disableDrag:d,dragHandleProps:E?{attributes:_,listeners:B,setActivatorNodeRef:V}:void 0}),R.jsxs(mo,{$isOverlay:g,children:[e,C&&y&&y.duration>0&&R.jsx(rr,{left:0,width:Math.floor(y.duration*m/l),type:"fadeIn",curveType:y.type}),C&&v&&v.duration>0&&R.jsx(rr,{left:I-Math.floor(v.duration*m/l),width:Math.floor(v.duration*m/l),type:"fadeOut",curveType:v.type})]}),u&&!d&&!g&&R.jsxs(R.Fragment,{children:[R.jsx(nr,{clipId:n,trackIndex:r,clipIndex:a,edge:"left",touchOptimized:w,dragHandleProps:{attributes:G,listeners:ee,setActivatorNodeRef:re,isDragging:L}}),R.jsx(nr,{clipId:n,trackIndex:r,clipIndex:a,edge:"right",touchOptimized:w,dragHandleProps:{attributes:A,listeners:j,setActivatorNodeRef:H,isDragging:K}})]})]})},po=k.div`
|
|
377
377
|
display: inline-flex;
|
|
378
378
|
align-items: center;
|
|
379
379
|
gap: 0.5rem;
|
|
380
|
-
`,
|
|
380
|
+
`,go=k(Nr)`
|
|
381
381
|
margin: 0;
|
|
382
382
|
white-space: nowrap;
|
|
383
|
-
`,
|
|
383
|
+
`,bo=k(Lr)`
|
|
384
384
|
width: 120px;
|
|
385
|
-
`,
|
|
385
|
+
`,vo=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(parseFloat(s.target.value)/100)};return R.jsxs(po,{className:r,children:[R.jsx(go,{htmlFor:"master-gain",children:"Master Volume"}),R.jsx(bo,{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)`}}))`
|
|
386
386
|
position: absolute;
|
|
387
387
|
top: 0;
|
|
388
388
|
left: 0;
|
|
@@ -416,30 +416,32 @@ React keys must be passed directly to JSX without using spread:
|
|
|
416
416
|
width: 2px;
|
|
417
417
|
height: 100%;
|
|
418
418
|
background: ${e=>e.$color};
|
|
419
|
-
`;var
|
|
419
|
+
`;var Co=k.div`
|
|
420
420
|
overflow-y: hidden;
|
|
421
421
|
overflow-x: auto;
|
|
422
422
|
position: relative;
|
|
423
|
-
`,
|
|
423
|
+
`,xo=k.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
|
|
424
424
|
position: relative;
|
|
425
425
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
426
|
-
`,
|
|
426
|
+
`,wo=k.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
|
|
427
427
|
background: ${e=>e.$backgroundColor||"white"};
|
|
428
428
|
width: 100%;
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
position: relative;
|
|
430
|
+
overflow: hidden; /* Constrain loop region to timescale area */
|
|
431
|
+
`,yo=k.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
|
|
431
432
|
position: relative;
|
|
432
433
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
433
434
|
width: 100%;
|
|
434
|
-
`,
|
|
435
|
+
`,Io=k.div`
|
|
435
436
|
position: absolute;
|
|
436
437
|
top: 0;
|
|
437
438
|
left: 0;
|
|
438
439
|
right: 0;
|
|
439
440
|
bottom: 0;
|
|
440
441
|
cursor: crosshair;
|
|
441
|
-
|
|
442
|
-
|
|
442
|
+
/* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
|
|
443
|
+
z-index: ${e=>e.$isSelecting?110:1};
|
|
444
|
+
`,Kr=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:a,tracksWidth:s,scrollContainerWidth:o,controlsWidth:i,onTracksClick:l,onTracksMouseDown:u,onTracksMouseMove:d,onTracksMouseUp:g,scrollContainerRef:p,isSelecting:f})=>R.jsx(Co,{"data-scroll-container":"true",ref:p,children:R.jsxs(xo,{$backgroundColor:t,$width:o,children:[r&&R.jsx(wo,{$width:a,$backgroundColor:n,children:r}),R.jsxs(yo,{$width:s,$backgroundColor:t,children:[e,(l||u)&&R.jsx(Io,{$controlsWidth:i,$isSelecting:f,onClick:l,onMouseDown:u,onMouseMove:d,onMouseUp:g})]})]})});k.withTheme(Kr);var So=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
443
445
|
position: absolute;
|
|
444
446
|
top: 0;
|
|
445
447
|
background: ${e=>e.$color};
|
|
@@ -447,34 +449,116 @@ React keys must be passed directly to JSX without using spread:
|
|
|
447
449
|
z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
|
|
448
450
|
pointer-events: none;
|
|
449
451
|
opacity: 0.3;
|
|
450
|
-
`,
|
|
452
|
+
`,Ao=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:R.jsx(So,{$left:e,$width:r,$color:n,"data-selection":!0})};k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
453
|
+
position: absolute;
|
|
454
|
+
top: 0;
|
|
455
|
+
background: ${e=>e.$color};
|
|
456
|
+
height: 100%;
|
|
457
|
+
z-index: 55; /* Between clips (z-index: 50) and selection (z-index: 60) */
|
|
458
|
+
pointer-events: none;
|
|
459
|
+
`;k.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
|
|
460
|
+
position: absolute;
|
|
461
|
+
top: 0;
|
|
462
|
+
width: 2px;
|
|
463
|
+
height: 100%;
|
|
464
|
+
background: ${e=>e.$color};
|
|
465
|
+
z-index: 90; /* Below playhead (z-index: 100) */
|
|
466
|
+
pointer-events: none;
|
|
467
|
+
|
|
468
|
+
/* Triangle marker at top */
|
|
469
|
+
&::before {
|
|
470
|
+
content: '';
|
|
471
|
+
position: absolute;
|
|
472
|
+
top: 0;
|
|
473
|
+
${e=>e.$isStart?"left: 0":"right: 0"};
|
|
474
|
+
width: 0;
|
|
475
|
+
height: 0;
|
|
476
|
+
border-top: 8px solid ${e=>e.$color};
|
|
477
|
+
${e=>e.$isStart?"border-right: 8px solid transparent;":"border-left: 8px solid transparent;"}
|
|
478
|
+
}
|
|
479
|
+
`;var or=k.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
|
|
480
|
+
position: absolute;
|
|
481
|
+
top: 0;
|
|
482
|
+
width: 12px;
|
|
483
|
+
height: 100%;
|
|
484
|
+
cursor: ew-resize;
|
|
485
|
+
z-index: 100;
|
|
486
|
+
/* Center the handle on the marker position */
|
|
487
|
+
transform: translateX(-5px);
|
|
488
|
+
|
|
489
|
+
/* Visual marker line */
|
|
490
|
+
&::before {
|
|
491
|
+
content: '';
|
|
492
|
+
position: absolute;
|
|
493
|
+
top: 0;
|
|
494
|
+
left: 5px;
|
|
495
|
+
width: 2px;
|
|
496
|
+
height: 100%;
|
|
497
|
+
background: ${e=>e.$color};
|
|
498
|
+
opacity: ${e=>e.$isDragging?1:.8};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/* Triangle marker at top */
|
|
502
|
+
&::after {
|
|
503
|
+
content: '';
|
|
504
|
+
position: absolute;
|
|
505
|
+
top: 0;
|
|
506
|
+
${e=>e.$isStart?"left: 5px":"left: -1px"};
|
|
507
|
+
width: 0;
|
|
508
|
+
height: 0;
|
|
509
|
+
border-top: 10px solid ${e=>e.$color};
|
|
510
|
+
${e=>e.$isStart?"border-right: 10px solid transparent;":"border-left: 10px solid transparent;"}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
&:hover::before {
|
|
514
|
+
opacity: 1;
|
|
515
|
+
}
|
|
516
|
+
`,ko=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
517
|
+
position: absolute;
|
|
518
|
+
top: 0;
|
|
519
|
+
height: 100%;
|
|
520
|
+
background: ${e=>e.$color};
|
|
521
|
+
z-index: 50;
|
|
522
|
+
cursor: grab;
|
|
523
|
+
|
|
524
|
+
&:active {
|
|
525
|
+
cursor: grabbing;
|
|
526
|
+
}
|
|
527
|
+
`,$o=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopStartChange:a,onLoopEndChange:s,onLoopRegionMove:o,minPosition:i=0,maxPosition:l=1/0})=>{const[u,d]=c.useState(null),g=c.useRef(0),p=c.useRef(0),f=c.useRef(0),x=Math.max(0,t-e),y=c.useCallback((m,C)=>{m.preventDefault(),m.stopPropagation(),d(C),g.current=m.clientX,p.current=C==="start"?e:t;const w=S=>{const I=S.clientX-g.current,E=p.current+I;if(C==="start"){const D=Math.max(i,Math.min(t-10,E));a?.(D)}else{const D=Math.max(e+10,Math.min(l,E));s?.(D)}},b=()=>{d(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",b)},[e,t,i,l,a,s]),v=c.useCallback(m=>{m.preventDefault(),m.stopPropagation(),d("region"),g.current=m.clientX,p.current=e,f.current=t;const C=t-e,w=S=>{const I=S.clientX-g.current;let E=p.current+I,D=f.current+I;E<i&&(E=i,D=i+C),D>l&&(D=l,E=l-C),o?.(E,D)},b=()=>{d(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",b)},[e,t,i,l,o]);return x<=0?null:R.jsxs(R.Fragment,{children:[R.jsx(ko,{$left:e,$width:x,$color:r,$isDragging:u==="region",onMouseDown:v,"data-loop-region-timescale":!0}),R.jsx(or,{$left:e,$color:n,$isStart:!0,$isDragging:u==="start",onMouseDown:m=>y(m,"start"),"data-loop-marker-handle":"start"}),R.jsx(or,{$left:t,$color:n,$isStart:!1,$isDragging:u==="end",onMouseDown:m=>y(m,"end"),"data-loop-marker-handle":"end"})]})},Ro=k.div.attrs(e=>({style:{left:`${e.$leftOffset||0}px`}}))`
|
|
528
|
+
position: absolute;
|
|
529
|
+
top: 0;
|
|
530
|
+
right: 0;
|
|
531
|
+
height: 100%; /* Stay within timescale bounds, don't extend into tracks */
|
|
532
|
+
cursor: crosshair;
|
|
533
|
+
z-index: 40; /* Below markers and shading */
|
|
534
|
+
`,Eo=({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:i=0})=>{const[l,u]=c.useState(!1),d=c.useRef(0),g=c.useRef(null),p=t>e,f=c.useCallback(x=>{const y=x.target;if(y.closest("[data-loop-marker-handle]")||y.closest("[data-loop-region-timescale]"))return;x.preventDefault(),u(!0);const v=g.current?.getBoundingClientRect();if(!v)return;const m=x.clientX-v.left,C=Math.max(s,Math.min(o,m));d.current=C,a?.(C,C);const w=S=>{const I=S.clientX-v.left,E=Math.max(s,Math.min(o,I)),D=Math.min(d.current,E),_=Math.max(d.current,E);a?.(D,_)},b=()=>{u(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",b)},[s,o,a]);return R.jsx(Ro,{ref:g,$leftOffset:i,onMouseDown:f,"data-timescale-loop-creator":!0,children:p&&R.jsx($o,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:s,maxPosition:o,onLoopStartChange:x=>a?.(x,t),onLoopEndChange:x=>a?.(e,x),onLoopRegionMove:(x,y)=>a?.(x,y)})})};function Tt(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 Tt(e,0);case"hh:mm:ss.u":return Tt(e,1);case"hh:mm:ss.uu":return Tt(e,2);case"hh:mm:ss.uuu":return Tt(e,3);default:return Tt(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[i,l]=c.useState("");c.useEffect(()=>{const p=It(n,r);l(p)},[n,r,e]);const u=p=>{const f=p.target.value;l(f)},d=()=>{if(s){const p=Ur(i,r);s(p)}l(It(n,r))},g=p=>{p.key==="Enter"&&p.currentTarget.blur()};return R.jsxs(R.Fragment,{children:[R.jsx(Ua,{as:"label",htmlFor:e,children:t}),R.jsx(Or,{type:"text",className:a,id:e,value:i,onChange:u,onBlur:d,onKeyDown:g,readOnly:o})]})},To=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[a,s]=c.useState("hh:mm:ss.uuu");c.useEffect(()=>{const l=document.querySelector(".time-format"),u=()=>{l&&s(l.value)};return l&&(s(l.value),l.addEventListener("change",u)),()=>{l?.removeEventListener("change",u)}},[]);const o=l=>{n&&n(l,t)},i=l=>{n&&n(e,l)};return R.jsxs(R.Fragment,{children:[R.jsx(sr,{id:"audio_start",label:"Start of audio selection",value:e,format:a,className:"audio-start form-control mr-sm-2",onChange:o}),R.jsx(sr,{id:"audio_end",label:"End of audio selection",value:t,format:a,className:"audio-end form-control mr-sm-2",onChange:i})]})};function Lt(){return window.devicePixelRatio}var Jr=c.createContext(Lt()),Do=({children:e})=>{const[t,n]=c.useState(Lt());return matchMedia(`(resolution: ${Lt()}dppx)`).addEventListener("change",()=>{n(Lt())},{once:!0}),R.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}),Qt=()=>c.useContext(_n),Mn=()=>c.useContext(k.ThemeContext),Qr=c.createContext(R.jsx(c.Fragment,{})),_o=()=>c.useContext(Qr),Mo=0,Bo=!1,Fo=0,Wo=0,Zo={progress:Mo,isPlaying:Bo,selectionStart:Fo,selectionEnd:Wo};c.createContext(Zo);c.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var Po=({isSelected:e,transparentBackground:t,...n})=>{const r=Mn(),{waveHeight:a,barWidth:s,barGap:o}=Qt(),i=qr(),l=e&&r?r.selectedWaveOutlineColor:r?.waveOutlineColor,u=e&&r?r.selectedWaveFillColor:r?.waveFillColor,d=r?.waveformDrawMode||"inverted";return R.jsx(ro,{...n,...r,waveOutlineColor:l,waveFillColor:u,waveHeight:a,devicePixelRatio:i,barWidth:s,barGap:o,transparentBackground:t,drawMode:d})};function Vo(e,t,n){return Math.ceil(e*n/t)}function jo(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var zo=k.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,marginLeft:`${e.$controlWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
|
|
451
535
|
position: relative;
|
|
452
536
|
overflow: visible; /* Allow time labels to render above the container */
|
|
453
537
|
border-bottom: 1px solid ${e=>e.theme.timeColor};
|
|
454
538
|
box-sizing: border-box;
|
|
455
|
-
|
|
539
|
+
`,Oo=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
|
|
456
540
|
position: absolute;
|
|
457
541
|
left: 0;
|
|
458
542
|
right: 0;
|
|
459
543
|
bottom: 0;
|
|
460
|
-
`,
|
|
544
|
+
`,No=k.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
|
|
461
545
|
position: absolute;
|
|
462
546
|
font-size: 0.75rem; /* Smaller font to prevent overflow */
|
|
463
547
|
white-space: nowrap; /* Prevent text wrapping */
|
|
464
548
|
color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
|
|
465
|
-
`,
|
|
549
|
+
`,Lo=e=>{const{theme:{timeColor:t},duration:n,marker:r,bigStep:a,secondStep:s,renderTimestamp:o}=e,i=new Map,l=[],u=c.useRef(null),{sampleRate:d,samplesPerPixel:g,timeScaleHeight:p,controls:{show:f,width:x}}=c.useContext(_n),y=qr();c.useEffect(()=>{if(u.current!==null){const w=u.current,b=w.getContext("2d");if(b){b.resetTransform(),b.clearRect(0,0,w.width,w.height),b.imageSmoothingEnabled=!1,b.fillStyle=t,b.scale(y,y);for(const[S,I]of i.entries()){const E=p-I;b.fillRect(S,E,1,I)}}}},[n,y,t,p,a,s,r,i]);const v=Vo(n/1e3,g,d),m=d/g;let C=0;for(let w=0;w<v;w+=m*s/1e3){const b=Math.floor(w);if(C%r===0){const S=C,I=jo(S),E=o?R.jsx(c.Fragment,{children:o(S,b)},`timestamp-${C}`):R.jsx(No,{$left:b,children:I},I);l.push(E),i.set(b,p)}else C%a===0?i.set(b,Math.floor(p/2)):C%s===0&&i.set(b,Math.floor(p/5));C+=s}return R.jsxs(zo,{$cssWidth:v,$controlWidth:f?x:0,$timeScaleHeight:p,children:[l,R.jsx(Oo,{$cssWidth:v,$timeScaleHeight:p,width:v*y,height:p*y,ref:u})]})},Xo=k.withTheme(Lo),Ho=k.div`
|
|
466
550
|
display: inline-flex;
|
|
467
551
|
align-items: center;
|
|
468
552
|
gap: 0.5rem;
|
|
469
|
-
`,
|
|
553
|
+
`,Go=[{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"}],Yo=({value:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.value)};return R.jsx(Ho,{className:r,children:R.jsx(Dn,{className:"time-format",value:e,onChange:a,disabled:n,"aria-label":"Time format selection",children:Go.map(s=>R.jsx("option",{value:s.value,children:s.label},s.value))})})},Ko=k.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?Hr:0)}px`}}))`
|
|
470
554
|
position: relative;
|
|
471
555
|
display: flex;
|
|
472
556
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
473
|
-
`,
|
|
557
|
+
`,Uo=k.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
|
|
474
558
|
position: relative;
|
|
475
559
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
476
560
|
flex: 1;
|
|
477
|
-
`,
|
|
561
|
+
`,Jo=k.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
|
|
478
562
|
position: sticky;
|
|
479
563
|
z-index: 101; /* Above waveform content, below Docusaurus navbar (z-index: 200) */
|
|
480
564
|
left: 0;
|
|
@@ -488,7 +572,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
488
572
|
${e=>e.$isSelected&&`
|
|
489
573
|
background: ${e.theme.selectedTrackControlsBackground};
|
|
490
574
|
`}
|
|
491
|
-
`,
|
|
575
|
+
`,qo=({numChannels:e,children:t,className:n,backgroundColor:r,offset:a=0,width:s,hasClipHeaders:o=!1,onClick:i,trackId:l,isSelected:u=!1})=>{const{waveHeight:d,controls:{show:g,width:p}}=Qt(),f=_o();return R.jsxs(Ko,{$numChannels:e,className:n,$waveHeight:d,$controlWidth:g?p:0,$width:s,$hasClipHeaders:o,$isSelected:u,children:[R.jsx(Jo,{$controlWidth:g?p:0,$isSelected:u,children:f}),R.jsx(Uo,{$controlWidth:g?p:0,$backgroundColor:r,$offset:a,onClick:i,"data-track-id":l,children:t})]})},ir=k.button.attrs({type:"button"})`
|
|
492
576
|
display: inline-block;
|
|
493
577
|
font-family: ${e=>e.theme.fontFamily};
|
|
494
578
|
font-weight: 500;
|
|
@@ -547,7 +631,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
547
631
|
box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
|
|
548
632
|
}
|
|
549
633
|
`}
|
|
550
|
-
`,
|
|
634
|
+
`,Qo=k.div`
|
|
551
635
|
margin-bottom: 0.3rem;
|
|
552
636
|
|
|
553
637
|
button:not(:first-child) {
|
|
@@ -559,7 +643,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
559
643
|
border-top-right-radius: 0;
|
|
560
644
|
border-bottom-right-radius: 0;
|
|
561
645
|
}
|
|
562
|
-
`,
|
|
646
|
+
`,es=k.div`
|
|
563
647
|
background: transparent;
|
|
564
648
|
width: 100%;
|
|
565
649
|
height: 100%;
|
|
@@ -572,7 +656,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
572
656
|
text-align: center;
|
|
573
657
|
border: 1px solid ${e=>e.theme.borderColor};
|
|
574
658
|
border-radius: ${e=>e.theme.borderRadius};
|
|
575
|
-
`,
|
|
659
|
+
`,ts=k.header`
|
|
576
660
|
overflow: hidden;
|
|
577
661
|
height: 26px;
|
|
578
662
|
width: 100%;
|
|
@@ -583,7 +667,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
583
667
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
584
668
|
color: ${e=>e.theme.textColor};
|
|
585
669
|
background-color: transparent;
|
|
586
|
-
`,
|
|
670
|
+
`,ns=e=>R.jsx(zr,{weight:"light",...e}),rs=e=>R.jsx(jr,{weight:"light",...e}),lr=k(Lr)`
|
|
587
671
|
width: 75%;
|
|
588
672
|
height: 5px;
|
|
589
673
|
background: ${e=>e.theme.sliderTrackColor};
|
|
@@ -632,7 +716,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
632
716
|
&:focus::-moz-range-thumb {
|
|
633
717
|
border: 2px solid ${e=>e.theme.textColor};
|
|
634
718
|
}
|
|
635
|
-
`,
|
|
719
|
+
`,cr=k.label`
|
|
636
720
|
width: 100%;
|
|
637
721
|
display: flex;
|
|
638
722
|
justify-content: space-between;
|
|
@@ -678,7 +762,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
678
762
|
&:active {
|
|
679
763
|
transform: scale(0.9);
|
|
680
764
|
}
|
|
681
|
-
`;function
|
|
765
|
+
`;function as(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 i=o*t,l=Math.min((o+1)*t,r),u=e.subarray(i,l),d=as(u),g=ur(d.min,n),p=ur(d.max,n);s[o*2]=g,s[o*2+1]=p}return s}function os(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 i=0,l=0;for(let u=0;u<n;u++)i+=r*e[u][o*2],l+=r*e[u][o*2+1];s[o*2]=i,s[o*2+1]=l}return[s]}function ss(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 l=e.numberOfChannels,u=a??e.length;for(let d=0;d<l;d++){const p=e.getChannelData(d).subarray(r,u);o.push(dr(p,t,s))}}else{const l=a??e.length,u=e.subarray(r,l);o.push(dr(u,t,s))}return n&&o.length>1&&(o=os(o,s)),{length:o[0].length/2,data:o,bits:s}}function is(e,t=1e3,n=!0,r=8,a=0,s){const o=s!==void 0?a+s:void 0;return ss(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 ls=127,cs=-128,us=32767,ds=-32768;function fs(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(T){return new Float32Array(T)}),i=r?o.length:1,l=24,u=fs(a,t),d=e.bits===8?1:2,g=l+u*2*d*i,p=new ArrayBuffer(g),f=new DataView(p),x=0,y=l,v=new Array(i),m=new Array(i),C=0;C<i;C++)v[C]=1/0,m[C]=-1/0;var w=e.bits===8?cs:ds,b=e.bits===8?ls:us;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,i,!0);for(var S=0;S<a;S++){var I=0;if(i===1){for(var E=0;E<o.length;++E)I+=o[E][S];I=Math.floor(b*I*n/o.length),I<v[0]&&(v[0]=I,v[0]<w&&(v[0]=w)),I>m[0]&&(m[0]=I,m[0]>b&&(m[0]=b))}else for(var D=0;D<i;++D)I=Math.floor(b*o[D][S]*n),I<v[D]&&(v[D]=I,v[D]<w&&(v[D]=w)),I>m[D]&&(m[D]=I,m[D]>b&&(m[D]=b));if(++x===t){for(var _=0;_<i;_++)e.bits===8?(f.setInt8(y++,v[_]),f.setInt8(y++,m[_])):(f.setInt16(y,v[_],!0),f.setInt16(y+2,m[_],!0),y+=4),v[_]=1/0,m[_]=-1/0;x=0}}if(x>0)for(var B=0;B<i;B++)e.bits===8?(f.setInt8(y++,v[B]),f.setInt8(y++,m[B])):(f.setInt16(y,v[B],!0),f.setInt16(y+2,m[B],!0));return p}function Gt(e){"@babel/helpers - typeof";return Gt=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},Gt(e)}function ms(e){return e&&Gt(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function ps(e){var t=e&&Gt(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 gs(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,i=new ArrayBuffer(o),l=new DataView(i);l.setInt32(0,2,!0),l.setUint32(4,e.bits===8,!0),l.setInt32(8,e.sample_rate,!0),l.setInt32(12,e.samples_per_pixel,!0),l.setInt32(16,e.length,!0),l.setInt32(20,n,!0);var u=r;if(e.bits===8)for(var d=0;d<t.length;d++)l.setInt8(u++,t[d],!0);else for(var g=0;g<t.length;g++)l.setInt16(u,t[g],!0),u+=2;return i}function Ct(e){return e==null}function bs(e,t){var n=atob(e);return n}function vs(e,t,n){var r=bs(e),a=r.indexOf(`
|
|
766
|
+
`,10)+1,s=r.substring(a)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function Cs(e,t,n){var r;return function(s){return r=r||vs(e),new Worker(r,s)}}var xs=Cs("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function ze(e){if(ms(e)&&(e=gs(e)),ps(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 Dt={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function ws(e){var t={scale:e.scale||Dt.scale,bits:e.bits||Dt.bits,amplitude_scale:e.amplitude_scale||Dt.amplitude_scale,split_channels:e.split_channels||Dt.split_channels,disable_worker:e.disable_worker||Dt.disable_worker};return t}function ys(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=ys(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 ze(a),e)}else{var s=new xs;s.onmessage=function(o){n(void 0,new ze(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 Is(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)}ze.create=function(t){return new ze(t)};ze.createFromAudio=function(e,t){var n=ws(e);if(e.audio_context&&e.array_buffer)return Is(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 en(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 ze(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 i=0;i<o;++i)this._input_buffer_size>0?(this._min[i]=this._inputData.channel(i).min_sample(this._input_index),this._max[i]=this._inputData.channel(i).max_sample(this._input_index)):(this._min[i]=0,this._max[i]=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}en.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};en.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 i=r.min_sample(this._input_index);i<this._min[o]&&(this._min[o]=i),i=r.max_sample(this._input_index),i>this._max[o]&&(this._max[o]=i)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var l=0;l<n;++l)r=this._outputWaveformData.channel(l),r.set_min_sample(this._output_index-1,this._min[l]),r.set_max_sample(this._output_index-1,this._max[l]);return!0};en.prototype.getOutputData=function(){return this._output_data};ze.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 en(t);!n.next(););return new ze(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 ze.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 i=s[o],l=new DataView(i).getInt32(16,!0);r+=i.byteLength-n,a+=l}for(var u=new ArrayBuffer(r),d=new DataView(s[0]),g=new DataView(u),p=0;p<n;p++)g.setUint8(p,d.getUint8(p));g.setInt32(16,a,!0);for(var f=0,x=new Uint8Array(u,n),y=0;y<s.length;y++){var v=s[y];x.set(new Uint8Array(v,n),f),f+=v.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,i=s+a*2*this.channels*o,l=new ArrayBuffer(i),u=new DataView(l);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 g=this._at(n*this.channels*2+d);this.bits===8?u.setInt8(s+d,g):u.setInt16(s+d*2,g,!0)}return new ze(l)},_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 ze.create(r)}else{const r=await t.json();return ze.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,i=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let l=0;l<o;l++)i[l*2]=a[l],i[l*2+1]=s[l];return{data:i,bits:r,length:o,sampleRate:e.sample_rate}}async function Ss(e,t=0){const n=await Bn(e);return na(n,t)}async function As(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 ks(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),x=Math.ceil((r+a)/p);s=s.slice({startIndex:f,endIndex:x})}s.scale!==t&&(s=s.resample({scale:t}));const o=s.channel(n),i=s.bits,l=o.min_array(),u=o.max_array(),d=l.length,g=i===8?new Int8Array(d*2):new Int16Array(d*2);for(let p=0;p<d;p++)g[p*2]=l[p],g[p*2+1]=u[p];return{data:g,bits:i,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 hr(){}const $s=Object.freeze({x:0,y:0});var wt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(wt||(wt={}));var mr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(mr||(mr={}));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 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={}));wt.Backward+"",wt.Forward+"",wt.Backward+"",wt.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 Rs(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 Es={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:hr,draggableNodes:new Map,over:null,measureDroppableContainers:hr},Ts=c.createContext(Es),Ds=c.createContext({...$s,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 _s=c.createContext(null),Cr="button",Ms="Draggable";function xr(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Vr(Ms),{activators:o,activatorEvent:i,active:l,activeNodeRect:u,ariaDescribedById:d,draggableNodes:g,over:p}=c.useContext(Ts),{role:f=Cr,roleDescription:x="draggable",tabIndex:y=0}=a??{},v=l?.id===t,m=c.useContext(v?Ds:_s),[C,w]=Xt(),[b,S]=Xt(),I=Rs(o,t),E=Pr(n);Kt(()=>(g.set(t,{id:t,key:s,node:C,activatorNode:b,data:E}),()=>{const _=g.get(t);_&&_.key===s&&g.delete(t)}),[g,t]);const D=c.useMemo(()=>({role:f,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&f===Cr?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,f,y,v,x,d.draggable]);return{active:l,activatorEvent:i,activeNodeRect:u,attributes:D,isDragging:v,listeners:r?void 0:I,node:C,over:p,setNodeRef:w,setActivatorNodeRef:S,transform:m}}function Bs(e){return{id:e.id,start:parseFloat(e.begin),end:parseFloat(e.end),lines:e.lines,lang:e.language}}function Fs(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`}}))`
|
|
682
767
|
position: absolute;
|
|
683
768
|
top: 0;
|
|
684
769
|
background: ${e=>e.$color};
|
|
@@ -763,12 +848,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
763
848
|
&:active {
|
|
764
849
|
background: rgba(255, 255, 255, 0.3);
|
|
765
850
|
}
|
|
766
|
-
`;var
|
|
851
|
+
`;var Ws=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
767
852
|
position: absolute;
|
|
768
853
|
top: 0;
|
|
769
854
|
height: 100%;
|
|
770
855
|
pointer-events: none; /* Let events pass through to children */
|
|
771
|
-
`,
|
|
856
|
+
`,Zs=k.div`
|
|
772
857
|
position: absolute;
|
|
773
858
|
top: 0;
|
|
774
859
|
left: 0;
|
|
@@ -792,7 +877,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
792
877
|
border-width: 3px;
|
|
793
878
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
|
|
794
879
|
}
|
|
795
|
-
`,
|
|
880
|
+
`,Ps=k.span`
|
|
796
881
|
font-size: 12px;
|
|
797
882
|
font-weight: 600;
|
|
798
883
|
color: ${e=>e.theme?.annotationLabelColor||"#2a2a2a"};
|
|
@@ -802,7 +887,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
802
887
|
padding: 0 6px;
|
|
803
888
|
letter-spacing: 0.3px;
|
|
804
889
|
user-select: none;
|
|
805
|
-
`,
|
|
890
|
+
`,wr=k.div`
|
|
806
891
|
position: absolute;
|
|
807
892
|
top: 0;
|
|
808
893
|
${e=>e.$position==="left"?"left: -8px":"right: -8px"};
|
|
@@ -837,13 +922,13 @@ React keys must be passed directly to JSX without using spread:
|
|
|
837
922
|
opacity: 1;
|
|
838
923
|
background: ${e=>e.theme?.annotationResizeHandleActiveColor||"rgba(0, 0, 0, 0.7)"};
|
|
839
924
|
}
|
|
840
|
-
`,
|
|
925
|
+
`,Vs=({annotationId:e,annotationIndex:t,startPosition:n,endPosition:r,label:a,color:s="#ff9800",isActive:o=!1,onClick:i,editable:l=!0})=>{const u=Math.max(0,r-n),d=`annotation-boundary-start-${t}`,{attributes:g,listeners:p,setActivatorNodeRef:f,isDragging:x}=xr({id:d,data:{annotationId:e,annotationIndex:t,edge:"start"},disabled:!l}),y=`annotation-boundary-end-${t}`,{attributes:v,listeners:m,setActivatorNodeRef:C,isDragging:w}=xr({id:y,data:{annotationId:e,annotationIndex:t,edge:"end"},disabled:!l});if(u<=0)return null;const b=I=>E=>{E.stopPropagation(),I?.(E)},S=I=>{I.stopPropagation()};return R.jsxs(Ws,{$left:n,$width:u,children:[R.jsx(Zs,{$color:s,$isActive:o,onClick:i,children:a&&R.jsx(Ps,{children:a})}),l&&R.jsx(wr,{ref:f,$position:"left",$isDragging:x,onClick:S,...p,onPointerDown:b(p?.onPointerDown),...g}),l&&R.jsx(wr,{ref:C,$position:"right",$isDragging:w,onClick:S,...m,onPointerDown:b(m?.onPointerDown),...v})]})},js=k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
|
|
841
926
|
position: relative;
|
|
842
927
|
display: flex;
|
|
843
928
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
844
929
|
background: transparent;
|
|
845
930
|
z-index: 110;
|
|
846
|
-
`,
|
|
931
|
+
`,zs=k.div`
|
|
847
932
|
position: sticky;
|
|
848
933
|
z-index: 200;
|
|
849
934
|
left: 0;
|
|
@@ -851,11 +936,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
851
936
|
width: ${e=>e.$controlWidth}px;
|
|
852
937
|
flex-shrink: 0;
|
|
853
938
|
background: transparent;
|
|
854
|
-
`,
|
|
939
|
+
`,Os=k.div`
|
|
855
940
|
position: relative;
|
|
856
941
|
flex: 1;
|
|
857
942
|
padding-left: ${e=>e.$offset||0}px;
|
|
858
|
-
`,
|
|
943
|
+
`,Ns=({children:e,className:t,height:n=30,offset:r=0,width:a})=>{const{controls:{show:s,width:o}}=Qt();return R.jsxs(js,{className:t,$height:n,$controlWidth:s?o:0,$width:a,children:[R.jsx(zs,{$controlWidth:s?o:0}),R.jsx(Os,{$offset:r,children:e})]})};k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
|
|
859
944
|
position: relative;
|
|
860
945
|
display: flex;
|
|
861
946
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
@@ -878,12 +963,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
878
963
|
position: relative;
|
|
879
964
|
flex: 1;
|
|
880
965
|
padding-left: ${e=>e.$offset||0}px;
|
|
881
|
-
`;var
|
|
966
|
+
`;var Ls=k.div`
|
|
882
967
|
background: ${e=>e.theme?.backgroundColor||"#fff"};
|
|
883
968
|
${e=>e.$height?`height: ${e.$height}px;`:"max-height: 200px;"}
|
|
884
969
|
overflow-y: auto;
|
|
885
970
|
padding: 8px;
|
|
886
|
-
`,
|
|
971
|
+
`,Xs=k.div`
|
|
887
972
|
padding: 12px;
|
|
888
973
|
margin-bottom: 6px;
|
|
889
974
|
border-left: 4px solid ${e=>e.$isActive?"#ff9800":"transparent"};
|
|
@@ -902,16 +987,16 @@ React keys must be passed directly to JSX without using spread:
|
|
|
902
987
|
outline: 2px solid #ff9800;
|
|
903
988
|
outline-offset: 2px;
|
|
904
989
|
}
|
|
905
|
-
`,
|
|
990
|
+
`,Hs=k.div`
|
|
906
991
|
display: flex;
|
|
907
992
|
justify-content: space-between;
|
|
908
993
|
align-items: center;
|
|
909
994
|
margin-bottom: 6px;
|
|
910
|
-
`,
|
|
995
|
+
`,Gs=k.div`
|
|
911
996
|
display: flex;
|
|
912
997
|
align-items: center;
|
|
913
998
|
gap: 8px;
|
|
914
|
-
`,
|
|
999
|
+
`,Ys=k.span`
|
|
915
1000
|
font-size: 11px;
|
|
916
1001
|
font-weight: 600;
|
|
917
1002
|
color: ${e=>e.theme?.textColorMuted||"#666"};
|
|
@@ -925,16 +1010,16 @@ React keys must be passed directly to JSX without using spread:
|
|
|
925
1010
|
outline: 2px solid #ff9800;
|
|
926
1011
|
background: rgba(255, 152, 0, 0.1);
|
|
927
1012
|
}
|
|
928
|
-
`,
|
|
1013
|
+
`,Ks=k.span`
|
|
929
1014
|
font-size: 12px;
|
|
930
1015
|
font-weight: 500;
|
|
931
1016
|
color: ${e=>e.theme?.textColorMuted||"#555"};
|
|
932
1017
|
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
933
1018
|
letter-spacing: 0.5px;
|
|
934
|
-
`,
|
|
1019
|
+
`,Us=k.div`
|
|
935
1020
|
display: flex;
|
|
936
1021
|
gap: 6px;
|
|
937
|
-
`,
|
|
1022
|
+
`,Js=k.button`
|
|
938
1023
|
background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
|
|
939
1024
|
border: 1px solid ${e=>e.theme?.borderColor||"#ccc"};
|
|
940
1025
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
@@ -953,7 +1038,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
953
1038
|
&:active {
|
|
954
1039
|
transform: scale(0.95);
|
|
955
1040
|
}
|
|
956
|
-
`,
|
|
1041
|
+
`,qs=k.div`
|
|
957
1042
|
font-size: 14px;
|
|
958
1043
|
line-height: 1.6;
|
|
959
1044
|
color: ${e=>e.theme?.textColor||"#2a2a2a"};
|
|
@@ -968,9 +1053,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
968
1053
|
outline: 2px solid #ff9800;
|
|
969
1054
|
background: rgba(255, 152, 0, 0.1);
|
|
970
1055
|
}
|
|
971
|
-
`,
|
|
972
|
-
`)},l(w)},x=(m,C)=>{if(!r||!l)return;const w=C.trim();if(!w)return;const
|
|
973
|
-
`)})]},m.id)})})},
|
|
1056
|
+
`,Qs=({annotations:e,activeAnnotationId:t,shouldScrollToActive:n=!1,editable:r=!1,controls:a=[],annotationListConfig:s,height:o,onAnnotationClick:i,onAnnotationUpdate:l})=>{const u=c.useRef(null),d=c.useRef(null),g=c.useRef(void 0);c.useEffect(()=>{}),c.useEffect(()=>{const m=d.current;if(!m)return;const C=()=>{};return m.addEventListener("scroll",C),()=>m.removeEventListener("scroll",C)},[]),c.useEffect(()=>{t&&u.current&&n&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"}),g.current=t},[t,n]);const p=m=>{if(isNaN(m)||!isFinite(m))return"0:00.000";const C=Math.floor(m/60),w=(m%60).toFixed(3);return`${C}:${w.padStart(6,"0")}`},f=(m,C)=>{if(!r||!l)return;const w=[...e];w[m]={...w[m],lines:C.split(`
|
|
1057
|
+
`)},l(w)},x=(m,C)=>{if(!r||!l)return;const w=C.trim();if(!w)return;const b=[...e];b[m]={...b[m],id:w},l(b)},y=(m,C,w)=>{if(!l)return;const b=[...e];m.action(b[w],w,b,s||{}),l(b)},v=m=>m.replace(/\./g," ");return R.jsx(Ls,{ref:d,$height:o,children:e.map((m,C)=>{const w=m.id===t;return R.jsxs(Xs,{ref:w?u:null,$isActive:w,onClick:()=>i?.(m),children:[R.jsxs(Hs,{children:[R.jsxs(Gs,{children:[R.jsx(Ys,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:b=>x(C,b.currentTarget.textContent||""),children:m.id}),R.jsxs(Ks,{children:[p(m.start)," - ",p(m.end)]})]}),a.length>0&&R.jsx(Us,{onClick:b=>b.stopPropagation(),children:a.map((b,S)=>R.jsx(Js,{title:b.title,onClick:()=>y(b,m,C),children:b.text?b.text:R.jsx("i",{className:v(b.class||"")})},S))})]}),R.jsx(qs,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:b=>f(C,b.currentTarget.textContent||""),children:m.lines.join(`
|
|
1058
|
+
`)})]},m.id)})})},ei=c.memo(Qs),ti=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return R.jsxs(Ut,{className:r,children:[R.jsx(Jt,{type:"checkbox",id:"continuous-play",className:"continuous-play",checked:e,onChange:a,disabled:n}),R.jsx(qt,{htmlFor:"continuous-play",children:"Continuous Play"})]})},ni=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return R.jsxs(Ut,{className:r,children:[R.jsx(Jt,{type:"checkbox",id:"link-endpoints",className:"link-endpoints",checked:e,onChange:a,disabled:n}),R.jsx(qt,{htmlFor:"link-endpoints",children:"Link Endpoints"})]})},ri=({checked:e,onChange:t,className:n})=>R.jsxs(Ut,{className:n,children:[R.jsx(Jt,{type:"checkbox",id:"editable-annotations",checked:e,onChange:r=>t(r.target.checked)}),R.jsx(qt,{htmlFor:"editable-annotations",children:"Editable Annotations"})]}),ai=k.button`
|
|
974
1059
|
padding: 0.5rem 1rem;
|
|
975
1060
|
background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
|
|
976
1061
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
@@ -996,7 +1081,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
996
1081
|
opacity: 0.6;
|
|
997
1082
|
cursor: not-allowed;
|
|
998
1083
|
}
|
|
999
|
-
`,ks=({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=>ns(b)),i=JSON.stringify(o,null,2),l=new Blob([i],{type:"application/json"}),u=URL.createObjectURL(l),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(Ss,{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 Gr(){const[e,t]=c.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:a=>lt(a,e),parseTime:a=>jr(a,e)}}const Rs=[256,512,1024,2048,4096,8192];function Xr({initialSamplesPerPixel:e,zoomLevels:t=Rs}){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,i=c.useCallback(()=>{r(u=>Math.max(0,u-1))},[]),l=c.useCallback(()=>{r(u=>Math.min(t.length-1,u+1))},[t.length]);return{samplesPerPixel:a,zoomIn:i,zoomOut:l,canZoomIn:s,canZoomOut:o}}function Yr({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 $s=(e=256)=>{const t=c.useRef(null),n=c.useCallback((r,a,s)=>{const o=new V.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 pn(e){const{audioBuffer:t,startSample:n,durationSamples:r=t.length,offsetSamples:a=0,gain:s=1,name:o,color:i,fadeIn:l,fadeOut:u}=e;return{id:Lr(),audioBuffer:t,startSample:n,durationSamples:r,offsetSamples:a,gain:s,name:o,color:i,fadeIn:l,fadeOut:u}}function Es(e){const{audioBuffer:t,startTime:n,duration:r=t.duration,offset:a=0,gain:s=1,name:o,color:i,fadeIn:l,fadeOut:u}=e,d=t.sampleRate;return pn({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(r*d),offsetSamples:Math.round(a*d),gain:s,name:o,color:i,fadeIn:l,fadeOut:u})}function Ts(e){const{name:t,clips:n=[],muted:r=!1,soloed:a=!1,volume:s=1,pan:o=0,color:i,height:l}=e;return{id:Lr(),name:t,clips:n,muted:r,soloed:a,volume:s,pan:o,color:i,height:l}}function Lr(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function Ds(e){const[t,n]=c.useState([]),[r,a]=c.useState(!0),[s,o]=c.useState(null);return c.useEffect(()=>{if(e.length===0){n([]),a(!1);return}let i=!1;return(async()=>{try{a(!0),o(null);const u=kr.getContext().rawContext,d=e.map(async(p,f)=>{const x=await fetch(p.src);if(!x.ok)throw new Error(`Failed to fetch ${p.src}: ${x.statusText}`);const y=await x.arrayBuffer(),v=await u.decodeAudioData(y);if(!v||!v.sampleRate||!v.duration)throw new Error(`Invalid audio buffer for ${p.src}`);const m=p.duration??v.duration,C=Es({audioBuffer:v,startTime:p.startTime??0,duration:m,offset:p.offset??0,name:p.name||`Track ${f+1}`,fadeIn:p.fadeIn,fadeOut:p.fadeOut});if(isNaN(C.startSample)||isNaN(C.durationSamples)||isNaN(C.offsetSamples))throw console.error("Invalid clip values:",C),new Error(`Invalid clip values for ${p.src}`);return{...Ts({name:p.name||`Track ${f+1}`,clips:[C],muted:p.muted??!1,soloed:p.soloed??!1,volume:p.volume??1,pan:p.pan??0,color:p.color}),effects:p.effects}}),b=await Promise.all(d);i||(n(b),a(!1))}catch(u){if(!i){const d=u instanceof Error?u.message:"Unknown error loading audio";o(d),a(!1),console.error("Error loading audio tracks:",u)}}})(),()=>{i=!0}},[e]),{tracks:t,loading:r,error:s}}function _s({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:x}=b.data.current;if(x)return{...d,scaleX:1,scaleY:1};const y=e[p];if(!y)return{...d,scaleX:1,scaleY:1};const v=y.clips[f];if(!v)return{...d,scaleX:1,scaleY:1};const m=v.startSample/r,C=v.durationSamples/r,w=d.x*n/r;let g=m+w;const A=[...y.clips].sort(($,j)=>$.startSample-j.startSample),I=A.findIndex($=>$===v);g=Math.max(0,g);const D=I>0?A[I-1]:null;if(D){const $=(D.startSample+D.durationSamples)/r;g=Math.max(g,$)}const F=I<A.length-1?A[I+1]:null;if(F){const $=g+C,j=F.startSample/r;$>j&&(g=j-C)}const M=(g-m)*r/n;return{...d,x:M,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]),i=c.useCallback(u=>{const{active:d,delta:b}=u,{boundary:p}=d.data.current;if(!p||!a.current)return;const{trackIndex:f,clipIndex:x}=d.data.current,y=b.x*n,v=Math.floor(.1*r),m=a.current,C=e.map((w,g)=>{if(g!==f)return w;const A=[...w.clips].sort((F,_)=>F.startSample-_.startSample),I=A.findIndex(F=>F===w.clips[x]),D=w.clips.map((F,_)=>{if(_!==x)return F;const M=Math.floor(F.audioBuffer.duration*r);if(p==="left"){let $=Math.floor(y);const j=-m.startSample;$<j&&($=j);const Z=-m.offsetSamples;$<Z&&($=Z);const X=I>0?A[I-1]:null;if(X){const oe=X.startSample+X.durationSamples-m.startSample;$<oe&&($=oe)}const Y=m.durationSamples-v;$>Y&&($=Y);const K=m.offsetSamples+$,te=m.durationSamples-$,re=m.startSample+$;return{...F,offsetSamples:K,durationSamples:te,startSample:re}}else{let $=Math.floor(m.durationSamples+y);$=Math.max(v,$),m.offsetSamples+$>M&&($=M-m.offsetSamples);const j=I<A.length-1?A[I+1]:null;return j&&m.startSample+$>j.startSample&&($=j.startSample-m.startSample,$=Math.max(v,$)),{...F,durationSamples:$}}});return{...w,clips:D}});t(C)},[e,t,n,r]),l=c.useCallback(u=>{const{active:d,delta:b}=u,{trackIndex:p,clipIndex:f,boundary:x}=d.data.current,y=b.x*n;if(x){a.current=null;return}const v=e.map((m,C)=>{if(C!==p)return m;const w=[...m.clips].sort((I,D)=>I.startSample-D.startSample),g=w.findIndex(I=>I===m.clips[f]),A=m.clips.map((I,D)=>{if(D!==f)return I;let F=Math.floor(I.startSample+y);F=Math.max(0,F);const _=g>0?w[g-1]:null;if(_){const $=_.startSample+_.durationSamples;F=Math.max(F,$)}const M=g<w.length-1?w[g+1]:null;return M&&F+I.durationSamples>M.startSample&&(F=M.startSample-I.durationSamples),{...I,startSample:F}});return{...m,clips:A}});t(v)},[e,t,n,r]);return{onDragStart:o,onDragMove:i,onDragEnd:l,collisionModifier:s}}const rn=.01;function Ms({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:a,linkEndpoints:s}){const o=c.useRef(null),i=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]),l=c.useCallback(d=>{const{active:b,delta:p}=d;if(!o.current)return;const f=b.data.current;if(!f)return;const{edge:x,annotationIndex:y}=f,v=o.current,m=p.x*n/r,C=x==="start"?v.start+m:v.end+m,w=Bs({annotationIndex:y,newTime:C,isDraggingStart:x==="start",annotations:e,duration:a,linkEndpoints:s});t(w)},[e,t,n,r,a,s]),u=c.useCallback(()=>{o.current=null},[]);return{onDragStart:i,onDragMove:l,onDragEnd:u}}function Bs({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:a,linkEndpoints:s}){const o=[...r],i=r[e];if(n){const l=Math.min(i.end-.1,Math.max(0,t)),u=l-i.start;if(o[e]={...i,start:l},s&&e>0){const d=o[e-1];Math.abs(d.end-i.start)<rn?o[e-1]={...d,end:Math.max(d.start+.1,d.end+u)}:l<=d.end&&(o[e]={...o[e],start:d.end})}else!s&&e>0&&l<o[e-1].end&&(o[e-1]={...o[e-1],end:l})}else{const l=Math.max(i.start+.1,Math.min(t,a)),u=l-i.end;if(o[e]={...i,end:l},s&&e<o.length-1){const d=o[e+1];if(Math.abs(d.start-i.end)<rn){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],x=o[p+1];if(Math.abs(x.start-f.end)<rn){const y=f.end-r[p].end;o[p+1]={...x,start:Math.min(x.end-.1,x.start+y)},p++}else break}}else l>=d.start&&(o[e]={...o[e],end:d.start})}else if(!s&&e<o.length-1&&l>o[e+1].start){const d=o[e+1];o[e+1]={...d,start:l};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 Sn(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Kr(e){return"nodeType"in e}function ct(e){var t,n;return e?Sn(e)?e:Kr(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Ws(e){const{Document:t}=ct(e);return e instanceof t}function Fs(e){return Sn(e)?!1:e instanceof ct(e).HTMLElement}function Ps(e){return e instanceof ct(e).SVGElement}function Ht(e){return e?Sn(e)?e.document:Kr(e)?Ws(e)?e:Fs(e)||Ps(e)?e.ownerDocument:document:document:document}function Zs(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 i=Object.entries(o);for(const[l,u]of i){const d=s[l];d!=null&&(s[l]=d+e*u)}return s},{...t})}}const Vs=Zs(-1);function js(e){return"clientX"in e&&"clientY"in e}function zs(e){if(!e)return!1;const{TouchEvent:t}=ct(e.target);return t&&e instanceof t}function fr(e){if(zs(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 js(e)?{x:e.clientX,y:e.clientY}:null}var hr;(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"})(hr||(hr={}));function an(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Os(){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 gn=Object.freeze({x:0,y:0});var it;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(it||(it={}));class on{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 Ns(e){const{EventTarget:t}=ct(e);return e instanceof t?e:Ht(e)}function sn(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 Xe;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Xe||(Xe={}));function mr(e){e.preventDefault()}function Hs(e){e.stopPropagation()}var Ye;(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"})(Ye||(Ye={}));Ye.Space,Ye.Enter,Ye.Esc,Ye.Space,Ye.Enter,Ye.Tab;function pr(e){return!!(e&&"distance"in e)}function gr(e){return!!(e&&"delay"in e)}class kn{constructor(t,n,r){var a;r===void 0&&(r=Ns(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=Ht(o),this.documentListeners=new on(this.document),this.listeners=new on(r),this.windowListeners=new on(ct(o)),this.initialCoordinates=(a=fr(s))!=null?a:gn,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(Xe.Resize,this.handleCancel),this.windowListeners.add(Xe.DragStart,mr),this.windowListeners.add(Xe.VisibilityChange,this.handleCancel),this.windowListeners.add(Xe.ContextMenu,mr),this.documentListeners.add(Xe.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(gr(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(pr(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(Xe.Click,Hs,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Xe.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:a,props:s}=this,{onMove:o,options:{activationConstraint:i}}=s;if(!a)return;const l=(n=fr(t))!=null?n:gn,u=Vs(a,l);if(!r&&i){if(pr(i)){if(i.tolerance!=null&&sn(u,i.tolerance))return this.handleCancel();if(sn(u,i.distance))return this.handleStart()}if(gr(i)&&sn(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}t.cancelable&&t.preventDefault(),o(l)}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===Ye.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Gs={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ur extends kn{constructor(t){const{event:n}=t,r=Ht(n.target);super(t,Gs,r)}}Ur.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 Xs={move:{name:"mousemove"},end:{name:"mouseup"}};var bn;(function(e){e[e.RightClick=2]="RightClick"})(bn||(bn={}));class Jr extends kn{constructor(t){super(t,Xs,Ht(t.event.target))}}Jr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===bn.RightClick?!1:(r?.({event:n}),!0)}}];const ln={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class qr extends kn{constructor(t){super(t,ln)}static setup(){return window.addEventListener(ln.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ln.move.name,t)};function t(){}}}qr.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 br;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(br||(br={}));var vr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(vr||(vr={}));it.Backward+"",it.Forward+"",it.Backward+"",it.Forward+"";var vn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(vn||(vn={}));var Cn;(function(e){e.Optimized="optimized"})(Cn||(Cn={}));vn.WhileDragging,Cn.Optimized;({...gn});var Cr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Cr||(Cr={}));function Ys(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:a=1}=e,s=an(Jr,{activationConstraint:{distance:a}}),o=an(qr,{activationConstraint:t?{delay:n,tolerance:r}:{distance:a}}),i=an(Ur,{activationConstraint:{distance:a}});return Os(...t?[s,o]:[i])}const Ls=e=>{const{tracks:t,onTracksChange:n,sampleRate:r}=e,{currentTimeRef:a}=Te(),{selectedTrackId:s}=Ne(),o=c.useCallback((l,u,d)=>{const{sampleRate:b,samplesPerPixel:p}=e,f=t[l];if(!f)return!1;const x=f.clips[u];if(!x)return!1;const y=x.startSample/b,v=(x.startSample+x.durationSamples)/b;if(d<=y||d>=v)return console.warn("Split time is outside clip bounds"),!1;const m=Math.round(d*b),C=Math.floor(m/p),w=x.startSample+x.durationSamples,g=C*p,A=x.startSample,I=g-A,D=g,F=w-D,_=g-x.startSample,M=pn({audioBuffer:x.audioBuffer,startSample:A,durationSamples:I,offsetSamples:x.offsetSamples,gain:x.gain,name:x.name?`${x.name} (1)`:void 0,color:x.color,fadeIn:x.fadeIn}),$=pn({audioBuffer:x.audioBuffer,startSample:D,durationSamples:F,offsetSamples:x.offsetSamples+_,gain:x.gain,name:x.name?`${x.name} (2)`:void 0,color:x.color,fadeOut:x.fadeOut}),j=[...f.clips];j.splice(u,1,M,$);const Z=[...t];return Z[l]={...f,clips:j},n(Z),!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 l=t.findIndex(b=>b.id===s);if(l===-1)return console.warn("Selected track not found"),!1;const u=t[l],d=a.current??0;for(let b=0;b<u.clips.length;b++){const p=u.clips[b],f=p.startSample/r,x=(p.startSample+p.durationSamples)/r;if(d>f&&d<x)return console.log(`Splitting clip on track "${u.name}" at ${d}s`),o(l,b,d)}return console.log(`No clip found at playhead position on track "${u.name}"`),!1},[t,a,s,o,r]),splitClipAt:o}},Pt=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(i=>{const l=a.key.toLowerCase()===i.key.toLowerCase()||a.key===i.key,u=i.ctrlKey===void 0||a.ctrlKey===i.ctrlKey,d=i.shiftKey===void 0||a.shiftKey===i.shiftKey,b=i.metaKey===void 0||a.metaKey===i.metaKey,p=i.altKey===void 0||a.altKey===i.altKey;return l&&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])},Ks=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("+")},Us=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:a}=Te(),{setCurrentTime:s,play:o,pause:i,stop:l}=xe(),{playoutRef:u}=Re(),d=c.useCallback(()=>{a?i():o()},[a,o,i]),b=c.useCallback(()=>{l()},[l]),p=c.useCallback(()=>{a&&u.current?(u.current.stop(),s(0),o(0)):s(0)},[a,u,s,o]),x=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 Pt({shortcuts:x,enabled:t}),{rewindToStart:p,togglePlayPause:d,stopPlayback:b,shortcuts:x}},cn=.01,_t=.01;function Js({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:a,linkEndpoints:s,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:u,sampleRate:d,controlsWidth:b=0,onPlay:p}){const f=c.useMemo(()=>t?e.findIndex(_=>_.id===t):-1,[e,t]),x=c.useCallback(_=>{if(!l?.current||!u||!d)return;const M=e.find(L=>L.id===_);if(!M)return;const $=l.current,j=$.clientWidth,Z=M.start*d/u+b,X=M.end*d/u+b,Y=(Z+X)/2,K=$.scrollLeft,te=K,re=K+j;if(Z<te||X>re){const L=Math.max(0,Y-j/2);$.scrollTo({left:L,behavior:"smooth"})}},[e,l,u,d,b]);c.useEffect(()=>{t&&l?.current&&u&&d&&x(t)},[t,x,l,u,d]);const y=c.useCallback(_=>{if(f<0)return;const M=e[f],$=Math.max(0,Math.min(M.end-.1,M.start+_)),j=$-M.start,Z=[...e];if(Z[f]={...M,start:$},s&&f>0){const X=Z[f-1];Math.abs(X.end-M.start)<cn&&(Z[f-1]={...X,end:Math.max(X.start+.1,X.end+j)})}else if(!s&&f>0){const X=Z[f-1];$<X.end&&(Z[f-1]={...X,end:$})}n(Z)},[e,f,s,n]),v=c.useCallback(_=>{if(f<0)return;const M=e[f],$=Math.max(M.start+.1,Math.min(a,M.end+_)),j=$-M.end,Z=[...e];if(Z[f]={...M,end:$},s&&f<e.length-1){const X=Z[f+1];if(Math.abs(X.start-M.end)<cn){const Y=Math.min(X.end-.1,X.start+j);Z[f+1]={...X,start:Y};let K=f+1;for(;K<Z.length-1;){const te=Z[K],re=Z[K+1];if(Math.abs(re.start-e[K].end)<cn){const L=te.end-e[K].end;Z[K+1]={...re,start:Math.min(re.end-.1,re.start+L)},K++}else break}}}else if(!s&&f<e.length-1){const X=Z[f+1];if($>X.start){Z[f+1]={...X,start:$};let Y=f+1;for(;Y<Z.length-1;){const K=Z[Y],te=Z[Y+1];if(K.end>te.start)Z[Y+1]={...te,start:K.end},Y++;else break}}}n(Z)},[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]),C=c.useCallback(()=>{!r||e.length===0||(f<0||f>=e.length-1?r(e[0].id):r(e[f+1].id))},[e,f,r]),w=c.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),g=c.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),A=c.useCallback(()=>{r&&r(null)},[r]),I=c.useCallback(()=>{if(f<0||!p)return;const _=e[f],M=o?void 0:_.end-_.start;p(_.start,M)},[e,f,o,p]),D=c.useMemo(()=>[{key:"[",action:()=>y(-_t),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>y(_t),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-_t),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(_t),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:I,description:"Play selected annotation",preventDefault:!0}],[y,v,I]),F=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:C,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:C,description:"Select next annotation",preventDefault:!0},{key:"Home",action:w,description:"Select first annotation",preventDefault:!0},{key:"End",action:g,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:A,description:"Deselect annotation",preventDefault:!0}],[m,C,w,g,A]);return Pt({shortcuts:D,enabled:i&&f>=0}),Pt({shortcuts:F,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:y,moveEndBoundary:v,selectPrevious:m,selectNext:C,selectFirst:w,selectLast:g,clearSelection:A,scrollToAnnotation:x,playActiveAnnotation:I}}function qs(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 Qs(e,t,n,r=1){const a=e.createBuffer(r,t.length,n),s=new Float32Array(t);return a.copyToChannel(s,0),a}function xr(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 i=o*t,l=Math.min(i+t,e.length);let u=0,d=0;for(let b=i;b<l;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 ei(e,t,n,r,a=16){const s=2**(a-1),o=r%n;let i=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 C=t[m];C<p&&(p=C),C>f&&(f=C)}const x=new(a===8?Int8Array:Int16Array)(e.length);x.set(e),x[e.length-2]=Math.floor(p*s),x[e.length-1]=Math.floor(f*s),i=b;const y=xr(t.slice(i),n,a),v=new(a===8?Int8Array:Int16Array)(x.length+y.length);return v.set(x),v.set(y,x.length),v}const l=xr(t.slice(i),n,a),u=new(a===8?Int8Array:Int16Array)(e.length+l.length);return u.set(e),u.set(l,e.length),u}function ti(e,t={}){const{channelCount:n=1,samplesPerPixel:r=1024}=t,[a,s]=c.useState(!1),[o,i]=c.useState(!1),[l,u]=c.useState(0),[d,b]=c.useState(new Int16Array(0)),[p,f]=c.useState(null),[x,y]=c.useState(null),[v,m]=c.useState(0),[C,w]=c.useState(0),g=16,A=c.useRef(!1),I=c.useRef(null),D=c.useRef(null),F=c.useRef([]),_=c.useRef(0),M=c.useRef(null),$=c.useRef(0),j=c.useRef(!1),Z=c.useRef(!1),X=c.useCallback(async()=>{if(!A.current)try{const L=V.getContext(),oe=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw",typeof document>"u"?require("url").pathToFileURL(__filename).href:Qt&&Qt.tagName.toUpperCase()==="SCRIPT"&&Qt.src||new URL("index.js",document.baseURI).href).href;await L.addAudioWorkletModule(oe),A.current=!0}catch(L){throw console.error("Failed to load AudioWorklet module:",L),new Error("Failed to load recording processor")}},[]),Y=c.useCallback(async()=>{if(!e){y(new Error("No microphone stream available"));return}try{y(null);const L=V.getContext();L.state==="suspended"&&await L.resume(),await X();const oe=L.createMediaStreamSource(e);D.current=oe;const S=L.createAudioWorkletNode("recording-processor");I.current=S,oe.connect(S),S.port.onmessage=G=>{const{samples:Q}=G.data;F.current.push(Q),_.current+=Q.length,b(se=>ei(se,Q,r,_.current-Q.length,g))},S.port.postMessage({command:"start",sampleRate:L.sampleRate,channelCount:n}),F.current=[],_.current=0,b(new Int16Array(0)),f(null),m(0),w(0),j.current=!0,Z.current=!1,s(!0),i(!1),$.current=performance.now();const z=()=>{if(j.current&&!Z.current){const G=(performance.now()-$.current)/1e3;u(G),M.current=requestAnimationFrame(z)}};z()}catch(L){console.error("Failed to start recording:",L),y(L instanceof Error?L:new Error("Failed to start recording"))}},[e,n,r,X,a,o]),K=c.useCallback(async()=>{if(!a)return null;try{if(I.current){if(I.current.port.postMessage({command:"stop"}),D.current)try{D.current.disconnect(I.current)}catch{}I.current.disconnect()}M.current!==null&&(cancelAnimationFrame(M.current),M.current=null);const L=qs(F.current),S=V.getContext().rawContext,z=Qs(S,L,S.sampleRate,n);return f(z),u(z.duration),j.current=!1,Z.current=!1,s(!1),i(!1),m(0),z}catch(L){return console.error("Failed to stop recording:",L),y(L instanceof Error?L:new Error("Failed to stop recording")),null}},[a,n]),te=c.useCallback(()=>{a&&!o&&(M.current!==null&&(cancelAnimationFrame(M.current),M.current=null),Z.current=!0,i(!0))},[a,o]),re=c.useCallback(()=>{if(a&&o){Z.current=!1,i(!1),$.current=performance.now()-l*1e3;const L=()=>{if(j.current&&!Z.current){const oe=(performance.now()-$.current)/1e3;u(oe),M.current=requestAnimationFrame(L)}};L()}},[a,o,l]);return c.useEffect(()=>()=>{if(I.current){if(I.current.port.postMessage({command:"stop"}),D.current)try{D.current.disconnect(I.current)}catch{}I.current.disconnect()}M.current!==null&&cancelAnimationFrame(M.current)},[]),{isRecording:a,isPaused:o,duration:l,peaks:d,audioBuffer:p,level:v,peakLevel:C,startRecording:Y,stopRecording:K,pauseRecording:te,resumeRecording:re,error:x}}function ni(){const[e,t]=c.useState(null),[n,r]=c.useState([]),[a,s]=c.useState(!1),[o,i]=c.useState(!1),[l,u]=c.useState(null),d=c.useCallback(async()=>{try{const x=(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(x)}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,x)=>{i(!0),u(null);try{e&&e.getTracks().forEach(C=>C.stop());const v={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...x,...f&&{deviceId:{exact:f}}},video:!1},m=await navigator.mediaDevices.getUserMedia(v);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{i(!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:l}}function ri(e,t={}){const{updateRate:n=60,smoothingTimeConstant:r=.8}=t,[a,s]=c.useState(0),[o,i]=c.useState(0),l=c.useRef(null),u=c.useRef(null),d=c.useRef(null),b=()=>i(0);return c.useEffect(()=>{if(!e){s(0),i(0);return}let p=!0;return(async()=>{if(!p)return;const x=V.getContext();if(x.state==="suspended"&&await x.resume(),!p)return;const y=new V.Meter({smoothing:r,context:x});l.current=y;const v=x.createMediaStreamSource(e);u.current=v,V.connect(v,y);const m=1e3/n;let C=0;const w=g=>{if(!(!p||!l.current)){if(g-C>=m){C=g;const A=l.current.getValue(),I=typeof A=="number"?A:A[0],D=Math.max(0,Math.min(1,(I+100)/100));s(D),i(F=>Math.max(F,D))}d.current=requestAnimationFrame(w)}};d.current=requestAnimationFrame(w)})(),()=>{if(p=!1,d.current&&(cancelAnimationFrame(d.current),d.current=null),u.current){try{u.current.disconnect()}catch{}u.current=null}l.current&&(l.current.dispose(),l.current=null)}},[e,r,n]),{level:a,peakLevel:o,resetPeak:b}}k.button`
|
|
1084
|
+
`,oi=({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(g=>Fs(g)),i=JSON.stringify(o,null,2),l=new Blob([i],{type:"application/json"}),u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download=t,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(u)};return R.jsx(ai,{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 si=[256,512,1024,2048,4096,8192];function aa({initialSamplesPerPixel:e,zoomLevels:t=si}){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,i=c.useCallback(()=>{r(u=>Math.max(0,u-1))},[]),l=c.useCallback(()=>{r(u=>Math.min(t.length-1,u+1))},[t.length]);return{samplesPerPixel:a,zoomIn:i,zoomOut:l,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 ii=(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,durationSamples:r=t.length,offsetSamples:a=0,gain:s=1,name:o,color:i,fadeIn:l,fadeOut:u,waveformData:d}=e;return{id:sa(),audioBuffer:t,startSample:n,durationSamples:r,offsetSamples:a,gain:s,name:o,color:i,fadeIn:l,fadeOut:u,waveformData:d}}function li(e){const{audioBuffer:t,startTime:n,duration:r=t.duration,offset:a=0,gain:s=1,name:o,color:i,fadeIn:l,fadeOut:u,waveformData:d}=e,g=t.sampleRate;return Sn({audioBuffer:t,startSample:Math.round(n*g),durationSamples:Math.round(r*g),offsetSamples:Math.round(a*g),gain:s,name:o,color:i,fadeIn:l,fadeOut:u,waveformData:d})}function ci(e){const{name:t,clips:n=[],muted:r=!1,soloed:a=!1,volume:s=1,pan:o=0,color:i,height:l}=e;return{id:sa(),name:t,clips:n,muted:r,soloed:a,volume:s,pan:o,color:i,height:l}}function sa(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ui(e){const[t,n]=c.useState([]),[r,a]=c.useState(!0),[s,o]=c.useState(null);return c.useEffect(()=>{if(e.length===0){n([]),a(!1);return}let i=!1;return(async()=>{try{a(!0),o(null);const u=Wr.getContext().rawContext,d=e.map(async(p,f)=>{const x=await fetch(p.src);if(!x.ok)throw new Error(`Failed to fetch ${p.src}: ${x.statusText}`);const y=await x.arrayBuffer(),v=await u.decodeAudioData(y);if(!v||!v.sampleRate||!v.duration)throw new Error(`Invalid audio buffer for ${p.src}`);const m=p.duration??v.duration,C=li({audioBuffer:v,startTime:p.startTime??0,duration:m,offset:p.offset??0,name:p.name||`Track ${f+1}`,fadeIn:p.fadeIn,fadeOut:p.fadeOut,waveformData:p.waveformData});if(isNaN(C.startSample)||isNaN(C.durationSamples)||isNaN(C.offsetSamples))throw console.error("Invalid clip values:",C),new Error(`Invalid clip values for ${p.src}`);return{...ci({name:p.name||`Track ${f+1}`,clips:[C],muted:p.muted??!1,soloed:p.soloed??!1,volume:p.volume??1,pan:p.pan??0,color:p.color}),effects:p.effects}}),g=await Promise.all(d);i||(n(g),a(!1))}catch(u){if(!i){const d=u instanceof Error?u.message:"Unknown error loading audio";o(d),a(!1),console.error("Error loading audio tracks:",u)}}})(),()=>{i=!0}},[e]),{tracks:t,loading:r,error:s}}function di({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r}){const a=c.useRef(null),s=c.useCallback(u=>{const{transform:d,active:g}=u;if(!g?.data?.current)return{...d,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:f,boundary:x}=g.data.current;if(x)return{...d,scaleX:1,scaleY:1};const y=e[p];if(!y)return{...d,scaleX:1,scaleY:1};const v=y.clips[f];if(!v)return{...d,scaleX:1,scaleY:1};const m=v.startSample/r,C=v.durationSamples/r,w=d.x*n/r;let b=m+w;const S=[...y.clips].sort((T,V)=>T.startSample-V.startSample),I=S.findIndex(T=>T===v);b=Math.max(0,b);const E=I>0?S[I-1]:null;if(E){const T=(E.startSample+E.durationSamples)/r;b=Math.max(b,T)}const D=I<S.length-1?S[I+1]:null;if(D){const T=b+C,V=D.startSample/r;T>V&&(b=V-C)}const B=(b-m)*r/n;return{...d,x:B,scaleX:1,scaleY:1}},[e,n,r]),o=c.useCallback(u=>{const{active:d}=u,{boundary:g}=d.data.current;if(!g){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]),i=c.useCallback(u=>{const{active:d,delta:g}=u,{boundary:p}=d.data.current;if(!p||!a.current)return;const{trackIndex:f,clipIndex:x}=d.data.current,y=g.x*n,v=Math.floor(.1*r),m=a.current,C=e.map((w,b)=>{if(b!==f)return w;const S=[...w.clips].sort((D,_)=>D.startSample-_.startSample),I=S.findIndex(D=>D===w.clips[x]),E=w.clips.map((D,_)=>{if(_!==x)return D;const B=Math.floor(D.audioBuffer.duration*r);if(p==="left"){let T=Math.floor(y);const V=-m.startSample;T<V&&(T=V);const W=-m.offsetSamples;T<W&&(T=W);const O=I>0?S[I-1]:null;if(O){const oe=O.startSample+O.durationSamples-m.startSample;T<oe&&(T=oe)}const X=m.durationSamples-v;T>X&&(T=X);const G=m.offsetSamples+T,ee=m.durationSamples-T,re=m.startSample+T;return{...D,offsetSamples:G,durationSamples:ee,startSample:re}}else{let T=Math.floor(m.durationSamples+y);T=Math.max(v,T),m.offsetSamples+T>B&&(T=B-m.offsetSamples);const V=I<S.length-1?S[I+1]:null;return V&&m.startSample+T>V.startSample&&(T=V.startSample-m.startSample,T=Math.max(v,T)),{...D,durationSamples:T}}});return{...w,clips:E}});t(C)},[e,t,n,r]),l=c.useCallback(u=>{const{active:d,delta:g}=u,{trackIndex:p,clipIndex:f,boundary:x}=d.data.current,y=g.x*n;if(x){a.current=null;return}const v=e.map((m,C)=>{if(C!==p)return m;const w=[...m.clips].sort((I,E)=>I.startSample-E.startSample),b=w.findIndex(I=>I===m.clips[f]),S=m.clips.map((I,E)=>{if(E!==f)return I;let D=Math.floor(I.startSample+y);D=Math.max(0,D);const _=b>0?w[b-1]:null;if(_){const T=_.startSample+_.durationSamples;D=Math.max(D,T)}const B=b<w.length-1?w[b+1]:null;return B&&D+I.durationSamples>B.startSample&&(D=B.startSample-I.durationSamples),{...I,startSample:D}});return{...m,clips:S}});t(v)},[e,t,n,r]);return{onDragStart:o,onDragMove:i,onDragEnd:l,collisionModifier:s}}const hn=.01;function fi({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:a,linkEndpoints:s}){const o=c.useRef(null),i=c.useCallback(d=>{const{active:g}=d,p=g.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]),l=c.useCallback(d=>{const{active:g,delta:p}=d;if(!o.current)return;const f=g.data.current;if(!f)return;const{edge:x,annotationIndex:y}=f,v=o.current,m=p.x*n/r,C=x==="start"?v.start+m:v.end+m,w=hi({annotationIndex:y,newTime:C,isDraggingStart:x==="start",annotations:e,duration:a,linkEndpoints:s});t(w)},[e,t,n,r,a,s]),u=c.useCallback(()=>{o.current=null},[]);return{onDragStart:i,onDragMove:l,onDragEnd:u}}function hi({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:a,linkEndpoints:s}){const o=[...r],i=r[e];if(n){const l=Math.min(i.end-.1,Math.max(0,t)),u=l-i.start;if(o[e]={...i,start:l},s&&e>0){const d=o[e-1];Math.abs(d.end-i.start)<hn?o[e-1]={...d,end:Math.max(d.start+.1,d.end+u)}:l<=d.end&&(o[e]={...o[e],start:d.end})}else!s&&e>0&&l<o[e-1].end&&(o[e-1]={...o[e-1],end:l})}else{const l=Math.max(i.start+.1,Math.min(t,a)),u=l-i.end;if(o[e]={...i,end:l},s&&e<o.length-1){const d=o[e+1];if(Math.abs(d.start-i.end)<hn){const g=d.start+u;o[e+1]={...d,start:Math.min(d.end-.1,g)};let p=e+1;for(;p<o.length-1;){const f=o[p],x=o[p+1];if(Math.abs(x.start-f.end)<hn){const y=f.end-r[p].end;o[p+1]={...x,start:Math.min(x.end-.1,x.start+y)},p++}else break}}else l>=d.start&&(o[e]={...o[e],end:d.start})}else if(!s&&e<o.length-1&&l>o[e+1].start){const d=o[e+1];o[e+1]={...d,start:l};let g=e+1;for(;g<o.length-1;){const p=o[g],f=o[g+1];if(p.end>f.start)o[g+1]={...f,start:p.end},g++;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 mi(e){const{Document:t}=St(e);return e instanceof t}function pi(e){return Fn(e)?!1:e instanceof St(e).HTMLElement}function gi(e){return e instanceof St(e).SVGElement}function tn(e){return e?Fn(e)?e.document:ia(e)?mi(e)?e:pi(e)||gi(e)?e.ownerDocument:document:document:document}function bi(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 i=Object.entries(o);for(const[l,u]of i){const d=s[l];d!=null&&(s[l]=d+e*u)}return s},{...t})}}const vi=bi(-1);function Ci(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 Ci(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 mn(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function wi(){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 yi(e){const{EventTarget:t}=St(e);return e instanceof t?e:tn(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 tt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(tt||(tt={}));function Sr(e){e.preventDefault()}function Ii(e){e.stopPropagation()}var nt;(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"})(nt||(nt={}));nt.Space,nt.Enter,nt.Esc,nt.Space,nt.Enter,nt.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=yi(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=tn(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(tt.Resize,this.handleCancel),this.windowListeners.add(tt.DragStart,Sr),this.windowListeners.add(tt.VisibilityChange,this.handleCancel),this.windowListeners.add(tt.ContextMenu,Sr),this.documentListeners.add(tt.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(tt.Click,Ii,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(tt.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:a,props:s}=this,{onMove:o,options:{activationConstraint:i}}=s;if(!a)return;const l=(n=yr(t))!=null?n:An,u=vi(a,l);if(!r&&i){if(Ar(i)){if(i.tolerance!=null&&gn(u,i.tolerance))return this.handleCancel();if(gn(u,i.distance))return this.handleStart()}if(kr(i)&&gn(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}t.cancelable&&t.preventDefault(),o(l)}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===nt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Si={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class la extends Wn{constructor(t){const{event:n}=t,r=tn(n.target);super(t,Si,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 Ai={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,Ai,tn(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 ki(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:a=1}=e,s=mn(ca,{activationConstraint:{distance:a}}),o=mn(ua,{activationConstraint:t?{delay:n,tolerance:r}:{distance:a}}),i=mn(la,{activationConstraint:{distance:a}});return wi(...t?[s,o]:[i])}const $i=e=>{const{tracks:t,onTracksChange:n,sampleRate:r}=e,{currentTimeRef:a}=We(),{selectedTrackId:s}=Ne(),o=c.useCallback((l,u,d)=>{const{sampleRate:g,samplesPerPixel:p}=e,f=t[l];if(!f)return!1;const x=f.clips[u];if(!x)return!1;const y=x.startSample/g,v=(x.startSample+x.durationSamples)/g;if(d<=y||d>=v)return console.warn("Split time is outside clip bounds"),!1;const m=Math.round(d*g),C=Math.floor(m/p),w=x.startSample+x.durationSamples,b=C*p,S=x.startSample,I=b-S,E=b,D=w-E,_=b-x.startSample,B=Sn({audioBuffer:x.audioBuffer,startSample:S,durationSamples:I,offsetSamples:x.offsetSamples,gain:x.gain,name:x.name?`${x.name} (1)`:void 0,color:x.color,fadeIn:x.fadeIn}),T=Sn({audioBuffer:x.audioBuffer,startSample:E,durationSamples:D,offsetSamples:x.offsetSamples+_,gain:x.gain,name:x.name?`${x.name} (2)`:void 0,color:x.color,fadeOut:x.fadeOut}),V=[...f.clips];V.splice(u,1,B,T);const W=[...t];return W[l]={...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 l=t.findIndex(g=>g.id===s);if(l===-1)return console.warn("Selected track not found"),!1;const u=t[l],d=a.current??0;for(let g=0;g<u.clips.length;g++){const p=u.clips[g],f=p.startSample/r,x=(p.startSample+p.durationSamples)/r;if(d>f&&d<x)return console.log(`Splitting clip on track "${u.name}" at ${d}s`),o(l,g,d)}return console.log(`No clip found at playhead position on track "${u.name}"`),!1},[t,a,s,o,r]),splitClipAt:o}},Yt=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(i=>{const l=a.key.toLowerCase()===i.key.toLowerCase()||a.key===i.key,u=i.ctrlKey===void 0||a.ctrlKey===i.ctrlKey,d=i.shiftKey===void 0||a.shiftKey===i.shiftKey,g=i.metaKey===void 0||a.metaKey===i.metaKey,p=i.altKey===void 0||a.altKey===i.altKey;return l&&u&&d&&g&&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])},Ri=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("+")},Ei=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:a}=We(),{setCurrentTime:s,play:o,pause:i,stop:l}=xe(),{playoutRef:u}=Te(),d=c.useCallback(()=>{a?i():o()},[a,o,i]),g=c.useCallback(()=>{l()},[l]),p=c.useCallback(()=>{a&&u.current?(u.current.stop(),s(0),o(0)):s(0)},[a,u,s,o]),x=r??[...[{key:" ",action:d,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:g,description:"Stop",preventDefault:!0},{key:"0",action:p,description:"Rewind to start",preventDefault:!0}],...n];return Yt({shortcuts:x,enabled:t}),{rewindToStart:p,togglePlayPause:d,stopPlayback:g,shortcuts:x}},vn=.01,Ot=.01;function Ti({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:a,linkEndpoints:s,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:u,sampleRate:d,controlsWidth:g=0,onPlay:p}){const f=c.useMemo(()=>t?e.findIndex(_=>_.id===t):-1,[e,t]),x=c.useCallback(_=>{if(!l?.current||!u||!d)return;const B=e.find(L=>L.id===_);if(!B)return;const T=l.current,V=T.clientWidth,W=B.start*d/u+g,O=B.end*d/u+g,X=(W+O)/2,G=T.scrollLeft,ee=G,re=G+V;if(W<ee||O>re){const L=Math.max(0,X-V/2);T.scrollTo({left:L,behavior:"smooth"})}},[e,l,u,d,g]);c.useEffect(()=>{t&&l?.current&&u&&d&&x(t)},[t,x,l,u,d]);const y=c.useCallback(_=>{if(f<0)return;const B=e[f],T=Math.max(0,Math.min(B.end-.1,B.start+_)),V=T-B.start,W=[...e];if(W[f]={...B,start:T},s&&f>0){const O=W[f-1];Math.abs(O.end-B.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];T<O.end&&(W[f-1]={...O,end:T})}n(W)},[e,f,s,n]),v=c.useCallback(_=>{if(f<0)return;const B=e[f],T=Math.max(B.start+.1,Math.min(a,B.end+_)),V=T-B.end,W=[...e];if(W[f]={...B,end:T},s&&f<e.length-1){const O=W[f+1];if(Math.abs(O.start-B.end)<vn){const X=Math.min(O.end-.1,O.start+V);W[f+1]={...O,start:X};let G=f+1;for(;G<W.length-1;){const ee=W[G],re=W[G+1];if(Math.abs(re.start-e[G].end)<vn){const L=ee.end-e[G].end;W[G+1]={...re,start:Math.min(re.end-.1,re.start+L)},G++}else break}}}else if(!s&&f<e.length-1){const O=W[f+1];if(T>O.start){W[f+1]={...O,start:T};let X=f+1;for(;X<W.length-1;){const G=W[X],ee=W[X+1];if(G.end>ee.start)W[X+1]={...ee,start:G.end},X++;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]),C=c.useCallback(()=>{!r||e.length===0||(f<0||f>=e.length-1?r(e[0].id):r(e[f+1].id))},[e,f,r]),w=c.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),b=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 _=e[f],B=o?void 0:_.end-_.start;p(_.start,B)},[e,f,o,p]),E=c.useMemo(()=>[{key:"[",action:()=>y(-Ot),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>y(Ot),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-Ot),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(Ot),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:I,description:"Play selected annotation",preventDefault:!0}],[y,v,I]),D=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:C,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:C,description:"Select next annotation",preventDefault:!0},{key:"Home",action:w,description:"Select first annotation",preventDefault:!0},{key:"End",action:b,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:S,description:"Deselect annotation",preventDefault:!0}],[m,C,w,b,S]);return Yt({shortcuts:E,enabled:i&&f>=0}),Yt({shortcuts:D,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:y,moveEndBoundary:v,selectPrevious:m,selectNext:C,selectFirst:w,selectLast:b,clearSelection:S,scrollToAnnotation:x,playActiveAnnotation:I}}function Di(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 _i(e,t,n,r=1){const a=e.createBuffer(r,t.length,n),s=new Float32Array(t);return a.copyToChannel(s,0),a}function Tr(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 i=o*t,l=Math.min(i+t,e.length);let u=0,d=0;for(let g=i;g<l;g++){const p=e[g];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 Mi(e,t,n,r,a=16){const s=2**(a-1),o=r%n;let i=0;if(o>0&&e.length>0){const d=n-o,g=Math.min(d,t.length);let p=e[e.length-2]/s,f=e[e.length-1]/s;for(let m=0;m<g;m++){const C=t[m];C<p&&(p=C),C>f&&(f=C)}const x=new(a===8?Int8Array:Int16Array)(e.length);x.set(e),x[e.length-2]=Math.floor(p*s),x[e.length-1]=Math.floor(f*s),i=g;const y=Tr(t.slice(i),n,a),v=new(a===8?Int8Array:Int16Array)(x.length+y.length);return v.set(x),v.set(y,x.length),v}const l=Tr(t.slice(i),n,a),u=new(a===8?Int8Array:Int16Array)(e.length+l.length);return u.set(e),u.set(l,e.length),u}function Bi(e,t={}){const{channelCount:n=1,samplesPerPixel:r=1024}=t,[a,s]=c.useState(!1),[o,i]=c.useState(!1),[l,u]=c.useState(0),[d,g]=c.useState(new Int16Array(0)),[p,f]=c.useState(null),[x,y]=c.useState(null),[v,m]=c.useState(0),[C,w]=c.useState(0),b=16,S=c.useRef(!1),I=c.useRef(null),E=c.useRef(null),D=c.useRef([]),_=c.useRef(0),B=c.useRef(null),T=c.useRef(0),V=c.useRef(!1),W=c.useRef(!1),O=c.useCallback(async()=>{if(!S.current)try{const L=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 L.addAudioWorkletModule(oe),S.current=!0}catch(L){throw console.error("Failed to load AudioWorklet module:",L),new Error("Failed to load recording processor")}},[]),X=c.useCallback(async()=>{if(!e){y(new Error("No microphone stream available"));return}try{y(null);const L=P.getContext();L.state==="suspended"&&await L.resume(),await O();const oe=L.createMediaStreamSource(e);E.current=oe;const A=L.createAudioWorkletNode("recording-processor");I.current=A,oe.connect(A),A.port.onmessage=H=>{const{samples:K}=H.data;D.current.push(K),_.current+=K.length,g(be=>Mi(be,K,r,_.current-K.length,b))},A.port.postMessage({command:"start",sampleRate:L.sampleRate,channelCount:n}),D.current=[],_.current=0,g(new Int16Array(0)),f(null),m(0),w(0),V.current=!0,W.current=!1,s(!0),i(!1),T.current=performance.now();const j=()=>{if(V.current&&!W.current){const H=(performance.now()-T.current)/1e3;u(H),B.current=requestAnimationFrame(j)}};j()}catch(L){console.error("Failed to start recording:",L),y(L instanceof Error?L:new Error("Failed to start recording"))}},[e,n,r,O,a,o]),G=c.useCallback(async()=>{if(!a)return null;try{if(I.current){if(I.current.port.postMessage({command:"stop"}),E.current)try{E.current.disconnect(I.current)}catch{}I.current.disconnect()}B.current!==null&&(cancelAnimationFrame(B.current),B.current=null);const L=Di(D.current),A=P.getContext().rawContext,j=_i(A,L,A.sampleRate,n);return f(j),u(j.duration),V.current=!1,W.current=!1,s(!1),i(!1),m(0),j}catch(L){return console.error("Failed to stop recording:",L),y(L instanceof Error?L:new Error("Failed to stop recording")),null}},[a,n]),ee=c.useCallback(()=>{a&&!o&&(B.current!==null&&(cancelAnimationFrame(B.current),B.current=null),W.current=!0,i(!0))},[a,o]),re=c.useCallback(()=>{if(a&&o){W.current=!1,i(!1),T.current=performance.now()-l*1e3;const L=()=>{if(V.current&&!W.current){const oe=(performance.now()-T.current)/1e3;u(oe),B.current=requestAnimationFrame(L)}};L()}},[a,o,l]);return c.useEffect(()=>()=>{if(I.current){if(I.current.port.postMessage({command:"stop"}),E.current)try{E.current.disconnect(I.current)}catch{}I.current.disconnect()}B.current!==null&&cancelAnimationFrame(B.current)},[]),{isRecording:a,isPaused:o,duration:l,peaks:d,audioBuffer:p,level:v,peakLevel:C,startRecording:X,stopRecording:G,pauseRecording:ee,resumeRecording:re,error:x}}function Fi(){const[e,t]=c.useState(null),[n,r]=c.useState([]),[a,s]=c.useState(!1),[o,i]=c.useState(!1),[l,u]=c.useState(null),d=c.useCallback(async()=>{try{const x=(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(x)}catch(f){console.error("Failed to enumerate devices:",f),u(f instanceof Error?f:new Error("Failed to enumerate devices"))}},[]),g=c.useCallback(async(f,x)=>{i(!0),u(null);try{e&&e.getTracks().forEach(C=>C.stop());const v={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...x,...f&&{deviceId:{exact:f}}},video:!1},m=await navigator.mediaDevices.getUserMedia(v);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{i(!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:g,stopStream:p,error:l}}function Wi(e,t={}){const{updateRate:n=60,smoothingTimeConstant:r=.8}=t,[a,s]=c.useState(0),[o,i]=c.useState(0),l=c.useRef(null),u=c.useRef(null),d=c.useRef(null),g=()=>i(0);return c.useEffect(()=>{if(!e){s(0),i(0);return}let p=!0;return(async()=>{if(!p)return;const x=P.getContext();if(x.state==="suspended"&&await x.resume(),!p)return;const y=new P.Meter({smoothing:r,context:x});l.current=y;const v=x.createMediaStreamSource(e);u.current=v,P.connect(v,y);const m=1e3/n;let C=0;const w=b=>{if(!(!p||!l.current)){if(b-C>=m){C=b;const S=l.current.getValue(),I=typeof S=="number"?S:S[0],E=Math.max(0,Math.min(1,(I+100)/100));s(E),i(D=>Math.max(D,E))}d.current=requestAnimationFrame(w)}};d.current=requestAnimationFrame(w)})(),()=>{if(p=!1,d.current&&(cancelAnimationFrame(d.current),d.current=null),u.current){try{u.current.disconnect()}catch{}u.current=null}l.current&&(l.current.dispose(),l.current=null)}},[e,r,n]),{level:a,peakLevel:o,resetPeak:g}}k.button`
|
|
1000
1085
|
padding: 0.5rem 1rem;
|
|
1001
1086
|
font-size: 0.875rem;
|
|
1002
1087
|
font-weight: 500;
|
|
@@ -1044,9 +1129,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1044
1129
|
opacity: 0.3;
|
|
1045
1130
|
}
|
|
1046
1131
|
}
|
|
1047
|
-
`;k(
|
|
1132
|
+
`;k(Dn)`
|
|
1048
1133
|
min-width: 200px;
|
|
1049
|
-
`;k(
|
|
1134
|
+
`;k(Nr)`
|
|
1050
1135
|
display: flex;
|
|
1051
1136
|
flex-direction: column;
|
|
1052
1137
|
gap: 0.25rem;
|
|
@@ -1089,7 +1174,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1089
1174
|
font-weight: 500;
|
|
1090
1175
|
color: ${e=>e.$isPaused?"#ffc107":"#dc3545"};
|
|
1091
1176
|
text-transform: uppercase;
|
|
1092
|
-
`;var
|
|
1177
|
+
`;var Zi=k.div`
|
|
1093
1178
|
position: relative;
|
|
1094
1179
|
width: ${e=>e.$width}px;
|
|
1095
1180
|
height: ${e=>e.$height}px;
|
|
@@ -1097,39 +1182,39 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1097
1182
|
border-radius: 4px;
|
|
1098
1183
|
overflow: hidden;
|
|
1099
1184
|
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
|
|
1100
|
-
`,
|
|
1185
|
+
`,Pi=e=>e<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":e<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",Vi=k.div.attrs(e=>({style:{width:`${e.$level*100}%`,height:`${e.$height}px`,background:Pi(e.$level),boxShadow:e.$level>.01?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}}))`
|
|
1101
1186
|
position: absolute;
|
|
1102
1187
|
left: 0;
|
|
1103
1188
|
top: 0;
|
|
1104
1189
|
transition: width 0.05s ease-out, background 0.1s ease-out;
|
|
1105
|
-
`,
|
|
1190
|
+
`,ji=k.div.attrs(e=>({style:{left:`${e.$peakLevel*100}%`,height:`${e.$height}px`}}))`
|
|
1106
1191
|
position: absolute;
|
|
1107
1192
|
top: 0;
|
|
1108
1193
|
width: 2px;
|
|
1109
1194
|
background: #ecf0f1;
|
|
1110
1195
|
box-shadow: 0 0 4px rgba(236, 240, 241, 0.8);
|
|
1111
1196
|
transition: left 0.1s ease-out;
|
|
1112
|
-
`,
|
|
1197
|
+
`,zi=k.div`
|
|
1113
1198
|
position: absolute;
|
|
1114
1199
|
top: 0;
|
|
1115
1200
|
left: 0;
|
|
1116
1201
|
width: 100%;
|
|
1117
1202
|
height: ${e=>e.$height}px;
|
|
1118
1203
|
pointer-events: none;
|
|
1119
|
-
`,
|
|
1204
|
+
`,Dr=k.div`
|
|
1120
1205
|
position: absolute;
|
|
1121
1206
|
left: ${e=>e.$position}%;
|
|
1122
1207
|
top: 0;
|
|
1123
1208
|
width: 1px;
|
|
1124
1209
|
height: ${e=>e.$height}px;
|
|
1125
1210
|
background: rgba(255, 255, 255, 0.2);
|
|
1126
|
-
`,ci=({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(ai,{$width:n,$height:r,className:a,children:[E.jsx(si,{$level:s,$height:r}),t!==void 0&&o>0&&E.jsx(ii,{$peakLevel:o,$height:r}),E.jsxs(li,{$height:r,children:[E.jsx(wr,{$position:60,$height:r}),E.jsx(wr,{$position:85,$height:r})]})]})};c.memo(ci);function ui(e,t,n,r={}){const{currentTime:a=0,audioConstraints:s,...o}=r,[i,l]=c.useState(!1),[u,d]=c.useState(null),{stream:b,devices:p,hasPermission:f,requestAccess:x,error:y}=ni(),{level:v,peakLevel:m}=ri(b),{isRecording:C,isPaused:w,duration:g,peaks:A,startRecording:I,stopRecording:D,pauseRecording:F,resumeRecording:_,error:M}=ti(b,o),$=c.useCallback(async()=>{n&&(i||(await en(),l(!0)),await I())},[n,i,I]),j=c.useCallback(async()=>{const Y=await D();if(Y&&n){const K=e.findIndex(G=>G.id===n);if(K===-1)return;const te=e[K],re=Math.floor(a*Y.sampleRate);let L=0;if(te.clips.length>0){const G=te.clips.map(Q=>Q.startSample+Q.durationSamples);L=Math.max(...G)}const oe=Math.max(re,L),S={id:`clip-${Date.now()}`,audioBuffer:Y,startSample:oe,durationSamples:Y.length,offsetSamples:0,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},z=e.map((G,Q)=>Q===K?{...G,clips:[...G.clips,S]}:G);t(z)}},[n,e,t,a,D]);c.useEffect(()=>{f&&p.length>0&&u===null&&d(p[0].deviceId)},[f,p.length]);const Z=c.useCallback(async()=>{await x(void 0,s),await en(),l(!0)},[x,s]),X=c.useCallback(async Y=>{d(Y),await x(Y,s),await en(),l(!0)},[x,s]);return{isRecording:C,isPaused:w,duration:g,level:v,peakLevel:m,error:y||M,stream:b,devices:p,hasPermission:f,selectedDevice:u,startRecording:$,stopRecording:j,pauseRecording:F,resumeRecording:_,requestMicAccess:Z,changeDevice:X,recordingPeaks:A}}const xt=[{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}]}],Rn=e=>xt.find(t=>t.id===e),di=e=>xt.filter(t=>t.category===e),fi=[{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"}],hi={reverb:V.Reverb,freeverb:V.Freeverb,jcReverb:V.JCReverb,feedbackDelay:V.FeedbackDelay,pingPongDelay:V.PingPongDelay,chorus:V.Chorus,phaser:V.Phaser,tremolo:V.Tremolo,vibrato:V.Vibrato,autoPanner:V.AutoPanner,autoFilter:V.AutoFilter,autoWah:V.AutoWah,eq3:V.EQ3,distortion:V.Distortion,bitCrusher:V.BitCrusher,chebyshev:V.Chebyshev,compressor:V.Compressor,limiter:V.Limiter,gate:V.Gate,stereoWidener:V.StereoWidener};let mi=0;const pi=()=>`effect_${Date.now()}_${++mi}`;function Ct(e,t){const n=hi[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(o=>{const i=t?.[o.name]??o.default;r[o.name]=i});const a=new n(r),s=pi();return{effect:a,id:e.id,instanceId:s,dispose(){try{a.disconnect(),a.dispose()}catch{}},setParameter(o,i){o==="wet"&&a.wet?a.wet.value=i:a[o]!==void 0&&(a[o]?.value!==void 0?a[o].value=i:a[o]=i)},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 gi(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 bi(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),i=c.useCallback(v=>{const m=o.current;if(!m)return;const{masterGainNode:C,destination:w,analyserNode:g}=m;try{C.disconnect()}catch{}const A=v.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(A.length===0)C.connect(g),g.connect(w);else{let I=C;A.forEach(D=>{try{D.disconnect()}catch{}I.connect(D.effect),I=D.effect}),I.connect(g),g.connect(w)}},[]),l=c.useCallback(v=>{const m=Rn(v);if(!m){console.error(`Unknown effect: ${v}`);return}const C={};m.parameters.forEach(A=>{C[A.name]=A.default});const w=Ct(m,C);a.current.set(w.instanceId,w);const g={instanceId:w.instanceId,effectId:m.id,definition:m,params:C,bypassed:!1};n(A=>[...A,g])},[]),u=c.useCallback(v=>{const m=a.current.get(v);m&&(m.dispose(),a.current.delete(v)),n(C=>C.filter(w=>w.instanceId!==v))},[]),d=c.useCallback((v,m,C)=>{const w=a.current.get(v);w&&w.setParameter(m,C),n(g=>g.map(A=>A.instanceId===v?{...A,params:{...A.params,[m]:C}}:A))},[]),b=c.useCallback(v=>{const m=r.current.find(g=>g.instanceId===v);if(!m)return;const C=!m.bypassed,w=a.current.get(v);if(w){const g=m.params.wet??1;w.setParameter("wet",C?0:g)}n(g=>g.map(A=>A.instanceId===v?{...A,bypassed:C}:A))},[]),p=c.useCallback((v,m)=>{n(C=>{const w=[...C],[g]=w.splice(v,1);return w.splice(m,0,g),w})},[]),f=c.useCallback(()=>{a.current.forEach(v=>v.dispose()),a.current.clear(),n([])},[]);c.useEffect(()=>{i(t)},[t,i]);const x=c.useCallback((v,m,C)=>{const w=new V.Analyser("fft",e);s.current=w,o.current={masterGainNode:v,destination:m,analyserNode:w};const A=r.current.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(A.length===0)v.connect(w),w.connect(m);else{let I=v;A.forEach(D=>{I.connect(D.effect),I=D.effect}),I.connect(w),w.connect(m)}return function(){w.dispose(),s.current=null,o.current=null}},[e]);c.useEffect(()=>()=>{a.current.forEach(v=>v.dispose()),a.current.clear()},[]);const y=c.useCallback(()=>{const v=t.filter(m=>!m.bypassed);if(v.length!==0)return(m,C,w)=>{const g=[];for(const A of v){const I=Ct(A.definition,A.params);g.push(I)}if(g.length===0)m.connect(C);else{let A=m;g.forEach(I=>{A.connect(I.effect),A=I.effect}),A.connect(C)}return function(){g.forEach(I=>I.dispose())}}},[t]);return{activeEffects:t,availableEffects:xt,addEffect:l,removeEffect:u,updateParameter:d,toggleBypass:b,reorderEffects:p,clearAllEffects:f,masterEffects:x,createOfflineEffectsFunction:y,analyserRef:s}}function vi(){const[e,t]=c.useState(new Map),n=c.useRef(new Map),r=c.useRef(new Map),a=c.useCallback((f,x)=>{const y=r.current.get(f);if(!y)return;const{graphEnd:v,masterGainNode:m}=y,C=n.current.get(f);try{v.disconnect()}catch{}const w=x.map(g=>C?.get(g.instanceId)).filter(g=>g!==void 0);if(w.length===0)v.connect(m);else{let g=v;w.forEach(A=>{try{A.disconnect()}catch{}g.connect(A.effect),g=A.effect}),g.connect(m)}},[]),s=c.useCallback((f,x)=>{const y=Rn(x);if(!y){console.error(`Unknown effect: ${x}`);return}const v={};y.parameters.forEach(w=>{v[w.name]=w.default});const m=Ct(y,v);n.current.has(f)||n.current.set(f,new Map),n.current.get(f).set(m.instanceId,m);const C={instanceId:m.instanceId,effectId:y.id,definition:y,params:v,bypassed:!1};t(w=>{const g=new Map(w),A=g.get(f)||[];return g.set(f,[...A,C]),g})},[]),o=c.useCallback((f,x)=>{const y=n.current.get(f),v=y?.get(x);v&&(v.dispose(),y?.delete(x)),t(m=>{const C=new Map(m),w=C.get(f)||[];return C.set(f,w.filter(g=>g.instanceId!==x)),C})},[]),i=c.useCallback((f,x,y,v)=>{const C=n.current.get(f)?.get(x);C&&C.setParameter(y,v),t(w=>{const g=new Map(w),A=g.get(f)||[];return g.set(f,A.map(I=>I.instanceId===x?{...I,params:{...I.params,[y]:v}}:I)),g})},[]),l=c.useCallback((f,x)=>{const v=(d.current.get(f)||[]).find(g=>g.instanceId===x);if(!v)return;const m=!v.bypassed,w=n.current.get(f)?.get(x);if(w){const g=v.params.wet??1;w.setParameter("wet",m?0:g)}t(g=>{const A=new Map(g),I=A.get(f)||[];return A.set(f,I.map(D=>D.instanceId===x?{...D,bypassed:m}:D)),A})},[]),u=c.useCallback(f=>{const x=n.current.get(f);x&&(x.forEach(y=>y.dispose()),x.clear()),t(y=>{const v=new Map(y);return v.set(f,[]),v})},[]),d=c.useRef(e);d.current=e;const b=c.useCallback(f=>(x,y,v)=>{r.current.set(f,{graphEnd:x,masterGainNode:y});const m=d.current.get(f)||[],C=n.current.get(f),w=m.map(g=>C?.get(g.instanceId)).filter(g=>g!==void 0);if(w.length===0)x.connect(y);else{let g=x;w.forEach(A=>{g.connect(A.effect),g=A.effect}),g.connect(y)}return function(){r.current.delete(f)}},[]);c.useEffect(()=>{e.forEach((f,x)=>{a(x,f)})},[e,a]),c.useEffect(()=>()=>{n.current.forEach(f=>{f.forEach(x=>x.dispose()),f.clear()}),n.current.clear()},[]);const p=c.useCallback(f=>{const y=(e.get(f)||[]).filter(v=>!v.bypassed);if(y.length!==0)return(v,m,C)=>{const w=[];for(const g of y){const A=Ct(g.definition,g.params);w.push(A)}if(w.length===0)v.connect(m);else{let g=v;w.forEach(A=>{g.connect(A.effect),g=A.effect}),g.connect(m)}return function(){w.forEach(A=>A.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:u,getTrackEffectsFunction:b,createOfflineTrackEffectsFunction:p,availableEffects:xt}}function Ci(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,a=e.sampleRate,s=e.length,o=n/8,i=r*o,l=a*i,u=s*i,d=44,b=d+u,p=new ArrayBuffer(b),f=new DataView(p);Mt(f,0,"RIFF"),f.setUint32(4,b-8,!0),Mt(f,8,"WAVE"),Mt(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,l,!0),f.setUint16(32,i,!0),f.setUint16(34,n,!0),Mt(f,36,"data"),f.setUint32(40,u,!0);const x=[];for(let v=0;v<r;v++)x.push(e.getChannelData(v));let y=d;if(n===16)for(let v=0;v<s;v++)for(let m=0;m<r;m++){const C=x[m][v],w=Math.max(-1,Math.min(1,C)),g=w<0?w*32768:w*32767;f.setInt16(y,g,!0),y+=2}else for(let v=0;v<s;v++)for(let m=0;m<r;m++)f.setFloat32(y,x[m][v],!0),y+=4;return new Blob([p],{type:"audio/wav"})}function Mt(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function xi(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 Qr(){const[e,t]=c.useState(!1),[n,r]=c.useState(0),[a,s]=c.useState(null);return{exportWav:c.useCallback(async(i,l,u={})=>{const{filename:d="export",mode:b="master",trackIndex:p,autoDownload:f=!0,applyEffects:x=!0,effectsFunction:y,createOfflineTrackEffects:v,bitDepth:m=16,onProgress:C}=u;t(!0),r(0),s(null);try{if(i.length===0)throw new Error("No tracks to export");if(b==="individual"&&(p===void 0||p<0||p>=i.length))throw new Error("Invalid track index for individual export");const w=i[0].clips[0]?.audioBuffer.sampleRate||44100;let g=0;for(const $ of i)for(const j of $.clips){const Z=j.startSample+j.durationSamples;g=Math.max(g,Z)}g+=Math.round(w*.1);const A=g/w,I=b==="individual"?[{track:i[p],state:l[p],index:p}]:i.map(($,j)=>({track:$,state:l[j],index:j})),D=l.some($=>$.soloed),F=!!v;let _;if((y||F)&&x)_=await wi(I,l,D,A,w,y,v,$=>{r($),C?.($)});else{const $=new OfflineAudioContext(2,g,w);let j=0;const Z=I.reduce((X,{track:Y})=>X+Y.clips.length,0);for(const{track:X,state:Y}of I)if(!(Y.muted&&!Y.soloed)&&!(D&&!Y.soloed))for(const K of X.clips){await Ii($,K,Y,w,x),j++;const te=j/Z*.5;r(te),C?.(te)}r(.5),C?.(.5),_=await $.startRendering()}r(.9),C?.(.9);const M=Ci(_,{bitDepth:m});if(r(1),C?.(1),f){const $=b==="individual"?`${d}_${i[p].name}`:d;xi(M,`${$}.wav`)}return{audioBuffer:_,blob:M,duration:A}}catch(w){const g=w instanceof Error?w.message:"Export failed";throw s(g),w}finally{t(!1)}},[]),isExporting:e,progress:n,error:a}}async function wi(e,t,n,r,a,s,o,i){const{Offline:l,Volume:u,Gain:d,Panner:b,Player:p,ToneAudioBuffer:f}=await import("tone");i(.1);let x;try{x=await l(async({transport:y,destination:v})=>{const m=new u(0);let C;s?C=s(m,v,!0):m.connect(v);for(const{track:w,state:g}of e){if(g.muted&&!g.soloed||n&&!g.soloed)continue;const A=new u(yi(g.volume)),I=new b(g.pan),D=new d(g.muted?0:1),F=o?.(w.id);F?F(D,m,!0):D.connect(m),I.connect(D),A.connect(I);for(const _ of w.clips){const{audioBuffer:M,startSample:$,durationSamples:j,offsetSamples:Z,gain:X,fadeIn:Y,fadeOut:K}=_,te=$/a,re=j/a,L=Z/a,oe=new f(M),S=new p(oe),z=new d(X);if(S.connect(z),z.connect(A),Y){const G=te,Q=te+Y.duration,se=z.gain._param;se.setValueAtTime(0,G),se.linearRampToValueAtTime(X,Q)}if(K){const G=te+re-K.duration,Q=te+re,se=z.gain._param;se.setValueAtTime(X,G),se.linearRampToValueAtTime(0,Q)}S.start(te,L,re)}}y.start(0)},r,2,a)}catch(y){throw y instanceof Error?y:new Error(`Tone.Offline rendering failed: ${String(y)}`)}return i(.9),x.get()}function yi(e){return 20*Math.log10(Math.max(e,1e-4))}async function Ii(e,t,n,r,a){const{audioBuffer:s,startSample:o,durationSamples:i,offsetSamples:l,gain:u,fadeIn:d,fadeOut:b}=t,p=o/r,f=i/r,x=l/r,y=e.createBufferSource();y.buffer=s;const v=e.createGain(),m=u*n.volume,C=e.createStereoPanner();if(C.pan.value=n.pan,y.connect(v),v.connect(C),C.connect(e.destination),a){if(d?v.gain.setValueAtTime(0,p):v.gain.setValueAtTime(m,p),d){const w=p,g=p+d.duration;yr(v.gain,w,g,0,m,d.type||"linear")}if(b){const w=p+f-b.duration,g=p+f;(!d||d.duration<f-b.duration)&&v.gain.setValueAtTime(m,w),yr(v.gain,w,g,m,0,b.type||"linear")}}else v.gain.setValueAtTime(m,p);y.start(p,x,f)}function yr(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 i=Math.max(r,1e-4),l=Math.max(a,1e-4);e.setValueAtTime(i,t),e.exponentialRampToValueAtTime(l,n),a===0&&e.setValueAtTime(0,n);break;case"logarithmic":const u=Ir(r,a,256,"logarithmic");e.setValueCurveAtTime(u,t,o);break;case"sCurve":const d=Ir(r,a,256,"sCurve");e.setValueCurveAtTime(d,t,o);break;default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n)}}function Ir(e,t,n,r){const a=new Float32Array(n),s=t-e;for(let o=0;o<n;o++){const i=o/(n-1);let l;r==="logarithmic"?s>0?l=Math.log10(1+i*9)/Math.log10(10):l=1-Math.log10(1+(1-i)*9)/Math.log10(10):l=i*i*(3-2*i),a[o]=e+s*l}return a}const ea=c.createContext(null),ta=c.createContext(null),na=c.createContext(null),ra=c.createContext(null),aa=c.createContext(null),Ai=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:a=1024,zoomLevels:s,automaticScroll:o=!1,theme:i,controls:l={show:!1,width:0},annotationList:u,effects:d,onReady:b,onAnnotationUpdate:p,barWidth:f=1,barGap:x=0,progressBarWidth:y,children:v})=>{const m=y??f+x,[C,w]=c.useState([]),[g,A]=c.useState(null),[I,D]=c.useState(!1),[F,_]=c.useState(0),[M,$]=c.useState(0),[j,Z]=c.useState([]),[X,Y]=c.useState([]),[K,te]=c.useState([]),[re,L]=c.useState(0),[oe,S]=c.useState(0),[z,G]=c.useState(null),[Q,se]=c.useState(o),[fe,ue]=c.useState(u?.isContinuousPlay??!1),[ye,le]=c.useState(u?.linkEndpoints??!0),[De,ut]=c.useState(u?.editable??!1),[Qe,et]=c.useState(!1),N=c.useRef(null),Ie=c.useRef(0),ge=c.useRef(0),be=c.useRef(null),Pe=c.useRef(K),$e=c.useRef(0),_e=c.useRef(0),Ze=c.useRef(null),Be=c.useRef(null),tt=c.useRef(!1),dt=c.useRef(u?.isContinuousPlay??!1),J=c.useRef(null),ne=c.useRef(a),he=c.useRef(!1),ve=c.useRef(0),we=c.useRef(0),{timeFormat:Ee,setTimeFormat:de,formatTime:Ve}=Gr(),Ae=Xr({initialSamplesPerPixel:a,zoomLevels:s}),Se=Ae.samplesPerPixel,{masterVolume:He,setMasterVolume:Le}=Yr({playoutRef:N,initialVolume:1}),Je=c.useCallback(T=>{dt.current=T,ue(T)},[]),We=c.useCallback(T=>{J.current=T,A(T)},[]),wt=c.useCallback(T=>{he.current=T,et(T)},[]);c.useEffect(()=>{tt.current=Q},[Q]),c.useEffect(()=>{Pe.current=K},[K]),c.useEffect(()=>{ve.current=re,we.current=oe},[re,oe]),c.useEffect(()=>{if(!Be.current||!j.length)return;const T=Be.current,B=ne.current,W=Se;if(B===W)return;const U=l.show?l.width:0,H=T.clientWidth,Ce=T.scrollLeft+H/2-U,ce=j[0].sampleRate,pe=Ce*B/ce*ce/W,Ge=Math.max(0,pe+U-H/2);T.scrollLeft=Ge,ne.current=W},[Se,j,l]);const je=c.useRef(null);c.useEffect(()=>{if(e.length===0){Z([]),$(0),te([]),Y([]),N.current&&(N.current.dispose(),N.current=null);return}const T=I,B=ge.current;return N.current&&T&&(N.current.stop(),be.current&&(cancelAnimationFrame(be.current),be.current=null),je.current={position:B}),(async()=>{try{const U=[];e.forEach(ce=>{ce.clips.length>0&&U.push(ce.clips[0].audioBuffer)});let H=0;e.forEach(ce=>{ce.clips.forEach(me=>{const pe=me.audioBuffer.sampleRate,ft=(me.startSample+me.durationSamples)/pe;H=Math.max(H,ft)})}),Z(U),$(H),te(ce=>ce.length===e.length?ce.map((me,pe)=>({...me,name:e[pe].name})):e.map(me=>({name:me.name,muted:me.muted,soloed:me.soloed,volume:me.volume,pan:me.pan}))),N.current&&N.current.dispose();const ae=new Ia({effects:d}),Ce=Pe.current;e.forEach((ce,me)=>{if(ce.clips.length>0){const pe=ce.clips[0].audioBuffer.sampleRate,Ge=Math.min(...ce.clips.map(Me=>Me.startSample/pe)),ft=Math.max(...ce.clips.map(Me=>(Me.startSample+Me.durationSamples)/pe)),rt=Ce[me],ia={id:`track-${me}`,name:ce.name,gain:rt?.volume??ce.volume,muted:rt?.muted??ce.muted,soloed:rt?.soloed??ce.soloed,stereoPan:rt?.pan??ce.pan,startTime:Ge,endTime:ft},la=ce.clips.map(Me=>{const qt=Me.audioBuffer.sampleRate;return{buffer:Me.audioBuffer,startTime:Me.startSample/qt-Ge,duration:Me.durationSamples/qt,offset:Me.offsetSamples/qt,fadeIn:Me.fadeIn,fadeOut:Me.fadeOut,gain:Me.gain}});ae.addTrack({clips:la,track:ia,effects:ce.effects})}}),ae.applyInitialSoloState(),N.current=ae,b?.()}catch(U){console.error("Error loading audio:",U)}})(),()=>{be.current&&cancelAnimationFrame(be.current),N.current&&N.current.dispose()}},[e,b,I]),c.useEffect(()=>{if(e.length===0)return;const T=16,B=e.map(W=>W.clips.map(H=>{const ae=H.audioBuffer.sampleRate,Ce=Yo(H.audioBuffer,Se,n,T,H.offsetSamples/ae,H.durationSamples/ae);return{clipId:H.id,trackName:W.name,peaks:Ce,startSample:H.startSample,durationSamples:H.durationSamples,fadeIn:H.fadeIn,fadeOut:H.fadeOut}}));Y(B)},[e,Se,n]),c.useEffect(()=>{if(u?.annotations){const T=u.annotations.map(B=>typeof B.start=="number"?B:ts(B));w(T)}},[u]);const ze=c.useCallback(()=>{be.current&&(cancelAnimationFrame(be.current),be.current=null);const T=()=>{const B=V.getContext().currentTime-$e.current,W=_e.current+B;if(ge.current=W,_(W),C.length>0){const U=C.find(H=>W>=H.start&&W<H.end);if(dt.current){if(U&&U.id!==J.current)We(U.id);else if(!U&&J.current!==null){const H=C[C.length-1];if(W>=H.end){N.current&&N.current.stop(),D(!1),ge.current=Ie.current,_(Ie.current),We(null);return}}}else if(J.current){const H=C.find(ae=>ae.id===J.current);if(H&&W>=H.end){N.current&&N.current.stop(),D(!1),ge.current=Ie.current,_(Ie.current);return}}else U&&We(U.id)}if(tt.current&&Be.current&&j.length>0){const U=Be.current,H=j[0].sampleRate,ae=W*H/ne.current,Ce=U.clientWidth,ce=l.show?l.width:0,me=ae+ce,pe=Math.max(0,me-Ce/2);U.scrollLeft=pe}if(Ze.current!==null&&W>=Ze.current){const U=ve.current!==we.current&&we.current>ve.current;if(he.current&&U){N.current?.stop();const ae=V.getContext().currentTime;$e.current=ae,_e.current=ve.current,ge.current=ve.current;const Ce=we.current-ve.current;Ze.current=ve.current+Ce,N.current?.play(ae,ve.current,Ce),be.current=requestAnimationFrame(T);return}else{N.current&&N.current.stop(),D(!1),ge.current=Ze.current,_(Ze.current),Ze.current=null;return}}if(W>=M){N.current&&N.current.stop(),D(!1),ge.current=Ie.current,_(Ie.current),We(null);return}be.current=requestAnimationFrame(T)};be.current=requestAnimationFrame(T)},[M,j,Se,C,fe]),ke=c.useCallback(()=>{be.current&&(cancelAnimationFrame(be.current),be.current=null)},[]);c.useEffect(()=>{(async()=>{if(I&&be.current&&N.current)if(fe){const B=ge.current;N.current.stop(),ke(),await N.current.init(),N.current.setOnPlaybackComplete(()=>{});const U=V.getContext().currentTime;$e.current=U,_e.current=B,N.current.play(U,B),ze()}else ke(),ze()})()},[fe,I,ze,ke]),c.useEffect(()=>{(async()=>{if(je.current&&N.current){const{position:B}=je.current;je.current=null,await N.current.init(),N.current.setOnPlaybackComplete(()=>{});const U=V.getContext().currentTime;$e.current=U,_e.current=B,N.current.play(U,B),D(!0),ze()}})()},[e,ze]);const nt=c.useCallback(async(T,B)=>{if(!N.current||j.length===0)return;await N.current.init(),await V.start();const W=T??ge.current;Ie.current=W,ge.current=W,N.current.setOnPlaybackComplete(()=>{}),N.current.stop(),ke();const H=V.getContext().currentTime;$e.current=H,_e.current=W,Ze.current=B!==void 0?W+B:null,N.current.play(H,W,B),D(!0),ze()},[j.length,ze,ke]),Xt=c.useCallback(()=>{if(!N.current)return;const T=V.getContext().currentTime-$e.current,B=_e.current+T;N.current.pause(),D(!1),ke(),ge.current=B,_(B)},[ke]),yt=c.useCallback(()=>{N.current&&(N.current.stop(),D(!1),ke(),ge.current=Ie.current,_(Ie.current),We(null))},[ke]),Yt=c.useCallback(T=>{const B=Math.max(0,Math.min(T,M));ge.current=B,_(B),I&&N.current&&(N.current.stop(),ke(),nt(B))},[M,I,nt,ke]),It=c.useCallback((T,B)=>{const W=[...K];if(W[T]={...W[T],muted:B},te(W),N.current){const U=`track-${T}`;N.current.setMute(U,B)}},[K]),At=c.useCallback((T,B)=>{const W=[...K];if(W[T]={...W[T],soloed:B},te(W),N.current){const U=`track-${T}`;N.current.setSolo(U,B)}},[K]),Lt=c.useCallback((T,B)=>{const W=[...K];if(W[T]={...W[T],volume:B},te(W),N.current){const U=`track-${T}`,H=N.current.getTrack(U);H&&H.setVolume(B)}},[K]),Kt=c.useCallback((T,B)=>{const W=[...K];if(W[T]={...W[T],pan:B},te(W),N.current){const U=`track-${T}`,H=N.current.getTrack(U);H&&H.setPan(B)}},[K]),St=c.useCallback((T,B)=>{L(T),S(B),ge.current=T,_(T),I&&N.current&&(N.current.stop(),N.current.play(V.getContext().currentTime,T))},[I]),kt=c.useCallback(T=>{Be.current=T},[]),Ut=j[0]?.sampleRate||44100,Rt=t?30:0,Jt=e.length*r+Rt,$t={isPlaying:I,currentTime:F,currentTimeRef:ge,playbackStartTimeRef:$e,audioStartPositionRef:_e},h={continuousPlay:fe,linkEndpoints:ye,annotationsEditable:De,isAutomaticScroll:Q,isLoopEnabled:Qe,annotations:C,activeAnnotationId:g,selectionStart:re,selectionEnd:oe,selectedTrackId:z},R={play:nt,pause:Xt,stop:yt,seekTo:Yt,setCurrentTime:T=>{ge.current=T,_(T)},setTrackMute:It,setTrackSolo:At,setTrackVolume:Lt,setTrackPan:Kt,setSelection:St,setSelectedTrackId:G,setTimeFormat:de,formatTime:Ve,zoomIn:Ae.zoomIn,zoomOut:Ae.zoomOut,setMasterVolume:Le,setAutomaticScroll:T=>{se(T)},setScrollContainer:kt,scrollContainerRef:Be,setContinuousPlay:Je,setLinkEndpoints:le,setAnnotationsEditable:ut,setAnnotations:w,setActiveAnnotationId:We,setLoopEnabled:wt},P={duration:M,audioBuffers:j,peaksDataArray:X,trackStates:K,tracks:e,sampleRate:Ut,waveHeight:r,timeScaleHeight:Rt,minimumPlaylistHeight:Jt,controls:l,playoutRef:N,samplesPerPixel:Se,timeFormat:Ee,masterVolume:He,canZoomIn:Ae.canZoomIn,canZoomOut:Ae.canZoomOut,barWidth:f,barGap:x,progressBarWidth:m},q={...$t,...h,...R,...P},ie={...Oa,...i};return O.jsx(k.ThemeProvider,{theme:ie,children:O.jsx(ea.Provider,{value:$t,children:O.jsx(ta.Provider,{value:h,children:O.jsx(na.Provider,{value:R,children:O.jsx(ra.Provider,{value:P,children:O.jsx(aa.Provider,{value:q,children:v})})})})})})},Te=()=>{const e=c.useContext(ea);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Ne=()=>{const e=c.useContext(ta);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},xe=()=>{const e=c.useContext(na);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},Re=()=>{const e=c.useContext(ra);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e},Si=()=>{const e=c.useContext(aa);if(!e)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return e},ki=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=Te(),{selectionStart:r,selectionEnd:a}=Ne(),{play:s}=xe(),o=async()=>{if(r!==a&&a>r){const i=a-r;await s(r,i)}else await s(n.current??0)};return O.jsx(Oe,{onClick:o,disabled:t,className:e,children:"Play"})},Ri=({className:e})=>{const{isPlaying:t}=Te(),{pause:n}=xe();return O.jsx(Oe,{onClick:n,disabled:!t,className:e,children:"Pause"})},$i=({className:e})=>{const{isPlaying:t}=Te(),{stop:n}=xe();return O.jsx(Oe,{onClick:n,disabled:!t,className:e,children:"Stop"})},Ei=({className:e})=>{const{isPlaying:t}=Te(),{play:n,setCurrentTime:r}=xe(),{playoutRef:a}=Re(),s=()=>{r(0),t&&a.current&&(a.current.stop(),n(0))};return O.jsx(Oe,{onClick:s,className:e,children:"Rewind"})},Ti=({className:e})=>{const{isPlaying:t}=Te(),{play:n,setCurrentTime:r}=xe(),{duration:a,playoutRef:s}=Re(),o=()=>{r(a),t&&s.current&&(s.current.stop(),n(a))};return O.jsx(Oe,{onClick:o,className:e,children:"Fast Forward"})},Di=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=Te(),{play:a,setCurrentTime:s}=xe(),{playoutRef:o}=Re(),i=()=>{const l=Math.max(0,(n.current??0)-e);s(l),r&&o.current&&(o.current.stop(),a(l))};return O.jsx(Oe,{onClick:i,className:t,children:"Skip Backward"})},_i=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=Te(),{play:a,setCurrentTime:s}=xe(),{duration:o,playoutRef:i}=Re(),l=()=>{const u=Math.min(o,(n.current??0)+e);s(u),r&&i.current&&(i.current.stop(),a(u))};return O.jsx(Oe,{onClick:l,className:t,children:"Skip Forward"})},Mi=({className:e})=>{const{isLoopEnabled:t,selectionStart:n,selectionEnd:r}=Ne(),{setLoopEnabled:a}=xe(),s=n!==r&&r>n,o=()=>{a(!t)};return O.jsx(Oe,{onClick:o,disabled:!s,className:e,title:s?t?"Disable loop":"Enable loop":"Create a selection to enable looping",children:t?"Loop On":"Loop Off"})},Bi=({className:e,disabled:t})=>{const{zoomIn:n}=xe(),{canZoomIn:r}=Re();return O.jsx(Oe,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},Wi=({className:e,disabled:t})=>{const{zoomOut:n}=xe(),{canZoomOut:r}=Re();return O.jsx(Oe,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},Fi=({className:e})=>{const{masterVolume:t}=Re(),{setMasterVolume:n}=xe();return O.jsx(io,{volume:t,onChange:n,className:e})},Pi=({className:e})=>{const{timeFormat:t}=Re(),{setTimeFormat:n}=xe();return O.jsx(Bo,{value:t,onChange:n,className:e})},Zi=k.span`
|
|
1211
|
+
`,Oi=({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 R.jsxs(Zi,{$width:n,$height:r,className:a,children:[R.jsx(Vi,{$level:s,$height:r}),t!==void 0&&o>0&&R.jsx(ji,{$peakLevel:o,$height:r}),R.jsxs(zi,{$height:r,children:[R.jsx(Dr,{$position:60,$height:r}),R.jsx(Dr,{$position:85,$height:r})]})]})};c.memo(Oi);function Ni(e,t,n,r={}){const{currentTime:a=0,audioConstraints:s,...o}=r,[i,l]=c.useState(!1),[u,d]=c.useState(null),{stream:g,devices:p,hasPermission:f,requestAccess:x,error:y}=Fi(),{level:v,peakLevel:m}=Wi(g),{isRecording:C,isPaused:w,duration:b,peaks:S,startRecording:I,stopRecording:E,pauseRecording:D,resumeRecording:_,error:B}=Bi(g,o),T=c.useCallback(async()=>{n&&(i||(await un(),l(!0)),await I())},[n,i,I]),V=c.useCallback(async()=>{const X=await E();if(X&&n){const G=e.findIndex(H=>H.id===n);if(G===-1)return;const ee=e[G],re=Math.floor(a*X.sampleRate);let L=0;if(ee.clips.length>0){const H=ee.clips.map(K=>K.startSample+K.durationSamples);L=Math.max(...H)}const oe=Math.max(re,L),A={id:`clip-${Date.now()}`,audioBuffer:X,startSample:oe,durationSamples:X.length,offsetSamples:0,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},j=e.map((H,K)=>K===G?{...H,clips:[...H.clips,A]}:H);t(j)}},[n,e,t,a,E]);c.useEffect(()=>{f&&p.length>0&&u===null&&d(p[0].deviceId)},[f,p.length]);const W=c.useCallback(async()=>{await x(void 0,s),await un(),l(!0)},[x,s]),O=c.useCallback(async X=>{d(X),await x(X,s),await un(),l(!0)},[x,s]);return{isRecording:C,isPaused:w,duration:b,level:v,peakLevel:m,error:y||B,stream:g,devices:p,hasPermission:f,selectedDevice:u,startRecording:T,stopRecording:V,pauseRecording:D,resumeRecording:_,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),Li=e=>Mt.filter(t=>t.category===e),Xi=[{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"}],Hi={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 Gi=0;const Yi=()=>`effect_${Date.now()}_${++Gi}`;function _t(e,t){const n=Hi[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(o=>{const i=t?.[o.name]??o.default;r[o.name]=i});const a=new n(r),s=Yi();return{effect:a,id:e.id,instanceId:s,dispose(){try{a.disconnect(),a.dispose()}catch{}},setParameter(o,i){o==="wet"&&a.wet?a.wet.value=i:a[o]!==void 0&&(a[o]?.value!==void 0?a[o].value=i:a[o]=i)},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 Ki(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 Ui(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),i=c.useCallback(v=>{const m=o.current;if(!m)return;const{masterGainNode:C,destination:w,analyserNode:b}=m;try{C.disconnect()}catch{}const S=v.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(S.length===0)C.connect(b),b.connect(w);else{let I=C;S.forEach(E=>{try{E.disconnect()}catch{}I.connect(E.effect),I=E.effect}),I.connect(b),b.connect(w)}},[]),l=c.useCallback(v=>{const m=Zn(v);if(!m){console.error(`Unknown effect: ${v}`);return}const C={};m.parameters.forEach(S=>{C[S.name]=S.default});const w=_t(m,C);a.current.set(w.instanceId,w);const b={instanceId:w.instanceId,effectId:m.id,definition:m,params:C,bypassed:!1};n(S=>[...S,b])},[]),u=c.useCallback(v=>{const m=a.current.get(v);m&&(m.dispose(),a.current.delete(v)),n(C=>C.filter(w=>w.instanceId!==v))},[]),d=c.useCallback((v,m,C)=>{const w=a.current.get(v);w&&w.setParameter(m,C),n(b=>b.map(S=>S.instanceId===v?{...S,params:{...S.params,[m]:C}}:S))},[]),g=c.useCallback(v=>{const m=r.current.find(b=>b.instanceId===v);if(!m)return;const C=!m.bypassed,w=a.current.get(v);if(w){const b=m.params.wet??1;w.setParameter("wet",C?0:b)}n(b=>b.map(S=>S.instanceId===v?{...S,bypassed:C}:S))},[]),p=c.useCallback((v,m)=>{n(C=>{const w=[...C],[b]=w.splice(v,1);return w.splice(m,0,b),w})},[]),f=c.useCallback(()=>{a.current.forEach(v=>v.dispose()),a.current.clear(),n([])},[]);c.useEffect(()=>{i(t)},[t,i]);const x=c.useCallback((v,m,C)=>{const w=new P.Analyser("fft",e);s.current=w,o.current={masterGainNode:v,destination:m,analyserNode:w};const S=r.current.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(S.length===0)v.connect(w),w.connect(m);else{let I=v;S.forEach(E=>{I.connect(E.effect),I=E.effect}),I.connect(w),w.connect(m)}return function(){w.dispose(),s.current=null,o.current=null}},[e]);c.useEffect(()=>()=>{a.current.forEach(v=>v.dispose()),a.current.clear()},[]);const y=c.useCallback(()=>{const v=t.filter(m=>!m.bypassed);if(v.length!==0)return(m,C,w)=>{const b=[];for(const S of v){const I=_t(S.definition,S.params);b.push(I)}if(b.length===0)m.connect(C);else{let S=m;b.forEach(I=>{S.connect(I.effect),S=I.effect}),S.connect(C)}return function(){b.forEach(I=>I.dispose())}}},[t]);return{activeEffects:t,availableEffects:Mt,addEffect:l,removeEffect:u,updateParameter:d,toggleBypass:g,reorderEffects:p,clearAllEffects:f,masterEffects:x,createOfflineEffectsFunction:y,analyserRef:s}}function Ji(){const[e,t]=c.useState(new Map),n=c.useRef(new Map),r=c.useRef(new Map),a=c.useCallback((f,x)=>{const y=r.current.get(f);if(!y)return;const{graphEnd:v,masterGainNode:m}=y,C=n.current.get(f);try{v.disconnect()}catch{}const w=x.map(b=>C?.get(b.instanceId)).filter(b=>b!==void 0);if(w.length===0)v.connect(m);else{let b=v;w.forEach(S=>{try{S.disconnect()}catch{}b.connect(S.effect),b=S.effect}),b.connect(m)}},[]),s=c.useCallback((f,x)=>{const y=Zn(x);if(!y){console.error(`Unknown effect: ${x}`);return}const v={};y.parameters.forEach(w=>{v[w.name]=w.default});const m=_t(y,v);n.current.has(f)||n.current.set(f,new Map),n.current.get(f).set(m.instanceId,m);const C={instanceId:m.instanceId,effectId:y.id,definition:y,params:v,bypassed:!1};t(w=>{const b=new Map(w),S=b.get(f)||[];return b.set(f,[...S,C]),b})},[]),o=c.useCallback((f,x)=>{const y=n.current.get(f),v=y?.get(x);v&&(v.dispose(),y?.delete(x)),t(m=>{const C=new Map(m),w=C.get(f)||[];return C.set(f,w.filter(b=>b.instanceId!==x)),C})},[]),i=c.useCallback((f,x,y,v)=>{const C=n.current.get(f)?.get(x);C&&C.setParameter(y,v),t(w=>{const b=new Map(w),S=b.get(f)||[];return b.set(f,S.map(I=>I.instanceId===x?{...I,params:{...I.params,[y]:v}}:I)),b})},[]),l=c.useCallback((f,x)=>{const v=(d.current.get(f)||[]).find(b=>b.instanceId===x);if(!v)return;const m=!v.bypassed,w=n.current.get(f)?.get(x);if(w){const b=v.params.wet??1;w.setParameter("wet",m?0:b)}t(b=>{const S=new Map(b),I=S.get(f)||[];return S.set(f,I.map(E=>E.instanceId===x?{...E,bypassed:m}:E)),S})},[]),u=c.useCallback(f=>{const x=n.current.get(f);x&&(x.forEach(y=>y.dispose()),x.clear()),t(y=>{const v=new Map(y);return v.set(f,[]),v})},[]),d=c.useRef(e);d.current=e;const g=c.useCallback(f=>(x,y,v)=>{r.current.set(f,{graphEnd:x,masterGainNode:y});const m=d.current.get(f)||[],C=n.current.get(f),w=m.map(b=>C?.get(b.instanceId)).filter(b=>b!==void 0);if(w.length===0)x.connect(y);else{let b=x;w.forEach(S=>{b.connect(S.effect),b=S.effect}),b.connect(y)}return function(){r.current.delete(f)}},[]);c.useEffect(()=>{e.forEach((f,x)=>{a(x,f)})},[e,a]),c.useEffect(()=>()=>{n.current.forEach(f=>{f.forEach(x=>x.dispose()),f.clear()}),n.current.clear()},[]);const p=c.useCallback(f=>{const y=(e.get(f)||[]).filter(v=>!v.bypassed);if(y.length!==0)return(v,m,C)=>{const w=[];for(const b of y){const S=_t(b.definition,b.params);w.push(S)}if(w.length===0)v.connect(m);else{let b=v;w.forEach(S=>{b.connect(S.effect),b=S.effect}),b.connect(m)}return function(){w.forEach(S=>S.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:u,getTrackEffectsFunction:g,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,i=r*o,l=a*i,u=s*i,d=44,g=d+u,p=new ArrayBuffer(g),f=new DataView(p);Nt(f,0,"RIFF"),f.setUint32(4,g-8,!0),Nt(f,8,"WAVE"),Nt(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,l,!0),f.setUint16(32,i,!0),f.setUint16(34,n,!0),Nt(f,36,"data"),f.setUint32(40,u,!0);const x=[];for(let v=0;v<r;v++)x.push(e.getChannelData(v));let y=d;if(n===16)for(let v=0;v<s;v++)for(let m=0;m<r;m++){const C=x[m][v],w=Math.max(-1,Math.min(1,C)),b=w<0?w*32768:w*32767;f.setInt16(y,b,!0),y+=2}else for(let v=0;v<s;v++)for(let m=0;m<r;m++)f.setFloat32(y,x[m][v],!0),y+=4;return new Blob([p],{type:"audio/wav"})}function Nt(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function Qi(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(i,l,u={})=>{const{filename:d="export",mode:g="master",trackIndex:p,autoDownload:f=!0,applyEffects:x=!0,effectsFunction:y,createOfflineTrackEffects:v,bitDepth:m=16,onProgress:C}=u;t(!0),r(0),s(null);try{if(i.length===0)throw new Error("No tracks to export");if(g==="individual"&&(p===void 0||p<0||p>=i.length))throw new Error("Invalid track index for individual export");const w=i[0].clips[0]?.audioBuffer.sampleRate||44100;let b=0;for(const T of i)for(const V of T.clips){const W=V.startSample+V.durationSamples;b=Math.max(b,W)}b+=Math.round(w*.1);const S=b/w,I=g==="individual"?[{track:i[p],state:l[p],index:p}]:i.map((T,V)=>({track:T,state:l[V],index:V})),E=l.some(T=>T.soloed),D=!!v;let _;if((y||D)&&x)_=await el(I,l,E,S,w,y,v,T=>{r(T),C?.(T)});else{const T=new OfflineAudioContext(2,b,w);let V=0;const W=I.reduce((O,{track:X})=>O+X.clips.length,0);for(const{track:O,state:X}of I)if(!(X.muted&&!X.soloed)&&!(E&&!X.soloed))for(const G of O.clips){await nl(T,G,X,w,x),V++;const ee=V/W*.5;r(ee),C?.(ee)}r(.5),C?.(.5),_=await T.startRendering()}r(.9),C?.(.9);const B=qi(_,{bitDepth:m});if(r(1),C?.(1),f){const T=g==="individual"?`${d}_${i[p].name}`:d;Qi(B,`${T}.wav`)}return{audioBuffer:_,blob:B,duration:S}}catch(w){const b=w instanceof Error?w.message:"Export failed";throw s(b),w}finally{t(!1)}},[]),isExporting:e,progress:n,error:a}}async function el(e,t,n,r,a,s,o,i){const{Offline:l,Volume:u,Gain:d,Panner:g,Player:p,ToneAudioBuffer:f}=await import("tone");i(.1);let x;try{x=await l(async({transport:y,destination:v})=>{const m=new u(0);let C;s?C=s(m,v,!0):m.connect(v);for(const{track:w,state:b}of e){if(b.muted&&!b.soloed||n&&!b.soloed)continue;const S=new u(tl(b.volume)),I=new g(b.pan),E=new d(b.muted?0:1),D=o?.(w.id);D?D(E,m,!0):E.connect(m),I.connect(E),S.connect(I);for(const _ of w.clips){const{audioBuffer:B,startSample:T,durationSamples:V,offsetSamples:W,gain:O,fadeIn:X,fadeOut:G}=_,ee=T/a,re=V/a,L=W/a,oe=new f(B),A=new p(oe),j=new d(O);if(A.connect(j),j.connect(S),X){const H=ee,K=ee+X.duration,be=j.gain._param;be.setValueAtTime(0,H),be.linearRampToValueAtTime(O,K)}if(G){const H=ee+re-G.duration,K=ee+re,be=j.gain._param;be.setValueAtTime(O,H),be.linearRampToValueAtTime(0,K)}A.start(ee,L,re)}}y.start(0)},r,2,a)}catch(y){throw y instanceof Error?y:new Error(`Tone.Offline rendering failed: ${String(y)}`)}return i(.9),x.get()}function tl(e){return 20*Math.log10(Math.max(e,1e-4))}async function nl(e,t,n,r,a){const{audioBuffer:s,startSample:o,durationSamples:i,offsetSamples:l,gain:u,fadeIn:d,fadeOut:g}=t,p=o/r,f=i/r,x=l/r,y=e.createBufferSource();y.buffer=s;const v=e.createGain(),m=u*n.volume,C=e.createStereoPanner();if(C.pan.value=n.pan,y.connect(v),v.connect(C),C.connect(e.destination),a){if(d?v.gain.setValueAtTime(0,p):v.gain.setValueAtTime(m,p),d){const w=p,b=p+d.duration;_r(v.gain,w,b,0,m,d.type||"linear")}if(g){const w=p+f-g.duration,b=p+f;(!d||d.duration<f-g.duration)&&v.gain.setValueAtTime(m,w),_r(v.gain,w,b,m,0,g.type||"linear")}}else v.gain.setValueAtTime(m,p);y.start(p,x,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 i=Math.max(r,1e-4),l=Math.max(a,1e-4);e.setValueAtTime(i,t),e.exponentialRampToValueAtTime(l,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 i=o/(n-1);let l;r==="logarithmic"?s>0?l=Math.log10(1+i*9)/Math.log10(10):l=1-Math.log10(1+(1-i)*9)/Math.log10(10):l=i*i*(3-2*i),a[o]=e+s*l}return a}const fa=c.createContext(null),ha=c.createContext(null),ma=c.createContext(null),pa=c.createContext(null),ga=c.createContext(null),rl=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:a=1024,zoomLevels:s,automaticScroll:o=!1,theme:i,controls:l={show:!1,width:0},annotationList:u,effects:d,onReady:g,onAnnotationUpdate:p,barWidth:f=1,barGap:x=0,progressBarWidth:y,children:v})=>{const m=y??f+x,[C,w]=c.useState([]),[b,S]=c.useState(null),[I,E]=c.useState(!1),[D,_]=c.useState(0),[B,T]=c.useState(0),[V,W]=c.useState([]),[O,X]=c.useState([]),[G,ee]=c.useState([]),[re,L]=c.useState(0),[oe,A]=c.useState(0),[j,H]=c.useState(null),[K,be]=c.useState(o),[Be,ie]=c.useState(u?.isContinuousPlay??!1),[De,ue]=c.useState(u?.linkEndpoints??!0),[he,gt]=c.useState(u?.editable??!1),[ut,de]=c.useState(!1),[rt,at]=c.useState(0),[Je,ot]=c.useState(0),z=c.useRef(null),Re=c.useRef(0),we=c.useRef(0),ve=c.useRef(null),Ze=c.useRef(G),Le=c.useRef(0),Pe=c.useRef(0),Xe=c.useRef(null),He=c.useRef(null),dt=c.useRef(!1),At=c.useRef(u?.isContinuousPlay??!1),Y=c.useRef(null),te=c.useRef(a),me=c.useRef(!1),ye=c.useRef(0),Ee=c.useRef(0),Ae=c.useRef(0),le=c.useRef(0),{timeFormat:Ge,setTimeFormat:Ye,formatTime:je}=ra(),_e=aa({initialSamplesPerPixel:a,zoomLevels:s}),Ie=_e.samplesPerPixel,{masterVolume:qe,setMasterVolume:ft}=oa({playoutRef:z,initialVolume:1}),Bt=c.useCallback(M=>{At.current=M,ie(M)},[]),st=c.useCallback(M=>{Y.current=M,S(M)},[]),Ft=c.useCallback(M=>{me.current=M,de(M)},[]),ht=c.useCallback((M,N)=>{Ae.current=M,le.current=N,at(M),ot(N)},[]),Wt=c.useCallback(()=>{const M=ye.current,N=Ee.current;M!==N&&N>M&&ht(M,N)},[ht]),Zt=c.useCallback(()=>{ht(0,0)},[ht]);c.useEffect(()=>{dt.current=K},[K]),c.useEffect(()=>{Ze.current=G},[G]),c.useEffect(()=>{ye.current=re,Ee.current=oe},[re,oe]),c.useEffect(()=>{if(!He.current||!V.length)return;const M=He.current,N=te.current,q=Ie;if(N===q)return;const fe=l.show?l.width:0,Q=M.clientWidth,Ke=M.scrollLeft+Q/2-fe,ge=V[0].sampleRate,Ue=Ke*N/ge*ge/q,mt=Math.max(0,Ue+fe-Q/2);M.scrollLeft=mt,te.current=q},[Ie,V,l]);const bt=c.useRef(null);c.useEffect(()=>{if(e.length===0){W([]),T(0),ee([]),X([]),z.current&&(z.current.dispose(),z.current=null);return}const M=I,N=we.current;return z.current&&M&&(z.current.stop(),ve.current&&(cancelAnimationFrame(ve.current),ve.current=null),bt.current={position:N}),(async()=>{try{const fe=[];e.forEach(ge=>{ge.clips.length>0&&fe.push(ge.clips[0].audioBuffer)});let Q=0;e.forEach(ge=>{ge.clips.forEach($e=>{const Ue=$e.audioBuffer.sampleRate,sn=($e.startSample+$e.durationSamples)/Ue;Q=Math.max(Q,sn)})}),W(fe),T(Q),ee(ge=>ge.length===e.length?ge.map(($e,Ue)=>({...$e,name:e[Ue].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 Ma({effects:d}),Ke=Ze.current;e.forEach((ge,$e)=>{if(ge.clips.length>0){const Ue=ge.clips[0].audioBuffer.sampleRate,mt=Math.min(...ge.clips.map(Ve=>Ve.startSample/Ue)),sn=Math.max(...ge.clips.map(Ve=>(Ve.startSample+Ve.durationSamples)/Ue)),Pt=Ke[$e],ba={id:`track-${$e}`,name:ge.name,gain:Pt?.volume??ge.volume,muted:Pt?.muted??ge.muted,soloed:Pt?.soloed??ge.soloed,stereoPan:Pt?.pan??ge.pan,startTime:mt,endTime:sn},va=ge.clips.map(Ve=>{const ln=Ve.audioBuffer.sampleRate;return{buffer:Ve.audioBuffer,startTime:Ve.startSample/ln-mt,duration:Ve.durationSamples/ln,offset:Ve.offsetSamples/ln,fadeIn:Ve.fadeIn,fadeOut:Ve.fadeOut,gain:Ve.gain}});Se.addTrack({clips:va,track:ba,effects:ge.effects})}}),Se.applyInitialSoloState(),z.current=Se,g?.()}catch(fe){console.error("Error loading audio:",fe)}})(),()=>{ve.current&&cancelAnimationFrame(ve.current),z.current&&z.current.dispose()}},[e,g,I]),c.useEffect(()=>{if(e.length===0)return;const M=16,N=e.map(q=>q.clips.map(Q=>{if(Q.waveformData){const Ke=ks(Q.waveformData,Ie,0,Q.offsetSamples,Q.durationSamples);return{clipId:Q.id,trackName:q.name,peaks:{length:Ke.length,data:[Ke.data],bits:Ke.bits},startSample:Q.startSample,durationSamples:Q.durationSamples,fadeIn:Q.fadeIn,fadeOut:Q.fadeOut}}const Se=is(Q.audioBuffer,Ie,n,M,Q.offsetSamples,Q.durationSamples);return{clipId:Q.id,trackName:q.name,peaks:Se,startSample:Q.startSample,durationSamples:Q.durationSamples,fadeIn:Q.fadeIn,fadeOut:Q.fadeOut}}));X(N)},[e,Ie,n]),c.useEffect(()=>{if(u?.annotations){const M=u.annotations.map(N=>typeof N.start=="number"?N:Bs(N));w(M)}},[u]);const Qe=c.useCallback(()=>{ve.current&&(cancelAnimationFrame(ve.current),ve.current=null);const M=()=>{const N=P.getContext().currentTime-Le.current,q=Pe.current+N;if(we.current=q,_(q),C.length>0){const Q=C.find(Se=>q>=Se.start&&q<Se.end);if(At.current){if(Q&&Q.id!==Y.current)st(Q.id);else if(!Q&&Y.current!==null){const Se=C[C.length-1];if(q>=Se.end){z.current&&z.current.stop(),E(!1),we.current=Re.current,_(Re.current),st(null);return}}}else if(Y.current){const Se=C.find(Ke=>Ke.id===Y.current);if(Se&&q>=Se.end){z.current&&z.current.stop(),E(!1),we.current=Re.current,_(Re.current);return}}else Q&&st(Q.id)}if(dt.current&&He.current&&V.length>0){const Q=He.current,Se=V[0].sampleRate,Ke=q*Se/te.current,ge=Q.clientWidth,$e=l.show?l.width:0,Ue=Ke+$e,mt=Math.max(0,Ue-ge/2);Q.scrollLeft=mt}if(Xe.current!==null&&q>=Xe.current){z.current&&z.current.stop(),E(!1),we.current=Xe.current,_(Xe.current),Xe.current=null;return}const fe=Ae.current!==le.current&&le.current>Ae.current;if(me.current&&fe&&q>=le.current){z.current?.stop();const Se=P.getContext().currentTime;Le.current=Se,Pe.current=Ae.current,we.current=Ae.current,z.current?.play(Se,Ae.current),ve.current=requestAnimationFrame(M);return}if(q>=B){z.current&&z.current.stop(),E(!1),we.current=Re.current,_(Re.current),st(null);return}ve.current=requestAnimationFrame(M)};ve.current=requestAnimationFrame(M)},[B,V,Ie,C,Be]),Fe=c.useCallback(()=>{ve.current&&(cancelAnimationFrame(ve.current),ve.current=null)},[]);c.useEffect(()=>{(async()=>{if(I&&ve.current&&z.current)if(Be){const N=we.current;z.current.stop(),Fe(),await z.current.init(),z.current.setOnPlaybackComplete(()=>{});const fe=P.getContext().currentTime;Le.current=fe,Pe.current=N,z.current.play(fe,N),Qe()}else Fe(),Qe()})()},[Be,I,Qe,Fe]),c.useEffect(()=>{(async()=>{if(bt.current&&z.current){const{position:N}=bt.current;bt.current=null,await z.current.init(),z.current.setOnPlaybackComplete(()=>{});const fe=P.getContext().currentTime;Le.current=fe,Pe.current=N,z.current.play(fe,N),E(!0),Qe()}})()},[e,Qe]);const vt=c.useCallback(async(M,N)=>{if(!z.current||V.length===0)return;await z.current.init(),await P.start();const q=M??we.current;Re.current=q,we.current=q,z.current.setOnPlaybackComplete(()=>{}),z.current.stop(),Fe();const Q=P.getContext().currentTime;Le.current=Q,Pe.current=q,Xe.current=N!==void 0?q+N:null,z.current.play(Q,q,N),E(!0),Qe()},[V.length,Qe,Fe]),nn=c.useCallback(()=>{if(!z.current)return;const M=P.getContext().currentTime-Le.current,N=Pe.current+M;z.current.pause(),E(!1),Fe(),we.current=N,_(N)},[Fe]),rn=c.useCallback(()=>{z.current&&(z.current.stop(),E(!1),Fe(),we.current=Re.current,_(Re.current),st(null))},[Fe]),an=c.useCallback(M=>{const N=Math.max(0,Math.min(M,B));we.current=N,_(N),I&&z.current&&(z.current.stop(),Fe(),vt(N))},[B,I,vt,Fe]),on=c.useCallback((M,N)=>{const q=[...G];if(q[M]={...q[M],muted:N},ee(q),z.current){const fe=`track-${M}`;z.current.setMute(fe,N)}},[G]),h=c.useCallback((M,N)=>{const q=[...G];if(q[M]={...q[M],soloed:N},ee(q),z.current){const fe=`track-${M}`;z.current.setSolo(fe,N)}},[G]),$=c.useCallback((M,N)=>{const q=[...G];if(q[M]={...q[M],volume:N},ee(q),z.current){const fe=`track-${M}`,Q=z.current.getTrack(fe);Q&&Q.setVolume(N)}},[G]),F=c.useCallback((M,N)=>{const q=[...G];if(q[M]={...q[M],pan:N},ee(q),z.current){const fe=`track-${M}`,Q=z.current.getTrack(fe);Q&&Q.setPan(N)}},[G]),U=c.useCallback((M,N)=>{L(M),A(N),we.current=M,_(M),I&&z.current&&(z.current.stop(),z.current.play(P.getContext().currentTime,M))},[I]),se=c.useCallback(M=>{He.current=M},[]),ce=V[0]?.sampleRate||44100,ae=t?30:0,ne=e.length*r+ae,ke={isPlaying:I,currentTime:D,currentTimeRef:we,playbackStartTimeRef:Le,audioStartPositionRef:Pe},pe={continuousPlay:Be,linkEndpoints:De,annotationsEditable:he,isAutomaticScroll:K,isLoopEnabled:ut,annotations:C,activeAnnotationId:b,selectionStart:re,selectionEnd:oe,selectedTrackId:j,loopStart:rt,loopEnd:Je},Ce={play:vt,pause:nn,stop:rn,seekTo:an,setCurrentTime:M=>{we.current=M,_(M)},setTrackMute:on,setTrackSolo:h,setTrackVolume:$,setTrackPan:F,setSelection:U,setSelectedTrackId:H,setTimeFormat:Ye,formatTime:je,zoomIn:_e.zoomIn,zoomOut:_e.zoomOut,setMasterVolume:ft,setAutomaticScroll:M=>{be(M)},setScrollContainer:se,scrollContainerRef:He,setContinuousPlay:Bt,setLinkEndpoints:ue,setAnnotationsEditable:gt,setAnnotations:w,setActiveAnnotationId:st,setLoopEnabled:Ft,setLoopRegion:ht,setLoopRegionFromSelection:Wt,clearLoopRegion:Zt},Me={duration:B,audioBuffers:V,peaksDataArray:O,trackStates:G,tracks:e,sampleRate:ce,waveHeight:r,timeScaleHeight:ae,minimumPlaylistHeight:ne,controls:l,playoutRef:z,samplesPerPixel:Ie,timeFormat:Ge,masterVolume:qe,canZoomIn:_e.canZoomIn,canZoomOut:_e.canZoomOut,barWidth:f,barGap:x,progressBarWidth:m},it={...ke,...pe,...Ce,...Me},et={...qa,...i};return Z.jsx(k.ThemeProvider,{theme:et,children:Z.jsx(fa.Provider,{value:ke,children:Z.jsx(ha.Provider,{value:pe,children:Z.jsx(ma.Provider,{value:Ce,children:Z.jsx(pa.Provider,{value:Me,children:Z.jsx(ga.Provider,{value:it,children:v})})})})})})},We=()=>{const e=c.useContext(fa);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Ne=()=>{const e=c.useContext(ha);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},xe=()=>{const e=c.useContext(ma);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},Te=()=>{const e=c.useContext(pa);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e},al=()=>{const e=c.useContext(ga);if(!e)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return e},ol=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=We(),{selectionStart:r,selectionEnd:a,isLoopEnabled:s}=Ne(),{play:o}=xe(),i=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(Oe,{onClick:i,disabled:t,className:e,children:"Play"})},sl=({className:e})=>{const{isPlaying:t}=We(),{pause:n}=xe();return Z.jsx(Oe,{onClick:n,disabled:!t,className:e,children:"Pause"})},il=({className:e})=>{const{isPlaying:t}=We(),{stop:n}=xe();return Z.jsx(Oe,{onClick:n,disabled:!t,className:e,children:"Stop"})},ll=({className:e})=>{const{isPlaying:t}=We(),{play:n,setCurrentTime:r}=xe(),{playoutRef:a}=Te(),s=()=>{r(0),t&&a.current&&(a.current.stop(),n(0))};return Z.jsx(Oe,{onClick:s,className:e,children:"Rewind"})},cl=({className:e})=>{const{isPlaying:t}=We(),{play:n,setCurrentTime:r}=xe(),{duration:a,playoutRef:s}=Te(),o=()=>{r(a),t&&s.current&&(s.current.stop(),n(a))};return Z.jsx(Oe,{onClick:o,className:e,children:"Fast Forward"})},ul=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=We(),{play:a,setCurrentTime:s}=xe(),{playoutRef:o}=Te(),i=()=>{const l=Math.max(0,(n.current??0)-e);s(l),r&&o.current&&(o.current.stop(),a(l))};return Z.jsx(Oe,{onClick:i,className:t,children:"Skip Backward"})},dl=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=We(),{play:a,setCurrentTime:s}=xe(),{duration:o,playoutRef:i}=Te(),l=()=>{const u=Math.min(o,(n.current??0)+e);s(u),r&&i.current&&(i.current.stop(),a(u))};return Z.jsx(Oe,{onClick:l,className:t,children:"Skip Forward"})},fl=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=Ne(),{setLoopEnabled:a,setLoopRegion:s}=xe(),{duration:o}=Te(),i=n!==r&&r>n,l=()=>{if(!t&&!i){const u=Math.min(10,o*.25);s(0,Math.max(1,u))}a(!t)};return Z.jsx(Oe,{onClick:l,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}=Ne(),{setLoopRegionFromSelection:s,clearLoopRegion:o}=xe(),i=t!==n&&n>t,l=r!==a&&a>r,u=()=>{l?o():s()};return Z.jsx(Oe,{onClick:u,disabled:!i&&!l,className:e,title:l?"Clear loop region":i?"Set loop region from selection":"Create a selection first",children:l?"Clear Loop":"Set Loop"})},ml=({className:e,disabled:t})=>{const{zoomIn:n}=xe(),{canZoomIn:r}=Te();return Z.jsx(Oe,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},pl=({className:e,disabled:t})=>{const{zoomOut:n}=xe(),{canZoomOut:r}=Te();return Z.jsx(Oe,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},gl=({className:e})=>{const{masterVolume:t}=Te(),{setMasterVolume:n}=xe();return Z.jsx(vo,{volume:t,onChange:n,className:e})},bl=({className:e})=>{const{timeFormat:t}=Te(),{setTimeFormat:n}=xe();return Z.jsx(Yo,{value:t,onChange:n,className:e})},vl=k.span`
|
|
1127
1212
|
font-family: 'Courier New', Monaco, monospace;
|
|
1128
1213
|
font-size: 1rem;
|
|
1129
1214
|
font-weight: 600;
|
|
1130
1215
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
1131
1216
|
user-select: none;
|
|
1132
|
-
`,
|
|
1217
|
+
`,Cl=({className:e})=>{const t=c.useRef(null),n=c.useRef(null),{isPlaying:r,currentTimeRef:a,playbackStartTimeRef:s,audioStartPositionRef:o}=We(),{timeFormat:i}=Te(),l=i;return c.useEffect(()=>{const u=()=>{if(t.current){let d;if(r){const g=P.getContext().currentTime-(s.current??0);d=(o.current??0)+g}else d=a.current??0;t.current.textContent=It(d,l)}r&&(n.current=requestAnimationFrame(u))};return r?n.current=requestAnimationFrame(u):u(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,l,a,s,o]),c.useEffect(()=>{!r&&t.current&&(t.current.textContent=It(a.current??0,l))}),Z.jsx(vl,{ref:t,className:e,"aria-label":"Audio position",children:It(a.current??0,l)})},xl=({className:e})=>{const{selectionStart:t,selectionEnd:n}=Ne(),{setSelection:r}=xe();return Z.jsx(To,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},wl=({className:e})=>{const{isAutomaticScroll:t}=Ne(),{setAutomaticScroll:n}=xe();return Z.jsx(Ja,{checked:t,onChange:n,className:e})},yl=({className:e})=>{const{continuousPlay:t}=Ne(),{setContinuousPlay:n}=xe();return Z.jsx(ti,{checked:t,onChange:n,className:e})},Il=({className:e})=>{const{linkEndpoints:t}=Ne(),{setLinkEndpoints:n}=xe();return Z.jsx(ni,{checked:t,onChange:n,className:e})},Sl=({className:e})=>{const{annotationsEditable:t}=Ne(),{setAnnotationsEditable:n}=xe();return Z.jsx(ri,{checked:t,onChange:n,className:e})},Al=({filename:e,className:t})=>{const{annotations:n}=Ne();return Z.jsx(oi,{annotations:n,filename:e,className:t})},kl=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:a=16,applyEffects:s=!0,effectsFunction:o,createOfflineTrackEffects:i,className:l,onExportComplete:u,onExportError:d})=>{const{tracks:g,trackStates:p}=Te(),{exportWav:f,isExporting:x,progress:y}=da(),v=async()=>{try{const C=await f(g,p,{filename:t,mode:n,trackIndex:r,bitDepth:a,applyEffects:s,effectsFunction:o,createOfflineTrackEffects:i,autoDownload:!0});u?.(C.blob)}catch(C){d?.(C instanceof Error?C:new Error("Export failed"))}},m=x?`Exporting ${Math.round(y*100)}%`:e;return Z.jsx(Oe,{onClick:v,disabled:x||g.length===0,className:l,children:m})},$l=k.div`
|
|
1133
1218
|
position: absolute;
|
|
1134
1219
|
top: 0;
|
|
1135
1220
|
left: 0;
|
|
@@ -1139,9 +1224,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1139
1224
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
1140
1225
|
pointer-events: none;
|
|
1141
1226
|
will-change: transform;
|
|
1142
|
-
`,
|
|
1227
|
+
`,Rl=({color:e="#ff0000",controlsOffset:t=0})=>{const n=c.useRef(null),r=c.useRef(null),{isPlaying:a,currentTimeRef:s,playbackStartTimeRef:o,audioStartPositionRef:i}=We(),{samplesPerPixel:l,sampleRate:u,progressBarWidth:d}=Te();return c.useEffect(()=>{const g=()=>{if(n.current){let p;if(a){const x=P.getContext().currentTime-(o.current??0);p=(i.current??0)+x}else p=s.current??0;const f=p*u/l+t;n.current.style.transform=`translate3d(${f}px, 0, 0)`}a&&(r.current=requestAnimationFrame(g))};return a?r.current=requestAnimationFrame(g):g(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[a,u,l,t,s,o,i]),c.useEffect(()=>{if(!a&&n.current){const p=(s.current??0)*u/l+t;n.current.style.transform=`translate3d(${p}px, 0, 0)`}}),Z.jsx($l,{ref:n,$color:e,$width:d,"data-playhead":!0})},El=k.div`
|
|
1143
1228
|
position: relative;
|
|
1144
|
-
`,
|
|
1229
|
+
`,Tl=k.div`
|
|
1145
1230
|
position: absolute;
|
|
1146
1231
|
top: ${e=>e.$top}px;
|
|
1147
1232
|
left: 0;
|
|
@@ -1153,7 +1238,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1153
1238
|
transform: translateZ(0);
|
|
1154
1239
|
backface-visibility: hidden;
|
|
1155
1240
|
will-change: transform;
|
|
1156
|
-
`,
|
|
1241
|
+
`,Dl=k.div`
|
|
1157
1242
|
position: absolute;
|
|
1158
1243
|
top: ${e=>e.$top}px;
|
|
1159
1244
|
left: 0;
|
|
@@ -1162,9 +1247,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1162
1247
|
pointer-events: none;
|
|
1163
1248
|
z-index: 1;
|
|
1164
1249
|
will-change: width;
|
|
1165
|
-
`,
|
|
1250
|
+
`,_l=k.div`
|
|
1166
1251
|
position: relative;
|
|
1167
1252
|
z-index: 2;
|
|
1168
|
-
`,Ar=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=c.useRef(null),a=c.useRef(null),s=An(),{waveHeight:o}=Nt(),{isPlaying:i,currentTimeRef:l,playbackStartTimeRef:u,audioStartPositionRef:d}=Te(),{samplesPerPixel:b,sampleRate:p}=Re(),f=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";c.useEffect(()=>{const m=()=>{if(r.current){let C;if(i){const I=V.getContext().currentTime-(u.current??0);C=(d.current??0)+I}else C=l.current??0;const w=C*p,g=e+t;let A=0;if(w<=e)A=0;else if(w>=g)A=n.length;else{const I=w-e;A=Math.floor(I/b)}r.current.style.width=`${A}px`}i&&(a.current=requestAnimationFrame(m))};return i?a.current=requestAnimationFrame(m):m(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[i,p,b,e,t,n.length,l,u,d]),c.useEffect(()=>{if(!i&&r.current){const C=(l.current??0)*p,w=e+t;let g=0;if(C<=e)g=0;else if(C>=w)g=n.length;else{const A=C-e;g=Math.floor(A/b)}r.current.style.width=`${g}px`}});const x=s?.waveformDrawMode||"inverted";let y;x==="inverted"?y=n.isSelected&&s?s.selectedWaveFillColor:s?.waveFillColor||"white":y=n.isSelected&&s?s.selectedWaveOutlineColor:s?.waveOutlineColor||"grey";const v=Ft(y);return O.jsxs(Ki,{children:[O.jsx(Ui,{$color:v,$height:o,$top:n.index*o,$width:n.length}),O.jsx(Ji,{ref:r,$color:f,$height:o,$top:n.index*o}),O.jsx(qi,{children:O.jsx(Ao,{...n,transparentBackground:!0})})]})},Qi=60,el=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:a,annotationTextHeight:s,className:o,showClipHeaders:i=!1,interactiveClips:l=!1,showFades:u=!1,touchOptimized:d=!1,recordingState:b})=>{const p=An(),{isPlaying:f,currentTimeRef:x,playbackStartTimeRef:y,audioStartPositionRef:v}=Te(),{selectionStart:m,selectionEnd:C,annotations:w,activeAnnotationId:g,annotationsEditable:A,linkEndpoints:I,continuousPlay:D,selectedTrackId:F}=Ne(),{setAnnotations:_,setActiveAnnotationId:M,setTrackMute:$,setTrackSolo:j,setTrackVolume:Z,setTrackPan:X,setSelection:Y,play:K,setScrollContainer:te,setSelectedTrackId:re,setCurrentTime:L}=xe(),{audioBuffers:oe,peaksDataArray:S,trackStates:z,tracks:G,duration:Q,samplesPerPixel:se,sampleRate:fe,waveHeight:ue,timeScaleHeight:ye,controls:le,playoutRef:De,barWidth:ut,barGap:Qe}=Re(),[et,N]=c.useState(!1),Ie=c.useRef(null),ge=c.useCallback(J=>{Ie.current=J,te(J)},[te]);let be=oe.length>0?Q:Qi;if(b?.isRecording){const ne=(b.startSample+b.durationSamples)/fe;be=Math.max(be,ne+10)}const Pe=Math.floor(be*fe/se),$e=async J=>{console.log("Annotation clicked:",J.id),M(J.id);const ne=D?void 0:J.end-J.start;await K(J.start,ne)},_e=c.useCallback(J=>{if(J>=0&&J<G.length){const ne=G[J];re(ne.id)}},[G,re]),Ze=J=>{const ne=J.currentTarget.getBoundingClientRect(),he=le.show?le.width:0,we=(J.clientX-ne.left-he)*se/fe,de=J.clientY-ne.top;let Ve=0,Ae=-1;for(let Se=0;Se<S.length;Se++){const He=S[Se],Je=(He.length>0?Math.max(...He.map(We=>We.peaks.data.length)):1)*ue+(i?22:0);if(de>=Ve&&de<Ve+Je){Ae=Se;break}Ve+=Je}Ae!==-1&&_e(Ae),N(!0),L(we),Y(we,we)},Be=J=>{if(!et)return;const ne=J.currentTarget.getBoundingClientRect(),he=le.show?le.width:0,we=(J.clientX-ne.left-he)*se/fe,Ee=Math.min(m,we),de=Math.max(m,we);Y(Ee,de)},tt=J=>{if(!et)return;N(!1);const ne=J.currentTarget.getBoundingClientRect(),he=le.show?le.width:0,we=(J.clientX-ne.left-he)*se/fe,Ee=Math.min(m,we),de=Math.max(m,we);Math.abs(de-Ee)<.1?(L(Ee),f&&De.current?(De.current.stop(),K(Ee)):De.current&&De.current.stop()):Y(Ee,de)};return G.some(J=>J.clips.length>0)&&(oe.length===0||S.length===0)?O.jsx("div",{className:o,children:"Loading waveform..."}):O.jsx(bo,{children:O.jsxs(In.Provider,{value:{samplesPerPixel:se,sampleRate:fe,zoomLevels:[se],waveHeight:ue,timeScaleHeight:ye,duration:be,controls:le,barWidth:ut,barGap:Qe},children:[O.jsx(Vr,{theme:p,backgroundColor:Ft(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Pe+(le.show?le.width:0),timescaleWidth:Pe,tracksWidth:Pe,controlsWidth:le.show?le.width:0,onTracksMouseDown:Ze,onTracksMouseMove:Be,onTracksMouseUp:tt,scrollContainerRef:ge,timescale:ye>0?O.jsx(Do,{duration:be*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:t}):void 0,children:O.jsxs(O.Fragment,{children:[S.map((J,ne)=>{const he=G[ne];if(!he)return null;const ve=z[ne]||{name:`Track ${ne+1}`,muted:!1,soloed:!1,volume:1,pan:0},we=e?e(ne):O.jsxs(jo,{onClick:()=>_e(ne),children:[O.jsx(zo,{style:{justifyContent:"center"},children:ve.name||`Track ${ne+1}`}),O.jsxs(Vo,{children:[O.jsx(Jn,{$variant:ve.muted?"danger":"outline",onClick:()=>$(ne,!ve.muted),children:"Mute"}),O.jsx(Jn,{$variant:ve.soloed?"info":"outline",onClick:()=>j(ne,!ve.soloed),children:"Solo"})]}),O.jsxs(Qn,{children:[O.jsx(Oo,{}),O.jsx(qn,{min:"0",max:"1",step:"0.01",value:ve.volume,onChange:de=>Z(ne,parseFloat(de.target.value))}),O.jsx(No,{})]}),O.jsxs(Qn,{children:[O.jsx("span",{children:"L"}),O.jsx(qn,{min:"-1",max:"1",step:"0.01",value:ve.pan,onChange:de=>X(ne,parseFloat(de.target.value))}),O.jsx("span",{children:"R"})]})]}),Ee=J.length>0?Math.max(...J.map(de=>de.peaks.data.length)):1;return O.jsx(Nr.Provider,{value:we,children:O.jsxs(Zo,{numChannels:Ee,backgroundColor:Ft(p.waveOutlineColor),offset:0,width:Pe,hasClipHeaders:i,trackId:he.id,isSelected:he.id===F,children:[J.map((de,Ve)=>{const Ae=de.peaks,Se=Ae.length;return O.jsx(Kn,{clipId:de.clipId,trackIndex:ne,clipIndex:Ve,trackName:de.trackName,startSample:de.startSample,durationSamples:de.durationSamples,samplesPerPixel:se,showHeader:i,disableHeaderDrag:!l,isSelected:he.id===F,trackId:he.id,fadeIn:de.fadeIn,fadeOut:de.fadeOut,sampleRate:fe,showFades:u,touchOptimized:d,onMouseDown:He=>{He.target.closest('[role="button"][aria-roledescription="draggable"]')||_e(ne)},children:Ae.data.map((He,Le)=>O.jsx(Ar,{index:Le,data:He,bits:Ae.bits,length:Se,isSelected:he.id===F,clipStartSample:de.startSample,clipDurationSamples:de.durationSamples},`${ne}-${Ve}-${Le}`))},`${ne}-${Ve}`)}),b?.isRecording&&b.trackId===he.id&&b.peaks.length>0&&O.jsx(Kn,{clipId:"recording-preview",trackIndex:ne,clipIndex:J.length,trackName:"Recording...",startSample:b.startSample,durationSamples:b.durationSamples,samplesPerPixel:se,showHeader:i,disableHeaderDrag:!0,isSelected:he.id===F,trackId:he.id,children:O.jsx(Ar,{index:0,data:b.peaks,bits:16,length:Math.floor(b.peaks.length/2),isSelected:he.id===F,clipStartSample:b.startSample,clipDurationSamples:b.durationSamples},`${ne}-recording-0`)},`${ne}-recording`)]})},he.id)}),w.length>0&&O.jsx(us,{height:30,width:Pe,children:w.map((J,ne)=>{const he=J.start*fe/se,ve=J.end*fe/se;return O.jsx(ss,{annotationId:J.id,annotationIndex:ne,startPosition:he,endPosition:ve,label:J.id,color:"#ff9800",isActive:J.id===g,onClick:()=>$e(J),editable:A},J.id)})}),m!==C&&O.jsx(po,{startPosition:Math.min(m,C)*fe/se+(le.show?le.width:0),endPosition:Math.max(m,C)*fe/se+(le.show?le.width:0),color:p.selectionColor}),(f||m===C)&&(n?n({position:(x.current??0)*fe/se+(le.show?le.width:0),color:p.playheadColor,isPlaying:f,currentTimeRef:x,playbackStartTimeRef:y,audioStartPositionRef:v,samplesPerPixel:se,sampleRate:fe,controlsOffset:le.show?le.width:0,getAudioContextTime:()=>V.getContext().currentTime}):O.jsx(Li,{color:p.playheadColor,controlsOffset:le.show?le.width:0}))]})}),w.length>0&&O.jsx(ws,{annotations:w,activeAnnotationId:g??void 0,shouldScrollToActive:!0,editable:A,controls:A?r:void 0,annotationListConfig:{linkEndpoints:I,continuousPlay:D},height:s,onAnnotationUpdate:J=>{_(J)}})]})})};function qe(e,t){this._waveformData=e,this._channelIndex=t}qe.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};qe.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};qe.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};qe.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};qe.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};qe.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 tl=127,nl=-128,rl=32767,al=-32768;function ol(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function sl(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($){return new Float32Array($)}),i=r?o.length:1,l=24,u=ol(a,t),d=e.bits===8?1:2,b=l+u*2*d*i,p=new ArrayBuffer(b),f=new DataView(p),x=0,y=l,v=new Array(i),m=new Array(i),C=0;C<i;C++)v[C]=1/0,m[C]=-1/0;var w=e.bits===8?nl:al,g=e.bits===8?tl:rl;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,i,!0);for(var A=0;A<a;A++){var I=0;if(i===1){for(var D=0;D<o.length;++D)I+=o[D][A];I=Math.floor(g*I*n/o.length),I<v[0]&&(v[0]=I,v[0]<w&&(v[0]=w)),I>m[0]&&(m[0]=I,m[0]>g&&(m[0]=g))}else for(var F=0;F<i;++F)I=Math.floor(g*o[F][A]*n),I<v[F]&&(v[F]=I,v[F]<w&&(v[F]=w)),I>m[F]&&(m[F]=I,m[F]>g&&(m[F]=g));if(++x===t){for(var _=0;_<i;_++)e.bits===8?(f.setInt8(y++,v[_]),f.setInt8(y++,m[_])):(f.setInt16(y,v[_],!0),f.setInt16(y+2,m[_],!0),y+=4),v[_]=1/0,m[_]=-1/0;x=0}}if(x>0)for(var M=0;M<i;M++)e.bits===8?(f.setInt8(y++,v[M]),f.setInt8(y++,m[M])):(f.setInt16(y,v[M],!0),f.setInt16(y+2,m[M],!0));return p}function Zt(e){"@babel/helpers - typeof";return Zt=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},Zt(e)}function il(e){return e&&Zt(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function ll(e){var t=e&&Zt(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 cl(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,i=new ArrayBuffer(o),l=new DataView(i);l.setInt32(0,2,!0),l.setUint32(4,e.bits===8,!0),l.setInt32(8,e.sample_rate,!0),l.setInt32(12,e.samples_per_pixel,!0),l.setInt32(16,e.length,!0),l.setInt32(20,n,!0);var u=r;if(e.bits===8)for(var d=0;d<t.length;d++)l.setInt8(u++,t[d],!0);else for(var b=0;b<t.length;b++)l.setInt16(u,t[b],!0),u+=2;return i}function at(e){return e==null}function ul(e,t){var n=atob(e);return n}function dl(e,t,n){var r=ul(e),a=r.indexOf(`
|
|
1169
|
-
`,10)+1,s=r.substring(a)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function fl(e,t,n){var r;return function(s){return r=r||dl(e),new Worker(r,s)}}var hl=fl("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function Fe(e){if(il(e)&&(e=cl(e)),ll(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 qe(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var vt={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function ml(e){var t={scale:e.scale||vt.scale,bits:e.bits||vt.bits,amplitude_scale:e.amplitude_scale||vt.amplitude_scale,split_channels:e.split_channels||vt.split_channels,disable_worker:e.disable_worker||vt.disable_worker};return t}function pl(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function oa(e,t,n){var r=pl(e);if(t.disable_worker){var a=sl({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 Fe(a),e)}else{var s=new hl;s.onmessage=function(o){n(void 0,new Fe(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 gl(e,t,n,r){function a(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var s=e.decodeAudioData(t,function(o){oa(o,n,r)},a);s&&s.catch(a)}Fe.create=function(t){return new Fe(t)};Fe.createFromAudio=function(e,t){var n=ml(e);if(e.audio_context&&e.array_buffer)return gl(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return oa(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Gt(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 Fe(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 i=0;i<o;++i)this._input_buffer_size>0?(this._min[i]=this._inputData.channel(i).min_sample(this._input_index),this._max[i]=this._inputData.channel(i).max_sample(this._input_index)):(this._min[i]=0,this._max[i]=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}Gt.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};Gt.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 i=r.min_sample(this._input_index);i<this._min[o]&&(this._min[o]=i),i=r.max_sample(this._input_index),i>this._max[o]&&(this._max[o]=i)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var l=0;l<n;++l)r=this._outputWaveformData.channel(l),r.set_min_sample(this._output_index-1,this._min[l]),r.set_max_sample(this._output_index-1,this._max[l]);return!0};Gt.prototype.getOutputData=function(){return this._output_data};Fe.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!at(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!at(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 Gt(t);!n.next(););return new Fe(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 Fe.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 i=s[o],l=new DataView(i).getInt32(16,!0);r+=i.byteLength-n,a+=l}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,x=new Uint8Array(u,n),y=0;y<s.length;y++){var v=s[y];x.set(new Uint8Array(v,n),f),f+=v.byteLength-n}return u},slice:function(t){var n=0,r=0;if(!at(t.startIndex)&&!at(t.endIndex)?(n=t.startIndex,r=t.endIndex):!at(t.startTime)&&!at(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,i=s+a*2*this.channels*o,l=new ArrayBuffer(i),u=new DataView(l);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 Fe(l)},_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 $n(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 Fe.create(r)}else{const r=await t.json();return Fe.create(r)}}function sa(e,t=0){const n=e.channel(t),r=e.bits,a=n.min_array(),s=n.max_array(),o=a.length,i=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let l=0;l<o;l++)i[l*2]=a[l],i[l*2+1]=s[l];return{data:i,bits:r,length:o,sampleRate:e.sample_rate}}async function bl(e,t=0){const n=await $n(e);return sa(n,t)}async function vl(e){const t=await $n(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}exports.Tone=kr;exports.AudioPosition=Vi;exports.AutomaticScrollCheckbox=zi;exports.ContinuousPlayCheckbox=Oi;exports.DownloadAnnotationsButton=Gi;exports.EditableCheckbox=Hi;exports.ExportWavButton=Xi;exports.FastForwardButton=Ti;exports.LinkEndpointsCheckbox=Ni;exports.LoopButton=Mi;exports.MasterVolumeControl=Fi;exports.PauseButton=Ri;exports.PlayButton=ki;exports.RewindButton=Ei;exports.SelectionTimeInputs=ji;exports.SkipBackwardButton=Di;exports.SkipForwardButton=_i;exports.StopButton=$i;exports.TimeFormatSelect=Pi;exports.Waveform=el;exports.WaveformPlaylistProvider=Ai;exports.ZoomInButton=Bi;exports.ZoomOutButton=Wi;exports.createEffectChain=gi;exports.createEffectInstance=Ct;exports.effectCategories=fi;exports.effectDefinitions=xt;exports.getEffectDefinition=Rn;exports.getEffectsByCategory=di;exports.getShortcutLabel=Ks;exports.getWaveformDataMetadata=vl;exports.loadPeaksFromWaveformData=bl;exports.loadWaveformData=$n;exports.useAnnotationDragHandlers=Ms;exports.useAnnotationKeyboardControls=Js;exports.useAudioTracks=Ds;exports.useClipDragHandlers=_s;exports.useClipSplitting=Ls;exports.useDragSensors=Ys;exports.useDynamicEffects=bi;exports.useExportWav=Qr;exports.useIntegratedRecording=ui;exports.useKeyboardShortcuts=Pt;exports.useMasterAnalyser=$s;exports.useMasterVolume=Yr;exports.usePlaybackAnimation=Te;exports.usePlaybackShortcuts=Us;exports.usePlaylistControls=xe;exports.usePlaylistData=Re;exports.usePlaylistState=Ne;exports.useTimeFormat=Gr;exports.useTrackDynamicEffects=vi;exports.useWaveformPlaylist=Si;exports.useZoomControls=Xr;exports.waveformDataToPeaks=sa;
|
|
1253
|
+
`,Br=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=c.useRef(null),a=c.useRef(null),s=Mn(),{waveHeight:o}=Qt(),{isPlaying:i,currentTimeRef:l,playbackStartTimeRef:u,audioStartPositionRef:d}=We(),{samplesPerPixel:g,sampleRate:p}=Te(),f=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";c.useEffect(()=>{const m=()=>{if(r.current){let C;if(i){const I=P.getContext().currentTime-(u.current??0);C=(d.current??0)+I}else C=l.current??0;const w=C*p,b=e+t;let S=0;if(w<=e)S=0;else if(w>=b)S=n.length;else{const I=w-e;S=Math.floor(I/g)}r.current.style.width=`${S}px`}i&&(a.current=requestAnimationFrame(m))};return i?a.current=requestAnimationFrame(m):m(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[i,p,g,e,t,n.length,l,u,d]),c.useEffect(()=>{if(!i&&r.current){const C=(l.current??0)*p,w=e+t;let b=0;if(C<=e)b=0;else if(C>=w)b=n.length;else{const S=C-e;b=Math.floor(S/g)}r.current.style.width=`${b}px`}});const x=s?.waveformDrawMode||"inverted";let y;x==="inverted"?y=n.isSelected&&s?s.selectedWaveFillColor:s?.waveFillColor||"white":y=n.isSelected&&s?s.selectedWaveOutlineColor:s?.waveOutlineColor||"grey";const v=Ht(y);return Z.jsxs(El,{children:[Z.jsx(Tl,{$color:v,$height:o,$top:n.index*o,$width:n.length}),Z.jsx(Dl,{ref:r,$color:f,$height:o,$top:n.index*o}),Z.jsx(_l,{children:Z.jsx(Po,{...n,transparentBackground:!0})})]})},Ml=60,Bl=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:a,annotationTextHeight:s,className:o,showClipHeaders:i=!1,interactiveClips:l=!1,showFades:u=!1,touchOptimized:d=!1,recordingState:g})=>{const p=Mn(),{isPlaying:f,currentTimeRef:x,playbackStartTimeRef:y,audioStartPositionRef:v}=We(),{selectionStart:m,selectionEnd:C,annotations:w,activeAnnotationId:b,annotationsEditable:S,linkEndpoints:I,continuousPlay:E,selectedTrackId:D,loopStart:_,loopEnd:B,isLoopEnabled:T}=Ne(),{setAnnotations:V,setActiveAnnotationId:W,setTrackMute:O,setTrackSolo:X,setTrackVolume:G,setTrackPan:ee,setSelection:re,play:L,setScrollContainer:oe,setSelectedTrackId:A,setCurrentTime:j,setLoopRegion:H}=xe(),{audioBuffers:K,peaksDataArray:be,trackStates:Be,tracks:ie,duration:De,samplesPerPixel:ue,sampleRate:he,waveHeight:gt,timeScaleHeight:ut,controls:de,playoutRef:rt,barWidth:at,barGap:Je}=Te(),[ot,z]=c.useState(!1),Re=c.useRef(null),we=c.useCallback(Y=>{Re.current=Y,oe(Y)},[oe]);let ve=K.length>0?De:Ml;if(g?.isRecording){const te=(g.startSample+g.durationSamples)/he;ve=Math.max(ve,te+10)}const Ze=Math.floor(ve*he/ue),Le=async Y=>{console.log("Annotation clicked:",Y.id),W(Y.id);const te=E?void 0:Y.end-Y.start;await L(Y.start,te)},Pe=c.useCallback(Y=>{if(Y>=0&&Y<ie.length){const te=ie[Y];A(te.id)}},[ie,A]),Xe=Y=>{const te=Y.currentTarget.getBoundingClientRect(),me=de.show?de.width:0,Ee=(Y.clientX-te.left-me)*ue/he,le=Y.clientY-te.top;let Ge=0,Ye=-1;for(let je=0;je<be.length;je++){const _e=be[je],qe=(_e.length>0?Math.max(..._e.map(ft=>ft.peaks.data.length)):1)*gt+(i?22:0);if(le>=Ge&&le<Ge+qe){Ye=je;break}Ge+=qe}Ye!==-1&&Pe(Ye),z(!0),j(Ee),re(Ee,Ee)},He=Y=>{if(!ot)return;const te=Y.currentTarget.getBoundingClientRect(),me=de.show?de.width:0,Ee=(Y.clientX-te.left-me)*ue/he,Ae=Math.min(m,Ee),le=Math.max(m,Ee);re(Ae,le)},dt=Y=>{if(!ot)return;z(!1);const te=Y.currentTarget.getBoundingClientRect(),me=de.show?de.width:0,Ee=(Y.clientX-te.left-me)*ue/he,Ae=Math.min(m,Ee),le=Math.max(m,Ee);Math.abs(le-Ae)<.1?(j(Ae),f&&rt.current?(rt.current.stop(),L(Ae)):rt.current&&rt.current.stop()):re(Ae,le)};return ie.some(Y=>Y.clips.length>0)&&(K.length===0||be.length===0)?Z.jsx("div",{className:o,children:"Loading waveform..."}):Z.jsx(Do,{children:Z.jsxs(_n.Provider,{value:{samplesPerPixel:ue,sampleRate:he,zoomLevels:[ue],waveHeight:gt,timeScaleHeight:ut,duration:ve,controls:de,barWidth:at,barGap:Je},children:[Z.jsx(Kr,{theme:p,backgroundColor:Ht(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Ze+(de.show?de.width:0),timescaleWidth:Ze,tracksWidth:Ze,controlsWidth:de.show?de.width:0,onTracksMouseDown:Xe,onTracksMouseMove:He,onTracksMouseUp:dt,scrollContainerRef:we,isSelecting:ot,timescale:ut>0?Z.jsxs(Z.Fragment,{children:[Z.jsx(Xo,{duration:ve*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:t}),T&&Z.jsx(Eo,{startPosition:Math.min(_,B)*he/ue,endPosition:Math.max(_,B)*he/ue,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:Ze,controlsOffset:de.show?de.width:0,onLoopRegionChange:(Y,te)=>{const me=Y*ue/he,ye=te*ue/he;H(me,ye)}})]}):void 0,children:Z.jsxs(Z.Fragment,{children:[be.map((Y,te)=>{const me=ie[te];if(!me)return null;const ye=Be[te]||{name:`Track ${te+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ee=e?e(te):Z.jsxs(es,{onClick:()=>Pe(te),children:[Z.jsx(ts,{style:{justifyContent:"center"},children:ye.name||`Track ${te+1}`}),Z.jsxs(Qo,{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:()=>X(te,!ye.soloed),children:"Solo"})]}),Z.jsxs(cr,{children:[Z.jsx(ns,{}),Z.jsx(lr,{min:"0",max:"1",step:"0.01",value:ye.volume,onChange:le=>G(te,parseFloat(le.target.value))}),Z.jsx(rs,{})]}),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=Y.length>0?Math.max(...Y.map(le=>le.peaks.data.length)):1;return Z.jsx(Qr.Provider,{value:Ee,children:Z.jsxs(qo,{numChannels:Ae,backgroundColor:Ht(p.waveOutlineColor),offset:0,width:Ze,hasClipHeaders:i,trackId:me.id,isSelected:me.id===D,children:[Y.map((le,Ge)=>{const Ye=le.peaks,je=Ye.length;return Z.jsx(ar,{clipId:le.clipId,trackIndex:te,clipIndex:Ge,trackName:le.trackName,startSample:le.startSample,durationSamples:le.durationSamples,samplesPerPixel:ue,showHeader:i,disableHeaderDrag:!l,isSelected:me.id===D,trackId:me.id,fadeIn:le.fadeIn,fadeOut:le.fadeOut,sampleRate:he,showFades:u,touchOptimized:d,onMouseDown:_e=>{_e.target.closest('[role="button"][aria-roledescription="draggable"]')||Pe(te)},children:Ye.data.map((_e,Ie)=>Z.jsx(Br,{index:Ie,data:_e,bits:Ye.bits,length:je,isSelected:me.id===D,clipStartSample:le.startSample,clipDurationSamples:le.durationSamples},`${te}-${Ge}-${Ie}`))},`${te}-${Ge}`)}),g?.isRecording&&g.trackId===me.id&&g.peaks.length>0&&Z.jsx(ar,{clipId:"recording-preview",trackIndex:te,clipIndex:Y.length,trackName:"Recording...",startSample:g.startSample,durationSamples:g.durationSamples,samplesPerPixel:ue,showHeader:i,disableHeaderDrag:!0,isSelected:me.id===D,trackId:me.id,children:Z.jsx(Br,{index:0,data:g.peaks,bits:16,length:Math.floor(g.peaks.length/2),isSelected:me.id===D,clipStartSample:g.startSample,clipDurationSamples:g.durationSamples},`${te}-recording-0`)},`${te}-recording`)]})},me.id)}),w.length>0&&Z.jsx(Ns,{height:30,width:Ze,children:w.map((Y,te)=>{const me=Y.start*he/ue,ye=Y.end*he/ue;return Z.jsx(Vs,{annotationId:Y.id,annotationIndex:te,startPosition:me,endPosition:ye,label:Y.id,color:"#ff9800",isActive:Y.id===b,onClick:()=>Le(Y),editable:S},Y.id)})}),m!==C&&Z.jsx(Ao,{startPosition:Math.min(m,C)*he/ue+(de.show?de.width:0),endPosition:Math.max(m,C)*he/ue+(de.show?de.width:0),color:p.selectionColor}),(f||m===C)&&(n?n({position:(x.current??0)*he/ue+(de.show?de.width:0),color:p.playheadColor,isPlaying:f,currentTimeRef:x,playbackStartTimeRef:y,audioStartPositionRef:v,samplesPerPixel:ue,sampleRate:he,controlsOffset:de.show?de.width:0,getAudioContextTime:()=>P.getContext().currentTime}):Z.jsx(Rl,{color:p.playheadColor,controlsOffset:de.show?de.width:0}))]})}),w.length>0&&Z.jsx(ei,{annotations:w,activeAnnotationId:b??void 0,shouldScrollToActive:!0,editable:S,controls:S?r:void 0,annotationListConfig:{linkEndpoints:I,continuousPlay:E},height:s,onAnnotationUpdate:Y=>{V(Y)}})]})})};exports.Tone=Wr;exports.AudioPosition=Cl;exports.AutomaticScrollCheckbox=wl;exports.ContinuousPlayCheckbox=yl;exports.DownloadAnnotationsButton=Al;exports.EditableCheckbox=Sl;exports.ExportWavButton=kl;exports.FastForwardButton=cl;exports.LinkEndpointsCheckbox=Il;exports.LoopButton=fl;exports.MasterVolumeControl=gl;exports.PauseButton=sl;exports.PlayButton=ol;exports.RewindButton=ll;exports.SelectionTimeInputs=xl;exports.SetLoopRegionButton=hl;exports.SkipBackwardButton=ul;exports.SkipForwardButton=dl;exports.StopButton=il;exports.TimeFormatSelect=bl;exports.Waveform=Bl;exports.WaveformPlaylistProvider=rl;exports.ZoomInButton=ml;exports.ZoomOutButton=pl;exports.createEffectChain=Ki;exports.createEffectInstance=_t;exports.effectCategories=Xi;exports.effectDefinitions=Mt;exports.getEffectDefinition=Zn;exports.getEffectsByCategory=Li;exports.getShortcutLabel=Ri;exports.getWaveformDataMetadata=As;exports.loadPeaksFromWaveformData=Ss;exports.loadWaveformData=Bn;exports.useAnnotationDragHandlers=fi;exports.useAnnotationKeyboardControls=Ti;exports.useAudioTracks=ui;exports.useClipDragHandlers=di;exports.useClipSplitting=$i;exports.useDragSensors=ki;exports.useDynamicEffects=Ui;exports.useExportWav=da;exports.useIntegratedRecording=Ni;exports.useKeyboardShortcuts=Yt;exports.useMasterAnalyser=ii;exports.useMasterVolume=oa;exports.usePlaybackAnimation=We;exports.usePlaybackShortcuts=Ei;exports.usePlaylistControls=xe;exports.usePlaylistData=Te;exports.usePlaylistState=Ne;exports.useTimeFormat=ra;exports.useTrackDynamicEffects=Ji;exports.useWaveformPlaylist=al;exports.useZoomControls=aa;exports.waveformDataToPeaks=na;
|
|
1170
1254
|
//# sourceMappingURL=index.js.map
|