@waveform-playlist/browser 9.1.1 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +73 -39
- package/dist/index.js +91 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4802 -4721
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -10
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var If=Object.create;var Yi=Object.defineProperty;var Mf=Object.getOwnPropertyDescriptor;var Af=Object.getOwnPropertyNames;var Tf=Object.getPrototypeOf,$f=Object.prototype.hasOwnProperty;var Rf=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Af(t))!$f.call(e,s)&&s!==n&&Yi(e,s,{get:()=>t[s],enumerable:!(r=Mf(t,s))||r.enumerable});return e};var Df=(e,t,n)=>(n=e!=null?If(Tf(e)):{},Rf(t||!e||!e.__esModule?Yi(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("tone"),C=require("react/jsx-runtime"),g=require("react"),P=require("styled-components"),da=require("react-dom");function Kl(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 ql=Kl(F),D=Kl(g);var oo={exports:{}},Ki;function Pf(){return Ki||(Ki=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(p){return(l=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})(p)}function c(p,v){for(var y=0;y<v.length;y++){var m=v[y];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(p,m.key,m)}}function u(p){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)})(p)}function f(p,v){return(f=Object.setPrototypeOf||function(y,m){return y.__proto__=m,y})(p,v)}function h(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}var d=(function(p){function v(b){var _,w,x,S,k,E;return(function(T,I){if(!(T instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v),w=this,_=!(x=u(v).call(this,b.id,b.length,b.buffer,b.subChunks))||l(x)!=="object"&&typeof x!="function"?h(w):x,S=h(h(_)),E=void 0,(k="subChunks")in S?Object.defineProperty(S,k,{value:E,enumerable:!0,configurable:!0,writable:!0}):S[k]=E,_.subChunks=b.subChunks.map((function(T){return new v(T)})),_}var y,m;return(function(b,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(_&&_.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),_&&f(b,_)})(v,p),y=v,(m=[{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){if(w.id==="ifil"||w.id==="iver"){if(w.length!==a.SF_VERSION_LENGTH)throw new o.ParseError("Invalid size for the '".concat(w.id,"' sub-chunk"));_[w.id]="".concat(w.getInt16(),".").concat(w.getInt16(2))}else _[w.id]=w.getString();return _}),{});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,m),v})(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(h,d){if(h.id!==d)throw new o.ParseError("Unexpected chunk ID","'".concat(d,"'"),"'".concat(h.id,"'"));if(h.length%i.SF_GENERATOR_SIZE)throw new o.ParseError("Invalid size for the '".concat(d,"' sub-chunk"));return h.iterate((function(p){var v=p.getInt16();return a.GeneratorType[v]?d==="pgen"&&l.includes(v)||d==="igen"&&c.includes(v)?null:u.includes(v)?{id:v,range:{lo:p.getByte(),hi:p.getByte()}}:{id:v,value:p.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,p){if(d.id!==p)throw new o.ParseError("Unexpected chunk ID","'".concat(p,"'"),"'".concat(d.id,"'"));if(d.length%a.SF_BAG_SIZE)throw new o.ParseError("Invalid size for the '".concat(p,"' sub-chunk"));return d.iterate((function(v){return{generatorIndex:v.getInt16(),modulatorIndex:v.getInt16()}}))},c=function(d,p,v,y,m,b){for(var _=[],w=0;w<d.length;w++){for(var x=d[w],S=d[w+1],k=x.bagIndex,E=S?S.bagIndex:p.length,T=[],I=void 0,M=k;M<E;M++){var $=u(M,p,v),A=f(M,p,y),R=A[i.GeneratorType.KeyRange]&&A[i.GeneratorType.KeyRange].range,W=A[b];if(W){var q=m[W.value];q&&T.push({keyRange:R,modulators:$,generators:A,reference:q})}else M-k==0&&(I={keyRange:R,modulators:$,generators:A})}_.push({header:x,globalZone:I,zones:T})}return _},u=function(d,p,v){var y=p[d],m=p[d+1],b=y.modulatorIndex,_=m?m.modulatorIndex:p.length;return h(b,_,v)},f=function(d,p,v){var y=p[d],m=p[d+1],b=y.generatorIndex,_=m?m.generatorIndex:p.length;return h(b,_,v)},h=function(d,p,v){for(var y={},m=d;m<p;m++){var b=v[m];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 h}));var o=4,a=38,i=4,l=10,c=4,u=22,f=46,h=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 h=0;h<f.length;h++){var d=f[h];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,h){return f in u?Object.defineProperty(u,f,{value:h,enumerable:!0,configurable:!0,writable:!0}):u[f]=h,u}var c=(function(){function u(d){var p=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=p}var f,h;return f=u,(h=[{key:"iterate",value:function(d){for(;this.position<this.chunk.length;){var p=d(this);p&&this.target.push(p)}}},{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,p=Object(o.getStringFromBuffer)(this.getBuffer(this.position,d));return this.position+=d,p}},{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,p){return this.chunk.buffer.subarray(d,d+p)}},{key:"currentPosition",get:function(){return this.position}}])&&i(f.prototype,h),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(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p})(d)}function a(d,p){return!p||o(p)!=="object"&&typeof p!="function"?(function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v})(d):p}function i(d){var p=typeof Map=="function"?new Map:void 0;return(i=function(v){if(v===null||(y=v,Function.toString.call(y).indexOf("[native code]")===-1))return v;var y;if(typeof v!="function")throw new TypeError("Super expression must either be null or a function");if(p!==void 0){if(p.has(v))return p.get(v);p.set(v,m)}function m(){return c(v,arguments,f(this).constructor)}return m.prototype=Object.create(v.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),u(m,v)})(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,p,v){return(c=l()?Reflect.construct:function(y,m,b){var _=[null];_.push.apply(_,m);var w=new(Function.bind.apply(y,_));return b&&u(w,b.prototype),w}).apply(null,arguments)}function u(d,p){return(u=Object.setPrototypeOf||function(v,y){return v.__proto__=y,v})(d,p)}function f(d){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)})(d)}s.r(r),s.d(r,"ParseError",(function(){return h}));var h=(function(d){function p(v,y,m){return(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,p),a(this,f(p).call(this,"".concat(v).concat(y&&m?", expected ".concat(y,", received ").concat(m):"")))}return(function(v,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(y&&y.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),y&&u(v,y)})(p,d),p})(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 h}));var o=s("./src/riff/parseError.ts"),a=s("./src/utils/buffer.ts"),i=s("./src/riff/riffChunk.ts"),l=function(d){var p=h(d);if(p!=="RIFF")throw new o.ParseError("Invalid file format","RIFF",p);var v=h(d,8);if(v!=="sfbk")throw new o.ParseError("Invalid signature","sfbk",v);var y=d.subarray(8),m=f(y.subarray(4));return new i.RIFFChunk(p,y.length,y,m)},c=function(d,p){var v=h(d,p),y=u(d,p+4),m=[];return v!=="RIFF"&&v!=="LIST"||(m=f(d.subarray(p+12))),new i.RIFFChunk(v,y,d.subarray(p+8),m)},u=function(d,p){return((d=d.subarray(p,p+4))[0]|d[1]<<8|d[2]<<16|d[3]<<24)>>>0},f=function(d){for(var p=[],v=0;v<=d.length-8;){var y=c(d,v);p.push(y),v=(v+=8+y.length)%2?v+1:v}return p},h=function(d){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return Object(a.getStringFromBuffer)(d.subarray(p,p+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 h=0;h<f.length;h++){var d=f[h];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,h){return f in u?Object.defineProperty(u,f,{value:h,enumerable:!0,configurable:!0,writable:!0}):u[f]=h,u}var c=(function(){function u(d,p,v,y){(function(m,b){if(!(m 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=p,this.buffer=v,this.subChunks=y}var f,h;return f=u,(h=[{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,p=arguments.length>1?arguments[1]:void 0;return Object(a.getStringFromBuffer)(this.getBuffer(d,p||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 p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,v=new o.ChunkIterator(this,p);return v.iterate(d),v.target}},{key:"getBuffer",value:function(d,p){return this.buffer.subarray(d,d+p)}}])&&i(f.prototype,h),u})()},"./src/soundFont2.ts":function(n,r,s){s.r(r),s.d(r,"SoundFont2",(function(){return p}));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(v){for(var y=1;y<arguments.length;y++){var m=arguments[y]!=null?arguments[y]:{},b=Object.keys(m);typeof Object.getOwnPropertySymbols=="function"&&(b=b.concat(Object.getOwnPropertySymbols(m).filter((function(_){return Object.getOwnPropertyDescriptor(m,_).enumerable})))),b.forEach((function(_){d(v,_,m[_])}))}return v}function f(v,y){for(var m=0;m<y.length;m++){var b=y[m];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function h(v,y,m){return y&&f(v.prototype,y),m&&f(v,m),v}function d(v,y,m){return y in v?Object.defineProperty(v,y,{value:m,enumerable:!0,configurable:!0,writable:!0}):v[y]=m,v}var p=(function(){function v(y){if((function(b,_){if(!(b instanceof _))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),!(y instanceof a.SF2Chunk)){var m=Object(i.parseBuffer)(y);y=new a.SF2Chunk(m)}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 h(v,null,[{key:"from",value:function(y){return new v(y)}}]),h(v,[{key:"getKeyData",value:function(y){var m=this,b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,_=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return Object(c.memoize)((function(w,x,S){var k=m.banks[x];if(k){var E=k.presets[S];if(E){var T=E.zones.filter((function(N){return m.isKeyInRange(N,w)}));if(T.length>0){var I=!0,M=!1,$=void 0;try{for(var A,R=T[Symbol.iterator]();!(I=(A=R.next()).done);I=!0){var W=A.value,q=W.instrument,z=q.zones.filter((function(N){return m.isKeyInRange(N,w)}));if(z.length>0){var J=!0,ee=!1,j=void 0;try{for(var se,U=z[Symbol.iterator]();!(J=(se=U.next()).done);J=!0){var ie=se.value,le=ie.sample,ge=u({},W.generators,ie.generators),Se=u({},W.modulators,ie.modulators);return{keyNumber:w,preset:E,instrument:q,sample:le,generators:ge,modulators:Se}}}catch(N){ee=!0,j=N}finally{try{J||U.return==null||U.return()}finally{if(ee)throw j}}}}}catch(N){M=!0,$=N}finally{try{I||R.return==null||R.return()}finally{if(M)throw $}}}}}return null}))(y,b,_)}},{key:"isKeyInRange",value:function(y,m){return y.keyRange===void 0||y.keyRange.lo<=m&&y.keyRange.hi>=m}},{key:"getBanks",value:function(){return this.presets.reduce((function(y,m){var b=m.header.bank;return y[b]||(y[b]={presets:[]}),y[b].presets[m.header.preset]=m,y}),[])}},{key:"getPresets",value:function(){var y=this.presetData,m=y.presetHeaders,b=y.presetZones,_=y.presetGenerators,w=y.presetModulators;return Object(l.getItemsInZone)(m,b,w,_,this.instruments,o.GeneratorType.Instrument).filter((function(x){return x.header.name!=="EOP"})).map((function(x){return{header:x.header,globalZone:x.globalZone,zones:x.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,m=y.instrumentHeaders,b=y.instrumentZones,_=y.instrumentModulators,w=y.instrumentGenerators;return Object(l.getItemsInZone)(m,b,_,w,this.samples,o.GeneratorType.SampleId).filter((function(x){return x.header.name!=="EOI"})).map((function(x){return{header:x.header,globalZone:x.globalZone,zones:x.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(m){return m.name!=="EOS"})).map((function(m){if(m.name!=="EOS"&&m.sampleRate<=0)throw new Error("Illegal sample rate of ".concat(m.sampleRate," hz in sample '").concat(m.name,"'"));return m.originalPitch>=128&&m.originalPitch<=254&&(m.originalPitch=60),m.startLoop-=m.start,m.endLoop-=m.start,{header:m,data:new Int16Array(new Uint8Array(y.sampleData.subarray(2*m.start,2*m.end)).buffer)}}))}}]),v})()},"./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(m){s.d(r,m,(function(){return l[m]}))})(a);var c=s("./src/types/key.ts");for(var a in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return c[m]}))})(a);var u=s("./src/types/metaData.ts");for(var a in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return u[m]}))})(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 h=s("./src/types/preset.ts");for(var a in h)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return h[m]}))})(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(m){s.d(r,m,(function(){return d[m]}))})(a);var p=s("./src/types/sample.ts");s.d(r,"SampleType",(function(){return p.SampleType}));var v=s("./src/types/zone.ts");for(var a in v)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS","SampleType"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return v[m]}))})(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 h}));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 h=[{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 h=a.apply(void 0,c);return i[f]=h,h}}}})}))})(oo)),oo.exports}Pf();var Le=1e3;function Co(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:h}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate,p=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(p===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 v=e.durationSamples??p;return{id:ec(),audioBuffer:t,startSample:n,durationSamples:v,offsetSamples:r,sampleRate:d,sourceDurationSamples:p,gain:s,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:h}}function Jl(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:h}=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 p=t?.duration??e.sourceDuration??c?.duration;if(p===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 v=e.duration??p;return Co({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(v*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(p*d),gain:s,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:h})}function Ql(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:ec(),name:t,clips:n,muted:r,soloed:s,volume:o,pan:a,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function ec(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function qi(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function Yr(e){return e.startSample/e.sampleRate}function Ji(e){return(e.startSample+e.durationSamples)/e.sampleRate}function Qi(e){return e.offsetSamples/e.sampleRate}function el(e){return e.durationSamples/e.sampleRate}var tl=!1;function wr(e){const t=e._param;return!t&&!tl&&(tl=!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 nl(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 Ff(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 Of(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 Lf(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 tc(e,t,n){switch(e){case"linear":return nl(t,n);case"exponential":return Ff(t,n);case"sCurve":return Of(t,n);case"logarithmic":return Lf(t,n);default:return nl(t,n)}}function rl(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=tc(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 sl(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=tc(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 Wf=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new F.Volume(this.gainToDb(e.track.gain)),this.panNode=new F.Panner(e.track.stereoPan),this.muteGain=new F.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||F.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=F.getTransport(),s=F.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=F.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)rl(o,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-a,c=a/i,u=r.gain*c;rl(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;sl(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,h=r.gain*(1-f);sl(o,t,u,r.fadeOut.type||"linear",h,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;wr(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=F.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 Bf(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 Vf=class{constructor(e){this.track=e.track,this.volumeNode=new F.Volume(this.gainToDb(e.track.gain)),this.panNode=new F.Panner(e.track.stereoPan),this.muteGain=new F.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain),this.synth=new F.PolySynth(F.Synth,e.synthOptions),this.synth.connect(this.volumeNode),this.kickSynth=new F.PolySynth(F.MembraneSynth,{voice:F.MembraneSynth,options:{pitchDecay:.05,octaves:6,envelope:{attack:.001,decay:.4,sustain:0,release:.1}}}),this.snareSynth=new F.NoiseSynth({noise:{type:"white"},envelope:{attack:.001,decay:.15,sustain:0,release:.05}}),this.cymbalSynth=new F.PolySynth(F.MetalSynth,{voice:F.MetalSynth,options:{envelope:{attack:.001,decay:.3,release:.1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5}}),this.tomSynth=new F.PolySynth(F.MembraneSynth,{voice:F.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||F.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 F.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(Bf(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=F.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;wr(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}},nc=class So{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 F.Volume(this.gainToDb(t.track.gain)),this.panNode=new F.Panner(t.track.stereoPan),this.muteGain=new F.Gain(t.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const n=t.destination||F.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 F.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){So._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${a}, preset ${i}). Subsequent missing samples will be silent.`),So._missingSampleWarned=!0);return}const c=F.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,h=l.loopMode===0?Math.max(n,f):n,d=s*s,p=c.createGain(),{attackVolEnv:v,holdVolEnv:y,decayVolEnv:m,sustainVolEnv:b,releaseVolEnv:_}=l,w=d*b;p.gain.setValueAtTime(0,r),p.gain.linearRampToValueAtTime(d,r+v),y>.001&&p.gain.setValueAtTime(d,r+v+y);const x=r+v+y;p.gain.linearRampToValueAtTime(w,x+m),p.gain.setValueAtTime(w,r+h),p.gain.linearRampToValueAtTime(0,r+h+_),u.connect(p),p.connect(this.volumeNode.input.input),this.activeSources.add(u),u.onended=()=>{this.activeSources.delete(u);try{p.disconnect()}catch(S){console.warn("[waveform-playlist] GainNode already disconnected:",S)}},u.start(r),u.stop(r+h+_)}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;wr(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}};nc._missingSampleWarned=!1;var Nf=nc,zf=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 F.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,F.getDestination(),!1);t&&(this.effectsCleanup=t)}else this.masterVolume.toDestination();e.tracks&&e.tracks.forEach(t=>{this.tracks.set(t.id,t),this.manualMuteState.set(t.id,t.muted)})}gainToDb(e){return 20*Math.log10(e)}clearCompletionEvent(){if(this._completionEventId!==null){try{F.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await F.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new Wf(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 Vf(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 Nf(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??F.now(),s=F.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=F.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=F.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=>t.stopAllSources()),this.tracks.forEach(t=>t.cancelFades()),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=F.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=F.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 F.getTransport().seconds}seekTo(e){F.getTransport().seconds=e}dispose(){if(this.clearCompletionEvent(),this._loopHandler){try{F.getTransport().off("loop",this._loopHandler)}catch(e){console.warn("[waveform-playlist] Error removing Transport loop handler:",e)}this._loopHandler=null}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 F.getContext()}get sampleRate(){return F.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Kr=null;function jf(){return Kr||(Kr=new F.Context,F.setContext(Kr)),Kr}function Zf(){return jf().rawContext}function Hf(e){let t=null,n=!1,r=0,s=!1,o=0,a=0,i=!1;function l(c){if(t){try{t.dispose()}catch(f){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",f)}t=null}r++;const u=r;t=new zf({effects:e?.effects}),i&&t.init().catch(f=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",f),i=!1});for(const f of c){const h=f.clips.filter(p=>p.audioBuffer&&!p.midiNotes),d=f.clips.filter(p=>p.midiNotes&&p.midiNotes.length>0);if(h.length>0){const p=Math.min(...h.map(Yr)),v=Math.max(...h.map(Ji)),y={id:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:p,endTime:v},m=h.map(b=>({buffer:b.audioBuffer,startTime:Yr(b)-p,duration:el(b),offset:Qi(b),fadeIn:b.fadeIn,fadeOut:b.fadeOut,gain:b.gain}));t.addTrack({clips:m,track:y,effects:f.effects})}if(d.length>0){const p=Math.min(...d.map(Yr)),v=Math.max(...d.map(Ji)),m={id:h.length>0?`${f.id}:midi`:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:p,endTime:v},b=d.map(_=>({notes:_.midiNotes,startTime:Yr(_)-p,duration:el(_),offset:Qi(_)}));if(e?.soundFontCache?.isLoaded){const _=d[0],x=_.midiChannel===9,S=_.midiProgram??0;t.addSoundFontTrack({clips:b,track:m,soundFontCache:e.soundFontCache,programNumber:S,isPercussion:x,effects:f.effects})}else e?.soundFontCache&&console.warn(`[waveform-playlist] SoundFont not loaded for track "${f.name}" — falling back to PolySynth.`),t.addMidiTrack({clips:b,track:m,effects:f.effects})}}t.applyInitialSoloState(),t.setLoop(s,o,a),t.setOnPlaybackComplete(()=>{u===r&&(n=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(c){l(c)},play(c,u){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 f=u!==void 0?u-c:void 0;t.play(F.now(),c,f),n=!0},pause(){t?.pause(),n=!1},stop(){t?.stop(),n=!1},seek(c){t?.seekTo(c)},getCurrentTime(){return t?.getCurrentTime()??0},isPlaying(){return n},setMasterVolume(c){t?.setMasterGain(c)},setTrackVolume(c,u){t?.getTrack(c)?.setVolume(u)},setTrackMute(c,u){t?.setMute(c,u)},setTrackSolo(c,u){t?.setSolo(c,u)},setTrackPan(c,u){t?.getTrack(c)?.setPan(u)},setLoop(c,u,f){s=c,o=u,a=f,t?.setLoop(c,u,f)},dispose(){try{t?.dispose()}catch(c){console.warn("[waveform-playlist] Error disposing playout:",c)}t=null,n=!1}}}function rc(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 ko(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 Gf(e,t){return Math.floor(e/t)*t}function Uf(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=Co({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=Co({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 sc(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 ao(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 Xf(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 ol(e,t){return Math.max(0,Math.min(e,t))}var Yf=44100,Kf=1024,qf=[256,512,1024,2048,4096,8192],al=.1,Jf=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??Yf,this._zoomLevels=[...e.zoomLevels??qf],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??Kf,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:ao(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?.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=qi(r.clips),i=a.findIndex(c=>c.id===t),l=rc(o,n,a,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=c.clips.map((f,h)=>h===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(al*this._sampleRate);if(!sc(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}=Uf(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=qi(s.clips),l=i.findIndex(f=>f.id===t),c=Math.floor(al*this._sampleRate),u=ko(a,r,n,i,l,c);u!==0&&(this._tracks=this._tracks.map(f=>{if(f.id!==e)return f;const h=f.clips.map((d,p)=>p!==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:h}}),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=ao(this._tracks);this._currentTime=ol(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=ao(this._tracks);this._currentTime=ol(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=Xf(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)}},Qf=Symbol.for("preact-signals");function Fs(){if(Jt>1)Jt--;else{for(var e,t=!1;pr!==void 0;){var n=pr;for(pr=void 0,Eo++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&ac(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Eo=0,Jt--,t)throw e}}function Qt(e){if(Jt>0)return e();Jt++;try{return e()}finally{Fs()}}var me=void 0;function we(e){var t=me;me=void 0;try{return e()}finally{me=t}}var pr=void 0,Jt=0,Eo=0,vs=0;function oc(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=Qf;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 Ct(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=oc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Eo>100)throw new Error("Cycle detected");this.v=e,this.i++,vs++,Jt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Fs()}}}});function $r(e,t){return new st(e,t)}function ac(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 ic(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 lc(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 yn(e,t){st.call(this,void 0),this.x=e,this.s=void 0,this.g=vs-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}yn.prototype=new st;yn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===vs))return!0;if(this.g=vs,this.f|=1,this.i>0&&!ac(this))return this.f&=-2,!0;var e=me;try{ic(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,lc(this),this.f&=-2,!0};yn.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)};yn.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)}};yn.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(yn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=oc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function il(e,t){return new yn(e,t)}function cc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Jt++;var n=me;me=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,fa(e),r}finally{me=n,Fs()}}}function fa(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,cc(e)}function eh(e){if(me!==this)throw new Error("Out-of-order effect");lc(this),me=e,this.f&=-2,8&this.f&&fa(this),Fs()}function jn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}jn.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()}};jn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,cc(this),ic(this),Jt++;var e=me;return me=this,eh.bind(this,e)};jn.prototype.N=function(){2&this.f||(this.f|=2,this.o=pr,pr=this)};jn.prototype.d=function(){this.f|=8,1&this.f||fa(this)};jn.prototype.dispose=function(){this.d()};function Ct(e,t){var n=new jn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var th=Object.create,ha=Object.defineProperty,nh=Object.defineProperties,rh=Object.getOwnPropertyDescriptor,sh=Object.getOwnPropertyDescriptors,ll=Object.getOwnPropertySymbols,oh=Object.prototype.hasOwnProperty,ah=Object.prototype.propertyIsEnumerable,ih=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},Io=(e,t,n)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lh=(e,t)=>{for(var n in t||(t={}))oh.call(t,n)&&Io(e,n,t[n]);if(ll)for(var n of ll(t))ah.call(t,n)&&Io(e,n,t[n]);return e},ch=(e,t)=>nh(e,sh(t)),cl=(e,t)=>ha(e,"name",{value:t,configurable:!0}),uh=e=>{var t;return[,,,th((t=void 0)!=null?t:null)]},uc=["class","method","getter","setter","accessor","field","value","get","set"],rr=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,dh=(e,t,n,r,s)=>({kind:uc[e],name:t,metadata:r,addInitializer:o=>n._?Zn("Already initialized"):s.push(rr(o||null))}),dc=(e,t)=>Io(t,ih("metadata"),e[3]),an=(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},Hn=(e,t,n,r,s,o)=>{var a,i,l,c,u,f=t&7,h=!!(t&8),d=!!(t&16),p=f>3?e.length+1:f?h?1:2:0,v=uc[f+5],y=f>3&&(e[p-1]=[]),m=e[p]||(e[p]=[]),b=f&&(!d&&!h&&(s=s.prototype),f<5&&(f>3||!d)&&rh(f<4?s:{get[n](){return pn(this,o)},set[n](w){return Yt(this,o,w)}},n));f?d&&f<4&&cl(o,(f>2?"set ":f>1?"get ":"")+n):cl(s,n);for(var _=r.length-1;_>=0;_--)c=dh(f,n,l={},e[3],m),f&&(c.static=h,c.private=d,u=c.access={has:d?w=>fh(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?pn:hh)(w,s,f^4?o:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>Yt(w,s,x,f^4?o:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?o:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?rr(i)&&(f>4?y.unshift(i):f?d?o=i:b[v]=i:s=i):typeof i!="object"||i===null?Zn("Object expected"):(rr(a=i.get)&&(b.get=a),rr(a=i.set)&&(b.set=a),rr(a=i.init)&&y.unshift(a));return f||dc(e,s),b&&ha(s,n,b),d?f^4?o:b:s},pa=(e,t,n)=>t.has(e)||Zn("Cannot "+n),fh=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),pn=(e,t,n)=>(pa(e,t,"read from private field"),n?n.call(e):t.get(e)),qr=(e,t,n)=>t.has(e)?Zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Yt=(e,t,n,r)=>(pa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),hh=(e,t,n)=>(pa(e,t,"access private method"),n);function ys(e,t){if(t){let n;return il(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return il(e)}function _r(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)=>!_r(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=>!_r(e[o],t[o]))}return!1}function de({get:e},t){return{init(n){return $r(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ie(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=ys(e.bind(this)),n.set(this,r)),r.value}}function io(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,ch(lh({},s),{enumerable:e}))})}}function Rr(...e){const t=e.map(n=>Ct(n));return()=>t.forEach(n=>n())}var fc,hc,pc,mc,gc,vc,tt,ma,lo,Mo,Ao,qe,ga,co,yc,To,va,uo,$o,Ro;vc=[de],gc=[de],mc=[de],pc=[io()],hc=[io()],fc=[io()];var tn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,an(tt,5,this),qr(this,qe),qr(this,ma,an(tt,8,this)),an(tt,11,this),qr(this,ga,an(tt,12,this)),an(tt,15,this),qr(this,va,an(tt,16,this)),an(tt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return pn(this,qe,$o)}get initial(){return pn(this,qe,Mo)}get previous(){return pn(this,qe,yc)}set current(e){const t=we(()=>pn(this,qe,$o));e&&t&&this.equals(t,e)||Qt(()=>{pn(this,qe,Mo)||Yt(this,qe,e,Ao),Yt(this,qe,t,To),Yt(this,qe,e,Ro)})}reset(e=this.defaultValue){Qt(()=>{Yt(this,qe,void 0,To),Yt(this,qe,e,Ao),Yt(this,qe,e,Ro)})}};tt=uh();ma=new WeakMap;qe=new WeakSet;ga=new WeakMap;va=new WeakMap;lo=Hn(tt,20,"#initial",vc,qe,ma),Mo=lo.get,Ao=lo.set;co=Hn(tt,20,"#previous",gc,qe,ga),yc=co.get,To=co.set;uo=Hn(tt,20,"#current",mc,qe,va),$o=uo.get,Ro=uo.set;Hn(tt,2,"current",pc,tn);Hn(tt,2,"initial",hc,tn);Hn(tt,2,"previous",fc,tn);dc(tt,tn);function fo(e){return we(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var ph=Object.create,bc=Object.defineProperty,mh=Object.getOwnPropertyDescriptor,ul=Object.getOwnPropertySymbols,gh=Object.prototype.hasOwnProperty,vh=Object.prototype.propertyIsEnumerable,wc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Os=e=>{throw TypeError(e)},dl=Math.pow,Do=(e,t,n)=>t in e?bc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yh=(e,t)=>{for(var n in t||(t={}))gh.call(t,n)&&Do(e,n,t[n]);if(ul)for(var n of ul(t))vh.call(t,n)&&Do(e,n,t[n]);return e},bh=e=>{var t;return[,,,ph((t=e?.[wc("metadata")])!=null?t:null)]},_c=["class","method","getter","setter","accessor","field","value","get","set"],xc=e=>e!==void 0&&typeof e!="function"?Os("Function expected"):e,wh=(e,t,n,r,s)=>({kind:_c[e],name:t,metadata:r,addInitializer:o=>n._?Os("Already initialized"):s.push(xc(o||null))}),_h=(e,t)=>Do(t,wc("metadata"),e[3]),xh=(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},Cc=(e,t,n,r,s,o)=>{for(var a,i,l,c,u=t&7,f=!1,h=!1,d=2,p=_c[u+5],v=e[d]||(e[d]=[]),y=(s=s.prototype,mh(s,n)),m=r.length-1;m>=0;m--)l=wh(u,n,i={},e[3],v),l.static=f,l.private=h,c=l.access={has:b=>n in b},c.get=b=>b[n],a=(0,r[m])(y[p],l),i._=1,xc(a)&&(y[p]=a);return y&&bc(s,n,y),s},Sc=(e,t,n)=>t.has(e)||Os("Cannot "+n),Ch=(e,t,n)=>(Sc(e,t,"read from private field"),t.get(e)),Sh=(e,t,n)=>t.has(e)?Os("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),kh=(e,t,n,r)=>(Sc(e,t,"write to private field"),t.set(e,n),n),Pt=class Po{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Po(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 Po(t,n)}},Dr=class cn{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 cn(s+t,r+n,o,a);return l.scale=yh({},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 cn))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 cn?Eh(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 cn(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 cn.from(t).intersectionRatio(cn.from(n))}};function Eh(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 kc,Ec,Fo,ss,Pr,Ls=class extends(Fo=tn,Ec=[Ie],kc=[Ie],Fo){constructor(t){const n=Pt.from(t);super(n,(r,s)=>Pt.equals(r,s)),xh(Pr,5,this),Sh(this,ss,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-Ch(this,ss),i=l=>Math.round(l/a*100);Qt(()=>{kh(this,ss,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}}};Pr=bh(Fo);ss=new WeakMap;Cc(Pr,2,"delta",Ec,Ls);Cc(Pr,2,"direction",kc,Ls);_h(Pr,Ls);function Oo({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(dl(r,2)+dl(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 Ic=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ic||{}),Mc=Object.values(Ic),Ih=Object.create,ya=Object.defineProperty,Mh=Object.defineProperties,Ah=Object.getOwnPropertyDescriptor,Th=Object.getOwnPropertyDescriptors,bs=Object.getOwnPropertySymbols,Ac=Object.prototype.hasOwnProperty,Tc=Object.prototype.propertyIsEnumerable,$c=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Gn=e=>{throw TypeError(e)},Lo=(e,t,n)=>t in e?ya(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rc=(e,t)=>{for(var n in t||(t={}))Ac.call(t,n)&&Lo(e,n,t[n]);if(bs)for(var n of bs(t))Tc.call(t,n)&&Lo(e,n,t[n]);return e},Dc=(e,t)=>Mh(e,Th(t)),fl=(e,t)=>ya(e,"name",{value:t,configurable:!0}),Pc=(e,t)=>{var n={};for(var r in e)Ac.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&bs)for(var r of bs(e))t.indexOf(r)<0&&Tc.call(e,r)&&(n[r]=e[r]);return n},Un=e=>{var t;return[,,,Ih((t=e?.[$c("metadata")])!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],sr=e=>e!==void 0&&typeof e!="function"?Gn("Function expected"):e,$h=(e,t,n,r,s)=>({kind:Fc[e],name:t,metadata:r,addInitializer:o=>n._?Gn("Already initialized"):s.push(sr(o||null))}),bn=(e,t)=>Lo(t,$c("metadata"),e[3]),re=(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},ue=(e,t,n,r,s,o)=>{var a,i,l,c,u,f=t&7,h=!!(t&8),d=!!(t&16),p=f>3?e.length+1:f?h?1:2:0,v=Fc[f+5],y=f>3&&(e[p-1]=[]),m=e[p]||(e[p]=[]),b=f&&(!d&&!h&&(s=s.prototype),f<5&&(f>3||!d)&&Ah(f<4?s:{get[n](){return He(this,o)},set[n](w){return wt(this,o,w)}},n));f?d&&f<4&&fl(o,(f>2?"set ":f>1?"get ":"")+n):fl(s,n);for(var _=r.length-1;_>=0;_--)c=$h(f,n,l={},e[3],m),f&&(c.static=h,c.private=d,u=c.access={has:d?w=>Rh(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?He:Dh)(w,s,f^4?o:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>wt(w,s,x,f^4?o:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?o:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?sr(i)&&(f>4?y.unshift(i):f?d?o=i:b[v]=i:s=i):typeof i!="object"||i===null?Gn("Object expected"):(sr(a=i.get)&&(b.get=a),sr(a=i.set)&&(b.set=a),sr(a=i.init)&&y.unshift(a));return f||bn(e,s),b&&ya(s,n,b),d?f^4?o:b:s},ba=(e,t,n)=>t.has(e)||Gn("Cannot "+n),Rh=(e,t)=>Object(t)!==t?Gn('Cannot use the "in" operator on this value'):e.has(t),He=(e,t,n)=>(ba(e,t,"read from private field"),n?n.call(e):t.get(e)),be=(e,t,n)=>t.has(e)?Gn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),wt=(e,t,n,r)=>(ba(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Dh=(e,t,n)=>(ba(e,t,"access private method"),n);function Oc(e,t){return{plugin:e,options:t}}function Xn(e){return t=>Oc(e,t)}function wa(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Lc,xr,_a,os;Lc=[de];var it=class{constructor(e,t){this.manager=e,this.options=t,be(this,_a,re(xr,8,this,!1)),re(xr,11,this),be(this,os,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return we(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=Ct(e.bind(this));return He(this,os).add(t),t}destroy(){He(this,os).forEach(e=>e())}static configure(e){return Oc(this,e)}};xr=Un(null);_a=new WeakMap;os=new WeakMap;ue(xr,4,"disabled",Lc,it,_a);bn(xr,it);var Fr=class extends it{},as,ho=class{constructor(e){this.manager=e,this.instances=new Map,be(this,as,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(wa).reduceRight((r,s)=>r.some(({plugin:o})=>o===s.plugin)?r:[s,...r],[]),n=t.map(({plugin:r})=>r);for(const r of He(this,as))if(!n.includes(r)){if(r.prototype instanceof Fr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);wt(this,as,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()}};as=new WeakMap;function Ph(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Jr=[],Tn,$n,Fh=class extends it{constructor(e){super(e),be(this,Tn),be(this,$n),this.computeCollisions=this.computeCollisions.bind(this),wt(this,$n,$r(Jr)),this.destroy=Rr(()=>{const t=this.computeCollisions(),n=we(()=>this.manager.dragOperation.position.current);if(t!==Jr){const r=He(this,Tn);if(wt(this,Tn,n),r&&n.x==r.x&&n.y==r.y)return}else wt(this,Tn,void 0);He(this,$n).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){we(()=>{e?He(this,$n).value=this.computeCollisions():wt(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 Jr;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?Jr:(i.sort(Ph),i)}get collisions(){return He(this,$n).value}};Tn=new WeakMap;$n=new WeakMap;var Oh=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)}},Lh=class extends Oh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function is(e,t=!0){let n=!1;return Dc(Rc({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Wh=class extends Fr{constructor(e){super(e);const t=(r,s)=>r.map(({id:o})=>o).join("")===s.map(({id:o})=>o).join("");let n=[];this.destroy=Rr(()=>{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=is({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()}))})})}},xa=(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))(xa||{}),Ca=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Ca||{}),Wc,Bc,Vc,Nc,zc,jc,Zc,xt,Sa;Zc=[de],jc=[Ie],zc=[Ie],Nc=[Ie],Vc=[Ie],Bc=[Ie],Wc=[Ie];var jt=class{constructor(){re(xt,5,this),be(this,Sa,re(xt,8,this,"idle")),re(xt,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}};xt=Un(null);Sa=new WeakMap;ue(xt,4,"value",Zc,jt,Sa);ue(xt,2,"current",jc,jt);ue(xt,2,"idle",zc,jt);ue(xt,2,"initializing",Nc,jt);ue(xt,2,"initialized",Vc,jt);ue(xt,2,"dragging",Bc,jt);ue(xt,2,"dropped",Wc,jt);bn(xt,jt);var Bh=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=is({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=is({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=is({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 h=(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=h})})}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=Ct(()=>{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()})}},Hc,Gc,Uc,Xc,at,ka,Ea,Ia,Ma;Xc=[de],Uc=[de],Gc=[de],Hc=[de];var nn=class{constructor(e,t){be(this,ka,re(at,8,this)),re(at,11,this),be(this,Ea,re(at,12,this)),re(at,15,this),be(this,Ia,re(at,16,this)),re(at,19,this),be(this,Ma,re(at,20,this)),re(at,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)}};at=Un(null);ka=new WeakMap;Ea=new WeakMap;Ia=new WeakMap;Ma=new WeakMap;ue(at,4,"manager",Xc,nn,ka);ue(at,4,"id",Uc,nn,Ea);ue(at,4,"data",Gc,nn,Ia);ue(at,4,"disabled",Hc,nn,Ma);bn(at,nn);var hl=class{constructor(){this.map=$r(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=Rr(...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}},Yc,Kc,qc,Jc,Qc,eu,Wo,nt,Aa,Ta,$a,Ft=class extends(Wo=nn,eu=[de],Qc=[de],Jc=[de],qc=[Ie],Kc=[Ie],Yc=[Ie],Wo){constructor(t,n){var r=t,{modifiers:s,type:o,sensors:a}=r,i=Pc(r,["modifiers","type","sensors"]);super(i,n),re(nt,5,this),be(this,Aa,re(nt,8,this)),re(nt,11,this),be(this,Ta,re(nt,12,this)),re(nt,15,this),be(this,$a,re(nt,16,this,this.isDragSource?"dragging":"idle")),re(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=Un(Wo);Aa=new WeakMap;Ta=new WeakMap;$a=new WeakMap;ue(nt,4,"type",eu,Ft,Aa);ue(nt,4,"modifiers",Qc,Ft,Ta);ue(nt,4,"status",Jc,Ft,$a);ue(nt,2,"isDropping",qc,Ft);ue(nt,2,"isDragging",Kc,Ft);ue(nt,2,"isDragSource",Yc,Ft);bn(nt,Ft);var tu,nu,ru,su,ou,au,Bo,ze,Ra,Da,Pa,Fa,Oa,Ot=class extends(Bo=nn,au=[de],ou=[de],su=[de],ru=[de],nu=[de],tu=[Ie],Bo){constructor(t,n){var r=t,{accept:s,collisionDetector:o,collisionPriority:a,type:i}=r,l=Pc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),re(ze,5,this),be(this,Ra,re(ze,8,this)),re(ze,11,this),be(this,Da,re(ze,12,this)),re(ze,15,this),be(this,Pa,re(ze,16,this)),re(ze,19,this),be(this,Fa,re(ze,20,this)),re(ze,23,this),be(this,Oa,re(ze,24,this)),re(ze,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}};ze=Un(Bo);Ra=new WeakMap;Da=new WeakMap;Pa=new WeakMap;Fa=new WeakMap;Oa=new WeakMap;ue(ze,4,"accept",au,Ot,Ra);ue(ze,4,"type",ou,Ot,Da);ue(ze,4,"collisionDetector",su,Ot,Pa);ue(ze,4,"collisionPriority",ru,Ot,Fa);ue(ze,4,"shape",nu,Ot,Oa);ue(ze,2,"isDropTarget",tu,Ot);bn(ze,Ot);var Wn=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Vh=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)}},ls,iu=class{constructor(e){this.options=e,be(this,ls)}set controller(e){wt(this,ls,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=He(this,ls))==null||t.activate(e)}};ls=new WeakMap;var Cr=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Nh=class{constructor(e){this.draggables=new hl,this.droppables=new hl,this.plugins=new ho(e),this.sensors=new ho(e),this.modifiers=new ho(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 Cr)return this.modifiers.register(e,t);if(e.prototype instanceof Wn)return this.sensors.register(e,t);if(e.prototype instanceof it)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof nn)return e instanceof Ft?this.draggables.unregister(e.id,e):e instanceof Ot?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Cr)return this.modifiers.unregister(e);if(e.prototype instanceof Wn)return this.sensors.unregister(e);if(e.prototype instanceof it)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()}},lu,cu,uu,du,fu,hu,pu,mu,gu,or,cs,Rn,Re,La,Wa,Ba,Va,Na,ar;gu=[Ie],mu=[de],pu=[de],hu=[de],fu=[de],du=[de],uu=[Ie],cu=[Ie],lu=[Ie];var Rt=class{constructor(e){re(Re,5,this),be(this,or),be(this,cs),be(this,Rn,new tn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new jt,be(this,La,re(Re,8,this,!1)),re(Re,11,this),be(this,Wa,re(Re,12,this,null)),re(Re,15,this),be(this,Ba,re(Re,16,this,null)),re(Re,19,this),be(this,Va,re(Re,20,this,null)),re(Re,23,this),be(this,Na,re(Re,24,this,[])),re(Re,27,this),this.position=new Ls({x:0,y:0}),be(this,ar,{x:0,y:0}),wt(this,or,e)}get shape(){const{current:e,initial:t,previous:n}=He(this,Rn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?He(this,Rn).current=e:He(this,Rn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=He(this,or).registry.draggables.get(t);return n&&wt(this,cs,n),(e=n??He(this,cs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=He(this,or).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(Dc(Rc({},this.snapshot()),{transform:n}));return wt(this,ar,n),n}snapshot(){return we(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:He(this,ar),shape:this.shape?fo(this.shape):null,position:fo(this.position),status:fo(this.status),canceled:this.canceled}))}reset(){Qt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,He(this,Rn).reset(),this.position.reset({x:0,y:0}),wt(this,ar,{x:0,y:0}),this.modifiers=[]})}};Re=Un(null);or=new WeakMap;cs=new WeakMap;Rn=new WeakMap;La=new WeakMap;Wa=new WeakMap;Ba=new WeakMap;Va=new WeakMap;Na=new WeakMap;ar=new WeakMap;ue(Re,2,"shape",gu,Rt);ue(Re,4,"canceled",mu,Rt,La);ue(Re,4,"activatorEvent",pu,Rt,Wa);ue(Re,4,"sourceIdentifier",hu,Rt,Ba);ue(Re,4,"targetIdentifier",fu,Rt,Va);ue(Re,4,"modifiers",du,Rt,Na);ue(Re,2,"source",uu,Rt);ue(Re,2,"target",cu,Rt);ue(Re,2,"transform",lu,Rt);bn(Re,Rt);var zh={get rendering(){return Promise.resolve()}};function Vt(e,t){return typeof e=="function"?e(t):e??t}var jh=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(h=>h.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Vt(r.plugins,[]),o=Vt(r.sensors,[]),a=Vt(r.modifiers,[]),i=(n=r.renderer)!=null?n:zh,l=new Lh(this),c=new Nh(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new Bh(this),this.dragOperation=new Rt(this),this.collisionObserver=new Fh(this),this.plugins=[Wh,...s],this.modifiers=a,this.sensors=o;const{destroy:u}=this,f=Rr(()=>{var h,d,p;const v=we(()=>this.dragOperation.modifiers),y=this.modifiers;for(const m of v)y.includes(m)||m.destroy();this.dragOperation.modifiers=(p=(d=(h=this.dragOperation.source)==null?void 0:h.modifiers)==null?void 0:d.map(m=>{const{plugin:b,options:_}=wa(m);return new b(this,_)}))!=null?p: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}},vu=e=>{throw TypeError(e)},za=(e,t,n)=>t.has(e)||vu("Cannot "+n),ae=(e,t,n)=>(za(e,t,"read from private field"),t.get(e)),ot=(e,t,n)=>t.has(e)?vu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pt=(e,t,n,r)=>(za(e,t,"write to private field"),t.set(e,n),n),yu=(e,t,n)=>(za(e,t,"access private method"),n);function Ws(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Zh(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=(Ws(s)?s.getKeyframes():[]).filter(t);if(a.length>0)return[a[a.length-1],r]}return null}function Bs(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 ja(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Or(e){return"nodeType"in e}function St(e){var t,n,r;return e?ja(e)?e:Or(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 Za(e){const{Document:t}=St(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function mn(e){return!e||ja(e)?!1:e instanceof St(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function bu(e){return e instanceof St(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function wn(e){return e?ja(e)?e.document:Or(e)?Za(e)?e:mn(e)||bu(e)?e.ownerDocument:document:document:document}function Hh(e){var t,n,r,s;const{documentElement:o}=wn(e),a=St(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 Gh(e,t){if(Uh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Uh(e){return e.tagName==="DETAILS"}function ws(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(!Gh(f)){const _=f.getBoundingClientRect(),w=n*(_.bottom-_.top),x=n*(_.right-_.left),S=n*(_.bottom-_.top),k=n*(_.right-_.left);l={top:Math.max(l.top,_.top-w),right:Math.min(l.right,_.right+x),bottom:Math.min(l.bottom,_.bottom+S),left:Math.max(l.left,_.left-k),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}f=f.parentElement}const h=u.visualViewport,d=(s=h?.offsetTop)!=null?s:0,p=(o=h?.offsetLeft)!=null?o:0,v=(a=h?.width)!=null?a:u.innerWidth,y=(i=h?.height)!=null?i:u.innerHeight,m=n*y,b=n*v;return l={top:Math.max(l.top,d-m),right:Math.min(l.right,p+v+b),bottom:Math.min(l.bottom,d+y+m),left:Math.max(l.left,p-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 Bn(e){return{x:e.clientX,y:e.clientY}}var wu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vo(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(...Vo(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(...Vo(s.document,t))}}catch{}return n}function Ha(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function _u(){var e,t;const n=Ha()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Ga(e){return!e||!Or(e)?!1:e instanceof St(e).ShadowRoot}function _s(e){if(e&&Or(e)){let t=e.getRootNode();if(Ga(t))return t;if(t instanceof Document)return t}return wn(e)}function xu(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Xh(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(pl(o)&&pl(i)&&(o.type!=="file"&&(o.value=i.value),o.type==="radio"&&o.name&&(o.name=`Cloned__${o.name}`)),ml(o)&&ml(i)&&i.width>0&&i.height>0){const l=o.getContext("2d");l?.drawImage(i,0,0)}}),n}function pl(e){return"value"in e}function ml(e){return e.tagName==="CANVAS"}function Cu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Yh(r)){const{contentDocument:s}=r;if(s){const{left:o,top:a}=r.getBoundingClientRect();return Cu(s,{x:t-o,y:n-a})}}return r}function Yh(e){return e?.tagName==="IFRAME"}var gl=new WeakMap;function Kh(e){return!!e.closest(`
|
|
1
|
+
"use strict";var Lf=Object.create;var el=Object.defineProperty;var Bf=Object.getOwnPropertyDescriptor;var Wf=Object.getOwnPropertyNames;var Vf=Object.getPrototypeOf,Nf=Object.prototype.hasOwnProperty;var zf=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Wf(t))!Nf.call(e,s)&&s!==n&&el(e,s,{get:()=>t[s],enumerable:!(r=Bf(t,s))||r.enumerable});return e};var jf=(e,t,n)=>(n=e!=null?Lf(Vf(e)):{},zf(t||!e||!e.__esModule?el(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("tone"),S=require("react/jsx-runtime"),p=require("react"),P=require("styled-components"),mo=require("react-dom");function rc(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 sc=rc(O),D=rc(p);var ca={exports:{}},tl;function Zf(){return tl||(tl=1,(function(e,t){(function(n,r){e.exports=r()})(window,(function(){return(function(n){var r={};function s(a){if(r[a])return r[a].exports;var o=r[a]={i:a,l:!1,exports:{}};return n[a].call(o.exports,o,o.exports,s),o.l=!0,o.exports}return s.m=n,s.c=r,s.d=function(a,o,i){s.o(a,o)||Object.defineProperty(a,o,{enumerable:!0,get:i})},s.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},s.t=function(a,o){if(1&o&&(a=s(a)),8&o||4&o&&typeof a=="object"&&a&&a.__esModule)return a;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:a}),2&o&&typeof a!="string")for(var l in a)s.d(i,l,(function(c){return a[c]}).bind(null,l));return i},s.n=function(a){var o=a&&a.__esModule?function(){return a.default}:function(){return a};return s.d(o,"a",o),o},s.o=function(a,o){return Object.prototype.hasOwnProperty.call(a,o)},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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=s("./src/chunks/index.ts");function l(h){return(l=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 c(h,v){for(var y=0;y<v.length;y++){var g=v[y];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(h,g.key,g)}}function u(h){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)})(h)}function f(h,v){return(f=Object.setPrototypeOf||function(y,g){return y.__proto__=g,y})(h,v)}function m(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(b){var w,_,x,C,k,I;return(function(E,T){if(!(E instanceof T))throw new TypeError("Cannot call a class as a function")})(this,v),_=this,w=!(x=u(v).call(this,b.id,b.length,b.buffer,b.subChunks))||l(x)!=="object"&&typeof x!="function"?m(_):x,C=m(m(w)),I=void 0,(k="subChunks")in C?Object.defineProperty(C,k,{value:I,enumerable:!0,configurable:!0,writable:!0}):C[k]=I,w.subChunks=b.subChunks.map((function(E){return new v(E)})),w}var y,g;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)})(v,h),y=v,(g=[{key:"getMetaData",value:function(){if(this.id!=="LIST")throw new a.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks.reduce((function(w,_){if(_.id==="ifil"||_.id==="iver"){if(_.length!==o.SF_VERSION_LENGTH)throw new a.ParseError("Invalid size for the '".concat(_.id,"' sub-chunk"));w[_.id]="".concat(_.getInt16(),".").concat(_.getInt16(2))}else w[_.id]=_.getString();return w}),{});if(!b.ifil)throw new a.ParseError("Missing required 'ifil' sub-chunk");if(!b.INAM)throw new a.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 a.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks[0];if(b.id!=="smpl")throw new a.ParseError("Invalid chunk signature","'smpl'","'".concat(b.id,"'"));return b.buffer}},{key:"getPresetData",value:function(){if(this.id!=="LIST")throw new a.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,g),v})(a.RIFFChunk)},"./src/chunks/generators.ts":function(n,r,s){s.r(r),s.d(r,"getGenerators",(function(){return f}));var a=s("./src/riff/index.ts"),o=s("./src/types/index.ts"),i=s("./src/constants.ts"),l=[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],c=[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],f=function(m,d){if(m.id!==d)throw new a.ParseError("Unexpected chunk ID","'".concat(d,"'"),"'".concat(m.id,"'"));if(m.length%i.SF_GENERATOR_SIZE)throw new a.ParseError("Invalid size for the '".concat(d,"' sub-chunk"));return m.iterate((function(h){var v=h.getInt16();return o.GeneratorType[v]?d==="pgen"&&l.includes(v)||d==="igen"&&c.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(n,r,s){s.r(r);var a=s("./src/chunks/instruments/index.ts");s.d(r,"getInstrumentHeaders",(function(){return a.getInstrumentHeaders}));var o=s("./src/chunks/presets/index.ts");s.d(r,"getPresetHeaders",(function(){return o.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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="inst")throw new a.ParseError("Unexpected chunk ID","'inst'","'".concat(l.id,"'"));if(l.length%o.SF_INSTRUMENT_HEADER_SIZE)throw new a.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 a=s("./src/chunks/instruments/headers.ts");s.d(r,"getInstrumentHeaders",(function(){return a.getInstrumentHeaders}))},"./src/chunks/modulators.ts":function(n,r,s){s.r(r),s.d(r,"getModulators",(function(){return l}));var a=s("./src/riff/index.ts"),o=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 a.ParseError("Unexpected chunk ID","'".concat(u,"'"),"'".concat(c.id,"'"));if(c.length%o.SF_MODULATOR_SIZE)throw new a.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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="phdr")throw new a.ParseError("Invalid chunk ID","'phdr'","'".concat(l.id,"'"));if(l.length%o.SF_PRESET_HEADER_SIZE)throw new a.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 a=s("./src/chunks/presets/headers.ts");s.d(r,"getPresetHeaders",(function(){return a.getPresetHeaders}))},"./src/chunks/samples/headers.ts":function(n,r,s){s.r(r),s.d(r,"getSampleHeaders",(function(){return i}));var a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="shdr")throw new a.ParseError("Unexpected chunk ID","'shdr'","'".concat(l.id,"'"));if(l.length%o.SF_SAMPLE_HEADER_SIZE)throw new a.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 a=s("./src/chunks/samples/headers.ts");s.d(r,"getSampleHeaders",(function(){return a.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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=s("./src/types/index.ts"),l=function(d,h){if(d.id!==h)throw new a.ParseError("Unexpected chunk ID","'".concat(h,"'"),"'".concat(d.id,"'"));if(d.length%o.SF_BAG_SIZE)throw new a.ParseError("Invalid size for the '".concat(h,"' sub-chunk"));return d.iterate((function(v){return{generatorIndex:v.getInt16(),modulatorIndex:v.getInt16()}}))},c=function(d,h,v,y,g,b){for(var w=[],_=0;_<d.length;_++){for(var x=d[_],C=d[_+1],k=x.bagIndex,I=C?C.bagIndex:h.length,E=[],T=void 0,R=k;R<I;R++){var A=u(R,h,v),M=f(R,h,y),$=M[i.GeneratorType.KeyRange]&&M[i.GeneratorType.KeyRange].range,F=M[b];if(F){var L=g[F.value];L&&E.push({keyRange:$,modulators:A,generators:M,reference:L})}else R-k==0&&(T={keyRange:$,modulators:A,generators:M})}w.push({header:x,globalZone:T,zones:E})}return w},u=function(d,h,v){var y=h[d],g=h[d+1],b=y.modulatorIndex,w=g?g.modulatorIndex:h.length;return m(b,w,v)},f=function(d,h,v){var y=h[d],g=h[d+1],b=y.generatorIndex,w=g?g.generatorIndex:h.length;return m(b,w,v)},m=function(d,h,v){for(var y={},g=d;g<h;g++){var b=v[g];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 a})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return o})),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 m}));var a=4,o=38,i=4,l=10,c=4,u=22,f=46,m=22050},"./src/index.ts":function(n,r,s){s.r(r);var a=s("./src/types/index.ts");for(var o in a)["default"].indexOf(o)<0&&(function(u){s.d(r,u,(function(){return a[u]}))})(o);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 a=s("./src/utils/index.ts");function o(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function i(u,f){for(var m=0;m<f.length;m++){var d=f[m];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,m){return f in u?Object.defineProperty(u,f,{value:m,enumerable:!0,configurable:!0,writable:!0}):u[f]=m,u}var c=(function(){function u(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;o(this,u),l(this,"target",[]),l(this,"chunk",void 0),l(this,"position",0),this.chunk=d,this.position=h}var f,m;return f=u,(m=[{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(a.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,m),u})()},"./src/riff/index.ts":function(n,r,s){s.r(r);var a=s("./src/riff/chunkIterator.ts");s.d(r,"ChunkIterator",(function(){return a.ChunkIterator}));var o=s("./src/riff/parseError.ts");s.d(r,"ParseError",(function(){return o.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 a(d){return(a=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||a(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||(y=v,Function.toString.call(y).indexOf("[native code]")===-1))return v;var y;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,g)}function g(){return c(v,arguments,f(this).constructor)}return g.prototype=Object.create(v.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u(g,v)})(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,v){return(c=l()?Reflect.construct:function(y,g,b){var w=[null];w.push.apply(w,g);var _=new(Function.bind.apply(y,w));return b&&u(_,b.prototype),_}).apply(null,arguments)}function u(d,h){return(u=Object.setPrototypeOf||function(v,y){return v.__proto__=y,v})(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 m}));var m=(function(d){function h(v,y,g){return(function(b,w){if(!(b instanceof w))throw new TypeError("Cannot call a class as a function")})(this,h),o(this,f(h).call(this,"".concat(v).concat(y&&g?", expected ".concat(y,", received ").concat(g):"")))}return(function(v,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(y&&y.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),y&&u(v,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 m}));var a=s("./src/riff/parseError.ts"),o=s("./src/utils/buffer.ts"),i=s("./src/riff/riffChunk.ts"),l=function(d){var h=m(d);if(h!=="RIFF")throw new a.ParseError("Invalid file format","RIFF",h);var v=m(d,8);if(v!=="sfbk")throw new a.ParseError("Invalid signature","sfbk",v);var y=d.subarray(8),g=f(y.subarray(4));return new i.RIFFChunk(h,y.length,y,g)},c=function(d,h){var v=m(d,h),y=u(d,h+4),g=[];return v!=="RIFF"&&v!=="LIST"||(g=f(d.subarray(h+12))),new i.RIFFChunk(v,y,d.subarray(h+8),g)},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=[],v=0;v<=d.length-8;){var y=c(d,v);h.push(y),v=(v+=8+y.length)%2?v+1:v}return h},m=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(n,r,s){s.r(r),s.d(r,"RIFFChunk",(function(){return c}));var a=s("./src/riff/chunkIterator.ts"),o=s("./src/utils/index.ts");function i(u,f){for(var m=0;m<f.length;m++){var d=f[m];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,m){return f in u?Object.defineProperty(u,f,{value:m,enumerable:!0,configurable:!0,writable:!0}):u[f]=m,u}var c=(function(){function u(d,h,v,y){(function(g,b){if(!(g 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=v,this.subChunks=y}var f,m;return f=u,(m=[{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 a.ChunkIterator(this,d)}},{key:"iterate",value:function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,v=new a.ChunkIterator(this,h);return v.iterate(d),v.target}},{key:"getBuffer",value:function(d,h){return this.buffer.subarray(d,d+h)}}])&&i(f.prototype,m),u})()},"./src/soundFont2.ts":function(n,r,s){s.r(r),s.d(r,"SoundFont2",(function(){return h}));var a=s("./src/types/index.ts"),o=s("./src/chunk.ts"),i=s("./src/riff/index.ts"),l=s("./src/chunks/index.ts"),c=s("./src/utils/index.ts");function u(v){for(var y=1;y<arguments.length;y++){var g=arguments[y]!=null?arguments[y]:{},b=Object.keys(g);typeof Object.getOwnPropertySymbols=="function"&&(b=b.concat(Object.getOwnPropertySymbols(g).filter((function(w){return Object.getOwnPropertyDescriptor(g,w).enumerable})))),b.forEach((function(w){d(v,w,g[w])}))}return v}function f(v,y){for(var g=0;g<y.length;g++){var b=y[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function m(v,y,g){return y&&f(v.prototype,y),g&&f(v,g),v}function d(v,y,g){return y in v?Object.defineProperty(v,y,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[y]=g,v}var h=(function(){function v(y){if((function(b,w){if(!(b instanceof w))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),!(y instanceof o.SF2Chunk)){var g=Object(i.parseBuffer)(y);y=new o.SF2Chunk(g)}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 m(v,null,[{key:"from",value:function(y){return new v(y)}}]),m(v,[{key:"getKeyData",value:function(y){var g=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(_,x,C){var k=g.banks[x];if(k){var I=k.presets[C];if(I){var E=I.zones.filter((function(j){return g.isKeyInRange(j,_)}));if(E.length>0){var T=!0,R=!1,A=void 0;try{for(var M,$=E[Symbol.iterator]();!(T=(M=$.next()).done);T=!0){var F=M.value,L=F.instrument,z=L.zones.filter((function(j){return g.isKeyInRange(j,_)}));if(z.length>0){var q=!0,Y=!1,ne=void 0;try{for(var G,J=z[Symbol.iterator]();!(q=(G=J.next()).done);q=!0){var ae=G.value,ue=ae.sample,de=u({},F.generators,ae.generators),Me=u({},F.modulators,ae.modulators);return{keyNumber:_,preset:I,instrument:L,sample:ue,generators:de,modulators:Me}}}catch(j){Y=!0,ne=j}finally{try{q||J.return==null||J.return()}finally{if(Y)throw ne}}}}}catch(j){R=!0,A=j}finally{try{T||$.return==null||$.return()}finally{if(R)throw A}}}}}return null}))(y,b,w)}},{key:"isKeyInRange",value:function(y,g){return y.keyRange===void 0||y.keyRange.lo<=g&&y.keyRange.hi>=g}},{key:"getBanks",value:function(){return this.presets.reduce((function(y,g){var b=g.header.bank;return y[b]||(y[b]={presets:[]}),y[b].presets[g.header.preset]=g,y}),[])}},{key:"getPresets",value:function(){var y=this.presetData,g=y.presetHeaders,b=y.presetZones,w=y.presetGenerators,_=y.presetModulators;return Object(l.getItemsInZone)(g,b,_,w,this.instruments,a.GeneratorType.Instrument).filter((function(x){return x.header.name!=="EOP"})).map((function(x){return{header:x.header,globalZone:x.globalZone,zones:x.zones.map((function(C){return{keyRange:C.keyRange,generators:C.generators,modulators:C.modulators,instrument:C.reference}}))}}))}},{key:"getInstruments",value:function(){var y=this.presetData,g=y.instrumentHeaders,b=y.instrumentZones,w=y.instrumentModulators,_=y.instrumentGenerators;return Object(l.getItemsInZone)(g,b,w,_,this.samples,a.GeneratorType.SampleId).filter((function(x){return x.header.name!=="EOI"})).map((function(x){return{header:x.header,globalZone:x.globalZone,zones:x.zones.map((function(C){return{keyRange:C.keyRange,generators:C.generators,modulators:C.modulators,sample:C.reference}}))}}))}},{key:"getSamples",value:function(){var y=this;return this.presetData.sampleHeaders.filter((function(g){return g.name!=="EOS"})).map((function(g){if(g.name!=="EOS"&&g.sampleRate<=0)throw new Error("Illegal sample rate of ".concat(g.sampleRate," hz in sample '").concat(g.name,"'"));return g.originalPitch>=128&&g.originalPitch<=254&&(g.originalPitch=60),g.startLoop-=g.start,g.endLoop-=g.start,{header:g,data:new Int16Array(new Uint8Array(y.sampleData.subarray(2*g.start,2*g.end)).buffer)}}))}}]),v})()},"./src/types/bank.ts":function(n,r){},"./src/types/generator.ts":function(n,r,s){var a,o;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 o})),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"})(o||(o={}));var l=(i(a={},o.StartAddrsOffset,0),i(a,o.EndAddrsOffset,0),i(a,o.StartLoopAddrsOffset,0),i(a,o.EndLoopAddrsOffset,0),i(a,o.StartAddrsCoarseOffset,0),i(a,o.ModLFOToPitch,0),i(a,o.VibLFOToPitch,0),i(a,o.ModEnvToPitch,0),i(a,o.InitialFilterFc,13500),i(a,o.InitialFilterQ,0),i(a,o.ModLFOToFilterFc,0),i(a,o.ModEnvToFilterFc,0),i(a,o.EndAddrsCoarseOffset,0),i(a,o.ModLFOToVolume,0),i(a,o.ChorusEffectsSend,0),i(a,o.ReverbEffectsSend,0),i(a,o.Pan,0),i(a,o.DelayModLFO,-12e3),i(a,o.FreqModLFO,0),i(a,o.DelayVibLFO,-12e3),i(a,o.FreqVibLFO,0),i(a,o.DelayModEnv,-12e3),i(a,o.AttackModEnv,-12e3),i(a,o.HoldModEnv,-12e3),i(a,o.DecayModEnv,-12e3),i(a,o.SustainModEnv,0),i(a,o.ReleaseModEnv,-12e3),i(a,o.KeyNumToModEnvHold,0),i(a,o.KeyNumToModEnvDecay,0),i(a,o.DelayVolEnv,-12e3),i(a,o.AttackVolEnv,-12e3),i(a,o.HoldVolEnv,-12e3),i(a,o.DecayVolEnv,-12e3),i(a,o.SustainVolEnv,0),i(a,o.ReleaseVolEnv,-12e3),i(a,o.KeyNumToVolEnvHold,0),i(a,o.KeyNumToVolEnvDecay,0),i(a,o.StartLoopAddrsCoarseOffset,0),i(a,o.KeyNum,-1),i(a,o.Velocity,-1),i(a,o.InitialAttenuation,0),i(a,o.EndLoopAddrsCoarseOffset,0),i(a,o.CoarseTune,0),i(a,o.FineTune,0),i(a,o.SampleModes,0),i(a,o.ScaleTuning,100),i(a,o.ExclusiveClass,0),i(a,o.OverridingRootKey,-1),a)},"./src/types/index.ts":function(n,r,s){s.r(r);var a=s("./src/types/bank.ts");for(var o in a)["default"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return a[y]}))})(o);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 o in l)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(g){s.d(r,g,(function(){return l[g]}))})(o);var c=s("./src/types/key.ts");for(var o in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(g){s.d(r,g,(function(){return c[g]}))})(o);var u=s("./src/types/metaData.ts");for(var o in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(g){s.d(r,g,(function(){return u[g]}))})(o);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 m=s("./src/types/preset.ts");for(var o in m)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(g){s.d(r,g,(function(){return m[g]}))})(o);var d=s("./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(g){s.d(r,g,(function(){return d[g]}))})(o);var h=s("./src/types/sample.ts");s.d(r,"SampleType",(function(){return h.SampleType}));var v=s("./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(g){s.d(r,g,(function(){return v[g]}))})(o)},"./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 a})),s.d(r,"ControllerPolarity",(function(){return o})),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 m}));var a,o,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"})(a||(a={})),(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"})(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 m=[{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialFilterFc,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:-2400,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.ChannelPressure},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:1},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:7},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.MidiController,index:10},value:1e3,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:11},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ReverbEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:91},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ChorusEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:93},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.CoarseTune,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheel},value:12700,valueSource:{type:a.Linear,polarity:o.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 a;s.r(r),s.d(r,"SampleType",(function(){return a})),(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"})(a||(a={}))},"./src/types/zone.ts":function(n,r){},"./src/utils/buffer.ts":function(n,r,s){s.r(r),s.d(r,"getStringFromBuffer",(function(){return a}));var a=function(o){var i=new TextDecoder("utf8").decode(o),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 a=s("./src/utils/buffer.ts");s.d(r,"getStringFromBuffer",(function(){return a.getStringFromBuffer}));var o=s("./src/utils/memoize.ts");s.d(r,"memoize",(function(){return o.memoize}))},"./src/utils/memoize.ts":function(n,r,s){s.r(r),s.d(r,"memoize",(function(){return a}));var a=function(o){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 m=o.apply(void 0,c);return i[f]=m,m}}}})}))})(ca)),ca.exports}Zf();var Le=1e3;function Ea(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}=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 v=e.durationSamples??h;return{id:ic(),audioBuffer:t,startSample:n,durationSamples:v,offsetSamples:r,sampleRate:d,sourceDurationSamples:h,gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}}function ac(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}=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 v=e.duration??h;return Ea({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(v*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(h*d),gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m})}function oc(e){const{name:t,clips:n=[],muted:r=!1,soloed:s=!1,volume:a=1,pan:o=0,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}=e;return{id:ic(),name:t,clips:n,muted:r,soloed:s,volume:a,pan:o,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function ic(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function nl(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function Hf(e,t){return Math.floor(e/t)}function Gf(e,t,n){return Math.ceil(e*n/t)}var Zn=192;function go(e,t=Zn){const[,n]=e;return t*(4/n)}function lc(e,t=Zn){const[n]=e;return n*go(e,t)}function mr(e,t,n,r=Zn){return Math.round(e*60*n/(t*r))}function rl(e,t,n,r=Zn){return Math.round(e*r*t/(60*n))}function sl(e,t){return Math.round(e/t)*t}function Uf(e,t,n=Zn){const r=lc(t,n),s=go(t,n),a=Math.floor(e/r)+1,o=Math.floor(e%r/s)+1;return o===1?`${a}`:`${a}.${o}`}function Jr(e){return e.startSample/e.sampleRate}function al(e){return(e.startSample+e.durationSamples)/e.sampleRate}function ol(e){return e.offsetSamples/e.sampleRate}function il(e){return e.durationSamples/e.sampleRate}function cc(e,t,n){return Math.floor((e+t)/n)-Math.floor(e/n)}var ll=!1;function xr(e){const t=e._param;return!t&&!ll&&(ll=!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 cl(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const a=s/r;n[s]=t?a:1-a}return n}function Xf(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const a=s/r,o=t?s:e-1-s;n[o]=Math.exp(2*a-1)/Math.E}return n}function Yf(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 Kf(e,t,n=10){const r=new Float32Array(e);for(let s=0;s<e;s++){const a=t?s:e-1-s,o=s/e;r[a]=Math.log(1+n*o)/Math.log(1+n)}return r}function uc(e,t,n){switch(e){case"linear":return cl(t,n);case"exponential":return Xf(t,n);case"sCurve":return Yf(t,n);case"logarithmic":return Kf(t,n);default:return cl(t,n)}}function ul(e,t,n,r="linear",s=0,a=1){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(a,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(a,.001),t+n);else{const o=uc(r,1e4,!0),i=new Float32Array(o.length),l=a-s;for(let c=0;c<o.length;c++)i[c]=s+o[c]*l;e.setValueCurveAtTime(i,t,n)}}function dl(e,t,n,r="linear",s=1,a=0){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(a,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(a,.001),t+n);else{const o=uc(r,1e4,!1),i=new Float32Array(o.length),l=s-a;for(let c=0;c<o.length;c++)i[c]=a+o[c]*l;e.setValueCurveAtTime(i,t,n)}}var qf=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new O.Volume(this.gainToDb(e.track.gain)),this.panNode=new O.Panner(e.track.stereoPan),this.muteGain=new O.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||O.getDestination();if(e.effects){const o=e.effects(this.muteGain,t,!1);o&&(this.effectsCleanup=o)}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=O.getTransport(),s=O.getContext().rawContext,a=this.volumeNode.input.input;this.scheduledClips=n.map(o=>{const i=s.createGain();i.gain.value=o.gain,i.connect(a);const l=this.track.startTime+o.startTime,c=r.schedule(u=>{l<this._scheduleGuardOffset||this.startClipSource(o,i,u)},l);return{clipInfo:o,fadeGainNode:i,scheduleId:c}})}startClipSource(e,t,n,r,s){const o=O.getContext().rawContext.createBufferSource();o.buffer=e.buffer,o.connect(t);const i=r??e.offset,l=s??e.duration;try{o.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),o.disconnect();return}this.activeSources.add(o),o.onended=()=>{this.activeSources.delete(o)}}setScheduleGuardOffset(e){this._scheduleGuardOffset=e}startMidClipSources(e,t){for(const{clipInfo:n,fadeGainNode:r}of this.scheduledClips){const s=this.track.startTime+n.startTime,a=s+n.duration;if(s<e&&a>e){const o=e-s,i=n.offset+o,l=n.duration-o;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,a=s.gain;a.cancelScheduledValues(0);const o=n-r.offset;if(r.fadeIn&&o<r.fadeIn.duration){const i=r.fadeIn.duration;if(o<=0)ul(a,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,c=o/i,u=r.gain*c;ul(a,t,l,r.fadeIn.type||"linear",u,r.gain)}}else a.setValueAtTime(r.gain,t);if(r.fadeOut){const l=r.duration-r.fadeOut.duration-o;if(l>0){const c=t+l;dl(a,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,m=r.gain*(1-f);dl(a,t,u,r.fadeOut.type||"linear",m,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 a=t-r+n.clipInfo.offset;this.scheduleFades(n,e,a)}else{const a=r-t;this.scheduleFades(n,e+a,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;xr(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=O.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 Jf(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 Qf=class{constructor(e){this.track=e.track,this.volumeNode=new O.Volume(this.gainToDb(e.track.gain)),this.panNode=new O.Panner(e.track.stereoPan),this.muteGain=new O.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain),this.synth=new O.PolySynth(O.Synth,e.synthOptions),this.synth.connect(this.volumeNode),this.kickSynth=new O.PolySynth(O.MembraneSynth,{voice:O.MembraneSynth,options:{pitchDecay:.05,octaves:6,envelope:{attack:.001,decay:.4,sustain:0,release:.1}}}),this.snareSynth=new O.NoiseSynth({noise:{type:"white"},envelope:{attack:.001,decay:.15,sustain:0,release:.05}}),this.cymbalSynth=new O.PolySynth(O.MetalSynth,{voice:O.MetalSynth,options:{envelope:{attack:.001,decay:.3,release:.1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5}}),this.tomSynth=new O.PolySynth(O.MembraneSynth,{voice:O.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||O.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,a=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}}),o=new O.Part((i,l)=>{l.duration>0&&this.triggerNote(l.midi,l.note,l.duration,i,l.velocity,l.channel)},a);return o.start(0),{clipInfo:n,part:o}})}triggerNote(e,t,n,r,s,a){if(a===9)switch(Jf(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 a of n.notes){const o=a.time-n.offset,i=r+Math.max(0,o),l=i+a.duration;if(i<e&&l>e){const c=l-e;try{this.triggerNote(a.midi,a.name,c,t,a.velocity,a.channel)}catch(u){console.warn(`[waveform-playlist] Failed to start mid-clip MIDI note "${a.name}" on track "${this.id}":`,u)}}}}}stopAllSources(){const e=O.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;xr(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}},dc=class Ia{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 O.Volume(this.gainToDb(t.track.gain)),this.panNode=new O.Panner(t.track.stereoPan),this.muteGain=new O.Gain(t.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const n=t.destination||O.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}),a=this.track.startTime+r.startTime,o=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:a+u,note:l.name,midi:l.midi,duration:Math.max(0,f),velocity:l.velocity,channel:l.channel}}),i=new O.Part((l,c)=>{c.duration>0&&this.triggerNote(c.midi,c.duration,l,c.velocity,c.channel)},o);return i.start(0),{clipInfo:r,part:i}})}triggerNote(t,n,r,s,a){const o=a===9?128:this.bankNumber,i=a===9?0:this.programNumber,l=this.soundFontCache.getAudioBuffer(t,o,i);if(!l){Ia._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${o}, preset ${i}). Subsequent missing samples will be silent.`),Ia._missingSampleWarned=!0);return}const c=O.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,m=l.loopMode===0?Math.max(n,f):n,d=s*s,h=c.createGain(),{attackVolEnv:v,holdVolEnv:y,decayVolEnv:g,sustainVolEnv:b,releaseVolEnv:w}=l,_=d*b;h.gain.setValueAtTime(0,r),h.gain.linearRampToValueAtTime(d,r+v),y>.001&&h.gain.setValueAtTime(d,r+v+y);const x=r+v+y;h.gain.linearRampToValueAtTime(_,x+g),h.gain.setValueAtTime(_,r+m),h.gain.linearRampToValueAtTime(0,r+m+w),u.connect(h),h.connect(this.volumeNode.input.input),this.activeSources.add(u),u.onended=()=>{this.activeSources.delete(u);try{h.disconnect()}catch(C){console.warn("[waveform-playlist] GainNode already disconnected:",C)}},u.start(r),u.stop(r+m+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,a=s+r.duration;if(s<t&&a>t)for(const o of r.notes){const i=o.time-r.offset,l=s+Math.max(0,i),c=l+o.duration;if(l<t&&c>t){const u=c-t;try{this.triggerNote(o.midi,u,n,o.velocity,o.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;xr(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}};dc._missingSampleWarned=!1;var eh=dc,th=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 O.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,O.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{O.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await O.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new qf(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 Qf(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??O.now(),s=O.getTransport();this.clearCompletionEvent();const a=t??0;this.tracks.forEach(o=>{o.cancelFades(),o.prepareFades(r,a)}),n!==void 0&&(this._completionEventId=s.scheduleOnce(()=>{this._completionEventId=null;try{this.onPlaybackCompleteCallback?.()}catch(o){console.warn("[waveform-playlist] Error in playback completion callback:",o)}},a+n));try{s.state!=="stopped"&&s.stop(),this.tracks.forEach(o=>o.stopAllSources()),s.loopStart=this._loopStart,s.loopEnd=this._loopEnd,s.loop=this._loopEnabled,this.tracks.forEach(o=>o.setScheduleGuardOffset(a)),t!==void 0?s.start(r,t):s.start(r),s._clock._lastUpdate=r,this.tracks.forEach(o=>{o.startMidClipSources(a,r)})}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=O.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=O.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=>t.stopAllSources()),this.tracks.forEach(t=>t.cancelFades()),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=O.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=O.now();this.tracks.forEach(a=>{try{a.stopAllSources(),a.cancelFades(),a.setScheduleGuardOffset(this._loopStart),a.startMidClipSources(this._loopStart,s),a.prepareFades(s,this._loopStart)}catch(o){console.warn(`[waveform-playlist] Error re-scheduling track "${a.id}" on loop:`,o)}})},r.on("loop",this._loopHandler)):!e&&this._loopHandler&&(r.off("loop",this._loopHandler),this._loopHandler=null)}getCurrentTime(){return O.getTransport().seconds}seekTo(e){O.getTransport().seconds=e}dispose(){if(this.clearCompletionEvent(),this._loopHandler){try{O.getTransport().off("loop",this._loopHandler)}catch(e){console.warn("[waveform-playlist] Error removing Transport loop handler:",e)}this._loopHandler=null}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 O.getContext()}get sampleRate(){return O.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Qr=null;function nh(){return Qr||(Qr=new O.Context,O.setContext(Qr)),Qr}function rh(){return nh().rawContext}function sh(e){let t=null,n=!1,r=0,s=!1,a=0,o=0,i=!1;function l(c){if(t){try{t.dispose()}catch(f){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",f)}t=null}r++;const u=r;t=new th({effects:e?.effects}),i&&t.init().catch(f=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",f),i=!1});for(const f of c){const m=f.clips.filter(h=>h.audioBuffer&&!h.midiNotes),d=f.clips.filter(h=>h.midiNotes&&h.midiNotes.length>0);if(m.length>0){const h=Math.min(...m.map(Jr)),v=Math.max(...m.map(al)),y={id:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:v},g=m.map(b=>({buffer:b.audioBuffer,startTime:Jr(b)-h,duration:il(b),offset:ol(b),fadeIn:b.fadeIn,fadeOut:b.fadeOut,gain:b.gain}));t.addTrack({clips:g,track:y,effects:f.effects})}if(d.length>0){const h=Math.min(...d.map(Jr)),v=Math.max(...d.map(al)),g={id:m.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:v},b=d.map(w=>({notes:w.midiNotes,startTime:Jr(w)-h,duration:il(w),offset:ol(w)}));if(e?.soundFontCache?.isLoaded){const w=d[0],x=w.midiChannel===9,C=w.midiProgram??0;t.addSoundFontTrack({clips:b,track:g,soundFontCache:e.soundFontCache,programNumber:C,isPercussion:x,effects:f.effects})}else e?.soundFontCache&&console.warn(`[waveform-playlist] SoundFont not loaded for track "${f.name}" — falling back to PolySynth.`),t.addMidiTrack({clips:b,track:g,effects:f.effects})}}t.applyInitialSoloState(),t.setLoop(s,a,o),t.setOnPlaybackComplete(()=>{u===r&&(n=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(c){l(c)},play(c,u){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 f=u!==void 0?u-c:void 0;t.play(O.now(),c,f),n=!0},pause(){t?.pause(),n=!1},stop(){t?.stop(),n=!1},seek(c){t?.seekTo(c)},getCurrentTime(){return t?.getCurrentTime()??0},isPlaying(){return n},setMasterVolume(c){t?.setMasterGain(c)},setTrackVolume(c,u){t?.getTrack(c)?.setVolume(u)},setTrackMute(c,u){t?.setMute(c,u)},setTrackSolo(c,u){t?.setSolo(c,u)},setTrackPan(c,u){t?.getTrack(c)?.setPan(u)},setLoop(c,u,f){s=c,a=u,o=f,t?.setLoop(c,u,f)},dispose(){try{t?.dispose()}catch(c){console.warn("[waveform-playlist] Error disposing playout:",c)}t=null,n=!1}}}function fc(e,t,n,r){let s=t;const a=-e.startSample;if(s=Math.max(s,a),r>0){const o=n[r-1],l=o.startSample+o.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 hc(e,t,n,r,s,a){let o=t;if(n==="left"){if(o=Math.max(o,-e.startSample),o=Math.max(o,-e.offsetSamples),s>0){const i=r[s-1],l=i.startSample+i.durationSamples;o=Math.max(o,l-e.startSample)}o=Math.min(o,e.durationSamples-a)}else if(o=Math.max(o,a-e.durationSamples),o=Math.min(o,e.sourceDurationSamples-e.offsetSamples-e.durationSamples),s<r.length-1){const i=r[s+1];o=Math.min(o,i.startSample-e.startSample-e.durationSamples)}return o}function ah(e,t){return Math.floor(e/t)*t}function oh(e,t){const n=t-e.startSample,r=e.durationSamples-n,s=e.name?`${e.name} (1)`:void 0,a=e.name?`${e.name} (2)`:void 0,o=Ea({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=Ea({startSample:t,durationSamples:r,offsetSamples:e.offsetSamples+n,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:a,color:e.color,fadeOut:e.fadeOut,audioBuffer:e.audioBuffer,waveformData:e.waveformData});return{left:o,right:i}}function pc(e,t,n){const r=e.startSample+e.durationSamples;if(t<=e.startSample||t>=r)return!1;const s=t-e.startSample,a=r-t;return s>=n&&a>=n}function ua(e){let t=0;for(const n of e)for(const r of n.clips){const a=(r.startSample+r.durationSamples)/r.sampleRate;t=Math.max(t,a)}return t}function ih(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 a=Math.abs(t[s]-e);a<r&&(r=a,n=s)}return n}function fl(e,t){return Math.max(0,Math.min(e,t))}var lh=44100,ch=1024,uh=[256,512,1024,2048,4096,8192],hl=.1,dh=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??lh,this._zoomLevels=[...e.zoomLevels??uh],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??ch,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:ua(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?.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 a=r.clips[s],o=nl(r.clips),i=o.findIndex(c=>c.id===t),l=fc(a,n,o,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=c.clips.map((f,m)=>m===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 a=r.clips[s],o=Math.floor(hl*this._sampleRate);if(!pc(a,n,o)){console.warn(`[waveform-playlist/engine] splitClip: cannot split clip "${t}" at sample ${n} (clip range: ${a.startSample}–${a.startSample+a.durationSamples}, minDuration: ${o})`);return}const{left:i,right:l}=oh(a,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 a=s.clips.findIndex(f=>f.id===t);if(a===-1){console.warn(`[waveform-playlist/engine] trimClip: clip "${t}" not found in track "${e}"`);return}const o=s.clips[a],i=nl(s.clips),l=i.findIndex(f=>f.id===t),c=Math.floor(hl*this._sampleRate),u=hc(o,r,n,i,l,c);u!==0&&(this._tracks=this._tracks.map(f=>{if(f.id!==e)return f;const m=f.clips.map((d,h)=>h!==a?d:n==="left"?{...d,startSample:d.startSample+u,offsetSamples:d.offsetSamples+u,durationSamples:d.durationSamples-u}:{...d,durationSamples:d.durationSamples+u});return{...f,clips:m}}),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=ua(this._tracks);this._currentTime=fl(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=ua(this._tracks);this._currentTime=fl(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=ih(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)}},fh=Symbol.for("preact-signals");function Vs(){if(Kt>1)Kt--;else{for(var e,t=!1;gr!==void 0;){var n=gr;for(gr=void 0,Ma++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&gc(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Ma=0,Kt--,t)throw e}}function qt(e){if(Kt>0)return e();Kt++;try{return e()}finally{Vs()}}var ve=void 0;function we(e){var t=ve;ve=void 0;try{return e()}finally{ve=t}}var gr=void 0,Kt=0,Ma=0,_s=0;function mc(e){if(ve!==void 0){var t=e.n;if(t===void 0||t.t!==ve)return t={i:0,S:e,p:ve.s,n:void 0,t:ve,e:void 0,x:void 0,r:t},ve.s!==void 0&&(ve.s.n=t),ve.s=t,e.n=t,32&ve.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=ve.s,t.n=void 0,ve.s.n=t,ve.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=fh;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 xt(function(){var n=t.value,r=ve;ve=void 0;try{e(n)}finally{ve=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=ve;ve=void 0;try{return this.value}finally{ve=e}};Object.defineProperty(st.prototype,"value",{get:function(){var e=mc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ma>100)throw new Error("Cycle detected");this.v=e,this.i++,_s++,Kt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Vs()}}}});function Rr(e,t){return new st(e,t)}function gc(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 vc(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 yc(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 gn(e,t){st.call(this,void 0),this.x=e,this.s=void 0,this.g=_s-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}gn.prototype=new st;gn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===_s))return!0;if(this.g=_s,this.f|=1,this.i>0&&!gc(this))return this.f&=-2,!0;var e=ve;try{vc(this),ve=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 ve=e,yc(this),this.f&=-2,!0};gn.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)};gn.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)}};gn.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(gn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=mc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function pl(e,t){return new gn(e,t)}function bc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Kt++;var n=ve;ve=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,vo(e),r}finally{ve=n,Vs()}}}function vo(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 hh(e){if(ve!==this)throw new Error("Out-of-order effect");yc(this),ve=e,this.f&=-2,8&this.f&&vo(this),Vs()}function Hn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}Hn.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()}};Hn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,bc(this),vc(this),Kt++;var e=ve;return ve=this,hh.bind(this,e)};Hn.prototype.N=function(){2&this.f||(this.f|=2,this.o=gr,gr=this)};Hn.prototype.d=function(){this.f|=8,1&this.f||vo(this)};Hn.prototype.dispose=function(){this.d()};function xt(e,t){var n=new Hn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var ph=Object.create,yo=Object.defineProperty,mh=Object.defineProperties,gh=Object.getOwnPropertyDescriptor,vh=Object.getOwnPropertyDescriptors,ml=Object.getOwnPropertySymbols,yh=Object.prototype.hasOwnProperty,bh=Object.prototype.propertyIsEnumerable,wh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Gn=e=>{throw TypeError(e)},Aa=(e,t,n)=>t in e?yo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_h=(e,t)=>{for(var n in t||(t={}))yh.call(t,n)&&Aa(e,n,t[n]);if(ml)for(var n of ml(t))bh.call(t,n)&&Aa(e,n,t[n]);return e},xh=(e,t)=>mh(e,vh(t)),gl=(e,t)=>yo(e,"name",{value:t,configurable:!0}),Sh=e=>{var t;return[,,,ph((t=void 0)!=null?t:null)]},wc=["class","method","getter","setter","accessor","field","value","get","set"],sr=e=>e!==void 0&&typeof e!="function"?Gn("Function expected"):e,Ch=(e,t,n,r,s)=>({kind:wc[e],name:t,metadata:r,addInitializer:a=>n._?Gn("Already initialized"):s.push(sr(a||null))}),_c=(e,t)=>Aa(t,wh("metadata"),e[3]),sn=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},Un=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,v=wc[f+5],y=f>3&&(e[h-1]=[]),g=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&gh(f<4?s:{get[n](){return fn(this,a)},set[n](_){return Ut(this,a,_)}},n));f?d&&f<4&&gl(a,(f>2?"set ":f>1?"get ":"")+n):gl(s,n);for(var w=r.length-1;w>=0;w--)c=Ch(f,n,l={},e[3],g),f&&(c.static=m,c.private=d,u=c.access={has:d?_=>kh(s,_):_=>n in _},f^3&&(u.get=d?_=>(f^1?fn:Eh)(_,s,f^4?a:b.get):_=>_[n]),f>2&&(u.set=d?(_,x)=>Ut(_,s,x,f^4?a:b.set):(_,x)=>_[n]=x)),i=(0,r[w])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?sr(i)&&(f>4?y.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?Gn("Object expected"):(sr(o=i.get)&&(b.get=o),sr(o=i.set)&&(b.set=o),sr(o=i.init)&&y.unshift(o));return f||_c(e,s),b&&yo(s,n,b),d?f^4?a:b:s},bo=(e,t,n)=>t.has(e)||Gn("Cannot "+n),kh=(e,t)=>Object(t)!==t?Gn('Cannot use the "in" operator on this value'):e.has(t),fn=(e,t,n)=>(bo(e,t,"read from private field"),n?n.call(e):t.get(e)),es=(e,t,n)=>t.has(e)?Gn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ut=(e,t,n,r)=>(bo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Eh=(e,t,n)=>(bo(e,t,"access private method"),n);function xs(e,t){if(t){let n;return pl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return pl(e)}function Sr(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)=>!Sr(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(a=>!Sr(e[a],t[a]))}return!1}function he({get:e},t){return{init(n){return Rr(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ae(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=xs(e.bind(this)),n.set(this,r)),r.value}}function da(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,xh(_h({},s),{enumerable:e}))})}}function Dr(...e){const t=e.map(n=>xt(n));return()=>t.forEach(n=>n())}var xc,Sc,Cc,kc,Ec,Ic,tt,wo,fa,Ta,$a,qe,_o,ha,Mc,Ra,xo,pa,Da,Pa;Ic=[he],Ec=[he],kc=[he],Cc=[da()],Sc=[da()],xc=[da()];var Qt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,sn(tt,5,this),es(this,qe),es(this,wo,sn(tt,8,this)),sn(tt,11,this),es(this,_o,sn(tt,12,this)),sn(tt,15,this),es(this,xo,sn(tt,16,this)),sn(tt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return fn(this,qe,Da)}get initial(){return fn(this,qe,Ta)}get previous(){return fn(this,qe,Mc)}set current(e){const t=we(()=>fn(this,qe,Da));e&&t&&this.equals(t,e)||qt(()=>{fn(this,qe,Ta)||Ut(this,qe,e,$a),Ut(this,qe,t,Ra),Ut(this,qe,e,Pa)})}reset(e=this.defaultValue){qt(()=>{Ut(this,qe,void 0,Ra),Ut(this,qe,e,$a),Ut(this,qe,e,Pa)})}};tt=Sh();wo=new WeakMap;qe=new WeakSet;_o=new WeakMap;xo=new WeakMap;fa=Un(tt,20,"#initial",Ic,qe,wo),Ta=fa.get,$a=fa.set;ha=Un(tt,20,"#previous",Ec,qe,_o),Mc=ha.get,Ra=ha.set;pa=Un(tt,20,"#current",kc,qe,xo),Da=pa.get,Pa=pa.set;Un(tt,2,"current",Cc,Qt);Un(tt,2,"initial",Sc,Qt);Un(tt,2,"previous",xc,Qt);_c(tt,Qt);function ma(e){return we(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Ih=Object.create,Ac=Object.defineProperty,Mh=Object.getOwnPropertyDescriptor,vl=Object.getOwnPropertySymbols,Ah=Object.prototype.hasOwnProperty,Th=Object.prototype.propertyIsEnumerable,Tc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ns=e=>{throw TypeError(e)},yl=Math.pow,Fa=(e,t,n)=>t in e?Ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$h=(e,t)=>{for(var n in t||(t={}))Ah.call(t,n)&&Fa(e,n,t[n]);if(vl)for(var n of vl(t))Th.call(t,n)&&Fa(e,n,t[n]);return e},Rh=e=>{var t;return[,,,Ih((t=e?.[Tc("metadata")])!=null?t:null)]},$c=["class","method","getter","setter","accessor","field","value","get","set"],Rc=e=>e!==void 0&&typeof e!="function"?Ns("Function expected"):e,Dh=(e,t,n,r,s)=>({kind:$c[e],name:t,metadata:r,addInitializer:a=>n._?Ns("Already initialized"):s.push(Rc(a||null))}),Ph=(e,t)=>Fa(t,Tc("metadata"),e[3]),Fh=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},Dc=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=$c[u+5],v=e[d]||(e[d]=[]),y=(s=s.prototype,Mh(s,n)),g=r.length-1;g>=0;g--)l=Dh(u,n,i={},e[3],v),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[g])(y[h],l),i._=1,Rc(o)&&(y[h]=o);return y&&Ac(s,n,y),s},Pc=(e,t,n)=>t.has(e)||Ns("Cannot "+n),Oh=(e,t,n)=>(Pc(e,t,"read from private field"),t.get(e)),Lh=(e,t,n)=>t.has(e)?Ns("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Bh=(e,t,n,r)=>(Pc(e,t,"write to private field"),t.set(e,n),n),Rt=class Oa{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Oa(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 Oa(t,n)}},Pr=class on{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:a,height:o,scale:i}=this,l=new on(s+t,r+n,a,o);return l.scale=$h({},i),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:a,bottom:o}=this;return{width:t,height:n,left:r,top:s,right:a,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new Rt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof on))return!1;const{left:n,top:r,width:s,height:a}=this;return n===t.left&&r===t.top&&s===t.width&&a===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:a}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=a}intersectionArea(t){return t instanceof on?Wh(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 on(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(a,o)=>{const i=r[o],l=o==="x"?a.left:a.top,c=o==="x"?a.width:a.height;return i=="start"?l:i=="end"?l+c:l+c/2};return Rt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return on.from(t).intersectionRatio(on.from(n))}};function Wh(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),a=Math.min(t.top+t.height,e.top+e.height),o=s-r,i=a-n;return r<s&&n<a?o*i:0}var Fc,Oc,La,ls,Fr,zs=class extends(La=Qt,Oc=[Ae],Fc=[Ae],La){constructor(t){const n=Rt.from(t);super(n,(r,s)=>Rt.equals(r,s)),Fh(Fr,5,this),Lh(this,ls,0),this.velocity={x:0,y:0}}get delta(){return Rt.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=Rt.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-Oh(this,ls),i=l=>Math.round(l/o*100);qt(()=>{Bh(this,ls,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Rt.from(t)),this.velocity={x:0,y:0}}};Fr=Rh(La);ls=new WeakMap;Dc(Fr,2,"delta",Oc,zs);Dc(Fr,2,"direction",Fc,zs);Ph(Fr,zs);function Ba({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(yl(r,2)+yl(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 Lc=(e=>(e.Horizontal="x",e.Vertical="y",e))(Lc||{}),Bc=Object.values(Lc),Vh=Object.create,So=Object.defineProperty,Nh=Object.defineProperties,zh=Object.getOwnPropertyDescriptor,jh=Object.getOwnPropertyDescriptors,Ss=Object.getOwnPropertySymbols,Wc=Object.prototype.hasOwnProperty,Vc=Object.prototype.propertyIsEnumerable,Nc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Xn=e=>{throw TypeError(e)},Wa=(e,t,n)=>t in e?So(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zc=(e,t)=>{for(var n in t||(t={}))Wc.call(t,n)&&Wa(e,n,t[n]);if(Ss)for(var n of Ss(t))Vc.call(t,n)&&Wa(e,n,t[n]);return e},jc=(e,t)=>Nh(e,jh(t)),bl=(e,t)=>So(e,"name",{value:t,configurable:!0}),Zc=(e,t)=>{var n={};for(var r in e)Wc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ss)for(var r of Ss(e))t.indexOf(r)<0&&Vc.call(e,r)&&(n[r]=e[r]);return n},Yn=e=>{var t;return[,,,Vh((t=e?.[Nc("metadata")])!=null?t:null)]},Hc=["class","method","getter","setter","accessor","field","value","get","set"],ar=e=>e!==void 0&&typeof e!="function"?Xn("Function expected"):e,Zh=(e,t,n,r,s)=>({kind:Hc[e],name:t,metadata:r,addInitializer:a=>n._?Xn("Already initialized"):s.push(ar(a||null))}),vn=(e,t)=>Wa(t,Nc("metadata"),e[3]),se=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},ce=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,v=Hc[f+5],y=f>3&&(e[h-1]=[]),g=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&zh(f<4?s:{get[n](){return Ge(this,a)},set[n](_){return bt(this,a,_)}},n));f?d&&f<4&&bl(a,(f>2?"set ":f>1?"get ":"")+n):bl(s,n);for(var w=r.length-1;w>=0;w--)c=Zh(f,n,l={},e[3],g),f&&(c.static=m,c.private=d,u=c.access={has:d?_=>Hh(s,_):_=>n in _},f^3&&(u.get=d?_=>(f^1?Ge:Gh)(_,s,f^4?a:b.get):_=>_[n]),f>2&&(u.set=d?(_,x)=>bt(_,s,x,f^4?a:b.set):(_,x)=>_[n]=x)),i=(0,r[w])(f?f<4?d?a:b[v]: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?a=i:b[v]=i:s=i):typeof i!="object"||i===null?Xn("Object expected"):(ar(o=i.get)&&(b.get=o),ar(o=i.set)&&(b.set=o),ar(o=i.init)&&y.unshift(o));return f||vn(e,s),b&&So(s,n,b),d?f^4?a:b:s},Co=(e,t,n)=>t.has(e)||Xn("Cannot "+n),Hh=(e,t)=>Object(t)!==t?Xn('Cannot use the "in" operator on this value'):e.has(t),Ge=(e,t,n)=>(Co(e,t,"read from private field"),n?n.call(e):t.get(e)),be=(e,t,n)=>t.has(e)?Xn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),bt=(e,t,n,r)=>(Co(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Gh=(e,t,n)=>(Co(e,t,"access private method"),n);function Gc(e,t){return{plugin:e,options:t}}function yn(e){return t=>Gc(e,t)}function ko(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Uc,Cr,Eo,cs;Uc=[he];var lt=class{constructor(e,t){this.manager=e,this.options=t,be(this,Eo,se(Cr,8,this,!1)),se(Cr,11,this),be(this,cs,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return we(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=xt(e.bind(this));return Ge(this,cs).add(t),t}destroy(){Ge(this,cs).forEach(e=>e())}static configure(e){return Gc(this,e)}};Cr=Yn(null);Eo=new WeakMap;cs=new WeakMap;ce(Cr,4,"disabled",Uc,lt,Eo);vn(Cr,lt);var Or=class extends lt{},us,ga=class{constructor(e){this.manager=e,this.instances=new Map,be(this,us,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(ko).reduceRight((r,s)=>r.some(({plugin:a})=>a===s.plugin)?r:[s,...r],[]),n=t.map(({plugin:r})=>r);for(const r of Ge(this,us))if(!n.includes(r)){if(r.prototype instanceof Or)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);bt(this,us,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()}};us=new WeakMap;function Uh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var ts=[],Tn,$n,Xh=class extends lt{constructor(e){super(e),be(this,Tn),be(this,$n),this.computeCollisions=this.computeCollisions.bind(this),bt(this,$n,Rr(ts)),this.destroy=Dr(()=>{const t=this.computeCollisions(),n=we(()=>this.manager.dragOperation.position.current);if(t!==ts){const r=Ge(this,Tn);if(bt(this,Tn,n),r&&n.x==r.x&&n.y==r.y)return}else bt(this,Tn,void 0);Ge(this,$n).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){we(()=>{e?Ge(this,$n).value=this.computeCollisions():bt(this,Tn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:a,status:o}=r;if(!o.initialized||!a)return ts;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?ts:(i.sort(Uh),i)}get collisions(){return Ge(this,$n).value}};Tn=new WeakMap;$n=new WeakMap;var Yh=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)}},Kh=class extends Yh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ds(e,t=!0){let n=!1;return jc(zc({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var qh=class extends Or{constructor(e){super(e);const t=(r,s)=>r.map(({id:a})=>a).join("")===s.map(({id:a})=>a).join("");let n=[];this.destroy=Dr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:a}=r;if(r.isDisabled())return;const o=ds({collisions:a});if(s.dispatch("collision",o),o.defaultPrevented||t(a,n))return;n=a;const[i]=a;we(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},Io=(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))(Io||{}),Mo=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Mo||{}),Xc,Yc,Kc,qc,Jc,Qc,eu,_t,Ao;eu=[he],Qc=[Ae],Jc=[Ae],qc=[Ae],Kc=[Ae],Yc=[Ae],Xc=[Ae];var Vt=class{constructor(){se(_t,5,this),be(this,Ao,se(_t,8,this,"idle")),se(_t,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}};_t=Yn(null);Ao=new WeakMap;ce(_t,4,"value",eu,Vt,Ao);ce(_t,2,"current",Qc,Vt);ce(_t,2,"idle",Jc,Vt);ce(_t,2,"initializing",qc,Vt);ce(_t,2,"initialized",Kc,Vt);ce(_t,2,"dragging",Yc,Vt);ce(_t,2,"dropped",Xc,Vt);vn(_t,Vt);var Jh=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=ds({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:a}=e;qt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(a)});const o=ds({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.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:a}=r;if(!s.dragging||!a||a.signal.aborted)return;const o=ds({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",o),queueMicrotask(()=>{var i,l,c,u,f;if(o.defaultPrevented)return;const m=(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=m})})}stop(e={}){return we(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let a;const o=()=>{const l={resume:()=>{},abort:()=>{}};return a=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=xt(()=>{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:o}),a?a.then(i).catch(()=>r.reset()):i()})}},tu,nu,ru,su,it,To,$o,Ro,Do;su=[he],ru=[he],nu=[he],tu=[he];var en=class{constructor(e,t){be(this,To,se(it,8,this)),se(it,11,this),be(this,$o,se(it,12,this)),se(it,15,this),be(this,Ro,se(it,16,this)),se(it,19,this),be(this,Do,se(it,20,this)),se(it,23,this);const{effects:n,id:r,data:s={},disabled:a=!1,register:o=!0}=e;let i=r;this.manager=t,this.id=r,this.data=s,this.disabled=a,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&&o&&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)}};it=Yn(null);To=new WeakMap;$o=new WeakMap;Ro=new WeakMap;Do=new WeakMap;ce(it,4,"manager",su,en,To);ce(it,4,"id",ru,en,$o);ce(it,4,"data",nu,en,Ro);ce(it,4,"disabled",tu,en,Do);vn(it,en);var wl=class{constructor(){this.map=Rr(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 a=new Map(n);a.set(e,t),this.map.value=a;const o=Dr(...t.effects());return this.cleanupFunctions.set(t,o),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}},au,ou,iu,lu,cu,uu,Va,nt,Po,Fo,Oo,Dt=class extends(Va=en,uu=[he],cu=[he],lu=[he],iu=[Ae],ou=[Ae],au=[Ae],Va){constructor(t,n){var r=t,{modifiers:s,type:a,sensors:o}=r,i=Zc(r,["modifiers","type","sensors"]);super(i,n),se(nt,5,this),be(this,Po,se(nt,8,this)),se(nt,11,this),be(this,Fo,se(nt,12,this)),se(nt,15,this),be(this,Oo,se(nt,16,this,this.isDragSource?"dragging":"idle")),se(nt,19,this),this.type=a,this.sensors=o,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=Yn(Va);Po=new WeakMap;Fo=new WeakMap;Oo=new WeakMap;ce(nt,4,"type",uu,Dt,Po);ce(nt,4,"modifiers",cu,Dt,Fo);ce(nt,4,"status",lu,Dt,Oo);ce(nt,2,"isDropping",iu,Dt);ce(nt,2,"isDragging",ou,Dt);ce(nt,2,"isDragSource",au,Dt);vn(nt,Dt);var du,fu,hu,pu,mu,gu,Na,ze,Lo,Bo,Wo,Vo,No,Pt=class extends(Na=en,gu=[he],mu=[he],pu=[he],hu=[he],fu=[he],du=[Ae],Na){constructor(t,n){var r=t,{accept:s,collisionDetector:a,collisionPriority:o,type:i}=r,l=Zc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),se(ze,5,this),be(this,Lo,se(ze,8,this)),se(ze,11,this),be(this,Bo,se(ze,12,this)),se(ze,15,this),be(this,Wo,se(ze,16,this)),se(ze,19,this),be(this,Vo,se(ze,20,this)),se(ze,23,this),be(this,No,se(ze,24,this)),se(ze,27,this),this.accept=s,this.collisionDetector=a,this.collisionPriority=o,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}};ze=Yn(Na);Lo=new WeakMap;Bo=new WeakMap;Wo=new WeakMap;Vo=new WeakMap;No=new WeakMap;ce(ze,4,"accept",gu,Pt,Lo);ce(ze,4,"type",mu,Pt,Bo);ce(ze,4,"collisionDetector",pu,Pt,Wo);ce(ze,4,"collisionPriority",hu,Pt,Vo);ce(ze,4,"shape",fu,Pt,No);ce(ze,2,"isDropTarget",du,Pt);vn(ze,Pt);var Bn=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Qh=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)}},fs,vu=class{constructor(e){this.options=e,be(this,fs)}set controller(e){bt(this,fs,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ge(this,fs))==null||t.activate(e)}};fs=new WeakMap;var Wn=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},ep=class{constructor(e){this.draggables=new wl,this.droppables=new wl,this.plugins=new ga(e),this.sensors=new ga(e),this.modifiers=new ga(e)}register(e,t){if(e instanceof Dt)return this.draggables.register(e.id,e);if(e instanceof Pt)return this.droppables.register(e.id,e);if(e.prototype instanceof Wn)return this.modifiers.register(e,t);if(e.prototype instanceof Bn)return this.sensors.register(e,t);if(e.prototype instanceof lt)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof en)return e instanceof Dt?this.draggables.unregister(e.id,e):e instanceof Pt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Wn)return this.modifiers.unregister(e);if(e.prototype instanceof Bn)return this.sensors.unregister(e);if(e.prototype instanceof lt)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()}},yu,bu,wu,_u,xu,Su,Cu,ku,Eu,or,hs,Rn,Re,zo,jo,Zo,Ho,Go,ir;Eu=[Ae],ku=[he],Cu=[he],Su=[he],xu=[he],_u=[he],wu=[Ae],bu=[Ae],yu=[Ae];var Tt=class{constructor(e){se(Re,5,this),be(this,or),be(this,hs),be(this,Rn,new Qt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Vt,be(this,zo,se(Re,8,this,!1)),se(Re,11,this),be(this,jo,se(Re,12,this,null)),se(Re,15,this),be(this,Zo,se(Re,16,this,null)),se(Re,19,this),be(this,Ho,se(Re,20,this,null)),se(Re,23,this),be(this,Go,se(Re,24,this,[])),se(Re,27,this),this.position=new zs({x:0,y:0}),be(this,ir,{x:0,y:0}),bt(this,or,e)}get shape(){const{current:e,initial:t,previous:n}=Ge(this,Rn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ge(this,Rn).current=e:Ge(this,Rn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ge(this,or).registry.draggables.get(t);return n&&bt(this,hs,n),(e=n??Ge(this,hs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ge(this,or).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(jc(zc({},this.snapshot()),{transform:n}));return bt(this,ir,n),n}snapshot(){return we(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ge(this,ir),shape:this.shape?ma(this.shape):null,position:ma(this.position),status:ma(this.status),canceled:this.canceled}))}reset(){qt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ge(this,Rn).reset(),this.position.reset({x:0,y:0}),bt(this,ir,{x:0,y:0}),this.modifiers=[]})}};Re=Yn(null);or=new WeakMap;hs=new WeakMap;Rn=new WeakMap;zo=new WeakMap;jo=new WeakMap;Zo=new WeakMap;Ho=new WeakMap;Go=new WeakMap;ir=new WeakMap;ce(Re,2,"shape",Eu,Tt);ce(Re,4,"canceled",ku,Tt,zo);ce(Re,4,"activatorEvent",Cu,Tt,jo);ce(Re,4,"sourceIdentifier",Su,Tt,Zo);ce(Re,4,"targetIdentifier",xu,Tt,Ho);ce(Re,4,"modifiers",_u,Tt,Go);ce(Re,2,"source",wu,Tt);ce(Re,2,"target",bu,Tt);ce(Re,2,"transform",yu,Tt);vn(Re,Tt);var tp={get rendering(){return Promise.resolve()}};function Lt(e,t){return typeof e=="function"?e(t):e??t}var np=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(m=>m.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Lt(r.plugins,[]),a=Lt(r.sensors,[]),o=Lt(r.modifiers,[]),i=(n=r.renderer)!=null?n:tp,l=new Kh(this),c=new ep(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new Jh(this),this.dragOperation=new Tt(this),this.collisionObserver=new Xh(this),this.plugins=[qh,...s],this.modifiers=o,this.sensors=a;const{destroy:u}=this,f=Dr(()=>{var m,d,h;const v=we(()=>this.dragOperation.modifiers),y=this.modifiers;for(const g of v)y.includes(g)||g.destroy();this.dragOperation.modifiers=(h=(d=(m=this.dragOperation.source)==null?void 0:m.modifiers)==null?void 0:d.map(g=>{const{plugin:b,options:w}=ko(g);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}},Iu=e=>{throw TypeError(e)},Uo=(e,t,n)=>t.has(e)||Iu("Cannot "+n),ie=(e,t,n)=>(Uo(e,t,"read from private field"),t.get(e)),ot=(e,t,n)=>t.has(e)?Iu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),mt=(e,t,n,r)=>(Uo(e,t,"write to private field"),t.set(e,n),n),Mu=(e,t,n)=>(Uo(e,t,"access private method"),n);function js(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function rp(e,t){const n=e.getAnimations();if(n.length>0)for(const r of n){if(r.playState!=="running")continue;const{effect:s}=r,o=(js(s)?s.getKeyframes():[]).filter(t);if(o.length>0)return[o[o.length-1],r]}return null}function Zs(e){const{width:t,height:n,top:r,left:s,bottom:a,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:a,right:o}}function Xo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Lr(e){return"nodeType"in e}function St(e){var t,n,r;return e?Xo(e)?e:Lr(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 Yo(e){const{Document:t}=St(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function hn(e){return!e||Xo(e)?!1:e instanceof St(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Au(e){return e instanceof St(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function bn(e){return e?Xo(e)?e.document:Lr(e)?Yo(e)?e:hn(e)||Au(e)?e.ownerDocument:document:document:document}function sp(e){var t,n,r,s;const{documentElement:a}=bn(e),o=St(e).visualViewport,i=(t=o?.width)!=null?t:a.clientWidth,l=(n=o?.height)!=null?n:a.clientHeight,c=(r=o?.offsetTop)!=null?r:0,u=(s=o?.offsetLeft)!=null?s:0;return{top:c,left:u,right:u+i,bottom:c+l,width:i,height:l}}function ap(e,t){if(op(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function op(e){return e.tagName==="DETAILS"}function Cs(e,t=e.getBoundingClientRect(),n=0){var r,s,a,o,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(!ap(f)){const w=f.getBoundingClientRect(),_=n*(w.bottom-w.top),x=n*(w.right-w.left),C=n*(w.bottom-w.top),k=n*(w.right-w.left);l={top:Math.max(l.top,w.top-_),right:Math.min(l.right,w.right+x),bottom:Math.min(l.bottom,w.bottom+C),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 m=u.visualViewport,d=(s=m?.offsetTop)!=null?s:0,h=(a=m?.offsetLeft)!=null?a:0,v=(o=m?.width)!=null?o:u.innerWidth,y=(i=m?.height)!=null?i:u.innerHeight,g=n*y,b=n*v;return l={top:Math.max(l.top,d-g),right:Math.min(l.right,h+v+b),bottom:Math.min(l.bottom,d+y+g),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 Vn(e){return{x:e.clientX,y:e.clientY}}var Tu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function za(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(...za(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(...za(s.document,t))}}catch{}return n}function Ko(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function $u(){var e,t;const n=Ko()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function qo(e){return!e||!Lr(e)?!1:e instanceof St(e).ShadowRoot}function ks(e){if(e&&Lr(e)){let t=e.getRootNode();if(qo(t))return t;if(t instanceof Document)return t}return bn(e)}function Ru(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function ip(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((a,o)=>{const i=r[o];if(_l(a)&&_l(i)&&(a.type!=="file"&&(a.value=i.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),xl(a)&&xl(i)&&i.width>0&&i.height>0){const l=a.getContext("2d");l?.drawImage(i,0,0)}}),n}function _l(e){return"value"in e}function xl(e){return e.tagName==="CANVAS"}function Du(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(lp(r)){const{contentDocument:s}=r;if(s){const{left:a,top:o}=r.getBoundingClientRect();return Du(s,{x:t-a,y:n-o})}}return r}function lp(e){return e?.tagName==="IFRAME"}var Sl=new WeakMap;function cp(e){return!!e.closest(`
|
|
2
2
|
input:not([disabled]),
|
|
3
3
|
select:not([disabled]),
|
|
4
4
|
textarea:not([disabled]),
|
|
5
5
|
button:not([disabled]),
|
|
6
6
|
a[href],
|
|
7
7
|
[contenteditable]:not([contenteditable="false"])
|
|
8
|
-
`)}var Su=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 Vn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function qh(e){const t=new Set;let n=Vn(e);for(;n;)t.add(n),n=Vn(n);return t}function Jh(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function ku(e,t){const n=()=>performance.now();let r,s;return function(...o){const a=this;s?(r?.(),r=Jh(()=>{e.apply(a,o),s=n()},t-(n()-s))):(e.apply(a,o),s=n())}}function Qh(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 ep(e,t=e.getBoundingClientRect()){const{width:n,height:r}=ws(e,t);return n>0&&r>0}var tp=wu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},us,np=class extends tp{constructor(e){super(t=>{if(!ae(this,us)){pt(this,us,!0);return}e(t,this)}),ot(this,us,!1)}};us=new WeakMap;var vl=Array.from({length:100},(e,t)=>t/100),Eu=75,un,xs,Ut,dn,ir,Ye,mr,lr,Cs,Iu,Mu,Au=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ot(this,Cs),this.disconnect=()=>{var o,a,i;pt(this,mr,!0),(o=ae(this,Ut))==null||o.disconnect(),(a=ae(this,dn))==null||a.disconnect(),ae(this,ir).disconnect(),(i=ae(this,Ye))==null||i.remove()},ot(this,un,!0),ot(this,xs),ot(this,Ut),ot(this,dn),ot(this,ir),ot(this,Ye),ot(this,mr,!1),ot(this,lr,ku(()=>{var o,a,i;const{element:l}=this;if((o=ae(this,dn))==null||o.disconnect(),ae(this,mr)||!ae(this,un)||!l.isConnected)return;const c=(a=l.ownerDocument)!=null?a:document,{innerHeight:u,innerWidth:f}=(i=c.defaultView)!=null?i:window,h=l.getBoundingClientRect(),d=ws(l,h),{top:p,left:v,bottom:y,right:m}=d,b=-Math.floor(p),_=-Math.floor(v),w=-Math.floor(f-m),x=-Math.floor(u-y),S=`${b}px ${w}px ${x}px ${_}px`;this.boundingClientRect=h,pt(this,dn,new IntersectionObserver(k=>{const[E]=k,{intersectionRect:T}=E;(E.intersectionRatio!==1?E.intersectionRatio:Dr.intersectionRatio(T,ws(l)))!==1&&ae(this,lr).call(this)},{threshold:vl,rootMargin:S,root:c})),ae(this,dn).observe(l),yu(this,Cs,Iu).call(this)},Eu)),this.boundingClientRect=e.getBoundingClientRect(),pt(this,un,ep(e,this.boundingClientRect));let r=!0;this.callback=o=>{r&&(r=!1,n.skipInitial)||t(o)};const s=e.ownerDocument;n?.debug&&(pt(this,Ye,document.createElement("div")),ae(this,Ye).style.background="rgba(0,0,0,0.15)",ae(this,Ye).style.position="fixed",ae(this,Ye).style.pointerEvents="none",s.body.appendChild(ae(this,Ye))),pt(this,ir,new IntersectionObserver(o=>{var a,i;const l=o[o.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:f,height:h}=c,d=ae(this,un);pt(this,un,u),!(!f&&!h)&&(d&&!u?((a=ae(this,dn))==null||a.disconnect(),this.callback(null),(i=ae(this,Ut))==null||i.disconnect(),pt(this,Ut,void 0),ae(this,Ye)&&(ae(this,Ye).style.visibility="hidden")):ae(this,lr).call(this),u&&!ae(this,Ut)&&(pt(this,Ut,new np(ae(this,lr))),ae(this,Ut).observe(e)))},{threshold:vl,root:s})),ae(this,un)&&!n.skipInitial&&this.callback(this.boundingClientRect),ae(this,ir).observe(e)}};un=new WeakMap;xs=new WeakMap;Ut=new WeakMap;dn=new WeakMap;ir=new WeakMap;Ye=new WeakMap;mr=new WeakMap;lr=new WeakMap;Cs=new WeakSet;Iu=function(){ae(this,mr)||(yu(this,Cs,Mu).call(this),!Qh(this.boundingClientRect,ae(this,xs))&&(this.callback(this.boundingClientRect),pt(this,xs,this.boundingClientRect)))};Mu=function(){if(ae(this,Ye)){const{top:e,left:t,width:n,height:r}=ws(this.element);ae(this,Ye).style.overflow="hidden",ae(this,Ye).style.visibility="visible",ae(this,Ye).style.top=`${Math.floor(e)}px`,ae(this,Ye).style.left=`${Math.floor(t)}px`,ae(this,Ye).style.width=`${Math.floor(n)}px`,ae(this,Ye).style.height=`${Math.floor(r)}px`}};var Qr=new WeakMap,es=new WeakMap;function rp(e,t){let n=Qr.get(e);return n||(n={disconnect:new Au(e,s=>{const o=Qr.get(e);o&&o.callbacks.forEach(a=>a(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Qr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Qr.delete(e),n.disconnect())}}function sp(e,t){const n=new Set;for(const r of e){const s=rp(r,t);n.add(s)}return()=>n.forEach(r=>r())}function op(e,t){var n;const r=e.ownerDocument;if(!es.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}),es.set(r,{disconnect:()=>a.abort(),listeners:i})}const{listeners:s,disconnect:o}=(n=es.get(r))!=null?n:{};return!s||!o?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(o(),es.delete(r))})}var cr,ur,ds,No,ap=class{constructor(e,t,n){this.callback=t,ot(this,cr),ot(this,ur,!1),ot(this,ds),ot(this,No,ku(a=>{if(!ae(this,ur)&&a.target&&"contains"in a.target&&typeof a.target.contains=="function"){for(const i of ae(this,ds))if(a.target.contains(i)){this.callback(ae(this,cr).boundingClientRect);break}}},Eu));const r=qh(e),s=sp(r,t),o=op(e,ae(this,No));pt(this,ds,r),pt(this,cr,new Au(e,t,n)),this.disconnect=()=>{ae(this,ur)||(pt(this,ur,!0),s(),o(),ae(this,cr).disconnect())}}};cr=new WeakMap;ur=new WeakMap;ds=new WeakMap;No=new WeakMap;function zo(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function Sr(e){try{zo(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function yl(e){return!wu||!e?!1:e===wn(e).scrollingElement}function Tu(e){var t,n;const r=St(e),s=yl(e)?Hh(e):Bs(e),o=r.visualViewport,a=yl(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 ip(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:o,position:a}=Tu(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,h=!o&&a.current.x+i<a.max.x;return{top:c,bottom:u,left:f,right:h,x:f||h,y:c||u}}var Ua=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))}},Ss=new Ua(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),lp=new Ua(e=>setTimeout(e,50)),ks=new Map,cp=ks.clear.bind(ks);function Zt(e,t=!1){if(!t)return bl(e);let n=ks.get(e);return n||(n=bl(e),ks.set(e,n),lp.schedule(cp),n)}function bl(e){return St(e).getComputedStyle(e)}function up(e,t=Zt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function dp(e,t=Zt(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 fp={excludeElement:!0,escapeShadowDOM:!0};function jo(e,t=fp){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,o=new Set;function a(i){if(n!=null&&o.size>=n||!i)return o;if(Za(i)&&i.scrollingElement!=null&&!o.has(i.scrollingElement))return o.add(i.scrollingElement),o;if(s&&Ga(i))return a(i.host);if(!mn(i))return bu(i)?a(i.parentElement):o;if(o.has(i))return o;const l=Zt(i,!0);if(r&&i===e||dp(i,l)&&o.add(i),up(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&o.add(c),o}return a(i.parentNode)}return e?a(e):o}function hp(e){const[t]=jo(e,{limit:1});return t??null}function Nn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Vn(e);for(;r;){if(r===t)return n;const s=Bs(r),{x:o,y:a}=pp(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=Vn(r)}return n}function pp(e,t=Bs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(mn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Zt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function mp(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 Xa(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 Ya(e){var t,n,r,s,o,a,i,l,c;const{scale:u,transform:f,translate:h}=e,d=mp(u),p=Xa(h),v=gp(f);if(!v&&!d&&!p)return null;const y={x:(t=d?.x)!=null?t:1,y:(n=d?.y)!=null?n:1},m={x:(r=p?.x)!=null?r:0,y:(s=p?.y)!=null?s:0},b={x:(o=v?.x)!=null?o:0,y:(a=v?.y)!=null?a:0,scaleX:(i=v?.scaleX)!=null?i:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:m.x+b.x,y:m.y+b.y,z:(c=p?.z)!=null?c:0,scaleX:y.x*b.scaleX,scaleY:y.y*b.scaleY}}function gp(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 _t=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(_t||{}),vp={x:.2,y:.2},yp={x:10,y:10};function bp(e,t,n,r=25,s=vp,o=yp){const{x:a,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:f,isRight:h}=Tu(e),d=Nn(e),p=Zt(e,!0),v=Ya(p),y=v!==null?v?.scaleX<0:!1,m=v!==null?v?.scaleY<0:!1,b=new Dr(l.left*d.scaleX+d.x,l.top*d.scaleY+d.y,l.width*d.scaleX,l.height*d.scaleY),_={x:0,y:0},w={x:0,y:0},x={height:b.height*s.y,width:b.width*s.x};return(!c||m&&!u)&&i<=b.top+x.height&&n?.y!==1&&a>=b.left-o.x&&a<=b.right+o.x?(_.y=m?1:-1,w.y=r*Math.abs((b.top+x.height-i)/x.height)):(!u||m&&!c)&&i>=b.bottom-x.height&&n?.y!==-1&&a>=b.left-o.x&&a<=b.right+o.x&&(_.y=m?-1:1,w.y=r*Math.abs((b.bottom-x.height-i)/x.height)),(!h||y&&!f)&&a>=b.right-x.width&&n?.x!==-1&&i>=b.top-o.y&&i<=b.bottom+o.y?(_.x=y?-1:1,w.x=r*Math.abs((b.right-x.width-a)/x.width)):(!f||y&&!h)&&a<=b.left+x.width&&n?.x!==1&&i>=b.top-o.y&&i<=b.bottom+o.y&&(_.x=y?1:-1,w.x=r*Math.abs((b.left+x.width-a)/x.width)),{direction:_,speed:w}}function wp(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function _p(e,t=!1){if(wp(e)){e.scrollIntoViewIfNeeded(t);return}if(!mn(e))return e.scrollIntoView();var n=hp(e);if(!mn(n))return;const r=Zt(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 xp(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 Cp(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 Sp({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var kp=new Ua(e=>setTimeout(e,0)),gr=new Map,Ep=gr.clear.bind(gr);function Ip(e){const t=e.ownerDocument;let n=gr.get(t);if(n)return n;n=t.getAnimations(),gr.set(t,n),kp.schedule(Ep);const r=n.filter(s=>Ws(s.effect)&&s.effect.target===e);return gr.set(e,r),n}function Mp(e,t){const n=Ip(e).filter(r=>{var s,o;if(Ws(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 Nt=class extends Dr{constructor(e,t={}){var n,r,s,o;const{frameTransform:a=Nn(e),ignoreTransforms:i,getBoundingClientRect:l=Bs}=t,c=Mp(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||Ha())&&x.contains(e)}),u=l(e);let{top:f,left:h,width:d,height:p}=u,v;const y=Zt(e),m=Ya(y),b={x:(n=m?.scaleX)!=null?n:1,y:(r=m?.scaleY)!=null?r:1},_=Ap(e,y);c?.(),m&&(v=Cp(u,m,y.transformOrigin),(i||_)&&(f=v.top,h=v.left,d=v.width,p=v.height));const w={width:(s=v?.width)!=null?s:d,height:(o=v?.height)!=null?o:p};if(_&&!i&&v){const x=xp(v,_,y.transformOrigin);f=x.top,h=x.left,d=x.width,p=x.height,b.x=_.scaleX,b.y=_.scaleY}a&&(i||(h*=a.scaleX,d*=a.scaleX,f*=a.scaleY,p*=a.scaleY),h+=a.x,f+=a.y),super(h,f,d,p),this.scale=b,this.intrinsicWidth=w.width,this.intrinsicHeight=w.height}};function Ap(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=Ws(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=Ya({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 vr(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 Tp=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(vr(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(vr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(vr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function gn(e){return e?e instanceof St(e).Element||Or(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function Ka(e){if(!e)return!1;const{KeyboardEvent:t}=St(e.target);return e instanceof t}function $p(e){if(!e)return!1;const{PointerEvent:t}=St(e.target);return e instanceof t}function Rp(e){if(!gn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||Dp(e)}function Dp(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var po={};function Zo(e){const t=po[e]==null?0:po[e]+1;return po[e]=t,`${e}-${t}`}var Pp=({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:Ca.PointerIntersection,priority:xa.High}}return null},Fp=({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:Ca.ShapeIntersection,priority:xa.Normal}}return null},Op=e=>{var t;return(t=Pp(e))!=null?t:Fp(e)},Lp=Object.create,qa=Object.defineProperty,Wp=Object.defineProperties,Bp=Object.getOwnPropertyDescriptor,Vp=Object.getOwnPropertyDescriptors,Es=Object.getOwnPropertySymbols,$u=Object.prototype.hasOwnProperty,Ru=Object.prototype.propertyIsEnumerable,Du=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yn=e=>{throw TypeError(e)},Ho=(e,t,n)=>t in e?qa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kr=(e,t)=>{for(var n in t||(t={}))$u.call(t,n)&&Ho(e,n,t[n]);if(Es)for(var n of Es(t))Ru.call(t,n)&&Ho(e,n,t[n]);return e},Ja=(e,t)=>Wp(e,Vp(t)),wl=(e,t)=>qa(e,"name",{value:t,configurable:!0}),Pu=(e,t)=>{var n={};for(var r in e)$u.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&&Ru.call(e,r)&&(n[r]=e[r]);return n},Kn=e=>{var t;return[,,,Lp((t=e?.[Du("metadata")])!=null?t:null)]},Fu=["class","method","getter","setter","accessor","field","value","get","set"],dr=e=>e!==void 0&&typeof e!="function"?Yn("Function expected"):e,Np=(e,t,n,r,s)=>({kind:Fu[e],name:t,metadata:r,addInitializer:o=>n._?Yn("Already initialized"):s.push(dr(o||null))}),_n=(e,t)=>Ho(t,Du("metadata"),e[3]),We=(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},gt=(e,t,n,r,s,o)=>{var a,i,l,c,u,f=t&7,h=!!(t&8),d=!!(t&16),p=f>3?e.length+1:f?h?1:2:0,v=Fu[f+5],y=f>3&&(e[p-1]=[]),m=e[p]||(e[p]=[]),b=f&&(!d&&!h&&(s=s.prototype),f<5&&(f>3||!d)&&Bp(f<4?s:{get[n](){return Ce(this,o)},set[n](w){return rt(this,o,w)}},n));f?d&&f<4&&wl(o,(f>2?"set ":f>1?"get ":"")+n):wl(s,n);for(var _=r.length-1;_>=0;_--)c=Np(f,n,l={},e[3],m),f&&(c.static=h,c.private=d,u=c.access={has:d?w=>zp(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?Ce:vn)(w,s,f^4?o:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>rt(w,s,x,f^4?o:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?o:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?dr(i)&&(f>4?y.unshift(i):f?d?o=i:b[v]=i:s=i):typeof i!="object"||i===null?Yn("Object expected"):(dr(a=i.get)&&(b.get=a),dr(a=i.set)&&(b.set=a),dr(a=i.init)&&y.unshift(a));return f||_n(e,s),b&&qa(s,n,b),d?f^4?o:b:s},Qa=(e,t,n)=>t.has(e)||Yn("Cannot "+n),zp=(e,t)=>Object(t)!==t?Yn('Cannot use the "in" operator on this value'):e.has(t),Ce=(e,t,n)=>(Qa(e,t,"read from private field"),n?n.call(e):t.get(e)),De=(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),rt=(e,t,n,r)=>(Qa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),vn=(e,t,n)=>(Qa(e,t,"access private method"),n),_l={role:"button",roleDescription:"draggable"},jp="dnd-kit-description",Zp="dnd-kit-announcement",Hp={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."},Gp={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 Up(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Xp(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Yp(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 Kp=["dragover","dragmove"],qp=class extends it{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=jp,announcement:s=Zp}={},announcements:o=Gp,screenReaderInstructions:a=Hp,debounce:i=500}=t??{},l=n?`${r}-${n}`:Zo(r),c=n?`${s}-${n}`:Zo(s);let u,f,h,d;const p=(x=d)=>{!h||!x||h?.nodeValue!==x&&(h.nodeValue=x)},v=()=>Ss.schedule(p),y=Jp(v,i),m=Object.entries(o).map(([x,S])=>this.manager.monitor.addEventListener(x,(k,E)=>{const T=h;if(!T)return;const I=S?.(k,E);I&&T.nodeValue!==I&&(d=I,Kp.includes(x)?y():(v(),y.cancel()))})),b=()=>{let x=[];u?.isConnected||(u=Xp(l,a.draggable),x.push(u)),f?.isConnected||(f=Yp(c),h=document.createTextNode(""),f.appendChild(h),x.push(f)),x.length>0&&document.body.append(...x)},_=new Set;function w(){for(const x of _)x()}this.registerEffect(()=>{var x;_.clear();for(const S of this.manager.registry.draggables.value){const k=(x=S.handle)!=null?x:S.element;if(k){(!u||!f)&&_.add(b),(!Up(k)||Ha())&&!k.hasAttribute("tabindex")&&_.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&_.add(()=>k.setAttribute("role",_l.role)),k.hasAttribute("aria-roledescription")||_.add(()=>k.setAttribute("aria-roledescription",_l.roleDescription)),k.hasAttribute("aria-describedby")||_.add(()=>k.setAttribute("aria-describedby",l));for(const T of["aria-pressed","aria-grabbed"]){const I=String(S.isDragging);k.getAttribute(T)!==I&&_.add(()=>k.setAttribute(T,I))}const E=String(S.disabled);k.getAttribute("aria-disabled")!==E&&_.add(()=>k.setAttribute("aria-disabled",E))}}_.size>0&&Ss.schedule(w)}),this.destroy=()=>{super.destroy(),u?.remove(),f?.remove(),m.forEach(x=>x())}}};function Jp(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Qp=class extends it{constructor(e,t){super(e,t),this.manager=e;const n=ys(()=>{var r;return wn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=Ct(()=>{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()}})}},Is=new Map,Ou,Lu,Wu,Bu,Go,yr,zt,ei,zn,Vu,Nu,zu,ju,xn=class extends(Go=Fr,Bu=[de],Wu=[Ie],Lu=[Ie],Ou=[Ie],Go){constructor(e){super(e),We(zt,5,this),De(this,zn),De(this,yr,new Set),De(this,ei,We(zt,8,this,new Set)),We(zt,11,this),this.registerEffect(vn(this,zn,Vu))}register(e){return Ce(this,yr).add(e),()=>{Ce(this,yr).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 _s((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return _s((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}};zt=Kn(Go);yr=new WeakMap;ei=new WeakMap;zn=new WeakSet;Vu=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Ce(this,yr))t.push(vn(this,zn,Nu).call(this,n,r));return()=>{for(const n of t)n()}};Nu=function(e,t){let n=Is.get(e);n||(n=new Map,Is.set(e,n));let r=n.get(t);if(!r){const o=Za(e)?vn(this,zn,zu).call(this,e,n,t):vn(this,zn,ju).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())}};zu=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&&Is.delete(e)}}};ju=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(Ga(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&&Is.delete(e)}}};gt(zt,4,"additionalRoots",Bu,xn,ei);gt(zt,2,"sourceRoot",Wu,xn);gt(zt,2,"targetRoot",Lu,xn);gt(zt,2,"roots",Ou,xn);_n(zt,xn);var Lr="data-dnd-",Uo=`${Lr}dropping`,Je="--dnd-",Dt=`${Lr}dragging`,Ms=`${Lr}placeholder`,em=[Dt,Ms,"popover","aria-pressed","aria-grabbing"],tm=["view-transition-name"],nm=`
|
|
9
|
-
:is(:root,:host) [${
|
|
8
|
+
`)}var Pu=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 a of n)for(const o of r){const{type:i,listener:l,options:c}=o,u=[a,o];a.addEventListener(i,l,c),this.entries.add(u),s.push(u)}return function(){for(const[o,{type:i,listener:l,options:c}]of s)o.removeEventListener(i,l,c)}}};function Nn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function up(e){const t=new Set;let n=Nn(e);for(;n;)t.add(n),n=Nn(n);return t}function dp(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Fu(e,t){const n=()=>performance.now();let r,s;return function(...a){const o=this;s?(r?.(),r=dp(()=>{e.apply(o,a),s=n()},t-(n()-s))):(e.apply(o,a),s=n())}}function fp(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 hp(e,t=e.getBoundingClientRect()){const{width:n,height:r}=Cs(e,t);return n>0&&r>0}var pp=Tu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ps,mp=class extends pp{constructor(e){super(t=>{if(!ie(this,ps)){mt(this,ps,!0);return}e(t,this)}),ot(this,ps,!1)}};ps=new WeakMap;var Cl=Array.from({length:100},(e,t)=>t/100),Ou=75,ln,Es,Ht,cn,lr,Xe,vr,cr,Is,Lu,Bu,Wu=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ot(this,Is),this.disconnect=()=>{var a,o,i;mt(this,vr,!0),(a=ie(this,Ht))==null||a.disconnect(),(o=ie(this,cn))==null||o.disconnect(),ie(this,lr).disconnect(),(i=ie(this,Xe))==null||i.remove()},ot(this,ln,!0),ot(this,Es),ot(this,Ht),ot(this,cn),ot(this,lr),ot(this,Xe),ot(this,vr,!1),ot(this,cr,Fu(()=>{var a,o,i;const{element:l}=this;if((a=ie(this,cn))==null||a.disconnect(),ie(this,vr)||!ie(this,ln)||!l.isConnected)return;const c=(o=l.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:f}=(i=c.defaultView)!=null?i:window,m=l.getBoundingClientRect(),d=Cs(l,m),{top:h,left:v,bottom:y,right:g}=d,b=-Math.floor(h),w=-Math.floor(v),_=-Math.floor(f-g),x=-Math.floor(u-y),C=`${b}px ${_}px ${x}px ${w}px`;this.boundingClientRect=m,mt(this,cn,new IntersectionObserver(k=>{const[I]=k,{intersectionRect:E}=I;(I.intersectionRatio!==1?I.intersectionRatio:Pr.intersectionRatio(E,Cs(l)))!==1&&ie(this,cr).call(this)},{threshold:Cl,rootMargin:C,root:c})),ie(this,cn).observe(l),Mu(this,Is,Lu).call(this)},Ou)),this.boundingClientRect=e.getBoundingClientRect(),mt(this,ln,hp(e,this.boundingClientRect));let r=!0;this.callback=a=>{r&&(r=!1,n.skipInitial)||t(a)};const s=e.ownerDocument;n?.debug&&(mt(this,Xe,document.createElement("div")),ie(this,Xe).style.background="rgba(0,0,0,0.15)",ie(this,Xe).style.position="fixed",ie(this,Xe).style.pointerEvents="none",s.body.appendChild(ie(this,Xe))),mt(this,lr,new IntersectionObserver(a=>{var o,i;const l=a[a.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:f,height:m}=c,d=ie(this,ln);mt(this,ln,u),!(!f&&!m)&&(d&&!u?((o=ie(this,cn))==null||o.disconnect(),this.callback(null),(i=ie(this,Ht))==null||i.disconnect(),mt(this,Ht,void 0),ie(this,Xe)&&(ie(this,Xe).style.visibility="hidden")):ie(this,cr).call(this),u&&!ie(this,Ht)&&(mt(this,Ht,new mp(ie(this,cr))),ie(this,Ht).observe(e)))},{threshold:Cl,root:s})),ie(this,ln)&&!n.skipInitial&&this.callback(this.boundingClientRect),ie(this,lr).observe(e)}};ln=new WeakMap;Es=new WeakMap;Ht=new WeakMap;cn=new WeakMap;lr=new WeakMap;Xe=new WeakMap;vr=new WeakMap;cr=new WeakMap;Is=new WeakSet;Lu=function(){ie(this,vr)||(Mu(this,Is,Bu).call(this),!fp(this.boundingClientRect,ie(this,Es))&&(this.callback(this.boundingClientRect),mt(this,Es,this.boundingClientRect)))};Bu=function(){if(ie(this,Xe)){const{top:e,left:t,width:n,height:r}=Cs(this.element);ie(this,Xe).style.overflow="hidden",ie(this,Xe).style.visibility="visible",ie(this,Xe).style.top=`${Math.floor(e)}px`,ie(this,Xe).style.left=`${Math.floor(t)}px`,ie(this,Xe).style.width=`${Math.floor(n)}px`,ie(this,Xe).style.height=`${Math.floor(r)}px`}};var ns=new WeakMap,rs=new WeakMap;function gp(e,t){let n=ns.get(e);return n||(n={disconnect:new Wu(e,s=>{const a=ns.get(e);a&&a.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),ns.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(ns.delete(e),n.disconnect())}}function vp(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 yp(e,t){var n;const r=e.ownerDocument;if(!rs.has(r)){const o=new AbortController,i=new Set;document.addEventListener("scroll",l=>i.forEach(c=>c(l)),{capture:!0,passive:!0,signal:o.signal}),rs.set(r,{disconnect:()=>o.abort(),listeners:i})}const{listeners:s,disconnect:a}=(n=rs.get(r))!=null?n:{};return!s||!a?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(a(),rs.delete(r))})}var ur,dr,ms,ja,bp=class{constructor(e,t,n){this.callback=t,ot(this,ur),ot(this,dr,!1),ot(this,ms),ot(this,ja,Fu(o=>{if(!ie(this,dr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const i of ie(this,ms))if(o.target.contains(i)){this.callback(ie(this,ur).boundingClientRect);break}}},Ou));const r=up(e),s=vp(r,t),a=yp(e,ie(this,ja));mt(this,ms,r),mt(this,ur,new Wu(e,t,n)),this.disconnect=()=>{ie(this,dr)||(mt(this,dr,!0),s(),a(),ie(this,ur).disconnect())}}};ur=new WeakMap;dr=new WeakMap;ms=new WeakMap;ja=new WeakMap;function Za(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function kr(e){try{Za(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function kl(e){return!Tu||!e?!1:e===bn(e).scrollingElement}function Vu(e){var t,n;const r=St(e),s=kl(e)?sp(e):Zs(e),a=r.visualViewport,o=kl(e)?{height:(t=a?.height)!=null?t:r.innerHeight,width:(n=a?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},i={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.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 wp(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:a,position:o}=Vu(e),{x:i,y:l}=t??{x:0,y:0},c=!n&&o.current.y+l>0,u=!r&&o.current.y+l<o.max.y,f=!s&&o.current.x+i>0,m=!a&&o.current.x+i<o.max.x;return{top:c,bottom:u,left:f,right:m,x:f||m,y:c||u}}var Jo=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))}},Ms=new Jo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),_p=new Jo(e=>setTimeout(e,50)),As=new Map,xp=As.clear.bind(As);function Nt(e,t=!1){if(!t)return El(e);let n=As.get(e);return n||(n=El(e),As.set(e,n),_p.schedule(xp),n)}function El(e){return St(e).getComputedStyle(e)}function Sp(e,t=Nt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Cp(e,t=Nt(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const a=t[s];return typeof a=="string"?n.test(a):!1})}var kp={excludeElement:!0,escapeShadowDOM:!0};function Ha(e,t=kp){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,a=new Set;function o(i){if(n!=null&&a.size>=n||!i)return a;if(Yo(i)&&i.scrollingElement!=null&&!a.has(i.scrollingElement))return a.add(i.scrollingElement),a;if(s&&qo(i))return o(i.host);if(!hn(i))return Au(i)?o(i.parentElement):a;if(a.has(i))return a;const l=Nt(i,!0);if(r&&i===e||Cp(i,l)&&a.add(i),Sp(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&a.add(c),a}return o(i.parentNode)}return e?o(e):a}function Ep(e){const[t]=Ha(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=Nn(e);for(;r;){if(r===t)return n;const s=Zs(r),{x:a,y:o}=Ip(r,s);n.x=n.x+s.left,n.y=n.y+s.top,n.scaleX=n.scaleX*a,n.scaleY=n.scaleY*o,r=Nn(r)}return n}function Ip(e,t=Zs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(hn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Nt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function Mp(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 Qo(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 ei(e){var t,n,r,s,a,o,i,l,c;const{scale:u,transform:f,translate:m}=e,d=Mp(u),h=Qo(m),v=Ap(f);if(!v&&!d&&!h)return null;const y={x:(t=d?.x)!=null?t:1,y:(n=d?.y)!=null?n:1},g={x:(r=h?.x)!=null?r:0,y:(s=h?.y)!=null?s:0},b={x:(a=v?.x)!=null?a:0,y:(o=v?.y)!=null?o:0,scaleX:(i=v?.scaleX)!=null?i:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:g.x+b.x,y:g.y+b.y,z:(c=h?.z)!=null?c:0,scaleX:y.x*b.scaleX,scaleY:y.y*b.scaleY}}function Ap(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 wt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(wt||{}),Tp={x:.2,y:.2},$p={x:10,y:10};function Rp(e,t,n,r=25,s=Tp,a=$p){const{x:o,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:f,isRight:m}=Vu(e),d=zn(e),h=Nt(e,!0),v=ei(h),y=v!==null?v?.scaleX<0:!1,g=v!==null?v?.scaleY<0:!1,b=new Pr(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},_={x:0,y:0},x={height:b.height*s.y,width:b.width*s.x};return(!c||g&&!u)&&i<=b.top+x.height&&n?.y!==1&&o>=b.left-a.x&&o<=b.right+a.x?(w.y=g?1:-1,_.y=r*Math.abs((b.top+x.height-i)/x.height)):(!u||g&&!c)&&i>=b.bottom-x.height&&n?.y!==-1&&o>=b.left-a.x&&o<=b.right+a.x&&(w.y=g?-1:1,_.y=r*Math.abs((b.bottom-x.height-i)/x.height)),(!m||y&&!f)&&o>=b.right-x.width&&n?.x!==-1&&i>=b.top-a.y&&i<=b.bottom+a.y?(w.x=y?-1:1,_.x=r*Math.abs((b.right-x.width-o)/x.width)):(!f||y&&!m)&&o<=b.left+x.width&&n?.x!==1&&i>=b.top-a.y&&i<=b.bottom+a.y&&(w.x=y?1:-1,_.x=r*Math.abs((b.left+x.width-o)/x.width)),{direction:w,speed:_}}function Dp(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function Pp(e,t=!1){if(Dp(e)){e.scrollIntoViewIfNeeded(t);return}if(!hn(e))return e.scrollIntoView();var n=Ep(e);if(!hn(n))return;const r=Nt(n,!0),s=parseInt(r.getPropertyValue("border-top-width")),a=parseInt(r.getPropertyValue("border-left-width")),o=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-a>n.scrollLeft+n.clientWidth,u=o&&!i;(o||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-a+e.clientWidth/2),(o||i||l||c)&&!t&&e.scrollIntoView(u)}function Fp(e,t,n){const{scaleX:r,scaleY:s,x:a,y:o}=t,i=e.left+a+(1-r)*parseFloat(n),l=e.top+o+(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 Op(e,t,n){const{scaleX:r,scaleY:s,x:a,y:o}=t,i=e.left-a-(1-r)*parseFloat(n),l=e.top-o-(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 Lp({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var Bp=new Jo(e=>setTimeout(e,0)),yr=new Map,Wp=yr.clear.bind(yr);function Vp(e){const t=e.ownerDocument;let n=yr.get(t);if(n)return n;n=t.getAnimations(),yr.set(t,n),Bp.schedule(Wp);const r=n.filter(s=>js(s.effect)&&s.effect.target===e);return yr.set(e,r),n}function Np(e,t){const n=Vp(e).filter(r=>{var s,a;if(js(r.effect)){const{target:o}=r.effect;if((a=o&&((s=t.isValidTarget)==null?void 0:s.call(t,o)))!=null?a:!0)return r.effect.getKeyframes().some(l=>{for(const c of t.properties)if(l[c])return!0})}}).map(r=>{const{effect:s,currentTime:a}=r,o=s?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof a=="number"&&a<o)return r.currentTime=o,()=>{r.currentTime=a}});if(n.length>0)return()=>n.forEach(r=>r?.())}var Bt=class extends Pr{constructor(e,t={}){var n,r,s,a;const{frameTransform:o=zn(e),ignoreTransforms:i,getBoundingClientRect:l=Zs}=t,c=Np(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||Ko())&&x.contains(e)}),u=l(e);let{top:f,left:m,width:d,height:h}=u,v;const y=Nt(e),g=ei(y),b={x:(n=g?.scaleX)!=null?n:1,y:(r=g?.scaleY)!=null?r:1},w=zp(e,y);c?.(),g&&(v=Op(u,g,y.transformOrigin),(i||w)&&(f=v.top,m=v.left,d=v.width,h=v.height));const _={width:(s=v?.width)!=null?s:d,height:(a=v?.height)!=null?a:h};if(w&&!i&&v){const x=Fp(v,w,y.transformOrigin);f=x.top,m=x.left,d=x.width,h=x.height,b.x=w.scaleX,b.y=w.scaleY}o&&(i||(m*=o.scaleX,d*=o.scaleX,f*=o.scaleY,h*=o.scaleY),m+=o.x,f+=o.y),super(m,f,d,h),this.scale=b,this.intrinsicWidth=_.width,this.intrinsicHeight=_.height}};function zp(e,t){var n;const r=e.getAnimations();let s=null;if(!r.length)return null;for(const a of r){if(a.playState!=="running")continue;const o=js(a.effect)?a.effect.getKeyframes():[],i=o[o.length-1];if(!i)continue;const{transform:l,translate:c,scale:u}=i;if(l||c||u){const f=ei({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 jp=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 a=`${t}${r}`;this.initial.has(a)||this.initial.set(a,n.style.getPropertyValue(a)),n.style.setProperty(a,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 pn(e){return e?e instanceof St(e).Element||Lr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function ti(e){if(!e)return!1;const{KeyboardEvent:t}=St(e.target);return e instanceof t}function Zp(e){if(!e)return!1;const{PointerEvent:t}=St(e.target);return e instanceof t}function Hp(e){if(!pn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||Gp(e)}function Gp(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var va={};function Ga(e){const t=va[e]==null?0:va[e]+1;return va[e]=t,`${e}-${t}`}var Up=({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=Rt.distance(t.shape.center,n);return{id:r,value:1/s,type:Mo.PointerIntersection,priority:Io.High}}return null},Xp=({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,a=Rt.distance(t.shape.center,s.current),i=r/(n.current.area+t.shape.area-r)/a;return{id:t.id,value:i,type:Mo.ShapeIntersection,priority:Io.Normal}}return null},Yp=e=>{var t;return(t=Up(e))!=null?t:Xp(e)},Kp=Object.create,ni=Object.defineProperty,qp=Object.defineProperties,Jp=Object.getOwnPropertyDescriptor,Qp=Object.getOwnPropertyDescriptors,Ts=Object.getOwnPropertySymbols,Nu=Object.prototype.hasOwnProperty,zu=Object.prototype.propertyIsEnumerable,ju=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Kn=e=>{throw TypeError(e)},Ua=(e,t,n)=>t in e?ni(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Er=(e,t)=>{for(var n in t||(t={}))Nu.call(t,n)&&Ua(e,n,t[n]);if(Ts)for(var n of Ts(t))zu.call(t,n)&&Ua(e,n,t[n]);return e},ri=(e,t)=>qp(e,Qp(t)),Il=(e,t)=>ni(e,"name",{value:t,configurable:!0}),Zu=(e,t)=>{var n={};for(var r in e)Nu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ts)for(var r of Ts(e))t.indexOf(r)<0&&zu.call(e,r)&&(n[r]=e[r]);return n},qn=e=>{var t;return[,,,Kp((t=e?.[ju("metadata")])!=null?t:null)]},Hu=["class","method","getter","setter","accessor","field","value","get","set"],fr=e=>e!==void 0&&typeof e!="function"?Kn("Function expected"):e,em=(e,t,n,r,s)=>({kind:Hu[e],name:t,metadata:r,addInitializer:a=>n._?Kn("Already initialized"):s.push(fr(a||null))}),wn=(e,t)=>Ua(t,ju("metadata"),e[3]),Be=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},vt=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,v=Hu[f+5],y=f>3&&(e[h-1]=[]),g=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&Jp(f<4?s:{get[n](){return Se(this,a)},set[n](_){return rt(this,a,_)}},n));f?d&&f<4&&Il(a,(f>2?"set ":f>1?"get ":"")+n):Il(s,n);for(var w=r.length-1;w>=0;w--)c=em(f,n,l={},e[3],g),f&&(c.static=m,c.private=d,u=c.access={has:d?_=>tm(s,_):_=>n in _},f^3&&(u.get=d?_=>(f^1?Se:mn)(_,s,f^4?a:b.get):_=>_[n]),f>2&&(u.set=d?(_,x)=>rt(_,s,x,f^4?a:b.set):(_,x)=>_[n]=x)),i=(0,r[w])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?fr(i)&&(f>4?y.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?Kn("Object expected"):(fr(o=i.get)&&(b.get=o),fr(o=i.set)&&(b.set=o),fr(o=i.init)&&y.unshift(o));return f||wn(e,s),b&&ni(s,n,b),d?f^4?a:b:s},si=(e,t,n)=>t.has(e)||Kn("Cannot "+n),tm=(e,t)=>Object(t)!==t?Kn('Cannot use the "in" operator on this value'):e.has(t),Se=(e,t,n)=>(si(e,t,"read from private field"),n?n.call(e):t.get(e)),De=(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),rt=(e,t,n,r)=>(si(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),mn=(e,t,n)=>(si(e,t,"access private method"),n),Ml={role:"button",roleDescription:"draggable"},nm="dnd-kit-description",rm="dnd-kit-announcement",sm={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."},am={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 om(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function im(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function lm(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 cm=["dragover","dragmove"],um=class extends lt{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=nm,announcement:s=rm}={},announcements:a=am,screenReaderInstructions:o=sm,debounce:i=500}=t??{},l=n?`${r}-${n}`:Ga(r),c=n?`${s}-${n}`:Ga(s);let u,f,m,d;const h=(x=d)=>{!m||!x||m?.nodeValue!==x&&(m.nodeValue=x)},v=()=>Ms.schedule(h),y=dm(v,i),g=Object.entries(a).map(([x,C])=>this.manager.monitor.addEventListener(x,(k,I)=>{const E=m;if(!E)return;const T=C?.(k,I);T&&E.nodeValue!==T&&(d=T,cm.includes(x)?y():(v(),y.cancel()))})),b=()=>{let x=[];u?.isConnected||(u=im(l,o.draggable),x.push(u)),f?.isConnected||(f=lm(c),m=document.createTextNode(""),f.appendChild(m),x.push(f)),x.length>0&&document.body.append(...x)},w=new Set;function _(){for(const x of w)x()}this.registerEffect(()=>{var x;w.clear();for(const C of this.manager.registry.draggables.value){const k=(x=C.handle)!=null?x:C.element;if(k){(!u||!f)&&w.add(b),(!om(k)||Ko())&&!k.hasAttribute("tabindex")&&w.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&w.add(()=>k.setAttribute("role",Ml.role)),k.hasAttribute("aria-roledescription")||w.add(()=>k.setAttribute("aria-roledescription",Ml.roleDescription)),k.hasAttribute("aria-describedby")||w.add(()=>k.setAttribute("aria-describedby",l));for(const E of["aria-pressed","aria-grabbed"]){const T=String(C.isDragging);k.getAttribute(E)!==T&&w.add(()=>k.setAttribute(E,T))}const I=String(C.disabled);k.getAttribute("aria-disabled")!==I&&w.add(()=>k.setAttribute("aria-disabled",I))}}w.size>0&&Ms.schedule(_)}),this.destroy=()=>{super.destroy(),u?.remove(),f?.remove(),g.forEach(x=>x())}}};function dm(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var fm=class extends lt{constructor(e,t){super(e,t),this.manager=e;const n=xs(()=>{var r;return bn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=xt(()=>{var r;const{dragOperation:s}=this.manager,{cursor:a="grabbing",nonce:o}=(r=this.options)!=null?r:{};if(s.status.initialized){const i=n.value,l=i.createElement("style");return o&&l.setAttribute("nonce",o),l.textContent=`* { cursor: ${a} !important; }`,i.head.appendChild(l),()=>l.remove()}})}},$s=new Map,Gu,Uu,Xu,Yu,Xa,wr,Wt,ai,jn,Ku,qu,Ju,Qu,_n=class extends(Xa=Or,Yu=[he],Xu=[Ae],Uu=[Ae],Gu=[Ae],Xa){constructor(e){super(e),Be(Wt,5,this),De(this,jn),De(this,wr,new Set),De(this,ai,Be(Wt,8,this,new Set)),Be(Wt,11,this),this.registerEffect(mn(this,jn,Ku))}register(e){return Se(this,wr).add(e),()=>{Se(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 ks((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return ks((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}};Wt=qn(Xa);wr=new WeakMap;ai=new WeakMap;jn=new WeakSet;Ku=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Se(this,wr))t.push(mn(this,jn,qu).call(this,n,r));return()=>{for(const n of t)n()}};qu=function(e,t){let n=$s.get(e);n||(n=new Map,$s.set(e,n));let r=n.get(t);if(!r){const a=Yo(e)?mn(this,jn,Ju).call(this,e,n,t):mn(this,jn,Qu).call(this,e,n,t);if(!a)return()=>{};r=a,n.set(t,r)}r.refCount++;let s=!1;return()=>{s||(s=!0,r.refCount--,r.refCount===0&&r.cleanup())}};Ju=function(e,t,n){const r=e.createElement("style");r.textContent=n,e.head.prepend(r);const s=new MutationObserver(a=>{for(const o of a)for(const i of Array.from(o.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&&$s.delete(e)}}};Qu=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 a=new s;return a.replaceSync(n),e.adoptedStyleSheets.push(a),{refCount:0,cleanup:()=>{var o;if(qo(e)&&((o=e.host)!=null&&o.isConnected)){const i=e.adoptedStyleSheets.indexOf(a);i!==-1&&e.adoptedStyleSheets.splice(i,1)}t.delete(n),t.size===0&&$s.delete(e)}}};vt(Wt,4,"additionalRoots",Yu,_n,ai);vt(Wt,2,"sourceRoot",Xu,_n);vt(Wt,2,"targetRoot",Uu,_n);vt(Wt,2,"roots",Gu,_n);wn(Wt,_n);var Br="data-dnd-",Ya=`${Br}dropping`,Je="--dnd-",$t=`${Br}dragging`,Rs=`${Br}placeholder`,hm=[$t,Rs,"popover","aria-pressed","aria-grabbing"],pm=["view-transition-name"],mm=`
|
|
9
|
+
:is(:root,:host) [${$t}] {
|
|
10
10
|
position: fixed !important;
|
|
11
11
|
pointer-events: none !important;
|
|
12
12
|
touch-action: none;
|
|
@@ -23,29 +23,29 @@
|
|
|
23
23
|
transition: var(${Je}transition) !important;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
:is(:root,:host) [${
|
|
26
|
+
:is(:root,:host) [${Rs}] {
|
|
27
27
|
transition: none;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
:is(:root,:host) [${
|
|
30
|
+
:is(:root,:host) [${Rs}='hidden'] {
|
|
31
31
|
visibility: hidden;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
[${
|
|
34
|
+
[${$t}] * {
|
|
35
35
|
pointer-events: none !important;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
[${
|
|
38
|
+
[${$t}]:not([${Ya}]) {
|
|
39
39
|
translate: var(${Je}translate) !important;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
[${
|
|
42
|
+
[${$t}][style*='${Je}scale'] {
|
|
43
43
|
scale: var(${Je}scale) !important;
|
|
44
44
|
transform-origin: var(${Je}transform-origin) !important;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@layer dnd-kit {
|
|
48
|
-
:where([${
|
|
48
|
+
:where([${$t}][popover]) {
|
|
49
49
|
overflow: visible;
|
|
50
50
|
background: unset;
|
|
51
51
|
border: unset;
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
[${
|
|
62
|
+
[${$t}]::backdrop, [${Br}overlay]:not([${$t}]) {
|
|
63
63
|
display: none;
|
|
64
64
|
visibility: hidden;
|
|
65
65
|
}
|
|
66
|
-
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function rm(e,t="hidden"){return we(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=sm(n,r.registry.droppables),o=[],a=Xh(n),{remove:i}=a;return om(s,a,o),am(a,t),a.remove=()=>{o.forEach(l=>l()),i.call(a)},a})}function sm(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Lr}${Zo("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function om(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),gl.set(i,a),n.push(()=>{gl.delete(i),r.proxy=void 0})}}function am(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Ms,t)}function Zu(e,t){return e===t?!0:Vn(e)===Vn(t)}function xl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&gn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>Sr(t))}function Xo(e){return e.tagName==="TR"}function im(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-")||em.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(vr(e)&&vr(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(tm.includes(u)||u.startsWith(Je))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 lm(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),Sr(n);return}if(a.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),Sr(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function cm(e){return new ResizeObserver(()=>{var t,n;const r=new Nt(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=_u();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},Je),(n=e.getElementMutationObserver())==null||n.takeRecords(),Xo(e.element)&&Xo(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 h=c[u];f.style.width=`${h.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Nt(e.feedbackElement)})}var um=250,dm="ease";function fm(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=um,easing:i=dm}=o??{};Sr(e.feedbackElement);const[,l]=(t=Zh(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:Zu(e.feedbackElement,c)?null:void 0},f=new Nt(e.feedbackElement,u),h=(r=Xa(Zt(e.feedbackElement).translate))!=null?r:e.translate,d=new Nt(c,u),p=Dr.delta(f,d,e.alignment),v={x:h.x-p.x,y:h.y-p.y},y=Math.round(f.intrinsicHeight)!==Math.round(d.intrinsicHeight)?{minHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`],maxHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`]}:{},m=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},Je),e.feedbackElement.setAttribute(Uo,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),Sp({element:e.feedbackElement,keyframes:Ja(kr(kr({},y),m),{translate:[`${h.x}px ${h.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:xu(St(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?a:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(Uo),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Hu,Yo,Er,ti,fs,Gu,Uu,Ir=class extends(Yo=it,Hu=[de],Yo){constructor(t,n){super(t,n),De(this,fs),De(this,ti,We(Er,8,this)),We(Er,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(xn),s=r?.register(nm);if(s){const o=this.destroy.bind(this);this.destroy=()=>{s(),o()}}this.registerEffect(vn(this,fs,Gu).bind(this,r)),this.registerEffect(vn(this,fs,Uu))}};Er=Kn(Yo);ti=new WeakMap;fs=new WeakSet;Gu=function(e){const{overlay:t}=this;if(!t||!e)return;const n=_s(t);if(n)return e.addRoot(n)};Uu=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:h}=r,d=(e=this.overlay)!=null?e:u,p=Nn(d),v=Nn(u),y=!Zu(u,d),m=new Nt(u,{frameTransform:y?v:null,ignoreTransforms:!y}),b={x:v.scaleX/p.scaleX,y:v.scaleY/p.scaleY};let{width:_,height:w,top:x,left:S}=m;y&&(_=_/b.x,w=w/b.y);const k=new Tp(d),{transition:E,translate:T,boxSizing:I,paddingBlockStart:M,paddingBlockEnd:$,paddingInlineStart:A,paddingInlineEnd:R,borderInlineStartWidth:W,borderInlineEndWidth:q,borderBlockStartWidth:z,borderBlockEndWidth:J}=Zt(u),ee=f==="clone",j=I==="content-box",se=j?parseInt(A)+parseInt(R)+parseInt(W)+parseInt(q):0,U=j?parseInt(M)+parseInt($)+parseInt(z)+parseInt(J):0,ie=f!=="move"&&!this.overlay?rm(l,ee?"clone":"hidden"):null,le=we(()=>Ka(s.dragOperation.activatorEvent));if(T!=="none"){const oe=Xa(T);oe&&!h.translate&&(h.translate=oe)}if(!h.transformOrigin){const oe=we(()=>i.current);h.transformOrigin={x:(oe.x-S*p.scaleX-p.x)/(_*p.scaleX),y:(oe.y-x*p.scaleY-p.y)/(w*p.scaleY)}}const{transformOrigin:ge}=h,Se=x*p.scaleY+p.y,N=S*p.scaleX+p.x;if(!h.coordinates&&(h.coordinates={x:N,y:Se},b.x!==1||b.y!==1)){const{scaleX:oe,scaleY:he}=v,{x:Xe,y:At}=ge;h.coordinates.x+=(_*oe-_)*Xe,h.coordinates.y+=(w*he-w)*At}h.dimensions||(h.dimensions={width:_,height:w}),h.frameTransform||(h.frameTransform=p);const G={x:h.coordinates.x-N,y:h.coordinates.y-Se},ye={width:(h.dimensions.width*h.frameTransform.scaleX-_*p.scaleX)*ge.x,height:(h.dimensions.height*h.frameTransform.scaleY-w*p.scaleY)*ge.y},Z={x:G.x/p.scaleX+ye.width,y:G.y/p.scaleY+ye.height},Q={left:S+Z.x,top:x+Z.y};d.setAttribute(Dt,"true");const O=we(()=>a.transform),_e=(t=h.translate)!=null?t:{x:0,y:0},Ne=O.x*p.scaleX+_e.x,Be=O.y*p.scaleY+_e.y,ve=_u();k.set({width:_-se,height:w-U,top:Q.top+ve.y,left:Q.left+ve.x,translate:`${Ne}px ${Be}px 0`,transition:E?`${E}, translate 0ms linear`:"",scale:y?`${b.x} ${b.y}`:"","transform-origin":`${ge.x*100}% ${ge.y*100}%`},Je),ie&&(u.insertAdjacentElement("afterend",ie),o?.rootElement&&(typeof o.rootElement=="function"?o.rootElement(l):o.rootElement).appendChild(u)),zo(d)&&(d.hasAttribute("popover")||d.setAttribute("popover","manual"),Sr(d),d.addEventListener("beforetoggle",xl));let Ve,ne,Ge;const je=cm({placeholder:ie,element:u,feedbackElement:d,frameTransform:p,transformOrigin:ge,width:_,height:w,top:x,left:S,widthOffset:se,heightOffset:U,delta:Z,styles:k,dragOperation:a,getElementMutationObserver:()=>Ve,getSavedCellWidths:()=>Ge,setSavedCellWidths:oe=>{Ge=oe}}),xe=new Nt(d);we(()=>a.shape=xe);const Fe=St(d),Oe=oe=>{this.manager.actions.stop({event:oe})},Et=xu(Fe);le&&Fe.addEventListener("resize",Oe),we(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),ie&&(je.observe(ie),Ve=im(u,ie,ee),ne=lm(u,ie,d));const It=(n=s.dragOperation.source)==null?void 0:n.id,Mt=()=>{var oe;if(!le||It==null)return;const he=s.registry.draggables.get(It),Xe=(oe=he?.handle)!=null?oe:he?.element;mn(Xe)&&Xe.focus()},X=()=>{var oe;if(Ve?.disconnect(),ne?.disconnect(),je.disconnect(),Fe.removeEventListener("resize",Oe),zo(d)&&(d.removeEventListener("beforetoggle",xl),d.removeAttribute("popover")),d.removeAttribute(Dt),k.reset(),Ge&&Xo(u)){const Xe=Array.from(u.cells);for(const[At,Tt]of Xe.entries())Tt.style.width=(oe=Ge[At])!=null?oe:""}l.status="idle";const he=r.current.translate!=null;ie&&(he||ie.parentElement!==d.parentElement)&&d.isConnected&&ie.replaceWith(d),ie?.remove()},fe=o?.dropAnimation,Ue=this,Me=Rr(()=>{var oe;const{transform:he,status:Xe}=a;if(!(!he.x&&!he.y&&!r.current.translate)&&Xe.dragging){const At=(oe=h.translate)!=null?oe:{x:0,y:0},Tt={x:he.x/p.scaleX+At.x,y:he.y/p.scaleY+At.y},ut=r.current.translate,yt=we(()=>a.modifiers),V=we(()=>{var K;return(K=a.shape)==null?void 0:K.current}),Y=le&&!Et?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${E}, translate ${Y}`,translate:`${Tt.x}px ${Tt.y}px 0`},Je),Ve?.takeRecords(),V&&V!==xe&&ut&&!yt.length){const K=Pt.delta(Tt,ut);a.shape=Dr.from(V.boundingRectangle).translate(K.x*p.scaleX,K.y*p.scaleY)}else a.shape=new Nt(d);r.current.translate=Tt}},function(){if(a.status.dropped){this.dispose(),l.status="dropping";const oe=Ue.dropAnimation!==void 0?Ue.dropAnimation:fe;let he=r.current.translate;const Xe=he!=null;if(!he&&u!==d&&(he={x:0,y:0}),!he||oe===null){X();return}s.renderer.rendering.then(()=>{fm({element:u,feedbackElement:d,placeholder:ie,translate:he,moved:Xe,transition:E,alignment:l.alignment,styles:k,animation:oe??void 0,getElementMutationObserver:()=>Ve,cleanup:X,restoreFocus:Mt})})}});return()=>{X(),Me()}};gt(Er,4,"overlay",Hu,Ir,ti);_n(Er,Ir);Ir.configure=Xn(Ir);var Ko=Ir,Jn=!0,hm=!1,Xu,Yu,Ku,qu,Kt,ni,ri;qu=(Ku=[de],_t.Forward),Yu=(Xu=[de],_t.Reverse);var Mr=class{constructor(){De(this,ni,We(Kt,8,this,Jn)),We(Kt,11,this),De(this,ri,We(Kt,12,this,Jn)),We(Kt,15,this)}isLocked(e){return e===_t.Idle?!1:e==null?this[_t.Forward]===Jn&&this[_t.Reverse]===Jn:this[e]===Jn}unlock(e){e!==_t.Idle&&(this[e]=hm)}};Kt=Kn(null);ni=new WeakMap;ri=new WeakMap;gt(Kt,4,qu,Ku,Mr,ni);gt(Kt,4,Yu,Xu,Mr,ri);_n(Kt,Mr);var pm=[_t.Forward,_t.Reverse],Cl=class{constructor(){this.x=new Mr,this.y=new Mr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},mm=class extends it{constructor(e){super(e);const t=$r(new Cl);let n=null;this.signal=t,Ct(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Cl;return}const{delta:s}=e.dragOperation.position;if(n){const o={x:Sl(s.x,n.x),y:Sl(s.y,n.y)},a=t.peek();Qt(()=>{for(const i of Mc)for(const l of pm)o[i]===l&&a[i].unlock(l);t.value=a})}n=s})}get current(){return this.signal.peek()}};function Sl(e,t){return Math.sign(e-t)}var Ju,qo,Ar,si,Xt,Jo,Vs=class extends(qo=Fr,Ju=[de],qo){constructor(e){super(e),De(this,si,We(Ar,8,this,!1)),We(Ar,11,this),De(this,Xt),De(this,Jo,()=>{if(!Ce(this,Xt))return;const{element:o,by:a}=Ce(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:kl(u.x),y:kl(u.y)}:void 0,h=f?void 0:this.scrollIntentTracker.current;if(h?.isLocked())return!1;for(const d of i){const p=ip(d,u);if(p.x||p.y){const{speed:v,direction:y}=bp(d,c,f);if(h)for(const m of Mc)h[m].isLocked(y[m])&&(v[m]=0,y[m]=0);if(y.x||y.y){const{x:m,y:b}=u??y,_=m*v.x,w=b*v.y;if(_||w){const x=(a=Ce(this,Xt))==null?void 0:a.by;if(this.autoScrolling&&x&&(x.x&&!_||x.y&&!w))continue;return rt(this,Xt,{element:d,by:{x:_,y:w}}),Ss.schedule(Ce(this,Jo)),!0}}}}}return rt(this,Xt,void 0),!1};let t=null,n=null;const r=ys(()=>{const{position:o,source:a}=e.dragOperation;if(!o)return null;const i=Cu(_s(a?.element),o.current);return i&&(t=i),i??t}),s=ys(()=>{const o=r.value,{documentElement:a}=wn(o);if(!o||o===a){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=jo(l,{excludeElement:!1});return n=c,c}}if(o){const i=jo(o,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},_r);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new mm(e),this.destroy=e.monitor.addEventListener("dragmove",o=>{this.disabled||o.defaultPrevented||!Ka(e.dragOperation.activatorEvent)||!o.by||this.scroll({by:o.by})&&o.preventDefault()})}};Ar=Kn(qo);si=new WeakMap;Xt=new WeakMap;Jo=new WeakMap;gt(Ar,4,"autoScrolling",Ju,Vs,si);_n(Ar,Vs);function kl(e){return e>0?_t.Forward:e<0?_t.Reverse:_t.Idle}var gm=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))}},vm=new gm(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),ym=10,Qu=class extends it{constructor(e,t){super(e);const n=e.registry.plugins.get(Vs);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=Ct(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const a=setInterval(()=>vm.schedule(n.scroll),ym);return()=>{clearInterval(a)}}else n.autoScrolling=!1})}},El={capture:!0,passive:!0},fr,bm=class extends Fr{constructor(e){super(e),De(this,fr),this.handleScroll=()=>{Ce(this,fr)==null&&rt(this,fr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),rt(this,fr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=Ct(()=>{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,El),()=>{a.removeEventListener("scroll",this.handleScroll,El)}}})}};fr=new WeakMap;var wm=class extends it{constructor(e,t){super(e,t),this.manager=e,this.destroy=Ct(()=>{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),mo(),document.addEventListener("selectionchange",mo,{capture:!0}),()=>{document.removeEventListener("selectionchange",mo,{capture:!0}),o.remove()}}})}};function mo(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var hr=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,As=class extends Wn{constructor(t,n){super(t),this.manager=t,this.options=n,De(this,Dn,[]),this.listeners=new Su,this.handleSourceKeyDown=(r,s,o)=>{if(this.disabled||r.defaultPrevented||!gn(r.target)||s.disabled)return;const{keyboardCodes:a=hr.keyboardCodes,preventActivation:i=hr.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 Ct(()=>{var s;const o=(s=t.handle)!=null?s:t.element,a=i=>{Ka(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(),_p(s);const{center:o}=new Nt(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}}])];Ce(this,Dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=hr.keyboardCodes}=r??{};if(In(t,[...s.end,...s.cancel])){t.preventDefault();const o=In(t,s.cancel);this.handleEnd(t,o);return}In(t,s.up)?this.handleMove("up",t):In(t,s.down)&&this.handleMove("down",t),In(t,s.left)?this.handleMove("left",t):In(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:hr.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(Qu);t?.disabled===!1&&(t.disable(),Ce(this,Dn).push(()=>{t.enable()}))}cleanup(){Ce(this,Dn).forEach(t=>t()),rt(this,Dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};Dn=new WeakMap;As.configure=Xn(As);As.defaults=hr;var _m=As;function In(e,t){return t.includes(e.code)}var fn,xm=class extends iu{constructor(){super(...arguments),De(this,fn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,fn,Bn(e));break;case"pointermove":if(!Ce(this,fn))return;const{x:t,y:n}=Bn(e),r={x:t-Ce(this,fn).x,y:n-Ce(this,fn).y},{tolerance:s}=this.options;if(s&&Oo(r,s)){this.abort();return}Oo(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){rt(this,fn,void 0)}};fn=new WeakMap;var Pn,hn,Cm=class extends iu{constructor(){super(...arguments),De(this,Pn),De(this,hn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,hn,Bn(e)),rt(this,Pn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Ce(this,hn))return;const{x:t,y:n}=Bn(e),r={x:t-Ce(this,hn).x,y:n-Ce(this,hn).y};Oo(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Ce(this,Pn)&&(clearTimeout(Ce(this,Pn)),rt(this,hn,void 0),rt(this,Pn,void 0))}};Pn=new WeakMap;hn=new WeakMap;var Bt=class{};Bt.Delay=Cm;Bt.Distance=xm;var Qo=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&gn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Bt.Delay({value:250,tolerance:5})]:Rp(s)&&!e.defaultPrevented?[new Bt.Delay({value:200,tolerance:0})]:[new Bt.Delay({value:200,tolerance:10}),new Bt.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;return r===t.element||r===t.handle||!gn(r)||(n=t.handle)!=null&&n.contains(r)?!1:Kh(r)}}),Fn,Ts=class extends Wn{constructor(t,n){super(t),this.manager=t,this.options=n,De(this,Fn,new Set),this.listeners=new Su,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=Qo.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return Ct(()=>{var s;const o=new AbortController,{signal:a}=o,i=c=>{$p(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&&(Em(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:a}));return()=>o.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!gn(t.target)||n.disabled||Sm(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=Qo.preventActivation}=r??{};if(s?.(t,n))return;const{target:o}=t,a=mn(o)&&o.draggable&&o.getAttribute("draggable")==="true",i=Nn(n.element),{x:l,y:c}=Bn(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 Vh(u,v=>this.handleStart(n,v));f.signal.onabort=()=>this.handleCancel(t),f.onEvent(t),this.controller=f;const h=Vo(),d=this.listeners.bind(h,[{type:"pointermove",listener:v=>this.handlePointerMove(v,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:a?this.handleCancel:ts,options:{capture:!0}}]),p=()=>{d(),this.initialCoordinates=void 0};Ce(this,Fn).add(p)}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=Bn(t),a=Nn(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,Ss.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=gn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:ts,options:{passive:!1}},{type:"click",listener:ts},{type:"contextmenu",listener:ts},{type:"keydown",listener:this.handleKeyDown}]);Ce(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},Ce(this,Fn).forEach(t=>t()),Ce(this,Fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Fn=new WeakMap;Ts.configure=Xn(Ts);Ts.defaults=Qo;var ea=Ts;function Sm(e){return"sensor"in e}function ts(e){e.preventDefault()}function km(){}var Il=new WeakSet;function Em(e){!e||Il.has(e)||(e.addEventListener("touchmove",km,{capture:!1,passive:!1}),Il.add(e))}var On={modifiers:[],plugins:[qp,Qu,Qp,Ko,wm],sensors:[ea,_m]},oi=class extends jh{constructor(e={}){const t=Vt(e.plugins,On.plugins),n=Vt(e.sensors,On.sensors),r=Vt(e.modifiers,On.modifiers);super(Ja(kr({},e),{plugins:[bm,Vs,xn,...t],sensors:n,modifiers:r}))}},ed,td,nd,ta,$t,ai,ii,li,Wr=class extends(ta=Ft,nd=[de],td=[de],ed=[de],ta){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:o,feedback:a="default"}=n,i=Pu(n,["element","effects","handle","feedback"]);super(kr({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const h=((c=(l=this.sensors)==null?void 0:l.map(wa))!=null?c:[...u.sensors]).map(d=>{const p=d instanceof Wn?d:u.registry.register(d.plugin),v=d instanceof Wn?void 0:d.options;return p.bind(this,v)});return function(){h.forEach(p=>p())}}]},i),t),De(this,ai,We($t,8,this)),We($t,11,this),De(this,ii,We($t,12,this)),We($t,15,this),De(this,li,We($t,16,this)),We($t,19,this),this.element=r,this.handle=o,this.feedback=a}};$t=Kn(ta);ai=new WeakMap;ii=new WeakMap;li=new WeakMap;gt($t,4,"handle",nd,Wr,ai);gt($t,4,"element",td,Wr,ii);gt($t,4,"feedback",ed,Wr,li);_n($t,Wr);var rd,sd,na,qt,ci,go,od,ad,br,ui,id=class extends(na=Ot,sd=[de],rd=[de],na){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,o=Pu(n,["element","effects"]);const{collisionDetector:a=Op}=o,i=c=>{const{manager:u,element:f}=this;if(!f||c===null){this.shape=void 0;return}if(!u)return;const h=new Nt(f),d=we(()=>this.shape);return h&&d?.equals(h)?d:(this.shape=h,h)},l=$r(!1);super(Ja(kr({},o),{collisionDetector:a,effects:()=>[...s(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:f}=u,{source:h}=f;l.value=!!(h&&f.status.initialized&&c&&!this.disabled&&this.accepts(h))},()=>{const{element:c}=this;if(l.value&&c){const u=new ap(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),De(this,br),De(this,ci,We(qt,8,this)),We(qt,11,this),De(this,ui,We(qt,12,this)),We(qt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){rt(this,br,e,ad)}get element(){var e;return(e=this.proxy)!=null?e:Ce(this,br,od)}};qt=Kn(na);ci=new WeakMap;br=new WeakSet;ui=new WeakMap;go=gt(qt,20,"#element",sd,br,ci),od=go.get,ad=go.set;gt(qt,4,"proxy",rd,id,ui);_n(qt,id);function Im(e){return e!=null&&typeof e=="object"&&"current"in e}function $s(e){var t;if(e!=null)return Im(e)?(t=e.current)!=null?t:void 0:e}var Mm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ns=Mm?g.useLayoutEffect:g.useEffect;function Am(){const e=g.useState(0)[1];return g.useCallback(()=>{e(t=>t+1)},[e])}function Tm(e,t){const n=g.useRef(new Map),r=Am();return Ns(()=>{if(!e){n.current.clear();return}return Ct(()=>{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?da.flushSync(r):r())})},[e]),g.useMemo(()=>e&&new Proxy(e,{get(s,o){const a=s[o];return n.current.set(o,a),a}}),[e])}function ln(e,t,n=g.useEffect,r=Object.is){const s=g.useRef(e);n(()=>{const o=s.current;r(e,o)||(s.current=e,t(e,o))},[t,e])}function Ml(e,t){const n=g.useRef($s(e));Ns(()=>{const r=$s(e);r!==n.current&&(n.current=r,t(r))})}var $m=Object.defineProperty,Rm=Object.defineProperties,Dm=Object.getOwnPropertyDescriptors,Al=Object.getOwnPropertySymbols,Pm=Object.prototype.hasOwnProperty,Fm=Object.prototype.propertyIsEnumerable,Tl=(e,t,n)=>t in e?$m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Om=(e,t)=>{for(var n in t||(t={}))Pm.call(t,n)&&Tl(e,n,t[n]);if(Al)for(var n of Al(t))Fm.call(t,n)&&Tl(e,n,t[n]);return e},Lm=(e,t)=>Rm(e,Dm(t)),Wm=new oi,Bm=g.createContext(Wm);g.memo(g.forwardRef(({children:e},t)=>{const[n,r]=g.useState(0),s=g.useRef(null),o=g.useRef(null),a=g.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})),g.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Ns(()=>{var i;(i=o.current)==null||i.call(o),s.current=null},[e,n]),g.useImperativeHandle(t,()=>a),null}));function Vm(){return g.useContext(Bm)}function Nm(e){var t;const n=(t=Vm())!=null?t:void 0,[r]=g.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ns(r.register,[n,r]),r}function vo(e){const{disabled:t,data:n,element:r,handle:s,id:o,modifiers:a,sensors:i}=e,l=Nm(u=>new Wr(Lm(Om({},e),{register:!1,handle:$s(s),element:$s(r)}),u)),c=Tm(l,zm);return ln(o,()=>l.id=o),Ml(s,u=>l.handle=u),Ml(r,u=>l.element=u),ln(n,()=>n&&(l.data=n)),ln(t,()=>l.disabled=t===!0),ln(i,()=>l.sensors=i),ln(a,()=>l.modifiers=a,void 0,_r),ln(e.feedback,()=>{var u;return l.feedback=(u=e.feedback)!=null?u:"default"}),ln(e.alignment,()=>l.alignment=e.alignment),{draggable:c,get isDragging(){return c.isDragging},get isDropping(){return c.isDropping},get isDragSource(){return c.isDragSource},handleRef:g.useCallback(u=>{l.handle=u??void 0},[l]),ref:g.useCallback(u=>{var f,h;!u&&((f=l.element)!=null&&f.isConnected)&&!((h=l.manager)!=null&&h.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function zm(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var jm=Object.create,ld=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,cd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),zs=e=>{throw TypeError(e)},Hm=(e,t,n)=>t in e?ld(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gm=e=>{var t;return[,,,jm((t=e?.[cd("metadata")])!=null?t:null)]},ud=["class","method","getter","setter","accessor","field","value","get","set"],dd=e=>e!==void 0&&typeof e!="function"?zs("Function expected"):e,Um=(e,t,n,r,s)=>({kind:ud[e],name:t,metadata:r,addInitializer:o=>n._?zs("Already initialized"):s.push(dd(o||null))}),Xm=(e,t)=>Hm(t,cd("metadata"),e[3]),Ym=(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},fd=(e,t,n,r,s,o)=>{for(var a,i,l,c,u=t&7,f=!1,h=!1,d=2,p=ud[u+5],v=e[d]||(e[d]=[]),y=(s=s.prototype,Zm(s,n)),m=r.length-1;m>=0;m--)l=Um(u,n,i={},e[3],v),l.static=f,l.private=h,c=l.access={has:b=>n in b},c.get=b=>b[n],a=(0,r[m])(y[p],l),i._=1,dd(a)&&(y[p]=a);return y&&ld(s,n,y),s},hd=(e,t,n)=>t.has(e)||zs("Cannot "+n),Km=(e,t,n)=>(hd(e,t,"read from private field"),t.get(e)),qm=(e,t,n)=>t.has(e)?zs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Jm=(e,t,n,r)=>(hd(e,t,"write to private field"),t.set(e,n),n),Qn=class ra{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ra(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 ra(t,n)}},pd,md,sa,hs,Br,di=class extends(sa=tn,md=[Ie],pd=[Ie],sa){constructor(t){const n=Qn.from(t);super(n,(r,s)=>Qn.equals(r,s)),Ym(Br,5,this),qm(this,hs,0),this.velocity={x:0,y:0}}get delta(){return Qn.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=Qn.from(t),s={x:r.x-n.x,y:r.y-n.y},o=Date.now(),a=o-Km(this,hs),i=l=>Math.round(l/a*100);Qt(()=>{Jm(this,hs,o),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Qn.from(t)),this.velocity={x:0,y:0}}};Br=Gm(sa);hs=new WeakMap;fd(Br,2,"delta",md,di);fd(Br,2,"direction",pd,di);Xm(Br,di);var gd=(e=>(e.Horizontal="x",e.Vertical="y",e))(gd||{});Object.values(gd);const Qm=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),eg=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),tg=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),ng=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),rg=g.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Vr=D.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:h="regular",mirrored:d=!1,...p}=D.useContext(rg);return D.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,...p,...c},!!n&&D.createElement("title",null,n),i,l.get(o??h))});Vr.displayName="IconBase";const vd=D.forwardRef((e,t)=>D.createElement(Vr,{ref:t,...e,weights:Qm}));vd.displayName="DotsThreeIcon";const yd=D.forwardRef((e,t)=>D.createElement(Vr,{ref:t,...e,weights:eg}));yd.displayName="SpeakerHighIcon";const bd=D.forwardRef((e,t)=>D.createElement(Vr,{ref:t,...e,weights:tg}));bd.displayName="SpeakerLowIcon";const wd=D.forwardRef((e,t)=>D.createElement(Vr,{ref:t,...e,weights:ng}));wd.displayName="XIcon";const sg=wd;P.span`
|
|
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=vm(n,r.registry.droppables),a=[],o=ip(n),{remove:i}=o;return ym(s,o,a),bm(o,t),o.remove=()=>{a.forEach(l=>l()),i.call(o)},o})}function vm(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Br}${Ga("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function ym(e,t,n){for(const[r,s]of e){if(!r.element)continue;const a=`[${s}]`,o=t.matches(a)?t:t.querySelector(a);if(r.element.removeAttribute(s),!o)continue;const i=r.element;r.proxy=o,o.removeAttribute(s),Sl.set(i,o),n.push(()=>{Sl.delete(i),r.proxy=void 0})}}function bm(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Rs,t)}function ed(e,t){return e===t?!0:Nn(e)===Nn(t)}function Al(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&pn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>kr(t))}function Ka(e){return e.tagName==="TR"}function wm(e,t,n){const r=new MutationObserver(s=>{let a=!1;for(const o of s){if(o.target!==e){a=!0;continue}if(o.type!=="attributes")continue;const i=o.attributeName;if(i.startsWith("aria-")||hm.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(pm.includes(u)||u.startsWith(Je))continue;const f=c.getPropertyValue(u);t.style.setProperty(u,f)}}}else l!==null?t.setAttribute(i,l):t.removeAttribute(i)}a&&n&&(t.innerHTML=e.innerHTML)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function _m(e,t,n){const r=new MutationObserver(s=>{for(const a of s)if(a.addedNodes.length!==0)for(const o of Array.from(a.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),kr(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),kr(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function xm(e){return new ResizeObserver(()=>{var t,n;const r=new Bt(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},a=(e.width-r.width)*s.x+e.delta.x,o=(e.height-r.height)*s.y+e.delta.y,i=$u();if(e.styles.set({width:r.width-e.widthOffset,height:r.height-e.heightOffset,top:e.top+o+i.y,left:e.left+a+i.x},Je),(n=e.getElementMutationObserver())==null||n.takeRecords(),Ka(e.element)&&Ka(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 m=c[u];f.style.width=`${m.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Bt(e.feedbackElement)})}var Sm=250,Cm="ease";function km(e){var t,n,r,s;const{animation:a}=e;if(typeof a=="function"){const b=a({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:o=Sm,easing:i=Cm}=a??{};kr(e.feedbackElement);const[,l]=(t=rp(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:ed(e.feedbackElement,c)?null:void 0},f=new Bt(e.feedbackElement,u),m=(r=Qo(Nt(e.feedbackElement).translate))!=null?r:e.translate,d=new Bt(c,u),h=Pr.delta(f,d,e.alignment),v={x:m.x-h.x,y:m.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`]}:{},g=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},Je),e.feedbackElement.setAttribute(Ya,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),Lp({element:e.feedbackElement,keyframes:ri(Er(Er({},y),g),{translate:[`${m.x}px ${m.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:Ru(St(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(Ya),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var td,qa,Ir,oi,gs,nd,rd,Mr=class extends(qa=lt,td=[he],qa){constructor(t,n){super(t,n),De(this,gs),De(this,oi,Be(Ir,8,this)),Be(Ir,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(_n),s=r?.register(mm);if(s){const a=this.destroy.bind(this);this.destroy=()=>{s(),a()}}this.registerEffect(mn(this,gs,nd).bind(this,r)),this.registerEffect(mn(this,gs,rd))}};Ir=qn(qa);oi=new WeakMap;gs=new WeakSet;nd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=ks(t);if(n)return e.addRoot(n)};rd=function(){var e,t,n;const{state:r,manager:s,options:a}=this,{dragOperation:o}=s,{position:i,source:l,status:c}=o;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:m}=r,d=(e=this.overlay)!=null?e:u,h=zn(d),v=zn(u),y=!ed(u,d),g=new Bt(u,{frameTransform:y?v:null,ignoreTransforms:!y}),b={x:v.scaleX/h.scaleX,y:v.scaleY/h.scaleY};let{width:w,height:_,top:x,left:C}=g;y&&(w=w/b.x,_=_/b.y);const k=new jp(d),{transition:I,translate:E,boxSizing:T,paddingBlockStart:R,paddingBlockEnd:A,paddingInlineStart:M,paddingInlineEnd:$,borderInlineStartWidth:F,borderInlineEndWidth:L,borderBlockStartWidth:z,borderBlockEndWidth:q}=Nt(u),Y=f==="clone",ne=T==="content-box",G=ne?parseInt(M)+parseInt($)+parseInt(F)+parseInt(L):0,J=ne?parseInt(R)+parseInt(A)+parseInt(z)+parseInt(q):0,ae=f!=="move"&&!this.overlay?gm(l,Y?"clone":"hidden"):null,ue=we(()=>ti(s.dragOperation.activatorEvent));if(E!=="none"){const oe=Qo(E);oe&&!m.translate&&(m.translate=oe)}if(!m.transformOrigin){const oe=we(()=>i.current);m.transformOrigin={x:(oe.x-C*h.scaleX-h.x)/(w*h.scaleX),y:(oe.y-x*h.scaleY-h.y)/(_*h.scaleY)}}const{transformOrigin:de}=m,Me=x*h.scaleY+h.y,j=C*h.scaleX+h.x;if(!m.coordinates&&(m.coordinates={x:j,y:Me},b.x!==1||b.y!==1)){const{scaleX:oe,scaleY:fe}=v,{x:Ze,y:Et}=de;m.coordinates.x+=(w*oe-w)*Ze,m.coordinates.y+=(_*fe-_)*Et}m.dimensions||(m.dimensions={width:w,height:_}),m.frameTransform||(m.frameTransform=h);const U={x:m.coordinates.x-j,y:m.coordinates.y-Me},ye={width:(m.dimensions.width*m.frameTransform.scaleX-w*h.scaleX)*de.x,height:(m.dimensions.height*m.frameTransform.scaleY-_*h.scaleY)*de.y},Z={x:U.x/h.scaleX+ye.width,y:U.y/h.scaleY+ye.height},Q={left:C+Z.x,top:x+Z.y};d.setAttribute($t,"true");const ke=we(()=>o.transform),B=(t=m.translate)!=null?t:{x:0,y:0},Te=ke.x*h.scaleX+B.x,Qe=ke.y*h.scaleY+B.y,We=$u();k.set({width:w-G,height:_-J,top:Q.top+We.y,left:Q.left+We.x,translate:`${Te}px ${Qe}px 0`,transition:I?`${I}, translate 0ms linear`:"",scale:y?`${b.x} ${b.y}`:"","transform-origin":`${de.x*100}% ${de.y*100}%`},Je),ae&&(u.insertAdjacentElement("afterend",ae),a?.rootElement&&(typeof a.rootElement=="function"?a.rootElement(l):a.rootElement).appendChild(u)),Za(d)&&(d.hasAttribute("popover")||d.setAttribute("popover","manual"),kr(d),d.addEventListener("beforetoggle",Al));let pe,te,Ue;const at=xm({placeholder:ae,element:u,feedbackElement:d,frameTransform:h,transformOrigin:de,width:w,height:_,top:x,left:C,widthOffset:G,heightOffset:J,delta:Z,styles:k,dragOperation:o,getElementMutationObserver:()=>pe,getSavedCellWidths:()=>Ue,setSavedCellWidths:oe=>{Ue=oe}}),_e=new Bt(d);we(()=>o.shape=_e);const Fe=St(d),Ve=oe=>{this.manager.actions.stop({event:oe})},Ye=Ru(Fe);ue&&Fe.addEventListener("resize",Ve),we(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),ae&&(at.observe(ae),pe=wm(u,ae,Y),te=_m(u,ae,d));const kt=(n=s.dragOperation.source)==null?void 0:n.id,zt=()=>{var oe;if(!ue||kt==null)return;const fe=s.registry.draggables.get(kt),Ze=(oe=fe?.handle)!=null?oe:fe?.element;hn(Ze)&&Ze.focus()},X=()=>{var oe;if(pe?.disconnect(),te?.disconnect(),at.disconnect(),Fe.removeEventListener("resize",Ve),Za(d)&&(d.removeEventListener("beforetoggle",Al),d.removeAttribute("popover")),d.removeAttribute($t),k.reset(),Ue&&Ka(u)){const Ze=Array.from(u.cells);for(const[Et,It]of Ze.entries())It.style.width=(oe=Ue[Et])!=null?oe:""}l.status="idle";const fe=r.current.translate!=null;ae&&(fe||ae.parentElement!==d.parentElement)&&d.isConnected&&ae.replaceWith(d),ae?.remove()},me=a?.dropAnimation,je=this,Oe=Dr(()=>{var oe;const{transform:fe,status:Ze}=o;if(!(!fe.x&&!fe.y&&!r.current.translate)&&Ze.dragging){const Et=(oe=m.translate)!=null?oe:{x:0,y:0},It={x:fe.x/h.scaleX+Et.x,y:fe.y/h.scaleY+Et.y},Cn=r.current.translate,dt=we(()=>o.modifiers),V=we(()=>{var ee;return(ee=o.shape)==null?void 0:ee.current}),K=ue&&!Ye?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${I}, translate ${K}`,translate:`${It.x}px ${It.y}px 0`},Je),pe?.takeRecords(),V&&V!==_e&&Cn&&!dt.length){const ee=Rt.delta(It,Cn);o.shape=Pr.from(V.boundingRectangle).translate(ee.x*h.scaleX,ee.y*h.scaleY)}else o.shape=new Bt(d);r.current.translate=It}},function(){if(o.status.dropped){this.dispose(),l.status="dropping";const oe=je.dropAnimation!==void 0?je.dropAnimation:me;let fe=r.current.translate;const Ze=fe!=null;if(!fe&&u!==d&&(fe={x:0,y:0}),!fe||oe===null){X();return}s.renderer.rendering.then(()=>{km({element:u,feedbackElement:d,placeholder:ae,translate:fe,moved:Ze,transition:I,alignment:l.alignment,styles:k,animation:oe??void 0,getElementMutationObserver:()=>pe,cleanup:X,restoreFocus:zt})})}});return()=>{X(),Oe()}};vt(Ir,4,"overlay",td,Mr,oi);wn(Ir,Mr);Mr.configure=yn(Mr);var Ja=Mr,Qn=!0,Em=!1,sd,ad,od,id,Xt,ii,li;id=(od=[he],wt.Forward),ad=(sd=[he],wt.Reverse);var Ar=class{constructor(){De(this,ii,Be(Xt,8,this,Qn)),Be(Xt,11,this),De(this,li,Be(Xt,12,this,Qn)),Be(Xt,15,this)}isLocked(e){return e===wt.Idle?!1:e==null?this[wt.Forward]===Qn&&this[wt.Reverse]===Qn:this[e]===Qn}unlock(e){e!==wt.Idle&&(this[e]=Em)}};Xt=qn(null);ii=new WeakMap;li=new WeakMap;vt(Xt,4,id,od,Ar,ii);vt(Xt,4,ad,sd,Ar,li);wn(Xt,Ar);var Im=[wt.Forward,wt.Reverse],Tl=class{constructor(){this.x=new Ar,this.y=new Ar}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Mm=class extends lt{constructor(e){super(e);const t=Rr(new Tl);let n=null;this.signal=t,xt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Tl;return}const{delta:s}=e.dragOperation.position;if(n){const a={x:$l(s.x,n.x),y:$l(s.y,n.y)},o=t.peek();qt(()=>{for(const i of Bc)for(const l of Im)a[i]===l&&o[i].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function $l(e,t){return Math.sign(e-t)}var ld,Qa,Tr,ci,Gt,eo,Hs=class extends(Qa=Or,ld=[he],Qa){constructor(e){super(e),De(this,ci,Be(Tr,8,this,!1)),Be(Tr,11,this),De(this,Gt),De(this,eo,()=>{if(!Se(this,Gt))return;const{element:a,by:o}=Se(this,Gt);o.y&&(a.scrollTop+=o.y),o.x&&(a.scrollLeft+=o.x)}),this.scroll=a=>{var o;if(this.disabled)return!1;const i=this.getScrollableElements();if(!i)return rt(this,Gt,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:u}=a??{},f=u?{x:Rl(u.x),y:Rl(u.y)}:void 0,m=f?void 0:this.scrollIntentTracker.current;if(m?.isLocked())return!1;for(const d of i){const h=wp(d,u);if(h.x||h.y){const{speed:v,direction:y}=Rp(d,c,f);if(m)for(const g of Bc)m[g].isLocked(y[g])&&(v[g]=0,y[g]=0);if(y.x||y.y){const{x:g,y:b}=u??y,w=g*v.x,_=b*v.y;if(w||_){const x=(o=Se(this,Gt))==null?void 0:o.by;if(this.autoScrolling&&x&&(x.x&&!w||x.y&&!_))continue;return rt(this,Gt,{element:d,by:{x:w,y:_}}),Ms.schedule(Se(this,eo)),!0}}}}}return rt(this,Gt,void 0),!1};let t=null,n=null;const r=xs(()=>{const{position:a,source:o}=e.dragOperation;if(!a)return null;const i=Du(ks(o?.element),a.current);return i&&(t=i),i??t}),s=xs(()=>{const a=r.value,{documentElement:o}=bn(a);if(!a||a===o){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=Ha(l,{excludeElement:!1});return n=c,c}}if(a){const i=Ha(a,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},Sr);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new Mm(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!ti(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Tr=qn(Qa);ci=new WeakMap;Gt=new WeakMap;eo=new WeakMap;vt(Tr,4,"autoScrolling",ld,Hs,ci);wn(Tr,Hs);function Rl(e){return e>0?wt.Forward:e<0?wt.Reverse:wt.Idle}var Am=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))}},Tm=new Am(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),$m=10,cd=class extends lt{constructor(e,t){super(e);const n=e.registry.plugins.get(Hs);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=xt(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const o=setInterval(()=>Tm.schedule(n.scroll),$m);return()=>{clearInterval(o)}}else n.autoScrolling=!1})}},Dl={capture:!0,passive:!0},hr,Rm=class extends Or{constructor(e){super(e),De(this,hr),this.handleScroll=()=>{Se(this,hr)==null&&rt(this,hr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),rt(this,hr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=xt(()=>{var n,r,s;if(t.status.dragging){const o=(s=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?s:document;return o.addEventListener("scroll",this.handleScroll,Dl),()=>{o.removeEventListener("scroll",this.handleScroll,Dl)}}})}};hr=new WeakMap;var Dm=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.destroy=xt(()=>{var n;const{dragOperation:r}=this.manager,{nonce:s}=(n=this.options)!=null?n:{};if(r.status.initialized){const a=document.createElement("style");return s&&a.setAttribute("nonce",s),a.textContent="* { user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(a),ya(),document.addEventListener("selectionchange",ya,{capture:!0}),()=>{document.removeEventListener("selectionchange",ya,{capture:!0}),a.remove()}}})}};function ya(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var pr=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,Ds=class extends Bn{constructor(t,n){super(t),this.manager=t,this.options=n,De(this,Dn,[]),this.listeners=new Pu,this.handleSourceKeyDown=(r,s,a)=>{if(this.disabled||r.defaultPrevented||!pn(r.target)||s.disabled)return;const{keyboardCodes:o=pr.keyboardCodes,preventActivation:i=pr.preventActivation}=a??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(i?.(r,s)||this.handleStart(r,s,a))}}bind(t,n=this.options){return xt(()=>{var s;const a=(s=t.handle)!=null?s:t.element,o=i=>{ti(i)&&this.handleSourceKeyDown(i,t,n)};if(a)return a.addEventListener("keydown",o),()=>{a.removeEventListener("keydown",o)}})}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(),Pp(s);const{center:a}=new Bt(s);if(this.manager.actions.start({event:t,coordinates:{x:a.x,y:a.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const i=bn(s),l=[this.listeners.bind(i,[{type:"keydown",listener:c=>this.handleKeyDown(c,n,r),options:{capture:!0}}])];Se(this,Dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=pr.keyboardCodes}=r??{};if(In(t,[...s.end,...s.cancel])){t.preventDefault();const a=In(t,s.cancel);this.handleEnd(t,a);return}In(t,s.up)?this.handleMove("up",t):In(t,s.down)&&this.handleMove("down",t),In(t,s.left)?this.handleMove("left",t):In(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:a}=this.manager.dragOperation,o=n.shiftKey?5:1;let i={x:0,y:0},l=(s=(r=this.options)==null?void 0:r.offset)!=null?s:pr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!a){switch(t){case"up":i={x:0,y:-l.y*o};break;case"down":i={x:0,y:l.y*o};break;case"left":i={x:-l.x*o,y:0};break;case"right":i={x:l.x*o,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(cd);t?.disabled===!1&&(t.disable(),Se(this,Dn).push(()=>{t.enable()}))}cleanup(){Se(this,Dn).forEach(t=>t()),rt(this,Dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};Dn=new WeakMap;Ds.configure=yn(Ds);Ds.defaults=pr;var Pm=Ds;function In(e,t){return t.includes(e.code)}var un,Fm=class extends vu{constructor(){super(...arguments),De(this,un)}onEvent(e){switch(e.type){case"pointerdown":rt(this,un,Vn(e));break;case"pointermove":if(!Se(this,un))return;const{x:t,y:n}=Vn(e),r={x:t-Se(this,un).x,y:n-Se(this,un).y},{tolerance:s}=this.options;if(s&&Ba(r,s)){this.abort();return}Ba(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){rt(this,un,void 0)}};un=new WeakMap;var Pn,dn,Om=class extends vu{constructor(){super(...arguments),De(this,Pn),De(this,dn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,dn,Vn(e)),rt(this,Pn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Se(this,dn))return;const{x:t,y:n}=Vn(e),r={x:t-Se(this,dn).x,y:n-Se(this,dn).y};Ba(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Se(this,Pn)&&(clearTimeout(Se(this,Pn)),rt(this,dn,void 0),rt(this,Pn,void 0))}};Pn=new WeakMap;dn=new WeakMap;var Ot=class{};Ot.Delay=Om;Ot.Distance=Fm;var to=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&pn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Ot.Delay({value:250,tolerance:5})]:Hp(s)&&!e.defaultPrevented?[new Ot.Delay({value:200,tolerance:0})]:[new Ot.Delay({value:200,tolerance:10}),new Ot.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;return r===t.element||r===t.handle||!pn(r)||(n=t.handle)!=null&&n.contains(r)?!1:cp(r)}}),Fn,Ps=class extends Bn{constructor(t,n){super(t),this.manager=t,this.options=n,De(this,Fn,new Set),this.listeners=new Pu,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=to.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return xt(()=>{var s;const a=new AbortController,{signal:o}=a,i=c=>{Zp(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&&(Wm(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:o}));return()=>a.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!pn(t.target)||n.disabled||Lm(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=to.preventActivation}=r??{};if(s?.(t,n))return;const{target:a}=t,o=hn(a)&&a.draggable&&a.getAttribute("draggable")==="true",i=zn(n.element),{x:l,y:c}=Vn(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 Qh(u,v=>this.handleStart(n,v));f.signal.onabort=()=>this.handleCancel(t),f.onEvent(t),this.controller=f;const m=za(),d=this.listeners.bind(m,[{type:"pointermove",listener:v=>this.handlePointerMove(v,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:ss,options:{capture:!0}}]),h=()=>{d(),this.initialCoordinates=void 0};Se(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 a=Vn(t),o=zn(n.element);a.x=a.x*o.scaleX+o.x,a.y=a.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=a,Ms.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=bn(n.target).body;i.setPointerCapture(n.pointerId);const l=pn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:ss,options:{passive:!1}},{type:"click",listener:ss},{type:"contextmenu",listener:ss},{type:"keydown",listener:this.handleKeyDown}]);Se(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},Se(this,Fn).forEach(t=>t()),Se(this,Fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Fn=new WeakMap;Ps.configure=yn(Ps);Ps.defaults=to;var no=Ps;function Lm(e){return"sensor"in e}function ss(e){e.preventDefault()}function Bm(){}var Pl=new WeakSet;function Wm(e){!e||Pl.has(e)||(e.addEventListener("touchmove",Bm,{capture:!1,passive:!1}),Pl.add(e))}var On={modifiers:[],plugins:[um,cd,fm,Ja,Dm],sensors:[no,Pm]},ui=class extends np{constructor(e={}){const t=Lt(e.plugins,On.plugins),n=Lt(e.sensors,On.sensors),r=Lt(e.modifiers,On.modifiers);super(ri(Er({},e),{plugins:[Rm,Hs,_n,...t],sensors:n,modifiers:r}))}},ud,dd,fd,ro,At,di,fi,hi,Wr=class extends(ro=Dt,fd=[he],dd=[he],ud=[he],ro){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:a,feedback:o="default"}=n,i=Zu(n,["element","effects","handle","feedback"]);super(Er({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const m=((c=(l=this.sensors)==null?void 0:l.map(ko))!=null?c:[...u.sensors]).map(d=>{const h=d instanceof Bn?d:u.registry.register(d.plugin),v=d instanceof Bn?void 0:d.options;return h.bind(this,v)});return function(){m.forEach(h=>h())}}]},i),t),De(this,di,Be(At,8,this)),Be(At,11,this),De(this,fi,Be(At,12,this)),Be(At,15,this),De(this,hi,Be(At,16,this)),Be(At,19,this),this.element=r,this.handle=a,this.feedback=o}};At=qn(ro);di=new WeakMap;fi=new WeakMap;hi=new WeakMap;vt(At,4,"handle",fd,Wr,di);vt(At,4,"element",dd,Wr,fi);vt(At,4,"feedback",ud,Wr,hi);wn(At,Wr);var hd,pd,so,Yt,pi,ba,md,gd,_r,mi,vd=class extends(so=Pt,pd=[he],hd=[he],so){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,a=Zu(n,["element","effects"]);const{collisionDetector:o=Yp}=a,i=c=>{const{manager:u,element:f}=this;if(!f||c===null){this.shape=void 0;return}if(!u)return;const m=new Bt(f),d=we(()=>this.shape);return m&&d?.equals(m)?d:(this.shape=m,m)},l=Rr(!1);super(ri(Er({},a),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:f}=u,{source:m}=f;l.value=!!(m&&f.status.initialized&&c&&!this.disabled&&this.accepts(m))},()=>{const{element:c}=this;if(l.value&&c){const u=new bp(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),De(this,_r),De(this,pi,Be(Yt,8,this)),Be(Yt,11,this),De(this,mi,Be(Yt,12,this)),Be(Yt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){rt(this,_r,e,gd)}get element(){var e;return(e=this.proxy)!=null?e:Se(this,_r,md)}};Yt=qn(so);pi=new WeakMap;_r=new WeakSet;mi=new WeakMap;ba=vt(Yt,20,"#element",pd,_r,pi),md=ba.get,gd=ba.set;vt(Yt,4,"proxy",hd,vd,mi);wn(Yt,vd);function Vm(e){return e!=null&&typeof e=="object"&&"current"in e}function Fs(e){var t;if(e!=null)return Vm(e)?(t=e.current)!=null?t:void 0:e}var Nm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Gs=Nm?p.useLayoutEffect:p.useEffect;function zm(){const e=p.useState(0)[1];return p.useCallback(()=>{e(t=>t+1)},[e])}function jm(e,t){const n=p.useRef(new Map),r=zm();return Gs(()=>{if(!e){n.current.clear();return}return xt(()=>{var s;let a=!1,o=!1;for(const i of n.current){const[l]=i,c=we(()=>i[1]),u=e[l];c!==u&&(a=!0,n.current.set(l,u),o=(s=t?.(l,c,u))!=null?s:!1)}a&&(o?mo.flushSync(r):r())})},[e]),p.useMemo(()=>e&&new Proxy(e,{get(s,a){const o=s[a];return n.current.set(a,o),o}}),[e])}function an(e,t,n=p.useEffect,r=Object.is){const s=p.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}function Fl(e,t){const n=p.useRef(Fs(e));Gs(()=>{const r=Fs(e);r!==n.current&&(n.current=r,t(r))})}var Zm=Object.defineProperty,Hm=Object.defineProperties,Gm=Object.getOwnPropertyDescriptors,Ol=Object.getOwnPropertySymbols,Um=Object.prototype.hasOwnProperty,Xm=Object.prototype.propertyIsEnumerable,Ll=(e,t,n)=>t in e?Zm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ym=(e,t)=>{for(var n in t||(t={}))Um.call(t,n)&&Ll(e,n,t[n]);if(Ol)for(var n of Ol(t))Xm.call(t,n)&&Ll(e,n,t[n]);return e},Km=(e,t)=>Hm(e,Gm(t)),qm=new ui,Jm=p.createContext(qm);p.memo(p.forwardRef(({children:e},t)=>{const[n,r]=p.useState(0),s=p.useRef(null),a=p.useRef(null),o=p.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{a.current=l})),p.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Gs(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),p.useImperativeHandle(t,()=>o),null}));function Qm(){return p.useContext(Jm)}function eg(e){var t;const n=(t=Qm())!=null?t:void 0,[r]=p.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Gs(r.register,[n,r]),r}function wa(e){const{disabled:t,data:n,element:r,handle:s,id:a,modifiers:o,sensors:i}=e,l=eg(u=>new Wr(Km(Ym({},e),{register:!1,handle:Fs(s),element:Fs(r)}),u)),c=jm(l,tg);return an(a,()=>l.id=a),Fl(s,u=>l.handle=u),Fl(r,u=>l.element=u),an(n,()=>n&&(l.data=n)),an(t,()=>l.disabled=t===!0),an(i,()=>l.sensors=i),an(o,()=>l.modifiers=o,void 0,Sr),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:p.useCallback(u=>{l.handle=u??void 0},[l]),ref:p.useCallback(u=>{var f,m;!u&&((f=l.element)!=null&&f.isConnected)&&!((m=l.manager)!=null&&m.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function tg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var ng=Object.create,yd=Object.defineProperty,rg=Object.getOwnPropertyDescriptor,bd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Us=e=>{throw TypeError(e)},sg=(e,t,n)=>t in e?yd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ag=e=>{var t;return[,,,ng((t=e?.[bd("metadata")])!=null?t:null)]},wd=["class","method","getter","setter","accessor","field","value","get","set"],_d=e=>e!==void 0&&typeof e!="function"?Us("Function expected"):e,og=(e,t,n,r,s)=>({kind:wd[e],name:t,metadata:r,addInitializer:a=>n._?Us("Already initialized"):s.push(_d(a||null))}),ig=(e,t)=>sg(t,bd("metadata"),e[3]),lg=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},xd=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=wd[u+5],v=e[d]||(e[d]=[]),y=(s=s.prototype,rg(s,n)),g=r.length-1;g>=0;g--)l=og(u,n,i={},e[3],v),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[g])(y[h],l),i._=1,_d(o)&&(y[h]=o);return y&&yd(s,n,y),s},Sd=(e,t,n)=>t.has(e)||Us("Cannot "+n),cg=(e,t,n)=>(Sd(e,t,"read from private field"),t.get(e)),ug=(e,t,n)=>t.has(e)?Us("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),dg=(e,t,n,r)=>(Sd(e,t,"write to private field"),t.set(e,n),n),er=class ao{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ao(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 ao(t,n)}},Cd,kd,oo,vs,Vr,gi=class extends(oo=Qt,kd=[Ae],Cd=[Ae],oo){constructor(t){const n=er.from(t);super(n,(r,s)=>er.equals(r,s)),lg(Vr,5,this),ug(this,vs,0),this.velocity={x:0,y:0}}get delta(){return er.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=er.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-cg(this,vs),i=l=>Math.round(l/o*100);qt(()=>{dg(this,vs,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(er.from(t)),this.velocity={x:0,y:0}}};Vr=ag(oo);vs=new WeakMap;xd(Vr,2,"delta",kd,gi);xd(Vr,2,"direction",Cd,gi);ig(Vr,gi);var Ed=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ed||{});Object.values(Ed);const fg=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),hg=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),pg=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),mg=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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=p.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Nr=D.forwardRef((e,t)=>{const{alt:n,color:r,size:s,weight:a,mirrored:o,children:i,weights:l,...c}=e,{color:u="currentColor",size:f,weight:m="regular",mirrored:d=!1,...h}=D.useContext(gg);return D.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:o||d?"scale(-1, 1)":void 0,...h,...c},!!n&&D.createElement("title",null,n),i,l.get(a??m))});Nr.displayName="IconBase";const Id=D.forwardRef((e,t)=>D.createElement(Nr,{ref:t,...e,weights:fg}));Id.displayName="DotsThreeIcon";const Md=D.forwardRef((e,t)=>D.createElement(Nr,{ref:t,...e,weights:hg}));Md.displayName="SpeakerHighIcon";const Ad=D.forwardRef((e,t)=>D.createElement(Nr,{ref:t,...e,weights:pg}));Ad.displayName="SpeakerLowIcon";const Td=D.forwardRef((e,t)=>D.createElement(Nr,{ref:t,...e,weights:mg}));Td.displayName="XIcon";const vg=Td;P.span`
|
|
67
67
|
font-family: 'Courier New', Monaco, monospace;
|
|
68
68
|
font-size: 1rem;
|
|
69
69
|
font-weight: 600;
|
|
70
70
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
71
71
|
user-select: none;
|
|
72
|
-
`;var
|
|
72
|
+
`;var vi=P.button`
|
|
73
73
|
display: inline-flex;
|
|
74
74
|
align-items: center;
|
|
75
75
|
justify-content: center;
|
|
@@ -100,37 +100,37 @@
|
|
|
100
100
|
opacity: 0.6;
|
|
101
101
|
cursor: not-allowed;
|
|
102
102
|
}
|
|
103
|
-
`;P(
|
|
103
|
+
`;P(vi)`
|
|
104
104
|
padding: 0.25rem 0.5rem;
|
|
105
105
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
106
|
-
`;P(
|
|
106
|
+
`;P(vi)`
|
|
107
107
|
padding: 0.5rem;
|
|
108
108
|
min-width: 2.25rem;
|
|
109
109
|
min-height: 2.25rem;
|
|
110
|
-
`;P(
|
|
110
|
+
`;P(vi)`
|
|
111
111
|
padding: 0.25rem;
|
|
112
112
|
min-width: 1.75rem;
|
|
113
113
|
min-height: 1.75rem;
|
|
114
114
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
115
|
-
`;var
|
|
115
|
+
`;var yg=P.div`
|
|
116
116
|
display: inline-flex;
|
|
117
117
|
align-items: center;
|
|
118
118
|
gap: 0.5rem;
|
|
119
|
-
`,
|
|
119
|
+
`,bg=P.input`
|
|
120
120
|
cursor: pointer;
|
|
121
121
|
accent-color: ${e=>e.theme.inputFocusBorder};
|
|
122
122
|
|
|
123
123
|
&:disabled {
|
|
124
124
|
cursor: not-allowed;
|
|
125
125
|
}
|
|
126
|
-
`,
|
|
126
|
+
`,wg=P.label`
|
|
127
127
|
margin: 0;
|
|
128
128
|
cursor: pointer;
|
|
129
129
|
user-select: none;
|
|
130
130
|
font-family: ${e=>e.theme.fontFamily};
|
|
131
131
|
font-size: ${e=>e.theme.fontSize};
|
|
132
132
|
color: ${e=>e.theme.textColor};
|
|
133
|
-
`,
|
|
133
|
+
`,Ct=P.button`
|
|
134
134
|
padding: 0.5rem 1rem;
|
|
135
135
|
background: ${e=>e.theme.buttonBackground||"#007bff"};
|
|
136
136
|
color: ${e=>e.theme.buttonText||"white"};
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
cursor: not-allowed;
|
|
157
157
|
opacity: 0.6;
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
`,$d=P.input`
|
|
160
160
|
padding: 0.5rem 0.75rem;
|
|
161
161
|
font-family: ${e=>e.theme.fontFamily};
|
|
162
162
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -182,10 +182,10 @@
|
|
|
182
182
|
opacity: 0.6;
|
|
183
183
|
cursor: not-allowed;
|
|
184
184
|
}
|
|
185
|
-
`;P(
|
|
185
|
+
`;P($d)`
|
|
186
186
|
padding: 0.25rem 0.5rem;
|
|
187
187
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
188
|
-
`;var
|
|
188
|
+
`;var _g=P.label`
|
|
189
189
|
font-family: ${e=>e.theme.fontFamily};
|
|
190
190
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
191
191
|
font-weight: 500;
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
align-items: center;
|
|
201
201
|
gap: 0.5rem;
|
|
202
202
|
cursor: pointer;
|
|
203
|
-
`;var
|
|
203
|
+
`;var xg=P.span`
|
|
204
204
|
position: absolute;
|
|
205
205
|
width: 1px;
|
|
206
206
|
height: 1px;
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
clip: rect(0, 0, 0, 0);
|
|
211
211
|
white-space: nowrap;
|
|
212
212
|
border: 0;
|
|
213
|
-
`,
|
|
213
|
+
`,Rd=P.select`
|
|
214
214
|
padding: 0.5rem 2rem 0.5rem 0.75rem;
|
|
215
215
|
font-family: ${e=>e.theme.fontFamily};
|
|
216
216
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -243,10 +243,10 @@
|
|
|
243
243
|
color: ${e=>e.theme.inputText};
|
|
244
244
|
background-color: ${e=>e.theme.inputBackground};
|
|
245
245
|
}
|
|
246
|
-
`;P(
|
|
246
|
+
`;P(Rd)`
|
|
247
247
|
padding: 0.25rem 1.75rem 0.25rem 0.5rem;
|
|
248
248
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
249
|
-
`;var
|
|
249
|
+
`;var Dd=P.input.attrs({type:"range"})`
|
|
250
250
|
-webkit-appearance: none;
|
|
251
251
|
appearance: none;
|
|
252
252
|
width: 100%;
|
|
@@ -326,21 +326,21 @@
|
|
|
326
326
|
&:disabled::-moz-range-thumb {
|
|
327
327
|
cursor: not-allowed;
|
|
328
328
|
}
|
|
329
|
-
`,
|
|
329
|
+
`,Sg=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.checked)};return S.jsxs(yg,{className:r,children:[S.jsx(bg,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:s,disabled:n}),S.jsx(wg,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Pd(e){return typeof e=="object"&&e!==null&&"type"in e}function Jt(e){if(!Pd(e))return e;const t=e.direction==="vertical"?"to bottom":"to right",n=e.stops.map(r=>`${r.color} ${r.offset*100}%`).join(", ");return`linear-gradient(${t}, ${n})`}var Fd={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",timeColor:"#000",timescaleBackgroundColor:"#fff",playheadColor:"#f00",selectionColor:"rgba(255, 105, 180, 0.7)",loopRegionColor:"rgba(59, 130, 246, 0.3)",loopMarkerColor:"#3b82f6",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",pianoRollNoteColor:"#2a7070",pianoRollSelectedNoteColor:"#3d9e9e",pianoRollBackgroundColor:"#1a1a2e",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},Cg=class{constructor(e){this._listeners=new Set,this._notifyRafId=null,this.subscribe=r=>(this._listeners.add(r),()=>this._listeners.delete(r)),this.getSnapshot=()=>this._state;const t=e?.clientWidth??(typeof window<"u"?window.innerWidth:1024),n=t*1.5;this._state={scrollLeft:0,containerWidth:t,visibleStart:0,visibleEnd:t+n}}update(e,t){const n=t*1.5,r=Math.max(0,e-n),s=e+t+n;this._state&&this._state.containerWidth===t&&Math.abs(this._state.scrollLeft-e)<100||(this._state={scrollLeft:e,containerWidth:t,visibleStart:r,visibleEnd:s},this._notifyRafId===null&&(this._notifyRafId=requestAnimationFrame(()=>{this._notifyRafId=null;for(const a of this._listeners)a()})))}cancelPendingNotification(){this._notifyRafId!==null&&(cancelAnimationFrame(this._notifyRafId),this._notifyRafId=null)}},Od=p.createContext(null),kg=()=>()=>{},Eg=({containerRef:e,children:t})=>{const n=p.useRef(null);n.current===null&&(n.current=new Cg(e.current));const r=n.current,s=p.useRef(null),a=p.useCallback(()=>{const i=e.current;i&&r.update(i.scrollLeft,i.clientWidth)},[e,r]),o=p.useCallback(()=>{s.current===null&&(s.current=requestAnimationFrame(()=>{s.current=null,a()}))},[a]);return p.useLayoutEffect(()=>{a()},[a]),p.useEffect(()=>{const i=e.current;if(!i)return;i.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(()=>{o()});return l.observe(i),()=>{i.removeEventListener("scroll",o),l.disconnect(),s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),r.cancelPendingNotification()}},[e,o,r]),S.jsx(Od.Provider,{value:r,children:t})};function Ig(e){const t=p.useContext(Od);return p.useSyncExternalStore(t?t.subscribe:kg,()=>e(t?t.getSnapshot():null),()=>e(null))}function Xs(e,t,n=0){const r=Ig(s=>{const a=Math.ceil(e/t),o=[];for(let i=0;i<a;i++){const l=i*t,c=Math.min(e-l,t);if(s){const u=n+l;if(u+c<=s.visibleStart||u>=s.visibleEnd)continue}o.push(i)}return o.join(",")});return p.useMemo(()=>r?r.split(",").map(Number):[],[r])}var Ld=p.createContext(0),Mg=({originX:e,children:t})=>S.jsx(Ld.Provider,{value:e,children:t}),yi=()=>p.useContext(Ld);function Ys(){const e=p.useRef(new Map),t=p.useCallback(n=>{if(n!==null){const r=parseInt(n.dataset.index,10);e.current.set(r,n)}},[]);return p.useEffect(()=>{const n=e.current;for(const[r,s]of n.entries())s.isConnected||n.delete(r)}),{canvasRef:t,canvasMapRef:e}}function Ag(e,t,n,r){if(n*2+1>=e.length)return null;const s=2**(t-1);let a=e[n*2]/s,o=e[n*2+1]/s;for(let i=n+1;i<r&&!(i*2+1>=e.length);i++){const l=e[i*2]/s,c=e[i*2+1]/s;l<a&&(a=l),c>o&&(o=c)}return{min:a,max:o}}function Tg(e,t,n,r,s,a){const o=Math.abs(r*n),i=Math.abs(s*n);return a==="normal"?[{x:e,y:n-i,width:t,height:i+o}]:[{x:e,y:0,width:t,height:n-i},{x:e,y:n+o,width:t,height:n-o}]}function $g(e,t,n){return Math.floor((e-t+n)/n)*n}function Rg(e,t,n,r){if(!Pd(t))return t;let s;t.direction==="vertical"?s=e.createLinearGradient(0,0,0,r):s=e.createLinearGradient(0,0,n,0);for(const a of t.stops)s.addColorStop(a.offset,a.color);return s}var Dg=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
330
330
|
position: absolute;
|
|
331
331
|
top: 0;
|
|
332
332
|
/* Disable image rendering interpolation */
|
|
333
333
|
image-rendering: pixelated;
|
|
334
334
|
image-rendering: crisp-edges;
|
|
335
|
-
`,
|
|
335
|
+
`,Pg=P.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
336
336
|
position: absolute;
|
|
337
337
|
background: ${e=>e.$waveFillColor};
|
|
338
338
|
/* Force GPU compositing layer to reduce scroll flickering */
|
|
339
339
|
transform: translateZ(0);
|
|
340
340
|
backface-visibility: hidden;
|
|
341
|
-
|
|
341
|
+
`,Bl=e=>{const{data:t,bits:n,length:r,index:s,className:a,devicePixelRatio:o=1,waveHeight:i=80,waveOutlineColor:l="#E0EFF1",waveFillColor:c="grey",barWidth:u=1,barGap:f=0,transparentBackground:m=!1,drawMode:d="inverted"}=e,{canvasRef:h,canvasMapRef:v}=Ys(),y=yi(),g=Xs(r,Le,y);p.useEffect(()=>{const x=u+f;for(const[C,k]of v.current.entries()){const I=C*Le,E=k.getContext("2d"),T=Math.floor(i/2);if(E){E.resetTransform(),E.clearRect(0,0,k.width,k.height),E.imageSmoothingEnabled=!1,E.scale(o,o);const R=k.width/o;let A;d==="normal"?A=c:A=l,E.fillStyle=Rg(E,A,R,i);const M=I,$=I+R,F=$g(M,u,x);for(let L=Math.max(0,F);L<$;L+=x){const z=L-M;if(z+u<=0)continue;const q=Math.min(L+x,r),Y=Ag(t,n,L,q);if(Y){const ne=Tg(z,u,T,Y.min,Y.max,d);for(const G of ne)E.fillRect(G.x,G.y,G.width,G.height)}}}}},[v,t,n,i,l,c,o,r,u,f,d,g,s]);const b=g.map(x=>{const C=x*Le,k=Math.min(r-C,Le);return S.jsx(Dg,{$cssWidth:k,$left:C,width:k*o,height:i*o,$waveHeight:i,"data-index":x,ref:h},`${r}-${x}`)}),_=m?"transparent":Jt(c);return S.jsx(Pg,{$index:s,$cssWidth:r,className:a,$waveHeight:i,$waveFillColor:_,children:b})},Fg={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 p.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:S.jsx("div",{style:Fg,children:"Waveform playlist encountered an error. Check console for details."}):this.props.children}});var bi=22,Bd=P.div`
|
|
342
342
|
position: relative;
|
|
343
|
-
height: ${
|
|
343
|
+
height: ${bi}px;
|
|
344
344
|
background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
|
|
345
345
|
border-bottom: 1px solid ${e=>e.theme.clipHeaderBorderColor};
|
|
346
346
|
display: flex;
|
|
@@ -362,7 +362,7 @@
|
|
|
362
362
|
cursor: grabbing;
|
|
363
363
|
}
|
|
364
364
|
`}
|
|
365
|
-
`,
|
|
365
|
+
`,Wd=P.span`
|
|
366
366
|
font-size: 11px;
|
|
367
367
|
font-weight: 600;
|
|
368
368
|
font-family: ${e=>e.theme.clipHeaderFontFamily};
|
|
@@ -370,12 +370,12 @@
|
|
|
370
370
|
white-space: nowrap;
|
|
371
371
|
overflow: hidden;
|
|
372
372
|
text-overflow: ellipsis;
|
|
373
|
-
`,
|
|
373
|
+
`,Og=({trackName:e,isSelected:t=!1})=>S.jsx(Bd,{$interactive:!1,$isSelected:t,children:S.jsx(Wd,{title:e,children:e})}),Lg=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:s=!1,disableDrag:a=!1,dragHandleProps:o})=>{if(a||!o)return S.jsx(Og,{trackName:r,isSelected:s});const{handleRef:i}=o;return S.jsx(Bd,{ref:i,"data-clip-id":e,$interactive:!0,$isSelected:s,children:S.jsx(Wd,{title:r,children:r})})},Bg=8,Wg=24,Vg=P.div`
|
|
374
374
|
position: absolute;
|
|
375
375
|
${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
|
|
376
376
|
top: 0;
|
|
377
377
|
bottom: 0;
|
|
378
|
-
width: ${e=>e.$touchOptimized?
|
|
378
|
+
width: ${e=>e.$touchOptimized?Wg:Bg}px;
|
|
379
379
|
cursor: col-resize;
|
|
380
380
|
user-select: none;
|
|
381
381
|
z-index: 105; /* Above waveform, below header */
|
|
@@ -398,56 +398,51 @@
|
|
|
398
398
|
background: rgba(255, 255, 255, 0.4);
|
|
399
399
|
${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
400
|
}
|
|
401
|
-
`,
|
|
401
|
+
`,Wl=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:s,touchOptimized:a=!1})=>{const[o,i]=p.useState(!1);if(!s)return null;const{ref:l,isDragging:c}=s;return S.jsx(Vg,{ref:l,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:c,$isHovered:o,$touchOptimized:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)})},Ng=P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
402
402
|
position: absolute;
|
|
403
403
|
top: 0;
|
|
404
404
|
bottom: 0;
|
|
405
405
|
pointer-events: none;
|
|
406
406
|
z-index: 50;
|
|
407
|
-
`,
|
|
407
|
+
`,zg=P.svg`
|
|
408
408
|
width: 100%;
|
|
409
409
|
height: 100%;
|
|
410
410
|
display: block;
|
|
411
411
|
/* Flip horizontally for fadeOut - makes it mirror of fadeIn */
|
|
412
412
|
transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
|
|
413
|
-
`;function
|
|
413
|
+
`;function jg(e,t,n="logarithmic"){const r=[],s=Math.max(20,Math.min(e,100));for(let a=0;a<=s;a++){const o=a/s*e,i=a/s;let l;switch(n){case"linear":l=i;break;case"exponential":l=i*i;break;case"sCurve":l=(1-Math.cos(i*Math.PI))/2;break;case"logarithmic":default:l=Math.log10(1+i*9)/Math.log10(10);break}const c=(1-l)*t;r.push(`${o},${c}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var Vl=({left:e,width:t,type:n,curveType:r="logarithmic",color:s})=>{const a=P.useTheme();if(t<1)return null;const o=s||a?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return S.jsx(Ng,{$left:e,$width:t,$type:n,children:S.jsx(zg,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:S.jsx("path",{d:jg(t,100,r),fill:o})})})},Zg=P.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
414
414
|
position: ${e=>e.$isOverlay?"relative":"absolute"};
|
|
415
415
|
top: 0;
|
|
416
416
|
height: ${e=>e.$isOverlay?"auto":"100%"};
|
|
417
417
|
width: ${e=>e.$isOverlay?`${e.$width}px`:"auto"};
|
|
418
418
|
display: flex;
|
|
419
419
|
flex-direction: column;
|
|
420
|
-
background: rgba(255, 255, 255, 0.05);
|
|
421
420
|
z-index: 10; /* Above progress overlay (z-index: 2) but below controls/playhead */
|
|
422
421
|
pointer-events: none; /* Let clicks pass through to ClickOverlay for playhead positioning */
|
|
423
|
-
|
|
424
|
-
&:hover {
|
|
425
|
-
background: rgba(255, 255, 255, 0.08);
|
|
426
|
-
}
|
|
427
|
-
`,Rg=P.div`
|
|
422
|
+
`,Hg=P.div`
|
|
428
423
|
flex: 1;
|
|
429
424
|
position: relative;
|
|
430
425
|
overflow: ${e=>e.$isOverlay?"visible":"hidden"};
|
|
431
|
-
`,
|
|
426
|
+
`,io=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:s,trackName:a,startSample:o,durationSamples:i,samplesPerPixel:l,showHeader:c=!1,disableHeaderDrag:u=!1,isOverlay:f=!1,isSelected:m=!1,onMouseDown:d,trackId:h,fadeIn:v,fadeOut:y,sampleRate:g=44100,showFades:b=!1,touchOptimized:w=!1})=>{const _=Math.floor(o/l),x=cc(o,i,l),C=c&&!u&&!f,k=`clip-${r}-${s}`,{ref:I,handleRef:E,isDragSource:T}=wa({id:k,data:{clipId:n,trackIndex:r,clipIndex:s,startSample:o,durationSamples:i},disabled:!C}),R=`clip-boundary-left-${r}-${s}`,{ref:A,isDragSource:M}=wa({id:R,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"left",startSample:o,durationSamples:i},disabled:!C,feedback:"none"}),$=`clip-boundary-right-${r}-${s}`,{ref:F,isDragSource:L}=wa({id:$,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"right",startSample:o,durationSamples:i},disabled:!C,feedback:"none"}),z=T?{zIndex:100}:void 0;return S.jsxs(Zg,{ref:I,style:z,className:t,$left:_,$width:x,$isOverlay:f,"data-clip-container":"true","data-track-id":h,onMouseDown:d,tabIndex:-1,children:[c&&S.jsx(Lg,{clipId:n,trackIndex:r,clipIndex:s,trackName:a,isSelected:m,disableDrag:u,dragHandleProps:C?{handleRef:E}:void 0}),S.jsx(Mg,{originX:_,children:S.jsxs(Hg,{$isOverlay:f,children:[e,b&&v&&v.duration>0&&S.jsx(Vl,{left:0,width:Math.floor(v.duration*g/l),type:"fadeIn",curveType:v.type}),b&&y&&y.duration>0&&S.jsx(Vl,{left:x-Math.floor(y.duration*g/l),width:Math.floor(y.duration*g/l),type:"fadeOut",curveType:y.type})]})}),c&&!u&&!f&&S.jsxs(S.Fragment,{children:[S.jsx(Wl,{clipId:n,trackIndex:r,clipIndex:s,edge:"left",touchOptimized:w,dragHandleProps:{ref:A,isDragging:M}}),S.jsx(Wl,{clipId:n,trackIndex:r,clipIndex:s,edge:"right",touchOptimized:w,dragHandleProps:{ref:F,isDragging:L}})]})]})},Gg=P.div`
|
|
432
427
|
display: inline-flex;
|
|
433
428
|
align-items: center;
|
|
434
429
|
gap: 0.5rem;
|
|
435
|
-
`,
|
|
430
|
+
`,Ug=P(_g)`
|
|
436
431
|
margin: 0;
|
|
437
432
|
white-space: nowrap;
|
|
438
|
-
`,
|
|
433
|
+
`,Xg=P(Dd)`
|
|
439
434
|
width: 120px;
|
|
440
|
-
`,
|
|
435
|
+
`,Yg=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(parseFloat(a.target.value)/100)};return S.jsxs(Gg,{className:r,children:[S.jsx(Ug,{htmlFor:"master-gain",children:"Master Volume"}),S.jsx(Xg,{min:"0",max:"100",value:e*100,onChange:s,disabled:n,id:"master-gain"})]})},Kg=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
441
436
|
position: absolute;
|
|
442
437
|
top: 0;
|
|
443
438
|
image-rendering: pixelated;
|
|
444
439
|
image-rendering: crisp-edges;
|
|
445
|
-
`,
|
|
440
|
+
`,qg=P.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
446
441
|
position: absolute;
|
|
447
442
|
background: ${e=>e.$backgroundColor};
|
|
448
443
|
transform: translateZ(0);
|
|
449
444
|
backface-visibility: hidden;
|
|
450
|
-
`,
|
|
445
|
+
`,Jg=({index:e,midiNotes:t,length:n,waveHeight:r,devicePixelRatio:s,samplesPerPixel:a,sampleRate:o,clipOffsetSeconds:i,noteColor:l="#2a7070",selectedNoteColor:c="#3d9e9e",isSelected:u=!1,transparentBackground:f=!1,backgroundColor:m="#1a1a2e"})=>{const{canvasRef:d,canvasMapRef:h}=Ys(),v=yi(),y=Xs(n,Le,v),{minMidi:g,maxMidi:b}=p.useMemo(()=>{if(t.length===0)return{minMidi:0,maxMidi:127};let C=127,k=0;for(const I of t)I.midi<C&&(C=I.midi),I.midi>k&&(k=I.midi);return{minMidi:Math.max(0,C-1),maxMidi:Math.min(127,k+1)}},[t]),w=u?c:l;p.useEffect(()=>{const C=b-g+1,k=Math.max(2,r/C),I=o/a;for(const[E,T]of h.current.entries()){const R=E*Le,A=T.width/s,M=T.getContext("2d");if(!M)continue;M.resetTransform(),M.clearRect(0,0,T.width,T.height),M.imageSmoothingEnabled=!1,M.scale(s,s);const $=R*a/o,F=(R+A)*a/o;for(const L of t){const z=L.time-i;if(z+L.duration<=$||z>=F)continue;const Y=z*I-R,ne=Math.max(2,L.duration*I),G=(b-L.midi)/C*r,J=.3+L.velocity*.7;M.fillStyle=w,M.globalAlpha=J;const ae=1;M.beginPath(),M.roundRect(Y,G,ne,k,ae),M.fill()}M.globalAlpha=1}},[h,t,r,s,a,o,i,w,g,b,n,y,e]);const _=y.map(C=>{const k=C*Le,I=Math.min(n-k,Le);return S.jsx(Kg,{$cssWidth:I,$left:k,width:I*s,height:r*s,$waveHeight:r,"data-index":C,ref:d},`${n}-${C}`)}),x=f?"transparent":m;return S.jsx(qg,{$index:e,$cssWidth:n,$waveHeight:r,$backgroundColor:x,children:_})};P.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
|
|
451
446
|
position: absolute;
|
|
452
447
|
top: 0;
|
|
453
448
|
left: 0;
|
|
@@ -481,32 +476,32 @@
|
|
|
481
476
|
width: 2px;
|
|
482
477
|
height: 100%;
|
|
483
478
|
background: ${e=>e.$color};
|
|
484
|
-
`;var
|
|
479
|
+
`;var Qg=P.div`
|
|
485
480
|
display: flex;
|
|
486
481
|
overflow-y: hidden;
|
|
487
482
|
position: relative;
|
|
488
|
-
`,
|
|
483
|
+
`,ev=P.div.attrs(e=>({style:{width:`${e.$width}px`}}))`
|
|
489
484
|
flex-shrink: 0;
|
|
490
485
|
overflow: hidden;
|
|
491
|
-
`,
|
|
486
|
+
`,tv=P.div.attrs(e=>({style:{height:`${e.$height}px`}}))``,nv=P.div`
|
|
492
487
|
overflow-x: auto;
|
|
493
488
|
overflow-y: hidden;
|
|
494
489
|
overflow-anchor: none;
|
|
495
490
|
flex: 1;
|
|
496
491
|
position: relative;
|
|
497
|
-
`,
|
|
492
|
+
`,rv=P.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
|
|
498
493
|
position: relative;
|
|
499
494
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
500
|
-
`,
|
|
495
|
+
`,sv=P.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
|
|
501
496
|
background: ${e=>e.$backgroundColor||"white"};
|
|
502
497
|
width: 100%;
|
|
503
498
|
position: relative;
|
|
504
499
|
overflow: hidden; /* Constrain loop region to timescale area */
|
|
505
|
-
`,
|
|
500
|
+
`,av=P.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
|
|
506
501
|
position: relative;
|
|
507
502
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
508
503
|
width: 100%;
|
|
509
|
-
`,
|
|
504
|
+
`,ov=P.div`
|
|
510
505
|
position: absolute;
|
|
511
506
|
top: 0;
|
|
512
507
|
left: 0;
|
|
@@ -515,7 +510,7 @@
|
|
|
515
510
|
cursor: crosshair;
|
|
516
511
|
/* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
|
|
517
512
|
z-index: ${e=>e.$isSelecting?110:1};
|
|
518
|
-
`,
|
|
513
|
+
`,wi=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:s,tracksWidth:a,controlsWidth:o,onTracksClick:i,onTracksMouseDown:l,onTracksMouseMove:c,onTracksMouseUp:u,scrollContainerRef:f,isSelecting:m,"data-playlist-state":d,trackControlsSlots:h,timescaleGapHeight:v=0})=>{const y=p.useRef(null),g=p.useCallback(w=>{y.current=w,f?.(w)},[f]),b=o!==void 0&&o>0;return S.jsxs(Qg,{"data-playlist-state":d,children:[b&&S.jsxs(ev,{$width:o,children:[v>0&&S.jsx(tv,{$height:v}),h]}),S.jsx(nv,{"data-scroll-container":"true",ref:g,children:S.jsx(Eg,{containerRef:y,children:S.jsxs(rv,{$backgroundColor:t,$width:a,children:[r&&S.jsx(sv,{$width:s,$backgroundColor:n,children:r}),S.jsxs(av,{$width:a,$backgroundColor:t,children:[e,(i||l)&&S.jsx(ov,{$isSelecting:m,onClick:i,onMouseDown:l,onMouseMove:c,onMouseUp:u})]})]})})})]})};P.withTheme(wi);var iv=P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
519
514
|
position: absolute;
|
|
520
515
|
top: 0;
|
|
521
516
|
background: ${e=>e.$color};
|
|
@@ -523,7 +518,7 @@
|
|
|
523
518
|
z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
|
|
524
519
|
pointer-events: none;
|
|
525
520
|
opacity: 0.3;
|
|
526
|
-
`,
|
|
521
|
+
`,Vd=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:S.jsx(iv,{$left:e,$width:r,$color:n,"data-selection":!0})};P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
527
522
|
position: absolute;
|
|
528
523
|
top: 0;
|
|
529
524
|
background: ${e=>e.$color};
|
|
@@ -550,7 +545,7 @@
|
|
|
550
545
|
border-top: 8px solid ${e=>e.$color};
|
|
551
546
|
${e=>e.$isStart?"border-right: 8px solid transparent;":"border-left: 8px solid transparent;"}
|
|
552
547
|
}
|
|
553
|
-
`;var
|
|
548
|
+
`;var Nl=P.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
|
|
554
549
|
position: absolute;
|
|
555
550
|
top: 0;
|
|
556
551
|
width: 12px;
|
|
@@ -587,7 +582,7 @@
|
|
|
587
582
|
&:hover::before {
|
|
588
583
|
opacity: 1;
|
|
589
584
|
}
|
|
590
|
-
`,
|
|
585
|
+
`,lv=P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
591
586
|
position: absolute;
|
|
592
587
|
top: 0;
|
|
593
588
|
height: 100%;
|
|
@@ -598,7 +593,7 @@
|
|
|
598
593
|
&:active {
|
|
599
594
|
cursor: grabbing;
|
|
600
595
|
}
|
|
601
|
-
`,
|
|
596
|
+
`,cv=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopStartChange:s,onLoopEndChange:a,onLoopRegionMove:o,minPosition:i=0,maxPosition:l=1/0})=>{const[c,u]=p.useState(null),f=p.useRef(0),m=p.useRef(0),d=p.useRef(0),h=Math.max(0,t-e),v=p.useCallback((g,b)=>{g.preventDefault(),g.stopPropagation(),u(b),f.current=g.clientX,m.current=b==="start"?e:t;const w=x=>{const C=x.clientX-f.current,k=m.current+C;if(b==="start"){const I=Math.max(i,Math.min(t-10,k));s?.(I)}else{const I=Math.max(e+10,Math.min(l,k));a?.(I)}},_=()=>{u(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",_)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",_)},[e,t,i,l,s,a]),y=p.useCallback(g=>{g.preventDefault(),g.stopPropagation(),u("region"),f.current=g.clientX,m.current=e,d.current=t;const b=t-e,w=x=>{const C=x.clientX-f.current;let k=m.current+C,I=d.current+C;k<i&&(k=i,I=i+b),I>l&&(I=l,k=l-b),o?.(k,I)},_=()=>{u(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",_)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",_)},[e,t,i,l,o]);return h<=0?null:S.jsxs(S.Fragment,{children:[S.jsx(lv,{$left:e,$width:h,$color:r,$isDragging:c==="region",onMouseDown:y,"data-loop-region-timescale":!0}),S.jsx(Nl,{$left:e,$color:n,$isStart:!0,$isDragging:c==="start",onMouseDown:g=>v(g,"start"),"data-loop-marker-handle":"start"}),S.jsx(Nl,{$left:t,$color:n,$isStart:!1,$isDragging:c==="end",onMouseDown:g=>v(g,"end"),"data-loop-marker-handle":"end"})]})},uv=P.div`
|
|
602
597
|
position: absolute;
|
|
603
598
|
top: 0;
|
|
604
599
|
left: 0;
|
|
@@ -606,17 +601,17 @@
|
|
|
606
601
|
height: 100%; /* Stay within timescale bounds, don't extend into tracks */
|
|
607
602
|
cursor: crosshair;
|
|
608
603
|
z-index: 40; /* Below markers and shading */
|
|
609
|
-
`,
|
|
604
|
+
`,dv=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopRegionChange:s,minPosition:a=0,maxPosition:o=1/0})=>{const[,i]=p.useState(!1),l=p.useRef(0),c=p.useRef(null),u=t>e,f=p.useCallback(m=>{const d=m.target;if(d.closest("[data-loop-marker-handle]")||d.closest("[data-loop-region-timescale]"))return;m.preventDefault(),i(!0);const h=c.current?.getBoundingClientRect();if(!h)return;const v=m.clientX-h.left,y=Math.max(a,Math.min(o,v));l.current=y,s?.(y,y);const g=w=>{const _=w.clientX-h.left,x=Math.max(a,Math.min(o,_)),C=Math.min(l.current,x),k=Math.max(l.current,x);s?.(C,k)},b=()=>{i(!1),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",b)},[a,o,s]);return S.jsx(uv,{ref:c,onMouseDown:f,"data-timescale-loop-creator":!0,children:u&&S.jsx(cv,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:a,maxPosition:o,onLoopStartChange:m=>s?.(m,t),onLoopEndChange:m=>s?.(e,m),onLoopRegionMove:(m,d)=>s?.(m,d)})})};function tr(e,t){const n=Math.floor(e/3600)%24,r=Math.floor(e/60)%60,s=(e%60).toFixed(t);return String(n).padStart(2,"0")+":"+String(r).padStart(2,"0")+":"+s.padStart(t>0?t+3:2,"0")}function Ln(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return tr(e,0);case"hh:mm:ss.u":return tr(e,1);case"hh:mm:ss.uu":return tr(e,2);case"hh:mm:ss.uuu":return tr(e,3);default:return tr(e,3)}}function Nd(e,t){if(!e)return 0;switch(t){case"seconds":case"thousandths":return parseFloat(e)||0;case"hh:mm:ss":case"hh:mm:ss.u":case"hh:mm:ss.uu":case"hh:mm:ss.uuu":{const n=e.split(":");if(n.length!==3)return 0;const r=parseInt(n[0],10)||0,s=parseInt(n[1],10)||0,a=parseFloat(n[2])||0;return r*3600+s*60+a}default:return 0}}var zl=({id:e,label:t,value:n,format:r,className:s,onChange:a,readOnly:o=!1})=>{const[i,l]=p.useState("");p.useEffect(()=>{const m=Ln(n,r);l(m)},[n,r,e]);const c=m=>{const d=m.target.value;l(d)},u=()=>{if(a){const m=Nd(i,r);a(m)}l(Ln(n,r))},f=m=>{m.key==="Enter"&&m.currentTarget.blur()};return S.jsxs(S.Fragment,{children:[S.jsx(xg,{as:"label",htmlFor:e,children:t}),S.jsx($d,{type:"text",className:s,id:e,value:i,onChange:c,onBlur:u,onKeyDown:f,readOnly:o})]})},fv=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[s,a]=p.useState("hh:mm:ss.uuu");p.useEffect(()=>{const l=document.querySelector(".time-format"),c=()=>{l&&a(l.value)};return l&&(a(l.value),l.addEventListener("change",c)),()=>{l?.removeEventListener("change",c)}},[]);const o=l=>{n&&n(l,t)},i=l=>{n&&n(e,l)};return S.jsxs("div",{className:r,children:[S.jsx(zl,{id:"audio_start",label:"Start of audio selection",value:e,format:s,className:"audio-start form-control mr-sm-2",onChange:o}),S.jsx(zl,{id:"audio_end",label:"End of audio selection",value:t,format:s,className:"audio-end form-control mr-sm-2",onChange:i})]})},hv=p.createContext(null);function pv(){return p.useContext(hv)}function ys(){return window.devicePixelRatio}var zd=p.createContext(ys()),jd=({children:e})=>{const[t,n]=p.useState(ys());return matchMedia(`(resolution: ${ys()}dppx)`).addEventListener("change",()=>{n(ys())},{once:!0}),S.jsx(zd.Provider,{value:Math.ceil(t),children:e})},_i=()=>p.useContext(zd),zr=p.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}),Ks=()=>p.useContext(zr),jr=()=>p.useContext(P.ThemeContext);p.createContext(S.jsx(p.Fragment,{}));var mv=0,gv=!1,vv=0,yv=0,bv={progress:mv,isPlaying:gv,selectionStart:vv,selectionEnd:yv};p.createContext(bv);p.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var wv=(e,t,n)=>(e-t)/(n-t),_v=P.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
610
605
|
position: absolute;
|
|
611
606
|
background: #000;
|
|
612
607
|
transform: translateZ(0);
|
|
613
608
|
backface-visibility: hidden;
|
|
614
|
-
`,
|
|
609
|
+
`,xv=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
615
610
|
position: absolute;
|
|
616
611
|
top: 0;
|
|
617
612
|
image-rendering: pixelated;
|
|
618
613
|
image-rendering: crisp-edges;
|
|
619
|
-
`;function
|
|
614
|
+
`;function Sv(){const e=new Uint8Array(768);for(let t=0;t<256;t++)e[t*3]=e[t*3+1]=e[t*3+2]=t;return e}var Cv=Sv(),jl=({index:e,channelIndex:t,data:n,length:r,waveHeight:s,devicePixelRatio:a=1,samplesPerPixel:o,colorLUT:i,frequencyScaleFn:l,minFrequency:c=0,maxFrequency:u,workerApi:f,clipId:m,onCanvasesReady:d})=>{const h=t??e,{canvasRef:v,canvasMapRef:y}=Ys(),g=p.useRef([]),b=p.useRef(new WeakSet),w=p.useRef(f),_=p.useRef(d),x=!!(f&&m),C=yi(),k=Xs(r,Le,C),I=i??Cv,E=u??(n?n.sampleRate/2:22050),T=l??wv,R=!!l;p.useEffect(()=>{w.current=f},[f]),p.useEffect(()=>{_.current=d},[d]),p.useEffect(()=>{if(!x)return;const M=w.current;if(!M||!m)return;const $=g.current.length,F=[];for(const q of g.current){const Y=q.match(/chunk(\d+)$/);if(!Y){F.push(q);continue}const ne=parseInt(Y[1],10),G=y.current.get(ne);if(G&&G.isConnected)F.push(q);else try{M.unregisterCanvas(q)}catch(J){console.warn(`[spectrogram] unregisterCanvas failed for ${q}:`,J)}}g.current=F;const L=[];for(const[q,Y]of y.current.entries()){if(b.current.has(Y))continue;const ne=`${m}-ch${h}-chunk${q}`;let G;try{G=Y.transferControlToOffscreen()}catch(J){console.warn(`[spectrogram] transferControlToOffscreen failed for ${ne}:`,J);continue}b.current.add(Y);try{M.registerCanvas(ne,G),L.push(ne)}catch(J){console.warn(`[spectrogram] registerCanvas failed for ${ne}:`,J);continue}}if(L.length>0&&(g.current=[...g.current,...L]),L.length>0||F.length<$){const q=g.current,Y=q.map(ne=>{const G=ne.match(/chunk(\d+)$/);if(!G)return console.warn(`[spectrogram] Unexpected canvas ID format: ${ne}`),Le;const J=parseInt(G[1],10);return Math.min(r-J*Le,Le)});_.current?.(q,Y)}},[y,x,m,h,r,k]),p.useEffect(()=>()=>{const M=w.current;if(M){for(const $ of g.current)try{M.unregisterCanvas($)}catch(F){console.warn(`[spectrogram] unregisterCanvas failed for ${$}:`,F)}g.current=[]}},[]),p.useEffect(()=>{if(x||!n)return;const{frequencyBinCount:M,frameCount:$,hopSize:F,sampleRate:L,gainDb:z,rangeDb:q}=n,Y=q===0?1:q,ne=G=>G/M*(L/2);for(const[G,J]of y.current.entries()){const ae=G*Le,ue=J.getContext("2d");if(!ue)continue;const de=J.width/a,Me=s;ue.resetTransform(),ue.clearRect(0,0,J.width,J.height),ue.imageSmoothingEnabled=!1,ue.scale(a,a);const j=ue.createImageData(de,Me),U=j.data;for(let ye=0;ye<de;ye++){const Q=(ae+ye)*o,ke=Math.floor(Q/F);if(ke<0||ke>=$)continue;const B=ke*M;for(let Te=0;Te<Me;Te++){const Qe=1-Te/Me;let We=Math.floor(Qe*M);if(R){let _e=0,Fe=M-1;for(;_e<Fe;){const Ve=_e+Fe>>1,Ye=ne(Ve);T(Ye,c,E)<Qe?_e=Ve+1:Fe=Ve}We=_e}if(We<0||We>=M)continue;const pe=n.data[B+We],te=Math.max(0,Math.min(1,(pe+Y+z)/Y)),Ue=Math.floor(te*255),at=(Te*de+ye)*4;U[at]=I[Ue*3],U[at+1]=I[Ue*3+1],U[at+2]=I[Ue*3+2],U[at+3]=255}}if(ue.resetTransform(),ue.putImageData(j,0,0),a!==1){const ye=document.createElement("canvas");ye.width=de,ye.height=Me;const Z=ye.getContext("2d");if(!Z)continue;Z.putImageData(j,0,0),ue.clearRect(0,0,J.width,J.height),ue.imageSmoothingEnabled=!1,ue.drawImage(ye,0,0,J.width,J.height)}}},[y,x,n,r,s,a,o,I,c,E,T,R,k]);const A=k.map(M=>{const $=M*Le,F=Math.min(r-$,Le);return S.jsx(xv,{$cssWidth:F,$left:$,width:F*a,height:s*a,$waveHeight:s,"data-index":M,ref:v},`${r}-${M}`)});return S.jsx(_v,{$index:e,$cssWidth:r,$waveHeight:s,children:A})},Zd=({isSelected:e,transparentBackground:t,renderMode:n="waveform",spectrogramData:r,spectrogramColorLUT:s,samplesPerPixel:a,spectrogramFrequencyScaleFn:o,spectrogramMinFrequency:i,spectrogramMaxFrequency:l,spectrogramWorkerApi:c,spectrogramClipId:u,spectrogramOnCanvasesReady:f,midiNotes:m,sampleRate:d,clipOffsetSeconds:h,...v})=>{const y=jr(),{waveHeight:g,barWidth:b,barGap:w,samplesPerPixel:_,sampleRate:x}=Ks(),C=_i(),k=a??_,I=e&&y?y.selectedWaveOutlineColor:y?.waveOutlineColor,E=e&&y?y.selectedWaveFillColor:y?.waveFillColor,T=y?.waveformDrawMode||"inverted",R=r||c;if(n==="spectrogram"&&R)return S.jsx(jl,{index:v.index,data:r,length:v.length,waveHeight:g,devicePixelRatio:C,samplesPerPixel:k,colorLUT:s,frequencyScaleFn:o,minFrequency:i,maxFrequency:l,workerApi:c,clipId:u,onCanvasesReady:f});if(n==="both"&&R){const A=Math.floor(g/2);return S.jsxs(S.Fragment,{children:[S.jsx(jl,{index:v.index*2,channelIndex:v.index,data:r,length:v.length,waveHeight:A,devicePixelRatio:C,samplesPerPixel:k,colorLUT:s,frequencyScaleFn:o,minFrequency:i,maxFrequency:l,workerApi:c,clipId:u,onCanvasesReady:f}),S.jsx("div",{style:{position:"absolute",top:(v.index*2+1)*A,width:v.length,height:A},children:S.jsx(Bl,{...v,index:0,waveOutlineColor:I,waveFillColor:E,waveHeight:A,devicePixelRatio:C,barWidth:b,barGap:w,transparentBackground:t,drawMode:T})})]})}return n==="piano-roll"?S.jsx(Jg,{index:v.index,midiNotes:m??[],length:v.length,waveHeight:g,devicePixelRatio:C,samplesPerPixel:k,sampleRate:d??x,clipOffsetSeconds:h??0,noteColor:y?.pianoRollNoteColor,selectedNoteColor:y?.pianoRollSelectedNoteColor,isSelected:e,transparentBackground:t,backgroundColor:y?.pianoRollBackgroundColor}):S.jsx(Bl,{...v,waveOutlineColor:I,waveFillColor:E,waveHeight:g,devicePixelRatio:C,barWidth:b,barGap:w,transparentBackground:t,drawMode:T})},Zl=72,kv=P.div`
|
|
620
615
|
position: sticky;
|
|
621
616
|
left: 0;
|
|
622
617
|
z-index: 101;
|
|
@@ -624,31 +619,31 @@
|
|
|
624
619
|
height: 0;
|
|
625
620
|
width: 0;
|
|
626
621
|
overflow: visible;
|
|
627
|
-
`;function
|
|
622
|
+
`;function Ev(e,t,n){const s=[20,50,100,200,500,1e3,2e3,3e3,4e3,5e3,8e3,1e4,12e3,16e3,2e4].filter(l=>l>=e&&l<=t),a=Math.max(2,Math.floor(n/20));if(s.length<=a)return s;const o=(s.length-1)/(a-1),i=[];for(let l=0;l<a;l++)i.push(s[Math.round(l*o)]);return i}var Iv=({waveHeight:e,numChannels:t,frequencyScaleFn:n,minFrequency:r,maxFrequency:s,labelsColor:a="#ccc",labelsBackground:o="rgba(0,0,0,0.6)",renderMode:i="spectrogram",hasClipHeaders:l=!1})=>{const c=p.useRef(null),u=_i(),f=i==="both"?Math.floor(e/2):e,m=t*e,d=l?22:0;return p.useLayoutEffect(()=>{const h=c.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 y=Ev(r,s,f);for(let g=0;g<t;g++){const b=g*e+d;v.font="11px monospace",v.textBaseline="middle";for(const w of y){const _=n(w,r,s);if(_<0||_>1)continue;const x=b+f*(1-_),C=w>=1e3?`${(w/1e3).toFixed(1)}k`:`${w} Hz`,k=v.measureText(C),I=3;v.fillStyle=o,v.fillRect(0,x-7,k.width+I*2,14),v.fillStyle=a,v.fillText(C,I,x)}}},[e,t,n,r,s,a,o,u,f,d]),S.jsx(kv,{$height:m+d,children:S.jsx("canvas",{ref:c,width:Zl*u,height:(m+d)*u,style:{width:Zl,height:m+d,pointerEvents:"none"}})})},Mv=P.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
|
|
628
623
|
position: relative;
|
|
629
624
|
overflow: visible; /* Allow time labels to render above the container */
|
|
630
625
|
border-bottom: 1px solid ${e=>e.theme.timeColor};
|
|
631
626
|
box-sizing: border-box;
|
|
632
|
-
`,
|
|
627
|
+
`,Av=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`,left:`${e.$left}px`}}))`
|
|
633
628
|
position: absolute;
|
|
634
629
|
bottom: 0;
|
|
635
|
-
`,
|
|
630
|
+
`,Tv=e=>{const{theme:{timeColor:t},tickData:n}=e,{canvasRef:r,canvasMapRef:s}=Ys(),{timeScaleHeight:a}=p.useContext(zr),o=_i(),{widthX:i,canvasInfo:l,timeMarkersWithPositions:c}=n,u=Xs(i,Le),f=u.map(v=>{const y=v*Le,g=Math.min(i-y,Le);return S.jsx(Av,{$cssWidth:g,$left:y,$timeScaleHeight:a,width:g*o,height:a*o,"data-index":v,ref:r},`timescale-${v}`)}),m=u.length>0?u[0]*Le:0,d=u.length>0?(u[u.length-1]+1)*Le:1/0,h=u.length>0?c.filter(({pix:v})=>v>=m&&v<d).map(({element:v})=>v):c.map(({element:v})=>v);return p.useLayoutEffect(()=>{for(const[v,y]of s.current.entries()){const g=y.getContext("2d");if(!g)continue;const b=v*Le,w=y.width/o;g.resetTransform(),g.clearRect(0,0,y.width,y.height),g.imageSmoothingEnabled=!1,g.fillStyle=t,g.scale(o,o);for(const[_,x]of l.entries()){if(_<b||_>=b+w)continue;const C=_-b,k=a-x;g.fillRect(C,k,1,x)}}},[s,o,t,a,l,u]),S.jsxs(Mv,{$cssWidth:i,$timeScaleHeight:a,children:[h,f]})},$v=P.withTheme(Tv),Hl=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 Rv(e){const t=Hl.keys();let n;for(const r of t)if(e<r){n=Hl.get(r);break}return n===void 0&&(n={marker:3e4,bigStep:1e4,smallStep:5e3}),n}function Dv(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var Pv=P.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
|
|
636
631
|
position: absolute;
|
|
637
632
|
font-size: 0.75rem; /* Smaller font to prevent overflow */
|
|
638
633
|
white-space: nowrap; /* Prevent text wrapping */
|
|
639
634
|
color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
|
|
640
|
-
`,
|
|
635
|
+
`,Hd=({renderTick:e})=>{const{samplesPerPixel:t,sampleRate:n,duration:r,timeScaleHeight:s}=p.useContext(zr),a=pv(),o=p.useMemo(()=>{const i=Gf(r/1e3,t,n);if(a){const{bpm:y,timeSignature:g,ticksPerBar:b,ticksPerBeat:w}=a,_=new Map,x=[],C=r/1e3,k=Math.ceil(C*y*Zn/60),I=mr(w,y,n)/t,E=mr(b,y,n)/t,T=10,R=30;let A;if(I>=T)A=w;else if(E>=T)A=b;else{const $=Math.ceil(T/E);A=b*$}let M;if(I>=R)M=w;else if(E>=R)M=b;else{const $=Math.ceil(R/E);M=b*$}for(let $=0;$<=k;$+=A){const F=mr($,y,n),L=Hf(F,t);if(L>=i)break;const z=$%b===0,q=$%M===0,Y=z?s:Math.floor(q?s/2:s/5);if(_.set(L,Y),q){const ne=Uf($,g),G=e?S.jsx(p.Fragment,{children:e(ne,L)},`bb-${$}`):S.jsx("div",{style:{position:"absolute",left:`${L+4}px`,fontSize:"0.75rem",whiteSpace:"nowrap"},children:ne},`bb-${$}`);x.push({pix:L,element:G})}}return{widthX:i,canvasInfo:_,timeMarkersWithPositions:x}}const l=Rv(t),{marker:c,bigStep:u,smallStep:f}=l,m=new Map,d=[],h=n/t;let v=0;for(let y=0;y<i;y+=h*f/1e3){const g=Math.floor(y);if(v%c===0){const b=Dv(v),w=e?S.jsx(p.Fragment,{children:e(b,g)},`timestamp-${v}`):S.jsx(Pv,{$left:g,children:b},b);d.push({pix:g,element:w}),m.set(g,s)}else v%u===0?m.set(g,Math.floor(s/2)):v%f===0&&m.set(g,Math.floor(s/5));v+=f}return{widthX:i,canvasInfo:m,timeMarkersWithPositions:d}},[a,r,t,n,s,e]);return S.jsx($v,{tickData:o})},Fv=P.div`
|
|
641
636
|
display: inline-flex;
|
|
642
637
|
align-items: center;
|
|
643
638
|
gap: 0.5rem;
|
|
644
|
-
`,
|
|
639
|
+
`,Ov=[{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"}],Lv=({value:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.value)};return S.jsx(Fv,{className:r,children:S.jsx(Rd,{className:"time-format",value:e,onChange:s,disabled:n,"aria-label":"Time format selection",children:Ov.map(a=>S.jsx("option",{value:a.value,children:a.label},a.value))})})},Bv=P.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?bi:0)}px`}}))`
|
|
645
640
|
position: relative;
|
|
646
641
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
647
|
-
`,
|
|
642
|
+
`,Wv=P.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
|
|
648
643
|
position: relative;
|
|
649
644
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
650
645
|
height: 100%;
|
|
651
|
-
`,
|
|
646
|
+
`,Gd=({numChannels:e,children:t,className:n,backgroundColor:r,offset:s=0,width:a,hasClipHeaders:o=!1,onClick:i,trackId:l,isSelected:c=!1})=>{const{waveHeight:u}=Ks();return S.jsx(Bv,{$numChannels:e,className:n,$waveHeight:u,$width:a,$hasClipHeaders:o,children:S.jsx(Wv,{$backgroundColor:r,$offset:s,onClick:i,"data-track-id":l,children:t})})},Gl=P.button.attrs({type:"button"})`
|
|
652
647
|
display: inline-block;
|
|
653
648
|
font-family: ${e=>e.theme.fontFamily};
|
|
654
649
|
font-weight: 500;
|
|
@@ -710,7 +705,7 @@
|
|
|
710
705
|
box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
|
|
711
706
|
}
|
|
712
707
|
`}
|
|
713
|
-
`,
|
|
708
|
+
`,Vv=P.div`
|
|
714
709
|
margin-bottom: 0.3rem;
|
|
715
710
|
|
|
716
711
|
button:not(:first-child) {
|
|
@@ -722,7 +717,7 @@
|
|
|
722
717
|
border-top-right-radius: 0;
|
|
723
718
|
border-bottom-right-radius: 0;
|
|
724
719
|
}
|
|
725
|
-
`,
|
|
720
|
+
`,Nv=P.button`
|
|
726
721
|
position: absolute;
|
|
727
722
|
left: 0;
|
|
728
723
|
top: 0;
|
|
@@ -744,7 +739,7 @@
|
|
|
744
739
|
opacity: 1;
|
|
745
740
|
color: #dc3545;
|
|
746
741
|
}
|
|
747
|
-
`,
|
|
742
|
+
`,zv=({onClick:e,title:t="Remove track"})=>S.jsx(Nv,{onClick:e,title:t,children:S.jsx(vg,{size:12,weight:"bold"})}),jv=P.div`
|
|
748
743
|
background: transparent;
|
|
749
744
|
width: 100%;
|
|
750
745
|
height: 100%;
|
|
@@ -757,7 +752,7 @@
|
|
|
757
752
|
text-align: center;
|
|
758
753
|
border: 1px solid ${e=>e.theme.borderColor};
|
|
759
754
|
border-radius: ${e=>e.theme.borderRadius};
|
|
760
|
-
`,
|
|
755
|
+
`,Zv=P.header`
|
|
761
756
|
overflow: hidden;
|
|
762
757
|
height: 26px;
|
|
763
758
|
width: 100%;
|
|
@@ -768,7 +763,7 @@
|
|
|
768
763
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
769
764
|
color: ${e=>e.theme.textColor};
|
|
770
765
|
background-color: transparent;
|
|
771
|
-
|
|
766
|
+
`,Hv=e=>S.jsx(Ad,{weight:"light",...e}),Gv=e=>S.jsx(Md,{weight:"light",...e}),Uv=e=>S.jsx(Id,{weight:"bold",...e}),Ul=P(Dd)`
|
|
772
767
|
width: 75%;
|
|
773
768
|
height: 5px;
|
|
774
769
|
background: ${e=>e.theme.sliderTrackColor};
|
|
@@ -817,7 +812,7 @@
|
|
|
817
812
|
&:focus::-moz-range-thumb {
|
|
818
813
|
border: 2px solid ${e=>e.theme.textColor};
|
|
819
814
|
}
|
|
820
|
-
`,
|
|
815
|
+
`,Xl=P.label`
|
|
821
816
|
width: 100%;
|
|
822
817
|
display: flex;
|
|
823
818
|
justify-content: space-between;
|
|
@@ -825,10 +820,10 @@
|
|
|
825
820
|
padding: 0 1rem;
|
|
826
821
|
margin-bottom: 0.2rem;
|
|
827
822
|
font-size: 14px;
|
|
828
|
-
`,
|
|
823
|
+
`,Xv=P.div`
|
|
829
824
|
position: relative;
|
|
830
825
|
display: inline-block;
|
|
831
|
-
`,
|
|
826
|
+
`,Yv=P.button`
|
|
832
827
|
background: none;
|
|
833
828
|
border: none;
|
|
834
829
|
cursor: pointer;
|
|
@@ -842,7 +837,7 @@
|
|
|
842
837
|
&:hover {
|
|
843
838
|
opacity: 1;
|
|
844
839
|
}
|
|
845
|
-
`,
|
|
840
|
+
`,bs=180,Kv=P.div`
|
|
846
841
|
position: fixed;
|
|
847
842
|
top: ${e=>e.$top}px;
|
|
848
843
|
left: ${e=>e.$left}px;
|
|
@@ -852,14 +847,14 @@
|
|
|
852
847
|
border: 1px solid rgba(128, 128, 128, 0.4);
|
|
853
848
|
border-radius: 6px;
|
|
854
849
|
padding: 0.5rem 0;
|
|
855
|
-
min-width: ${
|
|
850
|
+
min-width: ${bs}px;
|
|
856
851
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
857
|
-
`,
|
|
852
|
+
`,qv=P.hr`
|
|
858
853
|
border: none;
|
|
859
854
|
border-top: 1px solid rgba(128, 128, 128, 0.3);
|
|
860
855
|
margin: 0.35rem 0;
|
|
861
|
-
`,
|
|
862
|
-
`,10)+1,o=r.substring(s)+"",a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)}function Kv(e,t,n){var r;return function(o){return r=r||Yv(e),new Worker(r,o)}}var qv=Kv("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function mt(e){if(Hv(e)&&(e=Uv(e)),Gv(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 Cn(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var tr={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function Jv(e){var t={scale:e.scale||tr.scale,bits:e.bits||tr.bits,amplitude_scale:e.amplitude_scale||tr.amplitude_scale,split_channels:e.split_channels||tr.split_channels,disable_worker:e.disable_worker||tr.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 Ld(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 mt(s),e)}else{var o=new qv;o.onmessage=function(a){n(void 0,new mt(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 e0(e,t,n,r){function s(a){a||(a=new DOMException("EncodingError")),r(a),r=function(){}}var o=e.decodeAudioData(t,function(a){Ld(a,n,r)},s);o&&o.catch(s)}mt.create=function(t){return new mt(t)};mt.createFromAudio=function(e,t){var n=Jv(e);if(e.audio_context&&e.array_buffer)return e0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Ld(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Gs(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 mt(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}Gs.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};Gs.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};Gs.prototype.getOutputData=function(){return this._output_data};mt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Mn(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Mn(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 Gs(t);!n.next(););return new mt(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 mt.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(m){return m._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),h=0;h<n;h++)f.setUint8(h,u.getUint8(h));f.setInt32(16,s,!0);for(var d=0,p=new Uint8Array(c,n),v=0;v<o.length;v++){var y=o[v];p.set(new Uint8Array(y,n),d),d+=y.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!Mn(t.startIndex)&&!Mn(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Mn(t.startTime)&&!Mn(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 mt(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 vi(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 mt.create(r)}else{const r=await t.json();return mt.create(r)}}function Wd(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 t0(e,t=0){const n=await vi(e);return Wd(n,t)}async function n0(e){const t=await vi(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function Bd(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 r0(e,t,n=0,r,s){const o=Bd(e,t,r,s);if(o===null){const h=e.bits;return{data:h===8?new Int8Array(0):new Int16Array(0),bits:h,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 h=0;h<u;h++)f[h*2]=l[h],f[h*2+1]=c[h];return{data:f,bits:i,length:u}}function zl(e,t,n,r,s){const o=Bd(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),h=f.min_array(),d=f.max_array(),p=h.length,v=i===8?new Int8Array(p*2):new Int16Array(p*2);for(let y=0;y<p;y++)v[y*2]=h[y],v[y*2+1]=d[y];l.push(v)}if(n&&l.length>1){const u=1/l.length,f=l[0].length/2,h=i===8?new Int8Array(f*2):new Int16Array(f*2);for(let d=0;d<f;d++){let p=0,v=0;for(let y=0;y<l.length;y++)p+=u*l[y][d*2],v+=u*l[y][d*2+1];h[d*2]=p,h[d*2+1]=v}return{length:f,data:[h],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function Vd(){const[e,t]=g.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Ln(s,e),parseTime:s=>$d(s,e)}}function Nd({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=g.useState(t),[s,o]=g.useState(!0),[a,i]=g.useState(!0),l=g.useRef(!0),c=g.useRef(!0),u=g.useRef(t),f=g.useCallback(()=>{e.current?.zoomIn()},[e]),h=g.useCallback(()=>{e.current?.zoomOut()},[e]),d=g.useCallback(p=>{p.samplesPerPixel!==u.current&&(u.current=p.samplesPerPixel,g.startTransition(()=>{r(p.samplesPerPixel)})),p.canZoomIn!==l.current&&(l.current=p.canZoomIn,o(p.canZoomIn)),p.canZoomOut!==c.current&&(c.current=p.canZoomOut,i(p.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:f,zoomOut:h,canZoomIn:s,canZoomOut:a,onEngineState:d}}function zd({engineRef:e,initialVolume:t=1}){const[n,r]=g.useState(t),s=g.useRef(t),o=g.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),a=g.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:o,masterVolumeRef:s,onEngineState:a}}function s0({engineRef:e}){const[t,n]=g.useState(0),[r,s]=g.useState(0),o=g.useRef(0),a=g.useRef(0),i=g.useCallback((c,u)=>{e.current?.setSelection(c,u)},[e]),l=g.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 o0({engineRef:e}){const[t,n]=g.useState(!1),[r,s]=g.useState(0),[o,a]=g.useState(0),i=g.useRef(!1),l=g.useRef(0),c=g.useRef(0),u=g.useCallback(p=>{e.current?.setLoopEnabled(p)},[e]),f=g.useCallback((p,v)=>{e.current?.setLoopRegion(p,v)},[e]),h=g.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),d=g.useCallback(p=>{p.isLoopEnabled!==i.current&&(i.current=p.isLoopEnabled,n(p.isLoopEnabled)),p.loopStart!==l.current&&(l.current=p.loopStart,s(p.loopStart)),p.loopEnd!==c.current&&(c.current=p.loopEnd,a(p.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:o,setLoopEnabled:u,setLoopRegion:f,clearLoopRegion:h,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:d}}function a0({engineRef:e}){const[t,n]=g.useState(null),r=g.useRef(null),s=g.useCallback(a=>{e.current?.selectTrack(a)},[e]),o=g.useCallback(a=>{a.selectedTrackId!==r.current&&(r.current=a.selectedTrackId,n(a.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:o,selectedTrackIdRef:r}}const i0=(e=256)=>{const t=g.useRef(null),n=g.useCallback((r,s,o)=>{const a=new F.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 l0(e,t={}){const{progressive:n=!1}=t,[r,s]=g.useState([]),[o,a]=g.useState(!0),[i,l]=g.useState(null),[c,u]=g.useState(0),f=e.length;return g.useEffect(()=>{if(e.length===0){s([]),a(!1),u(0);return}let h=!1;const d=new AbortController,p=new Map,v=(m,b,_)=>{const w=_??m.audioBuffer;if(!w&&!m.waveformData)throw new Error(`Track ${b+1}: Must provide src, audioBuffer, or waveformData`);const x=w?.duration??m.waveformData?.duration,S=Jl({audioBuffer:w,startTime:m.startTime??0,duration:m.duration??x,offset:m.offset??0,name:m.name||`Track ${b+1}`,fadeIn:m.fadeIn,fadeOut:m.fadeOut,waveformData:m.waveformData});if(isNaN(S.startSample)||isNaN(S.durationSamples)||isNaN(S.offsetSamples))throw console.error("Invalid clip values:",S),new Error(`Invalid clip values for track ${b+1}`);return{...Ql({name:m.name||`Track ${b+1}`,clips:[S],muted:m.muted??!1,soloed:m.soloed??!1,volume:m.volume??1,pan:m.pan??0,color:m.color}),effects:m.effects,renderMode:m.renderMode,spectrogramConfig:m.spectrogramConfig,spectrogramColorMap:m.spectrogramColorMap}};return(async()=>{try{a(!0),l(null),u(0);const m=ql.getContext().rawContext,b=e.map(async(w,x)=>{if(w.audioBuffer){const I=v(w,x,w.audioBuffer);return n&&!h&&(p.set(x,I),u(M=>M+1),s(Array.from({length:e.length},(M,$)=>p.get($)).filter(M=>M!==void 0))),I}if(!w.src&&w.waveformData){const I=v(w,x);return n&&!h&&(p.set(x,I),u(M=>M+1),s(Array.from({length:e.length},(M,$)=>p.get($)).filter(M=>M!==void 0))),I}if(!w.src)throw new Error(`Track ${x+1}: Must provide src, audioBuffer, or waveformData`);const S=await fetch(w.src,{signal:d.signal});if(!S.ok)throw new Error(`Failed to fetch ${w.src}: ${S.statusText}`);const k=await S.arrayBuffer(),E=await m.decodeAudioData(k);if(!E||!E.sampleRate||!E.duration)throw new Error(`Invalid audio buffer for ${w.src}`);const T=v(w,x,E);return n&&!h&&(p.set(x,T),u(I=>I+1),s(Array.from({length:e.length},(I,M)=>p.get(M)).filter(I=>I!==void 0))),T}),_=await Promise.all(b);h||(n||(s(_),u(_.length)),a(!1))}catch(m){if(!h){const b=m instanceof Error?m.message:"Unknown error loading audio";l(b),a(!1),console.error("Error loading audio tracks:",m)}}})(),()=>{h=!0,d.abort()}},[e,n]),{tracks:r,loading:o,error:i,loadedCount:c,totalCount:f}}function c0({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:o}){const a=g.useRef(null),i=g.useRef(0),l=g.useCallback(f=>{const h=f.operation.source?.data;if(!h)return;if(!h.boundary){a.current=null;return}const p=e[h.trackIndex]?.clips[h.clipIndex];p&&(a.current={offsetSamples:p.offsetSamples,durationSamples:p.durationSamples,startSample:p.startSample},o.current=!0)},[e,o]),c=g.useCallback(f=>{const h=f.operation.source?.data;if(!h||!h.boundary||!a.current)return;const{boundary:d,trackIndex:p,clipIndex:v}=h,b=((f.to?.x??f.operation.position.current.x)-f.operation.position.initial.x)*n,_=Math.floor(.1*r),w=a.current,x=e.map((S,k)=>{if(k!==p)return S;const E=[...S.clips].sort((M,$)=>M.startSample-$.startSample),T=E.findIndex(M=>M===S.clips[v]),I=S.clips.map((M,$)=>{if($!==v)return M;if(d==="left"){const A={...M,startSample:w.startSample,offsetSamples:w.offsetSamples,durationSamples:w.durationSamples},R=ko(A,Math.floor(b),"left",E,T,_),W=w.offsetSamples+R,q=w.durationSamples-R,z=w.startSample+R;return{...M,offsetSamples:W,durationSamples:q,startSample:z}}else{const A={...M,startSample:w.startSample,offsetSamples:w.offsetSamples,durationSamples:w.durationSamples},R=ko(A,Math.floor(b),"right",E,T,_),W=w.durationSamples+R;return{...M,durationSamples:W}}});return{...S,clips:I}});i.current=b,t(x)},[e,t,n,r]),u=g.useCallback(f=>{if(f.canceled){if(a.current){const b=f.operation.source?.data;if(b){const{trackIndex:_,clipIndex:w}=b,x=a.current,S=e.map((k,E)=>{if(E!==_)return k;const T=k.clips.map((I,M)=>M!==w?I:{...I,offsetSamples:x.offsetSamples,durationSamples:x.durationSamples,startSample:x.startSample});return{...k,clips:T}});t(S)}}o.current=!1,a.current=null,i.current=0;return}const h=f.operation.source?.data;if(!h)return;const{trackIndex:d,clipId:p,boundary:v}=h,y=v?i.current:f.operation.transform.x*n,m=e[d]?.id;if(v){o.current=!1,m?s.current?s.current.trimClip(m,p,v,Math.floor(y)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${d} not found — trim not synced to adapter`),a.current=null,i.current=0;return}m?s.current?s.current.moveClip(m,p,Math.floor(y)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${d} not found — move not synced to adapter`)},[e,t,n,s,o]);return{onDragStart:l,onDragMove:c,onDragEnd:u}}const yo=.01;function jd({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:o}){const a=g.useRef(null),i=g.useCallback(u=>{const f=u.operation.source?.data;if(!f||f.annotationIndex===void 0){a.current=null;return}const h=e[f.annotationIndex];h&&(a.current={start:h.start,end:h.end,annotationIndex:f.annotationIndex})},[e]),l=g.useCallback(u=>{if(!a.current)return;const f=u.operation.source?.data;if(!f)return;const{edge:h,annotationIndex:d}=f,p=a.current,m=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,b=h==="start"?p.start+m:p.end+m,_=u0({annotationIndex:d,newTime:b,isDraggingStart:h==="start",annotations:e,duration:s,linkEndpoints:o});t(_)},[e,t,n,r,s,o]),c=g.useCallback(u=>{if(u.canceled&&a.current){const{annotationIndex:f,start:h,end:d}=a.current,p=e.map((v,y)=>y!==f?v:{...v,start:h,end:d});t(p)}a.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function u0({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)<yo?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)<yo){const f=u.start+c;a[e+1]={...u,start:Math.min(u.end-.1,f)};let h=e+1;for(;h<a.length-1;){const d=a[h],p=a[h+1];if(Math.abs(p.start-d.end)<yo){const v=d.end-r[h].end;a[h+1]={...p,start:Math.min(p.end-.1,p.start+v)},h++}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 h=a[f],d=a[f+1];if(h.end>d.start)a[f+1]={...d,start:h.end},f++;else break}}}return a}function d0(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return g.useMemo(()=>t?[ea.configure({activationConstraints(o){return o.pointerType==="touch"?[new Bt.Delay({value:n,tolerance:r})]:[new Bt.Distance({value:s})]}})]:[ea.configure({activationConstraints:[new Bt.Distance({value:s})]})],[t,n,r,s])}const f0=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=lt(),{selectedTrackId:o}=ct(),a=g.useCallback((l,c,u)=>{const{samplesPerPixel:f}=e,h=t[l];if(!h)return!1;const d=h.clips[c];if(!d)return!1;const p=Math.round(u*n),v=Gf(p,f),y=Math.floor(.1*n);if(!sc(d,v,y))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const m=r.current;return m?(m.splitClip(h.id,d.id,v),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:g.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 h=c.clips[f],d=h.startSample/n,p=(h.startSample+h.durationSamples)/n;if(u>d&&u<p)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}},Ds=e=>{const{shortcuts:t,enabled:n=!0}=e,r=g.useCallback(s=>{if(!n)return;const o=s.target;if(o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const a=t.find(i=>{const l=s.key.toLowerCase()===i.key.toLowerCase()||s.key===i.key,c=i.ctrlKey===void 0||s.ctrlKey===i.ctrlKey,u=i.shiftKey===void 0||s.shiftKey===i.shiftKey,f=i.metaKey===void 0||s.metaKey===i.metaKey,h=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&u&&f&&h});a&&(a.preventDefault!==!1&&s.preventDefault(),a.action())},[t,n]);g.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},h0=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("+")},p0=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=lt(),{setCurrentTime:o,play:a,pause:i,stop:l}=Pe(),c=g.useCallback(()=>{s?i():a()},[s,a,i]),u=g.useCallback(()=>{l()},[l]),f=g.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 Ds({shortcuts:d,enabled:t}),{rewindToStart:f,togglePlayPause:c,stopPlayback:u,shortcuts:d}},bo=.01,ns=.01;function m0({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 h=g.useMemo(()=>t?e.findIndex(E=>E.id===t):-1,[e,t]),d=g.useCallback(E=>{if(!l?.current||!c||!u)return;const T=e.find(J=>J.id===E);if(!T)return;const I=l.current,M=I.clientWidth,$=T.start*u/c,A=T.end*u/c,R=($+A)/2,W=I.scrollLeft,q=W,z=W+M;if($<q||A>z){const J=Math.max(0,R-M/2);I.scrollTo({left:J,behavior:"smooth"})}},[e,l,c,u]);g.useEffect(()=>{t&&l?.current&&c&&u&&d(t)},[t,d,l,c,u]);const p=g.useCallback(E=>{if(h<0)return;const T=e[h],I=Math.max(0,Math.min(T.end-.1,T.start+E)),M=I-T.start,$=[...e];if($[h]={...T,start:I},o&&h>0){const A=$[h-1];Math.abs(A.end-T.start)<bo&&($[h-1]={...A,end:Math.max(A.start+.1,A.end+M)})}else if(!o&&h>0){const A=$[h-1];I<A.end&&($[h-1]={...A,end:I})}n($)},[e,h,o,n]),v=g.useCallback(E=>{if(h<0)return;const T=e[h],I=Math.max(T.start+.1,Math.min(s,T.end+E)),M=I-T.end,$=[...e];if($[h]={...T,end:I},o&&h<e.length-1){const A=$[h+1];if(Math.abs(A.start-T.end)<bo){const R=Math.min(A.end-.1,A.start+M);$[h+1]={...A,start:R};let W=h+1;for(;W<$.length-1;){const q=$[W],z=$[W+1];if(Math.abs(z.start-e[W].end)<bo){const J=q.end-e[W].end;$[W+1]={...z,start:Math.min(z.end-.1,z.start+J)},W++}else break}}}else if(!o&&h<e.length-1){const A=$[h+1];if(I>A.start){$[h+1]={...A,start:I};let R=h+1;for(;R<$.length-1;){const W=$[R],q=$[R+1];if(W.end>q.start)$[R+1]={...q,start:W.end},R++;else break}}}n($)},[e,h,s,o,n]),y=g.useCallback(()=>{!r||e.length===0||(h<=0?r(e[e.length-1].id):r(e[h-1].id))},[e,h,r]),m=g.useCallback(()=>{!r||e.length===0||(h<0||h>=e.length-1?r(e[0].id):r(e[h+1].id))},[e,h,r]),b=g.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),_=g.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),w=g.useCallback(()=>{r&&r(null)},[r]),x=g.useCallback(()=>{if(h<0||!f)return;const E=e[h],T=a?void 0:E.end-E.start;f(E.start,T)},[e,h,a,f]),S=g.useMemo(()=>[{key:"[",action:()=>p(-ns),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>p(ns),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-ns),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(ns),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:x,description:"Play selected annotation",preventDefault:!0}],[p,v,x]),k=g.useMemo(()=>[{key:"ArrowUp",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:m,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:m,description:"Select next annotation",preventDefault:!0},{key:"Home",action:b,description:"Select first annotation",preventDefault:!0},{key:"End",action:_,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:w,description:"Deselect annotation",preventDefault:!0}],[y,m,b,_,w]);return Ds({shortcuts:S,enabled:i&&h>=0}),Ds({shortcuts:k,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:p,moveEndBoundary:v,selectPrevious:y,selectNext:m,selectFirst:b,selectLast:_,clearSelection:w,scrollToAnnotation:d,playActiveAnnotation:x}}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}]}],yi=e=>jr.find(t=>t.id===e),g0=e=>jr.filter(t=>t.category===e),v0=[{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 y0={reverb:F.Reverb,freeverb:F.Freeverb,jcReverb:F.JCReverb,feedbackDelay:F.FeedbackDelay,pingPongDelay:F.PingPongDelay,chorus:F.Chorus,phaser:F.Phaser,tremolo:F.Tremolo,vibrato:F.Vibrato,autoPanner:F.AutoPanner,autoFilter:F.AutoFilter,autoWah:F.AutoWah,eq3:F.EQ3,distortion:F.Distortion,bitCrusher:F.BitCrusher,chebyshev:F.Chebyshev,compressor:F.Compressor,limiter:F.Limiter,gate:F.Gate,stereoWidener:F.StereoWidener};let b0=0;const w0=()=>`effect_${Date.now()}_${++b0}`;function Tr(e,t){const n=y0[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=w0(),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 _0(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 x0(e=256){const[t,n]=g.useState([]),r=g.useRef(t);r.current=t;const s=g.useRef(new Map),o=g.useRef(null),a=g.useRef(null),i=g.useCallback(y=>{const m=a.current;if(!m)return;const{masterGainNode:b,destination:_,analyserNode:w}=m;try{b.disconnect()}catch(S){console.warn("[waveform-playlist] Error disconnecting master effects chain:",S)}const x=y.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)b.connect(w),w.connect(_);else{let S=b;x.forEach(k=>{try{k.disconnect()}catch(E){console.warn(`[waveform-playlist] Error disconnecting effect "${k.id}":`,E)}S.connect(k.effect),S=k.effect}),S.connect(w),w.connect(_)}},[]),l=g.useCallback(y=>{const m=yi(y);if(!m){console.error(`Unknown effect: ${y}`);return}const b={};m.parameters.forEach(x=>{b[x.name]=x.default});const _=Tr(m,b);s.current.set(_.instanceId,_);const w={instanceId:_.instanceId,effectId:m.id,definition:m,params:b,bypassed:!1};n(x=>[...x,w])},[]),c=g.useCallback(y=>{const m=s.current.get(y);m&&(m.dispose(),s.current.delete(y)),n(b=>b.filter(_=>_.instanceId!==y))},[]),u=g.useCallback((y,m,b)=>{const _=s.current.get(y);_&&_.setParameter(m,b),n(w=>w.map(x=>x.instanceId===y?{...x,params:{...x.params,[m]:b}}:x))},[]),f=g.useCallback(y=>{const m=r.current.find(w=>w.instanceId===y);if(!m)return;const b=!m.bypassed,_=s.current.get(y);if(_){const w=m.params.wet??1;_.setParameter("wet",b?0:w)}n(w=>w.map(x=>x.instanceId===y?{...x,bypassed:b}:x))},[]),h=g.useCallback((y,m)=>{n(b=>{const _=[...b],[w]=_.splice(y,1);return _.splice(m,0,w),_})},[]),d=g.useCallback(()=>{s.current.forEach(y=>y.dispose()),s.current.clear(),n([])},[]);g.useEffect(()=>{i(t)},[t,i]);const p=g.useCallback((y,m,b)=>{const _=new F.Analyser("fft",e);o.current=_,a.current={masterGainNode:y,destination:m,analyserNode:_};const x=r.current.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)y.connect(_),_.connect(m);else{let S=y;x.forEach(k=>{S.connect(k.effect),S=k.effect}),S.connect(_),_.connect(m)}return function(){_.dispose(),o.current=null,a.current=null}},[e]);g.useEffect(()=>{const y=s.current;return()=>{y.forEach(m=>m.dispose()),y.clear()}},[]);const v=g.useCallback(()=>{const y=t.filter(m=>!m.bypassed);if(y.length!==0)return(m,b,_)=>{const w=[];for(const x of y){const S=Tr(x.definition,x.params);w.push(S)}if(w.length===0)m.connect(b);else{let x=m;w.forEach(S=>{x.connect(S.effect),x=S.effect}),x.connect(b)}return function(){w.forEach(S=>S.dispose())}}},[t]);return{activeEffects:t,availableEffects:jr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:f,reorderEffects:h,clearAllEffects:d,masterEffects:p,createOfflineEffectsFunction:v,analyserRef:o}}function C0(){const[e,t]=g.useState(new Map),n=g.useRef(new Map),r=g.useRef(new Map),s=g.useCallback((d,p)=>{const v=r.current.get(d);if(!v)return;const{graphEnd:y,masterGainNode:m}=v,b=n.current.get(d);try{y.disconnect()}catch(w){console.warn(`[waveform-playlist] Error disconnecting track "${d}" effect chain:`,w)}const _=p.map(w=>b?.get(w.instanceId)).filter(w=>w!==void 0);if(_.length===0)y.connect(m);else{let w=y;_.forEach(x=>{try{x.disconnect()}catch(S){console.warn(`[waveform-playlist] Error disconnecting effect "${x.id}" on track "${d}":`,S)}w.connect(x.effect),w=x.effect}),w.connect(m)}},[]),o=g.useCallback((d,p)=>{const v=yi(p);if(!v){console.error(`Unknown effect: ${p}`);return}const y={};v.parameters.forEach(_=>{y[_.name]=_.default});const m=Tr(v,y);n.current.has(d)||n.current.set(d,new Map),n.current.get(d).set(m.instanceId,m);const b={instanceId:m.instanceId,effectId:v.id,definition:v,params:y,bypassed:!1};t(_=>{const w=new Map(_),x=w.get(d)||[];return w.set(d,[...x,b]),w})},[]),a=g.useCallback((d,p)=>{const v=n.current.get(d),y=v?.get(p);y&&(y.dispose(),v?.delete(p)),t(m=>{const b=new Map(m),_=b.get(d)||[];return b.set(d,_.filter(w=>w.instanceId!==p)),b})},[]),i=g.useCallback((d,p,v,y)=>{const b=n.current.get(d)?.get(p);b&&b.setParameter(v,y),t(_=>{const w=new Map(_),x=w.get(d)||[];return w.set(d,x.map(S=>S.instanceId===p?{...S,params:{...S.params,[v]:y}}:S)),w})},[]),l=g.useCallback((d,p)=>{const y=(u.current.get(d)||[]).find(w=>w.instanceId===p);if(!y)return;const m=!y.bypassed,_=n.current.get(d)?.get(p);if(_){const w=y.params.wet??1;_.setParameter("wet",m?0:w)}t(w=>{const x=new Map(w),S=x.get(d)||[];return x.set(d,S.map(k=>k.instanceId===p?{...k,bypassed:m}:k)),x})},[]),c=g.useCallback(d=>{const p=n.current.get(d);p&&(p.forEach(v=>v.dispose()),p.clear()),t(v=>{const y=new Map(v);return y.set(d,[]),y})},[]),u=g.useRef(e);u.current=e;const f=g.useCallback(d=>(p,v,y)=>{r.current.set(d,{graphEnd:p,masterGainNode:v});const m=u.current.get(d)||[],b=n.current.get(d),_=m.map(w=>b?.get(w.instanceId)).filter(w=>w!==void 0);if(_.length===0)p.connect(v);else{let w=p;_.forEach(x=>{w.connect(x.effect),w=x.effect}),w.connect(v)}return function(){r.current.delete(d)}},[]);g.useEffect(()=>{e.forEach((d,p)=>{s(p,d)})},[e,s]),g.useEffect(()=>{const d=n.current;return()=>{d.forEach(p=>{p.forEach(v=>v.dispose()),p.clear()}),d.clear()}},[]);const h=g.useCallback(d=>{const v=(e.get(d)||[]).filter(y=>!y.bypassed);if(v.length!==0)return(y,m,b)=>{const _=[];for(const w of v){const x=Tr(w.definition,w.params);_.push(x)}if(_.length===0)y.connect(m);else{let w=y;_.forEach(x=>{w.connect(x.effect),w=x.effect}),w.connect(m)}return function(){_.forEach(x=>x.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:o,removeEffectFromTrack:a,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:f,createOfflineTrackEffectsFunction:h,availableEffects:jr}}function S0(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,h=new ArrayBuffer(f),d=new DataView(h);rs(d,0,"RIFF"),d.setUint32(4,f-8,!0),rs(d,8,"WAVE"),rs(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),rs(d,36,"data"),d.setUint32(40,c,!0);const p=[];for(let y=0;y<r;y++)p.push(e.getChannelData(y));let v=u;if(n===16)for(let y=0;y<o;y++)for(let m=0;m<r;m++){const b=p[m][y],_=Math.max(-1,Math.min(1,b)),w=_<0?_*32768:_*32767;d.setInt16(v,w,!0),v+=2}else for(let y=0;y<o;y++)for(let m=0;m<r;m++)d.setFloat32(v,p[m][y],!0),v+=4;return new Blob([h],{type:"audio/wav"})}function rs(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function k0(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 Zd(){const[e,t]=g.useState(!1),[n,r]=g.useState(0),[s,o]=g.useState(null);return{exportWav:g.useCallback(async(i,l,c={})=>{const{filename:u="export",mode:f="master",trackIndex:h,autoDownload:d=!0,applyEffects:p=!0,effectsFunction:v,createOfflineTrackEffects:y,bitDepth:m=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"&&(h===void 0||h<0||h>=i.length))throw new Error("Invalid track index for individual export");const _=i[0].clips[0]?.sampleRate||44100;let w=0;for(const M of i)for(const $ of M.clips){const A=$.startSample+$.durationSamples;w=Math.max(w,A)}w+=Math.round(_*.1);const x=w/_,S=f==="individual"?[{track:i[h],state:l[h],index:h}]:i.map((M,$)=>({track:M,state:l[$],index:$})),k=l.some(M=>M.soloed),E=!!y;let T;if((v||E)&&p)T=await E0(S,l,k,x,_,v,y,M=>{r(M),b?.(M)});else{const M=new OfflineAudioContext(2,w,_);let $=0;const A=S.reduce((R,{track:W})=>R+W.clips.length,0);for(const{track:R,state:W}of S)if(!(W.muted&&!W.soloed)&&!(k&&!W.soloed))for(const q of R.clips){await M0(M,q,W,_,p),$++;const z=$/A*.5;r(z),b?.(z)}r(.5),b?.(.5),T=await M.startRendering()}r(.9),b?.(.9);const I=S0(T,{bitDepth:m});if(r(1),b?.(1),d){const M=f==="individual"?`${u}_${i[h].name}`:u;k0(I,`${M}.wav`)}return{audioBuffer:T,blob:I,duration:x}}catch(_){const w=_ instanceof Error?_.message:"Export failed";throw o(w),_}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function E0(e,t,n,r,s,o,a,i){const{Offline:l,Volume:c,Gain:u,Panner:f,Player:h,ToneAudioBuffer:d}=await import("tone");i(.1);let p;try{p=await l(async({transport:v,destination:y})=>{const m=new c(0);let b;o?b=o(m,y,!0):m.connect(y);for(const{track:_,state:w}of e){if(w.muted&&!w.soloed||n&&!w.soloed)continue;const x=new c(I0(w.volume)),S=new f(w.pan),k=new u(w.muted?0:1),E=a?.(_.id);E?E(k,m,!0):k.connect(m),S.connect(k),x.connect(S);for(const T of _.clips){const{audioBuffer:I,startSample:M,durationSamples:$,offsetSamples:A,gain:R,fadeIn:W,fadeOut:q}=T,z=M/s,J=$/s,ee=A/s,j=new d(I),se=new h(j),U=new u(R);if(se.connect(U),U.connect(x),W){const ie=z,le=z+W.duration,ge=wr(U.gain);ge&&(ge.setValueAtTime(0,ie),ge.linearRampToValueAtTime(R,le))}if(q){const ie=z+J-q.duration,le=z+J,ge=wr(U.gain);ge&&(ge.setValueAtTime(R,ie),ge.linearRampToValueAtTime(0,le))}se.start(z,ee,J)}}v.start(0)},r,2,s)}catch(v){throw v instanceof Error?v:new Error(`Tone.Offline rendering failed: ${String(v)}`)}return i(.9),p.get()}function I0(e){return 20*Math.log10(Math.max(e,1e-4))}async function M0(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 h=a/r,d=i/r,p=l/r,v=e.createBufferSource();v.buffer=o;const y=e.createGain(),m=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,v.connect(y),y.connect(b),b.connect(e.destination),s){if(u?y.gain.setValueAtTime(0,h):y.gain.setValueAtTime(m,h),u){const _=h,w=h+u.duration;jl(y.gain,_,w,0,m,u.type||"linear")}if(f){const _=h+d-f.duration,w=h+d;(!u||u.duration<d-f.duration)&&y.gain.setValueAtTime(m,_),jl(y.gain,_,w,m,0,f.type||"linear")}}else y.gain.setValueAtTime(m,h);v.start(h,p,d)}function jl(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=Zl(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,a);break}case"sCurve":{const i=Zl(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,a);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function Zl(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 Hd=()=>{const e=g.useRef(null),t=g.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=g.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return g.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},A0=`
|
|
856
|
+
`,Jv=({items:e})=>{const[t,n]=p.useState(!1),r=p.useCallback(()=>n(!1),[]),s=typeof e=="function"?e(r):e,[a,o]=p.useState({top:0,left:0}),i=p.useRef(null),l=p.useRef(null),c=p.useCallback(()=>{if(!i.current)return;const u=i.current.getBoundingClientRect(),f=window.innerWidth,m=window.innerHeight,d=l.current?.offsetHeight??160;let h=u.right+4;h+bs>f&&(h=u.left-bs-4),h=Math.max(4,Math.min(h,f-bs-4));let v=u.top;v+d>m-4&&(v=Math.max(4,u.bottom-d)),o({top:v,left:h})},[]);return p.useEffect(()=>{if(!t)return;c();const u=requestAnimationFrame(()=>c()),f=()=>c(),m=()=>c();return window.addEventListener("scroll",f,!0),window.addEventListener("resize",m),()=>{cancelAnimationFrame(u),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",m)}},[t,c]),p.useEffect(()=>{if(!t)return;const u=m=>{const d=m.target;i.current&&!i.current.contains(d)&&l.current&&!l.current.contains(d)&&n(!1)},f=m=>{m.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[t]),S.jsxs(Xv,{children:[S.jsx(Yv,{ref:i,onClick:u=>{u.stopPropagation(),n(f=>!f)},onMouseDown:u=>u.stopPropagation(),title:"Track menu","aria-label":"Track menu",children:S.jsx(Uv,{size:16})}),t&&typeof document<"u"&&mo.createPortal(S.jsx(Kv,{ref:l,$top:a.top,$left:a.left,onMouseDown:u=>u.stopPropagation(),children:s.map((u,f)=>S.jsxs(p.Fragment,{children:[f>0&&S.jsx(qv,{}),u.content]},u.id))}),document.body)]})};function xn(e,t){this._waveformData=e,this._channelIndex=t}xn.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};xn.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};xn.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};xn.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};xn.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};xn.prototype.max_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.max_sample(n));return t};var Qv=127,e0=-128,t0=32767,n0=-32768;function r0(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function s0(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,s=e.length,a=e.sample_rate,o=e.channels.map(function(R){return new Float32Array(R)}),i=r?o.length:1,l=24,c=r0(s,t),u=e.bits===8?1:2,f=l+c*2*u*i,m=new ArrayBuffer(f),d=new DataView(m),h=0,v=l,y=new Array(i),g=new Array(i),b=0;b<i;b++)y[b]=1/0,g[b]=-1/0;var w=e.bits===8?e0:n0,_=e.bits===8?Qv:t0;d.setInt32(0,2,!0),d.setUint32(4,e.bits===8,!0),d.setInt32(8,a,!0),d.setInt32(12,t,!0),d.setInt32(16,c,!0),d.setInt32(20,i,!0);for(var x=0;x<s;x++){var C=0;if(i===1){for(var k=0;k<o.length;++k)C+=o[k][x];C=Math.floor(_*C*n/o.length),C<y[0]&&(y[0]=C,y[0]<w&&(y[0]=w)),C>g[0]&&(g[0]=C,g[0]>_&&(g[0]=_))}else for(var I=0;I<i;++I)C=Math.floor(_*o[I][x]*n),C<y[I]&&(y[I]=C,y[I]<w&&(y[I]=w)),C>g[I]&&(g[I]=C,g[I]>_&&(g[I]=_));if(++h===t){for(var E=0;E<i;E++)e.bits===8?(d.setInt8(v++,y[E]),d.setInt8(v++,g[E])):(d.setInt16(v,y[E],!0),d.setInt16(v+2,g[E],!0),v+=4),y[E]=1/0,g[E]=-1/0;h=0}}if(h>0)for(var T=0;T<i;T++)e.bits===8?(d.setInt8(v++,y[T]),d.setInt8(v++,g[T])):(d.setInt16(v,y[T],!0),d.setInt16(v+2,g[T],!0));return m}function Os(e){"@babel/helpers - typeof";return Os=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},Os(e)}function a0(e){return e&&Os(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function o0(e){var t=e&&Os(e)==="object"&&"byteLength"in e;if(t){var n=new DataView(e),r=n.getInt32(0,!0);if(r!==1&&r!==2)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return t}function i0(e){var t=e.data,n=e.channels||1,r=24,s=e.bits===8?1:2,a=e.length*2*n;if(t.length!==a)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=r+t.length*s,i=new ArrayBuffer(o),l=new DataView(i);l.setInt32(0,2,!0),l.setUint32(4,e.bits===8,!0),l.setInt32(8,e.sample_rate,!0),l.setInt32(12,e.samples_per_pixel,!0),l.setInt32(16,e.length,!0),l.setInt32(20,n,!0);var c=r;if(e.bits===8)for(var u=0;u<t.length;u++)l.setInt8(c++,t[u],!0);else for(var f=0;f<t.length;f++)l.setInt16(c,t[f],!0),c+=2;return i}function Mn(e){return e==null}function l0(e,t){var n=atob(e);return n}function c0(e,t,n){var r=l0(e),s=r.indexOf(`
|
|
857
|
+
`,10)+1,a=r.substring(s)+"",o=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(o)}function u0(e,t,n){var r;return function(a){return r=r||c0(e),new Worker(r,a)}}var d0=u0("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function gt(e){if(a0(e)&&(e=i0(e)),o0(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 nr={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function f0(e){var t={scale:e.scale||nr.scale,bits:e.bits||nr.bits,amplitude_scale:e.amplitude_scale||nr.amplitude_scale,split_channels:e.split_channels||nr.split_channels,disable_worker:e.disable_worker||nr.disable_worker};return t}function h0(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Ud(e,t,n){var r=h0(e);if(t.disable_worker){var s=s0({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 gt(s),e)}else{var a=new d0;a.onmessage=function(o){n(void 0,new gt(o.data),e)},a.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 p0(e,t,n,r){function s(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var a=e.decodeAudioData(t,function(o){Ud(o,n,r)},s);a&&a.catch(s)}gt.create=function(t){return new gt(t)};gt.createFromAudio=function(e,t){var n=f0(e);if(e.audio_context&&e.array_buffer)return p0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Ud(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function qs(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,a=r+n*2*this._inputData.channels*s;this._output_data=new ArrayBuffer(a),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 gt(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}qs.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};qs.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 a=0;a<n;++a)this._min[a]=this._max_value,this._max[a]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(var o=0;o<n;++o){r=this._inputData.channel(o);var i=r.min_sample(this._input_index);i<this._min[o]&&(this._min[o]=i),i=r.max_sample(this._input_index),i>this._max[o]&&(this._max[o]=i)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var l=0;l<n;++l)r=this._outputWaveformData.channel(l),r.set_min_sample(this._output_index-1,this._min[l]),r.set_max_sample(this._output_index-1,this._max[l]);return!0};qs.prototype.getOutputData=function(){return this._output_data};gt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Mn(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Mn(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 qs(t);!n.next(););return new gt(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 gt.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,s=0,a=[this].concat(t).map(function(g){return g._data.buffer}),o=0;o<a.length;o++){var i=a[o],l=new DataView(i).getInt32(16,!0);r+=i.byteLength-n,s+=l}for(var c=new ArrayBuffer(r),u=new DataView(a[0]),f=new DataView(c),m=0;m<n;m++)f.setUint8(m,u.getUint8(m));f.setInt32(16,s,!0);for(var d=0,h=new Uint8Array(c,n),v=0;v<a.length;v++){var y=a[v];h.set(new Uint8Array(y,n),d),d+=y.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!Mn(t.startIndex)&&!Mn(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Mn(t.startTime)&&!Mn(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,a=24,o=this.bits===8?1:2,i=a+s*2*this.channels*o,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(a+u,f):c.setInt16(a+u*2,f,!0)}return new gt(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 xi(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 gt.create(r)}else{const r=await t.json();return gt.create(r)}}function Xd(e,t=0){const n=e.channel(t),r=e.bits,s=n.min_array(),a=n.max_array(),o=s.length,i=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let l=0;l<o;l++)i[l*2]=s[l],i[l*2+1]=a[l];return{data:i,bits:r,length:o,sampleRate:e.sample_rate}}async function m0(e,t=0){const n=await xi(e);return Xd(n,t)}async function g0(e){const t=await xi(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function Yd(e,t,n,r){let s=e;if(n!==void 0&&r!==void 0)if(s.scale!==t){const a=e.scale,o=t/a,i=Math.floor(n/t),l=Math.ceil((n+r)/t),c=Math.floor(i*o),u=Math.min(e.length,Math.ceil(l*o));if(c>=u)return null;s=s.slice({startIndex:c,endIndex:u}),s=s.resample({scale:t})}else{const a=Math.floor(n/t),o=Math.ceil((n+r)/t);s=s.slice({startIndex:a,endIndex:o})}else s.scale!==t&&(s=s.resample({scale:t}));return s}function v0(e,t,n=0,r,s){const a=Yd(e,t,r,s);if(a===null){const m=e.bits;return{data:m===8?new Int8Array(0):new Int16Array(0),bits:m,length:0}}const o=a.channel(n),i=a.bits,l=o.min_array(),c=o.max_array(),u=l.length,f=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let m=0;m<u;m++)f[m*2]=l[m],f[m*2+1]=c[m];return{data:f,bits:i,length:u}}function Yl(e,t,n,r,s){const a=Yd(e,t,r,s);if(a===null){const u=e.bits;return{length:0,data:[],bits:u}}const o=a.channels,i=a.bits,l=[];for(let u=0;u<o;u++){const f=a.channel(u),m=f.min_array(),d=f.max_array(),h=m.length,v=i===8?new Int8Array(h*2):new Int16Array(h*2);for(let y=0;y<h;y++)v[y*2]=m[y],v[y*2+1]=d[y];l.push(v)}if(n&&l.length>1){const u=1/l.length,f=l[0].length/2,m=i===8?new Int8Array(f*2):new Int16Array(f*2);for(let d=0;d<f;d++){let h=0,v=0;for(let y=0;y<l.length;y++)h+=u*l[y][d*2],v+=u*l[y][d*2+1];m[d*2]=h,m[d*2+1]=v}return{length:f,data:[m],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function Kd(){const[e,t]=p.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Ln(s,e),parseTime:s=>Nd(s,e)}}function qd({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=p.useState(t),[s,a]=p.useState(!0),[o,i]=p.useState(!0),l=p.useRef(!0),c=p.useRef(!0),u=p.useRef(t),f=p.useCallback(()=>{e.current?.zoomIn()},[e]),m=p.useCallback(()=>{e.current?.zoomOut()},[e]),d=p.useCallback(h=>{h.samplesPerPixel!==u.current&&(u.current=h.samplesPerPixel,p.startTransition(()=>{r(h.samplesPerPixel)})),h.canZoomIn!==l.current&&(l.current=h.canZoomIn,a(h.canZoomIn)),h.canZoomOut!==c.current&&(c.current=h.canZoomOut,i(h.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:f,zoomOut:m,canZoomIn:s,canZoomOut:o,onEngineState:d}}function Jd({engineRef:e,initialVolume:t=1}){const[n,r]=p.useState(t),s=p.useRef(t),a=p.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),o=p.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:a,masterVolumeRef:s,onEngineState:o}}function y0({engineRef:e}){const[t,n]=p.useState(0),[r,s]=p.useState(0),a=p.useRef(0),o=p.useRef(0),i=p.useCallback((c,u)=>{e.current?.setSelection(c,u)},[e]),l=p.useCallback(c=>{c.selectionStart!==a.current&&(a.current=c.selectionStart,n(c.selectionStart)),c.selectionEnd!==o.current&&(o.current=c.selectionEnd,s(c.selectionEnd))},[]);return{selectionStart:t,selectionEnd:r,setSelection:i,selectionStartRef:a,selectionEndRef:o,onEngineState:l}}function b0({engineRef:e}){const[t,n]=p.useState(!1),[r,s]=p.useState(0),[a,o]=p.useState(0),i=p.useRef(!1),l=p.useRef(0),c=p.useRef(0),u=p.useCallback(h=>{e.current?.setLoopEnabled(h)},[e]),f=p.useCallback((h,v)=>{e.current?.setLoopRegion(h,v)},[e]),m=p.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),d=p.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,o(h.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:a,setLoopEnabled:u,setLoopRegion:f,clearLoopRegion:m,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:d}}function w0({engineRef:e}){const[t,n]=p.useState(null),r=p.useRef(null),s=p.useCallback(o=>{e.current?.selectTrack(o)},[e]),a=p.useCallback(o=>{o.selectedTrackId!==r.current&&(r.current=o.selectedTrackId,n(o.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:a,selectedTrackIdRef:r}}const _0=(e=256)=>{const t=p.useRef(null),n=p.useCallback((r,s,a)=>{const o=new O.Analyser("fft",e);return r.connect(o),r.connect(s),t.current=o,function(){o.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}},x0=48e3;function as(e,t,n,r){const s=n??e.audioBuffer,a=s?.sampleRate??e.waveformData?.sample_rate??x0,o=s?.duration??e.waveformData?.duration??(e.duration!=null?e.duration+(e.offset??0):void 0);if(o===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 i=ac({audioBuffer:s,sampleRate:a,sourceDuration:o,startTime:e.startTime??0,duration:e.duration??o,offset:e.offset??0,name:e.name||`Track ${t+1}`,fadeIn:e.fadeIn,fadeOut:e.fadeOut,waveformData:e.waveformData});if(isNaN(i.startSample)||isNaN(i.durationSamples)||isNaN(i.offsetSamples))return console.error(`[waveform-playlist] Invalid clip values for track ${t+1} ("${e.name??"unnamed"}"): startSample=${i.startSample}, durationSamples=${i.durationSamples}, offsetSamples=${i.offsetSamples}`),null;const l={...oc({name:e.name||`Track ${t+1}`,clips:[i],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},c=r.get(t);return c?(l.id=c.trackId,l.clips[0]={...l.clips[0],id:c.clipId}):r.set(t,{trackId:l.id,clipId:l.clips[0].id}),l}function S0(e,t={}){const{immediate:n=!1,progressive:r=!1}=t,s=n||r,[a,o]=p.useState(!0),[i,l]=p.useState(null),[c,u]=p.useState(0),f=e.length,[m,d]=p.useState(new Map),h=p.useRef(new Map),v=p.useMemo(()=>{if(!s)return null;const w=[];for(let _=0;_<e.length;_++){const x=as(e[_],_,m.get(_),h.current);x&&w.push(x)}return w},[s,e,m]),[y,g]=p.useState(v??[]),b=p.useRef(v);return v!==b.current&&(b.current=v,v&&g(v)),p.useEffect(()=>{if(e.length===0){g([]),o(!1),u(0);return}let w=!1;const _=new AbortController;return(async()=>{try{o(!0),l(null),u(0),s&&d(new Map);const C=sc.getContext().rawContext,k=e.map(async(E,T)=>{if(E.audioBuffer){if(s&&!w){d($=>{const F=new Map($);return F.set(T,E.audioBuffer),F}),u($=>$+1);return}return as(E,T,E.audioBuffer,h.current)}if(!E.src&&E.waveformData){if(s&&!w){u($=>$+1);return}return as(E,T,void 0,h.current)}if(!E.src)throw new Error(`Track ${T+1}: Must provide src, audioBuffer, or waveformData`);const R=await fetch(E.src,{signal:_.signal});if(!R.ok)throw new Error(`Failed to fetch ${E.src}: ${R.statusText}`);const A=await R.arrayBuffer(),M=await C.decodeAudioData(A);if(!M||!M.sampleRate||!M.duration)throw new Error(`Invalid audio buffer for ${E.src}`);if(s&&!w){d($=>{const F=new Map($);return F.set(T,M),F}),u($=>$+1);return}return as(E,T,M,h.current)}),I=await Promise.all(k);if(!w){if(!s){const E=I.filter(T=>T!=null);g(E),u(E.length)}o(!1)}}catch(C){if(!w){const k=C instanceof Error?C.message:"Unknown error loading audio";l(k),o(!1),console.error(`[waveform-playlist] Error loading audio tracks: ${k}`)}}})(),()=>{w=!0,_.abort()}},[e,s]),{tracks:y,loading:a,error:i,loadedCount:c,totalCount:f}}function C0({originalClip:e,clip:t,pixelDelta:n,samplesPerPixel:r,sampleRate:s,boundary:a,sortedClips:o,sortedIndex:i}){const l=n*r,c=Math.floor(.1*s),u={...t,startSample:e.startSample,offsetSamples:e.offsetSamples,durationSamples:e.durationSamples},f=hc(u,Math.floor(l),a,o,i,c);return a==="left"?{startSample:e.startSample+f,durationSamples:e.durationSamples-f,offsetSamples:e.offsetSamples+f}:{startSample:e.startSample,durationSamples:e.durationSamples+f,offsetSamples:e.offsetSamples}}function k0({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:a,snapSamplePosition:o}){const i=p.useRef(o);i.current=o;const l=p.useRef(null),c=p.useRef(0),u=p.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},a.current=!0)},[e,a]),f=p.useCallback(d=>{const h=d.operation.source?.data;if(!h||!h.boundary||!l.current)return;const{boundary:v,trackIndex:y,clipIndex:g}=h,w=(d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x,_=w*n,x=l.current,C=i.current;let k=_;const I=e.map((E,T)=>{if(T!==y)return E;const R=[...E.clips].sort(($,F)=>$.startSample-F.startSample),A=R.findIndex($=>$===E.clips[g]),M=E.clips.map(($,F)=>{if(F!==g)return $;let L=C0({originalClip:x,clip:$,pixelDelta:w,samplesPerPixel:n,sampleRate:r,boundary:v,sortedClips:R,sortedIndex:A});if(C)if(v==="left"){const z=C(L.startSample),q=z-L.startSample;L={startSample:z,durationSamples:L.durationSamples-q,offsetSamples:L.offsetSamples+q},k=z-x.startSample}else{const z=L.startSample+L.durationSamples,q=C(z);L={...L,durationSamples:q-L.startSample},k=L.durationSamples-x.durationSamples}return{...$,startSample:L.startSample,durationSamples:L.durationSamples,offsetSamples:L.offsetSamples}});return{...E,clips:M}});c.current=k,t(I)},[e,t,n,r]),m=p.useCallback(d=>{if(d.canceled){if(l.current){const _=d.operation.source?.data;if(_){const{trackIndex:x,clipIndex:C}=_,k=l.current,I=e.map((E,T)=>{if(T!==x)return E;const R=E.clips.map((A,M)=>M!==C?A:{...A,offsetSamples:k.offsetSamples,durationSamples:k.durationSamples,startSample:k.startSample});return{...E,clips:R}});t(I)}}a.current=!1,l.current=null,c.current=0;return}const h=d.operation.source?.data;if(!h)return;const{trackIndex:v,clipId:y,boundary:g}=h,b=g?c.current:d.operation.transform.x*n,w=e[v]?.id;if(g){a.current=!1,w?s.current?s.current.trimClip(w,y,g,Math.floor(b)):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`),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 ${v} not found — move not synced to adapter`)},[e,t,n,s,a]);return{onDragStart:u,onDragMove:f,onDragEnd:m}}const _a=.01;function Qd({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:a}){const o=p.useRef(null),i=p.useCallback(u=>{const f=u.operation.source?.data;if(!f||f.annotationIndex===void 0){o.current=null;return}const m=e[f.annotationIndex];m&&(o.current={start:m.start,end:m.end,annotationIndex:f.annotationIndex})},[e]),l=p.useCallback(u=>{if(!o.current)return;const f=u.operation.source?.data;if(!f)return;const{edge:m,annotationIndex:d}=f,h=o.current,g=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,b=m==="start"?h.start+g:h.end+g,w=E0({annotationIndex:d,newTime:b,isDraggingStart:m==="start",annotations:e,duration:s,linkEndpoints:a});t(w)},[e,t,n,r,s,a]),c=p.useCallback(u=>{if(u.canceled&&o.current){const{annotationIndex:f,start:m,end:d}=o.current,h=e.map((v,y)=>y!==f?v:{...v,start:m,end:d});t(h)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function E0({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:s,linkEndpoints:a}){const o=[...r],i=r[e];if(n){const l=Math.min(i.end-.1,Math.max(0,t)),c=l-i.start;if(o[e]={...i,start:l},a&&e>0){const u=o[e-1];Math.abs(u.end-i.start)<_a?o[e-1]={...u,end:Math.max(u.start+.1,u.end+c)}:l<=u.end&&(o[e]={...o[e],start:u.end})}else!a&&e>0&&l<o[e-1].end&&(o[e-1]={...o[e-1],end:l})}else{const l=Math.max(i.start+.1,Math.min(t,s)),c=l-i.end;if(o[e]={...i,end:l},a&&e<o.length-1){const u=o[e+1];if(Math.abs(u.start-i.end)<_a){const f=u.start+c;o[e+1]={...u,start:Math.min(u.end-.1,f)};let m=e+1;for(;m<o.length-1;){const d=o[m],h=o[m+1];if(Math.abs(h.start-d.end)<_a){const v=d.end-r[m].end;o[m+1]={...h,start:Math.min(h.end-.1,h.start+v)},m++}else break}}else l>=u.start&&(o[e]={...o[e],end:u.start})}else if(!a&&e<o.length-1&&l>o[e+1].start){const u=o[e+1];o[e+1]={...u,start:l};let f=e+1;for(;f<o.length-1;){const m=o[f],d=o[f+1];if(m.end>d.start)o[f+1]={...d,start:m.end},f++;else break}}}return o}function I0(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return p.useMemo(()=>t?[no.configure({activationConstraints(a){return a.pointerType==="touch"?[new Ot.Delay({value:n,tolerance:r})]:[new Ot.Distance({value:s})]}})]:[no.configure({activationConstraints:[new Ot.Distance({value:s})]})],[t,n,r,s])}const M0=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=ct(),{selectedTrackId:a}=ut(),o=p.useCallback((l,c,u)=>{const{samplesPerPixel:f}=e,m=t[l];if(!m)return!1;const d=m.clips[c];if(!d)return!1;const h=Math.round(u*n),v=ah(h,f),y=Math.floor(.1*n);if(!pc(d,v,y))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const g=r.current;return g?(g.splitClip(m.id,d.id,v),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:p.useCallback(()=>{if(!a)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(f=>f.id===a);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 m=c.clips[f],d=m.startSample/n,h=(m.startSample+m.durationSamples)/n;if(u>d&&u<h)return o(l,f,u)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,a,o,n]),splitClipAt:o}},Ls=e=>{const{shortcuts:t,enabled:n=!0}=e,r=p.useCallback(s=>{if(!n)return;const a=s.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const o=t.find(i=>{const l=s.key.toLowerCase()===i.key.toLowerCase()||s.key===i.key,c=i.ctrlKey===void 0||s.ctrlKey===i.ctrlKey,u=i.shiftKey===void 0||s.shiftKey===i.shiftKey,f=i.metaKey===void 0||s.metaKey===i.metaKey,m=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&u&&f&&m});o&&(o.preventDefault!==!1&&s.preventDefault(),o.action())},[t,n]);p.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},A0=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("+")},T0=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=ct(),{setCurrentTime:a,play:o,pause:i,stop:l}=Pe(),c=p.useCallback(()=>{s?i():o()},[s,o,i]),u=p.useCallback(()=>{l()},[l]),f=p.useCallback(()=>{a(0),s&&o(0)},[s,a,o]),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 Ls({shortcuts:d,enabled:t}),{rewindToStart:f,togglePlayPause:c,stopPlayback:u,shortcuts:d}},xa=.01,os=.01;function $0({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:a,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:u,onPlay:f}){const m=p.useMemo(()=>t?e.findIndex(I=>I.id===t):-1,[e,t]),d=p.useCallback(I=>{if(!l?.current||!c||!u)return;const E=e.find(q=>q.id===I);if(!E)return;const T=l.current,R=T.clientWidth,A=E.start*u/c,M=E.end*u/c,$=(A+M)/2,F=T.scrollLeft,L=F,z=F+R;if(A<L||M>z){const q=Math.max(0,$-R/2);T.scrollTo({left:q,behavior:"smooth"})}},[e,l,c,u]);p.useEffect(()=>{t&&l?.current&&c&&u&&d(t)},[t,d,l,c,u]);const h=p.useCallback(I=>{if(m<0)return;const E=e[m],T=Math.max(0,Math.min(E.end-.1,E.start+I)),R=T-E.start,A=[...e];if(A[m]={...E,start:T},a&&m>0){const M=A[m-1];Math.abs(M.end-E.start)<xa&&(A[m-1]={...M,end:Math.max(M.start+.1,M.end+R)})}else if(!a&&m>0){const M=A[m-1];T<M.end&&(A[m-1]={...M,end:T})}n(A)},[e,m,a,n]),v=p.useCallback(I=>{if(m<0)return;const E=e[m],T=Math.max(E.start+.1,Math.min(s,E.end+I)),R=T-E.end,A=[...e];if(A[m]={...E,end:T},a&&m<e.length-1){const M=A[m+1];if(Math.abs(M.start-E.end)<xa){const $=Math.min(M.end-.1,M.start+R);A[m+1]={...M,start:$};let F=m+1;for(;F<A.length-1;){const L=A[F],z=A[F+1];if(Math.abs(z.start-e[F].end)<xa){const q=L.end-e[F].end;A[F+1]={...z,start:Math.min(z.end-.1,z.start+q)},F++}else break}}}else if(!a&&m<e.length-1){const M=A[m+1];if(T>M.start){A[m+1]={...M,start:T};let $=m+1;for(;$<A.length-1;){const F=A[$],L=A[$+1];if(F.end>L.start)A[$+1]={...L,start:F.end},$++;else break}}}n(A)},[e,m,s,a,n]),y=p.useCallback(()=>{!r||e.length===0||(m<=0?r(e[e.length-1].id):r(e[m-1].id))},[e,m,r]),g=p.useCallback(()=>{!r||e.length===0||(m<0||m>=e.length-1?r(e[0].id):r(e[m+1].id))},[e,m,r]),b=p.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),w=p.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),_=p.useCallback(()=>{r&&r(null)},[r]),x=p.useCallback(()=>{if(m<0||!f)return;const I=e[m],E=o?void 0:I.end-I.start;f(I.start,E)},[e,m,o,f]),C=p.useMemo(()=>[{key:"[",action:()=>h(-os),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>h(os),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-os),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(os),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:x,description:"Play selected annotation",preventDefault:!0}],[h,v,x]),k=p.useMemo(()=>[{key:"ArrowUp",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:g,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:g,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:_,description:"Deselect annotation",preventDefault:!0}],[y,g,b,w,_]);return Ls({shortcuts:C,enabled:i&&m>=0}),Ls({shortcuts:k,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:h,moveEndBoundary:v,selectPrevious:y,selectNext:g,selectFirst:b,selectLast:w,clearSelection:_,scrollToAnnotation:d,playActiveAnnotation:x}}const Zr=[{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}]}],Si=e=>Zr.find(t=>t.id===e),R0=e=>Zr.filter(t=>t.category===e),D0=[{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 P0={reverb:O.Reverb,freeverb:O.Freeverb,jcReverb:O.JCReverb,feedbackDelay:O.FeedbackDelay,pingPongDelay:O.PingPongDelay,chorus:O.Chorus,phaser:O.Phaser,tremolo:O.Tremolo,vibrato:O.Vibrato,autoPanner:O.AutoPanner,autoFilter:O.AutoFilter,autoWah:O.AutoWah,eq3:O.EQ3,distortion:O.Distortion,bitCrusher:O.BitCrusher,chebyshev:O.Chebyshev,compressor:O.Compressor,limiter:O.Limiter,gate:O.Gate,stereoWidener:O.StereoWidener};let F0=0;const O0=()=>`effect_${Date.now()}_${++F0}`;function $r(e,t){const n=P0[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),a=O0(),o=s;return{effect:s,id:e.id,instanceId:a,dispose(){try{s.disconnect(),s.dispose()}catch(i){console.warn(`[waveform-playlist] Error disposing effect "${e.id}" (${a}):`,i)}},setParameter(i,l){const c=o[i];if(i==="wet"){const u=o.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:o[i]=l)},getParameter(i){if(i==="wet"){const c=o.wet;if(c&&typeof c=="object"&&"value"in c)return c.value}const l=o[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}" (${a}):`,i)}}}}function L0(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 B0(e=256){const[t,n]=p.useState([]),r=p.useRef(t);r.current=t;const s=p.useRef(new Map),a=p.useRef(null),o=p.useRef(null),i=p.useCallback(y=>{const g=o.current;if(!g)return;const{masterGainNode:b,destination:w,analyserNode:_}=g;try{b.disconnect()}catch(C){console.warn("[waveform-playlist] Error disconnecting master effects chain:",C)}const x=y.map(C=>s.current.get(C.instanceId)).filter(C=>C!==void 0);if(x.length===0)b.connect(_),_.connect(w);else{let C=b;x.forEach(k=>{try{k.disconnect()}catch(I){console.warn(`[waveform-playlist] Error disconnecting effect "${k.id}":`,I)}C.connect(k.effect),C=k.effect}),C.connect(_),_.connect(w)}},[]),l=p.useCallback(y=>{const g=Si(y);if(!g){console.error(`Unknown effect: ${y}`);return}const b={};g.parameters.forEach(x=>{b[x.name]=x.default});const w=$r(g,b);s.current.set(w.instanceId,w);const _={instanceId:w.instanceId,effectId:g.id,definition:g,params:b,bypassed:!1};n(x=>[...x,_])},[]),c=p.useCallback(y=>{const g=s.current.get(y);g&&(g.dispose(),s.current.delete(y)),n(b=>b.filter(w=>w.instanceId!==y))},[]),u=p.useCallback((y,g,b)=>{const w=s.current.get(y);w&&w.setParameter(g,b),n(_=>_.map(x=>x.instanceId===y?{...x,params:{...x.params,[g]:b}}:x))},[]),f=p.useCallback(y=>{const g=r.current.find(_=>_.instanceId===y);if(!g)return;const b=!g.bypassed,w=s.current.get(y);if(w){const _=g.params.wet??1;w.setParameter("wet",b?0:_)}n(_=>_.map(x=>x.instanceId===y?{...x,bypassed:b}:x))},[]),m=p.useCallback((y,g)=>{n(b=>{const w=[...b],[_]=w.splice(y,1);return w.splice(g,0,_),w})},[]),d=p.useCallback(()=>{s.current.forEach(y=>y.dispose()),s.current.clear(),n([])},[]);p.useEffect(()=>{i(t)},[t,i]);const h=p.useCallback((y,g,b)=>{const w=new O.Analyser("fft",e);a.current=w,o.current={masterGainNode:y,destination:g,analyserNode:w};const x=r.current.map(C=>s.current.get(C.instanceId)).filter(C=>C!==void 0);if(x.length===0)y.connect(w),w.connect(g);else{let C=y;x.forEach(k=>{C.connect(k.effect),C=k.effect}),C.connect(w),w.connect(g)}return function(){w.dispose(),a.current=null,o.current=null}},[e]);p.useEffect(()=>{const y=s.current;return()=>{y.forEach(g=>g.dispose()),y.clear()}},[]);const v=p.useCallback(()=>{const y=t.filter(g=>!g.bypassed);if(y.length!==0)return(g,b,w)=>{const _=[];for(const x of y){const C=$r(x.definition,x.params);_.push(C)}if(_.length===0)g.connect(b);else{let x=g;_.forEach(C=>{x.connect(C.effect),x=C.effect}),x.connect(b)}return function(){_.forEach(C=>C.dispose())}}},[t]);return{activeEffects:t,availableEffects:Zr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:f,reorderEffects:m,clearAllEffects:d,masterEffects:h,createOfflineEffectsFunction:v,analyserRef:a}}function W0(){const[e,t]=p.useState(new Map),n=p.useRef(new Map),r=p.useRef(new Map),s=p.useCallback((d,h)=>{const v=r.current.get(d);if(!v)return;const{graphEnd:y,masterGainNode:g}=v,b=n.current.get(d);try{y.disconnect()}catch(_){console.warn(`[waveform-playlist] Error disconnecting track "${d}" effect chain:`,_)}const w=h.map(_=>b?.get(_.instanceId)).filter(_=>_!==void 0);if(w.length===0)y.connect(g);else{let _=y;w.forEach(x=>{try{x.disconnect()}catch(C){console.warn(`[waveform-playlist] Error disconnecting effect "${x.id}" on track "${d}":`,C)}_.connect(x.effect),_=x.effect}),_.connect(g)}},[]),a=p.useCallback((d,h)=>{const v=Si(h);if(!v){console.error(`Unknown effect: ${h}`);return}const y={};v.parameters.forEach(w=>{y[w.name]=w.default});const g=$r(v,y);n.current.has(d)||n.current.set(d,new Map),n.current.get(d).set(g.instanceId,g);const b={instanceId:g.instanceId,effectId:v.id,definition:v,params:y,bypassed:!1};t(w=>{const _=new Map(w),x=_.get(d)||[];return _.set(d,[...x,b]),_})},[]),o=p.useCallback((d,h)=>{const v=n.current.get(d),y=v?.get(h);y&&(y.dispose(),v?.delete(h)),t(g=>{const b=new Map(g),w=b.get(d)||[];return b.set(d,w.filter(_=>_.instanceId!==h)),b})},[]),i=p.useCallback((d,h,v,y)=>{const b=n.current.get(d)?.get(h);b&&b.setParameter(v,y),t(w=>{const _=new Map(w),x=_.get(d)||[];return _.set(d,x.map(C=>C.instanceId===h?{...C,params:{...C.params,[v]:y}}:C)),_})},[]),l=p.useCallback((d,h)=>{const y=(u.current.get(d)||[]).find(_=>_.instanceId===h);if(!y)return;const g=!y.bypassed,w=n.current.get(d)?.get(h);if(w){const _=y.params.wet??1;w.setParameter("wet",g?0:_)}t(_=>{const x=new Map(_),C=x.get(d)||[];return x.set(d,C.map(k=>k.instanceId===h?{...k,bypassed:g}:k)),x})},[]),c=p.useCallback(d=>{const h=n.current.get(d);h&&(h.forEach(v=>v.dispose()),h.clear()),t(v=>{const y=new Map(v);return y.set(d,[]),y})},[]),u=p.useRef(e);u.current=e;const f=p.useCallback(d=>(h,v,y)=>{r.current.set(d,{graphEnd:h,masterGainNode:v});const g=u.current.get(d)||[],b=n.current.get(d),w=g.map(_=>b?.get(_.instanceId)).filter(_=>_!==void 0);if(w.length===0)h.connect(v);else{let _=h;w.forEach(x=>{_.connect(x.effect),_=x.effect}),_.connect(v)}return function(){r.current.delete(d)}},[]);p.useEffect(()=>{e.forEach((d,h)=>{s(h,d)})},[e,s]),p.useEffect(()=>{const d=n.current;return()=>{d.forEach(h=>{h.forEach(v=>v.dispose()),h.clear()}),d.clear()}},[]);const m=p.useCallback(d=>{const v=(e.get(d)||[]).filter(y=>!y.bypassed);if(v.length!==0)return(y,g,b)=>{const w=[];for(const _ of v){const x=$r(_.definition,_.params);w.push(x)}if(w.length===0)y.connect(g);else{let _=y;w.forEach(x=>{_.connect(x.effect),_=x.effect}),_.connect(g)}return function(){w.forEach(x=>x.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:a,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:f,createOfflineTrackEffectsFunction:m,availableEffects:Zr}}function V0(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,s=e.sampleRate,a=e.length,o=n/8,i=r*o,l=s*i,c=a*i,u=44,f=u+c,m=new ArrayBuffer(f),d=new DataView(m);is(d,0,"RIFF"),d.setUint32(4,f-8,!0),is(d,8,"WAVE"),is(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),is(d,36,"data"),d.setUint32(40,c,!0);const h=[];for(let y=0;y<r;y++)h.push(e.getChannelData(y));let v=u;if(n===16)for(let y=0;y<a;y++)for(let g=0;g<r;g++){const b=h[g][y],w=Math.max(-1,Math.min(1,b)),_=w<0?w*32768:w*32767;d.setInt16(v,_,!0),v+=2}else for(let y=0;y<a;y++)for(let g=0;g<r;g++)d.setFloat32(v,h[g][y],!0),v+=4;return new Blob([m],{type:"audio/wav"})}function is(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function N0(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 ef(){const[e,t]=p.useState(!1),[n,r]=p.useState(0),[s,a]=p.useState(null);return{exportWav:p.useCallback(async(i,l,c={})=>{const{filename:u="export",mode:f="master",trackIndex:m,autoDownload:d=!0,applyEffects:h=!0,effectsFunction:v,createOfflineTrackEffects:y,bitDepth:g=16,onProgress:b}=c;t(!0),r(0),a(null);try{if(i.length===0)throw new Error("No tracks to export");if(f==="individual"&&(m===void 0||m<0||m>=i.length))throw new Error("Invalid track index for individual export");const w=i[0].clips[0]?.sampleRate||44100;let _=0;for(const R of i)for(const A of R.clips){const M=A.startSample+A.durationSamples;_=Math.max(_,M)}_+=Math.round(w*.1);const x=_/w,C=f==="individual"?[{track:i[m],state:l[m],index:m}]:i.map((R,A)=>({track:R,state:l[A],index:A})),k=l.some(R=>R.soloed),I=!!y;let E;if((v||I)&&h)E=await z0(C,l,k,x,w,v,y,R=>{r(R),b?.(R)});else{const R=new OfflineAudioContext(2,_,w);let A=0;const M=C.reduce(($,{track:F})=>$+F.clips.length,0);for(const{track:$,state:F}of C)if(!(F.muted&&!F.soloed)&&!(k&&!F.soloed))for(const L of $.clips){await Z0(R,L,F,w,h),A++;const z=A/M*.5;r(z),b?.(z)}r(.5),b?.(.5),E=await R.startRendering()}r(.9),b?.(.9);const T=V0(E,{bitDepth:g});if(r(1),b?.(1),d){const R=f==="individual"?`${u}_${i[m].name}`:u;N0(T,`${R}.wav`)}return{audioBuffer:E,blob:T,duration:x}}catch(w){const _=w instanceof Error?w.message:"Export failed";throw a(_),w}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function z0(e,t,n,r,s,a,o,i){const{Offline:l,Volume:c,Gain:u,Panner:f,Player:m,ToneAudioBuffer:d}=await import("tone");i(.1);let h;try{h=await l(async({transport:v,destination:y})=>{const g=new c(0);let b;a?b=a(g,y,!0):g.connect(y);for(const{track:w,state:_}of e){if(_.muted&&!_.soloed||n&&!_.soloed)continue;const x=new c(j0(_.volume)),C=new f(_.pan),k=new u(_.muted?0:1),I=o?.(w.id);I?I(k,g,!0):k.connect(g),C.connect(k),x.connect(C);for(const E of w.clips){const{audioBuffer:T,startSample:R,durationSamples:A,offsetSamples:M,gain:$,fadeIn:F,fadeOut:L}=E,z=R/s,q=A/s,Y=M/s,ne=new d(T),G=new m(ne),J=new u($);if(G.connect(J),J.connect(x),F){const ae=z,ue=z+F.duration,de=xr(J.gain);de&&(de.setValueAtTime(0,ae),de.linearRampToValueAtTime($,ue))}if(L){const ae=z+q-L.duration,ue=z+q,de=xr(J.gain);de&&(de.setValueAtTime($,ae),de.linearRampToValueAtTime(0,ue))}G.start(z,Y,q)}}v.start(0)},r,2,s)}catch(v){throw v instanceof Error?v:new Error(`Tone.Offline rendering failed: ${String(v)}`)}return i(.9),h.get()}function j0(e){return 20*Math.log10(Math.max(e,1e-4))}async function Z0(e,t,n,r,s){const{audioBuffer:a,startSample:o,durationSamples:i,offsetSamples:l,gain:c,fadeIn:u,fadeOut:f}=t;if(!a){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const m=o/r,d=i/r,h=l/r,v=e.createBufferSource();v.buffer=a;const y=e.createGain(),g=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,v.connect(y),y.connect(b),b.connect(e.destination),s){if(u?y.gain.setValueAtTime(0,m):y.gain.setValueAtTime(g,m),u){const w=m,_=m+u.duration;Kl(y.gain,w,_,0,g,u.type||"linear")}if(f){const w=m+d-f.duration,_=m+d;(!u||u.duration<d-f.duration)&&y.gain.setValueAtTime(g,w),Kl(y.gain,w,_,g,0,f.type||"linear")}}else y.gain.setValueAtTime(g,m);v.start(m,h,d)}function Kl(e,t,n,r,s,a){const o=n-t;if(!(o<=0))switch(a){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=ql(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=ql(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function ql(e,t,n,r){const s=new Float32Array(n),a=t-e;for(let o=0;o<n;o++){const i=o/(n-1);let l;r==="logarithmic"?a>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[o]=e+a*l}return s}const tf=()=>{const e=p.useRef(null),t=p.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=p.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return p.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},H0=`
|
|
863
858
|
"use strict";
|
|
864
859
|
|
|
865
860
|
var INT8_MAX = 127;
|
|
@@ -1006,13 +1001,13 @@ self.onmessage = function(e) {
|
|
|
1006
1001
|
self.postMessage({ id: msg.id, error: err.message || String(err) });
|
|
1007
1002
|
}
|
|
1008
1003
|
};
|
|
1009
|
-
`;let T0=0;function $0(){let e;try{const r=new Blob([A0],{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=mt.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(++T0);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 R0(e,t){const[n,r]=g.useState(()=>new Map),[s,o]=g.useState(!1),a=g.useRef(null),i=g.useRef(new WeakMap),l=g.useRef(new WeakMap),c=g.useRef(new WeakMap),u=g.useRef(0),f=g.useCallback(()=>(a.current||(a.current=$0()),a.current),[]);return g.useEffect(()=>{let h=!1;const d=i.current,p=l.current,v=c.current,y=[],m=new Map;for(const _ of e)for(const w of _.clips){if(!w.audioBuffer||w.waveformData)continue;const x=d.get(w.audioBuffer);if(x){y.push({clipId:w.id,waveformData:x});continue}if(p.get(w.audioBuffer)){const k=v.get(w.audioBuffer);k?k.add(w.id):v.set(w.audioBuffer,new Set([w.id]));continue}const S=m.get(w.audioBuffer);S?S.add(w.id):m.set(w.audioBuffer,new Set([w.id]))}if(y.length>0&&r(_=>{const w=new Map(_);for(const x of y)w.set(x.clipId,x.waveformData);return w}),m.size===0)return;u.current+=m.size,o(!0);const b=f();for(const[_,w]of m){v.set(_,new Set(w));const x=[];for(let E=0;E<_.numberOfChannels;E++)x.push(_.getChannelData(E).slice().buffer);const S=`buffer-${Math.random().toString(36).slice(2,11)}`,k=b.generate({id:S,channels:x,length:_.length,sampleRate:_.sampleRate,scale:t,bits:16,splitChannels:!0}).then(E=>{d.set(_,E);const T=v.get(_)??new Set;v.delete(_),p.delete(_),!h&&(r(I=>{const M=new Map(I);for(const $ of T)M.set($,E);return M}),u.current--,u.current<=0&&(u.current=0,o(!1)))}).catch(E=>{v.delete(_),p.delete(_),!h&&(console.warn("[waveform-playlist] Worker peak generation failed:",E),u.current--,u.current<=0&&(u.current=0,o(!1)))});p.set(_,k)}return()=>{h=!0,l.current=new WeakMap,c.current=new WeakMap,u.current=0,o(!1)}},[e,t,f]),g.useEffect(()=>()=>{a.current?.terminate(),a.current=null},[]),{cache:n,isGenerating:s}}function aa(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 D0(e,t,n){const r=aa(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 P0(){const[e,t]=g.useState([]),[n,r]=g.useState(0),[s,o]=g.useState([]),a=g.useRef(!1),i=g.useRef(new Set),l=g.useRef(new Map);g.useEffect(()=>{const f=l.current;return()=>{a.current=!0;for(const h of f.values())h.abort();f.clear()}},[]);const c=g.useCallback(f=>{if(f.length===0)return;const h=Zf(),d=f.map(p=>({track:Ql({name:`${aa(p)} (loading...)`,clips:[]}),source:p}));t(p=>[...p,...d.map(v=>v.track)]),r(p=>p+f.length);for(const{track:p,source:v}of d){i.current.add(p.id);const y=new AbortController;l.current.set(p.id,y),(async()=>{try{const{audioBuffer:m,name:b}=await D0(v,h,y.signal),_=Jl({audioBuffer:m,startTime:0,duration:m.duration,offset:0,name:b});!a.current&&i.current.has(p.id)&&t(w=>w.map(x=>x.id===p.id?{...x,name:b,clips:[_]}:x))}catch(m){if(m instanceof DOMException&&m.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",m),!a.current&&i.current.has(p.id)&&(t(b=>b.filter(_=>_.id!==p.id)),o(b=>[...b,{name:aa(v),error:m instanceof Error?m:new Error(String(m))}]))}finally{l.current.delete(p.id),!a.current&&i.current.delete(p.id)&&r(m=>m-1)}})()}},[]),u=g.useCallback(f=>{t(d=>d.filter(p=>p.id!==f));const h=l.current.get(f);h&&(h.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}}const Gd=g.createContext(null),Ud=g.createContext(null),Xd=g.createContext(null),Yd=g.createContext(null),F0=({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:h,onAnnotationsChange:d,barWidth:p=1,barGap:v=0,progressBarWidth:y,onTracksChange:m,soundFontCache:b,children:_})=>{const w=y??p+v,x=g.useMemo(()=>o,[o?.join(",")]),S=g.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]),k=g.useRef(S);k.current=S;const[E,T]=g.useState(null),[I,M]=g.useState(!1),[$,A]=g.useState(0),[R,W]=g.useState(0),[q,z]=g.useState([]),[J,ee]=g.useState([]),[j,se]=g.useState([]),[U,ie]=g.useState(a),[le,ge]=g.useState(c?.isContinuousPlay??!1),[Se,N]=g.useState(c?.linkEndpoints??!1),[G,ye]=g.useState(c?.editable??!1),[Z,Q]=g.useState(!1),O=g.useRef(null),_e=g.useRef(!1),Ne=g.useRef(!1);Ne.current=I;const Be=g.useRef(0),ve=g.useRef(0),Ve=g.useRef(e),ne=g.useRef(b);ne.current=b;const Ge=g.useRef(j),je=g.useRef(0),xe=g.useRef(0),Fe=g.useRef(null),Oe=g.useRef(null),Et=g.useRef(!1),It=g.useRef(c?.isContinuousPlay??!1),Mt=g.useRef(null),X=g.useRef(null),fe=g.useRef(0),Ue=g.useRef(!1),Me=g.useRef(!1),oe=g.useRef(s),he=g.useRef(44100),{timeFormat:Xe,setTimeFormat:At,formatTime:Tt}=Vd(),ut=Nd({engineRef:O,initialSamplesPerPixel:s}),{samplesPerPixel:yt,onEngineState:V}=ut,Y=zd({engineRef:O,initialVolume:1}),{masterVolume:K,setMasterVolume:ce,masterVolumeRef:Ae,onEngineState:Ze}=Y,{selectionStart:te,selectionEnd:Ke,setSelection:Qe,selectionStartRef:Te,selectionEndRef:dt,onEngineState:Lt}=s0({engineRef:O}),{isLoopEnabled:rn,loopStart:sn,loopEnd:Ht,setLoopEnabled:qn,setLoopRegion:kn,clearLoopRegion:Hr,isLoopEnabledRef:xi,loopStartRef:Ci,loopEndRef:Si,onEngineState:ki}=o0({engineRef:O}),{selectedTrackId:Ei,setSelectedTrackId:Ii,onEngineState:Mi,selectedTrackIdRef:Ai}=a0({engineRef:O}),{animationFrameRef:Ti,startAnimationFrameLoop:Js,stopAnimationFrameLoop:Gr}=Hd(),bf=g.useMemo(()=>Math.min(...x??[256,512,1024,2048,4096,8192]),[x]),{cache:$i}=R0(e,bf),Ri=g.useCallback(L=>{It.current=L,ge(L)},[]),Wt=g.useCallback(L=>{Mt.current=L,T(L)},[]),Di=g.useCallback(()=>{const L=Te.current??0,H=dt.current??0;L!==H&&H>L&&kn(L,H)},[kn,Te,dt]);g.useEffect(()=>{Et.current=U},[U]),g.useEffect(()=>{Ge.current=j},[j]),Ve.current=e;const Qs=e===X.current;Ue.current=Qs||Me.current,g.useEffect(()=>{if(!Oe.current||R===0)return;const L=Oe.current,H=oe.current,pe=yt;if(H===pe)return;const B=L.clientWidth,Ee=L.scrollLeft+B/2,et=he.current,ro=Ee*H/et*et/pe,so=Math.max(0,ro-B/2);L.scrollLeft=so,oe.current=pe},[yt,R]);const Ur=g.useRef(null);g.useEffect(()=>{if(Qs||Me.current){Qs&&(X.current=null);let B=0;e.forEach($e=>{$e.clips.forEach(Ee=>{const et=(Ee.startSample+Ee.durationSamples)/Ee.sampleRate;B=Math.max(B,et)})}),W(B);return}if(Q(!1),e.length===0){z([]),W(0),se([]),ee([]),O.current&&(O.current.dispose(),O.current=null);return}const L=Ne.current,H=ve.current;return O.current&&L&&(O.current.stop(),Gr(),Ur.current={position:H}),(async()=>{try{const B=performance.now(),$e=[];e.forEach(ke=>{ke.clips.length>0&&ke.clips[0].audioBuffer&&$e.push(ke.clips[0].audioBuffer)});let Ee=0;e.forEach(ke=>{ke.clips.forEach(ht=>{const Gt=ht.sampleRate,Ef=(ht.startSample+ht.durationSamples)/Gt;Ee=Math.max(Ee,Ef)})}),z($e),W(Ee),se(ke=>ke.length===e.length?ke.map((ht,Gt)=>({...ht,name:e[Gt].name})):e.map(ht=>({name:ht.name,muted:ht.muted,soloed:ht.soloed,volume:ht.volume,pan:ht.pan}))),O.current&&O.current.dispose(),fe.current=0,X.current=null,_e.current=!1;const et=Hf({effects:u,soundFontCache:ne.current}),bt=new Jf({adapter:et,samplesPerPixel:oe.current,zoomLevels:x});bt.setSelection(Te.current??0,dt.current??0),bt.setLoopRegion(Ci.current??0,Si.current??0),xi.current&&bt.setLoopEnabled(!0),bt.setMasterVolume(Ae.current??1),Ai.current&&bt.selectTrack(Ai.current);const ro=Ge.current,so=e.map((ke,ht)=>{const Gt=ro[ht];return{...ke,volume:Gt?.volume??ke.volume,muted:Gt?.muted??ke.muted,soloed:Gt?.soloed??ke.soloed,pan:Gt?.pan??ke.pan}});let Xi=!0;bt.on("statechange",ke=>{Lt(ke),ki(ke),Mi(ke),V(ke),Ze(ke),!Xi&&ke.tracksVersion!==fe.current&&(fe.current=ke.tracksVersion,X.current=ke.tracks,m?m(ke.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),bt.setTracks(so),Xi=!1,fe.current=bt.getState().tracksVersion,O.current=bt,Q(!0),console.log(`[engine] rebuild: ${e.length} tracks, ${(performance.now()-B).toFixed(1)}ms`);const kf=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:Ee}});window.dispatchEvent(kf),f?.()}catch(B){console.error("Error loading audio:",B)}})(),()=>{if(Ue.current){Ue.current=!1;return}Gr(),O.current&&O.current.dispose()}},[e,f,u,Gr,Lt,ki,Mi,V,Ze,m,Ae,Te,dt,Ci,Si,xi,x,b]),g.useEffect(()=>{if(e.length===0)return;const L=e.map(H=>H.clips.map(B=>{let $e;if(B.waveformData)try{$e=zl(B.waveformData,yt,n,B.offsetSamples,B.durationSamples)}catch(Ee){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",Ee)}if(!$e){const Ee=$i.get(B.id);if(Ee)try{$e=zl(Ee,yt,n,B.offsetSamples,B.durationSamples)}catch(et){console.warn("[waveform-playlist] Failed to extract peaks from cache:",et)}}if(!$e){!B.audioBuffer&&!B.waveformData&&!B.midiNotes&&console.warn(`[waveform-playlist] Clip "${B.id}" has no audio data or waveform data`);const Ee=n?1:B.audioBuffer?.numberOfChannels??1,et=B.midiNotes?Math.ceil(B.durationSamples/yt):0;$e={length:et,data:Array.from({length:Ee},()=>new Int16Array(et*2)),bits:16}}return{clipId:B.id,trackName:H.name,peaks:$e,startSample:B.startSample,durationSamples:B.durationSamples,fadeIn:B.fadeIn,fadeOut:B.fadeOut,midiNotes:B.midiNotes,sampleRate:B.sampleRate,offsetSamples:B.offsetSamples}}));ee(L)},[e,yt,n,$i]);const Pi=g.useRef(!1),En=g.useCallback(()=>{if(O.current)return O.current.getCurrentTime();Pi.current||(Pi.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const L=F.getContext().currentTime-(je.current??0);return(xe.current??0)+L},[]),on=g.useCallback(()=>{const L=()=>{const H=En();ve.current=H;const pe=k.current;if(pe.length>0){const B=pe.find($e=>H>=$e.start&&H<$e.end);if(It.current)B&&B.id!==Mt.current?Wt(B.id):!B&&Mt.current!==null&&Wt(null);else if(Mt.current){const $e=pe.find(Ee=>Ee.id===Mt.current);if($e&&H>=$e.end){O.current&&O.current.stop(),M(!1),ve.current=Be.current,A(Be.current);return}}else B&&Wt(B.id)}if(Et.current&&Oe.current&&R>0){const B=Oe.current,$e=he.current,Ee=H*$e/oe.current,et=B.clientWidth,bt=Math.max(0,Ee-et/2);B.scrollLeft=bt}if(Fe.current!==null&&H>=Fe.current){O.current&&O.current.stop(),M(!1),ve.current=Fe.current,A(Fe.current),Fe.current=null;return}if(H>=R){O.current&&O.current.stop(),M(!1),ve.current=Be.current,A(Be.current),Wt(null);return}Js(L)};Js(L)},[R,Wt,Js,En]),ft=Gr;g.useEffect(()=>{(async()=>{if(I&&Ti.current&&O.current)if(le){const H=ve.current;O.current.stop(),ft();const B=F.getContext().currentTime;je.current=B,xe.current=H,O.current.play(H),on()}else ft(),on()})().catch(H=>{console.warn("[waveform-playlist] Failed to reschedule playback:",H),M(!1),ft()})},[le,I,on,ft,Ti]),g.useEffect(()=>{(async()=>{if(Ur.current&&O.current){const{position:H}=Ur.current;Ur.current=null;const B=F.getContext().currentTime;je.current=B,xe.current=H,_e.current||(await O.current.init(),_e.current=!0),O.current.play(H),M(!0),on()}})().catch(H=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",H),M(!1),ft()})},[e,on,ft]);const Xr=g.useCallback(async(L,H)=>{if(!O.current||R===0)return;const pe=L??ve.current;Be.current=pe,ve.current=pe,O.current.stop(),O.current.seek(pe),ft();const $e=F.getContext().currentTime;je.current=$e,xe.current=pe,Fe.current=H!==void 0?pe+H:null,_e.current||(await O.current.init(),_e.current=!0);const Ee=H!==void 0?pe+H:void 0;try{O.current.play(pe,Ee)}catch(et){console.warn("[waveform-playlist] Playback failed to start:",et),ft();return}M(!0),on()},[R,on,ft]),Fi=g.useCallback(()=>{if(!O.current)return;const L=En();O.current.pause(),M(!1),ft(),ve.current=L,A(L)},[ft,En]),Oi=g.useCallback(()=>{O.current&&(O.current.stop(),M(!1),ft(),ve.current=Be.current,A(Be.current),Wt(null))},[ft,Wt]),Li=g.useCallback(L=>{const H=Math.max(0,Math.min(L,R));ve.current=H,A(H),I&&O.current&&Xr(H)},[R,I,Xr]),Wi=g.useCallback((L,H)=>{const pe=Ve.current[L]?.id;if(!pe)return;const B=[...j];B[L]={...B[L],muted:H},se(B),O.current&&O.current.setTrackMute(pe,H)},[j]),Bi=g.useCallback((L,H)=>{const pe=Ve.current[L]?.id;if(!pe)return;const B=[...j];B[L]={...B[L],soloed:H},se(B),O.current&&O.current.setTrackSolo(pe,H)},[j]),Vi=g.useCallback((L,H)=>{const pe=Ve.current[L]?.id;if(!pe)return;const B=[...j];B[L]={...B[L],volume:H},se(B),O.current&&O.current.setTrackVolume(pe,H)},[j]),Ni=g.useCallback((L,H)=>{const pe=Ve.current[L]?.id;if(!pe)return;const B=[...j];B[L]={...B[L],pan:H},se(B),O.current&&O.current.setTrackPan(pe,H)},[j]),zi=g.useCallback((L,H)=>{Qe(L,H),ve.current=L,A(L),I&&O.current&&(O.current.stop(),O.current.seek(L),O.current.play(L))},[I,Qe]),ji=g.useCallback(L=>{Oe.current=L},[]),eo=g.useRef(d);eo.current=d;const Zi=g.useCallback(L=>{const H=typeof L=="function"?L(k.current):L;if(!eo.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}eo.current(H)},[]),to=q[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;he.current=to;const no=t?30:0,Hi=e.length*r+no,wf=g.useMemo(()=>({isPlaying:I,currentTime:$,currentTimeRef:ve,playbackStartTimeRef:je,audioStartPositionRef:xe,getPlaybackTime:En}),[I,$,ve,je,xe,En]),_f=g.useMemo(()=>({continuousPlay:le,linkEndpoints:Se,annotationsEditable:G,isAutomaticScroll:U,isLoopEnabled:rn,annotations:S,activeAnnotationId:E,selectionStart:te,selectionEnd:Ke,selectedTrackId:Ei,loopStart:sn,loopEnd:Ht}),[le,Se,G,U,rn,S,E,te,Ke,Ei,sn,Ht]),Gi=g.useCallback(L=>{ve.current=L,A(L)},[ve]),Ui=g.useCallback(L=>{ie(L)},[]),xf=g.useMemo(()=>({play:Xr,pause:Fi,stop:Oi,seekTo:Li,setCurrentTime:Gi,setTrackMute:Wi,setTrackSolo:Bi,setTrackVolume:Vi,setTrackPan:Ni,setSelection:zi,setSelectedTrackId:Ii,setTimeFormat:At,formatTime:Tt,zoomIn:ut.zoomIn,zoomOut:ut.zoomOut,setMasterVolume:ce,setAutomaticScroll:Ui,setScrollContainer:ji,scrollContainerRef:Oe,setContinuousPlay:Ri,setLinkEndpoints:N,setAnnotationsEditable:ye,setAnnotations:Zi,setActiveAnnotationId:Wt,setLoopEnabled:qn,setLoopRegion:kn,setLoopRegionFromSelection:Di,clearLoopRegion:Hr}),[Xr,Fi,Oi,Li,Gi,Wi,Bi,Vi,Ni,zi,Ii,At,Tt,ut.zoomIn,ut.zoomOut,ce,Ui,ji,Oe,Ri,N,ye,Zi,Wt,qn,kn,Di,Hr]),Cf=g.useMemo(()=>({duration:R,audioBuffers:q,peaksDataArray:J,trackStates:j,tracks:e,sampleRate:to,waveHeight:r,timeScaleHeight:no,minimumPlaylistHeight:Hi,controls:l,playoutRef:O,samplesPerPixel:yt,timeFormat:Xe,masterVolume:K,canZoomIn:ut.canZoomIn,canZoomOut:ut.canZoomOut,barWidth:p,barGap:v,progressBarWidth:w,isReady:Z,mono:n,isDraggingRef:Me}),[R,q,J,j,e,to,r,no,Hi,l,O,yt,Xe,K,ut.canZoomIn,ut.canZoomOut,p,v,w,Z,n,Me]),Sf={...kd,...i};return C.jsx(P.ThemeProvider,{theme:Sf,children:C.jsx(Gd.Provider,{value:wf,children:C.jsx(Ud.Provider,{value:_f,children:C.jsx(Xd.Provider,{value:xf,children:C.jsx(Yd.Provider,{value:Cf,children:_})})})})})},lt=()=>{const e=g.useContext(Gd);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},ct=()=>{const e=g.useContext(Ud);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Pe=()=>{const e=g.useContext(Xd);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},vt=()=>{const e=g.useContext(Yd);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var O0=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}},L0=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 O0({...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 Kd=g.createContext(null),qd=g.createContext(null),Jd=g.createContext(null),Qd=g.createContext(null),W0=({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:h,onReady:d,children:p})=>{const v=f??c+u,[y,m]=g.useState(!1),[b,_]=g.useState(0),[w,x]=g.useState(0),[S,k]=g.useState([]),[E,T]=g.useState(s),I=g.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const X=l.annotations[0];if(typeof X.start!="number"||typeof X.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 X.start),[]}return l.annotations},[l?.annotations]),M=g.useRef(I);M.current=I;const[$,A]=g.useState(null),[R,W]=g.useState(l?.isContinuousPlay??!1),[q]=g.useState(t),[z,J]=g.useState(o),ee=g.useRef(null),j=g.useRef(0),se=g.useRef(R),U=g.useRef(null),ie=g.useRef(null),le=g.useRef(o),ge=g.useRef(t),{startAnimationFrameLoop:Se,stopAnimationFrameLoop:N}=Hd();g.useEffect(()=>{se.current=R},[R]),g.useEffect(()=>{le.current=z},[z]);const G=g.useCallback(X=>{U.current=X,A(X)},[]),ye=g.useCallback(X=>{se.current=X,W(X)},[]),Z=g.useCallback(X=>{ie.current=X},[]),Q=e.waveformData.sample_rate;g.useEffect(()=>{const X=new L0({playbackRate:s});X.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const fe=X.getTrack(X.track?.id??"");return fe&&fe.setOnTimeUpdateCallback(Ue=>{j.current=Ue}),X.setOnPlaybackComplete(()=>{N(),m(!1),G(null),j.current=0,_(0)}),ee.current=X,x(e.waveformData.duration),d?.(),()=>{N(),X.dispose()}},[e.source,e.waveformData,e.name,s,d,N,G]),g.useEffect(()=>{try{const X=r0(e.waveformData,q,0,0,Math.ceil(e.waveformData.duration*Q)),fe={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:X.length,data:[X.data],bits:X.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*Q)};k([[fe]])}catch(X){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",X)}},[e.waveformData,e.name,q,Q]);const O=g.useCallback(()=>{const X=()=>{const fe=ee.current?.getCurrentTime()??0;j.current=fe;const Ue=M.current;if(Ue.length>0){const Me=Ue.find(oe=>fe>=oe.start&&fe<oe.end);if(se.current)Me&&Me.id!==U.current?G(Me.id):!Me&&U.current!==null&&G(null);else if(U.current){const oe=Ue.find(he=>he.id===U.current);if(oe&&fe>=oe.end){ee.current?.stop(),m(!1);return}}else Me&&G(Me.id)}if(le.current&&ie.current){const Me=ie.current,oe=fe*Q/ge.current,he=Me.clientWidth,Xe=Math.max(0,oe-he/2);Me.scrollLeft=Xe}Se(X)};Se(X)},[G,Q,Se]),_e=N,Ne=g.useCallback(X=>{if(!ee.current)return;const fe=X??j.current;ee.current.play(void 0,fe),m(!0),O()},[O]),Be=g.useCallback(()=>{ee.current&&(ee.current.pause(),m(!1),_e(),_(ee.current.getCurrentTime()))},[_e]),ve=g.useCallback(()=>{ee.current&&(ee.current.stop(),m(!1),_e(),j.current=0,_(0),G(null))},[_e,G]),Ve=g.useCallback(X=>{const fe=Math.max(0,Math.min(X,w));j.current=fe,_(fe),ee.current&&ee.current.seekTo(fe)},[w]),ne=g.useCallback(X=>{const fe=Math.max(.5,Math.min(2,X));T(fe),ee.current&&ee.current.setPlaybackRate(fe)},[]),Ge=r?30:0,je=g.useMemo(()=>({isPlaying:y,currentTime:b,currentTimeRef:j}),[y,b]),xe=g.useMemo(()=>({continuousPlay:R,annotations:I,activeAnnotationId:$,playbackRate:E,isAutomaticScroll:z}),[R,I,$,E,z]),Fe=g.useRef(h);Fe.current=h;const Oe=g.useCallback(X=>{const fe=typeof X=="function"?X(M.current):X;if(!Fe.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}Fe.current(fe)},[]),Et=g.useMemo(()=>({play:Ne,pause:Be,stop:ve,seekTo:Ve,setPlaybackRate:ne,setContinuousPlay:ye,setAnnotations:Oe,setActiveAnnotationId:G,setAutomaticScroll:X=>{J(X)},setScrollContainer:Z,scrollContainerRef:ie}),[Ne,Be,ve,Ve,ne,ye,Oe,G,Z]),It=g.useMemo(()=>({duration:w,peaksDataArray:S,sampleRate:Q,waveHeight:n,timeScaleHeight:Ge,samplesPerPixel:q,playoutRef:ee,controls:i,barWidth:c,barGap:u,progressBarWidth:v}),[w,S,Q,n,Ge,q,i,c,u,v]),Mt={...kd,...a};return C.jsx(P.ThemeProvider,{theme:Mt,children:C.jsx(Kd.Provider,{value:je,children:C.jsx(qd.Provider,{value:xe,children:C.jsx(Jd.Provider,{value:Et,children:C.jsx(Qd.Provider,{value:It,children:p})})})})})},Us=()=>{const e=g.useContext(Kd);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},Xs=()=>{const e=g.useContext(qd);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},bi=()=>{const e=g.useContext(Jd);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},Ys=()=>{const e=g.useContext(Qd);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},B0=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=lt(),{selectionStart:r,selectionEnd:s,isLoopEnabled:o}=ct(),{play:a}=Pe(),i=async()=>{if(r!==s&&s>r&&!o){const c=s-r;await a(r,c)}else await a(n.current??0)};return C.jsx(kt,{onClick:i,disabled:t,className:e,children:"Play"})},V0=({className:e})=>{const{isPlaying:t}=lt(),{pause:n}=Pe();return C.jsx(kt,{onClick:n,disabled:!t,className:e,children:"Pause"})},N0=({className:e})=>{const{isPlaying:t}=lt(),{stop:n}=Pe();return C.jsx(kt,{onClick:n,disabled:!t,className:e,children:"Stop"})},z0=({className:e})=>{const{isPlaying:t}=lt(),{play:n,setCurrentTime:r}=Pe(),s=()=>{r(0),t&&n(0)};return C.jsx(kt,{onClick:s,className:e,children:"Rewind"})},j0=({className:e})=>{const{isPlaying:t}=lt(),{play:n,setCurrentTime:r}=Pe(),{duration:s}=vt(),o=()=>{r(s),t&&n(s)};return C.jsx(kt,{onClick:o,className:e,children:"Fast Forward"})},Z0=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=lt(),{play:s,setCurrentTime:o}=Pe(),a=()=>{const i=Math.max(0,(n.current??0)-e);o(i),r&&s(i)};return C.jsx(kt,{onClick:a,className:t,children:"Skip Backward"})},H0=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=lt(),{play:s,setCurrentTime:o}=Pe(),{duration:a}=vt(),i=()=>{const l=Math.min(a,(n.current??0)+e);o(l),r&&s(l)};return C.jsx(kt,{onClick:i,className:t,children:"Skip Forward"})},G0=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=ct(),{setLoopEnabled:s,setLoopRegion:o}=Pe(),{duration:a}=vt(),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 C.jsx(kt,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},U0=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=ct(),{setLoopRegionFromSelection:o,clearLoopRegion:a}=Pe(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?a():o()};return C.jsx(kt,{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"})},X0=({className:e,disabled:t})=>{const{zoomIn:n}=Pe(),{canZoomIn:r}=vt();return C.jsx(kt,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},Y0=({className:e,disabled:t})=>{const{zoomOut:n}=Pe(),{canZoomOut:r}=vt();return C.jsx(kt,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},K0=({className:e})=>{const{masterVolume:t}=vt(),{setMasterVolume:n}=Pe();return C.jsx(Og,{volume:t,onChange:n,className:e})},q0=({className:e})=>{const{timeFormat:t}=vt(),{setTimeFormat:n}=Pe();return C.jsx(Cv,{value:t,onChange:n,className:e})},J0=P.span`
|
|
1004
|
+
`;let G0=0;function U0(){let e;try{const r=new Blob([H0],{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,a=t.get(s.id);if(a)if(t.delete(s.id),s.error)a.reject(new Error(s.error));else try{const o=gt.create(s.buffer);a.resolve(o)}catch(o){a.reject(o)}},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(++G0);return new Promise((a,o)=>{t.set(s,{resolve:a,reject:o}),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 X0(e,t){const[n,r]=p.useState(()=>new Map),[s,a]=p.useState(!1),o=p.useRef(null),i=p.useRef(new WeakMap),l=p.useRef(new WeakMap),c=p.useRef(new WeakMap),u=p.useRef(0),f=p.useCallback(()=>(o.current||(o.current=U0()),o.current),[]);return p.useEffect(()=>{let m=!1;const d=i.current,h=l.current,v=c.current,y=[],g=new Map;for(const w of e)for(const _ of w.clips){if(!_.audioBuffer||_.waveformData)continue;const x=d.get(_.audioBuffer);if(x){y.push({clipId:_.id,waveformData:x});continue}if(h.get(_.audioBuffer)){const k=v.get(_.audioBuffer);k?k.add(_.id):v.set(_.audioBuffer,new Set([_.id]));continue}const C=g.get(_.audioBuffer);C?C.add(_.id):g.set(_.audioBuffer,new Set([_.id]))}if(y.length>0&&r(w=>{const _=new Map(w);for(const x of y)_.set(x.clipId,x.waveformData);return _}),g.size===0)return;u.current+=g.size,a(!0);const b=f();for(const[w,_]of g){v.set(w,new Set(_));const x=[];for(let I=0;I<w.numberOfChannels;I++)x.push(w.getChannelData(I).slice().buffer);const C=`buffer-${Math.random().toString(36).slice(2,11)}`,k=b.generate({id:C,channels:x,length:w.length,sampleRate:w.sampleRate,scale:t,bits:16,splitChannels:!0}).then(I=>{d.set(w,I);const E=v.get(w)??new Set;v.delete(w),h.delete(w),!m&&(r(T=>{const R=new Map(T);for(const A of E)R.set(A,I);return R}),u.current--,u.current<=0&&(u.current=0,a(!1)))}).catch(I=>{v.delete(w),h.delete(w),!m&&(console.warn("[waveform-playlist] Worker peak generation failed:",I),u.current--,u.current<=0&&(u.current=0,a(!1)))});h.set(w,k)}return()=>{m=!0,l.current=new WeakMap,c.current=new WeakMap,u.current=0,a(!1)}},[e,t,f]),p.useEffect(()=>()=>{o.current?.terminate(),o.current=null},[]),{cache:n,isGenerating:s}}function lo(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 Y0(e,t,n){const r=lo(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,a=await fetch(s,{signal:n});if(!a.ok)throw new Error(`Failed to fetch ${s}: ${a.statusText}`);const o=await a.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(o),name:r}}function K0(){const[e,t]=p.useState([]),[n,r]=p.useState(0),[s,a]=p.useState([]),o=p.useRef(!1),i=p.useRef(new Set),l=p.useRef(new Map);p.useEffect(()=>{const f=l.current;return()=>{o.current=!0;for(const m of f.values())m.abort();f.clear()}},[]);const c=p.useCallback(f=>{if(f.length===0)return;const m=rh(),d=f.map(h=>({track:oc({name:`${lo(h)} (loading...)`,clips:[]}),source:h}));t(h=>[...h,...d.map(v=>v.track)]),r(h=>h+f.length);for(const{track:h,source:v}of d){i.current.add(h.id);const y=new AbortController;l.current.set(h.id,y),(async()=>{try{const{audioBuffer:g,name:b}=await Y0(v,m,y.signal),w=ac({audioBuffer:g,startTime:0,duration:g.duration,offset:0,name:b});!o.current&&i.current.has(h.id)&&t(_=>_.map(x=>x.id===h.id?{...x,name:b,clips:[w]}:x))}catch(g){if(g instanceof DOMException&&g.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",g),!o.current&&i.current.has(h.id)&&(t(b=>b.filter(w=>w.id!==h.id)),a(b=>[...b,{name:lo(v),error:g instanceof Error?g:new Error(String(g))}]))}finally{l.current.delete(h.id),!o.current&&i.current.delete(h.id)&&r(g=>g-1)}})()}},[]),u=p.useCallback(f=>{t(d=>d.filter(h=>h.id!==f));const m=l.current.get(f);m&&(m.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}}const nf=p.createContext(null),rf=p.createContext(null),sf=p.createContext(null),af=p.createContext(null),q0=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:s=1024,zoomLevels:a,automaticScroll:o=!1,theme:i,controls:l={show:!1,width:0},annotationList:c,effects:u,onReady:f,onAnnotationUpdate:m,onAnnotationsChange:d,barWidth:h=1,barGap:v=0,progressBarWidth:y,onTracksChange:g,soundFontCache:b,deferEngineRebuild:w=!1,children:_})=>{const x=y??h+v,C=p.useMemo(()=>a,[a?.join(",")]),k=p.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const N=c.annotations[0];if(typeof N.start!="number"||typeof N.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 N.start),[]}return c.annotations},[c?.annotations]),I=p.useRef(k);I.current=k;const[E,T]=p.useState(null),[R,A]=p.useState(!1),[M,$]=p.useState(0),[F,L]=p.useState(0),[z,q]=p.useState([]),[Y,ne]=p.useState([]),[G,J]=p.useState([]),[ae,ue]=p.useState(o),[de,Me]=p.useState(c?.isContinuousPlay??!1),[j,U]=p.useState(c?.linkEndpoints??!1),[ye,Z]=p.useState(c?.editable??!1),[Q,ke]=p.useState(!1),B=p.useRef(null),Te=p.useRef(!1),Qe=p.useRef(!1);Qe.current=R;const We=p.useRef(0),pe=p.useRef(0),te=p.useRef(e),Ue=p.useRef(b);Ue.current=b;const at=p.useRef(G),_e=p.useRef(0),Fe=p.useRef(0),Ve=p.useRef(null),Ye=p.useRef(null),kt=p.useRef(!1),zt=p.useRef(c?.isContinuousPlay??!1),X=p.useRef(null),me=p.useRef(null),je=p.useRef(0),Oe=p.useRef(!1),oe=p.useRef(!1),fe=p.useRef(s),Ze=p.useRef(44100),{timeFormat:Et,setTimeFormat:It,formatTime:Cn}=Kd(),dt=qd({engineRef:B,initialSamplesPerPixel:s}),{samplesPerPixel:V,onEngineState:K}=dt,ee=Jd({engineRef:B,initialVolume:1}),{masterVolume:le,setMasterVolume:$e,masterVolumeRef:He,onEngineState:re}=ee,{selectionStart:Ke,selectionEnd:et,setSelection:Ne,selectionStartRef:ft,selectionEndRef:Mt,onEngineState:tn}=y0({engineRef:B}),{isLoopEnabled:nn,loopStart:jt,loopEnd:Jn,setLoopEnabled:Gr,setLoopRegion:kn,clearLoopRegion:Ii,isLoopEnabledRef:Mi,loopStartRef:Ai,loopEndRef:Ti,onEngineState:$i}=b0({engineRef:B}),{selectedTrackId:Ri,setSelectedTrackId:Di,onEngineState:Pi,selectedTrackIdRef:Fi}=w0({engineRef:B}),{animationFrameRef:Oi,startAnimationFrameLoop:ra,stopAnimationFrameLoop:Ur}=tf(),Af=p.useMemo(()=>Math.min(...C??[256,512,1024,2048,4096,8192]),[C]),{cache:Li}=X0(e,Af),Bi=p.useCallback(N=>{zt.current=N,Me(N)},[]),Ft=p.useCallback(N=>{X.current=N,T(N)},[]),Wi=p.useCallback(()=>{const N=ft.current??0,H=Mt.current??0;N!==H&&H>N&&kn(N,H)},[kn,ft,Mt]);p.useEffect(()=>{kt.current=ae},[ae]),p.useEffect(()=>{at.current=G},[G]),te.current=e;const sa=e===me.current;Oe.current=sa||oe.current,p.useEffect(()=>{if(!Ye.current||F===0)return;const N=Ye.current,H=fe.current,ge=V;if(H===ge)return;const W=N.clientWidth,Ee=N.scrollLeft+W/2,Ce=Ze.current,la=Ee*H/Ce*Ce/ge,qr=Math.max(0,la-W/2);N.scrollLeft=qr,fe.current=ge},[V,F]);const Xr=p.useRef(null);p.useEffect(()=>{if(sa||oe.current){sa&&(me.current=null);let W=0;e.forEach(xe=>{xe.clips.forEach(Ee=>{const Ce=(Ee.startSample+Ee.durationSamples)/Ee.sampleRate;W=Math.max(W,Ce)})}),L(W);return}if(w){let W=0;e.forEach(xe=>{xe.clips.forEach(Ee=>{const Ce=(Ee.startSample+Ee.durationSamples)/Ee.sampleRate;W=Math.max(W,Ce)})}),L(W);return}if(ke(!1),e.length===0){q([]),L(0),J([]),ne([]),B.current&&(B.current.dispose(),B.current=null);return}const N=Qe.current,H=pe.current;return B.current&&N&&(B.current.stop(),Ur(),Xr.current={position:H}),(async()=>{try{const W=[];e.forEach(Ie=>{Ie.clips.length>0&&Ie.clips[0].audioBuffer&&W.push(Ie.clips[0].audioBuffer)});let xe=0;e.forEach(Ie=>{Ie.clips.forEach(pt=>{const Zt=pt.sampleRate,Of=(pt.startSample+pt.durationSamples)/Zt;xe=Math.max(xe,Of)})}),q(W),L(xe),J(Ie=>Ie.length===e.length?Ie.map((pt,Zt)=>({...pt,name:e[Zt].name})):e.map(pt=>({name:pt.name,muted:pt.muted,soloed:pt.soloed,volume:pt.volume,pan:pt.pan}))),B.current&&B.current.dispose(),je.current=0,me.current=null,Te.current=!1;const Ee=sh({effects:u,soundFontCache:Ue.current}),Ce=new dh({adapter:Ee,samplesPerPixel:fe.current,zoomLevels:C});Ce.setSelection(ft.current??0,Mt.current??0),Ce.setLoopRegion(Ai.current??0,Ti.current??0),Mi.current&&Ce.setLoopEnabled(!0),Ce.setMasterVolume(He.current??1),Fi.current&&Ce.selectTrack(Fi.current);const Kr=at.current,la=e.map((Ie,pt)=>{const Zt=Kr[pt];return{...Ie,volume:Zt?.volume??Ie.volume,muted:Zt?.muted??Ie.muted,soloed:Zt?.soloed??Ie.soloed,pan:Zt?.pan??Ie.pan}});let qr=!0;Ce.on("statechange",Ie=>{tn(Ie),$i(Ie),Pi(Ie),K(Ie),re(Ie),!qr&&Ie.tracksVersion!==je.current&&(je.current=Ie.tracksVersion,me.current=Ie.tracks,g?g(Ie.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),Ce.setTracks(la),qr=!1,je.current=Ce.getState().tracksVersion,B.current=Ce,ke(!0);const Ff=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:xe}});window.dispatchEvent(Ff),f?.()}catch(W){console.error("Error loading audio:",W)}})(),()=>{if(Oe.current){Oe.current=!1;return}Ur(),B.current&&B.current.dispose()}},[e,f,u,Ur,tn,$i,Pi,K,re,g,He,ft,Mt,Ai,Ti,Mi,C,b,w]),p.useEffect(()=>{if(e.length===0)return;const N=e.map(H=>H.clips.map(W=>{let xe;if(W.waveformData)try{xe=Yl(W.waveformData,V,n,W.offsetSamples,W.durationSamples)}catch(Ee){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",Ee)}if(!xe){const Ee=Li.get(W.id);if(Ee)try{xe=Yl(Ee,V,n,W.offsetSamples,W.durationSamples)}catch(Ce){console.warn("[waveform-playlist] Failed to extract peaks from cache:",Ce)}}if(!xe){!w&&!W.audioBuffer&&!W.waveformData&&!W.midiNotes&&console.warn(`[waveform-playlist] Clip "${W.id}" has no audio data or waveform data`);const Ee=n?1:W.audioBuffer?.numberOfChannels??1,Ce=W.midiNotes?Math.ceil(W.durationSamples/V):0;xe={length:Ce,data:Array.from({length:Ee},()=>new Int16Array(Ce*2)),bits:16}}return{clipId:W.id,trackName:H.name,peaks:xe,startSample:W.startSample,durationSamples:W.durationSamples,fadeIn:W.fadeIn,fadeOut:W.fadeOut,midiNotes:W.midiNotes,sampleRate:W.sampleRate,offsetSamples:W.offsetSamples}}));ne(N)},[e,V,n,Li,w]);const Vi=p.useRef(!1),En=p.useCallback(()=>{if(B.current)return B.current.getCurrentTime();Vi.current||(Vi.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const N=O.getContext().currentTime-(_e.current??0);return(Fe.current??0)+N},[]),rn=p.useCallback(()=>{const N=()=>{const H=En();pe.current=H;const ge=I.current;if(ge.length>0){const W=ge.find(xe=>H>=xe.start&&H<xe.end);if(zt.current)W&&W.id!==X.current?Ft(W.id):!W&&X.current!==null&&Ft(null);else if(X.current){const xe=ge.find(Ee=>Ee.id===X.current);if(xe&&H>=xe.end){B.current&&B.current.stop(),A(!1),pe.current=We.current,$(We.current);return}}else W&&Ft(W.id)}if(kt.current&&Ye.current&&F>0){const W=Ye.current,xe=Ze.current,Ee=H*xe/fe.current,Ce=W.clientWidth,Kr=Math.max(0,Ee-Ce/2);W.scrollLeft=Kr}if(Ve.current!==null&&H>=Ve.current){B.current&&B.current.stop(),A(!1),pe.current=Ve.current,$(Ve.current),Ve.current=null;return}if(H>=F){B.current&&B.current.stop(),A(!1),pe.current=We.current,$(We.current),Ft(null);return}ra(N)};ra(N)},[F,Ft,ra,En]),ht=Ur;p.useEffect(()=>{(async()=>{if(R&&Oi.current&&B.current)if(de){const H=pe.current;B.current.stop(),ht();const W=O.getContext().currentTime;_e.current=W,Fe.current=H,B.current.play(H),rn()}else ht(),rn()})().catch(H=>{console.warn("[waveform-playlist] Failed to reschedule playback:",H),A(!1),ht()})},[de,R,rn,ht,Oi]),p.useEffect(()=>{(async()=>{if(Xr.current&&B.current){const{position:H}=Xr.current;Xr.current=null;const W=O.getContext().currentTime;_e.current=W,Fe.current=H,Te.current||(await B.current.init(),Te.current=!0),B.current.play(H),A(!0),rn()}})().catch(H=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",H),A(!1),ht()})},[e,rn,ht]);const Yr=p.useCallback(async(N,H)=>{if(!B.current||F===0)return;const ge=N??pe.current;We.current=ge,pe.current=ge,B.current.stop(),B.current.seek(ge),ht();const xe=O.getContext().currentTime;_e.current=xe,Fe.current=ge,Ve.current=H!==void 0?ge+H:null,Te.current||(await B.current.init(),Te.current=!0);const Ee=H!==void 0?ge+H:void 0;try{B.current.play(ge,Ee)}catch(Ce){console.warn("[waveform-playlist] Playback failed to start:",Ce),ht();return}A(!0),rn()},[F,rn,ht]),Ni=p.useCallback(()=>{if(!B.current)return;const N=En();B.current.pause(),A(!1),ht(),pe.current=N,$(N)},[ht,En]),zi=p.useCallback(()=>{B.current&&(B.current.stop(),A(!1),ht(),pe.current=We.current,$(We.current),Ft(null))},[ht,Ft]),ji=p.useCallback(N=>{const H=Math.max(0,Math.min(N,F));pe.current=H,$(H),R&&B.current&&Yr(H)},[F,R,Yr]),Zi=p.useCallback((N,H)=>{const ge=te.current[N]?.id;if(!ge)return;const W=[...G];W[N]={...W[N],muted:H},J(W),B.current&&B.current.setTrackMute(ge,H)},[G]),Hi=p.useCallback((N,H)=>{const ge=te.current[N]?.id;if(!ge)return;const W=[...G];W[N]={...W[N],soloed:H},J(W),B.current&&B.current.setTrackSolo(ge,H)},[G]),Gi=p.useCallback((N,H)=>{const ge=te.current[N]?.id;if(!ge)return;const W=[...G];W[N]={...W[N],volume:H},J(W),B.current&&B.current.setTrackVolume(ge,H)},[G]),Ui=p.useCallback((N,H)=>{const ge=te.current[N]?.id;if(!ge)return;const W=[...G];W[N]={...W[N],pan:H},J(W),B.current&&B.current.setTrackPan(ge,H)},[G]),Xi=p.useCallback((N,H)=>{Ne(N,H),pe.current=N,$(N),R&&B.current&&(B.current.stop(),B.current.seek(N),B.current.play(N))},[R,Ne]),Yi=p.useCallback(N=>{Ye.current=N},[]),aa=p.useRef(d);aa.current=d;const Ki=p.useCallback(N=>{const H=typeof N=="function"?N(I.current):N;if(!aa.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}aa.current(H)},[]),oa=z[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;Ze.current=oa;const ia=t?30:0,qi=e.length*r+ia,Tf=p.useMemo(()=>({isPlaying:R,currentTime:M,currentTimeRef:pe,playbackStartTimeRef:_e,audioStartPositionRef:Fe,getPlaybackTime:En}),[R,M,pe,_e,Fe,En]),$f=p.useMemo(()=>({continuousPlay:de,linkEndpoints:j,annotationsEditable:ye,isAutomaticScroll:ae,isLoopEnabled:nn,annotations:k,activeAnnotationId:E,selectionStart:Ke,selectionEnd:et,selectedTrackId:Ri,loopStart:jt,loopEnd:Jn}),[de,j,ye,ae,nn,k,E,Ke,et,Ri,jt,Jn]),Ji=p.useCallback(N=>{pe.current=N,$(N)},[pe]),Qi=p.useCallback(N=>{ue(N)},[]),Rf=p.useMemo(()=>({play:Yr,pause:Ni,stop:zi,seekTo:ji,setCurrentTime:Ji,setTrackMute:Zi,setTrackSolo:Hi,setTrackVolume:Gi,setTrackPan:Ui,setSelection:Xi,setSelectedTrackId:Di,setTimeFormat:It,formatTime:Cn,zoomIn:dt.zoomIn,zoomOut:dt.zoomOut,setMasterVolume:$e,setAutomaticScroll:Qi,setScrollContainer:Yi,scrollContainerRef:Ye,setContinuousPlay:Bi,setLinkEndpoints:U,setAnnotationsEditable:Z,setAnnotations:Ki,setActiveAnnotationId:Ft,setLoopEnabled:Gr,setLoopRegion:kn,setLoopRegionFromSelection:Wi,clearLoopRegion:Ii}),[Yr,Ni,zi,ji,Ji,Zi,Hi,Gi,Ui,Xi,Di,It,Cn,dt.zoomIn,dt.zoomOut,$e,Qi,Yi,Ye,Bi,U,Z,Ki,Ft,Gr,kn,Wi,Ii]),Df=p.useMemo(()=>({duration:F,audioBuffers:z,peaksDataArray:Y,trackStates:G,tracks:e,sampleRate:oa,waveHeight:r,timeScaleHeight:ia,minimumPlaylistHeight:qi,controls:l,playoutRef:B,samplesPerPixel:V,timeFormat:Et,masterVolume:le,canZoomIn:dt.canZoomIn,canZoomOut:dt.canZoomOut,barWidth:h,barGap:v,progressBarWidth:x,isReady:Q,mono:n,isDraggingRef:oe}),[F,z,Y,G,e,oa,r,ia,qi,l,B,V,Et,le,dt.canZoomIn,dt.canZoomOut,h,v,x,Q,n,oe]),Pf={...Fd,...i};return S.jsx(P.ThemeProvider,{theme:Pf,children:S.jsx(nf.Provider,{value:Tf,children:S.jsx(rf.Provider,{value:$f,children:S.jsx(sf.Provider,{value:Rf,children:S.jsx(af.Provider,{value:Df,children:_})})})})})},ct=()=>{const e=p.useContext(nf);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},ut=()=>{const e=p.useContext(rf);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Pe=()=>{const e=p.useContext(sf);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},yt=()=>{const e=p.useContext(af);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var J0=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}},Q0=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 J0({...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 of=p.createContext(null),lf=p.createContext(null),cf=p.createContext(null),uf=p.createContext(null),ey=({track:e,samplesPerPixel:t=1024,waveHeight:n=100,timescale:r=!1,playbackRate:s=1,automaticScroll:a=!1,theme:o,controls:i={show:!1,width:0},annotationList:l,barWidth:c=1,barGap:u=0,progressBarWidth:f,onAnnotationsChange:m,onReady:d,children:h})=>{const v=f??c+u,[y,g]=p.useState(!1),[b,w]=p.useState(0),[_,x]=p.useState(0),[C,k]=p.useState([]),[I,E]=p.useState(s),T=p.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const X=l.annotations[0];if(typeof X.start!="number"||typeof X.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 X.start),[]}return l.annotations},[l?.annotations]),R=p.useRef(T);R.current=T;const[A,M]=p.useState(null),[$,F]=p.useState(l?.isContinuousPlay??!1),[L]=p.useState(t),[z,q]=p.useState(a),Y=p.useRef(null),ne=p.useRef(0),G=p.useRef($),J=p.useRef(null),ae=p.useRef(null),ue=p.useRef(a),de=p.useRef(t),{startAnimationFrameLoop:Me,stopAnimationFrameLoop:j}=tf();p.useEffect(()=>{G.current=$},[$]),p.useEffect(()=>{ue.current=z},[z]);const U=p.useCallback(X=>{J.current=X,M(X)},[]),ye=p.useCallback(X=>{G.current=X,F(X)},[]),Z=p.useCallback(X=>{ae.current=X},[]),Q=e.waveformData.sample_rate;p.useEffect(()=>{const X=new Q0({playbackRate:s});X.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const me=X.getTrack(X.track?.id??"");return me&&me.setOnTimeUpdateCallback(je=>{ne.current=je}),X.setOnPlaybackComplete(()=>{j(),g(!1),U(null),ne.current=0,w(0)}),Y.current=X,x(e.waveformData.duration),d?.(),()=>{j(),X.dispose()}},[e.source,e.waveformData,e.name,s,d,j,U]),p.useEffect(()=>{try{const X=v0(e.waveformData,L,0,0,Math.ceil(e.waveformData.duration*Q)),me={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:X.length,data:[X.data],bits:X.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*Q)};k([[me]])}catch(X){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",X)}},[e.waveformData,e.name,L,Q]);const ke=p.useCallback(()=>{const X=()=>{const me=Y.current?.getCurrentTime()??0;ne.current=me;const je=R.current;if(je.length>0){const Oe=je.find(oe=>me>=oe.start&&me<oe.end);if(G.current)Oe&&Oe.id!==J.current?U(Oe.id):!Oe&&J.current!==null&&U(null);else if(J.current){const oe=je.find(fe=>fe.id===J.current);if(oe&&me>=oe.end){Y.current?.stop(),g(!1);return}}else Oe&&U(Oe.id)}if(ue.current&&ae.current){const Oe=ae.current,oe=me*Q/de.current,fe=Oe.clientWidth,Ze=Math.max(0,oe-fe/2);Oe.scrollLeft=Ze}Me(X)};Me(X)},[U,Q,Me]),B=j,Te=p.useCallback(X=>{if(!Y.current)return;const me=X??ne.current;Y.current.play(void 0,me),g(!0),ke()},[ke]),Qe=p.useCallback(()=>{Y.current&&(Y.current.pause(),g(!1),B(),w(Y.current.getCurrentTime()))},[B]),We=p.useCallback(()=>{Y.current&&(Y.current.stop(),g(!1),B(),ne.current=0,w(0),U(null))},[B,U]),pe=p.useCallback(X=>{const me=Math.max(0,Math.min(X,_));ne.current=me,w(me),Y.current&&Y.current.seekTo(me)},[_]),te=p.useCallback(X=>{const me=Math.max(.5,Math.min(2,X));E(me),Y.current&&Y.current.setPlaybackRate(me)},[]),Ue=r?30:0,at=p.useMemo(()=>({isPlaying:y,currentTime:b,currentTimeRef:ne}),[y,b]),_e=p.useMemo(()=>({continuousPlay:$,annotations:T,activeAnnotationId:A,playbackRate:I,isAutomaticScroll:z}),[$,T,A,I,z]),Fe=p.useRef(m);Fe.current=m;const Ve=p.useCallback(X=>{const me=typeof X=="function"?X(R.current):X;if(!Fe.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}Fe.current(me)},[]),Ye=p.useMemo(()=>({play:Te,pause:Qe,stop:We,seekTo:pe,setPlaybackRate:te,setContinuousPlay:ye,setAnnotations:Ve,setActiveAnnotationId:U,setAutomaticScroll:X=>{q(X)},setScrollContainer:Z,scrollContainerRef:ae}),[Te,Qe,We,pe,te,ye,Ve,U,Z]),kt=p.useMemo(()=>({duration:_,peaksDataArray:C,sampleRate:Q,waveHeight:n,timeScaleHeight:Ue,samplesPerPixel:L,playoutRef:Y,controls:i,barWidth:c,barGap:u,progressBarWidth:v}),[_,C,Q,n,Ue,L,i,c,u,v]),zt={...Fd,...o};return S.jsx(P.ThemeProvider,{theme:zt,children:S.jsx(of.Provider,{value:at,children:S.jsx(lf.Provider,{value:_e,children:S.jsx(cf.Provider,{value:Ye,children:S.jsx(uf.Provider,{value:kt,children:h})})})})})},Js=()=>{const e=p.useContext(of);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},Qs=()=>{const e=p.useContext(lf);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},Ci=()=>{const e=p.useContext(cf);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},ea=()=>{const e=p.useContext(uf);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},ty=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=ct(),{selectionStart:r,selectionEnd:s,isLoopEnabled:a}=ut(),{play:o}=Pe(),i=async()=>{if(r!==s&&s>r&&!a){const c=s-r;await o(r,c)}else await o(n.current??0)};return S.jsx(Ct,{onClick:i,disabled:t,className:e,children:"Play"})},ny=({className:e})=>{const{isPlaying:t}=ct(),{pause:n}=Pe();return S.jsx(Ct,{onClick:n,disabled:!t,className:e,children:"Pause"})},ry=({className:e})=>{const{isPlaying:t}=ct(),{stop:n}=Pe();return S.jsx(Ct,{onClick:n,disabled:!t,className:e,children:"Stop"})},sy=({className:e})=>{const{isPlaying:t}=ct(),{play:n,setCurrentTime:r}=Pe(),s=()=>{r(0),t&&n(0)};return S.jsx(Ct,{onClick:s,className:e,children:"Rewind"})},ay=({className:e})=>{const{isPlaying:t}=ct(),{play:n,setCurrentTime:r}=Pe(),{duration:s}=yt(),a=()=>{r(s),t&&n(s)};return S.jsx(Ct,{onClick:a,className:e,children:"Fast Forward"})},oy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ct(),{play:s,setCurrentTime:a}=Pe(),o=()=>{const i=Math.max(0,(n.current??0)-e);a(i),r&&s(i)};return S.jsx(Ct,{onClick:o,className:t,children:"Skip Backward"})},iy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ct(),{play:s,setCurrentTime:a}=Pe(),{duration:o}=yt(),i=()=>{const l=Math.min(o,(n.current??0)+e);a(l),r&&s(l)};return S.jsx(Ct,{onClick:i,className:t,children:"Skip Forward"})},ly=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=ut(),{setLoopEnabled:s,setLoopRegion:a}=Pe(),{duration:o}=yt(),i=n!==r&&r>n,l=()=>{if(!t&&!i){const c=Math.min(10,o*.25);a(0,Math.max(1,c))}s(!t)};return S.jsx(Ct,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},cy=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=ut(),{setLoopRegionFromSelection:a,clearLoopRegion:o}=Pe(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?o():a()};return S.jsx(Ct,{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"})},uy=({className:e,disabled:t})=>{const{zoomIn:n}=Pe(),{canZoomIn:r}=yt();return S.jsx(Ct,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},dy=({className:e,disabled:t})=>{const{zoomOut:n}=Pe(),{canZoomOut:r}=yt();return S.jsx(Ct,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},fy=({className:e})=>{const{masterVolume:t}=yt(),{setMasterVolume:n}=Pe();return S.jsx(Yg,{volume:t,onChange:n,className:e})},hy=({className:e})=>{const{timeFormat:t}=yt(),{setTimeFormat:n}=Pe();return S.jsx(Lv,{value:t,onChange:n,className:e})},py=P.span`
|
|
1010
1005
|
font-family: 'Courier New', Monaco, monospace;
|
|
1011
1006
|
font-size: 1rem;
|
|
1012
1007
|
font-weight: 600;
|
|
1013
1008
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
1014
1009
|
user-select: none;
|
|
1015
|
-
`,
|
|
1010
|
+
`,my=({className:e})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=ct(),{timeFormat:o}=yt();return p.useEffect(()=>{const i=()=>{if(t.current){const l=r?a():s.current??0;t.current.textContent=Ln(l,o)}r&&(n.current=requestAnimationFrame(i))};return r?n.current=requestAnimationFrame(i):i(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,o,s,a]),p.useEffect(()=>{!r&&t.current&&(t.current.textContent=Ln(s.current??0,o))}),S.jsx(py,{ref:t,className:e,"aria-label":"Audio position",children:Ln(s.current??0,o)})},gy=({className:e})=>{const{selectionStart:t,selectionEnd:n}=ut(),{setSelection:r}=Pe();return S.jsx(fv,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},vy=({className:e})=>{const{isAutomaticScroll:t}=ut(),{setAutomaticScroll:n}=Pe();return S.jsx(Sg,{checked:t,onChange:n,className:e})},ta=p.createContext(null),yy=ta.Provider;function Sn(){const e=p.useContext(ta);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 by=({className:e})=>{const{ContinuousPlayCheckbox:t}=Sn(),{continuousPlay:n}=ut(),{setContinuousPlay:r}=Pe();return S.jsx(t,{checked:n,onChange:r,className:e})},wy=({className:e})=>{const{LinkEndpointsCheckbox:t}=Sn(),{linkEndpoints:n}=ut(),{setLinkEndpoints:r}=Pe();return S.jsx(t,{checked:n,onChange:r,className:e})},_y=({className:e})=>{const{EditableCheckbox:t}=Sn(),{annotationsEditable:n}=ut(),{setAnnotationsEditable:r}=Pe();return S.jsx(t,{checked:n,onChange:r,className:e})},xy=({filename:e,className:t})=>{const{DownloadAnnotationsButton:n}=Sn(),{annotations:r}=ut();return S.jsx(n,{annotations:r,filename:e,className:t})},Sy=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:s=16,applyEffects:a=!0,effectsFunction:o,createOfflineTrackEffects:i,className:l,onExportComplete:c,onExportError:u})=>{const{tracks:f,trackStates:m}=yt(),{exportWav:d,isExporting:h,progress:v}=ef(),y=async()=>{try{const b=await d(f,m,{filename:t,mode:n,trackIndex:r,bitDepth:s,applyEffects:a,effectsFunction:o,createOfflineTrackEffects:i,autoDownload:!0});c?.(b.blob)}catch(b){u?.(b instanceof Error?b:new Error("Export failed"))}},g=h?`Exporting ${Math.round(v*100)}%`:e;return S.jsx(Ct,{onClick:y,disabled:h||f.length===0,className:l,children:g})},Cy=P.div.attrs(e=>({style:{width:`${e.$width}px`,background:e.$color}}))`
|
|
1016
1011
|
position: absolute;
|
|
1017
1012
|
top: 0;
|
|
1018
1013
|
left: 0;
|
|
@@ -1020,16 +1015,16 @@ self.onmessage = function(e) {
|
|
|
1020
1015
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
1021
1016
|
pointer-events: none;
|
|
1022
1017
|
will-change: transform;
|
|
1023
|
-
`,
|
|
1018
|
+
`,ky=({color:e="#ff0000"})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=ct(),{samplesPerPixel:o,sampleRate:i,progressBarWidth:l}=yt();return p.useEffect(()=>{const c=()=>{if(t.current){const f=(r?a():s.current??0)*i/o;t.current.style.transform=`translate3d(${f}px, 0, 0)`}r&&(n.current=requestAnimationFrame(c))};return r?n.current=requestAnimationFrame(c):c(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,i,o,s,a]),p.useEffect(()=>{if(!r&&t.current){const u=(s.current??0)*i/o;t.current.style.transform=`translate3d(${u}px, 0, 0)`}}),S.jsx(Cy,{ref:t,$color:e,$width:l,"data-playhead":!0})},Ey=P.div`
|
|
1024
1019
|
position: relative;
|
|
1025
|
-
`,
|
|
1020
|
+
`,Sa=P.div.attrs(e=>({style:{top:`${e.$top}px`,width:`${e.$width}px`,height:`${e.$height}px`,background:e.$color}}))`
|
|
1026
1021
|
position: absolute;
|
|
1027
1022
|
left: 0;
|
|
1028
1023
|
z-index: 0;
|
|
1029
1024
|
/* Force GPU compositing layer to prevent gradient flickering during scroll */
|
|
1030
1025
|
transform: translateZ(0);
|
|
1031
1026
|
backface-visibility: hidden;
|
|
1032
|
-
`,
|
|
1027
|
+
`,Iy=P.div.attrs(e=>({style:{top:`${e.$top}px`,height:`${e.$height}px`,width:`${e.$width}px`,background:e.$color,transform:"scaleX(0)"}}))`
|
|
1033
1028
|
position: absolute;
|
|
1034
1029
|
left: 0;
|
|
1035
1030
|
pointer-events: none;
|
|
@@ -1037,16 +1032,16 @@ self.onmessage = function(e) {
|
|
|
1037
1032
|
transform-origin: left;
|
|
1038
1033
|
/* scaleX changes are composite-only (GPU) — no layout reflow per frame */
|
|
1039
1034
|
will-change: transform;
|
|
1040
|
-
`,
|
|
1035
|
+
`,My=P.div`
|
|
1041
1036
|
position: relative;
|
|
1042
1037
|
z-index: 2;
|
|
1043
|
-
`,
|
|
1038
|
+
`,Jl=({clipStartSample:e,clipDurationSamples:t,midiNotes:n,clipSampleRate:r,clipOffsetSeconds:s,...a})=>{const o=p.useRef(null),i=p.useRef(null),l=jr(),{waveHeight:c}=Ks(),{isPlaying:u,currentTimeRef:f,getPlaybackTime:m}=ct(),{samplesPerPixel:d,sampleRate:h}=yt(),v=l?.waveProgressColor||"rgba(0, 0, 0, 0.1)",y=cc(e,t,d);p.useEffect(()=>{const R=()=>{if(o.current){const M=(u?m():f.current??0)*h,$=e+t;let F=0;M<=e?F=0:M>=$?F=1:F=(M-e)/t,o.current.style.transform=`scaleX(${F})`}u&&(i.current=requestAnimationFrame(R))};return u?i.current=requestAnimationFrame(R):R(),()=>{i.current&&(cancelAnimationFrame(i.current),i.current=null)}},[u,h,e,t,y,f,m]),p.useEffect(()=>{if(!u&&o.current){const A=(f.current??0)*h,M=e+t;let $=0;A<=e?$=0:A>=M?$=1:$=(A-e)/t,o.current.style.transform=`scaleX(${$})`}});const g=l?.waveformDrawMode||"inverted";let b;g==="inverted"?b=a.isSelected&&l?l.selectedWaveFillColor:l?.waveFillColor||"white":b=a.isSelected&&l?l.selectedWaveOutlineColor:l?.waveOutlineColor||"grey";const w=a.renderMode==="spectrogram"||a.renderMode==="both",_=a.renderMode==="piano-roll",x=a.renderMode==="both",C=w?"#000":_?l?.pianoRollBackgroundColor||"#1a1a2e":Jt(b),k=Math.floor(c/2),I=c,E=a.index*c,T=Jt(b);return S.jsxs(Ey,{children:[x?S.jsxs(S.Fragment,{children:[S.jsx(Sa,{$color:"#000",$height:k,$top:E,$width:a.length}),S.jsx(Sa,{$color:T,$height:k,$top:E+k,$width:a.length})]}):S.jsx(Sa,{$color:C,$height:I,$top:E,$width:a.length}),!_&&S.jsx(Iy,{ref:o,$color:v,$height:I,$top:E,$width:y}),S.jsx(My,{children:S.jsx(Zd,{...a,transparentBackground:!0,midiNotes:n,sampleRate:r,clipOffsetSeconds:s})})]})},ki=p.createContext(null),Ay=ki.Provider;function Ty(){const e=p.useContext(ki);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const $y=60,Ry=P.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
|
|
1044
1039
|
overflow: hidden;
|
|
1045
1040
|
pointer-events: auto;
|
|
1046
1041
|
background: ${e=>e.theme.surfaceColor};
|
|
1047
1042
|
transition: background 0.15s ease-in-out;
|
|
1048
1043
|
${e=>e.$isSelected&&`background: ${e.theme.selectedTrackControlsBackground};`}
|
|
1049
|
-
`,ef=({renderTrackControls:e,renderTimestamp: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 h=zr(),{isPlaying:d,currentTimeRef:p,playbackStartTimeRef:v,audioStartPositionRef:y,getPlaybackTime:m}=lt(),{selectionStart:b,selectionEnd:_,annotations:w,activeAnnotationId:x,annotationsEditable:S,linkEndpoints:k,continuousPlay:E,selectedTrackId:T,loopStart:I,loopEnd:M,isLoopEnabled:$}=ct(),A=g.useContext(Ks),{setAnnotations:R,setActiveAnnotationId:W,setTrackMute:q,setTrackSolo:z,setTrackVolume:J,setTrackPan:ee,setSelection:j,play:se,setScrollContainer:U,setSelectedTrackId:ie,setCurrentTime:le,setLoopRegion:ge}=Pe(),{peaksDataArray:Se,trackStates:N,tracks:G,duration:ye,samplesPerPixel:Z,sampleRate:Q,waveHeight:O,timeScaleHeight:_e,controls:Ne,barWidth:Be,barGap:ve,isReady:Ve}=vt(),ne=g.useContext(wi),Ge=g.useMemo(()=>{if(!ne)return new Map;const V=new Map;return G.forEach(Y=>{if((ne.trackSpectrogramOverrides.get(Y.id)?.renderMode??Y.renderMode??"waveform")==="waveform")return;const ce=ne.trackSpectrogramOverrides.get(Y.id),Ae=ce?.colorMap??Y.spectrogramColorMap??ne.spectrogramColorMap??"viridis",Ze=ce?.config??Y.spectrogramConfig??ne.spectrogramConfig;V.set(Y.id,{colorLUT:ne.getColorMap(Ae),frequencyScaleFn:ne.getFrequencyScale(Ze?.frequencyScale??"mel"),config:Ze})}),V},[G,ne]),je=g.useMemo(()=>{if(ne?.spectrogramWorkerApi)return{registerCanvas:ne.spectrogramWorkerApi.registerCanvas.bind(ne.spectrogramWorkerApi),unregisterCanvas:ne.spectrogramWorkerApi.unregisterCanvas.bind(ne.spectrogramWorkerApi)}},[ne?.spectrogramWorkerApi]),[xe,Fe]=g.useState(null),[Oe,Et]=g.useState(!1),It=g.useRef(0),Mt=g.useRef(null),X=g.useCallback(V=>{Mt.current=V,U(V)},[U]),fe=G.reduce((V,Y)=>Y.clips.reduce((K,ce)=>{const Ae=(ce.startSample+ce.durationSamples)/ce.sampleRate;return Math.max(K,Ae)},V),0);let Ue=fe>0?fe:ye>0?ye:my;if(f?.isRecording){const Y=(f.startSample+f.durationSamples)/Q;Ue=Math.max(Ue,Y+10)}const Me=Math.floor(Ue*Q/Z),oe=async V=>{W(V.id);const Y=E?void 0:V.end-V.start;try{await se(V.start,Y)}catch(K){console.error("waveform-playlist: Failed to start playback for annotation",V.id,K)}},he=g.useCallback(V=>{if(V>=0&&V<G.length){const Y=G[V];ie(Y.id)}},[G,ie]),Xe=V=>{const Y=V.currentTarget.getBoundingClientRect(),ce=(V.clientX-Y.left)*Z/Q,Ze=V.clientY-Y.top;let te=0,Ke=-1;for(let Qe=0;Qe<Se.length;Qe++){const Te=Se[Qe],dt=Te.length>0?Math.max(1,...Te.map(Ht=>Ht.peaks.data.length)):1,sn=((ne?.trackSpectrogramOverrides.get(G[Qe]?.id)?.renderMode??G[Qe]?.renderMode??"waveform")==="both"?dt*2:dt)*O+(a?22:0);if(Ze>=te&&Ze<te+sn){Ke=Qe;break}te+=sn}Ke!==-1&&he(Ke),It.current=ce,Et(!0),le(ce),j(ce,ce)},At=V=>{if(!Oe||d)return;const Y=V.currentTarget.getBoundingClientRect(),ce=(V.clientX-Y.left)*Z/Q,Ae=Math.min(b,ce),Ze=Math.max(b,ce);j(Ae,Ze)},Tt=V=>{if(!Oe)return;if(Et(!1),d){const te=Math.max(0,It.current);le(te),j(te,te),se(te);return}const Y=V.currentTarget.getBoundingClientRect(),ce=(V.clientX-Y.left)*Z/Q,Ae=Math.min(b,ce),Ze=Math.max(b,ce);Math.abs(Ze-Ae)<.1?le(Ae):j(Ae,Ze)};if(G.some(V=>V.clips.length>0)&&Se.length===0)return C.jsx("div",{className:o,children:"Loading waveform..."});const yt=Ne.show?Se.map((V,Y)=>{const K=G[Y];if(!K)return null;const ce=N[Y]||{name:`Track ${Y+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ae=K.clips.some(Te=>Te.midiNotes&&Te.midiNotes.length>0),Ze=ne?.trackSpectrogramOverrides.get(K.id)?.renderMode??K.renderMode??(Ae?"piano-roll":"waveform"),te=V.length>0?Math.max(1,...V.map(Te=>Te.peaks.data.length)):1,Ke=O*te+(a?pi:0),Qe=e?e(Y):C.jsxs(Av,{onClick:()=>he(Y),children:[C.jsxs(Tv,{style:{justifyContent:"center",position:"relative"},children:[u&&C.jsx(Mv,{onClick:Te=>{Te.stopPropagation(),u(Y)}}),C.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:ce.name||`Track ${Y+1}`}),ne?.renderMenuItems&&C.jsx("span",{style:{position:"absolute",right:0,top:0},children:C.jsx(Wv,{items:Te=>ne.renderMenuItems({renderMode:Ze,onRenderModeChange:dt=>ne.setTrackRenderMode(K.id,dt),onOpenSettings:()=>Fe(K.id),onClose:Te})})})]}),C.jsxs(Ev,{children:[C.jsx(Bl,{$variant:ce.muted?"danger":"outline",onClick:()=>q(Y,!ce.muted),children:"Mute"}),C.jsx(Bl,{$variant:ce.soloed?"info":"outline",onClick:()=>z(Y,!ce.soloed),children:"Solo"})]}),C.jsxs(Nl,{children:[C.jsx($v,{}),C.jsx(Vl,{min:"0",max:"1",step:"0.01",value:ce.volume,onChange:Te=>J(Y,parseFloat(Te.target.value))}),C.jsx(Rv,{})]}),C.jsxs(Nl,{children:[C.jsx("span",{children:"L"}),C.jsx(Vl,{min:"-1",max:"1",step:"0.01",value:ce.pan,onChange:Te=>ee(Y,parseFloat(Te.target.value))}),C.jsx("span",{children:"R"})]})]});return C.jsx(gy,{$height:Ke,$isSelected:K.id===T,children:Qe},K.id)}):void 0;return C.jsxs(Dd,{children:[C.jsx(Nr.Provider,{value:{samplesPerPixel:Z,sampleRate:Q,zoomLevels:[Z],waveHeight:O,timeScaleHeight:_e,duration:Ue*1e3,controls:Ne,barWidth:Be,barGap:ve},children:C.jsx(mi,{theme:h,backgroundColor:h.playlistBackgroundColor||en(h.waveOutlineColor),timescaleBackgroundColor:h.timescaleBackgroundColor,timescaleWidth:Me,tracksWidth:Me,controlsWidth:Ne.show?Ne.width:0,onTracksMouseDown:Xe,onTracksMouseMove:At,onTracksMouseUp:Tt,scrollContainerRef:X,isSelecting:Oe,"data-playlist-state":Ve?"ready":"loading",trackControlsSlots:yt,timescaleGapHeight:_e>0?_e+1:0,timescale:_e>0?C.jsxs(C.Fragment,{children:[C.jsx(Fd,{renderTimestamp:t}),$&&C.jsx(Jg,{startPosition:Math.min(I,M)*Q/Z,endPosition:Math.max(I,M)*Q/Z,markerColor:h.loopMarkerColor,regionColor:h.loopRegionColor,minPosition:0,maxPosition:Me,onLoopRegionChange:(V,Y)=>{const K=V*Z/Q,ce=Y*Z/Q;ge(K,ce)}})]}):void 0,children:C.jsxs(C.Fragment,{children:[Se.map((V,Y)=>{const K=G[Y];if(!K)return null;const ce=K.clips.some(te=>te.midiNotes&&te.midiNotes.length>0),Ae=ne?.trackSpectrogramOverrides.get(K.id)?.renderMode??K.renderMode??(ce?"piano-roll":"waveform"),Ze=V.length>0?Math.max(1,...V.map(te=>te.peaks.data.length)):1;return C.jsxs(Od,{numChannels:Ze,backgroundColor:Ae==="piano-roll"?h.pianoRollBackgroundColor||"#1a1a2e":en(h.waveOutlineColor),offset:0,width:Me,hasClipHeaders:a,trackId:K.id,isSelected:K.id===T,children:[Ae!=="waveform"&&(()=>{const te=Ge.get(K.id),Ke=te?.config;return!Ke?.labels||!te?null:C.jsx(fv,{waveHeight:O,numChannels:Ze,frequencyScaleFn:te.frequencyScaleFn,minFrequency:Ke.minFrequency??0,maxFrequency:Ke.maxFrequency??Q/2,labelsColor:Ke.labelsColor,labelsBackground:Ke.labelsBackground,renderMode:Ae,hasClipHeaders:a})})(),V.map((te,Ke)=>{const Qe=te.peaks,Te=Qe.length;return C.jsx(oa,{clipId:te.clipId,trackIndex:Y,clipIndex:Ke,trackName:te.trackName,startSample:te.startSample,durationSamples:te.durationSamples,samplesPerPixel:Z,showHeader:a,disableHeaderDrag:!i,isSelected:K.id===T,trackId:K.id,fadeIn:te.fadeIn,fadeOut:te.fadeOut,sampleRate:Q,showFades:l,touchOptimized:c,onMouseDown:dt=>{dt.target.closest('[role="button"][aria-roledescription="draggable"]')||he(Y)},children:Qe.data.map((dt,Lt)=>{const rn=ne?.spectrogramDataMap.get(te.clipId),sn=rn?.[Lt]??rn?.[0],Ht=Ge.get(K.id),qn=Ht?.config;return C.jsx(Hl,{index:Lt,data:dt,bits:Qe.bits,length:Te,isSelected:K.id===T,clipStartSample:te.startSample,clipDurationSamples:te.durationSamples,renderMode:te.midiNotes?"piano-roll":Ae,midiNotes:te.midiNotes,clipSampleRate:te.sampleRate,clipOffsetSeconds:te.offsetSamples!=null?te.offsetSamples/(te.sampleRate||Q):0,spectrogramData:sn,samplesPerPixel:Z,spectrogramColorLUT:Ht?.colorLUT,spectrogramFrequencyScaleFn:Ht?.frequencyScaleFn,spectrogramMinFrequency:qn?.minFrequency,spectrogramMaxFrequency:qn?.maxFrequency,spectrogramWorkerApi:je,spectrogramClipId:te.clipId,spectrogramOnCanvasesReady:ne?(kn,Hr)=>{ne.registerSpectrogramCanvases(te.clipId,Lt,kn,Hr)}:void 0},`${te.clipId}-${Lt}`)})},te.clipId)}),f?.isRecording&&f.trackId===K.id&&f.peaks.length>0&&C.jsx(oa,{clipId:"recording-preview",trackIndex:Y,clipIndex:V.length,trackName:"Recording...",startSample:f.startSample,durationSamples:f.durationSamples,samplesPerPixel:Z,showHeader:a,disableHeaderDrag:!0,isSelected:K.id===T,trackId:K.id,children:C.jsx(Hl,{index:0,data:f.peaks,bits:16,length:Math.floor(f.peaks.length/2),isSelected:K.id===T,clipStartSample:f.startSample,clipDurationSamples:f.durationSamples},`${K.id}-recording-0`)},`${K.id}-recording`)]},K.id)}),w.length>0&&A&&C.jsx(A.AnnotationBoxesWrapper,{height:30,width:Me,children:w.map((V,Y)=>{const K=V.start*Q/Z,ce=V.end*Q/Z,Ae=s?s(V,Y):V.id;return C.jsx(A.AnnotationBox,{annotationId:V.id,annotationIndex:Y,startPosition:K,endPosition:ce,label:Ae,color:"#ff9800",isActive:V.id===x,onClick:()=>oe(V),editable:S},V.id)})}),b!==_&&C.jsx(Td,{startPosition:Math.min(b,_)*Q/Z,endPosition:Math.max(b,_)*Q/Z,color:h.selectionColor}),(d||b===_)&&(n?n({position:(p.current??0)*Q/Z,color:h.playheadColor,isPlaying:d,currentTimeRef:p,playbackStartTimeRef:v,audioStartPositionRef:y,samplesPerPixel:Z,sampleRate:Q,controlsOffset:0,getAudioContextTime:()=>F.getContext().currentTime,getPlaybackTime:m}):C.jsx(cy,{color:h.playheadColor}))]})})}),ne?.SettingsModal&&typeof document<"u"&&da.createPortal(C.jsx(ne.SettingsModal,{open:xe!==null,onClose:()=>Fe(null),config:xe!==null?ne.trackSpectrogramOverrides.get(xe)?.config??G.find(V=>V.id===xe)?.spectrogramConfig??ne.spectrogramConfig??{}:{},colorMap:xe!==null?ne.trackSpectrogramOverrides.get(xe)?.colorMap??G.find(V=>V.id===xe)?.spectrogramColorMap??ne.spectrogramColorMap??"viridis":"viridis",onApply:(V,Y)=>{xe!==null&&ne.setTrackSpectrogramConfig(xe,V,Y)}}),document.body)]})},tf=({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}=ct(),h=Sn(),{setAnnotations:d}=Pe(),p=s??{linkEndpoints:u,continuousPlay:f},v=g.useCallback(m=>{d(m),n?.(m)},[d,n]),{AnnotationText:y}=h;return C.jsx(y,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:o,scrollActiveContainer:a,editable:c,controls:c?r:void 0,annotationListConfig:p,height:e,onAnnotationUpdate:v,renderAnnotationItem:t})},vy=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:s,annotationTextHeight:o,renderAnnotationItem:a,getAnnotationBoxLabel:i,scrollActivePosition:l="center",scrollActiveContainer:c="nearest",className:u,showClipHeaders:f=!1,interactiveClips:h=!1,showFades:d=!1,touchOptimized:p=!1,onRemoveTrack:v,recordingState:y})=>{const{annotations:m}=ct();return C.jsxs(C.Fragment,{children:[C.jsx(ef,{renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:i,className:u,showClipHeaders:f,interactiveClips:h,showFades:d,touchOptimized:p,onRemoveTrack:v,recordingState:y}),m.length>0&&C.jsx(tf,{height:o,renderAnnotationItem:a,controls:r,annotationListConfig:s,scrollActivePosition:l,scrollActiveContainer:c})]})};var yy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",nf=yy?g.useLayoutEffect:g.useEffect;function An(e){const t=g.useRef(e);return nf(()=>{t.current=e},[e]),t}function _o(e,t,n=g.useEffect,r=Object.is){const s=g.useRef(e);n(()=>{const o=s.current;r(e,o)||(s.current=e,t(e,o))},[t,e])}var Gl=Object.getOwnPropertySymbols,by=Object.prototype.hasOwnProperty,wy=Object.prototype.propertyIsEnumerable,_y=(e,t)=>{var n={};for(var r in e)by.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Gl)for(var r of Gl(e))t.indexOf(r)<0&&wy.call(e,r)&&(n[r]=e[r]);return n},xy=new oi,Cy=g.createContext(xy),Sy=g.memo(g.forwardRef(({children:e},t)=>{const[n,r]=g.useState(0),s=g.useRef(null),o=g.useRef(null),a=g.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})),g.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return nf(()=>{var i;(i=o.current)==null||i.call(o),s.current=null},[e,n]),g.useImperativeHandle(t,()=>a),null})),xo=[void 0,_r];function ky(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:o,onDragMove:a,onDragOver:i,onDragEnd:l}=t,c=_y(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=g.useRef(null),{plugins:f,modifiers:h,sensors:d}=c,p=Vt(f,On.plugins),v=Vt(d,On.sensors),y=Vt(h,On.modifiers),m=An(s),b=An(o),_=An(i),w=An(a),x=An(l),S=An(r),k=Ey(()=>{var E;return(E=c.manager)!=null?E:new oi(c)});return g.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:E,trackRendering:T}=u.current,{monitor:I}=k;k.renderer=E;const M=[I.addEventListener("beforedragstart",$=>{const A=m.current;A&&T(()=>A($,k))}),I.addEventListener("dragstart",$=>{var A;return(A=b.current)==null?void 0:A.call(b,$,k)}),I.addEventListener("dragover",$=>{const A=_.current;A&&T(()=>A($,k))}),I.addEventListener("dragmove",$=>{const A=w.current;A&&T(()=>A($,k))}),I.addEventListener("dragend",$=>{const A=x.current;A&&T(()=>A($,k))}),I.addEventListener("collision",$=>{var A;return(A=S.current)==null?void 0:A.call(S,$,k)})];return()=>M.forEach($=>$())},[k]),_o(p,()=>k&&(k.plugins=p),...xo),_o(v,()=>k&&(k.sensors=v),...xo),_o(y,()=>k&&(k.modifiers=y),...xo),C.jsxs(Cy.Provider,{value:k,children:[C.jsx(Sy,{ref:u,children:n}),n]})}function Ey(e){const t=g.useRef(null);return t.current||(t.current=e()),g.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var Iy=Object.create,rf=Object.defineProperty,My=Object.getOwnPropertyDescriptor,sf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),qs=e=>{throw TypeError(e)},Ay=(e,t,n)=>t in e?rf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ty=e=>{var t;return[,,,Iy((t=e?.[sf("metadata")])!=null?t:null)]},of=["class","method","getter","setter","accessor","field","value","get","set"],af=e=>e!==void 0&&typeof e!="function"?qs("Function expected"):e,$y=(e,t,n,r,s)=>({kind:of[e],name:t,metadata:r,addInitializer:o=>n._?qs("Already initialized"):s.push(af(o||null))}),Ry=(e,t)=>Ay(t,sf("metadata"),e[3]),Dy=(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},lf=(e,t,n,r,s,o)=>{for(var a,i,l,c,u=t&7,f=!1,h=!1,d=2,p=of[u+5],v=e[d]||(e[d]=[]),y=(s=s.prototype,My(s,n)),m=r.length-1;m>=0;m--)l=$y(u,n,i={},e[3],v),l.static=f,l.private=h,c=l.access={has:b=>n in b},c.get=b=>b[n],a=(0,r[m])(y[p],l),i._=1,af(a)&&(y[p]=a);return y&&rf(s,n,y),s},cf=(e,t,n)=>t.has(e)||qs("Cannot "+n),Py=(e,t,n)=>(cf(e,t,"read from private field"),t.get(e)),Fy=(e,t,n)=>t.has(e)?qs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Oy=(e,t,n,r)=>(cf(e,t,"write to private field"),t.set(e,n),n),nr=class ia{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ia(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 ia(t,n)}},uf,df,la,gs,Zr,_i=class extends(la=tn,df=[Ie],uf=[Ie],la){constructor(e){const t=nr.from(e);super(t,(n,r)=>nr.equals(n,r)),Dy(Zr,5,this),Fy(this,gs,0),this.velocity={x:0,y:0}}get delta(){return nr.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=nr.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),o=s-Py(this,gs),a=i=>Math.round(i/o*100);Qt(()=>{Oy(this,gs,s),this.velocity={x:a(r.x),y:a(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(nr.from(e)),this.velocity={x:0,y:0}}};Zr=Ty(la);gs=new WeakMap;lf(Zr,2,"delta",df,_i);lf(Zr,2,"direction",uf,_i);Ry(Zr,_i);var ff=(e=>(e.Horizontal="x",e.Vertical="y",e))(ff||{});Object.values(ff);var Ly=Object.defineProperty,Wy=Object.defineProperties,By=Object.getOwnPropertyDescriptors,Ul=Object.getOwnPropertySymbols,Vy=Object.prototype.hasOwnProperty,Ny=Object.prototype.propertyIsEnumerable,Xl=(e,t,n)=>t in e?Ly(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hf=(e,t)=>{for(var n in t||(t={}))Vy.call(t,n)&&Xl(e,n,t[n]);if(Ul)for(var n of Ul(t))Ny.call(t,n)&&Xl(e,n,t[n]);return e},pf=(e,t)=>Wy(e,By(t)),ca=class extends Cr{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return pf(hf({},t),{[n]:r})}};ca.configure=Xn(ca);var mf=ca;mf.configure({axis:"x",value:0});var zy=mf.configure({axis:"y",value:0}),Yl=class extends Cr{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 pf(hf({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/o)*o})}};Yl.configure=Xn(Yl);const gf=e=>{let t=!1;const n=e.map(r=>r===Ko?(t=!0,Ko.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},jy=P.div`
|
|
1044
|
+
`,df=({renderTrackControls:e,renderTick:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:a,showClipHeaders:o=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:u,recordingState:f})=>{const m=jr(),{isPlaying:d,currentTimeRef:h,playbackStartTimeRef:v,audioStartPositionRef:y,getPlaybackTime:g}=ct(),{selectionStart:b,selectionEnd:w,annotations:_,activeAnnotationId:x,annotationsEditable:C,linkEndpoints:k,continuousPlay:I,selectedTrackId:E,loopStart:T,loopEnd:R,isLoopEnabled:A}=ut(),M=p.useContext(ta),{setAnnotations:$,setActiveAnnotationId:F,setTrackMute:L,setTrackSolo:z,setTrackVolume:q,setTrackPan:Y,setSelection:ne,play:G,setScrollContainer:J,setSelectedTrackId:ae,setCurrentTime:ue,setLoopRegion:de}=Pe(),{peaksDataArray:Me,trackStates:j,tracks:U,duration:ye,samplesPerPixel:Z,sampleRate:Q,waveHeight:ke,timeScaleHeight:B,controls:Te,barWidth:Qe,barGap:We,isReady:pe}=yt(),te=p.useContext(ki),Ue=p.useMemo(()=>{if(!te)return new Map;const V=new Map;return U.forEach(K=>{if((te.trackSpectrogramOverrides.get(K.id)?.renderMode??K.renderMode??"waveform")==="waveform")return;const le=te.trackSpectrogramOverrides.get(K.id),$e=le?.colorMap??K.spectrogramColorMap??te.spectrogramColorMap??"viridis",He=le?.config??K.spectrogramConfig??te.spectrogramConfig;V.set(K.id,{colorLUT:te.getColorMap($e),frequencyScaleFn:te.getFrequencyScale(He?.frequencyScale??"mel"),config:He})}),V},[U,te]),at=p.useMemo(()=>{if(te?.spectrogramWorkerApi)return{registerCanvas:te.spectrogramWorkerApi.registerCanvas.bind(te.spectrogramWorkerApi),unregisterCanvas:te.spectrogramWorkerApi.unregisterCanvas.bind(te.spectrogramWorkerApi)}},[te?.spectrogramWorkerApi]),[_e,Fe]=p.useState(null),[Ve,Ye]=p.useState(!1),kt=p.useRef(0),zt=p.useRef(null),X=p.useCallback(V=>{zt.current=V,J(V)},[J]),me=U.reduce((V,K)=>K.clips.reduce((ee,le)=>{const $e=(le.startSample+le.durationSamples)/le.sampleRate;return Math.max(ee,$e)},V),0);let je=me>0?me:ye>0?ye:$y;if(f?.isRecording){const K=(f.startSample+f.durationSamples)/Q;je=Math.max(je,K+10)}const Oe=Math.floor(je*Q/Z),oe=async V=>{F(V.id);const K=I?void 0:V.end-V.start;try{await G(V.start,K)}catch(ee){console.error("waveform-playlist: Failed to start playback for annotation",V.id,ee)}},fe=p.useCallback(V=>{if(V>=0&&V<U.length){const K=U[V];ae(K.id)}},[U,ae]),Ze=V=>{const K=V.currentTarget.getBoundingClientRect(),le=(V.clientX-K.left)*Z/Q,He=V.clientY-K.top;let re=0,Ke=-1;for(let et=0;et<Me.length;et++){const Ne=Me[et],ft=Ne.length>0?Math.max(1,...Ne.map(jt=>jt.peaks.data.length)):1,nn=((te?.trackSpectrogramOverrides.get(U[et]?.id)?.renderMode??U[et]?.renderMode??"waveform")==="both"?ft*2:ft)*ke+(o?22:0);if(He>=re&&He<re+nn){Ke=et;break}re+=nn}Ke!==-1&&fe(Ke),kt.current=le,Ye(!0),ue(le),ne(le,le)},Et=V=>{if(!Ve||d)return;const K=V.currentTarget.getBoundingClientRect(),le=(V.clientX-K.left)*Z/Q,$e=Math.min(b,le),He=Math.max(b,le);ne($e,He)},It=V=>{if(!Ve)return;if(Ye(!1),d){const re=Math.max(0,kt.current);ue(re),ne(re,re),G(re);return}const K=V.currentTarget.getBoundingClientRect(),le=(V.clientX-K.left)*Z/Q,$e=Math.min(b,le),He=Math.max(b,le);Math.abs(He-$e)<.1?ue($e):ne($e,He)};if(U.some(V=>V.clips.length>0)&&Me.length===0)return S.jsx("div",{className:a,children:"Loading waveform..."});const dt=Te.show?Me.map((V,K)=>{const ee=U[K];if(!ee)return null;const le=j[K]||{name:`Track ${K+1}`,muted:!1,soloed:!1,volume:1,pan:0},$e=ee.clips.some(Ne=>Ne.midiNotes&&Ne.midiNotes.length>0),He=te?.trackSpectrogramOverrides.get(ee.id)?.renderMode??ee.renderMode??($e?"piano-roll":"waveform"),re=V.length>0?Math.max(1,...V.map(Ne=>Ne.peaks.data.length)):1,Ke=ke*re+(o?bi:0),et=e?e(K):S.jsxs(jv,{onClick:()=>fe(K),children:[S.jsxs(Zv,{style:{justifyContent:"center",position:"relative"},children:[u&&S.jsx(zv,{onClick:Ne=>{Ne.stopPropagation(),u(K)}}),S.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:le.name||`Track ${K+1}`}),te?.renderMenuItems&&S.jsx("span",{style:{position:"absolute",right:0,top:0},children:S.jsx(Jv,{items:Ne=>te.renderMenuItems({renderMode:He,onRenderModeChange:ft=>te.setTrackRenderMode(ee.id,ft),onOpenSettings:()=>Fe(ee.id),onClose:Ne})})})]}),S.jsxs(Vv,{children:[S.jsx(Gl,{$variant:le.muted?"danger":"outline",onClick:()=>L(K,!le.muted),children:"Mute"}),S.jsx(Gl,{$variant:le.soloed?"info":"outline",onClick:()=>z(K,!le.soloed),children:"Solo"})]}),S.jsxs(Xl,{children:[S.jsx(Hv,{}),S.jsx(Ul,{min:"0",max:"1",step:"0.01",value:le.volume,onChange:Ne=>q(K,parseFloat(Ne.target.value))}),S.jsx(Gv,{})]}),S.jsxs(Xl,{children:[S.jsx("span",{children:"L"}),S.jsx(Ul,{min:"-1",max:"1",step:"0.01",value:le.pan,onChange:Ne=>Y(K,parseFloat(Ne.target.value))}),S.jsx("span",{children:"R"})]})]});return S.jsx(Ry,{$height:Ke,$isSelected:ee.id===E,children:et},ee.id)}):void 0;return S.jsxs(jd,{children:[S.jsx(zr.Provider,{value:{samplesPerPixel:Z,sampleRate:Q,zoomLevels:[Z],waveHeight:ke,timeScaleHeight:B,duration:je*1e3,controls:Te,barWidth:Qe,barGap:We},children:S.jsx(wi,{theme:m,backgroundColor:m.playlistBackgroundColor||Jt(m.waveOutlineColor),timescaleBackgroundColor:m.timescaleBackgroundColor,timescaleWidth:Oe,tracksWidth:Oe,controlsWidth:Te.show?Te.width:0,onTracksMouseDown:Ze,onTracksMouseMove:Et,onTracksMouseUp:It,scrollContainerRef:X,isSelecting:Ve,"data-playlist-state":pe?"ready":"loading",trackControlsSlots:dt,timescaleGapHeight:B>0?B+1:0,timescale:B>0?S.jsxs(S.Fragment,{children:[S.jsx(Hd,{renderTick:t}),A&&S.jsx(dv,{startPosition:Math.min(T,R)*Q/Z,endPosition:Math.max(T,R)*Q/Z,markerColor:m.loopMarkerColor,regionColor:m.loopRegionColor,minPosition:0,maxPosition:Oe,onLoopRegionChange:(V,K)=>{const ee=V*Z/Q,le=K*Z/Q;de(ee,le)}})]}):void 0,children:S.jsxs(S.Fragment,{children:[Me.map((V,K)=>{const ee=U[K];if(!ee)return null;const le=ee.clips.some(re=>re.midiNotes&&re.midiNotes.length>0),$e=te?.trackSpectrogramOverrides.get(ee.id)?.renderMode??ee.renderMode??(le?"piano-roll":"waveform"),He=V.length>0?Math.max(1,...V.map(re=>re.peaks.data.length)):1;return S.jsxs(Gd,{numChannels:He,backgroundColor:$e==="piano-roll"?m.pianoRollBackgroundColor||"#1a1a2e":Jt(m.waveOutlineColor),offset:0,width:Oe,hasClipHeaders:o,trackId:ee.id,isSelected:ee.id===E,children:[$e!=="waveform"&&(()=>{const re=Ue.get(ee.id),Ke=re?.config;return!Ke?.labels||!re?null:S.jsx(Iv,{waveHeight:ke,numChannels:He,frequencyScaleFn:re.frequencyScaleFn,minFrequency:Ke.minFrequency??0,maxFrequency:Ke.maxFrequency??Q/2,labelsColor:Ke.labelsColor,labelsBackground:Ke.labelsBackground,renderMode:$e,hasClipHeaders:o})})(),V.map((re,Ke)=>{const et=re.peaks,Ne=et.length;return S.jsx(io,{clipId:re.clipId,trackIndex:K,clipIndex:Ke,trackName:re.trackName,startSample:re.startSample,durationSamples:re.durationSamples,samplesPerPixel:Z,showHeader:o,disableHeaderDrag:!i,isSelected:ee.id===E,trackId:ee.id,fadeIn:re.fadeIn,fadeOut:re.fadeOut,sampleRate:Q,showFades:l,touchOptimized:c,onMouseDown:ft=>{ft.target.closest('[role="button"][aria-roledescription="draggable"]')||fe(K)},children:et.data.map((ft,Mt)=>{const tn=te?.spectrogramDataMap.get(re.clipId),nn=tn?.[Mt]??tn?.[0],jt=Ue.get(ee.id),Jn=jt?.config;return S.jsx(Jl,{index:Mt,data:ft,bits:et.bits,length:Ne,isSelected:ee.id===E,clipStartSample:re.startSample,clipDurationSamples:re.durationSamples,renderMode:re.midiNotes?"piano-roll":$e,midiNotes:re.midiNotes,clipSampleRate:re.sampleRate,clipOffsetSeconds:re.offsetSamples!=null?re.offsetSamples/(re.sampleRate||Q):0,spectrogramData:nn,samplesPerPixel:Z,spectrogramColorLUT:jt?.colorLUT,spectrogramFrequencyScaleFn:jt?.frequencyScaleFn,spectrogramMinFrequency:Jn?.minFrequency,spectrogramMaxFrequency:Jn?.maxFrequency,spectrogramWorkerApi:at,spectrogramClipId:re.clipId,spectrogramOnCanvasesReady:te?(Gr,kn)=>{te.registerSpectrogramCanvases(re.clipId,Mt,Gr,kn)}:void 0},`${re.clipId}-${Mt}`)})},re.clipId)}),f?.isRecording&&f.trackId===ee.id&&f.peaks.length>0&&S.jsx(io,{clipId:"recording-preview",trackIndex:K,clipIndex:V.length,trackName:"Recording...",startSample:f.startSample,durationSamples:f.durationSamples,samplesPerPixel:Z,showHeader:o,disableHeaderDrag:!0,isSelected:ee.id===E,trackId:ee.id,children:S.jsx(Jl,{index:0,data:f.peaks,bits:16,length:Math.floor(f.peaks.length/2),isSelected:ee.id===E,clipStartSample:f.startSample,clipDurationSamples:f.durationSamples},`${ee.id}-recording-0`)},`${ee.id}-recording`)]},ee.id)}),_.length>0&&M&&S.jsx(M.AnnotationBoxesWrapper,{height:30,width:Oe,children:_.map((V,K)=>{const ee=V.start*Q/Z,le=V.end*Q/Z,$e=s?s(V,K):V.id;return S.jsx(M.AnnotationBox,{annotationId:V.id,annotationIndex:K,startPosition:ee,endPosition:le,label:$e,color:"#ff9800",isActive:V.id===x,onClick:()=>oe(V),editable:C},V.id)})}),b!==w&&S.jsx(Vd,{startPosition:Math.min(b,w)*Q/Z,endPosition:Math.max(b,w)*Q/Z,color:m.selectionColor}),(d||b===w)&&(n?n({position:(h.current??0)*Q/Z,color:m.playheadColor,isPlaying:d,currentTimeRef:h,playbackStartTimeRef:v,audioStartPositionRef:y,samplesPerPixel:Z,sampleRate:Q,controlsOffset:0,getAudioContextTime:()=>O.getContext().currentTime,getPlaybackTime:g}):S.jsx(ky,{color:m.playheadColor}))]})})}),te?.SettingsModal&&typeof document<"u"&&mo.createPortal(S.jsx(te.SettingsModal,{open:_e!==null,onClose:()=>Fe(null),config:_e!==null?te.trackSpectrogramOverrides.get(_e)?.config??U.find(V=>V.id===_e)?.spectrogramConfig??te.spectrogramConfig??{}:{},colorMap:_e!==null?te.trackSpectrogramOverrides.get(_e)?.colorMap??U.find(V=>V.id===_e)?.spectrogramColorMap??te.spectrogramColorMap??"viridis":"viridis",onApply:(V,K)=>{_e!==null&&te.setTrackSpectrogramConfig(_e,V,K)}}),document.body)]})},ff=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,controls:r,annotationListConfig:s,scrollActivePosition:a="center",scrollActiveContainer:o="nearest"})=>{const{annotations:i,activeAnnotationId:l,annotationsEditable:c,linkEndpoints:u,continuousPlay:f}=ut(),m=Sn(),{setAnnotations:d}=Pe(),h=s??{linkEndpoints:u,continuousPlay:f},v=p.useCallback(g=>{d(g),n?.(g)},[d,n]),{AnnotationText:y}=m;return S.jsx(y,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:o,editable:c,controls:c?r:void 0,annotationListConfig:h,height:e,onAnnotationUpdate:v,renderAnnotationItem:t})},Dy=({renderTrackControls:e,renderTick:t,renderTimestamp:n,renderPlayhead:r,annotationControls:s,annotationListConfig:a,annotationTextHeight:o,renderAnnotationItem:i,getAnnotationBoxLabel:l,scrollActivePosition:c="center",scrollActiveContainer:u="nearest",className:f,showClipHeaders:m=!1,interactiveClips:d=!1,showFades:h=!1,touchOptimized:v=!1,onRemoveTrack:y,recordingState:g})=>{const{annotations:b}=ut();return S.jsxs(S.Fragment,{children:[S.jsx(df,{renderTrackControls:e,renderTick:t??(n?(w,_)=>n(parseFloat(w)||0,_):void 0),renderPlayhead:r,annotationControls:s,getAnnotationBoxLabel:l,className:f,showClipHeaders:m,interactiveClips:d,showFades:h,touchOptimized:v,onRemoveTrack:y,recordingState:g}),b.length>0&&S.jsx(ff,{height:o,renderAnnotationItem:i,controls:s,annotationListConfig:a,scrollActivePosition:c,scrollActiveContainer:u})]})};var Py=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",hf=Py?p.useLayoutEffect:p.useEffect;function An(e){const t=p.useRef(e);return hf(()=>{t.current=e},[e]),t}function Ca(e,t,n=p.useEffect,r=Object.is){const s=p.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}var Ql=Object.getOwnPropertySymbols,Fy=Object.prototype.hasOwnProperty,Oy=Object.prototype.propertyIsEnumerable,Ly=(e,t)=>{var n={};for(var r in e)Fy.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ql)for(var r of Ql(e))t.indexOf(r)<0&&Oy.call(e,r)&&(n[r]=e[r]);return n},By=new ui,Wy=p.createContext(By),Vy=p.memo(p.forwardRef(({children:e},t)=>{const[n,r]=p.useState(0),s=p.useRef(null),a=p.useRef(null),o=p.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{a.current=l})),p.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return hf(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),p.useImperativeHandle(t,()=>o),null})),ka=[void 0,Sr];function Ny(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:a,onDragMove:o,onDragOver:i,onDragEnd:l}=t,c=Ly(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=p.useRef(null),{plugins:f,modifiers:m,sensors:d}=c,h=Lt(f,On.plugins),v=Lt(d,On.sensors),y=Lt(m,On.modifiers),g=An(s),b=An(a),w=An(i),_=An(o),x=An(l),C=An(r),k=zy(()=>{var I;return(I=c.manager)!=null?I:new ui(c)});return p.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:I,trackRendering:E}=u.current,{monitor:T}=k;k.renderer=I;const R=[T.addEventListener("beforedragstart",A=>{const M=g.current;M&&E(()=>M(A,k))}),T.addEventListener("dragstart",A=>{var M;return(M=b.current)==null?void 0:M.call(b,A,k)}),T.addEventListener("dragover",A=>{const M=w.current;M&&E(()=>M(A,k))}),T.addEventListener("dragmove",A=>{const M=_.current;M&&E(()=>M(A,k))}),T.addEventListener("dragend",A=>{const M=x.current;M&&E(()=>M(A,k))}),T.addEventListener("collision",A=>{var M;return(M=C.current)==null?void 0:M.call(C,A,k)})];return()=>R.forEach(A=>A())},[k]),Ca(h,()=>k&&(k.plugins=h),...ka),Ca(v,()=>k&&(k.sensors=v),...ka),Ca(y,()=>k&&(k.modifiers=y),...ka),S.jsxs(Wy.Provider,{value:k,children:[S.jsx(Vy,{ref:u,children:n}),n]})}function zy(e){const t=p.useRef(null);return t.current||(t.current=e()),p.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var jy=Object.create,pf=Object.defineProperty,Zy=Object.getOwnPropertyDescriptor,mf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),na=e=>{throw TypeError(e)},Hy=(e,t,n)=>t in e?pf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gy=e=>{var t;return[,,,jy((t=e?.[mf("metadata")])!=null?t:null)]},gf=["class","method","getter","setter","accessor","field","value","get","set"],vf=e=>e!==void 0&&typeof e!="function"?na("Function expected"):e,Uy=(e,t,n,r,s)=>({kind:gf[e],name:t,metadata:r,addInitializer:a=>n._?na("Already initialized"):s.push(vf(a||null))}),Xy=(e,t)=>Hy(t,mf("metadata"),e[3]),Yy=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},yf=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=gf[u+5],v=e[d]||(e[d]=[]),y=(s=s.prototype,Zy(s,n)),g=r.length-1;g>=0;g--)l=Uy(u,n,i={},e[3],v),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[g])(y[h],l),i._=1,vf(o)&&(y[h]=o);return y&&pf(s,n,y),s},bf=(e,t,n)=>t.has(e)||na("Cannot "+n),Ky=(e,t,n)=>(bf(e,t,"read from private field"),t.get(e)),qy=(e,t,n)=>t.has(e)?na("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Jy=(e,t,n,r)=>(bf(e,t,"write to private field"),t.set(e,n),n),rr=class co{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new co(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 co(t,n)}},wf,_f,uo,ws,Hr,Ei=class extends(uo=Qt,_f=[Ae],wf=[Ae],uo){constructor(e){const t=rr.from(e);super(t,(n,r)=>rr.equals(n,r)),Yy(Hr,5,this),qy(this,ws,0),this.velocity={x:0,y:0}}get delta(){return rr.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=rr.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),a=s-Ky(this,ws),o=i=>Math.round(i/a*100);qt(()=>{Jy(this,ws,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(rr.from(e)),this.velocity={x:0,y:0}}};Hr=Gy(uo);ws=new WeakMap;yf(Hr,2,"delta",_f,Ei);yf(Hr,2,"direction",wf,Ei);Xy(Hr,Ei);var xf=(e=>(e.Horizontal="x",e.Vertical="y",e))(xf||{});Object.values(xf);var Qy=Object.defineProperty,eb=Object.defineProperties,tb=Object.getOwnPropertyDescriptors,ec=Object.getOwnPropertySymbols,nb=Object.prototype.hasOwnProperty,rb=Object.prototype.propertyIsEnumerable,tc=(e,t,n)=>t in e?Qy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sf=(e,t)=>{for(var n in t||(t={}))nb.call(t,n)&&tc(e,n,t[n]);if(ec)for(var n of ec(t))rb.call(t,n)&&tc(e,n,t[n]);return e},Cf=(e,t)=>eb(e,tb(t)),fo=class extends Wn{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return Cf(Sf({},t),{[n]:r})}};fo.configure=yn(fo);var kf=fo;kf.configure({axis:"x",value:0});var sb=kf.configure({axis:"y",value:0}),nc=class extends Wn{apply({transform:t}){var n;const{size:r=20}=(n=this.options)!=null?n:{},s=typeof r=="number"?r:r.x,a=typeof r=="number"?r:r.y;return Cf(Sf({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/a)*a})}};nc.configure=yn(nc);const Ef=e=>{let t=!1;const n=e.map(r=>r===Ja?(t=!0,Ja.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},ab=P.div`
|
|
1050
1045
|
position: absolute;
|
|
1051
1046
|
top: 0;
|
|
1052
1047
|
left: 0;
|
|
@@ -1056,9 +1051,9 @@ self.onmessage = function(e) {
|
|
|
1056
1051
|
z-index: 100;
|
|
1057
1052
|
pointer-events: none;
|
|
1058
1053
|
will-change: transform;
|
|
1059
|
-
`,
|
|
1054
|
+
`,ob=({color:e="#ff0000"})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s}=Js(),{samplesPerPixel:a,sampleRate:o,progressBarWidth:i}=ea();return p.useEffect(()=>{const l=()=>{if(t.current){const u=(s.current??0)*o/a;t.current.style.transform=`translate3d(${u}px, 0, 0)`}r&&(n.current=requestAnimationFrame(l))};return r?n.current=requestAnimationFrame(l):l(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,o,a,s]),p.useEffect(()=>{if(!r&&t.current){const c=(s.current??0)*o/a;t.current.style.transform=`translate3d(${c}px, 0, 0)`}}),S.jsx(ab,{ref:t,$color:e,$width:i,"data-playhead":!0})},ib=P.div`
|
|
1060
1055
|
position: relative;
|
|
1061
|
-
`,
|
|
1056
|
+
`,lb=P.div`
|
|
1062
1057
|
position: absolute;
|
|
1063
1058
|
top: ${e=>e.$top}px;
|
|
1064
1059
|
left: 0;
|
|
@@ -1068,7 +1063,7 @@ self.onmessage = function(e) {
|
|
|
1068
1063
|
z-index: 0;
|
|
1069
1064
|
transform: translateZ(0);
|
|
1070
1065
|
backface-visibility: hidden;
|
|
1071
|
-
`,
|
|
1066
|
+
`,cb=P.div`
|
|
1072
1067
|
position: absolute;
|
|
1073
1068
|
top: ${e=>e.$top}px;
|
|
1074
1069
|
left: 0;
|
|
@@ -1077,8 +1072,8 @@ self.onmessage = function(e) {
|
|
|
1077
1072
|
pointer-events: none;
|
|
1078
1073
|
z-index: 1;
|
|
1079
1074
|
will-change: width;
|
|
1080
|
-
`,
|
|
1075
|
+
`,ub=P.div`
|
|
1081
1076
|
position: relative;
|
|
1082
1077
|
z-index: 2;
|
|
1083
|
-
`,
|
|
1078
|
+
`,db=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=p.useRef(null),s=p.useRef(null),a=jr(),{waveHeight:o}=Ks(),{isPlaying:i,currentTimeRef:l}=Js(),{samplesPerPixel:c,sampleRate:u}=ea(),f=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";p.useEffect(()=>{const v=()=>{if(r.current){const g=(l.current??0)*u,b=e+t;let w=0;if(g<=e)w=0;else if(g>=b)w=n.length;else{const _=g-e;w=Math.floor(_/c)}r.current.style.width=`${w}px`}i&&(s.current=requestAnimationFrame(v))};return i?s.current=requestAnimationFrame(v):v(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,u,c,e,t,n.length,l]),p.useEffect(()=>{if(!i&&r.current){const y=(l.current??0)*u,g=e+t;let b=0;if(y<=e)b=0;else if(y>=g)b=n.length;else{const w=y-e;b=Math.floor(w/c)}r.current.style.width=`${b}px`}});const m=a?.waveformDrawMode||"inverted";let d;m==="inverted"?d=a?.selectedWaveFillColor||a?.waveFillColor||"white":d=a?.selectedWaveOutlineColor||a?.waveOutlineColor||"grey";const h=Jt(d);return S.jsxs(ib,{children:[S.jsx(lb,{$color:h,$height:o,$top:n.index*o,$width:n.length}),S.jsx(cb,{ref:r,$color:f,$height:o,$top:n.index*o}),S.jsx(ub,{children:S.jsx(Zd,{...n,isSelected:!0,transparentBackground:!0})})]})},If=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:n=!1,onAnnotationUpdate:r,className:s})=>{const a=jr(),{isPlaying:o}=Js(),{annotations:i,activeAnnotationId:l}=Qs(),c=p.useContext(ta),{play:u,seekTo:f,setActiveAnnotationId:m,setAnnotations:d,setScrollContainer:h}=Ci(),{duration:v,peaksDataArray:y,sampleRate:g,waveHeight:b,timeScaleHeight:w,samplesPerPixel:_,controls:x,playoutRef:C,barWidth:k,barGap:I}=ea(),[E,T]=p.useState(0),[R,A]=p.useState(0),[M,$]=p.useState(!1),F=p.useRef(null),L=p.useCallback(j=>{F.current=j,h(j)},[h]),z=Math.floor(v*g/_),q=p.useCallback(async j=>{m(j.id);try{await u(j.start)}catch(U){console.error("waveform-playlist: Failed to start playback for annotation",j.id,U)}},[m,u]),Y=p.useCallback(j=>{d(j),r?.(j)},[d,r]),{onDragStart:ne,onDragMove:G,onDragEnd:J}=Qd({annotations:i,onAnnotationsChange:Y,samplesPerPixel:_,sampleRate:g,duration:v,linkEndpoints:n}),ae=p.useRef(0),ue=p.useCallback(j=>{const U=j.currentTarget.getBoundingClientRect(),Z=(j.clientX-U.left)*_/g;ae.current=Z,$(!0),T(Z),A(Z)},[_,g]),de=p.useCallback(j=>{if(!M)return;const U=j.currentTarget.getBoundingClientRect(),Z=(j.clientX-U.left)*_/g;A(Z)},[M,_,g]),Me=p.useCallback(j=>{if(!M)return;if($(!1),o&&C.current){const B=Math.max(0,ae.current);f(B),T(B),A(B),C.current.stop(),u(B);return}const U=j.currentTarget.getBoundingClientRect(),Z=(j.clientX-U.left)*_/g,Q=Math.min(E,Z),ke=Math.max(E,Z);Math.abs(ke-Q)<.1?(f(Q),T(Q),A(Q)):(T(Q),A(ke))},[M,E,_,g,f,o,C,u]);return y.length===0?S.jsx("div",{className:s,children:"Loading waveform..."}):S.jsx(jd,{children:S.jsx(zr.Provider,{value:{samplesPerPixel:_,sampleRate:g,zoomLevels:[_],waveHeight:b,timeScaleHeight:w,duration:v*1e3,controls:x,barWidth:k,barGap:I},children:S.jsx(wi,{theme:a,backgroundColor:Jt(a.waveOutlineColor),timescaleBackgroundColor:a.timescaleBackgroundColor,timescaleWidth:z,tracksWidth:z,controlsWidth:x.show?x.width:0,onTracksMouseDown:ue,onTracksMouseMove:de,onTracksMouseUp:Me,scrollContainerRef:L,isSelecting:M,timescale:w>0?S.jsx(Hd,{}):void 0,children:S.jsxs(S.Fragment,{children:[y.map((j,U)=>{const ye=j.length>0?Math.max(...j.map(Z=>Z.peaks.data.length)):1;return S.jsx(Gd,{numChannels:ye,backgroundColor:Jt(a.waveOutlineColor),offset:0,width:z,hasClipHeaders:!1,trackId:`media-element-track-${U}`,isSelected:!0,children:j.map((Z,Q)=>{const ke=Z.peaks,B=ke.length;return S.jsx(io,{clipId:Z.clipId,trackIndex:U,clipIndex:Q,trackName:Z.trackName,startSample:Z.startSample,durationSamples:Z.durationSamples,samplesPerPixel:_,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${U}`,children:ke.data.map((Te,Qe)=>S.jsx(db,{index:Qe,data:Te,bits:ke.bits,length:B,clipStartSample:Z.startSample,clipDurationSamples:Z.durationSamples},`${U}-${Q}-${Qe}`))},`${U}-${Q}`)})},U)}),i.length>0&&c&&S.jsx(Ny,{onDragStart:ne,onDragMove:G,onDragEnd:J,modifiers:t?[sb]:[],plugins:Ef,children:S.jsx(c.AnnotationBoxesWrapper,{height:30,width:z,children:i.map((j,U)=>{const ye=j.start*g/_,Z=j.end*g/_,Q=e?e(j,U):j.id;return S.jsx(c.AnnotationBox,{annotationId:j.id,annotationIndex:U,startPosition:ye,endPosition:Z,label:Q,color:"#ff9800",isActive:j.id===l,onClick:()=>q(j),editable:t},j.id)})})}),E!==R&&S.jsx(Vd,{startPosition:Math.min(E,R)*g/_,endPosition:Math.max(E,R)*g/_,color:a.selectionColor}),S.jsx(ob,{color:a.playheadColor})]})})})})},Mf=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,editable:r=!1,controls:s,annotationListConfig:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest"})=>{const{annotations:l,activeAnnotationId:c,continuousPlay:u}=Qs(),f=Sn(),{setAnnotations:m}=Ci(),d=a??{linkEndpoints:!1,continuousPlay:u},h=p.useCallback(y=>{m(y),n?.(y)},[m,n]),{AnnotationText:v}=f;return S.jsx(v,{annotations:l,activeAnnotationId:c??void 0,shouldScrollToActive:!0,scrollActivePosition:o,scrollActiveContainer:i,editable:r,controls:r?s:void 0,annotationListConfig:d,height:e,onAnnotationUpdate:h,renderAnnotationItem:t})},fb=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:n,editable:r=!1,linkEndpoints:s=!1,onAnnotationUpdate:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest",className:l})=>{const{annotations:c}=Qs();return S.jsxs(S.Fragment,{children:[S.jsx(If,{getAnnotationBoxLabel:t,editable:r,linkEndpoints:s,onAnnotationUpdate:a,className:l}),c.length>0&&S.jsx(Mf,{height:e,renderAnnotationItem:n,onAnnotationUpdate:a,editable:r,annotationListConfig:{linkEndpoints:s,continuousPlay:!1},scrollActivePosition:o,scrollActiveContainer:i})]})},Bs=class Bs extends Wn{apply(t){const{transform:n,source:r}=t;if(!r?.data||!this.options)return n;const{boundary:s,trackIndex:a,clipIndex:o}=r.data;if(s)return{x:0,y:0};const{tracks:i,samplesPerPixel:l}=this.options,c=i[a];if(!c)return n;const u=c.clips[o];if(!u)return n;const f=n.x*l,m=[...c.clips].sort((v,y)=>v.startSample-y.startSample),d=m.findIndex(v=>v.id===u.id);return{x:fc(u,f,m,d)/l,y:0}}};Bs.configure=yn(Bs);let ho=Bs;const Ws=class Ws extends Wn{apply(t){const{transform:n,source:r}=t;if(!this.options||!r?.data)return n;const{boundary:s,startSample:a}=r.data;if(s)return n;const{samplesPerPixel:o}=this.options;if(this.options.mode==="temporal"){const{gridSamples:y}=this.options;if(a!==void 0){const w=a+n.x*o;return{x:(Math.round(w/y)*y-a)/o,y:0}}const g=n.x*o;return{x:Math.round(g/y)*y/o,y:0}}const{snapTo:i,bpm:l,timeSignature:c,sampleRate:u}=this.options;if(i==="off")return n;const f=i==="bar"?lc(c):go(c);if(a!==void 0){const y=a+n.x*o,g=rl(y,l,u),b=sl(g,f);return{x:(mr(b,l,u)-a)/o,y:0}}const m=n.x*o,d=rl(m,l,u),h=sl(d,f);return{x:mr(h,l,u)/o,y:0}}};Ws.configure=yn(Ws);let po=Ws;exports.Tone=sc;exports.AnnotationIntegrationProvider=yy;exports.AudioPosition=my;exports.AutomaticScrollCheckbox=vy;exports.ClipCollisionModifier=ho;exports.ContinuousPlayCheckbox=by;exports.DownloadAnnotationsButton=xy;exports.EditableCheckbox=_y;exports.ExportWavButton=Sy;exports.FastForwardButton=ay;exports.LinkEndpointsCheckbox=wy;exports.LoopButton=ly;exports.MasterVolumeControl=fy;exports.MediaElementAnnotationList=Mf;exports.MediaElementPlaylist=If;exports.MediaElementPlaylistProvider=ey;exports.MediaElementWaveform=fb;exports.PauseButton=ny;exports.PlayButton=ty;exports.PlaylistAnnotationList=ff;exports.PlaylistVisualization=df;exports.RewindButton=sy;exports.SelectionTimeInputs=gy;exports.SetLoopRegionButton=cy;exports.SkipBackwardButton=oy;exports.SkipForwardButton=iy;exports.SnapToGridModifier=po;exports.SpectrogramIntegrationProvider=Ay;exports.StopButton=ry;exports.TimeFormatSelect=hy;exports.Waveform=Dy;exports.WaveformPlaylistProvider=q0;exports.ZoomInButton=uy;exports.ZoomOutButton=dy;exports.createEffectChain=L0;exports.createEffectInstance=$r;exports.effectCategories=D0;exports.effectDefinitions=Zr;exports.getEffectDefinition=Si;exports.getEffectsByCategory=R0;exports.getShortcutLabel=A0;exports.getWaveformDataMetadata=g0;exports.loadPeaksFromWaveformData=m0;exports.loadWaveformData=xi;exports.noDropAnimationPlugins=Ef;exports.useAnnotationDragHandlers=Qd;exports.useAnnotationIntegration=Sn;exports.useAnnotationKeyboardControls=$0;exports.useAudioTracks=S0;exports.useClipDragHandlers=k0;exports.useClipSplitting=M0;exports.useDragSensors=I0;exports.useDynamicEffects=B0;exports.useDynamicTracks=K0;exports.useExportWav=ef;exports.useKeyboardShortcuts=Ls;exports.useMasterAnalyser=_0;exports.useMasterVolume=Jd;exports.useMediaElementAnimation=Js;exports.useMediaElementControls=Ci;exports.useMediaElementData=ea;exports.useMediaElementState=Qs;exports.usePlaybackAnimation=ct;exports.usePlaybackShortcuts=T0;exports.usePlaylistControls=Pe;exports.usePlaylistData=yt;exports.usePlaylistState=ut;exports.useSpectrogramIntegration=Ty;exports.useTimeFormat=Kd;exports.useTrackDynamicEffects=W0;exports.useZoomControls=qd;exports.waveformDataToPeaks=Xd;
|
|
1084
1079
|
//# sourceMappingURL=index.js.map
|