@waveform-playlist/browser 5.0.0-alpha.5 → 5.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,23 +1,28 @@
1
- "use strict";var Or=Object.create;var bn=Object.defineProperty;var Nr=Object.getOwnPropertyDescriptor;var Hr=Object.getOwnPropertyNames;var Gr=Object.getPrototypeOf,Xr=Object.prototype.hasOwnProperty;var Yr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Hr(t))!Xr.call(e,a)&&a!==n&&bn(e,a,{get:()=>t[a],enumerable:!(r=Nr(t,a))||r.enumerable});return e};var Lr=(e,t,n)=>(n=e!=null?Or(Gr(e)):{},Yr(t||!e||!e.__esModule?bn(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("tone"),u=require("react"),$=require("styled-components");require("react-dom");var Nt=typeof document<"u"?document.currentScript:null;function ar(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 or=ar(F),X=ar(u);var wt={exports:{}},ut={};var vn;function Kr(){if(vn)return ut;vn=1;var e=u,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(l,i,d){var f,b={},p=null,h=null;d!==void 0&&(p=""+d),i.key!==void 0&&(p=""+i.key),i.ref!==void 0&&(h=i.ref);for(f in i)r.call(i,f)&&!s.hasOwnProperty(f)&&(b[f]=i[f]);if(l&&l.defaultProps)for(f in i=l.defaultProps,i)b[f]===void 0&&(b[f]=i[f]);return{$$typeof:t,type:l,key:p,ref:h,props:b,_owner:a.current}}return ut.Fragment=n,ut.jsx=o,ut.jsxs=o,ut}var dt={};var Cn;function Ur(){return Cn||(Cn=1,process.env.NODE_ENV!=="production"&&(function(){var e=u,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),i=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),x=Symbol.iterator,I="@@iterator";function v(c){if(c===null||typeof c!="object")return null;var S=x&&c[x]||c[I];return typeof S=="function"?S:null}var m=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(c){{for(var S=arguments.length,R=new Array(S>1?S-1:0),T=1;T<S;T++)R[T-1]=arguments[T];y("error",c,R)}}function y(c,S,R){{var T=m.ReactDebugCurrentFrame,L=T.getStackAddendum();L!==""&&(S+="%s",R=R.concat([L]));var J=R.map(function(P){return String(P)});J.unshift("Warning: "+S),Function.prototype.apply.call(console[c],console,J)}}var g=!1,k=!1,A=!1,E=!1,_=!1,B;B=Symbol.for("react.module.reference");function M(c){return!!(typeof c=="string"||typeof c=="function"||c===r||c===s||_||c===a||c===d||c===f||E||c===h||g||k||A||typeof c=="object"&&c!==null&&(c.$$typeof===p||c.$$typeof===b||c.$$typeof===o||c.$$typeof===l||c.$$typeof===i||c.$$typeof===B||c.getModuleId!==void 0))}function D(c,S,R){var T=c.displayName;if(T)return T;var L=S.displayName||S.name||"";return L!==""?R+"("+L+")":R}function Z(c){return c.displayName||"Context"}function W(c){if(c==null)return null;if(typeof c.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case a:return"StrictMode";case d:return"Suspense";case f:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case l:var S=c;return Z(S)+".Consumer";case o:var R=c;return Z(R._context)+".Provider";case i:return D(c,c.render,"ForwardRef");case b:var T=c.displayName||null;return T!==null?T:W(c.type)||"Memo";case p:{var L=c,J=L._payload,P=L._init;try{return W(P(J))}catch{return null}}}return null}var O=Object.assign,N=0,G,K,Q,H,ee,ie,ce;function q(){}q.__reactDisabledLog=!0;function re(){{if(N===0){G=console.log,K=console.info,Q=console.warn,H=console.error,ee=console.group,ie=console.groupCollapsed,ce=console.groupEnd;var c={configurable:!0,enumerable:!0,value:q,writable:!0};Object.defineProperties(console,{info:c,log:c,warn:c,error:c,group:c,groupCollapsed:c,groupEnd:c})}N++}}function te(){{if(N--,N===0){var c={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},c,{value:G}),info:O({},c,{value:K}),warn:O({},c,{value:Q}),error:O({},c,{value:H}),group:O({},c,{value:ee}),groupCollapsed:O({},c,{value:ie}),groupEnd:O({},c,{value:ce})})}N<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var fe=m.ReactCurrentDispatcher,Ne;function Ze(c,S,R){{if(Ne===void 0)try{throw Error()}catch(L){var T=L.stack.trim().match(/\n( *(at )?)/);Ne=T&&T[1]||""}return`
2
- `+Ne+c}}var ae=!1,Me;{var at=typeof WeakMap=="function"?WeakMap:Map;Me=new at}function V(c,S){if(!c||ae)return"";{var R=Me.get(c);if(R!==void 0)return R}var T;ae=!0;var L=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var J;J=fe.current,fe.current=null,re();try{if(S){var P=function(){throw Error()};if(Object.defineProperty(P.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(P,[])}catch(ne){T=ne}Reflect.construct(c,[],P)}else{try{P.call()}catch(ne){T=ne}c.call(P.prototype)}}else{try{throw Error()}catch(ne){T=ne}c()}}catch(ne){if(ne&&T&&typeof ne.stack=="string"){for(var z=ne.stack.split(`
3
- `),le=T.stack.split(`
4
- `),se=z.length-1,de=le.length-1;se>=1&&de>=0&&z[se]!==le[de];)de--;for(;se>=1&&de>=0;se--,de--)if(z[se]!==le[de]){if(se!==1||de!==1)do if(se--,de--,de<0||z[se]!==le[de]){var Ce=`
5
- `+z[se].replace(" at new "," at ");return c.displayName&&Ce.includes("<anonymous>")&&(Ce=Ce.replace("<anonymous>",c.displayName)),typeof c=="function"&&Me.set(c,Ce),Ce}while(se>=1&&de>=0);break}}}finally{ae=!1,fe.current=J,te(),Error.prepareStackTrace=L}var Xe=c?c.displayName||c.name:"",je=Xe?Ze(Xe):"";return typeof c=="function"&&Me.set(c,je),je}function Se(c,S,R){return V(c,!1)}function pe(c){var S=c.prototype;return!!(S&&S.isReactComponent)}function he(c,S,R){if(c==null)return"";if(typeof c=="function")return V(c,pe(c));if(typeof c=="string")return Ze(c);switch(c){case d:return Ze("Suspense");case f:return Ze("SuspenseList")}if(typeof c=="object")switch(c.$$typeof){case i:return Se(c.render);case b:return he(c.type,S,R);case p:{var T=c,L=T._payload,J=T._init;try{return he(J(L),S,R)}catch{}}}return""}var _e=Object.prototype.hasOwnProperty,we={},Ie=m.ReactDebugCurrentFrame;function Re(c){if(c){var S=c._owner,R=he(c.type,c._source,S?S.type:null);Ie.setExtraStackFrame(R)}else Ie.setExtraStackFrame(null)}function Ee(c,S,R,T,L){{var J=Function.call.bind(_e);for(var P in c)if(J(c,P)){var z=void 0;try{if(typeof c[P]!="function"){var le=Error((T||"React class")+": "+R+" type `"+P+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof c[P]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw le.name="Invariant Violation",le}z=c[P](S,P,T,R,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(se){z=se}z&&!(z instanceof Error)&&(Re(L),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).",T||"React class",R,P,typeof z),Re(null)),z instanceof Error&&!(z.message in we)&&(we[z.message]=!0,Re(L),C("Failed %s type: %s",R,z.message),Re(null))}}}var Je=Array.isArray;function He(c){return Je(c)}function Pe(c){{var S=typeof Symbol=="function"&&Symbol.toStringTag,R=S&&c[Symbol.toStringTag]||c.constructor.name||"Object";return R}}function qe(c){try{return Y(c),!1}catch{return!0}}function Y(c){return""+c}function U(c){if(qe(c))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Pe(c)),Y(c)}var ue=m.ReactCurrentOwner,ge={key:!0,ref:!0,__self:!0,__source:!0},me,ke;function oe(c){if(_e.call(c,"ref")){var S=Object.getOwnPropertyDescriptor(c,"ref").get;if(S&&S.isReactWarning)return!1}return c.ref!==void 0}function Be(c){if(_e.call(c,"key")){var S=Object.getOwnPropertyDescriptor(c,"key").get;if(S&&S.isReactWarning)return!1}return c.key!==void 0}function xe(c,S){typeof c.ref=="string"&&ue.current}function De(c,S){{var R=function(){me||(me=!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)",S))};R.isReactWarning=!0,Object.defineProperty(c,"key",{get:R,configurable:!0})}}function ye(c,S){{var R=function(){ke||(ke=!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)",S))};R.isReactWarning=!0,Object.defineProperty(c,"ref",{get:R,configurable:!0})}}var ve=function(c,S,R,T,L,J,P){var z={$$typeof:t,type:c,key:S,ref:R,props:P,_owner:J};return z._store={},Object.defineProperty(z._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(z,"_self",{configurable:!1,enumerable:!1,writable:!1,value:T}),Object.defineProperty(z,"_source",{configurable:!1,enumerable:!1,writable:!1,value:L}),Object.freeze&&(Object.freeze(z.props),Object.freeze(z)),z};function Ve(c,S,R,T,L){{var J,P={},z=null,le=null;R!==void 0&&(U(R),z=""+R),Be(S)&&(U(S.key),z=""+S.key),oe(S)&&(le=S.ref,xe(S,L));for(J in S)_e.call(S,J)&&!ge.hasOwnProperty(J)&&(P[J]=S[J]);if(c&&c.defaultProps){var se=c.defaultProps;for(J in se)P[J]===void 0&&(P[J]=se[J])}if(z||le){var de=typeof c=="function"?c.displayName||c.name||"Unknown":c;z&&De(P,de),le&&ye(P,de)}return ve(c,z,le,L,T,ue.current,P)}}var Le=m.ReactCurrentOwner,gt=m.ReactDebugCurrentFrame;function Ge(c){if(c){var S=c._owner,R=he(c.type,c._source,S?S.type:null);gt.setExtraStackFrame(R)}else gt.setExtraStackFrame(null)}var ot;ot=!1;function st(c){return typeof c=="object"&&c!==null&&c.$$typeof===t}function bt(){{if(Le.current){var c=W(Le.current.type);if(c)return`
1
+ "use strict";var ca=Object.create;var En=Object.defineProperty;var ua=Object.getOwnPropertyDescriptor;var da=Object.getOwnPropertyNames;var fa=Object.getPrototypeOf,ha=Object.prototype.hasOwnProperty;var ma=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of da(t))!ha.call(e,a)&&a!==n&&En(e,a,{get:()=>t[a],enumerable:!(r=ua(t,a))||r.enumerable});return e};var pa=(e,t,n)=>(n=e!=null?ca(fa(e)):{},ma(t||!e||!e.__esModule?En(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("tone"),c=require("react"),k=require("styled-components");require("react-dom");var Qt=typeof document<"u"?document.currentScript:null;function Sr(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 kr=Sr(V),ee=Sr(c);var Et={exports:{}},ht={};var Tn;function ga(){if(Tn)return ht;Tn=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 ht.Fragment=t,ht.jsx=n,ht.jsxs=n,ht}var mt={};var Dn;function ba(){return Dn||(Dn=1,process.env.NODE_ENV!=="production"&&(function(){function e(S){if(S==null)return null;if(typeof S=="function")return S.$$typeof===$?null:S.displayName||S.name||null;if(typeof S=="string")return S;switch(S){case v:return"Fragment";case C:return"Profiler";case m:return"StrictMode";case I:return"Suspense";case D:return"SuspenseList";case M:return"Activity"}if(typeof S=="object")switch(typeof S.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),S.$$typeof){case y:return"Portal";case g:return S.displayName||"Context";case w:return(S._context.displayName||"Context")+".Consumer";case A:var z=S.render;return S=S.displayName,S||(S=z.displayName||z.name||"",S=S!==""?"ForwardRef("+S+")":"ForwardRef"),S;case F:return z=S.displayName||null,z!==null?z:e(S.type)||"Memo";case _:z=S._payload,S=S._init;try{return e(S(z))}catch{}}return null}function t(S){return""+S}function n(S){try{t(S);var z=!1}catch{z=!0}if(z){z=console;var G=z.error,Q=typeof Symbol=="function"&&Symbol.toStringTag&&S[Symbol.toStringTag]||S.constructor.name||"Object";return G.call(z,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Q),t(S)}}function r(S){if(S===v)return"<>";if(typeof S=="object"&&S!==null&&S.$$typeof===_)return"<...>";try{var z=e(S);return z?"<"+z+">":"<...>"}catch{return"<...>"}}function a(){var S=j.A;return S===null?null:S.getOwner()}function s(){return Error("react-stack-top-frame")}function o(S){if(Z.call(S,"key")){var z=Object.getOwnPropertyDescriptor(S,"key").get;if(z&&z.isReactWarning)return!1}return S.key!==void 0}function i(S,z){function G(){K||(K=!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)",z))}G.isReactWarning=!0,Object.defineProperty(S,"key",{get:G,configurable:!0})}function l(){var S=e(this.type);return te[S]||(te[S]=!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.")),S=this.props.ref,S!==void 0?S:null}function u(S,z,G,Q,se,fe){var ue=G.ref;return S={$$typeof:x,type:S,key:z,props:G,_owner:Q},(ue!==void 0?ue:null)!==null?Object.defineProperty(S,"ref",{enumerable:!1,get:l}):Object.defineProperty(S,"ref",{enumerable:!1,value:null}),S._store={},Object.defineProperty(S._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(S,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(S,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:se}),Object.defineProperty(S,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:fe}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S}function d(S,z,G,Q,se,fe){var ue=z.children;if(ue!==void 0)if(Q)if(X(ue)){for(Q=0;Q<ue.length;Q++)b(ue[Q]);Object.freeze&&Object.freeze(ue)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(ue);if(Z.call(z,"key")){ue=e(S);var ye=Object.keys(z).filter(function(De){return De!=="key"});Q=0<ye.length?"{key: someKey, "+ye.join(": ..., ")+": ...}":"{key: someKey}",oe[ue+Q]||(ye=0<ye.length?"{"+ye.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,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
+ `+ue+h}}var le=!1,De;{var ut=typeof WeakMap=="function"?WeakMap:Map;De=new ut}function Qe(h,R){if(!h||le)return"";{var P=De.get(h);if(P!==void 0)return P}var q;le=!0;var ie=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var T;T=fe.current,fe.current=null,Q();try{if(R){var B=function(){throw Error()};if(Object.defineProperty(B.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(B,[])}catch(pe){q=pe}Reflect.construct(h,[],B)}else{try{B.call()}catch(pe){q=pe}h.call(B.prototype)}}else{try{throw Error()}catch(pe){q=pe}h()}}catch(pe){if(pe&&q&&typeof pe.stack=="string"){for(var W=pe.stack.split(`
8
+ `),U=q.stack.split(`
9
+ `),H=W.length-1,ae=U.length-1;H>=1&&ae>=0&&W[H]!==U[ae];)ae--;for(;H>=1&&ae>=0;H--,ae--)if(W[H]!==U[ae]){if(H!==1||ae!==1)do if(H--,ae--,ae<0||W[H]!==U[ae]){var Ce=`
10
+ `+W[H].replace(" at new "," at ");return h.displayName&&Ce.includes("<anonymous>")&&(Ce=Ce.replace("<anonymous>",h.displayName)),typeof h=="function"&&De.set(h,Ce),Ce}while(H>=1&&ae>=0);break}}}finally{le=!1,fe.current=T,se(),Error.prepareStackTrace=ie}var ce=h?h.displayName||h.name:"",me=ce?ye(ce):"";return typeof h=="function"&&De.set(h,me),me}function et(h,R,P){return Qe(h,!1)}function N(h){var R=h.prototype;return!!(R&&R.isReactComponent)}function Ie(h,R,P){if(h==null)return"";if(typeof h=="function")return Qe(h,N(h));if(typeof h=="string")return ye(h);switch(h){case u:return ye("Suspense");case d:return ye("SuspenseList")}if(typeof h=="object")switch(h.$$typeof){case l:return et(h.render);case b:return Ie(h.type,R,P);case p:{var q=h,ie=q._payload,T=q._init;try{return Ie(T(ie),R,P)}catch{}}}return""}var ge=Object.prototype.hasOwnProperty,be={},Pe=m.ReactDebugCurrentFrame;function $e(h){if(h){var R=h._owner,P=Ie(h.type,h._source,R?R.type:null);Pe.setExtraStackFrame(P)}else Pe.setExtraStackFrame(null)}function _e(h,R,P,q,ie){{var T=Function.call.bind(ge);for(var B in h)if(T(h,B)){var W=void 0;try{if(typeof h[B]!="function"){var U=Error((q||"React class")+": "+P+" type `"+B+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof h[B]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw U.name="Invariant Violation",U}W=h[B](R,B,q,P,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(H){W=H}W&&!(W instanceof Error)&&($e(ie),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).",q||"React class",P,B,typeof W),$e(null)),W instanceof Error&&!(W.message in be)&&(be[W.message]=!0,$e(ie),C("Failed %s type: %s",P,W.message),$e(null))}}}var Ze=Array.isArray;function Be(h){return Ze(h)}function tt(h){{var R=typeof Symbol=="function"&&Symbol.toStringTag,P=R&&h[Symbol.toStringTag]||h.constructor.name||"Object";return P}}function dt(h){try{return J(h),!1}catch{return!0}}function J(h){return""+h}function ne(h){if(dt(h))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",tt(h)),J(h)}var he=m.ReactCurrentOwner,ve={key:!0,ref:!0,__self:!0,__source:!0},we,Ee;function de(h){if(ge.call(h,"ref")){var R=Object.getOwnPropertyDescriptor(h,"ref").get;if(R&&R.isReactWarning)return!1}return h.ref!==void 0}function Ve(h){if(ge.call(h,"key")){var R=Object.getOwnPropertyDescriptor(h,"key").get;if(R&&R.isReactWarning)return!1}return h.key!==void 0}function Ae(h,R){typeof h.ref=="string"&&he.current}function Se(h,R){{var P=function(){we||(we=!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)",R))};P.isReactWarning=!0,Object.defineProperty(h,"key",{get:P,configurable:!0})}}function He(h,R){{var P=function(){Ee||(Ee=!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)",R))};P.isReactWarning=!0,Object.defineProperty(h,"ref",{get:P,configurable:!0})}}var Le=function(h,R,P,q,ie,T,B){var W={$$typeof:t,type:h,key:R,ref:P,props:B,_owner:T};return W._store={},Object.defineProperty(W._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(W,"_self",{configurable:!1,enumerable:!1,writable:!1,value:q}),Object.defineProperty(W,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ie}),Object.freeze&&(Object.freeze(W.props),Object.freeze(W)),W};function Je(h,R,P,q,ie){{var T,B={},W=null,U=null;P!==void 0&&(ne(P),W=""+P),Ve(R)&&(ne(R.key),W=""+R.key),de(R)&&(U=R.ref,Ae(R,ie));for(T in R)ge.call(R,T)&&!ve.hasOwnProperty(T)&&(B[T]=R[T]);if(h&&h.defaultProps){var H=h.defaultProps;for(T in H)B[T]===void 0&&(B[T]=H[T])}if(W||U){var ae=typeof h=="function"?h.displayName||h.name||"Unknown":h;W&&Se(B,ae),U&&He(B,ae)}return Le(h,W,U,ie,q,he.current,B)}}var We=m.ReactCurrentOwner,wt=m.ReactDebugCurrentFrame;function je(h){if(h){var R=h._owner,P=Ie(h.type,h._source,R?R.type:null);wt.setExtraStackFrame(P)}else wt.setExtraStackFrame(null)}var ze;ze=!1;function ke(h){return typeof h=="object"&&h!==null&&h.$$typeof===t}function nt(){{if(We.current){var h=Z(We.current.type);if(h)return`
6
11
 
7
- Check the render method of \``+c+"`."}return""}}function Pt(c){return""}var vt={};function Vt(c){{var S=bt();if(!S){var R=typeof c=="string"?c:c.displayName||c.name;R&&(S=`
12
+ Check the render method of \``+h+"`."}return""}}function Xt(h){return""}var yt={};function Yt(h){{var R=nt();if(!R){var P=typeof h=="string"?h:h.displayName||h.name;P&&(R=`
8
13
 
9
- Check the top-level render call using <`+R+">.")}return S}}function Ct(c,S){{if(!c._store||c._store.validated||c.key!=null)return;c._store.validated=!0;var R=Vt(S);if(vt[R])return;vt[R]=!0;var T="";c&&c._owner&&c._owner!==Le.current&&(T=" It was passed a child from "+W(c._owner.type)+"."),Ge(c),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',R,T),Ge(null)}}function it(c,S){{if(typeof c!="object")return;if(He(c))for(var R=0;R<c.length;R++){var T=c[R];st(T)&&Ct(T,S)}else if(st(c))c._store&&(c._store.validated=!0);else if(c){var L=v(c);if(typeof L=="function"&&L!==c.entries)for(var J=L.call(c),P;!(P=J.next()).done;)st(P.value)&&Ct(P.value,S)}}}function jt(c){{var S=c.type;if(S==null||typeof S=="string")return;var R;if(typeof S=="function")R=S.propTypes;else if(typeof S=="object"&&(S.$$typeof===i||S.$$typeof===b))R=S.propTypes;else return;if(R){var T=W(S);Ee(R,c.props,"prop",T,c)}else if(S.PropTypes!==void 0&&!ot){ot=!0;var L=W(S);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",L||"Unknown")}typeof S.getDefaultProps=="function"&&!S.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xt(c){{for(var S=Object.keys(c.props),R=0;R<S.length;R++){var T=S[R];if(T!=="children"&&T!=="key"){Ge(c),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",T),Ge(null);break}}c.ref!==null&&(Ge(c),C("Invalid attribute `ref` supplied to `React.Fragment`."),Ge(null))}}var lt={};function ct(c,S,R,T,L,J){{var P=M(c);if(!P){var z="";(c===void 0||typeof c=="object"&&c!==null&&Object.keys(c).length===0)&&(z+=" 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 le=Pt();le?z+=le:z+=bt();var se;c===null?se="null":He(c)?se="array":c!==void 0&&c.$$typeof===t?(se="<"+(W(c.type)||"Unknown")+" />",z=" Did you accidentally export a JSX literal instead of a component?"):se=typeof c,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",se,z)}var de=Ve(c,S,R,L,J);if(de==null)return de;if(P){var Ce=S.children;if(Ce!==void 0)if(T)if(He(Ce)){for(var Xe=0;Xe<Ce.length;Xe++)it(Ce[Xe],c);Object.freeze&&Object.freeze(Ce)}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 it(Ce,c)}if(_e.call(S,"key")){var je=W(c),ne=Object.keys(S).filter(function(zr){return zr!=="key"}),Ke=ne.length>0?"{key: someKey, "+ne.join(": ..., ")+": ...}":"{key: someKey}";if(!lt[je+Ke]){var jr=ne.length>0?"{"+ne.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX:
14
+ Check the top-level render call using <`+P+">.")}return R}}function It(h,R){{if(!h._store||h._store.validated||h.key!=null)return;h._store.validated=!0;var P=Yt(R);if(yt[P])return;yt[P]=!0;var q="";h&&h._owner&&h._owner!==We.current&&(q=" It was passed a child from "+Z(h._owner.type)+"."),je(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.',P,q),je(null)}}function At(h,R){{if(typeof h!="object")return;if(Be(h))for(var P=0;P<h.length;P++){var q=h[P];ke(q)&&It(q,R)}else if(ke(h))h._store&&(h._store.validated=!0);else if(h){var ie=v(h);if(typeof ie=="function"&&ie!==h.entries)for(var T=ie.call(h),B;!(B=T.next()).done;)ke(B.value)&&It(B.value,R)}}}function Lt(h){{var R=h.type;if(R==null||typeof R=="string")return;var P;if(typeof R=="function")P=R.propTypes;else if(typeof R=="object"&&(R.$$typeof===l||R.$$typeof===b))P=R.propTypes;else return;if(P){var q=Z(R);_e(P,h.props,"prop",q,h)}else if(R.PropTypes!==void 0&&!ze){ze=!0;var ie=Z(R);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ie||"Unknown")}typeof R.getDefaultProps=="function"&&!R.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Kt(h){{for(var R=Object.keys(h.props),P=0;P<R.length;P++){var q=R[P];if(q!=="children"&&q!=="key"){je(h),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",q),je(null);break}}h.ref!==null&&(je(h),C("Invalid attribute `ref` supplied to `React.Fragment`."),je(null))}}var St={};function kt(h,R,P,q,ie,T){{var B=M(h);if(!B){var W="";(h===void 0||typeof h=="object"&&h!==null&&Object.keys(h).length===0)&&(W+=" 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 U=Xt();U?W+=U:W+=nt();var H;h===null?H="null":Be(h)?H="array":h!==void 0&&h.$$typeof===t?(H="<"+(Z(h.type)||"Unknown")+" />",W=" Did you accidentally export a JSX literal instead of a component?"):H=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",H,W)}var ae=Je(h,R,P,ie,T);if(ae==null)return ae;if(B){var Ce=R.children;if(Ce!==void 0)if(q)if(Be(Ce)){for(var ce=0;ce<Ce.length;ce++)At(Ce[ce],h);Object.freeze&&Object.freeze(Ce)}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 At(Ce,h)}if(ge.call(R,"key")){var me=Z(h),pe=Object.keys(R).filter(function(rt){return rt!=="key"}),Ge=pe.length>0?"{key: someKey, "+pe.join(": ..., ")+": ...}":"{key: someKey}";if(!St[me+Ge]){var ft=pe.length>0?"{"+pe.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX:
10
15
  let props = %s;
11
16
  <%s {...props} />
12
17
  React keys must be passed directly to JSX without using spread:
13
18
  let props = %s;
14
- <%s key={someKey} {...props} />`,Ke,je,jr,je),lt[je+Ke]=!0}}return c===r?xt(de):jt(de),de}}function yt(c,S,R){return ct(c,S,R,!0)}function zt(c,S,R){return ct(c,S,R,!1)}var Ot=zt,j=yt;dt.Fragment=r,dt.jsx=Ot,dt.jsxs=j})()),dt}var xn;function Jr(){return xn||(xn=1,process.env.NODE_ENV==="production"?wt.exports=Kr():wt.exports=Ur()),wt.exports}var w=Jr();function yn(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 qr(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 Qr(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 ea(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 sr(e,t,n){switch(e){case"linear":return yn(t,n);case"exponential":return qr(t,n);case"sCurve":return Qr(t,n);case"logarithmic":return ea(t,n);default:return yn(t,n)}}function wn(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=sr(r,1e4,!0),l=new Float32Array(o.length),i=s-a;for(let d=0;d<o.length;d++)l[d]=a+o[d]*i;e.setValueCurveAtTime(l,t,n)}}function In(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=sr(r,1e4,!1),l=new Float32Array(o.length),i=a-s;for(let d=0;d<o.length;d++)l[d]=s+o[d]*i;e.setValueCurveAtTime(l,t,n)}}var ta=class{constructor(e){this.activePlayers=0,this.track=e.track,this.volumeNode=new F.Volume(this.gainToDb(e.track.gain)),this.panNode=new F.Panner(e.track.stereoPan),this.muteGain=new F.Gain(e.track.muted?0:1);const t=e.destination||F.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 F.Player({url:r.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),s=new F.Gain(r.gain);return a.connect(s),s.chain(this.volumeNode,this.panNode,this.muteGain),{player:a,clipInfo:r,fadeGain:s,pausedPosition:0,playStartTime:0}})}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGain:a}=e,s=a.gain._param;s.cancelScheduledValues(0);const o=n-r.offset;if(r.fadeIn&&o<r.fadeIn.duration){const l=r.fadeIn.duration;if(o<=0)wn(s,t,l,r.fadeIn.type||"linear",0,r.gain);else{const i=l-o,d=o/l,f=r.gain*d;wn(s,t,i,r.fadeIn.type||"linear",f,r.gain)}}else s.setValueAtTime(r.gain,t);if(r.fadeOut){const i=r.duration-r.fadeOut.duration-o;if(i>0){const d=t+i;In(s,d,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(i>-r.fadeOut.duration){const d=-i,f=r.fadeOut.duration-d,b=d/r.fadeOut.duration,p=r.gain*(1-b);In(s,t,f,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??F.now();this.isPlaying&&this.stop(),this.activePlayers=0,this.clips.forEach(a=>{const{player:s,clipInfo:o}=a,l=t,i=o.startTime,d=o.startTime+o.duration;if(l<d)if(this.activePlayers++,a.playStartTime=F.now(),l>=i){const f=l-i+o.offset,b=o.duration-(l-i),p=n?Math.min(n,b):b;a.pausedPosition=f,this.scheduleFades(a,r,f),s.start(r,f,p)}else{const f=i-l,b=n?Math.min(n-f,o.duration):o.duration;f<(n??1/0)?(a.pausedPosition=o.offset,this.scheduleFades(a,r+f,o.offset),s.start(r+f,o.offset,b)):this.activePlayers--}})}pause(){this.clips.forEach(e=>{if(e.player.state==="started"){const t=(F.now()-e.playStartTime)*e.player.playbackRate;e.pausedPosition=e.pausedPosition+t}e.player.stop()}),this.activePlayers=0}stop(e){const t=e??F.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}},na=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 F.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,F.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 F.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new ta(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??F.now(),a=t??0;this.playbackSessionId++;const s=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const l=o.startTime;if(a>=l){const i=a-l;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r,i,n)}else{const i=l-a;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r+i,0,n)}}),t!==void 0?F.getTransport().start(r,t):F.getTransport().start(r)}pause(){F.getTransport().pause(),this.tracks.forEach(e=>{e.pause()})}stop(){F.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 F.getTransport().seconds}seekTo(e){F.getTransport().seconds=e}dispose(){this.tracks.forEach(e=>{e.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return F.getContext()}get sampleRate(){return F.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},It=null;function ra(){return It||(It=new F.Context,F.setContext(It)),It}async function Ht(){const e=ra();e.state!=="running"&&await e.resume()}const aa=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ln(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ir(e){return"nodeType"in e}function rt(e){var t,n;return e?ln(e)?e:ir(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function oa(e){const{Document:t}=rt(e);return e instanceof t}function sa(e){return ln(e)?!1:e instanceof rt(e).HTMLElement}function ia(e){return e instanceof rt(e).SVGElement}function Tt(e){return e?ln(e)?e.document:ir(e)?oa(e)?e:sa(e)||ia(e)?e.ownerDocument:document:document:document}const Mt=aa?u.useLayoutEffect:u.useEffect;function la(e){const t=u.useRef(e);return Mt(()=>{t.current=e}),u.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 lr(e,t){t===void 0&&(t=[e]);const n=u.useRef(e);return Mt(()=>{n.current!==e&&(n.current=e)},t),n}function $t(e){const t=la(e),n=u.useRef(null),r=u.useCallback(a=>{a!==n.current&&t?.(a,n.current),n.current=a},[]);return[n,r]}let Gt={};function cr(e,t){return u.useMemo(()=>{const n=Gt[e]==null?0:Gt[e]+1;return Gt[e]=n,e+"-"+n},[e,t])}function ca(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((s,o)=>{const l=Object.entries(o);for(const[i,d]of l){const f=s[i];f!=null&&(s[i]=f+e*d)}return s},{...t})}}const ua=ca(-1);function da(e){return"clientX"in e&&"clientY"in e}function fa(e){if(!e)return!1;const{TouchEvent:t}=rt(e.target);return t&&e instanceof t}function An(e){if(fa(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 da(e)?{x:e.clientX,y:e.clientY}:null}const Qt=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[Qt.Translate.toString(e),Qt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}});var Sn;(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"})(Sn||(Sn={}));function kn(){}function Xt(e,t){return u.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function ha(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return u.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const en=Object.freeze({x:0,y:0});var et;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(et||(et={}));class Yt{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 ma(e){const{EventTarget:t}=rt(e);return e instanceof t?e:Tt(e)}function Lt(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 ze;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ze||(ze={}));function $n(e){e.preventDefault()}function pa(e){e.stopPropagation()}var Oe;(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"})(Oe||(Oe={}));Oe.Space,Oe.Enter,Oe.Esc,Oe.Space,Oe.Enter,Oe.Tab;function Rn(e){return!!(e&&"distance"in e)}function Dn(e){return!!(e&&"delay"in e)}class cn{constructor(t,n,r){var a;r===void 0&&(r=ma(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=Tt(o),this.documentListeners=new Yt(this.document),this.listeners=new Yt(r),this.windowListeners=new Yt(rt(o)),this.initialCoordinates=(a=An(s))!=null?a:en,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(ze.Resize,this.handleCancel),this.windowListeners.add(ze.DragStart,$n),this.windowListeners.add(ze.VisibilityChange,this.handleCancel),this.windowListeners.add(ze.ContextMenu,$n),this.documentListeners.add(ze.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Dn(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Rn(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(ze.Click,pa,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ze.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:a,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!a)return;const i=(n=An(t))!=null?n:en,d=ua(a,i);if(!r&&l){if(Rn(l)){if(l.tolerance!=null&&Lt(d,l.tolerance))return this.handleCancel();if(Lt(d,l.distance))return this.handleStart()}if(Dn(l)&&Lt(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}t.cancelable&&t.preventDefault(),o(i)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Oe.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ga={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ur extends cn{constructor(t){const{event:n}=t,r=Tt(n.target);super(t,ga,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 ba={move:{name:"mousemove"},end:{name:"mouseup"}};var tn;(function(e){e[e.RightClick=2]="RightClick"})(tn||(tn={}));class dr extends cn{constructor(t){super(t,ba,Tt(t.event.target))}}dr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===tn.RightClick?!1:(r?.({event:n}),!0)}}];const Kt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class fr extends cn{constructor(t){super(t,Kt)}static setup(){return window.addEventListener(Kt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Kt.move.name,t)};function t(){}}}fr.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 En;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(En||(En={}));var Tn;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Tn||(Tn={}));et.Backward+"",et.Forward+"",et.Backward+"",et.Forward+"";var nn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(nn||(nn={}));var rn;(function(e){e.Optimized="optimized"})(rn||(rn={}));function va(e,t){return u.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:s}=r;return n[a]=o=>{s(o,t)},n},{}),[e,t])}nn.WhileDragging,rn.Optimized;const Ca={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kn,draggableNodes:new Map,over:null,measureDroppableContainers:kn},xa=u.createContext(Ca),ya=u.createContext({...en,scaleX:1,scaleY:1});var Mn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Mn||(Mn={}));const wa=u.createContext(null),Bn="button",Ia="Draggable";function Ut(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=cr(Ia),{activators:o,activatorEvent:l,active:i,activeNodeRect:d,ariaDescribedById:f,draggableNodes:b,over:p}=u.useContext(xa),{role:h=Bn,roleDescription:x="draggable",tabIndex:I=0}=a??{},v=i?.id===t,m=u.useContext(v?ya:wa),[C,y]=$t(),[g,k]=$t(),A=va(o,t),E=lr(n);Mt(()=>(b.set(t,{id:t,key:s,node:C,activatorNode:g,data:E}),()=>{const B=b.get(t);B&&B.key===s&&b.delete(t)}),[b,t]);const _=u.useMemo(()=>({role:h,tabIndex:I,"aria-disabled":r,"aria-pressed":v&&h===Bn?!0:void 0,"aria-roledescription":x,"aria-describedby":f.draggable}),[r,h,I,v,x,f.draggable]);return{active:i,activatorEvent:l,activeNodeRect:d,attributes:_,isDragging:v,listeners:r?void 0:A,node:C,over:p,setNodeRef:y,setActivatorNodeRef:k,transform:m}}const Aa=new Map([["bold",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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"}))]]),Sa=new Map([["bold",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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=u.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),un=X.forwardRef((e,t)=>{const{alt:n,color:r,size:a,weight:s,mirrored:o,children:l,weights:i,...d}=e,{color:f="currentColor",size:b,weight:p="regular",mirrored:h=!1,...x}=X.useContext(ka);return X.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:a??b,height:a??b,fill:r??f,viewBox:"0 0 256 256",transform:o||h?"scale(-1, 1)":void 0,...x,...d},!!n&&X.createElement("title",null,n),l,i.get(s??p))});un.displayName="IconBase";const hr=X.forwardRef((e,t)=>X.createElement(un,{ref:t,...e,weights:Aa}));hr.displayName="SpeakerHighIcon";const mr=X.forwardRef((e,t)=>X.createElement(un,{ref:t,...e,weights:Sa}));mr.displayName="SpeakerLowIcon";$.span`
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`
15
20
  font-family: 'Courier New', Monaco, monospace;
16
21
  font-size: 1rem;
17
22
  font-weight: 600;
18
23
  color: ${e=>e.theme?.textColor||"#333"};
19
24
  user-select: none;
20
- `;var dn=$.button`
25
+ `;var wn=k.button`
21
26
  display: inline-flex;
22
27
  align-items: center;
23
28
  justify-content: center;
@@ -46,37 +51,37 @@ React keys must be passed directly to JSX without using spread:
46
51
  opacity: 0.6;
47
52
  cursor: not-allowed;
48
53
  }
49
- `;$(dn)`
54
+ `;k(wn)`
50
55
  padding: 0.25rem 0.5rem;
51
56
  font-size: ${e=>e.theme.fontSizeSmall};
52
- `;$(dn)`
57
+ `;k(wn)`
53
58
  padding: 0.5rem;
54
59
  min-width: 2.25rem;
55
60
  min-height: 2.25rem;
56
- `;$(dn)`
61
+ `;k(wn)`
57
62
  padding: 0.25rem;
58
63
  min-width: 1.75rem;
59
64
  min-height: 1.75rem;
60
65
  font-size: ${e=>e.theme.fontSizeSmall};
61
- `;var Bt=$.div`
66
+ `;var jt=k.div`
62
67
  display: inline-flex;
63
68
  align-items: center;
64
69
  gap: 0.5rem;
65
- `,_t=$.input`
70
+ `,zt=k.input`
66
71
  cursor: pointer;
67
72
  accent-color: ${e=>e.theme.inputFocusBorder};
68
73
 
69
74
  &:disabled {
70
75
  cursor: not-allowed;
71
76
  }
72
- `,Wt=$.label`
77
+ `,Ot=k.label`
73
78
  margin: 0;
74
79
  cursor: pointer;
75
80
  user-select: none;
76
81
  font-family: ${e=>e.theme.fontFamily};
77
82
  font-size: ${e=>e.theme.fontSize};
78
83
  color: ${e=>e.theme.textColor};
79
- `,We=$.button`
84
+ `,Oe=k.button`
80
85
  padding: 0.5rem 1rem;
81
86
  background: ${e=>e.theme.buttonBackground||"#007bff"};
82
87
  color: ${e=>e.theme.buttonText||"white"};
@@ -102,7 +107,7 @@ React keys must be passed directly to JSX without using spread:
102
107
  cursor: not-allowed;
103
108
  opacity: 0.6;
104
109
  }
105
- `,pr=$.input`
110
+ `,_r=k.input`
106
111
  padding: 0.5rem 0.75rem;
107
112
  font-family: ${e=>e.theme.fontFamily};
108
113
  font-size: ${e=>e.theme.fontSize};
@@ -126,17 +131,17 @@ React keys must be passed directly to JSX without using spread:
126
131
  opacity: 0.6;
127
132
  cursor: not-allowed;
128
133
  }
129
- `;$(pr)`
134
+ `;k(_r)`
130
135
  padding: 0.25rem 0.5rem;
131
136
  font-size: ${e=>e.theme.fontSizeSmall};
132
- `;var gr=$.label`
137
+ `;var Mr=k.label`
133
138
  font-family: ${e=>e.theme.fontFamily};
134
139
  font-size: ${e=>e.theme.fontSizeSmall};
135
140
  font-weight: 500;
136
141
  color: ${e=>e.theme.textColorMuted};
137
142
  margin-bottom: 0.25rem;
138
143
  display: block;
139
- `;$.label`
144
+ `;k.label`
140
145
  font-family: ${e=>e.theme.fontFamily};
141
146
  font-size: ${e=>e.theme.fontSize};
142
147
  color: ${e=>e.theme.textColor};
@@ -144,7 +149,7 @@ React keys must be passed directly to JSX without using spread:
144
149
  align-items: center;
145
150
  gap: 0.5rem;
146
151
  cursor: pointer;
147
- `;var $a=$.span`
152
+ `;var ja=k.span`
148
153
  position: absolute;
149
154
  width: 1px;
150
155
  height: 1px;
@@ -154,7 +159,7 @@ React keys must be passed directly to JSX without using spread:
154
159
  clip: rect(0, 0, 0, 0);
155
160
  white-space: nowrap;
156
161
  border: 0;
157
- `,fn=$.select`
162
+ `,yn=k.select`
158
163
  padding: 0.5rem 2rem 0.5rem 0.75rem;
159
164
  font-family: ${e=>e.theme.fontFamily};
160
165
  font-size: ${e=>e.theme.fontSize};
@@ -185,10 +190,10 @@ React keys must be passed directly to JSX without using spread:
185
190
  color: ${e=>e.theme.inputText};
186
191
  background-color: ${e=>e.theme.inputBackground};
187
192
  }
188
- `;$(fn)`
193
+ `;k(yn)`
189
194
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
190
195
  font-size: ${e=>e.theme.fontSizeSmall};
191
- `;var br=$.input.attrs({type:"range"})`
196
+ `;var Br=k.input.attrs({type:"range"})`
192
197
  -webkit-appearance: none;
193
198
  appearance: none;
194
199
  width: 100%;
@@ -264,7 +269,7 @@ React keys must be passed directly to JSX without using spread:
264
269
  &:disabled::-moz-range-thumb {
265
270
  cursor: not-allowed;
266
271
  }
267
- `,Ra=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return w.jsxs(Bt,{className:r,children:[w.jsx(_t,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:a,disabled:n}),w.jsx(Wt,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function vr(e){return typeof e=="object"&&e!==null&&"type"in e}function Rt(e){if(!vr(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 Da={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)",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"},Ea=1e3;function Ta(e,t,n,r){if(!vr(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 Ma=$.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
272
+ `,za=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return E.jsxs(jt,{className:r,children:[E.jsx(zt,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:a,disabled:n}),E.jsx(Ot,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Wr(e){return typeof e=="object"&&e!==null&&"type"in e}function Ft(e){if(!Wr(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 Oa={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)",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"},Na=1e3;function Ha(e,t,n,r){if(!Wr(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 Ga=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
268
273
  float: left;
269
274
  position: relative;
270
275
  /* Promote to own compositing layer for smoother scrolling */
@@ -272,15 +277,15 @@ React keys must be passed directly to JSX without using spread:
272
277
  /* Disable image rendering interpolation */
273
278
  image-rendering: pixelated;
274
279
  image-rendering: crisp-edges;
275
- `,Ba=$.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
280
+ `,Xa=k.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
276
281
  position: absolute;
277
282
  background: ${e=>e.$waveFillColor};
278
283
  /* Force GPU compositing layer to reduce scroll flickering */
279
284
  transform: translateZ(0);
280
285
  backface-visibility: hidden;
281
- `,_a=e=>{const{data:t,bits:n,length:r,index:a,className:s,devicePixelRatio:o=1,waveHeight:l=80,waveOutlineColor:i="#E0EFF1",waveFillColor:d="grey",barWidth:f=1,barGap:b=0,transparentBackground:p=!1,drawMode:h="inverted"}=e,x=u.useRef([]),I=u.useCallback(k=>{if(k!==null){const A=parseInt(k.dataset.index,10);x.current[A]=k}},[]);u.useLayoutEffect(()=>{const k=x.current,A=f+b;let E=0;for(let _=0;_<k.length;_++){const B=k[_],M=B.getContext("2d"),D=Math.floor(l/2),Z=2**(n-1);if(M){M.resetTransform(),M.clearRect(0,0,B.width,B.height),M.imageSmoothingEnabled=!1,M.scale(o,o);const W=B.width/o;let O;h==="normal"?O=d:O=i,M.fillStyle=Ta(M,O,W,l);const N=E,G=E+W,K=Math.floor((N-f+A)/A)*A;for(let Q=Math.max(0,K);Q<G;Q+=A){const H=Q-N;if(H+f<=0)continue;const ee=Q;if(ee*2+1<t.length){const ie=t[ee*2]/Z,ce=t[ee*2+1]/Z,q=Math.abs(ie*D),re=Math.abs(ce*D);h==="normal"?M.fillRect(H,D-re,f,re+q):(M.fillRect(H,0,f,D-re),M.fillRect(H,D+q,f,D-q))}}}E+=B.width/o}},[t,n,l,i,d,o,r,f,b,h]);let v=r,m=0;const C=[];for(;v>0;){const k=Math.min(v,Ea),A=w.jsx(Ma,{$cssWidth:k,width:k*o,height:l*o,$waveHeight:l,"data-index":m,ref:I},`${r}-${m}`);C.push(A),v-=k,m+=1}const g=p?"transparent":Rt(d);return w.jsx(Ba,{$index:a,$cssWidth:r,className:s,$waveHeight:l,$waveFillColor:g,children:C})},Cr=22,xr=$.div`
286
+ `,Ya=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:b=0,transparentBackground:p=!1,drawMode:f="inverted"}=e,x=c.useRef([]),y=c.useCallback(A=>{if(A!==null){const I=parseInt(A.dataset.index,10);x.current[I]=A}},[]);c.useLayoutEffect(()=>{const A=x.current,I=d+b;let D=0;for(let F=0;F<A.length;F++){const _=A[F],M=_.getContext("2d"),$=Math.floor(i/2),j=2**(n-1);if(M){M.resetTransform(),M.clearRect(0,0,_.width,_.height),M.imageSmoothingEnabled=!1,M.scale(o,o);const Z=_.width/o;let X;f==="normal"?X=u:X=l,M.fillStyle=Ha(M,X,Z,i);const Y=D,K=D+Z,te=Math.floor((Y-d+I)/I)*I;for(let re=Math.max(0,te);re<K;re+=I){const L=re-Y;if(L+d<=0)continue;const oe=re;if(oe*2+1<t.length){const S=t[oe*2]/j,z=t[oe*2+1]/j,G=Math.abs(S*$),Q=Math.abs(z*$);f==="normal"?M.fillRect(L,$-Q,d,Q+G):(M.fillRect(L,0,d,$-Q),M.fillRect(L,$+G,d,$-G))}}}D+=_.width/o}},[t,n,i,l,u,o,r,d,b,f]);let v=r,m=0;const C=[];for(;v>0;){const A=Math.min(v,Na),I=E.jsx(Ga,{$cssWidth:A,width:A*o,height:i*o,$waveHeight:i,"data-index":m,ref:y},`${r}-${m}`);C.push(I),v-=A,m+=1}const g=p?"transparent":Ft(u);return E.jsx(Xa,{$index:a,$cssWidth:r,className:s,$waveHeight:i,$waveFillColor:g,children:C})},Fr=22,Pr=k.div`
282
287
  position: relative;
283
- height: ${Cr}px;
288
+ height: ${Fr}px;
284
289
  background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
285
290
  border-bottom: 1px solid ${e=>e.theme.clipHeaderBorderColor};
286
291
  display: flex;
@@ -302,7 +307,7 @@ React keys must be passed directly to JSX without using spread:
302
307
  cursor: grabbing;
303
308
  }
304
309
  `}
305
- `,yr=$.span`
310
+ `,Zr=k.span`
306
311
  font-size: 11px;
307
312
  font-weight: 600;
308
313
  font-family: ${e=>e.theme.clipHeaderFontFamily};
@@ -310,12 +315,12 @@ React keys must be passed directly to JSX without using spread:
310
315
  white-space: nowrap;
311
316
  overflow: hidden;
312
317
  text-overflow: ellipsis;
313
- `,Wa=({trackName:e,isSelected:t=!1})=>w.jsx(xr,{$isDragging:!1,$interactive:!1,$isSelected:t,children:w.jsx(yr,{children:e})}),Fa=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:a=!1,disableDrag:s=!1,dragHandleProps:o})=>{if(s||!o)return w.jsx(Wa,{trackName:r,isSelected:a});const{attributes:l,listeners:i,setActivatorNodeRef:d}=o;return w.jsx(xr,{ref:d,"data-clip-id":e,$interactive:!0,$isSelected:a,...i,...l,children:w.jsx(yr,{children:r})})},Za=8,Pa=24,Va=$.div`
318
+ `,La=({trackName:e,isSelected:t=!1})=>E.jsx(Pr,{$isDragging:!1,$interactive:!1,$isSelected:t,children:E.jsx(Zr,{children:e})}),Ka=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:a=!1,disableDrag:s=!1,dragHandleProps:o})=>{if(s||!o)return E.jsx(La,{trackName:r,isSelected:a});const{attributes:i,listeners:l,setActivatorNodeRef:u}=o;return E.jsx(Pr,{ref:u,"data-clip-id":e,$interactive:!0,$isSelected:a,...l,...i,children:E.jsx(Zr,{children:r})})},Ua=8,Ja=24,qa=k.div`
314
319
  position: absolute;
315
320
  ${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
316
321
  top: 0;
317
322
  bottom: 0;
318
- width: ${e=>e.$touchOptimized?Pa:Za}px;
323
+ width: ${e=>e.$touchOptimized?Ja:Ua}px;
319
324
  cursor: col-resize;
320
325
  user-select: none;
321
326
  z-index: 105; /* Above waveform, below header */
@@ -338,19 +343,19 @@ React keys must be passed directly to JSX without using spread:
338
343
  background: rgba(255, 255, 255, 0.4);
339
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);"}
340
345
  }
341
- `,_n=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:a,touchOptimized:s=!1})=>{const[o,l]=u.useState(!1);if(!a)return null;const{attributes:i,listeners:d,setActivatorNodeRef:f,isDragging:b}=a;return w.jsx(Va,{ref:f,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:b,$isHovered:o,$touchOptimized:s,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),...d,...i})},ja=$.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
346
+ `,Yn=({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:b}=a;return E.jsx(qa,{ref:d,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:b,$isHovered:o,$touchOptimized:s,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),...u,...l})},Qa=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
342
347
  position: absolute;
343
348
  top: 0;
344
349
  bottom: 0;
345
350
  pointer-events: none;
346
351
  z-index: 50;
347
- `,za=$.svg`
352
+ `,eo=k.svg`
348
353
  width: 100%;
349
354
  height: 100%;
350
355
  display: block;
351
356
  /* Flip horizontally for fadeOut - makes it mirror of fadeIn */
352
357
  transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
353
- `;function Oa(e,t,n="logarithmic"){const r=[],a=Math.max(20,Math.min(e,100));for(let s=0;s<=a;s++){const o=s/a*e,l=s/a;let i;switch(n){case"linear":i=l;break;case"exponential":i=l*l;break;case"sCurve":i=(1-Math.cos(l*Math.PI))/2;break;case"logarithmic":default:i=Math.log10(1+l*9)/Math.log10(10);break}const d=(1-i)*t;r.push(`${o},${d}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var Wn=({left:e,width:t,type:n,curveType:r="logarithmic",color:a})=>{const s=$.useTheme();if(t<1)return null;const o=a||s?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return w.jsx(ja,{$left:e,$width:t,$type:n,children:w.jsx(za,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:w.jsx("path",{d:Oa(t,100,r),fill:o})})})},Na=$.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
358
+ `;function to(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 Ln=({left:e,width:t,type:n,curveType:r="logarithmic",color:a})=>{const s=k.useTheme();if(t<1)return null;const o=a||s?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return E.jsx(Qa,{$left:e,$width:t,$type:n,children:E.jsx(eo,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:E.jsx("path",{d:to(t,100,r),fill:o})})})},no=k.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
354
359
  position: ${e=>e.$isOverlay?"relative":"absolute"};
355
360
  top: 0;
356
361
  height: ${e=>e.$isOverlay?"auto":"100%"};
@@ -364,20 +369,20 @@ React keys must be passed directly to JSX without using spread:
364
369
  &:hover {
365
370
  background: rgba(255, 255, 255, 0.08);
366
371
  }
367
- `,Ha=$.div`
372
+ `,ro=k.div`
368
373
  flex: 1;
369
374
  position: relative;
370
375
  overflow: ${e=>e.$isOverlay?"visible":"hidden"};
371
- `,Fn=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:a,trackName:s,startSample:o,durationSamples:l,samplesPerPixel:i,showHeader:d=!1,disableHeaderDrag:f=!1,isOverlay:b=!1,isSelected:p=!1,onMouseDown:h,trackId:x,fadeIn:I,fadeOut:v,sampleRate:m=44100,showFades:C=!1,touchOptimized:y=!1})=>{const g=Math.floor(o/i),A=Math.floor((o+l)/i)-g,E=d&&!f&&!b,_=`clip-${r}-${a}`,{attributes:B,listeners:M,setNodeRef:D,setActivatorNodeRef:Z,transform:W,isDragging:O}=Ut({id:_,data:{clipId:n,trackIndex:r,clipIndex:a},disabled:!E}),N=`clip-boundary-left-${r}-${a}`,{attributes:G,listeners:K,setActivatorNodeRef:Q,isDragging:H}=Ut({id:N,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"left"},disabled:!E}),ee=`clip-boundary-right-${r}-${a}`,{attributes:ie,listeners:ce,setActivatorNodeRef:q,isDragging:re}=Ut({id:ee,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"right"},disabled:!E}),te=W?{transform:Qt.Translate.toString(W),zIndex:O?100:void 0}:void 0;return w.jsxs(Na,{ref:D,style:te,className:t,$left:g,$width:A,$isOverlay:b,"data-clip-container":"true","data-track-id":x,onMouseDown:h,children:[d&&w.jsx(Fa,{clipId:n,trackIndex:r,clipIndex:a,trackName:s,isSelected:p,disableDrag:f,dragHandleProps:E?{attributes:B,listeners:M,setActivatorNodeRef:Z}:void 0}),w.jsxs(Ha,{$isOverlay:b,children:[e,C&&I&&I.duration>0&&w.jsx(Wn,{left:0,width:Math.floor(I.duration*m/i),type:"fadeIn",curveType:I.type}),C&&v&&v.duration>0&&w.jsx(Wn,{left:A-Math.floor(v.duration*m/i),width:Math.floor(v.duration*m/i),type:"fadeOut",curveType:v.type})]}),d&&!f&&!b&&w.jsxs(w.Fragment,{children:[w.jsx(_n,{clipId:n,trackIndex:r,clipIndex:a,edge:"left",touchOptimized:y,dragHandleProps:{attributes:G,listeners:K,setActivatorNodeRef:Q,isDragging:H}}),w.jsx(_n,{clipId:n,trackIndex:r,clipIndex:a,edge:"right",touchOptimized:y,dragHandleProps:{attributes:ie,listeners:ce,setActivatorNodeRef:q,isDragging:re}})]})]})},Ga=$.div`
376
+ `,Kn=({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:b=!1,isSelected:p=!1,onMouseDown:f,trackId:x,fadeIn:y,fadeOut:v,sampleRate:m=44100,showFades:C=!1,touchOptimized:w=!1})=>{const g=Math.floor(o/l),I=Math.floor((o+i)/l)-g,D=u&&!d&&!b,F=`clip-${r}-${a}`,{attributes:_,listeners:M,setNodeRef:$,setActivatorNodeRef:j,transform:Z,isDragging:X}=nn({id:F,data:{clipId:n,trackIndex:r,clipIndex:a},disabled:!D}),Y=`clip-boundary-left-${r}-${a}`,{attributes:K,listeners:te,setActivatorNodeRef:re,isDragging:L}=nn({id:Y,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"left"},disabled:!D}),oe=`clip-boundary-right-${r}-${a}`,{attributes:S,listeners:z,setActivatorNodeRef:G,isDragging:Q}=nn({id:oe,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"right"},disabled:!D}),se=Z?{transform:un.Translate.toString(Z),zIndex:X?100:void 0}:void 0;return E.jsxs(no,{ref:$,style:se,className:t,$left:g,$width:I,$isOverlay:b,"data-clip-container":"true","data-track-id":x,onMouseDown:f,children:[u&&E.jsx(Ka,{clipId:n,trackIndex:r,clipIndex:a,trackName:s,isSelected:p,disableDrag:d,dragHandleProps:D?{attributes:_,listeners:M,setActivatorNodeRef:j}:void 0}),E.jsxs(ro,{$isOverlay:b,children:[e,C&&y&&y.duration>0&&E.jsx(Ln,{left:0,width:Math.floor(y.duration*m/l),type:"fadeIn",curveType:y.type}),C&&v&&v.duration>0&&E.jsx(Ln,{left:I-Math.floor(v.duration*m/l),width:Math.floor(v.duration*m/l),type:"fadeOut",curveType:v.type})]}),u&&!d&&!b&&E.jsxs(E.Fragment,{children:[E.jsx(Yn,{clipId:n,trackIndex:r,clipIndex:a,edge:"left",touchOptimized:w,dragHandleProps:{attributes:K,listeners:te,setActivatorNodeRef:re,isDragging:L}}),E.jsx(Yn,{clipId:n,trackIndex:r,clipIndex:a,edge:"right",touchOptimized:w,dragHandleProps:{attributes:S,listeners:z,setActivatorNodeRef:G,isDragging:Q}})]})]})},ao=k.div`
372
377
  display: inline-flex;
373
378
  align-items: center;
374
379
  gap: 0.5rem;
375
- `,Xa=$(gr)`
380
+ `,oo=k(Mr)`
376
381
  margin: 0;
377
382
  white-space: nowrap;
378
- `,Ya=$(br)`
383
+ `,so=k(Br)`
379
384
  width: 120px;
380
- `,La=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(parseFloat(s.target.value)/100)};return w.jsxs(Ga,{className:r,children:[w.jsx(Xa,{htmlFor:"master-gain",children:"Master Volume"}),w.jsx(Ya,{min:"0",max:"100",value:e*100,onChange:a,disabled:n,id:"master-gain"})]})};$.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
385
+ `,io=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(parseFloat(s.target.value)/100)};return E.jsxs(ao,{className:r,children:[E.jsx(oo,{htmlFor:"master-gain",children:"Master Volume"}),E.jsx(so,{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)`}}))`
381
386
  position: absolute;
382
387
  top: 0;
383
388
  left: 0;
@@ -387,7 +392,7 @@ React keys must be passed directly to JSX without using spread:
387
392
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
388
393
  pointer-events: none;
389
394
  will-change: transform;
390
- `;$.div`
395
+ `;k.div`
391
396
  position: absolute;
392
397
  top: 0;
393
398
  left: 0;
@@ -395,7 +400,7 @@ React keys must be passed directly to JSX without using spread:
395
400
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
396
401
  pointer-events: none;
397
402
  will-change: transform;
398
- `;$.div`
403
+ `;k.div`
399
404
  position: absolute;
400
405
  top: -10px;
401
406
  left: -6px;
@@ -404,29 +409,29 @@ React keys must be passed directly to JSX without using spread:
404
409
  border-left: 7px solid transparent;
405
410
  border-right: 7px solid transparent;
406
411
  border-top: 10px solid ${e=>e.$color};
407
- `;$.div`
412
+ `;k.div`
408
413
  position: absolute;
409
414
  top: 0;
410
415
  left: 0;
411
416
  width: 2px;
412
417
  height: 100%;
413
418
  background: ${e=>e.$color};
414
- `;var Ka=$.div`
419
+ `;var lo=k.div`
415
420
  overflow-y: hidden;
416
421
  overflow-x: auto;
417
422
  position: relative;
418
- `,Ua=$.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
423
+ `,co=k.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
419
424
  position: relative;
420
425
  background: ${e=>e.$backgroundColor||"transparent"};
421
- `,Ja=$.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
426
+ `,uo=k.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
422
427
  background: ${e=>e.$backgroundColor||"white"};
423
428
  width: 100%;
424
429
  overflow: visible;
425
- `,qa=$.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
430
+ `,fo=k.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
426
431
  position: relative;
427
432
  background: ${e=>e.$backgroundColor||"transparent"};
428
433
  width: 100%;
429
- `,Qa=$.div`
434
+ `,ho=k.div`
430
435
  position: absolute;
431
436
  top: 0;
432
437
  left: 0;
@@ -434,7 +439,7 @@ React keys must be passed directly to JSX without using spread:
434
439
  bottom: 0;
435
440
  cursor: crosshair;
436
441
  z-index: 1; /* Low z-index - clip headers and boundaries have higher z-index */
437
- `,wr=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:a,tracksWidth:s,scrollContainerWidth:o,controlsWidth:l,onTracksClick:i,onTracksMouseDown:d,onTracksMouseMove:f,onTracksMouseUp:b,scrollContainerRef:p})=>w.jsx(Ka,{"data-scroll-container":"true",ref:p,children:w.jsxs(Ua,{$backgroundColor:t,$width:o,children:[r&&w.jsx(Ja,{$width:a,$backgroundColor:n,children:r}),w.jsxs(qa,{$width:s,$backgroundColor:t,children:[e,(i||d)&&w.jsx(Qa,{$controlsWidth:l,onClick:i,onMouseDown:d,onMouseMove:f,onMouseUp:b})]})]})});$.withTheme(wr);var eo=$.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
442
+ `,Vr=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:a,tracksWidth:s,scrollContainerWidth:o,controlsWidth:i,onTracksClick:l,onTracksMouseDown:u,onTracksMouseMove:d,onTracksMouseUp:b,scrollContainerRef:p})=>E.jsx(lo,{"data-scroll-container":"true",ref:p,children:E.jsxs(co,{$backgroundColor:t,$width:o,children:[r&&E.jsx(uo,{$width:a,$backgroundColor:n,children:r}),E.jsxs(fo,{$width:s,$backgroundColor:t,children:[e,(l||u)&&E.jsx(ho,{$controlsWidth:i,onClick:l,onMouseDown:u,onMouseMove:d,onMouseUp:b})]})]})});k.withTheme(Vr);var mo=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
438
443
  position: absolute;
439
444
  top: 0;
440
445
  background: ${e=>e.$color};
@@ -442,34 +447,34 @@ React keys must be passed directly to JSX without using spread:
442
447
  z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
443
448
  pointer-events: none;
444
449
  opacity: 0.3;
445
- `,to=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:w.jsx(eo,{$left:e,$width:r,$color:n,"data-selection":!0})};function ft(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 nt(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return ft(e,0);case"hh:mm:ss.u":return ft(e,1);case"hh:mm:ss.uu":return ft(e,2);case"hh:mm:ss.uuu":return ft(e,3);default:return ft(e,3)}}function Ir(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 Zn=({id:e,label:t,value:n,format:r,className:a,onChange:s,readOnly:o=!1})=>{const[l,i]=u.useState("");u.useEffect(()=>{const p=nt(n,r);i(p)},[n,r,e]);const d=p=>{const h=p.target.value;i(h)},f=()=>{if(s){const p=Ir(l,r);s(p)}i(nt(n,r))},b=p=>{p.key==="Enter"&&p.currentTarget.blur()};return w.jsxs(w.Fragment,{children:[w.jsx($a,{as:"label",htmlFor:e,children:t}),w.jsx(pr,{type:"text",className:a,id:e,value:l,onChange:d,onBlur:f,onKeyDown:b,readOnly:o})]})},no=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[a,s]=u.useState("hh:mm:ss.uuu");u.useEffect(()=>{const i=document.querySelector(".time-format"),d=()=>{i&&s(i.value)};return i&&(s(i.value),i.addEventListener("change",d)),()=>{i?.removeEventListener("change",d)}},[]);const o=i=>{n&&n(i,t)},l=i=>{n&&n(e,i)};return w.jsxs(w.Fragment,{children:[w.jsx(Zn,{id:"audio_start",label:"Start of audio selection",value:e,format:a,className:"audio-start form-control mr-sm-2",onChange:o}),w.jsx(Zn,{id:"audio_end",label:"End of audio selection",value:t,format:a,className:"audio-end form-control mr-sm-2",onChange:l})]})};function kt(){return window.devicePixelRatio}var Ar=u.createContext(kt()),ro=({children:e})=>{const[t,n]=u.useState(kt());return matchMedia(`(resolution: ${kt()}dppx)`).addEventListener("change",()=>{n(kt())},{once:!0}),w.jsx(Ar.Provider,{value:Math.ceil(t),children:e})},Sr=()=>u.useContext(Ar),hn=u.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}),Ft=()=>u.useContext(hn),mn=()=>u.useContext($.ThemeContext),kr=u.createContext(w.jsx(u.Fragment,{})),ao=()=>u.useContext(kr),oo=0,so=!1,io=0,lo=0,co={progress:oo,isPlaying:so,selectionStart:io,selectionEnd:lo};u.createContext(co);u.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var uo=({isSelected:e,transparentBackground:t,...n})=>{const r=mn(),{waveHeight:a,barWidth:s,barGap:o}=Ft(),l=Sr(),i=e&&r?r.selectedWaveOutlineColor:r?.waveOutlineColor,d=e&&r?r.selectedWaveFillColor:r?.waveFillColor,f=r?.waveformDrawMode||"inverted";return w.jsx(_a,{...n,...r,waveOutlineColor:i,waveFillColor:d,waveHeight:a,devicePixelRatio:l,barWidth:s,barGap:o,transparentBackground:t,drawMode:f})};function fo(e,t,n){return Math.ceil(e*n/t)}function ho(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var mo=$.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,marginLeft:`${e.$controlWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
450
+ `,po=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:E.jsx(mo,{$left:e,$width:r,$color:n,"data-selection":!0})};function bt(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 lt(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return bt(e,0);case"hh:mm:ss.u":return bt(e,1);case"hh:mm:ss.uu":return bt(e,2);case"hh:mm:ss.uuu":return bt(e,3);default:return bt(e,3)}}function jr(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 Un=({id:e,label:t,value:n,format:r,className:a,onChange:s,readOnly:o=!1})=>{const[i,l]=c.useState("");c.useEffect(()=>{const p=lt(n,r);l(p)},[n,r,e]);const u=p=>{const f=p.target.value;l(f)},d=()=>{if(s){const p=jr(i,r);s(p)}l(lt(n,r))},b=p=>{p.key==="Enter"&&p.currentTarget.blur()};return E.jsxs(E.Fragment,{children:[E.jsx(ja,{as:"label",htmlFor:e,children:t}),E.jsx(_r,{type:"text",className:a,id:e,value:i,onChange:u,onBlur:d,onKeyDown:b,readOnly:o})]})},go=({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 E.jsxs(E.Fragment,{children:[E.jsx(Un,{id:"audio_start",label:"Start of audio selection",value:e,format:a,className:"audio-start form-control mr-sm-2",onChange:o}),E.jsx(Un,{id:"audio_end",label:"End of audio selection",value:t,format:a,className:"audio-end form-control mr-sm-2",onChange:i})]})};function Bt(){return window.devicePixelRatio}var zr=c.createContext(Bt()),bo=({children:e})=>{const[t,n]=c.useState(Bt());return matchMedia(`(resolution: ${Bt()}dppx)`).addEventListener("change",()=>{n(Bt())},{once:!0}),E.jsx(zr.Provider,{value:Math.ceil(t),children:e})},Or=()=>c.useContext(zr),In=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}),Nt=()=>c.useContext(In),An=()=>c.useContext(k.ThemeContext),Nr=c.createContext(E.jsx(c.Fragment,{})),vo=()=>c.useContext(Nr),Co=0,xo=!1,wo=0,yo=0,Io={progress:Co,isPlaying:xo,selectionStart:wo,selectionEnd:yo};c.createContext(Io);c.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var Ao=({isSelected:e,transparentBackground:t,...n})=>{const r=An(),{waveHeight:a,barWidth:s,barGap:o}=Nt(),i=Or(),l=e&&r?r.selectedWaveOutlineColor:r?.waveOutlineColor,u=e&&r?r.selectedWaveFillColor:r?.waveFillColor,d=r?.waveformDrawMode||"inverted";return E.jsx(Ya,{...n,...r,waveOutlineColor:l,waveFillColor:u,waveHeight:a,devicePixelRatio:i,barWidth:s,barGap:o,transparentBackground:t,drawMode:d})};function So(e,t,n){return Math.ceil(e*n/t)}function ko(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var Ro=k.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,marginLeft:`${e.$controlWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
446
451
  position: relative;
447
452
  overflow: visible; /* Allow time labels to render above the container */
448
453
  border-bottom: 1px solid ${e=>e.theme.timeColor};
449
454
  box-sizing: border-box;
450
- `,po=$.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
455
+ `,$o=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
451
456
  position: absolute;
452
457
  left: 0;
453
458
  right: 0;
454
459
  bottom: 0;
455
- `,go=$.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
460
+ `,Eo=k.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
456
461
  position: absolute;
457
462
  font-size: 0.75rem; /* Smaller font to prevent overflow */
458
463
  white-space: nowrap; /* Prevent text wrapping */
459
464
  color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
460
- `,bo=e=>{const{theme:{timeColor:t},duration:n,marker:r,bigStep:a,secondStep:s,renderTimestamp:o}=e,l=new Map,i=[],d=u.useRef(null),{sampleRate:f,samplesPerPixel:b,timeScaleHeight:p,controls:{show:h,width:x}}=u.useContext(hn),I=Sr();u.useEffect(()=>{if(d.current!==null){const y=d.current,g=y.getContext("2d");if(g){g.resetTransform(),g.clearRect(0,0,y.width,y.height),g.imageSmoothingEnabled=!1,g.fillStyle=t,g.scale(I,I);for(const[k,A]of l.entries()){const E=p-A;g.fillRect(k,E,1,A)}}}},[n,I,t,p,a,s,r,l]);const v=fo(n/1e3,b,f),m=f/b;let C=0;for(let y=0;y<v;y+=m*s/1e3){const g=Math.floor(y);if(C%r===0){const k=C,A=ho(k),E=o?w.jsx(u.Fragment,{children:o(k,g)},`timestamp-${C}`):w.jsx(go,{$left:g,children:A},A);i.push(E),l.set(g,p)}else C%a===0?l.set(g,Math.floor(p/2)):C%s===0&&l.set(g,Math.floor(p/5));C+=s}return w.jsxs(mo,{$cssWidth:v,$controlWidth:h?x:0,$timeScaleHeight:p,children:[i,w.jsx(po,{$cssWidth:v,$timeScaleHeight:p,width:v*I,height:p*I,ref:d})]})},vo=$.withTheme(bo),Co=$.div`
465
+ `,To=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:b,timeScaleHeight:p,controls:{show:f,width:x}}=c.useContext(In),y=Or();c.useEffect(()=>{if(u.current!==null){const w=u.current,g=w.getContext("2d");if(g){g.resetTransform(),g.clearRect(0,0,w.width,w.height),g.imageSmoothingEnabled=!1,g.fillStyle=t,g.scale(y,y);for(const[A,I]of i.entries()){const D=p-I;g.fillRect(A,D,1,I)}}}},[n,y,t,p,a,s,r,i]);const v=So(n/1e3,b,d),m=d/b;let C=0;for(let w=0;w<v;w+=m*s/1e3){const g=Math.floor(w);if(C%r===0){const A=C,I=ko(A),D=o?E.jsx(c.Fragment,{children:o(A,g)},`timestamp-${C}`):E.jsx(Eo,{$left:g,children:I},I);l.push(D),i.set(g,p)}else C%a===0?i.set(g,Math.floor(p/2)):C%s===0&&i.set(g,Math.floor(p/5));C+=s}return E.jsxs(Ro,{$cssWidth:v,$controlWidth:f?x:0,$timeScaleHeight:p,children:[l,E.jsx($o,{$cssWidth:v,$timeScaleHeight:p,width:v*y,height:p*y,ref:u})]})},Do=k.withTheme(To),_o=k.div`
461
466
  display: inline-flex;
462
467
  align-items: center;
463
468
  gap: 0.5rem;
464
- `,xo=[{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 w.jsx(Co,{className:r,children:w.jsx(fn,{className:"time-format",value:e,onChange:a,disabled:n,"aria-label":"Time format selection",children:xo.map(s=>w.jsx("option",{value:s.value,children:s.label},s.value))})})},wo=$.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?Cr:0)}px`}}))`
469
+ `,Mo=[{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"}],Bo=({value:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.value)};return E.jsx(_o,{className:r,children:E.jsx(yn,{className:"time-format",value:e,onChange:a,disabled:n,"aria-label":"Time format selection",children:Mo.map(s=>E.jsx("option",{value:s.value,children:s.label},s.value))})})},Wo=k.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?Fr:0)}px`}}))`
465
470
  position: relative;
466
471
  display: flex;
467
472
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
468
- `,Io=$.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
473
+ `,Fo=k.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
469
474
  position: relative;
470
475
  background: ${e=>e.$backgroundColor||"transparent"};
471
476
  flex: 1;
472
- `,Ao=$.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
477
+ `,Po=k.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
473
478
  position: sticky;
474
479
  z-index: 101; /* Above waveform content, below Docusaurus navbar (z-index: 200) */
475
480
  left: 0;
@@ -483,7 +488,7 @@ React keys must be passed directly to JSX without using spread:
483
488
  ${e=>e.$isSelected&&`
