@m2c2kit/core 0.3.13 → 0.3.14

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 (3) hide show
  1. package/dist/index.d.ts +154 -47
  2. package/dist/index.js +1105 -1032
  3. package/package.json +19 -17
package/dist/index.js CHANGED
@@ -6,15 +6,10 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
6
6
  ActionType2["Move"] = "Move";
7
7
  ActionType2["Scale"] = "Scale";
8
8
  ActionType2["FadeAlpha"] = "FadeAlpha";
9
+ ActionType2["Rotate"] = "Rotate";
9
10
  return ActionType2;
10
11
  })(ActionType || {});
11
12
 
12
- var __defProp$k = Object.defineProperty;
13
- var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
- var __publicField$k = (obj, key, value) => {
15
- __defNormalProp$k(obj, typeof key !== "symbol" ? key + "" : key, value);
16
- return value;
17
- };
18
13
  class Easings {
19
14
  }
20
15
  // These easing functions are adapted from work by Robert Penner
@@ -33,134 +28,369 @@ class Easings {
33
28
  // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
34
29
  // Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
35
30
  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
- __publicField$k(Easings, "none", (t, b, c, d) => {
31
+ Easings.none = (t, b, c, d) => {
37
32
  return c + b;
38
- });
39
- __publicField$k(Easings, "linear", (t, b, c, d) => {
33
+ };
34
+ Easings.linear = (t, b, c, d) => {
40
35
  return c * t / d + b;
41
- });
42
- __publicField$k(Easings, "quadraticIn", (t, b, c, d) => {
36
+ };
37
+ Easings.quadraticIn = (t, b, c, d) => {
43
38
  t /= d;
44
39
  return c * t * t + b;
45
- });
46
- __publicField$k(Easings, "quadraticOut", (t, b, c, d) => {
40
+ };
41
+ Easings.quadraticOut = (t, b, c, d) => {
47
42
  t /= d;
48
43
  return -c * t * (t - 2) + b;
49
- });
50
- __publicField$k(Easings, "quadraticInOut", (t, b, c, d) => {
44
+ };
45
+ Easings.quadraticInOut = (t, b, c, d) => {
51
46
  t /= d / 2;
52
47
  if (t < 1)
53
48
  return c / 2 * t * t + b;
54
49
  t--;
55
50
  return -c / 2 * (t * (t - 2) - 1) + b;
56
- });
57
- __publicField$k(Easings, "cubicIn", (t, b, c, d) => {
51
+ };
52
+ Easings.cubicIn = (t, b, c, d) => {
58
53
  t /= d;
59
54
  return c * t * t * t + b;
60
- });
61
- __publicField$k(Easings, "cubicOut", (t, b, c, d) => {
55
+ };
56
+ Easings.cubicOut = (t, b, c, d) => {
62
57
  t /= d;
63
58
  t--;
64
59
  return c * (t * t * t + 1) + b;
65
- });
66
- __publicField$k(Easings, "cubicInOut", (t, b, c, d) => {
60
+ };
61
+ Easings.cubicInOut = (t, b, c, d) => {
67
62
  t /= d / 2;
68
63
  if (t < 1)
69
64
  return c / 2 * t * t * t + b;
70
65
  t -= 2;
71
66
  return c / 2 * (t * t * t + 2) + b;
72
- });
73
- __publicField$k(Easings, "quarticIn", (t, b, c, d) => {
67
+ };
68
+ Easings.quarticIn = (t, b, c, d) => {
74
69
  t /= d;
75
70
  return c * t * t * t * t + b;
76
- });
77
- __publicField$k(Easings, "quarticOut", (t, b, c, d) => {
71
+ };
72
+ Easings.quarticOut = (t, b, c, d) => {
78
73
  t /= d;
79
74
  t--;
80
75
  return -c * (t * t * t * t - 1) + b;
81
- });
82
- __publicField$k(Easings, "quarticInOut", (t, b, c, d) => {
76
+ };
77
+ Easings.quarticInOut = (t, b, c, d) => {
83
78
  t /= d / 2;
84
79
  if (t < 1)
85
80
  return c / 2 * t * t * t * t + b;
86
81
  t -= 2;
87
82
  return -c / 2 * (t * t * t * t - 2) + b;
88
- });
89
- __publicField$k(Easings, "quinticIn", (t, b, c, d) => {
83
+ };
84
+ Easings.quinticIn = (t, b, c, d) => {
90
85
  t /= d;
91
86
  return c * t * t * t * t * t + b;
92
- });
93
- __publicField$k(Easings, "quinticOut", (t, b, c, d) => {
87
+ };
88
+ Easings.quinticOut = (t, b, c, d) => {
94
89
  t /= d;
95
90
  t--;
96
91
  return c * (t * t * t * t * t + 1) + b;
97
- });
98
- __publicField$k(Easings, "quinticInOut", (t, b, c, d) => {
92
+ };
93
+ Easings.quinticInOut = (t, b, c, d) => {
99
94
  t /= d / 2;
100
95
  if (t < 1)
101
96
  return c / 2 * t * t * t * t * t + b;
102
97
  t -= 2;
103
98
  return c / 2 * (t * t * t * t * t + 2) + b;
104
- });
105
- __publicField$k(Easings, "sinusoidalIn", (t, b, c, d) => {
99
+ };
100
+ Easings.sinusoidalIn = (t, b, c, d) => {
106
101
  return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
107
- });
108
- __publicField$k(Easings, "sinusoidalOut", (t, b, c, d) => {
102
+ };
103
+ Easings.sinusoidalOut = (t, b, c, d) => {
109
104
  return c * Math.sin(t / d * (Math.PI / 2)) + b;
110
- });
111
- __publicField$k(Easings, "sinusoidalInOut", (t, b, c, d) => {
105
+ };
106
+ Easings.sinusoidalInOut = (t, b, c, d) => {
112
107
  return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
113
- });
114
- __publicField$k(Easings, "exponentialIn", (t, b, c, d) => {
108
+ };
109
+ Easings.exponentialIn = (t, b, c, d) => {
115
110
  return c * Math.pow(2, 10 * (t / d - 1)) + b;
116
- });
117
- __publicField$k(Easings, "exponentialOut", (t, b, c, d) => {
111
+ };
112
+ Easings.exponentialOut = (t, b, c, d) => {
118
113
  return c * (-Math.pow(2, -10 * t / d) + 1) + b;
119
- });
120
- __publicField$k(Easings, "exponentialInOut", (t, b, c, d) => {
114
+ };
115
+ Easings.exponentialInOut = (t, b, c, d) => {
121
116
  t /= d / 2;
122
117
  if (t < 1)
123
118
  return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
124
119
  t--;
125
120
  return c / 2 * (-Math.pow(2, -10 * t) + 2) + b;
126
- });
127
- __publicField$k(Easings, "circularIn", (t, b, c, d) => {
121
+ };
122
+ Easings.circularIn = (t, b, c, d) => {
128
123
  t /= d;
129
124
  return -c * (Math.sqrt(1 - t * t) - 1) + b;
130
- });
131
- __publicField$k(Easings, "circularOut", (t, b, c, d) => {
125
+ };
126
+ Easings.circularOut = (t, b, c, d) => {
132
127
  t /= d;
133
128
  t--;
134
129
  return c * Math.sqrt(1 - t * t) + b;
135
- });
136
- __publicField$k(Easings, "circularInOut", (t, b, c, d) => {
130
+ };
131
+ Easings.circularInOut = (t, b, c, d) => {
137
132
  t /= d / 2;
138
133
  if (t < 1)
139
134
  return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
140
135
  t -= 2;
141
136
  return c / 2 * (Math.sqrt(1 - t * t) + 1) + b;
142
- });
143
-
144
- var __defProp$j = Object.defineProperty;
145
- var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
146
- var __publicField$j = (obj, key, value) => {
147
- __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
148
- return value;
149
137
  };
138
+
139
+ var EntityType = /* @__PURE__ */ ((EntityType2) => {
140
+ EntityType2["Entity"] = "Entity";
141
+ EntityType2["Scene"] = "Scene";
142
+ EntityType2["Sprite"] = "Sprite";
143
+ EntityType2["Label"] = "Label";
144
+ EntityType2["TextLine"] = "TextLine";
145
+ EntityType2["Shape"] = "Shape";
146
+ EntityType2["Composite"] = "Composite";
147
+ return EntityType2;
148
+ })(EntityType || {});
149
+
150
+ var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
151
+ ShapeType2["Undefined"] = "Undefined";
152
+ ShapeType2["Rectangle"] = "Rectangle";
153
+ ShapeType2["Circle"] = "Circle";
154
+ ShapeType2["Path"] = "Path";
155
+ return ShapeType2;
156
+ })(ShapeType || {});
157
+
158
+ class M2c2KitHelpers {
159
+ /**
160
+ * Calculates the four points of the bounding box of the entity, taking
161
+ * into account the entity's rotation (as well as the rotation of its
162
+ * ancestors).
163
+ *
164
+ * @remarks This method is used to calculate the rotated bounding box of an
165
+ * entity when in order to determine if a point is inside the entity in
166
+ * response to DOM pointer events. This method is NOT used to prepare the
167
+ * CanvasKit canvas for drawing the entity.
168
+ *
169
+ * @param drawableEntity
170
+ * @returns array of points representing the rotated entity
171
+ */
172
+ static calculateRotatedPoints(drawableEntity) {
173
+ const entities = drawableEntity.ancestors;
174
+ entities.reverse();
175
+ entities.push(drawableEntity);
176
+ const entityPointsArray = entities.map((entity) => {
177
+ const boundingBox = M2c2KitHelpers.calculateEntityAbsoluteBoundingBox(entity);
178
+ return boundingBoxToPoints(boundingBox);
179
+ });
180
+ for (let i = 0; i < entityPointsArray.length; i++) {
181
+ if (!entityNeedsRotation(entities[i])) {
182
+ continue;
183
+ }
184
+ const entityPoints = entityPointsArray[i];
185
+ const radians = entities[i].zRotation;
186
+ const center = findCentroid(entityPoints);
187
+ for (let j = i; j < entities.length; j++) {
188
+ entityPointsArray[j] = rotateRectangle(
189
+ entityPointsArray[j],
190
+ radians,
191
+ center
192
+ );
193
+ }
194
+ }
195
+ return entityPointsArray[entityPointsArray.length - 1];
196
+ }
197
+ /**
198
+ * Rotates the canvas so the entity appears rotated when drawn.
199
+ *
200
+ * @remarks Entities inherit rotations from their ancestors. Each ancestor,
201
+ * however, rotates around its own anchor point. Thus, we must rotate the
202
+ * canvas around the anchor point of each ancestor as well as the entity's
203
+ * anchor point.
204
+ *
205
+ * @param canvas - CanvasKit canvas to rotate
206
+ * @param drawableEntity - Entity to rotate the canvas for
207
+ */
208
+ static rotateCanvasForDrawableEntity(canvas, drawableEntity) {
209
+ const rotationTransforms = calculateRotationTransforms(drawableEntity);
210
+ if (rotationTransforms.length === 0) {
211
+ return;
212
+ }
213
+ const drawScale = Globals.canvasScale / drawableEntity.absoluteScale;
214
+ applyRotationTransformsToCanvas(rotationTransforms, drawScale, canvas);
215
+ }
216
+ /**
217
+ * Calculates the absolute bounding box of the entity before any rotation
218
+ * is applied.
219
+ *
220
+ * @remarks The absolute bounding box is the bounding box of the entity
221
+ * relative to the scene's origin (0, 0).
222
+ *
223
+ * @param entity
224
+ * @returns the bounding box of the entity
225
+ */
226
+ static calculateEntityAbsoluteBoundingBox(entity) {
227
+ const anchorPoint = entity.anchorPoint;
228
+ const scale = entity.absoluteScale;
229
+ let width = entity.size.width;
230
+ let height = entity.size.height;
231
+ if (entity.type === EntityType.Shape && entity.shapeType === ShapeType.Circle) {
232
+ const radius = entity.circleOfRadius;
233
+ if (!radius) {
234
+ throw "circleOfRadius is undefined";
235
+ }
236
+ width = radius * 2;
237
+ height = radius * 2;
238
+ }
239
+ const xMin = entity.absolutePosition.x - width * anchorPoint.x * scale;
240
+ const xMax = entity.absolutePosition.x + width * (1 - anchorPoint.x) * scale;
241
+ const yMin = entity.absolutePosition.y - height * anchorPoint.y * scale;
242
+ const yMax = entity.absolutePosition.y + height * (1 - anchorPoint.y) * scale;
243
+ return { xMin, xMax, yMin, yMax };
244
+ }
245
+ /**
246
+ * Converts an angle from radians to degrees.
247
+ *
248
+ * @remarks In m2c2kit, radians are counter clockwise from the positive
249
+ * x-axis, but the rotate method in CanvasKit uses degrees clockwise. Thus
250
+ * we negate after conversion from radians to degrees.
251
+ *
252
+ * @param radians - The angle in radians
253
+ * @returns The angle in degrees
254
+ */
255
+ static radiansToDegrees(radians) {
256
+ return -M2c2KitHelpers.normalizeAngleRadians(radians) * (180 / Math.PI);
257
+ }
258
+ /**
259
+ * Normalizes an angle in radians to the range [0, 2*Math.PI)
260
+ *
261
+ * @param radians - angle in radians
262
+ * @returns normalized angle in radians
263
+ */
264
+ static normalizeAngleRadians(radians) {
265
+ const quotient = Math.floor(radians / (2 * Math.PI));
266
+ let normalized = radians - quotient * (2 * Math.PI);
267
+ if (normalized < 0) {
268
+ normalized += 2 * Math.PI;
269
+ }
270
+ return normalized;
271
+ }
272
+ /**
273
+ * Checks if a point is inside a rectangle.
274
+ *
275
+ * @param point - The Point to check
276
+ * @param rect - An array of four Points representing the vertices of the
277
+ * rectangle in clockwise order
278
+ * @returns true if the Point is inside the rectangle
279
+ */
280
+ static isPointInsideRectangle(point, rect) {
281
+ for (let i = 0; i < 4; i++) {
282
+ const p1 = rect[i];
283
+ const p2 = rect[(i + 1) % 4];
284
+ const cross = (p2.x - p1.x) * (point.y - p1.y) - (p2.y - p1.y) * (point.x - p1.x);
285
+ if (cross > 0) {
286
+ return false;
287
+ }
288
+ }
289
+ return true;
290
+ }
291
+ }
292
+ function applyRotationTransformsToCanvas(rotationTransforms, scale, canvas) {
293
+ rotationTransforms.forEach((transform) => {
294
+ canvas.rotate(
295
+ M2c2KitHelpers.radiansToDegrees(transform.radians),
296
+ transform.center.x * scale,
297
+ transform.center.y * scale
298
+ );
299
+ });
300
+ }
301
+ function calculateRotationTransforms(drawableEntity) {
302
+ const rotationTransforms = [];
303
+ const entities = drawableEntity.ancestors;
304
+ entities.reverse();
305
+ entities.push(drawableEntity);
306
+ entities.forEach((entity) => {
307
+ if (entityNeedsRotation(entity)) {
308
+ const drawable = entity;
309
+ if (drawable.type === EntityType.Scene) {
310
+ const center2 = {
311
+ x: drawable.absolutePosition.x + drawable.size.width * 0.5,
312
+ y: drawable.absolutePosition.y + drawable.size.height * 0.5
313
+ };
314
+ rotationTransforms.push({
315
+ radians: drawable.zRotation,
316
+ center: center2
317
+ });
318
+ return;
319
+ }
320
+ const boundingBox = M2c2KitHelpers.calculateEntityAbsoluteBoundingBox(drawable);
321
+ const points = boundingBoxToPoints(boundingBox);
322
+ const center = findCentroid(points);
323
+ rotationTransforms.push({
324
+ radians: drawable.zRotation,
325
+ center
326
+ });
327
+ }
328
+ });
329
+ return rotationTransforms;
330
+ }
331
+ function entityNeedsRotation(entity) {
332
+ return M2c2KitHelpers.normalizeAngleRadians(entity.zRotation) !== 0 && entity.isDrawable;
333
+ }
334
+ function boundingBoxToPoints(boundingBox) {
335
+ const { xMin, xMax, yMin, yMax } = boundingBox;
336
+ const points = [
337
+ { x: xMin, y: yMin },
338
+ // Top left
339
+ { x: xMin, y: yMax },
340
+ // Bottom left
341
+ { x: xMax, y: yMax },
342
+ // Bottom right
343
+ { x: xMax, y: yMin }
344
+ // Top right
345
+ ];
346
+ return points;
347
+ }
348
+ function findCentroid(points) {
349
+ if (points.length !== 4) {
350
+ throw new Error("Invalid input: expected an array of four points");
351
+ }
352
+ let xSum = 0;
353
+ let ySum = 0;
354
+ for (const point of points) {
355
+ xSum += point.x;
356
+ ySum += point.y;
357
+ }
358
+ const xAvg = xSum / 4;
359
+ const yAvg = ySum / 4;
360
+ return { x: xAvg, y: yAvg };
361
+ }
362
+ function rotatePoint(point, radians, center) {
363
+ const dx = point.x - center.x;
364
+ const dy = point.y - center.y;
365
+ const x = dx * Math.cos(-radians) - dy * Math.sin(-radians);
366
+ const y = dx * Math.sin(-radians) + dy * Math.cos(-radians);
367
+ return {
368
+ x: x + center.x,
369
+ y: y + center.y
370
+ };
371
+ }
372
+ function rotateRectangle(rect, radians, center) {
373
+ if (rect.length !== 4) {
374
+ throw new Error("Invalid input: expected an array of four points");
375
+ }
376
+ const rotated = [];
377
+ for (const p of rect) {
378
+ rotated.push(rotatePoint(p, radians, center));
379
+ }
380
+ return rotated;
381
+ }
382
+
150
383
  class Action {
151
384
  constructor(runDuringTransition = false) {
152
- __publicField$j(this, "startOffset", -1);
153
- __publicField$j(this, "endOffset", -1);
154
- __publicField$j(this, "started", false);
155
- __publicField$j(this, "running", false);
156
- __publicField$j(this, "completed", false);
157
- __publicField$j(this, "runStartTime", -1);
158
- __publicField$j(this, "duration", 0);
159
- __publicField$j(this, "runDuringTransition");
160
- __publicField$j(this, "parent");
161
- __publicField$j(this, "isParent", false);
162
- __publicField$j(this, "isChild", false);
163
- __publicField$j(this, "key");
385
+ this.startOffset = -1;
386
+ this.endOffset = -1;
387
+ this.started = false;
388
+ this.running = false;
389
+ this.completed = false;
390
+ this.runStartTime = -1;
391
+ this.duration = 0;
392
+ this.isParent = false;
393
+ this.isChild = false;
164
394
  this.runDuringTransition = runDuringTransition;
165
395
  }
166
396
  /**
@@ -170,12 +400,11 @@ class Action {
170
400
  * @returns The move action
171
401
  */
172
402
  static move(options) {
173
- var _a, _b;
174
403
  return new MoveAction(
175
404
  options.point,
176
405
  options.duration,
177
- (_a = options.easing) != null ? _a : Easings.linear,
178
- (_b = options.runDuringTransition) != null ? _b : false
406
+ options.easing ?? Easings.linear,
407
+ options.runDuringTransition ?? false
179
408
  );
180
409
  }
181
410
  /**
@@ -185,10 +414,9 @@ class Action {
185
414
  * @returns The wait action
186
415
  */
187
416
  static wait(options) {
188
- var _a;
189
417
  return new WaitAction(
190
418
  options.duration,
191
- (_a = options.runDuringTransition) != null ? _a : false
419
+ options.runDuringTransition ?? false
192
420
  );
193
421
  }
194
422
  /**
@@ -198,10 +426,9 @@ class Action {
198
426
  * @returns The custom action
199
427
  */
200
428
  static custom(options) {
201
- var _a;
202
429
  return new CustomAction(
203
430
  options.callback,
204
- (_a = options.runDuringTransition) != null ? _a : false
431
+ options.runDuringTransition ?? false
205
432
  );
206
433
  }
207
434
  /**
@@ -234,6 +461,37 @@ class Action {
234
461
  options.runDuringTransition
235
462
  );
236
463
  }
464
+ /**
465
+ * Creates an action that will rotate the entity.
466
+ *
467
+ * @remarks Rotate actions are applied to their children. In addition to this entity's rotate action, all ancestors' rotate actions will also be applied.
468
+ *
469
+ * @param options - {@link RotateActionOptions}
470
+ * @returns The rotate action
471
+ */
472
+ static rotate(options) {
473
+ if (options.byAngle !== void 0 && options.toAngle !== void 0) {
474
+ throw new Error("rotate Action: cannot specify both byAngle and toAngle");
475
+ }
476
+ if (options.byAngle === void 0 && options.toAngle === void 0) {
477
+ throw new Error("rotate Action: must specify either byAngle or toAngle");
478
+ }
479
+ if (options.toAngle === void 0 && options.shortestUnitArc !== void 0) {
480
+ throw new Error(
481
+ "rotate Action: shortestUnitArc can only be specified when toAngle is provided"
482
+ );
483
+ }
484
+ if (options.toAngle !== void 0 && options.shortestUnitArc === void 0) {
485
+ options.shortestUnitArc = true;
486
+ }
487
+ return new RotateAction(
488
+ options.byAngle,
489
+ options.toAngle,
490
+ options.shortestUnitArc,
491
+ options.duration,
492
+ options.runDuringTransition
493
+ );
494
+ }
237
495
  /**
238
496
  * Creates an array of actions that will be run in order.
239
497
  *
@@ -329,6 +587,17 @@ class Action {
329
587
  });
330
588
  break;
331
589
  }
590
+ case ActionType.Rotate: {
591
+ const rotate = action;
592
+ cloned = Action.rotate({
593
+ byAngle: rotate.byAngle,
594
+ toAngle: rotate.toAngle,
595
+ shortestUnitArc: rotate.shortestUnitArc,
596
+ duration: rotate.duration,
597
+ runDuringTransition: rotate.runDuringTransition
598
+ });
599
+ break;
600
+ }
332
601
  case ActionType.Wait: {
333
602
  const wait = action;
334
603
  cloned = Action.wait({
@@ -430,6 +699,41 @@ class Action {
430
699
  fadeAlphaAction.completed = true;
431
700
  }
432
701
  }
702
+ if (action.type === ActionType.Rotate) {
703
+ const rotateAction = action;
704
+ if (!rotateAction.started) {
705
+ if (rotateAction.byAngle !== void 0) {
706
+ rotateAction.delta = rotateAction.byAngle;
707
+ }
708
+ if (rotateAction.toAngle !== void 0) {
709
+ rotateAction.toAngle = M2c2KitHelpers.normalizeAngleRadians(
710
+ rotateAction.toAngle
711
+ );
712
+ entity.zRotation = M2c2KitHelpers.normalizeAngleRadians(
713
+ entity.zRotation
714
+ );
715
+ rotateAction.delta = rotateAction.toAngle - entity.zRotation;
716
+ if (rotateAction.shortestUnitArc === true && Math.abs(rotateAction.delta) > Math.PI) {
717
+ rotateAction.delta = 2 * Math.PI - Math.abs(rotateAction.delta);
718
+ }
719
+ }
720
+ rotateAction.started = true;
721
+ rotateAction.finalValue = entity.zRotation + rotateAction.delta;
722
+ }
723
+ if (elapsed < rotateAction.duration) {
724
+ entity.zRotation = entity.zRotation + rotateAction.delta * (dt / rotateAction.duration);
725
+ if (rotateAction.delta <= 0 && entity.zRotation < rotateAction.finalValue) {
726
+ entity.zRotation = rotateAction.finalValue;
727
+ }
728
+ if (rotateAction.delta > 0 && entity.zRotation > rotateAction.finalValue) {
729
+ entity.zRotation = rotateAction.finalValue;
730
+ }
731
+ } else {
732
+ entity.zRotation = rotateAction.finalValue;
733
+ rotateAction.running = false;
734
+ rotateAction.completed = true;
735
+ }
736
+ }
433
737
  }
434
738
  /**
435
739
  * Calculates the duration of an action, including any children actions
@@ -467,17 +771,16 @@ class Action {
467
771
  * @param action that needs assigning start and end offsets
468
772
  */
469
773
  calculateStartEndOffsets(action) {
470
- var _a, _b, _c;
471
774
  let parentStartOffset;
472
775
  if (action.parent === void 0) {
473
776
  parentStartOffset = 0;
474
777
  } else {
475
778
  parentStartOffset = action.parent.startOffset;
476
779
  }
477
- if (((_a = action.parent) == null ? void 0 : _a.type) === ActionType.Group) {
780
+ if (action.parent?.type === ActionType.Group) {
478
781
  action.startOffset = parentStartOffset;
479
782
  action.endOffset = action.startOffset + action.duration;
480
- } else if (((_b = action.parent) == null ? void 0 : _b.type) === ActionType.Sequence) {
783
+ } else if (action.parent?.type === ActionType.Sequence) {
481
784
  const parent = action.parent;
482
785
  let dur = 0;
483
786
  for (const a of parent.children) {
@@ -493,7 +796,7 @@ class Action {
493
796
  action.endOffset = action.startOffset + action.duration;
494
797
  }
495
798
  if (action.isParent) {
496
- (_c = action.children) == null ? void 0 : _c.forEach(
799
+ action.children?.forEach(
497
800
  (child) => this.calculateStartEndOffsets(child)
498
801
  );
499
802
  }
@@ -551,8 +854,7 @@ class Action {
551
854
  class SequenceAction extends Action {
552
855
  constructor(actions) {
553
856
  super();
554
- __publicField$j(this, "type", ActionType.Sequence);
555
- __publicField$j(this, "children");
857
+ this.type = ActionType.Sequence;
556
858
  this.children = actions;
557
859
  this.isParent = true;
558
860
  }
@@ -560,8 +862,8 @@ class SequenceAction extends Action {
560
862
  class GroupAction extends Action {
561
863
  constructor(actions) {
562
864
  super();
563
- __publicField$j(this, "type", ActionType.Group);
564
- __publicField$j(this, "children", new Array());
865
+ this.type = ActionType.Group;
866
+ this.children = new Array();
565
867
  this.children = actions;
566
868
  this.isParent = true;
567
869
  }
@@ -569,8 +871,7 @@ class GroupAction extends Action {
569
871
  class CustomAction extends Action {
570
872
  constructor(callback, runDuringTransition = false) {
571
873
  super(runDuringTransition);
572
- __publicField$j(this, "type", ActionType.Custom);
573
- __publicField$j(this, "callback");
874
+ this.type = ActionType.Custom;
574
875
  this.callback = callback;
575
876
  this.isParent = false;
576
877
  this.duration = 0;
@@ -579,7 +880,7 @@ class CustomAction extends Action {
579
880
  class WaitAction extends Action {
580
881
  constructor(duration, runDuringTransition) {
581
882
  super(runDuringTransition);
582
- __publicField$j(this, "type", ActionType.Wait);
883
+ this.type = ActionType.Wait;
583
884
  this.duration = duration;
584
885
  this.isParent = false;
585
886
  }
@@ -587,12 +888,9 @@ class WaitAction extends Action {
587
888
  class MoveAction extends Action {
588
889
  constructor(point, duration, easing, runDuringTransition) {
589
890
  super(runDuringTransition);
590
- __publicField$j(this, "type", ActionType.Move);
591
- __publicField$j(this, "point");
592
- __publicField$j(this, "startPoint");
593
- __publicField$j(this, "dx", 0);
594
- __publicField$j(this, "dy", 0);
595
- __publicField$j(this, "easing");
891
+ this.type = ActionType.Move;
892
+ this.dx = 0;
893
+ this.dy = 0;
596
894
  this.duration = duration;
597
895
  this.point = point;
598
896
  this.isParent = false;
@@ -603,9 +901,8 @@ class MoveAction extends Action {
603
901
  class ScaleAction extends Action {
604
902
  constructor(scale, duration, runDuringTransition = false) {
605
903
  super(runDuringTransition);
606
- __publicField$j(this, "type", ActionType.Scale);
607
- __publicField$j(this, "scale");
608
- __publicField$j(this, "delta", 0);
904
+ this.type = ActionType.Scale;
905
+ this.delta = 0;
609
906
  this.duration = duration;
610
907
  this.scale = scale;
611
908
  this.isParent = false;
@@ -614,14 +911,26 @@ class ScaleAction extends Action {
614
911
  class FadeAlphaAction extends Action {
615
912
  constructor(alpha, duration, runDuringTransition = false) {
616
913
  super(runDuringTransition);
617
- __publicField$j(this, "type", ActionType.FadeAlpha);
618
- __publicField$j(this, "alpha");
619
- __publicField$j(this, "delta", 0);
914
+ this.type = ActionType.FadeAlpha;
915
+ this.delta = 0;
620
916
  this.duration = duration;
621
917
  this.alpha = alpha;
622
918
  this.isParent = false;
623
919
  }
624
920
  }
921
+ class RotateAction extends Action {
922
+ constructor(byAngle, toAngle, shortestUnitArc, duration, runDuringTransition = false) {
923
+ super(runDuringTransition);
924
+ this.type = ActionType.Rotate;
925
+ this.delta = 0;
926
+ this.finalValue = NaN;
927
+ this.duration = duration;
928
+ this.byAngle = byAngle;
929
+ this.toAngle = toAngle;
930
+ this.shortestUnitArc = shortestUnitArc;
931
+ this.isParent = false;
932
+ }
933
+ }
625
934
 
626
935
  var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
627
936
  ActivityType2["Game"] = "Game";
@@ -638,7 +947,7 @@ class CanvasKitHelpers {
638
947
  * free these wasm objects.
639
948
  */
640
949
  static Dispose(objects) {
641
- objects.filter((o) => !(o == null ? void 0 : o.isDeleted())).forEach((o) => o == null ? void 0 : o.delete());
950
+ objects.filter((o) => !o?.isDeleted()).forEach((o) => o?.delete());
642
951
  }
643
952
  static makePaint(canvasKit, color, style, isAntialiased) {
644
953
  const paint = new canvasKit.Paint();
@@ -649,23 +958,316 @@ class CanvasKitHelpers {
649
958
  }
650
959
  }
651
960
 
652
- var __defProp$i = Object.defineProperty;
653
- var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
654
- var __publicField$i = (obj, key, value) => {
655
- __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
656
- return value;
657
- };
961
+ class MutablePath {
962
+ constructor() {
963
+ this._subpaths = new Array();
964
+ this.currentPath = new Array();
965
+ }
966
+ get subpaths() {
967
+ if (this.currentPath.length > 0) {
968
+ return [...this._subpaths, this.currentPath];
969
+ } else {
970
+ return this._subpaths;
971
+ }
972
+ }
973
+ /**
974
+ * Starts a new subpath at a given point.
975
+ *
976
+ * @param point - location at which to start the new subpath
977
+ */
978
+ move(point) {
979
+ if (this.currentPath.length > 0) {
980
+ this._subpaths.push(this.currentPath);
981
+ }
982
+ this.currentPath = new Array();
983
+ this.currentPath.push(point);
984
+ }
985
+ /**
986
+ * Adds a straight line to the current subpath.
987
+ *
988
+ * @remarks The line is added from the last point in the current subpath to
989
+ * the given point.
990
+ *
991
+ * @param point - location where the line will end
992
+ */
993
+ addLine(point) {
994
+ this.currentPath.push(point);
995
+ }
996
+ /**
997
+ * Removes all subpaths from the shape.
998
+ */
999
+ clear() {
1000
+ this._subpaths = new Array();
1001
+ this.currentPath = new Array();
1002
+ }
1003
+ /**
1004
+ * Makes a deep copy.
1005
+ *
1006
+ * @returns a deep copy
1007
+ */
1008
+ duplicate() {
1009
+ const newPath = new MutablePath();
1010
+ newPath._subpaths = JSON.parse(JSON.stringify(this._subpaths));
1011
+ newPath.currentPath = JSON.parse(JSON.stringify(this.currentPath));
1012
+ return newPath;
1013
+ }
1014
+ }
1015
+
1016
+ class WebColors {
1017
+ }
1018
+ WebColors.Transparent = [0, 0, 0, 0];
1019
+ WebColors.MediumVioletRed = [199, 21, 133, 1];
1020
+ WebColors.DeepPink = [255, 20, 147, 1];
1021
+ WebColors.PaleVioletRed = [219, 112, 147, 1];
1022
+ WebColors.HotPink = [255, 105, 180, 1];
1023
+ WebColors.LightPink = [255, 182, 193, 1];
1024
+ WebColors.Pink = [255, 192, 203, 1];
1025
+ WebColors.DarkRed = [139, 0, 0, 1];
1026
+ WebColors.Red = [255, 0, 0, 1];
1027
+ WebColors.Firebrick = [178, 34, 34, 1];
1028
+ WebColors.Crimson = [220, 20, 60, 1];
1029
+ WebColors.IndianRed = [205, 92, 92, 1];
1030
+ WebColors.LightCoral = [240, 128, 128, 1];
1031
+ WebColors.Salmon = [250, 128, 114, 1];
1032
+ WebColors.DarkSalmon = [233, 150, 122, 1];
1033
+ WebColors.LightSalmon = [255, 160, 122, 1];
1034
+ WebColors.OrangeRed = [255, 69, 0, 1];
1035
+ WebColors.Tomato = [255, 99, 71, 1];
1036
+ WebColors.DarkOrange = [255, 140, 0, 1];
1037
+ WebColors.Coral = [255, 127, 80, 1];
1038
+ WebColors.Orange = [255, 165, 0, 1];
1039
+ WebColors.DarkKhaki = [189, 183, 107, 1];
1040
+ WebColors.Gold = [255, 215, 0, 1];
1041
+ WebColors.Khaki = [240, 230, 140, 1];
1042
+ WebColors.PeachPuff = [255, 218, 185, 1];
1043
+ WebColors.Yellow = [255, 255, 0, 1];
1044
+ WebColors.PaleGoldenrod = [238, 232, 170, 1];
1045
+ WebColors.Moccasin = [255, 228, 181, 1];
1046
+ WebColors.PapayaWhip = [255, 239, 213, 1];
1047
+ WebColors.LightGoldenrodYellow = [250, 250, 210, 1];
1048
+ WebColors.LemonChiffon = [255, 250, 205, 1];
1049
+ WebColors.LightYellow = [255, 255, 224, 1];
1050
+ WebColors.Maroon = [128, 0, 0, 1];
1051
+ WebColors.Brown = [165, 42, 42, 1];
1052
+ WebColors.SaddleBrown = [139, 69, 19, 1];
1053
+ WebColors.Sienna = [160, 82, 45, 1];
1054
+ WebColors.Chocolate = [210, 105, 30, 1];
1055
+ WebColors.DarkGoldenrod = [184, 134, 11, 1];
1056
+ WebColors.Peru = [205, 133, 63, 1];
1057
+ WebColors.RosyBrown = [188, 143, 143, 1];
1058
+ WebColors.Goldenrod = [218, 165, 32, 1];
1059
+ WebColors.SandyBrown = [244, 164, 96, 1];
1060
+ WebColors.Tan = [210, 180, 140, 1];
1061
+ WebColors.Burlywood = [222, 184, 135, 1];
1062
+ WebColors.Wheat = [245, 222, 179, 1];
1063
+ WebColors.NavajoWhite = [255, 222, 173, 1];
1064
+ WebColors.Bisque = [255, 228, 196, 1];
1065
+ WebColors.BlanchedAlmond = [255, 235, 205, 1];
1066
+ WebColors.Cornsilk = [255, 248, 220, 1];
1067
+ WebColors.DarkGreen = [0, 100, 0, 1];
1068
+ WebColors.Green = [0, 128, 0, 1];
1069
+ WebColors.DarkOliveGreen = [85, 107, 47, 1];
1070
+ WebColors.ForestGreen = [34, 139, 34, 1];
1071
+ WebColors.SeaGreen = [46, 139, 87, 1];
1072
+ WebColors.Olive = [128, 128, 0, 1];
1073
+ WebColors.OliveDrab = [107, 142, 35, 1];
1074
+ WebColors.MediumSeaGreen = [60, 179, 113, 1];
1075
+ WebColors.LimeGreen = [50, 205, 50, 1];
1076
+ WebColors.Lime = [0, 255, 0, 1];
1077
+ WebColors.SpringGreen = [0, 255, 127, 1];
1078
+ WebColors.MediumSpringGreen = [0, 250, 154, 1];
1079
+ WebColors.DarkSeaGreen = [143, 188, 143, 1];
1080
+ WebColors.MediumAquamarine = [102, 205, 170, 1];
1081
+ WebColors.YellowGreen = [154, 205, 50, 1];
1082
+ WebColors.LawnGreen = [124, 252, 0, 1];
1083
+ WebColors.Chartreuse = [127, 255, 0, 1];
1084
+ WebColors.LightGreen = [144, 238, 144, 1];
1085
+ WebColors.GreenYellow = [173, 255, 47, 1];
1086
+ WebColors.PaleGreen = [152, 251, 152, 1];
1087
+ WebColors.Teal = [0, 128, 128, 1];
1088
+ WebColors.DarkCyan = [0, 139, 139, 1];
1089
+ WebColors.LightSeaGreen = [32, 178, 170, 1];
1090
+ WebColors.CadetBlue = [95, 158, 160, 1];
1091
+ WebColors.DarkTurquoise = [0, 206, 209, 1];
1092
+ WebColors.MediumTurquoise = [72, 209, 204, 1];
1093
+ WebColors.Turquoise = [64, 224, 208, 1];
1094
+ WebColors.Aqua = [0, 255, 255, 1];
1095
+ WebColors.Cyan = [0, 255, 255, 1];
1096
+ WebColors.Aquamarine = [127, 255, 212, 1];
1097
+ WebColors.PaleTurquoise = [175, 238, 238, 1];
1098
+ WebColors.LightCyan = [224, 255, 255, 1];
1099
+ WebColors.Navy = [0, 0, 128, 1];
1100
+ WebColors.DarkBlue = [0, 0, 139, 1];
1101
+ WebColors.MediumBlue = [0, 0, 205, 1];
1102
+ WebColors.Blue = [0, 0, 255, 1];
1103
+ WebColors.MidnightBlue = [25, 25, 112, 1];
1104
+ WebColors.RoyalBlue = [65, 105, 225, 1];
1105
+ WebColors.SteelBlue = [70, 130, 180, 1];
1106
+ WebColors.DodgerBlue = [30, 144, 255, 1];
1107
+ WebColors.DeepSkyBlue = [0, 191, 255, 1];
1108
+ WebColors.CornflowerBlue = [100, 149, 237, 1];
1109
+ WebColors.SkyBlue = [135, 206, 235, 1];
1110
+ WebColors.LightSkyBlue = [135, 206, 250, 1];
1111
+ WebColors.LightSteelBlue = [176, 196, 222, 1];
1112
+ WebColors.LightBlue = [173, 216, 230, 1];
1113
+ WebColors.PowderBlue = [176, 224, 230, 1];
1114
+ WebColors.Indigo = [75, 0, 130, 1];
1115
+ WebColors.Purple = [128, 0, 128, 1];
1116
+ WebColors.DarkMagenta = [139, 0, 139, 1];
1117
+ WebColors.DarkViolet = [148, 0, 211, 1];
1118
+ WebColors.DarkSlateBlue = [72, 61, 139, 1];
1119
+ WebColors.BlueViolet = [138, 43, 226, 1];
1120
+ WebColors.DarkOrchid = [153, 50, 204, 1];
1121
+ WebColors.Fuchsia = [255, 0, 255, 1];
1122
+ WebColors.Magenta = [255, 0, 255, 1];
1123
+ WebColors.SlateBlue = [106, 90, 205, 1];
1124
+ WebColors.MediumSlateBlue = [123, 104, 238, 1];
1125
+ WebColors.MediumOrchid = [186, 85, 211, 1];
1126
+ WebColors.MediumPurple = [147, 112, 219, 1];
1127
+ WebColors.Orchid = [218, 112, 214, 1];
1128
+ WebColors.Violet = [238, 130, 238, 1];
1129
+ WebColors.Plum = [221, 160, 221, 1];
1130
+ WebColors.Thistle = [216, 191, 216, 1];
1131
+ WebColors.Lavender = [230, 230, 250, 1];
1132
+ WebColors.MistyRose = [255, 228, 225, 1];
1133
+ WebColors.AntiqueWhite = [250, 235, 215, 1];
1134
+ WebColors.Linen = [250, 240, 230, 1];
1135
+ WebColors.Beige = [245, 245, 220, 1];
1136
+ WebColors.WhiteSmoke = [245, 245, 245, 1];
1137
+ WebColors.LavenderBlush = [255, 240, 245, 1];
1138
+ WebColors.OldLace = [253, 245, 230, 1];
1139
+ WebColors.AliceBlue = [240, 248, 255, 1];
1140
+ WebColors.Seashell = [255, 245, 238, 1];
1141
+ WebColors.GhostWhite = [248, 248, 255, 1];
1142
+ WebColors.Honeydew = [240, 255, 240, 1];
1143
+ WebColors.FloralWhite = [255, 250, 240, 1];
1144
+ WebColors.Azure = [240, 255, 255, 1];
1145
+ WebColors.MintCream = [245, 255, 250, 1];
1146
+ WebColors.Snow = [255, 250, 250, 1];
1147
+ WebColors.Ivory = [255, 255, 240, 1];
1148
+ WebColors.White = [255, 255, 255, 1];
1149
+ WebColors.Black = [0, 0, 0, 1];
1150
+ WebColors.DarkSlateGray = [47, 79, 79, 1];
1151
+ WebColors.DimGray = [105, 105, 105, 1];
1152
+ WebColors.SlateGray = [112, 128, 144, 1];
1153
+ WebColors.Gray = [128, 128, 128, 1];
1154
+ WebColors.LightSlateGray = [119, 136, 153, 1];
1155
+ WebColors.DarkGray = [169, 169, 169, 1];
1156
+ WebColors.Silver = [192, 192, 192, 1];
1157
+ WebColors.LightGray = [211, 211, 211, 1];
1158
+ WebColors.Gainsboro = [220, 220, 220, 1];
1159
+ WebColors.RebeccaPurple = [102, 51, 153, 1];
1160
+
1161
+ class Constants {
1162
+ }
1163
+ /** Size of the font showing frames per second */
1164
+ Constants.FPS_DISPLAY_TEXT_FONT_SIZE = 12;
1165
+ /** Color of the font showing frames per second */
1166
+ Constants.FPS_DISPLAY_TEXT_COLOR = [0, 0, 0, 0.5];
1167
+ /** Frequency, in milliseconds, at which to update frames per second metric shown on the screen */
1168
+ Constants.FPS_DISPLAY_UPDATE_INTERVAL = 1e3;
1169
+ /** Maximum number of activity metrics to log. */
1170
+ Constants.MAXIMUM_RECORDED_ACTIVITY_METRICS = 32;
1171
+ /** The frames per second will be logged in game metrics if the FPS is lower than this value */
1172
+ Constants.FPS_METRIC_REPORT_THRESHOLD = 59;
1173
+ /** Scene color, if none is specified. */
1174
+ Constants.DEFAULT_SCENE_BACKGROUND_COLOR = WebColors.White;
1175
+ /** Shape fill color, if none is specified. */
1176
+ Constants.DEFAULT_SHAPE_FILL_COLOR = WebColors.Red;
1177
+ /** Color of paths in a shape, if none is specified. */
1178
+ Constants.DEFAULT_PATH_STROKE_COLOR = WebColors.Red;
1179
+ /** Line width of paths in a shape, if none is specified. */
1180
+ Constants.DEFAULT_PATH_LINE_WIDTH = 2;
1181
+ /** Color of text in Label and TextLine, if none is specified. */
1182
+ Constants.DEFAULT_FONT_COLOR = WebColors.Black;
1183
+ /** Font size in Label and TextLine, if none is specified. */
1184
+ Constants.DEFAULT_FONT_SIZE = 16;
1185
+ Constants.LIMITED_FPS_RATE = 5;
1186
+ Constants.FREE_ENTITIES_SCENE_NAME = "__freeEntitiesScene";
1187
+ Constants.OUTGOING_SCENE_NAME = "__outgoingScene";
1188
+ Constants.OUTGOING_SCENE_SPRITE_NAME = "__outgoingSceneSprite";
1189
+ Constants.OUTGOING_SCENE_IMAGE_NAME = "__outgoingSceneSnapshot";
1190
+ Constants.SESSION_INITIALIZATION_POLLING_INTERVAL_MS = 50;
1191
+
1192
+ class ColorfulMutablePath extends MutablePath {
1193
+ constructor() {
1194
+ super(...arguments);
1195
+ /** Stroke color to be applied to subsequent lines. */
1196
+ this.strokeColor = Constants.DEFAULT_PATH_STROKE_COLOR;
1197
+ /** Line width to be applied to subsequent lines. */
1198
+ this.lineWidth = Constants.DEFAULT_PATH_LINE_WIDTH;
1199
+ /** Colors and widths of lines in the path. */
1200
+ this.linePresentations = [];
1201
+ }
1202
+ /**
1203
+ * Adds a straight line to the current subpath
1204
+ *
1205
+ * @remarks The line is added from the last point in the current subpath to
1206
+ * the given point, with the current stroke color and line width.
1207
+ *
1208
+ * @param point - location where the line will end
1209
+ */
1210
+ addLine(point) {
1211
+ if (this.isNewLinePresentation()) {
1212
+ this.linePresentations.push({
1213
+ strokeColor: this.strokeColor,
1214
+ lineWidth: this.lineWidth,
1215
+ subpathIndex: this._subpaths.length,
1216
+ pointIndex: this.currentPath.length - 1
1217
+ });
1218
+ }
1219
+ this.currentPath.push(point);
1220
+ }
1221
+ /**
1222
+ * Checks if the current line presentation (stroke color and line width) is
1223
+ * different from the last line presentation.
1224
+ *
1225
+ * @returns true if the current line presentation is different from the last
1226
+ */
1227
+ isNewLinePresentation() {
1228
+ if (this.linePresentations.length === 0) {
1229
+ return true;
1230
+ }
1231
+ const currentLinePresentation = this.linePresentations[this.linePresentations.length - 1];
1232
+ return currentLinePresentation.strokeColor !== this.strokeColor || currentLinePresentation.lineWidth !== this.lineWidth;
1233
+ }
1234
+ /**
1235
+ * Removes all subpaths from the shape and resets the stroke color and line
1236
+ * width to their default values.
1237
+ */
1238
+ clear() {
1239
+ super.clear();
1240
+ this.linePresentations = [];
1241
+ this.strokeColor = Constants.DEFAULT_PATH_STROKE_COLOR;
1242
+ this.lineWidth = Constants.DEFAULT_PATH_LINE_WIDTH;
1243
+ }
1244
+ /**
1245
+ * Makes a deep copy.
1246
+ *
1247
+ * @returns a deep copy
1248
+ */
1249
+ duplicate() {
1250
+ const newPath = super.duplicate();
1251
+ newPath.strokeColor = JSON.parse(JSON.stringify(this.strokeColor));
1252
+ newPath.lineWidth = this.lineWidth;
1253
+ newPath.linePresentations = JSON.parse(
1254
+ JSON.stringify(this.linePresentations)
1255
+ );
1256
+ return newPath;
1257
+ }
1258
+ }
1259
+
658
1260
  class GlobalVariables {
659
1261
  constructor() {
660
- __publicField$i(this, "now", NaN);
661
- __publicField$i(this, "deltaTime", NaN);
662
- __publicField$i(this, "canvasScale", NaN);
1262
+ this.now = NaN;
1263
+ this.deltaTime = NaN;
1264
+ this.canvasScale = NaN;
663
1265
  // _rootScale is the scaling factor to be applied to scenes to scale up or
664
1266
  // down to fit the device's window while preserving the aspect ratio the
665
1267
  // game was designed for
666
- __publicField$i(this, "rootScale", 1);
667
- __publicField$i(this, "canvasCssWidth", NaN);
668
- __publicField$i(this, "canvasCssHeight", NaN);
1268
+ this.rootScale = 1;
1269
+ this.canvasCssWidth = NaN;
1270
+ this.canvasCssHeight = NaN;
669
1271
  }
670
1272
  }
671
1273
 
@@ -687,20 +1289,8 @@ var ConstraintType = /* @__PURE__ */ ((ConstraintType2) => {
687
1289
  return ConstraintType2;
688
1290
  })(ConstraintType || {});
689
1291
 
690
- var __defProp$h = Object.defineProperty;
691
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
692
- var __publicField$h = (obj, key, value) => {
693
- __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
694
- return value;
695
- };
696
1292
  class LayoutConstraint {
697
1293
  constructor(type, alterEntity) {
698
- // the constraint, e.g., bottomToTopOf
699
- __publicField$h(this, "type");
700
- // alter is the other entity that the focal entity is constrained to.
701
- // in the example above, A is the focal entity, B is the alter
702
- // thus the alter entity property is B
703
- __publicField$h(this, "alterEntity");
704
1294
  // the below 3 properties are calculated from the constraint type
705
1295
  // (we set them to false by default to avoid undefined warnings, but
706
1296
  // they will be definitely assigned in the constructor logic)
@@ -708,37 +1298,37 @@ class LayoutConstraint {
708
1298
  //
709
1299
  // does the constraint affect the Y or X axis? If not, then it's
710
1300
  // a horizontal constraint
711
- __publicField$h(this, "verticalConstraint", false);
1301
+ this.verticalConstraint = false;
712
1302
  // does the constraint apply to the focal entity's "minimum" position
713
1303
  // along its axis? That is, does the constraint reference the focal
714
1304
  // entity's "top" or "start"? Top and start are considered minimums because
715
1305
  // our origin (0, 0) in the upper left.
716
1306
  // If not, then the constraint applies to the focal entity's "maximum"
717
1307
  // position, e.g., its "bottom" or "end".
718
- __publicField$h(this, "focalEntityMinimum", false);
1308
+ this.focalEntityMinimum = false;
719
1309
  // does the constraint apply to the alter entity's "minimum" position
720
1310
  // along its axis?
721
- __publicField$h(this, "alterEntityMinimum", false);
722
- __publicField$h(this, "verticalTypes", [
1311
+ this.alterEntityMinimum = false;
1312
+ this.verticalTypes = [
723
1313
  ConstraintType.topToTopOf,
724
1314
  ConstraintType.topToBottomOf,
725
1315
  ConstraintType.bottomToTopOf,
726
1316
  ConstraintType.bottomToBottomOf
727
- ]);
1317
+ ];
728
1318
  // e.g., entity A
729
- __publicField$h(this, "focalEntityMinimumTypes", [
1319
+ this.focalEntityMinimumTypes = [
730
1320
  ConstraintType.topToTopOf,
731
1321
  ConstraintType.topToBottomOf,
732
1322
  ConstraintType.startToStartOf,
733
1323
  ConstraintType.startToEndOf
734
- ]);
1324
+ ];
735
1325
  // e.g., entity B
736
- __publicField$h(this, "alterEntityMinimumTypes", [
1326
+ this.alterEntityMinimumTypes = [
737
1327
  ConstraintType.topToTopOf,
738
1328
  ConstraintType.bottomToTopOf,
739
1329
  ConstraintType.startToStartOf,
740
1330
  ConstraintType.endToStartOf
741
- ]);
1331
+ ];
742
1332
  this.type = type;
743
1333
  this.alterEntity = alterEntity;
744
1334
  if (this.verticalTypes.includes(type)) {
@@ -769,26 +1359,15 @@ class LayoutConstraint {
769
1359
  }
770
1360
  }
771
1361
 
772
- var EntityType = /* @__PURE__ */ ((EntityType2) => {
773
- EntityType2["Entity"] = "Entity";
774
- EntityType2["Scene"] = "Scene";
775
- EntityType2["Sprite"] = "Sprite";
776
- EntityType2["Label"] = "Label";
777
- EntityType2["TextLine"] = "TextLine";
778
- EntityType2["Shape"] = "Shape";
779
- EntityType2["Composite"] = "Composite";
780
- return EntityType2;
781
- })(EntityType || {});
782
-
783
1362
  class Uuid {
784
1363
  static generate() {
785
1364
  try {
786
1365
  return crypto.randomUUID();
787
- } catch (e) {
1366
+ } catch {
788
1367
  let randomValue;
789
1368
  try {
790
1369
  randomValue = () => crypto.getRandomValues(new Uint8Array(1))[0];
791
- } catch (e2) {
1370
+ } catch {
792
1371
  randomValue = () => Math.floor(Math.random() * 256);
793
1372
  }
794
1373
  return (1e7.toString() + -1e3 + -4e3 + -8e3 + -1e11).replace(
@@ -822,12 +1401,6 @@ const EventType = {
822
1401
  FrameDidSimulatePhysics: "FrameDidSimulatePhysics"
823
1402
  };
824
1403
 
825
- var __defProp$g = Object.defineProperty;
826
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
827
- var __publicField$g = (obj, key, value) => {
828
- __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
829
- return value;
830
- };
831
1404
  function handleDrawableOptions(drawable, options) {
832
1405
  if (options.anchorPoint) {
833
1406
  drawable.anchorPoint = options.anchorPoint;
@@ -863,63 +1436,59 @@ function handleInterfaceOptions(entity, options) {
863
1436
  }
864
1437
  class Entity {
865
1438
  constructor(options = {}) {
866
- __publicField$g(this, "type", EntityType.Entity);
867
- __publicField$g(this, "isDrawable", false);
868
- __publicField$g(this, "isShape", false);
869
- __publicField$g(this, "isText", false);
870
- // Entity Options
871
- __publicField$g(this, "name");
872
- __publicField$g(this, "position", { x: 0, y: 0 });
1439
+ this.type = EntityType.Entity;
1440
+ this.isDrawable = false;
1441
+ this.isShape = false;
1442
+ this.isText = false;
1443
+ this.position = { x: 0, y: 0 };
873
1444
  // position of the entity in the parent coordinate system
874
- __publicField$g(this, "scale", 1);
875
- __publicField$g(this, "alpha", 1);
876
- __publicField$g(this, "isUserInteractionEnabled", false);
877
- __publicField$g(this, "draggable", false);
878
- __publicField$g(this, "hidden", false);
879
- __publicField$g(this, "layout", {});
880
- __publicField$g(this, "_game");
881
- __publicField$g(this, "parent");
882
- __publicField$g(this, "children", new Array());
883
- __publicField$g(this, "absolutePosition", { x: 0, y: 0 });
1445
+ this.scale = 1;
1446
+ this.alpha = 1;
1447
+ this.zRotation = 0;
1448
+ this.isUserInteractionEnabled = false;
1449
+ this.draggable = false;
1450
+ this.hidden = false;
1451
+ this.layout = {};
1452
+ this.children = new Array();
1453
+ this.absolutePosition = { x: 0, y: 0 };
884
1454
  // position within the root coordinate system
885
- __publicField$g(this, "size", { width: 0, height: 0 });
886
- __publicField$g(this, "absoluteScale", 1);
887
- __publicField$g(this, "absoluteAlpha", 1);
888
- __publicField$g(this, "absoluteAlphaChange", 0);
889
- __publicField$g(this, "actions", new Array());
890
- __publicField$g(this, "queuedAction");
891
- __publicField$g(this, "originalActions", new Array());
892
- __publicField$g(this, "eventListeners", new Array());
893
- __publicField$g(this, "uuid", Uuid.generate());
894
- __publicField$g(this, "needsInitialization", true);
1455
+ this.size = { width: 0, height: 0 };
1456
+ this.absoluteScale = 1;
1457
+ this.absoluteAlpha = 1;
1458
+ this.absoluteAlphaChange = 0;
1459
+ this.actions = new Array();
1460
+ this.originalActions = new Array();
1461
+ this.eventListeners = new Array();
1462
+ this.uuid = Uuid.generate();
1463
+ this.needsInitialization = true;
895
1464
  // library users might put anything in userData property
896
1465
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
897
- __publicField$g(this, "userData", {});
898
- __publicField$g(this, "loopMessages", /* @__PURE__ */ new Set());
1466
+ this.userData = {};
1467
+ this.loopMessages = /* @__PURE__ */ new Set();
899
1468
  /** Is the entity in a pressed state? E.g., did the user put the pointer
900
1469
  * down on the entity and not yet release it? */
901
- __publicField$g(this, "pressed", false);
902
- __publicField$g(this, "withinHitArea", false);
1470
+ this.pressed = false;
1471
+ this.withinHitArea = false;
903
1472
  /** Is the entity in a pressed state AND is the pointer within the entity's
904
1473
  * hit area? For example, a user may put the pointer down on the entity, but
905
1474
  * then move the pointer, while still down, beyond the entity's hit area. In
906
1475
  * this case, pressed = true, but pressedAndWithinHitArea = false. */
907
- __publicField$g(this, "pressedAndWithinHitArea", false);
1476
+ this.pressedAndWithinHitArea = false;
908
1477
  /** When the entity initially enters the pressed state, what is the pointer
909
1478
  * offset? (offset from the canvas's origin to the pointer position). We
910
1479
  * save this because it will be needed if this press then led to a drag. */
911
- __publicField$g(this, "pressedInitialPointerOffset", { x: NaN, y: NaN });
1480
+ this.pressedInitialPointerOffset = { x: NaN, y: NaN };
912
1481
  /** What was the previous pointer offset when the entity was in a dragging
913
1482
  * state? */
914
- __publicField$g(this, "draggingLastPointerOffset", { x: NaN, y: NaN });
1483
+ this.draggingLastPointerOffset = { x: NaN, y: NaN };
915
1484
  /** Is the entity in a dragging state? */
916
- __publicField$g(this, "dragging", false);
1485
+ this.dragging = false;
917
1486
  /**
918
1487
  * Overrides toString() and returns a human-friendly description of the entity.
919
1488
  *
920
1489
  * @remarks Inspiration from https://stackoverflow.com/a/35361695
921
1490
  */
922
- __publicField$g(this, "toString", () => {
1491
+ this.toString = () => {
923
1492
  let type = this.type.toString();
924
1493
  if (this.type == EntityType.Composite) {
925
1494
  type = this.compositeType;
@@ -929,7 +1498,7 @@ class Entity {
929
1498
  } else {
930
1499
  return `${type} (${this.uuid})`;
931
1500
  }
932
- });
1501
+ };
933
1502
  if (options.name === void 0) {
934
1503
  this.name = this.uuid;
935
1504
  } else {
@@ -944,6 +1513,9 @@ class Entity {
944
1513
  if (options.alpha !== void 0) {
945
1514
  this.alpha = options.alpha;
946
1515
  }
1516
+ if (options.zRotation !== void 0) {
1517
+ this.zRotation = options.zRotation;
1518
+ }
947
1519
  if (options.isUserInteractionEnabled !== void 0) {
948
1520
  this.isUserInteractionEnabled = options.isUserInteractionEnabled;
949
1521
  }
@@ -984,7 +1556,6 @@ class Entity {
984
1556
  * @returns true if entity has been added
985
1557
  */
986
1558
  isPartOfGame() {
987
- var _a;
988
1559
  if (this.type === EntityType.Scene && this._game === void 0) {
989
1560
  return false;
990
1561
  }
@@ -1000,7 +1571,7 @@ class Entity {
1000
1571
  return findParentScene(entity.parent);
1001
1572
  }
1002
1573
  };
1003
- return ((_a = findParentScene(this)) == null ? void 0 : _a._game) !== void 0;
1574
+ return findParentScene(this)?._game !== void 0;
1004
1575
  }
1005
1576
  /**
1006
1577
  * Adds a child to this parent entity. Throws exception if the child's name
@@ -1033,10 +1604,7 @@ class Entity {
1033
1604
  } else {
1034
1605
  const descendants = this.descendants;
1035
1606
  if (descendants.includes(child)) {
1036
- otherParents = descendants.filter((d) => d.children.includes(child)).map((d) => {
1037
- var _a;
1038
- return (_a = d.parent) != null ? _a : void 0;
1039
- });
1607
+ otherParents = descendants.filter((d) => d.children.includes(child)).map((d) => d.parent ?? void 0);
1040
1608
  }
1041
1609
  }
1042
1610
  if (otherParents.length === 0) {
@@ -1051,7 +1619,7 @@ class Entity {
1051
1619
  );
1052
1620
  }
1053
1621
  throw new Error(
1054
- `Cannot add child entity ${child.toString()} to parent entity ${this.toString()}. This child already exists on other parent entity: ${firstOtherParent == null ? void 0 : firstOtherParent.toString()}}. Remove the child from the other parent first.`
1622
+ `Cannot add child entity ${child.toString()} to parent entity ${this.toString()}. This child already exists on other parent entity: ${firstOtherParent?.toString()}}. Remove the child from the other parent first.`
1055
1623
  );
1056
1624
  }
1057
1625
  /**
@@ -1358,7 +1926,7 @@ class Entity {
1358
1926
  entityUuid: this.uuid,
1359
1927
  callback
1360
1928
  };
1361
- if (callbackOptions == null ? void 0 : callbackOptions.replaceExisting) {
1929
+ if (callbackOptions?.replaceExisting) {
1362
1930
  this.eventListeners = this.eventListeners.filter(
1363
1931
  (listener) => !(listener.entityUuid === eventListener.entityUuid && listener.type === eventListener.type)
1364
1932
  );
@@ -1456,7 +2024,6 @@ class Entity {
1456
2024
  return alpha * inheritedAlpha;
1457
2025
  }
1458
2026
  update() {
1459
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1460
2027
  if (this.needsInitialization) {
1461
2028
  this.initialize();
1462
2029
  this.needsInitialization = false;
@@ -1469,18 +2036,18 @@ class Entity {
1469
2036
  this.absoluteScale = this.scale;
1470
2037
  } else {
1471
2038
  this.absoluteScale = this.parent.absoluteScale * this.scale;
1472
- if (((_a = this.layout) == null ? void 0 : _a.constraints) === void 0) {
2039
+ if (this.layout?.constraints === void 0) {
1473
2040
  this.absolutePosition.x = this.parent.absolutePosition.x + this.position.x * this.parent.absoluteScale;
1474
2041
  this.absolutePosition.y = this.parent.absolutePosition.y + this.position.y * this.parent.absoluteScale;
1475
2042
  } else {
1476
- const horizontalBias = (_d = (_c = (_b = this.layout) == null ? void 0 : _b.constraints) == null ? void 0 : _c.horizontalBias) != null ? _d : 0.5;
1477
- const verticalBias = (_g = (_f = (_e = this.layout) == null ? void 0 : _e.constraints) == null ? void 0 : _f.verticalBias) != null ? _g : 0.5;
1478
- const marginTop = (_i = (_h = this.layout) == null ? void 0 : _h.marginTop) != null ? _i : 0;
1479
- const marginBottom = (_k = (_j = this.layout) == null ? void 0 : _j.marginBottom) != null ? _k : 0;
1480
- const marginStart = (_m = (_l = this.layout) == null ? void 0 : _l.marginStart) != null ? _m : 0;
1481
- const marginEnd = (_o = (_n = this.layout) == null ? void 0 : _n.marginEnd) != null ? _o : 0;
2043
+ const horizontalBias = this.layout?.constraints?.horizontalBias ?? 0.5;
2044
+ const verticalBias = this.layout?.constraints?.verticalBias ?? 0.5;
2045
+ const marginTop = this.layout?.marginTop ?? 0;
2046
+ const marginBottom = this.layout?.marginBottom ?? 0;
2047
+ const marginStart = this.layout?.marginStart ?? 0;
2048
+ const marginEnd = this.layout?.marginEnd ?? 0;
1482
2049
  const layoutConstraints = this.parseLayoutConstraints(
1483
- (_p = this.layout) == null ? void 0 : _p.constraints,
2050
+ this.layout?.constraints,
1484
2051
  //this.parentScene.game.entities
1485
2052
  this.parentSceneAsEntity.descendants
1486
2053
  );
@@ -1578,10 +2145,9 @@ class Entity {
1578
2145
  }
1579
2146
  const adjList = /* @__PURE__ */ new Map();
1580
2147
  this.children.forEach((child) => {
1581
- var _a2;
1582
2148
  adjList.set(
1583
2149
  child.uuid,
1584
- getSiblingConstraintUuids(this, (_a2 = child.layout) == null ? void 0 : _a2.constraints)
2150
+ getSiblingConstraintUuids(this, child.layout?.constraints)
1585
2151
  );
1586
2152
  });
1587
2153
  const sortedUuids = this.findTopologicalSort(adjList);
@@ -1717,7 +2283,6 @@ class Entity {
1717
2283
  * @param adjList Adjacency List that represent a graph with vertices and edges
1718
2284
  */
1719
2285
  findTopologicalSort(adjList) {
1720
- var _a;
1721
2286
  const tSort = [];
1722
2287
  const inDegree = /* @__PURE__ */ new Map();
1723
2288
  adjList.forEach((edges, vertex) => {
@@ -1745,7 +2310,7 @@ class Entity {
1745
2310
  }
1746
2311
  tSort.push(current);
1747
2312
  if (adjList.has(current)) {
1748
- (_a = adjList.get(current)) == null ? void 0 : _a.forEach((edge) => {
2313
+ adjList.get(current)?.forEach((edge) => {
1749
2314
  if (inDegree.has(edge) && inDegree.get(edge) > 0) {
1750
2315
  const newDegree = inDegree.get(edge) - 1;
1751
2316
  inDegree.set(edge, newDegree);
@@ -1760,12 +2325,6 @@ class Entity {
1760
2325
  }
1761
2326
  }
1762
2327
 
1763
- var __defProp$f = Object.defineProperty;
1764
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1765
- var __publicField$f = (obj, key, value) => {
1766
- __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
1767
- return value;
1768
- };
1769
2328
  class Composite extends Entity {
1770
2329
  /**
1771
2330
  * Base Drawable object for creating custom entities ("composites") composed of primitive entities.
@@ -1774,12 +2333,12 @@ class Composite extends Entity {
1774
2333
  */
1775
2334
  constructor(options = {}) {
1776
2335
  super(options);
1777
- __publicField$f(this, "type", EntityType.Composite);
1778
- __publicField$f(this, "compositeType", "<compositeType>");
1779
- __publicField$f(this, "isDrawable", true);
2336
+ this.type = EntityType.Composite;
2337
+ this.compositeType = "<compositeType>";
2338
+ this.isDrawable = true;
1780
2339
  // Drawable options
1781
- __publicField$f(this, "anchorPoint", { x: 0.5, y: 0.5 });
1782
- __publicField$f(this, "zPosition", 0);
2340
+ this.anchorPoint = { x: 0.5, y: 0.5 };
2341
+ this.zPosition = 0;
1783
2342
  handleInterfaceOptions(this, options);
1784
2343
  }
1785
2344
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -1796,194 +2355,6 @@ class Composite extends Entity {
1796
2355
  }
1797
2356
  }
1798
2357
 
1799
- var __defProp$e = Object.defineProperty;
1800
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1801
- var __publicField$e = (obj, key, value) => {
1802
- __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
1803
- return value;
1804
- };
1805
- class WebColors {
1806
- }
1807
- __publicField$e(WebColors, "Transparent", [0, 0, 0, 0]);
1808
- __publicField$e(WebColors, "MediumVioletRed", [199, 21, 133, 1]);
1809
- __publicField$e(WebColors, "DeepPink", [255, 20, 147, 1]);
1810
- __publicField$e(WebColors, "PaleVioletRed", [219, 112, 147, 1]);
1811
- __publicField$e(WebColors, "HotPink", [255, 105, 180, 1]);
1812
- __publicField$e(WebColors, "LightPink", [255, 182, 193, 1]);
1813
- __publicField$e(WebColors, "Pink", [255, 192, 203, 1]);
1814
- __publicField$e(WebColors, "DarkRed", [139, 0, 0, 1]);
1815
- __publicField$e(WebColors, "Red", [255, 0, 0, 1]);
1816
- __publicField$e(WebColors, "Firebrick", [178, 34, 34, 1]);
1817
- __publicField$e(WebColors, "Crimson", [220, 20, 60, 1]);
1818
- __publicField$e(WebColors, "IndianRed", [205, 92, 92, 1]);
1819
- __publicField$e(WebColors, "LightCoral", [240, 128, 128, 1]);
1820
- __publicField$e(WebColors, "Salmon", [250, 128, 114, 1]);
1821
- __publicField$e(WebColors, "DarkSalmon", [233, 150, 122, 1]);
1822
- __publicField$e(WebColors, "LightSalmon", [255, 160, 122, 1]);
1823
- __publicField$e(WebColors, "OrangeRed", [255, 69, 0, 1]);
1824
- __publicField$e(WebColors, "Tomato", [255, 99, 71, 1]);
1825
- __publicField$e(WebColors, "DarkOrange", [255, 140, 0, 1]);
1826
- __publicField$e(WebColors, "Coral", [255, 127, 80, 1]);
1827
- __publicField$e(WebColors, "Orange", [255, 165, 0, 1]);
1828
- __publicField$e(WebColors, "DarkKhaki", [189, 183, 107, 1]);
1829
- __publicField$e(WebColors, "Gold", [255, 215, 0, 1]);
1830
- __publicField$e(WebColors, "Khaki", [240, 230, 140, 1]);
1831
- __publicField$e(WebColors, "PeachPuff", [255, 218, 185, 1]);
1832
- __publicField$e(WebColors, "Yellow", [255, 255, 0, 1]);
1833
- __publicField$e(WebColors, "PaleGoldenrod", [238, 232, 170, 1]);
1834
- __publicField$e(WebColors, "Moccasin", [255, 228, 181, 1]);
1835
- __publicField$e(WebColors, "PapayaWhip", [255, 239, 213, 1]);
1836
- __publicField$e(WebColors, "LightGoldenrodYellow", [250, 250, 210, 1]);
1837
- __publicField$e(WebColors, "LemonChiffon", [255, 250, 205, 1]);
1838
- __publicField$e(WebColors, "LightYellow", [255, 255, 224, 1]);
1839
- __publicField$e(WebColors, "Maroon", [128, 0, 0, 1]);
1840
- __publicField$e(WebColors, "Brown", [165, 42, 42, 1]);
1841
- __publicField$e(WebColors, "SaddleBrown", [139, 69, 19, 1]);
1842
- __publicField$e(WebColors, "Sienna", [160, 82, 45, 1]);
1843
- __publicField$e(WebColors, "Chocolate", [210, 105, 30, 1]);
1844
- __publicField$e(WebColors, "DarkGoldenrod", [184, 134, 11, 1]);
1845
- __publicField$e(WebColors, "Peru", [205, 133, 63, 1]);
1846
- __publicField$e(WebColors, "RosyBrown", [188, 143, 143, 1]);
1847
- __publicField$e(WebColors, "Goldenrod", [218, 165, 32, 1]);
1848
- __publicField$e(WebColors, "SandyBrown", [244, 164, 96, 1]);
1849
- __publicField$e(WebColors, "Tan", [210, 180, 140, 1]);
1850
- __publicField$e(WebColors, "Burlywood", [222, 184, 135, 1]);
1851
- __publicField$e(WebColors, "Wheat", [245, 222, 179, 1]);
1852
- __publicField$e(WebColors, "NavajoWhite", [255, 222, 173, 1]);
1853
- __publicField$e(WebColors, "Bisque", [255, 228, 196, 1]);
1854
- __publicField$e(WebColors, "BlanchedAlmond", [255, 235, 205, 1]);
1855
- __publicField$e(WebColors, "Cornsilk", [255, 248, 220, 1]);
1856
- __publicField$e(WebColors, "DarkGreen", [0, 100, 0, 1]);
1857
- __publicField$e(WebColors, "Green", [0, 128, 0, 1]);
1858
- __publicField$e(WebColors, "DarkOliveGreen", [85, 107, 47, 1]);
1859
- __publicField$e(WebColors, "ForestGreen", [34, 139, 34, 1]);
1860
- __publicField$e(WebColors, "SeaGreen", [46, 139, 87, 1]);
1861
- __publicField$e(WebColors, "Olive", [128, 128, 0, 1]);
1862
- __publicField$e(WebColors, "OliveDrab", [107, 142, 35, 1]);
1863
- __publicField$e(WebColors, "MediumSeaGreen", [60, 179, 113, 1]);
1864
- __publicField$e(WebColors, "LimeGreen", [50, 205, 50, 1]);
1865
- __publicField$e(WebColors, "Lime", [0, 255, 0, 1]);
1866
- __publicField$e(WebColors, "SpringGreen", [0, 255, 127, 1]);
1867
- __publicField$e(WebColors, "MediumSpringGreen", [0, 250, 154, 1]);
1868
- __publicField$e(WebColors, "DarkSeaGreen", [143, 188, 143, 1]);
1869
- __publicField$e(WebColors, "MediumAquamarine", [102, 205, 170, 1]);
1870
- __publicField$e(WebColors, "YellowGreen", [154, 205, 50, 1]);
1871
- __publicField$e(WebColors, "LawnGreen", [124, 252, 0, 1]);
1872
- __publicField$e(WebColors, "Chartreuse", [127, 255, 0, 1]);
1873
- __publicField$e(WebColors, "LightGreen", [144, 238, 144, 1]);
1874
- __publicField$e(WebColors, "GreenYellow", [173, 255, 47, 1]);
1875
- __publicField$e(WebColors, "PaleGreen", [152, 251, 152, 1]);
1876
- __publicField$e(WebColors, "Teal", [0, 128, 128, 1]);
1877
- __publicField$e(WebColors, "DarkCyan", [0, 139, 139, 1]);
1878
- __publicField$e(WebColors, "LightSeaGreen", [32, 178, 170, 1]);
1879
- __publicField$e(WebColors, "CadetBlue", [95, 158, 160, 1]);
1880
- __publicField$e(WebColors, "DarkTurquoise", [0, 206, 209, 1]);
1881
- __publicField$e(WebColors, "MediumTurquoise", [72, 209, 204, 1]);
1882
- __publicField$e(WebColors, "Turquoise", [64, 224, 208, 1]);
1883
- __publicField$e(WebColors, "Aqua", [0, 255, 255, 1]);
1884
- __publicField$e(WebColors, "Cyan", [0, 255, 255, 1]);
1885
- __publicField$e(WebColors, "Aquamarine", [127, 255, 212, 1]);
1886
- __publicField$e(WebColors, "PaleTurquoise", [175, 238, 238, 1]);
1887
- __publicField$e(WebColors, "LightCyan", [224, 255, 255, 1]);
1888
- __publicField$e(WebColors, "Navy", [0, 0, 128, 1]);
1889
- __publicField$e(WebColors, "DarkBlue", [0, 0, 139, 1]);
1890
- __publicField$e(WebColors, "MediumBlue", [0, 0, 205, 1]);
1891
- __publicField$e(WebColors, "Blue", [0, 0, 255, 1]);
1892
- __publicField$e(WebColors, "MidnightBlue", [25, 25, 112, 1]);
1893
- __publicField$e(WebColors, "RoyalBlue", [65, 105, 225, 1]);
1894
- __publicField$e(WebColors, "SteelBlue", [70, 130, 180, 1]);
1895
- __publicField$e(WebColors, "DodgerBlue", [30, 144, 255, 1]);
1896
- __publicField$e(WebColors, "DeepSkyBlue", [0, 191, 255, 1]);
1897
- __publicField$e(WebColors, "CornflowerBlue", [100, 149, 237, 1]);
1898
- __publicField$e(WebColors, "SkyBlue", [135, 206, 235, 1]);
1899
- __publicField$e(WebColors, "LightSkyBlue", [135, 206, 250, 1]);
1900
- __publicField$e(WebColors, "LightSteelBlue", [176, 196, 222, 1]);
1901
- __publicField$e(WebColors, "LightBlue", [173, 216, 230, 1]);
1902
- __publicField$e(WebColors, "PowderBlue", [176, 224, 230, 1]);
1903
- __publicField$e(WebColors, "Indigo", [75, 0, 130, 1]);
1904
- __publicField$e(WebColors, "Purple", [128, 0, 128, 1]);
1905
- __publicField$e(WebColors, "DarkMagenta", [139, 0, 139, 1]);
1906
- __publicField$e(WebColors, "DarkViolet", [148, 0, 211, 1]);
1907
- __publicField$e(WebColors, "DarkSlateBlue", [72, 61, 139, 1]);
1908
- __publicField$e(WebColors, "BlueViolet", [138, 43, 226, 1]);
1909
- __publicField$e(WebColors, "DarkOrchid", [153, 50, 204, 1]);
1910
- __publicField$e(WebColors, "Fuchsia", [255, 0, 255, 1]);
1911
- __publicField$e(WebColors, "Magenta", [255, 0, 255, 1]);
1912
- __publicField$e(WebColors, "SlateBlue", [106, 90, 205, 1]);
1913
- __publicField$e(WebColors, "MediumSlateBlue", [123, 104, 238, 1]);
1914
- __publicField$e(WebColors, "MediumOrchid", [186, 85, 211, 1]);
1915
- __publicField$e(WebColors, "MediumPurple", [147, 112, 219, 1]);
1916
- __publicField$e(WebColors, "Orchid", [218, 112, 214, 1]);
1917
- __publicField$e(WebColors, "Violet", [238, 130, 238, 1]);
1918
- __publicField$e(WebColors, "Plum", [221, 160, 221, 1]);
1919
- __publicField$e(WebColors, "Thistle", [216, 191, 216, 1]);
1920
- __publicField$e(WebColors, "Lavender", [230, 230, 250, 1]);
1921
- __publicField$e(WebColors, "MistyRose", [255, 228, 225, 1]);
1922
- __publicField$e(WebColors, "AntiqueWhite", [250, 235, 215, 1]);
1923
- __publicField$e(WebColors, "Linen", [250, 240, 230, 1]);
1924
- __publicField$e(WebColors, "Beige", [245, 245, 220, 1]);
1925
- __publicField$e(WebColors, "WhiteSmoke", [245, 245, 245, 1]);
1926
- __publicField$e(WebColors, "LavenderBlush", [255, 240, 245, 1]);
1927
- __publicField$e(WebColors, "OldLace", [253, 245, 230, 1]);
1928
- __publicField$e(WebColors, "AliceBlue", [240, 248, 255, 1]);
1929
- __publicField$e(WebColors, "Seashell", [255, 245, 238, 1]);
1930
- __publicField$e(WebColors, "GhostWhite", [248, 248, 255, 1]);
1931
- __publicField$e(WebColors, "Honeydew", [240, 255, 240, 1]);
1932
- __publicField$e(WebColors, "FloralWhite", [255, 250, 240, 1]);
1933
- __publicField$e(WebColors, "Azure", [240, 255, 255, 1]);
1934
- __publicField$e(WebColors, "MintCream", [245, 255, 250, 1]);
1935
- __publicField$e(WebColors, "Snow", [255, 250, 250, 1]);
1936
- __publicField$e(WebColors, "Ivory", [255, 255, 240, 1]);
1937
- __publicField$e(WebColors, "White", [255, 255, 255, 1]);
1938
- __publicField$e(WebColors, "Black", [0, 0, 0, 1]);
1939
- __publicField$e(WebColors, "DarkSlateGray", [47, 79, 79, 1]);
1940
- __publicField$e(WebColors, "DimGray", [105, 105, 105, 1]);
1941
- __publicField$e(WebColors, "SlateGray", [112, 128, 144, 1]);
1942
- __publicField$e(WebColors, "Gray", [128, 128, 128, 1]);
1943
- __publicField$e(WebColors, "LightSlateGray", [119, 136, 153, 1]);
1944
- __publicField$e(WebColors, "DarkGray", [169, 169, 169, 1]);
1945
- __publicField$e(WebColors, "Silver", [192, 192, 192, 1]);
1946
- __publicField$e(WebColors, "LightGray", [211, 211, 211, 1]);
1947
- __publicField$e(WebColors, "Gainsboro", [220, 220, 220, 1]);
1948
- __publicField$e(WebColors, "RebeccaPurple", [102, 51, 153, 1]);
1949
-
1950
- var __defProp$d = Object.defineProperty;
1951
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1952
- var __publicField$d = (obj, key, value) => {
1953
- __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
1954
- return value;
1955
- };
1956
- class Constants {
1957
- }
1958
- /** Size of the font showing frames per second */
1959
- __publicField$d(Constants, "FPS_DISPLAY_TEXT_FONT_SIZE", 12);
1960
- /** Color of the font showing frames per second */
1961
- __publicField$d(Constants, "FPS_DISPLAY_TEXT_COLOR", [0, 0, 0, 0.5]);
1962
- /** Frequency, in milliseconds, at which to update frames per second metric shown on the screen */
1963
- __publicField$d(Constants, "FPS_DISPLAY_UPDATE_INTERVAL", 1e3);
1964
- /** Maximum number of activity metrics to log. */
1965
- __publicField$d(Constants, "MAXIMUM_RECORDED_ACTIVITY_METRICS", 32);
1966
- /** The frames per second will be logged in game metrics if the FPS is lower than this value */
1967
- __publicField$d(Constants, "FPS_METRIC_REPORT_THRESHOLD", 59);
1968
- /** Scene color, if none is specified. */
1969
- __publicField$d(Constants, "DEFAULT_SCENE_BACKGROUND_COLOR", WebColors.White);
1970
- /** Shape fill color, if none is specified. */
1971
- __publicField$d(Constants, "DEFAULT_SHAPE_FILL_COLOR", WebColors.Red);
1972
- /** Color of paths in a shape, if none is specified. */
1973
- __publicField$d(Constants, "DEFAULT_PATH_STROKE_COLOR", WebColors.Red);
1974
- /** Line width of paths in a shape, if none is specified. */
1975
- __publicField$d(Constants, "DEFAULT_PATH_LINE_WIDTH", 2);
1976
- /** Color of text in Label and TextLine, if none is specified. */
1977
- __publicField$d(Constants, "DEFAULT_FONT_COLOR", WebColors.Black);
1978
- /** Font size in Label and TextLine, if none is specified. */
1979
- __publicField$d(Constants, "DEFAULT_FONT_SIZE", 16);
1980
- __publicField$d(Constants, "LIMITED_FPS_RATE", 5);
1981
- __publicField$d(Constants, "FREE_ENTITIES_SCENE_NAME", "__freeEntitiesScene");
1982
- __publicField$d(Constants, "OUTGOING_SCENE_NAME", "__outgoingScene");
1983
- __publicField$d(Constants, "OUTGOING_SCENE_SPRITE_NAME", "__outgoingSceneSprite");
1984
- __publicField$d(Constants, "OUTGOING_SCENE_IMAGE_NAME", "__outgoingSceneSnapshot");
1985
- __publicField$d(Constants, "SESSION_INITIALIZATION_POLLING_INTERVAL_MS", 50);
1986
-
1987
2358
  var Dimensions = /* @__PURE__ */ ((Dimensions2) => {
1988
2359
  Dimensions2[Dimensions2["MatchConstraint"] = 0] = "MatchConstraint";
1989
2360
  return Dimensions2;
@@ -2228,22 +2599,12 @@ function property(e) {
2228
2599
  return meta;
2229
2600
  }
2230
2601
 
2231
- var __defProp$c = Object.defineProperty;
2232
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2233
- var __publicField$c = (obj, key, value) => {
2234
- __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
2235
- return value;
2236
- };
2237
2602
  class GameTypefaces {
2238
2603
  }
2239
2604
  class FontManager {
2240
2605
  constructor(session) {
2241
- __publicField$c(this, "canvasKit");
2242
- __publicField$c(this, "fontMgr");
2243
- __publicField$c(this, "gameTypefaces", new GameTypefaces());
2244
- __publicField$c(this, "fontData", new Array());
2245
- __publicField$c(this, "session");
2246
- __publicField$c(this, "games");
2606
+ this.gameTypefaces = new GameTypefaces();
2607
+ this.fontData = new Array();
2247
2608
  this.session = session;
2248
2609
  }
2249
2610
  /**
@@ -2277,20 +2638,17 @@ class FontManager {
2277
2638
  fetchFonts(games) {
2278
2639
  this.games = games;
2279
2640
  const fontsToFetch = games.flatMap(
2280
- (game) => {
2281
- var _a;
2282
- return (
2283
- // no fonts in game if game.options.fonts is undefined
2284
- (_a = game.options.fonts) == null ? void 0 : _a.map((font, i) => {
2285
- return {
2286
- gameUuid: game.uuid,
2287
- fontUrl: font.url,
2288
- fontName: font.fontName,
2289
- isDefault: i === 0
2290
- };
2291
- })
2292
- );
2293
- }
2641
+ (game) => (
2642
+ // no fonts in game if game.options.fonts is undefined
2643
+ game.options.fonts?.map((font, i) => {
2644
+ return {
2645
+ gameUuid: game.uuid,
2646
+ fontUrl: font.url,
2647
+ fontName: font.fontName,
2648
+ isDefault: i === 0
2649
+ };
2650
+ })
2651
+ )
2294
2652
  ).filter((f) => f !== void 0);
2295
2653
  if (fontsToFetch.length === 0) {
2296
2654
  return Promise.all([Promise.resolve()]);
@@ -2323,23 +2681,21 @@ class FontManager {
2323
2681
  * to our engine by creating canvaskit Typefaces.
2324
2682
  */
2325
2683
  loadAllGamesFontData() {
2326
- var _a;
2327
2684
  if (this.fontData.length === 0) {
2328
2685
  return;
2329
2686
  }
2330
2687
  if (!this.canvasKit) {
2331
2688
  throw new Error("canvasKit undefined");
2332
2689
  }
2333
- this.fontMgr = (_a = this.canvasKit.FontMgr.FromData(
2690
+ this.fontMgr = this.canvasKit.FontMgr.FromData(
2334
2691
  ...this.fontData.map((f) => f.fontArrayBuffer)
2335
- )) != null ? _a : void 0;
2692
+ ) ?? void 0;
2336
2693
  if (!this.fontMgr) {
2337
2694
  throw new Error("error creating FontMgr while loading fonts");
2338
2695
  }
2339
2696
  this.fontData.forEach((font) => {
2340
- var _a2, _b, _c;
2341
2697
  const result = ttfInfo(new DataView(font.fontArrayBuffer));
2342
- const fontFamilyUtf16Be = (_a2 = result.meta.property.filter((p) => p.name === "font-family").find(Boolean)) == null ? void 0 : _a2.text;
2698
+ const fontFamilyUtf16Be = result.meta.property.filter((p) => p.name === "font-family").find(Boolean)?.text;
2343
2699
  if (fontFamilyUtf16Be === void 0) {
2344
2700
  throw new Error(
2345
2701
  `error loading fonts. could not get font-family name from font at ${font.fontUrl}`
@@ -2359,7 +2715,7 @@ class FontManager {
2359
2715
  if (!typeface) {
2360
2716
  throw new Error("cannot make typeface from font array buffer");
2361
2717
  }
2362
- const gameId = (_c = (_b = this.games) == null ? void 0 : _b.find((g) => g.uuid === font.gameUuid)) == null ? void 0 : _c.id;
2718
+ const gameId = this.games?.find((g) => g.uuid === font.gameUuid)?.id;
2363
2719
  console.log(
2364
2720
  `\u26AA typeface ${font.fontName} ${font.isDefault ? "(default) " : ""}created from font-family ${fontFamily} for game ${gameId}`
2365
2721
  );
@@ -2375,29 +2731,6 @@ class FontManager {
2375
2731
  }
2376
2732
  }
2377
2733
 
2378
- var __defProp$b = Object.defineProperty;
2379
- var __defProps$5 = Object.defineProperties;
2380
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
2381
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
2382
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
2383
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
2384
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2385
- var __spreadValues$7 = (a, b) => {
2386
- for (var prop in b || (b = {}))
2387
- if (__hasOwnProp$7.call(b, prop))
2388
- __defNormalProp$b(a, prop, b[prop]);
2389
- if (__getOwnPropSymbols$7)
2390
- for (var prop of __getOwnPropSymbols$7(b)) {
2391
- if (__propIsEnum$7.call(b, prop))
2392
- __defNormalProp$b(a, prop, b[prop]);
2393
- }
2394
- return a;
2395
- };
2396
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
2397
- var __publicField$b = (obj, key, value) => {
2398
- __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
2399
- return value;
2400
- };
2401
2734
  class Sprite extends Entity {
2402
2735
  /**
2403
2736
  * Visual image displayed on the screen.
@@ -2408,16 +2741,13 @@ class Sprite extends Entity {
2408
2741
  */
2409
2742
  constructor(options = {}) {
2410
2743
  super(options);
2411
- __publicField$b(this, "type", EntityType.Sprite);
2412
- __publicField$b(this, "isDrawable", true);
2744
+ this.type = EntityType.Sprite;
2745
+ this.isDrawable = true;
2413
2746
  // Drawable options
2414
- __publicField$b(this, "anchorPoint", { x: 0.5, y: 0.5 });
2415
- __publicField$b(this, "zPosition", 0);
2747
+ this.anchorPoint = { x: 0.5, y: 0.5 };
2748
+ this.zPosition = 0;
2416
2749
  // Sprite options
2417
- __publicField$b(this, "_imageName", "");
2418
- // public getter/setter is below
2419
- __publicField$b(this, "loadedImage");
2420
- __publicField$b(this, "_paint");
2750
+ this._imageName = "";
2421
2751
  handleInterfaceOptions(this, options);
2422
2752
  if (options.imageName !== void 0) {
2423
2753
  this.imageName = options.imageName;
@@ -2444,8 +2774,7 @@ class Sprite extends Entity {
2444
2774
  this.needsInitialization = false;
2445
2775
  }
2446
2776
  dispose() {
2447
- var _a;
2448
- CanvasKitHelpers.Dispose([(_a = this.loadedImage) == null ? void 0 : _a.image, this._paint]);
2777
+ CanvasKitHelpers.Dispose([this.loadedImage?.image, this._paint]);
2449
2778
  }
2450
2779
  set imageName(imageName) {
2451
2780
  this._imageName = imageName;
@@ -2476,10 +2805,12 @@ class Sprite extends Entity {
2476
2805
  * provided, name will be the new uuid
2477
2806
  */
2478
2807
  duplicate(newName) {
2479
- const dest = new Sprite(__spreadProps$5(__spreadValues$7(__spreadValues$7({}, this.getEntityOptions()), this.getDrawableOptions()), {
2808
+ const dest = new Sprite({
2809
+ ...this.getEntityOptions(),
2810
+ ...this.getDrawableOptions(),
2480
2811
  imageName: this.imageName,
2481
2812
  name: newName
2482
- }));
2813
+ });
2483
2814
  if (this.children.length > 0) {
2484
2815
  dest.children = this.children.map((child) => {
2485
2816
  const clonedChild = child.duplicate();
@@ -2498,6 +2829,7 @@ class Sprite extends Entity {
2498
2829
  canvas.save();
2499
2830
  const drawScale = Globals.canvasScale / this.absoluteScale;
2500
2831
  canvas.scale(1 / drawScale, 1 / drawScale);
2832
+ M2c2KitHelpers.rotateCanvasForDrawableEntity(canvas, this);
2501
2833
  const x = (this.absolutePosition.x - this.size.width * this.anchorPoint.x * this.absoluteScale) * drawScale;
2502
2834
  const y = (this.absolutePosition.y - this.size.height * this.anchorPoint.y * this.absoluteScale) * drawScale;
2503
2835
  if (this.absoluteAlphaChange !== 0) {
@@ -2534,29 +2866,6 @@ class LoadedImage {
2534
2866
  }
2535
2867
  }
2536
2868
 
2537
- var __defProp$a = Object.defineProperty;
2538
- var __defProps$4 = Object.defineProperties;
2539
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
2540
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
2541
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
2542
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
2543
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2544
- var __spreadValues$6 = (a, b) => {
2545
- for (var prop in b || (b = {}))
2546
- if (__hasOwnProp$6.call(b, prop))
2547
- __defNormalProp$a(a, prop, b[prop]);
2548
- if (__getOwnPropSymbols$6)
2549
- for (var prop of __getOwnPropSymbols$6(b)) {
2550
- if (__propIsEnum$6.call(b, prop))
2551
- __defNormalProp$a(a, prop, b[prop]);
2552
- }
2553
- return a;
2554
- };
2555
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
2556
- var __publicField$a = (obj, key, value) => {
2557
- __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
2558
- return value;
2559
- };
2560
2869
  class Scene extends Entity {
2561
2870
  /**
2562
2871
  * Top-level entity that holds all other entities, such as sprites, rectangles, or labels, that will be displayed on the screen
@@ -2567,18 +2876,15 @@ class Scene extends Entity {
2567
2876
  */
2568
2877
  constructor(options = {}) {
2569
2878
  super(options);
2570
- __publicField$a(this, "type", EntityType.Scene);
2571
- __publicField$a(this, "isDrawable", true);
2879
+ this.type = EntityType.Scene;
2880
+ this.isDrawable = true;
2572
2881
  // Drawable options
2573
- __publicField$a(this, "anchorPoint", { x: 0, y: 0 });
2574
- __publicField$a(this, "zPosition", 0);
2882
+ this.anchorPoint = { x: 0, y: 0 };
2883
+ this.zPosition = 0;
2575
2884
  // Scene options
2576
- __publicField$a(this, "_backgroundColor", Constants.DEFAULT_SCENE_BACKGROUND_COLOR);
2577
- __publicField$a(this, "_active", false);
2578
- __publicField$a(this, "_transitioning", false);
2579
- __publicField$a(this, "_setupCallback");
2580
- __publicField$a(this, "_appearCallback");
2581
- __publicField$a(this, "backgroundPaint");
2885
+ this._backgroundColor = Constants.DEFAULT_SCENE_BACKGROUND_COLOR;
2886
+ this._active = false;
2887
+ this._transitioning = false;
2582
2888
  handleInterfaceOptions(this, options);
2583
2889
  if (options.backgroundColor) {
2584
2890
  this.backgroundColor = options.backgroundColor;
@@ -2634,10 +2940,12 @@ class Scene extends Entity {
2634
2940
  * provided, name will be the new uuid
2635
2941
  */
2636
2942
  duplicate(newName) {
2637
- const dest = new Scene(__spreadProps$4(__spreadValues$6(__spreadValues$6({}, this.getEntityOptions()), this.getDrawableOptions()), {
2943
+ const dest = new Scene({
2944
+ ...this.getEntityOptions(),
2945
+ ...this.getDrawableOptions(),
2638
2946
  backgroundColor: this.backgroundColor,
2639
2947
  name: newName
2640
- }));
2948
+ });
2641
2949
  dest.game = this.game;
2642
2950
  if (this.children.length > 0) {
2643
2951
  dest.children = this.children.map((child) => {
@@ -2680,6 +2988,7 @@ class Scene extends Entity {
2680
2988
  canvas.save();
2681
2989
  const drawScale = Globals.canvasScale / this.absoluteScale;
2682
2990
  canvas.scale(1 / drawScale, 1 / drawScale);
2991
+ M2c2KitHelpers.rotateCanvasForDrawableEntity(canvas, this);
2683
2992
  if (!this.backgroundPaint) {
2684
2993
  throw new Error(`in Scene ${this}, background paint is undefined.`);
2685
2994
  }
@@ -2724,12 +3033,6 @@ class Scene extends Entity {
2724
3033
  }
2725
3034
  }
2726
3035
 
2727
- var __defProp$9 = Object.defineProperty;
2728
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2729
- var __publicField$9 = (obj, key, value) => {
2730
- __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
2731
- return value;
2732
- };
2733
3036
  class Transition {
2734
3037
  /**
2735
3038
  * Creates a scene transition in which the outgoing scene slides out and the incoming scene slides in, as if the incoming scene pushes it.
@@ -2738,11 +3041,10 @@ class Transition {
2738
3041
  * @returns
2739
3042
  */
2740
3043
  static slide(options) {
2741
- var _a;
2742
3044
  return new SlideTransition(
2743
3045
  options.direction,
2744
3046
  options.duration,
2745
- (_a = options.easing) != null ? _a : Easings.linear
3047
+ options.easing ?? Easings.linear
2746
3048
  );
2747
3049
  }
2748
3050
  /**
@@ -2755,9 +3057,7 @@ class Transition {
2755
3057
  class NoneTransition extends Transition {
2756
3058
  constructor() {
2757
3059
  super();
2758
- __publicField$9(this, "type", "None" /* None */);
2759
- __publicField$9(this, "easing");
2760
- __publicField$9(this, "duration");
3060
+ this.type = "None" /* None */;
2761
3061
  this.duration = NaN;
2762
3062
  this.easing = Easings.none;
2763
3063
  }
@@ -2765,10 +3065,7 @@ class NoneTransition extends Transition {
2765
3065
  class SlideTransition extends Transition {
2766
3066
  constructor(direction, duration, easing) {
2767
3067
  super();
2768
- __publicField$9(this, "type", "Slide" /* Slide */);
2769
- __publicField$9(this, "easing");
2770
- __publicField$9(this, "duration");
2771
- __publicField$9(this, "direction");
3068
+ this.type = "Slide" /* Slide */;
2772
3069
  this.direction = direction;
2773
3070
  this.duration = duration;
2774
3071
  this.easing = easing;
@@ -2793,25 +3090,18 @@ class SceneTransition {
2793
3090
  }
2794
3091
  }
2795
3092
 
2796
- var __defProp$8 = Object.defineProperty;
2797
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2798
- var __publicField$8 = (obj, key, value) => {
2799
- __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
2800
- return value;
2801
- };
2802
3093
  const _Timer = class _Timer {
2803
3094
  constructor(name) {
2804
3095
  // startTime is the timestamp of the current active run
2805
- __publicField$8(this, "startTime", NaN);
2806
- __publicField$8(this, "stopTime", NaN);
2807
- __publicField$8(this, "stopped", true);
3096
+ this.startTime = NaN;
3097
+ this.stopTime = NaN;
3098
+ this.stopped = true;
2808
3099
  /**
2809
3100
  * cumulativeElapsed is a cumulative total of elapsed time while the timer
2810
3101
  * was in previous started (running) states, NOT INCLUDING the possibly
2811
3102
  * active run's duration
2812
3103
  */
2813
- __publicField$8(this, "cumulativeElapsed", NaN);
2814
- __publicField$8(this, "name");
3104
+ this.cumulativeElapsed = NaN;
2815
3105
  this.name = name;
2816
3106
  }
2817
3107
  /**
@@ -2963,7 +3253,7 @@ const _Timer = class _Timer {
2963
3253
  return this._timers.some((t) => t.name === name);
2964
3254
  }
2965
3255
  };
2966
- __publicField$8(_Timer, "_timers", new Array());
3256
+ _Timer._timers = new Array();
2967
3257
  let Timer = _Timer;
2968
3258
 
2969
3259
  const deviceMetadataSchema = {
@@ -3073,39 +3363,16 @@ class WebGlInfo {
3073
3363
  }
3074
3364
  }
3075
3365
 
3076
- var __defProp$7 = Object.defineProperty;
3077
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
3078
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
3079
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
3080
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3081
- var __spreadValues$5 = (a, b) => {
3082
- for (var prop in b || (b = {}))
3083
- if (__hasOwnProp$5.call(b, prop))
3084
- __defNormalProp$7(a, prop, b[prop]);
3085
- if (__getOwnPropSymbols$5)
3086
- for (var prop of __getOwnPropSymbols$5(b)) {
3087
- if (__propIsEnum$5.call(b, prop))
3088
- __defNormalProp$7(a, prop, b[prop]);
3089
- }
3090
- return a;
3091
- };
3092
- var __publicField$7 = (obj, key, value) => {
3093
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
3094
- return value;
3095
- };
3096
3366
  class I18n {
3097
3367
  constructor(options) {
3098
- __publicField$7(this, "_translations");
3099
- __publicField$7(this, "locale", "");
3100
- __publicField$7(this, "fallbackLocale", "en");
3101
- __publicField$7(this, "environmentLocale", this.getEnvironmentLocale());
3102
- __publicField$7(this, "options");
3103
- var _a;
3368
+ this.locale = "";
3369
+ this.fallbackLocale = "en";
3370
+ this.environmentLocale = this.getEnvironmentLocale();
3104
3371
  this.options = options;
3105
- this._translations = (_a = this.mergeAdditionalTranslations(
3372
+ this._translations = this.mergeAdditionalTranslations(
3106
3373
  options.translations,
3107
3374
  options.additionalTranslations
3108
- )) != null ? _a : {};
3375
+ ) ?? {};
3109
3376
  if (options.locale.toLowerCase() === "auto") {
3110
3377
  this.locale = this.environmentLocale;
3111
3378
  if (!this.locale) {
@@ -3158,11 +3425,10 @@ class I18n {
3158
3425
  return localizationParameters;
3159
3426
  }
3160
3427
  t(key, useFallback = false) {
3161
- var _a, _b;
3162
3428
  if (useFallback) {
3163
- return (_a = this._translations[this.fallbackLocale]) == null ? void 0 : _a[key];
3429
+ return this._translations[this.fallbackLocale]?.[key];
3164
3430
  }
3165
- return (_b = this._translations[this.locale]) == null ? void 0 : _b[key];
3431
+ return this._translations[this.locale]?.[key];
3166
3432
  }
3167
3433
  get translations() {
3168
3434
  return this._translations;
@@ -3187,7 +3453,10 @@ class I18n {
3187
3453
  const processedLocales = new Array();
3188
3454
  for (const locale in baseTranslations) {
3189
3455
  processedLocales.push(locale);
3190
- result[locale] = __spreadValues$5(__spreadValues$5({}, baseTranslations[locale]), additionalTranslations[locale]);
3456
+ result[locale] = {
3457
+ ...baseTranslations[locale],
3458
+ ...additionalTranslations[locale]
3459
+ };
3191
3460
  }
3192
3461
  for (const locale in additionalTranslations) {
3193
3462
  if (processedLocales.includes(locale)) {
@@ -3309,49 +3578,6 @@ class DomHelpers {
3309
3578
  }
3310
3579
  }
3311
3580
 
3312
- var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
3313
- ShapeType2["Undefined"] = "Undefined";
3314
- ShapeType2["Rectangle"] = "Rectangle";
3315
- ShapeType2["Circle"] = "Circle";
3316
- ShapeType2["Path"] = "Path";
3317
- return ShapeType2;
3318
- })(ShapeType || {});
3319
-
3320
- var __defProp$6 = Object.defineProperty;
3321
- var __defProps$3 = Object.defineProperties;
3322
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
3323
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
3324
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
3325
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
3326
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3327
- var __spreadValues$4 = (a, b) => {
3328
- for (var prop in b || (b = {}))
3329
- if (__hasOwnProp$4.call(b, prop))
3330
- __defNormalProp$6(a, prop, b[prop]);
3331
- if (__getOwnPropSymbols$4)
3332
- for (var prop of __getOwnPropSymbols$4(b)) {
3333
- if (__propIsEnum$4.call(b, prop))
3334
- __defNormalProp$6(a, prop, b[prop]);
3335
- }
3336
- return a;
3337
- };
3338
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
3339
- var __objRest = (source, exclude) => {
3340
- var target = {};
3341
- for (var prop in source)
3342
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
3343
- target[prop] = source[prop];
3344
- if (source != null && __getOwnPropSymbols$4)
3345
- for (var prop of __getOwnPropSymbols$4(source)) {
3346
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
3347
- target[prop] = source[prop];
3348
- }
3349
- return target;
3350
- };
3351
- var __publicField$6 = (obj, key, value) => {
3352
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
3353
- return value;
3354
- };
3355
3581
  class Game {
3356
3582
  /**
3357
3583
  * The base class for all games. New games should extend this class.
@@ -3359,66 +3585,44 @@ class Game {
3359
3585
  * @param options - {@link GameOptions}
3360
3586
  */
3361
3587
  constructor(options) {
3362
- __publicField$6(this, "type", ActivityType.Game);
3363
- __publicField$6(this, "_canvasKit");
3364
- __publicField$6(this, "_session");
3365
- __publicField$6(this, "uuid", Uuid.generate());
3366
- __publicField$6(this, "name");
3367
- __publicField$6(this, "id");
3368
- __publicField$6(this, "options");
3369
- __publicField$6(this, "beginTimestamp", NaN);
3370
- __publicField$6(this, "beginIso8601Timestamp", "");
3371
- __publicField$6(this, "eventListeners", new Array());
3372
- __publicField$6(this, "gameMetrics", new Array());
3373
- __publicField$6(this, "fpsMetricReportThreshold");
3374
- __publicField$6(this, "maximumRecordedActivityMetrics");
3375
- __publicField$6(this, "stepCount", 0);
3376
- __publicField$6(this, "steppingNow", 0);
3377
- __publicField$6(this, "i18n");
3378
- __publicField$6(this, "warmupFunctionQueue", new Array());
3379
- __publicField$6(this, "loaderElementsRemoved", false);
3380
- __publicField$6(this, "_dataStores");
3381
- __publicField$6(this, "additionalParameters");
3382
- __publicField$6(this, "staticTrialSchema", {});
3383
- /** The scene, or its name as a string, to be presented when the game is started. If this is undefined, the game will start with the first scene that has been added */
3384
- __publicField$6(this, "entryScene");
3385
- __publicField$6(this, "data", {
3588
+ this.type = ActivityType.Game;
3589
+ this.uuid = Uuid.generate();
3590
+ this.beginTimestamp = NaN;
3591
+ this.beginIso8601Timestamp = "";
3592
+ this.eventListeners = new Array();
3593
+ this.gameMetrics = new Array();
3594
+ this.stepCount = 0;
3595
+ this.steppingNow = 0;
3596
+ this.warmupFunctionQueue = new Array();
3597
+ this.loaderElementsRemoved = false;
3598
+ this.staticTrialSchema = {};
3599
+ this.data = {
3386
3600
  trials: new Array()
3387
- });
3601
+ };
3388
3602
  /** The 0-based index of the current trial */
3389
- __publicField$6(this, "trialIndex", 0);
3390
- __publicField$6(this, "htmlCanvas");
3391
- __publicField$6(this, "surface");
3392
- __publicField$6(this, "showFps");
3393
- __publicField$6(this, "bodyBackgroundColor");
3394
- __publicField$6(this, "currentScene");
3395
- __publicField$6(this, "priorUpdateTime");
3396
- __publicField$6(this, "fpsTextFont");
3397
- __publicField$6(this, "fpsTextPaint");
3398
- __publicField$6(this, "drawnFrames", 0);
3399
- __publicField$6(this, "lastFpsUpdate", 0);
3400
- __publicField$6(this, "nextFpsUpdate", 0);
3401
- __publicField$6(this, "fpsRate", 0);
3402
- __publicField$6(this, "animationFramesRequested", 0);
3403
- __publicField$6(this, "limitFps", false);
3404
- __publicField$6(this, "unitTesting", false);
3405
- __publicField$6(this, "gameStopRequested", false);
3406
- __publicField$6(this, "webGlRendererInfo", "");
3407
- __publicField$6(this, "canvasCssWidth", 0);
3408
- __publicField$6(this, "canvasCssHeight", 0);
3409
- __publicField$6(this, "scenes", new Array());
3410
- __publicField$6(this, "freeEntitiesScene", new Scene({
3603
+ this.trialIndex = 0;
3604
+ this.drawnFrames = 0;
3605
+ this.lastFpsUpdate = 0;
3606
+ this.nextFpsUpdate = 0;
3607
+ this.fpsRate = 0;
3608
+ this.animationFramesRequested = 0;
3609
+ this.limitFps = false;
3610
+ this.unitTesting = false;
3611
+ this.gameStopRequested = false;
3612
+ this.webGlRendererInfo = "";
3613
+ this.canvasCssWidth = 0;
3614
+ this.canvasCssHeight = 0;
3615
+ this.scenes = new Array();
3616
+ this.freeEntitiesScene = new Scene({
3411
3617
  name: Constants.FREE_ENTITIES_SCENE_NAME,
3412
3618
  backgroundColor: [255, 255, 255, 0]
3413
- }));
3414
- __publicField$6(this, "incomingSceneTransitions", new Array());
3415
- __publicField$6(this, "currentSceneSnapshot");
3416
- __publicField$6(this, "pendingScreenshot");
3619
+ });
3620
+ this.incomingSceneTransitions = new Array();
3417
3621
  /**
3418
3622
  * The m2c2kit engine will automatically include these schema and their
3419
3623
  * values in the trial data.
3420
3624
  */
3421
- __publicField$6(this, "automaticTrialSchema", {
3625
+ this.automaticTrialSchema = {
3422
3626
  document_uuid: {
3423
3627
  type: "string",
3424
3628
  format: "uuid",
@@ -3450,9 +3654,8 @@ class Game {
3450
3654
  type: "integer",
3451
3655
  description: "Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."
3452
3656
  }
3453
- });
3454
- __publicField$6(this, "snapshots", new Array());
3455
- var _a, _b;
3657
+ };
3658
+ this.snapshots = new Array();
3456
3659
  if (!options.id || options.id.trim() === "") {
3457
3660
  throw new Error("id is required in GameOptions");
3458
3661
  }
@@ -3461,31 +3664,33 @@ class Game {
3461
3664
  this.id = options.id;
3462
3665
  this.freeEntitiesScene.game = this;
3463
3666
  this.freeEntitiesScene.needsInitialization = true;
3464
- this.fpsMetricReportThreshold = (_a = options.fpsMetricReportThreshold) != null ? _a : Constants.FPS_METRIC_REPORT_THRESHOLD;
3465
- this.maximumRecordedActivityMetrics = (_b = options.maximumRecordedActivityMetrics) != null ? _b : Constants.MAXIMUM_RECORDED_ACTIVITY_METRICS;
3667
+ this.fpsMetricReportThreshold = options.fpsMetricReportThreshold ?? Constants.FPS_METRIC_REPORT_THRESHOLD;
3668
+ this.maximumRecordedActivityMetrics = options.maximumRecordedActivityMetrics ?? Constants.MAXIMUM_RECORDED_ACTIVITY_METRICS;
3466
3669
  this.addLocalizationParametersToGameParameters();
3467
3670
  if (!this.options.trialSchema) {
3468
3671
  this.options.trialSchema = {};
3469
3672
  }
3470
3673
  }
3471
3674
  addLocalizationParametersToGameParameters() {
3472
- this.options.parameters = __spreadValues$4(__spreadValues$4({}, this.options.parameters), I18n.makeLocalizationParameters());
3675
+ this.options.parameters = {
3676
+ ...this.options.parameters,
3677
+ ...I18n.makeLocalizationParameters()
3678
+ };
3473
3679
  }
3474
3680
  async init() {
3475
3681
  return this.initialize();
3476
3682
  }
3477
3683
  async initialize() {
3478
- var _a, _b;
3479
3684
  if (this.isLocalizationRequested()) {
3480
3685
  const options = this.getLocalizationOptionsFromGameParameters();
3481
3686
  this.i18n = new I18n(options);
3482
3687
  }
3483
- if ((_a = this.session.options.activityCallbacks) == null ? void 0 : _a.onActivityLifecycle) {
3688
+ if (this.session.options.activityCallbacks?.onActivityLifecycle) {
3484
3689
  this.onStart(this.session.options.activityCallbacks.onActivityLifecycle);
3485
3690
  this.onCancel(this.session.options.activityCallbacks.onActivityLifecycle);
3486
3691
  this.onEnd(this.session.options.activityCallbacks.onActivityLifecycle);
3487
3692
  }
3488
- if ((_b = this.session.options.activityCallbacks) == null ? void 0 : _b.onActivityResults) {
3693
+ if (this.session.options.activityCallbacks?.onActivityResults) {
3489
3694
  this.onData(this.session.options.activityCallbacks.onActivityResults);
3490
3695
  }
3491
3696
  }
@@ -3874,16 +4079,15 @@ class Game {
3874
4079
  * @param entryScene - The scene (Scene object or its string name) to display when the game starts
3875
4080
  */
3876
4081
  async start(entryScene) {
3877
- var _a, _b;
3878
4082
  const gameInitOptions = this.options;
3879
- this.unitTesting = (_a = gameInitOptions._unitTesting) != null ? _a : false;
4083
+ this.unitTesting = gameInitOptions._unitTesting ?? false;
3880
4084
  this.setupHtmlCanvases(
3881
4085
  gameInitOptions.canvasId,
3882
4086
  gameInitOptions.width,
3883
4087
  gameInitOptions.height,
3884
4088
  gameInitOptions.stretch
3885
4089
  );
3886
- this.showFps = (_b = gameInitOptions.showFps) != null ? _b : false;
4090
+ this.showFps = gameInitOptions.showFps ?? false;
3887
4091
  this.bodyBackgroundColor = gameInitOptions.bodyBackgroundColor;
3888
4092
  this.initData();
3889
4093
  this.setupCanvasKitSurface();
@@ -3995,11 +4199,10 @@ class Game {
3995
4199
  }
3996
4200
  }
3997
4201
  advanceStepsHandler(mouseEvent) {
3998
- var _a, _b;
3999
- if (((_a = mouseEvent == null ? void 0 : mouseEvent.target) == null ? void 0 : _a.id) === "1-step-advance") {
4202
+ if (mouseEvent?.target?.id === "1-step-advance") {
4000
4203
  this.steppingNow = this.steppingNow + 16.66666666666667;
4001
4204
  this.stepCount = this.stepCount + 1;
4002
- } else if (((_b = mouseEvent == null ? void 0 : mouseEvent.target) == null ? void 0 : _b.id) === "55-step-advance") {
4205
+ } else if (mouseEvent?.target?.id === "55-step-advance") {
4003
4206
  this.steppingNow = this.steppingNow + 16.66666666666667 * 55;
4004
4207
  this.stepCount = this.stepCount + 55;
4005
4208
  }
@@ -4169,12 +4372,11 @@ class Game {
4169
4372
  this.entities.filter((e) => e.isDrawable).forEach((e) => e.dispose());
4170
4373
  }
4171
4374
  initData() {
4172
- var _a;
4173
4375
  this.trialIndex = 0;
4174
4376
  this.data = {
4175
4377
  trials: new Array()
4176
4378
  };
4177
- const trialSchema = (_a = this.options.trialSchema) != null ? _a : {};
4379
+ const trialSchema = this.options.trialSchema ?? {};
4178
4380
  const variables = Object.entries(trialSchema);
4179
4381
  for (const [variableName, propertySchema] of variables) {
4180
4382
  if (propertySchema.type !== void 0 && !this.propertySchemaDataTypeIsValid(propertySchema.type)) {
@@ -4256,7 +4458,6 @@ class Game {
4256
4458
  * @param value - value of the variable to set
4257
4459
  */
4258
4460
  addTrialData(variableName, value) {
4259
- var _a, _b, _c;
4260
4461
  if (!this.options.trialSchema) {
4261
4462
  throw new Error(
4262
4463
  "no trial schema were provided in GameOptions. cannot add trial data"
@@ -4268,17 +4469,17 @@ class Game {
4268
4469
  for (const [variableName2] of variables) {
4269
4470
  emptyTrial[variableName2] = null;
4270
4471
  }
4271
- this.data.trials.push(__spreadProps$3(__spreadValues$4({
4472
+ this.data.trials.push({
4272
4473
  document_uuid: Uuid.generate(),
4273
4474
  session_uuid: this.session.uuid,
4274
4475
  activity_uuid: this.uuid,
4275
4476
  activity_id: this.options.id,
4276
4477
  activity_version: this.options.version,
4277
- device_timezone: (_c = (_b = (_a = Intl == null ? void 0 : Intl.DateTimeFormat()) == null ? void 0 : _a.resolvedOptions()) == null ? void 0 : _b.timeZone) != null ? _c : "",
4278
- device_timezone_offset_minutes: (/* @__PURE__ */ new Date()).getTimezoneOffset()
4279
- }, emptyTrial), {
4478
+ device_timezone: Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone ?? "",
4479
+ device_timezone_offset_minutes: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
4480
+ ...emptyTrial,
4280
4481
  device_metadata: this.getDeviceMetadata()
4281
- }));
4482
+ });
4282
4483
  }
4283
4484
  if (!(variableName in this.options.trialSchema)) {
4284
4485
  throw new Error(`trial variable ${variableName} not defined in schema`);
@@ -4337,12 +4538,12 @@ class Game {
4337
4538
  * Rather than modify the source code for the game, you can do the following
4338
4539
  * to ensure that the participant ID is saved for each trial:
4339
4540
  *
4340
- * game.addTrialSchema({
4341
- * participant_id: {
4541
+ * game.addTrialSchema(&#123
4542
+ * participant_id: &#123
4342
4543
  * type: "string",
4343
4544
  * description: "ID of the participant",
4344
- * }
4345
- * });
4545
+ * &#125;
4546
+ * &#125;);
4346
4547
  * game.addStaticTrialData("participant_id", "12345");
4347
4548
  *
4348
4549
  * When Game.trialComplete() is called, the participant_id variable will
@@ -4371,9 +4572,11 @@ class Game {
4371
4572
  * the appropriate time. It is not triggered automatically.
4372
4573
  */
4373
4574
  trialComplete() {
4374
- var _a, _b;
4375
4575
  if (Object.keys(this.staticTrialSchema).length > 0) {
4376
- this.data.trials[this.trialIndex] = __spreadValues$4(__spreadValues$4({}, this.data.trials[this.trialIndex]), this.staticTrialSchema);
4576
+ this.data.trials[this.trialIndex] = {
4577
+ ...this.data.trials[this.trialIndex],
4578
+ ...this.staticTrialSchema
4579
+ };
4377
4580
  }
4378
4581
  this.trialIndex++;
4379
4582
  const resultsEvent = {
@@ -4387,10 +4590,10 @@ class Game {
4387
4590
  data: this.data,
4388
4591
  dataSchema: this.makeGameDataSchema(),
4389
4592
  activityConfiguration: this.makeGameActivityConfiguration(
4390
- (_a = this.options.parameters) != null ? _a : {}
4593
+ this.options.parameters ?? {}
4391
4594
  ),
4392
4595
  activityConfigurationSchema: this.makeGameActivityConfigurationSchema(
4393
- (_b = this.options.parameters) != null ? _b : {}
4596
+ this.options.parameters ?? {}
4394
4597
  ),
4395
4598
  activityMetrics: this.gameMetrics
4396
4599
  };
@@ -4402,9 +4605,11 @@ class Game {
4402
4605
  $comment: `Activity identifier: ${this.options.id}, version: ${this.options.version}.`,
4403
4606
  $schema: "https://json-schema.org/draft/2019-09/schema",
4404
4607
  type: "object",
4405
- properties: __spreadProps$3(__spreadValues$4(__spreadValues$4({}, this.automaticTrialSchema), this.options.trialSchema), {
4608
+ properties: {
4609
+ ...this.automaticTrialSchema,
4610
+ ...this.options.trialSchema,
4406
4611
  device_metadata: deviceMetadataSchema
4407
- })
4612
+ }
4408
4613
  };
4409
4614
  return newDataSchema;
4410
4615
  }
@@ -4425,9 +4630,11 @@ class Game {
4425
4630
  $defs: {
4426
4631
  trial: {
4427
4632
  type: "object",
4428
- properties: __spreadProps$3(__spreadValues$4(__spreadValues$4({}, this.automaticTrialSchema), this.options.trialSchema), {
4633
+ properties: {
4634
+ ...this.automaticTrialSchema,
4635
+ ...this.options.trialSchema,
4429
4636
  device_metadata: deviceMetadataSchema
4430
- })
4637
+ }
4431
4638
  }
4432
4639
  }
4433
4640
  };
@@ -4442,15 +4649,17 @@ class Game {
4442
4649
  */
4443
4650
  makeGameActivityConfiguration(parameters) {
4444
4651
  const gameParams = JSON.parse(JSON.stringify(parameters));
4445
- const _a = gameParams, result = __objRest(_a, [
4446
- "locale",
4652
+ const {
4653
+ locale,
4447
4654
  // eslint-disable-line @typescript-eslint/no-unused-vars
4448
- "fallback_locale",
4655
+ fallback_locale,
4449
4656
  // eslint-disable-line @typescript-eslint/no-unused-vars
4450
- "missing_translation_font_color",
4657
+ missing_translation_font_color,
4451
4658
  // eslint-disable-line @typescript-eslint/no-unused-vars
4452
- "translations"
4453
- ]);
4659
+ translations,
4660
+ // eslint-disable-line @typescript-eslint/no-unused-vars
4661
+ ...result
4662
+ } = gameParams;
4454
4663
  for (const prop in result) {
4455
4664
  for (const subProp in result[prop]) {
4456
4665
  if (subProp == "default") {
@@ -4462,15 +4671,17 @@ class Game {
4462
4671
  }
4463
4672
  makeGameActivityConfigurationSchema(parameters) {
4464
4673
  const gameParams = JSON.parse(JSON.stringify(parameters));
4465
- const _a = gameParams, result = __objRest(_a, [
4466
- "locale",
4674
+ const {
4675
+ locale,
4467
4676
  // eslint-disable-line @typescript-eslint/no-unused-vars
4468
- "fallback_locale",
4677
+ fallback_locale,
4469
4678
  // eslint-disable-line @typescript-eslint/no-unused-vars
4470
- "missing_translation_font_color",
4679
+ missing_translation_font_color,
4471
4680
  // eslint-disable-line @typescript-eslint/no-unused-vars
4472
- "translations"
4473
- ]);
4681
+ translations,
4682
+ // eslint-disable-line @typescript-eslint/no-unused-vars
4683
+ ...result
4684
+ } = gameParams;
4474
4685
  for (const prop in result) {
4475
4686
  if (!("type" in result[prop]) && "value" in result[prop]) {
4476
4687
  const valueType = typeof result[prop]["default"];
@@ -4501,7 +4712,6 @@ class Game {
4501
4712
  * appropriate time. It is not triggered automatically.
4502
4713
  */
4503
4714
  end() {
4504
- var _a, _b;
4505
4715
  const activityEndEvent = {
4506
4716
  target: this,
4507
4717
  type: EventType.ActivityEnd
@@ -4510,10 +4720,10 @@ class Game {
4510
4720
  data: this.data,
4511
4721
  dataSchema: this.makeGameDataSchema(),
4512
4722
  activityConfiguration: this.makeGameActivityConfiguration(
4513
- (_a = this.options.parameters) != null ? _a : {}
4723
+ this.options.parameters ?? {}
4514
4724
  ),
4515
4725
  activityConfigurationSchema: this.makeGameActivityConfigurationSchema(
4516
- (_b = this.options.parameters) != null ? _b : {}
4726
+ this.options.parameters ?? {}
4517
4727
  ),
4518
4728
  activityMetrics: this.gameMetrics
4519
4729
  };
@@ -4530,7 +4740,6 @@ class Game {
4530
4740
  * appropriate time. It is not triggered automatically.
4531
4741
  */
4532
4742
  cancel() {
4533
- var _a, _b;
4534
4743
  const activityCancelEvent = {
4535
4744
  target: this,
4536
4745
  type: EventType.ActivityCancel
@@ -4539,10 +4748,10 @@ class Game {
4539
4748
  data: this.data,
4540
4749
  dataSchema: this.makeGameDataSchema(),
4541
4750
  activityConfiguration: this.makeGameActivityConfiguration(
4542
- (_a = this.options.parameters) != null ? _a : {}
4751
+ this.options.parameters ?? {}
4543
4752
  ),
4544
4753
  activityConfigurationSchema: this.makeGameActivityConfigurationSchema(
4545
- (_b = this.options.parameters) != null ? _b : {}
4754
+ this.options.parameters ?? {}
4546
4755
  ),
4547
4756
  activityMetrics: this.gameMetrics
4548
4757
  };
@@ -4614,7 +4823,7 @@ class Game {
4614
4823
  this.interceptWebGlCalls();
4615
4824
  try {
4616
4825
  this.webGlRendererInfo = WebGlInfo.getRendererString();
4617
- } catch (e) {
4826
+ } catch {
4618
4827
  this.webGlRendererInfo = "err";
4619
4828
  WebGlInfo.dispose();
4620
4829
  }
@@ -4701,13 +4910,12 @@ class Game {
4701
4910
  );
4702
4911
  }
4703
4912
  loop(canvas) {
4704
- var _a;
4705
4913
  if (!this.surface) {
4706
4914
  throw new Error("surface is undefined");
4707
4915
  }
4708
4916
  if (this.warmupFunctionQueue.length > 0) {
4709
4917
  const warmup = this.warmupFunctionQueue.shift();
4710
- warmup == null ? void 0 : warmup.warmupFunction.call(this, canvas, warmup.positionOffset);
4918
+ warmup?.warmupFunction.call(this, canvas, warmup.positionOffset);
4711
4919
  this.surface.requestAnimationFrame(this.loop.bind(this));
4712
4920
  return;
4713
4921
  }
@@ -4732,7 +4940,7 @@ class Game {
4732
4940
  this.update();
4733
4941
  this.draw(canvas);
4734
4942
  while (this.snapshots.length > 0) {
4735
- (_a = this.snapshots.shift()) == null ? void 0 : _a.delete();
4943
+ this.snapshots.shift()?.delete();
4736
4944
  }
4737
4945
  this.snapshots.push(this.takeCurrentSceneSnapshot());
4738
4946
  this.freeEntitiesScene.draw(canvas);
@@ -5542,7 +5750,7 @@ class Game {
5542
5750
  }
5543
5751
  const x = domPointerEvent.offsetX;
5544
5752
  const y = domPointerEvent.offsetY;
5545
- const bb = this.calculateEntityAbsoluteBoundingBox(entity);
5753
+ const bb = M2c2KitHelpers.calculateEntityAbsoluteBoundingBox(entity);
5546
5754
  const relativeX = (x - bb.xMin) / (bb.xMax - bb.xMin) * width;
5547
5755
  const relativeY = (y - bb.yMin) / (bb.yMax - bb.yMin) * height;
5548
5756
  return { x: relativeX, y: relativeY };
@@ -5593,7 +5801,7 @@ class Game {
5593
5801
  activityUuid: this.uuid,
5594
5802
  callback
5595
5803
  };
5596
- if (options == null ? void 0 : options.replaceExisting) {
5804
+ if (options?.replaceExisting) {
5597
5805
  this.eventListeners = this.eventListeners.filter(
5598
5806
  (listener) => !(listener.activityUuid === eventListener.activityUuid && listener.type === eventListener.type)
5599
5807
  );
@@ -5602,7 +5810,11 @@ class Game {
5602
5810
  }
5603
5811
  raiseActivityEventOnListeners(activityEvent, extra) {
5604
5812
  if (extra) {
5605
- activityEvent = __spreadValues$4(__spreadValues$4({}, activityEvent), extra);
5813
+ activityEvent = {
5814
+ ...activityEvent,
5815
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5816
+ ...extra
5817
+ };
5606
5818
  }
5607
5819
  this.eventListeners.filter((listener) => listener.type === activityEvent.type).forEach((listener) => {
5608
5820
  listener.callback(activityEvent);
@@ -5650,8 +5862,7 @@ class Game {
5650
5862
  });
5651
5863
  }
5652
5864
  sceneCanReceiveUserInteraction(scene) {
5653
- var _a;
5654
- if (scene.game === ((_a = scene.game.session) == null ? void 0 : _a.currentActivity) && scene._transitioning === false) {
5865
+ if (scene.game === scene.game.session?.currentActivity && scene._transitioning === false) {
5655
5866
  return true;
5656
5867
  }
5657
5868
  return false;
@@ -5670,14 +5881,14 @@ class Game {
5670
5881
  throw "only drawable entities can receive pointer events";
5671
5882
  }
5672
5883
  if (entity.type === EntityType.Shape && entity.shapeType === ShapeType.Circle) {
5673
- const bb2 = this.calculateEntityAbsoluteBoundingBox(entity);
5884
+ const bb = M2c2KitHelpers.calculateEntityAbsoluteBoundingBox(entity);
5674
5885
  const radius = entity.circleOfRadius;
5675
5886
  if (!radius) {
5676
5887
  throw "circleOfRadius is undefined";
5677
5888
  }
5678
5889
  const center = {
5679
- x: bb2.xMin + radius * entity.absoluteScale,
5680
- y: bb2.yMin + radius * entity.absoluteScale
5890
+ x: bb.xMin + radius * entity.absoluteScale,
5891
+ y: bb.yMin + radius * entity.absoluteScale
5681
5892
  };
5682
5893
  const distance = Math.sqrt(
5683
5894
  Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2)
@@ -5690,30 +5901,10 @@ class Game {
5690
5901
  if (entity.type === EntityType.TextLine && isNaN(entity.size.width)) {
5691
5902
  return false;
5692
5903
  }
5693
- const bb = this.calculateEntityAbsoluteBoundingBox(entity);
5694
- if (entity.isUserInteractionEnabled && x >= bb.xMin && x <= bb.xMax && y >= bb.yMin && y <= bb.yMax) {
5695
- return true;
5696
- }
5697
- return false;
5698
- }
5699
- calculateEntityAbsoluteBoundingBox(entity) {
5700
- const anchorPoint = entity.anchorPoint;
5701
- const scale = entity.absoluteScale;
5702
- let width = entity.size.width;
5703
- let height = entity.size.height;
5704
- if (entity.type === EntityType.Shape && entity.shapeType === ShapeType.Circle) {
5705
- const radius = entity.circleOfRadius;
5706
- if (!radius) {
5707
- throw "circleOfRadius is undefined";
5708
- }
5709
- width = radius * 2;
5710
- height = radius * 2;
5711
- }
5712
- const xMin = entity.absolutePosition.x - width * anchorPoint.x * scale;
5713
- const xMax = entity.absolutePosition.x + width * (1 - anchorPoint.x) * scale;
5714
- const yMin = entity.absolutePosition.y - height * anchorPoint.y * scale;
5715
- const yMax = entity.absolutePosition.y + height * (1 - anchorPoint.y) * scale;
5716
- return { xMin, xMax, yMin, yMax };
5904
+ const points = M2c2KitHelpers.calculateRotatedPoints(
5905
+ entity
5906
+ );
5907
+ return entity.isUserInteractionEnabled && M2c2KitHelpers.isPointInsideRectangle({ x, y }, points);
5717
5908
  }
5718
5909
  prependAssetsGameIdUrl(url) {
5719
5910
  function hasUrlScheme(str) {
@@ -5738,25 +5929,14 @@ class RenderedDataUrlImage {
5738
5929
  }
5739
5930
  }
5740
5931
 
5741
- var __defProp$5 = Object.defineProperty;
5742
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5743
- var __publicField$5 = (obj, key, value) => {
5744
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
5745
- return value;
5746
- };
5747
5932
  class RenderedImages {
5748
5933
  }
5749
5934
  class LoadedImages {
5750
5935
  }
5751
5936
  class ImageManager {
5752
5937
  constructor(session) {
5753
- __publicField$5(this, "canvasKit");
5754
- __publicField$5(this, "renderedImages", new RenderedImages());
5755
- __publicField$5(this, "loadedImages", new LoadedImages());
5756
- __publicField$5(this, "_scratchCanvas");
5757
- __publicField$5(this, "ctx");
5758
- __publicField$5(this, "scale");
5759
- __publicField$5(this, "session");
5938
+ this.renderedImages = new RenderedImages();
5939
+ this.loadedImages = new LoadedImages();
5760
5940
  this.session = session;
5761
5941
  }
5762
5942
  /**
@@ -6030,10 +6210,9 @@ class ImageManager {
6030
6210
  return window.btoa(binary);
6031
6211
  }
6032
6212
  inferImageSubtypeFromUrl(url) {
6033
- var _a, _b;
6034
6213
  let subtype = "jpeg";
6035
- if (url == null ? void 0 : url.includes(".")) {
6036
- subtype = (_b = (_a = url.split(".").pop()) == null ? void 0 : _a.toLowerCase()) != null ? _b : "jpeg";
6214
+ if (url?.includes(".")) {
6215
+ subtype = url.split(".").pop()?.toLowerCase() ?? "jpeg";
6037
6216
  if (subtype === "") {
6038
6217
  subtype = "jpeg";
6039
6218
  }
@@ -6052,7 +6231,7 @@ class ImageManager {
6052
6231
  img = this.canvasKit.MakeImageFromEncoded(
6053
6232
  this.dataURLtoArrayBuffer(loadedDataUrlImage.dataUrlImage)
6054
6233
  );
6055
- } catch (e) {
6234
+ } catch {
6056
6235
  throw new Error(
6057
6236
  `could not create image with name "${loadedDataUrlImage.name}."`
6058
6237
  );
@@ -6104,9 +6283,8 @@ class ImageManager {
6104
6283
  return u8arr.buffer;
6105
6284
  }
6106
6285
  removeScratchCanvas() {
6107
- var _a;
6108
6286
  this.ctx = void 0;
6109
- (_a = this._scratchCanvas) == null ? void 0 : _a.remove();
6287
+ this._scratchCanvas?.remove();
6110
6288
  }
6111
6289
  }
6112
6290
 
@@ -6117,29 +6295,6 @@ var LabelHorizontalAlignmentMode = /* @__PURE__ */ ((LabelHorizontalAlignmentMod
6117
6295
  return LabelHorizontalAlignmentMode2;
6118
6296
  })(LabelHorizontalAlignmentMode || {});
6119
6297
 
6120
- var __defProp$4 = Object.defineProperty;
6121
- var __defProps$2 = Object.defineProperties;
6122
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
6123
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
6124
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
6125
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
6126
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6127
- var __spreadValues$3 = (a, b) => {
6128
- for (var prop in b || (b = {}))
6129
- if (__hasOwnProp$3.call(b, prop))
6130
- __defNormalProp$4(a, prop, b[prop]);
6131
- if (__getOwnPropSymbols$3)
6132
- for (var prop of __getOwnPropSymbols$3(b)) {
6133
- if (__propIsEnum$3.call(b, prop))
6134
- __defNormalProp$4(a, prop, b[prop]);
6135
- }
6136
- return a;
6137
- };
6138
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
6139
- var __publicField$4 = (obj, key, value) => {
6140
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
6141
- return value;
6142
- };
6143
6298
  class Label extends Entity {
6144
6299
  /**
6145
6300
  * Single or multi-line text formatted and rendered on the screen.
@@ -6150,36 +6305,22 @@ class Label extends Entity {
6150
6305
  */
6151
6306
  constructor(options = {}) {
6152
6307
  super(options);
6153
- __publicField$4(this, "type", EntityType.Label);
6154
- __publicField$4(this, "isDrawable", true);
6155
- __publicField$4(this, "isText", true);
6308
+ this.type = EntityType.Label;
6309
+ this.isDrawable = true;
6310
+ this.isText = true;
6156
6311
  // Drawable options
6157
- __publicField$4(this, "anchorPoint", { x: 0.5, y: 0.5 });
6158
- __publicField$4(this, "zPosition", 0);
6312
+ this.anchorPoint = { x: 0.5, y: 0.5 };
6313
+ this.zPosition = 0;
6159
6314
  // Text options
6160
- __publicField$4(this, "_text", "");
6161
- // public getter/setter is below
6162
- __publicField$4(this, "_fontName");
6315
+ this._text = "";
6163
6316
  // public getter/setter is below
6164
- __publicField$4(this, "_fontNames");
6317
+ this._fontColor = Constants.DEFAULT_FONT_COLOR;
6165
6318
  // public getter/setter is below
6166
- __publicField$4(this, "_fontColor", Constants.DEFAULT_FONT_COLOR);
6167
- // public getter/setter is below
6168
- __publicField$4(this, "_fontSize", Constants.DEFAULT_FONT_SIZE);
6319
+ this._fontSize = Constants.DEFAULT_FONT_SIZE;
6169
6320
  // public getter/setter is below
6170
6321
  // Label options
6171
- __publicField$4(this, "_horizontalAlignmentMode", LabelHorizontalAlignmentMode.Center);
6172
- // public getter/setter is below
6173
- __publicField$4(this, "_preferredMaxLayoutWidth");
6174
- // public getter/setter is below
6175
- __publicField$4(this, "_backgroundColor");
6176
- // public getter/setter is below
6177
- __publicField$4(this, "paragraph");
6178
- __publicField$4(this, "paraStyle");
6179
- __publicField$4(this, "builder");
6180
- __publicField$4(this, "_fontPaint");
6181
- __publicField$4(this, "_backgroundPaint");
6182
- __publicField$4(this, "_translatedText", "");
6322
+ this._horizontalAlignmentMode = LabelHorizontalAlignmentMode.Center;
6323
+ this._translatedText = "";
6183
6324
  handleInterfaceOptions(this, options);
6184
6325
  if (options.horizontalAlignmentMode) {
6185
6326
  this.horizontalAlignmentMode = options.horizontalAlignmentMode;
@@ -6195,7 +6336,6 @@ class Label extends Entity {
6195
6336
  }
6196
6337
  }
6197
6338
  initialize() {
6198
- var _a, _b, _c;
6199
6339
  let ckTextAlign = this.canvasKit.TextAlign.Center;
6200
6340
  switch (this.horizontalAlignmentMode) {
6201
6341
  case LabelHorizontalAlignmentMode.Center:
@@ -6347,7 +6487,7 @@ class Label extends Entity {
6347
6487
  this.paragraph = this.builder.build();
6348
6488
  const preferredWidth = (
6349
6489
  //this.preferredMaxLayoutWidth ?? this.parentScene.game.canvasCssWidth;
6350
- (_a = this.preferredMaxLayoutWidth) != null ? _a : Globals.canvasCssWidth
6490
+ this.preferredMaxLayoutWidth ?? Globals.canvasCssWidth
6351
6491
  );
6352
6492
  let calculatedWidth = preferredWidth;
6353
6493
  if (preferredWidth === 0 || this.layout.width === 0) {
@@ -6356,8 +6496,8 @@ class Label extends Entity {
6356
6496
  "width is set to match parent, but entity has no parent"
6357
6497
  );
6358
6498
  }
6359
- const marginStart = (_b = this.layout.marginStart) != null ? _b : 0;
6360
- const marginEnd = (_c = this.layout.marginEnd) != null ? _c : 0;
6499
+ const marginStart = this.layout.marginStart ?? 0;
6500
+ const marginEnd = this.layout.marginEnd ?? 0;
6361
6501
  calculatedWidth = this.parent.size.width - (marginStart + marginEnd);
6362
6502
  }
6363
6503
  this.paragraph.layout(calculatedWidth * Globals.canvasScale);
@@ -6468,12 +6608,15 @@ class Label extends Entity {
6468
6608
  * provided, name will be the new uuid
6469
6609
  */
6470
6610
  duplicate(newName) {
6471
- const dest = new Label(__spreadProps$2(__spreadValues$3(__spreadValues$3(__spreadValues$3({}, this.getEntityOptions()), this.getDrawableOptions()), this.getTextOptions()), {
6611
+ const dest = new Label({
6612
+ ...this.getEntityOptions(),
6613
+ ...this.getDrawableOptions(),
6614
+ ...this.getTextOptions(),
6472
6615
  horizontalAlignmentMode: this.horizontalAlignmentMode,
6473
6616
  preferredMaxLayoutWidth: this.preferredMaxLayoutWidth,
6474
6617
  backgroundColor: this.backgroundColor,
6475
6618
  name: newName
6476
- }));
6619
+ });
6477
6620
  if (this.children.length > 0) {
6478
6621
  dest.children = this.children.map((child) => {
6479
6622
  const clonedChild = child.duplicate();
@@ -6494,6 +6637,7 @@ class Label extends Entity {
6494
6637
  canvas.save();
6495
6638
  const drawScale = Globals.canvasScale / this.absoluteScale;
6496
6639
  canvas.scale(1 / drawScale, 1 / drawScale);
6640
+ M2c2KitHelpers.rotateCanvasForDrawableEntity(canvas, this);
6497
6641
  const x = (this.absolutePosition.x - this.size.width * this.anchorPoint.x * this.absoluteScale) * drawScale;
6498
6642
  const y = (this.absolutePosition.y - this.size.height * this.anchorPoint.y * this.absoluteScale) * drawScale;
6499
6643
  if (this.paragraph === void 0) {
@@ -6517,57 +6661,6 @@ class Label extends Entity {
6517
6661
  }
6518
6662
  }
6519
6663
 
6520
- var __defProp$3 = Object.defineProperty;
6521
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6522
- var __publicField$3 = (obj, key, value) => {
6523
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
6524
- return value;
6525
- };
6526
- class MutablePath {
6527
- constructor() {
6528
- __publicField$3(this, "size", { width: 0, height: 0 });
6529
- __publicField$3(this, "_subpaths", new Array());
6530
- __publicField$3(this, "currentPath", new Array());
6531
- }
6532
- get subpaths() {
6533
- if (this.currentPath.length > 0) {
6534
- return [...this._subpaths, this.currentPath];
6535
- } else {
6536
- return this._subpaths;
6537
- }
6538
- }
6539
- /**
6540
- * Starts a new subpath at a given point.
6541
- *
6542
- * @param point - location at which to start the new subpath
6543
- */
6544
- move(point) {
6545
- if (this.currentPath.length > 0) {
6546
- this._subpaths.push(this.currentPath);
6547
- }
6548
- this.currentPath = new Array();
6549
- this.currentPath.push(point);
6550
- }
6551
- /**
6552
- * Adds a straight line to the current subpath.
6553
- *
6554
- * @remarks The line is added from the last point in the current subpath to
6555
- * the given point.
6556
- *
6557
- * @param point - location where the line will end
6558
- */
6559
- addLine(point) {
6560
- this.currentPath.push(point);
6561
- }
6562
- clear() {
6563
- this._subpaths = new Array();
6564
- this.currentPath = new Array();
6565
- }
6566
- duplicate(newName) {
6567
- throw new Error("Method not implemented.");
6568
- }
6569
- }
6570
-
6571
6664
  class RandomDraws {
6572
6665
  /**
6573
6666
  * Draws a single random integer from a uniform distribution of integers in
@@ -6620,7 +6713,7 @@ class RandomDraws {
6620
6713
  * grid location to be along the diagonal, the predicate would be:
6621
6714
  * (row, column) => row === column
6622
6715
  * @returns Array of grid cells. Each cell is object in form of:
6623
- * \{ row: number, column: number \}. Grid cell locations are zero-based
6716
+ * &#123 row: number, column: number &#125;. Grid cell locations are zero-based
6624
6717
  */
6625
6718
  static FromGridWithoutReplacement(n, rows, columns, predicate) {
6626
6719
  const result = new Array();
@@ -6661,10 +6754,7 @@ function getAugmentedNamespace(n) {
6661
6754
  if (typeof f == "function") {
6662
6755
  var a = function a () {
6663
6756
  if (this instanceof a) {
6664
- var args = [null];
6665
- args.push.apply(args, arguments);
6666
- var Ctor = Function.bind.apply(f, args);
6667
- return new Ctor();
6757
+ return Reflect.construct(f, arguments, this.constructor);
6668
6758
  }
6669
6759
  return f.apply(this, arguments);
6670
6760
  };
@@ -7231,26 +7321,6 @@ var w;w||(w=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var da,ea
7231
7321
  var canvaskitExports = canvaskit.exports;
7232
7322
  var CanvasKitInit = /*@__PURE__*/getDefaultExportFromCjs(canvaskitExports);
7233
7323
 
7234
- var __defProp$2 = Object.defineProperty;
7235
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
7236
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
7237
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
7238
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7239
- var __spreadValues$2 = (a, b) => {
7240
- for (var prop in b || (b = {}))
7241
- if (__hasOwnProp$2.call(b, prop))
7242
- __defNormalProp$2(a, prop, b[prop]);
7243
- if (__getOwnPropSymbols$2)
7244
- for (var prop of __getOwnPropSymbols$2(b)) {
7245
- if (__propIsEnum$2.call(b, prop))
7246
- __defNormalProp$2(a, prop, b[prop]);
7247
- }
7248
- return a;
7249
- };
7250
- var __publicField$2 = (obj, key, value) => {
7251
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
7252
- return value;
7253
- };
7254
7324
  class Session {
7255
7325
  /**
7256
7326
  * A Session contains one or more activities. The session manages the start
@@ -7259,17 +7329,10 @@ class Session {
7259
7329
  * @param options
7260
7330
  */
7261
7331
  constructor(options) {
7262
- __publicField$2(this, "options");
7263
- __publicField$2(this, "fontManager");
7264
- __publicField$2(this, "imageManager");
7265
- __publicField$2(this, "currentActivity");
7266
- __publicField$2(this, "uuid");
7267
- __publicField$2(this, "dataStores");
7268
- __publicField$2(this, "eventListeners", new Array());
7269
- __publicField$2(this, "sessionDictionary", /* @__PURE__ */ new Map());
7270
- __publicField$2(this, "canvasKit");
7271
- __publicField$2(this, "initialized", false);
7272
- __publicField$2(this, "version", "0.3.13 (f05b4c6d)");
7332
+ this.eventListeners = new Array();
7333
+ this.sessionDictionary = /* @__PURE__ */ new Map();
7334
+ this.initialized = false;
7335
+ this.version = "0.3.14 (60325bea)";
7273
7336
  this.options = options;
7274
7337
  for (const activity of this.options.activities) {
7275
7338
  if (this.options.activities.filter((a) => a === activity).length > 1) {
@@ -7343,9 +7406,9 @@ class Session {
7343
7406
  const eventListener = {
7344
7407
  type,
7345
7408
  callback,
7346
- key: options == null ? void 0 : options.key
7409
+ key: options?.key
7347
7410
  };
7348
- if (options == null ? void 0 : options.replaceExisting) {
7411
+ if (options?.replaceExisting) {
7349
7412
  this.eventListeners = this.eventListeners.filter(
7350
7413
  (listener) => !(listener.type === eventListener.type)
7351
7414
  );
@@ -7354,7 +7417,11 @@ class Session {
7354
7417
  }
7355
7418
  raiseEventOnListeners(event, extra) {
7356
7419
  if (extra) {
7357
- event = __spreadValues$2(__spreadValues$2({}, event), extra);
7420
+ event = {
7421
+ ...event,
7422
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7423
+ ...extra
7424
+ };
7358
7425
  }
7359
7426
  this.eventListeners.filter((listener) => listener.type === event.type).forEach((listener) => {
7360
7427
  listener.callback(event);
@@ -7430,13 +7497,12 @@ class Session {
7430
7497
  }
7431
7498
  const activityPrototype = Object.getPrototypeOf(activity);
7432
7499
  const gamePrototype = Object.getPrototypeOf(activityPrototype);
7433
- return (activityPrototype == null ? void 0 : activityPrototype.init) !== (gamePrototype == null ? void 0 : gamePrototype.init);
7500
+ return activityPrototype?.init !== gamePrototype?.init;
7434
7501
  }
7435
7502
  /**
7436
7503
  * Asynchronously initializes the m2c2kit engine and loads assets
7437
7504
  */
7438
7505
  async initialize() {
7439
- var _a;
7440
7506
  console.log(`\u26AA @m2c2kit/core version ${this.version}`);
7441
7507
  Timer.start("sessionInitialize");
7442
7508
  const sessionInitializeEvent = {
@@ -7448,7 +7514,7 @@ class Session {
7448
7514
  DomHelpers.setSpinnerVisibility(true);
7449
7515
  DomHelpers.setCanvasOverlayVisibility(true);
7450
7516
  this.dataStores = this.options.dataStores;
7451
- if (((_a = this.dataStores) == null ? void 0 : _a.length) === 0) {
7517
+ if (this.dataStores?.length === 0) {
7452
7518
  throw new Error(
7453
7519
  "Session.initialize(): dataStores must be undefined or a non-zero array of datastores."
7454
7520
  );
@@ -7737,9 +7803,8 @@ class Session {
7737
7803
  }
7738
7804
  getImagesConfigurationFromGames() {
7739
7805
  return this.options.activities.filter((activity) => activity.type == ActivityType.Game).map((activity) => {
7740
- var _a;
7741
7806
  const game = activity;
7742
- return { uuid: game.uuid, images: (_a = game.options.images) != null ? _a : [] };
7807
+ return { uuid: game.uuid, images: game.options.images ?? [] };
7743
7808
  });
7744
7809
  }
7745
7810
  prependAssetsUrl(url) {
@@ -7756,29 +7821,6 @@ class Session {
7756
7821
  }
7757
7822
  }
7758
7823
 
7759
- var __defProp$1 = Object.defineProperty;
7760
- var __defProps$1 = Object.defineProperties;
7761
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
7762
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
7763
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
7764
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
7765
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7766
- var __spreadValues$1 = (a, b) => {
7767
- for (var prop in b || (b = {}))
7768
- if (__hasOwnProp$1.call(b, prop))
7769
- __defNormalProp$1(a, prop, b[prop]);
7770
- if (__getOwnPropSymbols$1)
7771
- for (var prop of __getOwnPropSymbols$1(b)) {
7772
- if (__propIsEnum$1.call(b, prop))
7773
- __defNormalProp$1(a, prop, b[prop]);
7774
- }
7775
- return a;
7776
- };
7777
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
7778
- var __publicField$1 = (obj, key, value) => {
7779
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
7780
- return value;
7781
- };
7782
7824
  class Shape extends Entity {
7783
7825
  /**
7784
7826
  * Rectangular, circular, or path-based shape
@@ -7787,45 +7829,41 @@ class Shape extends Entity {
7787
7829
  */
7788
7830
  constructor(options = {}) {
7789
7831
  super(options);
7790
- __publicField$1(this, "type", EntityType.Shape);
7791
- __publicField$1(this, "isDrawable", true);
7792
- __publicField$1(this, "isShape", true);
7832
+ this.type = EntityType.Shape;
7833
+ this.isDrawable = true;
7834
+ this.isShape = true;
7793
7835
  // Drawable options
7794
- __publicField$1(this, "anchorPoint", { x: 0.5, y: 0.5 });
7795
- __publicField$1(this, "zPosition", 0);
7836
+ this.anchorPoint = { x: 0.5, y: 0.5 };
7837
+ this.zPosition = 0;
7796
7838
  // Shape options
7797
7839
  // TODO: fix the Size issue; should be readonly (calculated value) in all entities, but Rectangle
7798
- __publicField$1(this, "shapeType", ShapeType.Undefined);
7799
- __publicField$1(this, "circleOfRadius");
7800
- __publicField$1(this, "rect");
7801
- __publicField$1(this, "path");
7802
- __publicField$1(this, "ckPath", null);
7803
- __publicField$1(this, "ckPathWidth");
7804
- __publicField$1(this, "ckPathHeight");
7805
- __publicField$1(this, "cornerRadius", 0);
7806
- __publicField$1(this, "_fillColor", Constants.DEFAULT_SHAPE_FILL_COLOR);
7807
- __publicField$1(this, "_strokeColor");
7808
- __publicField$1(this, "lineWidth");
7809
- __publicField$1(this, "_isAntialiased", true);
7810
- __publicField$1(this, "_fillColorPaintAntialiased");
7811
- __publicField$1(this, "_strokeColorPaintAntialiased");
7812
- __publicField$1(this, "_fillColorPaintNotAntialiased");
7813
- __publicField$1(this, "_strokeColorPaintNotAntialiased");
7814
- __publicField$1(this, "svgPathRequestedWidth");
7815
- __publicField$1(this, "svgPathRequestedHeight");
7816
- __publicField$1(this, "svgPathScaleForResizing", 1);
7817
- __publicField$1(this, "svgPathWidth", 0);
7818
- __publicField$1(this, "svgPathHeight", 0);
7819
- __publicField$1(this, "svgPreviousAbsoluteX", NaN);
7820
- __publicField$1(this, "svgPreviousAbsoluteY", NaN);
7821
- __publicField$1(this, "svgFirstPathDraw", true);
7840
+ this.shapeType = ShapeType.Undefined;
7841
+ this.ckPath = null;
7842
+ this.cornerRadius = 0;
7843
+ this._fillColor = Constants.DEFAULT_SHAPE_FILL_COLOR;
7844
+ this._isAntialiased = true;
7845
+ this.svgPathScaleForResizing = 1;
7846
+ this.svgPathWidth = 0;
7847
+ this.svgPathHeight = 0;
7848
+ this.svgPreviousAbsoluteX = NaN;
7849
+ this.svgPreviousAbsoluteY = NaN;
7850
+ this.svgFirstPathDraw = true;
7851
+ this.colorfulPathPaints = /* @__PURE__ */ new Map();
7822
7852
  handleInterfaceOptions(this, options);
7823
7853
  if (options.path !== void 0) {
7824
7854
  this.path = options.path;
7825
7855
  this.shapeType = ShapeType.Path;
7826
- if (this.path.size !== void 0) {
7827
- this.size.height = this.path.size.height;
7828
- this.size.width = this.path.size.width;
7856
+ if (this.shapeIsM2Path()) {
7857
+ if (options.size !== void 0) {
7858
+ this.size = options.size;
7859
+ }
7860
+ }
7861
+ if (this.shapeIsSvgStringPath()) {
7862
+ if (options.size !== void 0) {
7863
+ throw new Error(
7864
+ "Size cannot be specified when path is SVG string path"
7865
+ );
7866
+ }
7829
7867
  }
7830
7868
  this.svgPathRequestedWidth = options.path.width;
7831
7869
  this.svgPathRequestedHeight = options.path.height;
@@ -7906,11 +7944,16 @@ class Shape extends Entity {
7906
7944
  initialize() {
7907
7945
  if (this.shapeType === ShapeType.Path) {
7908
7946
  if (this.shapeIsSvgStringPath()) {
7909
- const pathSvgString = this.path.svgPathString;
7910
- if (!pathSvgString) {
7947
+ const pathString = this.path.pathString ?? this.path.svgPathString;
7948
+ if (!pathString) {
7911
7949
  throw new Error("SVG Path string is null/undefined");
7912
7950
  }
7913
- this.ckPath = this.canvasKit.Path.MakeFromSVGString(pathSvgString);
7951
+ if (this.path.svgPathString !== void 0) {
7952
+ console.warn(
7953
+ `warning: svgPathString is deprecated. Use pathString instead.`
7954
+ );
7955
+ }
7956
+ this.ckPath = this.canvasKit.Path.MakeFromSVGString(pathString);
7914
7957
  if (!this.ckPath) {
7915
7958
  throw new Error("could not make CanvasKit Path from SVG string");
7916
7959
  }
@@ -7928,6 +7971,13 @@ class Shape extends Entity {
7928
7971
  this.svgPreviousAbsoluteY = 0;
7929
7972
  }
7930
7973
  }
7974
+ if (this.shapeIsM2Path()) {
7975
+ if (this.size.width === 0 || this.size.height === 0 || this.size.width === void 0 || this.size.height === void 0) {
7976
+ throw new Error(
7977
+ "Size of shape must have non-zero height and width when path is M2Path"
7978
+ );
7979
+ }
7980
+ }
7931
7981
  if (this.fillColor) {
7932
7982
  this.fillColorPaintAntialiased = CanvasKitHelpers.makePaint(
7933
7983
  this.canvasKit,
@@ -7966,7 +8016,8 @@ class Shape extends Entity {
7966
8016
  this._strokeColorPaintNotAntialiased,
7967
8017
  this._fillColorPaintAntialiased,
7968
8018
  this._fillColorPaintNotAntialiased,
7969
- this.ckPath
8019
+ this.ckPath,
8020
+ ...Array.from(this.colorfulPathPaints.values())
7970
8021
  ]);
7971
8022
  }
7972
8023
  /**
@@ -7980,7 +8031,9 @@ class Shape extends Entity {
7980
8031
  * provided, name will be the new uuid
7981
8032
  */
7982
8033
  duplicate(newName) {
7983
- const dest = new Shape(__spreadProps$1(__spreadValues$1(__spreadValues$1({}, this.getEntityOptions()), this.getDrawableOptions()), {
8034
+ const dest = new Shape({
8035
+ ...this.getEntityOptions(),
8036
+ ...this.getDrawableOptions(),
7984
8037
  shapeType: this.shapeType,
7985
8038
  circleOfRadius: this.circleOfRadius,
7986
8039
  rect: this.rect,
@@ -7989,7 +8042,7 @@ class Shape extends Entity {
7989
8042
  strokeColor: this.strokeColor,
7990
8043
  lineWidth: this.lineWidth,
7991
8044
  name: newName
7992
- }));
8045
+ });
7993
8046
  if (this.children.length > 0) {
7994
8047
  dest.children = this.children.map((child) => {
7995
8048
  const clonedChild = child.duplicate();
@@ -8006,6 +8059,7 @@ class Shape extends Entity {
8006
8059
  canvas.save();
8007
8060
  const drawScale = Globals.canvasScale / this.absoluteScale;
8008
8061
  canvas.scale(1 / drawScale, 1 / drawScale);
8062
+ M2c2KitHelpers.rotateCanvasForDrawableEntity(canvas, this);
8009
8063
  if (this.absoluteAlphaChange !== 0) {
8010
8064
  this.applyAlphaToPaints(this.absoluteAlpha, [
8011
8065
  this._fillColorPaintAntialiased,
@@ -8040,8 +8094,52 @@ class Shape extends Entity {
8040
8094
  const drawScale = Globals.canvasScale / this.absoluteScale;
8041
8095
  const pathOriginX = (this.absolutePosition.x - this.anchorPoint.x * this.size.width * this.absoluteScale) * drawScale;
8042
8096
  const pathOriginY = (this.absolutePosition.y - this.anchorPoint.y * this.size.height * this.absoluteScale) * drawScale;
8097
+ if (this.pathIsM2ColorfulPath(this.path)) {
8098
+ const linePresentations = this.path.linePresentations;
8099
+ let lp = 0;
8100
+ const subpaths = this.path.subpaths;
8101
+ let paint;
8102
+ for (let s = 0; s < subpaths.length; s++) {
8103
+ const subpath = subpaths[s];
8104
+ const points = subpath.flat();
8105
+ for (let i = 0; i < points.length - 1; i++) {
8106
+ if (linePresentations[lp].subpathIndex === s && linePresentations[lp].pointIndex === i) {
8107
+ const strokeColor = linePresentations[lp].strokeColor;
8108
+ const lineWidth = linePresentations[lp].lineWidth;
8109
+ const paintKey = [...strokeColor, lineWidth].toString();
8110
+ paint = this.colorfulPathPaints.get(paintKey);
8111
+ if (paint === void 0) {
8112
+ paint = CanvasKitHelpers.makePaint(
8113
+ this.canvasKit,
8114
+ strokeColor,
8115
+ this.canvasKit.PaintStyle.Stroke,
8116
+ true
8117
+ );
8118
+ paint.setStrokeWidth(lineWidth * Globals.canvasScale);
8119
+ this.colorfulPathPaints.set(paintKey, paint);
8120
+ }
8121
+ if (lp < linePresentations.length - 1) {
8122
+ lp++;
8123
+ }
8124
+ }
8125
+ if (paint === void 0) {
8126
+ throw new Error("paint is undefined");
8127
+ }
8128
+ canvas.drawLine(
8129
+ pathOriginX + points[i].x * Globals.canvasScale,
8130
+ pathOriginY + points[i].y * Globals.canvasScale,
8131
+ pathOriginX + points[i + 1].x * Globals.canvasScale,
8132
+ pathOriginY + points[i + 1].y * Globals.canvasScale,
8133
+ paint
8134
+ );
8135
+ }
8136
+ }
8137
+ return;
8138
+ }
8043
8139
  if (this.strokeColor && this.strokeColorPaintAntialiased && this.lineWidth) {
8044
- this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth);
8140
+ this.strokeColorPaintAntialiased.setStrokeWidth(
8141
+ this.lineWidth * Globals.canvasScale
8142
+ );
8045
8143
  const subpaths = this.path.subpaths;
8046
8144
  for (const subpath of subpaths) {
8047
8145
  const points = subpath.flat();
@@ -8107,12 +8205,13 @@ class Shape extends Entity {
8107
8205
  return this.svgFirstPathDraw === true || x !== this.svgPreviousAbsoluteX || y !== this.svgPreviousAbsoluteY;
8108
8206
  }
8109
8207
  shapeIsSvgStringPath() {
8110
- var _a;
8111
- return ((_a = this.path) == null ? void 0 : _a.svgPathString) !== void 0;
8208
+ return this.path?.pathString !== void 0 || this.path?.svgPathString !== void 0;
8112
8209
  }
8113
8210
  shapeIsM2Path() {
8114
- var _a;
8115
- return ((_a = this.path) == null ? void 0 : _a.subpaths) !== void 0;
8211
+ return this.path?.subpaths !== void 0;
8212
+ }
8213
+ pathIsM2ColorfulPath(path) {
8214
+ return path !== void 0 && "linePresentations" in path;
8116
8215
  }
8117
8216
  drawCircle(canvas) {
8118
8217
  if (!this.circleOfRadius) {
@@ -8314,29 +8413,6 @@ class Story {
8314
8413
  }
8315
8414
  }
8316
8415
 
8317
- var __defProp = Object.defineProperty;
8318
- var __defProps = Object.defineProperties;
8319
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8320
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8321
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8322
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8323
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8324
- var __spreadValues = (a, b) => {
8325
- for (var prop in b || (b = {}))
8326
- if (__hasOwnProp.call(b, prop))
8327
- __defNormalProp(a, prop, b[prop]);
8328
- if (__getOwnPropSymbols)
8329
- for (var prop of __getOwnPropSymbols(b)) {
8330
- if (__propIsEnum.call(b, prop))
8331
- __defNormalProp(a, prop, b[prop]);
8332
- }
8333
- return a;
8334
- };
8335
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8336
- var __publicField = (obj, key, value) => {
8337
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8338
- return value;
8339
- };
8340
8416
  class TextLine extends Entity {
8341
8417
  /**
8342
8418
  * Single-line text rendered on the screen.
@@ -8346,33 +8422,26 @@ class TextLine extends Entity {
8346
8422
  * @param options - {@link TextLineOptions}
8347
8423
  */
8348
8424
  constructor(options = {}) {
8349
- var _a;
8350
8425
  super(options);
8351
- __publicField(this, "type", EntityType.TextLine);
8352
- __publicField(this, "isDrawable", true);
8353
- __publicField(this, "isText", true);
8426
+ this.type = EntityType.TextLine;
8427
+ this.isDrawable = true;
8428
+ this.isText = true;
8354
8429
  // Drawable options
8355
- __publicField(this, "zPosition", 0);
8430
+ this.zPosition = 0;
8356
8431
  // We don't know TextLine width in advance, so we must text align left,
8357
8432
  // and so anchorPoint is (0, .5). (we do know height, which is fontSize)
8358
- __publicField(this, "anchorPoint", { x: 0, y: 0.5 });
8433
+ this.anchorPoint = { x: 0, y: 0.5 };
8359
8434
  // Text options
8360
- __publicField(this, "_text", "");
8435
+ this._text = "";
8361
8436
  // public getter/setter is below
8362
- __publicField(this, "_fontName");
8437
+ this._fontColor = Constants.DEFAULT_FONT_COLOR;
8363
8438
  // public getter/setter is below
8364
- __publicField(this, "_fontColor", Constants.DEFAULT_FONT_COLOR);
8365
- // public getter/setter is below
8366
- __publicField(this, "_fontSize", Constants.DEFAULT_FONT_SIZE);
8367
- // public getter/setter is below
8368
- __publicField(this, "paint");
8369
- __publicField(this, "font");
8370
- __publicField(this, "typeface", null);
8371
- __publicField(this, "_translatedText", "");
8372
- __publicField(this, "missingTranslationPaint");
8439
+ this._fontSize = Constants.DEFAULT_FONT_SIZE;
8440
+ this.typeface = null;
8441
+ this._translatedText = "";
8373
8442
  handleInterfaceOptions(this, options);
8374
8443
  this.size.height = this.fontSize;
8375
- this.size.width = (_a = options.width) != null ? _a : NaN;
8444
+ this.size.width = options.width ?? NaN;
8376
8445
  }
8377
8446
  get text() {
8378
8447
  return this._text;
@@ -8474,10 +8543,13 @@ class TextLine extends Entity {
8474
8543
  * provided, name will be the new uuid
8475
8544
  */
8476
8545
  duplicate(newName) {
8477
- const dest = new TextLine(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, this.getEntityOptions()), this.getDrawableOptions()), this.getTextOptions()), {
8546
+ const dest = new TextLine({
8547
+ ...this.getEntityOptions(),
8548
+ ...this.getDrawableOptions(),
8549
+ ...this.getTextOptions(),
8478
8550
  width: this.size.width,
8479
8551
  name: newName
8480
- }));
8552
+ });
8481
8553
  if (this.children.length > 0) {
8482
8554
  dest.children = this.children.map((child) => {
8483
8555
  const clonedChild = child.duplicate();
@@ -8492,6 +8564,7 @@ class TextLine extends Entity {
8492
8564
  canvas.save();
8493
8565
  const drawScale = Globals.canvasScale / this.absoluteScale;
8494
8566
  canvas.scale(1 / drawScale, 1 / drawScale);
8567
+ M2c2KitHelpers.rotateCanvasForDrawableEntity(canvas, this);
8495
8568
  const x = this.absolutePosition.x * drawScale;
8496
8569
  const y = (this.absolutePosition.y + this.size.height * this.anchorPoint.y * this.absoluteScale) * drawScale;
8497
8570
  let textForDraw;
@@ -8548,5 +8621,5 @@ class TextLine extends Entity {
8548
8621
  }
8549
8622
  }
8550
8623
 
8551
- export { Action, ActivityType, CanvasKitHelpers, Composite, Constants, ConstraintType, CustomAction, Dimensions, Easings, Entity, EntityType, Equals, EventType, FadeAlphaAction, FontManager, Game, GlobalVariables, GroupAction, I18n, ImageManager, Label, LabelHorizontalAlignmentMode, LayoutConstraint, LoadedImage, MoveAction, MutablePath, NoneTransition, RandomDraws, ScaleAction, Scene, SceneTransition, SequenceAction, Session, Shape, ShapeType, SlideTransition, Sprite, Story, TextLine, Timer, Transition, TransitionDirection, TransitionType, Uuid, WaitAction, WebColors, WebGlInfo, handleInterfaceOptions };
8624
+ export { Action, ActivityType, CanvasKitHelpers, ColorfulMutablePath, Composite, Constants, ConstraintType, CustomAction, Dimensions, Easings, Entity, EntityType, Equals, EventType, FadeAlphaAction, FontManager, Game, GlobalVariables, GroupAction, I18n, ImageManager, Label, LabelHorizontalAlignmentMode, LayoutConstraint, LoadedImage, MoveAction, MutablePath, NoneTransition, RandomDraws, RotateAction, ScaleAction, Scene, SceneTransition, SequenceAction, Session, Shape, ShapeType, SlideTransition, Sprite, Story, TextLine, Timer, Transition, TransitionDirection, TransitionType, Uuid, WaitAction, WebColors, WebGlInfo, handleInterfaceOptions };
8552
8625
  //# sourceMappingURL=index.js.map