@ezuikit/player-theme 2.1.4-beta.1 → 3.0.0-beta.1

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.mjs CHANGED
@@ -1,16 +1,18 @@
1
1
  /*
2
- * @ezuikit/player-theme v2.1.4-beta.1
3
- * Copyright (c) 2026-03-30 Ezviz-OpenBiz
2
+ * @ezuikit/player-theme v3.0.0-beta.1
3
+ * Copyright (c) 2026-05-04 Ezviz-OpenBiz
4
4
  * Released under the MIT License.
5
5
  */
6
6
  import EventEmitter from 'eventemitter3';
7
7
  import Picker from '@skax/picker';
8
8
  import delegate from '@skax/delegate';
9
9
  import deepmerge from 'deepmerge';
10
- import require$$1, { isMobile, DateTime, parseEzopenUrl } from '@ezuikit/utils-tools';
10
+ import { isMobile, DateTime, parseEzopenUrl } from '@ezuikit/utils-tools';
11
11
  import screenfull from 'screenfull';
12
12
  import I18n from '@ezuikit/utils-i18n';
13
13
  import Logger from '@ezuikit/utils-logger';
14
+ import Zoom$1 from '@ezuikit/control-zoom';
15
+ import { Ptz as Ptz$1, MobilePtz } from '@ezuikit/control-ptz';
14
16
  import { DatePicker } from '@ezuikit/control-date-picker';
15
17
  import { MobileTimeLine, TimeLine } from '@ezuikit/control-time-line';
16
18
 