484
489
  background: ${e.theme.selectedTrackControlsBackground};
485
490
  `}
486
- `,So=({numChannels:e,children:t,className:n,backgroundColor:r,offset:a=0,width:s,hasClipHeaders:o=!1,onClick:l,trackId:i,isSelected:d=!1})=>{const{waveHeight:f,controls:{show:b,width:p}}=Ft(),h=ao();return w.jsxs(wo,{$numChannels:e,className:n,$waveHeight:f,$controlWidth:b?p:0,$width:s,$hasClipHeaders:o,$isSelected:d,children:[w.jsx(Ao,{$controlWidth:b?p:0,$isSelected:d,children:h}),w.jsx(Io,{$controlWidth:b?p:0,$backgroundColor:r,$offset:a,onClick:l,"data-track-id":i,children:t})]})},Pn=$.button.attrs({type:"button"})`
491
+ `,Zo=({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:b,width:p}}=Nt(),f=vo();return E.jsxs(Wo,{$numChannels:e,className:n,$waveHeight:d,$controlWidth:b?p:0,$width:s,$hasClipHeaders:o,$isSelected:u,children:[E.jsx(Po,{$controlWidth:b?p:0,$isSelected:u,children:f}),E.jsx(Fo,{$controlWidth:b?p:0,$backgroundColor:r,$offset:a,onClick:i,"data-track-id":l,children:t})]})},Jn=k.button.attrs({type:"button"})`
487
492
  display: inline-block;
488
493
  font-family: ${e=>e.theme.fontFamily};
489
494
  font-weight: 500;
@@ -542,7 +547,7 @@ React keys must be passed directly to JSX without using spread:
542
547
  box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
543
548
  }
544
549
  `}
