@tspro/web-music-score 3.1.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +35 -7
  2. package/README.md +189 -331
  3. package/dist/audio/index.d.ts +1 -1
  4. package/dist/audio/index.js +1 -1
  5. package/dist/audio/index.mjs +2 -2
  6. package/dist/audio-cg/index.js +1 -1
  7. package/dist/audio-cg/index.mjs +2 -2
  8. package/dist/{chunk-PU4J7K4Z.mjs → chunk-D643HZHM.mjs} +2 -2
  9. package/dist/core/index.js +2 -2
  10. package/dist/core/index.mjs +3 -3
  11. package/dist/{guitar-C2Cp71NZ.d.ts → guitar-cNmE-EvH.d.ts} +1 -1
  12. package/dist/iife/index.global.js +11 -11
  13. package/dist/{interface-Fn8ufBQx.d.ts → interface-7k8qGG44.d.ts} +131 -83
  14. package/dist/{interface-Bz_525zj.d.mts → interface-XoKiryoV.d.mts} +130 -82
  15. package/dist/{note-BFa43I86.d.ts → note-CcVdUFqS.d.ts} +1 -1
  16. package/dist/pieces/index.d.mts +2 -2
  17. package/dist/pieces/index.d.ts +3 -3
  18. package/dist/pieces/index.js +4 -7
  19. package/dist/pieces/index.mjs +8 -11
  20. package/dist/react-ui/index.d.mts +3 -3
  21. package/dist/react-ui/index.d.ts +5 -5
  22. package/dist/react-ui/index.js +1 -1
  23. package/dist/react-ui/index.mjs +2 -2
  24. package/dist/{scale-DRR-t4Kr.d.mts → scale-C2pCNxdE.d.mts} +4 -3
  25. package/dist/{scale-ebJm37q1.d.ts → scale-CvPbJvfN.d.ts} +5 -4
  26. package/dist/score/index.d.mts +98 -31
  27. package/dist/score/index.d.ts +99 -32
  28. package/dist/score/index.js +922 -599
  29. package/dist/score/index.mjs +929 -606
  30. package/dist/tempo-BAYoZ_Li.d.mts +187 -0
  31. package/dist/tempo-r2sb6Ku2.d.ts +187 -0
  32. package/dist/theory/index.d.mts +3 -3
  33. package/dist/theory/index.d.ts +6 -6
  34. package/dist/theory/index.js +221 -78
  35. package/dist/theory/index.mjs +218 -76
  36. package/package.json +2 -2
  37. package/dist/tempo-B4h5Ktob.d.mts +0 -104
  38. package/dist/tempo-DgqDEsn0.d.ts +0 -104
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v3.1.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v4.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  "use strict";
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
@@ -361,22 +361,22 @@ var DivRect = class _DivRect {
361
361
  };
362
362
 
363
363
  // src/score/pub/document-builder.ts
364
- var import_ts_utils_lib11 = require("@tspro/ts-utils-lib");
364
+ var import_ts_utils_lib13 = require("@tspro/ts-utils-lib");
365
365
 
366
366
  // src/score/pub/types.ts
