@tspro/web-music-score 5.3.0 → 5.4.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 (45) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +6 -4
  3. package/dist/audio/index.d.mts +1 -1
  4. package/dist/audio/index.d.ts +1 -1
  5. package/dist/audio/index.js +3 -3
  6. package/dist/audio/index.mjs +6 -6
  7. package/dist/audio-cg/index.js +1 -1
  8. package/dist/audio-cg/index.mjs +3 -3
  9. package/dist/audio-synth/index.js +1 -1
  10. package/dist/audio-synth/index.mjs +3 -3
  11. package/dist/{chunk-C6UQDKWU.mjs → chunk-AUT4C6TY.mjs} +2 -2
  12. package/dist/{chunk-ZBA5XLYR.mjs → chunk-MHDBTCVG.mjs} +21 -21
  13. package/dist/{chunk-PMDIUO22.mjs → chunk-QGMOI7AP.mjs} +2 -2
  14. package/dist/chunk-ZWUBO5EW.mjs +37 -0
  15. package/dist/core/index.js +2 -2
  16. package/dist/core/index.mjs +6 -31
  17. package/dist/{guitar-BsSayRsH.d.ts → guitar-CarHGDAt.d.ts} +1 -1
  18. package/dist/{guitar-DdexKdN6.d.mts → guitar-DXlB-9vK.d.mts} +1 -1
  19. package/dist/iife/audio-cg.global.js +1 -1
  20. package/dist/iife/index.global.js +18 -11
  21. package/dist/{music-objects-Ih9vCl4p.d.ts → music-objects-3Esbz7ij.d.ts} +48 -243
  22. package/dist/{music-objects-BGiRQIXW.d.mts → music-objects-ONIuVUgs.d.mts} +48 -243
  23. package/dist/{note-CgCIBwvR.d.ts → note-CJuq5aBy.d.ts} +13 -1
  24. package/dist/{note-eA2xPPiG.d.mts → note-RVXvpfyV.d.mts} +13 -1
  25. package/dist/pieces/index.d.mts +3 -3
  26. package/dist/pieces/index.d.ts +3 -3
  27. package/dist/pieces/index.js +1 -1
  28. package/dist/pieces/index.mjs +2 -2
  29. package/dist/react-ui/index.d.mts +9 -9
  30. package/dist/react-ui/index.d.ts +9 -9
  31. package/dist/react-ui/index.js +12 -14
  32. package/dist/react-ui/index.mjs +14 -16
  33. package/dist/{scale-CBW4eTz7.d.ts → scale-C8gHC448.d.mts} +3 -3
  34. package/dist/{scale-DQP3b9Zx.d.mts → scale-DulPFco_.d.ts} +3 -3
  35. package/dist/score/index.d.mts +232 -6
  36. package/dist/score/index.d.ts +232 -6
  37. package/dist/score/index.js +981 -883
  38. package/dist/score/index.mjs +837 -769
  39. package/dist/{tempo-dkctPkCS.d.mts → tempo-BlCGZuYg.d.mts} +14 -2
  40. package/dist/{tempo-DMt3iwz9.d.ts → tempo-BnUjm25M.d.ts} +14 -2
  41. package/dist/theory/index.d.mts +6 -6
  42. package/dist/theory/index.d.ts +6 -6
  43. package/dist/theory/index.js +88 -86
  44. package/dist/theory/index.mjs +85 -81
  45. package/package.json +5 -4
@@ -1,43 +1,45 @@
1
- /* WebMusicScore v5.3.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.4.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
+ import {
3
+ MusicError
4
+ } from "../chunk-ZWUBO5EW.mjs";
2
5
  import {
3
6
  NoteLengthProps,
4
7
  RhythmProps,
5
8
  validateNoteLength
6
- } from "../chunk-ZBA5XLYR.mjs";
9
+ } from "../chunk-MHDBTCVG.mjs";
7
10
  import {
8
11
  __publicField
9
- } from "../chunk-C6UQDKWU.mjs";
12
+ } from "../chunk-AUT4C6TY.mjs";
10
13
 
11
14
  // src/score/pub/div-rect.ts
12
15
  import { Utils } from "@tspro/ts-utils-lib";
13
- import { MusicError, MusicErrorType } from "@tspro/web-music-score/core";
14
16
  var DivRect = class _DivRect {
15
17
  constructor(...args) {
16
18
  __publicField(this, "left");
17
- __publicField(this, "centerX");
19
+ __publicField(this, "anchorX");
18
20
  __publicField(this, "right");
19
21
  __publicField(this, "top");
20
- __publicField(this, "centerY");
22
+ __publicField(this, "anchorY");
21
23
  __publicField(this, "bottom");
22
24
  if (args.length === 6) {
23
25
  this.left = args[0];
24
- this.centerX = args[1];
26
+ this.anchorX = args[1];
25
27
  this.right = args[2];
26
28
  this.top = args[3];
27
- this.centerY = args[4];
29
+ this.anchorY = args[4];
28
30
  this.bottom = args[5];
29
31
  } else if (args.length === 4) {
30
32
  this.left = args[0];
31
33
  this.right = args[1];
32
- this.centerX = (this.left + this.right) / 2;
34
+ this.anchorX = (this.left + this.right) / 2;
33
35
  this.top = args[2];
34
36
  this.bottom = args[3];
35
- this.centerY = (this.top + this.bottom) / 2;
37
+ this.anchorY = (this.top + this.bottom) / 2;
36
38
  } else if (args.length === 0) {
37
- this.left = this.centerX = this.right = 0;
38
- this.top = this.centerY = this.bottom = 0;
39
+ this.left = this.anchorX = this.right = 0;
40
+ this.top = this.anchorY = this.bottom = 0;
39
41
  } else {
40
- throw new MusicError(MusicErrorType.InvalidArg, `Invalid DivRect args: ${args}`);
42
+ throw new TypeError(`Invalid DivRect args: ${args}`);
41
43
  }
42
44
  }
43
45
  /**
@@ -45,7 +47,7 @@ var DivRect = class _DivRect {
45
47
  *
46
48
  * @param left - Left coordinate.
47
49
  * @param top - Top coordinate.
48
- * @param width - With.
50
+ * @param width - Width.
49
51
  * @param height - Height.
50
52
  * @returns - DivRect.
51
53
  */
@@ -53,7 +55,7 @@ var DivRect = class _DivRect {
53
55
  return new _DivRect(left, left + width, top, top + height);
54
56
  }
55
57
  /**
56
- * Create rect from centerX, centerY, width, height arguments.
58
+ * Create rect from anchorX, anchorY, width, height arguments.
57
59
  *
58
60
  * @param centerX - Center x-coordinate.
59
61
  * @param centerY - Center y-coordinate.
@@ -62,7 +64,14 @@ var DivRect = class _DivRect {
62
64
  * @returns - DivRect.
63
65
  */
64
66
  static createCentered(centerX, centerY, width, height) {
65
- return new _DivRect(centerX - width / 2, centerX + width / 2, centerY - height / 2, centerY + height / 2);
67
+ return new _DivRect(
68
+ centerX - width / 2,
69
+ centerX,
70
+ centerX + width / 2,
71
+ centerY - height / 2,
72
+ centerY,
73
+ centerY + height / 2
74
+ );
66
75
  }
67
76
  /**
68
77
  * Create rect from sections.
@@ -76,6 +85,22 @@ var DivRect = class _DivRect {
76
85
  static createSections(leftw, rightw, toph, bottomh) {
77
86
  return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
78
87
  }
88
+ /** @deprecated - Renamed to anchorX. */
89
+ get centerX() {
90
+ return this.anchorX;
91
+ }
92
+ /** @deprecated - Renamed to anchorX. */
93
+ set centerX(x) {
94
+ this.anchorX = x;
95
+ }
96
+ /** @deprecated - Renamed to anchorY. */
97
+ get centerY() {
98
+ return this.anchorY;
99
+ }
100
+ /** @deprecated - Renamed to anchorY. */
101
+ set centerY(y) {
102
+ this.anchorY = y;
103
+ }
79
104
  /**
80
105
  * Width getter.
81
106
  */