545
- `,ko=$.div`
550
+ `,Vo=k.div`
546
551
  margin-bottom: 0.3rem;
547
552
 
548
553
  button:not(:first-child) {
@@ -554,7 +559,7 @@ React keys must be passed directly to JSX without using spread:
554
559
  border-top-right-radius: 0;
555
560
  border-bottom-right-radius: 0;
556
561
  }
557
- `,$o=$.div`
562
+ `,jo=k.div`
558
563
  background: transparent;
559
564
  width: 100%;
560
565
  height: 100%;
@@ -567,7 +572,7 @@ React keys must be passed directly to JSX without using spread:
567
572
  text-align: center;
568
573
  border: 1px solid ${e=>e.theme.borderColor};
569
574
  border-radius: ${e=>e.theme.borderRadius};
570
- `,Ro=$.header`
575
+ `,zo=k.header`
571
576
  overflow: hidden;
572
577
  height: 26px;
573
578
  width: 100%;
@@ -578,7 +583,7 @@ React keys must be passed directly to JSX without using spread:
578
583
  font-size: ${e=>e.theme.fontSizeSmall};
579
584
  color: ${e=>e.theme.textColor};
580
585
  background-color: transparent;
581
- `,Do=e=>w.jsx(mr,{weight:"light",...e}),Eo=e=>w.jsx(hr,{weight:"light",...e}),Vn=$(br)`
586
+ `,Oo=e=>E.jsx(Dr,{weight:"light",...e}),No=e=>E.jsx(Tr,{weight:"light",...e}),qn=k(Br)`
582
587
  width: 75%;
