UNPKG

opensheetmusicdisplay

Version:

An open source JavaScript engine for displaying MusicXML based on VexFlow.

2 lines 1.17 MB
/*! For license information please see opensheetmusicdisplay.min.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.opensheetmusicdisplay=e():t.opensheetmusicdisplay=e()}(this,(()=>(()=>{var t={67:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.SystemLinePosition=void 0,function(t){t[t.MeasureBegin=0]="MeasureBegin",t[t.MeasureEnd=1]="MeasureEnd"}(i||(e.SystemLinePosition=i={}))},98:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalGlissando=void 0;const s=i(9409),n=i(6438),r=i(6452);e.GraphicalGlissando=class{constructor(t){this.Glissando=t,this.staffEntries=[]}calculateLine(t){const e=this.staffEntries[0],i=this.staffEntries[this.staffEntries.length-1],o=e.findGraphicalNoteFromNote(this.Glissando.StartNote),a=i.findGraphicalNoteFromNote(this.Glissando.EndNote);if(!o&&!a)return;const l=e.parentMeasure.ParentStaffLine;let h,c,u,d;if(o&&e.parentMeasure.ParentStaffLine===this.StaffLine)h=o.PositionAndShape.RelativePosition.x+o.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+o.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x+t.GlissandoNoteOffset,u=o.PositionAndShape.AbsolutePosition.y;else{h=i.parentMeasure.beginInstructionsWidth-.4;const e=this.Glissando.Direction===n.ColDirEnum.Down?-1:1;u=a.PositionAndShape.AbsolutePosition.y+e*t.GlissandoStafflineStartYDistanceToNote}if(a&&i.parentMeasure.ParentStaffLine===this.StaffLine)c=a.PositionAndShape.RelativePosition.x+a.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+a.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x-.5-t.GlissandoNoteOffset,h>c&&(h=c-t.GlissandoStafflineStartMinimumWidth),d=a.PositionAndShape.AbsolutePosition.y;else{if(l.Measures.last().parentSourceMeasure.HasEndLine)return;c=l.PositionAndShape.Size.width,c-h>t.GlissandoStafflineEndOffset&&(h=c-t.GlissandoStafflineEndOffset);const e=this.Glissando.Direction===n.ColDirEnum.Down?1:-1;d=o.PositionAndShape.AbsolutePosition.y+e*t.GlissandoStafflineStartYDistanceToNote}const f=new s.PointF2D(h,u),m=new s.PointF2D(c,d);void 0===this.Width&&(this.Width=t.GlissandoDefaultWidth),this.Line=new r.GraphicalLine(f,m,this.Width)}}},164:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MidiInstrument=e.ClefEnum=e.ClefInstruction=void 0;const s=i(8233),n=i(5364),r=i(8233),o=i(8233),a=i(7307);class l extends n.AbstractNotationInstruction{constructor(t=h.G,e=0,i=2){super(void 0),this.clefType=h.G,this.line=2,this.octaveOffset=0,this.line=i,this.clefType=t,this.octaveOffset=e,this.calcParameters()}static getDefaultClefFromMidiInstrument(t){switch(t){case c.Acoustic_Grand_Piano:case c.Electric_Bass_finger:case c.Electric_Bass_pick:case c.Fretless_Bass:case c.Slap_Bass_1:case c.Slap_Bass_2:case c.Synth_Bass_1:case c.Synth_Bass_2:case c.Contrabass:return new l(h.F,0,4);default:return new l(h.G,0,2)}}static getAllPossibleClefs(){const t=[];for(let e=0;e<=2;e++){const i=new l(h.G,e,2);t.push(i)}for(let e=-2;e<=0;e++){const i=new l(h.F,e,4);t.push(i)}return t}static isSupportedClef(t){switch(t){case h.G:case h.F:case h.C:case h.percussion:case h.TAB:return!0;default:return!1}}get ClefType(){return this.clefType}set ClefType(t){this.clefType=t}get Line(){return this.line}set Line(t){this.line=t}get OctaveOffset(){return this.octaveOffset}set OctaveOffset(t){this.octaveOffset=t}get ClefPitch(){return this.clefPitch}set ClefPitch(t){this.clefPitch=t}get ReferenceCyPosition(){return this.referenceCyPosition}set ReferenceCyPosition(t){this.referenceCyPosition=t}Equals(t){return this===t||!(!this||!t)&&this.clefPitch===t.clefPitch&&this.Line===t.Line}NotEqual(t){return!this.Equals(t)}ToString(){return"ClefType: "+this.clefType}calcParameters(){switch(this.clefType){case h.G:this.clefPitch=new s.Pitch(r.NoteEnum.G,1+this.octaveOffset,o.AccidentalEnum.NONE),this.referenceCyPosition=5-this.line+2;break;case h.F:this.clefPitch=new s.Pitch(r.NoteEnum.F,0+this.octaveOffset,o.AccidentalEnum.NONE),this.referenceCyPosition=5-this.line+1.5;break;case h.C:this.clefPitch=new s.Pitch(r.NoteEnum.C,1+this.octaveOffset,o.AccidentalEnum.NONE),this.referenceCyPosition=5-this.line;break;case h.percussion:this.clefPitch=new s.Pitch(r.NoteEnum.C,2,o.AccidentalEnum.NONE),this.referenceCyPosition=2;break;case h.TAB:this.clefPitch=new s.Pitch(r.NoteEnum.G,0,o.AccidentalEnum.NONE),this.referenceCyPosition=0;break;default:throw new a.ArgumentOutOfRangeException("clefType")}}}var h,c;e.ClefInstruction=l,function(t){t[t.G=0]="G",t[t.F=1]="F",t[t.C=2]="C",t[t.percussion=3]="percussion",t[t.TAB=4]="TAB"}(h||(e.ClefEnum=h={})),function(t){t[t.None=-1]="None",t[t.Acoustic_Grand_Piano=0]="Acoustic_Grand_Piano",t[t.Bright_Acoustic_Piano=1]="Bright_Acoustic_Piano",t[t.Electric_Grand_Piano=2]="Electric_Grand_Piano",t[t.Honky_tonk_Piano=3]="Honky_tonk_Piano",t[t.Electric_Piano_1=4]="Electric_Piano_1",t[t.Electric_Piano_2=5]="Electric_Piano_2",t[t.Harpsichord=6]="Harpsichord",t[t.Clavinet=7]="Clavinet",t[t.Celesta=8]="Celesta",t[t.Glockenspiel=9]="Glockenspiel",t[t.Music_Box=10]="Music_Box",t[t.Vibraphone=11]="Vibraphone",t[t.Marimba=12]="Marimba",t[t.Xylophone=13]="Xylophone",t[t.Tubular_Bells=14]="Tubular_Bells",t[t.Dulcimer=15]="Dulcimer",t[t.Drawbar_Organ=16]="Drawbar_Organ",t[t.Percussive_Organ=17]="Percussive_Organ",t[t.Rock_Organ=18]="Rock_Organ",t[t.Church_Organ=19]="Church_Organ",t[t.Reed_Organ=20]="Reed_Organ",t[t.Accordion=21]="Accordion",t[t.Harmonica=22]="Harmonica",t[t.Tango_Accordion=23]="Tango_Accordion",t[t.Acoustic_Guitar_nylon=24]="Acoustic_Guitar_nylon",t[t.Acoustic_Guitar_steel=25]="Acoustic_Guitar_steel",t[t.Electric_Guitar_jazz=26]="Electric_Guitar_jazz",t[t.Electric_Guitar_clean=27]="Electric_Guitar_clean",t[t.Electric_Guitar_muted=28]="Electric_Guitar_muted",t[t.Overdriven_Guitar=29]="Overdriven_Guitar",t[t.Distortion_Guitar=30]="Distortion_Guitar",t[t.Guitar_harmonics=31]="Guitar_harmonics",t[t.Acoustic_Bass=32]="Acoustic_Bass",t[t.Electric_Bass_finger=33]="Electric_Bass_finger",t[t.Electric_Bass_pick=34]="Electric_Bass_pick",t[t.Fretless_Bass=35]="Fretless_Bass",t[t.Slap_Bass_1=36]="Slap_Bass_1",t[t.Slap_Bass_2=37]="Slap_Bass_2",t[t.Synth_Bass_1=38]="Synth_Bass_1",t[t.Synth_Bass_2=39]="Synth_Bass_2",t[t.Violin=40]="Violin",t[t.Viola=41]="Viola",t[t.Cello=42]="Cello",t[t.Contrabass=43]="Contrabass",t[t.Tremolo_Strings=44]="Tremolo_Strings",t[t.Pizzicato_Strings=45]="Pizzicato_Strings",t[t.Orchestral_Harp=46]="Orchestral_Harp",t[t.Timpani=47]="Timpani",t[t.String_Ensemble_1=48]="String_Ensemble_1",t[t.String_Ensemble_2=49]="String_Ensemble_2",t[t.Synth_Strings_1=50]="Synth_Strings_1",t[t.Synth_Strings_2=51]="Synth_Strings_2",t[t.Choir_Aahs=52]="Choir_Aahs",t[t.Voice_Oohs=53]="Voice_Oohs",t[t.Synth_Voice=54]="Synth_Voice",t[t.Orchestra_Hit=55]="Orchestra_Hit",t[t.Trumpet=56]="Trumpet",t[t.Trombone=57]="Trombone",t[t.Tuba=58]="Tuba",t[t.Muted_Trumpet=59]="Muted_Trumpet",t[t.French_Horn=60]="French_Horn",t[t.Brass_Section=61]="Brass_Section",t[t.Synth_Brass_1=62]="Synth_Brass_1",t[t.Synth_Brass_2=63]="Synth_Brass_2",t[t.Soprano_Sax=64]="Soprano_Sax",t[t.Alto_Sax=65]="Alto_Sax",t[t.Tenor_Sax=66]="Tenor_Sax",t[t.Baritone_Sax=67]="Baritone_Sax",t[t.Oboe=68]="Oboe",t[t.English_Horn=69]="English_Horn",t[t.Bassoon=70]="Bassoon",t[t.Clarinet=71]="Clarinet",t[t.Piccolo=72]="Piccolo",t[t.Flute=73]="Flute",t[t.Recorder=74]="Recorder",t[t.Pan_Flute=75]="Pan_Flute",t[t.Blown_Bottle=76]="Blown_Bottle",t[t.Shakuhachi=77]="Shakuhachi",t[t.Whistle=78]="Whistle",t[t.Ocarina=79]="Ocarina",t[t.Lead_1_square=80]="Lead_1_square",t[t.Lead_2_sawtooth=81]="Lead_2_sawtooth",t[t.Lead_3_calliope=82]="Lead_3_calliope",t[t.Lead_4_chiff=83]="Lead_4_chiff",t[t.Lead_5_charang=84]="Lead_5_charang",t[t.Lead_6_voice=85]="Lead_6_voice",t[t.Lead_7_fifths=86]="Lead_7_fifths",t[t.Lead_8_bass_lead=87]="Lead_8_bass_lead",t[t.Pad_1_new_age=88]="Pad_1_new_age",t[t.Pad_2_warm=89]="Pad_2_warm",t[t.Pad_3_polysynth=90]="Pad_3_polysynth",t[t.Pad_4_choir=91]="Pad_4_choir",t[t.Pad_5_bowed=92]="Pad_5_bowed",t[t.Pad_6_metallic=93]="Pad_6_metallic",t[t.Pad_7_halo=94]="Pad_7_halo",t[t.Pad_8_sweep=95]="Pad_8_sweep",t[t.FX_1_rain=96]="FX_1_rain",t[t.FX_2_soundtrack=97]="FX_2_soundtrack",t[t.FX_3_crystal=98]="FX_3_crystal",t[t.FX_4_atmosphere=99]="FX_4_atmosphere",t[t.FX_5_brightness=100]="FX_5_brightness",t[t.FX_6_goblins=101]="FX_6_goblins",t[t.FX_7_echoes=102]="FX_7_echoes",t[t.FX_8_scifi=103]="FX_8_scifi",t[t.Sitar=104]="Sitar",t[t.Banjo=105]="Banjo",t[t.Shamisen=106]="Shamisen",t[t.Koto=107]="Koto",t[t.Kalimba=108]="Kalimba",t[t.Bag_pipe=109]="Bag_pipe",t[t.Fiddle=110]="Fiddle",t[t.Shanai=111]="Shanai",t[t.Tinkle_Bell=112]="Tinkle_Bell",t[t.Agogo=113]="Agogo",t[t.Steel_Drums=114]="Steel_Drums",t[t.Woodblock=115]="Woodblock",t[t.Taiko_Drum=116]="Taiko_Drum",t[t.Melodic_Tom=117]="Melodic_Tom",t[t.Synth_Drum=118]="Synth_Drum",t[t.Reverse_Cymbal=119]="Reverse_Cymbal",t[t.Guitar_Fret_Noise=120]="Guitar_Fret_Noise",t[t.Breath_Noise=121]="Breath_Noise",t[t.Seashore=122]="Seashore",t[t.Bird_Tweet=123]="Bird_Tweet",t[t.Telephone_Ring=124]="Telephone_Ring",t[t.Helicopter=125]="Helicopter",t[t.Applause=126]="Applause",t[t.Gunshot=127]="Gunshot",t[t.Percussion=128]="Percussion"}(c||(e.MidiInstrument=c={}))},200:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RectangleF2D=void 0;const s=i(6864),n=i(9409);class r{constructor(t,e,i,s){this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=i,this.height=s}static createFromLocationAndSize(t,e){return new r(t.x,t.y,e.width,e.height)}get Location(){return new n.PointF2D(this.x,this.y)}get Size(){return new s.SizeF2D(this.width,this.height)}}e.RectangleF2D=r},242:(t,e)=>{"use strict";var i,s,n;Object.defineProperty(e,"__esModule",{value:!0}),e.PhonicScoreModes=e.MusicSymbolDrawingStyle=e.DrawingMode=void 0,function(t){t[t.All=0]="All",t[t.NoOverlays=1]="NoOverlays",t[t.Leadsheet=2]="Leadsheet"}(i||(e.DrawingMode=i={})),function(t){t[t.Normal=0]="Normal",t[t.Disabled=1]="Disabled",t[t.Selected=2]="Selected",t[t.Clickable=3]="Clickable",t[t.PlaybackSymbols=4]="PlaybackSymbols",t[t.FollowSymbols=5]="FollowSymbols",t[t.QFeedbackNotFound=6]="QFeedbackNotFound",t[t.QFeedbackOk=7]="QFeedbackOk",t[t.QFeedbackPerfect=8]="QFeedbackPerfect",t[t.Debug1=9]="Debug1",t[t.Debug2=10]="Debug2",t[t.Debug3=11]="Debug3"}(s||(e.MusicSymbolDrawingStyle=s={})),function(t){t[t.Following=0]="Following",t[t.Midi=1]="Midi",t[t.Manual=2]="Manual"}(n||(e.PhonicScoreModes=n={}))},298:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StaffLineActivitySymbol=void 0;const s=i(7741),n=i(6438);class r extends s.GraphicalObject{constructor(t){super(),this.parentStaffLine=t;const e=t.PositionAndShape;this.boundingBox=new n.BoundingBox(this,e),this.boundingBox.BorderRight=6,this.boundingBox.BorderBottom=4.5,this.boundingBox.BorderLeft=-1.5,this.boundingBox.BorderTop=-1.5}}e.StaffLineActivitySymbol=r},302:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(4127),e),n(i(9536),e),n(i(5984),e),n(i(6030),e),n(i(6302),e),n(i(7631),e),n(i(3186),e)},348:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalStaffEntry=void 0;const s=i(6438),n=i(2561),r=i(7741),o=i(813),a=i(7921);class l extends r.GraphicalObject{constructor(t,e=void 0,i=void 0){super(),this.graphicalChordContainers=[],this.tabStaffEntry=void 0,this.MaxAccidentals=0,this.graphicalInstructions=[],this.ties=[],this.graphicalTies=[],this.lyricsEntries=[],this.parentMeasure=t,this.graphicalVoiceEntries=[],this.sourceStaffEntry=e,i?(this.staffEntryParent=i,this.parentVerticalContainer=i.parentVerticalContainer,this.PositionAndShape=new s.BoundingBox(this,i.PositionAndShape)):this.PositionAndShape=new s.BoundingBox(this,t.PositionAndShape),e&&(this.relInMeasureTimestamp=e.Timestamp),this.FingeringEntries=[]}get GraphicalInstructions(){return this.graphicalInstructions}get GraphicalTies(){return this.graphicalTies}get LyricsEntries(){return this.lyricsEntries}set LyricsEntries(t){this.lyricsEntries=t}getAbsoluteTimestamp(){const t=this.parentMeasure.parentSourceMeasure.AbsoluteTimestamp.clone();return this.relInMeasureTimestamp&&t.Add(this.relInMeasureTimestamp),t}findTieGraphicalNoteFromNote(t){for(const e of this.graphicalVoiceEntries)for(const i of e.notes){const e=i.sourceNote;if(!e.isRest()&&e.Pitch.FundamentalNote===t.Pitch.FundamentalNote&&e.Pitch.Octave===t.Pitch.Octave&&e.getAbsoluteTimestamp().Equals(t.getAbsoluteTimestamp()))return i}}findEndTieGraphicalNoteFromNoteWithStartingSlur(t,e){if(t)for(const i of this.graphicalVoiceEntries)if(i.parentVoiceEntry===t.ParentVoiceEntry)for(const t of i.notes){const i=t.sourceNote;if(i.NoteTie&&-1!==i.NoteSlurs.indexOf(e))return t}}findGraphicalNoteFromGraceNote(t){if(t)for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t.ParentVoiceEntry)for(const i of e.notes)if(i.sourceNote===t)return i}findGraphicalNoteFromNote(t){if(t)for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t.ParentVoiceEntry)for(const i of e.notes)if(i.sourceNote===t&&this.getAbsoluteTimestamp().Equals(t.getAbsoluteTimestamp()))return i}getGraphicalNoteDurationFromVoice(t){for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry.ParentVoice===t)return e.notes[0].graphicalNoteLength;return new n.Fraction(0,1)}findVoiceEntryGraphicalNotes(t){for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t)return e.notes}isVoiceEntryPartOfLinkedVoiceEntry(t){if(this.sourceStaffEntry.Link)for(let e=0,i=this.sourceStaffEntry.Link.LinkStaffEntries.length;e<i;++e){const i=this.sourceStaffEntry.Link.LinkStaffEntries[e];if(-1!==i.VoiceEntries.indexOf(t)&&i!==this.sourceStaffEntry)return!0}return!1}findStaffEntryMinNoteLength(){let t=new n.Fraction(Number.MAX_VALUE,1);for(const e of this.graphicalVoiceEntries)for(const i of e.notes){const e=i.graphicalNoteLength;e.lt(t)&&e.GetExpandedNumerator()>0&&(t=e)}return t}findStaffEntryMaxNoteLength(){let t=new n.Fraction(0,1);for(const e of this.graphicalVoiceEntries)for(const i of e.notes){const e=i.graphicalNoteLength;t.lt(e)&&e.GetExpandedNumerator()>0&&(t=e)}return t}findOrCreateGraphicalVoiceEntry(t){for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t)return e;const e=a.MusicSheetCalculator.symbolFactory.createVoiceEntry(t,this);return this.graphicalVoiceEntries.push(e),e}findOrCreateGraphicalVoiceEntryFromGraphicalNote(t){for(const e of this.graphicalVoiceEntries)if(e===t.parentVoiceEntry)return e;const e=a.MusicSheetCalculator.symbolFactory.createVoiceEntry(t.sourceNote.ParentVoiceEntry,this);return this.graphicalVoiceEntries.push(e),e}addGraphicalNoteToListAtCorrectYPosition(t,e){const i=t.notes;if(0===i.length||e.PositionAndShape.RelativePosition.y<o.CollectionUtil.last(i).PositionAndShape.RelativePosition.y)i.push(e);else for(let t=i.length-1;t>=0;t--){if(i[t].PositionAndShape.RelativePosition.y>e.PositionAndShape.RelativePosition.y){i.splice(t+1,0,e);break}if(0===t){i.splice(0,0,e);break}}}hasOnlyRests(){return this.sourceStaffEntry.hasOnlyRests}getSkylineMin(){const t=this.parentMeasure?.ParentStaffLine.SkyBottomLineCalculator;if(!t)return;const[e,i]=this.getAbsoluteStartAndEnd();return t.getSkyLineMinInRange(e,i)}getHighestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getSkylineMin()}getLowestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getBottomlineMax()}getBottomlineMax(){const t=this.parentMeasure?.ParentStaffLine.SkyBottomLineCalculator;if(!t)return;const[e,i]=this.getAbsoluteStartAndEnd();return t.getBottomLineMaxInRange(e,i)}getAbsoluteStartAndEnd(){let t=this.PositionAndShape.AbsolutePosition.x;return t-=this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.x,[t,t+this.PositionAndShape.Size.width]}}e.GraphicalStaffEntry=l},363:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(8659),e)},427:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSheet=e.PlaybackSettings=void 0;const n=i(2561),r=i(9024),o=i(6001),a=i(7435),l=i(5534),h=i(8786),c=i(9713),u=i(2683),d=s(i(3065)),f=i(7533);class m{}e.PlaybackSettings=m;class p{constructor(){this.idString="uninitialized",this.sourceMeasures=[],this.repetitions=[],this.dynListStaves=[],this.timestampSortedDynamicExpressionsList=[],this.timestampSortedTempoExpressionsList=[],this.instrumentalGroups=[],this.instruments=[],this.musicPartManager=void 0,this.musicSheetErrors=new h.MusicSheetErrors,this.staves=[],this.transpose=0,this.defaultStartTempoInBpm=0,this.drawErroneousMeasures=!1,this.hasBeenOpenedForTheFirstTime=!1,this.currentEnrolledPosition=new n.Fraction(0,1),this.MeasureWidthFactor=1,this.playbackSettings=new m,this.playbackSettings.rhythm=new n.Fraction(4,4,0,!1),this.userStartTempoInBPM=100,this.pageWidth=120,this.MusicPartManager=new r.MusicPartManager(this),this.hasBPMInfo=!1}static getIndexFromStaff(t){return t.idInMusicSheet}get SourceMeasures(){return this.sourceMeasures}set SourceMeasures(t){this.sourceMeasures=t}get Repetitions(){return this.repetitions}set Repetitions(t){this.repetitions=t}get DynListStaves(){return this.dynListStaves}get TimestampSortedTempoExpressionsList(){return this.timestampSortedTempoExpressionsList}get TimestampSortedDynamicExpressionsList(){return this.timestampSortedDynamicExpressionsList}get InstrumentalGroups(){return this.instrumentalGroups}get Parts(){return this.instruments}get Instruments(){return this.instruments}get SheetPlaybackSetting(){return this.playbackSettings}set SheetPlaybackSetting(t){this.playbackSettings=t}get DrawErroneousMeasures(){return this.drawErroneousMeasures}set DrawErroneousMeasures(t){this.drawErroneousMeasures=t}get HasBeenOpenedForTheFirstTime(){return this.hasBeenOpenedForTheFirstTime}set HasBeenOpenedForTheFirstTime(t){this.hasBeenOpenedForTheFirstTime=t}InitializeStartTempoInBPM(t){this.userStartTempoInBPM=t}get DefaultStartTempoInBpm(){return this.defaultStartTempoInBpm}set DefaultStartTempoInBpm(t){this.defaultStartTempoInBpm=t,this.InitializeStartTempoInBPM(t)}get Path(){return this.path}set Path(t){this.path=t}get Staves(){return this.staves}get TitleString(){return this.title?this.title.text:""}set TitleString(t){this.Title=new a.Label(t)}get SubtitleString(){return this.subtitle?this.subtitle.text:""}set SubtitleString(t){this.Subtitle=new a.Label(t)}get ComposerString(){return this.composer?this.composer.text:""}set ComposerString(t){this.Composer=new a.Label(t)}get LyricistString(){return this.lyricist?this.lyricist.text:""}set LyricistString(t){this.Lyricist=new a.Label(t)}get CopyrightString(){return this.copyright?this.copyright.text:""}set CopyrightString(t){this.Copyright=new a.Label(t,f.TextAlignmentEnum.CenterBottom,void 0,!0)}get Title(){return this.title}set Title(t){this.title=t}get Subtitle(){return this.subtitle}set Subtitle(t){this.subtitle=t}get Composer(){return this.composer}set Composer(t){this.composer=t}get Lyricist(){return this.lyricist}set Lyricist(t){this.lyricist=t}get Copyright(){return this.copyright}set Copyright(t){this.copyright=t}get Rules(){return this.rules||(d.default.debug("warning: sheet.Rules was undefined. Creating new EngravingRules."),this.rules=new c.EngravingRules),this.rules}set Rules(t){this.rules=t}get SheetErrors(){return this.musicSheetErrors}get SelectionStart(){return this.selectionStart}set SelectionStart(t){this.selectionStart=t.clone(),this.currentEnrolledPosition=t.clone()}get SelectionEnd(){return this.selectionEnd}set SelectionEnd(t){this.selectionEnd=t}set HasBPMInfo(t){this.hasBPMInfo=t}get HasBPMInfo(){return this.hasBPMInfo}addMeasure(t){this.sourceMeasures.push(t),t.measureListIndex=this.sourceMeasures.length-1}checkForInstrumentWithNoVoice(){for(let t=0,e=this.instruments.length;t<e;++t){const e=this.instruments[t];if(0===e.Voices.length){const t=new l.Voice(e,1);e.Voices.push(t)}}}getStaffFromIndex(t){return this.staves[t]}fillStaffList(){let t=0;for(let e=0,i=this.instruments.length;e<i;++e){const i=this.instruments[e];for(let e=0,s=i.Staves.length;e<s;++e){const s=i.Staves[e];s.idInMusicSheet=t,this.staves.push(s),t++}}}get MusicPartManager(){return this.musicPartManager}set MusicPartManager(t){this.musicPartManager=t}getCompleteNumberOfStaves(){let t=0;for(let e=0,i=this.instruments.length;e<i;++e)t+=this.instruments[e].Staves.length;return t}getListOfMeasuresFromIndeces(t,e){const i=[];for(let s=t;s<=e;s++)i.push(this.sourceMeasures[s]);return i}getNextSourceMeasure(t){const e=this.sourceMeasures.indexOf(t);return e===this.sourceMeasures.length-1?t:this.sourceMeasures[e+1]}getFirstSourceMeasure(){return this.sourceMeasures[0]}getLastSourceMeasure(){return this.sourceMeasures[this.sourceMeasures.length-1]}resetAllNoteStates(){const t=this.MusicPartManager.getIterator();for(;!t.EndReached&&t.CurrentVoiceEntries;){for(let e=0,i=t.CurrentVoiceEntries.length;e<i;++e){const i=t.CurrentVoiceEntries[e];for(let t=0,e=i.Notes.length;t<e;++t)i.Notes[t].state=u.NoteState.Normal}t.moveToNext()}}getMusicSheetInstrumentIndex(t){return this.Instruments.indexOf(t)}getGlobalStaffIndexOfFirstStaff(t){const e=this.getMusicSheetInstrumentIndex(t);let i=0;for(let t=0;t<e;t++)i+=this.Instruments[t].Staves.length;return i}setRepetitionNewUserNumberOfRepetitions(t,e){let i=0;for(let s=0;s<this.repetitions.length;s++)if(this.repetitions[s]instanceof o.Repetition){if(t===i){this.repetitions[s].UserNumberOfRepetitions=e;break}i++}}getRepetitionByIndex(t){let e=0;for(let i=0;i<this.repetitions.length;i++)if(this.repetitions[i]instanceof o.Repetition){if(t===e)return this.repetitions[i];e++}}CompareTo(t){return this.Title.text.localeCompare(t.Title.text)}getExpressionsStartTempoInBPM(){if(this.TimestampSortedTempoExpressionsList.length>0){const t=this.TimestampSortedTempoExpressionsList[0];if(t.InstantaneousTempo)return t.InstantaneousTempo.TempoInBpm;if(t.ContinuousTempo)return t.ContinuousTempo.StartTempo}return this.userStartTempoInBPM}get Errors(){return this.musicSheetErrors.measureErrors}get FirstMeasureNumber(){try{return this.getFirstSourceMeasure().MeasureNumber}catch(t){return d.default.info("MusicSheet.FirstMeasureNumber: ",t),0}}get LastMeasureNumber(){try{return this.getLastSourceMeasure().MeasureNumber}catch(t){return d.default.info("MusicSheet.LastMeasureNumber: ",t),0}}get CurrentEnrolledPosition(){return this.currentEnrolledPosition.clone()}set CurrentEnrolledPosition(t){this.currentEnrolledPosition=t.clone()}get Transpose(){return this.transpose}set Transpose(t){this.transpose=t}get FullNameString(){return this.ComposerString+" "+this.TitleString}get IdString(){return this.idString}set IdString(t){this.idString=t}getEnrolledSelectionStartTimeStampWorkaround(){const t=this.MusicPartManager.getIterator(this.SelectionStart);return n.Fraction.createFromFraction(t.CurrentEnrolledTimestamp)}get SheetEndTimestamp(){const t=this.getLastSourceMeasure();return n.Fraction.plus(t.AbsoluteTimestamp,t.Duration)}getSourceMeasureFromTimeStamp(t){for(let e=0,i=this.sourceMeasures.length;e<i;++e){const i=this.sourceMeasures[e];for(let e=0,s=i.VerticalSourceStaffEntryContainers.length;e<s;++e){const s=i.VerticalSourceStaffEntryContainers[e];if(t.Equals(s.getAbsoluteTimestamp()))return i}}return this.findSourceMeasureFromTimeStamp(t)}findSourceMeasureFromTimeStamp(t){for(const e of this.sourceMeasures)if(e.AbsoluteTimestamp.lte(t)&&t.lt(n.Fraction.plus(e.AbsoluteTimestamp,e.Duration)))return e}getVisibleInstruments(){const t=[];for(let e=0,i=this.Instruments.length;e<i;++e){const i=this.Instruments[e];i.Voices.length>0&&i.Voices[0].Visible&&t.push(i)}return t}}e.MusicSheet=p,p.defaultTitle="defaultTitle"},437:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OctaveEnum=e.OctaveShift=void 0;const s=i(8233);var n;e.OctaveShift=class{constructor(t,e){this.numberXml=1,this.setOctaveShiftValue(t,e)}get Type(){return this.octaveValue}set Type(t){this.octaveValue=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get ParentStartMultiExpression(){return this.startMultiExpression}set ParentStartMultiExpression(t){this.startMultiExpression=t}get ParentEndMultiExpression(){return this.endMultiExpression}set ParentEndMultiExpression(t){this.endMultiExpression=t}setOctaveShiftValue(t,e){this.octaveValue=1===e&&"down"===t?n.VA8:1===e&&"up"===t?n.VB8:2===e&&"down"===t?n.MA15:2===e&&"up"===t?n.MB15:n.NONE}static getPitchFromOctaveShift(t,e){if(!t)return;if(t.OctaveShiftApplied)return t;let i=t.Octave;switch(e){case n.VA8:i-=1;break;case n.VB8:i+=1;break;case n.MA15:i-=2;break;case n.MB15:i+=2;break;case n.NONE:default:i+=0}const r=new s.Pitch(t.FundamentalNote,i,t.Accidental);return r.OctaveShiftApplied=!0,r}},function(t){t[t.VA8=0]="VA8",t[t.VB8=1]="VB8",t[t.MA15=2]="MA15",t[t.MB15=3]="MB15",t[t.NONE=4]="NONE"}(n||(e.OctaveEnum=n={}))},469:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VoiceGenerator=void 0;const n=i(4249),r=i(5534),o=i(1336),a=i(1850),l=i(2369),h=i(8365),c=i(5274),u=i(2257),d=i(4268),f=i(2561),m=i(2148),p=i(6030),g=i(7307),b=i(8233),S=i(8233),y=i(6644),E=s(i(3065)),x=i(8233),v=i(813),_=i(4127),M=i(4064),w=i(4236),P=i(5282),T=i(9647),L=i(6362);e.VoiceGenerator=class{constructor(t,e,i,s,o=void 0){this.openBeams=[],this.beamNumberOffset=0,this.currentOctaveShift=0,this.tupletDict={},this.openTupletNumber=0,this.staff=e,this.instrument=e.ParentInstrument,this.musicSheet=this.instrument.GetMusicSheet,this.slurReader=s,this.pluginManager=t,this.voice=o?new n.LinkedVoice(this.instrument,i,o):new r.Voice(this.instrument,i),this.instrument.Voices.push(this.voice),this.staff.Voices.push(this.voice),this.lyricsReader=new p.LyricsReader(this.musicSheet),this.articulationReader=new _.ArticulationReader(this.musicSheet.Rules)}get openTieDict(){return this.staff.openTieDict}get GetVoice(){return this.voice}get OctaveShift(){return this.currentOctaveShift}set OctaveShift(t){this.currentOctaveShift=t}createVoiceEntry(t,e,i,s=!1,n=!1,r=!1){this.currentVoiceEntry=new o.VoiceEntry(t.clone(),this.voice,e,s,n,r),i&&this.voice.VoiceEntries.push(this.currentVoiceEntry)}read(t,e,i,s,n,r,o,a,l,h,c,d,f,p,g,b,S,y,x,v,_){this.currentStaffEntry=o,this.currentMeasure=a;try{this.currentNote=r?this.addRestNote(t.element("rest"),e,s,i,n,f,p,x):this.addSingleNote(t,e,s,i,n,c,d,f,p,g,b,S,y,x,v),this.currentNote.DotsXml=_;const o=t.elements("lyric");void 0!==this.lyricsReader&&o&&(this.lyricsReader.addLyricEntry(o,this.currentVoiceEntry),this.voice.Parent.HasLyrics=!0);let a=!1;const m=t.element("notations");if(m){this.articulationReader&&this.readArticulations(m,this.currentVoiceEntry,this.currentNote);const e=m.elements("slur"),i=m.elements("slide"),s=m.elements("glissando");void 0!==this.slurReader&&(e.length>0||i.length>0)&&!this.currentNote.ParentVoiceEntry.IsGrace&&(this.slurReader.addSlur(e,this.currentNote),i.length>0&&this.slurReader.addSlur(i,this.currentNote),s.length>0&&this.slurReader.addSlur(s,this.currentNote));const n=m.elements("tuplet");n.length>0&&(this.openTupletNumber=this.addTuplet(t,n),a=!0);const r=m.element("arpeggiate");if(void 0!==r){let t;if(this.currentVoiceEntry.Arpeggio)t=this.currentVoiceEntry.Arpeggio;else{let e=!1;for(const i of this.currentStaffEntry.VoiceEntries)if(i.Arpeggio){e=!0,t=i.Arpeggio;break}if(!e){let e=w.ArpeggioType.ARPEGGIO_DIRECTIONLESS;const i=r.attribute("direction");if(i)switch(i.value){case"up":e=w.ArpeggioType.ROLL_UP;break;case"down":e=w.ArpeggioType.ROLL_DOWN;break;default:e=w.ArpeggioType.ARPEGGIO_DIRECTIONLESS}t=new w.Arpeggio(this.currentVoiceEntry,e),this.currentVoiceEntry.Arpeggio=t}}t.addNote(this.currentNote)}const o=m.elements("tied");o.length>0&&this.addTie(o,l,h,u.TieTypes.SIMPLE);const c=m.element("technical");if(c){const t=c.elements("hammer-on");t.length>0&&this.addTie(t,l,h,u.TieTypes.HAMMERON);const e=c.elements("pull-off");e.length>0&&this.addTie(e,l,h,u.TieTypes.PULLOFF)}}void 0===t.element("time-modification")||a||this.handleTimeModificationNode(t)}catch(t){E.default.warn(t);const e=m.ITextTranslation.translateText("ReaderErrorMessages/NoteError","Ignored erroneous Note.");this.musicSheet.SheetErrors.pushMeasureError(e),this.musicSheet.SheetErrors.pushMeasureError(t)}return this.currentNote}checkForStaffEntryLink(t,e,i,s){const n=new y.StaffEntryLink(this.currentVoiceEntry);n.LinkStaffEntries.push(i),i.Link=n;const r=this.currentVoiceEntry.Timestamp.clone(),o=s.getVerticalContainerByTimestamp(r);return(i=o.StaffEntries[t])||(i=new l.SourceStaffEntry(o,e),o.StaffEntries[t]=i),i.VoiceEntries.push(this.currentVoiceEntry),n.LinkStaffEntries.push(i),i.Link=n,i}checkForOpenBeam(){this.openBeams.length>0&&this.currentNote&&this.handleOpenBeam()}checkOpenTies(){const t=this.openTieDict;for(const e in t)if(t.hasOwnProperty(e)){const i=t[e];f.Fraction.plus(i.StartNote.ParentStaffEntry.Timestamp,i.Duration).lt(i.StartNote.SourceMeasure.Duration)&&delete t[e]}}hasVoiceEntry(){return void 0!==this.currentVoiceEntry}readArticulations(t,e,i){const s=t.element("articulations");s&&this.articulationReader.addArticulationExpression(s,e);const n=t.element("fermata");n&&this.articulationReader.addFermata(n,e);const r=t.element("technical");r&&this.articulationReader.addTechnicalArticulations(r,e,i);const o=t.element("ornaments");o&&this.articulationReader.addOrnament(o,e)}addSingleNote(t,e,i,s,n,r,l,h,c,u,d,p,y,v,_){let w,P,L,A,C=0,R=b.AccidentalEnum.NONE,N=S.NoteEnum.C,I=S.NoteEnum.C,B=0,F=0;const D=t.elements();for(let t=0,e=D.length;t<e;++t){const e=D[t];try{if("pitch"===e.name){const t=e.elements();for(let e=0,i=t.length;e<i;++e){const i=t[e];L=void 0,A=void 0;try{if("step"===i.name){if(N=S.NoteEnum[i.value],void 0===N){const t=m.ITextTranslation.translateText("ReaderErrorMessages/NotePitchError","Invalid pitch while reading note.");throw this.musicSheet.SheetErrors.pushMeasureError(t),new g.MusicSheetReadingException(t,void 0)}}else if("alter"===i.name){if(C=parseFloat(i.value),isNaN(C)){const t=m.ITextTranslation.translateText("ReaderErrorMessages/NoteAlterationError","Invalid alteration while reading note.");throw this.musicSheet.SheetErrors.pushMeasureError(t),new g.MusicSheetReadingException(t,void 0)}R=x.Pitch.AccidentalFromHalfTones(C)}else if("octave"===i.name&&(B=parseInt(i.value,10),isNaN(B))){const t=m.ITextTranslation.translateText("ReaderErrorMessages/NoteOctaveError","Invalid octave value while reading note.");throw this.musicSheet.SheetErrors.pushMeasureError(t),new g.MusicSheetReadingException(t,void 0)}}catch(t){E.default.info("VoiceGenerator.addSingleNote read Step: ",t.message)}}}else if("accidental"===e.name)w=e.value,"natural"===w?R=b.AccidentalEnum.NATURAL:"slash-flat"===w?R=b.AccidentalEnum.SLASHFLAT:"slash-quarter-sharp"===w?R=b.AccidentalEnum.SLASHQUARTERSHARP:"slash-sharp"===w?R=b.AccidentalEnum.SLASHSHARP:"double-slash-flat"===w?R=b.AccidentalEnum.DOUBLESLASHFLAT:"sori"===w?R=b.AccidentalEnum.SORI:"koron"===w&&(R=b.AccidentalEnum.KORON);else if("unpitched"===e.name){const t=e.element("display-step"),i=e.element("display-octave");if(i&&(B=parseInt(i.value,10),F=B-3,l&&(B+=1),1===this.instrument.Staves[0].StafflineCount&&(F+=1)),t){N=S.NoteEnum[t.value.toUpperCase()];let e=0,i=this.musicSheet.Rules.PercussionXMLDisplayStepNoteValueShift;1===this.instrument.Staves[0].StafflineCount&&(i-=3),[I,e]=x.Pitch.lineShiftFromNoteEnum(N,i),F+=e}}else"instrument"===e.name?e.firstAttribute&&(P=e.firstAttribute.value):"notehead"===e.name&&(L=e.value,e.attribute("filled")&&(A="yes"===e.attribute("filled").value))}catch(t){E.default.info("VoiceGenerator.addSingleNote: ",t)}}B-=x.Pitch.OctaveXmlDifference;const O=new x.Pitch(N,B,R,w),k=f.Fraction.createFromFraction(e);let V,G=-1,W=-1;const U=[],z=t.element("notations");if(z){const t=z.element("technical");if(t){const e=t.element("string");e&&(G=parseInt(e.value,10));const i=t.element("fret");i&&(W=parseInt(i.value,10)),t.elements("bend").forEach((function(t){const e=t.element("bend-alter");void 0!==t.element("release")?U.push({bendalter:parseInt(e.value,10),direction:"down"}):U.push({bendalter:parseInt(e.value,10),direction:"up"})}))}}return V=G<0||W<0?new a.Note(this.currentVoiceEntry,this.currentStaffEntry,k,O,this.currentMeasure):new T.TabNote(this.currentVoiceEntry,this.currentStaffEntry,k,O,this.currentMeasure,G,W,U,_),this.addNoteInfo(V,i,h,c,n,I,F,v,v),V.TypeLength=s,V.IsGraceNote=u,V.StemDirectionXml=d,V.TremoloInfo=p,V.PlaybackInstrumentId=P,(void 0!==L&&"normal"!==L||void 0!==A)&&(V.Notehead=new M.Notehead(V,L,A)),d===o.StemDirectionType.None&&(y="#00000000"),this.currentVoiceEntry.Notes.push(V),this.currentVoiceEntry.StemDirectionXml=d,y&&(this.currentVoiceEntry.StemColorXml=y,this.currentVoiceEntry.StemColor=y,V.StemColorXml=y),t.elements("beam")&&!r&&this.createBeam(t,V),V}addRestNote(t,e,i,s,n,r,o,l){const h=f.Fraction.createFromFraction(e),c=t.element("display-step"),u=t.element("display-octave");let d,m,p;c&&u&&(d=S.NoteEnum[c.value.toUpperCase()],m=parseInt(u.value,10),p=new x.Pitch(d,m,b.AccidentalEnum.NONE,void 0,!0));const g=new a.Note(this.currentVoiceEntry,this.currentStaffEntry,h,p,this.currentMeasure,!0);return this.addNoteInfo(g,i,r,o,n,d,m,l,l),g.TypeLength=s,this.currentVoiceEntry.Notes.push(g),this.openBeams.length>0&&this.openBeams.last().ExtendedNoteList.push(g),g}addNoteInfo(t,e,i,s,n,r,o,a,l){t.NoteTypeXml=e,t.PrintObject=i,t.IsCueNote=s,t.NormalNotes=n,t.displayStepUnpitched=r,t.displayOctaveUnpitched=o,t.NoteheadColorXml=a,t.NoteheadColor=a}createBeam(t,e){try{const i=t.element("beam");let s;if(void 0!==i&&i.hasAttributes&&(s=i.attribute("number")),s){let i=parseInt(s.value,10);const n=t.elements("beam"),r=n[0].value;n&&("begin"===r?(i===this.openBeams.last()?.BeamNumber?(this.beamNumberOffset++,i+=this.beamNumberOffset):this.openBeams.last()&&this.handleOpenBeam(),this.openBeams.push(new h.Beam(i,this.beamNumberOffset))):i+=this.beamNumberOffset);let o=!1;if(!(i>0&&i<=this.openBeams.length&&this.openBeams[i-1]))return void E.default.debug("[OSMD] invalid beamnumber");for(let t=0,e=this.openBeams[i-1].Notes.length;t<e;++t){const e=this.openBeams[i-1].Notes[t];this.currentVoiceEntry===e.ParentVoiceEntry&&(o=!0)}o||(this.openBeams[i-1].addNoteToBeam(e),"end"===r&&this.endBeam())}}catch(t){const e=m.ITextTranslation.translateText("ReaderErrorMessages/BeamError","Error while reading beam.");throw this.musicSheet.SheetErrors.pushMeasureError(e),new g.MusicSheetReadingException("",t)}}endBeam(){this.openBeams.pop(),this.beamNumberOffset=Math.max(0,this.beamNumberOffset-1)}handleOpenBeam(){const t=this.openBeams.last();if(0!==t.Notes.length){if(1===t.Notes.length)return t.Notes[0].NoteBeam=void 0,void this.endBeam();if(this.currentNote===v.CollectionUtil.last(t.Notes))this.endBeam();else{const e=v.CollectionUtil.last(t.Notes).ParentStaffEntry,i=this.currentMeasure.getVerticalContainerIndexByTimestamp(e.Timestamp),s=e.VerticalContainerParent.StaffEntries.indexOf(e);if(i<this.currentMeasure.VerticalSourceStaffEntryContainers.length-1){const t=this.currentMeasure.VerticalSourceStaffEntryContainers[i+1].StaffEntries[s];if(t)for(let e=0,i=t.VoiceEntries.length;e<i;++e){const i=t.VoiceEntries[e];if(i.ParentVoice===this.voice){const t=i.Notes[0];t.Length.lte(new f.Fraction(1,8))?(this.openBeams.last().addNoteToBeam(t),this.endBeam()):this.endBeam()}}}else this.endBeam()}}else this.endBeam()}addTuplet(t,e){let i,s=!1;if(void 0!==e&&e.length>1){let n=t.element("time-modification");n&&(n=n.element("actual-notes"));const r=e;for(let e=0,a=r.length;e<a;++e){const a=r[e];if(void 0!==a&&a.attributes()){const e=a.attribute("bracket");e&&"yes"===e.value?(s=!0,i=!0):e&&"no"===e.value&&(i=!1);const r=this.readShowNumberNoneGiven(a),l=a.attribute("type");if(l&&"start"===l.value){let e=1;a.attribute("number")&&(e=parseInt(a.attribute("number").value,10));let o=0;if(n&&(o=parseInt(n.value,10),isNaN(o))){const t=m.ITextTranslation.translateText("ReaderErrorMessages/TupletNoteDurationError","Invalid tuplet note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(t),new g.MusicSheetReadingException(t,void 0)}const l=new d.Tuplet(o,s);l.BracketedXmlValue=i,l.ShowNumberNoneGivenInXml=r,l.tupletLabelNumberPlacement=L.PlacementEnum.Above;const h=a.attribute("placement");h&&("below"===h.value&&(l.tupletLabelNumberPlacement=L.PlacementEnum.Below),l.PlacementFromXml=!0),this.tupletDict[e]&&(delete this.tupletDict[e],0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--),this.tupletDict[e]=l;const c=[];c.push(this.currentNote),l.Notes.push(c),l.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=l,this.openTupletNumber=e}else if("stop"===l.value){let e=1;a.attribute("number")&&(e=parseInt(a.attribute("number").value,10));const i=this.tupletDict[e];if(i){const s=a.attribute("placement");s&&("below"===s.value?i.tupletLabelNumberPlacement=L.PlacementEnum.Below:i.tupletLabelNumberPlacement=L.PlacementEnum.Above,i.PlacementFromXml=!0);const n=[];if(n.push(this.currentNote),i.Notes.push(n),!i.PlacementFromXml){let t=!1;for(const e of i.Notes){for(const s of e)if(!s.isRest()){s.StemDirectionXml===o.StemDirectionType.Down?i.tupletLabelNumberPlacement=L.PlacementEnum.Below:i.tupletLabelNumberPlacement=L.PlacementEnum.Above,t=!0;break}if(t)break}}i.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=i,delete this.tupletDict[e],0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--}}}}}else if(e[0]){const n=e[0];if(n.hasAttributes){const e=n.attribute("type").value;let r=1;n.attribute("number")&&(r=parseInt(n.attribute("number").value,10));const a=isNaN(r),l=this.readShowNumberNoneGiven(n),h=n.attribute("bracket");if(h&&"yes"===h.value?(s=!0,i=!0):h&&"no"===h.value&&(i=!1),"start"===e){let e=0,o=t.element("time-modification");if(o&&(o=o.element("actual-notes")),o&&(e=parseInt(o.value,10),isNaN(e))){const t=m.ITextTranslation.translateText("ReaderErrorMessages/TupletNoteDurationError","Invalid tuplet note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(t),new g.MusicSheetReadingException(t)}a&&(this.openTupletNumber++,r=this.openTupletNumber);let h=this.tupletDict[r];h||(h=this.tupletDict[r]=new d.Tuplet(e,s),h.BracketedXmlValue=i,h.ShowNumberNoneGivenInXml=l,h.tupletLabelNumberPlacement=L.PlacementEnum.Above);const c=n.attribute("placement");c&&("below"===c.value?h.tupletLabelNumberPlacement=L.PlacementEnum.Below:h.tupletLabelNumberPlacement=L.PlacementEnum.Above,h.PlacementFromXml=!0);const u=[];u.push(this.currentNote),h.Notes.push(u),h.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=h,this.openTupletNumber=r}else if("stop"===e){a&&(r=this.openTupletNumber);const e=this.tupletDict[this.openTupletNumber];if(e){const i=n.attribute("placement");i&&("below"===i.value?e.tupletLabelNumberPlacement=L.PlacementEnum.Below:e.tupletLabelNumberPlacement=L.PlacementEnum.Above,e.PlacementFromXml=!0);const s=[];if(s.push(this.currentNote),e.Notes.push(s),!e.PlacementFromXml){let t=!1;for(const i of e.Notes){for(const s of i)if(!s.isRest()){s.StemDirectionXml===o.StemDirectionType.Down?e.tupletLabelNumberPlacement=L.PlacementEnum.Below:e.tupletLabelNumberPlacement=L.PlacementEnum.Above,t=!0;break}if(t)break}}e.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=e,0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--,delete this.tupletDict[r]}}}}return this.openTupletNumber}readShowNumberNoneGiven(t){const e=t.attribute("show-number");return!(!e?.value||"none"!==e.value)}handleTimeModificationNode(t){if(this.tupletDict[this.openTupletNumber])try{const e=this.tupletDict[this.openTupletNumber],i=v.CollectionUtil.last(e.Notes);let s;i[0].ParentVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)?s=i:(s=[],e.Notes.push(s),e.Fractions.push(this.getTupletNoteDurationFromType(t))),s.push(this.currentNote),this.currentNote.NoteTuplet=e}catch(t){const e=m.ITextTranslation.translateText("ReaderErrorMessages/TupletNumberError","Invalid tuplet number.");throw this.musicSheet.SheetErrors.pushMeasureError(e),t}else if(this.currentVoiceEntry.Notes.length>0){const t=this.currentVoiceEntry.Notes[0];if(t.NoteTuplet){const e=t.NoteTuplet;v.CollectionUtil.last(e.Notes).push(this.currentNote),this.currentNote.NoteTuplet=e}}}addTie(t,e,i,s){if(t)if(1===t.length){const e=t[0];if(void 0!==e&&e.attributes()){const t=this.getTieDirection(e),i=e.attribute("type").value;try{if("start"===i){const e=this.findCurrentNoteInTieDict(this.currentNote);e<0&&delete this.openTieDict[e];const i=this.getNextAvailableNumberForTie(),n=new c.Tie(this.currentNote,s);this.openTieDict[i]=n,n.TieNumber=i,n.TieDirection=t}else if("stop"===i){const t=this.findCurrentNoteInTieDict(this.currentNote),e=this.openTieDict[t];e&&(e.AddNote(this.currentNote),delete this.openTieDict[t])}}catch(t){const e=m.ITextTranslation.translateText("ReaderErrorMessages/TieError","Error while reading tie.");this.musicSheet.SheetErrors.pushMeasureError(e)}}}else if(2===t.length){const e=this.findCurrentNoteInTieDict(this.currentNote);if(e>=0){const i=this.openTieDict[e];i.AddNote(this.currentNote);for(const e of t)if("start"===e.attribute("type").value){const t=this.getTieDirection(e);i.NoteIndexToTieDirection[i.Notes.length-1]=t}}}}getTieDirection(t){let e=L.PlacementEnum.NotYetDefined;const i=t.attribute("placement");i&&("above"===i.value?e=L.PlacementEnum.Above:"below"===i.value&&(e=L.PlacementEnum.Below));const s=t.attribute("orientation");return s&&("over"===s.value?e=L.PlacementEnum.Above:"under"===s.value&&(e=L.PlacementEnum.Below)),e}getNextAvailableNumberForTie(){const t=Object.keys(this.openTieDict);if(0===t.length)return 1;t.sort(((t,e)=>+t-+e));for(let e=0;e<t.length;e++)if(""+(e+1)!==t[e])return e+1;return+t[t.length-1]+1}findCurrentNoteInTieDict(t){const e=this.openTieDict;for(const i in e)if(e.hasOwnProperty(i)){const s=e[i],n=s.Notes[0],r=t;if(s.Pitch.FundamentalNote===t.Pitch.FundamentalNote&&s.Pitch.Octave===t.Pitch.Octave)return parseInt(i,10);if(void 0!==n.StringNumberTab&&n.StringNumberTab===r.StringNumberTab)return parseInt(i,10)}return-1}getTupletNoteDurationFromType(t){if(t.element("type")){const e=t.element("type");if(e){const t=e.value;try{return P.NoteTypeHandler.getNoteDurationFromType(t)}catch(t){const e=m.ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError","Invalid note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(e),new g.MusicSheetReadingException("",t)}}}}}},474:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicPartManagerIterator=void 0;const n=i(2561),r=i(1110),o=i(9288),a=i(5875),l=s(i(3065));class h{constructor(t,e,i){this.currentMeasureIndex=0,this.currentPartIndex=0,this.currentVoiceEntryIndex=-1,this.currentDynamicEntryIndex=0,this.currentTempoEntryIndex=0,this.currentDynamicChangingExpressions=[],this.currentRepetition=void 0,this.endReached=!1,this.frontReached=!1,this.currentTimeStamp=new n.Fraction(0,1),this.currentEnrolledMeasureTimestamp=new n.Fraction(0,1),this.currentRelativeInMeasureTimestamp=new n.Fraction(0,1),this.currentVerticalContainerInMeasureTimestamp=new n.Fraction(0,1),this.jumpResponsibleRepetition=void 0,this.activeDynamicExpressions=[],this.SkipInvisibleNotes=!0;try{this.frontReached=!0,this.musicSheet=t,this.currentVoiceEntries=void 0,this.frontReached=!1;for(const t of this.musicSheet.Repetitions)this.setRepetitionIterationCount(t,1);if(this.activeDynamicExpressions=new Array(this.musicSheet.getCompleteNumberOfStaves()),this.currentMeasure=this.musicSheet.SourceMeasures[0],!e)return;do{this.moveToNext()}while((!this.currentVoiceEntries||this.currentTimeStamp.lt(e))&&!this.endReached);for(let t=0;t<this.activeDynamicExpressions.length;t++)if(this.activeDynamicExpressions[t])if(this.activeDynamicExpressions[t]instanceof a.ContinuousDynamicExpression){const e=this.activeDynamicExpressions[t];this.currentDynamicChangingExpressions.push(new r.DynamicsContainer(e,t))}else{const e=this.activeDynamicExpressions[t];this.currentDynamicChangingExpressions.push(new r.DynamicsContainer(e,t))}this.currentTempoChangingExpression=this.activeTempoExpression}catch(t){l.default.info("MusicPartManagerIterator: "+t)}}get EndReached(){return this.endReached}get FrontReached(){return this.frontReached}get CurrentMeasure(){return this.currentMeasure}get CurrentRepetition(){return this.currentRepetition}get CurrentRepetitionIteration(){return this.CurrentRepetition?this.getRepetitionIterationCount(this.CurrentRepetition):0}get CurrentJumpResponsibleRepetitionIterationBeforeJump(){return this.jumpResponsibleRepetition?this.getRepetitionIterationCount(this.jumpResponsibleRepetition)-1:0}get CurrentBpm(){return this.currentBpm}get CurrentVoiceEntries(){return this.currentVoiceEntries}get CurrentMeasureIndex(){return this.currentMeasureIndex}get CurrentEnrolledTimestamp(){return n.Fraction.plus(this.currentEnrolledMeasureTimestamp,this.currentVerticalContainerInMeasureTimestamp)}get CurrentSourceTimestamp(){return this.currentTimeStamp}get CurrentRelativeInMeasureTimestamp(){return this.currentRelativeInMeasureTimestamp}get JumpOccurred(){return this.backJumpOccurred||this.forwardJumpOccurred}get ActiveTempoExpression(){return this.activeTempoExpression}get ActiveDynamicExpressions(){return this.activeDynamicExpressions}get CurrentTempoChangingExpression(){return this.currentTempoChangingExpression}get JumpResponsibleRepetition(){return this.jumpResponsibleRepetition}clone(t=void 0,e=void 0){const i=new h(this.musicSheet,t??this.currentTimeStamp,e);return i.currentVoiceEntryIndex=this.currentVoiceEntryIndex,i.currentMappingPart=this.currentMappingPart,i.currentPartIndex=this.currentPartIndex,i.currentVoiceEntries=this.currentVoiceEntries,i.endReached=this.endReached,i.frontReached=this.frontReached,i}CurrentVisibleVoiceEntries(t){const e=[];if(!this.currentVoiceEntries)return e;if(t){for(const i of this.currentVoiceEntries)i.ParentVoice.Parent.IdString===t.IdString&&this.getVisibleEntries(i,e);return e}for(const t of this.currentVoiceEntries)this.getVisibleEntries(t,e);return e}CurrentAudibleVoiceEntries(t){const e=[];if(!this.currentVoiceEntries)return e;if(t){for(const i of this.currentVoiceEntries)if(i.ParentVoice.Parent.IdString===t.IdString)return this.getAudibleEntries(i,e),e}else for(const t of this.currentVoiceEntries)this.getAudibleEntries(t,e);return e}getCurrentDynamicChangingExpressions(){return this.currentDynamicChangingExpressions}CurrentScoreFollowingVoiceEntries(t){const e=[];if(!this.currentVoiceEntries)return e;if(t){for(const i of this.currentVoiceEntries)if(i.ParentVoice.Parent.IdString===t.IdString)return this.getScoreFollowingEntries(i,e),e}else for(const t of this.currentVoiceEntries)this.getScoreFollowingEntries(t,e);return e}moveToPrevious(){this.frontReached||(this.currentVoiceEntries&&(this.currentVoiceEntries=[]),this.recursiveMoveBack())}moveToPreviousVisibleVoiceEntry(t){for(;!this.frontReached;)if(this.moveToPrevious(),this.checkEntries(t))return}moveToNext(){this.forwardJumpOccurred=this.backJumpOccurred=!1,this.endReached||(this.frontReached&&(this.frontReached=!1,this.currentVoiceEntryIndex=-1),this.currentVoiceEntries&&(this.currentVoiceEntries=[]),this.recursiveMove(),this.currentMeasure||(this.currentTimeStamp=new n.Fraction(99999,1),this.currentMeasure=this.musicSheet.SourceMeasures.last()))}moveToNextVisibleVoiceEntry(t){for(;!this.endReached;)if(this.moveToNext(),this.checkEntries(t))return}resetRepetitionIterationCount(t){return this.setRepetitionIterationCount(t,1),1}incrementRepetitionIterationCount(t){return-1===this.repetitionIterationCountDictKeys.indexOf(t)?this.setRepetitionIterationCount(t,1):this.setRepetitionIterationCount(t,this.getRepetitionIterationCount(t)+1)}setRepetitionIterationCount(t,e){const i=this.repetitionIterationCountDictKeys.indexOf(t);return-1===i?(this.repetitionIterationCountDictKeys.push(t),this.repetitionIterationCountDictValues.push(e)):this.repetitionIterationCountDictValues[i]=e,e}getRepetitionIterationCount(t){const e=this.repetitionIterationCountDictKeys.indexOf(t);if(-1!==e)return this.repetitionIterationCountDictValues[e]}handleRepetitionsAtMeasureBegin(){for(let t=0,e=this.currentMeasure.FirstRepetitionInstructions.length;t<e;++t){const e=this.currentMeasure.FirstRepetitionInstructions[t];if(!e.parentRepetition)continue;const i=e.parentR