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.

4181 lines
136 KiB

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