583
588
  height: 5px;
584
589
  background: ${e=>e.theme.sliderTrackColor};
@@ -627,7 +632,7 @@ React keys must be passed directly to JSX without using spread:
627
632
  &:focus::-moz-range-thumb {
628
633
  border: 2px solid ${e=>e.theme.textColor};
629
634
  }
630
- `,jn=$.label`
635
+ `,Qn=k.label`
631
636
  width: 100%;
632
637
  display: flex;
633
638
  justify-content: space-between;
@@ -635,12 +640,12 @@ React keys must be passed directly to JSX without using spread:
635
640
  padding: 0 1rem;
636
641
  margin-bottom: 0.2rem;
637
642
  font-size: 14px;
638
- `;$.div`
643
+ `;k.div`
639
644
  display: flex;
640
645
  align-items: center;
641
646
  gap: 0.25rem;
642
647
  padding: 0.5rem 0.5rem 0.25rem 0.5rem;
643
- `;$.span`
648
+ `;k.span`
644
649
  flex: 1;
645
650
  font-weight: 600;
646
651
  font-size: 0.875rem;
@@ -648,7 +653,7 @@ React keys must be passed directly to JSX without using spread:
648
653
  text-overflow: ellipsis;
649
654
  white-space: nowrap;
650
655
  margin: 0 0.25rem;
651
- `;$.button`
656
+ `;k.button`
652
657
  display: flex;
653
658
  align-items: center;
654
659
  justify-content: center;
@@ -673,7 +678,7 @@ React keys must be passed directly to JSX without using spread:
673
678
  &:active {
674
679
  transform: scale(0.9);
675
680
  }
676
- `;function To(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 zn(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 $r(e,t){switch(e){case 8:return new Int8Array(t);case 16:return new Int16Array(t)}}function On(e,t,n){const r=e.length,a=Math.ceil(r/t),s=$r(n,a*2);for(let o=0;o<a;o++){const l=o*t,i=Math.min((o+1)*t,r),d=e.subarray(l,i),f=To(d),b=zn(f.min,n),p=zn(f.max,n);s[o*2]=b,s[o*2+1]=p}return s}function Mo(e,t){const n=e.length,r=1/n,a=e[0].length/2,s=$r(t,a*2);for(let o=0;o<a;o++){let l=0,i=0;for(let d=0;d<n;d++)l+=r*e[d][o*2],i+=r*e[d][o*2+1];s[o*2]=l,s[o*2+1]=i}return[s]}function Bo(e,t=1e3,n=!0,r=0,a,s=16){if(s!==8&&s!==16)throw new Error("Invalid number of bits specified for peaks. Must be 8 or 16.");let o=[];if("getChannelData"in e){const i=e.numberOfChannels,d=a??e.length;for(let f=0;f<i;f++){const p=e.getChannelData(f).subarray(r,d);o.push(On(p,t,s))}}else{const i=a??e.length,d=e.subarray(r,i);o.push(On(d,t,s))}return n&&o.length>1&&(o=Mo(o,s)),{length:o[0].length/2,data:o,bits:s}}function _o(e,t=1e3,n=!0,r=8,a=0,s){const o=e.sampleRate,l=Math.floor(a*o),i=s!==void 0?Math.floor((a+s)*o):void 0;return Bo(e,t,n,l,i,r)}var Nn;(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"})(Nn||(Nn={}));function Hn(){}const Wo=Object.freeze({x:0,y:0});var tt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(tt||(tt={}));var Gn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Gn||(Gn={}));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;var Xn;(function(e){e[e.RightClick=2]="RightClick"})(Xn||(Xn={}));var Yn;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Yn||(Yn={}));var Ln;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ln||(Ln={}));tt.Backward+"",tt.Forward+"",tt.Backward+"",tt.Forward+"";var an;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(an||(an={}));var on;(function(e){e.Optimized="optimized"})(on||(on={}));function Fo(e,t){return u.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:s}=r;return n[a]=o=>{s(o,t)},n},{}),[e,t])}an.WhileDragging,on.Optimized;const Zo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Hn,draggableNodes:new Map,over:null,measureDroppableContainers:Hn},Po=u.createContext(Zo),Vo=u.createContext({...Wo,scaleX:1,scaleY:1});var Kn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Kn||(Kn={}));const jo=u.createContext(null),Un="button",zo="Draggable";function Jn(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=cr(zo),{activators:o,activatorEvent:l,active:i,activeNodeRect:d,ariaDescribedById:f,draggableNodes:b,over:p}=u.useContext(Po),{role:h=Un,roleDescription:x="draggable",tabIndex:I=0}=a??{},v=i?.id===t,m=u.useContext(v?Vo:jo),[C,y]=$t(),[g,k]=$t(),A=Fo(o,t),E=lr(n);Mt(()=>(b.set(t,{id:t,key:s,node:C,activatorNode:g,data:E}),()=>{const B=b.get(t);B&&B.key===s&&b.delete(t)}),[b,t]);const _=u.useMemo(()=>({role:h,tabIndex:I,"aria-disabled":r,"aria-pressed":v&&h===Un?!0:void 0,"aria-roledescription":x,"aria-describedby":f.draggable}),[r,h,I,v,x,f.draggable]);return{active:i,activatorEvent:l,activeNodeRect:d,attributes:_,isDragging:v,listeners:r?void 0:A,node:C,over:p,setNodeRef:y,setActivatorNodeRef:k,transform:m}}function Oo(e){return{id:e.id,start:parseFloat(e.begin),end:parseFloat(e.end),lines:e.lines,lang:e.language}}function No(e){return{id:e.id,begin:e.start.toFixed(3),end:e.end.toFixed(3),lines:e.lines,language:e.lang||"en"}}$.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
681
+ `;function Ho(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 er(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 Hr(e,t){switch(e){case 8:return new Int8Array(t);case 16:return new Int16Array(t)}}function tr(e,t,n){const r=e.length,a=Math.ceil(r/t),s=Hr(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=Ho(u),b=er(d.min,n),p=er(d.max,n);s[o*2]=b,s[o*2+1]=p}return s}function Go(e,t){const n=e.length,r=1/n,a=e[0].length/2,s=Hr(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 Xo(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(tr(p,t,s))}}else{const l=a??e.length,u=e.subarray(r,l);o.push(tr(u,t,s))}return n&&o.length>1&&(o=Go(o,s)),{length:o[0].length/2,data:o,bits:s}}function Yo(e,t=1e3,n=!0,r=8,a=0,s){const o=e.sampleRate,i=Math.floor(a*o),l=s!==void 0?Math.floor((a+s)*o):void 0;return Xo(e,t,n,i,l,r)}var nr;(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"})(nr||(nr={}));function rr(){}const Lo=Object.freeze({x:0,y:0});var st;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(st||(st={}));var ar;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ar||(ar={}));var Ue;(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"})(Ue||(Ue={}));Ue.Space,Ue.Enter,Ue.Esc,Ue.Space,Ue.Enter,Ue.Tab;var or;(function(e){e[e.RightClick=2]="RightClick"})(or||(or={}));var sr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(sr||(sr={}));var ir;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ir||(ir={}));st.Backward+"",st.Forward+"",st.Backward+"",st.Forward+"";var hn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(hn||(hn={}));var mn;(function(e){e.Optimized="optimized"})(mn||(mn={}));function Ko(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])}hn.WhileDragging,mn.Optimized;const Uo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:rr,draggableNodes:new Map,over:null,measureDroppableContainers:rr},Jo=c.createContext(Uo),qo=c.createContext({...Lo,scaleX:1,scaleY:1});var lr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(lr||(lr={}));const Qo=c.createContext(null),cr="button",es="Draggable";function ur(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Er(es),{activators:o,activatorEvent:i,active:l,activeNodeRect:u,ariaDescribedById:d,draggableNodes:b,over:p}=c.useContext(Jo),{role:f=cr,roleDescription:x="draggable",tabIndex:y=0}=a??{},v=l?.id===t,m=c.useContext(v?qo:Qo),[C,w]=Wt(),[g,A]=Wt(),I=Ko(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===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:F,isDragging:v,listeners:r?void 0:I,node:C,over:p,setNodeRef:w,setActivatorNodeRef:A,transform:m}}function ts(e){return{id:e.id,start:parseFloat(e.begin),end:parseFloat(e.end),lines:e.lines,lang:e.language}}function ns(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`}}))`
677
682
  position: absolute;
678
683
  top: 0;
679
684
  background: ${e=>e.$color};
@@ -689,7 +694,7 @@ React keys must be passed directly to JSX without using spread:
689
694
  opacity: 0.5;
690
695
  border-color: ${e=>e.$color};
691
696
  }
692
- `;$.div`
697
+ `;k.div`
693
698
  position: absolute;
694
699
  bottom: 0;
695
700
  left: 0;
@@ -705,7 +710,7 @@ React keys must be passed directly to JSX without using spread:
705
710
  pointer-events: none;
706
711
  white-space: pre-wrap;
707
712
  word-break: break-word;
708
- `;$.textarea`
713
+ `;k.textarea`
709
714
  position: absolute;
710
715
  bottom: 0;
711
716
  left: 0;
@@ -725,7 +730,7 @@ React keys must be passed directly to JSX without using spread:
725
730
  outline: none;
726
731
  border-color: #4CAF50;
727
732
  }
728
- `;$.div`
733
+ `;k.div`
729
734
  position: absolute;
730
735
  top: 0;
731
736
  left: 0;
@@ -736,7 +741,7 @@ React keys must be passed directly to JSX without using spread:
736
741
  padding: 4px;
737
742
  justify-content: flex-start;
738
743
  align-items: center;
739
- `;$.button`
744
+ `;k.button`
740
745
  background: transparent;
741
746
  border: 1px solid rgba(255, 255, 255, 0.5);
742
747
  color: white;
@@ -758,12 +763,12 @@ React keys must be passed directly to JSX without using spread:
758
763
  &:active {
759
764
  background: rgba(255, 255, 255, 0.3);
760
765
  }
761
- `;var Ho=$.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
766
+ `;var rs=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
762
767
  position: absolute;
763
768
  top: 0;
764
769
  height: 100%;
765
770
  pointer-events: none; /* Let events pass through to children */
766
- `,Go=$.div`
771
+ `,as=k.div`
767
772
  position: absolute;
768
773
  top: 0;
769
774
  left: 0;
@@ -787,7 +792,7 @@ React keys must be passed directly to JSX without using spread:
787
792
  border-width: 3px;
788
793
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
789
794
  }
790
- `,Xo=$.span`
795
+ `,os=k.span`
791
796
  font-size: 12px;
792
797
  font-weight: 600;
793
798
  color: ${e=>e.theme?.annotationLabelColor||"#2a2a2a"};
@@ -797,7 +802,7 @@ React keys must be passed directly to JSX without using spread:
797
802
  padding: 0 6px;
798
803
  letter-spacing: 0.3px;
799
804
  user-select: none;
800
- `,qn=$.div`
805
+ `,dr=k.div`
801
806
  position: absolute;
802
807
  top: 0;
803
808
  ${e=>e.$position==="left"?"left: -8px":"right: -8px"};
@@ -832,13 +837,13 @@ React keys must be passed directly to JSX without using spread:
832
837
  opacity: 1;
833
838
  background: ${e=>e.theme?.annotationResizeHandleActiveColor||"rgba(0, 0, 0, 0.7)"};
834
839
  }
835
- `,Yo=({annotationId:e,annotationIndex:t,startPosition:n,endPosition:r,label:a,color:s="#ff9800",isActive:o=!1,onClick:l,editable:i=!0})=>{const d=Math.max(0,r-n),f=`annotation-boundary-start-${t}`,{attributes:b,listeners:p,setActivatorNodeRef:h,isDragging:x}=Jn({id:f,data:{annotationId:e,annotationIndex:t,edge:"start"},disabled:!i}),I=`annotation-boundary-end-${t}`,{attributes:v,listeners:m,setActivatorNodeRef:C,isDragging:y}=Jn({id:I,data:{annotationId:e,annotationIndex:t,edge:"end"},disabled:!i});if(d<=0)return null;const g=A=>E=>{E.stopPropagation(),A?.(E)},k=A=>{A.stopPropagation()};return w.jsxs(Ho,{$left:n,$width:d,children:[w.jsx(Go,{$color:s,$isActive:o,onClick:l,children:a&&w.jsx(Xo,{children:a})}),i&&w.jsx(qn,{ref:h,$position:"left",$isDragging:x,onClick:k,...p,onPointerDown:g(p?.onPointerDown),...b}),i&&w.jsx(qn,{ref:C,$position:"right",$isDragging:y,onClick:k,...m,onPointerDown:g(m?.onPointerDown),...v})]})},Lo=$.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
840
+ `,ss=({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:b,listeners:p,setActivatorNodeRef:f,isDragging:x}=ur({id:d,data:{annotationId:e,annotationIndex:t,edge:"start"},disabled:!l}),y=`annotation-boundary-end-${t}`,{attributes:v,listeners:m,setActivatorNodeRef:C,isDragging:w}=ur({id:y,data:{annotationId:e,annotationIndex:t,edge:"end"},disabled:!l});if(u<=0)return null;const g=I=>D=>{D.stopPropagation(),I?.(D)},A=I=>{I.stopPropagation()};return E.jsxs(rs,{$left:n,$width:u,children:[E.jsx(as,{$color:s,$isActive:o,onClick:i,children:a&&E.jsx(os,{children:a})}),l&&E.jsx(dr,{ref:f,$position:"left",$isDragging:x,onClick:A,...p,onPointerDown:g(p?.onPointerDown),...b}),l&&E.jsx(dr,{ref:C,$position:"right",$isDragging:w,onClick:A,...m,onPointerDown:g(m?.onPointerDown),...v})]})},is=k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
836
841
  position: relative;
837
842
  display: flex;
838
843
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
839
844
  background: transparent;
840
845
  z-index: 110;
841
- `,Ko=$.div`
846
+ `,ls=k.div`
842
847
  position: sticky;
843
848
  z-index: 200;
844
849
  left: 0;
@@ -846,16 +851,16 @@ React keys must be passed directly to JSX without using spread:
846
851
  width: ${e=>e.$controlWidth}px;
847
852
  flex-shrink: 0;
848
853
  background: transparent;
849
- `,Uo=$.div`
854
+ `,cs=k.div`
850
855
  position: relative;
851
856
  flex: 1;
852
857
  padding-left: ${e=>e.$offset||0}px;
853
- `,Jo=({children:e,className:t,height:n=30,offset:r=0,width:a})=>{const{controls:{show:s,width:o}}=Ft();return w.jsxs(Lo,{className:t,$height:n,$controlWidth:s?o:0,$width:a,children:[w.jsx(Ko,{$controlWidth:s?o:0}),w.jsx(Uo,{$offset:r,children:e})]})};$.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
858
+ `,us=({children:e,className:t,height:n=30,offset:r=0,width:a})=>{const{controls:{show:s,width:o}}=Nt();return E.jsxs(is,{className:t,$height:n,$controlWidth:s?o:0,$width:a,children:[E.jsx(ls,{$controlWidth:s?o:0}),E.jsx(cs,{$offset:r,children:e})]})};k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
854
859
  position: relative;
855
860
  display: flex;
856
861
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
857
862
  background: transparent;
858
- `;$.div`
863
+ `;k.div`
859
864
  position: sticky;
860
865
  z-index: 200;
861
866
  left: 0;
@@ -869,16 +874,16 @@ React keys must be passed directly to JSX without using spread:
869
874
  font-size: 12px;
870
875
  color: ${e=>e.theme?.textColorMuted||"#666"};
871
876
  font-weight: bold;
872
- `;$.div`
877
+ `;k.div`
873
878
  position: relative;
874
879
  flex: 1;
875
880
  padding-left: ${e=>e.$offset||0}px;
876
- `;var qo=$.div`
881
+ `;var ds=k.div`
877
882
  background: ${e=>e.theme?.backgroundColor||"#fff"};
878
883
  ${e=>e.$height?`height: ${e.$height}px;`:"max-height: 200px;"}
879
884
  overflow-y: auto;
880
885
  padding: 8px;
881
- `,Qo=$.div`
886
+ `,fs=k.div`
882
887
  padding: 12px;
883
888
  margin-bottom: 6px;
884
889
  border-left: 4px solid ${e=>e.$isActive?"#ff9800":"transparent"};
@@ -897,16 +902,16 @@ React keys must be passed directly to JSX without using spread:
897
902
  outline: 2px solid #ff9800;
898
903
  outline-offset: 2px;
899
904
  }
900
- `,es=$.div`
905
+ `,hs=k.div`
901
906
  display: flex;
902
907
  justify-content: space-between;
903
908
  align-items: center;
904
909
  margin-bottom: 6px;
905
- `,ts=$.div`
910
+ `,ms=k.div`
906
911
  display: flex;
907
912
  align-items: center;
908
913
  gap: 8px;
909
- `,ns=$.span`
914
+ `,ps=k.span`
910
915
  font-size: 11px;
911
916
  font-weight: 600;
912
917
  color: ${e=>e.theme?.textColorMuted||"#666"};
@@ -920,16 +925,16 @@ React keys must be passed directly to JSX without using spread:
920
925
  outline: 2px solid #ff9800;
921
926
  background: rgba(255, 152, 0, 0.1);
922
927
  }
923
- `,rs=$.span`
928
+ `,gs=k.span`
924
929
  font-size: 12px;
925
930
  font-weight: 500;
926
931
  color: ${e=>e.theme?.textColorMuted||"#555"};
927
932
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
928
933
  letter-spacing: 0.5px;
929
- `,as=$.div`
934
+ `,bs=k.div`
930
935
  display: flex;
931
936
  gap: 6px;
932
- `,os=$.button`
937
+ `,vs=k.button`
933
938
  background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
934
939
  border: 1px solid ${e=>e.theme?.borderColor||"#ccc"};
935
940
  color: ${e=>e.theme?.textColor||"#333"};
@@ -948,7 +953,7 @@ React keys must be passed directly to JSX without using spread:
948
953
  &:active {
949
954
  transform: scale(0.95);
950
955
  }
951
- `,ss=$.div`
956
+ `,Cs=k.div`
952
957
  font-size: 14px;
953
958
  line-height: 1.6;
954
959
  color: ${e=>e.theme?.textColor||"#2a2a2a"};
@@ -963,9 +968,9 @@ React keys must be passed directly to JSX without using spread:
963
968
  outline: 2px solid #ff9800;
964
969
  background: rgba(255, 152, 0, 0.1);
965
970
  }
