@oliasoft-open-source/charts-library 4.8.2 → 4.8.3-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.js CHANGED
@@ -572,9 +572,9 @@ let Color$1 = class Color {
572
572
  }
573
573
  };
574
574
  /*!
575
- * Chart.js v4.4.7
575
+ * Chart.js v4.4.8
576
576
  * https://www.chartjs.org
577
- * (c) 2024 Chart.js Contributors
577
+ * (c) 2025 Chart.js Contributors
578
578
  * Released under the MIT License
579
579
  */
580
580
  function noop$1() {
@@ -815,8 +815,11 @@ function _factorize$1(value) {
815
815
  result.sort((a2, b2) => a2 - b2).pop();
816
816
  return result;
817
817
  }
818
+ function isNonPrimitive(n2) {
819
+ return typeof n2 === "symbol" || typeof n2 === "object" && n2 !== null && !(Symbol.toPrimitive in n2 || "toString" in n2 || "valueOf" in n2);
820
+ }
818
821
  function isNumber$1(n2) {
819
- return !isNaN(parseFloat(n2)) && isFinite(n2);
822
+ return !isNonPrimitive(n2) && !isNaN(parseFloat(n2)) && isFinite(n2);
820
823
  }
821
824
  function almostWhole$1(x2, epsilon) {
822
825
  const rounded = Math.round(x2);
@@ -1034,24 +1037,35 @@ function _getStartAndCountOfVisiblePoints$1(meta, points, animationsDisabled) {
1034
1037
  let start = 0;
1035
1038
  let count = pointCount;
1036
1039
  if (meta._sorted) {
1037
- const { iScale, _parsed } = meta;
1040
+ const { iScale, vScale, _parsed } = meta;
1041
+ const spanGaps = meta.dataset ? meta.dataset.options ? meta.dataset.options.spanGaps : null : null;
1038
1042
  const axis = iScale.axis;
1039
1043
  const { min, max, minDefined, maxDefined } = iScale.getUserBounds();
1040
1044
  if (minDefined) {
1041
- start = _limitValue$1(Math.min(
1045
+ start = Math.min(
1042
1046
  // @ts-expect-error Need to type _parsed
1043
1047
  _lookupByKey$1(_parsed, axis, min).lo,
1044
1048
  // @ts-expect-error Need to fix types on _lookupByKey
1045
1049
  animationsDisabled ? pointCount : _lookupByKey$1(points, axis, iScale.getPixelForValue(min)).lo
1046
- ), 0, pointCount - 1);
1050
+ );
1051
+ if (spanGaps) {
1052
+ const distanceToDefinedLo = _parsed.slice(0, start + 1).reverse().findIndex((point) => !isNullOrUndef$1(point[vScale.axis]));
1053
+ start -= Math.max(0, distanceToDefinedLo);
1054
+ }
1055
+ start = _limitValue$1(start, 0, pointCount - 1);
1047
1056
  }
1048
1057
  if (maxDefined) {
1049
- count = _limitValue$1(Math.max(
1058
+ let end = Math.max(
1050
1059
  // @ts-expect-error Need to type _parsed
1051
1060
  _lookupByKey$1(_parsed, iScale.axis, max, true).hi + 1,
1052
1061
  // @ts-expect-error Need to fix types on _lookupByKey
1053
1062
  animationsDisabled ? 0 : _lookupByKey$1(points, axis, iScale.getPixelForValue(max), true).hi + 1
1054
- ), start, pointCount) - start;
1063
+ );
1064
+ if (spanGaps) {
1065
+ const distanceToDefinedHi = _parsed.slice(end - 1).findIndex((point) => !isNullOrUndef$1(point[vScale.axis]));
1066
+ end += Math.max(0, distanceToDefinedHi);
1067
+ }
1068
+ count = _limitValue$1(end, start, pointCount) - start;
1055
1069
  } else {
1056
1070
  count = pointCount - start;
1057
1071
  }
@@ -1562,6 +1576,7 @@ function drawPointLegend$1(ctx, options, x2, y2, w2) {
1562
1576
  }
1563
1577
  ctx.beginPath();
1564
1578
  switch (style) {
1579
+ // Default includes circle
1565
1580
  default:
1566
1581
  if (w2) {
1567
1582
  ctx.ellipse(x2, y2, w2 / 2, radius, 0, 0, TAU$1);
@@ -1600,6 +1615,7 @@ function drawPointLegend$1(ctx, options, x2, y2, w2) {
1600
1615
  break;
1601
1616
  }
1602
1617
  rad += QUARTER_PI$1;
1618
+ /* falls through */
1603
1619
  case "rectRot":
1604
1620
  xOffsetW = Math.cos(rad) * (w2 ? w2 / 2 : radius);
1605
1621
  xOffset = Math.cos(rad) * radius;
@@ -1613,6 +1629,7 @@ function drawPointLegend$1(ctx, options, x2, y2, w2) {
1613
1629
  break;
1614
1630
  case "crossRot":
1615
1631
  rad += QUARTER_PI$1;
1632
+ /* falls through */
1616
1633
  case "cross":
1617
1634
  xOffsetW = Math.cos(rad) * (w2 ? w2 / 2 : radius);
1618
1635
  xOffset = Math.cos(rad) * radius;
@@ -2883,9 +2900,9 @@ function styleChanged$1(style, prevStyle) {
2883
2900
  return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
2884
2901
  }
2885
2902
  /*!
2886
- * Chart.js v4.4.7
2903
+ * Chart.js v4.4.8
2887
2904
  * https://www.chartjs.org
2888
- * (c) 2024 Chart.js Contributors
2905
+ * (c) 2025 Chart.js Contributors
2889
2906
  * Released under the MIT License
2890
2907
  */
2891
2908
  let Animator$1 = class Animator {
@@ -5094,10 +5111,20 @@ var adapters$1 = {
5094
5111
  function binarySearch$1(metaset, axis, value, intersect) {
5095
5112
  const { controller, data, _sorted } = metaset;
5096
5113
  const iScale = controller._cachedMeta.iScale;
5114
+ const spanGaps = metaset.dataset ? metaset.dataset.options ? metaset.dataset.options.spanGaps : null : null;
5097
5115
  if (iScale && axis === iScale.axis && axis !== "r" && _sorted && data.length) {
5098
5116
  const lookupMethod = iScale._reversePixels ? _rlookupByKey$1 : _lookupByKey$1;
5099
5117
  if (!intersect) {
5100
- return lookupMethod(data, axis, value);
5118
+ const result = lookupMethod(data, axis, value);
5119
+ if (spanGaps) {
5120
+ const { vScale } = controller._cachedMeta;
5121
+ const { _parsed } = metaset;
5122
+ const distanceToDefinedLo = _parsed.slice(0, result.lo + 1).reverse().findIndex((point) => !isNullOrUndef$1(point[vScale.axis]));
5123
+ result.lo -= Math.max(0, distanceToDefinedLo);
5124
+ const distanceToDefinedHi = _parsed.slice(result.hi).findIndex((point) => !isNullOrUndef$1(point[vScale.axis]));
5125
+ result.hi += Math.max(0, distanceToDefinedHi);
5126
+ }
5127
+ return result;
5101
5128
  } else if (controller._sharedOptions) {
5102
5129
  const el = data[0];
5103
5130
  const range = typeof el.getRange === "function" && el.getRange(axis);
@@ -7975,7 +8002,7 @@ function needContext$1(proxy, names2) {
7975
8002
  }
7976
8003
  return false;
7977
8004
  }
7978
- var version$3 = "4.4.7";
8005
+ var version$3 = "4.4.8";
7979
8006
  const KNOWN_POSITIONS$1 = [
7980
8007
  "top",
7981
8008
  "bottom",
@@ -13133,1797 +13160,1803 @@ var hammer = { exports: {} };
13133
13160
  *
13134
13161
  * Copyright (c) 2016 Jorik Tangelder;
13135
13162
  * Licensed under the MIT license */
13136
- (function(module) {
13137
- (function(window2, document2, exportName, undefined$1) {
13138
- var VENDOR_PREFIXES = ["", "webkit", "Moz", "MS", "ms", "o"];
13139
- var TEST_ELEMENT = document2.createElement("div");
13140
- var TYPE_FUNCTION = "function";
13141
- var round2 = Math.round;
13142
- var abs = Math.abs;
13143
- var now = Date.now;
13144
- function setTimeoutContext(fn, timeout, context) {
13145
- return setTimeout(bindFn(fn, context), timeout);
13146
- }
13147
- function invokeArrayArg(arg, fn, context) {
13148
- if (Array.isArray(arg)) {
13149
- each2(arg, context[fn], context);
13150
- return true;
13151
- }
13152
- return false;
13153
- }
13154
- function each2(obj, iterator, context) {
13155
- var i2;
13156
- if (!obj) {
13157
- return;
13158
- }
13159
- if (obj.forEach) {
13160
- obj.forEach(iterator, context);
13161
- } else if (obj.length !== undefined$1) {
13162
- i2 = 0;
13163
- while (i2 < obj.length) {
13164
- iterator.call(context, obj[i2], i2, obj);
13165
- i2++;
13166
- }
13167
- } else {
13168
- for (i2 in obj) {
13169
- obj.hasOwnProperty(i2) && iterator.call(context, obj[i2], i2, obj);
13163
+ var hasRequiredHammer;
13164
+ function requireHammer() {
13165
+ if (hasRequiredHammer) return hammer.exports;
13166
+ hasRequiredHammer = 1;
13167
+ (function(module) {
13168
+ (function(window2, document2, exportName, undefined$1) {
13169
+ var VENDOR_PREFIXES = ["", "webkit", "Moz", "MS", "ms", "o"];
13170
+ var TEST_ELEMENT = document2.createElement("div");
13171
+ var TYPE_FUNCTION = "function";
13172
+ var round2 = Math.round;
13173
+ var abs = Math.abs;
13174
+ var now = Date.now;
13175
+ function setTimeoutContext(fn, timeout, context) {
13176
+ return setTimeout(bindFn(fn, context), timeout);
13177
+ }
13178
+ function invokeArrayArg(arg, fn, context) {
13179
+ if (Array.isArray(arg)) {
13180
+ each2(arg, context[fn], context);
13181
+ return true;
13170
13182
  }
13183
+ return false;
13171
13184
  }
13172
- }
13173
- function deprecate(method, name, message) {
13174
- var deprecationMessage = "DEPRECATED METHOD: " + name + "\n" + message + " AT \n";
13175
- return function() {
13176
- var e2 = new Error("get-stack-trace");
13177
- var stack = e2 && e2.stack ? e2.stack.replace(/^[^\(]+?[\n$]/gm, "").replace(/^\s+at\s+/gm, "").replace(/^Object.<anonymous>\s*\(/gm, "{anonymous}()@") : "Unknown Stack Trace";
13178
- var log = window2.console && (window2.console.warn || window2.console.log);
13179
- if (log) {
13180
- log.call(window2.console, deprecationMessage, stack);
13181
- }
13182
- return method.apply(this, arguments);
13183
- };
13184
- }
13185
- var assign;
13186
- if (typeof Object.assign !== "function") {
13187
- assign = function assign2(target) {
13188
- if (target === undefined$1 || target === null) {
13189
- throw new TypeError("Cannot convert undefined or null to object");
13185
+ function each2(obj, iterator, context) {
13186
+ var i2;
13187
+ if (!obj) {
13188
+ return;
13190
13189
  }
13191
- var output = Object(target);
13192
- for (var index2 = 1; index2 < arguments.length; index2++) {
13193
- var source = arguments[index2];
13194
- if (source !== undefined$1 && source !== null) {
13195
- for (var nextKey in source) {
13196
- if (source.hasOwnProperty(nextKey)) {
13197
- output[nextKey] = source[nextKey];
13198
- }
13199
- }
13190
+ if (obj.forEach) {
13191
+ obj.forEach(iterator, context);
13192
+ } else if (obj.length !== undefined$1) {
13193
+ i2 = 0;
13194
+ while (i2 < obj.length) {
13195
+ iterator.call(context, obj[i2], i2, obj);
13196
+ i2++;
13197
+ }
13198
+ } else {
13199
+ for (i2 in obj) {
13200
+ obj.hasOwnProperty(i2) && iterator.call(context, obj[i2], i2, obj);
13200
13201
  }
13201
13202
  }
13202
- return output;
13203
- };
13204
- } else {
13205
- assign = Object.assign;
13206
- }
13207
- var extend = deprecate(function extend2(dest, src, merge3) {
13208
- var keys = Object.keys(src);
13209
- var i2 = 0;
13210
- while (i2 < keys.length) {
13211
- if (!merge3 || merge3 && dest[keys[i2]] === undefined$1) {
13212
- dest[keys[i2]] = src[keys[i2]];
13213
- }
13214
- i2++;
13215
- }
13216
- return dest;
13217
- }, "extend", "Use `assign`.");
13218
- var merge2 = deprecate(function merge3(dest, src) {
13219
- return extend(dest, src, true);
13220
- }, "merge", "Use `assign`.");
13221
- function inherit(child, base, properties) {
13222
- var baseP = base.prototype, childP;
13223
- childP = child.prototype = Object.create(baseP);
13224
- childP.constructor = child;
13225
- childP._super = baseP;
13226
- if (properties) {
13227
- assign(childP, properties);
13228
- }
13229
- }
13230
- function bindFn(fn, context) {
13231
- return function boundFn() {
13232
- return fn.apply(context, arguments);
13233
- };
13234
- }
13235
- function boolOrFn(val, args) {
13236
- if (typeof val == TYPE_FUNCTION) {
13237
- return val.apply(args ? args[0] || undefined$1 : undefined$1, args);
13238
13203
  }
13239
- return val;
13240
- }
13241
- function ifUndefined(val1, val2) {
13242
- return val1 === undefined$1 ? val2 : val1;
13243
- }
13244
- function addEventListeners(target, types, handler) {
13245
- each2(splitStr(types), function(type) {
13246
- target.addEventListener(type, handler, false);
13247
- });
13248
- }
13249
- function removeEventListeners(target, types, handler) {
13250
- each2(splitStr(types), function(type) {
13251
- target.removeEventListener(type, handler, false);
13252
- });
13253
- }
13254
- function hasParent(node, parent) {
13255
- while (node) {
13256
- if (node == parent) {
13257
- return true;
13258
- }
13259
- node = node.parentNode;
13204
+ function deprecate(method, name, message) {
13205
+ var deprecationMessage = "DEPRECATED METHOD: " + name + "\n" + message + " AT \n";
13206
+ return function() {
13207
+ var e2 = new Error("get-stack-trace");
13208
+ var stack = e2 && e2.stack ? e2.stack.replace(/^[^\(]+?[\n$]/gm, "").replace(/^\s+at\s+/gm, "").replace(/^Object.<anonymous>\s*\(/gm, "{anonymous}()@") : "Unknown Stack Trace";
13209
+ var log = window2.console && (window2.console.warn || window2.console.log);
13210
+ if (log) {
13211
+ log.call(window2.console, deprecationMessage, stack);
13212
+ }
13213
+ return method.apply(this, arguments);
13214
+ };
13260
13215
  }
13261
- return false;
13262
- }
13263
- function inStr(str, find2) {
13264
- return str.indexOf(find2) > -1;
13265
- }
13266
- function splitStr(str) {
13267
- return str.trim().split(/\s+/g);
13268
- }
13269
- function inArray(src, find2, findByKey) {
13270
- if (src.indexOf && !findByKey) {
13271
- return src.indexOf(find2);
13216
+ var assign;
13217
+ if (typeof Object.assign !== "function") {
13218
+ assign = function assign2(target) {
13219
+ if (target === undefined$1 || target === null) {
13220
+ throw new TypeError("Cannot convert undefined or null to object");
13221
+ }
13222
+ var output = Object(target);
13223
+ for (var index2 = 1; index2 < arguments.length; index2++) {
13224
+ var source = arguments[index2];
13225
+ if (source !== undefined$1 && source !== null) {
13226
+ for (var nextKey in source) {
13227
+ if (source.hasOwnProperty(nextKey)) {
13228
+ output[nextKey] = source[nextKey];
13229
+ }
13230
+ }
13231
+ }
13232
+ }
13233
+ return output;
13234
+ };
13272
13235
  } else {
13236
+ assign = Object.assign;
13237
+ }
13238
+ var extend = deprecate(function extend2(dest, src, merge3) {
13239
+ var keys = Object.keys(src);
13273
13240
  var i2 = 0;
13274
- while (i2 < src.length) {
13275
- if (findByKey && src[i2][findByKey] == find2 || !findByKey && src[i2] === find2) {
13276
- return i2;
13241
+ while (i2 < keys.length) {
13242
+ if (!merge3 || merge3 && dest[keys[i2]] === undefined$1) {
13243
+ dest[keys[i2]] = src[keys[i2]];
13277
13244
  }
13278
13245
  i2++;
13279
13246
  }
13280
- return -1;
13281
- }
13282
- }
13283
- function toArray2(obj) {
13284
- return Array.prototype.slice.call(obj, 0);
13285
- }
13286
- function uniqueArray(src, key, sort) {
13287
- var results = [];
13288
- var values = [];
13289
- var i2 = 0;
13290
- while (i2 < src.length) {
13291
- var val = src[i2][key];
13292
- if (inArray(values, val) < 0) {
13293
- results.push(src[i2]);
13247
+ return dest;
13248
+ }, "extend", "Use `assign`.");
13249
+ var merge2 = deprecate(function merge3(dest, src) {
13250
+ return extend(dest, src, true);
13251
+ }, "merge", "Use `assign`.");
13252
+ function inherit(child, base, properties) {
13253
+ var baseP = base.prototype, childP;
13254
+ childP = child.prototype = Object.create(baseP);
13255
+ childP.constructor = child;
13256
+ childP._super = baseP;
13257
+ if (properties) {
13258
+ assign(childP, properties);
13294
13259
  }
13295
- values[i2] = val;
13296
- i2++;
13297
13260
  }
13298
- {
13299
- {
13300
- results = results.sort(function sortUniqueArray(a2, b2) {
13301
- return a2[key] > b2[key];
13302
- });
13303
- }
13261
+ function bindFn(fn, context) {
13262
+ return function boundFn() {
13263
+ return fn.apply(context, arguments);
13264
+ };
13304
13265
  }
13305
- return results;
13306
- }
13307
- function prefixed(obj, property) {
13308
- var prefix, prop;
13309
- var camelProp = property[0].toUpperCase() + property.slice(1);
13310
- var i2 = 0;
13311
- while (i2 < VENDOR_PREFIXES.length) {
13312
- prefix = VENDOR_PREFIXES[i2];
13313
- prop = prefix ? prefix + camelProp : property;
13314
- if (prop in obj) {
13315
- return prop;
13266
+ function boolOrFn(val, args) {
13267
+ if (typeof val == TYPE_FUNCTION) {
13268
+ return val.apply(args ? args[0] || undefined$1 : undefined$1, args);
13316
13269
  }
13317
- i2++;
13318
- }
13319
- return undefined$1;
13320
- }
13321
- var _uniqueId = 1;
13322
- function uniqueId() {
13323
- return _uniqueId++;
13324
- }
13325
- function getWindowForElement(element) {
13326
- var doc = element.ownerDocument || element;
13327
- return doc.defaultView || doc.parentWindow || window2;
13328
- }
13329
- var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
13330
- var SUPPORT_TOUCH = "ontouchstart" in window2;
13331
- var SUPPORT_POINTER_EVENTS = prefixed(window2, "PointerEvent") !== undefined$1;
13332
- var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
13333
- var INPUT_TYPE_TOUCH = "touch";
13334
- var INPUT_TYPE_PEN = "pen";
13335
- var INPUT_TYPE_MOUSE = "mouse";
13336
- var INPUT_TYPE_KINECT = "kinect";
13337
- var COMPUTE_INTERVAL = 25;
13338
- var INPUT_START = 1;
13339
- var INPUT_MOVE = 2;
13340
- var INPUT_END = 4;
13341
- var INPUT_CANCEL = 8;
13342
- var DIRECTION_NONE = 1;
13343
- var DIRECTION_LEFT = 2;
13344
- var DIRECTION_RIGHT = 4;
13345
- var DIRECTION_UP = 8;
13346
- var DIRECTION_DOWN = 16;
13347
- var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
13348
- var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
13349
- var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
13350
- var PROPS_XY = ["x", "y"];
13351
- var PROPS_CLIENT_XY = ["clientX", "clientY"];
13352
- function Input(manager, callback2) {
13353
- var self2 = this;
13354
- this.manager = manager;
13355
- this.callback = callback2;
13356
- this.element = manager.element;
13357
- this.target = manager.options.inputTarget;
13358
- this.domHandler = function(ev) {
13359
- if (boolOrFn(manager.options.enable, [manager])) {
13360
- self2.handler(ev);
13361
- }
13362
- };
13363
- this.init();
13364
- }
13365
- Input.prototype = {
13366
- /**
13367
- * should handle the inputEvent data and trigger the callback
13368
- * @virtual
13369
- */
13370
- handler: function() {
13371
- },
13372
- /**
13373
- * bind the events
13374
- */
13375
- init: function() {
13376
- this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
13377
- this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
13378
- this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
13379
- },
13380
- /**
13381
- * unbind the events
13382
- */
13383
- destroy: function() {
13384
- this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
13385
- this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
13386
- this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
13270
+ return val;
13387
13271
  }
13388
- };
13389
- function createInputInstance(manager) {
13390
- var Type;
13391
- var inputClass = manager.options.inputClass;
13392
- if (inputClass) {
13393
- Type = inputClass;
13394
- } else if (SUPPORT_POINTER_EVENTS) {
13395
- Type = PointerEventInput;
13396
- } else if (SUPPORT_ONLY_TOUCH) {
13397
- Type = TouchInput;
13398
- } else if (!SUPPORT_TOUCH) {
13399
- Type = MouseInput;
13400
- } else {
13401
- Type = TouchMouseInput;
13402
- }
13403
- return new Type(manager, inputHandler);
13404
- }
13405
- function inputHandler(manager, eventType, input) {
13406
- var pointersLen = input.pointers.length;
13407
- var changedPointersLen = input.changedPointers.length;
13408
- var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
13409
- var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
13410
- input.isFirst = !!isFirst;
13411
- input.isFinal = !!isFinal;
13412
- if (isFirst) {
13413
- manager.session = {};
13414
- }
13415
- input.eventType = eventType;
13416
- computeInputData(manager, input);
13417
- manager.emit("hammer.input", input);
13418
- manager.recognize(input);
13419
- manager.session.prevInput = input;
13420
- }
13421
- function computeInputData(manager, input) {
13422
- var session = manager.session;
13423
- var pointers = input.pointers;
13424
- var pointersLength = pointers.length;
13425
- if (!session.firstInput) {
13426
- session.firstInput = simpleCloneInputData(input);
13427
- }
13428
- if (pointersLength > 1 && !session.firstMultiple) {
13429
- session.firstMultiple = simpleCloneInputData(input);
13430
- } else if (pointersLength === 1) {
13431
- session.firstMultiple = false;
13432
- }
13433
- var firstInput = session.firstInput;
13434
- var firstMultiple = session.firstMultiple;
13435
- var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
13436
- var center = input.center = getCenter2(pointers);
13437
- input.timeStamp = now();
13438
- input.deltaTime = input.timeStamp - firstInput.timeStamp;
13439
- input.angle = getAngle(offsetCenter, center);
13440
- input.distance = getDistance(offsetCenter, center);
13441
- computeDeltaXY(session, input);
13442
- input.offsetDirection = getDirection(input.deltaX, input.deltaY);
13443
- var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
13444
- input.overallVelocityX = overallVelocity.x;
13445
- input.overallVelocityY = overallVelocity.y;
13446
- input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
13447
- input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
13448
- input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
13449
- input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
13450
- computeIntervalInputData(session, input);
13451
- var target = manager.element;
13452
- if (hasParent(input.srcEvent.target, target)) {
13453
- target = input.srcEvent.target;
13454
- }
13455
- input.target = target;
13456
- }
13457
- function computeDeltaXY(session, input) {
13458
- var center = input.center;
13459
- var offset = session.offsetDelta || {};
13460
- var prevDelta = session.prevDelta || {};
13461
- var prevInput = session.prevInput || {};
13462
- if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
13463
- prevDelta = session.prevDelta = {
13464
- x: prevInput.deltaX || 0,
13465
- y: prevInput.deltaY || 0
13466
- };
13467
- offset = session.offsetDelta = {
13468
- x: center.x,
13469
- y: center.y
13470
- };
13272
+ function ifUndefined(val1, val2) {
13273
+ return val1 === undefined$1 ? val2 : val1;
13471
13274
  }
13472
- input.deltaX = prevDelta.x + (center.x - offset.x);
13473
- input.deltaY = prevDelta.y + (center.y - offset.y);
13474
- }
13475
- function computeIntervalInputData(session, input) {
13476
- var last = session.lastInterval || input, deltaTime = input.timeStamp - last.timeStamp, velocity, velocityX, velocityY, direction;
13477
- if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined$1)) {
13478
- var deltaX = input.deltaX - last.deltaX;
13479
- var deltaY = input.deltaY - last.deltaY;
13480
- var v2 = getVelocity(deltaTime, deltaX, deltaY);
13481
- velocityX = v2.x;
13482
- velocityY = v2.y;
13483
- velocity = abs(v2.x) > abs(v2.y) ? v2.x : v2.y;
13484
- direction = getDirection(deltaX, deltaY);
13485
- session.lastInterval = input;
13486
- } else {
13487
- velocity = last.velocity;
13488
- velocityX = last.velocityX;
13489
- velocityY = last.velocityY;
13490
- direction = last.direction;
13491
- }
13492
- input.velocity = velocity;
13493
- input.velocityX = velocityX;
13494
- input.velocityY = velocityY;
13495
- input.direction = direction;
13496
- }
13497
- function simpleCloneInputData(input) {
13498
- var pointers = [];
13499
- var i2 = 0;
13500
- while (i2 < input.pointers.length) {
13501
- pointers[i2] = {
13502
- clientX: round2(input.pointers[i2].clientX),
13503
- clientY: round2(input.pointers[i2].clientY)
13504
- };
13505
- i2++;
13275
+ function addEventListeners(target, types, handler) {
13276
+ each2(splitStr(types), function(type) {
13277
+ target.addEventListener(type, handler, false);
13278
+ });
13506
13279
  }
13507
- return {
13508
- timeStamp: now(),
13509
- pointers,
13510
- center: getCenter2(pointers),
13511
- deltaX: input.deltaX,
13512
- deltaY: input.deltaY
13513
- };
13514
- }
13515
- function getCenter2(pointers) {
13516
- var pointersLength = pointers.length;
13517
- if (pointersLength === 1) {
13518
- return {
13519
- x: round2(pointers[0].clientX),
13520
- y: round2(pointers[0].clientY)
13521
- };
13280
+ function removeEventListeners(target, types, handler) {
13281
+ each2(splitStr(types), function(type) {
13282
+ target.removeEventListener(type, handler, false);
13283
+ });
13522
13284
  }
13523
- var x2 = 0, y2 = 0, i2 = 0;
13524
- while (i2 < pointersLength) {
13525
- x2 += pointers[i2].clientX;
13526
- y2 += pointers[i2].clientY;
13527
- i2++;
13285
+ function hasParent(node, parent) {
13286
+ while (node) {
13287
+ if (node == parent) {
13288
+ return true;
13289
+ }
13290
+ node = node.parentNode;
13291
+ }
13292
+ return false;
13528
13293
  }
13529
- return {
13530
- x: round2(x2 / pointersLength),
13531
- y: round2(y2 / pointersLength)
13532
- };
13533
- }
13534
- function getVelocity(deltaTime, x2, y2) {
13535
- return {
13536
- x: x2 / deltaTime || 0,
13537
- y: y2 / deltaTime || 0
13538
- };
13539
- }
13540
- function getDirection(x2, y2) {
13541
- if (x2 === y2) {
13542
- return DIRECTION_NONE;
13294
+ function inStr(str, find2) {
13295
+ return str.indexOf(find2) > -1;
13543
13296
  }
13544
- if (abs(x2) >= abs(y2)) {
13545
- return x2 < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
13297
+ function splitStr(str) {
13298
+ return str.trim().split(/\s+/g);
13546
13299
  }
13547
- return y2 < 0 ? DIRECTION_UP : DIRECTION_DOWN;
13548
- }
13549
- function getDistance(p1, p2, props) {
13550
- if (!props) {
13551
- props = PROPS_XY;
13300
+ function inArray(src, find2, findByKey) {
13301
+ if (src.indexOf && !findByKey) {
13302
+ return src.indexOf(find2);
13303
+ } else {
13304
+ var i2 = 0;
13305
+ while (i2 < src.length) {
13306
+ if (findByKey && src[i2][findByKey] == find2 || !findByKey && src[i2] === find2) {
13307
+ return i2;
13308
+ }
13309
+ i2++;
13310
+ }
13311
+ return -1;
13312
+ }
13552
13313
  }
13553
- var x2 = p2[props[0]] - p1[props[0]], y2 = p2[props[1]] - p1[props[1]];
13554
- return Math.sqrt(x2 * x2 + y2 * y2);
13555
- }
13556
- function getAngle(p1, p2, props) {
13557
- if (!props) {
13558
- props = PROPS_XY;
13314
+ function toArray2(obj) {
13315
+ return Array.prototype.slice.call(obj, 0);
13559
13316
  }
13560
- var x2 = p2[props[0]] - p1[props[0]], y2 = p2[props[1]] - p1[props[1]];
13561
- return Math.atan2(y2, x2) * 180 / Math.PI;
13562
- }
13563
- function getRotation(start, end) {
13564
- return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
13565
- }
13566
- function getScale(start, end) {
13567
- return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
13568
- }
13569
- var MOUSE_INPUT_MAP = {
13570
- mousedown: INPUT_START,
13571
- mousemove: INPUT_MOVE,
13572
- mouseup: INPUT_END
13573
- };
13574
- var MOUSE_ELEMENT_EVENTS = "mousedown";
13575
- var MOUSE_WINDOW_EVENTS = "mousemove mouseup";
13576
- function MouseInput() {
13577
- this.evEl = MOUSE_ELEMENT_EVENTS;
13578
- this.evWin = MOUSE_WINDOW_EVENTS;
13579
- this.pressed = false;
13580
- Input.apply(this, arguments);
13581
- }
13582
- inherit(MouseInput, Input, {
13583
- /**
13584
- * handle mouse events
13585
- * @param {Object} ev
13586
- */
13587
- handler: function MEhandler(ev) {
13588
- var eventType = MOUSE_INPUT_MAP[ev.type];
13589
- if (eventType & INPUT_START && ev.button === 0) {
13590
- this.pressed = true;
13591
- }
13592
- if (eventType & INPUT_MOVE && ev.which !== 1) {
13593
- eventType = INPUT_END;
13594
- }
13595
- if (!this.pressed) {
13596
- return;
13317
+ function uniqueArray(src, key, sort) {
13318
+ var results = [];
13319
+ var values = [];
13320
+ var i2 = 0;
13321
+ while (i2 < src.length) {
13322
+ var val = src[i2][key];
13323
+ if (inArray(values, val) < 0) {
13324
+ results.push(src[i2]);
13325
+ }
13326
+ values[i2] = val;
13327
+ i2++;
13597
13328
  }
13598
- if (eventType & INPUT_END) {
13599
- this.pressed = false;
13329
+ {
13330
+ {
13331
+ results = results.sort(function sortUniqueArray(a2, b2) {
13332
+ return a2[key] > b2[key];
13333
+ });
13334
+ }
13600
13335
  }
13601
- this.callback(this.manager, eventType, {
13602
- pointers: [ev],
13603
- changedPointers: [ev],
13604
- pointerType: INPUT_TYPE_MOUSE,
13605
- srcEvent: ev
13606
- });
13336
+ return results;
13607
13337
  }
13608
- });
13609
- var POINTER_INPUT_MAP = {
13610
- pointerdown: INPUT_START,
13611
- pointermove: INPUT_MOVE,
13612
- pointerup: INPUT_END,
13613
- pointercancel: INPUT_CANCEL,
13614
- pointerout: INPUT_CANCEL
13615
- };
13616
- var IE10_POINTER_TYPE_ENUM = {
13617
- 2: INPUT_TYPE_TOUCH,
13618
- 3: INPUT_TYPE_PEN,
13619
- 4: INPUT_TYPE_MOUSE,
13620
- 5: INPUT_TYPE_KINECT
13621
- // see https://twitter.com/jacobrossi/status/480596438489890816
13622
- };
13623
- var POINTER_ELEMENT_EVENTS = "pointerdown";
13624
- var POINTER_WINDOW_EVENTS = "pointermove pointerup pointercancel";
13625
- if (window2.MSPointerEvent && !window2.PointerEvent) {
13626
- POINTER_ELEMENT_EVENTS = "MSPointerDown";
13627
- POINTER_WINDOW_EVENTS = "MSPointerMove MSPointerUp MSPointerCancel";
13628
- }
13629
- function PointerEventInput() {
13630
- this.evEl = POINTER_ELEMENT_EVENTS;
13631
- this.evWin = POINTER_WINDOW_EVENTS;
13632
- Input.apply(this, arguments);
13633
- this.store = this.manager.session.pointerEvents = [];
13634
- }
13635
- inherit(PointerEventInput, Input, {
13636
- /**
13637
- * handle mouse events
13638
- * @param {Object} ev
13639
- */
13640
- handler: function PEhandler(ev) {
13641
- var store = this.store;
13642
- var removePointer = false;
13643
- var eventTypeNormalized = ev.type.toLowerCase().replace("ms", "");
13644
- var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
13645
- var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
13646
- var isTouch = pointerType == INPUT_TYPE_TOUCH;
13647
- var storeIndex = inArray(store, ev.pointerId, "pointerId");
13648
- if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
13649
- if (storeIndex < 0) {
13650
- store.push(ev);
13651
- storeIndex = store.length - 1;
13338
+ function prefixed(obj, property) {
13339
+ var prefix, prop;
13340
+ var camelProp = property[0].toUpperCase() + property.slice(1);
13341
+ var i2 = 0;
13342
+ while (i2 < VENDOR_PREFIXES.length) {
13343
+ prefix = VENDOR_PREFIXES[i2];
13344
+ prop = prefix ? prefix + camelProp : property;
13345
+ if (prop in obj) {
13346
+ return prop;
13652
13347
  }
13653
- } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
13654
- removePointer = true;
13348
+ i2++;
13655
13349
  }
13656
- if (storeIndex < 0) {
13657
- return;
13350
+ return undefined$1;
13351
+ }
13352
+ var _uniqueId = 1;
13353
+ function uniqueId() {
13354
+ return _uniqueId++;
13355
+ }
13356
+ function getWindowForElement(element) {
13357
+ var doc = element.ownerDocument || element;
13358
+ return doc.defaultView || doc.parentWindow || window2;
13359
+ }
13360
+ var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
13361
+ var SUPPORT_TOUCH = "ontouchstart" in window2;
13362
+ var SUPPORT_POINTER_EVENTS = prefixed(window2, "PointerEvent") !== undefined$1;
13363
+ var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
13364
+ var INPUT_TYPE_TOUCH = "touch";
13365
+ var INPUT_TYPE_PEN = "pen";
13366
+ var INPUT_TYPE_MOUSE = "mouse";
13367
+ var INPUT_TYPE_KINECT = "kinect";
13368
+ var COMPUTE_INTERVAL = 25;
13369
+ var INPUT_START = 1;
13370
+ var INPUT_MOVE = 2;
13371
+ var INPUT_END = 4;
13372
+ var INPUT_CANCEL = 8;
13373
+ var DIRECTION_NONE = 1;
13374
+ var DIRECTION_LEFT = 2;
13375
+ var DIRECTION_RIGHT = 4;
13376
+ var DIRECTION_UP = 8;
13377
+ var DIRECTION_DOWN = 16;
13378
+ var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
13379
+ var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
13380
+ var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
13381
+ var PROPS_XY = ["x", "y"];
13382
+ var PROPS_CLIENT_XY = ["clientX", "clientY"];
13383
+ function Input(manager, callback2) {
13384
+ var self2 = this;
13385
+ this.manager = manager;
13386
+ this.callback = callback2;
13387
+ this.element = manager.element;
13388
+ this.target = manager.options.inputTarget;
13389
+ this.domHandler = function(ev) {
13390
+ if (boolOrFn(manager.options.enable, [manager])) {
13391
+ self2.handler(ev);
13392
+ }
13393
+ };
13394
+ this.init();
13395
+ }
13396
+ Input.prototype = {
13397
+ /**
13398
+ * should handle the inputEvent data and trigger the callback
13399
+ * @virtual
13400
+ */
13401
+ handler: function() {
13402
+ },
13403
+ /**
13404
+ * bind the events
13405
+ */
13406
+ init: function() {
13407
+ this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
13408
+ this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
13409
+ this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
13410
+ },
13411
+ /**
13412
+ * unbind the events
13413
+ */
13414
+ destroy: function() {
13415
+ this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
13416
+ this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
13417
+ this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
13658
13418
  }
13659
- store[storeIndex] = ev;
13660
- this.callback(this.manager, eventType, {
13661
- pointers: store,
13662
- changedPointers: [ev],
13663
- pointerType,
13664
- srcEvent: ev
13665
- });
13666
- if (removePointer) {
13667
- store.splice(storeIndex, 1);
13419
+ };
13420
+ function createInputInstance(manager) {
13421
+ var Type;
13422
+ var inputClass = manager.options.inputClass;
13423
+ if (inputClass) {
13424
+ Type = inputClass;
13425
+ } else if (SUPPORT_POINTER_EVENTS) {
13426
+ Type = PointerEventInput;
13427
+ } else if (SUPPORT_ONLY_TOUCH) {
13428
+ Type = TouchInput;
13429
+ } else if (!SUPPORT_TOUCH) {
13430
+ Type = MouseInput;
13431
+ } else {
13432
+ Type = TouchMouseInput;
13668
13433
  }
13669
- }
13670
- });
13671
- var SINGLE_TOUCH_INPUT_MAP = {
13672
- touchstart: INPUT_START,
13673
- touchmove: INPUT_MOVE,
13674
- touchend: INPUT_END,
13675
- touchcancel: INPUT_CANCEL
13676
- };
13677
- var SINGLE_TOUCH_TARGET_EVENTS = "touchstart";
13678
- var SINGLE_TOUCH_WINDOW_EVENTS = "touchstart touchmove touchend touchcancel";
13679
- function SingleTouchInput() {
13680
- this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
13681
- this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
13682
- this.started = false;
13683
- Input.apply(this, arguments);
13684
- }
13685
- inherit(SingleTouchInput, Input, {
13686
- handler: function TEhandler(ev) {
13687
- var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
13688
- if (type === INPUT_START) {
13689
- this.started = true;
13434
+ return new Type(manager, inputHandler);
13435
+ }
13436
+ function inputHandler(manager, eventType, input) {
13437
+ var pointersLen = input.pointers.length;
13438
+ var changedPointersLen = input.changedPointers.length;
13439
+ var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
13440
+ var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
13441
+ input.isFirst = !!isFirst;
13442
+ input.isFinal = !!isFinal;
13443
+ if (isFirst) {
13444
+ manager.session = {};
13690
13445
  }
13691
- if (!this.started) {
13692
- return;
13446
+ input.eventType = eventType;
13447
+ computeInputData(manager, input);
13448
+ manager.emit("hammer.input", input);
13449
+ manager.recognize(input);
13450
+ manager.session.prevInput = input;
13451
+ }
13452
+ function computeInputData(manager, input) {
13453
+ var session = manager.session;
13454
+ var pointers = input.pointers;
13455
+ var pointersLength = pointers.length;
13456
+ if (!session.firstInput) {
13457
+ session.firstInput = simpleCloneInputData(input);
13693
13458
  }
13694
- var touches = normalizeSingleTouches.call(this, ev, type);
13695
- if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
13696
- this.started = false;
13459
+ if (pointersLength > 1 && !session.firstMultiple) {
13460
+ session.firstMultiple = simpleCloneInputData(input);
13461
+ } else if (pointersLength === 1) {
13462
+ session.firstMultiple = false;
13697
13463
  }
13698
- this.callback(this.manager, type, {
13699
- pointers: touches[0],
13700
- changedPointers: touches[1],
13701
- pointerType: INPUT_TYPE_TOUCH,
13702
- srcEvent: ev
13703
- });
13704
- }
13705
- });
13706
- function normalizeSingleTouches(ev, type) {
13707
- var all = toArray2(ev.touches);
13708
- var changed = toArray2(ev.changedTouches);
13709
- if (type & (INPUT_END | INPUT_CANCEL)) {
13710
- all = uniqueArray(all.concat(changed), "identifier");
13711
- }
13712
- return [all, changed];
13713
- }
13714
- var TOUCH_INPUT_MAP = {
13715
- touchstart: INPUT_START,
13716
- touchmove: INPUT_MOVE,
13717
- touchend: INPUT_END,
13718
- touchcancel: INPUT_CANCEL
13719
- };
13720
- var TOUCH_TARGET_EVENTS = "touchstart touchmove touchend touchcancel";
13721
- function TouchInput() {
13722
- this.evTarget = TOUCH_TARGET_EVENTS;
13723
- this.targetIds = {};
13724
- Input.apply(this, arguments);
13725
- }
13726
- inherit(TouchInput, Input, {
13727
- handler: function MTEhandler(ev) {
13728
- var type = TOUCH_INPUT_MAP[ev.type];
13729
- var touches = getTouches.call(this, ev, type);
13730
- if (!touches) {
13731
- return;
13464
+ var firstInput = session.firstInput;
13465
+ var firstMultiple = session.firstMultiple;
13466
+ var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
13467
+ var center = input.center = getCenter2(pointers);
13468
+ input.timeStamp = now();
13469
+ input.deltaTime = input.timeStamp - firstInput.timeStamp;
13470
+ input.angle = getAngle(offsetCenter, center);
13471
+ input.distance = getDistance(offsetCenter, center);
13472
+ computeDeltaXY(session, input);
13473
+ input.offsetDirection = getDirection(input.deltaX, input.deltaY);
13474
+ var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
13475
+ input.overallVelocityX = overallVelocity.x;
13476
+ input.overallVelocityY = overallVelocity.y;
13477
+ input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
13478
+ input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
13479
+ input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
13480
+ input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
13481
+ computeIntervalInputData(session, input);
13482
+ var target = manager.element;
13483
+ if (hasParent(input.srcEvent.target, target)) {
13484
+ target = input.srcEvent.target;
13732
13485
  }
13733
- this.callback(this.manager, type, {
13734
- pointers: touches[0],
13735
- changedPointers: touches[1],
13736
- pointerType: INPUT_TYPE_TOUCH,
13737
- srcEvent: ev
13738
- });
13486
+ input.target = target;
13487
+ }
13488
+ function computeDeltaXY(session, input) {
13489
+ var center = input.center;
13490
+ var offset = session.offsetDelta || {};
13491
+ var prevDelta = session.prevDelta || {};
13492
+ var prevInput = session.prevInput || {};
13493
+ if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
13494
+ prevDelta = session.prevDelta = {
13495
+ x: prevInput.deltaX || 0,
13496
+ y: prevInput.deltaY || 0
13497
+ };
13498
+ offset = session.offsetDelta = {
13499
+ x: center.x,
13500
+ y: center.y
13501
+ };
13502
+ }
13503
+ input.deltaX = prevDelta.x + (center.x - offset.x);
13504
+ input.deltaY = prevDelta.y + (center.y - offset.y);
13505
+ }
13506
+ function computeIntervalInputData(session, input) {
13507
+ var last = session.lastInterval || input, deltaTime = input.timeStamp - last.timeStamp, velocity, velocityX, velocityY, direction;
13508
+ if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined$1)) {
13509
+ var deltaX = input.deltaX - last.deltaX;
13510
+ var deltaY = input.deltaY - last.deltaY;
13511
+ var v2 = getVelocity(deltaTime, deltaX, deltaY);
13512
+ velocityX = v2.x;
13513
+ velocityY = v2.y;
13514
+ velocity = abs(v2.x) > abs(v2.y) ? v2.x : v2.y;
13515
+ direction = getDirection(deltaX, deltaY);
13516
+ session.lastInterval = input;
13517
+ } else {
13518
+ velocity = last.velocity;
13519
+ velocityX = last.velocityX;
13520
+ velocityY = last.velocityY;
13521
+ direction = last.direction;
13522
+ }
13523
+ input.velocity = velocity;
13524
+ input.velocityX = velocityX;
13525
+ input.velocityY = velocityY;
13526
+ input.direction = direction;
13739
13527
  }
13740
- });
13741
- function getTouches(ev, type) {
13742
- var allTouches = toArray2(ev.touches);
13743
- var targetIds = this.targetIds;
13744
- if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
13745
- targetIds[allTouches[0].identifier] = true;
13746
- return [allTouches, allTouches];
13747
- }
13748
- var i2, targetTouches, changedTouches = toArray2(ev.changedTouches), changedTargetTouches = [], target = this.target;
13749
- targetTouches = allTouches.filter(function(touch) {
13750
- return hasParent(touch.target, target);
13751
- });
13752
- if (type === INPUT_START) {
13753
- i2 = 0;
13754
- while (i2 < targetTouches.length) {
13755
- targetIds[targetTouches[i2].identifier] = true;
13528
+ function simpleCloneInputData(input) {
13529
+ var pointers = [];
13530
+ var i2 = 0;
13531
+ while (i2 < input.pointers.length) {
13532
+ pointers[i2] = {
13533
+ clientX: round2(input.pointers[i2].clientX),
13534
+ clientY: round2(input.pointers[i2].clientY)
13535
+ };
13756
13536
  i2++;
13757
13537
  }
13538
+ return {
13539
+ timeStamp: now(),
13540
+ pointers,
13541
+ center: getCenter2(pointers),
13542
+ deltaX: input.deltaX,
13543
+ deltaY: input.deltaY
13544
+ };
13758
13545
  }
13759
- i2 = 0;
13760
- while (i2 < changedTouches.length) {
13761
- if (targetIds[changedTouches[i2].identifier]) {
13762
- changedTargetTouches.push(changedTouches[i2]);
13546
+ function getCenter2(pointers) {
13547
+ var pointersLength = pointers.length;
13548
+ if (pointersLength === 1) {
13549
+ return {
13550
+ x: round2(pointers[0].clientX),
13551
+ y: round2(pointers[0].clientY)
13552
+ };
13763
13553
  }
13764
- if (type & (INPUT_END | INPUT_CANCEL)) {
13765
- delete targetIds[changedTouches[i2].identifier];
13554
+ var x2 = 0, y2 = 0, i2 = 0;
13555
+ while (i2 < pointersLength) {
13556
+ x2 += pointers[i2].clientX;
13557
+ y2 += pointers[i2].clientY;
13558
+ i2++;
13766
13559
  }
13767
- i2++;
13560
+ return {
13561
+ x: round2(x2 / pointersLength),
13562
+ y: round2(y2 / pointersLength)
13563
+ };
13768
13564
  }
13769
- if (!changedTargetTouches.length) {
13770
- return;
13565
+ function getVelocity(deltaTime, x2, y2) {
13566
+ return {
13567
+ x: x2 / deltaTime || 0,
13568
+ y: y2 / deltaTime || 0
13569
+ };
13771
13570
  }
13772
- return [
13773
- // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
13774
- uniqueArray(targetTouches.concat(changedTargetTouches), "identifier"),
13775
- changedTargetTouches
13776
- ];
13777
- }
13778
- var DEDUP_TIMEOUT = 2500;
13779
- var DEDUP_DISTANCE = 25;
13780
- function TouchMouseInput() {
13781
- Input.apply(this, arguments);
13782
- var handler = bindFn(this.handler, this);
13783
- this.touch = new TouchInput(this.manager, handler);
13784
- this.mouse = new MouseInput(this.manager, handler);
13785
- this.primaryTouch = null;
13786
- this.lastTouches = [];
13787
- }
13788
- inherit(TouchMouseInput, Input, {
13789
- /**
13790
- * handle mouse and touch events
13791
- * @param {Hammer} manager
13792
- * @param {String} inputEvent
13793
- * @param {Object} inputData
13794
- */
13795
- handler: function TMEhandler(manager, inputEvent, inputData) {
13796
- var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH, isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
13797
- if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
13798
- return;
13571
+ function getDirection(x2, y2) {
13572
+ if (x2 === y2) {
13573
+ return DIRECTION_NONE;
13799
13574
  }
13800
- if (isTouch) {
13801
- recordTouches.call(this, inputEvent, inputData);
13802
- } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
13803
- return;
13575
+ if (abs(x2) >= abs(y2)) {
13576
+ return x2 < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
13804
13577
  }
13805
- this.callback(manager, inputEvent, inputData);
13806
- },
13807
- /**
13808
- * remove the event listeners
13809
- */
13810
- destroy: function destroy() {
13811
- this.touch.destroy();
13812
- this.mouse.destroy();
13578
+ return y2 < 0 ? DIRECTION_UP : DIRECTION_DOWN;
13813
13579
  }
13814
- });
13815
- function recordTouches(eventType, eventData) {
13816
- if (eventType & INPUT_START) {
13817
- this.primaryTouch = eventData.changedPointers[0].identifier;
13818
- setLastTouch.call(this, eventData);
13819
- } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
13820
- setLastTouch.call(this, eventData);
13821
- }
13822
- }
13823
- function setLastTouch(eventData) {
13824
- var touch = eventData.changedPointers[0];
13825
- if (touch.identifier === this.primaryTouch) {
13826
- var lastTouch = { x: touch.clientX, y: touch.clientY };
13827
- this.lastTouches.push(lastTouch);
13828
- var lts = this.lastTouches;
13829
- var removeLastTouch = function() {
13830
- var i2 = lts.indexOf(lastTouch);
13831
- if (i2 > -1) {
13832
- lts.splice(i2, 1);
13833
- }
13834
- };
13835
- setTimeout(removeLastTouch, DEDUP_TIMEOUT);
13580
+ function getDistance(p1, p2, props) {
13581
+ if (!props) {
13582
+ props = PROPS_XY;
13583
+ }
13584
+ var x2 = p2[props[0]] - p1[props[0]], y2 = p2[props[1]] - p1[props[1]];
13585
+ return Math.sqrt(x2 * x2 + y2 * y2);
13836
13586
  }
13837
- }
13838
- function isSyntheticEvent(eventData) {
13839
- var x2 = eventData.srcEvent.clientX, y2 = eventData.srcEvent.clientY;
13840
- for (var i2 = 0; i2 < this.lastTouches.length; i2++) {
13841
- var t = this.lastTouches[i2];
13842
- var dx = Math.abs(x2 - t.x), dy = Math.abs(y2 - t.y);
13843
- if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
13844
- return true;
13587
+ function getAngle(p1, p2, props) {
13588
+ if (!props) {
13589
+ props = PROPS_XY;
13845
13590
  }
13591
+ var x2 = p2[props[0]] - p1[props[0]], y2 = p2[props[1]] - p1[props[1]];
13592
+ return Math.atan2(y2, x2) * 180 / Math.PI;
13846
13593
  }
13847
- return false;
13848
- }
13849
- var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, "touchAction");
13850
- var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined$1;
13851
- var TOUCH_ACTION_COMPUTE = "compute";
13852
- var TOUCH_ACTION_AUTO = "auto";
13853
- var TOUCH_ACTION_MANIPULATION = "manipulation";
13854
- var TOUCH_ACTION_NONE = "none";
13855
- var TOUCH_ACTION_PAN_X = "pan-x";
13856
- var TOUCH_ACTION_PAN_Y = "pan-y";
13857
- var TOUCH_ACTION_MAP = getTouchActionProps();
13858
- function TouchAction(manager, value) {
13859
- this.manager = manager;
13860
- this.set(value);
13861
- }
13862
- TouchAction.prototype = {
13863
- /**
13864
- * set the touchAction value on the element or enable the polyfill
13865
- * @param {String} value
13866
- */
13867
- set: function(value) {
13868
- if (value == TOUCH_ACTION_COMPUTE) {
13869
- value = this.compute();
13594
+ function getRotation(start, end) {
13595
+ return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
13596
+ }
13597
+ function getScale(start, end) {
13598
+ return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
13599
+ }
13600
+ var MOUSE_INPUT_MAP = {
13601
+ mousedown: INPUT_START,
13602
+ mousemove: INPUT_MOVE,
13603
+ mouseup: INPUT_END
13604
+ };
13605
+ var MOUSE_ELEMENT_EVENTS = "mousedown";
13606
+ var MOUSE_WINDOW_EVENTS = "mousemove mouseup";
13607
+ function MouseInput() {
13608
+ this.evEl = MOUSE_ELEMENT_EVENTS;
13609
+ this.evWin = MOUSE_WINDOW_EVENTS;
13610
+ this.pressed = false;
13611
+ Input.apply(this, arguments);
13612
+ }
13613
+ inherit(MouseInput, Input, {
13614
+ /**
13615
+ * handle mouse events
13616
+ * @param {Object} ev
13617
+ */
13618
+ handler: function MEhandler(ev) {
13619
+ var eventType = MOUSE_INPUT_MAP[ev.type];
13620
+ if (eventType & INPUT_START && ev.button === 0) {
13621
+ this.pressed = true;
13622
+ }
13623
+ if (eventType & INPUT_MOVE && ev.which !== 1) {
13624
+ eventType = INPUT_END;
13625
+ }
13626
+ if (!this.pressed) {
13627
+ return;
13628
+ }
13629
+ if (eventType & INPUT_END) {
13630
+ this.pressed = false;
13631
+ }
13632
+ this.callback(this.manager, eventType, {
13633
+ pointers: [ev],
13634
+ changedPointers: [ev],
13635
+ pointerType: INPUT_TYPE_MOUSE,
13636
+ srcEvent: ev
13637
+ });
13870
13638
  }
13871
- if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
13872
- this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
13639
+ });
13640
+ var POINTER_INPUT_MAP = {
13641
+ pointerdown: INPUT_START,
13642
+ pointermove: INPUT_MOVE,
13643
+ pointerup: INPUT_END,
13644
+ pointercancel: INPUT_CANCEL,
13645
+ pointerout: INPUT_CANCEL
13646
+ };
13647
+ var IE10_POINTER_TYPE_ENUM = {
13648
+ 2: INPUT_TYPE_TOUCH,
13649
+ 3: INPUT_TYPE_PEN,
13650
+ 4: INPUT_TYPE_MOUSE,
13651
+ 5: INPUT_TYPE_KINECT
13652
+ // see https://twitter.com/jacobrossi/status/480596438489890816
13653
+ };
13654
+ var POINTER_ELEMENT_EVENTS = "pointerdown";
13655
+ var POINTER_WINDOW_EVENTS = "pointermove pointerup pointercancel";
13656
+ if (window2.MSPointerEvent && !window2.PointerEvent) {
13657
+ POINTER_ELEMENT_EVENTS = "MSPointerDown";
13658
+ POINTER_WINDOW_EVENTS = "MSPointerMove MSPointerUp MSPointerCancel";
13659
+ }
13660
+ function PointerEventInput() {
13661
+ this.evEl = POINTER_ELEMENT_EVENTS;
13662
+ this.evWin = POINTER_WINDOW_EVENTS;
13663
+ Input.apply(this, arguments);
13664
+ this.store = this.manager.session.pointerEvents = [];
13665
+ }
13666
+ inherit(PointerEventInput, Input, {
13667
+ /**
13668
+ * handle mouse events
13669
+ * @param {Object} ev
13670
+ */
13671
+ handler: function PEhandler(ev) {
13672
+ var store = this.store;
13673
+ var removePointer = false;
13674
+ var eventTypeNormalized = ev.type.toLowerCase().replace("ms", "");
13675
+ var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
13676
+ var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
13677
+ var isTouch = pointerType == INPUT_TYPE_TOUCH;
13678
+ var storeIndex = inArray(store, ev.pointerId, "pointerId");
13679
+ if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
13680
+ if (storeIndex < 0) {
13681
+ store.push(ev);
13682
+ storeIndex = store.length - 1;
13683
+ }
13684
+ } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
13685
+ removePointer = true;
13686
+ }
13687
+ if (storeIndex < 0) {
13688
+ return;
13689
+ }
13690
+ store[storeIndex] = ev;
13691
+ this.callback(this.manager, eventType, {
13692
+ pointers: store,
13693
+ changedPointers: [ev],
13694
+ pointerType,
13695
+ srcEvent: ev
13696
+ });
13697
+ if (removePointer) {
13698
+ store.splice(storeIndex, 1);
13699
+ }
13873
13700
  }
13874
- this.actions = value.toLowerCase().trim();
13875
- },
13876
- /**
13877
- * just re-set the touchAction value
13878
- */
13879
- update: function() {
13880
- this.set(this.manager.options.touchAction);
13881
- },
13882
- /**
13883
- * compute the value for the touchAction property based on the recognizer's settings
13884
- * @returns {String} value
13885
- */
13886
- compute: function() {
13887
- var actions2 = [];
13888
- each2(this.manager.recognizers, function(recognizer) {
13889
- if (boolOrFn(recognizer.options.enable, [recognizer])) {
13890
- actions2 = actions2.concat(recognizer.getTouchAction());
13701
+ });
13702
+ var SINGLE_TOUCH_INPUT_MAP = {
13703
+ touchstart: INPUT_START,
13704
+ touchmove: INPUT_MOVE,
13705
+ touchend: INPUT_END,
13706
+ touchcancel: INPUT_CANCEL
13707
+ };
13708
+ var SINGLE_TOUCH_TARGET_EVENTS = "touchstart";
13709
+ var SINGLE_TOUCH_WINDOW_EVENTS = "touchstart touchmove touchend touchcancel";
13710
+ function SingleTouchInput() {
13711
+ this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
13712
+ this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
13713
+ this.started = false;
13714
+ Input.apply(this, arguments);
13715
+ }
13716
+ inherit(SingleTouchInput, Input, {
13717
+ handler: function TEhandler(ev) {
13718
+ var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
13719
+ if (type === INPUT_START) {
13720
+ this.started = true;
13891
13721
  }
13892
- });
13893
- return cleanTouchActions(actions2.join(" "));
13894
- },
13895
- /**
13896
- * this method is called on each input cycle and provides the preventing of the browser behavior
13897
- * @param {Object} input
13898
- */
13899
- preventDefaults: function(input) {
13900
- var srcEvent = input.srcEvent;
13901
- var direction = input.offsetDirection;
13902
- if (this.manager.session.prevented) {
13903
- srcEvent.preventDefault();
13904
- return;
13722
+ if (!this.started) {
13723
+ return;
13724
+ }
13725
+ var touches = normalizeSingleTouches.call(this, ev, type);
13726
+ if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
13727
+ this.started = false;
13728
+ }
13729
+ this.callback(this.manager, type, {
13730
+ pointers: touches[0],
13731
+ changedPointers: touches[1],
13732
+ pointerType: INPUT_TYPE_TOUCH,
13733
+ srcEvent: ev
13734
+ });
13735
+ }
13736
+ });
13737
+ function normalizeSingleTouches(ev, type) {
13738
+ var all = toArray2(ev.touches);
13739
+ var changed = toArray2(ev.changedTouches);
13740
+ if (type & (INPUT_END | INPUT_CANCEL)) {
13741
+ all = uniqueArray(all.concat(changed), "identifier");
13905
13742
  }
13906
- var actions2 = this.actions;
13907
- var hasNone = inStr(actions2, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
13908
- var hasPanY = inStr(actions2, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
13909
- var hasPanX = inStr(actions2, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
13910
- if (hasNone) {
13911
- var isTapPointer = input.pointers.length === 1;
13912
- var isTapMovement = input.distance < 2;
13913
- var isTapTouchTime = input.deltaTime < 250;
13914
- if (isTapPointer && isTapMovement && isTapTouchTime) {
13743
+ return [all, changed];
13744
+ }
13745
+ var TOUCH_INPUT_MAP = {
13746
+ touchstart: INPUT_START,
13747
+ touchmove: INPUT_MOVE,
13748
+ touchend: INPUT_END,
13749
+ touchcancel: INPUT_CANCEL
13750
+ };
13751
+ var TOUCH_TARGET_EVENTS = "touchstart touchmove touchend touchcancel";
13752
+ function TouchInput() {
13753
+ this.evTarget = TOUCH_TARGET_EVENTS;
13754
+ this.targetIds = {};
13755
+ Input.apply(this, arguments);
13756
+ }
13757
+ inherit(TouchInput, Input, {
13758
+ handler: function MTEhandler(ev) {
13759
+ var type = TOUCH_INPUT_MAP[ev.type];
13760
+ var touches = getTouches.call(this, ev, type);
13761
+ if (!touches) {
13915
13762
  return;
13916
13763
  }
13764
+ this.callback(this.manager, type, {
13765
+ pointers: touches[0],
13766
+ changedPointers: touches[1],
13767
+ pointerType: INPUT_TYPE_TOUCH,
13768
+ srcEvent: ev
13769
+ });
13917
13770
  }
13918
- if (hasPanX && hasPanY) {
13919
- return;
13771
+ });
13772
+ function getTouches(ev, type) {
13773
+ var allTouches = toArray2(ev.touches);
13774
+ var targetIds = this.targetIds;
13775
+ if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
13776
+ targetIds[allTouches[0].identifier] = true;
13777
+ return [allTouches, allTouches];
13920
13778
  }
13921
- if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
13922
- return this.preventSrc(srcEvent);
13779
+ var i2, targetTouches, changedTouches = toArray2(ev.changedTouches), changedTargetTouches = [], target = this.target;
13780
+ targetTouches = allTouches.filter(function(touch) {
13781
+ return hasParent(touch.target, target);
13782
+ });
13783
+ if (type === INPUT_START) {
13784
+ i2 = 0;
13785
+ while (i2 < targetTouches.length) {
13786
+ targetIds[targetTouches[i2].identifier] = true;
13787
+ i2++;
13788
+ }
13923
13789
  }
13924
- },
13925
- /**
13926
- * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
13927
- * @param {Object} srcEvent
13928
- */
13929
- preventSrc: function(srcEvent) {
13930
- this.manager.session.prevented = true;
13931
- srcEvent.preventDefault();
13932
- }
13933
- };
13934
- function cleanTouchActions(actions2) {
13935
- if (inStr(actions2, TOUCH_ACTION_NONE)) {
13936
- return TOUCH_ACTION_NONE;
13937
- }
13938
- var hasPanX = inStr(actions2, TOUCH_ACTION_PAN_X);
13939
- var hasPanY = inStr(actions2, TOUCH_ACTION_PAN_Y);
13940
- if (hasPanX && hasPanY) {
13941
- return TOUCH_ACTION_NONE;
13942
- }
13943
- if (hasPanX || hasPanY) {
13944
- return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
13945
- }
13946
- if (inStr(actions2, TOUCH_ACTION_MANIPULATION)) {
13947
- return TOUCH_ACTION_MANIPULATION;
13948
- }
13949
- return TOUCH_ACTION_AUTO;
13950
- }
13951
- function getTouchActionProps() {
13952
- if (!NATIVE_TOUCH_ACTION) {
13953
- return false;
13954
- }
13955
- var touchMap = {};
13956
- var cssSupports = window2.CSS && window2.CSS.supports;
13957
- ["auto", "manipulation", "pan-y", "pan-x", "pan-x pan-y", "none"].forEach(function(val) {
13958
- touchMap[val] = cssSupports ? window2.CSS.supports("touch-action", val) : true;
13959
- });
13960
- return touchMap;
13961
- }
13962
- var STATE_POSSIBLE = 1;
13963
- var STATE_BEGAN = 2;
13964
- var STATE_CHANGED = 4;
13965
- var STATE_ENDED = 8;
13966
- var STATE_RECOGNIZED = STATE_ENDED;
13967
- var STATE_CANCELLED = 16;
13968
- var STATE_FAILED = 32;
13969
- function Recognizer(options) {
13970
- this.options = assign({}, this.defaults, options || {});
13971
- this.id = uniqueId();
13972
- this.manager = null;
13973
- this.options.enable = ifUndefined(this.options.enable, true);
13974
- this.state = STATE_POSSIBLE;
13975
- this.simultaneous = {};
13976
- this.requireFail = [];
13977
- }
13978
- Recognizer.prototype = {
13979
- /**
13980
- * @virtual
13981
- * @type {Object}
13982
- */
13983
- defaults: {},
13984
- /**
13985
- * set options
13986
- * @param {Object} options
13987
- * @return {Recognizer}
13988
- */
13989
- set: function(options) {
13990
- assign(this.options, options);
13991
- this.manager && this.manager.touchAction.update();
13992
- return this;
13993
- },
13994
- /**
13995
- * recognize simultaneous with an other recognizer.
13996
- * @param {Recognizer} otherRecognizer
13997
- * @returns {Recognizer} this
13998
- */
13999
- recognizeWith: function(otherRecognizer) {
14000
- if (invokeArrayArg(otherRecognizer, "recognizeWith", this)) {
14001
- return this;
13790
+ i2 = 0;
13791
+ while (i2 < changedTouches.length) {
13792
+ if (targetIds[changedTouches[i2].identifier]) {
13793
+ changedTargetTouches.push(changedTouches[i2]);
13794
+ }
13795
+ if (type & (INPUT_END | INPUT_CANCEL)) {
13796
+ delete targetIds[changedTouches[i2].identifier];
13797
+ }
13798
+ i2++;
14002
13799
  }
14003
- var simultaneous = this.simultaneous;
14004
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
14005
- if (!simultaneous[otherRecognizer.id]) {
14006
- simultaneous[otherRecognizer.id] = otherRecognizer;
14007
- otherRecognizer.recognizeWith(this);
13800
+ if (!changedTargetTouches.length) {
13801
+ return;
14008
13802
  }
14009
- return this;
14010
- },
14011
- /**
14012
- * drop the simultaneous link. it doesnt remove the link on the other recognizer.
14013
- * @param {Recognizer} otherRecognizer
14014
- * @returns {Recognizer} this
14015
- */
14016
- dropRecognizeWith: function(otherRecognizer) {
14017
- if (invokeArrayArg(otherRecognizer, "dropRecognizeWith", this)) {
14018
- return this;
13803
+ return [
13804
+ // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
13805
+ uniqueArray(targetTouches.concat(changedTargetTouches), "identifier"),
13806
+ changedTargetTouches
13807
+ ];
13808
+ }
13809
+ var DEDUP_TIMEOUT = 2500;
13810
+ var DEDUP_DISTANCE = 25;
13811
+ function TouchMouseInput() {
13812
+ Input.apply(this, arguments);
13813
+ var handler = bindFn(this.handler, this);
13814
+ this.touch = new TouchInput(this.manager, handler);
13815
+ this.mouse = new MouseInput(this.manager, handler);
13816
+ this.primaryTouch = null;
13817
+ this.lastTouches = [];
13818
+ }
13819
+ inherit(TouchMouseInput, Input, {
13820
+ /**
13821
+ * handle mouse and touch events
13822
+ * @param {Hammer} manager
13823
+ * @param {String} inputEvent
13824
+ * @param {Object} inputData
13825
+ */
13826
+ handler: function TMEhandler(manager, inputEvent, inputData) {
13827
+ var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH, isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
13828
+ if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
13829
+ return;
13830
+ }
13831
+ if (isTouch) {
13832
+ recordTouches.call(this, inputEvent, inputData);
13833
+ } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
13834
+ return;
13835
+ }
13836
+ this.callback(manager, inputEvent, inputData);
13837
+ },
13838
+ /**
13839
+ * remove the event listeners
13840
+ */
13841
+ destroy: function destroy() {
13842
+ this.touch.destroy();
13843
+ this.mouse.destroy();
14019
13844
  }
14020
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
14021
- delete this.simultaneous[otherRecognizer.id];
14022
- return this;
14023
- },
14024
- /**
14025
- * recognizer can only run when an other is failing
14026
- * @param {Recognizer} otherRecognizer
14027
- * @returns {Recognizer} this
14028
- */
14029
- requireFailure: function(otherRecognizer) {
14030
- if (invokeArrayArg(otherRecognizer, "requireFailure", this)) {
14031
- return this;
13845
+ });
13846
+ function recordTouches(eventType, eventData) {
13847
+ if (eventType & INPUT_START) {
13848
+ this.primaryTouch = eventData.changedPointers[0].identifier;
13849
+ setLastTouch.call(this, eventData);
13850
+ } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
13851
+ setLastTouch.call(this, eventData);
14032
13852
  }
14033
- var requireFail = this.requireFail;
14034
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
14035
- if (inArray(requireFail, otherRecognizer) === -1) {
14036
- requireFail.push(otherRecognizer);
14037
- otherRecognizer.requireFailure(this);
13853
+ }
13854
+ function setLastTouch(eventData) {
13855
+ var touch = eventData.changedPointers[0];
13856
+ if (touch.identifier === this.primaryTouch) {
13857
+ var lastTouch = { x: touch.clientX, y: touch.clientY };
13858
+ this.lastTouches.push(lastTouch);
13859
+ var lts = this.lastTouches;
13860
+ var removeLastTouch = function() {
13861
+ var i2 = lts.indexOf(lastTouch);
13862
+ if (i2 > -1) {
13863
+ lts.splice(i2, 1);
13864
+ }
13865
+ };
13866
+ setTimeout(removeLastTouch, DEDUP_TIMEOUT);
14038
13867
  }
14039
- return this;
14040
- },
14041
- /**
14042
- * drop the requireFailure link. it does not remove the link on the other recognizer.
14043
- * @param {Recognizer} otherRecognizer
14044
- * @returns {Recognizer} this
14045
- */
14046
- dropRequireFailure: function(otherRecognizer) {
14047
- if (invokeArrayArg(otherRecognizer, "dropRequireFailure", this)) {
14048
- return this;
13868
+ }
13869
+ function isSyntheticEvent(eventData) {
13870
+ var x2 = eventData.srcEvent.clientX, y2 = eventData.srcEvent.clientY;
13871
+ for (var i2 = 0; i2 < this.lastTouches.length; i2++) {
13872
+ var t = this.lastTouches[i2];
13873
+ var dx = Math.abs(x2 - t.x), dy = Math.abs(y2 - t.y);
13874
+ if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
13875
+ return true;
13876
+ }
14049
13877
  }
14050
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
14051
- var index2 = inArray(this.requireFail, otherRecognizer);
14052
- if (index2 > -1) {
14053
- this.requireFail.splice(index2, 1);
13878
+ return false;
13879
+ }
13880
+ var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, "touchAction");
13881
+ var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined$1;
13882
+ var TOUCH_ACTION_COMPUTE = "compute";
13883
+ var TOUCH_ACTION_AUTO = "auto";
13884
+ var TOUCH_ACTION_MANIPULATION = "manipulation";
13885
+ var TOUCH_ACTION_NONE = "none";
13886
+ var TOUCH_ACTION_PAN_X = "pan-x";
13887
+ var TOUCH_ACTION_PAN_Y = "pan-y";
13888
+ var TOUCH_ACTION_MAP = getTouchActionProps();
13889
+ function TouchAction(manager, value) {
13890
+ this.manager = manager;
13891
+ this.set(value);
13892
+ }
13893
+ TouchAction.prototype = {
13894
+ /**
13895
+ * set the touchAction value on the element or enable the polyfill
13896
+ * @param {String} value
13897
+ */
13898
+ set: function(value) {
13899
+ if (value == TOUCH_ACTION_COMPUTE) {
13900
+ value = this.compute();
13901
+ }
13902
+ if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
13903
+ this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
13904
+ }
13905
+ this.actions = value.toLowerCase().trim();
13906
+ },
13907
+ /**
13908
+ * just re-set the touchAction value
13909
+ */
13910
+ update: function() {
13911
+ this.set(this.manager.options.touchAction);
13912
+ },
13913
+ /**
13914
+ * compute the value for the touchAction property based on the recognizer's settings
13915
+ * @returns {String} value
13916
+ */
13917
+ compute: function() {
13918
+ var actions2 = [];
13919
+ each2(this.manager.recognizers, function(recognizer) {
13920
+ if (boolOrFn(recognizer.options.enable, [recognizer])) {
13921
+ actions2 = actions2.concat(recognizer.getTouchAction());
13922
+ }
13923
+ });
13924
+ return cleanTouchActions(actions2.join(" "));
13925
+ },
13926
+ /**
13927
+ * this method is called on each input cycle and provides the preventing of the browser behavior
13928
+ * @param {Object} input
13929
+ */
13930
+ preventDefaults: function(input) {
13931
+ var srcEvent = input.srcEvent;
13932
+ var direction = input.offsetDirection;
13933
+ if (this.manager.session.prevented) {
13934
+ srcEvent.preventDefault();
13935
+ return;
13936
+ }
13937
+ var actions2 = this.actions;
13938
+ var hasNone = inStr(actions2, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
13939
+ var hasPanY = inStr(actions2, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
13940
+ var hasPanX = inStr(actions2, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
13941
+ if (hasNone) {
13942
+ var isTapPointer = input.pointers.length === 1;
13943
+ var isTapMovement = input.distance < 2;
13944
+ var isTapTouchTime = input.deltaTime < 250;
13945
+ if (isTapPointer && isTapMovement && isTapTouchTime) {
13946
+ return;
13947
+ }
13948
+ }
13949
+ if (hasPanX && hasPanY) {
13950
+ return;
13951
+ }
13952
+ if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
13953
+ return this.preventSrc(srcEvent);
13954
+ }
13955
+ },
13956
+ /**
13957
+ * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
13958
+ * @param {Object} srcEvent
13959
+ */
13960
+ preventSrc: function(srcEvent) {
13961
+ this.manager.session.prevented = true;
13962
+ srcEvent.preventDefault();
14054
13963
  }
14055
- return this;
14056
- },
14057
- /**
14058
- * has require failures boolean
14059
- * @returns {boolean}
14060
- */
14061
- hasRequireFailures: function() {
14062
- return this.requireFail.length > 0;
14063
- },
14064
- /**
14065
- * if the recognizer can recognize simultaneous with an other recognizer
14066
- * @param {Recognizer} otherRecognizer
14067
- * @returns {Boolean}
14068
- */
14069
- canRecognizeWith: function(otherRecognizer) {
14070
- return !!this.simultaneous[otherRecognizer.id];
14071
- },
14072
- /**
14073
- * You should use `tryEmit` instead of `emit` directly to check
14074
- * that all the needed recognizers has failed before emitting.
14075
- * @param {Object} input
14076
- */
14077
- emit: function(input) {
14078
- var self2 = this;
14079
- var state = this.state;
14080
- function emit(event) {
14081
- self2.manager.emit(event, input);
13964
+ };
13965
+ function cleanTouchActions(actions2) {
13966
+ if (inStr(actions2, TOUCH_ACTION_NONE)) {
13967
+ return TOUCH_ACTION_NONE;
14082
13968
  }
14083
- if (state < STATE_ENDED) {
14084
- emit(self2.options.event + stateStr(state));
13969
+ var hasPanX = inStr(actions2, TOUCH_ACTION_PAN_X);
13970
+ var hasPanY = inStr(actions2, TOUCH_ACTION_PAN_Y);
13971
+ if (hasPanX && hasPanY) {
13972
+ return TOUCH_ACTION_NONE;
14085
13973
  }
14086
- emit(self2.options.event);
14087
- if (input.additionalEvent) {
14088
- emit(input.additionalEvent);
13974
+ if (hasPanX || hasPanY) {
13975
+ return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
14089
13976
  }
14090
- if (state >= STATE_ENDED) {
14091
- emit(self2.options.event + stateStr(state));
13977
+ if (inStr(actions2, TOUCH_ACTION_MANIPULATION)) {
13978
+ return TOUCH_ACTION_MANIPULATION;
14092
13979
  }
14093
- },
14094
- /**
14095
- * Check that all the require failure recognizers has failed,
14096
- * if true, it emits a gesture event,
14097
- * otherwise, setup the state to FAILED.
14098
- * @param {Object} input
14099
- */
14100
- tryEmit: function(input) {
14101
- if (this.canEmit()) {
14102
- return this.emit(input);
13980
+ return TOUCH_ACTION_AUTO;
13981
+ }
13982
+ function getTouchActionProps() {
13983
+ if (!NATIVE_TOUCH_ACTION) {
13984
+ return false;
14103
13985
  }
14104
- this.state = STATE_FAILED;
14105
- },
14106
- /**
14107
- * can we emit?
14108
- * @returns {boolean}
14109
- */
14110
- canEmit: function() {
14111
- var i2 = 0;
14112
- while (i2 < this.requireFail.length) {
14113
- if (!(this.requireFail[i2].state & (STATE_FAILED | STATE_POSSIBLE))) {
14114
- return false;
13986
+ var touchMap = {};
13987
+ var cssSupports = window2.CSS && window2.CSS.supports;
13988
+ ["auto", "manipulation", "pan-y", "pan-x", "pan-x pan-y", "none"].forEach(function(val) {
13989
+ touchMap[val] = cssSupports ? window2.CSS.supports("touch-action", val) : true;
13990
+ });
13991
+ return touchMap;
13992
+ }
13993
+ var STATE_POSSIBLE = 1;
13994
+ var STATE_BEGAN = 2;
13995
+ var STATE_CHANGED = 4;
13996
+ var STATE_ENDED = 8;
13997
+ var STATE_RECOGNIZED = STATE_ENDED;
13998
+ var STATE_CANCELLED = 16;
13999
+ var STATE_FAILED = 32;
14000
+ function Recognizer(options) {
14001
+ this.options = assign({}, this.defaults, options || {});
14002
+ this.id = uniqueId();
14003
+ this.manager = null;
14004
+ this.options.enable = ifUndefined(this.options.enable, true);
14005
+ this.state = STATE_POSSIBLE;
14006
+ this.simultaneous = {};
14007
+ this.requireFail = [];
14008
+ }
14009
+ Recognizer.prototype = {
14010
+ /**
14011
+ * @virtual
14012
+ * @type {Object}
14013
+ */
14014
+ defaults: {},
14015
+ /**
14016
+ * set options
14017
+ * @param {Object} options
14018
+ * @return {Recognizer}
14019
+ */
14020
+ set: function(options) {
14021
+ assign(this.options, options);
14022
+ this.manager && this.manager.touchAction.update();
14023
+ return this;
14024
+ },
14025
+ /**
14026
+ * recognize simultaneous with an other recognizer.
14027
+ * @param {Recognizer} otherRecognizer
14028
+ * @returns {Recognizer} this
14029
+ */
14030
+ recognizeWith: function(otherRecognizer) {
14031
+ if (invokeArrayArg(otherRecognizer, "recognizeWith", this)) {
14032
+ return this;
14033
+ }
14034
+ var simultaneous = this.simultaneous;
14035
+ otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
14036
+ if (!simultaneous[otherRecognizer.id]) {
14037
+ simultaneous[otherRecognizer.id] = otherRecognizer;
14038
+ otherRecognizer.recognizeWith(this);
14039
+ }
14040
+ return this;
14041
+ },
14042
+ /**
14043
+ * drop the simultaneous link. it doesnt remove the link on the other recognizer.
14044
+ * @param {Recognizer} otherRecognizer
14045
+ * @returns {Recognizer} this
14046
+ */
14047
+ dropRecognizeWith: function(otherRecognizer) {
14048
+ if (invokeArrayArg(otherRecognizer, "dropRecognizeWith", this)) {
14049
+ return this;
14050
+ }
14051
+ otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
14052
+ delete this.simultaneous[otherRecognizer.id];
14053
+ return this;
14054
+ },
14055
+ /**
14056
+ * recognizer can only run when an other is failing
14057
+ * @param {Recognizer} otherRecognizer
14058
+ * @returns {Recognizer} this
14059
+ */
14060
+ requireFailure: function(otherRecognizer) {
14061
+ if (invokeArrayArg(otherRecognizer, "requireFailure", this)) {
14062
+ return this;
14063
+ }
14064
+ var requireFail = this.requireFail;
14065
+ otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
14066
+ if (inArray(requireFail, otherRecognizer) === -1) {
14067
+ requireFail.push(otherRecognizer);
14068
+ otherRecognizer.requireFailure(this);
14069
+ }
14070
+ return this;
14071
+ },
14072
+ /**
14073
+ * drop the requireFailure link. it does not remove the link on the other recognizer.
14074
+ * @param {Recognizer} otherRecognizer
14075
+ * @returns {Recognizer} this
14076
+ */
14077
+ dropRequireFailure: function(otherRecognizer) {
14078
+ if (invokeArrayArg(otherRecognizer, "dropRequireFailure", this)) {
14079
+ return this;
14080
+ }
14081
+ otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
14082
+ var index2 = inArray(this.requireFail, otherRecognizer);
14083
+ if (index2 > -1) {
14084
+ this.requireFail.splice(index2, 1);
14085
+ }
14086
+ return this;
14087
+ },
14088
+ /**
14089
+ * has require failures boolean
14090
+ * @returns {boolean}
14091
+ */
14092
+ hasRequireFailures: function() {
14093
+ return this.requireFail.length > 0;
14094
+ },
14095
+ /**
14096
+ * if the recognizer can recognize simultaneous with an other recognizer
14097
+ * @param {Recognizer} otherRecognizer
14098
+ * @returns {Boolean}
14099
+ */
14100
+ canRecognizeWith: function(otherRecognizer) {
14101
+ return !!this.simultaneous[otherRecognizer.id];
14102
+ },
14103
+ /**
14104
+ * You should use `tryEmit` instead of `emit` directly to check
14105
+ * that all the needed recognizers has failed before emitting.
14106
+ * @param {Object} input
14107
+ */
14108
+ emit: function(input) {
14109
+ var self2 = this;
14110
+ var state = this.state;
14111
+ function emit(event) {
14112
+ self2.manager.emit(event, input);
14113
+ }
14114
+ if (state < STATE_ENDED) {
14115
+ emit(self2.options.event + stateStr(state));
14116
+ }
14117
+ emit(self2.options.event);
14118
+ if (input.additionalEvent) {
14119
+ emit(input.additionalEvent);
14120
+ }
14121
+ if (state >= STATE_ENDED) {
14122
+ emit(self2.options.event + stateStr(state));
14123
+ }
14124
+ },
14125
+ /**
14126
+ * Check that all the require failure recognizers has failed,
14127
+ * if true, it emits a gesture event,
14128
+ * otherwise, setup the state to FAILED.
14129
+ * @param {Object} input
14130
+ */
14131
+ tryEmit: function(input) {
14132
+ if (this.canEmit()) {
14133
+ return this.emit(input);
14115
14134
  }
14116
- i2++;
14117
- }
14118
- return true;
14119
- },
14120
- /**
14121
- * update the recognizer
14122
- * @param {Object} inputData
14123
- */
14124
- recognize: function(inputData) {
14125
- var inputDataClone = assign({}, inputData);
14126
- if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
14127
- this.reset();
14128
14135
  this.state = STATE_FAILED;
14129
- return;
14136
+ },
14137
+ /**
14138
+ * can we emit?
14139
+ * @returns {boolean}
14140
+ */
14141
+ canEmit: function() {
14142
+ var i2 = 0;
14143
+ while (i2 < this.requireFail.length) {
14144
+ if (!(this.requireFail[i2].state & (STATE_FAILED | STATE_POSSIBLE))) {
14145
+ return false;
14146
+ }
14147
+ i2++;
14148
+ }
14149
+ return true;
14150
+ },
14151
+ /**
14152
+ * update the recognizer
14153
+ * @param {Object} inputData
14154
+ */
14155
+ recognize: function(inputData) {
14156
+ var inputDataClone = assign({}, inputData);
14157
+ if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
14158
+ this.reset();
14159
+ this.state = STATE_FAILED;
14160
+ return;
14161
+ }
14162
+ if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
14163
+ this.state = STATE_POSSIBLE;
14164
+ }
14165
+ this.state = this.process(inputDataClone);
14166
+ if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
14167
+ this.tryEmit(inputDataClone);
14168
+ }
14169
+ },
14170
+ /**
14171
+ * return the state of the recognizer
14172
+ * the actual recognizing happens in this method
14173
+ * @virtual
14174
+ * @param {Object} inputData
14175
+ * @returns {Const} STATE
14176
+ */
14177
+ process: function(inputData) {
14178
+ },
14179
+ // jshint ignore:line
14180
+ /**
14181
+ * return the preferred touch-action
14182
+ * @virtual
14183
+ * @returns {Array}
14184
+ */
14185
+ getTouchAction: function() {
14186
+ },
14187
+ /**
14188
+ * called when the gesture isn't allowed to recognize
14189
+ * like when another is being recognized or it is disabled
14190
+ * @virtual
14191
+ */
14192
+ reset: function() {
14193
+ }
14194
+ };
14195
+ function stateStr(state) {
14196
+ if (state & STATE_CANCELLED) {
14197
+ return "cancel";
14198
+ } else if (state & STATE_ENDED) {
14199
+ return "end";
14200
+ } else if (state & STATE_CHANGED) {
14201
+ return "move";
14202
+ } else if (state & STATE_BEGAN) {
14203
+ return "start";
14130
14204
  }
14131
- if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
14132
- this.state = STATE_POSSIBLE;
14205
+ return "";
14206
+ }
14207
+ function directionStr(direction) {
14208
+ if (direction == DIRECTION_DOWN) {
14209
+ return "down";
14210
+ } else if (direction == DIRECTION_UP) {
14211
+ return "up";
14212
+ } else if (direction == DIRECTION_LEFT) {
14213
+ return "left";
14214
+ } else if (direction == DIRECTION_RIGHT) {
14215
+ return "right";
14133
14216
  }
14134
- this.state = this.process(inputDataClone);
14135
- if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
14136
- this.tryEmit(inputDataClone);
14217
+ return "";
14218
+ }
14219
+ function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
14220
+ var manager = recognizer.manager;
14221
+ if (manager) {
14222
+ return manager.get(otherRecognizer);
14137
14223
  }
14138
- },
14139
- /**
14140
- * return the state of the recognizer
14141
- * the actual recognizing happens in this method
14142
- * @virtual
14143
- * @param {Object} inputData
14144
- * @returns {Const} STATE
14145
- */
14146
- process: function(inputData) {
14147
- },
14148
- // jshint ignore:line
14149
- /**
14150
- * return the preferred touch-action
14151
- * @virtual
14152
- * @returns {Array}
14153
- */
14154
- getTouchAction: function() {
14155
- },
14156
- /**
14157
- * called when the gesture isn't allowed to recognize
14158
- * like when another is being recognized or it is disabled
14159
- * @virtual
14160
- */
14161
- reset: function() {
14224
+ return otherRecognizer;
14162
14225
  }
14163
- };
14164
- function stateStr(state) {
14165
- if (state & STATE_CANCELLED) {
14166
- return "cancel";
14167
- } else if (state & STATE_ENDED) {
14168
- return "end";
14169
- } else if (state & STATE_CHANGED) {
14170
- return "move";
14171
- } else if (state & STATE_BEGAN) {
14172
- return "start";
14173
- }
14174
- return "";
14175
- }
14176
- function directionStr(direction) {
14177
- if (direction == DIRECTION_DOWN) {
14178
- return "down";
14179
- } else if (direction == DIRECTION_UP) {
14180
- return "up";
14181
- } else if (direction == DIRECTION_LEFT) {
14182
- return "left";
14183
- } else if (direction == DIRECTION_RIGHT) {
14184
- return "right";
14185
- }
14186
- return "";
14187
- }
14188
- function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
14189
- var manager = recognizer.manager;
14190
- if (manager) {
14191
- return manager.get(otherRecognizer);
14192
- }
14193
- return otherRecognizer;
14194
- }
14195
- function AttrRecognizer() {
14196
- Recognizer.apply(this, arguments);
14197
- }
14198
- inherit(AttrRecognizer, Recognizer, {
14199
- /**
14200
- * @namespace
14201
- * @memberof AttrRecognizer
14202
- */
14203
- defaults: {
14226
+ function AttrRecognizer() {
14227
+ Recognizer.apply(this, arguments);
14228
+ }
14229
+ inherit(AttrRecognizer, Recognizer, {
14204
14230
  /**
14205
- * @type {Number}
14206
- * @default 1
14231
+ * @namespace
14232
+ * @memberof AttrRecognizer
14207
14233
  */
14208
- pointers: 1
14209
- },
14210
- /**
14211
- * Used to check if it the recognizer receives valid input, like input.distance > 10.
14212
- * @memberof AttrRecognizer
14213
- * @param {Object} input
14214
- * @returns {Boolean} recognized
14215
- */
14216
- attrTest: function(input) {
14217
- var optionPointers = this.options.pointers;
14218
- return optionPointers === 0 || input.pointers.length === optionPointers;
14219
- },
14220
- /**
14221
- * Process the input and return the state for the recognizer
14222
- * @memberof AttrRecognizer
14223
- * @param {Object} input
14224
- * @returns {*} State
14225
- */
14226
- process: function(input) {
14227
- var state = this.state;
14228
- var eventType = input.eventType;
14229
- var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
14230
- var isValid = this.attrTest(input);
14231
- if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
14232
- return state | STATE_CANCELLED;
14233
- } else if (isRecognized || isValid) {
14234
- if (eventType & INPUT_END) {
14235
- return state | STATE_ENDED;
14236
- } else if (!(state & STATE_BEGAN)) {
14237
- return STATE_BEGAN;
14234
+ defaults: {
14235
+ /**
14236
+ * @type {Number}
14237
+ * @default 1
14238
+ */
14239
+ pointers: 1
14240
+ },
14241
+ /**
14242
+ * Used to check if it the recognizer receives valid input, like input.distance > 10.
14243
+ * @memberof AttrRecognizer
14244
+ * @param {Object} input
14245
+ * @returns {Boolean} recognized
14246
+ */
14247
+ attrTest: function(input) {
14248
+ var optionPointers = this.options.pointers;
14249
+ return optionPointers === 0 || input.pointers.length === optionPointers;
14250
+ },
14251
+ /**
14252
+ * Process the input and return the state for the recognizer
14253
+ * @memberof AttrRecognizer
14254
+ * @param {Object} input
14255
+ * @returns {*} State
14256
+ */
14257
+ process: function(input) {
14258
+ var state = this.state;
14259
+ var eventType = input.eventType;
14260
+ var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
14261
+ var isValid = this.attrTest(input);
14262
+ if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
14263
+ return state | STATE_CANCELLED;
14264
+ } else if (isRecognized || isValid) {
14265
+ if (eventType & INPUT_END) {
14266
+ return state | STATE_ENDED;
14267
+ } else if (!(state & STATE_BEGAN)) {
14268
+ return STATE_BEGAN;
14269
+ }
14270
+ return state | STATE_CHANGED;
14238
14271
  }
14239
- return state | STATE_CHANGED;
14272
+ return STATE_FAILED;
14240
14273
  }
14241
- return STATE_FAILED;
14274
+ });
14275
+ function PanRecognizer() {
14276
+ AttrRecognizer.apply(this, arguments);
14277
+ this.pX = null;
14278
+ this.pY = null;
14242
14279
  }
14243
- });
14244
- function PanRecognizer() {
14245
- AttrRecognizer.apply(this, arguments);
14246
- this.pX = null;
14247
- this.pY = null;
14248
- }
14249
- inherit(PanRecognizer, AttrRecognizer, {
14250
- /**
14251
- * @namespace
14252
- * @memberof PanRecognizer
14253
- */
14254
- defaults: {
14255
- event: "pan",
14256
- threshold: 10,
14257
- pointers: 1,
14258
- direction: DIRECTION_ALL
14259
- },
14260
- getTouchAction: function() {
14261
- var direction = this.options.direction;
14262
- var actions2 = [];
14263
- if (direction & DIRECTION_HORIZONTAL) {
14264
- actions2.push(TOUCH_ACTION_PAN_Y);
14280
+ inherit(PanRecognizer, AttrRecognizer, {
14281
+ /**
14282
+ * @namespace
14283
+ * @memberof PanRecognizer
14284
+ */
14285
+ defaults: {
14286
+ event: "pan",
14287
+ threshold: 10,
14288
+ pointers: 1,
14289
+ direction: DIRECTION_ALL
14290
+ },
14291
+ getTouchAction: function() {
14292
+ var direction = this.options.direction;
14293
+ var actions2 = [];
14294
+ if (direction & DIRECTION_HORIZONTAL) {
14295
+ actions2.push(TOUCH_ACTION_PAN_Y);
14296
+ }
14297
+ if (direction & DIRECTION_VERTICAL) {
14298
+ actions2.push(TOUCH_ACTION_PAN_X);
14299
+ }
14300
+ return actions2;
14301
+ },
14302
+ directionTest: function(input) {
14303
+ var options = this.options;
14304
+ var hasMoved = true;
14305
+ var distance = input.distance;
14306
+ var direction = input.direction;
14307
+ var x2 = input.deltaX;
14308
+ var y2 = input.deltaY;
14309
+ if (!(direction & options.direction)) {
14310
+ if (options.direction & DIRECTION_HORIZONTAL) {
14311
+ direction = x2 === 0 ? DIRECTION_NONE : x2 < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
14312
+ hasMoved = x2 != this.pX;
14313
+ distance = Math.abs(input.deltaX);
14314
+ } else {
14315
+ direction = y2 === 0 ? DIRECTION_NONE : y2 < 0 ? DIRECTION_UP : DIRECTION_DOWN;
14316
+ hasMoved = y2 != this.pY;
14317
+ distance = Math.abs(input.deltaY);
14318
+ }
14319
+ }
14320
+ input.direction = direction;
14321
+ return hasMoved && distance > options.threshold && direction & options.direction;
14322
+ },
14323
+ attrTest: function(input) {
14324
+ return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
14325
+ },
14326
+ emit: function(input) {
14327
+ this.pX = input.deltaX;
14328
+ this.pY = input.deltaY;
14329
+ var direction = directionStr(input.direction);
14330
+ if (direction) {
14331
+ input.additionalEvent = this.options.event + direction;
14332
+ }
14333
+ this._super.emit.call(this, input);
14265
14334
  }
14266
- if (direction & DIRECTION_VERTICAL) {
14267
- actions2.push(TOUCH_ACTION_PAN_X);
14335
+ });
14336
+ function PinchRecognizer() {
14337
+ AttrRecognizer.apply(this, arguments);
14338
+ }
14339
+ inherit(PinchRecognizer, AttrRecognizer, {
14340
+ /**
14341
+ * @namespace
14342
+ * @memberof PinchRecognizer
14343
+ */
14344
+ defaults: {
14345
+ event: "pinch",
14346
+ threshold: 0,
14347
+ pointers: 2
14348
+ },
14349
+ getTouchAction: function() {
14350
+ return [TOUCH_ACTION_NONE];
14351
+ },
14352
+ attrTest: function(input) {
14353
+ return this._super.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
14354
+ },
14355
+ emit: function(input) {
14356
+ if (input.scale !== 1) {
14357
+ var inOut = input.scale < 1 ? "in" : "out";
14358
+ input.additionalEvent = this.options.event + inOut;
14359
+ }
14360
+ this._super.emit.call(this, input);
14268
14361
  }
14269
- return actions2;
14270
- },
14271
- directionTest: function(input) {
14272
- var options = this.options;
14273
- var hasMoved = true;
14274
- var distance = input.distance;
14275
- var direction = input.direction;
14276
- var x2 = input.deltaX;
14277
- var y2 = input.deltaY;
14278
- if (!(direction & options.direction)) {
14279
- if (options.direction & DIRECTION_HORIZONTAL) {
14280
- direction = x2 === 0 ? DIRECTION_NONE : x2 < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
14281
- hasMoved = x2 != this.pX;
14282
- distance = Math.abs(input.deltaX);
14362
+ });
14363
+ function PressRecognizer() {
14364
+ Recognizer.apply(this, arguments);
14365
+ this._timer = null;
14366
+ this._input = null;
14367
+ }
14368
+ inherit(PressRecognizer, Recognizer, {
14369
+ /**
14370
+ * @namespace
14371
+ * @memberof PressRecognizer
14372
+ */
14373
+ defaults: {
14374
+ event: "press",
14375
+ pointers: 1,
14376
+ time: 251,
14377
+ // minimal time of the pointer to be pressed
14378
+ threshold: 9
14379
+ // a minimal movement is ok, but keep it low
14380
+ },
14381
+ getTouchAction: function() {
14382
+ return [TOUCH_ACTION_AUTO];
14383
+ },
14384
+ process: function(input) {
14385
+ var options = this.options;
14386
+ var validPointers = input.pointers.length === options.pointers;
14387
+ var validMovement = input.distance < options.threshold;
14388
+ var validTime = input.deltaTime > options.time;
14389
+ this._input = input;
14390
+ if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
14391
+ this.reset();
14392
+ } else if (input.eventType & INPUT_START) {
14393
+ this.reset();
14394
+ this._timer = setTimeoutContext(function() {
14395
+ this.state = STATE_RECOGNIZED;
14396
+ this.tryEmit();
14397
+ }, options.time, this);
14398
+ } else if (input.eventType & INPUT_END) {
14399
+ return STATE_RECOGNIZED;
14400
+ }
14401
+ return STATE_FAILED;
14402
+ },
14403
+ reset: function() {
14404
+ clearTimeout(this._timer);
14405
+ },
14406
+ emit: function(input) {
14407
+ if (this.state !== STATE_RECOGNIZED) {
14408
+ return;
14409
+ }
14410
+ if (input && input.eventType & INPUT_END) {
14411
+ this.manager.emit(this.options.event + "up", input);
14283
14412
  } else {
14284
- direction = y2 === 0 ? DIRECTION_NONE : y2 < 0 ? DIRECTION_UP : DIRECTION_DOWN;
14285
- hasMoved = y2 != this.pY;
14286
- distance = Math.abs(input.deltaY);
14413
+ this._input.timeStamp = now();
14414
+ this.manager.emit(this.options.event, this._input);
14287
14415
  }
14288
14416
  }
14289
- input.direction = direction;
14290
- return hasMoved && distance > options.threshold && direction & options.direction;
14291
- },
14292
- attrTest: function(input) {
14293
- return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
14294
- },
14295
- emit: function(input) {
14296
- this.pX = input.deltaX;
14297
- this.pY = input.deltaY;
14298
- var direction = directionStr(input.direction);
14299
- if (direction) {
14300
- input.additionalEvent = this.options.event + direction;
14301
- }
14302
- this._super.emit.call(this, input);
14417
+ });
14418
+ function RotateRecognizer() {
14419
+ AttrRecognizer.apply(this, arguments);
14303
14420
  }
14304
- });
14305
- function PinchRecognizer() {
14306
- AttrRecognizer.apply(this, arguments);
14307
- }
14308
- inherit(PinchRecognizer, AttrRecognizer, {
14309
- /**
14310
- * @namespace
14311
- * @memberof PinchRecognizer
14312
- */
14313
- defaults: {
14314
- event: "pinch",
14315
- threshold: 0,
14316
- pointers: 2
14317
- },
14318
- getTouchAction: function() {
14319
- return [TOUCH_ACTION_NONE];
14320
- },
14321
- attrTest: function(input) {
14322
- return this._super.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
14323
- },
14324
- emit: function(input) {
14325
- if (input.scale !== 1) {
14326
- var inOut = input.scale < 1 ? "in" : "out";
14327
- input.additionalEvent = this.options.event + inOut;
14421
+ inherit(RotateRecognizer, AttrRecognizer, {
14422
+ /**
14423
+ * @namespace
14424
+ * @memberof RotateRecognizer
14425
+ */
14426
+ defaults: {
14427
+ event: "rotate",
14428
+ threshold: 0,
14429
+ pointers: 2
14430
+ },
14431
+ getTouchAction: function() {
14432
+ return [TOUCH_ACTION_NONE];
14433
+ },
14434
+ attrTest: function(input) {
14435
+ return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
14328
14436
  }
14329
- this._super.emit.call(this, input);
14437
+ });
14438
+ function SwipeRecognizer() {
14439
+ AttrRecognizer.apply(this, arguments);
14330
14440
  }
14331
- });
14332
- function PressRecognizer() {
14333
- Recognizer.apply(this, arguments);
14334
- this._timer = null;
14335
- this._input = null;
14336
- }
14337
- inherit(PressRecognizer, Recognizer, {
14338
- /**
14339
- * @namespace
14340
- * @memberof PressRecognizer
14341
- */
14342
- defaults: {
14343
- event: "press",
14344
- pointers: 1,
14345
- time: 251,
14346
- // minimal time of the pointer to be pressed
14347
- threshold: 9
14348
- // a minimal movement is ok, but keep it low
14349
- },
14350
- getTouchAction: function() {
14351
- return [TOUCH_ACTION_AUTO];
14352
- },
14353
- process: function(input) {
14354
- var options = this.options;
14355
- var validPointers = input.pointers.length === options.pointers;
14356
- var validMovement = input.distance < options.threshold;
14357
- var validTime = input.deltaTime > options.time;
14358
- this._input = input;
14359
- if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
14360
- this.reset();
14361
- } else if (input.eventType & INPUT_START) {
14441
+ inherit(SwipeRecognizer, AttrRecognizer, {
14442
+ /**
14443
+ * @namespace
14444
+ * @memberof SwipeRecognizer
14445
+ */
14446
+ defaults: {
14447
+ event: "swipe",
14448
+ threshold: 10,
14449
+ velocity: 0.3,
14450
+ direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
14451
+ pointers: 1
14452
+ },
14453
+ getTouchAction: function() {
14454
+ return PanRecognizer.prototype.getTouchAction.call(this);
14455
+ },
14456
+ attrTest: function(input) {
14457
+ var direction = this.options.direction;
14458
+ var velocity;
14459
+ if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
14460
+ velocity = input.overallVelocity;
14461
+ } else if (direction & DIRECTION_HORIZONTAL) {
14462
+ velocity = input.overallVelocityX;
14463
+ } else if (direction & DIRECTION_VERTICAL) {
14464
+ velocity = input.overallVelocityY;
14465
+ }
14466
+ return this._super.attrTest.call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers == this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
14467
+ },
14468
+ emit: function(input) {
14469
+ var direction = directionStr(input.offsetDirection);
14470
+ if (direction) {
14471
+ this.manager.emit(this.options.event + direction, input);
14472
+ }
14473
+ this.manager.emit(this.options.event, input);
14474
+ }
14475
+ });
14476
+ function TapRecognizer() {
14477
+ Recognizer.apply(this, arguments);
14478
+ this.pTime = false;
14479
+ this.pCenter = false;
14480
+ this._timer = null;
14481
+ this._input = null;
14482
+ this.count = 0;
14483
+ }
14484
+ inherit(TapRecognizer, Recognizer, {
14485
+ /**
14486
+ * @namespace
14487
+ * @memberof PinchRecognizer
14488
+ */
14489
+ defaults: {
14490
+ event: "tap",
14491
+ pointers: 1,
14492
+ taps: 1,
14493
+ interval: 300,
14494
+ // max time between the multi-tap taps
14495
+ time: 250,
14496
+ // max time of the pointer to be down (like finger on the screen)
14497
+ threshold: 9,
14498
+ // a minimal movement is ok, but keep it low
14499
+ posThreshold: 10
14500
+ // a multi-tap can be a bit off the initial position
14501
+ },
14502
+ getTouchAction: function() {
14503
+ return [TOUCH_ACTION_MANIPULATION];
14504
+ },
14505
+ process: function(input) {
14506
+ var options = this.options;
14507
+ var validPointers = input.pointers.length === options.pointers;
14508
+ var validMovement = input.distance < options.threshold;
14509
+ var validTouchTime = input.deltaTime < options.time;
14362
14510
  this.reset();
14511
+ if (input.eventType & INPUT_START && this.count === 0) {
14512
+ return this.failTimeout();
14513
+ }
14514
+ if (validMovement && validTouchTime && validPointers) {
14515
+ if (input.eventType != INPUT_END) {
14516
+ return this.failTimeout();
14517
+ }
14518
+ var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
14519
+ var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
14520
+ this.pTime = input.timeStamp;
14521
+ this.pCenter = input.center;
14522
+ if (!validMultiTap || !validInterval) {
14523
+ this.count = 1;
14524
+ } else {
14525
+ this.count += 1;
14526
+ }
14527
+ this._input = input;
14528
+ var tapCount = this.count % options.taps;
14529
+ if (tapCount === 0) {
14530
+ if (!this.hasRequireFailures()) {
14531
+ return STATE_RECOGNIZED;
14532
+ } else {
14533
+ this._timer = setTimeoutContext(function() {
14534
+ this.state = STATE_RECOGNIZED;
14535
+ this.tryEmit();
14536
+ }, options.interval, this);
14537
+ return STATE_BEGAN;
14538
+ }
14539
+ }
14540
+ }
14541
+ return STATE_FAILED;
14542
+ },
14543
+ failTimeout: function() {
14363
14544
  this._timer = setTimeoutContext(function() {
14364
- this.state = STATE_RECOGNIZED;
14365
- this.tryEmit();
14366
- }, options.time, this);
14367
- } else if (input.eventType & INPUT_END) {
14368
- return STATE_RECOGNIZED;
14369
- }
14370
- return STATE_FAILED;
14371
- },
14372
- reset: function() {
14373
- clearTimeout(this._timer);
14374
- },
14375
- emit: function(input) {
14376
- if (this.state !== STATE_RECOGNIZED) {
14377
- return;
14378
- }
14379
- if (input && input.eventType & INPUT_END) {
14380
- this.manager.emit(this.options.event + "up", input);
14381
- } else {
14382
- this._input.timeStamp = now();
14383
- this.manager.emit(this.options.event, this._input);
14545
+ this.state = STATE_FAILED;
14546
+ }, this.options.interval, this);
14547
+ return STATE_FAILED;
14548
+ },
14549
+ reset: function() {
14550
+ clearTimeout(this._timer);
14551
+ },
14552
+ emit: function() {
14553
+ if (this.state == STATE_RECOGNIZED) {
14554
+ this._input.tapCount = this.count;
14555
+ this.manager.emit(this.options.event, this._input);
14556
+ }
14384
14557
  }
14558
+ });
14559
+ function Hammer2(element, options) {
14560
+ options = options || {};
14561
+ options.recognizers = ifUndefined(options.recognizers, Hammer2.defaults.preset);
14562
+ return new Manager(element, options);
14385
14563
  }
14386
- });
14387
- function RotateRecognizer() {
14388
- AttrRecognizer.apply(this, arguments);
14389
- }
14390
- inherit(RotateRecognizer, AttrRecognizer, {
14391
- /**
14392
- * @namespace
14393
- * @memberof RotateRecognizer
14394
- */
14395
- defaults: {
14396
- event: "rotate",
14397
- threshold: 0,
14398
- pointers: 2
14399
- },
14400
- getTouchAction: function() {
14401
- return [TOUCH_ACTION_NONE];
14402
- },
14403
- attrTest: function(input) {
14404
- return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
14405
- }
14406
- });
14407
- function SwipeRecognizer() {
14408
- AttrRecognizer.apply(this, arguments);
14409
- }
14410
- inherit(SwipeRecognizer, AttrRecognizer, {
14411
- /**
14412
- * @namespace
14413
- * @memberof SwipeRecognizer
14414
- */
14415
- defaults: {
14416
- event: "swipe",
14417
- threshold: 10,
14418
- velocity: 0.3,
14419
- direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
14420
- pointers: 1
14421
- },
14422
- getTouchAction: function() {
14423
- return PanRecognizer.prototype.getTouchAction.call(this);
14424
- },
14425
- attrTest: function(input) {
14426
- var direction = this.options.direction;
14427
- var velocity;
14428
- if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
14429
- velocity = input.overallVelocity;
14430
- } else if (direction & DIRECTION_HORIZONTAL) {
14431
- velocity = input.overallVelocityX;
14432
- } else if (direction & DIRECTION_VERTICAL) {
14433
- velocity = input.overallVelocityY;
14434
- }
14435
- return this._super.attrTest.call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers == this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
14436
- },
14437
- emit: function(input) {
14438
- var direction = directionStr(input.offsetDirection);
14439
- if (direction) {
14440
- this.manager.emit(this.options.event + direction, input);
14564
+ Hammer2.VERSION = "2.0.7";
14565
+ Hammer2.defaults = {
14566
+ /**
14567
+ * set if DOM events are being triggered.
14568
+ * But this is slower and unused by simple implementations, so disabled by default.
14569
+ * @type {Boolean}
14570
+ * @default false
14571
+ */
14572
+ domEvents: false,
14573
+ /**
14574
+ * The value for the touchAction property/fallback.
14575
+ * When set to `compute` it will magically set the correct value based on the added recognizers.
14576
+ * @type {String}
14577
+ * @default compute
14578
+ */
14579
+ touchAction: TOUCH_ACTION_COMPUTE,
14580
+ /**
14581
+ * @type {Boolean}
14582
+ * @default true
14583
+ */
14584
+ enable: true,
14585
+ /**
14586
+ * EXPERIMENTAL FEATURE -- can be removed/changed
14587
+ * Change the parent input target element.
14588
+ * If Null, then it is being set the to main element.
14589
+ * @type {Null|EventTarget}
14590
+ * @default null
14591
+ */
14592
+ inputTarget: null,
14593
+ /**
14594
+ * force an input class
14595
+ * @type {Null|Function}
14596
+ * @default null
14597
+ */
14598
+ inputClass: null,
14599
+ /**
14600
+ * Default recognizer setup when calling `Hammer()`
14601
+ * When creating a new Manager these will be skipped.
14602
+ * @type {Array}
14603
+ */
14604
+ preset: [
14605
+ // RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
14606
+ [RotateRecognizer, { enable: false }],
14607
+ [PinchRecognizer, { enable: false }, ["rotate"]],
14608
+ [SwipeRecognizer, { direction: DIRECTION_HORIZONTAL }],
14609
+ [PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ["swipe"]],
14610
+ [TapRecognizer],
14611
+ [TapRecognizer, { event: "doubletap", taps: 2 }, ["tap"]],
14612
+ [PressRecognizer]
14613
+ ],
14614
+ /**
14615
+ * Some CSS properties can be used to improve the working of Hammer.
14616
+ * Add them to this method and they will be set when creating a new Manager.
14617
+ * @namespace
14618
+ */
14619
+ cssProps: {
14620
+ /**
14621
+ * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
14622
+ * @type {String}
14623
+ * @default 'none'
14624
+ */
14625
+ userSelect: "none",
14626
+ /**
14627
+ * Disable the Windows Phone grippers when pressing an element.
14628
+ * @type {String}
14629
+ * @default 'none'
14630
+ */
14631
+ touchSelect: "none",
14632
+ /**
14633
+ * Disables the default callout shown when you touch and hold a touch target.
14634
+ * On iOS, when you touch and hold a touch target such as a link, Safari displays
14635
+ * a callout containing information about the link. This property allows you to disable that callout.
14636
+ * @type {String}
14637
+ * @default 'none'
14638
+ */
14639
+ touchCallout: "none",
14640
+ /**
14641
+ * Specifies whether zooming is enabled. Used by IE10>
14642
+ * @type {String}
14643
+ * @default 'none'
14644
+ */
14645
+ contentZooming: "none",
14646
+ /**
14647
+ * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
14648
+ * @type {String}
14649
+ * @default 'none'
14650
+ */
14651
+ userDrag: "none",
14652
+ /**
14653
+ * Overrides the highlight color shown when the user taps a link or a JavaScript
14654
+ * clickable element in iOS. This property obeys the alpha value, if specified.
14655
+ * @type {String}
14656
+ * @default 'rgba(0,0,0,0)'
14657
+ */
14658
+ tapHighlightColor: "rgba(0,0,0,0)"
14441
14659
  }
14442
- this.manager.emit(this.options.event, input);
14660
+ };
14661
+ var STOP = 1;
14662
+ var FORCED_STOP = 2;
14663
+ function Manager(element, options) {
14664
+ this.options = assign({}, Hammer2.defaults, options || {});
14665
+ this.options.inputTarget = this.options.inputTarget || element;
14666
+ this.handlers = {};
14667
+ this.session = {};
14668
+ this.recognizers = [];
14669
+ this.oldCssProps = {};
14670
+ this.element = element;
14671
+ this.input = createInputInstance(this);
14672
+ this.touchAction = new TouchAction(this, this.options.touchAction);
14673
+ toggleCssProps(this, true);
14674
+ each2(this.options.recognizers, function(item) {
14675
+ var recognizer = this.add(new item[0](item[1]));
14676
+ item[2] && recognizer.recognizeWith(item[2]);
14677
+ item[3] && recognizer.requireFailure(item[3]);
14678
+ }, this);
14443
14679
  }
14444
- });
14445
- function TapRecognizer() {
14446
- Recognizer.apply(this, arguments);
14447
- this.pTime = false;
14448
- this.pCenter = false;
14449
- this._timer = null;
14450
- this._input = null;
14451
- this.count = 0;
14452
- }
14453
- inherit(TapRecognizer, Recognizer, {
14454
- /**
14455
- * @namespace
14456
- * @memberof PinchRecognizer
14457
- */
14458
- defaults: {
14459
- event: "tap",
14460
- pointers: 1,
14461
- taps: 1,
14462
- interval: 300,
14463
- // max time between the multi-tap taps
14464
- time: 250,
14465
- // max time of the pointer to be down (like finger on the screen)
14466
- threshold: 9,
14467
- // a minimal movement is ok, but keep it low
14468
- posThreshold: 10
14469
- // a multi-tap can be a bit off the initial position
14470
- },
14471
- getTouchAction: function() {
14472
- return [TOUCH_ACTION_MANIPULATION];
14473
- },
14474
- process: function(input) {
14475
- var options = this.options;
14476
- var validPointers = input.pointers.length === options.pointers;
14477
- var validMovement = input.distance < options.threshold;
14478
- var validTouchTime = input.deltaTime < options.time;
14479
- this.reset();
14480
- if (input.eventType & INPUT_START && this.count === 0) {
14481
- return this.failTimeout();
14482
- }
14483
- if (validMovement && validTouchTime && validPointers) {
14484
- if (input.eventType != INPUT_END) {
14485
- return this.failTimeout();
14680
+ Manager.prototype = {
14681
+ /**
14682
+ * set options
14683
+ * @param {Object} options
14684
+ * @returns {Manager}
14685
+ */
14686
+ set: function(options) {
14687
+ assign(this.options, options);
14688
+ if (options.touchAction) {
14689
+ this.touchAction.update();
14486
14690
  }
14487
- var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
14488
- var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
14489
- this.pTime = input.timeStamp;
14490
- this.pCenter = input.center;
14491
- if (!validMultiTap || !validInterval) {
14492
- this.count = 1;
14493
- } else {
14494
- this.count += 1;
14691
+ if (options.inputTarget) {
14692
+ this.input.destroy();
14693
+ this.input.target = options.inputTarget;
14694
+ this.input.init();
14495
14695
  }
14496
- this._input = input;
14497
- var tapCount = this.count % options.taps;
14498
- if (tapCount === 0) {
14499
- if (!this.hasRequireFailures()) {
14500
- return STATE_RECOGNIZED;
14696
+ return this;
14697
+ },
14698
+ /**
14699
+ * stop recognizing for this session.
14700
+ * This session will be discarded, when a new [input]start event is fired.
14701
+ * When forced, the recognizer cycle is stopped immediately.
14702
+ * @param {Boolean} [force]
14703
+ */
14704
+ stop: function(force) {
14705
+ this.session.stopped = force ? FORCED_STOP : STOP;
14706
+ },
14707
+ /**
14708
+ * run the recognizers!
14709
+ * called by the inputHandler function on every movement of the pointers (touches)
14710
+ * it walks through all the recognizers and tries to detect the gesture that is being made
14711
+ * @param {Object} inputData
14712
+ */
14713
+ recognize: function(inputData) {
14714
+ var session = this.session;
14715
+ if (session.stopped) {
14716
+ return;
14717
+ }
14718
+ this.touchAction.preventDefaults(inputData);
14719
+ var recognizer;
14720
+ var recognizers = this.recognizers;
14721
+ var curRecognizer = session.curRecognizer;
14722
+ if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
14723
+ curRecognizer = session.curRecognizer = null;
14724
+ }
14725
+ var i2 = 0;
14726
+ while (i2 < recognizers.length) {
14727
+ recognizer = recognizers[i2];
14728
+ if (session.stopped !== FORCED_STOP && // 1
14729
+ (!curRecognizer || recognizer == curRecognizer || // 2
14730
+ recognizer.canRecognizeWith(curRecognizer))) {
14731
+ recognizer.recognize(inputData);
14501
14732
  } else {
14502
- this._timer = setTimeoutContext(function() {
14503
- this.state = STATE_RECOGNIZED;
14504
- this.tryEmit();
14505
- }, options.interval, this);
14506
- return STATE_BEGAN;
14733
+ recognizer.reset();
14734
+ }
14735
+ if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
14736
+ curRecognizer = session.curRecognizer = recognizer;
14507
14737
  }
14738
+ i2++;
14508
14739
  }
14509
- }
14510
- return STATE_FAILED;
14511
- },
14512
- failTimeout: function() {
14513
- this._timer = setTimeoutContext(function() {
14514
- this.state = STATE_FAILED;
14515
- }, this.options.interval, this);
14516
- return STATE_FAILED;
14517
- },
14518
- reset: function() {
14519
- clearTimeout(this._timer);
14520
- },
14521
- emit: function() {
14522
- if (this.state == STATE_RECOGNIZED) {
14523
- this._input.tapCount = this.count;
14524
- this.manager.emit(this.options.event, this._input);
14525
- }
14526
- }
14527
- });
14528
- function Hammer2(element, options) {
14529
- options = options || {};
14530
- options.recognizers = ifUndefined(options.recognizers, Hammer2.defaults.preset);
14531
- return new Manager(element, options);
14532
- }
14533
- Hammer2.VERSION = "2.0.7";
14534
- Hammer2.defaults = {
14535
- /**
14536
- * set if DOM events are being triggered.
14537
- * But this is slower and unused by simple implementations, so disabled by default.
14538
- * @type {Boolean}
14539
- * @default false
14540
- */
14541
- domEvents: false,
14542
- /**
14543
- * The value for the touchAction property/fallback.
14544
- * When set to `compute` it will magically set the correct value based on the added recognizers.
14545
- * @type {String}
14546
- * @default compute
14547
- */
14548
- touchAction: TOUCH_ACTION_COMPUTE,
14549
- /**
14550
- * @type {Boolean}
14551
- * @default true
14552
- */
14553
- enable: true,
14554
- /**
14555
- * EXPERIMENTAL FEATURE -- can be removed/changed
14556
- * Change the parent input target element.
14557
- * If Null, then it is being set the to main element.
14558
- * @type {Null|EventTarget}
14559
- * @default null
14560
- */
14561
- inputTarget: null,
14562
- /**
14563
- * force an input class
14564
- * @type {Null|Function}
14565
- * @default null
14566
- */
14567
- inputClass: null,
14568
- /**
14569
- * Default recognizer setup when calling `Hammer()`
14570
- * When creating a new Manager these will be skipped.
14571
- * @type {Array}
14572
- */
14573
- preset: [
14574
- // RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
14575
- [RotateRecognizer, { enable: false }],
14576
- [PinchRecognizer, { enable: false }, ["rotate"]],
14577
- [SwipeRecognizer, { direction: DIRECTION_HORIZONTAL }],
14578
- [PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ["swipe"]],
14579
- [TapRecognizer],
14580
- [TapRecognizer, { event: "doubletap", taps: 2 }, ["tap"]],
14581
- [PressRecognizer]
14582
- ],
14583
- /**
14584
- * Some CSS properties can be used to improve the working of Hammer.
14585
- * Add them to this method and they will be set when creating a new Manager.
14586
- * @namespace
14587
- */
14588
- cssProps: {
14740
+ },
14589
14741
  /**
14590
- * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
14591
- * @type {String}
14592
- * @default 'none'
14742
+ * get a recognizer by its event name.
14743
+ * @param {Recognizer|String} recognizer
14744
+ * @returns {Recognizer|Null}
14593
14745
  */
14594
- userSelect: "none",
14746
+ get: function(recognizer) {
14747
+ if (recognizer instanceof Recognizer) {
14748
+ return recognizer;
14749
+ }
14750
+ var recognizers = this.recognizers;
14751
+ for (var i2 = 0; i2 < recognizers.length; i2++) {
14752
+ if (recognizers[i2].options.event == recognizer) {
14753
+ return recognizers[i2];
14754
+ }
14755
+ }
14756
+ return null;
14757
+ },
14595
14758
  /**
14596
- * Disable the Windows Phone grippers when pressing an element.
14597
- * @type {String}
14598
- * @default 'none'
14759
+ * add a recognizer to the manager
14760
+ * existing recognizers with the same event name will be removed
14761
+ * @param {Recognizer} recognizer
14762
+ * @returns {Recognizer|Manager}
14599
14763
  */
14600
- touchSelect: "none",
14764
+ add: function(recognizer) {
14765
+ if (invokeArrayArg(recognizer, "add", this)) {
14766
+ return this;
14767
+ }
14768
+ var existing = this.get(recognizer.options.event);
14769
+ if (existing) {
14770
+ this.remove(existing);
14771
+ }
14772
+ this.recognizers.push(recognizer);
14773
+ recognizer.manager = this;
14774
+ this.touchAction.update();
14775
+ return recognizer;
14776
+ },
14601
14777
  /**
14602
- * Disables the default callout shown when you touch and hold a touch target.
14603
- * On iOS, when you touch and hold a touch target such as a link, Safari displays
14604
- * a callout containing information about the link. This property allows you to disable that callout.
14605
- * @type {String}
14606
- * @default 'none'
14778
+ * remove a recognizer by name or instance
14779
+ * @param {Recognizer|String} recognizer
14780
+ * @returns {Manager}
14607
14781
  */
14608
- touchCallout: "none",
14782
+ remove: function(recognizer) {
14783
+ if (invokeArrayArg(recognizer, "remove", this)) {
14784
+ return this;
14785
+ }
14786
+ recognizer = this.get(recognizer);
14787
+ if (recognizer) {
14788
+ var recognizers = this.recognizers;
14789
+ var index2 = inArray(recognizers, recognizer);
14790
+ if (index2 !== -1) {
14791
+ recognizers.splice(index2, 1);
14792
+ this.touchAction.update();
14793
+ }
14794
+ }
14795
+ return this;
14796
+ },
14609
14797
  /**
14610
- * Specifies whether zooming is enabled. Used by IE10>
14611
- * @type {String}
14612
- * @default 'none'
14798
+ * bind event
14799
+ * @param {String} events
14800
+ * @param {Function} handler
14801
+ * @returns {EventEmitter} this
14613
14802
  */
14614
- contentZooming: "none",
14803
+ on: function(events, handler) {
14804
+ if (events === undefined$1) {
14805
+ return;
14806
+ }
14807
+ if (handler === undefined$1) {
14808
+ return;
14809
+ }
14810
+ var handlers = this.handlers;
14811
+ each2(splitStr(events), function(event) {
14812
+ handlers[event] = handlers[event] || [];
14813
+ handlers[event].push(handler);
14814
+ });
14815
+ return this;
14816
+ },
14615
14817
  /**
14616
- * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
14617
- * @type {String}
14618
- * @default 'none'
14818
+ * unbind event, leave emit blank to remove all handlers
14819
+ * @param {String} events
14820
+ * @param {Function} [handler]
14821
+ * @returns {EventEmitter} this
14619
14822
  */
14620
- userDrag: "none",
14823
+ off: function(events, handler) {
14824
+ if (events === undefined$1) {
14825
+ return;
14826
+ }
14827
+ var handlers = this.handlers;
14828
+ each2(splitStr(events), function(event) {
14829
+ if (!handler) {
14830
+ delete handlers[event];
14831
+ } else {
14832
+ handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
14833
+ }
14834
+ });
14835
+ return this;
14836
+ },
14621
14837
  /**
14622
- * Overrides the highlight color shown when the user taps a link or a JavaScript
14623
- * clickable element in iOS. This property obeys the alpha value, if specified.
14624
- * @type {String}
14625
- * @default 'rgba(0,0,0,0)'
14838
+ * emit event to the listeners
14839
+ * @param {String} event
14840
+ * @param {Object} data
14626
14841
  */
14627
- tapHighlightColor: "rgba(0,0,0,0)"
14628
- }
14629
- };
14630
- var STOP = 1;
14631
- var FORCED_STOP = 2;
14632
- function Manager(element, options) {
14633
- this.options = assign({}, Hammer2.defaults, options || {});
14634
- this.options.inputTarget = this.options.inputTarget || element;
14635
- this.handlers = {};
14636
- this.session = {};
14637
- this.recognizers = [];
14638
- this.oldCssProps = {};
14639
- this.element = element;
14640
- this.input = createInputInstance(this);
14641
- this.touchAction = new TouchAction(this, this.options.touchAction);
14642
- toggleCssProps(this, true);
14643
- each2(this.options.recognizers, function(item) {
14644
- var recognizer = this.add(new item[0](item[1]));
14645
- item[2] && recognizer.recognizeWith(item[2]);
14646
- item[3] && recognizer.requireFailure(item[3]);
14647
- }, this);
14648
- }
14649
- Manager.prototype = {
14650
- /**
14651
- * set options
14652
- * @param {Object} options
14653
- * @returns {Manager}
14654
- */
14655
- set: function(options) {
14656
- assign(this.options, options);
14657
- if (options.touchAction) {
14658
- this.touchAction.update();
14659
- }
14660
- if (options.inputTarget) {
14661
- this.input.destroy();
14662
- this.input.target = options.inputTarget;
14663
- this.input.init();
14664
- }
14665
- return this;
14666
- },
14667
- /**
14668
- * stop recognizing for this session.
14669
- * This session will be discarded, when a new [input]start event is fired.
14670
- * When forced, the recognizer cycle is stopped immediately.
14671
- * @param {Boolean} [force]
14672
- */
14673
- stop: function(force) {
14674
- this.session.stopped = force ? FORCED_STOP : STOP;
14675
- },
14676
- /**
14677
- * run the recognizers!
14678
- * called by the inputHandler function on every movement of the pointers (touches)
14679
- * it walks through all the recognizers and tries to detect the gesture that is being made
14680
- * @param {Object} inputData
14681
- */
14682
- recognize: function(inputData) {
14683
- var session = this.session;
14684
- if (session.stopped) {
14685
- return;
14686
- }
14687
- this.touchAction.preventDefaults(inputData);
14688
- var recognizer;
14689
- var recognizers = this.recognizers;
14690
- var curRecognizer = session.curRecognizer;
14691
- if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
14692
- curRecognizer = session.curRecognizer = null;
14693
- }
14694
- var i2 = 0;
14695
- while (i2 < recognizers.length) {
14696
- recognizer = recognizers[i2];
14697
- if (session.stopped !== FORCED_STOP && // 1
14698
- (!curRecognizer || recognizer == curRecognizer || // 2
14699
- recognizer.canRecognizeWith(curRecognizer))) {
14700
- recognizer.recognize(inputData);
14701
- } else {
14702
- recognizer.reset();
14842
+ emit: function(event, data) {
14843
+ if (this.options.domEvents) {
14844
+ triggerDomEvent(event, data);
14703
14845
  }
14704
- if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
14705
- curRecognizer = session.curRecognizer = recognizer;
14706
- }
14707
- i2++;
14708
- }
14709
- },
14710
- /**
14711
- * get a recognizer by its event name.
14712
- * @param {Recognizer|String} recognizer
14713
- * @returns {Recognizer|Null}
14714
- */
14715
- get: function(recognizer) {
14716
- if (recognizer instanceof Recognizer) {
14717
- return recognizer;
14718
- }
14719
- var recognizers = this.recognizers;
14720
- for (var i2 = 0; i2 < recognizers.length; i2++) {
14721
- if (recognizers[i2].options.event == recognizer) {
14722
- return recognizers[i2];
14846
+ var handlers = this.handlers[event] && this.handlers[event].slice();
14847
+ if (!handlers || !handlers.length) {
14848
+ return;
14723
14849
  }
14724
- }
14725
- return null;
14726
- },
14727
- /**
14728
- * add a recognizer to the manager
14729
- * existing recognizers with the same event name will be removed
14730
- * @param {Recognizer} recognizer
14731
- * @returns {Recognizer|Manager}
14732
- */
14733
- add: function(recognizer) {
14734
- if (invokeArrayArg(recognizer, "add", this)) {
14735
- return this;
14736
- }
14737
- var existing = this.get(recognizer.options.event);
14738
- if (existing) {
14739
- this.remove(existing);
14740
- }
14741
- this.recognizers.push(recognizer);
14742
- recognizer.manager = this;
14743
- this.touchAction.update();
14744
- return recognizer;
14745
- },
14746
- /**
14747
- * remove a recognizer by name or instance
14748
- * @param {Recognizer|String} recognizer
14749
- * @returns {Manager}
14750
- */
14751
- remove: function(recognizer) {
14752
- if (invokeArrayArg(recognizer, "remove", this)) {
14753
- return this;
14754
- }
14755
- recognizer = this.get(recognizer);
14756
- if (recognizer) {
14757
- var recognizers = this.recognizers;
14758
- var index2 = inArray(recognizers, recognizer);
14759
- if (index2 !== -1) {
14760
- recognizers.splice(index2, 1);
14761
- this.touchAction.update();
14850
+ data.type = event;
14851
+ data.preventDefault = function() {
14852
+ data.srcEvent.preventDefault();
14853
+ };
14854
+ var i2 = 0;
14855
+ while (i2 < handlers.length) {
14856
+ handlers[i2](data);
14857
+ i2++;
14762
14858
  }
14859
+ },
14860
+ /**
14861
+ * destroy the manager and unbinds all events
14862
+ * it doesn't unbind dom events, that is the user own responsibility
14863
+ */
14864
+ destroy: function() {
14865
+ this.element && toggleCssProps(this, false);
14866
+ this.handlers = {};
14867
+ this.session = {};
14868
+ this.input.destroy();
14869
+ this.element = null;
14763
14870
  }
14764
- return this;
14765
- },
14766
- /**
14767
- * bind event
14768
- * @param {String} events
14769
- * @param {Function} handler
14770
- * @returns {EventEmitter} this
14771
- */
14772
- on: function(events, handler) {
14773
- if (events === undefined$1) {
14774
- return;
14775
- }
14776
- if (handler === undefined$1) {
14777
- return;
14778
- }
14779
- var handlers = this.handlers;
14780
- each2(splitStr(events), function(event) {
14781
- handlers[event] = handlers[event] || [];
14782
- handlers[event].push(handler);
14783
- });
14784
- return this;
14785
- },
14786
- /**
14787
- * unbind event, leave emit blank to remove all handlers
14788
- * @param {String} events
14789
- * @param {Function} [handler]
14790
- * @returns {EventEmitter} this
14791
- */
14792
- off: function(events, handler) {
14793
- if (events === undefined$1) {
14871
+ };
14872
+ function toggleCssProps(manager, add2) {
14873
+ var element = manager.element;
14874
+ if (!element.style) {
14794
14875
  return;
14795
14876
  }
14796
- var handlers = this.handlers;
14797
- each2(splitStr(events), function(event) {
14798
- if (!handler) {
14799
- delete handlers[event];
14877
+ var prop;
14878
+ each2(manager.options.cssProps, function(value, name) {
14879
+ prop = prefixed(element.style, name);
14880
+ if (add2) {
14881
+ manager.oldCssProps[prop] = element.style[prop];
14882
+ element.style[prop] = value;
14800
14883
  } else {
14801
- handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
14884
+ element.style[prop] = manager.oldCssProps[prop] || "";
14802
14885
  }
14803
14886
  });
14804
- return this;
14805
- },
14806
- /**
14807
- * emit event to the listeners
14808
- * @param {String} event
14809
- * @param {Object} data
14810
- */
14811
- emit: function(event, data) {
14812
- if (this.options.domEvents) {
14813
- triggerDomEvent(event, data);
14814
- }
14815
- var handlers = this.handlers[event] && this.handlers[event].slice();
14816
- if (!handlers || !handlers.length) {
14817
- return;
14818
- }
14819
- data.type = event;
14820
- data.preventDefault = function() {
14821
- data.srcEvent.preventDefault();
14822
- };
14823
- var i2 = 0;
14824
- while (i2 < handlers.length) {
14825
- handlers[i2](data);
14826
- i2++;
14887
+ if (!add2) {
14888
+ manager.oldCssProps = {};
14827
14889
  }
14828
- },
14829
- /**
14830
- * destroy the manager and unbinds all events
14831
- * it doesn't unbind dom events, that is the user own responsibility
14832
- */
14833
- destroy: function() {
14834
- this.element && toggleCssProps(this, false);
14835
- this.handlers = {};
14836
- this.session = {};
14837
- this.input.destroy();
14838
- this.element = null;
14839
- }
14840
- };
14841
- function toggleCssProps(manager, add2) {
14842
- var element = manager.element;
14843
- if (!element.style) {
14844
- return;
14845
14890
  }
14846
- var prop;
14847
- each2(manager.options.cssProps, function(value, name) {
14848
- prop = prefixed(element.style, name);
14849
- if (add2) {
14850
- manager.oldCssProps[prop] = element.style[prop];
14851
- element.style[prop] = value;
14852
- } else {
14853
- element.style[prop] = manager.oldCssProps[prop] || "";
14854
- }
14891
+ function triggerDomEvent(event, data) {
14892
+ var gestureEvent = document2.createEvent("Event");
14893
+ gestureEvent.initEvent(event, true, true);
14894
+ gestureEvent.gesture = data;
14895
+ data.target.dispatchEvent(gestureEvent);
14896
+ }
14897
+ assign(Hammer2, {
14898
+ INPUT_START,
14899
+ INPUT_MOVE,
14900
+ INPUT_END,
14901
+ INPUT_CANCEL,
14902
+ STATE_POSSIBLE,
14903
+ STATE_BEGAN,
14904
+ STATE_CHANGED,
14905
+ STATE_ENDED,
14906
+ STATE_RECOGNIZED,
14907
+ STATE_CANCELLED,
14908
+ STATE_FAILED,
14909
+ DIRECTION_NONE,
14910
+ DIRECTION_LEFT,
14911
+ DIRECTION_RIGHT,
14912
+ DIRECTION_UP,
14913
+ DIRECTION_DOWN,
14914
+ DIRECTION_HORIZONTAL,
14915
+ DIRECTION_VERTICAL,
14916
+ DIRECTION_ALL,
14917
+ Manager,
14918
+ Input,
14919
+ TouchAction,
14920
+ TouchInput,
14921
+ MouseInput,
14922
+ PointerEventInput,
14923
+ TouchMouseInput,
14924
+ SingleTouchInput,
14925
+ Recognizer,
14926
+ AttrRecognizer,
14927
+ Tap: TapRecognizer,
14928
+ Pan: PanRecognizer,
14929
+ Swipe: SwipeRecognizer,
14930
+ Pinch: PinchRecognizer,
14931
+ Rotate: RotateRecognizer,
14932
+ Press: PressRecognizer,
14933
+ on: addEventListeners,
14934
+ off: removeEventListeners,
14935
+ each: each2,
14936
+ merge: merge2,
14937
+ extend,
14938
+ assign,
14939
+ inherit,
14940
+ bindFn,
14941
+ prefixed
14855
14942
  });
14856
- if (!add2) {
14857
- manager.oldCssProps = {};
14858
- }
14859
- }
14860
- function triggerDomEvent(event, data) {
14861
- var gestureEvent = document2.createEvent("Event");
14862
- gestureEvent.initEvent(event, true, true);
14863
- gestureEvent.gesture = data;
14864
- data.target.dispatchEvent(gestureEvent);
14865
- }
14866
- assign(Hammer2, {
14867
- INPUT_START,
14868
- INPUT_MOVE,
14869
- INPUT_END,
14870
- INPUT_CANCEL,
14871
- STATE_POSSIBLE,
14872
- STATE_BEGAN,
14873
- STATE_CHANGED,
14874
- STATE_ENDED,
14875
- STATE_RECOGNIZED,
14876
- STATE_CANCELLED,
14877
- STATE_FAILED,
14878
- DIRECTION_NONE,
14879
- DIRECTION_LEFT,
14880
- DIRECTION_RIGHT,
14881
- DIRECTION_UP,
14882
- DIRECTION_DOWN,
14883
- DIRECTION_HORIZONTAL,
14884
- DIRECTION_VERTICAL,
14885
- DIRECTION_ALL,
14886
- Manager,
14887
- Input,
14888
- TouchAction,
14889
- TouchInput,
14890
- MouseInput,
14891
- PointerEventInput,
14892
- TouchMouseInput,
14893
- SingleTouchInput,
14894
- Recognizer,
14895
- AttrRecognizer,
14896
- Tap: TapRecognizer,
14897
- Pan: PanRecognizer,
14898
- Swipe: SwipeRecognizer,
14899
- Pinch: PinchRecognizer,
14900
- Rotate: RotateRecognizer,
14901
- Press: PressRecognizer,
14902
- on: addEventListeners,
14903
- off: removeEventListeners,
14904
- each: each2,
14905
- merge: merge2,
14906
- extend,
14907
- assign,
14908
- inherit,
14909
- bindFn,
14910
- prefixed
14911
- });
14912
- var freeGlobal = typeof window2 !== "undefined" ? window2 : typeof self !== "undefined" ? self : {};
14913
- freeGlobal.Hammer = Hammer2;
14914
- if (module.exports) {
14915
- module.exports = Hammer2;
14916
- } else {
14917
- window2[exportName] = Hammer2;
14918
- }
14919
- })(window, document, "Hammer");
14920
- })(hammer);
14921
- var hammerExports = hammer.exports;
14943
+ var freeGlobal = typeof window2 !== "undefined" ? window2 : typeof self !== "undefined" ? self : {};
14944
+ freeGlobal.Hammer = Hammer2;
14945
+ if (module.exports) {
14946
+ module.exports = Hammer2;
14947
+ } else {
14948
+ window2[exportName] = Hammer2;
14949
+ }
14950
+ })(window, document, "Hammer");
14951
+ })(hammer);
14952
+ return hammer.exports;
14953
+ }
14954
+ var hammerExports = requireHammer();
14922
14955
  const Hammer = /* @__PURE__ */ getDefaultExportFromCjs(hammerExports);
14923
14956
  /*!
14924
- * chartjs-plugin-zoom v2.2.0
14925
- * https://www.chartjs.org/chartjs-plugin-zoom/2.2.0/
14926
- * (c) 2016-2024 chartjs-plugin-zoom Contributors
14957
+ * chartjs-plugin-zoom v2.0.1
14958
+ * undefined
14959
+ * (c) 2016-2023 chartjs-plugin-zoom Contributors
14927
14960
  * Released under the MIT License
14928
14961
  */
14929
14962
  const getModifierKey = (opts) => opts && opts.enabled && opts.modifierKey;
@@ -15000,9 +15033,7 @@ function getState(chart2) {
15000
15033
  originalScaleLimits: {},
15001
15034
  updatedScaleLimits: {},
15002
15035
  handlers: {},
15003
- panDelta: {},
15004
- dragging: false,
15005
- panning: false
15036
+ panDelta: {}
15006
15037
  };
15007
15038
  chartStates$1.set(chart2, state);
15008
15039
  }
@@ -15011,43 +15042,20 @@ function getState(chart2) {
15011
15042
  function removeState(chart2) {
15012
15043
  chartStates$1.delete(chart2);
15013
15044
  }
15014
- function zoomDelta(val, min, range, newRange) {
15015
- const minPercent = Math.max(0, Math.min(1, (val - min) / range || 0));
15045
+ function zoomDelta(scale, zoom2, center) {
15046
+ const range = scale.max - scale.min;
15047
+ const newRange = range * (zoom2 - 1);
15048
+ const centerPoint = scale.isHorizontal() ? center.x : center.y;
15049
+ const minPercent = Math.max(0, Math.min(
15050
+ 1,
15051
+ (scale.getValueForPixel(centerPoint) - scale.min) / range || 0
15052
+ ));
15016
15053
  const maxPercent = 1 - minPercent;
15017
15054
  return {
15018
15055
  min: newRange * minPercent,
15019
15056
  max: newRange * maxPercent
15020
15057
  };
15021
15058
  }
15022
- function getValueAtPoint(scale, point) {
15023
- const pixel = scale.isHorizontal() ? point.x : point.y;
15024
- return scale.getValueForPixel(pixel);
15025
- }
15026
- function linearZoomDelta(scale, zoom2, center) {
15027
- const range = scale.max - scale.min;
15028
- const newRange = range * (zoom2 - 1);
15029
- const centerValue = getValueAtPoint(scale, center);
15030
- return zoomDelta(centerValue, scale.min, range, newRange);
15031
- }
15032
- function logarithmicZoomRange(scale, zoom2, center) {
15033
- const centerValue = getValueAtPoint(scale, center);
15034
- if (centerValue === void 0) {
15035
- return { min: scale.min, max: scale.max };
15036
- }
15037
- const logMin = Math.log10(scale.min);
15038
- const logMax = Math.log10(scale.max);
15039
- const logCenter = Math.log10(centerValue);
15040
- const logRange = logMax - logMin;
15041
- const newLogRange = logRange * (zoom2 - 1);
15042
- const delta = zoomDelta(logCenter, logMin, logRange, newLogRange);
15043
- return {
15044
- min: Math.pow(10, logMin + delta.min),
15045
- max: Math.pow(10, logMax - delta.max)
15046
- };
15047
- }
15048
- function getScaleLimits$1(scale, limits) {
15049
- return limits && (limits[scale.id] || limits[scale.axis]) || {};
15050
- }
15051
15059
  function getLimit(state, scale, scaleLimits, prop, fallback) {
15052
15060
  let limit = scaleLimits[prop];
15053
15061
  if (limit === "original") {
@@ -15056,7 +15064,7 @@ function getLimit(state, scale, scaleLimits, prop, fallback) {
15056
15064
  }
15057
15065
  return valueOrDefault$1(limit, fallback);
15058
15066
  }
15059
- function linearRange(scale, pixel0, pixel1) {
15067
+ function getRange(scale, pixel0, pixel1) {
15060
15068
  const v0 = scale.getValueForPixel(pixel0);
15061
15069
  const v1 = scale.getValueForPixel(pixel1);
15062
15070
  return {
@@ -15064,19 +15072,17 @@ function linearRange(scale, pixel0, pixel1) {
15064
15072
  max: Math.max(v0, v1)
15065
15073
  };
15066
15074
  }
15067
- function fixRange(range, { min, max, minLimit, maxLimit }, originalLimits) {
15075
+ function updateRange(scale, { min, max }, limits, zoom2 = false) {
15076
+ const state = getState(scale.chart);
15077
+ const { id, axis, options: scaleOpts } = scale;
15078
+ const scaleLimits = limits && (limits[id] || limits[axis]) || {};
15079
+ const { minRange = 0 } = scaleLimits;
15080
+ const minLimit = getLimit(state, scale, scaleLimits, "min", -Infinity);
15081
+ const maxLimit = getLimit(state, scale, scaleLimits, "max", Infinity);
15082
+ const range = zoom2 ? Math.max(max - min, minRange) : scale.max - scale.min;
15068
15083
  const offset = (range - max + min) / 2;
15069
15084
  min -= offset;
15070
15085
  max += offset;
15071
- const origMin = originalLimits.min.options ?? originalLimits.min.scale;
15072
- const origMax = originalLimits.max.options ?? originalLimits.max.scale;
15073
- const epsilon = range / 1e6;
15074
- if (almostEquals$1(min, origMin, epsilon)) {
15075
- min = origMin;
15076
- }
15077
- if (almostEquals$1(max, origMax, epsilon)) {
15078
- max = origMax;
15079
- }
15080
15086
  if (min < minLimit) {
15081
15087
  min = minLimit;
15082
15088
  max = Math.min(minLimit + range, maxLimit);
@@ -15084,40 +15090,18 @@ function fixRange(range, { min, max, minLimit, maxLimit }, originalLimits) {
15084
15090
  max = maxLimit;
15085
15091
  min = Math.max(maxLimit - range, minLimit);
15086
15092
  }
15087
- return { min, max };
15088
- }
15089
- function updateRange(scale, { min, max }, limits, zoom2 = false) {
15090
- const state = getState(scale.chart);
15091
- const { options: scaleOpts } = scale;
15092
- const scaleLimits = getScaleLimits$1(scale, limits);
15093
- const { minRange = 0 } = scaleLimits;
15094
- const minLimit = getLimit(state, scale, scaleLimits, "min", -Infinity);
15095
- const maxLimit = getLimit(state, scale, scaleLimits, "max", Infinity);
15096
- if (zoom2 === "pan" && (min < minLimit || max > maxLimit)) {
15097
- return true;
15098
- }
15099
- const scaleRange = scale.max - scale.min;
15100
- const range = zoom2 ? Math.max(max - min, minRange) : scaleRange;
15101
- if (zoom2 && range === minRange && scaleRange <= minRange) {
15102
- return true;
15103
- }
15104
- const newRange = fixRange(range, { min, max, minLimit, maxLimit }, state.originalScaleLimits[scale.id]);
15105
- scaleOpts.min = newRange.min;
15106
- scaleOpts.max = newRange.max;
15107
- state.updatedScaleLimits[scale.id] = newRange;
15108
- return scale.parse(newRange.min) !== scale.min || scale.parse(newRange.max) !== scale.max;
15093
+ scaleOpts.min = min;
15094
+ scaleOpts.max = max;
15095
+ state.updatedScaleLimits[scale.id] = { min, max };
15096
+ return scale.parse(min) !== scale.min || scale.parse(max) !== scale.max;
15109
15097
  }
15110
15098
  function zoomNumericalScale(scale, zoom2, center, limits) {
15111
- const delta = linearZoomDelta(scale, zoom2, center);
15099
+ const delta = zoomDelta(scale, zoom2, center);
15112
15100
  const newRange = { min: scale.min + delta.min, max: scale.max - delta.max };
15113
15101
  return updateRange(scale, newRange, limits, true);
15114
15102
  }
15115
- function zoomLogarithmicScale(scale, zoom2, center, limits) {
15116
- const newRange = logarithmicZoomRange(scale, zoom2, center);
15117
- return updateRange(scale, newRange, limits, true);
15118
- }
15119
15103
  function zoomRectNumericalScale(scale, from2, to2, limits) {
15120
- updateRange(scale, linearRange(scale, from2, to2), limits, true);
15104
+ updateRange(scale, getRange(scale, from2, to2), limits, true);
15121
15105
  }
15122
15106
  const integerChange = (v2) => v2 === 0 || isNaN(v2) ? 0 : v2 < 0 ? Math.min(Math.round(v2), -1) : Math.max(Math.round(v2), 1);
15123
15107
  function existCategoryFromMaxZoom(scale) {
@@ -15131,7 +15115,7 @@ function existCategoryFromMaxZoom(scale) {
15131
15115
  }
15132
15116
  }
15133
15117
  function zoomCategoryScale(scale, zoom2, center, limits) {
15134
- const delta = linearZoomDelta(scale, zoom2, center);
15118
+ const delta = zoomDelta(scale, zoom2, center);
15135
15119
  if (scale.min === scale.max && zoom2 < 1) {
15136
15120
  existCategoryFromMaxZoom(scale);
15137
15121
  }
@@ -15162,32 +15146,40 @@ function panCategoryScale(scale, delta, limits) {
15162
15146
  }
15163
15147
  const OFFSETS = {
15164
15148
  second: 500,
15149
+ // 500 ms
15165
15150
  minute: 30 * 1e3,
15151
+ // 30 s
15166
15152
  hour: 30 * 60 * 1e3,
15153
+ // 30 m
15167
15154
  day: 12 * 60 * 60 * 1e3,
15155
+ // 12 h
15168
15156
  week: 3.5 * 24 * 60 * 60 * 1e3,
15157
+ // 3.5 d
15169
15158
  month: 15 * 24 * 60 * 60 * 1e3,
15159
+ // 15 d
15170
15160
  quarter: 60 * 24 * 60 * 60 * 1e3,
15161
+ // 60 d
15171
15162
  year: 182 * 24 * 60 * 60 * 1e3
15163
+ // 182 d
15172
15164
  };
15173
- function panNumericalScale(scale, delta, limits, pan2 = false) {
15165
+ function panNumericalScale(scale, delta, limits, canZoom = false) {
15174
15166
  const { min: prevStart, max: prevEnd, options } = scale;
15175
15167
  const round2 = options.time && options.time.round;
15176
15168
  const offset = OFFSETS[round2] || 0;
15177
15169
  const newMin = scale.getValueForPixel(scale.getPixelForValue(prevStart + offset) - delta);
15178
15170
  const newMax = scale.getValueForPixel(scale.getPixelForValue(prevEnd + offset) - delta);
15179
- if (isNaN(newMin) || isNaN(newMax)) {
15171
+ const { min: minLimit = -Infinity, max: maxLimit = Infinity } = canZoom && limits && limits[scale.axis] || {};
15172
+ if (isNaN(newMin) || isNaN(newMax) || newMin < minLimit || newMax > maxLimit) {
15180
15173
  return true;
15181
15174
  }
15182
- return updateRange(scale, { min: newMin, max: newMax }, limits, pan2 ? "pan" : false);
15175
+ return updateRange(scale, { min: newMin, max: newMax }, limits, canZoom);
15183
15176
  }
15184
15177
  function panNonLinearScale(scale, delta, limits) {
15185
15178
  return panNumericalScale(scale, delta, limits, true);
15186
15179
  }
15187
15180
  const zoomFunctions = {
15188
15181
  category: zoomCategoryScale,
15189
- default: zoomNumericalScale,
15190
- logarithmic: zoomLogarithmicScale
15182
+ default: zoomNumericalScale
15191
15183
  };
15192
15184
  const zoomRectFunctions = {
15193
15185
  default: zoomRectNumericalScale
@@ -15232,9 +15224,9 @@ function doZoom(scale, amount, center, limits) {
15232
15224
  const fn = zoomFunctions[scale.type] || zoomFunctions.default;
15233
15225
  callback$1(fn, [scale, amount, center, limits]);
15234
15226
  }
15235
- function doZoomRect(scale, from2, to2, limits) {
15227
+ function doZoomRect(scale, amount, from2, to2, limits) {
15236
15228
  const fn = zoomRectFunctions[scale.type] || zoomRectFunctions.default;
15237
- callback$1(fn, [scale, from2, to2, limits]);
15229
+ callback$1(fn, [scale, amount, from2, to2, limits]);
15238
15230
  }
15239
15231
  function getCenter(chart2) {
15240
15232
  const ca = chart2.chartArea;
@@ -15243,7 +15235,7 @@ function getCenter(chart2) {
15243
15235
  y: (ca.top + ca.bottom) / 2
15244
15236
  };
15245
15237
  }
15246
- function zoom(chart2, amount, transition = "none", trigger = "api") {
15238
+ function zoom(chart2, amount, transition = "none") {
15247
15239
  const { x: x2 = 1, y: y2 = 1, focalPoint = getCenter(chart2) } = typeof amount === "number" ? { x: amount, y: amount } : amount;
15248
15240
  const state = getState(chart2);
15249
15241
  const { options: { limits, zoom: zoomOptions } } = state;
@@ -15259,9 +15251,9 @@ function zoom(chart2, amount, transition = "none", trigger = "api") {
15259
15251
  }
15260
15252
  });
15261
15253
  chart2.update(transition);
15262
- callback$1(zoomOptions.onZoom, [{ chart: chart2, trigger }]);
15254
+ callback$1(zoomOptions.onZoom, [{ chart: chart2 }]);
15263
15255
  }
15264
- function zoomRect(chart2, p0, p1, transition = "none", trigger = "api") {
15256
+ function zoomRect(chart2, p0, p1, transition = "none") {
15265
15257
  const state = getState(chart2);
15266
15258
  const { options: { limits, zoom: zoomOptions } } = state;
15267
15259
  const { mode = "xy" } = zoomOptions;
@@ -15276,16 +15268,13 @@ function zoomRect(chart2, p0, p1, transition = "none", trigger = "api") {
15276
15268
  }
15277
15269
  });
15278
15270
  chart2.update(transition);
15279
- callback$1(zoomOptions.onZoom, [{ chart: chart2, trigger }]);
15271
+ callback$1(zoomOptions.onZoom, [{ chart: chart2 }]);
15280
15272
  }
15281
- function zoomScale(chart2, scaleId, range, transition = "none", trigger = "api") {
15282
- var _a2;
15283
- const state = getState(chart2);
15284
- storeOriginalScaleLimits(chart2, state);
15273
+ function zoomScale(chart2, scaleId, range, transition = "none") {
15274
+ storeOriginalScaleLimits(chart2, getState(chart2));
15285
15275
  const scale = chart2.scales[scaleId];
15286
15276
  updateRange(scale, range, void 0, true);
15287
15277
  chart2.update(transition);
15288
- callback$1((_a2 = state.options.zoom) == null ? void 0 : _a2.onZoom, [{ chart: chart2, trigger }]);
15289
15278
  }
15290
15279
  function resetZoom(chart2, transition = "default") {
15291
15280
  const state = getState(chart2);
@@ -15299,7 +15288,6 @@ function resetZoom(chart2, transition = "default") {
15299
15288
  delete scaleOptions.min;
15300
15289
  delete scaleOptions.max;
15301
15290
  }
15302
- delete state.updatedScaleLimits[scale.id];
15303
15291
  });
15304
15292
  chart2.update(transition);
15305
15293
  callback$1(state.options.zoom.onZoomComplete, [{ chart: chart2 }]);
@@ -15367,14 +15355,6 @@ function getInitialScaleBounds(chart2) {
15367
15355
  }
15368
15356
  return scaleBounds;
15369
15357
  }
15370
- function getZoomedScaleBounds(chart2) {
15371
- const state = getState(chart2);
15372
- const scaleBounds = {};
15373
- for (const scaleId of Object.keys(chart2.scales)) {
15374
- scaleBounds[scaleId] = state.updatedScaleLimits[scaleId];
15375
- }
15376
- return scaleBounds;
15377
- }
15378
15358
  function isZoomedOrPanned(chart2) {
15379
15359
  const scaleBounds = getInitialScaleBounds(chart2);
15380
15360
  for (const scaleId of Object.keys(chart2.scales)) {
@@ -15388,11 +15368,6 @@ function isZoomedOrPanned(chart2) {
15388
15368
  }
15389
15369
  return false;
15390
15370
  }
15391
- function isZoomingOrPanning(chart2) {
15392
- const state = getState(chart2);
15393
- return state.panning || state.dragging;
15394
- }
15395
- const clamp$1 = (x2, from2, to2) => Math.min(to2, Math.max(from2, x2));
15396
15371
  function removeHandler(chart2, type) {
15397
15372
  const { handlers } = getState(chart2);
15398
15373
  const handler = handlers[type];
@@ -15410,8 +15385,7 @@ function addHandler(chart2, target, type, handler) {
15410
15385
  removeHandler(chart2, type);
15411
15386
  handlers[type] = (event) => handler(chart2, event, options);
15412
15387
  handlers[type].target = target;
15413
- const passive = type === "wheel" ? false : void 0;
15414
- target.addEventListener(type, handlers[type], { passive });
15388
+ target.addEventListener(type, handlers[type]);
15415
15389
  }
15416
15390
  function mouseMove(chart2, event) {
15417
15391
  const state = getState(chart2);
@@ -15431,20 +15405,10 @@ function keyDown(chart2, event) {
15431
15405
  state.dragStart = state.dragEnd = null;
15432
15406
  chart2.update("none");
15433
15407
  }
15434
- function getPointPosition(event, chart2) {
15435
- if (event.target !== chart2.canvas) {
15436
- const canvasArea = chart2.canvas.getBoundingClientRect();
15437
- return {
15438
- x: event.clientX - canvasArea.left,
15439
- y: event.clientY - canvasArea.top
15440
- };
15441
- }
15442
- return getRelativePosition$2(event, chart2);
15443
- }
15444
15408
  function zoomStart(chart2, event, zoomOptions) {
15445
15409
  const { onZoomStart, onZoomRejected } = zoomOptions;
15446
15410
  if (onZoomStart) {
15447
- const point = getPointPosition(event, chart2);
15411
+ const point = getRelativePosition$2(event, chart2);
15448
15412
  if (callback$1(onZoomStart, [{ chart: chart2, event, point }]) === false) {
15449
15413
  callback$1(onZoomRejected, [{ chart: chart2, event }]);
15450
15414
  return false;
@@ -15452,12 +15416,6 @@ function zoomStart(chart2, event, zoomOptions) {
15452
15416
  }
15453
15417
  }
15454
15418
  function mouseDown(chart2, event) {
15455
- if (chart2.legend) {
15456
- const point = getRelativePosition$2(event, chart2);
15457
- if (_isPointInArea$1(point, chart2.legend)) {
15458
- return;
15459
- }
15460
- }
15461
15419
  const state = getState(chart2);
15462
15420
  const { pan: panOptions, zoom: zoomOptions = {} } = state.options;
15463
15421
  if (event.button !== 0 || keyPressed(getModifierKey(panOptions), event) || keyNotPressed(getModifierKey(zoomOptions.drag), event)) {
@@ -15467,52 +15425,30 @@ function mouseDown(chart2, event) {
15467
15425
  return;
15468
15426
  }
15469
15427
  state.dragStart = event;
15470
- addHandler(chart2, chart2.canvas.ownerDocument, "mousemove", mouseMove);
15428
+ addHandler(chart2, chart2.canvas, "mousemove", mouseMove);
15471
15429
  addHandler(chart2, window.document, "keydown", keyDown);
15472
15430
  }
15473
- function applyAspectRatio({ begin, end }, aspectRatio) {
15474
- let width = end.x - begin.x;
15475
- let height = end.y - begin.y;
15476
- const ratio = Math.abs(width / height);
15477
- if (ratio > aspectRatio) {
15478
- width = Math.sign(width) * Math.abs(height * aspectRatio);
15479
- } else if (ratio < aspectRatio) {
15480
- height = Math.sign(height) * Math.abs(width / aspectRatio);
15481
- }
15482
- end.x = begin.x + width;
15483
- end.y = begin.y + height;
15484
- }
15485
- function applyMinMaxProps(rect, chartArea, points, { min, max, prop }) {
15486
- rect[min] = clamp$1(Math.min(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
15487
- rect[max] = clamp$1(Math.max(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
15488
- }
15489
- function getRelativePoints(chart2, pointEvents, maintainAspectRatio) {
15490
- const points = {
15491
- begin: getPointPosition(pointEvents.dragStart, chart2),
15492
- end: getPointPosition(pointEvents.dragEnd, chart2)
15493
- };
15494
- if (maintainAspectRatio) {
15495
- const aspectRatio = chart2.chartArea.width / chart2.chartArea.height;
15496
- applyAspectRatio(points, aspectRatio);
15497
- }
15498
- return points;
15499
- }
15500
- function computeDragRect(chart2, mode, pointEvents, maintainAspectRatio) {
15431
+ function computeDragRect(chart2, mode, beginPointEvent, endPointEvent) {
15501
15432
  const xEnabled = directionEnabled(mode, "x", chart2);
15502
15433
  const yEnabled = directionEnabled(mode, "y", chart2);
15503
- const { top: top2, left: left2, right: right2, bottom: bottom2, width: chartWidth, height: chartHeight } = chart2.chartArea;
15504
- const rect = { top: top2, left: left2, right: right2, bottom: bottom2 };
15505
- const points = getRelativePoints(chart2, pointEvents, maintainAspectRatio && xEnabled && yEnabled);
15434
+ let { top: top2, left: left2, right: right2, bottom: bottom2, width: chartWidth, height: chartHeight } = chart2.chartArea;
15435
+ const beginPoint = getRelativePosition$2(beginPointEvent, chart2);
15436
+ const endPoint = getRelativePosition$2(endPointEvent, chart2);
15506
15437
  if (xEnabled) {
15507
- applyMinMaxProps(rect, chart2.chartArea, points, { min: "left", max: "right", prop: "x" });
15438
+ left2 = Math.min(beginPoint.x, endPoint.x);
15439
+ right2 = Math.max(beginPoint.x, endPoint.x);
15508
15440
  }
15509
15441
  if (yEnabled) {
15510
- applyMinMaxProps(rect, chart2.chartArea, points, { min: "top", max: "bottom", prop: "y" });
15442
+ top2 = Math.min(beginPoint.y, endPoint.y);
15443
+ bottom2 = Math.max(beginPoint.y, endPoint.y);
15511
15444
  }
15512
- const width = rect.right - rect.left;
15513
- const height = rect.bottom - rect.top;
15445
+ const width = right2 - left2;
15446
+ const height = bottom2 - top2;
15514
15447
  return {
15515
- ...rect,
15448
+ left: left2,
15449
+ top: top2,
15450
+ right: right2,
15451
+ bottom: bottom2,
15516
15452
  width,
15517
15453
  height,
15518
15454
  zoomX: xEnabled && width ? 1 + (chartWidth - width) / chartWidth : 1,
@@ -15525,8 +15461,8 @@ function mouseUp(chart2, event) {
15525
15461
  return;
15526
15462
  }
15527
15463
  removeHandler(chart2, "mousemove");
15528
- const { mode, onZoomComplete, drag: { threshold = 0, maintainAspectRatio } } = state.options.zoom;
15529
- const rect = computeDragRect(chart2, mode, { dragStart: state.dragStart, dragEnd: event }, maintainAspectRatio);
15464
+ const { mode, onZoomComplete, drag: { threshold = 0 } } = state.options.zoom;
15465
+ const rect = computeDragRect(chart2, mode, state.dragStart, event);
15530
15466
  const distanceX = directionEnabled(mode, "x", chart2) ? rect.width : 0;
15531
15467
  const distanceY = directionEnabled(mode, "y", chart2) ? rect.height : 0;
15532
15468
  const distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
@@ -15536,9 +15472,8 @@ function mouseUp(chart2, event) {
15536
15472
  chart2.update("none");
15537
15473
  return;
15538
15474
  }
15539
- zoomRect(chart2, { x: rect.left, y: rect.top }, { x: rect.right, y: rect.bottom }, "zoom", "drag");
15540
- state.dragging = false;
15541
- state.filterNextClick = true;
15475
+ zoomRect(chart2, { x: rect.left, y: rect.top }, { x: rect.right, y: rect.bottom }, "zoom");
15476
+ setTimeout(() => state.dragging = false, 500);
15542
15477
  callback$1(onZoomComplete, [{ chart: chart2 }]);
15543
15478
  }
15544
15479
  function wheelPreconditions(chart2, event, zoomOptions) {
@@ -15563,18 +15498,19 @@ function wheel(chart2, event) {
15563
15498
  return;
15564
15499
  }
15565
15500
  const rect = event.target.getBoundingClientRect();
15566
- const speed = zoomOptions.wheel.speed;
15567
- const percentage = event.deltaY >= 0 ? 2 - 1 / (1 - speed) : 1 + speed;
15501
+ const speed = 1 + (event.deltaY >= 0 ? -zoomOptions.wheel.speed : zoomOptions.wheel.speed);
15568
15502
  const amount = {
15569
- x: percentage,
15570
- y: percentage,
15503
+ x: speed,
15504
+ y: speed,
15571
15505
  focalPoint: {
15572
15506
  x: event.clientX - rect.left,
15573
15507
  y: event.clientY - rect.top
15574
15508
  }
15575
15509
  };
15576
- zoom(chart2, amount, "zoom", "wheel");
15577
- callback$1(onZoomComplete, [{ chart: chart2 }]);
15510
+ zoom(chart2, amount);
15511
+ if (onZoomComplete) {
15512
+ onZoomComplete();
15513
+ }
15578
15514
  }
15579
15515
  function addDebouncedHandler(chart2, name, handler, delay) {
15580
15516
  if (handler) {
@@ -15654,19 +15590,13 @@ function handlePinch(chart2, state, e2) {
15654
15590
  y: center.y - rect.top
15655
15591
  }
15656
15592
  };
15657
- zoom(chart2, amount, "zoom", "pinch");
15593
+ zoom(chart2, amount);
15658
15594
  state.scale = e2.scale;
15659
15595
  }
15660
15596
  }
15661
- function startPinch(chart2, state, event) {
15597
+ function startPinch(chart2, state) {
15662
15598
  if (state.options.zoom.pinch.enabled) {
15663
- const point = getRelativePosition$2(event, chart2);
15664
- if (callback$1(state.options.zoom.onZoomStart, [{ chart: chart2, event, point }]) === false) {
15665
- state.scale = null;
15666
- callback$1(state.options.zoom.onZoomRejected, [{ chart: chart2, event }]);
15667
- } else {
15668
- state.scale = 1;
15669
- }
15599
+ state.scale = 1;
15670
15600
  }
15671
15601
  }
15672
15602
  function endPinch(chart2, state, e2) {
@@ -15699,13 +15629,13 @@ function startPan(chart2, state, event) {
15699
15629
  }
15700
15630
  state.panScales = getEnabledScalesByPoint(state.options.pan, point, chart2);
15701
15631
  state.delta = { x: 0, y: 0 };
15632
+ clearTimeout(state.panEndTimeout);
15702
15633
  handlePan(chart2, state, event);
15703
15634
  }
15704
15635
  function endPan(chart2, state) {
15705
15636
  state.delta = null;
15706
15637
  if (state.panning) {
15707
- state.panning = false;
15708
- state.filterNextClick = true;
15638
+ state.panEndTimeout = setTimeout(() => state.panning = false, 500);
15709
15639
  callback$1(state.options.pan.onPanComplete, [{ chart: chart2 }]);
15710
15640
  }
15711
15641
  }
@@ -15717,7 +15647,7 @@ function startHammer(chart2, options) {
15717
15647
  const mc = new Hammer.Manager(canvas2);
15718
15648
  if (zoomOptions && zoomOptions.pinch.enabled) {
15719
15649
  mc.add(new Hammer.Pinch());
15720
- mc.on("pinchstart", (e2) => startPinch(chart2, state, e2));
15650
+ mc.on("pinchstart", () => startPinch(chart2, state));
15721
15651
  mc.on("pinch", (e2) => handlePinch(chart2, state, e2));
15722
15652
  mc.on("pinchend", (e2) => endPinch(chart2, state, e2));
15723
15653
  }
@@ -15745,29 +15675,14 @@ function stopHammer(chart2) {
15745
15675
  hammers.delete(chart2);
15746
15676
  }
15747
15677
  }
15748
- function hammerOptionsChanged(oldOptions, newOptions) {
15749
- var _a2, _b2, _c2, _d2;
15750
- const { pan: oldPan, zoom: oldZoom } = oldOptions;
15751
- const { pan: newPan, zoom: newZoom } = newOptions;
15752
- if (((_b2 = (_a2 = oldZoom == null ? void 0 : oldZoom.zoom) == null ? void 0 : _a2.pinch) == null ? void 0 : _b2.enabled) !== ((_d2 = (_c2 = newZoom == null ? void 0 : newZoom.zoom) == null ? void 0 : _c2.pinch) == null ? void 0 : _d2.enabled)) {
15753
- return true;
15754
- }
15755
- if ((oldPan == null ? void 0 : oldPan.enabled) !== (newPan == null ? void 0 : newPan.enabled)) {
15756
- return true;
15757
- }
15758
- if ((oldPan == null ? void 0 : oldPan.threshold) !== (newPan == null ? void 0 : newPan.threshold)) {
15759
- return true;
15760
- }
15761
- return false;
15762
- }
15763
- var version$2 = "2.2.0";
15678
+ var version$2 = "2.0.1";
15764
15679
  function draw$2(chart2, caller, options) {
15765
15680
  const dragOptions = options.zoom.drag;
15766
15681
  const { dragStart, dragEnd } = getState(chart2);
15767
15682
  if (dragOptions.drawTime !== caller || !dragEnd) {
15768
15683
  return;
15769
15684
  }
15770
- const { left: left2, top: top2, width, height } = computeDragRect(chart2, options.zoom.mode, { dragStart, dragEnd }, dragOptions.maintainAspectRatio);
15685
+ const { left: left2, top: top2, width, height } = computeDragRect(chart2, options.zoom.mode, dragStart, dragEnd);
15771
15686
  const ctx = chart2.ctx;
15772
15687
  ctx.save();
15773
15688
  ctx.beginPath();
@@ -15826,30 +15741,17 @@ var plugin$1 = {
15826
15741
  chart2.resetZoom = (transition) => resetZoom(chart2, transition);
15827
15742
  chart2.getZoomLevel = () => getZoomLevel(chart2);
15828
15743
  chart2.getInitialScaleBounds = () => getInitialScaleBounds(chart2);
15829
- chart2.getZoomedScaleBounds = () => getZoomedScaleBounds(chart2);
15830
15744
  chart2.isZoomedOrPanned = () => isZoomedOrPanned(chart2);
15831
- chart2.isZoomingOrPanning = () => isZoomingOrPanning(chart2);
15832
15745
  },
15833
- beforeEvent(chart2, { event }) {
15834
- if (isZoomingOrPanning(chart2)) {
15746
+ beforeEvent(chart2) {
15747
+ const state = getState(chart2);
15748
+ if (state.panning || state.dragging) {
15835
15749
  return false;
15836
15750
  }
15837
- if (event.type === "click" || event.type === "mouseup") {
15838
- const state = getState(chart2);
15839
- if (state.filterNextClick) {
15840
- state.filterNextClick = false;
15841
- return false;
15842
- }
15843
- }
15844
15751
  },
15845
15752
  beforeUpdate: function(chart2, args, options) {
15846
15753
  const state = getState(chart2);
15847
- const previousOptions = state.options;
15848
15754
  state.options = options;
15849
- if (hammerOptionsChanged(previousOptions, options)) {
15850
- stopHammer(chart2);
15851
- startHammer(chart2, options);
15852
- }
15853
15755
  addListeners(chart2, options);
15854
15756
  },
15855
15757
  beforeDatasetsDraw(chart2, _args, options) {
@@ -17363,6 +17265,7 @@ function drawPointStyle(ctx, { x: x2, y: y2, radius, rotation, style, rad }) {
17363
17265
  let xOffset, yOffset, size, cornerRadius;
17364
17266
  ctx.beginPath();
17365
17267
  switch (style) {
17268
+ // Default includes circle
17366
17269
  default:
17367
17270
  ctx.arc(x2, y2, radius, 0, TAU$1);
17368
17271
  ctx.closePath();
@@ -17393,6 +17296,7 @@ function drawPointStyle(ctx, { x: x2, y: y2, radius, rotation, style, rad }) {
17393
17296
  break;
17394
17297
  }
17395
17298
  rad += QUARTER_PI$1;
17299
+ /* falls through */
17396
17300
  case "rectRot":
17397
17301
  xOffset = Math.cos(rad) * radius;
17398
17302
  yOffset = Math.sin(rad) * radius;
@@ -17404,6 +17308,7 @@ function drawPointStyle(ctx, { x: x2, y: y2, radius, rotation, style, rad }) {
17404
17308
  break;
17405
17309
  case "crossRot":
17406
17310
  rad += QUARTER_PI$1;
17311
+ /* falls through */
17407
17312
  case "cross":
17408
17313
  xOffset = Math.cos(rad) * radius;
17409
17314
  yOffset = Math.sin(rad) * radius;
@@ -20784,35 +20689,43 @@ function createSingletonDndContext(backend, context = getGlobalContext(), option
20784
20689
  function getGlobalContext() {
20785
20690
  return typeof global !== "undefined" ? global : window;
20786
20691
  }
20787
- var fastDeepEqual = function equal(a2, b2) {
20788
- if (a2 === b2) return true;
20789
- if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
20790
- if (a2.constructor !== b2.constructor) return false;
20791
- var length, i2, keys;
20792
- if (Array.isArray(a2)) {
20793
- length = a2.length;
20794
- if (length != b2.length) return false;
20692
+ var fastDeepEqual;
20693
+ var hasRequiredFastDeepEqual;
20694
+ function requireFastDeepEqual() {
20695
+ if (hasRequiredFastDeepEqual) return fastDeepEqual;
20696
+ hasRequiredFastDeepEqual = 1;
20697
+ fastDeepEqual = function equal(a2, b2) {
20698
+ if (a2 === b2) return true;
20699
+ if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
20700
+ if (a2.constructor !== b2.constructor) return false;
20701
+ var length, i2, keys;
20702
+ if (Array.isArray(a2)) {
20703
+ length = a2.length;
20704
+ if (length != b2.length) return false;
20705
+ for (i2 = length; i2-- !== 0; )
20706
+ if (!equal(a2[i2], b2[i2])) return false;
20707
+ return true;
20708
+ }
20709
+ if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
20710
+ if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
20711
+ if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
20712
+ keys = Object.keys(a2);
20713
+ length = keys.length;
20714
+ if (length !== Object.keys(b2).length) return false;
20795
20715
  for (i2 = length; i2-- !== 0; )
20796
- if (!equal(a2[i2], b2[i2])) return false;
20716
+ if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
20717
+ for (i2 = length; i2-- !== 0; ) {
20718
+ var key = keys[i2];
20719
+ if (!equal(a2[key], b2[key])) return false;
20720
+ }
20797
20721
  return true;
20798
20722
  }
20799
- if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
20800
- if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
20801
- if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
20802
- keys = Object.keys(a2);
20803
- length = keys.length;
20804
- if (length !== Object.keys(b2).length) return false;
20805
- for (i2 = length; i2-- !== 0; )
20806
- if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
20807
- for (i2 = length; i2-- !== 0; ) {
20808
- var key = keys[i2];
20809
- if (!equal(a2[key], b2[key])) return false;
20810
- }
20811
- return true;
20812
- }
20813
- return a2 !== a2 && b2 !== b2;
20814
- };
20815
- const isEqual = /* @__PURE__ */ getDefaultExportFromCjs(fastDeepEqual);
20723
+ return a2 !== a2 && b2 !== b2;
20724
+ };
20725
+ return fastDeepEqual;
20726
+ }
20727
+ var fastDeepEqualExports = requireFastDeepEqual();
20728
+ const isEqual = /* @__PURE__ */ getDefaultExportFromCjs(fastDeepEqualExports);
20816
20729
  const useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? useLayoutEffect : useEffect;
20817
20730
  function useCollector(monitor, collect, onUpdate) {
20818
20731
  const [collected, setCollected] = useState(
@@ -23500,6 +23413,18 @@ function toArray(arrayLike) {
23500
23413
  }
23501
23414
  return arr;
23502
23415
  }
23416
+ let styleProps = null;
23417
+ function getStyleProperties(options = {}) {
23418
+ if (styleProps) {
23419
+ return styleProps;
23420
+ }
23421
+ if (options.includeStyleProperties) {
23422
+ styleProps = options.includeStyleProperties;
23423
+ return styleProps;
23424
+ }
23425
+ styleProps = toArray(window.getComputedStyle(document.documentElement));
23426
+ return styleProps;
23427
+ }
23503
23428
  function px(node, styleProperty) {
23504
23429
  const win = node.ownerDocument.defaultView || window;
23505
23430
  const val = win.getComputedStyle(node).getPropertyValue(styleProperty);
@@ -23601,19 +23526,19 @@ function formatCSSText(style) {
23601
23526
  const content = style.getPropertyValue("content");
23602
23527
  return `${style.cssText} content: '${content.replace(/'|"/g, "")}';`;
23603
23528
  }
23604
- function formatCSSProperties(style) {
23605
- return toArray(style).map((name) => {
23529
+ function formatCSSProperties(style, options) {
23530
+ return getStyleProperties(options).map((name) => {
23606
23531
  const value = style.getPropertyValue(name);
23607
23532
  const priority = style.getPropertyPriority(name);
23608
23533
  return `${name}: ${value}${priority ? " !important" : ""};`;
23609
23534
  }).join(" ");
23610
23535
  }
23611
- function getPseudoElementStyle(className, pseudo, style) {
23536
+ function getPseudoElementStyle(className, pseudo, style, options) {
23612
23537
  const selector = `.${className}:${pseudo}`;
23613
- const cssText = style.cssText ? formatCSSText(style) : formatCSSProperties(style);
23538
+ const cssText = style.cssText ? formatCSSText(style) : formatCSSProperties(style, options);
23614
23539
  return document.createTextNode(`${selector}{${cssText}}`);
23615
23540
  }
23616
- function clonePseudoElement(nativeNode, clonedNode, pseudo) {
23541
+ function clonePseudoElement(nativeNode, clonedNode, pseudo, options) {
23617
23542
  const style = window.getComputedStyle(nativeNode, pseudo);
23618
23543
  const content = style.getPropertyValue("content");
23619
23544
  if (content === "" || content === "none") {
@@ -23626,12 +23551,12 @@ function clonePseudoElement(nativeNode, clonedNode, pseudo) {
23626
23551
  return;
23627
23552
  }
23628
23553
  const styleElement = document.createElement("style");
23629
- styleElement.appendChild(getPseudoElementStyle(className, pseudo, style));
23554
+ styleElement.appendChild(getPseudoElementStyle(className, pseudo, style, options));
23630
23555
  clonedNode.appendChild(styleElement);
23631
23556
  }
23632
- function clonePseudoElements(nativeNode, clonedNode) {
23633
- clonePseudoElement(nativeNode, clonedNode, ":before");
23634
- clonePseudoElement(nativeNode, clonedNode, ":after");
23557
+ function clonePseudoElements(nativeNode, clonedNode, options) {
23558
+ clonePseudoElement(nativeNode, clonedNode, ":before", options);
23559
+ clonePseudoElement(nativeNode, clonedNode, ":after", options);
23635
23560
  }
23636
23561
  const WOFF = "application/font-woff";
23637
23562
  const JPEG = "image/jpeg";
@@ -23747,11 +23672,11 @@ async function cloneVideoElement(video, options) {
23747
23672
  const dataURL = await resourceToDataURL(poster, contentType, options);
23748
23673
  return createImage(dataURL);
23749
23674
  }
23750
- async function cloneIFrameElement(iframe) {
23675
+ async function cloneIFrameElement(iframe, options) {
23751
23676
  var _a2;
23752
23677
  try {
23753
23678
  if ((_a2 = iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) === null || _a2 === void 0 ? void 0 : _a2.body) {
23754
- return await cloneNode(iframe.contentDocument.body, {}, true);
23679
+ return await cloneNode(iframe.contentDocument.body, options, true);
23755
23680
  }
23756
23681
  } catch (_b2) {
23757
23682
  }
@@ -23765,7 +23690,7 @@ async function cloneSingleNode(node, options) {
23765
23690
  return cloneVideoElement(node, options);
23766
23691
  }
23767
23692
  if (isInstanceOfElement(node, HTMLIFrameElement)) {
23768
- return cloneIFrameElement(node);
23693
+ return cloneIFrameElement(node, options);
23769
23694
  }
23770
23695
  return node.cloneNode(isSVGElement(node));
23771
23696
  }
@@ -23794,7 +23719,7 @@ async function cloneChildren(nativeNode, clonedNode, options) {
23794
23719
  }), Promise.resolve());
23795
23720
  return clonedNode;
23796
23721
  }
23797
- function cloneCSSStyle(nativeNode, clonedNode) {
23722
+ function cloneCSSStyle(nativeNode, clonedNode, options) {
23798
23723
  const targetStyle = clonedNode.style;
23799
23724
  if (!targetStyle) {
23800
23725
  return;
@@ -23804,7 +23729,7 @@ function cloneCSSStyle(nativeNode, clonedNode) {
23804
23729
  targetStyle.cssText = sourceStyle.cssText;
23805
23730
  targetStyle.transformOrigin = sourceStyle.transformOrigin;
23806
23731
  } else {
23807
- toArray(sourceStyle).forEach((name) => {
23732
+ getStyleProperties(options).forEach((name) => {
23808
23733
  let value = sourceStyle.getPropertyValue(name);
23809
23734
  if (name === "font-size" && value.endsWith("px")) {
23810
23735
  const reducedFont = Math.floor(parseFloat(value.substring(0, value.length - 2))) - 0.1;
@@ -23837,10 +23762,10 @@ function cloneSelectValue(nativeNode, clonedNode) {
23837
23762
  }
23838
23763
  }
23839
23764
  }
23840
- function decorate(nativeNode, clonedNode) {
23765
+ function decorate(nativeNode, clonedNode, options) {
23841
23766
  if (isInstanceOfElement(clonedNode, Element)) {
23842
- cloneCSSStyle(nativeNode, clonedNode);
23843
- clonePseudoElements(nativeNode, clonedNode);
23767
+ cloneCSSStyle(nativeNode, clonedNode, options);
23768
+ clonePseudoElements(nativeNode, clonedNode, options);
23844
23769
  cloneInputValue(nativeNode, clonedNode);
23845
23770
  cloneSelectValue(nativeNode, clonedNode);
23846
23771
  }
@@ -23886,7 +23811,7 @@ async function cloneNode(node, options, isRoot) {
23886
23811
  if (!isRoot && options.filter && !options.filter(node)) {
23887
23812
  return null;
23888
23813
  }
23889
- return Promise.resolve(node).then((clonedNode) => cloneSingleNode(clonedNode, options)).then((clonedNode) => cloneChildren(node, clonedNode, options)).then((clonedNode) => decorate(node, clonedNode)).then((clonedNode) => ensureSVGSymbols(clonedNode, options));
23814
+ return Promise.resolve(node).then((clonedNode) => cloneSingleNode(clonedNode, options)).then((clonedNode) => cloneChildren(node, clonedNode, options)).then((clonedNode) => decorate(node, clonedNode, options)).then((clonedNode) => ensureSVGSymbols(clonedNode, options));
23890
23815
  }
23891
23816
  const URL_REGEX = /url\((['"]?)([^'"]+?)\1\)/g;
23892
23817
  const URL_WITH_FORMAT_REGEX = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g;
@@ -23952,12 +23877,8 @@ async function embedProp(propName, node, options) {
23952
23877
  return false;
23953
23878
  }
23954
23879
  async function embedBackground(clonedNode, options) {
23955
- if (!await embedProp("background", clonedNode, options)) {
23956
- await embedProp("background-image", clonedNode, options);
23957
- }
23958
- if (!await embedProp("mask", clonedNode, options)) {
23959
- await embedProp("mask-image", clonedNode, options);
23960
- }
23880
+ await embedProp("background", clonedNode, options) || await embedProp("background-image", clonedNode, options);
23881
+ await embedProp("mask", clonedNode, options) || await embedProp("-webkit-mask", clonedNode, options) || await embedProp("mask-image", clonedNode, options) || await embedProp("-webkit-mask-image", clonedNode, options);
23961
23882
  }
23962
23883
  async function embedImageNode(clonedNode, options) {
23963
23884
  const isImageElement = isInstanceOfElement(clonedNode, HTMLImageElement);
@@ -24113,7 +24034,7 @@ async function getCSSRules(styleSheets, options) {
24113
24034
  const inline = styleSheets.find((a2) => a2.href == null) || document.styleSheets[0];
24114
24035
  if (sheet.href != null) {
24115
24036
  deferreds.push(fetchCSS(sheet.href).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
24116
- inline.insertRule(rule, sheet.cssRules.length);
24037
+ inline.insertRule(rule, inline.cssRules.length);
24117
24038
  })).catch((err) => {
24118
24039
  console.error("Error loading remote stylesheet", err);
24119
24040
  }));
@@ -24226,200 +24147,206 @@ async function toPng(node, options = {}) {
24226
24147
  return canvas2.toDataURL();
24227
24148
  }
24228
24149
  var dist = { exports: {} };
24229
- (function(module, exports) {
24230
- !function(e2, t) {
24231
- module.exports = t(React__default);
24232
- }(window, function(e2) {
24233
- return function(e3) {
24234
- var t = {};
24235
- function n2(o2) {
24236
- if (t[o2]) return t[o2].exports;
24237
- var r2 = t[o2] = { i: o2, l: false, exports: {} };
24238
- return e3[o2].call(r2.exports, r2, r2.exports, n2), r2.l = true, r2.exports;
24239
- }
24240
- return n2.m = e3, n2.c = t, n2.d = function(e4, t2, o2) {
24241
- n2.o(e4, t2) || Object.defineProperty(e4, t2, { enumerable: true, get: o2 });
24242
- }, n2.r = function(e4) {
24243
- "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e4, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e4, "__esModule", { value: true });
24244
- }, n2.t = function(e4, t2) {
24245
- if (1 & t2 && (e4 = n2(e4)), 8 & t2) return e4;
24246
- if (4 & t2 && "object" == typeof e4 && e4 && e4.__esModule) return e4;
24247
- var o2 = /* @__PURE__ */ Object.create(null);
24248
- if (n2.r(o2), Object.defineProperty(o2, "default", { enumerable: true, value: e4 }), 2 & t2 && "string" != typeof e4) for (var r2 in e4) n2.d(o2, r2, (function(t3) {
24249
- return e4[t3];
24250
- }).bind(null, r2));
24251
- return o2;
24252
- }, n2.n = function(e4) {
24253
- var t2 = e4 && e4.__esModule ? function() {
24254
- return e4.default;
24255
- } : function() {
24256
- return e4;
24257
- };
24258
- return n2.d(t2, "a", t2), t2;
24259
- }, n2.o = function(e4, t2) {
24260
- return Object.prototype.hasOwnProperty.call(e4, t2);
24261
- }, n2.p = "/dist/", n2(n2.s = 4);
24262
- }([function(e3, t, n2) {
24263
- e3.exports = n2(5)();
24264
- }, function(t, n2) {
24265
- t.exports = e2;
24266
- }, function(e3, t, n2) {
24267
- (function(n3) {
24150
+ var hasRequiredDist;
24151
+ function requireDist() {
24152
+ if (hasRequiredDist) return dist.exports;
24153
+ hasRequiredDist = 1;
24154
+ (function(module, exports) {
24155
+ !function(e2, t) {
24156
+ module.exports = t(React__default);
24157
+ }(window, function(e2) {
24158
+ return function(e3) {
24159
+ var t = {};
24160
+ function n2(o2) {
24161
+ if (t[o2]) return t[o2].exports;
24162
+ var r2 = t[o2] = { i: o2, l: false, exports: {} };
24163
+ return e3[o2].call(r2.exports, r2, r2.exports, n2), r2.l = true, r2.exports;
24164
+ }
24165
+ return n2.m = e3, n2.c = t, n2.d = function(e4, t2, o2) {
24166
+ n2.o(e4, t2) || Object.defineProperty(e4, t2, { enumerable: true, get: o2 });
24167
+ }, n2.r = function(e4) {
24168
+ "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e4, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e4, "__esModule", { value: true });
24169
+ }, n2.t = function(e4, t2) {
24170
+ if (1 & t2 && (e4 = n2(e4)), 8 & t2) return e4;
24171
+ if (4 & t2 && "object" == typeof e4 && e4 && e4.__esModule) return e4;
24172
+ var o2 = /* @__PURE__ */ Object.create(null);
24173
+ if (n2.r(o2), Object.defineProperty(o2, "default", { enumerable: true, value: e4 }), 2 & t2 && "string" != typeof e4) for (var r2 in e4) n2.d(o2, r2, (function(t3) {
24174
+ return e4[t3];
24175
+ }).bind(null, r2));
24176
+ return o2;
24177
+ }, n2.n = function(e4) {
24178
+ var t2 = e4 && e4.__esModule ? function() {
24179
+ return e4.default;
24180
+ } : function() {
24181
+ return e4;
24182
+ };
24183
+ return n2.d(t2, "a", t2), t2;
24184
+ }, n2.o = function(e4, t2) {
24185
+ return Object.prototype.hasOwnProperty.call(e4, t2);
24186
+ }, n2.p = "/dist/", n2(n2.s = 4);
24187
+ }([function(e3, t, n2) {
24188
+ e3.exports = n2(5)();
24189
+ }, function(t, n2) {
24190
+ t.exports = e2;
24191
+ }, function(e3, t, n2) {
24192
+ (function(n3) {
24193
+ var o2, r2, a2;
24194
+ r2 = [], void 0 === (a2 = "function" == typeof (o2 = function() {
24195
+ function t2(e4, t3, n4) {
24196
+ var o4 = new XMLHttpRequest();
24197
+ o4.open("GET", e4), o4.responseType = "blob", o4.onload = function() {
24198
+ c2(o4.response, t3, n4);
24199
+ }, o4.onerror = function() {
24200
+ console.error("could not download file");
24201
+ }, o4.send();
24202
+ }
24203
+ function o3(e4) {
24204
+ var t3 = new XMLHttpRequest();
24205
+ t3.open("HEAD", e4, false);
24206
+ try {
24207
+ t3.send();
24208
+ } catch (e5) {
24209
+ }
24210
+ return 200 <= t3.status && 299 >= t3.status;
24211
+ }
24212
+ function r3(e4) {
24213
+ try {
24214
+ e4.dispatchEvent(new MouseEvent("click"));
24215
+ } catch (n4) {
24216
+ var t3 = document.createEvent("MouseEvents");
24217
+ t3.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null), e4.dispatchEvent(t3);
24218
+ }
24219
+ }
24220
+ var a3 = "object" == typeof window && window.window === window ? window : "object" == typeof self && self.self === self ? self : "object" == typeof n3 && n3.global === n3 ? n3 : void 0, i2 = a3.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent), c2 = a3.saveAs || ("object" != typeof window || window !== a3 ? function() {
24221
+ } : "download" in HTMLAnchorElement.prototype && !i2 ? function(e4, n4, i3) {
24222
+ var c3 = a3.URL || a3.webkitURL, s2 = document.createElement("a");
24223
+ n4 = n4 || e4.name || "download", s2.download = n4, s2.rel = "noopener", "string" == typeof e4 ? (s2.href = e4, s2.origin === location.origin ? r3(s2) : o3(s2.href) ? t2(e4, n4, i3) : r3(s2, s2.target = "_blank")) : (s2.href = c3.createObjectURL(e4), setTimeout(function() {
24224
+ c3.revokeObjectURL(s2.href);
24225
+ }, 4e4), setTimeout(function() {
24226
+ r3(s2);
24227
+ }, 0));
24228
+ } : "msSaveOrOpenBlob" in navigator ? function(e4, n4, a4) {
24229
+ if (n4 = n4 || e4.name || "download", "string" != typeof e4) navigator.msSaveOrOpenBlob(function(e5, t3) {
24230
+ return void 0 === t3 ? t3 = { autoBom: false } : "object" != typeof t3 && (console.warn("Deprecated: Expected third argument to be a object"), t3 = { autoBom: !t3 }), t3.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e5.type) ? new Blob(["\uFEFF", e5], { type: e5.type }) : e5;
24231
+ }(e4, a4), n4);
24232
+ else if (o3(e4)) t2(e4, n4, a4);
24233
+ else {
24234
+ var i3 = document.createElement("a");
24235
+ i3.href = e4, i3.target = "_blank", setTimeout(function() {
24236
+ r3(i3);
24237
+ });
24238
+ }
24239
+ } : function(e4, n4, o4, r4) {
24240
+ if ((r4 = r4 || open("", "_blank")) && (r4.document.title = r4.document.body.innerText = "downloading..."), "string" == typeof e4) return t2(e4, n4, o4);
24241
+ var c3 = "application/octet-stream" === e4.type, s2 = /constructor/i.test(a3.HTMLElement) || a3.safari, u2 = /CriOS\/[\d]+/.test(navigator.userAgent);
24242
+ if ((u2 || c3 && s2 || i2) && "undefined" != typeof FileReader) {
24243
+ var l2 = new FileReader();
24244
+ l2.onloadend = function() {
24245
+ var e5 = l2.result;
24246
+ e5 = u2 ? e5 : e5.replace(/^data:[^;]*;/, "data:attachment/file;"), r4 ? r4.location.href = e5 : location = e5, r4 = null;
24247
+ }, l2.readAsDataURL(e4);
24248
+ } else {
24249
+ var f2 = a3.URL || a3.webkitURL, p2 = f2.createObjectURL(e4);
24250
+ r4 ? r4.location = p2 : location.href = p2, r4 = null, setTimeout(function() {
24251
+ f2.revokeObjectURL(p2);
24252
+ }, 4e4);
24253
+ }
24254
+ });
24255
+ a3.saveAs = c2.saveAs = c2, e3.exports = c2;
24256
+ }) ? o2.apply(t, r2) : o2) || (e3.exports = a2);
24257
+ }).call(this, n2(7));
24258
+ }, function(e3, t, n2) {
24268
24259
  var o2, r2, a2;
24269
24260
  r2 = [], void 0 === (a2 = "function" == typeof (o2 = function() {
24270
- function t2(e4, t3, n4) {
24271
- var o4 = new XMLHttpRequest();
24272
- o4.open("GET", e4), o4.responseType = "blob", o4.onload = function() {
24273
- c2(o4.response, t3, n4);
24274
- }, o4.onerror = function() {
24275
- console.error("could not download file");
24276
- }, o4.send();
24277
- }
24278
- function o3(e4) {
24279
- var t3 = new XMLHttpRequest();
24280
- t3.open("HEAD", e4, false);
24261
+ return function(e4, t2, n3) {
24262
+ t2 = t2 || "", n3 = n3 || 512;
24263
+ for (var o3 = atob(e4), r3 = [], a3 = 0; a3 < o3.length; a3 += n3) {
24264
+ for (var i2 = o3.slice(a3, a3 + n3), c2 = new Array(i2.length), s2 = 0; s2 < i2.length; s2++) c2[s2] = i2.charCodeAt(s2);
24265
+ var u2 = new Uint8Array(c2);
24266
+ r3.push(u2);
24267
+ }
24268
+ return new Blob(r3, { type: t2 });
24269
+ };
24270
+ }) ? o2.apply(t, r2) : o2) || (e3.exports = a2);
24271
+ }, function(e3, t, n2) {
24272
+ n2.r(t), n2.d(t, "defaultDownloadName", function() {
24273
+ return p2;
24274
+ }), n2.d(t, "triggerBase64Download", function() {
24275
+ return y2;
24276
+ }), n2.d(t, "getExtFromBase64", function() {
24277
+ return b2;
24278
+ });
24279
+ var o2 = n2(1), r2 = n2.n(o2), a2 = n2(0), i2 = n2.n(a2), c2 = n2(2), s2 = n2(3);
24280
+ function u2() {
24281
+ return (u2 = Object.assign || function(e4) {
24282
+ for (var t2 = 1; t2 < arguments.length; t2++) {
24283
+ var n3 = arguments[t2];
24284
+ for (var o3 in n3) Object.prototype.hasOwnProperty.call(n3, o3) && (e4[o3] = n3[o3]);
24285
+ }
24286
+ return e4;
24287
+ }).apply(this, arguments);
24288
+ }
24289
+ var l2 = { png: "image/png", jpeg: "image/jpeg", jpg: "image/jpg" }, f2 = { png: "data:".concat(l2.png, ";base64"), jpeg: "data:".concat(l2.jpeg, ";base64"), jpg: "data:".concat(l2.jpg, ";base64") }, p2 = "download", d2 = function(e4) {
24290
+ var t2 = e4.base64, n3 = e4.children, o3 = e4.downloadName, a3 = e4.onDownloadSuccess, i3 = e4.onDownloadError, c3 = e4.Tag, s3 = e4.className, l3 = e4.style, f3 = e4.extraAttributes;
24291
+ return r2.a.createElement(c3, u2({}, f3, { onClick: function() {
24281
24292
  try {
24282
- t3.send();
24293
+ y2(t2, o3), a3 && a3({ base64: t2 });
24283
24294
  } catch (e5) {
24295
+ console.error(e5), i3 && i3(e5);
24284
24296
  }
24285
- return 200 <= t3.status && 299 >= t3.status;
24286
- }
24287
- function r3(e4) {
24288
- try {
24289
- e4.dispatchEvent(new MouseEvent("click"));
24290
- } catch (n4) {
24291
- var t3 = document.createEvent("MouseEvents");
24292
- t3.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null), e4.dispatchEvent(t3);
24297
+ }, className: s3, style: l3 }), n3);
24298
+ };
24299
+ function y2(e4) {
24300
+ var t2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : p2, n3 = b2(e4), o3 = f2[n3], r3 = l2[n3], a3 = e4.replace("".concat(o3, ","), ""), i3 = s2(a3, r3), u3 = new File([i3], "".concat(t2, ".").concat(n3), { type: o3 });
24301
+ c2.saveAs(u3);
24302
+ }
24303
+ function b2(e4) {
24304
+ var t2;
24305
+ if ("string" == typeof e4 && (t2 = Object.keys(f2).find(function(t3) {
24306
+ return 0 === e4.indexOf(f2[t3]);
24307
+ })), t2) return t2;
24308
+ throw new Error("props.base64 on <Base64Downloader/> has invalid or undefined extension. expected ".concat(Object.keys(l2).join(", ")));
24309
+ }
24310
+ d2.defaultProps = { className: "", style: {}, downloadName: p2, Tag: "button", extraAttributes: {} }, d2.propTypes = { base64: i2.a.string.isRequired, children: i2.a.oneOfType([i2.a.node, i2.a.string]).isRequired, downloadName: i2.a.string, onDownloadSuccess: i2.a.func, onDownloadError: i2.a.func, Tag: i2.a.string, className: i2.a.string, style: i2.a.object, extraAttributes: i2.a.object }, t.default = d2;
24311
+ }, function(e3, t, n2) {
24312
+ var o2 = n2(6);
24313
+ function r2() {
24314
+ }
24315
+ function a2() {
24316
+ }
24317
+ a2.resetWarningCache = r2, e3.exports = function() {
24318
+ function e4(e5, t3, n4, r3, a3, i2) {
24319
+ if (i2 !== o2) {
24320
+ var c2 = new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");
24321
+ throw c2.name = "Invariant Violation", c2;
24293
24322
  }
24294
24323
  }
24295
- var a3 = "object" == typeof window && window.window === window ? window : "object" == typeof self && self.self === self ? self : "object" == typeof n3 && n3.global === n3 ? n3 : void 0, i2 = a3.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent), c2 = a3.saveAs || ("object" != typeof window || window !== a3 ? function() {
24296
- } : "download" in HTMLAnchorElement.prototype && !i2 ? function(e4, n4, i3) {
24297
- var c3 = a3.URL || a3.webkitURL, s2 = document.createElement("a");
24298
- n4 = n4 || e4.name || "download", s2.download = n4, s2.rel = "noopener", "string" == typeof e4 ? (s2.href = e4, s2.origin === location.origin ? r3(s2) : o3(s2.href) ? t2(e4, n4, i3) : r3(s2, s2.target = "_blank")) : (s2.href = c3.createObjectURL(e4), setTimeout(function() {
24299
- c3.revokeObjectURL(s2.href);
24300
- }, 4e4), setTimeout(function() {
24301
- r3(s2);
24302
- }, 0));
24303
- } : "msSaveOrOpenBlob" in navigator ? function(e4, n4, a4) {
24304
- if (n4 = n4 || e4.name || "download", "string" != typeof e4) navigator.msSaveOrOpenBlob(function(e5, t3) {
24305
- return void 0 === t3 ? t3 = { autoBom: false } : "object" != typeof t3 && (console.warn("Deprecated: Expected third argument to be a object"), t3 = { autoBom: !t3 }), t3.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e5.type) ? new Blob(["\uFEFF", e5], { type: e5.type }) : e5;
24306
- }(e4, a4), n4);
24307
- else if (o3(e4)) t2(e4, n4, a4);
24308
- else {
24309
- var i3 = document.createElement("a");
24310
- i3.href = e4, i3.target = "_blank", setTimeout(function() {
24311
- r3(i3);
24312
- });
24313
- }
24314
- } : function(e4, n4, o4, r4) {
24315
- if ((r4 = r4 || open("", "_blank")) && (r4.document.title = r4.document.body.innerText = "downloading..."), "string" == typeof e4) return t2(e4, n4, o4);
24316
- var c3 = "application/octet-stream" === e4.type, s2 = /constructor/i.test(a3.HTMLElement) || a3.safari, u2 = /CriOS\/[\d]+/.test(navigator.userAgent);
24317
- if ((u2 || c3 && s2 || i2) && "undefined" != typeof FileReader) {
24318
- var l2 = new FileReader();
24319
- l2.onloadend = function() {
24320
- var e5 = l2.result;
24321
- e5 = u2 ? e5 : e5.replace(/^data:[^;]*;/, "data:attachment/file;"), r4 ? r4.location.href = e5 : location = e5, r4 = null;
24322
- }, l2.readAsDataURL(e4);
24323
- } else {
24324
- var f2 = a3.URL || a3.webkitURL, p2 = f2.createObjectURL(e4);
24325
- r4 ? r4.location = p2 : location.href = p2, r4 = null, setTimeout(function() {
24326
- f2.revokeObjectURL(p2);
24327
- }, 4e4);
24328
- }
24329
- });
24330
- a3.saveAs = c2.saveAs = c2, e3.exports = c2;
24331
- }) ? o2.apply(t, r2) : o2) || (e3.exports = a2);
24332
- }).call(this, n2(7));
24333
- }, function(e3, t, n2) {
24334
- var o2, r2, a2;
24335
- r2 = [], void 0 === (a2 = "function" == typeof (o2 = function() {
24336
- return function(e4, t2, n3) {
24337
- t2 = t2 || "", n3 = n3 || 512;
24338
- for (var o3 = atob(e4), r3 = [], a3 = 0; a3 < o3.length; a3 += n3) {
24339
- for (var i2 = o3.slice(a3, a3 + n3), c2 = new Array(i2.length), s2 = 0; s2 < i2.length; s2++) c2[s2] = i2.charCodeAt(s2);
24340
- var u2 = new Uint8Array(c2);
24341
- r3.push(u2);
24324
+ function t2() {
24325
+ return e4;
24342
24326
  }
24343
- return new Blob(r3, { type: t2 });
24327
+ e4.isRequired = e4;
24328
+ var n3 = { array: e4, bool: e4, func: e4, number: e4, object: e4, string: e4, symbol: e4, any: e4, arrayOf: t2, element: e4, elementType: e4, instanceOf: t2, node: e4, objectOf: t2, oneOf: t2, oneOfType: t2, shape: t2, exact: t2, checkPropTypes: a2, resetWarningCache: r2 };
24329
+ return n3.PropTypes = n3, n3;
24344
24330
  };
24345
- }) ? o2.apply(t, r2) : o2) || (e3.exports = a2);
24346
- }, function(e3, t, n2) {
24347
- n2.r(t), n2.d(t, "defaultDownloadName", function() {
24348
- return p2;
24349
- }), n2.d(t, "triggerBase64Download", function() {
24350
- return y2;
24351
- }), n2.d(t, "getExtFromBase64", function() {
24352
- return b2;
24353
- });
24354
- var o2 = n2(1), r2 = n2.n(o2), a2 = n2(0), i2 = n2.n(a2), c2 = n2(2), s2 = n2(3);
24355
- function u2() {
24356
- return (u2 = Object.assign || function(e4) {
24357
- for (var t2 = 1; t2 < arguments.length; t2++) {
24358
- var n3 = arguments[t2];
24359
- for (var o3 in n3) Object.prototype.hasOwnProperty.call(n3, o3) && (e4[o3] = n3[o3]);
24360
- }
24361
- return e4;
24362
- }).apply(this, arguments);
24363
- }
24364
- var l2 = { png: "image/png", jpeg: "image/jpeg", jpg: "image/jpg" }, f2 = { png: "data:".concat(l2.png, ";base64"), jpeg: "data:".concat(l2.jpeg, ";base64"), jpg: "data:".concat(l2.jpg, ";base64") }, p2 = "download", d2 = function(e4) {
24365
- var t2 = e4.base64, n3 = e4.children, o3 = e4.downloadName, a3 = e4.onDownloadSuccess, i3 = e4.onDownloadError, c3 = e4.Tag, s3 = e4.className, l3 = e4.style, f3 = e4.extraAttributes;
24366
- return r2.a.createElement(c3, u2({}, f3, { onClick: function() {
24367
- try {
24368
- y2(t2, o3), a3 && a3({ base64: t2 });
24369
- } catch (e5) {
24370
- console.error(e5), i3 && i3(e5);
24371
- }
24372
- }, className: s3, style: l3 }), n3);
24373
- };
24374
- function y2(e4) {
24375
- var t2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : p2, n3 = b2(e4), o3 = f2[n3], r3 = l2[n3], a3 = e4.replace("".concat(o3, ","), ""), i3 = s2(a3, r3), u3 = new File([i3], "".concat(t2, ".").concat(n3), { type: o3 });
24376
- c2.saveAs(u3);
24377
- }
24378
- function b2(e4) {
24379
- var t2;
24380
- if ("string" == typeof e4 && (t2 = Object.keys(f2).find(function(t3) {
24381
- return 0 === e4.indexOf(f2[t3]);
24382
- })), t2) return t2;
24383
- throw new Error("props.base64 on <Base64Downloader/> has invalid or undefined extension. expected ".concat(Object.keys(l2).join(", ")));
24384
- }
24385
- d2.defaultProps = { className: "", style: {}, downloadName: p2, Tag: "button", extraAttributes: {} }, d2.propTypes = { base64: i2.a.string.isRequired, children: i2.a.oneOfType([i2.a.node, i2.a.string]).isRequired, downloadName: i2.a.string, onDownloadSuccess: i2.a.func, onDownloadError: i2.a.func, Tag: i2.a.string, className: i2.a.string, style: i2.a.object, extraAttributes: i2.a.object }, t.default = d2;
24386
- }, function(e3, t, n2) {
24387
- var o2 = n2(6);
24388
- function r2() {
24389
- }
24390
- function a2() {
24391
- }
24392
- a2.resetWarningCache = r2, e3.exports = function() {
24393
- function e4(e5, t3, n4, r3, a3, i2) {
24394
- if (i2 !== o2) {
24395
- var c2 = new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");
24396
- throw c2.name = "Invariant Violation", c2;
24397
- }
24398
- }
24399
- function t2() {
24400
- return e4;
24331
+ }, function(e3, t, n2) {
24332
+ e3.exports = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
24333
+ }, function(e3, t) {
24334
+ var n2;
24335
+ n2 = /* @__PURE__ */ function() {
24336
+ return this;
24337
+ }();
24338
+ try {
24339
+ n2 = n2 || new Function("return this")();
24340
+ } catch (e4) {
24341
+ "object" == typeof window && (n2 = window);
24401
24342
  }
24402
- e4.isRequired = e4;
24403
- var n3 = { array: e4, bool: e4, func: e4, number: e4, object: e4, string: e4, symbol: e4, any: e4, arrayOf: t2, element: e4, elementType: e4, instanceOf: t2, node: e4, objectOf: t2, oneOf: t2, oneOfType: t2, shape: t2, exact: t2, checkPropTypes: a2, resetWarningCache: r2 };
24404
- return n3.PropTypes = n3, n3;
24405
- };
24406
- }, function(e3, t, n2) {
24407
- e3.exports = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
24408
- }, function(e3, t) {
24409
- var n2;
24410
- n2 = /* @__PURE__ */ function() {
24411
- return this;
24412
- }();
24413
- try {
24414
- n2 = n2 || new Function("return this")();
24415
- } catch (e4) {
24416
- "object" == typeof window && (n2 = window);
24417
- }
24418
- e3.exports = n2;
24419
- }]);
24420
- });
24421
- })(dist);
24422
- var distExports = dist.exports;
24343
+ e3.exports = n2;
24344
+ }]);
24345
+ });
24346
+ })(dist);
24347
+ return dist.exports;
24348
+ }
24349
+ var distExports = requireDist();
24423
24350
  const downloadPgn = (chartRef, state) => {
24424
24351
  var _a2;
24425
24352
  const chart2 = chartRef.current;