@waveform-playlist/browser 10.0.0 → 10.1.1
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/LICENSE.md +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +96 -161
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5456 -9916
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -19
package/dist/index.js
CHANGED
|
@@ -1,75 +1,10 @@
|
|
|
1
|
-
"use strict";var uh=Object.create;var vl=Object.defineProperty;var dh=Object.getOwnPropertyDescriptor;var fh=Object.getOwnPropertyNames;var hh=Object.getPrototypeOf,ph=Object.prototype.hasOwnProperty;var mh=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fh(t))!ph.call(e,s)&&s!==n&&vl(e,s,{get:()=>t[s],enumerable:!(r=dh(t,s))||r.enumerable});return e};var gh=(e,t,n)=>(n=e!=null?uh(hh(e)):{},mh(t||!e||!e.__esModule?vl(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("tone"),x=require("react/jsx-runtime"),m=require("react"),D=require("styled-components"),Sa=require("react-dom");var On=typeof document<"u"?document.currentScript:null;function _c(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 xc=_c(B),F=_c(m);var mo={exports:{}},yl;function vh(){return yl||(yl=1,(function(e,t){(function(n,r){e.exports=r()})(window,(function(){return(function(n){var r={};function s(o){if(r[o])return r[o].exports;var a=r[o]={i:o,l:!1,exports:{}};return n[o].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=n,s.c=r,s.d=function(o,a,i){s.o(o,a)||Object.defineProperty(o,a,{enumerable:!0,get:i})},s.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},s.t=function(o,a){if(1&a&&(o=s(o)),8&a||4&a&&typeof o=="object"&&o&&o.__esModule)return o;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:o}),2&a&&typeof o!="string")for(var l in o)s.d(i,l,(function(c){return o[c]}).bind(null,l));return i},s.n=function(o){var a=o&&o.__esModule?function(){return o.default}:function(){return o};return s.d(a,"a",a),a},s.o=function(o,a){return Object.prototype.hasOwnProperty.call(o,a)},s.p="",s(s.s="./src/index.ts")})({"./src/chunk.ts":function(n,r,s){s.r(r),s.d(r,"SF2Chunk",(function(){return d}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=s("./src/chunks/index.ts");function l(h){return(l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g})(h)}function c(h,g){for(var y=0;y<g.length;y++){var v=g[y];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(h,v.key,v)}}function u(h){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(g){return g.__proto__||Object.getPrototypeOf(g)})(h)}function f(h,g){return(f=Object.setPrototypeOf||function(y,v){return y.__proto__=v,y})(h,g)}function p(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}var d=(function(h){function g(b){var w,C,_,S,k,I;return(function(E,A){if(!(E instanceof A))throw new TypeError("Cannot call a class as a function")})(this,g),C=this,w=!(_=u(g).call(this,b.id,b.length,b.buffer,b.subChunks))||l(_)!=="object"&&typeof _!="function"?p(C):_,S=p(p(w)),I=void 0,(k="subChunks")in S?Object.defineProperty(S,k,{value:I,enumerable:!0,configurable:!0,writable:!0}):S[k]=I,w.subChunks=b.subChunks.map((function(E){return new g(E)})),w}var y,v;return(function(b,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(w&&w.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),w&&f(b,w)})(g,h),y=g,(v=[{key:"getMetaData",value:function(){if(this.id!=="LIST")throw new o.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks.reduce((function(w,C){if(C.id==="ifil"||C.id==="iver"){if(C.length!==a.SF_VERSION_LENGTH)throw new o.ParseError("Invalid size for the '".concat(C.id,"' sub-chunk"));w[C.id]="".concat(C.getInt16(),".").concat(C.getInt16(2))}else w[C.id]=C.getString();return w}),{});if(!b.ifil)throw new o.ParseError("Missing required 'ifil' sub-chunk");if(!b.INAM)throw new o.ParseError("Missing required 'INAM' sub-chunk");return{version:b.ifil,soundEngine:b.isng||"EMU8000",name:b.INAM,rom:b.irom,romVersion:b.iver,creationDate:b.ICRD,author:b.IENG,product:b.IPRD,copyright:b.ICOP,comments:b.ICMT,createdBy:b.ISFT}}},{key:"getSampleData",value:function(){if(this.id!=="LIST")throw new o.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks[0];if(b.id!=="smpl")throw new o.ParseError("Invalid chunk signature","'smpl'","'".concat(b.id,"'"));return b.buffer}},{key:"getPresetData",value:function(){if(this.id!=="LIST")throw new o.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));return{presetHeaders:Object(i.getPresetHeaders)(this.subChunks[0]),presetZones:Object(i.getZones)(this.subChunks[1],"pbag"),presetModulators:Object(i.getModulators)(this.subChunks[2],"pmod"),presetGenerators:Object(i.getGenerators)(this.subChunks[3],"pgen"),instrumentHeaders:Object(i.getInstrumentHeaders)(this.subChunks[4]),instrumentZones:Object(i.getZones)(this.subChunks[5],"ibag"),instrumentModulators:Object(i.getModulators)(this.subChunks[6],"imod"),instrumentGenerators:Object(i.getGenerators)(this.subChunks[7],"igen"),sampleHeaders:Object(i.getSampleHeaders)(this.subChunks[8])}}}])&&c(y.prototype,v),g})(o.RIFFChunk)},"./src/chunks/generators.ts":function(n,r,s){s.r(r),s.d(r,"getGenerators",(function(){return f}));var o=s("./src/riff/index.ts"),a=s("./src/types/index.ts"),i=s("./src/constants.ts"),l=[a.GeneratorType.StartAddrsOffset,a.GeneratorType.EndAddrsOffset,a.GeneratorType.StartLoopAddrsOffset,a.GeneratorType.EndLoopAddrsOffset,a.GeneratorType.StartAddrsCoarseOffset,a.GeneratorType.EndAddrsCoarseOffset,a.GeneratorType.StartLoopAddrsCoarseOffset,a.GeneratorType.KeyNum,a.GeneratorType.Velocity,a.GeneratorType.EndLoopAddrsCoarseOffset,a.GeneratorType.SampleModes,a.GeneratorType.ExclusiveClass,a.GeneratorType.OverridingRootKey],c=[a.GeneratorType.Unused1,a.GeneratorType.Unused2,a.GeneratorType.Unused3,a.GeneratorType.Unused4,a.GeneratorType.Reserved1,a.GeneratorType.Reserved2,a.GeneratorType.Reserved3],u=[a.GeneratorType.KeyRange,a.GeneratorType.VelRange],f=function(p,d){if(p.id!==d)throw new o.ParseError("Unexpected chunk ID","'".concat(d,"'"),"'".concat(p.id,"'"));if(p.length%i.SF_GENERATOR_SIZE)throw new o.ParseError("Invalid size for the '".concat(d,"' sub-chunk"));return p.iterate((function(h){var g=h.getInt16();return a.GeneratorType[g]?d==="pgen"&&l.includes(g)||d==="igen"&&c.includes(g)?null:u.includes(g)?{id:g,range:{lo:h.getByte(),hi:h.getByte()}}:{id:g,value:h.getInt16BE()}:null}))}},"./src/chunks/index.ts":function(n,r,s){s.r(r);var o=s("./src/chunks/instruments/index.ts");s.d(r,"getInstrumentHeaders",(function(){return o.getInstrumentHeaders}));var a=s("./src/chunks/presets/index.ts");s.d(r,"getPresetHeaders",(function(){return a.getPresetHeaders}));var i=s("./src/chunks/samples/index.ts");s.d(r,"getSampleHeaders",(function(){return i.getSampleHeaders}));var l=s("./src/chunks/generators.ts");s.d(r,"getGenerators",(function(){return l.getGenerators}));var c=s("./src/chunks/modulators.ts");s.d(r,"getModulators",(function(){return c.getModulators}));var u=s("./src/chunks/zones.ts");s.d(r,"getZones",(function(){return u.getZones})),s.d(r,"getItemsInZone",(function(){return u.getItemsInZone}))},"./src/chunks/instruments/headers.ts":function(n,r,s){s.r(r),s.d(r,"getInstrumentHeaders",(function(){return i}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=function(l){if(l.id!=="inst")throw new o.ParseError("Unexpected chunk ID","'inst'","'".concat(l.id,"'"));if(l.length%a.SF_INSTRUMENT_HEADER_SIZE)throw new o.ParseError("Invalid size for the 'inst' sub-chunk");return l.iterate((function(c){return{name:c.getString(),bagIndex:c.getInt16()}}))}},"./src/chunks/instruments/index.ts":function(n,r,s){s.r(r);var o=s("./src/chunks/instruments/headers.ts");s.d(r,"getInstrumentHeaders",(function(){return o.getInstrumentHeaders}))},"./src/chunks/modulators.ts":function(n,r,s){s.r(r),s.d(r,"getModulators",(function(){return l}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=function(c){return{type:c>>10&63,polarity:c>>9&1,direction:c>>8&1,palette:c>>7&1,index:127&c}},l=function(c,u){if(c.id!==u)throw new o.ParseError("Unexpected chunk ID","'".concat(u,"'"),"'".concat(c.id,"'"));if(c.length%a.SF_MODULATOR_SIZE)throw new o.ParseError("Invalid size for the '".concat(u,"' sub-chunk"));return c.iterate((function(f){return{source:i(f.getInt16BE()),id:f.getInt16BE(),value:f.getInt16BE(),valueSource:i(f.getInt16BE()),transform:f.getInt16BE()}}))}},"./src/chunks/presets/headers.ts":function(n,r,s){s.r(r),s.d(r,"getPresetHeaders",(function(){return i}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=function(l){if(l.id!=="phdr")throw new o.ParseError("Invalid chunk ID","'phdr'","'".concat(l.id,"'"));if(l.length%a.SF_PRESET_HEADER_SIZE)throw new o.ParseError("Invalid size for the 'phdr' sub-chunk");return l.iterate((function(c){return{name:c.getString(),preset:c.getInt16(),bank:c.getInt16(),bagIndex:c.getInt16(),library:c.getUInt32(),genre:c.getUInt32(),morphology:c.getUInt32()}}))}},"./src/chunks/presets/index.ts":function(n,r,s){s.r(r);var o=s("./src/chunks/presets/headers.ts");s.d(r,"getPresetHeaders",(function(){return o.getPresetHeaders}))},"./src/chunks/samples/headers.ts":function(n,r,s){s.r(r),s.d(r,"getSampleHeaders",(function(){return i}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=function(l){if(l.id!=="shdr")throw new o.ParseError("Unexpected chunk ID","'shdr'","'".concat(l.id,"'"));if(l.length%a.SF_SAMPLE_HEADER_SIZE)throw new o.ParseError("Invalid size for the 'shdr' sub-chunk");return l.iterate((function(c){return{name:c.getString(),start:c.getUInt32(),end:c.getUInt32(),startLoop:c.getUInt32(),endLoop:c.getUInt32(),sampleRate:c.getUInt32(),originalPitch:c.getByte(),pitchCorrection:c.getChar(),link:c.getInt16(),type:c.getInt16()}}))}},"./src/chunks/samples/index.ts":function(n,r,s){s.r(r);var o=s("./src/chunks/samples/headers.ts");s.d(r,"getSampleHeaders",(function(){return o.getSampleHeaders}))},"./src/chunks/zones.ts":function(n,r,s){s.r(r),s.d(r,"getZones",(function(){return l})),s.d(r,"getItemsInZone",(function(){return c}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=s("./src/types/index.ts"),l=function(d,h){if(d.id!==h)throw new o.ParseError("Unexpected chunk ID","'".concat(h,"'"),"'".concat(d.id,"'"));if(d.length%a.SF_BAG_SIZE)throw new o.ParseError("Invalid size for the '".concat(h,"' sub-chunk"));return d.iterate((function(g){return{generatorIndex:g.getInt16(),modulatorIndex:g.getInt16()}}))},c=function(d,h,g,y,v,b){for(var w=[],C=0;C<d.length;C++){for(var _=d[C],S=d[C+1],k=_.bagIndex,I=S?S.bagIndex:h.length,E=[],A=void 0,R=k;R<I;R++){var T=u(R,h,g),M=f(R,h,y),$=M[i.GeneratorType.KeyRange]&&M[i.GeneratorType.KeyRange].range,O=M[b];if(O){var P=v[O.value];P&&E.push({keyRange:$,modulators:T,generators:M,reference:P})}else R-k==0&&(A={keyRange:$,modulators:T,generators:M})}w.push({header:_,globalZone:A,zones:E})}return w},u=function(d,h,g){var y=h[d],v=h[d+1],b=y.modulatorIndex,w=v?v.modulatorIndex:h.length;return p(b,w,g)},f=function(d,h,g){var y=h[d],v=h[d+1],b=y.generatorIndex,w=v?v.generatorIndex:h.length;return p(b,w,g)},p=function(d,h,g){for(var y={},v=d;v<h;v++){var b=g[v];b&&(y[b.id]=b)}return y}},"./src/constants.ts":function(n,r,s){s.r(r),s.d(r,"SF_VERSION_LENGTH",(function(){return o})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return a})),s.d(r,"SF_BAG_SIZE",(function(){return i})),s.d(r,"SF_MODULATOR_SIZE",(function(){return l})),s.d(r,"SF_GENERATOR_SIZE",(function(){return c})),s.d(r,"SF_INSTRUMENT_HEADER_SIZE",(function(){return u})),s.d(r,"SF_SAMPLE_HEADER_SIZE",(function(){return f})),s.d(r,"DEFAULT_SAMPLE_RATE",(function(){return p}));var o=4,a=38,i=4,l=10,c=4,u=22,f=46,p=22050},"./src/index.ts":function(n,r,s){s.r(r);var o=s("./src/types/index.ts");for(var a in o)["default"].indexOf(a)<0&&(function(u){s.d(r,u,(function(){return o[u]}))})(a);var i=s("./src/chunk.ts");s.d(r,"SF2Chunk",(function(){return i.SF2Chunk}));var l=s("./src/constants.ts");s.d(r,"SF_VERSION_LENGTH",(function(){return l.SF_VERSION_LENGTH})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return l.SF_PRESET_HEADER_SIZE})),s.d(r,"SF_BAG_SIZE",(function(){return l.SF_BAG_SIZE})),s.d(r,"SF_MODULATOR_SIZE",(function(){return l.SF_MODULATOR_SIZE})),s.d(r,"SF_GENERATOR_SIZE",(function(){return l.SF_GENERATOR_SIZE})),s.d(r,"SF_INSTRUMENT_HEADER_SIZE",(function(){return l.SF_INSTRUMENT_HEADER_SIZE})),s.d(r,"SF_SAMPLE_HEADER_SIZE",(function(){return l.SF_SAMPLE_HEADER_SIZE})),s.d(r,"DEFAULT_SAMPLE_RATE",(function(){return l.DEFAULT_SAMPLE_RATE}));var c=s("./src/soundFont2.ts");s.d(r,"SoundFont2",(function(){return c.SoundFont2}))},"./src/riff/chunkIterator.ts":function(n,r,s){s.r(r),s.d(r,"ChunkIterator",(function(){return c}));var o=s("./src/utils/index.ts");function a(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function i(u,f){for(var p=0;p<f.length;p++){var d=f[p];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,p){return f in u?Object.defineProperty(u,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):u[f]=p,u}var c=(function(){function u(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;a(this,u),l(this,"target",[]),l(this,"chunk",void 0),l(this,"position",0),this.chunk=d,this.position=h}var f,p;return f=u,(p=[{key:"iterate",value:function(d){for(;this.position<this.chunk.length;){var h=d(this);h&&this.target.push(h)}}},{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,h=Object(o.getStringFromBuffer)(this.getBuffer(this.position,d));return this.position+=d,h}},{key:"getInt16",value:function(){return this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8}},{key:"getInt16BE",value:function(){return this.getInt16()<<16>>16}},{key:"getUInt32",value:function(){return(this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8|this.chunk.buffer[this.position++]<<16|this.chunk.buffer[this.position++]<<24)>>>0}},{key:"getByte",value:function(){return this.chunk.buffer[this.position++]}},{key:"getChar",value:function(){return this.chunk.buffer[this.position++]<<24>>24}},{key:"skip",value:function(d){this.position+=d}},{key:"getBuffer",value:function(d,h){return this.chunk.buffer.subarray(d,d+h)}},{key:"currentPosition",get:function(){return this.position}}])&&i(f.prototype,p),u})()},"./src/riff/index.ts":function(n,r,s){s.r(r);var o=s("./src/riff/chunkIterator.ts");s.d(r,"ChunkIterator",(function(){return o.ChunkIterator}));var a=s("./src/riff/parseError.ts");s.d(r,"ParseError",(function(){return a.ParseError}));var i=s("./src/riff/parser.ts");s.d(r,"parseBuffer",(function(){return i.parseBuffer})),s.d(r,"getChunk",(function(){return i.getChunk})),s.d(r,"getChunkLength",(function(){return i.getChunkLength})),s.d(r,"getSubChunks",(function(){return i.getSubChunks})),s.d(r,"getChunkId",(function(){return i.getChunkId}));var l=s("./src/riff/riffChunk.ts");s.d(r,"RIFFChunk",(function(){return l.RIFFChunk}))},"./src/riff/parseError.ts":function(n,r,s){function o(d){return(o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h})(d)}function a(d,h){return!h||o(h)!=="object"&&typeof h!="function"?(function(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g})(d):h}function i(d){var h=typeof Map=="function"?new Map:void 0;return(i=function(g){if(g===null||(y=g,Function.toString.call(y).indexOf("[native code]")===-1))return g;var y;if(typeof g!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(g))return h.get(g);h.set(g,v)}function v(){return c(g,arguments,f(this).constructor)}return v.prototype=Object.create(g.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),u(v,g)})(d)}function l(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch{return!1}}function c(d,h,g){return(c=l()?Reflect.construct:function(y,v,b){var w=[null];w.push.apply(w,v);var C=new(Function.bind.apply(y,w));return b&&u(C,b.prototype),C}).apply(null,arguments)}function u(d,h){return(u=Object.setPrototypeOf||function(g,y){return g.__proto__=y,g})(d,h)}function f(d){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(h){return h.__proto__||Object.getPrototypeOf(h)})(d)}s.r(r),s.d(r,"ParseError",(function(){return p}));var p=(function(d){function h(g,y,v){return(function(b,w){if(!(b instanceof w))throw new TypeError("Cannot call a class as a function")})(this,h),a(this,f(h).call(this,"".concat(g).concat(y&&v?", expected ".concat(y,", received ").concat(v):"")))}return(function(g,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");g.prototype=Object.create(y&&y.prototype,{constructor:{value:g,writable:!0,configurable:!0}}),y&&u(g,y)})(h,d),h})(i(Error))},"./src/riff/parser.ts":function(n,r,s){s.r(r),s.d(r,"parseBuffer",(function(){return l})),s.d(r,"getChunk",(function(){return c})),s.d(r,"getChunkLength",(function(){return u})),s.d(r,"getSubChunks",(function(){return f})),s.d(r,"getChunkId",(function(){return p}));var o=s("./src/riff/parseError.ts"),a=s("./src/utils/buffer.ts"),i=s("./src/riff/riffChunk.ts"),l=function(d){var h=p(d);if(h!=="RIFF")throw new o.ParseError("Invalid file format","RIFF",h);var g=p(d,8);if(g!=="sfbk")throw new o.ParseError("Invalid signature","sfbk",g);var y=d.subarray(8),v=f(y.subarray(4));return new i.RIFFChunk(h,y.length,y,v)},c=function(d,h){var g=p(d,h),y=u(d,h+4),v=[];return g!=="RIFF"&&g!=="LIST"||(v=f(d.subarray(h+12))),new i.RIFFChunk(g,y,d.subarray(h+8),v)},u=function(d,h){return((d=d.subarray(h,h+4))[0]|d[1]<<8|d[2]<<16|d[3]<<24)>>>0},f=function(d){for(var h=[],g=0;g<=d.length-8;){var y=c(d,g);h.push(y),g=(g+=8+y.length)%2?g+1:g}return h},p=function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return Object(a.getStringFromBuffer)(d.subarray(h,h+4))}},"./src/riff/riffChunk.ts":function(n,r,s){s.r(r),s.d(r,"RIFFChunk",(function(){return c}));var o=s("./src/riff/chunkIterator.ts"),a=s("./src/utils/index.ts");function i(u,f){for(var p=0;p<f.length;p++){var d=f[p];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,p){return f in u?Object.defineProperty(u,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):u[f]=p,u}var c=(function(){function u(d,h,g,y){(function(v,b){if(!(v instanceof b))throw new TypeError("Cannot call a class as a function")})(this,u),l(this,"id",void 0),l(this,"length",void 0),l(this,"buffer",void 0),l(this,"subChunks",void 0),this.id=d,this.length=h,this.buffer=g,this.subChunks=y}var f,p;return f=u,(p=[{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,h=arguments.length>1?arguments[1]:void 0;return Object(a.getStringFromBuffer)(this.getBuffer(d,h||this.length-d))}},{key:"getInt16",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d++]|this.buffer[d]<<8}},{key:"getUInt32",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return(this.buffer[d++]|this.buffer[d++]<<8|this.buffer[d++]<<16|this.buffer[d]<<24)>>>0}},{key:"getByte",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]}},{key:"getChar",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]<<24>>24}},{key:"iterator",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new o.ChunkIterator(this,d)}},{key:"iterate",value:function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,g=new o.ChunkIterator(this,h);return g.iterate(d),g.target}},{key:"getBuffer",value:function(d,h){return this.buffer.subarray(d,d+h)}}])&&i(f.prototype,p),u})()},"./src/soundFont2.ts":function(n,r,s){s.r(r),s.d(r,"SoundFont2",(function(){return h}));var o=s("./src/types/index.ts"),a=s("./src/chunk.ts"),i=s("./src/riff/index.ts"),l=s("./src/chunks/index.ts"),c=s("./src/utils/index.ts");function u(g){for(var y=1;y<arguments.length;y++){var v=arguments[y]!=null?arguments[y]:{},b=Object.keys(v);typeof Object.getOwnPropertySymbols=="function"&&(b=b.concat(Object.getOwnPropertySymbols(v).filter((function(w){return Object.getOwnPropertyDescriptor(v,w).enumerable})))),b.forEach((function(w){d(g,w,v[w])}))}return g}function f(g,y){for(var v=0;v<y.length;v++){var b=y[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}function p(g,y,v){return y&&f(g.prototype,y),v&&f(g,v),g}function d(g,y,v){return y in g?Object.defineProperty(g,y,{value:v,enumerable:!0,configurable:!0,writable:!0}):g[y]=v,g}var h=(function(){function g(y){if((function(b,w){if(!(b instanceof w))throw new TypeError("Cannot call a class as a function")})(this,g),d(this,"chunk",void 0),d(this,"metaData",void 0),d(this,"sampleData",void 0),d(this,"samples",void 0),d(this,"presetData",void 0),d(this,"instruments",void 0),d(this,"presets",void 0),d(this,"banks",void 0),!(y instanceof a.SF2Chunk)){var v=Object(i.parseBuffer)(y);y=new a.SF2Chunk(v)}if(y.subChunks.length!==3)throw new i.ParseError("Invalid sfbk structure","3 chunks","".concat(y.subChunks.length," chunks"));this.chunk=y,this.metaData=y.subChunks[0].getMetaData(),this.sampleData=y.subChunks[1].getSampleData(),this.presetData=y.subChunks[2].getPresetData(),this.samples=this.getSamples(),this.instruments=this.getInstruments(),this.presets=this.getPresets(),this.banks=this.getBanks()}return p(g,null,[{key:"from",value:function(y){return new g(y)}}]),p(g,[{key:"getKeyData",value:function(y){var v=this,b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return Object(c.memoize)((function(C,_,S){var k=v.banks[_];if(k){var I=k.presets[S];if(I){var E=I.zones.filter((function(J){return v.isKeyInRange(J,C)}));if(E.length>0){var A=!0,R=!1,T=void 0;try{for(var M,$=E[Symbol.iterator]();!(A=(M=$.next()).done);A=!0){var O=M.value,P=O.instrument,V=P.zones.filter((function(J){return v.isKeyInRange(J,C)}));if(V.length>0){var Y=!0,K=!1,fe=void 0;try{for(var pe,Ce=V[Symbol.iterator]();!(Y=(pe=Ce.next()).done);Y=!0){var X=pe.value,Se=X.sample,te=u({},O.generators,X.generators),qe=u({},O.modulators,X.modulators);return{keyNumber:C,preset:I,instrument:P,sample:Se,generators:te,modulators:qe}}}catch(J){K=!0,fe=J}finally{try{Y||Ce.return==null||Ce.return()}finally{if(K)throw fe}}}}}catch(J){R=!0,T=J}finally{try{A||$.return==null||$.return()}finally{if(R)throw T}}}}}return null}))(y,b,w)}},{key:"isKeyInRange",value:function(y,v){return y.keyRange===void 0||y.keyRange.lo<=v&&y.keyRange.hi>=v}},{key:"getBanks",value:function(){return this.presets.reduce((function(y,v){var b=v.header.bank;return y[b]||(y[b]={presets:[]}),y[b].presets[v.header.preset]=v,y}),[])}},{key:"getPresets",value:function(){var y=this.presetData,v=y.presetHeaders,b=y.presetZones,w=y.presetGenerators,C=y.presetModulators;return Object(l.getItemsInZone)(v,b,C,w,this.instruments,o.GeneratorType.Instrument).filter((function(_){return _.header.name!=="EOP"})).map((function(_){return{header:_.header,globalZone:_.globalZone,zones:_.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,instrument:S.reference}}))}}))}},{key:"getInstruments",value:function(){var y=this.presetData,v=y.instrumentHeaders,b=y.instrumentZones,w=y.instrumentModulators,C=y.instrumentGenerators;return Object(l.getItemsInZone)(v,b,w,C,this.samples,o.GeneratorType.SampleId).filter((function(_){return _.header.name!=="EOI"})).map((function(_){return{header:_.header,globalZone:_.globalZone,zones:_.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,sample:S.reference}}))}}))}},{key:"getSamples",value:function(){var y=this;return this.presetData.sampleHeaders.filter((function(v){return v.name!=="EOS"})).map((function(v){if(v.name!=="EOS"&&v.sampleRate<=0)throw new Error("Illegal sample rate of ".concat(v.sampleRate," hz in sample '").concat(v.name,"'"));return v.originalPitch>=128&&v.originalPitch<=254&&(v.originalPitch=60),v.startLoop-=v.start,v.endLoop-=v.start,{header:v,data:new Int16Array(new Uint8Array(y.sampleData.subarray(2*v.start,2*v.end)).buffer)}}))}}]),g})()},"./src/types/bank.ts":function(n,r){},"./src/types/generator.ts":function(n,r,s){var o,a;function i(c,u,f){return u in c?Object.defineProperty(c,u,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[u]=f,c}s.r(r),s.d(r,"GeneratorType",(function(){return a})),s.d(r,"DEFAULT_GENERATOR_VALUES",(function(){return l})),(function(c){c[c.StartAddrsOffset=0]="StartAddrsOffset",c[c.EndAddrsOffset=1]="EndAddrsOffset",c[c.StartLoopAddrsOffset=2]="StartLoopAddrsOffset",c[c.EndLoopAddrsOffset=3]="EndLoopAddrsOffset",c[c.StartAddrsCoarseOffset=4]="StartAddrsCoarseOffset",c[c.ModLFOToPitch=5]="ModLFOToPitch",c[c.VibLFOToPitch=6]="VibLFOToPitch",c[c.ModEnvToPitch=7]="ModEnvToPitch",c[c.InitialFilterFc=8]="InitialFilterFc",c[c.InitialFilterQ=9]="InitialFilterQ",c[c.ModLFOToFilterFc=10]="ModLFOToFilterFc",c[c.ModEnvToFilterFc=11]="ModEnvToFilterFc",c[c.EndAddrsCoarseOffset=12]="EndAddrsCoarseOffset",c[c.ModLFOToVolume=13]="ModLFOToVolume",c[c.Unused1=14]="Unused1",c[c.ChorusEffectsSend=15]="ChorusEffectsSend",c[c.ReverbEffectsSend=16]="ReverbEffectsSend",c[c.Pan=17]="Pan",c[c.Unused2=18]="Unused2",c[c.Unused3=19]="Unused3",c[c.Unused4=20]="Unused4",c[c.DelayModLFO=21]="DelayModLFO",c[c.FreqModLFO=22]="FreqModLFO",c[c.DelayVibLFO=23]="DelayVibLFO",c[c.FreqVibLFO=24]="FreqVibLFO",c[c.DelayModEnv=25]="DelayModEnv",c[c.AttackModEnv=26]="AttackModEnv",c[c.HoldModEnv=27]="HoldModEnv",c[c.DecayModEnv=28]="DecayModEnv",c[c.SustainModEnv=29]="SustainModEnv",c[c.ReleaseModEnv=30]="ReleaseModEnv",c[c.KeyNumToModEnvHold=31]="KeyNumToModEnvHold",c[c.KeyNumToModEnvDecay=32]="KeyNumToModEnvDecay",c[c.DelayVolEnv=33]="DelayVolEnv",c[c.AttackVolEnv=34]="AttackVolEnv",c[c.HoldVolEnv=35]="HoldVolEnv",c[c.DecayVolEnv=36]="DecayVolEnv",c[c.SustainVolEnv=37]="SustainVolEnv",c[c.ReleaseVolEnv=38]="ReleaseVolEnv",c[c.KeyNumToVolEnvHold=39]="KeyNumToVolEnvHold",c[c.KeyNumToVolEnvDecay=40]="KeyNumToVolEnvDecay",c[c.Instrument=41]="Instrument",c[c.Reserved1=42]="Reserved1",c[c.KeyRange=43]="KeyRange",c[c.VelRange=44]="VelRange",c[c.StartLoopAddrsCoarseOffset=45]="StartLoopAddrsCoarseOffset",c[c.KeyNum=46]="KeyNum",c[c.Velocity=47]="Velocity",c[c.InitialAttenuation=48]="InitialAttenuation",c[c.Reserved2=49]="Reserved2",c[c.EndLoopAddrsCoarseOffset=50]="EndLoopAddrsCoarseOffset",c[c.CoarseTune=51]="CoarseTune",c[c.FineTune=52]="FineTune",c[c.SampleId=53]="SampleId",c[c.SampleModes=54]="SampleModes",c[c.Reserved3=55]="Reserved3",c[c.ScaleTuning=56]="ScaleTuning",c[c.ExclusiveClass=57]="ExclusiveClass",c[c.OverridingRootKey=58]="OverridingRootKey",c[c.Unused5=59]="Unused5",c[c.EndOper=60]="EndOper"})(a||(a={}));var l=(i(o={},a.StartAddrsOffset,0),i(o,a.EndAddrsOffset,0),i(o,a.StartLoopAddrsOffset,0),i(o,a.EndLoopAddrsOffset,0),i(o,a.StartAddrsCoarseOffset,0),i(o,a.ModLFOToPitch,0),i(o,a.VibLFOToPitch,0),i(o,a.ModEnvToPitch,0),i(o,a.InitialFilterFc,13500),i(o,a.InitialFilterQ,0),i(o,a.ModLFOToFilterFc,0),i(o,a.ModEnvToFilterFc,0),i(o,a.EndAddrsCoarseOffset,0),i(o,a.ModLFOToVolume,0),i(o,a.ChorusEffectsSend,0),i(o,a.ReverbEffectsSend,0),i(o,a.Pan,0),i(o,a.DelayModLFO,-12e3),i(o,a.FreqModLFO,0),i(o,a.DelayVibLFO,-12e3),i(o,a.FreqVibLFO,0),i(o,a.DelayModEnv,-12e3),i(o,a.AttackModEnv,-12e3),i(o,a.HoldModEnv,-12e3),i(o,a.DecayModEnv,-12e3),i(o,a.SustainModEnv,0),i(o,a.ReleaseModEnv,-12e3),i(o,a.KeyNumToModEnvHold,0),i(o,a.KeyNumToModEnvDecay,0),i(o,a.DelayVolEnv,-12e3),i(o,a.AttackVolEnv,-12e3),i(o,a.HoldVolEnv,-12e3),i(o,a.DecayVolEnv,-12e3),i(o,a.SustainVolEnv,0),i(o,a.ReleaseVolEnv,-12e3),i(o,a.KeyNumToVolEnvHold,0),i(o,a.KeyNumToVolEnvDecay,0),i(o,a.StartLoopAddrsCoarseOffset,0),i(o,a.KeyNum,-1),i(o,a.Velocity,-1),i(o,a.InitialAttenuation,0),i(o,a.EndLoopAddrsCoarseOffset,0),i(o,a.CoarseTune,0),i(o,a.FineTune,0),i(o,a.SampleModes,0),i(o,a.ScaleTuning,100),i(o,a.ExclusiveClass,0),i(o,a.OverridingRootKey,-1),o)},"./src/types/index.ts":function(n,r,s){s.r(r);var o=s("./src/types/bank.ts");for(var a in o)["default"].indexOf(a)<0&&(function(y){s.d(r,y,(function(){return o[y]}))})(a);var i=s("./src/types/generator.ts");s.d(r,"GeneratorType",(function(){return i.GeneratorType})),s.d(r,"DEFAULT_GENERATOR_VALUES",(function(){return i.DEFAULT_GENERATOR_VALUES}));var l=s("./src/types/instrument.ts");for(var a in l)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(a)<0&&(function(v){s.d(r,v,(function(){return l[v]}))})(a);var c=s("./src/types/key.ts");for(var a in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(a)<0&&(function(v){s.d(r,v,(function(){return c[v]}))})(a);var u=s("./src/types/metaData.ts");for(var a in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(a)<0&&(function(v){s.d(r,v,(function(){return u[v]}))})(a);var f=s("./src/types/modulator.ts");s.d(r,"ControllerType",(function(){return f.ControllerType})),s.d(r,"ControllerPolarity",(function(){return f.ControllerPolarity})),s.d(r,"ControllerDirection",(function(){return f.ControllerDirection})),s.d(r,"ControllerPalette",(function(){return f.ControllerPalette})),s.d(r,"Controller",(function(){return f.Controller})),s.d(r,"TransformType",(function(){return f.TransformType})),s.d(r,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return f.DEFAULT_INSTRUMENT_MODULATORS}));var p=s("./src/types/preset.ts");for(var a in p)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(a)<0&&(function(v){s.d(r,v,(function(){return p[v]}))})(a);var d=s("./src/types/presetData.ts");for(var a in d)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(a)<0&&(function(v){s.d(r,v,(function(){return d[v]}))})(a);var h=s("./src/types/sample.ts");s.d(r,"SampleType",(function(){return h.SampleType}));var g=s("./src/types/zone.ts");for(var a in g)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS","SampleType"].indexOf(a)<0&&(function(v){s.d(r,v,(function(){return g[v]}))})(a)},"./src/types/instrument.ts":function(n,r){},"./src/types/key.ts":function(n,r){},"./src/types/metaData.ts":function(n,r){},"./src/types/modulator.ts":function(n,r,s){s.r(r),s.d(r,"ControllerType",(function(){return o})),s.d(r,"ControllerPolarity",(function(){return a})),s.d(r,"ControllerDirection",(function(){return i})),s.d(r,"ControllerPalette",(function(){return l})),s.d(r,"Controller",(function(){return c})),s.d(r,"TransformType",(function(){return u})),s.d(r,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return p}));var o,a,i,l,c,u,f=s("./src/types/generator.ts");(function(d){d[d.Linear=0]="Linear",d[d.Concave=1]="Concave",d[d.Convex=2]="Convex",d[d.Switch=3]="Switch"})(o||(o={})),(function(d){d[d.Unipolar=0]="Unipolar",d[d.Bipolar=1]="Bipolar"})(a||(a={})),(function(d){d[d.Increasing=0]="Increasing",d[d.Decreasing=1]="Decreasing"})(i||(i={})),(function(d){d[d.GeneralController=0]="GeneralController",d[d.MidiController=1]="MidiController"})(l||(l={})),(function(d){d[d.NoController=0]="NoController",d[d.NoteOnVelocity=2]="NoteOnVelocity",d[d.NoteOnKeyNumber=3]="NoteOnKeyNumber",d[d.PolyPressure=10]="PolyPressure",d[d.ChannelPressure=13]="ChannelPressure",d[d.PitchWheel=14]="PitchWheel",d[d.PitchWheelSensitivity=16]="PitchWheelSensitivity",d[d.Link=127]="Link"})(c||(c={})),(function(d){d[d.Linear=0]="Linear",d[d.Absolute=2]="Absolute"})(u||(u={}));var p=[{id:f.GeneratorType.InitialAttenuation,source:{type:o.Concave,polarity:a.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:960,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialFilterFc,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:-2400,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.ChannelPressure},value:50,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.MidiController,index:1},value:50,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:o.Concave,polarity:a.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:7},value:960,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:o.Linear,polarity:a.Bipolar,direction:i.Increasing,palette:l.MidiController,index:10},value:1e3,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:o.Concave,polarity:a.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:11},value:960,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ReverbEffectsSend,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.MidiController,index:91},value:200,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ChorusEffectsSend,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.MidiController,index:93},value:200,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.CoarseTune,source:{type:o.Linear,polarity:a.Bipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheel},value:12700,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheelSensitivity},transform:u.Linear}]},"./src/types/preset.ts":function(n,r){},"./src/types/presetData.ts":function(n,r){},"./src/types/sample.ts":function(n,r,s){var o;s.r(r),s.d(r,"SampleType",(function(){return o})),(function(a){a[a.EOS=0]="EOS",a[a.Mono=1]="Mono",a[a.Right=2]="Right",a[a.Left=4]="Left",a[a.Linked=8]="Linked",a[a.RomMono=32769]="RomMono",a[a.RomRight=32770]="RomRight",a[a.RomLeft=32772]="RomLeft",a[a.RomLinked=32776]="RomLinked"})(o||(o={}))},"./src/types/zone.ts":function(n,r){},"./src/utils/buffer.ts":function(n,r,s){s.r(r),s.d(r,"getStringFromBuffer",(function(){return o}));var o=function(a){var i=new TextDecoder("utf8").decode(a),l=i.indexOf("\0");return(l===-1?i:i.slice(0,l)).trim()}},"./src/utils/index.ts":function(n,r,s){s.r(r);var o=s("./src/utils/buffer.ts");s.d(r,"getStringFromBuffer",(function(){return o.getStringFromBuffer}));var a=s("./src/utils/memoize.ts");s.d(r,"memoize",(function(){return a.memoize}))},"./src/utils/memoize.ts":function(n,r,s){s.r(r),s.d(r,"memoize",(function(){return o}));var o=function(a){var i={};return function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var f=JSON.stringify(c);if(f in i)return i[f];var p=a.apply(void 0,c);return i[f]=p,p}}}})}))})(mo)),mo.exports}vh();var Oe=1e3;function Fo(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:s=1,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:p}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate,h=t?.length??e.sourceDurationSamples??(c&&d?Math.ceil(c.duration*d):void 0);if(d===void 0)throw new Error("createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");if(h===void 0)throw new Error("createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const g=e.durationSamples??h;return{id:Ic(),audioBuffer:t,startSample:n,durationSamples:g,offsetSamples:r,sampleRate:d,sourceDurationSamples:h,gain:s,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:p}}function Sc(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:p}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate;if(d===void 0)throw new Error("createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");const h=t?.duration??e.sourceDuration??c?.duration;if(h===void 0)throw new Error("createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const g=e.duration??h;return Fo({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(g*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(h*d),gain:s,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:p})}function kc(e){const{name:t,clips:n=[],muted:r=!1,soloed:s=!1,volume:o=1,pan:a=0,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}=e;return{id:Ic(),name:t,clips:n,muted:r,soloed:s,volume:o,pan:a,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function Ic(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function bl(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function yh(e,t){return Math.floor(e/t)}function bh(e,t,n){return Math.ceil(e*n/t)}var Hn=192;function Hs(e,t=Hn){const[,n]=e;return t*(4/n)}function ka(e,t=Hn){const[n]=e;return n*Hs(e,t)}function Bn(e,t,n,r=Hn){return Math.round(e*60*n/(t*r))}function Oo(e,t,n,r=Hn){return Math.round(e*r*t/(60*n))}function Bo(e,t){return Math.round(e/t)*t}function wh(e,t,n=Hn){const r=ka(t,n),s=Hs(t,n),o=Math.floor(e/r)+1,a=Math.floor(e%r/s)+1;return a===1?`${o}`:`${o}.${a}`}var Ss=-100;function Ch(e,t=Ss){return Number.isNaN(e)?(console.warn("[waveform-playlist] dBToNormalized received NaN"),0):t>=0?(console.warn("[waveform-playlist] dBToNormalized floor must be negative, got:",t),0):!isFinite(e)||e<=t?0:(e-t)/-t}function wl(e,t=Ss){return isFinite(e)?t>=0?(console.warn("[waveform-playlist] normalizedToDb floor must be negative, got:",t),Ss):Math.max(0,e)*-t+t:t}function Cl(e,t=Ss){if(e<=0)return 0;const n=20*Math.log10(e);return Ch(n,t)}function ts(e){return e.startSample/e.sampleRate}function _l(e){return(e.startSample+e.durationSamples)/e.sampleRate}function xl(e){return e.offsetSamples/e.sampleRate}function Sl(e){return e.durationSamples/e.sampleRate}function Ac(e,t,n){return Math.floor((e+t)/n)-Math.floor(e/n)}var kl=!1;function _r(e){const t=e._param;return!t&&!kl&&(kl=!0,console.warn("[waveform-playlist] Unable to access Tone.js internal _param. This likely means the Tone.js version is incompatible. Mute scheduling may not work correctly.")),t}function Il(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const o=s/r;n[s]=t?o:1-o}return n}function _h(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const o=s/r,a=t?s:e-1-s;n[a]=Math.exp(2*o-1)/Math.E}return n}function xh(e,t){const n=new Float32Array(e),r=t?Math.PI/2:-Math.PI/2;for(let s=0;s<e;s++)n[s]=Math.sin(Math.PI*s/e-r)/2+.5;return n}function Sh(e,t,n=10){const r=new Float32Array(e);for(let s=0;s<e;s++){const o=t?s:e-1-s,a=s/e;r[o]=Math.log(1+n*a)/Math.log(1+n)}return r}function Ec(e,t,n){switch(e){case"linear":return Il(t,n);case"exponential":return _h(t,n);case"sCurve":return xh(t,n);case"logarithmic":return Sh(t,n);default:return Il(t,n)}}function Al(e,t,n,r="linear",s=0,o=1){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(o,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(o,.001),t+n);else{const a=Ec(r,1e4,!0),i=new Float32Array(a.length),l=o-s;for(let c=0;c<a.length;c++)i[c]=s+a[c]*l;e.setValueCurveAtTime(i,t,n)}}function El(e,t,n,r="linear",s=1,o=0){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(o,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(o,.001),t+n);else{const a=Ec(r,1e4,!1),i=new Float32Array(a.length),l=s-o;for(let c=0;c<a.length;c++)i[c]=o+a[c]*l;e.setValueCurveAtTime(i,t,n)}}var kh=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new B.Volume(this.gainToDb(e.track.gain)),this.panNode=new B.Panner({pan:e.track.stereoPan,channelCount:2}),this.muteGain=new B.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||B.getDestination();if(e.effects){const a=e.effects(this.muteGain,t,!1);a&&(this.effectsCleanup=a)}else this.muteGain.connect(t);const n=e.clips||(e.buffer?[{buffer:e.buffer,startTime:0,duration:e.buffer.duration,offset:0,fadeIn:e.track.fadeIn,fadeOut:e.track.fadeOut,gain:1}]:[]),r=B.getTransport(),s=B.getContext().rawContext,o=this.volumeNode.input.input;this.scheduledClips=n.map(a=>{const i=s.createGain();i.gain.value=a.gain,i.connect(o);const l=this.track.startTime+a.startTime,c=r.schedule(u=>{l<this._scheduleGuardOffset||this.startClipSource(a,i,u)},l);return{clipInfo:a,fadeGainNode:i,scheduleId:c}})}startClipSource(e,t,n,r,s){const a=B.getContext().rawContext.createBufferSource();a.buffer=e.buffer,a.connect(t);const i=r??e.offset,l=s??e.duration;try{a.start(n,i,l)}catch(c){console.warn(`[waveform-playlist] Failed to start source on track "${this.id}" (time=${n}, offset=${i}, duration=${l}):`,c),a.disconnect();return}this.activeSources.add(a),a.onended=()=>{this.activeSources.delete(a)}}setScheduleGuardOffset(e){this._scheduleGuardOffset=e}startMidClipSources(e,t){for(const{clipInfo:n,fadeGainNode:r}of this.scheduledClips){const s=this.track.startTime+n.startTime,o=s+n.duration;if(s<e&&o>e){const a=e-s,i=n.offset+a,l=n.duration-a;this.startClipSource(n,r,t,i,l)}}}stopAllSources(){this.activeSources.forEach(e=>{try{e.stop()}catch(t){console.warn(`[waveform-playlist] Error stopping source on track "${this.id}":`,t)}}),this.activeSources.clear()}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGainNode:s}=e,o=s.gain;o.cancelScheduledValues(0);const a=n-r.offset;if(r.fadeIn&&a<r.fadeIn.duration){const i=r.fadeIn.duration;if(a<=0)Al(o,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-a,c=a/i,u=r.gain*c;Al(o,t,l,r.fadeIn.type||"linear",u,r.gain)}}else o.setValueAtTime(r.gain,t);if(r.fadeOut){const l=r.duration-r.fadeOut.duration-a;if(l>0){const c=t+l;El(o,c,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const c=-l,u=r.fadeOut.duration-c,f=c/r.fadeOut.duration,p=r.gain*(1-f);El(o,t,u,r.fadeOut.type||"linear",p,0)}}}prepareFades(e,t){this.scheduledClips.forEach(n=>{const r=this.track.startTime+n.clipInfo.startTime,s=r+n.clipInfo.duration;if(!(t>=s))if(t>=r){const o=t-r+n.clipInfo.offset;this.scheduleFades(n,e,o)}else{const o=r-t;this.scheduleFades(n,e+o,n.clipInfo.offset)}})}cancelFades(){this.scheduledClips.forEach(({fadeGainNode:e,clipInfo:t})=>{const n=e.gain;n.cancelScheduledValues(0),n.setValueAtTime(t.gain,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;const t=e?0:1;_r(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=B.getTransport();if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach((t,n)=>{try{e.clear(t.scheduleId)}catch(r){console.warn(`[waveform-playlist] Error clearing schedule ${n} on track "${this.id}":`,r)}try{t.fadeGainNode.disconnect()}catch(r){console.warn(`[waveform-playlist] Error disconnecting fadeGain ${n} on track "${this.id}":`,r)}});try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const e=this.scheduledClips[this.scheduledClips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.scheduledClips[0]?.clipInfo.buffer}get muted(){return this.track.muted}get startTime(){return this.track.startTime}};function Ih(e){return e===35||e===36?"kick":e>=37&&e<=40?"snare":e===41||e===43||e===45||e===47||e===48||e===50?"tom":"cymbal"}var Ah=class{constructor(e){this.track=e.track,this.volumeNode=new B.Volume(this.gainToDb(e.track.gain)),this.panNode=new B.Panner(e.track.stereoPan),this.muteGain=new B.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain),this.synth=new B.PolySynth(B.Synth,e.synthOptions),this.synth.connect(this.volumeNode),this.kickSynth=new B.PolySynth(B.MembraneSynth,{voice:B.MembraneSynth,options:{pitchDecay:.05,octaves:6,envelope:{attack:.001,decay:.4,sustain:0,release:.1}}}),this.snareSynth=new B.NoiseSynth({noise:{type:"white"},envelope:{attack:.001,decay:.15,sustain:0,release:.05}}),this.cymbalSynth=new B.PolySynth(B.MetalSynth,{voice:B.MetalSynth,options:{envelope:{attack:.001,decay:.3,release:.1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5}}),this.tomSynth=new B.PolySynth(B.MembraneSynth,{voice:B.MembraneSynth,options:{pitchDecay:.08,octaves:4,envelope:{attack:.001,decay:.3,sustain:0,release:.1}}}),this.kickSynth.connect(this.volumeNode),this.snareSynth.connect(this.volumeNode),this.cymbalSynth.connect(this.volumeNode),this.tomSynth.connect(this.volumeNode);const t=e.destination||B.getDestination();if(e.effects){const n=e.effects(this.muteGain,t,!1);n&&(this.effectsCleanup=n)}else this.muteGain.connect(t);this.scheduledClips=e.clips.map(n=>{const r=n.notes.filter(i=>{const l=i.time+i.duration;return i.time<n.offset+n.duration&&l>n.offset}),s=this.track.startTime+n.startTime,o=r.map(i=>{const l=i.time-n.offset,c=Math.max(0,l),u=Math.min(i.duration-Math.max(0,n.offset-i.time),n.duration-c);return{time:s+c,note:i.name,midi:i.midi,duration:Math.max(0,u),velocity:i.velocity,channel:i.channel}}),a=new B.Part((i,l)=>{l.duration>0&&this.triggerNote(l.midi,l.note,l.duration,i,l.velocity,l.channel)},o);return a.start(0),{clipInfo:n,part:a}})}triggerNote(e,t,n,r,s,o){if(o===9)switch(Ih(e)){case"kick":this.kickSynth.triggerAttackRelease("C1",n,r,s);break;case"snare":try{this.snareSynth.triggerAttackRelease(n,r,s)}catch(i){console.warn("[waveform-playlist] Snare overlap — previous hit still decaying, skipped:",i)}break;case"tom":{const i={41:"G1",43:"A1",45:"C2",47:"D2",48:"E2",50:"G2"};this.tomSynth.triggerAttackRelease(i[e]||"C2",n,r,s);break}case"cymbal":this.cymbalSynth.triggerAttackRelease("C4",n,r,s);break}else this.synth.triggerAttackRelease(t,n,r,s)}gainToDb(e){return 20*Math.log10(e)}setScheduleGuardOffset(e){}startMidClipSources(e,t){for(const{clipInfo:n}of this.scheduledClips){const r=this.track.startTime+n.startTime,s=r+n.duration;if(r<e&&s>e)for(const o of n.notes){const a=o.time-n.offset,i=r+Math.max(0,a),l=i+o.duration;if(i<e&&l>e){const c=l-e;try{this.triggerNote(o.midi,o.name,c,t,o.velocity,o.channel)}catch(u){console.warn(`[waveform-playlist] Failed to start mid-clip MIDI note "${o.name}" on track "${this.id}":`,u)}}}}}stopAllSources(){const e=B.getContext().rawContext.currentTime;try{this.synth.releaseAll(e),this.kickSynth.releaseAll(e),this.cymbalSynth.releaseAll(e),this.tomSynth.releaseAll(e)}catch(t){console.warn(`[waveform-playlist] Error releasing synth on track "${this.id}":`,t)}}prepareFades(e,t){}cancelFades(){}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;const t=e?0:1;_r(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during MIDI track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach(({part:t},n)=>{try{t.dispose()}catch(r){console.warn(`[waveform-playlist] Error disposing Part ${n} on MIDI track "${this.id}":`,r)}});const e=[this.synth,this.kickSynth,this.snareSynth,this.cymbalSynth,this.tomSynth];for(const t of e)try{t?.dispose()}catch(n){console.warn(`[waveform-playlist] Error disposing synth on MIDI track "${this.id}":`,n)}try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on MIDI track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on MIDI track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on MIDI track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const e=this.scheduledClips[this.scheduledClips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get muted(){return this.track.muted}get startTime(){return this.track.startTime}},Mc=class Wo{constructor(t){this.activeSources=new Set,this.track=t.track,this.soundFontCache=t.soundFontCache,this.programNumber=t.programNumber??0,this.bankNumber=t.isPercussion?128:0,this.volumeNode=new B.Volume(this.gainToDb(t.track.gain)),this.panNode=new B.Panner(t.track.stereoPan),this.muteGain=new B.Gain(t.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const n=t.destination||B.getDestination();if(t.effects){const r=t.effects(this.muteGain,n,!1);r&&(this.effectsCleanup=r)}else this.muteGain.connect(n);this.scheduledClips=t.clips.map(r=>{const s=r.notes.filter(l=>{const c=l.time+l.duration;return l.time<r.offset+r.duration&&c>r.offset}),o=this.track.startTime+r.startTime,a=s.map(l=>{const c=l.time-r.offset,u=Math.max(0,c),f=Math.min(l.duration-Math.max(0,r.offset-l.time),r.duration-u);return{time:o+u,note:l.name,midi:l.midi,duration:Math.max(0,f),velocity:l.velocity,channel:l.channel}}),i=new B.Part((l,c)=>{c.duration>0&&this.triggerNote(c.midi,c.duration,l,c.velocity,c.channel)},a);return i.start(0),{clipInfo:r,part:i}})}triggerNote(t,n,r,s,o){const a=o===9?128:this.bankNumber,i=o===9?0:this.programNumber,l=this.soundFontCache.getAudioBuffer(t,a,i);if(!l){Wo._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${a}, preset ${i}). Subsequent missing samples will be silent.`),Wo._missingSampleWarned=!0);return}const c=B.getContext().rawContext,u=c.createBufferSource();u.buffer=l.buffer,u.playbackRate.value=l.playbackRate,(l.loopMode===1||l.loopMode===3)&&(u.loop=!0,u.loopStart=l.loopStart,u.loopEnd=l.loopEnd);const f=l.buffer.duration/l.playbackRate,p=l.loopMode===0?Math.max(n,f):n,d=s*s,h=c.createGain(),{attackVolEnv:g,holdVolEnv:y,decayVolEnv:v,sustainVolEnv:b,releaseVolEnv:w}=l,C=d*b;h.gain.setValueAtTime(0,r),h.gain.linearRampToValueAtTime(d,r+g),y>.001&&h.gain.setValueAtTime(d,r+g+y);const _=r+g+y;h.gain.linearRampToValueAtTime(C,_+v),h.gain.setValueAtTime(C,r+p),h.gain.linearRampToValueAtTime(0,r+p+w),u.connect(h),h.connect(this.volumeNode.input.input),this.activeSources.add(u),u.onended=()=>{this.activeSources.delete(u);try{h.disconnect()}catch(S){console.warn("[waveform-playlist] GainNode already disconnected:",S)}},u.start(r),u.stop(r+p+w)}gainToDb(t){return 20*Math.log10(t)}setScheduleGuardOffset(t){}startMidClipSources(t,n){for(const{clipInfo:r}of this.scheduledClips){const s=this.track.startTime+r.startTime,o=s+r.duration;if(s<t&&o>t)for(const a of r.notes){const i=a.time-r.offset,l=s+Math.max(0,i),c=l+a.duration;if(l<t&&c>t){const u=c-t;try{this.triggerNote(a.midi,u,n,a.velocity,a.channel)}catch(f){console.warn(`[waveform-playlist] Failed to start mid-clip SoundFont note on track "${this.id}":`,f)}}}}}stopAllSources(){for(const t of this.activeSources)try{t.stop()}catch(n){console.warn("[waveform-playlist] Error stopping AudioBufferSourceNode:",n)}this.activeSources.clear()}prepareFades(t,n){}cancelFades(){}setVolume(t){this.track.gain=t,this.volumeNode.volume.value=this.gainToDb(t)}setPan(t){this.track.stereoPan=t,this.panNode.pan.value=t}setMute(t){this.track.muted=t;const n=t?0:1;_r(this.muteGain.gain)?.setValueAtTime(n,0),this.muteGain.gain.value=n}setSolo(t){this.track.soloed=t}dispose(){if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during SoundFont track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach(({part:t},n)=>{try{t.dispose()}catch(r){console.warn(`[waveform-playlist] Error disposing Part ${n} on SoundFont track "${this.id}":`,r)}});try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on SoundFont track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on SoundFont track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on SoundFont track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const t=this.scheduledClips[this.scheduledClips.length-1];return t.clipInfo.startTime+t.clipInfo.duration}get muted(){return this.track.muted}get startTime(){return this.track.startTime}};Mc._missingSampleWarned=!1;var Eh=Mc,Mh=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this._completionEventId=null,this._loopHandler=null,this._loopEnabled=!1,this._loopStart=0,this._loopEnd=0,this.masterVolume=new B.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,B.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)}clearCompletionEvent(){if(this._completionEventId!==null){try{B.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await B.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new kh(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}addMidiTrack(e){const t={...e,destination:this.masterVolume},n=new Ah(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}addSoundFontTrack(e){const t={...e,destination:this.masterVolume},n=new Eh(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)throw new Error("[waveform-playlist] TonePlayout not initialized. Call init() first.");const r=e??B.now(),s=B.getTransport();this.clearCompletionEvent();const o=t??0;this.tracks.forEach(a=>{a.cancelFades(),a.prepareFades(r,o)}),n!==void 0&&(this._completionEventId=s.scheduleOnce(()=>{this._completionEventId=null;try{this.onPlaybackCompleteCallback?.()}catch(a){console.warn("[waveform-playlist] Error in playback completion callback:",a)}},o+n));try{s.state!=="stopped"&&s.stop(),this.tracks.forEach(a=>a.stopAllSources()),s.loopStart=this._loopStart,s.loopEnd=this._loopEnd,s.loop=this._loopEnabled,this.tracks.forEach(a=>a.setScheduleGuardOffset(o)),t!==void 0?s.start(r,t):s.start(r),s._clock._lastUpdate=r,this.tracks.forEach(a=>{a.startMidClipSources(o,r)})}catch(a){throw this.clearCompletionEvent(),this.tracks.forEach(i=>i.cancelFades()),console.warn("[waveform-playlist] Transport.start() failed. Audio playback could not begin.",a),a}}pause(){const e=B.getTransport();try{e.pause()}catch(t){console.warn("[waveform-playlist] Transport.pause() failed:",t)}this.tracks.forEach(t=>t.stopAllSources()),this.tracks.forEach(t=>t.cancelFades()),this.clearCompletionEvent()}stop(){const e=B.getTransport();try{e.stop()}catch(t){console.warn("[waveform-playlist] Transport.stop() failed:",t)}if(this._loopHandler){try{e.off("loop",this._loopHandler)}catch(t){console.warn("[waveform-playlist] Error removing loop handler:",t)}this._loopHandler=null}this.tracks.forEach(t=>{try{t.stopAllSources()}catch(n){console.warn(`[waveform-playlist] Error stopping sources for track "${t.id}":`,n)}}),this.tracks.forEach(t=>{try{t.cancelFades()}catch(n){console.warn(`[waveform-playlist] Error canceling fades for track "${t.id}":`,n)}}),this.clearCompletionEvent()}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))}setLoop(e,t,n){this._loopEnabled=e,this._loopStart=t,this._loopEnd=n;const r=B.getTransport();try{r.loopStart=t,r.loopEnd=n,r.loop=e}catch(s){console.warn("[waveform-playlist] Error configuring Transport loop:",s);return}e&&!this._loopHandler?(this._loopHandler=()=>{const s=B.now();this.tracks.forEach(o=>{try{o.stopAllSources(),o.cancelFades(),o.setScheduleGuardOffset(this._loopStart),o.startMidClipSources(this._loopStart,s),o.prepareFades(s,this._loopStart)}catch(a){console.warn(`[waveform-playlist] Error re-scheduling track "${o.id}" on loop:`,a)}})},r.on("loop",this._loopHandler)):!e&&this._loopHandler&&(r.off("loop",this._loopHandler),this._loopHandler=null)}getCurrentTime(){return B.getTransport().seconds}seekTo(e){B.getTransport().seconds=e}dispose(){try{this.stop()}catch(e){console.warn("[waveform-playlist] Error stopping Transport during dispose:",e)}if(this.tracks.forEach(e=>{try{e.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing track "${e.id}":`,t)}}),this.tracks.clear(),this.effectsCleanup)try{this.effectsCleanup()}catch(e){console.warn("[waveform-playlist] Error during master effects cleanup:",e)}try{this.masterVolume.dispose()}catch(e){console.warn("[waveform-playlist] Error disposing master volume:",e)}}get context(){return B.getContext()}get sampleRate(){return B.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},ns=null;function ks(){return ns||(ns=new B.Context,B.setContext(ns)),ns}function Th(){return ks().rawContext}function Rh(e){let t=null,n=!1,r=0,s=!1,o=0,a=0,i=!1;function l(u,f){const p=f.clips.filter(h=>h.audioBuffer&&!h.midiNotes),d=f.clips.filter(h=>h.midiNotes&&h.midiNotes.length>0);if(p.length>0){const h=Math.min(...p.map(ts)),g=Math.max(...p.map(_l)),y={id:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:g},v=p.map(b=>({buffer:b.audioBuffer,startTime:ts(b)-h,duration:Sl(b),offset:xl(b),fadeIn:b.fadeIn,fadeOut:b.fadeOut,gain:b.gain}));u.addTrack({clips:v,track:y,effects:f.effects})}if(d.length>0){const h=Math.min(...d.map(ts)),g=Math.max(...d.map(_l)),v={id:p.length>0?`${f.id}:midi`:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:g},b=d.map(w=>({notes:w.midiNotes,startTime:ts(w)-h,duration:Sl(w),offset:xl(w)}));if(e?.soundFontCache?.isLoaded){const w=d[0],_=w.midiChannel===9,S=w.midiProgram??0;u.addSoundFontTrack({clips:b,track:v,soundFontCache:e.soundFontCache,programNumber:S,isPercussion:_,effects:f.effects})}else e?.soundFontCache&&console.warn(`[waveform-playlist] SoundFont not loaded for track "${f.name}" — falling back to PolySynth.`),u.addMidiTrack({clips:b,track:v,effects:f.effects})}}function c(u){if(t){try{t.dispose()}catch(p){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",p)}t=null}r++;const f=r;t=new Mh({effects:e?.effects}),i&&t.init().catch(p=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",p),i=!1});for(const p of u)l(t,p);t.applyInitialSoloState(),t.setLoop(s,o,a),t.setOnPlaybackComplete(()=>{f===r&&(n=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(u){c(u)},addTrack(u){if(!t)throw new Error("[waveform-playlist] adapter.addTrack() called but no playout exists. Call setTracks() first to initialize the playout.");l(t,u),t.applyInitialSoloState()},play(u,f){if(!t){console.warn("[waveform-playlist] adapter.play() called but no playout is available. Tracks may not have been set, or the adapter was disposed.");return}const p=f!==void 0?f-u:void 0;t.play(B.now(),u,p),n=!0},pause(){t?.pause(),n=!1},stop(){t?.stop(),n=!1},seek(u){t?.seekTo(u)},getCurrentTime(){return t?.getCurrentTime()??0},isPlaying(){return n},setMasterVolume(u){t?.setMasterGain(u)},setTrackVolume(u,f){t?.getTrack(u)?.setVolume(f)},setTrackMute(u,f){t?.setMute(u,f)},setTrackSolo(u,f){t?.setSolo(u,f)},setTrackPan(u,f){t?.getTrack(u)?.setPan(f)},setLoop(u,f,p){s=u,o=f,a=p,t?.setLoop(u,f,p)},dispose(){try{t?.dispose()}catch(u){console.warn("[waveform-playlist] Error disposing playout:",u)}t=null,n=!1}}}function Tc(e,t,n,r){let s=t;const o=-e.startSample;if(s=Math.max(s,o),r>0){const a=n[r-1],l=a.startSample+a.durationSamples-e.startSample;s=Math.max(s,l)}if(r<n.length-1){const i=n[r+1].startSample-(e.startSample+e.durationSamples);s=Math.min(s,i)}return s}function Rc(e,t,n,r,s,o){let a=t;if(n==="left"){if(a=Math.max(a,-e.startSample),a=Math.max(a,-e.offsetSamples),s>0){const i=r[s-1],l=i.startSample+i.durationSamples;a=Math.max(a,l-e.startSample)}a=Math.min(a,e.durationSamples-o)}else if(a=Math.max(a,o-e.durationSamples),a=Math.min(a,e.sourceDurationSamples-e.offsetSamples-e.durationSamples),s<r.length-1){const i=r[s+1];a=Math.min(a,i.startSample-e.startSample-e.durationSamples)}return a}function $h(e,t){return Math.floor(e/t)*t}function Dh(e,t){const n=t-e.startSample,r=e.durationSamples-n,s=e.name?`${e.name} (1)`:void 0,o=e.name?`${e.name} (2)`:void 0,a=Fo({startSample:e.startSample,durationSamples:n,offsetSamples:e.offsetSamples,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:s,color:e.color,fadeIn:e.fadeIn,audioBuffer:e.audioBuffer,waveformData:e.waveformData}),i=Fo({startSample:t,durationSamples:r,offsetSamples:e.offsetSamples+n,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:o,color:e.color,fadeOut:e.fadeOut,audioBuffer:e.audioBuffer,waveformData:e.waveformData});return{left:a,right:i}}function $c(e,t,n){const r=e.startSample+e.durationSamples;if(t<=e.startSample||t>=r)return!1;const s=t-e.startSample,o=r-t;return s>=n&&o>=n}function go(e){let t=0;for(const n of e)for(const r of n.clips){const o=(r.startSample+r.durationSamples)/r.sampleRate;t=Math.max(t,o)}return t}function Ph(e,t){if(t.length===0)return 0;let n=0,r=Math.abs(t[0]-e);for(let s=1;s<t.length;s++){const o=Math.abs(t[s]-e);o<r&&(r=o,n=s)}return n}function Ml(e,t){return Math.max(0,Math.min(e,t))}var Fh=44100,Oh=1024,Bh=[256,512,1024,2048,4096,8192],Tl=.1,Wh=class{constructor(e={}){if(this._tracks=[],this._currentTime=0,this._playStartPosition=0,this._isPlaying=!1,this._selectedTrackId=null,this._selectionStart=0,this._selectionEnd=0,this._masterVolume=1,this._loopStart=0,this._loopEnd=0,this._isLoopEnabled=!1,this._tracksVersion=0,this._animFrameId=null,this._disposed=!1,this._listeners=new Map,this._sampleRate=e.sampleRate??Fh,this._zoomLevels=[...e.zoomLevels??Bh],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??Oh,n=this._zoomLevels.indexOf(t);if(n===-1)throw new Error(`PlaylistEngine: samplesPerPixel ${t} is not in zoomLevels [${this._zoomLevels.join(", ")}]. Either pass a samplesPerPixel value that exists in zoomLevels, or include ${t} in your zoomLevels array.`);this._zoomIndex=n}getState(){return{tracks:this._tracks.map(e=>({...e,clips:[...e.clips]})),tracksVersion:this._tracksVersion,duration:go(this._tracks),currentTime:this._currentTime,isPlaying:this._isPlaying,samplesPerPixel:this._zoomLevels[this._zoomIndex],sampleRate:this._sampleRate,selectedTrackId:this._selectedTrackId,zoomIndex:this._zoomIndex,canZoomIn:this._zoomIndex>0,canZoomOut:this._zoomIndex<this._zoomLevels.length-1,selectionStart:this._selectionStart,selectionEnd:this._selectionEnd,masterVolume:this._masterVolume,loopStart:this._loopStart,loopEnd:this._loopEnd,isLoopEnabled:this._isLoopEnabled}}setTracks(e){this._tracks=[...e],this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}addTrack(e){this._tracks=[...this._tracks,e],this._tracksVersion++,this._adapter?.addTrack?this._adapter.addTrack(e):this._adapter?.setTracks(this._tracks),this._emitStateChange()}removeTrack(e){this._tracks.some(t=>t.id===e)&&(this._tracks=this._tracks.filter(t=>t.id!==e),this._tracksVersion++,this._selectedTrackId===e&&(this._selectedTrackId=null),this._adapter?.setTracks(this._tracks),this._emitStateChange())}selectTrack(e){e!==this._selectedTrackId&&(this._selectedTrackId=e,this._emitStateChange())}moveClip(e,t,n){const r=this._tracks.find(c=>c.id===e);if(!r){console.warn(`[waveform-playlist/engine] moveClip: track "${e}" not found`);return}const s=r.clips.findIndex(c=>c.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] moveClip: clip "${t}" not found in track "${e}"`);return}const o=r.clips[s],a=bl(r.clips),i=a.findIndex(c=>c.id===t),l=Tc(o,n,a,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=c.clips.map((f,p)=>p===s?{...f,startSample:Math.floor(f.startSample+l)}:f);return{...c,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}splitClip(e,t,n){const r=this._tracks.find(c=>c.id===e);if(!r){console.warn(`[waveform-playlist/engine] splitClip: track "${e}" not found`);return}const s=r.clips.findIndex(c=>c.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] splitClip: clip "${t}" not found in track "${e}"`);return}const o=r.clips[s],a=Math.floor(Tl*this._sampleRate);if(!$c(o,n,a)){console.warn(`[waveform-playlist/engine] splitClip: cannot split clip "${t}" at sample ${n} (clip range: ${o.startSample}–${o.startSample+o.durationSamples}, minDuration: ${a})`);return}const{left:i,right:l}=Dh(o,n);this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=[...c.clips];return u.splice(s,1,i,l),{...c,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}trimClip(e,t,n,r){const s=this._tracks.find(f=>f.id===e);if(!s){console.warn(`[waveform-playlist/engine] trimClip: track "${e}" not found`);return}const o=s.clips.findIndex(f=>f.id===t);if(o===-1){console.warn(`[waveform-playlist/engine] trimClip: clip "${t}" not found in track "${e}"`);return}const a=s.clips[o],i=bl(s.clips),l=i.findIndex(f=>f.id===t),c=Math.floor(Tl*this._sampleRate),u=Rc(a,r,n,i,l,c);u!==0&&(this._tracks=this._tracks.map(f=>{if(f.id!==e)return f;const p=f.clips.map((d,h)=>h!==o?d:n==="left"?{...d,startSample:d.startSample+u,offsetSamples:d.offsetSamples+u,durationSamples:d.durationSamples-u}:{...d,durationSamples:d.durationSamples+u});return{...f,clips:p}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}async init(){this._adapter&&await this._adapter.init()}play(e,t){const n=this._currentTime,r=this._playStartPosition;if(e!==void 0){const s=go(this._tracks);this._currentTime=Ml(e,s)}if(this._playStartPosition=this._currentTime,this._adapter){if(t!==void 0)this._adapter.setLoop(!1,this._loopStart,this._loopEnd);else if(this._isLoopEnabled){const s=this._currentTime<this._loopEnd;this._adapter.setLoop(s,this._loopStart,this._loopEnd)}try{this._adapter.play(this._currentTime,t)}catch(s){throw this._currentTime=n,this._playStartPosition=r,s}}this._isPlaying=!0,this._startTimeUpdateLoop(),this._emit("play"),this._emitStateChange()}pause(){this._isPlaying=!1,this._stopTimeUpdateLoop(),this._adapter?.pause(),this._adapter&&(this._currentTime=this._adapter.getCurrentTime()),this._emit("pause"),this._emitStateChange()}stop(){this._isPlaying=!1,this._currentTime=this._playStartPosition,this._stopTimeUpdateLoop(),this._adapter?.setLoop(!1,this._loopStart,this._loopEnd),this._adapter?.stop(),this._emit("stop"),this._emitStateChange()}seek(e){const t=go(this._tracks);this._currentTime=Ml(e,t),this._adapter?.seek(this._currentTime),this._emitStateChange()}setMasterVolume(e){e!==this._masterVolume&&(this._masterVolume=e,this._adapter?.setMasterVolume(e),this._emitStateChange())}getCurrentTime(){return this._isPlaying&&this._adapter?this._adapter.getCurrentTime():this._currentTime}setSelection(e,t){const n=Math.min(e,t),r=Math.max(e,t);n===this._selectionStart&&r===this._selectionEnd||(this._selectionStart=n,this._selectionEnd=r,this._emitStateChange())}setLoopRegion(e,t){const n=Math.min(e,t),r=Math.max(e,t);n===this._loopStart&&r===this._loopEnd||(this._loopStart=n,this._loopEnd=r,this._adapter?.setLoop(this._isLoopEnabled&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setLoopEnabled(e){e!==this._isLoopEnabled&&(this._isLoopEnabled=e,this._adapter?.setLoop(e&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setTrackVolume(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.volume=t),this._adapter?.setTrackVolume(e,t)}setTrackMute(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.muted=t),this._adapter?.setTrackMute(e,t)}setTrackSolo(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.soloed=t),this._adapter?.setTrackSolo(e,t)}setTrackPan(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.pan=t),this._adapter?.setTrackPan(e,t)}zoomIn(){this._zoomIndex>0&&(this._zoomIndex--,this._emitStateChange())}zoomOut(){this._zoomIndex<this._zoomLevels.length-1&&(this._zoomIndex++,this._emitStateChange())}setZoomLevel(e){const t=Ph(e,this._zoomLevels);t!==this._zoomIndex&&(this._zoomIndex=t,this._emitStateChange())}on(e,t){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t)}off(e,t){this._listeners.get(e)?.delete(t)}dispose(){if(!this._disposed){this._disposed=!0,this._stopTimeUpdateLoop();try{this._adapter?.dispose()}catch(e){console.warn("[waveform-playlist/engine] Error disposing adapter:",e)}this._listeners.clear()}}_emit(e,...t){const n=this._listeners.get(e);if(n)for(const r of n)try{r(...t)}catch(s){console.warn("[waveform-playlist/engine] Error in event listener:",s)}}_isBeforeLoopEnd(){return this._isPlaying?(this._adapter?.getCurrentTime()??this._currentTime)<this._loopEnd:!0}_emitStateChange(){this._emit("statechange",this.getState())}_startTimeUpdateLoop(){if(typeof requestAnimationFrame>"u")return;this._stopTimeUpdateLoop();const e=()=>{this._disposed||!this._isPlaying||(this._adapter&&(this._currentTime=this._adapter.getCurrentTime(),this._emit("timeupdate",this._currentTime)),this._animFrameId=requestAnimationFrame(e))};this._animFrameId=requestAnimationFrame(e)}_stopTimeUpdateLoop(){this._animFrameId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this._animFrameId),this._animFrameId=null)}},Lh=Symbol.for("preact-signals");function Xs(){if(Qt>1)Qt--;else{for(var e,t=!1;gr!==void 0;){var n=gr;for(gr=void 0,Lo++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Pc(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Lo=0,Qt--,t)throw e}}function qt(e){if(Qt>0)return e();Qt++;try{return e()}finally{Xs()}}var me=void 0;function we(e){var t=me;me=void 0;try{return e()}finally{me=t}}var gr=void 0,Qt=0,Lo=0,Is=0;function Dc(e){if(me!==void 0){var t=e.n;if(t===void 0||t.t!==me)return t={i:0,S:e,p:me.s,n:void 0,t:me,e:void 0,x:void 0,r:t},me.s!==void 0&&(me.s.n=t),me.s=t,e.n=t,32&me.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=me.s,t.n=void 0,me.s.n=t,me.s=t),t}}function st(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}st.prototype.brand=Lh;st.prototype.h=function(){return!0};st.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:we(function(){var r;(r=t.W)==null||r.call(t)}))};st.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&we(function(){var s;(s=t.Z)==null||s.call(t)}))}};st.prototype.subscribe=function(e){var t=this;return At(function(){var n=t.value,r=me;me=void 0;try{e(n)}finally{me=r}},{name:"sub"})};st.prototype.valueOf=function(){return this.value};st.prototype.toString=function(){return this.value+""};st.prototype.toJSON=function(){return this.value};st.prototype.peek=function(){var e=me;me=void 0;try{return this.value}finally{me=e}};Object.defineProperty(st.prototype,"value",{get:function(){var e=Dc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Lo>100)throw new Error("Cycle detected");this.v=e,this.i++,Is++,Qt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Xs()}}}});function Dr(e,t){return new st(e,t)}function Pc(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Fc(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Oc(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function vn(e,t){st.call(this,void 0),this.x=e,this.s=void 0,this.g=Is-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}vn.prototype=new st;vn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Is))return!0;if(this.g=Is,this.f|=1,this.i>0&&!Pc(this))return this.f&=-2,!0;var e=me;try{Fc(this),me=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return me=e,Oc(this),this.f&=-2,!0};vn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}st.prototype.S.call(this,e)};vn.prototype.U=function(e){if(this.t!==void 0&&(st.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};vn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(vn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Dc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Rl(e,t){return new vn(e,t)}function Bc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Qt++;var n=me;me=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ia(e),r}finally{me=n,Xs()}}}function Ia(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Bc(e)}function Vh(e){if(me!==this)throw new Error("Out-of-order effect");Oc(this),me=e,this.f&=-2,8&this.f&&Ia(this),Xs()}function Xn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}Xn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};Xn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Bc(this),Fc(this),Qt++;var e=me;return me=this,Vh.bind(this,e)};Xn.prototype.N=function(){2&this.f||(this.f|=2,this.o=gr,gr=this)};Xn.prototype.d=function(){this.f|=8,1&this.f||Ia(this)};Xn.prototype.dispose=function(){this.d()};function At(e,t){var n=new Xn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Nh=Object.create,Aa=Object.defineProperty,Zh=Object.defineProperties,Gh=Object.getOwnPropertyDescriptor,zh=Object.getOwnPropertyDescriptors,$l=Object.getOwnPropertySymbols,jh=Object.prototype.hasOwnProperty,Hh=Object.prototype.propertyIsEnumerable,Xh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yn=e=>{throw TypeError(e)},Vo=(e,t,n)=>t in e?Aa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yh=(e,t)=>{for(var n in t||(t={}))jh.call(t,n)&&Vo(e,n,t[n]);if($l)for(var n of $l(t))Hh.call(t,n)&&Vo(e,n,t[n]);return e},Uh=(e,t)=>Zh(e,zh(t)),Dl=(e,t)=>Aa(e,"name",{value:t,configurable:!0}),Kh=e=>{var t;return[,,,Nh((t=void 0)!=null?t:null)]},Wc=["class","method","getter","setter","accessor","field","value","get","set"],or=e=>e!==void 0&&typeof e!="function"?Yn("Function expected"):e,Qh=(e,t,n,r,s)=>({kind:Wc[e],name:t,metadata:r,addInitializer:o=>n._?Yn("Already initialized"):s.push(or(o||null))}),Lc=(e,t)=>Vo(t,Xh("metadata"),e[3]),on=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},Un=(e,t,n,r,s,o)=>{var a,i,l,c,u,f=t&7,p=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?p?1:2:0,g=Wc[f+5],y=f>3&&(e[h-1]=[]),v=e[h]||(e[h]=[]),b=f&&(!d&&!p&&(s=s.prototype),f<5&&(f>3||!d)&&Gh(f<4?s:{get[n](){return hn(this,o)},set[n](C){return Yt(this,o,C)}},n));f?d&&f<4&&Dl(o,(f>2?"set ":f>1?"get ":"")+n):Dl(s,n);for(var w=r.length-1;w>=0;w--)c=Qh(f,n,l={},e[3],v),f&&(c.static=p,c.private=d,u=c.access={has:d?C=>qh(s,C):C=>n in C},f^3&&(u.get=d?C=>(f^1?hn:Jh)(C,s,f^4?o:b.get):C=>C[n]),f>2&&(u.set=d?(C,_)=>Yt(C,s,_,f^4?o:b.set):(C,_)=>C[n]=_)),i=(0,r[w])(f?f<4?d?o:b[g]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?or(i)&&(f>4?y.unshift(i):f?d?o=i:b[g]=i:s=i):typeof i!="object"||i===null?Yn("Object expected"):(or(a=i.get)&&(b.get=a),or(a=i.set)&&(b.set=a),or(a=i.init)&&y.unshift(a));return f||Lc(e,s),b&&Aa(s,n,b),d?f^4?o:b:s},Ea=(e,t,n)=>t.has(e)||Yn("Cannot "+n),qh=(e,t)=>Object(t)!==t?Yn('Cannot use the "in" operator on this value'):e.has(t),hn=(e,t,n)=>(Ea(e,t,"read from private field"),n?n.call(e):t.get(e)),rs=(e,t,n)=>t.has(e)?Yn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Yt=(e,t,n,r)=>(Ea(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Jh=(e,t,n)=>(Ea(e,t,"access private method"),n);function As(e,t){if(t){let n;return Rl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return Rl(e)}function xr(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((r,s)=>!xr(r,t[s]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(o=>!xr(e[o],t[o]))}return!1}function de({get:e},t){return{init(n){return Dr(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ee(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=As(e.bind(this)),n.set(this,r)),r.value}}function vo(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),s=Object.getOwnPropertyDescriptor(r,n.name);s&&Object.defineProperty(r,n.name,Uh(Yh({},s),{enumerable:e}))})}}function Pr(...e){const t=e.map(n=>At(n));return()=>t.forEach(n=>n())}var Vc,Nc,Zc,Gc,zc,jc,tt,Ma,yo,No,Zo,Ke,Ta,bo,Hc,Go,Ra,wo,zo,jo;jc=[de],zc=[de],Gc=[de],Zc=[vo()],Nc=[vo()],Vc=[vo()];var en=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,on(tt,5,this),rs(this,Ke),rs(this,Ma,on(tt,8,this)),on(tt,11,this),rs(this,Ta,on(tt,12,this)),on(tt,15,this),rs(this,Ra,on(tt,16,this)),on(tt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return hn(this,Ke,zo)}get initial(){return hn(this,Ke,No)}get previous(){return hn(this,Ke,Hc)}set current(e){const t=we(()=>hn(this,Ke,zo));e&&t&&this.equals(t,e)||qt(()=>{hn(this,Ke,No)||Yt(this,Ke,e,Zo),Yt(this,Ke,t,Go),Yt(this,Ke,e,jo)})}reset(e=this.defaultValue){qt(()=>{Yt(this,Ke,void 0,Go),Yt(this,Ke,e,Zo),Yt(this,Ke,e,jo)})}};tt=Kh();Ma=new WeakMap;Ke=new WeakSet;Ta=new WeakMap;Ra=new WeakMap;yo=Un(tt,20,"#initial",jc,Ke,Ma),No=yo.get,Zo=yo.set;bo=Un(tt,20,"#previous",zc,Ke,Ta),Hc=bo.get,Go=bo.set;wo=Un(tt,20,"#current",Gc,Ke,Ra),zo=wo.get,jo=wo.set;Un(tt,2,"current",Zc,en);Un(tt,2,"initial",Nc,en);Un(tt,2,"previous",Vc,en);Lc(tt,en);function Co(e){return we(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var ep=Object.create,Xc=Object.defineProperty,tp=Object.getOwnPropertyDescriptor,Pl=Object.getOwnPropertySymbols,np=Object.prototype.hasOwnProperty,rp=Object.prototype.propertyIsEnumerable,Yc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ys=e=>{throw TypeError(e)},Fl=Math.pow,Ho=(e,t,n)=>t in e?Xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sp=(e,t)=>{for(var n in t||(t={}))np.call(t,n)&&Ho(e,n,t[n]);if(Pl)for(var n of Pl(t))rp.call(t,n)&&Ho(e,n,t[n]);return e},op=e=>{var t;return[,,,ep((t=e?.[Yc("metadata")])!=null?t:null)]},Uc=["class","method","getter","setter","accessor","field","value","get","set"],Kc=e=>e!==void 0&&typeof e!="function"?Ys("Function expected"):e,ap=(e,t,n,r,s)=>({kind:Uc[e],name:t,metadata:r,addInitializer:o=>n._?Ys("Already initialized"):s.push(Kc(o||null))}),ip=(e,t)=>Ho(t,Yc("metadata"),e[3]),lp=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)o[s].call(n);return r},Qc=(e,t,n,r,s,o)=>{for(var a,i,l,c,u=t&7,f=!1,p=!1,d=2,h=Uc[u+5],g=e[d]||(e[d]=[]),y=(s=s.prototype,tp(s,n)),v=r.length-1;v>=0;v--)l=ap(u,n,i={},e[3],g),l.static=f,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],a=(0,r[v])(y[h],l),i._=1,Kc(a)&&(y[h]=a);return y&&Xc(s,n,y),s},qc=(e,t,n)=>t.has(e)||Ys("Cannot "+n),cp=(e,t,n)=>(qc(e,t,"read from private field"),t.get(e)),up=(e,t,n)=>t.has(e)?Ys("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),dp=(e,t,n,r)=>(qc(e,t,"write to private field"),t.set(e,n),n),Pt=class Xo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Xo(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Xo(t,n)}},Fr=class ln{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:s,width:o,height:a,scale:i}=this,l=new ln(s+t,r+n,o,a);return l.scale=sp({},i),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:o,bottom:a}=this;return{width:t,height:n,left:r,top:s,right:o,bottom:a}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new Pt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof ln))return!1;const{left:n,top:r,width:s,height:o}=this;return n===t.left&&r===t.top&&s===t.width&&o===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:o}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=o}intersectionArea(t){return t instanceof ln?fp(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:s}){return new ln(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(o,a)=>{const i=r[a],l=a==="x"?o.left:o.top,c=a==="x"?o.width:o.height;return i=="start"?l:i=="end"?l+c:l+c/2};return Pt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return ln.from(t).intersectionRatio(ln.from(n))}};function fp(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),a=s-r,i=o-n;return r<s&&n<o?a*i:0}var Jc,eu,Yo,ds,Or,Us=class extends(Yo=en,eu=[Ee],Jc=[Ee],Yo){constructor(t){const n=Pt.from(t);super(n,(r,s)=>Pt.equals(r,s)),lp(Or,5,this),up(this,ds,0),this.velocity={x:0,y:0}}get delta(){return Pt.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Pt.from(t),s={x:r.x-n.x,y:r.y-n.y},o=Date.now(),a=o-cp(this,ds),i=l=>Math.round(l/a*100);qt(()=>{dp(this,ds,o),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Pt.from(t)),this.velocity={x:0,y:0}}};Or=op(Yo);ds=new WeakMap;Qc(Or,2,"delta",eu,Us);Qc(Or,2,"direction",Jc,Us);ip(Or,Us);function Uo({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(Fl(r,2)+Fl(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n?s>n.y:!1}var tu=(e=>(e.Horizontal="x",e.Vertical="y",e))(tu||{}),nu=Object.values(tu),hp=Object.create,$a=Object.defineProperty,pp=Object.defineProperties,mp=Object.getOwnPropertyDescriptor,gp=Object.getOwnPropertyDescriptors,Es=Object.getOwnPropertySymbols,ru=Object.prototype.hasOwnProperty,su=Object.prototype.propertyIsEnumerable,ou=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Kn=e=>{throw TypeError(e)},Ko=(e,t,n)=>t in e?$a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,au=(e,t)=>{for(var n in t||(t={}))ru.call(t,n)&&Ko(e,n,t[n]);if(Es)for(var n of Es(t))su.call(t,n)&&Ko(e,n,t[n]);return e},iu=(e,t)=>pp(e,gp(t)),Ol=(e,t)=>$a(e,"name",{value:t,configurable:!0}),lu=(e,t)=>{var n={};for(var r in e)ru.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Es)for(var r of Es(e))t.indexOf(r)<0&&su.call(e,r)&&(n[r]=e[r]);return n},Qn=e=>{var t;return[,,,hp((t=e?.[ou("metadata")])!=null?t:null)]},cu=["class","method","getter","setter","accessor","field","value","get","set"],ar=e=>e!==void 0&&typeof e!="function"?Kn("Function expected"):e,vp=(e,t,n,r,s)=>({kind:cu[e],name:t,metadata:r,addInitializer:o=>n._?Kn("Already initialized"):s.push(ar(o||null))}),yn=(e,t)=>Ko(t,ou("metadata"),e[3]),ee=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},ce=(e,t,n,r,s,o)=>{var a,i,l,c,u,f=t&7,p=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?p?1:2:0,g=cu[f+5],y=f>3&&(e[h-1]=[]),v=e[h]||(e[h]=[]),b=f&&(!d&&!p&&(s=s.prototype),f<5&&(f>3||!d)&&mp(f<4?s:{get[n](){return Ne(this,o)},set[n](C){return St(this,o,C)}},n));f?d&&f<4&&Ol(o,(f>2?"set ":f>1?"get ":"")+n):Ol(s,n);for(var w=r.length-1;w>=0;w--)c=vp(f,n,l={},e[3],v),f&&(c.static=p,c.private=d,u=c.access={has:d?C=>yp(s,C):C=>n in C},f^3&&(u.get=d?C=>(f^1?Ne:bp)(C,s,f^4?o:b.get):C=>C[n]),f>2&&(u.set=d?(C,_)=>St(C,s,_,f^4?o:b.set):(C,_)=>C[n]=_)),i=(0,r[w])(f?f<4?d?o:b[g]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?ar(i)&&(f>4?y.unshift(i):f?d?o=i:b[g]=i:s=i):typeof i!="object"||i===null?Kn("Object expected"):(ar(a=i.get)&&(b.get=a),ar(a=i.set)&&(b.set=a),ar(a=i.init)&&y.unshift(a));return f||yn(e,s),b&&$a(s,n,b),d?f^4?o:b:s},Da=(e,t,n)=>t.has(e)||Kn("Cannot "+n),yp=(e,t)=>Object(t)!==t?Kn('Cannot use the "in" operator on this value'):e.has(t),Ne=(e,t,n)=>(Da(e,t,"read from private field"),n?n.call(e):t.get(e)),be=(e,t,n)=>t.has(e)?Kn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),St=(e,t,n,r)=>(Da(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),bp=(e,t,n)=>(Da(e,t,"access private method"),n);function uu(e,t){return{plugin:e,options:t}}function bn(e){return t=>uu(e,t)}function Pa(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var du,Sr,Fa,fs;du=[de];var ht=class{constructor(e,t){this.manager=e,this.options=t,be(this,Fa,ee(Sr,8,this,!1)),ee(Sr,11,this),be(this,fs,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return we(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=At(e.bind(this));return Ne(this,fs).add(t),t}destroy(){Ne(this,fs).forEach(e=>e())}static configure(e){return uu(this,e)}};Sr=Qn(null);Fa=new WeakMap;fs=new WeakMap;ce(Sr,4,"disabled",du,ht,Fa);yn(Sr,ht);var Br=class extends ht{},hs,_o=class{constructor(e){this.manager=e,this.instances=new Map,be(this,hs,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(Pa).reduceRight((r,s)=>r.some(({plugin:o})=>o===s.plugin)?r:[s,...r],[]),n=t.map(({plugin:r})=>r);for(const r of Ne(this,hs))if(!n.includes(r)){if(r.prototype instanceof Br)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);St(this,hs,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};hs=new WeakMap;function wp(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var ss=[],Tn,Rn,Cp=class extends ht{constructor(e){super(e),be(this,Tn),be(this,Rn),this.computeCollisions=this.computeCollisions.bind(this),St(this,Rn,Dr(ss)),this.destroy=Pr(()=>{const t=this.computeCollisions(),n=we(()=>this.manager.dragOperation.position.current);if(t!==ss){const r=Ne(this,Tn);if(St(this,Tn,n),r&&n.x==r.x&&n.y==r.y)return}else St(this,Tn,void 0);Ne(this,Rn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){we(()=>{e?Ne(this,Rn).value=this.computeCollisions():St(this,Tn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:o,status:a}=r;if(!a.initialized||!o)return ss;const i=[],l=[];for(const c of e??n.droppables){if(c.disabled||s&&!c.accepts(s))continue;const u=t??c.collisionDetector;if(!u)continue;l.push(c),c.shape;const f=we(()=>u({droppable:c,dragOperation:r}));f&&(c.collisionPriority!=null&&(f.priority=c.collisionPriority),i.push(f))}return l.length===0?ss:(i.sort(wp),i)}get collisions(){return Ne(this,Rn).value}};Tn=new WeakMap;Rn=new WeakMap;var _p=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const s of r)s(...t)}},xp=class extends _p{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ps(e,t=!0){let n=!1;return iu(au({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Sp=class extends Br{constructor(e){super(e);const t=(r,s)=>r.map(({id:o})=>o).join("")===s.map(({id:o})=>o).join("");let n=[];this.destroy=Pr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:o}=r;if(r.isDisabled())return;const a=ps({collisions:o});if(s.dispatch("collision",a),a.defaultPrevented||t(o,n))return;n=o;const[i]=o;we(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},Oa=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(Oa||{}),Ba=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Ba||{}),fu,hu,pu,mu,gu,vu,yu,It,Wa;yu=[de],vu=[Ee],gu=[Ee],mu=[Ee],pu=[Ee],hu=[Ee],fu=[Ee];var Zt=class{constructor(){ee(It,5,this),be(this,Wa,ee(It,8,this,"idle")),ee(It,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};It=Qn(null);Wa=new WeakMap;ce(It,4,"value",yu,Zt,Wa);ce(It,2,"current",vu,Zt);ce(It,2,"idle",gu,Zt);ce(It,2,"initializing",mu,Zt);ce(It,2,"initialized",pu,Zt);ce(It,2,"dragging",hu,Zt);ce(It,2,"dropped",fu,Zt);yn(It,Zt);var kp=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return we(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=ps({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return we(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:s,coordinates:o}=e;qt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(o)});const a=ps({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",a),a.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:i}=t;i.current==="initializing"&&(t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1}))}),r)})}move(e){return we(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:o}=r;if(!s.dragging||!o||o.signal.aborted)return;const a=ps({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",a),queueMicrotask(()=>{var i,l,c,u,f;if(a.defaultPrevented)return;const p=(f=e.to)!=null?f:{x:r.position.current.x+((l=(i=e.by)==null?void 0:i.x)!=null?l:0),y:r.position.current.y+((u=(c=e.by)==null?void 0:c.y)!=null?u:0)};r.position.current=p})})}stop(e={}){return we(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let o;const a=()=>{const l={resume:()=>{},abort:()=>{}};return o=new Promise((c,u)=>{l.resume=c,l.abort=u}),l};s.abort();const i=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=we(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),c=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,f=At(()=>{u?.status==="idle"&&(f(),c())})}else this.manager.renderer.rendering.then(c)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:a}),o?o.then(i).catch(()=>r.reset()):i()})}},bu,wu,Cu,_u,ft,La,Va,Na,Za;_u=[de],Cu=[de],wu=[de],bu=[de];var tn=class{constructor(e,t){be(this,La,ee(ft,8,this)),ee(ft,11,this),be(this,Va,ee(ft,12,this)),ee(ft,15,this),be(this,Na,ee(ft,16,this)),ee(ft,19,this),be(this,Za,ee(ft,20,this)),ee(ft,23,this);const{effects:n,id:r,data:s={},disabled:o=!1,register:a=!0}=e;let i=r;this.manager=t,this.id=r,this.data=s,this.disabled=o,this.effects=()=>{var l;return[()=>{const{id:c,manager:u}=this;if(c!==i)return u?.registry.register(this),()=>u?.registry.unregister(this)},...(l=n?.())!=null?l:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),t&&a&&queueMicrotask(this.register)}register(){var e;return(e=this.manager)==null?void 0:e.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};ft=Qn(null);La=new WeakMap;Va=new WeakMap;Na=new WeakMap;Za=new WeakMap;ce(ft,4,"manager",_u,tn,La);ce(ft,4,"id",Cu,tn,Va);ce(ft,4,"data",wu,tn,Na);ce(ft,4,"disabled",bu,tn,Za);yn(ft,tn);var Bl=class{constructor(){this.map=Dr(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r){const i=this.cleanupFunctions.get(r);i?.(),this.cleanupFunctions.delete(r)}const o=new Map(n);o.set(e,t),this.map.value=o;const a=Pr(...t.effects());return this.cleanupFunctions.set(t,a),s},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const s=new Map(n);s.delete(e),this.map.value=s}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},xu,Su,ku,Iu,Au,Eu,Qo,nt,Ga,za,ja,Ft=class extends(Qo=tn,Eu=[de],Au=[de],Iu=[de],ku=[Ee],Su=[Ee],xu=[Ee],Qo){constructor(t,n){var r=t,{modifiers:s,type:o,sensors:a}=r,i=lu(r,["modifiers","type","sensors"]);super(i,n),ee(nt,5,this),be(this,Ga,ee(nt,8,this)),ee(nt,11,this),be(this,za,ee(nt,12,this)),ee(nt,15,this),be(this,ja,ee(nt,16,this,this.isDragSource?"dragging":"idle")),ee(nt,19,this),this.type=o,this.sensors=a,this.modifiers=s,this.alignment=i.alignment}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};nt=Qn(Qo);Ga=new WeakMap;za=new WeakMap;ja=new WeakMap;ce(nt,4,"type",Eu,Ft,Ga);ce(nt,4,"modifiers",Au,Ft,za);ce(nt,4,"status",Iu,Ft,ja);ce(nt,2,"isDropping",ku,Ft);ce(nt,2,"isDragging",Su,Ft);ce(nt,2,"isDragSource",xu,Ft);yn(nt,Ft);var Mu,Tu,Ru,$u,Du,Pu,qo,Le,Ha,Xa,Ya,Ua,Ka,Ot=class extends(qo=tn,Pu=[de],Du=[de],$u=[de],Ru=[de],Tu=[de],Mu=[Ee],qo){constructor(t,n){var r=t,{accept:s,collisionDetector:o,collisionPriority:a,type:i}=r,l=lu(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),ee(Le,5,this),be(this,Ha,ee(Le,8,this)),ee(Le,11,this),be(this,Xa,ee(Le,12,this)),ee(Le,15,this),be(this,Ya,ee(Le,16,this)),ee(Le,19,this),be(this,Ua,ee(Le,20,this)),ee(Le,23,this),be(this,Ka,ee(Le,24,this)),ee(Le,27,this),this.accept=s,this.collisionDetector=o,this.collisionPriority=a,this.type=i}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};Le=Qn(qo);Ha=new WeakMap;Xa=new WeakMap;Ya=new WeakMap;Ua=new WeakMap;Ka=new WeakMap;ce(Le,4,"accept",Pu,Ot,Ha);ce(Le,4,"type",Du,Ot,Xa);ce(Le,4,"collisionDetector",$u,Ot,Ya);ce(Le,4,"collisionPriority",Ru,Ot,Ua);ce(Le,4,"shape",Tu,Ot,Ka);ce(Le,2,"isDropTarget",Mu,Ot);yn(Le,Ot);var Vn=class extends ht{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Ip=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},ms,Fu=class{constructor(e){this.options=e,be(this,ms)}set controller(e){St(this,ms,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ne(this,ms))==null||t.activate(e)}};ms=new WeakMap;var Nn=class extends ht{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Ap=class{constructor(e){this.draggables=new Bl,this.droppables=new Bl,this.plugins=new _o(e),this.sensors=new _o(e),this.modifiers=new _o(e)}register(e,t){if(e instanceof Ft)return this.draggables.register(e.id,e);if(e instanceof Ot)return this.droppables.register(e.id,e);if(e.prototype instanceof Nn)return this.modifiers.register(e,t);if(e.prototype instanceof Vn)return this.sensors.register(e,t);if(e.prototype instanceof ht)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof tn)return e instanceof Ft?this.draggables.unregister(e.id,e):e instanceof Ot?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Nn)return this.modifiers.unregister(e);if(e.prototype instanceof Vn)return this.sensors.unregister(e);if(e.prototype instanceof ht)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Ou,Bu,Wu,Lu,Vu,Nu,Zu,Gu,zu,ir,gs,$n,Re,Qa,qa,Ja,ei,ti,lr;zu=[Ee],Gu=[de],Zu=[de],Nu=[de],Vu=[de],Lu=[de],Wu=[Ee],Bu=[Ee],Ou=[Ee];var $t=class{constructor(e){ee(Re,5,this),be(this,ir),be(this,gs),be(this,$n,new en(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Zt,be(this,Qa,ee(Re,8,this,!1)),ee(Re,11,this),be(this,qa,ee(Re,12,this,null)),ee(Re,15,this),be(this,Ja,ee(Re,16,this,null)),ee(Re,19,this),be(this,ei,ee(Re,20,this,null)),ee(Re,23,this),be(this,ti,ee(Re,24,this,[])),ee(Re,27,this),this.position=new Us({x:0,y:0}),be(this,lr,{x:0,y:0}),St(this,ir,e)}get shape(){const{current:e,initial:t,previous:n}=Ne(this,$n);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ne(this,$n).current=e:Ne(this,$n).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ne(this,ir).registry.draggables.get(t);return n&&St(this,gs,n),(e=n??Ne(this,gs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ne(this,ir).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(iu(au({},this.snapshot()),{transform:n}));return St(this,lr,n),n}snapshot(){return we(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ne(this,lr),shape:this.shape?Co(this.shape):null,position:Co(this.position),status:Co(this.status),canceled:this.canceled}))}reset(){qt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ne(this,$n).reset(),this.position.reset({x:0,y:0}),St(this,lr,{x:0,y:0}),this.modifiers=[]})}};Re=Qn(null);ir=new WeakMap;gs=new WeakMap;$n=new WeakMap;Qa=new WeakMap;qa=new WeakMap;Ja=new WeakMap;ei=new WeakMap;ti=new WeakMap;lr=new WeakMap;ce(Re,2,"shape",zu,$t);ce(Re,4,"canceled",Gu,$t,Qa);ce(Re,4,"activatorEvent",Zu,$t,qa);ce(Re,4,"sourceIdentifier",Nu,$t,Ja);ce(Re,4,"targetIdentifier",Vu,$t,ei);ce(Re,4,"modifiers",Lu,$t,ti);ce(Re,2,"source",Wu,$t);ce(Re,2,"target",Bu,$t);ce(Re,2,"transform",Ou,$t);yn(Re,$t);var Ep={get rendering(){return Promise.resolve()}};function Lt(e,t){return typeof e=="function"?e(t):e??t}var Mp=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(p=>p.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Lt(r.plugins,[]),o=Lt(r.sensors,[]),a=Lt(r.modifiers,[]),i=(n=r.renderer)!=null?n:Ep,l=new xp(this),c=new Ap(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new kp(this),this.dragOperation=new $t(this),this.collisionObserver=new Cp(this),this.plugins=[Sp,...s],this.modifiers=a,this.sensors=o;const{destroy:u}=this,f=Pr(()=>{var p,d,h;const g=we(()=>this.dragOperation.modifiers),y=this.modifiers;for(const v of g)y.includes(v)||v.destroy();this.dragOperation.modifiers=(h=(d=(p=this.dragOperation.source)==null?void 0:p.modifiers)==null?void 0:d.map(v=>{const{plugin:b,options:w}=Pa(v);return new b(this,w)}))!=null?h:y});this.destroy=()=>{f(),u()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},ju=e=>{throw TypeError(e)},ni=(e,t,n)=>t.has(e)||ju("Cannot "+n),re=(e,t,n)=>(ni(e,t,"read from private field"),t.get(e)),dt=(e,t,n)=>t.has(e)?ju("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),wt=(e,t,n,r)=>(ni(e,t,"write to private field"),t.set(e,n),n),Hu=(e,t,n)=>(ni(e,t,"access private method"),n);function Ks(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Tp(e,t){const n=e.getAnimations();if(n.length>0)for(const r of n){if(r.playState!=="running")continue;const{effect:s}=r,a=(Ks(s)?s.getKeyframes():[]).filter(t);if(a.length>0)return[a[a.length-1],r]}return null}function Qs(e){const{width:t,height:n,top:r,left:s,bottom:o,right:a}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:o,right:a}}function ri(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Wr(e){return"nodeType"in e}function Et(e){var t,n,r;return e?ri(e)?e:Wr(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function si(e){const{Document:t}=Et(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function pn(e){return!e||ri(e)?!1:e instanceof Et(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Xu(e){return e instanceof Et(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function wn(e){return e?ri(e)?e.document:Wr(e)?si(e)?e:pn(e)||Xu(e)?e.ownerDocument:document:document:document}function Rp(e){var t,n,r,s;const{documentElement:o}=wn(e),a=Et(e).visualViewport,i=(t=a?.width)!=null?t:o.clientWidth,l=(n=a?.height)!=null?n:o.clientHeight,c=(r=a?.offsetTop)!=null?r:0,u=(s=a?.offsetLeft)!=null?s:0;return{top:c,left:u,right:u+i,bottom:c+l,width:i,height:l}}function $p(e,t){if(Dp(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Dp(e){return e.tagName==="DETAILS"}function Ms(e,t=e.getBoundingClientRect(),n=0){var r,s,o,a,i;let l=t;const{ownerDocument:c}=e,u=(r=c.defaultView)!=null?r:window;let f=e.parentElement;for(;f&&f!==c.documentElement;){if(!$p(f)){const w=f.getBoundingClientRect(),C=n*(w.bottom-w.top),_=n*(w.right-w.left),S=n*(w.bottom-w.top),k=n*(w.right-w.left);l={top:Math.max(l.top,w.top-C),right:Math.min(l.right,w.right+_),bottom:Math.min(l.bottom,w.bottom+S),left:Math.max(l.left,w.left-k),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}f=f.parentElement}const p=u.visualViewport,d=(s=p?.offsetTop)!=null?s:0,h=(o=p?.offsetLeft)!=null?o:0,g=(a=p?.width)!=null?a:u.innerWidth,y=(i=p?.height)!=null?i:u.innerHeight,v=n*y,b=n*g;return l={top:Math.max(l.top,d-v),right:Math.min(l.right,h+g+b),bottom:Math.min(l.bottom,d+y+v),left:Math.max(l.left,h-b),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function Zn(e){return{x:e.clientX,y:e.clientY}}var Yu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Jo(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const s=r.contentDocument;s&&!t.has(s)&&n.push(...Jo(s,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const s=r.parent;s&&s.document&&s.document!==e&&n.push(...Jo(s.document,t))}}catch{}return n}function oi(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Uu(){var e,t;const n=oi()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ai(e){return!e||!Wr(e)?!1:e instanceof Et(e).ShadowRoot}function Ts(e){if(e&&Wr(e)){let t=e.getRootNode();if(ai(t))return t;if(t instanceof Document)return t}return wn(e)}function Ku(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Pp(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((o,a)=>{const i=r[a];if(Wl(o)&&Wl(i)&&(o.type!=="file"&&(o.value=i.value),o.type==="radio"&&o.name&&(o.name=`Cloned__${o.name}`)),Ll(o)&&Ll(i)&&i.width>0&&i.height>0){const l=o.getContext("2d");l?.drawImage(i,0,0)}}),n}function Wl(e){return"value"in e}function Ll(e){return e.tagName==="CANVAS"}function Qu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Fp(r)){const{contentDocument:s}=r;if(s){const{left:o,top:a}=r.getBoundingClientRect();return Qu(s,{x:t-o,y:n-a})}}return r}function Fp(e){return e?.tagName==="IFRAME"}var Vl=new WeakMap;function Op(e){return!!e.closest(`
|
|
2
|
-
input:not([disabled]),
|
|
3
|
-
select:not([disabled]),
|
|
4
|
-
textarea:not([disabled]),
|
|
5
|
-
button:not([disabled]),
|
|
6
|
-
a[href],
|
|
7
|
-
[contenteditable]:not([contenteditable="false"])
|
|
8
|
-
`)}var qu=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:s}]=e;t.removeEventListener(n,r,s)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],s=[];for(const o of n)for(const a of r){const{type:i,listener:l,options:c}=a,u=[o,a];o.addEventListener(i,l,c),this.entries.add(u),s.push(u)}return function(){for(const[a,{type:i,listener:l,options:c}]of s)a.removeEventListener(i,l,c)}}};function Gn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Bp(e){const t=new Set;let n=Gn(e);for(;n;)t.add(n),n=Gn(n);return t}function Wp(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Ju(e,t){const n=()=>performance.now();let r,s;return function(...o){const a=this;s?(r?.(),r=Wp(()=>{e.apply(a,o),s=n()},t-(n()-s))):(e.apply(a,o),s=n())}}function Lp(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function Vp(e,t=e.getBoundingClientRect()){const{width:n,height:r}=Ms(e,t);return n>0&&r>0}var Np=Yu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},vs,Zp=class extends Np{constructor(e){super(t=>{if(!re(this,vs)){wt(this,vs,!0);return}e(t,this)}),dt(this,vs,!1)}};vs=new WeakMap;var Nl=Array.from({length:100},(e,t)=>t/100),ed=75,cn,Rs,Ht,un,cr,Ge,vr,ur,$s,td,nd,rd=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,dt(this,$s),this.disconnect=()=>{var o,a,i;wt(this,vr,!0),(o=re(this,Ht))==null||o.disconnect(),(a=re(this,un))==null||a.disconnect(),re(this,cr).disconnect(),(i=re(this,Ge))==null||i.remove()},dt(this,cn,!0),dt(this,Rs),dt(this,Ht),dt(this,un),dt(this,cr),dt(this,Ge),dt(this,vr,!1),dt(this,ur,Ju(()=>{var o,a,i;const{element:l}=this;if((o=re(this,un))==null||o.disconnect(),re(this,vr)||!re(this,cn)||!l.isConnected)return;const c=(a=l.ownerDocument)!=null?a:document,{innerHeight:u,innerWidth:f}=(i=c.defaultView)!=null?i:window,p=l.getBoundingClientRect(),d=Ms(l,p),{top:h,left:g,bottom:y,right:v}=d,b=-Math.floor(h),w=-Math.floor(g),C=-Math.floor(f-v),_=-Math.floor(u-y),S=`${b}px ${C}px ${_}px ${w}px`;this.boundingClientRect=p,wt(this,un,new IntersectionObserver(k=>{const[I]=k,{intersectionRect:E}=I;(I.intersectionRatio!==1?I.intersectionRatio:Fr.intersectionRatio(E,Ms(l)))!==1&&re(this,ur).call(this)},{threshold:Nl,rootMargin:S,root:c})),re(this,un).observe(l),Hu(this,$s,td).call(this)},ed)),this.boundingClientRect=e.getBoundingClientRect(),wt(this,cn,Vp(e,this.boundingClientRect));let r=!0;this.callback=o=>{r&&(r=!1,n.skipInitial)||t(o)};const s=e.ownerDocument;n?.debug&&(wt(this,Ge,document.createElement("div")),re(this,Ge).style.background="rgba(0,0,0,0.15)",re(this,Ge).style.position="fixed",re(this,Ge).style.pointerEvents="none",s.body.appendChild(re(this,Ge))),wt(this,cr,new IntersectionObserver(o=>{var a,i;const l=o[o.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:f,height:p}=c,d=re(this,cn);wt(this,cn,u),!(!f&&!p)&&(d&&!u?((a=re(this,un))==null||a.disconnect(),this.callback(null),(i=re(this,Ht))==null||i.disconnect(),wt(this,Ht,void 0),re(this,Ge)&&(re(this,Ge).style.visibility="hidden")):re(this,ur).call(this),u&&!re(this,Ht)&&(wt(this,Ht,new Zp(re(this,ur))),re(this,Ht).observe(e)))},{threshold:Nl,root:s})),re(this,cn)&&!n.skipInitial&&this.callback(this.boundingClientRect),re(this,cr).observe(e)}};cn=new WeakMap;Rs=new WeakMap;Ht=new WeakMap;un=new WeakMap;cr=new WeakMap;Ge=new WeakMap;vr=new WeakMap;ur=new WeakMap;$s=new WeakSet;td=function(){re(this,vr)||(Hu(this,$s,nd).call(this),!Lp(this.boundingClientRect,re(this,Rs))&&(this.callback(this.boundingClientRect),wt(this,Rs,this.boundingClientRect)))};nd=function(){if(re(this,Ge)){const{top:e,left:t,width:n,height:r}=Ms(this.element);re(this,Ge).style.overflow="hidden",re(this,Ge).style.visibility="visible",re(this,Ge).style.top=`${Math.floor(e)}px`,re(this,Ge).style.left=`${Math.floor(t)}px`,re(this,Ge).style.width=`${Math.floor(n)}px`,re(this,Ge).style.height=`${Math.floor(r)}px`}};var os=new WeakMap,as=new WeakMap;function Gp(e,t){let n=os.get(e);return n||(n={disconnect:new rd(e,s=>{const o=os.get(e);o&&o.callbacks.forEach(a=>a(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),os.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(os.delete(e),n.disconnect())}}function zp(e,t){const n=new Set;for(const r of e){const s=Gp(r,t);n.add(s)}return()=>n.forEach(r=>r())}function jp(e,t){var n;const r=e.ownerDocument;if(!as.has(r)){const a=new AbortController,i=new Set;document.addEventListener("scroll",l=>i.forEach(c=>c(l)),{capture:!0,passive:!0,signal:a.signal}),as.set(r,{disconnect:()=>a.abort(),listeners:i})}const{listeners:s,disconnect:o}=(n=as.get(r))!=null?n:{};return!s||!o?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(o(),as.delete(r))})}var dr,fr,ys,ea,Hp=class{constructor(e,t,n){this.callback=t,dt(this,dr),dt(this,fr,!1),dt(this,ys),dt(this,ea,Ju(a=>{if(!re(this,fr)&&a.target&&"contains"in a.target&&typeof a.target.contains=="function"){for(const i of re(this,ys))if(a.target.contains(i)){this.callback(re(this,dr).boundingClientRect);break}}},ed));const r=Bp(e),s=zp(r,t),o=jp(e,re(this,ea));wt(this,ys,r),wt(this,dr,new rd(e,t,n)),this.disconnect=()=>{re(this,fr)||(wt(this,fr,!0),s(),o(),re(this,dr).disconnect())}}};dr=new WeakMap;fr=new WeakMap;ys=new WeakMap;ea=new WeakMap;function ta(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function kr(e){try{ta(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Zl(e){return!Yu||!e?!1:e===wn(e).scrollingElement}function sd(e){var t,n;const r=Et(e),s=Zl(e)?Rp(e):Qs(e),o=r.visualViewport,a=Zl(e)?{height:(t=o?.height)!=null?t:r.innerHeight,width:(n=o?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},i={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-a.width,y:e.scrollHeight-a.height}},l=i.current.y<=0,c=i.current.x<=0,u=i.current.y>=i.max.y,f=i.current.x>=i.max.x;return{rect:s,position:i,isTop:l,isLeft:c,isBottom:u,isRight:f}}function Xp(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:o,position:a}=sd(e),{x:i,y:l}=t??{x:0,y:0},c=!n&&a.current.y+l>0,u=!r&&a.current.y+l<a.max.y,f=!s&&a.current.x+i>0,p=!o&&a.current.x+i<a.max.x;return{top:c,bottom:u,left:f,right:p,x:f||p,y:c||u}}var ii=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const s of n)s();for(const s of r)s()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},Ds=new ii(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Yp=new ii(e=>setTimeout(e,50)),Ps=new Map,Up=Ps.clear.bind(Ps);function Gt(e,t=!1){if(!t)return Gl(e);let n=Ps.get(e);return n||(n=Gl(e),Ps.set(e,n),Yp.schedule(Up),n)}function Gl(e){return Et(e).getComputedStyle(e)}function Kp(e,t=Gt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Qp(e,t=Gt(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const o=t[s];return typeof o=="string"?n.test(o):!1})}var qp={excludeElement:!0,escapeShadowDOM:!0};function na(e,t=qp){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,o=new Set;function a(i){if(n!=null&&o.size>=n||!i)return o;if(si(i)&&i.scrollingElement!=null&&!o.has(i.scrollingElement))return o.add(i.scrollingElement),o;if(s&&ai(i))return a(i.host);if(!pn(i))return Xu(i)?a(i.parentElement):o;if(o.has(i))return o;const l=Gt(i,!0);if(r&&i===e||Qp(i,l)&&o.add(i),Kp(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&o.add(c),o}return a(i.parentNode)}return e?a(e):o}function Jp(e){const[t]=na(e,{limit:1});return t??null}function zn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Gn(e);for(;r;){if(r===t)return n;const s=Qs(r),{x:o,y:a}=em(r,s);n.x=n.x+s.left,n.y=n.y+s.top,n.scaleX=n.scaleX*o,n.scaleY=n.scaleY*a,r=Gn(r)}return n}function em(e,t=Qs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(pn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Gt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function tm(e){if(e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function li(e){if(e==="none")return null;const[t,n,r="0"]=e.split(" "),s={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(s.x)&&isNaN(s.y)?null:{x:isNaN(s.x)?0:s.x,y:isNaN(s.y)?0:s.y,z:isNaN(s.z)?0:s.z}}function ci(e){var t,n,r,s,o,a,i,l,c;const{scale:u,transform:f,translate:p}=e,d=tm(u),h=li(p),g=nm(f);if(!g&&!d&&!h)return null;const y={x:(t=d?.x)!=null?t:1,y:(n=d?.y)!=null?n:1},v={x:(r=h?.x)!=null?r:0,y:(s=h?.y)!=null?s:0},b={x:(o=g?.x)!=null?o:0,y:(a=g?.y)!=null?a:0,scaleX:(i=g?.scaleX)!=null?i:1,scaleY:(l=g?.scaleY)!=null?l:1};return{x:v.x+b.x,y:v.y+b.y,z:(c=h?.z)!=null?c:0,scaleX:y.x*b.scaleX,scaleY:y.y*b.scaleY}}function nm(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var kt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(kt||{}),rm={x:.2,y:.2},sm={x:10,y:10};function om(e,t,n,r=25,s=rm,o=sm){const{x:a,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:f,isRight:p}=sd(e),d=zn(e),h=Gt(e,!0),g=ci(h),y=g!==null?g?.scaleX<0:!1,v=g!==null?g?.scaleY<0:!1,b=new Fr(l.left*d.scaleX+d.x,l.top*d.scaleY+d.y,l.width*d.scaleX,l.height*d.scaleY),w={x:0,y:0},C={x:0,y:0},_={height:b.height*s.y,width:b.width*s.x};return(!c||v&&!u)&&i<=b.top+_.height&&n?.y!==1&&a>=b.left-o.x&&a<=b.right+o.x?(w.y=v?1:-1,C.y=r*Math.abs((b.top+_.height-i)/_.height)):(!u||v&&!c)&&i>=b.bottom-_.height&&n?.y!==-1&&a>=b.left-o.x&&a<=b.right+o.x&&(w.y=v?-1:1,C.y=r*Math.abs((b.bottom-_.height-i)/_.height)),(!p||y&&!f)&&a>=b.right-_.width&&n?.x!==-1&&i>=b.top-o.y&&i<=b.bottom+o.y?(w.x=y?-1:1,C.x=r*Math.abs((b.right-_.width-a)/_.width)):(!f||y&&!p)&&a<=b.left+_.width&&n?.x!==1&&i>=b.top-o.y&&i<=b.bottom+o.y&&(w.x=y?1:-1,C.x=r*Math.abs((b.left+_.width-a)/_.width)),{direction:w,speed:C}}function am(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function im(e,t=!1){if(am(e)){e.scrollIntoViewIfNeeded(t);return}if(!pn(e))return e.scrollIntoView();var n=Jp(e);if(!pn(n))return;const r=Gt(n,!0),s=parseInt(r.getPropertyValue("border-top-width")),o=parseInt(r.getPropertyValue("border-left-width")),a=e.offsetTop-n.offsetTop<n.scrollTop,i=e.offsetTop-n.offsetTop+e.clientHeight-s>n.scrollTop+n.clientHeight,l=e.offsetLeft-n.offsetLeft<n.scrollLeft,c=e.offsetLeft-n.offsetLeft+e.clientWidth-o>n.scrollLeft+n.clientWidth,u=a&&!i;(a||i)&&t&&(n.scrollTop=e.offsetTop-n.offsetTop-n.clientHeight/2-s+e.clientHeight/2),(l||c)&&t&&(n.scrollLeft=e.offsetLeft-n.offsetLeft-n.clientWidth/2-o+e.clientWidth/2),(a||i||l||c)&&!t&&e.scrollIntoView(u)}function lm(e,t,n){const{scaleX:r,scaleY:s,x:o,y:a}=t,i=e.left+o+(1-r)*parseFloat(n),l=e.top+a+(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width*r:e.width,u=s?e.height*s:e.height;return{width:c,height:u,top:l,right:i+c,bottom:l+u,left:i}}function cm(e,t,n){const{scaleX:r,scaleY:s,x:o,y:a}=t,i=e.left-o-(1-r)*parseFloat(n),l=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width/r:e.width,u=s?e.height/s:e.height;return{width:c,height:u,top:l,right:i+c,bottom:l+u,left:i}}function um({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var dm=new ii(e=>setTimeout(e,0)),yr=new Map,fm=yr.clear.bind(yr);function hm(e){const t=e.ownerDocument;let n=yr.get(t);if(n)return n;n=t.getAnimations(),yr.set(t,n),dm.schedule(fm);const r=n.filter(s=>Ks(s.effect)&&s.effect.target===e);return yr.set(e,r),n}function pm(e,t){const n=hm(e).filter(r=>{var s,o;if(Ks(r.effect)){const{target:a}=r.effect;if((o=a&&((s=t.isValidTarget)==null?void 0:s.call(t,a)))!=null?o:!0)return r.effect.getKeyframes().some(l=>{for(const c of t.properties)if(l[c])return!0})}}).map(r=>{const{effect:s,currentTime:o}=r,a=s?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof a=="number"&&typeof o=="number"&&o<a)return r.currentTime=a,()=>{r.currentTime=o}});if(n.length>0)return()=>n.forEach(r=>r?.())}var Vt=class extends Fr{constructor(e,t={}){var n,r,s,o;const{frameTransform:a=zn(e),ignoreTransforms:i,getBoundingClientRect:l=Qs}=t,c=pm(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||oi())&&_.contains(e)}),u=l(e);let{top:f,left:p,width:d,height:h}=u,g;const y=Gt(e),v=ci(y),b={x:(n=v?.scaleX)!=null?n:1,y:(r=v?.scaleY)!=null?r:1},w=mm(e,y);c?.(),v&&(g=cm(u,v,y.transformOrigin),(i||w)&&(f=g.top,p=g.left,d=g.width,h=g.height));const C={width:(s=g?.width)!=null?s:d,height:(o=g?.height)!=null?o:h};if(w&&!i&&g){const _=lm(g,w,y.transformOrigin);f=_.top,p=_.left,d=_.width,h=_.height,b.x=w.scaleX,b.y=w.scaleY}a&&(i||(p*=a.scaleX,d*=a.scaleX,f*=a.scaleY,h*=a.scaleY),p+=a.x,f+=a.y),super(p,f,d,h),this.scale=b,this.intrinsicWidth=C.width,this.intrinsicHeight=C.height}};function mm(e,t){var n;const r=e.getAnimations();let s=null;if(!r.length)return null;for(const o of r){if(o.playState!=="running")continue;const a=Ks(o.effect)?o.effect.getKeyframes():[],i=a[a.length-1];if(!i)continue;const{transform:l,translate:c,scale:u}=i;if(l||c||u){const f=ci({transform:typeof l=="string"&&l?l:t.transform,translate:typeof c=="string"&&c?c:t.translate,scale:typeof u=="string"&&u?u:t.scale});f&&(s=s?{x:s.x+f.x,y:s.y+f.y,z:(n=s.z)!=null?n:f.z,scaleX:s.scaleX*f.scaleX,scaleY:s.scaleY*f.scaleY}:f)}}return s}function br(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var gm=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(br(n))for(const[r,s]of Object.entries(e)){const o=`${t}${r}`;this.initial.has(o)||this.initial.set(o,n.style.getPropertyValue(o)),n.style.setProperty(o,typeof s=="string"?s:`${s}px`)}}remove(e,t=""){const{element:n}=this;if(br(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(br(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function mn(e){return e?e instanceof Et(e).Element||Wr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function ui(e){if(!e)return!1;const{KeyboardEvent:t}=Et(e.target);return e instanceof t}function vm(e){if(!e)return!1;const{PointerEvent:t}=Et(e.target);return e instanceof t}function ym(e){if(!mn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||bm(e)}function bm(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var xo={};function ra(e){const t=xo[e]==null?0:xo[e]+1;return xo[e]=t,`${e}-${t}`}var wm=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=Pt.distance(t.shape.center,n);return{id:r,value:1/s,type:Ba.PointerIntersection,priority:Oa.High}}return null},Cm=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,o=Pt.distance(t.shape.center,s.current),i=r/(n.current.area+t.shape.area-r)/o;return{id:t.id,value:i,type:Ba.ShapeIntersection,priority:Oa.Normal}}return null},_m=e=>{var t;return(t=wm(e))!=null?t:Cm(e)},xm=Object.create,di=Object.defineProperty,Sm=Object.defineProperties,km=Object.getOwnPropertyDescriptor,Im=Object.getOwnPropertyDescriptors,Fs=Object.getOwnPropertySymbols,od=Object.prototype.hasOwnProperty,ad=Object.prototype.propertyIsEnumerable,id=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),qn=e=>{throw TypeError(e)},sa=(e,t,n)=>t in e?di(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ir=(e,t)=>{for(var n in t||(t={}))od.call(t,n)&&sa(e,n,t[n]);if(Fs)for(var n of Fs(t))ad.call(t,n)&&sa(e,n,t[n]);return e},fi=(e,t)=>Sm(e,Im(t)),zl=(e,t)=>di(e,"name",{value:t,configurable:!0}),ld=(e,t)=>{var n={};for(var r in e)od.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Fs)for(var r of Fs(e))t.indexOf(r)<0&&ad.call(e,r)&&(n[r]=e[r]);return n},Jn=e=>{var t;return[,,,xm((t=e?.[id("metadata")])!=null?t:null)]},cd=["class","method","getter","setter","accessor","field","value","get","set"],hr=e=>e!==void 0&&typeof e!="function"?qn("Function expected"):e,Am=(e,t,n,r,s)=>({kind:cd[e],name:t,metadata:r,addInitializer:o=>n._?qn("Already initialized"):s.push(hr(o||null))}),Cn=(e,t)=>sa(t,id("metadata"),e[3]),Pe=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},_t=(e,t,n,r,s,o)=>{var a,i,l,c,u,f=t&7,p=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?p?1:2:0,g=cd[f+5],y=f>3&&(e[h-1]=[]),v=e[h]||(e[h]=[]),b=f&&(!d&&!p&&(s=s.prototype),f<5&&(f>3||!d)&&km(f<4?s:{get[n](){return xe(this,o)},set[n](C){return rt(this,o,C)}},n));f?d&&f<4&&zl(o,(f>2?"set ":f>1?"get ":"")+n):zl(s,n);for(var w=r.length-1;w>=0;w--)c=Am(f,n,l={},e[3],v),f&&(c.static=p,c.private=d,u=c.access={has:d?C=>Em(s,C):C=>n in C},f^3&&(u.get=d?C=>(f^1?xe:gn)(C,s,f^4?o:b.get):C=>C[n]),f>2&&(u.set=d?(C,_)=>rt(C,s,_,f^4?o:b.set):(C,_)=>C[n]=_)),i=(0,r[w])(f?f<4?d?o:b[g]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?hr(i)&&(f>4?y.unshift(i):f?d?o=i:b[g]=i:s=i):typeof i!="object"||i===null?qn("Object expected"):(hr(a=i.get)&&(b.get=a),hr(a=i.set)&&(b.set=a),hr(a=i.init)&&y.unshift(a));return f||Cn(e,s),b&&di(s,n,b),d?f^4?o:b:s},hi=(e,t,n)=>t.has(e)||qn("Cannot "+n),Em=(e,t)=>Object(t)!==t?qn('Cannot use the "in" operator on this value'):e.has(t),xe=(e,t,n)=>(hi(e,t,"read from private field"),n?n.call(e):t.get(e)),$e=(e,t,n)=>t.has(e)?qn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rt=(e,t,n,r)=>(hi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),gn=(e,t,n)=>(hi(e,t,"access private method"),n),jl={role:"button",roleDescription:"draggable"},Mm="dnd-kit-description",Tm="dnd-kit-announcement",Rm={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},$m={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function Dm(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Pm(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Fm(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var Om=["dragover","dragmove"],Bm=class extends ht{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Mm,announcement:s=Tm}={},announcements:o=$m,screenReaderInstructions:a=Rm,debounce:i=500}=t??{},l=n?`${r}-${n}`:ra(r),c=n?`${s}-${n}`:ra(s);let u,f,p,d;const h=(_=d)=>{!p||!_||p?.nodeValue!==_&&(p.nodeValue=_)},g=()=>Ds.schedule(h),y=Wm(g,i),v=Object.entries(o).map(([_,S])=>this.manager.monitor.addEventListener(_,(k,I)=>{const E=p;if(!E)return;const A=S?.(k,I);A&&E.nodeValue!==A&&(d=A,Om.includes(_)?y():(g(),y.cancel()))})),b=()=>{let _=[];u?.isConnected||(u=Pm(l,a.draggable),_.push(u)),f?.isConnected||(f=Fm(c),p=document.createTextNode(""),f.appendChild(p),_.push(f)),_.length>0&&document.body.append(..._)},w=new Set;function C(){for(const _ of w)_()}this.registerEffect(()=>{var _;w.clear();for(const S of this.manager.registry.draggables.value){const k=(_=S.handle)!=null?_:S.element;if(k){(!u||!f)&&w.add(b),(!Dm(k)||oi())&&!k.hasAttribute("tabindex")&&w.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&w.add(()=>k.setAttribute("role",jl.role)),k.hasAttribute("aria-roledescription")||w.add(()=>k.setAttribute("aria-roledescription",jl.roleDescription)),k.hasAttribute("aria-describedby")||w.add(()=>k.setAttribute("aria-describedby",l));for(const E of["aria-pressed","aria-grabbed"]){const A=String(S.isDragging);k.getAttribute(E)!==A&&w.add(()=>k.setAttribute(E,A))}const I=String(S.disabled);k.getAttribute("aria-disabled")!==I&&w.add(()=>k.setAttribute("aria-disabled",I))}}w.size>0&&Ds.schedule(C)}),this.destroy=()=>{super.destroy(),u?.remove(),f?.remove(),v.forEach(_=>_())}}};function Wm(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Lm=class extends ht{constructor(e,t){super(e,t),this.manager=e;const n=As(()=>{var r;return wn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=At(()=>{var r;const{dragOperation:s}=this.manager,{cursor:o="grabbing",nonce:a}=(r=this.options)!=null?r:{};if(s.status.initialized){const i=n.value,l=i.createElement("style");return a&&l.setAttribute("nonce",a),l.textContent=`* { cursor: ${o} !important; }`,i.head.appendChild(l),()=>l.remove()}})}},Os=new Map,ud,dd,fd,hd,oa,wr,Nt,pi,jn,pd,md,gd,vd,_n=class extends(oa=Br,hd=[de],fd=[Ee],dd=[Ee],ud=[Ee],oa){constructor(e){super(e),Pe(Nt,5,this),$e(this,jn),$e(this,wr,new Set),$e(this,pi,Pe(Nt,8,this,new Set)),Pe(Nt,11,this),this.registerEffect(gn(this,jn,pd))}register(e){return xe(this,wr).add(e),()=>{xe(this,wr).delete(e)}}addRoot(e){return we(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{we(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return Ts((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return Ts((e=t?.element)!=null?e:null)}get roots(){const{status:e}=this.manager.dragOperation;if(e.initializing||e.initialized){const t=[this.sourceRoot,this.targetRoot].filter(n=>n!=null);return new Set([...t,...this.additionalRoots])}return new Set}};Nt=Jn(oa);wr=new WeakMap;pi=new WeakMap;jn=new WeakSet;pd=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of xe(this,wr))t.push(gn(this,jn,md).call(this,n,r));return()=>{for(const n of t)n()}};md=function(e,t){let n=Os.get(e);n||(n=new Map,Os.set(e,n));let r=n.get(t);if(!r){const o=si(e)?gn(this,jn,gd).call(this,e,n,t):gn(this,jn,vd).call(this,e,n,t);if(!o)return()=>{};r=o,n.set(t,r)}r.refCount++;let s=!1;return()=>{s||(s=!0,r.refCount--,r.refCount===0&&r.cleanup())}};gd=function(e,t,n){const r=e.createElement("style");r.textContent=n,e.head.prepend(r);const s=new MutationObserver(o=>{for(const a of o)for(const i of Array.from(a.removedNodes))if(i===r){e.head.prepend(r);return}});return s.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{s.disconnect(),r.remove(),t.delete(n),t.size===0&&Os.delete(e)}}};vd=function(e,t,n){!("adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets))&&process.env.NODE_ENV!=="production"&&console.error("Cannot inject styles: This browser doesn't support adoptedStyleSheets");const r=e.ownerDocument.defaultView,{CSSStyleSheet:s}=r??{};if(!s)return process.env.NODE_ENV!=="production"&&console.error("Cannot inject styles: CSSStyleSheet constructor not available"),null;const o=new s;return o.replaceSync(n),e.adoptedStyleSheets.push(o),{refCount:0,cleanup:()=>{var a;if(ai(e)&&((a=e.host)!=null&&a.isConnected)){const i=e.adoptedStyleSheets.indexOf(o);i!==-1&&e.adoptedStyleSheets.splice(i,1)}t.delete(n),t.size===0&&Os.delete(e)}}};_t(Nt,4,"additionalRoots",hd,_n,pi);_t(Nt,2,"sourceRoot",fd,_n);_t(Nt,2,"targetRoot",dd,_n);_t(Nt,2,"roots",ud,_n);Cn(Nt,_n);var Lr="data-dnd-",aa=`${Lr}dropping`,Qe="--dnd-",Dt=`${Lr}dragging`,Bs=`${Lr}placeholder`,Vm=[Dt,Bs,"popover","aria-pressed","aria-grabbing"],Nm=["view-transition-name"],Zm=`
|
|
9
|
-
:is(:root,:host) [${Dt}] {
|
|
10
|
-
position: fixed !important;
|
|
11
|
-
pointer-events: none !important;
|
|
12
|
-
touch-action: none;
|
|
13
|
-
z-index: calc(infinity);
|
|
14
|
-
will-change: translate;
|
|
15
|
-
top: var(${Qe}top, 0px) !important;
|
|
16
|
-
left: var(${Qe}left, 0px) !important;
|
|
17
|
-
right: unset !important;
|
|
18
|
-
bottom: unset !important;
|
|
19
|
-
width: var(${Qe}width, auto);
|
|
20
|
-
max-width: var(${Qe}width, auto);
|
|
21
|
-
height: var(${Qe}height, auto);
|
|
22
|
-
max-height: var(${Qe}height, auto);
|
|
23
|
-
transition: var(${Qe}transition) !important;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
:is(:root,:host) [${Bs}] {
|
|
27
|
-
transition: none;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
:is(:root,:host) [${Bs}='hidden'] {
|
|
31
|
-
visibility: hidden;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
[${Dt}] * {
|
|
35
|
-
pointer-events: none !important;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
[${Dt}]:not([${aa}]) {
|
|
39
|
-
translate: var(${Qe}translate) !important;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
[${Dt}][style*='${Qe}scale'] {
|
|
43
|
-
scale: var(${Qe}scale) !important;
|
|
44
|
-
transform-origin: var(${Qe}transform-origin) !important;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@layer dnd-kit {
|
|
48
|
-
:where([${Dt}][popover]) {
|
|
49
|
-
overflow: visible;
|
|
50
|
-
background: unset;
|
|
51
|
-
border: unset;
|
|
52
|
-
margin: unset;
|
|
53
|
-
padding: unset;
|
|
54
|
-
color: inherit;
|
|
55
|
-
|
|
56
|
-
&:is(input, button) {
|
|
57
|
-
border: revert;
|
|
58
|
-
background: revert;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
[${Dt}]::backdrop, [${Lr}overlay]:not([${Dt}]) {
|
|
63
|
-
display: none;
|
|
64
|
-
visibility: hidden;
|
|
65
|
-
}
|
|
66
|
-
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Gm(e,t="hidden"){return we(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=zm(n,r.registry.droppables),o=[],a=Pp(n),{remove:i}=a;return jm(s,a,o),Hm(a,t),a.remove=()=>{o.forEach(l=>l()),i.call(a)},a})}function zm(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Lr}${ra("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function jm(e,t,n){for(const[r,s]of e){if(!r.element)continue;const o=`[${s}]`,a=t.matches(o)?t:t.querySelector(o);if(r.element.removeAttribute(s),!a)continue;const i=r.element;r.proxy=a,a.removeAttribute(s),Vl.set(i,a),n.push(()=>{Vl.delete(i),r.proxy=void 0})}}function Hm(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Bs,t)}function yd(e,t){return e===t?!0:Gn(e)===Gn(t)}function Hl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&mn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>kr(t))}function ia(e){return e.tagName==="TR"}function Xm(e,t,n){const r=new MutationObserver(s=>{let o=!1;for(const a of s){if(a.target!==e){o=!0;continue}if(a.type!=="attributes")continue;const i=a.attributeName;if(i.startsWith("aria-")||Vm.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(br(e)&&br(t)){const c=e.style;for(const u of Array.from(t.style))c.getPropertyValue(u)===""&&t.style.removeProperty(u);for(const u of Array.from(c)){if(Nm.includes(u)||u.startsWith(Qe))continue;const f=c.getPropertyValue(u);t.style.setProperty(u,f)}}}else l!==null?t.setAttribute(i,l):t.removeAttribute(i)}o&&n&&(t.innerHTML=e.innerHTML)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function Ym(e,t,n){const r=new MutationObserver(s=>{for(const o of s)if(o.addedNodes.length!==0)for(const a of Array.from(o.addedNodes)){if(a.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),kr(n);return}if(a.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),kr(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Um(e){return new ResizeObserver(()=>{var t,n;const r=new Vt(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-r.width)*s.x+e.delta.x,a=(e.height-r.height)*s.y+e.delta.y,i=Uu();if(e.styles.set({width:r.width-e.widthOffset,height:r.height-e.heightOffset,top:e.top+a+i.y,left:e.left+o+i.x},Qe),(n=e.getElementMutationObserver())==null||n.takeRecords(),ia(e.element)&&ia(e.placeholder)){const l=Array.from(e.element.cells),c=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(l.map(u=>u.style.width));for(const[u,f]of l.entries()){const p=c[u];f.style.width=`${p.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Vt(e.feedbackElement)})}var Km=250,Qm="ease";function qm(e){var t,n,r,s;const{animation:o}=e;if(typeof o=="function"){const b=o({element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(b).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:a=Km,easing:i=Qm}=o??{};kr(e.feedbackElement);const[,l]=(t=Tp(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:yd(e.feedbackElement,c)?null:void 0},f=new Vt(e.feedbackElement,u),p=(r=li(Gt(e.feedbackElement).translate))!=null?r:e.translate,d=new Vt(c,u),h=Fr.delta(f,d,e.alignment),g={x:p.x-h.x,y:p.y-h.y},y=Math.round(f.intrinsicHeight)!==Math.round(d.intrinsicHeight)?{minHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`],maxHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`]}:{},v=Math.round(f.intrinsicWidth)!==Math.round(d.intrinsicWidth)?{minWidth:[`${f.intrinsicWidth}px`,`${d.intrinsicWidth}px`],maxWidth:[`${f.intrinsicWidth}px`,`${d.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Qe),e.feedbackElement.setAttribute(aa,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),um({element:e.feedbackElement,keyframes:fi(Ir(Ir({},y),v),{translate:[`${p.x}px ${p.y}px 0`,`${g.x}px ${g.y}px 0`]}),options:{duration:Ku(Et(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?a:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(aa),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var bd,la,Ar,mi,bs,wd,Cd,Er=class extends(la=ht,bd=[de],la){constructor(t,n){super(t,n),$e(this,bs),$e(this,mi,Pe(Ar,8,this)),Pe(Ar,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(_n),s=r?.register(Zm);if(s){const o=this.destroy.bind(this);this.destroy=()=>{s(),o()}}this.registerEffect(gn(this,bs,wd).bind(this,r)),this.registerEffect(gn(this,bs,Cd))}};Ar=Jn(la);mi=new WeakMap;bs=new WeakSet;wd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Ts(t);if(n)return e.addRoot(n)};Cd=function(){var e,t,n;const{state:r,manager:s,options:o}=this,{dragOperation:a}=s,{position:i,source:l,status:c}=a;if(c.idle){r.current={},r.initial={};return}if(!l)return;const{element:u,feedback:f}=l;if(!u||f==="none"||!c.initialized||c.initializing)return;const{initial:p}=r,d=(e=this.overlay)!=null?e:u,h=zn(d),g=zn(u),y=!yd(u,d),v=new Vt(u,{frameTransform:y?g:null,ignoreTransforms:!y}),b={x:g.scaleX/h.scaleX,y:g.scaleY/h.scaleY};let{width:w,height:C,top:_,left:S}=v;y&&(w=w/b.x,C=C/b.y);const k=new gm(d),{transition:I,translate:E,boxSizing:A,paddingBlockStart:R,paddingBlockEnd:T,paddingInlineStart:M,paddingInlineEnd:$,borderInlineStartWidth:O,borderInlineEndWidth:P,borderBlockStartWidth:V,borderBlockEndWidth:Y}=Gt(u),K=f==="clone",fe=A==="content-box",pe=fe?parseInt(M)+parseInt($)+parseInt(O)+parseInt(P):0,Ce=fe?parseInt(R)+parseInt(T)+parseInt(V)+parseInt(Y):0,X=f!=="move"&&!this.overlay?Gm(l,K?"clone":"hidden"):null,Se=we(()=>ui(s.dragOperation.activatorEvent));if(E!=="none"){const ne=li(E);ne&&!p.translate&&(p.translate=ne)}if(!p.transformOrigin){const ne=we(()=>i.current);p.transformOrigin={x:(ne.x-S*h.scaleX-h.x)/(w*h.scaleX),y:(ne.y-_*h.scaleY-h.y)/(C*h.scaleY)}}const{transformOrigin:te}=p,qe=_*h.scaleY+h.y,J=S*h.scaleX+h.x;if(!p.coordinates&&(p.coordinates={x:J,y:qe},b.x!==1||b.y!==1)){const{scaleX:ne,scaleY:ge}=g,{x:We,y:vt}=te;p.coordinates.x+=(w*ne-w)*We,p.coordinates.y+=(C*ge-C)*vt}p.dimensions||(p.dimensions={width:w,height:C}),p.frameTransform||(p.frameTransform=h);const Z={x:p.coordinates.x-J,y:p.coordinates.y-qe},he={width:(p.dimensions.width*p.frameTransform.scaleX-w*h.scaleX)*te.x,height:(p.dimensions.height*p.frameTransform.scaleY-C*h.scaleY)*te.y},De={x:Z.x/h.scaleX+he.width,y:Z.y/h.scaleY+he.height},se={left:S+De.x,top:_+De.y};d.setAttribute(Dt,"true");const Me=we(()=>a.transform),Be=(t=p.translate)!=null?t:{x:0,y:0},ze=Me.x*h.scaleX+Be.x,N=Me.y*h.scaleY+Be.y,Q=Uu();k.set({width:w-pe,height:C-Ce,top:se.top+Q.y,left:se.left+Q.x,translate:`${ze}px ${N}px 0`,transition:I?`${I}, translate 0ms linear`:"",scale:y?`${b.x} ${b.y}`:"","transform-origin":`${te.x*100}% ${te.y*100}%`},Qe),X&&(u.insertAdjacentElement("afterend",X),o?.rootElement&&(typeof o.rootElement=="function"?o.rootElement(l):o.rootElement).appendChild(u)),ta(d)&&(d.hasAttribute("popover")||d.setAttribute("popover","manual"),kr(d),d.addEventListener("beforetoggle",Hl));let Je,je,ie;const pt=Um({placeholder:X,element:u,feedbackElement:d,frameTransform:h,transformOrigin:te,width:w,height:C,top:_,left:S,widthOffset:pe,heightOffset:Ce,delta:De,styles:k,dragOperation:a,getElementMutationObserver:()=>Je,getSavedCellWidths:()=>ie,setSavedCellWidths:ne=>{ie=ne}}),Mt=new Vt(d);we(()=>a.shape=Mt);const lt=Et(d),et=ne=>{this.manager.actions.stop({event:ne})},mt=Ku(lt);Se&<.addEventListener("resize",et),we(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),X&&(pt.observe(X),Je=Xm(u,X,K),je=Ym(u,X,d));const gt=(n=s.dragOperation.source)==null?void 0:n.id,ct=()=>{var ne;if(!Se||gt==null)return;const ge=s.registry.draggables.get(gt),We=(ne=ge?.handle)!=null?ne:ge?.element;pn(We)&&We.focus()},j=()=>{var ne;if(Je?.disconnect(),je?.disconnect(),pt.disconnect(),lt.removeEventListener("resize",et),ta(d)&&(d.removeEventListener("beforetoggle",Hl),d.removeAttribute("popover")),d.removeAttribute(Dt),k.reset(),ie&&ia(u)){const We=Array.from(u.cells);for(const[vt,yt]of We.entries())yt.style.width=(ne=ie[vt])!=null?ne:""}l.status="idle";const ge=r.current.translate!=null;X&&(ge||X.parentElement!==d.parentElement)&&d.isConnected&&X.replaceWith(d),X?.remove()},ue=o?.dropAnimation,He=this,Fe=Pr(()=>{var ne;const{transform:ge,status:We}=a;if(!(!ge.x&&!ge.y&&!r.current.translate)&&We.dragging){const vt=(ne=p.translate)!=null?ne:{x:0,y:0},yt={x:ge.x/h.scaleX+vt.x,y:ge.y/h.scaleY+vt.y},G=r.current.translate,H=we(()=>a.modifiers),U=we(()=>{var ae;return(ae=a.shape)==null?void 0:ae.current}),oe=Se&&!mt?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${I}, translate ${oe}`,translate:`${yt.x}px ${yt.y}px 0`},Qe),Je?.takeRecords(),U&&U!==Mt&&G&&!H.length){const ae=Pt.delta(yt,G);a.shape=Fr.from(U.boundingRectangle).translate(ae.x*h.scaleX,ae.y*h.scaleY)}else a.shape=new Vt(d);r.current.translate=yt}},function(){if(a.status.dropped){this.dispose(),l.status="dropping";const ne=He.dropAnimation!==void 0?He.dropAnimation:ue;let ge=r.current.translate;const We=ge!=null;if(!ge&&u!==d&&(ge={x:0,y:0}),!ge||ne===null){j();return}s.renderer.rendering.then(()=>{qm({element:u,feedbackElement:d,placeholder:X,translate:ge,moved:We,transition:I,alignment:l.alignment,styles:k,animation:ne??void 0,getElementMutationObserver:()=>Je,cleanup:j,restoreFocus:ct})})}});return()=>{j(),Fe()}};_t(Ar,4,"overlay",bd,Er,mi);Cn(Ar,Er);Er.configure=bn(Er);var ca=Er,er=!0,Jm=!1,_d,xd,Sd,kd,Ut,gi,vi;kd=(Sd=[de],kt.Forward),xd=(_d=[de],kt.Reverse);var Mr=class{constructor(){$e(this,gi,Pe(Ut,8,this,er)),Pe(Ut,11,this),$e(this,vi,Pe(Ut,12,this,er)),Pe(Ut,15,this)}isLocked(e){return e===kt.Idle?!1:e==null?this[kt.Forward]===er&&this[kt.Reverse]===er:this[e]===er}unlock(e){e!==kt.Idle&&(this[e]=Jm)}};Ut=Jn(null);gi=new WeakMap;vi=new WeakMap;_t(Ut,4,kd,Sd,Mr,gi);_t(Ut,4,xd,_d,Mr,vi);Cn(Ut,Mr);var eg=[kt.Forward,kt.Reverse],Xl=class{constructor(){this.x=new Mr,this.y=new Mr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},tg=class extends ht{constructor(e){super(e);const t=Dr(new Xl);let n=null;this.signal=t,At(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Xl;return}const{delta:s}=e.dragOperation.position;if(n){const o={x:Yl(s.x,n.x),y:Yl(s.y,n.y)},a=t.peek();qt(()=>{for(const i of nu)for(const l of eg)o[i]===l&&a[i].unlock(l);t.value=a})}n=s})}get current(){return this.signal.peek()}};function Yl(e,t){return Math.sign(e-t)}var Id,ua,Tr,yi,Xt,da,qs=class extends(ua=Br,Id=[de],ua){constructor(e){super(e),$e(this,yi,Pe(Tr,8,this,!1)),Pe(Tr,11,this),$e(this,Xt),$e(this,da,()=>{if(!xe(this,Xt))return;const{element:o,by:a}=xe(this,Xt);a.y&&(o.scrollTop+=a.y),a.x&&(o.scrollLeft+=a.x)}),this.scroll=o=>{var a;if(this.disabled)return!1;const i=this.getScrollableElements();if(!i)return rt(this,Xt,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:u}=o??{},f=u?{x:Ul(u.x),y:Ul(u.y)}:void 0,p=f?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const d of i){const h=Xp(d,u);if(h.x||h.y){const{speed:g,direction:y}=om(d,c,f);if(p)for(const v of nu)p[v].isLocked(y[v])&&(g[v]=0,y[v]=0);if(y.x||y.y){const{x:v,y:b}=u??y,w=v*g.x,C=b*g.y;if(w||C){const _=(a=xe(this,Xt))==null?void 0:a.by;if(this.autoScrolling&&_&&(_.x&&!w||_.y&&!C))continue;return rt(this,Xt,{element:d,by:{x:w,y:C}}),Ds.schedule(xe(this,da)),!0}}}}}return rt(this,Xt,void 0),!1};let t=null,n=null;const r=As(()=>{const{position:o,source:a}=e.dragOperation;if(!o)return null;const i=Qu(Ts(a?.element),o.current);return i&&(t=i),i??t}),s=As(()=>{const o=r.value,{documentElement:a}=wn(o);if(!o||o===a){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=na(l,{excludeElement:!1});return n=c,c}}if(o){const i=na(o,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},xr);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new tg(e),this.destroy=e.monitor.addEventListener("dragmove",o=>{this.disabled||o.defaultPrevented||!ui(e.dragOperation.activatorEvent)||!o.by||this.scroll({by:o.by})&&o.preventDefault()})}};Tr=Jn(ua);yi=new WeakMap;Xt=new WeakMap;da=new WeakMap;_t(Tr,4,"autoScrolling",Id,qs,yi);Cn(Tr,qs);function Ul(e){return e>0?kt.Forward:e<0?kt.Reverse:kt.Idle}var ng=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},rg=new ng(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),sg=10,Ad=class extends ht{constructor(e,t){super(e);const n=e.registry.plugins.get(qs);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=At(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const a=setInterval(()=>rg.schedule(n.scroll),sg);return()=>{clearInterval(a)}}else n.autoScrolling=!1})}},Kl={capture:!0,passive:!0},pr,og=class extends Br{constructor(e){super(e),$e(this,pr),this.handleScroll=()=>{xe(this,pr)==null&&rt(this,pr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),rt(this,pr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=At(()=>{var n,r,s;if(t.status.dragging){const a=(s=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?s:document;return a.addEventListener("scroll",this.handleScroll,Kl),()=>{a.removeEventListener("scroll",this.handleScroll,Kl)}}})}};pr=new WeakMap;var ag=class extends ht{constructor(e,t){super(e,t),this.manager=e,this.destroy=At(()=>{var n;const{dragOperation:r}=this.manager,{nonce:s}=(n=this.options)!=null?n:{};if(r.status.initialized){const o=document.createElement("style");return s&&o.setAttribute("nonce",s),o.textContent="* { user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(o),So(),document.addEventListener("selectionchange",So,{capture:!0}),()=>{document.removeEventListener("selectionchange",So,{capture:!0}),o.remove()}}})}};function So(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var mr=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),Dn,Ws=class extends Vn{constructor(t,n){super(t),this.manager=t,this.options=n,$e(this,Dn,[]),this.listeners=new qu,this.handleSourceKeyDown=(r,s,o)=>{if(this.disabled||r.defaultPrevented||!mn(r.target)||s.disabled)return;const{keyboardCodes:a=mr.keyboardCodes,preventActivation:i=mr.preventActivation}=o??{};a.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(i?.(r,s)||this.handleStart(r,s,o))}}bind(t,n=this.options){return At(()=>{var s;const o=(s=t.handle)!=null?s:t.element,a=i=>{ui(i)&&this.handleSourceKeyDown(i,t,n)};if(o)return o.addEventListener("keydown",a),()=>{o.removeEventListener("keydown",a)}})}handleStart(t,n,r){const{element:s}=n;if(!s)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),im(s);const{center:o}=new Vt(s);if(this.manager.actions.start({event:t,coordinates:{x:o.x,y:o.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const i=wn(s),l=[this.listeners.bind(i,[{type:"keydown",listener:c=>this.handleKeyDown(c,n,r),options:{capture:!0}}])];xe(this,Dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=mr.keyboardCodes}=r??{};if(An(t,[...s.end,...s.cancel])){t.preventDefault();const o=An(t,s.cancel);this.handleEnd(t,o);return}An(t,s.up)?this.handleMove("up",t):An(t,s.down)&&this.handleMove("down",t),An(t,s.left)?this.handleMove("left",t):An(t,s.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,s;const{shape:o}=this.manager.dragOperation,a=n.shiftKey?5:1;let i={x:0,y:0},l=(s=(r=this.options)==null?void 0:r.offset)!=null?s:mr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!o){switch(t){case"up":i={x:0,y:-l.y*a};break;case"down":i={x:0,y:l.y*a};break;case"left":i={x:-l.x*a,y:0};break;case"right":i={x:l.x*a,y:0};break}(i.x||i.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:i}))}}sideEffects(){const t=this.manager.registry.plugins.get(Ad);t?.disabled===!1&&(t.disable(),xe(this,Dn).push(()=>{t.enable()}))}cleanup(){xe(this,Dn).forEach(t=>t()),rt(this,Dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};Dn=new WeakMap;Ws.configure=bn(Ws);Ws.defaults=mr;var ig=Ws;function An(e,t){return t.includes(e.code)}var dn,lg=class extends Fu{constructor(){super(...arguments),$e(this,dn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,dn,Zn(e));break;case"pointermove":if(!xe(this,dn))return;const{x:t,y:n}=Zn(e),r={x:t-xe(this,dn).x,y:n-xe(this,dn).y},{tolerance:s}=this.options;if(s&&Uo(r,s)){this.abort();return}Uo(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){rt(this,dn,void 0)}};dn=new WeakMap;var Pn,fn,cg=class extends Fu{constructor(){super(...arguments),$e(this,Pn),$e(this,fn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,fn,Zn(e)),rt(this,Pn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!xe(this,fn))return;const{x:t,y:n}=Zn(e),r={x:t-xe(this,fn).x,y:n-xe(this,fn).y};Uo(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){xe(this,Pn)&&(clearTimeout(xe(this,Pn)),rt(this,fn,void 0),rt(this,Pn,void 0))}};Pn=new WeakMap;fn=new WeakMap;var Wt=class{};Wt.Delay=cg;Wt.Distance=lg;var fa=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&mn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Wt.Delay({value:250,tolerance:5})]:ym(s)&&!e.defaultPrevented?[new Wt.Delay({value:200,tolerance:0})]:[new Wt.Delay({value:200,tolerance:10}),new Wt.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;return r===t.element||r===t.handle||!mn(r)||(n=t.handle)!=null&&n.contains(r)?!1:Op(r)}}),Fn,Ls=class extends Vn{constructor(t,n){super(t),this.manager=t,this.options=n,$e(this,Fn,new Set),this.listeners=new qu,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:s}=this.latest;!r||!s||this.manager.actions.move({event:r,to:s})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:s=fa.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return At(()=>{var s;const o=new AbortController,{signal:a}=o,i=c=>{vm(c)&&this.handlePointerDown(c,t,n)};let l=[(s=t.handle)!=null?s:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const c of l)c&&(fg(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:a}));return()=>o.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!mn(t.target)||n.disabled||ug(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=fa.preventActivation}=r??{};if(s?.(t,n))return;const{target:o}=t,a=pn(o)&&o.draggable&&o.getAttribute("draggable")==="true",i=zn(n.element),{x:l,y:c}=Zn(t);this.initialCoordinates={x:l*i.scaleX+i.x,y:c*i.scaleY+i.y};const u=this.activationConstraints(t,n,r);t.sensor=this;const f=new Ip(u,g=>this.handleStart(n,g));f.signal.onabort=()=>this.handleCancel(t),f.onEvent(t),this.controller=f;const p=Jo(),d=this.listeners.bind(p,[{type:"pointermove",listener:g=>this.handlePointerMove(g,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:a?this.handleCancel:is,options:{capture:!0}}]),h=()=>{d(),this.initialCoordinates=void 0};xe(this,Fn).add(h)}handlePointerMove(t,n){var r,s;if(((r=this.controller)==null?void 0:r.activated)===!1){(s=this.controller)==null||s.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const o=Zn(t),a=zn(n.element);o.x=o.x*a.scaleX+a.x,o.y=o.y*a.scaleY+a.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=o,Ds.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:s}=this;if(!s||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:s,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const i=wn(n.target).body;i.setPointerCapture(n.pointerId);const l=mn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:is,options:{passive:!1}},{type:"click",listener:is},{type:"contextmenu",listener:is},{type:"keydown",listener:this.handleKeyDown}]);xe(this,Fn).add(c)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){this.latest={event:void 0,coordinates:void 0},xe(this,Fn).forEach(t=>t()),xe(this,Fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Fn=new WeakMap;Ls.configure=bn(Ls);Ls.defaults=fa;var ha=Ls;function ug(e){return"sensor"in e}function is(e){e.preventDefault()}function dg(){}var Ql=new WeakSet;function fg(e){!e||Ql.has(e)||(e.addEventListener("touchmove",dg,{capture:!1,passive:!1}),Ql.add(e))}var Wn={modifiers:[],plugins:[Bm,Ad,Lm,ca,ag],sensors:[ha,ig]},bi=class extends Mp{constructor(e={}){const t=Lt(e.plugins,Wn.plugins),n=Lt(e.sensors,Wn.sensors),r=Lt(e.modifiers,Wn.modifiers);super(fi(Ir({},e),{plugins:[og,qs,_n,...t],sensors:n,modifiers:r}))}},Ed,Md,Td,pa,Rt,wi,Ci,_i,Vr=class extends(pa=Ft,Td=[de],Md=[de],Ed=[de],pa){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:o,feedback:a="default"}=n,i=ld(n,["element","effects","handle","feedback"]);super(Ir({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const p=((c=(l=this.sensors)==null?void 0:l.map(Pa))!=null?c:[...u.sensors]).map(d=>{const h=d instanceof Vn?d:u.registry.register(d.plugin),g=d instanceof Vn?void 0:d.options;return h.bind(this,g)});return function(){p.forEach(h=>h())}}]},i),t),$e(this,wi,Pe(Rt,8,this)),Pe(Rt,11,this),$e(this,Ci,Pe(Rt,12,this)),Pe(Rt,15,this),$e(this,_i,Pe(Rt,16,this)),Pe(Rt,19,this),this.element=r,this.handle=o,this.feedback=a}};Rt=Jn(pa);wi=new WeakMap;Ci=new WeakMap;_i=new WeakMap;_t(Rt,4,"handle",Td,Vr,wi);_t(Rt,4,"element",Md,Vr,Ci);_t(Rt,4,"feedback",Ed,Vr,_i);Cn(Rt,Vr);var Rd,$d,ma,Kt,xi,ko,Dd,Pd,Cr,Si,Fd=class extends(ma=Ot,$d=[de],Rd=[de],ma){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,o=ld(n,["element","effects"]);const{collisionDetector:a=_m}=o,i=c=>{const{manager:u,element:f}=this;if(!f||c===null){this.shape=void 0;return}if(!u)return;const p=new Vt(f),d=we(()=>this.shape);return p&&d?.equals(p)?d:(this.shape=p,p)},l=Dr(!1);super(fi(Ir({},o),{collisionDetector:a,effects:()=>[...s(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:f}=u,{source:p}=f;l.value=!!(p&&f.status.initialized&&c&&!this.disabled&&this.accepts(p))},()=>{const{element:c}=this;if(l.value&&c){const u=new Hp(c,i);return()=>{u.disconnect(),this.shape=void 0}}},()=>{var c;if((c=this.manager)!=null&&c.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),$e(this,Cr),$e(this,xi,Pe(Kt,8,this)),Pe(Kt,11,this),$e(this,Si,Pe(Kt,12,this)),Pe(Kt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){rt(this,Cr,e,Pd)}get element(){var e;return(e=this.proxy)!=null?e:xe(this,Cr,Dd)}};Kt=Jn(ma);xi=new WeakMap;Cr=new WeakSet;Si=new WeakMap;ko=_t(Kt,20,"#element",$d,Cr,xi),Dd=ko.get,Pd=ko.set;_t(Kt,4,"proxy",Rd,Fd,Si);Cn(Kt,Fd);function hg(e){return e!=null&&typeof e=="object"&&"current"in e}function Vs(e){var t;if(e!=null)return hg(e)?(t=e.current)!=null?t:void 0:e}var pg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Js=pg?m.useLayoutEffect:m.useEffect;function mg(){const e=m.useState(0)[1];return m.useCallback(()=>{e(t=>t+1)},[e])}function gg(e,t){const n=m.useRef(new Map),r=mg();return Js(()=>{if(!e){n.current.clear();return}return At(()=>{var s;let o=!1,a=!1;for(const i of n.current){const[l]=i,c=we(()=>i[1]),u=e[l];c!==u&&(o=!0,n.current.set(l,u),a=(s=t?.(l,c,u))!=null?s:!1)}o&&(a?Sa.flushSync(r):r())})},[e]),m.useMemo(()=>e&&new Proxy(e,{get(s,o){const a=s[o];return n.current.set(o,a),a}}),[e])}function an(e,t,n=m.useEffect,r=Object.is){const s=m.useRef(e);n(()=>{const o=s.current;r(e,o)||(s.current=e,t(e,o))},[t,e])}function ql(e,t){const n=m.useRef(Vs(e));Js(()=>{const r=Vs(e);r!==n.current&&(n.current=r,t(r))})}var vg=Object.defineProperty,yg=Object.defineProperties,bg=Object.getOwnPropertyDescriptors,Jl=Object.getOwnPropertySymbols,wg=Object.prototype.hasOwnProperty,Cg=Object.prototype.propertyIsEnumerable,ec=(e,t,n)=>t in e?vg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_g=(e,t)=>{for(var n in t||(t={}))wg.call(t,n)&&ec(e,n,t[n]);if(Jl)for(var n of Jl(t))Cg.call(t,n)&&ec(e,n,t[n]);return e},xg=(e,t)=>yg(e,bg(t)),Sg=new bi,kg=m.createContext(Sg);m.memo(m.forwardRef(({children:e},t)=>{const[n,r]=m.useState(0),s=m.useRef(null),o=m.useRef(null),a=m.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{o.current=l})),m.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Js(()=>{var i;(i=o.current)==null||i.call(o),s.current=null},[e,n]),m.useImperativeHandle(t,()=>a),null}));function Ig(){return m.useContext(kg)}function Ag(e){var t;const n=(t=Ig())!=null?t:void 0,[r]=m.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Js(r.register,[n,r]),r}function Io(e){const{disabled:t,data:n,element:r,handle:s,id:o,modifiers:a,sensors:i}=e,l=Ag(u=>new Vr(xg(_g({},e),{register:!1,handle:Vs(s),element:Vs(r)}),u)),c=gg(l,Eg);return an(o,()=>l.id=o),ql(s,u=>l.handle=u),ql(r,u=>l.element=u),an(n,()=>n&&(l.data=n)),an(t,()=>l.disabled=t===!0),an(i,()=>l.sensors=i),an(a,()=>l.modifiers=a,void 0,xr),an(e.feedback,()=>{var u;return l.feedback=(u=e.feedback)!=null?u:"default"}),an(e.alignment,()=>l.alignment=e.alignment),{draggable:c,get isDragging(){return c.isDragging},get isDropping(){return c.isDropping},get isDragSource(){return c.isDragSource},handleRef:m.useCallback(u=>{l.handle=u??void 0},[l]),ref:m.useCallback(u=>{var f,p;!u&&((f=l.element)!=null&&f.isConnected)&&!((p=l.manager)!=null&&p.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function Eg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var Mg=Object.create,Od=Object.defineProperty,Tg=Object.getOwnPropertyDescriptor,Bd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),eo=e=>{throw TypeError(e)},Rg=(e,t,n)=>t in e?Od(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$g=e=>{var t;return[,,,Mg((t=e?.[Bd("metadata")])!=null?t:null)]},Wd=["class","method","getter","setter","accessor","field","value","get","set"],Ld=e=>e!==void 0&&typeof e!="function"?eo("Function expected"):e,Dg=(e,t,n,r,s)=>({kind:Wd[e],name:t,metadata:r,addInitializer:o=>n._?eo("Already initialized"):s.push(Ld(o||null))}),Pg=(e,t)=>Rg(t,Bd("metadata"),e[3]),Fg=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)o[s].call(n);return r},Vd=(e,t,n,r,s,o)=>{for(var a,i,l,c,u=t&7,f=!1,p=!1,d=2,h=Wd[u+5],g=e[d]||(e[d]=[]),y=(s=s.prototype,Tg(s,n)),v=r.length-1;v>=0;v--)l=Dg(u,n,i={},e[3],g),l.static=f,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],a=(0,r[v])(y[h],l),i._=1,Ld(a)&&(y[h]=a);return y&&Od(s,n,y),s},Nd=(e,t,n)=>t.has(e)||eo("Cannot "+n),Og=(e,t,n)=>(Nd(e,t,"read from private field"),t.get(e)),Bg=(e,t,n)=>t.has(e)?eo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Wg=(e,t,n,r)=>(Nd(e,t,"write to private field"),t.set(e,n),n),tr=class ga{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ga(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new ga(t,n)}},Zd,Gd,va,ws,Nr,ki=class extends(va=en,Gd=[Ee],Zd=[Ee],va){constructor(t){const n=tr.from(t);super(n,(r,s)=>tr.equals(r,s)),Fg(Nr,5,this),Bg(this,ws,0),this.velocity={x:0,y:0}}get delta(){return tr.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=tr.from(t),s={x:r.x-n.x,y:r.y-n.y},o=Date.now(),a=o-Og(this,ws),i=l=>Math.round(l/a*100);qt(()=>{Wg(this,ws,o),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(tr.from(t)),this.velocity={x:0,y:0}}};Nr=$g(va);ws=new WeakMap;Vd(Nr,2,"delta",Gd,ki);Vd(Nr,2,"direction",Zd,ki);Pg(Nr,ki);var zd=(e=>(e.Horizontal="x",e.Vertical="y",e))(zd||{});Object.values(zd);const Lg=new Map([["bold",F.createElement(F.Fragment,null,F.createElement("path",{d:"M144,128a16,16,0,1,1-16-16A16,16,0,0,1,144,128ZM60,112a16,16,0,1,0,16,16A16,16,0,0,0,60,112Zm136,0a16,16,0,1,0,16,16A16,16,0,0,0,196,112Z"}))],["duotone",F.createElement(F.Fragment,null,F.createElement("path",{d:"M240,96v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V96A16,16,0,0,1,32,80H224A16,16,0,0,1,240,96Z",opacity:"0.2"}),F.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["fill",F.createElement(F.Fragment,null,F.createElement("path",{d:"M224,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V96A16,16,0,0,0,224,80ZM60,140a12,12,0,1,1,12-12A12,12,0,0,1,60,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,196,140Z"}))],["light",F.createElement(F.Fragment,null,F.createElement("path",{d:"M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM60,118a10,10,0,1,0,10,10A10,10,0,0,0,60,118Zm136,0a10,10,0,1,0,10,10A10,10,0,0,0,196,118Z"}))],["regular",F.createElement(F.Fragment,null,F.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["thin",F.createElement(F.Fragment,null,F.createElement("path",{d:"M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-76-8a8,8,0,1,0,8,8A8,8,0,0,0,60,120Zm136,0a8,8,0,1,0,8,8A8,8,0,0,0,196,120Z"}))]]),Vg=new Map([["bold",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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"}))]]),Ng=new Map([["bold",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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"}))]]),Zg=new Map([["bold",F.createElement(F.Fragment,null,F.createElement("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"}))],["duotone",F.createElement(F.Fragment,null,F.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),F.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["fill",F.createElement(F.Fragment,null,F.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["light",F.createElement(F.Fragment,null,F.createElement("path",{d:"M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"}))],["regular",F.createElement(F.Fragment,null,F.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["thin",F.createElement(F.Fragment,null,F.createElement("path",{d:"M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"}))]]),Gg=m.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Zr=F.forwardRef((e,t)=>{const{alt:n,color:r,size:s,weight:o,mirrored:a,children:i,weights:l,...c}=e,{color:u="currentColor",size:f,weight:p="regular",mirrored:d=!1,...h}=F.useContext(Gg);return F.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:s??f,height:s??f,fill:r??u,viewBox:"0 0 256 256",transform:a||d?"scale(-1, 1)":void 0,...h,...c},!!n&&F.createElement("title",null,n),i,l.get(o??p))});Zr.displayName="IconBase";const jd=F.forwardRef((e,t)=>F.createElement(Zr,{ref:t,...e,weights:Lg}));jd.displayName="DotsThreeIcon";const Hd=F.forwardRef((e,t)=>F.createElement(Zr,{ref:t,...e,weights:Vg}));Hd.displayName="SpeakerHighIcon";const Xd=F.forwardRef((e,t)=>F.createElement(Zr,{ref:t,...e,weights:Ng}));Xd.displayName="SpeakerLowIcon";const Yd=F.forwardRef((e,t)=>F.createElement(Zr,{ref:t,...e,weights:Zg}));Yd.displayName="XIcon";const zg=Yd;D.span`
|
|
1
|
+
"use strict";var co=Object.create;var Cr=Object.defineProperty;var uo=Object.getOwnPropertyDescriptor;var fo=Object.getOwnPropertyNames;var mo=Object.getPrototypeOf,ho=Object.prototype.hasOwnProperty;var po=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of fo(t))!ho.call(e,a)&&a!==r&&Cr(e,a,{get:()=>t[a],enumerable:!(n=uo(t,a))||n.enumerable});return e};var go=(e,t,r)=>(r=e!=null?co(mo(e)):{},po(t||!e||!e.__esModule?Cr(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("tone"),x=require("react/jsx-runtime"),f=require("react"),$=require("styled-components"),yt=require("@dnd-kit/react"),Yr=require("react-dom"),Ur=require("@dnd-kit/abstract/modifiers"),st=require("@dnd-kit/dom"),Nt=require("@dnd-kit/abstract");var mt=typeof document<"u"?document.currentScript:null;function Kr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Qr=Kr(Z),B=Kr(f);var we=1e3;function Cn(e){const{audioBuffer:t,startSample:r,offsetSamples:n=0,gain:a=1,name:s,color:o,fadeIn:i,fadeOut:c,waveformData:l,midiNotes:u,midiChannel:m,midiProgram:b}=e,d=t?.sampleRate??e.sampleRate??l?.sample_rate,h=t?.length??e.sourceDurationSamples??(l&&d?Math.ceil(l.duration*d):void 0);if(d===void 0)throw new Error("createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");if(h===void 0)throw new Error("createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)");t&&l&&t.sampleRate!==l.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${l.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const v=e.durationSamples??h;return{id:ea(),audioBuffer:t,startSample:r,durationSamples:v,offsetSamples:n,sampleRate:d,sourceDurationSamples:h,gain:a,name:s,color:o,fadeIn:i,fadeOut:c,waveformData:l,midiNotes:u,midiChannel:m,midiProgram:b}}function Jr(e){const{audioBuffer:t,startTime:r,offset:n=0,gain:a=1,name:s,color:o,fadeIn:i,fadeOut:c,waveformData:l,midiNotes:u,midiChannel:m,midiProgram:b}=e,d=t?.sampleRate??e.sampleRate??l?.sample_rate;if(d===void 0)throw new Error("createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");const h=t?.duration??e.sourceDuration??l?.duration;if(h===void 0)throw new Error("createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)");t&&l&&t.sampleRate!==l.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${l.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const v=e.duration??h;return Cn({audioBuffer:t,startSample:Math.round(r*d),durationSamples:Math.round(v*d),offsetSamples:Math.round(n*d),sampleRate:d,sourceDurationSamples:Math.ceil(h*d),gain:a,name:s,color:o,fadeIn:i,fadeOut:c,waveformData:l,midiNotes:u,midiChannel:m,midiProgram:b})}function qr(e){const{name:t,clips:r=[],muted:n=!1,soloed:a=!1,volume:s=1,pan:o=0,color:i,height:c,spectrogramConfig:l,spectrogramColorMap:u}=e;return{id:ea(),name:t,clips:r,muted:n,soloed:a,volume:s,pan:o,color:i,height:c,spectrogramConfig:l,spectrogramColorMap:u}}function ea(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function wr(e){return[...e].sort((t,r)=>t.startSample-r.startSample)}function vo(e,t){return Math.floor(e/t)}function bo(e,t,r){return Math.ceil(e*r/t)}var gt=192;function Jt(e,t=gt){const[,r]=e;return t*(4/r)}function Mn(e,t=gt){const[r]=e;return r*Jt(e,t)}function ht(e,t,r,n=gt){return Math.round(e*60*r/(t*n))}function wn(e,t,r,n=gt){return Math.round(e*n*t/(60*r))}function xn(e,t){return Math.round(e/t)*t}function yo(e,t,r=gt){const n=Mn(t,r),a=Jt(t,r),s=Math.floor(e/n)+1,o=Math.floor(e%n/a)+1;return o===1?`${s}`:`${s}.${o}`}var Ot=-100;function Co(e,t=Ot){return Number.isNaN(e)?(console.warn("[waveform-playlist] dBToNormalized received NaN"),0):t>=0?(console.warn("[waveform-playlist] dBToNormalized floor must be negative, got:",t),0):!isFinite(e)||e<=t?0:(e-t)/-t}function xr(e,t=Ot){return isFinite(e)?t>=0?(console.warn("[waveform-playlist] normalizedToDb floor must be negative, got:",t),Ot):Math.max(0,e)*-t+t:t}function Ir(e,t=Ot){if(e<=0)return 0;const r=20*Math.log10(e);return Co(r,t)}function Bt(e){return e.startSample/e.sampleRate}function Sr(e){return(e.startSample+e.durationSamples)/e.sampleRate}function kr(e){return e.offsetSamples/e.sampleRate}function Ar(e){return e.durationSamples/e.sampleRate}function ta(e,t,r){return Math.floor((e+t)/r)-Math.floor(e/r)}function _r(e,t){const r=new Float32Array(e),n=e-1;for(let a=0;a<e;a++){const s=a/n;r[a]=t?s:1-s}return r}function wo(e,t){const r=new Float32Array(e),n=e-1;for(let a=0;a<e;a++){const s=a/n,o=t?a:e-1-a;r[o]=Math.exp(2*s-1)/Math.E}return r}function xo(e,t){const r=new Float32Array(e),n=t?Math.PI/2:-Math.PI/2;for(let a=0;a<e;a++)r[a]=Math.sin(Math.PI*a/e-n)/2+.5;return r}function Io(e,t,r=10){const n=new Float32Array(e);for(let a=0;a<e;a++){const s=t?a:e-1-a,o=a/e;n[s]=Math.log(1+r*o)/Math.log(1+r)}return n}function Ht(e,t,r){switch(e){case"linear":return _r(t,r);case"exponential":return wo(t,r);case"sCurve":return xo(t,r);case"logarithmic":return Io(t,r);default:return _r(t,r)}}function In(e,t,r,n="linear",a=0,s=1){if(!(r<=0))if(n==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+r);else if(n==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+r);else{const o=Ht(n,1e4,!0),i=new Float32Array(o.length),c=s-a;for(let l=0;l<o.length;l++)i[l]=a+o[l]*c;e.setValueCurveAtTime(i,t,r)}}function Sn(e,t,r,n="linear",a=1,s=0){if(!(r<=0))if(n==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+r);else if(n==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+r);else{const o=Ht(n,1e4,!1),i=new Float32Array(o.length),c=a-s;for(let l=0;l<o.length;l++)i[l]=s+o[l]*c;e.setValueCurveAtTime(i,t,r)}}var fn={exports:{}},Er;function So(){return Er||(Er=1,(function(e,t){(function(r,n){e.exports=n()})(window,(function(){return(function(r){var n={};function a(s){if(n[s])return n[s].exports;var o=n[s]={i:s,l:!1,exports:{}};return r[s].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=r,a.c=n,a.d=function(s,o,i){a.o(s,o)||Object.defineProperty(s,o,{enumerable:!0,get:i})},a.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},a.t=function(s,o){if(1&o&&(s=a(s)),8&o||4&o&&typeof s=="object"&&s&&s.__esModule)return s;var i=Object.create(null);if(a.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:s}),2&o&&typeof s!="string")for(var c in s)a.d(i,c,(function(l){return s[l]}).bind(null,c));return i},a.n=function(s){var o=s&&s.__esModule?function(){return s.default}:function(){return s};return a.d(o,"a",o),o},a.o=function(s,o){return Object.prototype.hasOwnProperty.call(s,o)},a.p="",a(a.s="./src/index.ts")})({"./src/chunk.ts":function(r,n,a){a.r(n),a.d(n,"SF2Chunk",(function(){return d}));var s=a("./src/riff/index.ts"),o=a("./src/constants.ts"),i=a("./src/chunks/index.ts");function c(h){return(c=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(v){return typeof v}:function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v})(h)}function l(h,v){for(var g=0;g<v.length;g++){var p=v[g];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(h,p.key,p)}}function u(h){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)})(h)}function m(h,v){return(m=Object.setPrototypeOf||function(g,p){return g.__proto__=p,g})(h,v)}function b(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}var d=(function(h){function v(C){var y,w,I,S,A,k;return(function(M,_){if(!(M instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),w=this,y=!(I=u(v).call(this,C.id,C.length,C.buffer,C.subChunks))||c(I)!=="object"&&typeof I!="function"?b(w):I,S=b(b(y)),k=void 0,(A="subChunks")in S?Object.defineProperty(S,A,{value:k,enumerable:!0,configurable:!0,writable:!0}):S[A]=k,y.subChunks=C.subChunks.map((function(M){return new v(M)})),y}var g,p;return(function(C,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");C.prototype=Object.create(y&&y.prototype,{constructor:{value:C,writable:!0,configurable:!0}}),y&&m(C,y)})(v,h),g=v,(p=[{key:"getMetaData",value:function(){if(this.id!=="LIST")throw new s.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var C=this.subChunks.reduce((function(y,w){if(w.id==="ifil"||w.id==="iver"){if(w.length!==o.SF_VERSION_LENGTH)throw new s.ParseError("Invalid size for the '".concat(w.id,"' sub-chunk"));y[w.id]="".concat(w.getInt16(),".").concat(w.getInt16(2))}else y[w.id]=w.getString();return y}),{});if(!C.ifil)throw new s.ParseError("Missing required 'ifil' sub-chunk");if(!C.INAM)throw new s.ParseError("Missing required 'INAM' sub-chunk");return{version:C.ifil,soundEngine:C.isng||"EMU8000",name:C.INAM,rom:C.irom,romVersion:C.iver,creationDate:C.ICRD,author:C.IENG,product:C.IPRD,copyright:C.ICOP,comments:C.ICMT,createdBy:C.ISFT}}},{key:"getSampleData",value:function(){if(this.id!=="LIST")throw new s.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var C=this.subChunks[0];if(C.id!=="smpl")throw new s.ParseError("Invalid chunk signature","'smpl'","'".concat(C.id,"'"));return C.buffer}},{key:"getPresetData",value:function(){if(this.id!=="LIST")throw new s.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));return{presetHeaders:Object(i.getPresetHeaders)(this.subChunks[0]),presetZones:Object(i.getZones)(this.subChunks[1],"pbag"),presetModulators:Object(i.getModulators)(this.subChunks[2],"pmod"),presetGenerators:Object(i.getGenerators)(this.subChunks[3],"pgen"),instrumentHeaders:Object(i.getInstrumentHeaders)(this.subChunks[4]),instrumentZones:Object(i.getZones)(this.subChunks[5],"ibag"),instrumentModulators:Object(i.getModulators)(this.subChunks[6],"imod"),instrumentGenerators:Object(i.getGenerators)(this.subChunks[7],"igen"),sampleHeaders:Object(i.getSampleHeaders)(this.subChunks[8])}}}])&&l(g.prototype,p),v})(s.RIFFChunk)},"./src/chunks/generators.ts":function(r,n,a){a.r(n),a.d(n,"getGenerators",(function(){return m}));var s=a("./src/riff/index.ts"),o=a("./src/types/index.ts"),i=a("./src/constants.ts"),c=[o.GeneratorType.StartAddrsOffset,o.GeneratorType.EndAddrsOffset,o.GeneratorType.StartLoopAddrsOffset,o.GeneratorType.EndLoopAddrsOffset,o.GeneratorType.StartAddrsCoarseOffset,o.GeneratorType.EndAddrsCoarseOffset,o.GeneratorType.StartLoopAddrsCoarseOffset,o.GeneratorType.KeyNum,o.GeneratorType.Velocity,o.GeneratorType.EndLoopAddrsCoarseOffset,o.GeneratorType.SampleModes,o.GeneratorType.ExclusiveClass,o.GeneratorType.OverridingRootKey],l=[o.GeneratorType.Unused1,o.GeneratorType.Unused2,o.GeneratorType.Unused3,o.GeneratorType.Unused4,o.GeneratorType.Reserved1,o.GeneratorType.Reserved2,o.GeneratorType.Reserved3],u=[o.GeneratorType.KeyRange,o.GeneratorType.VelRange],m=function(b,d){if(b.id!==d)throw new s.ParseError("Unexpected chunk ID","'".concat(d,"'"),"'".concat(b.id,"'"));if(b.length%i.SF_GENERATOR_SIZE)throw new s.ParseError("Invalid size for the '".concat(d,"' sub-chunk"));return b.iterate((function(h){var v=h.getInt16();return o.GeneratorType[v]?d==="pgen"&&c.includes(v)||d==="igen"&&l.includes(v)?null:u.includes(v)?{id:v,range:{lo:h.getByte(),hi:h.getByte()}}:{id:v,value:h.getInt16BE()}:null}))}},"./src/chunks/index.ts":function(r,n,a){a.r(n);var s=a("./src/chunks/instruments/index.ts");a.d(n,"getInstrumentHeaders",(function(){return s.getInstrumentHeaders}));var o=a("./src/chunks/presets/index.ts");a.d(n,"getPresetHeaders",(function(){return o.getPresetHeaders}));var i=a("./src/chunks/samples/index.ts");a.d(n,"getSampleHeaders",(function(){return i.getSampleHeaders}));var c=a("./src/chunks/generators.ts");a.d(n,"getGenerators",(function(){return c.getGenerators}));var l=a("./src/chunks/modulators.ts");a.d(n,"getModulators",(function(){return l.getModulators}));var u=a("./src/chunks/zones.ts");a.d(n,"getZones",(function(){return u.getZones})),a.d(n,"getItemsInZone",(function(){return u.getItemsInZone}))},"./src/chunks/instruments/headers.ts":function(r,n,a){a.r(n),a.d(n,"getInstrumentHeaders",(function(){return i}));var s=a("./src/riff/index.ts"),o=a("./src/constants.ts"),i=function(c){if(c.id!=="inst")throw new s.ParseError("Unexpected chunk ID","'inst'","'".concat(c.id,"'"));if(c.length%o.SF_INSTRUMENT_HEADER_SIZE)throw new s.ParseError("Invalid size for the 'inst' sub-chunk");return c.iterate((function(l){return{name:l.getString(),bagIndex:l.getInt16()}}))}},"./src/chunks/instruments/index.ts":function(r,n,a){a.r(n);var s=a("./src/chunks/instruments/headers.ts");a.d(n,"getInstrumentHeaders",(function(){return s.getInstrumentHeaders}))},"./src/chunks/modulators.ts":function(r,n,a){a.r(n),a.d(n,"getModulators",(function(){return c}));var s=a("./src/riff/index.ts"),o=a("./src/constants.ts"),i=function(l){return{type:l>>10&63,polarity:l>>9&1,direction:l>>8&1,palette:l>>7&1,index:127&l}},c=function(l,u){if(l.id!==u)throw new s.ParseError("Unexpected chunk ID","'".concat(u,"'"),"'".concat(l.id,"'"));if(l.length%o.SF_MODULATOR_SIZE)throw new s.ParseError("Invalid size for the '".concat(u,"' sub-chunk"));return l.iterate((function(m){return{source:i(m.getInt16BE()),id:m.getInt16BE(),value:m.getInt16BE(),valueSource:i(m.getInt16BE()),transform:m.getInt16BE()}}))}},"./src/chunks/presets/headers.ts":function(r,n,a){a.r(n),a.d(n,"getPresetHeaders",(function(){return i}));var s=a("./src/riff/index.ts"),o=a("./src/constants.ts"),i=function(c){if(c.id!=="phdr")throw new s.ParseError("Invalid chunk ID","'phdr'","'".concat(c.id,"'"));if(c.length%o.SF_PRESET_HEADER_SIZE)throw new s.ParseError("Invalid size for the 'phdr' sub-chunk");return c.iterate((function(l){return{name:l.getString(),preset:l.getInt16(),bank:l.getInt16(),bagIndex:l.getInt16(),library:l.getUInt32(),genre:l.getUInt32(),morphology:l.getUInt32()}}))}},"./src/chunks/presets/index.ts":function(r,n,a){a.r(n);var s=a("./src/chunks/presets/headers.ts");a.d(n,"getPresetHeaders",(function(){return s.getPresetHeaders}))},"./src/chunks/samples/headers.ts":function(r,n,a){a.r(n),a.d(n,"getSampleHeaders",(function(){return i}));var s=a("./src/riff/index.ts"),o=a("./src/constants.ts"),i=function(c){if(c.id!=="shdr")throw new s.ParseError("Unexpected chunk ID","'shdr'","'".concat(c.id,"'"));if(c.length%o.SF_SAMPLE_HEADER_SIZE)throw new s.ParseError("Invalid size for the 'shdr' sub-chunk");return c.iterate((function(l){return{name:l.getString(),start:l.getUInt32(),end:l.getUInt32(),startLoop:l.getUInt32(),endLoop:l.getUInt32(),sampleRate:l.getUInt32(),originalPitch:l.getByte(),pitchCorrection:l.getChar(),link:l.getInt16(),type:l.getInt16()}}))}},"./src/chunks/samples/index.ts":function(r,n,a){a.r(n);var s=a("./src/chunks/samples/headers.ts");a.d(n,"getSampleHeaders",(function(){return s.getSampleHeaders}))},"./src/chunks/zones.ts":function(r,n,a){a.r(n),a.d(n,"getZones",(function(){return c})),a.d(n,"getItemsInZone",(function(){return l}));var s=a("./src/riff/index.ts"),o=a("./src/constants.ts"),i=a("./src/types/index.ts"),c=function(d,h){if(d.id!==h)throw new s.ParseError("Unexpected chunk ID","'".concat(h,"'"),"'".concat(d.id,"'"));if(d.length%o.SF_BAG_SIZE)throw new s.ParseError("Invalid size for the '".concat(h,"' sub-chunk"));return d.iterate((function(v){return{generatorIndex:v.getInt16(),modulatorIndex:v.getInt16()}}))},l=function(d,h,v,g,p,C){for(var y=[],w=0;w<d.length;w++){for(var I=d[w],S=d[w+1],A=I.bagIndex,k=S?S.bagIndex:h.length,M=[],_=void 0,E=A;E<k;E++){var T=u(E,h,v),R=m(E,h,g),D=R[i.GeneratorType.KeyRange]&&R[i.GeneratorType.KeyRange].range,P=R[C];if(P){var F=p[P.value];F&&M.push({keyRange:D,modulators:T,generators:R,reference:F})}else E-A==0&&(_={keyRange:D,modulators:T,generators:R})}y.push({header:I,globalZone:_,zones:M})}return y},u=function(d,h,v){var g=h[d],p=h[d+1],C=g.modulatorIndex,y=p?p.modulatorIndex:h.length;return b(C,y,v)},m=function(d,h,v){var g=h[d],p=h[d+1],C=g.generatorIndex,y=p?p.generatorIndex:h.length;return b(C,y,v)},b=function(d,h,v){for(var g={},p=d;p<h;p++){var C=v[p];C&&(g[C.id]=C)}return g}},"./src/constants.ts":function(r,n,a){a.r(n),a.d(n,"SF_VERSION_LENGTH",(function(){return s})),a.d(n,"SF_PRESET_HEADER_SIZE",(function(){return o})),a.d(n,"SF_BAG_SIZE",(function(){return i})),a.d(n,"SF_MODULATOR_SIZE",(function(){return c})),a.d(n,"SF_GENERATOR_SIZE",(function(){return l})),a.d(n,"SF_INSTRUMENT_HEADER_SIZE",(function(){return u})),a.d(n,"SF_SAMPLE_HEADER_SIZE",(function(){return m})),a.d(n,"DEFAULT_SAMPLE_RATE",(function(){return b}));var s=4,o=38,i=4,c=10,l=4,u=22,m=46,b=22050},"./src/index.ts":function(r,n,a){a.r(n);var s=a("./src/types/index.ts");for(var o in s)["default"].indexOf(o)<0&&(function(u){a.d(n,u,(function(){return s[u]}))})(o);var i=a("./src/chunk.ts");a.d(n,"SF2Chunk",(function(){return i.SF2Chunk}));var c=a("./src/constants.ts");a.d(n,"SF_VERSION_LENGTH",(function(){return c.SF_VERSION_LENGTH})),a.d(n,"SF_PRESET_HEADER_SIZE",(function(){return c.SF_PRESET_HEADER_SIZE})),a.d(n,"SF_BAG_SIZE",(function(){return c.SF_BAG_SIZE})),a.d(n,"SF_MODULATOR_SIZE",(function(){return c.SF_MODULATOR_SIZE})),a.d(n,"SF_GENERATOR_SIZE",(function(){return c.SF_GENERATOR_SIZE})),a.d(n,"SF_INSTRUMENT_HEADER_SIZE",(function(){return c.SF_INSTRUMENT_HEADER_SIZE})),a.d(n,"SF_SAMPLE_HEADER_SIZE",(function(){return c.SF_SAMPLE_HEADER_SIZE})),a.d(n,"DEFAULT_SAMPLE_RATE",(function(){return c.DEFAULT_SAMPLE_RATE}));var l=a("./src/soundFont2.ts");a.d(n,"SoundFont2",(function(){return l.SoundFont2}))},"./src/riff/chunkIterator.ts":function(r,n,a){a.r(n),a.d(n,"ChunkIterator",(function(){return l}));var s=a("./src/utils/index.ts");function o(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function i(u,m){for(var b=0;b<m.length;b++){var d=m[b];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function c(u,m,b){return m in u?Object.defineProperty(u,m,{value:b,enumerable:!0,configurable:!0,writable:!0}):u[m]=b,u}var l=(function(){function u(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;o(this,u),c(this,"target",[]),c(this,"chunk",void 0),c(this,"position",0),this.chunk=d,this.position=h}var m,b;return m=u,(b=[{key:"iterate",value:function(d){for(;this.position<this.chunk.length;){var h=d(this);h&&this.target.push(h)}}},{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,h=Object(s.getStringFromBuffer)(this.getBuffer(this.position,d));return this.position+=d,h}},{key:"getInt16",value:function(){return this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8}},{key:"getInt16BE",value:function(){return this.getInt16()<<16>>16}},{key:"getUInt32",value:function(){return(this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8|this.chunk.buffer[this.position++]<<16|this.chunk.buffer[this.position++]<<24)>>>0}},{key:"getByte",value:function(){return this.chunk.buffer[this.position++]}},{key:"getChar",value:function(){return this.chunk.buffer[this.position++]<<24>>24}},{key:"skip",value:function(d){this.position+=d}},{key:"getBuffer",value:function(d,h){return this.chunk.buffer.subarray(d,d+h)}},{key:"currentPosition",get:function(){return this.position}}])&&i(m.prototype,b),u})()},"./src/riff/index.ts":function(r,n,a){a.r(n);var s=a("./src/riff/chunkIterator.ts");a.d(n,"ChunkIterator",(function(){return s.ChunkIterator}));var o=a("./src/riff/parseError.ts");a.d(n,"ParseError",(function(){return o.ParseError}));var i=a("./src/riff/parser.ts");a.d(n,"parseBuffer",(function(){return i.parseBuffer})),a.d(n,"getChunk",(function(){return i.getChunk})),a.d(n,"getChunkLength",(function(){return i.getChunkLength})),a.d(n,"getSubChunks",(function(){return i.getSubChunks})),a.d(n,"getChunkId",(function(){return i.getChunkId}));var c=a("./src/riff/riffChunk.ts");a.d(n,"RIFFChunk",(function(){return c.RIFFChunk}))},"./src/riff/parseError.ts":function(r,n,a){function s(d){return(s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h})(d)}function o(d,h){return!h||s(h)!=="object"&&typeof h!="function"?(function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v})(d):h}function i(d){var h=typeof Map=="function"?new Map:void 0;return(i=function(v){if(v===null||(g=v,Function.toString.call(g).indexOf("[native code]")===-1))return v;var g;if(typeof v!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(v))return h.get(v);h.set(v,p)}function p(){return l(v,arguments,m(this).constructor)}return p.prototype=Object.create(v.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u(p,v)})(d)}function c(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch{return!1}}function l(d,h,v){return(l=c()?Reflect.construct:function(g,p,C){var y=[null];y.push.apply(y,p);var w=new(Function.bind.apply(g,y));return C&&u(w,C.prototype),w}).apply(null,arguments)}function u(d,h){return(u=Object.setPrototypeOf||function(v,g){return v.__proto__=g,v})(d,h)}function m(d){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(h){return h.__proto__||Object.getPrototypeOf(h)})(d)}a.r(n),a.d(n,"ParseError",(function(){return b}));var b=(function(d){function h(v,g,p){return(function(C,y){if(!(C instanceof y))throw new TypeError("Cannot call a class as a function")})(this,h),o(this,m(h).call(this,"".concat(v).concat(g&&p?", expected ".concat(g,", received ").concat(p):"")))}return(function(v,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(g&&g.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),g&&u(v,g)})(h,d),h})(i(Error))},"./src/riff/parser.ts":function(r,n,a){a.r(n),a.d(n,"parseBuffer",(function(){return c})),a.d(n,"getChunk",(function(){return l})),a.d(n,"getChunkLength",(function(){return u})),a.d(n,"getSubChunks",(function(){return m})),a.d(n,"getChunkId",(function(){return b}));var s=a("./src/riff/parseError.ts"),o=a("./src/utils/buffer.ts"),i=a("./src/riff/riffChunk.ts"),c=function(d){var h=b(d);if(h!=="RIFF")throw new s.ParseError("Invalid file format","RIFF",h);var v=b(d,8);if(v!=="sfbk")throw new s.ParseError("Invalid signature","sfbk",v);var g=d.subarray(8),p=m(g.subarray(4));return new i.RIFFChunk(h,g.length,g,p)},l=function(d,h){var v=b(d,h),g=u(d,h+4),p=[];return v!=="RIFF"&&v!=="LIST"||(p=m(d.subarray(h+12))),new i.RIFFChunk(v,g,d.subarray(h+8),p)},u=function(d,h){return((d=d.subarray(h,h+4))[0]|d[1]<<8|d[2]<<16|d[3]<<24)>>>0},m=function(d){for(var h=[],v=0;v<=d.length-8;){var g=l(d,v);h.push(g),v=(v+=8+g.length)%2?v+1:v}return h},b=function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return Object(o.getStringFromBuffer)(d.subarray(h,h+4))}},"./src/riff/riffChunk.ts":function(r,n,a){a.r(n),a.d(n,"RIFFChunk",(function(){return l}));var s=a("./src/riff/chunkIterator.ts"),o=a("./src/utils/index.ts");function i(u,m){for(var b=0;b<m.length;b++){var d=m[b];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function c(u,m,b){return m in u?Object.defineProperty(u,m,{value:b,enumerable:!0,configurable:!0,writable:!0}):u[m]=b,u}var l=(function(){function u(d,h,v,g){(function(p,C){if(!(p instanceof C))throw new TypeError("Cannot call a class as a function")})(this,u),c(this,"id",void 0),c(this,"length",void 0),c(this,"buffer",void 0),c(this,"subChunks",void 0),this.id=d,this.length=h,this.buffer=v,this.subChunks=g}var m,b;return m=u,(b=[{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,h=arguments.length>1?arguments[1]:void 0;return Object(o.getStringFromBuffer)(this.getBuffer(d,h||this.length-d))}},{key:"getInt16",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d++]|this.buffer[d]<<8}},{key:"getUInt32",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return(this.buffer[d++]|this.buffer[d++]<<8|this.buffer[d++]<<16|this.buffer[d]<<24)>>>0}},{key:"getByte",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]}},{key:"getChar",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]<<24>>24}},{key:"iterator",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new s.ChunkIterator(this,d)}},{key:"iterate",value:function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,v=new s.ChunkIterator(this,h);return v.iterate(d),v.target}},{key:"getBuffer",value:function(d,h){return this.buffer.subarray(d,d+h)}}])&&i(m.prototype,b),u})()},"./src/soundFont2.ts":function(r,n,a){a.r(n),a.d(n,"SoundFont2",(function(){return h}));var s=a("./src/types/index.ts"),o=a("./src/chunk.ts"),i=a("./src/riff/index.ts"),c=a("./src/chunks/index.ts"),l=a("./src/utils/index.ts");function u(v){for(var g=1;g<arguments.length;g++){var p=arguments[g]!=null?arguments[g]:{},C=Object.keys(p);typeof Object.getOwnPropertySymbols=="function"&&(C=C.concat(Object.getOwnPropertySymbols(p).filter((function(y){return Object.getOwnPropertyDescriptor(p,y).enumerable})))),C.forEach((function(y){d(v,y,p[y])}))}return v}function m(v,g){for(var p=0;p<g.length;p++){var C=g[p];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(v,C.key,C)}}function b(v,g,p){return g&&m(v.prototype,g),p&&m(v,p),v}function d(v,g,p){return g in v?Object.defineProperty(v,g,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[g]=p,v}var h=(function(){function v(g){if((function(C,y){if(!(C instanceof y))throw new TypeError("Cannot call a class as a function")})(this,v),d(this,"chunk",void 0),d(this,"metaData",void 0),d(this,"sampleData",void 0),d(this,"samples",void 0),d(this,"presetData",void 0),d(this,"instruments",void 0),d(this,"presets",void 0),d(this,"banks",void 0),!(g instanceof o.SF2Chunk)){var p=Object(i.parseBuffer)(g);g=new o.SF2Chunk(p)}if(g.subChunks.length!==3)throw new i.ParseError("Invalid sfbk structure","3 chunks","".concat(g.subChunks.length," chunks"));this.chunk=g,this.metaData=g.subChunks[0].getMetaData(),this.sampleData=g.subChunks[1].getSampleData(),this.presetData=g.subChunks[2].getPresetData(),this.samples=this.getSamples(),this.instruments=this.getInstruments(),this.presets=this.getPresets(),this.banks=this.getBanks()}return b(v,null,[{key:"from",value:function(g){return new v(g)}}]),b(v,[{key:"getKeyData",value:function(g){var p=this,C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return Object(l.memoize)((function(w,I,S){var A=p.banks[I];if(A){var k=A.presets[S];if(k){var M=k.zones.filter((function(Q){return p.isKeyInRange(Q,w)}));if(M.length>0){var _=!0,E=!1,T=void 0;try{for(var R,D=M[Symbol.iterator]();!(_=(R=D.next()).done);_=!0){var P=R.value,F=P.instrument,G=F.zones.filter((function(Q){return p.isKeyInRange(Q,w)}));if(G.length>0){var z=!0,fe=!1,q=void 0;try{for(var ee,ye=G[Symbol.iterator]();!(z=(ee=ye.next()).done);z=!0){var J=ee.value,ve=J.sample,te=u({},P.generators,J.generators),Xe=u({},P.modulators,J.modulators);return{keyNumber:w,preset:k,instrument:F,sample:ve,generators:te,modulators:Xe}}}catch(Q){fe=!0,q=Q}finally{try{z||ye.return==null||ye.return()}finally{if(fe)throw q}}}}}catch(Q){E=!0,T=Q}finally{try{_||D.return==null||D.return()}finally{if(E)throw T}}}}}return null}))(g,C,y)}},{key:"isKeyInRange",value:function(g,p){return g.keyRange===void 0||g.keyRange.lo<=p&&g.keyRange.hi>=p}},{key:"getBanks",value:function(){return this.presets.reduce((function(g,p){var C=p.header.bank;return g[C]||(g[C]={presets:[]}),g[C].presets[p.header.preset]=p,g}),[])}},{key:"getPresets",value:function(){var g=this.presetData,p=g.presetHeaders,C=g.presetZones,y=g.presetGenerators,w=g.presetModulators;return Object(c.getItemsInZone)(p,C,w,y,this.instruments,s.GeneratorType.Instrument).filter((function(I){return I.header.name!=="EOP"})).map((function(I){return{header:I.header,globalZone:I.globalZone,zones:I.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,instrument:S.reference}}))}}))}},{key:"getInstruments",value:function(){var g=this.presetData,p=g.instrumentHeaders,C=g.instrumentZones,y=g.instrumentModulators,w=g.instrumentGenerators;return Object(c.getItemsInZone)(p,C,y,w,this.samples,s.GeneratorType.SampleId).filter((function(I){return I.header.name!=="EOI"})).map((function(I){return{header:I.header,globalZone:I.globalZone,zones:I.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,sample:S.reference}}))}}))}},{key:"getSamples",value:function(){var g=this;return this.presetData.sampleHeaders.filter((function(p){return p.name!=="EOS"})).map((function(p){if(p.name!=="EOS"&&p.sampleRate<=0)throw new Error("Illegal sample rate of ".concat(p.sampleRate," hz in sample '").concat(p.name,"'"));return p.originalPitch>=128&&p.originalPitch<=254&&(p.originalPitch=60),p.startLoop-=p.start,p.endLoop-=p.start,{header:p,data:new Int16Array(new Uint8Array(g.sampleData.subarray(2*p.start,2*p.end)).buffer)}}))}}]),v})()},"./src/types/bank.ts":function(r,n){},"./src/types/generator.ts":function(r,n,a){var s,o;function i(l,u,m){return u in l?Object.defineProperty(l,u,{value:m,enumerable:!0,configurable:!0,writable:!0}):l[u]=m,l}a.r(n),a.d(n,"GeneratorType",(function(){return o})),a.d(n,"DEFAULT_GENERATOR_VALUES",(function(){return c})),(function(l){l[l.StartAddrsOffset=0]="StartAddrsOffset",l[l.EndAddrsOffset=1]="EndAddrsOffset",l[l.StartLoopAddrsOffset=2]="StartLoopAddrsOffset",l[l.EndLoopAddrsOffset=3]="EndLoopAddrsOffset",l[l.StartAddrsCoarseOffset=4]="StartAddrsCoarseOffset",l[l.ModLFOToPitch=5]="ModLFOToPitch",l[l.VibLFOToPitch=6]="VibLFOToPitch",l[l.ModEnvToPitch=7]="ModEnvToPitch",l[l.InitialFilterFc=8]="InitialFilterFc",l[l.InitialFilterQ=9]="InitialFilterQ",l[l.ModLFOToFilterFc=10]="ModLFOToFilterFc",l[l.ModEnvToFilterFc=11]="ModEnvToFilterFc",l[l.EndAddrsCoarseOffset=12]="EndAddrsCoarseOffset",l[l.ModLFOToVolume=13]="ModLFOToVolume",l[l.Unused1=14]="Unused1",l[l.ChorusEffectsSend=15]="ChorusEffectsSend",l[l.ReverbEffectsSend=16]="ReverbEffectsSend",l[l.Pan=17]="Pan",l[l.Unused2=18]="Unused2",l[l.Unused3=19]="Unused3",l[l.Unused4=20]="Unused4",l[l.DelayModLFO=21]="DelayModLFO",l[l.FreqModLFO=22]="FreqModLFO",l[l.DelayVibLFO=23]="DelayVibLFO",l[l.FreqVibLFO=24]="FreqVibLFO",l[l.DelayModEnv=25]="DelayModEnv",l[l.AttackModEnv=26]="AttackModEnv",l[l.HoldModEnv=27]="HoldModEnv",l[l.DecayModEnv=28]="DecayModEnv",l[l.SustainModEnv=29]="SustainModEnv",l[l.ReleaseModEnv=30]="ReleaseModEnv",l[l.KeyNumToModEnvHold=31]="KeyNumToModEnvHold",l[l.KeyNumToModEnvDecay=32]="KeyNumToModEnvDecay",l[l.DelayVolEnv=33]="DelayVolEnv",l[l.AttackVolEnv=34]="AttackVolEnv",l[l.HoldVolEnv=35]="HoldVolEnv",l[l.DecayVolEnv=36]="DecayVolEnv",l[l.SustainVolEnv=37]="SustainVolEnv",l[l.ReleaseVolEnv=38]="ReleaseVolEnv",l[l.KeyNumToVolEnvHold=39]="KeyNumToVolEnvHold",l[l.KeyNumToVolEnvDecay=40]="KeyNumToVolEnvDecay",l[l.Instrument=41]="Instrument",l[l.Reserved1=42]="Reserved1",l[l.KeyRange=43]="KeyRange",l[l.VelRange=44]="VelRange",l[l.StartLoopAddrsCoarseOffset=45]="StartLoopAddrsCoarseOffset",l[l.KeyNum=46]="KeyNum",l[l.Velocity=47]="Velocity",l[l.InitialAttenuation=48]="InitialAttenuation",l[l.Reserved2=49]="Reserved2",l[l.EndLoopAddrsCoarseOffset=50]="EndLoopAddrsCoarseOffset",l[l.CoarseTune=51]="CoarseTune",l[l.FineTune=52]="FineTune",l[l.SampleId=53]="SampleId",l[l.SampleModes=54]="SampleModes",l[l.Reserved3=55]="Reserved3",l[l.ScaleTuning=56]="ScaleTuning",l[l.ExclusiveClass=57]="ExclusiveClass",l[l.OverridingRootKey=58]="OverridingRootKey",l[l.Unused5=59]="Unused5",l[l.EndOper=60]="EndOper"})(o||(o={}));var c=(i(s={},o.StartAddrsOffset,0),i(s,o.EndAddrsOffset,0),i(s,o.StartLoopAddrsOffset,0),i(s,o.EndLoopAddrsOffset,0),i(s,o.StartAddrsCoarseOffset,0),i(s,o.ModLFOToPitch,0),i(s,o.VibLFOToPitch,0),i(s,o.ModEnvToPitch,0),i(s,o.InitialFilterFc,13500),i(s,o.InitialFilterQ,0),i(s,o.ModLFOToFilterFc,0),i(s,o.ModEnvToFilterFc,0),i(s,o.EndAddrsCoarseOffset,0),i(s,o.ModLFOToVolume,0),i(s,o.ChorusEffectsSend,0),i(s,o.ReverbEffectsSend,0),i(s,o.Pan,0),i(s,o.DelayModLFO,-12e3),i(s,o.FreqModLFO,0),i(s,o.DelayVibLFO,-12e3),i(s,o.FreqVibLFO,0),i(s,o.DelayModEnv,-12e3),i(s,o.AttackModEnv,-12e3),i(s,o.HoldModEnv,-12e3),i(s,o.DecayModEnv,-12e3),i(s,o.SustainModEnv,0),i(s,o.ReleaseModEnv,-12e3),i(s,o.KeyNumToModEnvHold,0),i(s,o.KeyNumToModEnvDecay,0),i(s,o.DelayVolEnv,-12e3),i(s,o.AttackVolEnv,-12e3),i(s,o.HoldVolEnv,-12e3),i(s,o.DecayVolEnv,-12e3),i(s,o.SustainVolEnv,0),i(s,o.ReleaseVolEnv,-12e3),i(s,o.KeyNumToVolEnvHold,0),i(s,o.KeyNumToVolEnvDecay,0),i(s,o.StartLoopAddrsCoarseOffset,0),i(s,o.KeyNum,-1),i(s,o.Velocity,-1),i(s,o.InitialAttenuation,0),i(s,o.EndLoopAddrsCoarseOffset,0),i(s,o.CoarseTune,0),i(s,o.FineTune,0),i(s,o.SampleModes,0),i(s,o.ScaleTuning,100),i(s,o.ExclusiveClass,0),i(s,o.OverridingRootKey,-1),s)},"./src/types/index.ts":function(r,n,a){a.r(n);var s=a("./src/types/bank.ts");for(var o in s)["default"].indexOf(o)<0&&(function(g){a.d(n,g,(function(){return s[g]}))})(o);var i=a("./src/types/generator.ts");a.d(n,"GeneratorType",(function(){return i.GeneratorType})),a.d(n,"DEFAULT_GENERATOR_VALUES",(function(){return i.DEFAULT_GENERATOR_VALUES}));var c=a("./src/types/instrument.ts");for(var o in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(p){a.d(n,p,(function(){return c[p]}))})(o);var l=a("./src/types/key.ts");for(var o in l)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(p){a.d(n,p,(function(){return l[p]}))})(o);var u=a("./src/types/metaData.ts");for(var o in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(p){a.d(n,p,(function(){return u[p]}))})(o);var m=a("./src/types/modulator.ts");a.d(n,"ControllerType",(function(){return m.ControllerType})),a.d(n,"ControllerPolarity",(function(){return m.ControllerPolarity})),a.d(n,"ControllerDirection",(function(){return m.ControllerDirection})),a.d(n,"ControllerPalette",(function(){return m.ControllerPalette})),a.d(n,"Controller",(function(){return m.Controller})),a.d(n,"TransformType",(function(){return m.TransformType})),a.d(n,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return m.DEFAULT_INSTRUMENT_MODULATORS}));var b=a("./src/types/preset.ts");for(var o in b)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(p){a.d(n,p,(function(){return b[p]}))})(o);var d=a("./src/types/presetData.ts");for(var o in d)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(p){a.d(n,p,(function(){return d[p]}))})(o);var h=a("./src/types/sample.ts");a.d(n,"SampleType",(function(){return h.SampleType}));var v=a("./src/types/zone.ts");for(var o in v)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS","SampleType"].indexOf(o)<0&&(function(p){a.d(n,p,(function(){return v[p]}))})(o)},"./src/types/instrument.ts":function(r,n){},"./src/types/key.ts":function(r,n){},"./src/types/metaData.ts":function(r,n){},"./src/types/modulator.ts":function(r,n,a){a.r(n),a.d(n,"ControllerType",(function(){return s})),a.d(n,"ControllerPolarity",(function(){return o})),a.d(n,"ControllerDirection",(function(){return i})),a.d(n,"ControllerPalette",(function(){return c})),a.d(n,"Controller",(function(){return l})),a.d(n,"TransformType",(function(){return u})),a.d(n,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return b}));var s,o,i,c,l,u,m=a("./src/types/generator.ts");(function(d){d[d.Linear=0]="Linear",d[d.Concave=1]="Concave",d[d.Convex=2]="Convex",d[d.Switch=3]="Switch"})(s||(s={})),(function(d){d[d.Unipolar=0]="Unipolar",d[d.Bipolar=1]="Bipolar"})(o||(o={})),(function(d){d[d.Increasing=0]="Increasing",d[d.Decreasing=1]="Decreasing"})(i||(i={})),(function(d){d[d.GeneralController=0]="GeneralController",d[d.MidiController=1]="MidiController"})(c||(c={})),(function(d){d[d.NoController=0]="NoController",d[d.NoteOnVelocity=2]="NoteOnVelocity",d[d.NoteOnKeyNumber=3]="NoteOnKeyNumber",d[d.PolyPressure=10]="PolyPressure",d[d.ChannelPressure=13]="ChannelPressure",d[d.PitchWheel=14]="PitchWheel",d[d.PitchWheelSensitivity=16]="PitchWheelSensitivity",d[d.Link=127]="Link"})(l||(l={})),(function(d){d[d.Linear=0]="Linear",d[d.Absolute=2]="Absolute"})(u||(u={}));var b=[{id:m.GeneratorType.InitialAttenuation,source:{type:s.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:c.GeneralController,index:l.NoteOnVelocity},value:960,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.NoController},transform:u.Linear},{id:m.GeneratorType.InitialFilterFc,source:{type:s.Linear,polarity:o.Unipolar,direction:i.Decreasing,palette:c.GeneralController,index:l.NoteOnVelocity},value:-2400,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.NoController},transform:u.Linear},{id:m.GeneratorType.VibLFOToPitch,source:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.ChannelPressure},value:50,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.NoController},transform:u.Linear},{id:m.GeneratorType.VibLFOToPitch,source:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.MidiController,index:1},value:50,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.NoController},transform:u.Linear},{id:m.GeneratorType.InitialAttenuation,source:{type:s.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:c.MidiController,index:7},value:960,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.NoController},transform:u.Linear},{id:m.GeneratorType.InitialAttenuation,source:{type:s.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:c.MidiController,index:10},value:1e3,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.NoController},transform:u.Linear},{id:m.GeneratorType.InitialAttenuation,source:{type:s.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:c.MidiController,index:11},value:960,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.NoController},transform:u.Linear},{id:m.GeneratorType.ReverbEffectsSend,source:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.MidiController,index:91},value:200,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.NoController},transform:u.Linear},{id:m.GeneratorType.ChorusEffectsSend,source:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.MidiController,index:93},value:200,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.NoController},transform:u.Linear},{id:m.GeneratorType.CoarseTune,source:{type:s.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:c.GeneralController,index:l.PitchWheel},value:12700,valueSource:{type:s.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:c.GeneralController,index:l.PitchWheelSensitivity},transform:u.Linear}]},"./src/types/preset.ts":function(r,n){},"./src/types/presetData.ts":function(r,n){},"./src/types/sample.ts":function(r,n,a){var s;a.r(n),a.d(n,"SampleType",(function(){return s})),(function(o){o[o.EOS=0]="EOS",o[o.Mono=1]="Mono",o[o.Right=2]="Right",o[o.Left=4]="Left",o[o.Linked=8]="Linked",o[o.RomMono=32769]="RomMono",o[o.RomRight=32770]="RomRight",o[o.RomLeft=32772]="RomLeft",o[o.RomLinked=32776]="RomLinked"})(s||(s={}))},"./src/types/zone.ts":function(r,n){},"./src/utils/buffer.ts":function(r,n,a){a.r(n),a.d(n,"getStringFromBuffer",(function(){return s}));var s=function(o){var i=new TextDecoder("utf8").decode(o),c=i.indexOf("\0");return(c===-1?i:i.slice(0,c)).trim()}},"./src/utils/index.ts":function(r,n,a){a.r(n);var s=a("./src/utils/buffer.ts");a.d(n,"getStringFromBuffer",(function(){return s.getStringFromBuffer}));var o=a("./src/utils/memoize.ts");a.d(n,"memoize",(function(){return o.memoize}))},"./src/utils/memoize.ts":function(r,n,a){a.r(n),a.d(n,"memoize",(function(){return s}));var s=function(o){var i={};return function(){for(var c=arguments.length,l=new Array(c),u=0;u<c;u++)l[u]=arguments[u];var m=JSON.stringify(l);if(m in i)return i[m];var b=o.apply(void 0,l);return i[m]=b,b}}}})}))})(fn)),fn.exports}So();var Mr=!1;function Ct(e){const t=e._param;return!t&&!Mr&&(Mr=!0,console.warn("[waveform-playlist] Unable to access Tone.js internal _param. This likely means the Tone.js version is incompatible. Mute scheduling may not work correctly.")),t}var ko=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new Z.Volume(this.gainToDb(e.track.gain)),this.panNode=new Z.Panner({pan:e.track.stereoPan,channelCount:2}),this.muteGain=new Z.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||Z.getDestination();if(e.effects){const o=e.effects(this.muteGain,t,!1);o&&(this.effectsCleanup=o)}else this.muteGain.connect(t);const r=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}]:[]),n=Z.getTransport(),a=Z.getContext().rawContext,s=this.volumeNode.input.input;this.scheduledClips=r.map(o=>{const i=a.createGain();i.gain.value=o.gain,i.connect(s);const c=this.track.startTime+o.startTime,l=n.schedule(u=>{c<this._scheduleGuardOffset||this.startClipSource(o,i,u)},c);return{clipInfo:o,fadeGainNode:i,scheduleId:l}})}startClipSource(e,t,r,n,a){const o=Z.getContext().rawContext.createBufferSource();o.buffer=e.buffer,o.connect(t);const i=n??e.offset,c=a??e.duration;try{o.start(r,i,c)}catch(l){console.warn(`[waveform-playlist] Failed to start source on track "${this.id}" (time=${r}, offset=${i}, duration=${c}):`,l),o.disconnect();return}this.activeSources.add(o),o.onended=()=>{this.activeSources.delete(o)}}setScheduleGuardOffset(e){this._scheduleGuardOffset=e}startMidClipSources(e,t){for(const{clipInfo:r,fadeGainNode:n}of this.scheduledClips){const a=this.track.startTime+r.startTime,s=a+r.duration;if(a<e&&s>e){const o=e-a,i=r.offset+o,c=r.duration-o;this.startClipSource(r,n,t,i,c)}}}stopAllSources(){this.activeSources.forEach(e=>{try{e.stop()}catch(t){console.warn(`[waveform-playlist] Error stopping source on track "${this.id}":`,t)}}),this.activeSources.clear()}scheduleFades(e,t,r=0){const{clipInfo:n,fadeGainNode:a}=e,s=a.gain;s.cancelScheduledValues(0);const o=r-n.offset;if(n.fadeIn&&o<n.fadeIn.duration){const i=n.fadeIn.duration;if(o<=0)In(s,t,i,n.fadeIn.type||"linear",0,n.gain);else{const c=i-o,l=o/i,u=n.gain*l;In(s,t,c,n.fadeIn.type||"linear",u,n.gain)}}else s.setValueAtTime(n.gain,t);if(n.fadeOut){const c=n.duration-n.fadeOut.duration-o;if(c>0){const l=t+c;Sn(s,l,n.fadeOut.duration,n.fadeOut.type||"linear",n.gain,0)}else if(c>-n.fadeOut.duration){const l=-c,u=n.fadeOut.duration-l,m=l/n.fadeOut.duration,b=n.gain*(1-m);Sn(s,t,u,n.fadeOut.type||"linear",b,0)}}}prepareFades(e,t){this.scheduledClips.forEach(r=>{const n=this.track.startTime+r.clipInfo.startTime,a=n+r.clipInfo.duration;if(!(t>=a))if(t>=n){const s=t-n+r.clipInfo.offset;this.scheduleFades(r,e,s)}else{const s=n-t;this.scheduleFades(r,e+s,r.clipInfo.offset)}})}cancelFades(){this.scheduledClips.forEach(({fadeGainNode:e,clipInfo:t})=>{const r=e.gain;r.cancelScheduledValues(0),r.setValueAtTime(t.gain,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;const t=e?0:1;Ct(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=Z.getTransport();if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach((t,r)=>{try{e.clear(t.scheduleId)}catch(n){console.warn(`[waveform-playlist] Error clearing schedule ${r} on track "${this.id}":`,n)}try{t.fadeGainNode.disconnect()}catch(n){console.warn(`[waveform-playlist] Error disconnecting fadeGain ${r} on track "${this.id}":`,n)}});try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const e=this.scheduledClips[this.scheduledClips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.scheduledClips[0]?.clipInfo.buffer}get muted(){return this.track.muted}get startTime(){return this.track.startTime}};function Ao(e){return e===35||e===36?"kick":e>=37&&e<=40?"snare":e===41||e===43||e===45||e===47||e===48||e===50?"tom":"cymbal"}var _o=class{constructor(e){this.track=e.track,this.volumeNode=new Z.Volume(this.gainToDb(e.track.gain)),this.panNode=new Z.Panner(e.track.stereoPan),this.muteGain=new Z.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain),this.synth=new Z.PolySynth(Z.Synth,e.synthOptions),this.synth.connect(this.volumeNode),this.kickSynth=new Z.PolySynth(Z.MembraneSynth,{voice:Z.MembraneSynth,options:{pitchDecay:.05,octaves:6,envelope:{attack:.001,decay:.4,sustain:0,release:.1}}}),this.snareSynth=new Z.NoiseSynth({noise:{type:"white"},envelope:{attack:.001,decay:.15,sustain:0,release:.05}}),this.cymbalSynth=new Z.PolySynth(Z.MetalSynth,{voice:Z.MetalSynth,options:{envelope:{attack:.001,decay:.3,release:.1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5}}),this.tomSynth=new Z.PolySynth(Z.MembraneSynth,{voice:Z.MembraneSynth,options:{pitchDecay:.08,octaves:4,envelope:{attack:.001,decay:.3,sustain:0,release:.1}}}),this.kickSynth.connect(this.volumeNode),this.snareSynth.connect(this.volumeNode),this.cymbalSynth.connect(this.volumeNode),this.tomSynth.connect(this.volumeNode);const t=e.destination||Z.getDestination();if(e.effects){const r=e.effects(this.muteGain,t,!1);r&&(this.effectsCleanup=r)}else this.muteGain.connect(t);this.scheduledClips=e.clips.map(r=>{const n=r.notes.filter(i=>{const c=i.time+i.duration;return i.time<r.offset+r.duration&&c>r.offset}),a=this.track.startTime+r.startTime,s=n.map(i=>{const c=i.time-r.offset,l=Math.max(0,c),u=Math.min(i.duration-Math.max(0,r.offset-i.time),r.duration-l);return{time:a+l,note:i.name,midi:i.midi,duration:Math.max(0,u),velocity:i.velocity,channel:i.channel}}),o=new Z.Part((i,c)=>{c.duration>0&&this.triggerNote(c.midi,c.note,c.duration,i,c.velocity,c.channel)},s);return o.start(0),{clipInfo:r,part:o}})}triggerNote(e,t,r,n,a,s){if(s===9)switch(Ao(e)){case"kick":this.kickSynth.triggerAttackRelease("C1",r,n,a);break;case"snare":try{this.snareSynth.triggerAttackRelease(r,n,a)}catch(i){console.warn("[waveform-playlist] Snare overlap — previous hit still decaying, skipped:",i)}break;case"tom":{const i={41:"G1",43:"A1",45:"C2",47:"D2",48:"E2",50:"G2"};this.tomSynth.triggerAttackRelease(i[e]||"C2",r,n,a);break}case"cymbal":this.cymbalSynth.triggerAttackRelease("C4",r,n,a);break}else this.synth.triggerAttackRelease(t,r,n,a)}gainToDb(e){return 20*Math.log10(e)}setScheduleGuardOffset(e){}startMidClipSources(e,t){for(const{clipInfo:r}of this.scheduledClips){const n=this.track.startTime+r.startTime,a=n+r.duration;if(n<e&&a>e)for(const s of r.notes){const o=s.time-r.offset,i=n+Math.max(0,o),c=i+s.duration;if(i<e&&c>e){const l=c-e;try{this.triggerNote(s.midi,s.name,l,t,s.velocity,s.channel)}catch(u){console.warn(`[waveform-playlist] Failed to start mid-clip MIDI note "${s.name}" on track "${this.id}":`,u)}}}}}stopAllSources(){const e=Z.getContext().rawContext.currentTime;try{this.synth.releaseAll(e),this.kickSynth.releaseAll(e),this.cymbalSynth.releaseAll(e),this.tomSynth.releaseAll(e)}catch(t){console.warn(`[waveform-playlist] Error releasing synth on track "${this.id}":`,t)}}prepareFades(e,t){}cancelFades(){}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;const t=e?0:1;Ct(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during MIDI track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach(({part:t},r)=>{try{t.dispose()}catch(n){console.warn(`[waveform-playlist] Error disposing Part ${r} on MIDI track "${this.id}":`,n)}});const e=[this.synth,this.kickSynth,this.snareSynth,this.cymbalSynth,this.tomSynth];for(const t of e)try{t?.dispose()}catch(r){console.warn(`[waveform-playlist] Error disposing synth on MIDI track "${this.id}":`,r)}try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on MIDI track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on MIDI track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on MIDI track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const e=this.scheduledClips[this.scheduledClips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get muted(){return this.track.muted}get startTime(){return this.track.startTime}},na=class kn{constructor(t){this.activeSources=new Set,this.track=t.track,this.soundFontCache=t.soundFontCache,this.programNumber=t.programNumber??0,this.bankNumber=t.isPercussion?128:0,this.volumeNode=new Z.Volume(this.gainToDb(t.track.gain)),this.panNode=new Z.Panner(t.track.stereoPan),this.muteGain=new Z.Gain(t.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const r=t.destination||Z.getDestination();if(t.effects){const n=t.effects(this.muteGain,r,!1);n&&(this.effectsCleanup=n)}else this.muteGain.connect(r);this.scheduledClips=t.clips.map(n=>{const a=n.notes.filter(c=>{const l=c.time+c.duration;return c.time<n.offset+n.duration&&l>n.offset}),s=this.track.startTime+n.startTime,o=a.map(c=>{const l=c.time-n.offset,u=Math.max(0,l),m=Math.min(c.duration-Math.max(0,n.offset-c.time),n.duration-u);return{time:s+u,note:c.name,midi:c.midi,duration:Math.max(0,m),velocity:c.velocity,channel:c.channel}}),i=new Z.Part((c,l)=>{l.duration>0&&this.triggerNote(l.midi,l.duration,c,l.velocity,l.channel)},o);return i.start(0),{clipInfo:n,part:i}})}triggerNote(t,r,n,a,s){const o=s===9?128:this.bankNumber,i=s===9?0:this.programNumber,c=this.soundFontCache.getAudioBuffer(t,o,i);if(!c){kn._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${o}, preset ${i}). Subsequent missing samples will be silent.`),kn._missingSampleWarned=!0);return}const l=Z.getContext().rawContext,u=l.createBufferSource();u.buffer=c.buffer,u.playbackRate.value=c.playbackRate,(c.loopMode===1||c.loopMode===3)&&(u.loop=!0,u.loopStart=c.loopStart,u.loopEnd=c.loopEnd);const m=c.buffer.duration/c.playbackRate,b=c.loopMode===0?Math.max(r,m):r,d=a*a,h=l.createGain(),{attackVolEnv:v,holdVolEnv:g,decayVolEnv:p,sustainVolEnv:C,releaseVolEnv:y}=c,w=d*C;h.gain.setValueAtTime(0,n),h.gain.linearRampToValueAtTime(d,n+v),g>.001&&h.gain.setValueAtTime(d,n+v+g);const I=n+v+g;h.gain.linearRampToValueAtTime(w,I+p),h.gain.setValueAtTime(w,n+b),h.gain.linearRampToValueAtTime(0,n+b+y),u.connect(h),h.connect(this.volumeNode.input.input),this.activeSources.add(u),u.onended=()=>{this.activeSources.delete(u);try{h.disconnect()}catch(S){console.warn("[waveform-playlist] GainNode already disconnected:",S)}},u.start(n),u.stop(n+b+y)}gainToDb(t){return 20*Math.log10(t)}setScheduleGuardOffset(t){}startMidClipSources(t,r){for(const{clipInfo:n}of this.scheduledClips){const a=this.track.startTime+n.startTime,s=a+n.duration;if(a<t&&s>t)for(const o of n.notes){const i=o.time-n.offset,c=a+Math.max(0,i),l=c+o.duration;if(c<t&&l>t){const u=l-t;try{this.triggerNote(o.midi,u,r,o.velocity,o.channel)}catch(m){console.warn(`[waveform-playlist] Failed to start mid-clip SoundFont note on track "${this.id}":`,m)}}}}}stopAllSources(){for(const t of this.activeSources)try{t.stop()}catch(r){console.warn("[waveform-playlist] Error stopping AudioBufferSourceNode:",r)}this.activeSources.clear()}prepareFades(t,r){}cancelFades(){}setVolume(t){this.track.gain=t,this.volumeNode.volume.value=this.gainToDb(t)}setPan(t){this.track.stereoPan=t,this.panNode.pan.value=t}setMute(t){this.track.muted=t;const r=t?0:1;Ct(this.muteGain.gain)?.setValueAtTime(r,0),this.muteGain.gain.value=r}setSolo(t){this.track.soloed=t}dispose(){if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during SoundFont track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach(({part:t},r)=>{try{t.dispose()}catch(n){console.warn(`[waveform-playlist] Error disposing Part ${r} on SoundFont track "${this.id}":`,n)}});try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on SoundFont track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on SoundFont track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on SoundFont track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const t=this.scheduledClips[this.scheduledClips.length-1];return t.clipInfo.startTime+t.clipInfo.duration}get muted(){return this.track.muted}get startTime(){return this.track.startTime}};na._missingSampleWarned=!1;var Eo=na,Mo=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this._completionEventId=null,this._loopHandler=null,this._loopEnabled=!1,this._loopStart=0,this._loopEnd=0,this.masterVolume=new Z.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,Z.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)}clearCompletionEvent(){if(this._completionEventId!==null){try{Z.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await Z.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},r=new ko(t);return this.tracks.set(r.id,r),this.manualMuteState.set(r.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(r.id),r}addMidiTrack(e){const t={...e,destination:this.masterVolume},r=new _o(t);return this.tracks.set(r.id,r),this.manualMuteState.set(r.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(r.id),r}addSoundFontTrack(e){const t={...e,destination:this.masterVolume},r=new Eo(t);return this.tracks.set(r.id,r),this.manualMuteState.set(r.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(r.id),r}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,r){if(!this.isInitialized)throw new Error("[waveform-playlist] TonePlayout not initialized. Call init() first.");const n=e??Z.now(),a=Z.getTransport();this.clearCompletionEvent();const s=t??0;this.tracks.forEach(o=>{o.cancelFades(),o.prepareFades(n,s)}),r!==void 0&&(this._completionEventId=a.scheduleOnce(()=>{this._completionEventId=null;try{this.onPlaybackCompleteCallback?.()}catch(o){console.warn("[waveform-playlist] Error in playback completion callback:",o)}},s+r));try{a.state!=="stopped"&&a.stop(),this.tracks.forEach(o=>o.stopAllSources()),a.loopStart=this._loopStart,a.loopEnd=this._loopEnd,a.loop=this._loopEnabled,this.tracks.forEach(o=>o.setScheduleGuardOffset(s)),t!==void 0?a.start(n,t):a.start(n),a._clock._lastUpdate=n,this.tracks.forEach(o=>{o.startMidClipSources(s,n)})}catch(o){throw this.clearCompletionEvent(),this.tracks.forEach(i=>i.cancelFades()),console.warn("[waveform-playlist] Transport.start() failed. Audio playback could not begin.",o),o}}pause(){const e=Z.getTransport();try{e.pause()}catch(t){console.warn("[waveform-playlist] Transport.pause() failed:",t)}this.tracks.forEach(t=>t.stopAllSources()),this.tracks.forEach(t=>t.cancelFades()),this.clearCompletionEvent()}stop(){const e=Z.getTransport();try{e.stop()}catch(t){console.warn("[waveform-playlist] Transport.stop() failed:",t)}if(this._loopHandler){try{e.off("loop",this._loopHandler)}catch(t){console.warn("[waveform-playlist] Error removing loop handler:",t)}this._loopHandler=null}this.tracks.forEach(t=>{try{t.stopAllSources()}catch(r){console.warn(`[waveform-playlist] Error stopping sources for track "${t.id}":`,r)}}),this.tracks.forEach(t=>{try{t.cancelFades()}catch(r){console.warn(`[waveform-playlist] Error canceling fades for track "${t.id}":`,r)}}),this.clearCompletionEvent()}setMasterGain(e){this.masterVolume.volume.value=this.gainToDb(e)}setSolo(e,t){const r=this.tracks.get(e);r&&(r.setSolo(t),t?this.soloedTracks.add(e):this.soloedTracks.delete(e),this.updateSoloMuting())}updateSoloMuting(){const e=this.soloedTracks.size>0;this.tracks.forEach((t,r)=>{if(e)if(!this.soloedTracks.has(r))t.setMute(!0);else{const n=this.manualMuteState.get(r)??!1;t.setMute(n)}else{const n=this.manualMuteState.get(r)??!1;t.setMute(n)}})}setMute(e,t){const r=this.tracks.get(e);r&&(this.manualMuteState.set(e,t),r.setMute(t))}setLoop(e,t,r){this._loopEnabled=e,this._loopStart=t,this._loopEnd=r;const n=Z.getTransport();try{n.loopStart=t,n.loopEnd=r,n.loop=e}catch(a){console.warn("[waveform-playlist] Error configuring Transport loop:",a);return}e&&!this._loopHandler?(this._loopHandler=()=>{const a=Z.now();this.tracks.forEach(s=>{try{s.stopAllSources(),s.cancelFades(),s.setScheduleGuardOffset(this._loopStart),s.startMidClipSources(this._loopStart,a),s.prepareFades(a,this._loopStart)}catch(o){console.warn(`[waveform-playlist] Error re-scheduling track "${s.id}" on loop:`,o)}})},n.on("loop",this._loopHandler)):!e&&this._loopHandler&&(n.off("loop",this._loopHandler),this._loopHandler=null)}getCurrentTime(){return Z.getTransport().seconds}seekTo(e){Z.getTransport().seconds=e}dispose(){try{this.stop()}catch(e){console.warn("[waveform-playlist] Error stopping Transport during dispose:",e)}if(this.tracks.forEach(e=>{try{e.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing track "${e.id}":`,t)}}),this.tracks.clear(),this.effectsCleanup)try{this.effectsCleanup()}catch(e){console.warn("[waveform-playlist] Error during master effects cleanup:",e)}try{this.masterVolume.dispose()}catch(e){console.warn("[waveform-playlist] Error disposing master volume:",e)}}get context(){return Z.getContext()}get sampleRate(){return Z.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Pt=null;function jt(){return Pt||(Pt=new Z.Context,Z.setContext(Pt)),Pt}function To(){return jt().rawContext}function Ro(e){let t=null,r=!1,n=0,a=!1,s=0,o=0,i=!1;function c(u,m){const b=m.clips.filter(h=>h.audioBuffer&&!h.midiNotes),d=m.clips.filter(h=>h.midiNotes&&h.midiNotes.length>0);if(b.length>0){const h=Math.min(...b.map(Bt)),v=Math.max(...b.map(Sr)),g={id:m.id,name:m.name,gain:m.volume,muted:m.muted,soloed:m.soloed,stereoPan:m.pan,startTime:h,endTime:v},p=b.map(C=>({buffer:C.audioBuffer,startTime:Bt(C)-h,duration:Ar(C),offset:kr(C),fadeIn:C.fadeIn,fadeOut:C.fadeOut,gain:C.gain}));u.addTrack({clips:p,track:g,effects:m.effects})}if(d.length>0){const h=Math.min(...d.map(Bt)),v=Math.max(...d.map(Sr)),p={id:b.length>0?`${m.id}:midi`:m.id,name:m.name,gain:m.volume,muted:m.muted,soloed:m.soloed,stereoPan:m.pan,startTime:h,endTime:v},C=d.map(y=>({notes:y.midiNotes,startTime:Bt(y)-h,duration:Ar(y),offset:kr(y)}));if(e?.soundFontCache?.isLoaded){const y=d[0],I=y.midiChannel===9,S=y.midiProgram??0;u.addSoundFontTrack({clips:C,track:p,soundFontCache:e.soundFontCache,programNumber:S,isPercussion:I,effects:m.effects})}else e?.soundFontCache&&console.warn(`[waveform-playlist] SoundFont not loaded for track "${m.name}" — falling back to PolySynth.`),u.addMidiTrack({clips:C,track:p,effects:m.effects})}}function l(u){if(t){try{t.dispose()}catch(b){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",b)}t=null}n++;const m=n;t=new Mo({effects:e?.effects}),i&&t.init().catch(b=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",b),i=!1});for(const b of u)c(t,b);t.applyInitialSoloState(),t.setLoop(a,s,o),t.setOnPlaybackComplete(()=>{m===n&&(r=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(u){l(u)},addTrack(u){if(!t)throw new Error("[waveform-playlist] adapter.addTrack() called but no playout exists. Call setTracks() first to initialize the playout.");c(t,u),t.applyInitialSoloState()},play(u,m){if(!t){console.warn("[waveform-playlist] adapter.play() called but no playout is available. Tracks may not have been set, or the adapter was disposed.");return}const b=m!==void 0?m-u:void 0;t.play(Z.now(),u,b),r=!0},pause(){t?.pause(),r=!1},stop(){t?.stop(),r=!1},seek(u){t?.seekTo(u)},getCurrentTime(){return t?.getCurrentTime()??0},isPlaying(){return r},setMasterVolume(u){t?.setMasterGain(u)},setTrackVolume(u,m){t?.getTrack(u)?.setVolume(m)},setTrackMute(u,m){t?.setMute(u,m)},setTrackSolo(u,m){t?.setSolo(u,m)},setTrackPan(u,m){t?.getTrack(u)?.setPan(m)},setLoop(u,m,b){a=u,s=m,o=b,t?.setLoop(u,m,b)},dispose(){try{t?.dispose()}catch(u){console.warn("[waveform-playlist] Error disposing playout:",u)}t=null,r=!1}}}function ra(e,t,r,n){let a=t;const s=-e.startSample;if(a=Math.max(a,s),n>0){const o=r[n-1],c=o.startSample+o.durationSamples-e.startSample;a=Math.max(a,c)}if(n<r.length-1){const i=r[n+1].startSample-(e.startSample+e.durationSamples);a=Math.min(a,i)}return a}function aa(e,t,r,n,a,s){let o=t;if(r==="left"){if(o=Math.max(o,-e.startSample),o=Math.max(o,-e.offsetSamples),a>0){const i=n[a-1],c=i.startSample+i.durationSamples;o=Math.max(o,c-e.startSample)}o=Math.min(o,e.durationSamples-s)}else if(o=Math.max(o,s-e.durationSamples),o=Math.min(o,e.sourceDurationSamples-e.offsetSamples-e.durationSamples),a<n.length-1){const i=n[a+1];o=Math.min(o,i.startSample-e.startSample-e.durationSamples)}return o}function Do(e,t){return Math.floor(e/t)*t}function $o(e,t){const r=t-e.startSample,n=e.durationSamples-r,a=e.name?`${e.name} (1)`:void 0,s=e.name?`${e.name} (2)`:void 0,o=Cn({startSample:e.startSample,durationSamples:r,offsetSamples:e.offsetSamples,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:a,color:e.color,fadeIn:e.fadeIn,audioBuffer:e.audioBuffer,waveformData:e.waveformData}),i=Cn({startSample:t,durationSamples:n,offsetSamples:e.offsetSamples+r,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:s,color:e.color,fadeOut:e.fadeOut,audioBuffer:e.audioBuffer,waveformData:e.waveformData});return{left:o,right:i}}function oa(e,t,r){const n=e.startSample+e.durationSamples;if(t<=e.startSample||t>=n)return!1;const a=t-e.startSample,s=n-t;return a>=r&&s>=r}function mn(e){let t=0;for(const r of e)for(const n of r.clips){const s=(n.startSample+n.durationSamples)/n.sampleRate;t=Math.max(t,s)}return t}function Fo(e,t){if(t.length===0)return 0;let r=0,n=Math.abs(t[0]-e);for(let a=1;a<t.length;a++){const s=Math.abs(t[a]-e);s<n&&(n=s,r=a)}return r}function Tr(e,t){return Math.max(0,Math.min(e,t))}var Bo=44100,Po=1024,Vo=[256,512,1024,2048,4096,8192],Rr=.1,Zo=class{constructor(e={}){if(this._tracks=[],this._currentTime=0,this._playStartPosition=0,this._isPlaying=!1,this._selectedTrackId=null,this._selectionStart=0,this._selectionEnd=0,this._masterVolume=1,this._loopStart=0,this._loopEnd=0,this._isLoopEnabled=!1,this._tracksVersion=0,this._animFrameId=null,this._disposed=!1,this._listeners=new Map,this._sampleRate=e.sampleRate??Bo,this._zoomLevels=[...e.zoomLevels??Vo],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??Po,r=this._zoomLevels.indexOf(t);if(r===-1)throw new Error(`PlaylistEngine: samplesPerPixel ${t} is not in zoomLevels [${this._zoomLevels.join(", ")}]. Either pass a samplesPerPixel value that exists in zoomLevels, or include ${t} in your zoomLevels array.`);this._zoomIndex=r}getState(){return{tracks:this._tracks.map(e=>({...e,clips:[...e.clips]})),tracksVersion:this._tracksVersion,duration:mn(this._tracks),currentTime:this._currentTime,isPlaying:this._isPlaying,samplesPerPixel:this._zoomLevels[this._zoomIndex],sampleRate:this._sampleRate,selectedTrackId:this._selectedTrackId,zoomIndex:this._zoomIndex,canZoomIn:this._zoomIndex>0,canZoomOut:this._zoomIndex<this._zoomLevels.length-1,selectionStart:this._selectionStart,selectionEnd:this._selectionEnd,masterVolume:this._masterVolume,loopStart:this._loopStart,loopEnd:this._loopEnd,isLoopEnabled:this._isLoopEnabled}}setTracks(e){this._tracks=[...e],this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}addTrack(e){this._tracks=[...this._tracks,e],this._tracksVersion++,this._adapter?.addTrack?this._adapter.addTrack(e):this._adapter?.setTracks(this._tracks),this._emitStateChange()}removeTrack(e){this._tracks.some(t=>t.id===e)&&(this._tracks=this._tracks.filter(t=>t.id!==e),this._tracksVersion++,this._selectedTrackId===e&&(this._selectedTrackId=null),this._adapter?.setTracks(this._tracks),this._emitStateChange())}selectTrack(e){e!==this._selectedTrackId&&(this._selectedTrackId=e,this._emitStateChange())}moveClip(e,t,r){const n=this._tracks.find(l=>l.id===e);if(!n){console.warn(`[waveform-playlist/engine] moveClip: track "${e}" not found`);return}const a=n.clips.findIndex(l=>l.id===t);if(a===-1){console.warn(`[waveform-playlist/engine] moveClip: clip "${t}" not found in track "${e}"`);return}const s=n.clips[a],o=wr(n.clips),i=o.findIndex(l=>l.id===t),c=ra(s,r,o,i);c!==0&&(this._tracks=this._tracks.map(l=>{if(l.id!==e)return l;const u=l.clips.map((m,b)=>b===a?{...m,startSample:Math.floor(m.startSample+c)}:m);return{...l,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}splitClip(e,t,r){const n=this._tracks.find(l=>l.id===e);if(!n){console.warn(`[waveform-playlist/engine] splitClip: track "${e}" not found`);return}const a=n.clips.findIndex(l=>l.id===t);if(a===-1){console.warn(`[waveform-playlist/engine] splitClip: clip "${t}" not found in track "${e}"`);return}const s=n.clips[a],o=Math.floor(Rr*this._sampleRate);if(!oa(s,r,o)){console.warn(`[waveform-playlist/engine] splitClip: cannot split clip "${t}" at sample ${r} (clip range: ${s.startSample}–${s.startSample+s.durationSamples}, minDuration: ${o})`);return}const{left:i,right:c}=$o(s,r);this._tracks=this._tracks.map(l=>{if(l.id!==e)return l;const u=[...l.clips];return u.splice(a,1,i,c),{...l,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}trimClip(e,t,r,n){const a=this._tracks.find(m=>m.id===e);if(!a){console.warn(`[waveform-playlist/engine] trimClip: track "${e}" not found`);return}const s=a.clips.findIndex(m=>m.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] trimClip: clip "${t}" not found in track "${e}"`);return}const o=a.clips[s],i=wr(a.clips),c=i.findIndex(m=>m.id===t),l=Math.floor(Rr*this._sampleRate),u=aa(o,n,r,i,c,l);u!==0&&(this._tracks=this._tracks.map(m=>{if(m.id!==e)return m;const b=m.clips.map((d,h)=>h!==s?d:r==="left"?{...d,startSample:d.startSample+u,offsetSamples:d.offsetSamples+u,durationSamples:d.durationSamples-u}:{...d,durationSamples:d.durationSamples+u});return{...m,clips:b}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}async init(){this._adapter&&await this._adapter.init()}play(e,t){const r=this._currentTime,n=this._playStartPosition;if(e!==void 0){const a=mn(this._tracks);this._currentTime=Tr(e,a)}if(this._playStartPosition=this._currentTime,this._adapter){if(t!==void 0)this._adapter.setLoop(!1,this._loopStart,this._loopEnd);else if(this._isLoopEnabled){const a=this._currentTime<this._loopEnd;this._adapter.setLoop(a,this._loopStart,this._loopEnd)}try{this._adapter.play(this._currentTime,t)}catch(a){throw this._currentTime=r,this._playStartPosition=n,a}}this._isPlaying=!0,this._startTimeUpdateLoop(),this._emit("play"),this._emitStateChange()}pause(){this._isPlaying=!1,this._stopTimeUpdateLoop(),this._adapter?.pause(),this._adapter&&(this._currentTime=this._adapter.getCurrentTime()),this._emit("pause"),this._emitStateChange()}stop(){this._isPlaying=!1,this._currentTime=this._playStartPosition,this._stopTimeUpdateLoop(),this._adapter?.setLoop(!1,this._loopStart,this._loopEnd),this._adapter?.stop(),this._emit("stop"),this._emitStateChange()}seek(e){const t=mn(this._tracks);this._currentTime=Tr(e,t),this._adapter?.seek(this._currentTime),this._emitStateChange()}setMasterVolume(e){e!==this._masterVolume&&(this._masterVolume=e,this._adapter?.setMasterVolume(e),this._emitStateChange())}getCurrentTime(){return this._isPlaying&&this._adapter?this._adapter.getCurrentTime():this._currentTime}setSelection(e,t){const r=Math.min(e,t),n=Math.max(e,t);r===this._selectionStart&&n===this._selectionEnd||(this._selectionStart=r,this._selectionEnd=n,this._emitStateChange())}setLoopRegion(e,t){const r=Math.min(e,t),n=Math.max(e,t);r===this._loopStart&&n===this._loopEnd||(this._loopStart=r,this._loopEnd=n,this._adapter?.setLoop(this._isLoopEnabled&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setLoopEnabled(e){e!==this._isLoopEnabled&&(this._isLoopEnabled=e,this._adapter?.setLoop(e&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setTrackVolume(e,t){const r=this._tracks.find(n=>n.id===e);r&&(r.volume=t),this._adapter?.setTrackVolume(e,t)}setTrackMute(e,t){const r=this._tracks.find(n=>n.id===e);r&&(r.muted=t),this._adapter?.setTrackMute(e,t)}setTrackSolo(e,t){const r=this._tracks.find(n=>n.id===e);r&&(r.soloed=t),this._adapter?.setTrackSolo(e,t)}setTrackPan(e,t){const r=this._tracks.find(n=>n.id===e);r&&(r.pan=t),this._adapter?.setTrackPan(e,t)}zoomIn(){this._zoomIndex>0&&(this._zoomIndex--,this._emitStateChange())}zoomOut(){this._zoomIndex<this._zoomLevels.length-1&&(this._zoomIndex++,this._emitStateChange())}setZoomLevel(e){const t=Fo(e,this._zoomLevels);t!==this._zoomIndex&&(this._zoomIndex=t,this._emitStateChange())}on(e,t){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t)}off(e,t){this._listeners.get(e)?.delete(t)}dispose(){if(!this._disposed){this._disposed=!0,this._stopTimeUpdateLoop();try{this._adapter?.dispose()}catch(e){console.warn("[waveform-playlist/engine] Error disposing adapter:",e)}this._listeners.clear()}}_emit(e,...t){const r=this._listeners.get(e);if(r)for(const n of r)try{n(...t)}catch(a){console.warn("[waveform-playlist/engine] Error in event listener:",a)}}_isBeforeLoopEnd(){return this._isPlaying?(this._adapter?.getCurrentTime()??this._currentTime)<this._loopEnd:!0}_emitStateChange(){this._emit("statechange",this.getState())}_startTimeUpdateLoop(){if(typeof requestAnimationFrame>"u")return;this._stopTimeUpdateLoop();const e=()=>{this._disposed||!this._isPlaying||(this._adapter&&(this._currentTime=this._adapter.getCurrentTime(),this._emit("timeupdate",this._currentTime)),this._animFrameId=requestAnimationFrame(e))};this._animFrameId=requestAnimationFrame(e)}_stopTimeUpdateLoop(){this._animFrameId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this._animFrameId),this._animFrameId=null)}};const Lo=new Map([["bold",B.createElement(B.Fragment,null,B.createElement("path",{d:"M144,128a16,16,0,1,1-16-16A16,16,0,0,1,144,128ZM60,112a16,16,0,1,0,16,16A16,16,0,0,0,60,112Zm136,0a16,16,0,1,0,16,16A16,16,0,0,0,196,112Z"}))],["duotone",B.createElement(B.Fragment,null,B.createElement("path",{d:"M240,96v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V96A16,16,0,0,1,32,80H224A16,16,0,0,1,240,96Z",opacity:"0.2"}),B.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["fill",B.createElement(B.Fragment,null,B.createElement("path",{d:"M224,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V96A16,16,0,0,0,224,80ZM60,140a12,12,0,1,1,12-12A12,12,0,0,1,60,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,196,140Z"}))],["light",B.createElement(B.Fragment,null,B.createElement("path",{d:"M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM60,118a10,10,0,1,0,10,10A10,10,0,0,0,60,118Zm136,0a10,10,0,1,0,10,10A10,10,0,0,0,196,118Z"}))],["regular",B.createElement(B.Fragment,null,B.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["thin",B.createElement(B.Fragment,null,B.createElement("path",{d:"M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-76-8a8,8,0,1,0,8,8A8,8,0,0,0,60,120Zm136,0a8,8,0,1,0,8,8A8,8,0,0,0,196,120Z"}))]]),Go=new Map([["bold",B.createElement(B.Fragment,null,B.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",B.createElement(B.Fragment,null,B.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),B.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",B.createElement(B.Fragment,null,B.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",B.createElement(B.Fragment,null,B.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",B.createElement(B.Fragment,null,B.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",B.createElement(B.Fragment,null,B.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"}))]]),Wo=new Map([["bold",B.createElement(B.Fragment,null,B.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",B.createElement(B.Fragment,null,B.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),B.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",B.createElement(B.Fragment,null,B.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",B.createElement(B.Fragment,null,B.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",B.createElement(B.Fragment,null,B.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",B.createElement(B.Fragment,null,B.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"}))]]),No=new Map([["bold",B.createElement(B.Fragment,null,B.createElement("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"}))],["duotone",B.createElement(B.Fragment,null,B.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),B.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["fill",B.createElement(B.Fragment,null,B.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["light",B.createElement(B.Fragment,null,B.createElement("path",{d:"M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"}))],["regular",B.createElement(B.Fragment,null,B.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["thin",B.createElement(B.Fragment,null,B.createElement("path",{d:"M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"}))]]),Oo=f.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),It=B.forwardRef((e,t)=>{const{alt:r,color:n,size:a,weight:s,mirrored:o,children:i,weights:c,...l}=e,{color:u="currentColor",size:m,weight:b="regular",mirrored:d=!1,...h}=B.useContext(Oo);return B.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:a??m,height:a??m,fill:n??u,viewBox:"0 0 256 256",transform:o||d?"scale(-1, 1)":void 0,...h,...l},!!r&&B.createElement("title",null,r),i,c.get(s??b))});It.displayName="IconBase";const sa=B.forwardRef((e,t)=>B.createElement(It,{ref:t,...e,weights:Lo}));sa.displayName="DotsThreeIcon";const ia=B.forwardRef((e,t)=>B.createElement(It,{ref:t,...e,weights:Go}));ia.displayName="SpeakerHighIcon";const la=B.forwardRef((e,t)=>B.createElement(It,{ref:t,...e,weights:Wo}));la.displayName="SpeakerLowIcon";const ca=B.forwardRef((e,t)=>B.createElement(It,{ref:t,...e,weights:No}));ca.displayName="XIcon";const Ho=ca;$.span`
|
|
67
2
|
font-family: 'Courier New', Monaco, monospace;
|
|
68
3
|
font-size: 1rem;
|
|
69
4
|
font-weight: 600;
|
|
70
5
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
71
6
|
user-select: none;
|
|
72
|
-
`;var
|
|
7
|
+
`;var Tn=$.button`
|
|
73
8
|
display: inline-flex;
|
|
74
9
|
align-items: center;
|
|
75
10
|
justify-content: center;
|
|
@@ -100,37 +35,37 @@
|
|
|
100
35
|
opacity: 0.6;
|
|
101
36
|
cursor: not-allowed;
|
|
102
37
|
}
|
|
103
|
-
|
|
38
|
+
`;$(Tn)`
|
|
104
39
|
padding: 0.25rem 0.5rem;
|
|
105
40
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
106
|
-
|
|
41
|
+
`;$(Tn)`
|
|
107
42
|
padding: 0.5rem;
|
|
108
43
|
min-width: 2.25rem;
|
|
109
44
|
min-height: 2.25rem;
|
|
110
|
-
|
|
45
|
+
`;$(Tn)`
|
|
111
46
|
padding: 0.25rem;
|
|
112
47
|
min-width: 1.75rem;
|
|
113
48
|
min-height: 1.75rem;
|
|
114
49
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
115
|
-
`;var
|
|
50
|
+
`;var jo=$.div`
|
|
116
51
|
display: inline-flex;
|
|
117
52
|
align-items: center;
|
|
118
53
|
gap: 0.5rem;
|
|
119
|
-
`,
|
|
54
|
+
`,zo=$.input`
|
|
120
55
|
cursor: pointer;
|
|
121
56
|
accent-color: ${e=>e.theme.inputFocusBorder};
|
|
122
57
|
|
|
123
58
|
&:disabled {
|
|
124
59
|
cursor: not-allowed;
|
|
125
60
|
}
|
|
126
|
-
`,
|
|
61
|
+
`,Xo=$.label`
|
|
127
62
|
margin: 0;
|
|
128
63
|
cursor: pointer;
|
|
129
64
|
user-select: none;
|
|
130
65
|
font-family: ${e=>e.theme.fontFamily};
|
|
131
66
|
font-size: ${e=>e.theme.fontSize};
|
|
132
67
|
color: ${e=>e.theme.textColor};
|
|
133
|
-
`,
|
|
68
|
+
`,Ge=$.button`
|
|
134
69
|
padding: 0.5rem 1rem;
|
|
135
70
|
background: ${e=>e.theme.buttonBackground||"#007bff"};
|
|
136
71
|
color: ${e=>e.theme.buttonText||"white"};
|
|
@@ -156,7 +91,7 @@
|
|
|
156
91
|
cursor: not-allowed;
|
|
157
92
|
opacity: 0.6;
|
|
158
93
|
}
|
|
159
|
-
`,
|
|
94
|
+
`,ua=$.input`
|
|
160
95
|
padding: 0.5rem 0.75rem;
|
|
161
96
|
font-family: ${e=>e.theme.fontFamily};
|
|
162
97
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -182,17 +117,17 @@
|
|
|
182
117
|
opacity: 0.6;
|
|
183
118
|
cursor: not-allowed;
|
|
184
119
|
}
|
|
185
|
-
|
|
120
|
+
`;$(ua)`
|
|
186
121
|
padding: 0.25rem 0.5rem;
|
|
187
122
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
188
|
-
`;var
|
|
123
|
+
`;var Yo=$.label`
|
|
189
124
|
font-family: ${e=>e.theme.fontFamily};
|
|
190
125
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
191
126
|
font-weight: 500;
|
|
192
127
|
color: ${e=>e.theme.textColorMuted};
|
|
193
128
|
margin-bottom: 0.25rem;
|
|
194
129
|
display: block;
|
|
195
|
-
|
|
130
|
+
`;$.label`
|
|
196
131
|
font-family: ${e=>e.theme.fontFamily};
|
|
197
132
|
font-size: ${e=>e.theme.fontSize};
|
|
198
133
|
color: ${e=>e.theme.textColor};
|
|
@@ -200,7 +135,7 @@
|
|
|
200
135
|
align-items: center;
|
|
201
136
|
gap: 0.5rem;
|
|
202
137
|
cursor: pointer;
|
|
203
|
-
`;var
|
|
138
|
+
`;var Uo=$.span`
|
|
204
139
|
position: absolute;
|
|
205
140
|
width: 1px;
|
|
206
141
|
height: 1px;
|
|
@@ -210,7 +145,7 @@
|
|
|
210
145
|
clip: rect(0, 0, 0, 0);
|
|
211
146
|
white-space: nowrap;
|
|
212
147
|
border: 0;
|
|
213
|
-
`,
|
|
148
|
+
`,da=$.select`
|
|
214
149
|
padding: 0.5rem 2rem 0.5rem 0.75rem;
|
|
215
150
|
font-family: ${e=>e.theme.fontFamily};
|
|
216
151
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -243,10 +178,10 @@
|
|
|
243
178
|
color: ${e=>e.theme.inputText};
|
|
244
179
|
background-color: ${e=>e.theme.inputBackground};
|
|
245
180
|
}
|
|
246
|
-
|
|
181
|
+
`;$(da)`
|
|
247
182
|
padding: 0.25rem 1.75rem 0.25rem 0.5rem;
|
|
248
183
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
249
|
-
`;var
|
|
184
|
+
`;var fa=$.input.attrs({type:"range"})`
|
|
250
185
|
-webkit-appearance: none;
|
|
251
186
|
appearance: none;
|
|
252
187
|
width: 100%;
|
|
@@ -326,21 +261,21 @@
|
|
|
326
261
|
&:disabled::-moz-range-thumb {
|
|
327
262
|
cursor: not-allowed;
|
|
328
263
|
}
|
|
329
|
-
`,
|
|
264
|
+
`,Ko=({checked:e,onChange:t,disabled:r=!1,className:n})=>{const a=s=>{t(s.target.checked)};return x.jsxs(jo,{className:n,children:[x.jsx(zo,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:a,disabled:r}),x.jsx(Xo,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function ma(e){return typeof e=="object"&&e!==null&&"type"in e}function nt(e){if(!ma(e))return e;const t=e.direction==="vertical"?"to bottom":"to right",r=e.stops.map(n=>`${n.color} ${n.offset*100}%`).join(", ");return`linear-gradient(${t}, ${r})`}var ha={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",selectedTrackBackground:"#e8f0fe",timeColor:"#000",timescaleBackgroundColor:"#fff",playheadColor:"#f00",selectionColor:"rgba(255, 105, 180, 0.7)",loopRegionColor:"rgba(59, 130, 246, 0.3)",loopMarkerColor:"#3b82f6",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",pianoRollNoteColor:"#2a7070",pianoRollSelectedNoteColor:"#3d9e9e",pianoRollBackgroundColor:"#1a1a2e",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},Qo=class{constructor(e){this._listeners=new Set,this._notifyRafId=null,this.subscribe=n=>(this._listeners.add(n),()=>this._listeners.delete(n)),this.getSnapshot=()=>this._state;const t=e?.clientWidth??(typeof window<"u"?window.innerWidth:1024),r=t*1.5;this._state={scrollLeft:0,containerWidth:t,visibleStart:0,visibleEnd:t+r}}update(e,t){const r=t*1.5,n=Math.max(0,e-r),a=e+t+r;this._state&&this._state.containerWidth===t&&Math.abs(this._state.scrollLeft-e)<100||(this._state={scrollLeft:e,containerWidth:t,visibleStart:n,visibleEnd:a},this._notifyRafId===null&&(this._notifyRafId=requestAnimationFrame(()=>{this._notifyRafId=null;for(const s of this._listeners)s()})))}cancelPendingNotification(){this._notifyRafId!==null&&(cancelAnimationFrame(this._notifyRafId),this._notifyRafId=null)}},pa=f.createContext(null),Jo=()=>()=>{},qo=({containerRef:e,children:t})=>{const r=f.useRef(null);r.current===null&&(r.current=new Qo(e.current));const n=r.current,a=f.useRef(null),s=f.useCallback(()=>{const i=e.current;i&&n.update(i.scrollLeft,i.clientWidth)},[e,n]),o=f.useCallback(()=>{a.current===null&&(a.current=requestAnimationFrame(()=>{a.current=null,s()}))},[s]);return f.useLayoutEffect(()=>{s()},[s]),f.useEffect(()=>{const i=e.current;if(!i)return;i.addEventListener("scroll",o,{passive:!0});const c=new ResizeObserver(()=>{o()});return c.observe(i),()=>{i.removeEventListener("scroll",o),c.disconnect(),a.current!==null&&(cancelAnimationFrame(a.current),a.current=null),n.cancelPendingNotification()}},[e,o,n]),x.jsx(pa.Provider,{value:n,children:t})};function es(e){const t=f.useContext(pa);return f.useSyncExternalStore(t?t.subscribe:Jo,()=>e(t?t.getSnapshot():null),()=>e(null))}function qt(e,t,r=0){const n=es(a=>{const s=Math.ceil(e/t),o=[];for(let i=0;i<s;i++){const c=i*t,l=Math.min(e-c,t);if(a){const u=r+c;if(u+l<=a.visibleStart||u>=a.visibleEnd)continue}o.push(i)}return o.join(",")});return f.useMemo(()=>n?n.split(",").map(Number):[],[n])}var ga=f.createContext(0),ts=({originX:e,children:t})=>x.jsx(ga.Provider,{value:e,children:t}),Rn=()=>f.useContext(ga);function en(){const e=f.useRef(new Map),t=f.useCallback(r=>{if(r!==null){const n=parseInt(r.dataset.index,10);e.current.set(n,r)}},[]);return f.useEffect(()=>{const r=e.current;for(const[n,a]of r.entries())a.isConnected||r.delete(n)}),{canvasRef:t,canvasMapRef:e}}function ns(e,t,r,n){if(r*2+1>=e.length)return null;const a=2**(t-1);let s=e[r*2]/a,o=e[r*2+1]/a;for(let i=r+1;i<n&&!(i*2+1>=e.length);i++){const c=e[i*2]/a,l=e[i*2+1]/a;c<s&&(s=c),l>o&&(o=l)}return{min:s,max:o}}function rs(e,t,r,n,a,s){const o=Math.abs(n*r),i=Math.abs(a*r);return s==="normal"?[{x:e,y:r-i,width:t,height:i+o}]:[{x:e,y:0,width:t,height:r-i},{x:e,y:r+o,width:t,height:r-o}]}function as(e,t,r){return Math.floor((e-t+r)/r)*r}function os(e,t,r,n){if(!ma(t))return t;let a;t.direction==="vertical"?a=e.createLinearGradient(0,0,0,n):a=e.createLinearGradient(0,0,r,0);for(const s of t.stops)a.addColorStop(s.offset,s.color);return a}var ss=$.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
330
265
|
position: absolute;
|
|
331
266
|
top: 0;
|
|
332
267
|
/* Disable image rendering interpolation */
|
|
333
268
|
image-rendering: pixelated;
|
|
334
269
|
image-rendering: crisp-edges;
|
|
335
|
-
`,
|
|
270
|
+
`,is=$.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
336
271
|
position: absolute;
|
|
337
272
|
background: ${e=>e.$waveFillColor};
|
|
338
273
|
/* Force GPU compositing layer to reduce scroll flickering */
|
|
339
274
|
transform: translateZ(0);
|
|
340
275
|
backface-visibility: hidden;
|
|
341
|
-
`,
|
|
276
|
+
`,Dr=e=>{const{data:t,bits:r,length:n,index:a,className:s,devicePixelRatio:o=1,waveHeight:i=80,waveOutlineColor:c="#E0EFF1",waveFillColor:l="grey",barWidth:u=1,barGap:m=0,transparentBackground:b=!1,drawMode:d="inverted"}=e,{canvasRef:h,canvasMapRef:v}=en(),g=Rn(),p=qt(n,we,g);f.useLayoutEffect(()=>{const I=u+m;for(const[S,A]of v.current.entries()){const k=S*we,M=A.getContext("2d"),_=Math.floor(i/2);if(M){M.resetTransform(),M.clearRect(0,0,A.width,A.height),M.imageSmoothingEnabled=!1,M.scale(o,o);const E=A.width/o;let T;d==="normal"?T=l:T=c,M.fillStyle=os(M,T,E,i);const R=k,D=k+E,P=as(R,u,I);for(let F=Math.max(0,P);F<D;F+=I){const G=F-R;if(G+u<=0)continue;const z=Math.min(F+I,n),fe=ns(t,r,F,z);if(fe){const q=rs(G,u,_,fe.min,fe.max,d);for(const ee of q)M.fillRect(ee.x,ee.y,ee.width,ee.height)}}}}},[v,t,r,i,c,l,o,n,u,m,d,p,a]);const C=p.map(I=>{const S=I*we,A=Math.min(n-S,we);return x.jsx(ss,{$cssWidth:A,$left:S,width:A*o,height:i*o,$waveHeight:i,"data-index":I,ref:h},`${n}-${I}`)}),w=b?"transparent":nt(l);return x.jsx(is,{$index:a,$cssWidth:n,className:s,$waveHeight:i,$waveFillColor:w,children:C})},ls={padding:"16px",background:"#1a1a2e",color:"#e0e0e0",border:"1px solid #d08070",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px",minHeight:"60px",display:"flex",alignItems:"center",justifyContent:"center"};(class extends f.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[waveform-playlist] Render error:",e,t.componentStack)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:x.jsx("div",{style:ls,children:"Waveform playlist encountered an error. Check console for details."}):this.props.children}});var Dn=22,va=$.div`
|
|
342
277
|
position: relative;
|
|
343
|
-
height: ${
|
|
278
|
+
height: ${Dn}px;
|
|
344
279
|
background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
|
|
345
280
|
border-bottom: 1px solid ${e=>e.theme.clipHeaderBorderColor};
|
|
346
281
|
display: flex;
|
|
@@ -362,7 +297,7 @@
|
|
|
362
297
|
cursor: grabbing;
|
|
363
298
|
}
|
|
364
299
|
`}
|
|
365
|
-
`,
|
|
300
|
+
`,ba=$.span`
|
|
366
301
|
font-size: 11px;
|
|
367
302
|
font-weight: 600;
|
|
368
303
|
font-family: ${e=>e.theme.clipHeaderFontFamily};
|
|
@@ -370,12 +305,12 @@
|
|
|
370
305
|
white-space: nowrap;
|
|
371
306
|
overflow: hidden;
|
|
372
307
|
text-overflow: ellipsis;
|
|
373
|
-
`,
|
|
308
|
+
`,cs=({trackName:e,isSelected:t=!1})=>x.jsx(va,{$interactive:!1,$isSelected:t,children:x.jsx(ba,{title:e,children:e})}),us=({clipId:e,trackIndex:t,clipIndex:r,trackName:n,isSelected:a=!1,disableDrag:s=!1,dragHandleProps:o})=>{if(s||!o)return x.jsx(cs,{trackName:n,isSelected:a});const{handleRef:i}=o;return x.jsx(va,{ref:i,"data-clip-id":e,$interactive:!0,$isSelected:a,children:x.jsx(ba,{title:n,children:n})})},ds=8,fs=24,ms=$.div`
|
|
374
309
|
position: absolute;
|
|
375
310
|
${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
|
|
376
311
|
top: 0;
|
|
377
312
|
bottom: 0;
|
|
378
|
-
width: ${e=>e.$touchOptimized?
|
|
313
|
+
width: ${e=>e.$touchOptimized?fs:ds}px;
|
|
379
314
|
cursor: col-resize;
|
|
380
315
|
user-select: none;
|
|
381
316
|
z-index: 105; /* Above waveform, below header */
|
|
@@ -398,19 +333,19 @@
|
|
|
398
333
|
background: rgba(255, 255, 255, 0.4);
|
|
399
334
|
${e=>e.$edge==="left"?"border-left: 2px solid rgba(255, 255, 255, 0.8);":"border-right: 2px solid rgba(255, 255, 255, 0.8);"}
|
|
400
335
|
}
|
|
401
|
-
|
|
336
|
+
`,$r=({clipId:e,trackIndex:t,clipIndex:r,edge:n,dragHandleProps:a,touchOptimized:s=!1})=>{const[o,i]=f.useState(!1);if(!a)return null;const{ref:c,isDragging:l}=a;return x.jsx(ms,{ref:c,"data-clip-id":e,"data-boundary-edge":n,$edge:n,$isDragging:l,$isHovered:o,$touchOptimized:s,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)})},hs=$.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
402
337
|
position: absolute;
|
|
403
338
|
top: 0;
|
|
404
339
|
bottom: 0;
|
|
405
340
|
pointer-events: none;
|
|
406
341
|
z-index: 50;
|
|
407
|
-
`,
|
|
342
|
+
`,ps=$.svg`
|
|
408
343
|
width: 100%;
|
|
409
344
|
height: 100%;
|
|
410
345
|
display: block;
|
|
411
346
|
/* Flip horizontally for fadeOut - makes it mirror of fadeIn */
|
|
412
347
|
transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
|
|
413
|
-
`;function
|
|
348
|
+
`;function gs(e,t,r="logarithmic"){const n=[],a=Math.max(20,Math.min(e,100));for(let s=0;s<=a;s++){const o=s/a*e,i=s/a;let c;switch(r){case"linear":c=i;break;case"exponential":c=i*i;break;case"sCurve":c=(1-Math.cos(i*Math.PI))/2;break;case"logarithmic":default:c=Math.log10(1+i*9)/Math.log10(10);break}const l=(1-c)*t;n.push(`${o},${l}`)}return`M 0,${t} L ${n.join(" L ")} L ${e},0 L 0,0 Z`}var zt=({left:e,width:t,type:r,curveType:n="logarithmic",color:a})=>{const s=$.useTheme();if(t<1)return null;const o=a||s?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return x.jsx(hs,{$left:e,$width:t,$type:r,children:x.jsx(ps,{$type:r,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:x.jsx("path",{d:gs(t,100,n),fill:o})})})},vs=$.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
414
349
|
position: ${e=>e.$isOverlay?"relative":"absolute"};
|
|
415
350
|
top: 0;
|
|
416
351
|
height: ${e=>e.$isOverlay?"auto":"100%"};
|
|
@@ -419,30 +354,30 @@
|
|
|
419
354
|
flex-direction: column;
|
|
420
355
|
z-index: 10; /* Above progress overlay (z-index: 2) but below controls/playhead */
|
|
421
356
|
pointer-events: none; /* Let clicks pass through to ClickOverlay for playhead positioning */
|
|
422
|
-
`,
|
|
357
|
+
`,bs=$.div`
|
|
423
358
|
flex: 1;
|
|
424
359
|
position: relative;
|
|
425
360
|
overflow: ${e=>e.$isOverlay?"visible":"hidden"};
|
|
426
|
-
`,
|
|
361
|
+
`,An=({children:e,className:t,clipId:r,trackIndex:n,clipIndex:a,trackName:s,startSample:o,durationSamples:i,samplesPerPixel:c,showHeader:l=!1,disableHeaderDrag:u=!1,isOverlay:m=!1,isSelected:b=!1,onMouseDown:d,trackId:h,fadeIn:v,fadeOut:g,sampleRate:p=44100,showFades:C=!1,touchOptimized:y=!1})=>{const w=Math.floor(o/c),I=ta(o,i,c),S=l&&!u&&!m,A=`clip-${n}-${a}`,{ref:k,handleRef:M,isDragSource:_}=yt.useDraggable({id:A,data:{clipId:r,trackIndex:n,clipIndex:a,startSample:o,durationSamples:i},disabled:!S}),E=`clip-boundary-left-${n}-${a}`,{ref:T,isDragSource:R}=yt.useDraggable({id:E,data:{clipId:r,trackIndex:n,clipIndex:a,boundary:"left",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),D=`clip-boundary-right-${n}-${a}`,{ref:P,isDragSource:F}=yt.useDraggable({id:D,data:{clipId:r,trackIndex:n,clipIndex:a,boundary:"right",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),G=_?{zIndex:100}:void 0;return x.jsxs(vs,{ref:k,style:G,className:t,$left:w,$width:I,$isOverlay:m,"data-clip-container":"true","data-track-id":h,onMouseDown:d,tabIndex:-1,children:[l&&x.jsx(us,{clipId:r,trackIndex:n,clipIndex:a,trackName:s,isSelected:b,disableDrag:u,dragHandleProps:S?{handleRef:M}:void 0}),x.jsx(ts,{originX:w,children:x.jsxs(bs,{$isOverlay:m,children:[e,C&&v&&v.duration>0&&x.jsx(zt,{left:0,width:Math.floor(v.duration*p/c),type:"fadeIn",curveType:v.type}),C&&g&&g.duration>0&&x.jsx(zt,{left:I-Math.floor(g.duration*p/c),width:Math.floor(g.duration*p/c),type:"fadeOut",curveType:g.type})]})}),l&&!u&&!m&&x.jsxs(x.Fragment,{children:[x.jsx($r,{clipId:r,trackIndex:n,clipIndex:a,edge:"left",touchOptimized:y,dragHandleProps:{ref:T,isDragging:R}}),x.jsx($r,{clipId:r,trackIndex:n,clipIndex:a,edge:"right",touchOptimized:y,dragHandleProps:{ref:P,isDragging:F}})]})]})},ys=$.div`
|
|
427
362
|
display: inline-flex;
|
|
428
363
|
align-items: center;
|
|
429
364
|
gap: 0.5rem;
|
|
430
|
-
`,
|
|
365
|
+
`,Cs=$(Yo)`
|
|
431
366
|
margin: 0;
|
|
432
367
|
white-space: nowrap;
|
|
433
|
-
`,
|
|
368
|
+
`,ws=$(fa)`
|
|
434
369
|
width: 120px;
|
|
435
|
-
`,
|
|
370
|
+
`,xs=({volume:e,onChange:t,disabled:r=!1,className:n})=>{const a=s=>{t(parseFloat(s.target.value)/100)};return x.jsxs(ys,{className:n,children:[x.jsx(Cs,{htmlFor:"master-gain",children:"Master Volume"}),x.jsx(ws,{min:"0",max:"100",value:e*100,onChange:a,disabled:r,id:"master-gain"})]})},Is=$.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
436
371
|
position: absolute;
|
|
437
372
|
top: 0;
|
|
438
373
|
image-rendering: pixelated;
|
|
439
374
|
image-rendering: crisp-edges;
|
|
440
|
-
`,
|
|
375
|
+
`,Ss=$.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
441
376
|
position: absolute;
|
|
442
377
|
background: ${e=>e.$backgroundColor};
|
|
443
378
|
transform: translateZ(0);
|
|
444
379
|
backface-visibility: hidden;
|
|
445
|
-
`,
|
|
380
|
+
`,ks=({index:e,midiNotes:t,length:r,waveHeight:n,devicePixelRatio:a,samplesPerPixel:s,sampleRate:o,clipOffsetSeconds:i,noteColor:c="#2a7070",selectedNoteColor:l="#3d9e9e",isSelected:u=!1,transparentBackground:m=!1,backgroundColor:b="#1a1a2e"})=>{const{canvasRef:d,canvasMapRef:h}=en(),v=Rn(),g=qt(r,we,v),{minMidi:p,maxMidi:C}=f.useMemo(()=>{if(t.length===0)return{minMidi:0,maxMidi:127};let S=127,A=0;for(const k of t)k.midi<S&&(S=k.midi),k.midi>A&&(A=k.midi);return{minMidi:Math.max(0,S-1),maxMidi:Math.min(127,A+1)}},[t]),y=u?l:c;f.useLayoutEffect(()=>{const S=C-p+1,A=Math.max(2,n/S),k=o/s;for(const[M,_]of h.current.entries()){const E=M*we,T=_.width/a,R=_.getContext("2d");if(!R)continue;R.resetTransform(),R.clearRect(0,0,_.width,_.height),R.imageSmoothingEnabled=!1,R.scale(a,a);const D=E*s/o,P=(E+T)*s/o;for(const F of t){const G=F.time-i;if(G+F.duration<=D||G>=P)continue;const fe=G*k-E,q=Math.max(2,F.duration*k),ee=(C-F.midi)/S*n,ye=.3+F.velocity*.7;R.fillStyle=y,R.globalAlpha=ye;const J=1;R.beginPath(),R.roundRect(fe,ee,q,A,J),R.fill()}R.globalAlpha=1}},[h,t,n,a,s,o,i,y,p,C,r,g,e]);const w=g.map(S=>{const A=S*we,k=Math.min(r-A,we);return x.jsx(Is,{$cssWidth:k,$left:A,width:k*a,height:n*a,$waveHeight:n,"data-index":S,ref:d},`${r}-${S}`)}),I=m?"transparent":b;return x.jsx(Ss,{$index:e,$cssWidth:r,$waveHeight:n,$backgroundColor:I,children:w})};$.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
|
|
446
381
|
position: absolute;
|
|
447
382
|
top: 0;
|
|
448
383
|
left: 0;
|
|
@@ -452,7 +387,7 @@
|
|
|
452
387
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
453
388
|
pointer-events: none;
|
|
454
389
|
will-change: transform;
|
|
455
|
-
|
|
390
|
+
`;$.div`
|
|
456
391
|
position: absolute;
|
|
457
392
|
top: 0;
|
|
458
393
|
left: 0;
|
|
@@ -460,7 +395,7 @@
|
|
|
460
395
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
461
396
|
pointer-events: none;
|
|
462
397
|
will-change: transform;
|
|
463
|
-
|
|
398
|
+
`;$.div`
|
|
464
399
|
position: absolute;
|
|
465
400
|
top: -10px;
|
|
466
401
|
left: -6px;
|
|
@@ -469,39 +404,39 @@
|
|
|
469
404
|
border-left: 7px solid transparent;
|
|
470
405
|
border-right: 7px solid transparent;
|
|
471
406
|
border-top: 10px solid ${e=>e.$color};
|
|
472
|
-
|
|
407
|
+
`;$.div`
|
|
473
408
|
position: absolute;
|
|
474
409
|
top: 0;
|
|
475
410
|
left: 0;
|
|
476
411
|
width: 2px;
|
|
477
412
|
height: 100%;
|
|
478
413
|
background: ${e=>e.$color};
|
|
479
|
-
`;var
|
|
414
|
+
`;var As=$.div`
|
|
480
415
|
display: flex;
|
|
481
416
|
overflow-y: hidden;
|
|
482
417
|
position: relative;
|
|
483
|
-
`,
|
|
418
|
+
`,_s=$.div.attrs(e=>({style:{width:`${e.$width}px`}}))`
|
|
484
419
|
flex-shrink: 0;
|
|
485
420
|
overflow: hidden;
|
|
486
|
-
`,
|
|
421
|
+
`,Es=$.div.attrs(e=>({style:{height:`${e.$height}px`}}))``,Ms=$.div`
|
|
487
422
|
overflow-x: auto;
|
|
488
423
|
overflow-y: hidden;
|
|
489
424
|
overflow-anchor: none;
|
|
490
425
|
flex: 1;
|
|
491
426
|
position: relative;
|
|
492
|
-
`,
|
|
427
|
+
`,Ts=$.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
|
|
493
428
|
position: relative;
|
|
494
429
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
495
|
-
`,
|
|
430
|
+
`,Rs=$.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
|
|
496
431
|
background: ${e=>e.$backgroundColor||"white"};
|
|
497
432
|
width: 100%;
|
|
498
433
|
position: relative;
|
|
499
434
|
overflow: hidden; /* Constrain loop region to timescale area */
|
|
500
|
-
|
|
435
|
+
`,Ds=$.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
|
|
501
436
|
position: relative;
|
|
502
437
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
503
438
|
width: 100%;
|
|
504
|
-
|
|
439
|
+
`,$s=$.div`
|
|
505
440
|
position: absolute;
|
|
506
441
|
top: 0;
|
|
507
442
|
left: 0;
|
|
@@ -510,7 +445,7 @@
|
|
|
510
445
|
cursor: crosshair;
|
|
511
446
|
/* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
|
|
512
447
|
z-index: ${e=>e.$isSelecting?110:1};
|
|
513
|
-
|
|
448
|
+
`,$n=({children:e,backgroundColor:t,timescaleBackgroundColor:r,timescale:n,timescaleWidth:a,tracksWidth:s,controlsWidth:o,onTracksClick:i,onTracksMouseDown:c,onTracksMouseMove:l,onTracksMouseUp:u,scrollContainerRef:m,isSelecting:b,"data-playlist-state":d,trackControlsSlots:h,timescaleGapHeight:v=0})=>{const g=f.useRef(null),p=f.useCallback(y=>{g.current=y,m?.(y)},[m]),C=o!==void 0&&o>0;return x.jsxs(As,{"data-playlist-state":d,children:[C&&x.jsxs(_s,{$width:o,children:[v>0&&x.jsx(Es,{$height:v}),h]}),x.jsx(Ms,{"data-scroll-container":"true",ref:p,children:x.jsx(qo,{containerRef:g,children:x.jsxs(Ts,{$backgroundColor:t,$width:s,children:[n&&x.jsx(Rs,{$width:a,$backgroundColor:r,children:n}),x.jsxs(Ds,{$width:s,$backgroundColor:t,children:[e,(i||c)&&x.jsx($s,{$isSelecting:b,onClick:i,onMouseDown:c,onMouseMove:l,onMouseUp:u})]})]})})})]})};$.withTheme($n);var Fs=$.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
514
449
|
position: absolute;
|
|
515
450
|
top: 0;
|
|
516
451
|
background: ${e=>e.$color};
|
|
@@ -518,14 +453,14 @@
|
|
|
518
453
|
z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
|
|
519
454
|
pointer-events: none;
|
|
520
455
|
opacity: 0.3;
|
|
521
|
-
`,
|
|
456
|
+
`,ya=({startPosition:e,endPosition:t,color:r="#00ff00"})=>{const n=Math.max(0,t-e);return n<=0?null:x.jsx(Fs,{$left:e,$width:n,$color:r,"data-selection":!0})};$.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
522
457
|
position: absolute;
|
|
523
458
|
top: 0;
|
|
524
459
|
background: ${e=>e.$color};
|
|
525
460
|
height: 100%;
|
|
526
461
|
z-index: 55; /* Between clips (z-index: 50) and selection (z-index: 60) */
|
|
527
462
|
pointer-events: none;
|
|
528
|
-
|
|
463
|
+
`;$.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
|
|
529
464
|
position: absolute;
|
|
530
465
|
top: 0;
|
|
531
466
|
width: 2px;
|
|
@@ -545,7 +480,7 @@
|
|
|
545
480
|
border-top: 8px solid ${e=>e.$color};
|
|
546
481
|
${e=>e.$isStart?"border-right: 8px solid transparent;":"border-left: 8px solid transparent;"}
|
|
547
482
|
}
|
|
548
|
-
`;var
|
|
483
|
+
`;var Fr=$.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
|
|
549
484
|
position: absolute;
|
|
550
485
|
top: 0;
|
|
551
486
|
width: 12px;
|
|
@@ -582,7 +517,7 @@
|
|
|
582
517
|
&:hover::before {
|
|
583
518
|
opacity: 1;
|
|
584
519
|
}
|
|
585
|
-
`,
|
|
520
|
+
`,Bs=$.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
586
521
|
position: absolute;
|
|
587
522
|
top: 0;
|
|
588
523
|
height: 100%;
|
|
@@ -593,7 +528,7 @@
|
|
|
593
528
|
&:active {
|
|
594
529
|
cursor: grabbing;
|
|
595
530
|
}
|
|
596
|
-
`,
|
|
531
|
+
`,Ps=({startPosition:e,endPosition:t,markerColor:r="#3b82f6",regionColor:n="rgba(59, 130, 246, 0.3)",onLoopStartChange:a,onLoopEndChange:s,onLoopRegionMove:o,minPosition:i=0,maxPosition:c=1/0})=>{const[l,u]=f.useState(null),m=f.useRef(0),b=f.useRef(0),d=f.useRef(0),h=Math.max(0,t-e),v=f.useCallback((p,C)=>{p.preventDefault(),p.stopPropagation(),u(C),m.current=p.clientX,b.current=C==="start"?e:t;const y=I=>{const S=I.clientX-m.current,A=b.current+S;if(C==="start"){const k=Math.max(i,Math.min(t-10,A));a?.(k)}else{const k=Math.max(e+10,Math.min(c,A));s?.(k)}},w=()=>{u(null),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",y),document.addEventListener("mouseup",w)},[e,t,i,c,a,s]),g=f.useCallback(p=>{p.preventDefault(),p.stopPropagation(),u("region"),m.current=p.clientX,b.current=e,d.current=t;const C=t-e,y=I=>{const S=I.clientX-m.current;let A=b.current+S,k=d.current+S;A<i&&(A=i,k=i+C),k>c&&(k=c,A=c-C),o?.(A,k)},w=()=>{u(null),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",y),document.addEventListener("mouseup",w)},[e,t,i,c,o]);return h<=0?null:x.jsxs(x.Fragment,{children:[x.jsx(Bs,{$left:e,$width:h,$color:n,$isDragging:l==="region",onMouseDown:g,"data-loop-region-timescale":!0}),x.jsx(Fr,{$left:e,$color:r,$isStart:!0,$isDragging:l==="start",onMouseDown:p=>v(p,"start"),"data-loop-marker-handle":"start"}),x.jsx(Fr,{$left:t,$color:r,$isStart:!1,$isDragging:l==="end",onMouseDown:p=>v(p,"end"),"data-loop-marker-handle":"end"})]})},Vs=$.div`
|
|
597
532
|
position: absolute;
|
|
598
533
|
top: 0;
|
|
599
534
|
left: 0;
|
|
@@ -601,17 +536,17 @@
|
|
|
601
536
|
height: 100%; /* Stay within timescale bounds, don't extend into tracks */
|
|
602
537
|
cursor: crosshair;
|
|
603
538
|
z-index: 40; /* Below markers and shading */
|
|
604
|
-
`,
|
|
539
|
+
`,Zs=({startPosition:e,endPosition:t,markerColor:r="#3b82f6",regionColor:n="rgba(59, 130, 246, 0.3)",onLoopRegionChange:a,minPosition:s=0,maxPosition:o=1/0})=>{const[,i]=f.useState(!1),c=f.useRef(0),l=f.useRef(null),u=t>e,m=f.useCallback(b=>{const d=b.target;if(d.closest("[data-loop-marker-handle]")||d.closest("[data-loop-region-timescale]"))return;b.preventDefault(),i(!0);const h=l.current?.getBoundingClientRect();if(!h)return;const v=b.clientX-h.left,g=Math.max(s,Math.min(o,v));c.current=g,a?.(g,g);const p=y=>{const w=y.clientX-h.left,I=Math.max(s,Math.min(o,w)),S=Math.min(c.current,I),A=Math.max(c.current,I);a?.(S,A)},C=()=>{i(!1),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",C)},[s,o,a]);return x.jsx(Vs,{ref:l,onMouseDown:m,"data-timescale-loop-creator":!0,children:u&&x.jsx(Ps,{startPosition:e,endPosition:t,markerColor:r,regionColor:n,minPosition:s,maxPosition:o,onLoopStartChange:b=>a?.(b,t),onLoopEndChange:b=>a?.(e,b),onLoopRegionMove:(b,d)=>a?.(b,d)})})};function vt(e,t){const r=Math.floor(e/3600)%24,n=Math.floor(e/60)%60,a=(e%60).toFixed(t);return String(r).padStart(2,"0")+":"+String(n).padStart(2,"0")+":"+a.padStart(t>0?t+3:2,"0")}function pt(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return vt(e,0);case"hh:mm:ss.u":return vt(e,1);case"hh:mm:ss.uu":return vt(e,2);case"hh:mm:ss.uuu":return vt(e,3);default:return vt(e,3)}}function Ca(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 r=e.split(":");if(r.length!==3)return 0;const n=parseInt(r[0],10)||0,a=parseInt(r[1],10)||0,s=parseFloat(r[2])||0;return n*3600+a*60+s}default:return 0}}var Br=({id:e,label:t,value:r,format:n,className:a,onChange:s,readOnly:o=!1})=>{const[i,c]=f.useState("");f.useEffect(()=>{const b=pt(r,n);c(b)},[r,n,e]);const l=b=>{const d=b.target.value;c(d)},u=()=>{if(s){const b=Ca(i,n);s(b)}c(pt(r,n))},m=b=>{b.key==="Enter"&&b.currentTarget.blur()};return x.jsxs(x.Fragment,{children:[x.jsx(Uo,{as:"label",htmlFor:e,children:t}),x.jsx(ua,{type:"text",className:a,id:e,value:i,onChange:l,onBlur:u,onKeyDown:m,readOnly:o})]})},Ls=({selectionStart:e,selectionEnd:t,onSelectionChange:r,className:n})=>{const[a,s]=f.useState("hh:mm:ss.uuu");f.useEffect(()=>{const c=document.querySelector(".time-format"),l=()=>{c&&s(c.value)};return c&&(s(c.value),c.addEventListener("change",l)),()=>{c?.removeEventListener("change",l)}},[]);const o=c=>{r&&r(c,t)},i=c=>{r&&r(e,c)};return x.jsxs("div",{className:n,children:[x.jsx(Br,{id:"audio_start",label:"Start of audio selection",value:e,format:a,className:"audio-start form-control mr-sm-2",onChange:o}),x.jsx(Br,{id:"audio_end",label:"End of audio selection",value:t,format:a,className:"audio-end form-control mr-sm-2",onChange:i})]})},Gs=f.createContext(null);function wa(){return f.useContext(Gs)}function Gt(){return window.devicePixelRatio}var xa=f.createContext(Gt()),Ia=({children:e})=>{const[t,r]=f.useState(Gt());return matchMedia(`(resolution: ${Gt()}dppx)`).addEventListener("change",()=>{r(Gt())},{once:!0}),x.jsx(xa.Provider,{value:Math.ceil(t),children:e})},Fn=()=>f.useContext(xa),St=f.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}),tn=()=>f.useContext(St),kt=()=>f.useContext($.ThemeContext);f.createContext(x.jsx(f.Fragment,{}));var Ws=0,Ns=!1,Os=0,Hs=0,js={progress:Ws,isPlaying:Ns,selectionStart:Os,selectionEnd:Hs};f.createContext(js);f.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var zs=$.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
605
540
|
position: absolute;
|
|
606
541
|
background: #000;
|
|
607
542
|
transform: translateZ(0);
|
|
608
543
|
backface-visibility: hidden;
|
|
609
|
-
`,
|
|
544
|
+
`,Xs=$.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
610
545
|
position: absolute;
|
|
611
546
|
top: 0;
|
|
612
547
|
image-rendering: pixelated;
|
|
613
548
|
image-rendering: crisp-edges;
|
|
614
|
-
`,
|
|
549
|
+
`,Pr=({index:e,channelIndex:t,length:r,waveHeight:n,devicePixelRatio:a=1,samplesPerPixel:s,workerApi:o,clipId:i,onCanvasesReady:c})=>{const l=t??e,{canvasRef:u,canvasMapRef:m}=en(),b=f.useRef([]),d=f.useRef(new WeakSet),h=f.useRef(o),v=f.useRef(c),g=Rn(),p=qt(r,we,g);f.useEffect(()=>{h.current=o},[o]),f.useEffect(()=>{v.current=c},[c]),f.useEffect(()=>{const y=h.current;if(!y||!i)return;const w=b.current.length,I=[];for(const k of b.current){const M=k.match(/chunk(\d+)$/);if(!M){I.push(k);continue}const _=parseInt(M[1],10),E=m.current.get(_);if(E&&E.isConnected)I.push(k);else try{y.unregisterCanvas(k)}catch(T){console.warn(`[spectrogram] unregisterCanvas failed for ${k}:`,T)}}b.current=I;const S=[];for(const[k,M]of m.current.entries()){if(d.current.has(M))continue;const _=`${i}-ch${l}-chunk${k}`;let E;try{E=M.transferControlToOffscreen()}catch(T){console.warn(`[spectrogram] transferControlToOffscreen failed for ${_}:`,T);continue}d.current.add(M);try{y.registerCanvas(_,E),S.push(_)}catch(T){console.warn(`[spectrogram] registerCanvas failed for ${_}:`,T);continue}}if(S.length>0&&(b.current=[...b.current,...S]),S.length>0||I.length<w){const k=b.current,M=k.map(_=>{const E=_.match(/chunk(\d+)$/);if(!E)return console.warn(`[spectrogram] Unexpected canvas ID format: ${_}`),we;const T=parseInt(E[1],10);return Math.min(r-T*we,we)});v.current?.(k,M)}},[m,i,l,r,p]),f.useEffect(()=>()=>{const y=h.current;if(y){for(const w of b.current)try{y.unregisterCanvas(w)}catch(I){console.warn(`[spectrogram] unregisterCanvas failed for ${w}:`,I)}b.current=[]}},[]);const C=p.map(y=>{const w=y*we,I=Math.min(r-w,we);return x.jsx(Xs,{$cssWidth:I,$left:w,width:I*a,height:n*a,$waveHeight:n,"data-index":y,ref:u},`${r}-${y}`)});return x.jsx(zs,{$index:e,$cssWidth:r,$waveHeight:n,children:C})},Sa=({isSelected:e,transparentBackground:t,renderMode:r="waveform",samplesPerPixel:n,spectrogramWorkerApi:a,spectrogramClipId:s,spectrogramOnCanvasesReady:o,midiNotes:i,sampleRate:c,clipOffsetSeconds:l,...u})=>{const m=kt(),{waveHeight:b,barWidth:d,barGap:h,samplesPerPixel:v,sampleRate:g}=tn(),p=Fn(),C=n??v,y=e&&m?m.selectedWaveOutlineColor:m?.waveOutlineColor,w=e&&m?m.selectedWaveFillColor:m?.waveFillColor,I=m?.waveformDrawMode||"inverted",S=a&&s;if(r==="spectrogram"&&S)return x.jsx(Pr,{index:u.index,length:u.length,waveHeight:b,devicePixelRatio:p,samplesPerPixel:C,workerApi:a,clipId:s,onCanvasesReady:o});if(r==="both"&&S){const A=Math.floor(b/2);return x.jsxs(x.Fragment,{children:[x.jsx(Pr,{index:u.index*2,channelIndex:u.index,length:u.length,waveHeight:A,devicePixelRatio:p,samplesPerPixel:C,workerApi:a,clipId:s,onCanvasesReady:o}),x.jsx("div",{style:{position:"absolute",top:(u.index*2+1)*A,width:u.length,height:A},children:x.jsx(Dr,{...u,index:0,waveOutlineColor:y,waveFillColor:w,waveHeight:A,devicePixelRatio:p,barWidth:d,barGap:h,transparentBackground:t,drawMode:I})})]})}return r==="piano-roll"?x.jsx(ks,{index:u.index,midiNotes:i??[],length:u.length,waveHeight:b,devicePixelRatio:p,samplesPerPixel:C,sampleRate:c??g,clipOffsetSeconds:l??0,noteColor:m?.pianoRollNoteColor,selectedNoteColor:m?.pianoRollSelectedNoteColor,isSelected:e,transparentBackground:t,backgroundColor:m?.pianoRollBackgroundColor}):x.jsx(Dr,{...u,waveOutlineColor:y,waveFillColor:w,waveHeight:b,devicePixelRatio:p,barWidth:d,barGap:h,transparentBackground:t,drawMode:I})},Vr=72,Ys=$.div`
|
|
615
550
|
position: sticky;
|
|
616
551
|
left: 0;
|
|
617
552
|
z-index: 101;
|
|
@@ -619,31 +554,31 @@
|
|
|
619
554
|
height: 0;
|
|
620
555
|
width: 0;
|
|
621
556
|
overflow: visible;
|
|
622
|
-
`;function
|
|
557
|
+
`;function Us(e,t,r){const a=[20,50,100,200,500,1e3,2e3,3e3,4e3,5e3,8e3,1e4,12e3,16e3,2e4].filter(c=>c>=e&&c<=t),s=Math.max(2,Math.floor(r/20));if(a.length<=s)return a;const o=(a.length-1)/(s-1),i=[];for(let c=0;c<s;c++)i.push(a[Math.round(c*o)]);return i}var Ks=({waveHeight:e,numChannels:t,frequencyScaleFn:r,minFrequency:n,maxFrequency:a,labelsColor:s="#ccc",labelsBackground:o="rgba(0,0,0,0.6)",renderMode:i="spectrogram",hasClipHeaders:c=!1})=>{const l=f.useRef(null),u=Fn(),m=i==="both"?Math.floor(e/2):e,b=t*e,d=c?22:0;return f.useLayoutEffect(()=>{const h=l.current;if(!h)return;const v=h.getContext("2d");if(!v)return;v.resetTransform(),v.clearRect(0,0,h.width,h.height),v.scale(u,u);const g=Us(n,a,m);for(let p=0;p<t;p++){const C=p*e+d;v.font="11px monospace",v.textBaseline="middle";for(const y of g){const w=r(y,n,a);if(w<0||w>1)continue;const I=C+m*(1-w),S=y>=1e3?`${(y/1e3).toFixed(1)}k`:`${y} Hz`,A=v.measureText(S),k=3;v.fillStyle=o,v.fillRect(0,I-7,A.width+k*2,14),v.fillStyle=s,v.fillText(S,k,I)}}},[e,t,r,n,a,s,o,u,m,d]),x.jsx(Ys,{$height:b+d,children:x.jsx("canvas",{ref:l,width:Vr*u,height:(b+d)*u,style:{width:Vr,height:b+d,pointerEvents:"none"}})})},Qs=$.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
|
|
623
558
|
position: relative;
|
|
624
559
|
overflow: visible; /* Allow time labels to render above the container */
|
|
625
560
|
border-bottom: 1px solid ${e=>e.theme.timeColor};
|
|
626
561
|
box-sizing: border-box;
|
|
627
|
-
`,
|
|
562
|
+
`,Js=$.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`,left:`${e.$left}px`}}))`
|
|
628
563
|
position: absolute;
|
|
629
564
|
bottom: 0;
|
|
630
|
-
`,
|
|
565
|
+
`,qs=e=>{const{theme:{timeColor:t},tickData:r}=e,{canvasRef:n,canvasMapRef:a}=en(),{timeScaleHeight:s}=f.useContext(St),o=Fn(),{widthX:i,canvasInfo:c,timeMarkersWithPositions:l}=r,u=qt(i,we),m=u.map(v=>{const g=v*we,p=Math.min(i-g,we);return x.jsx(Js,{$cssWidth:p,$left:g,$timeScaleHeight:s,width:p*o,height:s*o,"data-index":v,ref:n},`timescale-${v}`)}),b=u.length>0?u[0]*we:0,d=u.length>0?(u[u.length-1]+1)*we:1/0,h=u.length>0?l.filter(({pix:v})=>v>=b&&v<d).map(({element:v})=>v):l.map(({element:v})=>v);return f.useLayoutEffect(()=>{for(const[v,g]of a.current.entries()){const p=g.getContext("2d");if(!p)continue;const C=v*we,y=g.width/o;p.resetTransform(),p.clearRect(0,0,g.width,g.height),p.imageSmoothingEnabled=!1,p.fillStyle=t,p.scale(o,o);for(const[w,I]of c.entries()){if(w<C||w>=C+y)continue;const S=w-C,A=s-I;p.fillRect(S,A,1,I)}}},[a,o,t,s,c,u]),x.jsxs(Qs,{$cssWidth:i,$timeScaleHeight:s,children:[h,m]})},ei=$.withTheme(qs),Zr=new Map([[700,{marker:1e3,bigStep:500,smallStep:100}],[1500,{marker:2e3,bigStep:1e3,smallStep:200}],[2500,{marker:2e3,bigStep:1e3,smallStep:500}],[5e3,{marker:5e3,bigStep:1e3,smallStep:500}],[1e4,{marker:1e4,bigStep:5e3,smallStep:1e3}],[12e3,{marker:15e3,bigStep:5e3,smallStep:1e3}],[1/0,{marker:3e4,bigStep:1e4,smallStep:5e3}]]);function _n(e){const t=Zr.keys();let r;for(const n of t)if(e<n){r=Zr.get(n);break}return r===void 0&&(r={marker:3e4,bigStep:1e4,smallStep:5e3}),r}function ti(e){const t=Math.floor(e/1e3),r=t%60;return`${(t-r)/60}:${String(r).padStart(2,"0")}`}var ni=$.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
|
|
631
566
|
position: absolute;
|
|
632
567
|
font-size: 0.75rem; /* Smaller font to prevent overflow */
|
|
633
568
|
white-space: nowrap; /* Prevent text wrapping */
|
|
634
569
|
color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
|
|
635
|
-
`,
|
|
570
|
+
`,ka=({renderTick:e})=>{const{samplesPerPixel:t,sampleRate:r,duration:n,timeScaleHeight:a}=f.useContext(St),s=wa(),o=f.useMemo(()=>{const i=bo(n/1e3,t,r);if(s&&s.scaleMode==="beats"){const{bpm:g,timeSignature:p,ticksPerBar:C,ticksPerBeat:y}=s,w=new Map,I=[],S=n/1e3,A=Math.ceil(S*g*gt/60),k=ht(y,g,r)/t,M=ht(C,g,r)/t,_=10,E=30;let T;if(k>=_)T=y;else if(M>=_)T=C;else{const D=Math.ceil(_/M);T=C*D}let R;if(k>=E)R=y;else if(M>=E)R=C;else{const D=Math.ceil(E/M);R=C*D}for(let D=0;D<=A;D+=T){const P=ht(D,g,r),F=vo(P,t);if(F>=i)break;const G=D%C===0,z=D%R===0,fe=G?a:Math.floor(z?a/2:a/5);if(w.set(F,fe),z){const q=yo(D,p),ee=e?x.jsx(f.Fragment,{children:e(q,F)},`bb-${D}`):x.jsx("div",{style:{position:"absolute",left:`${F+4}px`,fontSize:"0.75rem",whiteSpace:"nowrap"},children:q},`bb-${D}`);I.push({pix:F,element:ee})}}return{widthX:i,canvasInfo:w,timeMarkersWithPositions:I}}const c=_n(t),{marker:l,bigStep:u,smallStep:m}=c,b=new Map,d=[],h=r/t;let v=0;for(let g=0;g<i;g+=h*m/1e3){const p=Math.floor(g);if(v%l===0){const C=ti(v),y=e?x.jsx(f.Fragment,{children:e(C,p)},`timestamp-${v}`):x.jsx(ni,{$left:p,children:C},C);d.push({pix:p,element:y}),b.set(p,a)}else v%u===0?b.set(p,Math.floor(a/2)):v%m===0&&b.set(p,Math.floor(a/5));v+=m}return{widthX:i,canvasInfo:b,timeMarkersWithPositions:d}},[s,n,t,r,a,e]);return x.jsx(ei,{tickData:o})},ri=$.div`
|
|
636
571
|
display: inline-flex;
|
|
637
572
|
align-items: center;
|
|
638
573
|
gap: 0.5rem;
|
|
639
|
-
`,
|
|
574
|
+
`,ai=[{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"}],oi=({value:e,onChange:t,disabled:r=!1,className:n})=>{const a=s=>{t(s.target.value)};return x.jsx(ri,{className:n,children:x.jsx(da,{className:"time-format",value:e,onChange:a,disabled:r,"aria-label":"Time format selection",children:ai.map(s=>x.jsx("option",{value:s.value,children:s.label},s.value))})})},si=$.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?Dn:0)}px`}}))`
|
|
640
575
|
position: relative;
|
|
641
576
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
642
|
-
`,
|
|
577
|
+
`,ii=$.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
|
|
643
578
|
position: relative;
|
|
644
579
|
background: ${e=>e.$isSelected?e.theme.selectedTrackBackground||e.$backgroundColor||"transparent":e.$backgroundColor||"transparent"};
|
|
645
580
|
height: 100%;
|
|
646
|
-
`,
|
|
581
|
+
`,Aa=({numChannels:e,children:t,className:r,backgroundColor:n,offset:a=0,width:s,hasClipHeaders:o=!1,onClick:i,trackId:c,isSelected:l=!1})=>{const{waveHeight:u}=tn();return x.jsx(si,{$numChannels:e,className:r,$waveHeight:u,$width:s,$hasClipHeaders:o,children:x.jsx(ii,{$backgroundColor:n,$offset:a,$isSelected:l,onClick:i,"data-track-id":c,children:t})})},Lr=$.button.attrs({type:"button"})`
|
|
647
582
|
display: inline-block;
|
|
648
583
|
font-family: ${e=>e.theme.fontFamily};
|
|
649
584
|
font-weight: 500;
|
|
@@ -705,7 +640,7 @@
|
|
|
705
640
|
box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
|
|
706
641
|
}
|
|
707
642
|
`}
|
|
708
|
-
`,
|
|
643
|
+
`,li=$.div`
|
|
709
644
|
margin-bottom: 0.3rem;
|
|
710
645
|
|
|
711
646
|
button:not(:first-child) {
|
|
@@ -717,7 +652,7 @@
|
|
|
717
652
|
border-top-right-radius: 0;
|
|
718
653
|
border-bottom-right-radius: 0;
|
|
719
654
|
}
|
|
720
|
-
`,
|
|
655
|
+
`,ci=$.button`
|
|
721
656
|
position: absolute;
|
|
722
657
|
left: 0;
|
|
723
658
|
top: 0;
|
|
@@ -739,7 +674,7 @@
|
|
|
739
674
|
opacity: 1;
|
|
740
675
|
color: #dc3545;
|
|
741
676
|
}
|
|
742
|
-
`,
|
|
677
|
+
`,ui=({onClick:e,title:t="Remove track"})=>x.jsx(ci,{onClick:e,title:t,children:x.jsx(Ho,{size:12,weight:"bold"})}),di=$.div`
|
|
743
678
|
background: transparent;
|
|
744
679
|
width: 100%;
|
|
745
680
|
height: 100%;
|
|
@@ -752,7 +687,7 @@
|
|
|
752
687
|
text-align: center;
|
|
753
688
|
border: 1px solid ${e=>e.theme.borderColor};
|
|
754
689
|
border-radius: ${e=>e.theme.borderRadius};
|
|
755
|
-
`,
|
|
690
|
+
`,fi=$.header`
|
|
756
691
|
overflow: hidden;
|
|
757
692
|
height: 26px;
|
|
758
693
|
width: 100%;
|
|
@@ -763,7 +698,7 @@
|
|
|
763
698
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
764
699
|
color: ${e=>e.theme.textColor};
|
|
765
700
|
background-color: transparent;
|
|
766
|
-
`,
|
|
701
|
+
`,mi=e=>x.jsx(la,{weight:"light",...e}),hi=e=>x.jsx(ia,{weight:"light",...e}),pi=e=>x.jsx(sa,{weight:"bold",...e}),Gr=$(fa)`
|
|
767
702
|
width: 75%;
|
|
768
703
|
height: 5px;
|
|
769
704
|
background: ${e=>e.theme.sliderTrackColor};
|
|
@@ -812,7 +747,7 @@
|
|
|
812
747
|
&:focus::-moz-range-thumb {
|
|
813
748
|
border: 2px solid ${e=>e.theme.textColor};
|
|
814
749
|
}
|
|
815
|
-
`,
|
|
750
|
+
`,Wr=$.label`
|
|
816
751
|
width: 100%;
|
|
817
752
|
display: flex;
|
|
818
753
|
justify-content: space-between;
|
|
@@ -820,10 +755,10 @@
|
|
|
820
755
|
padding: 0 1rem;
|
|
821
756
|
margin-bottom: 0.2rem;
|
|
822
757
|
font-size: 14px;
|
|
823
|
-
`,
|
|
758
|
+
`,gi=$.div`
|
|
824
759
|
position: relative;
|
|
825
760
|
display: inline-block;
|
|
826
|
-
`,
|
|
761
|
+
`,vi=$.button`
|
|
827
762
|
background: none;
|
|
828
763
|
border: none;
|
|
829
764
|
cursor: pointer;
|
|
@@ -837,7 +772,7 @@
|
|
|
837
772
|
&:hover {
|
|
838
773
|
opacity: 1;
|
|
839
774
|
}
|
|
840
|
-
`,
|
|
775
|
+
`,Wt=180,bi=$.div`
|
|
841
776
|
position: fixed;
|
|
842
777
|
top: ${e=>e.$top}px;
|
|
843
778
|
left: ${e=>e.$left}px;
|
|
@@ -847,38 +782,38 @@
|
|
|
847
782
|
border: 1px solid rgba(128, 128, 128, 0.4);
|
|
848
783
|
border-radius: 6px;
|
|
849
784
|
padding: 0.5rem 0;
|
|
850
|
-
min-width: ${
|
|
785
|
+
min-width: ${Wt}px;
|
|
851
786
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
852
|
-
`,
|
|
787
|
+
`,yi=$.hr`
|
|
853
788
|
border: none;
|
|
854
789
|
border-top: 1px solid rgba(128, 128, 128, 0.3);
|
|
855
790
|
margin: 0.35rem 0;
|
|
856
|
-
`,
|
|
791
|
+
`,Ci=({items:e})=>{const[t,r]=f.useState(!1),n=f.useCallback(()=>r(!1),[]),a=typeof e=="function"?e(n):e,[s,o]=f.useState({top:0,left:0}),i=f.useRef(null),c=f.useRef(null),l=f.useCallback(()=>{if(!i.current)return;const u=i.current.getBoundingClientRect(),m=window.innerWidth,b=window.innerHeight,d=c.current?.offsetHeight??160;let h=u.right+4;h+Wt>m&&(h=u.left-Wt-4),h=Math.max(4,Math.min(h,m-Wt-4));let v=u.top;v+d>b-4&&(v=Math.max(4,u.bottom-d)),o({top:v,left:h})},[]);return f.useEffect(()=>{if(!t)return;l();const u=requestAnimationFrame(()=>l()),m=()=>l(),b=()=>l();return window.addEventListener("scroll",m,!0),window.addEventListener("resize",b),()=>{cancelAnimationFrame(u),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",b)}},[t,l]),f.useEffect(()=>{if(!t)return;const u=b=>{const d=b.target;i.current&&!i.current.contains(d)&&c.current&&!c.current.contains(d)&&r(!1)},m=b=>{b.key==="Escape"&&r(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",m)}},[t]),x.jsxs(gi,{children:[x.jsx(vi,{ref:i,onClick:u=>{u.stopPropagation(),r(m=>!m)},onMouseDown:u=>u.stopPropagation(),title:"Track menu","aria-label":"Track menu",children:x.jsx(pi,{size:16})}),t&&typeof document<"u"&&Yr.createPortal(x.jsx(bi,{ref:c,$top:s.top,$left:s.left,onMouseDown:u=>u.stopPropagation(),children:a.map((u,m)=>x.jsxs(f.Fragment,{children:[m>0&&x.jsx(yi,{}),u.content]},u.id))}),document.body)]})},wi=[{dB:2,color:"#ff0000"},{dB:-1,color:"#e74c3c"},{dB:-3,color:"#e67e22"},{dB:-6,color:"#f1c40f"},{dB:-12,color:"#2ecc71"},{dB:-20,color:"#27ae60"},{dB:-30,color:"#5dade2"},{dB:-50,color:"#85c1e9"}],xi=.15,_a="rgba(128, 128, 128, 0.2)",Nr="#ffffff";function Ii(e){return e===1?["M"]:e===2?["L","R"]:Array.from({length:e},(t,r)=>String(r+1))}function Si(e,t){if(t.length===0)return _a;for(const r of t)if(e>=r.dB)return r.color;return t[t.length-1].color}function ki(e,t){const r=Math.max(2,e),[n,a]=t,s=(a-n)/(r-1);return Array.from({length:r},(o,i)=>a-i*s)}function Ai(e){return Math.round(e).toString()}var hn=$.div`
|
|
857
792
|
display: inline-flex;
|
|
858
793
|
flex-direction: ${e=>e.$orientation==="horizontal"?"column":"row"};
|
|
859
794
|
gap: 4px;
|
|
860
795
|
font-family: 'Courier New', monospace;
|
|
861
|
-
`,
|
|
796
|
+
`,_i=$.div`
|
|
862
797
|
display: flex;
|
|
863
798
|
flex-direction: ${e=>e.$orientation==="horizontal"?"row":"column"};
|
|
864
799
|
align-items: center;
|
|
865
800
|
gap: 4px;
|
|
866
|
-
`,
|
|
801
|
+
`,Ei=$.div`
|
|
867
802
|
display: flex;
|
|
868
803
|
flex-direction: ${e=>e.$orientation==="horizontal"?"row":"column"};
|
|
869
|
-
`,
|
|
804
|
+
`,Mi=$.div.attrs(e=>({style:{width:`${e.$width}px`,height:`${e.$height}px`,...e.$orientation==="horizontal"?{marginRight:`${e.$gap}px`}:{marginBottom:`${e.$gap}px`},backgroundColor:e.$isPeak?Nr:e.$active||e.$coloredInactive?e.$color:_a,opacity:e.$isPeak||e.$active?1:e.$coloredInactive?xi:1,boxShadow:e.$active||e.$isPeak?`0 0 4px ${e.$isPeak?Nr:e.$color}40`:"none"}}))`
|
|
870
805
|
border-radius: 1px;
|
|
871
|
-
`,
|
|
806
|
+
`,Ti="#888",pn=$.div`
|
|
872
807
|
color: ${e=>e.$labelColor};
|
|
873
808
|
font-size: 10px;
|
|
874
809
|
text-align: center;
|
|
875
810
|
user-select: none;
|
|
876
|
-
`,
|
|
811
|
+
`,Ri=$.div`
|
|
877
812
|
display: flex;
|
|
878
813
|
flex-direction: column;
|
|
879
814
|
position: relative;
|
|
880
815
|
min-width: 28px;
|
|
881
|
-
|
|
816
|
+
`,Di=$.div.attrs(e=>({style:{top:`${e.$top}px`,color:e.$labelColor}}))`
|
|
882
817
|
position: absolute;
|
|
883
818
|
left: 50%;
|
|
884
819
|
font-size: 9px;
|
|
@@ -886,17 +821,17 @@
|
|
|
886
821
|
white-space: nowrap;
|
|
887
822
|
transform: translate(-50%, -50%);
|
|
888
823
|
user-select: none;
|
|
889
|
-
|
|
824
|
+
`,$i=$.div`
|
|
890
825
|
display: flex;
|
|
891
826
|
flex-direction: row;
|
|
892
827
|
align-items: center;
|
|
893
828
|
gap: 4px;
|
|
894
|
-
`,
|
|
829
|
+
`,Fi=$.div`
|
|
895
830
|
display: flex;
|
|
896
831
|
flex-direction: row;
|
|
897
832
|
position: relative;
|
|
898
833
|
min-height: 16px;
|
|
899
|
-
`,
|
|
834
|
+
`,Bi=$.div.attrs(e=>({style:{left:`${e.$left}px`,color:e.$labelColor}}))`
|
|
900
835
|
position: absolute;
|
|
901
836
|
top: 50%;
|
|
902
837
|
font-size: 9px;
|
|
@@ -904,8 +839,8 @@
|
|
|
904
839
|
white-space: nowrap;
|
|
905
840
|
transform: translate(-50%, -50%);
|
|
906
841
|
user-select: none;
|
|
907
|
-
`,
|
|
908
|
-
`,10)+1,o=r.substring(s)+"",a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)}function Yv(e,t,n){var r;return function(o){return r=r||Xv(e),new Worker(r,o)}}var Uv=Yv("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function Ct(e){if(Gv(e)&&(e=jv(e)),zv(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 xn(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var rr={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function Kv(e){var t={scale:e.scale||rr.scale,bits:e.bits||rr.bits,amplitude_scale:e.amplitude_scale||rr.amplitude_scale,split_channels:e.split_channels||rr.split_channels,disable_worker:e.disable_worker||rr.disable_worker};return t}function Qv(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function pf(e,t,n){var r=Qv(e);if(t.disable_worker){var s=Zv({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 Ct(s),e)}else{var o=new Uv;o.onmessage=function(a){n(void 0,new Ct(a.data),e)},o.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 qv(e,t,n,r){function s(a){a||(a=new DOMException("EncodingError")),r(a),r=function(){}}var o=e.decodeAudioData(t,function(a){pf(a,n,r)},s);o&&o.catch(s)}Ct.create=function(t){return new Ct(t)};Ct.createFromAudio=function(e,t){var n=Kv(e);if(e.audio_context&&e.array_buffer)return qv(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return pf(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function so(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,s=this._inputData.bits===8?1:2,o=r+n*2*this._inputData.channels*s;this._output_data=new ArrayBuffer(o),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 Ct(this._output_data),this._input_index=0,this._output_index=0;var a=this._inputData.channels;this._min=new Array(a),this._max=new Array(a);for(var i=0;i<a;++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}so.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};so.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 s=0;s<n;++s)r=this._outputWaveformData.channel(s),r.set_min_sample(this._output_index-1,this._min[s]),r.set_max_sample(this._output_index-1,this._max[s]);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 o=0;o<n;++o)this._min[o]=this._max_value,this._max[o]=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 a=0;a<n;++a){r=this._inputData.channel(a);var i=r.min_sample(this._input_index);i<this._min[a]&&(this._min[a]=i),i=r.max_sample(this._input_index),i>this._max[a]&&(this._max[a]=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};so.prototype.getOutputData=function(){return this._output_data};Ct.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!En(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!En(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 so(t);!n.next(););return new Ct(n.getOutputData())},concat:function(){var t=this,n=Array.prototype.slice.call(arguments);n.forEach(function(s){if(t.channels!==s.channels||t.sample_rate!==s.sample_rate||t.bits!==s.bits||t.scale!==s.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var r=this._concatBuffers.apply(this,n);return Ct.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,s=0,o=[this].concat(t).map(function(v){return v._data.buffer}),a=0;a<o.length;a++){var i=o[a],l=new DataView(i).getInt32(16,!0);r+=i.byteLength-n,s+=l}for(var c=new ArrayBuffer(r),u=new DataView(o[0]),f=new DataView(c),p=0;p<n;p++)f.setUint8(p,u.getUint8(p));f.setInt32(16,s,!0);for(var d=0,h=new Uint8Array(c,n),g=0;g<o.length;g++){var y=o[g];h.set(new Uint8Array(y,n),d),d+=y.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!En(t.startIndex)&&!En(t.endIndex)?(n=t.startIndex,r=t.endIndex):!En(t.startTime)&&!En(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 s=r-n,o=24,a=this.bits===8?1:2,i=o+s*2*this.channels*a,l=new ArrayBuffer(i),c=new DataView(l);c.setInt32(0,2,!0),c.setUint32(4,this.bits===8,!0),c.setInt32(8,this.sample_rate,!0),c.setInt32(12,this.scale,!0),c.setInt32(16,s,!0),c.setInt32(20,this.channels,!0);for(var u=0;u<s*this.channels*2;u++){var f=this._at(n*this.channels*2+u);this.bits===8?c.setInt8(o+u,f):c.setInt16(o+u*2,f,!0)}return new Ct(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 Ri(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 Ct.create(r)}else{const r=await t.json();return Ct.create(r)}}function mf(e,t=0){const n=e.channel(t),r=e.bits,s=n.min_array(),o=n.max_array(),a=s.length,i=r===8?new Int8Array(a*2):new Int16Array(a*2);for(let l=0;l<a;l++)i[l*2]=s[l],i[l*2+1]=o[l];return{data:i,bits:r,length:a,sampleRate:e.sample_rate}}async function Jv(e,t=0){const n=await Ri(e);return mf(n,t)}async function ey(e){const t=await Ri(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function gf(e,t,n,r){let s=e;if(n!==void 0&&r!==void 0)if(s.scale!==t){const o=e.scale,a=t/o,i=Math.floor(n/t),l=Math.ceil((n+r)/t),c=Math.floor(i*a),u=Math.min(e.length,Math.ceil(l*a));if(c>=u)return null;s=s.slice({startIndex:c,endIndex:u}),s=s.resample({scale:t})}else{const o=Math.floor(n/t),a=Math.ceil((n+r)/t);s=s.slice({startIndex:o,endIndex:a})}else s.scale!==t&&(s=s.resample({scale:t}));return s}function ty(e,t,n=0,r,s){const o=gf(e,t,r,s);if(o===null){const p=e.bits;return{data:p===8?new Int8Array(0):new Int16Array(0),bits:p,length:0}}const a=o.channel(n),i=o.bits,l=a.min_array(),c=a.max_array(),u=l.length,f=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let p=0;p<u;p++)f[p*2]=l[p],f[p*2+1]=c[p];return{data:f,bits:i,length:u}}function hc(e,t,n,r,s){const o=gf(e,t,r,s);if(o===null){const u=e.bits;return{length:0,data:[],bits:u}}const a=o.channels,i=o.bits,l=[];for(let u=0;u<a;u++){const f=o.channel(u),p=f.min_array(),d=f.max_array(),h=p.length,g=i===8?new Int8Array(h*2):new Int16Array(h*2);for(let y=0;y<h;y++)g[y*2]=p[y],g[y*2+1]=d[y];l.push(g)}if(n&&l.length>1){const u=1/l.length,f=l[0].length/2,p=i===8?new Int8Array(f*2):new Int16Array(f*2);for(let d=0;d<f;d++){let h=0,g=0;for(let y=0;y<l.length;y++)h+=u*l[y][d*2],g+=u*l[y][d*2+1];p[d*2]=h,p[d*2+1]=g}return{length:f,data:[p],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function vf(){const[e,t]=m.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Ln(s,e),parseTime:s=>of(s,e)}}function yf({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=m.useState(t),[s,o]=m.useState(!0),[a,i]=m.useState(!0),l=m.useRef(!0),c=m.useRef(!0),u=m.useRef(t),f=m.useCallback(()=>{e.current?.zoomIn()},[e]),p=m.useCallback(()=>{e.current?.zoomOut()},[e]),d=m.useCallback(h=>{h.samplesPerPixel!==u.current&&(u.current=h.samplesPerPixel,m.startTransition(()=>{r(h.samplesPerPixel)})),h.canZoomIn!==l.current&&(l.current=h.canZoomIn,o(h.canZoomIn)),h.canZoomOut!==c.current&&(c.current=h.canZoomOut,i(h.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:f,zoomOut:p,canZoomIn:s,canZoomOut:a,onEngineState:d}}function bf({engineRef:e,initialVolume:t=1}){const[n,r]=m.useState(t),s=m.useRef(t),o=m.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),a=m.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:o,masterVolumeRef:s,onEngineState:a}}function ny({engineRef:e}){const[t,n]=m.useState(0),[r,s]=m.useState(0),o=m.useRef(0),a=m.useRef(0),i=m.useCallback((c,u)=>{e.current?.setSelection(c,u)},[e]),l=m.useCallback(c=>{c.selectionStart!==o.current&&(o.current=c.selectionStart,n(c.selectionStart)),c.selectionEnd!==a.current&&(a.current=c.selectionEnd,s(c.selectionEnd))},[]);return{selectionStart:t,selectionEnd:r,setSelection:i,selectionStartRef:o,selectionEndRef:a,onEngineState:l}}function ry({engineRef:e}){const[t,n]=m.useState(!1),[r,s]=m.useState(0),[o,a]=m.useState(0),i=m.useRef(!1),l=m.useRef(0),c=m.useRef(0),u=m.useCallback(h=>{e.current?.setLoopEnabled(h)},[e]),f=m.useCallback((h,g)=>{e.current?.setLoopRegion(h,g)},[e]),p=m.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),d=m.useCallback(h=>{h.isLoopEnabled!==i.current&&(i.current=h.isLoopEnabled,n(h.isLoopEnabled)),h.loopStart!==l.current&&(l.current=h.loopStart,s(h.loopStart)),h.loopEnd!==c.current&&(c.current=h.loopEnd,a(h.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:o,setLoopEnabled:u,setLoopRegion:f,clearLoopRegion:p,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:d}}function sy({engineRef:e}){const[t,n]=m.useState(null),r=m.useRef(null),s=m.useCallback(a=>{e.current?.selectTrack(a)},[e]),o=m.useCallback(a=>{a.selectedTrackId!==r.current&&(r.current=a.selectedTrackId,n(a.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:o,selectedTrackIdRef:r}}const oy=(e=256)=>{const t=m.useRef(null),n=m.useCallback((r,s,o)=>{const a=new B.Analyser("fft",e);return r.connect(a),r.connect(s),t.current=a,function(){a.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}};function ls(e,t,n,r,s=48e3){const o=n??e.audioBuffer,a=o?.sampleRate??e.waveformData?.sample_rate??s,i=o?.duration??e.waveformData?.duration??(e.duration!=null?e.duration+(e.offset??0):void 0);if(i===void 0)return console.warn(`[waveform-playlist] Track ${t+1} ("${e.name??"unnamed"}"): Cannot create track — provide duration, audioBuffer, or waveformData with duration.`),null;const l=Sc({audioBuffer:o,sampleRate:a,sourceDuration:i,startTime:e.startTime??0,duration:e.duration??i,offset:e.offset??0,name:e.name||`Track ${t+1}`,fadeIn:e.fadeIn,fadeOut:e.fadeOut,waveformData:e.waveformData});if(isNaN(l.startSample)||isNaN(l.durationSamples)||isNaN(l.offsetSamples))return console.error(`[waveform-playlist] Invalid clip values for track ${t+1} ("${e.name??"unnamed"}"): startSample=${l.startSample}, durationSamples=${l.durationSamples}, offsetSamples=${l.offsetSamples}`),null;const c={...kc({name:e.name||`Track ${t+1}`,clips:[l],muted:e.muted??!1,soloed:e.soloed??!1,volume:e.volume??1,pan:e.pan??0,color:e.color}),effects:e.effects,renderMode:e.renderMode,spectrogramConfig:e.spectrogramConfig,spectrogramColorMap:e.spectrogramColorMap},u=r.get(t);return u?(c.id=u.trackId,c.clips[0]={...c.clips[0],id:u.clipId}):r.set(t,{trackId:c.id,clipId:c.clips[0].id}),c}function ay(e,t={}){const{immediate:n=!1,progressive:r=!1}=t,s=n||r,[o,a]=m.useState(!0),[i,l]=m.useState(null),[c,u]=m.useState(0),f=e.length,[p,d]=m.useState(new Map),h=m.useRef(new Map),g=m.useRef(48e3),y=m.useMemo(()=>{if(!s)return null;const C=[];for(let _=0;_<e.length;_++){const S=ls(e[_],_,p.get(_),h.current,g.current);S&&C.push(S)}return C},[s,e,p]),[v,b]=m.useState(y??[]),w=m.useRef(y);return y!==w.current&&(w.current=y,y&&b(y)),m.useEffect(()=>{if(e.length===0){b([]),a(!1),u(0);return}let C=!1;const _=new AbortController;return(async()=>{try{a(!0),l(null),u(0),s&&d(new Map);const k=xc.getContext().rawContext;g.current=k.sampleRate;const I=e.map(async(A,R)=>{if(A.audioBuffer){if(s&&!C){d(O=>{const P=new Map(O);return P.set(R,A.audioBuffer),P}),u(O=>O+1);return}return ls(A,R,A.audioBuffer,h.current,k.sampleRate)}if(!A.src&&A.waveformData){if(s&&!C){u(O=>O+1);return}return ls(A,R,void 0,h.current,k.sampleRate)}if(!A.src)throw new Error(`Track ${R+1}: Must provide src, audioBuffer, or waveformData`);const T=await fetch(A.src,{signal:_.signal});if(!T.ok)throw new Error(`Failed to fetch ${A.src}: ${T.statusText}`);const M=await T.arrayBuffer(),$=await k.decodeAudioData(M);if(!$||!$.sampleRate||!$.duration)throw new Error(`Invalid audio buffer for ${A.src}`);if(s&&!C){d(O=>{const P=new Map(O);return P.set(R,$),P}),u(O=>O+1);return}return ls(A,R,$,h.current,k.sampleRate)}),E=await Promise.all(I);if(!C){if(!s){const A=E.filter(R=>R!=null);b(A),u(A.length)}a(!1)}}catch(k){if(!C){const I=k instanceof Error?k.message:"Unknown error loading audio";l(I),a(!1),console.error(`[waveform-playlist] Error loading audio tracks: ${I}`)}}})(),()=>{C=!0,_.abort()}},[e,s]),{tracks:v,loading:o,error:i,loadedCount:c,totalCount:f}}function iy({originalClip:e,clip:t,pixelDelta:n,samplesPerPixel:r,sampleRate:s,boundary:o,sortedClips:a,sortedIndex:i}){const l=n*r,c=Math.floor(.1*s),u={...t,startSample:e.startSample,offsetSamples:e.offsetSamples,durationSamples:e.durationSamples},f=Rc(u,Math.floor(l),o,a,i,c);return o==="left"?{startSample:e.startSample+f,durationSamples:e.durationSamples-f,offsetSamples:e.offsetSamples+f}:{startSample:e.startSample,durationSamples:e.durationSamples+f,offsetSamples:e.offsetSamples}}function wf({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:o,snapSamplePosition:a}){const i=m.useRef(a);i.current=a;const l=m.useRef(null),c=m.useRef(0),u=m.useCallback(d=>{const h=d.operation.source?.data;if(!h)return;if(!h.boundary){l.current=null;return}const y=e[h.trackIndex]?.clips[h.clipIndex];y&&(l.current={offsetSamples:y.offsetSamples,durationSamples:y.durationSamples,startSample:y.startSample},o.current=!0)},[e,o]),f=m.useCallback(d=>{const h=d.operation.source?.data;if(!h||!h.boundary||!l.current)return;const{boundary:g,trackIndex:y,clipIndex:v}=h,w=(d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x,C=w*n,_=l.current,S=i.current;let k=C;const I=e.map((E,A)=>{if(A!==y)return E;const R=[...E.clips].sort(($,O)=>$.startSample-O.startSample),T=R.findIndex($=>$===E.clips[v]),M=E.clips.map(($,O)=>{if(O!==v)return $;let P=iy({originalClip:_,clip:$,pixelDelta:w,samplesPerPixel:n,sampleRate:r,boundary:g,sortedClips:R,sortedIndex:T});if(S)if(g==="left"){const V=S(P.startSample),Y=V-P.startSample;P={startSample:V,durationSamples:P.durationSamples-Y,offsetSamples:P.offsetSamples+Y},k=V-_.startSample}else{const V=P.startSample+P.durationSamples,Y=S(V);P={...P,durationSamples:Y-P.startSample},k=P.durationSamples-_.durationSamples}return{...$,startSample:P.startSample,durationSamples:P.durationSamples,offsetSamples:P.offsetSamples}});return{...E,clips:M}});c.current=k,t(I)},[e,t,n,r]),p=m.useCallback(d=>{if(d.canceled){if(l.current){const C=d.operation.source?.data;if(C){const{trackIndex:_,clipIndex:S}=C,k=l.current,I=e.map((E,A)=>{if(A!==_)return E;const R=E.clips.map((T,M)=>M!==S?T:{...T,offsetSamples:k.offsetSamples,durationSamples:k.durationSamples,startSample:k.startSample});return{...E,clips:R}});t(I)}}o.current=!1,l.current=null,c.current=0;return}const h=d.operation.source?.data;if(!h)return;const{trackIndex:g,clipId:y,boundary:v}=h,b=v?c.current:d.operation.transform.x*n,w=e[g]?.id;if(v){o.current=!1,w?s.current?s.current.trimClip(w,y,v,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${g} not found — trim not synced to adapter`),l.current=null,c.current=0;return}w?s.current?s.current.moveClip(w,y,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${g} not found — move not synced to adapter`)},[e,t,n,s,o]);return{onDragStart:u,onDragMove:f,onDragEnd:p}}const Mo=.01;function Cf({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:o}){const a=m.useRef(null),i=m.useCallback(u=>{const f=u.operation.source?.data;if(!f||f.annotationIndex===void 0){a.current=null;return}const p=e[f.annotationIndex];p&&(a.current={start:p.start,end:p.end,annotationIndex:f.annotationIndex})},[e]),l=m.useCallback(u=>{if(!a.current)return;const f=u.operation.source?.data;if(!f)return;const{edge:p,annotationIndex:d}=f,h=a.current,v=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,b=p==="start"?h.start+v:h.end+v,w=ly({annotationIndex:d,newTime:b,isDraggingStart:p==="start",annotations:e,duration:s,linkEndpoints:o});t(w)},[e,t,n,r,s,o]),c=m.useCallback(u=>{if(u.canceled&&a.current){const{annotationIndex:f,start:p,end:d}=a.current,h=e.map((g,y)=>y!==f?g:{...g,start:p,end:d});t(h)}a.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function ly({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:s,linkEndpoints:o}){const a=[...r],i=r[e];if(n){const l=Math.min(i.end-.1,Math.max(0,t)),c=l-i.start;if(a[e]={...i,start:l},o&&e>0){const u=a[e-1];Math.abs(u.end-i.start)<Mo?a[e-1]={...u,end:Math.max(u.start+.1,u.end+c)}:l<=u.end&&(a[e]={...a[e],start:u.end})}else!o&&e>0&&l<a[e-1].end&&(a[e-1]={...a[e-1],end:l})}else{const l=Math.max(i.start+.1,Math.min(t,s)),c=l-i.end;if(a[e]={...i,end:l},o&&e<a.length-1){const u=a[e+1];if(Math.abs(u.start-i.end)<Mo){const f=u.start+c;a[e+1]={...u,start:Math.min(u.end-.1,f)};let p=e+1;for(;p<a.length-1;){const d=a[p],h=a[p+1];if(Math.abs(h.start-d.end)<Mo){const g=d.end-r[p].end;a[p+1]={...h,start:Math.min(h.end-.1,h.start+g)},p++}else break}}else l>=u.start&&(a[e]={...a[e],end:u.start})}else if(!o&&e<a.length-1&&l>a[e+1].start){const u=a[e+1];a[e+1]={...u,start:l};let f=e+1;for(;f<a.length-1;){const p=a[f],d=a[f+1];if(p.end>d.start)a[f+1]={...d,start:p.end},f++;else break}}}return a}function _f(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return m.useMemo(()=>t?[ha.configure({activationConstraints(o){return o.pointerType==="touch"?[new Wt.Delay({value:n,tolerance:r})]:[new Wt.Distance({value:s})]}})]:[ha.configure({activationConstraints:[new Wt.Distance({value:s})]})],[t,n,r,s])}const xf=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=ot(),{selectedTrackId:o}=at(),a=m.useCallback((l,c,u)=>{const{samplesPerPixel:f}=e,p=t[l];if(!p)return!1;const d=p.clips[c];if(!d)return!1;const h=Math.round(u*n),g=$h(h,f),y=Math.floor(.1*n);if(!$c(d,g,y))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const v=r.current;return v?(v.splitClip(p.id,d.id,g),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:m.useCallback(()=>{if(!o)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(f=>f.id===o);if(l===-1)return console.warn("Selected track not found"),!1;const c=t[l],u=s.current??0;for(let f=0;f<c.clips.length;f++){const p=c.clips[f],d=p.startSample/n,h=(p.startSample+p.durationSamples)/n;if(u>d&&u<h)return a(l,f,u)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,o,a,n]),splitClipAt:a}};function cy(e,t,n){if(!n||e.repeat)return;const r=e.target;if(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)return;const s=t.find(o=>{const a=e.key.toLowerCase()===o.key.toLowerCase()||e.key===o.key,i=o.ctrlKey===void 0||e.ctrlKey===o.ctrlKey,l=o.shiftKey===void 0||e.shiftKey===o.shiftKey,c=o.metaKey===void 0||e.metaKey===o.metaKey,u=o.altKey===void 0||e.altKey===o.altKey;return a&&i&&l&&c&&u});s&&(s.preventDefault!==!1&&e.preventDefault(),s.action())}const Zs=e=>{const{shortcuts:t,enabled:n=!0}=e,r=m.useCallback(s=>cy(s,t,n),[t,n]);m.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},uy=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("+")},Sf=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=ot(),{setCurrentTime:o,play:a,pause:i,stop:l}=ke(),c=m.useCallback(()=>{s?i():a()},[s,a,i]),u=m.useCallback(()=>{l()},[l]),f=m.useCallback(()=>{o(0),s&&a(0)},[s,o,a]),d=r??[...[{key:" ",action:c,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:u,description:"Stop",preventDefault:!0},{key:"0",action:f,description:"Rewind to start",preventDefault:!0}],...n];return Zs({shortcuts:d,enabled:t}),{rewindToStart:f,togglePlayPause:c,stopPlayback:u,shortcuts:d}},To=.01,cs=.01;function kf({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:o,continuousPlay:a=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:u,onPlay:f}){const p=m.useMemo(()=>t?e.findIndex(I=>I.id===t):-1,[e,t]),d=m.useCallback(I=>{if(!l?.current||!c||!u)return;const E=e.find(Y=>Y.id===I);if(!E)return;const A=l.current,R=A.clientWidth,T=E.start*u/c,M=E.end*u/c,$=(T+M)/2,O=A.scrollLeft,P=O,V=O+R;if(T<P||M>V){const Y=Math.max(0,$-R/2);A.scrollTo({left:Y,behavior:"smooth"})}},[e,l,c,u]);m.useEffect(()=>{t&&l?.current&&c&&u&&d(t)},[t,d,l,c,u]);const h=m.useCallback(I=>{if(p<0)return;const E=e[p],A=Math.max(0,Math.min(E.end-.1,E.start+I)),R=A-E.start,T=[...e];if(T[p]={...E,start:A},o&&p>0){const M=T[p-1];Math.abs(M.end-E.start)<To&&(T[p-1]={...M,end:Math.max(M.start+.1,M.end+R)})}else if(!o&&p>0){const M=T[p-1];A<M.end&&(T[p-1]={...M,end:A})}n(T)},[e,p,o,n]),g=m.useCallback(I=>{if(p<0)return;const E=e[p],A=Math.max(E.start+.1,Math.min(s,E.end+I)),R=A-E.end,T=[...e];if(T[p]={...E,end:A},o&&p<e.length-1){const M=T[p+1];if(Math.abs(M.start-E.end)<To){const $=Math.min(M.end-.1,M.start+R);T[p+1]={...M,start:$};let O=p+1;for(;O<T.length-1;){const P=T[O],V=T[O+1];if(Math.abs(V.start-e[O].end)<To){const Y=P.end-e[O].end;T[O+1]={...V,start:Math.min(V.end-.1,V.start+Y)},O++}else break}}}else if(!o&&p<e.length-1){const M=T[p+1];if(A>M.start){T[p+1]={...M,start:A};let $=p+1;for(;$<T.length-1;){const O=T[$],P=T[$+1];if(O.end>P.start)T[$+1]={...P,start:O.end},$++;else break}}}n(T)},[e,p,s,o,n]),y=m.useCallback(()=>{!r||e.length===0||(p<=0?r(e[e.length-1].id):r(e[p-1].id))},[e,p,r]),v=m.useCallback(()=>{!r||e.length===0||(p<0||p>=e.length-1?r(e[0].id):r(e[p+1].id))},[e,p,r]),b=m.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),w=m.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),C=m.useCallback(()=>{r&&r(null)},[r]),_=m.useCallback(()=>{if(p<0||!f)return;const I=e[p],E=a?void 0:I.end-I.start;f(I.start,E)},[e,p,a,f]),S=m.useMemo(()=>[{key:"[",action:()=>h(-cs),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>h(cs),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>g(-cs),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>g(cs),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:_,description:"Play selected annotation",preventDefault:!0}],[h,g,_]),k=m.useMemo(()=>[{key:"ArrowUp",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:v,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:v,description:"Select next annotation",preventDefault:!0},{key:"Home",action:b,description:"Select first annotation",preventDefault:!0},{key:"End",action:w,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:C,description:"Deselect annotation",preventDefault:!0}],[y,v,b,w,C]);return Zs({shortcuts:S,enabled:i&&p>=0}),Zs({shortcuts:k,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:h,moveEndBoundary:g,selectPrevious:y,selectNext:v,selectFirst:b,selectLast:w,clearSelection:C,scrollToAnnotation:d,playActiveAnnotation:_}}const jr=[{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}]}],$i=e=>jr.find(t=>t.id===e),dy=e=>jr.filter(t=>t.category===e),fy=[{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"}];const hy={reverb:B.Reverb,freeverb:B.Freeverb,jcReverb:B.JCReverb,feedbackDelay:B.FeedbackDelay,pingPongDelay:B.PingPongDelay,chorus:B.Chorus,phaser:B.Phaser,tremolo:B.Tremolo,vibrato:B.Vibrato,autoPanner:B.AutoPanner,autoFilter:B.AutoFilter,autoWah:B.AutoWah,eq3:B.EQ3,distortion:B.Distortion,bitCrusher:B.BitCrusher,chebyshev:B.Chebyshev,compressor:B.Compressor,limiter:B.Limiter,gate:B.Gate,stereoWidener:B.StereoWidener};let py=0;const my=()=>`effect_${Date.now()}_${++py}`;function Rr(e,t){const n=hy[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(i=>{const l=t?.[i.name]??i.default;r[i.name]=l});const s=new n(r),o=my(),a=s;return{effect:s,id:e.id,instanceId:o,dispose(){try{s.disconnect(),s.dispose()}catch(i){console.warn(`[waveform-playlist] Error disposing effect "${e.id}" (${o}):`,i)}},setParameter(i,l){const c=a[i];if(i==="wet"){const u=a.wet;if(u&&typeof u=="object"&&"value"in u){u.value=l;return}}c!==void 0&&(c&&typeof c=="object"&&"value"in c?c.value=l:a[i]=l)},getParameter(i){if(i==="wet"){const c=a.wet;if(c&&typeof c=="object"&&"value"in c)return c.value}const l=a[i];if(l!==void 0)return l&&typeof l=="object"&&"value"in l?l.value:l},connect(i){s.connect(i)},disconnect(){try{s.disconnect()}catch(i){console.warn(`[waveform-playlist] Error disconnecting effect "${e.id}" (${o}):`,i)}}}}function gy(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 vy(e=256){const[t,n]=m.useState([]),r=m.useRef(t);r.current=t;const s=m.useRef(new Map),o=m.useRef(null),a=m.useRef(null),i=m.useCallback(y=>{const v=a.current;if(!v)return;const{masterGainNode:b,destination:w,analyserNode:C}=v;try{b.disconnect()}catch(S){console.warn("[waveform-playlist] Error disconnecting master effects chain:",S)}const _=y.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(_.length===0)b.connect(C),C.connect(w);else{let S=b;_.forEach(k=>{try{k.disconnect()}catch(I){console.warn(`[waveform-playlist] Error disconnecting effect "${k.id}":`,I)}S.connect(k.effect),S=k.effect}),S.connect(C),C.connect(w)}},[]),l=m.useCallback(y=>{const v=$i(y);if(!v){console.error(`Unknown effect: ${y}`);return}const b={};v.parameters.forEach(_=>{b[_.name]=_.default});const w=Rr(v,b);s.current.set(w.instanceId,w);const C={instanceId:w.instanceId,effectId:v.id,definition:v,params:b,bypassed:!1};n(_=>[..._,C])},[]),c=m.useCallback(y=>{const v=s.current.get(y);v&&(v.dispose(),s.current.delete(y)),n(b=>b.filter(w=>w.instanceId!==y))},[]),u=m.useCallback((y,v,b)=>{const w=s.current.get(y);w&&w.setParameter(v,b),n(C=>C.map(_=>_.instanceId===y?{..._,params:{..._.params,[v]:b}}:_))},[]),f=m.useCallback(y=>{const v=r.current.find(C=>C.instanceId===y);if(!v)return;const b=!v.bypassed,w=s.current.get(y);if(w){const C=v.params.wet??1;w.setParameter("wet",b?0:C)}n(C=>C.map(_=>_.instanceId===y?{..._,bypassed:b}:_))},[]),p=m.useCallback((y,v)=>{n(b=>{const w=[...b],[C]=w.splice(y,1);return w.splice(v,0,C),w})},[]),d=m.useCallback(()=>{s.current.forEach(y=>y.dispose()),s.current.clear(),n([])},[]);m.useEffect(()=>{i(t)},[t,i]);const h=m.useCallback((y,v,b)=>{const w=new B.Analyser("fft",e);o.current=w,a.current={masterGainNode:y,destination:v,analyserNode:w};const _=r.current.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(_.length===0)y.connect(w),w.connect(v);else{let S=y;_.forEach(k=>{S.connect(k.effect),S=k.effect}),S.connect(w),w.connect(v)}return function(){w.dispose(),o.current=null,a.current=null}},[e]);m.useEffect(()=>{const y=s.current;return()=>{y.forEach(v=>v.dispose()),y.clear()}},[]);const g=m.useCallback(()=>{const y=t.filter(v=>!v.bypassed);if(y.length!==0)return(v,b,w)=>{const C=[];for(const _ of y){const S=Rr(_.definition,_.params);C.push(S)}if(C.length===0)v.connect(b);else{let _=v;C.forEach(S=>{_.connect(S.effect),_=S.effect}),_.connect(b)}return function(){C.forEach(S=>S.dispose())}}},[t]);return{activeEffects:t,availableEffects:jr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:f,reorderEffects:p,clearAllEffects:d,masterEffects:h,createOfflineEffectsFunction:g,analyserRef:o}}function yy(){const[e,t]=m.useState(new Map),n=m.useRef(new Map),r=m.useRef(new Map),s=m.useCallback((d,h)=>{const g=r.current.get(d);if(!g)return;const{graphEnd:y,masterGainNode:v}=g,b=n.current.get(d);try{y.disconnect()}catch(C){console.warn(`[waveform-playlist] Error disconnecting track "${d}" effect chain:`,C)}const w=h.map(C=>b?.get(C.instanceId)).filter(C=>C!==void 0);if(w.length===0)y.connect(v);else{let C=y;w.forEach(_=>{try{_.disconnect()}catch(S){console.warn(`[waveform-playlist] Error disconnecting effect "${_.id}" on track "${d}":`,S)}C.connect(_.effect),C=_.effect}),C.connect(v)}},[]),o=m.useCallback((d,h)=>{const g=$i(h);if(!g){console.error(`Unknown effect: ${h}`);return}const y={};g.parameters.forEach(w=>{y[w.name]=w.default});const v=Rr(g,y);n.current.has(d)||n.current.set(d,new Map),n.current.get(d).set(v.instanceId,v);const b={instanceId:v.instanceId,effectId:g.id,definition:g,params:y,bypassed:!1};t(w=>{const C=new Map(w),_=C.get(d)||[];return C.set(d,[..._,b]),C})},[]),a=m.useCallback((d,h)=>{const g=n.current.get(d),y=g?.get(h);y&&(y.dispose(),g?.delete(h)),t(v=>{const b=new Map(v),w=b.get(d)||[];return b.set(d,w.filter(C=>C.instanceId!==h)),b})},[]),i=m.useCallback((d,h,g,y)=>{const b=n.current.get(d)?.get(h);b&&b.setParameter(g,y),t(w=>{const C=new Map(w),_=C.get(d)||[];return C.set(d,_.map(S=>S.instanceId===h?{...S,params:{...S.params,[g]:y}}:S)),C})},[]),l=m.useCallback((d,h)=>{const y=(u.current.get(d)||[]).find(C=>C.instanceId===h);if(!y)return;const v=!y.bypassed,w=n.current.get(d)?.get(h);if(w){const C=y.params.wet??1;w.setParameter("wet",v?0:C)}t(C=>{const _=new Map(C),S=_.get(d)||[];return _.set(d,S.map(k=>k.instanceId===h?{...k,bypassed:v}:k)),_})},[]),c=m.useCallback(d=>{const h=n.current.get(d);h&&(h.forEach(g=>g.dispose()),h.clear()),t(g=>{const y=new Map(g);return y.set(d,[]),y})},[]),u=m.useRef(e);u.current=e;const f=m.useCallback(d=>(h,g,y)=>{r.current.set(d,{graphEnd:h,masterGainNode:g});const v=u.current.get(d)||[],b=n.current.get(d),w=v.map(C=>b?.get(C.instanceId)).filter(C=>C!==void 0);if(w.length===0)h.connect(g);else{let C=h;w.forEach(_=>{C.connect(_.effect),C=_.effect}),C.connect(g)}return function(){r.current.delete(d)}},[]);m.useEffect(()=>{e.forEach((d,h)=>{s(h,d)})},[e,s]),m.useEffect(()=>{const d=n.current;return()=>{d.forEach(h=>{h.forEach(g=>g.dispose()),h.clear()}),d.clear()}},[]);const p=m.useCallback(d=>{const g=(e.get(d)||[]).filter(y=>!y.bypassed);if(g.length!==0)return(y,v,b)=>{const w=[];for(const C of g){const _=Rr(C.definition,C.params);w.push(_)}if(w.length===0)y.connect(v);else{let C=y;w.forEach(_=>{C.connect(_.effect),C=_.effect}),C.connect(v)}return function(){w.forEach(_=>_.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:o,removeEffectFromTrack:a,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:f,createOfflineTrackEffectsFunction:p,availableEffects:jr}}function by(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,s=e.sampleRate,o=e.length,a=n/8,i=r*a,l=s*i,c=o*i,u=44,f=u+c,p=new ArrayBuffer(f),d=new DataView(p);us(d,0,"RIFF"),d.setUint32(4,f-8,!0),us(d,8,"WAVE"),us(d,12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,n===32?3:1,!0),d.setUint16(22,r,!0),d.setUint32(24,s,!0),d.setUint32(28,l,!0),d.setUint16(32,i,!0),d.setUint16(34,n,!0),us(d,36,"data"),d.setUint32(40,c,!0);const h=[];for(let y=0;y<r;y++)h.push(e.getChannelData(y));let g=u;if(n===16)for(let y=0;y<o;y++)for(let v=0;v<r;v++){const b=h[v][y],w=Math.max(-1,Math.min(1,b)),C=w<0?w*32768:w*32767;d.setInt16(g,C,!0),g+=2}else for(let y=0;y<o;y++)for(let v=0;v<r;v++)d.setFloat32(g,h[v][y],!0),g+=4;return new Blob([p],{type:"audio/wav"})}function us(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function wy(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 If(){const[e,t]=m.useState(!1),[n,r]=m.useState(0),[s,o]=m.useState(null);return{exportWav:m.useCallback(async(i,l,c={})=>{const{filename:u="export",mode:f="master",trackIndex:p,autoDownload:d=!0,applyEffects:h=!0,effectsFunction:g,createOfflineTrackEffects:y,bitDepth:v=16,onProgress:b}=c;t(!0),r(0),o(null);try{if(i.length===0)throw new Error("No tracks to export");if(f==="individual"&&(p===void 0||p<0||p>=i.length))throw new Error("Invalid track index for individual export");const w=i[0].clips[0]?.sampleRate||44100;let C=0;for(const R of i)for(const T of R.clips){const M=T.startSample+T.durationSamples;C=Math.max(C,M)}C+=Math.round(w*.1);const _=C/w,S=f==="individual"?[{track:i[p],state:l[p],index:p}]:i.map((R,T)=>({track:R,state:l[T],index:T})),k=l.some(R=>R.soloed),I=!!y;let E;if((g||I)&&h)E=await Cy(S,l,k,_,w,g,y,R=>{r(R),b?.(R)});else{const R=new OfflineAudioContext(2,C,w);let T=0;const M=S.reduce(($,{track:O})=>$+O.clips.length,0);for(const{track:$,state:O}of S)if(!(O.muted&&!O.soloed)&&!(k&&!O.soloed))for(const P of $.clips){await xy(R,P,O,w,h),T++;const V=T/M*.5;r(V),b?.(V)}r(.5),b?.(.5),E=await R.startRendering()}r(.9),b?.(.9);const A=by(E,{bitDepth:v});if(r(1),b?.(1),d){const R=f==="individual"?`${u}_${i[p].name}`:u;wy(A,`${R}.wav`)}return{audioBuffer:E,blob:A,duration:_}}catch(w){const C=w instanceof Error?w.message:"Export failed";throw o(C),w}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function Cy(e,t,n,r,s,o,a,i){const{Offline:l,Volume:c,Gain:u,Panner:f,Player:p,ToneAudioBuffer:d}=await import("tone");i(.1);let h;try{h=await l(async({transport:g,destination:y})=>{const v=new c(0);let b;o?b=o(v,y,!0):v.connect(y);for(const{track:w,state:C}of e){if(C.muted&&!C.soloed||n&&!C.soloed)continue;const _=new c(_y(C.volume)),S=new f(C.pan),k=new u(C.muted?0:1),I=a?.(w.id);I?I(k,v,!0):k.connect(v),S.connect(k),_.connect(S);for(const E of w.clips){const{audioBuffer:A,startSample:R,durationSamples:T,offsetSamples:M,gain:$,fadeIn:O,fadeOut:P}=E,V=R/s,Y=T/s,K=M/s,fe=new d(A),pe=new p(fe),Ce=new u($);if(pe.connect(Ce),Ce.connect(_),O){const X=V,Se=V+O.duration,te=_r(Ce.gain);te&&(te.setValueAtTime(0,X),te.linearRampToValueAtTime($,Se))}if(P){const X=V+Y-P.duration,Se=V+Y,te=_r(Ce.gain);te&&(te.setValueAtTime($,X),te.linearRampToValueAtTime(0,Se))}pe.start(V,K,Y)}}g.start(0)},r,2,s)}catch(g){throw g instanceof Error?g:new Error(`Tone.Offline rendering failed: ${String(g)}`)}return i(.9),h.get()}function _y(e){return 20*Math.log10(Math.max(e,1e-4))}async function xy(e,t,n,r,s){const{audioBuffer:o,startSample:a,durationSamples:i,offsetSamples:l,gain:c,fadeIn:u,fadeOut:f}=t;if(!o){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const p=a/r,d=i/r,h=l/r,g=e.createBufferSource();g.buffer=o;const y=e.createGain(),v=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,g.connect(y),y.connect(b),b.connect(e.destination),s){if(u?y.gain.setValueAtTime(0,p):y.gain.setValueAtTime(v,p),u){const w=p,C=p+u.duration;pc(y.gain,w,C,0,v,u.type||"linear")}if(f){const w=p+d-f.duration,C=p+d;(!u||u.duration<d-f.duration)&&y.gain.setValueAtTime(v,w),pc(y.gain,w,C,v,0,f.type||"linear")}}else y.gain.setValueAtTime(v,p);g.start(p,h,d)}function pc(e,t,n,r,s,o){const a=n-t;if(!(a<=0))switch(o){case"linear":e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n);break;case"exponential":{const i=Math.max(r,1e-4),l=Math.max(s,1e-4);e.setValueAtTime(i,t),e.exponentialRampToValueAtTime(l,n),s===0&&e.setValueAtTime(0,n);break}case"logarithmic":{const i=mc(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,a);break}case"sCurve":{const i=mc(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,a);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function mc(e,t,n,r){const s=new Float32Array(n),o=t-e;for(let a=0;a<n;a++){const i=a/(n-1);let l;r==="logarithmic"?o>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),s[a]=e+o*l}return s}const Af=()=>{const e=m.useRef(null),t=m.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=m.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return m.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},Sy=`
|
|
842
|
+
`,Pi=({levels:e,peakLevels:t,channelLabels:r,orientation:n="vertical",segmentCount:a=24,dBRange:s=[-50,5],showScale:o=!0,colorStops:i=wi,segmentWidth:c=20,segmentHeight:l=8,segmentGap:u=2,coloredInactive:m=!1,labelColor:b,className:d})=>{const h=r??Ii(e.length),v=b??Ti,g=e.length;process.env.NODE_ENV!=="production"&&t!=null&&t.length!==g&&console.warn(`[waveform-playlist] SegmentedVUMeter: peakLevels length (${t.length}) does not match levels length (${g})`);const p=g>=2,C=l+u,[y,w]=s,I=f.useMemo(()=>ki(a,[y,w]),[a,y,w]),S=f.useMemo(()=>{const _=a*C-u,E=y,T=w;let R;n==="horizontal"?R=35:R=Math.max(14,C*2);const D=Math.max(2,Math.floor(_/R)),P=[];for(let F=0;F<D;F++){const G=F/(D-1),z=G*_,fe=n==="horizontal"?E+G*(T-E):T-G*(T-E);P.push({position:z,label:Ai(fe)})}return P},[n,a,C,u,y,w]),A=f.useMemo(()=>n==="horizontal"?[...I].reverse():I,[I,n]),k=_=>{const E=e[_],T=xr(E),R=t!=null?xr(t[_]):null;let D=-1;if(R!=null){let P=1/0;for(let F=0;F<A.length;F++){const G=Math.abs(A[F]-R);G<P&&(P=G,D=F)}}return x.jsxs(_i,{$orientation:n,"data-channel":!0,children:[n==="horizontal"&&x.jsx(pn,{$labelColor:v,children:h[_]}),x.jsx(Ei,{$orientation:n,children:A.map((P,F)=>{const G=T>=P,z=F===D,fe=Si(P,i);return x.jsx(Mi,{$width:n==="horizontal"?l:c,$height:n==="horizontal"?c:l,$gap:u,$active:G,$color:fe,$isPeak:z,$orientation:n,$coloredInactive:m,"data-segment":!0,...z?{"data-peak":!0}:{}},F)})}),n==="vertical"&&x.jsx(pn,{$labelColor:v,children:h[_]})]},_)},M=()=>{if(n==="horizontal"){const E=a*C-u;return x.jsxs($i,{children:[x.jsx(pn,{$labelColor:v,style:{visibility:"hidden"},children:"L"}),x.jsx(Fi,{style:{width:`${E}px`},children:S.map(({position:T,label:R},D)=>x.jsx(Bi,{$left:T,$labelColor:v,children:R},D))})]})}const _=a*C-u;return x.jsx(Ri,{style:{height:`${_}px`},children:S.map(({position:E,label:T},R)=>x.jsx(Di,{$top:E,$labelColor:v,children:T},R))})};if(p){if(n==="horizontal")return x.jsxs(hn,{className:d,$orientation:n,"data-meter-orientation":n,children:[Array.from({length:g},(R,D)=>k(D)),o&&M()]});const _=Math.ceil(g/2),E=Array.from({length:_},(R,D)=>D),T=Array.from({length:g-_},(R,D)=>_+D);return x.jsxs(hn,{className:d,$orientation:n,"data-meter-orientation":n,children:[E.map(k),o&&M(),T.map(k)]})}return x.jsxs(hn,{className:d,$orientation:n,"data-meter-orientation":n,children:[k(0),o&&M()]})};f.memo(Pi);function it(e,t){this._waveformData=e,this._channelIndex=t}it.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};it.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};it.prototype.set_min_sample=function(e,t){var r=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(r,t)};it.prototype.set_max_sample=function(e,t){var r=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(r,t)};it.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],r=0;r<e;r++)t.push(this.min_sample(r));return t};it.prototype.max_array=function(){for(var e=this._waveformData.length,t=[],r=0;r<e;r++)t.push(this.max_sample(r));return t};var Vi=127,Zi=-128,Li=32767,Gi=-32768;function Wi(e,t){var r=Math.floor(e/t),n=e-r*t;return n>0&&r++,r}function Ni(e){for(var t=e.scale,r=e.amplitude_scale,n=e.split_channels,a=e.length,s=e.sample_rate,o=e.channels.map(function(E){return new Float32Array(E)}),i=n?o.length:1,c=24,l=Wi(a,t),u=e.bits===8?1:2,m=c+l*2*u*i,b=new ArrayBuffer(m),d=new DataView(b),h=0,v=c,g=new Array(i),p=new Array(i),C=0;C<i;C++)g[C]=1/0,p[C]=-1/0;var y=e.bits===8?Zi:Gi,w=e.bits===8?Vi:Li;d.setInt32(0,2,!0),d.setUint32(4,e.bits===8,!0),d.setInt32(8,s,!0),d.setInt32(12,t,!0),d.setInt32(16,l,!0),d.setInt32(20,i,!0);for(var I=0;I<a;I++){var S=0;if(i===1){for(var A=0;A<o.length;++A)S+=o[A][I];S=Math.floor(w*S*r/o.length),S<g[0]&&(g[0]=S,g[0]<y&&(g[0]=y)),S>p[0]&&(p[0]=S,p[0]>w&&(p[0]=w))}else for(var k=0;k<i;++k)S=Math.floor(w*o[k][I]*r),S<g[k]&&(g[k]=S,g[k]<y&&(g[k]=y)),S>p[k]&&(p[k]=S,p[k]>w&&(p[k]=w));if(++h===t){for(var M=0;M<i;M++)e.bits===8?(d.setInt8(v++,g[M]),d.setInt8(v++,p[M])):(d.setInt16(v,g[M],!0),d.setInt16(v+2,p[M],!0),v+=4),g[M]=1/0,p[M]=-1/0;h=0}}if(h>0)for(var _=0;_<i;_++)e.bits===8?(d.setInt8(v++,g[_]),d.setInt8(v++,p[_])):(d.setInt16(v,g[_],!0),d.setInt16(v+2,p[_],!0));return b}function Xt(e){"@babel/helpers - typeof";return Xt=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},Xt(e)}function Oi(e){return e&&Xt(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function Hi(e){var t=e&&Xt(e)==="object"&&"byteLength"in e;if(t){var r=new DataView(e),n=r.getInt32(0,!0);if(n!==1&&n!==2)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return t}function ji(e){var t=e.data,r=e.channels||1,n=24,a=e.bits===8?1:2,s=e.length*2*r;if(t.length!==s)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=n+t.length*a,i=new ArrayBuffer(o),c=new DataView(i);c.setInt32(0,2,!0),c.setUint32(4,e.bits===8,!0),c.setInt32(8,e.sample_rate,!0),c.setInt32(12,e.samples_per_pixel,!0),c.setInt32(16,e.length,!0),c.setInt32(20,r,!0);var l=n;if(e.bits===8)for(var u=0;u<t.length;u++)c.setInt8(l++,t[u],!0);else for(var m=0;m<t.length;m++)c.setInt16(l,t[m],!0),l+=2;return i}function ft(e){return e==null}function zi(e,t){var r=atob(e);return r}function Xi(e,t,r){var n=zi(e),a=n.indexOf(`
|
|
843
|
+
`,10)+1,s=n.substring(a)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function Yi(e,t,r){var n;return function(s){return n=n||Xi(e),new Worker(n,s)}}var Ui=Yi("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function Le(e){if(Oi(e)&&(e=ji(e)),Hi(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 it(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var bt={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function Ki(e){var t={scale:e.scale||bt.scale,bits:e.bits||bt.bits,amplitude_scale:e.amplitude_scale||bt.amplitude_scale,split_channels:e.split_channels||bt.split_channels,disable_worker:e.disable_worker||bt.disable_worker};return t}function Qi(e){for(var t=[],r=0;r<e.numberOfChannels;++r)t.push(e.getChannelData(r).buffer);return t}function Ea(e,t,r){var n=Qi(e);if(t.disable_worker){var a=Ni({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:n});r(void 0,new Le(a),e)}else{var s=new Ui;s.onmessage=function(o){r(void 0,new Le(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:n},n)}}function Ji(e,t,r,n){function a(o){o||(o=new DOMException("EncodingError")),n(o),n=function(){}}var s=e.decodeAudioData(t,function(o){Ea(o,r,n)},a);s&&s.catch(a)}Le.create=function(t){return new Le(t)};Le.createFromAudio=function(e,t){var r=Ki(e);if(e.audio_context&&e.array_buffer)return Ji(e.audio_context,e.array_buffer,r,t);if(e.audio_buffer)return Ea(e.audio_buffer,r,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function nn(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,r=Math.ceil(t/this._output_samples_per_pixel),n=24,a=this._inputData.bits===8?1:2,s=n+r*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,r,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new Le(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}nn.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};nn.prototype.next=function(){for(var e=0,t=1e3,r=this._inputData.channels,n;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<r;++a)n=this._outputWaveformData.channel(a),n.set_min_sample(this._output_index-1,this._min[a]),n.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<r;++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<r;++o){n=this._inputData.channel(o);var i=n.min_sample(this._input_index);i<this._min[o]&&(this._min[o]=i),i=n.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 c=0;c<r;++c)n=this._outputWaveformData.channel(c),n.set_min_sample(this._output_index-1,this._min[c]),n.set_max_sample(this._output_index-1,this._max[c]);return!0};nn.prototype.getOutputData=function(){return this._output_data};Le.prototype={_getResampleOptions:function(t){var r={};if(r.scale=t.scale,r.width=t.width,!ft(r.width)&&(typeof r.width!="number"||r.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!ft(r.scale)&&(typeof r.scale!="number"||r.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!r.scale&&!r.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(r.width&&(r.scale=Math.floor(this.duration*this.sample_rate/r.width)),r.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+r.scale+" too low, minimum: "+this.scale);return r.abortSignal=t.abortSignal,r},resample:function(t){t=this._getResampleOptions(t),t.waveformData=this;for(var r=new nn(t);!r.next(););return new Le(r.getOutputData())},concat:function(){var t=this,r=Array.prototype.slice.call(arguments);r.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 n=this._concatBuffers.apply(this,r);return Le.create(n)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),r=this._offset,n=r,a=0,s=[this].concat(t).map(function(p){return p._data.buffer}),o=0;o<s.length;o++){var i=s[o],c=new DataView(i).getInt32(16,!0);n+=i.byteLength-r,a+=c}for(var l=new ArrayBuffer(n),u=new DataView(s[0]),m=new DataView(l),b=0;b<r;b++)m.setUint8(b,u.getUint8(b));m.setInt32(16,a,!0);for(var d=0,h=new Uint8Array(l,r),v=0;v<s.length;v++){var g=s[v];h.set(new Uint8Array(g,r),d),d+=g.byteLength-r}return l},slice:function(t){var r=0,n=0;if(!ft(t.startIndex)&&!ft(t.endIndex)?(r=t.startIndex,n=t.endIndex):!ft(t.startTime)&&!ft(t.endTime)&&(r=this.at_time(t.startTime),n=this.at_time(t.endTime)),r<0)throw new RangeError("startIndex or startTime must not be negative");if(n<0)throw new RangeError("endIndex or endTime must not be negative");r>this.length&&(r=this.length),n>this.length&&(n=this.length),r>n&&(r=n);var a=n-r,s=24,o=this.bits===8?1:2,i=s+a*2*this.channels*o,c=new ArrayBuffer(i),l=new DataView(c);l.setInt32(0,2,!0),l.setUint32(4,this.bits===8,!0),l.setInt32(8,this.sample_rate,!0),l.setInt32(12,this.scale,!0),l.setInt32(16,a,!0),l.setInt32(20,this.channels,!0);for(var u=0;u<a*this.channels*2;u++){var m=this._at(r*this.channels*2+u);this.bits===8?l.setInt8(s+u,m):l.setInt16(s+u*2,m,!0)}return new Le(c)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var e=!!this._data.getUint32(4,!0);return e?8:16},get duration(){return this.length*this.scale/this.sample_rate},get pixels_per_second(){return this.sample_rate/this.scale},get seconds_per_pixel(){return this.scale/this.sample_rate},get channels(){return this._version()===2?this._data.getInt32(20,!0):1},channel:function(t){if(t>=0&&t<this._channels.length)return this._channels[t];throw new RangeError("Invalid channel: "+t)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(t){return this.bits===8?this._data.getInt8(this._offset+t):this._data.getInt16(this._offset+t*2,!0)},_set_at:function(t,r){return this.bits===8?this._data.setInt8(this._offset+t,r):this._data.setInt16(this._offset+t*2,r,!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:[]},r=0;r<this.length;r++)for(var n=0;n<this.channels;n++)t.data.push(this.channel(n).min_sample(r)),t.data.push(this.channel(n).max_sample(r));return t},toArrayBuffer:function(){return this._data.buffer}};async function Bn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch waveform data: ${t.statusText}`);if(e.endsWith(".dat")){const n=await t.arrayBuffer();return Le.create(n)}else{const n=await t.json();return Le.create(n)}}function Ma(e,t=0){const r=e.channel(t),n=e.bits,a=r.min_array(),s=r.max_array(),o=a.length,i=n===8?new Int8Array(o*2):new Int16Array(o*2);for(let c=0;c<o;c++)i[c*2]=a[c],i[c*2+1]=s[c];return{data:i,bits:n,length:o,sampleRate:e.sample_rate}}async function qi(e,t=0){const r=await Bn(e);return Ma(r,t)}async function el(e){const t=await Bn(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function Ta(e,t,r,n){let a=e;if(r!==void 0&&n!==void 0)if(a.scale!==t){const s=e.scale,o=t/s,i=Math.floor(r/t),c=Math.ceil((r+n)/t),l=Math.floor(i*o),u=Math.min(e.length,Math.ceil(c*o));if(l>=u)return null;a=a.slice({startIndex:l,endIndex:u}),a=a.resample({scale:t})}else{const s=Math.floor(r/t),o=Math.ceil((r+n)/t);a=a.slice({startIndex:s,endIndex:o})}else a.scale!==t&&(a=a.resample({scale:t}));return a}function tl(e,t,r=0,n,a){const s=Ta(e,t,n,a);if(s===null){const b=e.bits;return{data:b===8?new Int8Array(0):new Int16Array(0),bits:b,length:0}}const o=s.channel(r),i=s.bits,c=o.min_array(),l=o.max_array(),u=c.length,m=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let b=0;b<u;b++)m[b*2]=c[b],m[b*2+1]=l[b];return{data:m,bits:i,length:u}}function Or(e,t,r,n,a){const s=Ta(e,t,n,a);if(s===null){const u=e.bits;return{length:0,data:[],bits:u}}const o=s.channels,i=s.bits,c=[];for(let u=0;u<o;u++){const m=s.channel(u),b=m.min_array(),d=m.max_array(),h=b.length,v=i===8?new Int8Array(h*2):new Int16Array(h*2);for(let g=0;g<h;g++)v[g*2]=b[g],v[g*2+1]=d[g];c.push(v)}if(r&&c.length>1){const u=1/c.length,m=c[0].length/2,b=i===8?new Int8Array(m*2):new Int16Array(m*2);for(let d=0;d<m;d++){let h=0,v=0;for(let g=0;g<c.length;g++)h+=u*c[g][d*2],v+=u*c[g][d*2+1];b[d*2]=h,b[d*2+1]=v}return{length:m,data:[b],bits:i}}return{length:c.length>0?c[0].length/2:0,data:c,bits:i}}function Ra(){const[e,t]=f.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:a=>pt(a,e),parseTime:a=>Ca(a,e)}}function Da({engineRef:e,initialSamplesPerPixel:t}){const[r,n]=f.useState(t),[a,s]=f.useState(!0),[o,i]=f.useState(!0),c=f.useRef(!0),l=f.useRef(!0),u=f.useRef(t),m=f.useCallback(()=>{e.current?.zoomIn()},[e]),b=f.useCallback(()=>{e.current?.zoomOut()},[e]),d=f.useCallback(h=>{h.samplesPerPixel!==u.current&&(u.current=h.samplesPerPixel,f.startTransition(()=>{n(h.samplesPerPixel)})),h.canZoomIn!==c.current&&(c.current=h.canZoomIn,s(h.canZoomIn)),h.canZoomOut!==l.current&&(l.current=h.canZoomOut,i(h.canZoomOut))},[]);return{samplesPerPixel:r,zoomIn:m,zoomOut:b,canZoomIn:a,canZoomOut:o,onEngineState:d}}function $a({engineRef:e,initialVolume:t=1}){const[r,n]=f.useState(t),a=f.useRef(t),s=f.useCallback(i=>{e.current?e.current.setMasterVolume(i):(a.current=i,n(i))},[e]),o=f.useCallback(i=>{i.masterVolume!==a.current&&(a.current=i.masterVolume,n(i.masterVolume))},[]);return{masterVolume:r,setMasterVolume:s,masterVolumeRef:a,onEngineState:o}}function nl({engineRef:e}){const[t,r]=f.useState(0),[n,a]=f.useState(0),s=f.useRef(0),o=f.useRef(0),i=f.useCallback((l,u)=>{e.current?.setSelection(l,u)},[e]),c=f.useCallback(l=>{l.selectionStart!==s.current&&(s.current=l.selectionStart,r(l.selectionStart)),l.selectionEnd!==o.current&&(o.current=l.selectionEnd,a(l.selectionEnd))},[]);return{selectionStart:t,selectionEnd:n,setSelection:i,selectionStartRef:s,selectionEndRef:o,onEngineState:c}}function rl({engineRef:e}){const[t,r]=f.useState(!1),[n,a]=f.useState(0),[s,o]=f.useState(0),i=f.useRef(!1),c=f.useRef(0),l=f.useRef(0),u=f.useCallback(h=>{e.current?.setLoopEnabled(h)},[e]),m=f.useCallback((h,v)=>{e.current?.setLoopRegion(h,v)},[e]),b=f.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),d=f.useCallback(h=>{h.isLoopEnabled!==i.current&&(i.current=h.isLoopEnabled,r(h.isLoopEnabled)),h.loopStart!==c.current&&(c.current=h.loopStart,a(h.loopStart)),h.loopEnd!==l.current&&(l.current=h.loopEnd,o(h.loopEnd))},[]);return{isLoopEnabled:t,loopStart:n,loopEnd:s,setLoopEnabled:u,setLoopRegion:m,clearLoopRegion:b,isLoopEnabledRef:i,loopStartRef:c,loopEndRef:l,onEngineState:d}}function al({engineRef:e}){const[t,r]=f.useState(null),n=f.useRef(null),a=f.useCallback(o=>{e.current?.selectTrack(o)},[e]),s=f.useCallback(o=>{o.selectedTrackId!==n.current&&(n.current=o.selectedTrackId,r(o.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:a,onEngineState:s,selectedTrackIdRef:n}}const ol=(e=256)=>{const t=f.useRef(null),r=f.useCallback((n,a,s)=>{const o=new Z.Analyser("fft",e);return n.connect(o),n.connect(a),t.current=o,function(){o.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:r}};function Vt(e,t,r,n,a=48e3){const s=r??e.audioBuffer,o=s?.sampleRate??e.waveformData?.sample_rate??a,i=s?.duration??e.waveformData?.duration??(e.duration!=null?e.duration+(e.offset??0):void 0);if(i===void 0)return console.warn(`[waveform-playlist] Track ${t+1} ("${e.name??"unnamed"}"): Cannot create track — provide duration, audioBuffer, or waveformData with duration.`),null;const c=Jr({audioBuffer:s,sampleRate:o,sourceDuration:i,startTime:e.startTime??0,duration:e.duration??i,offset:e.offset??0,name:e.name||`Track ${t+1}`,fadeIn:e.fadeIn,fadeOut:e.fadeOut,waveformData:e.waveformData});if(isNaN(c.startSample)||isNaN(c.durationSamples)||isNaN(c.offsetSamples))return console.error(`[waveform-playlist] Invalid clip values for track ${t+1} ("${e.name??"unnamed"}"): startSample=${c.startSample}, durationSamples=${c.durationSamples}, offsetSamples=${c.offsetSamples}`),null;const l={...qr({name:e.name||`Track ${t+1}`,clips:[c],muted:e.muted??!1,soloed:e.soloed??!1,volume:e.volume??1,pan:e.pan??0,color:e.color}),effects:e.effects,renderMode:e.renderMode,spectrogramConfig:e.spectrogramConfig,spectrogramColorMap:e.spectrogramColorMap},u=n.get(t);return u?(l.id=u.trackId,l.clips[0]={...l.clips[0],id:u.clipId}):n.set(t,{trackId:l.id,clipId:l.clips[0].id}),l}function sl(e,t={}){const{immediate:r=!1,progressive:n=!1}=t,a=r||n,[s,o]=f.useState(!0),[i,c]=f.useState(null),[l,u]=f.useState(0),m=e.length,[b,d]=f.useState(new Map),h=f.useRef(new Map),v=f.useRef(48e3),g=f.useMemo(()=>{if(!a)return null;const w=[];for(let I=0;I<e.length;I++){const S=Vt(e[I],I,b.get(I),h.current,v.current);S&&w.push(S)}return w},[a,e,b]),[p,C]=f.useState(g??[]),y=f.useRef(g);return g!==y.current&&(y.current=g,g&&C(g)),f.useEffect(()=>{if(e.length===0){C([]),o(!1),u(0);return}let w=!1;const I=new AbortController;return(async()=>{try{o(!0),c(null),u(0),a&&d(new Map);const A=Qr.getContext().rawContext;v.current=A.sampleRate;const k=e.map(async(_,E)=>{if(_.audioBuffer){if(a&&!w){d(P=>{const F=new Map(P);return F.set(E,_.audioBuffer),F}),u(P=>P+1);return}return Vt(_,E,_.audioBuffer,h.current,A.sampleRate)}if(!_.src&&_.waveformData){if(a&&!w){u(P=>P+1);return}return Vt(_,E,void 0,h.current,A.sampleRate)}if(!_.src)throw new Error(`Track ${E+1}: Must provide src, audioBuffer, or waveformData`);const T=await fetch(_.src,{signal:I.signal});if(!T.ok)throw new Error(`Failed to fetch ${_.src}: ${T.statusText}`);const R=await T.arrayBuffer(),D=await A.decodeAudioData(R);if(!D||!D.sampleRate||!D.duration)throw new Error(`Invalid audio buffer for ${_.src}`);if(a&&!w){d(P=>{const F=new Map(P);return F.set(E,D),F}),u(P=>P+1);return}return Vt(_,E,D,h.current,A.sampleRate)}),M=await Promise.all(k);if(!w){if(!a){const _=M.filter(E=>E!=null);C(_),u(_.length)}o(!1)}}catch(A){if(!w){const k=A instanceof Error?A.message:"Unknown error loading audio";c(k),o(!1),console.error(`[waveform-playlist] Error loading audio tracks: ${k}`)}}})(),()=>{w=!0,I.abort()}},[e,a]),{tracks:p,loading:s,error:i,loadedCount:l,totalCount:m}}function il({originalClip:e,clip:t,pixelDelta:r,samplesPerPixel:n,sampleRate:a,boundary:s,sortedClips:o,sortedIndex:i}){const c=r*n,l=Math.floor(.1*a),u={...t,startSample:e.startSample,offsetSamples:e.offsetSamples,durationSamples:e.durationSamples},m=aa(u,Math.floor(c),s,o,i,l);return s==="left"?{startSample:e.startSample+m,durationSamples:e.durationSamples-m,offsetSamples:e.offsetSamples+m}:{startSample:e.startSample,durationSamples:e.durationSamples+m,offsetSamples:e.offsetSamples}}function Fa({tracks:e,onTracksChange:t,samplesPerPixel:r,sampleRate:n,engineRef:a,isDraggingRef:s,snapSamplePosition:o}){const i=f.useRef(o);i.current=o;const c=f.useRef(null),l=f.useRef(0),u=f.useCallback(d=>{const h=d.operation.source?.data;if(!h)return;if(!h.boundary){c.current=null;return}const g=e[h.trackIndex]?.clips[h.clipIndex];g&&(c.current={offsetSamples:g.offsetSamples,durationSamples:g.durationSamples,startSample:g.startSample},s.current=!0)},[e,s]),m=f.useCallback(d=>{const h=d.operation.source?.data;if(!h||!h.boundary||!c.current)return;const{boundary:v,trackIndex:g,clipIndex:p}=h,y=(d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x,w=y*r,I=c.current,S=i.current;let A=w;const k=e.map((M,_)=>{if(_!==g)return M;const E=[...M.clips].sort((D,P)=>D.startSample-P.startSample),T=E.findIndex(D=>D===M.clips[p]),R=M.clips.map((D,P)=>{if(P!==p)return D;let F=il({originalClip:I,clip:D,pixelDelta:y,samplesPerPixel:r,sampleRate:n,boundary:v,sortedClips:E,sortedIndex:T});if(S)if(v==="left"){const G=S(F.startSample),z=G-F.startSample;F={startSample:G,durationSamples:F.durationSamples-z,offsetSamples:F.offsetSamples+z},A=G-I.startSample}else{const G=F.startSample+F.durationSamples,z=S(G);F={...F,durationSamples:z-F.startSample},A=F.durationSamples-I.durationSamples}return{...D,startSample:F.startSample,durationSamples:F.durationSamples,offsetSamples:F.offsetSamples}});return{...M,clips:R}});l.current=A,t(k)},[e,t,r,n]),b=f.useCallback(d=>{if(d.canceled){if(c.current){const w=d.operation.source?.data;if(w){const{trackIndex:I,clipIndex:S}=w,A=c.current,k=e.map((M,_)=>{if(_!==I)return M;const E=M.clips.map((T,R)=>R!==S?T:{...T,offsetSamples:A.offsetSamples,durationSamples:A.durationSamples,startSample:A.startSample});return{...M,clips:E}});t(k)}}s.current=!1,c.current=null,l.current=0;return}const h=d.operation.source?.data;if(!h)return;const{trackIndex:v,clipId:g,boundary:p}=h,C=p?l.current:d.operation.transform.x*r,y=e[v]?.id;if(p){s.current=!1,y?a.current?a.current.trimClip(y,g,p,Math.floor(C)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${v} not found — trim not synced to adapter`),c.current=null,l.current=0;return}y?a.current?a.current.moveClip(y,g,Math.floor(C)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${v} not found — move not synced to adapter`)},[e,t,r,a,s]);return{onDragStart:u,onDragMove:m,onDragEnd:b}}const gn=.01;function Ba({annotations:e,onAnnotationsChange:t,samplesPerPixel:r,sampleRate:n,duration:a,linkEndpoints:s}){const o=f.useRef(null),i=f.useCallback(u=>{const m=u.operation.source?.data;if(!m||m.annotationIndex===void 0){o.current=null;return}const b=e[m.annotationIndex];b&&(o.current={start:b.start,end:b.end,annotationIndex:m.annotationIndex})},[e]),c=f.useCallback(u=>{if(!o.current)return;const m=u.operation.source?.data;if(!m)return;const{edge:b,annotationIndex:d}=m,h=o.current,p=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*r/n,C=b==="start"?h.start+p:h.end+p,y=ll({annotationIndex:d,newTime:C,isDraggingStart:b==="start",annotations:e,duration:a,linkEndpoints:s});t(y)},[e,t,r,n,a,s]),l=f.useCallback(u=>{if(u.canceled&&o.current){const{annotationIndex:m,start:b,end:d}=o.current,h=e.map((v,g)=>g!==m?v:{...v,start:b,end:d});t(h)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:c,onDragEnd:l}}function ll({annotationIndex:e,newTime:t,isDraggingStart:r,annotations:n,duration:a,linkEndpoints:s}){const o=[...n],i=n[e];if(r){const c=Math.min(i.end-.1,Math.max(0,t)),l=c-i.start;if(o[e]={...i,start:c},s&&e>0){const u=o[e-1];Math.abs(u.end-i.start)<gn?o[e-1]={...u,end:Math.max(u.start+.1,u.end+l)}:c<=u.end&&(o[e]={...o[e],start:u.end})}else!s&&e>0&&c<o[e-1].end&&(o[e-1]={...o[e-1],end:c})}else{const c=Math.max(i.start+.1,Math.min(t,a)),l=c-i.end;if(o[e]={...i,end:c},s&&e<o.length-1){const u=o[e+1];if(Math.abs(u.start-i.end)<gn){const m=u.start+l;o[e+1]={...u,start:Math.min(u.end-.1,m)};let b=e+1;for(;b<o.length-1;){const d=o[b],h=o[b+1];if(Math.abs(h.start-d.end)<gn){const v=d.end-n[b].end;o[b+1]={...h,start:Math.min(h.end-.1,h.start+v)},b++}else break}}else c>=u.start&&(o[e]={...o[e],end:u.start})}else if(!s&&e<o.length-1&&c>o[e+1].start){const u=o[e+1];o[e+1]={...u,start:c};let m=e+1;for(;m<o.length-1;){const b=o[m],d=o[m+1];if(b.end>d.start)o[m+1]={...d,start:b.end},m++;else break}}}return o}function Pa(e={}){const{touchOptimized:t=!1,touchDelay:r=250,touchTolerance:n=5,mouseDistance:a=1}=e;return f.useMemo(()=>t?[st.PointerSensor.configure({activationConstraints(s){return s.pointerType==="touch"?[new st.PointerActivationConstraints.Delay({value:r,tolerance:n})]:[new st.PointerActivationConstraints.Distance({value:a})]}})]:[st.PointerSensor.configure({activationConstraints:[new st.PointerActivationConstraints.Distance({value:a})]})],[t,r,n,a])}const Va=e=>{const{tracks:t,sampleRate:r,engineRef:n}=e,{currentTimeRef:a}=Me(),{selectedTrackId:s}=Te(),o=f.useCallback((c,l,u)=>{const{samplesPerPixel:m}=e,b=t[c];if(!b)return!1;const d=b.clips[l];if(!d)return!1;const h=Math.round(u*r),v=Do(h,m),g=Math.floor(.1*r);if(!oa(d,v,g))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const p=n.current;return p?(p.splitClip(b.id,d.id,v),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,r,n]);return{splitClipAtPlayhead:f.useCallback(()=>{if(!s)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const c=t.findIndex(m=>m.id===s);if(c===-1)return console.warn("Selected track not found"),!1;const l=t[c],u=a.current??0;for(let m=0;m<l.clips.length;m++){const b=l.clips[m],d=b.startSample/r,h=(b.startSample+b.durationSamples)/r;if(u>d&&u<h)return o(c,m,u)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${l.name}"`),!1},[t,a,s,o,r]),splitClipAt:o}};function cl(e,t,r){if(!r||e.repeat)return;const n=e.target;if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable)return;const a=t.find(s=>{const o=e.key.toLowerCase()===s.key.toLowerCase()||e.key===s.key,i=s.ctrlKey===void 0||e.ctrlKey===s.ctrlKey,c=s.shiftKey===void 0||e.shiftKey===s.shiftKey,l=s.metaKey===void 0||e.metaKey===s.metaKey,u=s.altKey===void 0||e.altKey===s.altKey;return o&&i&&c&&l&&u});a&&(a.preventDefault!==!1&&e.preventDefault(),a.action())}const Yt=e=>{const{shortcuts:t,enabled:r=!0}=e,n=f.useCallback(a=>cl(a,t,r),[t,r]);f.useEffect(()=>{if(r)return window.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n)}},[n,r])},ul=e=>{const t=[],r=typeof navigator<"u"&&navigator.platform.includes("Mac");return e.metaKey&&t.push(r?"Cmd":"Ctrl"),e.ctrlKey&&!e.metaKey&&t.push("Ctrl"),e.altKey&&t.push(r?"Option":"Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")},Za=(e={})=>{const{enabled:t=!0,additionalShortcuts:r=[],shortcuts:n}=e,{isPlaying:a}=Me(),{setCurrentTime:s,play:o,pause:i,stop:c}=he(),l=f.useCallback(()=>{a?i():o()},[a,o,i]),u=f.useCallback(()=>{c()},[c]),m=f.useCallback(()=>{s(0),a&&o(0)},[a,s,o]),d=n??[...[{key:" ",action:l,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:u,description:"Stop",preventDefault:!0},{key:"0",action:m,description:"Rewind to start",preventDefault:!0}],...r];return Yt({shortcuts:d,enabled:t}),{rewindToStart:m,togglePlayPause:l,stopPlayback:u,shortcuts:d}},vn=.01,Zt=.01;function La({annotations:e,activeAnnotationId:t,onAnnotationsChange:r,onActiveAnnotationChange:n,duration:a,linkEndpoints:s,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:c,samplesPerPixel:l,sampleRate:u,onPlay:m}){const b=f.useMemo(()=>t?e.findIndex(k=>k.id===t):-1,[e,t]),d=f.useCallback(k=>{if(!c?.current||!l||!u)return;const M=e.find(z=>z.id===k);if(!M)return;const _=c.current,E=_.clientWidth,T=M.start*u/l,R=M.end*u/l,D=(T+R)/2,P=_.scrollLeft,F=P,G=P+E;if(T<F||R>G){const z=Math.max(0,D-E/2);_.scrollTo({left:z,behavior:"smooth"})}},[e,c,l,u]);f.useEffect(()=>{t&&c?.current&&l&&u&&d(t)},[t,d,c,l,u]);const h=f.useCallback(k=>{if(b<0)return;const M=e[b],_=Math.max(0,Math.min(M.end-.1,M.start+k)),E=_-M.start,T=[...e];if(T[b]={...M,start:_},s&&b>0){const R=T[b-1];Math.abs(R.end-M.start)<vn&&(T[b-1]={...R,end:Math.max(R.start+.1,R.end+E)})}else if(!s&&b>0){const R=T[b-1];_<R.end&&(T[b-1]={...R,end:_})}r(T)},[e,b,s,r]),v=f.useCallback(k=>{if(b<0)return;const M=e[b],_=Math.max(M.start+.1,Math.min(a,M.end+k)),E=_-M.end,T=[...e];if(T[b]={...M,end:_},s&&b<e.length-1){const R=T[b+1];if(Math.abs(R.start-M.end)<vn){const D=Math.min(R.end-.1,R.start+E);T[b+1]={...R,start:D};let P=b+1;for(;P<T.length-1;){const F=T[P],G=T[P+1];if(Math.abs(G.start-e[P].end)<vn){const z=F.end-e[P].end;T[P+1]={...G,start:Math.min(G.end-.1,G.start+z)},P++}else break}}}else if(!s&&b<e.length-1){const R=T[b+1];if(_>R.start){T[b+1]={...R,start:_};let D=b+1;for(;D<T.length-1;){const P=T[D],F=T[D+1];if(P.end>F.start)T[D+1]={...F,start:P.end},D++;else break}}}r(T)},[e,b,a,s,r]),g=f.useCallback(()=>{!n||e.length===0||(b<=0?n(e[e.length-1].id):n(e[b-1].id))},[e,b,n]),p=f.useCallback(()=>{!n||e.length===0||(b<0||b>=e.length-1?n(e[0].id):n(e[b+1].id))},[e,b,n]),C=f.useCallback(()=>{!n||e.length===0||n(e[0].id)},[e,n]),y=f.useCallback(()=>{!n||e.length===0||n(e[e.length-1].id)},[e,n]),w=f.useCallback(()=>{n&&n(null)},[n]),I=f.useCallback(()=>{if(b<0||!m)return;const k=e[b],M=o?void 0:k.end-k.start;m(k.start,M)},[e,b,o,m]),S=f.useMemo(()=>[{key:"[",action:()=>h(-Zt),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>h(Zt),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-Zt),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(Zt),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:I,description:"Play selected annotation",preventDefault:!0}],[h,v,I]),A=f.useMemo(()=>[{key:"ArrowUp",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:p,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:p,description:"Select next annotation",preventDefault:!0},{key:"Home",action:C,description:"Select first annotation",preventDefault:!0},{key:"End",action:y,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:w,description:"Deselect annotation",preventDefault:!0}],[g,p,C,y,w]);return Yt({shortcuts:S,enabled:i&&b>=0}),Yt({shortcuts:A,enabled:i&&e.length>0&&!!n}),{moveStartBoundary:h,moveEndBoundary:v,selectPrevious:g,selectNext:p,selectFirst:C,selectLast:y,clearSelection:w,scrollToAnnotation:d,playActiveAnnotation:I}}const At=[{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=>At.find(t=>t.id===e),dl=e=>At.filter(t=>t.category===e),fl=[{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"}];const ml={reverb:Z.Reverb,freeverb:Z.Freeverb,jcReverb:Z.JCReverb,feedbackDelay:Z.FeedbackDelay,pingPongDelay:Z.PingPongDelay,chorus:Z.Chorus,phaser:Z.Phaser,tremolo:Z.Tremolo,vibrato:Z.Vibrato,autoPanner:Z.AutoPanner,autoFilter:Z.AutoFilter,autoWah:Z.AutoWah,eq3:Z.EQ3,distortion:Z.Distortion,bitCrusher:Z.BitCrusher,chebyshev:Z.Chebyshev,compressor:Z.Compressor,limiter:Z.Limiter,gate:Z.Gate,stereoWidener:Z.StereoWidener};let hl=0;const pl=()=>`effect_${Date.now()}_${++hl}`;function wt(e,t){const r=ml[e.id];if(!r)throw new Error(`Unknown effect type: ${e.id}`);const n={};e.parameters.forEach(i=>{const c=t?.[i.name]??i.default;n[i.name]=c});const a=new r(n),s=pl(),o=a;return{effect:a,id:e.id,instanceId:s,dispose(){try{a.disconnect(),a.dispose()}catch(i){console.warn(`[waveform-playlist] Error disposing effect "${e.id}" (${s}):`,i)}},setParameter(i,c){const l=o[i];if(i==="wet"){const u=o.wet;if(u&&typeof u=="object"&&"value"in u){u.value=c;return}}l!==void 0&&(l&&typeof l=="object"&&"value"in l?l.value=c:o[i]=c)},getParameter(i){if(i==="wet"){const l=o.wet;if(l&&typeof l=="object"&&"value"in l)return l.value}const c=o[i];if(c!==void 0)return c&&typeof c=="object"&&"value"in c?c.value:c},connect(i){a.connect(i)},disconnect(){try{a.disconnect()}catch(i){console.warn(`[waveform-playlist] Error disconnecting effect "${e.id}" (${s}):`,i)}}}}function gl(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 vl(e=256){const[t,r]=f.useState([]),n=f.useRef(t);n.current=t;const a=f.useRef(new Map),s=f.useRef(null),o=f.useRef(null),i=f.useCallback(g=>{const p=o.current;if(!p)return;const{masterGainNode:C,destination:y,analyserNode:w}=p;try{C.disconnect()}catch(S){console.warn("[waveform-playlist] Error disconnecting master effects chain:",S)}const I=g.map(S=>a.current.get(S.instanceId)).filter(S=>S!==void 0);if(I.length===0)C.connect(w),w.connect(y);else{let S=C;I.forEach(A=>{try{A.disconnect()}catch(k){console.warn(`[waveform-playlist] Error disconnecting effect "${A.id}":`,k)}S.connect(A.effect),S=A.effect}),S.connect(w),w.connect(y)}},[]),c=f.useCallback(g=>{const p=Pn(g);if(!p){console.error(`Unknown effect: ${g}`);return}const C={};p.parameters.forEach(I=>{C[I.name]=I.default});const y=wt(p,C);a.current.set(y.instanceId,y);const w={instanceId:y.instanceId,effectId:p.id,definition:p,params:C,bypassed:!1};r(I=>[...I,w])},[]),l=f.useCallback(g=>{const p=a.current.get(g);p&&(p.dispose(),a.current.delete(g)),r(C=>C.filter(y=>y.instanceId!==g))},[]),u=f.useCallback((g,p,C)=>{const y=a.current.get(g);y&&y.setParameter(p,C),r(w=>w.map(I=>I.instanceId===g?{...I,params:{...I.params,[p]:C}}:I))},[]),m=f.useCallback(g=>{const p=n.current.find(w=>w.instanceId===g);if(!p)return;const C=!p.bypassed,y=a.current.get(g);if(y){const w=p.params.wet??1;y.setParameter("wet",C?0:w)}r(w=>w.map(I=>I.instanceId===g?{...I,bypassed:C}:I))},[]),b=f.useCallback((g,p)=>{r(C=>{const y=[...C],[w]=y.splice(g,1);return y.splice(p,0,w),y})},[]),d=f.useCallback(()=>{a.current.forEach(g=>g.dispose()),a.current.clear(),r([])},[]);f.useEffect(()=>{i(t)},[t,i]);const h=f.useCallback((g,p,C)=>{const y=new Z.Analyser("fft",e);s.current=y,o.current={masterGainNode:g,destination:p,analyserNode:y};const I=n.current.map(S=>a.current.get(S.instanceId)).filter(S=>S!==void 0);if(I.length===0)g.connect(y),y.connect(p);else{let S=g;I.forEach(A=>{S.connect(A.effect),S=A.effect}),S.connect(y),y.connect(p)}return function(){y.dispose(),s.current=null,o.current=null}},[e]);f.useEffect(()=>{const g=a.current;return()=>{g.forEach(p=>p.dispose()),g.clear()}},[]);const v=f.useCallback(()=>{const g=t.filter(p=>!p.bypassed);if(g.length!==0)return(p,C,y)=>{const w=[];for(const I of g){const S=wt(I.definition,I.params);w.push(S)}if(w.length===0)p.connect(C);else{let I=p;w.forEach(S=>{I.connect(S.effect),I=S.effect}),I.connect(C)}return function(){w.forEach(S=>S.dispose())}}},[t]);return{activeEffects:t,availableEffects:At,addEffect:c,removeEffect:l,updateParameter:u,toggleBypass:m,reorderEffects:b,clearAllEffects:d,masterEffects:h,createOfflineEffectsFunction:v,analyserRef:s}}function bl(){const[e,t]=f.useState(new Map),r=f.useRef(new Map),n=f.useRef(new Map),a=f.useCallback((d,h)=>{const v=n.current.get(d);if(!v)return;const{graphEnd:g,masterGainNode:p}=v,C=r.current.get(d);try{g.disconnect()}catch(w){console.warn(`[waveform-playlist] Error disconnecting track "${d}" effect chain:`,w)}const y=h.map(w=>C?.get(w.instanceId)).filter(w=>w!==void 0);if(y.length===0)g.connect(p);else{let w=g;y.forEach(I=>{try{I.disconnect()}catch(S){console.warn(`[waveform-playlist] Error disconnecting effect "${I.id}" on track "${d}":`,S)}w.connect(I.effect),w=I.effect}),w.connect(p)}},[]),s=f.useCallback((d,h)=>{const v=Pn(h);if(!v){console.error(`Unknown effect: ${h}`);return}const g={};v.parameters.forEach(y=>{g[y.name]=y.default});const p=wt(v,g);r.current.has(d)||r.current.set(d,new Map),r.current.get(d).set(p.instanceId,p);const C={instanceId:p.instanceId,effectId:v.id,definition:v,params:g,bypassed:!1};t(y=>{const w=new Map(y),I=w.get(d)||[];return w.set(d,[...I,C]),w})},[]),o=f.useCallback((d,h)=>{const v=r.current.get(d),g=v?.get(h);g&&(g.dispose(),v?.delete(h)),t(p=>{const C=new Map(p),y=C.get(d)||[];return C.set(d,y.filter(w=>w.instanceId!==h)),C})},[]),i=f.useCallback((d,h,v,g)=>{const C=r.current.get(d)?.get(h);C&&C.setParameter(v,g),t(y=>{const w=new Map(y),I=w.get(d)||[];return w.set(d,I.map(S=>S.instanceId===h?{...S,params:{...S.params,[v]:g}}:S)),w})},[]),c=f.useCallback((d,h)=>{const g=(u.current.get(d)||[]).find(w=>w.instanceId===h);if(!g)return;const p=!g.bypassed,y=r.current.get(d)?.get(h);if(y){const w=g.params.wet??1;y.setParameter("wet",p?0:w)}t(w=>{const I=new Map(w),S=I.get(d)||[];return I.set(d,S.map(A=>A.instanceId===h?{...A,bypassed:p}:A)),I})},[]),l=f.useCallback(d=>{const h=r.current.get(d);h&&(h.forEach(v=>v.dispose()),h.clear()),t(v=>{const g=new Map(v);return g.set(d,[]),g})},[]),u=f.useRef(e);u.current=e;const m=f.useCallback(d=>(h,v,g)=>{n.current.set(d,{graphEnd:h,masterGainNode:v});const p=u.current.get(d)||[],C=r.current.get(d),y=p.map(w=>C?.get(w.instanceId)).filter(w=>w!==void 0);if(y.length===0)h.connect(v);else{let w=h;y.forEach(I=>{w.connect(I.effect),w=I.effect}),w.connect(v)}return function(){n.current.delete(d)}},[]);f.useEffect(()=>{e.forEach((d,h)=>{a(h,d)})},[e,a]),f.useEffect(()=>{const d=r.current;return()=>{d.forEach(h=>{h.forEach(v=>v.dispose()),h.clear()}),d.clear()}},[]);const b=f.useCallback(d=>{const v=(e.get(d)||[]).filter(g=>!g.bypassed);if(v.length!==0)return(g,p,C)=>{const y=[];for(const w of v){const I=wt(w.definition,w.params);y.push(I)}if(y.length===0)g.connect(p);else{let w=g;y.forEach(I=>{w.connect(I.effect),w=I.effect}),w.connect(p)}return function(){y.forEach(I=>I.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:c,clearTrackEffects:l,getTrackEffectsFunction:m,createOfflineTrackEffectsFunction:b,availableEffects:At}}function yl(e,t={}){const{bitDepth:r=16}=t,n=e.numberOfChannels,a=e.sampleRate,s=e.length,o=r/8,i=n*o,c=a*i,l=s*i,u=44,m=u+l,b=new ArrayBuffer(m),d=new DataView(b);Lt(d,0,"RIFF"),d.setUint32(4,m-8,!0),Lt(d,8,"WAVE"),Lt(d,12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,r===32?3:1,!0),d.setUint16(22,n,!0),d.setUint32(24,a,!0),d.setUint32(28,c,!0),d.setUint16(32,i,!0),d.setUint16(34,r,!0),Lt(d,36,"data"),d.setUint32(40,l,!0);const h=[];for(let g=0;g<n;g++)h.push(e.getChannelData(g));let v=u;if(r===16)for(let g=0;g<s;g++)for(let p=0;p<n;p++){const C=h[p][g],y=Math.max(-1,Math.min(1,C)),w=y<0?y*32768:y*32767;d.setInt16(v,w,!0),v+=2}else for(let g=0;g<s;g++)for(let p=0;p<n;p++)d.setFloat32(v,h[p][g],!0),v+=4;return new Blob([b],{type:"audio/wav"})}function Lt(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))}function Cl(e,t){const r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}function Ga(){const[e,t]=f.useState(!1),[r,n]=f.useState(0),[a,s]=f.useState(null);return{exportWav:f.useCallback(async(i,c,l={})=>{const{filename:u="export",mode:m="master",trackIndex:b,autoDownload:d=!0,applyEffects:h=!0,effectsFunction:v,createOfflineTrackEffects:g,bitDepth:p=16,onProgress:C}=l;t(!0),n(0),s(null);try{if(i.length===0)throw new Error("No tracks to export");if(m==="individual"&&(b===void 0||b<0||b>=i.length))throw new Error("Invalid track index for individual export");const y=i[0].clips[0]?.sampleRate||44100;let w=0;for(const E of i)for(const T of E.clips){const R=T.startSample+T.durationSamples;w=Math.max(w,R)}w+=Math.round(y*.1);const I=w/y,S=m==="individual"?[{track:i[b],state:c[b],index:b}]:i.map((E,T)=>({track:E,state:c[T],index:T})),A=c.some(E=>E.soloed),k=!!g;let M;if((v||k)&&h)M=await wl(S,c,A,I,y,v,g,E=>{n(E),C?.(E)});else{const E=new OfflineAudioContext(2,w,y);let T=0;const R=S.reduce((D,{track:P})=>D+P.clips.length,0);for(const{track:D,state:P}of S)if(!(P.muted&&!P.soloed)&&!(A&&!P.soloed))for(const F of D.clips){await Il(E,F,P,y,h),T++;const G=T/R*.5;n(G),C?.(G)}n(.5),C?.(.5),M=await E.startRendering()}n(.9),C?.(.9);const _=yl(M,{bitDepth:p});if(n(1),C?.(1),d){const E=m==="individual"?`${u}_${i[b].name}`:u;Cl(_,`${E}.wav`)}return{audioBuffer:M,blob:_,duration:I}}catch(y){const w=y instanceof Error?y.message:"Export failed";throw s(w),y}finally{t(!1)}},[]),isExporting:e,progress:r,error:a}}async function wl(e,t,r,n,a,s,o,i){const{Offline:c,Volume:l,Gain:u,Panner:m,Player:b,ToneAudioBuffer:d}=await import("tone");i(.1);let h;try{h=await c(async({transport:v,destination:g})=>{const p=new l(0);let C;s?C=s(p,g,!0):p.connect(g);for(const{track:y,state:w}of e){if(w.muted&&!w.soloed||r&&!w.soloed)continue;const I=new l(xl(w.volume)),S=new m(w.pan),A=new u(w.muted?0:1),k=o?.(y.id);k?k(A,p,!0):A.connect(p),S.connect(A),I.connect(S);for(const M of y.clips){const{audioBuffer:_,startSample:E,durationSamples:T,offsetSamples:R,gain:D,fadeIn:P,fadeOut:F}=M,G=E/a,z=T/a,fe=R/a,q=new d(_),ee=new b(q),ye=new u(D);if(ee.connect(ye),ye.connect(I),P){const J=G,ve=G+P.duration,te=Ct(ye.gain);te&&(te.setValueAtTime(0,J),te.linearRampToValueAtTime(D,ve))}if(F){const J=G+z-F.duration,ve=G+z,te=Ct(ye.gain);te&&(te.setValueAtTime(D,J),te.linearRampToValueAtTime(0,ve))}ee.start(G,fe,z)}}v.start(0)},n,2,a)}catch(v){throw v instanceof Error?v:new Error(`Tone.Offline rendering failed: ${String(v)}`)}return i(.9),h.get()}function xl(e){return 20*Math.log10(Math.max(e,1e-4))}async function Il(e,t,r,n,a){const{audioBuffer:s,startSample:o,durationSamples:i,offsetSamples:c,gain:l,fadeIn:u,fadeOut:m}=t;if(!s){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const b=o/n,d=i/n,h=c/n,v=e.createBufferSource();v.buffer=s;const g=e.createGain(),p=l*r.volume,C=e.createStereoPanner();if(C.pan.value=r.pan,v.connect(g),g.connect(C),C.connect(e.destination),a){if(u?g.gain.setValueAtTime(0,b):g.gain.setValueAtTime(p,b),u){const y=b,w=b+u.duration;Hr(g.gain,y,w,0,p,u.type||"linear")}if(m){const y=b+d-m.duration,w=b+d;(!u||u.duration<d-m.duration)&&g.gain.setValueAtTime(p,y),Hr(g.gain,y,w,p,0,m.type||"linear")}}else g.gain.setValueAtTime(p,b);v.start(b,h,d)}function Hr(e,t,r,n,a,s){const o=r-t;if(!(o<=0))switch(s){case"linear":e.setValueAtTime(n,t),e.linearRampToValueAtTime(a,r);break;case"exponential":{const i=Math.max(n,1e-4),c=Math.max(a,1e-4);e.setValueAtTime(i,t),e.exponentialRampToValueAtTime(c,r),a===0&&e.setValueAtTime(0,r);break}case"logarithmic":{const i=jr(n,a,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=jr(n,a,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(n,t),e.linearRampToValueAtTime(a,r)}}function jr(e,t,r,n){const a=new Float32Array(r),s=t-e;for(let o=0;o<r;o++){const i=o/(r-1);let c;n==="logarithmic"?s>0?c=Math.log10(1+i*9)/Math.log10(10):c=1-Math.log10(1+(1-i)*9)/Math.log10(10):c=i*i*(3-2*i),a[o]=e+s*c}return a}const Wa=()=>{const e=f.useRef(null),t=f.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),r=f.useCallback(n=>{t(),e.current=requestAnimationFrame(n)},[t]);return f.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:r,stopAnimationFrameLoop:t}},Sl=`
|
|
909
844
|
"use strict";
|
|
910
845
|
|
|
911
846
|
var INT8_MAX = 127;
|
|
@@ -1052,13 +987,13 @@ self.onmessage = function(e) {
|
|
|
1052
987
|
self.postMessage({ id: msg.id, error: err.message || String(err) });
|
|
1053
988
|
}
|
|
1054
989
|
};
|
|
1055
|
-
`;let ky=0;function Iy(){let e;try{const r=new Blob([Sy],{type:"application/javascript"}),s=URL.createObjectURL(r);e=new Worker(s),URL.revokeObjectURL(s)}catch(r){return console.warn("[waveform-playlist] Failed to create peaks worker (CSP restriction?):",r),{generate(){return Promise.reject(new Error("Worker creation failed"))},terminate(){}}}const t=new Map;let n=!1;return e.onmessage=r=>{const s=r.data,o=t.get(s.id);if(o)if(t.delete(s.id),s.error)o.reject(new Error(s.error));else try{const a=Ct.create(s.buffer);o.resolve(a)}catch(a){o.reject(a)}},e.onerror=r=>{n=!0,e.terminate();for(const[,s]of t)s.reject(r.error??new Error(r.message));t.clear()},{generate(r){if(n)return Promise.reject(new Error("Worker terminated"));const s=String(++ky);return new Promise((o,a)=>{t.set(s,{resolve:o,reject:a}),e.postMessage({id:s,scale:r.scale,bits:r.bits,amplitude_scale:1,split_channels:r.splitChannels,length:r.length,sample_rate:r.sampleRate,channels:r.channels},r.channels)})},terminate(){n=!0,e.terminate();for(const[,r]of t)r.reject(new Error("Worker terminated"));t.clear()}}}function Ay(e,t){const[n,r]=m.useState(()=>new Map),[s,o]=m.useState(!1),a=m.useRef(null),i=m.useRef(new WeakMap),l=m.useRef(new WeakMap),c=m.useRef(new WeakMap),u=m.useRef(0),f=m.useCallback(()=>(a.current||(a.current=Iy()),a.current),[]);return m.useEffect(()=>{let p=!1;const d=i.current,h=l.current,g=c.current,y=[],v=new Map;for(const w of e)for(const C of w.clips){if(!C.audioBuffer||C.waveformData)continue;const _=d.get(C.audioBuffer);if(_){y.push({clipId:C.id,waveformData:_});continue}if(h.get(C.audioBuffer)){const k=g.get(C.audioBuffer);k?k.add(C.id):g.set(C.audioBuffer,new Set([C.id]));continue}const S=v.get(C.audioBuffer);S?S.add(C.id):v.set(C.audioBuffer,new Set([C.id]))}if(y.length>0&&r(w=>{const C=new Map(w);for(const _ of y)C.set(_.clipId,_.waveformData);return C}),v.size===0)return;u.current+=v.size,o(!0);const b=f();for(const[w,C]of v){g.set(w,new Set(C));const _=[];for(let I=0;I<w.numberOfChannels;I++)_.push(w.getChannelData(I).slice().buffer);const S=`buffer-${Math.random().toString(36).slice(2,11)}`,k=b.generate({id:S,channels:_,length:w.length,sampleRate:w.sampleRate,scale:t,bits:16,splitChannels:!0}).then(I=>{d.set(w,I);const E=g.get(w)??new Set;g.delete(w),h.delete(w),!p&&(r(A=>{const R=new Map(A);for(const T of E)R.set(T,I);return R}),u.current--,u.current<=0&&(u.current=0,o(!1)))}).catch(I=>{g.delete(w),h.delete(w),!p&&(console.warn("[waveform-playlist] Worker peak generation failed:",I),u.current--,u.current<=0&&(u.current=0,o(!1)))});h.set(w,k)}return()=>{p=!0,l.current=new WeakMap,c.current=new WeakMap,u.current=0,o(!1)}},[e,t,f]),m.useEffect(()=>()=>{a.current?.terminate(),a.current=null},[]),{cache:n,isGenerating:s}}function wa(e){return e instanceof File?e.name.replace(/\.[^/.]+$/,""):e instanceof Blob?"Untitled":typeof e=="string"?e.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled":e.name??e.src.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled"}async function Ey(e,t,n){const r=wa(e);if(e instanceof Blob){const l=await e.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(l),name:r}}const s=typeof e=="string"?e:e.src,o=await fetch(s,{signal:n});if(!o.ok)throw new Error(`Failed to fetch ${s}: ${o.statusText}`);const a=await o.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(a),name:r}}function My(){const[e,t]=m.useState([]),[n,r]=m.useState(0),[s,o]=m.useState([]),a=m.useRef(!1),i=m.useRef(new Set),l=m.useRef(new Map);m.useEffect(()=>{const f=l.current;return()=>{a.current=!0;for(const p of f.values())p.abort();f.clear()}},[]);const c=m.useCallback(f=>{if(f.length===0)return;const p=Th(),d=f.map(h=>({track:kc({name:`${wa(h)} (loading...)`,clips:[]}),source:h}));t(h=>[...h,...d.map(g=>g.track)]),r(h=>h+f.length);for(const{track:h,source:g}of d){i.current.add(h.id);const y=new AbortController;l.current.set(h.id,y),(async()=>{try{const{audioBuffer:v,name:b}=await Ey(g,p,y.signal),w=Sc({audioBuffer:v,startTime:0,duration:v.duration,offset:0,name:b});!a.current&&i.current.has(h.id)&&t(C=>C.map(_=>_.id===h.id?{..._,name:b,clips:[w]}:_))}catch(v){if(v instanceof DOMException&&v.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",v),!a.current&&i.current.has(h.id)&&(t(b=>b.filter(w=>w.id!==h.id)),o(b=>[...b,{name:wa(g),error:v instanceof Error?v:new Error(String(v))}]))}finally{l.current.delete(h.id),!a.current&&i.current.delete(h.id)&&r(v=>v-1)}})()}},[]),u=m.useCallback(f=>{t(d=>d.filter(h=>h.id!==f));const p=l.current.get(f);p&&(p.abort(),l.current.delete(f)),i.current.delete(f)&&r(d=>d-1)},[]);return{tracks:e,addTracks:c,removeTrack:u,loadingCount:n,isLoading:n>0,errors:s}}var Ty=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvbWV0ZXItcHJvY2Vzc29yLndvcmtsZXQudHMKdmFyIE1ldGVyUHJvY2Vzc29yID0gY2xhc3MgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIGNvbnN0cnVjdG9yKG9wdGlvbnMpIHsKICAgIHN1cGVyKCk7CiAgICBjb25zdCB7IG51bWJlck9mQ2hhbm5lbHMsIHVwZGF0ZVJhdGUgfSA9IG9wdGlvbnMucHJvY2Vzc29yT3B0aW9uczsKICAgIHRoaXMubnVtYmVyT2ZDaGFubmVscyA9IG51bWJlck9mQ2hhbm5lbHM7CiAgICB0aGlzLmJsb2Nrc1BlclVwZGF0ZSA9IE1hdGgubWF4KDEsIE1hdGguZmxvb3Ioc2FtcGxlUmF0ZSAvICgxMjggKiB1cGRhdGVSYXRlKSkpOwogICAgdGhpcy5ibG9ja3NQcm9jZXNzZWQgPSAwOwogICAgdGhpcy5tYXhQZWFrID0gbmV3IEFycmF5KG51bWJlck9mQ2hhbm5lbHMpLmZpbGwoMCk7CiAgICB0aGlzLnN1bVNxdWFyZXMgPSBuZXcgQXJyYXkobnVtYmVyT2ZDaGFubmVscykuZmlsbCgwKTsKICAgIHRoaXMuc2FtcGxlQ291bnQgPSBuZXcgQXJyYXkobnVtYmVyT2ZDaGFubmVscykuZmlsbCgwKTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIF9wYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBpZiAoIWlucHV0IHx8IGlucHV0Lmxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGZvciAobGV0IGNoID0gMDsgY2ggPCBvdXRwdXQubGVuZ3RoOyBjaCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoXTsKICAgICAgY29uc3Qgb3V0cHV0Q2hhbm5lbCA9IG91dHB1dFtjaF07CiAgICAgIGlmIChpbnB1dENoYW5uZWwgJiYgb3V0cHV0Q2hhbm5lbCkgewogICAgICAgIG91dHB1dENoYW5uZWwuc2V0KGlucHV0Q2hhbm5lbCk7CiAgICAgIH0KICAgIH0KICAgIGZvciAobGV0IGNoID0gMDsgY2ggPCB0aGlzLm51bWJlck9mQ2hhbm5lbHM7IGNoKyspIHsKICAgICAgY29uc3QgaW5wdXRDaGFubmVsID0gaW5wdXRbY2hdOwogICAgICBpZiAoIWlucHV0Q2hhbm5lbCkgY29udGludWU7CiAgICAgIGxldCBwZWFrID0gdGhpcy5tYXhQZWFrW2NoXTsKICAgICAgbGV0IHN1bSA9IHRoaXMuc3VtU3F1YXJlc1tjaF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaW5wdXRDaGFubmVsLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgY29uc3Qgc2FtcGxlID0gaW5wdXRDaGFubmVsW2ldOwogICAgICAgIGNvbnN0IGFicyA9IE1hdGguYWJzKHNhbXBsZSk7CiAgICAgICAgaWYgKGFicyA+IHBlYWspIHBlYWsgPSBhYnM7CiAgICAgICAgc3VtICs9IHNhbXBsZSAqIHNhbXBsZTsKICAgICAgfQogICAgICB0aGlzLm1heFBlYWtbY2hdID0gcGVhazsKICAgICAgdGhpcy5zdW1TcXVhcmVzW2NoXSA9IHN1bTsKICAgICAgdGhpcy5zYW1wbGVDb3VudFtjaF0gKz0gaW5wdXRDaGFubmVsLmxlbmd0aDsKICAgIH0KICAgIHRoaXMuYmxvY2tzUHJvY2Vzc2VkKys7CiAgICBpZiAodGhpcy5ibG9ja3NQcm9jZXNzZWQgPj0gdGhpcy5ibG9ja3NQZXJVcGRhdGUpIHsKICAgICAgY29uc3QgcGVhayA9IFtdOwogICAgICBjb25zdCBybXMgPSBbXTsKICAgICAgZm9yIChsZXQgY2ggPSAwOyBjaCA8IHRoaXMubnVtYmVyT2ZDaGFubmVsczsgY2grKykgewogICAgICAgIHBlYWsucHVzaCh0aGlzLm1heFBlYWtbY2hdKTsKICAgICAgICBjb25zdCBjb3VudCA9IHRoaXMuc2FtcGxlQ291bnRbY2hdOwogICAgICAgIHJtcy5wdXNoKGNvdW50ID4gMCA/IE1hdGguc3FydCh0aGlzLnN1bVNxdWFyZXNbY2hdIC8gY291bnQpIDogMCk7CiAgICAgIH0KICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsgcGVhaywgcm1zIH0pOwogICAgICB0aGlzLm1heFBlYWsuZmlsbCgwKTsKICAgICAgdGhpcy5zdW1TcXVhcmVzLmZpbGwoMCk7CiAgICAgIHRoaXMuc2FtcGxlQ291bnQuZmlsbCgwKTsKICAgICAgdGhpcy5ibG9ja3NQcm9jZXNzZWQgPSAwOwogICAgfQogICAgcmV0dXJuIHRydWU7CiAgfQp9OwpyZWdpc3RlclByb2Nlc3NvcigibWV0ZXItcHJvY2Vzc29yIiwgTWV0ZXJQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1tZXRlci1wcm9jZXNzb3Iud29ya2xldC5qcy5tYXA=",typeof document>"u"?require("url").pathToFileURL(__filename).href:On&&On.tagName.toUpperCase()==="SCRIPT"&&On.src||new URL("index.js",document.baseURI).href).href;new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIF9vdXRwdXRzLCBfcGFyYW1ldGVycykgewogICAgaWYgKCF0aGlzLmlzUmVjb3JkaW5nKSB7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgY29uc3QgaW5wdXQgPSBpbnB1dHNbMF07CiAgICBpZiAoIWlucHV0IHx8IGlucHV0Lmxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGZyYW1lQ291bnQgPSBpbnB1dFswXS5sZW5ndGg7CiAgICBpZiAodGhpcy5idWZmZXJTaXplIDw9IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBsZXQgb2Zmc2V0ID0gMDsKICAgIHdoaWxlIChvZmZzZXQgPCBmcmFtZUNvdW50KSB7CiAgICAgIGNvbnN0IHJlbWFpbmluZyA9IHRoaXMuYnVmZmVyU2l6ZSAtIHRoaXMuc2FtcGxlc0NvbGxlY3RlZDsKICAgICAgY29uc3QgdG9Db3B5ID0gTWF0aC5taW4ocmVtYWluaW5nLCBmcmFtZUNvdW50IC0gb2Zmc2V0KTsKICAgICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgICAgY29uc3QgaW5wdXRDaGFubmVsID0gaW5wdXRbY2hhbm5lbF07CiAgICAgICAgY29uc3QgYnVmZmVyID0gdGhpcy5idWZmZXJzW2NoYW5uZWxdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdG9Db3B5OyBpKyspIHsKICAgICAgICAgIGJ1ZmZlclt0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKyBpXSA9IGlucHV0Q2hhbm5lbFtvZmZzZXQgKyBpXTsKICAgICAgICB9CiAgICAgIH0KICAgICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkICs9IHRvQ29weTsKICAgICAgb2Zmc2V0ICs9IHRvQ29weTsKICAgICAgaWYgKHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA+PSB0aGlzLmJ1ZmZlclNpemUpIHsKICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3QgY2hhbm5lbHMgPSBbXTsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5jaGFubmVsQ291bnQ7IGkrKykgewogICAgICBjaGFubmVscy5wdXNoKHRoaXMuYnVmZmVyc1tpXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpKTsKICAgIH0KICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgIGNoYW5uZWxzLAogICAgICBzYW1wbGVSYXRlLAogICAgICBjaGFubmVsQ291bnQ6IHRoaXMuY2hhbm5lbENvdW50CiAgICB9KTsKICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgfQp9OwpyZWdpc3RlclByb2Nlc3NvcigicmVjb3JkaW5nLXByb2Nlc3NvciIsIFJlY29yZGluZ1Byb2Nlc3Nvcik7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXJlY29yZGluZy1wcm9jZXNzb3Iud29ya2xldC5qcy5tYXA=",typeof document>"u"?require("url").pathToFileURL(__filename).href:On&&On.tagName.toUpperCase()==="SCRIPT"&&On.src||new URL("index.js",document.baseURI).href).href;const Ry=.98;function $y(e={}){const{channelCount:t=2,updateRate:n=60,isPlaying:r=!1}=e,[s,o]=m.useState(()=>new Array(t).fill(0)),[a,i]=m.useState(()=>new Array(t).fill(0)),[l,c]=m.useState(()=>new Array(t).fill(0)),u=m.useRef(null),f=m.useRef(new Array(t).fill(0)),[p,d]=m.useState(null),h=m.useCallback(()=>i(new Array(t).fill(0)),[t]);return m.useEffect(()=>{if(!r){const g=new Array(t).fill(0);f.current=new Array(t).fill(0),o(g),c(g),i(g)}},[r,t]),m.useEffect(()=>{let g=!0;return(async()=>{const v=ks();if(await v.rawContext.audioWorklet.addModule(Ty),!g)return;const w=v.createAudioWorkletNode("meter-processor",{channelCount:t,channelCountMode:"explicit",processorOptions:{numberOfChannels:t,updateRate:n}});u.current=w,w.onprocessorerror=_=>{console.warn("[waveform-playlist] Output meter worklet processor error:",String(_))},v.destination.chain(w),f.current=new Array(t).fill(0),w.port.onmessage=_=>{if(!g)return;const{peak:S,rms:k}=_.data,I=f.current,E=[],A=[];for(let R=0;R<S.length;R++)I[R]=Math.max(S[R],(I[R]??0)*Ry),E.push(Cl(I[R])),A.push(Cl(k[R]));o(E),c(A),i(R=>E.map((T,M)=>Math.max(R[M]??0,T)))}})().catch(v=>{console.warn("[waveform-playlist] Failed to set up output meter:",String(v)),g&&d(v instanceof Error?v:new Error(String(v)))}),()=>{if(g=!1,u.current){try{ks().destination.chain()}catch(v){console.warn("[waveform-playlist] Failed to restore destination chain:",String(v))}try{u.current.disconnect(),u.current.port.close()}catch(v){console.warn("[waveform-playlist] Output meter disconnect during cleanup:",String(v))}u.current=null}}},[t,n]),{levels:s,peakLevels:a,rmsLevels:l,resetPeak:h,error:p}}const Ef=m.createContext(null),Mf=m.createContext(null),Tf=m.createContext(null),Rf=m.createContext(null),Dy=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:s=1024,zoomLevels:o,automaticScroll:a=!1,theme:i,controls:l={show:!1,width:0},annotationList:c,effects:u,onReady:f,onAnnotationUpdate:p,onAnnotationsChange:d,barWidth:h=1,barGap:g=0,progressBarWidth:y,onTracksChange:v,soundFontCache:b,deferEngineRebuild:w=!1,indefinitePlayback:C=!1,children:_})=>{const S=y??h+g,k=m.useRef(C);k.current=C;const I=m.useMemo(()=>o,[o?.join(",")]),E=m.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const L=c.annotations[0];if(typeof L.start!="number"||typeof L.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof L.start),[]}return c.annotations},[c?.annotations]),A=m.useRef(E);A.current=E;const[R,T]=m.useState(null),[M,$]=m.useState(!1),[O,P]=m.useState(0),[V,Y]=m.useState(0),[K,fe]=m.useState([]),[pe,Ce]=m.useState([]),[X,Se]=m.useState([]),[te,qe]=m.useState(a),[J,Z]=m.useState(c?.isContinuousPlay??!1),[he,De]=m.useState(c?.linkEndpoints??!1),[se,Me]=m.useState(c?.editable??!1),[Be,ze]=m.useState(!1),N=m.useRef(null),Q=m.useRef(!1),Je=m.useRef(!1);Je.current=M;const je=m.useRef(0),ie=m.useRef(0),pt=m.useRef(e),Mt=m.useRef(b);Mt.current=b;const lt=m.useRef(X),et=m.useRef(0),mt=m.useRef(0),gt=m.useRef(null),ct=m.useRef(null),j=m.useRef(!1),ue=m.useRef(c?.isContinuousPlay??!1),He=m.useRef(null),Fe=m.useRef(null),ne=m.useRef(0),ge=m.useRef(!1),We=m.useRef(!1),vt=m.useRef([]),yt=m.useRef(s),G=m.useRef(44100),{timeFormat:H,setTimeFormat:U,formatTime:oe}=vf(),ae=yf({engineRef:N,initialSamplesPerPixel:s}),{samplesPerPixel:Ie,onEngineState:q}=ae,Ve=bf({engineRef:N,initialVolume:1}),{masterVolume:Xe,setMasterVolume:Ze,masterVolumeRef:Tt,onEngineState:zt}=Ve,{selectionStart:kn,selectionEnd:nn,setSelection:Bi,selectionStartRef:Yr,selectionEndRef:Ur,onEngineState:Wi}=ny({engineRef:N}),{isLoopEnabled:Li,loopStart:Vi,loopEnd:Ni,setLoopEnabled:Zi,setLoopRegion:Kr,clearLoopRegion:Gi,isLoopEnabledRef:zi,loopStartRef:ji,loopEndRef:Hi,onEngineState:Xi}=ry({engineRef:N}),{selectedTrackId:Yi,setSelectedTrackId:Ui,onEngineState:Ki,selectedTrackIdRef:Qi}=sy({engineRef:N}),{animationFrameRef:qi,startAnimationFrameLoop:co,stopAnimationFrameLoop:Qr}=Af(),rh=m.useMemo(()=>Math.min(...I??[256,512,1024,2048,4096,8192]),[I]),{cache:Ji}=Ay(e,rh),el=m.useCallback(L=>{ue.current=L,Z(L)},[]),Bt=m.useCallback(L=>{He.current=L,T(L)},[]),tl=m.useCallback(()=>{const L=Yr.current??0,z=Ur.current??0;L!==z&&z>L&&Kr(L,z)},[Kr,Yr,Ur]);m.useEffect(()=>{j.current=te},[te]),m.useEffect(()=>{lt.current=X},[X]),pt.current=e;const uo=e===Fe.current,qr=vt.current,nl=N.current!==null&&qr.length>0&&e.length>qr.length&&qr.every(L=>e.find(le=>le.id===L.id)===L);ge.current=uo||We.current||nl,m.useEffect(()=>{if(!ct.current||V===0)return;const L=ct.current,z=yt.current,le=Ie;if(z===le)return;const W=L.clientWidth,_e=L.scrollLeft+W/2,ye=G.current,Te=_e*z/ye*ye/le,Ye=Math.max(0,Te-W/2);L.scrollLeft=Ye,yt.current=le},[Ie,V]);const Jr=m.useRef(null);m.useEffect(()=>{if(uo||We.current){uo&&(Fe.current=null);let W=0;e.forEach(ve=>{ve.clips.forEach(_e=>{const ye=(_e.startSample+_e.durationSamples)/_e.sampleRate;W=Math.max(W,ye)})}),Y(W),vt.current=e;return}if(nl&&N.current)try{const W=new Set(qr.map(Te=>Te.id)),ve=e.filter(Te=>!W.has(Te.id)),_e=lt.current;for(const Te of ve){const Ye=e.indexOf(Te),ut=_e[Ye],Ae={...Te,volume:ut?.volume??Te.volume,muted:ut?.muted??Te.muted,soloed:ut?.soloed??Te.soloed,pan:ut?.pan??Te.pan};N.current.addTrack(Ae)}let ye=0;e.forEach(Te=>{Te.clips.forEach(Ye=>{const ut=(Ye.startSample+Ye.durationSamples)/Ye.sampleRate;ye=Math.max(ye,ut)})}),Y(ye),Se(Te=>{if(Te.length===e.length)return Te;const Ye=[...Te];for(const ut of ve)Ye.push({name:ut.name,muted:ut.muted,soloed:ut.soloed,volume:ut.volume,pan:ut.pan});return Ye});const sn=[];e.forEach(Te=>{Te.clips.forEach(Ye=>{Ye.audioBuffer&&sn.push(Ye.audioBuffer)})}),fe(sn),vt.current=e;return}catch(W){console.warn("[waveform-playlist] Incremental add failed, falling through to full rebuild:",String(W))}if(w){let W=0;e.forEach(ve=>{ve.clips.forEach(_e=>{const ye=(_e.startSample+_e.durationSamples)/_e.sampleRate;W=Math.max(W,ye)})}),Y(W);return}if(ze(!1),e.length===0){fe([]),Y(0),Se([]),Ce([]),N.current&&(N.current.dispose(),N.current=null),vt.current=e;return}const L=Je.current,z=ie.current;return N.current&&L&&(N.current.stop(),Qr(),Jr.current={position:z}),(async()=>{try{const W=[];e.forEach(Ae=>{Ae.clips.forEach(Ue=>{Ue.audioBuffer&&W.push(Ue.audioBuffer)})});let ve=0;e.forEach(Ae=>{Ae.clips.forEach(Ue=>{const jt=Ue.sampleRate,ch=(Ue.startSample+Ue.durationSamples)/jt;ve=Math.max(ve,ch)})}),fe(W),Y(ve),Se(Ae=>Ae.length===e.length?Ae.map((Ue,jt)=>({...Ue,name:e[jt].name})):e.map(Ue=>({name:Ue.name,muted:Ue.muted,soloed:Ue.soloed,volume:Ue.volume,pan:Ue.pan}))),N.current&&N.current.dispose(),ne.current=0,Fe.current=null,Q.current=!1;const _e=Rh({effects:u,soundFontCache:Mt.current}),ye=new Wh({adapter:_e,samplesPerPixel:yt.current,zoomLevels:I});ye.setSelection(Yr.current??0,Ur.current??0),ye.setLoopRegion(ji.current??0,Hi.current??0),zi.current&&ye.setLoopEnabled(!0),ye.setMasterVolume(Tt.current??1),Qi.current&&ye.selectTrack(Qi.current);const sn=lt.current,Te=e.map((Ae,Ue)=>{const jt=sn[Ue];return{...Ae,volume:jt?.volume??Ae.volume,muted:jt?.muted??Ae.muted,soloed:jt?.soloed??Ae.soloed,pan:jt?.pan??Ae.pan}});let Ye=!0;ye.on("statechange",Ae=>{Wi(Ae),Xi(Ae),Ki(Ae),q(Ae),zt(Ae),!Ye&&Ae.tracksVersion!==ne.current&&(ne.current=Ae.tracksVersion,Fe.current=Ae.tracks,v?v(Ae.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),ye.setTracks(Te),Ye=!1,ne.current=ye.getState().tracksVersion,N.current=ye,ze(!0);const ut=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:ve}});window.dispatchEvent(ut),vt.current=e,f?.()}catch(W){console.warn("[waveform-playlist] Error loading audio:",String(W))}})(),()=>{if(ge.current){ge.current=!1;return}Qr(),N.current&&N.current.dispose()}},[e,f,u,Qr,Wi,Xi,Ki,q,zt,v,Tt,Yr,Ur,ji,Hi,zi,I,b,w]),m.useEffect(()=>{if(e.length===0)return;const L=e.map(z=>z.clips.map(W=>{let ve;if(W.waveformData)try{ve=hc(W.waveformData,Ie,n,W.offsetSamples,W.durationSamples)}catch(_e){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",_e)}if(!ve){const _e=Ji.get(W.id);if(_e)try{ve=hc(_e,Ie,n,W.offsetSamples,W.durationSamples)}catch(ye){console.warn("[waveform-playlist] Failed to extract peaks from cache:",ye)}}if(!ve){!w&&!W.audioBuffer&&!W.waveformData&&!W.midiNotes&&console.warn(`[waveform-playlist] Clip "${W.id}" has no audio data or waveform data`);const _e=n?1:W.audioBuffer?.numberOfChannels??1,ye=W.midiNotes?Math.ceil(W.durationSamples/Ie):0;ve={length:ye,data:Array.from({length:_e},()=>new Int16Array(ye*2)),bits:16}}return{clipId:W.id,trackName:z.name,peaks:ve,startSample:W.startSample,durationSamples:W.durationSamples,fadeIn:W.fadeIn,fadeOut:W.fadeOut,midiNotes:W.midiNotes,sampleRate:W.sampleRate,offsetSamples:W.offsetSamples}}));Ce(L)},[e,Ie,n,Ji,w]);const rl=m.useRef(!1),In=m.useCallback(()=>{if(N.current)return N.current.getCurrentTime();rl.current||(rl.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const L=B.getContext().currentTime-(et.current??0);return(mt.current??0)+L},[]),rn=m.useCallback(()=>{const L=()=>{const z=In();ie.current=z;const le=A.current;if(le.length>0){const W=le.find(ve=>z>=ve.start&&z<ve.end);if(ue.current)W&&W.id!==He.current?Bt(W.id):!W&&He.current!==null&&Bt(null);else if(He.current){const ve=le.find(_e=>_e.id===He.current);if(ve&&z>=ve.end){N.current&&N.current.stop(),$(!1),ie.current=je.current,P(je.current);return}}else W&&Bt(W.id)}if(j.current&&ct.current&&V>0){const W=ct.current,ve=G.current,_e=z*ve/yt.current,ye=W.clientWidth,sn=Math.max(0,_e-ye/2);W.scrollLeft=sn}if(gt.current!==null&&z>=gt.current){N.current&&N.current.stop(),$(!1),ie.current=gt.current,P(gt.current),gt.current=null;return}if(z>=V&&!k.current){N.current&&N.current.stop(),$(!1),ie.current=je.current,P(je.current),Bt(null);return}co(L)};co(L)},[V,Bt,co,In]),bt=Qr;m.useEffect(()=>{(async()=>{if(M&&qi.current&&N.current)if(J){const z=ie.current;N.current.stop(),bt();const W=B.getContext().currentTime;et.current=W,mt.current=z,N.current.play(z),rn()}else bt(),rn()})().catch(z=>{console.warn("[waveform-playlist] Failed to reschedule playback:",z),$(!1),bt()})},[J,M,rn,bt,qi]),m.useEffect(()=>{(async()=>{if(Jr.current&&N.current){const{position:z}=Jr.current;Jr.current=null;const W=B.getContext().currentTime;et.current=W,mt.current=z,Q.current||(await N.current.init(),Q.current=!0),N.current.play(z),$(!0),rn()}})().catch(z=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",z),$(!1),bt()})},[e,rn,bt]);const es=m.useCallback(async(L,z)=>{if(!N.current||V===0)return;const le=L??ie.current;je.current=le,ie.current=le,N.current.stop(),N.current.seek(le),bt();const ve=B.getContext().currentTime;et.current=ve,mt.current=le,gt.current=z!==void 0?le+z:null,Q.current||(await N.current.init(),Q.current=!0);const _e=z!==void 0?le+z:void 0;try{N.current.play(le,_e)}catch(ye){console.warn("[waveform-playlist] Playback failed to start:",ye),bt();return}$(!0),rn()},[V,rn,bt]),sl=m.useCallback(()=>{if(!N.current)return;const L=In();N.current.pause(),$(!1),bt(),ie.current=L,P(L)},[bt,In]),ol=m.useCallback(()=>{N.current&&(N.current.stop(),$(!1),bt(),ie.current=je.current,P(je.current),Bt(null))},[bt,Bt]),al=m.useCallback(L=>{const z=Math.max(0,Math.min(L,V));ie.current=z,P(z),M&&N.current&&es(z)},[V,M,es]),il=m.useCallback((L,z)=>{const le=pt.current[L]?.id;if(!le)return;const W=[...X];W[L]={...W[L],muted:z},Se(W),N.current&&N.current.setTrackMute(le,z)},[X]),ll=m.useCallback((L,z)=>{const le=pt.current[L]?.id;if(!le)return;const W=[...X];W[L]={...W[L],soloed:z},Se(W),N.current&&N.current.setTrackSolo(le,z)},[X]),cl=m.useCallback((L,z)=>{const le=pt.current[L]?.id;if(!le)return;const W=[...X];W[L]={...W[L],volume:z},Se(W),N.current&&N.current.setTrackVolume(le,z)},[X]),ul=m.useCallback((L,z)=>{const le=pt.current[L]?.id;if(!le)return;const W=[...X];W[L]={...W[L],pan:z},Se(W),N.current&&N.current.setTrackPan(le,z)},[X]),dl=m.useCallback((L,z)=>{Bi(L,z),ie.current=L,P(L),M&&N.current&&(N.current.stop(),N.current.seek(L),N.current.play(L))},[M,Bi]),fl=m.useCallback(L=>{ct.current=L},[]),fo=m.useRef(d);fo.current=d;const hl=m.useCallback(L=>{const z=typeof L=="function"?L(A.current):L;if(!fo.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to WaveformPlaylistProvider to handle annotation updates.");return}fo.current(z)},[]),ho=K[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;G.current=ho;const po=t?30:0,pl=e.length*r+po,sh=m.useMemo(()=>({isPlaying:M,currentTime:O,currentTimeRef:ie,playbackStartTimeRef:et,audioStartPositionRef:mt,getPlaybackTime:In}),[M,O,ie,et,mt,In]),oh=m.useMemo(()=>({continuousPlay:J,linkEndpoints:he,annotationsEditable:se,isAutomaticScroll:te,isLoopEnabled:Li,annotations:E,activeAnnotationId:R,selectionStart:kn,selectionEnd:nn,selectedTrackId:Yi,loopStart:Vi,loopEnd:Ni,indefinitePlayback:C}),[J,he,se,te,Li,E,R,kn,nn,Yi,Vi,Ni,C]),ml=m.useCallback(L=>{ie.current=L,P(L)},[ie]),gl=m.useCallback(L=>{qe(L)},[]),ah=m.useMemo(()=>({play:es,pause:sl,stop:ol,seekTo:al,setCurrentTime:ml,setTrackMute:il,setTrackSolo:ll,setTrackVolume:cl,setTrackPan:ul,setSelection:dl,setSelectedTrackId:Ui,setTimeFormat:U,formatTime:oe,zoomIn:ae.zoomIn,zoomOut:ae.zoomOut,setMasterVolume:Ze,setAutomaticScroll:gl,setScrollContainer:fl,scrollContainerRef:ct,setContinuousPlay:el,setLinkEndpoints:De,setAnnotationsEditable:Me,setAnnotations:hl,setActiveAnnotationId:Bt,setLoopEnabled:Zi,setLoopRegion:Kr,setLoopRegionFromSelection:tl,clearLoopRegion:Gi}),[es,sl,ol,al,ml,il,ll,cl,ul,dl,Ui,U,oe,ae.zoomIn,ae.zoomOut,Ze,gl,fl,ct,el,De,Me,hl,Bt,Zi,Kr,tl,Gi]),ih=m.useMemo(()=>({duration:V,audioBuffers:K,peaksDataArray:pe,trackStates:X,tracks:e,sampleRate:ho,waveHeight:r,timeScaleHeight:po,minimumPlaylistHeight:pl,controls:l,playoutRef:N,samplesPerPixel:Ie,timeFormat:H,masterVolume:Xe,canZoomIn:ae.canZoomIn,canZoomOut:ae.canZoomOut,barWidth:h,barGap:g,progressBarWidth:S,isReady:Be,mono:n,isDraggingRef:We,onTracksChange:v}),[V,K,pe,X,e,ho,r,po,pl,l,N,Ie,H,Xe,ae.canZoomIn,ae.canZoomOut,h,g,S,Be,n,We,v]),lh={...Jd,...i};return x.jsx(D.ThemeProvider,{theme:lh,children:x.jsx(Ef.Provider,{value:sh,children:x.jsx(Mf.Provider,{value:oh,children:x.jsx(Tf.Provider,{value:ah,children:x.jsx(Rf.Provider,{value:ih,children:_})})})})})},ot=()=>{const e=m.useContext(Ef);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},at=()=>{const e=m.useContext(Mf);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},ke=()=>{const e=m.useContext(Tf);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},it=()=>{const e=m.useContext(Rf);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var Py=class{constructor(e){this._playbackRate=1,this.handleEnded=()=>{this.onStopCallback&&this.onStopCallback()},this.handleTimeUpdate=()=>{this.onTimeUpdateCallback&&this.onTimeUpdateCallback(this.audioElement.currentTime)},this._peaks=e.peaks,this._id=e.id??`track-${Date.now()}`,this._name=e.name??"Track",this._playbackRate=e.playbackRate??1,typeof e.source=="string"?(this.audioElement=new Audio(e.source),this.ownsElement=!0):(this.audioElement=e.source,this.ownsElement=!1),this.audioElement.preload="auto",this.audioElement.volume=e.volume??1,this.audioElement.playbackRate=this._playbackRate;const t=this.audioElement;"preservesPitch"in this.audioElement?t.preservesPitch=!0:"mozPreservesPitch"in this.audioElement?t.mozPreservesPitch=!0:"webkitPreservesPitch"in this.audioElement&&(t.webkitPreservesPitch=!0),this.audioElement.addEventListener("ended",this.handleEnded),this.audioElement.addEventListener("timeupdate",this.handleTimeUpdate)}play(e=0){this.audioElement.currentTime=e,this.audioElement.play().catch(t=>{console.warn("MediaElementTrack: play() failed:",t)})}pause(){this.audioElement.pause()}stop(){this.audioElement.pause(),this.audioElement.currentTime=0}seekTo(e){this.audioElement.currentTime=Math.max(0,Math.min(e,this.duration))}setVolume(e){this.audioElement.volume=Math.max(0,Math.min(1,e))}setPlaybackRate(e){const t=Math.max(.5,Math.min(2,e));this._playbackRate=t,this.audioElement.playbackRate=t}setMuted(e){this.audioElement.muted=e}setOnStopCallback(e){this.onStopCallback=e}setOnTimeUpdateCallback(e){this.onTimeUpdateCallback=e}dispose(){this.audioElement.removeEventListener("ended",this.handleEnded),this.audioElement.removeEventListener("timeupdate",this.handleTimeUpdate),this.audioElement.pause(),this.ownsElement&&(this.audioElement.src="",this.audioElement.load())}get id(){return this._id}get name(){return this._name}get peaks(){return this._peaks}get currentTime(){return this.audioElement.currentTime}get duration(){return this.audioElement.duration||this._peaks.duration}get isPlaying(){return!this.audioElement.paused&&!this.audioElement.ended}get volume(){return this.audioElement.volume}get playbackRate(){return this._playbackRate}get muted(){return this.audioElement.muted}get element(){return this.audioElement}},Fy=class{constructor(e={}){this.track=null,this._isPlaying=!1,this._masterVolume=e.masterVolume??1,this._playbackRate=e.playbackRate??1}async init(){}addTrack(e){return this.track&&(console.warn("MediaElementPlayout: Only one track is supported. Disposing previous track. For multi-track, use TonePlayout."),this.track.dispose()),this.track=new Py({...e,volume:this._masterVolume*(e.volume??1),playbackRate:this._playbackRate}),this.track.setOnStopCallback(()=>{this._isPlaying=!1,this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback()}),this.track}removeTrack(e){this.track&&this.track.id===e&&(this.track.dispose(),this.track=null)}getTrack(e){if(this.track&&this.track.id===e)return this.track}play(e,t,n){if(!this.track){console.warn("MediaElementPlayout: No track to play");return}const r=t??0;if(this._isPlaying=!0,this.track.play(r),n!==void 0){const s=n/this._playbackRate;setTimeout(()=>{this._isPlaying&&(this.pause(),this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())},s*1e3)}}pause(){this.track&&this.track.pause(),this._isPlaying=!1}stop(){this.track&&this.track.stop(),this._isPlaying=!1}seekTo(e){this.track&&this.track.seekTo(e)}getCurrentTime(){return this.track?this.track.currentTime:0}setMasterVolume(e){this._masterVolume=Math.max(0,Math.min(1,e)),this.track&&this.track.setVolume(this._masterVolume)}setPlaybackRate(e){this._playbackRate=Math.max(.5,Math.min(2,e)),this.track&&this.track.setPlaybackRate(this._playbackRate)}setMute(e,t){const n=this.getTrack(e);n&&n.setMuted(t)}setSolo(e,t){console.warn("MediaElementPlayout: Solo is not applicable for single-track playback")}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}dispose(){this.track&&(this.track.dispose(),this.track=null)}get isPlaying(){return this._isPlaying}get masterVolume(){return this._masterVolume}get playbackRate(){return this._playbackRate}get duration(){return this.track?.duration??0}get sampleRate(){return this.track?.peaks.sample_rate??44100}};const $f=m.createContext(null),Df=m.createContext(null),Pf=m.createContext(null),Ff=m.createContext(null),Oy=({track:e,samplesPerPixel:t=1024,waveHeight:n=100,timescale:r=!1,playbackRate:s=1,automaticScroll:o=!1,theme:a,controls:i={show:!1,width:0},annotationList:l,barWidth:c=1,barGap:u=0,progressBarWidth:f,onAnnotationsChange:p,onReady:d,children:h})=>{const g=f??c+u,[y,v]=m.useState(!1),[b,w]=m.useState(0),[C,_]=m.useState(0),[S,k]=m.useState([]),[I,E]=m.useState(s),A=m.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const j=l.annotations[0];if(typeof j.start!="number"||typeof j.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof j.start),[]}return l.annotations},[l?.annotations]),R=m.useRef(A);R.current=A;const[T,M]=m.useState(null),[$,O]=m.useState(l?.isContinuousPlay??!1),[P]=m.useState(t),[V,Y]=m.useState(o),K=m.useRef(null),fe=m.useRef(0),pe=m.useRef($),Ce=m.useRef(null),X=m.useRef(null),Se=m.useRef(o),te=m.useRef(t),{startAnimationFrameLoop:qe,stopAnimationFrameLoop:J}=Af();m.useEffect(()=>{pe.current=$},[$]),m.useEffect(()=>{Se.current=V},[V]);const Z=m.useCallback(j=>{Ce.current=j,M(j)},[]),he=m.useCallback(j=>{pe.current=j,O(j)},[]),De=m.useCallback(j=>{X.current=j},[]),se=e.waveformData.sample_rate;m.useEffect(()=>{const j=new Fy({playbackRate:s});j.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const ue=j.getTrack(j.track?.id??"");return ue&&ue.setOnTimeUpdateCallback(He=>{fe.current=He}),j.setOnPlaybackComplete(()=>{J(),v(!1),Z(null),fe.current=0,w(0)}),K.current=j,_(e.waveformData.duration),d?.(),()=>{J(),j.dispose()}},[e.source,e.waveformData,e.name,s,d,J,Z]),m.useEffect(()=>{try{const j=ty(e.waveformData,P,0,0,Math.ceil(e.waveformData.duration*se)),ue={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:j.length,data:[j.data],bits:j.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*se)};k([[ue]])}catch(j){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",j)}},[e.waveformData,e.name,P,se]);const Me=m.useCallback(()=>{const j=()=>{const ue=K.current?.getCurrentTime()??0;fe.current=ue;const He=R.current;if(He.length>0){const Fe=He.find(ne=>ue>=ne.start&&ue<ne.end);if(pe.current)Fe&&Fe.id!==Ce.current?Z(Fe.id):!Fe&&Ce.current!==null&&Z(null);else if(Ce.current){const ne=He.find(ge=>ge.id===Ce.current);if(ne&&ue>=ne.end){K.current?.stop(),v(!1);return}}else Fe&&Z(Fe.id)}if(Se.current&&X.current){const Fe=X.current,ne=ue*se/te.current,ge=Fe.clientWidth,We=Math.max(0,ne-ge/2);Fe.scrollLeft=We}qe(j)};qe(j)},[Z,se,qe]),Be=J,ze=m.useCallback(j=>{if(!K.current)return;const ue=j??fe.current;K.current.play(void 0,ue),v(!0),Me()},[Me]),N=m.useCallback(()=>{K.current&&(K.current.pause(),v(!1),Be(),w(K.current.getCurrentTime()))},[Be]),Q=m.useCallback(()=>{K.current&&(K.current.stop(),v(!1),Be(),fe.current=0,w(0),Z(null))},[Be,Z]),Je=m.useCallback(j=>{const ue=Math.max(0,Math.min(j,C));fe.current=ue,w(ue),K.current&&K.current.seekTo(ue)},[C]),je=m.useCallback(j=>{const ue=Math.max(.5,Math.min(2,j));E(ue),K.current&&K.current.setPlaybackRate(ue)},[]),ie=r?30:0,pt=m.useMemo(()=>({isPlaying:y,currentTime:b,currentTimeRef:fe}),[y,b]),Mt=m.useMemo(()=>({continuousPlay:$,annotations:A,activeAnnotationId:T,playbackRate:I,isAutomaticScroll:V}),[$,A,T,I,V]),lt=m.useRef(p);lt.current=p;const et=m.useCallback(j=>{const ue=typeof j=="function"?j(R.current):j;if(!lt.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to MediaElementPlaylistProvider to handle annotation updates.");return}lt.current(ue)},[]),mt=m.useMemo(()=>({play:ze,pause:N,stop:Q,seekTo:Je,setPlaybackRate:je,setContinuousPlay:he,setAnnotations:et,setActiveAnnotationId:Z,setAutomaticScroll:j=>{Y(j)},setScrollContainer:De,scrollContainerRef:X}),[ze,N,Q,Je,je,he,et,Z,De]),gt=m.useMemo(()=>({duration:C,peaksDataArray:S,sampleRate:se,waveHeight:n,timeScaleHeight:ie,samplesPerPixel:P,playoutRef:K,controls:i,barWidth:c,barGap:u,progressBarWidth:g}),[C,S,se,n,ie,P,i,c,u,g]),ct={...Jd,...a};return x.jsx(D.ThemeProvider,{theme:ct,children:x.jsx($f.Provider,{value:pt,children:x.jsx(Df.Provider,{value:Mt,children:x.jsx(Pf.Provider,{value:mt,children:x.jsx(Ff.Provider,{value:gt,children:h})})})})})},Hr=()=>{const e=m.useContext($f);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},oo=()=>{const e=m.useContext(Df);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},Di=()=>{const e=m.useContext(Pf);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},ao=()=>{const e=m.useContext(Ff);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},By=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=ot(),{selectionStart:r,selectionEnd:s,isLoopEnabled:o}=at(),{play:a}=ke(),i=async()=>{if(r!==s&&s>r&&!o){const c=s-r;await a(r,c)}else await a(n.current??0)};return x.jsx(xt,{onClick:i,disabled:t,className:e,children:"Play"})},Wy=({className:e})=>{const{isPlaying:t}=ot(),{pause:n}=ke();return x.jsx(xt,{onClick:n,disabled:!t,className:e,children:"Pause"})},Ly=({className:e})=>{const{isPlaying:t}=ot(),{stop:n}=ke();return x.jsx(xt,{onClick:n,disabled:!t,className:e,children:"Stop"})},Vy=({className:e})=>{const{isPlaying:t}=ot(),{play:n,setCurrentTime:r}=ke(),s=()=>{r(0),t&&n(0)};return x.jsx(xt,{onClick:s,className:e,children:"Rewind"})},Ny=({className:e})=>{const{isPlaying:t}=ot(),{play:n,setCurrentTime:r}=ke(),{duration:s}=it(),o=()=>{r(s),t&&n(s)};return x.jsx(xt,{onClick:o,className:e,children:"Fast Forward"})},Zy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ot(),{play:s,setCurrentTime:o}=ke(),a=()=>{const i=Math.max(0,(n.current??0)-e);o(i),r&&s(i)};return x.jsx(xt,{onClick:a,className:t,children:"Skip Backward"})},Gy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ot(),{play:s,setCurrentTime:o}=ke(),{duration:a}=it(),i=()=>{const l=Math.min(a,(n.current??0)+e);o(l),r&&s(l)};return x.jsx(xt,{onClick:i,className:t,children:"Skip Forward"})},zy=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=at(),{setLoopEnabled:s,setLoopRegion:o}=ke(),{duration:a}=it(),i=n!==r&&r>n,l=()=>{if(!t&&!i){const c=Math.min(10,a*.25);o(0,Math.max(1,c))}s(!t)};return x.jsx(xt,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},jy=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=at(),{setLoopRegionFromSelection:o,clearLoopRegion:a}=ke(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?a():o()};return x.jsx(xt,{onClick:c,disabled:!i&&!l,className:e,title:l?"Clear loop region":i?"Set loop region from selection":"Create a selection first",children:l?"Clear Loop":"Set Loop"})},Hy=({onClearAll:e,label:t="Clear All",className:n})=>{const{stop:r}=ke(),s=m.useCallback(()=>{r(),e()},[r,e]);return x.jsx(xt,{onClick:s,className:n,title:"Remove all tracks",children:t})},Xy=({className:e,disabled:t})=>{const{zoomIn:n}=ke(),{canZoomIn:r}=it();return x.jsx(xt,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},Yy=({className:e,disabled:t})=>{const{zoomOut:n}=ke(),{canZoomOut:r}=it();return x.jsx(xt,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},Uy=({className:e})=>{const{masterVolume:t}=it(),{setMasterVolume:n}=ke();return x.jsx(_0,{volume:t,onChange:n,className:e})},Ky=({className:e})=>{const{timeFormat:t}=it(),{setTimeFormat:n}=ke();return x.jsx(ov,{value:t,onChange:n,className:e})},Qy=D.span`
|
|
990
|
+
`;let kl=0;function Al(){let e;try{const n=new Blob([Sl],{type:"application/javascript"}),a=URL.createObjectURL(n);e=new Worker(a),URL.revokeObjectURL(a)}catch(n){return console.warn("[waveform-playlist] Failed to create peaks worker (CSP restriction?):",n),{generate(){return Promise.reject(new Error("Worker creation failed"))},terminate(){}}}const t=new Map;let r=!1;return e.onmessage=n=>{const a=n.data,s=t.get(a.id);if(s)if(t.delete(a.id),a.error)s.reject(new Error(a.error));else try{const o=Le.create(a.buffer);s.resolve(o)}catch(o){s.reject(o)}},e.onerror=n=>{r=!0,e.terminate();for(const[,a]of t)a.reject(n.error??new Error(n.message));t.clear()},{generate(n){if(r)return Promise.reject(new Error("Worker terminated"));const a=String(++kl);return new Promise((s,o)=>{t.set(a,{resolve:s,reject:o}),e.postMessage({id:a,scale:n.scale,bits:n.bits,amplitude_scale:1,split_channels:n.splitChannels,length:n.length,sample_rate:n.sampleRate,channels:n.channels},n.channels)})},terminate(){r=!0,e.terminate();for(const[,n]of t)n.reject(new Error("Worker terminated"));t.clear()}}}function _l(e,t){const[r,n]=f.useState(()=>new Map),[a,s]=f.useState(!1),o=f.useRef(null),i=f.useRef(new WeakMap),c=f.useRef(new WeakMap),l=f.useRef(new WeakMap),u=f.useRef(0),m=f.useCallback(()=>(o.current||(o.current=Al()),o.current),[]);return f.useEffect(()=>{let b=!1;const d=i.current,h=c.current,v=l.current,g=[],p=new Map;for(const y of e)for(const w of y.clips){if(!w.audioBuffer||w.waveformData)continue;const I=d.get(w.audioBuffer);if(I){g.push({clipId:w.id,waveformData:I});continue}if(h.get(w.audioBuffer)){const A=v.get(w.audioBuffer);A?A.add(w.id):v.set(w.audioBuffer,new Set([w.id]));continue}const S=p.get(w.audioBuffer);S?S.add(w.id):p.set(w.audioBuffer,new Set([w.id]))}if(g.length>0&&n(y=>{const w=new Map(y);for(const I of g)w.set(I.clipId,I.waveformData);return w}),p.size===0)return;u.current+=p.size,s(!0);const C=m();for(const[y,w]of p){v.set(y,new Set(w));const I=[];for(let k=0;k<y.numberOfChannels;k++)I.push(y.getChannelData(k).slice().buffer);const S=`buffer-${Math.random().toString(36).slice(2,11)}`,A=C.generate({id:S,channels:I,length:y.length,sampleRate:y.sampleRate,scale:t,bits:16,splitChannels:!0}).then(k=>{d.set(y,k);const M=v.get(y)??new Set;v.delete(y),h.delete(y),!b&&(n(_=>{const E=new Map(_);for(const T of M)E.set(T,k);return E}),u.current--,u.current<=0&&(u.current=0,s(!1)))}).catch(k=>{v.delete(y),h.delete(y),!b&&(console.warn("[waveform-playlist] Worker peak generation failed:",k),u.current--,u.current<=0&&(u.current=0,s(!1)))});h.set(y,A)}return()=>{b=!0,c.current=new WeakMap,l.current=new WeakMap,u.current=0,s(!1)}},[e,t,m]),f.useEffect(()=>()=>{o.current?.terminate(),o.current=null},[]),{cache:r,isGenerating:a}}function En(e){return e instanceof File?e.name.replace(/\.[^/.]+$/,""):e instanceof Blob?"Untitled":typeof e=="string"?e.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled":e.name??e.src.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled"}async function El(e,t,r){const n=En(e);if(e instanceof Blob){const c=await e.arrayBuffer();return r?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(c),name:n}}const a=typeof e=="string"?e:e.src,s=await fetch(a,{signal:r});if(!s.ok)throw new Error(`Failed to fetch ${a}: ${s.statusText}`);const o=await s.arrayBuffer();return r?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(o),name:n}}function Ml(){const[e,t]=f.useState([]),[r,n]=f.useState(0),[a,s]=f.useState([]),o=f.useRef(!1),i=f.useRef(new Set),c=f.useRef(new Map);f.useEffect(()=>{const m=c.current;return()=>{o.current=!0;for(const b of m.values())b.abort();m.clear()}},[]);const l=f.useCallback(m=>{if(m.length===0)return;const b=To(),d=m.map(h=>({track:qr({name:`${En(h)} (loading...)`,clips:[]}),source:h}));t(h=>[...h,...d.map(v=>v.track)]),n(h=>h+m.length);for(const{track:h,source:v}of d){i.current.add(h.id);const g=new AbortController;c.current.set(h.id,g),(async()=>{try{const{audioBuffer:p,name:C}=await El(v,b,g.signal),y=Jr({audioBuffer:p,startTime:0,duration:p.duration,offset:0,name:C});!o.current&&i.current.has(h.id)&&t(w=>w.map(I=>I.id===h.id?{...I,name:C,clips:[y]}:I))}catch(p){if(p instanceof DOMException&&p.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",p),!o.current&&i.current.has(h.id)&&(t(C=>C.filter(y=>y.id!==h.id)),s(C=>[...C,{name:En(v),error:p instanceof Error?p:new Error(String(p))}]))}finally{c.current.delete(h.id),!o.current&&i.current.delete(h.id)&&n(p=>p-1)}})()}},[]),u=f.useCallback(m=>{t(d=>d.filter(h=>h.id!==m));const b=c.current.get(m);b&&(b.abort(),c.current.delete(m)),i.current.delete(m)&&n(d=>d-1)},[]);return{tracks:e,addTracks:l,removeTrack:u,loadingCount:r,isLoading:r>0,errors:a}}var Tl=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvbWV0ZXItcHJvY2Vzc29yLndvcmtsZXQudHMKdmFyIE1ldGVyUHJvY2Vzc29yID0gY2xhc3MgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIGNvbnN0cnVjdG9yKG9wdGlvbnMpIHsKICAgIHN1cGVyKCk7CiAgICBjb25zdCB7IG51bWJlck9mQ2hhbm5lbHMsIHVwZGF0ZVJhdGUgfSA9IG9wdGlvbnMucHJvY2Vzc29yT3B0aW9uczsKICAgIHRoaXMubnVtYmVyT2ZDaGFubmVscyA9IG51bWJlck9mQ2hhbm5lbHM7CiAgICB0aGlzLmJsb2Nrc1BlclVwZGF0ZSA9IE1hdGgubWF4KDEsIE1hdGguZmxvb3Ioc2FtcGxlUmF0ZSAvICgxMjggKiB1cGRhdGVSYXRlKSkpOwogICAgdGhpcy5ibG9ja3NQcm9jZXNzZWQgPSAwOwogICAgdGhpcy5tYXhQZWFrID0gbmV3IEFycmF5KG51bWJlck9mQ2hhbm5lbHMpLmZpbGwoMCk7CiAgICB0aGlzLnN1bVNxdWFyZXMgPSBuZXcgQXJyYXkobnVtYmVyT2ZDaGFubmVscykuZmlsbCgwKTsKICAgIHRoaXMuc2FtcGxlQ291bnQgPSBuZXcgQXJyYXkobnVtYmVyT2ZDaGFubmVscykuZmlsbCgwKTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIF9wYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBpZiAoIWlucHV0IHx8IGlucHV0Lmxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGZvciAobGV0IGNoID0gMDsgY2ggPCBvdXRwdXQubGVuZ3RoOyBjaCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoXTsKICAgICAgY29uc3Qgb3V0cHV0Q2hhbm5lbCA9IG91dHB1dFtjaF07CiAgICAgIGlmIChpbnB1dENoYW5uZWwgJiYgb3V0cHV0Q2hhbm5lbCkgewogICAgICAgIG91dHB1dENoYW5uZWwuc2V0KGlucHV0Q2hhbm5lbCk7CiAgICAgIH0KICAgIH0KICAgIGZvciAobGV0IGNoID0gMDsgY2ggPCB0aGlzLm51bWJlck9mQ2hhbm5lbHM7IGNoKyspIHsKICAgICAgY29uc3QgaW5wdXRDaGFubmVsID0gaW5wdXRbY2hdOwogICAgICBpZiAoIWlucHV0Q2hhbm5lbCkgY29udGludWU7CiAgICAgIGxldCBwZWFrID0gdGhpcy5tYXhQZWFrW2NoXTsKICAgICAgbGV0IHN1bSA9IHRoaXMuc3VtU3F1YXJlc1tjaF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaW5wdXRDaGFubmVsLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgY29uc3Qgc2FtcGxlID0gaW5wdXRDaGFubmVsW2ldOwogICAgICAgIGNvbnN0IGFicyA9IE1hdGguYWJzKHNhbXBsZSk7CiAgICAgICAgaWYgKGFicyA+IHBlYWspIHBlYWsgPSBhYnM7CiAgICAgICAgc3VtICs9IHNhbXBsZSAqIHNhbXBsZTsKICAgICAgfQogICAgICB0aGlzLm1heFBlYWtbY2hdID0gcGVhazsKICAgICAgdGhpcy5zdW1TcXVhcmVzW2NoXSA9IHN1bTsKICAgICAgdGhpcy5zYW1wbGVDb3VudFtjaF0gKz0gaW5wdXRDaGFubmVsLmxlbmd0aDsKICAgIH0KICAgIHRoaXMuYmxvY2tzUHJvY2Vzc2VkKys7CiAgICBpZiAodGhpcy5ibG9ja3NQcm9jZXNzZWQgPj0gdGhpcy5ibG9ja3NQZXJVcGRhdGUpIHsKICAgICAgY29uc3QgcGVhayA9IFtdOwogICAgICBjb25zdCBybXMgPSBbXTsKICAgICAgZm9yIChsZXQgY2ggPSAwOyBjaCA8IHRoaXMubnVtYmVyT2ZDaGFubmVsczsgY2grKykgewogICAgICAgIHBlYWsucHVzaCh0aGlzLm1heFBlYWtbY2hdKTsKICAgICAgICBjb25zdCBjb3VudCA9IHRoaXMuc2FtcGxlQ291bnRbY2hdOwogICAgICAgIHJtcy5wdXNoKGNvdW50ID4gMCA/IE1hdGguc3FydCh0aGlzLnN1bVNxdWFyZXNbY2hdIC8gY291bnQpIDogMCk7CiAgICAgIH0KICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsgcGVhaywgcm1zIH0pOwogICAgICB0aGlzLm1heFBlYWsuZmlsbCgwKTsKICAgICAgdGhpcy5zdW1TcXVhcmVzLmZpbGwoMCk7CiAgICAgIHRoaXMuc2FtcGxlQ291bnQuZmlsbCgwKTsKICAgICAgdGhpcy5ibG9ja3NQcm9jZXNzZWQgPSAwOwogICAgfQogICAgcmV0dXJuIHRydWU7CiAgfQp9OwpyZWdpc3RlclByb2Nlc3NvcigibWV0ZXItcHJvY2Vzc29yIiwgTWV0ZXJQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1tZXRlci1wcm9jZXNzb3Iud29ya2xldC5qcy5tYXA=",typeof document>"u"?require("url").pathToFileURL(__filename).href:mt&&mt.tagName.toUpperCase()==="SCRIPT"&&mt.src||new URL("index.js",document.baseURI).href).href;new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIF9vdXRwdXRzLCBfcGFyYW1ldGVycykgewogICAgaWYgKCF0aGlzLmlzUmVjb3JkaW5nKSB7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgY29uc3QgaW5wdXQgPSBpbnB1dHNbMF07CiAgICBpZiAoIWlucHV0IHx8IGlucHV0Lmxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGZyYW1lQ291bnQgPSBpbnB1dFswXS5sZW5ndGg7CiAgICBpZiAodGhpcy5idWZmZXJTaXplIDw9IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBsZXQgb2Zmc2V0ID0gMDsKICAgIHdoaWxlIChvZmZzZXQgPCBmcmFtZUNvdW50KSB7CiAgICAgIGNvbnN0IHJlbWFpbmluZyA9IHRoaXMuYnVmZmVyU2l6ZSAtIHRoaXMuc2FtcGxlc0NvbGxlY3RlZDsKICAgICAgY29uc3QgdG9Db3B5ID0gTWF0aC5taW4ocmVtYWluaW5nLCBmcmFtZUNvdW50IC0gb2Zmc2V0KTsKICAgICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgICAgY29uc3QgaW5wdXRDaGFubmVsID0gaW5wdXRbY2hhbm5lbF07CiAgICAgICAgY29uc3QgYnVmZmVyID0gdGhpcy5idWZmZXJzW2NoYW5uZWxdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdG9Db3B5OyBpKyspIHsKICAgICAgICAgIGJ1ZmZlclt0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKyBpXSA9IGlucHV0Q2hhbm5lbFtvZmZzZXQgKyBpXTsKICAgICAgICB9CiAgICAgIH0KICAgICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkICs9IHRvQ29weTsKICAgICAgb2Zmc2V0ICs9IHRvQ29weTsKICAgICAgaWYgKHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA+PSB0aGlzLmJ1ZmZlclNpemUpIHsKICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3QgY2hhbm5lbHMgPSBbXTsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5jaGFubmVsQ291bnQ7IGkrKykgewogICAgICBjaGFubmVscy5wdXNoKHRoaXMuYnVmZmVyc1tpXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpKTsKICAgIH0KICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgIGNoYW5uZWxzLAogICAgICBzYW1wbGVSYXRlLAogICAgICBjaGFubmVsQ291bnQ6IHRoaXMuY2hhbm5lbENvdW50CiAgICB9KTsKICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgfQp9OwpyZWdpc3RlclByb2Nlc3NvcigicmVjb3JkaW5nLXByb2Nlc3NvciIsIFJlY29yZGluZ1Byb2Nlc3Nvcik7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXJlY29yZGluZy1wcm9jZXNzb3Iud29ya2xldC5qcy5tYXA=",typeof document>"u"?require("url").pathToFileURL(__filename).href:mt&&mt.tagName.toUpperCase()==="SCRIPT"&&mt.src||new URL("index.js",document.baseURI).href).href;const Rl=.98;function Dl(e={}){const{channelCount:t=2,updateRate:r=60,isPlaying:n=!1}=e,[a,s]=f.useState(()=>new Array(t).fill(0)),[o,i]=f.useState(()=>new Array(t).fill(0)),[c,l]=f.useState(()=>new Array(t).fill(0)),u=f.useRef(null),m=f.useRef(new Array(t).fill(0)),[b,d]=f.useState(null),h=f.useCallback(()=>i(new Array(t).fill(0)),[t]);return f.useEffect(()=>{if(!n){const v=new Array(t).fill(0);m.current=new Array(t).fill(0),s(v),l(v),i(v)}},[n,t]),f.useEffect(()=>{let v=!0;return(async()=>{const p=jt();if(await p.rawContext.audioWorklet.addModule(Tl),!v)return;const y=p.createAudioWorkletNode("meter-processor",{channelCount:t,channelCountMode:"explicit",processorOptions:{numberOfChannels:t,updateRate:r}});u.current=y,y.onprocessorerror=I=>{console.warn("[waveform-playlist] Output meter worklet processor error:",String(I))},p.destination.chain(y),m.current=new Array(t).fill(0),y.port.onmessage=I=>{if(!v)return;const{peak:S,rms:A}=I.data,k=m.current,M=[],_=[];for(let E=0;E<S.length;E++)k[E]=Math.max(S[E],(k[E]??0)*Rl),M.push(Ir(k[E])),_.push(Ir(A[E]));s(M),l(_),i(E=>M.map((T,R)=>Math.max(E[R]??0,T)))}})().catch(p=>{console.warn("[waveform-playlist] Failed to set up output meter:",String(p)),v&&d(p instanceof Error?p:new Error(String(p)))}),()=>{if(v=!1,u.current){try{jt().destination.chain()}catch(p){console.warn("[waveform-playlist] Failed to restore destination chain:",String(p))}try{u.current.disconnect(),u.current.port.close()}catch(p){console.warn("[waveform-playlist] Output meter disconnect during cleanup:",String(p))}u.current=null}}},[t,r]),{levels:a,peakLevels:o,rmsLevels:c,resetPeak:h,error:b}}const Na=f.createContext(null),Oa=f.createContext(null),Ha=f.createContext(null),ja=f.createContext(null),$l=({tracks:e,timescale:t=!1,mono:r=!1,waveHeight:n=80,samplesPerPixel:a=1024,zoomLevels:s,automaticScroll:o=!1,theme:i,controls:c={show:!1,width:0},annotationList:l,effects:u,onReady:m,onAnnotationUpdate:b,onAnnotationsChange:d,barWidth:h=1,barGap:v=0,progressBarWidth:g,onTracksChange:p,soundFontCache:C,deferEngineRebuild:y=!1,indefinitePlayback:w=!1,children:I})=>{const S=g??h+v,A=f.useRef(w);A.current=w;const k=f.useMemo(()=>s,[s?.join(",")]),M=f.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const W=l.annotations[0];if(typeof W.start!="number"||typeof W.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof W.start),[]}return l.annotations},[l?.annotations]),_=f.useRef(M);_.current=M;const[E,T]=f.useState(null),[R,D]=f.useState(!1),[P,F]=f.useState(0),[G,z]=f.useState(0),[fe,q]=f.useState([]),[ee,ye]=f.useState([]),[J,ve]=f.useState([]),[te,Xe]=f.useState(o),[Q,de]=f.useState(l?.isContinuousPlay??!1),[Ce,We]=f.useState(l?.linkEndpoints??!1),[K,oe]=f.useState(l?.editable??!1),[De,se]=f.useState(!1),V=f.useRef(null),X=f.useRef(!1),Ee=f.useRef(!1);Ee.current=R;const $e=f.useRef(0),ae=f.useRef(0),He=f.useRef(e),Qe=f.useRef(C);Qe.current=C;const Je=f.useRef(J),Pe=f.useRef(0),Ne=f.useRef(0),Ye=f.useRef(null),Oe=f.useRef(null),je=f.useRef(!1),j=f.useRef(l?.isContinuousPlay??!1),ie=f.useRef(null),Fe=f.useRef(null),Se=f.useRef(0),Ve=f.useRef(!1),Ue=f.useRef(!1),qe=f.useRef([]),ct=f.useRef(a),N=f.useRef(44100),{timeFormat:H,setTimeFormat:Y,formatTime:ne}=Ra(),le=Da({engineRef:V,initialSamplesPerPixel:a}),{samplesPerPixel:pe,onEngineState:U}=le,xe=$a({engineRef:V,initialVolume:1}),{masterVolume:ke,setMasterVolume:Ie,masterVolumeRef:ze,onEngineState:et}=xe,{selectionStart:ut,selectionEnd:rt,setSelection:Gn,selectionStartRef:Et,selectionEndRef:Mt,onEngineState:Wn}=nl({engineRef:V}),{isLoopEnabled:Nn,loopStart:On,loopEnd:Hn,setLoopEnabled:jn,setLoopRegion:Tt,clearLoopRegion:zn,isLoopEnabledRef:Xn,loopStartRef:Yn,loopEndRef:Un,onEngineState:Kn}=rl({engineRef:V}),{selectedTrackId:Qn,setSelectedTrackId:Jn,onEngineState:qn,selectedTrackIdRef:er}=al({engineRef:V}),{animationFrameRef:tr,startAnimationFrameLoop:sn,stopAnimationFrameLoop:Rt}=Wa(),no=f.useMemo(()=>Math.min(...k??[256,512,1024,2048,4096,8192]),[k]),{cache:nr}=_l(e,no),rr=f.useCallback(W=>{j.current=W,de(W)},[]),Ke=f.useCallback(W=>{ie.current=W,T(W)},[]),ar=f.useCallback(()=>{const W=Et.current??0,O=Mt.current??0;W!==O&&O>W&&Tt(W,O)},[Tt,Et,Mt]);f.useEffect(()=>{je.current=te},[te]),f.useEffect(()=>{Je.current=J},[J]),He.current=e;const ln=e===Fe.current,Dt=qe.current,or=V.current!==null&&Dt.length>0&&e.length>Dt.length&&Dt.every(W=>e.find(re=>re.id===W.id)===W);Ve.current=ln||Ue.current||or,f.useEffect(()=>{if(!Oe.current||G===0)return;const W=Oe.current,O=ct.current,re=pe;if(O===re)return;const L=W.clientWidth,me=W.scrollLeft+L/2,ue=N.current,be=me*O/ue*ue/re,Ae=Math.max(0,be-L/2);W.scrollLeft=Ae,ct.current=re},[pe,G]);const $t=f.useRef(null);f.useEffect(()=>{if(ln||Ue.current){ln&&(Fe.current=null);let L=0;e.forEach(ce=>{ce.clips.forEach(me=>{const ue=(me.startSample+me.durationSamples)/me.sampleRate;L=Math.max(L,ue)})}),z(L),qe.current=e;return}if(or&&V.current)try{const L=new Set(Dt.map(be=>be.id)),ce=e.filter(be=>!L.has(be.id)),me=Je.current;for(const be of ce){const Ae=e.indexOf(be),Be=me[Ae],ge={...be,volume:Be?.volume??be.volume,muted:Be?.muted??be.muted,soloed:Be?.soloed??be.soloed,pan:Be?.pan??be.pan};V.current.addTrack(ge)}let ue=0;e.forEach(be=>{be.clips.forEach(Ae=>{const Be=(Ae.startSample+Ae.durationSamples)/Ae.sampleRate;ue=Math.max(ue,Be)})}),z(ue),ve(be=>{if(be.length===e.length)return be;const Ae=[...be];for(const Be of ce)Ae.push({name:Be.name,muted:Be.muted,soloed:Be.soloed,volume:Be.volume,pan:Be.pan});return Ae});const ot=[];e.forEach(be=>{be.clips.forEach(Ae=>{Ae.audioBuffer&&ot.push(Ae.audioBuffer)})}),q(ot),qe.current=e;return}catch(L){console.warn("[waveform-playlist] Incremental add failed, falling through to full rebuild:",String(L))}if(y){let L=0;e.forEach(ce=>{ce.clips.forEach(me=>{const ue=(me.startSample+me.durationSamples)/me.sampleRate;L=Math.max(L,ue)})}),z(L);return}if(se(!1),e.length===0){q([]),z(0),ve([]),ye([]),V.current&&(V.current.dispose(),V.current=null),qe.current=e;return}const W=Ee.current,O=ae.current;return V.current&&W&&(V.current.stop(),Rt(),$t.current={position:O}),(async()=>{try{const L=[];e.forEach(ge=>{ge.clips.forEach(_e=>{_e.audioBuffer&&L.push(_e.audioBuffer)})});let ce=0;e.forEach(ge=>{ge.clips.forEach(_e=>{const tt=_e.sampleRate,lo=(_e.startSample+_e.durationSamples)/tt;ce=Math.max(ce,lo)})}),q(L),z(ce),ve(ge=>ge.length===e.length?ge.map((_e,tt)=>({..._e,name:e[tt].name})):e.map(_e=>({name:_e.name,muted:_e.muted,soloed:_e.soloed,volume:_e.volume,pan:_e.pan}))),V.current&&V.current.dispose(),Se.current=0,Fe.current=null,X.current=!1;const me=Ro({effects:u,soundFontCache:Qe.current}),ue=new Zo({adapter:me,samplesPerPixel:ct.current,zoomLevels:k});ue.setSelection(Et.current??0,Mt.current??0),ue.setLoopRegion(Yn.current??0,Un.current??0),Xn.current&&ue.setLoopEnabled(!0),ue.setMasterVolume(ze.current??1),er.current&&ue.selectTrack(er.current);const ot=Je.current,be=e.map((ge,_e)=>{const tt=ot[_e];return{...ge,volume:tt?.volume??ge.volume,muted:tt?.muted??ge.muted,soloed:tt?.soloed??ge.soloed,pan:tt?.pan??ge.pan}});let Ae=!0;ue.on("statechange",ge=>{Wn(ge),Kn(ge),qn(ge),U(ge),et(ge),!Ae&&ge.tracksVersion!==Se.current&&(Se.current=ge.tracksVersion,Fe.current=ge.tracks,p?p(ge.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),ue.setTracks(be),Ae=!1,Se.current=ue.getState().tracksVersion,V.current=ue,se(!0);const Be=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:ce}});window.dispatchEvent(Be),qe.current=e,m?.()}catch(L){console.warn("[waveform-playlist] Error loading audio:",String(L))}})(),()=>{if(Ve.current){Ve.current=!1;return}Rt(),V.current&&V.current.dispose()}},[e,m,u,Rt,Wn,Kn,qn,U,et,p,ze,Et,Mt,Yn,Un,Xn,k,C,y]),f.useEffect(()=>{if(e.length===0)return;const W=e.map(O=>O.clips.map(L=>{let ce;if(L.waveformData)try{ce=Or(L.waveformData,pe,r,L.offsetSamples,L.durationSamples)}catch(me){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",me)}if(!ce){const me=nr.get(L.id);if(me)try{ce=Or(me,pe,r,L.offsetSamples,L.durationSamples)}catch(ue){console.warn("[waveform-playlist] Failed to extract peaks from cache:",ue)}}if(!ce){!y&&!L.audioBuffer&&!L.waveformData&&!L.midiNotes&&console.warn(`[waveform-playlist] Clip "${L.id}" has no audio data or waveform data`);const me=r?1:L.audioBuffer?.numberOfChannels??1,ue=L.midiNotes?Math.ceil(L.durationSamples/pe):0;ce={length:ue,data:Array.from({length:me},()=>new Int16Array(ue*2)),bits:16}}return{clipId:L.id,trackName:O.name,peaks:ce,startSample:L.startSample,durationSamples:L.durationSamples,fadeIn:L.fadeIn,fadeOut:L.fadeOut,midiNotes:L.midiNotes,sampleRate:L.sampleRate,offsetSamples:L.offsetSamples}}));ye(W)},[e,pe,r,nr,y]);const sr=f.useRef(!1),dt=f.useCallback(()=>{if(V.current)return V.current.getCurrentTime();sr.current||(sr.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const W=Z.getContext().currentTime-(Pe.current??0);return(Ne.current??0)+W},[]),at=f.useCallback(()=>{const W=()=>{const O=dt();ae.current=O;const re=_.current;if(re.length>0){const L=re.find(ce=>O>=ce.start&&O<ce.end);if(j.current)L&&L.id!==ie.current?Ke(L.id):!L&&ie.current!==null&&Ke(null);else if(ie.current){const ce=re.find(me=>me.id===ie.current);if(ce&&O>=ce.end){V.current&&V.current.stop(),D(!1),ae.current=$e.current,F($e.current);return}}else L&&Ke(L.id)}if(je.current&&Oe.current&&G>0){const L=Oe.current,ce=N.current,me=O*ce/ct.current,ue=L.clientWidth,ot=Math.max(0,me-ue/2);L.scrollLeft=ot}if(Ye.current!==null&&O>=Ye.current){V.current&&V.current.stop(),D(!1),ae.current=Ye.current,F(Ye.current),Ye.current=null;return}if(O>=G&&!A.current){V.current&&V.current.stop(),D(!1),ae.current=$e.current,F($e.current),Ke(null);return}sn(W)};sn(W)},[G,Ke,sn,dt]),Ze=Rt;f.useEffect(()=>{(async()=>{if(R&&tr.current&&V.current)if(Q){const O=ae.current;V.current.stop(),Ze();const L=Z.getContext().currentTime;Pe.current=L,Ne.current=O,V.current.play(O),at()}else Ze(),at()})().catch(O=>{console.warn("[waveform-playlist] Failed to reschedule playback:",O),D(!1),Ze()})},[Q,R,at,Ze,tr]),f.useEffect(()=>{(async()=>{if($t.current&&V.current){const{position:O}=$t.current;$t.current=null;const L=Z.getContext().currentTime;Pe.current=L,Ne.current=O,X.current||(await V.current.init(),X.current=!0),V.current.play(O),D(!0),at()}})().catch(O=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",O),D(!1),Ze()})},[e,at,Ze]);const Ft=f.useCallback(async(W,O)=>{if(!V.current||G===0)return;const re=W??ae.current;$e.current=re,ae.current=re,V.current.stop(),V.current.seek(re),Ze();const ce=Z.getContext().currentTime;Pe.current=ce,Ne.current=re,Ye.current=O!==void 0?re+O:null,X.current||(await V.current.init(),X.current=!0);const me=O!==void 0?re+O:void 0;try{V.current.play(re,me)}catch(ue){console.warn("[waveform-playlist] Playback failed to start:",ue),Ze();return}D(!0),at()},[G,at,Ze]),ir=f.useCallback(()=>{if(!V.current)return;const W=dt();V.current.pause(),D(!1),Ze(),ae.current=W,F(W)},[Ze,dt]),lr=f.useCallback(()=>{V.current&&(V.current.stop(),D(!1),Ze(),ae.current=$e.current,F($e.current),Ke(null))},[Ze,Ke]),cr=f.useCallback(W=>{const O=Math.max(0,Math.min(W,G));ae.current=O,F(O),R&&V.current&&Ft(O)},[G,R,Ft]),ur=f.useCallback((W,O)=>{const re=He.current[W]?.id;if(!re)return;const L=[...J];L[W]={...L[W],muted:O},ve(L),V.current&&V.current.setTrackMute(re,O)},[J]),dr=f.useCallback((W,O)=>{const re=He.current[W]?.id;if(!re)return;const L=[...J];L[W]={...L[W],soloed:O},ve(L),V.current&&V.current.setTrackSolo(re,O)},[J]),fr=f.useCallback((W,O)=>{const re=He.current[W]?.id;if(!re)return;const L=[...J];L[W]={...L[W],volume:O},ve(L),V.current&&V.current.setTrackVolume(re,O)},[J]),mr=f.useCallback((W,O)=>{const re=He.current[W]?.id;if(!re)return;const L=[...J];L[W]={...L[W],pan:O},ve(L),V.current&&V.current.setTrackPan(re,O)},[J]),hr=f.useCallback((W,O)=>{Gn(W,O),ae.current=W,F(W),R&&V.current&&(V.current.stop(),V.current.seek(W),V.current.play(W))},[R,Gn]),pr=f.useCallback(W=>{Oe.current=W},[]),cn=f.useRef(d);cn.current=d;const gr=f.useCallback(W=>{const O=typeof W=="function"?W(_.current):W;if(!cn.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to WaveformPlaylistProvider to handle annotation updates.");return}cn.current(O)},[]),un=fe[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;N.current=un;const dn=t?30:0,vr=e.length*n+dn,ro=f.useMemo(()=>({isPlaying:R,currentTime:P,currentTimeRef:ae,playbackStartTimeRef:Pe,audioStartPositionRef:Ne,getPlaybackTime:dt}),[R,P,ae,Pe,Ne,dt]),ao=f.useMemo(()=>({continuousPlay:Q,linkEndpoints:Ce,annotationsEditable:K,isAutomaticScroll:te,isLoopEnabled:Nn,annotations:M,activeAnnotationId:E,selectionStart:ut,selectionEnd:rt,selectedTrackId:Qn,loopStart:On,loopEnd:Hn,indefinitePlayback:w}),[Q,Ce,K,te,Nn,M,E,ut,rt,Qn,On,Hn,w]),br=f.useCallback(W=>{ae.current=W,F(W)},[ae]),yr=f.useCallback(W=>{Xe(W)},[]),oo=f.useMemo(()=>({play:Ft,pause:ir,stop:lr,seekTo:cr,setCurrentTime:br,setTrackMute:ur,setTrackSolo:dr,setTrackVolume:fr,setTrackPan:mr,setSelection:hr,setSelectedTrackId:Jn,setTimeFormat:Y,formatTime:ne,zoomIn:le.zoomIn,zoomOut:le.zoomOut,setMasterVolume:Ie,setAutomaticScroll:yr,setScrollContainer:pr,scrollContainerRef:Oe,setContinuousPlay:rr,setLinkEndpoints:We,setAnnotationsEditable:oe,setAnnotations:gr,setActiveAnnotationId:Ke,setLoopEnabled:jn,setLoopRegion:Tt,setLoopRegionFromSelection:ar,clearLoopRegion:zn}),[Ft,ir,lr,cr,br,ur,dr,fr,mr,hr,Jn,Y,ne,le.zoomIn,le.zoomOut,Ie,yr,pr,Oe,rr,We,oe,gr,Ke,jn,Tt,ar,zn]),so=f.useMemo(()=>({duration:G,audioBuffers:fe,peaksDataArray:ee,trackStates:J,tracks:e,sampleRate:un,waveHeight:n,timeScaleHeight:dn,minimumPlaylistHeight:vr,controls:c,playoutRef:V,samplesPerPixel:pe,timeFormat:H,masterVolume:ke,canZoomIn:le.canZoomIn,canZoomOut:le.canZoomOut,barWidth:h,barGap:v,progressBarWidth:S,isReady:De,mono:r,isDraggingRef:Ue,onTracksChange:p}),[G,fe,ee,J,e,un,n,dn,vr,c,V,pe,H,ke,le.canZoomIn,le.canZoomOut,h,v,S,De,r,Ue,p]),io={...ha,...i};return x.jsx($.ThemeProvider,{theme:io,children:x.jsx(Na.Provider,{value:ro,children:x.jsx(Oa.Provider,{value:ao,children:x.jsx(Ha.Provider,{value:oo,children:x.jsx(ja.Provider,{value:so,children:I})})})})})},Me=()=>{const e=f.useContext(Na);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Te=()=>{const e=f.useContext(Oa);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},he=()=>{const e=f.useContext(Ha);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},Re=()=>{const e=f.useContext(ja);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var Fl=class{constructor(e){this._playbackRate=1,this._audioContext=null,this._sourceNode=null,this._fadeGain=null,this._volumeGain=null,this.handleEnded=()=>{this._cancelFades(),this.onStopCallback&&this.onStopCallback()},this.handleTimeUpdate=()=>{this.onTimeUpdateCallback&&this.onTimeUpdateCallback(this.audioElement.currentTime)},this._peaks=e.peaks,this._id=e.id??`track-${Date.now()}`,this._name=e.name??"Track",this._playbackRate=e.playbackRate??1,this._volume=e.volume??1,this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut,typeof e.source=="string"?(this.audioElement=new Audio(e.source),this.ownsElement=!0):(this.audioElement=e.source,this.ownsElement=!1),this.audioElement.preload="auto",this.audioElement.playbackRate=this._playbackRate;const t=this.audioElement;if("preservesPitch"in this.audioElement?t.preservesPitch=!0:"mozPreservesPitch"in this.audioElement?t.mozPreservesPitch=!0:"webkitPreservesPitch"in this.audioElement&&(t.webkitPreservesPitch=!0),e.audioContext){this._audioContext=e.audioContext;try{this._sourceNode=e.audioContext.createMediaElementSource(this.audioElement)}catch(r){throw new Error("[waveform-playlist] MediaElementTrack: createMediaElementSource() failed. This can happen if the audio element is already connected to another AudioContext. Each audio element can only have one MediaElementSourceNode. Original error: "+String(r))}this._fadeGain=e.audioContext.createGain(),this._volumeGain=e.audioContext.createGain(),this._volumeGain.gain.value=this._volume,this._sourceNode.connect(this._fadeGain),this._fadeGain.connect(this._volumeGain),this._volumeGain.connect(e.audioContext.destination),this.audioElement.volume=1}else this.audioElement.volume=this._volume;this.audioElement.addEventListener("ended",this.handleEnded),this.audioElement.addEventListener("timeupdate",this.handleTimeUpdate)}_scheduleFades(e){if(!this._fadeGain||!this._audioContext)return;const t=this._fadeGain.gain,r=this._audioContext.currentTime,n=this.duration;if(t.cancelScheduledValues(0),t.setValueAtTime(1,r),this._fadeIn&&this._fadeIn.duration>0){const a=this._fadeIn.duration;if(e<a){const s=a-e,o=this._fadeIn.type??"linear";if(e===0)In(t,r,s,o,0,1);else{const i=Ht(o,1e3,!0),c=Math.round(e/this._fadeIn.duration*(i.length-1)),l=i.slice(c);t.setValueAtTime(l[0],r),t.setValueCurveAtTime(l,r,s)}}}if(this._fadeOut&&this._fadeOut.duration>0){const a=n-this._fadeOut.duration;if(e<n&&a<n)if(e>a){const s=e-a,o=this._fadeOut.type??"linear",i=Ht(o,1e3,!1),c=Math.round(s/this._fadeOut.duration*(i.length-1)),l=i.slice(c),u=this._fadeOut.duration-s;t.setValueAtTime(l[0],r),t.setValueCurveAtTime(l,r,u)}else{const s=a-e;Sn(t,r+s,this._fadeOut.duration,this._fadeOut.type??"linear",1,0)}}}_cancelFades(){this._fadeGain&&(this._fadeGain.gain.cancelScheduledValues(0),this._fadeGain.gain.value=1)}play(e=0){const t=()=>{this._scheduleFades(e),this.audioElement.currentTime=e,this.audioElement.play().catch(r=>{console.warn("[waveform-playlist] MediaElementTrack: play() failed: "+String(r))})};this._audioContext&&this._audioContext.state==="suspended"?this._audioContext.resume().then(t).catch(r=>{console.warn("[waveform-playlist] MediaElementTrack: AudioContext.resume() failed: "+String(r))}):t()}pause(){this._cancelFades(),this.audioElement.pause()}stop(){this._cancelFades(),this.audioElement.pause(),this.audioElement.currentTime=0}seekTo(e){this.audioElement.currentTime=Math.max(0,Math.min(e,this.duration))}setVolume(e){this._volume=Math.max(0,Math.min(1,e)),this._volumeGain?this._volumeGain.gain.value=this._volume:this.audioElement.volume=this._volume}setPlaybackRate(e){const t=Math.max(.5,Math.min(2,e));this._playbackRate=t,this.audioElement.playbackRate=t}setMuted(e){this.audioElement.muted=e}setFadeIn(e){this._fadeIn=e}setFadeOut(e){this._fadeOut=e}setOnStopCallback(e){this.onStopCallback=e}setOnTimeUpdateCallback(e){this.onTimeUpdateCallback=e}connectOutput(e){if(!this._volumeGain){console.warn("[waveform-playlist] MediaElementTrack: connectOutput() requires audioContext. Pass audioContext in constructor options.");return}try{this._volumeGain.disconnect()}catch(t){console.warn("[waveform-playlist] MediaElementTrack: disconnect before connectOutput failed: "+String(t))}this._volumeGain.connect(e)}disconnectOutput(){if(!(!this._volumeGain||!this._audioContext)){try{this._volumeGain.disconnect()}catch(e){console.warn("[waveform-playlist] MediaElementTrack: disconnect before disconnectOutput failed: "+String(e))}this._volumeGain.connect(this._audioContext.destination)}}dispose(){if(this.audioElement.removeEventListener("ended",this.handleEnded),this.audioElement.removeEventListener("timeupdate",this.handleTimeUpdate),this._cancelFades(),this.audioElement.pause(),this._sourceNode)try{this._sourceNode.disconnect()}catch(e){console.warn("[waveform-playlist] MediaElementTrack: sourceNode disconnect failed: "+String(e))}if(this._fadeGain)try{this._fadeGain.disconnect()}catch(e){console.warn("[waveform-playlist] MediaElementTrack: fadeGain disconnect failed: "+String(e))}if(this._volumeGain)try{this._volumeGain.disconnect()}catch(e){console.warn("[waveform-playlist] MediaElementTrack: volumeGain disconnect failed: "+String(e))}this.ownsElement&&(this.audioElement.src="",this.audioElement.load())}get id(){return this._id}get name(){return this._name}get peaks(){return this._peaks}get currentTime(){return this.audioElement.currentTime}get duration(){return this.audioElement.duration||this._peaks.duration}get isPlaying(){return!this.audioElement.paused&&!this.audioElement.ended}get volume(){return this._volume}get playbackRate(){return this._playbackRate}get muted(){return this.audioElement.muted}get element(){return this.audioElement}get outputNode(){return this._volumeGain}},Bl=class{constructor(e={}){this.track=null,this._isPlaying=!1,this._masterVolume=e.masterVolume??1,this._playbackRate=e.playbackRate??1}async init(){}addTrack(e){return this.track&&(console.warn("MediaElementPlayout: Only one track is supported. Disposing previous track. For multi-track, use TonePlayout."),this.track.dispose()),this.track=new Fl({...e,volume:this._masterVolume*(e.volume??1),playbackRate:this._playbackRate}),this.track.setOnStopCallback(()=>{this._isPlaying=!1,this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback()}),this.track}removeTrack(e){this.track&&this.track.id===e&&(this.track.dispose(),this.track=null)}getTrack(e){if(this.track&&this.track.id===e)return this.track}play(e,t,r){if(!this.track){console.warn("MediaElementPlayout: No track to play");return}const n=t??0;if(this._isPlaying=!0,this.track.play(n),r!==void 0){const a=r/this._playbackRate;setTimeout(()=>{this._isPlaying&&(this.pause(),this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())},a*1e3)}}pause(){this.track&&this.track.pause(),this._isPlaying=!1}stop(){this.track&&this.track.stop(),this._isPlaying=!1}seekTo(e){this.track&&this.track.seekTo(e)}getCurrentTime(){return this.track?this.track.currentTime:0}setMasterVolume(e){this._masterVolume=Math.max(0,Math.min(1,e)),this.track&&this.track.setVolume(this._masterVolume)}setPlaybackRate(e){this._playbackRate=Math.max(.5,Math.min(2,e)),this.track&&this.track.setPlaybackRate(this._playbackRate)}setMute(e,t){const r=this.getTrack(e);r&&r.setMuted(t)}setSolo(e,t){console.warn("MediaElementPlayout: Solo is not applicable for single-track playback")}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}dispose(){this.track&&(this.track.dispose(),this.track=null)}get isPlaying(){return this._isPlaying}get masterVolume(){return this._masterVolume}get playbackRate(){return this._playbackRate}get duration(){return this.track?.duration??0}get sampleRate(){return this.track?.peaks.sample_rate??44100}get outputNode(){return this.track?.outputNode??null}};const za=f.createContext(null),Xa=f.createContext(null),Ya=f.createContext(null),Ua=f.createContext(null),Pl=({track:e,samplesPerPixel:t=1024,waveHeight:r=100,timescale:n=!1,playbackRate:a=1,automaticScroll:s=!1,theme:o,controls:i={show:!1,width:0},annotationList:c,barWidth:l=1,barGap:u=0,progressBarWidth:m,audioContext:b,onAnnotationsChange:d,onReady:h,children:v})=>{const g=m??l+u,[p,C]=f.useState(!1),[y,w]=f.useState(0),[I,S]=f.useState(0),[A,k]=f.useState([]),[M,_]=f.useState(a),E=f.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const j=c.annotations[0];if(typeof j.start!="number"||typeof j.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof j.start),[]}return c.annotations},[c?.annotations]),T=f.useRef(E);T.current=E;const[R,D]=f.useState(null),[P,F]=f.useState(c?.isContinuousPlay??!1),[G]=f.useState(t),[z,fe]=f.useState(s),q=f.useRef(null),ee=f.useRef(0),ye=f.useRef(P),J=f.useRef(null),ve=f.useRef(null),te=f.useRef(s),Xe=f.useRef(t),{startAnimationFrameLoop:Q,stopAnimationFrameLoop:de}=Wa();f.useEffect(()=>{ye.current=P},[P]),f.useEffect(()=>{te.current=z},[z]);const Ce=f.useCallback(j=>{J.current=j,D(j)},[]),We=f.useCallback(j=>{ye.current=j,F(j)},[]),K=f.useCallback(j=>{ve.current=j},[]),oe=e.waveformData.sample_rate;f.useEffect(()=>{const j=new Bl({playbackRate:a});j.addTrack({source:e.source,peaks:e.waveformData,name:e.name,audioContext:b,fadeIn:e.fadeIn,fadeOut:e.fadeOut});const ie=j.getTrack(j.track?.id??"");return ie&&ie.setOnTimeUpdateCallback(Fe=>{ee.current=Fe}),j.setOnPlaybackComplete(()=>{de(),C(!1),Ce(null),ee.current=0,w(0)}),q.current=j,S(e.waveformData.duration),h?.(),()=>{de(),j.dispose()}},[e.source,e.waveformData,e.name,e.fadeIn,e.fadeOut,b,a,h,de,Ce]),f.useEffect(()=>{try{const j=tl(e.waveformData,G,0,0,Math.ceil(e.waveformData.duration*oe)),ie={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:j.length,data:[j.data],bits:j.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*oe)};k([[ie]])}catch(j){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",j)}},[e.waveformData,e.name,G,oe]);const De=f.useCallback(()=>{const j=()=>{const ie=q.current?.getCurrentTime()??0;ee.current=ie;const Fe=T.current;if(Fe.length>0){const Se=Fe.find(Ve=>ie>=Ve.start&&ie<Ve.end);if(ye.current)Se&&Se.id!==J.current?Ce(Se.id):!Se&&J.current!==null&&Ce(null);else if(J.current){const Ve=Fe.find(Ue=>Ue.id===J.current);if(Ve&&ie>=Ve.end){q.current?.stop(),C(!1);return}}else Se&&Ce(Se.id)}if(te.current&&ve.current){const Se=ve.current,Ve=ie*oe/Xe.current,Ue=Se.clientWidth,qe=Math.max(0,Ve-Ue/2);Se.scrollLeft=qe}Q(j)};Q(j)},[Ce,oe,Q]),se=de,V=f.useCallback(j=>{if(!q.current)return;const ie=j??ee.current;q.current.play(void 0,ie),C(!0),De()},[De]),X=f.useCallback(()=>{q.current&&(q.current.pause(),C(!1),se(),w(q.current.getCurrentTime()))},[se]),Ee=f.useCallback(()=>{q.current&&(q.current.stop(),C(!1),se(),ee.current=0,w(0),Ce(null))},[se,Ce]),$e=f.useCallback(j=>{const ie=Math.max(0,Math.min(j,I));ee.current=ie,w(ie),q.current&&q.current.seekTo(ie)},[I]),ae=f.useCallback(j=>{const ie=Math.max(.5,Math.min(2,j));_(ie),q.current&&q.current.setPlaybackRate(ie)},[]),He=n?30:0,Qe=f.useMemo(()=>({isPlaying:p,currentTime:y,currentTimeRef:ee}),[p,y]),Je=f.useMemo(()=>({continuousPlay:P,annotations:E,activeAnnotationId:R,playbackRate:M,isAutomaticScroll:z}),[P,E,R,M,z]),Pe=f.useRef(d);Pe.current=d;const Ne=f.useCallback(j=>{const ie=typeof j=="function"?j(T.current):j;if(!Pe.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to MediaElementPlaylistProvider to handle annotation updates.");return}Pe.current(ie)},[]),Ye=f.useMemo(()=>({play:V,pause:X,stop:Ee,seekTo:$e,setPlaybackRate:ae,setContinuousPlay:We,setAnnotations:Ne,setActiveAnnotationId:Ce,setAutomaticScroll:j=>{fe(j)},setScrollContainer:K,scrollContainerRef:ve}),[V,X,Ee,$e,ae,We,Ne,Ce,K]),Oe=f.useMemo(()=>({duration:I,peaksDataArray:A,sampleRate:oe,waveHeight:r,timeScaleHeight:He,samplesPerPixel:G,playoutRef:q,controls:i,barWidth:l,barGap:u,progressBarWidth:g,fadeIn:e.fadeIn,fadeOut:e.fadeOut}),[I,A,oe,r,He,G,i,l,u,g,e.fadeIn,e.fadeOut]),je={...ha,...o};return x.jsx($.ThemeProvider,{theme:je,children:x.jsx(za.Provider,{value:Qe,children:x.jsx(Xa.Provider,{value:Je,children:x.jsx(Ya.Provider,{value:Ye,children:x.jsx(Ua.Provider,{value:Oe,children:v})})})})})},_t=()=>{const e=f.useContext(za);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},rn=()=>{const e=f.useContext(Xa);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},Vn=()=>{const e=f.useContext(Ya);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},an=()=>{const e=f.useContext(Ua);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},Vl=({className:e})=>{const{isPlaying:t,currentTimeRef:r}=Me(),{selectionStart:n,selectionEnd:a,isLoopEnabled:s}=Te(),{play:o}=he(),i=async()=>{if(n!==a&&a>n&&!s){const l=a-n;await o(n,l)}else await o(r.current??0)};return x.jsx(Ge,{onClick:i,disabled:t,className:e,children:"Play"})},Zl=({className:e})=>{const{isPlaying:t}=Me(),{pause:r}=he();return x.jsx(Ge,{onClick:r,disabled:!t,className:e,children:"Pause"})},Ll=({className:e})=>{const{isPlaying:t}=Me(),{stop:r}=he();return x.jsx(Ge,{onClick:r,disabled:!t,className:e,children:"Stop"})},Gl=({className:e})=>{const{isPlaying:t}=Me(),{play:r,setCurrentTime:n}=he(),a=()=>{n(0),t&&r(0)};return x.jsx(Ge,{onClick:a,className:e,children:"Rewind"})},Wl=({className:e})=>{const{isPlaying:t}=Me(),{play:r,setCurrentTime:n}=he(),{duration:a}=Re(),s=()=>{n(a),t&&r(a)};return x.jsx(Ge,{onClick:s,className:e,children:"Fast Forward"})},Nl=({skipAmount:e=5,className:t})=>{const{currentTimeRef:r,isPlaying:n}=Me(),{play:a,setCurrentTime:s}=he(),o=()=>{const i=Math.max(0,(r.current??0)-e);s(i),n&&a(i)};return x.jsx(Ge,{onClick:o,className:t,children:"Skip Backward"})},Ol=({skipAmount:e=5,className:t})=>{const{currentTimeRef:r,isPlaying:n}=Me(),{play:a,setCurrentTime:s}=he(),{duration:o}=Re(),i=()=>{const c=Math.min(o,(r.current??0)+e);s(c),n&&a(c)};return x.jsx(Ge,{onClick:i,className:t,children:"Skip Forward"})},Hl=({className:e})=>{const{isLoopEnabled:t,loopStart:r,loopEnd:n}=Te(),{setLoopEnabled:a,setLoopRegion:s}=he(),{duration:o}=Re(),i=r!==n&&n>r,c=()=>{if(!t&&!i){const l=Math.min(10,o*.25);s(0,Math.max(1,l))}a(!t)};return x.jsx(Ge,{onClick:c,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},jl=({className:e})=>{const{selectionStart:t,selectionEnd:r,loopStart:n,loopEnd:a}=Te(),{setLoopRegionFromSelection:s,clearLoopRegion:o}=he(),i=t!==r&&r>t,c=n!==a&&a>n,l=()=>{c?o():s()};return x.jsx(Ge,{onClick:l,disabled:!i&&!c,className:e,title:c?"Clear loop region":i?"Set loop region from selection":"Create a selection first",children:c?"Clear Loop":"Set Loop"})},zl=({onClearAll:e,label:t="Clear All",className:r})=>{const{stop:n}=he(),a=f.useCallback(()=>{n(),e()},[n,e]);return x.jsx(Ge,{onClick:a,className:r,title:"Remove all tracks",children:t})},Xl=({className:e,disabled:t})=>{const{zoomIn:r}=he(),{canZoomIn:n}=Re();return x.jsx(Ge,{onClick:r,disabled:t||!n,className:e,children:"Zoom In"})},Yl=({className:e,disabled:t})=>{const{zoomOut:r}=he(),{canZoomOut:n}=Re();return x.jsx(Ge,{onClick:r,disabled:t||!n,className:e,children:"Zoom Out"})},Ul=({className:e})=>{const{masterVolume:t}=Re(),{setMasterVolume:r}=he();return x.jsx(xs,{volume:t,onChange:r,className:e})},Kl=({className:e})=>{const{timeFormat:t}=Re(),{setTimeFormat:r}=he();return x.jsx(oi,{value:t,onChange:r,className:e})},Ql=$.span`
|
|
1056
991
|
font-family: 'Courier New', Monaco, monospace;
|
|
1057
992
|
font-size: 1rem;
|
|
1058
993
|
font-weight: 600;
|
|
1059
994
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
1060
995
|
user-select: none;
|
|
1061
|
-
`,
|
|
996
|
+
`,Jl=({className:e})=>{const t=f.useRef(null),r=f.useRef(null),{isPlaying:n,currentTimeRef:a,getPlaybackTime:s}=Me(),{timeFormat:o}=Re();return f.useEffect(()=>{const i=()=>{if(t.current){const c=n?s():a.current??0;t.current.textContent=pt(c,o)}n&&(r.current=requestAnimationFrame(i))};return n?r.current=requestAnimationFrame(i):i(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[n,o,a,s]),f.useEffect(()=>{!n&&t.current&&(t.current.textContent=pt(a.current??0,o))}),x.jsx(Ql,{ref:t,className:e,"aria-label":"Audio position",children:pt(a.current??0,o)})},ql=({className:e})=>{const{selectionStart:t,selectionEnd:r}=Te(),{setSelection:n}=he();return x.jsx(Ls,{selectionStart:t,selectionEnd:r,onSelectionChange:n,className:e})},ec=({className:e})=>{const{isAutomaticScroll:t}=Te(),{setAutomaticScroll:r}=he();return x.jsx(Ko,{checked:t,onChange:r,className:e})},on=f.createContext(null),tc=on.Provider;function lt(){const e=f.useContext(on);if(!e)throw new Error("useAnnotationIntegration must be used within <AnnotationProvider>. Install @waveform-playlist/annotations and wrap your app with <AnnotationProvider>. See: https://waveform-playlist.naomiaro.com/docs/guides/annotations");return e}const nc=({className:e})=>{const{ContinuousPlayCheckbox:t}=lt(),{continuousPlay:r}=Te(),{setContinuousPlay:n}=he();return x.jsx(t,{checked:r,onChange:n,className:e})},rc=({className:e})=>{const{LinkEndpointsCheckbox:t}=lt(),{linkEndpoints:r}=Te(),{setLinkEndpoints:n}=he();return x.jsx(t,{checked:r,onChange:n,className:e})},ac=({className:e})=>{const{EditableCheckbox:t}=lt(),{annotationsEditable:r}=Te(),{setAnnotationsEditable:n}=he();return x.jsx(t,{checked:r,onChange:n,className:e})},oc=({filename:e,className:t})=>{const{DownloadAnnotationsButton:r}=lt(),{annotations:n}=Te();return x.jsx(r,{annotations:n,filename:e,className:t})},sc=({label:e="Export WAV",filename:t="export",mode:r="master",trackIndex:n,bitDepth:a=16,applyEffects:s=!0,effectsFunction:o,createOfflineTrackEffects:i,className:c,onExportComplete:l,onExportError:u})=>{const{tracks:m,trackStates:b}=Re(),{exportWav:d,isExporting:h,progress:v}=Ga(),g=async()=>{try{const C=await d(m,b,{filename:t,mode:r,trackIndex:n,bitDepth:a,applyEffects:s,effectsFunction:o,createOfflineTrackEffects:i,autoDownload:!0});l?.(C.blob)}catch(C){u?.(C instanceof Error?C:new Error("Export failed"))}},p=h?`Exporting ${Math.round(v*100)}%`:e;return x.jsx(Ge,{onClick:g,disabled:h||m.length===0,className:c,children:p})},Ka=f.createContext(!1),ic=Ka.Provider;function Qa(){return f.useContext(Ka)}const lc=$.div.attrs(e=>({style:{width:`${e.$width}px`,background:e.$color}}))`
|
|
1062
997
|
position: absolute;
|
|
1063
998
|
top: 0;
|
|
1064
999
|
left: 0;
|
|
@@ -1066,16 +1001,16 @@ self.onmessage = function(e) {
|
|
|
1066
1001
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
1067
1002
|
pointer-events: none;
|
|
1068
1003
|
will-change: transform;
|
|
1069
|
-
`,
|
|
1004
|
+
`,cc=({color:e="#ff0000"})=>{const t=f.useRef(null),r=f.useRef(null),{isPlaying:n,currentTimeRef:a,getPlaybackTime:s}=Me(),{samplesPerPixel:o,sampleRate:i,progressBarWidth:c}=Re();return f.useEffect(()=>{const l=()=>{if(t.current){const m=(n?s():a.current??0)*i/o;t.current.style.transform=`translate3d(${m}px, 0, 0)`}n&&(r.current=requestAnimationFrame(l))};return n?r.current=requestAnimationFrame(l):l(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[n,i,o,a,s]),f.useEffect(()=>{if(!n&&t.current){const u=(a.current??0)*i/o;t.current.style.transform=`translate3d(${u}px, 0, 0)`}}),x.jsx(lc,{ref:t,$color:e,$width:c,"data-playhead":!0})},uc=$.div`
|
|
1070
1005
|
position: relative;
|
|
1071
|
-
`,
|
|
1006
|
+
`,bn=$.div.attrs(e=>({style:{top:`${e.$top}px`,width:`${e.$width}px`,height:`${e.$height}px`,background:e.$color}}))`
|
|
1072
1007
|
position: absolute;
|
|
1073
1008
|
left: 0;
|
|
1074
1009
|
z-index: 0;
|
|
1075
1010
|
/* Force GPU compositing layer to prevent gradient flickering during scroll */
|
|
1076
1011
|
transform: translateZ(0);
|
|
1077
1012
|
backface-visibility: hidden;
|
|
1078
|
-
`,
|
|
1013
|
+
`,dc=$.div.attrs(e=>({style:{top:`${e.$top}px`,height:`${e.$height}px`,width:`${e.$width}px`,background:e.$color,transform:"scaleX(0)"}}))`
|
|
1079
1014
|
position: absolute;
|
|
1080
1015
|
left: 0;
|
|
1081
1016
|
pointer-events: none;
|
|
@@ -1083,16 +1018,16 @@ self.onmessage = function(e) {
|
|
|
1083
1018
|
transform-origin: left;
|
|
1084
1019
|
/* scaleX changes are composite-only (GPU) — no layout reflow per frame */
|
|
1085
1020
|
will-change: transform;
|
|
1086
|
-
`,
|
|
1021
|
+
`,fc=$.div`
|
|
1087
1022
|
position: relative;
|
|
1088
1023
|
z-index: 2;
|
|
1089
|
-
`,
|
|
1024
|
+
`,zr=({clipStartSample:e,clipDurationSamples:t,midiNotes:r,clipSampleRate:n,clipOffsetSeconds:a,...s})=>{const o=f.useRef(null),i=f.useRef(null),c=kt(),{waveHeight:l}=tn(),{isPlaying:u,currentTimeRef:m,getPlaybackTime:b}=Me(),{samplesPerPixel:d,sampleRate:h}=Re(),v=c?.waveProgressColor||"rgba(0, 0, 0, 0.1)",g=ta(e,t,d);f.useEffect(()=>{const E=()=>{if(o.current){const R=(u?b():m.current??0)*h,D=e+t;let P=0;R<=e?P=0:R>=D?P=1:P=(R-e)/t,o.current.style.transform=`scaleX(${P})`}u&&(i.current=requestAnimationFrame(E))};return u?i.current=requestAnimationFrame(E):E(),()=>{i.current&&(cancelAnimationFrame(i.current),i.current=null)}},[u,h,e,t,g,m,b]),f.useEffect(()=>{if(!u&&o.current){const T=(m.current??0)*h,R=e+t;let D=0;T<=e?D=0:T>=R?D=1:D=(T-e)/t,o.current.style.transform=`scaleX(${D})`}});const p=c?.waveformDrawMode||"inverted";let C;p==="inverted"?C=s.isSelected&&c?c.selectedWaveFillColor:c?.waveFillColor||"white":C=s.isSelected&&c?c.selectedWaveOutlineColor:c?.waveOutlineColor||"grey";const y=s.renderMode==="spectrogram"||s.renderMode==="both",w=s.renderMode==="piano-roll",I=s.renderMode==="both",S=y?"#000":w?c?.pianoRollBackgroundColor||"#1a1a2e":nt(C),A=Math.floor(l/2),k=l,M=s.index*l,_=nt(C);return x.jsxs(uc,{children:[I?x.jsxs(x.Fragment,{children:[x.jsx(bn,{$color:"#000",$height:A,$top:M,$width:s.length}),x.jsx(bn,{$color:_,$height:A,$top:M+A,$width:s.length})]}):x.jsx(bn,{$color:S,$height:k,$top:M,$width:s.length}),!w&&x.jsx(dc,{ref:o,$color:v,$height:k,$top:M,$width:g}),x.jsx(fc,{children:x.jsx(Sa,{...s,transparentBackground:!0,midiNotes:r,sampleRate:n,clipOffsetSeconds:a})})]})},Zn=f.createContext(null),mc=Zn.Provider;function hc(){const e=f.useContext(Zn);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const pc=60,gc=$.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
|
|
1090
1025
|
overflow: hidden;
|
|
1091
1026
|
pointer-events: auto;
|
|
1092
1027
|
background: ${e=>e.theme.surfaceColor};
|
|
1093
1028
|
transition: background 0.15s ease-in-out;
|
|
1094
1029
|
${e=>e.$isSelected&&`background: ${e.theme.selectedTrackControlsBackground};`}
|
|
1095
|
-
`,vb=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:o,playbackStartTimeRef:a,audioStartPositionRef:i,getPlaybackTime:l}=ot();return e({position:(o.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:o,playbackStartTimeRef:a,audioStartPositionRef:i,samplesPerPixel:n,sampleRate:r,controlsOffset:0,getAudioContextTime:()=>ks().rawContext.currentTime,getPlaybackTime:l})};function $o(e,t,n,r){const s=e.length>0?Math.max(1,...e.map(a=>a.peaks.data.length)):1,o=t?.isRecording&&t.trackId===n?r?1:t.peaks.length:0;return Math.max(s,o)}const Wf=({renderTrackControls:e,renderTick:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:o,showClipHeaders:a=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:u,recordingState:f})=>{const p=zr(),{isPlaying:d}=ot(),{selectionStart:h,selectionEnd:g,annotations:y,activeAnnotationId:v,annotationsEditable:b,linkEndpoints:w,continuousPlay:C,selectedTrackId:_,loopStart:S,loopEnd:k,isLoopEnabled:I,indefinitePlayback:E}=at(),A=m.useContext(io),{setAnnotations:R,setActiveAnnotationId:T,setTrackMute:M,setTrackSolo:$,setTrackVolume:O,setTrackPan:P,setSelection:V,play:Y,setScrollContainer:K,setSelectedTrackId:fe,setCurrentTime:pe,setLoopRegion:Ce}=ke(),{peaksDataArray:X,trackStates:Se,tracks:te,duration:qe,samplesPerPixel:J,sampleRate:Z,waveHeight:he,timeScaleHeight:De,controls:se,barWidth:Me,barGap:Be,isReady:ze,mono:N}=it(),Q=m.useContext(Pi),Je=m.useMemo(()=>{if(!Q)return new Map;const G=new Map;return te.forEach(H=>{if((Q.trackSpectrogramOverrides.get(H.id)?.renderMode??H.renderMode??"waveform")==="waveform")return;const oe=Q.trackSpectrogramOverrides.get(H.id),ae=oe?.colorMap??H.spectrogramColorMap??Q.spectrogramColorMap??"viridis",Ie=oe?.config??H.spectrogramConfig??Q.spectrogramConfig;G.set(H.id,{colorLUT:Q.getColorMap(ae),frequencyScaleFn:Q.getFrequencyScale(Ie?.frequencyScale??"mel"),config:Ie})}),G},[te,Q]),je=m.useMemo(()=>{if(Q?.spectrogramWorkerApi)return{registerCanvas:Q.spectrogramWorkerApi.registerCanvas.bind(Q.spectrogramWorkerApi),unregisterCanvas:Q.spectrogramWorkerApi.unregisterCanvas.bind(Q.spectrogramWorkerApi)}},[Q?.spectrogramWorkerApi]),[ie,pt]=m.useState(null),[Mt,lt]=m.useState(!1),et=m.useRef(0),mt=m.useRef(null),gt=m.useCallback(G=>{mt.current=G,K(G)},[K]),ct=te.reduce((G,H)=>H.clips.reduce((U,oe)=>{const ae=(oe.startSample+oe.durationSamples)/oe.sampleRate;return Math.max(U,ae)},G),0);let j=ct>0?ct:qe>0?qe:mb;if(E){const H=(mt.current?.clientWidth??0)*J/Z;j=Math.max(j,H)}if(f?.isRecording){const H=(f.startSample+f.durationSamples)/Z;j=Math.max(j,H+10)}const ue=Math.floor(j*Z/J),He=async G=>{T(G.id);const H=C?void 0:G.end-G.start;try{await Y(G.start,H)}catch(U){console.error("waveform-playlist: Failed to start playback for annotation",G.id,U)}},Fe=m.useCallback(G=>{if(G>=0&&G<te.length){const H=te[G];fe(H.id)}},[te,fe]),ne=G=>{const H=G.currentTarget.getBoundingClientRect(),oe=(G.clientX-H.left)*J/Z,Ie=G.clientY-H.top;let q=0,Ve=-1;for(let Xe=0;Xe<X.length;Xe++){const Ze=X[Xe],Tt=$o(Ze,f,te[Xe]?.id,N),nn=((Q?.trackSpectrogramOverrides.get(te[Xe]?.id)?.renderMode??te[Xe]?.renderMode??"waveform")==="both"?Tt*2:Tt)*he+(a?22:0);if(Ie>=q&&Ie<q+nn){Ve=Xe;break}q+=nn}Ve!==-1&&Fe(Ve),et.current=oe,lt(!0),pe(oe),V(oe,oe)},ge=G=>{if(!Mt||d)return;const H=G.currentTarget.getBoundingClientRect(),oe=(G.clientX-H.left)*J/Z,ae=Math.min(h,oe),Ie=Math.max(h,oe);V(ae,Ie)},We=G=>{if(!Mt)return;if(lt(!1),d){const q=Math.max(0,et.current);pe(q),V(q,q),Y(q);return}const H=G.currentTarget.getBoundingClientRect(),oe=(G.clientX-H.left)*J/Z,ae=Math.min(h,oe),Ie=Math.max(h,oe);Math.abs(Ie-ae)<.1?pe(ae):V(ae,Ie)};if(te.some(G=>G.clips.length>0)&&X.length===0)return x.jsx("div",{className:o,children:"Loading waveform..."});const yt=se.show?X.map((G,H)=>{const U=te[H];if(!U)return null;const oe=Se[H]||{name:`Track ${H+1}`,muted:!1,soloed:!1,volume:1,pan:0},ae=U.clips.some(Ze=>Ze.midiNotes&&Ze.midiNotes.length>0),Ie=Q?.trackSpectrogramOverrides.get(U.id)?.renderMode??U.renderMode??(ae?"piano-roll":"waveform"),q=$o(G,f,U.id,N),Ve=he*q+(a?Ei:0),Xe=e?e(H):x.jsxs(dv,{onClick:()=>Fe(H),children:[x.jsxs(fv,{style:{justifyContent:"center",position:"relative"},children:[u&&x.jsx(uv,{onClick:Ze=>{Ze.stopPropagation(),u(H)}}),x.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:oe.name||`Track ${H+1}`}),Q?.renderMenuItems&&x.jsx("span",{style:{position:"absolute",right:0,top:0},children:x.jsx(wv,{items:Ze=>Q.renderMenuItems({renderMode:Ie,onRenderModeChange:Tt=>Q.setTrackRenderMode(U.id,Tt),onOpenSettings:()=>pt(U.id),onClose:Ze})})})]}),x.jsxs(lv,{children:[x.jsx(cc,{$variant:oe.muted?"danger":"outline",onClick:()=>M(H,!oe.muted),children:"Mute"}),x.jsx(cc,{$variant:oe.soloed?"info":"outline",onClick:()=>$(H,!oe.soloed),children:"Solo"})]}),x.jsxs(dc,{children:[x.jsx(hv,{}),x.jsx(uc,{min:"0",max:"1",step:"0.01",value:oe.volume,onChange:Ze=>O(H,parseFloat(Ze.target.value))}),x.jsx(pv,{})]}),x.jsxs(dc,{children:[x.jsx("span",{children:"L"}),x.jsx(uc,{min:"-1",max:"1",step:"0.01",value:oe.pan,onChange:Ze=>P(H,parseFloat(Ze.target.value))}),x.jsx("span",{children:"R"})]})]});return x.jsx(gb,{$height:Ve,$isSelected:U.id===_,children:Xe},U.id)}):void 0;return x.jsxs(cf,{children:[x.jsx(Gr.Provider,{value:{samplesPerPixel:J,sampleRate:Z,zoomLevels:[J],waveHeight:he,timeScaleHeight:De,duration:j*1e3,controls:se,barWidth:Me,barGap:Be},children:x.jsx(Mi,{theme:p,backgroundColor:p.playlistBackgroundColor||Jt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,timescaleWidth:ue,tracksWidth:ue,controlsWidth:se.show?se.width:0,onTracksMouseDown:ne,onTracksMouseMove:ge,onTracksMouseUp:We,scrollContainerRef:gt,isSelecting:Mt,"data-playlist-state":ze?"ready":"loading",trackControlsSlots:yt,timescaleGapHeight:De>0?De+1:0,timescale:De>0?x.jsxs(x.Fragment,{children:[x.jsx(df,{renderTick:t}),I&&x.jsx(W0,{startPosition:Math.min(S,k)*Z/J,endPosition:Math.max(S,k)*Z/J,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:ue,onLoopRegionChange:(G,H)=>{const U=G*J/Z,oe=H*J/Z;Ce(U,oe)}})]}):void 0,children:x.jsxs(x.Fragment,{children:[X.map((G,H)=>{const U=te[H];if(!U)return null;const oe=U.clips.some(q=>q.midiNotes&&q.midiNotes.length>0),ae=Q?.trackSpectrogramOverrides.get(U.id)?.renderMode??U.renderMode??(oe?"piano-roll":"waveform"),Ie=$o(G,f,U.id,N);return x.jsxs(ff,{numChannels:Ie,backgroundColor:ae==="piano-roll"?p.pianoRollBackgroundColor||"#1a1a2e":Jt(p.waveOutlineColor),offset:0,width:ue,hasClipHeaders:a,trackId:U.id,isSelected:U.id===_,children:[ae!=="waveform"&&(()=>{const q=Je.get(U.id),Ve=q?.config;return!Ve?.labels||!q?null:x.jsx(K0,{waveHeight:he,numChannels:Ie,frequencyScaleFn:q.frequencyScaleFn,minFrequency:Ve.minFrequency??0,maxFrequency:Ve.maxFrequency??Z/2,labelsColor:Ve.labelsColor,labelsBackground:Ve.labelsBackground,renderMode:ae,hasClipHeaders:a})})(),G.map((q,Ve)=>{const Xe=q.peaks,Ze=Xe.length;return x.jsx(ya,{clipId:q.clipId,trackIndex:H,clipIndex:Ve,trackName:q.trackName,startSample:q.startSample,durationSamples:q.durationSamples,samplesPerPixel:J,showHeader:a,disableHeaderDrag:!i,isSelected:U.id===_,trackId:U.id,fadeIn:q.fadeIn,fadeOut:q.fadeOut,sampleRate:Z,showFades:l,touchOptimized:c,onMouseDown:Tt=>{Tt.target.closest('[role="button"][aria-roledescription="draggable"]')||Fe(H)},children:Xe.data.map((Tt,zt)=>x.jsx(gc,{index:zt,data:Tt,bits:Xe.bits,length:Ze,isSelected:U.id===_,clipStartSample:q.startSample,clipDurationSamples:q.durationSamples,renderMode:q.midiNotes?"piano-roll":ae,midiNotes:q.midiNotes,clipSampleRate:q.sampleRate,clipOffsetSeconds:q.offsetSamples!=null?q.offsetSamples/(q.sampleRate||Z):0,samplesPerPixel:J,spectrogramWorkerApi:je,spectrogramClipId:q.clipId,spectrogramOnCanvasesReady:Q?(kn,nn)=>{Q.registerSpectrogramCanvases(q.clipId,zt,kn,nn)}:void 0},`${q.clipId}-${zt}`))},q.clipId)}),f?.isRecording&&f.trackId===U.id&&f.peaks[0]?.length>0&&x.jsx(ya,{clipId:"recording-preview",trackIndex:H,clipIndex:G.length,trackName:"Recording...",startSample:f.startSample,durationSamples:f.durationSamples,samplesPerPixel:J,showHeader:a,disableHeaderDrag:!0,isSelected:U.id===_,trackId:U.id,children:(N?f.peaks.slice(0,1):f.peaks).map((q,Ve)=>x.jsx(gc,{index:Ve,data:q,bits:f.bits,length:Math.floor(q.length/2),isSelected:U.id===_,clipStartSample:f.startSample,clipDurationSamples:f.durationSamples},`${U.id}-recording-${Ve}`))},`${U.id}-recording`)]},U.id)}),y.length>0&&A&&x.jsx(A.AnnotationBoxesWrapper,{height:30,width:ue,children:y.map((G,H)=>{const U=G.start*Z/J,oe=G.end*Z/J,ae=s?s(G,H):G.id;return x.jsx(A.AnnotationBox,{annotationId:G.id,annotationIndex:H,startPosition:U,endPosition:oe,label:ae,color:"#ff9800",isActive:G.id===v,onClick:()=>He(G),editable:b},G.id)})}),h!==g&&x.jsx(sf,{startPosition:Math.min(h,g)*Z/J,endPosition:Math.max(h,g)*Z/J,color:p.selectionColor}),(d||h===g)&&(n?x.jsx(vb,{renderPlayhead:n,color:p.playheadColor,samplesPerPixel:J,sampleRate:Z}):x.jsx(cb,{color:p.playheadColor}))]})})}),Q?.SettingsModal&&typeof document<"u"&&Sa.createPortal(x.jsx(Q.SettingsModal,{open:ie!==null,onClose:()=>pt(null),config:ie!==null?Q.trackSpectrogramOverrides.get(ie)?.config??te.find(G=>G.id===ie)?.spectrogramConfig??Q.spectrogramConfig??{}:{},colorMap:ie!==null?Q.trackSpectrogramOverrides.get(ie)?.colorMap??te.find(G=>G.id===ie)?.spectrogramColorMap??Q.spectrogramColorMap??"viridis":"viridis",onApply:(G,H)=>{ie!==null&&Q.setTrackSpectrogramConfig(ie,G,H)}}),document.body)]})},Lf=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,controls:r,annotationListConfig:s,scrollActivePosition:o="center",scrollActiveContainer:a="nearest"})=>{const{annotations:i,activeAnnotationId:l,annotationsEditable:c,linkEndpoints:u,continuousPlay:f}=at(),p=Sn(),{setAnnotations:d}=ke(),h=s??{linkEndpoints:u,continuousPlay:f},g=m.useCallback(v=>{d(v),n?.(v)},[d,n]),{AnnotationText:y}=p;return x.jsx(y,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:o,scrollActiveContainer:a,editable:c,controls:c?r:void 0,annotationListConfig:h,height:e,onAnnotationUpdate:g,renderAnnotationItem:t})},yb=({renderTrackControls:e,renderTick:t,renderTimestamp:n,renderPlayhead:r,annotationControls:s,annotationListConfig:o,annotationTextHeight:a,renderAnnotationItem:i,getAnnotationBoxLabel:l,scrollActivePosition:c="center",scrollActiveContainer:u="nearest",className:f,showClipHeaders:p=!1,interactiveClips:d=!1,showFades:h=!1,touchOptimized:g=!1,onRemoveTrack:y,recordingState:v})=>{const{annotations:b}=at(),w=Bf(),C=d||w;return x.jsxs(x.Fragment,{children:[x.jsx(Wf,{renderTrackControls:e,renderTick:t??(n?(_,S)=>n(parseFloat(_)||0,S):void 0),renderPlayhead:r,annotationControls:s,getAnnotationBoxLabel:l,className:f,showClipHeaders:p,interactiveClips:C,showFades:h,touchOptimized:g,onRemoveTrack:y,recordingState:v}),b.length>0&&x.jsx(Lf,{height:a,renderAnnotationItem:i,controls:s,annotationListConfig:o,scrollActivePosition:c,scrollActiveContainer:u})]})};var bb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Vf=bb?m.useLayoutEffect:m.useEffect;function Mn(e){const t=m.useRef(e);return Vf(()=>{t.current=e},[e]),t}function Do(e,t,n=m.useEffect,r=Object.is){const s=m.useRef(e);n(()=>{const o=s.current;r(e,o)||(s.current=e,t(e,o))},[t,e])}var vc=Object.getOwnPropertySymbols,wb=Object.prototype.hasOwnProperty,Cb=Object.prototype.propertyIsEnumerable,_b=(e,t)=>{var n={};for(var r in e)wb.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&vc)for(var r of vc(e))t.indexOf(r)<0&&Cb.call(e,r)&&(n[r]=e[r]);return n},xb=new bi,Sb=m.createContext(xb),kb=m.memo(m.forwardRef(({children:e},t)=>{const[n,r]=m.useState(0),s=m.useRef(null),o=m.useRef(null),a=m.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{o.current=l})),m.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Vf(()=>{var i;(i=o.current)==null||i.call(o),s.current=null},[e,n]),m.useImperativeHandle(t,()=>a),null})),Po=[void 0,xr];function Nf(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:o,onDragMove:a,onDragOver:i,onDragEnd:l}=t,c=_b(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=m.useRef(null),{plugins:f,modifiers:p,sensors:d}=c,h=Lt(f,Wn.plugins),g=Lt(d,Wn.sensors),y=Lt(p,Wn.modifiers),v=Mn(s),b=Mn(o),w=Mn(i),C=Mn(a),_=Mn(l),S=Mn(r),k=Ib(()=>{var I;return(I=c.manager)!=null?I:new bi(c)});return m.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:I,trackRendering:E}=u.current,{monitor:A}=k;k.renderer=I;const R=[A.addEventListener("beforedragstart",T=>{const M=v.current;M&&E(()=>M(T,k))}),A.addEventListener("dragstart",T=>{var M;return(M=b.current)==null?void 0:M.call(b,T,k)}),A.addEventListener("dragover",T=>{const M=w.current;M&&E(()=>M(T,k))}),A.addEventListener("dragmove",T=>{const M=C.current;M&&E(()=>M(T,k))}),A.addEventListener("dragend",T=>{const M=_.current;M&&E(()=>M(T,k))}),A.addEventListener("collision",T=>{var M;return(M=S.current)==null?void 0:M.call(S,T,k)})];return()=>R.forEach(T=>T())},[k]),Do(h,()=>k&&(k.plugins=h),...Po),Do(g,()=>k&&(k.sensors=g),...Po),Do(y,()=>k&&(k.modifiers=y),...Po),x.jsxs(Sb.Provider,{value:k,children:[x.jsx(kb,{ref:u,children:n}),n]})}function Ib(e){const t=m.useRef(null);return t.current||(t.current=e()),m.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var Ab=Object.create,Zf=Object.defineProperty,Eb=Object.getOwnPropertyDescriptor,Gf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),lo=e=>{throw TypeError(e)},Mb=(e,t,n)=>t in e?Zf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tb=e=>{var t;return[,,,Ab((t=e?.[Gf("metadata")])!=null?t:null)]},zf=["class","method","getter","setter","accessor","field","value","get","set"],jf=e=>e!==void 0&&typeof e!="function"?lo("Function expected"):e,Rb=(e,t,n,r,s)=>({kind:zf[e],name:t,metadata:r,addInitializer:o=>n._?lo("Already initialized"):s.push(jf(o||null))}),$b=(e,t)=>Mb(t,Gf("metadata"),e[3]),Db=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)o[s].call(n);return r},Hf=(e,t,n,r,s,o)=>{for(var a,i,l,c,u=t&7,f=!1,p=!1,d=2,h=zf[u+5],g=e[d]||(e[d]=[]),y=(s=s.prototype,Eb(s,n)),v=r.length-1;v>=0;v--)l=Rb(u,n,i={},e[3],g),l.static=f,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],a=(0,r[v])(y[h],l),i._=1,jf(a)&&(y[h]=a);return y&&Zf(s,n,y),s},Xf=(e,t,n)=>t.has(e)||lo("Cannot "+n),Pb=(e,t,n)=>(Xf(e,t,"read from private field"),t.get(e)),Fb=(e,t,n)=>t.has(e)?lo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ob=(e,t,n,r)=>(Xf(e,t,"write to private field"),t.set(e,n),n),sr=class Ca{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ca(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Ca(t,n)}},Yf,Uf,_a,xs,Xr,Fi=class extends(_a=en,Uf=[Ee],Yf=[Ee],_a){constructor(e){const t=sr.from(e);super(t,(n,r)=>sr.equals(n,r)),Db(Xr,5,this),Fb(this,xs,0),this.velocity={x:0,y:0}}get delta(){return sr.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=sr.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),o=s-Pb(this,xs),a=i=>Math.round(i/o*100);qt(()=>{Ob(this,xs,s),this.velocity={x:a(r.x),y:a(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(sr.from(e)),this.velocity={x:0,y:0}}};Xr=Tb(_a);xs=new WeakMap;Hf(Xr,2,"delta",Uf,Fi);Hf(Xr,2,"direction",Yf,Fi);$b(Xr,Fi);var Kf=(e=>(e.Horizontal="x",e.Vertical="y",e))(Kf||{});Object.values(Kf);var Bb=Object.defineProperty,Wb=Object.defineProperties,Lb=Object.getOwnPropertyDescriptors,yc=Object.getOwnPropertySymbols,Vb=Object.prototype.hasOwnProperty,Nb=Object.prototype.propertyIsEnumerable,bc=(e,t,n)=>t in e?Bb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qf=(e,t)=>{for(var n in t||(t={}))Vb.call(t,n)&&bc(e,n,t[n]);if(yc)for(var n of yc(t))Nb.call(t,n)&&bc(e,n,t[n]);return e},qf=(e,t)=>Wb(e,Lb(t)),xa=class extends Nn{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return qf(Qf({},t),{[n]:r})}};xa.configure=bn(xa);var Jf=xa;Jf.configure({axis:"x",value:0});var eh=Jf.configure({axis:"y",value:0}),wc=class extends Nn{apply({transform:t}){var n;const{size:r=20}=(n=this.options)!=null?n:{},s=typeof r=="number"?r:r.x,o=typeof r=="number"?r:r.y;return qf(Qf({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/o)*o})}};wc.configure=bn(wc);const Oi=e=>{let t=!1;const n=e.map(r=>r===ca?(t=!0,ca.configure({dropAnimation:null})):r);return t||console.warn("[waveform-playlist] noDropAnimationPlugins: Feedback plugin not found in defaults — drop animation may not be disabled. Check @dnd-kit/dom version."),n},Zb=D.div`
|
|
1030
|
+
`,vc=({renderPlayhead:e,color:t,samplesPerPixel:r,sampleRate:n})=>{const{isPlaying:a,currentTimeRef:s,playbackStartTimeRef:o,audioStartPositionRef:i,getPlaybackTime:c}=Me();return e({position:(s.current??0)*n/r,color:t,isPlaying:a,currentTimeRef:s,playbackStartTimeRef:o,audioStartPositionRef:i,samplesPerPixel:r,sampleRate:n,controlsOffset:0,getAudioContextTime:()=>jt().rawContext.currentTime,getPlaybackTime:c})};function yn(e,t,r,n){const a=e.length>0?Math.max(1,...e.map(o=>o.peaks.data.length)):1,s=t?.isRecording&&t.trackId===r?n?1:t.peaks.length:0;return Math.max(a,s)}const Ja=({renderTrackControls:e,renderTick:t,renderPlayhead:r,annotationControls:n,getAnnotationBoxLabel:a,className:s,showClipHeaders:o=!1,interactiveClips:i=!1,showFades:c=!1,touchOptimized:l=!1,onRemoveTrack:u,recordingState:m})=>{const b=kt(),{isPlaying:d}=Me(),{selectionStart:h,selectionEnd:v,annotations:g,activeAnnotationId:p,annotationsEditable:C,linkEndpoints:y,continuousPlay:w,selectedTrackId:I,loopStart:S,loopEnd:A,isLoopEnabled:k,indefinitePlayback:M}=Te(),_=f.useContext(on),{setAnnotations:E,setActiveAnnotationId:T,setTrackMute:R,setTrackSolo:D,setTrackVolume:P,setTrackPan:F,setSelection:G,play:z,setScrollContainer:fe,setSelectedTrackId:q,setCurrentTime:ee,setLoopRegion:ye}=he(),{peaksDataArray:J,trackStates:ve,tracks:te,duration:Xe,samplesPerPixel:Q,sampleRate:de,waveHeight:Ce,timeScaleHeight:We,controls:K,barWidth:oe,barGap:De,isReady:se,mono:V}=Re(),X=f.useContext(Zn),Ee=f.useMemo(()=>{if(!X)return new Map;const N=new Map;return te.forEach(H=>{if((X.trackSpectrogramOverrides.get(H.id)?.renderMode??H.renderMode??"waveform")==="waveform")return;const ne=X.trackSpectrogramOverrides.get(H.id),le=ne?.colorMap??H.spectrogramColorMap??X.spectrogramColorMap??"viridis",pe=ne?.config??H.spectrogramConfig??X.spectrogramConfig;N.set(H.id,{colorLUT:X.getColorMap(le),frequencyScaleFn:X.getFrequencyScale(pe?.frequencyScale??"mel"),config:pe})}),N},[te,X]),$e=f.useMemo(()=>{if(X?.spectrogramWorkerApi)return{registerCanvas:X.spectrogramWorkerApi.registerCanvas.bind(X.spectrogramWorkerApi),unregisterCanvas:X.spectrogramWorkerApi.unregisterCanvas.bind(X.spectrogramWorkerApi)}},[X?.spectrogramWorkerApi]),[ae,He]=f.useState(null),[Qe,Je]=f.useState(!1),Pe=f.useRef(0),Ne=f.useRef(null),Ye=f.useCallback(N=>{Ne.current=N,fe(N)},[fe]),Oe=te.reduce((N,H)=>H.clips.reduce((Y,ne)=>{const le=(ne.startSample+ne.durationSamples)/ne.sampleRate;return Math.max(Y,le)},N),0);let je=Oe>0?Oe:Xe>0?Xe:pc;if(M){const H=(Ne.current?.clientWidth??0)*Q/de;je=Math.max(je,H)}if(m?.isRecording){const H=(m.startSample+m.durationSamples)/de;je=Math.max(je,H+10)}const j=Math.floor(je*de/Q),ie=async N=>{T(N.id);const H=w?void 0:N.end-N.start;try{await z(N.start,H)}catch(Y){console.error("waveform-playlist: Failed to start playback for annotation",N.id,Y)}},Fe=f.useCallback(N=>{if(N>=0&&N<te.length){const H=te[N];q(H.id)}},[te,q]),Se=N=>{const H=N.currentTarget.getBoundingClientRect(),ne=(N.clientX-H.left)*Q/de,pe=N.clientY-H.top;let U=0,xe=-1;for(let ke=0;ke<J.length;ke++){const Ie=J[ke],ze=yn(Ie,m,te[ke]?.id,V),rt=((X?.trackSpectrogramOverrides.get(te[ke]?.id)?.renderMode??te[ke]?.renderMode??"waveform")==="both"?ze*2:ze)*Ce+(o?22:0);if(pe>=U&&pe<U+rt){xe=ke;break}U+=rt}xe!==-1&&Fe(xe),Pe.current=ne,Je(!0),ee(ne),G(ne,ne)},Ve=N=>{if(!Qe||d)return;const H=N.currentTarget.getBoundingClientRect(),ne=(N.clientX-H.left)*Q/de,le=Math.min(h,ne),pe=Math.max(h,ne);G(le,pe)},Ue=N=>{if(!Qe)return;if(Je(!1),d){const U=Math.max(0,Pe.current);ee(U),G(U,U),z(U);return}const H=N.currentTarget.getBoundingClientRect(),ne=(N.clientX-H.left)*Q/de,le=Math.min(h,ne),pe=Math.max(h,ne);Math.abs(pe-le)<.1?ee(le):G(le,pe)};if(te.some(N=>N.clips.length>0)&&J.length===0)return x.jsx("div",{className:s,children:"Loading waveform..."});const ct=K.show?J.map((N,H)=>{const Y=te[H];if(!Y)return null;const ne=ve[H]||{name:`Track ${H+1}`,muted:!1,soloed:!1,volume:1,pan:0},le=Y.clips.some(Ie=>Ie.midiNotes&&Ie.midiNotes.length>0),pe=X?.trackSpectrogramOverrides.get(Y.id)?.renderMode??Y.renderMode??(le?"piano-roll":"waveform"),U=yn(N,m,Y.id,V),xe=Ce*U+(o?Dn:0),ke=e?e(H):x.jsxs(di,{onClick:()=>Fe(H),children:[x.jsxs(fi,{style:{justifyContent:"center",position:"relative"},children:[u&&x.jsx(ui,{onClick:Ie=>{Ie.stopPropagation(),u(H)}}),x.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:ne.name||`Track ${H+1}`}),X?.renderMenuItems&&x.jsx("span",{style:{position:"absolute",right:0,top:0},children:x.jsx(Ci,{items:Ie=>X.renderMenuItems({renderMode:pe,onRenderModeChange:ze=>X.setTrackRenderMode(Y.id,ze),onOpenSettings:()=>He(Y.id),onClose:Ie})})})]}),x.jsxs(li,{children:[x.jsx(Lr,{$variant:ne.muted?"danger":"outline",onClick:()=>R(H,!ne.muted),children:"Mute"}),x.jsx(Lr,{$variant:ne.soloed?"info":"outline",onClick:()=>D(H,!ne.soloed),children:"Solo"})]}),x.jsxs(Wr,{children:[x.jsx(mi,{}),x.jsx(Gr,{min:"0",max:"1",step:"0.01",value:ne.volume,onChange:Ie=>P(H,parseFloat(Ie.target.value))}),x.jsx(hi,{})]}),x.jsxs(Wr,{children:[x.jsx("span",{children:"L"}),x.jsx(Gr,{min:"-1",max:"1",step:"0.01",value:ne.pan,onChange:Ie=>F(H,parseFloat(Ie.target.value))}),x.jsx("span",{children:"R"})]})]});return x.jsx(gc,{$height:xe,$isSelected:Y.id===I,children:ke},Y.id)}):void 0;return x.jsxs(Ia,{children:[x.jsx(St.Provider,{value:{samplesPerPixel:Q,sampleRate:de,zoomLevels:[Q],waveHeight:Ce,timeScaleHeight:We,duration:je*1e3,controls:K,barWidth:oe,barGap:De},children:x.jsx($n,{theme:b,backgroundColor:b.playlistBackgroundColor||nt(b.waveOutlineColor),timescaleBackgroundColor:b.timescaleBackgroundColor,timescaleWidth:j,tracksWidth:j,controlsWidth:K.show?K.width:0,onTracksMouseDown:Se,onTracksMouseMove:Ve,onTracksMouseUp:Ue,scrollContainerRef:Ye,isSelecting:Qe,"data-playlist-state":se?"ready":"loading",trackControlsSlots:ct,timescaleGapHeight:We>0?We+1:0,timescale:We>0?x.jsxs(x.Fragment,{children:[x.jsx(ka,{renderTick:t}),k&&x.jsx(Zs,{startPosition:Math.min(S,A)*de/Q,endPosition:Math.max(S,A)*de/Q,markerColor:b.loopMarkerColor,regionColor:b.loopRegionColor,minPosition:0,maxPosition:j,onLoopRegionChange:(N,H)=>{const Y=N*Q/de,ne=H*Q/de;ye(Y,ne)}})]}):void 0,children:x.jsxs(x.Fragment,{children:[J.map((N,H)=>{const Y=te[H];if(!Y)return null;const ne=Y.clips.some(U=>U.midiNotes&&U.midiNotes.length>0),le=X?.trackSpectrogramOverrides.get(Y.id)?.renderMode??Y.renderMode??(ne?"piano-roll":"waveform"),pe=yn(N,m,Y.id,V);return x.jsxs(Aa,{numChannels:pe,backgroundColor:le==="piano-roll"?b.pianoRollBackgroundColor||"#1a1a2e":nt(b.waveOutlineColor),offset:0,width:j,hasClipHeaders:o,trackId:Y.id,isSelected:Y.id===I,children:[le!=="waveform"&&(()=>{const U=Ee.get(Y.id),xe=U?.config;return!xe?.labels||!U?null:x.jsx(Ks,{waveHeight:Ce,numChannels:pe,frequencyScaleFn:U.frequencyScaleFn,minFrequency:xe.minFrequency??0,maxFrequency:xe.maxFrequency??de/2,labelsColor:xe.labelsColor,labelsBackground:xe.labelsBackground,renderMode:le,hasClipHeaders:o})})(),N.map((U,xe)=>{const ke=U.peaks,Ie=ke.length;return x.jsx(An,{clipId:U.clipId,trackIndex:H,clipIndex:xe,trackName:U.trackName,startSample:U.startSample,durationSamples:U.durationSamples,samplesPerPixel:Q,showHeader:o,disableHeaderDrag:!i,isSelected:Y.id===I,trackId:Y.id,fadeIn:U.fadeIn,fadeOut:U.fadeOut,sampleRate:de,showFades:c,touchOptimized:l,onMouseDown:ze=>{ze.target.closest('[role="button"][aria-roledescription="draggable"]')||Fe(H)},children:ke.data.map((ze,et)=>x.jsx(zr,{index:et,data:ze,bits:ke.bits,length:Ie,isSelected:Y.id===I,clipStartSample:U.startSample,clipDurationSamples:U.durationSamples,renderMode:U.midiNotes?"piano-roll":le,midiNotes:U.midiNotes,clipSampleRate:U.sampleRate,clipOffsetSeconds:U.offsetSamples!=null?U.offsetSamples/(U.sampleRate||de):0,samplesPerPixel:Q,spectrogramWorkerApi:$e,spectrogramClipId:U.clipId,spectrogramOnCanvasesReady:X?(ut,rt)=>{X.registerSpectrogramCanvases(U.clipId,et,ut,rt)}:void 0},`${U.clipId}-${et}`))},U.clipId)}),m?.isRecording&&m.trackId===Y.id&&m.peaks[0]?.length>0&&x.jsx(An,{clipId:"recording-preview",trackIndex:H,clipIndex:N.length,trackName:"Recording...",startSample:m.startSample,durationSamples:m.durationSamples,samplesPerPixel:Q,showHeader:o,disableHeaderDrag:!0,isSelected:Y.id===I,trackId:Y.id,children:(V?m.peaks.slice(0,1):m.peaks).map((U,xe)=>x.jsx(zr,{index:xe,data:U,bits:m.bits,length:Math.floor(U.length/2),isSelected:Y.id===I,clipStartSample:m.startSample,clipDurationSamples:m.durationSamples},`${Y.id}-recording-${xe}`))},`${Y.id}-recording`)]},Y.id)}),g.length>0&&_&&x.jsx(_.AnnotationBoxesWrapper,{height:30,width:j,children:g.map((N,H)=>{const Y=N.start*de/Q,ne=N.end*de/Q,le=a?a(N,H):N.id;return x.jsx(_.AnnotationBox,{annotationId:N.id,annotationIndex:H,startPosition:Y,endPosition:ne,label:le,color:"#ff9800",isActive:N.id===p,onClick:()=>ie(N),editable:C},N.id)})}),h!==v&&x.jsx(ya,{startPosition:Math.min(h,v)*de/Q,endPosition:Math.max(h,v)*de/Q,color:b.selectionColor}),(d||h===v)&&(r?x.jsx(vc,{renderPlayhead:r,color:b.playheadColor,samplesPerPixel:Q,sampleRate:de}):x.jsx(cc,{color:b.playheadColor}))]})})}),X?.SettingsModal&&typeof document<"u"&&Yr.createPortal(x.jsx(X.SettingsModal,{open:ae!==null,onClose:()=>He(null),config:ae!==null?X.trackSpectrogramOverrides.get(ae)?.config??te.find(N=>N.id===ae)?.spectrogramConfig??X.spectrogramConfig??{}:{},colorMap:ae!==null?X.trackSpectrogramOverrides.get(ae)?.colorMap??te.find(N=>N.id===ae)?.spectrogramColorMap??X.spectrogramColorMap??"viridis":"viridis",onApply:(N,H)=>{ae!==null&&X.setTrackSpectrogramConfig(ae,N,H)}}),document.body)]})},qa=({height:e,renderAnnotationItem:t,onAnnotationUpdate:r,controls:n,annotationListConfig:a,scrollActivePosition:s="center",scrollActiveContainer:o="nearest"})=>{const{annotations:i,activeAnnotationId:c,annotationsEditable:l,linkEndpoints:u,continuousPlay:m}=Te(),b=lt(),{setAnnotations:d}=he(),h=a??{linkEndpoints:u,continuousPlay:m},v=f.useCallback(p=>{d(p),r?.(p)},[d,r]),{AnnotationText:g}=b;return x.jsx(g,{annotations:i,activeAnnotationId:c??void 0,shouldScrollToActive:!0,scrollActivePosition:s,scrollActiveContainer:o,editable:l,controls:l?n:void 0,annotationListConfig:h,height:e,onAnnotationUpdate:v,renderAnnotationItem:t})},bc=({renderTrackControls:e,renderTick:t,renderTimestamp:r,renderPlayhead:n,annotationControls:a,annotationListConfig:s,annotationTextHeight:o,renderAnnotationItem:i,getAnnotationBoxLabel:c,scrollActivePosition:l="center",scrollActiveContainer:u="nearest",className:m,showClipHeaders:b=!1,interactiveClips:d=!1,showFades:h=!1,touchOptimized:v=!1,onRemoveTrack:g,recordingState:p})=>{const{annotations:C}=Te(),y=Qa(),w=d||y;return x.jsxs(x.Fragment,{children:[x.jsx(Ja,{renderTrackControls:e,renderTick:t??(r?(I,S)=>r(parseFloat(I)||0,S):void 0),renderPlayhead:n,annotationControls:a,getAnnotationBoxLabel:c,className:m,showClipHeaders:b,interactiveClips:w,showFades:h,touchOptimized:v,onRemoveTrack:g,recordingState:p}),C.length>0&&x.jsx(qa,{height:o,renderAnnotationItem:i,controls:a,annotationListConfig:s,scrollActivePosition:l,scrollActiveContainer:u})]})},Ln=e=>{let t=!1;const r=e.map(n=>n===st.Feedback?(t=!0,st.Feedback.configure({dropAnimation:null})):n);return t||console.warn("[waveform-playlist] noDropAnimationPlugins: Feedback plugin not found in defaults — drop animation may not be disabled. Check @dnd-kit/dom version."),r},yc=$.div`
|
|
1096
1031
|
position: absolute;
|
|
1097
1032
|
top: 0;
|
|
1098
1033
|
left: 0;
|
|
@@ -1102,9 +1037,9 @@ self.onmessage = function(e) {
|
|
|
1102
1037
|
z-index: 100;
|
|
1103
1038
|
pointer-events: none;
|
|
1104
1039
|
will-change: transform;
|
|
1105
|
-
`,
|
|
1040
|
+
`,Cc=({color:e="#ff0000"})=>{const t=f.useRef(null),r=f.useRef(null),{isPlaying:n,currentTimeRef:a}=_t(),{samplesPerPixel:s,sampleRate:o,progressBarWidth:i}=an();return f.useEffect(()=>{const c=()=>{if(t.current){const u=(a.current??0)*o/s;t.current.style.transform=`translate3d(${u}px, 0, 0)`}n&&(r.current=requestAnimationFrame(c))};return n?r.current=requestAnimationFrame(c):c(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[n,o,s,a]),f.useEffect(()=>{if(!n&&t.current){const l=(a.current??0)*o/s;t.current.style.transform=`translate3d(${l}px, 0, 0)`}}),x.jsx(yc,{ref:t,$color:e,$width:i,"data-playhead":!0})},wc=$.div`
|
|
1106
1041
|
position: relative;
|
|
1107
|
-
`,
|
|
1042
|
+
`,xc=$.div`
|
|
1108
1043
|
position: absolute;
|
|
1109
1044
|
top: ${e=>e.$top}px;
|
|
1110
1045
|
left: 0;
|
|
@@ -1114,7 +1049,7 @@ self.onmessage = function(e) {
|
|
|
1114
1049
|
z-index: 0;
|
|
1115
1050
|
transform: translateZ(0);
|
|
1116
1051
|
backface-visibility: hidden;
|
|
1117
|
-
`,
|
|
1052
|
+
`,Ic=$.div`
|
|
1118
1053
|
position: absolute;
|
|
1119
1054
|
top: ${e=>e.$top}px;
|
|
1120
1055
|
left: 0;
|
|
@@ -1123,8 +1058,8 @@ self.onmessage = function(e) {
|
|
|
1123
1058
|
pointer-events: none;
|
|
1124
1059
|
z-index: 1;
|
|
1125
1060
|
will-change: width;
|
|
1126
|
-
`,
|
|
1061
|
+
`,Sc=$.div`
|
|
1127
1062
|
position: relative;
|
|
1128
1063
|
z-index: 2;
|
|
1129
|
-
`,Yb=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=m.useRef(null),s=m.useRef(null),o=zr(),{waveHeight:a}=ro(),{isPlaying:i,currentTimeRef:l}=Hr(),{samplesPerPixel:c,sampleRate:u}=ao(),f=o?.waveProgressColor||"rgba(0, 0, 0, 0.1)";m.useEffect(()=>{const g=()=>{if(r.current){const v=(l.current??0)*u,b=e+t;let w=0;if(v<=e)w=0;else if(v>=b)w=n.length;else{const C=v-e;w=Math.floor(C/c)}r.current.style.width=`${w}px`}i&&(s.current=requestAnimationFrame(g))};return i?s.current=requestAnimationFrame(g):g(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,u,c,e,t,n.length,l]),m.useEffect(()=>{if(!i&&r.current){const y=(l.current??0)*u,v=e+t;let b=0;if(y<=e)b=0;else if(y>=v)b=n.length;else{const w=y-e;b=Math.floor(w/c)}r.current.style.width=`${b}px`}});const p=o?.waveformDrawMode||"inverted";let d;p==="inverted"?d=o?.selectedWaveFillColor||o?.waveFillColor||"white":d=o?.selectedWaveOutlineColor||o?.waveOutlineColor||"grey";const h=Jt(d);return x.jsxs(zb,{children:[x.jsx(jb,{$color:h,$height:a,$top:n.index*a,$width:n.length}),x.jsx(Hb,{ref:r,$color:f,$height:a,$top:n.index*a}),x.jsx(Xb,{children:x.jsx(uf,{...n,isSelected:!0,transparentBackground:!0})})]})},Cc={current:0},Ub=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:o}=Hr();return e({position:(o.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:o,playbackStartTimeRef:Cc,audioStartPositionRef:Cc,samplesPerPixel:n,sampleRate:r,controlsOffset:0})},th=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:n=!1,onAnnotationUpdate:r,renderPlayhead:s,className:o})=>{const a=zr(),{isPlaying:i}=Hr(),{annotations:l,activeAnnotationId:c}=oo(),u=m.useContext(io),{play:f,seekTo:p,setActiveAnnotationId:d,setAnnotations:h,setScrollContainer:g}=Di(),{duration:y,peaksDataArray:v,sampleRate:b,waveHeight:w,timeScaleHeight:C,samplesPerPixel:_,controls:S,playoutRef:k,barWidth:I,barGap:E}=ao(),[A,R]=m.useState(0),[T,M]=m.useState(0),[$,O]=m.useState(!1),P=m.useRef(null),V=m.useCallback(Z=>{P.current=Z,g(Z)},[g]),Y=Math.floor(y*b/_),K=m.useCallback(async Z=>{d(Z.id);try{await f(Z.start)}catch(he){console.error("waveform-playlist: Failed to start playback for annotation",Z.id,he)}},[d,f]),fe=m.useCallback(Z=>{h(Z),r?.(Z)},[h,r]),{onDragStart:pe,onDragMove:Ce,onDragEnd:X}=Cf({annotations:l,onAnnotationsChange:fe,samplesPerPixel:_,sampleRate:b,duration:y,linkEndpoints:n}),Se=m.useRef(0),te=m.useCallback(Z=>{const he=Z.currentTarget.getBoundingClientRect(),se=(Z.clientX-he.left)*_/b;Se.current=se,O(!0),R(se),M(se)},[_,b]),qe=m.useCallback(Z=>{if(!$)return;const he=Z.currentTarget.getBoundingClientRect(),se=(Z.clientX-he.left)*_/b;M(se)},[$,_,b]),J=m.useCallback(Z=>{if(!$)return;if(O(!1),i&&k.current){const ze=Math.max(0,Se.current);p(ze),R(ze),M(ze),k.current.stop(),f(ze);return}const he=Z.currentTarget.getBoundingClientRect(),se=(Z.clientX-he.left)*_/b,Me=Math.min(A,se),Be=Math.max(A,se);Math.abs(Be-Me)<.1?(p(Me),R(Me),M(Me)):(R(Me),M(Be))},[$,A,_,b,p,i,k,f]);return v.length===0?x.jsx("div",{className:o,children:"Loading waveform..."}):x.jsx(cf,{children:x.jsx(Gr.Provider,{value:{samplesPerPixel:_,sampleRate:b,zoomLevels:[_],waveHeight:w,timeScaleHeight:C,duration:y*1e3,controls:S,barWidth:I,barGap:E},children:x.jsx(Mi,{theme:a,backgroundColor:Jt(a.waveOutlineColor),timescaleBackgroundColor:a.timescaleBackgroundColor,timescaleWidth:Y,tracksWidth:Y,controlsWidth:S.show?S.width:0,onTracksMouseDown:te,onTracksMouseMove:qe,onTracksMouseUp:J,scrollContainerRef:V,isSelecting:$,timescale:C>0?x.jsx(df,{}):void 0,children:x.jsxs(x.Fragment,{children:[v.map((Z,he)=>{const De=Z.length>0?Math.max(...Z.map(se=>se.peaks.data.length)):1;return x.jsx(ff,{numChannels:De,backgroundColor:Jt(a.waveOutlineColor),offset:0,width:Y,hasClipHeaders:!1,trackId:`media-element-track-${he}`,isSelected:!0,children:Z.map((se,Me)=>{const Be=se.peaks,ze=Be.length;return x.jsx(ya,{clipId:se.clipId,trackIndex:he,clipIndex:Me,trackName:se.trackName,startSample:se.startSample,durationSamples:se.durationSamples,samplesPerPixel:_,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${he}`,children:Be.data.map((N,Q)=>x.jsx(Yb,{index:Q,data:N,bits:Be.bits,length:ze,clipStartSample:se.startSample,clipDurationSamples:se.durationSamples},`${he}-${Me}-${Q}`))},`${he}-${Me}`)})},he)}),l.length>0&&u&&x.jsx(Nf,{onDragStart:pe,onDragMove:Ce,onDragEnd:X,modifiers:t?[eh]:[],plugins:Oi,children:x.jsx(u.AnnotationBoxesWrapper,{height:30,width:Y,children:l.map((Z,he)=>{const De=Z.start*b/_,se=Z.end*b/_,Me=e?e(Z,he):Z.id;return x.jsx(u.AnnotationBox,{annotationId:Z.id,annotationIndex:he,startPosition:De,endPosition:se,label:Me,color:"#ff9800",isActive:Z.id===c,onClick:()=>K(Z),editable:t},Z.id)})})}),A!==T&&x.jsx(sf,{startPosition:Math.min(A,T)*b/_,endPosition:Math.max(A,T)*b/_,color:a.selectionColor}),s?x.jsx(Ub,{renderPlayhead:s,color:a.playheadColor,samplesPerPixel:_,sampleRate:b}):x.jsx(Gb,{color:a.playheadColor})]})})})})},nh=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,editable:r=!1,controls:s,annotationListConfig:o,scrollActivePosition:a="center",scrollActiveContainer:i="nearest"})=>{const{annotations:l,activeAnnotationId:c,continuousPlay:u}=oo(),f=Sn(),{setAnnotations:p}=Di(),d=o??{linkEndpoints:!1,continuousPlay:u},h=m.useCallback(y=>{p(y),n?.(y)},[p,n]),{AnnotationText:g}=f;return x.jsx(g,{annotations:l,activeAnnotationId:c??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:i,editable:r,controls:r?s:void 0,annotationListConfig:d,height:e,onAnnotationUpdate:h,renderAnnotationItem:t})},Kb=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:n,editable:r=!1,linkEndpoints:s=!1,onAnnotationUpdate:o,scrollActivePosition:a="center",scrollActiveContainer:i="nearest",renderPlayhead:l,className:c})=>{const{annotations:u}=oo();return x.jsxs(x.Fragment,{children:[x.jsx(th,{getAnnotationBoxLabel:t,editable:r,linkEndpoints:s,onAnnotationUpdate:o,renderPlayhead:l,className:c}),u.length>0&&x.jsx(nh,{height:e,renderAnnotationItem:n,onAnnotationUpdate:o,editable:r,annotationListConfig:{linkEndpoints:s,continuousPlay:!1},scrollActivePosition:a,scrollActiveContainer:i})]})},Qb=({playback:e=!1,clipSplitting:t=!1,annotations:n=!1,additionalShortcuts:r=[]})=>{const{tracks:s,samplesPerPixel:o,sampleRate:a,playoutRef:i,duration:l}=it(),{annotations:c,linkEndpoints:u,activeAnnotationId:f,continuousPlay:p}=at(),{setAnnotations:d,setActiveAnnotationId:h,scrollContainerRef:g,play:y}=ke(),{splitClipAtPlayhead:v}=xf({tracks:s,sampleRate:a,samplesPerPixel:o,engineRef:i}),b=[];return t&&b.push({key:"s",action:v,description:"Split clip at playhead",preventDefault:!0}),r.length>0&&b.push(...r),Sf({enabled:e||b.length>0,...e?{additionalShortcuts:b}:{shortcuts:b}}),kf({annotations:c,activeAnnotationId:f,onAnnotationsChange:d,onActiveAnnotationChange:h,duration:l,linkEndpoints:u,continuousPlay:p,scrollContainerRef:g,samplesPerPixel:o,sampleRate:a,onPlay:y,enabled:n&&c.length>0}),null},zs=class zs extends Nn{apply(t){const{transform:n,source:r}=t;if(!r?.data||!this.options)return n;const{boundary:s,trackIndex:o,clipIndex:a}=r.data;if(s)return{x:0,y:0};const{tracks:i,samplesPerPixel:l}=this.options,c=i[o];if(!c)return n;const u=c.clips[a];if(!u)return n;const f=n.x*l,p=[...c.clips].sort((g,y)=>g.startSample-y.startSample),d=p.findIndex(g=>g.id===u.id);return{x:Tc(u,f,p,d)/l,y:0}}};zs.configure=bn(zs);let Gs=zs;const js=class js extends Nn{apply(t){const{transform:n,source:r}=t;if(!this.options||!r?.data)return n;const{boundary:s,startSample:o}=r.data;if(s)return n;const{samplesPerPixel:a}=this.options;if(this.options.mode==="timescale"){const{gridSamples:y}=this.options;if(o!==void 0){const w=o+n.x*a;return{x:(Math.round(w/y)*y-o)/a,y:0}}const v=n.x*a;return{x:Math.round(v/y)*y/a,y:0}}const{snapTo:i,bpm:l,timeSignature:c,sampleRate:u}=this.options;if(i==="off")return n;const f=i==="bar"?ka(c):Hs(c);if(o!==void 0){const y=o+n.x*a,v=Oo(y,l,u),b=Bo(v,f);return{x:(Bn(b,l,u)-o)/a,y:0}}const p=n.x*a,d=Oo(p,l,u),h=Bo(d,f);return{x:Bn(h,l,u)/a,y:0}}};js.configure=bn(js);let $r=js;const qb=()=>{},Jb=({snap:e=!1,touchOptimized:t=!1,children:n})=>{const{tracks:r,samplesPerPixel:s,sampleRate:o,playoutRef:a,isDraggingRef:i,onTracksChange:l}=it(),{setSelectedTrackId:c}=ke(),u=af(),f=e&&u!=null&&u.scaleMode==="beats"&&u.snapTo!=="off",p=e&&!f;m.useEffect(()=>{l==null&&console.warn("[waveform-playlist] ClipInteractionProvider: onTracksChange is not set on WaveformPlaylistProvider. Drag and trim edits will not be persisted.")},[l]);const d=m.useMemo(()=>{if(f&&u){const{bpm:C,timeSignature:_,snapTo:S}=u,k=S==="bar"?ka(_):Hs(_);return I=>{const E=Oo(I,C,o),A=Bo(E,k);return Bn(A,C,o)}}if(p){const C=Math.round(ba(s).smallStep/1e3*o);return _=>Math.round(_/C)*C}},[f,p,u,o,s]),h=_f({touchOptimized:t}),{onDragStart:g,onDragMove:y,onDragEnd:v}=wf({tracks:r,onTracksChange:l??qb,samplesPerPixel:s,sampleRate:o,engineRef:a,isDraggingRef:i,snapSamplePosition:d}),b=m.useCallback(C=>{const _=C.operation?.source?.data?.trackIndex;_!==void 0&&r[_]&&c(r[_].id),g(C)},[g,r,c]),w=m.useMemo(()=>{const C=[eh];return f&&u?C.push($r.configure({mode:"beats",snapTo:u.snapTo,bpm:u.bpm,timeSignature:u.timeSignature,samplesPerPixel:s,sampleRate:o})):p&&C.push($r.configure({mode:"timescale",gridSamples:Math.round(ba(s).smallStep/1e3*o),samplesPerPixel:s})),C.push(Gs.configure({tracks:r,samplesPerPixel:s})),C},[f,p,u,r,s,o]);return x.jsx(ib,{value:!0,children:x.jsx(Nf,{sensors:h,onDragStart:b,onDragMove:y,onDragEnd:v,modifiers:w,plugins:Oi,children:n})})};exports.Tone=xc;exports.AnnotationIntegrationProvider=tb;exports.AudioPosition=qy;exports.AutomaticScrollCheckbox=eb;exports.ClearAllButton=Hy;exports.ClipCollisionModifier=Gs;exports.ClipInteractionProvider=Jb;exports.ContinuousPlayCheckbox=nb;exports.DownloadAnnotationsButton=ob;exports.EditableCheckbox=sb;exports.ExportWavButton=ab;exports.FastForwardButton=Ny;exports.KeyboardShortcuts=Qb;exports.LinkEndpointsCheckbox=rb;exports.LoopButton=zy;exports.MasterVolumeControl=Uy;exports.MediaElementAnnotationList=nh;exports.MediaElementPlaylist=th;exports.MediaElementPlaylistProvider=Oy;exports.MediaElementWaveform=Kb;exports.PauseButton=Wy;exports.PlayButton=By;exports.PlaylistAnnotationList=Lf;exports.PlaylistVisualization=Wf;exports.RewindButton=Vy;exports.SelectionTimeInputs=Jy;exports.SetLoopRegionButton=jy;exports.SkipBackwardButton=Zy;exports.SkipForwardButton=Gy;exports.SnapToGridModifier=$r;exports.SpectrogramIntegrationProvider=hb;exports.StopButton=Ly;exports.TimeFormatSelect=Ky;exports.Waveform=yb;exports.WaveformPlaylistProvider=Dy;exports.ZoomInButton=Xy;exports.ZoomOutButton=Yy;exports.createEffectChain=gy;exports.createEffectInstance=Rr;exports.effectCategories=fy;exports.effectDefinitions=jr;exports.getEffectDefinition=$i;exports.getEffectsByCategory=dy;exports.getShortcutLabel=uy;exports.getWaveformDataMetadata=ey;exports.loadPeaksFromWaveformData=Jv;exports.loadWaveformData=Ri;exports.noDropAnimationPlugins=Oi;exports.useAnnotationDragHandlers=Cf;exports.useAnnotationIntegration=Sn;exports.useAnnotationKeyboardControls=kf;exports.useAudioTracks=ay;exports.useClipDragHandlers=wf;exports.useClipInteractionEnabled=Bf;exports.useClipSplitting=xf;exports.useDragSensors=_f;exports.useDynamicEffects=vy;exports.useDynamicTracks=My;exports.useExportWav=If;exports.useKeyboardShortcuts=Zs;exports.useMasterAnalyser=oy;exports.useMasterVolume=bf;exports.useMediaElementAnimation=Hr;exports.useMediaElementControls=Di;exports.useMediaElementData=ao;exports.useMediaElementState=oo;exports.useOutputMeter=$y;exports.usePlaybackAnimation=ot;exports.usePlaybackShortcuts=Sf;exports.usePlaylistControls=ke;exports.usePlaylistData=it;exports.usePlaylistState=at;exports.useSpectrogramIntegration=pb;exports.useTimeFormat=vf;exports.useTrackDynamicEffects=yy;exports.useZoomControls=yf;exports.waveformDataToPeaks=mf;
|
|
1064
|
+
`,kc=({clipStartSample:e,clipDurationSamples:t,...r})=>{const n=f.useRef(null),a=f.useRef(null),s=kt(),{waveHeight:o}=tn(),{isPlaying:i,currentTimeRef:c}=_t(),{samplesPerPixel:l,sampleRate:u}=an(),m=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";f.useEffect(()=>{const v=()=>{if(n.current){const p=(c.current??0)*u,C=e+t;let y=0;if(p<=e)y=0;else if(p>=C)y=r.length;else{const w=p-e;y=Math.floor(w/l)}n.current.style.width=`${y}px`}i&&(a.current=requestAnimationFrame(v))};return i?a.current=requestAnimationFrame(v):v(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[i,u,l,e,t,r.length,c]),f.useEffect(()=>{if(!i&&n.current){const g=(c.current??0)*u,p=e+t;let C=0;if(g<=e)C=0;else if(g>=p)C=r.length;else{const y=g-e;C=Math.floor(y/l)}n.current.style.width=`${C}px`}});const b=s?.waveformDrawMode||"inverted";let d;b==="inverted"?d=s?.selectedWaveFillColor||s?.waveFillColor||"white":d=s?.selectedWaveOutlineColor||s?.waveOutlineColor||"grey";const h=nt(d);return x.jsxs(wc,{children:[x.jsx(xc,{$color:h,$height:o,$top:r.index*o,$width:r.length}),x.jsx(Ic,{ref:n,$color:m,$height:o,$top:r.index*o}),x.jsx(Sc,{children:x.jsx(Sa,{...r,isSelected:!0,transparentBackground:!0})})]})},Xr={current:0},Ac=({renderPlayhead:e,color:t,samplesPerPixel:r,sampleRate:n})=>{const{isPlaying:a,currentTimeRef:s}=_t();return e({position:(s.current??0)*n/r,color:t,isPlaying:a,currentTimeRef:s,playbackStartTimeRef:Xr,audioStartPositionRef:Xr,samplesPerPixel:r,sampleRate:n,controlsOffset:0})},eo=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:r=!1,onAnnotationUpdate:n,renderPlayhead:a,showFades:s=!1,className:o})=>{const i=kt(),{isPlaying:c}=_t(),{annotations:l,activeAnnotationId:u}=rn(),m=f.useContext(on),{play:b,seekTo:d,setActiveAnnotationId:h,setAnnotations:v,setScrollContainer:g}=Vn(),{duration:p,peaksDataArray:C,sampleRate:y,waveHeight:w,timeScaleHeight:I,samplesPerPixel:S,controls:A,playoutRef:k,barWidth:M,barGap:_,fadeIn:E,fadeOut:T}=an(),[R,D]=f.useState(0),[P,F]=f.useState(0),[G,z]=f.useState(!1),fe=f.useRef(null),q=f.useCallback(K=>{fe.current=K,g(K)},[g]),ee=Math.floor(p*y/S),ye=f.useCallback(async K=>{h(K.id);try{await b(K.start)}catch(oe){console.error("waveform-playlist: Failed to start playback for annotation",K.id,oe)}},[h,b]),J=f.useCallback(K=>{v(K),n?.(K)},[v,n]),{onDragStart:ve,onDragMove:te,onDragEnd:Xe}=Ba({annotations:l,onAnnotationsChange:J,samplesPerPixel:S,sampleRate:y,duration:p,linkEndpoints:r}),Q=f.useRef(0),de=f.useCallback(K=>{const oe=K.currentTarget.getBoundingClientRect(),se=(K.clientX-oe.left)*S/y;Q.current=se,z(!0),D(se),F(se)},[S,y]),Ce=f.useCallback(K=>{if(!G)return;const oe=K.currentTarget.getBoundingClientRect(),se=(K.clientX-oe.left)*S/y;F(se)},[G,S,y]),We=f.useCallback(K=>{if(!G)return;if(z(!1),c&&k.current){const Ee=Math.max(0,Q.current);d(Ee),D(Ee),F(Ee),k.current.stop(),b(Ee);return}const oe=K.currentTarget.getBoundingClientRect(),se=(K.clientX-oe.left)*S/y,V=Math.min(R,se),X=Math.max(R,se);Math.abs(X-V)<.1?(d(V),D(V),F(V)):(D(V),F(X))},[G,R,S,y,d,c,k,b]);return C.length===0?x.jsx("div",{className:o,children:"Loading waveform..."}):x.jsx(Ia,{children:x.jsx(St.Provider,{value:{samplesPerPixel:S,sampleRate:y,zoomLevels:[S],waveHeight:w,timeScaleHeight:I,duration:p*1e3,controls:A,barWidth:M,barGap:_},children:x.jsx($n,{theme:i,backgroundColor:nt(i.waveOutlineColor),timescaleBackgroundColor:i.timescaleBackgroundColor,timescaleWidth:ee,tracksWidth:ee,controlsWidth:A.show?A.width:0,onTracksMouseDown:de,onTracksMouseMove:Ce,onTracksMouseUp:We,scrollContainerRef:q,isSelecting:G,timescale:I>0?x.jsx(ka,{}):void 0,children:x.jsxs(x.Fragment,{children:[C.map((K,oe)=>{const De=K.length>0?Math.max(...K.map(se=>se.peaks.data.length)):1;return x.jsx(Aa,{numChannels:De,backgroundColor:nt(i.waveOutlineColor),offset:0,width:ee,hasClipHeaders:!1,trackId:`media-element-track-${oe}`,isSelected:!0,children:K.map((se,V)=>{const X=se.peaks,Ee=X.length;return x.jsxs(An,{clipId:se.clipId,trackIndex:oe,clipIndex:V,trackName:se.trackName,startSample:se.startSample,durationSamples:se.durationSamples,samplesPerPixel:S,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${oe}`,children:[X.data.map(($e,ae)=>x.jsx(kc,{index:ae,data:$e,bits:X.bits,length:Ee,clipStartSample:se.startSample,clipDurationSamples:se.durationSamples},`${oe}-${V}-${ae}`)),s&&E&&E.duration>0&&x.jsx(zt,{left:0,width:Math.floor(E.duration*y/S),type:"fadeIn",curveType:E.type}),s&&T&&T.duration>0&&x.jsx(zt,{left:Ee-Math.floor(T.duration*y/S),width:Math.floor(T.duration*y/S),type:"fadeOut",curveType:T.type})]},`${oe}-${V}`)})},oe)}),l.length>0&&m&&x.jsx(yt.DragDropProvider,{onDragStart:ve,onDragMove:te,onDragEnd:Xe,modifiers:t?[Ur.RestrictToHorizontalAxis]:[],plugins:Ln,children:x.jsx(m.AnnotationBoxesWrapper,{height:30,width:ee,children:l.map((K,oe)=>{const De=K.start*y/S,se=K.end*y/S,V=e?e(K,oe):K.id;return x.jsx(m.AnnotationBox,{annotationId:K.id,annotationIndex:oe,startPosition:De,endPosition:se,label:V,color:"#ff9800",isActive:K.id===u,onClick:()=>ye(K),editable:t},K.id)})})}),R!==P&&x.jsx(ya,{startPosition:Math.min(R,P)*y/S,endPosition:Math.max(R,P)*y/S,color:i.selectionColor}),a?x.jsx(Ac,{renderPlayhead:a,color:i.playheadColor,samplesPerPixel:S,sampleRate:y}):x.jsx(Cc,{color:i.playheadColor})]})})})})},to=({height:e,renderAnnotationItem:t,onAnnotationUpdate:r,editable:n=!1,controls:a,annotationListConfig:s,scrollActivePosition:o="center",scrollActiveContainer:i="nearest"})=>{const{annotations:c,activeAnnotationId:l,continuousPlay:u}=rn(),m=lt(),{setAnnotations:b}=Vn(),d=s??{linkEndpoints:!1,continuousPlay:u},h=f.useCallback(g=>{b(g),r?.(g)},[b,r]),{AnnotationText:v}=m;return x.jsx(v,{annotations:c,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:o,scrollActiveContainer:i,editable:n,controls:n?a:void 0,annotationListConfig:d,height:e,onAnnotationUpdate:h,renderAnnotationItem:t})},_c=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:r,editable:n=!1,linkEndpoints:a=!1,onAnnotationUpdate:s,scrollActivePosition:o="center",scrollActiveContainer:i="nearest",renderPlayhead:c,showFades:l=!1,className:u})=>{const{annotations:m}=rn();return x.jsxs(x.Fragment,{children:[x.jsx(eo,{getAnnotationBoxLabel:t,editable:n,linkEndpoints:a,onAnnotationUpdate:s,renderPlayhead:c,showFades:l,className:u}),m.length>0&&x.jsx(to,{height:e,renderAnnotationItem:r,onAnnotationUpdate:s,editable:n,annotationListConfig:{linkEndpoints:a,continuousPlay:!1},scrollActivePosition:o,scrollActiveContainer:i})]})},Ec=({playback:e=!1,clipSplitting:t=!1,annotations:r=!1,additionalShortcuts:n=[]})=>{const{tracks:a,samplesPerPixel:s,sampleRate:o,playoutRef:i,duration:c}=Re(),{annotations:l,linkEndpoints:u,activeAnnotationId:m,continuousPlay:b}=Te(),{setAnnotations:d,setActiveAnnotationId:h,scrollContainerRef:v,play:g}=he(),{splitClipAtPlayhead:p}=Va({tracks:a,sampleRate:o,samplesPerPixel:s,engineRef:i}),C=[];return t&&C.push({key:"s",action:p,description:"Split clip at playhead",preventDefault:!0}),n.length>0&&C.push(...n),Za({enabled:e||C.length>0,...e?{additionalShortcuts:C}:{shortcuts:C}}),La({annotations:l,activeAnnotationId:m,onAnnotationsChange:d,onActiveAnnotationChange:h,duration:c,linkEndpoints:u,continuousPlay:b,scrollContainerRef:v,samplesPerPixel:s,sampleRate:o,onPlay:g,enabled:r&&l.length>0}),null},Kt=class Kt extends Nt.Modifier{apply(t){const{transform:r,source:n}=t;if(!n?.data||!this.options)return r;const{boundary:a,trackIndex:s,clipIndex:o}=n.data;if(a)return{x:0,y:0};const{tracks:i,samplesPerPixel:c}=this.options,l=i[s];if(!l)return r;const u=l.clips[o];if(!u)return r;const m=r.x*c,b=[...l.clips].sort((v,g)=>v.startSample-g.startSample),d=b.findIndex(v=>v.id===u.id);return{x:ra(u,m,b,d)/c,y:0}}};Kt.configure=Nt.configurator(Kt);let Ut=Kt;const Qt=class Qt extends Nt.Modifier{apply(t){const{transform:r,source:n}=t;if(!this.options||!n?.data)return r;const{boundary:a,startSample:s}=n.data;if(a)return r;const{samplesPerPixel:o}=this.options;if(this.options.mode==="timescale"){const{gridSamples:g}=this.options;if(s!==void 0){const y=s+r.x*o;return{x:(Math.round(y/g)*g-s)/o,y:0}}const p=r.x*o;return{x:Math.round(p/g)*g/o,y:0}}const{snapTo:i,bpm:c,timeSignature:l,sampleRate:u}=this.options;if(i==="off")return r;const m=i==="bar"?Mn(l):Jt(l);if(s!==void 0){const g=s+r.x*o,p=wn(g,c,u),C=xn(p,m);return{x:(ht(C,c,u)-s)/o,y:0}}const b=r.x*o,d=wn(b,c,u),h=xn(d,m);return{x:ht(h,c,u)/o,y:0}}};Qt.configure=Nt.configurator(Qt);let xt=Qt;const Mc=()=>{},Tc=({snap:e=!1,touchOptimized:t=!1,children:r})=>{const{tracks:n,samplesPerPixel:a,sampleRate:s,playoutRef:o,isDraggingRef:i,onTracksChange:c}=Re(),{setSelectedTrackId:l}=he(),u=wa(),m=e&&u!=null&&u.scaleMode==="beats"&&u.snapTo!=="off",b=e&&!m;f.useEffect(()=>{c==null&&console.warn("[waveform-playlist] ClipInteractionProvider: onTracksChange is not set on WaveformPlaylistProvider. Drag and trim edits will not be persisted.")},[c]);const d=f.useMemo(()=>{if(m&&u){const{bpm:w,timeSignature:I,snapTo:S}=u,A=S==="bar"?Mn(I):Jt(I);return k=>{const M=wn(k,w,s),_=xn(M,A);return ht(_,w,s)}}if(b){const w=Math.round(_n(a).smallStep/1e3*s);return I=>Math.round(I/w)*w}},[m,b,u,s,a]),h=Pa({touchOptimized:t}),{onDragStart:v,onDragMove:g,onDragEnd:p}=Fa({tracks:n,onTracksChange:c??Mc,samplesPerPixel:a,sampleRate:s,engineRef:o,isDraggingRef:i,snapSamplePosition:d}),C=f.useCallback(w=>{const I=w.operation?.source?.data?.trackIndex;I!==void 0&&n[I]&&l(n[I].id),v(w)},[v,n,l]),y=f.useMemo(()=>{const w=[Ur.RestrictToHorizontalAxis];return m&&u?w.push(xt.configure({mode:"beats",snapTo:u.snapTo,bpm:u.bpm,timeSignature:u.timeSignature,samplesPerPixel:a,sampleRate:s})):b&&w.push(xt.configure({mode:"timescale",gridSamples:Math.round(_n(a).smallStep/1e3*s),samplesPerPixel:a})),w.push(Ut.configure({tracks:n,samplesPerPixel:a})),w},[m,b,u,n,a,s]);return x.jsx(ic,{value:!0,children:x.jsx(yt.DragDropProvider,{sensors:h,onDragStart:C,onDragMove:g,onDragEnd:p,modifiers:y,plugins:Ln,children:r})})};exports.Tone=Qr;exports.AnnotationIntegrationProvider=tc;exports.AudioPosition=Jl;exports.AutomaticScrollCheckbox=ec;exports.ClearAllButton=zl;exports.ClipCollisionModifier=Ut;exports.ClipInteractionProvider=Tc;exports.ContinuousPlayCheckbox=nc;exports.DownloadAnnotationsButton=oc;exports.EditableCheckbox=ac;exports.ExportWavButton=sc;exports.FastForwardButton=Wl;exports.KeyboardShortcuts=Ec;exports.LinkEndpointsCheckbox=rc;exports.LoopButton=Hl;exports.MasterVolumeControl=Ul;exports.MediaElementAnnotationList=to;exports.MediaElementPlaylist=eo;exports.MediaElementPlaylistProvider=Pl;exports.MediaElementWaveform=_c;exports.PauseButton=Zl;exports.PlayButton=Vl;exports.PlaylistAnnotationList=qa;exports.PlaylistVisualization=Ja;exports.RewindButton=Gl;exports.SelectionTimeInputs=ql;exports.SetLoopRegionButton=jl;exports.SkipBackwardButton=Nl;exports.SkipForwardButton=Ol;exports.SnapToGridModifier=xt;exports.SpectrogramIntegrationProvider=mc;exports.StopButton=Ll;exports.TimeFormatSelect=Kl;exports.Waveform=bc;exports.WaveformPlaylistProvider=$l;exports.ZoomInButton=Xl;exports.ZoomOutButton=Yl;exports.createEffectChain=gl;exports.createEffectInstance=wt;exports.effectCategories=fl;exports.effectDefinitions=At;exports.getEffectDefinition=Pn;exports.getEffectsByCategory=dl;exports.getShortcutLabel=ul;exports.getWaveformDataMetadata=el;exports.loadPeaksFromWaveformData=qi;exports.loadWaveformData=Bn;exports.noDropAnimationPlugins=Ln;exports.useAnnotationDragHandlers=Ba;exports.useAnnotationIntegration=lt;exports.useAnnotationKeyboardControls=La;exports.useAudioTracks=sl;exports.useClipDragHandlers=Fa;exports.useClipInteractionEnabled=Qa;exports.useClipSplitting=Va;exports.useDragSensors=Pa;exports.useDynamicEffects=vl;exports.useDynamicTracks=Ml;exports.useExportWav=Ga;exports.useKeyboardShortcuts=Yt;exports.useMasterAnalyser=ol;exports.useMasterVolume=$a;exports.useMediaElementAnimation=_t;exports.useMediaElementControls=Vn;exports.useMediaElementData=an;exports.useMediaElementState=rn;exports.useOutputMeter=Dl;exports.usePlaybackAnimation=Me;exports.usePlaybackShortcuts=Za;exports.usePlaylistControls=he;exports.usePlaylistData=Re;exports.usePlaylistState=Te;exports.useSpectrogramIntegration=hc;exports.useTimeFormat=Ra;exports.useTrackDynamicEffects=bl;exports.useZoomControls=Da;exports.waveformDataToPeaks=Ma;
|
|
1130
1065
|
//# sourceMappingURL=index.js.map
|