966
- `,is=({annotations:e,activeAnnotationId:t,shouldScrollToActive:n=!1,editable:r=!1,controls:a=[],annotationListConfig:s,height:o,onAnnotationClick:l,onAnnotationUpdate:i})=>{const d=u.useRef(null),f=u.useRef(null),b=u.useRef(void 0);u.useEffect(()=>{}),u.useEffect(()=>{const m=f.current;if(!m)return;const C=()=>{};return m.addEventListener("scroll",C),()=>m.removeEventListener("scroll",C)},[]),u.useEffect(()=>{t&&d.current&&n&&d.current.scrollIntoView({behavior:"smooth",block:"nearest"}),b.current=t},[t,n]);const p=m=>{if(isNaN(m)||!isFinite(m))return"0:00.000";const C=Math.floor(m/60),y=(m%60).toFixed(3);return`${C}:${y.padStart(6,"0")}`},h=(m,C)=>{if(!r||!i)return;const y=[...e];y[m]={...y[m],lines:C.split(`
967
- `)},i(y)},x=(m,C)=>{if(!r||!i)return;const y=C.trim();if(!y)return;const g=[...e];g[m]={...g[m],id:y},i(g)},I=(m,C,y)=>{if(!i)return;const g=[...e];m.action(g[y],y,g,s||{}),i(g)},v=m=>m.replace(/\./g," ");return w.jsx(qo,{ref:f,$height:o,children:e.map((m,C)=>{const y=m.id===t;return w.jsxs(Qo,{ref:y?d:null,$isActive:y,onClick:()=>l?.(m),children:[w.jsxs(es,{children:[w.jsxs(ts,{children:[w.jsx(ns,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:g=>x(C,g.currentTarget.textContent||""),children:m.id}),w.jsxs(rs,{children:[p(m.start)," - ",p(m.end)]})]}),a.length>0&&w.jsx(as,{onClick:g=>g.stopPropagation(),children:a.map((g,k)=>w.jsx(os,{title:g.title,onClick:()=>I(g,m,C),children:g.text?g.text:w.jsx("i",{className:v(g.class||"")})},k))})]}),w.jsx(ss,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:g=>h(C,g.currentTarget.textContent||""),children:m.lines.join(`
968
- `)})]},m.id)})})},ls=u.memo(is),cs=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return w.jsxs(Bt,{className:r,children:[w.jsx(_t,{type:"checkbox",id:"continuous-play",className:"continuous-play",checked:e,onChange:a,disabled:n}),w.jsx(Wt,{htmlFor:"continuous-play",children:"Continuous Play"})]})},us=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return w.jsxs(Bt,{className:r,children:[w.jsx(_t,{type:"checkbox",id:"link-endpoints",className:"link-endpoints",checked:e,onChange:a,disabled:n}),w.jsx(Wt,{htmlFor:"link-endpoints",children:"Link Endpoints"})]})},ds=({checked:e,onChange:t,className:n})=>w.jsxs(Bt,{className:n,children:[w.jsx(_t,{type:"checkbox",id:"editable-annotations",checked:e,onChange:r=>t(r.target.checked)}),w.jsx(Wt,{htmlFor:"editable-annotations",children:"Editable Annotations"})]}),fs=$.button`
971
+ `,xs=({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),b=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"}),b.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(`
972
+ `)},l(w)},x=(m,C)=>{if(!r||!l)return;const w=C.trim();if(!w)return;const g=[...e];g[m]={...g[m],id:w},l(g)},y=(m,C,w)=>{if(!l)return;const g=[...e];m.action(g[w],w,g,s||{}),l(g)},v=m=>m.replace(/\./g," ");return E.jsx(ds,{ref:d,$height:o,children:e.map((m,C)=>{const w=m.id===t;return E.jsxs(fs,{ref:w?u:null,$isActive:w,onClick:()=>i?.(m),children:[E.jsxs(hs,{children:[E.jsxs(ms,{children:[E.jsx(ps,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:g=>x(C,g.currentTarget.textContent||""),children:m.id}),E.jsxs(gs,{children:[p(m.start)," - ",p(m.end)]})]}),a.length>0&&E.jsx(bs,{onClick:g=>g.stopPropagation(),children:a.map((g,A)=>E.jsx(vs,{title:g.title,onClick:()=>y(g,m,C),children:g.text?g.text:E.jsx("i",{className:v(g.class||"")})},A))})]}),E.jsx(Cs,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:g=>f(C,g.currentTarget.textContent||""),children:m.lines.join(`
973
+ `)})]},m.id)})})},ws=c.memo(xs),ys=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return E.jsxs(jt,{className:r,children:[E.jsx(zt,{type:"checkbox",id:"continuous-play",className:"continuous-play",checked:e,onChange:a,disabled:n}),E.jsx(Ot,{htmlFor:"continuous-play",children:"Continuous Play"})]})},Is=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return E.jsxs(jt,{className:r,children:[E.jsx(zt,{type:"checkbox",id:"link-endpoints",className:"link-endpoints",checked:e,onChange:a,disabled:n}),E.jsx(Ot,{htmlFor:"link-endpoints",children:"Link Endpoints"})]})},As=({checked:e,onChange:t,className:n})=>E.jsxs(jt,{className:n,children:[E.jsx(zt,{type:"checkbox",id:"editable-annotations",checked:e,onChange:r=>t(r.target.checked)}),E.jsx(Ot,{htmlFor:"editable-annotations",children:"Editable Annotations"})]}),Ss=k.button`
969
974
  padding: 0.5rem 1rem;
970
975
  background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
971
976
  color: ${e=>e.theme?.textColor||"#333"};
@@ -991,7 +996,7 @@ React keys must be passed directly to JSX without using spread:
991
996
  opacity: 0.6;
992
997
  cursor: not-allowed;
993
998
  }
