@waveform-playlist/browser 9.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +63 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1686 -1634
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -10
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var gf=Object.create;var zi=Object.defineProperty;var vf=Object.getOwnPropertyDescriptor;var yf=Object.getOwnPropertyNames;var bf=Object.getPrototypeOf,wf=Object.prototype.hasOwnProperty;var _f=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of yf(t))!wf.call(e,s)&&s!==n&&zi(e,s,{get:()=>t[s],enumerable:!(r=vf(t,s))||r.enumerable});return e};var xf=(e,t,n)=>(n=e!=null?gf(bf(e)):{},_f(t||!e||!e.__esModule?zi(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("tone"),C=require("react/jsx-runtime"),f=require("react"),R=require("styled-components"),ro=require("react-dom");function Ll(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 zl=Ll(j),D=Ll(f);var Ye=1e3;function ma(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate,u=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(u===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 p=e.durationSamples??u;return{id:Hl(),audioBuffer:t,startSample:n,durationSamples:p,offsetSamples:r,sampleRate:d,sourceDurationSamples:u,gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c}}function jl(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c}=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 u=t?.duration??e.sourceDuration??c?.duration;if(u===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 p=e.duration??u;return ma({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(p*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(u*d),gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c})}function Zl(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:d}=e;return{id:Hl(),name:t,clips:n,muted:r,soloed:s,volume:a,pan:o,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:d}}function Hl(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ji(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function Zi(e){return e.startSample/e.sampleRate}function Cf(e){return(e.startSample+e.durationSamples)/e.sampleRate}function kf(e){return e.offsetSamples/e.sampleRate}function Sf(e){return e.durationSamples/e.sampleRate}var Hi=!1;function ga(e){const t=e._param;return!t&&!Hi&&(Hi=!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 Ni(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 Ef(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 If(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 Af(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 Nl(e,t,n){switch(e){case"linear":return Ni(t,n);case"exponential":return Ef(t,n);case"sCurve":return If(t,n);case"logarithmic":return Af(t,n);default:return Ni(t,n)}}function Xi(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=Nl(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 Gi(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=Nl(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 Mf=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new j.Volume(this.gainToDb(e.track.gain)),this.panNode=new j.Panner(e.track.stereoPan),this.muteGain=new j.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||j.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=j.getTransport(),s=j.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(d=>{l<this._scheduleGuardOffset||this.startClipSource(o,i,d)},l);return{clipInfo:o,fadeGainNode:i,scheduleId:c}})}startClipSource(e,t,n,r,s){const o=j.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)Xi(a,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,c=o/i,d=r.gain*c;Xi(a,t,l,r.fadeIn.type||"linear",d,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;Gi(a,c,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const c=-l,d=r.fadeOut.duration-c,u=c/r.fadeOut.duration,p=r.gain*(1-u);Gi(a,t,d,r.fadeOut.type||"linear",p,0)}}}prepareFades(e,t){this.scheduledClips.forEach(n=>{const r=this.track.startTime+n.clipInfo.startTime,s=r+n.clipInfo.duration;if(!(t>=s))if(t>=r){const 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;ga(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=j.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}},$f=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 j.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,j.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{j.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await j.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new Mf(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??j.now(),s=j.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=j.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=j.getTransport();try{e.stop()}catch(t){console.warn("[waveform-playlist] Transport.stop() failed:",t)}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=j.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=j.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 j.getTransport().seconds}seekTo(e){j.getTransport().seconds=e}dispose(){if(this.clearCompletionEvent(),this._loopHandler){try{j.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 j.getContext()}get sampleRate(){return j.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Ur=null;function Tf(){return Ur||(Ur=new j.Context,j.setContext(Ur)),Ur}function Df(){return Tf().rawContext}function Rf(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(u){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",u)}t=null}r++;const d=r;t=new $f({effects:e?.effects}),i&&t.init().catch(u=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",u),i=!1});for(const u of c){const p=u.clips.filter(m=>m.audioBuffer);if(p.length===0)continue;const h=Math.min(...p.map(Zi)),g=Math.max(...p.map(Cf)),w={id:u.id,name:u.name,gain:u.volume,muted:u.muted,soloed:u.soloed,stereoPan:u.pan,startTime:h,endTime:g},v=p.map(m=>({buffer:m.audioBuffer,startTime:Zi(m)-h,duration:Sf(m),offset:kf(m),fadeIn:m.fadeIn,fadeOut:m.fadeOut,gain:m.gain}));t.addTrack({clips:v,track:w,effects:u.effects})}t.applyInitialSoloState(),t.setLoop(s,a,o),t.setOnPlaybackComplete(()=>{d===r&&(n=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(c){l(c)},play(c,d){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 u=d!==void 0?d-c:void 0;t.play(j.now(),c,u),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,d){t?.getTrack(c)?.setVolume(d)},setTrackMute(c,d){t?.setMute(c,d)},setTrackSolo(c,d){t?.setSolo(c,d)},setTrackPan(c,d){t?.getTrack(c)?.setPan(d)},setLoop(c,d,u){s=c,a=d,o=u,t?.setLoop(c,d,u)},dispose(){try{t?.dispose()}catch(c){console.warn("[waveform-playlist] Error disposing playout:",c)}t=null,n=!1}}}function Xl(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 va(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 Pf(e,t){return Math.floor(e/t)*t}function Wf(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=ma({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=ma({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 Gl(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 Qs(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 Yi(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 Ui(e,t){return Math.max(0,Math.min(e,t))}var Ff=44100,Of=1e3,Bf=[256,512,1024,2048,4096,8192],Ki=.1,Vf=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??Ff,this._zoomLevels=[...e.zoomLevels??Bf],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??Of;this._zoomIndex=Yi(t,this._zoomLevels)}getState(){return{tracks:this._tracks.map(e=>({...e,clips:[...e.clips]})),tracksVersion:this._tracksVersion,duration:Qs(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=ji(r.clips),i=o.findIndex(c=>c.id===t),l=Xl(a,n,o,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const d=c.clips.map((u,p)=>p===s?{...u,startSample:Math.floor(u.startSample+l)}:u);return{...c,clips:d}}),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(Ki*this._sampleRate);if(!Gl(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}=Wf(a,n);this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const d=[...c.clips];return d.splice(s,1,i,l),{...c,clips:d}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}trimClip(e,t,n,r){const s=this._tracks.find(u=>u.id===e);if(!s){console.warn(`[waveform-playlist/engine] trimClip: track "${e}" not found`);return}const a=s.clips.findIndex(u=>u.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=ji(s.clips),l=i.findIndex(u=>u.id===t),c=Math.floor(Ki*this._sampleRate),d=va(o,r,n,i,l,c);d!==0&&(this._tracks=this._tracks.map(u=>{if(u.id!==e)return u;const p=u.clips.map((h,g)=>g!==a?h:n==="left"?{...h,startSample:h.startSample+d,offsetSamples:h.offsetSamples+d,durationSamples:h.durationSamples-d}:{...h,durationSamples:h.durationSamples+d});return{...u,clips:p}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}async init(){this._adapter&&await this._adapter.init()}play(e,t){const n=this._currentTime,r=this._playStartPosition;if(e!==void 0){const s=Qs(this._tracks);this._currentTime=Ui(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._loopStart&&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=Qs(this._tracks);this._currentTime=Ui(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._shouldActivateTransportLoop(),this._loopStart,this._loopEnd),this._emitStateChange())}setLoopEnabled(e){e!==this._isLoopEnabled&&(this._isLoopEnabled=e,this._adapter?.setLoop(e&&this._shouldActivateTransportLoop(),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=Yi(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)}}_emitStateChange(){this._emit("statechange",this.getState())}_shouldActivateTransportLoop(){if(!this._isPlaying)return!0;const e=this._adapter?.getCurrentTime()??this._currentTime;return e>=this._loopStart&&e<this._loopEnd}_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)}},Lf=Symbol.for("preact-signals");function Rs(){if(Ut>1)Ut--;else{for(var e,t=!1;hr!==void 0;){var n=hr;for(hr=void 0,ya++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Ul(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(ya=0,Ut--,t)throw e}}function Kt(e){if(Ut>0)return e();Ut++;try{return e()}finally{Rs()}}var pe=void 0;function _e(e){var t=pe;pe=void 0;try{return e()}finally{pe=t}}var hr=void 0,Ut=0,ya=0,ms=0;function Yl(e){if(pe!==void 0){var t=e.n;if(t===void 0||t.t!==pe)return t={i:0,S:e,p:pe.s,n:void 0,t:pe,e:void 0,x:void 0,r:t},pe.s!==void 0&&(pe.s.n=t),pe.s=t,e.n=t,32&pe.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=pe.s,t.n=void 0,pe.s.n=t,pe.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=Lf;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:_e(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&&_e(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=pe;pe=void 0;try{e(n)}finally{pe=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=pe;pe=void 0;try{return this.value}finally{pe=e}};Object.defineProperty(st.prototype,"value",{get:function(){var e=Yl(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ya>100)throw new Error("Cycle detected");this.v=e,this.i++,ms++,Ut++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Rs()}}}});function Mr(e,t){return new st(e,t)}function Ul(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 Kl(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 ql(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=ms-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===ms))return!0;if(this.g=ms,this.f|=1,this.i>0&&!Ul(this))return this.f&=-2,!0;var e=pe;try{Kl(this),pe=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 pe=e,ql(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=Yl(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function qi(e,t){return new gn(e,t)}function Jl(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Ut++;var n=pe;pe=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,so(e),r}finally{pe=n,Rs()}}}function so(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Jl(e)}function zf(e){if(pe!==this)throw new Error("Out-of-order effect");ql(this),pe=e,this.f&=-2,8&this.f&&so(this),Rs()}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,Jl(this),Kl(this),Ut++;var e=pe;return pe=this,zf.bind(this,e)};jn.prototype.N=function(){2&this.f||(this.f|=2,this.o=hr,hr=this)};jn.prototype.d=function(){this.f|=8,1&this.f||so(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 jf=Object.create,ao=Object.defineProperty,Zf=Object.defineProperties,Hf=Object.getOwnPropertyDescriptor,Nf=Object.getOwnPropertyDescriptors,Ji=Object.getOwnPropertySymbols,Xf=Object.prototype.hasOwnProperty,Gf=Object.prototype.propertyIsEnumerable,Yf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},ba=(e,t,n)=>t in e?ao(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uf=(e,t)=>{for(var n in t||(t={}))Xf.call(t,n)&&ba(e,n,t[n]);if(Ji)for(var n of Ji(t))Gf.call(t,n)&&ba(e,n,t[n]);return e},Kf=(e,t)=>Zf(e,Nf(t)),Qi=(e,t)=>ao(e,"name",{value:t,configurable:!0}),qf=e=>{var t;return[,,,jf((t=void 0)!=null?t:null)]},Ql=["class","method","getter","setter","accessor","field","value","get","set"],nr=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,Jf=(e,t,n,r,s)=>({kind:Ql[e],name:t,metadata:r,addInitializer:a=>n._?Zn("Already initialized"):s.push(nr(a||null))}),ec=(e,t)=>ba(t,Yf("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},Hn=(e,t,n,r,s,a)=>{var o,i,l,c,d,u=t&7,p=!!(t&8),h=!!(t&16),g=u>3?e.length+1:u?p?1:2:0,w=Ql[u+5],v=u>3&&(e[g-1]=[]),m=e[g]||(e[g]=[]),b=u&&(!h&&!p&&(s=s.prototype),u<5&&(u>3||!h)&&Hf(u<4?s:{get[n](){return fn(this,a)},set[n](y){return Xt(this,a,y)}},n));u?h&&u<4&&Qi(a,(u>2?"set ":u>1?"get ":"")+n):Qi(s,n);for(var _=r.length-1;_>=0;_--)c=Jf(u,n,l={},e[3],m),u&&(c.static=p,c.private=h,d=c.access={has:h?y=>Qf(s,y):y=>n in y},u^3&&(d.get=h?y=>(u^1?fn:eh)(y,s,u^4?a:b.get):y=>y[n]),u>2&&(d.set=h?(y,x)=>Xt(y,s,x,u^4?a:b.set):(y,x)=>y[n]=x)),i=(0,r[_])(u?u<4?h?a:b[w]:u>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,u^4||i===void 0?nr(i)&&(u>4?v.unshift(i):u?h?a=i:b[w]=i:s=i):typeof i!="object"||i===null?Zn("Object expected"):(nr(o=i.get)&&(b.get=o),nr(o=i.set)&&(b.set=o),nr(o=i.init)&&v.unshift(o));return u||ec(e,s),b&&ao(s,n,b),h?u^4?a:b:s},oo=(e,t,n)=>t.has(e)||Zn("Cannot "+n),Qf=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),fn=(e,t,n)=>(oo(e,t,"read from private field"),n?n.call(e):t.get(e)),Kr=(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),Xt=(e,t,n,r)=>(oo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),eh=(e,t,n)=>(oo(e,t,"access private method"),n);function gs(e,t){if(t){let n;return qi(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return qi(e)}function br(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)=>!br(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=>!br(e[a],t[a]))}return!1}function ue({get:e},t){return{init(n){return Mr(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=gs(e.bind(this)),n.set(this,r)),r.value}}function ea(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,Kf(Uf({},s),{enumerable:e}))})}}function $r(...e){const t=e.map(n=>Ct(n));return()=>t.forEach(n=>n())}var tc,nc,rc,sc,ac,oc,tt,io,ta,wa,_a,qe,lo,na,ic,xa,co,ra,Ca,ka;oc=[ue],ac=[ue],sc=[ue],rc=[ea()],nc=[ea()],tc=[ea()];var Jt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,sn(tt,5,this),Kr(this,qe),Kr(this,io,sn(tt,8,this)),sn(tt,11,this),Kr(this,lo,sn(tt,12,this)),sn(tt,15,this),Kr(this,co,sn(tt,16,this)),sn(tt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return fn(this,qe,Ca)}get initial(){return fn(this,qe,wa)}get previous(){return fn(this,qe,ic)}set current(e){const t=_e(()=>fn(this,qe,Ca));e&&t&&this.equals(t,e)||Kt(()=>{fn(this,qe,wa)||Xt(this,qe,e,_a),Xt(this,qe,t,xa),Xt(this,qe,e,ka)})}reset(e=this.defaultValue){Kt(()=>{Xt(this,qe,void 0,xa),Xt(this,qe,e,_a),Xt(this,qe,e,ka)})}};tt=qf();io=new WeakMap;qe=new WeakSet;lo=new WeakMap;co=new WeakMap;ta=Hn(tt,20,"#initial",oc,qe,io),wa=ta.get,_a=ta.set;na=Hn(tt,20,"#previous",ac,qe,lo),ic=na.get,xa=na.set;ra=Hn(tt,20,"#current",sc,qe,co),Ca=ra.get,ka=ra.set;Hn(tt,2,"current",rc,Jt);Hn(tt,2,"initial",nc,Jt);Hn(tt,2,"previous",tc,Jt);ec(tt,Jt);function sa(e){return _e(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var th=Object.create,lc=Object.defineProperty,nh=Object.getOwnPropertyDescriptor,el=Object.getOwnPropertySymbols,rh=Object.prototype.hasOwnProperty,sh=Object.prototype.propertyIsEnumerable,cc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ps=e=>{throw TypeError(e)},tl=Math.pow,Sa=(e,t,n)=>t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ah=(e,t)=>{for(var n in t||(t={}))rh.call(t,n)&&Sa(e,n,t[n]);if(el)for(var n of el(t))sh.call(t,n)&&Sa(e,n,t[n]);return e},oh=e=>{var t;return[,,,th((t=e?.[cc("metadata")])!=null?t:null)]},uc=["class","method","getter","setter","accessor","field","value","get","set"],dc=e=>e!==void 0&&typeof e!="function"?Ps("Function expected"):e,ih=(e,t,n,r,s)=>({kind:uc[e],name:t,metadata:r,addInitializer:a=>n._?Ps("Already initialized"):s.push(dc(a||null))}),lh=(e,t)=>Sa(t,cc("metadata"),e[3]),ch=(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},fc=(e,t,n,r,s,a)=>{for(var o,i,l,c,d=t&7,u=!1,p=!1,h=2,g=uc[d+5],w=e[h]||(e[h]=[]),v=(s=s.prototype,nh(s,n)),m=r.length-1;m>=0;m--)l=ih(d,n,i={},e[3],w),l.static=u,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[m])(v[g],l),i._=1,dc(o)&&(v[g]=o);return v&&lc(s,n,v),s},hc=(e,t,n)=>t.has(e)||Ps("Cannot "+n),uh=(e,t,n)=>(hc(e,t,"read from private field"),t.get(e)),dh=(e,t,n)=>t.has(e)?Ps("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),fh=(e,t,n,r)=>(hc(e,t,"write to private field"),t.set(e,n),n),Tt=class Ea{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ea(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 Ea(t,n)}},Tr=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=ah({},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 Tt((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?hh(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 Tt.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 hh(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 pc,mc,Ia,rs,Dr,Ws=class extends(Ia=Jt,mc=[Ae],pc=[Ae],Ia){constructor(t){const n=Tt.from(t);super(n,(r,s)=>Tt.equals(r,s)),ch(Dr,5,this),dh(this,rs,0),this.velocity={x:0,y:0}}get delta(){return Tt.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=Tt.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-uh(this,rs),i=l=>Math.round(l/o*100);Kt(()=>{fh(this,rs,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Tt.from(t)),this.velocity={x:0,y:0}}};Dr=oh(Ia);rs=new WeakMap;fc(Dr,2,"delta",mc,Ws);fc(Dr,2,"direction",pc,Ws);lh(Dr,Ws);function Aa({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(tl(r,2)+tl(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 gc=(e=>(e.Horizontal="x",e.Vertical="y",e))(gc||{}),vc=Object.values(gc),ph=Object.create,uo=Object.defineProperty,mh=Object.defineProperties,gh=Object.getOwnPropertyDescriptor,vh=Object.getOwnPropertyDescriptors,vs=Object.getOwnPropertySymbols,yc=Object.prototype.hasOwnProperty,bc=Object.prototype.propertyIsEnumerable,wc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Nn=e=>{throw TypeError(e)},Ma=(e,t,n)=>t in e?uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_c=(e,t)=>{for(var n in t||(t={}))yc.call(t,n)&&Ma(e,n,t[n]);if(vs)for(var n of vs(t))bc.call(t,n)&&Ma(e,n,t[n]);return e},xc=(e,t)=>mh(e,vh(t)),nl=(e,t)=>uo(e,"name",{value:t,configurable:!0}),Cc=(e,t)=>{var n={};for(var r in e)yc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&vs)for(var r of vs(e))t.indexOf(r)<0&&bc.call(e,r)&&(n[r]=e[r]);return n},Xn=e=>{var t;return[,,,ph((t=e?.[wc("metadata")])!=null?t:null)]},kc=["class","method","getter","setter","accessor","field","value","get","set"],rr=e=>e!==void 0&&typeof e!="function"?Nn("Function expected"):e,yh=(e,t,n,r,s)=>({kind:kc[e],name:t,metadata:r,addInitializer:a=>n._?Nn("Already initialized"):s.push(rr(a||null))}),vn=(e,t)=>Ma(t,wc("metadata"),e[3]),Q=(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,d,u=t&7,p=!!(t&8),h=!!(t&16),g=u>3?e.length+1:u?p?1:2:0,w=kc[u+5],v=u>3&&(e[g-1]=[]),m=e[g]||(e[g]=[]),b=u&&(!h&&!p&&(s=s.prototype),u<5&&(u>3||!h)&&gh(u<4?s:{get[n](){return He(this,a)},set[n](y){return wt(this,a,y)}},n));u?h&&u<4&&nl(a,(u>2?"set ":u>1?"get ":"")+n):nl(s,n);for(var _=r.length-1;_>=0;_--)c=yh(u,n,l={},e[3],m),u&&(c.static=p,c.private=h,d=c.access={has:h?y=>bh(s,y):y=>n in y},u^3&&(d.get=h?y=>(u^1?He:wh)(y,s,u^4?a:b.get):y=>y[n]),u>2&&(d.set=h?(y,x)=>wt(y,s,x,u^4?a:b.set):(y,x)=>y[n]=x)),i=(0,r[_])(u?u<4?h?a:b[w]:u>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,u^4||i===void 0?rr(i)&&(u>4?v.unshift(i):u?h?a=i:b[w]=i:s=i):typeof i!="object"||i===null?Nn("Object expected"):(rr(o=i.get)&&(b.get=o),rr(o=i.set)&&(b.set=o),rr(o=i.init)&&v.unshift(o));return u||vn(e,s),b&&uo(s,n,b),h?u^4?a:b:s},fo=(e,t,n)=>t.has(e)||Nn("Cannot "+n),bh=(e,t)=>Object(t)!==t?Nn('Cannot use the "in" operator on this value'):e.has(t),He=(e,t,n)=>(fo(e,t,"read from private field"),n?n.call(e):t.get(e)),we=(e,t,n)=>t.has(e)?Nn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),wt=(e,t,n,r)=>(fo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),wh=(e,t,n)=>(fo(e,t,"access private method"),n);function Sc(e,t){return{plugin:e,options:t}}function Gn(e){return t=>Sc(e,t)}function ho(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Ec,wr,po,ss;Ec=[ue];var lt=class{constructor(e,t){this.manager=e,this.options=t,we(this,po,Q(wr,8,this,!1)),Q(wr,11,this),we(this,ss,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return _e(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=Ct(e.bind(this));return He(this,ss).add(t),t}destroy(){He(this,ss).forEach(e=>e())}static configure(e){return Sc(this,e)}};wr=Xn(null);po=new WeakMap;ss=new WeakMap;ce(wr,4,"disabled",Ec,lt,po);vn(wr,lt);var Rr=class extends lt{},as,aa=class{constructor(e){this.manager=e,this.instances=new Map,we(this,as,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(ho).reduceRight((r,s)=>r.some(({plugin:a})=>a===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 Rr)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 _h(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var qr=[],Mn,$n,xh=class extends lt{constructor(e){super(e),we(this,Mn),we(this,$n),this.computeCollisions=this.computeCollisions.bind(this),wt(this,$n,Mr(qr)),this.destroy=$r(()=>{const t=this.computeCollisions(),n=_e(()=>this.manager.dragOperation.position.current);if(t!==qr){const r=He(this,Mn);if(wt(this,Mn,n),r&&n.x==r.x&&n.y==r.y)return}else wt(this,Mn,void 0);He(this,$n).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){_e(()=>{e?He(this,$n).value=this.computeCollisions():wt(this,Mn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:a,status:o}=r;if(!o.initialized||!a)return qr;const i=[],l=[];for(const c of e??n.droppables){if(c.disabled||s&&!c.accepts(s))continue;const d=t??c.collisionDetector;if(!d)continue;l.push(c),c.shape;const u=_e(()=>d({droppable:c,dragOperation:r}));u&&(c.collisionPriority!=null&&(u.priority=c.collisionPriority),i.push(u))}return l.length===0?qr:(i.sort(_h),i)}get collisions(){return He(this,$n).value}};Mn=new WeakMap;$n=new WeakMap;var Ch=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 Ch{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function os(e,t=!0){let n=!1;return xc(_c({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Sh=class extends Rr{constructor(e){super(e);const t=(r,s)=>r.map(({id:a})=>a).join("")===s.map(({id:a})=>a).join("");let n=[];this.destroy=$r(()=>{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=os({collisions:a});if(s.dispatch("collision",o),o.defaultPrevented||t(a,n))return;n=a;const[i]=a;_e(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},mo=(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))(mo||{}),go=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(go||{}),Ic,Ac,Mc,$c,Tc,Dc,Rc,xt,vo;Rc=[ue],Dc=[Ae],Tc=[Ae],$c=[Ae],Mc=[Ae],Ac=[Ae],Ic=[Ae];var zt=class{constructor(){Q(xt,5,this),we(this,vo,Q(xt,8,this,"idle")),Q(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=Xn(null);vo=new WeakMap;ce(xt,4,"value",Rc,zt,vo);ce(xt,2,"current",Dc,zt);ce(xt,2,"idle",Tc,zt);ce(xt,2,"initializing",$c,zt);ce(xt,2,"initialized",Mc,zt);ce(xt,2,"dragging",Ac,zt);ce(xt,2,"dropped",Ic,zt);vn(xt,zt);var Eh=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 _e(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=os({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return _e(()=>{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;Kt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(a)});const o=os({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 _e(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:a}=r;if(!s.dragging||!a||a.signal.aborted)return;const o=os({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,d,u;if(o.defaultPrevented)return;const p=(u=e.to)!=null?u:{x:r.position.current.x+((l=(i=e.by)==null?void 0:i.x)!=null?l:0),y:r.position.current.y+((d=(c=e.by)==null?void 0:c.y)!=null?d:0)};r.position.current=p})})}stop(e={}){return _e(()=>{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,d)=>{l.resume=c,l.abort=d}),l};s.abort();const i=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=_e(()=>{var d;return((d=r.source)==null?void 0:d.status)==="dropping"}),c=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:d}=r,u=Ct(()=>{d?.status==="idle"&&(u(),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()})}},Pc,Wc,Fc,Oc,it,yo,bo,wo,_o;Oc=[ue],Fc=[ue],Wc=[ue],Pc=[ue];var Qt=class{constructor(e,t){we(this,yo,Q(it,8,this)),Q(it,11,this),we(this,bo,Q(it,12,this)),Q(it,15,this),we(this,wo,Q(it,16,this)),Q(it,19,this),we(this,_o,Q(it,20,this)),Q(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:d}=this;if(c!==i)return d?.registry.register(this),()=>d?.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=Xn(null);yo=new WeakMap;bo=new WeakMap;wo=new WeakMap;_o=new WeakMap;ce(it,4,"manager",Oc,Qt,yo);ce(it,4,"id",Fc,Qt,bo);ce(it,4,"data",Wc,Qt,wo);ce(it,4,"disabled",Pc,Qt,_o);vn(it,Qt);var rl=class{constructor(){this.map=Mr(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=$r(...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}},Bc,Vc,Lc,zc,jc,Zc,$a,nt,xo,Co,ko,Dt=class extends($a=Qt,Zc=[ue],jc=[ue],zc=[ue],Lc=[Ae],Vc=[Ae],Bc=[Ae],$a){constructor(t,n){var r=t,{modifiers:s,type:a,sensors:o}=r,i=Cc(r,["modifiers","type","sensors"]);super(i,n),Q(nt,5,this),we(this,xo,Q(nt,8,this)),Q(nt,11,this),we(this,Co,Q(nt,12,this)),Q(nt,15,this),we(this,ko,Q(nt,16,this,this.isDragSource?"dragging":"idle")),Q(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=Xn($a);xo=new WeakMap;Co=new WeakMap;ko=new WeakMap;ce(nt,4,"type",Zc,Dt,xo);ce(nt,4,"modifiers",jc,Dt,Co);ce(nt,4,"status",zc,Dt,ko);ce(nt,2,"isDropping",Lc,Dt);ce(nt,2,"isDragging",Vc,Dt);ce(nt,2,"isDragSource",Bc,Dt);vn(nt,Dt);var Hc,Nc,Xc,Gc,Yc,Uc,Ta,Ve,So,Eo,Io,Ao,Mo,Rt=class extends(Ta=Qt,Uc=[ue],Yc=[ue],Gc=[ue],Xc=[ue],Nc=[ue],Hc=[Ae],Ta){constructor(t,n){var r=t,{accept:s,collisionDetector:a,collisionPriority:o,type:i}=r,l=Cc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),Q(Ve,5,this),we(this,So,Q(Ve,8,this)),Q(Ve,11,this),we(this,Eo,Q(Ve,12,this)),Q(Ve,15,this),we(this,Io,Q(Ve,16,this)),Q(Ve,19,this),we(this,Ao,Q(Ve,20,this)),Q(Ve,23,this),we(this,Mo,Q(Ve,24,this)),Q(Ve,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}};Ve=Xn(Ta);So=new WeakMap;Eo=new WeakMap;Io=new WeakMap;Ao=new WeakMap;Mo=new WeakMap;ce(Ve,4,"accept",Uc,Rt,So);ce(Ve,4,"type",Yc,Rt,Eo);ce(Ve,4,"collisionDetector",Gc,Rt,Io);ce(Ve,4,"collisionPriority",Xc,Rt,Ao);ce(Ve,4,"shape",Nc,Rt,Mo);ce(Ve,2,"isDropTarget",Hc,Rt);vn(Ve,Rt);var On=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Ih=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)}},is,Kc=class{constructor(e){this.options=e,we(this,is)}set controller(e){wt(this,is,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=He(this,is))==null||t.activate(e)}};is=new WeakMap;var _r=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Ah=class{constructor(e){this.draggables=new rl,this.droppables=new rl,this.plugins=new aa(e),this.sensors=new aa(e),this.modifiers=new aa(e)}register(e,t){if(e instanceof Dt)return this.draggables.register(e.id,e);if(e instanceof Rt)return this.droppables.register(e.id,e);if(e.prototype instanceof _r)return this.modifiers.register(e,t);if(e.prototype instanceof On)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 Qt)return e instanceof Dt?this.draggables.unregister(e.id,e):e instanceof Rt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof _r)return this.modifiers.unregister(e);if(e.prototype instanceof On)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()}},qc,Jc,Qc,eu,tu,nu,ru,su,au,sr,ls,Tn,Me,$o,To,Do,Ro,Po,ar;au=[Ae],su=[ue],ru=[ue],nu=[ue],tu=[ue],eu=[ue],Qc=[Ae],Jc=[Ae],qc=[Ae];var It=class{constructor(e){Q(Me,5,this),we(this,sr),we(this,ls),we(this,Tn,new Jt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new zt,we(this,$o,Q(Me,8,this,!1)),Q(Me,11,this),we(this,To,Q(Me,12,this,null)),Q(Me,15,this),we(this,Do,Q(Me,16,this,null)),Q(Me,19,this),we(this,Ro,Q(Me,20,this,null)),Q(Me,23,this),we(this,Po,Q(Me,24,this,[])),Q(Me,27,this),this.position=new Ws({x:0,y:0}),we(this,ar,{x:0,y:0}),wt(this,sr,e)}get shape(){const{current:e,initial:t,previous:n}=He(this,Tn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?He(this,Tn).current=e:He(this,Tn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=He(this,sr).registry.draggables.get(t);return n&&wt(this,ls,n),(e=n??He(this,ls))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=He(this,sr).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(xc(_c({},this.snapshot()),{transform:n}));return wt(this,ar,n),n}snapshot(){return _e(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:He(this,ar),shape:this.shape?sa(this.shape):null,position:sa(this.position),status:sa(this.status),canceled:this.canceled}))}reset(){Kt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,He(this,Tn).reset(),this.position.reset({x:0,y:0}),wt(this,ar,{x:0,y:0}),this.modifiers=[]})}};Me=Xn(null);sr=new WeakMap;ls=new WeakMap;Tn=new WeakMap;$o=new WeakMap;To=new WeakMap;Do=new WeakMap;Ro=new WeakMap;Po=new WeakMap;ar=new WeakMap;ce(Me,2,"shape",au,It);ce(Me,4,"canceled",su,It,$o);ce(Me,4,"activatorEvent",ru,It,To);ce(Me,4,"sourceIdentifier",nu,It,Do);ce(Me,4,"targetIdentifier",tu,It,Ro);ce(Me,4,"modifiers",eu,It,Po);ce(Me,2,"source",Qc,It);ce(Me,2,"target",Jc,It);ce(Me,2,"transform",qc,It);vn(Me,It);var Mh={get rendering(){return Promise.resolve()}};function Bt(e,t){return typeof e=="function"?e(t):e??t}var $h=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(p=>p.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Bt(r.plugins,[]),a=Bt(r.sensors,[]),o=Bt(r.modifiers,[]),i=(n=r.renderer)!=null?n:Mh,l=new kh(this),c=new Ah(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new Eh(this),this.dragOperation=new It(this),this.collisionObserver=new xh(this),this.plugins=[Sh,...s],this.modifiers=o,this.sensors=a;const{destroy:d}=this,u=$r(()=>{var p,h,g;const w=_e(()=>this.dragOperation.modifiers),v=this.modifiers;for(const m of w)v.includes(m)||m.destroy();this.dragOperation.modifiers=(g=(h=(p=this.dragOperation.source)==null?void 0:p.modifiers)==null?void 0:h.map(m=>{const{plugin:b,options:_}=ho(m);return new b(this,_)}))!=null?g:v});this.destroy=()=>{u(),d()}}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}},ou=e=>{throw TypeError(e)},Wo=(e,t,n)=>t.has(e)||ou("Cannot "+n),re=(e,t,n)=>(Wo(e,t,"read from private field"),t.get(e)),ot=(e,t,n)=>t.has(e)?ou("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pt=(e,t,n,r)=>(Wo(e,t,"write to private field"),t.set(e,n),n),iu=(e,t,n)=>(Wo(e,t,"access private method"),n);function Fs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Th(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=(Fs(s)?s.getKeyframes():[]).filter(t);if(o.length>0)return[o[o.length-1],r]}return null}function Os(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 Fo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Pr(e){return"nodeType"in e}function kt(e){var t,n,r;return e?Fo(e)?e:Pr(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 Oo(e){const{Document:t}=kt(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function hn(e){return!e||Fo(e)?!1:e instanceof kt(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function lu(e){return e instanceof kt(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function yn(e){return e?Fo(e)?e.document:Pr(e)?Oo(e)?e:hn(e)||lu(e)?e.ownerDocument:document:document:document}function Dh(e){var t,n,r,s;const{documentElement:a}=yn(e),o=kt(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,d=(s=o?.offsetLeft)!=null?s:0;return{top:c,left:d,right:d+i,bottom:c+l,width:i,height:l}}function Rh(e,t){if(Ph(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Ph(e){return e.tagName==="DETAILS"}function ys(e,t=e.getBoundingClientRect(),n=0){var r,s,a,o,i;let l=t;const{ownerDocument:c}=e,d=(r=c.defaultView)!=null?r:window;let u=e.parentElement;for(;u&&u!==c.documentElement;){if(!Rh(u)){const _=u.getBoundingClientRect(),y=n*(_.bottom-_.top),x=n*(_.right-_.left),k=n*(_.bottom-_.top),S=n*(_.right-_.left);l={top:Math.max(l.top,_.top-y),right:Math.min(l.right,_.right+x),bottom:Math.min(l.bottom,_.bottom+k),left:Math.max(l.left,_.left-S),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}u=u.parentElement}const p=d.visualViewport,h=(s=p?.offsetTop)!=null?s:0,g=(a=p?.offsetLeft)!=null?a:0,w=(o=p?.width)!=null?o:d.innerWidth,v=(i=p?.height)!=null?i:d.innerHeight,m=n*v,b=n*w;return l={top:Math.max(l.top,h-m),right:Math.min(l.right,g+w+b),bottom:Math.min(l.bottom,h+v+m),left:Math.max(l.left,g-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 cu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Da(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(...Da(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(...Da(s.document,t))}}catch{}return n}function Bo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function uu(){var e,t;const n=Bo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Vo(e){return!e||!Pr(e)?!1:e instanceof kt(e).ShadowRoot}function bs(e){if(e&&Pr(e)){let t=e.getRootNode();if(Vo(t))return t;if(t instanceof Document)return t}return yn(e)}function du(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Wh(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(sl(a)&&sl(i)&&(a.type!=="file"&&(a.value=i.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),al(a)&&al(i)&&i.width>0&&i.height>0){const l=a.getContext("2d");l?.drawImage(i,0,0)}}),n}function sl(e){return"value"in e}function al(e){return e.tagName==="CANVAS"}function fu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Fh(r)){const{contentDocument:s}=r;if(s){const{left:a,top:o}=r.getBoundingClientRect();return fu(s,{x:t-a,y:n-o})}}return r}function Fh(e){return e?.tagName==="IFRAME"}var ol=new WeakMap;function Oh(e){return!!e.closest(`
|
|
1
|
+
"use strict";var vf=Object.create;var zi=Object.defineProperty;var yf=Object.getOwnPropertyDescriptor;var bf=Object.getOwnPropertyNames;var wf=Object.getPrototypeOf,_f=Object.prototype.hasOwnProperty;var xf=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of bf(t))!_f.call(e,s)&&s!==n&&zi(e,s,{get:()=>t[s],enumerable:!(r=yf(t,s))||r.enumerable});return e};var Cf=(e,t,n)=>(n=e!=null?vf(wf(e)):{},xf(t||!e||!e.__esModule?zi(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("tone"),C=require("react/jsx-runtime"),f=require("react"),R=require("styled-components"),ro=require("react-dom");function Ll(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 zl=Ll(j),D=Ll(f);var Ye=1e3;function ma(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate,u=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(u===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 p=e.durationSamples??u;return{id:Hl(),audioBuffer:t,startSample:n,durationSamples:p,offsetSamples:r,sampleRate:d,sourceDurationSamples:u,gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c}}function jl(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c}=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 u=t?.duration??e.sourceDuration??c?.duration;if(u===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 p=e.duration??u;return ma({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(p*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(u*d),gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c})}function Zl(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:d}=e;return{id:Hl(),name:t,clips:n,muted:r,soloed:s,volume:a,pan:o,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:d}}function Hl(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ji(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function Zi(e){return e.startSample/e.sampleRate}function kf(e){return(e.startSample+e.durationSamples)/e.sampleRate}function Sf(e){return e.offsetSamples/e.sampleRate}function Ef(e){return e.durationSamples/e.sampleRate}var Hi=!1;function ga(e){const t=e._param;return!t&&!Hi&&(Hi=!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 Ni(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 If(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 Af(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 Mf(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 Nl(e,t,n){switch(e){case"linear":return Ni(t,n);case"exponential":return If(t,n);case"sCurve":return Af(t,n);case"logarithmic":return Mf(t,n);default:return Ni(t,n)}}function Xi(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=Nl(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 Gi(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=Nl(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 $f=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new j.Volume(this.gainToDb(e.track.gain)),this.panNode=new j.Panner(e.track.stereoPan),this.muteGain=new j.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||j.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=j.getTransport(),s=j.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(d=>{l<this._scheduleGuardOffset||this.startClipSource(o,i,d)},l);return{clipInfo:o,fadeGainNode:i,scheduleId:c}})}startClipSource(e,t,n,r,s){const o=j.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)Xi(a,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,c=o/i,d=r.gain*c;Xi(a,t,l,r.fadeIn.type||"linear",d,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;Gi(a,c,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const c=-l,d=r.fadeOut.duration-c,u=c/r.fadeOut.duration,p=r.gain*(1-u);Gi(a,t,d,r.fadeOut.type||"linear",p,0)}}}prepareFades(e,t){this.scheduledClips.forEach(n=>{const r=this.track.startTime+n.clipInfo.startTime,s=r+n.clipInfo.duration;if(!(t>=s))if(t>=r){const 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;ga(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=j.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}},Tf=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 j.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,j.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{j.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await j.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new $f(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??j.now(),s=j.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=j.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=j.getTransport();try{e.stop()}catch(t){console.warn("[waveform-playlist] Transport.stop() failed:",t)}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=j.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=j.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 j.getTransport().seconds}seekTo(e){j.getTransport().seconds=e}dispose(){if(this.clearCompletionEvent(),this._loopHandler){try{j.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 j.getContext()}get sampleRate(){return j.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Ur=null;function Df(){return Ur||(Ur=new j.Context,j.setContext(Ur)),Ur}function Rf(){return Df().rawContext}function Pf(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(u){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",u)}t=null}r++;const d=r;t=new Tf({effects:e?.effects}),i&&t.init().catch(u=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",u),i=!1});for(const u of c){const p=u.clips.filter(m=>m.audioBuffer);if(p.length===0)continue;const h=Math.min(...p.map(Zi)),g=Math.max(...p.map(kf)),w={id:u.id,name:u.name,gain:u.volume,muted:u.muted,soloed:u.soloed,stereoPan:u.pan,startTime:h,endTime:g},v=p.map(m=>({buffer:m.audioBuffer,startTime:Zi(m)-h,duration:Ef(m),offset:Sf(m),fadeIn:m.fadeIn,fadeOut:m.fadeOut,gain:m.gain}));t.addTrack({clips:v,track:w,effects:u.effects})}t.applyInitialSoloState(),t.setLoop(s,a,o),t.setOnPlaybackComplete(()=>{d===r&&(n=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(c){l(c)},play(c,d){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 u=d!==void 0?d-c:void 0;t.play(j.now(),c,u),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,d){t?.getTrack(c)?.setVolume(d)},setTrackMute(c,d){t?.setMute(c,d)},setTrackSolo(c,d){t?.setSolo(c,d)},setTrackPan(c,d){t?.getTrack(c)?.setPan(d)},setLoop(c,d,u){s=c,a=d,o=u,t?.setLoop(c,d,u)},dispose(){try{t?.dispose()}catch(c){console.warn("[waveform-playlist] Error disposing playout:",c)}t=null,n=!1}}}function Xl(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 va(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 Wf(e,t){return Math.floor(e/t)*t}function Ff(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=ma({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=ma({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 Gl(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 Qs(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 Yi(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 Ui(e,t){return Math.max(0,Math.min(e,t))}var Of=44100,Bf=1e3,Vf=[256,512,1024,2048,4096,8192],Ki=.1,Lf=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??Of,this._zoomLevels=[...e.zoomLevels??Vf],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??Bf;this._zoomIndex=Yi(t,this._zoomLevels)}getState(){return{tracks:this._tracks.map(e=>({...e,clips:[...e.clips]})),tracksVersion:this._tracksVersion,duration:Qs(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=ji(r.clips),i=o.findIndex(c=>c.id===t),l=Xl(a,n,o,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const d=c.clips.map((u,p)=>p===s?{...u,startSample:Math.floor(u.startSample+l)}:u);return{...c,clips:d}}),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(Ki*this._sampleRate);if(!Gl(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}=Ff(a,n);this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const d=[...c.clips];return d.splice(s,1,i,l),{...c,clips:d}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}trimClip(e,t,n,r){const s=this._tracks.find(u=>u.id===e);if(!s){console.warn(`[waveform-playlist/engine] trimClip: track "${e}" not found`);return}const a=s.clips.findIndex(u=>u.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=ji(s.clips),l=i.findIndex(u=>u.id===t),c=Math.floor(Ki*this._sampleRate),d=va(o,r,n,i,l,c);d!==0&&(this._tracks=this._tracks.map(u=>{if(u.id!==e)return u;const p=u.clips.map((h,g)=>g!==a?h:n==="left"?{...h,startSample:h.startSample+d,offsetSamples:h.offsetSamples+d,durationSamples:h.durationSamples-d}:{...h,durationSamples:h.durationSamples+d});return{...u,clips:p}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}async init(){this._adapter&&await this._adapter.init()}play(e,t){const n=this._currentTime,r=this._playStartPosition;if(e!==void 0){const s=Qs(this._tracks);this._currentTime=Ui(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._loopStart&&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=Qs(this._tracks);this._currentTime=Ui(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._shouldActivateTransportLoop(),this._loopStart,this._loopEnd),this._emitStateChange())}setLoopEnabled(e){e!==this._isLoopEnabled&&(this._isLoopEnabled=e,this._adapter?.setLoop(e&&this._shouldActivateTransportLoop(),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=Yi(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)}}_emitStateChange(){this._emit("statechange",this.getState())}_shouldActivateTransportLoop(){if(!this._isPlaying)return!0;const e=this._adapter?.getCurrentTime()??this._currentTime;return e>=this._loopStart&&e<this._loopEnd}_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)}},zf=Symbol.for("preact-signals");function Rs(){if(Ut>1)Ut--;else{for(var e,t=!1;hr!==void 0;){var n=hr;for(hr=void 0,ya++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Ul(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(ya=0,Ut--,t)throw e}}function Kt(e){if(Ut>0)return e();Ut++;try{return e()}finally{Rs()}}var pe=void 0;function _e(e){var t=pe;pe=void 0;try{return e()}finally{pe=t}}var hr=void 0,Ut=0,ya=0,ms=0;function Yl(e){if(pe!==void 0){var t=e.n;if(t===void 0||t.t!==pe)return t={i:0,S:e,p:pe.s,n:void 0,t:pe,e:void 0,x:void 0,r:t},pe.s!==void 0&&(pe.s.n=t),pe.s=t,e.n=t,32&pe.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=pe.s,t.n=void 0,pe.s.n=t,pe.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=zf;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:_e(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&&_e(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=pe;pe=void 0;try{e(n)}finally{pe=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=pe;pe=void 0;try{return this.value}finally{pe=e}};Object.defineProperty(st.prototype,"value",{get:function(){var e=Yl(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ya>100)throw new Error("Cycle detected");this.v=e,this.i++,ms++,Ut++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Rs()}}}});function Mr(e,t){return new st(e,t)}function Ul(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 Kl(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 ql(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=ms-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===ms))return!0;if(this.g=ms,this.f|=1,this.i>0&&!Ul(this))return this.f&=-2,!0;var e=pe;try{Kl(this),pe=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 pe=e,ql(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=Yl(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function qi(e,t){return new gn(e,t)}function Jl(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Ut++;var n=pe;pe=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,so(e),r}finally{pe=n,Rs()}}}function so(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Jl(e)}function jf(e){if(pe!==this)throw new Error("Out-of-order effect");ql(this),pe=e,this.f&=-2,8&this.f&&so(this),Rs()}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,Jl(this),Kl(this),Ut++;var e=pe;return pe=this,jf.bind(this,e)};jn.prototype.N=function(){2&this.f||(this.f|=2,this.o=hr,hr=this)};jn.prototype.d=function(){this.f|=8,1&this.f||so(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 Zf=Object.create,ao=Object.defineProperty,Hf=Object.defineProperties,Nf=Object.getOwnPropertyDescriptor,Xf=Object.getOwnPropertyDescriptors,Ji=Object.getOwnPropertySymbols,Gf=Object.prototype.hasOwnProperty,Yf=Object.prototype.propertyIsEnumerable,Uf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},ba=(e,t,n)=>t in e?ao(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kf=(e,t)=>{for(var n in t||(t={}))Gf.call(t,n)&&ba(e,n,t[n]);if(Ji)for(var n of Ji(t))Yf.call(t,n)&&ba(e,n,t[n]);return e},qf=(e,t)=>Hf(e,Xf(t)),Qi=(e,t)=>ao(e,"name",{value:t,configurable:!0}),Jf=e=>{var t;return[,,,Zf((t=void 0)!=null?t:null)]},Ql=["class","method","getter","setter","accessor","field","value","get","set"],nr=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,Qf=(e,t,n,r,s)=>({kind:Ql[e],name:t,metadata:r,addInitializer:a=>n._?Zn("Already initialized"):s.push(nr(a||null))}),ec=(e,t)=>ba(t,Uf("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},Hn=(e,t,n,r,s,a)=>{var o,i,l,c,d,u=t&7,p=!!(t&8),h=!!(t&16),g=u>3?e.length+1:u?p?1:2:0,w=Ql[u+5],v=u>3&&(e[g-1]=[]),m=e[g]||(e[g]=[]),b=u&&(!h&&!p&&(s=s.prototype),u<5&&(u>3||!h)&&Nf(u<4?s:{get[n](){return fn(this,a)},set[n](y){return Xt(this,a,y)}},n));u?h&&u<4&&Qi(a,(u>2?"set ":u>1?"get ":"")+n):Qi(s,n);for(var _=r.length-1;_>=0;_--)c=Qf(u,n,l={},e[3],m),u&&(c.static=p,c.private=h,d=c.access={has:h?y=>eh(s,y):y=>n in y},u^3&&(d.get=h?y=>(u^1?fn:th)(y,s,u^4?a:b.get):y=>y[n]),u>2&&(d.set=h?(y,x)=>Xt(y,s,x,u^4?a:b.set):(y,x)=>y[n]=x)),i=(0,r[_])(u?u<4?h?a:b[w]:u>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,u^4||i===void 0?nr(i)&&(u>4?v.unshift(i):u?h?a=i:b[w]=i:s=i):typeof i!="object"||i===null?Zn("Object expected"):(nr(o=i.get)&&(b.get=o),nr(o=i.set)&&(b.set=o),nr(o=i.init)&&v.unshift(o));return u||ec(e,s),b&&ao(s,n,b),h?u^4?a:b:s},oo=(e,t,n)=>t.has(e)||Zn("Cannot "+n),eh=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),fn=(e,t,n)=>(oo(e,t,"read from private field"),n?n.call(e):t.get(e)),Kr=(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),Xt=(e,t,n,r)=>(oo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),th=(e,t,n)=>(oo(e,t,"access private method"),n);function gs(e,t){if(t){let n;return qi(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return qi(e)}function br(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)=>!br(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=>!br(e[a],t[a]))}return!1}function ue({get:e},t){return{init(n){return Mr(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=gs(e.bind(this)),n.set(this,r)),r.value}}function ea(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,qf(Kf({},s),{enumerable:e}))})}}function $r(...e){const t=e.map(n=>Ct(n));return()=>t.forEach(n=>n())}var tc,nc,rc,sc,ac,oc,tt,io,ta,wa,_a,qe,lo,na,ic,xa,co,ra,Ca,ka;oc=[ue],ac=[ue],sc=[ue],rc=[ea()],nc=[ea()],tc=[ea()];var Jt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,sn(tt,5,this),Kr(this,qe),Kr(this,io,sn(tt,8,this)),sn(tt,11,this),Kr(this,lo,sn(tt,12,this)),sn(tt,15,this),Kr(this,co,sn(tt,16,this)),sn(tt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return fn(this,qe,Ca)}get initial(){return fn(this,qe,wa)}get previous(){return fn(this,qe,ic)}set current(e){const t=_e(()=>fn(this,qe,Ca));e&&t&&this.equals(t,e)||Kt(()=>{fn(this,qe,wa)||Xt(this,qe,e,_a),Xt(this,qe,t,xa),Xt(this,qe,e,ka)})}reset(e=this.defaultValue){Kt(()=>{Xt(this,qe,void 0,xa),Xt(this,qe,e,_a),Xt(this,qe,e,ka)})}};tt=Jf();io=new WeakMap;qe=new WeakSet;lo=new WeakMap;co=new WeakMap;ta=Hn(tt,20,"#initial",oc,qe,io),wa=ta.get,_a=ta.set;na=Hn(tt,20,"#previous",ac,qe,lo),ic=na.get,xa=na.set;ra=Hn(tt,20,"#current",sc,qe,co),Ca=ra.get,ka=ra.set;Hn(tt,2,"current",rc,Jt);Hn(tt,2,"initial",nc,Jt);Hn(tt,2,"previous",tc,Jt);ec(tt,Jt);function sa(e){return _e(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var nh=Object.create,lc=Object.defineProperty,rh=Object.getOwnPropertyDescriptor,el=Object.getOwnPropertySymbols,sh=Object.prototype.hasOwnProperty,ah=Object.prototype.propertyIsEnumerable,cc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ps=e=>{throw TypeError(e)},tl=Math.pow,Sa=(e,t,n)=>t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,oh=(e,t)=>{for(var n in t||(t={}))sh.call(t,n)&&Sa(e,n,t[n]);if(el)for(var n of el(t))ah.call(t,n)&&Sa(e,n,t[n]);return e},ih=e=>{var t;return[,,,nh((t=e?.[cc("metadata")])!=null?t:null)]},uc=["class","method","getter","setter","accessor","field","value","get","set"],dc=e=>e!==void 0&&typeof e!="function"?Ps("Function expected"):e,lh=(e,t,n,r,s)=>({kind:uc[e],name:t,metadata:r,addInitializer:a=>n._?Ps("Already initialized"):s.push(dc(a||null))}),ch=(e,t)=>Sa(t,cc("metadata"),e[3]),uh=(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},fc=(e,t,n,r,s,a)=>{for(var o,i,l,c,d=t&7,u=!1,p=!1,h=2,g=uc[d+5],w=e[h]||(e[h]=[]),v=(s=s.prototype,rh(s,n)),m=r.length-1;m>=0;m--)l=lh(d,n,i={},e[3],w),l.static=u,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[m])(v[g],l),i._=1,dc(o)&&(v[g]=o);return v&&lc(s,n,v),s},hc=(e,t,n)=>t.has(e)||Ps("Cannot "+n),dh=(e,t,n)=>(hc(e,t,"read from private field"),t.get(e)),fh=(e,t,n)=>t.has(e)?Ps("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),hh=(e,t,n,r)=>(hc(e,t,"write to private field"),t.set(e,n),n),Tt=class Ea{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ea(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 Ea(t,n)}},Tr=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=oh({},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 Tt((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?ph(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 Tt.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 ph(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 pc,mc,Ia,rs,Dr,Ws=class extends(Ia=Jt,mc=[Ae],pc=[Ae],Ia){constructor(t){const n=Tt.from(t);super(n,(r,s)=>Tt.equals(r,s)),uh(Dr,5,this),fh(this,rs,0),this.velocity={x:0,y:0}}get delta(){return Tt.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=Tt.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-dh(this,rs),i=l=>Math.round(l/o*100);Kt(()=>{hh(this,rs,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Tt.from(t)),this.velocity={x:0,y:0}}};Dr=ih(Ia);rs=new WeakMap;fc(Dr,2,"delta",mc,Ws);fc(Dr,2,"direction",pc,Ws);ch(Dr,Ws);function Aa({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(tl(r,2)+tl(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 gc=(e=>(e.Horizontal="x",e.Vertical="y",e))(gc||{}),vc=Object.values(gc),mh=Object.create,uo=Object.defineProperty,gh=Object.defineProperties,vh=Object.getOwnPropertyDescriptor,yh=Object.getOwnPropertyDescriptors,vs=Object.getOwnPropertySymbols,yc=Object.prototype.hasOwnProperty,bc=Object.prototype.propertyIsEnumerable,wc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Nn=e=>{throw TypeError(e)},Ma=(e,t,n)=>t in e?uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_c=(e,t)=>{for(var n in t||(t={}))yc.call(t,n)&&Ma(e,n,t[n]);if(vs)for(var n of vs(t))bc.call(t,n)&&Ma(e,n,t[n]);return e},xc=(e,t)=>gh(e,yh(t)),nl=(e,t)=>uo(e,"name",{value:t,configurable:!0}),Cc=(e,t)=>{var n={};for(var r in e)yc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&vs)for(var r of vs(e))t.indexOf(r)<0&&bc.call(e,r)&&(n[r]=e[r]);return n},Xn=e=>{var t;return[,,,mh((t=e?.[wc("metadata")])!=null?t:null)]},kc=["class","method","getter","setter","accessor","field","value","get","set"],rr=e=>e!==void 0&&typeof e!="function"?Nn("Function expected"):e,bh=(e,t,n,r,s)=>({kind:kc[e],name:t,metadata:r,addInitializer:a=>n._?Nn("Already initialized"):s.push(rr(a||null))}),vn=(e,t)=>Ma(t,wc("metadata"),e[3]),J=(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,d,u=t&7,p=!!(t&8),h=!!(t&16),g=u>3?e.length+1:u?p?1:2:0,w=kc[u+5],v=u>3&&(e[g-1]=[]),m=e[g]||(e[g]=[]),b=u&&(!h&&!p&&(s=s.prototype),u<5&&(u>3||!h)&&vh(u<4?s:{get[n](){return He(this,a)},set[n](y){return wt(this,a,y)}},n));u?h&&u<4&&nl(a,(u>2?"set ":u>1?"get ":"")+n):nl(s,n);for(var _=r.length-1;_>=0;_--)c=bh(u,n,l={},e[3],m),u&&(c.static=p,c.private=h,d=c.access={has:h?y=>wh(s,y):y=>n in y},u^3&&(d.get=h?y=>(u^1?He:_h)(y,s,u^4?a:b.get):y=>y[n]),u>2&&(d.set=h?(y,x)=>wt(y,s,x,u^4?a:b.set):(y,x)=>y[n]=x)),i=(0,r[_])(u?u<4?h?a:b[w]:u>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,u^4||i===void 0?rr(i)&&(u>4?v.unshift(i):u?h?a=i:b[w]=i:s=i):typeof i!="object"||i===null?Nn("Object expected"):(rr(o=i.get)&&(b.get=o),rr(o=i.set)&&(b.set=o),rr(o=i.init)&&v.unshift(o));return u||vn(e,s),b&&uo(s,n,b),h?u^4?a:b:s},fo=(e,t,n)=>t.has(e)||Nn("Cannot "+n),wh=(e,t)=>Object(t)!==t?Nn('Cannot use the "in" operator on this value'):e.has(t),He=(e,t,n)=>(fo(e,t,"read from private field"),n?n.call(e):t.get(e)),we=(e,t,n)=>t.has(e)?Nn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),wt=(e,t,n,r)=>(fo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),_h=(e,t,n)=>(fo(e,t,"access private method"),n);function Sc(e,t){return{plugin:e,options:t}}function Gn(e){return t=>Sc(e,t)}function ho(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Ec,wr,po,ss;Ec=[ue];var lt=class{constructor(e,t){this.manager=e,this.options=t,we(this,po,J(wr,8,this,!1)),J(wr,11,this),we(this,ss,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return _e(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=Ct(e.bind(this));return He(this,ss).add(t),t}destroy(){He(this,ss).forEach(e=>e())}static configure(e){return Sc(this,e)}};wr=Xn(null);po=new WeakMap;ss=new WeakMap;ce(wr,4,"disabled",Ec,lt,po);vn(wr,lt);var Rr=class extends lt{},as,aa=class{constructor(e){this.manager=e,this.instances=new Map,we(this,as,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(ho).reduceRight((r,s)=>r.some(({plugin:a})=>a===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 Rr)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 xh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var qr=[],Mn,$n,Ch=class extends lt{constructor(e){super(e),we(this,Mn),we(this,$n),this.computeCollisions=this.computeCollisions.bind(this),wt(this,$n,Mr(qr)),this.destroy=$r(()=>{const t=this.computeCollisions(),n=_e(()=>this.manager.dragOperation.position.current);if(t!==qr){const r=He(this,Mn);if(wt(this,Mn,n),r&&n.x==r.x&&n.y==r.y)return}else wt(this,Mn,void 0);He(this,$n).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){_e(()=>{e?He(this,$n).value=this.computeCollisions():wt(this,Mn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:a,status:o}=r;if(!o.initialized||!a)return qr;const i=[],l=[];for(const c of e??n.droppables){if(c.disabled||s&&!c.accepts(s))continue;const d=t??c.collisionDetector;if(!d)continue;l.push(c),c.shape;const u=_e(()=>d({droppable:c,dragOperation:r}));u&&(c.collisionPriority!=null&&(u.priority=c.collisionPriority),i.push(u))}return l.length===0?qr:(i.sort(xh),i)}get collisions(){return He(this,$n).value}};Mn=new WeakMap;$n=new WeakMap;var kh=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)}},Sh=class extends kh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function os(e,t=!0){let n=!1;return xc(_c({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Eh=class extends Rr{constructor(e){super(e);const t=(r,s)=>r.map(({id:a})=>a).join("")===s.map(({id:a})=>a).join("");let n=[];this.destroy=$r(()=>{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=os({collisions:a});if(s.dispatch("collision",o),o.defaultPrevented||t(a,n))return;n=a;const[i]=a;_e(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},mo=(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))(mo||{}),go=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(go||{}),Ic,Ac,Mc,$c,Tc,Dc,Rc,xt,vo;Rc=[ue],Dc=[Ae],Tc=[Ae],$c=[Ae],Mc=[Ae],Ac=[Ae],Ic=[Ae];var zt=class{constructor(){J(xt,5,this),we(this,vo,J(xt,8,this,"idle")),J(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=Xn(null);vo=new WeakMap;ce(xt,4,"value",Rc,zt,vo);ce(xt,2,"current",Dc,zt);ce(xt,2,"idle",Tc,zt);ce(xt,2,"initializing",$c,zt);ce(xt,2,"initialized",Mc,zt);ce(xt,2,"dragging",Ac,zt);ce(xt,2,"dropped",Ic,zt);vn(xt,zt);var Ih=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 _e(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=os({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return _e(()=>{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;Kt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(a)});const o=os({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 _e(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:a}=r;if(!s.dragging||!a||a.signal.aborted)return;const o=os({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,d,u;if(o.defaultPrevented)return;const p=(u=e.to)!=null?u:{x:r.position.current.x+((l=(i=e.by)==null?void 0:i.x)!=null?l:0),y:r.position.current.y+((d=(c=e.by)==null?void 0:c.y)!=null?d:0)};r.position.current=p})})}stop(e={}){return _e(()=>{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,d)=>{l.resume=c,l.abort=d}),l};s.abort();const i=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=_e(()=>{var d;return((d=r.source)==null?void 0:d.status)==="dropping"}),c=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:d}=r,u=Ct(()=>{d?.status==="idle"&&(u(),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()})}},Pc,Wc,Fc,Oc,it,yo,bo,wo,_o;Oc=[ue],Fc=[ue],Wc=[ue],Pc=[ue];var Qt=class{constructor(e,t){we(this,yo,J(it,8,this)),J(it,11,this),we(this,bo,J(it,12,this)),J(it,15,this),we(this,wo,J(it,16,this)),J(it,19,this),we(this,_o,J(it,20,this)),J(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:d}=this;if(c!==i)return d?.registry.register(this),()=>d?.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=Xn(null);yo=new WeakMap;bo=new WeakMap;wo=new WeakMap;_o=new WeakMap;ce(it,4,"manager",Oc,Qt,yo);ce(it,4,"id",Fc,Qt,bo);ce(it,4,"data",Wc,Qt,wo);ce(it,4,"disabled",Pc,Qt,_o);vn(it,Qt);var rl=class{constructor(){this.map=Mr(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=$r(...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}},Bc,Vc,Lc,zc,jc,Zc,$a,nt,xo,Co,ko,Dt=class extends($a=Qt,Zc=[ue],jc=[ue],zc=[ue],Lc=[Ae],Vc=[Ae],Bc=[Ae],$a){constructor(t,n){var r=t,{modifiers:s,type:a,sensors:o}=r,i=Cc(r,["modifiers","type","sensors"]);super(i,n),J(nt,5,this),we(this,xo,J(nt,8,this)),J(nt,11,this),we(this,Co,J(nt,12,this)),J(nt,15,this),we(this,ko,J(nt,16,this,this.isDragSource?"dragging":"idle")),J(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=Xn($a);xo=new WeakMap;Co=new WeakMap;ko=new WeakMap;ce(nt,4,"type",Zc,Dt,xo);ce(nt,4,"modifiers",jc,Dt,Co);ce(nt,4,"status",zc,Dt,ko);ce(nt,2,"isDropping",Lc,Dt);ce(nt,2,"isDragging",Vc,Dt);ce(nt,2,"isDragSource",Bc,Dt);vn(nt,Dt);var Hc,Nc,Xc,Gc,Yc,Uc,Ta,Ve,So,Eo,Io,Ao,Mo,Rt=class extends(Ta=Qt,Uc=[ue],Yc=[ue],Gc=[ue],Xc=[ue],Nc=[ue],Hc=[Ae],Ta){constructor(t,n){var r=t,{accept:s,collisionDetector:a,collisionPriority:o,type:i}=r,l=Cc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),J(Ve,5,this),we(this,So,J(Ve,8,this)),J(Ve,11,this),we(this,Eo,J(Ve,12,this)),J(Ve,15,this),we(this,Io,J(Ve,16,this)),J(Ve,19,this),we(this,Ao,J(Ve,20,this)),J(Ve,23,this),we(this,Mo,J(Ve,24,this)),J(Ve,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}};Ve=Xn(Ta);So=new WeakMap;Eo=new WeakMap;Io=new WeakMap;Ao=new WeakMap;Mo=new WeakMap;ce(Ve,4,"accept",Uc,Rt,So);ce(Ve,4,"type",Yc,Rt,Eo);ce(Ve,4,"collisionDetector",Gc,Rt,Io);ce(Ve,4,"collisionPriority",Xc,Rt,Ao);ce(Ve,4,"shape",Nc,Rt,Mo);ce(Ve,2,"isDropTarget",Hc,Rt);vn(Ve,Rt);var On=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Ah=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)}},is,Kc=class{constructor(e){this.options=e,we(this,is)}set controller(e){wt(this,is,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=He(this,is))==null||t.activate(e)}};is=new WeakMap;var _r=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Mh=class{constructor(e){this.draggables=new rl,this.droppables=new rl,this.plugins=new aa(e),this.sensors=new aa(e),this.modifiers=new aa(e)}register(e,t){if(e instanceof Dt)return this.draggables.register(e.id,e);if(e instanceof Rt)return this.droppables.register(e.id,e);if(e.prototype instanceof _r)return this.modifiers.register(e,t);if(e.prototype instanceof On)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 Qt)return e instanceof Dt?this.draggables.unregister(e.id,e):e instanceof Rt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof _r)return this.modifiers.unregister(e);if(e.prototype instanceof On)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()}},qc,Jc,Qc,eu,tu,nu,ru,su,au,sr,ls,Tn,Me,$o,To,Do,Ro,Po,ar;au=[Ae],su=[ue],ru=[ue],nu=[ue],tu=[ue],eu=[ue],Qc=[Ae],Jc=[Ae],qc=[Ae];var It=class{constructor(e){J(Me,5,this),we(this,sr),we(this,ls),we(this,Tn,new Jt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new zt,we(this,$o,J(Me,8,this,!1)),J(Me,11,this),we(this,To,J(Me,12,this,null)),J(Me,15,this),we(this,Do,J(Me,16,this,null)),J(Me,19,this),we(this,Ro,J(Me,20,this,null)),J(Me,23,this),we(this,Po,J(Me,24,this,[])),J(Me,27,this),this.position=new Ws({x:0,y:0}),we(this,ar,{x:0,y:0}),wt(this,sr,e)}get shape(){const{current:e,initial:t,previous:n}=He(this,Tn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?He(this,Tn).current=e:He(this,Tn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=He(this,sr).registry.draggables.get(t);return n&&wt(this,ls,n),(e=n??He(this,ls))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=He(this,sr).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(xc(_c({},this.snapshot()),{transform:n}));return wt(this,ar,n),n}snapshot(){return _e(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:He(this,ar),shape:this.shape?sa(this.shape):null,position:sa(this.position),status:sa(this.status),canceled:this.canceled}))}reset(){Kt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,He(this,Tn).reset(),this.position.reset({x:0,y:0}),wt(this,ar,{x:0,y:0}),this.modifiers=[]})}};Me=Xn(null);sr=new WeakMap;ls=new WeakMap;Tn=new WeakMap;$o=new WeakMap;To=new WeakMap;Do=new WeakMap;Ro=new WeakMap;Po=new WeakMap;ar=new WeakMap;ce(Me,2,"shape",au,It);ce(Me,4,"canceled",su,It,$o);ce(Me,4,"activatorEvent",ru,It,To);ce(Me,4,"sourceIdentifier",nu,It,Do);ce(Me,4,"targetIdentifier",tu,It,Ro);ce(Me,4,"modifiers",eu,It,Po);ce(Me,2,"source",Qc,It);ce(Me,2,"target",Jc,It);ce(Me,2,"transform",qc,It);vn(Me,It);var $h={get rendering(){return Promise.resolve()}};function Bt(e,t){return typeof e=="function"?e(t):e??t}var Th=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(p=>p.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Bt(r.plugins,[]),a=Bt(r.sensors,[]),o=Bt(r.modifiers,[]),i=(n=r.renderer)!=null?n:$h,l=new Sh(this),c=new Mh(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new Ih(this),this.dragOperation=new It(this),this.collisionObserver=new Ch(this),this.plugins=[Eh,...s],this.modifiers=o,this.sensors=a;const{destroy:d}=this,u=$r(()=>{var p,h,g;const w=_e(()=>this.dragOperation.modifiers),v=this.modifiers;for(const m of w)v.includes(m)||m.destroy();this.dragOperation.modifiers=(g=(h=(p=this.dragOperation.source)==null?void 0:p.modifiers)==null?void 0:h.map(m=>{const{plugin:b,options:_}=ho(m);return new b(this,_)}))!=null?g:v});this.destroy=()=>{u(),d()}}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}},ou=e=>{throw TypeError(e)},Wo=(e,t,n)=>t.has(e)||ou("Cannot "+n),te=(e,t,n)=>(Wo(e,t,"read from private field"),t.get(e)),ot=(e,t,n)=>t.has(e)?ou("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pt=(e,t,n,r)=>(Wo(e,t,"write to private field"),t.set(e,n),n),iu=(e,t,n)=>(Wo(e,t,"access private method"),n);function Fs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Dh(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=(Fs(s)?s.getKeyframes():[]).filter(t);if(o.length>0)return[o[o.length-1],r]}return null}function Os(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 Fo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Pr(e){return"nodeType"in e}function kt(e){var t,n,r;return e?Fo(e)?e:Pr(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 Oo(e){const{Document:t}=kt(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function hn(e){return!e||Fo(e)?!1:e instanceof kt(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function lu(e){return e instanceof kt(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function yn(e){return e?Fo(e)?e.document:Pr(e)?Oo(e)?e:hn(e)||lu(e)?e.ownerDocument:document:document:document}function Rh(e){var t,n,r,s;const{documentElement:a}=yn(e),o=kt(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,d=(s=o?.offsetLeft)!=null?s:0;return{top:c,left:d,right:d+i,bottom:c+l,width:i,height:l}}function Ph(e,t){if(Wh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Wh(e){return e.tagName==="DETAILS"}function ys(e,t=e.getBoundingClientRect(),n=0){var r,s,a,o,i;let l=t;const{ownerDocument:c}=e,d=(r=c.defaultView)!=null?r:window;let u=e.parentElement;for(;u&&u!==c.documentElement;){if(!Ph(u)){const _=u.getBoundingClientRect(),y=n*(_.bottom-_.top),x=n*(_.right-_.left),k=n*(_.bottom-_.top),S=n*(_.right-_.left);l={top:Math.max(l.top,_.top-y),right:Math.min(l.right,_.right+x),bottom:Math.min(l.bottom,_.bottom+k),left:Math.max(l.left,_.left-S),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}u=u.parentElement}const p=d.visualViewport,h=(s=p?.offsetTop)!=null?s:0,g=(a=p?.offsetLeft)!=null?a:0,w=(o=p?.width)!=null?o:d.innerWidth,v=(i=p?.height)!=null?i:d.innerHeight,m=n*v,b=n*w;return l={top:Math.max(l.top,h-m),right:Math.min(l.right,g+w+b),bottom:Math.min(l.bottom,h+v+m),left:Math.max(l.left,g-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 cu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Da(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(...Da(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(...Da(s.document,t))}}catch{}return n}function Bo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function uu(){var e,t;const n=Bo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Vo(e){return!e||!Pr(e)?!1:e instanceof kt(e).ShadowRoot}function bs(e){if(e&&Pr(e)){let t=e.getRootNode();if(Vo(t))return t;if(t instanceof Document)return t}return yn(e)}function du(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Fh(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(sl(a)&&sl(i)&&(a.type!=="file"&&(a.value=i.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),al(a)&&al(i)&&i.width>0&&i.height>0){const l=a.getContext("2d");l?.drawImage(i,0,0)}}),n}function sl(e){return"value"in e}function al(e){return e.tagName==="CANVAS"}function fu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Oh(r)){const{contentDocument:s}=r;if(s){const{left:a,top:o}=r.getBoundingClientRect();return fu(s,{x:t-a,y:n-o})}}return r}function Oh(e){return e?.tagName==="IFRAME"}var ol=new WeakMap;function Bh(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 hu=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,d=[a,o];a.addEventListener(i,l,c),this.entries.add(d),s.push(d)}return function(){for(const[o,{type:i,listener:l,options:c}]of s)o.removeEventListener(i,l,c)}}};function Vn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Bh(e){const t=new Set;let n=Vn(e);for(;n;)t.add(n),n=Vn(n);return t}function Vh(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function pu(e,t){const n=()=>performance.now();let r,s;return function(...a){const o=this;s?(r?.(),r=Vh(()=>{e.apply(o,a),s=n()},t-(n()-s))):(e.apply(o,a),s=n())}}function Lh(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 zh(e,t=e.getBoundingClientRect()){const{width:n,height:r}=ys(e,t);return n>0&&r>0}var jh=cu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},cs,Zh=class extends jh{constructor(e){super(t=>{if(!re(this,cs)){pt(this,cs,!0);return}e(t,this)}),ot(this,cs,!1)}};cs=new WeakMap;var il=Array.from({length:100},(e,t)=>t/100),mu=75,ln,ws,Ht,cn,or,Ge,pr,ir,_s,gu,vu,yu=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ot(this,_s),this.disconnect=()=>{var a,o,i;pt(this,pr,!0),(a=re(this,Ht))==null||a.disconnect(),(o=re(this,cn))==null||o.disconnect(),re(this,or).disconnect(),(i=re(this,Ge))==null||i.remove()},ot(this,ln,!0),ot(this,ws),ot(this,Ht),ot(this,cn),ot(this,or),ot(this,Ge),ot(this,pr,!1),ot(this,ir,pu(()=>{var a,o,i;const{element:l}=this;if((a=re(this,cn))==null||a.disconnect(),re(this,pr)||!re(this,ln)||!l.isConnected)return;const c=(o=l.ownerDocument)!=null?o:document,{innerHeight:d,innerWidth:u}=(i=c.defaultView)!=null?i:window,p=l.getBoundingClientRect(),h=ys(l,p),{top:g,left:w,bottom:v,right:m}=h,b=-Math.floor(g),_=-Math.floor(w),y=-Math.floor(u-m),x=-Math.floor(d-v),k=`${b}px ${y}px ${x}px ${_}px`;this.boundingClientRect=p,pt(this,cn,new IntersectionObserver(S=>{const[M]=S,{intersectionRect:E}=M;(M.intersectionRatio!==1?M.intersectionRatio:Tr.intersectionRatio(E,ys(l)))!==1&&re(this,ir).call(this)},{threshold:il,rootMargin:k,root:c})),re(this,cn).observe(l),iu(this,_s,gu).call(this)},mu)),this.boundingClientRect=e.getBoundingClientRect(),pt(this,ln,zh(e,this.boundingClientRect));let r=!0;this.callback=a=>{r&&(r=!1,n.skipInitial)||t(a)};const s=e.ownerDocument;n?.debug&&(pt(this,Ge,document.createElement("div")),re(this,Ge).style.background="rgba(0,0,0,0.15)",re(this,Ge).style.position="fixed",re(this,Ge).style.pointerEvents="none",s.body.appendChild(re(this,Ge))),pt(this,or,new IntersectionObserver(a=>{var o,i;const l=a[a.length-1],{boundingClientRect:c,isIntersecting:d}=l,{width:u,height:p}=c,h=re(this,ln);pt(this,ln,d),!(!u&&!p)&&(h&&!d?((o=re(this,cn))==null||o.disconnect(),this.callback(null),(i=re(this,Ht))==null||i.disconnect(),pt(this,Ht,void 0),re(this,Ge)&&(re(this,Ge).style.visibility="hidden")):re(this,ir).call(this),d&&!re(this,Ht)&&(pt(this,Ht,new Zh(re(this,ir))),re(this,Ht).observe(e)))},{threshold:il,root:s})),re(this,ln)&&!n.skipInitial&&this.callback(this.boundingClientRect),re(this,or).observe(e)}};ln=new WeakMap;ws=new WeakMap;Ht=new WeakMap;cn=new WeakMap;or=new WeakMap;Ge=new WeakMap;pr=new WeakMap;ir=new WeakMap;_s=new WeakSet;gu=function(){re(this,pr)||(iu(this,_s,vu).call(this),!Lh(this.boundingClientRect,re(this,ws))&&(this.callback(this.boundingClientRect),pt(this,ws,this.boundingClientRect)))};vu=function(){if(re(this,Ge)){const{top:e,left:t,width:n,height:r}=ys(this.element);re(this,Ge).style.overflow="hidden",re(this,Ge).style.visibility="visible",re(this,Ge).style.top=`${Math.floor(e)}px`,re(this,Ge).style.left=`${Math.floor(t)}px`,re(this,Ge).style.width=`${Math.floor(n)}px`,re(this,Ge).style.height=`${Math.floor(r)}px`}};var Jr=new WeakMap,Qr=new WeakMap;function Hh(e,t){let n=Jr.get(e);return n||(n={disconnect:new yu(e,s=>{const a=Jr.get(e);a&&a.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Jr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Jr.delete(e),n.disconnect())}}function Nh(e,t){const n=new Set;for(const r of e){const s=Hh(r,t);n.add(s)}return()=>n.forEach(r=>r())}function Xh(e,t){var n;const r=e.ownerDocument;if(!Qr.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}),Qr.set(r,{disconnect:()=>o.abort(),listeners:i})}const{listeners:s,disconnect:a}=(n=Qr.get(r))!=null?n:{};return!s||!a?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(a(),Qr.delete(r))})}var lr,cr,us,Ra,Gh=class{constructor(e,t,n){this.callback=t,ot(this,lr),ot(this,cr,!1),ot(this,us),ot(this,Ra,pu(o=>{if(!re(this,cr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const i of re(this,us))if(o.target.contains(i)){this.callback(re(this,lr).boundingClientRect);break}}},mu));const r=Bh(e),s=Nh(r,t),a=Xh(e,re(this,Ra));pt(this,us,r),pt(this,lr,new yu(e,t,n)),this.disconnect=()=>{re(this,cr)||(pt(this,cr,!0),s(),a(),re(this,lr).disconnect())}}};lr=new WeakMap;cr=new WeakMap;us=new WeakMap;Ra=new WeakMap;function Pa(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function xr(e){try{Pa(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function ll(e){return!cu||!e?!1:e===yn(e).scrollingElement}function bu(e){var t,n;const r=kt(e),s=ll(e)?Dh(e):Os(e),a=r.visualViewport,o=ll(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,d=i.current.y>=i.max.y,u=i.current.x>=i.max.x;return{rect:s,position:i,isTop:l,isLeft:c,isBottom:d,isRight:u}}function Yh(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:a,position:o}=bu(e),{x:i,y:l}=t??{x:0,y:0},c=!n&&o.current.y+l>0,d=!r&&o.current.y+l<o.max.y,u=!s&&o.current.x+i>0,p=!a&&o.current.x+i<o.max.x;return{top:c,bottom:d,left:u,right:p,x:u||p,y:c||d}}var Lo=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))}},xs=new Lo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Uh=new Lo(e=>setTimeout(e,50)),Cs=new Map,Kh=Cs.clear.bind(Cs);function jt(e,t=!1){if(!t)return cl(e);let n=Cs.get(e);return n||(n=cl(e),Cs.set(e,n),Uh.schedule(Kh),n)}function cl(e){return kt(e).getComputedStyle(e)}function qh(e,t=jt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Jh(e,t=jt(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 Qh={excludeElement:!0,escapeShadowDOM:!0};function Wa(e,t=Qh){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,a=new Set;function o(i){if(n!=null&&a.size>=n||!i)return a;if(Oo(i)&&i.scrollingElement!=null&&!a.has(i.scrollingElement))return a.add(i.scrollingElement),a;if(s&&Vo(i))return o(i.host);if(!hn(i))return lu(i)?o(i.parentElement):a;if(a.has(i))return a;const l=jt(i,!0);if(r&&i===e||Jh(i,l)&&a.add(i),qh(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]=Wa(e,{limit:1});return t??null}function Ln(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=Os(r),{x:a,y:o}=tp(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=Vn(r)}return n}function tp(e,t=Os(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=jt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function np(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 zo(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 jo(e){var t,n,r,s,a,o,i,l,c;const{scale:d,transform:u,translate:p}=e,h=np(d),g=zo(p),w=rp(u);if(!w&&!h&&!g)return null;const v={x:(t=h?.x)!=null?t:1,y:(n=h?.y)!=null?n:1},m={x:(r=g?.x)!=null?r:0,y:(s=g?.y)!=null?s:0},b={x:(a=w?.x)!=null?a:0,y:(o=w?.y)!=null?o:0,scaleX:(i=w?.scaleX)!=null?i:1,scaleY:(l=w?.scaleY)!=null?l:1};return{x:m.x+b.x,y:m.y+b.y,z:(c=g?.z)!=null?c:0,scaleX:v.x*b.scaleX,scaleY:v.y*b.scaleY}}function rp(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||{}),sp={x:.2,y:.2},ap={x:10,y:10};function op(e,t,n,r=25,s=sp,a=ap){const{x:o,y:i}=t,{rect:l,isTop:c,isBottom:d,isLeft:u,isRight:p}=bu(e),h=Ln(e),g=jt(e,!0),w=jo(g),v=w!==null?w?.scaleX<0:!1,m=w!==null?w?.scaleY<0:!1,b=new Tr(l.left*h.scaleX+h.x,l.top*h.scaleY+h.y,l.width*h.scaleX,l.height*h.scaleY),_={x:0,y:0},y={x:0,y:0},x={height:b.height*s.y,width:b.width*s.x};return(!c||m&&!d)&&i<=b.top+x.height&&n?.y!==1&&o>=b.left-a.x&&o<=b.right+a.x?(_.y=m?1:-1,y.y=r*Math.abs((b.top+x.height-i)/x.height)):(!d||m&&!c)&&i>=b.bottom-x.height&&n?.y!==-1&&o>=b.left-a.x&&o<=b.right+a.x&&(_.y=m?-1:1,y.y=r*Math.abs((b.bottom-x.height-i)/x.height)),(!p||v&&!u)&&o>=b.right-x.width&&n?.x!==-1&&i>=b.top-a.y&&i<=b.bottom+a.y?(_.x=v?-1:1,y.x=r*Math.abs((b.right-x.width-o)/x.width)):(!u||v&&!p)&&o<=b.left+x.width&&n?.x!==1&&i>=b.top-a.y&&i<=b.bottom+a.y&&(_.x=v?1:-1,y.x=r*Math.abs((b.left+x.width-o)/x.width)),{direction:_,speed:y}}function ip(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function lp(e,t=!1){if(ip(e)){e.scrollIntoViewIfNeeded(t);return}if(!hn(e))return e.scrollIntoView();var n=ep(e);if(!hn(n))return;const r=jt(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,d=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(d)}function cp(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,d=s?e.height*s:e.height;return{width:c,height:d,top:l,right:i+c,bottom:l+d,left:i}}function up(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,d=s?e.height/s:e.height;return{width:c,height:d,top:l,right:i+c,bottom:l+d,left:i}}function dp({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var fp=new Lo(e=>setTimeout(e,0)),mr=new Map,hp=mr.clear.bind(mr);function pp(e){const t=e.ownerDocument;let n=mr.get(t);if(n)return n;n=t.getAnimations(),mr.set(t,n),fp.schedule(hp);const r=n.filter(s=>Fs(s.effect)&&s.effect.target===e);return mr.set(e,r),n}function mp(e,t){const n=pp(e).filter(r=>{var s,a;if(Fs(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 Vt=class extends Tr{constructor(e,t={}){var n,r,s,a;const{frameTransform:o=Ln(e),ignoreTransforms:i,getBoundingClientRect:l=Os}=t,c=mp(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||Bo())&&x.contains(e)}),d=l(e);let{top:u,left:p,width:h,height:g}=d,w;const v=jt(e),m=jo(v),b={x:(n=m?.scaleX)!=null?n:1,y:(r=m?.scaleY)!=null?r:1},_=gp(e,v);c?.(),m&&(w=up(d,m,v.transformOrigin),(i||_)&&(u=w.top,p=w.left,h=w.width,g=w.height));const y={width:(s=w?.width)!=null?s:h,height:(a=w?.height)!=null?a:g};if(_&&!i&&w){const x=cp(w,_,v.transformOrigin);u=x.top,p=x.left,h=x.width,g=x.height,b.x=_.scaleX,b.y=_.scaleY}o&&(i||(p*=o.scaleX,h*=o.scaleX,u*=o.scaleY,g*=o.scaleY),p+=o.x,u+=o.y),super(p,u,h,g),this.scale=b,this.intrinsicWidth=y.width,this.intrinsicHeight=y.height}};function gp(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=Fs(a.effect)?a.effect.getKeyframes():[],i=o[o.length-1];if(!i)continue;const{transform:l,translate:c,scale:d}=i;if(l||c||d){const u=jo({transform:typeof l=="string"&&l?l:t.transform,translate:typeof c=="string"&&c?c:t.translate,scale:typeof d=="string"&&d?d:t.scale});u&&(s=s?{x:s.x+u.x,y:s.y+u.y,z:(n=s.z)!=null?n:u.z,scaleX:s.scaleX*u.scaleX,scaleY:s.scaleY*u.scaleY}:u)}}return s}function gr(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 vp=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(gr(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(gr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(gr(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 kt(e).Element||Pr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function Zo(e){if(!e)return!1;const{KeyboardEvent:t}=kt(e.target);return e instanceof t}function yp(e){if(!e)return!1;const{PointerEvent:t}=kt(e.target);return e instanceof t}function bp(e){if(!pn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||wp(e)}function wp(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var oa={};function Fa(e){const t=oa[e]==null?0:oa[e]+1;return oa[e]=t,`${e}-${t}`}var _p=({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=Tt.distance(t.shape.center,n);return{id:r,value:1/s,type:go.PointerIntersection,priority:mo.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=Tt.distance(t.shape.center,s.current),i=r/(n.current.area+t.shape.area-r)/a;return{id:t.id,value:i,type:go.ShapeIntersection,priority:mo.Normal}}return null},Cp=e=>{var t;return(t=_p(e))!=null?t:xp(e)},kp=Object.create,Ho=Object.defineProperty,Sp=Object.defineProperties,Ep=Object.getOwnPropertyDescriptor,Ip=Object.getOwnPropertyDescriptors,ks=Object.getOwnPropertySymbols,wu=Object.prototype.hasOwnProperty,_u=Object.prototype.propertyIsEnumerable,xu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yn=e=>{throw TypeError(e)},Oa=(e,t,n)=>t in e?Ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Cr=(e,t)=>{for(var n in t||(t={}))wu.call(t,n)&&Oa(e,n,t[n]);if(ks)for(var n of ks(t))_u.call(t,n)&&Oa(e,n,t[n]);return e},No=(e,t)=>Sp(e,Ip(t)),ul=(e,t)=>Ho(e,"name",{value:t,configurable:!0}),Cu=(e,t)=>{var n={};for(var r in e)wu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ks)for(var r of ks(e))t.indexOf(r)<0&&_u.call(e,r)&&(n[r]=e[r]);return n},Un=e=>{var t;return[,,,kp((t=e?.[xu("metadata")])!=null?t:null)]},ku=["class","method","getter","setter","accessor","field","value","get","set"],ur=e=>e!==void 0&&typeof e!="function"?Yn("Function expected"):e,Ap=(e,t,n,r,s)=>({kind:ku[e],name:t,metadata:r,addInitializer:a=>n._?Yn("Already initialized"):s.push(ur(a||null))}),bn=(e,t)=>Oa(t,xu("metadata"),e[3]),Pe=(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},gt=(e,t,n,r,s,a)=>{var o,i,l,c,d,u=t&7,p=!!(t&8),h=!!(t&16),g=u>3?e.length+1:u?p?1:2:0,w=ku[u+5],v=u>3&&(e[g-1]=[]),m=e[g]||(e[g]=[]),b=u&&(!h&&!p&&(s=s.prototype),u<5&&(u>3||!h)&&Ep(u<4?s:{get[n](){return Se(this,a)},set[n](y){return rt(this,a,y)}},n));u?h&&u<4&&ul(a,(u>2?"set ":u>1?"get ":"")+n):ul(s,n);for(var _=r.length-1;_>=0;_--)c=Ap(u,n,l={},e[3],m),u&&(c.static=p,c.private=h,d=c.access={has:h?y=>Mp(s,y):y=>n in y},u^3&&(d.get=h?y=>(u^1?Se:mn)(y,s,u^4?a:b.get):y=>y[n]),u>2&&(d.set=h?(y,x)=>rt(y,s,x,u^4?a:b.set):(y,x)=>y[n]=x)),i=(0,r[_])(u?u<4?h?a:b[w]:u>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,u^4||i===void 0?ur(i)&&(u>4?v.unshift(i):u?h?a=i:b[w]=i:s=i):typeof i!="object"||i===null?Yn("Object expected"):(ur(o=i.get)&&(b.get=o),ur(o=i.set)&&(b.set=o),ur(o=i.init)&&v.unshift(o));return u||bn(e,s),b&&Ho(s,n,b),h?u^4?a:b:s},Xo=(e,t,n)=>t.has(e)||Yn("Cannot "+n),Mp=(e,t)=>Object(t)!==t?Yn('Cannot use the "in" operator on this value'):e.has(t),Se=(e,t,n)=>(Xo(e,t,"read from private field"),n?n.call(e):t.get(e)),$e=(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)=>(Xo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),mn=(e,t,n)=>(Xo(e,t,"access private method"),n),dl={role:"button",roleDescription:"draggable"},$p="dnd-kit-description",Tp="dnd-kit-announcement",Dp={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."},Rp={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 Pp(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Wp(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Fp(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 Op=["dragover","dragmove"],Bp=class extends lt{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=$p,announcement:s=Tp}={},announcements:a=Rp,screenReaderInstructions:o=Dp,debounce:i=500}=t??{},l=n?`${r}-${n}`:Fa(r),c=n?`${s}-${n}`:Fa(s);let d,u,p,h;const g=(x=h)=>{!p||!x||p?.nodeValue!==x&&(p.nodeValue=x)},w=()=>xs.schedule(g),v=Vp(w,i),m=Object.entries(a).map(([x,k])=>this.manager.monitor.addEventListener(x,(S,M)=>{const E=p;if(!E)return;const I=k?.(S,M);I&&E.nodeValue!==I&&(h=I,Op.includes(x)?v():(w(),v.cancel()))})),b=()=>{let x=[];d?.isConnected||(d=Wp(l,o.draggable),x.push(d)),u?.isConnected||(u=Fp(c),p=document.createTextNode(""),u.appendChild(p),x.push(u)),x.length>0&&document.body.append(...x)},_=new Set;function y(){for(const x of _)x()}this.registerEffect(()=>{var x;_.clear();for(const k of this.manager.registry.draggables.value){const S=(x=k.handle)!=null?x:k.element;if(S){(!d||!u)&&_.add(b),(!Pp(S)||Bo())&&!S.hasAttribute("tabindex")&&_.add(()=>S.setAttribute("tabindex","0")),!S.hasAttribute("role")&&S.tagName.toLowerCase()!=="button"&&_.add(()=>S.setAttribute("role",dl.role)),S.hasAttribute("aria-roledescription")||_.add(()=>S.setAttribute("aria-roledescription",dl.roleDescription)),S.hasAttribute("aria-describedby")||_.add(()=>S.setAttribute("aria-describedby",l));for(const E of["aria-pressed","aria-grabbed"]){const I=String(k.isDragging);S.getAttribute(E)!==I&&_.add(()=>S.setAttribute(E,I))}const M=String(k.disabled);S.getAttribute("aria-disabled")!==M&&_.add(()=>S.setAttribute("aria-disabled",M))}}_.size>0&&xs.schedule(y)}),this.destroy=()=>{super.destroy(),d?.remove(),u?.remove(),m.forEach(x=>x())}}};function Vp(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Lp=class extends lt{constructor(e,t){super(e,t),this.manager=e;const n=gs(()=>{var r;return yn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=Ct(()=>{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()}})}},Ss=new Map,Su,Eu,Iu,Au,Ba,vr,Lt,Go,zn,Mu,$u,Tu,Du,wn=class extends(Ba=Rr,Au=[ue],Iu=[Ae],Eu=[Ae],Su=[Ae],Ba){constructor(e){super(e),Pe(Lt,5,this),$e(this,zn),$e(this,vr,new Set),$e(this,Go,Pe(Lt,8,this,new Set)),Pe(Lt,11,this),this.registerEffect(mn(this,zn,Mu))}register(e){return Se(this,vr).add(e),()=>{Se(this,vr).delete(e)}}addRoot(e){return _e(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{_e(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return bs((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return bs((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}};Lt=Un(Ba);vr=new WeakMap;Go=new WeakMap;zn=new WeakSet;Mu=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Se(this,vr))t.push(mn(this,zn,$u).call(this,n,r));return()=>{for(const n of t)n()}};$u=function(e,t){let n=Ss.get(e);n||(n=new Map,Ss.set(e,n));let r=n.get(t);if(!r){const a=Oo(e)?mn(this,zn,Tu).call(this,e,n,t):mn(this,zn,Du).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())}};Tu=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&&Ss.delete(e)}}};Du=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(Vo(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&&Ss.delete(e)}}};gt(Lt,4,"additionalRoots",Au,wn,Go);gt(Lt,2,"sourceRoot",Iu,wn);gt(Lt,2,"targetRoot",Eu,wn);gt(Lt,2,"roots",Su,wn);bn(Lt,wn);var Wr="data-dnd-",Va=`${Wr}dropping`,Je="--dnd-",$t=`${Wr}dragging`,Es=`${Wr}placeholder`,zp=[$t,Es,"popover","aria-pressed","aria-grabbing"],jp=["view-transition-name"],Zp=`
|
|
8
|
+
`)}var hu=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,d=[a,o];a.addEventListener(i,l,c),this.entries.add(d),s.push(d)}return function(){for(const[o,{type:i,listener:l,options:c}]of s)o.removeEventListener(i,l,c)}}};function Vn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Vh(e){const t=new Set;let n=Vn(e);for(;n;)t.add(n),n=Vn(n);return t}function Lh(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function pu(e,t){const n=()=>performance.now();let r,s;return function(...a){const o=this;s?(r?.(),r=Lh(()=>{e.apply(o,a),s=n()},t-(n()-s))):(e.apply(o,a),s=n())}}function zh(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 jh(e,t=e.getBoundingClientRect()){const{width:n,height:r}=ys(e,t);return n>0&&r>0}var Zh=cu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},cs,Hh=class extends Zh{constructor(e){super(t=>{if(!te(this,cs)){pt(this,cs,!0);return}e(t,this)}),ot(this,cs,!1)}};cs=new WeakMap;var il=Array.from({length:100},(e,t)=>t/100),mu=75,ln,ws,Ht,cn,or,Ge,pr,ir,_s,gu,vu,yu=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ot(this,_s),this.disconnect=()=>{var a,o,i;pt(this,pr,!0),(a=te(this,Ht))==null||a.disconnect(),(o=te(this,cn))==null||o.disconnect(),te(this,or).disconnect(),(i=te(this,Ge))==null||i.remove()},ot(this,ln,!0),ot(this,ws),ot(this,Ht),ot(this,cn),ot(this,or),ot(this,Ge),ot(this,pr,!1),ot(this,ir,pu(()=>{var a,o,i;const{element:l}=this;if((a=te(this,cn))==null||a.disconnect(),te(this,pr)||!te(this,ln)||!l.isConnected)return;const c=(o=l.ownerDocument)!=null?o:document,{innerHeight:d,innerWidth:u}=(i=c.defaultView)!=null?i:window,p=l.getBoundingClientRect(),h=ys(l,p),{top:g,left:w,bottom:v,right:m}=h,b=-Math.floor(g),_=-Math.floor(w),y=-Math.floor(u-m),x=-Math.floor(d-v),k=`${b}px ${y}px ${x}px ${_}px`;this.boundingClientRect=p,pt(this,cn,new IntersectionObserver(S=>{const[I]=S,{intersectionRect:E}=I;(I.intersectionRatio!==1?I.intersectionRatio:Tr.intersectionRatio(E,ys(l)))!==1&&te(this,ir).call(this)},{threshold:il,rootMargin:k,root:c})),te(this,cn).observe(l),iu(this,_s,gu).call(this)},mu)),this.boundingClientRect=e.getBoundingClientRect(),pt(this,ln,jh(e,this.boundingClientRect));let r=!0;this.callback=a=>{r&&(r=!1,n.skipInitial)||t(a)};const s=e.ownerDocument;n?.debug&&(pt(this,Ge,document.createElement("div")),te(this,Ge).style.background="rgba(0,0,0,0.15)",te(this,Ge).style.position="fixed",te(this,Ge).style.pointerEvents="none",s.body.appendChild(te(this,Ge))),pt(this,or,new IntersectionObserver(a=>{var o,i;const l=a[a.length-1],{boundingClientRect:c,isIntersecting:d}=l,{width:u,height:p}=c,h=te(this,ln);pt(this,ln,d),!(!u&&!p)&&(h&&!d?((o=te(this,cn))==null||o.disconnect(),this.callback(null),(i=te(this,Ht))==null||i.disconnect(),pt(this,Ht,void 0),te(this,Ge)&&(te(this,Ge).style.visibility="hidden")):te(this,ir).call(this),d&&!te(this,Ht)&&(pt(this,Ht,new Hh(te(this,ir))),te(this,Ht).observe(e)))},{threshold:il,root:s})),te(this,ln)&&!n.skipInitial&&this.callback(this.boundingClientRect),te(this,or).observe(e)}};ln=new WeakMap;ws=new WeakMap;Ht=new WeakMap;cn=new WeakMap;or=new WeakMap;Ge=new WeakMap;pr=new WeakMap;ir=new WeakMap;_s=new WeakSet;gu=function(){te(this,pr)||(iu(this,_s,vu).call(this),!zh(this.boundingClientRect,te(this,ws))&&(this.callback(this.boundingClientRect),pt(this,ws,this.boundingClientRect)))};vu=function(){if(te(this,Ge)){const{top:e,left:t,width:n,height:r}=ys(this.element);te(this,Ge).style.overflow="hidden",te(this,Ge).style.visibility="visible",te(this,Ge).style.top=`${Math.floor(e)}px`,te(this,Ge).style.left=`${Math.floor(t)}px`,te(this,Ge).style.width=`${Math.floor(n)}px`,te(this,Ge).style.height=`${Math.floor(r)}px`}};var Jr=new WeakMap,Qr=new WeakMap;function Nh(e,t){let n=Jr.get(e);return n||(n={disconnect:new yu(e,s=>{const a=Jr.get(e);a&&a.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Jr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Jr.delete(e),n.disconnect())}}function Xh(e,t){const n=new Set;for(const r of e){const s=Nh(r,t);n.add(s)}return()=>n.forEach(r=>r())}function Gh(e,t){var n;const r=e.ownerDocument;if(!Qr.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}),Qr.set(r,{disconnect:()=>o.abort(),listeners:i})}const{listeners:s,disconnect:a}=(n=Qr.get(r))!=null?n:{};return!s||!a?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(a(),Qr.delete(r))})}var lr,cr,us,Ra,Yh=class{constructor(e,t,n){this.callback=t,ot(this,lr),ot(this,cr,!1),ot(this,us),ot(this,Ra,pu(o=>{if(!te(this,cr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const i of te(this,us))if(o.target.contains(i)){this.callback(te(this,lr).boundingClientRect);break}}},mu));const r=Vh(e),s=Xh(r,t),a=Gh(e,te(this,Ra));pt(this,us,r),pt(this,lr,new yu(e,t,n)),this.disconnect=()=>{te(this,cr)||(pt(this,cr,!0),s(),a(),te(this,lr).disconnect())}}};lr=new WeakMap;cr=new WeakMap;us=new WeakMap;Ra=new WeakMap;function Pa(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function xr(e){try{Pa(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function ll(e){return!cu||!e?!1:e===yn(e).scrollingElement}function bu(e){var t,n;const r=kt(e),s=ll(e)?Rh(e):Os(e),a=r.visualViewport,o=ll(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,d=i.current.y>=i.max.y,u=i.current.x>=i.max.x;return{rect:s,position:i,isTop:l,isLeft:c,isBottom:d,isRight:u}}function Uh(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:a,position:o}=bu(e),{x:i,y:l}=t??{x:0,y:0},c=!n&&o.current.y+l>0,d=!r&&o.current.y+l<o.max.y,u=!s&&o.current.x+i>0,p=!a&&o.current.x+i<o.max.x;return{top:c,bottom:d,left:u,right:p,x:u||p,y:c||d}}var Lo=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))}},xs=new Lo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Kh=new Lo(e=>setTimeout(e,50)),Cs=new Map,qh=Cs.clear.bind(Cs);function jt(e,t=!1){if(!t)return cl(e);let n=Cs.get(e);return n||(n=cl(e),Cs.set(e,n),Kh.schedule(qh),n)}function cl(e){return kt(e).getComputedStyle(e)}function Jh(e,t=jt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Qh(e,t=jt(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 ep={excludeElement:!0,escapeShadowDOM:!0};function Wa(e,t=ep){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,a=new Set;function o(i){if(n!=null&&a.size>=n||!i)return a;if(Oo(i)&&i.scrollingElement!=null&&!a.has(i.scrollingElement))return a.add(i.scrollingElement),a;if(s&&Vo(i))return o(i.host);if(!hn(i))return lu(i)?o(i.parentElement):a;if(a.has(i))return a;const l=jt(i,!0);if(r&&i===e||Qh(i,l)&&a.add(i),Jh(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&a.add(c),a}return o(i.parentNode)}return e?o(e):a}function tp(e){const[t]=Wa(e,{limit:1});return t??null}function Ln(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=Os(r),{x:a,y:o}=np(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=Vn(r)}return n}function np(e,t=Os(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=jt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function rp(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 zo(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 jo(e){var t,n,r,s,a,o,i,l,c;const{scale:d,transform:u,translate:p}=e,h=rp(d),g=zo(p),w=sp(u);if(!w&&!h&&!g)return null;const v={x:(t=h?.x)!=null?t:1,y:(n=h?.y)!=null?n:1},m={x:(r=g?.x)!=null?r:0,y:(s=g?.y)!=null?s:0},b={x:(a=w?.x)!=null?a:0,y:(o=w?.y)!=null?o:0,scaleX:(i=w?.scaleX)!=null?i:1,scaleY:(l=w?.scaleY)!=null?l:1};return{x:m.x+b.x,y:m.y+b.y,z:(c=g?.z)!=null?c:0,scaleX:v.x*b.scaleX,scaleY:v.y*b.scaleY}}function sp(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||{}),ap={x:.2,y:.2},op={x:10,y:10};function ip(e,t,n,r=25,s=ap,a=op){const{x:o,y:i}=t,{rect:l,isTop:c,isBottom:d,isLeft:u,isRight:p}=bu(e),h=Ln(e),g=jt(e,!0),w=jo(g),v=w!==null?w?.scaleX<0:!1,m=w!==null?w?.scaleY<0:!1,b=new Tr(l.left*h.scaleX+h.x,l.top*h.scaleY+h.y,l.width*h.scaleX,l.height*h.scaleY),_={x:0,y:0},y={x:0,y:0},x={height:b.height*s.y,width:b.width*s.x};return(!c||m&&!d)&&i<=b.top+x.height&&n?.y!==1&&o>=b.left-a.x&&o<=b.right+a.x?(_.y=m?1:-1,y.y=r*Math.abs((b.top+x.height-i)/x.height)):(!d||m&&!c)&&i>=b.bottom-x.height&&n?.y!==-1&&o>=b.left-a.x&&o<=b.right+a.x&&(_.y=m?-1:1,y.y=r*Math.abs((b.bottom-x.height-i)/x.height)),(!p||v&&!u)&&o>=b.right-x.width&&n?.x!==-1&&i>=b.top-a.y&&i<=b.bottom+a.y?(_.x=v?-1:1,y.x=r*Math.abs((b.right-x.width-o)/x.width)):(!u||v&&!p)&&o<=b.left+x.width&&n?.x!==1&&i>=b.top-a.y&&i<=b.bottom+a.y&&(_.x=v?1:-1,y.x=r*Math.abs((b.left+x.width-o)/x.width)),{direction:_,speed:y}}function lp(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function cp(e,t=!1){if(lp(e)){e.scrollIntoViewIfNeeded(t);return}if(!hn(e))return e.scrollIntoView();var n=tp(e);if(!hn(n))return;const r=jt(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,d=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(d)}function up(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,d=s?e.height*s:e.height;return{width:c,height:d,top:l,right:i+c,bottom:l+d,left:i}}function dp(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,d=s?e.height/s:e.height;return{width:c,height:d,top:l,right:i+c,bottom:l+d,left:i}}function fp({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var hp=new Lo(e=>setTimeout(e,0)),mr=new Map,pp=mr.clear.bind(mr);function mp(e){const t=e.ownerDocument;let n=mr.get(t);if(n)return n;n=t.getAnimations(),mr.set(t,n),hp.schedule(pp);const r=n.filter(s=>Fs(s.effect)&&s.effect.target===e);return mr.set(e,r),n}function gp(e,t){const n=mp(e).filter(r=>{var s,a;if(Fs(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 Vt=class extends Tr{constructor(e,t={}){var n,r,s,a;const{frameTransform:o=Ln(e),ignoreTransforms:i,getBoundingClientRect:l=Os}=t,c=gp(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||Bo())&&x.contains(e)}),d=l(e);let{top:u,left:p,width:h,height:g}=d,w;const v=jt(e),m=jo(v),b={x:(n=m?.scaleX)!=null?n:1,y:(r=m?.scaleY)!=null?r:1},_=vp(e,v);c?.(),m&&(w=dp(d,m,v.transformOrigin),(i||_)&&(u=w.top,p=w.left,h=w.width,g=w.height));const y={width:(s=w?.width)!=null?s:h,height:(a=w?.height)!=null?a:g};if(_&&!i&&w){const x=up(w,_,v.transformOrigin);u=x.top,p=x.left,h=x.width,g=x.height,b.x=_.scaleX,b.y=_.scaleY}o&&(i||(p*=o.scaleX,h*=o.scaleX,u*=o.scaleY,g*=o.scaleY),p+=o.x,u+=o.y),super(p,u,h,g),this.scale=b,this.intrinsicWidth=y.width,this.intrinsicHeight=y.height}};function vp(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=Fs(a.effect)?a.effect.getKeyframes():[],i=o[o.length-1];if(!i)continue;const{transform:l,translate:c,scale:d}=i;if(l||c||d){const u=jo({transform:typeof l=="string"&&l?l:t.transform,translate:typeof c=="string"&&c?c:t.translate,scale:typeof d=="string"&&d?d:t.scale});u&&(s=s?{x:s.x+u.x,y:s.y+u.y,z:(n=s.z)!=null?n:u.z,scaleX:s.scaleX*u.scaleX,scaleY:s.scaleY*u.scaleY}:u)}}return s}function gr(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 yp=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(gr(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(gr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(gr(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 kt(e).Element||Pr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function Zo(e){if(!e)return!1;const{KeyboardEvent:t}=kt(e.target);return e instanceof t}function bp(e){if(!e)return!1;const{PointerEvent:t}=kt(e.target);return e instanceof t}function wp(e){if(!pn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||_p(e)}function _p(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var oa={};function Fa(e){const t=oa[e]==null?0:oa[e]+1;return oa[e]=t,`${e}-${t}`}var xp=({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=Tt.distance(t.shape.center,n);return{id:r,value:1/s,type:go.PointerIntersection,priority:mo.High}}return null},Cp=({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=Tt.distance(t.shape.center,s.current),i=r/(n.current.area+t.shape.area-r)/a;return{id:t.id,value:i,type:go.ShapeIntersection,priority:mo.Normal}}return null},kp=e=>{var t;return(t=xp(e))!=null?t:Cp(e)},Sp=Object.create,Ho=Object.defineProperty,Ep=Object.defineProperties,Ip=Object.getOwnPropertyDescriptor,Ap=Object.getOwnPropertyDescriptors,ks=Object.getOwnPropertySymbols,wu=Object.prototype.hasOwnProperty,_u=Object.prototype.propertyIsEnumerable,xu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yn=e=>{throw TypeError(e)},Oa=(e,t,n)=>t in e?Ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Cr=(e,t)=>{for(var n in t||(t={}))wu.call(t,n)&&Oa(e,n,t[n]);if(ks)for(var n of ks(t))_u.call(t,n)&&Oa(e,n,t[n]);return e},No=(e,t)=>Ep(e,Ap(t)),ul=(e,t)=>Ho(e,"name",{value:t,configurable:!0}),Cu=(e,t)=>{var n={};for(var r in e)wu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ks)for(var r of ks(e))t.indexOf(r)<0&&_u.call(e,r)&&(n[r]=e[r]);return n},Un=e=>{var t;return[,,,Sp((t=e?.[xu("metadata")])!=null?t:null)]},ku=["class","method","getter","setter","accessor","field","value","get","set"],ur=e=>e!==void 0&&typeof e!="function"?Yn("Function expected"):e,Mp=(e,t,n,r,s)=>({kind:ku[e],name:t,metadata:r,addInitializer:a=>n._?Yn("Already initialized"):s.push(ur(a||null))}),bn=(e,t)=>Oa(t,xu("metadata"),e[3]),Pe=(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},gt=(e,t,n,r,s,a)=>{var o,i,l,c,d,u=t&7,p=!!(t&8),h=!!(t&16),g=u>3?e.length+1:u?p?1:2:0,w=ku[u+5],v=u>3&&(e[g-1]=[]),m=e[g]||(e[g]=[]),b=u&&(!h&&!p&&(s=s.prototype),u<5&&(u>3||!h)&&Ip(u<4?s:{get[n](){return Se(this,a)},set[n](y){return rt(this,a,y)}},n));u?h&&u<4&&ul(a,(u>2?"set ":u>1?"get ":"")+n):ul(s,n);for(var _=r.length-1;_>=0;_--)c=Mp(u,n,l={},e[3],m),u&&(c.static=p,c.private=h,d=c.access={has:h?y=>$p(s,y):y=>n in y},u^3&&(d.get=h?y=>(u^1?Se:mn)(y,s,u^4?a:b.get):y=>y[n]),u>2&&(d.set=h?(y,x)=>rt(y,s,x,u^4?a:b.set):(y,x)=>y[n]=x)),i=(0,r[_])(u?u<4?h?a:b[w]:u>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,u^4||i===void 0?ur(i)&&(u>4?v.unshift(i):u?h?a=i:b[w]=i:s=i):typeof i!="object"||i===null?Yn("Object expected"):(ur(o=i.get)&&(b.get=o),ur(o=i.set)&&(b.set=o),ur(o=i.init)&&v.unshift(o));return u||bn(e,s),b&&Ho(s,n,b),h?u^4?a:b:s},Xo=(e,t,n)=>t.has(e)||Yn("Cannot "+n),$p=(e,t)=>Object(t)!==t?Yn('Cannot use the "in" operator on this value'):e.has(t),Se=(e,t,n)=>(Xo(e,t,"read from private field"),n?n.call(e):t.get(e)),$e=(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)=>(Xo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),mn=(e,t,n)=>(Xo(e,t,"access private method"),n),dl={role:"button",roleDescription:"draggable"},Tp="dnd-kit-description",Dp="dnd-kit-announcement",Rp={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."},Pp={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 Wp(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Fp(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Op(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 Bp=["dragover","dragmove"],Vp=class extends lt{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Tp,announcement:s=Dp}={},announcements:a=Pp,screenReaderInstructions:o=Rp,debounce:i=500}=t??{},l=n?`${r}-${n}`:Fa(r),c=n?`${s}-${n}`:Fa(s);let d,u,p,h;const g=(x=h)=>{!p||!x||p?.nodeValue!==x&&(p.nodeValue=x)},w=()=>xs.schedule(g),v=Lp(w,i),m=Object.entries(a).map(([x,k])=>this.manager.monitor.addEventListener(x,(S,I)=>{const E=p;if(!E)return;const M=k?.(S,I);M&&E.nodeValue!==M&&(h=M,Bp.includes(x)?v():(w(),v.cancel()))})),b=()=>{let x=[];d?.isConnected||(d=Fp(l,o.draggable),x.push(d)),u?.isConnected||(u=Op(c),p=document.createTextNode(""),u.appendChild(p),x.push(u)),x.length>0&&document.body.append(...x)},_=new Set;function y(){for(const x of _)x()}this.registerEffect(()=>{var x;_.clear();for(const k of this.manager.registry.draggables.value){const S=(x=k.handle)!=null?x:k.element;if(S){(!d||!u)&&_.add(b),(!Wp(S)||Bo())&&!S.hasAttribute("tabindex")&&_.add(()=>S.setAttribute("tabindex","0")),!S.hasAttribute("role")&&S.tagName.toLowerCase()!=="button"&&_.add(()=>S.setAttribute("role",dl.role)),S.hasAttribute("aria-roledescription")||_.add(()=>S.setAttribute("aria-roledescription",dl.roleDescription)),S.hasAttribute("aria-describedby")||_.add(()=>S.setAttribute("aria-describedby",l));for(const E of["aria-pressed","aria-grabbed"]){const M=String(k.isDragging);S.getAttribute(E)!==M&&_.add(()=>S.setAttribute(E,M))}const I=String(k.disabled);S.getAttribute("aria-disabled")!==I&&_.add(()=>S.setAttribute("aria-disabled",I))}}_.size>0&&xs.schedule(y)}),this.destroy=()=>{super.destroy(),d?.remove(),u?.remove(),m.forEach(x=>x())}}};function Lp(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var zp=class extends lt{constructor(e,t){super(e,t),this.manager=e;const n=gs(()=>{var r;return yn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=Ct(()=>{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()}})}},Ss=new Map,Su,Eu,Iu,Au,Ba,vr,Lt,Go,zn,Mu,$u,Tu,Du,wn=class extends(Ba=Rr,Au=[ue],Iu=[Ae],Eu=[Ae],Su=[Ae],Ba){constructor(e){super(e),Pe(Lt,5,this),$e(this,zn),$e(this,vr,new Set),$e(this,Go,Pe(Lt,8,this,new Set)),Pe(Lt,11,this),this.registerEffect(mn(this,zn,Mu))}register(e){return Se(this,vr).add(e),()=>{Se(this,vr).delete(e)}}addRoot(e){return _e(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{_e(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return bs((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return bs((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}};Lt=Un(Ba);vr=new WeakMap;Go=new WeakMap;zn=new WeakSet;Mu=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Se(this,vr))t.push(mn(this,zn,$u).call(this,n,r));return()=>{for(const n of t)n()}};$u=function(e,t){let n=Ss.get(e);n||(n=new Map,Ss.set(e,n));let r=n.get(t);if(!r){const a=Oo(e)?mn(this,zn,Tu).call(this,e,n,t):mn(this,zn,Du).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())}};Tu=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&&Ss.delete(e)}}};Du=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(Vo(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&&Ss.delete(e)}}};gt(Lt,4,"additionalRoots",Au,wn,Go);gt(Lt,2,"sourceRoot",Iu,wn);gt(Lt,2,"targetRoot",Eu,wn);gt(Lt,2,"roots",Su,wn);bn(Lt,wn);var Wr="data-dnd-",Va=`${Wr}dropping`,Je="--dnd-",$t=`${Wr}dragging`,Es=`${Wr}placeholder`,jp=[$t,Es,"popover","aria-pressed","aria-grabbing"],Zp=["view-transition-name"],Hp=`
|
|
9
9
|
:is(:root,:host) [${$t}] {
|
|
10
10
|
position: fixed !important;
|
|
11
11
|
pointer-events: none !important;
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
display: none;
|
|
64
64
|
visibility: hidden;
|
|
65
65
|
}
|
|
66
|
-
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Hp(e,t="hidden"){return _e(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Np(n,r.registry.droppables),a=[],o=Wh(n),{remove:i}=o;return Xp(s,o,a),Gp(o,t),o.remove=()=>{a.forEach(l=>l()),i.call(o)},o})}function Np(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Wr}${Fa("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function Xp(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),ol.set(i,o),n.push(()=>{ol.delete(i),r.proxy=void 0})}}function Gp(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Es,t)}function Ru(e,t){return e===t?!0:Vn(e)===Vn(t)}function fl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&pn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>xr(t))}function La(e){return e.tagName==="TR"}function Yp(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-")||zp.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(gr(e)&&gr(t)){const c=e.style;for(const d of Array.from(t.style))c.getPropertyValue(d)===""&&t.style.removeProperty(d);for(const d of Array.from(c)){if(jp.includes(d)||d.startsWith(Je))continue;const u=c.getPropertyValue(d);t.style.setProperty(d,u)}}}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 Up(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),xr(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),xr(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Kp(e){return new ResizeObserver(()=>{var t,n;const r=new Vt(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},a=(e.width-r.width)*s.x+e.delta.x,o=(e.height-r.height)*s.y+e.delta.y,i=uu();if(e.styles.set({width:r.width-e.widthOffset,height:r.height-e.heightOffset,top:e.top+o+i.y,left:e.left+a+i.x},Je),(n=e.getElementMutationObserver())==null||n.takeRecords(),La(e.element)&&La(e.placeholder)){const l=Array.from(e.element.cells),c=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(l.map(d=>d.style.width));for(const[d,u]of l.entries()){const p=c[d];u.style.width=`${p.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Vt(e.feedbackElement)})}var qp=250,Jp="ease";function Qp(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=qp,easing:i=Jp}=a??{};xr(e.feedbackElement);const[,l]=(t=Th(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,d={frameTransform:Ru(e.feedbackElement,c)?null:void 0},u=new Vt(e.feedbackElement,d),p=(r=zo(jt(e.feedbackElement).translate))!=null?r:e.translate,h=new Vt(c,d),g=Tr.delta(u,h,e.alignment),w={x:p.x-g.x,y:p.y-g.y},v=Math.round(u.intrinsicHeight)!==Math.round(h.intrinsicHeight)?{minHeight:[`${u.intrinsicHeight}px`,`${h.intrinsicHeight}px`],maxHeight:[`${u.intrinsicHeight}px`,`${h.intrinsicHeight}px`]}:{},m=Math.round(u.intrinsicWidth)!==Math.round(h.intrinsicWidth)?{minWidth:[`${u.intrinsicWidth}px`,`${h.intrinsicWidth}px`],maxWidth:[`${u.intrinsicWidth}px`,`${h.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Je),e.feedbackElement.setAttribute(Va,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),dp({element:e.feedbackElement,keyframes:No(Cr(Cr({},v),m),{translate:[`${p.x}px ${p.y}px 0`,`${w.x}px ${w.y}px 0`]}),options:{duration:du(kt(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(Va),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Pu,za,kr,Yo,ds,Wu,Fu,Sr=class extends(za=lt,Pu=[ue],za){constructor(t,n){super(t,n),$e(this,ds),$e(this,Yo,Pe(kr,8,this)),Pe(kr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(wn),s=r?.register(Zp);if(s){const a=this.destroy.bind(this);this.destroy=()=>{s(),a()}}this.registerEffect(mn(this,ds,Wu).bind(this,r)),this.registerEffect(mn(this,ds,Fu))}};kr=Un(za);Yo=new WeakMap;ds=new WeakSet;Wu=function(e){const{overlay:t}=this;if(!t||!e)return;const n=bs(t);if(n)return e.addRoot(n)};Fu=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:d,feedback:u}=l;if(!d||u==="none"||!c.initialized||c.initializing)return;const{initial:p}=r,h=(e=this.overlay)!=null?e:d,g=Ln(h),w=Ln(d),v=!Ru(d,h),m=new Vt(d,{frameTransform:v?w:null,ignoreTransforms:!v}),b={x:w.scaleX/g.scaleX,y:w.scaleY/g.scaleY};let{width:_,height:y,top:x,left:k}=m;v&&(_=_/b.x,y=y/b.y);const S=new vp(h),{transition:M,translate:E,boxSizing:I,paddingBlockStart:T,paddingBlockEnd:P,paddingInlineStart:A,paddingInlineEnd:W,borderInlineStartWidth:O,borderInlineEndWidth:Y,borderBlockStartWidth:U,borderBlockEndWidth:J}=jt(d),B=u==="clone",se=I==="content-box",ie=se?parseInt(A)+parseInt(W)+parseInt(O)+parseInt(Y):0,ee=se?parseInt(T)+parseInt(P)+parseInt(U)+parseInt(J):0,ae=u!=="move"&&!this.overlay?Hp(l,B?"clone":"hidden"):null,me=_e(()=>Zo(s.dragOperation.activatorEvent));if(E!=="none"){const ne=zo(E);ne&&!p.translate&&(p.translate=ne)}if(!p.transformOrigin){const ne=_e(()=>i.current);p.transformOrigin={x:(ne.x-k*g.scaleX-g.x)/(_*g.scaleX),y:(ne.y-x*g.scaleY-g.y)/(y*g.scaleY)}}const{transformOrigin:ye}=p,De=x*g.scaleY+g.y,H=k*g.scaleX+g.x;if(!p.coordinates&&(p.coordinates={x:H,y:De},b.x!==1||b.y!==1)){const{scaleX:ne,scaleY:be}=w,{x:Ee,y:je}=ye;p.coordinates.x+=(_*ne-_)*Ee,p.coordinates.y+=(y*be-y)*je}p.dimensions||(p.dimensions={width:_,height:y}),p.frameTransform||(p.frameTransform=g);const Z={x:p.coordinates.x-H,y:p.coordinates.y-De},de={width:(p.dimensions.width*p.frameTransform.scaleX-_*g.scaleX)*ye.x,height:(p.dimensions.height*p.frameTransform.scaleY-y*g.scaleY)*ye.y},N={x:Z.x/g.scaleX+de.width,y:Z.y/g.scaleY+de.height},$={left:k+N.x,top:x+N.y};h.setAttribute($t,"true");const he=_e(()=>o.transform),We=(t=p.translate)!=null?t:{x:0,y:0},q=he.x*g.scaleX+We.x,ge=he.y*g.scaleY+We.y,Le=uu();S.set({width:_-ie,height:y-ee,top:$.top+Le.y,left:$.left+Le.x,translate:`${q}px ${ge}px 0`,transition:M?`${M}, translate 0ms linear`:"",scale:v?`${b.x} ${b.y}`:"","transform-origin":`${ye.x*100}% ${ye.y*100}%`},Je),ae&&(d.insertAdjacentElement("afterend",ae),a?.rootElement&&(typeof a.rootElement=="function"?a.rootElement(l):a.rootElement).appendChild(d)),Pa(h)&&(h.hasAttribute("popover")||h.setAttribute("popover","manual"),xr(h),h.addEventListener("beforetoggle",fl));let Ne,K,Re;const ze=Kp({placeholder:ae,element:d,feedbackElement:h,frameTransform:g,transformOrigin:ye,width:_,height:y,top:x,left:k,widthOffset:ie,heightOffset:ee,delta:N,styles:S,dragOperation:o,getElementMutationObserver:()=>Ne,getSavedCellWidths:()=>Re,setSavedCellWidths:ne=>{Re=ne}}),xe=new Vt(h);_e(()=>o.shape=xe);const Xe=kt(h),Ue=ne=>{this.manager.actions.stop({event:ne})},at=du(Xe);me&&Xe.addEventListener("resize",Ue),_e(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),ae&&(ze.observe(ae),Ne=Yp(d,ae,B),K=Up(d,ae,h));const yt=(n=s.dragOperation.source)==null?void 0:n.id,At=()=>{var ne;if(!me||yt==null)return;const be=s.registry.draggables.get(yt),Ee=(ne=be?.handle)!=null?ne:be?.element;hn(Ee)&&Ee.focus()},X=()=>{var ne;if(Ne?.disconnect(),K?.disconnect(),ze.disconnect(),Xe.removeEventListener("resize",Ue),Pa(h)&&(h.removeEventListener("beforetoggle",fl),h.removeAttribute("popover")),h.removeAttribute($t),S.reset(),Re&&La(d)){const Ee=Array.from(d.cells);for(const[je,bt]of Ee.entries())bt.style.width=(ne=Re[je])!=null?ne:""}l.status="idle";const be=r.current.translate!=null;ae&&(be||ae.parentElement!==h.parentElement)&&h.isConnected&&ae.replaceWith(h),ae?.remove()},le=a?.dropAnimation,Fe=this,Ke=$r(()=>{var ne;const{transform:be,status:Ee}=o;if(!(!be.x&&!be.y&&!r.current.translate)&&Ee.dragging){const je=(ne=p.translate)!=null?ne:{x:0,y:0},bt={x:be.x/g.scaleX+je.x,y:be.y/g.scaleY+je.y},L=r.current.translate,G=_e(()=>o.modifiers),te=_e(()=>{var ve;return(ve=o.shape)==null?void 0:ve.current}),Ce=me&&!at?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(S.set({transition:`${M}, translate ${Ce}`,translate:`${bt.x}px ${bt.y}px 0`},Je),Ne?.takeRecords(),te&&te!==xe&&L&&!G.length){const ve=Tt.delta(bt,L);o.shape=Tr.from(te.boundingRectangle).translate(ve.x*g.scaleX,ve.y*g.scaleY)}else o.shape=new Vt(h);r.current.translate=bt}},function(){if(o.status.dropped){this.dispose(),l.status="dropping";const ne=Fe.dropAnimation!==void 0?Fe.dropAnimation:le;let be=r.current.translate;const Ee=be!=null;if(!be&&d!==h&&(be={x:0,y:0}),!be||ne===null){X();return}s.renderer.rendering.then(()=>{Qp({element:d,feedbackElement:h,placeholder:ae,translate:be,moved:Ee,transition:M,alignment:l.alignment,styles:S,animation:ne??void 0,getElementMutationObserver:()=>Ne,cleanup:X,restoreFocus:At})})}});return()=>{X(),Ke()}};gt(kr,4,"overlay",Pu,Sr,Yo);bn(kr,Sr);Sr.configure=Gn(Sr);var ja=Sr,qn=!0,em=!1,Ou,Bu,Vu,Lu,Gt,Uo,Ko;Lu=(Vu=[ue],_t.Forward),Bu=(Ou=[ue],_t.Reverse);var Er=class{constructor(){$e(this,Uo,Pe(Gt,8,this,qn)),Pe(Gt,11,this),$e(this,Ko,Pe(Gt,12,this,qn)),Pe(Gt,15,this)}isLocked(e){return e===_t.Idle?!1:e==null?this[_t.Forward]===qn&&this[_t.Reverse]===qn:this[e]===qn}unlock(e){e!==_t.Idle&&(this[e]=em)}};Gt=Un(null);Uo=new WeakMap;Ko=new WeakMap;gt(Gt,4,Lu,Vu,Er,Uo);gt(Gt,4,Bu,Ou,Er,Ko);bn(Gt,Er);var tm=[_t.Forward,_t.Reverse],hl=class{constructor(){this.x=new Er,this.y=new Er}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},nm=class extends lt{constructor(e){super(e);const t=Mr(new hl);let n=null;this.signal=t,Ct(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new hl;return}const{delta:s}=e.dragOperation.position;if(n){const a={x:pl(s.x,n.x),y:pl(s.y,n.y)},o=t.peek();Kt(()=>{for(const i of vc)for(const l of tm)a[i]===l&&o[i].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function pl(e,t){return Math.sign(e-t)}var zu,Za,Ir,qo,Nt,Ha,Bs=class extends(Za=Rr,zu=[ue],Za){constructor(e){super(e),$e(this,qo,Pe(Ir,8,this,!1)),Pe(Ir,11,this),$e(this,Nt),$e(this,Ha,()=>{if(!Se(this,Nt))return;const{element:a,by:o}=Se(this,Nt);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,Nt,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:d}=a??{},u=d?{x:ml(d.x),y:ml(d.y)}:void 0,p=u?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const h of i){const g=Yh(h,d);if(g.x||g.y){const{speed:w,direction:v}=op(h,c,u);if(p)for(const m of vc)p[m].isLocked(v[m])&&(w[m]=0,v[m]=0);if(v.x||v.y){const{x:m,y:b}=d??v,_=m*w.x,y=b*w.y;if(_||y){const x=(o=Se(this,Nt))==null?void 0:o.by;if(this.autoScrolling&&x&&(x.x&&!_||x.y&&!y))continue;return rt(this,Nt,{element:h,by:{x:_,y}}),xs.schedule(Se(this,Ha)),!0}}}}}return rt(this,Nt,void 0),!1};let t=null,n=null;const r=gs(()=>{const{position:a,source:o}=e.dragOperation;if(!a)return null;const i=fu(bs(o?.element),a.current);return i&&(t=i),i??t}),s=gs(()=>{const a=r.value,{documentElement:o}=yn(a);if(!a||a===o){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=Wa(l,{excludeElement:!1});return n=c,c}}if(a){const i=Wa(a,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},br);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new nm(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!Zo(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Ir=Un(Za);qo=new WeakMap;Nt=new WeakMap;Ha=new WeakMap;gt(Ir,4,"autoScrolling",zu,Bs,qo);bn(Ir,Bs);function ml(e){return e>0?_t.Forward:e<0?_t.Reverse:_t.Idle}var rm=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))}},sm=new rm(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),am=10,ju=class extends lt{constructor(e,t){super(e);const n=e.registry.plugins.get(Bs);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 o=setInterval(()=>sm.schedule(n.scroll),am);return()=>{clearInterval(o)}}else n.autoScrolling=!1})}},gl={capture:!0,passive:!0},dr,om=class extends Rr{constructor(e){super(e),$e(this,dr),this.handleScroll=()=>{Se(this,dr)==null&&rt(this,dr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),rt(this,dr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=Ct(()=>{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,gl),()=>{o.removeEventListener("scroll",this.handleScroll,gl)}}})}};dr=new WeakMap;var im=class extends lt{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 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),ia(),document.addEventListener("selectionchange",ia,{capture:!0}),()=>{document.removeEventListener("selectionchange",ia,{capture:!0}),a.remove()}}})}};function ia(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var fr=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,Is=class extends On{constructor(t,n){super(t),this.manager=t,this.options=n,$e(this,Dn,[]),this.listeners=new hu,this.handleSourceKeyDown=(r,s,a)=>{if(this.disabled||r.defaultPrevented||!pn(r.target)||s.disabled)return;const{keyboardCodes:o=fr.keyboardCodes,preventActivation:i=fr.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 Ct(()=>{var s;const a=(s=t.handle)!=null?s:t.element,o=i=>{Zo(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(),lp(s);const{center:a}=new Vt(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=yn(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=fr.keyboardCodes}=r??{};if(En(t,[...s.end,...s.cancel])){t.preventDefault();const a=En(t,s.cancel);this.handleEnd(t,a);return}En(t,s.up)?this.handleMove("up",t):En(t,s.down)&&this.handleMove("down",t),En(t,s.left)?this.handleMove("left",t):En(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:fr.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(ju);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;Is.configure=Gn(Is);Is.defaults=fr;var lm=Is;function En(e,t){return t.includes(e.code)}var un,cm=class extends Kc{constructor(){super(...arguments),$e(this,un)}onEvent(e){switch(e.type){case"pointerdown":rt(this,un,Bn(e));break;case"pointermove":if(!Se(this,un))return;const{x:t,y:n}=Bn(e),r={x:t-Se(this,un).x,y:n-Se(this,un).y},{tolerance:s}=this.options;if(s&&Aa(r,s)){this.abort();return}Aa(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){rt(this,un,void 0)}};un=new WeakMap;var Rn,dn,um=class extends Kc{constructor(){super(...arguments),$e(this,Rn),$e(this,dn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,dn,Bn(e)),rt(this,Rn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Se(this,dn))return;const{x:t,y:n}=Bn(e),r={x:t-Se(this,dn).x,y:n-Se(this,dn).y};Aa(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Se(this,Rn)&&(clearTimeout(Se(this,Rn)),rt(this,dn,void 0),rt(this,Rn,void 0))}};Rn=new WeakMap;dn=new WeakMap;var Ot=class{};Ot.Delay=um;Ot.Distance=cm;var Na=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})]:bp(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:Oh(r)}}),Pn,As=class extends On{constructor(t,n){super(t),this.manager=t,this.options=n,$e(this,Pn,new Set),this.listeners=new hu,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=Na.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return Ct(()=>{var s;const a=new AbortController,{signal:o}=a,i=c=>{yp(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&&(hm(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||dm(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=Na.preventActivation}=r??{};if(s?.(t,n))return;const{target:a}=t,o=hn(a)&&a.draggable&&a.getAttribute("draggable")==="true",i=Ln(n.element),{x:l,y:c}=Bn(t);this.initialCoordinates={x:l*i.scaleX+i.x,y:c*i.scaleY+i.y};const d=this.activationConstraints(t,n,r);t.sensor=this;const u=new Ih(d,w=>this.handleStart(n,w));u.signal.onabort=()=>this.handleCancel(t),u.onEvent(t),this.controller=u;const p=Da(),h=this.listeners.bind(p,[{type:"pointermove",listener:w=>this.handlePointerMove(w,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:es,options:{capture:!0}}]),g=()=>{h(),this.initialCoordinates=void 0};Se(this,Pn).add(g)}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=Bn(t),o=Ln(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,xs.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=yn(n.target).body;i.setPointerCapture(n.pointerId);const l=pn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:es,options:{passive:!1}},{type:"click",listener:es},{type:"contextmenu",listener:es},{type:"keydown",listener:this.handleKeyDown}]);Se(this,Pn).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,Pn).forEach(t=>t()),Se(this,Pn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Pn=new WeakMap;As.configure=Gn(As);As.defaults=Na;var Xa=As;function dm(e){return"sensor"in e}function es(e){e.preventDefault()}function fm(){}var vl=new WeakSet;function hm(e){!e||vl.has(e)||(e.addEventListener("touchmove",fm,{capture:!1,passive:!1}),vl.add(e))}var Wn={modifiers:[],plugins:[Bp,ju,Lp,ja,im],sensors:[Xa,lm]},Jo=class extends $h{constructor(e={}){const t=Bt(e.plugins,Wn.plugins),n=Bt(e.sensors,Wn.sensors),r=Bt(e.modifiers,Wn.modifiers);super(No(Cr({},e),{plugins:[om,Bs,wn,...t],sensors:n,modifiers:r}))}},Zu,Hu,Nu,Ga,Et,Qo,ei,ti,Fr=class extends(Ga=Dt,Nu=[ue],Hu=[ue],Zu=[ue],Ga){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:a,feedback:o="default"}=n,i=Cu(n,["element","effects","handle","feedback"]);super(Cr({effects:()=>[...s(),()=>{var l,c;const{manager:d}=this;if(!d)return;const p=((c=(l=this.sensors)==null?void 0:l.map(ho))!=null?c:[...d.sensors]).map(h=>{const g=h instanceof On?h:d.registry.register(h.plugin),w=h instanceof On?void 0:h.options;return g.bind(this,w)});return function(){p.forEach(g=>g())}}]},i),t),$e(this,Qo,Pe(Et,8,this)),Pe(Et,11,this),$e(this,ei,Pe(Et,12,this)),Pe(Et,15,this),$e(this,ti,Pe(Et,16,this)),Pe(Et,19,this),this.element=r,this.handle=a,this.feedback=o}};Et=Un(Ga);Qo=new WeakMap;ei=new WeakMap;ti=new WeakMap;gt(Et,4,"handle",Nu,Fr,Qo);gt(Et,4,"element",Hu,Fr,ei);gt(Et,4,"feedback",Zu,Fr,ti);bn(Et,Fr);var Xu,Gu,Ya,Yt,ni,la,Yu,Uu,yr,ri,Ku=class extends(Ya=Rt,Gu=[ue],Xu=[ue],Ya){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,a=Cu(n,["element","effects"]);const{collisionDetector:o=Cp}=a,i=c=>{const{manager:d,element:u}=this;if(!u||c===null){this.shape=void 0;return}if(!d)return;const p=new Vt(u),h=_e(()=>this.shape);return p&&h?.equals(p)?h:(this.shape=p,p)},l=Mr(!1);super(No(Cr({},a),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:c,manager:d}=this;if(!d)return;const{dragOperation:u}=d,{source:p}=u;l.value=!!(p&&u.status.initialized&&c&&!this.disabled&&this.accepts(p))},()=>{const{element:c}=this;if(l.value&&c){const d=new Gh(c,i);return()=>{d.disconnect(),this.shape=void 0}}},()=>{var c;if((c=this.manager)!=null&&c.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),$e(this,yr),$e(this,ni,Pe(Yt,8,this)),Pe(Yt,11,this),$e(this,ri,Pe(Yt,12,this)),Pe(Yt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){rt(this,yr,e,Uu)}get element(){var e;return(e=this.proxy)!=null?e:Se(this,yr,Yu)}};Yt=Un(Ya);ni=new WeakMap;yr=new WeakSet;ri=new WeakMap;la=gt(Yt,20,"#element",Gu,yr,ni),Yu=la.get,Uu=la.set;gt(Yt,4,"proxy",Xu,Ku,ri);bn(Yt,Ku);function pm(e){return e!=null&&typeof e=="object"&&"current"in e}function Ms(e){var t;if(e!=null)return pm(e)?(t=e.current)!=null?t:void 0:e}var mm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Vs=mm?f.useLayoutEffect:f.useEffect;function gm(){const e=f.useState(0)[1];return f.useCallback(()=>{e(t=>t+1)},[e])}function vm(e,t){const n=f.useRef(new Map),r=gm();return Vs(()=>{if(!e){n.current.clear();return}return Ct(()=>{var s;let a=!1,o=!1;for(const i of n.current){const[l]=i,c=_e(()=>i[1]),d=e[l];c!==d&&(a=!0,n.current.set(l,d),o=(s=t?.(l,c,d))!=null?s:!1)}a&&(o?ro.flushSync(r):r())})},[e]),f.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=f.useEffect,r=Object.is){const s=f.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}function yl(e,t){const n=f.useRef(Ms(e));Vs(()=>{const r=Ms(e);r!==n.current&&(n.current=r,t(r))})}var ym=Object.defineProperty,bm=Object.defineProperties,wm=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,_m=Object.prototype.hasOwnProperty,xm=Object.prototype.propertyIsEnumerable,wl=(e,t,n)=>t in e?ym(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Cm=(e,t)=>{for(var n in t||(t={}))_m.call(t,n)&&wl(e,n,t[n]);if(bl)for(var n of bl(t))xm.call(t,n)&&wl(e,n,t[n]);return e},km=(e,t)=>bm(e,wm(t)),Sm=new Jo,Em=f.createContext(Sm);f.memo(f.forwardRef(({children:e},t)=>{const[n,r]=f.useState(0),s=f.useRef(null),a=f.useRef(null),o=f.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})),f.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Vs(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),f.useImperativeHandle(t,()=>o),null}));function Im(){return f.useContext(Em)}function Am(e){var t;const n=(t=Im())!=null?t:void 0,[r]=f.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Vs(r.register,[n,r]),r}function ca(e){const{disabled:t,data:n,element:r,handle:s,id:a,modifiers:o,sensors:i}=e,l=Am(d=>new Fr(km(Cm({},e),{register:!1,handle:Ms(s),element:Ms(r)}),d)),c=vm(l,Mm);return an(a,()=>l.id=a),yl(s,d=>l.handle=d),yl(r,d=>l.element=d),an(n,()=>n&&(l.data=n)),an(t,()=>l.disabled=t===!0),an(i,()=>l.sensors=i),an(o,()=>l.modifiers=o,void 0,br),an(e.feedback,()=>{var d;return l.feedback=(d=e.feedback)!=null?d:"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:f.useCallback(d=>{l.handle=d??void 0},[l]),ref:f.useCallback(d=>{var u,p;!d&&((u=l.element)!=null&&u.isConnected)&&!((p=l.manager)!=null&&p.dragOperation.status.idle)||(l.element=d??void 0)},[l])}}function Mm(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var $m=Object.create,qu=Object.defineProperty,Tm=Object.getOwnPropertyDescriptor,Ju=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ls=e=>{throw TypeError(e)},Dm=(e,t,n)=>t in e?qu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rm=e=>{var t;return[,,,$m((t=e?.[Ju("metadata")])!=null?t:null)]},Qu=["class","method","getter","setter","accessor","field","value","get","set"],ed=e=>e!==void 0&&typeof e!="function"?Ls("Function expected"):e,Pm=(e,t,n,r,s)=>({kind:Qu[e],name:t,metadata:r,addInitializer:a=>n._?Ls("Already initialized"):s.push(ed(a||null))}),Wm=(e,t)=>Dm(t,Ju("metadata"),e[3]),Fm=(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},td=(e,t,n,r,s,a)=>{for(var o,i,l,c,d=t&7,u=!1,p=!1,h=2,g=Qu[d+5],w=e[h]||(e[h]=[]),v=(s=s.prototype,Tm(s,n)),m=r.length-1;m>=0;m--)l=Pm(d,n,i={},e[3],w),l.static=u,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[m])(v[g],l),i._=1,ed(o)&&(v[g]=o);return v&&qu(s,n,v),s},nd=(e,t,n)=>t.has(e)||Ls("Cannot "+n),Om=(e,t,n)=>(nd(e,t,"read from private field"),t.get(e)),Bm=(e,t,n)=>t.has(e)?Ls("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Vm=(e,t,n,r)=>(nd(e,t,"write to private field"),t.set(e,n),n),Jn=class Ua{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ua(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 Ua(t,n)}},rd,sd,Ka,fs,Or,si=class extends(Ka=Jt,sd=[Ae],rd=[Ae],Ka){constructor(t){const n=Jn.from(t);super(n,(r,s)=>Jn.equals(r,s)),Fm(Or,5,this),Bm(this,fs,0),this.velocity={x:0,y:0}}get delta(){return Jn.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=Jn.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-Om(this,fs),i=l=>Math.round(l/o*100);Kt(()=>{Vm(this,fs,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Jn.from(t)),this.velocity={x:0,y:0}}};Or=Rm(Ka);fs=new WeakMap;td(Or,2,"delta",sd,si);td(Or,2,"direction",rd,si);Wm(Or,si);var ad=(e=>(e.Horizontal="x",e.Vertical="y",e))(ad||{});Object.values(ad);const Lm=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"}))]]),zm=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"}))]]),jm=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"}))]]),Zm=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"}))]]),Hm=f.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Br=D.forwardRef((e,t)=>{const{alt:n,color:r,size:s,weight:a,mirrored:o,children:i,weights:l,...c}=e,{color:d="currentColor",size:u,weight:p="regular",mirrored:h=!1,...g}=D.useContext(Hm);return D.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:s??u,height:s??u,fill:r??d,viewBox:"0 0 256 256",transform:o||h?"scale(-1, 1)":void 0,...g,...c},!!n&&D.createElement("title",null,n),i,l.get(a??p))});Br.displayName="IconBase";const od=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:Lm}));od.displayName="DotsThreeIcon";const id=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:zm}));id.displayName="SpeakerHighIcon";const ld=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:jm}));ld.displayName="SpeakerLowIcon";const cd=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:Zm}));cd.displayName="XIcon";const Nm=cd;R.span`
|
|
66
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Np(e,t="hidden"){return _e(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Xp(n,r.registry.droppables),a=[],o=Fh(n),{remove:i}=o;return Gp(s,o,a),Yp(o,t),o.remove=()=>{a.forEach(l=>l()),i.call(o)},o})}function Xp(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Wr}${Fa("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function Gp(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),ol.set(i,o),n.push(()=>{ol.delete(i),r.proxy=void 0})}}function Yp(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Es,t)}function Ru(e,t){return e===t?!0:Vn(e)===Vn(t)}function fl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&pn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>xr(t))}function La(e){return e.tagName==="TR"}function Up(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-")||jp.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(gr(e)&&gr(t)){const c=e.style;for(const d of Array.from(t.style))c.getPropertyValue(d)===""&&t.style.removeProperty(d);for(const d of Array.from(c)){if(Zp.includes(d)||d.startsWith(Je))continue;const u=c.getPropertyValue(d);t.style.setProperty(d,u)}}}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 Kp(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),xr(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),xr(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function qp(e){return new ResizeObserver(()=>{var t,n;const r=new Vt(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},a=(e.width-r.width)*s.x+e.delta.x,o=(e.height-r.height)*s.y+e.delta.y,i=uu();if(e.styles.set({width:r.width-e.widthOffset,height:r.height-e.heightOffset,top:e.top+o+i.y,left:e.left+a+i.x},Je),(n=e.getElementMutationObserver())==null||n.takeRecords(),La(e.element)&&La(e.placeholder)){const l=Array.from(e.element.cells),c=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(l.map(d=>d.style.width));for(const[d,u]of l.entries()){const p=c[d];u.style.width=`${p.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Vt(e.feedbackElement)})}var Jp=250,Qp="ease";function em(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=Jp,easing:i=Qp}=a??{};xr(e.feedbackElement);const[,l]=(t=Dh(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,d={frameTransform:Ru(e.feedbackElement,c)?null:void 0},u=new Vt(e.feedbackElement,d),p=(r=zo(jt(e.feedbackElement).translate))!=null?r:e.translate,h=new Vt(c,d),g=Tr.delta(u,h,e.alignment),w={x:p.x-g.x,y:p.y-g.y},v=Math.round(u.intrinsicHeight)!==Math.round(h.intrinsicHeight)?{minHeight:[`${u.intrinsicHeight}px`,`${h.intrinsicHeight}px`],maxHeight:[`${u.intrinsicHeight}px`,`${h.intrinsicHeight}px`]}:{},m=Math.round(u.intrinsicWidth)!==Math.round(h.intrinsicWidth)?{minWidth:[`${u.intrinsicWidth}px`,`${h.intrinsicWidth}px`],maxWidth:[`${u.intrinsicWidth}px`,`${h.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Je),e.feedbackElement.setAttribute(Va,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),fp({element:e.feedbackElement,keyframes:No(Cr(Cr({},v),m),{translate:[`${p.x}px ${p.y}px 0`,`${w.x}px ${w.y}px 0`]}),options:{duration:du(kt(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(Va),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Pu,za,kr,Yo,ds,Wu,Fu,Sr=class extends(za=lt,Pu=[ue],za){constructor(t,n){super(t,n),$e(this,ds),$e(this,Yo,Pe(kr,8,this)),Pe(kr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(wn),s=r?.register(Hp);if(s){const a=this.destroy.bind(this);this.destroy=()=>{s(),a()}}this.registerEffect(mn(this,ds,Wu).bind(this,r)),this.registerEffect(mn(this,ds,Fu))}};kr=Un(za);Yo=new WeakMap;ds=new WeakSet;Wu=function(e){const{overlay:t}=this;if(!t||!e)return;const n=bs(t);if(n)return e.addRoot(n)};Fu=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:d,feedback:u}=l;if(!d||u==="none"||!c.initialized||c.initializing)return;const{initial:p}=r,h=(e=this.overlay)!=null?e:d,g=Ln(h),w=Ln(d),v=!Ru(d,h),m=new Vt(d,{frameTransform:v?w:null,ignoreTransforms:!v}),b={x:w.scaleX/g.scaleX,y:w.scaleY/g.scaleY};let{width:_,height:y,top:x,left:k}=m;v&&(_=_/b.x,y=y/b.y);const S=new yp(h),{transition:I,translate:E,boxSizing:M,paddingBlockStart:T,paddingBlockEnd:P,paddingInlineStart:A,paddingInlineEnd:F,borderInlineStartWidth:O,borderInlineEndWidth:H,borderBlockStartWidth:K,borderBlockEndWidth:ne}=jt(d),B=u==="clone",re=M==="content-box",se=re?parseInt(A)+parseInt(F)+parseInt(O)+parseInt(H):0,ae=re?parseInt(T)+parseInt(P)+parseInt(K)+parseInt(ne):0,ie=u!=="move"&&!this.overlay?Np(l,B?"clone":"hidden"):null,me=_e(()=>Zo(s.dragOperation.activatorEvent));if(E!=="none"){const ee=zo(E);ee&&!p.translate&&(p.translate=ee)}if(!p.transformOrigin){const ee=_e(()=>i.current);p.transformOrigin={x:(ee.x-k*g.scaleX-g.x)/(_*g.scaleX),y:(ee.y-x*g.scaleY-g.y)/(y*g.scaleY)}}const{transformOrigin:ye}=p,De=x*g.scaleY+g.y,X=k*g.scaleX+g.x;if(!p.coordinates&&(p.coordinates={x:X,y:De},b.x!==1||b.y!==1)){const{scaleX:ee,scaleY:be}=w,{x:Ee,y:je}=ye;p.coordinates.x+=(_*ee-_)*Ee,p.coordinates.y+=(y*be-y)*je}p.dimensions||(p.dimensions={width:_,height:y}),p.frameTransform||(p.frameTransform=g);const Z={x:p.coordinates.x-X,y:p.coordinates.y-De},de={width:(p.dimensions.width*p.frameTransform.scaleX-_*g.scaleX)*ye.x,height:(p.dimensions.height*p.frameTransform.scaleY-y*g.scaleY)*ye.y},G={x:Z.x/g.scaleX+de.width,y:Z.y/g.scaleY+de.height},$={left:k+G.x,top:x+G.y};h.setAttribute($t,"true");const he=_e(()=>o.transform),We=(t=p.translate)!=null?t:{x:0,y:0},q=he.x*g.scaleX+We.x,ge=he.y*g.scaleY+We.y,Le=uu();S.set({width:_-se,height:y-ae,top:$.top+Le.y,left:$.left+Le.x,translate:`${q}px ${ge}px 0`,transition:I?`${I}, translate 0ms linear`:"",scale:v?`${b.x} ${b.y}`:"","transform-origin":`${ye.x*100}% ${ye.y*100}%`},Je),ie&&(d.insertAdjacentElement("afterend",ie),a?.rootElement&&(typeof a.rootElement=="function"?a.rootElement(l):a.rootElement).appendChild(d)),Pa(h)&&(h.hasAttribute("popover")||h.setAttribute("popover","manual"),xr(h),h.addEventListener("beforetoggle",fl));let Ne,U,Re;const ze=qp({placeholder:ie,element:d,feedbackElement:h,frameTransform:g,transformOrigin:ye,width:_,height:y,top:x,left:k,widthOffset:se,heightOffset:ae,delta:G,styles:S,dragOperation:o,getElementMutationObserver:()=>Ne,getSavedCellWidths:()=>Re,setSavedCellWidths:ee=>{Re=ee}}),xe=new Vt(h);_e(()=>o.shape=xe);const Xe=kt(h),Ue=ee=>{this.manager.actions.stop({event:ee})},at=du(Xe);me&&Xe.addEventListener("resize",Ue),_e(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),ie&&(ze.observe(ie),Ne=Up(d,ie,B),U=Kp(d,ie,h));const yt=(n=s.dragOperation.source)==null?void 0:n.id,At=()=>{var ee;if(!me||yt==null)return;const be=s.registry.draggables.get(yt),Ee=(ee=be?.handle)!=null?ee:be?.element;hn(Ee)&&Ee.focus()},N=()=>{var ee;if(Ne?.disconnect(),U?.disconnect(),ze.disconnect(),Xe.removeEventListener("resize",Ue),Pa(h)&&(h.removeEventListener("beforetoggle",fl),h.removeAttribute("popover")),h.removeAttribute($t),S.reset(),Re&&La(d)){const Ee=Array.from(d.cells);for(const[je,bt]of Ee.entries())bt.style.width=(ee=Re[je])!=null?ee:""}l.status="idle";const be=r.current.translate!=null;ie&&(be||ie.parentElement!==h.parentElement)&&h.isConnected&&ie.replaceWith(h),ie?.remove()},le=a?.dropAnimation,Fe=this,Ke=$r(()=>{var ee;const{transform:be,status:Ee}=o;if(!(!be.x&&!be.y&&!r.current.translate)&&Ee.dragging){const je=(ee=p.translate)!=null?ee:{x:0,y:0},bt={x:be.x/g.scaleX+je.x,y:be.y/g.scaleY+je.y},L=r.current.translate,Y=_e(()=>o.modifiers),Q=_e(()=>{var ve;return(ve=o.shape)==null?void 0:ve.current}),Ce=me&&!at?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(S.set({transition:`${I}, translate ${Ce}`,translate:`${bt.x}px ${bt.y}px 0`},Je),Ne?.takeRecords(),Q&&Q!==xe&&L&&!Y.length){const ve=Tt.delta(bt,L);o.shape=Tr.from(Q.boundingRectangle).translate(ve.x*g.scaleX,ve.y*g.scaleY)}else o.shape=new Vt(h);r.current.translate=bt}},function(){if(o.status.dropped){this.dispose(),l.status="dropping";const ee=Fe.dropAnimation!==void 0?Fe.dropAnimation:le;let be=r.current.translate;const Ee=be!=null;if(!be&&d!==h&&(be={x:0,y:0}),!be||ee===null){N();return}s.renderer.rendering.then(()=>{em({element:d,feedbackElement:h,placeholder:ie,translate:be,moved:Ee,transition:I,alignment:l.alignment,styles:S,animation:ee??void 0,getElementMutationObserver:()=>Ne,cleanup:N,restoreFocus:At})})}});return()=>{N(),Ke()}};gt(kr,4,"overlay",Pu,Sr,Yo);bn(kr,Sr);Sr.configure=Gn(Sr);var ja=Sr,qn=!0,tm=!1,Ou,Bu,Vu,Lu,Gt,Uo,Ko;Lu=(Vu=[ue],_t.Forward),Bu=(Ou=[ue],_t.Reverse);var Er=class{constructor(){$e(this,Uo,Pe(Gt,8,this,qn)),Pe(Gt,11,this),$e(this,Ko,Pe(Gt,12,this,qn)),Pe(Gt,15,this)}isLocked(e){return e===_t.Idle?!1:e==null?this[_t.Forward]===qn&&this[_t.Reverse]===qn:this[e]===qn}unlock(e){e!==_t.Idle&&(this[e]=tm)}};Gt=Un(null);Uo=new WeakMap;Ko=new WeakMap;gt(Gt,4,Lu,Vu,Er,Uo);gt(Gt,4,Bu,Ou,Er,Ko);bn(Gt,Er);var nm=[_t.Forward,_t.Reverse],hl=class{constructor(){this.x=new Er,this.y=new Er}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},rm=class extends lt{constructor(e){super(e);const t=Mr(new hl);let n=null;this.signal=t,Ct(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new hl;return}const{delta:s}=e.dragOperation.position;if(n){const a={x:pl(s.x,n.x),y:pl(s.y,n.y)},o=t.peek();Kt(()=>{for(const i of vc)for(const l of nm)a[i]===l&&o[i].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function pl(e,t){return Math.sign(e-t)}var zu,Za,Ir,qo,Nt,Ha,Bs=class extends(Za=Rr,zu=[ue],Za){constructor(e){super(e),$e(this,qo,Pe(Ir,8,this,!1)),Pe(Ir,11,this),$e(this,Nt),$e(this,Ha,()=>{if(!Se(this,Nt))return;const{element:a,by:o}=Se(this,Nt);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,Nt,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:d}=a??{},u=d?{x:ml(d.x),y:ml(d.y)}:void 0,p=u?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const h of i){const g=Uh(h,d);if(g.x||g.y){const{speed:w,direction:v}=ip(h,c,u);if(p)for(const m of vc)p[m].isLocked(v[m])&&(w[m]=0,v[m]=0);if(v.x||v.y){const{x:m,y:b}=d??v,_=m*w.x,y=b*w.y;if(_||y){const x=(o=Se(this,Nt))==null?void 0:o.by;if(this.autoScrolling&&x&&(x.x&&!_||x.y&&!y))continue;return rt(this,Nt,{element:h,by:{x:_,y}}),xs.schedule(Se(this,Ha)),!0}}}}}return rt(this,Nt,void 0),!1};let t=null,n=null;const r=gs(()=>{const{position:a,source:o}=e.dragOperation;if(!a)return null;const i=fu(bs(o?.element),a.current);return i&&(t=i),i??t}),s=gs(()=>{const a=r.value,{documentElement:o}=yn(a);if(!a||a===o){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=Wa(l,{excludeElement:!1});return n=c,c}}if(a){const i=Wa(a,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},br);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new rm(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!Zo(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Ir=Un(Za);qo=new WeakMap;Nt=new WeakMap;Ha=new WeakMap;gt(Ir,4,"autoScrolling",zu,Bs,qo);bn(Ir,Bs);function ml(e){return e>0?_t.Forward:e<0?_t.Reverse:_t.Idle}var sm=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))}},am=new sm(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),om=10,ju=class extends lt{constructor(e,t){super(e);const n=e.registry.plugins.get(Bs);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 o=setInterval(()=>am.schedule(n.scroll),om);return()=>{clearInterval(o)}}else n.autoScrolling=!1})}},gl={capture:!0,passive:!0},dr,im=class extends Rr{constructor(e){super(e),$e(this,dr),this.handleScroll=()=>{Se(this,dr)==null&&rt(this,dr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),rt(this,dr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=Ct(()=>{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,gl),()=>{o.removeEventListener("scroll",this.handleScroll,gl)}}})}};dr=new WeakMap;var lm=class extends lt{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 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),ia(),document.addEventListener("selectionchange",ia,{capture:!0}),()=>{document.removeEventListener("selectionchange",ia,{capture:!0}),a.remove()}}})}};function ia(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var fr=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,Is=class extends On{constructor(t,n){super(t),this.manager=t,this.options=n,$e(this,Dn,[]),this.listeners=new hu,this.handleSourceKeyDown=(r,s,a)=>{if(this.disabled||r.defaultPrevented||!pn(r.target)||s.disabled)return;const{keyboardCodes:o=fr.keyboardCodes,preventActivation:i=fr.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 Ct(()=>{var s;const a=(s=t.handle)!=null?s:t.element,o=i=>{Zo(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(),cp(s);const{center:a}=new Vt(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=yn(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=fr.keyboardCodes}=r??{};if(En(t,[...s.end,...s.cancel])){t.preventDefault();const a=En(t,s.cancel);this.handleEnd(t,a);return}En(t,s.up)?this.handleMove("up",t):En(t,s.down)&&this.handleMove("down",t),En(t,s.left)?this.handleMove("left",t):En(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:fr.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(ju);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;Is.configure=Gn(Is);Is.defaults=fr;var cm=Is;function En(e,t){return t.includes(e.code)}var un,um=class extends Kc{constructor(){super(...arguments),$e(this,un)}onEvent(e){switch(e.type){case"pointerdown":rt(this,un,Bn(e));break;case"pointermove":if(!Se(this,un))return;const{x:t,y:n}=Bn(e),r={x:t-Se(this,un).x,y:n-Se(this,un).y},{tolerance:s}=this.options;if(s&&Aa(r,s)){this.abort();return}Aa(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){rt(this,un,void 0)}};un=new WeakMap;var Rn,dn,dm=class extends Kc{constructor(){super(...arguments),$e(this,Rn),$e(this,dn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,dn,Bn(e)),rt(this,Rn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Se(this,dn))return;const{x:t,y:n}=Bn(e),r={x:t-Se(this,dn).x,y:n-Se(this,dn).y};Aa(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Se(this,Rn)&&(clearTimeout(Se(this,Rn)),rt(this,dn,void 0),rt(this,Rn,void 0))}};Rn=new WeakMap;dn=new WeakMap;var Ot=class{};Ot.Delay=dm;Ot.Distance=um;var Na=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})]:wp(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:Bh(r)}}),Pn,As=class extends On{constructor(t,n){super(t),this.manager=t,this.options=n,$e(this,Pn,new Set),this.listeners=new hu,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=Na.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return Ct(()=>{var s;const a=new AbortController,{signal:o}=a,i=c=>{bp(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&&(pm(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||fm(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=Na.preventActivation}=r??{};if(s?.(t,n))return;const{target:a}=t,o=hn(a)&&a.draggable&&a.getAttribute("draggable")==="true",i=Ln(n.element),{x:l,y:c}=Bn(t);this.initialCoordinates={x:l*i.scaleX+i.x,y:c*i.scaleY+i.y};const d=this.activationConstraints(t,n,r);t.sensor=this;const u=new Ah(d,w=>this.handleStart(n,w));u.signal.onabort=()=>this.handleCancel(t),u.onEvent(t),this.controller=u;const p=Da(),h=this.listeners.bind(p,[{type:"pointermove",listener:w=>this.handlePointerMove(w,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:es,options:{capture:!0}}]),g=()=>{h(),this.initialCoordinates=void 0};Se(this,Pn).add(g)}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=Bn(t),o=Ln(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,xs.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=yn(n.target).body;i.setPointerCapture(n.pointerId);const l=pn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:es,options:{passive:!1}},{type:"click",listener:es},{type:"contextmenu",listener:es},{type:"keydown",listener:this.handleKeyDown}]);Se(this,Pn).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,Pn).forEach(t=>t()),Se(this,Pn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Pn=new WeakMap;As.configure=Gn(As);As.defaults=Na;var Xa=As;function fm(e){return"sensor"in e}function es(e){e.preventDefault()}function hm(){}var vl=new WeakSet;function pm(e){!e||vl.has(e)||(e.addEventListener("touchmove",hm,{capture:!1,passive:!1}),vl.add(e))}var Wn={modifiers:[],plugins:[Vp,ju,zp,ja,lm],sensors:[Xa,cm]},Jo=class extends Th{constructor(e={}){const t=Bt(e.plugins,Wn.plugins),n=Bt(e.sensors,Wn.sensors),r=Bt(e.modifiers,Wn.modifiers);super(No(Cr({},e),{plugins:[im,Bs,wn,...t],sensors:n,modifiers:r}))}},Zu,Hu,Nu,Ga,Et,Qo,ei,ti,Fr=class extends(Ga=Dt,Nu=[ue],Hu=[ue],Zu=[ue],Ga){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:a,feedback:o="default"}=n,i=Cu(n,["element","effects","handle","feedback"]);super(Cr({effects:()=>[...s(),()=>{var l,c;const{manager:d}=this;if(!d)return;const p=((c=(l=this.sensors)==null?void 0:l.map(ho))!=null?c:[...d.sensors]).map(h=>{const g=h instanceof On?h:d.registry.register(h.plugin),w=h instanceof On?void 0:h.options;return g.bind(this,w)});return function(){p.forEach(g=>g())}}]},i),t),$e(this,Qo,Pe(Et,8,this)),Pe(Et,11,this),$e(this,ei,Pe(Et,12,this)),Pe(Et,15,this),$e(this,ti,Pe(Et,16,this)),Pe(Et,19,this),this.element=r,this.handle=a,this.feedback=o}};Et=Un(Ga);Qo=new WeakMap;ei=new WeakMap;ti=new WeakMap;gt(Et,4,"handle",Nu,Fr,Qo);gt(Et,4,"element",Hu,Fr,ei);gt(Et,4,"feedback",Zu,Fr,ti);bn(Et,Fr);var Xu,Gu,Ya,Yt,ni,la,Yu,Uu,yr,ri,Ku=class extends(Ya=Rt,Gu=[ue],Xu=[ue],Ya){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,a=Cu(n,["element","effects"]);const{collisionDetector:o=kp}=a,i=c=>{const{manager:d,element:u}=this;if(!u||c===null){this.shape=void 0;return}if(!d)return;const p=new Vt(u),h=_e(()=>this.shape);return p&&h?.equals(p)?h:(this.shape=p,p)},l=Mr(!1);super(No(Cr({},a),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:c,manager:d}=this;if(!d)return;const{dragOperation:u}=d,{source:p}=u;l.value=!!(p&&u.status.initialized&&c&&!this.disabled&&this.accepts(p))},()=>{const{element:c}=this;if(l.value&&c){const d=new Yh(c,i);return()=>{d.disconnect(),this.shape=void 0}}},()=>{var c;if((c=this.manager)!=null&&c.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),$e(this,yr),$e(this,ni,Pe(Yt,8,this)),Pe(Yt,11,this),$e(this,ri,Pe(Yt,12,this)),Pe(Yt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){rt(this,yr,e,Uu)}get element(){var e;return(e=this.proxy)!=null?e:Se(this,yr,Yu)}};Yt=Un(Ya);ni=new WeakMap;yr=new WeakSet;ri=new WeakMap;la=gt(Yt,20,"#element",Gu,yr,ni),Yu=la.get,Uu=la.set;gt(Yt,4,"proxy",Xu,Ku,ri);bn(Yt,Ku);function mm(e){return e!=null&&typeof e=="object"&&"current"in e}function Ms(e){var t;if(e!=null)return mm(e)?(t=e.current)!=null?t:void 0:e}var gm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Vs=gm?f.useLayoutEffect:f.useEffect;function vm(){const e=f.useState(0)[1];return f.useCallback(()=>{e(t=>t+1)},[e])}function ym(e,t){const n=f.useRef(new Map),r=vm();return Vs(()=>{if(!e){n.current.clear();return}return Ct(()=>{var s;let a=!1,o=!1;for(const i of n.current){const[l]=i,c=_e(()=>i[1]),d=e[l];c!==d&&(a=!0,n.current.set(l,d),o=(s=t?.(l,c,d))!=null?s:!1)}a&&(o?ro.flushSync(r):r())})},[e]),f.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=f.useEffect,r=Object.is){const s=f.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}function yl(e,t){const n=f.useRef(Ms(e));Vs(()=>{const r=Ms(e);r!==n.current&&(n.current=r,t(r))})}var bm=Object.defineProperty,wm=Object.defineProperties,_m=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,xm=Object.prototype.hasOwnProperty,Cm=Object.prototype.propertyIsEnumerable,wl=(e,t,n)=>t in e?bm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,km=(e,t)=>{for(var n in t||(t={}))xm.call(t,n)&&wl(e,n,t[n]);if(bl)for(var n of bl(t))Cm.call(t,n)&&wl(e,n,t[n]);return e},Sm=(e,t)=>wm(e,_m(t)),Em=new Jo,Im=f.createContext(Em);f.memo(f.forwardRef(({children:e},t)=>{const[n,r]=f.useState(0),s=f.useRef(null),a=f.useRef(null),o=f.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})),f.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Vs(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),f.useImperativeHandle(t,()=>o),null}));function Am(){return f.useContext(Im)}function Mm(e){var t;const n=(t=Am())!=null?t:void 0,[r]=f.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Vs(r.register,[n,r]),r}function ca(e){const{disabled:t,data:n,element:r,handle:s,id:a,modifiers:o,sensors:i}=e,l=Mm(d=>new Fr(Sm(km({},e),{register:!1,handle:Ms(s),element:Ms(r)}),d)),c=ym(l,$m);return an(a,()=>l.id=a),yl(s,d=>l.handle=d),yl(r,d=>l.element=d),an(n,()=>n&&(l.data=n)),an(t,()=>l.disabled=t===!0),an(i,()=>l.sensors=i),an(o,()=>l.modifiers=o,void 0,br),an(e.feedback,()=>{var d;return l.feedback=(d=e.feedback)!=null?d:"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:f.useCallback(d=>{l.handle=d??void 0},[l]),ref:f.useCallback(d=>{var u,p;!d&&((u=l.element)!=null&&u.isConnected)&&!((p=l.manager)!=null&&p.dragOperation.status.idle)||(l.element=d??void 0)},[l])}}function $m(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var Tm=Object.create,qu=Object.defineProperty,Dm=Object.getOwnPropertyDescriptor,Ju=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ls=e=>{throw TypeError(e)},Rm=(e,t,n)=>t in e?qu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pm=e=>{var t;return[,,,Tm((t=e?.[Ju("metadata")])!=null?t:null)]},Qu=["class","method","getter","setter","accessor","field","value","get","set"],ed=e=>e!==void 0&&typeof e!="function"?Ls("Function expected"):e,Wm=(e,t,n,r,s)=>({kind:Qu[e],name:t,metadata:r,addInitializer:a=>n._?Ls("Already initialized"):s.push(ed(a||null))}),Fm=(e,t)=>Rm(t,Ju("metadata"),e[3]),Om=(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},td=(e,t,n,r,s,a)=>{for(var o,i,l,c,d=t&7,u=!1,p=!1,h=2,g=Qu[d+5],w=e[h]||(e[h]=[]),v=(s=s.prototype,Dm(s,n)),m=r.length-1;m>=0;m--)l=Wm(d,n,i={},e[3],w),l.static=u,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[m])(v[g],l),i._=1,ed(o)&&(v[g]=o);return v&&qu(s,n,v),s},nd=(e,t,n)=>t.has(e)||Ls("Cannot "+n),Bm=(e,t,n)=>(nd(e,t,"read from private field"),t.get(e)),Vm=(e,t,n)=>t.has(e)?Ls("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Lm=(e,t,n,r)=>(nd(e,t,"write to private field"),t.set(e,n),n),Jn=class Ua{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ua(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 Ua(t,n)}},rd,sd,Ka,fs,Or,si=class extends(Ka=Jt,sd=[Ae],rd=[Ae],Ka){constructor(t){const n=Jn.from(t);super(n,(r,s)=>Jn.equals(r,s)),Om(Or,5,this),Vm(this,fs,0),this.velocity={x:0,y:0}}get delta(){return Jn.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=Jn.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-Bm(this,fs),i=l=>Math.round(l/o*100);Kt(()=>{Lm(this,fs,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Jn.from(t)),this.velocity={x:0,y:0}}};Or=Pm(Ka);fs=new WeakMap;td(Or,2,"delta",sd,si);td(Or,2,"direction",rd,si);Fm(Or,si);var ad=(e=>(e.Horizontal="x",e.Vertical="y",e))(ad||{});Object.values(ad);const zm=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"}))]]),jm=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"}))]]),Zm=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"}))]]),Hm=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"}))]]),Nm=f.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Br=D.forwardRef((e,t)=>{const{alt:n,color:r,size:s,weight:a,mirrored:o,children:i,weights:l,...c}=e,{color:d="currentColor",size:u,weight:p="regular",mirrored:h=!1,...g}=D.useContext(Nm);return D.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:s??u,height:s??u,fill:r??d,viewBox:"0 0 256 256",transform:o||h?"scale(-1, 1)":void 0,...g,...c},!!n&&D.createElement("title",null,n),i,l.get(a??p))});Br.displayName="IconBase";const od=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:zm}));od.displayName="DotsThreeIcon";const id=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:jm}));id.displayName="SpeakerHighIcon";const ld=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:Zm}));ld.displayName="SpeakerLowIcon";const cd=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:Hm}));cd.displayName="XIcon";const Xm=cd;R.span`
|
|
67
67
|
font-family: 'Courier New', Monaco, monospace;
|
|
68
68
|
font-size: 1rem;
|
|
69
69
|
font-weight: 600;
|
|
@@ -112,18 +112,18 @@
|
|
|
112
112
|
min-width: 1.75rem;
|
|
113
113
|
min-height: 1.75rem;
|
|
114
114
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
115
|
-
`;var
|
|
115
|
+
`;var Gm=R.div`
|
|
116
116
|
display: inline-flex;
|
|
117
117
|
align-items: center;
|
|
118
118
|
gap: 0.5rem;
|
|
119
|
-
`,
|
|
119
|
+
`,Ym=R.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
|
+
`,Um=R.label`
|
|
127
127
|
margin: 0;
|
|
128
128
|
cursor: pointer;
|
|
129
129
|
user-select: none;
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
`;R(ud)`
|
|
186
186
|
padding: 0.25rem 0.5rem;
|
|
187
187
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
188
|
-
`;var
|
|
188
|
+
`;var Km=R.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 qm=R.span`
|
|
204
204
|
position: absolute;
|
|
205
205
|
width: 1px;
|
|
206
206
|
height: 1px;
|
|
@@ -326,7 +326,7 @@
|
|
|
326
326
|
&:disabled::-moz-range-thumb {
|
|
327
327
|
cursor: not-allowed;
|
|
328
328
|
}
|
|
329
|
-
`,
|
|
329
|
+
`,Jm=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.checked)};return C.jsxs(Gm,{className:r,children:[C.jsx(Ym,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:s,disabled:n}),C.jsx(Um,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function hd(e){return typeof e=="object"&&e!==null&&"type"in e}function qt(e){if(!hd(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 pd={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",timeColor:"#000",timescaleBackgroundColor:"#fff",playheadColor:"#f00",selectionColor:"rgba(255, 105, 180, 0.7)",loopRegionColor:"rgba(59, 130, 246, 0.3)",loopMarkerColor:"#3b82f6",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},Qm=class{constructor(){this._state=null,this._listeners=new Set,this.subscribe=e=>(this._listeners.add(e),()=>this._listeners.delete(e)),this.getSnapshot=()=>this._state}update(e,t){const n=t*1.5,r=Math.max(0,e-n),s=e+t+n;if(!(this._state&&this._state.containerWidth===t&&Math.abs(this._state.scrollLeft-e)<100)){this._state={scrollLeft:e,containerWidth:t,visibleStart:r,visibleEnd:s};for(const a of this._listeners)a()}}},md=f.createContext(null),eg=()=>()=>{},tg=({containerRef:e,children:t})=>{const n=f.useRef(null);n.current===null&&(n.current=new Qm);const r=n.current,s=f.useRef(null),a=f.useCallback(()=>{const i=e.current;i&&r.update(i.scrollLeft,i.clientWidth)},[e,r]),o=f.useCallback(()=>{s.current===null&&(s.current=requestAnimationFrame(()=>{s.current=null,a()}))},[a]);return f.useEffect(()=>{const i=e.current;if(!i)return;a(),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)}},[e,a,o]),C.jsx(md.Provider,{value:r,children:t})};function ng(e){const t=f.useContext(md);return f.useSyncExternalStore(t?t.subscribe:eg,()=>e(t?t.getSnapshot():null),()=>e(null))}function oi(e,t,n=0){const r=ng(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 d=n+l;if(d+c<=s.visibleStart||d>=s.visibleEnd)continue}o.push(i)}return o.join(",")});return f.useMemo(()=>r?r.split(",").map(Number):[],[r])}var gd=f.createContext(0),rg=({originX:e,children:t})=>C.jsx(gd.Provider,{value:e,children:t}),vd=()=>f.useContext(gd);function ii(){const e=f.useRef(new Map),t=f.useCallback(n=>{if(n!==null){const r=parseInt(n.dataset.index,10);e.current.set(r,n)}},[]);return f.useEffect(()=>{const n=e.current;for(const[r,s]of n.entries())s.isConnected||n.delete(r)}),{canvasRef:t,canvasMapRef:e}}function sg(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 ag(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 og(e,t,n){return Math.floor((e-t+n)/n)*n}function ig(e,t,n,r){if(!hd(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 lg=R.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
|
/* Promote to own compositing layer for smoother scrolling */
|
|
@@ -334,13 +334,13 @@
|
|
|
334
334
|
/* Disable image rendering interpolation */
|
|
335
335
|
image-rendering: pixelated;
|
|
336
336
|
image-rendering: crisp-edges;
|
|
337
|
-
`,
|
|
337
|
+
`,cg=R.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
338
338
|
position: absolute;
|
|
339
339
|
background: ${e=>e.$waveFillColor};
|
|
340
340
|
/* Force GPU compositing layer to reduce scroll flickering */
|
|
341
341
|
transform: translateZ(0);
|
|
342
342
|
backface-visibility: hidden;
|
|
343
|
-
`,_l=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:d=1,barGap:u=0,transparentBackground:p=!1,drawMode:h="inverted"}=e,{canvasRef:g,canvasMapRef:w}=ii(),v=vd(),m=oi(r,Ye,v);f.useLayoutEffect(()=>{const x=d+u;for(const[k,S]of w.current.entries()){const
|
|
343
|
+
`,_l=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:d=1,barGap:u=0,transparentBackground:p=!1,drawMode:h="inverted"}=e,{canvasRef:g,canvasMapRef:w}=ii(),v=vd(),m=oi(r,Ye,v);f.useLayoutEffect(()=>{const x=d+u;for(const[k,S]of w.current.entries()){const I=k*Ye,E=S.getContext("2d"),M=Math.floor(i/2);if(E){E.resetTransform(),E.clearRect(0,0,S.width,S.height),E.imageSmoothingEnabled=!1,E.scale(o,o);const T=S.width/o;let P;h==="normal"?P=c:P=l,E.fillStyle=ig(E,P,T,i);const A=I,F=I+T,O=og(A,d,x);for(let H=Math.max(0,O);H<F;H+=x){const K=H-A;if(K+d<=0)continue;const ne=Math.min(H+x,r),B=sg(t,n,H,ne);if(B){const re=ag(K,d,M,B.min,B.max,h);for(const se of re)E.fillRect(se.x,se.y,se.width,se.height)}}}}},[w,t,n,i,l,c,o,r,d,u,h,m]);const b=m.map(x=>{const k=x*Ye,S=Math.min(r-k,Ye);return C.jsx(lg,{$cssWidth:S,$left:k,width:S*o,height:i*o,$waveHeight:i,"data-index":x,ref:g},`${r}-${x}`)}),y=p?"transparent":qt(c);return C.jsx(cg,{$index:s,$cssWidth:r,className:a,$waveHeight:i,$waveFillColor:y,children:b})},ug={padding:"16px",background:"#1a1a2e",color:"#e0e0e0",border:"1px solid #d08070",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px",minHeight:"60px",display:"flex",alignItems:"center",justifyContent:"center"};(class extends f.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[waveform-playlist] Render error:",e,t.componentStack)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:C.jsx("div",{style:ug,children:"Waveform playlist encountered an error. Check console for details."}):this.props.children}});var yd=22,bd=R.div`
|
|
344
344
|
position: relative;
|
|
345
345
|
height: ${yd}px;
|
|
346
346
|
background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
|
|
@@ -372,12 +372,12 @@
|
|
|
372
372
|
white-space: nowrap;
|
|
373
373
|
overflow: hidden;
|
|
374
374
|
text-overflow: ellipsis;
|
|
375
|
-
`,
|
|
375
|
+
`,dg=({trackName:e,isSelected:t=!1})=>C.jsx(bd,{$interactive:!1,$isSelected:t,children:C.jsx(wd,{children:e})}),fg=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:s=!1,disableDrag:a=!1,dragHandleProps:o})=>{if(a||!o)return C.jsx(dg,{trackName:r,isSelected:s});const{handleRef:i}=o;return C.jsx(bd,{ref:i,"data-clip-id":e,$interactive:!0,$isSelected:s,children:C.jsx(wd,{children:r})})},hg=8,pg=24,mg=R.div`
|
|
376
376
|
position: absolute;
|
|
377
377
|
${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
|
|
378
378
|
top: 0;
|
|
379
379
|
bottom: 0;
|
|
380
|
-
width: ${e=>e.$touchOptimized?
|
|
380
|
+
width: ${e=>e.$touchOptimized?pg:hg}px;
|
|
381
381
|
cursor: col-resize;
|
|
382
382
|
user-select: none;
|
|
383
383
|
z-index: 105; /* Above waveform, below header */
|
|
@@ -400,19 +400,19 @@
|
|
|
400
400
|
background: rgba(255, 255, 255, 0.4);
|
|
401
401
|
${e=>e.$edge==="left"?"border-left: 2px solid rgba(255, 255, 255, 0.8);":"border-right: 2px solid rgba(255, 255, 255, 0.8);"}
|
|
402
402
|
}
|
|
403
|
-
`,xl=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:s,touchOptimized:a=!1})=>{const[o,i]=f.useState(!1);if(!s)return null;const{ref:l,isDragging:c}=s;return C.jsx(
|
|
403
|
+
`,xl=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:s,touchOptimized:a=!1})=>{const[o,i]=f.useState(!1);if(!s)return null;const{ref:l,isDragging:c}=s;return C.jsx(mg,{ref:l,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:c,$isHovered:o,$touchOptimized:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)})},gg=R.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
404
404
|
position: absolute;
|
|
405
405
|
top: 0;
|
|
406
406
|
bottom: 0;
|
|
407
407
|
pointer-events: none;
|
|
408
408
|
z-index: 50;
|
|
409
|
-
`,
|
|
409
|
+
`,vg=R.svg`
|
|
410
410
|
width: 100%;
|
|
411
411
|
height: 100%;
|
|
412
412
|
display: block;
|
|
413
413
|
/* Flip horizontally for fadeOut - makes it mirror of fadeIn */
|
|
414
414
|
transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
|
|
415
|
-
`;function
|
|
415
|
+
`;function yg(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 Cl=({left:e,width:t,type:n,curveType:r="logarithmic",color:s})=>{const a=R.useTheme();if(t<1)return null;const o=s||a?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return C.jsx(gg,{$left:e,$width:t,$type:n,children:C.jsx(vg,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:C.jsx("path",{d:yg(t,100,r),fill:o})})})},bg=R.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
416
416
|
position: ${e=>e.$isOverlay?"relative":"absolute"};
|
|
417
417
|
top: 0;
|
|
418
418
|
height: ${e=>e.$isOverlay?"auto":"100%"};
|
|
@@ -426,20 +426,20 @@
|
|
|
426
426
|
&:hover {
|
|
427
427
|
background: rgba(255, 255, 255, 0.08);
|
|
428
428
|
}
|
|
429
|
-
`,
|
|
429
|
+
`,wg=R.div`
|
|
430
430
|
flex: 1;
|
|
431
431
|
position: relative;
|
|
432
432
|
overflow: ${e=>e.$isOverlay?"visible":"hidden"};
|
|
433
|
-
`,qa=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:s,trackName:a,startSample:o,durationSamples:i,samplesPerPixel:l,showHeader:c=!1,disableHeaderDrag:d=!1,isOverlay:u=!1,isSelected:p=!1,onMouseDown:h,trackId:g,fadeIn:w,fadeOut:v,sampleRate:m=44100,showFades:b=!1,touchOptimized:_=!1})=>{const y=Math.floor(o/l),k=Math.floor((o+i)/l)-y,S=c&&!d&&!u,
|
|
433
|
+
`,qa=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:s,trackName:a,startSample:o,durationSamples:i,samplesPerPixel:l,showHeader:c=!1,disableHeaderDrag:d=!1,isOverlay:u=!1,isSelected:p=!1,onMouseDown:h,trackId:g,fadeIn:w,fadeOut:v,sampleRate:m=44100,showFades:b=!1,touchOptimized:_=!1})=>{const y=Math.floor(o/l),k=Math.floor((o+i)/l)-y,S=c&&!d&&!u,I=`clip-${r}-${s}`,{ref:E,handleRef:M,isDragSource:T}=ca({id:I,data:{clipId:n,trackIndex:r,clipIndex:s},disabled:!S}),P=`clip-boundary-left-${r}-${s}`,{ref:A,isDragSource:F}=ca({id:P,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"left"},disabled:!S,feedback:"none"}),O=`clip-boundary-right-${r}-${s}`,{ref:H,isDragSource:K}=ca({id:O,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"right"},disabled:!S,feedback:"none"}),ne=T?{zIndex:100}:void 0;return C.jsxs(bg,{ref:E,style:ne,className:t,$left:y,$width:k,$isOverlay:u,"data-clip-container":"true","data-track-id":g,onMouseDown:h,children:[c&&C.jsx(fg,{clipId:n,trackIndex:r,clipIndex:s,trackName:a,isSelected:p,disableDrag:d,dragHandleProps:S?{handleRef:M}:void 0}),C.jsx(rg,{originX:y,children:C.jsxs(wg,{$isOverlay:u,children:[e,b&&w&&w.duration>0&&C.jsx(Cl,{left:0,width:Math.floor(w.duration*m/l),type:"fadeIn",curveType:w.type}),b&&v&&v.duration>0&&C.jsx(Cl,{left:k-Math.floor(v.duration*m/l),width:Math.floor(v.duration*m/l),type:"fadeOut",curveType:v.type})]})}),c&&!d&&!u&&C.jsxs(C.Fragment,{children:[C.jsx(xl,{clipId:n,trackIndex:r,clipIndex:s,edge:"left",touchOptimized:_,dragHandleProps:{ref:A,isDragging:F}}),C.jsx(xl,{clipId:n,trackIndex:r,clipIndex:s,edge:"right",touchOptimized:_,dragHandleProps:{ref:H,isDragging:K}})]})]})},_g=R.div`
|
|
434
434
|
display: inline-flex;
|
|
435
435
|
align-items: center;
|
|
436
436
|
gap: 0.5rem;
|
|
437
|
-
`,
|
|
437
|
+
`,xg=R(Km)`
|
|
438
438
|
margin: 0;
|
|
439
439
|
white-space: nowrap;
|
|
440
|
-
`,
|
|
440
|
+
`,Cg=R(fd)`
|
|
441
441
|
width: 120px;
|
|
442
|
-
`,
|
|
442
|
+
`,kg=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(parseFloat(a.target.value)/100)};return C.jsxs(_g,{className:r,children:[C.jsx(xg,{htmlFor:"master-gain",children:"Master Volume"}),C.jsx(Cg,{min:"0",max:"100",value:e*100,onChange:s,disabled:n,id:"master-gain"})]})};R.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
|
|
443
443
|
position: absolute;
|
|
444
444
|
top: 0;
|
|
445
445
|
left: 0;
|
|
@@ -473,23 +473,23 @@
|
|
|
473
473
|
width: 2px;
|
|
474
474
|
height: 100%;
|
|
475
475
|
background: ${e=>e.$color};
|
|
476
|
-
`;var
|
|
476
|
+
`;var Sg=R.div`
|
|
477
477
|
overflow-y: hidden;
|
|
478
478
|
overflow-x: auto;
|
|
479
479
|
position: relative;
|
|
480
|
-
`,
|
|
480
|
+
`,Eg=R.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
|
|
481
481
|
position: relative;
|
|
482
482
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
483
|
-
`,
|
|
483
|
+
`,Ig=R.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
|
|
484
484
|
background: ${e=>e.$backgroundColor||"white"};
|
|
485
485
|
width: 100%;
|
|
486
486
|
position: relative;
|
|
487
487
|
overflow: hidden; /* Constrain loop region to timescale area */
|
|
488
|
-
`,
|
|
488
|
+
`,Ag=R.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
|
|
489
489
|
position: relative;
|
|
490
490
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
491
491
|
width: 100%;
|
|
492
|
-
`,
|
|
492
|
+
`,Mg=R.div`
|
|
493
493
|
position: absolute;
|
|
494
494
|
top: 0;
|
|
495
495
|
left: 0;
|
|
@@ -498,7 +498,7 @@
|
|
|
498
498
|
cursor: crosshair;
|
|
499
499
|
/* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
|
|
500
500
|
z-index: ${e=>e.$isSelecting?110:1};
|
|
501
|
-
`,li=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:s,tracksWidth:a,scrollContainerWidth:o,controlsWidth:i,onTracksClick:l,onTracksMouseDown:c,onTracksMouseMove:d,onTracksMouseUp:u,scrollContainerRef:p,isSelecting:h,"data-playlist-state":g})=>{const w=f.useRef(null),v=f.useCallback(m=>{w.current=m,p?.(m)},[p]);return C.jsx(
|
|
501
|
+
`,li=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:s,tracksWidth:a,scrollContainerWidth:o,controlsWidth:i,onTracksClick:l,onTracksMouseDown:c,onTracksMouseMove:d,onTracksMouseUp:u,scrollContainerRef:p,isSelecting:h,"data-playlist-state":g})=>{const w=f.useRef(null),v=f.useCallback(m=>{w.current=m,p?.(m)},[p]);return C.jsx(Sg,{"data-scroll-container":"true","data-playlist-state":g,ref:v,children:C.jsx(tg,{containerRef:w,children:C.jsxs(Eg,{$backgroundColor:t,$width:o,children:[r&&C.jsx(Ig,{$width:s,$backgroundColor:n,children:r}),C.jsxs(Ag,{$width:a,$backgroundColor:t,children:[e,(l||c)&&C.jsx(Mg,{$controlsWidth:i,$isSelecting:h,onClick:l,onMouseDown:c,onMouseMove:d,onMouseUp:u})]})]})})})};R.withTheme(li);var $g=R.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
502
502
|
position: absolute;
|
|
503
503
|
top: 0;
|
|
504
504
|
background: ${e=>e.$color};
|
|
@@ -506,7 +506,7 @@
|
|
|
506
506
|
z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
|
|
507
507
|
pointer-events: none;
|
|
508
508
|
opacity: 0.3;
|
|
509
|
-
`,_d=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:C.jsx(
|
|
509
|
+
`,_d=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:C.jsx($g,{$left:e,$width:r,$color:n,"data-selection":!0})};R.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
510
510
|
position: absolute;
|
|
511
511
|
top: 0;
|
|
512
512
|
background: ${e=>e.$color};
|
|
@@ -570,7 +570,7 @@
|
|
|
570
570
|
&:hover::before {
|
|
571
571
|
opacity: 1;
|
|
572
572
|
}
|
|
573
|
-
`,
|
|
573
|
+
`,Tg=R.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
574
574
|
position: absolute;
|
|
575
575
|
top: 0;
|
|
576
576
|
height: 100%;
|
|
@@ -581,26 +581,26 @@
|
|
|
581
581
|
&:active {
|
|
582
582
|
cursor: grabbing;
|
|
583
583
|
}
|
|
584
|
-
`,
|
|
584
|
+
`,Dg=({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,d]=f.useState(null),u=f.useRef(0),p=f.useRef(0),h=f.useRef(0),g=Math.max(0,t-e),w=f.useCallback((m,b)=>{m.preventDefault(),m.stopPropagation(),d(b),u.current=m.clientX,p.current=b==="start"?e:t;const _=x=>{const k=x.clientX-u.current,S=p.current+k;if(b==="start"){const I=Math.max(i,Math.min(t-10,S));s?.(I)}else{const I=Math.max(e+10,Math.min(l,S));a?.(I)}},y=()=>{d(null),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",y)},[e,t,i,l,s,a]),v=f.useCallback(m=>{m.preventDefault(),m.stopPropagation(),d("region"),u.current=m.clientX,p.current=e,h.current=t;const b=t-e,_=x=>{const k=x.clientX-u.current;let S=p.current+k,I=h.current+k;S<i&&(S=i,I=i+b),I>l&&(I=l,S=l-b),o?.(S,I)},y=()=>{d(null),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",y)},[e,t,i,l,o]);return g<=0?null:C.jsxs(C.Fragment,{children:[C.jsx(Tg,{$left:e,$width:g,$color:r,$isDragging:c==="region",onMouseDown:v,"data-loop-region-timescale":!0}),C.jsx(kl,{$left:e,$color:n,$isStart:!0,$isDragging:c==="start",onMouseDown:m=>w(m,"start"),"data-loop-marker-handle":"start"}),C.jsx(kl,{$left:t,$color:n,$isStart:!1,$isDragging:c==="end",onMouseDown:m=>w(m,"end"),"data-loop-marker-handle":"end"})]})},Rg=R.div.attrs(e=>({style:{left:`${e.$leftOffset||0}px`}}))`
|
|
585
585
|
position: absolute;
|
|
586
586
|
top: 0;
|
|
587
587
|
right: 0;
|
|
588
588
|
height: 100%; /* Stay within timescale bounds, don't extend into tracks */
|
|
589
589
|
cursor: crosshair;
|
|
590
590
|
z-index: 40; /* Below markers and shading */
|
|
591
|
-
|
|
591
|
+
`,Pg=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopRegionChange:s,minPosition:a=0,maxPosition:o=1/0,controlsOffset:i=0})=>{const[,l]=f.useState(!1),c=f.useRef(0),d=f.useRef(null),u=t>e,p=f.useCallback(h=>{const g=h.target;if(g.closest("[data-loop-marker-handle]")||g.closest("[data-loop-region-timescale]"))return;h.preventDefault(),l(!0);const w=d.current?.getBoundingClientRect();if(!w)return;const v=h.clientX-w.left,m=Math.max(a,Math.min(o,v));c.current=m,s?.(m,m);const b=y=>{const x=y.clientX-w.left,k=Math.max(a,Math.min(o,x)),S=Math.min(c.current,k),I=Math.max(c.current,k);s?.(S,I)},_=()=>{l(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",_)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",_)},[a,o,s]);return C.jsx(Rg,{ref:d,$leftOffset:i,onMouseDown:p,"data-timescale-loop-creator":!0,children:u&&C.jsx(Dg,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:a,maxPosition:o,onLoopStartChange:h=>s?.(h,t),onLoopEndChange:h=>s?.(e,h),onLoopRegionMove:(h,g)=>s?.(h,g)})})};function Qn(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+3,"0")}function Fn(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return Qn(e,0);case"hh:mm:ss.u":return Qn(e,1);case"hh:mm:ss.uu":return Qn(e,2);case"hh:mm:ss.uuu":return Qn(e,3);default:return Qn(e,3)}}function xd(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 Sl=({id:e,label:t,value:n,format:r,className:s,onChange:a,readOnly:o=!1})=>{const[i,l]=f.useState("");f.useEffect(()=>{const p=Fn(n,r);l(p)},[n,r,e]);const c=p=>{const h=p.target.value;l(h)},d=()=>{if(a){const p=xd(i,r);a(p)}l(Fn(n,r))},u=p=>{p.key==="Enter"&&p.currentTarget.blur()};return C.jsxs(C.Fragment,{children:[C.jsx(qm,{as:"label",htmlFor:e,children:t}),C.jsx(ud,{type:"text",className:s,id:e,value:i,onChange:c,onBlur:d,onKeyDown:u,readOnly:o})]})},Wg=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[s,a]=f.useState("hh:mm:ss.uuu");f.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 C.jsxs("div",{className:r,children:[C.jsx(Sl,{id:"audio_start",label:"Start of audio selection",value:e,format:s,className:"audio-start form-control mr-sm-2",onChange:o}),C.jsx(Sl,{id:"audio_end",label:"End of audio selection",value:t,format:s,className:"audio-end form-control mr-sm-2",onChange:i})]})};function hs(){return window.devicePixelRatio}var Cd=f.createContext(hs()),kd=({children:e})=>{const[t,n]=f.useState(hs());return matchMedia(`(resolution: ${hs()}dppx)`).addEventListener("change",()=>{n(hs())},{once:!0}),C.jsx(Cd.Provider,{value:Math.ceil(t),children:e})},ci=()=>f.useContext(Cd),Vr=f.createContext({sampleRate:48e3,samplesPerPixel:1e3,zoomLevels:[1e3,1500,2e3,2500],waveHeight:80,timeScaleHeight:15,controls:{show:!1,width:150},duration:3e4,barWidth:1,barGap:0}),zs=()=>f.useContext(Vr),Lr=()=>f.useContext(R.ThemeContext),ui=f.createContext(C.jsx(f.Fragment,{})),Fg=()=>f.useContext(ui),Og=0,Bg=!1,Vg=0,Lg=0,zg={progress:Og,isPlaying:Bg,selectionStart:Vg,selectionEnd:Lg};f.createContext(zg);f.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var jg=(e,t,n)=>(e-t)/(n-t),Zg=R.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
592
592
|
position: absolute;
|
|
593
593
|
background: #000;
|
|
594
594
|
transform: translateZ(0);
|
|
595
595
|
backface-visibility: hidden;
|
|
596
|
-
`,
|
|
596
|
+
`,Hg=R.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
597
597
|
position: absolute;
|
|
598
598
|
top: 0;
|
|
599
599
|
/* Promote to own compositing layer for smoother scrolling */
|
|
600
600
|
will-change: transform;
|
|
601
601
|
image-rendering: pixelated;
|
|
602
602
|
image-rendering: crisp-edges;
|
|
603
|
-
`;function
|
|
603
|
+
`;function Ng(){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 Xg=Ng(),El=({index:e,channelIndex:t,data:n,length:r,waveHeight:s,devicePixelRatio:a=1,samplesPerPixel:o,colorLUT:i,frequencyScaleFn:l,minFrequency:c=0,maxFrequency:d,workerApi:u,clipId:p,onCanvasesReady:h})=>{const g=t??e,{canvasRef:w,canvasMapRef:v}=ii(),m=f.useRef([]),b=f.useRef(new WeakSet),_=f.useRef(u),y=f.useRef(h),x=!!(u&&p),k=vd(),S=oi(r,Ye,k),I=i??Xg,E=d??(n?n.sampleRate/2:22050),M=l??jg,T=!!l;f.useEffect(()=>{_.current=u},[u]),f.useEffect(()=>{y.current=h},[h]),f.useEffect(()=>{if(!x)return;const A=_.current;if(!A||!p)return;const F=m.current.length,O=[];for(const ne of m.current){const B=ne.match(/chunk(\d+)$/);if(!B){O.push(ne);continue}const re=parseInt(B[1],10),se=v.current.get(re);if(se&&se.isConnected)O.push(ne);else try{A.unregisterCanvas(ne)}catch(ae){console.warn(`[spectrogram] unregisterCanvas failed for ${ne}:`,ae)}}m.current=O;const H=[];for(const[ne,B]of v.current.entries()){if(b.current.has(B))continue;const re=`${p}-ch${g}-chunk${ne}`;let se;try{se=B.transferControlToOffscreen()}catch(ae){console.warn(`[spectrogram] transferControlToOffscreen failed for ${re}:`,ae);continue}b.current.add(B);try{A.registerCanvas(re,se),H.push(re)}catch(ae){console.warn(`[spectrogram] registerCanvas failed for ${re}:`,ae);continue}}if(H.length>0&&(m.current=[...m.current,...H]),H.length>0||O.length<F){const ne=m.current,B=ne.map(re=>{const se=re.match(/chunk(\d+)$/);if(!se)return console.warn(`[spectrogram] Unexpected canvas ID format: ${re}`),Ye;const ae=parseInt(se[1],10);return Math.min(r-ae*Ye,Ye)});y.current?.(ne,B)}},[v,x,p,g,r,S]),f.useEffect(()=>()=>{const A=_.current;if(A){for(const F of m.current)try{A.unregisterCanvas(F)}catch(O){console.warn(`[spectrogram] unregisterCanvas failed for ${F}:`,O)}m.current=[]}},[]),f.useLayoutEffect(()=>{if(x||!n)return;const{frequencyBinCount:A,frameCount:F,hopSize:O,sampleRate:H,gainDb:K,rangeDb:ne}=n,B=ne===0?1:ne,re=se=>se/A*(H/2);for(const[se,ae]of v.current.entries()){const ie=se*Ye,me=ae.getContext("2d");if(!me)continue;const ye=ae.width/a,De=s;me.resetTransform(),me.clearRect(0,0,ae.width,ae.height),me.imageSmoothingEnabled=!1,me.scale(a,a);const X=me.createImageData(ye,De),Z=X.data;for(let de=0;de<ye;de++){const $=(ie+de)*o,he=Math.floor($/O);if(he<0||he>=F)continue;const We=he*A;for(let q=0;q<De;q++){const ge=1-q/De;let Le=Math.floor(ge*A);if(T){let xe=0,Xe=A-1;for(;xe<Xe;){const Ue=xe+Xe>>1,at=re(Ue);M(at,c,E)<ge?xe=Ue+1:Xe=Ue}Le=xe}if(Le<0||Le>=A)continue;const Ne=n.data[We+Le],U=Math.max(0,Math.min(1,(Ne+B+K)/B)),Re=Math.floor(U*255),ze=(q*ye+de)*4;Z[ze]=I[Re*3],Z[ze+1]=I[Re*3+1],Z[ze+2]=I[Re*3+2],Z[ze+3]=255}}if(me.resetTransform(),me.putImageData(X,0,0),a!==1){const de=document.createElement("canvas");de.width=ye,de.height=De;const G=de.getContext("2d");if(!G)continue;G.putImageData(X,0,0),me.clearRect(0,0,ae.width,ae.height),me.imageSmoothingEnabled=!1,me.drawImage(de,0,0,ae.width,ae.height)}}},[v,x,n,r,s,a,o,I,c,E,M,T,S]);const P=S.map(A=>{const F=A*Ye,O=Math.min(r-F,Ye);return C.jsx(Hg,{$cssWidth:O,$left:F,width:O*a,height:s*a,$waveHeight:s,"data-index":A,ref:w},`${r}-${A}`)});return C.jsx(Zg,{$index:e,$cssWidth:r,$waveHeight:s,children:P})},Sd=({isSelected:e,transparentBackground:t,renderMode:n="waveform",spectrogramData:r,spectrogramColorLUT:s,samplesPerPixel:a,spectrogramFrequencyScaleFn:o,spectrogramMinFrequency:i,spectrogramMaxFrequency:l,spectrogramWorkerApi:c,spectrogramClipId:d,spectrogramOnCanvasesReady:u,...p})=>{const h=Lr(),{waveHeight:g,barWidth:w,barGap:v,samplesPerPixel:m}=zs(),b=ci(),_=a??m,y=e&&h?h.selectedWaveOutlineColor:h?.waveOutlineColor,x=e&&h?h.selectedWaveFillColor:h?.waveFillColor,k=h?.waveformDrawMode||"inverted",S=r||c;if(n==="spectrogram"&&S)return C.jsx(El,{index:p.index,data:r,length:p.length,waveHeight:g,devicePixelRatio:b,samplesPerPixel:_,colorLUT:s,frequencyScaleFn:o,minFrequency:i,maxFrequency:l,workerApi:c,clipId:d,onCanvasesReady:u});if(n==="both"&&S){const I=Math.floor(g/2);return C.jsxs(C.Fragment,{children:[C.jsx(El,{index:p.index*2,channelIndex:p.index,data:r,length:p.length,waveHeight:I,devicePixelRatio:b,samplesPerPixel:_,colorLUT:s,frequencyScaleFn:o,minFrequency:i,maxFrequency:l,workerApi:c,clipId:d,onCanvasesReady:u}),C.jsx("div",{style:{position:"absolute",top:(p.index*2+1)*I,width:p.length,height:I},children:C.jsx(_l,{...p,index:0,waveOutlineColor:y,waveFillColor:x,waveHeight:I,devicePixelRatio:b,barWidth:w,barGap:v,transparentBackground:t,drawMode:k})})]})}return C.jsx(_l,{...p,waveOutlineColor:y,waveFillColor:x,waveHeight:g,devicePixelRatio:b,barWidth:w,barGap:v,transparentBackground:t,drawMode:k})},Il=72,Gg=R.div`
|
|
604
604
|
position: sticky;
|
|
605
605
|
left: 0;
|
|
606
606
|
z-index: 101;
|
|
@@ -608,34 +608,34 @@
|
|
|
608
608
|
height: 0;
|
|
609
609
|
width: 0;
|
|
610
610
|
overflow: visible;
|
|
611
|
-
`;function
|
|
611
|
+
`;function Yg(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 Ug=({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=f.useRef(null),d=ci(),u=i==="both"?Math.floor(e/2):e,p=t*e,h=l?22:0;return f.useLayoutEffect(()=>{const g=c.current;if(!g)return;const w=g.getContext("2d");if(!w)return;w.resetTransform(),w.clearRect(0,0,g.width,g.height),w.scale(d,d);const v=Yg(r,s,u);for(let m=0;m<t;m++){const b=m*e+h;w.font="11px monospace",w.textBaseline="middle";for(const _ of v){const y=n(_,r,s);if(y<0||y>1)continue;const x=b+u*(1-y),k=_>=1e3?`${(_/1e3).toFixed(1)}k`:`${_} Hz`,S=w.measureText(k),I=3;w.fillStyle=o,w.fillRect(0,x-7,S.width+I*2,14),w.fillStyle=a,w.fillText(k,I,x)}}},[e,t,n,r,s,a,o,d,u,h]),C.jsx(Gg,{$height:p+h,children:C.jsx("canvas",{ref:c,width:Il*d,height:(p+h)*d,style:{width:Il,height:p+h,pointerEvents:"none"}})})};function Kg(e,t,n){return Math.ceil(e*n/t)}function qg(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var Jg=R.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,marginLeft:`${e.$controlWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
|
|
612
612
|
position: relative;
|
|
613
613
|
overflow: visible; /* Allow time labels to render above the container */
|
|
614
614
|
border-bottom: 1px solid ${e=>e.theme.timeColor};
|
|
615
615
|
box-sizing: border-box;
|
|
616
|
-
`,
|
|
616
|
+
`,Qg=R.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`,left:`${e.$left}px`}}))`
|
|
617
617
|
position: absolute;
|
|
618
618
|
bottom: 0;
|
|
619
619
|
/* Promote to own compositing layer for smoother scrolling */
|
|
620
620
|
will-change: transform;
|
|
621
|
-
`,
|
|
621
|
+
`,e0=R.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
|
|
622
622
|
position: absolute;
|
|
623
623
|
font-size: 0.75rem; /* Smaller font to prevent overflow */
|
|
624
624
|
white-space: nowrap; /* Prevent text wrapping */
|
|
625
625
|
color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
|
|
626
|
-
`,
|
|
626
|
+
`,t0=e=>{const{theme:{timeColor:t},duration:n,marker:r,bigStep:s,secondStep:a,renderTimestamp:o}=e,{canvasRef:i,canvasMapRef:l}=ii(),{sampleRate:c,samplesPerPixel:d,timeScaleHeight:u,controls:{show:p,width:h}}=f.useContext(Vr),g=ci(),{widthX:w,canvasInfo:v,timeMarkersWithPositions:m}=f.useMemo(()=>{const S=new Map,I=[],E=Kg(n/1e3,d,c),M=c/d;let T=0;for(let P=0;P<E;P+=M*a/1e3){const A=Math.floor(P);if(T%r===0){const F=T,O=qg(F),H=o?C.jsx(f.Fragment,{children:o(F,A)},`timestamp-${T}`):C.jsx(e0,{$left:A,children:O},O);I.push({pix:A,element:H}),S.set(A,u)}else T%s===0?S.set(A,Math.floor(u/2)):T%a===0&&S.set(A,Math.floor(u/5));T+=a}return{widthX:E,canvasInfo:S,timeMarkersWithPositions:I}},[n,d,c,r,s,a,o,u]),b=oi(w,Ye),_=b.map(S=>{const I=S*Ye,E=Math.min(w-I,Ye);return C.jsx(Qg,{$cssWidth:E,$left:I,$timeScaleHeight:u,width:E*g,height:u*g,"data-index":S,ref:i},`timescale-${S}`)}),y=b.length>0?b[0]*Ye:0,x=b.length>0?(b[b.length-1]+1)*Ye:1/0,k=b.length>0?m.filter(({pix:S})=>S>=y&&S<x).map(({element:S})=>S):m.map(({element:S})=>S);return f.useLayoutEffect(()=>{for(const[S,I]of l.current.entries()){const E=I.getContext("2d");if(!E)continue;const M=S*Ye,T=I.width/g;E.resetTransform(),E.clearRect(0,0,I.width,I.height),E.imageSmoothingEnabled=!1,E.fillStyle=t,E.scale(g,g);for(const[P,A]of v.entries()){if(P<M||P>=M+T)continue;const F=P-M,O=u-A;E.fillRect(F,O,1,A)}}},[l,n,g,t,u,v,b]),C.jsxs(Jg,{$cssWidth:w,$controlWidth:p?h:0,$timeScaleHeight:u,children:[k,_]})},n0=R.withTheme(t0),Al=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 r0(e){const t=Al.keys();let n;for(const r of t)if(e<r){n=Al.get(r);break}return n===void 0&&(n={marker:3e4,bigStep:1e4,smallStep:5e3}),n}var Ed=({renderTimestamp:e})=>{const{samplesPerPixel:t,duration:n}=f.useContext(Vr);let r=r0(t);return C.jsx(n0,{marker:r.marker,bigStep:r.bigStep,secondStep:r.smallStep,duration:n,renderTimestamp:e})},s0=R.div`
|
|
627
627
|
display: inline-flex;
|
|
628
628
|
align-items: center;
|
|
629
629
|
gap: 0.5rem;
|
|
630
|
-
`,
|
|
630
|
+
`,a0=[{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"}],o0=({value:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.value)};return C.jsx(s0,{className:r,children:C.jsx(dd,{className:"time-format",value:e,onChange:s,disabled:n,"aria-label":"Time format selection",children:a0.map(a=>C.jsx("option",{value:a.value,children:a.label},a.value))})})},i0=R.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?yd:0)}px`}}))`
|
|
631
631
|
position: relative;
|
|
632
632
|
display: flex;
|
|
633
633
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
634
|
-
`,
|
|
634
|
+
`,l0=R.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
|
|
635
635
|
position: relative;
|
|
636
636
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
637
637
|
flex: 1;
|
|
638
|
-
`,
|
|
638
|
+
`,c0=R.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
|
|
639
639
|
position: sticky;
|
|
640
640
|
z-index: 102; /* Above waveform content and spectrogram labels (101), below Docusaurus navbar (200) */
|
|
641
641
|
left: 0;
|
|
@@ -649,7 +649,7 @@
|
|
|
649
649
|
${e=>e.$isSelected&&`
|
|
650
650
|
background: ${e.theme.selectedTrackControlsBackground};
|
|
651
651
|
`}
|
|
652
|
-
`,Id=({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:d,controls:{show:u,width:p}}=zs(),h=
|
|
652
|
+
`,Id=({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:d,controls:{show:u,width:p}}=zs(),h=Fg();return C.jsxs(i0,{$numChannels:e,className:n,$waveHeight:d,$controlWidth:u?p:0,$width:a,$hasClipHeaders:o,$isSelected:c,children:[C.jsx(c0,{$controlWidth:u?p:0,$isSelected:c,children:h}),C.jsx(l0,{$controlWidth:u?p:0,$backgroundColor:r,$offset:s,onClick:i,"data-track-id":l,children:t})]})},Ml=R.button.attrs({type:"button"})`
|
|
653
653
|
display: inline-block;
|
|
654
654
|
font-family: ${e=>e.theme.fontFamily};
|
|
655
655
|
font-weight: 500;
|
|
@@ -711,7 +711,7 @@
|
|
|
711
711
|
box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
|
|
712
712
|
}
|
|
713
713
|
`}
|
|
714
|
-
`,
|
|
714
|
+
`,u0=R.div`
|
|
715
715
|
margin-bottom: 0.3rem;
|
|
716
716
|
|
|
717
717
|
button:not(:first-child) {
|
|
@@ -723,7 +723,7 @@
|
|
|
723
723
|
border-top-right-radius: 0;
|
|
724
724
|
border-bottom-right-radius: 0;
|
|
725
725
|
}
|
|
726
|
-
`,
|
|
726
|
+
`,d0=R.button`
|
|
727
727
|
position: absolute;
|
|
728
728
|
left: 0;
|
|
729
729
|
top: 0;
|
|
@@ -745,7 +745,7 @@
|
|
|
745
745
|
opacity: 1;
|
|
746
746
|
color: #dc3545;
|
|
747
747
|
}
|
|
748
|
-
`,
|
|
748
|
+
`,f0=({onClick:e,title:t="Remove track"})=>C.jsx(d0,{onClick:e,title:t,children:C.jsx(Xm,{size:12,weight:"bold"})}),h0=R.div`
|
|
749
749
|
background: transparent;
|
|
750
750
|
width: 100%;
|
|
751
751
|
height: 100%;
|
|
@@ -758,7 +758,7 @@
|
|
|
758
758
|
text-align: center;
|
|
759
759
|
border: 1px solid ${e=>e.theme.borderColor};
|
|
760
760
|
border-radius: ${e=>e.theme.borderRadius};
|
|
761
|
-
`,
|
|
761
|
+
`,p0=R.header`
|
|
762
762
|
overflow: hidden;
|
|
763
763
|
height: 26px;
|
|
764
764
|
width: 100%;
|
|
@@ -769,7 +769,7 @@
|
|
|
769
769
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
770
770
|
color: ${e=>e.theme.textColor};
|
|
771
771
|
background-color: transparent;
|
|
772
|
-
`,
|
|
772
|
+
`,m0=e=>C.jsx(ld,{weight:"light",...e}),g0=e=>C.jsx(id,{weight:"light",...e}),v0=e=>C.jsx(od,{weight:"bold",...e}),$l=R(fd)`
|
|
773
773
|
width: 75%;
|
|
774
774
|
height: 5px;
|
|
775
775
|
background: ${e=>e.theme.sliderTrackColor};
|
|
@@ -826,10 +826,10 @@
|
|
|
826
826
|
padding: 0 1rem;
|
|
827
827
|
margin-bottom: 0.2rem;
|
|
828
828
|
font-size: 14px;
|
|
829
|
-
`,
|
|
829
|
+
`,y0=R.div`
|
|
830
830
|
position: relative;
|
|
831
831
|
display: inline-block;
|
|
832
|
-
`,
|
|
832
|
+
`,b0=R.button`
|
|
833
833
|
background: none;
|
|
834
834
|
border: none;
|
|
835
835
|
cursor: pointer;
|
|
@@ -843,7 +843,7 @@
|
|
|
843
843
|
&:hover {
|
|
844
844
|
opacity: 1;
|
|
845
845
|
}
|
|
846
|
-
`,
|
|
846
|
+
`,w0=R.div`
|
|
847
847
|
position: fixed;
|
|
848
848
|
top: ${e=>e.$top}px;
|
|
849
849
|
left: ${e=>e.$left}px;
|
|
@@ -855,12 +855,12 @@
|
|
|
855
855
|
padding: 0.5rem 0;
|
|
856
856
|
min-width: 180px;
|
|
857
857
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
858
|
-
`,
|
|
858
|
+
`,_0=R.hr`
|
|
859
859
|
border: none;
|
|
860
860
|
border-top: 1px solid rgba(128, 128, 128, 0.3);
|
|
861
861
|
margin: 0.35rem 0;
|
|
862
|
-
`,
|
|
863
|
-
`,10)+1,a=r.substring(s)+"",o=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(o)}function $0(e,t,n){var r;return function(a){return r=r||M0(e),new Worker(r,a)}}var T0=$0("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function mt(e){if(S0(e)&&(e=I0(e)),E0(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 _n(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var er={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function D0(e){var t={scale:e.scale||er.scale,bits:e.bits||er.bits,amplitude_scale:e.amplitude_scale||er.amplitude_scale,split_channels:e.split_channels||er.split_channels,disable_worker:e.disable_worker||er.disable_worker};return t}function R0(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Ad(e,t,n){var r=R0(e);if(t.disable_worker){var s=k0({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 a=new T0;a.onmessage=function(o){n(void 0,new mt(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){Ad(o,n,r)},s);a&&a.catch(s)}mt.create=function(t){return new mt(t)};mt.createFromAudio=function(e,t){var n=D0(e);if(e.audio_context&&e.array_buffer)return P0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Ad(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function js(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 mt(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}js.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};js.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};js.prototype.getOutputData=function(){return this._output_data};mt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!In(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!In(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 js(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,a=[this].concat(t).map(function(m){return m._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),d=new DataView(a[0]),u=new DataView(c),p=0;p<n;p++)u.setUint8(p,d.getUint8(p));u.setInt32(16,s,!0);for(var h=0,g=new Uint8Array(c,n),w=0;w<a.length;w++){var v=a[w];g.set(new Uint8Array(v,n),h),h+=v.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!In(t.startIndex)&&!In(t.endIndex)?(n=t.startIndex,r=t.endIndex):!In(t.startTime)&&!In(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 d=0;d<s*this.channels*2;d++){var u=this._at(n*this.channels*2+d);this.bits===8?c.setInt8(a+d,u):c.setInt16(a+d*2,u,!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 di(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 Md(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 W0(e,t=0){const n=await di(e);return Md(n,t)}async function F0(e){const t=await di(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function O0(e,t,n=0,r,s){let a=e;if(s!==void 0){const p=e.scale,h=Math.floor(r/p),g=Math.ceil((r+s)/p);a=a.slice({startIndex:h,endIndex:g})}a.scale!==t&&(a=a.resample({scale:t}));const o=a.channel(n),i=a.bits,l=o.min_array(),c=o.max_array(),d=l.length,u=i===8?new Int8Array(d*2):new Int16Array(d*2);for(let p=0;p<d;p++)u[p*2]=l[p],u[p*2+1]=c[p];return{data:u,bits:i,length:d}}function Dl(e,t,n,r,s){let a=e;if(r!==void 0&&s!==void 0){const d=e.scale,u=Math.floor(r/d),p=Math.ceil((r+s)/d);a=a.slice({startIndex:u,endIndex:p})}a.scale!==t&&(a=a.resample({scale:t}));const o=a.channels,i=a.bits,l=[];for(let d=0;d<o;d++){const u=a.channel(d),p=u.min_array(),h=u.max_array(),g=p.length,w=i===8?new Int8Array(g*2):new Int16Array(g*2);for(let v=0;v<g;v++)w[v*2]=p[v],w[v*2+1]=h[v];l.push(w)}if(n&&l.length>1){const d=1/l.length,u=l[0].length/2,p=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let h=0;h<u;h++){let g=0,w=0;for(let v=0;v<l.length;v++)g+=d*l[v][h*2],w+=d*l[v][h*2+1];p[h*2]=g,p[h*2+1]=w}return{length:u,data:[p],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function $d(){const[e,t]=f.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Fn(s,e),parseTime:s=>xd(s,e)}}function Td({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=f.useState(t),[s,a]=f.useState(!0),[o,i]=f.useState(!0),l=f.useRef(!0),c=f.useRef(!0),d=f.useRef(t),u=f.useCallback(()=>{e.current?.zoomIn()},[e]),p=f.useCallback(()=>{e.current?.zoomOut()},[e]),h=f.useCallback(g=>{g.samplesPerPixel!==d.current&&(d.current=g.samplesPerPixel,f.startTransition(()=>{r(g.samplesPerPixel)})),g.canZoomIn!==l.current&&(l.current=g.canZoomIn,a(g.canZoomIn)),g.canZoomOut!==c.current&&(c.current=g.canZoomOut,i(g.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:u,zoomOut:p,canZoomIn:s,canZoomOut:o,onEngineState:h}}function Dd({engineRef:e,initialVolume:t=1}){const[n,r]=f.useState(t),s=f.useRef(t),a=f.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),o=f.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:a,masterVolumeRef:s,onEngineState:o}}function B0({engineRef:e}){const[t,n]=f.useState(0),[r,s]=f.useState(0),a=f.useRef(0),o=f.useRef(0),i=f.useCallback((c,d)=>{e.current?.setSelection(c,d)},[e]),l=f.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 V0({engineRef:e}){const[t,n]=f.useState(!1),[r,s]=f.useState(0),[a,o]=f.useState(0),i=f.useRef(!1),l=f.useRef(0),c=f.useRef(0),d=f.useCallback(g=>{e.current?.setLoopEnabled(g)},[e]),u=f.useCallback((g,w)=>{e.current?.setLoopRegion(g,w)},[e]),p=f.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),h=f.useCallback(g=>{g.isLoopEnabled!==i.current&&(i.current=g.isLoopEnabled,n(g.isLoopEnabled)),g.loopStart!==l.current&&(l.current=g.loopStart,s(g.loopStart)),g.loopEnd!==c.current&&(c.current=g.loopEnd,o(g.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:a,setLoopEnabled:d,setLoopRegion:u,clearLoopRegion:p,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:h}}function L0({engineRef:e}){const[t,n]=f.useState(null),r=f.useRef(null),s=f.useCallback(o=>{e.current?.selectTrack(o)},[e]),a=f.useCallback(o=>{o.selectedTrackId!==r.current&&(r.current=o.selectedTrackId,n(o.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:a,selectedTrackIdRef:r}}const z0=(e=256)=>{const t=f.useRef(null),n=f.useCallback((r,s,a)=>{const o=new j.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}};function j0(e,t={}){const{progressive:n=!1}=t,[r,s]=f.useState([]),[a,o]=f.useState(!0),[i,l]=f.useState(null),[c,d]=f.useState(0),u=e.length;return f.useEffect(()=>{if(e.length===0){s([]),o(!1),d(0);return}let p=!1;const h=new AbortController,g=new Map,w=(m,b,_)=>{const y=_??m.audioBuffer;if(!y&&!m.waveformData)throw new Error(`Track ${b+1}: Must provide src, audioBuffer, or waveformData`);const x=y?.duration??m.waveformData?.duration,k=jl({audioBuffer:y,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(k.startSample)||isNaN(k.durationSamples)||isNaN(k.offsetSamples))throw console.error("Invalid clip values:",k),new Error(`Invalid clip values for track ${b+1}`);return{...Zl({name:m.name||`Track ${b+1}`,clips:[k],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{o(!0),l(null),d(0);const m=zl.getContext().rawContext,b=e.map(async(y,x)=>{if(y.audioBuffer){const I=w(y,x,y.audioBuffer);return n&&!p&&(g.set(x,I),d(T=>T+1),s(Array.from({length:e.length},(T,P)=>g.get(P)).filter(T=>T!==void 0))),I}if(!y.src&&y.waveformData){const I=w(y,x);return n&&!p&&(g.set(x,I),d(T=>T+1),s(Array.from({length:e.length},(T,P)=>g.get(P)).filter(T=>T!==void 0))),I}if(!y.src)throw new Error(`Track ${x+1}: Must provide src, audioBuffer, or waveformData`);const k=await fetch(y.src,{signal:h.signal});if(!k.ok)throw new Error(`Failed to fetch ${y.src}: ${k.statusText}`);const S=await k.arrayBuffer(),M=await m.decodeAudioData(S);if(!M||!M.sampleRate||!M.duration)throw new Error(`Invalid audio buffer for ${y.src}`);const E=w(y,x,M);return n&&!p&&(g.set(x,E),d(I=>I+1),s(Array.from({length:e.length},(I,T)=>g.get(T)).filter(I=>I!==void 0))),E}),_=await Promise.all(b);p||(n||(s(_),d(_.length)),o(!1))}catch(m){if(!p){const b=m instanceof Error?m.message:"Unknown error loading audio";l(b),o(!1),console.error("Error loading audio tracks:",m)}}})(),()=>{p=!0,h.abort()}},[e,n]),{tracks:r,loading:a,error:i,loadedCount:c,totalCount:u}}function Z0({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:a}){const o=f.useRef(null),i=f.useRef(0),l=f.useCallback(u=>{const p=u.operation.source?.data;if(!p)return;if(!p.boundary){o.current=null;return}const g=e[p.trackIndex]?.clips[p.clipIndex];g&&(o.current={offsetSamples:g.offsetSamples,durationSamples:g.durationSamples,startSample:g.startSample},a.current=!0)},[e,a]),c=f.useCallback(u=>{const p=u.operation.source?.data;if(!p||!p.boundary||!o.current)return;const{boundary:h,trackIndex:g,clipIndex:w}=p,b=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n,_=Math.floor(.1*r),y=o.current,x=e.map((k,S)=>{if(S!==g)return k;const M=[...k.clips].sort((T,P)=>T.startSample-P.startSample),E=M.findIndex(T=>T===k.clips[w]),I=k.clips.map((T,P)=>{if(P!==w)return T;if(h==="left"){const A={...T,startSample:y.startSample,offsetSamples:y.offsetSamples,durationSamples:y.durationSamples},W=va(A,Math.floor(b),"left",M,E,_),O=y.offsetSamples+W,Y=y.durationSamples-W,U=y.startSample+W;return{...T,offsetSamples:O,durationSamples:Y,startSample:U}}else{const A={...T,startSample:y.startSample,offsetSamples:y.offsetSamples,durationSamples:y.durationSamples},W=va(A,Math.floor(b),"right",M,E,_),O=y.durationSamples+W;return{...T,durationSamples:O}}});return{...k,clips:I}});i.current=b,t(x)},[e,t,n,r]),d=f.useCallback(u=>{if(u.canceled){if(o.current){const b=u.operation.source?.data;if(b){const{trackIndex:_,clipIndex:y}=b,x=o.current,k=e.map((S,M)=>{if(M!==_)return S;const E=S.clips.map((I,T)=>T!==y?I:{...I,offsetSamples:x.offsetSamples,durationSamples:x.durationSamples,startSample:x.startSample});return{...S,clips:E}});t(k)}}a.current=!1,o.current=null,i.current=0;return}const p=u.operation.source?.data;if(!p)return;const{trackIndex:h,clipId:g,boundary:w}=p,v=w?i.current:u.operation.transform.x*n,m=e[h]?.id;if(w){a.current=!1,m?s.current?s.current.trimClip(m,g,w,Math.floor(v)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${h} not found — trim not synced to adapter`),o.current=null,i.current=0;return}m?s.current?s.current.moveClip(m,g,Math.floor(v)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${h} not found — move not synced to adapter`)},[e,t,n,s,a]);return{onDragStart:l,onDragMove:c,onDragEnd:d}}const ua=.01;function Rd({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:a}){const o=f.useRef(null),i=f.useCallback(d=>{const u=d.operation.source?.data;if(!u||u.annotationIndex===void 0){o.current=null;return}const p=e[u.annotationIndex];p&&(o.current={start:p.start,end:p.end,annotationIndex:u.annotationIndex})},[e]),l=f.useCallback(d=>{if(!o.current)return;const u=d.operation.source?.data;if(!u)return;const{edge:p,annotationIndex:h}=u,g=o.current,m=((d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x)*n/r,b=p==="start"?g.start+m:g.end+m,_=H0({annotationIndex:h,newTime:b,isDraggingStart:p==="start",annotations:e,duration:s,linkEndpoints:a});t(_)},[e,t,n,r,s,a]),c=f.useCallback(d=>{if(d.canceled&&o.current){const{annotationIndex:u,start:p,end:h}=o.current,g=e.map((w,v)=>v!==u?w:{...w,start:p,end:h});t(g)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function H0({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 d=o[e-1];Math.abs(d.end-i.start)<ua?o[e-1]={...d,end:Math.max(d.start+.1,d.end+c)}:l<=d.end&&(o[e]={...o[e],start:d.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 d=o[e+1];if(Math.abs(d.start-i.end)<ua){const u=d.start+c;o[e+1]={...d,start:Math.min(d.end-.1,u)};let p=e+1;for(;p<o.length-1;){const h=o[p],g=o[p+1];if(Math.abs(g.start-h.end)<ua){const w=h.end-r[p].end;o[p+1]={...g,start:Math.min(g.end-.1,g.start+w)},p++}else break}}else l>=d.start&&(o[e]={...o[e],end:d.start})}else if(!a&&e<o.length-1&&l>o[e+1].start){const d=o[e+1];o[e+1]={...d,start:l};let u=e+1;for(;u<o.length-1;){const p=o[u],h=o[u+1];if(p.end>h.start)o[u+1]={...h,start:p.end},u++;else break}}}return o}function N0(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return f.useMemo(()=>t?[Xa.configure({activationConstraints(a){return a.pointerType==="touch"?[new Ot.Delay({value:n,tolerance:r})]:[new Ot.Distance({value:s})]}})]:[Xa.configure({activationConstraints:[new Ot.Distance({value:s})]})],[t,n,r,s])}const X0=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=ct(),{selectedTrackId:a}=ut(),o=f.useCallback((l,c,d)=>{const{samplesPerPixel:u}=e,p=t[l];if(!p)return!1;const h=p.clips[c];if(!h)return!1;const g=Math.round(d*n),w=Pf(g,u),v=Math.floor(.1*n);if(!Gl(h,w,v))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const m=r.current;return m?(m.splitClip(p.id,h.id,w),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:f.useCallback(()=>{if(!a)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(u=>u.id===a);if(l===-1)return console.warn("Selected track not found"),!1;const c=t[l],d=s.current??0;for(let u=0;u<c.clips.length;u++){const p=c.clips[u],h=p.startSample/n,g=(p.startSample+p.durationSamples)/n;if(d>h&&d<g)return o(l,u,d)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,a,o,n]),splitClipAt:o}},Ts=e=>{const{shortcuts:t,enabled:n=!0}=e,r=f.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,d=i.shiftKey===void 0||s.shiftKey===i.shiftKey,u=i.metaKey===void 0||s.metaKey===i.metaKey,p=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&d&&u&&p});o&&(o.preventDefault!==!1&&s.preventDefault(),o.action())},[t,n]);f.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},G0=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("+")},Y0=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=ct(),{setCurrentTime:a,play:o,pause:i,stop:l}=Te(),c=f.useCallback(()=>{s?i():o()},[s,o,i]),d=f.useCallback(()=>{l()},[l]),u=f.useCallback(()=>{a(0),s&&o(0)},[s,a,o]),h=r??[...[{key:" ",action:c,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:d,description:"Stop",preventDefault:!0},{key:"0",action:u,description:"Rewind to start",preventDefault:!0}],...n];return Ts({shortcuts:h,enabled:t}),{rewindToStart:u,togglePlayPause:c,stopPlayback:d,shortcuts:h}},da=.01,ts=.01;function U0({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:a,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:d,controlsWidth:u=0,onPlay:p}){const h=f.useMemo(()=>t?e.findIndex(E=>E.id===t):-1,[e,t]),g=f.useCallback(E=>{if(!l?.current||!c||!d)return;const I=e.find(B=>B.id===E);if(!I)return;const T=l.current,P=T.clientWidth,A=I.start*d/c+u,W=I.end*d/c+u,O=(A+W)/2,Y=T.scrollLeft,U=Y,J=Y+P;if(A<U||W>J){const B=Math.max(0,O-P/2);T.scrollTo({left:B,behavior:"smooth"})}},[e,l,c,d,u]);f.useEffect(()=>{t&&l?.current&&c&&d&&g(t)},[t,g,l,c,d]);const w=f.useCallback(E=>{if(h<0)return;const I=e[h],T=Math.max(0,Math.min(I.end-.1,I.start+E)),P=T-I.start,A=[...e];if(A[h]={...I,start:T},a&&h>0){const W=A[h-1];Math.abs(W.end-I.start)<da&&(A[h-1]={...W,end:Math.max(W.start+.1,W.end+P)})}else if(!a&&h>0){const W=A[h-1];T<W.end&&(A[h-1]={...W,end:T})}n(A)},[e,h,a,n]),v=f.useCallback(E=>{if(h<0)return;const I=e[h],T=Math.max(I.start+.1,Math.min(s,I.end+E)),P=T-I.end,A=[...e];if(A[h]={...I,end:T},a&&h<e.length-1){const W=A[h+1];if(Math.abs(W.start-I.end)<da){const O=Math.min(W.end-.1,W.start+P);A[h+1]={...W,start:O};let Y=h+1;for(;Y<A.length-1;){const U=A[Y],J=A[Y+1];if(Math.abs(J.start-e[Y].end)<da){const B=U.end-e[Y].end;A[Y+1]={...J,start:Math.min(J.end-.1,J.start+B)},Y++}else break}}}else if(!a&&h<e.length-1){const W=A[h+1];if(T>W.start){A[h+1]={...W,start:T};let O=h+1;for(;O<A.length-1;){const Y=A[O],U=A[O+1];if(Y.end>U.start)A[O+1]={...U,start:Y.end},O++;else break}}}n(A)},[e,h,s,a,n]),m=f.useCallback(()=>{!r||e.length===0||(h<=0?r(e[e.length-1].id):r(e[h-1].id))},[e,h,r]),b=f.useCallback(()=>{!r||e.length===0||(h<0||h>=e.length-1?r(e[0].id):r(e[h+1].id))},[e,h,r]),_=f.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),y=f.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),x=f.useCallback(()=>{r&&r(null)},[r]),k=f.useCallback(()=>{if(h<0||!p)return;const E=e[h],I=o?void 0:E.end-E.start;p(E.start,I)},[e,h,o,p]),S=f.useMemo(()=>[{key:"[",action:()=>w(-ts),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>w(ts),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-ts),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(ts),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:k,description:"Play selected annotation",preventDefault:!0}],[w,v,k]),M=f.useMemo(()=>[{key:"ArrowUp",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:b,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:b,description:"Select next annotation",preventDefault:!0},{key:"Home",action:_,description:"Select first annotation",preventDefault:!0},{key:"End",action:y,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:x,description:"Deselect annotation",preventDefault:!0}],[m,b,_,y,x]);return Ts({shortcuts:S,enabled:i&&h>=0}),Ts({shortcuts:M,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:w,moveEndBoundary:v,selectPrevious:m,selectNext:b,selectFirst:_,selectLast:y,clearSelection:x,scrollToAnnotation:g,playActiveAnnotation:k}}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}]}],fi=e=>zr.find(t=>t.id===e),K0=e=>zr.filter(t=>t.category===e),q0=[{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 J0={reverb:j.Reverb,freeverb:j.Freeverb,jcReverb:j.JCReverb,feedbackDelay:j.FeedbackDelay,pingPongDelay:j.PingPongDelay,chorus:j.Chorus,phaser:j.Phaser,tremolo:j.Tremolo,vibrato:j.Vibrato,autoPanner:j.AutoPanner,autoFilter:j.AutoFilter,autoWah:j.AutoWah,eq3:j.EQ3,distortion:j.Distortion,bitCrusher:j.BitCrusher,chebyshev:j.Chebyshev,compressor:j.Compressor,limiter:j.Limiter,gate:j.Gate,stereoWidener:j.StereoWidener};let Q0=0;const ev=()=>`effect_${Date.now()}_${++Q0}`;function Ar(e,t){const n=J0[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=ev(),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 d=o.wet;if(d&&typeof d=="object"&&"value"in d){d.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 tv(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 nv(e=256){const[t,n]=f.useState([]),r=f.useRef(t);r.current=t;const s=f.useRef(new Map),a=f.useRef(null),o=f.useRef(null),i=f.useCallback(v=>{const m=o.current;if(!m)return;const{masterGainNode:b,destination:_,analyserNode:y}=m;try{b.disconnect()}catch(k){console.warn("[waveform-playlist] Error disconnecting master effects chain:",k)}const x=v.map(k=>s.current.get(k.instanceId)).filter(k=>k!==void 0);if(x.length===0)b.connect(y),y.connect(_);else{let k=b;x.forEach(S=>{try{S.disconnect()}catch(M){console.warn(`[waveform-playlist] Error disconnecting effect "${S.id}":`,M)}k.connect(S.effect),k=S.effect}),k.connect(y),y.connect(_)}},[]),l=f.useCallback(v=>{const m=fi(v);if(!m){console.error(`Unknown effect: ${v}`);return}const b={};m.parameters.forEach(x=>{b[x.name]=x.default});const _=Ar(m,b);s.current.set(_.instanceId,_);const y={instanceId:_.instanceId,effectId:m.id,definition:m,params:b,bypassed:!1};n(x=>[...x,y])},[]),c=f.useCallback(v=>{const m=s.current.get(v);m&&(m.dispose(),s.current.delete(v)),n(b=>b.filter(_=>_.instanceId!==v))},[]),d=f.useCallback((v,m,b)=>{const _=s.current.get(v);_&&_.setParameter(m,b),n(y=>y.map(x=>x.instanceId===v?{...x,params:{...x.params,[m]:b}}:x))},[]),u=f.useCallback(v=>{const m=r.current.find(y=>y.instanceId===v);if(!m)return;const b=!m.bypassed,_=s.current.get(v);if(_){const y=m.params.wet??1;_.setParameter("wet",b?0:y)}n(y=>y.map(x=>x.instanceId===v?{...x,bypassed:b}:x))},[]),p=f.useCallback((v,m)=>{n(b=>{const _=[...b],[y]=_.splice(v,1);return _.splice(m,0,y),_})},[]),h=f.useCallback(()=>{s.current.forEach(v=>v.dispose()),s.current.clear(),n([])},[]);f.useEffect(()=>{i(t)},[t,i]);const g=f.useCallback((v,m,b)=>{const _=new j.Analyser("fft",e);a.current=_,o.current={masterGainNode:v,destination:m,analyserNode:_};const x=r.current.map(k=>s.current.get(k.instanceId)).filter(k=>k!==void 0);if(x.length===0)v.connect(_),_.connect(m);else{let k=v;x.forEach(S=>{k.connect(S.effect),k=S.effect}),k.connect(_),_.connect(m)}return function(){_.dispose(),a.current=null,o.current=null}},[e]);f.useEffect(()=>{const v=s.current;return()=>{v.forEach(m=>m.dispose()),v.clear()}},[]);const w=f.useCallback(()=>{const v=t.filter(m=>!m.bypassed);if(v.length!==0)return(m,b,_)=>{const y=[];for(const x of v){const k=Ar(x.definition,x.params);y.push(k)}if(y.length===0)m.connect(b);else{let x=m;y.forEach(k=>{x.connect(k.effect),x=k.effect}),x.connect(b)}return function(){y.forEach(k=>k.dispose())}}},[t]);return{activeEffects:t,availableEffects:zr,addEffect:l,removeEffect:c,updateParameter:d,toggleBypass:u,reorderEffects:p,clearAllEffects:h,masterEffects:g,createOfflineEffectsFunction:w,analyserRef:a}}function rv(){const[e,t]=f.useState(new Map),n=f.useRef(new Map),r=f.useRef(new Map),s=f.useCallback((h,g)=>{const w=r.current.get(h);if(!w)return;const{graphEnd:v,masterGainNode:m}=w,b=n.current.get(h);try{v.disconnect()}catch(y){console.warn(`[waveform-playlist] Error disconnecting track "${h}" effect chain:`,y)}const _=g.map(y=>b?.get(y.instanceId)).filter(y=>y!==void 0);if(_.length===0)v.connect(m);else{let y=v;_.forEach(x=>{try{x.disconnect()}catch(k){console.warn(`[waveform-playlist] Error disconnecting effect "${x.id}" on track "${h}":`,k)}y.connect(x.effect),y=x.effect}),y.connect(m)}},[]),a=f.useCallback((h,g)=>{const w=fi(g);if(!w){console.error(`Unknown effect: ${g}`);return}const v={};w.parameters.forEach(_=>{v[_.name]=_.default});const m=Ar(w,v);n.current.has(h)||n.current.set(h,new Map),n.current.get(h).set(m.instanceId,m);const b={instanceId:m.instanceId,effectId:w.id,definition:w,params:v,bypassed:!1};t(_=>{const y=new Map(_),x=y.get(h)||[];return y.set(h,[...x,b]),y})},[]),o=f.useCallback((h,g)=>{const w=n.current.get(h),v=w?.get(g);v&&(v.dispose(),w?.delete(g)),t(m=>{const b=new Map(m),_=b.get(h)||[];return b.set(h,_.filter(y=>y.instanceId!==g)),b})},[]),i=f.useCallback((h,g,w,v)=>{const b=n.current.get(h)?.get(g);b&&b.setParameter(w,v),t(_=>{const y=new Map(_),x=y.get(h)||[];return y.set(h,x.map(k=>k.instanceId===g?{...k,params:{...k.params,[w]:v}}:k)),y})},[]),l=f.useCallback((h,g)=>{const v=(d.current.get(h)||[]).find(y=>y.instanceId===g);if(!v)return;const m=!v.bypassed,_=n.current.get(h)?.get(g);if(_){const y=v.params.wet??1;_.setParameter("wet",m?0:y)}t(y=>{const x=new Map(y),k=x.get(h)||[];return x.set(h,k.map(S=>S.instanceId===g?{...S,bypassed:m}:S)),x})},[]),c=f.useCallback(h=>{const g=n.current.get(h);g&&(g.forEach(w=>w.dispose()),g.clear()),t(w=>{const v=new Map(w);return v.set(h,[]),v})},[]),d=f.useRef(e);d.current=e;const u=f.useCallback(h=>(g,w,v)=>{r.current.set(h,{graphEnd:g,masterGainNode:w});const m=d.current.get(h)||[],b=n.current.get(h),_=m.map(y=>b?.get(y.instanceId)).filter(y=>y!==void 0);if(_.length===0)g.connect(w);else{let y=g;_.forEach(x=>{y.connect(x.effect),y=x.effect}),y.connect(w)}return function(){r.current.delete(h)}},[]);f.useEffect(()=>{e.forEach((h,g)=>{s(g,h)})},[e,s]),f.useEffect(()=>{const h=n.current;return()=>{h.forEach(g=>{g.forEach(w=>w.dispose()),g.clear()}),h.clear()}},[]);const p=f.useCallback(h=>{const w=(e.get(h)||[]).filter(v=>!v.bypassed);if(w.length!==0)return(v,m,b)=>{const _=[];for(const y of w){const x=Ar(y.definition,y.params);_.push(x)}if(_.length===0)v.connect(m);else{let y=v;_.forEach(x=>{y.connect(x.effect),y=x.effect}),y.connect(m)}return function(){_.forEach(x=>x.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:a,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:u,createOfflineTrackEffectsFunction:p,availableEffects:zr}}function sv(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,d=44,u=d+c,p=new ArrayBuffer(u),h=new DataView(p);ns(h,0,"RIFF"),h.setUint32(4,u-8,!0),ns(h,8,"WAVE"),ns(h,12,"fmt "),h.setUint32(16,16,!0),h.setUint16(20,n===32?3:1,!0),h.setUint16(22,r,!0),h.setUint32(24,s,!0),h.setUint32(28,l,!0),h.setUint16(32,i,!0),h.setUint16(34,n,!0),ns(h,36,"data"),h.setUint32(40,c,!0);const g=[];for(let v=0;v<r;v++)g.push(e.getChannelData(v));let w=d;if(n===16)for(let v=0;v<a;v++)for(let m=0;m<r;m++){const b=g[m][v],_=Math.max(-1,Math.min(1,b)),y=_<0?_*32768:_*32767;h.setInt16(w,y,!0),w+=2}else for(let v=0;v<a;v++)for(let m=0;m<r;m++)h.setFloat32(w,g[m][v],!0),w+=4;return new Blob([p],{type:"audio/wav"})}function ns(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function av(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 Pd(){const[e,t]=f.useState(!1),[n,r]=f.useState(0),[s,a]=f.useState(null);return{exportWav:f.useCallback(async(i,l,c={})=>{const{filename:d="export",mode:u="master",trackIndex:p,autoDownload:h=!0,applyEffects:g=!0,effectsFunction:w,createOfflineTrackEffects:v,bitDepth:m=16,onProgress:b}=c;t(!0),r(0),a(null);try{if(i.length===0)throw new Error("No tracks to export");if(u==="individual"&&(p===void 0||p<0||p>=i.length))throw new Error("Invalid track index for individual export");const _=i[0].clips[0]?.sampleRate||44100;let y=0;for(const T of i)for(const P of T.clips){const A=P.startSample+P.durationSamples;y=Math.max(y,A)}y+=Math.round(_*.1);const x=y/_,k=u==="individual"?[{track:i[p],state:l[p],index:p}]:i.map((T,P)=>({track:T,state:l[P],index:P})),S=l.some(T=>T.soloed),M=!!v;let E;if((w||M)&&g)E=await ov(k,l,S,x,_,w,v,T=>{r(T),b?.(T)});else{const T=new OfflineAudioContext(2,y,_);let P=0;const A=k.reduce((W,{track:O})=>W+O.clips.length,0);for(const{track:W,state:O}of k)if(!(O.muted&&!O.soloed)&&!(S&&!O.soloed))for(const Y of W.clips){await lv(T,Y,O,_,g),P++;const U=P/A*.5;r(U),b?.(U)}r(.5),b?.(.5),E=await T.startRendering()}r(.9),b?.(.9);const I=sv(E,{bitDepth:m});if(r(1),b?.(1),h){const T=u==="individual"?`${d}_${i[p].name}`:d;av(I,`${T}.wav`)}return{audioBuffer:E,blob:I,duration:x}}catch(_){const y=_ instanceof Error?_.message:"Export failed";throw a(y),_}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function ov(e,t,n,r,s,a,o,i){const{Offline:l,Volume:c,Gain:d,Panner:u,Player:p,ToneAudioBuffer:h}=await import("tone");i(.1);let g;try{g=await l(async({transport:w,destination:v})=>{const m=new c(0);let b;a?b=a(m,v,!0):m.connect(v);for(const{track:_,state:y}of e){if(y.muted&&!y.soloed||n&&!y.soloed)continue;const x=new c(iv(y.volume)),k=new u(y.pan),S=new d(y.muted?0:1),M=o?.(_.id);M?M(S,m,!0):S.connect(m),k.connect(S),x.connect(k);for(const E of _.clips){const{audioBuffer:I,startSample:T,durationSamples:P,offsetSamples:A,gain:W,fadeIn:O,fadeOut:Y}=E,U=T/s,J=P/s,B=A/s,se=new h(I),ie=new p(se),ee=new d(W);if(ie.connect(ee),ee.connect(x),O){const ae=U,me=U+O.duration,ye=ga(ee.gain);ye&&(ye.setValueAtTime(0,ae),ye.linearRampToValueAtTime(W,me))}if(Y){const ae=U+J-Y.duration,me=U+J,ye=ga(ee.gain);ye&&(ye.setValueAtTime(W,ae),ye.linearRampToValueAtTime(0,me))}ie.start(U,B,J)}}w.start(0)},r,2,s)}catch(w){throw w instanceof Error?w:new Error(`Tone.Offline rendering failed: ${String(w)}`)}return i(.9),g.get()}function iv(e){return 20*Math.log10(Math.max(e,1e-4))}async function lv(e,t,n,r,s){const{audioBuffer:a,startSample:o,durationSamples:i,offsetSamples:l,gain:c,fadeIn:d,fadeOut:u}=t;if(!a){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const p=o/r,h=i/r,g=l/r,w=e.createBufferSource();w.buffer=a;const v=e.createGain(),m=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,w.connect(v),v.connect(b),b.connect(e.destination),s){if(d?v.gain.setValueAtTime(0,p):v.gain.setValueAtTime(m,p),d){const _=p,y=p+d.duration;Rl(v.gain,_,y,0,m,d.type||"linear")}if(u){const _=p+h-u.duration,y=p+h;(!d||d.duration<h-u.duration)&&v.gain.setValueAtTime(m,_),Rl(v.gain,_,y,m,0,u.type||"linear")}}else v.gain.setValueAtTime(m,p);w.start(p,g,h)}function Rl(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=Pl(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=Pl(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function Pl(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 Wd=()=>{const e=f.useRef(null),t=f.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=f.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return f.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},cv=`
|
|
862
|
+
`,x0=({items:e})=>{const[t,n]=f.useState(!1),s=typeof e=="function"?e(()=>n(!1)):e,[a,o]=f.useState({top:0,left:0}),i=f.useRef(null),l=f.useRef(null);return f.useEffect(()=>{if(t&&i.current){const c=i.current.getBoundingClientRect();o({top:c.bottom+2,left:Math.max(0,c.right-180)})}},[t]),f.useEffect(()=>{if(!t)return;const c=d=>{const u=d.target;i.current&&!i.current.contains(u)&&l.current&&!l.current.contains(u)&&n(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[t]),C.jsxs(y0,{children:[C.jsx(b0,{ref:i,onClick:c=>{c.stopPropagation(),n(d=>!d)},onMouseDown:c=>c.stopPropagation(),title:"Track menu","aria-label":"Track menu",children:C.jsx(v0,{size:16})}),t&&typeof document<"u"&&ro.createPortal(C.jsx(w0,{ref:l,$top:a.top,$left:a.left,onMouseDown:c=>c.stopPropagation(),children:s.map((c,d)=>C.jsxs(f.Fragment,{children:[d>0&&C.jsx(_0,{}),c.content]},c.id))}),document.body)]})};function _n(e,t){this._waveformData=e,this._channelIndex=t}_n.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};_n.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};_n.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};_n.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};_n.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};_n.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 C0=127,k0=-128,S0=32767,E0=-32768;function I0(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function A0(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(T){return new Float32Array(T)}),i=r?o.length:1,l=24,c=I0(s,t),d=e.bits===8?1:2,u=l+c*2*d*i,p=new ArrayBuffer(u),h=new DataView(p),g=0,w=l,v=new Array(i),m=new Array(i),b=0;b<i;b++)v[b]=1/0,m[b]=-1/0;var _=e.bits===8?k0:E0,y=e.bits===8?C0:S0;h.setInt32(0,2,!0),h.setUint32(4,e.bits===8,!0),h.setInt32(8,a,!0),h.setInt32(12,t,!0),h.setInt32(16,c,!0),h.setInt32(20,i,!0);for(var x=0;x<s;x++){var k=0;if(i===1){for(var S=0;S<o.length;++S)k+=o[S][x];k=Math.floor(y*k*n/o.length),k<v[0]&&(v[0]=k,v[0]<_&&(v[0]=_)),k>m[0]&&(m[0]=k,m[0]>y&&(m[0]=y))}else for(var I=0;I<i;++I)k=Math.floor(y*o[I][x]*n),k<v[I]&&(v[I]=k,v[I]<_&&(v[I]=_)),k>m[I]&&(m[I]=k,m[I]>y&&(m[I]=y));if(++g===t){for(var E=0;E<i;E++)e.bits===8?(h.setInt8(w++,v[E]),h.setInt8(w++,m[E])):(h.setInt16(w,v[E],!0),h.setInt16(w+2,m[E],!0),w+=4),v[E]=1/0,m[E]=-1/0;g=0}}if(g>0)for(var M=0;M<i;M++)e.bits===8?(h.setInt8(w++,v[M]),h.setInt8(w++,m[M])):(h.setInt16(w,v[M],!0),h.setInt16(w+2,m[M],!0));return p}function $s(e){"@babel/helpers - typeof";return $s=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},$s(e)}function M0(e){return e&&$s(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function $0(e){var t=e&&$s(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 T0(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 d=0;d<t.length;d++)l.setInt8(c++,t[d],!0);else for(var u=0;u<t.length;u++)l.setInt16(c,t[u],!0),c+=2;return i}function In(e){return e==null}function D0(e,t){var n=atob(e);return n}function R0(e,t,n){var r=D0(e),s=r.indexOf(`
|
|
863
|
+
`,10)+1,a=r.substring(s)+"",o=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(o)}function P0(e,t,n){var r;return function(a){return r=r||R0(e),new Worker(r,a)}}var W0=P0("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function mt(e){if(M0(e)&&(e=T0(e)),$0(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 _n(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var er={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function F0(e){var t={scale:e.scale||er.scale,bits:e.bits||er.bits,amplitude_scale:e.amplitude_scale||er.amplitude_scale,split_channels:e.split_channels||er.split_channels,disable_worker:e.disable_worker||er.disable_worker};return t}function O0(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Ad(e,t,n){var r=O0(e);if(t.disable_worker){var s=A0({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 a=new W0;a.onmessage=function(o){n(void 0,new mt(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 B0(e,t,n,r){function s(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var a=e.decodeAudioData(t,function(o){Ad(o,n,r)},s);a&&a.catch(s)}mt.create=function(t){return new mt(t)};mt.createFromAudio=function(e,t){var n=F0(e);if(e.audio_context&&e.array_buffer)return B0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Ad(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function js(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 mt(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}js.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};js.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};js.prototype.getOutputData=function(){return this._output_data};mt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!In(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!In(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 js(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,a=[this].concat(t).map(function(m){return m._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),d=new DataView(a[0]),u=new DataView(c),p=0;p<n;p++)u.setUint8(p,d.getUint8(p));u.setInt32(16,s,!0);for(var h=0,g=new Uint8Array(c,n),w=0;w<a.length;w++){var v=a[w];g.set(new Uint8Array(v,n),h),h+=v.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!In(t.startIndex)&&!In(t.endIndex)?(n=t.startIndex,r=t.endIndex):!In(t.startTime)&&!In(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 d=0;d<s*this.channels*2;d++){var u=this._at(n*this.channels*2+d);this.bits===8?c.setInt8(a+d,u):c.setInt16(a+d*2,u,!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 di(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 Md(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 V0(e,t=0){const n=await di(e);return Md(n,t)}async function L0(e){const t=await di(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function $d(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),d=Math.min(e.length,Math.ceil(l*o));if(c>=d)return null;s=s.slice({startIndex:c,endIndex:d}),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 z0(e,t,n=0,r,s){const a=$d(e,t,r,s);if(a===null){const p=e.bits;return{data:p===8?new Int8Array(0):new Int16Array(0),bits:p,length:0}}const o=a.channel(n),i=a.bits,l=o.min_array(),c=o.max_array(),d=l.length,u=i===8?new Int8Array(d*2):new Int16Array(d*2);for(let p=0;p<d;p++)u[p*2]=l[p],u[p*2+1]=c[p];return{data:u,bits:i,length:d}}function Dl(e,t,n,r,s){const a=$d(e,t,r,s);if(a===null){const d=e.bits;return{length:0,data:[],bits:d}}const o=a.channels,i=a.bits,l=[];for(let d=0;d<o;d++){const u=a.channel(d),p=u.min_array(),h=u.max_array(),g=p.length,w=i===8?new Int8Array(g*2):new Int16Array(g*2);for(let v=0;v<g;v++)w[v*2]=p[v],w[v*2+1]=h[v];l.push(w)}if(n&&l.length>1){const d=1/l.length,u=l[0].length/2,p=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let h=0;h<u;h++){let g=0,w=0;for(let v=0;v<l.length;v++)g+=d*l[v][h*2],w+=d*l[v][h*2+1];p[h*2]=g,p[h*2+1]=w}return{length:u,data:[p],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function Td(){const[e,t]=f.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Fn(s,e),parseTime:s=>xd(s,e)}}function Dd({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=f.useState(t),[s,a]=f.useState(!0),[o,i]=f.useState(!0),l=f.useRef(!0),c=f.useRef(!0),d=f.useRef(t),u=f.useCallback(()=>{e.current?.zoomIn()},[e]),p=f.useCallback(()=>{e.current?.zoomOut()},[e]),h=f.useCallback(g=>{g.samplesPerPixel!==d.current&&(d.current=g.samplesPerPixel,f.startTransition(()=>{r(g.samplesPerPixel)})),g.canZoomIn!==l.current&&(l.current=g.canZoomIn,a(g.canZoomIn)),g.canZoomOut!==c.current&&(c.current=g.canZoomOut,i(g.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:u,zoomOut:p,canZoomIn:s,canZoomOut:o,onEngineState:h}}function Rd({engineRef:e,initialVolume:t=1}){const[n,r]=f.useState(t),s=f.useRef(t),a=f.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),o=f.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:a,masterVolumeRef:s,onEngineState:o}}function j0({engineRef:e}){const[t,n]=f.useState(0),[r,s]=f.useState(0),a=f.useRef(0),o=f.useRef(0),i=f.useCallback((c,d)=>{e.current?.setSelection(c,d)},[e]),l=f.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 Z0({engineRef:e}){const[t,n]=f.useState(!1),[r,s]=f.useState(0),[a,o]=f.useState(0),i=f.useRef(!1),l=f.useRef(0),c=f.useRef(0),d=f.useCallback(g=>{e.current?.setLoopEnabled(g)},[e]),u=f.useCallback((g,w)=>{e.current?.setLoopRegion(g,w)},[e]),p=f.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),h=f.useCallback(g=>{g.isLoopEnabled!==i.current&&(i.current=g.isLoopEnabled,n(g.isLoopEnabled)),g.loopStart!==l.current&&(l.current=g.loopStart,s(g.loopStart)),g.loopEnd!==c.current&&(c.current=g.loopEnd,o(g.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:a,setLoopEnabled:d,setLoopRegion:u,clearLoopRegion:p,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:h}}function H0({engineRef:e}){const[t,n]=f.useState(null),r=f.useRef(null),s=f.useCallback(o=>{e.current?.selectTrack(o)},[e]),a=f.useCallback(o=>{o.selectedTrackId!==r.current&&(r.current=o.selectedTrackId,n(o.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:a,selectedTrackIdRef:r}}const N0=(e=256)=>{const t=f.useRef(null),n=f.useCallback((r,s,a)=>{const o=new j.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}};function X0(e,t={}){const{progressive:n=!1}=t,[r,s]=f.useState([]),[a,o]=f.useState(!0),[i,l]=f.useState(null),[c,d]=f.useState(0),u=e.length;return f.useEffect(()=>{if(e.length===0){s([]),o(!1),d(0);return}let p=!1;const h=new AbortController,g=new Map,w=(m,b,_)=>{const y=_??m.audioBuffer;if(!y&&!m.waveformData)throw new Error(`Track ${b+1}: Must provide src, audioBuffer, or waveformData`);const x=y?.duration??m.waveformData?.duration,k=jl({audioBuffer:y,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(k.startSample)||isNaN(k.durationSamples)||isNaN(k.offsetSamples))throw console.error("Invalid clip values:",k),new Error(`Invalid clip values for track ${b+1}`);return{...Zl({name:m.name||`Track ${b+1}`,clips:[k],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{o(!0),l(null),d(0);const m=zl.getContext().rawContext,b=e.map(async(y,x)=>{if(y.audioBuffer){const M=w(y,x,y.audioBuffer);return n&&!p&&(g.set(x,M),d(T=>T+1),s(Array.from({length:e.length},(T,P)=>g.get(P)).filter(T=>T!==void 0))),M}if(!y.src&&y.waveformData){const M=w(y,x);return n&&!p&&(g.set(x,M),d(T=>T+1),s(Array.from({length:e.length},(T,P)=>g.get(P)).filter(T=>T!==void 0))),M}if(!y.src)throw new Error(`Track ${x+1}: Must provide src, audioBuffer, or waveformData`);const k=await fetch(y.src,{signal:h.signal});if(!k.ok)throw new Error(`Failed to fetch ${y.src}: ${k.statusText}`);const S=await k.arrayBuffer(),I=await m.decodeAudioData(S);if(!I||!I.sampleRate||!I.duration)throw new Error(`Invalid audio buffer for ${y.src}`);const E=w(y,x,I);return n&&!p&&(g.set(x,E),d(M=>M+1),s(Array.from({length:e.length},(M,T)=>g.get(T)).filter(M=>M!==void 0))),E}),_=await Promise.all(b);p||(n||(s(_),d(_.length)),o(!1))}catch(m){if(!p){const b=m instanceof Error?m.message:"Unknown error loading audio";l(b),o(!1),console.error("Error loading audio tracks:",m)}}})(),()=>{p=!0,h.abort()}},[e,n]),{tracks:r,loading:a,error:i,loadedCount:c,totalCount:u}}function G0({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:a}){const o=f.useRef(null),i=f.useRef(0),l=f.useCallback(u=>{const p=u.operation.source?.data;if(!p)return;if(!p.boundary){o.current=null;return}const g=e[p.trackIndex]?.clips[p.clipIndex];g&&(o.current={offsetSamples:g.offsetSamples,durationSamples:g.durationSamples,startSample:g.startSample},a.current=!0)},[e,a]),c=f.useCallback(u=>{const p=u.operation.source?.data;if(!p||!p.boundary||!o.current)return;const{boundary:h,trackIndex:g,clipIndex:w}=p,b=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n,_=Math.floor(.1*r),y=o.current,x=e.map((k,S)=>{if(S!==g)return k;const I=[...k.clips].sort((T,P)=>T.startSample-P.startSample),E=I.findIndex(T=>T===k.clips[w]),M=k.clips.map((T,P)=>{if(P!==w)return T;if(h==="left"){const A={...T,startSample:y.startSample,offsetSamples:y.offsetSamples,durationSamples:y.durationSamples},F=va(A,Math.floor(b),"left",I,E,_),O=y.offsetSamples+F,H=y.durationSamples-F,K=y.startSample+F;return{...T,offsetSamples:O,durationSamples:H,startSample:K}}else{const A={...T,startSample:y.startSample,offsetSamples:y.offsetSamples,durationSamples:y.durationSamples},F=va(A,Math.floor(b),"right",I,E,_),O=y.durationSamples+F;return{...T,durationSamples:O}}});return{...k,clips:M}});i.current=b,t(x)},[e,t,n,r]),d=f.useCallback(u=>{if(u.canceled){if(o.current){const b=u.operation.source?.data;if(b){const{trackIndex:_,clipIndex:y}=b,x=o.current,k=e.map((S,I)=>{if(I!==_)return S;const E=S.clips.map((M,T)=>T!==y?M:{...M,offsetSamples:x.offsetSamples,durationSamples:x.durationSamples,startSample:x.startSample});return{...S,clips:E}});t(k)}}a.current=!1,o.current=null,i.current=0;return}const p=u.operation.source?.data;if(!p)return;const{trackIndex:h,clipId:g,boundary:w}=p,v=w?i.current:u.operation.transform.x*n,m=e[h]?.id;if(w){a.current=!1,m?s.current?s.current.trimClip(m,g,w,Math.floor(v)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${h} not found — trim not synced to adapter`),o.current=null,i.current=0;return}m?s.current?s.current.moveClip(m,g,Math.floor(v)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${h} not found — move not synced to adapter`)},[e,t,n,s,a]);return{onDragStart:l,onDragMove:c,onDragEnd:d}}const ua=.01;function Pd({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:a}){const o=f.useRef(null),i=f.useCallback(d=>{const u=d.operation.source?.data;if(!u||u.annotationIndex===void 0){o.current=null;return}const p=e[u.annotationIndex];p&&(o.current={start:p.start,end:p.end,annotationIndex:u.annotationIndex})},[e]),l=f.useCallback(d=>{if(!o.current)return;const u=d.operation.source?.data;if(!u)return;const{edge:p,annotationIndex:h}=u,g=o.current,m=((d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x)*n/r,b=p==="start"?g.start+m:g.end+m,_=Y0({annotationIndex:h,newTime:b,isDraggingStart:p==="start",annotations:e,duration:s,linkEndpoints:a});t(_)},[e,t,n,r,s,a]),c=f.useCallback(d=>{if(d.canceled&&o.current){const{annotationIndex:u,start:p,end:h}=o.current,g=e.map((w,v)=>v!==u?w:{...w,start:p,end:h});t(g)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function Y0({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 d=o[e-1];Math.abs(d.end-i.start)<ua?o[e-1]={...d,end:Math.max(d.start+.1,d.end+c)}:l<=d.end&&(o[e]={...o[e],start:d.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 d=o[e+1];if(Math.abs(d.start-i.end)<ua){const u=d.start+c;o[e+1]={...d,start:Math.min(d.end-.1,u)};let p=e+1;for(;p<o.length-1;){const h=o[p],g=o[p+1];if(Math.abs(g.start-h.end)<ua){const w=h.end-r[p].end;o[p+1]={...g,start:Math.min(g.end-.1,g.start+w)},p++}else break}}else l>=d.start&&(o[e]={...o[e],end:d.start})}else if(!a&&e<o.length-1&&l>o[e+1].start){const d=o[e+1];o[e+1]={...d,start:l};let u=e+1;for(;u<o.length-1;){const p=o[u],h=o[u+1];if(p.end>h.start)o[u+1]={...h,start:p.end},u++;else break}}}return o}function U0(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return f.useMemo(()=>t?[Xa.configure({activationConstraints(a){return a.pointerType==="touch"?[new Ot.Delay({value:n,tolerance:r})]:[new Ot.Distance({value:s})]}})]:[Xa.configure({activationConstraints:[new Ot.Distance({value:s})]})],[t,n,r,s])}const K0=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=ct(),{selectedTrackId:a}=ut(),o=f.useCallback((l,c,d)=>{const{samplesPerPixel:u}=e,p=t[l];if(!p)return!1;const h=p.clips[c];if(!h)return!1;const g=Math.round(d*n),w=Wf(g,u),v=Math.floor(.1*n);if(!Gl(h,w,v))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const m=r.current;return m?(m.splitClip(p.id,h.id,w),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:f.useCallback(()=>{if(!a)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(u=>u.id===a);if(l===-1)return console.warn("Selected track not found"),!1;const c=t[l],d=s.current??0;for(let u=0;u<c.clips.length;u++){const p=c.clips[u],h=p.startSample/n,g=(p.startSample+p.durationSamples)/n;if(d>h&&d<g)return o(l,u,d)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,a,o,n]),splitClipAt:o}},Ts=e=>{const{shortcuts:t,enabled:n=!0}=e,r=f.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,d=i.shiftKey===void 0||s.shiftKey===i.shiftKey,u=i.metaKey===void 0||s.metaKey===i.metaKey,p=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&d&&u&&p});o&&(o.preventDefault!==!1&&s.preventDefault(),o.action())},[t,n]);f.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},q0=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("+")},J0=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=ct(),{setCurrentTime:a,play:o,pause:i,stop:l}=Te(),c=f.useCallback(()=>{s?i():o()},[s,o,i]),d=f.useCallback(()=>{l()},[l]),u=f.useCallback(()=>{a(0),s&&o(0)},[s,a,o]),h=r??[...[{key:" ",action:c,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:d,description:"Stop",preventDefault:!0},{key:"0",action:u,description:"Rewind to start",preventDefault:!0}],...n];return Ts({shortcuts:h,enabled:t}),{rewindToStart:u,togglePlayPause:c,stopPlayback:d,shortcuts:h}},da=.01,ts=.01;function Q0({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:a,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:d,controlsWidth:u=0,onPlay:p}){const h=f.useMemo(()=>t?e.findIndex(E=>E.id===t):-1,[e,t]),g=f.useCallback(E=>{if(!l?.current||!c||!d)return;const M=e.find(B=>B.id===E);if(!M)return;const T=l.current,P=T.clientWidth,A=M.start*d/c+u,F=M.end*d/c+u,O=(A+F)/2,H=T.scrollLeft,K=H,ne=H+P;if(A<K||F>ne){const B=Math.max(0,O-P/2);T.scrollTo({left:B,behavior:"smooth"})}},[e,l,c,d,u]);f.useEffect(()=>{t&&l?.current&&c&&d&&g(t)},[t,g,l,c,d]);const w=f.useCallback(E=>{if(h<0)return;const M=e[h],T=Math.max(0,Math.min(M.end-.1,M.start+E)),P=T-M.start,A=[...e];if(A[h]={...M,start:T},a&&h>0){const F=A[h-1];Math.abs(F.end-M.start)<da&&(A[h-1]={...F,end:Math.max(F.start+.1,F.end+P)})}else if(!a&&h>0){const F=A[h-1];T<F.end&&(A[h-1]={...F,end:T})}n(A)},[e,h,a,n]),v=f.useCallback(E=>{if(h<0)return;const M=e[h],T=Math.max(M.start+.1,Math.min(s,M.end+E)),P=T-M.end,A=[...e];if(A[h]={...M,end:T},a&&h<e.length-1){const F=A[h+1];if(Math.abs(F.start-M.end)<da){const O=Math.min(F.end-.1,F.start+P);A[h+1]={...F,start:O};let H=h+1;for(;H<A.length-1;){const K=A[H],ne=A[H+1];if(Math.abs(ne.start-e[H].end)<da){const B=K.end-e[H].end;A[H+1]={...ne,start:Math.min(ne.end-.1,ne.start+B)},H++}else break}}}else if(!a&&h<e.length-1){const F=A[h+1];if(T>F.start){A[h+1]={...F,start:T};let O=h+1;for(;O<A.length-1;){const H=A[O],K=A[O+1];if(H.end>K.start)A[O+1]={...K,start:H.end},O++;else break}}}n(A)},[e,h,s,a,n]),m=f.useCallback(()=>{!r||e.length===0||(h<=0?r(e[e.length-1].id):r(e[h-1].id))},[e,h,r]),b=f.useCallback(()=>{!r||e.length===0||(h<0||h>=e.length-1?r(e[0].id):r(e[h+1].id))},[e,h,r]),_=f.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),y=f.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),x=f.useCallback(()=>{r&&r(null)},[r]),k=f.useCallback(()=>{if(h<0||!p)return;const E=e[h],M=o?void 0:E.end-E.start;p(E.start,M)},[e,h,o,p]),S=f.useMemo(()=>[{key:"[",action:()=>w(-ts),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>w(ts),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-ts),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(ts),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:k,description:"Play selected annotation",preventDefault:!0}],[w,v,k]),I=f.useMemo(()=>[{key:"ArrowUp",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:b,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:b,description:"Select next annotation",preventDefault:!0},{key:"Home",action:_,description:"Select first annotation",preventDefault:!0},{key:"End",action:y,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:x,description:"Deselect annotation",preventDefault:!0}],[m,b,_,y,x]);return Ts({shortcuts:S,enabled:i&&h>=0}),Ts({shortcuts:I,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:w,moveEndBoundary:v,selectPrevious:m,selectNext:b,selectFirst:_,selectLast:y,clearSelection:x,scrollToAnnotation:g,playActiveAnnotation:k}}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}]}],fi=e=>zr.find(t=>t.id===e),ev=e=>zr.filter(t=>t.category===e),tv=[{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 nv={reverb:j.Reverb,freeverb:j.Freeverb,jcReverb:j.JCReverb,feedbackDelay:j.FeedbackDelay,pingPongDelay:j.PingPongDelay,chorus:j.Chorus,phaser:j.Phaser,tremolo:j.Tremolo,vibrato:j.Vibrato,autoPanner:j.AutoPanner,autoFilter:j.AutoFilter,autoWah:j.AutoWah,eq3:j.EQ3,distortion:j.Distortion,bitCrusher:j.BitCrusher,chebyshev:j.Chebyshev,compressor:j.Compressor,limiter:j.Limiter,gate:j.Gate,stereoWidener:j.StereoWidener};let rv=0;const sv=()=>`effect_${Date.now()}_${++rv}`;function Ar(e,t){const n=nv[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=sv(),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 d=o.wet;if(d&&typeof d=="object"&&"value"in d){d.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 av(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 ov(e=256){const[t,n]=f.useState([]),r=f.useRef(t);r.current=t;const s=f.useRef(new Map),a=f.useRef(null),o=f.useRef(null),i=f.useCallback(v=>{const m=o.current;if(!m)return;const{masterGainNode:b,destination:_,analyserNode:y}=m;try{b.disconnect()}catch(k){console.warn("[waveform-playlist] Error disconnecting master effects chain:",k)}const x=v.map(k=>s.current.get(k.instanceId)).filter(k=>k!==void 0);if(x.length===0)b.connect(y),y.connect(_);else{let k=b;x.forEach(S=>{try{S.disconnect()}catch(I){console.warn(`[waveform-playlist] Error disconnecting effect "${S.id}":`,I)}k.connect(S.effect),k=S.effect}),k.connect(y),y.connect(_)}},[]),l=f.useCallback(v=>{const m=fi(v);if(!m){console.error(`Unknown effect: ${v}`);return}const b={};m.parameters.forEach(x=>{b[x.name]=x.default});const _=Ar(m,b);s.current.set(_.instanceId,_);const y={instanceId:_.instanceId,effectId:m.id,definition:m,params:b,bypassed:!1};n(x=>[...x,y])},[]),c=f.useCallback(v=>{const m=s.current.get(v);m&&(m.dispose(),s.current.delete(v)),n(b=>b.filter(_=>_.instanceId!==v))},[]),d=f.useCallback((v,m,b)=>{const _=s.current.get(v);_&&_.setParameter(m,b),n(y=>y.map(x=>x.instanceId===v?{...x,params:{...x.params,[m]:b}}:x))},[]),u=f.useCallback(v=>{const m=r.current.find(y=>y.instanceId===v);if(!m)return;const b=!m.bypassed,_=s.current.get(v);if(_){const y=m.params.wet??1;_.setParameter("wet",b?0:y)}n(y=>y.map(x=>x.instanceId===v?{...x,bypassed:b}:x))},[]),p=f.useCallback((v,m)=>{n(b=>{const _=[...b],[y]=_.splice(v,1);return _.splice(m,0,y),_})},[]),h=f.useCallback(()=>{s.current.forEach(v=>v.dispose()),s.current.clear(),n([])},[]);f.useEffect(()=>{i(t)},[t,i]);const g=f.useCallback((v,m,b)=>{const _=new j.Analyser("fft",e);a.current=_,o.current={masterGainNode:v,destination:m,analyserNode:_};const x=r.current.map(k=>s.current.get(k.instanceId)).filter(k=>k!==void 0);if(x.length===0)v.connect(_),_.connect(m);else{let k=v;x.forEach(S=>{k.connect(S.effect),k=S.effect}),k.connect(_),_.connect(m)}return function(){_.dispose(),a.current=null,o.current=null}},[e]);f.useEffect(()=>{const v=s.current;return()=>{v.forEach(m=>m.dispose()),v.clear()}},[]);const w=f.useCallback(()=>{const v=t.filter(m=>!m.bypassed);if(v.length!==0)return(m,b,_)=>{const y=[];for(const x of v){const k=Ar(x.definition,x.params);y.push(k)}if(y.length===0)m.connect(b);else{let x=m;y.forEach(k=>{x.connect(k.effect),x=k.effect}),x.connect(b)}return function(){y.forEach(k=>k.dispose())}}},[t]);return{activeEffects:t,availableEffects:zr,addEffect:l,removeEffect:c,updateParameter:d,toggleBypass:u,reorderEffects:p,clearAllEffects:h,masterEffects:g,createOfflineEffectsFunction:w,analyserRef:a}}function iv(){const[e,t]=f.useState(new Map),n=f.useRef(new Map),r=f.useRef(new Map),s=f.useCallback((h,g)=>{const w=r.current.get(h);if(!w)return;const{graphEnd:v,masterGainNode:m}=w,b=n.current.get(h);try{v.disconnect()}catch(y){console.warn(`[waveform-playlist] Error disconnecting track "${h}" effect chain:`,y)}const _=g.map(y=>b?.get(y.instanceId)).filter(y=>y!==void 0);if(_.length===0)v.connect(m);else{let y=v;_.forEach(x=>{try{x.disconnect()}catch(k){console.warn(`[waveform-playlist] Error disconnecting effect "${x.id}" on track "${h}":`,k)}y.connect(x.effect),y=x.effect}),y.connect(m)}},[]),a=f.useCallback((h,g)=>{const w=fi(g);if(!w){console.error(`Unknown effect: ${g}`);return}const v={};w.parameters.forEach(_=>{v[_.name]=_.default});const m=Ar(w,v);n.current.has(h)||n.current.set(h,new Map),n.current.get(h).set(m.instanceId,m);const b={instanceId:m.instanceId,effectId:w.id,definition:w,params:v,bypassed:!1};t(_=>{const y=new Map(_),x=y.get(h)||[];return y.set(h,[...x,b]),y})},[]),o=f.useCallback((h,g)=>{const w=n.current.get(h),v=w?.get(g);v&&(v.dispose(),w?.delete(g)),t(m=>{const b=new Map(m),_=b.get(h)||[];return b.set(h,_.filter(y=>y.instanceId!==g)),b})},[]),i=f.useCallback((h,g,w,v)=>{const b=n.current.get(h)?.get(g);b&&b.setParameter(w,v),t(_=>{const y=new Map(_),x=y.get(h)||[];return y.set(h,x.map(k=>k.instanceId===g?{...k,params:{...k.params,[w]:v}}:k)),y})},[]),l=f.useCallback((h,g)=>{const v=(d.current.get(h)||[]).find(y=>y.instanceId===g);if(!v)return;const m=!v.bypassed,_=n.current.get(h)?.get(g);if(_){const y=v.params.wet??1;_.setParameter("wet",m?0:y)}t(y=>{const x=new Map(y),k=x.get(h)||[];return x.set(h,k.map(S=>S.instanceId===g?{...S,bypassed:m}:S)),x})},[]),c=f.useCallback(h=>{const g=n.current.get(h);g&&(g.forEach(w=>w.dispose()),g.clear()),t(w=>{const v=new Map(w);return v.set(h,[]),v})},[]),d=f.useRef(e);d.current=e;const u=f.useCallback(h=>(g,w,v)=>{r.current.set(h,{graphEnd:g,masterGainNode:w});const m=d.current.get(h)||[],b=n.current.get(h),_=m.map(y=>b?.get(y.instanceId)).filter(y=>y!==void 0);if(_.length===0)g.connect(w);else{let y=g;_.forEach(x=>{y.connect(x.effect),y=x.effect}),y.connect(w)}return function(){r.current.delete(h)}},[]);f.useEffect(()=>{e.forEach((h,g)=>{s(g,h)})},[e,s]),f.useEffect(()=>{const h=n.current;return()=>{h.forEach(g=>{g.forEach(w=>w.dispose()),g.clear()}),h.clear()}},[]);const p=f.useCallback(h=>{const w=(e.get(h)||[]).filter(v=>!v.bypassed);if(w.length!==0)return(v,m,b)=>{const _=[];for(const y of w){const x=Ar(y.definition,y.params);_.push(x)}if(_.length===0)v.connect(m);else{let y=v;_.forEach(x=>{y.connect(x.effect),y=x.effect}),y.connect(m)}return function(){_.forEach(x=>x.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:a,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:u,createOfflineTrackEffectsFunction:p,availableEffects:zr}}function lv(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,d=44,u=d+c,p=new ArrayBuffer(u),h=new DataView(p);ns(h,0,"RIFF"),h.setUint32(4,u-8,!0),ns(h,8,"WAVE"),ns(h,12,"fmt "),h.setUint32(16,16,!0),h.setUint16(20,n===32?3:1,!0),h.setUint16(22,r,!0),h.setUint32(24,s,!0),h.setUint32(28,l,!0),h.setUint16(32,i,!0),h.setUint16(34,n,!0),ns(h,36,"data"),h.setUint32(40,c,!0);const g=[];for(let v=0;v<r;v++)g.push(e.getChannelData(v));let w=d;if(n===16)for(let v=0;v<a;v++)for(let m=0;m<r;m++){const b=g[m][v],_=Math.max(-1,Math.min(1,b)),y=_<0?_*32768:_*32767;h.setInt16(w,y,!0),w+=2}else for(let v=0;v<a;v++)for(let m=0;m<r;m++)h.setFloat32(w,g[m][v],!0),w+=4;return new Blob([p],{type:"audio/wav"})}function ns(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function cv(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 Wd(){const[e,t]=f.useState(!1),[n,r]=f.useState(0),[s,a]=f.useState(null);return{exportWav:f.useCallback(async(i,l,c={})=>{const{filename:d="export",mode:u="master",trackIndex:p,autoDownload:h=!0,applyEffects:g=!0,effectsFunction:w,createOfflineTrackEffects:v,bitDepth:m=16,onProgress:b}=c;t(!0),r(0),a(null);try{if(i.length===0)throw new Error("No tracks to export");if(u==="individual"&&(p===void 0||p<0||p>=i.length))throw new Error("Invalid track index for individual export");const _=i[0].clips[0]?.sampleRate||44100;let y=0;for(const T of i)for(const P of T.clips){const A=P.startSample+P.durationSamples;y=Math.max(y,A)}y+=Math.round(_*.1);const x=y/_,k=u==="individual"?[{track:i[p],state:l[p],index:p}]:i.map((T,P)=>({track:T,state:l[P],index:P})),S=l.some(T=>T.soloed),I=!!v;let E;if((w||I)&&g)E=await uv(k,l,S,x,_,w,v,T=>{r(T),b?.(T)});else{const T=new OfflineAudioContext(2,y,_);let P=0;const A=k.reduce((F,{track:O})=>F+O.clips.length,0);for(const{track:F,state:O}of k)if(!(O.muted&&!O.soloed)&&!(S&&!O.soloed))for(const H of F.clips){await fv(T,H,O,_,g),P++;const K=P/A*.5;r(K),b?.(K)}r(.5),b?.(.5),E=await T.startRendering()}r(.9),b?.(.9);const M=lv(E,{bitDepth:m});if(r(1),b?.(1),h){const T=u==="individual"?`${d}_${i[p].name}`:d;cv(M,`${T}.wav`)}return{audioBuffer:E,blob:M,duration:x}}catch(_){const y=_ instanceof Error?_.message:"Export failed";throw a(y),_}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function uv(e,t,n,r,s,a,o,i){const{Offline:l,Volume:c,Gain:d,Panner:u,Player:p,ToneAudioBuffer:h}=await import("tone");i(.1);let g;try{g=await l(async({transport:w,destination:v})=>{const m=new c(0);let b;a?b=a(m,v,!0):m.connect(v);for(const{track:_,state:y}of e){if(y.muted&&!y.soloed||n&&!y.soloed)continue;const x=new c(dv(y.volume)),k=new u(y.pan),S=new d(y.muted?0:1),I=o?.(_.id);I?I(S,m,!0):S.connect(m),k.connect(S),x.connect(k);for(const E of _.clips){const{audioBuffer:M,startSample:T,durationSamples:P,offsetSamples:A,gain:F,fadeIn:O,fadeOut:H}=E,K=T/s,ne=P/s,B=A/s,re=new h(M),se=new p(re),ae=new d(F);if(se.connect(ae),ae.connect(x),O){const ie=K,me=K+O.duration,ye=ga(ae.gain);ye&&(ye.setValueAtTime(0,ie),ye.linearRampToValueAtTime(F,me))}if(H){const ie=K+ne-H.duration,me=K+ne,ye=ga(ae.gain);ye&&(ye.setValueAtTime(F,ie),ye.linearRampToValueAtTime(0,me))}se.start(K,B,ne)}}w.start(0)},r,2,s)}catch(w){throw w instanceof Error?w:new Error(`Tone.Offline rendering failed: ${String(w)}`)}return i(.9),g.get()}function dv(e){return 20*Math.log10(Math.max(e,1e-4))}async function fv(e,t,n,r,s){const{audioBuffer:a,startSample:o,durationSamples:i,offsetSamples:l,gain:c,fadeIn:d,fadeOut:u}=t;if(!a){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const p=o/r,h=i/r,g=l/r,w=e.createBufferSource();w.buffer=a;const v=e.createGain(),m=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,w.connect(v),v.connect(b),b.connect(e.destination),s){if(d?v.gain.setValueAtTime(0,p):v.gain.setValueAtTime(m,p),d){const _=p,y=p+d.duration;Rl(v.gain,_,y,0,m,d.type||"linear")}if(u){const _=p+h-u.duration,y=p+h;(!d||d.duration<h-u.duration)&&v.gain.setValueAtTime(m,_),Rl(v.gain,_,y,m,0,u.type||"linear")}}else v.gain.setValueAtTime(m,p);w.start(p,g,h)}function Rl(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=Pl(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=Pl(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function Pl(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 Fd=()=>{const e=f.useRef(null),t=f.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=f.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return f.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},hv=`
|
|
864
864
|
"use strict";
|
|
865
865
|
|
|
866
866
|
var INT8_MAX = 127;
|
|
@@ -1007,13 +1007,13 @@ self.onmessage = function(e) {
|
|
|
1007
1007
|
self.postMessage({ id: msg.id, error: err.message || String(err) });
|
|
1008
1008
|
}
|
|
1009
1009
|
};
|
|
1010
|
-
`;let uv=0;function dv(){let e;try{const r=new Blob([cv],{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=mt.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(++uv);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 fv(e,t){const[n,r]=f.useState(()=>new Map),[s,a]=f.useState(!1),o=f.useRef(null),i=f.useRef(new Set),l=f.useRef(0),c=f.useCallback(()=>(o.current||(o.current=dv()),o.current),[]);return f.useEffect(()=>{let d=!1;const u=i.current,p=[];for(const w of e)for(const v of w.clips)v.audioBuffer&&!v.waveformData&&!u.has(v.id)&&p.push({clipId:v.id,audioBuffer:v.audioBuffer});if(p.length===0)return;const h=new Set;for(const{clipId:w}of p)u.add(w),h.add(w);l.current+=p.length,a(!0);const g=c();for(const{clipId:w,audioBuffer:v}of p){const m=[];for(let b=0;b<v.numberOfChannels;b++)m.push(v.getChannelData(b).slice().buffer);g.generate({id:w,channels:m,length:v.length,sampleRate:v.sampleRate,scale:t,bits:16,splitChannels:!0}).then(b=>{d||(r(_=>{const y=new Map(_);return y.set(w,b),y}),l.current--,l.current<=0&&(l.current=0,a(!1)))}).catch(b=>{d||(console.warn("[waveform-playlist] Worker peak generation failed:",b),u.delete(w),l.current--,l.current<=0&&(l.current=0,a(!1)))})}return()=>{d=!0;for(const w of h)u.delete(w)}},[e,t,c]),f.useEffect(()=>()=>{o.current?.terminate(),o.current=null},[]),{cache:n,isGenerating:s}}function Ja(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 hv(e,t,n){const r=Ja(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 pv(){const[e,t]=f.useState([]),[n,r]=f.useState(0),[s,a]=f.useState([]),o=f.useRef(!1),i=f.useRef(new Set),l=f.useRef(new Map);f.useEffect(()=>{const u=l.current;return()=>{o.current=!0;for(const p of u.values())p.abort();u.clear()}},[]);const c=f.useCallback(u=>{if(u.length===0)return;const p=Df(),h=u.map(g=>({track:Zl({name:`${Ja(g)} (loading...)`,clips:[]}),source:g}));t(g=>[...g,...h.map(w=>w.track)]),r(g=>g+u.length);for(const{track:g,source:w}of h){i.current.add(g.id);const v=new AbortController;l.current.set(g.id,v),(async()=>{try{const{audioBuffer:m,name:b}=await hv(w,p,v.signal),_=jl({audioBuffer:m,startTime:0,duration:m.duration,offset:0,name:b});!o.current&&i.current.has(g.id)&&t(y=>y.map(x=>x.id===g.id?{...x,name:b,clips:[_]}:x))}catch(m){if(m instanceof DOMException&&m.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",m),!o.current&&i.current.has(g.id)&&(t(b=>b.filter(_=>_.id!==g.id)),a(b=>[...b,{name:Ja(w),error:m instanceof Error?m:new Error(String(m))}]))}finally{l.current.delete(g.id),!o.current&&i.current.delete(g.id)&&r(m=>m-1)}})()}},[]),d=f.useCallback(u=>{t(h=>h.filter(g=>g.id!==u));const p=l.current.get(u);p&&(p.abort(),l.current.delete(u)),i.current.delete(u)&&r(h=>h-1)},[]);return{tracks:e,addTracks:c,removeTrack:d,loadingCount:n,isLoading:n>0,errors:s}}const Fd=f.createContext(null),Od=f.createContext(null),Bd=f.createContext(null),Vd=f.createContext(null),mv=({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:d,onReady:u,onAnnotationUpdate:p,onAnnotationsChange:h,barWidth:g=1,barGap:w=0,progressBarWidth:v,onTracksChange:m,children:b})=>{const _=v??g+w,y=f.useMemo(()=>a,[a?.join(",")]),x=f.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const F=c.annotations[0];if(typeof F.start!="number"||typeof F.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 F.start),[]}return c.annotations},[c?.annotations]),k=f.useRef(x);k.current=x;const[S,M]=f.useState(null),[E,I]=f.useState(!1),[T,P]=f.useState(0),[A,W]=f.useState(0),[O,Y]=f.useState([]),[U,J]=f.useState([]),[B,se]=f.useState([]),[ie,ee]=f.useState(o),[ae,me]=f.useState(c?.isContinuousPlay??!1),[ye,De]=f.useState(c?.linkEndpoints??!1),[H,Z]=f.useState(c?.editable??!1),[de,N]=f.useState(!1),$=f.useRef(null),he=f.useRef(!1),We=f.useRef(!1);We.current=E;const q=f.useRef(0),ge=f.useRef(0),Le=f.useRef(e),Ne=f.useRef(B),K=f.useRef(0),Re=f.useRef(0),ze=f.useRef(null),xe=f.useRef(null),Xe=f.useRef(!1),Ue=f.useRef(c?.isContinuousPlay??!1),at=f.useRef(null),yt=f.useRef(null),At=f.useRef(0),X=f.useRef(!1),le=f.useRef(!1),Fe=f.useRef(s),{timeFormat:Ke,setTimeFormat:ne,formatTime:be}=$d(),Ee=Td({engineRef:$,initialSamplesPerPixel:s}),{samplesPerPixel:je,onEngineState:bt}=Ee,L=Dd({engineRef:$,initialVolume:1}),{masterVolume:G,setMasterVolume:te,masterVolumeRef:Ce,onEngineState:ve}=L,{selectionStart:Qe,selectionEnd:dt,setSelection:oe,selectionStartRef:Ze,selectionEndRef:et,onEngineState:en}=B0({engineRef:$}),{isLoopEnabled:Pt,loopStart:Wt,loopEnd:tn,setLoopEnabled:nn,setLoopRegion:Mt,clearLoopRegion:Kn,isLoopEnabledRef:Zr,loopStartRef:Hr,loopEndRef:gi,onEngineState:vi}=V0({engineRef:$}),{selectedTrackId:yi,setSelectedTrackId:bi,onEngineState:wi,selectedTrackIdRef:_i}=L0({engineRef:$}),{animationFrameRef:xi,startAnimationFrameLoop:Ys,stopAnimationFrameLoop:Nr}=Wd(),cf=f.useMemo(()=>Math.min(...y??[256,512,1024,2048,4096,8192]),[y]),{cache:Ci}=fv(e,cf),ki=f.useCallback(F=>{Ue.current=F,me(F)},[]),Ft=f.useCallback(F=>{at.current=F,M(F)},[]),Si=f.useCallback(()=>{const F=Ze.current??0,z=et.current??0;F!==z&&z>F&&Mt(F,z)},[Mt,Ze,et]);f.useEffect(()=>{Xe.current=ie},[ie]),f.useEffect(()=>{Ne.current=B},[B]),Le.current=e;const Us=e===yt.current;X.current=Us||le.current,f.useEffect(()=>{if(!xe.current||!O.length)return;const F=xe.current,z=Fe.current,fe=je;if(z===fe)return;const V=l.show?l.width:0,ke=F.clientWidth,Be=F.scrollLeft+ke/2-V,kn=O[0].sampleRate,Sn=Be*z/kn*kn/fe,Js=Math.max(0,Sn+V-ke/2);F.scrollLeft=Js,Fe.current=fe},[je,O,l]);const Xr=f.useRef(null);f.useEffect(()=>{if(Us||le.current){Us&&(yt.current=null);let V=0;e.forEach(ke=>{ke.clips.forEach(Oe=>{const Be=(Oe.startSample+Oe.durationSamples)/Oe.sampleRate;V=Math.max(V,Be)})}),W(V);return}if(N(!1),e.length===0){Y([]),W(0),se([]),J([]),$.current&&($.current.dispose(),$.current=null);return}const F=We.current,z=ge.current;return $.current&&F&&($.current.stop(),Nr(),Xr.current={position:z}),(async()=>{try{const V=[];e.forEach(Ie=>{Ie.clips.length>0&&Ie.clips[0].audioBuffer&&V.push(Ie.clips[0].audioBuffer)});let ke=0;e.forEach(Ie=>{Ie.clips.forEach(ht=>{const Zt=ht.sampleRate,mf=(ht.startSample+ht.durationSamples)/Zt;ke=Math.max(ke,mf)})}),Y(V),W(ke),se(Ie=>Ie.length===e.length?Ie.map((ht,Zt)=>({...ht,name:e[Zt].name})):e.map(ht=>({name:ht.name,muted:ht.muted,soloed:ht.soloed,volume:ht.volume,pan:ht.pan}))),$.current&&$.current.dispose(),At.current=0,yt.current=null,he.current=!1;const Oe=Rf({effects:d}),Be=new Vf({adapter:Oe,samplesPerPixel:Fe.current,zoomLevels:y});Be.setSelection(Ze.current??0,et.current??0),Be.setLoopRegion(Hr.current??0,gi.current??0),Zr.current&&Be.setLoopEnabled(!0),Be.setMasterVolume(Ce.current??1),_i.current&&Be.selectTrack(_i.current);const kn=Ne.current,Yr=e.map((Ie,ht)=>{const Zt=kn[ht];return{...Ie,volume:Zt?.volume??Ie.volume,muted:Zt?.muted??Ie.muted,soloed:Zt?.soloed??Ie.soloed,pan:Zt?.pan??Ie.pan}});let Sn=!0;Be.on("statechange",Ie=>{en(Ie),vi(Ie),wi(Ie),bt(Ie),ve(Ie),!Sn&&Ie.tracksVersion!==At.current&&(At.current=Ie.tracksVersion,yt.current=Ie.tracks,m?m(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."))}),Be.setTracks(Yr),Sn=!1,At.current=Be.getState().tracksVersion,$.current=Be,N(!0);const Js=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:ke}});window.dispatchEvent(Js),u?.()}catch(V){console.error("Error loading audio:",V)}})(),()=>{if(X.current){X.current=!1;return}Nr(),$.current&&$.current.dispose()}},[e,u,d,Nr,en,vi,wi,bt,ve,m,Ce,Ze,et,Hr,gi,Zr,y]),f.useEffect(()=>{if(e.length===0)return;const F=e.map(z=>z.clips.map(V=>{let ke;if(V.waveformData)try{ke=Dl(V.waveformData,je,n,V.offsetSamples,V.durationSamples)}catch(Oe){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",Oe)}if(!ke){const Oe=Ci.get(V.id);if(Oe)try{ke=Dl(Oe,je,n,V.offsetSamples,V.durationSamples)}catch(Be){console.warn("[waveform-playlist] Failed to extract peaks from cache:",Be)}}if(!ke){!V.audioBuffer&&!V.waveformData&&console.warn(`[waveform-playlist] Clip "${V.id}" has no audio data or waveform data`);const Oe=n?1:V.audioBuffer?.numberOfChannels??1;ke={length:0,data:Array.from({length:Oe},()=>new Int16Array(0)),bits:16}}return{clipId:V.id,trackName:z.name,peaks:ke,startSample:V.startSample,durationSamples:V.durationSamples,fadeIn:V.fadeIn,fadeOut:V.fadeOut}}));J(F)},[e,je,n,Ci]);const Ei=f.useRef(!1),Cn=f.useCallback(()=>{if($.current)return $.current.getCurrentTime();Ei.current||(Ei.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const F=j.getContext().currentTime-(K.current??0);return(Re.current??0)+F},[]),rn=f.useCallback(()=>{const F=()=>{const z=Cn();ge.current=z;const fe=k.current;if(fe.length>0){const V=fe.find(ke=>z>=ke.start&&z<ke.end);if(Ue.current)V&&V.id!==at.current?Ft(V.id):!V&&at.current!==null&&Ft(null);else if(at.current){const ke=fe.find(Oe=>Oe.id===at.current);if(ke&&z>=ke.end){$.current&&$.current.stop(),I(!1),ge.current=q.current,P(q.current);return}}else V&&Ft(V.id)}if(Xe.current&&xe.current&&O.length>0){const V=xe.current,ke=O[0].sampleRate,Oe=z*ke/Fe.current,Be=V.clientWidth,kn=l.show?l.width:0,Yr=Oe+kn,Sn=Math.max(0,Yr-Be/2);V.scrollLeft=Sn}if(ze.current!==null&&z>=ze.current){$.current&&$.current.stop(),I(!1),ge.current=ze.current,P(ze.current),ze.current=null;return}if(z>=A){$.current&&$.current.stop(),I(!1),ge.current=q.current,P(q.current),Ft(null);return}Ys(F)};Ys(F)},[A,O,l.show,l.width,Ft,Ys,Cn]),ft=Nr;f.useEffect(()=>{(async()=>{if(E&&xi.current&&$.current)if(ae){const z=ge.current;$.current.stop(),ft();const V=j.getContext().currentTime;K.current=V,Re.current=z,$.current.play(z),rn()}else ft(),rn()})().catch(z=>{console.warn("[waveform-playlist] Failed to reschedule playback:",z),I(!1),ft()})},[ae,E,rn,ft,xi]),f.useEffect(()=>{(async()=>{if(Xr.current&&$.current){const{position:z}=Xr.current;Xr.current=null;const V=j.getContext().currentTime;K.current=V,Re.current=z,he.current||(await $.current.init(),he.current=!0),$.current.play(z),I(!0),rn()}})().catch(z=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",z),I(!1),ft()})},[e,rn,ft]);const Gr=f.useCallback(async(F,z)=>{if(!$.current||O.length===0)return;const fe=F??ge.current;q.current=fe,ge.current=fe,$.current.stop(),$.current.seek(fe),ft();const ke=j.getContext().currentTime;K.current=ke,Re.current=fe,ze.current=z!==void 0?fe+z:null,he.current||(await $.current.init(),he.current=!0);const Oe=z!==void 0?fe+z:void 0;try{$.current.play(fe,Oe)}catch(Be){console.warn("[waveform-playlist] Playback failed to start:",Be),ft();return}I(!0),rn()},[O.length,rn,ft]),Ii=f.useCallback(()=>{if(!$.current)return;const F=Cn();$.current.pause(),I(!1),ft(),ge.current=F,P(F)},[ft,Cn]),Ai=f.useCallback(()=>{$.current&&($.current.stop(),I(!1),ft(),ge.current=q.current,P(q.current),Ft(null))},[ft,Ft]),Mi=f.useCallback(F=>{const z=Math.max(0,Math.min(F,A));ge.current=z,P(z),E&&$.current&&Gr(z)},[A,E,Gr]),$i=f.useCallback((F,z)=>{const fe=Le.current[F]?.id;if(!fe)return;const V=[...B];V[F]={...V[F],muted:z},se(V),$.current&&$.current.setTrackMute(fe,z)},[B]),Ti=f.useCallback((F,z)=>{const fe=Le.current[F]?.id;if(!fe)return;const V=[...B];V[F]={...V[F],soloed:z},se(V),$.current&&$.current.setTrackSolo(fe,z)},[B]),Di=f.useCallback((F,z)=>{const fe=Le.current[F]?.id;if(!fe)return;const V=[...B];V[F]={...V[F],volume:z},se(V),$.current&&$.current.setTrackVolume(fe,z)},[B]),Ri=f.useCallback((F,z)=>{const fe=Le.current[F]?.id;if(!fe)return;const V=[...B];V[F]={...V[F],pan:z},se(V),$.current&&$.current.setTrackPan(fe,z)},[B]),Pi=f.useCallback((F,z)=>{oe(F,z),ge.current=F,P(F),E&&$.current&&($.current.stop(),$.current.seek(F),$.current.play(F))},[E,oe]),Wi=f.useCallback(F=>{xe.current=F},[]),Ks=f.useRef(h);Ks.current=h;const Fi=f.useCallback(F=>{const z=typeof F=="function"?F(k.current):F;if(!Ks.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}Ks.current(z)},[]),Oi=O[0]?.sampleRate||44100,qs=t?30:0,Bi=e.length*r+qs,uf=f.useMemo(()=>({isPlaying:E,currentTime:T,currentTimeRef:ge,playbackStartTimeRef:K,audioStartPositionRef:Re,getPlaybackTime:Cn}),[E,T,ge,K,Re,Cn]),df=f.useMemo(()=>({continuousPlay:ae,linkEndpoints:ye,annotationsEditable:H,isAutomaticScroll:ie,isLoopEnabled:Pt,annotations:x,activeAnnotationId:S,selectionStart:Qe,selectionEnd:dt,selectedTrackId:yi,loopStart:Wt,loopEnd:tn}),[ae,ye,H,ie,Pt,x,S,Qe,dt,yi,Wt,tn]),Vi=f.useCallback(F=>{ge.current=F,P(F)},[ge]),Li=f.useCallback(F=>{ee(F)},[]),ff=f.useMemo(()=>({play:Gr,pause:Ii,stop:Ai,seekTo:Mi,setCurrentTime:Vi,setTrackMute:$i,setTrackSolo:Ti,setTrackVolume:Di,setTrackPan:Ri,setSelection:Pi,setSelectedTrackId:bi,setTimeFormat:ne,formatTime:be,zoomIn:Ee.zoomIn,zoomOut:Ee.zoomOut,setMasterVolume:te,setAutomaticScroll:Li,setScrollContainer:Wi,scrollContainerRef:xe,setContinuousPlay:ki,setLinkEndpoints:De,setAnnotationsEditable:Z,setAnnotations:Fi,setActiveAnnotationId:Ft,setLoopEnabled:nn,setLoopRegion:Mt,setLoopRegionFromSelection:Si,clearLoopRegion:Kn}),[Gr,Ii,Ai,Mi,Vi,$i,Ti,Di,Ri,Pi,bi,ne,be,Ee.zoomIn,Ee.zoomOut,te,Li,Wi,xe,ki,De,Z,Fi,Ft,nn,Mt,Si,Kn]),hf=f.useMemo(()=>({duration:A,audioBuffers:O,peaksDataArray:U,trackStates:B,tracks:e,sampleRate:Oi,waveHeight:r,timeScaleHeight:qs,minimumPlaylistHeight:Bi,controls:l,playoutRef:$,samplesPerPixel:je,timeFormat:Ke,masterVolume:G,canZoomIn:Ee.canZoomIn,canZoomOut:Ee.canZoomOut,barWidth:g,barGap:w,progressBarWidth:_,isReady:de,mono:n,isDraggingRef:le}),[A,O,U,B,e,Oi,r,qs,Bi,l,$,je,Ke,G,Ee.canZoomIn,Ee.canZoomOut,g,w,_,de,n,le]),pf={...pd,...i};return C.jsx(R.ThemeProvider,{theme:pf,children:C.jsx(Fd.Provider,{value:uf,children:C.jsx(Od.Provider,{value:df,children:C.jsx(Bd.Provider,{value:ff,children:C.jsx(Vd.Provider,{value:hf,children:b})})})})})},ct=()=>{const e=f.useContext(Fd);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},ut=()=>{const e=f.useContext(Od);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Te=()=>{const e=f.useContext(Bd);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},vt=()=>{const e=f.useContext(Vd);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var gv=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}},vv=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 gv({...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 Ld=f.createContext(null),zd=f.createContext(null),jd=f.createContext(null),Zd=f.createContext(null),yv=({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:d=0,progressBarWidth:u,onAnnotationsChange:p,onReady:h,children:g})=>{const w=u??c+d,[v,m]=f.useState(!1),[b,_]=f.useState(0),[y,x]=f.useState(0),[k,S]=f.useState([]),[M,E]=f.useState(s),I=f.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]),T=f.useRef(I);T.current=I;const[P,A]=f.useState(null),[W,O]=f.useState(l?.isContinuousPlay??!1),[Y]=f.useState(t),[U,J]=f.useState(a),B=f.useRef(null),se=f.useRef(0),ie=f.useRef(W),ee=f.useRef(null),ae=f.useRef(null),me=f.useRef(a),ye=f.useRef(t),{startAnimationFrameLoop:De,stopAnimationFrameLoop:H}=Wd();f.useEffect(()=>{ie.current=W},[W]),f.useEffect(()=>{me.current=U},[U]);const Z=f.useCallback(X=>{ee.current=X,A(X)},[]),de=f.useCallback(X=>{ie.current=X,O(X)},[]),N=f.useCallback(X=>{ae.current=X},[]),$=e.waveformData.sample_rate;f.useEffect(()=>{const X=new vv({playbackRate:s});X.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const le=X.getTrack(X.track?.id??"");return le&&le.setOnTimeUpdateCallback(Fe=>{se.current=Fe}),X.setOnPlaybackComplete(()=>{H(),m(!1),Z(null),se.current=0,_(0)}),B.current=X,x(e.waveformData.duration),h?.(),()=>{H(),X.dispose()}},[e.source,e.waveformData,e.name,s,h,H,Z]),f.useEffect(()=>{const X=O0(e.waveformData,Y,0,0,Math.ceil(e.waveformData.duration*$)),le={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*$)};S([[le]])},[e.waveformData,e.name,Y,$]);const he=f.useCallback(()=>{const X=()=>{const le=B.current?.getCurrentTime()??0;se.current=le;const Fe=T.current;if(Fe.length>0){const Ke=Fe.find(ne=>le>=ne.start&&le<ne.end);if(ie.current)Ke&&Ke.id!==ee.current?Z(Ke.id):!Ke&&ee.current!==null&&Z(null);else if(ee.current){const ne=Fe.find(be=>be.id===ee.current);if(ne&&le>=ne.end){B.current?.stop(),m(!1);return}}else Ke&&Z(Ke.id)}if(me.current&&ae.current){const Ke=ae.current,ne=le*$/ye.current,be=Ke.clientWidth,Ee=i.show?i.width:0,je=ne+Ee,bt=Math.max(0,je-be/2);Ke.scrollLeft=bt}De(X)};De(X)},[Z,$,i,De]),We=H,q=f.useCallback(X=>{if(!B.current)return;const le=X??se.current;B.current.play(void 0,le),m(!0),he()},[he]),ge=f.useCallback(()=>{B.current&&(B.current.pause(),m(!1),We(),_(B.current.getCurrentTime()))},[We]),Le=f.useCallback(()=>{B.current&&(B.current.stop(),m(!1),We(),se.current=0,_(0),Z(null))},[We,Z]),Ne=f.useCallback(X=>{const le=Math.max(0,Math.min(X,y));se.current=le,_(le),B.current&&B.current.seekTo(le)},[y]),K=f.useCallback(X=>{const le=Math.max(.5,Math.min(2,X));E(le),B.current&&B.current.setPlaybackRate(le)},[]),Re=r?30:0,ze=f.useMemo(()=>({isPlaying:v,currentTime:b,currentTimeRef:se}),[v,b]),xe=f.useMemo(()=>({continuousPlay:W,annotations:I,activeAnnotationId:P,playbackRate:M,isAutomaticScroll:U}),[W,I,P,M,U]),Xe=f.useRef(p);Xe.current=p;const Ue=f.useCallback(X=>{const le=typeof X=="function"?X(T.current):X;if(!Xe.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}Xe.current(le)},[]),at=f.useMemo(()=>({play:q,pause:ge,stop:Le,seekTo:Ne,setPlaybackRate:K,setContinuousPlay:de,setAnnotations:Ue,setActiveAnnotationId:Z,setAutomaticScroll:X=>{J(X)},setScrollContainer:N,scrollContainerRef:ae}),[q,ge,Le,Ne,K,de,Ue,Z,N]),yt=f.useMemo(()=>({duration:y,peaksDataArray:k,sampleRate:$,waveHeight:n,timeScaleHeight:Re,samplesPerPixel:Y,playoutRef:B,controls:i,barWidth:c,barGap:d,progressBarWidth:w}),[y,k,$,n,Re,Y,i,c,d,w]),At={...pd,...o};return C.jsx(R.ThemeProvider,{theme:At,children:C.jsx(Ld.Provider,{value:ze,children:C.jsx(zd.Provider,{value:xe,children:C.jsx(jd.Provider,{value:at,children:C.jsx(Zd.Provider,{value:yt,children:g})})})})})},Zs=()=>{const e=f.useContext(Ld);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},Hs=()=>{const e=f.useContext(zd);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},hi=()=>{const e=f.useContext(jd);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},Ns=()=>{const e=f.useContext(Zd);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},bv=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=ct(),{selectionStart:r,selectionEnd:s,isLoopEnabled:a}=ut(),{play:o}=Te(),i=async()=>{if(r!==s&&s>r&&!a){const c=s-r;await o(r,c)}else await o(n.current??0)};return C.jsx(St,{onClick:i,disabled:t,className:e,children:"Play"})},wv=({className:e})=>{const{isPlaying:t}=ct(),{pause:n}=Te();return C.jsx(St,{onClick:n,disabled:!t,className:e,children:"Pause"})},_v=({className:e})=>{const{isPlaying:t}=ct(),{stop:n}=Te();return C.jsx(St,{onClick:n,disabled:!t,className:e,children:"Stop"})},xv=({className:e})=>{const{isPlaying:t}=ct(),{play:n,setCurrentTime:r}=Te(),s=()=>{r(0),t&&n(0)};return C.jsx(St,{onClick:s,className:e,children:"Rewind"})},Cv=({className:e})=>{const{isPlaying:t}=ct(),{play:n,setCurrentTime:r}=Te(),{duration:s}=vt(),a=()=>{r(s),t&&n(s)};return C.jsx(St,{onClick:a,className:e,children:"Fast Forward"})},kv=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ct(),{play:s,setCurrentTime:a}=Te(),o=()=>{const i=Math.max(0,(n.current??0)-e);a(i),r&&s(i)};return C.jsx(St,{onClick:o,className:t,children:"Skip Backward"})},Sv=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ct(),{play:s,setCurrentTime:a}=Te(),{duration:o}=vt(),i=()=>{const l=Math.min(o,(n.current??0)+e);a(l),r&&s(l)};return C.jsx(St,{onClick:i,className:t,children:"Skip Forward"})},Ev=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=ut(),{setLoopEnabled:s,setLoopRegion:a}=Te(),{duration:o}=vt(),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 C.jsx(St,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},Iv=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=ut(),{setLoopRegionFromSelection:a,clearLoopRegion:o}=Te(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?o():a()};return C.jsx(St,{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"})},Av=({className:e,disabled:t})=>{const{zoomIn:n}=Te(),{canZoomIn:r}=vt();return C.jsx(St,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},Mv=({className:e,disabled:t})=>{const{zoomOut:n}=Te(),{canZoomOut:r}=vt();return C.jsx(St,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},$v=({className:e})=>{const{masterVolume:t}=vt(),{setMasterVolume:n}=Te();return C.jsx(wg,{volume:t,onChange:n,className:e})},Tv=({className:e})=>{const{timeFormat:t}=vt(),{setTimeFormat:n}=Te();return C.jsx(n0,{value:t,onChange:n,className:e})},Dv=R.span`
|
|
1010
|
+
`;let pv=0;function mv(){let e;try{const r=new Blob([hv],{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=mt.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(++pv);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 gv(e,t){const[n,r]=f.useState(()=>new Map),[s,a]=f.useState(!1),o=f.useRef(null),i=f.useRef(new Set),l=f.useRef(0),c=f.useCallback(()=>(o.current||(o.current=mv()),o.current),[]);return f.useEffect(()=>{let d=!1;const u=i.current,p=[];for(const w of e)for(const v of w.clips)v.audioBuffer&&!v.waveformData&&!u.has(v.id)&&p.push({clipId:v.id,audioBuffer:v.audioBuffer});if(p.length===0)return;const h=new Set;for(const{clipId:w}of p)u.add(w),h.add(w);l.current+=p.length,a(!0);const g=c();for(const{clipId:w,audioBuffer:v}of p){const m=[];for(let b=0;b<v.numberOfChannels;b++)m.push(v.getChannelData(b).slice().buffer);g.generate({id:w,channels:m,length:v.length,sampleRate:v.sampleRate,scale:t,bits:16,splitChannels:!0}).then(b=>{d||(r(_=>{const y=new Map(_);return y.set(w,b),y}),l.current--,l.current<=0&&(l.current=0,a(!1)))}).catch(b=>{d||(console.warn("[waveform-playlist] Worker peak generation failed:",b),u.delete(w),l.current--,l.current<=0&&(l.current=0,a(!1)))})}return()=>{d=!0;for(const w of h)u.delete(w)}},[e,t,c]),f.useEffect(()=>()=>{o.current?.terminate(),o.current=null},[]),{cache:n,isGenerating:s}}function Ja(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 vv(e,t,n){const r=Ja(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 yv(){const[e,t]=f.useState([]),[n,r]=f.useState(0),[s,a]=f.useState([]),o=f.useRef(!1),i=f.useRef(new Set),l=f.useRef(new Map);f.useEffect(()=>{const u=l.current;return()=>{o.current=!0;for(const p of u.values())p.abort();u.clear()}},[]);const c=f.useCallback(u=>{if(u.length===0)return;const p=Rf(),h=u.map(g=>({track:Zl({name:`${Ja(g)} (loading...)`,clips:[]}),source:g}));t(g=>[...g,...h.map(w=>w.track)]),r(g=>g+u.length);for(const{track:g,source:w}of h){i.current.add(g.id);const v=new AbortController;l.current.set(g.id,v),(async()=>{try{const{audioBuffer:m,name:b}=await vv(w,p,v.signal),_=jl({audioBuffer:m,startTime:0,duration:m.duration,offset:0,name:b});!o.current&&i.current.has(g.id)&&t(y=>y.map(x=>x.id===g.id?{...x,name:b,clips:[_]}:x))}catch(m){if(m instanceof DOMException&&m.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",m),!o.current&&i.current.has(g.id)&&(t(b=>b.filter(_=>_.id!==g.id)),a(b=>[...b,{name:Ja(w),error:m instanceof Error?m:new Error(String(m))}]))}finally{l.current.delete(g.id),!o.current&&i.current.delete(g.id)&&r(m=>m-1)}})()}},[]),d=f.useCallback(u=>{t(h=>h.filter(g=>g.id!==u));const p=l.current.get(u);p&&(p.abort(),l.current.delete(u)),i.current.delete(u)&&r(h=>h-1)},[]);return{tracks:e,addTracks:c,removeTrack:d,loadingCount:n,isLoading:n>0,errors:s}}const Od=f.createContext(null),Bd=f.createContext(null),Vd=f.createContext(null),Ld=f.createContext(null),bv=({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:d,onReady:u,onAnnotationUpdate:p,onAnnotationsChange:h,barWidth:g=1,barGap:w=0,progressBarWidth:v,onTracksChange:m,children:b})=>{const _=v??g+w,y=f.useMemo(()=>a,[a?.join(",")]),x=f.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const W=c.annotations[0];if(typeof W.start!="number"||typeof W.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof W.start),[]}return c.annotations},[c?.annotations]),k=f.useRef(x);k.current=x;const[S,I]=f.useState(null),[E,M]=f.useState(!1),[T,P]=f.useState(0),[A,F]=f.useState(0),[O,H]=f.useState([]),[K,ne]=f.useState([]),[B,re]=f.useState([]),[se,ae]=f.useState(o),[ie,me]=f.useState(c?.isContinuousPlay??!1),[ye,De]=f.useState(c?.linkEndpoints??!1),[X,Z]=f.useState(c?.editable??!1),[de,G]=f.useState(!1),$=f.useRef(null),he=f.useRef(!1),We=f.useRef(!1);We.current=E;const q=f.useRef(0),ge=f.useRef(0),Le=f.useRef(e),Ne=f.useRef(B),U=f.useRef(0),Re=f.useRef(0),ze=f.useRef(null),xe=f.useRef(null),Xe=f.useRef(!1),Ue=f.useRef(c?.isContinuousPlay??!1),at=f.useRef(null),yt=f.useRef(null),At=f.useRef(0),N=f.useRef(!1),le=f.useRef(!1),Fe=f.useRef(s),{timeFormat:Ke,setTimeFormat:ee,formatTime:be}=Td(),Ee=Dd({engineRef:$,initialSamplesPerPixel:s}),{samplesPerPixel:je,onEngineState:bt}=Ee,L=Rd({engineRef:$,initialVolume:1}),{masterVolume:Y,setMasterVolume:Q,masterVolumeRef:Ce,onEngineState:ve}=L,{selectionStart:Qe,selectionEnd:dt,setSelection:oe,selectionStartRef:Ze,selectionEndRef:et,onEngineState:en}=j0({engineRef:$}),{isLoopEnabled:Pt,loopStart:Wt,loopEnd:tn,setLoopEnabled:nn,setLoopRegion:Mt,clearLoopRegion:Kn,isLoopEnabledRef:Zr,loopStartRef:Hr,loopEndRef:gi,onEngineState:vi}=Z0({engineRef:$}),{selectedTrackId:yi,setSelectedTrackId:bi,onEngineState:wi,selectedTrackIdRef:_i}=H0({engineRef:$}),{animationFrameRef:xi,startAnimationFrameLoop:Ys,stopAnimationFrameLoop:Nr}=Fd(),uf=f.useMemo(()=>Math.min(...y??[256,512,1024,2048,4096,8192]),[y]),{cache:Ci}=gv(e,uf),ki=f.useCallback(W=>{Ue.current=W,me(W)},[]),Ft=f.useCallback(W=>{at.current=W,I(W)},[]),Si=f.useCallback(()=>{const W=Ze.current??0,z=et.current??0;W!==z&&z>W&&Mt(W,z)},[Mt,Ze,et]);f.useEffect(()=>{Xe.current=se},[se]),f.useEffect(()=>{Ne.current=B},[B]),Le.current=e;const Us=e===yt.current;N.current=Us||le.current,f.useEffect(()=>{if(!xe.current||!O.length)return;const W=xe.current,z=Fe.current,fe=je;if(z===fe)return;const V=l.show?l.width:0,ke=W.clientWidth,Be=W.scrollLeft+ke/2-V,kn=O[0].sampleRate,Sn=Be*z/kn*kn/fe,Js=Math.max(0,Sn+V-ke/2);W.scrollLeft=Js,Fe.current=fe},[je,O,l]);const Xr=f.useRef(null);f.useEffect(()=>{if(Us||le.current){Us&&(yt.current=null);let V=0;e.forEach(ke=>{ke.clips.forEach(Oe=>{const Be=(Oe.startSample+Oe.durationSamples)/Oe.sampleRate;V=Math.max(V,Be)})}),F(V);return}if(G(!1),e.length===0){H([]),F(0),re([]),ne([]),$.current&&($.current.dispose(),$.current=null);return}const W=We.current,z=ge.current;return $.current&&W&&($.current.stop(),Nr(),Xr.current={position:z}),(async()=>{try{const V=[];e.forEach(Ie=>{Ie.clips.length>0&&Ie.clips[0].audioBuffer&&V.push(Ie.clips[0].audioBuffer)});let ke=0;e.forEach(Ie=>{Ie.clips.forEach(ht=>{const Zt=ht.sampleRate,gf=(ht.startSample+ht.durationSamples)/Zt;ke=Math.max(ke,gf)})}),H(V),F(ke),re(Ie=>Ie.length===e.length?Ie.map((ht,Zt)=>({...ht,name:e[Zt].name})):e.map(ht=>({name:ht.name,muted:ht.muted,soloed:ht.soloed,volume:ht.volume,pan:ht.pan}))),$.current&&$.current.dispose(),At.current=0,yt.current=null,he.current=!1;const Oe=Pf({effects:d}),Be=new Lf({adapter:Oe,samplesPerPixel:Fe.current,zoomLevels:y});Be.setSelection(Ze.current??0,et.current??0),Be.setLoopRegion(Hr.current??0,gi.current??0),Zr.current&&Be.setLoopEnabled(!0),Be.setMasterVolume(Ce.current??1),_i.current&&Be.selectTrack(_i.current);const kn=Ne.current,Yr=e.map((Ie,ht)=>{const Zt=kn[ht];return{...Ie,volume:Zt?.volume??Ie.volume,muted:Zt?.muted??Ie.muted,soloed:Zt?.soloed??Ie.soloed,pan:Zt?.pan??Ie.pan}});let Sn=!0;Be.on("statechange",Ie=>{en(Ie),vi(Ie),wi(Ie),bt(Ie),ve(Ie),!Sn&&Ie.tracksVersion!==At.current&&(At.current=Ie.tracksVersion,yt.current=Ie.tracks,m?m(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."))}),Be.setTracks(Yr),Sn=!1,At.current=Be.getState().tracksVersion,$.current=Be,G(!0);const Js=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:ke}});window.dispatchEvent(Js),u?.()}catch(V){console.error("Error loading audio:",V)}})(),()=>{if(N.current){N.current=!1;return}Nr(),$.current&&$.current.dispose()}},[e,u,d,Nr,en,vi,wi,bt,ve,m,Ce,Ze,et,Hr,gi,Zr,y]),f.useEffect(()=>{if(e.length===0)return;const W=e.map(z=>z.clips.map(V=>{let ke;if(V.waveformData)try{ke=Dl(V.waveformData,je,n,V.offsetSamples,V.durationSamples)}catch(Oe){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",Oe)}if(!ke){const Oe=Ci.get(V.id);if(Oe)try{ke=Dl(Oe,je,n,V.offsetSamples,V.durationSamples)}catch(Be){console.warn("[waveform-playlist] Failed to extract peaks from cache:",Be)}}if(!ke){!V.audioBuffer&&!V.waveformData&&console.warn(`[waveform-playlist] Clip "${V.id}" has no audio data or waveform data`);const Oe=n?1:V.audioBuffer?.numberOfChannels??1;ke={length:0,data:Array.from({length:Oe},()=>new Int16Array(0)),bits:16}}return{clipId:V.id,trackName:z.name,peaks:ke,startSample:V.startSample,durationSamples:V.durationSamples,fadeIn:V.fadeIn,fadeOut:V.fadeOut}}));ne(W)},[e,je,n,Ci]);const Ei=f.useRef(!1),Cn=f.useCallback(()=>{if($.current)return $.current.getCurrentTime();Ei.current||(Ei.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const W=j.getContext().currentTime-(U.current??0);return(Re.current??0)+W},[]),rn=f.useCallback(()=>{const W=()=>{const z=Cn();ge.current=z;const fe=k.current;if(fe.length>0){const V=fe.find(ke=>z>=ke.start&&z<ke.end);if(Ue.current)V&&V.id!==at.current?Ft(V.id):!V&&at.current!==null&&Ft(null);else if(at.current){const ke=fe.find(Oe=>Oe.id===at.current);if(ke&&z>=ke.end){$.current&&$.current.stop(),M(!1),ge.current=q.current,P(q.current);return}}else V&&Ft(V.id)}if(Xe.current&&xe.current&&O.length>0){const V=xe.current,ke=O[0].sampleRate,Oe=z*ke/Fe.current,Be=V.clientWidth,kn=l.show?l.width:0,Yr=Oe+kn,Sn=Math.max(0,Yr-Be/2);V.scrollLeft=Sn}if(ze.current!==null&&z>=ze.current){$.current&&$.current.stop(),M(!1),ge.current=ze.current,P(ze.current),ze.current=null;return}if(z>=A){$.current&&$.current.stop(),M(!1),ge.current=q.current,P(q.current),Ft(null);return}Ys(W)};Ys(W)},[A,O,l.show,l.width,Ft,Ys,Cn]),ft=Nr;f.useEffect(()=>{(async()=>{if(E&&xi.current&&$.current)if(ie){const z=ge.current;$.current.stop(),ft();const V=j.getContext().currentTime;U.current=V,Re.current=z,$.current.play(z),rn()}else ft(),rn()})().catch(z=>{console.warn("[waveform-playlist] Failed to reschedule playback:",z),M(!1),ft()})},[ie,E,rn,ft,xi]),f.useEffect(()=>{(async()=>{if(Xr.current&&$.current){const{position:z}=Xr.current;Xr.current=null;const V=j.getContext().currentTime;U.current=V,Re.current=z,he.current||(await $.current.init(),he.current=!0),$.current.play(z),M(!0),rn()}})().catch(z=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",z),M(!1),ft()})},[e,rn,ft]);const Gr=f.useCallback(async(W,z)=>{if(!$.current||O.length===0)return;const fe=W??ge.current;q.current=fe,ge.current=fe,$.current.stop(),$.current.seek(fe),ft();const ke=j.getContext().currentTime;U.current=ke,Re.current=fe,ze.current=z!==void 0?fe+z:null,he.current||(await $.current.init(),he.current=!0);const Oe=z!==void 0?fe+z:void 0;try{$.current.play(fe,Oe)}catch(Be){console.warn("[waveform-playlist] Playback failed to start:",Be),ft();return}M(!0),rn()},[O.length,rn,ft]),Ii=f.useCallback(()=>{if(!$.current)return;const W=Cn();$.current.pause(),M(!1),ft(),ge.current=W,P(W)},[ft,Cn]),Ai=f.useCallback(()=>{$.current&&($.current.stop(),M(!1),ft(),ge.current=q.current,P(q.current),Ft(null))},[ft,Ft]),Mi=f.useCallback(W=>{const z=Math.max(0,Math.min(W,A));ge.current=z,P(z),E&&$.current&&Gr(z)},[A,E,Gr]),$i=f.useCallback((W,z)=>{const fe=Le.current[W]?.id;if(!fe)return;const V=[...B];V[W]={...V[W],muted:z},re(V),$.current&&$.current.setTrackMute(fe,z)},[B]),Ti=f.useCallback((W,z)=>{const fe=Le.current[W]?.id;if(!fe)return;const V=[...B];V[W]={...V[W],soloed:z},re(V),$.current&&$.current.setTrackSolo(fe,z)},[B]),Di=f.useCallback((W,z)=>{const fe=Le.current[W]?.id;if(!fe)return;const V=[...B];V[W]={...V[W],volume:z},re(V),$.current&&$.current.setTrackVolume(fe,z)},[B]),Ri=f.useCallback((W,z)=>{const fe=Le.current[W]?.id;if(!fe)return;const V=[...B];V[W]={...V[W],pan:z},re(V),$.current&&$.current.setTrackPan(fe,z)},[B]),Pi=f.useCallback((W,z)=>{oe(W,z),ge.current=W,P(W),E&&$.current&&($.current.stop(),$.current.seek(W),$.current.play(W))},[E,oe]),Wi=f.useCallback(W=>{xe.current=W},[]),Ks=f.useRef(h);Ks.current=h;const Fi=f.useCallback(W=>{const z=typeof W=="function"?W(k.current):W;if(!Ks.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}Ks.current(z)},[]),Oi=O[0]?.sampleRate||44100,qs=t?30:0,Bi=e.length*r+qs,df=f.useMemo(()=>({isPlaying:E,currentTime:T,currentTimeRef:ge,playbackStartTimeRef:U,audioStartPositionRef:Re,getPlaybackTime:Cn}),[E,T,ge,U,Re,Cn]),ff=f.useMemo(()=>({continuousPlay:ie,linkEndpoints:ye,annotationsEditable:X,isAutomaticScroll:se,isLoopEnabled:Pt,annotations:x,activeAnnotationId:S,selectionStart:Qe,selectionEnd:dt,selectedTrackId:yi,loopStart:Wt,loopEnd:tn}),[ie,ye,X,se,Pt,x,S,Qe,dt,yi,Wt,tn]),Vi=f.useCallback(W=>{ge.current=W,P(W)},[ge]),Li=f.useCallback(W=>{ae(W)},[]),hf=f.useMemo(()=>({play:Gr,pause:Ii,stop:Ai,seekTo:Mi,setCurrentTime:Vi,setTrackMute:$i,setTrackSolo:Ti,setTrackVolume:Di,setTrackPan:Ri,setSelection:Pi,setSelectedTrackId:bi,setTimeFormat:ee,formatTime:be,zoomIn:Ee.zoomIn,zoomOut:Ee.zoomOut,setMasterVolume:Q,setAutomaticScroll:Li,setScrollContainer:Wi,scrollContainerRef:xe,setContinuousPlay:ki,setLinkEndpoints:De,setAnnotationsEditable:Z,setAnnotations:Fi,setActiveAnnotationId:Ft,setLoopEnabled:nn,setLoopRegion:Mt,setLoopRegionFromSelection:Si,clearLoopRegion:Kn}),[Gr,Ii,Ai,Mi,Vi,$i,Ti,Di,Ri,Pi,bi,ee,be,Ee.zoomIn,Ee.zoomOut,Q,Li,Wi,xe,ki,De,Z,Fi,Ft,nn,Mt,Si,Kn]),pf=f.useMemo(()=>({duration:A,audioBuffers:O,peaksDataArray:K,trackStates:B,tracks:e,sampleRate:Oi,waveHeight:r,timeScaleHeight:qs,minimumPlaylistHeight:Bi,controls:l,playoutRef:$,samplesPerPixel:je,timeFormat:Ke,masterVolume:Y,canZoomIn:Ee.canZoomIn,canZoomOut:Ee.canZoomOut,barWidth:g,barGap:w,progressBarWidth:_,isReady:de,mono:n,isDraggingRef:le}),[A,O,K,B,e,Oi,r,qs,Bi,l,$,je,Ke,Y,Ee.canZoomIn,Ee.canZoomOut,g,w,_,de,n,le]),mf={...pd,...i};return C.jsx(R.ThemeProvider,{theme:mf,children:C.jsx(Od.Provider,{value:df,children:C.jsx(Bd.Provider,{value:ff,children:C.jsx(Vd.Provider,{value:hf,children:C.jsx(Ld.Provider,{value:pf,children:b})})})})})},ct=()=>{const e=f.useContext(Od);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},ut=()=>{const e=f.useContext(Bd);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Te=()=>{const e=f.useContext(Vd);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},vt=()=>{const e=f.useContext(Ld);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var wv=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}},_v=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 wv({...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 zd=f.createContext(null),jd=f.createContext(null),Zd=f.createContext(null),Hd=f.createContext(null),xv=({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:d=0,progressBarWidth:u,onAnnotationsChange:p,onReady:h,children:g})=>{const w=u??c+d,[v,m]=f.useState(!1),[b,_]=f.useState(0),[y,x]=f.useState(0),[k,S]=f.useState([]),[I,E]=f.useState(s),M=f.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const N=l.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 l.annotations},[l?.annotations]),T=f.useRef(M);T.current=M;const[P,A]=f.useState(null),[F,O]=f.useState(l?.isContinuousPlay??!1),[H]=f.useState(t),[K,ne]=f.useState(a),B=f.useRef(null),re=f.useRef(0),se=f.useRef(F),ae=f.useRef(null),ie=f.useRef(null),me=f.useRef(a),ye=f.useRef(t),{startAnimationFrameLoop:De,stopAnimationFrameLoop:X}=Fd();f.useEffect(()=>{se.current=F},[F]),f.useEffect(()=>{me.current=K},[K]);const Z=f.useCallback(N=>{ae.current=N,A(N)},[]),de=f.useCallback(N=>{se.current=N,O(N)},[]),G=f.useCallback(N=>{ie.current=N},[]),$=e.waveformData.sample_rate;f.useEffect(()=>{const N=new _v({playbackRate:s});N.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const le=N.getTrack(N.track?.id??"");return le&&le.setOnTimeUpdateCallback(Fe=>{re.current=Fe}),N.setOnPlaybackComplete(()=>{X(),m(!1),Z(null),re.current=0,_(0)}),B.current=N,x(e.waveformData.duration),h?.(),()=>{X(),N.dispose()}},[e.source,e.waveformData,e.name,s,h,X,Z]),f.useEffect(()=>{try{const N=z0(e.waveformData,H,0,0,Math.ceil(e.waveformData.duration*$)),le={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:N.length,data:[N.data],bits:N.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*$)};S([[le]])}catch(N){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",N)}},[e.waveformData,e.name,H,$]);const he=f.useCallback(()=>{const N=()=>{const le=B.current?.getCurrentTime()??0;re.current=le;const Fe=T.current;if(Fe.length>0){const Ke=Fe.find(ee=>le>=ee.start&&le<ee.end);if(se.current)Ke&&Ke.id!==ae.current?Z(Ke.id):!Ke&&ae.current!==null&&Z(null);else if(ae.current){const ee=Fe.find(be=>be.id===ae.current);if(ee&&le>=ee.end){B.current?.stop(),m(!1);return}}else Ke&&Z(Ke.id)}if(me.current&&ie.current){const Ke=ie.current,ee=le*$/ye.current,be=Ke.clientWidth,Ee=i.show?i.width:0,je=ee+Ee,bt=Math.max(0,je-be/2);Ke.scrollLeft=bt}De(N)};De(N)},[Z,$,i,De]),We=X,q=f.useCallback(N=>{if(!B.current)return;const le=N??re.current;B.current.play(void 0,le),m(!0),he()},[he]),ge=f.useCallback(()=>{B.current&&(B.current.pause(),m(!1),We(),_(B.current.getCurrentTime()))},[We]),Le=f.useCallback(()=>{B.current&&(B.current.stop(),m(!1),We(),re.current=0,_(0),Z(null))},[We,Z]),Ne=f.useCallback(N=>{const le=Math.max(0,Math.min(N,y));re.current=le,_(le),B.current&&B.current.seekTo(le)},[y]),U=f.useCallback(N=>{const le=Math.max(.5,Math.min(2,N));E(le),B.current&&B.current.setPlaybackRate(le)},[]),Re=r?30:0,ze=f.useMemo(()=>({isPlaying:v,currentTime:b,currentTimeRef:re}),[v,b]),xe=f.useMemo(()=>({continuousPlay:F,annotations:M,activeAnnotationId:P,playbackRate:I,isAutomaticScroll:K}),[F,M,P,I,K]),Xe=f.useRef(p);Xe.current=p;const Ue=f.useCallback(N=>{const le=typeof N=="function"?N(T.current):N;if(!Xe.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}Xe.current(le)},[]),at=f.useMemo(()=>({play:q,pause:ge,stop:Le,seekTo:Ne,setPlaybackRate:U,setContinuousPlay:de,setAnnotations:Ue,setActiveAnnotationId:Z,setAutomaticScroll:N=>{ne(N)},setScrollContainer:G,scrollContainerRef:ie}),[q,ge,Le,Ne,U,de,Ue,Z,G]),yt=f.useMemo(()=>({duration:y,peaksDataArray:k,sampleRate:$,waveHeight:n,timeScaleHeight:Re,samplesPerPixel:H,playoutRef:B,controls:i,barWidth:c,barGap:d,progressBarWidth:w}),[y,k,$,n,Re,H,i,c,d,w]),At={...pd,...o};return C.jsx(R.ThemeProvider,{theme:At,children:C.jsx(zd.Provider,{value:ze,children:C.jsx(jd.Provider,{value:xe,children:C.jsx(Zd.Provider,{value:at,children:C.jsx(Hd.Provider,{value:yt,children:g})})})})})},Zs=()=>{const e=f.useContext(zd);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},Hs=()=>{const e=f.useContext(jd);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},hi=()=>{const e=f.useContext(Zd);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},Ns=()=>{const e=f.useContext(Hd);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},Cv=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=ct(),{selectionStart:r,selectionEnd:s,isLoopEnabled:a}=ut(),{play:o}=Te(),i=async()=>{if(r!==s&&s>r&&!a){const c=s-r;await o(r,c)}else await o(n.current??0)};return C.jsx(St,{onClick:i,disabled:t,className:e,children:"Play"})},kv=({className:e})=>{const{isPlaying:t}=ct(),{pause:n}=Te();return C.jsx(St,{onClick:n,disabled:!t,className:e,children:"Pause"})},Sv=({className:e})=>{const{isPlaying:t}=ct(),{stop:n}=Te();return C.jsx(St,{onClick:n,disabled:!t,className:e,children:"Stop"})},Ev=({className:e})=>{const{isPlaying:t}=ct(),{play:n,setCurrentTime:r}=Te(),s=()=>{r(0),t&&n(0)};return C.jsx(St,{onClick:s,className:e,children:"Rewind"})},Iv=({className:e})=>{const{isPlaying:t}=ct(),{play:n,setCurrentTime:r}=Te(),{duration:s}=vt(),a=()=>{r(s),t&&n(s)};return C.jsx(St,{onClick:a,className:e,children:"Fast Forward"})},Av=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ct(),{play:s,setCurrentTime:a}=Te(),o=()=>{const i=Math.max(0,(n.current??0)-e);a(i),r&&s(i)};return C.jsx(St,{onClick:o,className:t,children:"Skip Backward"})},Mv=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ct(),{play:s,setCurrentTime:a}=Te(),{duration:o}=vt(),i=()=>{const l=Math.min(o,(n.current??0)+e);a(l),r&&s(l)};return C.jsx(St,{onClick:i,className:t,children:"Skip Forward"})},$v=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=ut(),{setLoopEnabled:s,setLoopRegion:a}=Te(),{duration:o}=vt(),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 C.jsx(St,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},Tv=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=ut(),{setLoopRegionFromSelection:a,clearLoopRegion:o}=Te(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?o():a()};return C.jsx(St,{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"})},Dv=({className:e,disabled:t})=>{const{zoomIn:n}=Te(),{canZoomIn:r}=vt();return C.jsx(St,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},Rv=({className:e,disabled:t})=>{const{zoomOut:n}=Te(),{canZoomOut:r}=vt();return C.jsx(St,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},Pv=({className:e})=>{const{masterVolume:t}=vt(),{setMasterVolume:n}=Te();return C.jsx(kg,{volume:t,onChange:n,className:e})},Wv=({className:e})=>{const{timeFormat:t}=vt(),{setTimeFormat:n}=Te();return C.jsx(o0,{value:t,onChange:n,className:e})},Fv=R.span`
|
|
1011
1011
|
font-family: 'Courier New', Monaco, monospace;
|
|
1012
1012
|
font-size: 1rem;
|
|
1013
1013
|
font-weight: 600;
|
|
1014
1014
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
1015
1015
|
user-select: none;
|
|
1016
|
-
`,
|
|
1016
|
+
`,Ov=({className:e})=>{const t=f.useRef(null),n=f.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=ct(),{timeFormat:o}=vt();return f.useEffect(()=>{const i=()=>{if(t.current){const l=r?a():s.current??0;t.current.textContent=Fn(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]),f.useEffect(()=>{!r&&t.current&&(t.current.textContent=Fn(s.current??0,o))}),C.jsx(Fv,{ref:t,className:e,"aria-label":"Audio position",children:Fn(s.current??0,o)})},Bv=({className:e})=>{const{selectionStart:t,selectionEnd:n}=ut(),{setSelection:r}=Te();return C.jsx(Wg,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},Vv=({className:e})=>{const{isAutomaticScroll:t}=ut(),{setAutomaticScroll:n}=Te();return C.jsx(Jm,{checked:t,onChange:n,className:e})},Xs=f.createContext(null),Lv=Xs.Provider;function xn(){const e=f.useContext(Xs);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 zv=({className:e})=>{const{ContinuousPlayCheckbox:t}=xn(),{continuousPlay:n}=ut(),{setContinuousPlay:r}=Te();return C.jsx(t,{checked:n,onChange:r,className:e})},jv=({className:e})=>{const{LinkEndpointsCheckbox:t}=xn(),{linkEndpoints:n}=ut(),{setLinkEndpoints:r}=Te();return C.jsx(t,{checked:n,onChange:r,className:e})},Zv=({className:e})=>{const{EditableCheckbox:t}=xn(),{annotationsEditable:n}=ut(),{setAnnotationsEditable:r}=Te();return C.jsx(t,{checked:n,onChange:r,className:e})},Hv=({filename:e,className:t})=>{const{DownloadAnnotationsButton:n}=xn(),{annotations:r}=ut();return C.jsx(n,{annotations:r,filename:e,className:t})},Nv=({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:d})=>{const{tracks:u,trackStates:p}=vt(),{exportWav:h,isExporting:g,progress:w}=Wd(),v=async()=>{try{const b=await h(u,p,{filename:t,mode:n,trackIndex:r,bitDepth:s,applyEffects:a,effectsFunction:o,createOfflineTrackEffects:i,autoDownload:!0});c?.(b.blob)}catch(b){d?.(b instanceof Error?b:new Error("Export failed"))}},m=g?`Exporting ${Math.round(w*100)}%`:e;return C.jsx(St,{onClick:v,disabled:g||u.length===0,className:l,children:m})},Xv=R.div.attrs(e=>({style:{width:`${e.$width}px`,background:e.$color}}))`
|
|
1017
1017
|
position: absolute;
|
|
1018
1018
|
top: 0;
|
|
1019
1019
|
left: 0;
|
|
@@ -1021,7 +1021,7 @@ self.onmessage = function(e) {
|
|
|
1021
1021
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
1022
1022
|
pointer-events: none;
|
|
1023
1023
|
will-change: transform;
|
|
1024
|
-
`,
|
|
1024
|
+
`,Gv=({color:e="#ff0000",controlsOffset:t=0})=>{const n=f.useRef(null),r=f.useRef(null),{isPlaying:s,currentTimeRef:a,getPlaybackTime:o}=ct(),{samplesPerPixel:i,sampleRate:l,progressBarWidth:c}=vt();return f.useEffect(()=>{const d=()=>{if(n.current){const p=(s?o():a.current??0)*l/i+t;n.current.style.transform=`translate3d(${p}px, 0, 0)`}s&&(r.current=requestAnimationFrame(d))};return s?r.current=requestAnimationFrame(d):d(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[s,l,i,t,a,o]),f.useEffect(()=>{if(!s&&n.current){const u=(a.current??0)*l/i+t;n.current.style.transform=`translate3d(${u}px, 0, 0)`}}),C.jsx(Xv,{ref:n,$color:e,$width:c,"data-playhead":!0})},Yv=R.div`
|
|
1025
1025
|
position: relative;
|
|
1026
1026
|
`,fa=R.div.attrs(e=>({style:{top:`${e.$top}px`,width:`${e.$width}px`,height:`${e.$height}px`,background:e.$color}}))`
|
|
1027
1027
|
position: absolute;
|
|
@@ -1031,7 +1031,7 @@ self.onmessage = function(e) {
|
|
|
1031
1031
|
transform: translateZ(0);
|
|
1032
1032
|
backface-visibility: hidden;
|
|
1033
1033
|
will-change: transform;
|
|
1034
|
-
`,
|
|
1034
|
+
`,Uv=R.div.attrs(e=>({style:{top:`${e.$top}px`,height:`${e.$height}px`,width:`${e.$width}px`,background:e.$color,transform:"scaleX(0)"}}))`
|
|
1035
1035
|
position: absolute;
|
|
1036
1036
|
left: 0;
|
|
1037
1037
|
pointer-events: none;
|
|
@@ -1039,10 +1039,10 @@ self.onmessage = function(e) {
|
|
|
1039
1039
|
transform-origin: left;
|
|
1040
1040
|
/* scaleX changes are composite-only (GPU) — no layout reflow per frame */
|
|
1041
1041
|
will-change: transform;
|
|
1042
|
-
`,
|
|
1042
|
+
`,Kv=R.div`
|
|
1043
1043
|
position: relative;
|
|
1044
1044
|
z-index: 2;
|
|
1045
|
-
`,Wl=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=f.useRef(null),s=f.useRef(null),a=Lr(),{waveHeight:o}=zs(),{isPlaying:i,currentTimeRef:l,getPlaybackTime:c}=ct(),{samplesPerPixel:d,sampleRate:u}=vt(),p=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";f.useEffect(()=>{const k=()=>{if(r.current){const M=(i?c():l.current??0)*u,E=e+t;let I=0;M<=e?I=0:M>=E?I=1:I=(M-e)/t,r.current.style.transform=`scaleX(${I})`}i&&(s.current=requestAnimationFrame(k))};return i?s.current=requestAnimationFrame(k):k(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,u,d,e,t,n.length,l,c]),f.useEffect(()=>{if(!i&&r.current){const S=(l.current??0)*u,M=e+t;let E=0;S<=e?E=0:S>=M?E=1:E=(S-e)/t,r.current.style.transform=`scaleX(${E})`}});const h=a?.waveformDrawMode||"inverted";let g;h==="inverted"?g=n.isSelected&&a?a.selectedWaveFillColor:a?.waveFillColor||"white":g=n.isSelected&&a?a.selectedWaveOutlineColor:a?.waveOutlineColor||"grey";const w=n.renderMode==="spectrogram"||n.renderMode==="both",v=n.renderMode==="both",m=w?"#000":qt(g),b=Math.floor(o/2),_=o,y=n.index*o,x=qt(g);return C.jsxs(Hv,{children:[v?C.jsxs(C.Fragment,{children:[C.jsx(fa,{$color:"#000",$height:b,$top:y,$width:n.length}),C.jsx(fa,{$color:x,$height:b,$top:y+b,$width:n.length})]}):C.jsx(fa,{$color:m,$height:_,$top:y,$width:n.length}),C.jsx(Nv,{ref:r,$color:p,$height:_,$top:y,$width:n.length}),C.jsx(Xv,{children:C.jsx(Sd,{...n,transparentBackground:!0})})]})},pi=f.createContext(null),Gv=pi.Provider;function Yv(){const e=f.useContext(pi);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const Uv=60,Hd=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:a,showClipHeaders:o=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:d,recordingState:u})=>{const p=Lr(),{isPlaying:h,currentTimeRef:g,playbackStartTimeRef:w,audioStartPositionRef:v,getPlaybackTime:m}=ct(),{selectionStart:b,selectionEnd:_,annotations:y,activeAnnotationId:x,annotationsEditable:k,linkEndpoints:S,continuousPlay:M,selectedTrackId:E,loopStart:I,loopEnd:T,isLoopEnabled:P}=ut(),A=f.useContext(Xs),{setAnnotations:W,setActiveAnnotationId:O,setTrackMute:Y,setTrackSolo:U,setTrackVolume:J,setTrackPan:B,setSelection:se,play:ie,setScrollContainer:ee,setSelectedTrackId:ae,setCurrentTime:me,setLoopRegion:ye}=Te(),{peaksDataArray:De,trackStates:H,tracks:Z,duration:de,samplesPerPixel:N,sampleRate:$,waveHeight:he,timeScaleHeight:We,controls:q,barWidth:ge,barGap:Le,isReady:Ne}=vt(),K=f.useContext(pi),Re=f.useMemo(()=>{if(!K)return new Map;const L=new Map;return Z.forEach(G=>{if((K.trackSpectrogramOverrides.get(G.id)?.renderMode??G.renderMode??"waveform")==="waveform")return;const Ce=K.trackSpectrogramOverrides.get(G.id),ve=Ce?.colorMap??G.spectrogramColorMap??K.spectrogramColorMap??"viridis",Qe=Ce?.config??G.spectrogramConfig??K.spectrogramConfig;L.set(G.id,{colorLUT:K.getColorMap(ve),frequencyScaleFn:K.getFrequencyScale(Qe?.frequencyScale??"mel"),config:Qe})}),L},[Z,K]),ze=f.useMemo(()=>{if(K?.spectrogramWorkerApi)return{registerCanvas:K.spectrogramWorkerApi.registerCanvas.bind(K.spectrogramWorkerApi),unregisterCanvas:K.spectrogramWorkerApi.unregisterCanvas.bind(K.spectrogramWorkerApi)}},[K?.spectrogramWorkerApi]),[xe,Xe]=f.useState(null),[Ue,at]=f.useState(!1),yt=f.useRef(null),At=f.useCallback(L=>{yt.current=L,ee(L)},[ee]),X=Z.reduce((L,G)=>G.clips.reduce((te,Ce)=>{const ve=(Ce.startSample+Ce.durationSamples)/Ce.sampleRate;return Math.max(te,ve)},L),0);let le=X>0?X:de>0?de:Uv;if(u?.isRecording){const G=(u.startSample+u.durationSamples)/$;le=Math.max(le,G+10)}const Fe=Math.floor(le*$/N),Ke=async L=>{O(L.id);const G=M?void 0:L.end-L.start;try{await ie(L.start,G)}catch(te){console.error("waveform-playlist: Failed to start playback for annotation",L.id,te)}},ne=f.useCallback(L=>{if(L>=0&&L<Z.length){const G=Z[L];ae(G.id)}},[Z,ae]),be=L=>{const G=L.currentTarget.getBoundingClientRect(),te=q.show?q.width:0,ve=(L.clientX-G.left-te)*N/$,dt=L.clientY-G.top;let oe=0,Ze=-1;for(let et=0;et<De.length;et++){const en=De[et],Pt=en.length>0?Math.max(1,...en.map(Mt=>Mt.peaks.data.length)):1,nn=((K?.trackSpectrogramOverrides.get(Z[et]?.id)?.renderMode??Z[et]?.renderMode??"waveform")==="both"?Pt*2:Pt)*he+(o?22:0);if(dt>=oe&&dt<oe+nn){Ze=et;break}oe+=nn}Ze!==-1&&ne(Ze),at(!0),me(ve),se(ve,ve)},Ee=L=>{if(!Ue)return;const G=L.currentTarget.getBoundingClientRect(),te=q.show?q.width:0,ve=(L.clientX-G.left-te)*N/$,Qe=Math.min(b,ve),dt=Math.max(b,ve);se(Qe,dt)},je=L=>{if(!Ue)return;at(!1);const G=L.currentTarget.getBoundingClientRect(),te=q.show?q.width:0,ve=(L.clientX-G.left-te)*N/$,Qe=Math.min(b,ve),dt=Math.max(b,ve);Math.abs(dt-Qe)<.1?(me(Qe),h&&ie(Qe)):se(Qe,dt)};return Z.some(L=>L.clips.length>0)&&De.length===0?C.jsx("div",{className:a,children:"Loading waveform..."}):C.jsxs(kd,{children:[C.jsx(Vr.Provider,{value:{samplesPerPixel:N,sampleRate:$,zoomLevels:[N],waveHeight:he,timeScaleHeight:We,duration:le*1e3,controls:q,barWidth:ge,barGap:Le},children:C.jsx(li,{theme:p,backgroundColor:qt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Fe+(q.show?q.width:0),timescaleWidth:Fe,tracksWidth:Fe,controlsWidth:q.show?q.width:0,onTracksMouseDown:be,onTracksMouseMove:Ee,onTracksMouseUp:je,scrollContainerRef:At,isSelecting:Ue,"data-playlist-state":Ne?"ready":"loading",timescale:We>0?C.jsxs(C.Fragment,{children:[C.jsx(Ed,{renderTimestamp:t}),P&&C.jsx($g,{startPosition:Math.min(I,T)*$/N,endPosition:Math.max(I,T)*$/N,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:Fe,controlsOffset:q.show?q.width:0,onLoopRegionChange:(L,G)=>{const te=L*N/$,Ce=G*N/$;ye(te,Ce)}})]}):void 0,children:C.jsxs(C.Fragment,{children:[De.map((L,G)=>{const te=Z[G];if(!te)return null;const Ce=H[G]||{name:`Track ${G+1}`,muted:!1,soloed:!1,volume:1,pan:0},ve=K?.trackSpectrogramOverrides.get(te.id)?.renderMode??te.renderMode??"waveform",Qe=e?e(G):C.jsxs(c0,{onClick:()=>ne(G),children:[C.jsxs(u0,{style:{justifyContent:"center",position:"relative"},children:[d&&C.jsx(l0,{onClick:oe=>{oe.stopPropagation(),d(G)}}),C.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:Ce.name||`Track ${G+1}`}),K?.renderMenuItems&&C.jsx("span",{style:{position:"absolute",right:0,top:0},children:C.jsx(y0,{items:oe=>K.renderMenuItems({renderMode:ve,onRenderModeChange:Ze=>K.setTrackRenderMode(te.id,Ze),onOpenSettings:()=>Xe(te.id),onClose:oe})})})]}),C.jsxs(o0,{children:[C.jsx(Ml,{$variant:Ce.muted?"danger":"outline",onClick:()=>Y(G,!Ce.muted),children:"Mute"}),C.jsx(Ml,{$variant:Ce.soloed?"info":"outline",onClick:()=>U(G,!Ce.soloed),children:"Solo"})]}),C.jsxs(Tl,{children:[C.jsx(d0,{}),C.jsx($l,{min:"0",max:"1",step:"0.01",value:Ce.volume,onChange:oe=>J(G,parseFloat(oe.target.value))}),C.jsx(f0,{})]}),C.jsxs(Tl,{children:[C.jsx("span",{children:"L"}),C.jsx($l,{min:"-1",max:"1",step:"0.01",value:Ce.pan,onChange:oe=>B(G,parseFloat(oe.target.value))}),C.jsx("span",{children:"R"})]})]}),dt=L.length>0?Math.max(1,...L.map(oe=>oe.peaks.data.length)):1;return C.jsx(ui.Provider,{value:Qe,children:C.jsxs(Id,{numChannels:dt,backgroundColor:qt(p.waveOutlineColor),offset:0,width:Fe,hasClipHeaders:o,trackId:te.id,isSelected:te.id===E,children:[ve!=="waveform"&&(()=>{const oe=Re.get(te.id),Ze=oe?.config;return!Ze?.labels||!oe?null:C.jsx(Ng,{waveHeight:he,numChannels:dt,frequencyScaleFn:oe.frequencyScaleFn,minFrequency:Ze.minFrequency??0,maxFrequency:Ze.maxFrequency??$/2,labelsColor:Ze.labelsColor,labelsBackground:Ze.labelsBackground,renderMode:ve,hasClipHeaders:o})})(),L.map((oe,Ze)=>{const et=oe.peaks,en=et.length;return C.jsx(qa,{clipId:oe.clipId,trackIndex:G,clipIndex:Ze,trackName:oe.trackName,startSample:oe.startSample,durationSamples:oe.durationSamples,samplesPerPixel:N,showHeader:o,disableHeaderDrag:!i,isSelected:te.id===E,trackId:te.id,fadeIn:oe.fadeIn,fadeOut:oe.fadeOut,sampleRate:$,showFades:l,touchOptimized:c,onMouseDown:Pt=>{Pt.target.closest('[role="button"][aria-roledescription="draggable"]')||ne(G)},children:et.data.map((Pt,Wt)=>{const tn=K?.spectrogramDataMap.get(oe.clipId),nn=tn?.[Wt]??tn?.[0],Mt=Re.get(te.id),Kn=Mt?.config;return C.jsx(Wl,{index:Wt,data:Pt,bits:et.bits,length:en,isSelected:te.id===E,clipStartSample:oe.startSample,clipDurationSamples:oe.durationSamples,renderMode:ve,spectrogramData:nn,samplesPerPixel:N,spectrogramColorLUT:Mt?.colorLUT,spectrogramFrequencyScaleFn:Mt?.frequencyScaleFn,spectrogramMinFrequency:Kn?.minFrequency,spectrogramMaxFrequency:Kn?.maxFrequency,spectrogramWorkerApi:ze,spectrogramClipId:oe.clipId,spectrogramOnCanvasesReady:K?(Zr,Hr)=>{K.registerSpectrogramCanvases(oe.clipId,Wt,Zr,Hr)}:void 0},`${oe.clipId}-${Wt}`)})},oe.clipId)}),u?.isRecording&&u.trackId===te.id&&u.peaks.length>0&&C.jsx(qa,{clipId:"recording-preview",trackIndex:G,clipIndex:L.length,trackName:"Recording...",startSample:u.startSample,durationSamples:u.durationSamples,samplesPerPixel:N,showHeader:o,disableHeaderDrag:!0,isSelected:te.id===E,trackId:te.id,children:C.jsx(Wl,{index:0,data:u.peaks,bits:16,length:Math.floor(u.peaks.length/2),isSelected:te.id===E,clipStartSample:u.startSample,clipDurationSamples:u.durationSamples},`${te.id}-recording-0`)},`${te.id}-recording`)]})},te.id)}),y.length>0&&A&&C.jsx(A.AnnotationBoxesWrapper,{height:30,width:Fe,children:y.map((L,G)=>{const te=L.start*$/N,Ce=L.end*$/N,ve=s?s(L,G):L.id;return C.jsx(A.AnnotationBox,{annotationId:L.id,annotationIndex:G,startPosition:te,endPosition:Ce,label:ve,color:"#ff9800",isActive:L.id===x,onClick:()=>Ke(L),editable:k},L.id)})}),b!==_&&C.jsx(_d,{startPosition:Math.min(b,_)*$/N+(q.show?q.width:0),endPosition:Math.max(b,_)*$/N+(q.show?q.width:0),color:p.selectionColor}),(h||b===_)&&(n?n({position:(g.current??0)*$/N+(q.show?q.width:0),color:p.playheadColor,isPlaying:h,currentTimeRef:g,playbackStartTimeRef:w,audioStartPositionRef:v,samplesPerPixel:N,sampleRate:$,controlsOffset:q.show?q.width:0,getAudioContextTime:()=>j.getContext().currentTime,getPlaybackTime:m}):C.jsx(Zv,{color:p.playheadColor,controlsOffset:q.show?q.width:0}))]})})}),K?.SettingsModal&&typeof document<"u"&&ro.createPortal(C.jsx(K.SettingsModal,{open:xe!==null,onClose:()=>Xe(null),config:xe!==null?K.trackSpectrogramOverrides.get(xe)?.config??Z.find(L=>L.id===xe)?.spectrogramConfig??K.spectrogramConfig??{}:{},colorMap:xe!==null?K.trackSpectrogramOverrides.get(xe)?.colorMap??Z.find(L=>L.id===xe)?.spectrogramColorMap??K.spectrogramColorMap??"viridis":"viridis",onApply:(L,G)=>{xe!==null&&K.setTrackSpectrogramConfig(xe,L,G)}}),document.body)]})},Nd=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,controls:r,annotationListConfig:s,scrollActivePosition:a="center",scrollActiveContainer:o="nearest"})=>{const{annotations:i,activeAnnotationId:l,annotationsEditable:c,linkEndpoints:d,continuousPlay:u}=ut(),p=xn(),{setAnnotations:h}=Te(),g=s??{linkEndpoints:d,continuousPlay:u},w=f.useCallback(m=>{h(m),n?.(m)},[h,n]),{AnnotationText:v}=p;return C.jsx(v,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:o,editable:c,controls:c?r:void 0,annotationListConfig:g,height:e,onAnnotationUpdate:w,renderAnnotationItem:t})},Kv=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:s,annotationTextHeight:a,renderAnnotationItem:o,getAnnotationBoxLabel:i,scrollActivePosition:l="center",scrollActiveContainer:c="nearest",className:d,showClipHeaders:u=!1,interactiveClips:p=!1,showFades:h=!1,touchOptimized:g=!1,onRemoveTrack:w,recordingState:v})=>{const{annotations:m}=ut();return C.jsxs(C.Fragment,{children:[C.jsx(Hd,{renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:i,className:d,showClipHeaders:u,interactiveClips:p,showFades:h,touchOptimized:g,onRemoveTrack:w,recordingState:v}),m.length>0&&C.jsx(Nd,{height:a,renderAnnotationItem:o,controls:r,annotationListConfig:s,scrollActivePosition:l,scrollActiveContainer:c})]})};var qv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Xd=qv?f.useLayoutEffect:f.useEffect;function An(e){const t=f.useRef(e);return Xd(()=>{t.current=e},[e]),t}function ha(e,t,n=f.useEffect,r=Object.is){const s=f.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}var Fl=Object.getOwnPropertySymbols,Jv=Object.prototype.hasOwnProperty,Qv=Object.prototype.propertyIsEnumerable,ey=(e,t)=>{var n={};for(var r in e)Jv.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Fl)for(var r of Fl(e))t.indexOf(r)<0&&Qv.call(e,r)&&(n[r]=e[r]);return n},ty=new Jo,ny=f.createContext(ty),ry=f.memo(f.forwardRef(({children:e},t)=>{const[n,r]=f.useState(0),s=f.useRef(null),a=f.useRef(null),o=f.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})),f.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Xd(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),f.useImperativeHandle(t,()=>o),null})),pa=[void 0,br];function sy(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:a,onDragMove:o,onDragOver:i,onDragEnd:l}=t,c=ey(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const d=f.useRef(null),{plugins:u,modifiers:p,sensors:h}=c,g=Bt(u,Wn.plugins),w=Bt(h,Wn.sensors),v=Bt(p,Wn.modifiers),m=An(s),b=An(a),_=An(i),y=An(o),x=An(l),k=An(r),S=ay(()=>{var M;return(M=c.manager)!=null?M:new Jo(c)});return f.useEffect(()=>{if(!d.current)throw new Error("Renderer not found");const{renderer:M,trackRendering:E}=d.current,{monitor:I}=S;S.renderer=M;const T=[I.addEventListener("beforedragstart",P=>{const A=m.current;A&&E(()=>A(P,S))}),I.addEventListener("dragstart",P=>{var A;return(A=b.current)==null?void 0:A.call(b,P,S)}),I.addEventListener("dragover",P=>{const A=_.current;A&&E(()=>A(P,S))}),I.addEventListener("dragmove",P=>{const A=y.current;A&&E(()=>A(P,S))}),I.addEventListener("dragend",P=>{const A=x.current;A&&E(()=>A(P,S))}),I.addEventListener("collision",P=>{var A;return(A=k.current)==null?void 0:A.call(k,P,S)})];return()=>T.forEach(P=>P())},[S]),ha(g,()=>S&&(S.plugins=g),...pa),ha(w,()=>S&&(S.sensors=w),...pa),ha(v,()=>S&&(S.modifiers=v),...pa),C.jsxs(ny.Provider,{value:S,children:[C.jsx(ry,{ref:d,children:n}),n]})}function ay(e){const t=f.useRef(null);return t.current||(t.current=e()),f.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var oy=Object.create,Gd=Object.defineProperty,iy=Object.getOwnPropertyDescriptor,Yd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Gs=e=>{throw TypeError(e)},ly=(e,t,n)=>t in e?Gd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cy=e=>{var t;return[,,,oy((t=e?.[Yd("metadata")])!=null?t:null)]},Ud=["class","method","getter","setter","accessor","field","value","get","set"],Kd=e=>e!==void 0&&typeof e!="function"?Gs("Function expected"):e,uy=(e,t,n,r,s)=>({kind:Ud[e],name:t,metadata:r,addInitializer:a=>n._?Gs("Already initialized"):s.push(Kd(a||null))}),dy=(e,t)=>ly(t,Yd("metadata"),e[3]),fy=(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},qd=(e,t,n,r,s,a)=>{for(var o,i,l,c,d=t&7,u=!1,p=!1,h=2,g=Ud[d+5],w=e[h]||(e[h]=[]),v=(s=s.prototype,iy(s,n)),m=r.length-1;m>=0;m--)l=uy(d,n,i={},e[3],w),l.static=u,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[m])(v[g],l),i._=1,Kd(o)&&(v[g]=o);return v&&Gd(s,n,v),s},Jd=(e,t,n)=>t.has(e)||Gs("Cannot "+n),hy=(e,t,n)=>(Jd(e,t,"read from private field"),t.get(e)),py=(e,t,n)=>t.has(e)?Gs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),my=(e,t,n,r)=>(Jd(e,t,"write to private field"),t.set(e,n),n),tr=class Qa{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Qa(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 Qa(t,n)}},Qd,ef,eo,ps,jr,mi=class extends(eo=Jt,ef=[Ae],Qd=[Ae],eo){constructor(e){const t=tr.from(e);super(t,(n,r)=>tr.equals(n,r)),fy(jr,5,this),py(this,ps,0),this.velocity={x:0,y:0}}get delta(){return tr.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=tr.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),a=s-hy(this,ps),o=i=>Math.round(i/a*100);Kt(()=>{my(this,ps,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(tr.from(e)),this.velocity={x:0,y:0}}};jr=cy(eo);ps=new WeakMap;qd(jr,2,"delta",ef,mi);qd(jr,2,"direction",Qd,mi);dy(jr,mi);var tf=(e=>(e.Horizontal="x",e.Vertical="y",e))(tf||{});Object.values(tf);var gy=Object.defineProperty,vy=Object.defineProperties,yy=Object.getOwnPropertyDescriptors,Ol=Object.getOwnPropertySymbols,by=Object.prototype.hasOwnProperty,wy=Object.prototype.propertyIsEnumerable,Bl=(e,t,n)=>t in e?gy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nf=(e,t)=>{for(var n in t||(t={}))by.call(t,n)&&Bl(e,n,t[n]);if(Ol)for(var n of Ol(t))wy.call(t,n)&&Bl(e,n,t[n]);return e},rf=(e,t)=>vy(e,yy(t)),to=class extends _r{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return rf(nf({},t),{[n]:r})}};to.configure=Gn(to);var sf=to;sf.configure({axis:"x",value:0});var _y=sf.configure({axis:"y",value:0}),Vl=class extends _r{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 rf(nf({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/a)*a})}};Vl.configure=Gn(Vl);const af=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},xy=R.div`
|
|
1045
|
+
`,Wl=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=f.useRef(null),s=f.useRef(null),a=Lr(),{waveHeight:o}=zs(),{isPlaying:i,currentTimeRef:l,getPlaybackTime:c}=ct(),{samplesPerPixel:d,sampleRate:u}=vt(),p=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";f.useEffect(()=>{const k=()=>{if(r.current){const I=(i?c():l.current??0)*u,E=e+t;let M=0;I<=e?M=0:I>=E?M=1:M=(I-e)/t,r.current.style.transform=`scaleX(${M})`}i&&(s.current=requestAnimationFrame(k))};return i?s.current=requestAnimationFrame(k):k(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,u,d,e,t,n.length,l,c]),f.useEffect(()=>{if(!i&&r.current){const S=(l.current??0)*u,I=e+t;let E=0;S<=e?E=0:S>=I?E=1:E=(S-e)/t,r.current.style.transform=`scaleX(${E})`}});const h=a?.waveformDrawMode||"inverted";let g;h==="inverted"?g=n.isSelected&&a?a.selectedWaveFillColor:a?.waveFillColor||"white":g=n.isSelected&&a?a.selectedWaveOutlineColor:a?.waveOutlineColor||"grey";const w=n.renderMode==="spectrogram"||n.renderMode==="both",v=n.renderMode==="both",m=w?"#000":qt(g),b=Math.floor(o/2),_=o,y=n.index*o,x=qt(g);return C.jsxs(Yv,{children:[v?C.jsxs(C.Fragment,{children:[C.jsx(fa,{$color:"#000",$height:b,$top:y,$width:n.length}),C.jsx(fa,{$color:x,$height:b,$top:y+b,$width:n.length})]}):C.jsx(fa,{$color:m,$height:_,$top:y,$width:n.length}),C.jsx(Uv,{ref:r,$color:p,$height:_,$top:y,$width:n.length}),C.jsx(Kv,{children:C.jsx(Sd,{...n,transparentBackground:!0})})]})},pi=f.createContext(null),qv=pi.Provider;function Jv(){const e=f.useContext(pi);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const Qv=60,Nd=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:a,showClipHeaders:o=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:d,recordingState:u})=>{const p=Lr(),{isPlaying:h,currentTimeRef:g,playbackStartTimeRef:w,audioStartPositionRef:v,getPlaybackTime:m}=ct(),{selectionStart:b,selectionEnd:_,annotations:y,activeAnnotationId:x,annotationsEditable:k,linkEndpoints:S,continuousPlay:I,selectedTrackId:E,loopStart:M,loopEnd:T,isLoopEnabled:P}=ut(),A=f.useContext(Xs),{setAnnotations:F,setActiveAnnotationId:O,setTrackMute:H,setTrackSolo:K,setTrackVolume:ne,setTrackPan:B,setSelection:re,play:se,setScrollContainer:ae,setSelectedTrackId:ie,setCurrentTime:me,setLoopRegion:ye}=Te(),{peaksDataArray:De,trackStates:X,tracks:Z,duration:de,samplesPerPixel:G,sampleRate:$,waveHeight:he,timeScaleHeight:We,controls:q,barWidth:ge,barGap:Le,isReady:Ne}=vt(),U=f.useContext(pi),Re=f.useMemo(()=>{if(!U)return new Map;const L=new Map;return Z.forEach(Y=>{if((U.trackSpectrogramOverrides.get(Y.id)?.renderMode??Y.renderMode??"waveform")==="waveform")return;const Ce=U.trackSpectrogramOverrides.get(Y.id),ve=Ce?.colorMap??Y.spectrogramColorMap??U.spectrogramColorMap??"viridis",Qe=Ce?.config??Y.spectrogramConfig??U.spectrogramConfig;L.set(Y.id,{colorLUT:U.getColorMap(ve),frequencyScaleFn:U.getFrequencyScale(Qe?.frequencyScale??"mel"),config:Qe})}),L},[Z,U]),ze=f.useMemo(()=>{if(U?.spectrogramWorkerApi)return{registerCanvas:U.spectrogramWorkerApi.registerCanvas.bind(U.spectrogramWorkerApi),unregisterCanvas:U.spectrogramWorkerApi.unregisterCanvas.bind(U.spectrogramWorkerApi)}},[U?.spectrogramWorkerApi]),[xe,Xe]=f.useState(null),[Ue,at]=f.useState(!1),yt=f.useRef(null),At=f.useCallback(L=>{yt.current=L,ae(L)},[ae]),N=Z.reduce((L,Y)=>Y.clips.reduce((Q,Ce)=>{const ve=(Ce.startSample+Ce.durationSamples)/Ce.sampleRate;return Math.max(Q,ve)},L),0);let le=N>0?N:de>0?de:Qv;if(u?.isRecording){const Y=(u.startSample+u.durationSamples)/$;le=Math.max(le,Y+10)}const Fe=Math.floor(le*$/G),Ke=async L=>{O(L.id);const Y=I?void 0:L.end-L.start;try{await se(L.start,Y)}catch(Q){console.error("waveform-playlist: Failed to start playback for annotation",L.id,Q)}},ee=f.useCallback(L=>{if(L>=0&&L<Z.length){const Y=Z[L];ie(Y.id)}},[Z,ie]),be=L=>{const Y=L.currentTarget.getBoundingClientRect(),Q=q.show?q.width:0,ve=(L.clientX-Y.left-Q)*G/$,dt=L.clientY-Y.top;let oe=0,Ze=-1;for(let et=0;et<De.length;et++){const en=De[et],Pt=en.length>0?Math.max(1,...en.map(Mt=>Mt.peaks.data.length)):1,nn=((U?.trackSpectrogramOverrides.get(Z[et]?.id)?.renderMode??Z[et]?.renderMode??"waveform")==="both"?Pt*2:Pt)*he+(o?22:0);if(dt>=oe&&dt<oe+nn){Ze=et;break}oe+=nn}Ze!==-1&&ee(Ze),at(!0),me(ve),re(ve,ve)},Ee=L=>{if(!Ue)return;const Y=L.currentTarget.getBoundingClientRect(),Q=q.show?q.width:0,ve=(L.clientX-Y.left-Q)*G/$,Qe=Math.min(b,ve),dt=Math.max(b,ve);re(Qe,dt)},je=L=>{if(!Ue)return;at(!1);const Y=L.currentTarget.getBoundingClientRect(),Q=q.show?q.width:0,ve=(L.clientX-Y.left-Q)*G/$,Qe=Math.min(b,ve),dt=Math.max(b,ve);Math.abs(dt-Qe)<.1?(me(Qe),h&&se(Qe)):re(Qe,dt)};return Z.some(L=>L.clips.length>0)&&De.length===0?C.jsx("div",{className:a,children:"Loading waveform..."}):C.jsxs(kd,{children:[C.jsx(Vr.Provider,{value:{samplesPerPixel:G,sampleRate:$,zoomLevels:[G],waveHeight:he,timeScaleHeight:We,duration:le*1e3,controls:q,barWidth:ge,barGap:Le},children:C.jsx(li,{theme:p,backgroundColor:qt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Fe+(q.show?q.width:0),timescaleWidth:Fe,tracksWidth:Fe,controlsWidth:q.show?q.width:0,onTracksMouseDown:be,onTracksMouseMove:Ee,onTracksMouseUp:je,scrollContainerRef:At,isSelecting:Ue,"data-playlist-state":Ne?"ready":"loading",timescale:We>0?C.jsxs(C.Fragment,{children:[C.jsx(Ed,{renderTimestamp:t}),P&&C.jsx(Pg,{startPosition:Math.min(M,T)*$/G,endPosition:Math.max(M,T)*$/G,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:Fe,controlsOffset:q.show?q.width:0,onLoopRegionChange:(L,Y)=>{const Q=L*G/$,Ce=Y*G/$;ye(Q,Ce)}})]}):void 0,children:C.jsxs(C.Fragment,{children:[De.map((L,Y)=>{const Q=Z[Y];if(!Q)return null;const Ce=X[Y]||{name:`Track ${Y+1}`,muted:!1,soloed:!1,volume:1,pan:0},ve=U?.trackSpectrogramOverrides.get(Q.id)?.renderMode??Q.renderMode??"waveform",Qe=e?e(Y):C.jsxs(h0,{onClick:()=>ee(Y),children:[C.jsxs(p0,{style:{justifyContent:"center",position:"relative"},children:[d&&C.jsx(f0,{onClick:oe=>{oe.stopPropagation(),d(Y)}}),C.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:Ce.name||`Track ${Y+1}`}),U?.renderMenuItems&&C.jsx("span",{style:{position:"absolute",right:0,top:0},children:C.jsx(x0,{items:oe=>U.renderMenuItems({renderMode:ve,onRenderModeChange:Ze=>U.setTrackRenderMode(Q.id,Ze),onOpenSettings:()=>Xe(Q.id),onClose:oe})})})]}),C.jsxs(u0,{children:[C.jsx(Ml,{$variant:Ce.muted?"danger":"outline",onClick:()=>H(Y,!Ce.muted),children:"Mute"}),C.jsx(Ml,{$variant:Ce.soloed?"info":"outline",onClick:()=>K(Y,!Ce.soloed),children:"Solo"})]}),C.jsxs(Tl,{children:[C.jsx(m0,{}),C.jsx($l,{min:"0",max:"1",step:"0.01",value:Ce.volume,onChange:oe=>ne(Y,parseFloat(oe.target.value))}),C.jsx(g0,{})]}),C.jsxs(Tl,{children:[C.jsx("span",{children:"L"}),C.jsx($l,{min:"-1",max:"1",step:"0.01",value:Ce.pan,onChange:oe=>B(Y,parseFloat(oe.target.value))}),C.jsx("span",{children:"R"})]})]}),dt=L.length>0?Math.max(1,...L.map(oe=>oe.peaks.data.length)):1;return C.jsx(ui.Provider,{value:Qe,children:C.jsxs(Id,{numChannels:dt,backgroundColor:qt(p.waveOutlineColor),offset:0,width:Fe,hasClipHeaders:o,trackId:Q.id,isSelected:Q.id===E,children:[ve!=="waveform"&&(()=>{const oe=Re.get(Q.id),Ze=oe?.config;return!Ze?.labels||!oe?null:C.jsx(Ug,{waveHeight:he,numChannels:dt,frequencyScaleFn:oe.frequencyScaleFn,minFrequency:Ze.minFrequency??0,maxFrequency:Ze.maxFrequency??$/2,labelsColor:Ze.labelsColor,labelsBackground:Ze.labelsBackground,renderMode:ve,hasClipHeaders:o})})(),L.map((oe,Ze)=>{const et=oe.peaks,en=et.length;return C.jsx(qa,{clipId:oe.clipId,trackIndex:Y,clipIndex:Ze,trackName:oe.trackName,startSample:oe.startSample,durationSamples:oe.durationSamples,samplesPerPixel:G,showHeader:o,disableHeaderDrag:!i,isSelected:Q.id===E,trackId:Q.id,fadeIn:oe.fadeIn,fadeOut:oe.fadeOut,sampleRate:$,showFades:l,touchOptimized:c,onMouseDown:Pt=>{Pt.target.closest('[role="button"][aria-roledescription="draggable"]')||ee(Y)},children:et.data.map((Pt,Wt)=>{const tn=U?.spectrogramDataMap.get(oe.clipId),nn=tn?.[Wt]??tn?.[0],Mt=Re.get(Q.id),Kn=Mt?.config;return C.jsx(Wl,{index:Wt,data:Pt,bits:et.bits,length:en,isSelected:Q.id===E,clipStartSample:oe.startSample,clipDurationSamples:oe.durationSamples,renderMode:ve,spectrogramData:nn,samplesPerPixel:G,spectrogramColorLUT:Mt?.colorLUT,spectrogramFrequencyScaleFn:Mt?.frequencyScaleFn,spectrogramMinFrequency:Kn?.minFrequency,spectrogramMaxFrequency:Kn?.maxFrequency,spectrogramWorkerApi:ze,spectrogramClipId:oe.clipId,spectrogramOnCanvasesReady:U?(Zr,Hr)=>{U.registerSpectrogramCanvases(oe.clipId,Wt,Zr,Hr)}:void 0},`${oe.clipId}-${Wt}`)})},oe.clipId)}),u?.isRecording&&u.trackId===Q.id&&u.peaks.length>0&&C.jsx(qa,{clipId:"recording-preview",trackIndex:Y,clipIndex:L.length,trackName:"Recording...",startSample:u.startSample,durationSamples:u.durationSamples,samplesPerPixel:G,showHeader:o,disableHeaderDrag:!0,isSelected:Q.id===E,trackId:Q.id,children:C.jsx(Wl,{index:0,data:u.peaks,bits:16,length:Math.floor(u.peaks.length/2),isSelected:Q.id===E,clipStartSample:u.startSample,clipDurationSamples:u.durationSamples},`${Q.id}-recording-0`)},`${Q.id}-recording`)]})},Q.id)}),y.length>0&&A&&C.jsx(A.AnnotationBoxesWrapper,{height:30,width:Fe,children:y.map((L,Y)=>{const Q=L.start*$/G,Ce=L.end*$/G,ve=s?s(L,Y):L.id;return C.jsx(A.AnnotationBox,{annotationId:L.id,annotationIndex:Y,startPosition:Q,endPosition:Ce,label:ve,color:"#ff9800",isActive:L.id===x,onClick:()=>Ke(L),editable:k},L.id)})}),b!==_&&C.jsx(_d,{startPosition:Math.min(b,_)*$/G+(q.show?q.width:0),endPosition:Math.max(b,_)*$/G+(q.show?q.width:0),color:p.selectionColor}),(h||b===_)&&(n?n({position:(g.current??0)*$/G+(q.show?q.width:0),color:p.playheadColor,isPlaying:h,currentTimeRef:g,playbackStartTimeRef:w,audioStartPositionRef:v,samplesPerPixel:G,sampleRate:$,controlsOffset:q.show?q.width:0,getAudioContextTime:()=>j.getContext().currentTime,getPlaybackTime:m}):C.jsx(Gv,{color:p.playheadColor,controlsOffset:q.show?q.width:0}))]})})}),U?.SettingsModal&&typeof document<"u"&&ro.createPortal(C.jsx(U.SettingsModal,{open:xe!==null,onClose:()=>Xe(null),config:xe!==null?U.trackSpectrogramOverrides.get(xe)?.config??Z.find(L=>L.id===xe)?.spectrogramConfig??U.spectrogramConfig??{}:{},colorMap:xe!==null?U.trackSpectrogramOverrides.get(xe)?.colorMap??Z.find(L=>L.id===xe)?.spectrogramColorMap??U.spectrogramColorMap??"viridis":"viridis",onApply:(L,Y)=>{xe!==null&&U.setTrackSpectrogramConfig(xe,L,Y)}}),document.body)]})},Xd=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,controls:r,annotationListConfig:s,scrollActivePosition:a="center",scrollActiveContainer:o="nearest"})=>{const{annotations:i,activeAnnotationId:l,annotationsEditable:c,linkEndpoints:d,continuousPlay:u}=ut(),p=xn(),{setAnnotations:h}=Te(),g=s??{linkEndpoints:d,continuousPlay:u},w=f.useCallback(m=>{h(m),n?.(m)},[h,n]),{AnnotationText:v}=p;return C.jsx(v,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:o,editable:c,controls:c?r:void 0,annotationListConfig:g,height:e,onAnnotationUpdate:w,renderAnnotationItem:t})},ey=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:s,annotationTextHeight:a,renderAnnotationItem:o,getAnnotationBoxLabel:i,scrollActivePosition:l="center",scrollActiveContainer:c="nearest",className:d,showClipHeaders:u=!1,interactiveClips:p=!1,showFades:h=!1,touchOptimized:g=!1,onRemoveTrack:w,recordingState:v})=>{const{annotations:m}=ut();return C.jsxs(C.Fragment,{children:[C.jsx(Nd,{renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:i,className:d,showClipHeaders:u,interactiveClips:p,showFades:h,touchOptimized:g,onRemoveTrack:w,recordingState:v}),m.length>0&&C.jsx(Xd,{height:a,renderAnnotationItem:o,controls:r,annotationListConfig:s,scrollActivePosition:l,scrollActiveContainer:c})]})};var ty=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Gd=ty?f.useLayoutEffect:f.useEffect;function An(e){const t=f.useRef(e);return Gd(()=>{t.current=e},[e]),t}function ha(e,t,n=f.useEffect,r=Object.is){const s=f.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}var Fl=Object.getOwnPropertySymbols,ny=Object.prototype.hasOwnProperty,ry=Object.prototype.propertyIsEnumerable,sy=(e,t)=>{var n={};for(var r in e)ny.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Fl)for(var r of Fl(e))t.indexOf(r)<0&&ry.call(e,r)&&(n[r]=e[r]);return n},ay=new Jo,oy=f.createContext(ay),iy=f.memo(f.forwardRef(({children:e},t)=>{const[n,r]=f.useState(0),s=f.useRef(null),a=f.useRef(null),o=f.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})),f.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Gd(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),f.useImperativeHandle(t,()=>o),null})),pa=[void 0,br];function ly(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:a,onDragMove:o,onDragOver:i,onDragEnd:l}=t,c=sy(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const d=f.useRef(null),{plugins:u,modifiers:p,sensors:h}=c,g=Bt(u,Wn.plugins),w=Bt(h,Wn.sensors),v=Bt(p,Wn.modifiers),m=An(s),b=An(a),_=An(i),y=An(o),x=An(l),k=An(r),S=cy(()=>{var I;return(I=c.manager)!=null?I:new Jo(c)});return f.useEffect(()=>{if(!d.current)throw new Error("Renderer not found");const{renderer:I,trackRendering:E}=d.current,{monitor:M}=S;S.renderer=I;const T=[M.addEventListener("beforedragstart",P=>{const A=m.current;A&&E(()=>A(P,S))}),M.addEventListener("dragstart",P=>{var A;return(A=b.current)==null?void 0:A.call(b,P,S)}),M.addEventListener("dragover",P=>{const A=_.current;A&&E(()=>A(P,S))}),M.addEventListener("dragmove",P=>{const A=y.current;A&&E(()=>A(P,S))}),M.addEventListener("dragend",P=>{const A=x.current;A&&E(()=>A(P,S))}),M.addEventListener("collision",P=>{var A;return(A=k.current)==null?void 0:A.call(k,P,S)})];return()=>T.forEach(P=>P())},[S]),ha(g,()=>S&&(S.plugins=g),...pa),ha(w,()=>S&&(S.sensors=w),...pa),ha(v,()=>S&&(S.modifiers=v),...pa),C.jsxs(oy.Provider,{value:S,children:[C.jsx(iy,{ref:d,children:n}),n]})}function cy(e){const t=f.useRef(null);return t.current||(t.current=e()),f.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var uy=Object.create,Yd=Object.defineProperty,dy=Object.getOwnPropertyDescriptor,Ud=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Gs=e=>{throw TypeError(e)},fy=(e,t,n)=>t in e?Yd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hy=e=>{var t;return[,,,uy((t=e?.[Ud("metadata")])!=null?t:null)]},Kd=["class","method","getter","setter","accessor","field","value","get","set"],qd=e=>e!==void 0&&typeof e!="function"?Gs("Function expected"):e,py=(e,t,n,r,s)=>({kind:Kd[e],name:t,metadata:r,addInitializer:a=>n._?Gs("Already initialized"):s.push(qd(a||null))}),my=(e,t)=>fy(t,Ud("metadata"),e[3]),gy=(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},Jd=(e,t,n,r,s,a)=>{for(var o,i,l,c,d=t&7,u=!1,p=!1,h=2,g=Kd[d+5],w=e[h]||(e[h]=[]),v=(s=s.prototype,dy(s,n)),m=r.length-1;m>=0;m--)l=py(d,n,i={},e[3],w),l.static=u,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[m])(v[g],l),i._=1,qd(o)&&(v[g]=o);return v&&Yd(s,n,v),s},Qd=(e,t,n)=>t.has(e)||Gs("Cannot "+n),vy=(e,t,n)=>(Qd(e,t,"read from private field"),t.get(e)),yy=(e,t,n)=>t.has(e)?Gs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),by=(e,t,n,r)=>(Qd(e,t,"write to private field"),t.set(e,n),n),tr=class Qa{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Qa(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 Qa(t,n)}},ef,tf,eo,ps,jr,mi=class extends(eo=Jt,tf=[Ae],ef=[Ae],eo){constructor(e){const t=tr.from(e);super(t,(n,r)=>tr.equals(n,r)),gy(jr,5,this),yy(this,ps,0),this.velocity={x:0,y:0}}get delta(){return tr.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=tr.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),a=s-vy(this,ps),o=i=>Math.round(i/a*100);Kt(()=>{by(this,ps,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(tr.from(e)),this.velocity={x:0,y:0}}};jr=hy(eo);ps=new WeakMap;Jd(jr,2,"delta",tf,mi);Jd(jr,2,"direction",ef,mi);my(jr,mi);var nf=(e=>(e.Horizontal="x",e.Vertical="y",e))(nf||{});Object.values(nf);var wy=Object.defineProperty,_y=Object.defineProperties,xy=Object.getOwnPropertyDescriptors,Ol=Object.getOwnPropertySymbols,Cy=Object.prototype.hasOwnProperty,ky=Object.prototype.propertyIsEnumerable,Bl=(e,t,n)=>t in e?wy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rf=(e,t)=>{for(var n in t||(t={}))Cy.call(t,n)&&Bl(e,n,t[n]);if(Ol)for(var n of Ol(t))ky.call(t,n)&&Bl(e,n,t[n]);return e},sf=(e,t)=>_y(e,xy(t)),to=class extends _r{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return sf(rf({},t),{[n]:r})}};to.configure=Gn(to);var af=to;af.configure({axis:"x",value:0});var Sy=af.configure({axis:"y",value:0}),Vl=class extends _r{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 sf(rf({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/a)*a})}};Vl.configure=Gn(Vl);const of=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},Ey=R.div`
|
|
1046
1046
|
position: absolute;
|
|
1047
1047
|
top: 0;
|
|
1048
1048
|
left: 0;
|
|
@@ -1052,9 +1052,9 @@ self.onmessage = function(e) {
|
|
|
1052
1052
|
z-index: 100;
|
|
1053
1053
|
pointer-events: none;
|
|
1054
1054
|
will-change: transform;
|
|
1055
|
-
`,
|
|
1055
|
+
`,Iy=({color:e="#ff0000",controlsOffset:t=0})=>{const n=f.useRef(null),r=f.useRef(null),{isPlaying:s,currentTimeRef:a}=Zs(),{samplesPerPixel:o,sampleRate:i,progressBarWidth:l}=Ns();return f.useEffect(()=>{const c=()=>{if(n.current){const u=(a.current??0)*i/o+t;n.current.style.transform=`translate3d(${u}px, 0, 0)`}s&&(r.current=requestAnimationFrame(c))};return s?r.current=requestAnimationFrame(c):c(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[s,i,o,t,a]),f.useEffect(()=>{if(!s&&n.current){const d=(a.current??0)*i/o+t;n.current.style.transform=`translate3d(${d}px, 0, 0)`}}),C.jsx(Ey,{ref:n,$color:e,$width:l,"data-playhead":!0})},Ay=R.div`
|
|
1056
1056
|
position: relative;
|
|
1057
|
-
`,
|
|
1057
|
+
`,My=R.div`
|
|
1058
1058
|
position: absolute;
|
|
1059
1059
|
top: ${e=>e.$top}px;
|
|
1060
1060
|
left: 0;
|
|
@@ -1065,7 +1065,7 @@ self.onmessage = function(e) {
|
|
|
1065
1065
|
transform: translateZ(0);
|
|
1066
1066
|
backface-visibility: hidden;
|
|
1067
1067
|
will-change: transform;
|
|
1068
|
-
|
|
1068
|
+
`,$y=R.div`
|
|
1069
1069
|
position: absolute;
|
|
1070
1070
|
top: ${e=>e.$top}px;
|
|
1071
1071
|
left: 0;
|
|
@@ -1074,8 +1074,8 @@ self.onmessage = function(e) {
|
|
|
1074
1074
|
pointer-events: none;
|
|
1075
1075
|
z-index: 1;
|
|
1076
1076
|
will-change: width;
|
|
1077
|
-
`,
|
|
1077
|
+
`,Ty=R.div`
|
|
1078
1078
|
position: relative;
|
|
1079
1079
|
z-index: 2;
|
|
1080
|
-
`,
|
|
1080
|
+
`,Dy=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=f.useRef(null),s=f.useRef(null),a=Lr(),{waveHeight:o}=zs(),{isPlaying:i,currentTimeRef:l}=Zs(),{samplesPerPixel:c,sampleRate:d}=Ns(),u=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";f.useEffect(()=>{const w=()=>{if(r.current){const m=(l.current??0)*d,b=e+t;let _=0;if(m<=e)_=0;else if(m>=b)_=n.length;else{const y=m-e;_=Math.floor(y/c)}r.current.style.width=`${_}px`}i&&(s.current=requestAnimationFrame(w))};return i?s.current=requestAnimationFrame(w):w(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,d,c,e,t,n.length,l]),f.useEffect(()=>{if(!i&&r.current){const v=(l.current??0)*d,m=e+t;let b=0;if(v<=e)b=0;else if(v>=m)b=n.length;else{const _=v-e;b=Math.floor(_/c)}r.current.style.width=`${b}px`}});const p=a?.waveformDrawMode||"inverted";let h;p==="inverted"?h=a?.selectedWaveFillColor||a?.waveFillColor||"white":h=a?.selectedWaveOutlineColor||a?.waveOutlineColor||"grey";const g=qt(h);return C.jsxs(Ay,{children:[C.jsx(My,{$color:g,$height:o,$top:n.index*o,$width:n.length}),C.jsx($y,{ref:r,$color:u,$height:o,$top:n.index*o}),C.jsx(Ty,{children:C.jsx(Sd,{...n,isSelected:!0,transparentBackground:!0})})]})},lf=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:n=!1,onAnnotationUpdate:r,className:s})=>{const a=Lr(),{isPlaying:o}=Zs(),{annotations:i,activeAnnotationId:l}=Hs(),c=f.useContext(Xs),{play:d,seekTo:u,setActiveAnnotationId:p,setAnnotations:h,setScrollContainer:g}=hi(),{duration:w,peaksDataArray:v,sampleRate:m,waveHeight:b,timeScaleHeight:_,samplesPerPixel:y,controls:x,playoutRef:k,barWidth:S,barGap:I}=Ns(),[E,M]=f.useState(0),[T,P]=f.useState(0),[A,F]=f.useState(!1),O=f.useRef(null),H=f.useCallback(X=>{O.current=X,g(X)},[g]),K=Math.floor(w*m/y),ne=f.useCallback(async X=>{p(X.id);try{await d(X.start)}catch(Z){console.error("waveform-playlist: Failed to start playback for annotation",X.id,Z)}},[p,d]),B=f.useCallback(X=>{h(X),r?.(X)},[h,r]),{onDragStart:re,onDragMove:se,onDragEnd:ae}=Pd({annotations:i,onAnnotationsChange:B,samplesPerPixel:y,sampleRate:m,duration:w,linkEndpoints:n}),ie=f.useCallback(X=>{const Z=X.currentTarget.getBoundingClientRect(),de=x.show?x.width:0,$=(X.clientX-Z.left-de)*y/m;F(!0),M($),P($)},[x,y,m]),me=f.useCallback(X=>{if(!A)return;const Z=X.currentTarget.getBoundingClientRect(),de=x.show?x.width:0,$=(X.clientX-Z.left-de)*y/m;P($)},[A,x,y,m]),ye=f.useCallback(X=>{if(!A)return;F(!1);const Z=X.currentTarget.getBoundingClientRect(),de=x.show?x.width:0,$=(X.clientX-Z.left-de)*y/m,he=Math.min(E,$),We=Math.max(E,$);Math.abs(We-he)<.1?(u(he),M(he),P(he),o&&k.current&&(k.current.stop(),d(he))):(M(he),P(We))},[A,E,y,m,x,u,o,k,d]);if(v.length===0)return C.jsx("div",{className:s,children:"Loading waveform..."});const De=null;return C.jsx(kd,{children:C.jsx(Vr.Provider,{value:{samplesPerPixel:y,sampleRate:m,zoomLevels:[y],waveHeight:b,timeScaleHeight:_,duration:w*1e3,controls:x,barWidth:S,barGap:I},children:C.jsx(li,{theme:a,backgroundColor:qt(a.waveOutlineColor),timescaleBackgroundColor:a.timescaleBackgroundColor,scrollContainerWidth:K+(x.show?x.width:0),timescaleWidth:K,tracksWidth:K,controlsWidth:x.show?x.width:0,onTracksMouseDown:ie,onTracksMouseMove:me,onTracksMouseUp:ye,scrollContainerRef:H,isSelecting:A,timescale:_>0?C.jsx(Ed,{}):void 0,children:C.jsxs(C.Fragment,{children:[v.map((X,Z)=>{const de=X.length>0?Math.max(...X.map(G=>G.peaks.data.length)):1;return C.jsx(ui.Provider,{value:De,children:C.jsx(Id,{numChannels:de,backgroundColor:qt(a.waveOutlineColor),offset:0,width:K,hasClipHeaders:!1,trackId:`media-element-track-${Z}`,isSelected:!0,children:X.map((G,$)=>{const he=G.peaks,We=he.length;return C.jsx(qa,{clipId:G.clipId,trackIndex:Z,clipIndex:$,trackName:G.trackName,startSample:G.startSample,durationSamples:G.durationSamples,samplesPerPixel:y,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${Z}`,children:he.data.map((q,ge)=>C.jsx(Dy,{index:ge,data:q,bits:he.bits,length:We,clipStartSample:G.startSample,clipDurationSamples:G.durationSamples},`${Z}-${$}-${ge}`))},`${Z}-${$}`)})})},Z)}),i.length>0&&c&&C.jsx(ly,{onDragStart:re,onDragMove:se,onDragEnd:ae,modifiers:t?[Sy]:[],plugins:of,children:C.jsx(c.AnnotationBoxesWrapper,{height:30,width:K,children:i.map((X,Z)=>{const de=X.start*m/y,G=X.end*m/y,$=e?e(X,Z):X.id;return C.jsx(c.AnnotationBox,{annotationId:X.id,annotationIndex:Z,startPosition:de,endPosition:G,label:$,color:"#ff9800",isActive:X.id===l,onClick:()=>ne(X),editable:t},X.id)})})}),E!==T&&C.jsx(_d,{startPosition:Math.min(E,T)*m/y+(x.show?x.width:0),endPosition:Math.max(E,T)*m/y+(x.show?x.width:0),color:a.selectionColor}),C.jsx(Iy,{color:a.playheadColor,controlsOffset:x.show?x.width:0})]})})})})},cf=({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:d}=Hs(),u=xn(),{setAnnotations:p}=hi(),h=a??{linkEndpoints:!1,continuousPlay:d},g=f.useCallback(v=>{p(v),n?.(v)},[p,n]),{AnnotationText:w}=u;return C.jsx(w,{annotations:l,activeAnnotationId:c??void 0,shouldScrollToActive:!0,scrollActivePosition:o,scrollActiveContainer:i,editable:r,controls:r?s:void 0,annotationListConfig:h,height:e,onAnnotationUpdate:g,renderAnnotationItem:t})},Ry=({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}=Hs();return C.jsxs(C.Fragment,{children:[C.jsx(lf,{getAnnotationBoxLabel:t,editable:r,linkEndpoints:s,onAnnotationUpdate:a,className:l}),c.length>0&&C.jsx(cf,{height:e,renderAnnotationItem:n,onAnnotationUpdate:a,editable:r,annotationListConfig:{linkEndpoints:s,continuousPlay:!1},scrollActivePosition:o,scrollActiveContainer:i})]})},Ds=class Ds extends _r{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 d=c.clips[o];if(!d)return n;const u=n.x*l,p=[...c.clips].sort((w,v)=>w.startSample-v.startSample),h=p.findIndex(w=>w.id===d.id);return{x:Xl(d,u,p,h)/l,y:0}}};Ds.configure=Gn(Ds);let no=Ds;exports.Tone=zl;exports.AnnotationIntegrationProvider=Lv;exports.AudioPosition=Ov;exports.AutomaticScrollCheckbox=Vv;exports.ClipCollisionModifier=no;exports.ContinuousPlayCheckbox=zv;exports.DownloadAnnotationsButton=Hv;exports.EditableCheckbox=Zv;exports.ExportWavButton=Nv;exports.FastForwardButton=Iv;exports.LinkEndpointsCheckbox=jv;exports.LoopButton=$v;exports.MasterVolumeControl=Pv;exports.MediaElementAnnotationList=cf;exports.MediaElementPlaylist=lf;exports.MediaElementPlaylistProvider=xv;exports.MediaElementWaveform=Ry;exports.PauseButton=kv;exports.PlayButton=Cv;exports.PlaylistAnnotationList=Xd;exports.PlaylistVisualization=Nd;exports.RewindButton=Ev;exports.SelectionTimeInputs=Bv;exports.SetLoopRegionButton=Tv;exports.SkipBackwardButton=Av;exports.SkipForwardButton=Mv;exports.SpectrogramIntegrationProvider=qv;exports.StopButton=Sv;exports.TimeFormatSelect=Wv;exports.Waveform=ey;exports.WaveformPlaylistProvider=bv;exports.ZoomInButton=Dv;exports.ZoomOutButton=Rv;exports.createEffectChain=av;exports.createEffectInstance=Ar;exports.effectCategories=tv;exports.effectDefinitions=zr;exports.getEffectDefinition=fi;exports.getEffectsByCategory=ev;exports.getShortcutLabel=q0;exports.getWaveformDataMetadata=L0;exports.loadPeaksFromWaveformData=V0;exports.loadWaveformData=di;exports.noDropAnimationPlugins=of;exports.useAnnotationDragHandlers=Pd;exports.useAnnotationIntegration=xn;exports.useAnnotationKeyboardControls=Q0;exports.useAudioTracks=X0;exports.useClipDragHandlers=G0;exports.useClipSplitting=K0;exports.useDragSensors=U0;exports.useDynamicEffects=ov;exports.useDynamicTracks=yv;exports.useExportWav=Wd;exports.useKeyboardShortcuts=Ts;exports.useMasterAnalyser=N0;exports.useMasterVolume=Rd;exports.useMediaElementAnimation=Zs;exports.useMediaElementControls=hi;exports.useMediaElementData=Ns;exports.useMediaElementState=Hs;exports.usePlaybackAnimation=ct;exports.usePlaybackShortcuts=J0;exports.usePlaylistControls=Te;exports.usePlaylistData=vt;exports.usePlaylistState=ut;exports.useSpectrogramIntegration=Jv;exports.useTimeFormat=Td;exports.useTrackDynamicEffects=iv;exports.useZoomControls=Dd;exports.waveformDataToPeaks=Md;
|
|
1081
1081
|
//# sourceMappingURL=index.js.map
|