@@ -92,25 +117,25 @@ var DivRect = class _DivRect {
92
117
  * Left section width getter.
93
118
  */
94
119
  get leftw() {
95
- return this.centerX - this.left;
120
+ return this.anchorX - this.left;
96
121
  }
97
122
  /**
98
123
  * Right section width getter.
99
124
  */
100
125
  get rightw() {
101
- return this.right - this.centerX;
126
+ return this.right - this.anchorX;
102
127
  }
103
128
  /**
104
129
  * Top section height getter.
105
130
  */
106
131
  get toph() {
107
- return this.centerY - this.top;
132
+ return this.anchorY - this.top;
108
133
  }
109
134
  /**
110
135
  * Bottom section height getter.
111
136
  */
112
137
  get bottomh() {
113
- return this.bottom - this.centerY;
138
+ return this.bottom - this.anchorY;
114
139
  }
115
140
  /**
116
141
  * Does this Rect contain given (x, y)-point?
@@ -143,7 +168,7 @@ var DivRect = class _DivRect {
143
168
  return a.right > b.left && a.left < b.right;
144
169
  }
145
170
  /**
146
- * Check if this Rect equals with given Rect.
171
+ * Check if given rects are equal.
147
172
  * @param a - DivRect a.
148
173
  * @param b - DivRect b.
149
174
  * @returns - True/false.
@@ -154,17 +179,25 @@ var DivRect = class _DivRect {
154
179
  } else if (a == null || b == null) {
155
180
  return false;
156
181
  } else {
157
- return a === b || a.left === b.left && a.centerX === b.centerX && a.right === b.right && a.top === b.top && a.centerY === b.centerY && a.bottom === b.bottom;
182
+ return a === b || a.left === b.left && a.anchorX === b.anchorX && a.right === b.right && a.top === b.top && a.anchorY === b.anchorY && a.bottom === b.bottom;
158
183
  }
159
184
  }
160
185
  /**
161
- * Check if frame of this Rect equals with given Rect, ignoring center x- and center y-coordinates.
186
+ * Check if this rect equals with another rect.
187
+ * @param other - The other rect.
188
+ * @returns - True/false.
189
+ */
190
+ equals(other) {
191
+ return _DivRect.equals(this, other);
192
+ }
193
+ /**
194
+ * Check if edges of given rects are equal, ignoring anchorX and anchorY.
162
195
  *
163
196
  * @param a - DivRect a.
164
197
  * @param b - DivRect b.
165
198
  * @returns - True/false.
166
199
  */
167
- static equalsFrame(a, b) {
200
+ static equalsEdges(a, b) {
168
201
  if (a == null && b == null) {
169
202
  return true;
170
203
  } else if (a == null || b == null) {
@@ -173,13 +206,26 @@ var DivRect = class _DivRect {
173
206
  return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
174
207
  }
175
208
  }
209
+ /**
210
+ * Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
211
+ *
212
+ * @param other - The other DivRect.
213
+ * @returns - True/false.
214
+ */
215
+ equalsEdges(other) {
216
+ return _DivRect.equalsEdges(this, other);
217
+ }
218
+ /** @deprecated - Use `DivRect.equalsEdges()` instead. */
219
+ static equalsFrame(a, b) {
220
+ return _DivRect.equalsEdges(a, b);
221
+ }
176
222
  /**
177
223
  * Created duplicate of this Rect.
178
224
  *
179
225
  * @returns - Duplicate.
180
226
  */
181
227
  copy() {
182
- return new _DivRect(this.left, this.centerX, this.right, this.top, this.centerY, this.bottom);
228
+ return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
183
229
  }
184
230
  /**
185
231
  * Move this rect by (dx, dy). Modifies this Rect.
@@ -190,10 +236,10 @@ var DivRect = class _DivRect {
190
236
  */
191
237
  offsetInPlace(dx, dy) {
192
238
  this.left += dx;
193
- this.centerX += dx;
239
+ this.anchorX += dx;
194
240
  this.right += dx;
195
241
  this.top += dy;
196
- this.centerY += dy;
242
+ this.anchorY += dy;
197
243
  this.bottom += dy;
198
244
  return this;
199
245
  }
@@ -238,10 +284,10 @@ var DivRect = class _DivRect {
238
284
  clipInPlace(clipRect) {
239
285
  this.left = Math.max(this.left, clipRect.left);
240
286
  this.right = Math.min(this.right, clipRect.right);
241
- this.centerX = Utils.Math.clamp(this.centerX, this.left, this.right);
287
+ this.anchorX = Utils.Math.clamp(this.anchorX, this.left, this.right);
242
288
  this.top = Math.max(this.top, clipRect.top);
243
289
  this.bottom = Math.min(this.bottom, clipRect.bottom);
244
- this.centerY = Utils.Math.clamp(this.centerY, this.top, this.bottom);
290
+ this.anchorY = Utils.Math.clamp(this.anchorY, this.top, this.bottom);
245
291
  return this;
246
292
  }
247
293
  /**
@@ -254,7 +300,7 @@ var DivRect = class _DivRect {
254
300
  return this.copy().clipInPlace(clipRect);
255
301
  }
256
302
  /**
257
- * Scale Rect. Anchor pos is (centerX, centerY). Modifies this Rect.
303
+ * Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
258
304
  *
259
305
  * @param scaleX - Scale x-amount.
260
306
  * @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
@@ -262,14 +308,14 @@ var DivRect = class _DivRect {
262
308
  */
263
309
  scaleInPlace(scaleX, scaleY) {
264
310
  scaleY = scaleY != null ? scaleY : scaleX;
265
- this.left = this.centerX - this.leftw * scaleX;
266
- this.right = this.centerX + this.rightw * scaleX;
267
- this.top = this.centerY - this.toph * scaleY;
268
- this.bottom = this.centerY + this.bottomh * scaleY;
311
+ this.left = this.anchorX - this.leftw * scaleX;
312
+ this.right = this.anchorX + this.rightw * scaleX;
313
+ this.top = this.anchorY - this.toph * scaleY;
314
+ this.bottom = this.anchorY + this.bottomh * scaleY;
269
315
  return this;
270
316
  }
271
317
  /**
272
- * Scale Rect. Anchor pos is (centerX, centerY). Immutable, returns modified copy.
318
+ * Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
273
319
  *
274
320
  * @param scaleX - Scale x-amount.
275
321
  * @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
@@ -288,17 +334,18 @@ var DivRect = class _DivRect {
288
334
  };
289
335
 
290
336
  // src/score/pub/document-builder.ts
291
- import { Utils as Utils16 } from "@tspro/ts-utils-lib";
337
+ import { Guard as Guard12, Utils as Utils12 } from "@tspro/ts-utils-lib";
292
338
 
293
339
  // src/score/pub/types.ts
294
- var StaffPreset = /* @__PURE__ */ ((StaffPreset3) => {
295
- StaffPreset3["Treble"] = "treble";
296
- StaffPreset3["Bass"] = "bass";
297
- StaffPreset3["Grand"] = "grand";
298
- StaffPreset3["GuitarTreble"] = "guitarTreble";
299
- StaffPreset3["GuitarTab"] = "guitarTab";
300
- StaffPreset3["GuitarCombined"] = "guitarCombined";
301
- return StaffPreset3;
340
+ import { Guard } from "@tspro/ts-utils-lib";
341
+ var StaffPreset = /* @__PURE__ */ ((StaffPreset2) => {
342
+ StaffPreset2["Treble"] = "treble";
343
+ StaffPreset2["Bass"] = "bass";
344
+ StaffPreset2["Grand"] = "grand";
345
+ StaffPreset2["GuitarTreble"] = "guitarTreble";
346
+ StaffPreset2["GuitarTab"] = "guitarTab";
347
+ StaffPreset2["GuitarCombined"] = "guitarCombined";
348
+ return StaffPreset2;
302
349
  })(StaffPreset || {});
303
350
  var Clef = /* @__PURE__ */ ((Clef2) => {
304
351
  Clef2["G"] = "G";
@@ -308,12 +355,42 @@ var Clef = /* @__PURE__ */ ((Clef2) => {
308
355
  function getVoiceIds() {
309
356
  return [0, 1, 2, 3];
310
357
  }
358
+ function isVoiceId(voiceId) {
359
+ return Guard.isIncluded(voiceId, getVoiceIds());
360
+ }
361
+ function validateVoiceId(voiceId) {
362
+ if (isVoiceId(voiceId)) {
363
+ return voiceId;
364
+ } else {
365
+ throw new MusicError(6 /* Score */, `Voice id ${voiceId} is invalid!`);
366
+ }
367
+ }
311
368
  function getStringNumbers() {
312
369
  return [1, 2, 3, 4, 5, 6];
313
370
  }
371
+ function isStringNumber(stringNum) {
372
+ return Guard.isIncluded(stringNum, getStringNumbers());
373
+ }
374
+ function validateStringNumber(stringNum) {
375
+ if (isStringNumber(stringNum)) {
376
+ return stringNum;
377
+ } else {
378
+ throw new MusicError(6 /* Score */, `String number ${stringNum} is invalid!`);
379
+ }
380
+ }
314
381
  function getVerseNumbers() {
315
382
  return [1, 2, 3];
316
383
  }
384
+ function isVerseNumber(verse) {
385
+ return Guard.isIncluded(verse, getVerseNumbers());
386
+ }
387
+ function validateVerseNumber(verseNum) {
388
+ if (isVerseNumber(verseNum)) {
389
+ return verseNum;
390
+ } else {
391
+ throw new MusicError(6 /* Score */, `Verse number ${verseNum} is invalid!`);
392
+ }
393
+ }
317
394
  var Stem = /* @__PURE__ */ ((Stem2) => {
318
395
  Stem2["Auto"] = "auto";
319
396
  Stem2["Up"] = "up";
@@ -344,12 +421,12 @@ var Connective = /* @__PURE__ */ ((Connective2) => {
344
421
  Connective2["Slide"] = "slide";
345
422
  return Connective2;
346
423
  })(Connective || {});
347
- var VerticalPosition = /* @__PURE__ */ ((VerticalPosition4) => {
348
- VerticalPosition4["Auto"] = "auto";
349
- VerticalPosition4["Above"] = "above";
350
- VerticalPosition4["Below"] = "below";
351
- VerticalPosition4["Both"] = "both";
352
- return VerticalPosition4;
424
+ var VerticalPosition = /* @__PURE__ */ ((VerticalPosition3) => {
425
+ VerticalPosition3["Auto"] = "auto";
426
+ VerticalPosition3["Above"] = "above";
427
+ VerticalPosition3["Below"] = "below";
428
+ VerticalPosition3["Both"] = "both";
429
+ return VerticalPosition3;
353
430
  })(VerticalPosition || {});
354
431
  var LyricsAlign = /* @__PURE__ */ ((LyricsAlign2) => {
355
432
  LyricsAlign2["Left"] = "left";
@@ -420,6 +497,7 @@ var PlayState = /* @__PURE__ */ ((PlayState2) => {
420
497
  })(PlayState || {});
421
498
 
422
499
  // src/score/engine/music-object.ts
500
+ import { AnchoredRect } from "@tspro/ts-utils-lib";
423
501
  var MusicObjectLink = class {
424
502
  constructor(head) {
425
503
  __publicField(this, "head");
@@ -448,7 +526,7 @@ var MusicObject = class {
448
526
  this.parent = parent;
449
527
  __publicField(this, "anchoredLayoutObjects", []);
450
528
  __publicField(this, "link");
451
- __publicField(this, "rect", new DivRect());
529
+ __publicField(this, "rect", new AnchoredRect());
452
530
  __publicField(this, "needRectUpdate", true);
453
531
  }
454
532
  getParent() {
@@ -500,7 +578,7 @@ import { Note as Note9 } from "@tspro/web-music-score/theory";
500
578
  import { getTuningStrings, Note as Note8, validateTuningName } from "@tspro/web-music-score/theory";
501
579
 
502
580
  // src/score/engine/render-context.ts
503
- import { Utils as Utils2, Vec2, Device } from "@tspro/ts-utils-lib";
581
+ import { Utils as Utils2, Vec, Device, UniMap, AnchoredRect as AnchoredRect2 } from "@tspro/ts-utils-lib";
504
582
 
505
583
  // src/score/engine/settings.ts
506
584
  var DebugSettings = {
@@ -545,7 +623,7 @@ var G_clef_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAACWCAYA
545
623
  var HilightStaffPosRectColor = "#55cc55";
546
624
  var HilightObjectRectColor = "#55cc55";
547
625
  var PlayPosIndicatorColor = "#44aa44";
548
- var ImageAssets = /* @__PURE__ */ new Map([
626
+ var ImageAssets = new UniMap([
549
627
  [0 /* G_Clef */, { src: G_clef_default }],
550
628
  [1 /* F_Clef */, { src: F_clef_default }]
551
629
  ]);
@@ -614,7 +692,7 @@ var RenderContext = class {
614
692
  }
615
693
  finishImageAsset(asset) {
616
694
  asset.finished = true;
617
- let allFinished = Array.from(ImageAssets).every((asset2) => asset2[1].finished === true);
695
+ let allFinished = ImageAssets.every((asset2) => asset2.finished === true);
618
696
  if (allFinished) {
619
697
  this.onLoad();
620
698
  }
@@ -662,7 +740,7 @@ var RenderContext = class {
662
740
  return this.scoreEventListener !== void 0;
663
741
  }
664
742
  getMousePos(e) {
665
- return new Vec2(e.offsetX, e.offsetY);
743
+ return new Vec(e.offsetX, e.offsetY);
666
744
  }
667
745
  updateCurStaffPos(staffPos, click) {
668
746
  let changed = !staffPosEquals(staffPos, this.curStaffPos);
@@ -879,7 +957,7 @@ var RenderContext = class {
879
957
  toph = unitSize * (0.5 + flagCount - adj);
880
958
  bottomh = unitSize * (1 + flagCount + adj);
881
959
  }
882
- return new DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
960
+ return new AnchoredRect2(-leftw, 0, rightw, -toph, 0, bottomh);
883
961
  }
884
962
  drawRest(restSize, x, y) {
885
963
  let { unitSize } = this;
@@ -1101,7 +1179,7 @@ var RenderContext = class {
1101
1179
  }
1102
1180
  drawBrace(rect, side) {
1103
1181
  if (this.ctx) {
1104
- let { left, right, width, top, bottom, centerY } = rect;
1182
+ let { left, right, width, top, bottom, anchorY } = rect;
1105
1183
  if (side === "right") {
1106
1184
  [left, right, width] = [right, left, -width];
1107
1185
  }
@@ -1111,18 +1189,18 @@ var RenderContext = class {
1111
1189
  left + width * 0.1,
1112
1190
  top,
1113
1191
  left + width * 0.8,
1114
- centerY,
1192
+ anchorY,
1115
1193
  left,
1116
- centerY
1194
+ anchorY
1117
1195
  );
1118
1196
  this.ctx.moveTo(right, bottom);
1119
1197
  this.ctx.bezierCurveTo(
1120
1198
  left + width * 0.1,
1121
1199
  bottom,
1122
1200
  left + width * 0.8,
1123
- centerY,
1201
+ anchorY,
1124
1202
  left,
1125
- centerY
1203
+ anchorY
1126
1204
  );
1127
1205
  this.ctx.stroke();
1128
1206
  }
@@ -1131,10 +1209,10 @@ var RenderContext = class {
1131
1209
 
1132
1210
  // src/score/engine/obj-staff-and-tab.ts
1133
1211
  import { MusicError as MusicError15, MusicErrorType as MusicErrorType15 } from "@tspro/web-music-score/core";
1134
- import { Utils as Utils13 } from "@tspro/ts-utils-lib";
1212
+ import { AnchoredRect as AnchoredRect23, Guard as Guard9, UniMap as UniMap7, Utils as Utils10 } from "@tspro/ts-utils-lib";
1135
1213
 
1136
1214
  // src/score/engine/obj-measure.ts
1137
- import { Map3 as Map32, Utils as Utils12 } from "@tspro/ts-utils-lib";
1215
+ import { Guard as Guard8, IndexArray as IndexArray2, UniMap as UniMap5, TriMap as TriMap2, ValueSet, Utils as Utils9, asMulti, AnchoredRect as AnchoredRect21 } from "@tspro/ts-utils-lib";
1138
1216
  import { getScale, Scale, validateScaleType, Note as Note7, RhythmProps as RhythmProps5, KeySignature as KeySignature2, getDefaultKeySignature, PitchNotation, SymbolSet, validateNoteLength as validateNoteLength2, NoteLengthProps as NoteLengthProps5 } from "@tspro/web-music-score/theory";
1139
1217
  import { getDefaultTempo, getDefaultTimeSignature } from "@tspro/web-music-score/theory";
1140
1218
 
@@ -1164,6 +1242,7 @@ var AccidentalState = class {
1164
1242
  import { Note as Note2, getTempoString, KeySignature } from "@tspro/web-music-score/theory";
1165
1243
 
1166
1244
  // src/score/engine/obj-image.ts
1245
+ import { AnchoredRect as AnchoredRect3 } from "@tspro/ts-utils-lib";
1167
1246
  var ObjImage = class extends MusicObject {
1168
1247
  constructor(parent, image, anchorX, anchorY, imageScale) {
1169
1248
  super(parent);
@@ -1186,9 +1265,9 @@ var ObjImage = class extends MusicObject {
1186
1265
  try {
1187
1266
  let w = image.naturalWidth * imageScale * unitSize;
1188
1267
  let h = image.naturalHeight * imageScale * unitSize;
1189
- this.rect = DivRect.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
1268
+ this.rect = AnchoredRect3.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
1190
1269
  } catch (err) {
1191
- this.rect = new DivRect();
1270
+ this.rect = new AnchoredRect3();
1192
1271
  }
1193
1272
  }
1194
1273
  offset(dx, dy) {
@@ -1197,12 +1276,13 @@ var ObjImage = class extends MusicObject {
1197
1276
  draw(ctx) {
1198
1277
  let r = this.rect;
1199
1278
  ctx.drawDebugRect(r);
1200
- ctx.drawImage(this.image, r.centerX - r.leftw, r.centerY - r.toph, r.width, r.height);
1279
+ ctx.drawImage(this.image, r.anchorX - r.leftw, r.anchorY - r.toph, r.width, r.height);
1201
1280
  }
1202
1281
  };
1203
1282
 
1204
1283
  // src/score/engine/obj-accidental.ts
1205
1284
  import { MusicError as MusicError3, MusicErrorType as MusicErrorType3 } from "@tspro/web-music-score/core";
1285
+ import { AnchoredRect as AnchoredRect4 } from "@tspro/ts-utils-lib";
1206
1286
  var ObjAccidental = class extends MusicObject {
1207
1287
  constructor(parent, diatonicId, accidental, color = "black") {
1208
1288
  super(parent);
@@ -1222,19 +1302,19 @@ var ObjAccidental = class extends MusicObject {
1222
1302
  let { unitSize } = ctx;
1223
1303
  switch (this.accidental) {
1224
1304
  case -2:
1225
- this.rect = DivRect.createSections(unitSize * 1.25, unitSize * 1.25, unitSize * 4, unitSize * 1.2);
1305
+ this.rect = AnchoredRect4.createSections(unitSize * 1.25, unitSize * 1.25, unitSize * 4, unitSize * 1.2);
1226
1306
  break;
1227
1307
  case -1:
1228
- this.rect = DivRect.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 4, unitSize * 1.2);
1308
+ this.rect = AnchoredRect4.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 4, unitSize * 1.2);
1229
1309
  break;
1230
1310
  case 0:
1231
- this.rect = DivRect.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2.2, unitSize * 2.2);
1311
+ this.rect = AnchoredRect4.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2.2, unitSize * 2.2);
1232
1312
  break;
1233
1313
  case 1:
1234
- this.rect = DivRect.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2, unitSize * 2);
1314
+ this.rect = AnchoredRect4.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2, unitSize * 2);
1235
1315
  break;
1236
1316
  case 2:
1237
- this.rect = DivRect.createSections(unitSize * 1, unitSize * 1, unitSize * 1, unitSize * 1);
1317
+ this.rect = AnchoredRect4.createSections(unitSize * 1, unitSize * 1, unitSize * 1, unitSize * 1);
1238
1318
  break;
1239
1319
  default:
1240
1320
  throw new MusicError3(MusicErrorType3.Score, "Invalid accidental value: " + this.accidental);
@@ -1247,8 +1327,8 @@ var ObjAccidental = class extends MusicObject {
1247
1327
  ctx.drawDebugRect(this.rect);
1248
1328
  let { unitSize } = ctx;
1249
1329
  let { accidental } = this;
1250
- let x = this.rect.centerX;
1251
- let y = this.rect.centerY;
1330
+ let x = this.rect.anchorX;
1331
+ let y = this.rect.anchorY;
1252
1332
  ctx.color(this.color);
1253
1333
  const draw_b = (x2, y2) => {
1254
1334
  ctx.lineWidth(1).beginPath().moveTo(x2 - unitSize * 0.75, y2 - unitSize * 4).lineTo(x2 - unitSize * 0.75, y2 + unitSize * 1.1).bezierCurveTo(
@@ -1277,6 +1357,7 @@ var ObjAccidental = class extends MusicObject {
1277
1357
  };
1278
1358
 
1279
1359
  // src/score/engine/obj-text.ts
1360
+ import { AnchoredRect as AnchoredRect5 } from "@tspro/ts-utils-lib";
1280
1361
  var DefaultBoxedPadding = 0.5;
1281
1362
  var ObjText = class extends MusicObject {
1282
1363
  constructor(parent, text, anchorX, anchorY) {
@@ -1313,7 +1394,7 @@ var ObjText = class extends MusicObject {
1313
1394
  if (this.textLines.length === 0) {
1314
1395
  this.textLines = [""];
1315
1396
  }
1316
- this.rect = new DivRect();
1397
+ this.rect = new AnchoredRect5();
1317
1398
  this.mi = new MText(this);
1318
1399
  }
1319
1400
  getMusicInterface() {
@@ -1325,14 +1406,14 @@ var ObjText = class extends MusicObject {
1325
1406
  updateAnchorX(anchorX) {
1326
1407
  this.anchorX = anchorX;
1327
1408
  let { width } = this.rect;
1328
- this.rect.left = this.rect.centerX - width * anchorX;
1329
- this.rect.right = this.rect.centerX + width * (1 - anchorX);
1409
+ this.rect.left = this.rect.anchorX - width * anchorX;
1410
+ this.rect.right = this.rect.anchorX + width * (1 - anchorX);
1330
1411
  }
1331
1412
  updateAnchorY(anchorY) {
1332
1413
  this.anchorY = anchorY;
1333
1414
  let { height } = this.rect;
1334
- this.rect.top = this.rect.centerY - height * anchorY;
1335
- this.rect.bottom = this.rect.centerY + height * (1 - anchorY);
1415
+ this.rect.top = this.rect.anchorY - height * anchorY;
1416
+ this.rect.bottom = this.rect.anchorY + height * (1 - anchorY);
1336
1417
  }
1337
1418
  pick(x, y) {
1338
1419
  return this.rect.contains(x, y) ? [this] : [];
@@ -1349,7 +1430,7 @@ var ObjText = class extends MusicObject {
1349
1430
  if (this.boxed === "square" || this.boxed === "circle") {
1350
1431
  h = w = Math.max(h, w);
1351
1432
  }
1352
- this.rect = DivRect.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
1433
+ this.rect = AnchoredRect5.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
1353
1434
  }
1354
1435
  offset(dx, dy) {
1355
1436
  this.rect.offsetInPlace(dx, dy);
@@ -1371,12 +1452,12 @@ var ObjText = class extends MusicObject {
1371
1452
  let textHeight = lineCount * lineHeight;
1372
1453
  let fixY = -lineHeight * (italic ? 0.25 : 0.2);
1373
1454
  let p = padding * ctx.unitSize;
1374
- let centerX = (rect.left + p) * (1 - anchorX) + (rect.right - p) * anchorX;
1375
- let centerY = (rect.top + p) * (1 - anchorY) + (rect.bottom - p) * anchorY;
1455
+ let aX = (rect.left + p) * (1 - anchorX) + (rect.right - p) * anchorX;
1456
+ let aY = (rect.top + p) * (1 - anchorY) + (rect.bottom - p) * anchorY;
1376
1457
  ctx.color(this.color);
1377
1458
  this.textLines.forEach((textLine, i) => {
1378
- let x = centerX - lineWidths[i] * anchorX;
1379
- let y = centerY - textHeight * anchorY + lineHeight * (i + 1) + fixY;
1459
+ let x = aX - lineWidths[i] * anchorX;
1460
+ let y = aY - textHeight * anchorY + lineHeight * (i + 1) + fixY;
1380
1461
  ctx.fillText(textLine, x, y);
1381
1462
  });
1382
1463
  switch (this.boxed) {
@@ -1386,12 +1467,8 @@ var ObjText = class extends MusicObject {
1386
1467
  break;
1387
1468
  case "circle":
1388
1469
  case "ellipse":
1389
- let x = (rect.left + rect.right) / 2;
1390
- let y = (rect.top + rect.bottom) / 2;
1391
- let rx = (rect.right - rect.left) / 2;
1392
- let ry = (rect.bottom - rect.top) / 2;
1393
1470
  ctx.beginPath();
1394
- ctx.ellipse(x, y, rx, ry, 0, 0, 2 * Math.PI);
1471
+ ctx.ellipse(rect.centerX, rect.centerY, rect.width / 2, rect.height / 2, 0, 0, 2 * Math.PI);
1395
1472
  ctx.stroke();
1396
1473
  break;
1397
1474
  }
@@ -1400,6 +1477,7 @@ var ObjText = class extends MusicObject {
1400
1477
 
1401
1478
  // src/score/engine/obj-signature.ts
1402
1479
  import { MusicError as MusicError4, MusicErrorType as MusicErrorType4 } from "@tspro/web-music-score/core";
1480
+ import { AnchoredRect as AnchoredRect6 } from "@tspro/ts-utils-lib";
1403
1481
  var ObjStaffSignature = class extends MusicObject {
1404
1482
  constructor(measure, staff) {
1405
1483
  super(measure);
@@ -1558,7 +1636,7 @@ var ObjStaffSignature = class extends MusicObject {
1558
1636
  let { staff } = this;
1559
1637
  let paddingX = unitSize;
1560
1638
  let x = 0;
1561
- this.rect = new DivRect();
1639
+ this.rect = new AnchoredRect6();
1562
1640
  if (this.clefImage) {
1563
1641
  x += paddingX;
1564
1642
  this.clefImage.layout(ctx);
@@ -1568,7 +1646,7 @@ var ObjStaffSignature = class extends MusicObject {
1568
1646
  if (this.eightBelowClef) {
1569
1647
  let r = this.clefImage.getRect();
1570
1648
  this.eightBelowClef.layout(ctx);
1571
- this.eightBelowClef.offset(r.left + r.width / 2, Math.max(r.centerY + r.height * 0.3, staff.getBottomLineY()));
1649
+ this.eightBelowClef.offset(r.centerX, Math.max(r.anchorY + r.height * 0.3, staff.getBottomLineY()));
1572
1650
  this.rect.expandInPlace(this.eightBelowClef.getRect());
1573
1651
  }
1574
1652
  }
@@ -1727,7 +1805,7 @@ var ObjTabSignature = class extends MusicObject {
1727
1805
  let paddingX = unitSize;
1728
1806
  let x = 0;
1729
1807
  let topLineY = tab.getTopLineY();
1730
- this.rect = new DivRect();
1808
+ this.rect = new AnchoredRect6();
1731
1809
  if (this.measureNumber) {
1732
1810
  this.measureNumber.layout(ctx);
1733
1811
  this.measureNumber.offset(0, topLineY);
@@ -1738,11 +1816,11 @@ var ObjTabSignature = class extends MusicObject {
1738
1816
  (_b = this.beatSizeText) == null ? void 0 : _b.layout(ctx);
1739
1817
  let tsWidth = Math.max((_d = (_c = this.beatCountText) == null ? void 0 : _c.getRect().width) != null ? _d : 0, (_f = (_e = this.beatSizeText) == null ? void 0 : _e.getRect().width) != null ? _f : 0);
1740
1818
  if (this.beatCountText) {
1741
- this.beatCountText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().centerY - this.beatCountText.getRect().bottomh);
1819
+ this.beatCountText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().anchorY - this.beatCountText.getRect().bottomh);
1742
1820
  this.rect.expandInPlace(this.beatCountText.getRect());
1743
1821
  }
1744
1822
  if (this.beatSizeText) {
1745
- this.beatSizeText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().centerY + this.beatSizeText.getRect().toph);
1823
+ this.beatSizeText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().anchorY + this.beatSizeText.getRect().toph);
1746
1824
  this.rect.expandInPlace(this.beatSizeText.getRect());
1747
1825
  }
1748
1826
  if (this.tempoText) {
@@ -1770,7 +1848,7 @@ var ObjTabSignature = class extends MusicObject {
1770
1848
  };
1771
1849
 
1772
1850
  // src/score/engine/player.ts
1773
- import { Utils as Utils5 } from "@tspro/ts-utils-lib";
1851
+ import { Rect as Rect2, UniMap as UniMap3, Utils as Utils5 } from "@tspro/ts-utils-lib";
1774
1852
  import { NoteLength as NoteLength4, RhythmProps as RhythmProps4, alterTempoSpeed } from "@tspro/web-music-score/theory";
1775
1853
  import * as Audio from "@tspro/web-music-score/audio";
1776
1854
 
@@ -1778,6 +1856,7 @@ import * as Audio from "@tspro/web-music-score/audio";
1778
1856
  import { Note as Note5 } from "@tspro/web-music-score/theory";
1779
1857
 
1780
1858
  // src/score/engine/obj-arpeggio.ts
1859
+ import { AnchoredRect as AnchoredRect7 } from "@tspro/ts-utils-lib";
1781
1860
  var ObjArpeggio = class extends MusicObject {
1782
1861
  constructor(col, line, arpeggioDir) {
1783
1862
  super(col);
@@ -1808,7 +1887,7 @@ var ObjArpeggio = class extends MusicObject {
1808
1887
  this.numCycles = Math.ceil((bottom - top) / this.cycleHeight) + 2;
1809
1888
  let width = unitSize * 2;
1810
1889
  let height = this.numCycles * this.cycleHeight;
1811
- this.rect = new DivRect(-width / 2, width / 2, -height / 2 - this.topArrowHeight, height / 2 + this.bottomArrowHeight);
1890
+ this.rect = new AnchoredRect7(-width / 2, width / 2, -height / 2 - this.topArrowHeight, height / 2 + this.bottomArrowHeight);
1812
1891
  }
1813
1892
  offset(dx, dy) {
1814
1893
  this.rect.offsetInPlace(dx, dy);
@@ -1820,21 +1899,21 @@ var ObjArpeggio = class extends MusicObject {
1820
1899
  ctx.lineWidth(2);
1821
1900
  ctx.beginPath();
1822
1901
  for (let i = 0, y = rect.top + topArrowHeight; i < this.numCycles; i++, y += this.cycleHeight) {
1823
- ctx.moveTo(rect.centerX, y);
1824
- ctx.quadraticCurveTo(rect.left, y + this.cycleHeight / 4, rect.centerX, y + this.cycleHeight / 2);
1825
- ctx.quadraticCurveTo(rect.right, y + this.cycleHeight * 3 / 4, rect.centerX, y + this.cycleHeight);
1902
+ ctx.moveTo(rect.anchorX, y);
1903
+ ctx.quadraticCurveTo(rect.left, y + this.cycleHeight / 4, rect.anchorX, y + this.cycleHeight / 2);
1904
+ ctx.quadraticCurveTo(rect.right, y + this.cycleHeight * 3 / 4, rect.anchorX, y + this.cycleHeight);
1826
1905
  }
1827
1906
  ctx.stroke();
1828
1907
  if (topArrowHeight > 0) {
1829
1908
  ctx.beginPath();
1830
- ctx.moveTo(rect.centerX, rect.top);
1909
+ ctx.moveTo(rect.anchorX, rect.top);
1831
1910
  ctx.lineTo(rect.right, rect.top + topArrowHeight);
1832
1911
  ctx.lineTo(rect.left, rect.top + topArrowHeight);
1833
1912
  ctx.fill();
1834
1913
  }
1835
1914
  if (bottomArrowHeight > 0) {
1836
1915
  ctx.beginPath();
1837
- ctx.moveTo(rect.centerX, rect.bottom);
1916
+ ctx.moveTo(rect.anchorX, rect.bottom);
1838
1917
  ctx.lineTo(rect.left, rect.bottom - bottomArrowHeight);
1839
1918
  ctx.lineTo(rect.right, rect.bottom - bottomArrowHeight);
1840
1919
  ctx.fill();
@@ -1845,6 +1924,7 @@ var ObjArpeggio = class extends MusicObject {
1845
1924
  // src/score/engine/obj-rest.ts
1846
1925
  import { Note as Note3, NoteLengthProps as NoteLengthProps2, RhythmProps as RhythmProps2, Tuplet } from "@tspro/web-music-score/theory";
1847
1926
  import { MusicError as MusicError5, MusicErrorType as MusicErrorType5 } from "@tspro/web-music-score/core";
1927
+ import { AnchoredRect as AnchoredRect8 } from "@tspro/ts-utils-lib";
1848
1928
  function getDiatonicIdFromStaffPos(staffPos) {
1849
1929
  if (typeof staffPos === "number") {
1850
1930
  return Note3.getChromaticNote(staffPos).diatonicId;
@@ -1861,7 +1941,7 @@ var ObjStaffRest = class extends MusicObject {
1861
1941
  super(staff);
1862
1942
  this.staff = staff;
1863
1943
  this.rest = rest;
1864
- __publicField(this, "restRect", new DivRect());
1944
+ __publicField(this, "restRect", new AnchoredRect8());
1865
1945
  __publicField(this, "dotRects", []);
1866
1946
  __publicField(this, "mi");
1867
1947
  staff.addObject(this);
@@ -1880,7 +1960,7 @@ var ObjStaffRest = class extends MusicObject {
1880
1960
  this.rest.requestRectUpdate();
1881
1961
  }
1882
1962
  updateRect() {
1883
- this.rect = this.restRect.copy();
1963
+ this.rect = this.restRect.clone();
1884
1964
  this.dotRects.forEach((r) => this.rect.expandInPlace(r));
1885
1965
  }
1886
1966
  };
@@ -1986,9 +2066,9 @@ var _ObjRest = class _ObjRest extends MusicObject {
1986
2066
  getBeamCoords() {
1987
2067
  return this.staffObjects.map((obj) => {
1988
2068
  let staff = obj.staff;
1989
- let x = obj.getRect().centerX;
2069
+ let x = obj.getRect().anchorX;
1990
2070
  let y = this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
1991
- let stemHeight = Math.abs(obj.getRect().centerY - y);
2071
+ let stemHeight = Math.abs(obj.getRect().anchorY - y);
1992
2072
  return { staff, x, y, stemHeight };
1993
2073
  });
1994
2074
  }
@@ -2042,17 +2122,18 @@ var _ObjRest = class _ObjRest extends MusicObject {
2042
2122
  let dotWidth = DocumentSettings.DotSize * unitSize;
2043
2123
  let dotX = obj.restRect.rightw + (DocumentSettings.RestDotSpace + DocumentSettings.DotSize * unitSize) + i * DocumentSettings.DotSize * unitSize * 1.5;
2044
2124
  let dotY = this.getRestDotVerticalDisplacement(noteSize) * unitSize;
2045
- obj.dotRects.push(DivRect.createCentered(dotX, dotY, dotWidth, dotWidth));
2125
+ obj.dotRects.push(AnchoredRect8.createCentered(dotX, dotY, dotWidth, dotWidth));
2046
2126
  }
2047
2127
  obj.offset(0, staff.getDiatonicIdY(diatonicId));
2048
2128
  this.staffObjects.push(obj);
2129
+ this.measure.addStaticObject(staff, obj);
2049
2130
  });
2050
2131
  }
2051
2132
  updateRect() {
2052
2133
  if (this.staffObjects.length === 0) {
2053
- this.rect = new DivRect();
2134
+ this.rect = new AnchoredRect8();
2054
2135
  } else {
2055
- this.rect = this.staffObjects[0].getRect().copy();
2136
+ this.rect = this.staffObjects[0].getRect().clone();
2056
2137
  if (this.staffObjects.length > 1) {
2057
2138
  for (let i = 1; i < this.staffObjects.length; i++) {
2058
2139
  this.rect.expandInPlace(this.staffObjects[i].getRect());
@@ -2073,10 +2154,8 @@ var _ObjRest = class _ObjRest extends MusicObject {
2073
2154
  ctx.color(this.color).lineWidth(1);
2074
2155
  this.staffObjects.forEach((obj) => {
2075
2156
  let { dotRects, restRect } = obj;
2076
- let x = restRect.centerX;
2077
- let y = restRect.centerY;
2078
- ctx.drawRest(noteSize, x, y);
2079
- dotRects.forEach((r) => ctx.fillCircle(r.centerX, r.centerY, r.width / 2));
2157
+ ctx.drawRest(noteSize, restRect.anchorX, restRect.anchorY);
2158
+ dotRects.forEach((r) => ctx.fillCircle(r.anchorX, r.anchorY, r.width / 2));
2080
2159
  });
2081
2160
  }
2082
2161
  };
@@ -2084,18 +2163,18 @@ __publicField(_ObjRest, "UndefinedDiatonicId", Infinity);
2084
2163
  var ObjRest = _ObjRest;
2085
2164
 
2086
2165
  // src/score/engine/obj-note-group.ts
2087
- import { Utils as Utils3 } from "@tspro/ts-utils-lib";
2166
+ import { AnchoredRect as AnchoredRect9, Guard as Guard2, Utils as Utils3 } from "@tspro/ts-utils-lib";
2088
2167
  import { Note as Note4, NoteLengthProps as NoteLengthProps3, RhythmProps as RhythmProps3, Tuplet as Tuplet2 } from "@tspro/web-music-score/theory";
2089
2168
  import { MusicError as MusicError6, MusicErrorType as MusicErrorType6 } from "@tspro/web-music-score/core";
2090
2169
  function getArpeggio(a) {
2091
- return Utils3.Is.isEnumValue(a, Arpeggio) ? a : a === true ? "up" /* Up */ : void 0;
2170
+ return Guard2.isEnumValue(a, Arpeggio) ? a : a === true ? "up" /* Up */ : void 0;
2092
2171
  }
2093
2172
  function sortNotesAndStrings(notes, strings) {
2094
2173
  let stringArr = Utils3.Arr.isArray(strings) ? strings : strings !== void 0 ? [strings] : [];
2095
2174
  let noteStringData = notes.map((note, i) => {
2096
2175
  return { note, string: stringArr[i] };
2097
2176
  });
2098
- noteStringData = Utils3.Arr.removeDuplicatesCmp(noteStringData, (a, b) => Note4.equals(a.note, b.note)).sort((a, b) => Note4.compareFunc(a.note, b.note));
2177
+ noteStringData = Utils3.Arr.removeDuplicates(noteStringData, (a, b) => Note4.equals(a.note, b.note)).sort((a, b) => Note4.compareFunc(a.note, b.note));
2099
2178
  return {
2100
2179
  sortedNotes: noteStringData.map((e) => e.note),
2101
2180
  sortedStrings: noteStringData.every((e) => e.string === void 0) ? void 0 : noteStringData.map((e) => e.string)
@@ -2133,7 +2212,7 @@ var ObjStaffNoteGroup = class extends MusicObject {
2133
2212
  return [this];
2134
2213
  }
2135
2214
  updateRect() {
2136
- this.rect = this.noteHeadRects[0].copy();
2215
+ this.rect = this.noteHeadRects[0].clone();
2137
2216
  this.noteHeadRects.forEach((r) => this.rect.expandInPlace(r));
2138
2217
  if (this.stemTip) this.rect.expandInPlace(this.stemTip);
2139
2218
  if (this.stemBase) this.rect.expandInPlace(this.stemBase);
@@ -2144,9 +2223,9 @@ var ObjStaffNoteGroup = class extends MusicObject {
2144
2223
  getRect() {
2145
2224
  let bottomNoteRect = this.noteHeadRects[0];
2146
2225
  let topNoteRect = this.noteHeadRects[this.noteHeadRects.length - 1];
2147
- if (this.prevTopNoteY !== topNoteRect.centerY || this.prevBottomNoteY !== bottomNoteRect.centerY) {
2148
- this.prevTopNoteY = topNoteRect.centerY;
2149
- this.prevBottomNoteY = bottomNoteRect.centerY;
2226
+ if (this.prevTopNoteY !== topNoteRect.anchorY || this.prevBottomNoteY !== bottomNoteRect.anchorY) {
2227
+ this.prevTopNoteY = topNoteRect.anchorY;
2228
+ this.prevBottomNoteY = bottomNoteRect.anchorY;
2150
2229
  this.requestRectUpdate();
2151
2230
  }
2152
2231
  return super.getRect();
@@ -2179,7 +2258,7 @@ var ObjTabNoteGroup = class extends MusicObject {
2179
2258
  return this.getRect().contains(x, y) ? [this] : [];
2180
2259
  }
2181
2260
  updateRect() {
2182
- this.rect = this.fretNumbers[0].getRect().copy();
2261
+ this.rect = this.fretNumbers[0].getRect().clone();
2183
2262
  this.fretNumbers.forEach((fn) => this.rect.expandInPlace(fn.getRect()));
2184
2263
  }
2185
2264
  offset(dx, dy) {
@@ -2215,13 +2294,15 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2215
2294
  __publicField(this, "beamGroup");
2216
2295
  __publicField(this, "staffObjects", []);
2217
2296
  __publicField(this, "tabObjects", []);
2297
+ __publicField(this, "isNoteDisplaced");
2218
2298
  __publicField(this, "mi");
2219
- if (!Utils3.Is.isIntegerGte(notes.length, 1)) {
2299
+ if (!Guard2.isIntegerGte(notes.length, 1)) {
2220
2300
  throw new MusicError6(MusicErrorType6.Score, "Cannot create note group object because notes array is empty.");
2221
2301
  }
2222
2302
  let { sortedNotes, sortedStrings } = sortNotesAndStrings(notes, options == null ? void 0 : options.string);
2223
2303
  this.notes = sortedNotes;
2224
2304
  this.setStringsNumbers = sortedStrings;
2305
+ this.isNoteDisplaced = this.notes.map(() => false);
2225
2306
  this.setDiatonicId = Math.round((this.minDiatonicId + this.maxDiatonicId) / 2);
2226
2307
  this.runningDiatonicId = this.setDiatonicId;
2227
2308
  this.runningStemDir = "up" /* Up */;
@@ -2259,6 +2340,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2259
2340
  get stemDir() {
2260
2341
  return this.runningStemDir;
2261
2342
  }
2343
+ setNoteDisplacement(note, isDisplaced) {
2344
+ let i = this.notes.indexOf(note);
2345
+ if (i >= 0) this.isNoteDisplaced[i] = isDisplaced;
2346
+ }
2262
2347
  enableConnective(line) {
2263
2348
  return line.containsVoiceId(this.voiceId) && (line instanceof ObjTab || line.containsDiatonicId(this.runningDiatonicId));
2264
2349
  }
@@ -2276,20 +2361,6 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2276
2361
  this.runningStemDir = stemDir;
2277
2362
  this.runningStringNumbers = stringNumbers;
2278
2363
  }
2279
- getStaticObjects(line) {
2280
- let staticObjects = [];
2281
- this.staffObjects.forEach((obj) => {
2282
- if (obj.staff === line) {
2283
- staticObjects.push(obj);
2284
- }
2285
- });
2286
- this.tabObjects.forEach((obj) => {
2287
- if (obj.tab === line) {
2288
- staticObjects.push(obj);
2289
- }
2290
- });
2291
- return staticObjects;
2292
- }
2293
2364
  pick(x, y) {
2294
2365
  if (!this.getRect().contains(x, y)) {
2295
2366
  return [];
@@ -2323,7 +2394,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2323
2394
  let obj = this.staffObjects.find((obj2) => obj2.staff === line);
2324
2395
  if (!obj || noteIndex < 0 || noteIndex >= obj.noteHeadRects.length) {
2325
2396
  let r = this.getRect();
2326
- return { x: r.centerX, y: r.bottom };
2397
+ return { x: r.anchorX, y: r.bottom };
2327
2398
  }
2328
2399
  let noteHeadRect = obj.noteHeadRects[noteIndex];
2329
2400
  let stemTip = obj.stemTip;
@@ -2331,8 +2402,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2331
2402
  let hasStem = stemTip !== void 0;
2332
2403
  let stemSide = !hasStem ? void 0 : stemDir === "up" /* Up */ ? "right" : "left";
2333
2404
  let padding = noteHeadRect.height / 2;
2334
- let centerX = noteHeadRect.centerX;
2335
- let centerY = noteHeadRect.centerY;
2405
+ let anchorX = noteHeadRect.anchorX;
2406
+ let anchorY = noteHeadRect.anchorY;
2336
2407
  let leftX = noteHeadRect.left - padding;
2337
2408
  let rightX = noteHeadRect.right + padding;
2338
2409
  let aboveY = noteHeadRect.top - padding;
@@ -2344,27 +2415,27 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2344
2415
  }
2345
2416
  switch (noteAnchor) {
2346
2417
  case "center" /* Center */:
2347
- return side === "left" ? { x: rightX, y: centerY } : { x: leftX, y: centerY };
2418
+ return side === "left" ? { x: rightX, y: anchorY } : { x: leftX, y: anchorY };
2348
2419
  case "above" /* Above */:
2349
2420
  if (!hasStem || stemDir === "down" /* Down */) {
2350
- return { x: centerX, y: aboveY };
2421
+ return { x: anchorX, y: aboveY };
2351
2422
  } else {
2352
2423
  return {
2353
- x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : centerX,
2424
+ x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : anchorX,
2354
2425
  y: aboveY
2355
2426
  };
2356
2427
  }
2357
2428
  case "below" /* Below */:
2358
2429
  if (!hasStem || stemDir === "up" /* Up */) {
2359
- return { x: centerX, y: belowY };
2430
+ return { x: anchorX, y: belowY };
2360
2431
  } else {
2361
2432
  return {
2362
- x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : centerX,
2433
+ x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : anchorX,
2363
2434
  y: belowY
2364
2435
  };
2365
2436
  }
2366
2437
  case "stemTip" /* StemTip */:
2367
- return { x: centerX, y: stemTip.centerY + (stemDir === "up" /* Up */ ? -padding : padding) };
2438
+ return { x: anchorX, y: stemTip.anchorY + (stemDir === "up" /* Up */ ? -padding : padding) };
2368
2439
  default:
2369
2440
  throw new MusicError6(MusicErrorType6.Score, "Invalid noteAnchor: " + noteAnchor);
2370
2441
  }
@@ -2382,12 +2453,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2382
2453
  let rightFretNumber = connectiveProps.noteGroups[1].getFretNumber(line, 0);
2383
2454
  let slideUp = leftFretNumber === void 0 || rightFretNumber === void 0 || leftFretNumber <= rightFretNumber;
2384
2455
  if (side === "left") {
2385
- y = (slideUp ? r.centerY + r.bottomh : r.centerY - r.toph) * s;
2456
+ y = (slideUp ? r.anchorY + r.bottomh : r.anchorY - r.toph) * s;
2386
2457
  } else {
2387
- y = (slideUp ? r.centerY - r.toph : r.centerY + r.bottomh) * s;
2458
+ y = (slideUp ? r.anchorY - r.toph : r.anchorY + r.bottomh) * s;
2388
2459
  }
2389
2460
  } else {
2390
- y = r.centerY + r.bottomh * s;
2461
+ y = r.anchorY + r.bottomh * s;
2391
2462
  }
2392
2463
  return { x, y };
2393
2464
  } else {
@@ -2457,9 +2528,9 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2457
2528
  return this.staffObjects.map((obj) => {
2458
2529
  var _a, _b, _c, _d;
2459
2530
  let staff = obj.staff;
2460
- let x = (_b = (_a = obj.stemTip) == null ? void 0 : _a.centerX) != null ? _b : obj.noteHeadRects[0].centerX;
2461
- let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.centerY) != null ? _d : this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
2462
- let stemHeight = this.stemDir === "up" /* Up */ ? Math.abs(obj.noteHeadRects[0].centerY - y) : Math.abs(obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY - y);
2531
+ let x = (_b = (_a = obj.stemTip) == null ? void 0 : _a.anchorX) != null ? _b : obj.noteHeadRects[0].anchorX;
2532
+ let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.anchorY) != null ? _d : this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
2533
+ let stemHeight = this.stemDir === "up" /* Up */ ? Math.abs(obj.noteHeadRects[0].anchorY - y) : Math.abs(obj.noteHeadRects[obj.noteHeadRects.length - 1].anchorY - y);
2463
2534
  return { staff, x, y, stemHeight };
2464
2535
  });
2465
2536
  }
@@ -2548,14 +2619,14 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2548
2619
  let isBottomNote = noteIndex === 0;
2549
2620
  let isTopNote = noteIndex === this.notes.length - 1;
2550
2621
  let noteStaff = (_a = staff.getActualStaff(note.diatonicId)) != null ? _a : staff;
2551
- let noteX = this.col.getNoteHeadDisplacement(this, note) * noteHeadWidth;
2622
+ let noteX = this.isNoteDisplaced[noteIndex] ? noteHeadWidth * (stemDir === "down" /* Down */ ? -1 : 1) : 0;
2552
2623
  let noteY = noteStaff.getDiatonicIdY(note.diatonicId);
2553
2624
  let isNoteOnLine = noteStaff.isLine(note.diatonicId);
2554
2625
  if (isBottomNote && stemDir === "up" /* Up */) stemBaseStaff = noteStaff;
2555
2626
  if (isTopNote && stemDir === "up" /* Up */) stemTipStaff = noteStaff;
2556
2627
  if (isBottomNote && stemDir === "down" /* Down */) stemTipStaff = noteStaff;
2557
2628
  if (isTopNote && stemDir === "down" /* Down */) stemBaseStaff = noteStaff;
2558
- let noteHeadRect = obj.noteHeadRects[noteIndex] = DivRect.createCentered(noteX, noteY, noteHeadWidth, noteHeadHeight);
2629
+ let noteHeadRect = obj.noteHeadRects[noteIndex] = AnchoredRect9.createCentered(noteX, noteY, noteHeadWidth, noteHeadHeight);
2559
2630
  noteStaff.addObject(noteHeadRect);
2560
2631
  if (accState.needAccidental(note)) {
2561
2632
  let acc = obj.accidentals[noteIndex] = new ObjAccidental(this, note.diatonicId, note.accidental, this.color);
@@ -2568,7 +2639,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2568
2639
  for (let i = 0; i < dotCount; i++) {
2569
2640
  let dotX = noteHeadRect.right + DocumentSettings.NoteDotSpace * unitSize + dotWidth / 2 + i * dotWidth * 1.5;
2570
2641
  let dotY = noteY + this.getDotVerticalDisplacement(staff, note.diatonicId, stemDir) * unitSize;
2571
- let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2642
+ let r = AnchoredRect9.createCentered(dotX, dotY, dotWidth, dotWidth);
2572
2643
  obj.dotRects.push(r);
2573
2644
  noteStaff.addObject(r);
2574
2645
  }
@@ -2576,27 +2647,27 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2576
2647
  if (stemDir === "up" /* Up */ && isBottomNote) {
2577
2648
  let dotX = noteX;
2578
2649
  let dotY = noteY + unitSize * (isNoteOnLine ? 3 : 2);
2579
- let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2650
+ let r = AnchoredRect9.createCentered(dotX, dotY, dotWidth, dotWidth);
2580
2651
  obj.dotRects.push(r);
2581
2652
  stemBaseStaff.addObject(r);
2582
2653
  } else if (stemDir === "down" /* Down */ && isTopNote) {
2583
2654
  let dotX = noteX;
2584
2655
  let dotY = noteY - unitSize * (isNoteOnLine ? 3 : 2);
2585
- let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2656
+ let r = AnchoredRect9.createCentered(dotX, dotY, dotWidth, dotWidth);
2586
2657
  obj.dotRects.push(r);
2587
2658
  stemBaseStaff.addObject(r);
2588
2659
  }
2589
2660
  }
2590
2661
  });
2591
- let bottomNoteY = obj.noteHeadRects[0].centerY;
2592
- let topNoteY = obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY;
2662
+ let bottomNoteY = obj.noteHeadRects[0].anchorY;
2663
+ let topNoteY = obj.noteHeadRects[obj.noteHeadRects.length - 1].anchorY;
2593
2664
  let stemX = stemDir === "up" /* Up */ ? noteHeadWidth / 2 : -noteHeadWidth / 2;
2594
2665
  let stemHeight = this.getStemHeight(ctx);
2595
2666
  let stemTipY = stemDir === "up" /* Up */ ? topNoteY - stemHeight : bottomNoteY + stemHeight;
2596
2667
  let stemBaseY = stemDir === "up" /* Up */ ? bottomNoteY : topNoteY;
2597
2668
  if (hasStem) {
2598
- obj.stemTip = new DivRect(stemX, stemX, stemTipY, stemTipY);
2599
- obj.stemBase = new DivRect(stemX, stemX, stemBaseY, stemBaseY);
2669
+ obj.stemTip = new AnchoredRect9(stemX, stemX, stemTipY, stemTipY);
2670
+ obj.stemBase = new AnchoredRect9(stemX, stemX, stemBaseY, stemBaseY);
2600
2671
  stemTipStaff.addObject(obj.stemTip);
2601
2672
  stemBaseStaff.addObject(obj.stemBase);
2602
2673
  }
@@ -2605,11 +2676,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2605
2676
  let flagHeight = flagCount === 0 ? 0 : DocumentSettings.FlagHeight * unitSize;
2606
2677
  for (let i = 0; i < flagCount; i++) {
2607
2678
  let flagAddY = i * unitSize * DocumentSettings.FlagSeparation;
2608
- 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);
2679
+ let r = obj.flagRects[i] = stemDir === "up" /* Up */ ? new AnchoredRect9(stemX, stemX + flagWidth, stemTipY + flagAddY, stemTipY + flagHeight + flagAddY) : new AnchoredRect9(stemX, stemX + flagWidth, stemTipY - flagHeight - flagAddY, stemTipY - flagAddY);
2609
2680
  stemTipStaff.addObject(r);
2610
2681
  }
2611
2682
  }
2612
2683
  this.staffObjects.push(obj);
2684
+ this.measure.addStaticObject(staff, obj);
2613
2685
  });
2614
2686
  this.tabObjects.length = 0;
2615
2687
  row.getTabs().forEach((tab) => {
@@ -2619,12 +2691,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2619
2691
  let obj = new ObjTabNoteGroup(tab, this);
2620
2692
  this.notes.forEach((note, noteIndex) => {
2621
2693
  let stringNumber = this.runningStringNumbers[noteIndex];
2622
- if (Utils3.Is.isIntegerBetween(stringNumber, 1, 6)) {
2694
+ if (Guard2.isIntegerBetween(stringNumber, 1, 6)) {
2623
2695
  let fretId = note.chromaticId - tab.getTuningStrings()[stringNumber - 1].chromaticId;
2624
2696
  let color = fretId < 0 ? "red" : "black";
2625
2697
  let fretNumber = new ObjText(this, { text: String(fretId), color, bgcolor: "white" }, 0.5, 0.5);
2626
2698
  fretNumber.layout(ctx);
2627
- let x = this.col.getRect().centerX;
2699
+ let x = this.col.getRect().anchorX;
2628
2700
  let y = tab.getStringY(stringNumber - 1);
2629
2701
  fretNumber.offset(x, y);
2630
2702
  obj.fretNumbers.push(fretNumber);
@@ -2633,16 +2705,17 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2633
2705
  if (obj.fretNumbers.length > 0) {
2634
2706
  this.tabObjects.push(obj);
2635
2707
  tab.addObject(obj);
2708
+ this.measure.addStaticObject(tab, obj);
2636
2709
  }
2637
2710
  });
2638
2711
  }
2639
2712
  updateRect() {
2640
2713
  if (this.staffObjects.length > 0) {
2641
- this.rect = this.staffObjects[0].noteHeadRects[0].copy();
2714
+ this.rect = this.staffObjects[0].noteHeadRects[0].clone();
2642
2715
  } else if (this.tabObjects.length > 0 && this.tabObjects[0].fretNumbers.length > 0) {
2643
- this.rect = this.tabObjects[0].fretNumbers[0].getRect().copy();
2716
+ this.rect = this.tabObjects[0].fretNumbers[0].getRect().clone();
2644
2717
  } else {
2645
- this.rect = new DivRect();
2718
+ this.rect = new AnchoredRect9();
2646
2719
  return;
2647
2720
  }
2648
2721
  this.staffObjects.forEach((obj) => this.rect.expandInPlace(obj.getRect()));
@@ -2650,9 +2723,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2650
2723
  }
2651
2724
  setStemTipY(staff, stemTipY) {
2652
2725
  let obj = this.staffObjects.find((obj2) => obj2.staff === staff);
2653
- if (this.hasBeamCount() && (obj == null ? void 0 : obj.stemTip) && stemTipY !== obj.stemTip.centerY) {
2654
- obj.stemTip.top = obj.stemTip.centerY = obj.stemTip.bottom = stemTipY;
2726
+ if (this.hasBeamCount() && (obj == null ? void 0 : obj.stemTip) && stemTipY !== obj.stemTip.anchorY) {
2727
+ obj.stemTip.top = obj.stemTip.anchorY = obj.stemTip.bottom = stemTipY;
2655
2728
  this.requestRectUpdate();
2729
+ this.col.requestRectUpdate();
2656
2730
  }
2657
2731
  }
2658
2732
  offset(dx, dy) {
@@ -2672,31 +2746,31 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2672
2746
  if (this.diamond) {
2673
2747
  if (isSolidNoteHead) {
2674
2748
  ctx.beginPath();
2675
- ctx.moveTo(r.centerX, r.top);
2676
- ctx.lineTo(r.right, r.centerY);
2677
- ctx.lineTo(r.centerX, r.bottom);
2678
- ctx.lineTo(r.left, r.centerY);
2679
- ctx.lineTo(r.centerX, r.top);
2749
+ ctx.moveTo(r.anchorX, r.top);
2750
+ ctx.lineTo(r.right, r.anchorY);
2751
+ ctx.lineTo(r.anchorX, r.bottom);
2752
+ ctx.lineTo(r.left, r.anchorY);
2753
+ ctx.lineTo(r.anchorX, r.top);
2680
2754
  ctx.fill();
2681
2755
  } else {
2682
2756
  ctx.beginPath();
2683
2757
  ctx.lineWidth(2.5);
2684
- ctx.moveTo(r.centerX, r.top);
2685
- ctx.lineTo(r.right, r.centerY);
2686
- ctx.moveTo(r.left, r.centerY);
2687
- ctx.lineTo(r.centerX, r.bottom);
2758
+ ctx.moveTo(r.anchorX, r.top);
2759
+ ctx.lineTo(r.right, r.anchorY);
2760
+ ctx.moveTo(r.left, r.anchorY);
2761
+ ctx.lineTo(r.anchorX, r.bottom);
2688
2762
  ctx.stroke();
2689
2763
  ctx.beginPath();
2690
2764
  ctx.lineWidth(1);
2691
- ctx.moveTo(r.right, r.centerY);
2692
- ctx.lineTo(r.centerX, r.bottom);
2693
- ctx.moveTo(r.centerX, r.top);
2694
- ctx.lineTo(r.left, r.centerY);
2765
+ ctx.moveTo(r.right, r.anchorY);
2766
+ ctx.lineTo(r.anchorX, r.bottom);
2767
+ ctx.moveTo(r.anchorX, r.top);
2768
+ ctx.lineTo(r.left, r.anchorY);
2695
2769
  ctx.stroke();
2696
2770
  }
2697
2771
  } else {
2698
2772
  ctx.beginPath();
2699
- ctx.ellipse(r.centerX, r.centerY, r.leftw, r.toph, -0.3, 0, Math.PI * 2);
2773
+ ctx.ellipse(r.anchorX, r.anchorY, r.leftw, r.toph, -0.3, 0, Math.PI * 2);
2700
2774
  if (isSolidNoteHead) {
2701
2775
  ctx.fill();
2702
2776
  } else {
@@ -2704,11 +2778,11 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2704
2778
  }
2705
2779
  }
2706
2780
  });
2707
- obj.dotRects.forEach((r) => ctx.fillCircle(r.centerX, r.centerY, r.width / 2));
2781
+ obj.dotRects.forEach((r) => ctx.fillCircle(r.anchorX, r.anchorY, r.width / 2));
2708
2782
  if (obj.stemTip && obj.stemBase) {
2709
2783
  ctx.beginPath();
2710
- ctx.moveTo(obj.stemBase.centerX, obj.stemBase.centerY);
2711
- ctx.lineTo(obj.stemTip.centerX, obj.stemTip.centerY);
2784
+ ctx.moveTo(obj.stemBase.anchorX, obj.stemBase.anchorY);
2785
+ ctx.lineTo(obj.stemTip.anchorX, obj.stemTip.anchorY);
2712
2786
  ctx.stroke();
2713
2787
  }
2714
2788
  obj.flagRects.forEach((rect) => ctx.drawFlag(rect, stemDir === "up" /* Up */ ? "up" : "down"));
@@ -2739,28 +2813,20 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2739
2813
 
2740
2814
  // src/score/engine/obj-rhythm-column.ts
2741
2815
  import { MusicError as MusicError7, MusicErrorType as MusicErrorType7 } from "@tspro/web-music-score/core";
2742
- import { Map3 } from "@tspro/ts-utils-lib";
2743
- var noteHeadDataCompareFunc = (a, b) => {
2744
- let cmp = Note5.compareFunc(a.note, b.note);
2745
- if (cmp === 0) {
2746
- cmp = a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === "up" /* Up */ ? 1 : -1;
2747
- }
2748
- return cmp;
2749
- };
2816
+ import { IndexArray, UniMap as UniMap2, TriMap, AnchoredRect as AnchoredRect10 } from "@tspro/ts-utils-lib";
2750
2817
  var ObjRhythmColumn = class extends MusicObject {
2751
2818
  constructor(measure, positionTicks) {
2752
2819
  super(measure);
2753
2820
  this.measure = measure;
2754
2821
  this.positionTicks = positionTicks;
2755
- __publicField(this, "voiceSymbol", []);
2756
- __publicField(this, "lyricsObject", new Map3());
2822
+ __publicField(this, "voiceSymbol", new IndexArray());
2823
+ __publicField(this, "lyricsObject", new TriMap());
2757
2824
  __publicField(this, "minDiatonicId");
2758
2825
  __publicField(this, "maxDiatonicId");
2759
- __publicField(this, "staffMinDiatonicId", /* @__PURE__ */ new Map());
2760
- __publicField(this, "staffMaxDiatonicId", /* @__PURE__ */ new Map());
2826
+ __publicField(this, "staffMinDiatonicId", new UniMap2());
2827
+ __publicField(this, "staffMaxDiatonicId", new UniMap2());
2761
2828
  __publicField(this, "arpeggioDir");
2762
2829
  __publicField(this, "arpeggios", []);
2763
- __publicField(this, "noteHeadDisplacements", []);
2764
2830
  __publicField(this, "playerProps");
2765
2831
  __publicField(this, "needLayout", true);
2766
2832
  __publicField(this, "shapeRects", []);
@@ -2810,22 +2876,6 @@ var ObjRhythmColumn = class extends MusicObject {
2810
2876
  this.getRect();
2811
2877
  return this.shapeRects;
2812
2878
  }
2813
- getStaticObjects(line) {
2814
- let staticObjects = [];
2815
- this.voiceSymbol.forEach((symbol) => {
2816
- if (symbol) {
2817
- symbol.getRect();
2818
- symbol.getStaticObjects(line).forEach((obj) => staticObjects.push(obj));
2819
- }
2820
- });
2821
- this.arpeggios.forEach((arpeggio) => {
2822
- if (arpeggio.line === line) {
2823
- arpeggio.getRect();
2824
- staticObjects.push(arpeggio);
2825
- }
2826
- });
2827
- return staticObjects;
2828
- }
2829
2879
  get doc() {
2830
2880
  return this.measure.doc;
2831
2881
  }
@@ -2833,12 +2883,22 @@ var ObjRhythmColumn = class extends MusicObject {
2833
2883
  return this.measure.row;
2834
2884
  }
2835
2885
  pick(x, y) {
2836
- if (!this.getRect().contains(x, y)) {
2837
- return [];
2886
+ const thisContainsXY = this.getRect().contains(x, y);
2887
+ for (let i = 0; i < this.voiceSymbol.length; i++) {
2888
+ let sym = this.voiceSymbol.get(i);
2889
+ if (sym instanceof ObjRest) {
2890
+ let arr = sym.pick(x, y);
2891
+ if (arr.length > 0) {
2892
+ return thisContainsXY ? [this, ...arr] : arr;
2893
+ }
2894
+ }
2838
2895
  }
2896
+ if (!thisContainsXY)
2897
+ return [];
2839
2898
  for (let i = 0; i < this.voiceSymbol.length; i++) {
2840
- if (this.voiceSymbol[i]) {
2841
- let arr = this.voiceSymbol[i].pick(x, y);
2899
+ let sym = this.voiceSymbol.get(i);
2900
+ if (sym instanceof ObjNoteGroup) {
2901
+ let arr = sym.pick(x, y);
2842
2902
  if (arr.length > 0) {
2843
2903
  return [this, ...arr];
2844
2904
  }
@@ -2861,7 +2921,7 @@ var ObjRhythmColumn = class extends MusicObject {
2861
2921
  }
2862
2922
  setVoiceSymbol(voiceId, symbol) {
2863
2923
  validateVoiceId(voiceId);
2864
- this.voiceSymbol[voiceId] = symbol;
2924
+ this.voiceSymbol.set(voiceId, symbol);
2865
2925
  if (symbol instanceof ObjRest && !symbol.hide) {
2866
2926
  this.row.getStaves().forEach((staff) => {
2867
2927
  let diatonicId = symbol.getDiatonicId(staff);
@@ -2874,13 +2934,13 @@ var ObjRhythmColumn = class extends MusicObject {
2874
2934
  if (symbol.arpeggio !== void 0) {
2875
2935
  this.arpeggioDir = symbol.arpeggio;
2876
2936
  }
2877
- this.setupNoteHeadDisplacements();
2937
+ this.updateNoteDisplacements();
2878
2938
  }
2879
2939
  this.requestLayout();
2880
2940
  this.requestRectUpdate();
2881
2941
  }
2882
2942
  getVoiceSymbol(voiceId) {
2883
- return this.voiceSymbol[voiceId];
2943
+ return this.voiceSymbol.get(voiceId);
2884
2944
  }
2885
2945
  getLyricsObject(verse, line, vpos) {
2886
2946
  return this.lyricsObject.get(verse, line, vpos);
@@ -2889,7 +2949,7 @@ var ObjRhythmColumn = class extends MusicObject {
2889
2949
  this.lyricsObject.set(lyricsObj.verse, lyricsObj.line, lyricsObj.vpos, lyricsObj);
2890
2950
  }
2891
2951
  getMinWidth() {
2892
- let maxNoteSize = Math.max(...this.voiceSymbol.map((s) => s.rhythmProps.noteSize));
2952
+ let maxNoteSize = Math.max(...this.voiceSymbol.mapToArray((s) => s.rhythmProps.noteSize));
2893
2953
  let w = DocumentSettings.NoteHeadWidth;
2894
2954
  switch (maxNoteSize) {
2895
2955
  case 1:
@@ -2905,56 +2965,50 @@ var ObjRhythmColumn = class extends MusicObject {
2905
2965
  return w;
2906
2966
  }
2907
2967
  }
2908
- setupNoteHeadDisplacements() {
2909
- this.noteHeadDisplacements = [];
2968
+ updateNoteDisplacements() {
2969
+ let data = [];
2910
2970
  this.voiceSymbol.forEach((symbol) => {
2911
2971
  if (symbol instanceof ObjNoteGroup) {
2912
2972
  symbol.notes.forEach((note) => {
2913
- this.noteHeadDisplacements.push({ noteGroup: symbol, note });
2973
+ symbol.setNoteDisplacement(note, false);
2974
+ data.push({ noteGroup: symbol, note });
2914
2975
  });
2915
2976
  }
2916
2977
  });
2917
- this.noteHeadDisplacements.sort(noteHeadDataCompareFunc);
2918
- if (this.noteHeadDisplacements.length < 2) {
2978
+ const noteHeadDataCompareFunc = (a, b) => {
2979
+ let cmp = Note5.compareFunc(a.note, b.note);
2980
+ return cmp === 0 ? a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === "up" /* Up */ ? 1 : -1 : cmp;
2981
+ };
2982
+ data.sort(noteHeadDataCompareFunc);
2983
+ if (data.length < 2) {
2919
2984
  return;
2920
2985
  }
2921
- for (let i = 0; i < this.noteHeadDisplacements.length; i++) {
2922
- let cur = this.noteHeadDisplacements[i];
2923
- let next = this.noteHeadDisplacements[i + 1];
2986
+ for (let i = 0; i < data.length; i++) {
2987
+ let cur = data[i];
2988
+ let next = data[i + 1];
2924
2989
  if (next && cur.note.diatonicId === next.note.diatonicId) {
2925
- cur.displacement = next.displacement = 0;
2926
- }
2927
- }
2928
- for (let i = 0; i < this.noteHeadDisplacements.length; i++) {
2929
- let prev = this.noteHeadDisplacements[i - 1];
2930
- let cur = this.noteHeadDisplacements[i];
2931
- let next = this.noteHeadDisplacements[i + 1];
2932
- if (cur.displacement !== void 0) {
2933
- continue;
2934
- }
2935
- let d = cur.noteGroup.stemDir === "down" /* Down */ ? -1 : 1;
2936
- if (prev && cur.note.diatonicId - prev.note.diatonicId <= 1) {
2937
- cur.displacement = prev.displacement === 0 ? d : 0;
2938
- } else if (next && next.note.diatonicId - cur.note.diatonicId <= 1) {
2939
- cur.displacement = next.displacement === 0 ? d : 0;
2990
+ cur.isDisplaced = next.isDisplaced = false;
2991
+ }
2992
+ }
2993
+ for (let i = 0; i < data.length; i++) {
2994
+ let prev = data[i - 1];
2995
+ let cur = data[i];
2996
+ let next = data[i + 1];
2997
+ if (cur.isDisplaced === void 0) {
2998
+ if (prev && cur.note.diatonicId - prev.note.diatonicId <= 1) {
2999
+ cur.isDisplaced = !prev.isDisplaced;
3000
+ } else if (next && next.note.diatonicId - cur.note.diatonicId <= 1) {
3001
+ cur.isDisplaced = !next.isDisplaced;
3002
+ }
2940
3003
  }
2941
3004
  }
2942
- }
2943
- getNoteHeadDisplacement(noteGroup, note) {
2944
- let data = this.noteHeadDisplacements.find((d) => d.noteGroup === noteGroup && Note5.equals(d.note, note));
2945
- if ((data == null ? void 0 : data.displacement) !== void 0) {
2946
- return data.displacement;
2947
- } else {
2948
- return 0;
2949
- }
3005
+ data.forEach((el) => {
3006
+ var _a;
3007
+ return el.noteGroup.setNoteDisplacement(el.note, (_a = el.isDisplaced) != null ? _a : false);
3008
+ });
2950
3009
  }
2951
3010
  isEmpty() {
2952
- for (let i = 0; i < this.voiceSymbol.length; i++) {
2953
- if (this.voiceSymbol[i] !== void 0 && !this.voiceSymbol[i].isEmpty()) {
2954
- return false;
2955
- }
2956
- }
2957
- return true;
3011
+ return this.voiceSymbol.size === 0 || this.voiceSymbol.every((symbol) => symbol.isEmpty());
2958
3012
  }
2959
3013
  getPlayerNotes() {
2960
3014
  let playerNotes = [];
@@ -3002,7 +3056,7 @@ var ObjRhythmColumn = class extends MusicObject {
3002
3056
  return;
3003
3057
  }
3004
3058
  this.requestRectUpdate();
3005
- this.rect = new DivRect();
3059
+ this.rect = new AnchoredRect10();
3006
3060
  let { row } = this;
3007
3061
  let { unitSize } = ctx;
3008
3062
  let halfMinWidth = this.getMinWidth() * unitSize / 2;
@@ -3019,9 +3073,10 @@ var ObjRhythmColumn = class extends MusicObject {
3019
3073
  this.arpeggios = row.getNotationLines().map((line) => {
3020
3074
  let arpeggio = new ObjArpeggio(this, line, this.getArpeggioDir());
3021
3075
  arpeggio.layout(ctx);
3022
- arpeggio.offset(-leftw - arpeggio.getRect().right, line.getRect().centerY - arpeggio.getRect().centerY);
3076
+ arpeggio.offset(-leftw - arpeggio.getRect().right, line.getRect().anchorY - arpeggio.getRect().anchorY);
3023
3077
  arpeggioWidth = Math.max(arpeggioWidth, arpeggio.getRect().width);
3024
3078
  line.addObject(arpeggio);
3079
+ this.measure.addStaticObject(line, arpeggio);
3025
3080
  return arpeggio;
3026
3081
  });
3027
3082
  leftw += arpeggioWidth;
@@ -3037,7 +3092,7 @@ var ObjRhythmColumn = class extends MusicObject {
3037
3092
  }
3038
3093
  this.voiceSymbol.forEach((symbol) => symbol.updateAccidentalState(accState));
3039
3094
  this.rect.left = -leftw;
3040
- this.rect.centerX = 0;
3095
+ this.rect.anchorX = 0;
3041
3096
  this.rect.right = rightw;
3042
3097
  this.row.getStaves().forEach((staff) => {
3043
3098
  let minDiatonicId = void 0;
@@ -3071,15 +3126,15 @@ var ObjRhythmColumn = class extends MusicObject {
3071
3126
  }
3072
3127
  updateRect() {
3073
3128
  this.shapeRects = [
3074
- ...this.voiceSymbol.filter((s) => !!s).map((s) => s.getRect().copy()),
3075
- ...this.arpeggios.map((a) => a.getRect().copy())
3129
+ ...this.voiceSymbol.filter((s) => !!s).mapToArray((s) => s.getRect().clone()),
3130
+ ...this.arpeggios.map((a) => a.getRect().clone())
3076
3131
  ];
3077
3132
  this.rect.top = Math.min(...this.shapeRects.map((r) => r.top));
3078
3133
  this.rect.bottom = Math.max(...this.shapeRects.map((r) => r.bottom));
3079
- this.rect.centerY = (this.rect.top + this.rect.bottom) / 2;
3134
+ this.rect.anchorY = (this.rect.top + this.rect.bottom) / 2;
3080
3135
  }
3081
3136
  offset(dx, dy) {
3082
- this.voiceSymbol.forEach((symbol) => symbol == null ? void 0 : symbol.offset(dx, 0));
3137
+ this.voiceSymbol.forEach((symbol) => symbol.offset(dx, 0));
3083
3138
  this.arpeggios.forEach((arpeggio) => arpeggio.offset(dx, 0));
3084
3139
  this.shapeRects.forEach((r) => r.offsetInPlace(dx, dy));
3085
3140
  this.rect.offsetInPlace(dx, dy);
@@ -3089,17 +3144,13 @@ var ObjRhythmColumn = class extends MusicObject {
3089
3144
  let minDiatonicId = this.staffMinDiatonicId.get(staff);
3090
3145
  let maxDiatonicId = this.staffMaxDiatonicId.get(staff);
3091
3146
  if (minDiatonicId !== void 0) {
3092
- ctx.drawLedgerLines(staff, minDiatonicId, this.getRect().centerX);
3147
+ ctx.drawLedgerLines(staff, minDiatonicId, this.getRect().anchorX);
3093
3148
  }
3094
3149
  if (maxDiatonicId !== void 0) {
3095
- ctx.drawLedgerLines(staff, maxDiatonicId, this.getRect().centerX);
3096
- }
3097
- });
3098
- this.voiceSymbol.forEach((symbol) => {
3099
- if (symbol) {
3100
- symbol.draw(ctx);
3150
+ ctx.drawLedgerLines(staff, maxDiatonicId, this.getRect().anchorX);
3101
3151
  }
3102
3152
  });
3153
+ this.voiceSymbol.forEach((symbol) => symbol.draw(ctx));
3103
3154
  this.arpeggios.forEach((arpeggio) => arpeggio.draw(ctx));
3104
3155
  }
3105
3156
  };
@@ -3108,9 +3159,10 @@ var ObjRhythmColumn = class extends MusicObject {
3108
3159
  import { MusicError as MusicError8, MusicErrorType as MusicErrorType8 } from "@tspro/web-music-score/core";
3109
3160
 
3110
3161
  // src/score/engine/element-data.ts
3111
- import { Utils as Utils4 } from "@tspro/ts-utils-lib";
3162
+ import { Guard as Guard3, Utils as Utils4 } from "@tspro/ts-utils-lib";
3112
3163
 
3113
3164
  // src/score/engine/obj-special-text.ts
3165
+ import { AnchoredRect as AnchoredRect11 } from "@tspro/ts-utils-lib";
3114
3166
  var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3115
3167
  constructor(parent, text) {
3116
3168
  super(parent);
@@ -3155,14 +3207,14 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3155
3207
  let codaText = this.components[1];
3156
3208
  codaSym.layout(ctx);
3157
3209
  codaText.layout(ctx);
3158
- codaSym.offset(0, (codaText.getRect().top + codaText.getRect().bottom) / 2);
3210
+ codaSym.offset(0, codaText.getRect().centerY);
3159
3211
  codaText.offset(codaSym.getRect().right, 0);
3160
- this.rect = new DivRect(
3212
+ this.rect = new AnchoredRect11(
3161
3213
  codaSym.getRect().left,
3162
- codaSym.getRect().centerX,
3214
+ codaSym.getRect().anchorX,
3163
3215
  codaText.getRect().right,
3164
3216
  codaText.getRect().top,
3165
- codaText.getRect().centerY,
3217
+ codaText.getRect().anchorY,
3166
3218
  codaText.getRect().bottom
3167
3219
  );
3168
3220
  break;
@@ -3172,14 +3224,14 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3172
3224
  let codaSym = this.components[1];
3173
3225
  toCodaText.layout(ctx);
3174
3226
  codaSym.layout(ctx);
3175
- codaSym.offset(0, (toCodaText.getRect().top + toCodaText.getRect().bottom) / 2);
3227
+ codaSym.offset(0, toCodaText.getRect().centerY);
3176
3228
  toCodaText.offset(codaSym.getRect().left, 0);
3177
- this.rect = new DivRect(
3229
+ this.rect = new AnchoredRect11(
3178
3230
  toCodaText.getRect().left,
3179
- codaSym.getRect().centerX,
3231
+ codaSym.getRect().anchorX,
3180
3232
  codaSym.getRect().right,
3181
3233
  toCodaText.getRect().top,
3182
- toCodaText.getRect().centerY,
3234
+ toCodaText.getRect().anchorY,
3183
3235
  toCodaText.getRect().bottom
3184
3236
  );
3185
3237
  break;
@@ -3187,7 +3239,7 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3187
3239
  default: {
3188
3240
  let text = this.components[0];
3189
3241
  text.layout(ctx);
3190
- this.rect = text.getRect().copy();
3242
+ this.rect = text.getRect().clone();
3191
3243
  break;
3192
3244
  }
3193
3245
  }
@@ -3230,7 +3282,7 @@ function getNavigationString(navigation) {
3230
3282
  }
3231
3283
  }
3232
3284
  function isDynamicsText(text) {
3233
- return Utils4.Is.isEnumValue(text, DynamicsAnnotation);
3285
+ return Guard3.isEnumValue(text, DynamicsAnnotation);
3234
3286
  }
3235
3287
  function getDynamicsVolume(text) {
3236
3288
  if (/^(p+|f+|m|mp|mf)$/.test(text)) {
@@ -3241,12 +3293,12 @@ function getDynamicsVolume(text) {
3241
3293
  }
3242
3294
  }
3243
3295
  function isTempoText(text) {
3244
- return Utils4.Is.isEnumValue(text, TempoAnnotation);
3296
+ return Guard3.isEnumValue(text, TempoAnnotation);
3245
3297
  }
3246
3298
  function getAnnotation(text) {
3247
- if (Utils4.Is.isEnumValue(text, DynamicsAnnotation)) {
3299
+ if (Guard3.isEnumValue(text, DynamicsAnnotation)) {
3248
3300
  return "dynamics" /* Dynamics */;
3249
- } else if (Utils4.Is.isEnumValue(text, TempoAnnotation)) {
3301
+ } else if (Guard3.isEnumValue(text, TempoAnnotation)) {
3250
3302
  return "tempo" /* Tempo */;
3251
3303
  } else {
3252
3304
  return void 0;
@@ -3550,24 +3602,17 @@ var Player = class _Player {
3550
3602
  }
3551
3603
  let curSpeed = 1;
3552
3604
  let curVolume = getDefaultVolume();
3553
- let speedMap = /* @__PURE__ */ new Map();
3554
- let volumeMap = /* @__PURE__ */ new Map();
3555
- const pushSpeed = (col, speed) => {
3556
- var _a;
3557
- return speedMap.set(col, [...(_a = speedMap.get(col)) != null ? _a : [], speed]);
3558
- };
3559
- const pushVolume = (col, volume) => {
3560
- var _a;
3561
- return volumeMap.set(col, [...(_a = volumeMap.get(col)) != null ? _a : [], volume]);
3562
- };
3605
+ let speedMap = new UniMap3();
3606
+ let volumeMap = new UniMap3();
3607
+ const pushSpeed = (col, speed) => speedMap.getOrCreate(col, []).push(speed);
3608
+ const pushVolume = (col, volume) => volumeMap.getOrCreate(col, []).push(volume);
3563
3609
  this.playerColumnSequence.forEach((col) => {
3564
- var _a, _b;
3565
3610
  if (!(col instanceof ObjRhythmColumn)) {
3566
3611
  return;
3567
3612
  }
3568
3613
  col.getAnchoredLayoutObjects().forEach((layoutObj) => {
3569
- var _a2;
3570
- let text = (_a2 = layoutObj.getTextContent()) != null ? _a2 : "";
3614
+ var _a;
3615
+ let text = (_a = layoutObj.getTextContent()) != null ? _a : "";
3571
3616
  let vol;
3572
3617
  if (text === "a tempo" /* a_tempo */) {
3573
3618
  curSpeed = 1;
@@ -3628,11 +3673,11 @@ var Player = class _Player {
3628
3673
  }
3629
3674
  }
3630
3675
  });
3631
- let speedArr = (_a = speedMap.get(col)) != null ? _a : [];
3676
+ let speedArr = speedMap.getOrDefault(col, []);
3632
3677
  if (speedArr.length > 0) {
3633
3678
  curSpeed = Utils5.Math.sum(speedArr) / speedArr.length;
3634
3679
  }
3635
- let volumeArr = (_b = volumeMap.get(col)) != null ? _b : [];
3680
+ let volumeArr = volumeMap.getOrDefault(col, []);
3636
3681
  if (volumeArr.length > 0) {
3637
3682
  curVolume = Utils5.Math.sum(volumeArr) / volumeArr.length;
3638
3683
  }
@@ -3752,14 +3797,14 @@ var Player = class _Player {
3752
3797
  return void 0;
3753
3798
  }
3754
3799
  let measure = col.measure;
3755
- let x = col.getRect().centerX;
3756
- let top = measure.row.getRect().top;
3757
- let bottom = measure.row.getRect().bottom;
3758
- return new DivRect(x, x, top, bottom);
3800
+ let x = col.getRect().anchorX;
3801
+ let { top, height } = measure.row.getRect();
3802
+ return new Rect2(x, top, 0, height);
3759
3803
  }
3760
3804
  };
3761
3805
 
3762
3806
  // src/score/engine/obj-bar-line.ts
3807
+ import { AnchoredRect as AnchoredRect13 } from "@tspro/ts-utils-lib";
3763
3808
  var ObjStaffTabBarLine = class extends MusicObject {
3764
3809
  constructor(barLine, line) {
3765
3810
  super(line);
@@ -3846,36 +3891,36 @@ var ObjBarLine = class extends MusicObject {
3846
3891
  bottom = line.getBottomLineY();
3847
3892
  switch (barLineType) {
3848
3893
  case 0 /* None */:
3849
- obj.setRect(new DivRect(0, 0, 0, top, 0, bottom));
3894
+ obj.setRect(new AnchoredRect13(0, 0, 0, top, 0, bottom));
3850
3895
  break;
3851
3896
  case 1 /* Single */:
3852
- obj.setRect(new DivRect(-thinW, 0, 0, top, 0, bottom));
3897
+ obj.setRect(new AnchoredRect13(-thinW, 0, 0, top, 0, bottom));
3853
3898
  addVerticalLine(-thinW, thinW);
3854
3899
  break;
3855
3900
  case 2 /* Double */:
3856
- obj.setRect(new DivRect(-thinW - spaceW - thinW, 0, 0, top, 0, bottom));
3901
+ obj.setRect(new AnchoredRect13(-thinW - spaceW - thinW, 0, 0, top, 0, bottom));
3857
3902
  addVerticalLine(-thinW - spaceW - thinW, thinW);
3858
3903
  addVerticalLine(-thinW, thinW);
3859
3904
  break;
3860
3905
  case 3 /* EndSong */:
3861
- obj.setRect(new DivRect(-thicW - spaceW - thinW, 0, 0, top, 0, bottom));
3906
+ obj.setRect(new AnchoredRect13(-thicW - spaceW - thinW, 0, 0, top, 0, bottom));
3862
3907
  addVerticalLine(-thinW - spaceW - thicW, thinW);
3863
3908
  addVerticalLine(-thicW, thicW);
3864
3909
  break;
3865
3910
  case 4 /* StartRepeat */:
3866
- obj.setRect(new DivRect(0, 0, thicW + spaceW + thinW + spaceW + dotW, top, 0, bottom));
3911
+ obj.setRect(new AnchoredRect13(0, 0, thicW + spaceW + thinW + spaceW + dotW, top, 0, bottom));
3867
3912
  addVerticalLine(0, thicW);
3868
3913
  addVerticalLine(thicW + spaceW, thinW);
3869
3914
  addDotPair(thicW + spaceW + thinW + spaceW + dotRadius);
3870
3915
  break;
3871
3916
  case 5 /* EndRepeat */:
3872
- obj.setRect(new DivRect(-thicW - spaceW - thinW - spaceW - dotW, 0, 0, top, 0, bottom));
3917
+ obj.setRect(new AnchoredRect13(-thicW - spaceW - thinW - spaceW - dotW, 0, 0, top, 0, bottom));
3873
3918
  addVerticalLine(-thinW - spaceW - thicW, thinW);
3874
3919
  addVerticalLine(-thicW, thicW);
3875
3920
  addDotPair(-thinW - spaceW - thicW - spaceW - dotRadius);
3876
3921
  break;
3877
3922
  case 6 /* EndStartRepeat */:
3878
- obj.setRect(new DivRect(-dotW - spaceW - thinW - spaceW - thicW / 2, 0, thicW / 2 + spaceW + thinW + spaceW + dotW, top, 0, bottom));
3923
+ obj.setRect(new AnchoredRect13(-dotW - spaceW - thinW - spaceW - thicW / 2, 0, thicW / 2 + spaceW + thinW + spaceW + dotW, top, 0, bottom));
3879
3924
  addVerticalLine(-thicW / 2, thicW);
3880
3925
  addVerticalLine(-thicW / 2 - spaceW - thinW, thinW);
3881
3926
  addVerticalLine(thicW / 2 + spaceW, thinW);
@@ -3891,12 +3936,12 @@ var ObjBarLine = class extends MusicObject {
3891
3936
  }
3892
3937
  updateRect() {
3893
3938
  if (this.staffTabObjects.length > 0) {
3894
- this.rect = this.staffTabObjects[0].getRect().copy();
3939
+ this.rect = this.staffTabObjects[0].getRect().clone();
3895
3940
  for (let i = 1; i < this.staffTabObjects.length; i++) {
3896
3941
  this.rect.expandInPlace(this.staffTabObjects[i].getRect());
3897
3942
  }
3898
3943
  } else {
3899
- this.rect = new DivRect();
3944
+ this.rect = new AnchoredRect13();
3900
3945
  }
3901
3946
  }
3902
3947
  offset(dx, dy) {
@@ -3981,7 +4026,7 @@ var ObjBarLineRight = class extends ObjBarLine {
3981
4026
  };
3982
4027
 
3983
4028
  // src/score/engine/obj-ending.ts
3984
- import { Utils as Utils6 } from "@tspro/ts-utils-lib";
4029
+ import { AnchoredRect as AnchoredRect14, Guard as Guard4 } from "@tspro/ts-utils-lib";
3985
4030
  import { MusicError as MusicError9, MusicErrorType as MusicErrorType9 } from "@tspro/web-music-score/core";
3986
4031
  var ObjEnding = class extends MusicObject {
3987
4032
  constructor(measure, passages) {
@@ -3992,9 +4037,9 @@ var ObjEnding = class extends MusicObject {
3992
4037
  __publicField(this, "shapeRects", []);
3993
4038
  __publicField(this, "mi");
3994
4039
  this.mi = new MEnding(this);
3995
- if (!Utils6.Is.isIntegerGte(passages.length, 1)) {
4040
+ if (!Guard4.isIntegerGte(passages.length, 1)) {
3996
4041
  throw new MusicError9(MusicErrorType9.Score, "Passages is empty.");
3997
- } else if (!this.passages.every((p) => Utils6.Is.isIntegerGte(p, 1))) {
4042
+ } else if (!this.passages.every((p) => Guard4.isIntegerGte(p, 1))) {
3998
4043
  throw new MusicError9(MusicErrorType9.Score, "Invalid passages: " + this.passages);
3999
4044
  }
4000
4045
  this.passages.sort((a, b) => a - b);
@@ -4022,8 +4067,8 @@ var ObjEnding = class extends MusicObject {
4022
4067
  return this.rect.contains(x, y) ? [this] : [];
4023
4068
  }
4024
4069
  layout(ctx) {
4025
- this.rect = new DivRect();
4026
- this.shapeRects = [this.rect.copy()];
4070
+ this.rect = new AnchoredRect14();
4071
+ this.shapeRects = [this.rect.clone()];
4027
4072
  }
4028
4073
  layoutFitToMeasure(ctx) {
4029
4074
  let { unitSize } = ctx;
@@ -4032,13 +4077,13 @@ var ObjEnding = class extends MusicObject {
4032
4077
  let textRect = this.endingText.getRect();
4033
4078
  let measureContent = measure.getColumnsContentRect();
4034
4079
  let endingHeight = textRect.height;
4035
- this.rect = new DivRect(measureContent.left + unitSize, measureContent.right - unitSize, -endingHeight, 0);
4080
+ this.rect = new AnchoredRect14(measureContent.left + unitSize, measureContent.right - unitSize, -endingHeight, 0);
4036
4081
  this.endingText.offset(this.rect.left + unitSize / 2, this.rect.bottom);
4037
4082
  this.shapeRects = [
4038
- new DivRect(this.rect.left, this.rect.left + 1, this.rect.top, this.rect.bottom),
4039
- new DivRect(this.rect.left, this.rect.right, this.rect.top, this.rect.top + 1),
4040
- new DivRect(this.rect.right - 1, this.rect.right, this.rect.top, this.rect.bottom),
4041
- this.endingText.getRect().copy()
4083
+ new AnchoredRect14(this.rect.left, this.rect.left + 1, this.rect.top, this.rect.bottom),
4084
+ new AnchoredRect14(this.rect.left, this.rect.right, this.rect.top, this.rect.top + 1),
4085
+ new AnchoredRect14(this.rect.right - 1, this.rect.right, this.rect.top, this.rect.bottom),
4086
+ this.endingText.getRect().clone()
4042
4087
  ];
4043
4088
  }
4044
4089
  offset(dx, dy) {
@@ -4063,7 +4108,7 @@ var ObjEnding = class extends MusicObject {
4063
4108
  };
4064
4109
 
4065
4110
  // src/score/engine/obj-beam-group.ts
4066
- import { Utils as Utils7 } from "@tspro/ts-utils-lib";
4111
+ import { AnchoredRect as AnchoredRect15, Utils as Utils6 } from "@tspro/ts-utils-lib";
4067
4112
  import { NoteLength as NoteLength5, Tuplet as Tuplet3, NoteLengthProps as NoteLengthProps4 } from "@tspro/web-music-score/theory";
4068
4113
  import { MusicError as MusicError10, MusicErrorType as MusicErrorType10 } from "@tspro/web-music-score/core";
4069
4114
  var adjustBeamAngle = (dx, dy) => {
@@ -4093,7 +4138,7 @@ var BeamPoint = class {
4093
4138
  this.beamGroup.requestRectUpdate();
4094
4139
  }
4095
4140
  getRect() {
4096
- return new DivRect(this.x, this.x, this.x, this.y - this.topBeamsHeight, this.y, this.y + this.bottomBeamsHeight);
4141
+ return new AnchoredRect15(this.x, this.x, this.x, this.y - this.topBeamsHeight, this.y, this.y + this.bottomBeamsHeight);
4097
4142
  }
4098
4143
  };
4099
4144
  var ObjStaffBeamGroup = class extends MusicObject {
@@ -4123,9 +4168,9 @@ var ObjStaffBeamGroup = class extends MusicObject {
4123
4168
  }
4124
4169
  updateRect() {
4125
4170
  if (this.points.length > 0) {
4126
- this.rect = this.points[0].getRect().copy();
4171
+ this.rect = this.points[0].getRect().clone();
4127
4172
  } else if (this.tupletNumber) {
4128
- this.rect = this.tupletNumber.getRect().copy();
4173
+ this.rect = this.tupletNumber.getRect().clone();
4129
4174
  }
4130
4175
  this.points.forEach((pt) => this.rect.expandInPlace(pt.getRect()));
4131
4176
  if (this.tupletNumber) {
@@ -4371,7 +4416,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4371
4416
  symbolY.forEach((symY, i) => {
4372
4417
  let symX = symbolX[i];
4373
4418
  if (symX !== void 0 && symY !== void 0) {
4374
- let beamY = Utils7.Math.interpolateY(leftX, leftY, rightX, rightY, symX);
4419
+ let beamY = Utils6.Math.interpolateY(leftX, leftY, rightX, rightY, symX);
4375
4420
  let raiseY = symY - beamY;
4376
4421
  if (stemDir === "up" /* Up */ && raiseY < 0) {
4377
4422
  raiseBeamY = Math.min(raiseBeamY, raiseY);
@@ -4386,8 +4431,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4386
4431
  let obj = new ObjStaffBeamGroup(mainStaff, this);
4387
4432
  if (type === 2 /* TupletGroup */) {
4388
4433
  let ef = unitSize / (rightX - leftX);
4389
- let l = Utils7.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, -ef);
4390
- let r = Utils7.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, 1 + ef);
4434
+ let l = Utils6.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, -ef);
4435
+ let r = Utils6.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, 1 + ef);
4391
4436
  obj.points.push(new BeamPoint(leftStaff, this, leftSymbol, l.x, l.y));
4392
4437
  obj.points.push(new BeamPoint(rightStaff, this, rightSymbol, r.x, r.y));
4393
4438
  obj.tupletNumberOffsetY = 0;
@@ -4436,10 +4481,10 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4436
4481
  }
4437
4482
  updateRect() {
4438
4483
  if (this.staffObjects.length === 0) {
4439
- this.rect = new DivRect();
4484
+ this.rect = new AnchoredRect15();
4440
4485
  } else {
4441
4486
  this.staffObjects.forEach((obj) => obj.updateRect());
4442
- this.rect = this.staffObjects[0].getRect().copy();
4487
+ this.rect = this.staffObjects[0].getRect().clone();
4443
4488
  for (let i = 1; i < this.staffObjects.length; i++) {
4444
4489
  this.rect.expandInPlace(this.staffObjects[i].getRect());
4445
4490
  }
@@ -4453,7 +4498,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4453
4498
  obj.points.forEach((pt) => {
4454
4499
  if (pt.symbol instanceof ObjNoteGroup) {
4455
4500
  if (pt !== left && pt !== right) {
4456
- pt.y = Utils7.Math.interpolateY(left.x, left.y, right.x, right.y, pt.x);
4501
+ pt.y = Utils6.Math.interpolateY(left.x, left.y, right.x, right.y, pt.x);
4457
4502
  }
4458
4503
  pt.symbol.setStemTipY(pt.staff, pt.y);
4459
4504
  }
@@ -4461,7 +4506,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4461
4506
  }
4462
4507
  if (obj.tupletNumber) {
4463
4508
  let y = (left.y + right.y) / 2 + obj.tupletNumberOffsetY;
4464
- obj.tupletNumber.offset(0, -obj.tupletNumber.getRect().centerY + y);
4509
+ obj.tupletNumber.offset(0, -obj.tupletNumber.getRect().anchorY + y);
4465
4510
  }
4466
4511
  });
4467
4512
  }
@@ -4480,8 +4525,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4480
4525
  let { x: rx, y: ry } = obj.points[obj.points.length - 1];
4481
4526
  if (obj.tupletNumber) {
4482
4527
  let tf = obj.tupletNumber.getRect().width / (rx - lx) * 1.2;
4483
- let lc = Utils7.Math.interpolateCoord(lx, ly, rx, ry, 0.5 - tf / 2);
4484
- let rc = Utils7.Math.interpolateCoord(lx, ly, rx, ry, 0.5 + tf / 2);
4528
+ let lc = Utils6.Math.interpolateCoord(lx, ly, rx, ry, 0.5 - tf / 2);
4529
+ let rc = Utils6.Math.interpolateCoord(lx, ly, rx, ry, 0.5 + tf / 2);
4485
4530
  ctx.strokeLine(lx, ly, lc.x, lc.y);
4486
4531
  ctx.strokeLine(rc.x, rc.y, rx, ry);
4487
4532
  } else {
@@ -4595,6 +4640,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4595
4640
  };
4596
4641
 
4597
4642
  // src/score/engine/obj-fermata.ts
4643
+ import { AnchoredRect as AnchoredRect16 } from "@tspro/ts-utils-lib";
4598
4644
  var ObjFermata = class extends MusicObject {
4599
4645
  constructor(parent, pos) {
4600
4646
  super(parent);
@@ -4622,7 +4668,7 @@ var ObjFermata = class extends MusicObject {
4622
4668
  let { unitSize } = ctx;
4623
4669
  let width = unitSize * 4;
4624
4670
  let height = unitSize * 3;
4625
- this.rect = new DivRect(-width / 2, width / 2, -height, 0);
4671
+ this.rect = new AnchoredRect16(-width / 2, width / 2, -height, 0);
4626
4672
  }
4627
4673
  offset(dx, dy) {
4628
4674
  this.rect.offsetInPlace(dx, dy);
@@ -4650,6 +4696,7 @@ var ObjFermata = class extends MusicObject {
4650
4696
  };
4651
4697
 
4652
4698
  // src/score/engine/obj-extension-line.ts
4699
+ import { AnchoredRect as AnchoredRect17 } from "@tspro/ts-utils-lib";
4653
4700
  var ObjExtensionLine = class extends MusicObject {
4654
4701
  constructor(measure, line, extension, leftObj, rightObj) {
4655
4702
  super(measure);
@@ -4670,7 +4717,7 @@ var ObjExtensionLine = class extends MusicObject {
4670
4717
  }
4671
4718
  getLineLeft() {
4672
4719
  if (this.leftObj instanceof ObjBarLineLeft) {
4673
- return this.leftObj.getRect().centerX;
4720
+ return this.leftObj.getRect().anchorX;
4674
4721
  } else {
4675
4722
  return this.leftObj.getRect().right;
4676
4723
  }
@@ -4685,7 +4732,7 @@ var ObjExtensionLine = class extends MusicObject {
4685
4732
  return (col.getRect().right + col.measure.getBarLineRight().getRect().left) / 2;
4686
4733
  }
4687
4734
  } else {
4688
- return this.rightObj.getRect().centerX;
4735
+ return this.rightObj.getRect().anchorX;
4689
4736
  }
4690
4737
  }
4691
4738
  layoutFitToMeasure(ctx) {
@@ -4693,13 +4740,13 @@ var ObjExtensionLine = class extends MusicObject {
4693
4740
  let lineLeft = this.getLineLeft();
4694
4741
  let lineRight = this.getLineRight();
4695
4742
  let lineRectH = unitSize;
4696
- this.rect = new DivRect(lineLeft, lineRight, -lineRectH / 2, lineRectH / 2);
4743
+ this.rect = new AnchoredRect17(lineLeft, lineRight, -lineRectH / 2, lineRectH / 2);
4697
4744
  }
4698
4745
  pick(x, y) {
4699
4746
  return this.rect.contains(x, y) ? [this] : [];
4700
4747
  }
4701
4748
  layout(ctx) {
4702
- this.rect = new DivRect();
4749
+ this.rect = new AnchoredRect17();
4703
4750
  }
4704
4751
  offset(dx, dy) {
4705
4752
  this.rect.offsetInPlace(dx, dy);
@@ -4710,12 +4757,12 @@ var ObjExtensionLine = class extends MusicObject {
4710
4757
  ctx.setLineDash([7, 3]);
4711
4758
  }
4712
4759
  ctx.color("black").lineWidth(1);
4713
- ctx.strokeLine(rect.left, rect.centerY, rect.right, rect.centerY);
4760
+ ctx.strokeLine(rect.left, rect.anchorY, rect.right, rect.anchorY);
4714
4761
  ctx.setLineDash([]);
4715
4762
  let tails = this.extension.getTails();
4716
4763
  if (tails.length > 0 && this === tails[tails.length - 1]) {
4717
- let tipH = rect.centerY > this.line.getRect().centerY ? -ctx.unitSize : ctx.unitSize;
4718
- ctx.strokeLine(rect.right, rect.centerY, rect.right, rect.centerY + tipH);
4764
+ let tipH = rect.anchorY > this.line.getRect().anchorY ? -ctx.unitSize : ctx.unitSize;
4765
+ ctx.strokeLine(rect.right, rect.anchorY, rect.right, rect.anchorY + tipH);
4719
4766
  }
4720
4767
  }
4721
4768
  };
@@ -4727,7 +4774,7 @@ import { MusicError as MusicError13, MusicErrorType as MusicErrorType13 } from "
4727
4774
  import { Note as Note6 } from "@tspro/web-music-score/theory";
4728
4775
 
4729
4776
  // src/score/engine/obj-connective.ts
4730
- import { Utils as Utils8 } from "@tspro/ts-utils-lib";
4777
+ import { AnchoredRect as AnchoredRect18, Guard as Guard5, Utils as Utils7 } from "@tspro/ts-utils-lib";
4731
4778
  import { MusicError as MusicError11, MusicErrorType as MusicErrorType11 } from "@tspro/web-music-score/core";
4732
4779
  var ObjConnective = class extends MusicObject {
4733
4780
  constructor(connectiveProps, line, measure, leftNoteGroup, leftNoteId, ...args) {
@@ -4758,7 +4805,7 @@ var ObjConnective = class extends MusicObject {
4758
4805
  this.rightNoteGroup = args[0];
4759
4806
  this.rightNoteId = args[1];
4760
4807
  this.tieType = void 0;
4761
- } else if (Utils8.Is.isEnumValue(args[0], TieType)) {
4808
+ } else if (Guard5.isEnumValue(args[0], TieType)) {
4762
4809
  this.rightNoteGroup = void 0;
4763
4810
  this.rightNoteId = void 0;
4764
4811
  this.tieType = args[0];
@@ -4828,12 +4875,12 @@ var ObjConnective = class extends MusicObject {
4828
4875
  this.rx = rx;
4829
4876
  this.ry = ry;
4830
4877
  this.arcHeight = this.connectiveProps.connective === "slide" /* Slide */ ? 0 : arcHeight;
4831
- let { nx, ny } = Utils8.Math.calcNormal(lx, ly, rx, ry);
4878
+ let { nx, ny } = Utils7.Math.calcNormal(lx, ly, rx, ry);
4832
4879
  this.cp1x = lx * 0.7 + rx * 0.3 + nx * this.arcHeight;
4833
4880
  this.cp1y = ly * 0.7 + ry * 0.3 + ny * this.arcHeight;
4834
4881
  this.cp2x = lx * 0.3 + rx * 0.7 + nx * this.arcHeight;
4835
4882
  this.cp2y = ly * 0.3 + ry * 0.7 + ny * this.arcHeight;
4836
- this.rect = new DivRect(
4883
+ this.rect = new AnchoredRect18(
4837
4884
  Math.min(this.lx, this.cp1x, this.cp2x, this.rx),
4838
4885
  Math.max(this.lx, this.cp1x, this.cp2x, this.rx),
4839
4886
  Math.min(this.ly, this.cp1y, this.cp2y, this.ry),
@@ -4884,7 +4931,7 @@ var ObjConnective = class extends MusicObject {
4884
4931
 
4885
4932
  // src/score/engine/connective-props.ts
4886
4933
  import { MusicError as MusicError12, MusicErrorType as MusicErrorType12 } from "@tspro/web-music-score/core";
4887
- import { Utils as Utils9 } from "@tspro/ts-utils-lib";
4934
+ import { Guard as Guard6 } from "@tspro/ts-utils-lib";
4888
4935
  var ConnectiveProps = class {
4889
4936
  constructor(connective, span, noteAnchor, startNoteGroup) {
4890
4937
  this.connective = connective;
@@ -4957,7 +5004,7 @@ var ConnectiveProps = class {
4957
5004
  this.noteGroups[0].row.getNotationLines().forEach((line) => {
4958
5005
  this.computeParams(line);
4959
5006
  if (connective === "tie" /* Tie */) {
4960
- if (Utils9.Is.isEnumValue(span, TieType)) {
5007
+ if (Guard6.isEnumValue(span, TieType)) {
4961
5008
  let leftNoteGroup = this.noteGroups[0];
4962
5009
  for (let noteId = 0; noteId < leftNoteGroup.notes.length; noteId++) {
4963
5010
  this.createObjConnectiveWithTieType(line, leftNoteGroup, noteId, span);
@@ -5029,7 +5076,7 @@ var ConnectiveProps = class {
5029
5076
  };
5030
5077
 
5031
5078
  // src/score/engine/obj-lyrics.ts
5032
- import { Utils as Utils10 } from "@tspro/ts-utils-lib";
5079
+ import { AnchoredRect as AnchoredRect19, Guard as Guard7 } from "@tspro/ts-utils-lib";
5033
5080
  var ObjLyrics = class extends MusicObject {
5034
5081
  constructor(col, verse, line, vpos, lyricsLength, lyricsText, lyricsOptions) {
5035
5082
  super(col);
@@ -5045,9 +5092,9 @@ var ObjLyrics = class extends MusicObject {
5045
5092
  __publicField(this, "mi");
5046
5093
  this.rhythmProps = RhythmProps.get(lyricsLength);
5047
5094
  let halign = (lyricsOptions == null ? void 0 : lyricsOptions.align) === "left" /* Left */ ? 0 : (lyricsOptions == null ? void 0 : lyricsOptions.align) === "right" /* Right */ ? 1 : 0.5;
5048
- this.hyphen = Utils10.Is.isEnumValue(lyricsOptions == null ? void 0 : lyricsOptions.hyphen, LyricsHyphen) ? lyricsOptions == null ? void 0 : lyricsOptions.hyphen : void 0;
5095
+ this.hyphen = Guard7.isEnumValue(lyricsOptions == null ? void 0 : lyricsOptions.hyphen, LyricsHyphen) ? lyricsOptions == null ? void 0 : lyricsOptions.hyphen : void 0;
5049
5096
  this.text = new ObjText(this, { text: lyricsText, color: this.color, scale: 0.8 }, halign, 0);
5050
- this.rect = new DivRect();
5097
+ this.rect = new AnchoredRect19();
5051
5098
  this.mi = new MLyrics(this);
5052
5099
  }
5053
5100
  getMusicInterface() {
@@ -5067,7 +5114,7 @@ var ObjLyrics = class extends MusicObject {
5067
5114
  }
5068
5115
  layout(ctx) {
5069
5116
  this.text.layout(ctx);
5070
- this.rect = this.text.getRect().copy();
5117
+ this.rect = this.text.getRect().clone();
5071
5118
  }
5072
5119
  offset(dx, dy) {
5073
5120
  this.text.offset(dx, dy);
@@ -5085,7 +5132,7 @@ var ObjLyrics = class extends MusicObject {
5085
5132
  let w = this.hyphen === "-" /* Hyphen */ ? Math.min(hyphenw, maxw) : maxw;
5086
5133
  if (w > 0) {
5087
5134
  let cx = r ? (r.left + l.right) / 2 : l.right + w / 0.85;
5088
- let cy = (l.top + l.bottom) / 2;
5135
+ let cy = l.centerY / 2;
5089
5136
  ctx.moveTo(cx - w / 2, cy);
5090
5137
  ctx.lineTo(cx + w / 2, cy);
5091
5138
  ctx.stroke();
@@ -5095,7 +5142,7 @@ var ObjLyrics = class extends MusicObject {
5095
5142
  };
5096
5143
 
5097
5144
  // src/score/engine/obj-tab-rhythm.ts
5098
- import { Utils as Utils11 } from "@tspro/ts-utils-lib";
5145
+ import { AnchoredRect as AnchoredRect20, UniMap as UniMap4, Utils as Utils8 } from "@tspro/ts-utils-lib";
5099
5146
  var ObjTabRhythm = class extends MusicObject {
5100
5147
  constructor(measure, tab) {
5101
5148
  super(measure);
@@ -5104,9 +5151,9 @@ var ObjTabRhythm = class extends MusicObject {
5104
5151
  __publicField(this, "voiceId");
5105
5152
  __publicField(this, "mi");
5106
5153
  // Keep non-static
5107
- __publicField(this, "tupletPartsTextObjMap", /* @__PURE__ */ new Map());
5154
+ __publicField(this, "tupletPartsTextObjMap", new UniMap4());
5108
5155
  this.voiceId = getVoiceIds().filter((voiceId) => tab.containsVoiceId(voiceId));
5109
- this.rect = new DivRect();
5156
+ this.rect = new AnchoredRect20();
5110
5157
  this.mi = new MTabRhythm(this);
5111
5158
  }
5112
5159
  getMusicInterface() {
@@ -5117,9 +5164,9 @@ var ObjTabRhythm = class extends MusicObject {
5117
5164
  }
5118
5165
  layout(ctx) {
5119
5166
  let columns = this.measure.getColumns();
5120
- let numColsInVoiceId = getVoiceIds().map((voiceId) => Utils11.Math.sum(columns.map((col) => col.getVoiceSymbol(voiceId) ? 1 : 0)));
5121
- this.voiceId.sort((a, b) => Utils11.Math.cmp(numColsInVoiceId[a], numColsInVoiceId[b]));
5122
- this.rect = new DivRect();
5167
+ let numColsInVoiceId = getVoiceIds().map((voiceId) => Utils8.Math.sum(columns.map((col) => col.getVoiceSymbol(voiceId) ? 1 : 0)));
5168
+ this.voiceId.sort((a, b) => Utils8.Math.cmp(numColsInVoiceId[a], numColsInVoiceId[b]));
5169
+ this.rect = new AnchoredRect20();
5123
5170
  }
5124
5171
  hasTuplets() {
5125
5172
  return this.measure.getBeamGroups().some((beamGroup) => beamGroup.isTuplet());
@@ -5127,13 +5174,13 @@ var ObjTabRhythm = class extends MusicObject {
5127
5174
  layoutFitToMeasure(ctx) {
5128
5175
  let { unitSize, fontSize } = ctx;
5129
5176
  let { measure } = this;
5130
- let { left, right } = measure.getColumnsContentRect();
5177
+ let cr = measure.getColumnsContentRect();
5131
5178
  let stemHeight = unitSize * 5;
5132
- this.rect.left = left;
5133
- this.rect.centerX = (left + right) / 2;
5134
- this.rect.right = right;
5179
+ this.rect.left = cr.left;
5180
+ this.rect.anchorX = cr.centerX;
5181
+ this.rect.right = cr.right;
5135
5182
  this.rect.top = this.hasTuplets() ? -fontSize : 0;
5136
- this.rect.centerY = 0;
5183
+ this.rect.anchorY = 0;
5137
5184
  this.rect.bottom = stemHeight;
5138
5185
  }
5139
5186
  offset(dx, dy) {
@@ -5146,8 +5193,8 @@ var ObjTabRhythm = class extends MusicObject {
5146
5193
  let flagSize = unitSize;
5147
5194
  let dotSpace = unitSize;
5148
5195
  let dotWidth = unitSize * 0.25;
5149
- let { bottom, centerY } = this.getRect();
5150
- let stemTop = centerY;
5196
+ let { bottom, anchorY } = this.getRect();
5197
+ let stemTop = anchorY;
5151
5198
  let stemBottom = bottom;
5152
5199
  let columns = this.measure.getColumns();
5153
5200
  for (let colId = 0; colId < columns.length; colId++) {
@@ -5161,7 +5208,7 @@ var ObjTabRhythm = class extends MusicObject {
5161
5208
  for (let j = 0; j < symbols.length; j++) {
5162
5209
  let sym = symbols[j];
5163
5210
  let nextSym = symbols[j + 1];
5164
- let colX = sym.col.getRect().centerX;
5211
+ let colX = sym.col.getRect().anchorX;
5165
5212
  if (sym instanceof ObjNoteGroup) {
5166
5213
  if (sym.rhythmProps.noteSize >= 2) {
5167
5214
  ctx.lineWidth(sym.rhythmProps.noteSize === 4 ? 2 : 1);
@@ -5170,7 +5217,7 @@ var ObjTabRhythm = class extends MusicObject {
5170
5217
  ctx.lineWidth(1);
5171
5218
  if (symbols.length === 1) {
5172
5219
  for (let i = 0; i < sym.rhythmProps.flagCount; i++) {
5173
- ctx.drawFlag(new DivRect(colX, colX + flagSize, stemTop + i * flagSize, stemTop + (i + 2) * flagSize), "up");
5220
+ ctx.drawFlag(new AnchoredRect20(colX, colX + flagSize, stemTop + i * flagSize, stemTop + (i + 2) * flagSize), "up");
5174
5221
  }
5175
5222
  }
5176
5223
  for (let i = 0; i < sym.rhythmProps.dotCount; i++) {
@@ -5192,8 +5239,8 @@ var ObjTabRhythm = class extends MusicObject {
5192
5239
  if (nextSym) {
5193
5240
  let left = sym;
5194
5241
  let right = nextSym;
5195
- let leftX = left.col.getRect().centerX;
5196
- let rightX = right.col.getRect().centerX;
5242
+ let leftX = left.col.getRect().anchorX;
5243
+ let rightX = right.col.getRect().anchorX;
5197
5244
  let leftBeamCount = left.hasTuplet() ? 1 : left instanceof ObjNoteGroup ? left.getRightBeamCount() : 1;
5198
5245
  let rightBeamCount = right.hasTuplet() ? 1 : right instanceof ObjNoteGroup ? right.getLeftBeamCount() : 1;
5199
5246
  let maxBeamCount = Math.max(leftBeamCount, rightBeamCount);
@@ -5212,14 +5259,14 @@ var ObjTabRhythm = class extends MusicObject {
5212
5259
  }
5213
5260
  }
5214
5261
  if (beamGroup && beamGroup.isTuplet()) {
5215
- let cx = (symbols[0].col.getRect().centerX + symbols[symbols.length - 1].col.getRect().centerX) / 2;
5262
+ let cx = (symbols[0].col.getRect().anchorX + symbols[symbols.length - 1].col.getRect().anchorX) / 2;
5216
5263
  let text = beamGroup.getTupletRatioText();
5217
5264
  let textObj = this.tupletPartsTextObjMap.get(text);
5218
5265
  if (!textObj) {
5219
5266
  this.tupletPartsTextObjMap.set(text, textObj = new ObjText(this, { text, scale: 0.75 }, 0.5, 0.5));
5220
5267
  textObj.layout(ctx);
5221
5268
  }
5222
- textObj.offset(-textObj.getRect().centerX, -textObj.getRect().centerY);
5269
+ textObj.offset(-textObj.getRect().anchorX, -textObj.getRect().anchorY);
5223
5270
  textObj.offset(cx, stemTop - fontSize / 2);
5224
5271
  textObj.draw(ctx);
5225
5272
  }
@@ -5235,18 +5282,11 @@ var ObjTabRhythm = class extends MusicObject {
5235
5282
  };
5236
5283
 
5237
5284
  // src/score/engine/obj-measure.ts
5238
- function validateVoiceId(voiceId) {
5239
- if (typeof voiceId === "number" && getVoiceIds().indexOf(voiceId) < 0) {
5240
- throw new MusicError13(MusicErrorType13.Score, "Invalid voiceId: " + voiceId);
5241
- } else {
5242
- return voiceId;
5243
- }
5244
- }
5245
5285
  function getExtensionTicks(extensionLength) {
5246
5286
  if (typeof extensionLength === "string") {
5247
5287
  extensionLength = [extensionLength];
5248
5288
  }
5249
- if (Utils12.Is.isArray(extensionLength)) {
5289
+ if (Guard8.isArray(extensionLength)) {
5250
5290
  let totalTicks = 0;
5251
5291
  for (let i = 0; i < extensionLength.length; ) {
5252
5292
  let str = extensionLength[i];
@@ -5306,7 +5346,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5306
5346
  __publicField(this, "leftSolidAreaWidth", 0);
5307
5347
  __publicField(this, "minColumnsAreaWidth", 0);
5308
5348
  __publicField(this, "rightSolidAreaWidth", 0);
5309
- __publicField(this, "voiceSymbols", []);
5349
+ __publicField(this, "voiceSymbols", asMulti(new IndexArray2()));
5310
5350
  __publicField(this, "lastAddedRhythmColumn");
5311
5351
  __publicField(this, "lastAddedRhythmSymbol");
5312
5352
  __publicField(this, "addExtensionToMusicObjects", []);
@@ -5315,14 +5355,14 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5315
5355
  __publicField(this, "passCount", 0);
5316
5356
  // How many times player has passed this measure.
5317
5357
  __publicField(this, "needBeamsUpdate", true);
5318
- __publicField(this, "navigationSet", /* @__PURE__ */ new Set());
5358
+ __publicField(this, "navigationSet", new ValueSet());
5319
5359
  __publicField(this, "isEndSong", false);
5320
5360
  __publicField(this, "isEndSection", false);
5321
5361
  __publicField(this, "endRepeatPlayCount", 2);
5322
5362
  // play twice.
5323
5363
  __publicField(this, "endRepeatPlayCountText");
5324
- __publicField(this, "staticObjectsCache", /* @__PURE__ */ new Map());
5325
- __publicField(this, "lyricsObjectsCache", new Map32());
5364
+ __publicField(this, "staticObjectsCache", new UniMap5());
5365
+ __publicField(this, "lyricsObjectsCache", new TriMap2());
5326
5366
  __publicField(this, "mi");
5327
5367
  this.mi = new MMeasure(this);
5328
5368
  this.prevMeasure = row.doc.getLastMeasure();
@@ -5363,7 +5403,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5363
5403
  updateRunningArguments(runningArgs) {
5364
5404
  var _a;
5365
5405
  runningArgs != null ? runningArgs : runningArgs = [];
5366
- let numVoices = Utils12.Math.sum(getVoiceIds().map((voiceId) => this.getVoiceSymbols(voiceId).length > 0 ? 1 : 0));
5406
+ let numVoices = Utils9.Math.sum(getVoiceIds().map((voiceId) => this.getVoiceSymbols(voiceId).length > 0 ? 1 : 0));
5367
5407
  getVoiceIds().forEach((voiceId) => {
5368
5408
  var _a2;
5369
5409
  const getDefaultDiatonicId = () => {
@@ -5522,7 +5562,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5522
5562
  this.alterKeySignature = args[0];
5523
5563
  } else if (args[0] instanceof Scale) {
5524
5564
  this.alterKeySignature = args[0];
5525
- } else if (Utils12.Is.isNonEmptyString(args[0])) {
5565
+ } else if (Guard8.isNonEmptyString(args[0])) {
5526
5566
  if (args.length === 1) {
5527
5567
  this.alterKeySignature = getScale(args[0]);
5528
5568
  } else if (args.length === 2) {
@@ -5633,7 +5673,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5633
5673
  let grp = this.doc.getStaffGroup(staffTabOrGroup);
5634
5674
  if (grp && !prevGroups.includes(staffTabOrGroup)) {
5635
5675
  let curGroups = [...prevGroups, staffTabOrGroup];
5636
- (Utils12.Is.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
5676
+ (Guard8.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
5637
5677
  switch (grp.verticalPosition) {
5638
5678
  case "above" /* Above */:
5639
5679
  addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
@@ -5660,7 +5700,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5660
5700
  } else {
5661
5701
  addToStaffTabOrGroup(0, defaultVerticalPos);
5662
5702
  }
5663
- } else if (Utils12.Is.isArray(staffTabOrGroups)) {
5703
+ } else if (Guard8.isArray(staffTabOrGroups)) {
5664
5704
  staffTabOrGroups.forEach((staffTabOrGroup) => addToStaffTabOrGroup(staffTabOrGroup, defaultVerticalPos));
5665
5705
  } else {
5666
5706
  addToStaffTabOrGroup(staffTabOrGroups, defaultVerticalPos);
@@ -5744,7 +5784,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5744
5784
  case "endRepeat" /* EndRepeat */:
5745
5785
  if (args.length === 0) {
5746
5786
  this.endRepeatPlayCount = 2;
5747
- } else if (Utils12.Is.isIntegerGte(args[0], 2)) {
5787
+ } else if (Guard8.isIntegerGte(args[0], 2)) {
5748
5788
  this.endRepeatPlayCount = args[0];
5749
5789
  } else {
5750
5790
  throw new MusicError13(MusicErrorType13.Score, "Invalid end repeat play count (should be 2 or greater integer): " + args[0]);
@@ -5831,15 +5871,15 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5831
5871
  throw new MusicError13(MusicErrorType13.Score, "Connective can be added to note group only.");
5832
5872
  }
5833
5873
  if (connective === "tie" /* Tie */) {
5834
- let tieSpan = Utils12.Is.isInteger(args[0]) || Utils12.Is.isEnumValue(args[0], TieType) ? args[0] : 2;
5835
- let noteAnchor = Utils12.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
5874
+ let tieSpan = Guard8.isInteger(args[0]) || Guard8.isEnumValue(args[0], TieType) ? args[0] : 2;
5875
+ let noteAnchor = Guard8.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
5836
5876
  anchor.startConnective(new ConnectiveProps("tie" /* Tie */, tieSpan, noteAnchor, anchor));
5837
5877
  } else if (connective === "slur" /* Slur */) {
5838
- let slurSpan = Utils12.Is.isInteger(args[0]) ? args[0] : 2;
5839
- let noteAnchor = Utils12.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
5878
+ let slurSpan = Guard8.isInteger(args[0]) ? args[0] : 2;
5879
+ let noteAnchor = Guard8.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
5840
5880
  anchor.startConnective(new ConnectiveProps("slur" /* Slur */, slurSpan, noteAnchor, anchor));
5841
5881
  } else if (connective === "slide" /* Slide */) {
5842
- let noteAnchor = Utils12.Is.isEnumValue(args[0], NoteAnchor) ? args[0] : "auto" /* Auto */;
5882
+ let noteAnchor = Guard8.isEnumValue(args[0], NoteAnchor) ? args[0] : "auto" /* Auto */;
5843
5883
  anchor.startConnective(new ConnectiveProps("slide" /* Slide */, 2, noteAnchor, anchor));
5844
5884
  }
5845
5885
  }
@@ -5894,11 +5934,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5894
5934
  this.disableExtension();
5895
5935
  }
5896
5936
  addRhythmSymbol(symbol) {
5897
- var _a, _b;
5898
5937
  let { col, voiceId } = symbol;
5899
5938
  col.setVoiceSymbol(voiceId, symbol);
5900
- (_b = (_a = this.voiceSymbols)[voiceId]) != null ? _b : _a[voiceId] = [];
5901
- this.voiceSymbols[voiceId].push(symbol);
5939
+ this.voiceSymbols.add(voiceId, symbol);
5902
5940
  if (symbol.oldStyleTriplet) {
5903
5941
  this.createOldStyleTriplets(voiceId);
5904
5942
  }
@@ -5925,9 +5963,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5925
5963
  let col = this.getRhythmColumn({ verse, line, vpos });
5926
5964
  let lyricsObj = new ObjLyrics(col, verse, line, vpos, validateNoteLength2(lyricsLength), lyricsText, lyricsOptions);
5927
5965
  col.addLyricsObject(lyricsObj);
5928
- let lyricsArr = this.getLyricsObjects(line, vpos, verse);
5966
+ let lyricsArr = this.lyricsObjectsCache.getOrCreate(line, vpos, verse, []);
5929
5967
  lyricsArr.push(lyricsObj);
5930
- lyricsArr.sort((a, b) => Utils12.Math.cmp(a.col.positionTicks, b.col.positionTicks));
5968
+ lyricsArr.sort((a, b) => Utils9.Math.cmp(a.col.positionTicks, b.col.positionTicks));
5931
5969
  (_a = lyricsObj.measure.getPrevLyricsObject(lyricsObj)) == null ? void 0 : _a.setNextLyricsObject(lyricsObj);
5932
5970
  this.addLayoutObject(lyricsObj, line, getVerseLayoutGroupId(verse), vpos);
5933
5971
  this.lastAddedRhythmColumn = col;
@@ -5976,9 +6014,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5976
6014
  }
5977
6015
  // Get content rect excluding signature
5978
6016
  getColumnsContentRect() {
5979
- return new DivRect(
5980
- this.barLineLeft.getRect().centerX,
5981
- this.barLineRight.getRect().centerX,
6017
+ return new AnchoredRect21(
6018
+ this.barLineLeft.getRect().anchorX,
6019
+ this.barLineRight.getRect().anchorX,
5982
6020
  this.getRect().top,
5983
6021
  this.getRect().bottom
5984
6022
  );
@@ -6007,24 +6045,17 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6007
6045
  }
6008
6046
  }
6009
6047
  getStaffLineRight() {
6010
- return this.barLineRight.getRect().centerX;
6011
- }
6012
- getLyricsObjects(line, vpos, verse) {
6013
- let lyricsObjs = this.lyricsObjectsCache.get(line, vpos, verse);
6014
- if (!lyricsObjs) {
6015
- this.lyricsObjectsCache.set(line, vpos, verse, lyricsObjs = []);
6016
- }
6017
- return lyricsObjs;
6048
+ return this.barLineRight.getRect().anchorX;
6018
6049
  }
6019
6050
  getPrevLyricsObject(lyricsObj) {
6020
6051
  var _a;
6021
6052
  let { line, verse, vpos } = lyricsObj;
6022
- let lyricsArr = this.getLyricsObjects(line, vpos, verse);
6053
+ let lyricsArr = this.lyricsObjectsCache.getOrDefault(line, vpos, verse, []);
6023
6054
  let i = lyricsArr.indexOf(lyricsObj);
6024
6055
  if (i > 0) {
6025
6056
  return lyricsArr[i - 1];
6026
6057
  } else if (i === 0) {
6027
- let lyricsArr2 = (_a = lyricsObj.measure.getPrevMeasure()) == null ? void 0 : _a.getLyricsObjects(line, vpos, verse);
6058
+ let lyricsArr2 = (_a = lyricsObj.measure.getPrevMeasure()) == null ? void 0 : _a.lyricsObjectsCache.get(line, vpos, verse);
6028
6059
  if (lyricsArr2 && lyricsArr2.length > 0) {
6029
6060
  return lyricsArr2[lyricsArr2.length - 1];
6030
6061
  }
@@ -6032,14 +6063,13 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6032
6063
  return void 0;
6033
6064
  }
6034
6065
  getStaticObjects(line) {
6035
- let staticObjects = this.staticObjectsCache.get(line);
6036
- if (!staticObjects) {
6037
- staticObjects = [];
6038
- this.getColumns().forEach((col) => col.getStaticObjects(line).forEach((obj) => staticObjects == null ? void 0 : staticObjects.push(obj)));
6039
- this.staticObjectsCache.set(line, staticObjects);
6040
- }
6041
6066
  let layoutObjects = this.layoutObjects.filter((layoutObj) => layoutObj.line === line && layoutObj.isPositionResolved()).map((layoutObj) => layoutObj.musicObj);
6042
- return layoutObjects.length > 0 ? [...staticObjects, ...layoutObjects] : staticObjects;
6067
+ let staticObjects = layoutObjects.length > 0 ? [...this.staticObjectsCache.getOrDefault(line, []), ...layoutObjects] : this.staticObjectsCache.getOrDefault(line, []);
6068
+ staticObjects.forEach((obj) => obj.getRect());
6069
+ return staticObjects;
6070
+ }
6071
+ addStaticObject(line, staticObj) {
6072
+ this.staticObjectsCache.getOrCreate(line, []).push(staticObj);
6043
6073
  }
6044
6074
  removeLayoutObjects(musicObj) {
6045
6075
  this.layoutObjects = this.layoutObjects.filter((layoutObj) => {
@@ -6138,7 +6168,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6138
6168
  let beamGroupSize = ts.beamGroupSizes[groupId];
6139
6169
  let beamGroupSizeList = [beamGroupSize];
6140
6170
  if (beamGroupSize.length > 1) {
6141
- beamGroupSizeList.unshift([Utils12.Math.sum(beamGroupSize)]);
6171
+ beamGroupSizeList.unshift([Utils9.Math.sum(beamGroupSize)]);
6142
6172
  }
6143
6173
  let beamCreated = false;
6144
6174
  let groupStartTicksSave = groupStartTicks;
@@ -6153,7 +6183,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6153
6183
  let symbolEndTicks = symbolStartTicks + symbol.rhythmProps.ticks;
6154
6184
  return symbolStartTicks >= groupStartTicks && symbolEndTicks <= groupEndTicks;
6155
6185
  });
6156
- let groupSymbolsTicks = Utils12.Math.sum(groupSymbols.map((sym) => sym.rhythmProps.ticks));
6186
+ let groupSymbolsTicks = Utils9.Math.sum(groupSymbols.map((sym) => sym.rhythmProps.ticks));
6157
6187
  if (groupSymbolsTicks === beamGroupTicks && groupSymbols.every((n) => n instanceof ObjNoteGroup) && (groupSymbols.every((n) => n.rhythmProps.flagCount === 1) || beamGroupSizeList.length === 0)) {
6158
6188
  if (ObjBeamGroup.createBeam(groupSymbols)) {
6159
6189
  beamCreated = true;
@@ -6174,10 +6204,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6174
6204
  return this.barLineRight;
6175
6205
  }
6176
6206
  getVoiceSymbols(voiceId) {
6177
- var _a, _b;
6178
- validateVoiceId(voiceId);
6179
- (_b = (_a = this.voiceSymbols)[voiceId]) != null ? _b : _a[voiceId] = [];
6180
- return this.voiceSymbols[voiceId];
6207
+ return this.voiceSymbols.getAll(voiceId);
6181
6208
  }
6182
6209
  completeRests(voiceId) {
6183
6210
  if (voiceId === void 0) {
@@ -6187,7 +6214,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6187
6214
  this.completeRests(getVoiceIds().filter((id) => this.getConsumedTicks(id) > 0));
6188
6215
  }
6189
6216
  return;
6190
- } else if (Utils12.Is.isArray(voiceId)) {
6217
+ } else if (Guard8.isArray(voiceId)) {
6191
6218
  voiceId.forEach((id) => this.completeRests(id));
6192
6219
  return;
6193
6220
  } else {
@@ -6291,34 +6318,43 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6291
6318
  return;
6292
6319
  }
6293
6320
  width = Math.max(width, this.getMinWidth());
6294
- this.rect = new DivRect();
6295
- this.rect.centerX = this.rect.left + width / 2;
6321
+ this.rect = new AnchoredRect21();
6322
+ this.rect.anchorX = this.rect.left + width / 2;
6296
6323
  this.rect.right = this.rect.left + width;
6297
6324
  let rect;
6298
6325
  this.signatures.forEach((signature) => {
6299
6326
  rect = signature.getRect();
6300
- signature.offset(this.rect.left + this.tabStringNotesWidth - rect.left, -rect.centerY);
6327
+ signature.offset(this.rect.left + this.tabStringNotesWidth - rect.left, -rect.anchorY);
6301
6328
  });
6302
6329
  let signaturesWidth = Math.max(0, ...this.signatures.map((signature) => signature.getRect().width));
6303
6330
  rect = this.barLineLeft.getRect();
6304
- this.barLineLeft.offset(this.rect.left + this.tabStringNotesWidth + signaturesWidth - rect.left, -rect.centerY);
6331
+ this.barLineLeft.offset(this.rect.left + this.tabStringNotesWidth + signaturesWidth - rect.left, -rect.anchorY);
6305
6332
  rect = this.barLineRight.getRect();
6306
- this.barLineRight.offset(this.rect.right - rect.right, -rect.centerY);
6333
+ this.barLineRight.offset(this.rect.right - rect.right, -rect.anchorY);
6307
6334
  if (this.endRepeatPlayCountText) {
6308
6335
  this.endRepeatPlayCountText.offset(this.barLineRight.getRect().left, this.barLineRight.getRect().top);
6309
6336
  }
6310
6337
  let columnsAreaLeft = this.rect.left + this.leftSolidAreaWidth;
6311
6338
  let columnsAreaRight = this.rect.right - this.rightSolidAreaWidth;
6312
6339
  let columnsAreaWidth = columnsAreaRight - columnsAreaLeft;
6313
- let columnsWidth = Utils12.Math.sum(this.columns.map((col) => col.getRect().width));
6340
+ let columnsWidth = Utils9.Math.sum(this.columns.map((col) => col.getRect().width));
6314
6341
  let columnScale = columnsAreaWidth / columnsWidth;
6315
6342
  let columnLeft = columnsAreaLeft;
6316
6343
  this.columns.forEach((col) => {
6317
6344
  rect = col.getRect();
6318
- let columnCenterX = columnLeft + rect.leftw * columnScale;
6319
- col.offset(columnCenterX - rect.centerX, -rect.centerY);
6345
+ let columnAnchorX = columnLeft + rect.leftw * columnScale;
6346
+ col.offset(columnAnchorX - rect.anchorX, -rect.anchorY);
6320
6347
  columnLeft += rect.width * columnScale;
6321
6348
  });
6349
+ getVoiceIds().forEach((voiceId) => {
6350
+ const symbols = this.getVoiceSymbols(voiceId);
6351
+ const onlyRest = symbols.length === 1 && symbols[0] instanceof ObjRest ? symbols[0] : void 0;
6352
+ if (!onlyRest) return;
6353
+ const isOnlySymbolInCol = getVoiceIds().map((voiceId2) => onlyRest.col.getVoiceSymbol(voiceId2)).filter((sym) => sym !== void 0 && sym !== onlyRest).length === 0;
6354
+ if (isOnlySymbolInCol) return;
6355
+ const r = this.getColumnsContentRect();
6356
+ onlyRest.offset(r.centerX - onlyRest.getRect().anchorX, 0);
6357
+ });
6322
6358
  }
6323
6359
  layoutConnectives(ctx) {
6324
6360
  if (!this.needLayout) {
@@ -6426,28 +6462,41 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6426
6462
  }
6427
6463
  };
6428
6464
  __publicField(_ObjMeasure, "MinFlexContentWidth", 10);
6429
- var ObjMeasure2 = _ObjMeasure;
6465
+ var ObjMeasure = _ObjMeasure;
6430
6466
 
6431
6467
  // src/score/engine/layout-object.ts
6432
6468
  import { MusicError as MusicError14, MusicErrorType as MusicErrorType14 } from "@tspro/web-music-score/core";
6433
- var WidenColumnList = [
6434
- 2 /* NoteLabel */,
6435
- 7 /* ChordLabel */
6436
- ];
6437
- var RowAlignList = [
6438
- 0 /* TabRhythm */,
6439
- 3 /* Navigation */,
6440
- 4 /* Ending */,
6441
- 5 /* TempoAnnotation */,
6442
- 6 /* DynamicsAnnotation */,
6443
- 7 /* ChordLabel */,
6444
- 8 /* LyricsVerse1 */,
6445
- 9 /* LyricsVerse2 */,
6446
- 10 /* LyricsVerse3 */
6447
- ];
6469
+ import { AnchoredRect as AnchoredRect22, asMulti as asMulti2, IndexArray as IndexArray3, UniMap as UniMap6 } from "@tspro/ts-utils-lib";
6470
+ var LayoutGroupId = /* @__PURE__ */ ((LayoutGroupId2) => {
6471
+ LayoutGroupId2[LayoutGroupId2["TabRhythm"] = 0] = "TabRhythm";
6472
+ LayoutGroupId2[LayoutGroupId2["Fermata"] = 1] = "Fermata";
6473
+ LayoutGroupId2[LayoutGroupId2["NoteLabel"] = 2] = "NoteLabel";
6474
+ LayoutGroupId2[LayoutGroupId2["Navigation"] = 3] = "Navigation";
6475
+ LayoutGroupId2[LayoutGroupId2["Ending"] = 4] = "Ending";
6476
+ LayoutGroupId2[LayoutGroupId2["TempoAnnotation"] = 5] = "TempoAnnotation";
6477
+ LayoutGroupId2[LayoutGroupId2["DynamicsAnnotation"] = 6] = "DynamicsAnnotation";
6478
+ LayoutGroupId2[LayoutGroupId2["ChordLabel"] = 7] = "ChordLabel";
6479
+ LayoutGroupId2[LayoutGroupId2["LyricsVerse1"] = 8] = "LyricsVerse1";
6480
+ LayoutGroupId2[LayoutGroupId2["LyricsVerse2"] = 9] = "LyricsVerse2";
6481
+ LayoutGroupId2[LayoutGroupId2["LyricsVerse3"] = 10] = "LyricsVerse3";
6482
+ return LayoutGroupId2;
6483
+ })(LayoutGroupId || {});
6484
+ var LayoutGroupIdAttrs = new UniMap6([
6485
+ [0 /* TabRhythm */, { rowAlign: true }],
6486
+ [1 /* Fermata */, {}],
6487
+ [2 /* NoteLabel */, { widen: true }],
6488
+ [3 /* Navigation */, { rowAlign: true }],
6489
+ [4 /* Ending */, { rowAlign: true, padding: 2 }],
6490
+ [5 /* TempoAnnotation */, { rowAlign: true, padding: 2 }],
6491
+ [6 /* DynamicsAnnotation */, { rowAlign: true, padding: 2 }],
6492
+ [7 /* ChordLabel */, { widen: true, rowAlign: true }],
6493
+ [8 /* LyricsVerse1 */, { rowAlign: true }],
6494
+ [9 /* LyricsVerse2 */, { rowAlign: true }],
6495
+ [10 /* LyricsVerse3 */, { rowAlign: true }]
6496
+ ]);
6448
6497
  function requireParentMeasure(p) {
6449
6498
  while (p) {
6450
- if (p instanceof ObjMeasure2) {
6499
+ if (p instanceof ObjMeasure) {
6451
6500
  return p;
6452
6501
  }
6453
6502
  p = p.getParent();
@@ -6483,7 +6532,7 @@ var LayoutObjectWrapper = class {
6483
6532
  this.layoutGroup = this.line.getLayoutGroup(layoutGroupId);
6484
6533
  this.layoutGroup.add(this);
6485
6534
  }
6486
- clearPositionResolved() {
6535
+ resetPositionResolved() {
6487
6536
  this.positionResolved = false;
6488
6537
  }
6489
6538
  setPositionResolved() {
@@ -6504,8 +6553,8 @@ var LayoutObjectWrapper = class {
6504
6553
  let staticShapeRects = staticObj.getShapeRects();
6505
6554
  objShapeRects.forEach((objR) => {
6506
6555
  staticShapeRects.forEach((staticR) => {
6507
- if (DivRect.overlapX(objR, staticR)) {
6508
- y = verticalPos === 1 /* Below */ ? Math.max(y, staticR.bottom + objR.toph + objR.centerY) : Math.min(y, staticR.top - objR.bottomh - objR.centerY);
6556
+ if (AnchoredRect22.overlapX(objR, staticR)) {
6557
+ y = verticalPos === 1 /* Below */ ? Math.max(y, staticR.bottom + objR.toph + objR.anchorY) : Math.min(y, staticR.top - objR.bottomh - objR.anchorY);
6509
6558
  }
6510
6559
  });
6511
6560
  });
@@ -6532,35 +6581,33 @@ var LayoutObjectWrapper = class {
6532
6581
  var LayoutGroup = class {
6533
6582
  constructor(layoutGroupId) {
6534
6583
  this.layoutGroupId = layoutGroupId;
6535
- __publicField(this, "layoutObjectTable", []);
6584
+ // key = VerticalPos
6585
+ __publicField(this, "layoutObject", asMulti2(new IndexArray3()));
6536
6586
  __publicField(this, "rowAlign");
6537
6587
  __publicField(this, "widensColumn");
6538
- this.layoutObjectTable[0 /* Above */] = [];
6539
- this.layoutObjectTable[1 /* Below */] = [];
6540
- this.rowAlign = RowAlignList.indexOf(layoutGroupId) >= 0;
6541
- this.widensColumn = WidenColumnList.indexOf(layoutGroupId) >= 0;
6588
+ __publicField(this, "padding");
6589
+ var _a, _b, _c, _d;
6590
+ this.rowAlign = ((_a = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _a.rowAlign) === true;
6591
+ this.widensColumn = ((_b = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _b.widen) === true;
6592
+ this.padding = (_d = (_c = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _c.padding) != null ? _d : 0;
6542
6593
  }
6543
6594
  getLayoutObjects(verticalPos) {
6544
- return this.layoutObjectTable[verticalPos];
6595
+ return this.layoutObject.getAll(verticalPos);
6545
6596
  }
6546
6597
  add(layoutObj) {
6547
- this.layoutObjectTable[layoutObj.verticalPos].push(layoutObj);
6598
+ this.layoutObject.add(layoutObj.verticalPos, layoutObj);
6548
6599
  }
6549
6600
  remove(layoutObj) {
6550
- this.layoutObjectTable.forEach((layoutObjects) => {
6551
- let i = layoutObjects.indexOf(layoutObj);
6552
- if (i >= 0) {
6553
- layoutObjects.splice(i, 1);
6554
- }
6555
- });
6601
+ this.layoutObject.remove(layoutObj.verticalPos, layoutObj);
6556
6602
  }
6557
- clearPositionAndLayout(ctx) {
6558
- this.layoutObjectTable.forEach((layoutObjects) => {
6559
- layoutObjects.forEach((layoutObj) => {
6560
- layoutObj.clearPositionResolved();
6561
- layoutObj.musicObj.layout(ctx);
6562
- });
6563
- });
6603
+ layout(ctx) {
6604
+ for (const w of this.layoutObject.values()) {
6605
+ w.resetPositionResolved();
6606
+ w.musicObj.layout(ctx);
6607
+ }
6608
+ }
6609
+ getPadding(ctx) {
6610
+ return this.padding * ctx.unitSize;
6564
6611
  }
6565
6612
  };
6566
6613
 
@@ -6570,7 +6617,7 @@ var ObjNotationLine5 = class extends MusicObject {
6570
6617
  super(row);
6571
6618
  this.row = row;
6572
6619
  __publicField(this, "objects", []);
6573
- __publicField(this, "layoutGroups", []);
6620
+ __publicField(this, "layoutGroups", new UniMap7());
6574
6621
  }
6575
6622
  addObject(o) {
6576
6623
  this.objects.push(o);
@@ -6579,41 +6626,36 @@ var ObjNotationLine5 = class extends MusicObject {
6579
6626
  this.objects.length = 0;
6580
6627
  }
6581
6628
  getLayoutGroup(lauoutGroupId) {
6582
- let layoutGroup = this.layoutGroups[lauoutGroupId];
6583
- if (!layoutGroup) {
6584
- layoutGroup = this.layoutGroups[lauoutGroupId] = new LayoutGroup(lauoutGroupId);
6585
- }
6586
- return layoutGroup;
6629
+ return this.layoutGroups.getOrCreate(lauoutGroupId, () => new LayoutGroup(lauoutGroupId));
6587
6630
  }
6588
6631
  resetLayoutGroups(ctx) {
6589
- this.layoutGroups.forEach((layoutGroup) => {
6590
- if (layoutGroup) {
6591
- layoutGroup.clearPositionAndLayout(ctx);
6592
- }
6593
- });
6632
+ this.layoutGroups.forEach((layoutGroup) => layoutGroup.layout(ctx));
6594
6633
  }
6595
6634
  layoutLayoutGroups(ctx) {
6596
- this.layoutGroups.forEach((layoutGroup) => {
6635
+ for (const groupId of Utils10.Enum.getEnumValues(LayoutGroupId)) {
6636
+ const layoutGroup = this.getLayoutGroup(groupId);
6597
6637
  if (layoutGroup) {
6598
6638
  this.layoutLayoutGroup(ctx, layoutGroup, 0 /* Above */);
6599
6639
  this.layoutLayoutGroup(ctx, layoutGroup, 1 /* Below */);
6600
6640
  }
6601
- });
6641
+ }
6602
6642
  }
6603
6643
  setObjectY(layoutObj, y) {
6604
6644
  if (y === void 0) {
6605
6645
  return;
6606
6646
  }
6607
- layoutObj.offset(0, y - layoutObj.getRect().centerY);
6647
+ layoutObj.offset(0, y - layoutObj.getRect().anchorY);
6608
6648
  layoutObj.setPositionResolved();
6609
6649
  }
6610
- alignObjectsY(ctx, layoutObjArr) {
6611
- layoutObjArr = layoutObjArr.filter((layoutObj) => !layoutObj.isPositionResolved());
6612
- let rowY;
6613
- layoutObjArr.forEach((layoutObj) => {
6614
- let y = layoutObj.resolveClosestToStaffY(ctx);
6615
- rowY = layoutObj.verticalPos === 1 /* Below */ ? Math.max(y, rowY != null ? rowY : y) : Math.min(y, rowY != null ? rowY : y);
6650
+ alignObjectsY(ctx, layoutObjects, verticalPos) {
6651
+ const layoutObjArr = layoutObjects.filter((obj) => !obj.isPositionResolved() && obj.verticalPos === verticalPos);
6652
+ if (layoutObjArr.length === 0)
6653
+ return;
6654
+ const vdir = verticalPos === 1 /* Below */ ? 1 : -1;
6655
+ let yArr = layoutObjArr.map((layoutObj) => {
6656
+ return layoutObj.resolveClosestToStaffY(ctx) + layoutObj.layoutGroup.getPadding(ctx) * vdir;
6616
6657
  });
6658
+ const rowY = verticalPos === 1 /* Below */ ? Math.max(...yArr) : Math.min(...yArr);
6617
6659
  layoutObjArr.forEach((layoutObj) => this.setObjectY(layoutObj, rowY));
6618
6660
  }
6619
6661
  layoutLayoutGroup(ctx, layoutGroup, verticalPos) {
@@ -6623,20 +6665,20 @@ var ObjNotationLine5 = class extends MusicObject {
6623
6665
  if (musicObj instanceof ObjEnding || musicObj instanceof ObjExtensionLine || musicObj instanceof ObjTabRhythm) {
6624
6666
  musicObj.layoutFitToMeasure(ctx);
6625
6667
  } else {
6626
- musicObj.offset(anchor.getRect().centerX - musicObj.getRect().centerX, 0);
6668
+ musicObj.offset(anchor.getRect().anchorX - musicObj.getRect().anchorX, 0);
6627
6669
  }
6628
6670
  });
6629
6671
  if (layoutGroup.rowAlign) {
6630
- this.alignObjectsY(ctx, rowLayoutObjs);
6672
+ this.alignObjectsY(ctx, rowLayoutObjs, verticalPos);
6631
6673
  } else {
6632
6674
  rowLayoutObjs.forEach((layoutObj) => {
6633
6675
  let link = layoutObj.musicObj.getLink();
6634
6676
  if (link && link.getHead() === layoutObj.musicObj) {
6635
6677
  let objectParts = [link.getHead(), ...link.getTails()];
6636
6678
  let layoutObjs = rowLayoutObjs.filter((layoutObj2) => objectParts.some((o) => o === layoutObj2.musicObj));
6637
- this.alignObjectsY(ctx, layoutObjs);
6679
+ this.alignObjectsY(ctx, layoutObjs, verticalPos);
6638
6680
  } else {
6639
- this.alignObjectsY(ctx, [layoutObj]);
6681
+ this.alignObjectsY(ctx, [layoutObj], verticalPos);
6640
6682
  }
6641
6683
  });
6642
6684
  }
@@ -6743,7 +6785,7 @@ var ObjStaff = class extends ObjNotationLine5 {
6743
6785
  return diatonicId % 2 !== this.middleLineDiatonicId % 2;
6744
6786
  }
6745
6787
  containsVoiceId(voiceId) {
6746
- return Utils13.Is.isUndefined(this.staffConfig.voiceId) || Utils13.Arr.toArray(this.staffConfig.voiceId).includes(voiceId);
6788
+ return Guard9.isUndefined(this.staffConfig.voiceId) || Utils10.Arr.toArray(this.staffConfig.voiceId).includes(voiceId);
6747
6789
  }
6748
6790
  calcTop() {
6749
6791
  let top = this.topLineY;
@@ -6773,7 +6815,7 @@ var ObjStaff = class extends ObjNotationLine5 {
6773
6815
  let h = unitSize * DocumentSettings.StaffHeight;
6774
6816
  this.topLineY = -h / 2;
6775
6817
  this.bottomLineY = h / 2;
6776
- this.rect = new DivRect(0, 0, this.topLineY, this.bottomLineY);
6818
+ this.rect = new AnchoredRect23(0, 0, this.topLineY, this.bottomLineY);
6777
6819
  }
6778
6820
  layoutWidth(ctx) {
6779
6821
  this.rect.left = this.row.getRect().left;
@@ -6805,7 +6847,7 @@ var ObjTab = class extends ObjNotationLine5 {
6805
6847
  __publicField(this, "tuningName");
6806
6848
  __publicField(this, "tuningStrings");
6807
6849
  __publicField(this, "mi");
6808
- if (Utils13.Is.isArray(tabConfig.tuning)) {
6850
+ if (Guard9.isArray(tabConfig.tuning)) {
6809
6851
  this.tuningName = void 0;
6810
6852
  this.tuningStrings = tabConfig.tuning.map((noteName) => Note8.getNote(noteName)).reverse();
6811
6853
  } else if (typeof tabConfig.tuning === "string") {
@@ -6856,7 +6898,7 @@ var ObjTab = class extends ObjNotationLine5 {
6856
6898
  return this.bottom;
6857
6899
  }
6858
6900
  containsVoiceId(voiceId) {
6859
- return Utils13.Is.isUndefined(this.tabConfig.voiceId) || Utils13.Arr.toArray(this.tabConfig.voiceId).includes(voiceId);
6901
+ return Guard9.isUndefined(this.tabConfig.voiceId) || Utils10.Arr.toArray(this.tabConfig.voiceId).includes(voiceId);
6860
6902
  }
6861
6903
  containsDiatonicId(diatonicId) {
6862
6904
  return true;
@@ -6879,7 +6921,7 @@ var ObjTab = class extends ObjNotationLine5 {
6879
6921
  let h = unitSize * DocumentSettings.TabHeight;
6880
6922
  this.top = -h / 2;
6881
6923
  this.bottom = h / 2;
6882
- this.rect = new DivRect(0, 0, this.top, this.bottom);
6924
+ this.rect = new AnchoredRect23(0, 0, this.top, this.bottom);
6883
6925
  }
6884
6926
  layoutWidth(ctx) {
6885
6927
  this.rect.left = this.row.getRect().left;
@@ -6903,7 +6945,7 @@ var ObjTab = class extends ObjNotationLine5 {
6903
6945
 
6904
6946
  // src/score/engine/obj-score-row.ts
6905
6947
  import { MusicError as MusicError16, MusicErrorType as MusicErrorType16 } from "@tspro/web-music-score/core";
6906
- import { Utils as Utils14 } from "@tspro/ts-utils-lib";
6948
+ import { AnchoredRect as AnchoredRect24, Guard as Guard10, Utils as Utils11 } from "@tspro/ts-utils-lib";
6907
6949
  var ObjScoreRow = class extends MusicObject {
6908
6950
  constructor(doc, prevRow, scoreConfig) {
6909
6951
  super(doc);
@@ -6935,7 +6977,7 @@ var ObjScoreRow = class extends MusicObject {
6935
6977
  }
6936
6978
  this.instrumentLineGroups = lineGroups;
6937
6979
  this.instrumentNames = this.instrumentLineGroups.map((lines) => {
6938
- return lines.length > 0 && Utils14.Is.isNonEmptyString(lines[0].getConfig().instrument) ? new ObjText(this, String(lines[0].getConfig().instrument), 0, 0.5) : void 0;
6980
+ return lines.length > 0 && Guard10.isNonEmptyString(lines[0].getConfig().instrument) ? new ObjText(this, String(lines[0].getConfig().instrument), 0, 0.5) : void 0;
6939
6981
  });
6940
6982
  if (this.prevRow) {
6941
6983
  this.prevRow.nextRow = this;
@@ -6965,7 +7007,7 @@ var ObjScoreRow = class extends MusicObject {
6965
7007
  }
6966
7008
  findMatchingLine(line) {
6967
7009
  return line.row === this ? line : this.notationLines.find(
6968
- (curLine) => Utils14.Obj.deepEqual(line.row.scoreConfig, curLine.row.scoreConfig) && line.id === curLine.id || Utils14.Is.isNonEmptyString(line.getConfig().name) && line.getConfig().name === curLine.getConfig().name && line.getConfig().type === curLine.getConfig().type
7010
+ (curLine) => Utils11.Obj.deepEqual(line.row.scoreConfig, curLine.row.scoreConfig) && line.id === curLine.id || Guard10.isNonEmptyString(line.getConfig().name) && line.getConfig().name === curLine.getConfig().name && line.getConfig().type === curLine.getConfig().type
6969
7011
  );
6970
7012
  }
6971
7013
  getStaves() {
@@ -7041,7 +7083,7 @@ var ObjScoreRow = class extends MusicObject {
7041
7083
  let r = this.getRect();
7042
7084
  let firstMeasure = this.getFirstMeasure();
7043
7085
  let left = firstMeasure ? firstMeasure.getColumnsContentRect().left : r.left;
7044
- return new DivRect(left, (left + r.right) / 2, r.right, r.top, r.centerY, r.bottom);
7086
+ return new AnchoredRect24(left, (left + r.right) / 2, r.right, r.top, r.anchorY, r.bottom);
7045
7087
  }
7046
7088
  getDiatonicIdAt(y) {
7047
7089
  for (let i = 0; i < this.notationLines.length; i++) {
@@ -7091,7 +7133,7 @@ var ObjScoreRow = class extends MusicObject {
7091
7133
  return "up" /* Up */;
7092
7134
  }
7093
7135
  let diatonicIds = noteGroupDiatonicIds.length > 0 ? noteGroupDiatonicIds : restDiatonicIds;
7094
- let avgDiatonicId = Math.floor(Utils14.Math.avg(...diatonicIds));
7136
+ let avgDiatonicId = Math.floor(Utils11.Math.avg(...diatonicIds));
7095
7137
  let staves = this.getStaves().filter((staff) => staff.containsVoiceId(voiceId) && staff.containsDiatonicId(avgDiatonicId));
7096
7138
  return staves.length > 0 ? avgDiatonicId >= staves[0].middleLineDiatonicId ? "down" /* Down */ : "up" /* Up */ : "up" /* Up */;
7097
7139
  }
@@ -7126,7 +7168,7 @@ var ObjScoreRow = class extends MusicObject {
7126
7168
  if (!this.needLayout) {
7127
7169
  return;
7128
7170
  }
7129
- this.rect = new DivRect(0, right, 0, 0);
7171
+ this.rect = new AnchoredRect24(0, right, 0, 0);
7130
7172
  this.notationLines.forEach((line) => line.layoutWidth(ctx));
7131
7173
  let targetColumnsAreaWidth = right - left;
7132
7174
  let minColumnsAreaWidth = 0;
@@ -7140,7 +7182,7 @@ var ObjScoreRow = class extends MusicObject {
7140
7182
  let newMeasureWidth = m.getSolidAreaWidth() + m.getMinColumnsAreaWidth() * columnsAreaScale;
7141
7183
  m.layoutWidth(ctx, newMeasureWidth);
7142
7184
  let r = m.getRect();
7143
- m.offset(x - r.left, -r.centerY);
7185
+ m.offset(x - r.left, -r.anchorY);
7144
7186
  x += r.width;
7145
7187
  x += m.getPostMeasureBreakWidth();
7146
7188
  });
@@ -7154,7 +7196,7 @@ var ObjScoreRow = class extends MusicObject {
7154
7196
  let right = this.measures.length > 0 ? this.measures[this.measures.length - 1].getRect().right : left;
7155
7197
  let top = this.measures.length > 0 ? Math.min(...this.measures.map((m) => m.getRect().top)) : 0;
7156
7198
  let bottom = this.measures.length > 0 ? Math.max(...this.measures.map((m) => m.getRect().bottom)) : 0;
7157
- this.rect = new DivRect(left, right, top, bottom);
7199
+ this.rect = new AnchoredRect24(left, right, top, bottom);
7158
7200
  }
7159
7201
  alignStemsToBeams() {
7160
7202
  this.measures.forEach((m) => m.alignStemsToBeams());
@@ -7189,7 +7231,7 @@ var ObjScoreRow = class extends MusicObject {
7189
7231
  if (obj && grp.length > 0) {
7190
7232
  obj.offset(
7191
7233
  -obj.getRect().left,
7192
- -obj.getRect().centerY + (grp[0].getRect().top + grp[grp.length - 1].getRect().bottom) / 2
7234
+ -obj.getRect().anchorY + (grp[0].getRect().top + grp[grp.length - 1].getRect().bottom) / 2
7193
7235
  );
7194
7236
  }
7195
7237
  });
@@ -7232,7 +7274,7 @@ var ObjScoreRow = class extends MusicObject {
7232
7274
  this.instrumentNames.forEach((obj, i) => {
7233
7275
  let grp = this.instrumentLineGroups[i];
7234
7276
  if (grp.length > 1) {
7235
- let r = new DivRect(
7277
+ let r = new AnchoredRect24(
7236
7278
  grpSize.braceLeft,
7237
7279
  grpSize.braceRight,
7238
7280
  grp[0].getTopLineY(),
@@ -7249,6 +7291,7 @@ var ObjScoreRow = class extends MusicObject {
7249
7291
  };
7250
7292
 
7251
7293
  // src/score/engine/obj-header.ts
7294
+ import { AnchoredRect as AnchoredRect25 } from "@tspro/ts-utils-lib";
7252
7295
  var ObjHeader = class extends MusicObject {
7253
7296
  constructor(doc, title, composer, arranger) {
7254
7297
  super(doc);
@@ -7293,7 +7336,7 @@ var ObjHeader = class extends MusicObject {
7293
7336
  }
7294
7337
  layoutWidth(ctx, left, right) {
7295
7338
  let top = 0;
7296
- this.rect = new DivRect(left, right, 0, 0);
7339
+ this.rect = new AnchoredRect25(left, right, 0, 0);
7297
7340
  if (this.titleText) {
7298
7341
  this.titleText.layout(ctx);
7299
7342
  this.titleText.offset((left + right) / 2, top);
@@ -7339,7 +7382,7 @@ var ObjHeader = class extends MusicObject {
7339
7382
  };
7340
7383
 
7341
7384
  // src/score/engine/obj-document.ts
7342
- import { Utils as Utils15 } from "@tspro/ts-utils-lib";
7385
+ import { AnchoredRect as AnchoredRect26, Guard as Guard11, UniMap as UniMap8 } from "@tspro/ts-utils-lib";
7343
7386
  import { MusicError as MusicError17, MusicErrorType as MusicErrorType17 } from "@tspro/web-music-score/core";
7344
7387
  var ObjDocument = class extends MusicObject {
7345
7388
  constructor() {
@@ -7353,7 +7396,7 @@ var ObjDocument = class extends MusicObject {
7353
7396
  __publicField(this, "header");
7354
7397
  __publicField(this, "newRowRequested", false);
7355
7398
  __publicField(this, "allConnectiveProps", []);
7356
- __publicField(this, "staffGroups", /* @__PURE__ */ new Map());
7399
+ __publicField(this, "staffGroups", new UniMap8());
7357
7400
  __publicField(this, "mi");
7358
7401
  this.mi = new MDocument2(this);
7359
7402
  }
@@ -7361,7 +7404,7 @@ var ObjDocument = class extends MusicObject {
7361
7404
  return this.mi;
7362
7405
  }
7363
7406
  setScoreConfiguration(config) {
7364
- if (Utils15.Is.isEnumValue(config, StaffPreset)) {
7407
+ if (Guard11.isEnumValue(config, StaffPreset)) {
7365
7408
  switch (config) {
7366
7409
  default:
7367
7410
  case "treble" /* Treble */:
@@ -7389,7 +7432,7 @@ var ObjDocument = class extends MusicObject {
7389
7432
  ];
7390
7433
  break;
7391
7434
  }
7392
- } else if (Utils15.Is.isArray(config)) {
7435
+ } else if (Guard11.isArray(config)) {
7393
7436
  this.curScoreConfig = config;
7394
7437
  } else {
7395
7438
  this.curScoreConfig = [config];
@@ -7515,7 +7558,7 @@ var ObjDocument = class extends MusicObject {
7515
7558
  lastRow = this.addNewRow(lastRow);
7516
7559
  this.newRowRequested = false;
7517
7560
  }
7518
- let measure = new ObjMeasure2(lastRow, measureOptions);
7561
+ let measure = new ObjMeasure(lastRow, measureOptions);
7519
7562
  this.measures.push(measure);
7520
7563
  lastRow.addMeasure(measure);
7521
7564
  this.requestLayout();
@@ -7599,7 +7642,7 @@ var ObjDocument = class extends MusicObject {
7599
7642
  this.rows.forEach((row) => row.layoutLayoutGroups(ctx));
7600
7643
  this.rows.forEach((row) => row.layoutSetNotationLines(ctx));
7601
7644
  this.rows.forEach((row) => row.layoutPadding(ctx));
7602
- this.rect = new DivRect();
7645
+ this.rect = new AnchoredRect26();
7603
7646
  if (this.header) {
7604
7647
  this.header.layoutWidth(ctx, left, right);
7605
7648
  this.rect.expandInPlace(this.header.getRect());
@@ -7661,126 +7704,106 @@ var ObjDocument = class extends MusicObject {
7661
7704
  };
7662
7705
 
7663
7706
  // src/score/pub/document-builder.ts
7664
- import { BeamGrouping, KeySignature as KeySignature3, Note as Note10, NoteLength as NoteLength8, RhythmProps as RhythmProps6, Scale as Scale2, ScaleType, SymbolSet as SymbolSet2, TimeSignature as TimeSignature2, TimeSignatures, TuningNameList, validateNoteLength as validateNoteLength3, validateTupletRatio } from "@tspro/web-music-score/theory";
7707
+ import { BeamGrouping, isNoteLength, isTupletRatio, KeySignature as KeySignature3, Note as Note10, NoteLength as NoteLength8, RhythmProps as RhythmProps6, Scale as Scale2, ScaleType, SymbolSet as SymbolSet2, TimeSignature as TimeSignature2, TimeSignatures, TuningNameList } from "@tspro/web-music-score/theory";
7665
7708
  import { MusicError as MusicError18, MusicErrorType as MusicErrorType18 } from "@tspro/web-music-score/core";
7666
- function assertArg(condition, argName, argValue) {
7667
- if (!condition) {
7668
- throw new MusicError18(MusicErrorType18.Score, `Invalid arg: ${argName} = ${argValue}`);
7669
- }
7670
- }
7671
- function isNote(note) {
7672
- if (typeof note !== "string") {
7673
- return false;
7674
- } else {
7675
- let p = Note10.parseNote(note);
7676
- return p !== void 0 && p.octave !== void 0;
7677
- }
7709
+ var assertingFunction = "";
7710
+ function setAssertFunction(fnName, ...fnArgs) {
7711
+ let argsStr = fnArgs.map((arg) => JSON.stringify(arg)).join(", ");
7712
+ assertingFunction = `DocumentBuilder.${fnName}(${argsStr})`;
7678
7713
  }
7679
- function isVoiceId(value) {
7680
- return Utils16.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
7681
- }
7682
- function isStringNumber(value) {
7683
- return Utils16.Is.isNumber(value) && getStringNumbers().indexOf(value) >= 0;
7714
+ function assertArg(...conditions) {
7715
+ conditions.forEach((condition) => {
7716
+ if (!condition) throw new MusicError18(MusicErrorType18.Score, assertingFunction);
7717
+ });
7684
7718
  }
7685
- function isVerseNumber(value) {
7686
- return Utils16.Is.isNumber(value) && getVerseNumbers().indexOf(value) >= 0;
7719
+ function assertArgMsg(condition, msg) {
7720
+ if (!condition) throw new MusicError18(MusicErrorType18.Score, msg);
7687
7721
  }
7688
7722
  function assertBaseConfig(baseConfig) {
7689
7723
  var _a;
7690
- assertArg(Utils16.Is.isObject(baseConfig), "baseConfig", baseConfig);
7691
- assertArg(Utils16.Is.isStringOrUndefined(baseConfig.name), "baseConfig.name", baseConfig.name);
7692
- assertArg(Utils16.Is.isUndefined(baseConfig.voiceId) || isVoiceId(baseConfig.voiceId) || Utils16.Is.isArray(baseConfig.voiceId) && baseConfig.voiceId.every((voiceId) => isVoiceId(voiceId)), "baseConfig.voiceId", baseConfig.voiceId);
7693
- if (!Utils16.Is.isUndefined(baseConfig.voiceIds)) {
7694
- assertArg(isVoiceId(baseConfig.voiceIds) || Utils16.Is.isArray(baseConfig.voiceIds) && baseConfig.voiceIds.every((voiceId) => isVoiceId(voiceId)), "baseConfig.voiceIds", baseConfig.voiceIds);
7724
+ assertArg(
7725
+ Guard12.isObject(baseConfig),
7726
+ Guard12.isStringOrUndefined(baseConfig.name),
7727
+ Guard12.isUndefined(baseConfig.voiceId) || isVoiceId(baseConfig.voiceId) || Guard12.isArray(baseConfig.voiceId) && baseConfig.voiceId.every((voiceId) => isVoiceId(voiceId))
7728
+ );
7729
+ if (!Guard12.isUndefined(baseConfig.voiceIds)) {
7730
+ assertArg(isVoiceId(baseConfig.voiceIds) || Guard12.isArray(baseConfig.voiceIds) && baseConfig.voiceIds.every((voiceId) => isVoiceId(voiceId)));
7695
7731
  console.warn(`Staff/tab config property 'voiceIds' is deprecated, use 'voiceId' instead.`);
7696
- let arr = Utils16.Arr.toArray((_a = baseConfig.voiceId) != null ? _a : []);
7697
- Utils16.Arr.toArray(baseConfig.voiceIds).forEach((voiceId) => arr.push(voiceId));
7732
+ let arr = Utils12.Arr.toArray((_a = baseConfig.voiceId) != null ? _a : []);
7733
+ Utils12.Arr.toArray(baseConfig.voiceIds).forEach((voiceId) => arr.push(voiceId));
7698
7734
  baseConfig.voiceId = arr;
7699
7735
  }
7700
- if (Utils16.Is.isArray(baseConfig.voiceId)) {
7701
- baseConfig.voiceId = Utils16.Arr.removeDuplicates(baseConfig.voiceId);
7736
+ if (Guard12.isArray(baseConfig.voiceId)) {
7737
+ baseConfig.voiceId = Utils12.Arr.removeDuplicates(baseConfig.voiceId);
7702
7738
  }
7703
- assertArg(Utils16.Is.isStringOrUndefined(baseConfig.instrument), "baseConfig.instrument", baseConfig.instrument);
7739
+ assertArg(Guard12.isStringOrUndefined(baseConfig.instrument));
7704
7740
  }
7705
7741
  function assertStaffConfig(staffConfig) {
7706
7742
  assertBaseConfig(staffConfig);
7707
- assertArg(Utils16.Is.isObject(staffConfig), "staffConfig", staffConfig);
7708
- assertArg(staffConfig.type === "staff", "staffConfig.type", staffConfig.type);
7709
- assertArg(Utils16.Is.isEnumValue(staffConfig.clef, Clef), "staffConfig.clef", staffConfig.clef);
7710
- assertArg(Utils16.Is.isBooleanOrUndefined(staffConfig.isOctaveDown), "staffConfig.isOctaveDown", staffConfig.isOctaveDown);
7711
- assertArg(Utils16.Is.isUndefined(staffConfig.minNote) || isNote(staffConfig.minNote), "staffConfig.minNote", staffConfig.minNote);
7712
- assertArg(Utils16.Is.isUndefined(staffConfig.maxNote) || isNote(staffConfig.maxNote), "staffConfig.maxNote", staffConfig.maxNote);
7713
- assertArg(Utils16.Is.isStringOrUndefined(staffConfig.grandId), "staffConfig.grandId", staffConfig.grandId);
7714
- assertArg(Utils16.Is.isBooleanOrUndefined(staffConfig.isGrand), "staffConfig.isGrand", staffConfig.isGrand);
7715
- if (!Utils16.Is.isUndefined(staffConfig.isGrand)) {
7743
+ assertArg(
7744
+ Guard12.isObject(staffConfig),
7745
+ Guard12.isStrictEqual(staffConfig.type, "staff"),
7746
+ Guard12.isEnumValue(staffConfig.clef, Clef),
7747
+ Guard12.isBooleanOrUndefined(staffConfig.isOctaveDown),
7748
+ Guard12.isUndefined(staffConfig.minNote) || Note10.isNote(staffConfig.minNote),
7749
+ Guard12.isUndefined(staffConfig.maxNote) || Note10.isNote(staffConfig.maxNote),
7750
+ Guard12.isStringOrUndefined(staffConfig.grandId),
7751
+ Guard12.isBooleanOrUndefined(staffConfig.isGrand)
7752
+ );
7753
+ if (!Guard12.isUndefined(staffConfig.isGrand))
7716
7754
  console.warn(`Staff config property 'isGrand' is deprecated, use 'grandId' instead.`);
7717
- }
7718
7755
  }
7719
7756
  function assertTabConfig(tabConfig) {
7720
7757
  assertBaseConfig(tabConfig);
7721
- assertArg(Utils16.Is.isObject(tabConfig), "tabConfig", tabConfig);
7722
- assertArg(tabConfig.type === "tab", "tabConfig.type", tabConfig.type);
7723
- if (Utils16.Is.isString(tabConfig.tuning)) {
7724
- assertArg(TuningNameList.includes(tabConfig.tuning), "tabConfig.tuning", tabConfig.tuning);
7725
- } else if (Utils16.Is.isArray(tabConfig.tuning)) {
7726
- assertArg(tabConfig.tuning.length === getStringNumbers().length && tabConfig.tuning.every((s) => isNote(s)), "tabConfig.tuning", tabConfig.tuning);
7727
- }
7758
+ assertArg(
7759
+ Guard12.isObject(tabConfig),
7760
+ Guard12.isStrictEqual(tabConfig.type, "tab"),
7761
+ Guard12.isUndefined(tabConfig.tuning) || Guard12.isString(tabConfig.tuning) && Guard12.isIncluded(tabConfig.tuning, TuningNameList) || Guard12.isArray(tabConfig.tuning) && Guard12.isStrictEqual(tabConfig.tuning.length, getStringNumbers().length && tabConfig.tuning.every((s) => Note10.isNote(s)))
7762
+ );
7728
7763
  }
7729
7764
  function assertNoteOptions(noteOptions) {
7730
- assertArg(Utils16.Is.isObject(noteOptions), "noteOptions", noteOptions);
7731
- assertArg(Utils16.Is.isBooleanOrUndefined(noteOptions.dotted) || Utils16.Is.isIntegerGte(noteOptions.dotted, 0), "noteOptions.dotted", noteOptions.dotted);
7732
- assertArg(Utils16.Is.isEnumValueOrUndefined(noteOptions.stem, Stem), "noteOptions.stem", noteOptions.stem);
7733
- assertArg(Utils16.Is.isStringOrUndefined(noteOptions.color), "noteOptions.color", noteOptions.color);
7734
- assertArg(Utils16.Is.isBooleanOrUndefined(noteOptions.arpeggio) || Utils16.Is.isEnumValue(noteOptions.arpeggio, Arpeggio), "noteOptions.arpeggio", noteOptions.arpeggio);
7735
- assertArg(Utils16.Is.isBooleanOrUndefined(noteOptions.staccato), "noteOptions.staccato", noteOptions.staccato);
7736
- assertArg(Utils16.Is.isBooleanOrUndefined(noteOptions.diamond), "noteOptions.diamond", noteOptions.diamond);
7737
- assertArg(Utils16.Is.isBooleanOrUndefined(noteOptions.triplet), "noteOptions.triplet", noteOptions.triplet);
7738
- assertArg(Utils16.Is.isUndefined(noteOptions.string) || isStringNumber(noteOptions.string) || Utils16.Is.isNonEmptyArray(noteOptions.string) && noteOptions.string.every((string) => isStringNumber(string)), "noteOptions.string", noteOptions.string);
7739
- assertArg(Utils16.Is.isUndefined(noteOptions.tieSpan), 'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)', "");
7740
- assertArg(Utils16.Is.isUndefined(noteOptions.slurSpan), 'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)', "");
7765
+ assertArg(
7766
+ Guard12.isObject(noteOptions),
7767
+ Guard12.isBooleanOrUndefined(noteOptions.dotted) || Guard12.isIntegerGte(noteOptions.dotted, 0),
7768
+ Guard12.isEnumValueOrUndefined(noteOptions.stem, Stem),
7769
+ Guard12.isStringOrUndefined(noteOptions.color),
7770
+ Guard12.isBooleanOrUndefined(noteOptions.arpeggio) || Guard12.isEnumValue(noteOptions.arpeggio, Arpeggio),
7771
+ Guard12.isBooleanOrUndefined(noteOptions.staccato),
7772
+ Guard12.isBooleanOrUndefined(noteOptions.diamond),
7773
+ Guard12.isBooleanOrUndefined(noteOptions.triplet),
7774
+ Guard12.isUndefined(noteOptions.string) || isStringNumber(noteOptions.string) || Guard12.isEmptyArray(noteOptions.string) || Guard12.isNonEmptyArray(noteOptions.string) && noteOptions.string.every((string) => isStringNumber(string))
7775
+ );
7776
+ assertArgMsg(Guard12.isUndefined(noteOptions.tieSpan), `NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)`);
7777
+ assertArgMsg(Guard12.isUndefined(noteOptions.slurSpan), `NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)`);
7741
7778
  }
7742
7779
  function assertRestOptions(restOptions) {
7743
- assertArg(Utils16.Is.isObject(restOptions), "restOptions", restOptions);
7744
- assertArg(Utils16.Is.isBooleanOrUndefined(restOptions.dotted) || Utils16.Is.isIntegerGte(restOptions.dotted, 0), "restOptions.dotted", restOptions.dotted);
7745
- assertArg(Utils16.Is.isStringOrUndefined(restOptions.staffPos) || Utils16.Is.isInteger(restOptions.staffPos) || restOptions.staffPos instanceof Note10, "restOptions.staffPos", restOptions.staffPos);
7746
- assertArg(Utils16.Is.isStringOrUndefined(restOptions.color), "restOptions.color", restOptions.color);
7747
- assertArg(Utils16.Is.isBooleanOrUndefined(restOptions.hide), "restOptions.hide", restOptions.hide);
7748
- assertArg(Utils16.Is.isBooleanOrUndefined(restOptions.triplet), "restOptions.triplet", restOptions.triplet);
7780
+ assertArg(
7781
+ Guard12.isObject(restOptions),
7782
+ Guard12.isBooleanOrUndefined(restOptions.dotted) || Guard12.isIntegerGte(restOptions.dotted, 0),
7783
+ Guard12.isStringOrUndefined(restOptions.staffPos) || Guard12.isInteger(restOptions.staffPos) || restOptions.staffPos instanceof Note10,
7784
+ Guard12.isStringOrUndefined(restOptions.color),
7785
+ Guard12.isBooleanOrUndefined(restOptions.hide),
7786
+ Guard12.isBooleanOrUndefined(restOptions.triplet)
7787
+ );
7749
7788
  }
7750
7789
  function assertLyricsOptions(lyricsOptions) {
7751
- assertArg(Utils16.Is.isObject(lyricsOptions), "lyricsOptions", lyricsOptions);
7752
- assertArg(Utils16.Is.isEnumValueOrUndefined(lyricsOptions.align, LyricsAlign), "lyricsOptions.align", lyricsOptions.align);
7753
- assertArg(Utils16.Is.isEnumValueOrUndefined(lyricsOptions.hyphen, LyricsHyphen), "lyricsOptions.hyphen", lyricsOptions.hyphen);
7790
+ assertArg(
7791
+ Guard12.isObject(lyricsOptions),
7792
+ Guard12.isEnumValueOrUndefined(lyricsOptions.align, LyricsAlign),
7793
+ Guard12.isEnumValueOrUndefined(lyricsOptions.hyphen, LyricsHyphen)
7794
+ );
7754
7795
  }
7755
7796
  function assertMeasureOptions(measureOptions) {
7756
- assertArg(Utils16.Is.isObject(measureOptions), "measureOptions", measureOptions);
7757
- assertArg(Utils16.Is.isBooleanOrUndefined(measureOptions.showNumber), "measureOptions.showNumber", measureOptions.showNumber);
7797
+ assertArg(
7798
+ Guard12.isObject(measureOptions),
7799
+ Guard12.isBooleanOrUndefined(measureOptions.showNumber)
7800
+ );
7758
7801
  }
7759
7802
  function assertStaffTabOrGRoups(staffTabOrGroups) {
7760
7803
  assertArg(
7761
- Utils16.Is.isStringOrUndefined(staffTabOrGroups) || Utils16.Is.isIntegerGte(staffTabOrGroups, 0) || Utils16.Is.isNonEmptyArray(staffTabOrGroups) && staffTabOrGroups.every(
7762
- (staffTabOrGroup) => Utils16.Is.isString(staffTabOrGroup) || Utils16.Is.isIntegerGte(staffTabOrGroup, 0)
7763
- ),
7764
- "staffTabOrGroup",
7765
- staffTabOrGroups
7804
+ Guard12.isStringOrUndefined(staffTabOrGroups) || Guard12.isIntegerGte(staffTabOrGroups, 0) || Guard12.isNonEmptyArray(staffTabOrGroups) && staffTabOrGroups.every((staffTabOrGroup) => Guard12.isString(staffTabOrGroup) || Guard12.isIntegerGte(staffTabOrGroup, 0))
7766
7805
  );
7767
7806
  }
7768
- function isNoteLength(noteLen) {
7769
- try {
7770
- validateNoteLength3(noteLen);
7771
- return true;
7772
- } catch (e) {
7773
- return false;
7774
- }
7775
- }
7776
- function isTupletRatio(tupletRatio) {
7777
- try {
7778
- validateTupletRatio(tupletRatio);
7779
- return true;
7780
- } catch (e) {
7781
- return false;
7782
- }
7783
- }
7784
7807
  var _DocumentBuilder = class _DocumentBuilder {
7785
7808
  /**
7786
7809
  * Create new document builder instance.
@@ -7791,27 +7814,28 @@ var _DocumentBuilder = class _DocumentBuilder {
7791
7814
  this.doc = new ObjDocument();
7792
7815
  }
7793
7816
  setScoreConfiguration(config) {
7794
- if (Utils16.Is.isEnumValue(config, StaffPreset)) {
7817
+ setAssertFunction("setScoreConfiguration", config);
7818
+ if (Guard12.isEnumValue(config, StaffPreset)) {
7795
7819
  this.doc.setScoreConfiguration(config);
7796
- } else if (Utils16.Is.isObject(config) && config.type === "staff") {
7820
+ } else if (Guard12.isObject(config) && config.type === "staff") {
7797
7821
  assertStaffConfig(config);
7798
7822
  this.doc.setScoreConfiguration(config);
7799
- } else if (Utils16.Is.isObject(config) && config.type === "tab") {
7823
+ } else if (Guard12.isObject(config) && config.type === "tab") {
7800
7824
  assertTabConfig(config);
7801
7825
  this.doc.setScoreConfiguration(config);
7802
- } else if (Utils16.Is.isNonEmptyArray(config)) {
7826
+ } else if (Guard12.isNonEmptyArray(config)) {
7803
7827
  config.forEach((c) => {
7804
- if (Utils16.Is.isObject(c) && c.type === "staff") {
7828
+ if (Guard12.isObject(c) && c.type === "staff") {
7805
7829
  assertStaffConfig(c);
7806
- } else if (Utils16.Is.isObject(c) && c.type === "tab") {
7830
+ } else if (Guard12.isObject(c) && c.type === "tab") {
7807
7831
  assertTabConfig(c);
7808
7832
  } else {
7809
- assertArg(false, "config", config);
7833
+ assertArg(false);
7810
7834
  }
7811
7835
  });
7812
7836
  this.doc.setScoreConfiguration(config);
7813
7837
  } else {
7814
- assertArg(false, "config", config);
7838
+ assertArg(false);
7815
7839
  }
7816
7840
  return this;
7817
7841
  }
@@ -7834,9 +7858,12 @@ var _DocumentBuilder = class _DocumentBuilder {
7834
7858
  * @returns - This document builder instance.
7835
7859
  */
7836
7860
  setHeader(title, composer, arranger) {
7837
- assertArg(Utils16.Is.isStringOrUndefined(title), "title", title);
7838
- assertArg(Utils16.Is.isStringOrUndefined(composer), "composer", composer);
7839
- assertArg(Utils16.Is.isStringOrUndefined(arranger), "arranger", arranger);
7861
+ setAssertFunction("setHeader", title, composer, arranger);
7862
+ assertArg(
7863
+ Guard12.isStringOrUndefined(title),
7864
+ Guard12.isStringOrUndefined(composer),
7865
+ Guard12.isStringOrUndefined(arranger)
7866
+ );
7840
7867
  this.doc.setHeader(title, composer, arranger);
7841
7868
  return this;
7842
7869
  }
@@ -7846,7 +7873,8 @@ var _DocumentBuilder = class _DocumentBuilder {
7846
7873
  * @returns - This document builder instance.
7847
7874
  */
7848
7875
  setMeasuresPerRow(measuresPerRow) {
7849
- assertArg(Utils16.Is.isIntegerGte(measuresPerRow, 1) || Utils16.Is.isPosInfinity(measuresPerRow), "measuresPerRow", measuresPerRow);
7876
+ setAssertFunction("setMeasuresPerRow", measuresPerRow);
7877
+ assertArg(Guard12.isIntegerGte(measuresPerRow, 1) || Guard12.isPosInfinity(measuresPerRow));
7850
7878
  this.doc.setMeasuresPerRow(measuresPerRow);
7851
7879
  return this;
7852
7880
  }
@@ -7856,36 +7884,37 @@ var _DocumentBuilder = class _DocumentBuilder {
7856
7884
  * @returns - This document builder instance.
7857
7885
  */
7858
7886
  addMeasure(measureOptions) {
7887
+ setAssertFunction("addMeasure", measureOptions);
7859
7888
  measureOptions != null ? measureOptions : measureOptions = {};
7860
7889
  assertMeasureOptions(measureOptions);
7861
7890
  this.doc.addMeasure(measureOptions);
7862
7891
  return this;
7863
7892
  }
7864
7893
  setKeySignature(...args) {
7865
- assertArg(args[0] instanceof Scale2 || args[0] instanceof KeySignature3 || Utils16.Is.isNonEmptyString(args[0]) && (args.length === 1 || Utils16.Is.isEnumValue(args[1], ScaleType)), "keySignature", args);
7894
+ setAssertFunction("setKeySignature", ...args);
7895
+ assertArg(args[0] instanceof Scale2 || args[0] instanceof KeySignature3 || Guard12.isNonEmptyString(args[0]) && Guard12.isEnumValueOrUndefined(args[1], ScaleType));
7866
7896
  this.getMeasure().setKeySignature(...args);
7867
7897
  return this;
7868
7898
  }
7869
7899
  setTimeSignature(...args) {
7900
+ setAssertFunction("setTimeSignature", ...args);
7870
7901
  if (args[0] instanceof TimeSignature2) {
7871
7902
  this.getMeasure().setTimeSignature(args[0]);
7872
- } else if (Utils16.Is.isEnumValue(args[0], TimeSignatures) && Utils16.Is.isEnumValueOrUndefined(args[1], BeamGrouping)) {
7903
+ } else if (Guard12.isEnumValue(args[0], TimeSignatures) && Guard12.isEnumValueOrUndefined(args[1], BeamGrouping)) {
7873
7904
  this.getMeasure().setTimeSignature(new TimeSignature2(args[0], args[1]));
7874
- } else if (Utils16.Is.isIntegerGte(args[0], 1) && Utils16.Is.isIntegerGte(args[1], 1) && Utils16.Is.isEnumValueOrUndefined(args[2], BeamGrouping)) {
7905
+ } else if (Guard12.isIntegerGte(args[0], 1) && Guard12.isIntegerGte(args[1], 1) && Guard12.isEnumValueOrUndefined(args[2], BeamGrouping)) {
7875
7906
  this.getMeasure().setTimeSignature(new TimeSignature2(args[0], args[1], args[2]));
7876
7907
  } else {
7877
- assertArg(false, "timeSignature args", args);
7908
+ assertArg(false);
7878
7909
  }
7879
7910
  return this;
7880
7911
  }
7881
7912
  setTempo(beatsPerMinute, beatLength, dotted) {
7882
- assertArg(Utils16.Is.isIntegerGte(beatsPerMinute, 1), "beatsPerMinute", beatsPerMinute);
7883
- if (beatLength === void 0) {
7884
- assertArg(Utils16.Is.isUndefined(dotted), "dotted", dotted);
7885
- } else {
7886
- assertArg(Utils16.Is.isEnumValue(beatLength, NoteLength8) || isNoteLength(beatLength), "beatLength", beatLength);
7887
- assertArg(Utils16.Is.isBooleanOrUndefined(dotted) || Utils16.Is.isIntegerGte(dotted, 0), "dotted", dotted);
7888
- }
7913
+ setAssertFunction("setTempo", beatsPerMinute, beatLength, dotted);
7914
+ assertArg(
7915
+ Guard12.isIntegerGte(beatsPerMinute, 1),
7916
+ Guard12.isUndefined(beatLength) && Guard12.isUndefined(dotted) || isNoteLength(beatLength) && (Guard12.isBooleanOrUndefined(dotted) || Guard12.isIntegerGte(dotted, 0))
7917
+ );
7889
7918
  this.getMeasure().setTempo(beatsPerMinute, beatLength, dotted);
7890
7919
  return this;
7891
7920
  }
@@ -7898,19 +7927,18 @@ var _DocumentBuilder = class _DocumentBuilder {
7898
7927
  * @returns - This document builder instance.
7899
7928
  */
7900
7929
  addNote(voiceId, note, noteLength, noteOptions) {
7901
- assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7930
+ setAssertFunction("addNote", voiceId, note, noteLength, noteOptions);
7902
7931
  assertArg(
7903
- note instanceof Note10 || Utils16.Is.isNonEmptyString(note) || Utils16.Is.isArray(note) && note.every((note2) => note2 instanceof Note10 || Utils16.Is.isNonEmptyString(note2)),
7904
- "note",
7905
- note
7932
+ isVoiceId(voiceId),
7933
+ note instanceof Note10 || Guard12.isNonEmptyString(note) || Guard12.isArray(note) && note.every((note2) => note2 instanceof Note10 || Guard12.isNonEmptyString(note2)),
7934
+ isNoteLength(noteLength)
7906
7935
  );
7907
- assertArg(Utils16.Is.isEnumValue(noteLength, NoteLength8) || isNoteLength(noteLength), "noteLength", noteLength);
7908
7936
  noteOptions != null ? noteOptions : noteOptions = {};
7909
7937
  assertNoteOptions(noteOptions);
7910
- if (Utils16.Is.isArray(note)) {
7938
+ if (Guard12.isArray(note)) {
7911
7939
  let string = noteOptions.string;
7912
7940
  note.forEach((note2, noteId) => {
7913
- noteOptions.string = Utils16.Is.isArray(string) ? string[noteId] : string;
7941
+ noteOptions.string = Guard12.isArray(string) ? string[noteId] : string;
7914
7942
  this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions);
7915
7943
  });
7916
7944
  } else {
@@ -7927,9 +7955,12 @@ var _DocumentBuilder = class _DocumentBuilder {
7927
7955
  * @returns - This document builder instance.
7928
7956
  */
7929
7957
  addChord(voiceId, notes, noteLength, noteOptions) {
7930
- assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7931
- assertArg(Utils16.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof Note10 || Utils16.Is.isNonEmptyString(note)), "notes", notes);
7932
- assertArg(Utils16.Is.isEnumValue(noteLength, NoteLength8) || isNoteLength(noteLength), "noteLength", noteLength);
7958
+ setAssertFunction("addChord", voiceId, notes, noteLength, noteOptions);
7959
+ assertArg(
7960
+ isVoiceId(voiceId),
7961
+ Guard12.isNonEmptyArray(notes) && notes.every((note) => note instanceof Note10 || Guard12.isNonEmptyString(note)),
7962
+ isNoteLength(noteLength)
7963
+ );
7933
7964
  noteOptions != null ? noteOptions : noteOptions = {};
7934
7965
  assertNoteOptions(noteOptions);
7935
7966
  this.getMeasure().addNoteGroup(voiceId, notes, noteLength, noteOptions);
@@ -7943,8 +7974,11 @@ var _DocumentBuilder = class _DocumentBuilder {
7943
7974
  * @returns - This document builder instance.
7944
7975
  */
7945
7976
  addRest(voiceId, restLength, restOptions) {
7946
- assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7947
- assertArg(Utils16.Is.isEnumValue(restLength, NoteLength8) || isNoteLength(restLength), "restLength", restLength);
7977
+ setAssertFunction("addRest", voiceId, restLength, restOptions);
7978
+ assertArg(
7979
+ isVoiceId(voiceId),
7980
+ isNoteLength(restLength)
7981
+ );
7948
7982
  restOptions != null ? restOptions : restOptions = {};
7949
7983
  assertRestOptions(restOptions);
7950
7984
  this.getMeasure().addRest(voiceId, restLength, restOptions);
@@ -7966,25 +8000,27 @@ var _DocumentBuilder = class _DocumentBuilder {
7966
8000
  * @returns - This document builder instance.
7967
8001
  */
7968
8002
  addTuplet(voiceId, tupletRatio, tupletBuilder) {
7969
- assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7970
- assertArg(Utils16.Is.isFunction(tupletBuilder), "tupletBuilder", tupletBuilder);
7971
- assertArg(isTupletRatio(tupletRatio) && Utils16.Is.isBooleanOrUndefined(tupletRatio.showRatio), "tupletRatio", tupletRatio);
8003
+ setAssertFunction("addTuplet", voiceId, tupletRatio);
8004
+ assertArg(
8005
+ isVoiceId(voiceId),
8006
+ Guard12.isFunction(tupletBuilder),
8007
+ isTupletRatio(tupletRatio) && Guard12.isBooleanOrUndefined(tupletRatio.showRatio)
8008
+ );
7972
8009
  let tupletSymbols = [];
7973
8010
  const helper = {
7974
8011
  addNote: (note, noteLength, noteOptions) => {
8012
+ setAssertFunction("addTuplet => addNote", note, noteLength, noteOptions);
7975
8013
  assertArg(
7976
- note instanceof Note10 || Utils16.Is.isNonEmptyString(note) || Utils16.Is.isArray(note) && note.every((note2) => note2 instanceof Note10 || Utils16.Is.isNonEmptyString(note2)),
7977
- "note",
7978
- note
8014
+ note instanceof Note10 || Guard12.isNonEmptyString(note) || Guard12.isArray(note) && note.every((note2) => note2 instanceof Note10 || Guard12.isNonEmptyString(note2)),
8015
+ isNoteLength(noteLength)
7979
8016
  );
7980
- assertArg(Utils16.Is.isEnumValue(noteLength, NoteLength8) || isNoteLength(noteLength), "noteLength", noteLength);
7981
8017
  noteOptions != null ? noteOptions : noteOptions = {};
7982
8018
  delete noteOptions.triplet;
7983
8019
  assertNoteOptions(noteOptions);
7984
- if (Utils16.Is.isArray(note)) {
8020
+ if (Guard12.isArray(note)) {
7985
8021
  let string = noteOptions.string;
7986
8022
  note.forEach((note2, noteId) => {
7987
- noteOptions.string = Utils16.Is.isArray(string) ? string[noteId] : string;
8023
+ noteOptions.string = Guard12.isArray(string) ? string[noteId] : string;
7988
8024
  let s = this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions, tupletRatio);
7989
8025
  tupletSymbols.push(s);
7990
8026
  });
@@ -7995,8 +8031,11 @@ var _DocumentBuilder = class _DocumentBuilder {
7995
8031
  return helper;
7996
8032
  },
7997
8033
  addChord: (notes, noteLength, noteOptions) => {
7998
- assertArg(Utils16.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof Note10 || Utils16.Is.isNonEmptyString(note)), "notes", notes);
7999
- assertArg(Utils16.Is.isEnumValue(noteLength, NoteLength8) || isNoteLength(noteLength), "noteLength", noteLength);
8034
+ setAssertFunction("addTuplet => addChord", notes, noteLength, noteOptions);
8035
+ assertArg(
8036
+ Guard12.isNonEmptyArray(notes) && notes.every((note) => note instanceof Note10 || Guard12.isNonEmptyString(note)),
8037
+ isNoteLength(noteLength)
8038
+ );
8000
8039
  noteOptions != null ? noteOptions : noteOptions = {};
8001
8040
  delete noteOptions.triplet;
8002
8041
  assertNoteOptions(noteOptions);
@@ -8005,7 +8044,8 @@ var _DocumentBuilder = class _DocumentBuilder {
8005
8044
  return helper;
8006
8045
  },
8007
8046
  addRest: (restLength, restOptions) => {
8008
- assertArg(Utils16.Is.isEnumValue(restLength, NoteLength8) || isNoteLength(restLength), "restLength", restLength);
8047
+ setAssertFunction("addTuplet => addRest", restLength, restOptions);
8048
+ assertArg(isNoteLength(restLength));
8009
8049
  restOptions != null ? restOptions : restOptions = {};
8010
8050
  delete restOptions.triplet;
8011
8051
  assertRestOptions(restOptions);
@@ -8021,9 +8061,11 @@ var _DocumentBuilder = class _DocumentBuilder {
8021
8061
  addLyricsInternal(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions) {
8022
8062
  var _a;
8023
8063
  assertStaffTabOrGRoups(staffTabOrGroups);
8024
- assertArg(isVerseNumber(verse), "verse", verse);
8025
- assertArg(Utils16.Is.isEnumValue(lyricsLength, NoteLength8), "lyricsLength", lyricsLength);
8026
- assertArg(Utils16.Is.isString(lyricsText) || Utils16.Is.isArray(lyricsText) && lyricsText.every((text) => Utils16.Is.isString(text)), "lyricsText", lyricsText);
8064
+ assertArg(
8065
+ isVerseNumber(verse),
8066
+ Guard12.isEnumValue(lyricsLength, NoteLength8),
8067
+ Guard12.isString(lyricsText) || Guard12.isArray(lyricsText) && lyricsText.every((text) => Guard12.isString(text))
8068
+ );
8027
8069
  lyricsOptions != null ? lyricsOptions : lyricsOptions = {};
8028
8070
  assertLyricsOptions(lyricsOptions);
8029
8071
  if (lyricsOptions.align !== void 0) {
@@ -8031,7 +8073,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8031
8073
  } else {
8032
8074
  (_a = lyricsOptions.align) != null ? _a : lyricsOptions.align = this.currentLyricsAlign;
8033
8075
  }
8034
- if (Utils16.Is.isArray(lyricsText)) {
8076
+ if (Guard12.isArray(lyricsText)) {
8035
8077
  lyricsText.forEach((text) => this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, text, lyricsOptions));
8036
8078
  } else {
8037
8079
  this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions);
@@ -8047,6 +8089,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8047
8089
  * @returns - This document builder instance.
8048
8090
  */
8049
8091
  addLyrics(verse, lyricsLength, lyricsText, lyricsOptions) {
8092
+ setAssertFunction("addLyrics", verse, lyricsLength, lyricsText, lyricsOptions);
8050
8093
  return this.addLyricsInternal(void 0, verse, lyricsLength, lyricsText != null ? lyricsText : "", lyricsOptions);
8051
8094
  }
8052
8095
  /**
@@ -8059,11 +8102,12 @@ var _DocumentBuilder = class _DocumentBuilder {
8059
8102
  * @returns - This document builder instance.
8060
8103
  */
8061
8104
  addLyricsTo(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions) {
8105
+ setAssertFunction("addLyricsTo", verse, lyricsLength, lyricsText, lyricsOptions);
8062
8106
  return this.addLyricsInternal(staffTabOrGroups, verse, lyricsLength, lyricsText != null ? lyricsText : "", lyricsOptions);
8063
8107
  }
8064
8108
  addFermataInternal(staffTabOrGroups, fermata) {
8065
8109
  assertStaffTabOrGRoups(staffTabOrGroups);
8066
- assertArg(Utils16.Is.isEnumValue(fermata, Fermata), "fermata", fermata);
8110
+ assertArg(Guard12.isEnumValue(fermata, Fermata));
8067
8111
  this.getMeasure().addFermata(staffTabOrGroups, fermata);
8068
8112
  return this;
8069
8113
  }
@@ -8073,6 +8117,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8073
8117
  * @returns - This document builder instance.
8074
8118
  */
8075
8119
  addFermata(fermata = "atNote" /* AtNote */) {
8120
+ setAssertFunction("addFermata", fermata);
8076
8121
  return this.addFermataInternal(void 0, fermata);
8077
8122
  }
8078
8123
  /**
@@ -8082,23 +8127,23 @@ var _DocumentBuilder = class _DocumentBuilder {
8082
8127
  * @returns - This document builder instance.
8083
8128
  */
8084
8129
  addFermataTo(staffTabOrGroups, fermata = "atNote" /* AtNote */) {
8130
+ setAssertFunction("addFermataTo", staffTabOrGroups, fermata);
8085
8131
  return this.addFermataInternal(staffTabOrGroups, fermata);
8086
8132
  }
8087
8133
  addNavigationInternal(staffTabOrGroups, navigation, ...args) {
8088
8134
  assertStaffTabOrGRoups(staffTabOrGroups);
8089
- assertArg(Utils16.Is.isEnumValue(navigation, Navigation), "navigation", navigation);
8090
- if (navigation === "endRepeat" /* EndRepeat */ && args.length > 0) {
8091
- assertArg(Utils16.Is.isIntegerGte(args[0], 1), "playCount", args[0]);
8092
- } else if (navigation === "ending" /* Ending */ && args.length > 0) {
8093
- assertArg(args.every((passage) => Utils16.Is.isIntegerGte(passage, 1)), "passages", args);
8094
- }
8135
+ assertArg(
8136
+ Guard12.isStrictEqual(navigation, "endRepeat" /* EndRepeat */) && Guard12.isStrictEqual(args.length, 1) || Guard12.isStrictEqual(navigation, "ending" /* Ending */) && Guard12.isIntegerGte(args.length, 1) && args.every((passage) => Guard12.isIntegerGte(passage, 1)) || Guard12.isEnumValue(navigation, Navigation) && Guard12.isEmptyArray(args)
8137
+ );
8095
8138
  this.getMeasure().addNavigation(staffTabOrGroups, navigation, ...args);
8096
8139
  return this;
8097
8140
  }
8098
8141
  addNavigation(navigation, ...args) {
8142
+ setAssertFunction("addNavigation", navigation, ...args);
8099
8143
  return this.addNavigationInternal(void 0, navigation, ...args);
8100
8144
  }
8101
8145
  addNavigationTo(staffTabOrGroups, navigation, ...args) {
8146
+ setAssertFunction("addNavigationTo", staffTabOrGroups, navigation, ...args);
8102
8147
  return this.addNavigationInternal(staffTabOrGroups, navigation, ...args);
8103
8148
  }
8104
8149
  addAnnotationInternal(staffTabOrGroups, annotation, text) {
@@ -8107,12 +8152,15 @@ var _DocumentBuilder = class _DocumentBuilder {
8107
8152
  throw new MusicError18(MusicErrorType18.Score, `Annotation text "${text}" is not known annotation.`);
8108
8153
  }
8109
8154
  assertStaffTabOrGRoups(staffTabOrGroups);
8110
- assertArg(Utils16.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
8111
- assertArg(Utils16.Is.isNonEmptyString(text), "text", text);
8155
+ assertArg(
8156
+ Guard12.isEnumValue(annotation, Annotation),
8157
+ Guard12.isNonEmptyString(text)
8158
+ );
8112
8159
  this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
8113
8160
  return this;
8114
8161
  }
8115
8162
  addAnnotation(...args) {
8163
+ setAssertFunction("addAnnotation", ...args);
8116
8164
  if (args.length === 1) {
8117
8165
  return this.addAnnotationInternal(void 0, void 0, args[0]);
8118
8166
  } else {
@@ -8120,6 +8168,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8120
8168
  }
8121
8169
  }
8122
8170
  addAnnotationTo(staffTabOrGroups, ...args) {
8171
+ setAssertFunction("addAnnotationTo", staffTabOrGroups, ...args);
8123
8172
  if (args.length === 1) {
8124
8173
  return this.addAnnotationInternal(staffTabOrGroups, void 0, args[0]);
8125
8174
  } else {
@@ -8128,8 +8177,10 @@ var _DocumentBuilder = class _DocumentBuilder {
8128
8177
  }
8129
8178
  addLabelInternal(staffTabOrGroups, label, text) {
8130
8179
  assertStaffTabOrGRoups(staffTabOrGroups);
8131
- assertArg(Utils16.Is.isEnumValue(label, Label), "label", label);
8132
- assertArg(Utils16.Is.isNonEmptyString(text), "text", text);
8180
+ assertArg(
8181
+ Guard12.isEnumValue(label, Label),
8182
+ Guard12.isNonEmptyString(text)
8183
+ );
8133
8184
  this.getMeasure().addLabel(staffTabOrGroups, label, text);
8134
8185
  return this;
8135
8186
  }
@@ -8140,6 +8191,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8140
8191
  * @returns - This document builder instance.
8141
8192
  */
8142
8193
  addLabel(label, text) {
8194
+ setAssertFunction("addLabel", label, text);
8143
8195
  return this.addLabelInternal(void 0, label, text);
8144
8196
  }
8145
8197
  /**
@@ -8150,24 +8202,26 @@ var _DocumentBuilder = class _DocumentBuilder {
8150
8202
  * @returns - This document builder instance.
8151
8203
  */
8152
8204
  addLabelTo(staffTabOrGroups, label, text) {
8205
+ setAssertFunction("addLabelTo", staffTabOrGroups, label, text);
8153
8206
  return this.addLabelInternal(staffTabOrGroups, label, text);
8154
8207
  }
8155
8208
  addConnective(connective, ...args) {
8156
- assertArg(Utils16.Is.isEnumValue(connective, Connective), "connective", connective);
8209
+ setAssertFunction("addConnective", connective, ...args);
8210
+ assertArg(Guard12.isEnumValue(connective, Connective));
8157
8211
  if (connective === "tie" /* Tie */) {
8158
- assertArg(Utils16.Is.isIntegerOrUndefined(args[0]) || Utils16.Is.isEnumValue(args[0], TieType), "tieSpan", args[0]);
8159
- assertArg(Utils16.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
8212
+ assertArg(Guard12.isIntegerOrUndefined(args[0]) || Guard12.isEnumValue(args[0], TieType));
8213
+ assertArg(Guard12.isEnumValueOrUndefined(args[1], NoteAnchor));
8160
8214
  let tieSpan = args[0];
8161
8215
  let noteAnchor = args[1];
8162
8216
  this.getMeasure().addConnective(connective, tieSpan, noteAnchor);
8163
8217
  } else if (connective === "slur" /* Slur */) {
8164
- assertArg(Utils16.Is.isIntegerOrUndefined(args[0]), "slurSpan", args[0]);
8165
- assertArg(Utils16.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
8218
+ assertArg(Guard12.isIntegerOrUndefined(args[0]));
8219
+ assertArg(Guard12.isEnumValueOrUndefined(args[1], NoteAnchor));
8166
8220
  let slurSpan = args[0];
8167
8221
  let noteAnchor = args[1];
8168
8222
  this.getMeasure().addConnective(connective, slurSpan, noteAnchor);
8169
8223
  } else if (connective === "slide" /* Slide */) {
8170
- assertArg(Utils16.Is.isEnumValueOrUndefined(args[0], NoteAnchor), "noteAnchor", args[0]);
8224
+ assertArg(Guard12.isEnumValueOrUndefined(args[0], NoteAnchor));
8171
8225
  let noteAnchor = args[0];
8172
8226
  this.getMeasure().addConnective(connective, noteAnchor);
8173
8227
  }
@@ -8186,26 +8240,31 @@ var _DocumentBuilder = class _DocumentBuilder {
8186
8240
  * @returns - This document builder instance.
8187
8241
  */
8188
8242
  addExtension(extensionBuilder) {
8189
- assertArg(Utils16.Is.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.", extensionBuilder);
8243
+ setAssertFunction("addExtension");
8244
+ assertArgMsg(Guard12.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, e.g. addExtension(ext => ext.measures(2)).");
8190
8245
  let ticks = 0;
8191
8246
  let visible = true;
8192
8247
  const helper = {
8193
8248
  notes: (noteLength, noteCount) => {
8194
- assertArg(Utils16.Is.isEnumValue(noteLength, NoteLength8) || isNoteLength(noteLength), "noteLength", noteLength);
8195
- assertArg(Utils16.Is.isUndefined(noteCount) || Utils16.Is.isNumber(noteCount) && noteCount >= 0, "noteCount", noteCount);
8249
+ setAssertFunction("addExtension.notes", noteLength, noteCount);
8250
+ assertArg(isNoteLength(noteLength));
8251
+ assertArg(Guard12.isUndefined(noteCount) || Guard12.isNumber(noteCount) && noteCount >= 0);
8196
8252
  ticks += RhythmProps6.get(noteLength).ticks * (noteCount != null ? noteCount : 1);
8197
8253
  return helper;
8198
8254
  },
8199
8255
  measures: (measureCount) => {
8200
- assertArg(Utils16.Is.isNumber(measureCount) && measureCount >= 1, "measureCount", measureCount);
8256
+ setAssertFunction("addExtension.measures", measureCount);
8257
+ assertArg(Guard12.isNumber(measureCount) && measureCount >= 1);
8201
8258
  ticks += this.getMeasure().getMeasureTicks() * measureCount;
8202
8259
  return helper;
8203
8260
  },
8204
8261
  infinity: () => {
8262
+ setAssertFunction("addExtension.infinity");
8205
8263
  ticks = Infinity;
8206
8264
  return helper;
8207
8265
  },
8208
8266
  hide: () => {
8267
+ setAssertFunction("addExtension.hide");
8209
8268
  visible = false;
8210
8269
  return helper;
8211
8270
  }
@@ -8226,13 +8285,12 @@ var _DocumentBuilder = class _DocumentBuilder {
8226
8285
  * @returns - This document builder instance.
8227
8286
  */
8228
8287
  addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = "auto" /* Auto */) {
8229
- assertArg(Utils16.Is.isNonEmptyString(groupName), "groupName", groupName);
8288
+ setAssertFunction("addStaffGroup", groupName, staffsTabsAndGroups, verticalPosition);
8230
8289
  assertArg(
8231
- Utils16.Is.isNonEmptyString(staffsTabsAndGroups) || Utils16.Is.isIntegerGte(staffsTabsAndGroups, 0) || Utils16.Is.isNonEmptyArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => Utils16.Is.isNonEmptyString(line) || Utils16.Is.isIntegerGte(line, 0)),
8232
- "staffsTabsAndGroups",
8233
- staffsTabsAndGroups
8290
+ Guard12.isNonEmptyString(groupName),
8291
+ Guard12.isNonEmptyString(staffsTabsAndGroups) || Guard12.isIntegerGte(staffsTabsAndGroups, 0) || Guard12.isNonEmptyArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => Guard12.isNonEmptyString(line) || Guard12.isIntegerGte(line, 0)),
8292
+ Guard12.isEnumValue(verticalPosition, VerticalPosition)
8234
8293
  );
8235
- assertArg(Utils16.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
8236
8294
  this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
8237
8295
  return this;
8238
8296
  }
@@ -8241,6 +8299,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8241
8299
  * @returns - This document builder instance.
8242
8300
  */
8243
8301
  endSong() {
8302
+ setAssertFunction("endSong");
8244
8303
  this.getMeasure().endSong();
8245
8304
  return this;
8246
8305
  }
@@ -8249,6 +8308,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8249
8308
  * @returns - This document builder instance.
8250
8309
  */
8251
8310
  endSection() {
8311
+ setAssertFunction("endSection");
8252
8312
  this.getMeasure().endSection();
8253
8313
  return this;
8254
8314
  }
@@ -8258,6 +8318,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8258
8318
  */
8259
8319
  endRow() {
8260
8320
  var _a;
8321
+ setAssertFunction("endRow");
8261
8322
  (_a = this.doc.getLastMeasure()) == null ? void 0 : _a.endRow();
8262
8323
  return this;
8263
8324
  }
@@ -8267,7 +8328,8 @@ var _DocumentBuilder = class _DocumentBuilder {
8267
8328
  * @returns - This document builder instance.
8268
8329
  */
8269
8330
  completeRests(voiceId) {
8270
- assertArg(Utils16.Is.isUndefined(voiceId) || isVoiceId(voiceId) || Utils16.Is.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)), "voiceId", voiceId);
8331
+ setAssertFunction("completeRests", voiceId);
8332
+ assertArg(Guard12.isUndefined(voiceId) || isVoiceId(voiceId) || Guard12.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)));
8271
8333
  this.getMeasure().completeRests(voiceId);
8272
8334
  return this;
8273
8335
  }
@@ -8279,8 +8341,11 @@ var _DocumentBuilder = class _DocumentBuilder {
8279
8341
  * @returns - This document builder instance.
8280
8342
  */
8281
8343
  addScaleArpeggio(scale, bottomNote, numOctaves) {
8282
- assertArg(Utils16.Is.isNonEmptyString(bottomNote), "bottomNote", bottomNote);
8283
- assertArg(Utils16.Is.isIntegerGte(numOctaves, 1), "numOctaves", numOctaves);
8344
+ setAssertFunction("addScaleArpeggio", scale, bottomNote, numOctaves);
8345
+ assertArg(
8346
+ Guard12.isNonEmptyString(bottomNote),
8347
+ Guard12.isIntegerGte(numOctaves, 1)
8348
+ );
8284
8349
  let ts = this.getMeasure().getTimeSignature();
8285
8350
  let notes = scale.getScaleNotes(bottomNote, numOctaves);
8286
8351
  for (let i = 0; i < notes.length; i++) {
@@ -8366,19 +8431,16 @@ var ScoreObjectEvent = class extends ScoreEvent {
8366
8431
 
8367
8432
  // src/score/pub/music-interface.ts
8368
8433
  import * as Audio2 from "@tspro/web-music-score/audio";
8369
- import { Utils as Utils18 } from "@tspro/ts-utils-lib";
8434
+ import { Guard as Guard14, UniMap as UniMap9, ValueSet as ValueSet2, Utils as Utils13 } from "@tspro/ts-utils-lib";
8370
8435
 
8371
8436
  // src/score/pub/music-objects.ts
8372
- import { Utils as Utils17 } from "@tspro/ts-utils-lib";
8437
+ import { Guard as Guard13 } from "@tspro/ts-utils-lib";
8373
8438
  import { MusicError as MusicError20, MusicErrorType as MusicErrorType20 } from "@tspro/web-music-score/core";
8374
8439
  function assertArg2(condition, argName, argValue) {
8375
8440
  if (!condition) {
8376
8441
  throw new MusicError20(MusicErrorType20.Score, `Invalid arg: ${argName} = ${argValue}`);
8377
8442
  }
8378
8443
  }
8379
- function isVoiceId2(value) {
8380
- return Utils17.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
8381
- }
8382
8444
  function getNotationLine(line) {
8383
8445
  if (line instanceof ObjStaff || line instanceof ObjTab) {
8384
8446
  return line.getMusicInterface();
@@ -8386,7 +8448,7 @@ function getNotationLine(line) {
8386
8448
  throw new MusicError20(MusicErrorType20.Score, `Notation line not staff nor tab.`);
8387
8449
  }
8388
8450
  }
8389
- var MusicInterface6 = class {
8451
+ var MusicInterface5 = class {
8390
8452
  /**
8391
8453
  * Create new music interface object.
8392
8454
  * @param name - OBject name.
@@ -8403,7 +8465,7 @@ var MusicInterface6 = class {
8403
8465
  return (_a = this.getMusicObject().getParent()) == null ? void 0 : _a.getMusicInterface();
8404
8466
  }
8405
8467
  };
8406
- var _MAccidental = class _MAccidental extends MusicInterface6 {
8468
+ var _MAccidental = class _MAccidental extends MusicInterface5 {
8407
8469
  /** @internal */
8408
8470
  constructor(obj) {
8409
8471
  super(_MAccidental.Name);
@@ -8424,7 +8486,7 @@ var _MAccidental = class _MAccidental extends MusicInterface6 {
8424
8486
  /** Object name. */
8425
8487
  __publicField(_MAccidental, "Name", "Accidental");
8426
8488
  var MAccidental = _MAccidental;
8427
- var _MConnective = class _MConnective extends MusicInterface6 {
8489
+ var _MConnective = class _MConnective extends MusicInterface5 {
8428
8490
  /** @internal */
8429
8491
  constructor(obj) {
8430
8492
  super(_MConnective.Name);
@@ -8438,7 +8500,7 @@ var _MConnective = class _MConnective extends MusicInterface6 {
8438
8500
  /** Object name. */
8439
8501
  __publicField(_MConnective, "Name", "Connective");
8440
8502
  var MConnective = _MConnective;
8441
- var _MArpeggio = class _MArpeggio extends MusicInterface6 {
8503
+ var _MArpeggio = class _MArpeggio extends MusicInterface5 {
8442
8504
  /** @internal */
8443
8505
  constructor(obj) {
8444
8506
  super(_MArpeggio.Name);
@@ -8466,7 +8528,7 @@ var _MArpeggio = class _MArpeggio extends MusicInterface6 {
8466
8528
  /** Object name. */
8467
8529
  __publicField(_MArpeggio, "Name", "Arpeggio");
8468
8530
  var MArpeggio = _MArpeggio;
8469
- var _MBeamGroup = class _MBeamGroup extends MusicInterface6 {
8531
+ var _MBeamGroup = class _MBeamGroup extends MusicInterface5 {
8470
8532
  /** @internal */
8471
8533
  constructor(obj) {
8472
8534
  super(_MBeamGroup.Name);
@@ -8480,7 +8542,7 @@ var _MBeamGroup = class _MBeamGroup extends MusicInterface6 {
8480
8542
  /** OBject name. */
8481
8543
  __publicField(_MBeamGroup, "Name", "BeamGroup");
8482
8544
  var MBeamGroup = _MBeamGroup;
8483
- var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
8545
+ var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface5 {
8484
8546
  /** @internal */
8485
8547
  constructor(obj) {
8486
8548
  super(_MStaffBeamGroup.Name);
@@ -8501,7 +8563,7 @@ var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
8501
8563
  /** Object name. */
8502
8564
  __publicField(_MStaffBeamGroup, "Name", "StaffBeamGroup");
8503
8565
  var MStaffBeamGroup = _MStaffBeamGroup;
8504
- var _MDocument = class _MDocument extends MusicInterface6 {
8566
+ var _MDocument = class _MDocument extends MusicInterface5 {
8505
8567
  /** @internal */
8506
8568
  constructor(obj) {
8507
8569
  super(_MDocument.Name);
@@ -8553,14 +8615,14 @@ var _MDocument = class _MDocument extends MusicInterface6 {
8553
8615
  * @returns - Player instance.
8554
8616
  */
8555
8617
  play(playStateChangeListener) {
8556
- assertArg2(Utils17.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
8618
+ assertArg2(Guard13.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
8557
8619
  return new MPlayer(this, playStateChangeListener).play();
8558
8620
  }
8559
8621
  };
8560
8622
  /** Object name. */
8561
8623
  __publicField(_MDocument, "Name", "Document");
8562
8624
  var MDocument2 = _MDocument;
8563
- var _MEnding = class _MEnding extends MusicInterface6 {
8625
+ var _MEnding = class _MEnding extends MusicInterface5 {
8564
8626
  /** @internal */
8565
8627
  constructor(obj) {
8566
8628
  super(_MEnding.Name);
@@ -8583,14 +8645,14 @@ var _MEnding = class _MEnding extends MusicInterface6 {
8583
8645
  * @returns - Boolean whether this ending has asked passage number.
8584
8646
  */
8585
8647
  hasPassage(passage) {
8586
- assertArg2(Utils17.Is.isIntegerGte(passage, 1), "passage", passage);
8648
+ assertArg2(Guard13.isIntegerGte(passage, 1), "passage", passage);
8587
8649
  return this.obj.hasPassage(passage);
8588
8650
  }
8589
8651
  };
8590
8652
  /** Object name. */
8591
8653
  __publicField(_MEnding, "Name", "Ending");
8592
8654
  var MEnding = _MEnding;
8593
- var _MFermata = class _MFermata extends MusicInterface6 {
8655
+ var _MFermata = class _MFermata extends MusicInterface5 {
8594
8656
  /** @internal */
8595
8657
  constructor(obj) {
8596
8658
  super(_MFermata.Name);
@@ -8604,7 +8666,7 @@ var _MFermata = class _MFermata extends MusicInterface6 {
8604
8666
  /** OBject name. */
8605
8667
  __publicField(_MFermata, "Name", "Fermata");
8606
8668
  var MFermata = _MFermata;
8607
- var _MHeader = class _MHeader extends MusicInterface6 {
8669
+ var _MHeader = class _MHeader extends MusicInterface5 {
8608
8670
  /** @internal */
8609
8671
  constructor(obj) {
8610
8672
  super(_MHeader.Name);
@@ -8639,7 +8701,7 @@ var _MHeader = class _MHeader extends MusicInterface6 {
8639
8701
  /** OBject name. */
8640
8702
  __publicField(_MHeader, "Name", "Header");
8641
8703
  var MHeader = _MHeader;
8642
- var _MImage = class _MImage extends MusicInterface6 {
8704
+ var _MImage = class _MImage extends MusicInterface5 {
8643
8705
  /** @internal */
8644
8706
  constructor(obj) {
8645
8707
  super(_MImage.Name);
@@ -8653,7 +8715,7 @@ var _MImage = class _MImage extends MusicInterface6 {
8653
8715
  /** Object name. */
8654
8716
  __publicField(_MImage, "Name", "Image");
8655
8717
  var MImage = _MImage;
8656
- var _MMeasure = class _MMeasure extends MusicInterface6 {
8718
+ var _MMeasure = class _MMeasure extends MusicInterface5 {
8657
8719
  /** @internal */
8658
8720
  constructor(obj) {
8659
8721
  super(_MMeasure.Name);
@@ -8688,7 +8750,7 @@ var _MMeasure = class _MMeasure extends MusicInterface6 {
8688
8750
  /** OBject name. */
8689
8751
  __publicField(_MMeasure, "Name", "Measure");
8690
8752
  var MMeasure = _MMeasure;
8691
- var _MBarLineRight = class _MBarLineRight extends MusicInterface6 {
8753
+ var _MBarLineRight = class _MBarLineRight extends MusicInterface5 {
8692
8754
  /** @internal */
8693
8755
  constructor(obj) {
8694
8756
  super(_MBarLineRight.Name);
@@ -8702,7 +8764,7 @@ var _MBarLineRight = class _MBarLineRight extends MusicInterface6 {
8702
8764
  /** OBject name. */
8703
8765
  __publicField(_MBarLineRight, "Name", "BarLineRight");
8704
8766
  var MBarLineRight = _MBarLineRight;
8705
- var _MBarLineLeft = class _MBarLineLeft extends MusicInterface6 {
8767
+ var _MBarLineLeft = class _MBarLineLeft extends MusicInterface5 {
8706
8768
  /** @internal */
8707
8769
  constructor(obj) {
8708
8770
  super(_MBarLineLeft.Name);
@@ -8716,7 +8778,7 @@ var _MBarLineLeft = class _MBarLineLeft extends MusicInterface6 {
8716
8778
  /** Object name. */
8717
8779
  __publicField(_MBarLineLeft, "Name", "BarLineLeft");
8718
8780
  var MBarLineLeft = _MBarLineLeft;
8719
- var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
8781
+ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface5 {
8720
8782
  /** @internal */
8721
8783
  constructor(obj) {
8722
8784
  super(_MStaffTabBarLine.Name);
@@ -8749,7 +8811,7 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
8749
8811
  /** Object name. */
8750
8812
  __publicField(_MStaffTabBarLine, "Name", "StaffTabBarLine");
8751
8813
  var MStaffTabBarLine = _MStaffTabBarLine;
8752
- var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
8814
+ var _MNoteGroup = class _MNoteGroup extends MusicInterface5 {
8753
8815
  /** @internal */
8754
8816
  constructor(obj) {
8755
8817
  super(_MNoteGroup.Name);
@@ -8791,7 +8853,7 @@ var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
8791
8853
  /** Object name. */
8792
8854
  __publicField(_MNoteGroup, "Name", "NoteGroup");
8793
8855
  var MNoteGroup = _MNoteGroup;
8794
- var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
8856
+ var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface5 {
8795
8857
  /** @internal */
8796
8858
  constructor(obj) {
8797
8859
  super(_MStaffNoteGroup.Name);
@@ -8833,7 +8895,7 @@ var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
8833
8895
  /** Object name. */
8834
8896
  __publicField(_MStaffNoteGroup, "Name", "StaffNoteGroup");
8835
8897
  var MStaffNoteGroup = _MStaffNoteGroup;
8836
- var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
8898
+ var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface5 {
8837
8899
  /** @internal */
8838
8900
  constructor(obj) {
8839
8901
  super(_MTabNoteGroup.Name);
@@ -8875,7 +8937,7 @@ var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
8875
8937
  /** OBject name. */
8876
8938
  __publicField(_MTabNoteGroup, "Name", "TabNoteGroup");
8877
8939
  var MTabNoteGroup = _MTabNoteGroup;
8878
- var _MRest = class _MRest extends MusicInterface6 {
8940
+ var _MRest = class _MRest extends MusicInterface5 {
8879
8941
  /** @internal */
8880
8942
  constructor(obj) {
8881
8943
  super(_MRest.Name);
@@ -8910,7 +8972,7 @@ var _MRest = class _MRest extends MusicInterface6 {
8910
8972
  /** OBject name. */
8911
8973
  __publicField(_MRest, "Name", "Rest");
8912
8974
  var MRest = _MRest;
8913
- var _MStaffRest = class _MStaffRest extends MusicInterface6 {
8975
+ var _MStaffRest = class _MStaffRest extends MusicInterface5 {
8914
8976
  /** @internal */
8915
8977
  constructor(obj) {
8916
8978
  super(_MStaffRest.Name);
@@ -8952,7 +9014,7 @@ var _MStaffRest = class _MStaffRest extends MusicInterface6 {
8952
9014
  /** Object name. */
8953
9015
  __publicField(_MStaffRest, "Name", "StaffRest");
8954
9016
  var MStaffRest = _MStaffRest;
8955
- var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
9017
+ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface5 {
8956
9018
  /** @internal */
8957
9019
  constructor(obj) {
8958
9020
  super(_MRhythmColumn.Name);
@@ -8969,7 +9031,7 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
8969
9031
  */
8970
9032
  getRhythmSymbol(voiceId) {
8971
9033
  var _a;
8972
- assertArg2(isVoiceId2(voiceId), "voiceId", voiceId);
9034
+ assertArg2(isVoiceId(voiceId), "voiceId", voiceId);
8973
9035
  return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
8974
9036
  }
8975
9037
  /**
@@ -8980,7 +9042,7 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
8980
9042
  */
8981
9043
  getVoiceSymbol(voiceId) {
8982
9044
  var _a;
8983
- assertArg2(isVoiceId2(voiceId), "voiceId", voiceId);
9045
+ assertArg2(isVoiceId(voiceId), "voiceId", voiceId);
8984
9046
  return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
8985
9047
  }
8986
9048
  /**
@@ -8994,7 +9056,7 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
8994
9056
  /** OBject name. */
8995
9057
  __publicField(_MRhythmColumn, "Name", "RhythmColumn");
8996
9058
  var MRhythmColumn = _MRhythmColumn;
8997
- var _MScoreRow = class _MScoreRow extends MusicInterface6 {
9059
+ var _MScoreRow = class _MScoreRow extends MusicInterface5 {
8998
9060
  /** @internal */
8999
9061
  constructor(obj) {
9000
9062
  super(_MScoreRow.Name);
@@ -9029,7 +9091,7 @@ var _MScoreRow = class _MScoreRow extends MusicInterface6 {
9029
9091
  /** Object name. */
9030
9092
  __publicField(_MScoreRow, "Name", "ScoreRow");
9031
9093
  var MScoreRow = _MScoreRow;
9032
- var _MStaff = class _MStaff extends MusicInterface6 {
9094
+ var _MStaff = class _MStaff extends MusicInterface5 {
9033
9095
  /** @internal */
9034
9096
  constructor(obj) {
9035
9097
  super(_MStaff.Name);
@@ -9064,7 +9126,7 @@ var _MStaff = class _MStaff extends MusicInterface6 {
9064
9126
  /** Object name. */
9065
9127
  __publicField(_MStaff, "Name", "Staff");
9066
9128
  var MStaff = _MStaff;
9067
- var _MTab = class _MTab extends MusicInterface6 {
9129
+ var _MTab = class _MTab extends MusicInterface5 {
9068
9130
  /** @internal */
9069
9131
  constructor(obj) {
9070
9132
  super(_MTab.Name);
@@ -9099,7 +9161,7 @@ var _MTab = class _MTab extends MusicInterface6 {
9099
9161
  /** Object name. */
9100
9162
  __publicField(_MTab, "Name", "Tab");
9101
9163
  var MTab = _MTab;
9102
- var _MStaffSignature = class _MStaffSignature extends MusicInterface6 {
9164
+ var _MStaffSignature = class _MStaffSignature extends MusicInterface5 {
9103
9165
  /** @internal */
9104
9166
  constructor(obj) {
9105
9167
  super(_MStaffSignature.Name);
@@ -9120,7 +9182,7 @@ var _MStaffSignature = class _MStaffSignature extends MusicInterface6 {
9120
9182
  /** Object name. */
9121
9183
  __publicField(_MStaffSignature, "Name", "StaffSignature");
9122
9184
  var MStaffSignature = _MStaffSignature;
9123
- var _MTabSignature = class _MTabSignature extends MusicInterface6 {
9185
+ var _MTabSignature = class _MTabSignature extends MusicInterface5 {
9124
9186
  /** @internal */
9125
9187
  constructor(obj) {
9126
9188
  super(_MTabSignature.Name);
@@ -9141,7 +9203,7 @@ var _MTabSignature = class _MTabSignature extends MusicInterface6 {
9141
9203
  /** Object name. */
9142
9204
  __publicField(_MTabSignature, "Name", "TabSignature");
9143
9205
  var MTabSignature = _MTabSignature;
9144
- var _MTabRhythm = class _MTabRhythm extends MusicInterface6 {
9206
+ var _MTabRhythm = class _MTabRhythm extends MusicInterface5 {
9145
9207
  /** @internal */
9146
9208
  constructor(obj) {
9147
9209
  super(_MTabRhythm.Name);
@@ -9169,7 +9231,7 @@ var _MTabRhythm = class _MTabRhythm extends MusicInterface6 {
9169
9231
  /** Object name. */
9170
9232
  __publicField(_MTabRhythm, "Name", "TabRhythm");
9171
9233
  var MTabRhythm = _MTabRhythm;
9172
- var _MSpecialText = class _MSpecialText extends MusicInterface6 {
9234
+ var _MSpecialText = class _MSpecialText extends MusicInterface5 {
9173
9235
  /** @internal */
9174
9236
  constructor(obj) {
9175
9237
  super(_MSpecialText.Name);
@@ -9190,7 +9252,7 @@ var _MSpecialText = class _MSpecialText extends MusicInterface6 {
9190
9252
  /** Object name. */
9191
9253
  __publicField(_MSpecialText, "Name", "SpecialText");
9192
9254
  var MSpecialText = _MSpecialText;
9193
- var _MText = class _MText extends MusicInterface6 {
9255
+ var _MText = class _MText extends MusicInterface5 {
9194
9256
  /** @internal */
9195
9257
  constructor(obj) {
9196
9258
  super(_MText.Name);
@@ -9211,7 +9273,7 @@ var _MText = class _MText extends MusicInterface6 {
9211
9273
  /** Object name. */
9212
9274
  __publicField(_MText, "Name", "Text");
9213
9275
  var MText = _MText;
9214
- var _MLyrics = class _MLyrics extends MusicInterface6 {
9276
+ var _MLyrics = class _MLyrics extends MusicInterface5 {
9215
9277
  /** @internal */
9216
9278
  constructor(obj) {
9217
9279
  super(_MLyrics.Name);
@@ -9232,7 +9294,7 @@ var _MLyrics = class _MLyrics extends MusicInterface6 {
9232
9294
  /** Object name. */
9233
9295
  __publicField(_MLyrics, "Name", "Lyrics");
9234
9296
  var MLyrics = _MLyrics;
9235
- var _MExtensionLine = class _MExtensionLine extends MusicInterface6 {
9297
+ var _MExtensionLine = class _MExtensionLine extends MusicInterface5 {
9236
9298
  /** @internal */
9237
9299
  constructor(obj) {
9238
9300
  super(_MExtensionLine.Name);
@@ -9270,10 +9332,12 @@ var _MPlayer = class _MPlayer {
9270
9332
  constructor(doc, playStateChangeListener) {
9271
9333
  __publicField(this, "player");
9272
9334
  assertArg3(doc instanceof MDocument2, "doc", doc);
9273
- assertArg3(Utils18.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
9335
+ assertArg3(Guard14.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
9274
9336
  this.player = new Player();
9275
9337
  this.player.setDocument(doc.getMusicObject());
9276
- this.player.setCursorPositionChangeListener((cursorRect) => doc.getMusicObject().updateCursorRect(cursorRect));
9338
+ this.player.setCursorPositionChangeListener((cursorRect) => {
9339
+ doc.getMusicObject().updateCursorRect(cursorRect);
9340
+ });
9277
9341
  if (playStateChangeListener) {
9278
9342
  this.player.setPlayStateChnageListener(playStateChangeListener);
9279
9343
  }
@@ -9312,7 +9376,7 @@ var _MPlayer = class _MPlayer {
9312
9376
  return this;
9313
9377
  }
9314
9378
  };
9315
- __publicField(_MPlayer, "currentlyPlaying", /* @__PURE__ */ new Set());
9379
+ __publicField(_MPlayer, "currentlyPlaying", new ValueSet2());
9316
9380
  var MPlayer = _MPlayer;
9317
9381
  var MRenderContext2 = class {
9318
9382
  /**
@@ -9328,7 +9392,7 @@ var MRenderContext2 = class {
9328
9392
  * @returns - This render context instance.
9329
9393
  */
9330
9394
  setDocument(doc) {
9331
- assertArg3(Utils18.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
9395
+ assertArg3(Guard14.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
9332
9396
  this.ctx.setDocument(doc);
9333
9397
  return this;
9334
9398
  }
@@ -9338,7 +9402,7 @@ var MRenderContext2 = class {
9338
9402
  * @returns - This render context instance.
9339
9403
  */
9340
9404
  setCanvas(canvas) {
9341
- canvas = require_t(Utils18.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set render canvas because invalid canvas id: " + canvas : "Cannot set render canvas because given canvas is undefined.");
9405
+ canvas = require_t(Utils13.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set render canvas because invalid canvas id: " + canvas : "Cannot set render canvas because given canvas is undefined.");
9342
9406
  this.ctx.setCanvas(canvas);
9343
9407
  return this;
9344
9408
  }
@@ -9347,7 +9411,7 @@ var MRenderContext2 = class {
9347
9411
  * @param scoreEventListener - Score event listener.
9348
9412
  */
9349
9413
  setScoreEventListener(scoreEventListener) {
9350
- assertArg3(Utils18.Is.isFunctionOrUndefined(scoreEventListener), "scoreEventListener", scoreEventListener);
9414
+ assertArg3(Guard14.isFunctionOrUndefined(scoreEventListener), "scoreEventListener", scoreEventListener);
9351
9415
  this.ctx.setScoreEventListener(scoreEventListener);
9352
9416
  }
9353
9417
  /**
@@ -9422,7 +9486,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9422
9486
  * @returns
9423
9487
  */
9424
9488
  setDocument(doc) {
9425
- assertArg3(Utils18.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
9489
+ assertArg3(Guard14.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
9426
9490
  this.onStop();
9427
9491
  if (doc) {
9428
9492
  this.player = new MPlayer(doc, (playState) => {
@@ -9466,9 +9530,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9466
9530
  * @returns - This playback buttons class instance.
9467
9531
  */
9468
9532
  setPlayButton(btn, btnLabel) {
9469
- assertArg3(Utils18.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9533
+ assertArg3(Guard14.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9470
9534
  _MPlaybackButtons.removeOnClickListeners(this.playButton, this.onPlay);
9471
- this.playButton = require_t(Utils18.Dom.getButton(btn), "Play button required!");
9535
+ this.playButton = require_t(Utils13.Dom.getButton(btn), "Play button required!");
9472
9536
  this.playLabel = btnLabel != null ? btnLabel : "Play";
9473
9537
  _MPlaybackButtons.removeOnClickListeners(this.playButton, "all");
9474
9538
  _MPlaybackButtons.addOnClickListener(this.playButton, this.onPlay);
@@ -9482,9 +9546,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9482
9546
  * @returns - This playback buttons class instance.
9483
9547
  */
9484
9548
  setStopButton(btn, btnLabel) {
9485
- assertArg3(Utils18.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9549
+ assertArg3(Guard14.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9486
9550
  _MPlaybackButtons.removeOnClickListeners(this.stopButton, this.onStop);
9487
- this.stopButton = require_t(Utils18.Dom.getButton(btn), "Stop button required!");
9551
+ this.stopButton = require_t(Utils13.Dom.getButton(btn), "Stop button required!");
9488
9552
  this.stopLabel = btnLabel != null ? btnLabel : "Stop";
9489
9553
  _MPlaybackButtons.removeOnClickListeners(this.stopButton, "all");
9490
9554
  _MPlaybackButtons.addOnClickListener(this.stopButton, this.onStop);
@@ -9499,10 +9563,10 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9499
9563
  * @returns - This playback buttons class instance.
9500
9564
  */
9501
9565
  setPlayStopButton(btn, playLabel, stopLabel) {
9502
- assertArg3(Utils18.Is.isStringOrUndefined(playLabel), "playLabel", playLabel);
9503
- assertArg3(Utils18.Is.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
9566
+ assertArg3(Guard14.isStringOrUndefined(playLabel), "playLabel", playLabel);
9567
+ assertArg3(Guard14.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
9504
9568
  _MPlaybackButtons.removeOnClickListeners(this.playStopButton, this.onPlayStop);
9505
- this.playStopButton = require_t(Utils18.Dom.getButton(btn), "Play/stop button required!");
9569
+ this.playStopButton = require_t(Utils13.Dom.getButton(btn), "Play/stop button required!");
9506
9570
  this.playLabel = playLabel != null ? playLabel : "Play";
9507
9571
  this.stopLabel = stopLabel != null ? stopLabel : "Stop";
9508
9572
  _MPlaybackButtons.removeOnClickListeners(this.playStopButton, "all");
@@ -9517,37 +9581,35 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9517
9581
  * @returns - This playback buttons class instance.
9518
9582
  */
9519
9583
  setPauseButton(btn, btnLabel) {
9520
- assertArg3(Utils18.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9584
+ assertArg3(Guard14.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9521
9585
  _MPlaybackButtons.removeOnClickListeners(this.pauseButton, this.onPause);
9522
- this.pauseButton = require_t(Utils18.Dom.getButton(btn), "Pause button required!");
9586
+ this.pauseButton = require_t(Utils13.Dom.getButton(btn), "Pause button required!");
9523
9587
  this.pauseLabel = btnLabel != null ? btnLabel : "Pause";
9524
9588
  _MPlaybackButtons.removeOnClickListeners(this.pauseButton, "all");
9525
9589
  _MPlaybackButtons.addOnClickListener(this.pauseButton, this.onPause);
9526
9590
  this.updateButtons();
9527
9591
  return this;
9528
9592
  }
9529
- static removeOnClickListeners(btn, onClick) {
9530
- if (btn) {
9531
- let savedListeners = this.savedOnClickListeners.get(btn) || [];
9532
- let remainingListeners = [];
9533
- savedListeners.forEach((l) => {
9534
- if (onClick === l || onClick === "all") {
9535
- btn.removeEventListener("click", l);
9536
- } else {
9537
- remainingListeners.push(l);
9538
- }
9539
- });
9540
- this.savedOnClickListeners.set(btn, remainingListeners);
9541
- }
9593
+ static removeOnClickListeners(btn, onClickListener) {
9594
+ if (!btn) return;
9595
+ let curListeners = this.savedOnClickListeners.getOrDefault(btn, []);
9596
+ curListeners = curListeners.filter((listener) => {
9597
+ if (onClickListener === listener || onClickListener === "all") {
9598
+ btn.removeEventListener("click", listener);
9599
+ return false;
9600
+ } else {
9601
+ return true;
9602
+ }
9603
+ });
9604
+ this.savedOnClickListeners.set(btn, curListeners);
9542
9605
  }
9543
- static addOnClickListener(btn, onClick) {
9544
- assertArg3(Utils18.Is.isFunction(onClick), "onClick", onClick);
9545
- btn.addEventListener("click", onClick);
9546
- let clickListeners = this.savedOnClickListeners.get(btn) || [];
9547
- this.savedOnClickListeners.set(btn, [...clickListeners, onClick]);
9606
+ static addOnClickListener(btn, onClickListener) {
9607
+ assertArg3(Guard14.isFunction(onClickListener), "onClick", onClickListener);
9608
+ btn.addEventListener("click", onClickListener);
9609
+ this.savedOnClickListeners.getOrCreate(btn, []).push(onClickListener);
9548
9610
  }
9549
9611
  };
9550
- __publicField(_MPlaybackButtons, "savedOnClickListeners", /* @__PURE__ */ new Map());
9612
+ __publicField(_MPlaybackButtons, "savedOnClickListeners", new UniMap9());
9551
9613
  var MPlaybackButtons = _MPlaybackButtons;
9552
9614
 
9553
9615
  // src/score/index.ts
@@ -9599,7 +9661,7 @@ export {
9599
9661
  MTabRhythm,
9600
9662
  MTabSignature,
9601
9663
  MText,
9602
- MusicInterface6 as MusicInterface,
9664
+ MusicInterface5 as MusicInterface,
9603
9665
  Navigation,
9604
9666
  NoteAnchor,
9605
9667
  PlayState,
@@ -9613,6 +9675,12 @@ export {
9613
9675
  VerticalPosition,
9614
9676
  getStringNumbers,
9615
9677
  getVerseNumbers,
9616
- getVoiceIds
9678
+ getVoiceIds,
9679
+ isStringNumber,
9680
+ isVerseNumber,
9681
+ isVoiceId,
9682
+ validateStringNumber,
9683
+ validateVerseNumber,
9684
+ validateVoiceId
9617
9685
  };
9618
9686
  //# sourceMappingURL=index.mjs.map