pixi-watchface-engine 0.1.0 → 0.1.2

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.
package/dist/index.js CHANGED
@@ -33036,12 +33036,15 @@ class Text extends AbstractText {
33036
33036
  }
33037
33037
  }
33038
33038
  // node_modules/pixi.js/lib/index.mjs
33039
+ init_Point();
33040
+ init_Rectangle();
33039
33041
  init_Texture();
33040
33042
  init_textureFrom();
33041
33043
  init_Container();
33042
33044
  init_Graphics();
33043
33045
  init_Sprite();
33044
33046
  init_TextStyle();
33047
+ init_Ticker();
33045
33048
  init_eventemitter3();
33046
33049
  extensions.add(browserExt, webworkerExt);
33047
33050
 
@@ -34673,6 +34676,7 @@ class WatchfaceEngine {
34673
34676
  elementsLayer;
34674
34677
  selectionLayer;
34675
34678
  overlayLayer;
34679
+ _contentRoot;
34676
34680
  interaction;
34677
34681
  _options;
34678
34682
  _initialized = false;
@@ -34700,12 +34704,18 @@ class WatchfaceEngine {
34700
34704
  autoDensity: true
34701
34705
  });
34702
34706
  container.appendChild(this.app.canvas);
34707
+ this._contentRoot = new Container;
34708
+ if (options.coordinateOrigin === "center") {
34709
+ this._contentRoot.x = options.width / 2;
34710
+ this._contentRoot.y = options.height / 2;
34711
+ }
34703
34712
  this.backgroundLayer = new Container;
34704
34713
  this.elementsLayer = new Container;
34705
34714
  this.elementsLayer.sortableChildren = true;
34706
34715
  this.selectionLayer = new Container;
34707
34716
  this.overlayLayer = new Container;
34708
- this.app.stage.addChild(this.backgroundLayer, this.elementsLayer, this.selectionLayer, this.overlayLayer);
34717
+ this._contentRoot.addChild(this.backgroundLayer, this.elementsLayer, this.selectionLayer, this.overlayLayer);
34718
+ this.app.stage.addChild(this._contentRoot);
34709
34719
  this.app.stage.eventMode = "static";
34710
34720
  this.app.stage.hitArea = this.app.screen;
34711
34721
  this.elements._setLayer(this.elementsLayer);
@@ -34726,6 +34736,15 @@ class WatchfaceEngine {
34726
34736
  get initialized() {
34727
34737
  return this._initialized;
34728
34738
  }
34739
+ get originOffset() {
34740
+ if (this._options?.coordinateOrigin === "center") {
34741
+ return { x: this._options.width / 2, y: this._options.height / 2 };
34742
+ }
34743
+ return { x: 0, y: 0 };
34744
+ }
34745
+ getContentRoot() {
34746
+ return this._contentRoot;
34747
+ }
34729
34748
  getBackgroundLayer() {
34730
34749
  return this.backgroundLayer;
34731
34750
  }
@@ -34984,9 +35003,1561 @@ class KeyboardShortcutsPlugin {
34984
35003
  }
34985
35004
  }
34986
35005
  }
