@mjhls/mjh-framework 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -12,8 +12,7 @@ import NavDropdown from 'react-bootstrap/NavDropdown';
12
12
  import Form from 'react-bootstrap/Form';
13
13
  import FormControl from 'react-bootstrap/FormControl';
14
14
  import Button from 'react-bootstrap/Button';
15
- import events from 'events';
16
- import propTypes from 'prop-types';
15
+ import PropTypes from 'prop-types';
17
16
 
18
17
  /*! *****************************************************************************
19
18
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1429,6 +1428,8 @@ var NavNormal = function NavNormal(props) {
1429
1428
  );
1430
1429
  };
1431
1430
 
1431
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1432
+
1432
1433
  function unwrapExports (x) {
1433
1434
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1434
1435
  }
@@ -1437,6 +1438,472 @@ function createCommonjsModule(fn, module) {
1437
1438
  return module = { exports: {} }, fn(module, module.exports), module.exports;
1438
1439
  }
1439
1440
 
1441
+ var domain;
1442
+
1443
+ // This constructor is used to store event handlers. Instantiating this is
1444
+ // faster than explicitly calling `Object.create(null)` to get a "clean" empty
1445
+ // object (tested with v8 v4.9).
1446
+ function EventHandlers() {}
1447
+ EventHandlers.prototype = Object.create(null);
1448
+
1449
+ function EventEmitter() {
1450
+ EventEmitter.init.call(this);
1451
+ }
1452
+
1453
+ // nodejs oddity
1454
+ // require('events') === require('events').EventEmitter
1455
+ EventEmitter.EventEmitter = EventEmitter;
1456
+
1457
+ EventEmitter.usingDomains = false;
1458
+
1459
+ EventEmitter.prototype.domain = undefined;
1460
+ EventEmitter.prototype._events = undefined;
1461
+ EventEmitter.prototype._maxListeners = undefined;
1462
+
1463
+ // By default EventEmitters will print a warning if more than 10 listeners are
1464
+ // added to it. This is a useful default which helps finding memory leaks.
1465
+ EventEmitter.defaultMaxListeners = 10;
1466
+
1467
+ EventEmitter.init = function() {
1468
+ this.domain = null;
1469
+ if (EventEmitter.usingDomains) {
1470
+ // if there is an active domain, then attach to it.
1471
+ if (domain.active && !(this instanceof domain.Domain)) ;
1472
+ }
1473
+
1474
+ if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
1475
+ this._events = new EventHandlers();
1476
+ this._eventsCount = 0;
1477
+ }
1478
+
1479
+ this._maxListeners = this._maxListeners || undefined;
1480
+ };
1481
+
1482
+ // Obviously not all Emitters should be limited to 10. This function allows
1483
+ // that to be increased. Set to zero for unlimited.
1484
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
1485
+ if (typeof n !== 'number' || n < 0 || isNaN(n))
1486
+ throw new TypeError('"n" argument must be a positive number');
1487
+ this._maxListeners = n;
1488
+ return this;
1489
+ };
1490
+
1491
+ function $getMaxListeners(that) {
1492
+ if (that._maxListeners === undefined)
1493
+ return EventEmitter.defaultMaxListeners;
1494
+ return that._maxListeners;
1495
+ }
1496
+
1497
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
1498
+ return $getMaxListeners(this);
1499
+ };
1500
+
1501
+ // These standalone emit* functions are used to optimize calling of event
1502
+ // handlers for fast cases because emit() itself often has a variable number of
1503
+ // arguments and can be deoptimized because of that. These functions always have
1504
+ // the same number of arguments and thus do not get deoptimized, so the code
1505
+ // inside them can execute faster.
1506
+ function emitNone(handler, isFn, self) {
1507
+ if (isFn)
1508
+ handler.call(self);
1509
+ else {
1510
+ var len = handler.length;
1511
+ var listeners = arrayClone(handler, len);
1512
+ for (var i = 0; i < len; ++i)
1513
+ listeners[i].call(self);
1514
+ }
1515
+ }
1516
+ function emitOne(handler, isFn, self, arg1) {
1517
+ if (isFn)
1518
+ handler.call(self, arg1);
1519
+ else {
1520
+ var len = handler.length;
1521
+ var listeners = arrayClone(handler, len);
1522
+ for (var i = 0; i < len; ++i)
1523
+ listeners[i].call(self, arg1);
1524
+ }
1525
+ }
1526
+ function emitTwo(handler, isFn, self, arg1, arg2) {
1527
+ if (isFn)
1528
+ handler.call(self, arg1, arg2);
1529
+ else {
1530
+ var len = handler.length;
1531
+ var listeners = arrayClone(handler, len);
1532
+ for (var i = 0; i < len; ++i)
1533
+ listeners[i].call(self, arg1, arg2);
1534
+ }
1535
+ }
1536
+ function emitThree(handler, isFn, self, arg1, arg2, arg3) {
1537
+ if (isFn)
1538
+ handler.call(self, arg1, arg2, arg3);
1539
+ else {
1540
+ var len = handler.length;
1541
+ var listeners = arrayClone(handler, len);
1542
+ for (var i = 0; i < len; ++i)
1543
+ listeners[i].call(self, arg1, arg2, arg3);
1544
+ }
1545
+ }
1546
+
1547
+ function emitMany(handler, isFn, self, args) {
1548
+ if (isFn)
1549
+ handler.apply(self, args);
1550
+ else {
1551
+ var len = handler.length;
1552
+ var listeners = arrayClone(handler, len);
1553
+ for (var i = 0; i < len; ++i)
1554
+ listeners[i].apply(self, args);
1555
+ }
1556
+ }
1557
+
1558
+ EventEmitter.prototype.emit = function emit(type) {
1559
+ var er, handler, len, args, i, events, domain;
1560
+ var doError = (type === 'error');
1561
+
1562
+ events = this._events;
1563
+ if (events)
1564
+ doError = (doError && events.error == null);
1565
+ else if (!doError)
1566
+ return false;
1567
+
1568
+ domain = this.domain;
1569
+
1570
+ // If there is no 'error' event listener then throw.
1571
+ if (doError) {
1572
+ er = arguments[1];
1573
+ if (domain) {
1574
+ if (!er)
1575
+ er = new Error('Uncaught, unspecified "error" event');
1576
+ er.domainEmitter = this;
1577
+ er.domain = domain;
1578
+ er.domainThrown = false;
1579
+ domain.emit('error', er);
1580
+ } else if (er instanceof Error) {
1581
+ throw er; // Unhandled 'error' event
1582
+ } else {
1583
+ // At least give some kind of context to the user
1584
+ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
1585
+ err.context = er;
1586
+ throw err;
1587
+ }
1588
+ return false;
1589
+ }
1590
+
1591
+ handler = events[type];
1592
+
1593
+ if (!handler)
1594
+ return false;
1595
+
1596
+ var isFn = typeof handler === 'function';
1597
+ len = arguments.length;
1598
+ switch (len) {
1599
+ // fast cases
1600
+ case 1:
1601
+ emitNone(handler, isFn, this);
1602
+ break;
1603
+ case 2:
1604
+ emitOne(handler, isFn, this, arguments[1]);
1605
+ break;
1606
+ case 3:
1607
+ emitTwo(handler, isFn, this, arguments[1], arguments[2]);
1608
+ break;
1609
+ case 4:
1610
+ emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
1611
+ break;
1612
+ // slower
1613
+ default:
1614
+ args = new Array(len - 1);
1615
+ for (i = 1; i < len; i++)
1616
+ args[i - 1] = arguments[i];
1617
+ emitMany(handler, isFn, this, args);
1618
+ }
1619
+
1620
+ return true;
1621
+ };
1622
+
1623
+ function _addListener(target, type, listener, prepend) {
1624
+ var m;
1625
+ var events;
1626
+ var existing;
1627
+
1628
+ if (typeof listener !== 'function')
1629
+ throw new TypeError('"listener" argument must be a function');
1630
+
1631
+ events = target._events;
1632
+ if (!events) {
1633
+ events = target._events = new EventHandlers();
1634
+ target._eventsCount = 0;
1635
+ } else {
1636
+ // To avoid recursion in the case that type === "newListener"! Before
1637
+ // adding it to the listeners, first emit "newListener".
1638
+ if (events.newListener) {
1639
+ target.emit('newListener', type,
1640
+ listener.listener ? listener.listener : listener);
1641
+
1642
+ // Re-assign `events` because a newListener handler could have caused the
1643
+ // this._events to be assigned to a new object
1644
+ events = target._events;
1645
+ }
1646
+ existing = events[type];
1647
+ }
1648
+
1649
+ if (!existing) {
1650
+ // Optimize the case of one listener. Don't need the extra array object.
1651
+ existing = events[type] = listener;
1652
+ ++target._eventsCount;
1653
+ } else {
1654
+ if (typeof existing === 'function') {
1655
+ // Adding the second element, need to change to array.
1656
+ existing = events[type] = prepend ? [listener, existing] :
1657
+ [existing, listener];
1658
+ } else {
1659
+ // If we've already got an array, just append.
1660
+ if (prepend) {
1661
+ existing.unshift(listener);
1662
+ } else {
1663
+ existing.push(listener);
1664
+ }
1665
+ }
1666
+
1667
+ // Check for listener leak
1668
+ if (!existing.warned) {
1669
+ m = $getMaxListeners(target);
1670
+ if (m && m > 0 && existing.length > m) {
1671
+ existing.warned = true;
1672
+ var w = new Error('Possible EventEmitter memory leak detected. ' +
1673
+ existing.length + ' ' + type + ' listeners added. ' +
1674
+ 'Use emitter.setMaxListeners() to increase limit');
1675
+ w.name = 'MaxListenersExceededWarning';
1676
+ w.emitter = target;
1677
+ w.type = type;
1678
+ w.count = existing.length;
1679
+ emitWarning(w);
1680
+ }
1681
+ }
1682
+ }
1683
+
1684
+ return target;
1685
+ }
1686
+ function emitWarning(e) {
1687
+ typeof console.warn === 'function' ? console.warn(e) : console.log(e);
1688
+ }
1689
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
1690
+ return _addListener(this, type, listener, false);
1691
+ };
1692
+
1693
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
1694
+
1695
+ EventEmitter.prototype.prependListener =
1696
+ function prependListener(type, listener) {
1697
+ return _addListener(this, type, listener, true);
1698
+ };
1699
+
1700
+ function _onceWrap(target, type, listener) {
1701
+ var fired = false;
1702
+ function g() {
1703
+ target.removeListener(type, g);
1704
+ if (!fired) {
1705
+ fired = true;
1706
+ listener.apply(target, arguments);
1707
+ }
1708
+ }
1709
+ g.listener = listener;
1710
+ return g;
1711
+ }
1712
+
1713
+ EventEmitter.prototype.once = function once(type, listener) {
1714
+ if (typeof listener !== 'function')
1715
+ throw new TypeError('"listener" argument must be a function');
1716
+ this.on(type, _onceWrap(this, type, listener));
1717
+ return this;
1718
+ };
1719
+
1720
+ EventEmitter.prototype.prependOnceListener =
1721
+ function prependOnceListener(type, listener) {
1722
+ if (typeof listener !== 'function')
1723
+ throw new TypeError('"listener" argument must be a function');
1724
+ this.prependListener(type, _onceWrap(this, type, listener));
1725
+ return this;
1726
+ };
1727
+
1728
+ // emits a 'removeListener' event iff the listener was removed
1729
+ EventEmitter.prototype.removeListener =
1730
+ function removeListener(type, listener) {
1731
+ var list, events, position, i, originalListener;
1732
+
1733
+ if (typeof listener !== 'function')
1734
+ throw new TypeError('"listener" argument must be a function');
1735
+
1736
+ events = this._events;
1737
+ if (!events)
1738
+ return this;
1739
+
1740
+ list = events[type];
1741
+ if (!list)
1742
+ return this;
1743
+
1744
+ if (list === listener || (list.listener && list.listener === listener)) {
1745
+ if (--this._eventsCount === 0)
1746
+ this._events = new EventHandlers();
1747
+ else {
1748
+ delete events[type];
1749
+ if (events.removeListener)
1750
+ this.emit('removeListener', type, list.listener || listener);
1751
+ }
1752
+ } else if (typeof list !== 'function') {
1753
+ position = -1;
1754
+
1755
+ for (i = list.length; i-- > 0;) {
1756
+ if (list[i] === listener ||
1757
+ (list[i].listener && list[i].listener === listener)) {
1758
+ originalListener = list[i].listener;
1759
+ position = i;
1760
+ break;
1761
+ }
1762
+ }
1763
+
1764
+ if (position < 0)
1765
+ return this;
1766
+
1767
+ if (list.length === 1) {
1768
+ list[0] = undefined;
1769
+ if (--this._eventsCount === 0) {
1770
+ this._events = new EventHandlers();
1771
+ return this;
1772
+ } else {
1773
+ delete events[type];
1774
+ }
1775
+ } else {
1776
+ spliceOne(list, position);
1777
+ }
1778
+
1779
+ if (events.removeListener)
1780
+ this.emit('removeListener', type, originalListener || listener);
1781
+ }
1782
+
1783
+ return this;
1784
+ };
1785
+
1786
+ EventEmitter.prototype.removeAllListeners =
1787
+ function removeAllListeners(type) {
1788
+ var listeners, events;
1789
+
1790
+ events = this._events;
1791
+ if (!events)
1792
+ return this;
1793
+
1794
+ // not listening for removeListener, no need to emit
1795
+ if (!events.removeListener) {
1796
+ if (arguments.length === 0) {
1797
+ this._events = new EventHandlers();
1798
+ this._eventsCount = 0;
1799
+ } else if (events[type]) {
1800
+ if (--this._eventsCount === 0)
1801
+ this._events = new EventHandlers();
1802
+ else
1803
+ delete events[type];
1804
+ }
1805
+ return this;
1806
+ }
1807
+
1808
+ // emit removeListener for all listeners on all events
1809
+ if (arguments.length === 0) {
1810
+ var keys = Object.keys(events);
1811
+ for (var i = 0, key; i < keys.length; ++i) {
1812
+ key = keys[i];
1813
+ if (key === 'removeListener') continue;
1814
+ this.removeAllListeners(key);
1815
+ }
1816
+ this.removeAllListeners('removeListener');
1817
+ this._events = new EventHandlers();
1818
+ this._eventsCount = 0;
1819
+ return this;
1820
+ }
1821
+
1822
+ listeners = events[type];
1823
+
1824
+ if (typeof listeners === 'function') {
1825
+ this.removeListener(type, listeners);
1826
+ } else if (listeners) {
1827
+ // LIFO order
1828
+ do {
1829
+ this.removeListener(type, listeners[listeners.length - 1]);
1830
+ } while (listeners[0]);
1831
+ }
1832
+
1833
+ return this;
1834
+ };
1835
+
1836
+ EventEmitter.prototype.listeners = function listeners(type) {
1837
+ var evlistener;
1838
+ var ret;
1839
+ var events = this._events;
1840
+
1841
+ if (!events)
1842
+ ret = [];
1843
+ else {
1844
+ evlistener = events[type];
1845
+ if (!evlistener)
1846
+ ret = [];
1847
+ else if (typeof evlistener === 'function')
1848
+ ret = [evlistener.listener || evlistener];
1849
+ else
1850
+ ret = unwrapListeners(evlistener);
1851
+ }
1852
+
1853
+ return ret;
1854
+ };
1855
+
1856
+ EventEmitter.listenerCount = function(emitter, type) {
1857
+ if (typeof emitter.listenerCount === 'function') {
1858
+ return emitter.listenerCount(type);
1859
+ } else {
1860
+ return listenerCount.call(emitter, type);
1861
+ }
1862
+ };
1863
+
1864
+ EventEmitter.prototype.listenerCount = listenerCount;
1865
+ function listenerCount(type) {
1866
+ var events = this._events;
1867
+
1868
+ if (events) {
1869
+ var evlistener = events[type];
1870
+
1871
+ if (typeof evlistener === 'function') {
1872
+ return 1;
1873
+ } else if (evlistener) {
1874
+ return evlistener.length;
1875
+ }
1876
+ }
1877
+
1878
+ return 0;
1879
+ }
1880
+
1881
+ EventEmitter.prototype.eventNames = function eventNames() {
1882
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
1883
+ };
1884
+
1885
+ // About 1.5x faster than the two-arg version of Array#splice().
1886
+ function spliceOne(list, index) {
1887
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
1888
+ list[i] = list[k];
1889
+ list.pop();
1890
+ }
1891
+
1892
+ function arrayClone(arr, i) {
1893
+ var copy = new Array(i);
1894
+ while (i--)
1895
+ copy[i] = arr[i];
1896
+ return copy;
1897
+ }
1898
+
1899
+ function unwrapListeners(arr) {
1900
+ var ret = new Array(arr.length);
1901
+ for (var i = 0; i < ret.length; ++i) {
1902
+ ret[i] = arr[i].listener || arr[i];
1903
+ }
1904
+ return ret;
1905
+ }
1906
+
1440
1907
  var utils = createCommonjsModule(function (module, exports) {
1441
1908
 
1442
1909
  Object.defineProperty(exports, "__esModule", {
@@ -1503,7 +1970,7 @@ var registeredSlots = {};
1503
1970
  var managerAlreadyInitialized = false;
1504
1971
  var globalTargetingArguments = {};
1505
1972
  var globalAdSenseAttributes = {};
1506
- var DFPManager = Object.assign(new events.EventEmitter().setMaxListeners(0), {
1973
+ var DFPManager = Object.assign(new EventEmitter.EventEmitter().setMaxListeners(0), {
1507
1974
  singleRequestIsEnabled: function singleRequestIsEnabled() {
1508
1975
  return singleRequestEnabled;
1509
1976
  },
@@ -1991,7 +2458,7 @@ exports.default = exports.Context = void 0;
1991
2458
 
1992
2459
  var _react = _interopRequireDefault(React__default);
1993
2460
 
1994
- var _propTypes = _interopRequireDefault(propTypes);
2461
+ var _propTypes = _interopRequireDefault(PropTypes);
1995
2462
 
1996
2463
  var _manager = _interopRequireDefault(manager);
1997
2464
 
@@ -2299,7 +2766,7 @@ exports.default = exports.AdSlot = void 0;
2299
2766
 
2300
2767
  var _react = _interopRequireDefault(React__default);
2301
2768
 
2302
- var _propTypes = _interopRequireDefault(propTypes);
2769
+ var _propTypes = _interopRequireDefault(PropTypes);
2303
2770
 
2304
2771
  var _manager = _interopRequireDefault(manager);
2305
2772
 
@@ -2787,5 +3254,2684 @@ var AD300x250x600 = function (_Component) {
2787
3254
  return AD300x250x600;
2788
3255
  }(Component);
2789
3256
 
2790
- export { DeckContent, DeckQueue, Column2, Column3, Header, LeftNav, NavMagazine, NavNative, NavNormal, TemplateNormal, AD300x250, AD300x250x600, AD728x90 };
3257
+ var getYoutubeId = createCommonjsModule(function (module, exports) {
3258
+ (function (root, factory) {
3259
+ {
3260
+ module.exports = factory();
3261
+ }
3262
+ }(commonjsGlobal, function (exports) {
3263
+
3264
+ return function (url, opts) {
3265
+ if (opts == undefined) {
3266
+ opts = {fuzzy: true};
3267
+ }
3268
+
3269
+ if (/youtu\.?be/.test(url)) {
3270
+
3271
+ // Look first for known patterns
3272
+ var i;
3273
+ var patterns = [
3274
+ /youtu\.be\/([^#\&\?]{11})/, // youtu.be/<id>
3275
+ /\?v=([^#\&\?]{11})/, // ?v=<id>
3276
+ /\&v=([^#\&\?]{11})/, // &v=<id>
3277
+ /embed\/([^#\&\?]{11})/, // embed/<id>
3278
+ /\/v\/([^#\&\?]{11})/ // /v/<id>
3279
+ ];
3280
+
3281
+ // If any pattern matches, return the ID
3282
+ for (i = 0; i < patterns.length; ++i) {
3283
+ if (patterns[i].test(url)) {
3284
+ return patterns[i].exec(url)[1];
3285
+ }
3286
+ }
3287
+
3288
+ if (opts.fuzzy) {
3289
+ // If that fails, break it apart by certain characters and look
3290
+ // for the 11 character key
3291
+ var tokens = url.split(/[\/\&\?=#\.\s]/g);
3292
+ for (i = 0; i < tokens.length; ++i) {
3293
+ if (/^[^#\&\?]{11}$/.test(tokens[i])) {
3294
+ return tokens[i];
3295
+ }
3296
+ }
3297
+ }
3298
+ }
3299
+
3300
+ return null;
3301
+ };
3302
+
3303
+ }));
3304
+ });
3305
+
3306
+ var isArray = Array.isArray;
3307
+ var keyList = Object.keys;
3308
+ var hasProp = Object.prototype.hasOwnProperty;
3309
+
3310
+ var fastDeepEqual = function equal(a, b) {
3311
+ if (a === b) return true;
3312
+
3313
+ if (a && b && typeof a == 'object' && typeof b == 'object') {
3314
+ var arrA = isArray(a)
3315
+ , arrB = isArray(b)
3316
+ , i
3317
+ , length
3318
+ , key;
3319
+
3320
+ if (arrA && arrB) {
3321
+ length = a.length;
3322
+ if (length != b.length) return false;
3323
+ for (i = length; i-- !== 0;)
3324
+ if (!equal(a[i], b[i])) return false;
3325
+ return true;
3326
+ }
3327
+
3328
+ if (arrA != arrB) return false;
3329
+
3330
+ var dateA = a instanceof Date
3331
+ , dateB = b instanceof Date;
3332
+ if (dateA != dateB) return false;
3333
+ if (dateA && dateB) return a.getTime() == b.getTime();
3334
+
3335
+ var regexpA = a instanceof RegExp
3336
+ , regexpB = b instanceof RegExp;
3337
+ if (regexpA != regexpB) return false;
3338
+ if (regexpA && regexpB) return a.toString() == b.toString();
3339
+
3340
+ var keys = keyList(a);
3341
+ length = keys.length;
3342
+
3343
+ if (length !== keyList(b).length)
3344
+ return false;
3345
+
3346
+ for (i = length; i-- !== 0;)
3347
+ if (!hasProp.call(b, keys[i])) return false;
3348
+
3349
+ for (i = length; i-- !== 0;) {
3350
+ key = keys[i];
3351
+ if (!equal(a[key], b[key])) return false;
3352
+ }
3353
+
3354
+ return true;
3355
+ }
3356
+
3357
+ return a!==a && b!==b;
3358
+ };
3359
+
3360
+ var Sister;
3361
+
3362
+ /**
3363
+ * @link https://github.com/gajus/sister for the canonical source repository
3364
+ * @license https://github.com/gajus/sister/blob/master/LICENSE BSD 3-Clause
3365
+ */
3366
+ Sister = function () {
3367
+ var sister = {},
3368
+ events = {};
3369
+
3370
+ /**
3371
+ * @name handler
3372
+ * @function
3373
+ * @param {Object} data Event data.
3374
+ */
3375
+
3376
+ /**
3377
+ * @param {String} name Event name.
3378
+ * @param {handler} handler
3379
+ * @return {listener}
3380
+ */
3381
+ sister.on = function (name, handler) {
3382
+ var listener = {name: name, handler: handler};
3383
+ events[name] = events[name] || [];
3384
+ events[name].unshift(listener);
3385
+ return listener;
3386
+ };
3387
+
3388
+ /**
3389
+ * @param {listener}
3390
+ */
3391
+ sister.off = function (listener) {
3392
+ var index = events[listener.name].indexOf(listener);
3393
+
3394
+ if (index !== -1) {
3395
+ events[listener.name].splice(index, 1);
3396
+ }
3397
+ };
3398
+
3399
+ /**
3400
+ * @param {String} name Event name.
3401
+ * @param {Object} data Event data.
3402
+ */
3403
+ sister.trigger = function (name, data) {
3404
+ var listeners = events[name],
3405
+ i;
3406
+
3407
+ if (listeners) {
3408
+ i = listeners.length;
3409
+ while (i--) {
3410
+ listeners[i].handler(data);
3411
+ }
3412
+ }
3413
+ };
3414
+
3415
+ return sister;
3416
+ };
3417
+
3418
+ var sister = Sister;
3419
+
3420
+ var loadScript = function load (src, opts, cb) {
3421
+ var head = document.head || document.getElementsByTagName('head')[0];
3422
+ var script = document.createElement('script');
3423
+
3424
+ if (typeof opts === 'function') {
3425
+ cb = opts;
3426
+ opts = {};
3427
+ }
3428
+
3429
+ opts = opts || {};
3430
+ cb = cb || function() {};
3431
+
3432
+ script.type = opts.type || 'text/javascript';
3433
+ script.charset = opts.charset || 'utf8';
3434
+ script.async = 'async' in opts ? !!opts.async : true;
3435
+ script.src = src;
3436
+
3437
+ if (opts.attrs) {
3438
+ setAttributes(script, opts.attrs);
3439
+ }
3440
+
3441
+ if (opts.text) {
3442
+ script.text = '' + opts.text;
3443
+ }
3444
+
3445
+ var onend = 'onload' in script ? stdOnEnd : ieOnEnd;
3446
+ onend(script, cb);
3447
+
3448
+ // some good legacy browsers (firefox) fail the 'in' detection above
3449
+ // so as a fallback we always set onload
3450
+ // old IE will ignore this and new IE will set onload
3451
+ if (!script.onload) {
3452
+ stdOnEnd(script, cb);
3453
+ }
3454
+
3455
+ head.appendChild(script);
3456
+ };
3457
+
3458
+ function setAttributes(script, attrs) {
3459
+ for (var attr in attrs) {
3460
+ script.setAttribute(attr, attrs[attr]);
3461
+ }
3462
+ }
3463
+
3464
+ function stdOnEnd (script, cb) {
3465
+ script.onload = function () {
3466
+ this.onerror = this.onload = null;
3467
+ cb(null, script);
3468
+ };
3469
+ script.onerror = function () {
3470
+ // this.onload = null here is necessary
3471
+ // because even IE9 works not like others
3472
+ this.onerror = this.onload = null;
3473
+ cb(new Error('Failed to load ' + this.src), script);
3474
+ };
3475
+ }
3476
+
3477
+ function ieOnEnd (script, cb) {
3478
+ script.onreadystatechange = function () {
3479
+ if (this.readyState != 'complete' && this.readyState != 'loaded') return
3480
+ this.onreadystatechange = null;
3481
+ cb(null, script); // there is no way to catch loading errors in IE8
3482
+ };
3483
+ }
3484
+
3485
+ var loadYouTubeIframeApi = createCommonjsModule(function (module, exports) {
3486
+
3487
+ Object.defineProperty(exports, "__esModule", {
3488
+ value: true
3489
+ });
3490
+
3491
+
3492
+
3493
+ var _loadScript2 = _interopRequireDefault(loadScript);
3494
+
3495
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3496
+
3497
+ exports.default = function (emitter) {
3498
+ /**
3499
+ * A promise that is resolved when window.onYouTubeIframeAPIReady is called.
3500
+ * The promise is resolved with a reference to window.YT object.
3501
+ */
3502
+ var iframeAPIReady = new Promise(function (resolve) {
3503
+ if (window.YT && window.YT.Player && window.YT.Player instanceof Function) {
3504
+ resolve(window.YT);
3505
+
3506
+ return;
3507
+ } else {
3508
+ var protocol = window.location.protocol === 'http:' ? 'http:' : 'https:';
3509
+
3510
+ (0, _loadScript2.default)(protocol + '//www.youtube.com/iframe_api', function (error) {
3511
+ if (error) {
3512
+ emitter.trigger('error', error);
3513
+ }
3514
+ });
3515
+ }
3516
+
3517
+ var previous = window.onYouTubeIframeAPIReady;
3518
+
3519
+ // The API will call this function when page has finished downloading
3520
+ // the JavaScript for the player API.
3521
+ window.onYouTubeIframeAPIReady = function () {
3522
+ if (previous) {
3523
+ previous();
3524
+ }
3525
+
3526
+ resolve(window.YT);
3527
+ };
3528
+ });
3529
+
3530
+ return iframeAPIReady;
3531
+ };
3532
+
3533
+ module.exports = exports['default'];
3534
+ });
3535
+
3536
+ unwrapExports(loadYouTubeIframeApi);
3537
+
3538
+ /**
3539
+ * Helpers.
3540
+ */
3541
+
3542
+ var s = 1000;
3543
+ var m = s * 60;
3544
+ var h = m * 60;
3545
+ var d = h * 24;
3546
+ var y = d * 365.25;
3547
+
3548
+ /**
3549
+ * Parse or format the given `val`.
3550
+ *
3551
+ * Options:
3552
+ *
3553
+ * - `long` verbose formatting [false]
3554
+ *
3555
+ * @param {String|Number} val
3556
+ * @param {Object} [options]
3557
+ * @throws {Error} throw an error if val is not a non-empty string or a number
3558
+ * @return {String|Number}
3559
+ * @api public
3560
+ */
3561
+
3562
+ var ms = function(val, options) {
3563
+ options = options || {};
3564
+ var type = typeof val;
3565
+ if (type === 'string' && val.length > 0) {
3566
+ return parse(val);
3567
+ } else if (type === 'number' && isNaN(val) === false) {
3568
+ return options.long ? fmtLong(val) : fmtShort(val);
3569
+ }
3570
+ throw new Error(
3571
+ 'val is not a non-empty string or a valid number. val=' +
3572
+ JSON.stringify(val)
3573
+ );
3574
+ };
3575
+
3576
+ /**
3577
+ * Parse the given `str` and return milliseconds.
3578
+ *
3579
+ * @param {String} str
3580
+ * @return {Number}
3581
+ * @api private
3582
+ */
3583
+
3584
+ function parse(str) {
3585
+ str = String(str);
3586
+ if (str.length > 100) {
3587
+ return;
3588
+ }
3589
+ var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
3590
+ str
3591
+ );
3592
+ if (!match) {
3593
+ return;
3594
+ }
3595
+ var n = parseFloat(match[1]);
3596
+ var type = (match[2] || 'ms').toLowerCase();
3597
+ switch (type) {
3598
+ case 'years':
3599
+ case 'year':
3600
+ case 'yrs':
3601
+ case 'yr':
3602
+ case 'y':
3603
+ return n * y;
3604
+ case 'days':
3605
+ case 'day':
3606
+ case 'd':
3607
+ return n * d;
3608
+ case 'hours':
3609
+ case 'hour':
3610
+ case 'hrs':
3611
+ case 'hr':
3612
+ case 'h':
3613
+ return n * h;
3614
+ case 'minutes':
3615
+ case 'minute':
3616
+ case 'mins':
3617
+ case 'min':
3618
+ case 'm':
3619
+ return n * m;
3620
+ case 'seconds':
3621
+ case 'second':
3622
+ case 'secs':
3623
+ case 'sec':
3624
+ case 's':
3625
+ return n * s;
3626
+ case 'milliseconds':
3627
+ case 'millisecond':
3628
+ case 'msecs':
3629
+ case 'msec':
3630
+ case 'ms':
3631
+ return n;
3632
+ default:
3633
+ return undefined;
3634
+ }
3635
+ }
3636
+
3637
+ /**
3638
+ * Short format for `ms`.
3639
+ *
3640
+ * @param {Number} ms
3641
+ * @return {String}
3642
+ * @api private
3643
+ */
3644
+
3645
+ function fmtShort(ms) {
3646
+ if (ms >= d) {
3647
+ return Math.round(ms / d) + 'd';
3648
+ }
3649
+ if (ms >= h) {
3650
+ return Math.round(ms / h) + 'h';
3651
+ }
3652
+ if (ms >= m) {
3653
+ return Math.round(ms / m) + 'm';
3654
+ }
3655
+ if (ms >= s) {
3656
+ return Math.round(ms / s) + 's';
3657
+ }
3658
+ return ms + 'ms';
3659
+ }
3660
+
3661
+ /**
3662
+ * Long format for `ms`.
3663
+ *
3664
+ * @param {Number} ms
3665
+ * @return {String}
3666
+ * @api private
3667
+ */
3668
+
3669
+ function fmtLong(ms) {
3670
+ return plural(ms, d, 'day') ||
3671
+ plural(ms, h, 'hour') ||
3672
+ plural(ms, m, 'minute') ||
3673
+ plural(ms, s, 'second') ||
3674
+ ms + ' ms';
3675
+ }
3676
+
3677
+ /**
3678
+ * Pluralization helper.
3679
+ */
3680
+
3681
+ function plural(ms, n, name) {
3682
+ if (ms < n) {
3683
+ return;
3684
+ }
3685
+ if (ms < n * 1.5) {
3686
+ return Math.floor(ms / n) + ' ' + name;
3687
+ }
3688
+ return Math.ceil(ms / n) + ' ' + name + 's';
3689
+ }
3690
+
3691
+ var debug = createCommonjsModule(function (module, exports) {
3692
+ /**
3693
+ * This is the common logic for both the Node.js and web browser
3694
+ * implementations of `debug()`.
3695
+ *
3696
+ * Expose `debug()` as the module.
3697
+ */
3698
+
3699
+ exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
3700
+ exports.coerce = coerce;
3701
+ exports.disable = disable;
3702
+ exports.enable = enable;
3703
+ exports.enabled = enabled;
3704
+ exports.humanize = ms;
3705
+
3706
+ /**
3707
+ * The currently active debug mode names, and names to skip.
3708
+ */
3709
+
3710
+ exports.names = [];
3711
+ exports.skips = [];
3712
+
3713
+ /**
3714
+ * Map of special "%n" handling functions, for the debug "format" argument.
3715
+ *
3716
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
3717
+ */
3718
+
3719
+ exports.formatters = {};
3720
+
3721
+ /**
3722
+ * Previous log timestamp.
3723
+ */
3724
+
3725
+ var prevTime;
3726
+
3727
+ /**
3728
+ * Select a color.
3729
+ * @param {String} namespace
3730
+ * @return {Number}
3731
+ * @api private
3732
+ */
3733
+
3734
+ function selectColor(namespace) {
3735
+ var hash = 0, i;
3736
+
3737
+ for (i in namespace) {
3738
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
3739
+ hash |= 0; // Convert to 32bit integer
3740
+ }
3741
+
3742
+ return exports.colors[Math.abs(hash) % exports.colors.length];
3743
+ }
3744
+
3745
+ /**
3746
+ * Create a debugger with the given `namespace`.
3747
+ *
3748
+ * @param {String} namespace
3749
+ * @return {Function}
3750
+ * @api public
3751
+ */
3752
+
3753
+ function createDebug(namespace) {
3754
+
3755
+ function debug() {
3756
+ // disabled?
3757
+ if (!debug.enabled) return;
3758
+
3759
+ var self = debug;
3760
+
3761
+ // set `diff` timestamp
3762
+ var curr = +new Date();
3763
+ var ms$$1 = curr - (prevTime || curr);
3764
+ self.diff = ms$$1;
3765
+ self.prev = prevTime;
3766
+ self.curr = curr;
3767
+ prevTime = curr;
3768
+
3769
+ // turn the `arguments` into a proper Array
3770
+ var args = new Array(arguments.length);
3771
+ for (var i = 0; i < args.length; i++) {
3772
+ args[i] = arguments[i];
3773
+ }
3774
+
3775
+ args[0] = exports.coerce(args[0]);
3776
+
3777
+ if ('string' !== typeof args[0]) {
3778
+ // anything else let's inspect with %O
3779
+ args.unshift('%O');
3780
+ }
3781
+
3782
+ // apply any `formatters` transformations
3783
+ var index = 0;
3784
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
3785
+ // if we encounter an escaped % then don't increase the array index
3786
+ if (match === '%%') return match;
3787
+ index++;
3788
+ var formatter = exports.formatters[format];
3789
+ if ('function' === typeof formatter) {
3790
+ var val = args[index];
3791
+ match = formatter.call(self, val);
3792
+
3793
+ // now we need to remove `args[index]` since it's inlined in the `format`
3794
+ args.splice(index, 1);
3795
+ index--;
3796
+ }
3797
+ return match;
3798
+ });
3799
+
3800
+ // apply env-specific formatting (colors, etc.)
3801
+ exports.formatArgs.call(self, args);
3802
+
3803
+ var logFn = debug.log || exports.log || console.log.bind(console);
3804
+ logFn.apply(self, args);
3805
+ }
3806
+
3807
+ debug.namespace = namespace;
3808
+ debug.enabled = exports.enabled(namespace);
3809
+ debug.useColors = exports.useColors();
3810
+ debug.color = selectColor(namespace);
3811
+
3812
+ // env-specific initialization logic for debug instances
3813
+ if ('function' === typeof exports.init) {
3814
+ exports.init(debug);
3815
+ }
3816
+
3817
+ return debug;
3818
+ }
3819
+
3820
+ /**
3821
+ * Enables a debug mode by namespaces. This can include modes
3822
+ * separated by a colon and wildcards.
3823
+ *
3824
+ * @param {String} namespaces
3825
+ * @api public
3826
+ */
3827
+
3828
+ function enable(namespaces) {
3829
+ exports.save(namespaces);
3830
+
3831
+ exports.names = [];
3832
+ exports.skips = [];
3833
+
3834
+ var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
3835
+ var len = split.length;
3836
+
3837
+ for (var i = 0; i < len; i++) {
3838
+ if (!split[i]) continue; // ignore empty strings
3839
+ namespaces = split[i].replace(/\*/g, '.*?');
3840
+ if (namespaces[0] === '-') {
3841
+ exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
3842
+ } else {
3843
+ exports.names.push(new RegExp('^' + namespaces + '$'));
3844
+ }
3845
+ }
3846
+ }
3847
+
3848
+ /**
3849
+ * Disable debug output.
3850
+ *
3851
+ * @api public
3852
+ */
3853
+
3854
+ function disable() {
3855
+ exports.enable('');
3856
+ }
3857
+
3858
+ /**
3859
+ * Returns true if the given mode name is enabled, false otherwise.
3860
+ *
3861
+ * @param {String} name
3862
+ * @return {Boolean}
3863
+ * @api public
3864
+ */
3865
+
3866
+ function enabled(name) {
3867
+ var i, len;
3868
+ for (i = 0, len = exports.skips.length; i < len; i++) {
3869
+ if (exports.skips[i].test(name)) {
3870
+ return false;
3871
+ }
3872
+ }
3873
+ for (i = 0, len = exports.names.length; i < len; i++) {
3874
+ if (exports.names[i].test(name)) {
3875
+ return true;
3876
+ }
3877
+ }
3878
+ return false;
3879
+ }
3880
+
3881
+ /**
3882
+ * Coerce `val`.
3883
+ *
3884
+ * @param {Mixed} val
3885
+ * @return {Mixed}
3886
+ * @api private
3887
+ */
3888
+
3889
+ function coerce(val) {
3890
+ if (val instanceof Error) return val.stack || val.message;
3891
+ return val;
3892
+ }
3893
+ });
3894
+ var debug_1 = debug.coerce;
3895
+ var debug_2 = debug.disable;
3896
+ var debug_3 = debug.enable;
3897
+ var debug_4 = debug.enabled;
3898
+ var debug_5 = debug.humanize;
3899
+ var debug_6 = debug.names;
3900
+ var debug_7 = debug.skips;
3901
+ var debug_8 = debug.formatters;
3902
+
3903
+ var browser = createCommonjsModule(function (module, exports) {
3904
+ /**
3905
+ * This is the web browser implementation of `debug()`.
3906
+ *
3907
+ * Expose `debug()` as the module.
3908
+ */
3909
+
3910
+ exports = module.exports = debug;
3911
+ exports.log = log;
3912
+ exports.formatArgs = formatArgs;
3913
+ exports.save = save;
3914
+ exports.load = load;
3915
+ exports.useColors = useColors;
3916
+ exports.storage = 'undefined' != typeof chrome
3917
+ && 'undefined' != typeof chrome.storage
3918
+ ? chrome.storage.local
3919
+ : localstorage();
3920
+
3921
+ /**
3922
+ * Colors.
3923
+ */
3924
+
3925
+ exports.colors = [
3926
+ 'lightseagreen',
3927
+ 'forestgreen',
3928
+ 'goldenrod',
3929
+ 'dodgerblue',
3930
+ 'darkorchid',
3931
+ 'crimson'
3932
+ ];
3933
+
3934
+ /**
3935
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
3936
+ * and the Firebug extension (any Firefox version) are known
3937
+ * to support "%c" CSS customizations.
3938
+ *
3939
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
3940
+ */
3941
+
3942
+ function useColors() {
3943
+ // NB: In an Electron preload script, document will be defined but not fully
3944
+ // initialized. Since we know we're in Chrome, we'll just detect this case
3945
+ // explicitly
3946
+ if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
3947
+ return true;
3948
+ }
3949
+
3950
+ // is webkit? http://stackoverflow.com/a/16459606/376773
3951
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
3952
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
3953
+ // is firebug? http://stackoverflow.com/a/398120/376773
3954
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
3955
+ // is firefox >= v31?
3956
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
3957
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
3958
+ // double check webkit in userAgent just in case we are in a worker
3959
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
3960
+ }
3961
+
3962
+ /**
3963
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
3964
+ */
3965
+
3966
+ exports.formatters.j = function(v) {
3967
+ try {
3968
+ return JSON.stringify(v);
3969
+ } catch (err) {
3970
+ return '[UnexpectedJSONParseError]: ' + err.message;
3971
+ }
3972
+ };
3973
+
3974
+
3975
+ /**
3976
+ * Colorize log arguments if enabled.
3977
+ *
3978
+ * @api public
3979
+ */
3980
+
3981
+ function formatArgs(args) {
3982
+ var useColors = this.useColors;
3983
+
3984
+ args[0] = (useColors ? '%c' : '')
3985
+ + this.namespace
3986
+ + (useColors ? ' %c' : ' ')
3987
+ + args[0]
3988
+ + (useColors ? '%c ' : ' ')
3989
+ + '+' + exports.humanize(this.diff);
3990
+
3991
+ if (!useColors) return;
3992
+
3993
+ var c = 'color: ' + this.color;
3994
+ args.splice(1, 0, c, 'color: inherit');
3995
+
3996
+ // the final "%c" is somewhat tricky, because there could be other
3997
+ // arguments passed either before or after the %c, so we need to
3998
+ // figure out the correct index to insert the CSS into
3999
+ var index = 0;
4000
+ var lastC = 0;
4001
+ args[0].replace(/%[a-zA-Z%]/g, function(match) {
4002
+ if ('%%' === match) return;
4003
+ index++;
4004
+ if ('%c' === match) {
4005
+ // we only are interested in the *last* %c
4006
+ // (the user may have provided their own)
4007
+ lastC = index;
4008
+ }
4009
+ });
4010
+
4011
+ args.splice(lastC, 0, c);
4012
+ }
4013
+
4014
+ /**
4015
+ * Invokes `console.log()` when available.
4016
+ * No-op when `console.log` is not a "function".
4017
+ *
4018
+ * @api public
4019
+ */
4020
+
4021
+ function log() {
4022
+ // this hackery is required for IE8/9, where
4023
+ // the `console.log` function doesn't have 'apply'
4024
+ return 'object' === typeof console
4025
+ && console.log
4026
+ && Function.prototype.apply.call(console.log, console, arguments);
4027
+ }
4028
+
4029
+ /**
4030
+ * Save `namespaces`.
4031
+ *
4032
+ * @param {String} namespaces
4033
+ * @api private
4034
+ */
4035
+
4036
+ function save(namespaces) {
4037
+ try {
4038
+ if (null == namespaces) {
4039
+ exports.storage.removeItem('debug');
4040
+ } else {
4041
+ exports.storage.debug = namespaces;
4042
+ }
4043
+ } catch(e) {}
4044
+ }
4045
+
4046
+ /**
4047
+ * Load `namespaces`.
4048
+ *
4049
+ * @return {String} returns the previously persisted debug modes
4050
+ * @api private
4051
+ */
4052
+
4053
+ function load() {
4054
+ var r;
4055
+ try {
4056
+ r = exports.storage.debug;
4057
+ } catch(e) {}
4058
+
4059
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
4060
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
4061
+ r = process.env.DEBUG;
4062
+ }
4063
+
4064
+ return r;
4065
+ }
4066
+
4067
+ /**
4068
+ * Enable namespaces listed in `localStorage.debug` initially.
4069
+ */
4070
+
4071
+ exports.enable(load());
4072
+
4073
+ /**
4074
+ * Localstorage attempts to return the localstorage.
4075
+ *
4076
+ * This is necessary because safari throws
4077
+ * when a user disables cookies/localstorage
4078
+ * and you attempt to access it.
4079
+ *
4080
+ * @return {LocalStorage}
4081
+ * @api private
4082
+ */
4083
+
4084
+ function localstorage() {
4085
+ try {
4086
+ return window.localStorage;
4087
+ } catch (e) {}
4088
+ }
4089
+ });
4090
+ var browser_1 = browser.log;
4091
+ var browser_2 = browser.formatArgs;
4092
+ var browser_3 = browser.save;
4093
+ var browser_4 = browser.load;
4094
+ var browser_5 = browser.useColors;
4095
+ var browser_6 = browser.storage;
4096
+ var browser_7 = browser.colors;
4097
+
4098
+ // MIT lisence
4099
+ // from https://github.com/substack/tty-browserify/blob/1ba769a6429d242f36226538835b4034bf6b7886/index.js
4100
+
4101
+ function isatty() {
4102
+ return false;
4103
+ }
4104
+
4105
+ function ReadStream() {
4106
+ throw new Error('tty.ReadStream is not implemented');
4107
+ }
4108
+
4109
+ function WriteStream() {
4110
+ throw new Error('tty.ReadStream is not implemented');
4111
+ }
4112
+
4113
+ var tty = {
4114
+ isatty: isatty,
4115
+ ReadStream: ReadStream,
4116
+ WriteStream: WriteStream
4117
+ };
4118
+
4119
+ // shim for using process in browser
4120
+ // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
4121
+
4122
+ function defaultSetTimout() {
4123
+ throw new Error('setTimeout has not been defined');
4124
+ }
4125
+ function defaultClearTimeout () {
4126
+ throw new Error('clearTimeout has not been defined');
4127
+ }
4128
+ var cachedSetTimeout = defaultSetTimout;
4129
+ var cachedClearTimeout = defaultClearTimeout;
4130
+ if (typeof global.setTimeout === 'function') {
4131
+ cachedSetTimeout = setTimeout;
4132
+ }
4133
+ if (typeof global.clearTimeout === 'function') {
4134
+ cachedClearTimeout = clearTimeout;
4135
+ }
4136
+
4137
+ function runTimeout(fun) {
4138
+ if (cachedSetTimeout === setTimeout) {
4139
+ //normal enviroments in sane situations
4140
+ return setTimeout(fun, 0);
4141
+ }
4142
+ // if setTimeout wasn't available but was latter defined
4143
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
4144
+ cachedSetTimeout = setTimeout;
4145
+ return setTimeout(fun, 0);
4146
+ }
4147
+ try {
4148
+ // when when somebody has screwed with setTimeout but no I.E. maddness
4149
+ return cachedSetTimeout(fun, 0);
4150
+ } catch(e){
4151
+ try {
4152
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
4153
+ return cachedSetTimeout.call(null, fun, 0);
4154
+ } catch(e){
4155
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
4156
+ return cachedSetTimeout.call(this, fun, 0);
4157
+ }
4158
+ }
4159
+
4160
+
4161
+ }
4162
+ function runClearTimeout(marker) {
4163
+ if (cachedClearTimeout === clearTimeout) {
4164
+ //normal enviroments in sane situations
4165
+ return clearTimeout(marker);
4166
+ }
4167
+ // if clearTimeout wasn't available but was latter defined
4168
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
4169
+ cachedClearTimeout = clearTimeout;
4170
+ return clearTimeout(marker);
4171
+ }
4172
+ try {
4173
+ // when when somebody has screwed with setTimeout but no I.E. maddness
4174
+ return cachedClearTimeout(marker);
4175
+ } catch (e){
4176
+ try {
4177
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
4178
+ return cachedClearTimeout.call(null, marker);
4179
+ } catch (e){
4180
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
4181
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
4182
+ return cachedClearTimeout.call(this, marker);
4183
+ }
4184
+ }
4185
+
4186
+
4187
+
4188
+ }
4189
+ var queue = [];
4190
+ var draining = false;
4191
+ var currentQueue;
4192
+ var queueIndex = -1;
4193
+
4194
+ function cleanUpNextTick() {
4195
+ if (!draining || !currentQueue) {
4196
+ return;
4197
+ }
4198
+ draining = false;
4199
+ if (currentQueue.length) {
4200
+ queue = currentQueue.concat(queue);
4201
+ } else {
4202
+ queueIndex = -1;
4203
+ }
4204
+ if (queue.length) {
4205
+ drainQueue();
4206
+ }
4207
+ }
4208
+
4209
+ function drainQueue() {
4210
+ if (draining) {
4211
+ return;
4212
+ }
4213
+ var timeout = runTimeout(cleanUpNextTick);
4214
+ draining = true;
4215
+
4216
+ var len = queue.length;
4217
+ while(len) {
4218
+ currentQueue = queue;
4219
+ queue = [];
4220
+ while (++queueIndex < len) {
4221
+ if (currentQueue) {
4222
+ currentQueue[queueIndex].run();
4223
+ }
4224
+ }
4225
+ queueIndex = -1;
4226
+ len = queue.length;
4227
+ }
4228
+ currentQueue = null;
4229
+ draining = false;
4230
+ runClearTimeout(timeout);
4231
+ }
4232
+ function nextTick(fun) {
4233
+ var args = new Array(arguments.length - 1);
4234
+ if (arguments.length > 1) {
4235
+ for (var i = 1; i < arguments.length; i++) {
4236
+ args[i - 1] = arguments[i];
4237
+ }
4238
+ }
4239
+ queue.push(new Item(fun, args));
4240
+ if (queue.length === 1 && !draining) {
4241
+ runTimeout(drainQueue);
4242
+ }
4243
+ }
4244
+ // v8 likes predictible objects
4245
+ function Item(fun, array) {
4246
+ this.fun = fun;
4247
+ this.array = array;
4248
+ }
4249
+ Item.prototype.run = function () {
4250
+ this.fun.apply(null, this.array);
4251
+ };
4252
+ var title = 'browser';
4253
+ var platform = 'browser';
4254
+ var browser$1 = true;
4255
+ var env = {};
4256
+ var argv = [];
4257
+ var version = ''; // empty string to avoid regexp issues
4258
+ var versions = {};
4259
+ var release = {};
4260
+ var config = {};
4261
+
4262
+ function noop() {}
4263
+
4264
+ var on = noop;
4265
+ var addListener = noop;
4266
+ var once = noop;
4267
+ var off = noop;
4268
+ var removeListener = noop;
4269
+ var removeAllListeners = noop;
4270
+ var emit = noop;
4271
+
4272
+ function binding(name) {
4273
+ throw new Error('process.binding is not supported');
4274
+ }
4275
+
4276
+ function cwd () { return '/' }
4277
+ function chdir (dir) {
4278
+ throw new Error('process.chdir is not supported');
4279
+ }function umask() { return 0; }
4280
+
4281
+ // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
4282
+ var performance = global.performance || {};
4283
+ var performanceNow =
4284
+ performance.now ||
4285
+ performance.mozNow ||
4286
+ performance.msNow ||
4287
+ performance.oNow ||
4288
+ performance.webkitNow ||
4289
+ function(){ return (new Date()).getTime() };
4290
+
4291
+ // generate timestamp or delta
4292
+ // see http://nodejs.org/api/process.html#process_process_hrtime
4293
+ function hrtime(previousTimestamp){
4294
+ var clocktime = performanceNow.call(performance)*1e-3;
4295
+ var seconds = Math.floor(clocktime);
4296
+ var nanoseconds = Math.floor((clocktime%1)*1e9);
4297
+ if (previousTimestamp) {
4298
+ seconds = seconds - previousTimestamp[0];
4299
+ nanoseconds = nanoseconds - previousTimestamp[1];
4300
+ if (nanoseconds<0) {
4301
+ seconds--;
4302
+ nanoseconds += 1e9;
4303
+ }
4304
+ }
4305
+ return [seconds,nanoseconds]
4306
+ }
4307
+
4308
+ var startTime = new Date();
4309
+ function uptime() {
4310
+ var currentTime = new Date();
4311
+ var dif = currentTime - startTime;
4312
+ return dif / 1000;
4313
+ }
4314
+
4315
+ var process$1 = {
4316
+ nextTick: nextTick,
4317
+ title: title,
4318
+ browser: browser$1,
4319
+ env: env,
4320
+ argv: argv,
4321
+ version: version,
4322
+ versions: versions,
4323
+ on: on,
4324
+ addListener: addListener,
4325
+ once: once,
4326
+ off: off,
4327
+ removeListener: removeListener,
4328
+ removeAllListeners: removeAllListeners,
4329
+ emit: emit,
4330
+ binding: binding,
4331
+ cwd: cwd,
4332
+ chdir: chdir,
4333
+ umask: umask,
4334
+ hrtime: hrtime,
4335
+ platform: platform,
4336
+ release: release,
4337
+ config: config,
4338
+ uptime: uptime
4339
+ };
4340
+
4341
+ var inherits$1;
4342
+ if (typeof Object.create === 'function'){
4343
+ inherits$1 = function inherits(ctor, superCtor) {
4344
+ // implementation from standard node.js 'util' module
4345
+ ctor.super_ = superCtor;
4346
+ ctor.prototype = Object.create(superCtor.prototype, {
4347
+ constructor: {
4348
+ value: ctor,
4349
+ enumerable: false,
4350
+ writable: true,
4351
+ configurable: true
4352
+ }
4353
+ });
4354
+ };
4355
+ } else {
4356
+ inherits$1 = function inherits(ctor, superCtor) {
4357
+ ctor.super_ = superCtor;
4358
+ var TempCtor = function () {};
4359
+ TempCtor.prototype = superCtor.prototype;
4360
+ ctor.prototype = new TempCtor();
4361
+ ctor.prototype.constructor = ctor;
4362
+ };
4363
+ }
4364
+ var inherits$2 = inherits$1;
4365
+
4366
+ // Copyright Joyent, Inc. and other Node contributors.
4367
+ var formatRegExp = /%[sdj%]/g;
4368
+ function format(f) {
4369
+ if (!isString(f)) {
4370
+ var objects = [];
4371
+ for (var i = 0; i < arguments.length; i++) {
4372
+ objects.push(inspect(arguments[i]));
4373
+ }
4374
+ return objects.join(' ');
4375
+ }
4376
+
4377
+ var i = 1;
4378
+ var args = arguments;
4379
+ var len = args.length;
4380
+ var str = String(f).replace(formatRegExp, function(x) {
4381
+ if (x === '%%') return '%';
4382
+ if (i >= len) return x;
4383
+ switch (x) {
4384
+ case '%s': return String(args[i++]);
4385
+ case '%d': return Number(args[i++]);
4386
+ case '%j':
4387
+ try {
4388
+ return JSON.stringify(args[i++]);
4389
+ } catch (_) {
4390
+ return '[Circular]';
4391
+ }
4392
+ default:
4393
+ return x;
4394
+ }
4395
+ });
4396
+ for (var x = args[i]; i < len; x = args[++i]) {
4397
+ if (isNull(x) || !isObject(x)) {
4398
+ str += ' ' + x;
4399
+ } else {
4400
+ str += ' ' + inspect(x);
4401
+ }
4402
+ }
4403
+ return str;
4404
+ }
4405
+
4406
+ // Mark that a method should not be used.
4407
+ // Returns a modified function which warns once by default.
4408
+ // If --no-deprecation is set, then it is a no-op.
4409
+ function deprecate(fn, msg) {
4410
+ // Allow for deprecating things in the process of starting up.
4411
+ if (isUndefined(global.process)) {
4412
+ return function() {
4413
+ return deprecate(fn, msg).apply(this, arguments);
4414
+ };
4415
+ }
4416
+
4417
+ var warned = false;
4418
+ function deprecated() {
4419
+ if (!warned) {
4420
+ {
4421
+ console.error(msg);
4422
+ }
4423
+ warned = true;
4424
+ }
4425
+ return fn.apply(this, arguments);
4426
+ }
4427
+
4428
+ return deprecated;
4429
+ }
4430
+
4431
+ var debugs = {};
4432
+ var debugEnviron;
4433
+ function debuglog(set) {
4434
+ if (isUndefined(debugEnviron))
4435
+ debugEnviron = process$1.env.NODE_DEBUG || '';
4436
+ set = set.toUpperCase();
4437
+ if (!debugs[set]) {
4438
+ if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
4439
+ var pid = 0;
4440
+ debugs[set] = function() {
4441
+ var msg = format.apply(null, arguments);
4442
+ console.error('%s %d: %s', set, pid, msg);
4443
+ };
4444
+ } else {
4445
+ debugs[set] = function() {};
4446
+ }
4447
+ }
4448
+ return debugs[set];
4449
+ }
4450
+
4451
+ /**
4452
+ * Echos the value of a value. Trys to print the value out
4453
+ * in the best way possible given the different types.
4454
+ *
4455
+ * @param {Object} obj The object to print out.
4456
+ * @param {Object} opts Optional options object that alters the output.
4457
+ */
4458
+ /* legacy: obj, showHidden, depth, colors*/
4459
+ function inspect(obj, opts) {
4460
+ // default options
4461
+ var ctx = {
4462
+ seen: [],
4463
+ stylize: stylizeNoColor
4464
+ };
4465
+ // legacy...
4466
+ if (arguments.length >= 3) ctx.depth = arguments[2];
4467
+ if (arguments.length >= 4) ctx.colors = arguments[3];
4468
+ if (isBoolean(opts)) {
4469
+ // legacy...
4470
+ ctx.showHidden = opts;
4471
+ } else if (opts) {
4472
+ // got an "options" object
4473
+ _extend(ctx, opts);
4474
+ }
4475
+ // set default options
4476
+ if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
4477
+ if (isUndefined(ctx.depth)) ctx.depth = 2;
4478
+ if (isUndefined(ctx.colors)) ctx.colors = false;
4479
+ if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
4480
+ if (ctx.colors) ctx.stylize = stylizeWithColor;
4481
+ return formatValue(ctx, obj, ctx.depth);
4482
+ }
4483
+
4484
+ // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
4485
+ inspect.colors = {
4486
+ 'bold' : [1, 22],
4487
+ 'italic' : [3, 23],
4488
+ 'underline' : [4, 24],
4489
+ 'inverse' : [7, 27],
4490
+ 'white' : [37, 39],
4491
+ 'grey' : [90, 39],
4492
+ 'black' : [30, 39],
4493
+ 'blue' : [34, 39],
4494
+ 'cyan' : [36, 39],
4495
+ 'green' : [32, 39],
4496
+ 'magenta' : [35, 39],
4497
+ 'red' : [31, 39],
4498
+ 'yellow' : [33, 39]
4499
+ };
4500
+
4501
+ // Don't use 'blue' not visible on cmd.exe
4502
+ inspect.styles = {
4503
+ 'special': 'cyan',
4504
+ 'number': 'yellow',
4505
+ 'boolean': 'yellow',
4506
+ 'undefined': 'grey',
4507
+ 'null': 'bold',
4508
+ 'string': 'green',
4509
+ 'date': 'magenta',
4510
+ // "name": intentionally not styling
4511
+ 'regexp': 'red'
4512
+ };
4513
+
4514
+
4515
+ function stylizeWithColor(str, styleType) {
4516
+ var style = inspect.styles[styleType];
4517
+
4518
+ if (style) {
4519
+ return '\u001b[' + inspect.colors[style][0] + 'm' + str +
4520
+ '\u001b[' + inspect.colors[style][1] + 'm';
4521
+ } else {
4522
+ return str;
4523
+ }
4524
+ }
4525
+
4526
+
4527
+ function stylizeNoColor(str, styleType) {
4528
+ return str;
4529
+ }
4530
+
4531
+
4532
+ function arrayToHash(array) {
4533
+ var hash = {};
4534
+
4535
+ array.forEach(function(val, idx) {
4536
+ hash[val] = true;
4537
+ });
4538
+
4539
+ return hash;
4540
+ }
4541
+
4542
+
4543
+ function formatValue(ctx, value, recurseTimes) {
4544
+ // Provide a hook for user-specified inspect functions.
4545
+ // Check that value is an object with an inspect function on it
4546
+ if (ctx.customInspect &&
4547
+ value &&
4548
+ isFunction(value.inspect) &&
4549
+ // Filter out the util module, it's inspect function is special
4550
+ value.inspect !== inspect &&
4551
+ // Also filter out any prototype objects using the circular check.
4552
+ !(value.constructor && value.constructor.prototype === value)) {
4553
+ var ret = value.inspect(recurseTimes, ctx);
4554
+ if (!isString(ret)) {
4555
+ ret = formatValue(ctx, ret, recurseTimes);
4556
+ }
4557
+ return ret;
4558
+ }
4559
+
4560
+ // Primitive types cannot have properties
4561
+ var primitive = formatPrimitive(ctx, value);
4562
+ if (primitive) {
4563
+ return primitive;
4564
+ }
4565
+
4566
+ // Look up the keys of the object.
4567
+ var keys = Object.keys(value);
4568
+ var visibleKeys = arrayToHash(keys);
4569
+
4570
+ if (ctx.showHidden) {
4571
+ keys = Object.getOwnPropertyNames(value);
4572
+ }
4573
+
4574
+ // IE doesn't make error fields non-enumerable
4575
+ // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
4576
+ if (isError(value)
4577
+ && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
4578
+ return formatError(value);
4579
+ }
4580
+
4581
+ // Some type of object without properties can be shortcutted.
4582
+ if (keys.length === 0) {
4583
+ if (isFunction(value)) {
4584
+ var name = value.name ? ': ' + value.name : '';
4585
+ return ctx.stylize('[Function' + name + ']', 'special');
4586
+ }
4587
+ if (isRegExp(value)) {
4588
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
4589
+ }
4590
+ if (isDate(value)) {
4591
+ return ctx.stylize(Date.prototype.toString.call(value), 'date');
4592
+ }
4593
+ if (isError(value)) {
4594
+ return formatError(value);
4595
+ }
4596
+ }
4597
+
4598
+ var base = '', array = false, braces = ['{', '}'];
4599
+
4600
+ // Make Array say that they are Array
4601
+ if (isArray$1(value)) {
4602
+ array = true;
4603
+ braces = ['[', ']'];
4604
+ }
4605
+
4606
+ // Make functions say that they are functions
4607
+ if (isFunction(value)) {
4608
+ var n = value.name ? ': ' + value.name : '';
4609
+ base = ' [Function' + n + ']';
4610
+ }
4611
+
4612
+ // Make RegExps say that they are RegExps
4613
+ if (isRegExp(value)) {
4614
+ base = ' ' + RegExp.prototype.toString.call(value);
4615
+ }
4616
+
4617
+ // Make dates with properties first say the date
4618
+ if (isDate(value)) {
4619
+ base = ' ' + Date.prototype.toUTCString.call(value);
4620
+ }
4621
+
4622
+ // Make error with message first say the error
4623
+ if (isError(value)) {
4624
+ base = ' ' + formatError(value);
4625
+ }
4626
+
4627
+ if (keys.length === 0 && (!array || value.length == 0)) {
4628
+ return braces[0] + base + braces[1];
4629
+ }
4630
+
4631
+ if (recurseTimes < 0) {
4632
+ if (isRegExp(value)) {
4633
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
4634
+ } else {
4635
+ return ctx.stylize('[Object]', 'special');
4636
+ }
4637
+ }
4638
+
4639
+ ctx.seen.push(value);
4640
+
4641
+ var output;
4642
+ if (array) {
4643
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
4644
+ } else {
4645
+ output = keys.map(function(key) {
4646
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
4647
+ });
4648
+ }
4649
+
4650
+ ctx.seen.pop();
4651
+
4652
+ return reduceToSingleString(output, base, braces);
4653
+ }
4654
+
4655
+
4656
+ function formatPrimitive(ctx, value) {
4657
+ if (isUndefined(value))
4658
+ return ctx.stylize('undefined', 'undefined');
4659
+ if (isString(value)) {
4660
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
4661
+ .replace(/'/g, "\\'")
4662
+ .replace(/\\"/g, '"') + '\'';
4663
+ return ctx.stylize(simple, 'string');
4664
+ }
4665
+ if (isNumber(value))
4666
+ return ctx.stylize('' + value, 'number');
4667
+ if (isBoolean(value))
4668
+ return ctx.stylize('' + value, 'boolean');
4669
+ // For some reason typeof null is "object", so special case here.
4670
+ if (isNull(value))
4671
+ return ctx.stylize('null', 'null');
4672
+ }
4673
+
4674
+
4675
+ function formatError(value) {
4676
+ return '[' + Error.prototype.toString.call(value) + ']';
4677
+ }
4678
+
4679
+
4680
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
4681
+ var output = [];
4682
+ for (var i = 0, l = value.length; i < l; ++i) {
4683
+ if (hasOwnProperty(value, String(i))) {
4684
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
4685
+ String(i), true));
4686
+ } else {
4687
+ output.push('');
4688
+ }
4689
+ }
4690
+ keys.forEach(function(key) {
4691
+ if (!key.match(/^\d+$/)) {
4692
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
4693
+ key, true));
4694
+ }
4695
+ });
4696
+ return output;
4697
+ }
4698
+
4699
+
4700
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
4701
+ var name, str, desc;
4702
+ desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
4703
+ if (desc.get) {
4704
+ if (desc.set) {
4705
+ str = ctx.stylize('[Getter/Setter]', 'special');
4706
+ } else {
4707
+ str = ctx.stylize('[Getter]', 'special');
4708
+ }
4709
+ } else {
4710
+ if (desc.set) {
4711
+ str = ctx.stylize('[Setter]', 'special');
4712
+ }
4713
+ }
4714
+ if (!hasOwnProperty(visibleKeys, key)) {
4715
+ name = '[' + key + ']';
4716
+ }
4717
+ if (!str) {
4718
+ if (ctx.seen.indexOf(desc.value) < 0) {
4719
+ if (isNull(recurseTimes)) {
4720
+ str = formatValue(ctx, desc.value, null);
4721
+ } else {
4722
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
4723
+ }
4724
+ if (str.indexOf('\n') > -1) {
4725
+ if (array) {
4726
+ str = str.split('\n').map(function(line) {
4727
+ return ' ' + line;
4728
+ }).join('\n').substr(2);
4729
+ } else {
4730
+ str = '\n' + str.split('\n').map(function(line) {
4731
+ return ' ' + line;
4732
+ }).join('\n');
4733
+ }
4734
+ }
4735
+ } else {
4736
+ str = ctx.stylize('[Circular]', 'special');
4737
+ }
4738
+ }
4739
+ if (isUndefined(name)) {
4740
+ if (array && key.match(/^\d+$/)) {
4741
+ return str;
4742
+ }
4743
+ name = JSON.stringify('' + key);
4744
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
4745
+ name = name.substr(1, name.length - 2);
4746
+ name = ctx.stylize(name, 'name');
4747
+ } else {
4748
+ name = name.replace(/'/g, "\\'")
4749
+ .replace(/\\"/g, '"')
4750
+ .replace(/(^"|"$)/g, "'");
4751
+ name = ctx.stylize(name, 'string');
4752
+ }
4753
+ }
4754
+
4755
+ return name + ': ' + str;
4756
+ }
4757
+
4758
+
4759
+ function reduceToSingleString(output, base, braces) {
4760
+ var length = output.reduce(function(prev, cur) {
4761
+ if (cur.indexOf('\n') >= 0) ;
4762
+ return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
4763
+ }, 0);
4764
+
4765
+ if (length > 60) {
4766
+ return braces[0] +
4767
+ (base === '' ? '' : base + '\n ') +
4768
+ ' ' +
4769
+ output.join(',\n ') +
4770
+ ' ' +
4771
+ braces[1];
4772
+ }
4773
+
4774
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
4775
+ }
4776
+
4777
+
4778
+ // NOTE: These type checking functions intentionally don't use `instanceof`
4779
+ // because it is fragile and can be easily faked with `Object.create()`.
4780
+ function isArray$1(ar) {
4781
+ return Array.isArray(ar);
4782
+ }
4783
+
4784
+ function isBoolean(arg) {
4785
+ return typeof arg === 'boolean';
4786
+ }
4787
+
4788
+ function isNull(arg) {
4789
+ return arg === null;
4790
+ }
4791
+
4792
+ function isNullOrUndefined(arg) {
4793
+ return arg == null;
4794
+ }
4795
+
4796
+ function isNumber(arg) {
4797
+ return typeof arg === 'number';
4798
+ }
4799
+
4800
+ function isString(arg) {
4801
+ return typeof arg === 'string';
4802
+ }
4803
+
4804
+ function isSymbol(arg) {
4805
+ return typeof arg === 'symbol';
4806
+ }
4807
+
4808
+ function isUndefined(arg) {
4809
+ return arg === void 0;
4810
+ }
4811
+
4812
+ function isRegExp(re) {
4813
+ return isObject(re) && objectToString(re) === '[object RegExp]';
4814
+ }
4815
+
4816
+ function isObject(arg) {
4817
+ return typeof arg === 'object' && arg !== null;
4818
+ }
4819
+
4820
+ function isDate(d) {
4821
+ return isObject(d) && objectToString(d) === '[object Date]';
4822
+ }
4823
+
4824
+ function isError(e) {
4825
+ return isObject(e) &&
4826
+ (objectToString(e) === '[object Error]' || e instanceof Error);
4827
+ }
4828
+
4829
+ function isFunction(arg) {
4830
+ return typeof arg === 'function';
4831
+ }
4832
+
4833
+ function isPrimitive(arg) {
4834
+ return arg === null ||
4835
+ typeof arg === 'boolean' ||
4836
+ typeof arg === 'number' ||
4837
+ typeof arg === 'string' ||
4838
+ typeof arg === 'symbol' || // ES6 symbol
4839
+ typeof arg === 'undefined';
4840
+ }
4841
+
4842
+ function isBuffer(maybeBuf) {
4843
+ return Buffer.isBuffer(maybeBuf);
4844
+ }
4845
+
4846
+ function objectToString(o) {
4847
+ return Object.prototype.toString.call(o);
4848
+ }
4849
+
4850
+
4851
+ function pad(n) {
4852
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
4853
+ }
4854
+
4855
+
4856
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
4857
+ 'Oct', 'Nov', 'Dec'];
4858
+
4859
+ // 26 Feb 16:19:34
4860
+ function timestamp() {
4861
+ var d = new Date();
4862
+ var time = [pad(d.getHours()),
4863
+ pad(d.getMinutes()),
4864
+ pad(d.getSeconds())].join(':');
4865
+ return [d.getDate(), months[d.getMonth()], time].join(' ');
4866
+ }
4867
+
4868
+
4869
+ // log is just a thin wrapper to console.log that prepends a timestamp
4870
+ function log() {
4871
+ console.log('%s - %s', timestamp(), format.apply(null, arguments));
4872
+ }
4873
+
4874
+ function _extend(origin, add) {
4875
+ // Don't do anything if add isn't an object
4876
+ if (!add || !isObject(add)) return origin;
4877
+
4878
+ var keys = Object.keys(add);
4879
+ var i = keys.length;
4880
+ while (i--) {
4881
+ origin[keys[i]] = add[keys[i]];
4882
+ }
4883
+ return origin;
4884
+ }
4885
+ function hasOwnProperty(obj, prop) {
4886
+ return Object.prototype.hasOwnProperty.call(obj, prop);
4887
+ }
4888
+
4889
+ var util = {
4890
+ inherits: inherits$2,
4891
+ _extend: _extend,
4892
+ log: log,
4893
+ isBuffer: isBuffer,
4894
+ isPrimitive: isPrimitive,
4895
+ isFunction: isFunction,
4896
+ isError: isError,
4897
+ isDate: isDate,
4898
+ isObject: isObject,
4899
+ isRegExp: isRegExp,
4900
+ isUndefined: isUndefined,
4901
+ isSymbol: isSymbol,
4902
+ isString: isString,
4903
+ isNumber: isNumber,
4904
+ isNullOrUndefined: isNullOrUndefined,
4905
+ isNull: isNull,
4906
+ isBoolean: isBoolean,
4907
+ isArray: isArray$1,
4908
+ inspect: inspect,
4909
+ deprecate: deprecate,
4910
+ format: format,
4911
+ debuglog: debuglog
4912
+ };
4913
+
4914
+ var require$$2 = {};
4915
+
4916
+ var node = createCommonjsModule(function (module, exports) {
4917
+ /**
4918
+ * Module dependencies.
4919
+ */
4920
+
4921
+
4922
+
4923
+
4924
+ /**
4925
+ * This is the Node.js implementation of `debug()`.
4926
+ *
4927
+ * Expose `debug()` as the module.
4928
+ */
4929
+
4930
+ exports = module.exports = debug;
4931
+ exports.init = init;
4932
+ exports.log = log;
4933
+ exports.formatArgs = formatArgs;
4934
+ exports.save = save;
4935
+ exports.load = load;
4936
+ exports.useColors = useColors;
4937
+
4938
+ /**
4939
+ * Colors.
4940
+ */
4941
+
4942
+ exports.colors = [6, 2, 3, 4, 5, 1];
4943
+
4944
+ /**
4945
+ * Build up the default `inspectOpts` object from the environment variables.
4946
+ *
4947
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
4948
+ */
4949
+
4950
+ exports.inspectOpts = Object.keys(process.env).filter(function (key) {
4951
+ return /^debug_/i.test(key);
4952
+ }).reduce(function (obj, key) {
4953
+ // camel-case
4954
+ var prop = key
4955
+ .substring(6)
4956
+ .toLowerCase()
4957
+ .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
4958
+
4959
+ // coerce string value into JS value
4960
+ var val = process.env[key];
4961
+ if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
4962
+ else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
4963
+ else if (val === 'null') val = null;
4964
+ else val = Number(val);
4965
+
4966
+ obj[prop] = val;
4967
+ return obj;
4968
+ }, {});
4969
+
4970
+ /**
4971
+ * The file descriptor to write the `debug()` calls to.
4972
+ * Set the `DEBUG_FD` env variable to override with another value. i.e.:
4973
+ *
4974
+ * $ DEBUG_FD=3 node script.js 3>debug.log
4975
+ */
4976
+
4977
+ var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
4978
+
4979
+ if (1 !== fd && 2 !== fd) {
4980
+ util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')();
4981
+ }
4982
+
4983
+ var stream = 1 === fd ? process.stdout :
4984
+ 2 === fd ? process.stderr :
4985
+ createWritableStdioStream(fd);
4986
+
4987
+ /**
4988
+ * Is stdout a TTY? Colored output is enabled when `true`.
4989
+ */
4990
+
4991
+ function useColors() {
4992
+ return 'colors' in exports.inspectOpts
4993
+ ? Boolean(exports.inspectOpts.colors)
4994
+ : tty.isatty(fd);
4995
+ }
4996
+
4997
+ /**
4998
+ * Map %o to `util.inspect()`, all on a single line.
4999
+ */
5000
+
5001
+ exports.formatters.o = function(v) {
5002
+ this.inspectOpts.colors = this.useColors;
5003
+ return util.inspect(v, this.inspectOpts)
5004
+ .split('\n').map(function(str) {
5005
+ return str.trim()
5006
+ }).join(' ');
5007
+ };
5008
+
5009
+ /**
5010
+ * Map %o to `util.inspect()`, allowing multiple lines if needed.
5011
+ */
5012
+
5013
+ exports.formatters.O = function(v) {
5014
+ this.inspectOpts.colors = this.useColors;
5015
+ return util.inspect(v, this.inspectOpts);
5016
+ };
5017
+
5018
+ /**
5019
+ * Adds ANSI color escape codes if enabled.
5020
+ *
5021
+ * @api public
5022
+ */
5023
+
5024
+ function formatArgs(args) {
5025
+ var name = this.namespace;
5026
+ var useColors = this.useColors;
5027
+
5028
+ if (useColors) {
5029
+ var c = this.color;
5030
+ var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
5031
+
5032
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
5033
+ args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
5034
+ } else {
5035
+ args[0] = new Date().toUTCString()
5036
+ + ' ' + name + ' ' + args[0];
5037
+ }
5038
+ }
5039
+
5040
+ /**
5041
+ * Invokes `util.format()` with the specified arguments and writes to `stream`.
5042
+ */
5043
+
5044
+ function log() {
5045
+ return stream.write(util.format.apply(util, arguments) + '\n');
5046
+ }
5047
+
5048
+ /**
5049
+ * Save `namespaces`.
5050
+ *
5051
+ * @param {String} namespaces
5052
+ * @api private
5053
+ */
5054
+
5055
+ function save(namespaces) {
5056
+ if (null == namespaces) {
5057
+ // If you set a process.env field to null or undefined, it gets cast to the
5058
+ // string 'null' or 'undefined'. Just delete instead.
5059
+ delete process.env.DEBUG;
5060
+ } else {
5061
+ process.env.DEBUG = namespaces;
5062
+ }
5063
+ }
5064
+
5065
+ /**
5066
+ * Load `namespaces`.
5067
+ *
5068
+ * @return {String} returns the previously persisted debug modes
5069
+ * @api private
5070
+ */
5071
+
5072
+ function load() {
5073
+ return process.env.DEBUG;
5074
+ }
5075
+
5076
+ /**
5077
+ * Copied from `node/src/node.js`.
5078
+ *
5079
+ * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
5080
+ * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
5081
+ */
5082
+
5083
+ function createWritableStdioStream (fd) {
5084
+ var stream;
5085
+ var tty_wrap = process.binding('tty_wrap');
5086
+
5087
+ // Note stream._type is used for test-module-load-list.js
5088
+
5089
+ switch (tty_wrap.guessHandleType(fd)) {
5090
+ case 'TTY':
5091
+ stream = new tty.WriteStream(fd);
5092
+ stream._type = 'tty';
5093
+
5094
+ // Hack to have stream not keep the event loop alive.
5095
+ // See https://github.com/joyent/node/issues/1726
5096
+ if (stream._handle && stream._handle.unref) {
5097
+ stream._handle.unref();
5098
+ }
5099
+ break;
5100
+
5101
+ case 'FILE':
5102
+ var fs = require$$2;
5103
+ stream = new fs.SyncWriteStream(fd, { autoClose: false });
5104
+ stream._type = 'fs';
5105
+ break;
5106
+
5107
+ case 'PIPE':
5108
+ case 'TCP':
5109
+ var net = require$$2;
5110
+ stream = new net.Socket({
5111
+ fd: fd,
5112
+ readable: false,
5113
+ writable: true
5114
+ });
5115
+
5116
+ // FIXME Should probably have an option in net.Socket to create a
5117
+ // stream from an existing fd which is writable only. But for now
5118
+ // we'll just add this hack and set the `readable` member to false.
5119
+ // Test: ./node test/fixtures/echo.js < /etc/passwd
5120
+ stream.readable = false;
5121
+ stream.read = null;
5122
+ stream._type = 'pipe';
5123
+
5124
+ // FIXME Hack to have stream not keep the event loop alive.
5125
+ // See https://github.com/joyent/node/issues/1726
5126
+ if (stream._handle && stream._handle.unref) {
5127
+ stream._handle.unref();
5128
+ }
5129
+ break;
5130
+
5131
+ default:
5132
+ // Probably an error on in uv_guess_handle()
5133
+ throw new Error('Implement me. Unknown stream file type!');
5134
+ }
5135
+
5136
+ // For supporting legacy API we put the FD here.
5137
+ stream.fd = fd;
5138
+
5139
+ stream._isStdio = true;
5140
+
5141
+ return stream;
5142
+ }
5143
+
5144
+ /**
5145
+ * Init logic for `debug` instances.
5146
+ *
5147
+ * Create a new `inspectOpts` object in case `useColors` is set
5148
+ * differently for a particular `debug` instance.
5149
+ */
5150
+
5151
+ function init (debug$$1) {
5152
+ debug$$1.inspectOpts = {};
5153
+
5154
+ var keys = Object.keys(exports.inspectOpts);
5155
+ for (var i = 0; i < keys.length; i++) {
5156
+ debug$$1.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
5157
+ }
5158
+ }
5159
+
5160
+ /**
5161
+ * Enable namespaces listed in `process.env.DEBUG` initially.
5162
+ */
5163
+
5164
+ exports.enable(load());
5165
+ });
5166
+ var node_1 = node.init;
5167
+ var node_2 = node.log;
5168
+ var node_3 = node.formatArgs;
5169
+ var node_4 = node.save;
5170
+ var node_5 = node.load;
5171
+ var node_6 = node.useColors;
5172
+ var node_7 = node.colors;
5173
+ var node_8 = node.inspectOpts;
5174
+
5175
+ var src = createCommonjsModule(function (module) {
5176
+ /**
5177
+ * Detect Electron renderer process, which is node, but we should
5178
+ * treat as a browser.
5179
+ */
5180
+
5181
+ if (typeof process !== 'undefined' && process.type === 'renderer') {
5182
+ module.exports = browser;
5183
+ } else {
5184
+ module.exports = node;
5185
+ }
5186
+ });
5187
+
5188
+ var functionNames = createCommonjsModule(function (module, exports) {
5189
+
5190
+ Object.defineProperty(exports, "__esModule", {
5191
+ value: true
5192
+ });
5193
+
5194
+
5195
+ /**
5196
+ * @see https://developers.google.com/youtube/iframe_api_reference#Functions
5197
+ */
5198
+ exports.default = ['cueVideoById', 'loadVideoById', 'cueVideoByUrl', 'loadVideoByUrl', 'playVideo', 'pauseVideo', 'stopVideo', 'getVideoLoadedFraction', 'cuePlaylist', 'loadPlaylist', 'nextVideo', 'previousVideo', 'playVideoAt', 'setShuffle', 'setLoop', 'getPlaylist', 'getPlaylistIndex', 'setOption', 'mute', 'unMute', 'isMuted', 'setVolume', 'getVolume', 'seekTo', 'getPlayerState', 'getPlaybackRate', 'setPlaybackRate', 'getAvailablePlaybackRates', 'getPlaybackQuality', 'setPlaybackQuality', 'getAvailableQualityLevels', 'getCurrentTime', 'getDuration', 'removeEventListener', 'getVideoUrl', 'getVideoEmbedCode', 'getOptions', 'getOption', 'addEventListener', 'destroy', 'setSize', 'getIframe'];
5199
+ module.exports = exports['default'];
5200
+ });
5201
+
5202
+ unwrapExports(functionNames);
5203
+
5204
+ var eventNames = createCommonjsModule(function (module, exports) {
5205
+
5206
+ Object.defineProperty(exports, "__esModule", {
5207
+ value: true
5208
+ });
5209
+
5210
+
5211
+ /**
5212
+ * @see https://developers.google.com/youtube/iframe_api_reference#Events
5213
+ * `volumeChange` is not officially supported but seems to work
5214
+ * it emits an object: `{volume: 82.6923076923077, muted: false}`
5215
+ */
5216
+ exports.default = ['ready', 'stateChange', 'playbackQualityChange', 'playbackRateChange', 'error', 'apiChange', 'volumeChange'];
5217
+ module.exports = exports['default'];
5218
+ });
5219
+
5220
+ unwrapExports(eventNames);
5221
+
5222
+ var PlayerStates = createCommonjsModule(function (module, exports) {
5223
+
5224
+ Object.defineProperty(exports, "__esModule", {
5225
+ value: true
5226
+ });
5227
+ exports.default = {
5228
+ BUFFERING: 3,
5229
+ ENDED: 0,
5230
+ PAUSED: 2,
5231
+ PLAYING: 1,
5232
+ UNSTARTED: -1,
5233
+ VIDEO_CUED: 5
5234
+ };
5235
+ module.exports = exports["default"];
5236
+ });
5237
+
5238
+ unwrapExports(PlayerStates);
5239
+
5240
+ var FunctionStateMap = createCommonjsModule(function (module, exports) {
5241
+
5242
+ Object.defineProperty(exports, "__esModule", {
5243
+ value: true
5244
+ });
5245
+
5246
+
5247
+
5248
+ var _PlayerStates2 = _interopRequireDefault(PlayerStates);
5249
+
5250
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5251
+
5252
+ exports.default = {
5253
+ pauseVideo: {
5254
+ acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PAUSED],
5255
+ stateChangeRequired: false
5256
+ },
5257
+ playVideo: {
5258
+ acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PLAYING],
5259
+ stateChangeRequired: false
5260
+ },
5261
+ seekTo: {
5262
+ acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PLAYING, _PlayerStates2.default.PAUSED],
5263
+ stateChangeRequired: true,
5264
+
5265
+ // TRICKY: `seekTo` may not cause a state change if no buffering is
5266
+ // required.
5267
+ timeout: 3000
5268
+ }
5269
+ };
5270
+ module.exports = exports['default'];
5271
+ });
5272
+
5273
+ unwrapExports(FunctionStateMap);
5274
+
5275
+ var YouTubePlayer_1 = createCommonjsModule(function (module, exports) {
5276
+
5277
+ Object.defineProperty(exports, "__esModule", {
5278
+ value: true
5279
+ });
5280
+
5281
+
5282
+
5283
+ var _debug2 = _interopRequireDefault(src);
5284
+
5285
+
5286
+
5287
+ var _functionNames2 = _interopRequireDefault(functionNames);
5288
+
5289
+
5290
+
5291
+ var _eventNames2 = _interopRequireDefault(eventNames);
5292
+
5293
+
5294
+
5295
+ var _FunctionStateMap2 = _interopRequireDefault(FunctionStateMap);
5296
+
5297
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5298
+
5299
+ /* eslint-disable promise/prefer-await-to-then */
5300
+
5301
+ var debug = (0, _debug2.default)('youtube-player');
5302
+
5303
+ var YouTubePlayer = {};
5304
+
5305
+ /**
5306
+ * Construct an object that defines an event handler for all of the YouTube
5307
+ * player events. Proxy captured events through an event emitter.
5308
+ *
5309
+ * @todo Capture event parameters.
5310
+ * @see https://developers.google.com/youtube/iframe_api_reference#Events
5311
+ */
5312
+ YouTubePlayer.proxyEvents = function (emitter) {
5313
+ var events = {};
5314
+
5315
+ var _loop = function _loop(eventName) {
5316
+ var onEventName = 'on' + eventName.slice(0, 1).toUpperCase() + eventName.slice(1);
5317
+
5318
+ events[onEventName] = function (event) {
5319
+ debug('event "%s"', onEventName, event);
5320
+
5321
+ emitter.trigger(eventName, event);
5322
+ };
5323
+ };
5324
+
5325
+ var _iteratorNormalCompletion = true;
5326
+ var _didIteratorError = false;
5327
+ var _iteratorError = undefined;
5328
+
5329
+ try {
5330
+ for (var _iterator = _eventNames2.default[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
5331
+ var eventName = _step.value;
5332
+
5333
+ _loop(eventName);
5334
+ }
5335
+ } catch (err) {
5336
+ _didIteratorError = true;
5337
+ _iteratorError = err;
5338
+ } finally {
5339
+ try {
5340
+ if (!_iteratorNormalCompletion && _iterator.return) {
5341
+ _iterator.return();
5342
+ }
5343
+ } finally {
5344
+ if (_didIteratorError) {
5345
+ throw _iteratorError;
5346
+ }
5347
+ }
5348
+ }
5349
+
5350
+ return events;
5351
+ };
5352
+
5353
+ /**
5354
+ * Delays player API method execution until player state is ready.
5355
+ *
5356
+ * @todo Proxy all of the methods using Object.keys.
5357
+ * @todo See TRICKY below.
5358
+ * @param playerAPIReady Promise that resolves when player is ready.
5359
+ * @param strictState A flag designating whether or not to wait for
5360
+ * an acceptable state when calling supported functions.
5361
+ * @returns {Object}
5362
+ */
5363
+ YouTubePlayer.promisifyPlayer = function (playerAPIReady) {
5364
+ var strictState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5365
+
5366
+ var functions = {};
5367
+
5368
+ var _loop2 = function _loop2(functionName) {
5369
+ if (strictState && _FunctionStateMap2.default[functionName]) {
5370
+ functions[functionName] = function () {
5371
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
5372
+ args[_key] = arguments[_key];
5373
+ }
5374
+
5375
+ return playerAPIReady.then(function (player) {
5376
+ var stateInfo = _FunctionStateMap2.default[functionName];
5377
+ var playerState = player.getPlayerState();
5378
+
5379
+ // eslint-disable-next-line no-warning-comments
5380
+ // TODO: Just spread the args into the function once Babel is fixed:
5381
+ // https://github.com/babel/babel/issues/4270
5382
+ //
5383
+ // eslint-disable-next-line prefer-spread
5384
+ var value = player[functionName].apply(player, args);
5385
+
5386
+ // TRICKY: For functions like `seekTo`, a change in state must be
5387
+ // triggered given that the resulting state could match the initial
5388
+ // state.
5389
+ if (stateInfo.stateChangeRequired ||
5390
+
5391
+ // eslint-disable-next-line no-extra-parens
5392
+ Array.isArray(stateInfo.acceptableStates) && stateInfo.acceptableStates.indexOf(playerState) === -1) {
5393
+ return new Promise(function (resolve) {
5394
+ var onPlayerStateChange = function onPlayerStateChange() {
5395
+ var playerStateAfterChange = player.getPlayerState();
5396
+
5397
+ var timeout = void 0;
5398
+
5399
+ if (typeof stateInfo.timeout === 'number') {
5400
+ timeout = setTimeout(function () {
5401
+ player.removeEventListener('onStateChange', onPlayerStateChange);
5402
+
5403
+ resolve();
5404
+ }, stateInfo.timeout);
5405
+ }
5406
+
5407
+ if (Array.isArray(stateInfo.acceptableStates) && stateInfo.acceptableStates.indexOf(playerStateAfterChange) !== -1) {
5408
+ player.removeEventListener('onStateChange', onPlayerStateChange);
5409
+
5410
+ clearTimeout(timeout);
5411
+
5412
+ resolve();
5413
+ }
5414
+ };
5415
+
5416
+ player.addEventListener('onStateChange', onPlayerStateChange);
5417
+ }).then(function () {
5418
+ return value;
5419
+ });
5420
+ }
5421
+
5422
+ return value;
5423
+ });
5424
+ };
5425
+ } else {
5426
+ functions[functionName] = function () {
5427
+ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
5428
+ args[_key2] = arguments[_key2];
5429
+ }
5430
+
5431
+ return playerAPIReady.then(function (player) {
5432
+ // eslint-disable-next-line no-warning-comments
5433
+ // TODO: Just spread the args into the function once Babel is fixed:
5434
+ // https://github.com/babel/babel/issues/4270
5435
+ //
5436
+ // eslint-disable-next-line prefer-spread
5437
+ return player[functionName].apply(player, args);
5438
+ });
5439
+ };
5440
+ }
5441
+ };
5442
+
5443
+ var _iteratorNormalCompletion2 = true;
5444
+ var _didIteratorError2 = false;
5445
+ var _iteratorError2 = undefined;
5446
+
5447
+ try {
5448
+ for (var _iterator2 = _functionNames2.default[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
5449
+ var functionName = _step2.value;
5450
+
5451
+ _loop2(functionName);
5452
+ }
5453
+ } catch (err) {
5454
+ _didIteratorError2 = true;
5455
+ _iteratorError2 = err;
5456
+ } finally {
5457
+ try {
5458
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
5459
+ _iterator2.return();
5460
+ }
5461
+ } finally {
5462
+ if (_didIteratorError2) {
5463
+ throw _iteratorError2;
5464
+ }
5465
+ }
5466
+ }
5467
+
5468
+ return functions;
5469
+ };
5470
+
5471
+ exports.default = YouTubePlayer;
5472
+ module.exports = exports['default'];
5473
+ });
5474
+
5475
+ unwrapExports(YouTubePlayer_1);
5476
+
5477
+ var dist = createCommonjsModule(function (module, exports) {
5478
+
5479
+ Object.defineProperty(exports, "__esModule", {
5480
+ value: true
5481
+ });
5482
+
5483
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
5484
+
5485
+
5486
+
5487
+ var _sister2 = _interopRequireDefault(sister);
5488
+
5489
+
5490
+
5491
+ var _loadYouTubeIframeApi2 = _interopRequireDefault(loadYouTubeIframeApi);
5492
+
5493
+
5494
+
5495
+ var _YouTubePlayer2 = _interopRequireDefault(YouTubePlayer_1);
5496
+
5497
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5498
+
5499
+ /**
5500
+ * @typedef YT.Player
5501
+ * @see https://developers.google.com/youtube/iframe_api_reference
5502
+ * */
5503
+
5504
+ /**
5505
+ * @see https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
5506
+ */
5507
+ var youtubeIframeAPI = void 0;
5508
+
5509
+ /**
5510
+ * A factory function used to produce an instance of YT.Player and queue function calls and proxy events of the resulting object.
5511
+ *
5512
+ * @param maybeElementId Either An existing YT.Player instance,
5513
+ * the DOM element or the id of the HTML element where the API will insert an <iframe>.
5514
+ * @param options See `options` (Ignored when using an existing YT.Player instance).
5515
+ * @param strictState A flag designating whether or not to wait for
5516
+ * an acceptable state when calling supported functions. Default: `false`.
5517
+ * See `FunctionStateMap.js` for supported functions and acceptable states.
5518
+ */
5519
+
5520
+ exports.default = function (maybeElementId) {
5521
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5522
+ var strictState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
5523
+
5524
+ var emitter = (0, _sister2.default)();
5525
+
5526
+ if (!youtubeIframeAPI) {
5527
+ youtubeIframeAPI = (0, _loadYouTubeIframeApi2.default)(emitter);
5528
+ }
5529
+
5530
+ if (options.events) {
5531
+ throw new Error('Event handlers cannot be overwritten.');
5532
+ }
5533
+
5534
+ if (typeof maybeElementId === 'string' && !document.getElementById(maybeElementId)) {
5535
+ throw new Error('Element "' + maybeElementId + '" does not exist.');
5536
+ }
5537
+
5538
+ options.events = _YouTubePlayer2.default.proxyEvents(emitter);
5539
+
5540
+ var playerAPIReady = new Promise(function (resolve) {
5541
+ if ((typeof maybeElementId === 'undefined' ? 'undefined' : _typeof(maybeElementId)) === 'object' && maybeElementId.playVideo instanceof Function) {
5542
+ var player = maybeElementId;
5543
+
5544
+ resolve(player);
5545
+ } else {
5546
+ // asume maybeElementId can be rendered inside
5547
+ // eslint-disable-next-line promise/catch-or-return
5548
+ youtubeIframeAPI.then(function (YT) {
5549
+ // eslint-disable-line promise/prefer-await-to-then
5550
+ var player = new YT.Player(maybeElementId, options);
5551
+
5552
+ emitter.on('ready', function () {
5553
+ resolve(player);
5554
+ });
5555
+
5556
+ return null;
5557
+ });
5558
+ }
5559
+ });
5560
+
5561
+ var playerApi = _YouTubePlayer2.default.promisifyPlayer(playerAPIReady, strictState);
5562
+
5563
+ playerApi.on = emitter.on;
5564
+ playerApi.off = emitter.off;
5565
+
5566
+ return playerApi;
5567
+ };
5568
+
5569
+ module.exports = exports['default'];
5570
+ });
5571
+
5572
+ var youTubePlayer = unwrapExports(dist);
5573
+
5574
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
5575
+
5576
+ var _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
5577
+
5578
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5579
+
5580
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
5581
+
5582
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
5583
+
5584
+ /**
5585
+ * Check whether a `props` change should result in the video being updated.
5586
+ *
5587
+ * @param {Object} prevProps
5588
+ * @param {Object} props
5589
+ */
5590
+ function shouldUpdateVideo(prevProps, props) {
5591
+ // A changing video should always trigger an update
5592
+ if (prevProps.videoId !== props.videoId) {
5593
+ return true;
5594
+ }
5595
+
5596
+ // Otherwise, a change in the start/end time playerVars also requires a player
5597
+ // update.
5598
+ var prevVars = prevProps.opts.playerVars || {};
5599
+ var vars = props.opts.playerVars || {};
5600
+
5601
+ return prevVars.start !== vars.start || prevVars.end !== vars.end;
5602
+ }
5603
+
5604
+ /**
5605
+ * Neutralise API options that only require a video update, leaving only options
5606
+ * that require a player reset. The results can then be compared to see if a
5607
+ * player reset is necessary.
5608
+ *
5609
+ * @param {Object} opts
5610
+ */
5611
+ function filterResetOptions(opts) {
5612
+ return _extends$1({}, opts, {
5613
+ playerVars: _extends$1({}, opts.playerVars, {
5614
+ autoplay: 0,
5615
+ start: 0,
5616
+ end: 0
5617
+ })
5618
+ });
5619
+ }
5620
+
5621
+ /**
5622
+ * Check whether a `props` change should result in the player being reset.
5623
+ * The player is reset when the `props.opts` change, except if the only change
5624
+ * is in the `start` and `end` playerVars, because a video update can deal with
5625
+ * those.
5626
+ *
5627
+ * @param {Object} prevProps
5628
+ * @param {Object} props
5629
+ */
5630
+ function shouldResetPlayer(prevProps, props) {
5631
+ return !fastDeepEqual(filterResetOptions(prevProps.opts), filterResetOptions(props.opts));
5632
+ }
5633
+
5634
+ /**
5635
+ * Check whether a props change should result in an id or className update.
5636
+ *
5637
+ * @param {Object} prevProps
5638
+ * @param {Object} props
5639
+ */
5640
+ function shouldUpdatePlayer(prevProps, props) {
5641
+ return prevProps.id !== props.id || prevProps.className !== props.className;
5642
+ }
5643
+
5644
+ var YouTube = function (_React$Component) {
5645
+ _inherits(YouTube, _React$Component);
5646
+
5647
+ function YouTube(props) {
5648
+ _classCallCheck(this, YouTube);
5649
+
5650
+ var _this = _possibleConstructorReturn(this, (YouTube.__proto__ || Object.getPrototypeOf(YouTube)).call(this, props));
5651
+
5652
+ _this.onPlayerReady = function (event) {
5653
+ return _this.props.onReady(event);
5654
+ };
5655
+
5656
+ _this.onPlayerError = function (event) {
5657
+ return _this.props.onError(event);
5658
+ };
5659
+
5660
+ _this.onPlayerStateChange = function (event) {
5661
+ _this.props.onStateChange(event);
5662
+ switch (event.data) {
5663
+
5664
+ case YouTube.PlayerState.ENDED:
5665
+ _this.props.onEnd(event);
5666
+ break;
5667
+
5668
+ case YouTube.PlayerState.PLAYING:
5669
+ _this.props.onPlay(event);
5670
+ break;
5671
+
5672
+ case YouTube.PlayerState.PAUSED:
5673
+ _this.props.onPause(event);
5674
+ break;
5675
+
5676
+ default:
5677
+ }
5678
+ };
5679
+
5680
+ _this.onPlayerPlaybackRateChange = function (event) {
5681
+ return _this.props.onPlaybackRateChange(event);
5682
+ };
5683
+
5684
+ _this.onPlayerPlaybackQualityChange = function (event) {
5685
+ return _this.props.onPlaybackQualityChange(event);
5686
+ };
5687
+
5688
+ _this.createPlayer = function () {
5689
+ // do not attempt to create a player server-side, it won't work
5690
+ if (typeof document === 'undefined') return;
5691
+ // create player
5692
+ var playerOpts = _extends$1({}, _this.props.opts, {
5693
+ // preload the `videoId` video if one is already given
5694
+ videoId: _this.props.videoId
5695
+ });
5696
+ _this.internalPlayer = youTubePlayer(_this.container, playerOpts);
5697
+ // attach event handlers
5698
+ _this.internalPlayer.on('ready', _this.onPlayerReady);
5699
+ _this.internalPlayer.on('error', _this.onPlayerError);
5700
+ _this.internalPlayer.on('stateChange', _this.onPlayerStateChange);
5701
+ _this.internalPlayer.on('playbackRateChange', _this.onPlayerPlaybackRateChange);
5702
+ _this.internalPlayer.on('playbackQualityChange', _this.onPlayerPlaybackQualityChange);
5703
+ };
5704
+
5705
+ _this.resetPlayer = function () {
5706
+ return _this.internalPlayer.destroy().then(_this.createPlayer);
5707
+ };
5708
+
5709
+ _this.updatePlayer = function () {
5710
+ _this.internalPlayer.getIframe().then(function (iframe) {
5711
+ if (_this.props.id) iframe.setAttribute('id', _this.props.id);else iframe.removeAttribute('id');
5712
+ if (_this.props.className) iframe.setAttribute('class', _this.props.className);else iframe.removeAttribute('class');
5713
+ });
5714
+ };
5715
+
5716
+ _this.updateVideo = function () {
5717
+ if (typeof _this.props.videoId === 'undefined' || _this.props.videoId === null) {
5718
+ _this.internalPlayer.stopVideo();
5719
+ return;
5720
+ }
5721
+
5722
+ // set queueing options
5723
+ var autoplay = false;
5724
+ var opts = {
5725
+ videoId: _this.props.videoId
5726
+ };
5727
+ if ('playerVars' in _this.props.opts) {
5728
+ autoplay = _this.props.opts.playerVars.autoplay === 1;
5729
+ if ('start' in _this.props.opts.playerVars) {
5730
+ opts.startSeconds = _this.props.opts.playerVars.start;
5731
+ }
5732
+ if ('end' in _this.props.opts.playerVars) {
5733
+ opts.endSeconds = _this.props.opts.playerVars.end;
5734
+ }
5735
+ }
5736
+
5737
+ // if autoplay is enabled loadVideoById
5738
+ if (autoplay) {
5739
+ _this.internalPlayer.loadVideoById(opts);
5740
+ return;
5741
+ }
5742
+ // default behaviour just cues the video
5743
+ _this.internalPlayer.cueVideoById(opts);
5744
+ };
5745
+
5746
+ _this.refContainer = function (container) {
5747
+ _this.container = container;
5748
+ };
5749
+
5750
+ _this.container = null;
5751
+ _this.internalPlayer = null;
5752
+ return _this;
5753
+ }
5754
+
5755
+ /**
5756
+ * Expose PlayerState constants for convenience. These constants can also be
5757
+ * accessed through the global YT object after the YouTube IFrame API is instantiated.
5758
+ * https://developers.google.com/youtube/iframe_api_reference#onStateChange
5759
+ */
5760
+
5761
+
5762
+ _createClass(YouTube, [{
5763
+ key: 'componentDidMount',
5764
+ value: function componentDidMount() {
5765
+ this.createPlayer();
5766
+ }
5767
+ }, {
5768
+ key: 'componentDidUpdate',
5769
+ value: function componentDidUpdate(prevProps) {
5770
+ if (shouldUpdatePlayer(prevProps, this.props)) {
5771
+ this.updatePlayer();
5772
+ }
5773
+
5774
+ if (shouldResetPlayer(prevProps, this.props)) {
5775
+ this.resetPlayer();
5776
+ }
5777
+
5778
+ if (shouldUpdateVideo(prevProps, this.props)) {
5779
+ this.updateVideo();
5780
+ }
5781
+ }
5782
+ }, {
5783
+ key: 'componentWillUnmount',
5784
+ value: function componentWillUnmount() {
5785
+ /**
5786
+ * Note: The `youtube-player` package that is used promisifies all Youtube
5787
+ * Player API calls, which introduces a delay of a tick before it actually
5788
+ * gets destroyed. Since React attempts to remove the element instantly
5789
+ * this method isn't quick enough to reset the container element.
5790
+ */
5791
+ this.internalPlayer.destroy();
5792
+ }
5793
+
5794
+ /**
5795
+ * https://developers.google.com/youtube/iframe_api_reference#onReady
5796
+ *
5797
+ * @param {Object} event
5798
+ * @param {Object} target - player object
5799
+ */
5800
+
5801
+
5802
+ /**
5803
+ * https://developers.google.com/youtube/iframe_api_reference#onError
5804
+ *
5805
+ * @param {Object} event
5806
+ * @param {Integer} data - error type
5807
+ * @param {Object} target - player object
5808
+ */
5809
+
5810
+
5811
+ /**
5812
+ * https://developers.google.com/youtube/iframe_api_reference#onStateChange
5813
+ *
5814
+ * @param {Object} event
5815
+ * @param {Integer} data - status change type
5816
+ * @param {Object} target - actual YT player
5817
+ */
5818
+
5819
+
5820
+ /**
5821
+ * https://developers.google.com/youtube/iframe_api_reference#onPlaybackRateChange
5822
+ *
5823
+ * @param {Object} event
5824
+ * @param {Float} data - playback rate
5825
+ * @param {Object} target - actual YT player
5826
+ */
5827
+
5828
+
5829
+ /**
5830
+ * https://developers.google.com/youtube/iframe_api_reference#onPlaybackQualityChange
5831
+ *
5832
+ * @param {Object} event
5833
+ * @param {String} data - playback quality
5834
+ * @param {Object} target - actual YT player
5835
+ */
5836
+
5837
+
5838
+ /**
5839
+ * Initialize the Youtube Player API on the container and attach event handlers
5840
+ */
5841
+
5842
+
5843
+ /**
5844
+ * Shorthand for destroying and then re-creating the Youtube Player
5845
+ */
5846
+
5847
+
5848
+ /**
5849
+ * Method to update the id and class of the Youtube Player iframe.
5850
+ * React should update this automatically but since the Youtube Player API
5851
+ * replaced the DIV that is mounted by React we need to do this manually.
5852
+ */
5853
+
5854
+
5855
+ /**
5856
+ * Call Youtube Player API methods to update the currently playing video.
5857
+ * Depeding on the `opts.playerVars.autoplay` this function uses one of two
5858
+ * Youtube Player API methods to update the video.
5859
+ */
5860
+
5861
+ }, {
5862
+ key: 'render',
5863
+ value: function render() {
5864
+ return React__default.createElement(
5865
+ 'div',
5866
+ { className: this.props.containerClassName },
5867
+ React__default.createElement('div', { id: this.props.id, className: this.props.className, ref: this.refContainer })
5868
+ );
5869
+ }
5870
+ }]);
5871
+
5872
+ return YouTube;
5873
+ }(React__default.Component);
5874
+
5875
+ YouTube.propTypes = {
5876
+ videoId: PropTypes.string,
5877
+
5878
+ // custom ID for player element
5879
+ id: PropTypes.string,
5880
+
5881
+ // custom class name for player element
5882
+ className: PropTypes.string,
5883
+ // custom class name for player container element
5884
+ containerClassName: PropTypes.string,
5885
+
5886
+ // https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
5887
+ opts: PropTypes.objectOf(PropTypes.any),
5888
+
5889
+ // event subscriptions
5890
+ onReady: PropTypes.func,
5891
+ onError: PropTypes.func,
5892
+ onPlay: PropTypes.func,
5893
+ onPause: PropTypes.func,
5894
+ onEnd: PropTypes.func,
5895
+ onStateChange: PropTypes.func,
5896
+ onPlaybackRateChange: PropTypes.func,
5897
+ onPlaybackQualityChange: PropTypes.func
5898
+ };
5899
+ YouTube.defaultProps = {
5900
+ id: null,
5901
+ className: null,
5902
+ opts: {},
5903
+ containerClassName: '',
5904
+ onReady: function onReady() {},
5905
+ onError: function onError() {},
5906
+ onPlay: function onPlay() {},
5907
+ onPause: function onPause() {},
5908
+ onEnd: function onEnd() {},
5909
+ onStateChange: function onStateChange() {},
5910
+ onPlaybackRateChange: function onPlaybackRateChange() {},
5911
+ onPlaybackQualityChange: function onPlaybackQualityChange() {}
5912
+ };
5913
+ YouTube.PlayerState = {
5914
+ UNSTARTED: -1,
5915
+ ENDED: 0,
5916
+ PLAYING: 1,
5917
+ PAUSED: 2,
5918
+ BUFFERING: 3,
5919
+ CUED: 5
5920
+ };
5921
+
5922
+ var getSerializers = function getSerializers() {
5923
+ return {
5924
+ types: {
5925
+ youtube: function youtube(_ref) {
5926
+ var node = _ref.node;
5927
+ var url = node.url;
5928
+
5929
+ var id = getYoutubeId(url);
5930
+ return React__default.createElement(YouTube, { videoId: id, className: 'youtube' });
5931
+ }
5932
+ }
5933
+ };
5934
+ };
5935
+
5936
+ export { DeckContent, DeckQueue, Column2, Column3, Header, LeftNav, NavMagazine, NavNative, NavNormal, TemplateNormal, AD300x250, AD300x250x600, AD728x90, getSerializers };
2791
5937
  //# sourceMappingURL=index.es.js.map