@@ -4646,7 +4648,7 @@ var ZOOM_DEFAULT_OPTIONS = {
4646
4648
  /**
4647
4649
  * 电子放大控件
4648
4650
  * @category Control
4649
- */ var Zoom$1 = /*#__PURE__*/ function(Control) {
4651
+ */ var Zoom = /*#__PURE__*/ function(Control) {
4650
4652
  _inherits$j(Zoom, Control);
4651
4653
  function Zoom(options) {
4652
4654
  var _this;
@@ -4778,735 +4780,6 @@ var ZOOM_DEFAULT_OPTIONS = {
4778
4780
  return Zoom;
4779
4781
  }(Control);
4780
4782
 
4781
- function getDefaultExportFromCjs (x) {
4782
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
4783
- }
4784
-
4785
- /*
4786
- * @ezuikit/control-zoom v0.0.2
4787
- * Copyright (c) 2026-03-18 Ezviz-OpenBiz
4788
- * Released under the MIT License.
4789
- */
4790
-
4791
- var dist$1;
4792
- var hasRequiredDist$1;
4793
-
4794
- function requireDist$1 () {
4795
- if (hasRequiredDist$1) return dist$1;
4796
- hasRequiredDist$1 = 1;
4797
-
4798
- /**
4799
- * Zoom position
4800
- *
4801
- */ function _defineProperties(target, props) {
4802
- for(var i = 0; i < props.length; i++){
4803
- var descriptor = props[i];
4804
- descriptor.enumerable = descriptor.enumerable || false;
4805
- descriptor.configurable = true;
4806
- if ("value" in descriptor) descriptor.writable = true;
4807
- Object.defineProperty(target, descriptor.key, descriptor);
4808
- }
4809
- }
4810
- function _create_class(Constructor, protoProps, staticProps) {
4811
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
4812
- return Constructor;
4813
- }
4814
- var ZOOM_DEFAULT_POSITION = [
4815
- 0,
4816
- 0
4817
- ];
4818
- /**
4819
- * 默认值
4820
- */ var DefaultOptions = {
4821
- initialZoom: 1,
4822
- defaultCursor: 'pointer',
4823
- scrollVelocity: 0.1,
4824
- animDuration: 0.25,
4825
- allowZoom: true,
4826
- allowPan: true,
4827
- onChange: function() {},
4828
- onTranslateChange: function() {},
4829
- onTap: function() {},
4830
- max: 8,
4831
- min: 1,
4832
- zoomStep: 0.1,
4833
- allowTouchEvents: false,
4834
- allowWheel: true,
4835
- ignoredMouseButtons: [],
4836
- doubleTouchMaxDelay: 300,
4837
- decelerationDuration: 750
4838
- };
4839
- /**
4840
- * dom 节点放大和拖动
4841
- *
4842
- */ var Zoom = /*#__PURE__*/ function() {
4843
- function Zoom(container, options) {
4844
- var _this = this;
4845
- this._dragging = false;
4846
- /**
4847
- * 销毁
4848
- * destroy
4849
- */ this.destroy = function() {
4850
- _this.setAllowZoom(false);
4851
- _this.reset();
4852
- _this.removeEventListeners();
4853
- };
4854
- /**
4855
- * 设置是否旋转
4856
- * @param trans - 是否transform
4857
- */ this.setTransform = function(trans) {
4858
- _this.transform = trans;
4859
- };
4860
- /**
4861
- * 获取是否旋转
4862
- * @returns
4863
- */ this.getTransform = function() {
4864
- return _this.transform;
4865
- };
4866
- /**
4867
- * 更新x轴和Y轴平移值
4868
- */ this.updateTranslate = function() {
4869
- var translateX = 0;
4870
- var translateY = 0;
4871
- if (_this.percentPos[0] < 0) {
4872
- translateX = _this.percentPos[0] < -(0.5 * (_this.zoom - 1)) ? -(0.5 * (_this.zoom - 1)) : _this.percentPos[0];
4873
- } else {
4874
- translateX = _this.percentPos[0] > 0.5 * (_this.zoom - 1) ? 0.5 * (_this.zoom - 1) : _this.percentPos[0];
4875
- }
4876
- if (_this.percentPos[1] < 0) {
4877
- translateY = _this.percentPos[1] < -(0.5 * (_this.zoom - 1)) ? -(0.5 * (_this.zoom - 1)) : _this.percentPos[1];
4878
- } else {
4879
- translateY = _this.percentPos[1] > 0.5 * (_this.zoom - 1) ? 0.5 * (_this.zoom - 1) : _this.percentPos[1];
4880
- }
4881
- _this.percentPos = [
4882
- translateX,
4883
- translateY
4884
- ];
4885
- };
4886
- /**
4887
- * 更新容器样式
4888
- */ this.update = function() {
4889
- if (!_this.container) return;
4890
- _this.updateTranslate();
4891
- _this.container.style.transition = "transform ease-out " + _this.transition + "s";
4892
- _this.container.style.transform = "translate3d(" + _this.percentPos[0] * 100 + "%, " + _this.percentPos[1] * 100 + "%, 0) scale(" + _this.zoom + ")";
4893
- };
4894
- /**
4895
- * 设置支持缩放
4896
- * @param allow
4897
- */ this.setAllowZoom = function(allow) {
4898
- _this.options.allowZoom = allow;
4899
- };
4900
- /**
4901
- * 设置缩放值
4902
- * @param zoom - 缩放值
4903
- * @param reset - 是否重置
4904
- */ this.setZoom = function(zoom, reset) {
4905
- zoom = parseFloat(zoom.toFixed(_this.getPrecision(_this.options.zoomStep)));
4906
- if (_this.zoom !== zoom) {
4907
- _this.zoom = zoom;
4908
- _this.update();
4909
- _this.options.onChange == null ? void 0 : _this.options.onChange.call(_this.options, +_this.zoom.toFixed(_this.getPrecision(_this.options.zoomStep)), reset);
4910
- }
4911
- };
4912
- /**
4913
- * 获取缩放值
4914
- * @returns
4915
- */ this.getZoom = function() {
4916
- return _this.zoom;
4917
- };
4918
- /**
4919
- * 设置位置
4920
- * @param pos - 位置 [X轴坐标转换, Y轴坐标转换]
4921
- */ this.setPos = function(pos) {
4922
- var _this_container, _this_container1;
4923
- var containerWidth = (_this_container = _this.container) == null ? void 0 : _this_container.clientWidth;
4924
- var containerHeight = (_this_container1 = _this.container) == null ? void 0 : _this_container1.clientHeight;
4925
- if (+_this.pos[0] !== pos[0] || +_this.pos[1] !== pos[1]) {
4926
- _this.percentPos = [
4927
- pos[0] / containerWidth,
4928
- pos[1] / containerHeight
4929
- ];
4930
- _this.update();
4931
- _this.options.onTranslateChange == null ? void 0 : _this.options.onTranslateChange.call(_this.options, {
4932
- posX: pos[0],
4933
- posY: pos[1]
4934
- });
4935
- }
4936
- };
4937
- /**
4938
- * 设置过渡时间
4939
- * @param duration - 过渡时间, 单位秒
4940
- */ this.setTransitionDuration = function(duration) {
4941
- _this.transition = duration;
4942
- _this.update();
4943
- };
4944
- /**
4945
- * 设置鼠标样式
4946
- * @param cursor
4947
- * @returns
4948
- */ this.setCursor = function(cursor) {
4949
- if (!_this.container) return;
4950
- _this.container.style.cssText += "cursor:" + cursor + ";";
4951
- _this.cursor = cursor;
4952
- };
4953
- this.zoomIn = function(value) {
4954
- var newPosX = _this.pos[0];
4955
- var newPosY = _this.pos[1];
4956
- var prevZoom = _this.zoom;
4957
- var _this_options_max, _this_options_max1;
4958
- var newZoom = prevZoom + value < ((_this_options_max = _this.options.max) != null ? _this_options_max : 8) ? prevZoom + value : (_this_options_max1 = _this.options.max) != null ? _this_options_max1 : 8;
4959
- if (newZoom !== prevZoom) {
4960
- newPosX = newPosX * (newZoom - 1) / (prevZoom > 1 ? prevZoom - 1 : prevZoom);
4961
- newPosY = newPosY * (newZoom - 1) / (prevZoom > 1 ? prevZoom - 1 : prevZoom);
4962
- }
4963
- _this.setZoom(newZoom);
4964
- _this.setPos([
4965
- newPosX,
4966
- newPosY
4967
- ]);
4968
- _this.setTransitionDuration(_this.options.animDuration);
4969
- };
4970
- this.zoomOut = function(value) {
4971
- var newPosX = _this.pos[0];
4972
- var newPosY = _this.pos[1];
4973
- var prevZoom = _this.zoom;
4974
- var _this_options_min, _this_options_min1;
4975
- var newZoom = prevZoom - value > ((_this_options_min = _this.options.min) != null ? _this_options_min : 1) ? prevZoom - value : (_this_options_min1 = _this.options.min) != null ? _this_options_min1 : 1;
4976
- if (newZoom !== prevZoom) {
4977
- newPosX = newPosX * (newZoom - 1) / (prevZoom - 1);
4978
- newPosY = newPosY * (newZoom - 1) / (prevZoom - 1);
4979
- }
4980
- _this.setZoom(newZoom);
4981
- _this.setPos([
4982
- newPosX,
4983
- newPosY
4984
- ]);
4985
- _this.setTransitionDuration(_this.options.animDuration);
4986
- };
4987
- this.zoomToZone = function(relX, relY, relWidth, relHeight) {
4988
- var _this_container;
4989
- if (!_this.container) return;
4990
- var newPosX = _this.pos[0];
4991
- var newPosY = _this.pos[1];
4992
- var parentRect = ((_this_container = _this.container) == null ? void 0 : _this_container.parentNode).getBoundingClientRect();
4993
- var prevZoom = _this.zoom;
4994
- // Calculate zoom factor to scale the zone
4995
- var optimalZoomX = parentRect.width / relWidth;
4996
- var optimalZoomY = parentRect.height / relHeight;
4997
- var _this_options_max;
4998
- var newZoom = Math.min(optimalZoomX, optimalZoomY, (_this_options_max = _this.options.max) != null ? _this_options_max : 8);
4999
- // Calculate new position to center the zone
5000
- var rect = _this.container.getBoundingClientRect();
5001
- var _ref = [
5002
- rect.width / prevZoom / 2,
5003
- rect.height / prevZoom / 2
5004
- ], centerX = _ref[0], centerY = _ref[1];
5005
- var _ref1 = [
5006
- relX + relWidth / 2,
5007
- relY + relHeight / 2
5008
- ], zoneCenterX = _ref1[0], zoneCenterY = _ref1[1];
5009
- newPosX = (centerX - zoneCenterX) * newZoom;
5010
- newPosY = (centerY - zoneCenterY) * newZoom;
5011
- _this.setZoom(newZoom);
5012
- _this.setPos([
5013
- newPosX,
5014
- newPosY
5015
- ]);
5016
- _this.setTransitionDuration(_this.options.animDuration);
5017
- };
5018
- this.getNewPosition = function(x, y, newZoom) {
5019
- var _ref = [
5020
- _this.zoom,
5021
- _this.pos[0],
5022
- _this.pos[1]
5023
- ], prevZoom = _ref[0];
5024
- if (newZoom === 1 || !_this) return ZOOM_DEFAULT_POSITION;
5025
- var _ref1 = [
5026
- _this.container.clientWidth,
5027
- _this.container.clientHeight
5028
- ], clientWidth = _ref1[0], clientHeight = _ref1[1];
5029
- if (newZoom > prevZoom) {
5030
- return [
5031
- 0,
5032
- 0
5033
- ];
5034
- } else {
5035
- // 放到最大
5036
- var w = -((x - clientWidth / 2) / (clientWidth / 2)) * newZoom / 2;
5037
- var h = -((y - clientHeight / 2) / (clientHeight / 2)) * newZoom / 2;
5038
- if (w > newZoom / 2 - 0.5) {
5039
- w = 3.5;
5040
- }
5041
- if (h > newZoom / 2 - 0.5) {
5042
- h = 3.5;
5043
- }
5044
- return [
5045
- clientWidth * w,
5046
- clientHeight * h
5047
- ];
5048
- }
5049
- };
5050
- /**
5051
- * 缩放到最大
5052
- * @param x - 点击点X坐标
5053
- * @param y - 点击点Y坐标
5054
- */ this.fullZoomInOnPosition = function(x, y) {
5055
- var _this_options_max;
5056
- var zoom = (_this_options_max = _this.options.max) != null ? _this_options_max : DefaultOptions.max;
5057
- _this.setZoom(zoom != null ? zoom : DefaultOptions.max);
5058
- _this.setPos(_this.getNewPosition(x, y, zoom));
5059
- _this.setTransitionDuration(_this.options.animDuration);
5060
- };
5061
- this.getLimitedShift = function(shift, minLimit, maxLimit, minElement, maxElement) {
5062
- if (shift > 0) {
5063
- if (minElement > minLimit) {
5064
- return 0;
5065
- } else if (minElement + shift > minLimit) {
5066
- return minLimit - minElement;
5067
- }
5068
- } else if (shift < 0) {
5069
- if (maxElement < maxLimit) {
5070
- return 0;
5071
- } else if (maxElement + shift < maxLimit) {
5072
- return maxLimit - maxElement;
5073
- }
5074
- }
5075
- return shift;
5076
- };
5077
- this.getCursor = function(canMoveOnX, canMoveOnY) {
5078
- if (canMoveOnX && canMoveOnY) {
5079
- return 'move';
5080
- } else if (canMoveOnX) {
5081
- return 'ew-resize';
5082
- } else if (canMoveOnY) {
5083
- return 'ns-resize';
5084
- } else {
5085
- return 'auto';
5086
- }
5087
- };
5088
- this.move = function(shiftX, shiftY, transitionDuration) {
5089
- if (transitionDuration === void 0) transitionDuration = 0;
5090
- if (!_this.container) return;
5091
- var newPosX = _this.pos[0];
5092
- var newPosY = _this.pos[1];
5093
- // let canMoveOnX: boolean, canMoveOnY: boolean;
5094
- var rect = _this.container.getBoundingClientRect();
5095
- var parentRect = _this.container.parentNode.getBoundingClientRect();
5096
- // 根据是否进行了伪横屏旋转,决定是使用 shiftX 还是 shiftY 来对画面进行移动
5097
- var shiftHorizontal = _this.transform ? shiftY : shiftX;
5098
- var shiftVertical = _this.transform ? shiftX : shiftY;
5099
- var _ref = _this.transform ? [
5100
- rect.height > parentRect.bottom - parentRect.top,
5101
- shiftVertical > 0 && rect.top - parentRect.top < 0,
5102
- shiftVertical < 0 && rect.bottom - parentRect.bottom > 0
5103
- ] : [
5104
- rect.width > parentRect.right - parentRect.left,
5105
- shiftHorizontal > 0 && rect.left - parentRect.left < 0,
5106
- shiftHorizontal < 0 && rect.right - parentRect.right > 0
5107
- ], isLargerHor = _ref[0], isOutLeftBoundary = _ref[1], isOutRightBoundary = _ref[2];
5108
- var canMoveOnX = isLargerHor || isOutLeftBoundary || isOutRightBoundary;
5109
- if (canMoveOnX) {
5110
- if (_this.transform) {
5111
- newPosX += _this.getLimitedShift(shiftVertical, parentRect.top, parentRect.bottom, rect.top, rect.bottom);
5112
- } else {
5113
- newPosX += _this.getLimitedShift(shiftHorizontal, parentRect.left, parentRect.right, rect.left, rect.right);
5114
- }
5115
- }
5116
- var _ref1 = _this.transform ? [
5117
- rect.width > parentRect.right - parentRect.left,
5118
- shiftHorizontal > 0 && rect.right - parentRect.right < 0,
5119
- shiftHorizontal < 0 && rect.left - parentRect.left > 0
5120
- ] : [
5121
- rect.height > parentRect.bottom - parentRect.top,
5122
- shiftVertical > 0 && rect.top - parentRect.top < 0,
5123
- shiftVertical < 0 && rect.bottom - parentRect.bottom > 0
5124
- ], isLargerVer = _ref1[0], isOutTopBoundary = _ref1[1], isOutBottomBoundary = _ref1[2];
5125
- var canMoveOnY = isLargerVer || isOutTopBoundary || isOutBottomBoundary;
5126
- if (canMoveOnY) {
5127
- if (_this.transform) {
5128
- var transformGetLimitedShift = function(shift, minLimit, maxLimit, minElement, maxElement) {
5129
- // css伪横屏边界判断特殊处理
5130
- if (shift > 0) {
5131
- if (maxElement < maxLimit + 1) {
5132
- return 0;
5133
- } else if (maxElement + shift < maxLimit + 1) {
5134
- return maxLimit - maxElement;
5135
- }
5136
- } else if (shift < 0) {
5137
- if (minElement + 1 > minLimit) {
5138
- return 0;
5139
- } else if (minElement + 1 + shift > minLimit) {
5140
- return minLimit - minElement;
5141
- }
5142
- }
5143
- return shift;
5144
- };
5145
- newPosY += transformGetLimitedShift(shiftHorizontal, parentRect.left, parentRect.right, rect.left, rect.right);
5146
- } else {
5147
- newPosY += _this.getLimitedShift(shiftVertical, parentRect.top, parentRect.bottom, rect.top, rect.bottom);
5148
- }
5149
- }
5150
- var cursor = _this.getCursor(canMoveOnX, canMoveOnY);
5151
- _this.setPos([
5152
- newPosX,
5153
- newPosY
5154
- ]);
5155
- _this.setCursor(cursor);
5156
- _this.setTransitionDuration(transitionDuration);
5157
- };
5158
- /**
5159
- * 移动端双击
5160
- * @returns
5161
- */ this.isDoubleTapping = function() {
5162
- var touchTime = new Date().getTime();
5163
- var _this_lastTouchTime, _this_options_doubleTouchMaxDelay, _this_lastDoubleTapTime, _this_options_doubleTouchMaxDelay1;
5164
- var isDoubleTap = touchTime - ((_this_lastTouchTime = _this.lastTouchTime) != null ? _this_lastTouchTime : 0) < ((_this_options_doubleTouchMaxDelay = _this.options.doubleTouchMaxDelay) != null ? _this_options_doubleTouchMaxDelay : 300) && touchTime - ((_this_lastDoubleTapTime = _this.lastDoubleTapTime) != null ? _this_lastDoubleTapTime : 0) > ((_this_options_doubleTouchMaxDelay1 = _this.options.doubleTouchMaxDelay) != null ? _this_options_doubleTouchMaxDelay1 : 750);
5165
- if (isDoubleTap) {
5166
- _this.lastDoubleTapTime = touchTime;
5167
- return true;
5168
- }
5169
- _this.lastTouchTime = touchTime;
5170
- return false;
5171
- };
5172
- this.startDeceleration = function(lastShiftOnX, lastShiftOnY) {
5173
- var startTimestamp = null;
5174
- var startDecelerationMove = function(timestamp) {
5175
- if (startTimestamp === null) startTimestamp = timestamp;
5176
- var progress = timestamp - startTimestamp;
5177
- var _this_options_decelerationDuration, _this_options_decelerationDuration1;
5178
- var ratio = (((_this_options_decelerationDuration = _this.options.decelerationDuration) != null ? _this_options_decelerationDuration : 750) - progress) / ((_this_options_decelerationDuration1 = _this.options.decelerationDuration) != null ? _this_options_decelerationDuration1 : 750);
5179
- var _ref = [
5180
- lastShiftOnX * ratio,
5181
- lastShiftOnY * ratio
5182
- ], shiftX = _ref[0], shiftY = _ref[1];
5183
- var _this_options_decelerationDuration2;
5184
- if (progress < ((_this_options_decelerationDuration2 = _this.options.decelerationDuration) != null ? _this_options_decelerationDuration2 : 750) && Math.max(Math.abs(shiftX), Math.abs(shiftY)) > 1) {
5185
- _this.move(shiftX, shiftY, 0);
5186
- _this.lastRequestAnimationId = requestAnimationFrame(startDecelerationMove);
5187
- } else {
5188
- _this.lastRequestAnimationId = null;
5189
- }
5190
- };
5191
- _this.lastRequestAnimationId = requestAnimationFrame(startDecelerationMove);
5192
- };
5193
- this.reset = function() {
5194
- _this.setZoom(_this.options.initialZoom, true);
5195
- _this.cursor = _this.options.defaultCursor;
5196
- _this.setTransitionDuration(_this.options.animDuration);
5197
- _this.setPos(ZOOM_DEFAULT_POSITION);
5198
- };
5199
- // api向前兼容
5200
- this.addScale = function(scale) {
5201
- if (scale === void 0) scale = 1;
5202
- _this.handleZoomAdd(scale);
5203
- };
5204
- this.handleZoomAdd = function(scale) {
5205
- if (scale === void 0) scale = 1;
5206
- if (!_this.options.allowZoom || !_this.options.allowWheel) return;
5207
- var newZoom = parseFloat((_this.zoom + scale).toFixed(_this.getPrecision(_this.options.zoomStep)));
5208
- var _this_options_max;
5209
- if (newZoom > ((_this_options_max = _this.options.max) != null ? _this_options_max : 8)) {
5210
- newZoom = 8;
5211
- }
5212
- _this.setZoom(newZoom);
5213
- _this.setPos(_this.pos);
5214
- _this.setTransitionDuration(0.05);
5215
- };
5216
- // api向前兼容
5217
- this.subScale = function(scale) {
5218
- if (scale === void 0) scale = 1;
5219
- _this.handleZoomSub(scale);
5220
- };
5221
- this.handleZoomSub = function(scale) {
5222
- if (scale === void 0) scale = 1;
5223
- if (!_this.options.allowZoom || !_this.options.allowWheel) return;
5224
- var newZoom = parseFloat((_this.zoom - scale).toFixed(_this.getPrecision(_this.options.zoomStep)));
5225
- if (newZoom < 1) {
5226
- newZoom = 1;
5227
- }
5228
- _this.setZoom(newZoom);
5229
- _this.setPos(_this.pos);
5230
- _this.setTransitionDuration(0.05);
5231
- };
5232
- this.handleMouseWheel = function(event) {
5233
- event.preventDefault();
5234
- if (!_this.options.allowZoom || !_this.options.allowWheel) return;
5235
- var velocity = event.deltaY < 0 ? _this.options.scrollVelocity : 0 - _this.options.scrollVelocity;
5236
- var _this_options_max, _this_options_min;
5237
- var newZoom = parseFloat(Math.max(Math.min(_this.zoom + velocity, (_this_options_max = _this.options.max) != null ? _this_options_max : 8), (_this_options_min = _this.options.min) != null ? _this_options_min : 1).toFixed(_this.getPrecision(_this.options.zoomStep)));
5238
- _this.setZoom(newZoom);
5239
- // this.setPos(this.getNewPosition(posX, posY, newZoom));
5240
- _this.setTransitionDuration(0.05);
5241
- };
5242
- this.handleMouseStart = function(event) {
5243
- var _this_options_ignoredMouseButtons;
5244
- event.preventDefault();
5245
- if (!_this.options.allowPan || ((_this_options_ignoredMouseButtons = _this.options.ignoredMouseButtons) == null ? void 0 : _this_options_ignoredMouseButtons.includes(event.button))) return;
5246
- _this._dragging = true;
5247
- if (_this.lastRequestAnimationId) cancelAnimationFrame(_this.lastRequestAnimationId);
5248
- _this.lastCursor = _this.getCoordinates(event);
5249
- };
5250
- this.handleMouseMove = function(event) {
5251
- event.preventDefault();
5252
- if (!_this.options.allowPan || !_this.lastCursor || !_this._dragging) return;
5253
- _this._touchOrMouseDrag(event);
5254
- };
5255
- this.handleMouseStop = function(event) {
5256
- event.preventDefault();
5257
- if (_this.lastShift) {
5258
- _this.startDeceleration(_this.lastShift[0], _this.lastShift[1]);
5259
- _this.lastShift = null;
5260
- }
5261
- _this.lastCursor = null;
5262
- _this.setCursor('auto');
5263
- _this._dragging = false;
5264
- };
5265
- this.handleTouchStart = function(event) {
5266
- var isThisDoubleTapping = _this.isDoubleTapping();
5267
- _this.isMultiTouch = event.touches.length;
5268
- if (!_this.options.allowTouchEvents) event.preventDefault();
5269
- if (_this.lastRequestAnimationId) cancelAnimationFrame(_this.lastRequestAnimationId);
5270
- var _this_getCoordinates = _this.getCoordinates(event.touches[0]), posX = _this_getCoordinates[0], posY = _this_getCoordinates[1];
5271
- if (_this.isMultiTouch > 1) {
5272
- _this.lastCursor = [
5273
- posX,
5274
- posY
5275
- ];
5276
- return;
5277
- }
5278
- if (isThisDoubleTapping && _this.options.allowZoom) {
5279
- if (_this.zoom === 1) {
5280
- var _this_container_getBoundingClientRect = _this.container.getBoundingClientRect(); _this_container_getBoundingClientRect.top; _this_container_getBoundingClientRect.left; var x = _this_container_getBoundingClientRect.x, y = _this_container_getBoundingClientRect.y;
5281
- var ref;
5282
- ref = _this.transform ? [
5283
- y,
5284
- x
5285
- ] : [
5286
- x,
5287
- y
5288
- ], x = ref[0], y = ref[1];
5289
- var ref1;
5290
- ref1 = [
5291
- posX - x,
5292
- posY - y
5293
- ], posX = ref1[0], posY = ref1[1];
5294
- // 双击放大到最大
5295
- _this.fullZoomInOnPosition(posX, posY);
5296
- } else {
5297
- _this.reset();
5298
- }
5299
- return;
5300
- }
5301
- _this._tapStartTime = new Date().getTime();
5302
- if (_this.options.allowPan) _this.lastCursor = [
5303
- posX,
5304
- posY
5305
- ];
5306
- };
5307
- this.handleTouchMove = function(event) {
5308
- if (!_this.options.allowTouchEvents) event.preventDefault();
5309
- if (!_this.lastCursor) return;
5310
- if (_this.isMultiTouch === 1) {
5311
- _this._touchOrMouseDrag(event.touches[0]);
5312
- _this.lastTouchDistance = null;
5313
- } else if (_this.isMultiTouch > 1) {
5314
- var newZoom = _this.zoom;
5315
- // If we detect two points, we shall zoom up or down
5316
- var _this_getCoordinates = _this.getCoordinates(event.touches[0]), pos1X = _this_getCoordinates[0], pos1Y = _this_getCoordinates[1];
5317
- var _this_getCoordinates1 = _this.getCoordinates(event.touches[1]), pos2X = _this_getCoordinates1[0], pos2Y = _this_getCoordinates1[1];
5318
- var distance = Math.sqrt(Math.pow(pos2X - pos1X, 2) + Math.pow(pos2Y - pos1Y, 2));
5319
- if (_this.lastTouchDistance && distance && distance !== _this.lastTouchDistance) {
5320
- if (_this.options.allowZoom) {
5321
- newZoom += (distance - _this.lastTouchDistance) / 100;
5322
- var _this_options_max, _this_options_min;
5323
- if (newZoom > ((_this_options_max = _this.options.max) != null ? _this_options_max : 8)) {
5324
- var _this_options_max1;
5325
- newZoom = (_this_options_max1 = _this.options.max) != null ? _this_options_max1 : 8;
5326
- } else if (newZoom < ((_this_options_min = _this.options.min) != null ? _this_options_min : 1)) {
5327
- var _this_options_min1;
5328
- newZoom = (_this_options_min1 = _this.options.min) != null ? _this_options_min1 : 1;
5329
- }
5330
- }
5331
- // 不要做移动,因为会有冲突
5332
- _this.setZoom(newZoom);
5333
- _this.setTransitionDuration(0);
5334
- }
5335
- // Save data for the next move
5336
- _this.lastCursor = [
5337
- pos1X,
5338
- pos1Y
5339
- ];
5340
- _this.lastTouchDistance = distance;
5341
- }
5342
- };
5343
- this.handleTouchStop = function() {
5344
- if (_this.lastShift) {
5345
- // Use the last shift to make a decelerating movement effect
5346
- _this.startDeceleration(_this.lastShift[0], _this.lastShift[1]);
5347
- _this.lastShift = null;
5348
- }
5349
- if (_this._tapStartTime && new Date().getTime() - _this._tapStartTime < 200) {
5350
- _this.options.onTap == null ? void 0 : _this.options.onTap.call(_this.options);
5351
- }
5352
- _this._tapStartTime = undefined;
5353
- _this.lastCursor = null;
5354
- _this.lastTouchDistance = null;
5355
- _this.isMultiTouch = 0;
5356
- };
5357
- this.container = container;
5358
- this.options = Object.assign({}, DefaultOptions, options || {});
5359
- this.percentPos = ZOOM_DEFAULT_POSITION;
5360
- this.transition = this.options.animDuration;
5361
- this.zoom = 1;
5362
- this.cursor = 'auto';
5363
- this.lastCursor = [
5364
- 0,
5365
- 0
5366
- ];
5367
- this.lastShift = null;
5368
- this.lastTouchDistance = null;
5369
- this.lastRequestAnimationId = null;
5370
- this.lastTouchTime = new Date().getTime();
5371
- this.lastDoubleTapTime = new Date().getTime();
5372
- this.transform = false; // 是否为横屏模式
5373
- this.isMultiTouch = 1;
5374
- this.handleMouseMove = this.handleMouseMove.bind(this);
5375
- this.handleMouseStart = this.handleMouseStart.bind(this);
5376
- this.handleMouseStop = this.handleMouseStop.bind(this);
5377
- this.handleMouseWheel = this.handleMouseWheel.bind(this);
5378
- this.handleTouchStart = this.handleTouchStart.bind(this);
5379
- this.handleTouchMove = this.handleTouchMove.bind(this);
5380
- this.handleTouchStop = this.handleTouchStop.bind(this);
5381
- this.getZoom = this.getZoom.bind(this);
5382
- this.setZoom = this.setZoom.bind(this);
5383
- }
5384
- var _proto = Zoom.prototype;
5385
- // 设置事件侦听器
5386
- _proto.setUpEventListeners = function setUpEventListeners() {
5387
- var refCurrentValue = this.container;
5388
- var hasMouseDevice = window.matchMedia('(pointer: fine)').matches;
5389
- if (hasMouseDevice) {
5390
- if (this.options.allowWheel) {
5391
- refCurrentValue == null ? void 0 : refCurrentValue.addEventListener('wheel', this.handleMouseWheel, {
5392
- passive: false
5393
- });
5394
- }
5395
- // Apply mouse events only to devices which include an accurate pointing device
5396
- refCurrentValue == null ? void 0 : refCurrentValue.addEventListener('mousedown', this.handleMouseStart, {
5397
- passive: false
5398
- });
5399
- refCurrentValue == null ? void 0 : refCurrentValue.addEventListener('mousemove', this.handleMouseMove, {
5400
- passive: false
5401
- });
5402
- refCurrentValue == null ? void 0 : refCurrentValue.addEventListener('mouseup', this.handleMouseStop, {
5403
- passive: false
5404
- });
5405
- refCurrentValue == null ? void 0 : refCurrentValue.addEventListener('mouseleave', this.handleMouseStop, {
5406
- passive: false
5407
- });
5408
- } else {
5409
- // Apply touch events to all other devices
5410
- refCurrentValue == null ? void 0 : refCurrentValue.addEventListener('touchstart', this.handleTouchStart, {
5411
- passive: false
5412
- });
5413
- refCurrentValue == null ? void 0 : refCurrentValue.addEventListener('touchmove', this.handleTouchMove, {
5414
- passive: false
5415
- });
5416
- refCurrentValue == null ? void 0 : refCurrentValue.addEventListener('touchend', this.handleTouchStop, {
5417
- passive: false
5418
- });
5419
- refCurrentValue == null ? void 0 : refCurrentValue.addEventListener('touchcancel', this.handleTouchStop, {
5420
- passive: false
5421
- });
5422
- }
5423
- };
5424
- // 移除事件侦听器
5425
- _proto.removeEventListeners = function removeEventListeners() {
5426
- var refCurrentValue = this.container;
5427
- var hasMouseDevice = window.matchMedia('(pointer: fine)').matches;
5428
- if (hasMouseDevice) {
5429
- if (this.options.allowWheel) {
5430
- refCurrentValue == null ? void 0 : refCurrentValue.removeEventListener('wheel', this.handleMouseWheel);
5431
- }
5432
- refCurrentValue == null ? void 0 : refCurrentValue.removeEventListener('mousedown', this.handleMouseStart);
5433
- refCurrentValue == null ? void 0 : refCurrentValue.removeEventListener('mousemove', this.handleMouseMove);
5434
- refCurrentValue == null ? void 0 : refCurrentValue.removeEventListener('mouseup', this.handleMouseStop);
5435
- refCurrentValue == null ? void 0 : refCurrentValue.removeEventListener('mouseleave', this.handleMouseStop);
5436
- } else {
5437
- refCurrentValue == null ? void 0 : refCurrentValue.removeEventListener('touchstart', this.handleTouchStart);
5438
- refCurrentValue == null ? void 0 : refCurrentValue.removeEventListener('touchmove', this.handleTouchMove);
5439
- refCurrentValue == null ? void 0 : refCurrentValue.removeEventListener('touchend', this.handleTouchStop);
5440
- refCurrentValue == null ? void 0 : refCurrentValue.removeEventListener('touchcancel', this.handleTouchStop);
5441
- }
5442
- };
5443
- _proto.getPrecision = function getPrecision(value) {
5444
- if (value === void 0) value = 1;
5445
- var valueStr = value.toString();
5446
- if (valueStr.includes('.')) {
5447
- return valueStr.split('.')[1].length;
5448
- } else {
5449
- return 1;
5450
- }
5451
- };
5452
- /**
5453
- * 获取坐标 (伪横屏X、Y轴坐标转换, 相对值)
5454
- * @param event
5455
- * @returns
5456
- */ _proto.getCoordinates = function getCoordinates(event) {
5457
- var clientHeight = this.container.clientHeight;
5458
- var clientTop = this.container.clientTop;
5459
- var clientLeft = this.container.clientLeft;
5460
- var _ref = this.transform ? [
5461
- event.clientY,
5462
- clientHeight - event.clientX
5463
- ] : [
5464
- event.clientX - clientTop,
5465
- event.clientY - clientLeft
5466
- ], x1 = _ref[0], y1 = _ref[1];
5467
- return [
5468
- x1,
5469
- y1
5470
- ];
5471
- };
5472
- _proto._touchOrMouseDrag = function _touchOrMouseDrag(event) {
5473
- if (this.lastCursor) {
5474
- var _this_getCoordinates = this.getCoordinates(event), posX = _this_getCoordinates[0], posY = _this_getCoordinates[1];
5475
- var shiftX = posX - this.lastCursor[0];
5476
- var shiftY = posY - this.lastCursor[1];
5477
- this.move(shiftX, shiftY, 0);
5478
- this.lastCursor = [
5479
- posX,
5480
- posY
5481
- ];
5482
- this.lastShift = [
5483
- shiftX,
5484
- shiftY
5485
- ];
5486
- }
5487
- };
5488
- _create_class(Zoom, [
5489
- {
5490
- key: "pos",
5491
- get: function get() {
5492
- return [
5493
- this.container.clientWidth * this.percentPos[0],
5494
- this.container.clientHeight * this.percentPos[1]
5495
- ];
5496
- }
5497
- }
5498
- ]);
5499
- return Zoom;
5500
- }();
5501
- Zoom.VERSION = '0.0.2';
5502
-
5503
- dist$1 = Zoom;
5504
- return dist$1;
5505
- }
5506
-
5507
- var distExports$1 = requireDist$1();
5508
- var Zoom = /*@__PURE__*/getDefaultExportFromCjs(distExports$1);
5509
-
5510
4783
  function _extends$j() {
5511
4784
  _extends$j = Object.assign || function(target) {
5512
4785
  for(var i = 1; i < arguments.length; i++){
@@ -5522,7 +4795,7 @@ function _extends$j() {
5522
4795
  return _extends$j.apply(this, arguments);
5523
4796
  }
5524
4797
  function __zoom(theme, container, options) {
5525
- theme.zoomUtil = new Zoom(container, _extends$j({}, options || {}, {
4798
+ theme.zoomUtil = new Zoom$1(container, _extends$j({}, options || {}, {
5526
4799
  min: 1,
5527
4800
  onChange: function(zoom, reset) {
5528
4801
  if (zoom !== theme._zoom) {
@@ -6576,949 +5849,6 @@ function _set_prototype_of$f(o, p) {
6576
5849
  return CapturePicture;
6577
5850
  }(Control);
6578
5851
 
6579
- var dist = {};
6580
-
6581
- /*
6582
- * @ezuikit/control-ptz v0.0.1
6583
- * Copyright (c) 2026-03-18 Ezviz-OpenBiz
6584
- * Released under the MIT License.
6585
- */
6586
-
6587
- var hasRequiredDist;
6588
-
6589
- function requireDist () {
6590
- if (hasRequiredDist) return dist;
6591
- hasRequiredDist = 1;
6592
-
6593
- var deepmerge$1 = deepmerge;
6594
- var utilsTools = require$$1;
6595
-
6596
- var en_US = {
6597
- GET_PTZ_STATUS: 'Get current PTZ status',
6598
- GET_PTZ_STATUS_FAILED: 'Theme module is not loaded, PTZ status cannot be obtained',
6599
- MOBILE_HIDE_PTZ: 'Mobile terminal, PTZ is not displayed in non-full screen state',
6600
- OPTION_PTZ_FAILED: 'Theme module is not loaded, PTZ cannot be operated',
6601
- MOBILE_PTZ_TIPS: 'Adjust camera angle by manipulating gimbal',
6602
- PTZ_FAST: 'F',
6603
- PTZ_MID: 'M',
6604
- PTZ_SLOW: 'S',
6605
- PTZ_SPEED: 'Adjust the PTZ rotation speed',
6606
- DEVICE_ZOOM: 'Control the device to zoom in/out of the screen',
6607
- DEVICE_FOCUS: "Adjusting the device's focal length"
6608
- };
6609
-
6610
- var zh_CN = {
6611
- GET_PTZ_STATUS: '获取当前云台状态',
6612
- GET_PTZ_STATUS_FAILED: '未加载Theme模块,无法获取云台状态',
6613
- MOBILE_HIDE_PTZ: '移动端,非全屏状态不展示云台',
6614
- OPTION_PTZ_FAILED: '未加载Theme模块,无法操作云台',
6615
- MOBILE_PTZ_TIPS: '请通过操控云台来调整摄像机视角',
6616
- PTZ_FAST: '快',
6617
- PTZ_MID: '中',
6618
- PTZ_SLOW: '慢',
6619
- PTZ_SPEED: '调整云台转动速度',
6620
- DEVICE_ZOOM: '控制设备放大/缩小画面',
6621
- DEVICE_FOCUS: '调整设备焦距'
6622
- };
6623
-
6624
- var PTZ_DEFAULT_OPTIONS = {
6625
- language: 'zh',
6626
- env: {
6627
- domain: 'https://open.ys7.com'
6628
- },
6629
- accessToken: '',
6630
- speed: 2,
6631
- locales: {
6632
- zh: zh_CN,
6633
- en: en_US
6634
- }
6635
- };
6636
- var PTZ_SPEED = {
6637
- 1: 1,
6638
- 2: 3,
6639
- 3: 7,
6640
- slow: 1,
6641
- mid: 3,
6642
- fast: 7
6643
- };
6644
- var PTZ_PREFIX = 'ez-ptz';
6645
- var PTZ_MOBILE_PREFIX = 'ez-mobile-ptz';
6646
- var PTZ_SPEED_ACTIVE_PREFIX = PTZ_PREFIX + '-speed-active';
6647
- var PTZ_DIRECTION_PREFIX = PTZ_PREFIX + '-direction';
6648
-
6649
- var BasePtz = /*#__PURE__*/ function() {
6650
- function BasePtz(container, options) {
6651
- if (options === void 0) options = {};
6652
- var _this_options_locales;
6653
- if (!container) throw new Error('Ptz container is required');
6654
- this.options = deepmerge$1(PTZ_DEFAULT_OPTIONS, options, {
6655
- clone: false
6656
- });
6657
- if ((_this_options_locales = this.options.locales) == null ? void 0 : _this_options_locales[this.options.language]) {
6658
- var _this_options_locales1;
6659
- this.locale = (_this_options_locales1 = this.options.locales) == null ? void 0 : _this_options_locales1[this.options.language];
6660
- } else {
6661
- var _this_options_locales2;
6662
- this.locale = (_this_options_locales2 = this.options.locales) == null ? void 0 : _this_options_locales2['zh'];
6663
- }
6664
- this.$container = container;
6665
- this.speed = PTZ_SPEED[this.options.speed || 2];
6666
- }
6667
- var _proto = BasePtz.prototype;
6668
- _proto.updateOptions = function updateOptions(options) {
6669
- this.options = deepmerge$1(this.options, options, {
6670
- clone: false
6671
- });
6672
- };
6673
- _proto.destroy = function destroy() {};
6674
- return BasePtz;
6675
- }();
6676
-
6677
- function _inherits$1(subClass, superClass) {
6678
- if (typeof superClass !== "function" && superClass !== null) {
6679
- throw new TypeError("Super expression must either be null or a function");
6680
- }
6681
- subClass.prototype = Object.create(superClass && superClass.prototype, {
6682
- constructor: {
6683
- value: subClass,
6684
- writable: true,
6685
- configurable: true
6686
- }
6687
- });
6688
- if (superClass) _set_prototype_of$1(subClass, superClass);
6689
- }
6690
- function _set_prototype_of$1(o, p) {
6691
- _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
6692
- o.__proto__ = p;
6693
- return o;
6694
- };
6695
- return _set_prototype_of$1(o, p);
6696
- }
6697
- var MobilePtz = /*#__PURE__*/ function(BasePtz) {
6698
- _inherits$1(MobilePtz, BasePtz);
6699
- function MobilePtz(container, options) {
6700
- var _this;
6701
- _this = BasePtz.call(this, container, options) || this;
6702
- _this._touchstart = _this._touchstart.bind(_this);
6703
- _this._touchend = _this._touchend.bind(_this);
6704
- _this._render();
6705
- return _this;
6706
- }
6707
- var _proto = MobilePtz.prototype;
6708
- _proto.destroy = function destroy() {
6709
- this._removeEventListener();
6710
- if (this.$content) {
6711
- this.$content.remove();
6712
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
6713
- this.$content = null;
6714
- }
6715
- BasePtz.prototype.destroy.call(this);
6716
- };
6717
- _proto._render = function _render() {
6718
- this.$content = document.createElement('div');
6719
- this.$content.classList.add(PTZ_MOBILE_PREFIX + '-content');
6720
- this.$content.innerHTML = '\n <div class="' + PTZ_MOBILE_PREFIX + '-wrap">\n <div class="' + PTZ_MOBILE_PREFIX + '-container">\n <div class="' + PTZ_MOBILE_PREFIX + "-center " + PTZ_MOBILE_PREFIX + '-center"></div>\n <div class="' + PTZ_MOBILE_PREFIX + "-icon " + PTZ_MOBILE_PREFIX + "-top " + PTZ_MOBILE_PREFIX + '-default"></div>\n <div class="' + PTZ_MOBILE_PREFIX + "-icon " + PTZ_MOBILE_PREFIX + "-left " + PTZ_MOBILE_PREFIX + '-default"></div>\n <div class="' + PTZ_MOBILE_PREFIX + "-icon " + PTZ_MOBILE_PREFIX + "-bottom " + PTZ_MOBILE_PREFIX + '-default"></div>\n <div class="' + PTZ_MOBILE_PREFIX + "-icon " + PTZ_MOBILE_PREFIX + "-right " + PTZ_MOBILE_PREFIX + '-default"></div>\n </div>\n </div>\n ';
6721
- this.$container.appendChild(this.$content);
6722
- this._addEventListener();
6723
- };
6724
- _proto._addEventListener = function _addEventListener() {
6725
- // 云台控制事件绑定
6726
- var $warp = this.$content.querySelector("." + PTZ_MOBILE_PREFIX + "-wrap");
6727
- var touchstart = 'PointerEvent' in window ? 'pointerdown' : 'touchstart';
6728
- var touchend = 'PointerEvent' in window ? 'pointerup' : 'touchend';
6729
- if ($warp) {
6730
- $warp.addEventListener(touchstart, this._touchstart);
6731
- $warp.addEventListener(touchend, this._touchend);
6732
- }
6733
- };
6734
- _proto._touchstart = function _touchstart(e) {
6735
- e.preventDefault();
6736
- this._handlePtzTouch(e, 'start');
6737
- };
6738
- _proto._touchend = function _touchend(e) {
6739
- e.preventDefault();
6740
- this._handlePtzTouch(e, 'stop');
6741
- };
6742
- _proto._removeEventListener = function _removeEventListener() {
6743
- var $warp = this.$content.querySelector("." + PTZ_MOBILE_PREFIX + "-wrap");
6744
- var touchstart = 'PointerEvent' in window ? 'pointerdown' : 'touchstart';
6745
- var touchend = 'PointerEvent' in window ? 'pointerup' : 'touchend';
6746
- if ($warp) {
6747
- $warp.removeEventListener(touchstart, this._touchstart);
6748
- $warp.removeEventListener(touchend, this._touchend);
6749
- }
6750
- };
6751
- _proto._handlePtzTouch = function _handlePtzTouch(e, type) {
6752
- var _this_options_token_deviceToken, _this_options_token, _e_changedTouches_, _e_changedTouches_1, _this_options_env, _this_options_token_deviceToken1, _this_options_token1;
6753
- if (!(this.options.accessToken || ((_this_options_token = this.options.token) == null ? void 0 : (_this_options_token_deviceToken = _this_options_token.deviceToken) == null ? void 0 : _this_options_token_deviceToken.video))) throw new Error('Ptz accessToken or token.deviceToken.video is required');
6754
- var $warp = this.$content.querySelector("." + PTZ_MOBILE_PREFIX + "-wrap");
6755
- var rect = $warp.getBoundingClientRect();
6756
- var containerCenterX = rect.left + 130;
6757
- var containerCenterY = rect.top + 130;
6758
- var eventX = e.x || ((_e_changedTouches_ = e.changedTouches[0]) == null ? void 0 : _e_changedTouches_.clientX);
6759
- var eventY = e.y || ((_e_changedTouches_1 = e.changedTouches[0]) == null ? void 0 : _e_changedTouches_1.clientY);
6760
- var left = eventX - containerCenterX;
6761
- var top = eventY - containerCenterY;
6762
- var direction = 0; // 操作命令:0-上,1-下,2-左,3右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距
6763
- var url = ((_this_options_env = this.options.env) == null ? void 0 : _this_options_env.domain) + '/api/lapp/device/ptz/start';
6764
- var token = this.options.accessToken || ((_this_options_token1 = this.options.token) == null ? void 0 : (_this_options_token_deviceToken1 = _this_options_token1.deviceToken) == null ? void 0 : _this_options_token_deviceToken1.video);
6765
- var $icons = $warp.querySelectorAll("." + PTZ_MOBILE_PREFIX + "-icon");
6766
- // 判读方位
6767
- if (Math.abs(left) > Math.abs(top)) {
6768
- if (left > 0) {
6769
- direction = 3;
6770
- $icons[3].className = $icons[3].className.replace("" + PTZ_MOBILE_PREFIX + "-default", "" + PTZ_MOBILE_PREFIX + "-active");
6771
- } else {
6772
- direction = 2;
6773
- $icons[1].className = $icons[1].className.replace("" + PTZ_MOBILE_PREFIX + "-default", "" + PTZ_MOBILE_PREFIX + "-active");
6774
- }
6775
- } else {
6776
- if (top > 0) {
6777
- direction = 1;
6778
- $icons[2].className = $icons[2].className.replace("" + PTZ_MOBILE_PREFIX + "-default", "" + PTZ_MOBILE_PREFIX + "-active");
6779
- } else {
6780
- direction = 0;
6781
- $icons[0].className = $icons[0].className.replace("" + PTZ_MOBILE_PREFIX + "-default", "" + PTZ_MOBILE_PREFIX + "-active");
6782
- }
6783
- }
6784
- $warp.style.cssText = "background-image:linear-gradient(" + (direction === 0 ? 180 : direction === 1 ? 0 : direction === 2 ? 90 : 270) + "deg, #c0ddf1 0%, rgba(100,143,252,0.00) 50%)";
6785
- if (type === 'stop') {
6786
- var _this_options_env1;
6787
- url = ((_this_options_env1 = this.options.env) == null ? void 0 : _this_options_env1.domain) + '/api/lapp/device/ptz/stop';
6788
- $warp.style.cssText = '';
6789
- $icons[3].className = $icons[3].className.replace("" + PTZ_MOBILE_PREFIX + "-active", "" + PTZ_MOBILE_PREFIX + "-default");
6790
- $icons[1].className = $icons[1].className.replace("" + PTZ_MOBILE_PREFIX + "-active", "" + PTZ_MOBILE_PREFIX + "-default");
6791
- $icons[2].className = $icons[2].className.replace("" + PTZ_MOBILE_PREFIX + "-active", "" + PTZ_MOBILE_PREFIX + "-default");
6792
- $icons[0].className = $icons[0].className.replace("" + PTZ_MOBILE_PREFIX + "-active", "" + PTZ_MOBILE_PREFIX + "-default");
6793
- }
6794
- // 这个控件暂时没有 ptzSpeed 和areaId 和backDeg 的值
6795
- // this.jSPlugin?.eventEmitter?.emit(EVENTS.ptz.ptzDirection, {
6796
- // type,
6797
- // direction,
6798
- // isRotate: false,
6799
- // ptzSpeed: 1,
6800
- // });
6801
- var operationResultCb = this.options.onDirection == null ? void 0 : this.options.onDirection.call(this.options, {
6802
- direction: direction,
6803
- speed: this.speed,
6804
- type: type
6805
- });
6806
- var data = new FormData();
6807
- data.append('deviceSerial', this.options.deviceSerial + '');
6808
- data.append('channelNo', this.options.channelNo + '');
6809
- data.append('speed', '1');
6810
- data.append('direction', direction + '');
6811
- data.append('accessToken', token);
6812
- // prettier-ignore
6813
- // eslint-disable-next-line @typescript-eslint/promise-function-async
6814
- fetch(url, {
6815
- method: 'POST',
6816
- body: data
6817
- }).then(function(response) {
6818
- return response.json();
6819
- }).then(function(rt) {
6820
- if (rt.code === 200) ; else {
6821
- // this.jSPlugin?.logger?.error('[errors]', this.jSPlugin.i18n.t('38' + rt.code) + `(${rt.code})`);
6822
- // const msg = this.jSPlugin.i18n.t('38' + rt.code) || rt.msg;
6823
- // this.pluginStatus.loadingSetText({
6824
- // text: msg,
6825
- // color: 'red',
6826
- // delayClear: 2000,
6827
- // });
6828
- if ([
6829
- 60005,
6830
- 60002,
6831
- 60003,
6832
- 60004
6833
- ].includes(+rt.code)) {
6834
- $warp.style.cssText = "background-image:linear-gradient(" + (direction === 0 ? 180 : direction === 1 ? 0 : direction === 2 ? 90 : 270) + "deg, #f45656 0%, rgba(100,143,252,0.00) 50%)";
6835
- }
6836
- }
6837
- operationResultCb == null ? void 0 : operationResultCb(rt);
6838
- }).catch(function(err) {
6839
- }).finally(function() {
6840
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
6841
- operationResultCb = null;
6842
- });
6843
- };
6844
- return MobilePtz;
6845
- }(BasePtz);
6846
-
6847
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
6848
- try {
6849
- var info = gen[key](arg);
6850
- var value = info.value;
6851
- } catch (error) {
6852
- reject(error);
6853
- return;
6854
- }
6855
- if (info.done) {
6856
- resolve(value);
6857
- } else {
6858
- Promise.resolve(value).then(_next, _throw);
6859
- }
6860
- }
6861
- function _async_to_generator(fn) {
6862
- return function() {
6863
- var self = this, args = arguments;
6864
- return new Promise(function(resolve, reject) {
6865
- var gen = fn.apply(self, args);
6866
- function _next(value) {
6867
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
6868
- }
6869
- function _throw(err) {
6870
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
6871
- }
6872
- _next(undefined);
6873
- });
6874
- };
6875
- }
6876
- function _defineProperties(target, props) {
6877
- for(var i = 0; i < props.length; i++){
6878
- var descriptor = props[i];
6879
- descriptor.enumerable = descriptor.enumerable || false;
6880
- descriptor.configurable = true;
6881
- if ("value" in descriptor) descriptor.writable = true;
6882
- Object.defineProperty(target, descriptor.key, descriptor);
6883
- }
6884
- }
6885
- function _create_class(Constructor, protoProps, staticProps) {
6886
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
6887
- return Constructor;
6888
- }
6889
- function _inherits(subClass, superClass) {
6890
- if (typeof superClass !== "function" && superClass !== null) {
6891
- throw new TypeError("Super expression must either be null or a function");
6892
- }
6893
- subClass.prototype = Object.create(superClass && superClass.prototype, {
6894
- constructor: {
6895
- value: subClass,
6896
- writable: true,
6897
- configurable: true
6898
- }
6899
- });
6900
- if (superClass) _set_prototype_of(subClass, superClass);
6901
- }
6902
- function _set_prototype_of(o, p) {
6903
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
6904
- o.__proto__ = p;
6905
- return o;
6906
- };
6907
- return _set_prototype_of(o, p);
6908
- }
6909
- function _ts_generator(thisArg, body) {
6910
- var f, y, t, _ = {
6911
- label: 0,
6912
- sent: function() {
6913
- if (t[0] & 1) throw t[1];
6914
- return t[1];
6915
- },
6916
- trys: [],
6917
- ops: []
6918
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
6919
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
6920
- return this;
6921
- }), g;
6922
- function verb(n) {
6923
- return function(v) {
6924
- return step([
6925
- n,
6926
- v
6927
- ]);
6928
- };
6929
- }
6930
- function step(op) {
6931
- if (f) throw new TypeError("Generator is already executing.");
6932
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
6933
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
6934
- if (y = 0, t) op = [
6935
- op[0] & 2,
6936
- t.value
6937
- ];
6938
- switch(op[0]){
6939
- case 0:
6940
- case 1:
6941
- t = op;
6942
- break;
6943
- case 4:
6944
- _.label++;
6945
- return {
6946
- value: op[1],
6947
- done: false
6948
- };
6949
- case 5:
6950
- _.label++;
6951
- y = op[1];
6952
- op = [
6953
- 0
6954
- ];
6955
- continue;
6956
- case 7:
6957
- op = _.ops.pop();
6958
- _.trys.pop();
6959
- continue;
6960
- default:
6961
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
6962
- _ = 0;
6963
- continue;
6964
- }
6965
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
6966
- _.label = op[1];
6967
- break;
6968
- }
6969
- if (op[0] === 6 && _.label < t[1]) {
6970
- _.label = t[1];
6971
- t = op;
6972
- break;
6973
- }
6974
- if (t && _.label < t[2]) {
6975
- _.label = t[2];
6976
- _.ops.push(op);
6977
- break;
6978
- }
6979
- if (t[2]) _.ops.pop();
6980
- _.trys.pop();
6981
- continue;
6982
- }
6983
- op = body.call(thisArg, _);
6984
- } catch (e) {
6985
- op = [
6986
- 6,
6987
- e
6988
- ];
6989
- y = 0;
6990
- } finally{
6991
- f = t = 0;
6992
- }
6993
- if (op[0] & 5) throw op[1];
6994
- return {
6995
- value: op[0] ? op[1] : void 0,
6996
- done: true
6997
- };
6998
- }
6999
- }
7000
- /**
7001
- * @class Ptz
7002
- * @classdesc 云台控制
7003
- *
7004
- * @example
7005
- * // 初始化云台控制
7006
- * // 显示云台控制
7007
- * ptz.show()
7008
- * // 隐藏云台控制
7009
- * ptz.hide()
7010
- */ var Ptz = /*#__PURE__*/ function(BasePtz) {
7011
- _inherits(Ptz, BasePtz);
7012
- function Ptz(container, options) {
7013
- if (options === void 0) options = {};
7014
- var _this;
7015
- _this = BasePtz.call(this, container, options) || this, _this._isMobile = utilsTools.isMobile(), _this._isRotate = false, _this._clearTimer = null;
7016
- _this._$wrapper = document.createElement('div');
7017
- _this._$wrapper.className = PTZ_PREFIX + '-container-wrap';
7018
- _this._$directionCircleContainer = document.createElement('div');
7019
- _this._$directionCircleContainer.classList.add(PTZ_PREFIX + '-container');
7020
- _this._$directionCircleContainer.innerHTML = '\n <div class="' + PTZ_PREFIX + "-main " + PTZ_DIRECTION_PREFIX + '-center"></div>\n <div class="' + PTZ_PREFIX + "-icon " + PTZ_DIRECTION_PREFIX + '-top" data-direction="0"></div>\n <div class="' + PTZ_PREFIX + "-icon " + PTZ_DIRECTION_PREFIX + '-top-left" data-direction="4"></div>\n <div class="' + PTZ_PREFIX + "-icon " + PTZ_DIRECTION_PREFIX + '-left" data-direction="2"></div>\n <div class="' + PTZ_PREFIX + "-icon " + PTZ_DIRECTION_PREFIX + '-left-bottom" data-direction="5"></div>\n <div class="' + PTZ_PREFIX + "-icon " + PTZ_DIRECTION_PREFIX + '-bottom" data-direction="1"></div>\n <div class="' + PTZ_PREFIX + "-icon " + PTZ_DIRECTION_PREFIX + '-bottom-right" data-direction="7"></div>\n <div class="' + PTZ_PREFIX + "-icon " + PTZ_DIRECTION_PREFIX + '-right" data-direction="3"></div>\n <div class="' + PTZ_PREFIX + "-icon " + PTZ_DIRECTION_PREFIX + '-right-top" data-direction="6"></div>\n ';
7021
- _this._$wrapper.appendChild(_this._$directionCircleContainer);
7022
- _this._$speedContainer = document.createElement('div');
7023
- _this._$speedContainer.classList.add(PTZ_PREFIX + '-speed-container');
7024
- _this._$speedContainer.innerHTML = '\n <div class="' + PTZ_PREFIX + '-speed-progress" title="' + _this.locale['PTZ_SPEED'] + '">\n <div class="' + PTZ_PREFIX + '-speed-progress-line">\n <div class="' + PTZ_PREFIX + "-speed-progress-line-dot " + (_this.speed === 1 ? PTZ_SPEED_ACTIVE_PREFIX : '') + '" data-id="slow" data-index="1" data-value="1"></div>\n <div class="' + PTZ_PREFIX + "-speed-progress-line-dot " + (_this.speed === 3 ? PTZ_SPEED_ACTIVE_PREFIX : '') + '" data-id="mid" data-index="2" data-value="3"></div>\n <div class="' + PTZ_PREFIX + "-speed-progress-line-dot " + (_this.speed === 7 ? PTZ_SPEED_ACTIVE_PREFIX : '') + '" data-id="fast" data-index="3" data-value="7"></div>\n </div>\n <div class="' + PTZ_PREFIX + '-speed-progress-points">\n <div class="' + PTZ_PREFIX + '-speed-progress-points-slow">\n ' + _this.locale['PTZ_SLOW'] + '\n </div>\n <div class="' + PTZ_PREFIX + '-speed-progress-points-mid">\n ' + _this.locale['PTZ_MID'] + '\n </div>\n <div class="' + PTZ_PREFIX + '-speed-progress-points-fast">\n ' + _this.locale['PTZ_FAST'] + "\n </div>\n </div>\n </div>\n ";
7025
- _this._$wrapper.appendChild(_this._$speedContainer);
7026
- _this._$btnContainer = document.createElement('div');
7027
- _this._$btnContainer.classList.add(PTZ_PREFIX + '-btn-container');
7028
- _this._$btnContainer.innerHTML = '\n <div class="' + PTZ_PREFIX + '-btn-zoom" title="' + _this.locale['DEVICE_ZOOM'] + '" style="user-select: none;">\n <div class="' + PTZ_PREFIX + '-btn-zoom-add" style="user-select: none;">\n <svg viewBox="0 0 1088 1024" version="1.1" width="20" height="20">\n <path d="M563.2 198.4c179.2 0 326.4 147.2 326.4 326.4s-147.2 326.4-326.4 326.4S230.4 704 230.4 524.8s147.2-326.4 332.8-326.4z m0 64c-147.2 0-262.4 115.2-262.4 262.4s115.2 262.4 262.4 262.4 262.4-115.2 262.4-262.4S704 262.4 563.2 262.4z" fill="#ffffff"></path>\n <path d="M691.2 556.8H428.8c-19.2 0-32-12.8-32-32s12.8-32 32-32h262.4c19.2 0 32 12.8 32 32s-12.8 32-32 32z" fill="#ffffff">\n </path>\n <path d="M556.8 691.2c-19.2 0-32-12.8-32-32V396.8c0-19.2 12.8-32 32-32s32 12.8 32 32v262.4c0 19.2-12.8 32-32 32z" fill="#ffffff"></path>\n </svg>\n </div>\n <div class="' + PTZ_PREFIX + '-btn-zoom-sub" style="user-select: none;">\n <svg viewBox="0 0 1088 1024" version="1.1" width="20" height="20">\n <path d="M569.6 838.4c-172.8 0-307.2-140.8-307.2-307.2s140.8-307.2 307.2-307.2 307.2 140.8 307.2 307.2-140.8 307.2-307.2 307.2z m0-64c134.4 0 249.6-108.8 249.6-249.6S704 281.6 569.6 281.6 320 396.8 320 531.2s108.8 243.2 249.6 243.2z" fill="#ffffff"></path>\n <path d="M691.2 563.2H448c-19.2 0-32-12.8-32-32s12.8-38.4 32-38.4h249.6c19.2 0 32 12.8 32 32s-19.2 38.4-38.4 38.4z" fill="#ffffff"></path>\n </svg>\n </div>\n </div>\n <div class="' + PTZ_PREFIX + '-btn-focal" title="' + _this.locale['DEVICE_FOCUS'] + '" style="user-select: none;">\n <div class="' + PTZ_PREFIX + '-btn-focal-add" style="user-select: none;">\n <svg viewBox="0 0 1088 1024" version="1.1" width="20" height="20">\n <path d="M646.4 825.6H320c-44.8 0-83.2-38.4-83.2-83.2V409.6c0-44.8 38.4-83.2 83.2-83.2h326.4c44.8 0 83.2 38.4 83.2 83.2v326.4c0 51.2-38.4 89.6-83.2 89.6zM320 390.4c-12.8 0-19.2 6.4-19.2 19.2v326.4c0 12.8 6.4 19.2 19.2 19.2h326.4c12.8 0 19.2-6.4 19.2-19.2V409.6c0-12.8-6.4-19.2-19.2-19.2H320z" fill="#ffffff"></path>\n <path d="M396.8 358.4V281.6c0-25.6 25.6-51.2 51.2-51.2h326.4c25.6 0 51.2 25.6 51.2 51.2v326.4c0 25.6-25.6 51.2-51.2 51.2H704l-6.4-268.8" fill="#ffffff"></path>\n </svg>\n </div>\n <div class="' + PTZ_PREFIX + '-btn-focal-sub" style="user-select: none;">\n <svg viewBox="0 0 1088 1024" version="1.1" width="20" height="20">\n <path d="M320 358.4h326.4c25.6 0 51.2 25.6 51.2 51.2v326.4c0 25.6-25.6 51.2-51.2 51.2H320c-25.6 0-51.2-25.6-51.2-51.2V409.6c0-25.6 25.6-51.2 51.2-51.2z" fill="#ffffff"></path>\n <path d="M774.4 697.6H704c-19.2 0-32-12.8-32-32s12.8-32 32-32h70.4c12.8 0 19.2-6.4 19.2-19.2V281.6c0-12.8-6.4-19.2-19.2-19.2H448c-12.8 0-19.2 6.4-19.2 19.2v70.4c0 19.2-12.8 32-32 32s-32-12.8-32-25.6V281.6c0-44.8 38.4-83.2 83.2-83.2h326.4c44.8 0 83.2 38.4 83.2 83.2v326.4c0 51.2-38.4 89.6-83.2 89.6z" fill="#ffffff"></path>\n </svg>\n </div>\n </div>\n ';
7029
- _this._$wrapper.appendChild(_this._$btnContainer);
7030
- container.appendChild(_this._$wrapper);
7031
- // 云台控制事件绑定
7032
- // 云台控制
7033
- _this._$directionCircleContainer.onmousedown = function(e) {
7034
- e.preventDefault();
7035
- e.stopPropagation();
7036
- _this._handlePtzTouch(e, 'start');
7037
- };
7038
- _this._$directionCircleContainer.onmouseup = function(e) {
7039
- e.preventDefault();
7040
- e.stopPropagation();
7041
- _this._handlePtzTouch(e, 'stop');
7042
- };
7043
- _this._$directionCircleContainer.ontouchstart = function(e) {
7044
- e.preventDefault();
7045
- e.stopPropagation();
7046
- _this._handlePtzTouch(e, 'start');
7047
- };
7048
- _this._$directionCircleContainer.ontouchend = function(e) {
7049
- e.preventDefault();
7050
- e.stopPropagation();
7051
- _this._handlePtzTouch(e, 'stop');
7052
- };
7053
- _this._onSwitchSpeed = function(e) {
7054
- var list = Array.from(_this._$speedContainer.querySelectorAll("." + PTZ_PREFIX + "-speed-progress-line-dot"));
7055
- if (list.includes(e.target) && !e.target.classList.contains(PTZ_SPEED_ACTIVE_PREFIX)) {
7056
- list.forEach(function(item) {
7057
- if (item === e.target) {
7058
- item.classList.add(PTZ_SPEED_ACTIVE_PREFIX);
7059
- } else {
7060
- item.classList.remove(PTZ_SPEED_ACTIVE_PREFIX);
7061
- }
7062
- });
7063
- var value = e.target.getAttribute('data-value');
7064
- var index = e.target.getAttribute('data-index');
7065
- _this.speed = +value;
7066
- _this.options.onSpeedChange == null ? void 0 : _this.options.onSpeedChange.call(_this.options, +index);
7067
- }
7068
- };
7069
- // mouse 事件绑定
7070
- // 云台速度变化事件绑定
7071
- _this._$speedContainer.onmouseup = _this._onSwitchSpeed;
7072
- if (_this._isMobile) {
7073
- _this._$speedContainer.ontouchend = _this._onSwitchSpeed;
7074
- }
7075
- if (_this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-add")) {
7076
- // 物理缩放、变焦按钮事件监听
7077
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-add").onmousedown = function(e) {
7078
- e.preventDefault();
7079
- e.stopPropagation();
7080
- _this._handleBtnTouch('zoom', 'add', 'start');
7081
- };
7082
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-add").onmouseup = function(e) {
7083
- e.preventDefault();
7084
- e.stopPropagation();
7085
- _this._handleBtnTouch('zoom', 'add', 'stop');
7086
- };
7087
- }
7088
- if (_this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-sub")) {
7089
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-sub").onmousedown = function(e) {
7090
- e.preventDefault();
7091
- e.stopPropagation();
7092
- _this._handleBtnTouch('zoom', 'sub', 'start');
7093
- };
7094
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-sub").onmouseup = function(e) {
7095
- e.preventDefault();
7096
- e.stopPropagation();
7097
- _this._handleBtnTouch('zoom', 'sub', 'stop');
7098
- };
7099
- }
7100
- if (_this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-add")) {
7101
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-add").onmousedown = function(e) {
7102
- e.preventDefault();
7103
- e.stopPropagation();
7104
- _this._handleBtnTouch('focal', 'add', 'start');
7105
- };
7106
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-add").onmouseup = function(e) {
7107
- e.preventDefault();
7108
- e.stopPropagation();
7109
- _this._handleBtnTouch('focal', 'add', 'stop');
7110
- };
7111
- }
7112
- if (_this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-sub")) {
7113
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-sub").onmousedown = function(e) {
7114
- e.preventDefault();
7115
- e.stopPropagation();
7116
- _this._handleBtnTouch('focal', 'sub', 'start');
7117
- };
7118
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-sub").onmouseup = function(e) {
7119
- e.preventDefault();
7120
- e.stopPropagation();
7121
- _this._handleBtnTouch('focal', 'sub', 'stop');
7122
- };
7123
- }
7124
- // mobile touch 事件监听
7125
- if (_this._isMobile) {
7126
- if (_this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-add")) {
7127
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-add").ontouchstart = function(e) {
7128
- e.preventDefault();
7129
- e.stopPropagation();
7130
- _this._handleBtnTouch('zoom', 'add', 'start');
7131
- };
7132
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-add").ontouchend = function(e) {
7133
- e.preventDefault();
7134
- e.stopPropagation();
7135
- _this._handleBtnTouch('zoom', 'add', 'stop');
7136
- };
7137
- }
7138
- if (_this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-sub")) {
7139
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-sub").ontouchstart = function(e) {
7140
- e.preventDefault();
7141
- e.stopPropagation();
7142
- _this._handleBtnTouch('zoom', 'sub', 'start');
7143
- };
7144
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-zoom-sub").ontouchend = function(e) {
7145
- e.preventDefault();
7146
- e.stopPropagation();
7147
- _this._handleBtnTouch('zoom', 'sub', 'stop');
7148
- };
7149
- }
7150
- if (_this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-add")) {
7151
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-add").ontouchstart = function(e) {
7152
- e.preventDefault();
7153
- e.stopPropagation();
7154
- _this._handleBtnTouch('focal', 'add', 'start');
7155
- };
7156
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-add").ontouchend = function(e) {
7157
- e.preventDefault();
7158
- e.stopPropagation();
7159
- _this._handleBtnTouch('focal', 'add', 'stop');
7160
- };
7161
- }
7162
- if (_this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-sub")) {
7163
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-sub").ontouchstart = function(e) {
7164
- e.preventDefault();
7165
- e.stopPropagation();
7166
- _this._handleBtnTouch('focal', 'sub', 'start');
7167
- };
7168
- _this._$btnContainer.querySelector("." + PTZ_PREFIX + "-btn-focal-sub").ontouchend = function(e) {
7169
- e.preventDefault();
7170
- e.stopPropagation();
7171
- _this._handleBtnTouch('focal', 'sub', 'stop');
7172
- };
7173
- }
7174
- }
7175
- return _this;
7176
- }
7177
- var _proto = Ptz.prototype;
7178
- _proto.destroy = function destroy() {
7179
- if (this._clearTimer) {
7180
- clearTimeout(this._clearTimer);
7181
- this._clearTimer = null;
7182
- }
7183
- if (this._$directionCircleContainer) {
7184
- this._$directionCircleContainer.remove();
7185
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7186
- this._$directionCircleContainer = null;
7187
- }
7188
- if (this._$speedContainer) {
7189
- this._onSwitchSpeed = null;
7190
- this._$speedContainer.remove();
7191
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7192
- this._$speedContainer = null;
7193
- }
7194
- if (this._$btnContainer) {
7195
- this._$btnContainer.remove();
7196
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7197
- this._$btnContainer = null;
7198
- }
7199
- if (this._$wrapper) {
7200
- this._$wrapper.remove();
7201
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7202
- this._$wrapper = null;
7203
- }
7204
- BasePtz.prototype.destroy.call(this);
7205
- };
7206
- _proto._handlePtzTouch = function _handlePtzTouch(e, type) {
7207
- var _this = this;
7208
- var _this_options_token_deviceToken, _this_options_token, _this_options_env, _this_options_token_deviceToken1, _this_options_token1;
7209
- if (!(this.options.accessToken || ((_this_options_token = this.options.token) == null ? void 0 : (_this_options_token_deviceToken = _this_options_token.deviceToken) == null ? void 0 : _this_options_token_deviceToken.video))) throw new Error('Ptz accessToken or token.deviceToken.video is required');
7210
- // 初始化或获取当前PTZ操作队列
7211
- if (!this._ptzQueue) {
7212
- this._ptzQueue = Promise.resolve();
7213
- }
7214
- var container = this._$directionCircleContainer.getBoundingClientRect();
7215
- var containerCenterX = container.left + (this._$directionCircleContainer.clientWidth + 2) / 2;
7216
- var containerCenterY = container.top + (this._$directionCircleContainer.clientHeight + 2) / 2;
7217
- var eventX = e.x || e.changedTouches[0].clientX;
7218
- var eventY = e.y || e.changedTouches[0].clientY;
7219
- var direction = 0;
7220
- var url = ((_this_options_env = this.options.env) == null ? void 0 : _this_options_env.domain) + '/api/lapp/device/ptz/start';
7221
- var token = this.options.accessToken || ((_this_options_token1 = this.options.token) == null ? void 0 : (_this_options_token_deviceToken1 = _this_options_token1.deviceToken) == null ? void 0 : _this_options_token_deviceToken1.video);
7222
- var backDeg = 0;
7223
- function getAreaId(x, y) {
7224
- // 获取当前点击位置相对于圆心的角度
7225
- var rad = Math.atan2(y, x);
7226
- if (rad < 0) rad += 2 * Math.PI;
7227
- var deg = rad * (180 / Math.PI) - 225 - 12.5;
7228
- if (deg < 0) deg += 360;
7229
- return Math.floor(deg / 45) + 1;
7230
- }
7231
- // 兼容画面旋转90度
7232
- // const isRotate = false; // /^rotate\(90/.test(document.getElementById(`${this.jSPlugin.id}-wrap`).style.transform);
7233
- var left = eventX - containerCenterX;
7234
- var top = eventY - containerCenterY;
7235
- if (this.isRotate) {
7236
- switch(getAreaId(left, top)){
7237
- case 1:
7238
- direction = 2;
7239
- backDeg = 90;
7240
- break;
7241
- case 2:
7242
- direction = 4;
7243
- backDeg = 135;
7244
- break;
7245
- case 3:
7246
- direction = 0;
7247
- backDeg = 180;
7248
- break;
7249
- case 4:
7250
- direction = 6;
7251
- backDeg = 225;
7252
- break;
7253
- case 5:
7254
- direction = 3;
7255
- backDeg = 270;
7256
- break;
7257
- case 6:
7258
- direction = 7;
7259
- backDeg = 315;
7260
- break;
7261
- case 7:
7262
- direction = 1;
7263
- backDeg = 0;
7264
- break;
7265
- case 8:
7266
- direction = 5;
7267
- backDeg = 45;
7268
- break;
7269
- }
7270
- } else {
7271
- switch(getAreaId(left, top)){
7272
- case 1:
7273
- direction = 0;
7274
- backDeg = 180;
7275
- break;
7276
- case 2:
7277
- direction = 6;
7278
- backDeg = 225;
7279
- break;
7280
- case 3:
7281
- direction = 3;
7282
- backDeg = 270;
7283
- break;
7284
- case 4:
7285
- direction = 7;
7286
- backDeg = 315;
7287
- break;
7288
- case 5:
7289
- direction = 1;
7290
- backDeg = 0;
7291
- break;
7292
- case 6:
7293
- direction = 5;
7294
- backDeg = 45;
7295
- break;
7296
- case 7:
7297
- direction = 2;
7298
- backDeg = 90;
7299
- break;
7300
- case 8:
7301
- direction = 4;
7302
- backDeg = 135;
7303
- break;
7304
- }
7305
- }
7306
- if (this._clearTimer) {
7307
- clearTimeout(this._clearTimer);
7308
- this._clearTimer = null;
7309
- }
7310
- if (type === 'start') {
7311
- this._$directionCircleContainer.style.cssText = "background-image:linear-gradient(" + backDeg + "deg, #4277FF 0%, rgba(100,143,252,0.00) 30%)";
7312
- } else {
7313
- this._$directionCircleContainer.style.cssText = '';
7314
- }
7315
- if (type === 'stop') {
7316
- var _this_options_env1;
7317
- url = ((_this_options_env1 = this.options.env) == null ? void 0 : _this_options_env1.domain) + '/api/lapp/device/ptz/stop';
7318
- }
7319
- var operationResultCb = this.options.onDirection == null ? void 0 : this.options.onDirection.call(this.options, {
7320
- areaId: getAreaId(left, top),
7321
- direction: direction,
7322
- backDeg: backDeg,
7323
- isRotate: this.isRotate,
7324
- speed: this.speed,
7325
- type: type
7326
- });
7327
- var data = new FormData();
7328
- data.append('deviceSerial', this.options.deviceSerial + '');
7329
- data.append('channelNo', this.options.channelNo + '');
7330
- data.append('speed', this.speed + '');
7331
- data.append('direction', direction + '');
7332
- data.append('accessToken', token);
7333
- // 将操作加入队列
7334
- this._ptzQueue = this._ptzQueue.then(function() {
7335
- return _async_to_generator(function() {
7336
- var _this;
7337
- return _ts_generator(this, function(_state) {
7338
- switch(_state.label){
7339
- case 0:
7340
- _this = this;
7341
- return [
7342
- 4,
7343
- fetch(url, {
7344
- method: 'POST',
7345
- body: data
7346
- }).then(function(response) {
7347
- return _async_to_generator(function() {
7348
- return _ts_generator(this, function(_state) {
7349
- switch(_state.label){
7350
- case 0:
7351
- return [
7352
- 4,
7353
- response.json()
7354
- ];
7355
- case 1:
7356
- return [
7357
- 2,
7358
- _state.sent()
7359
- ];
7360
- }
7361
- });
7362
- })();
7363
- }).then(function(rt) {
7364
- var _rt_result;
7365
- operationResultCb == null ? void 0 : operationResultCb(rt);
7366
- var code = rt.code || (rt == null ? void 0 : (_rt_result = rt.result) == null ? void 0 : _rt_result.code);
7367
- if ([
7368
- 60000,
7369
- 60001,
7370
- 60002,
7371
- 60003,
7372
- 60004,
7373
- 60005,
7374
- 60006,
7375
- 10002
7376
- ].includes(+code)) {
7377
- _this._$directionCircleContainer.style.cssText = "background-image:linear-gradient(" + backDeg + "deg, #f45656 0%, rgba(100,143,252,0.00) 30%)";
7378
- }
7379
- return rt;
7380
- }).catch(function(err) {
7381
- }).finally(function() {
7382
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7383
- operationResultCb = null;
7384
- if (type === 'stop') {
7385
- _this._clearTimer = setTimeout(function() {
7386
- _this._$directionCircleContainer.style.cssText = '';
7387
- }, 1000);
7388
- }
7389
- })
7390
- ];
7391
- case 1:
7392
- // prettier-ignore
7393
- return [
7394
- 2,
7395
- _state.sent()
7396
- ];
7397
- }
7398
- });
7399
- }).call(_this);
7400
- });
7401
- if (type === 'stop') {
7402
- this._ptzQueue = this._ptzQueue.finally(function() {});
7403
- }
7404
- // this.jSPlugin?.eventEmitter?.emit(EVENTS.ptzDirection, {
7405
- // areaId: getAreaId(left, top),
7406
- // direction,
7407
- // backDeg,
7408
- // isRotate,
7409
- // ptzSpeed: this.jSPlugin.ptzSpeed,
7410
- // type,
7411
- // });
7412
- };
7413
- _proto._handleBtnTouch = function _handleBtnTouch(btn, option, type) {
7414
- var _this = this;
7415
- var _this_options_token, _this_options_env, _this_options_token_deviceToken, _this_options_token1;
7416
- if (!(this.options.accessToken || ((_this_options_token = this.options.token) == null ? void 0 : _this_options_token.deviceToken.video))) throw new Error('Ptz accessToken or token.deviceToken.video is required');
7417
- // 使用Promise来跟踪当前操作状态
7418
- if (!this._ptzOperation) {
7419
- this._ptzOperation = Promise.resolve();
7420
- }
7421
- var direction = 8;
7422
- if (btn === 'zoom') {
7423
- direction = option === 'add' ? 8 : 9;
7424
- } else {
7425
- direction = option === 'add' ? 10 : 11;
7426
- }
7427
- var url = ((_this_options_env = this.options.env) == null ? void 0 : _this_options_env.domain) + '/api/lapp/device/ptz/start';
7428
- var token = this.options.accessToken || ((_this_options_token1 = this.options.token) == null ? void 0 : (_this_options_token_deviceToken = _this_options_token1.deviceToken) == null ? void 0 : _this_options_token_deviceToken.video);
7429
- if (type === 'stop') {
7430
- var _this_options_env1;
7431
- url = ((_this_options_env1 = this.options.env) == null ? void 0 : _this_options_env1.domain) + '/api/lapp/device/ptz/stop';
7432
- }
7433
- var operationResultCb = this.options.onDirection == null ? void 0 : this.options.onDirection.call(this.options, {
7434
- btn: btn,
7435
- option: option,
7436
- type: type
7437
- });
7438
- var data = new FormData();
7439
- data.append('deviceSerial', this.options.deviceSerial + '');
7440
- data.append('channelNo', this.options.channelNo + '');
7441
- data.append('speed', this.speed + '');
7442
- data.append('direction', direction + '');
7443
- data.append('accessToken', token);
7444
- // 将当前操作加入Promise链
7445
- this._ptzOperation = this._ptzOperation.then(function() {
7446
- return _async_to_generator(function() {
7447
- return _ts_generator(this, function(_state) {
7448
- switch(_state.label){
7449
- case 0:
7450
- return [
7451
- 4,
7452
- fetch(url, {
7453
- method: 'POST',
7454
- body: data
7455
- }).then(function(response) {
7456
- return _async_to_generator(function() {
7457
- return _ts_generator(this, function(_state) {
7458
- switch(_state.label){
7459
- case 0:
7460
- return [
7461
- 4,
7462
- response.json()
7463
- ];
7464
- case 1:
7465
- return [
7466
- 2,
7467
- _state.sent()
7468
- ];
7469
- }
7470
- });
7471
- })();
7472
- }).then(function(rt) {
7473
- operationResultCb == null ? void 0 : operationResultCb(rt);
7474
- return rt;
7475
- }).catch(function(err) {
7476
- }).finally(function() {
7477
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7478
- operationResultCb = null;
7479
- })
7480
- ];
7481
- case 1:
7482
- // prettier-ignore
7483
- return [
7484
- 2,
7485
- _state.sent()
7486
- ];
7487
- }
7488
- });
7489
- })();
7490
- });
7491
- // 如果是stop操作,添加一个清理操作
7492
- if (type === 'stop') {
7493
- this._ptzOperation = this._ptzOperation.finally(function() {
7494
- _this._ptzOperation = null; // 重置操作链
7495
- });
7496
- }
7497
- };
7498
- _create_class(Ptz, [
7499
- {
7500
- key: "isRotate",
7501
- get: function get() {
7502
- return this._isRotate;
7503
- },
7504
- set: /**
7505
- * 是否旋转了
7506
- */ function set(isRotate) {
7507
- this._isRotate = isRotate;
7508
- }
7509
- }
7510
- ]);
7511
- return Ptz;
7512
- }(BasePtz);
7513
-
7514
- dist.BasePtz = BasePtz;
7515
- dist.MobilePtz = MobilePtz;
7516
- dist.Ptz = Ptz;
7517
- return dist;
7518
- }
7519
-
7520
- var distExports = requireDist();
7521
-
7522
5852
  function _defineProperties$4(target, props) {
7523
5853
  for(var i = 0; i < props.length; i++){
7524
5854
  var descriptor = props[i];
@@ -7616,7 +5946,7 @@ function _set_prototype_of$e(o, p) {
7616
5946
  this.$turntable.classList.add("" + PREFIX_CLASS + "-ptz-turntable");
7617
5947
  this.$panel.appendChild(this.$turntable);
7618
5948
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
7619
- this._ptzControl = new distExports.Ptz(this.$turntable, _extends$d({}, this._options, {
5949
+ this._ptzControl = new Ptz$1(this.$turntable, _extends$d({}, this._options, {
7620
5950
  onSpeedChange: this._onSpeedChange.bind(this),
7621
5951
  onDirection: this._onDirection.bind(this)
7622
5952
  }));
@@ -7625,7 +5955,7 @@ function _set_prototype_of$e(o, p) {
7625
5955
  };
7626
5956
  _proto.renderMobileExtend = function renderMobileExtend($container) {
7627
5957
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
7628
- if (!this._ptzControl1) this._ptzControl1 = new distExports.MobilePtz($container, _extends$d({}, this._options, {
5958
+ if (!this._ptzControl1) this._ptzControl1 = new MobilePtz($container, _extends$d({}, this._options, {
7629
5959
  onSpeedChange: this._onSpeedChange.bind(this),
7630
5960
  onDirection: this._onDirection.bind(this)
7631
5961
  }));
@@ -8336,10 +6666,10 @@ function _ts_generator$3(thisArg, body) {
8336
6666
  _this._render();
8337
6667
  }
8338
6668
  });
8339
- if (options.sdkType === "base") {
8340
- _this.$container.style.removeProperty("display");
6669
+ if (options.sdkType === 'base') {
6670
+ _this.$container.style.removeProperty('display');
8341
6671
  } else {
8342
- _this.$container.style.display = "none";
6672
+ _this.$container.style.display = 'none';
8343
6673
  }
8344
6674
  return _this;
8345
6675
  }
@@ -8359,16 +6689,16 @@ function _ts_generator$3(thisArg, body) {
8359
6689
  }
8360
6690
  };
8361
6691
  /**
8362
- * 销毁语音广播控件
8363
- */ _proto.destroy = function destroy() {
6692
+ * 销毁语音广播控件
6693
+ */ _proto.destroy = function destroy() {
8364
6694
  if (this.active) {
8365
6695
  this.reset();
8366
6696
  }
8367
6697
  Control.prototype.destroy.call(this);
8368
6698
  };
8369
6699
  /**
8370
- * 点击 Control 会触发
8371
- */ _proto._onControlClick = function _onControlClick(e) {
6700
+ * 点击 Control 会触发
6701
+ */ _proto._onControlClick = function _onControlClick(e) {
8372
6702
  var _this = this, _superprop_get__onControlClick = function() {
8373
6703
  return Control.prototype._onControlClick;
8374
6704
  };
@@ -8566,10 +6896,10 @@ function _ts_generator$2(thisArg, body) {
8566
6896
  _this._render();
8567
6897
  }
8568
6898
  });
8569
- if (options.urlInfo.search === "" && options.urlInfo.recType === "cloud" && options.sdkType === "base") {
8570
- _this.$container.style.removeProperty("display");
6899
+ if (options.urlInfo.searchParams.busType !== '7' && options.urlInfo.recType === 'cloud' && options.sdkType === 'base') {
6900
+ _this.$container.style.removeProperty('display');
8571
6901
  } else {
8572
- _this.$container.style.display = "none";
6902
+ _this.$container.style.display = 'none';
8573
6903
  }
8574
6904
  return _this;
8575
6905
  }
@@ -8589,16 +6919,16 @@ function _ts_generator$2(thisArg, body) {
8589
6919
  }
8590
6920
  };
8591
6921
  /**
8592
- * 销毁AI对话框控件
8593
- */ _proto.destroy = function destroy() {
6922
+ * 销毁AI对话框控件
6923
+ */ _proto.destroy = function destroy() {
8594
6924
  if (this.active) {
8595
6925
  this.reset();
8596
6926
  }
8597
6927
  Control.prototype.destroy.call(this);
8598
6928
  };
8599
6929
  /**
8600
- * 点击 Control 会触发
8601
- */ _proto._onControlClick = function _onControlClick(e) {
6930
+ * 点击 Control 会触发
6931
+ */ _proto._onControlClick = function _onControlClick(e) {
8602
6932
  var _this = this, _superprop_get__onControlClick = function() {
8603
6933
  return Control.prototype._onControlClick;
8604
6934
  };
@@ -9611,7 +7941,7 @@ var Controls = {
9611
7941
  talk: Talk,
9612
7942
  broadcast: Broadcast,
9613
7943
  aiChat: AIChat,
9614
- zoom: Zoom$1,
7944
+ zoom: Zoom,
9615
7945
  definition: Definition,
9616
7946
  fullscreen: Fullscreen,
9617
7947
  globalFullscreen: GlobalFullscreen,
@@ -12002,6 +10332,6 @@ var THEME_DEFAULT_OPTIONS = {
12002
10332
  zh: zh,
12003
10333
  en: en
12004
10334
  };
12005
- /** 版本号 @since 0.0.1 */ Theme.THEME_VERSION = '2.1.4-beta.1';
10335
+ /** 版本号 @since 0.0.1 */ Theme.THEME_VERSION = '3.0.0-beta.1';
12006
10336
 
12007
10337
  export { Control, EVENTS, Fullscreen, Loading, Message, Play, Poster, Rec, Theme, Utils, Volume };