35006
+ // node_modules/pixi-viewport/dist/pixi_viewport.js
35007
+ var S2 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
35008
+ function M2(l2) {
35009
+ return l2 && l2.__esModule && Object.prototype.hasOwnProperty.call(l2, "default") ? l2.default : l2;
35010
+ }
35011
+ var W = { exports: {} };
35012
+ (function(l2, t2) {
35013
+ (function() {
35014
+ var e2, n2;
35015
+ n2 = function(i2) {
35016
+ return l2.exports = i2;
35017
+ }, e2 = {
35018
+ linear: function(i2, s2, h2, o2) {
35019
+ return h2 * i2 / o2 + s2;
35020
+ },
35021
+ easeInQuad: function(i2, s2, h2, o2) {
35022
+ return h2 * (i2 /= o2) * i2 + s2;
35023
+ },
35024
+ easeOutQuad: function(i2, s2, h2, o2) {
35025
+ return -h2 * (i2 /= o2) * (i2 - 2) + s2;
35026
+ },
35027
+ easeInOutQuad: function(i2, s2, h2, o2) {
35028
+ return (i2 /= o2 / 2) < 1 ? h2 / 2 * i2 * i2 + s2 : -h2 / 2 * (--i2 * (i2 - 2) - 1) + s2;
35029
+ },
35030
+ easeInCubic: function(i2, s2, h2, o2) {
35031
+ return h2 * (i2 /= o2) * i2 * i2 + s2;
35032
+ },
35033
+ easeOutCubic: function(i2, s2, h2, o2) {
35034
+ return h2 * ((i2 = i2 / o2 - 1) * i2 * i2 + 1) + s2;
35035
+ },
35036
+ easeInOutCubic: function(i2, s2, h2, o2) {
35037
+ return (i2 /= o2 / 2) < 1 ? h2 / 2 * i2 * i2 * i2 + s2 : h2 / 2 * ((i2 -= 2) * i2 * i2 + 2) + s2;
35038
+ },
35039
+ easeInQuart: function(i2, s2, h2, o2) {
35040
+ return h2 * (i2 /= o2) * i2 * i2 * i2 + s2;
35041
+ },
35042
+ easeOutQuart: function(i2, s2, h2, o2) {
35043
+ return -h2 * ((i2 = i2 / o2 - 1) * i2 * i2 * i2 - 1) + s2;
35044
+ },
35045
+ easeInOutQuart: function(i2, s2, h2, o2) {
35046
+ return (i2 /= o2 / 2) < 1 ? h2 / 2 * i2 * i2 * i2 * i2 + s2 : -h2 / 2 * ((i2 -= 2) * i2 * i2 * i2 - 2) + s2;
35047
+ },
35048
+ easeInQuint: function(i2, s2, h2, o2) {
35049
+ return h2 * (i2 /= o2) * i2 * i2 * i2 * i2 + s2;
35050
+ },
35051
+ easeOutQuint: function(i2, s2, h2, o2) {
35052
+ return h2 * ((i2 = i2 / o2 - 1) * i2 * i2 * i2 * i2 + 1) + s2;
35053
+ },
35054
+ easeInOutQuint: function(i2, s2, h2, o2) {
35055
+ return (i2 /= o2 / 2) < 1 ? h2 / 2 * i2 * i2 * i2 * i2 * i2 + s2 : h2 / 2 * ((i2 -= 2) * i2 * i2 * i2 * i2 + 2) + s2;
35056
+ },
35057
+ easeInSine: function(i2, s2, h2, o2) {
35058
+ return -h2 * Math.cos(i2 / o2 * (Math.PI / 2)) + h2 + s2;
35059
+ },
35060
+ easeOutSine: function(i2, s2, h2, o2) {
35061
+ return h2 * Math.sin(i2 / o2 * (Math.PI / 2)) + s2;
35062
+ },
35063
+ easeInOutSine: function(i2, s2, h2, o2) {
35064
+ return -h2 / 2 * (Math.cos(Math.PI * i2 / o2) - 1) + s2;
35065
+ },
35066
+ easeInExpo: function(i2, s2, h2, o2) {
35067
+ return i2 === 0 ? s2 : h2 * Math.pow(2, 10 * (i2 / o2 - 1)) + s2;
35068
+ },
35069
+ easeOutExpo: function(i2, s2, h2, o2) {
35070
+ return i2 === o2 ? s2 + h2 : h2 * (-Math.pow(2, -10 * i2 / o2) + 1) + s2;
35071
+ },
35072
+ easeInOutExpo: function(i2, s2, h2, o2) {
35073
+ return (i2 /= o2 / 2) < 1 ? h2 / 2 * Math.pow(2, 10 * (i2 - 1)) + s2 : h2 / 2 * (-Math.pow(2, -10 * --i2) + 2) + s2;
35074
+ },
35075
+ easeInCirc: function(i2, s2, h2, o2) {
35076
+ return -h2 * (Math.sqrt(1 - (i2 /= o2) * i2) - 1) + s2;
35077
+ },
35078
+ easeOutCirc: function(i2, s2, h2, o2) {
35079
+ return h2 * Math.sqrt(1 - (i2 = i2 / o2 - 1) * i2) + s2;
35080
+ },
35081
+ easeInOutCirc: function(i2, s2, h2, o2) {
35082
+ return (i2 /= o2 / 2) < 1 ? -h2 / 2 * (Math.sqrt(1 - i2 * i2) - 1) + s2 : h2 / 2 * (Math.sqrt(1 - (i2 -= 2) * i2) + 1) + s2;
35083
+ },
35084
+ easeInElastic: function(i2, s2, h2, o2) {
35085
+ var r2, a2, p2;
35086
+ return p2 = 1.70158, a2 = 0, r2 = h2, i2 === 0 || (i2 /= o2), a2 || (a2 = o2 * 0.3), r2 < Math.abs(h2) ? (r2 = h2, p2 = a2 / 4) : p2 = a2 / (2 * Math.PI) * Math.asin(h2 / r2), -(r2 * Math.pow(2, 10 * (i2 -= 1)) * Math.sin((i2 * o2 - p2) * (2 * Math.PI) / a2)) + s2;
35087
+ },
35088
+ easeOutElastic: function(i2, s2, h2, o2) {
35089
+ var r2, a2, p2;
35090
+ return p2 = 1.70158, a2 = 0, r2 = h2, i2 === 0 || (i2 /= o2), a2 || (a2 = o2 * 0.3), r2 < Math.abs(h2) ? (r2 = h2, p2 = a2 / 4) : p2 = a2 / (2 * Math.PI) * Math.asin(h2 / r2), r2 * Math.pow(2, -10 * i2) * Math.sin((i2 * o2 - p2) * (2 * Math.PI) / a2) + h2 + s2;
35091
+ },
35092
+ easeInOutElastic: function(i2, s2, h2, o2) {
35093
+ var r2, a2, p2;
35094
+ return p2 = 1.70158, a2 = 0, r2 = h2, i2 === 0 || (i2 /= o2 / 2), a2 || (a2 = o2 * (0.3 * 1.5)), r2 < Math.abs(h2) ? (r2 = h2, p2 = a2 / 4) : p2 = a2 / (2 * Math.PI) * Math.asin(h2 / r2), i2 < 1 ? -0.5 * (r2 * Math.pow(2, 10 * (i2 -= 1)) * Math.sin((i2 * o2 - p2) * (2 * Math.PI) / a2)) + s2 : r2 * Math.pow(2, -10 * (i2 -= 1)) * Math.sin((i2 * o2 - p2) * (2 * Math.PI) / a2) * 0.5 + h2 + s2;
35095
+ },
35096
+ easeInBack: function(i2, s2, h2, o2, r2) {
35097
+ return r2 === undefined && (r2 = 1.70158), h2 * (i2 /= o2) * i2 * ((r2 + 1) * i2 - r2) + s2;
35098
+ },
35099
+ easeOutBack: function(i2, s2, h2, o2, r2) {
35100
+ return r2 === undefined && (r2 = 1.70158), h2 * ((i2 = i2 / o2 - 1) * i2 * ((r2 + 1) * i2 + r2) + 1) + s2;
35101
+ },
35102
+ easeInOutBack: function(i2, s2, h2, o2, r2) {
35103
+ return r2 === undefined && (r2 = 1.70158), (i2 /= o2 / 2) < 1 ? h2 / 2 * (i2 * i2 * (((r2 *= 1.525) + 1) * i2 - r2)) + s2 : h2 / 2 * ((i2 -= 2) * i2 * (((r2 *= 1.525) + 1) * i2 + r2) + 2) + s2;
35104
+ },
35105
+ easeInBounce: function(i2, s2, h2, o2) {
35106
+ var r2;
35107
+ return r2 = e2.easeOutBounce(o2 - i2, 0, h2, o2), h2 - r2 + s2;
35108
+ },
35109
+ easeOutBounce: function(i2, s2, h2, o2) {
35110
+ return (i2 /= o2) < 1 / 2.75 ? h2 * (7.5625 * i2 * i2) + s2 : i2 < 2 / 2.75 ? h2 * (7.5625 * (i2 -= 1.5 / 2.75) * i2 + 0.75) + s2 : i2 < 2.5 / 2.75 ? h2 * (7.5625 * (i2 -= 2.25 / 2.75) * i2 + 0.9375) + s2 : h2 * (7.5625 * (i2 -= 2.625 / 2.75) * i2 + 0.984375) + s2;
35111
+ },
35112
+ easeInOutBounce: function(i2, s2, h2, o2) {
35113
+ var r2;
35114
+ return i2 < o2 / 2 ? (r2 = e2.easeInBounce(i2 * 2, 0, h2, o2), r2 * 0.5 + s2) : (r2 = e2.easeOutBounce(i2 * 2 - o2, 0, h2, o2), r2 * 0.5 + h2 * 0.5 + s2);
35115
+ }
35116
+ }, n2(e2);
35117
+ }).call(S2);
35118
+ })(W);
35119
+ var O = W.exports;
35120
+ var v2 = /* @__PURE__ */ M2(O);
35121
+ function x2(l2, t2) {
35122
+ if (l2) {
35123
+ if (typeof l2 == "function")
35124
+ return l2;
35125
+ if (typeof l2 == "string")
35126
+ return v2[l2];
35127
+ } else
35128
+ return v2[t2];
35129
+ }
35130
+
35131
+ class P {
35132
+ constructor(t2) {
35133
+ this.viewport = t2, this.touches = [], this.addListeners();
35134
+ }
35135
+ addListeners() {
35136
+ this.viewport.eventMode = "static", this.viewport.forceHitArea || (this.viewport.hitArea = new Rectangle(0, 0, this.viewport.worldWidth, this.viewport.worldHeight)), this.viewport.on("pointerdown", this.down, this), this.viewport.options.allowPreserveDragOutside ? this.viewport.on("globalpointermove", this.move, this) : this.viewport.on("pointermove", this.move, this), this.viewport.on("pointerup", this.up, this), this.viewport.on("pointerupoutside", this.up, this), this.viewport.on("pointercancel", this.up, this), this.viewport.options.allowPreserveDragOutside || this.viewport.on("pointerleave", this.up, this), this.wheelFunction = (t2) => this.handleWheel(t2), this.viewport.options.events.domElement.addEventListener("wheel", this.wheelFunction, { passive: this.viewport.options.passiveWheel }), this.isMouseDown = false;
35137
+ }
35138
+ destroy() {
35139
+ var t2;
35140
+ (t2 = this.viewport.options.events.domElement) == null || t2.removeEventListener("wheel", this.wheelFunction);
35141
+ }
35142
+ down(t2) {
35143
+ if (this.viewport.pause || !this.viewport.visible)
35144
+ return;
35145
+ if (t2.pointerType === "mouse" ? this.isMouseDown = true : this.get(t2.pointerId) || this.touches.push({ id: t2.pointerId, last: null }), this.count() === 1) {
35146
+ this.last = t2.global.clone();
35147
+ const n2 = this.viewport.plugins.get("decelerate", true), i2 = this.viewport.plugins.get("bounce", true);
35148
+ (!n2 || !n2.isActive()) && (!i2 || !i2.isActive()) ? this.clickedAvailable = true : this.clickedAvailable = false;
35149
+ } else
35150
+ this.clickedAvailable = false;
35151
+ this.viewport.plugins.down(t2) && this.viewport.options.stopPropagation && t2.stopPropagation();
35152
+ }
35153
+ clear() {
35154
+ this.isMouseDown = false, this.touches = [], this.last = null;
35155
+ }
35156
+ checkThreshold(t2) {
35157
+ return Math.abs(t2) >= this.viewport.threshold;
35158
+ }
35159
+ move(t2) {
35160
+ if (this.viewport.pause || !this.viewport.visible)
35161
+ return;
35162
+ const e2 = this.viewport.plugins.move(t2);
35163
+ if (this.clickedAvailable && this.last) {
35164
+ const n2 = t2.global.x - this.last.x, i2 = t2.global.y - this.last.y;
35165
+ (this.checkThreshold(n2) || this.checkThreshold(i2)) && (this.clickedAvailable = false);
35166
+ }
35167
+ e2 && this.viewport.options.stopPropagation && t2.stopPropagation();
35168
+ }
35169
+ up(t2) {
35170
+ if (this.viewport.pause || !this.viewport.visible)
35171
+ return;
35172
+ t2.pointerType === "mouse" && (this.isMouseDown = false), t2.pointerType !== "mouse" && this.remove(t2.pointerId);
35173
+ const e2 = this.viewport.plugins.up(t2);
35174
+ this.clickedAvailable && this.count() === 0 && this.last && (this.viewport.emit("clicked", {
35175
+ event: t2,
35176
+ screen: this.last,
35177
+ world: this.viewport.toWorld(this.last),
35178
+ viewport: this.viewport
35179
+ }), this.clickedAvailable = false), e2 && this.viewport.options.stopPropagation && t2.stopPropagation();
35180
+ }
35181
+ getPointerPosition(t2) {
35182
+ const e2 = new Point;
35183
+ return this.viewport.options.events.mapPositionToPoint(e2, t2.clientX, t2.clientY), e2;
35184
+ }
35185
+ handleWheel(t2) {
35186
+ if (this.viewport.pause || !this.viewport.visible)
35187
+ return;
35188
+ const e2 = this.viewport.toLocal(this.getPointerPosition(t2));
35189
+ this.viewport.left <= e2.x && e2.x <= this.viewport.right && this.viewport.top <= e2.y && e2.y <= this.viewport.bottom && this.viewport.plugins.wheel(t2) && !this.viewport.options.passiveWheel && t2.preventDefault();
35190
+ }
35191
+ pause() {
35192
+ this.touches = [], this.isMouseDown = false;
35193
+ }
35194
+ get(t2) {
35195
+ for (const e2 of this.touches)
35196
+ if (e2.id === t2)
35197
+ return e2;
35198
+ return null;
35199
+ }
35200
+ remove(t2) {
35201
+ for (let e2 = 0;e2 < this.touches.length; e2++)
35202
+ if (this.touches[e2].id === t2) {
35203
+ this.touches.splice(e2, 1);
35204
+ return;
35205
+ }
35206
+ }
35207
+ count() {
35208
+ return (this.isMouseDown ? 1 : 0) + this.touches.length;
35209
+ }
35210
+ }
35211
+ var m2 = [
35212
+ "drag",
35213
+ "pinch",
35214
+ "wheel",
35215
+ "follow",
35216
+ "mouse-edges",
35217
+ "decelerate",
35218
+ "animate",
35219
+ "bounce",
35220
+ "snap-zoom",
35221
+ "clamp-zoom",
35222
+ "snap",
35223
+ "clamp"
35224
+ ];
35225
+
35226
+ class C {
35227
+ constructor(t2) {
35228
+ this.viewport = t2, this.list = [], this.plugins = {};
35229
+ }
35230
+ add(t2, e2, n2 = m2.length) {
35231
+ const i2 = this.plugins[t2];
35232
+ i2 && i2.destroy(), this.plugins[t2] = e2;
35233
+ const s2 = m2.indexOf(t2);
35234
+ s2 !== -1 && m2.splice(s2, 1), m2.splice(n2, 0, t2), this.sort();
35235
+ }
35236
+ get(t2, e2) {
35237
+ var n2;
35238
+ return e2 && (n2 = this.plugins[t2]) != null && n2.paused ? null : this.plugins[t2];
35239
+ }
35240
+ update(t2) {
35241
+ for (const e2 of this.list)
35242
+ e2.update(t2);
35243
+ }
35244
+ resize() {
35245
+ for (const t2 of this.list)
35246
+ t2.resize();
35247
+ }
35248
+ reset() {
35249
+ for (const t2 of this.list)
35250
+ t2.reset();
35251
+ }
35252
+ removeAll() {
35253
+ this.list.forEach((t2) => {
35254
+ t2.destroy();
35255
+ }), this.plugins = {}, this.sort();
35256
+ }
35257
+ remove(t2) {
35258
+ var e2;
35259
+ this.plugins[t2] && ((e2 = this.plugins[t2]) == null || e2.destroy(), delete this.plugins[t2], this.viewport.emit("plugin-remove", t2), this.sort());
35260
+ }
35261
+ pause(t2) {
35262
+ var e2;
35263
+ (e2 = this.plugins[t2]) == null || e2.pause();
35264
+ }
35265
+ resume(t2) {
35266
+ var e2;
35267
+ (e2 = this.plugins[t2]) == null || e2.resume();
35268
+ }
35269
+ sort() {
35270
+ this.list = [];
35271
+ for (const t2 of m2)
35272
+ this.plugins[t2] && this.list.push(this.plugins[t2]);
35273
+ }
35274
+ down(t2) {
35275
+ let e2 = false;
35276
+ for (const n2 of this.list)
35277
+ n2.down(t2) && (e2 = true);
35278
+ return e2;
35279
+ }
35280
+ move(t2) {
35281
+ let e2 = false;
35282
+ for (const n2 of this.viewport.plugins.list)
35283
+ n2.move(t2) && (e2 = true);
35284
+ return e2;
35285
+ }
35286
+ up(t2) {
35287
+ let e2 = false;
35288
+ for (const n2 of this.list)
35289
+ n2.up(t2) && (e2 = true);
35290
+ return e2;
35291
+ }
35292
+ wheel(t2) {
35293
+ let e2 = false;
35294
+ for (const n2 of this.list)
35295
+ n2.wheel(t2) && (e2 = true);
35296
+ return e2;
35297
+ }
35298
+ }
35299
+
35300
+ class u2 {
35301
+ constructor(t2) {
35302
+ this.parent = t2, this.paused = false;
35303
+ }
35304
+ destroy() {}
35305
+ down(t2) {
35306
+ return false;
35307
+ }
35308
+ move(t2) {
35309
+ return false;
35310
+ }
35311
+ up(t2) {
35312
+ return false;
35313
+ }
35314
+ wheel(t2) {
35315
+ return false;
35316
+ }
35317
+ update(t2) {}
35318
+ resize() {}
35319
+ reset() {}
35320
+ pause() {
35321
+ this.paused = true;
35322
+ }
35323
+ resume() {
35324
+ this.paused = false;
35325
+ }
35326
+ }
35327
+ var I = {
35328
+ removeOnInterrupt: false,
35329
+ ease: "linear",
35330
+ time: 1000
35331
+ };
35332
+
35333
+ class k2 extends u2 {
35334
+ constructor(t2, e2 = {}) {
35335
+ super(t2), this.startWidth = null, this.startHeight = null, this.deltaWidth = null, this.deltaHeight = null, this.width = null, this.height = null, this.time = 0, this.options = Object.assign({}, I, e2), this.options.ease = x2(this.options.ease), this.setupPosition(), this.setupZoom(), this.time = 0;
35336
+ }
35337
+ setupPosition() {
35338
+ typeof this.options.position < "u" ? (this.startX = this.parent.center.x, this.startY = this.parent.center.y, this.deltaX = this.options.position.x - this.parent.center.x, this.deltaY = this.options.position.y - this.parent.center.y, this.keepCenter = false) : this.keepCenter = true;
35339
+ }
35340
+ setupZoom() {
35341
+ this.width = null, this.height = null, typeof this.options.scale < "u" ? this.width = this.parent.screenWidth / this.options.scale : typeof this.options.scaleX < "u" || typeof this.options.scaleY < "u" ? (typeof this.options.scaleX < "u" && (this.width = this.parent.screenWidth / this.options.scaleX), typeof this.options.scaleY < "u" && (this.height = this.parent.screenHeight / this.options.scaleY)) : (typeof this.options.width < "u" && (this.width = this.options.width), typeof this.options.height < "u" && (this.height = this.options.height)), this.width !== null && (this.startWidth = this.parent.screenWidthInWorldPixels, this.deltaWidth = this.width - this.startWidth), this.height !== null && (this.startHeight = this.parent.screenHeightInWorldPixels, this.deltaHeight = this.height - this.startHeight);
35342
+ }
35343
+ down() {
35344
+ return this.options.removeOnInterrupt && this.parent.plugins.remove("animate"), false;
35345
+ }
35346
+ complete() {
35347
+ this.parent.plugins.remove("animate"), this.width !== null && this.parent.fitWidth(this.width, this.keepCenter, this.height === null), this.height !== null && this.parent.fitHeight(this.height, this.keepCenter, this.width === null), !this.keepCenter && this.options.position && this.parent.moveCenter(this.options.position), this.parent.emit("animate-end", this.parent), this.options.callbackOnComplete && this.options.callbackOnComplete(this.parent);
35348
+ }
35349
+ update(t2) {
35350
+ if (this.paused)
35351
+ return;
35352
+ this.time += t2;
35353
+ const e2 = new Point(this.parent.scale.x, this.parent.scale.y);
35354
+ if (this.time >= this.options.time) {
35355
+ const n2 = this.parent.width, i2 = this.parent.height;
35356
+ this.complete(), (n2 !== this.parent.width || i2 !== this.parent.height) && this.parent.emit("zoomed", { viewport: this.parent, original: e2, type: "animate" });
35357
+ } else {
35358
+ const n2 = this.options.ease(this.time, 0, 1, this.options.time);
35359
+ if (this.width !== null) {
35360
+ const i2 = this.startWidth, s2 = this.deltaWidth;
35361
+ this.parent.fitWidth(i2 + s2 * n2, this.keepCenter, this.height === null);
35362
+ }
35363
+ if (this.height !== null) {
35364
+ const i2 = this.startHeight, s2 = this.deltaHeight;
35365
+ this.parent.fitHeight(i2 + s2 * n2, this.keepCenter, this.width === null);
35366
+ }
35367
+ if (this.width === null ? this.parent.scale.x = this.parent.scale.y : this.height === null && (this.parent.scale.y = this.parent.scale.x), !this.keepCenter) {
35368
+ const i2 = this.startX, s2 = this.startY, h2 = this.deltaX, o2 = this.deltaY, r2 = new Point(this.parent.x, this.parent.y);
35369
+ this.parent.moveCenter(i2 + h2 * n2, s2 + o2 * n2), this.parent.emit("moved", { viewport: this.parent, original: r2, type: "animate" });
35370
+ }
35371
+ (this.width || this.height) && this.parent.emit("zoomed", { viewport: this.parent, original: e2, type: "animate" });
35372
+ }
35373
+ }
35374
+ }
35375
+ var Y = {
35376
+ sides: "all",
35377
+ friction: 0.5,
35378
+ time: 150,
35379
+ ease: "easeInOutSine",
35380
+ underflow: "center",
35381
+ bounceBox: null
35382
+ };
35383
+
35384
+ class X extends u2 {
35385
+ constructor(t2, e2 = {}) {
35386
+ super(t2), this.options = Object.assign({}, Y, e2), this.ease = x2(this.options.ease, "easeInOutSine"), this.options.sides ? this.options.sides === "all" ? this.top = this.bottom = this.left = this.right = true : this.options.sides === "horizontal" ? (this.right = this.left = true, this.top = this.bottom = false) : this.options.sides === "vertical" ? (this.left = this.right = false, this.top = this.bottom = true) : (this.top = this.options.sides.indexOf("top") !== -1, this.bottom = this.options.sides.indexOf("bottom") !== -1, this.left = this.options.sides.indexOf("left") !== -1, this.right = this.options.sides.indexOf("right") !== -1) : this.left = this.top = this.right = this.bottom = false;
35387
+ const n2 = this.options.underflow.toLowerCase();
35388
+ n2 === "center" ? (this.underflowX = 0, this.underflowY = 0) : (this.underflowX = n2.indexOf("left") !== -1 ? -1 : n2.indexOf("right") !== -1 ? 1 : 0, this.underflowY = n2.indexOf("top") !== -1 ? -1 : n2.indexOf("bottom") !== -1 ? 1 : 0), this.reset();
35389
+ }
35390
+ isActive() {
35391
+ return this.toX !== null || this.toY !== null;
35392
+ }
35393
+ down() {
35394
+ return this.toX = this.toY = null, false;
35395
+ }
35396
+ up() {
35397
+ return this.bounce(), false;
35398
+ }
35399
+ update(t2) {
35400
+ if (!this.paused) {
35401
+ if (this.bounce(), this.toX) {
35402
+ const e2 = this.toX;
35403
+ e2.time += t2, this.parent.emit("moved", { viewport: this.parent, type: "bounce-x" }), e2.time >= this.options.time ? (this.parent.x = e2.end, this.toX = null, this.parent.emit("bounce-x-end", this.parent)) : this.parent.x = this.ease(e2.time, e2.start, e2.delta, this.options.time);
35404
+ }
35405
+ if (this.toY) {
35406
+ const e2 = this.toY;
35407
+ e2.time += t2, this.parent.emit("moved", { viewport: this.parent, type: "bounce-y" }), e2.time >= this.options.time ? (this.parent.y = e2.end, this.toY = null, this.parent.emit("bounce-y-end", this.parent)) : this.parent.y = this.ease(e2.time, e2.start, e2.delta, this.options.time);
35408
+ }
35409
+ }
35410
+ }
35411
+ calcUnderflowX() {
35412
+ let t2;
35413
+ switch (this.underflowX) {
35414
+ case -1:
35415
+ t2 = 0;
35416
+ break;
35417
+ case 1:
35418
+ t2 = this.parent.screenWidth - this.parent.screenWorldWidth;
35419
+ break;
35420
+ default:
35421
+ t2 = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2;
35422
+ }
35423
+ return t2;
35424
+ }
35425
+ calcUnderflowY() {
35426
+ let t2;
35427
+ switch (this.underflowY) {
35428
+ case -1:
35429
+ t2 = 0;
35430
+ break;
35431
+ case 1:
35432
+ t2 = this.parent.screenHeight - this.parent.screenWorldHeight;
35433
+ break;
35434
+ default:
35435
+ t2 = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2;
35436
+ }
35437
+ return t2;
35438
+ }
35439
+ oob() {
35440
+ const t2 = this.options.bounceBox;
35441
+ if (t2) {
35442
+ const e2 = typeof t2.x > "u" ? 0 : t2.x, n2 = typeof t2.y > "u" ? 0 : t2.y, i2 = typeof t2.width > "u" ? this.parent.worldWidth : t2.width, s2 = typeof t2.height > "u" ? this.parent.worldHeight : t2.height;
35443
+ return {
35444
+ left: this.parent.left < e2,
35445
+ right: this.parent.right > i2,
35446
+ top: this.parent.top < n2,
35447
+ bottom: this.parent.bottom > s2,
35448
+ topLeft: new Point(e2 * this.parent.scale.x, n2 * this.parent.scale.y),
35449
+ bottomRight: new Point(i2 * this.parent.scale.x - this.parent.screenWidth, s2 * this.parent.scale.y - this.parent.screenHeight)
35450
+ };
35451
+ }
35452
+ return {
35453
+ left: this.parent.left < 0,
35454
+ right: this.parent.right > this.parent.worldWidth,
35455
+ top: this.parent.top < 0,
35456
+ bottom: this.parent.bottom > this.parent.worldHeight,
35457
+ topLeft: new Point(0, 0),
35458
+ bottomRight: new Point(this.parent.worldWidth * this.parent.scale.x - this.parent.screenWidth, this.parent.worldHeight * this.parent.scale.y - this.parent.screenHeight)
35459
+ };
35460
+ }
35461
+ bounce() {
35462
+ var s2, h2;
35463
+ if (this.paused)
35464
+ return;
35465
+ let t2, e2 = this.parent.plugins.get("decelerate", true);
35466
+ e2 && (e2.x || e2.y) && (e2.x && e2.percentChangeX === ((s2 = e2.options) == null ? undefined : s2.friction) || e2.y && e2.percentChangeY === ((h2 = e2.options) == null ? undefined : h2.friction)) && (t2 = this.oob(), (t2.left && this.left || t2.right && this.right) && (e2.percentChangeX = this.options.friction), (t2.top && this.top || t2.bottom && this.bottom) && (e2.percentChangeY = this.options.friction));
35467
+ const n2 = this.parent.plugins.get("drag", true) || {}, i2 = this.parent.plugins.get("pinch", true) || {};
35468
+ if (e2 = e2 || {}, !(n2 != null && n2.active) && !(i2 != null && i2.active) && (!this.toX || !this.toY) && (!e2.x || !e2.y)) {
35469
+ t2 = t2 || this.oob();
35470
+ const { topLeft: o2, bottomRight: r2 } = t2;
35471
+ if (!this.toX && !e2.x) {
35472
+ let a2 = null;
35473
+ t2.left && this.left ? a2 = this.parent.screenWorldWidth < this.parent.screenWidth ? this.calcUnderflowX() : -o2.x : t2.right && this.right && (a2 = this.parent.screenWorldWidth < this.parent.screenWidth ? this.calcUnderflowX() : -r2.x), a2 !== null && this.parent.x !== a2 && (this.toX = { time: 0, start: this.parent.x, delta: a2 - this.parent.x, end: a2 }, this.parent.emit("bounce-x-start", this.parent));
35474
+ }
35475
+ if (!this.toY && !e2.y) {
35476
+ let a2 = null;
35477
+ t2.top && this.top ? a2 = this.parent.screenWorldHeight < this.parent.screenHeight ? this.calcUnderflowY() : -o2.y : t2.bottom && this.bottom && (a2 = this.parent.screenWorldHeight < this.parent.screenHeight ? this.calcUnderflowY() : -r2.y), a2 !== null && this.parent.y !== a2 && (this.toY = { time: 0, start: this.parent.y, delta: a2 - this.parent.y, end: a2 }, this.parent.emit("bounce-y-start", this.parent));
35478
+ }
35479
+ }
35480
+ }
35481
+ reset() {
35482
+ this.toX = this.toY = null, this.bounce();
35483
+ }
35484
+ }
35485
+ var z = {
35486
+ left: false,
35487
+ right: false,
35488
+ top: false,
35489
+ bottom: false,
35490
+ direction: null,
35491
+ underflow: "center"
35492
+ };
35493
+
35494
+ class A extends u2 {
35495
+ constructor(t2, e2 = {}) {
35496
+ super(t2), this.options = Object.assign({}, z, e2), this.options.direction && (this.options.left = this.options.direction === "x" || this.options.direction === "all" ? true : null, this.options.right = this.options.direction === "x" || this.options.direction === "all" ? true : null, this.options.top = this.options.direction === "y" || this.options.direction === "all" ? true : null, this.options.bottom = this.options.direction === "y" || this.options.direction === "all" ? true : null), this.parseUnderflow(), this.last = { x: null, y: null, scaleX: null, scaleY: null }, this.update();
35497
+ }
35498
+ parseUnderflow() {
35499
+ const t2 = this.options.underflow.toLowerCase();
35500
+ t2 === "none" ? this.noUnderflow = true : t2 === "center" ? (this.underflowX = this.underflowY = 0, this.noUnderflow = false) : (this.underflowX = t2.indexOf("left") !== -1 ? -1 : t2.indexOf("right") !== -1 ? 1 : 0, this.underflowY = t2.indexOf("top") !== -1 ? -1 : t2.indexOf("bottom") !== -1 ? 1 : 0, this.noUnderflow = false);
35501
+ }
35502
+ move() {
35503
+ return this.update(), false;
35504
+ }
35505
+ update() {
35506
+ if (this.paused || this.parent.x === this.last.x && this.parent.y === this.last.y && this.parent.scale.x === this.last.scaleX && this.parent.scale.y === this.last.scaleY)
35507
+ return;
35508
+ const t2 = new Point(this.parent.x, this.parent.y), e2 = this.parent.plugins.decelerate || {};
35509
+ if (this.options.left !== null || this.options.right !== null) {
35510
+ let n2 = false;
35511
+ if (!this.noUnderflow && this.parent.screenWorldWidth < this.parent.screenWidth)
35512
+ switch (this.underflowX) {
35513
+ case -1:
35514
+ this.parent.x !== 0 && (this.parent.x = 0, n2 = true);
35515
+ break;
35516
+ case 1:
35517
+ this.parent.x !== this.parent.screenWidth - this.parent.screenWorldWidth && (this.parent.x = this.parent.screenWidth - this.parent.screenWorldWidth, n2 = true);
35518
+ break;
35519
+ default:
35520
+ this.parent.x !== (this.parent.screenWidth - this.parent.screenWorldWidth) / 2 && (this.parent.x = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2, n2 = true);
35521
+ }
35522
+ else
35523
+ this.options.left !== null && this.parent.left < (this.options.left === true ? 0 : this.options.left) && (this.parent.x = -(this.options.left === true ? 0 : this.options.left) * this.parent.scale.x, e2.x = 0, n2 = true), this.options.right !== null && this.parent.right > (this.options.right === true ? this.parent.worldWidth : this.options.right) && (this.parent.x = -(this.options.right === true ? this.parent.worldWidth : this.options.right) * this.parent.scale.x + this.parent.screenWidth, e2.x = 0, n2 = true);
35524
+ n2 && this.parent.emit("moved", {
35525
+ viewport: this.parent,
35526
+ original: t2,
35527
+ type: "clamp-x"
35528
+ });
35529
+ }
35530
+ if (this.options.top !== null || this.options.bottom !== null) {
35531
+ let n2 = false;
35532
+ if (!this.noUnderflow && this.parent.screenWorldHeight < this.parent.screenHeight)
35533
+ switch (this.underflowY) {
35534
+ case -1:
35535
+ this.parent.y !== 0 && (this.parent.y = 0, n2 = true);
35536
+ break;
35537
+ case 1:
35538
+ this.parent.y !== this.parent.screenHeight - this.parent.screenWorldHeight && (this.parent.y = this.parent.screenHeight - this.parent.screenWorldHeight, n2 = true);
35539
+ break;
35540
+ default:
35541
+ this.parent.y !== (this.parent.screenHeight - this.parent.screenWorldHeight) / 2 && (this.parent.y = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2, n2 = true);
35542
+ }
35543
+ else
35544
+ this.options.top !== null && this.parent.top < (this.options.top === true ? 0 : this.options.top) && (this.parent.y = -(this.options.top === true ? 0 : this.options.top) * this.parent.scale.y, e2.y = 0, n2 = true), this.options.bottom !== null && this.parent.bottom > (this.options.bottom === true ? this.parent.worldHeight : this.options.bottom) && (this.parent.y = -(this.options.bottom === true ? this.parent.worldHeight : this.options.bottom) * this.parent.scale.y + this.parent.screenHeight, e2.y = 0, n2 = true);
35545
+ n2 && this.parent.emit("moved", {
35546
+ viewport: this.parent,
35547
+ original: t2,
35548
+ type: "clamp-y"
35549
+ });
35550
+ }
35551
+ this.last.x = this.parent.x, this.last.y = this.parent.y, this.last.scaleX = this.parent.scale.x, this.last.scaleY = this.parent.scale.y;
35552
+ }
35553
+ reset() {
35554
+ this.update();
35555
+ }
35556
+ }
35557
+ var T = {
35558
+ minWidth: null,
35559
+ minHeight: null,
35560
+ maxWidth: null,
35561
+ maxHeight: null,
35562
+ minScale: null,
35563
+ maxScale: null
35564
+ };
35565
+
35566
+ class _ extends u2 {
35567
+ constructor(t2, e2 = {}) {
35568
+ super(t2), this.options = Object.assign({}, T, e2), this.clamp();
35569
+ }
35570
+ resize() {
35571
+ this.clamp();
35572
+ }
35573
+ clamp() {
35574
+ if (!this.paused) {
35575
+ if (this.options.minWidth || this.options.minHeight || this.options.maxWidth || this.options.maxHeight) {
35576
+ let t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight;
35577
+ if (this.options.minWidth !== null && t2 < this.options.minWidth) {
35578
+ const n2 = this.parent.scale.x;
35579
+ this.parent.fitWidth(this.options.minWidth, false, false, true), this.parent.scale.y *= this.parent.scale.x / n2, t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
35580
+ }
35581
+ if (this.options.maxWidth !== null && t2 > this.options.maxWidth) {
35582
+ const n2 = this.parent.scale.x;
35583
+ this.parent.fitWidth(this.options.maxWidth, false, false, true), this.parent.scale.y *= this.parent.scale.x / n2, t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
35584
+ }
35585
+ if (this.options.minHeight !== null && e2 < this.options.minHeight) {
35586
+ const n2 = this.parent.scale.y;
35587
+ this.parent.fitHeight(this.options.minHeight, false, false, true), this.parent.scale.x *= this.parent.scale.y / n2, t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
35588
+ }
35589
+ if (this.options.maxHeight !== null && e2 > this.options.maxHeight) {
35590
+ const n2 = this.parent.scale.y;
35591
+ this.parent.fitHeight(this.options.maxHeight, false, false, true), this.parent.scale.x *= this.parent.scale.y / n2, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
35592
+ }
35593
+ } else if (this.options.minScale || this.options.maxScale) {
35594
+ const t2 = { x: null, y: null }, e2 = { x: null, y: null };
35595
+ if (typeof this.options.minScale == "number")
35596
+ t2.x = this.options.minScale, t2.y = this.options.minScale;
35597
+ else if (this.options.minScale !== null) {
35598
+ const s2 = this.options.minScale;
35599
+ t2.x = typeof s2.x > "u" ? null : s2.x, t2.y = typeof s2.y > "u" ? null : s2.y;
35600
+ }
35601
+ if (typeof this.options.maxScale == "number")
35602
+ e2.x = this.options.maxScale, e2.y = this.options.maxScale;
35603
+ else if (this.options.maxScale !== null) {
35604
+ const s2 = this.options.maxScale;
35605
+ e2.x = typeof s2.x > "u" ? null : s2.x, e2.y = typeof s2.y > "u" ? null : s2.y;
35606
+ }
35607
+ let n2 = this.parent.scale.x, i2 = this.parent.scale.y;
35608
+ t2.x !== null && n2 < t2.x && (n2 = t2.x), e2.x !== null && n2 > e2.x && (n2 = e2.x), t2.y !== null && i2 < t2.y && (i2 = t2.y), e2.y !== null && i2 > e2.y && (i2 = e2.y), (n2 !== this.parent.scale.x || i2 !== this.parent.scale.y) && (this.parent.scale.set(n2, i2), this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" }));
35609
+ }
35610
+ }
35611
+ }
35612
+ reset() {
35613
+ this.clamp();
35614
+ }
35615
+ }
35616
+ var L = {
35617
+ friction: 0.98,
35618
+ bounce: 0.8,
35619
+ minSpeed: 0.01
35620
+ };
35621
+ var d2 = 16;
35622
+
35623
+ class E extends u2 {
35624
+ constructor(t2, e2 = {}) {
35625
+ super(t2), this.options = Object.assign({}, L, e2), this.saved = [], this.timeSinceRelease = 0, this.reset(), this.parent.on("moved", (n2) => this.handleMoved(n2));
35626
+ }
35627
+ down() {
35628
+ return this.saved = [], this.x = this.y = null, false;
35629
+ }
35630
+ isActive() {
35631
+ return !!(this.x || this.y);
35632
+ }
35633
+ move() {
35634
+ if (this.paused)
35635
+ return false;
35636
+ const t2 = this.parent.input.count();
35637
+ return (t2 === 1 || t2 > 1 && !this.parent.plugins.get("pinch", true)) && (this.saved.push({ x: this.parent.x, y: this.parent.y, time: performance.now() }), this.saved.length > 60 && this.saved.splice(0, 30)), false;
35638
+ }
35639
+ handleMoved(t2) {
35640
+ if (this.saved.length) {
35641
+ const e2 = this.saved[this.saved.length - 1];
35642
+ t2.type === "clamp-x" && t2.original ? e2.x === t2.original.x && (e2.x = this.parent.x) : t2.type === "clamp-y" && t2.original && e2.y === t2.original.y && (e2.y = this.parent.y);
35643
+ }
35644
+ }
35645
+ up() {
35646
+ if (this.parent.input.count() === 0 && this.saved.length) {
35647
+ const t2 = performance.now();
35648
+ for (const e2 of this.saved)
35649
+ if (e2.time >= t2 - 100) {
35650
+ const n2 = t2 - e2.time;
35651
+ this.x = (this.parent.x - e2.x) / n2, this.y = (this.parent.y - e2.y) / n2, this.percentChangeX = this.percentChangeY = this.options.friction, this.timeSinceRelease = 0;
35652
+ break;
35653
+ }
35654
+ }
35655
+ return false;
35656
+ }
35657
+ activate(t2) {
35658
+ t2 = t2 || {}, typeof t2.x < "u" && (this.x = t2.x, this.percentChangeX = this.options.friction), typeof t2.y < "u" && (this.y = t2.y, this.percentChangeY = this.options.friction);
35659
+ }
35660
+ update(t2) {
35661
+ if (this.paused)
35662
+ return;
35663
+ const e2 = this.x || this.y, n2 = this.timeSinceRelease, i2 = this.timeSinceRelease + t2;
35664
+ if (this.x) {
35665
+ const s2 = this.percentChangeX, h2 = Math.log(s2);
35666
+ this.parent.x += this.x * d2 / h2 * (Math.pow(s2, i2 / d2) - Math.pow(s2, n2 / d2)), this.x *= Math.pow(this.percentChangeX, t2 / d2);
35667
+ }
35668
+ if (this.y) {
35669
+ const s2 = this.percentChangeY, h2 = Math.log(s2);
35670
+ this.parent.y += this.y * d2 / h2 * (Math.pow(s2, i2 / d2) - Math.pow(s2, n2 / d2)), this.y *= Math.pow(this.percentChangeY, t2 / d2);
35671
+ }
35672
+ this.timeSinceRelease += t2, this.x && this.y ? Math.abs(this.x) < this.options.minSpeed && Math.abs(this.y) < this.options.minSpeed && (this.x = 0, this.y = 0) : (Math.abs(this.x || 0) < this.options.minSpeed && (this.x = 0), Math.abs(this.y || 0) < this.options.minSpeed && (this.y = 0)), e2 && this.parent.emit("moved", { viewport: this.parent, type: "decelerate" });
35673
+ }
35674
+ reset() {
35675
+ this.x = this.y = null;
35676
+ }
35677
+ }
35678
+ var D = {
35679
+ direction: "all",
35680
+ pressDrag: true,
35681
+ wheel: true,
35682
+ wheelScroll: 1,
35683
+ reverse: false,
35684
+ clampWheel: false,
35685
+ underflow: "center",
35686
+ factor: 1,
35687
+ mouseButtons: "all",
35688
+ keyToPress: null,
35689
+ ignoreKeyToPressOnTouch: false,
35690
+ lineHeight: 20,
35691
+ wheelSwapAxes: false
35692
+ };
35693
+
35694
+ class U extends u2 {
35695
+ constructor(t2, e2 = {}) {
35696
+ super(t2), this.windowEventHandlers = [], this.options = Object.assign({}, D, e2), this.moved = false, this.reverse = this.options.reverse ? 1 : -1, this.xDirection = !this.options.direction || this.options.direction === "all" || this.options.direction === "x", this.yDirection = !this.options.direction || this.options.direction === "all" || this.options.direction === "y", this.keyIsPressed = false, this.parseUnderflow(), this.mouseButtons(this.options.mouseButtons), this.options.keyToPress && this.handleKeyPresses(this.options.keyToPress);
35697
+ }
35698
+ handleKeyPresses(t2) {
35699
+ const e2 = (i2) => {
35700
+ t2.includes(i2.code) && (this.keyIsPressed = true);
35701
+ }, n2 = (i2) => {
35702
+ t2.includes(i2.code) && (this.keyIsPressed = false);
35703
+ };
35704
+ this.addWindowEventHandler("keyup", n2), this.addWindowEventHandler("keydown", e2);
35705
+ }
35706
+ addWindowEventHandler(t2, e2) {
35707
+ typeof window > "u" || (window.addEventListener(t2, e2), this.windowEventHandlers.push({ event: t2, handler: e2 }));
35708
+ }
35709
+ destroy() {
35710
+ typeof window > "u" || this.windowEventHandlers.forEach(({ event: t2, handler: e2 }) => {
35711
+ window.removeEventListener(t2, e2);
35712
+ });
35713
+ }
35714
+ mouseButtons(t2) {
35715
+ !t2 || t2 === "all" ? this.mouse = [true, true, true] : this.mouse = [
35716
+ t2.indexOf("left") !== -1,
35717
+ t2.indexOf("middle") !== -1,
35718
+ t2.indexOf("right") !== -1
35719
+ ];
35720
+ }
35721
+ parseUnderflow() {
35722
+ const t2 = this.options.underflow.toLowerCase();
35723
+ t2 === "center" ? (this.underflowX = 0, this.underflowY = 0) : (t2.includes("left") ? this.underflowX = -1 : t2.includes("right") ? this.underflowX = 1 : this.underflowX = 0, t2.includes("top") ? this.underflowY = -1 : t2.includes("bottom") ? this.underflowY = 1 : this.underflowY = 0);
35724
+ }
35725
+ checkButtons(t2) {
35726
+ const e2 = t2.pointerType === "mouse", n2 = this.parent.input.count();
35727
+ return !!((n2 === 1 || n2 > 1 && !this.parent.plugins.get("pinch", true)) && (!e2 || this.mouse[t2.button]));
35728
+ }
35729
+ checkKeyPress(t2) {
35730
+ return !this.options.keyToPress || this.keyIsPressed || this.options.ignoreKeyToPressOnTouch && t2.data.pointerType === "touch";
35731
+ }
35732
+ down(t2) {
35733
+ return this.paused || !this.options.pressDrag ? false : this.checkButtons(t2) && this.checkKeyPress(t2) ? (this.last = { x: t2.global.x, y: t2.global.y }, (this.parent.parent || this.parent).toLocal(this.last, undefined, this.last), this.current = t2.pointerId, true) : (this.last = null, false);
35734
+ }
35735
+ get active() {
35736
+ return this.moved;
35737
+ }
35738
+ move(t2) {
35739
+ if (this.paused || !this.options.pressDrag)
35740
+ return false;
35741
+ if (this.last && this.current === t2.data.pointerId) {
35742
+ const e2 = t2.global.x, n2 = t2.global.y, i2 = this.parent.input.count();
35743
+ if (i2 === 1 || i2 > 1 && !this.parent.plugins.get("pinch", true)) {
35744
+ const s2 = { x: e2, y: n2 };
35745
+ (this.parent.parent || this.parent).toLocal(s2, undefined, s2);
35746
+ const h2 = s2.x - this.last.x, o2 = s2.y - this.last.y;
35747
+ if (this.moved || this.xDirection && this.parent.input.checkThreshold(h2) || this.yDirection && this.parent.input.checkThreshold(o2))
35748
+ return this.xDirection && (this.parent.x += (s2.x - this.last.x) * this.options.factor), this.yDirection && (this.parent.y += (s2.y - this.last.y) * this.options.factor), this.last = s2, this.moved || this.parent.emit("drag-start", {
35749
+ event: t2,
35750
+ screen: new Point(this.last.x, this.last.y),
35751
+ world: this.parent.toWorld(new Point(this.last.x, this.last.y)),
35752
+ viewport: this.parent
35753
+ }), this.moved = true, this.parent.emit("moved", { viewport: this.parent, type: "drag" }), true;
35754
+ } else
35755
+ this.moved = false;
35756
+ }
35757
+ return false;
35758
+ }
35759
+ up(t2) {
35760
+ if (this.paused)
35761
+ return false;
35762
+ const e2 = this.parent.input.touches;
35763
+ if (e2.length === 1) {
35764
+ const n2 = e2[0];
35765
+ return n2.last && (this.last = { x: n2.last.x, y: n2.last.y }, this.current = n2.id), this.moved = false, true;
35766
+ } else if (this.last && this.moved) {
35767
+ const n2 = new Point(this.last.x, this.last.y);
35768
+ return (this.parent.parent || this.parent).toGlobal(n2, n2, true), this.parent.emit("drag-end", {
35769
+ event: t2,
35770
+ screen: n2,
35771
+ world: this.parent.toWorld(n2),
35772
+ viewport: this.parent
35773
+ }), this.last = null, this.moved = false, true;
35774
+ }
35775
+ return false;
35776
+ }
35777
+ wheel(t2) {
35778
+ if (this.paused)
35779
+ return false;
35780
+ if (this.options.wheel) {
35781
+ const e2 = this.parent.plugins.get("wheel", true);
35782
+ if (!e2 || !e2.options.wheelZoom && !t2.ctrlKey) {
35783
+ const n2 = t2.deltaMode ? this.options.lineHeight : 1, i2 = [t2.deltaX, t2.deltaY], [s2, h2] = this.options.wheelSwapAxes ? i2.reverse() : i2;
35784
+ return this.xDirection && (this.parent.x += s2 * n2 * this.options.wheelScroll * this.reverse), this.yDirection && (this.parent.y += h2 * n2 * this.options.wheelScroll * this.reverse), this.options.clampWheel && this.clamp(), this.parent.emit("wheel-scroll", this.parent), this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.parent.options.passiveWheel || t2.preventDefault(), this.parent.options.stopPropagation && t2.stopPropagation(), true;
35785
+ }
35786
+ }
35787
+ return false;
35788
+ }
35789
+ resume() {
35790
+ this.last = null, this.paused = false;
35791
+ }
35792
+ clamp() {
35793
+ const t2 = this.parent.plugins.get("decelerate", true) || {};
35794
+ if (this.options.clampWheel !== "y")
35795
+ if (this.parent.screenWorldWidth < this.parent.screenWidth)
35796
+ switch (this.underflowX) {
35797
+ case -1:
35798
+ this.parent.x = 0;
35799
+ break;
35800
+ case 1:
35801
+ this.parent.x = this.parent.screenWidth - this.parent.screenWorldWidth;
35802
+ break;
35803
+ default:
35804
+ this.parent.x = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2;
35805
+ }
35806
+ else
35807
+ this.parent.left < 0 ? (this.parent.x = 0, t2.x = 0) : this.parent.right > this.parent.worldWidth && (this.parent.x = -this.parent.worldWidth * this.parent.scale.x + this.parent.screenWidth, t2.x = 0);
35808
+ if (this.options.clampWheel !== "x")
35809
+ if (this.parent.screenWorldHeight < this.parent.screenHeight)
35810
+ switch (this.underflowY) {
35811
+ case -1:
35812
+ this.parent.y = 0;
35813
+ break;
35814
+ case 1:
35815
+ this.parent.y = this.parent.screenHeight - this.parent.screenWorldHeight;
35816
+ break;
35817
+ default:
35818
+ this.parent.y = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2;
35819
+ }
35820
+ else
35821
+ this.parent.top < 0 && (this.parent.y = 0, t2.y = 0), this.parent.bottom > this.parent.worldHeight && (this.parent.y = -this.parent.worldHeight * this.parent.scale.y + this.parent.screenHeight, t2.y = 0);
35822
+ }
35823
+ }
35824
+ var F = {
35825
+ speed: 0,
35826
+ acceleration: null,
35827
+ radius: null
35828
+ };
35829
+
35830
+ class B extends u2 {
35831
+ constructor(t2, e2, n2 = {}) {
35832
+ super(t2), this.target = e2, this.options = Object.assign({}, F, n2), this.velocity = { x: 0, y: 0 };
35833
+ }
35834
+ update(t2) {
35835
+ if (this.paused)
35836
+ return;
35837
+ const e2 = this.parent.center;
35838
+ let n2 = this.target.x, i2 = this.target.y;
35839
+ if (this.options.radius)
35840
+ if (Math.sqrt(Math.pow(this.target.y - e2.y, 2) + Math.pow(this.target.x - e2.x, 2)) > this.options.radius) {
35841
+ const r2 = Math.atan2(this.target.y - e2.y, this.target.x - e2.x);
35842
+ n2 = this.target.x - Math.cos(r2) * this.options.radius, i2 = this.target.y - Math.sin(r2) * this.options.radius;
35843
+ } else
35844
+ return;
35845
+ const s2 = n2 - e2.x, h2 = i2 - e2.y;
35846
+ if (s2 || h2)
35847
+ if (this.options.speed)
35848
+ if (this.options.acceleration) {
35849
+ const o2 = Math.atan2(i2 - e2.y, n2 - e2.x), r2 = Math.sqrt(Math.pow(s2, 2) + Math.pow(h2, 2));
35850
+ if (r2) {
35851
+ const a2 = (Math.pow(this.velocity.x, 2) + Math.pow(this.velocity.y, 2)) / (2 * this.options.acceleration);
35852
+ r2 > a2 ? this.velocity = {
35853
+ x: Math.min(this.velocity.x + (this.options.acceleration * t2, this.options.speed)),
35854
+ y: Math.min(this.velocity.y + (this.options.acceleration * t2, this.options.speed))
35855
+ } : this.velocity = {
35856
+ x: Math.max(this.velocity.x - this.options.acceleration * this.options.speed, 0),
35857
+ y: Math.max(this.velocity.y - this.options.acceleration * this.options.speed, 0)
35858
+ };
35859
+ const p2 = Math.cos(o2) * this.velocity.x, f2 = Math.sin(o2) * this.velocity.y, g2 = Math.abs(p2) > Math.abs(s2) ? n2 : e2.x + p2, w2 = Math.abs(f2) > Math.abs(h2) ? i2 : e2.y + f2;
35860
+ this.parent.moveCenter(g2, w2), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
35861
+ }
35862
+ } else {
35863
+ const o2 = Math.atan2(i2 - e2.y, n2 - e2.x), r2 = Math.cos(o2) * this.options.speed, a2 = Math.sin(o2) * this.options.speed, p2 = Math.abs(r2) > Math.abs(s2) ? n2 : e2.x + r2, f2 = Math.abs(a2) > Math.abs(h2) ? i2 : e2.y + a2;
35864
+ this.parent.moveCenter(p2, f2), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
35865
+ }
35866
+ else
35867
+ this.parent.moveCenter(n2, i2), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
35868
+ }
35869
+ }
35870
+ var N2 = {
35871
+ radius: null,
35872
+ distance: null,
35873
+ top: null,
35874
+ bottom: null,
35875
+ left: null,
35876
+ right: null,
35877
+ speed: 8,
35878
+ reverse: false,
35879
+ noDecelerate: false,
35880
+ linear: false,
35881
+ allowButtons: false
35882
+ };
35883
+
35884
+ class V extends u2 {
35885
+ constructor(t2, e2 = {}) {
35886
+ super(t2), this.options = Object.assign({}, N2, e2), this.reverse = this.options.reverse ? 1 : -1, this.radiusSquared = typeof this.options.radius == "number" ? Math.pow(this.options.radius, 2) : null, this.resize();
35887
+ }
35888
+ resize() {
35889
+ const t2 = this.options.distance;
35890
+ t2 !== null ? (this.left = t2, this.top = t2, this.right = this.parent.screenWidth - t2, this.bottom = this.parent.screenHeight - t2) : this.options.radius || (this.left = this.options.left, this.top = this.options.top, this.right = this.options.right === null ? null : this.parent.screenWidth - this.options.right, this.bottom = this.options.bottom === null ? null : this.parent.screenHeight - this.options.bottom);
35891
+ }
35892
+ down() {
35893
+ return this.paused || this.options.allowButtons || (this.horizontal = this.vertical = null), false;
35894
+ }
35895
+ move(t2) {
35896
+ if (this.paused || t2.pointerType !== "mouse" && t2.pointerId !== 1 || !this.options.allowButtons && t2.buttons !== 0)
35897
+ return false;
35898
+ const e2 = t2.global.x, n2 = t2.global.y;
35899
+ if (this.radiusSquared) {
35900
+ const i2 = this.parent.toScreen(this.parent.center);
35901
+ if (Math.pow(i2.x - e2, 2) + Math.pow(i2.y - n2, 2) >= this.radiusSquared) {
35902
+ const h2 = Math.atan2(i2.y - n2, i2.x - e2);
35903
+ this.options.linear ? (this.horizontal = Math.round(Math.cos(h2)) * this.options.speed * this.reverse * (60 / 1000), this.vertical = Math.round(Math.sin(h2)) * this.options.speed * this.reverse * (60 / 1000)) : (this.horizontal = Math.cos(h2) * this.options.speed * this.reverse * (60 / 1000), this.vertical = Math.sin(h2) * this.options.speed * this.reverse * (60 / 1000));
35904
+ } else
35905
+ this.horizontal && this.decelerateHorizontal(), this.vertical && this.decelerateVertical(), this.horizontal = this.vertical = 0;
35906
+ } else
35907
+ this.left !== null && e2 < this.left ? this.horizontal = Number(this.reverse) * this.options.speed * (60 / 1000) : this.right !== null && e2 > this.right ? this.horizontal = -1 * this.reverse * this.options.speed * (60 / 1000) : (this.decelerateHorizontal(), this.horizontal = 0), this.top !== null && n2 < this.top ? this.vertical = Number(this.reverse) * this.options.speed * (60 / 1000) : this.bottom !== null && n2 > this.bottom ? this.vertical = -1 * this.reverse * this.options.speed * (60 / 1000) : (this.decelerateVertical(), this.vertical = 0);
35908
+ return false;
35909
+ }
35910
+ decelerateHorizontal() {
35911
+ const t2 = this.parent.plugins.get("decelerate", true);
35912
+ this.horizontal && t2 && !this.options.noDecelerate && t2.activate({ x: this.horizontal * this.options.speed * this.reverse / (1000 / 60) });
35913
+ }
35914
+ decelerateVertical() {
35915
+ const t2 = this.parent.plugins.get("decelerate", true);
35916
+ this.vertical && t2 && !this.options.noDecelerate && t2.activate({ y: this.vertical * this.options.speed * this.reverse / (1000 / 60) });
35917
+ }
35918
+ up() {
35919
+ return this.paused || (this.horizontal && this.decelerateHorizontal(), this.vertical && this.decelerateVertical(), this.horizontal = this.vertical = null), false;
35920
+ }
35921
+ update() {
35922
+ if (!this.paused && (this.horizontal || this.vertical)) {
35923
+ const t2 = this.parent.center;
35924
+ this.horizontal && (t2.x += this.horizontal * this.options.speed), this.vertical && (t2.y += this.vertical * this.options.speed), this.parent.moveCenter(t2), this.parent.emit("moved", { viewport: this.parent, type: "mouse-edges" });
35925
+ }
35926
+ }
35927
+ }
35928
+ var Z = {
35929
+ noDrag: false,
35930
+ percent: 1,
35931
+ center: null,
35932
+ factor: 1,
35933
+ axis: "all"
35934
+ };
35935
+ var R = new Point;
35936
+
35937
+ class j2 extends u2 {
35938
+ constructor(t2, e2 = {}) {
35939
+ super(t2), this.active = false, this.pinching = false, this.moved = false, this.options = Object.assign({}, Z, e2);
35940
+ }
35941
+ down() {
35942
+ return this.parent.input.count() >= 2 ? (this.active = true, true) : false;
35943
+ }
35944
+ isAxisX() {
35945
+ return ["all", "x"].includes(this.options.axis);
35946
+ }
35947
+ isAxisY() {
35948
+ return ["all", "y"].includes(this.options.axis);
35949
+ }
35950
+ move(t2) {
35951
+ if (this.paused || !this.active)
35952
+ return false;
35953
+ const { x: e2, y: n2 } = (this.parent.parent || this.parent).toLocal(t2.global, undefined, R), i2 = this.parent.input.touches;
35954
+ if (i2.length >= 2) {
35955
+ const s2 = i2[0], h2 = i2[1], o2 = s2.last && h2.last ? Math.sqrt(Math.pow(h2.last.x - s2.last.x, 2) + Math.pow(h2.last.y - s2.last.y, 2)) : null;
35956
+ if (s2.id === t2.pointerId ? s2.last = { x: e2, y: n2, data: t2 } : h2.id === t2.pointerId && (h2.last = { x: e2, y: n2, data: t2 }), o2) {
35957
+ let r2;
35958
+ const a2 = new Point(s2.last.x + (h2.last.x - s2.last.x) / 2, s2.last.y + (h2.last.y - s2.last.y) / 2);
35959
+ this.options.center || (r2 = this.parent.toLocal(a2, this.parent.parent || this.parent));
35960
+ let p2 = Math.sqrt(Math.pow(h2.last.x - s2.last.x, 2) + Math.pow(h2.last.y - s2.last.y, 2));
35961
+ p2 = p2 === 0 ? p2 = 0.0000000001 : p2;
35962
+ const f2 = (1 - o2 / p2) * this.options.percent * (this.isAxisX() ? this.parent.scale.x : this.parent.scale.y);
35963
+ this.isAxisX() && (this.parent.scale.x += f2), this.isAxisY() && (this.parent.scale.y += f2), this.parent.emit("zoomed", {
35964
+ viewport: this.parent,
35965
+ type: "pinch",
35966
+ center: a2
35967
+ });
35968
+ const g2 = this.parent.plugins.get("clamp-zoom", true);
35969
+ if (g2 && g2.clamp(), this.options.center)
35970
+ this.parent.moveCenter(this.options.center);
35971
+ else {
35972
+ const w2 = (this.parent.parent || this.parent).toLocal(r2, this.parent);
35973
+ this.parent.x += (a2.x - w2.x) * this.options.factor, this.parent.y += (a2.y - w2.y) * this.options.factor, this.parent.emit("moved", { viewport: this.parent, type: "pinch" });
35974
+ }
35975
+ !this.options.noDrag && this.lastCenter && (this.parent.x += (a2.x - this.lastCenter.x) * this.options.factor, this.parent.y += (a2.y - this.lastCenter.y) * this.options.factor, this.parent.emit("moved", { viewport: this.parent, type: "pinch" })), this.lastCenter = a2, this.moved = true;
35976
+ } else
35977
+ this.pinching || (this.parent.emit("pinch-start", this.parent), this.pinching = true);
35978
+ return true;
35979
+ }
35980
+ return false;
35981
+ }
35982
+ up() {
35983
+ return this.pinching && this.parent.input.touches.length <= 1 ? (this.active = false, this.lastCenter = null, this.pinching = false, this.moved = false, this.parent.emit("pinch-end", this.parent), true) : false;
35984
+ }
35985
+ }
35986
+ var K = {
35987
+ topLeft: false,
35988
+ friction: 0.8,
35989
+ time: 1000,
35990
+ ease: "easeInOutSine",
35991
+ interrupt: true,
35992
+ removeOnComplete: false,
35993
+ removeOnInterrupt: false,
35994
+ forceStart: false
35995
+ };
35996
+
35997
+ class q extends u2 {
35998
+ constructor(t2, e2, n2, i2 = {}) {
35999
+ super(t2), this.options = Object.assign({}, K, i2), this.ease = x2(i2.ease, "easeInOutSine"), this.x = e2, this.y = n2, this.options.forceStart && this.snapStart();
36000
+ }
36001
+ snapStart() {
36002
+ this.percent = 0, this.snapping = { time: 0 };
36003
+ const t2 = this.options.topLeft ? this.parent.corner : this.parent.center;
36004
+ this.deltaX = this.x - t2.x, this.deltaY = this.y - t2.y, this.startX = t2.x, this.startY = t2.y, this.parent.emit("snap-start", this.parent);
36005
+ }
36006
+ wheel() {
36007
+ return this.options.removeOnInterrupt && this.parent.plugins.remove("snap"), false;
36008
+ }
36009
+ down() {
36010
+ return this.options.removeOnInterrupt ? this.parent.plugins.remove("snap") : this.options.interrupt && (this.snapping = null), false;
36011
+ }
36012
+ up() {
36013
+ if (this.parent.input.count() === 0) {
36014
+ const t2 = this.parent.plugins.get("decelerate", true);
36015
+ t2 && (t2.x || t2.y) && (t2.percentChangeX = t2.percentChangeY = this.options.friction);
36016
+ }
36017
+ return false;
36018
+ }
36019
+ update(t2) {
36020
+ if (!this.paused && !(this.options.interrupt && this.parent.input.count() !== 0))
36021
+ if (this.snapping) {
36022
+ const e2 = this.snapping;
36023
+ e2.time += t2;
36024
+ let n2, i2, s2;
36025
+ const h2 = this.startX, o2 = this.startY, r2 = this.deltaX, a2 = this.deltaY;
36026
+ if (e2.time > this.options.time)
36027
+ n2 = true, i2 = h2 + r2, s2 = o2 + a2;
36028
+ else {
36029
+ const p2 = this.ease(e2.time, 0, 1, this.options.time);
36030
+ i2 = h2 + r2 * p2, s2 = o2 + a2 * p2;
36031
+ }
36032
+ this.options.topLeft ? this.parent.moveCorner(i2, s2) : this.parent.moveCenter(i2, s2), this.parent.emit("moved", { viewport: this.parent, type: "snap" }), n2 && (this.options.removeOnComplete && this.parent.plugins.remove("snap"), this.parent.emit("snap-end", this.parent), this.snapping = null);
36033
+ } else {
36034
+ const e2 = this.options.topLeft ? this.parent.corner : this.parent.center;
36035
+ (e2.x !== this.x || e2.y !== this.y) && this.snapStart();
36036
+ }
36037
+ }
36038
+ }
36039
+ var Q = {
36040
+ width: 0,
36041
+ height: 0,
36042
+ time: 1000,
36043
+ ease: "easeInOutSine",
36044
+ center: null,
36045
+ interrupt: true,
36046
+ removeOnComplete: false,
36047
+ removeOnInterrupt: false,
36048
+ forceStart: false,
36049
+ noMove: false
36050
+ };
36051
+
36052
+ class G extends u2 {
36053
+ constructor(t2, e2 = {}) {
36054
+ super(t2), this.options = Object.assign({}, Q, e2), this.ease = x2(this.options.ease), this.xIndependent = false, this.yIndependent = false, this.xScale = 0, this.yScale = 0, this.options.width > 0 && (this.xScale = t2.screenWidth / this.options.width, this.xIndependent = true), this.options.height > 0 && (this.yScale = t2.screenHeight / this.options.height, this.yIndependent = true), this.xScale = this.xIndependent ? this.xScale : this.yScale, this.yScale = this.yIndependent ? this.yScale : this.xScale, this.options.time === 0 ? (t2.container.scale.x = this.xScale, t2.container.scale.y = this.yScale, this.options.removeOnComplete && this.parent.plugins.remove("snap-zoom")) : e2.forceStart && this.createSnapping();
36055
+ }
36056
+ createSnapping() {
36057
+ const t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight, n2 = this.parent.screenWidth / this.xScale, i2 = this.parent.screenHeight / this.yScale;
36058
+ this.snapping = {
36059
+ time: 0,
36060
+ startX: t2,
36061
+ startY: e2,
36062
+ deltaX: n2 - t2,
36063
+ deltaY: i2 - e2
36064
+ }, this.parent.emit("snap-zoom-start", this.parent);
36065
+ }
36066
+ resize() {
36067
+ this.snapping = null, this.options.width > 0 && (this.xScale = this.parent.screenWidth / this.options.width), this.options.height > 0 && (this.yScale = this.parent.screenHeight / this.options.height), this.xScale = this.xIndependent ? this.xScale : this.yScale, this.yScale = this.yIndependent ? this.yScale : this.xScale;
36068
+ }
36069
+ wheel() {
36070
+ return this.options.removeOnInterrupt && this.parent.plugins.remove("snap-zoom"), false;
36071
+ }
36072
+ down() {
36073
+ return this.options.removeOnInterrupt ? this.parent.plugins.remove("snap-zoom") : this.options.interrupt && (this.snapping = null), false;
36074
+ }
36075
+ update(t2) {
36076
+ if (this.paused || this.options.interrupt && this.parent.input.count() !== 0)
36077
+ return;
36078
+ let e2;
36079
+ if (!this.options.center && !this.options.noMove && (e2 = this.parent.center), !this.snapping)
36080
+ (this.parent.scale.x !== this.xScale || this.parent.scale.y !== this.yScale) && this.createSnapping();
36081
+ else if (this.snapping) {
36082
+ const n2 = this.snapping;
36083
+ if (n2.time += t2, n2.time >= this.options.time)
36084
+ this.parent.scale.set(this.xScale, this.yScale), this.options.removeOnComplete && this.parent.plugins.remove("snap-zoom"), this.parent.emit("snap-zoom-end", this.parent), this.snapping = null;
36085
+ else {
36086
+ const s2 = this.snapping, h2 = this.ease(s2.time, s2.startX, s2.deltaX, this.options.time), o2 = this.ease(s2.time, s2.startY, s2.deltaY, this.options.time);
36087
+ this.parent.scale.x = this.parent.screenWidth / h2, this.parent.scale.y = this.parent.screenHeight / o2;
36088
+ }
36089
+ const i2 = this.parent.plugins.get("clamp-zoom", true);
36090
+ i2 && i2.clamp(), this.options.noMove || (this.options.center ? this.parent.moveCenter(this.options.center) : this.parent.moveCenter(e2));
36091
+ }
36092
+ }
36093
+ resume() {
36094
+ this.snapping = null, super.resume();
36095
+ }
36096
+ }
36097
+ var J = {
36098
+ percent: 0.1,
36099
+ smooth: false,
36100
+ interrupt: true,
36101
+ reverse: false,
36102
+ center: null,
36103
+ lineHeight: 20,
36104
+ axis: "all",
36105
+ keyToPress: null,
36106
+ trackpadPinch: false,
36107
+ wheelZoom: true
36108
+ };
36109
+
36110
+ class $2 extends u2 {
36111
+ constructor(t2, e2 = {}) {
36112
+ super(t2), this.options = Object.assign({}, J, e2), this.keyIsPressed = false, this.options.keyToPress && this.handleKeyPresses(this.options.keyToPress);
36113
+ }
36114
+ handleKeyPresses(t2) {
36115
+ typeof window > "u" || (window.addEventListener("keydown", (e2) => {
36116
+ t2.includes(e2.code) && (this.keyIsPressed = true);
36117
+ }), window.addEventListener("keyup", (e2) => {
36118
+ t2.includes(e2.code) && (this.keyIsPressed = false);
36119
+ }));
36120
+ }
36121
+ checkKeyPress() {
36122
+ return !this.options.keyToPress || this.keyIsPressed;
36123
+ }
36124
+ down() {
36125
+ return this.options.interrupt && (this.smoothing = null), false;
36126
+ }
36127
+ isAxisX() {
36128
+ return ["all", "x"].includes(this.options.axis);
36129
+ }
36130
+ isAxisY() {
36131
+ return ["all", "y"].includes(this.options.axis);
36132
+ }
36133
+ update() {
36134
+ if (this.smoothing) {
36135
+ const t2 = this.smoothingCenter, e2 = this.smoothing;
36136
+ let n2;
36137
+ this.options.center || (n2 = this.parent.toLocal(t2)), this.isAxisX() && (this.parent.scale.x += e2.x), this.isAxisY() && (this.parent.scale.y += e2.y), this.parent.emit("zoomed", { viewport: this.parent, type: "wheel" });
36138
+ const i2 = this.parent.plugins.get("clamp-zoom", true);
36139
+ if (i2 && i2.clamp(), this.options.center)
36140
+ this.parent.moveCenter(this.options.center);
36141
+ else {
36142
+ const s2 = this.parent.parent || this.parent;
36143
+ s2.toLocal(n2, this.parent, n2);
36144
+ const h2 = s2.toLocal(t2);
36145
+ this.parent.x += h2.x - n2.x, this.parent.y += h2.y - n2.y;
36146
+ }
36147
+ this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.smoothingCount++, typeof this.options.smooth == "number" && this.smoothingCount >= this.options.smooth && (this.smoothing = null);
36148
+ }
36149
+ }
36150
+ pinch(t2) {
36151
+ if (this.paused)
36152
+ return;
36153
+ const e2 = this.parent.input.getPointerPosition(t2), n2 = -t2.deltaY * (t2.deltaMode ? this.options.lineHeight : 1) / 200, i2 = Math.pow(2, (1 + this.options.percent) * n2);
36154
+ let s2;
36155
+ this.options.center || (s2 = this.parent.toLocal(e2)), this.isAxisX() && (this.parent.scale.x *= i2), this.isAxisY() && (this.parent.scale.y *= i2), this.parent.emit("zoomed", { viewport: this.parent, type: "wheel" });
36156
+ const h2 = this.parent.plugins.get("clamp-zoom", true);
36157
+ if (h2 && h2.clamp(), this.options.center)
36158
+ this.parent.moveCenter(this.options.center);
36159
+ else {
36160
+ const o2 = this.parent.parent || this.parent;
36161
+ o2.toLocal(s2, this.parent, s2);
36162
+ const r2 = o2.toLocal(e2);
36163
+ this.parent.x += r2.x - s2.x, this.parent.y += r2.y - s2.y;
36164
+ }
36165
+ this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.parent.emit("wheel-start", { event: t2, viewport: this.parent });
36166
+ }
36167
+ wheel(t2) {
36168
+ if (this.paused || !this.checkKeyPress())
36169
+ return false;
36170
+ if (t2.ctrlKey && this.options.trackpadPinch)
36171
+ this.pinch(t2);
36172
+ else if (this.options.wheelZoom) {
36173
+ const e2 = this.parent.input.getPointerPosition(t2), i2 = (this.options.reverse ? -1 : 1) * -t2.deltaY * (t2.deltaMode ? this.options.lineHeight : 1) / 500, s2 = Math.pow(2, (1 + this.options.percent) * i2);
36174
+ if (this.options.smooth) {
36175
+ const h2 = {
36176
+ x: this.smoothing ? this.smoothing.x * (this.options.smooth - this.smoothingCount) : 0,
36177
+ y: this.smoothing ? this.smoothing.y * (this.options.smooth - this.smoothingCount) : 0
36178
+ };
36179
+ this.smoothing = {
36180
+ x: ((this.parent.scale.x + h2.x) * s2 - this.parent.scale.x) / this.options.smooth,
36181
+ y: ((this.parent.scale.y + h2.y) * s2 - this.parent.scale.y) / this.options.smooth
36182
+ }, this.smoothingCount = 0, this.smoothingCenter = e2;
36183
+ } else {
36184
+ let h2;
36185
+ this.options.center || (h2 = this.parent.toLocal(e2)), this.isAxisX() && (this.parent.scale.x *= s2), this.isAxisY() && (this.parent.scale.y *= s2), this.parent.emit("zoomed", { viewport: this.parent, type: "wheel" });
36186
+ const o2 = this.parent.plugins.get("clamp-zoom", true);
36187
+ if (o2 && o2.clamp(), this.options.center)
36188
+ this.parent.moveCenter(this.options.center);
36189
+ else {
36190
+ const r2 = this.parent.parent || this.parent;
36191
+ r2.toLocal(h2, this.parent, h2);
36192
+ const a2 = r2.toLocal(e2);
36193
+ this.parent.x += a2.x - h2.x, this.parent.y += a2.y - h2.y;
36194
+ }
36195
+ }
36196
+ this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.parent.emit("wheel-start", { event: t2, viewport: this.parent });
36197
+ }
36198
+ return !this.parent.options.passiveWheel;
36199
+ }
36200
+ }
36201
+ var tt = {
36202
+ screenWidth: typeof window > "u" ? 0 : window.innerWidth,
36203
+ screenHeight: typeof window > "u" ? 0 : window.innerHeight,
36204
+ worldWidth: null,
36205
+ worldHeight: null,
36206
+ threshold: 5,
36207
+ passiveWheel: true,
36208
+ stopPropagation: false,
36209
+ forceHitArea: null,
36210
+ noTicker: false,
36211
+ disableOnContextMenu: false,
36212
+ ticker: Ticker.shared,
36213
+ allowPreserveDragOutside: false
36214
+ };
36215
+
36216
+ class it extends Container {
36217
+ constructor(t2) {
36218
+ super(), this._disableOnContextMenu = (e2) => e2.preventDefault(), this.options = {
36219
+ ...tt,
36220
+ ...t2
36221
+ }, this.screenWidth = this.options.screenWidth, this.screenHeight = this.options.screenHeight, this._worldWidth = this.options.worldWidth, this._worldHeight = this.options.worldHeight, this.forceHitArea = this.options.forceHitArea, this.threshold = this.options.threshold, this.options.disableOnContextMenu && this.options.events.domElement.addEventListener("contextmenu", this._disableOnContextMenu), this.options.noTicker || (this.tickerFunction = () => this.update(this.options.ticker.elapsedMS), this.options.ticker.add(this.tickerFunction)), this.input = new P(this), this.plugins = new C(this);
36222
+ }
36223
+ destroy(t2) {
36224
+ var e2;
36225
+ !this.options.noTicker && this.tickerFunction && this.options.ticker.remove(this.tickerFunction), this.options.disableOnContextMenu && ((e2 = this.options.events.domElement) == null || e2.removeEventListener("contextmenu", this._disableOnContextMenu)), this.input.destroy(), super.destroy(t2);
36226
+ }
36227
+ update(t2) {
36228
+ this.pause || (this.plugins.update(t2), this.lastViewport && (this.lastViewport.x !== this.x || this.lastViewport.y !== this.y ? this.moving = true : this.moving && (this.emit("moved-end", this), this.moving = false), this.lastViewport.scaleX !== this.scale.x || this.lastViewport.scaleY !== this.scale.y ? this.zooming = true : this.zooming && (this.emit("zoomed-end", this), this.zooming = false)), this.forceHitArea || (this._hitAreaDefault = new Rectangle(this.left, this.top, this.worldScreenWidth, this.worldScreenHeight), this.hitArea = this._hitAreaDefault), this._dirty = this._dirty || !this.lastViewport || this.lastViewport.x !== this.x || this.lastViewport.y !== this.y || this.lastViewport.scaleX !== this.scale.x || this.lastViewport.scaleY !== this.scale.y, this.lastViewport = {
36229
+ x: this.x,
36230
+ y: this.y,
36231
+ scaleX: this.scale.x,
36232
+ scaleY: this.scale.y
36233
+ }, this.emit("frame-end", this));
36234
+ }
36235
+ resize(t2 = typeof window > "u" ? 0 : window.innerWidth, e2 = typeof window > "u" ? 0 : window.innerHeight, n2, i2) {
36236
+ this.screenWidth = t2, this.screenHeight = e2, typeof n2 < "u" && (this._worldWidth = n2), typeof i2 < "u" && (this._worldHeight = i2), this.plugins.resize(), this.dirty = true;
36237
+ }
36238
+ get worldWidth() {
36239
+ return this._worldWidth ? this._worldWidth : this.width / this.scale.x;
36240
+ }
36241
+ set worldWidth(t2) {
36242
+ this._worldWidth = t2, this.plugins.resize();
36243
+ }
36244
+ get worldHeight() {
36245
+ return this._worldHeight ? this._worldHeight : this.height / this.scale.y;
36246
+ }
36247
+ set worldHeight(t2) {
36248
+ this._worldHeight = t2, this.plugins.resize();
36249
+ }
36250
+ getVisibleBounds() {
36251
+ return new Rectangle(this.left, this.top, this.worldScreenWidth, this.worldScreenHeight);
36252
+ }
36253
+ toWorld(t2, e2) {
36254
+ return arguments.length === 2 ? this.toLocal(new Point(t2, e2)) : this.toLocal(t2);
36255
+ }
36256
+ toScreen(t2, e2) {
36257
+ return arguments.length === 2 ? this.toGlobal(new Point(t2, e2)) : this.toGlobal(t2);
36258
+ }
36259
+ get worldScreenWidth() {
36260
+ return this.screenWidth / this.scale.x;
36261
+ }
36262
+ get worldScreenHeight() {
36263
+ return this.screenHeight / this.scale.y;
36264
+ }
36265
+ get screenWorldWidth() {
36266
+ return this.worldWidth * this.scale.x;
36267
+ }
36268
+ get screenWorldHeight() {
36269
+ return this.worldHeight * this.scale.y;
36270
+ }
36271
+ get center() {
36272
+ return new Point(this.worldScreenWidth / 2 - this.x / this.scale.x, this.worldScreenHeight / 2 - this.y / this.scale.y);
36273
+ }
36274
+ set center(t2) {
36275
+ this.moveCenter(t2);
36276
+ }
36277
+ moveCenter(...t2) {
36278
+ let e2, n2;
36279
+ typeof t2[0] == "number" ? (e2 = t2[0], n2 = t2[1]) : (e2 = t2[0].x, n2 = t2[0].y);
36280
+ const i2 = (this.worldScreenWidth / 2 - e2) * this.scale.x, s2 = (this.worldScreenHeight / 2 - n2) * this.scale.y;
36281
+ return (this.x !== i2 || this.y !== s2) && (this.position.set(i2, s2), this.plugins.reset(), this.dirty = true), this;
36282
+ }
36283
+ get corner() {
36284
+ return new Point(-this.x / this.scale.x, -this.y / this.scale.y);
36285
+ }
36286
+ set corner(t2) {
36287
+ this.moveCorner(t2);
36288
+ }
36289
+ moveCorner(...t2) {
36290
+ let e2, n2;
36291
+ return t2.length === 1 ? (e2 = -t2[0].x * this.scale.x, n2 = -t2[0].y * this.scale.y) : (e2 = -t2[0] * this.scale.x, n2 = -t2[1] * this.scale.y), (e2 !== this.x || n2 !== this.y) && (this.position.set(e2, n2), this.plugins.reset(), this.dirty = true), this;
36292
+ }
36293
+ get screenWidthInWorldPixels() {
36294
+ return this.screenWidth / this.scale.x;
36295
+ }
36296
+ get screenHeightInWorldPixels() {
36297
+ return this.screenHeight / this.scale.y;
36298
+ }
36299
+ findFitWidth(t2) {
36300
+ return this.screenWidth / t2;
36301
+ }
36302
+ findFitHeight(t2) {
36303
+ return this.screenHeight / t2;
36304
+ }
36305
+ findFit(t2, e2) {
36306
+ const n2 = this.screenWidth / t2, i2 = this.screenHeight / e2;
36307
+ return Math.min(n2, i2);
36308
+ }
36309
+ findCover(t2, e2) {
36310
+ const n2 = this.screenWidth / t2, i2 = this.screenHeight / e2;
36311
+ return Math.max(n2, i2);
36312
+ }
36313
+ fitWidth(t2 = this.worldWidth, e2, n2 = true, i2) {
36314
+ let s2;
36315
+ e2 && (s2 = this.center), this.scale.x = this.screenWidth / t2, n2 && (this.scale.y = this.scale.x);
36316
+ const h2 = this.plugins.get("clamp-zoom", true);
36317
+ return !i2 && h2 && h2.clamp(), e2 && s2 && this.moveCenter(s2), this;
36318
+ }
36319
+ fitHeight(t2 = this.worldHeight, e2, n2 = true, i2) {
36320
+ let s2;
36321
+ e2 && (s2 = this.center), this.scale.y = this.screenHeight / t2, n2 && (this.scale.x = this.scale.y);
36322
+ const h2 = this.plugins.get("clamp-zoom", true);
36323
+ return !i2 && h2 && h2.clamp(), e2 && s2 && this.moveCenter(s2), this;
36324
+ }
36325
+ fitWorld(t2) {
36326
+ let e2;
36327
+ t2 && (e2 = this.center), this.scale.x = this.screenWidth / this.worldWidth, this.scale.y = this.screenHeight / this.worldHeight, this.scale.x < this.scale.y ? this.scale.y = this.scale.x : this.scale.x = this.scale.y;
36328
+ const n2 = this.plugins.get("clamp-zoom", true);
36329
+ return n2 && n2.clamp(), t2 && e2 && this.moveCenter(e2), this;
36330
+ }
36331
+ fit(t2, e2 = this.worldWidth, n2 = this.worldHeight) {
36332
+ let i2;
36333
+ t2 && (i2 = this.center), this.scale.x = this.screenWidth / e2, this.scale.y = this.screenHeight / n2, this.scale.x < this.scale.y ? this.scale.y = this.scale.x : this.scale.x = this.scale.y;
36334
+ const s2 = this.plugins.get("clamp-zoom", true);
36335
+ return s2 && s2.clamp(), t2 && i2 && this.moveCenter(i2), this;
36336
+ }
36337
+ setZoom(t2, e2) {
36338
+ let n2;
36339
+ e2 && (n2 = this.center), this.scale.set(t2);
36340
+ const i2 = this.plugins.get("clamp-zoom", true);
36341
+ return i2 && i2.clamp(), e2 && n2 && this.moveCenter(n2), this;
36342
+ }
36343
+ zoomPercent(t2, e2) {
36344
+ return this.setZoom(this.scale.x + this.scale.x * t2, e2);
36345
+ }
36346
+ zoom(t2, e2) {
36347
+ return this.fitWidth(t2 + this.worldScreenWidth, e2), this;
36348
+ }
36349
+ get scaled() {
36350
+ return this.scale.x;
36351
+ }
36352
+ set scaled(t2) {
36353
+ this.setZoom(t2, true);
36354
+ }
36355
+ snapZoom(t2) {
36356
+ return this.plugins.add("snap-zoom", new G(this, t2)), this;
36357
+ }
36358
+ OOB() {
36359
+ return {
36360
+ left: this.left < 0,
36361
+ right: this.right > this.worldWidth,
36362
+ top: this.top < 0,
36363
+ bottom: this.bottom > this.worldHeight,
36364
+ cornerPoint: new Point(this.worldWidth * this.scale.x - this.screenWidth, this.worldHeight * this.scale.y - this.screenHeight)
36365
+ };
36366
+ }
36367
+ get right() {
36368
+ return -this.x / this.scale.x + this.worldScreenWidth;
36369
+ }
36370
+ set right(t2) {
36371
+ this.x = -t2 * this.scale.x + this.screenWidth, this.plugins.reset();
36372
+ }
36373
+ get left() {
36374
+ return -this.x / this.scale.x;
36375
+ }
36376
+ set left(t2) {
36377
+ this.x = -t2 * this.scale.x, this.plugins.reset();
36378
+ }
36379
+ get top() {
36380
+ return -this.y / this.scale.y;
36381
+ }
36382
+ set top(t2) {
36383
+ this.y = -t2 * this.scale.y, this.plugins.reset();
36384
+ }
36385
+ get bottom() {
36386
+ return -this.y / this.scale.y + this.worldScreenHeight;
36387
+ }
36388
+ set bottom(t2) {
36389
+ this.y = -t2 * this.scale.y + this.screenHeight, this.plugins.reset();
36390
+ }
36391
+ get dirty() {
36392
+ return !!this._dirty;
36393
+ }
36394
+ set dirty(t2) {
36395
+ this._dirty = t2;
36396
+ }
36397
+ get forceHitArea() {
36398
+ return this._forceHitArea;
36399
+ }
36400
+ set forceHitArea(t2) {
36401
+ t2 ? (this._forceHitArea = t2, this.hitArea = t2) : (this._forceHitArea = null, this.hitArea = new Rectangle(0, 0, this.worldWidth, this.worldHeight));
36402
+ }
36403
+ drag(t2) {
36404
+ return this.plugins.add("drag", new U(this, t2)), this;
36405
+ }
36406
+ clamp(t2) {
36407
+ return this.plugins.add("clamp", new A(this, t2)), this;
36408
+ }
36409
+ decelerate(t2) {
36410
+ return this.plugins.add("decelerate", new E(this, t2)), this;
36411
+ }
36412
+ bounce(t2) {
36413
+ return this.plugins.add("bounce", new X(this, t2)), this;
36414
+ }
36415
+ pinch(t2) {
36416
+ return this.plugins.add("pinch", new j2(this, t2)), this;
36417
+ }
36418
+ snap(t2, e2, n2) {
36419
+ return this.plugins.add("snap", new q(this, t2, e2, n2)), this;
36420
+ }
36421
+ follow(t2, e2) {
36422
+ return this.plugins.add("follow", new B(this, t2, e2)), this;
36423
+ }
36424
+ wheel(t2) {
36425
+ return this.plugins.add("wheel", new $2(this, t2)), this;
36426
+ }
36427
+ animate(t2) {
36428
+ return this.plugins.add("animate", new k2(this, t2)), this;
36429
+ }
36430
+ clampZoom(t2) {
36431
+ return this.plugins.add("clamp-zoom", new _(this, t2)), this;
36432
+ }
36433
+ mouseEdges(t2) {
36434
+ return this.plugins.add("mouse-edges", new V(this, t2)), this;
36435
+ }
36436
+ get pause() {
36437
+ return !!this._pause;
36438
+ }
36439
+ set pause(t2) {
36440
+ this._pause = t2, this.lastViewport = null, this.moving = false, this.zooming = false, t2 && this.input.pause();
36441
+ }
36442
+ ensureVisible(t2, e2, n2, i2, s2) {
36443
+ s2 && (n2 > this.worldScreenWidth || i2 > this.worldScreenHeight) && (this.fit(true, n2, i2), this.emit("zoomed", { viewport: this, type: "ensureVisible" }));
36444
+ let h2 = false;
36445
+ t2 < this.left ? (this.left = t2, h2 = true) : t2 + n2 > this.right && (this.right = t2 + n2, h2 = true), e2 < this.top ? (this.top = e2, h2 = true) : e2 + i2 > this.bottom && (this.bottom = e2 + i2, h2 = true), h2 && this.emit("moved", { viewport: this, type: "ensureVisible" });
36446
+ }
36447
+ }
36448
+
36449
+ // src/plugins/ViewportPlugin.ts
36450
+ var DEFAULTS2 = {
36451
+ worldWidth: 0,
36452
+ worldHeight: 0,
36453
+ minScale: 0.1,
36454
+ maxScale: 10,
36455
+ drag: true,
36456
+ pinch: true,
36457
+ wheel: true,
36458
+ decelerate: true
36459
+ };
36460
+
36461
+ class ViewportPlugin {
36462
+ name = "viewport";
36463
+ options;
36464
+ engine;
36465
+ _viewport;
36466
+ constructor(options) {
36467
+ this.options = { ...DEFAULTS2, ...options };
36468
+ }
36469
+ get viewport() {
36470
+ return this._viewport;
36471
+ }
36472
+ get zoom() {
36473
+ return this._viewport?.scale.x ?? 1;
36474
+ }
36475
+ set zoom(value) {
36476
+ if (!this._viewport)
36477
+ return;
36478
+ const clamped = Math.max(this.options.minScale, Math.min(this.options.maxScale, value));
36479
+ this._viewport.setZoom(clamped, true);
36480
+ this.engine.eventBus.emit("viewport:zoomed", { zoom: clamped });
36481
+ }
36482
+ get drag() {
36483
+ return this.options.drag;
36484
+ }
36485
+ set drag(value) {
36486
+ this.options.drag = value;
36487
+ if (!this._viewport)
36488
+ return;
36489
+ if (value) {
36490
+ this._viewport.drag({ mouseButtons: "middle-right" });
36491
+ } else {
36492
+ this._viewport.plugins.remove("drag");
36493
+ }
36494
+ }
36495
+ get wheel() {
36496
+ return this.options.wheel;
36497
+ }
36498
+ set wheel(value) {
36499
+ this.options.wheel = value;
36500
+ if (!this._viewport)
36501
+ return;
36502
+ if (value) {
36503
+ this._viewport.wheel({ smooth: 3 });
36504
+ } else {
36505
+ this._viewport.plugins.remove("wheel");
36506
+ }
36507
+ }
36508
+ init(engine) {
36509
+ this.engine = engine;
36510
+ const { app } = engine;
36511
+ const { width, height } = engine.options;
36512
+ const worldWidth = this.options.worldWidth || width;
36513
+ const worldHeight = this.options.worldHeight || height;
36514
+ this._viewport = new it({
36515
+ screenWidth: width,
36516
+ screenHeight: height,
36517
+ worldWidth,
36518
+ worldHeight,
36519
+ events: app.renderer.events
36520
+ });
36521
+ this._viewport.clampZoom({
36522
+ minScale: this.options.minScale,
36523
+ maxScale: this.options.maxScale
36524
+ });
36525
+ if (this.options.drag)
36526
+ this._viewport.drag({ mouseButtons: "middle-right" });
36527
+ if (this.options.pinch)
36528
+ this._viewport.pinch();
36529
+ if (this.options.wheel)
36530
+ this._viewport.wheel({ smooth: 3 });
36531
+ if (this.options.decelerate)
36532
+ this._viewport.decelerate();
36533
+ const contentRoot = engine.getContentRoot();
36534
+ contentRoot.parent?.removeChild(contentRoot);
36535
+ this._viewport.addChild(contentRoot);
36536
+ app.stage.addChildAt(this._viewport, 0);
36537
+ this._viewport.on("zoomed", () => {
36538
+ this.engine.eventBus.emit("viewport:zoomed", { zoom: this._viewport.scale.x });
36539
+ });
36540
+ this._viewport.on("moved", () => {
36541
+ this.engine.eventBus.emit("viewport:moved", {
36542
+ x: this._viewport.x,
36543
+ y: this._viewport.y
36544
+ });
36545
+ });
36546
+ }
36547
+ destroy() {
36548
+ if (!this._viewport)
36549
+ return;
36550
+ const { app } = this.engine;
36551
+ const contentRoot = this.engine.getContentRoot();
36552
+ this._viewport.removeChild(contentRoot);
36553
+ app.stage.addChild(contentRoot);
36554
+ this._viewport.destroy();
36555
+ }
36556
+ }
34987
36557
  export {
34988
36558
  ZOrderManager,
34989
36559
  WatchfaceEngine,
36560
+ ViewportPlugin,
34990
36561
  UndoRedoPlugin,
34991
36562
  TextElement,
34992
36563
  ShapeElement,