994
- `,hs=({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=>No(b)),l=JSON.stringify(o,null,2),i=new Blob([l],{type:"application/json"}),d=URL.createObjectURL(i),f=document.createElement("a");f.href=d,f.download=t,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(d)};return w.jsx(fs,{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 Rr(){const[e,t]=u.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:a=>nt(a,e),parseTime:a=>Ir(a,e)}}const ms=[256,512,1024,2048,4096,8192];function Dr({initialSamplesPerPixel:e,zoomLevels:t=ms}){const[n,r]=u.useState(()=>{const d=t.indexOf(e);return d!==-1?d:Math.floor(t.length/2)}),a=t[n],s=n>0,o=n<t.length-1,l=u.useCallback(()=>{r(d=>Math.max(0,d-1))},[]),i=u.useCallback(()=>{r(d=>Math.min(t.length-1,d+1))},[t.length]);return{samplesPerPixel:a,zoomIn:l,zoomOut:i,canZoomIn:s,canZoomOut:o}}function Er({playoutRef:e,initialVolume:t=1,onVolumeChange:n}){const[r,a]=u.useState(t),s=u.useCallback(o=>{a(o),e.current&&e.current.setMasterGain(o),n?.(o)},[e,n]);return{masterVolume:r,setMasterVolume:s}}const ps=(e=256)=>{const t=u.useRef(null),n=u.useCallback((r,a,s)=>{const o=new F.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:l,fadeIn:i,fadeOut:d}=e;return{id:Tr(),audioBuffer:t,startSample:n,durationSamples:r,offsetSamples:a,gain:s,name:o,color:l,fadeIn:i,fadeOut:d}}function gs(e){const{audioBuffer:t,startTime:n,duration:r=t.duration,offset:a=0,gain:s=1,name:o,color:l,fadeIn:i,fadeOut:d}=e,f=t.sampleRate;return sn({audioBuffer:t,startSample:Math.round(n*f),durationSamples:Math.round(r*f),offsetSamples:Math.round(a*f),gain:s,name:o,color:l,fadeIn:i,fadeOut:d})}function bs(e){const{name:t,clips:n=[],muted:r=!1,soloed:a=!1,volume:s=1,pan:o=0,color:l,height:i}=e;return{id:Tr(),name:t,clips:n,muted:r,soloed:a,volume:s,pan:o,color:l,height:i}}function Tr(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function vs(e){const[t,n]=u.useState([]),[r,a]=u.useState(!0),[s,o]=u.useState(null);return u.useEffect(()=>{if(e.length===0){n([]),a(!1);return}let l=!1;return(async()=>{try{a(!0),o(null);const d=or.getContext().rawContext,f=e.map(async(p,h)=>{const x=await fetch(p.src);if(!x.ok)throw new Error(`Failed to fetch ${p.src}: ${x.statusText}`);const I=await x.arrayBuffer(),v=await d.decodeAudioData(I);if(!v||!v.sampleRate||!v.duration)throw new Error(`Invalid audio buffer for ${p.src}`);const m=p.duration??v.duration,C=gs({audioBuffer:v,startTime:p.startTime??0,duration:m,offset:p.offset??0,name:p.name||`Track ${h+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{...bs({name:p.name||`Track ${h+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(f);l||(n(b),a(!1))}catch(d){if(!l){const f=d instanceof Error?d.message:"Unknown error loading audio";o(f),a(!1),console.error("Error loading audio tracks:",d)}}})(),()=>{l=!0}},[e]),{tracks:t,loading:r,error:s}}function Cs({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r}){const a=u.useRef(null),s=u.useCallback(d=>{const{transform:f,active:b}=d;if(!b?.data?.current)return{...f,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:h,boundary:x}=b.data.current;if(x)return{...f,scaleX:1,scaleY:1};const I=e[p];if(!I)return{...f,scaleX:1,scaleY:1};const v=I.clips[h];if(!v)return{...f,scaleX:1,scaleY:1};const m=v.startSample/r,C=v.durationSamples/r,y=f.x*n/r;let g=m+y;const k=[...I.clips].sort((D,Z)=>D.startSample-Z.startSample),A=k.findIndex(D=>D===v);g=Math.max(0,g);const E=A>0?k[A-1]:null;if(E){const D=(E.startSample+E.durationSamples)/r;g=Math.max(g,D)}const _=A<k.length-1?k[A+1]:null;if(_){const D=g+C,Z=_.startSample/r;D>Z&&(g=Z-C)}const M=(g-m)*r/n;return{...f,x:M,scaleX:1,scaleY:1}},[e,n,r]),o=u.useCallback(d=>{const{active:f}=d,{boundary:b}=f.data.current;if(!b){a.current=null;return}const{trackIndex:p,clipIndex:h}=f.data.current,I=e[p]?.clips[h];I&&(a.current={offsetSamples:I.offsetSamples,durationSamples:I.durationSamples,startSample:I.startSample})},[e]),l=u.useCallback(d=>{const{active:f,delta:b}=d,{boundary:p}=f.data.current;if(!p||!a.current)return;const{trackIndex:h,clipIndex:x}=f.data.current,I=b.x*n,v=Math.floor(.1*r),m=a.current,C=e.map((y,g)=>{if(g!==h)return y;const k=[...y.clips].sort((_,B)=>_.startSample-B.startSample),A=k.findIndex(_=>_===y.clips[x]),E=y.clips.map((_,B)=>{if(B!==x)return _;const M=Math.floor(_.audioBuffer.duration*r);if(p==="left"){let D=Math.floor(I);const Z=-m.startSample;D<Z&&(D=Z);const W=-m.offsetSamples;D<W&&(D=W);const O=A>0?k[A-1]:null;if(O){const ee=O.startSample+O.durationSamples-m.startSample;D<ee&&(D=ee)}const N=m.durationSamples-v;D>N&&(D=N);const G=m.offsetSamples+D,K=m.durationSamples-D,Q=m.startSample+D;return{..._,offsetSamples:G,durationSamples:K,startSample:Q}}else{let D=Math.floor(m.durationSamples+I);D=Math.max(v,D),m.offsetSamples+D>M&&(D=M-m.offsetSamples);const Z=A<k.length-1?k[A+1]:null;return Z&&m.startSample+D>Z.startSample&&(D=Z.startSample-m.startSample,D=Math.max(v,D)),{..._,durationSamples:D}}});return{...y,clips:E}});t(C)},[e,t,n,r]),i=u.useCallback(d=>{const{active:f,delta:b}=d,{trackIndex:p,clipIndex:h,boundary:x}=f.data.current,I=b.x*n;if(x){a.current=null;return}const v=e.map((m,C)=>{if(C!==p)return m;const y=[...m.clips].sort((A,E)=>A.startSample-E.startSample),g=y.findIndex(A=>A===m.clips[h]),k=m.clips.map((A,E)=>{if(E!==h)return A;let _=Math.floor(A.startSample+I);_=Math.max(0,_);const B=g>0?y[g-1]:null;if(B){const D=B.startSample+B.durationSamples;_=Math.max(_,D)}const M=g<y.length-1?y[g+1]:null;return M&&_+A.durationSamples>M.startSample&&(_=M.startSample-A.durationSamples),{...A,startSample:_}});return{...m,clips:k}});t(v)},[e,t,n,r]);return{onDragStart:o,onDragMove:l,onDragEnd:i,collisionModifier:s}}const Jt=.01;function xs({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:a,linkEndpoints:s}){const o=u.useRef(null),l=u.useCallback(f=>{const{active:b}=f,p=b.data.current;if(!p||p.annotationIndex===void 0){o.current=null;return}const h=e[p.annotationIndex];h&&(o.current={start:h.start,end:h.end,annotationIndex:p.annotationIndex})},[e]),i=u.useCallback(f=>{const{active:b,delta:p}=f;if(!o.current)return;const h=b.data.current;if(!h)return;const{edge:x,annotationIndex:I}=h,v=o.current,m=p.x*n/r,C=x==="start"?v.start+m:v.end+m,y=ys({annotationIndex:I,newTime:C,isDraggingStart:x==="start",annotations:e,duration:a,linkEndpoints:s});t(y)},[e,t,n,r,a,s]),d=u.useCallback(()=>{o.current=null},[]);return{onDragStart:l,onDragMove:i,onDragEnd:d}}function ys({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:a,linkEndpoints:s}){const o=[...r],l=r[e];if(n){const i=Math.min(l.end-.1,Math.max(0,t)),d=i-l.start;if(o[e]={...l,start:i},s&&e>0){const f=o[e-1];Math.abs(f.end-l.start)<Jt?o[e-1]={...f,end:Math.max(f.start+.1,f.end+d)}:i<=f.end&&(o[e]={...o[e],start:f.end})}else!s&&e>0&&i<o[e-1].end&&(o[e-1]={...o[e-1],end:i})}else{const i=Math.max(l.start+.1,Math.min(t,a)),d=i-l.end;if(o[e]={...l,end:i},s&&e<o.length-1){const f=o[e+1];if(Math.abs(f.start-l.end)<Jt){const b=f.start+d;o[e+1]={...f,start:Math.min(f.end-.1,b)};let p=e+1;for(;p<o.length-1;){const h=o[p],x=o[p+1];if(Math.abs(x.start-h.end)<Jt){const I=h.end-r[p].end;o[p+1]={...x,start:Math.min(x.end-.1,x.start+I)},p++}else break}}else i>=f.start&&(o[e]={...o[e],end:f.start})}else if(!s&&e<o.length-1&&i>o[e+1].start){const f=o[e+1];o[e+1]={...f,start:i};let b=e+1;for(;b<o.length-1;){const p=o[b],h=o[b+1];if(p.end>h.start)o[b+1]={...h,start:p.end},b++;else break}}}return o}function ws(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:a=1}=e,s=Xt(dr,{activationConstraint:{distance:a}}),o=Xt(fr,{activationConstraint:t?{delay:n,tolerance:r}:{distance:a}}),l=Xt(ur,{activationConstraint:{distance:a}});return ha(...t?[s,o]:[l])}const Is=e=>{const{tracks:t,onTracksChange:n,sampleRate:r}=e,{currentTimeRef:a}=$e(),{selectedTrackId:s}=Fe(),o=u.useCallback((i,d,f)=>{const{sampleRate:b,samplesPerPixel:p}=e,h=t[i];if(!h)return!1;const x=h.clips[d];if(!x)return!1;const I=x.startSample/b,v=(x.startSample+x.durationSamples)/b;if(f<=I||f>=v)return console.warn("Split time is outside clip bounds"),!1;const m=Math.round(f*b),C=Math.floor(m/p),y=x.startSample+x.durationSamples,g=C*p,k=x.startSample,A=g-k,E=g,_=y-E,B=g-x.startSample,M=sn({audioBuffer:x.audioBuffer,startSample:k,durationSamples:A,offsetSamples:x.offsetSamples,gain:x.gain,name:x.name?`${x.name} (1)`:void 0,color:x.color,fadeIn:x.fadeIn}),D=sn({audioBuffer:x.audioBuffer,startSample:E,durationSamples:_,offsetSamples:x.offsetSamples+B,gain:x.gain,name:x.name?`${x.name} (2)`:void 0,color:x.color,fadeOut:x.fadeOut}),Z=[...h.clips];Z.splice(d,1,M,D);const W=[...t];return W[i]={...h,clips:Z},n(W),!0},[t,n,e]);return{splitClipAtPlayhead:u.useCallback(()=>{if(!s)return console.log("No track selected - click a clip to select a track first"),!1;const i=t.findIndex(b=>b.id===s);if(i===-1)return console.warn("Selected track not found"),!1;const d=t[i],f=a.current??0;for(let b=0;b<d.clips.length;b++){const p=d.clips[b],h=p.startSample/r,x=(p.startSample+p.durationSamples)/r;if(f>h&&f<x)return console.log(`Splitting clip on track "${d.name}" at ${f}s`),o(i,b,f)}return console.log(`No clip found at playhead position on track "${d.name}"`),!1},[t,a,s,o,r]),splitClipAt:o}},Dt=e=>{const{shortcuts:t,enabled:n=!0}=e,r=u.useCallback(a=>{if(!n)return;const s=a.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const o=t.find(l=>{const i=a.key.toLowerCase()===l.key.toLowerCase()||a.key===l.key,d=l.ctrlKey===void 0||a.ctrlKey===l.ctrlKey,f=l.shiftKey===void 0||a.shiftKey===l.shiftKey,b=l.metaKey===void 0||a.metaKey===l.metaKey,p=l.altKey===void 0||a.altKey===l.altKey;return i&&d&&f&&b&&p});o&&(o.preventDefault!==!1&&a.preventDefault(),o.action())},[t,n]);u.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},As=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("+")},Ss=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:a}=$e(),{setCurrentTime:s,play:o,pause:l,stop:i}=be(),{playoutRef:d}=Ae(),f=u.useCallback(()=>{a?l():o()},[a,o,l]),b=u.useCallback(()=>{i()},[i]),p=u.useCallback(()=>{a&&d.current?(d.current.stop(),s(0),o(0)):s(0)},[a,d,s,o]),x=r??[...[{key:" ",action:f,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 Dt({shortcuts:x,enabled:t}),{rewindToStart:p,togglePlayPause:f,stopPlayback:b,shortcuts:x}},qt=.01,At=.01;function ks({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:a,linkEndpoints:s,continuousPlay:o=!1,enabled:l=!0,scrollContainerRef:i,samplesPerPixel:d,sampleRate:f,controlsWidth:b=0,onPlay:p}){const h=u.useMemo(()=>t?e.findIndex(B=>B.id===t):-1,[e,t]),x=u.useCallback(B=>{if(!i?.current||!d||!f)return;const M=e.find(H=>H.id===B);if(!M)return;const D=i.current,Z=D.clientWidth,W=M.start*f/d+b,O=M.end*f/d+b,N=(W+O)/2,G=D.scrollLeft,K=G,Q=G+Z;if(W<K||O>Q){const H=Math.max(0,N-Z/2);D.scrollTo({left:H,behavior:"smooth"})}},[e,i,d,f,b]);u.useEffect(()=>{t&&i?.current&&d&&f&&x(t)},[t,x,i,d,f]);const I=u.useCallback(B=>{if(h<0)return;const M=e[h],D=Math.max(0,Math.min(M.end-.1,M.start+B)),Z=D-M.start,W=[...e];if(W[h]={...M,start:D},s&&h>0){const O=W[h-1];Math.abs(O.end-M.start)<qt&&(W[h-1]={...O,end:Math.max(O.start+.1,O.end+Z)})}else if(!s&&h>0){const O=W[h-1];D<O.end&&(W[h-1]={...O,end:D})}n(W)},[e,h,s,n]),v=u.useCallback(B=>{if(h<0)return;const M=e[h],D=Math.max(M.start+.1,Math.min(a,M.end+B)),Z=D-M.end,W=[...e];if(W[h]={...M,end:D},s&&h<e.length-1){const O=W[h+1];if(Math.abs(O.start-M.end)<qt){const N=Math.min(O.end-.1,O.start+Z);W[h+1]={...O,start:N};let G=h+1;for(;G<W.length-1;){const K=W[G],Q=W[G+1];if(Math.abs(Q.start-e[G].end)<qt){const H=K.end-e[G].end;W[G+1]={...Q,start:Math.min(Q.end-.1,Q.start+H)},G++}else break}}}else if(!s&&h<e.length-1){const O=W[h+1];if(D>O.start){W[h+1]={...O,start:D};let N=h+1;for(;N<W.length-1;){const G=W[N],K=W[N+1];if(G.end>K.start)W[N+1]={...K,start:G.end},N++;else break}}}n(W)},[e,h,a,s,n]),m=u.useCallback(()=>{!r||e.length===0||(h<=0?r(e[e.length-1].id):r(e[h-1].id))},[e,h,r]),C=u.useCallback(()=>{!r||e.length===0||(h<0||h>=e.length-1?r(e[0].id):r(e[h+1].id))},[e,h,r]),y=u.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),g=u.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),k=u.useCallback(()=>{r&&r(null)},[r]),A=u.useCallback(()=>{if(h<0||!p)return;const B=e[h],M=o?void 0:B.end-B.start;p(B.start,M)},[e,h,o,p]),E=u.useMemo(()=>[{key:"[",action:()=>I(-At),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>I(At),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-At),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(At),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:A,description:"Play selected annotation",preventDefault:!0}],[I,v,A]),_=u.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:y,description:"Select first annotation",preventDefault:!0},{key:"End",action:g,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:k,description:"Deselect annotation",preventDefault:!0}],[m,C,y,g,k]);return Dt({shortcuts:E,enabled:l&&h>=0}),Dt({shortcuts:_,enabled:l&&e.length>0&&!!r}),{moveStartBoundary:I,moveEndBoundary:v,selectPrevious:m,selectNext:C,selectFirst:y,selectLast:g,clearSelection:k,scrollToAnnotation:x,playActiveAnnotation:A}}function $s(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 Rs(e,t,n,r=1){const a=e.createBuffer(r,t.length,n),s=new Float32Array(t);return a.copyToChannel(s,0),a}function Qn(e,t,n=16){const r=Math.ceil(e.length/t),a=n===8?new Int8Array(r*2):new Int16Array(r*2),s=2**(n-1);for(let o=0;o<r;o++){const l=o*t,i=Math.min(l+t,e.length);let d=0,f=0;for(let b=l;b<i;b++){const p=e[b];p<d&&(d=p),p>f&&(f=p)}a[o*2]=Math.floor(d*s),a[o*2+1]=Math.floor(f*s)}return a}function Ds(e,t,n,r,a=16){const s=2**(a-1),o=r%n;let l=0;if(o>0&&e.length>0){const f=n-o,b=Math.min(f,t.length);let p=e[e.length-2]/s,h=e[e.length-1]/s;for(let m=0;m<b;m++){const C=t[m];C<p&&(p=C),C>h&&(h=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(h*s),l=b;const I=Qn(t.slice(l),n,a),v=new(a===8?Int8Array:Int16Array)(x.length+I.length);return v.set(x),v.set(I,x.length),v}const i=Qn(t.slice(l),n,a),d=new(a===8?Int8Array:Int16Array)(e.length+i.length);return d.set(e),d.set(i,e.length),d}function Es(e,t={}){const{channelCount:n=1,samplesPerPixel:r=1024}=t,[a,s]=u.useState(!1),[o,l]=u.useState(!1),[i,d]=u.useState(0),[f,b]=u.useState(new Int16Array(0)),[p,h]=u.useState(null),[x,I]=u.useState(null),[v,m]=u.useState(0),[C,y]=u.useState(0),g=16,k=u.useRef(!1),A=u.useRef(null),E=u.useRef(null),_=u.useRef([]),B=u.useRef(0),M=u.useRef(null),D=u.useRef(0),Z=u.useRef(!1),W=u.useRef(!1),O=u.useCallback(async()=>{if(!k.current)try{const H=F.getContext(),ee=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw",typeof document>"u"?require("url").pathToFileURL(__filename).href:Nt&&Nt.tagName.toUpperCase()==="SCRIPT"&&Nt.src||new URL("index.js",document.baseURI).href).href;await H.addAudioWorkletModule(ee),k.current=!0}catch(H){throw console.error("Failed to load AudioWorklet module:",H),new Error("Failed to load recording processor")}},[]),N=u.useCallback(async()=>{if(!e){I(new Error("No microphone stream available"));return}try{I(null);const H=F.getContext();H.state==="suspended"&&await H.resume(),await O();const ee=H.createMediaStreamSource(e);E.current=ee;const ie=H.createAudioWorkletNode("recording-processor");A.current=ie,ee.connect(ie),ie.port.onmessage=q=>{const{samples:re}=q.data;_.current.push(re),B.current+=re.length,b(te=>Ds(te,re,r,B.current-re.length,g))},ie.port.postMessage({command:"start",sampleRate:H.sampleRate,channelCount:n}),_.current=[],B.current=0,b(new Int16Array(0)),h(null),m(0),y(0),Z.current=!0,W.current=!1,s(!0),l(!1),D.current=performance.now();const ce=()=>{if(Z.current&&!W.current){const q=(performance.now()-D.current)/1e3;d(q),M.current=requestAnimationFrame(ce)}};ce()}catch(H){console.error("Failed to start recording:",H),I(H instanceof Error?H:new Error("Failed to start recording"))}},[e,n,r,O,a,o]),G=u.useCallback(async()=>{if(!a)return null;try{if(A.current){if(A.current.port.postMessage({command:"stop"}),E.current)try{E.current.disconnect(A.current)}catch{}A.current.disconnect()}M.current!==null&&(cancelAnimationFrame(M.current),M.current=null);const H=$s(_.current),ie=F.getContext().rawContext,ce=Rs(ie,H,ie.sampleRate,n);return h(ce),d(ce.duration),Z.current=!1,W.current=!1,s(!1),l(!1),m(0),ce}catch(H){return console.error("Failed to stop recording:",H),I(H instanceof Error?H:new Error("Failed to stop recording")),null}},[a,n]),K=u.useCallback(()=>{a&&!o&&(M.current!==null&&(cancelAnimationFrame(M.current),M.current=null),W.current=!0,l(!0))},[a,o]),Q=u.useCallback(()=>{if(a&&o){W.current=!1,l(!1),D.current=performance.now()-i*1e3;const H=()=>{if(Z.current&&!W.current){const ee=(performance.now()-D.current)/1e3;d(ee),M.current=requestAnimationFrame(H)}};H()}},[a,o,i]);return u.useEffect(()=>()=>{if(A.current){if(A.current.port.postMessage({command:"stop"}),E.current)try{E.current.disconnect(A.current)}catch{}A.current.disconnect()}M.current!==null&&cancelAnimationFrame(M.current)},[]),{isRecording:a,isPaused:o,duration:i,peaks:f,audioBuffer:p,level:v,peakLevel:C,startRecording:N,stopRecording:G,pauseRecording:K,resumeRecording:Q,error:x}}function Ts(){const[e,t]=u.useState(null),[n,r]=u.useState([]),[a,s]=u.useState(!1),[o,l]=u.useState(!1),[i,d]=u.useState(null),f=u.useCallback(async()=>{try{const x=(await navigator.mediaDevices.enumerateDevices()).filter(I=>I.kind==="audioinput").map(I=>({deviceId:I.deviceId,label:I.label||`Microphone ${I.deviceId.slice(0,8)}`,groupId:I.groupId}));r(x)}catch(h){console.error("Failed to enumerate devices:",h),d(h instanceof Error?h:new Error("Failed to enumerate devices"))}},[]),b=u.useCallback(async(h,x)=>{l(!0),d(null);try{e&&e.getTracks().forEach(C=>C.stop());const v={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...x,...h&&{deviceId:{exact:h}}},video:!1},m=await navigator.mediaDevices.getUserMedia(v);t(m),s(!0),await f()}catch(I){console.error("Failed to access microphone:",I),d(I instanceof Error?I:new Error("Failed to access microphone")),s(!1)}finally{l(!1)}},[e,f]),p=u.useCallback(()=>{e&&(e.getTracks().forEach(h=>h.stop()),t(null),s(!1))},[e]);return u.useEffect(()=>(f(),()=>{e&&e.getTracks().forEach(h=>h.stop())}),[]),{stream:e,devices:n,hasPermission:a,isLoading:o,requestAccess:b,stopStream:p,error:i}}function Ms(e,t={}){const{updateRate:n=60,smoothingTimeConstant:r=.8}=t,[a,s]=u.useState(0),[o,l]=u.useState(0),i=u.useRef(null),d=u.useRef(null),f=u.useRef(null),b=()=>l(0);return u.useEffect(()=>{if(!e){s(0),l(0);return}let p=!0;return(async()=>{if(!p)return;const x=F.getContext();if(x.state==="suspended"&&await x.resume(),!p)return;const I=new F.Meter({smoothing:r,context:x});i.current=I;const v=x.createMediaStreamSource(e);d.current=v,F.connect(v,I);const m=1e3/n;let C=0;const y=g=>{if(!(!p||!i.current)){if(g-C>=m){C=g;const k=i.current.getValue(),A=typeof k=="number"?k:k[0],E=Math.max(0,Math.min(1,(A+100)/100));s(E),l(_=>Math.max(_,E))}f.current=requestAnimationFrame(y)}};f.current=requestAnimationFrame(y)})(),()=>{if(p=!1,f.current&&(cancelAnimationFrame(f.current),f.current=null),d.current){try{d.current.disconnect()}catch{}d.current=null}i.current&&(i.current.dispose(),i.current=null)}},[e,r,n]),{level:a,peakLevel:o,resetPeak:b}}$.button`
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`
995
1000
  padding: 0.5rem 1rem;
996
1001
  font-size: 0.875rem;
997
1002
  font-weight: 500;
@@ -1021,7 +1026,7 @@ React keys must be passed directly to JSX without using spread:
1021
1026
  outline: none;
1022
1027
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3);
1023
1028
  }
1024
- `;$.span`
1029
+ `;k.span`
1025
1030
  display: inline-block;
1026
1031
  width: 8px;
1027
1032
  height: 8px;
@@ -1039,13 +1044,13 @@ React keys must be passed directly to JSX without using spread:
1039
1044
  opacity: 0.3;
1040
1045
  }
1041
1046
  }
1042
- `;$(fn)`
1047
+ `;k(yn)`
1043
1048
  min-width: 200px;
1044
- `;$(gr)`
1049
+ `;k(Mr)`
1045
1050
  display: flex;
1046
1051
  flex-direction: column;
1047
1052
  gap: 0.25rem;
1048
- `;$.div`
1053
+ `;k.div`
1049
1054
  display: flex;
1050
1055
  align-items: center;
1051
1056
  gap: 0.75rem;
@@ -1053,7 +1058,7 @@ React keys must be passed directly to JSX without using spread:
1053
1058
  background: ${e=>e.$isRecording?"#fff3cd":"transparent"};
1054
1059
  border-radius: 0.25rem;
1055
1060
  transition: background 0.2s ease-in-out;
1056
- `;$.div`
1061
+ `;k.div`
1057
1062
  width: 12px;
1058
1063
  height: 12px;
1059
1064
  border-radius: 50%;
@@ -1073,18 +1078,18 @@ React keys must be passed directly to JSX without using spread:
1073
1078
  }
1074
1079
  }
1075
1080
  `}
1076
- `;$.span`
1081
+ `;k.span`
1077
1082
  font-family: 'Courier New', Monaco, monospace;
1078
1083
  font-size: 1rem;
1079
1084
  font-weight: 600;
1080
1085
  color: #495057;
1081
1086
  min-width: 70px;
1082
- `;$.span`
1087
+ `;k.span`
1083
1088
  font-size: 0.75rem;
1084
1089
  font-weight: 500;
1085
1090
  color: ${e=>e.$isPaused?"#ffc107":"#dc3545"};
1086
1091
  text-transform: uppercase;
1087
- `;var Bs=$.div`
1092
+ `;var ai=k.div`
1088
1093
  position: relative;
1089
1094
  width: ${e=>e.$width}px;
1090
1095
  height: ${e=>e.$height}px;
@@ -1092,39 +1097,39 @@ React keys must be passed directly to JSX without using spread:
1092
1097
  border-radius: 4px;
1093
1098
  overflow: hidden;
1094
1099
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
1095
- `,_s=e=>e<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":e<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",Ws=$.div.attrs(e=>({style:{width:`${e.$level*100}%`,height:`${e.$height}px`,background:_s(e.$level),boxShadow:e.$level>.01?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}}))`
1100
+ `,oi=e=>e<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":e<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",si=k.div.attrs(e=>({style:{width:`${e.$level*100}%`,height:`${e.$height}px`,background:oi(e.$level),boxShadow:e.$level>.01?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}}))`
1096
1101
  position: absolute;
1097
1102
  left: 0;
1098
1103
  top: 0;
1099
1104
  transition: width 0.05s ease-out, background 0.1s ease-out;
1100
- `,Fs=$.div.attrs(e=>({style:{left:`${e.$peakLevel*100}%`,height:`${e.$height}px`}}))`
1105
+ `,ii=k.div.attrs(e=>({style:{left:`${e.$peakLevel*100}%`,height:`${e.$height}px`}}))`
1101
1106
  position: absolute;
1102
1107
  top: 0;
1103
1108
  width: 2px;
1104
1109
  background: #ecf0f1;
1105
1110
  box-shadow: 0 0 4px rgba(236, 240, 241, 0.8);
1106
1111
  transition: left 0.1s ease-out;
1107
- `,Zs=$.div`
1112
+ `,li=k.div`
1108
1113
  position: absolute;
1109
1114
  top: 0;
1110
1115
  left: 0;
1111
1116
  width: 100%;
1112
1117
  height: ${e=>e.$height}px;
1113
1118
  pointer-events: none;
1114
- `,er=$.div`
1119
+ `,wr=k.div`
1115
1120
  position: absolute;
1116
1121
  left: ${e=>e.$position}%;
1117
1122
  top: 0;
1118
1123
  width: 1px;
1119
1124
  height: ${e=>e.$height}px;
1120
1125
  background: rgba(255, 255, 255, 0.2);
1121
- `,Ps=({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 w.jsxs(Bs,{$width:n,$height:r,className:a,children:[w.jsx(Ws,{$level:s,$height:r}),t!==void 0&&o>0&&w.jsx(Fs,{$peakLevel:o,$height:r}),w.jsxs(Zs,{$height:r,children:[w.jsx(er,{$position:60,$height:r}),w.jsx(er,{$position:85,$height:r})]})]})};u.memo(Ps);function Vs(e,t,n,r={}){const{currentTime:a=0,audioConstraints:s,...o}=r,[l,i]=u.useState(!1),[d,f]=u.useState(null),{stream:b,devices:p,hasPermission:h,requestAccess:x,error:I}=Ts(),{level:v,peakLevel:m}=Ms(b),{isRecording:C,isPaused:y,duration:g,peaks:k,startRecording:A,stopRecording:E,pauseRecording:_,resumeRecording:B,error:M}=Es(b,o),D=u.useCallback(async()=>{n&&(l||(await Ht(),i(!0)),await A())},[n,l,A]),Z=u.useCallback(async()=>{const N=await E();if(N&&n){const G=e.findIndex(q=>q.id===n);if(G===-1)return;const K=e[G],Q=Math.floor(a*N.sampleRate);let H=0;if(K.clips.length>0){const q=K.clips.map(re=>re.startSample+re.durationSamples);H=Math.max(...q)}const ee=Math.max(Q,H),ie={id:`clip-${Date.now()}`,audioBuffer:N,startSample:ee,durationSamples:N.length,offsetSamples:0,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},ce=e.map((q,re)=>re===G?{...q,clips:[...q.clips,ie]}:q);t(ce)}},[n,e,t,a,E]);u.useEffect(()=>{h&&p.length>0&&d===null&&f(p[0].deviceId)},[h,p.length]);const W=u.useCallback(async()=>{await x(void 0,s),await Ht(),i(!0)},[x,s]),O=u.useCallback(async N=>{f(N),await x(N,s),await Ht(),i(!0)},[x,s]);return{isRecording:C,isPaused:y,duration:g,level:v,peakLevel:m,error:I||M,stream:b,devices:p,hasPermission:h,selectedDevice:d,startRecording:D,stopRecording:Z,pauseRecording:_,resumeRecording:B,requestMicAccess:W,changeDevice:O,recordingPeaks:k}}const pt=[{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}]}],pn=e=>pt.find(t=>t.id===e),js=e=>pt.filter(t=>t.category===e),zs=[{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"}],Os={reverb:F.Reverb,freeverb:F.Freeverb,jcReverb:F.JCReverb,feedbackDelay:F.FeedbackDelay,pingPongDelay:F.PingPongDelay,chorus:F.Chorus,phaser:F.Phaser,tremolo:F.Tremolo,vibrato:F.Vibrato,autoPanner:F.AutoPanner,autoFilter:F.AutoFilter,autoWah:F.AutoWah,eq3:F.EQ3,distortion:F.Distortion,bitCrusher:F.BitCrusher,chebyshev:F.Chebyshev,compressor:F.Compressor,limiter:F.Limiter,gate:F.Gate,stereoWidener:F.StereoWidener};let Ns=0;const Hs=()=>`effect_${Date.now()}_${++Ns}`;function mt(e,t){const n=Os[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(o=>{const l=t?.[o.name]??o.default;r[o.name]=l});const a=new n(r),s=Hs();return{effect:a,id:e.id,instanceId:s,dispose(){try{a.disconnect(),a.dispose()}catch{}},setParameter(o,l){o==="wet"&&a.wet?a.wet.value=l:a[o]!==void 0&&(a[o]?.value!==void 0?a[o].value=l:a[o]=l)},getParameter(o){if(o==="wet"&&a.wet)return a.wet.value;if(a[o]!==void 0)return a[o]?.value!==void 0?a[o].value:a[o]},connect(o){a.connect(o)},disconnect(){try{a.disconnect()}catch{}}}}function Gs(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 Xs(e=256){const[t,n]=u.useState([]),r=u.useRef(t);r.current=t;const a=u.useRef(new Map),s=u.useRef(null),o=u.useRef(null),l=u.useCallback(v=>{const m=o.current;if(!m)return;const{masterGainNode:C,destination:y,analyserNode:g}=m;try{C.disconnect()}catch{}const k=v.map(A=>a.current.get(A.instanceId)).filter(A=>A!==void 0);if(k.length===0)C.connect(g),g.connect(y);else{let A=C;k.forEach(E=>{try{E.disconnect()}catch{}A.connect(E.effect),A=E.effect}),A.connect(g),g.connect(y)}},[]),i=u.useCallback(v=>{const m=pn(v);if(!m){console.error(`Unknown effect: ${v}`);return}const C={};m.parameters.forEach(k=>{C[k.name]=k.default});const y=mt(m,C);a.current.set(y.instanceId,y);const g={instanceId:y.instanceId,effectId:m.id,definition:m,params:C,bypassed:!1};n(k=>[...k,g])},[]),d=u.useCallback(v=>{const m=a.current.get(v);m&&(m.dispose(),a.current.delete(v)),n(C=>C.filter(y=>y.instanceId!==v))},[]),f=u.useCallback((v,m,C)=>{const y=a.current.get(v);y&&y.setParameter(m,C),n(g=>g.map(k=>k.instanceId===v?{...k,params:{...k.params,[m]:C}}:k))},[]),b=u.useCallback(v=>{const m=r.current.find(g=>g.instanceId===v);if(!m)return;const C=!m.bypassed,y=a.current.get(v);if(y){const g=m.params.wet??1;y.setParameter("wet",C?0:g)}n(g=>g.map(k=>k.instanceId===v?{...k,bypassed:C}:k))},[]),p=u.useCallback((v,m)=>{n(C=>{const y=[...C],[g]=y.splice(v,1);return y.splice(m,0,g),y})},[]),h=u.useCallback(()=>{a.current.forEach(v=>v.dispose()),a.current.clear(),n([])},[]);u.useEffect(()=>{l(t)},[t,l]);const x=u.useCallback((v,m,C)=>{const y=new F.Analyser("fft",e);s.current=y,o.current={masterGainNode:v,destination:m,analyserNode:y};const k=r.current.map(A=>a.current.get(A.instanceId)).filter(A=>A!==void 0);if(k.length===0)v.connect(y),y.connect(m);else{let A=v;k.forEach(E=>{A.connect(E.effect),A=E.effect}),A.connect(y),y.connect(m)}return function(){y.dispose(),s.current=null,o.current=null}},[e]);u.useEffect(()=>()=>{a.current.forEach(v=>v.dispose()),a.current.clear()},[]);const I=u.useCallback(()=>{const v=t.filter(m=>!m.bypassed);if(v.length!==0)return(m,C,y)=>{const g=[];for(const k of v){const A=mt(k.definition,k.params);g.push(A)}if(g.length===0)m.connect(C);else{let k=m;g.forEach(A=>{k.connect(A.effect),k=A.effect}),k.connect(C)}return function(){g.forEach(A=>A.dispose())}}},[t]);return{activeEffects:t,availableEffects:pt,addEffect:i,removeEffect:d,updateParameter:f,toggleBypass:b,reorderEffects:p,clearAllEffects:h,masterEffects:x,createOfflineEffectsFunction:I,analyserRef:s}}function Ys(){const[e,t]=u.useState(new Map),n=u.useRef(new Map),r=u.useRef(new Map),a=u.useCallback((h,x)=>{const I=r.current.get(h);if(!I)return;const{graphEnd:v,masterGainNode:m}=I,C=n.current.get(h);try{v.disconnect()}catch{}const y=x.map(g=>C?.get(g.instanceId)).filter(g=>g!==void 0);if(y.length===0)v.connect(m);else{let g=v;y.forEach(k=>{try{k.disconnect()}catch{}g.connect(k.effect),g=k.effect}),g.connect(m)}},[]),s=u.useCallback((h,x)=>{const I=pn(x);if(!I){console.error(`Unknown effect: ${x}`);return}const v={};I.parameters.forEach(y=>{v[y.name]=y.default});const m=mt(I,v);n.current.has(h)||n.current.set(h,new Map),n.current.get(h).set(m.instanceId,m);const C={instanceId:m.instanceId,effectId:I.id,definition:I,params:v,bypassed:!1};t(y=>{const g=new Map(y),k=g.get(h)||[];return g.set(h,[...k,C]),g})},[]),o=u.useCallback((h,x)=>{const I=n.current.get(h),v=I?.get(x);v&&(v.dispose(),I?.delete(x)),t(m=>{const C=new Map(m),y=C.get(h)||[];return C.set(h,y.filter(g=>g.instanceId!==x)),C})},[]),l=u.useCallback((h,x,I,v)=>{const C=n.current.get(h)?.get(x);C&&C.setParameter(I,v),t(y=>{const g=new Map(y),k=g.get(h)||[];return g.set(h,k.map(A=>A.instanceId===x?{...A,params:{...A.params,[I]:v}}:A)),g})},[]),i=u.useCallback((h,x)=>{const v=(f.current.get(h)||[]).find(g=>g.instanceId===x);if(!v)return;const m=!v.bypassed,y=n.current.get(h)?.get(x);if(y){const g=v.params.wet??1;y.setParameter("wet",m?0:g)}t(g=>{const k=new Map(g),A=k.get(h)||[];return k.set(h,A.map(E=>E.instanceId===x?{...E,bypassed:m}:E)),k})},[]),d=u.useCallback(h=>{const x=n.current.get(h);x&&(x.forEach(I=>I.dispose()),x.clear()),t(I=>{const v=new Map(I);return v.set(h,[]),v})},[]),f=u.useRef(e);f.current=e;const b=u.useCallback(h=>(x,I,v)=>{r.current.set(h,{graphEnd:x,masterGainNode:I});const m=f.current.get(h)||[],C=n.current.get(h),y=m.map(g=>C?.get(g.instanceId)).filter(g=>g!==void 0);if(y.length===0)x.connect(I);else{let g=x;y.forEach(k=>{g.connect(k.effect),g=k.effect}),g.connect(I)}return function(){r.current.delete(h)}},[]);u.useEffect(()=>{e.forEach((h,x)=>{a(x,h)})},[e,a]),u.useEffect(()=>()=>{n.current.forEach(h=>{h.forEach(x=>x.dispose()),h.clear()}),n.current.clear()},[]);const p=u.useCallback(h=>{const I=(e.get(h)||[]).filter(v=>!v.bypassed);if(I.length!==0)return(v,m,C)=>{const y=[];for(const g of I){const k=mt(g.definition,g.params);y.push(k)}if(y.length===0)v.connect(m);else{let g=v;y.forEach(k=>{g.connect(k.effect),g=k.effect}),g.connect(m)}return function(){y.forEach(k=>k.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:l,toggleBypass:i,clearTrackEffects:d,getTrackEffectsFunction:b,createOfflineTrackEffectsFunction:p,availableEffects:pt}}function Ls(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,a=e.sampleRate,s=e.length,o=n/8,l=r*o,i=a*l,d=s*l,f=44,b=f+d,p=new ArrayBuffer(b),h=new DataView(p);St(h,0,"RIFF"),h.setUint32(4,b-8,!0),St(h,8,"WAVE"),St(h,12,"fmt "),h.setUint32(16,16,!0),h.setUint16(20,n===32?3:1,!0),h.setUint16(22,r,!0),h.setUint32(24,a,!0),h.setUint32(28,i,!0),h.setUint16(32,l,!0),h.setUint16(34,n,!0),St(h,36,"data"),h.setUint32(40,d,!0);const x=[];for(let v=0;v<r;v++)x.push(e.getChannelData(v));let I=f;if(n===16)for(let v=0;v<s;v++)for(let m=0;m<r;m++){const C=x[m][v],y=Math.max(-1,Math.min(1,C)),g=y<0?y*32768:y*32767;h.setInt16(I,g,!0),I+=2}else for(let v=0;v<s;v++)for(let m=0;m<r;m++)h.setFloat32(I,x[m][v],!0),I+=4;return new Blob([p],{type:"audio/wav"})}function St(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function Ks(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 Mr(){const[e,t]=u.useState(!1),[n,r]=u.useState(0),[a,s]=u.useState(null);return{exportWav:u.useCallback(async(l,i,d={})=>{const{filename:f="export",mode:b="master",trackIndex:p,autoDownload:h=!0,applyEffects:x=!0,effectsFunction:I,createOfflineTrackEffects:v,bitDepth:m=16,onProgress:C}=d;t(!0),r(0),s(null);try{if(l.length===0)throw new Error("No tracks to export");if(b==="individual"&&(p===void 0||p<0||p>=l.length))throw new Error("Invalid track index for individual export");const y=l[0].clips[0]?.audioBuffer.sampleRate||44100;let g=0;for(const D of l)for(const Z of D.clips){const W=Z.startSample+Z.durationSamples;g=Math.max(g,W)}g+=Math.round(y*.1);const k=g/y,A=b==="individual"?[{track:l[p],state:i[p],index:p}]:l.map((D,Z)=>({track:D,state:i[Z],index:Z})),E=i.some(D=>D.soloed),_=!!v;let B;if((I||_)&&x)B=await Us(A,i,E,k,y,I,v,D=>{r(D),C?.(D)});else{const D=new OfflineAudioContext(2,g,y);let Z=0;const W=A.reduce((O,{track:N})=>O+N.clips.length,0);for(const{track:O,state:N}of A)if(!(N.muted&&!N.soloed)&&!(E&&!N.soloed))for(const G of O.clips){await qs(D,G,N,y,x),Z++;const K=Z/W*.5;r(K),C?.(K)}r(.5),C?.(.5),B=await D.startRendering()}r(.9),C?.(.9);const M=Ls(B,{bitDepth:m});if(r(1),C?.(1),h){const D=b==="individual"?`${f}_${l[p].name}`:f;Ks(M,`${D}.wav`)}return{audioBuffer:B,blob:M,duration:k}}catch(y){const g=y instanceof Error?y.message:"Export failed";throw s(g),y}finally{t(!1)}},[]),isExporting:e,progress:n,error:a}}async function Us(e,t,n,r,a,s,o,l){const{Offline:i,Volume:d,Gain:f,Panner:b,Player:p,ToneAudioBuffer:h}=await import("tone");l(.1);let x;try{x=await i(async({transport:I,destination:v})=>{const m=new d(0);let C;s?C=s(m,v,!0):m.connect(v);for(const{track:y,state:g}of e){if(g.muted&&!g.soloed||n&&!g.soloed)continue;const k=new d(Js(g.volume)),A=new b(g.pan),E=new f(g.muted?0:1),_=o?.(y.id);_?_(E,m,!0):E.connect(m),A.connect(E),k.connect(A);for(const B of y.clips){const{audioBuffer:M,startSample:D,durationSamples:Z,offsetSamples:W,gain:O,fadeIn:N,fadeOut:G}=B,K=D/a,Q=Z/a,H=W/a,ee=new h(M),ie=new p(ee),ce=new f(O);if(ie.connect(ce),ce.connect(k),N){const q=K,re=K+N.duration,te=ce.gain._param;te.setValueAtTime(0,q),te.linearRampToValueAtTime(O,re)}if(G){const q=K+Q-G.duration,re=K+Q,te=ce.gain._param;te.setValueAtTime(O,q),te.linearRampToValueAtTime(0,re)}ie.start(K,H,Q)}}I.start(0)},r,2,a)}catch(I){throw I instanceof Error?I:new Error(`Tone.Offline rendering failed: ${String(I)}`)}return l(.9),x.get()}function Js(e){return 20*Math.log10(Math.max(e,1e-4))}async function qs(e,t,n,r,a){const{audioBuffer:s,startSample:o,durationSamples:l,offsetSamples:i,gain:d,fadeIn:f,fadeOut:b}=t,p=o/r,h=l/r,x=i/r,I=e.createBufferSource();I.buffer=s;const v=e.createGain(),m=d*n.volume,C=e.createStereoPanner();if(C.pan.value=n.pan,I.connect(v),v.connect(C),C.connect(e.destination),a){if(f?v.gain.setValueAtTime(0,p):v.gain.setValueAtTime(m,p),f){const y=p,g=p+f.duration;tr(v.gain,y,g,0,m,f.type||"linear")}if(b){const y=p+h-b.duration,g=p+h;(!f||f.duration<h-b.duration)&&v.gain.setValueAtTime(m,y),tr(v.gain,y,g,m,0,b.type||"linear")}}else v.gain.setValueAtTime(m,p);I.start(p,x,h)}function tr(e,t,n,r,a,s){const o=n-t;if(!(o<=0))switch(s){case"linear":e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n);break;case"exponential":const l=Math.max(r,1e-4),i=Math.max(a,1e-4);e.setValueAtTime(l,t),e.exponentialRampToValueAtTime(i,n),a===0&&e.setValueAtTime(0,n);break;case"logarithmic":const d=nr(r,a,256,"logarithmic");e.setValueCurveAtTime(d,t,o);break;case"sCurve":const f=nr(r,a,256,"sCurve");e.setValueCurveAtTime(f,t,o);break;default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n)}}function nr(e,t,n,r){const a=new Float32Array(n),s=t-e;for(let o=0;o<n;o++){const l=o/(n-1);let i;r==="logarithmic"?s>0?i=Math.log10(1+l*9)/Math.log10(10):i=1-Math.log10(1+(1-l)*9)/Math.log10(10):i=l*l*(3-2*l),a[o]=e+s*i}return a}const Br=u.createContext(null),_r=u.createContext(null),Wr=u.createContext(null),Fr=u.createContext(null),Zr=u.createContext(null),Qs=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:a=1024,zoomLevels:s,automaticScroll:o=!1,theme:l,controls:i={show:!1,width:0},annotationList:d,effects:f,onReady:b,onAnnotationUpdate:p,barWidth:h=1,barGap:x=0,progressBarWidth:I,children:v})=>{const m=I??h+x,[C,y]=u.useState([]),[g,k]=u.useState(null),[A,E]=u.useState(!1),[_,B]=u.useState(0),[M,D]=u.useState(0),[Z,W]=u.useState([]),[O,N]=u.useState([]),[G,K]=u.useState([]),[Q,H]=u.useState(0),[ee,ie]=u.useState(0),[ce,q]=u.useState(null),[re,te]=u.useState(o),[fe,Ne]=u.useState(d?.isContinuousPlay??!1),[Ze,ae]=u.useState(d?.linkEndpoints??!0),[Me,at]=u.useState(d?.editable??!1),V=u.useRef(null),Se=u.useRef(0),pe=u.useRef(0),he=u.useRef(null),_e=u.useRef(G),we=u.useRef(0),Ie=u.useRef(0),Re=u.useRef(null),Ee=u.useRef(null),Je=u.useRef(!1),He=u.useRef(d?.isContinuousPlay??!1),Pe=u.useRef(null),qe=u.useRef(a),{timeFormat:Y,setTimeFormat:U,formatTime:ue}=Rr(),ge=Dr({initialSamplesPerPixel:a,zoomLevels:s}),me=ge.samplesPerPixel,{masterVolume:ke,setMasterVolume:oe}=Er({playoutRef:V,initialVolume:1}),Be=u.useCallback(j=>{He.current=j,Ne(j)},[]),xe=u.useCallback(j=>{Pe.current=j,k(j)},[]);u.useEffect(()=>{Je.current=re},[re]),u.useEffect(()=>{_e.current=G},[G]),u.useEffect(()=>{if(!Ee.current||!Z.length)return;const j=Ee.current,c=qe.current,S=me;if(c===S)return;const R=i.show?i.width:0,T=j.clientWidth,J=j.scrollLeft+T/2-R,P=Z[0].sampleRate,le=J*c/P*P/S,se=Math.max(0,le+R-T/2);j.scrollLeft=se,qe.current=S},[me,Z,i]);const De=u.useRef(null);u.useEffect(()=>{if(e.length===0){W([]),D(0),K([]),N([]),V.current&&(V.current.dispose(),V.current=null);return}const j=A,c=pe.current;return V.current&&j&&(V.current.stop(),he.current&&(cancelAnimationFrame(he.current),he.current=null),De.current={position:c}),(async()=>{try{const R=[];e.forEach(P=>{P.clips.length>0&&R.push(P.clips[0].audioBuffer)});let T=0;e.forEach(P=>{P.clips.forEach(z=>{const le=z.audioBuffer.sampleRate,de=(z.startSample+z.durationSamples)/le;T=Math.max(T,de)})}),W(R),D(T),K(P=>P.length===e.length?P.map((z,le)=>({...z,name:e[le].name})):e.map(z=>({name:z.name,muted:z.muted,soloed:z.soloed,volume:z.volume,pan:z.pan}))),V.current&&V.current.dispose();const L=new na({effects:f}),J=_e.current;e.forEach((P,z)=>{if(P.clips.length>0){const le=P.clips[0].audioBuffer.sampleRate,se=Math.min(...P.clips.map(ne=>ne.startSample/le)),de=Math.max(...P.clips.map(ne=>(ne.startSample+ne.durationSamples)/le)),Ce=J[z],Xe={id:`track-${z}`,name:P.name,gain:Ce?.volume??P.volume,muted:Ce?.muted??P.muted,soloed:Ce?.soloed??P.soloed,stereoPan:Ce?.pan??P.pan,startTime:se,endTime:de},je=P.clips.map(ne=>{const Ke=ne.audioBuffer.sampleRate;return{buffer:ne.audioBuffer,startTime:ne.startSample/Ke-se,duration:ne.durationSamples/Ke,offset:ne.offsetSamples/Ke,fadeIn:ne.fadeIn,fadeOut:ne.fadeOut,gain:ne.gain}});L.addTrack({clips:je,track:Xe,effects:P.effects})}}),L.applyInitialSoloState(),V.current=L,b?.()}catch(R){console.error("Error loading audio:",R)}})(),()=>{he.current&&cancelAnimationFrame(he.current),V.current&&V.current.dispose()}},[e,b,A]),u.useEffect(()=>{if(e.length===0)return;const j=16,c=e.map(S=>S.clips.map(T=>{const L=T.audioBuffer.sampleRate,J=_o(T.audioBuffer,me,n,j,T.offsetSamples/L,T.durationSamples/L);return{clipId:T.id,trackName:S.name,peaks:J,startSample:T.startSample,durationSamples:T.durationSamples,fadeIn:T.fadeIn,fadeOut:T.fadeOut}}));N(c)},[e,me,n]),u.useEffect(()=>{if(d?.annotations){const j=d.annotations.map(c=>typeof c.start=="number"?c:Oo(c));y(j)}},[d]);const ye=u.useCallback(()=>{he.current&&(cancelAnimationFrame(he.current),he.current=null);const j=()=>{const c=F.getContext().currentTime-we.current,S=Ie.current+c;if(pe.current=S,B(S),C.length>0){const R=C.find(T=>S>=T.start&&S<T.end);if(He.current){if(R&&R.id!==Pe.current)xe(R.id);else if(!R&&Pe.current!==null){const T=C[C.length-1];if(S>=T.end){V.current&&V.current.stop(),E(!1),pe.current=Se.current,B(Se.current),xe(null);return}}}else if(Pe.current){const T=C.find(L=>L.id===Pe.current);if(T&&S>=T.end){V.current&&V.current.stop(),E(!1),pe.current=Se.current,B(Se.current);return}}else R&&xe(R.id)}if(Je.current&&Ee.current&&Z.length>0){const R=Ee.current,T=Z[0].sampleRate,L=S*T/qe.current,J=R.clientWidth,P=i.show?i.width:0,z=L+P,le=Math.max(0,z-J/2);R.scrollLeft=le}if(Re.current!==null&&S>=Re.current){V.current&&V.current.stop(),E(!1),pe.current=Re.current,B(Re.current),Re.current=null;return}if(S>=M){V.current&&V.current.stop(),E(!1),pe.current=Se.current,B(Se.current),xe(null);return}he.current=requestAnimationFrame(j)};he.current=requestAnimationFrame(j)},[M,Z,me,C,fe]),ve=u.useCallback(()=>{he.current&&(cancelAnimationFrame(he.current),he.current=null)},[]);u.useEffect(()=>{(async()=>{if(A&&he.current&&V.current)if(fe){const c=pe.current;V.current.stop(),ve(),await V.current.init(),V.current.setOnPlaybackComplete(()=>{});const R=F.getContext().currentTime;we.current=R,Ie.current=c,V.current.play(R,c),ye()}else ve(),ye()})()},[fe,A,ye,ve]),u.useEffect(()=>{(async()=>{if(De.current&&V.current){const{position:c}=De.current;De.current=null,await V.current.init(),V.current.setOnPlaybackComplete(()=>{});const R=F.getContext().currentTime;we.current=R,Ie.current=c,V.current.play(R,c),E(!0),ye()}})()},[e,ye]);const Ve=u.useCallback(async(j,c)=>{if(!V.current||Z.length===0)return;await V.current.init(),await F.start();const S=j??pe.current;Se.current=S,pe.current=S,V.current.setOnPlaybackComplete(()=>{}),V.current.stop(),ve();const T=F.getContext().currentTime;we.current=T,Ie.current=S,Re.current=c!==void 0?S+c:null,V.current.play(T,S,c),E(!0),ye()},[Z.length,ye,ve]),Le=u.useCallback(()=>{if(!V.current)return;const j=F.getContext().currentTime-we.current,c=Ie.current+j;V.current.pause(),E(!1),ve(),pe.current=c,B(c)},[ve]),gt=u.useCallback(()=>{V.current&&(V.current.stop(),E(!1),ve(),pe.current=Se.current,B(Se.current),xe(null))},[ve]),Ge=u.useCallback(j=>{const c=Math.max(0,Math.min(j,M));pe.current=c,B(c),A&&V.current&&(V.current.stop(),ve(),Ve(c))},[M,A,Ve,ve]),ot=u.useCallback((j,c)=>{const S=[...G];if(S[j]={...S[j],muted:c},K(S),V.current){const R=`track-${j}`;V.current.setMute(R,c)}},[G]),st=u.useCallback((j,c)=>{const S=[...G];if(S[j]={...S[j],soloed:c},K(S),V.current){const R=`track-${j}`;V.current.setSolo(R,c)}},[G]),bt=u.useCallback((j,c)=>{const S=[...G];if(S[j]={...S[j],volume:c},K(S),V.current){const R=`track-${j}`,T=V.current.getTrack(R);T&&T.setVolume(c)}},[G]),Pt=u.useCallback((j,c)=>{const S=[...G];if(S[j]={...S[j],pan:c},K(S),V.current){const R=`track-${j}`,T=V.current.getTrack(R);T&&T.setPan(c)}},[G]),vt=u.useCallback((j,c)=>{H(j),ie(c),pe.current=j,B(j),A&&V.current&&(V.current.stop(),V.current.play(F.getContext().currentTime,j))},[A]),Vt=u.useCallback(j=>{Ee.current=j},[]),Ct=Z[0]?.sampleRate||44100,it=t?30:0,jt=e.length*r+it,xt={isPlaying:A,currentTime:_,currentTimeRef:pe,playbackStartTimeRef:we,audioStartPositionRef:Ie},lt={continuousPlay:fe,linkEndpoints:Ze,annotationsEditable:Me,isAutomaticScroll:re,annotations:C,activeAnnotationId:g,selectionStart:Q,selectionEnd:ee,selectedTrackId:ce},ct={play:Ve,pause:Le,stop:gt,seekTo:Ge,setCurrentTime:j=>{pe.current=j,B(j)},setTrackMute:ot,setTrackSolo:st,setTrackVolume:bt,setTrackPan:Pt,setSelection:vt,setSelectedTrackId:q,setTimeFormat:U,formatTime:ue,zoomIn:ge.zoomIn,zoomOut:ge.zoomOut,setMasterVolume:oe,setAutomaticScroll:j=>{te(j)},setScrollContainer:Vt,scrollContainerRef:Ee,setContinuousPlay:Be,setLinkEndpoints:ae,setAnnotationsEditable:at,setAnnotations:y,setActiveAnnotationId:xe},yt={duration:M,audioBuffers:Z,peaksDataArray:O,trackStates:G,tracks:e,sampleRate:Ct,waveHeight:r,timeScaleHeight:it,minimumPlaylistHeight:jt,controls:i,playoutRef:V,samplesPerPixel:me,timeFormat:Y,masterVolume:ke,canZoomIn:ge.canZoomIn,canZoomOut:ge.canZoomOut,barWidth:h,barGap:x,progressBarWidth:m},zt={...xt,...lt,...ct,...yt},Ot={...Da,...l};return w.jsx($.ThemeProvider,{theme:Ot,children:w.jsx(Br.Provider,{value:xt,children:w.jsx(_r.Provider,{value:lt,children:w.jsx(Wr.Provider,{value:ct,children:w.jsx(Fr.Provider,{value:yt,children:w.jsx(Zr.Provider,{value:zt,children:v})})})})})})},$e=()=>{const e=u.useContext(Br);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Fe=()=>{const e=u.useContext(_r);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},be=()=>{const e=u.useContext(Wr);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},Ae=()=>{const e=u.useContext(Fr);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e},ei=()=>{const e=u.useContext(Zr);if(!e)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return e},ti=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=$e(),{selectionStart:r,selectionEnd:a}=Fe(),{play:s}=be(),o=async()=>{if(r!==a&&a>r){const l=a-r;await s(r,l)}else await s(n.current??0)};return w.jsx(We,{onClick:o,disabled:t,className:e,children:"Play"})},ni=({className:e})=>{const{isPlaying:t}=$e(),{pause:n}=be();return w.jsx(We,{onClick:n,disabled:!t,className:e,children:"Pause"})},ri=({className:e})=>{const{isPlaying:t}=$e(),{stop:n}=be();return w.jsx(We,{onClick:n,disabled:!t,className:e,children:"Stop"})},ai=({className:e})=>{const{isPlaying:t}=$e(),{play:n,setCurrentTime:r}=be(),{playoutRef:a}=Ae(),s=()=>{r(0),t&&a.current&&(a.current.stop(),n(0))};return w.jsx(We,{onClick:s,className:e,children:"Rewind"})},oi=({className:e})=>{const{isPlaying:t}=$e(),{play:n,setCurrentTime:r}=be(),{duration:a,playoutRef:s}=Ae(),o=()=>{r(a),t&&s.current&&(s.current.stop(),n(a))};return w.jsx(We,{onClick:o,className:e,children:"Fast Forward"})},si=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=$e(),{play:a,setCurrentTime:s}=be(),{playoutRef:o}=Ae(),l=()=>{const i=Math.max(0,(n.current??0)-e);s(i),r&&o.current&&(o.current.stop(),a(i))};return w.jsx(We,{onClick:l,className:t,children:"Skip Backward"})},ii=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=$e(),{play:a,setCurrentTime:s}=be(),{duration:o,playoutRef:l}=Ae(),i=()=>{const d=Math.min(o,(n.current??0)+e);s(d),r&&l.current&&(l.current.stop(),a(d))};return w.jsx(We,{onClick:i,className:t,children:"Skip Forward"})},li=({className:e,disabled:t})=>{const{zoomIn:n}=be(),{canZoomIn:r}=Ae();return w.jsx(We,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},ci=({className:e,disabled:t})=>{const{zoomOut:n}=be(),{canZoomOut:r}=Ae();return w.jsx(We,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},ui=({className:e})=>{const{masterVolume:t}=Ae(),{setMasterVolume:n}=be();return w.jsx(La,{volume:t,onChange:n,className:e})},di=({className:e})=>{const{timeFormat:t}=Ae(),{setTimeFormat:n}=be();return w.jsx(yo,{value:t,onChange:n,className:e})},fi=$.span`
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`
1122
1127
  font-family: 'Courier New', Monaco, monospace;
1123
1128
  font-size: 1rem;
1124
1129
  font-weight: 600;
1125
1130
  color: ${e=>e.theme?.textColor||"#333"};
1126
1131
  user-select: none;
1127
- `,hi=({className:e})=>{const t=u.useRef(null),n=u.useRef(null),{isPlaying:r,currentTimeRef:a,playbackStartTimeRef:s,audioStartPositionRef:o}=$e(),{timeFormat:l}=Ae(),i=l;return u.useEffect(()=>{const d=()=>{if(t.current){let f;if(r){const b=F.getContext().currentTime-(s.current??0);f=(o.current??0)+b}else f=a.current??0;t.current.textContent=nt(f,i)}r&&(n.current=requestAnimationFrame(d))};return r?n.current=requestAnimationFrame(d):d(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,i,a,s,o]),u.useEffect(()=>{!r&&t.current&&(t.current.textContent=nt(a.current??0,i))}),w.jsx(fi,{ref:t,className:e,"aria-label":"Audio position",children:nt(a.current??0,i)})},mi=({className:e})=>{const{selectionStart:t,selectionEnd:n}=Fe(),{setSelection:r}=be();return w.jsx(no,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},pi=({className:e})=>{const{isAutomaticScroll:t}=Fe(),{setAutomaticScroll:n}=be();return w.jsx(Ra,{checked:t,onChange:n,className:e})},gi=({className:e})=>{const{continuousPlay:t}=Fe(),{setContinuousPlay:n}=be();return w.jsx(cs,{checked:t,onChange:n,className:e})},bi=({className:e})=>{const{linkEndpoints:t}=Fe(),{setLinkEndpoints:n}=be();return w.jsx(us,{checked:t,onChange:n,className:e})},vi=({className:e})=>{const{annotationsEditable:t}=Fe(),{setAnnotationsEditable:n}=be();return w.jsx(ds,{checked:t,onChange:n,className:e})},Ci=({filename:e,className:t})=>{const{annotations:n}=Fe();return w.jsx(hs,{annotations:n,filename:e,className:t})},xi=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:a=16,applyEffects:s=!0,effectsFunction:o,createOfflineTrackEffects:l,className:i,onExportComplete:d,onExportError:f})=>{const{tracks:b,trackStates:p}=Ae(),{exportWav:h,isExporting:x,progress:I}=Mr(),v=async()=>{try{const C=await h(b,p,{filename:t,mode:n,trackIndex:r,bitDepth:a,applyEffects:s,effectsFunction:o,createOfflineTrackEffects:l,autoDownload:!0});d?.(C.blob)}catch(C){f?.(C instanceof Error?C:new Error("Export failed"))}},m=x?`Exporting ${Math.round(I*100)}%`:e;return w.jsx(We,{onClick:v,disabled:x||b.length===0,className:i,children:m})},yi=$.div`
1132
+ `,Vi=({className:e})=>{const t=c.useRef(null),n=c.useRef(null),{isPlaying:r,currentTimeRef:a,playbackStartTimeRef:s,audioStartPositionRef:o}=Te(),{timeFormat:i}=Re(),l=i;return c.useEffect(()=>{const u=()=>{if(t.current){let d;if(r){const b=V.getContext().currentTime-(s.current??0);d=(o.current??0)+b}else d=a.current??0;t.current.textContent=lt(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=lt(a.current??0,l))}),O.jsx(Zi,{ref:t,className:e,"aria-label":"Audio position",children:lt(a.current??0,l)})},ji=({className:e})=>{const{selectionStart:t,selectionEnd:n}=Ne(),{setSelection:r}=xe();return O.jsx(go,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},zi=({className:e})=>{const{isAutomaticScroll:t}=Ne(),{setAutomaticScroll:n}=xe();return O.jsx(za,{checked:t,onChange:n,className:e})},Oi=({className:e})=>{const{continuousPlay:t}=Ne(),{setContinuousPlay:n}=xe();return O.jsx(ys,{checked:t,onChange:n,className:e})},Ni=({className:e})=>{const{linkEndpoints:t}=Ne(),{setLinkEndpoints:n}=xe();return O.jsx(Is,{checked:t,onChange:n,className:e})},Hi=({className:e})=>{const{annotationsEditable:t}=Ne(),{setAnnotationsEditable:n}=xe();return O.jsx(As,{checked:t,onChange:n,className:e})},Gi=({filename:e,className:t})=>{const{annotations:n}=Ne();return O.jsx(ks,{annotations:n,filename:e,className:t})},Xi=({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:b,trackStates:p}=Re(),{exportWav:f,isExporting:x,progress:y}=Qr(),v=async()=>{try{const C=await f(b,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 O.jsx(Oe,{onClick:v,disabled:x||b.length===0,className:l,children:m})},Yi=k.div`
1128
1133
  position: absolute;
1129
1134
  top: 0;
1130
1135
  left: 0;
@@ -1134,9 +1139,9 @@ React keys must be passed directly to JSX without using spread:
1134
1139
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
1135
1140
  pointer-events: none;
1136
1141
  will-change: transform;
1137
- `,wi=({color:e="#ff0000",controlsOffset:t=0})=>{const n=u.useRef(null),r=u.useRef(null),{isPlaying:a,currentTimeRef:s,playbackStartTimeRef:o,audioStartPositionRef:l}=$e(),{samplesPerPixel:i,sampleRate:d,progressBarWidth:f}=Ae();return u.useEffect(()=>{const b=()=>{if(n.current){let p;if(a){const x=F.getContext().currentTime-(o.current??0);p=(l.current??0)+x}else p=s.current??0;const h=p*d/i+t;n.current.style.transform=`translate3d(${h}px, 0, 0)`}a&&(r.current=requestAnimationFrame(b))};return a?r.current=requestAnimationFrame(b):b(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[a,d,i,t,s,o,l]),u.useEffect(()=>{if(!a&&n.current){const p=(s.current??0)*d/i+t;n.current.style.transform=`translate3d(${p}px, 0, 0)`}}),w.jsx(yi,{ref:n,$color:e,$width:f,"data-playhead":!0})},Ii=$.div`
1142
+ `,Li=({color:e="#ff0000",controlsOffset:t=0})=>{const n=c.useRef(null),r=c.useRef(null),{isPlaying:a,currentTimeRef:s,playbackStartTimeRef:o,audioStartPositionRef:i}=Te(),{samplesPerPixel:l,sampleRate:u,progressBarWidth:d}=Re();return c.useEffect(()=>{const b=()=>{if(n.current){let p;if(a){const x=V.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(b))};return a?r.current=requestAnimationFrame(b):b(),()=>{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)`}}),O.jsx(Yi,{ref:n,$color:e,$width:d,"data-playhead":!0})},Ki=k.div`
1138
1143
  position: relative;
1139
- `,Ai=$.div`
1144
+ `,Ui=k.div`
1140
1145
  position: absolute;
1141
1146
  top: ${e=>e.$top}px;
1142
1147
  left: 0;
@@ -1148,7 +1153,7 @@ React keys must be passed directly to JSX without using spread:
1148
1153
  transform: translateZ(0);
1149
1154
  backface-visibility: hidden;
1150
1155
  will-change: transform;
1151
- `,Si=$.div`
1156
+ `,Ji=k.div`
1152
1157
  position: absolute;
1153
1158
  top: ${e=>e.$top}px;
1154
1159
  left: 0;
@@ -1157,9 +1162,9 @@ React keys must be passed directly to JSX without using spread:
1157
1162
  pointer-events: none;
1158
1163
  z-index: 1;
1159
1164
  will-change: width;
1160
- `,ki=$.div`
1165
+ `,qi=k.div`
1161
1166
  position: relative;
1162
1167
  z-index: 2;
1163
- `,rr=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=u.useRef(null),a=u.useRef(null),s=mn(),{waveHeight:o}=Ft(),{isPlaying:l,currentTimeRef:i,playbackStartTimeRef:d,audioStartPositionRef:f}=$e(),{samplesPerPixel:b,sampleRate:p}=Ae(),h=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";u.useEffect(()=>{const m=()=>{if(r.current){let C;if(l){const A=F.getContext().currentTime-(d.current??0);C=(f.current??0)+A}else C=i.current??0;const y=C*p,g=e+t;let k=0;if(y<=e)k=0;else if(y>=g)k=n.length;else{const A=y-e;k=Math.floor(A/b)}r.current.style.width=`${k}px`}l&&(a.current=requestAnimationFrame(m))};return l?a.current=requestAnimationFrame(m):m(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[l,p,b,e,t,n.length,i,d,f]),u.useEffect(()=>{if(!l&&r.current){const C=(i.current??0)*p,y=e+t;let g=0;if(C<=e)g=0;else if(C>=y)g=n.length;else{const k=C-e;g=Math.floor(k/b)}r.current.style.width=`${g}px`}});const x=s?.waveformDrawMode||"inverted";let I;x==="inverted"?I=n.isSelected&&s?s.selectedWaveFillColor:s?.waveFillColor||"white":I=n.isSelected&&s?s.selectedWaveOutlineColor:s?.waveOutlineColor||"grey";const v=Rt(I);return w.jsxs(Ii,{children:[w.jsx(Ai,{$color:v,$height:o,$top:n.index*o,$width:n.length}),w.jsx(Si,{ref:r,$color:h,$height:o,$top:n.index*o}),w.jsx(ki,{children:w.jsx(uo,{...n,transparentBackground:!0})})]})},$i=60,Ri=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:a,annotationTextHeight:s,className:o,showClipHeaders:l=!1,interactiveClips:i=!1,showFades:d=!1,touchOptimized:f=!1,recordingState:b})=>{const p=mn(),{isPlaying:h,currentTimeRef:x,playbackStartTimeRef:I,audioStartPositionRef:v}=$e(),{selectionStart:m,selectionEnd:C,annotations:y,activeAnnotationId:g,annotationsEditable:k,linkEndpoints:A,continuousPlay:E,selectedTrackId:_}=Fe(),{setAnnotations:B,setActiveAnnotationId:M,setTrackMute:D,setTrackSolo:Z,setTrackVolume:W,setTrackPan:O,setSelection:N,play:G,setScrollContainer:K,setSelectedTrackId:Q,setCurrentTime:H}=be(),{audioBuffers:ee,peaksDataArray:ie,trackStates:ce,tracks:q,duration:re,samplesPerPixel:te,sampleRate:fe,waveHeight:Ne,timeScaleHeight:Ze,controls:ae,playoutRef:Me,barWidth:at,barGap:V}=Ae(),[Se,pe]=u.useState(!1),he=u.useRef(null),_e=u.useCallback(Y=>{he.current=Y,K(Y)},[K]);let we=ee.length>0?re:$i;if(b?.isRecording){const U=(b.startSample+b.durationSamples)/fe;we=Math.max(we,U+10)}const Ie=Math.floor(we*fe/te),Re=async Y=>{console.log("Annotation clicked:",Y.id),M(Y.id);const U=E?void 0:Y.end-Y.start;await G(Y.start,U)},Ee=u.useCallback(Y=>{if(Y>=0&&Y<q.length){const U=q[Y];Q(U.id)}},[q,Q]),Je=Y=>{const U=Y.currentTarget.getBoundingClientRect(),ue=ae.show?ae.width:0,me=(Y.clientX-U.left-ue)*te/fe,oe=Y.clientY-U.top;let Be=0,xe=-1;for(let De=0;De<ie.length;De++){const ye=ie[De],Ve=(ye.length>0?Math.max(...ye.map(Le=>Le.peaks.data.length)):1)*Ne+(l?22:0);if(oe>=Be&&oe<Be+Ve){xe=De;break}Be+=Ve}xe!==-1&&Ee(xe),pe(!0),H(me),N(me,me)},He=Y=>{if(!Se)return;const U=Y.currentTarget.getBoundingClientRect(),ue=ae.show?ae.width:0,me=(Y.clientX-U.left-ue)*te/fe,ke=Math.min(m,me),oe=Math.max(m,me);N(ke,oe)},Pe=Y=>{if(!Se)return;pe(!1);const U=Y.currentTarget.getBoundingClientRect(),ue=ae.show?ae.width:0,me=(Y.clientX-U.left-ue)*te/fe,ke=Math.min(m,me),oe=Math.max(m,me);Math.abs(oe-ke)<.1?(H(ke),h&&Me.current?(Me.current.stop(),G(ke)):Me.current&&Me.current.stop()):N(ke,oe)};return q.some(Y=>Y.clips.length>0)&&(ee.length===0||ie.length===0)?w.jsx("div",{className:o,children:"Loading waveform..."}):w.jsx(ro,{children:w.jsxs(hn.Provider,{value:{samplesPerPixel:te,sampleRate:fe,zoomLevels:[te],waveHeight:Ne,timeScaleHeight:Ze,duration:we,controls:ae,barWidth:at,barGap:V},children:[w.jsx(wr,{theme:p,backgroundColor:Rt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Ie+(ae.show?ae.width:0),timescaleWidth:Ie,tracksWidth:Ie,controlsWidth:ae.show?ae.width:0,onTracksMouseDown:Je,onTracksMouseMove:He,onTracksMouseUp:Pe,scrollContainerRef:_e,timescale:Ze>0?w.jsx(vo,{duration:we*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:t}):void 0,children:w.jsxs(w.Fragment,{children:[ie.map((Y,U)=>{const ue=q[U];if(!ue)return null;const ge=ce[U]||{name:`Track ${U+1}`,muted:!1,soloed:!1,volume:1,pan:0},me=e?e(U):w.jsxs($o,{onClick:()=>Ee(U),children:[w.jsx(Ro,{style:{justifyContent:"center"},children:ge.name||`Track ${U+1}`}),w.jsxs(ko,{children:[w.jsx(Pn,{$variant:ge.muted?"danger":"outline",onClick:()=>D(U,!ge.muted),children:"Mute"}),w.jsx(Pn,{$variant:ge.soloed?"info":"outline",onClick:()=>Z(U,!ge.soloed),children:"Solo"})]}),w.jsxs(jn,{children:[w.jsx(Do,{}),w.jsx(Vn,{min:"0",max:"1",step:"0.01",value:ge.volume,onChange:oe=>W(U,parseFloat(oe.target.value))}),w.jsx(Eo,{})]}),w.jsxs(jn,{children:[w.jsx("span",{children:"L"}),w.jsx(Vn,{min:"-1",max:"1",step:"0.01",value:ge.pan,onChange:oe=>O(U,parseFloat(oe.target.value))}),w.jsx("span",{children:"R"})]})]}),ke=Y.length>0?Math.max(...Y.map(oe=>oe.peaks.data.length)):1;return w.jsx(kr.Provider,{value:me,children:w.jsxs(So,{numChannels:ke,backgroundColor:Rt(p.waveOutlineColor),offset:0,width:Ie,hasClipHeaders:l,trackId:ue.id,isSelected:ue.id===_,children:[Y.map((oe,Be)=>{const xe=oe.peaks,De=xe.length;return w.jsx(Fn,{clipId:oe.clipId,trackIndex:U,clipIndex:Be,trackName:oe.trackName,startSample:oe.startSample,durationSamples:oe.durationSamples,samplesPerPixel:te,showHeader:l,disableHeaderDrag:!i,isSelected:ue.id===_,trackId:ue.id,fadeIn:oe.fadeIn,fadeOut:oe.fadeOut,sampleRate:fe,showFades:d,touchOptimized:f,onMouseDown:ye=>{ye.target.closest('[role="button"][aria-roledescription="draggable"]')||Ee(U)},children:xe.data.map((ye,ve)=>w.jsx(rr,{index:ve,data:ye,bits:xe.bits,length:De,isSelected:ue.id===_,clipStartSample:oe.startSample,clipDurationSamples:oe.durationSamples},`${U}-${Be}-${ve}`))},`${U}-${Be}`)}),b?.isRecording&&b.trackId===ue.id&&b.peaks.length>0&&w.jsx(Fn,{clipId:"recording-preview",trackIndex:U,clipIndex:Y.length,trackName:"Recording...",startSample:b.startSample,durationSamples:b.durationSamples,samplesPerPixel:te,showHeader:l,disableHeaderDrag:!0,isSelected:ue.id===_,trackId:ue.id,children:w.jsx(rr,{index:0,data:b.peaks,bits:16,length:Math.floor(b.peaks.length/2),isSelected:ue.id===_,clipStartSample:b.startSample,clipDurationSamples:b.durationSamples},`${U}-recording-0`)},`${U}-recording`)]})},ue.id)}),y.length>0&&w.jsx(Jo,{height:30,width:Ie,children:y.map((Y,U)=>{const ue=Y.start*fe/te,ge=Y.end*fe/te;return w.jsx(Yo,{annotationId:Y.id,annotationIndex:U,startPosition:ue,endPosition:ge,label:Y.id,color:"#ff9800",isActive:Y.id===g,onClick:()=>Re(Y),editable:k},Y.id)})}),m!==C&&w.jsx(to,{startPosition:Math.min(m,C)*fe/te+(ae.show?ae.width:0),endPosition:Math.max(m,C)*fe/te+(ae.show?ae.width:0),color:p.selectionColor}),(h||m===C)&&(n?n({position:(x.current??0)*fe/te+(ae.show?ae.width:0),color:p.playheadColor,isPlaying:h,currentTimeRef:x,playbackStartTimeRef:I,audioStartPositionRef:v,samplesPerPixel:te,sampleRate:fe,controlsOffset:ae.show?ae.width:0,getAudioContextTime:()=>F.getContext().currentTime}):w.jsx(wi,{color:p.playheadColor,controlsOffset:ae.show?ae.width:0}))]})}),y.length>0&&w.jsx(ls,{annotations:y,activeAnnotationId:g??void 0,shouldScrollToActive:!0,editable:k,controls:k?r:void 0,annotationListConfig:{linkEndpoints:A,continuousPlay:E},height:s,onAnnotationUpdate:Y=>{B(Y)}})]})})};function Ue(e,t){this._waveformData=e,this._channelIndex=t}Ue.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};Ue.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};Ue.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};Ue.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};Ue.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};Ue.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 Di=127,Ei=-128,Ti=32767,Mi=-32768;function Bi(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function _i(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,a=e.length,s=e.sample_rate,o=e.channels.map(function(D){return new Float32Array(D)}),l=r?o.length:1,i=24,d=Bi(a,t),f=e.bits===8?1:2,b=i+d*2*f*l,p=new ArrayBuffer(b),h=new DataView(p),x=0,I=i,v=new Array(l),m=new Array(l),C=0;C<l;C++)v[C]=1/0,m[C]=-1/0;var y=e.bits===8?Ei:Mi,g=e.bits===8?Di:Ti;h.setInt32(0,2,!0),h.setUint32(4,e.bits===8,!0),h.setInt32(8,s,!0),h.setInt32(12,t,!0),h.setInt32(16,d,!0),h.setInt32(20,l,!0);for(var k=0;k<a;k++){var A=0;if(l===1){for(var E=0;E<o.length;++E)A+=o[E][k];A=Math.floor(g*A*n/o.length),A<v[0]&&(v[0]=A,v[0]<y&&(v[0]=y)),A>m[0]&&(m[0]=A,m[0]>g&&(m[0]=g))}else for(var _=0;_<l;++_)A=Math.floor(g*o[_][k]*n),A<v[_]&&(v[_]=A,v[_]<y&&(v[_]=y)),A>m[_]&&(m[_]=A,m[_]>g&&(m[_]=g));if(++x===t){for(var B=0;B<l;B++)e.bits===8?(h.setInt8(I++,v[B]),h.setInt8(I++,m[B])):(h.setInt16(I,v[B],!0),h.setInt16(I+2,m[B],!0),I+=4),v[B]=1/0,m[B]=-1/0;x=0}}if(x>0)for(var M=0;M<l;M++)e.bits===8?(h.setInt8(I++,v[M]),h.setInt8(I++,m[M])):(h.setInt16(I,v[M],!0),h.setInt16(I+2,m[M],!0));return p}function Et(e){"@babel/helpers - typeof";return Et=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},Et(e)}function Wi(e){return e&&Et(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function Fi(e){var t=e&&Et(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 Zi(e){var t=e.data,n=e.channels||1,r=24,a=e.bits===8?1:2,s=e.length*2*n;if(t.length!==s)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=r+t.length*a,l=new ArrayBuffer(o),i=new DataView(l);i.setInt32(0,2,!0),i.setUint32(4,e.bits===8,!0),i.setInt32(8,e.sample_rate,!0),i.setInt32(12,e.samples_per_pixel,!0),i.setInt32(16,e.length,!0),i.setInt32(20,n,!0);var d=r;if(e.bits===8)for(var f=0;f<t.length;f++)i.setInt8(d++,t[f],!0);else for(var b=0;b<t.length;b++)i.setInt16(d,t[b],!0),d+=2;return l}function Qe(e){return e==null}function Pi(e,t){var n=atob(e);return n}function Vi(e,t,n){var r=Pi(e),a=r.indexOf(`
1164
- `,10)+1,s=r.substring(a)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function ji(e,t,n){var r;return function(s){return r=r||Vi(e),new Worker(r,s)}}var zi=ji("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function Te(e){if(Wi(e)&&(e=Zi(e)),Fi(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 Ue(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var ht={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function Oi(e){var t={scale:e.scale||ht.scale,bits:e.bits||ht.bits,amplitude_scale:e.amplitude_scale||ht.amplitude_scale,split_channels:e.split_channels||ht.split_channels,disable_worker:e.disable_worker||ht.disable_worker};return t}function Ni(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Pr(e,t,n){var r=Ni(e);if(t.disable_worker){var a=_i({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 Te(a),e)}else{var s=new zi;s.onmessage=function(o){n(void 0,new Te(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 Hi(e,t,n,r){function a(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var s=e.decodeAudioData(t,function(o){Pr(o,n,r)},a);s&&s.catch(a)}Te.create=function(t){return new Te(t)};Te.createFromAudio=function(e,t){var n=Oi(e);if(e.audio_context&&e.array_buffer)return Hi(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Pr(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Zt(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 Te(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var l=0;l<o;++l)this._input_buffer_size>0?(this._min[l]=this._inputData.channel(l).min_sample(this._input_index),this._max[l]=this._inputData.channel(l).max_sample(this._input_index)):(this._min[l]=0,this._max[l]=0);this._min_value=this._inputData.bits===8?-128:-32768,this._max_value=this._inputData.bits===8?127:32767,this._where=0,this._prev_where=0,this._stop=0,this._last_input_index=0}Zt.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};Zt.prototype.next=function(){for(var e=0,t=1e3,n=this._inputData.channels,r;this._input_index<this._input_buffer_size&&e<t;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var a=0;a<n;++a)r=this._outputWaveformData.channel(a),r.set_min_sample(this._output_index-1,this._min[a]),r.set_max_sample(this._output_index-1,this._max[a]);if(this._last_input_index=this._input_index,this._output_index++,this._where=this.sample_at_pixel(this._output_index),this._prev_where=this.sample_at_pixel(this._output_index-1),this._where!==this._prev_where)for(var s=0;s<n;++s)this._min[s]=this._max_value,this._max[s]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(var o=0;o<n;++o){r=this._inputData.channel(o);var l=r.min_sample(this._input_index);l<this._min[o]&&(this._min[o]=l),l=r.max_sample(this._input_index),l>this._max[o]&&(this._max[o]=l)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var i=0;i<n;++i)r=this._outputWaveformData.channel(i),r.set_min_sample(this._output_index-1,this._min[i]),r.set_max_sample(this._output_index-1,this._max[i]);return!0};Zt.prototype.getOutputData=function(){return this._output_data};Te.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Qe(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Qe(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 Zt(t);!n.next(););return new Te(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 Te.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,a=0,s=[this].concat(t).map(function(m){return m._data.buffer}),o=0;o<s.length;o++){var l=s[o],i=new DataView(l).getInt32(16,!0);r+=l.byteLength-n,a+=i}for(var d=new ArrayBuffer(r),f=new DataView(s[0]),b=new DataView(d),p=0;p<n;p++)b.setUint8(p,f.getUint8(p));b.setInt32(16,a,!0);for(var h=0,x=new Uint8Array(d,n),I=0;I<s.length;I++){var v=s[I];x.set(new Uint8Array(v,n),h),h+=v.byteLength-n}return d},slice:function(t){var n=0,r=0;if(!Qe(t.startIndex)&&!Qe(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Qe(t.startTime)&&!Qe(t.endTime)&&(n=this.at_time(t.startTime),r=this.at_time(t.endTime)),n<0)throw new RangeError("startIndex or startTime must not be negative");if(r<0)throw new RangeError("endIndex or endTime must not be negative");n>this.length&&(n=this.length),r>this.length&&(r=this.length),n>r&&(n=r);var a=r-n,s=24,o=this.bits===8?1:2,l=s+a*2*this.channels*o,i=new ArrayBuffer(l),d=new DataView(i);d.setInt32(0,2,!0),d.setUint32(4,this.bits===8,!0),d.setInt32(8,this.sample_rate,!0),d.setInt32(12,this.scale,!0),d.setInt32(16,a,!0),d.setInt32(20,this.channels,!0);for(var f=0;f<a*this.channels*2;f++){var b=this._at(n*this.channels*2+f);this.bits===8?d.setInt8(s+f,b):d.setInt16(s+f*2,b,!0)}return new Te(i)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var e=!!this._data.getUint32(4,!0);return e?8:16},get duration(){return this.length*this.scale/this.sample_rate},get pixels_per_second(){return this.sample_rate/this.scale},get seconds_per_pixel(){return this.scale/this.sample_rate},get channels(){return this._version()===2?this._data.getInt32(20,!0):1},channel:function(t){if(t>=0&&t<this._channels.length)return this._channels[t];throw new RangeError("Invalid channel: "+t)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(t){return this.bits===8?this._data.getInt8(this._offset+t):this._data.getInt16(this._offset+t*2,!0)},_set_at:function(t,n){return this.bits===8?this._data.setInt8(this._offset+t,n):this._data.setInt16(this._offset+t*2,n,!0)},at_time:function(t){return Math.floor(t*this.sample_rate/this.scale)},time:function(t){return t*this.scale/this.sample_rate},toJSON:function(){for(var t={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},n=0;n<this.length;n++)for(var r=0;r<this.channels;r++)t.data.push(this.channel(r).min_sample(n)),t.data.push(this.channel(r).max_sample(n));return t},toArrayBuffer:function(){return this._data.buffer}};async function gn(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 Te.create(r)}else{const r=await t.json();return Te.create(r)}}function Vr(e,t=0){const n=e.channel(t),r=e.bits,a=n.min_array(),s=n.max_array(),o=a.length,l=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let i=0;i<o;i++)l[i*2]=a[i],l[i*2+1]=s[i];return{data:l,bits:r,length:o,sampleRate:e.sample_rate}}async function Gi(e,t=0){const n=await gn(e);return Vr(n,t)}async function Xi(e){const t=await gn(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}exports.Tone=or;exports.AudioPosition=hi;exports.AutomaticScrollCheckbox=pi;exports.ContinuousPlayCheckbox=gi;exports.DownloadAnnotationsButton=Ci;exports.EditableCheckbox=vi;exports.ExportWavButton=xi;exports.FastForwardButton=oi;exports.LinkEndpointsCheckbox=bi;exports.MasterVolumeControl=ui;exports.PauseButton=ni;exports.PlayButton=ti;exports.RewindButton=ai;exports.SelectionTimeInputs=mi;exports.SkipBackwardButton=si;exports.SkipForwardButton=ii;exports.StopButton=ri;exports.TimeFormatSelect=di;exports.Waveform=Ri;exports.WaveformPlaylistProvider=Qs;exports.ZoomInButton=li;exports.ZoomOutButton=ci;exports.createEffectChain=Gs;exports.createEffectInstance=mt;exports.effectCategories=zs;exports.effectDefinitions=pt;exports.getEffectDefinition=pn;exports.getEffectsByCategory=js;exports.getShortcutLabel=As;exports.getWaveformDataMetadata=Xi;exports.loadPeaksFromWaveformData=Gi;exports.loadWaveformData=gn;exports.useAnnotationDragHandlers=xs;exports.useAnnotationKeyboardControls=ks;exports.useAudioTracks=vs;exports.useClipDragHandlers=Cs;exports.useClipSplitting=Is;exports.useDragSensors=ws;exports.useDynamicEffects=Xs;exports.useExportWav=Mr;exports.useIntegratedRecording=Vs;exports.useKeyboardShortcuts=Dt;exports.useMasterAnalyser=ps;exports.useMasterVolume=Er;exports.usePlaybackAnimation=$e;exports.usePlaybackShortcuts=Ss;exports.usePlaylistControls=be;exports.usePlaylistData=Ae;exports.usePlaylistState=Fe;exports.useTimeFormat=Rr;exports.useTrackDynamicEffects=Ys;exports.useWaveformPlaylist=ei;exports.useZoomControls=Dr;exports.waveformDataToPeaks=Vr;
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;
1165
1170
  //# sourceMappingURL=index.js.map