You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4390 lines
146 KiB

  1. /**
  2. * SimpleBar.js - v3.1.3
  3. * Scrollbars, simpler.
  4. * https://grsmto.github.io/simplebar/
  5. *
  6. * Made by Adrien Denat from a fork by Jonathan Nicol
  7. * Under MIT License
  8. */
  9. (function (global, factory) {
  10. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  11. typeof define === 'function' && define.amd ? define(factory) :
  12. (global = global || self, global.SimpleBar = factory());
  13. }(this, function () { 'use strict';
  14. var _isObject = function (it) {
  15. return typeof it === 'object' ? it !== null : typeof it === 'function';
  16. };
  17. var _anObject = function (it) {
  18. if (!_isObject(it)) throw TypeError(it + ' is not an object!');
  19. return it;
  20. };
  21. // 7.2.1 RequireObjectCoercible(argument)
  22. var _defined = function (it) {
  23. if (it == undefined) throw TypeError("Can't call method on " + it);
  24. return it;
  25. };
  26. // 7.1.13 ToObject(argument)
  27. var _toObject = function (it) {
  28. return Object(_defined(it));
  29. };
  30. // 7.1.4 ToInteger
  31. var ceil = Math.ceil;
  32. var floor = Math.floor;
  33. var _toInteger = function (it) {
  34. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  35. };
  36. // 7.1.15 ToLength
  37. var min = Math.min;
  38. var _toLength = function (it) {
  39. return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  40. };
  41. // true -> String#at
  42. // false -> String#codePointAt
  43. var _stringAt = function (TO_STRING) {
  44. return function (that, pos) {
  45. var s = String(_defined(that));
  46. var i = _toInteger(pos);
  47. var l = s.length;
  48. var a, b;
  49. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  50. a = s.charCodeAt(i);
  51. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  52. ? TO_STRING ? s.charAt(i) : a
  53. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  54. };
  55. };
  56. var at = _stringAt(true);
  57. // `AdvanceStringIndex` abstract operation
  58. // https://tc39.github.io/ecma262/#sec-advancestringindex
  59. var _advanceStringIndex = function (S, index, unicode) {
  60. return index + (unicode ? at(S, index).length : 1);
  61. };
  62. var toString = {}.toString;
  63. var _cof = function (it) {
  64. return toString.call(it).slice(8, -1);
  65. };
  66. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  67. function createCommonjsModule(fn, module) {
  68. return module = { exports: {} }, fn(module, module.exports), module.exports;
  69. }
  70. var _core = createCommonjsModule(function (module) {
  71. var core = module.exports = { version: '2.6.2' };
  72. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  73. });
  74. var _core_1 = _core.version;
  75. var _global = createCommonjsModule(function (module) {
  76. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  77. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  78. ? window : typeof self != 'undefined' && self.Math == Math ? self
  79. // eslint-disable-next-line no-new-func
  80. : Function('return this')();
  81. if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
  82. });
  83. var _library = false;
  84. var _shared = createCommonjsModule(function (module) {
  85. var SHARED = '__core-js_shared__';
  86. var store = _global[SHARED] || (_global[SHARED] = {});
  87. (module.exports = function (key, value) {
  88. return store[key] || (store[key] = value !== undefined ? value : {});
  89. })('versions', []).push({
  90. version: _core.version,
  91. mode: _library ? 'pure' : 'global',
  92. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  93. });
  94. });
  95. var id = 0;
  96. var px = Math.random();
  97. var _uid = function (key) {
  98. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  99. };
  100. var _wks = createCommonjsModule(function (module) {
  101. var store = _shared('wks');
  102. var Symbol = _global.Symbol;
  103. var USE_SYMBOL = typeof Symbol == 'function';
  104. var $exports = module.exports = function (name) {
  105. return store[name] || (store[name] =
  106. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
  107. };
  108. $exports.store = store;
  109. });
  110. // getting tag from 19.1.3.6 Object.prototype.toString()
  111. var TAG = _wks('toStringTag');
  112. // ES3 wrong here
  113. var ARG = _cof(function () { return arguments; }()) == 'Arguments';
  114. // fallback for IE11 Script Access Denied error
  115. var tryGet = function (it, key) {
  116. try {
  117. return it[key];
  118. } catch (e) { /* empty */ }
  119. };
  120. var _classof = function (it) {
  121. var O, T, B;
  122. return it === undefined ? 'Undefined' : it === null ? 'Null'
  123. // @@toStringTag case
  124. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  125. // builtinTag case
  126. : ARG ? _cof(O)
  127. // ES3 arguments fallback
  128. : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  129. };
  130. var builtinExec = RegExp.prototype.exec;
  131. // `RegExpExec` abstract operation
  132. // https://tc39.github.io/ecma262/#sec-regexpexec
  133. var _regexpExecAbstract = function (R, S) {
  134. var exec = R.exec;
  135. if (typeof exec === 'function') {
  136. var result = exec.call(R, S);
  137. if (typeof result !== 'object') {
  138. throw new TypeError('RegExp exec method returned something other than an Object or null');
  139. }
  140. return result;
  141. }
  142. if (_classof(R) !== 'RegExp') {
  143. throw new TypeError('RegExp#exec called on incompatible receiver');
  144. }
  145. return builtinExec.call(R, S);
  146. };
  147. // 21.2.5.3 get RegExp.prototype.flags
  148. var _flags = function () {
  149. var that = _anObject(this);
  150. var result = '';
  151. if (that.global) result += 'g';
  152. if (that.ignoreCase) result += 'i';
  153. if (that.multiline) result += 'm';
  154. if (that.unicode) result += 'u';
  155. if (that.sticky) result += 'y';
  156. return result;
  157. };
  158. var nativeExec = RegExp.prototype.exec;
  159. // This always refers to the native implementation, because the
  160. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  161. // which loads this file before patching the method.
  162. var nativeReplace = String.prototype.replace;
  163. var patchedExec = nativeExec;
  164. var LAST_INDEX = 'lastIndex';
  165. var UPDATES_LAST_INDEX_WRONG = (function () {
  166. var re1 = /a/,
  167. re2 = /b*/g;
  168. nativeExec.call(re1, 'a');
  169. nativeExec.call(re2, 'a');
  170. return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0;
  171. })();
  172. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  173. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  174. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
  175. if (PATCH) {
  176. patchedExec = function exec(str) {
  177. var re = this;
  178. var lastIndex, reCopy, match, i;
  179. if (NPCG_INCLUDED) {
  180. reCopy = new RegExp('^' + re.source + '$(?!\\s)', _flags.call(re));
  181. }
  182. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX];
  183. match = nativeExec.call(re, str);
  184. if (UPDATES_LAST_INDEX_WRONG && match) {
  185. re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex;
  186. }
  187. if (NPCG_INCLUDED && match && match.length > 1) {
  188. // Fix browsers whose `exec` methods don't consistently return `undefined`
  189. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  190. // eslint-disable-next-line no-loop-func
  191. nativeReplace.call(match[0], reCopy, function () {
  192. for (i = 1; i < arguments.length - 2; i++) {
  193. if (arguments[i] === undefined) match[i] = undefined;
  194. }
  195. });
  196. }
  197. return match;
  198. };
  199. }
  200. var _regexpExec = patchedExec;
  201. var _fails = function (exec) {
  202. try {
  203. return !!exec();
  204. } catch (e) {
  205. return true;
  206. }
  207. };
  208. // Thank's IE8 for his funny defineProperty
  209. var _descriptors = !_fails(function () {
  210. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  211. });
  212. var document$1 = _global.document;
  213. // typeof document.createElement is 'object' in old IE
  214. var is = _isObject(document$1) && _isObject(document$1.createElement);
  215. var _domCreate = function (it) {
  216. return is ? document$1.createElement(it) : {};
  217. };
  218. var _ie8DomDefine = !_descriptors && !_fails(function () {
  219. return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
  220. });
  221. // 7.1.1 ToPrimitive(input [, PreferredType])
  222. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  223. // and the second argument - flag - preferred type is a string
  224. var _toPrimitive = function (it, S) {
  225. if (!_isObject(it)) return it;
  226. var fn, val;
  227. if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
  228. if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
  229. if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
  230. throw TypeError("Can't convert object to primitive value");
  231. };
  232. var dP = Object.defineProperty;
  233. var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  234. _anObject(O);
  235. P = _toPrimitive(P, true);
  236. _anObject(Attributes);
  237. if (_ie8DomDefine) try {
  238. return dP(O, P, Attributes);
  239. } catch (e) { /* empty */ }
  240. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  241. if ('value' in Attributes) O[P] = Attributes.value;
  242. return O;
  243. };
  244. var _objectDp = {
  245. f: f
  246. };
  247. var _propertyDesc = function (bitmap, value) {
  248. return {
  249. enumerable: !(bitmap & 1),
  250. configurable: !(bitmap & 2),
  251. writable: !(bitmap & 4),
  252. value: value
  253. };
  254. };
  255. var _hide = _descriptors ? function (object, key, value) {
  256. return _objectDp.f(object, key, _propertyDesc(1, value));
  257. } : function (object, key, value) {
  258. object[key] = value;
  259. return object;
  260. };
  261. var hasOwnProperty = {}.hasOwnProperty;
  262. var _has = function (it, key) {
  263. return hasOwnProperty.call(it, key);
  264. };
  265. var _redefine = createCommonjsModule(function (module) {
  266. var SRC = _uid('src');
  267. var TO_STRING = 'toString';
  268. var $toString = Function[TO_STRING];
  269. var TPL = ('' + $toString).split(TO_STRING);
  270. _core.inspectSource = function (it) {
  271. return $toString.call(it);
  272. };
  273. (module.exports = function (O, key, val, safe) {
  274. var isFunction = typeof val == 'function';
  275. if (isFunction) _has(val, 'name') || _hide(val, 'name', key);
  276. if (O[key] === val) return;
  277. if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  278. if (O === _global) {
  279. O[key] = val;
  280. } else if (!safe) {
  281. delete O[key];
  282. _hide(O, key, val);
  283. } else if (O[key]) {
  284. O[key] = val;
  285. } else {
  286. _hide(O, key, val);
  287. }
  288. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  289. })(Function.prototype, TO_STRING, function toString() {
  290. return typeof this == 'function' && this[SRC] || $toString.call(this);
  291. });
  292. });
  293. var _aFunction = function (it) {
  294. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  295. return it;
  296. };
  297. // optional / simple context binding
  298. var _ctx = function (fn, that, length) {
  299. _aFunction(fn);
  300. if (that === undefined) return fn;
  301. switch (length) {
  302. case 1: return function (a) {
  303. return fn.call(that, a);
  304. };
  305. case 2: return function (a, b) {
  306. return fn.call(that, a, b);
  307. };
  308. case 3: return function (a, b, c) {
  309. return fn.call(that, a, b, c);
  310. };
  311. }
  312. return function (/* ...args */) {
  313. return fn.apply(that, arguments);
  314. };
  315. };
  316. var PROTOTYPE = 'prototype';
  317. var $export = function (type, name, source) {
  318. var IS_FORCED = type & $export.F;
  319. var IS_GLOBAL = type & $export.G;
  320. var IS_STATIC = type & $export.S;
  321. var IS_PROTO = type & $export.P;
  322. var IS_BIND = type & $export.B;
  323. var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
  324. var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
  325. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  326. var key, own, out, exp;
  327. if (IS_GLOBAL) source = name;
  328. for (key in source) {
  329. // contains in native
  330. own = !IS_FORCED && target && target[key] !== undefined;
  331. // export native or passed
  332. out = (own ? target : source)[key];
  333. // bind timers to global for call from export context
  334. exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
  335. // extend global
  336. if (target) _redefine(target, key, out, type & $export.U);
  337. // export
  338. if (exports[key] != out) _hide(exports, key, exp);
  339. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  340. }
  341. };
  342. _global.core = _core;
  343. // type bitmap
  344. $export.F = 1; // forced
  345. $export.G = 2; // global
  346. $export.S = 4; // static
  347. $export.P = 8; // proto
  348. $export.B = 16; // bind
  349. $export.W = 32; // wrap
  350. $export.U = 64; // safe
  351. $export.R = 128; // real proto method for `library`
  352. var _export = $export;
  353. _export({
  354. target: 'RegExp',
  355. proto: true,
  356. forced: _regexpExec !== /./.exec
  357. }, {
  358. exec: _regexpExec
  359. });
  360. var SPECIES = _wks('species');
  361. var REPLACE_SUPPORTS_NAMED_GROUPS = !_fails(function () {
  362. // #replace needs built-in support for named groups.
  363. // #match works fine because it just return the exec results, even if it has
  364. // a "grops" property.
  365. var re = /./;
  366. re.exec = function () {
  367. var result = [];
  368. result.groups = { a: '7' };
  369. return result;
  370. };
  371. return ''.replace(re, '$<a>') !== '7';
  372. });
  373. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = (function () {
  374. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  375. var re = /(?:)/;
  376. var originalExec = re.exec;
  377. re.exec = function () { return originalExec.apply(this, arguments); };
  378. var result = 'ab'.split(re);
  379. return result.length === 2 && result[0] === 'a' && result[1] === 'b';
  380. })();
  381. var _fixReWks = function (KEY, length, exec) {
  382. var SYMBOL = _wks(KEY);
  383. var DELEGATES_TO_SYMBOL = !_fails(function () {
  384. // String methods call symbol-named RegEp methods
  385. var O = {};
  386. O[SYMBOL] = function () { return 7; };
  387. return ''[KEY](O) != 7;
  388. });
  389. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !_fails(function () {
  390. // Symbol-named RegExp methods call .exec
  391. var execCalled = false;
  392. var re = /a/;
  393. re.exec = function () { execCalled = true; return null; };
  394. if (KEY === 'split') {
  395. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  396. // a new one. We need to return the patched regex when creating the new one.
  397. re.constructor = {};
  398. re.constructor[SPECIES] = function () { return re; };
  399. }
  400. re[SYMBOL]('');
  401. return !execCalled;
  402. }) : undefined;
  403. if (
  404. !DELEGATES_TO_SYMBOL ||
  405. !DELEGATES_TO_EXEC ||
  406. (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
  407. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  408. ) {
  409. var nativeRegExpMethod = /./[SYMBOL];
  410. var fns = exec(
  411. _defined,
  412. SYMBOL,
  413. ''[KEY],
  414. function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) {
  415. if (regexp.exec === _regexpExec) {
  416. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  417. // The native String method already delegates to @@method (this
  418. // polyfilled function), leasing to infinite recursion.
  419. // We avoid it by directly calling the native @@method method.
  420. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  421. }
  422. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  423. }
  424. return { done: false };
  425. }
  426. );
  427. var strfn = fns[0];
  428. var rxfn = fns[1];
  429. _redefine(String.prototype, KEY, strfn);
  430. _hide(RegExp.prototype, SYMBOL, length == 2
  431. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  432. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  433. ? function (string, arg) { return rxfn.call(string, this, arg); }
  434. // 21.2.5.6 RegExp.prototype[@@match](string)
  435. // 21.2.5.9 RegExp.prototype[@@search](string)
  436. : function (string) { return rxfn.call(string, this); }
  437. );
  438. }
  439. };
  440. var max = Math.max;
  441. var min$1 = Math.min;
  442. var floor$1 = Math.floor;
  443. var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
  444. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
  445. var maybeToString = function (it) {
  446. return it === undefined ? it : String(it);
  447. };
  448. // @@replace logic
  449. _fixReWks('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) {
  450. return [
  451. // `String.prototype.replace` method
  452. // https://tc39.github.io/ecma262/#sec-string.prototype.replace
  453. function replace(searchValue, replaceValue) {
  454. var O = defined(this);
  455. var fn = searchValue == undefined ? undefined : searchValue[REPLACE];
  456. return fn !== undefined
  457. ? fn.call(searchValue, O, replaceValue)
  458. : $replace.call(String(O), searchValue, replaceValue);
  459. },
  460. // `RegExp.prototype[@@replace]` method
  461. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
  462. function (regexp, replaceValue) {
  463. var res = maybeCallNative($replace, regexp, this, replaceValue);
  464. if (res.done) return res.value;
  465. var rx = _anObject(regexp);
  466. var S = String(this);
  467. var functionalReplace = typeof replaceValue === 'function';
  468. if (!functionalReplace) replaceValue = String(replaceValue);
  469. var global = rx.global;
  470. if (global) {
  471. var fullUnicode = rx.unicode;
  472. rx.lastIndex = 0;
  473. }
  474. var results = [];
  475. while (true) {
  476. var result = _regexpExecAbstract(rx, S);
  477. if (result === null) break;
  478. results.push(result);
  479. if (!global) break;
  480. var matchStr = String(result[0]);
  481. if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode);
  482. }
  483. var accumulatedResult = '';
  484. var nextSourcePosition = 0;
  485. for (var i = 0; i < results.length; i++) {
  486. result = results[i];
  487. var matched = String(result[0]);
  488. var position = max(min$1(_toInteger(result.index), S.length), 0);
  489. var captures = [];
  490. // NOTE: This is equivalent to
  491. // captures = result.slice(1).map(maybeToString)
  492. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  493. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  494. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  495. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  496. var namedCaptures = result.groups;
  497. if (functionalReplace) {
  498. var replacerArgs = [matched].concat(captures, position, S);
  499. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  500. var replacement = String(replaceValue.apply(undefined, replacerArgs));
  501. } else {
  502. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  503. }
  504. if (position >= nextSourcePosition) {
  505. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  506. nextSourcePosition = position + matched.length;
  507. }
  508. }
  509. return accumulatedResult + S.slice(nextSourcePosition);
  510. }
  511. ];
  512. // https://tc39.github.io/ecma262/#sec-getsubstitution
  513. function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
  514. var tailPos = position + matched.length;
  515. var m = captures.length;
  516. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  517. if (namedCaptures !== undefined) {
  518. namedCaptures = _toObject(namedCaptures);
  519. symbols = SUBSTITUTION_SYMBOLS;
  520. }
  521. return $replace.call(replacement, symbols, function (match, ch) {
  522. var capture;
  523. switch (ch.charAt(0)) {
  524. case '$': return '$';
  525. case '&': return matched;
  526. case '`': return str.slice(0, position);
  527. case "'": return str.slice(tailPos);
  528. case '<':
  529. capture = namedCaptures[ch.slice(1, -1)];
  530. break;
  531. default: // \d\d?
  532. var n = +ch;
  533. if (n === 0) return match;
  534. if (n > m) {
  535. var f = floor$1(n / 10);
  536. if (f === 0) return match;
  537. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  538. return match;
  539. }
  540. capture = captures[n - 1];
  541. }
  542. return capture === undefined ? '' : capture;
  543. });
  544. }
  545. });
  546. var dP$1 = _objectDp.f;
  547. var FProto = Function.prototype;
  548. var nameRE = /^\s*function ([^ (]*)/;
  549. var NAME = 'name';
  550. // 19.2.4.2 name
  551. NAME in FProto || _descriptors && dP$1(FProto, NAME, {
  552. configurable: true,
  553. get: function () {
  554. try {
  555. return ('' + this).match(nameRE)[1];
  556. } catch (e) {
  557. return '';
  558. }
  559. }
  560. });
  561. // @@match logic
  562. _fixReWks('match', 1, function (defined, MATCH, $match, maybeCallNative) {
  563. return [
  564. // `String.prototype.match` method
  565. // https://tc39.github.io/ecma262/#sec-string.prototype.match
  566. function match(regexp) {
  567. var O = defined(this);
  568. var fn = regexp == undefined ? undefined : regexp[MATCH];
  569. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  570. },
  571. // `RegExp.prototype[@@match]` method
  572. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
  573. function (regexp) {
  574. var res = maybeCallNative($match, regexp, this);
  575. if (res.done) return res.value;
  576. var rx = _anObject(regexp);
  577. var S = String(this);
  578. if (!rx.global) return _regexpExecAbstract(rx, S);
  579. var fullUnicode = rx.unicode;
  580. rx.lastIndex = 0;
  581. var A = [];
  582. var n = 0;
  583. var result;
  584. while ((result = _regexpExecAbstract(rx, S)) !== null) {
  585. var matchStr = String(result[0]);
  586. A[n] = matchStr;
  587. if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode);
  588. n++;
  589. }
  590. return n === 0 ? null : A;
  591. }
  592. ];
  593. });
  594. // 22.1.3.31 Array.prototype[@@unscopables]
  595. var UNSCOPABLES = _wks('unscopables');
  596. var ArrayProto = Array.prototype;
  597. if (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {});
  598. var _addToUnscopables = function (key) {
  599. ArrayProto[UNSCOPABLES][key] = true;
  600. };
  601. var _iterStep = function (done, value) {
  602. return { value: value, done: !!done };
  603. };
  604. var _iterators = {};
  605. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  606. // eslint-disable-next-line no-prototype-builtins
  607. var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  608. return _cof(it) == 'String' ? it.split('') : Object(it);
  609. };
  610. // to indexed object, toObject with fallback for non-array-like ES3 strings
  611. var _toIobject = function (it) {
  612. return _iobject(_defined(it));
  613. };
  614. var max$1 = Math.max;
  615. var min$2 = Math.min;
  616. var _toAbsoluteIndex = function (index, length) {
  617. index = _toInteger(index);
  618. return index < 0 ? max$1(index + length, 0) : min$2(index, length);
  619. };
  620. // false -> Array#indexOf
  621. // true -> Array#includes
  622. var _arrayIncludes = function (IS_INCLUDES) {
  623. return function ($this, el, fromIndex) {
  624. var O = _toIobject($this);
  625. var length = _toLength(O.length);
  626. var index = _toAbsoluteIndex(fromIndex, length);
  627. var value;
  628. // Array#includes uses SameValueZero equality algorithm
  629. // eslint-disable-next-line no-self-compare
  630. if (IS_INCLUDES && el != el) while (length > index) {
  631. value = O[index++];
  632. // eslint-disable-next-line no-self-compare
  633. if (value != value) return true;
  634. // Array#indexOf ignores holes, Array#includes - not
  635. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  636. if (O[index] === el) return IS_INCLUDES || index || 0;
  637. } return !IS_INCLUDES && -1;
  638. };
  639. };
  640. var shared = _shared('keys');
  641. var _sharedKey = function (key) {
  642. return shared[key] || (shared[key] = _uid(key));
  643. };
  644. var arrayIndexOf = _arrayIncludes(false);
  645. var IE_PROTO = _sharedKey('IE_PROTO');
  646. var _objectKeysInternal = function (object, names) {
  647. var O = _toIobject(object);
  648. var i = 0;
  649. var result = [];
  650. var key;
  651. for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
  652. // Don't enum bug & hidden keys
  653. while (names.length > i) if (_has(O, key = names[i++])) {
  654. ~arrayIndexOf(result, key) || result.push(key);
  655. }
  656. return result;
  657. };
  658. // IE 8- don't enum bug keys
  659. var _enumBugKeys = (
  660. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  661. ).split(',');
  662. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  663. var _objectKeys = Object.keys || function keys(O) {
  664. return _objectKeysInternal(O, _enumBugKeys);
  665. };
  666. var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
  667. _anObject(O);
  668. var keys = _objectKeys(Properties);
  669. var length = keys.length;
  670. var i = 0;
  671. var P;
  672. while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
  673. return O;
  674. };
  675. var document$2 = _global.document;
  676. var _html = document$2 && document$2.documentElement;
  677. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  678. var IE_PROTO$1 = _sharedKey('IE_PROTO');
  679. var Empty = function () { /* empty */ };
  680. var PROTOTYPE$1 = 'prototype';
  681. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  682. var createDict = function () {
  683. // Thrash, waste and sodomy: IE GC bug
  684. var iframe = _domCreate('iframe');
  685. var i = _enumBugKeys.length;
  686. var lt = '<';
  687. var gt = '>';
  688. var iframeDocument;
  689. iframe.style.display = 'none';
  690. _html.appendChild(iframe);
  691. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  692. // createDict = iframe.contentWindow.Object;
  693. // html.removeChild(iframe);
  694. iframeDocument = iframe.contentWindow.document;
  695. iframeDocument.open();
  696. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  697. iframeDocument.close();
  698. createDict = iframeDocument.F;
  699. while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
  700. return createDict();
  701. };
  702. var _objectCreate = Object.create || function create(O, Properties) {
  703. var result;
  704. if (O !== null) {
  705. Empty[PROTOTYPE$1] = _anObject(O);
  706. result = new Empty();
  707. Empty[PROTOTYPE$1] = null;
  708. // add "__proto__" for Object.getPrototypeOf polyfill
  709. result[IE_PROTO$1] = O;
  710. } else result = createDict();
  711. return Properties === undefined ? result : _objectDps(result, Properties);
  712. };
  713. var def = _objectDp.f;
  714. var TAG$1 = _wks('toStringTag');
  715. var _setToStringTag = function (it, tag, stat) {
  716. if (it && !_has(it = stat ? it : it.prototype, TAG$1)) def(it, TAG$1, { configurable: true, value: tag });
  717. };
  718. var IteratorPrototype = {};
  719. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  720. _hide(IteratorPrototype, _wks('iterator'), function () { return this; });
  721. var _iterCreate = function (Constructor, NAME, next) {
  722. Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) });
  723. _setToStringTag(Constructor, NAME + ' Iterator');
  724. };
  725. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  726. var IE_PROTO$2 = _sharedKey('IE_PROTO');
  727. var ObjectProto = Object.prototype;
  728. var _objectGpo = Object.getPrototypeOf || function (O) {
  729. O = _toObject(O);
  730. if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
  731. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  732. return O.constructor.prototype;
  733. } return O instanceof Object ? ObjectProto : null;
  734. };
  735. var ITERATOR = _wks('iterator');
  736. var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
  737. var FF_ITERATOR = '@@iterator';
  738. var KEYS = 'keys';
  739. var VALUES = 'values';
  740. var returnThis = function () { return this; };
  741. var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  742. _iterCreate(Constructor, NAME, next);
  743. var getMethod = function (kind) {
  744. if (!BUGGY && kind in proto) return proto[kind];
  745. switch (kind) {
  746. case KEYS: return function keys() { return new Constructor(this, kind); };
  747. case VALUES: return function values() { return new Constructor(this, kind); };
  748. } return function entries() { return new Constructor(this, kind); };
  749. };
  750. var TAG = NAME + ' Iterator';
  751. var DEF_VALUES = DEFAULT == VALUES;
  752. var VALUES_BUG = false;
  753. var proto = Base.prototype;
  754. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  755. var $default = $native || getMethod(DEFAULT);
  756. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  757. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  758. var methods, key, IteratorPrototype;
  759. // Fix native
  760. if ($anyNative) {
  761. IteratorPrototype = _objectGpo($anyNative.call(new Base()));
  762. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  763. // Set @@toStringTag to native iterators
  764. _setToStringTag(IteratorPrototype, TAG, true);
  765. // fix for some old engines
  766. if (!_library && typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis);
  767. }
  768. }
  769. // fix Array#{values, @@iterator}.name in V8 / FF
  770. if (DEF_VALUES && $native && $native.name !== VALUES) {
  771. VALUES_BUG = true;
  772. $default = function values() { return $native.call(this); };
  773. }
  774. // Define iterator
  775. if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  776. _hide(proto, ITERATOR, $default);
  777. }
  778. // Plug for library
  779. _iterators[NAME] = $default;
  780. _iterators[TAG] = returnThis;
  781. if (DEFAULT) {
  782. methods = {
  783. values: DEF_VALUES ? $default : getMethod(VALUES),
  784. keys: IS_SET ? $default : getMethod(KEYS),
  785. entries: $entries
  786. };
  787. if (FORCED) for (key in methods) {
  788. if (!(key in proto)) _redefine(proto, key, methods[key]);
  789. } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
  790. }
  791. return methods;
  792. };
  793. // 22.1.3.4 Array.prototype.entries()
  794. // 22.1.3.13 Array.prototype.keys()
  795. // 22.1.3.29 Array.prototype.values()
  796. // 22.1.3.30 Array.prototype[@@iterator]()
  797. var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
  798. this._t = _toIobject(iterated); // target
  799. this._i = 0; // next index
  800. this._k = kind; // kind
  801. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  802. }, function () {
  803. var O = this._t;
  804. var kind = this._k;
  805. var index = this._i++;
  806. if (!O || index >= O.length) {
  807. this._t = undefined;
  808. return _iterStep(1);
  809. }
  810. if (kind == 'keys') return _iterStep(0, index);
  811. if (kind == 'values') return _iterStep(0, O[index]);
  812. return _iterStep(0, [index, O[index]]);
  813. }, 'values');
  814. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  815. _iterators.Arguments = _iterators.Array;
  816. _addToUnscopables('keys');
  817. _addToUnscopables('values');
  818. _addToUnscopables('entries');
  819. var ITERATOR$1 = _wks('iterator');
  820. var TO_STRING_TAG = _wks('toStringTag');
  821. var ArrayValues = _iterators.Array;
  822. var DOMIterables = {
  823. CSSRuleList: true, // TODO: Not spec compliant, should be false.
  824. CSSStyleDeclaration: false,
  825. CSSValueList: false,
  826. ClientRectList: false,
  827. DOMRectList: false,
  828. DOMStringList: false,
  829. DOMTokenList: true,
  830. DataTransferItemList: false,
  831. FileList: false,
  832. HTMLAllCollection: false,
  833. HTMLCollection: false,
  834. HTMLFormElement: false,
  835. HTMLSelectElement: false,
  836. MediaList: true, // TODO: Not spec compliant, should be false.
  837. MimeTypeArray: false,
  838. NamedNodeMap: false,
  839. NodeList: true,
  840. PaintRequestList: false,
  841. Plugin: false,
  842. PluginArray: false,
  843. SVGLengthList: false,
  844. SVGNumberList: false,
  845. SVGPathSegList: false,
  846. SVGPointList: false,
  847. SVGStringList: false,
  848. SVGTransformList: false,
  849. SourceBufferList: false,
  850. StyleSheetList: true, // TODO: Not spec compliant, should be false.
  851. TextTrackCueList: false,
  852. TextTrackList: false,
  853. TouchList: false
  854. };
  855. for (var collections = _objectKeys(DOMIterables), i = 0; i < collections.length; i++) {
  856. var NAME$1 = collections[i];
  857. var explicit = DOMIterables[NAME$1];
  858. var Collection = _global[NAME$1];
  859. var proto = Collection && Collection.prototype;
  860. var key;
  861. if (proto) {
  862. if (!proto[ITERATOR$1]) _hide(proto, ITERATOR$1, ArrayValues);
  863. if (!proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME$1);
  864. _iterators[NAME$1] = ArrayValues;
  865. if (explicit) for (key in es6_array_iterator) if (!proto[key]) _redefine(proto, key, es6_array_iterator[key], true);
  866. }
  867. }
  868. var $at = _stringAt(true);
  869. // 21.1.3.27 String.prototype[@@iterator]()
  870. _iterDefine(String, 'String', function (iterated) {
  871. this._t = String(iterated); // target
  872. this._i = 0; // next index
  873. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  874. }, function () {
  875. var O = this._t;
  876. var index = this._i;
  877. var point;
  878. if (index >= O.length) return { value: undefined, done: true };
  879. point = $at(O, index);
  880. this._i += point.length;
  881. return { value: point, done: false };
  882. });
  883. // call something on iterator step with safe closing on error
  884. var _iterCall = function (iterator, fn, value, entries) {
  885. try {
  886. return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
  887. // 7.4.6 IteratorClose(iterator, completion)
  888. } catch (e) {
  889. var ret = iterator['return'];
  890. if (ret !== undefined) _anObject(ret.call(iterator));
  891. throw e;
  892. }
  893. };
  894. // check on default Array iterator
  895. var ITERATOR$2 = _wks('iterator');
  896. var ArrayProto$1 = Array.prototype;
  897. var _isArrayIter = function (it) {
  898. return it !== undefined && (_iterators.Array === it || ArrayProto$1[ITERATOR$2] === it);
  899. };
  900. var _createProperty = function (object, index, value) {
  901. if (index in object) _objectDp.f(object, index, _propertyDesc(0, value));
  902. else object[index] = value;
  903. };
  904. var ITERATOR$3 = _wks('iterator');
  905. var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
  906. if (it != undefined) return it[ITERATOR$3]
  907. || it['@@iterator']
  908. || _iterators[_classof(it)];
  909. };
  910. var ITERATOR$4 = _wks('iterator');
  911. var SAFE_CLOSING = false;
  912. try {
  913. var riter = [7][ITERATOR$4]();
  914. riter['return'] = function () { SAFE_CLOSING = true; };
  915. } catch (e) { /* empty */ }
  916. var _iterDetect = function (exec, skipClosing) {
  917. if (!skipClosing && !SAFE_CLOSING) return false;
  918. var safe = false;
  919. try {
  920. var arr = [7];
  921. var iter = arr[ITERATOR$4]();
  922. iter.next = function () { return { done: safe = true }; };
  923. arr[ITERATOR$4] = function () { return iter; };
  924. exec(arr);
  925. } catch (e) { /* empty */ }
  926. return safe;
  927. };
  928. _export(_export.S + _export.F * !_iterDetect(function (iter) { }), 'Array', {
  929. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  930. from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  931. var O = _toObject(arrayLike);
  932. var C = typeof this == 'function' ? this : Array;
  933. var aLen = arguments.length;
  934. var mapfn = aLen > 1 ? arguments[1] : undefined;
  935. var mapping = mapfn !== undefined;
  936. var index = 0;
  937. var iterFn = core_getIteratorMethod(O);
  938. var length, result, step, iterator;
  939. if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  940. // if object isn't iterable or it's array with default iterator - use simple case
  941. if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) {
  942. for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
  943. _createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [step.value, index], true) : step.value);
  944. }
  945. } else {
  946. length = _toLength(O.length);
  947. for (result = new C(length); length > index; index++) {
  948. _createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  949. }
  950. }
  951. result.length = index;
  952. return result;
  953. }
  954. });
  955. function _classCallCheck(instance, Constructor) {
  956. if (!(instance instanceof Constructor)) {
  957. throw new TypeError("Cannot call a class as a function");
  958. }
  959. }
  960. function _defineProperties(target, props) {
  961. for (var i = 0; i < props.length; i++) {
  962. var descriptor = props[i];
  963. descriptor.enumerable = descriptor.enumerable || false;
  964. descriptor.configurable = true;
  965. if ("value" in descriptor) descriptor.writable = true;
  966. Object.defineProperty(target, descriptor.key, descriptor);
  967. }
  968. }
  969. function _createClass(Constructor, protoProps, staticProps) {
  970. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  971. if (staticProps) _defineProperties(Constructor, staticProps);
  972. return Constructor;
  973. }
  974. function _defineProperty(obj, key, value) {
  975. if (key in obj) {
  976. Object.defineProperty(obj, key, {
  977. value: value,
  978. enumerable: true,
  979. configurable: true,
  980. writable: true
  981. });
  982. } else {
  983. obj[key] = value;
  984. }
  985. return obj;
  986. }
  987. function _objectSpread(target) {
  988. for (var i = 1; i < arguments.length; i++) {
  989. var source = arguments[i] != null ? arguments[i] : {};
  990. var ownKeys = Object.keys(source);
  991. if (typeof Object.getOwnPropertySymbols === 'function') {
  992. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  993. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  994. }));
  995. }
  996. ownKeys.forEach(function (key) {
  997. _defineProperty(target, key, source[key]);
  998. });
  999. }
  1000. return target;
  1001. }
  1002. var scrollbarWidth = createCommonjsModule(function (module, exports) {
  1003. /*! scrollbarWidth.js v0.1.3 | felixexter | MIT | https://github.com/felixexter/scrollbarWidth */
  1004. (function (root, factory) {
  1005. {
  1006. module.exports = factory();
  1007. }
  1008. }(commonjsGlobal, function () {
  1009. function scrollbarWidth() {
  1010. if (typeof document === 'undefined') {
  1011. return 0
  1012. }
  1013. var
  1014. body = document.body,
  1015. box = document.createElement('div'),
  1016. boxStyle = box.style,
  1017. width;
  1018. boxStyle.position = 'absolute';
  1019. boxStyle.top = boxStyle.left = '-9999px';
  1020. boxStyle.width = boxStyle.height = '100px';
  1021. boxStyle.overflow = 'scroll';
  1022. body.appendChild(box);
  1023. width = box.offsetWidth - box.clientWidth;
  1024. body.removeChild(box);
  1025. return width;
  1026. }
  1027. return scrollbarWidth;
  1028. }));
  1029. });
  1030. /**
  1031. * lodash (Custom Build) <https://lodash.com/>
  1032. * Build: `lodash modularize exports="npm" -o ./`
  1033. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1034. * Released under MIT license <https://lodash.com/license>
  1035. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1036. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1037. */
  1038. /** Used as the `TypeError` message for "Functions" methods. */
  1039. var FUNC_ERROR_TEXT = 'Expected a function';
  1040. /** Used as references for various `Number` constants. */
  1041. var NAN = 0 / 0;
  1042. /** `Object#toString` result references. */
  1043. var symbolTag = '[object Symbol]';
  1044. /** Used to match leading and trailing whitespace. */
  1045. var reTrim = /^\s+|\s+$/g;
  1046. /** Used to detect bad signed hexadecimal string values. */
  1047. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1048. /** Used to detect binary string values. */
  1049. var reIsBinary = /^0b[01]+$/i;
  1050. /** Used to detect octal string values. */
  1051. var reIsOctal = /^0o[0-7]+$/i;
  1052. /** Built-in method references without a dependency on `root`. */
  1053. var freeParseInt = parseInt;
  1054. /** Detect free variable `global` from Node.js. */
  1055. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1056. /** Detect free variable `self`. */
  1057. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1058. /** Used as a reference to the global object. */
  1059. var root = freeGlobal || freeSelf || Function('return this')();
  1060. /** Used for built-in method references. */
  1061. var objectProto = Object.prototype;
  1062. /**
  1063. * Used to resolve the
  1064. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1065. * of values.
  1066. */
  1067. var objectToString = objectProto.toString;
  1068. /* Built-in method references for those with the same name as other `lodash` methods. */
  1069. var nativeMax = Math.max,
  1070. nativeMin = Math.min;
  1071. /**
  1072. * Gets the timestamp of the number of milliseconds that have elapsed since
  1073. * the Unix epoch (1 January 1970 00:00:00 UTC).
  1074. *
  1075. * @static
  1076. * @memberOf _
  1077. * @since 2.4.0
  1078. * @category Date
  1079. * @returns {number} Returns the timestamp.
  1080. * @example
  1081. *
  1082. * _.defer(function(stamp) {
  1083. * console.log(_.now() - stamp);
  1084. * }, _.now());
  1085. * // => Logs the number of milliseconds it took for the deferred invocation.
  1086. */
  1087. var now = function() {
  1088. return root.Date.now();
  1089. };
  1090. /**
  1091. * Creates a debounced function that delays invoking `func` until after `wait`
  1092. * milliseconds have elapsed since the last time the debounced function was
  1093. * invoked. The debounced function comes with a `cancel` method to cancel
  1094. * delayed `func` invocations and a `flush` method to immediately invoke them.
  1095. * Provide `options` to indicate whether `func` should be invoked on the
  1096. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  1097. * with the last arguments provided to the debounced function. Subsequent
  1098. * calls to the debounced function return the result of the last `func`
  1099. * invocation.
  1100. *
  1101. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1102. * invoked on the trailing edge of the timeout only if the debounced function
  1103. * is invoked more than once during the `wait` timeout.
  1104. *
  1105. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1106. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1107. *
  1108. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1109. * for details over the differences between `_.debounce` and `_.throttle`.
  1110. *
  1111. * @static
  1112. * @memberOf _
  1113. * @since 0.1.0
  1114. * @category Function
  1115. * @param {Function} func The function to debounce.
  1116. * @param {number} [wait=0] The number of milliseconds to delay.
  1117. * @param {Object} [options={}] The options object.
  1118. * @param {boolean} [options.leading=false]
  1119. * Specify invoking on the leading edge of the timeout.
  1120. * @param {number} [options.maxWait]
  1121. * The maximum time `func` is allowed to be delayed before it's invoked.
  1122. * @param {boolean} [options.trailing=true]
  1123. * Specify invoking on the trailing edge of the timeout.
  1124. * @returns {Function} Returns the new debounced function.
  1125. * @example
  1126. *
  1127. * // Avoid costly calculations while the window size is in flux.
  1128. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  1129. *
  1130. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  1131. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  1132. * 'leading': true,
  1133. * 'trailing': false
  1134. * }));
  1135. *
  1136. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  1137. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  1138. * var source = new EventSource('/stream');
  1139. * jQuery(source).on('message', debounced);
  1140. *
  1141. * // Cancel the trailing debounced invocation.
  1142. * jQuery(window).on('popstate', debounced.cancel);
  1143. */
  1144. function debounce(func, wait, options) {
  1145. var lastArgs,
  1146. lastThis,
  1147. maxWait,
  1148. result,
  1149. timerId,
  1150. lastCallTime,
  1151. lastInvokeTime = 0,
  1152. leading = false,
  1153. maxing = false,
  1154. trailing = true;
  1155. if (typeof func != 'function') {
  1156. throw new TypeError(FUNC_ERROR_TEXT);
  1157. }
  1158. wait = toNumber(wait) || 0;
  1159. if (isObject(options)) {
  1160. leading = !!options.leading;
  1161. maxing = 'maxWait' in options;
  1162. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  1163. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1164. }
  1165. function invokeFunc(time) {
  1166. var args = lastArgs,
  1167. thisArg = lastThis;
  1168. lastArgs = lastThis = undefined;
  1169. lastInvokeTime = time;
  1170. result = func.apply(thisArg, args);
  1171. return result;
  1172. }
  1173. function leadingEdge(time) {
  1174. // Reset any `maxWait` timer.
  1175. lastInvokeTime = time;
  1176. // Start the timer for the trailing edge.
  1177. timerId = setTimeout(timerExpired, wait);
  1178. // Invoke the leading edge.
  1179. return leading ? invokeFunc(time) : result;
  1180. }
  1181. function remainingWait(time) {
  1182. var timeSinceLastCall = time - lastCallTime,
  1183. timeSinceLastInvoke = time - lastInvokeTime,
  1184. result = wait - timeSinceLastCall;
  1185. return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
  1186. }
  1187. function shouldInvoke(time) {
  1188. var timeSinceLastCall = time - lastCallTime,
  1189. timeSinceLastInvoke = time - lastInvokeTime;
  1190. // Either this is the first call, activity has stopped and we're at the
  1191. // trailing edge, the system time has gone backwards and we're treating
  1192. // it as the trailing edge, or we've hit the `maxWait` limit.
  1193. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  1194. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  1195. }
  1196. function timerExpired() {
  1197. var time = now();
  1198. if (shouldInvoke(time)) {
  1199. return trailingEdge(time);
  1200. }
  1201. // Restart the timer.
  1202. timerId = setTimeout(timerExpired, remainingWait(time));
  1203. }
  1204. function trailingEdge(time) {
  1205. timerId = undefined;
  1206. // Only invoke if we have `lastArgs` which means `func` has been
  1207. // debounced at least once.
  1208. if (trailing && lastArgs) {
  1209. return invokeFunc(time);
  1210. }
  1211. lastArgs = lastThis = undefined;
  1212. return result;
  1213. }
  1214. function cancel() {
  1215. if (timerId !== undefined) {
  1216. clearTimeout(timerId);
  1217. }
  1218. lastInvokeTime = 0;
  1219. lastArgs = lastCallTime = lastThis = timerId = undefined;
  1220. }
  1221. function flush() {
  1222. return timerId === undefined ? result : trailingEdge(now());
  1223. }
  1224. function debounced() {
  1225. var time = now(),
  1226. isInvoking = shouldInvoke(time);
  1227. lastArgs = arguments;
  1228. lastThis = this;
  1229. lastCallTime = time;
  1230. if (isInvoking) {
  1231. if (timerId === undefined) {
  1232. return leadingEdge(lastCallTime);
  1233. }
  1234. if (maxing) {
  1235. // Handle invocations in a tight loop.
  1236. timerId = setTimeout(timerExpired, wait);
  1237. return invokeFunc(lastCallTime);
  1238. }
  1239. }
  1240. if (timerId === undefined) {
  1241. timerId = setTimeout(timerExpired, wait);
  1242. }
  1243. return result;
  1244. }
  1245. debounced.cancel = cancel;
  1246. debounced.flush = flush;
  1247. return debounced;
  1248. }
  1249. /**
  1250. * Creates a throttled function that only invokes `func` at most once per
  1251. * every `wait` milliseconds. The throttled function comes with a `cancel`
  1252. * method to cancel delayed `func` invocations and a `flush` method to
  1253. * immediately invoke them. Provide `options` to indicate whether `func`
  1254. * should be invoked on the leading and/or trailing edge of the `wait`
  1255. * timeout. The `func` is invoked with the last arguments provided to the
  1256. * throttled function. Subsequent calls to the throttled function return the
  1257. * result of the last `func` invocation.
  1258. *
  1259. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1260. * invoked on the trailing edge of the timeout only if the throttled function
  1261. * is invoked more than once during the `wait` timeout.
  1262. *
  1263. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1264. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1265. *
  1266. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1267. * for details over the differences between `_.throttle` and `_.debounce`.
  1268. *
  1269. * @static
  1270. * @memberOf _
  1271. * @since 0.1.0
  1272. * @category Function
  1273. * @param {Function} func The function to throttle.
  1274. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  1275. * @param {Object} [options={}] The options object.
  1276. * @param {boolean} [options.leading=true]
  1277. * Specify invoking on the leading edge of the timeout.
  1278. * @param {boolean} [options.trailing=true]
  1279. * Specify invoking on the trailing edge of the timeout.
  1280. * @returns {Function} Returns the new throttled function.
  1281. * @example
  1282. *
  1283. * // Avoid excessively updating the position while scrolling.
  1284. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  1285. *
  1286. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  1287. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  1288. * jQuery(element).on('click', throttled);
  1289. *
  1290. * // Cancel the trailing throttled invocation.
  1291. * jQuery(window).on('popstate', throttled.cancel);
  1292. */
  1293. function throttle(func, wait, options) {
  1294. var leading = true,
  1295. trailing = true;
  1296. if (typeof func != 'function') {
  1297. throw new TypeError(FUNC_ERROR_TEXT);
  1298. }
  1299. if (isObject(options)) {
  1300. leading = 'leading' in options ? !!options.leading : leading;
  1301. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1302. }
  1303. return debounce(func, wait, {
  1304. 'leading': leading,
  1305. 'maxWait': wait,
  1306. 'trailing': trailing
  1307. });
  1308. }
  1309. /**
  1310. * Checks if `value` is the
  1311. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1312. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1313. *
  1314. * @static
  1315. * @memberOf _
  1316. * @since 0.1.0
  1317. * @category Lang
  1318. * @param {*} value The value to check.
  1319. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1320. * @example
  1321. *
  1322. * _.isObject({});
  1323. * // => true
  1324. *
  1325. * _.isObject([1, 2, 3]);
  1326. * // => true
  1327. *
  1328. * _.isObject(_.noop);
  1329. * // => true
  1330. *
  1331. * _.isObject(null);
  1332. * // => false
  1333. */
  1334. function isObject(value) {
  1335. var type = typeof value;
  1336. return !!value && (type == 'object' || type == 'function');
  1337. }
  1338. /**
  1339. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1340. * and has a `typeof` result of "object".
  1341. *
  1342. * @static
  1343. * @memberOf _
  1344. * @since 4.0.0
  1345. * @category Lang
  1346. * @param {*} value The value to check.
  1347. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1348. * @example
  1349. *
  1350. * _.isObjectLike({});
  1351. * // => true
  1352. *
  1353. * _.isObjectLike([1, 2, 3]);
  1354. * // => true
  1355. *
  1356. * _.isObjectLike(_.noop);
  1357. * // => false
  1358. *
  1359. * _.isObjectLike(null);
  1360. * // => false
  1361. */
  1362. function isObjectLike(value) {
  1363. return !!value && typeof value == 'object';
  1364. }
  1365. /**
  1366. * Checks if `value` is classified as a `Symbol` primitive or object.
  1367. *
  1368. * @static
  1369. * @memberOf _
  1370. * @since 4.0.0
  1371. * @category Lang
  1372. * @param {*} value The value to check.
  1373. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  1374. * @example
  1375. *
  1376. * _.isSymbol(Symbol.iterator);
  1377. * // => true
  1378. *
  1379. * _.isSymbol('abc');
  1380. * // => false
  1381. */
  1382. function isSymbol(value) {
  1383. return typeof value == 'symbol' ||
  1384. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  1385. }
  1386. /**
  1387. * Converts `value` to a number.
  1388. *
  1389. * @static
  1390. * @memberOf _
  1391. * @since 4.0.0
  1392. * @category Lang
  1393. * @param {*} value The value to process.
  1394. * @returns {number} Returns the number.
  1395. * @example
  1396. *
  1397. * _.toNumber(3.2);
  1398. * // => 3.2
  1399. *
  1400. * _.toNumber(Number.MIN_VALUE);
  1401. * // => 5e-324
  1402. *
  1403. * _.toNumber(Infinity);
  1404. * // => Infinity
  1405. *
  1406. * _.toNumber('3.2');
  1407. * // => 3.2
  1408. */
  1409. function toNumber(value) {
  1410. if (typeof value == 'number') {
  1411. return value;
  1412. }
  1413. if (isSymbol(value)) {
  1414. return NAN;
  1415. }
  1416. if (isObject(value)) {
  1417. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  1418. value = isObject(other) ? (other + '') : other;
  1419. }
  1420. if (typeof value != 'string') {
  1421. return value === 0 ? value : +value;
  1422. }
  1423. value = value.replace(reTrim, '');
  1424. var isBinary = reIsBinary.test(value);
  1425. return (isBinary || reIsOctal.test(value))
  1426. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  1427. : (reIsBadHex.test(value) ? NAN : +value);
  1428. }
  1429. var lodash_throttle = throttle;
  1430. /**
  1431. * lodash (Custom Build) <https://lodash.com/>
  1432. * Build: `lodash modularize exports="npm" -o ./`
  1433. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1434. * Released under MIT license <https://lodash.com/license>
  1435. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1436. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1437. */
  1438. /** Used as the `TypeError` message for "Functions" methods. */
  1439. var FUNC_ERROR_TEXT$1 = 'Expected a function';
  1440. /** Used as references for various `Number` constants. */
  1441. var NAN$1 = 0 / 0;
  1442. /** `Object#toString` result references. */
  1443. var symbolTag$1 = '[object Symbol]';
  1444. /** Used to match leading and trailing whitespace. */
  1445. var reTrim$1 = /^\s+|\s+$/g;
  1446. /** Used to detect bad signed hexadecimal string values. */
  1447. var reIsBadHex$1 = /^[-+]0x[0-9a-f]+$/i;
  1448. /** Used to detect binary string values. */
  1449. var reIsBinary$1 = /^0b[01]+$/i;
  1450. /** Used to detect octal string values. */
  1451. var reIsOctal$1 = /^0o[0-7]+$/i;
  1452. /** Built-in method references without a dependency on `root`. */
  1453. var freeParseInt$1 = parseInt;
  1454. /** Detect free variable `global` from Node.js. */
  1455. var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1456. /** Detect free variable `self`. */
  1457. var freeSelf$1 = typeof self == 'object' && self && self.Object === Object && self;
  1458. /** Used as a reference to the global object. */
  1459. var root$1 = freeGlobal$1 || freeSelf$1 || Function('return this')();
  1460. /** Used for built-in method references. */
  1461. var objectProto$1 = Object.prototype;
  1462. /**
  1463. * Used to resolve the
  1464. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1465. * of values.
  1466. */
  1467. var objectToString$1 = objectProto$1.toString;
  1468. /* Built-in method references for those with the same name as other `lodash` methods. */
  1469. var nativeMax$1 = Math.max,
  1470. nativeMin$1 = Math.min;
  1471. /**
  1472. * Gets the timestamp of the number of milliseconds that have elapsed since
  1473. * the Unix epoch (1 January 1970 00:00:00 UTC).
  1474. *
  1475. * @static
  1476. * @memberOf _
  1477. * @since 2.4.0
  1478. * @category Date
  1479. * @returns {number} Returns the timestamp.
  1480. * @example
  1481. *
  1482. * _.defer(function(stamp) {
  1483. * console.log(_.now() - stamp);
  1484. * }, _.now());
  1485. * // => Logs the number of milliseconds it took for the deferred invocation.
  1486. */
  1487. var now$1 = function() {
  1488. return root$1.Date.now();
  1489. };
  1490. /**
  1491. * Creates a debounced function that delays invoking `func` until after `wait`
  1492. * milliseconds have elapsed since the last time the debounced function was
  1493. * invoked. The debounced function comes with a `cancel` method to cancel
  1494. * delayed `func` invocations and a `flush` method to immediately invoke them.
  1495. * Provide `options` to indicate whether `func` should be invoked on the
  1496. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  1497. * with the last arguments provided to the debounced function. Subsequent
  1498. * calls to the debounced function return the result of the last `func`
  1499. * invocation.
  1500. *
  1501. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1502. * invoked on the trailing edge of the timeout only if the debounced function
  1503. * is invoked more than once during the `wait` timeout.
  1504. *
  1505. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1506. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1507. *
  1508. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1509. * for details over the differences between `_.debounce` and `_.throttle`.
  1510. *
  1511. * @static
  1512. * @memberOf _
  1513. * @since 0.1.0
  1514. * @category Function
  1515. * @param {Function} func The function to debounce.
  1516. * @param {number} [wait=0] The number of milliseconds to delay.
  1517. * @param {Object} [options={}] The options object.
  1518. * @param {boolean} [options.leading=false]
  1519. * Specify invoking on the leading edge of the timeout.
  1520. * @param {number} [options.maxWait]
  1521. * The maximum time `func` is allowed to be delayed before it's invoked.
  1522. * @param {boolean} [options.trailing=true]
  1523. * Specify invoking on the trailing edge of the timeout.
  1524. * @returns {Function} Returns the new debounced function.
  1525. * @example
  1526. *
  1527. * // Avoid costly calculations while the window size is in flux.
  1528. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  1529. *
  1530. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  1531. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  1532. * 'leading': true,
  1533. * 'trailing': false
  1534. * }));
  1535. *
  1536. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  1537. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  1538. * var source = new EventSource('/stream');
  1539. * jQuery(source).on('message', debounced);
  1540. *
  1541. * // Cancel the trailing debounced invocation.
  1542. * jQuery(window).on('popstate', debounced.cancel);
  1543. */
  1544. function debounce$1(func, wait, options) {
  1545. var lastArgs,
  1546. lastThis,
  1547. maxWait,
  1548. result,
  1549. timerId,
  1550. lastCallTime,
  1551. lastInvokeTime = 0,
  1552. leading = false,
  1553. maxing = false,
  1554. trailing = true;
  1555. if (typeof func != 'function') {
  1556. throw new TypeError(FUNC_ERROR_TEXT$1);
  1557. }
  1558. wait = toNumber$1(wait) || 0;
  1559. if (isObject$1(options)) {
  1560. leading = !!options.leading;
  1561. maxing = 'maxWait' in options;
  1562. maxWait = maxing ? nativeMax$1(toNumber$1(options.maxWait) || 0, wait) : maxWait;
  1563. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1564. }
  1565. function invokeFunc(time) {
  1566. var args = lastArgs,
  1567. thisArg = lastThis;
  1568. lastArgs = lastThis = undefined;
  1569. lastInvokeTime = time;
  1570. result = func.apply(thisArg, args);
  1571. return result;
  1572. }
  1573. function leadingEdge(time) {
  1574. // Reset any `maxWait` timer.
  1575. lastInvokeTime = time;
  1576. // Start the timer for the trailing edge.
  1577. timerId = setTimeout(timerExpired, wait);
  1578. // Invoke the leading edge.
  1579. return leading ? invokeFunc(time) : result;
  1580. }
  1581. function remainingWait(time) {
  1582. var timeSinceLastCall = time - lastCallTime,
  1583. timeSinceLastInvoke = time - lastInvokeTime,
  1584. result = wait - timeSinceLastCall;
  1585. return maxing ? nativeMin$1(result, maxWait - timeSinceLastInvoke) : result;
  1586. }
  1587. function shouldInvoke(time) {
  1588. var timeSinceLastCall = time - lastCallTime,
  1589. timeSinceLastInvoke = time - lastInvokeTime;
  1590. // Either this is the first call, activity has stopped and we're at the
  1591. // trailing edge, the system time has gone backwards and we're treating
  1592. // it as the trailing edge, or we've hit the `maxWait` limit.
  1593. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  1594. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  1595. }
  1596. function timerExpired() {
  1597. var time = now$1();
  1598. if (shouldInvoke(time)) {
  1599. return trailingEdge(time);
  1600. }
  1601. // Restart the timer.
  1602. timerId = setTimeout(timerExpired, remainingWait(time));
  1603. }
  1604. function trailingEdge(time) {
  1605. timerId = undefined;
  1606. // Only invoke if we have `lastArgs` which means `func` has been
  1607. // debounced at least once.
  1608. if (trailing && lastArgs) {
  1609. return invokeFunc(time);
  1610. }
  1611. lastArgs = lastThis = undefined;
  1612. return result;
  1613. }
  1614. function cancel() {
  1615. if (timerId !== undefined) {
  1616. clearTimeout(timerId);
  1617. }
  1618. lastInvokeTime = 0;
  1619. lastArgs = lastCallTime = lastThis = timerId = undefined;
  1620. }
  1621. function flush() {
  1622. return timerId === undefined ? result : trailingEdge(now$1());
  1623. }
  1624. function debounced() {
  1625. var time = now$1(),
  1626. isInvoking = shouldInvoke(time);
  1627. lastArgs = arguments;
  1628. lastThis = this;
  1629. lastCallTime = time;
  1630. if (isInvoking) {
  1631. if (timerId === undefined) {
  1632. return leadingEdge(lastCallTime);
  1633. }
  1634. if (maxing) {
  1635. // Handle invocations in a tight loop.
  1636. timerId = setTimeout(timerExpired, wait);
  1637. return invokeFunc(lastCallTime);
  1638. }
  1639. }
  1640. if (timerId === undefined) {
  1641. timerId = setTimeout(timerExpired, wait);
  1642. }
  1643. return result;
  1644. }
  1645. debounced.cancel = cancel;
  1646. debounced.flush = flush;
  1647. return debounced;
  1648. }
  1649. /**
  1650. * Checks if `value` is the
  1651. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1652. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1653. *
  1654. * @static
  1655. * @memberOf _
  1656. * @since 0.1.0
  1657. * @category Lang
  1658. * @param {*} value The value to check.
  1659. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1660. * @example
  1661. *
  1662. * _.isObject({});
  1663. * // => true
  1664. *
  1665. * _.isObject([1, 2, 3]);
  1666. * // => true
  1667. *
  1668. * _.isObject(_.noop);
  1669. * // => true
  1670. *
  1671. * _.isObject(null);
  1672. * // => false
  1673. */
  1674. function isObject$1(value) {
  1675. var type = typeof value;
  1676. return !!value && (type == 'object' || type == 'function');
  1677. }
  1678. /**
  1679. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1680. * and has a `typeof` result of "object".
  1681. *
  1682. * @static
  1683. * @memberOf _
  1684. * @since 4.0.0
  1685. * @category Lang
  1686. * @param {*} value The value to check.
  1687. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1688. * @example
  1689. *
  1690. * _.isObjectLike({});
  1691. * // => true
  1692. *
  1693. * _.isObjectLike([1, 2, 3]);
  1694. * // => true
  1695. *
  1696. * _.isObjectLike(_.noop);
  1697. * // => false
  1698. *
  1699. * _.isObjectLike(null);
  1700. * // => false
  1701. */
  1702. function isObjectLike$1(value) {
  1703. return !!value && typeof value == 'object';
  1704. }
  1705. /**
  1706. * Checks if `value` is classified as a `Symbol` primitive or object.
  1707. *
  1708. * @static
  1709. * @memberOf _
  1710. * @since 4.0.0
  1711. * @category Lang
  1712. * @param {*} value The value to check.
  1713. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  1714. * @example
  1715. *
  1716. * _.isSymbol(Symbol.iterator);
  1717. * // => true
  1718. *
  1719. * _.isSymbol('abc');
  1720. * // => false
  1721. */
  1722. function isSymbol$1(value) {
  1723. return typeof value == 'symbol' ||
  1724. (isObjectLike$1(value) && objectToString$1.call(value) == symbolTag$1);
  1725. }
  1726. /**
  1727. * Converts `value` to a number.
  1728. *
  1729. * @static
  1730. * @memberOf _
  1731. * @since 4.0.0
  1732. * @category Lang
  1733. * @param {*} value The value to process.
  1734. * @returns {number} Returns the number.
  1735. * @example
  1736. *
  1737. * _.toNumber(3.2);
  1738. * // => 3.2
  1739. *
  1740. * _.toNumber(Number.MIN_VALUE);
  1741. * // => 5e-324
  1742. *
  1743. * _.toNumber(Infinity);
  1744. * // => Infinity
  1745. *
  1746. * _.toNumber('3.2');
  1747. * // => 3.2
  1748. */
  1749. function toNumber$1(value) {
  1750. if (typeof value == 'number') {
  1751. return value;
  1752. }
  1753. if (isSymbol$1(value)) {
  1754. return NAN$1;
  1755. }
  1756. if (isObject$1(value)) {
  1757. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  1758. value = isObject$1(other) ? (other + '') : other;
  1759. }
  1760. if (typeof value != 'string') {
  1761. return value === 0 ? value : +value;
  1762. }
  1763. value = value.replace(reTrim$1, '');
  1764. var isBinary = reIsBinary$1.test(value);
  1765. return (isBinary || reIsOctal$1.test(value))
  1766. ? freeParseInt$1(value.slice(2), isBinary ? 2 : 8)
  1767. : (reIsBadHex$1.test(value) ? NAN$1 : +value);
  1768. }
  1769. var lodash_debounce = debounce$1;
  1770. /**
  1771. * lodash (Custom Build) <https://lodash.com/>
  1772. * Build: `lodash modularize exports="npm" -o ./`
  1773. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1774. * Released under MIT license <https://lodash.com/license>
  1775. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1776. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1777. */
  1778. /** Used as the `TypeError` message for "Functions" methods. */
  1779. var FUNC_ERROR_TEXT$2 = 'Expected a function';
  1780. /** Used to stand-in for `undefined` hash values. */
  1781. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1782. /** `Object#toString` result references. */
  1783. var funcTag = '[object Function]',
  1784. genTag = '[object GeneratorFunction]';
  1785. /**
  1786. * Used to match `RegExp`
  1787. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1788. */
  1789. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  1790. /** Used to detect host constructors (Safari). */
  1791. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1792. /** Detect free variable `global` from Node.js. */
  1793. var freeGlobal$2 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1794. /** Detect free variable `self`. */
  1795. var freeSelf$2 = typeof self == 'object' && self && self.Object === Object && self;
  1796. /** Used as a reference to the global object. */
  1797. var root$2 = freeGlobal$2 || freeSelf$2 || Function('return this')();
  1798. /**
  1799. * Gets the value at `key` of `object`.
  1800. *
  1801. * @private
  1802. * @param {Object} [object] The object to query.
  1803. * @param {string} key The key of the property to get.
  1804. * @returns {*} Returns the property value.
  1805. */
  1806. function getValue(object, key) {
  1807. return object == null ? undefined : object[key];
  1808. }
  1809. /**
  1810. * Checks if `value` is a host object in IE < 9.
  1811. *
  1812. * @private
  1813. * @param {*} value The value to check.
  1814. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  1815. */
  1816. function isHostObject(value) {
  1817. // Many host objects are `Object` objects that can coerce to strings
  1818. // despite having improperly defined `toString` methods.
  1819. var result = false;
  1820. if (value != null && typeof value.toString != 'function') {
  1821. try {
  1822. result = !!(value + '');
  1823. } catch (e) {}
  1824. }
  1825. return result;
  1826. }
  1827. /** Used for built-in method references. */
  1828. var arrayProto = Array.prototype,
  1829. funcProto = Function.prototype,
  1830. objectProto$2 = Object.prototype;
  1831. /** Used to detect overreaching core-js shims. */
  1832. var coreJsData = root$2['__core-js_shared__'];
  1833. /** Used to detect methods masquerading as native. */
  1834. var maskSrcKey = (function() {
  1835. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  1836. return uid ? ('Symbol(src)_1.' + uid) : '';
  1837. }());
  1838. /** Used to resolve the decompiled source of functions. */
  1839. var funcToString = funcProto.toString;
  1840. /** Used to check objects for own properties. */
  1841. var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
  1842. /**
  1843. * Used to resolve the
  1844. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1845. * of values.
  1846. */
  1847. var objectToString$2 = objectProto$2.toString;
  1848. /** Used to detect if a method is native. */
  1849. var reIsNative = RegExp('^' +
  1850. funcToString.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
  1851. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1852. );
  1853. /** Built-in value references. */
  1854. var splice = arrayProto.splice;
  1855. /* Built-in method references that are verified to be native. */
  1856. var Map$1 = getNative(root$2, 'Map'),
  1857. nativeCreate = getNative(Object, 'create');
  1858. /**
  1859. * Creates a hash object.
  1860. *
  1861. * @private
  1862. * @constructor
  1863. * @param {Array} [entries] The key-value pairs to cache.
  1864. */
  1865. function Hash(entries) {
  1866. var index = -1,
  1867. length = entries ? entries.length : 0;
  1868. this.clear();
  1869. while (++index < length) {
  1870. var entry = entries[index];
  1871. this.set(entry[0], entry[1]);
  1872. }
  1873. }
  1874. /**
  1875. * Removes all key-value entries from the hash.
  1876. *
  1877. * @private
  1878. * @name clear
  1879. * @memberOf Hash
  1880. */
  1881. function hashClear() {
  1882. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  1883. }
  1884. /**
  1885. * Removes `key` and its value from the hash.
  1886. *
  1887. * @private
  1888. * @name delete
  1889. * @memberOf Hash
  1890. * @param {Object} hash The hash to modify.
  1891. * @param {string} key The key of the value to remove.
  1892. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1893. */
  1894. function hashDelete(key) {
  1895. return this.has(key) && delete this.__data__[key];
  1896. }
  1897. /**
  1898. * Gets the hash value for `key`.
  1899. *
  1900. * @private
  1901. * @name get
  1902. * @memberOf Hash
  1903. * @param {string} key The key of the value to get.
  1904. * @returns {*} Returns the entry value.
  1905. */
  1906. function hashGet(key) {
  1907. var data = this.__data__;
  1908. if (nativeCreate) {
  1909. var result = data[key];
  1910. return result === HASH_UNDEFINED ? undefined : result;
  1911. }
  1912. return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
  1913. }
  1914. /**
  1915. * Checks if a hash value for `key` exists.
  1916. *
  1917. * @private
  1918. * @name has
  1919. * @memberOf Hash
  1920. * @param {string} key The key of the entry to check.
  1921. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1922. */
  1923. function hashHas(key) {
  1924. var data = this.__data__;
  1925. return nativeCreate ? data[key] !== undefined : hasOwnProperty$1.call(data, key);
  1926. }
  1927. /**
  1928. * Sets the hash `key` to `value`.
  1929. *
  1930. * @private
  1931. * @name set
  1932. * @memberOf Hash
  1933. * @param {string} key The key of the value to set.
  1934. * @param {*} value The value to set.
  1935. * @returns {Object} Returns the hash instance.
  1936. */
  1937. function hashSet(key, value) {
  1938. var data = this.__data__;
  1939. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  1940. return this;
  1941. }
  1942. // Add methods to `Hash`.
  1943. Hash.prototype.clear = hashClear;
  1944. Hash.prototype['delete'] = hashDelete;
  1945. Hash.prototype.get = hashGet;
  1946. Hash.prototype.has = hashHas;
  1947. Hash.prototype.set = hashSet;
  1948. /**
  1949. * Creates an list cache object.
  1950. *
  1951. * @private
  1952. * @constructor
  1953. * @param {Array} [entries] The key-value pairs to cache.
  1954. */
  1955. function ListCache(entries) {
  1956. var index = -1,
  1957. length = entries ? entries.length : 0;
  1958. this.clear();
  1959. while (++index < length) {
  1960. var entry = entries[index];
  1961. this.set(entry[0], entry[1]);
  1962. }
  1963. }
  1964. /**
  1965. * Removes all key-value entries from the list cache.
  1966. *
  1967. * @private
  1968. * @name clear
  1969. * @memberOf ListCache
  1970. */
  1971. function listCacheClear() {
  1972. this.__data__ = [];
  1973. }
  1974. /**
  1975. * Removes `key` and its value from the list cache.
  1976. *
  1977. * @private
  1978. * @name delete
  1979. * @memberOf ListCache
  1980. * @param {string} key The key of the value to remove.
  1981. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1982. */
  1983. function listCacheDelete(key) {
  1984. var data = this.__data__,
  1985. index = assocIndexOf(data, key);
  1986. if (index < 0) {
  1987. return false;
  1988. }
  1989. var lastIndex = data.length - 1;
  1990. if (index == lastIndex) {
  1991. data.pop();
  1992. } else {
  1993. splice.call(data, index, 1);
  1994. }
  1995. return true;
  1996. }
  1997. /**
  1998. * Gets the list cache value for `key`.
  1999. *
  2000. * @private
  2001. * @name get
  2002. * @memberOf ListCache
  2003. * @param {string} key The key of the value to get.
  2004. * @returns {*} Returns the entry value.
  2005. */
  2006. function listCacheGet(key) {
  2007. var data = this.__data__,
  2008. index = assocIndexOf(data, key);
  2009. return index < 0 ? undefined : data[index][1];
  2010. }
  2011. /**
  2012. * Checks if a list cache value for `key` exists.
  2013. *
  2014. * @private
  2015. * @name has
  2016. * @memberOf ListCache
  2017. * @param {string} key The key of the entry to check.
  2018. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2019. */
  2020. function listCacheHas(key) {
  2021. return assocIndexOf(this.__data__, key) > -1;
  2022. }
  2023. /**
  2024. * Sets the list cache `key` to `value`.
  2025. *
  2026. * @private
  2027. * @name set
  2028. * @memberOf ListCache
  2029. * @param {string} key The key of the value to set.
  2030. * @param {*} value The value to set.
  2031. * @returns {Object} Returns the list cache instance.
  2032. */
  2033. function listCacheSet(key, value) {
  2034. var data = this.__data__,
  2035. index = assocIndexOf(data, key);
  2036. if (index < 0) {
  2037. data.push([key, value]);
  2038. } else {
  2039. data[index][1] = value;
  2040. }
  2041. return this;
  2042. }
  2043. // Add methods to `ListCache`.
  2044. ListCache.prototype.clear = listCacheClear;
  2045. ListCache.prototype['delete'] = listCacheDelete;
  2046. ListCache.prototype.get = listCacheGet;
  2047. ListCache.prototype.has = listCacheHas;
  2048. ListCache.prototype.set = listCacheSet;
  2049. /**
  2050. * Creates a map cache object to store key-value pairs.
  2051. *
  2052. * @private
  2053. * @constructor
  2054. * @param {Array} [entries] The key-value pairs to cache.
  2055. */
  2056. function MapCache(entries) {
  2057. var index = -1,
  2058. length = entries ? entries.length : 0;
  2059. this.clear();
  2060. while (++index < length) {
  2061. var entry = entries[index];
  2062. this.set(entry[0], entry[1]);
  2063. }
  2064. }
  2065. /**
  2066. * Removes all key-value entries from the map.
  2067. *
  2068. * @private
  2069. * @name clear
  2070. * @memberOf MapCache
  2071. */
  2072. function mapCacheClear() {
  2073. this.__data__ = {
  2074. 'hash': new Hash,
  2075. 'map': new (Map$1 || ListCache),
  2076. 'string': new Hash
  2077. };
  2078. }
  2079. /**
  2080. * Removes `key` and its value from the map.
  2081. *
  2082. * @private
  2083. * @name delete
  2084. * @memberOf MapCache
  2085. * @param {string} key The key of the value to remove.
  2086. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2087. */
  2088. function mapCacheDelete(key) {
  2089. return getMapData(this, key)['delete'](key);
  2090. }
  2091. /**
  2092. * Gets the map value for `key`.
  2093. *
  2094. * @private
  2095. * @name get
  2096. * @memberOf MapCache
  2097. * @param {string} key The key of the value to get.
  2098. * @returns {*} Returns the entry value.
  2099. */
  2100. function mapCacheGet(key) {
  2101. return getMapData(this, key).get(key);
  2102. }
  2103. /**
  2104. * Checks if a map value for `key` exists.
  2105. *
  2106. * @private
  2107. * @name has
  2108. * @memberOf MapCache
  2109. * @param {string} key The key of the entry to check.
  2110. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2111. */
  2112. function mapCacheHas(key) {
  2113. return getMapData(this, key).has(key);
  2114. }
  2115. /**
  2116. * Sets the map `key` to `value`.
  2117. *
  2118. * @private
  2119. * @name set
  2120. * @memberOf MapCache
  2121. * @param {string} key The key of the value to set.
  2122. * @param {*} value The value to set.
  2123. * @returns {Object} Returns the map cache instance.
  2124. */
  2125. function mapCacheSet(key, value) {
  2126. getMapData(this, key).set(key, value);
  2127. return this;
  2128. }
  2129. // Add methods to `MapCache`.
  2130. MapCache.prototype.clear = mapCacheClear;
  2131. MapCache.prototype['delete'] = mapCacheDelete;
  2132. MapCache.prototype.get = mapCacheGet;
  2133. MapCache.prototype.has = mapCacheHas;
  2134. MapCache.prototype.set = mapCacheSet;
  2135. /**
  2136. * Gets the index at which the `key` is found in `array` of key-value pairs.
  2137. *
  2138. * @private
  2139. * @param {Array} array The array to inspect.
  2140. * @param {*} key The key to search for.
  2141. * @returns {number} Returns the index of the matched value, else `-1`.
  2142. */
  2143. function assocIndexOf(array, key) {
  2144. var length = array.length;
  2145. while (length--) {
  2146. if (eq(array[length][0], key)) {
  2147. return length;
  2148. }
  2149. }
  2150. return -1;
  2151. }
  2152. /**
  2153. * The base implementation of `_.isNative` without bad shim checks.
  2154. *
  2155. * @private
  2156. * @param {*} value The value to check.
  2157. * @returns {boolean} Returns `true` if `value` is a native function,
  2158. * else `false`.
  2159. */
  2160. function baseIsNative(value) {
  2161. if (!isObject$2(value) || isMasked(value)) {
  2162. return false;
  2163. }
  2164. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  2165. return pattern.test(toSource(value));
  2166. }
  2167. /**
  2168. * Gets the data for `map`.
  2169. *
  2170. * @private
  2171. * @param {Object} map The map to query.
  2172. * @param {string} key The reference key.
  2173. * @returns {*} Returns the map data.
  2174. */
  2175. function getMapData(map, key) {
  2176. var data = map.__data__;
  2177. return isKeyable(key)
  2178. ? data[typeof key == 'string' ? 'string' : 'hash']
  2179. : data.map;
  2180. }
  2181. /**
  2182. * Gets the native function at `key` of `object`.
  2183. *
  2184. * @private
  2185. * @param {Object} object The object to query.
  2186. * @param {string} key The key of the method to get.
  2187. * @returns {*} Returns the function if it's native, else `undefined`.
  2188. */
  2189. function getNative(object, key) {
  2190. var value = getValue(object, key);
  2191. return baseIsNative(value) ? value : undefined;
  2192. }
  2193. /**
  2194. * Checks if `value` is suitable for use as unique object key.
  2195. *
  2196. * @private
  2197. * @param {*} value The value to check.
  2198. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  2199. */
  2200. function isKeyable(value) {
  2201. var type = typeof value;
  2202. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  2203. ? (value !== '__proto__')
  2204. : (value === null);
  2205. }
  2206. /**
  2207. * Checks if `func` has its source masked.
  2208. *
  2209. * @private
  2210. * @param {Function} func The function to check.
  2211. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  2212. */
  2213. function isMasked(func) {
  2214. return !!maskSrcKey && (maskSrcKey in func);
  2215. }
  2216. /**
  2217. * Converts `func` to its source code.
  2218. *
  2219. * @private
  2220. * @param {Function} func The function to process.
  2221. * @returns {string} Returns the source code.
  2222. */
  2223. function toSource(func) {
  2224. if (func != null) {
  2225. try {
  2226. return funcToString.call(func);
  2227. } catch (e) {}
  2228. try {
  2229. return (func + '');
  2230. } catch (e) {}
  2231. }
  2232. return '';
  2233. }
  2234. /**
  2235. * Creates a function that memoizes the result of `func`. If `resolver` is
  2236. * provided, it determines the cache key for storing the result based on the
  2237. * arguments provided to the memoized function. By default, the first argument
  2238. * provided to the memoized function is used as the map cache key. The `func`
  2239. * is invoked with the `this` binding of the memoized function.
  2240. *
  2241. * **Note:** The cache is exposed as the `cache` property on the memoized
  2242. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  2243. * constructor with one whose instances implement the
  2244. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  2245. * method interface of `delete`, `get`, `has`, and `set`.
  2246. *
  2247. * @static
  2248. * @memberOf _
  2249. * @since 0.1.0
  2250. * @category Function
  2251. * @param {Function} func The function to have its output memoized.
  2252. * @param {Function} [resolver] The function to resolve the cache key.
  2253. * @returns {Function} Returns the new memoized function.
  2254. * @example
  2255. *
  2256. * var object = { 'a': 1, 'b': 2 };
  2257. * var other = { 'c': 3, 'd': 4 };
  2258. *
  2259. * var values = _.memoize(_.values);
  2260. * values(object);
  2261. * // => [1, 2]
  2262. *
  2263. * values(other);
  2264. * // => [3, 4]
  2265. *
  2266. * object.a = 2;
  2267. * values(object);
  2268. * // => [1, 2]
  2269. *
  2270. * // Modify the result cache.
  2271. * values.cache.set(object, ['a', 'b']);
  2272. * values(object);
  2273. * // => ['a', 'b']
  2274. *
  2275. * // Replace `_.memoize.Cache`.
  2276. * _.memoize.Cache = WeakMap;
  2277. */
  2278. function memoize(func, resolver) {
  2279. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  2280. throw new TypeError(FUNC_ERROR_TEXT$2);
  2281. }
  2282. var memoized = function() {
  2283. var args = arguments,
  2284. key = resolver ? resolver.apply(this, args) : args[0],
  2285. cache = memoized.cache;
  2286. if (cache.has(key)) {
  2287. return cache.get(key);
  2288. }
  2289. var result = func.apply(this, args);
  2290. memoized.cache = cache.set(key, result);
  2291. return result;
  2292. };
  2293. memoized.cache = new (memoize.Cache || MapCache);
  2294. return memoized;
  2295. }
  2296. // Assign cache to `_.memoize`.
  2297. memoize.Cache = MapCache;
  2298. /**
  2299. * Performs a
  2300. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  2301. * comparison between two values to determine if they are equivalent.
  2302. *
  2303. * @static
  2304. * @memberOf _
  2305. * @since 4.0.0
  2306. * @category Lang
  2307. * @param {*} value The value to compare.
  2308. * @param {*} other The other value to compare.
  2309. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2310. * @example
  2311. *
  2312. * var object = { 'a': 1 };
  2313. * var other = { 'a': 1 };
  2314. *
  2315. * _.eq(object, object);
  2316. * // => true
  2317. *
  2318. * _.eq(object, other);
  2319. * // => false
  2320. *
  2321. * _.eq('a', 'a');
  2322. * // => true
  2323. *
  2324. * _.eq('a', Object('a'));
  2325. * // => false
  2326. *
  2327. * _.eq(NaN, NaN);
  2328. * // => true
  2329. */
  2330. function eq(value, other) {
  2331. return value === other || (value !== value && other !== other);
  2332. }
  2333. /**
  2334. * Checks if `value` is classified as a `Function` object.
  2335. *
  2336. * @static
  2337. * @memberOf _
  2338. * @since 0.1.0
  2339. * @category Lang
  2340. * @param {*} value The value to check.
  2341. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  2342. * @example
  2343. *
  2344. * _.isFunction(_);
  2345. * // => true
  2346. *
  2347. * _.isFunction(/abc/);
  2348. * // => false
  2349. */
  2350. function isFunction(value) {
  2351. // The use of `Object#toString` avoids issues with the `typeof` operator
  2352. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  2353. var tag = isObject$2(value) ? objectToString$2.call(value) : '';
  2354. return tag == funcTag || tag == genTag;
  2355. }
  2356. /**
  2357. * Checks if `value` is the
  2358. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  2359. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  2360. *
  2361. * @static
  2362. * @memberOf _
  2363. * @since 0.1.0
  2364. * @category Lang
  2365. * @param {*} value The value to check.
  2366. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  2367. * @example
  2368. *
  2369. * _.isObject({});
  2370. * // => true
  2371. *
  2372. * _.isObject([1, 2, 3]);
  2373. * // => true
  2374. *
  2375. * _.isObject(_.noop);
  2376. * // => true
  2377. *
  2378. * _.isObject(null);
  2379. * // => false
  2380. */
  2381. function isObject$2(value) {
  2382. var type = typeof value;
  2383. return !!value && (type == 'object' || type == 'function');
  2384. }
  2385. var lodash_memoize = memoize;
  2386. /**
  2387. * A collection of shims that provide minimal functionality of the ES6 collections.
  2388. *
  2389. * These implementations are not meant to be used outside of the ResizeObserver
  2390. * modules as they cover only a limited range of use cases.
  2391. */
  2392. /* eslint-disable require-jsdoc, valid-jsdoc */
  2393. var MapShim = (function () {
  2394. if (typeof Map !== 'undefined') {
  2395. return Map;
  2396. }
  2397. /**
  2398. * Returns index in provided array that matches the specified key.
  2399. *
  2400. * @param {Array<Array>} arr
  2401. * @param {*} key
  2402. * @returns {number}
  2403. */
  2404. function getIndex(arr, key) {
  2405. var result = -1;
  2406. arr.some(function (entry, index) {
  2407. if (entry[0] === key) {
  2408. result = index;
  2409. return true;
  2410. }
  2411. return false;
  2412. });
  2413. return result;
  2414. }
  2415. return /** @class */ (function () {
  2416. function class_1() {
  2417. this.__entries__ = [];
  2418. }
  2419. Object.defineProperty(class_1.prototype, "size", {
  2420. /**
  2421. * @returns {boolean}
  2422. */
  2423. get: function () {
  2424. return this.__entries__.length;
  2425. },
  2426. enumerable: true,
  2427. configurable: true
  2428. });
  2429. /**
  2430. * @param {*} key
  2431. * @returns {*}
  2432. */
  2433. class_1.prototype.get = function (key) {
  2434. var index = getIndex(this.__entries__, key);
  2435. var entry = this.__entries__[index];
  2436. return entry && entry[1];
  2437. };
  2438. /**
  2439. * @param {*} key
  2440. * @param {*} value
  2441. * @returns {void}
  2442. */
  2443. class_1.prototype.set = function (key, value) {
  2444. var index = getIndex(this.__entries__, key);
  2445. if (~index) {
  2446. this.__entries__[index][1] = value;
  2447. }
  2448. else {
  2449. this.__entries__.push([key, value]);
  2450. }
  2451. };
  2452. /**
  2453. * @param {*} key
  2454. * @returns {void}
  2455. */
  2456. class_1.prototype.delete = function (key) {
  2457. var entries = this.__entries__;
  2458. var index = getIndex(entries, key);
  2459. if (~index) {
  2460. entries.splice(index, 1);
  2461. }
  2462. };
  2463. /**
  2464. * @param {*} key
  2465. * @returns {void}
  2466. */
  2467. class_1.prototype.has = function (key) {
  2468. return !!~getIndex(this.__entries__, key);
  2469. };
  2470. /**
  2471. * @returns {void}
  2472. */
  2473. class_1.prototype.clear = function () {
  2474. this.__entries__.splice(0);
  2475. };
  2476. /**
  2477. * @param {Function} callback
  2478. * @param {*} [ctx=null]
  2479. * @returns {void}
  2480. */
  2481. class_1.prototype.forEach = function (callback, ctx) {
  2482. if (ctx === void 0) { ctx = null; }
  2483. for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
  2484. var entry = _a[_i];
  2485. callback.call(ctx, entry[1], entry[0]);
  2486. }
  2487. };
  2488. return class_1;
  2489. }());
  2490. })();
  2491. /**
  2492. * Detects whether window and document objects are available in current environment.
  2493. */
  2494. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
  2495. // Returns global object of a current environment.
  2496. var global$1 = (function () {
  2497. if (typeof global !== 'undefined' && global.Math === Math) {
  2498. return global;
  2499. }
  2500. if (typeof self !== 'undefined' && self.Math === Math) {
  2501. return self;
  2502. }
  2503. if (typeof window !== 'undefined' && window.Math === Math) {
  2504. return window;
  2505. }
  2506. // eslint-disable-next-line no-new-func
  2507. return Function('return this')();
  2508. })();
  2509. /**
  2510. * A shim for the requestAnimationFrame which falls back to the setTimeout if
  2511. * first one is not supported.
  2512. *
  2513. * @returns {number} Requests' identifier.
  2514. */
  2515. var requestAnimationFrame$1 = (function () {
  2516. if (typeof requestAnimationFrame === 'function') {
  2517. // It's required to use a bounded function because IE sometimes throws
  2518. // an "Invalid calling object" error if rAF is invoked without the global
  2519. // object on the left hand side.
  2520. return requestAnimationFrame.bind(global$1);
  2521. }
  2522. return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
  2523. })();
  2524. // Defines minimum timeout before adding a trailing call.
  2525. var trailingTimeout = 2;
  2526. /**
  2527. * Creates a wrapper function which ensures that provided callback will be
  2528. * invoked only once during the specified delay period.
  2529. *
  2530. * @param {Function} callback - Function to be invoked after the delay period.
  2531. * @param {number} delay - Delay after which to invoke callback.
  2532. * @returns {Function}
  2533. */
  2534. function throttle$1 (callback, delay) {
  2535. var leadingCall = false, trailingCall = false, lastCallTime = 0;
  2536. /**
  2537. * Invokes the original callback function and schedules new invocation if
  2538. * the "proxy" was called during current request.
  2539. *
  2540. * @returns {void}
  2541. */
  2542. function resolvePending() {
  2543. if (leadingCall) {
  2544. leadingCall = false;
  2545. callback();
  2546. }
  2547. if (trailingCall) {
  2548. proxy();
  2549. }
  2550. }
  2551. /**
  2552. * Callback invoked after the specified delay. It will further postpone
  2553. * invocation of the original function delegating it to the
  2554. * requestAnimationFrame.
  2555. *
  2556. * @returns {void}
  2557. */
  2558. function timeoutCallback() {
  2559. requestAnimationFrame$1(resolvePending);
  2560. }
  2561. /**
  2562. * Schedules invocation of the original function.
  2563. *
  2564. * @returns {void}
  2565. */
  2566. function proxy() {
  2567. var timeStamp = Date.now();
  2568. if (leadingCall) {
  2569. // Reject immediately following calls.
  2570. if (timeStamp - lastCallTime < trailingTimeout) {
  2571. return;
  2572. }
  2573. // Schedule new call to be in invoked when the pending one is resolved.
  2574. // This is important for "transitions" which never actually start
  2575. // immediately so there is a chance that we might miss one if change
  2576. // happens amids the pending invocation.
  2577. trailingCall = true;
  2578. }
  2579. else {
  2580. leadingCall = true;
  2581. trailingCall = false;
  2582. setTimeout(timeoutCallback, delay);
  2583. }
  2584. lastCallTime = timeStamp;
  2585. }
  2586. return proxy;
  2587. }
  2588. // Minimum delay before invoking the update of observers.
  2589. var REFRESH_DELAY = 20;
  2590. // A list of substrings of CSS properties used to find transition events that
  2591. // might affect dimensions of observed elements.
  2592. var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
  2593. // Check if MutationObserver is available.
  2594. var mutationObserverSupported = typeof MutationObserver !== 'undefined';
  2595. /**
  2596. * Singleton controller class which handles updates of ResizeObserver instances.
  2597. */
  2598. var ResizeObserverController = /** @class */ (function () {
  2599. /**
  2600. * Creates a new instance of ResizeObserverController.
  2601. *
  2602. * @private
  2603. */
  2604. function ResizeObserverController() {
  2605. /**
  2606. * Indicates whether DOM listeners have been added.
  2607. *
  2608. * @private {boolean}
  2609. */
  2610. this.connected_ = false;
  2611. /**
  2612. * Tells that controller has subscribed for Mutation Events.
  2613. *
  2614. * @private {boolean}
  2615. */
  2616. this.mutationEventsAdded_ = false;
  2617. /**
  2618. * Keeps reference to the instance of MutationObserver.
  2619. *
  2620. * @private {MutationObserver}
  2621. */
  2622. this.mutationsObserver_ = null;
  2623. /**
  2624. * A list of connected observers.
  2625. *
  2626. * @private {Array<ResizeObserverSPI>}
  2627. */
  2628. this.observers_ = [];
  2629. this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
  2630. this.refresh = throttle$1(this.refresh.bind(this), REFRESH_DELAY);
  2631. }
  2632. /**
  2633. * Adds observer to observers list.
  2634. *
  2635. * @param {ResizeObserverSPI} observer - Observer to be added.
  2636. * @returns {void}
  2637. */
  2638. ResizeObserverController.prototype.addObserver = function (observer) {
  2639. if (!~this.observers_.indexOf(observer)) {
  2640. this.observers_.push(observer);
  2641. }
  2642. // Add listeners if they haven't been added yet.
  2643. if (!this.connected_) {
  2644. this.connect_();
  2645. }
  2646. };
  2647. /**
  2648. * Removes observer from observers list.
  2649. *
  2650. * @param {ResizeObserverSPI} observer - Observer to be removed.
  2651. * @returns {void}
  2652. */
  2653. ResizeObserverController.prototype.removeObserver = function (observer) {
  2654. var observers = this.observers_;
  2655. var index = observers.indexOf(observer);
  2656. // Remove observer if it's present in registry.
  2657. if (~index) {
  2658. observers.splice(index, 1);
  2659. }
  2660. // Remove listeners if controller has no connected observers.
  2661. if (!observers.length && this.connected_) {
  2662. this.disconnect_();
  2663. }
  2664. };
  2665. /**
  2666. * Invokes the update of observers. It will continue running updates insofar
  2667. * it detects changes.
  2668. *
  2669. * @returns {void}
  2670. */
  2671. ResizeObserverController.prototype.refresh = function () {
  2672. var changesDetected = this.updateObservers_();
  2673. // Continue running updates if changes have been detected as there might
  2674. // be future ones caused by CSS transitions.
  2675. if (changesDetected) {
  2676. this.refresh();
  2677. }
  2678. };
  2679. /**
  2680. * Updates every observer from observers list and notifies them of queued
  2681. * entries.
  2682. *
  2683. * @private
  2684. * @returns {boolean} Returns "true" if any observer has detected changes in
  2685. * dimensions of it's elements.
  2686. */
  2687. ResizeObserverController.prototype.updateObservers_ = function () {
  2688. // Collect observers that have active observations.
  2689. var activeObservers = this.observers_.filter(function (observer) {
  2690. return observer.gatherActive(), observer.hasActive();
  2691. });
  2692. // Deliver notifications in a separate cycle in order to avoid any
  2693. // collisions between observers, e.g. when multiple instances of
  2694. // ResizeObserver are tracking the same element and the callback of one
  2695. // of them changes content dimensions of the observed target. Sometimes
  2696. // this may result in notifications being blocked for the rest of observers.
  2697. activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
  2698. return activeObservers.length > 0;
  2699. };
  2700. /**
  2701. * Initializes DOM listeners.
  2702. *
  2703. * @private
  2704. * @returns {void}
  2705. */
  2706. ResizeObserverController.prototype.connect_ = function () {
  2707. // Do nothing if running in a non-browser environment or if listeners
  2708. // have been already added.
  2709. if (!isBrowser || this.connected_) {
  2710. return;
  2711. }
  2712. // Subscription to the "Transitionend" event is used as a workaround for
  2713. // delayed transitions. This way it's possible to capture at least the
  2714. // final state of an element.
  2715. document.addEventListener('transitionend', this.onTransitionEnd_);
  2716. window.addEventListener('resize', this.refresh);
  2717. if (mutationObserverSupported) {
  2718. this.mutationsObserver_ = new MutationObserver(this.refresh);
  2719. this.mutationsObserver_.observe(document, {
  2720. attributes: true,
  2721. childList: true,
  2722. characterData: true,
  2723. subtree: true
  2724. });
  2725. }
  2726. else {
  2727. document.addEventListener('DOMSubtreeModified', this.refresh);
  2728. this.mutationEventsAdded_ = true;
  2729. }
  2730. this.connected_ = true;
  2731. };
  2732. /**
  2733. * Removes DOM listeners.
  2734. *
  2735. * @private
  2736. * @returns {void}
  2737. */
  2738. ResizeObserverController.prototype.disconnect_ = function () {
  2739. // Do nothing if running in a non-browser environment or if listeners
  2740. // have been already removed.
  2741. if (!isBrowser || !this.connected_) {
  2742. return;
  2743. }
  2744. document.removeEventListener('transitionend', this.onTransitionEnd_);
  2745. window.removeEventListener('resize', this.refresh);
  2746. if (this.mutationsObserver_) {
  2747. this.mutationsObserver_.disconnect();
  2748. }
  2749. if (this.mutationEventsAdded_) {
  2750. document.removeEventListener('DOMSubtreeModified', this.refresh);
  2751. }
  2752. this.mutationsObserver_ = null;
  2753. this.mutationEventsAdded_ = false;
  2754. this.connected_ = false;
  2755. };
  2756. /**
  2757. * "Transitionend" event handler.
  2758. *
  2759. * @private
  2760. * @param {TransitionEvent} event
  2761. * @returns {void}
  2762. */
  2763. ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
  2764. var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
  2765. // Detect whether transition may affect dimensions of an element.
  2766. var isReflowProperty = transitionKeys.some(function (key) {
  2767. return !!~propertyName.indexOf(key);
  2768. });
  2769. if (isReflowProperty) {
  2770. this.refresh();
  2771. }
  2772. };
  2773. /**
  2774. * Returns instance of the ResizeObserverController.
  2775. *
  2776. * @returns {ResizeObserverController}
  2777. */
  2778. ResizeObserverController.getInstance = function () {
  2779. if (!this.instance_) {
  2780. this.instance_ = new ResizeObserverController();
  2781. }
  2782. return this.instance_;
  2783. };
  2784. /**
  2785. * Holds reference to the controller's instance.
  2786. *
  2787. * @private {ResizeObserverController}
  2788. */
  2789. ResizeObserverController.instance_ = null;
  2790. return ResizeObserverController;
  2791. }());
  2792. /**
  2793. * Defines non-writable/enumerable properties of the provided target object.
  2794. *
  2795. * @param {Object} target - Object for which to define properties.
  2796. * @param {Object} props - Properties to be defined.
  2797. * @returns {Object} Target object.
  2798. */
  2799. var defineConfigurable = (function (target, props) {
  2800. for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
  2801. var key = _a[_i];
  2802. Object.defineProperty(target, key, {
  2803. value: props[key],
  2804. enumerable: false,
  2805. writable: false,
  2806. configurable: true
  2807. });
  2808. }
  2809. return target;
  2810. });
  2811. /**
  2812. * Returns the global object associated with provided element.
  2813. *
  2814. * @param {Object} target
  2815. * @returns {Object}
  2816. */
  2817. var getWindowOf = (function (target) {
  2818. // Assume that the element is an instance of Node, which means that it
  2819. // has the "ownerDocument" property from which we can retrieve a
  2820. // corresponding global object.
  2821. var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
  2822. // Return the local global object if it's not possible extract one from
  2823. // provided element.
  2824. return ownerGlobal || global$1;
  2825. });
  2826. // Placeholder of an empty content rectangle.
  2827. var emptyRect = createRectInit(0, 0, 0, 0);
  2828. /**
  2829. * Converts provided string to a number.
  2830. *
  2831. * @param {number|string} value
  2832. * @returns {number}
  2833. */
  2834. function toFloat(value) {
  2835. return parseFloat(value) || 0;
  2836. }
  2837. /**
  2838. * Extracts borders size from provided styles.
  2839. *
  2840. * @param {CSSStyleDeclaration} styles
  2841. * @param {...string} positions - Borders positions (top, right, ...)
  2842. * @returns {number}
  2843. */
  2844. function getBordersSize(styles) {
  2845. var positions = [];
  2846. for (var _i = 1; _i < arguments.length; _i++) {
  2847. positions[_i - 1] = arguments[_i];
  2848. }
  2849. return positions.reduce(function (size, position) {
  2850. var value = styles['border-' + position + '-width'];
  2851. return size + toFloat(value);
  2852. }, 0);
  2853. }
  2854. /**
  2855. * Extracts paddings sizes from provided styles.
  2856. *
  2857. * @param {CSSStyleDeclaration} styles
  2858. * @returns {Object} Paddings box.
  2859. */
  2860. function getPaddings(styles) {
  2861. var positions = ['top', 'right', 'bottom', 'left'];
  2862. var paddings = {};
  2863. for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
  2864. var position = positions_1[_i];
  2865. var value = styles['padding-' + position];
  2866. paddings[position] = toFloat(value);
  2867. }
  2868. return paddings;
  2869. }
  2870. /**
  2871. * Calculates content rectangle of provided SVG element.
  2872. *
  2873. * @param {SVGGraphicsElement} target - Element content rectangle of which needs
  2874. * to be calculated.
  2875. * @returns {DOMRectInit}
  2876. */
  2877. function getSVGContentRect(target) {
  2878. var bbox = target.getBBox();
  2879. return createRectInit(0, 0, bbox.width, bbox.height);
  2880. }
  2881. /**
  2882. * Calculates content rectangle of provided HTMLElement.
  2883. *
  2884. * @param {HTMLElement} target - Element for which to calculate the content rectangle.
  2885. * @returns {DOMRectInit}
  2886. */
  2887. function getHTMLElementContentRect(target) {
  2888. // Client width & height properties can't be
  2889. // used exclusively as they provide rounded values.
  2890. var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
  2891. // By this condition we can catch all non-replaced inline, hidden and
  2892. // detached elements. Though elements with width & height properties less
  2893. // than 0.5 will be discarded as well.
  2894. //
  2895. // Without it we would need to implement separate methods for each of
  2896. // those cases and it's not possible to perform a precise and performance
  2897. // effective test for hidden elements. E.g. even jQuery's ':visible' filter
  2898. // gives wrong results for elements with width & height less than 0.5.
  2899. if (!clientWidth && !clientHeight) {
  2900. return emptyRect;
  2901. }
  2902. var styles = getWindowOf(target).getComputedStyle(target);
  2903. var paddings = getPaddings(styles);
  2904. var horizPad = paddings.left + paddings.right;
  2905. var vertPad = paddings.top + paddings.bottom;
  2906. // Computed styles of width & height are being used because they are the
  2907. // only dimensions available to JS that contain non-rounded values. It could
  2908. // be possible to utilize the getBoundingClientRect if only it's data wasn't
  2909. // affected by CSS transformations let alone paddings, borders and scroll bars.
  2910. var width = toFloat(styles.width), height = toFloat(styles.height);
  2911. // Width & height include paddings and borders when the 'border-box' box
  2912. // model is applied (except for IE).
  2913. if (styles.boxSizing === 'border-box') {
  2914. // Following conditions are required to handle Internet Explorer which
  2915. // doesn't include paddings and borders to computed CSS dimensions.
  2916. //
  2917. // We can say that if CSS dimensions + paddings are equal to the "client"
  2918. // properties then it's either IE, and thus we don't need to subtract
  2919. // anything, or an element merely doesn't have paddings/borders styles.
  2920. if (Math.round(width + horizPad) !== clientWidth) {
  2921. width -= getBordersSize(styles, 'left', 'right') + horizPad;
  2922. }
  2923. if (Math.round(height + vertPad) !== clientHeight) {
  2924. height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
  2925. }
  2926. }
  2927. // Following steps can't be applied to the document's root element as its
  2928. // client[Width/Height] properties represent viewport area of the window.
  2929. // Besides, it's as well not necessary as the <html> itself neither has
  2930. // rendered scroll bars nor it can be clipped.
  2931. if (!isDocumentElement(target)) {
  2932. // In some browsers (only in Firefox, actually) CSS width & height
  2933. // include scroll bars size which can be removed at this step as scroll
  2934. // bars are the only difference between rounded dimensions + paddings
  2935. // and "client" properties, though that is not always true in Chrome.
  2936. var vertScrollbar = Math.round(width + horizPad) - clientWidth;
  2937. var horizScrollbar = Math.round(height + vertPad) - clientHeight;
  2938. // Chrome has a rather weird rounding of "client" properties.
  2939. // E.g. for an element with content width of 314.2px it sometimes gives
  2940. // the client width of 315px and for the width of 314.7px it may give
  2941. // 314px. And it doesn't happen all the time. So just ignore this delta
  2942. // as a non-relevant.
  2943. if (Math.abs(vertScrollbar) !== 1) {
  2944. width -= vertScrollbar;
  2945. }
  2946. if (Math.abs(horizScrollbar) !== 1) {
  2947. height -= horizScrollbar;
  2948. }
  2949. }
  2950. return createRectInit(paddings.left, paddings.top, width, height);
  2951. }
  2952. /**
  2953. * Checks whether provided element is an instance of the SVGGraphicsElement.
  2954. *
  2955. * @param {Element} target - Element to be checked.
  2956. * @returns {boolean}
  2957. */
  2958. var isSVGGraphicsElement = (function () {
  2959. // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
  2960. // interface.
  2961. if (typeof SVGGraphicsElement !== 'undefined') {
  2962. return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
  2963. }
  2964. // If it's so, then check that element is at least an instance of the
  2965. // SVGElement and that it has the "getBBox" method.
  2966. // eslint-disable-next-line no-extra-parens
  2967. return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
  2968. typeof target.getBBox === 'function'); };
  2969. })();
  2970. /**
  2971. * Checks whether provided element is a document element (<html>).
  2972. *
  2973. * @param {Element} target - Element to be checked.
  2974. * @returns {boolean}
  2975. */
  2976. function isDocumentElement(target) {
  2977. return target === getWindowOf(target).document.documentElement;
  2978. }
  2979. /**
  2980. * Calculates an appropriate content rectangle for provided html or svg element.
  2981. *
  2982. * @param {Element} target - Element content rectangle of which needs to be calculated.
  2983. * @returns {DOMRectInit}
  2984. */
  2985. function getContentRect(target) {
  2986. if (!isBrowser) {
  2987. return emptyRect;
  2988. }
  2989. if (isSVGGraphicsElement(target)) {
  2990. return getSVGContentRect(target);
  2991. }
  2992. return getHTMLElementContentRect(target);
  2993. }
  2994. /**
  2995. * Creates rectangle with an interface of the DOMRectReadOnly.
  2996. * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
  2997. *
  2998. * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
  2999. * @returns {DOMRectReadOnly}
  3000. */
  3001. function createReadOnlyRect(_a) {
  3002. var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
  3003. // If DOMRectReadOnly is available use it as a prototype for the rectangle.
  3004. var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
  3005. var rect = Object.create(Constr.prototype);
  3006. // Rectangle's properties are not writable and non-enumerable.
  3007. defineConfigurable(rect, {
  3008. x: x, y: y, width: width, height: height,
  3009. top: y,
  3010. right: x + width,
  3011. bottom: height + y,
  3012. left: x
  3013. });
  3014. return rect;
  3015. }
  3016. /**
  3017. * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
  3018. * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
  3019. *
  3020. * @param {number} x - X coordinate.
  3021. * @param {number} y - Y coordinate.
  3022. * @param {number} width - Rectangle's width.
  3023. * @param {number} height - Rectangle's height.
  3024. * @returns {DOMRectInit}
  3025. */
  3026. function createRectInit(x, y, width, height) {
  3027. return { x: x, y: y, width: width, height: height };
  3028. }
  3029. /**
  3030. * Class that is responsible for computations of the content rectangle of
  3031. * provided DOM element and for keeping track of it's changes.
  3032. */
  3033. var ResizeObservation = /** @class */ (function () {
  3034. /**
  3035. * Creates an instance of ResizeObservation.
  3036. *
  3037. * @param {Element} target - Element to be observed.
  3038. */
  3039. function ResizeObservation(target) {
  3040. /**
  3041. * Broadcasted width of content rectangle.
  3042. *
  3043. * @type {number}
  3044. */
  3045. this.broadcastWidth = 0;
  3046. /**
  3047. * Broadcasted height of content rectangle.
  3048. *
  3049. * @type {number}
  3050. */
  3051. this.broadcastHeight = 0;
  3052. /**
  3053. * Reference to the last observed content rectangle.
  3054. *
  3055. * @private {DOMRectInit}
  3056. */
  3057. this.contentRect_ = createRectInit(0, 0, 0, 0);
  3058. this.target = target;
  3059. }
  3060. /**
  3061. * Updates content rectangle and tells whether it's width or height properties
  3062. * have changed since the last broadcast.
  3063. *
  3064. * @returns {boolean}
  3065. */
  3066. ResizeObservation.prototype.isActive = function () {
  3067. var rect = getContentRect(this.target);
  3068. this.contentRect_ = rect;
  3069. return (rect.width !== this.broadcastWidth ||
  3070. rect.height !== this.broadcastHeight);
  3071. };
  3072. /**
  3073. * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
  3074. * from the corresponding properties of the last observed content rectangle.
  3075. *
  3076. * @returns {DOMRectInit} Last observed content rectangle.
  3077. */
  3078. ResizeObservation.prototype.broadcastRect = function () {
  3079. var rect = this.contentRect_;
  3080. this.broadcastWidth = rect.width;
  3081. this.broadcastHeight = rect.height;
  3082. return rect;
  3083. };
  3084. return ResizeObservation;
  3085. }());
  3086. var ResizeObserverEntry = /** @class */ (function () {
  3087. /**
  3088. * Creates an instance of ResizeObserverEntry.
  3089. *
  3090. * @param {Element} target - Element that is being observed.
  3091. * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
  3092. */
  3093. function ResizeObserverEntry(target, rectInit) {
  3094. var contentRect = createReadOnlyRect(rectInit);
  3095. // According to the specification following properties are not writable
  3096. // and are also not enumerable in the native implementation.
  3097. //
  3098. // Property accessors are not being used as they'd require to define a
  3099. // private WeakMap storage which may cause memory leaks in browsers that
  3100. // don't support this type of collections.
  3101. defineConfigurable(this, { target: target, contentRect: contentRect });
  3102. }
  3103. return ResizeObserverEntry;
  3104. }());
  3105. var ResizeObserverSPI = /** @class */ (function () {
  3106. /**
  3107. * Creates a new instance of ResizeObserver.
  3108. *
  3109. * @param {ResizeObserverCallback} callback - Callback function that is invoked
  3110. * when one of the observed elements changes it's content dimensions.
  3111. * @param {ResizeObserverController} controller - Controller instance which
  3112. * is responsible for the updates of observer.
  3113. * @param {ResizeObserver} callbackCtx - Reference to the public
  3114. * ResizeObserver instance which will be passed to callback function.
  3115. */
  3116. function ResizeObserverSPI(callback, controller, callbackCtx) {
  3117. /**
  3118. * Collection of resize observations that have detected changes in dimensions
  3119. * of elements.
  3120. *
  3121. * @private {Array<ResizeObservation>}
  3122. */
  3123. this.activeObservations_ = [];
  3124. /**
  3125. * Registry of the ResizeObservation instances.
  3126. *
  3127. * @private {Map<Element, ResizeObservation>}
  3128. */
  3129. this.observations_ = new MapShim();
  3130. if (typeof callback !== 'function') {
  3131. throw new TypeError('The callback provided as parameter 1 is not a function.');
  3132. }
  3133. this.callback_ = callback;
  3134. this.controller_ = controller;
  3135. this.callbackCtx_ = callbackCtx;
  3136. }
  3137. /**
  3138. * Starts observing provided element.
  3139. *
  3140. * @param {Element} target - Element to be observed.
  3141. * @returns {void}
  3142. */
  3143. ResizeObserverSPI.prototype.observe = function (target) {
  3144. if (!arguments.length) {
  3145. throw new TypeError('1 argument required, but only 0 present.');
  3146. }
  3147. // Do nothing if current environment doesn't have the Element interface.
  3148. if (typeof Element === 'undefined' || !(Element instanceof Object)) {
  3149. return;
  3150. }
  3151. if (!(target instanceof getWindowOf(target).Element)) {
  3152. throw new TypeError('parameter 1 is not of type "Element".');
  3153. }
  3154. var observations = this.observations_;
  3155. // Do nothing if element is already being observed.
  3156. if (observations.has(target)) {
  3157. return;
  3158. }
  3159. observations.set(target, new ResizeObservation(target));
  3160. this.controller_.addObserver(this);
  3161. // Force the update of observations.
  3162. this.controller_.refresh();
  3163. };
  3164. /**
  3165. * Stops observing provided element.
  3166. *
  3167. * @param {Element} target - Element to stop observing.
  3168. * @returns {void}
  3169. */
  3170. ResizeObserverSPI.prototype.unobserve = function (target) {
  3171. if (!arguments.length) {
  3172. throw new TypeError('1 argument required, but only 0 present.');
  3173. }
  3174. // Do nothing if current environment doesn't have the Element interface.
  3175. if (typeof Element === 'undefined' || !(Element instanceof Object)) {
  3176. return;
  3177. }
  3178. if (!(target instanceof getWindowOf(target).Element)) {
  3179. throw new TypeError('parameter 1 is not of type "Element".');
  3180. }
  3181. var observations = this.observations_;
  3182. // Do nothing if element is not being observed.
  3183. if (!observations.has(target)) {
  3184. return;
  3185. }
  3186. observations.delete(target);
  3187. if (!observations.size) {
  3188. this.controller_.removeObserver(this);
  3189. }
  3190. };
  3191. /**
  3192. * Stops observing all elements.
  3193. *
  3194. * @returns {void}
  3195. */
  3196. ResizeObserverSPI.prototype.disconnect = function () {
  3197. this.clearActive();
  3198. this.observations_.clear();
  3199. this.controller_.removeObserver(this);
  3200. };
  3201. /**
  3202. * Collects observation instances the associated element of which has changed
  3203. * it's content rectangle.
  3204. *
  3205. * @returns {void}
  3206. */
  3207. ResizeObserverSPI.prototype.gatherActive = function () {
  3208. var _this = this;
  3209. this.clearActive();
  3210. this.observations_.forEach(function (observation) {
  3211. if (observation.isActive()) {
  3212. _this.activeObservations_.push(observation);
  3213. }
  3214. });
  3215. };
  3216. /**
  3217. * Invokes initial callback function with a list of ResizeObserverEntry
  3218. * instances collected from active resize observations.
  3219. *
  3220. * @returns {void}
  3221. */
  3222. ResizeObserverSPI.prototype.broadcastActive = function () {
  3223. // Do nothing if observer doesn't have active observations.
  3224. if (!this.hasActive()) {
  3225. return;
  3226. }
  3227. var ctx = this.callbackCtx_;
  3228. // Create ResizeObserverEntry instance for every active observation.
  3229. var entries = this.activeObservations_.map(function (observation) {
  3230. return new ResizeObserverEntry(observation.target, observation.broadcastRect());
  3231. });
  3232. this.callback_.call(ctx, entries, ctx);
  3233. this.clearActive();
  3234. };
  3235. /**
  3236. * Clears the collection of active observations.
  3237. *
  3238. * @returns {void}
  3239. */
  3240. ResizeObserverSPI.prototype.clearActive = function () {
  3241. this.activeObservations_.splice(0);
  3242. };
  3243. /**
  3244. * Tells whether observer has active observations.
  3245. *
  3246. * @returns {boolean}
  3247. */
  3248. ResizeObserverSPI.prototype.hasActive = function () {
  3249. return this.activeObservations_.length > 0;
  3250. };
  3251. return ResizeObserverSPI;
  3252. }());
  3253. // Registry of internal observers. If WeakMap is not available use current shim
  3254. // for the Map collection as it has all required methods and because WeakMap
  3255. // can't be fully polyfilled anyway.
  3256. var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
  3257. /**
  3258. * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
  3259. * exposing only those methods and properties that are defined in the spec.
  3260. */
  3261. var ResizeObserver = /** @class */ (function () {
  3262. /**
  3263. * Creates a new instance of ResizeObserver.
  3264. *
  3265. * @param {ResizeObserverCallback} callback - Callback that is invoked when
  3266. * dimensions of the observed elements change.
  3267. */
  3268. function ResizeObserver(callback) {
  3269. if (!(this instanceof ResizeObserver)) {
  3270. throw new TypeError('Cannot call a class as a function.');
  3271. }
  3272. if (!arguments.length) {
  3273. throw new TypeError('1 argument required, but only 0 present.');
  3274. }
  3275. var controller = ResizeObserverController.getInstance();
  3276. var observer = new ResizeObserverSPI(callback, controller, this);
  3277. observers.set(this, observer);
  3278. }
  3279. return ResizeObserver;
  3280. }());
  3281. // Expose public methods of ResizeObserver.
  3282. [
  3283. 'observe',
  3284. 'unobserve',
  3285. 'disconnect'
  3286. ].forEach(function (method) {
  3287. ResizeObserver.prototype[method] = function () {
  3288. var _a;
  3289. return (_a = observers.get(this))[method].apply(_a, arguments);
  3290. };
  3291. });
  3292. var index = (function () {
  3293. // Export existing implementation if available.
  3294. if (typeof global$1.ResizeObserver !== 'undefined') {
  3295. return global$1.ResizeObserver;
  3296. }
  3297. return ResizeObserver;
  3298. })();
  3299. var canUseDOM = !!(
  3300. typeof window !== 'undefined' &&
  3301. window.document &&
  3302. window.document.createElement
  3303. );
  3304. var canUseDom = canUseDOM;
  3305. var SimpleBar =
  3306. /*#__PURE__*/
  3307. function () {
  3308. function SimpleBar(element, options) {
  3309. var _this = this;
  3310. _classCallCheck(this, SimpleBar);
  3311. this.onScroll = function () {
  3312. if (!_this.scrollXTicking) {
  3313. window.requestAnimationFrame(_this.scrollX);
  3314. _this.scrollXTicking = true;
  3315. }
  3316. if (!_this.scrollYTicking) {
  3317. window.requestAnimationFrame(_this.scrollY);
  3318. _this.scrollYTicking = true;
  3319. }
  3320. };
  3321. this.scrollX = function () {
  3322. if (_this.axis.x.isOverflowing) {
  3323. _this.showScrollbar('x');
  3324. _this.positionScrollbar('x');
  3325. }
  3326. _this.scrollXTicking = false;
  3327. };
  3328. this.scrollY = function () {
  3329. if (_this.axis.y.isOverflowing) {
  3330. _this.showScrollbar('y');
  3331. _this.positionScrollbar('y');
  3332. }
  3333. _this.scrollYTicking = false;
  3334. };
  3335. this.onMouseEnter = function () {
  3336. _this.showScrollbar('x');
  3337. _this.showScrollbar('y');
  3338. };
  3339. this.onMouseMove = function (e) {
  3340. _this.mouseX = e.clientX;
  3341. _this.mouseY = e.clientY;
  3342. if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
  3343. _this.onMouseMoveForAxis('x');
  3344. }
  3345. if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
  3346. _this.onMouseMoveForAxis('y');
  3347. }
  3348. };
  3349. this.onMouseLeave = function () {
  3350. _this.onMouseMove.cancel();
  3351. if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
  3352. _this.onMouseLeaveForAxis('x');
  3353. }
  3354. if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
  3355. _this.onMouseLeaveForAxis('y');
  3356. }
  3357. _this.mouseX = -1;
  3358. _this.mouseY = -1;
  3359. };
  3360. this.onWindowResize = function () {
  3361. // Recalculate scrollbarWidth in case it's a zoom
  3362. _this.scrollbarWidth = scrollbarWidth();
  3363. _this.hideNativeScrollbar();
  3364. };
  3365. this.hideScrollbars = function () {
  3366. _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
  3367. _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
  3368. if (!_this.isWithinBounds(_this.axis.y.track.rect)) {
  3369. _this.axis.y.scrollbar.el.classList.remove(_this.classNames.visible);
  3370. _this.axis.y.isVisible = false;
  3371. }
  3372. if (!_this.isWithinBounds(_this.axis.x.track.rect)) {
  3373. _this.axis.x.scrollbar.el.classList.remove(_this.classNames.visible);
  3374. _this.axis.x.isVisible = false;
  3375. }
  3376. };
  3377. this.onPointerEvent = function (e) {
  3378. var isWithinBoundsY, isWithinBoundsX;
  3379. _this.axis.x.scrollbar.rect = _this.axis.x.scrollbar.el.getBoundingClientRect();
  3380. _this.axis.y.scrollbar.rect = _this.axis.y.scrollbar.el.getBoundingClientRect();
  3381. if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
  3382. isWithinBoundsX = _this.isWithinBounds(_this.axis.x.scrollbar.rect);
  3383. }
  3384. if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
  3385. isWithinBoundsY = _this.isWithinBounds(_this.axis.y.scrollbar.rect);
  3386. } // If any pointer event is called on the scrollbar
  3387. if (isWithinBoundsY || isWithinBoundsX) {
  3388. // Preventing the event's default action stops text being
  3389. // selectable during the drag.
  3390. e.preventDefault(); // Prevent event leaking
  3391. e.stopPropagation();
  3392. if (e.type === 'mousedown') {
  3393. if (isWithinBoundsY) {
  3394. _this.onDragStart(e, 'y');
  3395. }
  3396. if (isWithinBoundsX) {
  3397. _this.onDragStart(e, 'x');
  3398. }
  3399. }
  3400. }
  3401. };
  3402. this.drag = function (e) {
  3403. var eventOffset;
  3404. var track = _this.axis[_this.draggedAxis].track;
  3405. var trackSize = track.rect[_this.axis[_this.draggedAxis].sizeAttr];
  3406. var scrollbar = _this.axis[_this.draggedAxis].scrollbar;
  3407. e.preventDefault();
  3408. e.stopPropagation();
  3409. if (_this.draggedAxis === 'y') {
  3410. eventOffset = e.pageY;
  3411. } else {
  3412. eventOffset = e.pageX;
  3413. } // Calculate how far the user's mouse is from the top/left of the scrollbar (minus the dragOffset).
  3414. var dragPos = eventOffset - track.rect[_this.axis[_this.draggedAxis].offsetAttr] - _this.axis[_this.draggedAxis].dragOffset; // Convert the mouse position into a percentage of the scrollbar height/width.
  3415. var dragPerc = dragPos / track.rect[_this.axis[_this.draggedAxis].sizeAttr]; // Scroll the content by the same percentage.
  3416. var scrollPos = dragPerc * _this.contentEl[_this.axis[_this.draggedAxis].scrollSizeAttr]; // Fix browsers inconsistency on RTL
  3417. if (_this.draggedAxis === 'x') {
  3418. scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
  3419. scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
  3420. }
  3421. _this.contentEl[_this.axis[_this.draggedAxis].scrollOffsetAttr] = scrollPos;
  3422. };
  3423. this.onEndDrag = function (e) {
  3424. e.preventDefault();
  3425. e.stopPropagation();
  3426. document.removeEventListener('mousemove', _this.drag);
  3427. document.removeEventListener('mouseup', _this.onEndDrag);
  3428. };
  3429. this.el = element;
  3430. this.flashTimeout;
  3431. this.contentEl;
  3432. this.offsetEl;
  3433. this.maskEl;
  3434. this.globalObserver;
  3435. this.mutationObserver;
  3436. this.resizeObserver;
  3437. this.scrollbarWidth;
  3438. this.minScrollbarWidth = 20;
  3439. this.options = _objectSpread({}, SimpleBar.defaultOptions, options);
  3440. this.classNames = _objectSpread({}, SimpleBar.defaultOptions.classNames, this.options.classNames);
  3441. this.isRtl;
  3442. this.axis = {
  3443. x: {
  3444. scrollOffsetAttr: 'scrollLeft',
  3445. sizeAttr: 'width',
  3446. scrollSizeAttr: 'scrollWidth',
  3447. offsetAttr: 'left',
  3448. overflowAttr: 'overflowX',
  3449. dragOffset: 0,
  3450. isOverflowing: true,
  3451. isVisible: false,
  3452. forceVisible: false,
  3453. track: {},
  3454. scrollbar: {}
  3455. },
  3456. y: {
  3457. scrollOffsetAttr: 'scrollTop',
  3458. sizeAttr: 'height',
  3459. scrollSizeAttr: 'scrollHeight',
  3460. offsetAttr: 'top',
  3461. overflowAttr: 'overflowY',
  3462. dragOffset: 0,
  3463. isOverflowing: true,
  3464. isVisible: false,
  3465. forceVisible: false,
  3466. track: {},
  3467. scrollbar: {}
  3468. }
  3469. };
  3470. this.recalculate = lodash_throttle(this.recalculate.bind(this), 64);
  3471. this.onMouseMove = lodash_throttle(this.onMouseMove.bind(this), 64);
  3472. this.hideScrollbars = lodash_debounce(this.hideScrollbars.bind(this), this.options.timeout);
  3473. this.onWindowResize = lodash_debounce(this.onWindowResize.bind(this), 64, {
  3474. leading: true
  3475. });
  3476. SimpleBar.getRtlHelpers = lodash_memoize(SimpleBar.getRtlHelpers); // getContentElement is deprecated
  3477. this.getContentElement = this.getScrollElement;
  3478. this.init();
  3479. }
  3480. /**
  3481. * Static properties
  3482. */
  3483. /**
  3484. * Helper to fix browsers inconsistency on RTL:
  3485. * - Firefox inverts the scrollbar initial position
  3486. * - IE11 inverts both scrollbar position and scrolling offset
  3487. * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
  3488. */
  3489. _createClass(SimpleBar, [{
  3490. key: "init",
  3491. value: function init() {
  3492. // Save a reference to the instance, so we know this DOM node has already been instancied
  3493. this.el.SimpleBar = this; // We stop here on server-side
  3494. if (canUseDom) {
  3495. this.initDOM();
  3496. this.scrollbarWidth = scrollbarWidth();
  3497. this.recalculate();
  3498. this.initListeners();
  3499. }
  3500. }
  3501. }, {
  3502. key: "initDOM",
  3503. value: function initDOM() {
  3504. var _this2 = this;
  3505. // make sure this element doesn't have the elements yet
  3506. if (Array.from(this.el.children).filter(function (child) {
  3507. return child.classList.contains(_this2.classNames.wrapper);
  3508. }).length) {
  3509. // assume that element has his DOM already initiated
  3510. this.wrapperEl = this.el.querySelector(".".concat(this.classNames.wrapper));
  3511. this.contentEl = this.el.querySelector(".".concat(this.classNames.content));
  3512. this.offsetEl = this.el.querySelector(".".concat(this.classNames.offset));
  3513. this.maskEl = this.el.querySelector(".".concat(this.classNames.mask));
  3514. this.placeholderEl = this.el.querySelector(".".concat(this.classNames.placeholder));
  3515. this.heightAutoObserverWrapperEl = this.el.querySelector(".".concat(this.classNames.heightAutoObserverWrapperEl));
  3516. this.heightAutoObserverEl = this.el.querySelector(".".concat(this.classNames.heightAutoObserverEl));
  3517. this.axis.x.track.el = this.el.querySelector(".".concat(this.classNames.track, ".").concat(this.classNames.horizontal));
  3518. this.axis.y.track.el = this.el.querySelector(".".concat(this.classNames.track, ".").concat(this.classNames.vertical));
  3519. } else {
  3520. // Prepare DOM
  3521. this.wrapperEl = document.createElement('div');
  3522. this.contentEl = document.createElement('div');
  3523. this.offsetEl = document.createElement('div');
  3524. this.maskEl = document.createElement('div');
  3525. this.placeholderEl = document.createElement('div');
  3526. this.heightAutoObserverWrapperEl = document.createElement('div');
  3527. this.heightAutoObserverEl = document.createElement('div');
  3528. this.wrapperEl.classList.add(this.classNames.wrapper);
  3529. this.contentEl.classList.add(this.classNames.content);
  3530. this.offsetEl.classList.add(this.classNames.offset);
  3531. this.maskEl.classList.add(this.classNames.mask);
  3532. this.placeholderEl.classList.add(this.classNames.placeholder);
  3533. this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl);
  3534. this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);
  3535. while (this.el.firstChild) {
  3536. this.contentEl.appendChild(this.el.firstChild);
  3537. }
  3538. this.offsetEl.appendChild(this.contentEl);
  3539. this.maskEl.appendChild(this.offsetEl);
  3540. this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl);
  3541. this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl);
  3542. this.wrapperEl.appendChild(this.maskEl);
  3543. this.wrapperEl.appendChild(this.placeholderEl);
  3544. this.el.appendChild(this.wrapperEl);
  3545. }
  3546. if (!this.axis.x.track.el || !this.axis.y.track.el) {
  3547. var track = document.createElement('div');
  3548. var scrollbar = document.createElement('div');
  3549. track.classList.add(this.classNames.track);
  3550. scrollbar.classList.add(this.classNames.scrollbar);
  3551. if (!this.options.autoHide) {
  3552. scrollbar.classList.add(this.classNames.visible);
  3553. }
  3554. track.appendChild(scrollbar);
  3555. this.axis.x.track.el = track.cloneNode(true);
  3556. this.axis.x.track.el.classList.add(this.classNames.horizontal);
  3557. this.axis.y.track.el = track.cloneNode(true);
  3558. this.axis.y.track.el.classList.add(this.classNames.vertical);
  3559. this.el.appendChild(this.axis.x.track.el);
  3560. this.el.appendChild(this.axis.y.track.el);
  3561. }
  3562. this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector(".".concat(this.classNames.scrollbar));
  3563. this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector(".".concat(this.classNames.scrollbar));
  3564. this.el.setAttribute('data-simplebar', 'init');
  3565. }
  3566. }, {
  3567. key: "initListeners",
  3568. value: function initListeners() {
  3569. var _this3 = this;
  3570. // Event listeners
  3571. if (this.options.autoHide) {
  3572. this.el.addEventListener('mouseenter', this.onMouseEnter);
  3573. }
  3574. ['mousedown', 'click', 'dblclick', 'touchstart', 'touchend', 'touchmove'].forEach(function (e) {
  3575. _this3.el.addEventListener(e, _this3.onPointerEvent, true);
  3576. });
  3577. this.el.addEventListener('mousemove', this.onMouseMove);
  3578. this.el.addEventListener('mouseleave', this.onMouseLeave);
  3579. this.contentEl.addEventListener('scroll', this.onScroll); // Browser zoom triggers a window resize
  3580. window.addEventListener('resize', this.onWindowResize); // MutationObserver is IE11+
  3581. if (typeof MutationObserver !== 'undefined') {
  3582. // create an observer instance
  3583. this.mutationObserver = new MutationObserver(function (mutations) {
  3584. mutations.forEach(function (mutation) {
  3585. if (mutation.target === _this3.el || !_this3.isChildNode(mutation.target) || mutation.addedNodes.length || mutation.removedNodes.length) {
  3586. _this3.recalculate();
  3587. }
  3588. });
  3589. }); // pass in the target node, as well as the observer options
  3590. this.mutationObserver.observe(this.el, {
  3591. attributes: true,
  3592. childList: true,
  3593. characterData: true,
  3594. subtree: true
  3595. });
  3596. }
  3597. this.resizeObserver = new index(this.recalculate);
  3598. this.resizeObserver.observe(this.el);
  3599. }
  3600. }, {
  3601. key: "recalculate",
  3602. value: function recalculate() {
  3603. var isHeightAuto = this.heightAutoObserverEl.offsetHeight <= 1;
  3604. this.elStyles = window.getComputedStyle(this.el);
  3605. this.isRtl = this.elStyles.direction === 'rtl';
  3606. this.contentEl.style.padding = "".concat(this.elStyles.paddingTop, " ").concat(this.elStyles.paddingRight, " ").concat(this.elStyles.paddingBottom, " ").concat(this.elStyles.paddingLeft);
  3607. this.contentEl.style.height = isHeightAuto ? 'auto' : '100%';
  3608. this.placeholderEl.style.width = "".concat(this.contentEl.scrollWidth, "px");
  3609. this.placeholderEl.style.height = "".concat(this.contentEl.scrollHeight, "px");
  3610. this.wrapperEl.style.margin = "-".concat(this.elStyles.paddingTop, " -").concat(this.elStyles.paddingRight, " -").concat(this.elStyles.paddingBottom, " -").concat(this.elStyles.paddingLeft);
  3611. this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
  3612. this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect(); // Set isOverflowing to false if scrollbar is not necessary (content is shorter than offset)
  3613. this.axis.x.isOverflowing = (this.scrollbarWidth ? this.contentEl.scrollWidth : this.contentEl.scrollWidth - this.minScrollbarWidth) > Math.ceil(this.axis.x.track.rect.width);
  3614. this.axis.y.isOverflowing = (this.scrollbarWidth ? this.contentEl.scrollHeight : this.contentEl.scrollHeight - this.minScrollbarWidth) > Math.ceil(this.axis.y.track.rect.height); // Set isOverflowing to false if user explicitely set hidden overflow
  3615. this.axis.x.isOverflowing = this.elStyles.overflowX === 'hidden' ? false : this.axis.x.isOverflowing;
  3616. this.axis.y.isOverflowing = this.elStyles.overflowY === 'hidden' ? false : this.axis.y.isOverflowing;
  3617. this.axis.x.forceVisible = this.options.forceVisible === "x" || this.options.forceVisible === true;
  3618. this.axis.y.forceVisible = this.options.forceVisible === "y" || this.options.forceVisible === true;
  3619. this.axis.x.scrollbar.size = this.getScrollbarSize('x');
  3620. this.axis.y.scrollbar.size = this.getScrollbarSize('y');
  3621. this.axis.x.scrollbar.el.style.width = "".concat(this.axis.x.scrollbar.size, "px");
  3622. this.axis.y.scrollbar.el.style.height = "".concat(this.axis.y.scrollbar.size, "px");
  3623. this.positionScrollbar('x');
  3624. this.positionScrollbar('y');
  3625. this.toggleTrackVisibility('x');
  3626. this.toggleTrackVisibility('y');
  3627. this.hideNativeScrollbar();
  3628. }
  3629. /**
  3630. * Calculate scrollbar size
  3631. */
  3632. }, {
  3633. key: "getScrollbarSize",
  3634. value: function getScrollbarSize() {
  3635. var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
  3636. var contentSize = this.scrollbarWidth ? this.contentEl[this.axis[axis].scrollSizeAttr] : this.contentEl[this.axis[axis].scrollSizeAttr] - this.minScrollbarWidth;
  3637. var trackSize = this.axis[axis].track.rect[this.axis[axis].sizeAttr];
  3638. var scrollbarSize;
  3639. if (!this.axis[axis].isOverflowing) {
  3640. return;
  3641. }
  3642. var scrollbarRatio = trackSize / contentSize; // Calculate new height/position of drag handle.
  3643. scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
  3644. if (this.options.scrollbarMaxSize) {
  3645. scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
  3646. }
  3647. return scrollbarSize;
  3648. }
  3649. }, {
  3650. key: "positionScrollbar",
  3651. value: function positionScrollbar() {
  3652. var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
  3653. var contentSize = this.contentEl[this.axis[axis].scrollSizeAttr];
  3654. var trackSize = this.axis[axis].track.rect[this.axis[axis].sizeAttr];
  3655. var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
  3656. var scrollbar = this.axis[axis].scrollbar;
  3657. var scrollOffset = this.contentEl[this.axis[axis].scrollOffsetAttr];
  3658. scrollOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
  3659. var scrollPourcent = scrollOffset / (contentSize - hostSize);
  3660. var handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
  3661. handleOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
  3662. scrollbar.el.style.transform = axis === 'x' ? "translate3d(".concat(handleOffset, "px, 0, 0)") : "translate3d(0, ".concat(handleOffset, "px, 0)");
  3663. }
  3664. }, {
  3665. key: "toggleTrackVisibility",
  3666. value: function toggleTrackVisibility() {
  3667. var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
  3668. var track = this.axis[axis].track.el;
  3669. var scrollbar = this.axis[axis].scrollbar.el;
  3670. if (this.axis[axis].isOverflowing || this.axis[axis].forceVisible) {
  3671. track.style.visibility = 'visible';
  3672. this.contentEl.style[this.axis[axis].overflowAttr] = 'scroll';
  3673. } else {
  3674. track.style.visibility = 'hidden';
  3675. this.contentEl.style[this.axis[axis].overflowAttr] = 'hidden';
  3676. } // Even if forceVisible is enabled, scrollbar itself should be hidden
  3677. if (this.axis[axis].isOverflowing) {
  3678. scrollbar.style.visibility = 'visible';
  3679. } else {
  3680. scrollbar.style.visibility = 'hidden';
  3681. }
  3682. }
  3683. }, {
  3684. key: "hideNativeScrollbar",
  3685. value: function hideNativeScrollbar() {
  3686. this.offsetEl.style[this.isRtl ? 'left' : 'right'] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? "-".concat(this.scrollbarWidth || this.minScrollbarWidth, "px") : 0;
  3687. this.offsetEl.style.bottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? "-".concat(this.scrollbarWidth || this.minScrollbarWidth, "px") : 0; // If floating scrollbar
  3688. if (!this.scrollbarWidth) {
  3689. var paddingDirection = [this.isRtl ? 'paddingLeft' : 'paddingRight'];
  3690. this.contentEl.style[paddingDirection] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? "calc(".concat(this.elStyles[paddingDirection], " + ").concat(this.minScrollbarWidth, "px)") : this.elStyles[paddingDirection];
  3691. this.contentEl.style.paddingBottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? "calc(".concat(this.elStyles.paddingBottom, " + ").concat(this.minScrollbarWidth, "px)") : this.elStyles.paddingBottom;
  3692. }
  3693. }
  3694. /**
  3695. * On scroll event handling
  3696. */
  3697. }, {
  3698. key: "onMouseMoveForAxis",
  3699. value: function onMouseMoveForAxis() {
  3700. var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
  3701. this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
  3702. this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
  3703. var isWithinScrollbarBoundsX = this.isWithinBounds(this.axis[axis].scrollbar.rect);
  3704. if (isWithinScrollbarBoundsX) {
  3705. this.axis[axis].scrollbar.el.classList.add(this.classNames.hover);
  3706. } else {
  3707. this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
  3708. }
  3709. if (this.isWithinBounds(this.axis[axis].track.rect)) {
  3710. this.showScrollbar(axis);
  3711. this.axis[axis].track.el.classList.add(this.classNames.hover);
  3712. } else {
  3713. this.axis[axis].track.el.classList.remove(this.classNames.hover);
  3714. }
  3715. }
  3716. }, {
  3717. key: "onMouseLeaveForAxis",
  3718. value: function onMouseLeaveForAxis() {
  3719. var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
  3720. this.axis[axis].track.el.classList.remove(this.classNames.hover);
  3721. this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
  3722. }
  3723. }, {
  3724. key: "showScrollbar",
  3725. /**
  3726. * Show scrollbar
  3727. */
  3728. value: function showScrollbar() {
  3729. var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
  3730. var scrollbar = this.axis[axis].scrollbar.el;
  3731. if (!this.axis[axis].isVisible) {
  3732. scrollbar.classList.add(this.classNames.visible);
  3733. this.axis[axis].isVisible = true;
  3734. }
  3735. if (this.options.autoHide) {
  3736. this.hideScrollbars();
  3737. }
  3738. }
  3739. /**
  3740. * Hide Scrollbar
  3741. */
  3742. }, {
  3743. key: "onDragStart",
  3744. /**
  3745. * on scrollbar handle drag movement starts
  3746. */
  3747. value: function onDragStart(e) {
  3748. var axis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'y';
  3749. var scrollbar = this.axis[axis].scrollbar.el; // Measure how far the user's mouse is from the top of the scrollbar drag handle.
  3750. var eventOffset = axis === 'y' ? e.pageY : e.pageX;
  3751. this.axis[axis].dragOffset = eventOffset - scrollbar.getBoundingClientRect()[this.axis[axis].offsetAttr];
  3752. this.draggedAxis = axis;
  3753. document.addEventListener('mousemove', this.drag);
  3754. document.addEventListener('mouseup', this.onEndDrag);
  3755. }
  3756. /**
  3757. * Drag scrollbar handle
  3758. */
  3759. }, {
  3760. key: "getScrollElement",
  3761. /**
  3762. * Getter for original scrolling element
  3763. */
  3764. value: function getScrollElement() {
  3765. return this.contentEl;
  3766. }
  3767. }, {
  3768. key: "removeListeners",
  3769. value: function removeListeners() {
  3770. var _this4 = this;
  3771. // Event listeners
  3772. if (this.options.autoHide) {
  3773. this.el.removeEventListener('mouseenter', this.onMouseEnter);
  3774. }
  3775. ['mousedown', 'click', 'dblclick', 'touchstart', 'touchend', 'touchmove'].forEach(function (e) {
  3776. _this4.el.removeEventListener(e, _this4.onPointerEvent);
  3777. });
  3778. this.el.removeEventListener('mousemove', this.onMouseMove);
  3779. this.el.removeEventListener('mouseleave', this.onMouseLeave);
  3780. this.contentEl.removeEventListener('scroll', this.onScroll);
  3781. window.removeEventListener('resize', this.onWindowResize);
  3782. this.mutationObserver && this.mutationObserver.disconnect();
  3783. this.resizeObserver.disconnect(); // Cancel all debounced functions
  3784. this.recalculate.cancel();
  3785. this.onMouseMove.cancel();
  3786. this.hideScrollbars.cancel();
  3787. this.onWindowResize.cancel();
  3788. }
  3789. /**
  3790. * UnMount mutation observer and delete SimpleBar instance from DOM element
  3791. */
  3792. }, {
  3793. key: "unMount",
  3794. value: function unMount() {
  3795. this.removeListeners();
  3796. this.el.SimpleBar = null;
  3797. }
  3798. /**
  3799. * Recursively walks up the parent nodes looking for this.el
  3800. */
  3801. }, {
  3802. key: "isChildNode",
  3803. value: function isChildNode(el) {
  3804. if (el === null) return false;
  3805. if (el === this.el) return true;
  3806. return this.isChildNode(el.parentNode);
  3807. }
  3808. /**
  3809. * Check if mouse is within bounds
  3810. */
  3811. }, {
  3812. key: "isWithinBounds",
  3813. value: function isWithinBounds(bbox) {
  3814. return this.mouseX >= bbox.left && this.mouseX <= bbox.left + bbox.width && this.mouseY >= bbox.top && this.mouseY <= bbox.top + bbox.height;
  3815. }
  3816. }], [{
  3817. key: "getRtlHelpers",
  3818. value: function getRtlHelpers() {
  3819. var dummyDiv = document.createElement('div');
  3820. dummyDiv.innerHTML = '<div class="hs-dummy-scrollbar-size"><div style="height: 200%; width: 200%; margin: 10px 0;"></div></div>';
  3821. var scrollbarDummyEl = dummyDiv.firstElementChild;
  3822. document.body.appendChild(scrollbarDummyEl);
  3823. var dummyContainerChild = scrollbarDummyEl.firstElementChild;
  3824. scrollbarDummyEl.scrollLeft = 0;
  3825. var dummyContainerOffset = SimpleBar.getOffset(scrollbarDummyEl);
  3826. var dummyContainerChildOffset = SimpleBar.getOffset(dummyContainerChild);
  3827. scrollbarDummyEl.scrollLeft = 999;
  3828. var dummyContainerScrollOffsetAfterScroll = SimpleBar.getOffset(dummyContainerChild);
  3829. return {
  3830. // determines if the scrolling is responding with negative values
  3831. isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
  3832. // determines if the origin scrollbar position is inverted or not (positioned on left or right)
  3833. isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
  3834. };
  3835. }
  3836. }, {
  3837. key: "initHtmlApi",
  3838. value: function initHtmlApi() {
  3839. this.initDOMLoadedElements = this.initDOMLoadedElements.bind(this); // MutationObserver is IE11+
  3840. if (typeof MutationObserver !== 'undefined') {
  3841. // Mutation observer to observe dynamically added elements
  3842. this.globalObserver = new MutationObserver(function (mutations) {
  3843. mutations.forEach(function (mutation) {
  3844. Array.from(mutation.addedNodes).forEach(function (addedNode) {
  3845. if (addedNode.nodeType === 1) {
  3846. if (addedNode.hasAttribute('data-simplebar')) {
  3847. !addedNode.SimpleBar && new SimpleBar(addedNode, SimpleBar.getElOptions(addedNode));
  3848. } else {
  3849. Array.from(addedNode.querySelectorAll('[data-simplebar]')).forEach(function (el) {
  3850. !el.SimpleBar && new SimpleBar(el, SimpleBar.getElOptions(el));
  3851. });
  3852. }
  3853. }
  3854. });
  3855. Array.from(mutation.removedNodes).forEach(function (removedNode) {
  3856. if (removedNode.nodeType === 1) {
  3857. if (removedNode.hasAttribute('data-simplebar')) {
  3858. removedNode.SimpleBar && removedNode.SimpleBar.unMount();
  3859. } else {
  3860. Array.from(removedNode.querySelectorAll('[data-simplebar]')).forEach(function (el) {
  3861. el.SimpleBar && el.SimpleBar.unMount();
  3862. });
  3863. }
  3864. }
  3865. });
  3866. });
  3867. });
  3868. this.globalObserver.observe(document, {
  3869. childList: true,
  3870. subtree: true
  3871. });
  3872. } // Taken from jQuery `ready` function
  3873. // Instantiate elements already present on the page
  3874. if (document.readyState === 'complete' || document.readyState !== 'loading' && !document.documentElement.doScroll) {
  3875. // Handle it asynchronously to allow scripts the opportunity to delay init
  3876. window.setTimeout(this.initDOMLoadedElements);
  3877. } else {
  3878. document.addEventListener('DOMContentLoaded', this.initDOMLoadedElements);
  3879. window.addEventListener('load', this.initDOMLoadedElements);
  3880. }
  3881. } // Helper function to retrieve options from element attributes
  3882. }, {
  3883. key: "getElOptions",
  3884. value: function getElOptions(el) {
  3885. var options = Array.from(el.attributes).reduce(function (acc, attribute) {
  3886. var option = attribute.name.match(/data-simplebar-(.+)/);
  3887. if (option) {
  3888. var key = option[1].replace(/\W+(.)/g, function (x, chr) {
  3889. return chr.toUpperCase();
  3890. });
  3891. switch (attribute.value) {
  3892. case 'true':
  3893. acc[key] = true;
  3894. break;
  3895. case 'false':
  3896. acc[key] = false;
  3897. break;
  3898. case undefined:
  3899. acc[key] = true;
  3900. break;
  3901. default:
  3902. acc[key] = attribute.value;
  3903. }
  3904. }
  3905. return acc;
  3906. }, {});
  3907. return options;
  3908. }
  3909. }, {
  3910. key: "removeObserver",
  3911. value: function removeObserver() {
  3912. this.globalObserver.disconnect();
  3913. }
  3914. }, {
  3915. key: "initDOMLoadedElements",
  3916. value: function initDOMLoadedElements() {
  3917. document.removeEventListener('DOMContentLoaded', this.initDOMLoadedElements);
  3918. window.removeEventListener('load', this.initDOMLoadedElements);
  3919. Array.from(document.querySelectorAll('[data-simplebar]')).forEach(function (el) {
  3920. if (!el.SimpleBar) new SimpleBar(el, SimpleBar.getElOptions(el));
  3921. });
  3922. }
  3923. }, {
  3924. key: "getOffset",
  3925. value: function getOffset(el) {
  3926. var rect = el.getBoundingClientRect();
  3927. return {
  3928. top: rect.top + (window.pageYOffset || document.documentElement.scrollTop),
  3929. left: rect.left + (window.pageXOffset || document.documentElement.scrollLeft)
  3930. };
  3931. }
  3932. }]);
  3933. return SimpleBar;
  3934. }();
  3935. /**
  3936. * HTML API
  3937. * Called only in a browser env.
  3938. */
  3939. SimpleBar.defaultOptions = {
  3940. autoHide: true,
  3941. forceVisible: false,
  3942. classNames: {
  3943. content: 'simplebar-content',
  3944. offset: 'simplebar-offset',
  3945. mask: 'simplebar-mask',
  3946. wrapper: 'simplebar-wrapper',
  3947. placeholder: 'simplebar-placeholder',
  3948. scrollbar: 'simplebar-scrollbar',
  3949. track: 'simplebar-track',
  3950. heightAutoObserverWrapperEl: 'simplebar-height-auto-observer-wrapper',
  3951. heightAutoObserverEl: 'simplebar-height-auto-observer',
  3952. visible: 'simplebar-visible',
  3953. horizontal: 'simplebar-horizontal',
  3954. vertical: 'simplebar-vertical',
  3955. hover: 'simplebar-hover'
  3956. },
  3957. scrollbarMinSize: 25,
  3958. scrollbarMaxSize: 0,
  3959. timeout: 1000
  3960. };
  3961. if (canUseDom) {
  3962. SimpleBar.initHtmlApi();
  3963. }
  3964. return SimpleBar;
  3965. }));