367
- var StaffPreset = /* @__PURE__ */ ((StaffPreset4) => {
368
- StaffPreset4[StaffPreset4["Treble"] = 1] = "Treble";
369
- StaffPreset4[StaffPreset4["Bass"] = 2] = "Bass";
370
- StaffPreset4[StaffPreset4["Grand"] = 3] = "Grand";
371
- StaffPreset4[StaffPreset4["GuitarTreble"] = 4] = "GuitarTreble";
372
- StaffPreset4[StaffPreset4["GuitarTab"] = 8] = "GuitarTab";
373
- StaffPreset4[StaffPreset4["GuitarCombined"] = 12] = "GuitarCombined";
374
- return StaffPreset4;
367
+ var StaffPreset = /* @__PURE__ */ ((StaffPreset3) => {
368
+ StaffPreset3["Treble"] = "treble";
369
+ StaffPreset3["Bass"] = "bass";
370
+ StaffPreset3["Grand"] = "grand";
371
+ StaffPreset3["GuitarTreble"] = "guitarTreble";
372
+ StaffPreset3["GuitarTab"] = "guitarTab";
373
+ StaffPreset3["GuitarCombined"] = "guitarCombined";
374
+ return StaffPreset3;
375
375
  })(StaffPreset || {});
376
- var Clef = /* @__PURE__ */ ((Clef3) => {
377
- Clef3["G"] = "G";
378
- Clef3["F"] = "F";
379
- return Clef3;
376
+ var Clef = /* @__PURE__ */ ((Clef2) => {
377
+ Clef2["G"] = "G";
378
+ Clef2["F"] = "F";
379
+ return Clef2;
380
380
  })(Clef || {});
381
381
  function getVoiceIds() {
382
382
  return [0, 1, 2, 3];
@@ -384,78 +384,78 @@ function getVoiceIds() {
384
384
  function getStringNumbers() {
385
385
  return [1, 2, 3, 4, 5, 6];
386
386
  }
387
- var Stem = /* @__PURE__ */ ((Stem3) => {
388
- Stem3[Stem3["Auto"] = 0] = "Auto";
389
- Stem3[Stem3["Up"] = 1] = "Up";
390
- Stem3[Stem3["Down"] = 2] = "Down";
391
- return Stem3;
387
+ var Stem = /* @__PURE__ */ ((Stem2) => {
388
+ Stem2["Auto"] = "auto";
389
+ Stem2["Up"] = "up";
390
+ Stem2["Down"] = "down";
391
+ return Stem2;
392
392
  })(Stem || {});
393
393
  var Arpeggio = /* @__PURE__ */ ((Arpeggio2) => {
394
- Arpeggio2[Arpeggio2["Up"] = 0] = "Up";
395
- Arpeggio2[Arpeggio2["Down"] = 1] = "Down";
394
+ Arpeggio2["Up"] = "up";
395
+ Arpeggio2["Down"] = "down";
396
396
  return Arpeggio2;
397
397
  })(Arpeggio || {});
398
- var TieType = /* @__PURE__ */ ((TieType3) => {
399
- TieType3[TieType3["Stub"] = -1] = "Stub";
400
- TieType3[TieType3["ToMeasureEnd"] = -2] = "ToMeasureEnd";
401
- return TieType3;
398
+ var TieType = /* @__PURE__ */ ((TieType2) => {
399
+ TieType2["Stub"] = "stub";
400
+ TieType2["ToMeasureEnd"] = "toMeasureEnd";
401
+ return TieType2;
402
402
  })(TieType || {});
403
403
  var NoteAnchor = /* @__PURE__ */ ((NoteAnchor2) => {
404
- NoteAnchor2[NoteAnchor2["Auto"] = 0] = "Auto";
405
- NoteAnchor2[NoteAnchor2["Above"] = 1] = "Above";
406
- NoteAnchor2[NoteAnchor2["Center"] = 2] = "Center";
407
- NoteAnchor2[NoteAnchor2["Below"] = 3] = "Below";
408
- NoteAnchor2[NoteAnchor2["StemTip"] = 4] = "StemTip";
404
+ NoteAnchor2["Auto"] = "auto";
405
+ NoteAnchor2["Above"] = "above";
406
+ NoteAnchor2["Center"] = "center";
407
+ NoteAnchor2["Below"] = "below";
408
+ NoteAnchor2["StemTip"] = "stemTip";
409
409
  return NoteAnchor2;
410
410
  })(NoteAnchor || {});
411
- var Connective = /* @__PURE__ */ ((Connective3) => {
412
- Connective3[Connective3["Tie"] = 0] = "Tie";
413
- Connective3[Connective3["Slur"] = 1] = "Slur";
414
- Connective3[Connective3["Slide"] = 2] = "Slide";
415
- return Connective3;
411
+ var Connective = /* @__PURE__ */ ((Connective2) => {
412
+ Connective2["Tie"] = "tie";
413
+ Connective2["Slur"] = "slur";
414
+ Connective2["Slide"] = "slide";
415
+ return Connective2;
416
416
  })(Connective || {});
417
417
  var VerticalPosition = /* @__PURE__ */ ((VerticalPosition4) => {
418
- VerticalPosition4[VerticalPosition4["Above"] = 0] = "Above";
419
- VerticalPosition4[VerticalPosition4["Below"] = 1] = "Below";
420
- VerticalPosition4[VerticalPosition4["Both"] = 2] = "Both";
421
- VerticalPosition4[VerticalPosition4["Auto"] = 3] = "Auto";
418
+ VerticalPosition4["Auto"] = "auto";
419
+ VerticalPosition4["Above"] = "above";
420
+ VerticalPosition4["Below"] = "below";
421
+ VerticalPosition4["Both"] = "both";
422
422
  return VerticalPosition4;
423
423
  })(VerticalPosition || {});
424
+ var Fermata = /* @__PURE__ */ ((Fermata2) => {
425
+ Fermata2["AtNote"] = "atNote";
426
+ Fermata2["AtMeasureEnd"] = "atMeasureEnd";
427
+ return Fermata2;
428
+ })(Fermata || {});
429
+ var Navigation = /* @__PURE__ */ ((Navigation2) => {
430
+ Navigation2["DC_al_Fine"] = "D.C. al Fine";
431
+ Navigation2["DC_al_Coda"] = "D.C. al Coda";
432
+ Navigation2["DS_al_Fine"] = "D.S. al Fine";
433
+ Navigation2["DS_al_Coda"] = "D.S. al Coda";
434
+ Navigation2["Coda"] = "Coda";
435
+ Navigation2["toCoda"] = "toCoda";
436
+ Navigation2["Segno"] = "Segno";
437
+ Navigation2["Fine"] = "Fine";
438
+ Navigation2["StartRepeat"] = "startRepeat";
439
+ Navigation2["EndRepeat"] = "endRepeat";
440
+ Navigation2["Ending"] = "ending";
441
+ return Navigation2;
442
+ })(Navigation || {});
443
+ var Annotation = /* @__PURE__ */ ((Annotation2) => {
444
+ Annotation2["Dynamics"] = "dynamics";
445
+ Annotation2["Tempo"] = "tempo";
446
+ return Annotation2;
447
+ })(Annotation || {});
448
+ var Label = /* @__PURE__ */ ((Label2) => {
449
+ Label2["Note"] = "note";
450
+ Label2["Chord"] = "chord";
451
+ return Label2;
452
+ })(Label || {});
424
453
  var PlayState = /* @__PURE__ */ ((PlayState2) => {
425
454
  PlayState2[PlayState2["Playing"] = 0] = "Playing";
426
455
  PlayState2[PlayState2["Paused"] = 1] = "Paused";
427
456
  PlayState2[PlayState2["Stopped"] = 2] = "Stopped";
428
457
  return PlayState2;
429
458
  })(PlayState || {});
430
- var Fermata = /* @__PURE__ */ ((Fermata3) => {
431
- Fermata3[Fermata3["AtNote"] = 0] = "AtNote";
432
- Fermata3[Fermata3["AtMeasureEnd"] = 1] = "AtMeasureEnd";
433
- return Fermata3;
434
- })(Fermata || {});
435
- var Navigation = /* @__PURE__ */ ((Navigation3) => {
436
- Navigation3[Navigation3["DC_al_Fine"] = 0] = "DC_al_Fine";
437
- Navigation3[Navigation3["DC_al_Coda"] = 1] = "DC_al_Coda";
438
- Navigation3[Navigation3["DS_al_Fine"] = 2] = "DS_al_Fine";
439
- Navigation3[Navigation3["DS_al_Coda"] = 3] = "DS_al_Coda";
440
- Navigation3[Navigation3["Coda"] = 4] = "Coda";
441
- Navigation3[Navigation3["toCoda"] = 5] = "toCoda";
442
- Navigation3[Navigation3["Segno"] = 6] = "Segno";
443
- Navigation3[Navigation3["Fine"] = 7] = "Fine";
444
- Navigation3[Navigation3["StartRepeat"] = 8] = "StartRepeat";
445
- Navigation3[Navigation3["EndRepeat"] = 9] = "EndRepeat";
446
- Navigation3[Navigation3["Ending"] = 10] = "Ending";
447
- return Navigation3;
448
- })(Navigation || {});
449
- var Annotation = /* @__PURE__ */ ((Annotation3) => {
450
- Annotation3[Annotation3["Dynamics"] = 0] = "Dynamics";
451
- Annotation3[Annotation3["Tempo"] = 1] = "Tempo";
452
- return Annotation3;
453
- })(Annotation || {});
454
- var Label = /* @__PURE__ */ ((Label3) => {
455
- Label3[Label3["Note"] = 0] = "Note";
456
- Label3[Label3["Chord"] = 1] = "Chord";
457
- return Label3;
458
- })(Label || {});
459
459
 
460
460
  // src/score/engine/music-object.ts
461
461
  var MusicObjectLink = class {
@@ -954,10 +954,10 @@ var Renderer = class {
954
954
 
955
955
  // src/score/engine/obj-staff-and-tab.ts
956
956
  var import_core15 = require("@tspro/web-music-score/core");
957
- var import_ts_utils_lib9 = require("@tspro/ts-utils-lib");
957
+ var import_ts_utils_lib11 = require("@tspro/ts-utils-lib");
958
958
 
959
959
  // src/score/engine/obj-measure.ts
960
- var import_ts_utils_lib8 = require("@tspro/ts-utils-lib");
960
+ var import_ts_utils_lib10 = require("@tspro/ts-utils-lib");
961
961
  var import_theory9 = require("@tspro/web-music-score/theory");
962
962
  var import_theory10 = require("@tspro/web-music-score/theory");
963
963
 
@@ -1546,7 +1546,7 @@ var ObjSignature = class extends MusicObject {
1546
1546
  };
1547
1547
 
1548
1548
  // src/score/engine/player.ts
1549
- var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
1549
+ var import_ts_utils_lib6 = require("@tspro/ts-utils-lib");
1550
1550
  var import_theory7 = require("@tspro/web-music-score/theory");
1551
1551
  var Audio = __toESM(require("@tspro/web-music-score/audio"));
1552
1552
 
@@ -1576,8 +1576,8 @@ var ObjArpeggio = class extends MusicObject {
1576
1576
  }
1577
1577
  layout(renderer) {
1578
1578
  let { unitSize } = renderer;
1579
- this.topArrowHeight = this.arpeggioDir === 0 /* Up */ ? unitSize : 0;
1580
- this.bottomArrowHeight = this.arpeggioDir === 1 /* Down */ ? unitSize : 0;
1579
+ this.topArrowHeight = this.arpeggioDir === "up" /* Up */ ? unitSize : 0;
1580
+ this.bottomArrowHeight = this.arpeggioDir === "down" /* Down */ ? unitSize : 0;
1581
1581
  let top = this.line.getTopLineY();
1582
1582
  let bottom = this.line.getBottomLineY();
1583
1583
  this.cycleHeight = unitSize * 2;
@@ -1643,7 +1643,7 @@ var ObjStaffRest = class extends MusicObject {
1643
1643
  this.staff = staff;
1644
1644
  this.rest = rest;
1645
1645
  __publicField(this, "restRect", new DivRect());
1646
- __publicField(this, "dotRect");
1646
+ __publicField(this, "dotRects", []);
1647
1647
  __publicField(this, "mi");
1648
1648
  staff.addObject(this);
1649
1649
  this.mi = new MStaffRest(this);
@@ -1655,21 +1655,18 @@ var ObjStaffRest = class extends MusicObject {
1655
1655
  return this.getRect().contains(x, y) ? [this] : [];
1656
1656
  }
1657
1657
  offset(dx, dy) {
1658
- var _a;
1659
1658
  this.restRect.offsetInPlace(dx, dy);
1660
- (_a = this.dotRect) == null ? void 0 : _a.offsetInPlace(dx, dy);
1659
+ this.dotRects.forEach((r) => r.offsetInPlace(dx, dy));
1661
1660
  this.requestRectUpdate();
1662
1661
  this.rest.requestRectUpdate();
1663
1662
  }
1664
1663
  updateRect() {
1665
1664
  this.rect = this.restRect.copy();
1666
- if (this.dotRect) {
1667
- this.rect.expandInPlace(this.dotRect);
1668
- }
1665
+ this.dotRects.forEach((r) => this.rect.expandInPlace(r));
1669
1666
  }
1670
1667
  };
1671
1668
  var ObjRest = class extends MusicObject {
1672
- constructor(col, voiceId, noteLength, options) {
1669
+ constructor(col, voiceId, noteLength, options, tupletRatio) {
1673
1670
  var _a, _b;
1674
1671
  super(col);
1675
1672
  this.col = col;
@@ -1678,6 +1675,7 @@ var ObjRest = class extends MusicObject {
1678
1675
  __publicField(this, "ownDiatonicId");
1679
1676
  __publicField(this, "color");
1680
1677
  __publicField(this, "hide");
1678
+ __publicField(this, "oldStyleTriplet");
1681
1679
  __publicField(this, "rhythmProps");
1682
1680
  __publicField(this, "beamGroup");
1683
1681
  __publicField(this, "staffObjects", []);
@@ -1701,7 +1699,9 @@ var ObjRest = class extends MusicObject {
1701
1699
  }
1702
1700
  this.color = (_a = options == null ? void 0 : options.color) != null ? _a : "black";
1703
1701
  this.hide = (_b = options == null ? void 0 : options.hide) != null ? _b : false;
1704
- this.rhythmProps = new import_theory3.RhythmProps(noteLength, options == null ? void 0 : options.dotted, options == null ? void 0 : options.triplet);
1702
+ this.oldStyleTriplet = tupletRatio === void 0 && ((options == null ? void 0 : options.triplet) === true || import_theory3.NoteLengthProps.get(noteLength).isTriplet);
1703
+ let dotCount = typeof (options == null ? void 0 : options.dotted) === "number" ? options.dotted > 0 ? options.dotted : void 0 : (options == null ? void 0 : options.dotted) === true ? 1 : void 0;
1704
+ this.rhythmProps = import_theory3.RhythmProps.get(noteLength, dotCount, (tupletRatio != null ? tupletRatio : this.oldStyleTriplet) ? import_theory3.Tuplet.Triplet : void 0);
1705
1705
  this.mi = new MRest(this);
1706
1706
  }
1707
1707
  getMusicInterface() {
@@ -1719,15 +1719,9 @@ var ObjRest = class extends MusicObject {
1719
1719
  get noteLength() {
1720
1720
  return this.rhythmProps.noteLength;
1721
1721
  }
1722
- get dotted() {
1723
- return this.rhythmProps.dotted;
1724
- }
1725
1722
  get stemDir() {
1726
1723
  return this.beamGroup ? this.beamGroup.stemDir : this.ownStemDir;
1727
1724
  }
1728
- get triplet() {
1729
- return this.rhythmProps.triplet;
1730
- }
1731
1725
  getStaticObjects(line) {
1732
1726
  let staticObjects = [];
1733
1727
  this.staffObjects.forEach((obj) => {
@@ -1747,13 +1741,13 @@ var ObjRest = class extends MusicObject {
1747
1741
  return [this, ...arr];
1748
1742
  }
1749
1743
  }
1750
- return [this];
1744
+ return [];
1751
1745
  }
1752
1746
  getBeamGroup() {
1753
1747
  return this.beamGroup;
1754
1748
  }
1755
- setBeamGroup(beam) {
1756
- this.beamGroup = beam;
1749
+ setBeamGroup(beamGroup) {
1750
+ this.beamGroup = beamGroup;
1757
1751
  }
1758
1752
  resetBeamGroup() {
1759
1753
  this.beamGroup = void 0;
@@ -1762,7 +1756,7 @@ var ObjRest = class extends MusicObject {
1762
1756
  return this.staffObjects.map((obj) => {
1763
1757
  let staff = obj.staff;
1764
1758
  let x = obj.getRect().centerX;
1765
- let y = this.stemDir === 1 /* Up */ ? obj.getRect().top : obj.getRect().bottom;
1759
+ let y = this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
1766
1760
  let stemHeight = Math.abs(obj.getRect().centerY - y);
1767
1761
  return { staff, x, y, stemHeight };
1768
1762
  });
@@ -1803,7 +1797,7 @@ var ObjRest = class extends MusicObject {
1803
1797
  }
1804
1798
  let { unitSize } = renderer;
1805
1799
  let { ownDiatonicId } = this;
1806
- let { noteLength, dotted, flagCount } = this.rhythmProps;
1800
+ let { noteLength, dotCount, flagCount } = this.rhythmProps;
1807
1801
  let leftw = 0;
1808
1802
  let rightw = 0;
1809
1803
  let toph = 0;
@@ -1836,11 +1830,11 @@ var ObjRest = class extends MusicObject {
1836
1830
  }
1837
1831
  let obj = new ObjStaffRest(staff, this);
1838
1832
  obj.restRect = new DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
1839
- if (dotted) {
1833
+ for (let i = 0; i < dotCount; i++) {
1840
1834
  let dotWidth = DocumentSettings.DotSize * unitSize;
1841
- let dotX = rightw + (DocumentSettings.RestDotSpace + DocumentSettings.DotSize / 2) * unitSize;
1835
+ let dotX = rightw + (DocumentSettings.RestDotSpace + DocumentSettings.DotSize * unitSize) + i * DocumentSettings.DotSize * unitSize * 1.5;
1842
1836
  let dotY = this.getRestDotVerticalDisplacement(noteLength) * unitSize;
1843
- obj.dotRect = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
1837
+ obj.dotRects.push(DivRect.createCentered(dotX, dotY, dotWidth, dotWidth));
1844
1838
  }
1845
1839
  obj.offset(0, staff.getDiatonicIdY(ownDiatonicId));
1846
1840
  this.staffObjects.push(obj);
@@ -1874,7 +1868,7 @@ var ObjRest = class extends MusicObject {
1874
1868
  ctx.strokeStyle = ctx.fillStyle = color;
1875
1869
  ctx.lineWidth = lineWidth;
1876
1870
  this.staffObjects.forEach((obj) => {
1877
- let { dotRect, restRect } = obj;
1871
+ let { dotRects, restRect } = obj;
1878
1872
  let x = restRect.centerX;
1879
1873
  let y = restRect.centerY;
1880
1874
  if (noteLength === import_theory3.NoteLength.Whole) {
@@ -1939,9 +1933,9 @@ var ObjRest = class extends MusicObject {
1939
1933
  ctx.fill();
1940
1934
  }
1941
1935
  }
1942
- if (dotRect) {
1943
- renderer.fillCircle(dotRect.centerX, dotRect.centerY, dotRect.width / 2);
1944
- }
1936
+ dotRects.forEach((r) => {
1937
+ renderer.fillCircle(r.centerX, r.centerY, r.width / 2);
1938
+ });
1945
1939
  });
1946
1940
  }
1947
1941
  };
@@ -1989,8 +1983,8 @@ var ObjStaffBeamGroup = class extends MusicObject {
1989
1983
  super(staff);
1990
1984
  this.staff = staff;
1991
1985
  this.beamGroup = beamGroup;
1992
- __publicField(this, "tripletNumber");
1993
- __publicField(this, "tripletNumberOffsetY", 0);
1986
+ __publicField(this, "tupletNumber");
1987
+ __publicField(this, "tupletNumberOffsetY", 0);
1994
1988
  __publicField(this, "points", []);
1995
1989
  __publicField(this, "mi");
1996
1990
  staff.addObject(this);
@@ -2005,48 +1999,47 @@ var ObjStaffBeamGroup = class extends MusicObject {
2005
1999
  offset(dx, dy) {
2006
2000
  var _a;
2007
2001
  this.points.forEach((p) => p.offset(dx, 0));
2008
- (_a = this.tripletNumber) == null ? void 0 : _a.offset(dx, dy);
2002
+ (_a = this.tupletNumber) == null ? void 0 : _a.offset(dx, dy);
2009
2003
  this.requestRectUpdate();
2010
2004
  this.beamGroup.requestRectUpdate();
2011
2005
  }
2012
2006
  updateRect() {
2013
2007
  if (this.points.length > 0) {
2014
2008
  this.rect = this.points[0].getRect().copy();
2015
- } else if (this.tripletNumber) {
2016
- this.rect = this.tripletNumber.getRect().copy();
2009
+ } else if (this.tupletNumber) {
2010
+ this.rect = this.tupletNumber.getRect().copy();
2017
2011
  }
2018
2012
  this.points.forEach((pt) => this.rect.expandInPlace(pt.getRect()));
2019
- if (this.tripletNumber) {
2020
- this.rect.expandInPlace(this.tripletNumber.getRect());
2013
+ if (this.tupletNumber) {
2014
+ this.rect.expandInPlace(this.tupletNumber.getRect());
2021
2015
  }
2022
2016
  }
2023
2017
  };
2024
2018
  var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2025
- constructor(symbols, triplet) {
2019
+ constructor(symbols, tupletRatio) {
2026
2020
  super(symbols[0].measure);
2027
2021
  this.symbols = symbols;
2022
+ this.tupletRatio = tupletRatio;
2028
2023
  __publicField(this, "mi");
2029
2024
  __publicField(this, "type");
2030
2025
  __publicField(this, "staffObjects", []);
2031
2026
  this.mi = new MBeamGroup(this);
2027
+ let beamGroupName = tupletRatio ? "Tuplet" : "BeamGroup";
2032
2028
  if (!symbols.every((s) => s.measure === symbols[0].measure)) {
2033
- throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "All beam group symbols are not in same measure.");
2029
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, `All ${beamGroupName} symbols are not in same measure.`);
2034
2030
  } else if (symbols.length < 2) {
2035
- throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Beam group need minimum 2 symbols, but " + symbols.length + " given.");
2031
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, `${beamGroupName} needs minimum 2 symbols, but ${symbols.length} given.`);
2036
2032
  }
2037
- if (triplet) {
2038
- if (!symbols.every((s) => s.triplet)) {
2039
- throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Not every symbol's triplet property is true.");
2040
- }
2033
+ if (tupletRatio !== void 0) {
2041
2034
  let isGroup = symbols.length < 3 || symbols.some((s) => !(s instanceof ObjNoteGroup)) || symbols.some((s) => s.rhythmProps.flagCount !== symbols[0].rhythmProps.flagCount);
2042
- if (symbols.length === 3 && symbols[0] instanceof ObjNoteGroup && symbols[symbols.length - 1] instanceof ObjNoteGroup && symbols[0].rhythmProps.flagCount === symbols[symbols.length - 1].rhythmProps.flagCount) {
2035
+ if (symbols.length >= 3 && symbols[0] instanceof ObjNoteGroup && symbols[symbols.length - 1] instanceof ObjNoteGroup && symbols[0].rhythmProps.flagCount === symbols[symbols.length - 1].rhythmProps.flagCount) {
2043
2036
  isGroup = false;
2044
2037
  }
2045
- if (symbols.some((s) => s.rhythmProps.noteLength >= import_theory4.NoteLength.Quarter)) {
2038
+ if (symbols.some((s) => import_theory4.NoteLengthProps.cmp(s.rhythmProps.noteLength, import_theory4.NoteLength.Quarter) >= 0)) {
2046
2039
  isGroup = true;
2047
2040
  }
2048
- this.type = isGroup ? 2 /* TripletGroup */ : 1 /* TripletBeam */;
2049
- ObjNoteGroup.setTripletBeamCounts(this);
2041
+ this.type = isGroup ? 2 /* TupletGroup */ : 1 /* TupletBeam */;
2042
+ ObjNoteGroup.setTupletBeamCounts(this);
2050
2043
  } else {
2051
2044
  this.type = 0 /* RegularBeam */;
2052
2045
  }
@@ -2054,32 +2047,35 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2054
2047
  symbols.forEach((s) => s.setBeamGroup(this));
2055
2048
  symbols[0].measure.addBeamGroup(this);
2056
2049
  } else {
2057
- throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Cannot add beam group because some symbol already has one.");
2050
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, `Cannot add ${beamGroupName} because some symbol already has one.`);
2058
2051
  }
2059
2052
  }
2053
+ get showTupletRatio() {
2054
+ var _a;
2055
+ return ((_a = this.tupletRatio) == null ? void 0 : _a.showRatio) === true;
2056
+ }
2060
2057
  static createBeam(noteGroups) {
2061
2058
  if (noteGroups.length > 1) {
2062
- new _ObjBeamGroup(noteGroups, false);
2059
+ new _ObjBeamGroup(noteGroups, void 0);
2063
2060
  }
2064
2061
  }
2065
- static createTriplet(symbols) {
2066
- if (!symbols.every((s) => s.triplet)) {
2067
- return false;
2062
+ static createOldStyleTriplet(symbols) {
2063
+ let s2 = symbols.slice(0, 2);
2064
+ let n2 = s2.map((s) => s.rhythmProps.noteSize);
2065
+ if (s2.length === 2 && s2.every((s) => s.oldStyleTriplet && s.getBeamGroup() === void 0) && (n2[0] * 2 === n2[1] || n2[1] * 2 === n2[0])) {
2066
+ new _ObjBeamGroup(s2, import_theory4.Tuplet.Triplet);
2067
+ return 2;
2068
2068
  }
2069
- let MaxTripletNoteLenght = import_theory4.NoteLength.Half;
2070
- let len = symbols.map((s) => s.rhythmProps.noteLength);
2071
- if (symbols.length == 2) {
2072
- if (len[0] <= MaxTripletNoteLenght && len[1] === len[0] / 2 && len[0] / 2 >= import_theory4.MinNoteLength || len[1] <= MaxTripletNoteLenght && len[0] === len[1] / 2 && len[1] / 2 >= import_theory4.MinNoteLength) {
2073
- new _ObjBeamGroup(symbols, true);
2074
- return true;
2075
- }
2076
- } else if (symbols.length === 3) {
2077
- if (len[0] <= MaxTripletNoteLenght && len.every((l) => l === len[0])) {
2078
- new _ObjBeamGroup(symbols, true);
2079
- return true;
2080
- }
2069
+ let s3 = symbols.slice(0, 3);
2070
+ let n3 = s3.map((s) => s.rhythmProps.noteSize);
2071
+ if (s3.length === 3 && s3.every((s) => s.oldStyleTriplet && s.getBeamGroup() === void 0) && n3.every((n) => n === n3[0])) {
2072
+ new _ObjBeamGroup(s3, import_theory4.Tuplet.Triplet);
2073
+ return 3;
2081
2074
  }
2082
- return false;
2075
+ return 0;
2076
+ }
2077
+ static createTuplet(symbols, tupletRatio) {
2078
+ new _ObjBeamGroup(symbols, tupletRatio);
2083
2079
  }
2084
2080
  getMusicInterface() {
2085
2081
  return this.mi;
@@ -2105,8 +2101,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2105
2101
  getType() {
2106
2102
  return this.type;
2107
2103
  }
2108
- isTriplet() {
2109
- return this.type === 1 /* TripletBeam */ || this.type === 2 /* TripletGroup */;
2104
+ isTuplet() {
2105
+ return this.type === 1 /* TupletBeam */ || this.type === 2 /* TupletGroup */;
2110
2106
  }
2111
2107
  getSymbols() {
2112
2108
  return this.symbols;
@@ -2168,10 +2164,10 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2168
2164
  }
2169
2165
  let leftStemHeight = (_a = symbolStemHeight[0]) != null ? _a : 0;
2170
2166
  let rightStemHeight = (_b = symbolStemHeight[symbolStemHeight.length - 1]) != null ? _b : 0;
2171
- if (this.type !== 2 /* TripletGroup */) {
2167
+ if (this.type !== 2 /* TupletGroup */) {
2172
2168
  let leftDy = leftStemHeight < rightStemHeight ? Math.sqrt(rightStemHeight - leftStemHeight) : 0;
2173
2169
  let rightDy = rightStemHeight < leftStemHeight ? Math.sqrt(leftStemHeight - rightStemHeight) : 0;
2174
- if (stemDir === 1 /* Up */) {
2170
+ if (stemDir === "up" /* Up */) {
2175
2171
  leftDy *= -1;
2176
2172
  rightDy *= -1;
2177
2173
  }
@@ -2184,7 +2180,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2184
2180
  symbolY[symbolY.length - 1] += rightDy;
2185
2181
  }
2186
2182
  }
2187
- let groupLineDy = unitSize * 2 * (stemDir === 1 /* Up */ ? -1 : 1);
2183
+ let groupLineDy = unitSize * 2 * (stemDir === "up" /* Up */ ? -1 : 1);
2188
2184
  let centerY = (rightY + leftY) / 2;
2189
2185
  let halfDy = adjustBeamAngle(rightX - leftX, rightY - leftY) / 2;
2190
2186
  leftY = centerY - halfDy;
@@ -2195,9 +2191,9 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2195
2191
  if (symX !== void 0 && symY !== void 0) {
2196
2192
  let beamY = import_ts_utils_lib3.Utils.Math.interpolateY(leftX, leftY, rightX, rightY, symX);
2197
2193
  let raiseY = symY - beamY;
2198
- if (stemDir === 1 /* Up */ && raiseY < 0) {
2194
+ if (stemDir === "up" /* Up */ && raiseY < 0) {
2199
2195
  raiseBeamY = Math.min(raiseBeamY, raiseY);
2200
- } else if (stemDir === 2 /* Down */ && raiseY > 0) {
2196
+ } else if (stemDir === "down" /* Down */ && raiseY > 0) {
2201
2197
  raiseBeamY = Math.max(raiseBeamY, raiseY);
2202
2198
  }
2203
2199
  }
@@ -2206,21 +2202,21 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2206
2202
  rightY += raiseBeamY;
2207
2203
  symbolY = symbolY.map((y) => y === void 0 ? void 0 : y + raiseBeamY);
2208
2204
  let obj = new ObjStaffBeamGroup(mainStaff, this);
2209
- if (this.type === 2 /* TripletGroup */) {
2205
+ if (this.type === 2 /* TupletGroup */) {
2210
2206
  let ef = unitSize / (rightX - leftX);
2211
2207
  let l = import_ts_utils_lib3.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, -ef);
2212
2208
  let r = import_ts_utils_lib3.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, 1 + ef);
2213
2209
  obj.points.push(new BeamPoint(leftStaff, this, leftSymbol, l.x, l.y));
2214
2210
  obj.points.push(new BeamPoint(rightStaff, this, rightSymbol, r.x, r.y));
2215
- obj.tripletNumberOffsetY = 0;
2216
- } else if (this.type === 0 /* RegularBeam */ || this.type === 1 /* TripletBeam */) {
2211
+ obj.tupletNumberOffsetY = 0;
2212
+ } else if (this.type === 0 /* RegularBeam */ || this.type === 1 /* TupletBeam */) {
2217
2213
  raiseBeamY *= 0.5;
2218
2214
  let { beamThickness } = renderer;
2219
2215
  const beamHeight = (i) => {
2220
2216
  let sym = symbols[i];
2221
2217
  if (sym instanceof ObjNoteGroup) {
2222
2218
  let beamCount = sym instanceof ObjNoteGroup ? Math.max(sym.getLeftBeamCount(), sym.getRightBeamCount()) : 0;
2223
- return DocumentSettings.BeamSeparation * unitSize * (this.stemDir === 1 /* Up */ ? beamCount - 1 : 0);
2219
+ return DocumentSettings.BeamSeparation * unitSize * (this.stemDir === "up" /* Up */ ? beamCount - 1 : 0);
2224
2220
  } else {
2225
2221
  return 0;
2226
2222
  }
@@ -2231,17 +2227,18 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2231
2227
  let symY = symbolY[i];
2232
2228
  if (symStaff && symX !== void 0 && symY !== void 0) {
2233
2229
  let pt = new BeamPoint(symStaff, this, sym, symX, symY);
2234
- pt.topBeamsHeight = beamThickness / 2 + (stemDir === 2 /* Down */ ? beamHeight(i) : 0);
2235
- pt.bottomBeamsHeight = beamThickness / 2 + (stemDir === 1 /* Up */ ? beamHeight(i) : 0);
2230
+ pt.topBeamsHeight = beamThickness / 2 + (stemDir === "down" /* Down */ ? beamHeight(i) : 0);
2231
+ pt.bottomBeamsHeight = beamThickness / 2 + (stemDir === "up" /* Up */ ? beamHeight(i) : 0);
2236
2232
  obj.points.push(pt);
2237
2233
  }
2238
2234
  });
2239
- obj.tripletNumberOffsetY = groupLineDy;
2235
+ obj.tupletNumberOffsetY = groupLineDy;
2240
2236
  }
2241
- if (this.isTriplet()) {
2242
- obj.tripletNumber = new ObjText(this, "3", 0.5, 0.5);
2243
- obj.tripletNumber.layout(renderer);
2244
- obj.tripletNumber.offset((leftX + rightX) / 2, (leftY + rightY) / 2 + obj.tripletNumberOffsetY);
2237
+ if (this.isTuplet() && this.tupletRatio) {
2238
+ let txt = this.showTupletRatio ? String(this.tupletRatio.parts) + ":" + String(this.tupletRatio.inTimeOf) : String(this.tupletRatio.parts);
2239
+ obj.tupletNumber = new ObjText(this, txt, 0.5, 0.5);
2240
+ obj.tupletNumber.layout(renderer);
2241
+ obj.tupletNumber.offset((leftX + rightX) / 2, (leftY + rightY) / 2 + obj.tupletNumberOffsetY);
2245
2242
  }
2246
2243
  if (obj.points.length >= 2) {
2247
2244
  this.staffObjects.push(obj);
@@ -2263,7 +2260,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2263
2260
  this.staffObjects.forEach((obj) => {
2264
2261
  let left = obj.points[0];
2265
2262
  let right = obj.points[obj.points.length - 1];
2266
- if (this.type !== 2 /* TripletGroup */) {
2263
+ if (this.type !== 2 /* TupletGroup */) {
2267
2264
  obj.points.forEach((pt) => {
2268
2265
  if (pt.symbol instanceof ObjNoteGroup) {
2269
2266
  if (pt !== left && pt !== right) {
@@ -2273,9 +2270,9 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2273
2270
  }
2274
2271
  });
2275
2272
  }
2276
- if (obj.tripletNumber) {
2277
- let y = (left.y + right.y) / 2 + obj.tripletNumberOffsetY;
2278
- obj.tripletNumber.offset(0, -obj.tripletNumber.getRect().centerY + y);
2273
+ if (obj.tupletNumber) {
2274
+ let y = (left.y + right.y) / 2 + obj.tupletNumberOffsetY;
2275
+ obj.tupletNumber.offset(0, -obj.tupletNumber.getRect().centerY + y);
2279
2276
  }
2280
2277
  });
2281
2278
  }
@@ -2287,21 +2284,21 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2287
2284
  let { unitSize, beamThickness, lineWidth } = renderer;
2288
2285
  let color = "black";
2289
2286
  this.staffObjects.forEach((obj) => {
2290
- if (this.type === 2 /* TripletGroup */) {
2287
+ if (this.type === 2 /* TupletGroup */) {
2291
2288
  let l = obj.points[0];
2292
2289
  let r = obj.points[obj.points.length - 1];
2293
2290
  if (l && r) {
2294
- let tf = obj.tripletNumber ? obj.tripletNumber.getRect().width / (r.x - l.x) * 1.2 : 0;
2291
+ let tf = obj.tupletNumber ? obj.tupletNumber.getRect().width / (r.x - l.x) * 1.2 : 0;
2295
2292
  let lc = import_ts_utils_lib3.Utils.Math.interpolateCoord(l.x, l.y, r.x, r.y, 0.5 - tf / 2);
2296
2293
  let rc = import_ts_utils_lib3.Utils.Math.interpolateCoord(l.x, l.y, r.x, r.y, 0.5 + tf / 2);
2297
- let tipH = this.stemDir === 1 /* Up */ ? unitSize : -unitSize;
2294
+ let tipH = this.stemDir === "up" /* Up */ ? unitSize : -unitSize;
2298
2295
  renderer.drawLine(l.x, l.y, lc.x, lc.y, color, lineWidth);
2299
2296
  renderer.drawLine(rc.x, rc.y, r.x, r.y, color, lineWidth);
2300
2297
  renderer.drawLine(l.x, l.y, l.x, l.y + tipH, color, lineWidth);
2301
2298
  renderer.drawLine(r.x, r.y, r.x, r.y + tipH, color, lineWidth);
2302
2299
  }
2303
- } else if (this.type === 0 /* RegularBeam */ || this.type === 1 /* TripletBeam */) {
2304
- let beamSeparation = DocumentSettings.BeamSeparation * unitSize * (this.stemDir === 1 /* Up */ ? 1 : -1);
2300
+ } else if (this.type === 0 /* RegularBeam */ || this.type === 1 /* TupletBeam */) {
2301
+ let beamSeparation = DocumentSettings.BeamSeparation * unitSize * (this.stemDir === "up" /* Up */ ? 1 : -1);
2305
2302
  let noteGroupPoints = obj.points.filter((p) => p.symbol instanceof ObjNoteGroup);
2306
2303
  for (let i = 0; i < noteGroupPoints.length - 1; i++) {
2307
2304
  let left = noteGroupPoints[i];
@@ -2328,8 +2325,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2328
2325
  }
2329
2326
  }
2330
2327
  }
2331
- if (obj.tripletNumber) {
2332
- obj.tripletNumber.draw(renderer);
2328
+ if (obj.tupletNumber) {
2329
+ obj.tupletNumber.draw(renderer);
2333
2330
  }
2334
2331
  });
2335
2332
  }
@@ -2337,6 +2334,12 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2337
2334
 
2338
2335
  // src/score/engine/obj-note-group.ts
2339
2336
  var import_core7 = require("@tspro/web-music-score/core");
2337
+ function getStem(stem) {
2338
+ return import_ts_utils_lib4.Utils.Is.isEnumValue(stem, Stem) ? stem : void 0;
2339
+ }
2340
+ function getArpeggio(a) {
2341
+ return import_ts_utils_lib4.Utils.Is.isEnumValue(a, Arpeggio) ? a : a === true ? "up" /* Up */ : void 0;
2342
+ }
2340
2343
  function sortNoteStringData(notes, strings) {
2341
2344
  let stringArr = import_ts_utils_lib4.Utils.Arr.isArray(strings) ? strings : strings !== void 0 ? [strings] : [];
2342
2345
  let noteStringData = notes.map((note, i) => {
@@ -2348,9 +2351,6 @@ function sortNoteStringData(notes, strings) {
2348
2351
  strings: noteStringData.every((e) => e.string === void 0) ? void 0 : noteStringData.map((e) => e.string)
2349
2352
  };
2350
2353
  }
2351
- function solveArpeggio(a) {
2352
- return a === true || a === 0 /* Up */ ? 0 /* Up */ : a === 1 /* Down */ ? 1 /* Down */ : void 0;
2353
- }
2354
2354
  var ObjStaffNoteGroup = class extends MusicObject {
2355
2355
  constructor(staff, noteGroup) {
2356
2356
  super(staff);
@@ -2371,7 +2371,16 @@ var ObjStaffNoteGroup = class extends MusicObject {
2371
2371
  return this.mi;
2372
2372
  }
2373
2373
  pick(x, y) {
2374
- return this.getRect().contains(x, y) ? [this] : [];
2374
+ if (!this.getRect().contains(x, y)) {
2375
+ return [];
2376
+ }
2377
+ for (let i = 0; i < this.accidentals.length; i++) {
2378
+ let arr = this.accidentals[i].pick(x, y);
2379
+ if (arr.length > 0) {
2380
+ return [this, ...arr];
2381
+ }
2382
+ }
2383
+ return [this];
2375
2384
  }
2376
2385
  updateRect() {
2377
2386
  this.rect = this.noteHeadRects[0].copy();
@@ -2431,7 +2440,7 @@ var ObjTabNoteGroup = class extends MusicObject {
2431
2440
  }
2432
2441
  };
2433
2442
  var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2434
- constructor(col, voiceId, notes, noteLength, options) {
2443
+ constructor(col, voiceId, notes, noteLength, options, tupletRatio) {
2435
2444
  var _a, _b, _c;
2436
2445
  super(col);
2437
2446
  this.col = col;
@@ -2447,6 +2456,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2447
2456
  __publicField(this, "staccato");
2448
2457
  __publicField(this, "diamond");
2449
2458
  __publicField(this, "arpeggio");
2459
+ __publicField(this, "oldStyleTriplet");
2450
2460
  __publicField(this, "rhythmProps");
2451
2461
  __publicField(this, "startConnnectives", []);
2452
2462
  __publicField(this, "runningConnectives", []);
@@ -2464,13 +2474,15 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2464
2474
  this.minDiatonicId = this.notes[0].diatonicId;
2465
2475
  this.maxDiatonicId = this.notes[this.notes.length - 1].diatonicId;
2466
2476
  this.ownDiatonicId = this.measure.updateOwnDiatonicId(voiceId, Math.round((this.minDiatonicId + this.maxDiatonicId) / 2));
2467
- this.ownStemDir = this.measure.updateOwnStemDir(this, options == null ? void 0 : options.stem);
2477
+ this.ownStemDir = this.measure.updateOwnStemDir(this, getStem(options == null ? void 0 : options.stem));
2468
2478
  this.ownString = this.measure.updateOwnString(this, noteStringData.strings);
2469
2479
  this.color = (_a = options == null ? void 0 : options.color) != null ? _a : "black";
2470
2480
  this.staccato = (_b = options == null ? void 0 : options.staccato) != null ? _b : false;
2471
2481
  this.diamond = (_c = options == null ? void 0 : options.diamond) != null ? _c : false;
2472
- this.arpeggio = solveArpeggio(options == null ? void 0 : options.arpeggio);
2473
- this.rhythmProps = new import_theory5.RhythmProps(noteLength, options == null ? void 0 : options.dotted, options == null ? void 0 : options.triplet);
2482
+ this.arpeggio = getArpeggio(options == null ? void 0 : options.arpeggio);
2483
+ this.oldStyleTriplet = tupletRatio === void 0 && ((options == null ? void 0 : options.triplet) === true || import_theory5.NoteLengthProps.get(noteLength).isTriplet);
2484
+ let dotCount = typeof (options == null ? void 0 : options.dotted) === "number" ? options.dotted > 0 ? options.dotted : void 0 : (options == null ? void 0 : options.dotted) === true ? 1 : void 0;
2485
+ this.rhythmProps = import_theory5.RhythmProps.get(noteLength, dotCount, (tupletRatio != null ? tupletRatio : this.oldStyleTriplet) ? import_theory5.Tuplet.Triplet : void 0);
2474
2486
  this.mi = new MNoteGroup(this);
2475
2487
  }
2476
2488
  getMusicInterface() {
@@ -2488,16 +2500,13 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2488
2500
  get stemDir() {
2489
2501
  return this.beamGroup ? this.beamGroup.stemDir : this.ownStemDir;
2490
2502
  }
2491
- get triplet() {
2492
- return this.rhythmProps.triplet;
2493
- }
2494
2503
  enableConnective(line) {
2495
2504
  return line.containsVoiceId(this.voiceId) && (line instanceof ObjTab || line.containsDiatonicId(this.ownDiatonicId));
2496
2505
  }
2497
2506
  startConnective(connectiveProps) {
2498
- if (!this.row.hasStaff && connectiveProps.connective === 0 /* Tie */) {
2507
+ if (!this.row.hasStaff && connectiveProps.connective === "tie" /* Tie */) {
2499
2508
  throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Ties not implemented for guitar tabs alone, staff is required!");
2500
- } else if (!this.row.hasStaff && connectiveProps.connective === 1 /* Slur */) {
2509
+ } else if (!this.row.hasStaff && connectiveProps.connective === "slur" /* Slur */) {
2501
2510
  throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Slurs not implemented for guitar tabs alone, staff is required!");
2502
2511
  }
2503
2512
  this.startConnnectives.push(connectiveProps);
@@ -2533,7 +2542,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2533
2542
  return [this, ...arr];
2534
2543
  }
2535
2544
  }
2536
- return [this];
2545
+ return [];
2537
2546
  }
2538
2547
  getTopNote() {
2539
2548
  return this.notes[this.notes.length - 1];
@@ -2556,7 +2565,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2556
2565
  let stemTip = obj.stemTip;
2557
2566
  let stemDir = this.stemDir;
2558
2567
  let hasStem = stemTip !== void 0;
2559
- let stemSide = !hasStem ? void 0 : stemDir === 1 /* Up */ ? "right" : "left";
2568
+ let stemSide = !hasStem ? void 0 : stemDir === "up" /* Up */ ? "right" : "left";
2560
2569
  let padding = noteHeadRect.height / 2;
2561
2570
  let centerX = noteHeadRect.centerX;
2562
2571
  let centerY = noteHeadRect.centerY;
@@ -2564,16 +2573,16 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2564
2573
  let rightX = noteHeadRect.right + padding;
2565
2574
  let aboveY = noteHeadRect.top - padding;
2566
2575
  let belowY = noteHeadRect.bottom + padding;
2567
- if (noteAnchor === 0 /* Auto */) {
2568
- noteAnchor = 3 /* Below */;
2569
- } else if (noteAnchor === 4 /* StemTip */ && !hasStem) {
2570
- noteAnchor = stemDir === 1 /* Up */ ? 1 /* Above */ : 3 /* Below */;
2576
+ if (noteAnchor === "auto" /* Auto */) {
2577
+ noteAnchor = "below" /* Below */;
2578
+ } else if (noteAnchor === "stemTip" /* StemTip */ && !hasStem) {
2579
+ noteAnchor = stemDir === "up" /* Up */ ? "above" /* Above */ : "below" /* Below */;
2571
2580
  }
2572
2581
  switch (noteAnchor) {
2573
- case 2 /* Center */:
2582
+ case "center" /* Center */:
2574
2583
  return side === "left" ? { x: rightX, y: centerY } : { x: leftX, y: centerY };
2575
- case 1 /* Above */:
2576
- if (!hasStem || stemDir === 2 /* Down */) {
2584
+ case "above" /* Above */:
2585
+ if (!hasStem || stemDir === "down" /* Down */) {
2577
2586
  return { x: centerX, y: aboveY };
2578
2587
  } else {
2579
2588
  return {
@@ -2581,8 +2590,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2581
2590
  y: aboveY
2582
2591
  };
2583
2592
  }
2584
- case 3 /* Below */:
2585
- if (!hasStem || stemDir === 1 /* Up */) {
2593
+ case "below" /* Below */:
2594
+ if (!hasStem || stemDir === "up" /* Up */) {
2586
2595
  return { x: centerX, y: belowY };
2587
2596
  } else {
2588
2597
  return {
@@ -2590,8 +2599,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2590
2599
  y: belowY
2591
2600
  };
2592
2601
  }
2593
- case 4 /* StemTip */:
2594
- return { x: centerX, y: stemTip.centerY + (stemDir === 1 /* Up */ ? -padding : padding) };
2602
+ case "stemTip" /* StemTip */:
2603
+ return { x: centerX, y: stemTip.centerY + (stemDir === "up" /* Up */ ? -padding : padding) };
2595
2604
  default:
2596
2605
  throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Invalid noteAnchor: " + noteAnchor);
2597
2606
  }
@@ -2606,7 +2615,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2606
2615
  let x = side === "right" ? r.left : r.right;
2607
2616
  let y;
2608
2617
  let s = 0.9;
2609
- if (connectiveProps.connective === 2 /* Slide */) {
2618
+ if (connectiveProps.connective === "slide" /* Slide */) {
2610
2619
  let leftFretNumber = connectiveProps.noteGroups[0].getFretNumber(obj, 0);
2611
2620
  let rightFretNumber = connectiveProps.noteGroups[1].getFretNumber(obj, 0);
2612
2621
  let slideUp = leftFretNumber === void 0 || rightFretNumber === void 0 || leftFretNumber <= rightFretNumber;
@@ -2660,7 +2669,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2660
2669
  this.runningConnectives = [];
2661
2670
  }
2662
2671
  getPlaySlur() {
2663
- let slurs = this.runningConnectives.filter((c) => c.connective === 1 /* Slur */).map((c) => c.startsWith(this) ? "first" : "slurred");
2672
+ let slurs = this.runningConnectives.filter((c) => c.connective === "slur" /* Slur */).map((c) => c.startsWith(this) ? "first" : "slurred");
2664
2673
  if (slurs.indexOf("first") >= 0) {
2665
2674
  return "first";
2666
2675
  } else if (slurs.indexOf("slurred") >= 0) {
@@ -2672,8 +2681,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2672
2681
  getBeamGroup() {
2673
2682
  return this.beamGroup;
2674
2683
  }
2675
- setBeamGroup(beam) {
2676
- this.beamGroup = beam;
2684
+ setBeamGroup(beamGroup) {
2685
+ this.beamGroup = beamGroup;
2677
2686
  }
2678
2687
  resetBeamGroup() {
2679
2688
  this.leftBeamCount = this.rightBeamCount = 0;
@@ -2684,19 +2693,19 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2684
2693
  var _a, _b, _c, _d;
2685
2694
  let staff = obj.staff;
2686
2695
  let x = (_b = (_a = obj.stemTip) == null ? void 0 : _a.centerX) != null ? _b : obj.noteHeadRects[0].centerX;
2687
- let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.centerY) != null ? _d : this.stemDir === 1 /* Up */ ? obj.getRect().top : obj.getRect().bottom;
2688
- let stemHeight = this.stemDir === 1 /* Up */ ? Math.abs(obj.noteHeadRects[0].centerY - y) : Math.abs(obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY - y);
2696
+ let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.centerY) != null ? _d : this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
2697
+ let stemHeight = this.stemDir === "up" /* Up */ ? Math.abs(obj.noteHeadRects[0].centerY - y) : Math.abs(obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY - y);
2689
2698
  return { staff, x, y, stemHeight };
2690
2699
  });
2691
2700
  }
2692
2701
  getStemHeight(renderer) {
2693
2702
  let { unitSize } = renderer;
2694
- let { noteLength, flagCount } = this.rhythmProps;
2695
- if (noteLength >= import_theory5.NoteLength.Whole) {
2696
- return 0;
2697
- } else {
2703
+ let { flagCount, hasStem } = this.rhythmProps;
2704
+ if (hasStem) {
2698
2705
  let addY = this.hasBeamCount() ? DocumentSettings.BeamSeparation : DocumentSettings.FlagSeparation;
2699
2706
  return (DocumentSettings.StemHeight + Math.max(0, flagCount - 1) * addY) * unitSize;
2707
+ } else {
2708
+ return 0;
2700
2709
  }
2701
2710
  }
2702
2711
  hasBeamCount() {
@@ -2715,13 +2724,13 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2715
2724
  return staff.containsVoiceId(this.voiceId) && this.staffObjects.some((obj) => obj instanceof ObjStaffNoteGroup && obj.staff === staff);
2716
2725
  }
2717
2726
  getPlayTicks(note) {
2718
- let tiedTicks = this.runningConnectives.filter((c) => c.connective === 0 /* Tie */).map((tie) => {
2727
+ let tiedTicks = this.runningConnectives.filter((c) => c.connective === "tie" /* Tie */).map((tie) => {
2719
2728
  let tieNoteGroups = tie.noteGroups;
2720
2729
  let j = tieNoteGroups.indexOf(this);
2721
2730
  if (j < 0) {
2722
2731
  return 0;
2723
2732
  }
2724
- if (tie.span === -1 /* Stub */ || tie.span === -2 /* ToMeasureEnd */) {
2733
+ if (tie.span === "stub" /* Stub */ || tie.span === "toMeasureEnd" /* ToMeasureEnd */) {
2725
2734
  return Math.max(this.rhythmProps.ticks, this.measure.getMeasureTicks() - this.col.positionTicks);
2726
2735
  }
2727
2736
  let prev = tieNoteGroups[j - 1];
@@ -2748,7 +2757,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2748
2757
  this.requestRectUpdate();
2749
2758
  let { unitSize } = renderer;
2750
2759
  let { row, stemDir } = this;
2751
- let { dotted, flagCount } = this.rhythmProps;
2760
+ let { dotCount, flagCount, hasStem } = this.rhythmProps;
2752
2761
  let dotWidth = DocumentSettings.DotSize * unitSize;
2753
2762
  let noteHeadWidth = (this.diamond ? DocumentSettings.DiamondNoteHeadSize : DocumentSettings.NoteHeadWidth) * unitSize;
2754
2763
  let noteHeadHeight = (this.diamond ? DocumentSettings.DiamondNoteHeadSize : DocumentSettings.NoteHeadHeight) * unitSize;
@@ -2768,10 +2777,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2768
2777
  let noteX = this.col.getNoteHeadDisplacement(this, note) * noteHeadWidth;
2769
2778
  let noteY = noteStaff.getDiatonicIdY(note.diatonicId);
2770
2779
  let isNoteOnLine = noteStaff.isLine(note.diatonicId);
2771
- if (isBottomNote && stemDir === 1 /* Up */) stemBaseStaff = noteStaff;
2772
- if (isTopNote && stemDir === 1 /* Up */) stemTipStaff = noteStaff;
2773
- if (isBottomNote && stemDir === 2 /* Down */) stemTipStaff = noteStaff;
2774
- if (isTopNote && stemDir === 2 /* Down */) stemBaseStaff = noteStaff;
2780
+ if (isBottomNote && stemDir === "up" /* Up */) stemBaseStaff = noteStaff;
2781
+ if (isTopNote && stemDir === "up" /* Up */) stemTipStaff = noteStaff;
2782
+ if (isBottomNote && stemDir === "down" /* Down */) stemTipStaff = noteStaff;
2783
+ if (isTopNote && stemDir === "down" /* Down */) stemBaseStaff = noteStaff;
2775
2784
  let noteHeadRect = obj.noteHeadRects[noteIndex] = DivRect.createCentered(noteX, noteY, noteHeadWidth, noteHeadHeight);
2776
2785
  noteStaff.addObject(noteHeadRect);
2777
2786
  if (accState.needAccidental(note)) {
@@ -2782,21 +2791,21 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2782
2791
  }
2783
2792
  noteStaff.addObject(acc);
2784
2793
  }
2785
- if (dotted) {
2786
- let dotX = noteHeadRect.right + DocumentSettings.NoteDotSpace * unitSize + dotWidth / 2;
2794
+ for (let i = 0; i < dotCount; i++) {
2795
+ let dotX = noteHeadRect.right + DocumentSettings.NoteDotSpace * unitSize + dotWidth / 2 + i * dotWidth * 1.5;
2787
2796
  let dotY = noteY + this.getDotVerticalDisplacement(staff, note.diatonicId, stemDir) * unitSize;
2788
2797
  let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2789
2798
  obj.dotRects.push(r);
2790
2799
  noteStaff.addObject(r);
2791
2800
  }
2792
2801
  if (this.staccato) {
2793
- if (stemDir === 1 /* Up */ && isBottomNote) {
2802
+ if (stemDir === "up" /* Up */ && isBottomNote) {
2794
2803
  let dotX = noteX;
2795
2804
  let dotY = noteY + unitSize * (isNoteOnLine ? 3 : 2);
2796
2805
  let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2797
2806
  obj.dotRects.push(r);
2798
2807
  stemBaseStaff.addObject(r);
2799
- } else if (stemDir === 2 /* Down */ && isTopNote) {
2808
+ } else if (stemDir === "down" /* Down */ && isTopNote) {
2800
2809
  let dotX = noteX;
2801
2810
  let dotY = noteY - unitSize * (isNoteOnLine ? 3 : 2);
2802
2811
  let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
@@ -2807,11 +2816,11 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2807
2816
  });
2808
2817
  let bottomNoteY = obj.noteHeadRects[0].centerY;
2809
2818
  let topNoteY = obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY;
2810
- let stemX = stemDir === 1 /* Up */ ? noteHeadWidth / 2 : -noteHeadWidth / 2;
2819
+ let stemX = stemDir === "up" /* Up */ ? noteHeadWidth / 2 : -noteHeadWidth / 2;
2811
2820
  let stemHeight = this.getStemHeight(renderer);
2812
- let stemTipY = stemDir === 1 /* Up */ ? topNoteY - stemHeight : bottomNoteY + stemHeight;
2813
- let stemBaseY = stemDir === 1 /* Up */ ? bottomNoteY : topNoteY;
2814
- if (this.rhythmProps.hasStem()) {
2821
+ let stemTipY = stemDir === "up" /* Up */ ? topNoteY - stemHeight : bottomNoteY + stemHeight;
2822
+ let stemBaseY = stemDir === "up" /* Up */ ? bottomNoteY : topNoteY;
2823
+ if (hasStem) {
2815
2824
  obj.stemTip = new DivRect(stemX, stemX, stemTipY, stemTipY);
2816
2825
  obj.stemBase = new DivRect(stemX, stemX, stemBaseY, stemBaseY);
2817
2826
  stemTipStaff.addObject(obj.stemTip);
@@ -2822,7 +2831,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2822
2831
  let flagHeight = flagCount === 0 ? 0 : DocumentSettings.FlagHeight * unitSize;
2823
2832
  for (let i = 0; i < flagCount; i++) {
2824
2833
  let flagAddY = i * unitSize * DocumentSettings.FlagSeparation;
2825
- let r = obj.flagRects[i] = stemDir === 1 /* Up */ ? new DivRect(stemX, stemX + flagWidth, stemTipY + flagAddY, stemTipY + flagHeight + flagAddY) : new DivRect(stemX, stemX + flagWidth, stemTipY - flagHeight - flagAddY, stemTipY - flagAddY);
2834
+ let r = obj.flagRects[i] = stemDir === "up" /* Up */ ? new DivRect(stemX, stemX + flagWidth, stemTipY + flagAddY, stemTipY + flagHeight + flagAddY) : new DivRect(stemX, stemX + flagWidth, stemTipY - flagHeight - flagAddY, stemTipY - flagAddY);
2826
2835
  stemTipStaff.addObject(r);
2827
2836
  }
2828
2837
  }
@@ -2835,7 +2844,6 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2835
2844
  }
2836
2845
  let obj = new ObjTabNoteGroup(tab, this);
2837
2846
  this.notes.forEach((note, noteIndex) => {
2838
- var _a, _b;
2839
2847
  if (this.ownString[noteIndex] !== void 0) {
2840
2848
  let stringId = this.ownString[noteIndex] - 1;
2841
2849
  let fretId = note.chromaticId - tab.getTuningStrings()[stringId].chromaticId;
@@ -2843,9 +2851,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2843
2851
  let fretNumber = new ObjText(this, { text: String(fretId), color, bgcolor: "white" }, 0.5, 0.5);
2844
2852
  obj.fretNumbers.push(fretNumber);
2845
2853
  fretNumber.layout(renderer);
2846
- let noteX = this.col.getNoteHeadDisplacement(this, note) * noteHeadWidth;
2847
- let stemX = (_b = (_a = this.staffObjects[0]) == null ? void 0 : _a.stemBase) == null ? void 0 : _b.centerX;
2848
- let x = stemX != null ? stemX : noteX;
2854
+ let x = this.col.getRect().centerX;
2849
2855
  let y = tab.getStringY(stringId);
2850
2856
  fretNumber.offset(x, y);
2851
2857
  }
@@ -2888,15 +2894,22 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2888
2894
  renderer.drawDebugRect(this.getRect());
2889
2895
  let { lineWidth } = renderer;
2890
2896
  let { color, stemDir } = this;
2891
- let { noteLength } = this.rhythmProps;
2897
+ let { isSolidNoteHead } = this.rhythmProps;
2892
2898
  this.staffObjects.forEach((obj) => {
2893
2899
  obj.accidentals.forEach((d) => d.draw(renderer));
2894
2900
  ctx.strokeStyle = ctx.fillStyle = color;
2895
2901
  ctx.lineWidth = lineWidth;
2896
2902
  obj.noteHeadRects.forEach((r) => {
2897
- let outlinedNoteHead = noteLength >= import_theory5.NoteLength.Half;
2898
2903
  if (this.diamond) {
2899
- if (outlinedNoteHead) {
2904
+ if (isSolidNoteHead) {
2905
+ ctx.beginPath();
2906
+ ctx.moveTo(r.centerX, r.top);
2907
+ ctx.lineTo(r.right, r.centerY);
2908
+ ctx.lineTo(r.centerX, r.bottom);
2909
+ ctx.lineTo(r.left, r.centerY);
2910
+ ctx.lineTo(r.centerX, r.top);
2911
+ ctx.fill();
2912
+ } else {
2900
2913
  ctx.beginPath();
2901
2914
  ctx.lineWidth = lineWidth * 2.5;
2902
2915
  ctx.moveTo(r.centerX, r.top);
@@ -2911,22 +2924,14 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2911
2924
  ctx.moveTo(r.centerX, r.top);
2912
2925
  ctx.lineTo(r.left, r.centerY);
2913
2926
  ctx.stroke();
2914
- } else {
2915
- ctx.beginPath();
2916
- ctx.moveTo(r.centerX, r.top);
2917
- ctx.lineTo(r.right, r.centerY);
2918
- ctx.lineTo(r.centerX, r.bottom);
2919
- ctx.lineTo(r.left, r.centerY);
2920
- ctx.lineTo(r.centerX, r.top);
2921
- ctx.fill();
2922
2927
  }
2923
2928
  } else {
2924
2929
  ctx.beginPath();
2925
2930
  ctx.ellipse(r.centerX, r.centerY, r.leftw, r.toph, -0.3, 0, Math.PI * 2);
2926
- if (outlinedNoteHead) {
2927
- ctx.stroke();
2928
- } else {
2931
+ if (isSolidNoteHead) {
2929
2932
  ctx.fill();
2933
+ } else {
2934
+ ctx.stroke();
2930
2935
  }
2931
2936
  }
2932
2937
  });
@@ -2941,8 +2946,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2941
2946
  let left = rect.left;
2942
2947
  let right = rect.right;
2943
2948
  let width = right - left;
2944
- let top = stemDir === 1 /* Up */ ? rect.top : rect.bottom;
2945
- let bottom = stemDir === 1 /* Up */ ? rect.bottom : rect.top;
2949
+ let top = stemDir === "up" /* Up */ ? rect.top : rect.bottom;
2950
+ let bottom = stemDir === "up" /* Up */ ? rect.bottom : rect.top;
2946
2951
  ctx.beginPath();
2947
2952
  ctx.moveTo(left, top);
2948
2953
  ctx.bezierCurveTo(
@@ -2956,13 +2961,13 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2956
2961
  ctx.stroke();
2957
2962
  });
2958
2963
  });
2959
- this.tabObjects.forEach((obj) => {
2960
- obj.fretNumbers.forEach((fn) => fn.draw(renderer));
2961
- });
2964
+ this.tabObjects.forEach((obj) => obj.fretNumbers.forEach((fn) => fn.draw(renderer)));
2962
2965
  }
2963
2966
  static setBeamCounts(groupNotes) {
2964
2967
  const isADottedBHalf = (a, b) => {
2965
- return a.rhythmProps.noteLength === b.rhythmProps.noteLength * 2 && a.rhythmProps.dotted && !b.rhythmProps.dotted && a.rhythmProps.flagCount > 0 && b.rhythmProps.flagCount > 0;
2968
+ let { flagCount: aFlagCount, noteSize: aNoteSize, dotCount: aDotCount } = a.rhythmProps;
2969
+ let { flagCount: bFlagCount, noteSize: bNoteSize, dotCount: bDotCount } = b.rhythmProps;
2970
+ return aFlagCount > 0 && bFlagCount > 0 && aDotCount > 0 && bDotCount === 0 && aNoteSize * Math.pow(2, aDotCount) === bNoteSize;
2966
2971
  };
2967
2972
  for (let i = 0; i < groupNotes.length; i++) {
2968
2973
  let center = groupNotes[i];
@@ -3008,29 +3013,27 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
3008
3013
  }
3009
3014
  } while (fixAgain);
3010
3015
  }
3011
- static setTripletBeamCounts(triplet) {
3012
- let type = triplet.getType();
3013
- let symbols = triplet.getSymbols();
3014
- if (type === 1 /* TripletBeam */) {
3016
+ static setTupletBeamCounts(tuplet) {
3017
+ let type = tuplet.getType();
3018
+ let symbols = tuplet.getSymbols();
3019
+ if (type === 1 /* TupletBeam */) {
3015
3020
  symbols.forEach((s, i) => {
3016
3021
  if (s instanceof _ObjNoteGroup) {
3017
3022
  s.leftBeamCount = i === 0 ? 0 : s.rhythmProps.flagCount;
3018
3023
  s.rightBeamCount = i === symbols.length - 1 ? 0 : s.rhythmProps.flagCount;
3019
3024
  }
3020
3025
  });
3021
- } else if (type === 2 /* TripletGroup */) {
3026
+ } else if (type === 2 /* TupletGroup */) {
3022
3027
  symbols.forEach((s) => {
3023
3028
  if (s instanceof _ObjNoteGroup) {
3024
3029
  s.leftBeamCount = s.rightBeamCount = 0;
3025
3030
  }
3026
3031
  });
3027
- } else {
3028
- throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Cannot set triplet beam count because triplet beam group type is invalid.");
3029
3032
  }
3030
3033
  }
3031
3034
  getDotVerticalDisplacement(staff, diatonicId, stemDir) {
3032
3035
  if (staff.isLine(diatonicId)) {
3033
- return stemDir === 1 /* Up */ ? -1 : 1;
3036
+ return stemDir === "up" /* Up */ ? -1 : 1;
3034
3037
  } else {
3035
3038
  return 0;
3036
3039
  }
@@ -3055,7 +3058,7 @@ var import_core8 = require("@tspro/web-music-score/core");
3055
3058
  var noteHeadDataCompareFunc = (a, b) => {
3056
3059
  let cmp = import_theory6.Note.compareFunc(a.note, b.note);
3057
3060
  if (cmp === 0) {
3058
- cmp = a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === 1 /* Up */ ? 1 : -1;
3061
+ cmp = a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === "up" /* Up */ ? 1 : -1;
3059
3062
  }
3060
3063
  return cmp;
3061
3064
  };
@@ -3161,23 +3164,21 @@ var ObjRhythmColumn = class extends MusicObject {
3161
3164
  return [this, ...arr];
3162
3165
  }
3163
3166
  }
3164
- return [this];
3167
+ return [];
3165
3168
  }
3166
3169
  hasArpeggio() {
3167
3170
  return this.arpeggioDir !== void 0;
3168
3171
  }
3169
3172
  getArpeggioDir() {
3170
3173
  var _a;
3171
- return (_a = this.arpeggioDir) != null ? _a : 0 /* Up */;
3174
+ return (_a = this.arpeggioDir) != null ? _a : "up" /* Up */;
3172
3175
  }
3173
3176
  setVoiceSymbol(voiceId, symbol) {
3174
3177
  validateVoiceId(voiceId);
3175
3178
  this.voiceSymbol[voiceId] = symbol;
3176
- if (symbol instanceof ObjRest) {
3177
- if (!symbol.hide && symbol.noteLength >= import_theory6.NoteLength.Half) {
3178
- this.minDiatonicId = this.minDiatonicId === void 0 ? symbol.ownDiatonicId : Math.min(this.minDiatonicId, symbol.ownDiatonicId);
3179
- this.maxDiatonicId = this.maxDiatonicId === void 0 ? symbol.ownDiatonicId : Math.max(this.maxDiatonicId, symbol.ownDiatonicId);
3180
- }
3179
+ if (symbol instanceof ObjRest && !symbol.hide) {
3180
+ this.minDiatonicId = this.minDiatonicId === void 0 ? symbol.ownDiatonicId : Math.min(this.minDiatonicId, symbol.ownDiatonicId);
3181
+ this.maxDiatonicId = this.maxDiatonicId === void 0 ? symbol.ownDiatonicId : Math.max(this.maxDiatonicId, symbol.ownDiatonicId);
3181
3182
  } else if (symbol instanceof ObjNoteGroup) {
3182
3183
  this.minDiatonicId = this.minDiatonicId === void 0 ? symbol.notes[0].diatonicId : Math.min(this.minDiatonicId, symbol.notes[0].diatonicId);
3183
3184
  this.maxDiatonicId = this.maxDiatonicId === void 0 ? symbol.notes[symbol.notes.length - 1].diatonicId : Math.max(this.maxDiatonicId, symbol.notes[symbol.notes.length - 1].diatonicId);
@@ -3193,15 +3194,18 @@ var ObjRhythmColumn = class extends MusicObject {
3193
3194
  return this.voiceSymbol[voiceId];
3194
3195
  }
3195
3196
  getMinWidth() {
3196
- let maxNoteLength = Math.max(...this.voiceSymbol.map((s) => s.rhythmProps.noteLength));
3197
+ let maxNoteSize = Math.max(...this.voiceSymbol.map((s) => s.rhythmProps.noteSize));
3197
3198
  let w = DocumentSettings.NoteHeadWidth;
3198
- switch (maxNoteLength) {
3199
- case import_theory6.NoteLength.Whole:
3199
+ switch (maxNoteSize) {
3200
+ case 1:
3200
3201
  return w * 5;
3201
- case import_theory6.NoteLength.Half:
3202
+ // whole note
3203
+ case 2:
3202
3204
  return w * 3;
3203
- case import_theory6.NoteLength.Quarter:
3205
+ // half note
3206
+ case 4:
3204
3207
  return w * 2;
3208
+ // quarter note
3205
3209
  default:
3206
3210
  return w;
3207
3211
  }
@@ -3233,7 +3237,7 @@ var ObjRhythmColumn = class extends MusicObject {
3233
3237
  if (cur.displacement !== void 0) {
3234
3238
  continue;
3235
3239
  }
3236
- let d = cur.noteGroup.stemDir === 2 /* Down */ ? -1 : 1;
3240
+ let d = cur.noteGroup.stemDir === "down" /* Down */ ? -1 : 1;
3237
3241
  if (prev && cur.note.diatonicId - prev.note.diatonicId <= 1) {
3238
3242
  cur.displacement = prev.displacement === 0 ? d : 0;
3239
3243
  } else if (next && next.note.diatonicId - cur.note.diatonicId <= 1) {
@@ -3287,7 +3291,7 @@ var ObjRhythmColumn = class extends MusicObject {
3287
3291
  }
3288
3292
  });
3289
3293
  playerNotes.sort((a, b) => import_theory6.Note.compareFunc(a.note, b.note));
3290
- if (this.hasArpeggio() && this.getArpeggioDir() === 1 /* Down */) {
3294
+ if (this.hasArpeggio() && this.getArpeggioDir() === "down" /* Down */) {
3291
3295
  playerNotes.reverse();
3292
3296
  }
3293
3297
  return playerNotes;
@@ -3404,6 +3408,9 @@ var ObjRhythmColumn = class extends MusicObject {
3404
3408
  }
3405
3409
  };
3406
3410
 
3411
+ // src/score/engine/element-data.ts
3412
+ var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
3413
+
3407
3414
  // src/score/engine/obj-special-text.ts
3408
3415
  var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3409
3416
  constructor(parent, text) {
@@ -3501,36 +3508,71 @@ __publicField(_ObjSpecialText, "Segno", "\u{1D10B}");
3501
3508
  var ObjSpecialText = _ObjSpecialText;
3502
3509
 
3503
3510
  // src/score/engine/element-data.ts
3504
- function getNavigationString(n) {
3505
- switch (n) {
3506
- case 1 /* DC_al_Coda */:
3511
+ function getNavigationString(navigation) {
3512
+ switch (navigation) {
3513
+ case "D.C. al Coda" /* DC_al_Coda */:
3507
3514
  return "D.C. al Coda";
3508
- case 0 /* DC_al_Fine */:
3515
+ case "D.C. al Fine" /* DC_al_Fine */:
3509
3516
  return "D.C. al Fine";
3510
- case 3 /* DS_al_Coda */:
3517
+ case "D.S. al Coda" /* DS_al_Coda */:
3511
3518
  return "D.S. al Coda";
3512
- case 2 /* DS_al_Fine */:
3519
+ case "D.S. al Fine" /* DS_al_Fine */:
3513
3520
  return "D.S. al Fine";
3514
- case 7 /* Fine */:
3521
+ case "Fine" /* Fine */:
3515
3522
  return "Fine";
3516
- case 6 /* Segno */:
3523
+ case "Segno" /* Segno */:
3517
3524
  return ObjSpecialText.Segno;
3518
- case 4 /* Coda */:
3525
+ case "Coda" /* Coda */:
3519
3526
  return ObjSpecialText.Coda;
3520
- case 5 /* toCoda */:
3527
+ case "toCoda" /* toCoda */:
3521
3528
  return ObjSpecialText.toCoda;
3522
3529
  default:
3523
- return Navigation[n];
3530
+ return navigation[0].toUpperCase() + navigation.substring(1);
3524
3531
  }
3525
3532
  }
3533
+ var DynamicsAnnotations = /* @__PURE__ */ ((DynamicsAnnotations2) => {
3534
+ DynamicsAnnotations2["cresc"] = "cresc.";
3535
+ DynamicsAnnotations2["decresc"] = "decresc.";
3536
+ DynamicsAnnotations2["dim"] = "dim.";
3537
+ DynamicsAnnotations2["ppp"] = "ppp";
3538
+ DynamicsAnnotations2["pp"] = "pp";
3539
+ DynamicsAnnotations2["p"] = "p";
3540
+ DynamicsAnnotations2["mp"] = "mp";
3541
+ DynamicsAnnotations2["m"] = "m";
3542
+ DynamicsAnnotations2["mf"] = "mf";
3543
+ DynamicsAnnotations2["f"] = "f";
3544
+ DynamicsAnnotations2["ff"] = "ff";
3545
+ DynamicsAnnotations2["fff"] = "fff";
3546
+ return DynamicsAnnotations2;
3547
+ })(DynamicsAnnotations || {});
3548
+ var TempoAnnotations = /* @__PURE__ */ ((TempoAnnotations2) => {
3549
+ TempoAnnotations2["accel"] = "accel.";
3550
+ TempoAnnotations2["rit"] = "rit.";
3551
+ TempoAnnotations2["a_tempo"] = "a tempo";
3552
+ return TempoAnnotations2;
3553
+ })(TempoAnnotations || {});
3526
3554
  function isDynamicsText(text) {
3527
- return ["ppp", "pp", "p", "mp", "m", "mf", "f", "ff", "fff", "cresc.", "decresc.", "dim."].indexOf(text) >= 0;
3555
+ return import_ts_utils_lib5.Utils.Is.isEnumValue(text, DynamicsAnnotations);
3528
3556
  }
3529
- function isDynamicsLevelText(text) {
3530
- return ["ppp", "pp", "p", "mp", "m", "mf", "f", "ff", "fff"].indexOf(text) >= 0;
3557
+ function getDynamicsVolume(text) {
3558
+ if (/^(p+|f+|m|mp|mf)$/.test(text)) {
3559
+ let volume = 0.5 - import_ts_utils_lib5.Utils.Str.charCount(text, "p") * 0.1 + import_ts_utils_lib5.Utils.Str.charCount(text, "f") * 0.1;
3560
+ return import_ts_utils_lib5.Utils.Math.clamp(volume, 0, 1);
3561
+ } else {
3562
+ return void 0;
3563
+ }
3531
3564
  }
3532
3565
  function isTempoText(text) {
3533
- return ["accel.", "rit.", "a tempo"].indexOf(text) >= 0;
3566
+ return import_ts_utils_lib5.Utils.Is.isEnumValue(text, TempoAnnotations);
3567
+ }
3568
+ function getAnnotation(text) {
3569
+ if (import_ts_utils_lib5.Utils.Is.isEnumValue(text, DynamicsAnnotations)) {
3570
+ return "dynamics" /* Dynamics */;
3571
+ } else if (import_ts_utils_lib5.Utils.Is.isEnumValue(text, TempoAnnotations)) {
3572
+ return "tempo" /* Tempo */;
3573
+ } else {
3574
+ return void 0;
3575
+ }
3534
3576
  }
3535
3577
 
3536
3578
  // src/score/engine/extension.ts
@@ -3589,7 +3631,7 @@ var Extension = class extends MusicObjectLink {
3589
3631
  if (prevMeasure.hasEndSection() || prevMeasure.hasEndSong()) {
3590
3632
  return "section-break";
3591
3633
  }
3592
- let elemArr = [9 /* EndRepeat */, 10 /* Ending */];
3634
+ let elemArr = ["endRepeat" /* EndRepeat */, "ending" /* Ending */];
3593
3635
  for (let i = 0; i < elemArr.length; i++) {
3594
3636
  if (prevMeasure.hasNavigation(elemArr[i])) {
3595
3637
  return "section-break";
@@ -3650,35 +3692,12 @@ var RitardandoSpeedDiv = 2;
3650
3692
  var CrescendoVolumeAdd = 0.5;
3651
3693
  var DiminuendoVolumeSub = 0.5;
3652
3694
  function calcTicksDuration(ticks, tempo) {
3653
- let beatTicks = new import_theory7.RhythmProps(tempo.options.beatLength, tempo.options.dotted).ticks;
3695
+ let beatTicks = import_theory7.RhythmProps.get(tempo.options.beatLength, tempo.options.dotCount).ticks;
3654
3696
  let ticksPerMinute = tempo.beatsPerMinute * beatTicks;
3655
3697
  return 60 * ticks / ticksPerMinute;
3656
3698
  }
3657
- function getVolume(dynamicsLevelText) {
3658
- switch (dynamicsLevelText) {
3659
- case "fff":
3660
- return 0.9;
3661
- case "ff":
3662
- return 0.8;
3663
- case "f":
3664
- return 0.7;
3665
- case "mf":
3666
- return 0.6;
3667
- default:
3668
- case "m":
3669
- return 0.5;
3670
- case "mp":
3671
- return 0.4;
3672
- case "p":
3673
- return 0.3;
3674
- case "pp":
3675
- return 0.2;
3676
- case "ppp":
3677
- return 0.1;
3678
- }
3679
- }
3680
3699
  function getDefaultVolume() {
3681
- return getVolume("m");
3700
+ return getDynamicsVolume("m");
3682
3701
  }
3683
3702
  function adjustVolume(linearVolume) {
3684
3703
  return linearVolume * 1.25;
@@ -3706,7 +3725,7 @@ var PlayerColumnProps = class {
3706
3725
  return this.speed;
3707
3726
  }
3708
3727
  getTempo() {
3709
- let speed = import_ts_utils_lib5.Utils.Math.clamp(this.getSpeed(), 0.1, 10);
3728
+ let speed = import_ts_utils_lib6.Utils.Math.clamp(this.getSpeed(), 0.1, 10);
3710
3729
  return (0, import_theory7.alterTempoSpeed)(this.measure.getTempo(), speed);
3711
3730
  }
3712
3731
  setVolume(volume) {
@@ -3731,7 +3750,7 @@ var PlayerColumnProps = class {
3731
3750
  if (symbolsTicks.length === 0) {
3732
3751
  return 0;
3733
3752
  } else {
3734
- return import_ts_utils_lib5.Utils.Math.sum(symbolsTicks) / symbolsTicks.length;
3753
+ return import_ts_utils_lib6.Utils.Math.sum(symbolsTicks) / symbolsTicks.length;
3735
3754
  }
3736
3755
  }
3737
3756
  }
@@ -3794,34 +3813,34 @@ var Player = class _Player {
3794
3813
  continue;
3795
3814
  }
3796
3815
  measureSequence.push(curMeasure);
3797
- if (curMeasure.hasNavigation(8 /* StartRepeat */)) {
3816
+ if (curMeasure.hasNavigation("startRepeat" /* StartRepeat */)) {
3798
3817
  startRepeatMeasure = curMeasure;
3799
3818
  }
3800
- if (curMeasure.hasNavigation(6 /* Segno */)) {
3819
+ if (curMeasure.hasNavigation("Segno" /* Segno */)) {
3801
3820
  segnoMeasure = curMeasure;
3802
3821
  }
3803
- if (alCoda && curMeasure.hasNavigation(5 /* toCoda */)) {
3804
- while (curMeasure && !curMeasure.hasNavigation(4 /* Coda */)) {
3822
+ if (alCoda && curMeasure.hasNavigation("toCoda" /* toCoda */)) {
3823
+ while (curMeasure && !curMeasure.hasNavigation("Coda" /* Coda */)) {
3805
3824
  curMeasure = curMeasure.getNextMeasure();
3806
3825
  }
3807
- } else if (alFine && curMeasure.hasNavigation(7 /* Fine */)) {
3826
+ } else if (alFine && curMeasure.hasNavigation("Fine" /* Fine */)) {
3808
3827
  curMeasure = void 0;
3809
- } else if (curMeasure.hasNavigation(1 /* DC_al_Coda */)) {
3828
+ } else if (curMeasure.hasNavigation("D.C. al Coda" /* DC_al_Coda */)) {
3810
3829
  alCoda = true;
3811
3830
  curMeasure = this.doc.getFirstMeasure();
3812
- } else if (curMeasure.hasNavigation(0 /* DC_al_Fine */)) {
3831
+ } else if (curMeasure.hasNavigation("D.C. al Fine" /* DC_al_Fine */)) {
3813
3832
  alFine = true;
3814
3833
  curMeasure = this.doc.getFirstMeasure();
3815
- } else if (curMeasure.hasNavigation(3 /* DS_al_Coda */)) {
3834
+ } else if (curMeasure.hasNavigation("D.S. al Coda" /* DS_al_Coda */)) {
3816
3835
  alCoda = true;
3817
3836
  curMeasure = segnoMeasure;
3818
- } else if (curMeasure.hasNavigation(2 /* DS_al_Fine */)) {
3837
+ } else if (curMeasure.hasNavigation("D.S. al Fine" /* DS_al_Fine */)) {
3819
3838
  alFine = true;
3820
3839
  curMeasure = segnoMeasure;
3821
- } else if (curMeasure.hasNavigation(9 /* EndRepeat */)) {
3840
+ } else if (curMeasure.hasNavigation("endRepeat" /* EndRepeat */)) {
3822
3841
  let passage = curMeasure.getPassCount();
3823
3842
  let repeatCount = curMeasure.getEndRepeatPlayCount() - 1;
3824
- let cannotPassThrough = ((_a = curMeasure.getNextMeasure()) == null ? void 0 : _a.hasNavigation(10 /* Ending */)) === true;
3843
+ let cannotPassThrough = ((_a = curMeasure.getNextMeasure()) == null ? void 0 : _a.hasNavigation("ending" /* Ending */)) === true;
3825
3844
  if (passage <= repeatCount || cannotPassThrough) {
3826
3845
  curMeasure = startRepeatMeasure;
3827
3846
  } else {
@@ -3872,14 +3891,15 @@ var Player = class _Player {
3872
3891
  col.getAnchoredLayoutObjects().forEach((layoutObj) => {
3873
3892
  var _a2;
3874
3893
  let text = (_a2 = layoutObj.getTextContent()) != null ? _a2 : "";
3875
- if (text === "a tempo") {
3894
+ let vol;
3895
+ if (text === "a tempo" /* a_tempo */) {
3876
3896
  curSpeed = 1;
3877
- } else if (isDynamicsLevelText(text)) {
3878
- curVolume = getVolume(text);
3897
+ } else if ((vol = getDynamicsVolume(text)) !== void 0) {
3898
+ curVolume = vol;
3879
3899
  } else if (layoutObj.musicObj.getLink() instanceof Extension) {
3880
3900
  let extension = layoutObj.musicObj.getLink();
3881
3901
  let { columnRange, extensionBreakText } = extension.getExtensionRangeInfo();
3882
- let totalTicks = import_ts_utils_lib5.Utils.Math.sum(columnRange.map((c) => c.getTicksToNextColumn()));
3902
+ let totalTicks = import_ts_utils_lib6.Utils.Math.sum(columnRange.map((c) => c.getTicksToNextColumn()));
3883
3903
  switch (text) {
3884
3904
  case "accel." /* accel */: {
3885
3905
  let startSpeed = curSpeed;
@@ -3904,8 +3924,8 @@ var Player = class _Player {
3904
3924
  case "cresc." /* cresc */: {
3905
3925
  let startVol = curVolume;
3906
3926
  let endVol = startVol + CrescendoVolumeAdd;
3907
- if (extensionBreakText && isDynamicsLevelText(extensionBreakText) && getVolume(extensionBreakText) > startVol) {
3908
- endVol = getVolume(extensionBreakText);
3927
+ if (extensionBreakText && (vol = getDynamicsVolume(extensionBreakText)) !== void 0 && vol > startVol) {
3928
+ endVol = vol;
3909
3929
  }
3910
3930
  let accuTicks = 0;
3911
3931
  columnRange.forEach((c) => {
@@ -3918,8 +3938,8 @@ var Player = class _Player {
3918
3938
  case "dim." /* dim */: {
3919
3939
  let startVol = curVolume;
3920
3940
  let endVol = startVol - DiminuendoVolumeSub;
3921
- if (extensionBreakText && isDynamicsLevelText(extensionBreakText) && getVolume(extensionBreakText) < startVol) {
3922
- endVol = getVolume(extensionBreakText);
3941
+ if (extensionBreakText && (vol = getDynamicsVolume(extensionBreakText)) !== void 0 && vol < startVol) {
3942
+ endVol = vol;
3923
3943
  }
3924
3944
  let accuTicks = 0;
3925
3945
  columnRange.forEach((c) => {
@@ -3933,11 +3953,11 @@ var Player = class _Player {
3933
3953
  });
3934
3954
  let speedArr = (_a = speedMap.get(col)) != null ? _a : [];
3935
3955
  if (speedArr.length > 0) {
3936
- curSpeed = import_ts_utils_lib5.Utils.Math.sum(speedArr) / speedArr.length;
3956
+ curSpeed = import_ts_utils_lib6.Utils.Math.sum(speedArr) / speedArr.length;
3937
3957
  }
3938
3958
  let volumeArr = (_b = volumeMap.get(col)) != null ? _b : [];
3939
3959
  if (volumeArr.length > 0) {
3940
- curVolume = import_ts_utils_lib5.Utils.Math.sum(volumeArr) / volumeArr.length;
3960
+ curVolume = import_ts_utils_lib6.Utils.Math.sum(volumeArr) / volumeArr.length;
3941
3961
  }
3942
3962
  col.getPlayerProps().setSpeed(curSpeed);
3943
3963
  col.getPlayerProps().setVolume(curVolume);
@@ -3950,7 +3970,7 @@ var Player = class _Player {
3950
3970
  return m;
3951
3971
  }
3952
3972
  let next = m == null ? void 0 : m.getNextMeasure();
3953
- if (!m || m.hasEndSong() || m.hasEndSection() || !next || next.hasNavigation(8 /* StartRepeat */)) {
3973
+ if (!m || m.hasEndSong() || m.hasEndSection() || !next || next.hasNavigation("startRepeat" /* StartRepeat */)) {
3954
3974
  return void 0;
3955
3975
  }
3956
3976
  }
@@ -3975,11 +3995,11 @@ var Player = class _Player {
3975
3995
  } else {
3976
3996
  let playerNotes = col.getPlayerNotes();
3977
3997
  playerNotes.forEach((note, i) => {
3978
- let arpeggioDelayTicks = col.hasArpeggio() ? import_theory7.NoteLength.ThirtySecond * i : 0;
3998
+ let arpeggioDelayTicks = col.hasArpeggio() ? import_theory7.RhythmProps.get(import_theory7.NoteLength.ThirtySecond).ticks * i : 0;
3979
3999
  let noteSeconds = getDuration(note.ticks + fermataHoldTicks - arpeggioDelayTicks, tempo);
3980
4000
  if (noteSeconds > 0) {
3981
4001
  if (note.staccato) {
3982
- noteSeconds = Math.min(getDuration(import_theory7.NoteLength.Eighth, tempo) / 2, noteSeconds / 2);
4002
+ noteSeconds = Math.min(getDuration(import_theory7.RhythmProps.get(import_theory7.NoteLength.Eighth).ticks, tempo) / 2, noteSeconds / 2);
3983
4003
  }
3984
4004
  let volume = adjustVolume(col.getPlayerProps().getVolume());
3985
4005
  if (note.slur === "slurred") {
@@ -4057,8 +4077,9 @@ var Player = class _Player {
4057
4077
 
4058
4078
  // src/score/engine/obj-bar-line.ts
4059
4079
  var ObjStaffTabBarLine = class extends MusicObject {
4060
- constructor(line) {
4080
+ constructor(barLine, line) {
4061
4081
  super(line);
4082
+ this.barLine = barLine;
4062
4083
  this.line = line;
4063
4084
  __publicField(this, "lineRects", []);
4064
4085
  __publicField(this, "dotRects", []);
@@ -4113,7 +4134,7 @@ var ObjBarLine = class extends MusicObject {
4113
4134
  let dotW = DocumentSettings.DotSize * unitSize;
4114
4135
  let dotRadius = dotW / 2;
4115
4136
  row.getNotationLines().forEach((line) => {
4116
- let obj = new ObjStaffTabBarLine(line);
4137
+ let obj = new ObjStaffTabBarLine(this, line);
4117
4138
  let lineCenterY;
4118
4139
  let lineDotOff;
4119
4140
  let top, bottom;
@@ -4216,8 +4237,8 @@ var ObjBarLineLeft = class extends ObjBarLine {
4216
4237
  solveBarLineType() {
4217
4238
  let m = this.measure;
4218
4239
  let prev = m.getPrevMeasure();
4219
- if (m.hasNavigation(8 /* StartRepeat */)) {
4220
- if (prev && prev.row === m.row && prev.hasNavigation(9 /* EndRepeat */)) {
4240
+ if (m.hasNavigation("startRepeat" /* StartRepeat */)) {
4241
+ if (prev && prev.row === m.row && prev.hasNavigation("endRepeat" /* EndRepeat */)) {
4221
4242
  return 0 /* None */;
4222
4243
  } else {
4223
4244
  return 4 /* StartRepeat */;
@@ -4244,8 +4265,8 @@ var ObjBarLineRight = class extends ObjBarLine {
4244
4265
  solveBarLineType() {
4245
4266
  let m = this.measure;
4246
4267
  let next = m.getNextMeasure();
4247
- if (m.hasNavigation(9 /* EndRepeat */)) {
4248
- if (next && next.row === m.row && next.hasNavigation(8 /* StartRepeat */)) {
4268
+ if (m.hasNavigation("endRepeat" /* EndRepeat */)) {
4269
+ if (next && next.row === m.row && next.hasNavigation("startRepeat" /* StartRepeat */)) {
4249
4270
  return 6 /* EndStartRepeat */;
4250
4271
  } else {
4251
4272
  return 5 /* EndRepeat */;
@@ -4255,10 +4276,10 @@ var ObjBarLineRight = class extends ObjBarLine {
4255
4276
  } else if (m.hasEndSection()) {
4256
4277
  return 2 /* Double */;
4257
4278
  }
4258
- if (m === m.row.getLastMeasure() && next && next.row === m.row.getNextRow() && next.hasNavigation(8 /* StartRepeat */)) {
4279
+ if (m === m.row.getLastMeasure() && next && next.row === m.row.getNextRow() && next.hasNavigation("startRepeat" /* StartRepeat */)) {
4259
4280
  return 2 /* Double */;
4260
4281
  }
4261
- if (next && next.hasNavigation(8 /* StartRepeat */)) {
4282
+ if (next && next.hasNavigation("startRepeat" /* StartRepeat */)) {
4262
4283
  return 0 /* None */;
4263
4284
  }
4264
4285
  return 1 /* Single */;
@@ -4266,7 +4287,7 @@ var ObjBarLineRight = class extends ObjBarLine {
4266
4287
  };
4267
4288
 
4268
4289
  // src/score/engine/obj-ending.ts
4269
- var import_ts_utils_lib6 = require("@tspro/ts-utils-lib");
4290
+ var import_ts_utils_lib7 = require("@tspro/ts-utils-lib");
4270
4291
  var import_core10 = require("@tspro/web-music-score/core");
4271
4292
  var ObjEnding = class extends MusicObject {
4272
4293
  constructor(measure, passages) {
@@ -4277,9 +4298,9 @@ var ObjEnding = class extends MusicObject {
4277
4298
  __publicField(this, "shapeRects", []);
4278
4299
  __publicField(this, "mi");
4279
4300
  this.mi = new MEnding(this);
4280
- if (!import_ts_utils_lib6.Utils.Is.isIntegerGte(passages.length, 1)) {
4301
+ if (!import_ts_utils_lib7.Utils.Is.isIntegerGte(passages.length, 1)) {
4281
4302
  throw new import_core10.MusicError(import_core10.MusicErrorType.Score, "Passages is empty.");
4282
- } else if (!this.passages.every((p) => import_ts_utils_lib6.Utils.Is.isIntegerGte(p, 1))) {
4303
+ } else if (!this.passages.every((p) => import_ts_utils_lib7.Utils.Is.isIntegerGte(p, 1))) {
4283
4304
  throw new import_core10.MusicError(import_core10.MusicErrorType.Score, "Invalid passages: " + this.passages);
4284
4305
  }
4285
4306
  this.passages.sort((a, b) => a - b);
@@ -4295,7 +4316,7 @@ var ObjEnding = class extends MusicObject {
4295
4316
  isSingleMeasureEnding() {
4296
4317
  let { measure } = this;
4297
4318
  let next = measure.getNextMeasure();
4298
- return (next == null ? void 0 : next.hasNavigation(10 /* Ending */)) === true || measure.hasNavigation(9 /* EndRepeat */) || measure.isLastMeasure();
4319
+ return (next == null ? void 0 : next.hasNavigation("ending" /* Ending */)) === true || measure.hasNavigation("endRepeat" /* EndRepeat */) || measure.isLastMeasure();
4299
4320
  }
4300
4321
  hasPassage(pass) {
4301
4322
  return this.passages.some((p) => p === pass);
@@ -4415,9 +4436,10 @@ var ObjFermata = class extends MusicObject {
4415
4436
 
4416
4437
  // src/score/engine/obj-extension-line.ts
4417
4438
  var ObjExtensionLine = class extends MusicObject {
4418
- constructor(measure, extension, leftObj, rightObj) {
4439
+ constructor(measure, line, extension, leftObj, rightObj) {
4419
4440
  super(measure);
4420
4441
  this.measure = measure;
4442
+ this.line = line;
4421
4443
  this.extension = extension;
4422
4444
  this.leftObj = leftObj;
4423
4445
  this.rightObj = rightObj;
@@ -4480,7 +4502,7 @@ var ObjExtensionLine = class extends MusicObject {
4480
4502
  ctx.setLineDash([]);
4481
4503
  let tails = this.extension.getTails();
4482
4504
  if (tails.length > 0 && this === tails[tails.length - 1]) {
4483
- let tipH = rect.centerY > this.measure.row.getRect().centerY ? -renderer.unitSize : renderer.unitSize;
4505
+ let tipH = rect.centerY > this.line.getRect().centerY ? -renderer.unitSize : renderer.unitSize;
4484
4506
  renderer.drawLine(rect.right, rect.centerY, rect.right, rect.centerY + tipH, "black", renderer.lineWidth);
4485
4507
  }
4486
4508
  }
@@ -4493,7 +4515,7 @@ var import_core13 = require("@tspro/web-music-score/core");
4493
4515
  var import_theory8 = require("@tspro/web-music-score/theory");
4494
4516
 
4495
4517
  // src/score/engine/obj-connective.ts
4496
- var import_ts_utils_lib7 = require("@tspro/ts-utils-lib");
4518
+ var import_ts_utils_lib8 = require("@tspro/ts-utils-lib");
4497
4519
  var import_core11 = require("@tspro/web-music-score/core");
4498
4520
  var ObjConnective = class extends MusicObject {
4499
4521
  constructor(connectiveProps, line, measure, leftNoteGroup, leftNoteId, ...args) {
@@ -4522,7 +4544,7 @@ var ObjConnective = class extends MusicObject {
4522
4544
  this.rightNoteGroup = args[0];
4523
4545
  this.rightNoteId = args[1];
4524
4546
  this.tieType = void 0;
4525
- } else if (import_ts_utils_lib7.Utils.Is.isEnumValue(args[0], TieType)) {
4547
+ } else if (import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], TieType)) {
4526
4548
  this.rightNoteGroup = void 0;
4527
4549
  this.rightNoteId = void 0;
4528
4550
  this.tieType = args[0];
@@ -4553,7 +4575,7 @@ var ObjConnective = class extends MusicObject {
4553
4575
  if (rightNoteGroup !== void 0 && rightNoteId !== void 0) {
4554
4576
  rightPos = rightNoteGroup.getConnectiveAnchorPoint(connectiveProps, line, rightNoteId, noteAnchor, "right");
4555
4577
  } else {
4556
- rightPos = this.tieType === -2 /* ToMeasureEnd */ ? { x: measure.getColumnsContentRect().right, y: leftPos.y } : { x: leftPos.x + unitSize * DocumentSettings.StubTieLength, y: leftPos.y };
4578
+ rightPos = this.tieType === "toMeasureEnd" /* ToMeasureEnd */ ? { x: measure.getColumnsContentRect().right, y: leftPos.y } : { x: leftPos.x + unitSize * DocumentSettings.StubTieLength, y: leftPos.y };
4557
4579
  }
4558
4580
  let lx, ly, rx, ry;
4559
4581
  if (rightNoteGroup === void 0) {
@@ -4591,8 +4613,8 @@ var ObjConnective = class extends MusicObject {
4591
4613
  this.ly = ly;
4592
4614
  this.rx = rx;
4593
4615
  this.ry = ry;
4594
- this.arcHeight = this.connectiveProps.connective === 2 /* Slide */ ? 0 : arcHeight;
4595
- let { nx, ny } = import_ts_utils_lib7.Utils.Math.calcNormal(lx, ly, rx, ry);
4616
+ this.arcHeight = this.connectiveProps.connective === "slide" /* Slide */ ? 0 : arcHeight;
4617
+ let { nx, ny } = import_ts_utils_lib8.Utils.Math.calcNormal(lx, ly, rx, ry);
4596
4618
  this.cp1x = lx * 0.7 + rx * 0.3 + nx * this.arcHeight;
4597
4619
  this.cp1y = ly * 0.7 + ry * 0.3 + ny * this.arcHeight;
4598
4620
  this.cp2x = lx * 0.3 + rx * 0.7 + nx * this.arcHeight;
@@ -4653,6 +4675,7 @@ var ObjConnective = class extends MusicObject {
4653
4675
 
4654
4676
  // src/score/engine/connective-props.ts
4655
4677
  var import_core12 = require("@tspro/web-music-score/core");
4678
+ var import_ts_utils_lib9 = require("@tspro/ts-utils-lib");
4656
4679
  var ConnectiveProps = class {
4657
4680
  constructor(connective, span, noteAnchor, startNoteGroup) {
4658
4681
  this.connective = connective;
@@ -4674,7 +4697,7 @@ var ConnectiveProps = class {
4674
4697
  * @returns true if noteGroup was added, false if not.
4675
4698
  */
4676
4699
  addNoteGroup(noteGroup) {
4677
- if (this.span === -1 /* Stub */ || this.span === -2 /* ToMeasureEnd */) {
4700
+ if (this.span === "stub" /* Stub */ || this.span === "toMeasureEnd" /* ToMeasureEnd */) {
4678
4701
  return false;
4679
4702
  } else if (this.span > this.noteGroups.length) {
4680
4703
  this.noteGroups.push(noteGroup);
@@ -4684,29 +4707,29 @@ var ConnectiveProps = class {
4684
4707
  }
4685
4708
  }
4686
4709
  computeParams() {
4687
- let stemDir = this.noteGroups[0].stemDir;
4688
- let hasStem = this.noteGroups[0].rhythmProps.hasStem;
4689
- if (this.noteAnchor === 4 /* StemTip */) {
4690
- this.arcDir = stemDir === 1 /* Up */ ? "up" : "down";
4691
- } else if (this.noteAnchor === 0 /* Auto */) {
4692
- this.arcDir = stemDir === 1 /* Up */ || !hasStem ? "down" : "up";
4710
+ let { stemDir } = this.noteGroups[0];
4711
+ let { hasStem } = this.noteGroups[0].rhythmProps;
4712
+ if (this.noteAnchor === "stemTip" /* StemTip */) {
4713
+ this.arcDir = stemDir === "up" /* Up */ ? "up" : "down";
4714
+ } else if (this.noteAnchor === "auto" /* Auto */) {
4715
+ this.arcDir = stemDir === "up" /* Up */ || !hasStem ? "down" : "up";
4693
4716
  if (this.noteGroups[0].notes.length > 1) {
4694
- this.noteAnchor = 2 /* Center */;
4695
- } else if (this.connective === 2 /* Slide */) {
4696
- this.noteAnchor = 2 /* Center */;
4717
+ this.noteAnchor = "center" /* Center */;
4718
+ } else if (this.connective === "slide" /* Slide */) {
4719
+ this.noteAnchor = "center" /* Center */;
4697
4720
  } else if (this.arcDir === "up") {
4698
- this.noteAnchor = 1 /* Above */;
4721
+ this.noteAnchor = "above" /* Above */;
4699
4722
  } else {
4700
- this.noteAnchor = 3 /* Below */;
4723
+ this.noteAnchor = "below" /* Below */;
4701
4724
  }
4702
- } else if (this.noteAnchor === 2 /* Center */) {
4725
+ } else if (this.noteAnchor === "center" /* Center */) {
4703
4726
  let { row } = this.noteGroups[0].measure;
4704
4727
  let diatonicId = this.noteGroups[0].ownDiatonicId;
4705
4728
  let staff = row.getStaff(diatonicId);
4706
4729
  this.arcDir = !staff || diatonicId < staff.middleLineDiatonicId ? "down" : "up";
4707
- } else if (this.noteAnchor === 1 /* Above */) {
4730
+ } else if (this.noteAnchor === "above" /* Above */) {
4708
4731
  this.arcDir = "up";
4709
- } else if (this.noteAnchor === 3 /* Below */) {
4732
+ } else if (this.noteAnchor === "below" /* Below */) {
4710
4733
  this.arcDir = "down";
4711
4734
  }
4712
4735
  }
@@ -4721,8 +4744,8 @@ var ConnectiveProps = class {
4721
4744
  this.getStartNoteGroup().collectConnectiveProps();
4722
4745
  this.computeParams();
4723
4746
  let { connective, span } = this;
4724
- if (connective === 0 /* Tie */) {
4725
- if (span === -1 /* Stub */ || span === -2 /* ToMeasureEnd */) {
4747
+ if (connective === "tie" /* Tie */) {
4748
+ if (import_ts_utils_lib9.Utils.Is.isEnumValue(span, TieType)) {
4726
4749
  let leftNoteGroup = this.noteGroups[0];
4727
4750
  for (let noteId = 0; noteId < leftNoteGroup.notes.length; noteId++) {
4728
4751
  this.createObjConnectiveWithTieType(leftNoteGroup, noteId, span);
@@ -4739,13 +4762,13 @@ var ConnectiveProps = class {
4739
4762
  });
4740
4763
  }
4741
4764
  }
4742
- } else if (connective === 1 /* Slur */) {
4765
+ } else if (connective === "slur" /* Slur */) {
4743
4766
  if (typeof span === "number" && span >= 2 && this.noteGroups.length === span) {
4744
4767
  let leftNoteGroup = this.noteGroups[0];
4745
4768
  let rightNoteGroup = this.noteGroups[this.noteGroups.length - 1];
4746
4769
  this.createObjConnective(leftNoteGroup, 0, rightNoteGroup, 0);
4747
4770
  }
4748
- } else if (connective === 2 /* Slide */) {
4771
+ } else if (connective === "slide" /* Slide */) {
4749
4772
  if (this.noteGroups.length >= 2) {
4750
4773
  for (let i = 0; i < this.noteGroups.length - 1; i++) {
4751
4774
  let leftNoteGroup = this.noteGroups[i];
@@ -4775,7 +4798,7 @@ var ConnectiveProps = class {
4775
4798
  } else {
4776
4799
  let leftString = leftNoteGroup2.getFretNumberString(leftNoteId2);
4777
4800
  let rightString = rightNoteGroup2.getFretNumberString(rightNoteId2);
4778
- if (leftString !== void 0 && rightString !== void 0 && (leftString === rightString || this.connective === 1 /* Slur */)) {
4801
+ if (leftString !== void 0 && rightString !== void 0 && (leftString === rightString || this.connective === "slur" /* Slur */)) {
4779
4802
  new ObjConnective(this, line, measure, leftNoteGroup2, leftNoteId2, rightNoteGroup2, rightNoteId2);
4780
4803
  }
4781
4804
  }
@@ -4800,6 +4823,32 @@ function validateVoiceId(voiceId) {
4800
4823
  return voiceId;
4801
4824
  }
4802
4825
  }
4826
+ function getExtensionTicks(extensionLength) {
4827
+ if (typeof extensionLength === "string") {
4828
+ extensionLength = [extensionLength];
4829
+ }
4830
+ if (import_ts_utils_lib10.Utils.Is.isArray(extensionLength)) {
4831
+ let totalTicks = 0;
4832
+ for (let i = 0; i < extensionLength.length; ) {
4833
+ let str = extensionLength[i];
4834
+ let num = extensionLength[i + 1];
4835
+ if (typeof str === "string") {
4836
+ i++;
4837
+ let ticks = import_theory9.RhythmProps.get(str).ticks;
4838
+ if (typeof num === "number") {
4839
+ i++;
4840
+ ticks *= num;
4841
+ }
4842
+ totalTicks += ticks;
4843
+ } else {
4844
+ i++;
4845
+ }
4846
+ }
4847
+ return totalTicks;
4848
+ } else {
4849
+ return extensionLength;
4850
+ }
4851
+ }
4803
4852
  var _ObjMeasure = class _ObjMeasure extends MusicObject {
4804
4853
  constructor(row) {
4805
4854
  super(row);
@@ -4903,15 +4952,15 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
4903
4952
  if (setStemDir !== void 0) {
4904
4953
  this.useStemDir[voiceId] = setStemDir;
4905
4954
  } else if (this.useStemDir[voiceId] === void 0) {
4906
- this.useStemDir[voiceId] = (_b = (_a = this.getPrevMeasure()) == null ? void 0 : _a.useStemDir[voiceId]) != null ? _b : 0 /* Auto */;
4955
+ this.useStemDir[voiceId] = (_b = (_a = this.getPrevMeasure()) == null ? void 0 : _a.useStemDir[voiceId]) != null ? _b : "auto" /* Auto */;
4907
4956
  }
4908
4957
  let stemDir = this.useStemDir[voiceId];
4909
- if (stemDir === 0 /* Auto */ || stemDir === void 0) {
4958
+ if (stemDir === "auto" /* Auto */ || stemDir === void 0) {
4910
4959
  let staff = this.row.getStaff(symbol.ownDiatonicId);
4911
4960
  if (staff) {
4912
- return symbol.ownDiatonicId > staff.middleLineDiatonicId ? 2 /* Down */ : 1 /* Up */;
4961
+ return symbol.ownDiatonicId > staff.middleLineDiatonicId ? "down" /* Down */ : "up" /* Up */;
4913
4962
  } else {
4914
- return 1 /* Up */;
4963
+ return "up" /* Up */;
4915
4964
  }
4916
4965
  } else {
4917
4966
  return stemDir;
@@ -5018,6 +5067,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5018
5067
  // See MMeasure interface
5019
5068
  //setKeySignature(tonic: string, scaleType: ScaleType): void;
5020
5069
  //setKeySignature(keySignature: KeySignature): void;
5070
+ //setKeySignature(keySignature: string): void;
5021
5071
  //setKeySignature(scale: Scale): void;
5022
5072
  setKeySignature(...args) {
5023
5073
  var _a;
@@ -5026,13 +5076,17 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5026
5076
  this.alterKeySignature = args[0];
5027
5077
  } else if (args[0] instanceof import_theory9.Scale) {
5028
5078
  this.alterKeySignature = args[0];
5029
- } else {
5030
- try {
5031
- let tonic = "" + args[0];
5032
- let scaleType = (0, import_theory9.validateScaleType)("" + args[1]);
5033
- this.alterKeySignature = (0, import_theory9.getScale)(tonic, scaleType);
5034
- } catch (e) {
5035
- throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot set key signature because invalid args: " + args);
5079
+ } else if (import_ts_utils_lib10.Utils.Is.isNonEmptyString(args[0])) {
5080
+ if (args.length === 1) {
5081
+ this.alterKeySignature = (0, import_theory9.getScale)(args[0]);
5082
+ } else if (args.length === 2) {
5083
+ try {
5084
+ let tonic = "" + args[0];
5085
+ let scaleType = (0, import_theory9.validateScaleType)("" + args[1]);
5086
+ this.alterKeySignature = (0, import_theory9.getScale)(tonic, scaleType);
5087
+ } catch (e) {
5088
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot set key signature because invalid args: " + args);
5089
+ }
5036
5090
  }
5037
5091
  }
5038
5092
  this.updateKeySignature();
@@ -5072,8 +5126,16 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5072
5126
  setTempo(beatsPerMinute, beatLength, dotted) {
5073
5127
  var _a;
5074
5128
  (_a = this.getPrevMeasure()) == null ? void 0 : _a.endSection();
5075
- let options = beatLength !== void 0 ? { beatLength, dotted } : void 0;
5076
- this.alterTempo = { beatsPerMinute, options };
5129
+ if (beatLength === void 0) {
5130
+ this.alterTempo = { beatsPerMinute };
5131
+ } else {
5132
+ let dotCount = typeof dotted === "number" && dotted > 0 ? dotted : dotted === true ? 1 : import_theory9.NoteLengthProps.get(beatLength).dotCount;
5133
+ let options = {
5134
+ beatLength: (0, import_theory9.validateNoteLength)(beatLength),
5135
+ dotCount: dotCount > 0 ? dotCount : void 0
5136
+ };
5137
+ this.alterTempo = { beatsPerMinute, options };
5138
+ }
5077
5139
  this.updateTempo();
5078
5140
  }
5079
5141
  updateTempo() {
@@ -5082,18 +5144,18 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5082
5144
  if (this.alterTempo) {
5083
5145
  let beatsPerMinute = this.alterTempo.beatsPerMinute;
5084
5146
  let beatLength;
5085
- let dotted;
5147
+ let dotCount;
5086
5148
  if (this.alterTempo.options) {
5087
5149
  beatLength = this.alterTempo.options.beatLength;
5088
- dotted = (_a = this.alterTempo.options.dotted) != null ? _a : false;
5150
+ dotCount = (_a = this.alterTempo.options.dotCount) != null ? _a : 0;
5089
5151
  } else if (this.alterTimeSignature) {
5090
5152
  beatLength = this.alterTimeSignature.beatLength;
5091
- dotted = false;
5153
+ dotCount = 0;
5092
5154
  } else {
5093
5155
  beatLength = this.tempo.options.beatLength;
5094
- dotted = this.tempo.options.dotted;
5156
+ dotCount = this.tempo.options.dotCount;
5095
5157
  }
5096
- this.tempo = { beatsPerMinute, options: { beatLength, dotted } };
5158
+ this.tempo = { beatsPerMinute, options: { beatLength, dotCount } };
5097
5159
  }
5098
5160
  if (this.nextMeasure) {
5099
5161
  this.nextMeasure.updateTempo();
@@ -5125,19 +5187,19 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5125
5187
  let grp = this.doc.getStaffGroup(staffTabOrGroup);
5126
5188
  if (grp && !prevGroups.includes(staffTabOrGroup)) {
5127
5189
  let curGroups = [...prevGroups, staffTabOrGroup];
5128
- (import_ts_utils_lib8.Utils.Is.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
5190
+ (import_ts_utils_lib10.Utils.Is.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
5129
5191
  switch (grp.verticalPosition) {
5130
- case 0 /* Above */:
5192
+ case "above" /* Above */:
5131
5193
  addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
5132
5194
  break;
5133
- case 1 /* Below */:
5195
+ case "below" /* Below */:
5134
5196
  addToStaffTabOrGroup(staffTabOrGroup2, 1 /* Below */, curGroups);
5135
5197
  break;
5136
- case 2 /* Both */:
5198
+ case "both" /* Both */:
5137
5199
  addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
5138
5200
  addToStaffTabOrGroup(staffTabOrGroup2, 1 /* Below */, curGroups);
5139
5201
  break;
5140
- case 3 /* Auto */:
5202
+ case "auto" /* Auto */:
5141
5203
  addToStaffTabOrGroup(staffTabOrGroup2, defaultVerticalPos, curGroups);
5142
5204
  break;
5143
5205
  }
@@ -5152,14 +5214,14 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5152
5214
  } else {
5153
5215
  addToStaffTabOrGroup(0, defaultVerticalPos);
5154
5216
  }
5155
- } else if (import_ts_utils_lib8.Utils.Is.isArray(staffTabOrGroups)) {
5217
+ } else if (import_ts_utils_lib10.Utils.Is.isArray(staffTabOrGroups)) {
5156
5218
  staffTabOrGroups.forEach((staffTabOrGroup) => addToStaffTabOrGroup(staffTabOrGroup, defaultVerticalPos));
5157
5219
  } else {
5158
5220
  addToStaffTabOrGroup(staffTabOrGroups, defaultVerticalPos);
5159
5221
  }
5160
5222
  }
5161
5223
  addFermata(staffTabOrGroups, fermata) {
5162
- let anchor = fermata === 1 /* AtMeasureEnd */ ? this.barLineRight : this.lastAddedRhythmColumn;
5224
+ let anchor = fermata === "atMeasureEnd" /* AtMeasureEnd */ ? this.barLineRight : this.lastAddedRhythmColumn;
5163
5225
  if (!anchor) {
5164
5226
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add Fermata because anchor is undefined.");
5165
5227
  }
@@ -5175,7 +5237,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5175
5237
  addNavigation(staffTabOrGroups, navigation, ...args) {
5176
5238
  let addLayoutObjectProps = void 0;
5177
5239
  switch (navigation) {
5178
- case 10 /* Ending */:
5240
+ case "ending" /* Ending */:
5179
5241
  if (this.navigationSet.has(navigation)) {
5180
5242
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add ending beasure measure already has one.");
5181
5243
  }
@@ -5187,10 +5249,10 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5187
5249
  defaultVerticalPos: 0 /* Above */
5188
5250
  };
5189
5251
  break;
5190
- case 1 /* DC_al_Coda */:
5191
- case 0 /* DC_al_Fine */:
5192
- case 3 /* DS_al_Coda */:
5193
- case 2 /* DS_al_Fine */: {
5252
+ case "D.C. al Coda" /* DC_al_Coda */:
5253
+ case "D.C. al Fine" /* DC_al_Fine */:
5254
+ case "D.S. al Coda" /* DS_al_Coda */:
5255
+ case "D.S. al Fine" /* DS_al_Fine */: {
5194
5256
  let anchor2 = this.barLineRight;
5195
5257
  let text = getNavigationString(navigation);
5196
5258
  addLayoutObjectProps = {
@@ -5198,11 +5260,11 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5198
5260
  layoutGroupId: 2 /* Navigation */,
5199
5261
  defaultVerticalPos: 0 /* Above */
5200
5262
  };
5201
- this.addNavigation(staffTabOrGroups, 9 /* EndRepeat */);
5263
+ this.addNavigation(staffTabOrGroups, "endRepeat" /* EndRepeat */);
5202
5264
  this.endSong();
5203
5265
  break;
5204
5266
  }
5205
- case 7 /* Fine */: {
5267
+ case "Fine" /* Fine */: {
5206
5268
  let anchor2 = this.barLineRight;
5207
5269
  let text = getNavigationString(navigation);
5208
5270
  addLayoutObjectProps = {
@@ -5212,8 +5274,8 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5212
5274
  };
5213
5275
  break;
5214
5276
  }
5215
- case 6 /* Segno */:
5216
- case 4 /* Coda */: {
5277
+ case "Segno" /* Segno */:
5278
+ case "Coda" /* Coda */: {
5217
5279
  let anchor2 = this.barLineLeft;
5218
5280
  let text = getNavigationString(navigation);
5219
5281
  addLayoutObjectProps = {
@@ -5223,7 +5285,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5223
5285
  };
5224
5286
  break;
5225
5287
  }
5226
- case 5 /* toCoda */: {
5288
+ case "toCoda" /* toCoda */: {
5227
5289
  let anchor2 = this.barLineRight;
5228
5290
  let text = getNavigationString(navigation);
5229
5291
  addLayoutObjectProps = {
@@ -5233,10 +5295,10 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5233
5295
  };
5234
5296
  break;
5235
5297
  }
5236
- case 9 /* EndRepeat */:
5298
+ case "endRepeat" /* EndRepeat */:
5237
5299
  if (args.length === 0) {
5238
5300
  this.endRepeatPlayCount = 2;
5239
- } else if (import_ts_utils_lib8.Utils.Is.isIntegerGte(args[0], 2)) {
5301
+ } else if (import_ts_utils_lib10.Utils.Is.isIntegerGte(args[0], 2)) {
5240
5302
  this.endRepeatPlayCount = args[0];
5241
5303
  } else {
5242
5304
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Invalid end repeat play count (should be 2 or greater integer): " + args[0]);
@@ -5272,17 +5334,18 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5272
5334
  let layoutGroupId;
5273
5335
  let defaultVerticalPos;
5274
5336
  switch (annotation) {
5275
- case 0 /* Dynamics */:
5337
+ case "dynamics" /* Dynamics */:
5276
5338
  layoutGroupId = 5 /* DynamicsAnnotation */;
5277
5339
  defaultVerticalPos = 0 /* Above */;
5278
5340
  textProps.italic = true;
5279
5341
  break;
5280
- case 1 /* Tempo */:
5342
+ case "tempo" /* Tempo */:
5281
5343
  layoutGroupId = 4 /* TempoAnnotation */;
5282
5344
  defaultVerticalPos = 0 /* Above */;
5283
5345
  textProps.italic = true;
5284
5346
  break;
5285
5347
  }
5348
+ this.disableExtension();
5286
5349
  this.forEachStaffGroup(staffTabOrGroups, defaultVerticalPos, (line, vpos) => {
5287
5350
  let textObj = new ObjText(anchor, textProps, 0.5, 1);
5288
5351
  this.addLayoutObject(textObj, line, layoutGroupId, vpos);
@@ -5300,15 +5363,16 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5300
5363
  let layoutGroupId;
5301
5364
  let defaultVerticalPos;
5302
5365
  switch (label) {
5303
- case 0 /* Note */:
5366
+ case "note" /* Note */:
5304
5367
  layoutGroupId = 1 /* NoteLabel */;
5305
5368
  defaultVerticalPos = 1 /* Below */;
5306
5369
  break;
5307
- case 1 /* Chord */:
5370
+ case "chord" /* Chord */:
5308
5371
  layoutGroupId = 6 /* ChordLabel */;
5309
5372
  defaultVerticalPos = 0 /* Above */;
5310
5373
  break;
5311
5374
  }
5375
+ this.disableExtension();
5312
5376
  this.forEachStaffGroup(staffTabOrGroups, defaultVerticalPos, (line, vpos) => {
5313
5377
  let textObj = new ObjText(anchor, textProps, 0.5, 1);
5314
5378
  this.addLayoutObject(textObj, line, layoutGroupId, vpos);
@@ -5320,17 +5384,17 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5320
5384
  if (!(anchor instanceof ObjNoteGroup)) {
5321
5385
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Connective can be added to note group only.");
5322
5386
  }
5323
- if (connective === 0 /* Tie */) {
5324
- let tieSpan = import_ts_utils_lib8.Utils.Is.isInteger(args[0]) || import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], TieType) ? args[0] : 2;
5325
- let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : 0 /* Auto */;
5326
- anchor.startConnective(new ConnectiveProps(0 /* Tie */, tieSpan, noteAnchor, anchor));
5327
- } else if (connective === 1 /* Slur */) {
5328
- let slurSpan = import_ts_utils_lib8.Utils.Is.isInteger(args[0]) ? args[0] : 2;
5329
- let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : 0 /* Auto */;
5330
- anchor.startConnective(new ConnectiveProps(1 /* Slur */, slurSpan, noteAnchor, anchor));
5331
- } else if (connective === 2 /* Slide */) {
5332
- let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], NoteAnchor) ? args[0] : 0 /* Auto */;
5333
- anchor.startConnective(new ConnectiveProps(2 /* Slide */, 2, noteAnchor, anchor));
5387
+ if (connective === "tie" /* Tie */) {
5388
+ let tieSpan = import_ts_utils_lib10.Utils.Is.isInteger(args[0]) || import_ts_utils_lib10.Utils.Is.isEnumValue(args[0], TieType) ? args[0] : 2;
5389
+ let noteAnchor = import_ts_utils_lib10.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
5390
+ anchor.startConnective(new ConnectiveProps("tie" /* Tie */, tieSpan, noteAnchor, anchor));
5391
+ } else if (connective === "slur" /* Slur */) {
5392
+ let slurSpan = import_ts_utils_lib10.Utils.Is.isInteger(args[0]) ? args[0] : 2;
5393
+ let noteAnchor = import_ts_utils_lib10.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
5394
+ anchor.startConnective(new ConnectiveProps("slur" /* Slur */, slurSpan, noteAnchor, anchor));
5395
+ } else if (connective === "slide" /* Slide */) {
5396
+ let noteAnchor = import_ts_utils_lib10.Utils.Is.isEnumValue(args[0], NoteAnchor) ? args[0] : "auto" /* Auto */;
5397
+ anchor.startConnective(new ConnectiveProps("slide" /* Slide */, 2, noteAnchor, anchor));
5334
5398
  }
5335
5399
  }
5336
5400
  addExtension(extensionLength, extensionVisible) {
@@ -5339,7 +5403,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5339
5403
  if (musicObj instanceof ObjText && anchor instanceof ObjRhythmColumn) {
5340
5404
  let lineStyle = "dashed";
5341
5405
  let linePos = "bottom";
5342
- let extension = new Extension(musicObj, anchor, extensionLength, extensionVisible, lineStyle, linePos);
5406
+ let extension = new Extension(musicObj, anchor, getExtensionTicks(extensionLength), extensionVisible, lineStyle, linePos);
5343
5407
  musicObj.setLink(extension);
5344
5408
  } else {
5345
5409
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add extension becaue no compatible music object to attach it to.");
@@ -5388,18 +5452,25 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5388
5452
  col.setVoiceSymbol(voiceId, symbol);
5389
5453
  this.getVoiceSymbols(voiceId);
5390
5454
  this.voiceSymbols[voiceId].push(symbol);
5455
+ if (symbol.oldStyleTriplet) {
5456
+ this.createOldStyleTriplets(voiceId);
5457
+ }
5391
5458
  this.requestBeamsUpdate();
5392
5459
  this.lastAddedRhythmColumn = col;
5393
5460
  this.lastAddedRhythmSymbol = symbol;
5394
5461
  }
5395
- addNoteGroup(voiceId, notes, noteLength, options) {
5396
- let notes2 = notes.map((note) => typeof note === "string" ? import_theory9.Note.getNote(note) : note);
5462
+ addNoteGroup(voiceId, notes, noteLength, options, tupletRatio) {
5463
+ let realNotes = notes.map((note) => typeof note === "string" ? import_theory9.Note.getNote(note) : note);
5397
5464
  let col = this.getRhythmColumn(voiceId);
5398
- this.addRhythmSymbol(voiceId, new ObjNoteGroup(col, voiceId, notes2, noteLength, options));
5465
+ let noteGroup = new ObjNoteGroup(col, voiceId, realNotes, noteLength, options, tupletRatio);
5466
+ this.addRhythmSymbol(voiceId, noteGroup);
5467
+ return noteGroup;
5399
5468
  }
5400
- addRest(voiceId, restLength, options) {
5469
+ addRest(voiceId, restLength, options, tupletRatio) {
5401
5470
  let col = this.getRhythmColumn(voiceId);
5402
- this.addRhythmSymbol(voiceId, new ObjRest(col, voiceId, restLength, options));
5471
+ let rest = new ObjRest(col, voiceId, restLength, options, tupletRatio);
5472
+ this.addRhythmSymbol(voiceId, rest);
5473
+ return rest;
5403
5474
  }
5404
5475
  /**
5405
5476
  *
@@ -5527,7 +5598,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5527
5598
  const lines = m.row.getNotationLines();
5528
5599
  let line2 = (_a = lines.find((l) => l.name !== "" && l.name === line.name)) != null ? _a : lines[line.id];
5529
5600
  if (line2) {
5530
- m.addLayoutObject(new ObjExtensionLine(m, extension, leftObj, rightObj), line2, layoutGroupId, verticalPos);
5601
+ m.addLayoutObject(new ObjExtensionLine(m, line2, extension, leftObj, rightObj), line2, layoutGroupId, verticalPos);
5531
5602
  }
5532
5603
  }
5533
5604
  }
@@ -5541,28 +5612,36 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5541
5612
  requestBeamsUpdate() {
5542
5613
  this.needBeamsUpdate = true;
5543
5614
  }
5615
+ // Create triplets by triplet property of NoteOptions/RestOptions.
5616
+ createOldStyleTriplets(voiceId) {
5617
+ let symbols = this.getVoiceSymbols(voiceId);
5618
+ for (let i = 0; i < symbols.length; ) {
5619
+ if (symbols[i].oldStyleTriplet) {
5620
+ let n = ObjBeamGroup.createOldStyleTriplet(symbols.slice(i, i + 3));
5621
+ i += n === 0 ? 1 : n;
5622
+ } else {
5623
+ i++;
5624
+ }
5625
+ }
5626
+ this.requestLayout();
5627
+ }
5544
5628
  createBeams() {
5545
- if (!this.needBeamsUpdate || !this.row.hasStaff) {
5629
+ if (!this.needBeamsUpdate) {
5546
5630
  return;
5547
5631
  }
5548
- this.beamGroups.forEach((beamGroup) => beamGroup.detach());
5549
- this.beamGroups.length = 0;
5632
+ this.beamGroups = this.beamGroups.filter((beamGroup) => {
5633
+ if (beamGroup.isTuplet()) {
5634
+ return true;
5635
+ } else {
5636
+ beamGroup.detach();
5637
+ return false;
5638
+ }
5639
+ });
5550
5640
  getVoiceIds().forEach((voiceId) => {
5551
5641
  let symbols = this.getVoiceSymbols(voiceId);
5552
5642
  if (symbols.length <= 2) {
5553
5643
  return;
5554
5644
  }
5555
- for (let i = 0; i < symbols.length; ) {
5556
- let s2 = symbols.slice(i, i + 2);
5557
- let s3 = symbols.slice(i, i + 3);
5558
- if (s2.length === 2 && ObjBeamGroup.createTriplet(s2)) {
5559
- i += 2;
5560
- } else if (s3.length === 3 && ObjBeamGroup.createTriplet(s3)) {
5561
- i += 3;
5562
- } else {
5563
- i++;
5564
- }
5565
- }
5566
5645
  if (!DebugSettings.DisableBeams) {
5567
5646
  let groupSymbols = [];
5568
5647
  let groupStartTicks = 0;
@@ -5591,7 +5670,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5591
5670
  static setupBeamGroup(groupSymbols) {
5592
5671
  let groupNotes = groupSymbols.map((s) => {
5593
5672
  var _a;
5594
- return s instanceof ObjNoteGroup && ((_a = s.getBeamGroup()) == null ? void 0 : _a.isTriplet()) !== true ? s : void 0;
5673
+ return s instanceof ObjNoteGroup && ((_a = s.getBeamGroup()) == null ? void 0 : _a.isTuplet()) !== true ? s : void 0;
5595
5674
  });
5596
5675
  ObjNoteGroup.setBeamCounts(groupNotes);
5597
5676
  let beamNotes = [];
@@ -5623,36 +5702,32 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5623
5702
  if (this.getConsumedTicks() === 0) {
5624
5703
  this.completeRests(0);
5625
5704
  } else {
5626
- getVoiceIds().forEach((voiceId2) => {
5627
- if (this.getConsumedTicks(voiceId2) > 0) {
5628
- this.completeRests(voiceId2);
5629
- }
5630
- });
5705
+ this.completeRests(getVoiceIds().filter((id) => this.getConsumedTicks(id) > 0));
5631
5706
  }
5632
5707
  return;
5633
- }
5634
- let measureTicks = this.getMeasureTicks();
5635
- let consumedTicks = this.getConsumedTicks(voiceId);
5636
- let remainingTicks = measureTicks - consumedTicks;
5637
- let rests = [];
5638
- let noteLengthValues = import_ts_utils_lib8.Utils.Enum.getEnumValues(import_theory9.NoteLength);
5639
- while (remainingTicks > 0) {
5640
- noteLengthValues.forEach((restLength) => {
5641
- let restValue = new import_theory9.RhythmProps(restLength, false);
5642
- if (restValue.canDot()) {
5643
- let dottedRestValue = new import_theory9.RhythmProps(restLength, true);
5644
- while (dottedRestValue.ticks <= remainingTicks) {
5645
- rests.push(dottedRestValue);
5646
- remainingTicks -= dottedRestValue.ticks;
5708
+ } else if (import_ts_utils_lib10.Utils.Is.isArray(voiceId)) {
5709
+ voiceId.forEach((id) => this.completeRests(id));
5710
+ return;
5711
+ } else {
5712
+ validateVoiceId(voiceId);
5713
+ let measureTicks = this.getMeasureTicks();
5714
+ let consumedTicks = this.getConsumedTicks(voiceId);
5715
+ let remainingTicks = measureTicks - consumedTicks;
5716
+ let rests = [];
5717
+ while (remainingTicks > 0) {
5718
+ for (let noteSize = import_theory9.NoteLengthProps.LongestNoteSize; noteSize <= import_theory9.NoteLengthProps.ShortestNoteSize; noteSize *= 2) {
5719
+ let restLength = import_theory9.NoteLengthProps.create(noteSize).noteLength;
5720
+ for (let dotCount = import_theory9.NoteLengthProps.get(restLength).maxDotCount; dotCount >= 0; dotCount--) {
5721
+ let restProps = import_theory9.RhythmProps.get(restLength, dotCount);
5722
+ while (restProps.ticks <= remainingTicks) {
5723
+ rests.push(restProps);
5724
+ remainingTicks -= restProps.ticks;
5725
+ }
5647
5726
  }
5648
5727
  }
5649
- while (restValue.ticks <= remainingTicks) {
5650
- rests.push(restValue);
5651
- remainingTicks -= restValue.ticks;
5652
- }
5653
- });
5728
+ }
5729
+ rests.reverse().forEach((rest) => this.addRest(voiceId, rest.noteLength, { dotted: rest.dotCount }));
5654
5730
  }
5655
- rests.reverse().forEach((rest) => this.addRest(voiceId, rest.noteLength, { dotted: rest.dotted }));
5656
5731
  }
5657
5732
  requestLayout() {
5658
5733
  if (!this.needLayout) {
@@ -5745,7 +5820,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5745
5820
  let columnsAreaLeft = this.rect.left + this.leftSolidAreaWidth;
5746
5821
  let columnsAreaRight = this.rect.right - this.rightSolidAreaWidth;
5747
5822
  let columnsAreaWidth = columnsAreaRight - columnsAreaLeft;
5748
- let columnsWidth = import_ts_utils_lib8.Utils.Math.sum(this.columns.map((col) => col.getRect().width));
5823
+ let columnsWidth = import_ts_utils_lib10.Utils.Math.sum(this.columns.map((col) => col.getRect().width));
5749
5824
  let columnScale = columnsAreaWidth / columnsWidth;
5750
5825
  let columnLeft = columnsAreaLeft;
5751
5826
  this.columns.forEach((col) => {
@@ -6085,10 +6160,12 @@ var ObjStaff = class extends ObjNotationLine4 {
6085
6160
  this.clefImageAsset = 0 /* TrebleClefPng */;
6086
6161
  this.clefLineDiatonicId = getDiatonicId("G4", staffConfig.isOctaveDown === true);
6087
6162
  this.middleLineDiatonicId = this.clefLineDiatonicId + 2;
6088
- } else {
6163
+ } else if (staffConfig.clef === "F" /* F */) {
6089
6164
  this.clefImageAsset = 1 /* BassClefPng */;
6090
6165
  this.clefLineDiatonicId = getDiatonicId("F3", staffConfig.isOctaveDown === true);
6091
6166
  this.middleLineDiatonicId = this.clefLineDiatonicId - 2;
6167
+ } else {
6168
+ throw new import_core15.MusicError(import_core15.MusicErrorType.Score, `Invalid staffConfig.clef ${staffConfig.clef}.`);
6092
6169
  }
6093
6170
  this.topLineDiatonicId = this.middleLineDiatonicId + 4;
6094
6171
  this.bottomLineDiatonicId = this.middleLineDiatonicId - 4;
@@ -6224,7 +6301,7 @@ var ObjTab = class extends ObjNotationLine4 {
6224
6301
  __publicField(this, "tuningName");
6225
6302
  __publicField(this, "tuningStrings");
6226
6303
  __publicField(this, "mi");
6227
- if (import_ts_utils_lib9.Utils.Is.isArray(tabConfig.tuning)) {
6304
+ if (import_ts_utils_lib11.Utils.Is.isArray(tabConfig.tuning)) {
6228
6305
  this.tuningName = void 0;
6229
6306
  this.tuningStrings = tabConfig.tuning.map((noteName) => import_theory11.Note.getNote(noteName)).reverse();
6230
6307
  } else if (typeof tabConfig.tuning === "string") {
@@ -6515,8 +6592,8 @@ var ObjScoreRow = class extends MusicObject {
6515
6592
  updateRect() {
6516
6593
  let left = this.measures.length > 0 ? this.measures[0].getRect().left : 0;
6517
6594
  let right = this.measures.length > 0 ? this.measures[this.measures.length - 1].getRect().right : 0;
6518
- let top = Math.min(0, ...this.measures.map((m) => m.getRect().top));
6519
- let bottom = Math.max(0, ...this.measures.map((m) => m.getRect().bottom));
6595
+ let top = this.measures.length > 0 ? Math.min(...this.measures.map((m) => m.getRect().top)) : 0;
6596
+ let bottom = this.measures.length > 0 ? Math.max(...this.measures.map((m) => m.getRect().bottom)) : 0;
6520
6597
  this.rect = new DivRect(left, right, top, bottom);
6521
6598
  }
6522
6599
  alignStemsToBeams() {
@@ -6679,7 +6756,7 @@ var ObjHeader = class extends MusicObject {
6679
6756
  };
6680
6757
 
6681
6758
  // src/score/engine/obj-document.ts
6682
- var import_ts_utils_lib10 = require("@tspro/ts-utils-lib");
6759
+ var import_ts_utils_lib12 = require("@tspro/ts-utils-lib");
6683
6760
  var ObjDocument = class extends MusicObject {
6684
6761
  constructor() {
6685
6762
  super(void 0);
@@ -6700,35 +6777,35 @@ var ObjDocument = class extends MusicObject {
6700
6777
  return this.mi;
6701
6778
  }
6702
6779
  setScoreConfiguration(config) {
6703
- if (import_ts_utils_lib10.Utils.Is.isEnumValue(config, StaffPreset)) {
6780
+ if (import_ts_utils_lib12.Utils.Is.isEnumValue(config, StaffPreset)) {
6704
6781
  switch (config) {
6705
6782
  default:
6706
- case 1 /* Treble */:
6783
+ case "treble" /* Treble */:
6707
6784
  this.curScoreConfig = [{ type: "staff", clef: "G" /* G */ }];
6708
6785
  break;
6709
- case 2 /* Bass */:
6786
+ case "bass" /* Bass */:
6710
6787
  this.curScoreConfig = [{ type: "staff", clef: "F" /* F */ }];
6711
6788
  break;
6712
- case 3 /* Grand */:
6789
+ case "grand" /* Grand */:
6713
6790
  this.curScoreConfig = [
6714
6791
  { type: "staff", clef: "G" /* G */, isGrand: true },
6715
6792
  { type: "staff", clef: "F" /* F */, isGrand: true }
6716
6793
  ];
6717
6794
  break;
6718
- case 4 /* GuitarTreble */:
6795
+ case "guitarTreble" /* GuitarTreble */:
6719
6796
  this.curScoreConfig = [{ type: "staff", clef: "G" /* G */, isOctaveDown: true }];
6720
6797
  break;
6721
- case 8 /* GuitarTab */:
6798
+ case "guitarTab" /* GuitarTab */:
6722
6799
  this.curScoreConfig = [{ type: "tab", tuning: "Standard" }];
6723
6800
  break;
6724
- case 12 /* GuitarCombined */:
6801
+ case "guitarCombined" /* GuitarCombined */:
6725
6802
  this.curScoreConfig = [
6726
6803
  { type: "staff", clef: "G" /* G */, isOctaveDown: true },
6727
6804
  { type: "tab", tuning: "Standard" }
6728
6805
  ];
6729
6806
  break;
6730
6807
  }
6731
- } else if (import_ts_utils_lib10.Utils.Is.isArray(config)) {
6808
+ } else if (import_ts_utils_lib12.Utils.Is.isArray(config)) {
6732
6809
  this.curScoreConfig = config;
6733
6810
  } else {
6734
6811
  this.curScoreConfig = [config];
@@ -6808,6 +6885,12 @@ var ObjDocument = class extends MusicObject {
6808
6885
  getLastRow() {
6809
6886
  return this.rows.length === 0 ? this.addNewRow(void 0) : this.rows[this.rows.length - 1];
6810
6887
  }
6888
+ getRows() {
6889
+ return this.rows;
6890
+ }
6891
+ getMeasures() {
6892
+ return this.measures;
6893
+ }
6811
6894
  requestNewRow() {
6812
6895
  this.newRowRequested = true;
6813
6896
  }
@@ -6964,85 +7047,105 @@ function isNote(note) {
6964
7047
  }
6965
7048
  }
6966
7049
  function isVoiceId(value) {
6967
- return import_ts_utils_lib11.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
7050
+ return import_ts_utils_lib13.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
6968
7051
  }
6969
7052
  function isStringNumber(value) {
6970
- return import_ts_utils_lib11.Utils.Is.isNumber(value) && getStringNumbers().indexOf(value) >= 0;
7053
+ return import_ts_utils_lib13.Utils.Is.isNumber(value) && getStringNumbers().indexOf(value) >= 0;
6971
7054
  }
6972
7055
  function assertStaffConfig(staffConfig) {
6973
- assertArg(import_ts_utils_lib11.Utils.Is.isObject(staffConfig), "staffConfig", staffConfig);
7056
+ assertArg(import_ts_utils_lib13.Utils.Is.isObject(staffConfig), "staffConfig", staffConfig);
6974
7057
  assertArg(staffConfig.type === "staff", "staffConfig.type", staffConfig.type);
6975
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(staffConfig.clef, Clef), "staffConfig.clef", staffConfig.clef);
6976
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(staffConfig.isOctaveDown), "staffConfig.isOctaveDown", staffConfig.isOctaveDown);
6977
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(staffConfig.minNote) || isNote(staffConfig.minNote), "staffConfig.minNote", staffConfig.minNote);
6978
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(staffConfig.maxNote) || isNote(staffConfig.maxNote), "staffConfig.maxNote", staffConfig.maxNote);
6979
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(staffConfig.voiceIds) || import_ts_utils_lib11.Utils.Is.isArray(staffConfig.voiceIds) && staffConfig.voiceIds.every((voiceId) => import_ts_utils_lib11.Utils.Is.isNumber(voiceId)), "staffConfig.voiceIds", staffConfig.voiceIds);
6980
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(staffConfig.isGrand), "staffConfig.isGrand", staffConfig.isGrand);
7058
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(staffConfig.clef, Clef), "staffConfig.clef", staffConfig.clef);
7059
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(staffConfig.isOctaveDown), "staffConfig.isOctaveDown", staffConfig.isOctaveDown);
7060
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(staffConfig.minNote) || isNote(staffConfig.minNote), "staffConfig.minNote", staffConfig.minNote);
7061
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(staffConfig.maxNote) || isNote(staffConfig.maxNote), "staffConfig.maxNote", staffConfig.maxNote);
7062
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(staffConfig.voiceIds) || import_ts_utils_lib13.Utils.Is.isArray(staffConfig.voiceIds) && staffConfig.voiceIds.every((voiceId) => import_ts_utils_lib13.Utils.Is.isNumber(voiceId)), "staffConfig.voiceIds", staffConfig.voiceIds);
7063
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(staffConfig.isGrand), "staffConfig.isGrand", staffConfig.isGrand);
6981
7064
  }
6982
7065
  function assertTabConfig(tabConfig) {
6983
- assertArg(import_ts_utils_lib11.Utils.Is.isObject(tabConfig), "tabConfig", tabConfig);
7066
+ assertArg(import_ts_utils_lib13.Utils.Is.isObject(tabConfig), "tabConfig", tabConfig);
6984
7067
  assertArg(tabConfig.type === "tab", "tabConfig.type", tabConfig.type);
6985
7068
  if (typeof tabConfig.tuning === "string") {
6986
7069
  assertArg(import_theory13.TuningNameList.includes(tabConfig.tuning), "tabConfig.tuning", tabConfig.tuning);
6987
- } else if (import_ts_utils_lib11.Utils.Is.isArray(tabConfig.tuning)) {
6988
- assertArg(tabConfig.tuning.length === 6 && tabConfig.tuning.every((s) => isNote(s)), "tabConfig.tuning", tabConfig.tuning);
7070
+ } else if (import_ts_utils_lib13.Utils.Is.isArray(tabConfig.tuning)) {
7071
+ assertArg(tabConfig.tuning.length === getStringNumbers().length && tabConfig.tuning.every((s) => isNote(s)), "tabConfig.tuning", tabConfig.tuning);
6989
7072
  }
6990
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(tabConfig.voiceIds) || import_ts_utils_lib11.Utils.Is.isArray(tabConfig.voiceIds) && tabConfig.voiceIds.every((voiceId) => import_ts_utils_lib11.Utils.Is.isNumber(voiceId)), "tabConfig.voiceIds", tabConfig.voiceIds);
7073
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(tabConfig.voiceIds) || import_ts_utils_lib13.Utils.Is.isArray(tabConfig.voiceIds) && tabConfig.voiceIds.every((voiceId) => import_ts_utils_lib13.Utils.Is.isNumber(voiceId)), "tabConfig.voiceIds", tabConfig.voiceIds);
6991
7074
  }
6992
7075
  function assertNoteOptions(options) {
6993
- assertArg(import_ts_utils_lib11.Utils.Is.isObject(options), "noteOptions", options);
6994
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.dotted), "noteOptions.dotted", options.dotted);
6995
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValueOrUndefined(options.stem, Stem), "noteOptions.stem", options.stem);
6996
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(options.color), "noteOptions.color", options.color);
6997
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.arpeggio) || import_ts_utils_lib11.Utils.Is.isEnumValue(options.arpeggio, Arpeggio), "noteOptions.arpeggio", options.arpeggio);
6998
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.staccato), "noteOptions.staccato", options.staccato);
6999
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.diamond), "noteOptions.diamond", options.diamond);
7000
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.triplet), "noteOptions.triplet", options.triplet);
7001
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(options.string) || isStringNumber(options.string) || import_ts_utils_lib11.Utils.Is.isArray(options.string) && options.string.length > 0 && options.string.every((string) => isStringNumber(string)), "noteOptions.string", options.string);
7076
+ assertArg(import_ts_utils_lib13.Utils.Is.isObject(options), "noteOptions", options);
7077
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.dotted) || import_ts_utils_lib13.Utils.Is.isIntegerGte(options.dotted, 0), "noteOptions.dotted", options.dotted);
7078
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValueOrUndefined(options.stem, Stem), "noteOptions.stem", options.stem);
7079
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(options.color), "noteOptions.color", options.color);
7080
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.arpeggio) || import_ts_utils_lib13.Utils.Is.isEnumValue(options.arpeggio, Arpeggio), "noteOptions.arpeggio", options.arpeggio);
7081
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.staccato), "noteOptions.staccato", options.staccato);
7082
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.diamond), "noteOptions.diamond", options.diamond);
7083
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.triplet), "noteOptions.triplet", options.triplet);
7084
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(options.string) || isStringNumber(options.string) || import_ts_utils_lib13.Utils.Is.isNonEmptyArray(options.string) && options.string.every((string) => isStringNumber(string)), "noteOptions.string", options.string);
7085
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(options.tieSpan), 'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)', "");
7086
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(options.slurSpan), 'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)', "");
7002
7087
  }
7003
7088
  function assertRestOptions(options) {
7004
- assertArg(import_ts_utils_lib11.Utils.Is.isObject(options), "restOptions", options);
7005
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.dotted), "restOptions.dotted", options.dotted);
7006
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(options.staffPos) || import_ts_utils_lib11.Utils.Is.isInteger(options.staffPos) || options.staffPos instanceof import_theory13.Note, "restOptions.staffPos", options.staffPos);
7007
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(options.color), "restOptions.color", options.color);
7008
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.hide), "restOptions.hide", options.hide);
7009
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.triplet), "restOptions.triplet", options.triplet);
7089
+ assertArg(import_ts_utils_lib13.Utils.Is.isObject(options), "restOptions", options);
7090
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.dotted) || import_ts_utils_lib13.Utils.Is.isIntegerGte(options.dotted, 0), "restOptions.dotted", options.dotted);
7091
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(options.staffPos) || import_ts_utils_lib13.Utils.Is.isInteger(options.staffPos) || options.staffPos instanceof import_theory13.Note, "restOptions.staffPos", options.staffPos);
7092
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(options.color), "restOptions.color", options.color);
7093
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.hide), "restOptions.hide", options.hide);
7094
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.triplet), "restOptions.triplet", options.triplet);
7010
7095
  }
7011
7096
  function assertStaffTabOrGRoups(staffTabOrGroups) {
7012
7097
  assertArg(
7013
- import_ts_utils_lib11.Utils.Is.isStringOrUndefined(staffTabOrGroups) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroups, 0) || import_ts_utils_lib11.Utils.Is.isArray(staffTabOrGroups) && staffTabOrGroups.every(
7014
- (staffTabOrGroup) => import_ts_utils_lib11.Utils.Is.isString(staffTabOrGroup) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroup, 0)
7098
+ import_ts_utils_lib13.Utils.Is.isStringOrUndefined(staffTabOrGroups) || import_ts_utils_lib13.Utils.Is.isIntegerGte(staffTabOrGroups, 0) || import_ts_utils_lib13.Utils.Is.isNonEmptyArray(staffTabOrGroups) && staffTabOrGroups.every(
7099
+ (staffTabOrGroup) => import_ts_utils_lib13.Utils.Is.isString(staffTabOrGroup) || import_ts_utils_lib13.Utils.Is.isIntegerGte(staffTabOrGroup, 0)
7015
7100
  ),
7016
7101
  "staffTabOrGroup",
7017
7102
  staffTabOrGroups
7018
7103
  );
7019
7104
  }
7105
+ function isNoteLength(noteLen) {
7106
+ try {
7107
+ (0, import_theory13.validateNoteLength)(noteLen);
7108
+ return true;
7109
+ } catch (e) {
7110
+ return false;
7111
+ }
7112
+ }
7113
+ function isTupletRatio(tupletRatio) {
7114
+ try {
7115
+ (0, import_theory13.validateTupletRatio)(tupletRatio);
7116
+ return true;
7117
+ } catch (e) {
7118
+ return false;
7119
+ }
7120
+ }
7020
7121
  var DocumentBuilder = class {
7021
7122
  constructor() {
7022
7123
  __publicField(this, "doc");
7023
7124
  this.doc = new ObjDocument();
7024
7125
  }
7025
7126
  setScoreConfiguration(config) {
7026
- if (import_ts_utils_lib11.Utils.Is.isEnumValue(config, StaffPreset)) {
7027
- } else if (import_ts_utils_lib11.Utils.Is.isObject(config) && config.type === "staff") {
7127
+ if (import_ts_utils_lib13.Utils.Is.isEnumValue(config, StaffPreset)) {
7128
+ this.doc.setScoreConfiguration(config);
7129
+ } else if (import_ts_utils_lib13.Utils.Is.isObject(config) && config.type === "staff") {
7028
7130
  assertStaffConfig(config);
7029
- } else if (import_ts_utils_lib11.Utils.Is.isObject(config) && config.type === "tab") {
7131
+ this.doc.setScoreConfiguration(config);
7132
+ } else if (import_ts_utils_lib13.Utils.Is.isObject(config) && config.type === "tab") {
7030
7133
  assertTabConfig(config);
7031
- } else if (import_ts_utils_lib11.Utils.Is.isArray(config)) {
7032
- assertArg(config.length > 0, "config", config);
7134
+ this.doc.setScoreConfiguration(config);
7135
+ } else if (import_ts_utils_lib13.Utils.Is.isNonEmptyArray(config)) {
7033
7136
  config.forEach((c) => {
7034
- if (import_ts_utils_lib11.Utils.Is.isObject(c) && c.type === "staff") {
7137
+ if (import_ts_utils_lib13.Utils.Is.isObject(c) && c.type === "staff") {
7035
7138
  assertStaffConfig(c);
7036
- } else if (import_ts_utils_lib11.Utils.Is.isObject(c) && c.type === "tab") {
7139
+ } else if (import_ts_utils_lib13.Utils.Is.isObject(c) && c.type === "tab") {
7037
7140
  assertTabConfig(c);
7038
7141
  } else {
7039
7142
  assertArg(false, "config", config);
7040
7143
  }
7041
7144
  });
7145
+ this.doc.setScoreConfiguration(config);
7042
7146
  } else {
7043
7147
  assertArg(false, "config", config);
7044
7148
  }
7045
- this.doc.setScoreConfiguration(config);
7046
7149
  return this;
7047
7150
  }
7048
7151
  getMeasure() {
@@ -7053,14 +7156,14 @@ var DocumentBuilder = class {
7053
7156
  return this.doc.getMusicInterface();
7054
7157
  }
7055
7158
  setHeader(title, composer, arranger) {
7056
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(title), "title", title);
7057
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(composer), "composer", composer);
7058
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(arranger), "arranger", arranger);
7159
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(title), "title", title);
7160
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(composer), "composer", composer);
7161
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(arranger), "arranger", arranger);
7059
7162
  this.doc.setHeader(title, composer, arranger);
7060
7163
  return this;
7061
7164
  }
7062
7165
  setMeasuresPerRow(measuresPerRow) {
7063
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(measuresPerRow, 1) || measuresPerRow === Infinity, "measuresPerRow", measuresPerRow);
7166
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerGte(measuresPerRow, 1) || import_ts_utils_lib13.Utils.Is.isPosInfinity(measuresPerRow), "measuresPerRow", measuresPerRow);
7064
7167
  this.doc.setMeasuresPerRow(measuresPerRow);
7065
7168
  return this;
7066
7169
  }
@@ -7069,30 +7172,30 @@ var DocumentBuilder = class {
7069
7172
  return this;
7070
7173
  }
7071
7174
  setKeySignature(...args) {
7072
- assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature || import_ts_utils_lib11.Utils.Is.isString(args[0]) && import_ts_utils_lib11.Utils.Is.isEnumValue(args[1], import_theory13.ScaleType), "keySignature", args);
7175
+ assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature || import_ts_utils_lib13.Utils.Is.isNonEmptyString(args[0]) && (args.length === 1 || import_ts_utils_lib13.Utils.Is.isEnumValue(args[1], import_theory13.ScaleType)), "keySignature", args);
7073
7176
  this.getMeasure().setKeySignature(...args);
7074
7177
  return this;
7075
7178
  }
7076
7179
  setTimeSignature(timeSignature) {
7077
- assertArg(timeSignature instanceof import_theory13.TimeSignature || import_ts_utils_lib11.Utils.Is.isString(timeSignature), "timeSignature", timeSignature);
7180
+ assertArg(timeSignature instanceof import_theory13.TimeSignature || import_ts_utils_lib13.Utils.Is.isNonEmptyString(timeSignature), "timeSignature", timeSignature);
7078
7181
  this.getMeasure().setTimeSignature(timeSignature);
7079
7182
  return this;
7080
7183
  }
7081
7184
  setTempo(beatsPerMinute, beatLength, dotted) {
7082
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(beatsPerMinute, 1), "beatsPerMinute", beatsPerMinute);
7185
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerGte(beatsPerMinute, 1), "beatsPerMinute", beatsPerMinute);
7083
7186
  if (beatLength === void 0) {
7084
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(dotted), "dotted", dotted);
7187
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(dotted), "dotted", dotted);
7085
7188
  } else {
7086
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(beatLength, import_theory13.NoteLength), "beatLength", beatLength);
7087
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(dotted), "dotted", dotted);
7189
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(beatLength, import_theory13.NoteLength) || isNoteLength(beatLength), "beatLength", beatLength);
7190
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(dotted) || import_ts_utils_lib13.Utils.Is.isIntegerGte(dotted, 0), "dotted", dotted);
7088
7191
  }
7089
7192
  this.getMeasure().setTempo(beatsPerMinute, beatLength, dotted);
7090
7193
  return this;
7091
7194
  }
7092
7195
  addNote(voiceId, note, noteLength, options) {
7093
7196
  assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7094
- assertArg(note instanceof import_theory13.Note || import_ts_utils_lib11.Utils.Is.isString(note), "note", note);
7095
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength), "noteLength", noteLength);
7197
+ assertArg(note instanceof import_theory13.Note || import_ts_utils_lib13.Utils.Is.isNonEmptyString(note), "note", note);
7198
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7096
7199
  if (options !== void 0) {
7097
7200
  assertNoteOptions(options);
7098
7201
  }
@@ -7101,8 +7204,8 @@ var DocumentBuilder = class {
7101
7204
  }
7102
7205
  addChord(voiceId, notes, noteLength, options) {
7103
7206
  assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7104
- assertArg(import_ts_utils_lib11.Utils.Is.isArray(notes) && notes.length >= 1 && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib11.Utils.Is.isString(note)), "notes", notes);
7105
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength), "noteLength", noteLength);
7207
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib13.Utils.Is.isNonEmptyString(note)), "notes", notes);
7208
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7106
7209
  if (options !== void 0) {
7107
7210
  assertNoteOptions(options);
7108
7211
  }
@@ -7111,33 +7214,91 @@ var DocumentBuilder = class {
7111
7214
  }
7112
7215
  addRest(voiceId, restLength, options) {
7113
7216
  assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7114
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength), "restLength", restLength);
7217
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength) || isNoteLength(restLength), "restLength", restLength);
7115
7218
  if (options !== void 0) {
7116
7219
  assertRestOptions(options);
7117
7220
  }
7118
7221
  this.getMeasure().addRest(voiceId, restLength, options);
7119
7222
  return this;
7120
7223
  }
7224
+ /**
7225
+ * Usage:
7226
+ * <pre>
7227
+ * addTuplet(0, Theory.Tuplet.Triplet, notes => {
7228
+ * notes.addNote("G3", Theory.NoteLength.Eighth);
7229
+ * notes.addNote("B3", Theory.NoteLength.Eighth);
7230
+ * notes.addNote("D4", Theory.NoteLength.Eighth);
7231
+ * });
7232
+ * </pre>
7233
+ *
7234
+ * @param voiceId
7235
+ * @param tupletRatio - You can also use Theory.Tuplet presets (e.g. Theory.Tuplet.Triplet).
7236
+ * @param tupletBuilder
7237
+ * @returns
7238
+ */
7239
+ addTuplet(voiceId, tupletRatio, tupletBuilder) {
7240
+ assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7241
+ assertArg(import_ts_utils_lib13.Utils.Is.isFunction(tupletBuilder), "tupletBuilder", tupletBuilder);
7242
+ assertArg(isTupletRatio(tupletRatio) && import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(tupletRatio.showRatio), "tupletRatio", tupletRatio);
7243
+ let tupletSymbols = [];
7244
+ const helper = {
7245
+ addNote: (note, noteLength, options) => {
7246
+ assertArg(note instanceof import_theory13.Note || import_ts_utils_lib13.Utils.Is.isNonEmptyString(note), "note", note);
7247
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7248
+ if (options !== void 0) {
7249
+ delete options.triplet;
7250
+ assertNoteOptions(options);
7251
+ }
7252
+ let s = this.getMeasure().addNoteGroup(voiceId, [note], noteLength, options, tupletRatio);
7253
+ tupletSymbols.push(s);
7254
+ return helper;
7255
+ },
7256
+ addChord: (notes, noteLength, options) => {
7257
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib13.Utils.Is.isNonEmptyString(note)), "notes", notes);
7258
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7259
+ if (options !== void 0) {
7260
+ delete options.triplet;
7261
+ assertNoteOptions(options);
7262
+ }
7263
+ let s = this.getMeasure().addNoteGroup(voiceId, notes, noteLength, options, tupletRatio);
7264
+ tupletSymbols.push(s);
7265
+ return helper;
7266
+ },
7267
+ addRest: (restLength, options) => {
7268
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength) || isNoteLength(restLength), "restLength", restLength);
7269
+ if (options !== void 0) {
7270
+ delete options.triplet;
7271
+ assertRestOptions(options);
7272
+ }
7273
+ let s = this.getMeasure().addRest(voiceId, restLength, options, tupletRatio);
7274
+ tupletSymbols.push(s);
7275
+ return helper;
7276
+ }
7277
+ };
7278
+ tupletBuilder(helper);
7279
+ ObjBeamGroup.createTuplet(tupletSymbols, tupletRatio);
7280
+ return this;
7281
+ }
7121
7282
  addFermataInternal(staffTabOrGroups, fermata) {
7122
7283
  assertStaffTabOrGRoups(staffTabOrGroups);
7123
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(fermata, Fermata), "fermata", fermata);
7284
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(fermata, Fermata), "fermata", fermata);
7124
7285
  this.getMeasure().addFermata(staffTabOrGroups, fermata);
7125
7286
  return this;
7126
7287
  }
7127
- addFermata(fermata = 0 /* AtNote */) {
7288
+ addFermata(fermata = "atNote" /* AtNote */) {
7128
7289
  return this.addFermataInternal(void 0, fermata);
7129
7290
  }
7130
7291
  /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
7131
- addFermataTo(staffTabOrGroups, fermata = 0 /* AtNote */) {
7292
+ addFermataTo(staffTabOrGroups, fermata = "atNote" /* AtNote */) {
7132
7293
  return this.addFermataInternal(staffTabOrGroups, fermata);
7133
7294
  }
7134
7295
  addNavigationInternal(staffTabOrGroups, navigation, ...args) {
7135
7296
  assertStaffTabOrGRoups(staffTabOrGroups);
7136
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(navigation, Navigation), "navigation", navigation);
7137
- if (navigation === 9 /* EndRepeat */ && args.length > 0) {
7138
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(args[0], 1), "playCount", args[0]);
7139
- } else if (navigation === 10 /* Ending */ && args.length > 0) {
7140
- assertArg(args.every((passage) => import_ts_utils_lib11.Utils.Is.isIntegerGte(passage, 1)), "passages", args);
7297
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(navigation, Navigation), "navigation", navigation);
7298
+ if (navigation === "endRepeat" /* EndRepeat */ && args.length > 0) {
7299
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerGte(args[0], 1), "playCount", args[0]);
7300
+ } else if (navigation === "ending" /* Ending */ && args.length > 0) {
7301
+ assertArg(args.every((passage) => import_ts_utils_lib13.Utils.Is.isIntegerGte(passage, 1)), "passages", args);
7141
7302
  }
7142
7303
  this.getMeasure().addNavigation(staffTabOrGroups, navigation, ...args);
7143
7304
  return this;
@@ -7148,10 +7309,35 @@ var DocumentBuilder = class {
7148
7309
  addNavigationTo(staffTabOrGroups, navigation, ...args) {
7149
7310
  return this.addNavigationInternal(staffTabOrGroups, navigation, ...args);
7150
7311
  }
7312
+ addAnnotationInternal(staffTabOrGroups, annotation, text) {
7313
+ annotation != null ? annotation : annotation = getAnnotation(text);
7314
+ if (annotation === void 0) {
7315
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Annotation text "${text}" is not known annotation.`);
7316
+ }
7317
+ assertStaffTabOrGRoups(staffTabOrGroups);
7318
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
7319
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyString(text), "text", text);
7320
+ this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
7321
+ return this;
7322
+ }
7323
+ addAnnotation(...args) {
7324
+ if (args.length === 1) {
7325
+ return this.addAnnotationInternal(void 0, void 0, args[0]);
7326
+ } else {
7327
+ return this.addAnnotationInternal(void 0, args[0], args[1]);
7328
+ }
7329
+ }
7330
+ addAnnotationTo(staffTabOrGroups, ...args) {
7331
+ if (args.length === 1) {
7332
+ return this.addAnnotationInternal(staffTabOrGroups, void 0, args[0]);
7333
+ } else {
7334
+ return this.addAnnotationInternal(staffTabOrGroups, args[0], args[1]);
7335
+ }
7336
+ }
7151
7337
  addLabelInternal(staffTabOrGroups, label, text) {
7152
7338
  assertStaffTabOrGRoups(staffTabOrGroups);
7153
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(label, Label), "label", label);
7154
- assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
7339
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(label, Label), "label", label);
7340
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyString(text), "text", text);
7155
7341
  this.getMeasure().addLabel(staffTabOrGroups, label, text);
7156
7342
  return this;
7157
7343
  }
@@ -7162,45 +7348,70 @@ var DocumentBuilder = class {
7162
7348
  addLabelTo(staffTabOrGroups, label, text) {
7163
7349
  return this.addLabelInternal(staffTabOrGroups, label, text);
7164
7350
  }
7165
- addAnnotationInternal(staffTabOrGroups, annotation, text) {
7166
- assertStaffTabOrGRoups(staffTabOrGroups);
7167
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
7168
- assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
7169
- this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
7170
- return this;
7171
- }
7172
- addAnnotation(annotation, text) {
7173
- return this.addAnnotationInternal(void 0, annotation, text);
7174
- }
7175
- /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
7176
- addAnnotationTo(staffTabOrGroups, annotation, text) {
7177
- return this.addAnnotationInternal(staffTabOrGroups, annotation, text);
7178
- }
7179
7351
  addConnective(connective, ...args) {
7180
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(connective, Connective), "connective", connective);
7181
- if (connective === 0 /* Tie */) {
7182
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(args[0]) || import_ts_utils_lib11.Utils.Is.isInteger(args[0]) || import_ts_utils_lib11.Utils.Is.isEnumValue(args[0], TieType), "tieSpan", args[0]);
7183
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
7352
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(connective, Connective), "connective", connective);
7353
+ if (connective === "tie" /* Tie */) {
7354
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerOrUndefined(args[0]) || import_ts_utils_lib13.Utils.Is.isEnumValue(args[0], TieType), "tieSpan", args[0]);
7355
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
7184
7356
  let tieSpan = args[0];
7185
7357
  let noteAnchor = args[1];
7186
7358
  this.getMeasure().addConnective(connective, tieSpan, noteAnchor);
7187
- } else if (connective === 1 /* Slur */) {
7188
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(args[0]) || import_ts_utils_lib11.Utils.Is.isInteger(args[0]), "slurSpan", args[0]);
7189
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
7359
+ } else if (connective === "slur" /* Slur */) {
7360
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerOrUndefined(args[0]), "slurSpan", args[0]);
7361
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
7190
7362
  let slurSpan = args[0];
7191
7363
  let noteAnchor = args[1];
7192
7364
  this.getMeasure().addConnective(connective, slurSpan, noteAnchor);
7193
- } else if (connective === 2 /* Slide */) {
7194
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValueOrUndefined(args[0], NoteAnchor), "noteAnchor", args[0]);
7365
+ } else if (connective === "slide" /* Slide */) {
7366
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValueOrUndefined(args[0], NoteAnchor), "noteAnchor", args[0]);
7195
7367
  let noteAnchor = args[0];
7196
7368
  this.getMeasure().addConnective(connective, noteAnchor);
7197
7369
  }
7198
7370
  return this;
7199
7371
  }
7200
- addExtension(extensionLength, extensionVisible) {
7201
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(extensionLength, 0) || extensionLength === Infinity || import_ts_utils_lib11.Utils.Is.isEnumValue(extensionLength, import_theory13.NoteLength), "extendionLength", extensionLength);
7202
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(extensionVisible), "extensionVisible", extensionVisible);
7203
- this.getMeasure().addExtension(extensionLength, extensionVisible != null ? extensionVisible : true);
7372
+ /**
7373
+ * Extension length example:
7374
+ * <pre>
7375
+ * addExtension(ext => ext.notes("1n", 2)) // length is 2 whole notes
7376
+ * addExtension(ext => ext.measures(3).hide()) // length is 3 measures, hidden
7377
+ * addExtension(ext => ext.measures(1).notes("8n")) // length is 1 measure + 1 eigth note
7378
+ * addExtension(ext => ext.infinity()) // length is as long as possible
7379
+ * </pre>
7380
+ * @param extensionLength
7381
+ * @param extensionVisible
7382
+ * @returns
7383
+ */
7384
+ addExtension(extensionBuilder) {
7385
+ assertArg(import_ts_utils_lib13.Utils.Is.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.", extensionBuilder);
7386
+ let ticks = 0;
7387
+ let visible = true;
7388
+ const helper = {
7389
+ notes: (noteLength, noteCount) => {
7390
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7391
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(noteCount) || import_ts_utils_lib13.Utils.Is.isNumber(noteCount) && noteCount >= 0, "noteCount", noteCount);
7392
+ ticks += import_theory13.RhythmProps.get(noteLength).ticks * (noteCount != null ? noteCount : 1);
7393
+ return helper;
7394
+ },
7395
+ measures: (measureCount) => {
7396
+ assertArg(import_ts_utils_lib13.Utils.Is.isNumber(measureCount) && measureCount >= 1, "measureCount", measureCount);
7397
+ ticks += this.getMeasure().getMeasureTicks() * measureCount;
7398
+ return helper;
7399
+ },
7400
+ infinity: () => {
7401
+ ticks = Infinity;
7402
+ return helper;
7403
+ },
7404
+ hide: () => {
7405
+ visible = false;
7406
+ return helper;
7407
+ }
7408
+ };
7409
+ if (extensionBuilder) {
7410
+ extensionBuilder(helper);
7411
+ } else {
7412
+ ticks = Infinity;
7413
+ }
7414
+ this.getMeasure().addExtension(ticks, visible);
7204
7415
  return this;
7205
7416
  }
7206
7417
  /**
@@ -7210,14 +7421,14 @@ var DocumentBuilder = class {
7210
7421
  * @param verticalPosition - Vertical position, are elements added above, below or both.
7211
7422
  * @returns
7212
7423
  */
7213
- addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = 3 /* Auto */) {
7214
- assertArg(import_ts_utils_lib11.Utils.Is.isString(groupName) && groupName.length > 0, "groupName", groupName);
7424
+ addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = "auto" /* Auto */) {
7425
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyString(groupName), "groupName", groupName);
7215
7426
  assertArg(
7216
- import_ts_utils_lib11.Utils.Is.isString(staffsTabsAndGroups) && staffsTabsAndGroups.length > 0 || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffsTabsAndGroups, 0) || import_ts_utils_lib11.Utils.Is.isArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => import_ts_utils_lib11.Utils.Is.isString(line) && line.length > 0 || import_ts_utils_lib11.Utils.Is.isIntegerGte(line, 0)),
7427
+ import_ts_utils_lib13.Utils.Is.isNonEmptyString(staffsTabsAndGroups) || import_ts_utils_lib13.Utils.Is.isIntegerGte(staffsTabsAndGroups, 0) || import_ts_utils_lib13.Utils.Is.isNonEmptyArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => import_ts_utils_lib13.Utils.Is.isNonEmptyString(line) || import_ts_utils_lib13.Utils.Is.isIntegerGte(line, 0)),
7217
7428
  "staffsTabsAndGroups",
7218
7429
  staffsTabsAndGroups
7219
7430
  );
7220
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
7431
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
7221
7432
  this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
7222
7433
  return this;
7223
7434
  }
@@ -7235,13 +7446,13 @@ var DocumentBuilder = class {
7235
7446
  return this;
7236
7447
  }
7237
7448
  completeRests(voiceId) {
7238
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(voiceId) || isVoiceId(voiceId), "voiceId", voiceId);
7449
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(voiceId) || isVoiceId(voiceId) || import_ts_utils_lib13.Utils.Is.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)), "voiceId", voiceId);
7239
7450
  this.getMeasure().completeRests(voiceId);
7240
7451
  return this;
7241
7452
  }
7242
7453
  addScaleArpeggio(scale, bottomNote, numOctaves) {
7243
- assertArg(import_ts_utils_lib11.Utils.Is.isString(bottomNote), "bottomNote", bottomNote);
7244
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(numOctaves, 1), "numOctaves", numOctaves);
7454
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyString(bottomNote), "bottomNote", bottomNote);
7455
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerGte(numOctaves, 1), "numOctaves", numOctaves);
7245
7456
  let ts = this.getMeasure().getTimeSignature();
7246
7457
  let notes = scale.getScaleNotes(bottomNote, numOctaves);
7247
7458
  for (let i = 0; i < notes.length; i++) {
@@ -7250,7 +7461,7 @@ var DocumentBuilder = class {
7250
7461
  }
7251
7462
  let note = notes[i];
7252
7463
  this.addNote(0, note, ts.beatLength);
7253
- this.addLabel(0 /* Note */, note.formatOmitOctave(import_theory13.SymbolSet.Unicode));
7464
+ this.addLabel("note" /* Note */, note.formatOmitOctave(import_theory13.SymbolSet.Unicode));
7254
7465
  }
7255
7466
  return this;
7256
7467
  }
@@ -7290,7 +7501,7 @@ var ScoreObjectEvent = class extends ScoreEvent {
7290
7501
 
7291
7502
  // src/score/pub/interface.ts
7292
7503
  var Audio2 = __toESM(require("@tspro/web-music-score/audio"));
7293
- var import_ts_utils_lib12 = require("@tspro/ts-utils-lib");
7504
+ var import_ts_utils_lib14 = require("@tspro/ts-utils-lib");
7294
7505
  var import_core19 = require("@tspro/web-music-score/core");
7295
7506
  function assertArg2(condition, argName, argValue) {
7296
7507
  if (!condition) {
@@ -7305,7 +7516,14 @@ function require_t(t, message) {
7305
7516
  }
7306
7517
  }
7307
7518
  function isVoiceId2(value) {
7308
- return import_ts_utils_lib12.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
7519
+ return import_ts_utils_lib14.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
7520
+ }
7521
+ function getNotationLine(line) {
7522
+ if (line instanceof ObjStaff || line instanceof ObjTab) {
7523
+ return line.getMusicInterface();
7524
+ } else {
7525
+ throw new import_core19.MusicError(import_core19.MusicErrorType.Score, `Notation line not staff nor tab.`);
7526
+ }
7309
7527
  }
7310
7528
  var MusicInterface6 = class {
7311
7529
  constructor(name) {
@@ -7355,6 +7573,12 @@ var _MArpeggio = class _MArpeggio extends MusicInterface6 {
7355
7573
  getMusicObject() {
7356
7574
  return this.obj;
7357
7575
  }
7576
+ getRhythmColumn() {
7577
+ return this.obj.col.getMusicInterface();
7578
+ }
7579
+ getNotationLine() {
7580
+ return getNotationLine(this.obj.line);
7581
+ }
7358
7582
  };
7359
7583
  __publicField(_MArpeggio, "Name", "Arpeggio");
7360
7584
  var MArpeggio = _MArpeggio;
@@ -7381,6 +7605,9 @@ var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
7381
7605
  getMusicObject() {
7382
7606
  return this.obj;
7383
7607
  }
7608
+ getStaff() {
7609
+ return this.obj.staff.getMusicInterface();
7610
+ }
7384
7611
  };
7385
7612
  __publicField(_MStaffBeamGroup, "Name", "StaffBeamGroup");
7386
7613
  var MStaffBeamGroup = _MStaffBeamGroup;
@@ -7404,8 +7631,14 @@ var _MDocument = class _MDocument extends MusicInterface6 {
7404
7631
  getArranger() {
7405
7632
  return this.obj.getArranger();
7406
7633
  }
7634
+ getRows() {
7635
+ return this.obj.getRows().map((r) => r.getMusicInterface());
7636
+ }
7637
+ getMeasures() {
7638
+ return this.obj.getMeasures().map((m) => m.getMusicInterface());
7639
+ }
7407
7640
  play(fn) {
7408
- assertArg2(import_ts_utils_lib12.Utils.Is.isFunctionOrUndefined(fn), "playStateChangeListener", fn);
7641
+ assertArg2(import_ts_utils_lib14.Utils.Is.isFunctionOrUndefined(fn), "playStateChangeListener", fn);
7409
7642
  return new MPlayer(this, fn).play();
7410
7643
  }
7411
7644
  };
@@ -7425,7 +7658,7 @@ var _MEnding = class _MEnding extends MusicInterface6 {
7425
7658
  return this.obj.passages;
7426
7659
  }
7427
7660
  hasPassage(passage) {
7428
- assertArg2(import_ts_utils_lib12.Utils.Is.isIntegerGte(passage, 1), "passage", passage);
7661
+ assertArg2(import_ts_utils_lib14.Utils.Is.isIntegerGte(passage, 1), "passage", passage);
7429
7662
  return this.obj.hasPassage(passage);
7430
7663
  }
7431
7664
  };
@@ -7495,6 +7728,9 @@ var _MMeasure = class _MMeasure extends MusicInterface6 {
7495
7728
  getRhythmColumns() {
7496
7729
  return this.obj.getColumns().map((col) => col.getMusicInterface());
7497
7730
  }
7731
+ getRow() {
7732
+ return this.obj.row.getMusicInterface();
7733
+ }
7498
7734
  };
7499
7735
  __publicField(_MMeasure, "Name", "Measure");
7500
7736
  var MMeasure = _MMeasure;
@@ -7534,6 +7770,17 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
7534
7770
  getMusicObject() {
7535
7771
  return this.obj;
7536
7772
  }
7773
+ getBarLine() {
7774
+ let barLine = this.obj.barLine;
7775
+ if (barLine instanceof ObjBarLineLeft || barLine instanceof ObjBarLineRight) {
7776
+ return barLine.getMusicInterface();
7777
+ } else {
7778
+ throw new import_core19.MusicError(import_core19.MusicErrorType.Score, `Bar line not let nor right.`);
7779
+ }
7780
+ }
7781
+ getNotationLine() {
7782
+ return getNotationLine(this.obj.line);
7783
+ }
7537
7784
  };
7538
7785
  __publicField(_MStaffTabBarLine, "Name", "StaffTabBarLine");
7539
7786
  var MStaffTabBarLine = _MStaffTabBarLine;
@@ -7553,6 +7800,12 @@ var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
7553
7800
  getRhythmProps() {
7554
7801
  return this.obj.rhythmProps;
7555
7802
  }
7803
+ getRhythmColumn() {
7804
+ return this.obj.col.getMusicInterface();
7805
+ }
7806
+ getMeasure() {
7807
+ return this.obj.measure.getMusicInterface();
7808
+ }
7556
7809
  };
7557
7810
  __publicField(_MNoteGroup, "Name", "NoteGroup");
7558
7811
  var MNoteGroup = _MNoteGroup;
@@ -7569,6 +7822,15 @@ var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
7569
7822
  getNoteGroup() {
7570
7823
  return this.obj.noteGroup.getMusicInterface();
7571
7824
  }
7825
+ getRhythmColumn() {
7826
+ return this.getNoteGroup().getRhythmColumn();
7827
+ }
7828
+ getMeasure() {
7829
+ return this.getNoteGroup().getMeasure();
7830
+ }
7831
+ getStaff() {
7832
+ return this.obj.staff.getMusicInterface();
7833
+ }
7572
7834
  };
7573
7835
  __publicField(_MStaffNoteGroup, "Name", "StaffNoteGroup");
7574
7836
  var MStaffNoteGroup = _MStaffNoteGroup;
@@ -7585,6 +7847,15 @@ var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
7585
7847
  getNoteGroup() {
7586
7848
  return this.obj.noteGroup.getMusicInterface();
7587
7849
  }
7850
+ getRhythmColumn() {
7851
+ return this.getNoteGroup().getRhythmColumn();
7852
+ }
7853
+ getMeasure() {
7854
+ return this.getNoteGroup().getMeasure();
7855
+ }
7856
+ getTab() {
7857
+ return this.obj.tab.getMusicInterface();
7858
+ }
7588
7859
  };
7589
7860
  __publicField(_MTabNoteGroup, "Name", "TabNoteGroup");
7590
7861
  var MTabNoteGroup = _MTabNoteGroup;
@@ -7601,6 +7872,12 @@ var _MRest = class _MRest extends MusicInterface6 {
7601
7872
  getRhythmProps() {
7602
7873
  return this.obj.rhythmProps;
7603
7874
  }
7875
+ getRhythmColumn() {
7876
+ return this.obj.col.getMusicInterface();
7877
+ }
7878
+ getMeasure() {
7879
+ return this.obj.measure.getMusicInterface();
7880
+ }
7604
7881
  };
7605
7882
  __publicField(_MRest, "Name", "Rest");
7606
7883
  var MRest = _MRest;
@@ -7617,6 +7894,15 @@ var _MStaffRest = class _MStaffRest extends MusicInterface6 {
7617
7894
  getRest() {
7618
7895
  return this.obj.rest.getMusicInterface();
7619
7896
  }
7897
+ getRhythmColumn() {
7898
+ return this.getRest().getRhythmColumn();
7899
+ }
7900
+ getMeasure() {
7901
+ return this.getRest().getMeasure();
7902
+ }
7903
+ getStaff() {
7904
+ return this.obj.staff.getMusicInterface();
7905
+ }
7620
7906
  };
7621
7907
  __publicField(_MStaffRest, "Name", "StaffRest");
7622
7908
  var MStaffRest = _MStaffRest;
@@ -7635,6 +7921,13 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
7635
7921
  assertArg2(isVoiceId2(voiceId), "voiceId", voiceId);
7636
7922
  return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
7637
7923
  }
7924
+ getMeasure() {
7925
+ return this.obj.measure.getMusicInterface();
7926
+ }
7927
+ getVoiceSymbol(voiceId) {
7928
+ let s = this.obj.getVoiceSymbol(voiceId);
7929
+ return s instanceof ObjNoteGroup || s instanceof ObjRest ? s.getMusicInterface() : void 0;
7930
+ }
7638
7931
  };
7639
7932
  __publicField(_MRhythmColumn, "Name", "RhythmColumn");
7640
7933
  var MRhythmColumn = _MRhythmColumn;
@@ -7648,9 +7941,15 @@ var _MScoreRow = class _MScoreRow extends MusicInterface6 {
7648
7941
  getMusicObject() {
7649
7942
  return this.obj;
7650
7943
  }
7944
+ getDocument() {
7945
+ return this.obj.doc.getMusicInterface();
7946
+ }
7651
7947
  getMeasures() {
7652
7948
  return this.obj.getMeasures().map((m) => m.getMusicInterface());
7653
7949
  }
7950
+ getNotationLines() {
7951
+ return this.obj.getNotationLines().map((line) => getNotationLine(line));
7952
+ }
7654
7953
  };
7655
7954
  __publicField(_MScoreRow, "Name", "ScoreRow");
7656
7955
  var MScoreRow = _MScoreRow;
@@ -7664,6 +7963,15 @@ var _MStaff = class _MStaff extends MusicInterface6 {
7664
7963
  getMusicObject() {
7665
7964
  return this.obj;
7666
7965
  }
7966
+ getId() {
7967
+ return this.obj.id;
7968
+ }
7969
+ getName() {
7970
+ return this.obj.name.length > 0 ? this.obj.name : void 0;
7971
+ }
7972
+ getRow() {
7973
+ return this.obj.row.getMusicInterface();
7974
+ }
7667
7975
  };
7668
7976
  __publicField(_MStaff, "Name", "Staff");
7669
7977
  var MStaff = _MStaff;
@@ -7677,6 +7985,15 @@ var _MTab = class _MTab extends MusicInterface6 {
7677
7985
  getMusicObject() {
7678
7986
  return this.obj;
7679
7987
  }
7988
+ getId() {
7989
+ return this.obj.id;
7990
+ }
7991
+ getName() {
7992
+ return this.obj.name.length > 0 ? this.obj.name : void 0;
7993
+ }
7994
+ getRow() {
7995
+ return this.obj.row.getMusicInterface();
7996
+ }
7680
7997
  };
7681
7998
  __publicField(_MTab, "Name", "Tab");
7682
7999
  var MTab = _MTab;
@@ -7690,6 +8007,9 @@ var _MSignature = class _MSignature extends MusicInterface6 {
7690
8007
  getMusicObject() {
7691
8008
  return this.obj;
7692
8009
  }
8010
+ getStaff() {
8011
+ return this.obj.staff.getMusicInterface();
8012
+ }
7693
8013
  };
7694
8014
  __publicField(_MSignature, "Name", "Signature");
7695
8015
  var MSignature = _MSignature;
@@ -7703,6 +8023,9 @@ var _MSpecialText = class _MSpecialText extends MusicInterface6 {
7703
8023
  getMusicObject() {
7704
8024
  return this.obj;
7705
8025
  }
8026
+ getText() {
8027
+ return this.obj.getText();
8028
+ }
7706
8029
  };
7707
8030
  __publicField(_MSpecialText, "Name", "SpecialText");
7708
8031
  var MSpecialText = _MSpecialText;
@@ -7739,7 +8062,7 @@ var _MPlayer = class _MPlayer {
7739
8062
  constructor(doc, fn) {
7740
8063
  __publicField(this, "player");
7741
8064
  assertArg2(doc instanceof MDocument2, "doc", doc);
7742
- assertArg2(import_ts_utils_lib12.Utils.Is.isFunctionOrUndefined(fn), "playStateChangeListener", fn);
8065
+ assertArg2(import_ts_utils_lib14.Utils.Is.isFunctionOrUndefined(fn), "playStateChangeListener", fn);
7743
8066
  this.player = new Player();
7744
8067
  this.player.setDocument(doc.getMusicObject());
7745
8068
  this.player.setCursorPositionChangeListener((cursorRect) => doc.getMusicObject().updateCursorRect(cursorRect));
@@ -7774,17 +8097,17 @@ var MRenderer2 = class {
7774
8097
  this.renderer = new Renderer(this);
7775
8098
  }
7776
8099
  setDocument(doc) {
7777
- assertArg2(import_ts_utils_lib12.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
8100
+ assertArg2(import_ts_utils_lib14.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
7778
8101
  this.renderer.setDocument(doc);
7779
8102
  return this;
7780
8103
  }
7781
8104
  setCanvas(canvas) {
7782
- canvas = require_t(import_ts_utils_lib12.Utils.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set renderer canvas because invalid canvas id: " + canvas : "Cannot set renderer canvas because given canvas is undefined.");
8105
+ canvas = require_t(import_ts_utils_lib14.Utils.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set renderer canvas because invalid canvas id: " + canvas : "Cannot set renderer canvas because given canvas is undefined.");
7783
8106
  this.renderer.setCanvas(canvas);
7784
8107
  return this;
7785
8108
  }
7786
8109
  setScoreEventListener(fn) {
7787
- assertArg2(import_ts_utils_lib12.Utils.Is.isFunctionOrUndefined(fn), "scoreEventListener", fn);
8110
+ assertArg2(import_ts_utils_lib14.Utils.Is.isFunctionOrUndefined(fn), "scoreEventListener", fn);
7788
8111
  this.renderer.setScoreEventListener(fn);
7789
8112
  }
7790
8113
  hilightObject(obj) {
@@ -7839,7 +8162,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
7839
8162
  this.updateButtons();
7840
8163
  }
7841
8164
  setDocument(doc) {
7842
- assertArg2(import_ts_utils_lib12.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
8165
+ assertArg2(import_ts_utils_lib14.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
7843
8166
  this.onStop();
7844
8167
  if (doc) {
7845
8168
  this.player = new MPlayer(doc, (playState) => {
@@ -7874,9 +8197,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
7874
8197
  }
7875
8198
  }
7876
8199
  setPlayButton(btn, btnLabel) {
7877
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
8200
+ assertArg2(import_ts_utils_lib14.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
7878
8201
  _MPlaybackButtons.removeOnClickListeners(this.playButton, this.onPlay);
7879
- this.playButton = require_t(import_ts_utils_lib12.Utils.Dom.getButton(btn), "Play button required!");
8202
+ this.playButton = require_t(import_ts_utils_lib14.Utils.Dom.getButton(btn), "Play button required!");
7880
8203
  this.playLabel = btnLabel != null ? btnLabel : "Play";
7881
8204
  _MPlaybackButtons.removeOnClickListeners(this.playButton, "all");
7882
8205
  _MPlaybackButtons.addOnClickListener(this.playButton, this.onPlay);
@@ -7884,9 +8207,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
7884
8207
  return this;
7885
8208
  }
7886
8209
  setStopButton(btn, btnLabel) {
7887
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
8210
+ assertArg2(import_ts_utils_lib14.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
7888
8211
  _MPlaybackButtons.removeOnClickListeners(this.stopButton, this.onStop);
7889
- this.stopButton = require_t(import_ts_utils_lib12.Utils.Dom.getButton(btn), "Stop button required!");
8212
+ this.stopButton = require_t(import_ts_utils_lib14.Utils.Dom.getButton(btn), "Stop button required!");
7890
8213
  this.stopLabel = btnLabel != null ? btnLabel : "Stop";
7891
8214
  _MPlaybackButtons.removeOnClickListeners(this.stopButton, "all");
7892
8215
  _MPlaybackButtons.addOnClickListener(this.stopButton, this.onStop);
@@ -7894,10 +8217,10 @@ var _MPlaybackButtons = class _MPlaybackButtons {
7894
8217
  return this;
7895
8218
  }
7896
8219
  setPlayStopButton(btn, playLabel, stopLabel) {
7897
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(playLabel), "playLabel", playLabel);
7898
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
8220
+ assertArg2(import_ts_utils_lib14.Utils.Is.isStringOrUndefined(playLabel), "playLabel", playLabel);
8221
+ assertArg2(import_ts_utils_lib14.Utils.Is.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
7899
8222
  _MPlaybackButtons.removeOnClickListeners(this.playStopButton, this.onPlayStop);
7900
- this.playStopButton = require_t(import_ts_utils_lib12.Utils.Dom.getButton(btn), "Play/stop button required!");
8223
+ this.playStopButton = require_t(import_ts_utils_lib14.Utils.Dom.getButton(btn), "Play/stop button required!");
7901
8224
  this.playLabel = playLabel != null ? playLabel : "Play";
7902
8225
  this.stopLabel = stopLabel != null ? stopLabel : "Stop";
7903
8226
  _MPlaybackButtons.removeOnClickListeners(this.playStopButton, "all");
@@ -7906,9 +8229,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
7906
8229
  return this;
7907
8230
  }
7908
8231
  setPauseButton(btn, btnLabel) {
7909
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
8232
+ assertArg2(import_ts_utils_lib14.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
7910
8233
  _MPlaybackButtons.removeOnClickListeners(this.pauseButton, this.onPause);
7911
- this.pauseButton = require_t(import_ts_utils_lib12.Utils.Dom.getButton(btn), "Pause button required!");
8234
+ this.pauseButton = require_t(import_ts_utils_lib14.Utils.Dom.getButton(btn), "Pause button required!");
7912
8235
  this.pauseLabel = btnLabel != null ? btnLabel : "Pause";
7913
8236
  _MPlaybackButtons.removeOnClickListeners(this.pauseButton, "all");
7914
8237
  _MPlaybackButtons.addOnClickListener(this.pauseButton, this.onPause);
@@ -7930,7 +8253,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
7930
8253
  }
7931
8254
  }
7932
8255
  static addOnClickListener(btn, onClick) {
7933
- assertArg2(import_ts_utils_lib12.Utils.Is.isFunction(onClick), "onClick", onClick);
8256
+ assertArg2(import_ts_utils_lib14.Utils.Is.isFunction(onClick), "onClick", onClick);
7934
8257
  btn.addEventListener("click", onClick);
7935
8258
  let clickListeners = this.savedOnClickListeners.get(btn) || [];
7936
8259
  this.savedOnClickListeners.set(btn, [...clickListeners, onClick]);