@annotorious/plugin-segment-anything 0.2.2 → 0.2.3

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.
@@ -1614,7 +1614,7 @@ function Ve() {
1614
1614
  k(g, w);
1615
1615
  },
1616
1616
  losecapture: function(w) {
1617
- A(g, w);
1617
+ O(g, w);
1618
1618
  },
1619
1619
  mouseenter: function(w) {
1620
1620
  W(g, w);
@@ -2804,7 +2804,7 @@ function Ve() {
2804
2804
  userData: p.userData
2805
2805
  }, p.scrollHandler(D)), S.stopPropagation && e.stopEvent(g), (D && D.preventDefault || S.preventDefault && !S.defaultPrevented) && e.cancelEvent(g);
2806
2806
  }
2807
- function A(p, c) {
2807
+ function O(p, c) {
2808
2808
  var g = {
2809
2809
  id: e.MouseTracker.mousePointerId,
2810
2810
  type: "mouse"
@@ -2959,7 +2959,7 @@ function Ve() {
2959
2959
  pointerType: g.type,
2960
2960
  isEmulated: !1
2961
2961
  };
2962
- m(p, w), O(p, w, g), w.preventDefault && !w.defaultPrevented && e.cancelEvent(c), w.stopPropagation && e.stopEvent(c);
2962
+ m(p, w), A(p, w, g), w.preventDefault && !w.defaultPrevented && e.cancelEvent(c), w.stopPropagation && e.stopEvent(c);
2963
2963
  }
2964
2964
  function me(p, c) {
2965
2965
  var g = {
@@ -3138,7 +3138,7 @@ function Ve() {
3138
3138
  userData: p.userData
3139
3139
  }, p.leaveHandler && p.leaveHandler(D), p.exitHandler && p.exitHandler(D));
3140
3140
  }
3141
- function O(p, c, g) {
3141
+ function A(p, c, g) {
3142
3142
  var w, S;
3143
3143
  w = p.getActivePointersListByType(g.type), S = w.getById(g.id), S ? g = S : (g.captured = !1, g.insideElementPressed = !1), p.overHandler && p.overHandler(
3144
3144
  {
@@ -3740,7 +3740,7 @@ function Ve() {
3740
3740
  nonPrimaryReleaseHandler: e.delegate(this, k),
3741
3741
  scrollHandler: e.delegate(this, L),
3742
3742
  pinchHandler: e.delegate(this, J),
3743
- focusHandler: e.delegate(this, A),
3743
+ focusHandler: e.delegate(this, O),
3744
3744
  blurHandler: e.delegate(this, G)
3745
3745
  }), this.outerTracker = new e.MouseTracker({
3746
3746
  userData: "Viewer.outerTracker",
@@ -3792,9 +3792,9 @@ function Ve() {
3792
3792
  }), this.tileCache = new e.TileCache({
3793
3793
  maxImageCacheCount: this.maxImageCacheCount
3794
3794
  }), Object.prototype.hasOwnProperty.call(this.drawerOptions, "useCanvas") && (e.console.error('useCanvas is deprecated, use the "drawer" option to indicate preferred drawer(s)'), this.drawerOptions.useCanvas || (this.drawer = e.HTMLDrawer), delete this.drawerOptions.useCanvas);
3795
- let O = Array.isArray(this.drawer) ? this.drawer : [this.drawer];
3796
- O.length === 0 && (O = [e.DEFAULT_SETTINGS.drawer].flat(), e.console.warn("No valid drawers were selected. Using the default value.")), this.drawer = null;
3797
- for (const R of O)
3795
+ let A = Array.isArray(this.drawer) ? this.drawer : [this.drawer];
3796
+ A.length === 0 && (A = [e.DEFAULT_SETTINGS.drawer].flat(), e.console.warn("No valid drawers were selected. Using the default value.")), this.drawer = null;
3797
+ for (const R of A)
3798
3798
  if (this.requestDrawer(R, { mainDrawer: !0, redrawImmediately: !1 }))
3799
3799
  break;
3800
3800
  if (!this.drawer)
@@ -3884,8 +3884,8 @@ function Ve() {
3884
3884
  if (e.isArray(u) || (u = [u]), !u.length)
3885
3885
  return this;
3886
3886
  this._opening = !0;
3887
- for (var b = u.length, F = 0, O = 0, R, N = function() {
3888
- if (F + O === b)
3887
+ for (var b = u.length, F = 0, A = 0, R, N = function() {
3888
+ if (F + A === b)
3889
3889
  if (F) {
3890
3890
  (_._firstOpen || !_.preserveViewport) && (_.viewport.goHome(!0), _.viewport.update()), _._firstOpen = !1;
3891
3891
  var U = u[0];
@@ -3908,7 +3908,7 @@ function Ve() {
3908
3908
  };
3909
3909
  var p = U.error;
3910
3910
  U.error = function(c) {
3911
- O++, R || (R = c), p && p(c), N();
3911
+ A++, R || (R = c), p && p(c), N();
3912
3912
  }, _.addTiledImage(U);
3913
3913
  }, $ = 0; $ < u.length; $++)
3914
3914
  Y(u[$]);
@@ -3968,7 +3968,7 @@ function Ve() {
3968
3968
  drawerOptions: null
3969
3969
  };
3970
3970
  m = e.extend(!0, _, m);
3971
- const b = m.mainDrawer, F = m.redrawImmediately, O = m.drawerOptions, R = this.drawer;
3971
+ const b = m.mainDrawer, F = m.redrawImmediately, A = m.drawerOptions, R = this.drawer;
3972
3972
  let N = null;
3973
3973
  if (u && u.prototype instanceof e.DrawerBase ? (N = u, u = "custom") : typeof u == "string" && (N = e.determineDrawer(u)), N || e.console.warn("Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase."), N && N.isSupported()) {
3974
3974
  R && b && R.destroy();
@@ -3977,7 +3977,7 @@ function Ve() {
3977
3977
  viewport: this.viewport,
3978
3978
  element: this.canvas,
3979
3979
  debugGridColor: this.debugGridColor,
3980
- options: O || this.drawerOptions[u]
3980
+ options: A || this.drawerOptions[u]
3981
3981
  });
3982
3982
  return b && (this.drawer = Y, F && this.forceRedraw()), Y;
3983
3983
  }
@@ -4086,7 +4086,7 @@ function Ve() {
4086
4086
  * @fires OpenSeadragon.Viewer.event:full-page
4087
4087
  */
4088
4088
  setFullPage: function(u) {
4089
- var m = document.body, _ = m.style, b = document.documentElement.style, F = this, O, R;
4089
+ var m = document.body, _ = m.style, b = document.documentElement.style, F = this, A, R;
4090
4090
  if (u === this.isFullPage())
4091
4091
  return this;
4092
4092
  var N = {
@@ -4096,11 +4096,11 @@ function Ve() {
4096
4096
  if (this.raiseEvent("pre-full-page", N), N.preventDefaultAction)
4097
4097
  return this;
4098
4098
  if (u && this.element) {
4099
- for (this.elementSize = e.getElementSize(this.element), this.pageScroll = e.getPageScroll(), this.elementMargin = this.element.style.margin, this.element.style.margin = "0", this.elementPadding = this.element.style.padding, this.element.style.padding = "0", this.bodyMargin = _.margin, this.docMargin = b.margin, _.margin = "0", b.margin = "0", this.bodyPadding = _.padding, this.docPadding = b.padding, _.padding = "0", b.padding = "0", this.bodyWidth = _.width, this.docWidth = b.width, _.width = "100%", b.width = "100%", this.bodyHeight = _.height, this.docHeight = b.height, _.height = "100%", b.height = "100%", this.bodyDisplay = _.display, _.display = "block", this.previousBody = [], t[this.hash].prevElementParent = this.element.parentNode, t[this.hash].prevNextSibling = this.element.nextSibling, t[this.hash].prevElementWidth = this.element.style.width, t[this.hash].prevElementHeight = this.element.style.height, O = m.childNodes.length, R = 0; R < O; R++)
4099
+ for (this.elementSize = e.getElementSize(this.element), this.pageScroll = e.getPageScroll(), this.elementMargin = this.element.style.margin, this.element.style.margin = "0", this.elementPadding = this.element.style.padding, this.element.style.padding = "0", this.bodyMargin = _.margin, this.docMargin = b.margin, _.margin = "0", b.margin = "0", this.bodyPadding = _.padding, this.docPadding = b.padding, _.padding = "0", b.padding = "0", this.bodyWidth = _.width, this.docWidth = b.width, _.width = "100%", b.width = "100%", this.bodyHeight = _.height, this.docHeight = b.height, _.height = "100%", b.height = "100%", this.bodyDisplay = _.display, _.display = "block", this.previousBody = [], t[this.hash].prevElementParent = this.element.parentNode, t[this.hash].prevNextSibling = this.element.nextSibling, t[this.hash].prevElementWidth = this.element.style.width, t[this.hash].prevElementHeight = this.element.style.height, A = m.childNodes.length, R = 0; R < A; R++)
4100
4100
  this.previousBody.push(m.childNodes[0]), m.removeChild(m.childNodes[0]);
4101
4101
  this.toolbar && this.toolbar.element && (this.toolbar.parentNode = this.toolbar.element.parentNode, this.toolbar.nextSibling = this.toolbar.element.nextSibling, m.appendChild(this.toolbar.element), e.addClass(this.toolbar.element, "fullpage")), e.addClass(this.element, "fullpage"), m.appendChild(this.element), this.element.style.height = "100vh", this.element.style.width = "100vw", this.toolbar && this.toolbar.element && (this.element.style.height = e.getElementSize(this.element).y - e.getElementSize(this.toolbar.element).y + "px"), t[this.hash].fullPage = !0, e.delegate(this, X)({});
4102
4102
  } else {
4103
- for (this.element.style.margin = this.elementMargin, this.element.style.padding = this.elementPadding, _.margin = this.bodyMargin, b.margin = this.docMargin, _.padding = this.bodyPadding, b.padding = this.docPadding, _.width = this.bodyWidth, b.width = this.docWidth, _.height = this.bodyHeight, b.height = this.docHeight, _.display = this.bodyDisplay, m.removeChild(this.element), O = this.previousBody.length, R = 0; R < O; R++)
4103
+ for (this.element.style.margin = this.elementMargin, this.element.style.padding = this.elementPadding, _.margin = this.bodyMargin, b.margin = this.docMargin, _.padding = this.bodyPadding, b.padding = this.docPadding, _.width = this.bodyWidth, b.width = this.docWidth, _.height = this.bodyHeight, b.height = this.docHeight, _.display = this.bodyDisplay, m.removeChild(this.element), A = this.previousBody.length, R = 0; R < A; R++)
4104
4104
  m.appendChild(this.previousBody.shift());
4105
4105
  e.removeClass(this.element, "fullpage"), t[this.hash].prevElementParent.insertBefore(
4106
4106
  this.element,
@@ -4281,7 +4281,7 @@ function Ve() {
4281
4281
  return;
4282
4282
  }
4283
4283
  this._loadQueue.push(_);
4284
- function O() {
4284
+ function A() {
4285
4285
  for (var R, N, Y; m._loadQueue.length && (R = m._loadQueue[0], !!R.tileSource); ) {
4286
4286
  if (m._loadQueue.splice(0, 1), R.options.replace) {
4287
4287
  var $ = m.world.getIndexOfItem(R.options.replaceItem);
@@ -4338,9 +4338,9 @@ function Ve() {
4338
4338
  }
4339
4339
  }
4340
4340
  r(this, u.tileSource, u, function(R) {
4341
- _.tileSource = R, O();
4341
+ _.tileSource = R, A();
4342
4342
  }, function(R) {
4343
- R.options = u, b(R), O();
4343
+ R.options = u, b(R), A();
4344
4344
  });
4345
4345
  },
4346
4346
  /**
@@ -4419,8 +4419,8 @@ function Ve() {
4419
4419
  * @returns {OpenSeadragon.Viewer} Chainable.
4420
4420
  */
4421
4421
  bindSequenceControls: function() {
4422
- var u = e.delegate(this, v), m = e.delegate(this, y), _ = e.delegate(this, this.goToNextPage), b = e.delegate(this, this.goToPreviousPage), F = this.navImages, O = !0;
4423
- return this.showSequenceControl && ((this.previousButton || this.nextButton) && (O = !1), this.previousButton = new e.Button({
4422
+ var u = e.delegate(this, v), m = e.delegate(this, y), _ = e.delegate(this, this.goToNextPage), b = e.delegate(this, this.goToPreviousPage), F = this.navImages, A = !0;
4423
+ return this.showSequenceControl && ((this.previousButton || this.nextButton) && (A = !1), this.previousButton = new e.Button({
4424
4424
  element: this.previousButton ? e.getElement(this.previousButton) : null,
4425
4425
  clickTimeThreshold: this.clickTimeThreshold,
4426
4426
  clickDistThreshold: this.clickDistThreshold,
@@ -4444,7 +4444,7 @@ function Ve() {
4444
4444
  onRelease: _,
4445
4445
  onFocus: u,
4446
4446
  onBlur: m
4447
- }), this.navPrevNextWrap || this.previousButton.disable(), (!this.tileSources || !this.tileSources.length) && this.nextButton.disable(), O && (this.paging = new e.ButtonGroup({
4447
+ }), this.navPrevNextWrap || this.previousButton.disable(), (!this.tileSources || !this.tileSources.length) && this.nextButton.disable(), A && (this.paging = new e.ButtonGroup({
4448
4448
  buttons: [
4449
4449
  this.previousButton,
4450
4450
  this.nextButton
@@ -4464,7 +4464,7 @@ function Ve() {
4464
4464
  * @returns {OpenSeadragon.Viewer} Chainable.
4465
4465
  */
4466
4466
  bindStandardControls: function() {
4467
- var u = e.delegate(this, fe), m = e.delegate(this, me), _ = e.delegate(this, _e), b = e.delegate(this, ge), F = e.delegate(this, ye), O = e.delegate(this, Ee), R = e.delegate(this, Te), N = e.delegate(this, Se), Y = e.delegate(this, pe), $ = e.delegate(this, ce), U = e.delegate(this, v), ie = e.delegate(this, y), p = this.navImages, c = [], g = !0;
4467
+ var u = e.delegate(this, fe), m = e.delegate(this, me), _ = e.delegate(this, _e), b = e.delegate(this, ge), F = e.delegate(this, ye), A = e.delegate(this, Ee), R = e.delegate(this, Te), N = e.delegate(this, Se), Y = e.delegate(this, pe), $ = e.delegate(this, ce), U = e.delegate(this, v), ie = e.delegate(this, y), p = this.navImages, c = [], g = !0;
4468
4468
  return this.showNavigationControl && ((this.zoomInButton || this.zoomOutButton || this.homeButton || this.fullPageButton || this.rotateLeftButton || this.rotateRightButton || this.flipButton) && (g = !1), this.showZoomControl && (c.push(this.zoomInButton = new e.Button({
4469
4469
  element: this.zoomInButton ? e.getElement(this.zoomInButton) : null,
4470
4470
  clickTimeThreshold: this.clickTimeThreshold,
@@ -4506,7 +4506,7 @@ function Ve() {
4506
4506
  srcGroup: W(this.prefixUrl, p.home.GROUP),
4507
4507
  srcHover: W(this.prefixUrl, p.home.HOVER),
4508
4508
  srcDown: W(this.prefixUrl, p.home.DOWN),
4509
- onRelease: O,
4509
+ onRelease: A,
4510
4510
  onFocus: U,
4511
4511
  onBlur: ie
4512
4512
  })), this.showFullPageControl && c.push(this.fullPageButton = new e.Button({
@@ -4615,8 +4615,8 @@ function Ve() {
4615
4615
  onDraw: b
4616
4616
  }, u = e.getElement(F.element), o(this.currentOverlays, u) >= 0)
4617
4617
  return this;
4618
- var O = s(this, F);
4619
- return this.currentOverlays.push(O), O.drawHTML(this.overlaysContainer, this.viewport), this.raiseEvent("add-overlay", {
4618
+ var A = s(this, F);
4619
+ return this.currentOverlays.push(A), A.drawHTML(this.overlaysContainer, this.viewport), this.raiseEvent("add-overlay", {
4620
4620
  element: u,
4621
4621
  location: F.location,
4622
4622
  placement: F.placement
@@ -4830,7 +4830,7 @@ function Ve() {
4830
4830
  );
4831
4831
  }
4832
4832
  function r(u, m, _, b, F) {
4833
- var O = u;
4833
+ var A = u;
4834
4834
  if (e.type(m) === "string") {
4835
4835
  if (m.match(/^\s*<.*>\s*$/))
4836
4836
  m = e.parseXml(m);
@@ -4870,7 +4870,7 @@ function Ve() {
4870
4870
  var Y = new e.TileSource(m);
4871
4871
  Y.getTileUrl = m.getTileUrl, b(Y);
4872
4872
  } else {
4873
- var $ = e.TileSource.determineType(O, m);
4873
+ var $ = e.TileSource.determineType(A, m);
4874
4874
  if (!$) {
4875
4875
  F({
4876
4876
  message: "Unable to load TileSource",
@@ -4878,7 +4878,7 @@ function Ve() {
4878
4878
  });
4879
4879
  return;
4880
4880
  }
4881
- var U = $.prototype.configure.apply(O, [m]);
4881
+ var U = $.prototype.configure.apply(A, [m]);
4882
4882
  N(new $(U), m);
4883
4883
  }
4884
4884
  else
@@ -4898,17 +4898,17 @@ function Ve() {
4898
4898
  m.className ? m.className : "openseadragon-overlay"
4899
4899
  );
4900
4900
  }
4901
- var F = m.location, O = m.width, R = m.height;
4901
+ var F = m.location, A = m.width, R = m.height;
4902
4902
  if (!F) {
4903
4903
  var N = m.x, Y = m.y;
4904
4904
  if (m.px !== void 0) {
4905
4905
  var $ = u.viewport.imageToViewportRectangle(new e.Rect(
4906
4906
  m.px,
4907
4907
  m.py,
4908
- O || 0,
4908
+ A || 0,
4909
4909
  R || 0
4910
4910
  ));
4911
- N = $.x, Y = $.y, O = O !== void 0 ? $.width : void 0, R = R !== void 0 ? $.height : void 0;
4911
+ N = $.x, Y = $.y, A = A !== void 0 ? $.width : void 0, R = R !== void 0 ? $.height : void 0;
4912
4912
  }
4913
4913
  F = new e.Point(N, Y);
4914
4914
  }
@@ -4919,7 +4919,7 @@ function Ve() {
4919
4919
  placement: U,
4920
4920
  onDraw: m.onDraw,
4921
4921
  checkResize: m.checkResize,
4922
- width: O,
4922
+ width: A,
4923
4923
  height: R,
4924
4924
  rotationMode: m.rotationMode
4925
4925
  });
@@ -5091,8 +5091,8 @@ function Ve() {
5091
5091
  if (this.panHorizontal || (u.delta.x = 0), this.panVertical || (u.delta.y = 0), this.viewport.flipped && (u.delta.x = -u.delta.x), this.constrainDuringPan) {
5092
5092
  var F = this.viewport.deltaPointsFromPixels(u.delta.negate());
5093
5093
  this.viewport.centerSpringX.target.value += F.x, this.viewport.centerSpringY.target.value += F.y;
5094
- var O = this.viewport.getConstrainedBounds();
5095
- this.viewport.centerSpringX.target.value -= F.x, this.viewport.centerSpringY.target.value -= F.y, O.xConstrained && (u.delta.x = 0), O.yConstrained && (u.delta.y = 0);
5094
+ var A = this.viewport.getConstrainedBounds();
5095
+ this.viewport.centerSpringX.target.value -= F.x, this.viewport.centerSpringY.target.value -= F.y, A.xConstrained && (u.delta.x = 0), A.yConstrained && (u.delta.y = 0);
5096
5096
  }
5097
5097
  this.viewport.panBy(this.viewport.deltaPointsFromPixels(u.delta.negate()), m.flickEnabled && !this.constrainDuringPan);
5098
5098
  }
@@ -5115,10 +5115,10 @@ function Ve() {
5115
5115
  this.panHorizontal && (b = m.flickMomentum * u.speed * Math.cos(u.direction));
5116
5116
  var F = 0;
5117
5117
  this.panVertical && (F = m.flickMomentum * u.speed * Math.sin(u.direction));
5118
- var O = this.viewport.pixelFromPoint(
5118
+ var A = this.viewport.pixelFromPoint(
5119
5119
  this.viewport.getCenter(!0)
5120
5120
  ), R = this.viewport.pointFromPixel(
5121
- new e.Point(O.x - b, O.y - F)
5121
+ new e.Point(A.x - b, A.y - F)
5122
5122
  );
5123
5123
  this.viewport.panTo(R, !1);
5124
5124
  }
@@ -5197,7 +5197,7 @@ function Ve() {
5197
5197
  });
5198
5198
  }
5199
5199
  function J(u) {
5200
- var m, _, b, F, O = {
5200
+ var m, _, b, F, A = {
5201
5201
  tracker: u.eventSource,
5202
5202
  pointerType: u.pointerType,
5203
5203
  gesturePoints: u.gesturePoints,
@@ -5211,7 +5211,7 @@ function Ve() {
5211
5211
  preventDefaultZoomAction: !1,
5212
5212
  preventDefaultRotateAction: !1
5213
5213
  };
5214
- if (this.raiseEvent("canvas-pinch", O), this.viewport && (m = this.gestureSettingsByDeviceType(u.pointerType), m.pinchToZoom && (!O.preventDefaultPanAction || !O.preventDefaultZoomAction) && (_ = this.viewport.pointFromPixel(u.center, !0), m.zoomToRefPoint && !O.preventDefaultPanAction && (b = this.viewport.pointFromPixel(u.lastCenter, !0), F = b.minus(_), this.panHorizontal || (F.x = 0), this.panVertical || (F.y = 0), this.viewport.panBy(F, !0)), O.preventDefaultZoomAction || this.viewport.zoomBy(u.distance / u.lastDistance, _, !0), this.viewport.applyConstraints()), m.pinchRotate && !O.preventDefaultRotateAction)) {
5214
+ if (this.raiseEvent("canvas-pinch", A), this.viewport && (m = this.gestureSettingsByDeviceType(u.pointerType), m.pinchToZoom && (!A.preventDefaultPanAction || !A.preventDefaultZoomAction) && (_ = this.viewport.pointFromPixel(u.center, !0), m.zoomToRefPoint && !A.preventDefaultPanAction && (b = this.viewport.pointFromPixel(u.lastCenter, !0), F = b.minus(_), this.panHorizontal || (F.x = 0), this.panVertical || (F.y = 0), this.viewport.panBy(F, !0)), A.preventDefaultZoomAction || this.viewport.zoomBy(u.distance / u.lastDistance, _, !0), this.viewport.applyConstraints()), m.pinchRotate && !A.preventDefaultRotateAction)) {
5215
5215
  var R = Math.atan2(
5216
5216
  u.gesturePoints[0].currentPos.y - u.gesturePoints[1].currentPos.y,
5217
5217
  u.gesturePoints[0].currentPos.x - u.gesturePoints[1].currentPos.x
@@ -5222,7 +5222,7 @@ function Ve() {
5222
5222
  _ = this.viewport.pointFromPixel(u.center, !0), this.viewport.rotateTo(this.viewport.getRotation(!0) + (R - N) * (180 / Math.PI), _, !0);
5223
5223
  }
5224
5224
  }
5225
- function A(u) {
5225
+ function O(u) {
5226
5226
  this.raiseEvent("canvas-focus", {
5227
5227
  tracker: u.eventSource,
5228
5228
  originalEvent: u.originalEvent
@@ -5235,8 +5235,8 @@ function Ve() {
5235
5235
  });
5236
5236
  }
5237
5237
  function L(u) {
5238
- var m, _, b, F, O;
5239
- F = e.now(), O = F - this._lastScrollTime, O > this.minScrollDeltaTime ? (this._lastScrollTime = F, m = {
5238
+ var m, _, b, F, A;
5239
+ F = e.now(), A = F - this._lastScrollTime, A > this.minScrollDeltaTime ? (this._lastScrollTime = F, m = {
5240
5240
  tracker: u.eventSource,
5241
5241
  position: u.position,
5242
5242
  scroll: u.scroll,
@@ -5279,14 +5279,14 @@ function Ve() {
5279
5279
  function oe(u, m) {
5280
5280
  var _ = u.viewport, b = _.getZoom(), F = _.getCenter();
5281
5281
  _.resize(m, u.preserveImageSizeOnResize), _.panTo(F, !0);
5282
- var O;
5282
+ var A;
5283
5283
  if (u.preserveImageSizeOnResize)
5284
- O = t[u.hash].prevContainerSize.x / m.x;
5284
+ A = t[u.hash].prevContainerSize.x / m.x;
5285
5285
  else {
5286
5286
  var R = new e.Point(0, 0), N = new e.Point(t[u.hash].prevContainerSize.x, t[u.hash].prevContainerSize.y).distanceTo(R), Y = new e.Point(m.x, m.y).distanceTo(R);
5287
- O = Y / N * t[u.hash].prevContainerSize.x / m.x;
5287
+ A = Y / N * t[u.hash].prevContainerSize.x / m.x;
5288
5288
  }
5289
- _.zoomTo(b * O, null, !0), t[u.hash].prevContainerSize = m, t[u.hash].forceRedraw = !0, t[u.hash].needsResize = !1, t[u.hash].forceResize = !1;
5289
+ _.zoomTo(b * A, null, !0), t[u.hash].prevContainerSize = m, t[u.hash].forceRedraw = !0, t[u.hash].needsResize = !1, t[u.hash].forceResize = !1;
5290
5290
  }
5291
5291
  function le(u) {
5292
5292
  if (!(u._opening || !t[u.hash])) {
@@ -5301,9 +5301,9 @@ function Ve() {
5301
5301
  }
5302
5302
  var b = u.viewport.update(), F = u.world.update(b) || b;
5303
5303
  b && u.raiseEvent("viewport-change"), u.referenceStrip && (F = u.referenceStrip.update(u.viewport) || F);
5304
- var O = t[u.hash].animating;
5305
- !O && F && (u.raiseEvent("animation-start"), f(u));
5306
- var R = O && !F;
5304
+ var A = t[u.hash].animating;
5305
+ !A && F && (u.raiseEvent("animation-start"), f(u));
5306
+ var R = A && !F;
5307
5307
  R && (t[u.hash].animating = !1), (F || R || t[u.hash].forceRedraw || u.world.needsDraw()) && (he(u), u._drawOverlays(), u.navigator && u.navigator.update(u.viewport), t[u.hash].forceRedraw = !1, F && u.raiseEvent("animation")), R && (u.raiseEvent("animation-finish"), t[u.hash].mouseInside || h(u)), t[u.hash].animating = F;
5308
5308
  }
5309
5309
  }
@@ -7539,11 +7539,11 @@ function Ve() {
7539
7539
  );
7540
7540
  I && i.push(I);
7541
7541
  }
7542
- function B(k, J, A, G) {
7543
- var L = J.minus(k), X = G.minus(A), te = -X.x * L.y + L.x * X.y;
7542
+ function B(k, J, O, G) {
7543
+ var L = J.minus(k), X = G.minus(O), te = -X.x * L.y + L.x * X.y;
7544
7544
  if (te === 0)
7545
7545
  return null;
7546
- var se = (L.x * (k.y - A.y) - L.y * (k.x - A.x)) / te, oe = (X.x * (k.y - A.y) - X.y * (k.x - A.x)) / te;
7546
+ var se = (L.x * (k.y - O.y) - L.y * (k.x - O.x)) / te, oe = (X.x * (k.y - O.y) - X.y * (k.x - O.x)) / te;
7547
7547
  return -1e-10 <= se && se <= 1 - n && -1e-10 <= oe && oe <= 1 - n ? new e.Point(k.x + oe * L.x, k.y + oe * L.y) : null;
7548
7548
  }
7549
7549
  if (i.length === 0)
@@ -8748,7 +8748,7 @@ function Ve() {
8748
8748
  try {
8749
8749
  var j = l._croppingPolygons.map(function(k) {
8750
8750
  return k.map(function(J) {
8751
- var A = l.imageToViewportCoordinates(J.x, J.y, !0).rotate(-l.getRotation(!0), l._getRotationPoint(!0)), G = z.viewportCoordToDrawerCoord(A);
8751
+ var O = l.imageToViewportCoordinates(J.x, J.y, !0).rotate(-l.getRotation(!0), l._getRotationPoint(!0)), G = z.viewportCoordToDrawerCoord(O);
8752
8752
  return v && (G = G.times(v)), y && (G = G.plus(y)), G;
8753
8753
  });
8754
8754
  });
@@ -9250,7 +9250,7 @@ function Ve() {
9250
9250
  P && (v && this._outputContext.drawImage(this._renderingCanvas, 0, 0), r.bindFramebuffer(r.FRAMEBUFFER, null), r.clear(r.COLOR_BUFFER_BIT)), r.useProgram(this._firstPass.shaderProgram), I ? (r.bindFramebuffer(r.FRAMEBUFFER, this._glFrameBuffer), r.clear(r.COLOR_BUFFER_BIT)) : r.bindFramebuffer(r.FRAMEBUFFER, null);
9251
9251
  let B = f, z = y.getRotation(!0);
9252
9252
  if (z % 360 !== 0) {
9253
- let k = e.Mat3.makeRotation(-z * Math.PI / 180), J = y.getBoundsNoRotate(!0).getCenter(), A = e.Mat3.makeTranslation(J.x, J.y), G = e.Mat3.makeTranslation(-J.x, -J.y), L = A.multiply(k).multiply(G);
9253
+ let k = e.Mat3.makeRotation(-z * Math.PI / 180), J = y.getBoundsNoRotate(!0).getCenter(), O = e.Mat3.makeTranslation(J.x, J.y), G = e.Mat3.makeTranslation(-J.x, -J.y), L = O.multiply(k).multiply(G);
9254
9254
  B = f.multiply(L);
9255
9255
  }
9256
9256
  let j = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
@@ -9259,8 +9259,8 @@ function Ve() {
9259
9259
  if too many contexts have been created and not released, or there is another problem with the graphics card.`);
9260
9260
  let Z = new Float32Array(j * 12), q = new Array(j), ee = new Array(j), Q = new Array(j);
9261
9261
  for (let k = 0; k < x.length; k++) {
9262
- let J = x[k].tile, A = k % j, G = A + 1, L = J.getCanvasContext(), X = L ? this._TextureMap.get(L.canvas) : null;
9263
- if (X || (this._tileReadyHandler({ tile: J, tiledImage: y }), X = L ? this._TextureMap.get(L.canvas) : null), X && this._getTileData(J, y, X, B, A, Z, q, ee, Q), G === j || k === x.length - 1) {
9262
+ let J = x[k].tile, O = k % j, G = O + 1, L = J.getCanvasContext(), X = L ? this._TextureMap.get(L.canvas) : null;
9263
+ if (X || (this._tileReadyHandler({ tile: J, tiledImage: y }), X = L ? this._TextureMap.get(L.canvas) : null), X && this._getTileData(J, y, X, B, O, Z, q, ee, Q), G === j || k === x.length - 1) {
9264
9264
  for (let te = 0; te <= G; te++)
9265
9265
  r.activeTexture(r.TEXTURE0 + te), r.bindTexture(r.TEXTURE_2D, q[te]);
9266
9266
  r.bindBuffer(r.ARRAY_BUFFER, this._firstPass.bufferTexturePosition), r.bufferData(r.ARRAY_BUFFER, Z, r.DYNAMIC_DRAW), ee.forEach((te, se) => {
@@ -12582,21 +12582,21 @@ const Ze = /* @__PURE__ */ Oe(je), qe = (V, C = [255, 255, 255, 255], e = [0, 0,
12582
12582
  let t = !1, n = !1, i = "add";
12583
12583
  const r = We(), s = et();
12584
12584
  let o, a;
12585
- const l = (A) => {
12585
+ const l = (O) => {
12586
12586
  const { isSAMReady: G, sam: L } = s;
12587
12587
  if (!L || !G) return;
12588
- const X = e.drawer.canvas, te = X.width / (L.currentScale * X.offsetWidth), se = X.height / (L.currentScale * X.offsetHeight), oe = A.x * te + L.currentBounds.x, le = A.y * se + L.currentBounds.y;
12588
+ const X = e.drawer.canvas, te = X.width / (L.currentScale * X.offsetWidth), se = X.height / (L.currentScale * X.offsetHeight), oe = O.x * te + L.currentBounds.x, le = O.y * se + L.currentBounds.y;
12589
12589
  return { x: oe, y: le };
12590
- }, h = (A) => {
12590
+ }, h = (O) => {
12591
12591
  var X;
12592
12592
  if (!s.isSAMReady || !s.isOSDReady || !!((X = s.sam) != null && X.currentPrompt)) return;
12593
- const L = { x: A.offsetX, y: A.offsetY };
12593
+ const L = { x: O.offsetX, y: O.offsetY };
12594
12594
  s.lastPointerPos = L, s.isAnimationInProgress || T(L);
12595
- }, d = (A) => {
12595
+ }, d = (O) => {
12596
12596
  var oe, le, he, W;
12597
- const G = { x: A.offsetX, y: A.offsetY }, L = l(G);
12597
+ const G = { x: O.offsetX, y: O.offsetY }, L = l(G);
12598
12598
  if (!L) return;
12599
- A.shiftKey || i === "remove" ? s.sam.currentPrompt = {
12599
+ O.shiftKey || i === "remove" ? s.sam.currentPrompt = {
12600
12600
  include: ((oe = s.sam.currentPrompt) == null ? void 0 : oe.include) || [],
12601
12601
  exclude: [...((le = s.sam.currentPrompt) == null ? void 0 : le.exclude) || [], L]
12602
12602
  } : s.sam.currentPrompt = {
@@ -12605,24 +12605,24 @@ const Ze = /* @__PURE__ */ Oe(je), qe = (V, C = [255, 255, 255, 255], e = [0, 0,
12605
12605
  };
12606
12606
  const { currentPrompt: X, currentBounds: te, currentScale: se } = s.sam;
12607
12607
  a.setPrompt(X, te, se), k.postMessage({ type: "decode", prompt: s.sam.currentPrompt });
12608
- }, f = (A) => {
12609
- A.quick && (!s.sam || !s.isSAMReady || !s.isOSDReady || s.isAnimationInProgress || (e.setMouseNavEnabled(!1), d(A.originalEvent)));
12610
- }, v = (A) => {
12611
- e.isMouseNavEnabled() || d(A);
12608
+ }, f = (O) => {
12609
+ O.quick && (!s.sam || !s.isSAMReady || !s.isOSDReady || s.isAnimationInProgress || (e.setMouseNavEnabled(!1), d(O.originalEvent)));
12610
+ }, v = (O) => {
12611
+ e.isMouseNavEnabled() || d(O);
12612
12612
  }, y = () => {
12613
12613
  if (!s.sam) return;
12614
12614
  s.viewportVersion += 1, r.emit("encodingStart");
12615
- const A = Ne(s.sam.currentCanvas);
12616
- k.postMessage({ type: "encode", data: A, viewportVersion: s.viewportVersion });
12617
- }, T = (A) => {
12615
+ const O = Ne(s.sam.currentCanvas);
12616
+ k.postMessage({ type: "encode", data: O, viewportVersion: s.viewportVersion });
12617
+ }, T = (O) => {
12618
12618
  if (s.lastEncodingVersion !== s.viewportVersion) return;
12619
- const G = l(A);
12619
+ const G = l(O);
12620
12620
  G && k.postMessage({ type: "decode_preview", point: G });
12621
12621
  }, x = () => {
12622
- const { canvas: A, bounds: G, scale: L } = Ke(e.drawer.canvas);
12622
+ const { canvas: O, bounds: G, scale: L } = Ke(e.drawer.canvas);
12623
12623
  s.sam = {
12624
12624
  // The current 1024 x 1024 SAM working canvas
12625
- currentCanvas: A,
12625
+ currentCanvas: O,
12626
12626
  // The bbox of the resized & padded viewport on the working canvas
12627
12627
  currentBounds: G,
12628
12628
  // The current SAM scale (longer image dimension / 1024)
@@ -12643,50 +12643,55 @@ const Ze = /* @__PURE__ */ Oe(je), qe = (V, C = [255, 255, 255, 255], e = [0, 0,
12643
12643
  const B = () => {
12644
12644
  e.element.addEventListener("pointermove", h), e.element.addEventListener("pointerdown", v), e.addHandler("canvas-click", f);
12645
12645
  }, z = () => {
12646
- var A, G;
12647
- (A = e.element) == null || A.removeEventListener("pointermove", h), (G = e.element) == null || G.removeEventListener("pointerdown", v), e == null || e.removeHandler("canvas-click", f);
12648
- }, j = (A) => i = A, Z = () => {
12646
+ var O, G;
12647
+ (O = e.element) == null || O.removeEventListener("pointermove", h), (G = e.element) == null || G.removeEventListener("pointerdown", v), e == null || e.removeHandler("canvas-click", f);
12648
+ }, j = (O) => i = O, Z = () => {
12649
12649
  console.log("[a9s-sam] Stopping plugin"), n = !1, e == null || e.setMouseNavEnabled(!0), o == null || o.hide(), a == null || a.hide(), z();
12650
12650
  }, q = () => {
12651
12651
  Z(), I();
12652
12652
  }, ee = () => {
12653
12653
  if (s.sam) {
12654
- const A = V.state.store.getAnnotation(s.sam.currentAnnotationId);
12655
- A && (V.removeAnnotation(s.sam.currentAnnotationId), r.emit("deleteAnnotation", A));
12654
+ const O = V.state.store.getAnnotation(s.sam.currentAnnotationId);
12655
+ O && (V.removeAnnotation(s.sam.currentAnnotationId), r.emit("deleteAnnotation", O));
12656
12656
  }
12657
12657
  q();
12658
12658
  };
12659
12659
  e.addHandler("animation-start", E), e.addHandler("animation-finish", P);
12660
12660
  const Q = () => {
12661
- t = !1, n = !1, o == null || o.destroy(), a == null || a.destroy(), z(), e == null || e.setMouseNavEnabled(!0), e == null || e.removeHandler("animation-start", E), e == null || e.removeHandler("animation-finish", P);
12661
+ t = !1, n = !1, o == null || o.destroy(), a == null || a.destroy(), z();
12662
+ try {
12663
+ e == null || e.setMouseNavEnabled(!0), e == null || e.removeHandler("animation-start", E), e == null || e.removeHandler("animation-finish", P);
12664
+ } catch (O) {
12665
+ console.warn(O);
12666
+ }
12662
12667
  }, k = new ke();
12663
- k.onmessage = (A) => {
12664
- const { type: G } = A.data;
12668
+ k.onmessage = (O) => {
12669
+ const { type: G } = O.data;
12665
12670
  if (G === "starting_download")
12666
12671
  r.emit("downloadStart");
12667
12672
  else if (G === "download_progress") {
12668
- const { progress: L } = A.data;
12673
+ const { progress: L } = O.data;
12669
12674
  r.emit("downloadProgress", L);
12670
12675
  } else if (G === "init_success")
12671
12676
  s.isSAMReady = !0, r.emit("initialized"), n && y();
12672
12677
  else if (G === "encode_success") {
12673
- const { viewportVersion: L } = A.data;
12678
+ const { viewportVersion: L } = O.data;
12674
12679
  s.lastEncodingVersion = L, L < s.viewportVersion ? console.log("[a9s-sam] Stale encoding - discarding") : (r.emit("encodingFinished"), s.lastPointerPos && T(s.lastPointerPos));
12675
12680
  } else if (G === "decode_preview_success") {
12676
12681
  if (s.sam && !s.isAnimationInProgress) {
12677
- const { result: L, viewportVersion: X } = A.data;
12682
+ const { result: L, viewportVersion: X } = O.data;
12678
12683
  X === s.viewportVersion ? o.render(L, s.sam.currentBounds) : console.log("[a9s-sam] Stale preview - discarding");
12679
12684
  }
12680
12685
  } else if (G === "decode_success") {
12681
12686
  if (o.clear(), s.sam) {
12682
- const L = Xe(A.data.result, s.sam, V.getUser(), e), { store: X } = V.state, te = X.getAnnotation(s.sam.currentAnnotationId);
12687
+ const L = Xe(O.data.result, s.sam, V.getUser(), e), { store: X } = V.state, te = X.getAnnotation(s.sam.currentAnnotationId);
12683
12688
  te ? (X.updateAnnotation(s.sam.currentAnnotationId, L), r.emit("updateAnnotation", L, te, s.sam.currentPrompt)) : (X.addAnnotation(L), r.emit("createAnnotation", L, s.sam.currentPrompt));
12684
12689
  }
12685
12690
  } else if (G === "init_error") {
12686
- const { error: L } = A.data;
12691
+ const { error: L } = O.data;
12687
12692
  r.emit("initError", L);
12688
12693
  } else if (G === "encode_error") {
12689
- const { viewportVersion: L } = A.data;
12694
+ const { viewportVersion: L } = O.data;
12690
12695
  L === s.viewportVersion && setTimeout(() => y(), 100);
12691
12696
  }
12692
12697
  };
@@ -12701,7 +12706,7 @@ const Ze = /* @__PURE__ */ Oe(je), qe = (V, C = [255, 255, 255, 255], e = [0, 0,
12701
12706
  setQueryMode: j,
12702
12707
  start: I,
12703
12708
  stop: Z,
12704
- on: (A, G) => r.on(A, G)
12709
+ on: (O, G) => r.on(O, G)
12705
12710
  };
12706
12711
  };
12707
12712
  export {