1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[89227],{89227:(e,t,i)=>{i.d(t,{JD:()=>a});var n=i(75556),o=i(53763),s=i(9497),u=i(22479);let l="soundVolumeSettings";class r{loadVolumeSettings(){try{let e=localStorage.getItem(l);if(e){let t=JSON.parse(e);void 0!==t.musicVolume?this.musicVolume=t.musicVolume:void 0!==t.exerciseVolume&&(this.musicVolume=t.exerciseVolume)}}catch(e){}}saveVolumeSettings(){try{let e=localStorage.getItem(l),t={...e?JSON.parse(e):{},musicVolume:this.musicVolume};localStorage.setItem(l,JSON.stringify(t))}catch(e){}}setMusicVolume(e){this.musicVolume=Math.max(0,Math.min(1,e)),this.saveVolumeSettings()}getMusicVolume(){return this.loadVolumeSettings(),this.musicVolume}setExerciseVolume(e){this.setMusicVolume(e)}getExerciseVolume(){return this.getMusicVolume()}setUserVolume(e){this.setMusicVolume(e)}getUserVolume(){return this.getMusicVolume()}static getInstance(){return r.instance||(r.instance=new r),r.instance}async loadSamples(){this.isInitialized||(await this.loadSoundType("piano"),this.currentSoundType="piano",this.updateNotesMapping(),this.isInitialized=!0,this.isLoaded=!0,(0,u.g)("audio_ready"))}async loadSoundType(e){if(this.loadedSounds.has(e))return;let t=s.N[e],i=t.spriteMap,o=new n.Howl({src:[t.filePath],sprite:i,volume:1,html5:!1,onload:()=>{},onloaderror:(e,i)=>{console.error("Failed to load ".concat(t.label," sound:"),i)},onplay:e=>{},onend:e=>{}});this.activeHowls.add(o),this.loadedSounds.set(e,o)}updateNotesMapping(){let e=this.loadedSounds.get(this.currentSoundType);if(!e)return;let t=s.N[this.currentSoundType].spriteMap;this.notes={},Object.keys(t).forEach(t=>{this.notes[t]=e})}async setSoundType(e){this.currentSoundType!==e&&(await this.loadSoundType(e),this.loadedSounds.has("piano")||await this.loadSoundType("piano"),this.stopAllSounds(),this.currentSoundType=e,this.updateNotesMapping())}getCurrentSoundType(){return this.currentSoundType}getAvailableSoundTypes(){return Object.keys(s.N)}getSoundConfig(e){return s.N[e]}ensureCompatibleForSequential(){let e=s.N[this.currentSoundType];if(e&&!e.suitableForSequential){let t=e.label;return this.setSoundType("piano").catch(()=>{}),t}return null}ensureInitialized(){this.isInitialized||this.initialize()}isAudioContextSuspended(){try{let e=null===n.Howler||void 0===n.Howler?void 0:n.Howler.ctx,t=null==e?void 0:e.state;return!!(e&&("suspended"===t||"interrupted"===t))}catch(e){return!1}}async tryResumeAudioContext(){try{let e=null===n.Howler||void 0===n.Howler?void 0:n.Howler.usingWebAudio,t=null===n.Howler||void 0===n.Howler?void 0:n.Howler.ctx,i=null==t?void 0:t.state;e&&t&&("suspended"===i||"interrupted"===i)&&await t.resume()}catch(e){}}mapFlatToSharp(e){let t=e.match(/([A-G])bb(\d+)/);if(t){let[i,n,o]=t,s={C:"A#",D:"C",E:"D",F:"D#",G:"F",A:"G",B:"A"}[n];if(s){let t;t="B"===n?parseInt(o):"C"===n?parseInt(o)-1:s.startsWith("B")?parseInt(o)-1:parseInt(o),e="".concat(s).concat(t.toString())}}let i={Cb:"B",Db:"C#",Eb:"D#",Fb:"E",Gb:"F#",Ab:"G#",Bb:"A#"},n=e.match(/([A-G]b?)(\d+)/);if(!n)return e;let[o,s,u]=n;if(s.includes("b")&&i[s]){let e=i[s],t=u;return t="Cb"===s?(parseInt(u)-1).toString():parseInt(u).toString(),"".concat(e).concat(t)}return e}stopSound(e){e.stop()}playNoteWithId(e){var t,i;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5;this.ensureInitialized();let o=e;if(e.includes("b"))o=this.mapFlatToSharp(e);else if(e.includes("##")||e.includes("x")){let t=e.match(/([A-G](##|x))(\d+)/);if(t){let[e,i,n,s]=t,u={"C##":"D",Cx:"D","D##":"E",Dx:"E","E##":"F#",Ex:"F#","F##":"G",Fx:"G","G##":"A",Gx:"A","A##":"B",Ax:"B","B##":"C#",Bx:"C#"}[i];if(u){let e="B##"===i||"Bx"===i?(parseInt(s)+1).toString():s;o="".concat(u).concat(e)}}}else if(e.match(/[EB]#\d/)){let t=e.match(/([EB]#)(\d+)/);if(t){let[e,i,n]=t,s="B#"===i?(parseInt(n)+1).toString():n;o="".concat("E#"===i?"F":"C").concat(s)}}let u=this.notes[o];if(u){u.volume(n*(null!==(t=s.N[this.currentSoundType].volumeScale)&&void 0!==t?t:1));let e=u.play(o),i="".concat(this.currentSoundType,"_").concat(o);return this.activeSoundIds.has(i)||this.activeSoundIds.set(i,[]),this.activeSoundIds.get(i).push(e),setTimeout(()=>{let t=this.activeSoundIds.get(i);if(t){let i=t.indexOf(e);i>-1&&t.splice(i,1)}},this.getCurrentSoundDuration()+100),{howl:u,id:e,noteKey:o}}if("stringEnsemble"===this.currentSoundType||"harp"===this.currentSoundType||"rhodes"===this.currentSoundType){let e=this.transposeToAvailableRange(o);if(e&&this.notes[e]){(u=this.notes[e]).volume(n*(null!==(i=s.N[this.currentSoundType].volumeScale)&&void 0!==i?i:1));let t=u.play(e),o="".concat(this.currentSoundType,"_").concat(e);return this.activeSoundIds.has(o)||this.activeSoundIds.set(o,[]),this.activeSoundIds.get(o).push(t),setTimeout(()=>{let e=this.activeSoundIds.get(o);if(e){let i=e.indexOf(t);i>-1&&e.splice(i,1)}},this.getCurrentSoundDuration()+100),{howl:u,id:t,noteKey:e}}return this.playPianoFallback(o,n)}return"piano"!==this.currentSoundType?this.playPianoFallback(o,n):null}getCurrentSoundDuration(){var e;let t=s.N[this.currentSoundType];return null!==(e=null==t?void 0:t.sampleDuration)&&void 0!==e?e:4e3}getCurrentChordSound(){return this.currentChordSound}stopAllNotes(){this.isInitialized&&Object.values(this.notes).forEac
1h(e=>{this.stopSound(e)})}stopAllSounds(){this.isInitialized&&("piano"===this.currentSoundType?Object.values(this.notes).forEach(e=>{this.stopSound(e)}):this.activeSoundIds.clear(),this.currentChordSound&&(this.stopSound(this.currentChordSound),this.currentChordSound.unload(),this.activeHowls.delete(this.currentChordSound),this.currentChordSound=null),this.currentSequenceTimeout&&(clearTimeout(this.currentSequenceTimeout),this.currentSequenceTimeout=null))}stopAllSoundsForced(){this.isInitialized&&(Object.values(this.notes).forEach(e=>{this.stopSound(e)}),this.currentChordSound&&(this.stopSound(this.currentChordSound),this.currentChordSound.unload(),this.activeHowls.delete(this.currentChordSound),this.currentChordSound=null),this.currentSequenceTimeout&&(clearTimeout(this.currentSequenceTimeout),this.currentSequenceTimeout=null),this.activeSoundIds.clear())}playChord(e){this.ensureInitialized(),this.currentChordSound&&(this.stopSound(this.currentChordSound),this.currentChordSound.unload(),this.activeHowls.delete(this.currentChordSound));let t=new n.Howl({src:[e],html5:!1,volume:.3,onload:()=>{},onloaderror:(e,t)=>{}});this.currentChordSound=t,this.activeHowls.add(t),t.play()}async waitForLoad(){return this.isLoaded?void 0:this.initializationPromise?this.initializationPromise:this.initialize()}initialize(){return this.isInitialized?Promise.resolve():(this.initializationPromise||(this.initializationPromise=this.loadSamples().then(()=>{}).catch(e=>{throw this.initializationPromise=null,e})),this.initializationPromise)}async waitForSpriteLoaded(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3e3,t=Date.now(),i=this.loadedSounds.get(this.currentSoundType);i&&(i.state&&"loaded"===i.state()||await new Promise(n=>{let o=()=>{try{if(i.state&&"loaded"===i.state()){n();return}}catch(e){}if(Date.now()-t>=e){n();return}setTimeout(o,50)};o()}))}softCleanup(){this.stopAllSounds(),this.currentChordSound&&(this.currentChordSound.unload(),this.activeHowls.delete(this.currentChordSound),this.currentChordSound=null),this.currentSequenceTimeout&&(clearTimeout(this.currentSequenceTimeout),this.currentSequenceTimeout=null),this.activeSoundIds.clear()}cleanup(){this.stopAllSoundsForced(),this.activeHowls.forEach(e=>{this.stopSound(e),e.unload()}),this.activeHowls.clear(),this.currentChordSound=null,this.loadedSounds.clear(),this.currentSequenceTimeout&&(clearTimeout(this.currentSequenceTimeout),this.currentSequenceTimeout=null),this.activeSoundIds.clear(),this.isInitialized=!1,this.isLoaded=!1,this.initializationPromise=null,this.currentSoundType="piano",this.notes={}}playPianoFallback(e,t){var i,n;let u=this.loadedSounds.get("piano");if(!u)return this.loadSoundType("piano").catch(()=>{}),null;let l=e;if(!o.n[l]){let e=l.match(/^([A-G]#?)(-?\d+)$/);if(!e)return null;let[,t,i]=e,n=parseInt(i,10),s=null;for(let e=1;e<=3&&!s;e++)for(let i of[-1,1]){let u="".concat(t).concat(n+i*e);if(o.n[u]){s=u;break}}if(!s)return null;l=s}u.volume(t);let r=u.play(l),a="piano_".concat(l);return this.activeSoundIds.has(a)||this.activeSoundIds.set(a,[]),this.activeSoundIds.get(a).push(r),setTimeout(()=>{let e=this.activeSoundIds.get(a);if(e){let t=e.indexOf(r);t>-1&&e.splice(t,1)}},(null!==(n=null===(i=s.N.piano)||void 0===i?void 0:i.sampleDuration)&&void 0!==n?n:4e3)+100),{howl:u,id:r,noteKey:l}}transposeToAvailableRange(e){if("stringEnsemble"!==this.currentSoundType&&"harp"!==this.currentSoundType&&"rhodes"!==this.currentSoundType&&"eguitar"!==this.currentSoundType)return null;let t=e.match(/([A-G]#?)(\d+)/);if(!t)return null;let[i,n,o]=t,u=parseInt(o),l,r,a=null,d=null;switch(this.currentSoundType){case"rhodes":case"stringEnsemble":case"harp":l=2,r=7;break;case"eguitar":l=2,r=5,a="E",d="E";break;default:l=1,r=7}if(u>=l&&u<=r)return e;let c=u;if(u<l&&(c=l),u>r&&(c=r),"eguitar"===this.currentSoundType){if(c===l&&a&&["C","C#","D","D#"].includes(n))return"".concat(a).concat(l);if(c===r&&d&&["F","F#","G","G#","A","A#","B","C","C#","D","D#"].includes(n))return"".concat(d).concat(r)}let h="".concat(n).concat(c);return s.N[this.currentSoundType].spriteMap[h]?h:null}constructor(){var e=this;this.notes={},this.currentChordSound=null,this.currentSequenceTimeout=null,this.isInitialized=!1,this.activeHowls=new Set,this.isLoaded=!1,this.initializationPromise=null,this.currentSoundType="piano",this.loadedSounds=new Map,this.activeSoundIds=new Map,this.musicVolume=.5,this.playNote=function(t){var i,n;let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5;e.ensureInitialized();let u=t;if(t.includes("b"))u=e.mapFlatToSharp(t);else if(t.includes("##")||t.includes("x")){let e=t.match(/([A-G](##|x))(\d+)/);if(e){let[t,i,n,o]=e,s={"C##":"D",Cx:"D","D##":"E",Dx:"E","E##":"F#",Ex:"F#","F##":"G",Fx:"G","G##":"A",Gx:"A","A##":"B",Ax:"B","B##":"C#",Bx:"C#"}[i];if(s){let e="B##"===i||"Bx"===i?parseInt(o)+1:o;u="".concat(s).concat(e)}}}else if(t.match(/[EB]#\d/)){let e=t.match(/([EB]#)(\d+)/);if(e){let t;let[i,n,o]=e;t="B#"===n?(parseInt(o)+1).toString():o,u="".concat("E#"===n?"F":"C").concat(t)}}let l=e.notes[u];if(l){l.volume(o*(null!==(i=s.N[e.currentSoundType].volumeScale)&&void 0!==i?i:1));let t=l.play(u),n="".concat(e.currentSoundType,"_").concat(u);e.activeSoundIds.has(n)||e.activeSoundIds.set(n,[]),e.activeSoundIds.get(n).push(t),setTimeout(()=>{let i=e.activeSoundIds.get(n);if(i){let e=i.indexOf(t);e>-1&&i.splice(e,1)}},e.getCurrentSoundDuration()+100)}else if("stringEnsemble"===e.currentSoundType||"harp"===e.currentSoundType||"rhodes"===e.currentSoundType){let t=e.transposeToAvailableRange(u);if(t&&e.notes[t]){let i=e.notes[t];i.volume(o*(null!==(n=s.N[e.currentSoundType].volumeScale)&&void 0!==n?n:1));let u=i.play(t),l="".concat(e.currentSoundType,"_").concat(t);e.activeSoundIds.has(l)||e.activeSoundIds.set(l,[]),e.activeSoundIds.get(l).push(u),setTimeout(()=>{let t=e.activeSoundIds.get(l);if(t){let e=t.indexOf(u);e>-1&&t.splice(e,1)}},e.getCurrentSoundDuration()+100)}else e.playPianoFallback(u,o)}else"piano"!==e.currentSoundType&&e.playPianoFallback(u,o)},this.playNoteSequence=function(t){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;e.ensureInitialized(),e.currentSequenceTimeout&&(clearTimeout(e.currentSequenceTimeout),e.currentSequenceTimeout=null);let s=.5*o;if(i)t.forEach(t=>e.playNote(t,s));else{let i=o=>{o<t.length&&(e.playNote(t[o],s),e.currentSequenceTimeout=setTimeout(()=>{i(o+1)},n))};i(0)}},this.playMusicNote=e=>{this.loadVolumeSettings(),this.playNote(e,this.musicVolume)},this.playMusicSequence=function(t){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500;e.loadVolumeSettings(),(0,u.g)("question_played"),e.playNoteSequence(t,i,n,e.musicVolume)},this.playExerciseNote=e=>{this.playMusicNote(e)},this.playExerciseSequence=function(t){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500;e.playMusicSequence(t,i,n)},this.playUserNote=e=>{this.playMusicNote(e)},this.playNotesFromSprite=function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5;if(e.ensureInitialized(),0===t.length)return;let n=e.loadedSounds.get(e.currentSoundType);n&&t.forEach(t=>{let o=t.includes("b")?e.mapFlatToSharp(t):t;if(e.notes[o]){let t=n.play(o);n.volume(i,t);let s="".concat(e.currentSoundType,"_").concat(o);e.activeSoundIds.has(s)||e.activeSoundIds.set(s,[]),e.activeSoundIds.get(s).push(t),setTimeout(()=>{let i=e.activeSoundIds.get(s);if(i){let e=i.indexOf(t);e>-1&&i.splice(e,1)}},e.getCurrentSoundDuration()+100)}})},this.playMusicNotesFromSprite=e=>{this.loadVolumeSettings(),this.playNotesFromSprite(e,this.musicVolume)},this.playExerciseNotesFromSprite=e=>{this.playMusicNotesFromSprite(e)},this.loadVolumeSettings()}}r.instance=null;let a=r.getInstance()},22479:(e,t,i)=>{i.d(t,{g:()=>o});let n=new Set;function o(e,t){if(!n.has(e)){n.add(e);try{fetch("/api/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({platform:"web",step:e,meta:null!=t?t:null}),keepalive:!0}
1).catch(()=>{n.delete(e)})}catch(t){n.delete(e)}}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.