diff --git a/bower.json b/bower.json index bbc863e..1a333de 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "senna", - "version": "1.5.1", + "version": "1.5.2", "description": "A blazing-fast Single Page Application engine", "homepage": "http://sennajs.com", "main": [ diff --git a/build/amd/metal-events/src/EventEmitterProxy.js.map b/build/amd/metal-events/src/EventEmitterProxy.js.map index 9dd8a60..431ef17 100644 --- a/build/amd/metal-events/src/EventEmitterProxy.js.map +++ b/build/amd/metal-events/src/EventEmitterProxy.js.map @@ -1 +1 @@ -{"version":3,"sources":["EventEmitterProxy.js"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkBM,iB;;;AACL,6BAAY,aAAZ,EAA2B,aAA3B,EAA0C,aAA1C,EAAyD,aAAzD,EAAwE;AAAA;;AAAA,gDACvE,sBADuE;;;;;;;AAQvE,SAAK,UAAL,GAAkB,iBAAiB,EAAnC;;;;;;;;AAQA,SAAK,cAAL,GAAsB,aAAtB;;;;;;;;;AASA,SAAK,cAAL,GAAsB,EAAtB;;;;;;;AAOA,SAAK,cAAL,GAAsB,EAAtB;;;;;;;;AAQA,SAAK,cAAL,GAAsB,aAAtB;;;;;;;AAOA,SAAK,UAAL,GAAkB,aAAlB;;AAEA,SAAK,WAAL;AAjDuE;AAkDvE;;;;;;;;;;;8BASD,Y,yBAAa,K,EAAO,Q,EAAU;AAC7B,UAAO,KAAK,cAAL,CAAoB,EAApB,CAAuB,KAAvB,EAA8B,QAA9B,CAAP;AACA,G;;8BAQD,oB,iCAAqB,K,EAAO;AAC3B,UAAO,KAAK,YAAL,CAAkB,KAAlB,EAAyB,KAAK,aAAL,CAAmB,IAAnB,CAAwB,IAAxB,EAA8B,KAA9B,CAAzB,CAAP;AACA,G;;8BAKD,e,8BAAkB;AACjB,QAAK,gBAAL;AACA,QAAK,cAAL,GAAsB,IAAtB;AACA,QAAK,cAAL,GAAsB,IAAtB;AACA,QAAK,cAAL,GAAsB,I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AsC,KAAK,UAAL,CAAgB,IAAhB,CAAqB,IAArB,CAAtC;AACA,G;;8BAQD,iB,8BAAkB,K,EAAO;AACxB,OAAI,KAAK,cAAT,EAAyB;AACxB,SAAK,cAAL,CAAoB,KAApB,IAA6B,KAAK,oBAAL,CAA0B,KAA1B,CAA7B;AACA,IAFD,MAEO;AACN,SAAK,cAAL,CAAoB,IAApB,CAAyB,KAAzB;AACA;AACD,G;;;;;mBAGa,iB","file":"node_modules/metal-events/src/EventEmitterProxy.js","sourcesContent":["'use strict';\n\nimport { array, Disposable } from 'metal';\n\n/**\n * EventEmitterProxy utility. It's responsible for linking two EventEmitter\n * instances together, emitting events from the first emitter through the\n * second one. That means that listening to a supported event on the target\n * emitter will mean listening to it on the origin emitter as well.\n * @param {EventEmitter} originEmitter Events originated on this emitter\n * will be fired for the target emitter's listeners as well.\n * @param {EventEmitter} targetEmitter Event listeners attached to this emitter\n * will also be triggered when the event is fired by the origin emitter.\n * @param {Object} opt_blacklist Optional blacklist of events that should not be\n * proxied.\n * @constructor\n * @extends {Disposable}\n */\nclass EventEmitterProxy extends Disposable {\n\tconstructor(originEmitter, targetEmitter, opt_blacklist, opt_whitelist) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Map of events that should not be proxied.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.blacklist_ = opt_blacklist || {};\n\n\t\t/**\n\t\t * The origin emitter. This emitter's events will be proxied through the\n\t\t * target emitter.\n\t\t * @type {EventEmitter}\n\t\t * @protected\n\t\t */\n\t\tthis.originEmitter_ = originEmitter;\n\n\t\t/**\n\t\t * A list of events that are pending to be listened by an actual origin\n\t\t * emitter. Events are stored here when the origin doesn't exist, so they\n\t\t * can be set on a new origin when one is set.\n\t\t * @type {!Array}\n\t\t * @protected\n\t\t */\n\t\tthis.pendingEvents_ = [];\n\n\t\t/**\n\t\t * Holds a map of events from the origin emitter that are already being proxied.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.proxiedEvents_ = {};\n\n\t\t/**\n\t\t * The target emitter. This emitter will emit all events that come from\n\t\t * the origin emitter.\n\t\t * @type {EventEmitter}\n\t\t * @protected\n\t\t */\n\t\tthis.targetEmitter_ = targetEmitter;\n\n\t\t/**\n\t\t * Map of events that should be proxied. If whitelist is set blacklist is ignored.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.whitelist_ = opt_whitelist;\n\n\t\tthis.startProxy_();\n\t}\n\n\t/**\n\t * Adds the given listener for the given event.\n\t * @param {string} event\n\t * @param {!function()} listener\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t */\n\taddListener_(event, listener) {\n\t\treturn this.originEmitter_.on(event, listener);\n\t}\n\n\t/**\n\t * Adds the proxy listener for the given event.\n\t * @param {string} event\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t */\n\taddListenerForEvent_(event) {\n\t\treturn this.addListener_(event, this.emitOnTarget_.bind(this, event));\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tthis.removeListeners_();\n\t\tthis.proxiedEvents_ = null;\n\t\tthis.originEmitter_ = null;\n\t\tthis.targetEmitter_ = null;\n\t}\n\n\t/**\n\t * Emits the specified event type on the target emitter.\n\t * @param {string} eventType\n\t * @protected\n\t */\n\temitOnTarget_(eventType) {\n\t\tvar args = [eventType].concat(array.slice(arguments, 1));\n\t\tthis.targetEmitter_.emit.apply(this.targetEmitter_, args);\n\t}\n\n\t/**\n\t * Proxies the given event from the origin to the target emitter.\n\t * @param {string} event\n\t */\n\tproxyEvent(event) {\n\t\tif (this.shouldProxyEvent_(event)) {\n\t\t\tthis.tryToAddListener_(event);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the proxy listener for all events.\n\t * @protected\n\t */\n\tremoveListeners_() {\n\t\tvar events = Object.keys(this.proxiedEvents_);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tthis.proxiedEvents_[events[i]].removeListener();\n\t\t}\n\t\tthis.proxiedEvents_ = {};\n\t\tthis.pendingEvents_ = [];\n\t}\n\n\t/**\n\t * Changes the origin emitter. This automatically detaches any events that\n\t * were already being proxied from the previous emitter, and starts proxying\n\t * them on the new emitter instead.\n\t * @param {!EventEmitter} originEmitter\n\t */\n\tsetOriginEmitter(originEmitter) {\n\t\tvar events = this.originEmitter_?\n\t\t\tObject.keys(this.proxiedEvents_) :\n\t\t\tthis.pendingEvents_;\n\t\tthis.removeListeners_();\n\t\tthis.originEmitter_ = originEmitter;\n\t\tevents.forEach(event => this.proxyEvent(event));\n\t}\n\n\t/**\n\t * Checks if the given event should be proxied.\n\t * @param {string} event\n\t * @return {boolean}\n\t * @protected\n\t */\n\tshouldProxyEvent_(event) {\n\t\tif (this.whitelist_ && !this.whitelist_[event]) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.blacklist_[event]) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !this.proxiedEvents_[event];\n\t}\n\n\t/**\n\t * Starts proxying all events from the origin to the target emitter.\n\t * @protected\n\t */\n\tstartProxy_() {\n\t\tthis.targetEmitter_.on('newListener', this.proxyEvent.bind(this));\n\t}\n\n\t/**\n\t * Adds a listener to the origin emitter, if it exists. Otherwise, stores\n\t * the pending listener so it can be used on a future origin emitter.\n\t * @param {string} event\n\t * @protected\n\t */\n\ttryToAddListener_(event) {\n\t\tif (this.originEmitter_) {\n\t\t\tthis.proxiedEvents_[event] = this.addListenerForEvent_(event);\n\t\t} else {\n\t\t\tthis.pendingEvents_.push(event);\n\t\t}\n\t}\n}\n\nexport default EventEmitterProxy;\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["EventEmitterProxy.js"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkBM,iB;;;AACL,6BAAY,aAAZ,EAA2B,aAA3B,EAA0C,aAA1C,EAAyD,aAAzD,EAAwE;AAAA;;AAAA,gDACvE,sBADuE;;;;;;;AAQvE,SA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,cAA/B;AACA;AACD,QAAK,cAAL,GAAsB,EAAtB;AACA,QAAK,cAAL,GAAsB,EAAtB;AACA,G;;8BAQD,gB,6BAAiB,a,EAAe;AAAA;;AAC/B,OAAI,SAAS,KAAK,cAAL,GACZ,OAAO,IAAP,CAAY,KAAK,cAAjB,CADY,GAEZ,KAAK,cAFN;AAGA,QAAK,gBAAL;AACA,QAAK,cAAL,GAAsB,aAAtB;AACA,UAAO,OAAP,CAAe;AAAA,WAAS,OAAK,UAAL,CAAgB,KAAhB,CAAT;AAAA,IAAf;AACA,G;;8BAQD,iB,8BAAkB,K,EAAO;AACxB,OAAI,KAAK,UAAL,IAAmB,CAAC,KAAK,UAAL,CAAgB,KAAhB,CAAxB,EAAgD;AAC/C,WAAO,KAAP;AACA;AACD,OAAI,KAAK,UAAL,CAAgB,KAAhB,CAAJ,EAA4B;AAC3B,WAAO,KAAP;AACA;AACD,UAAO,CAAC,KAAK,cAAL,CAAoB,KAApB,CAAR;AACA,G;;8BAMD,W,0BAAc;AACb,QAAK,cAAL,CAAoB,EAApB,CAAuB,aAAvB,EAAsC,KAAK,UAAL,CAAgB,IAAhB,CAAqB,IAArB,CAAtC;AACA,G;;8BAQD,iB,8BAAkB,K,EAAO;AACxB,OAAI,KAAK,cAAT,EAAyB;AACxB,SAAK,cAAL,CAAoB,KAApB,IAA6B,KAAK,oBAAL,CAA0B,KAA1B,CAA7B;AACA,IAFD,MAEO;AACN,SAAK,cAAL,CAAoB,IAApB,CAAyB,KAAzB;AACA;AACD,G;;;;;mBAGa,iB","file":"node_modules/metal-events/src/EventEmitterProxy.js","sourcesContent":["'use strict';\n\nimport { array, Disposable } from 'metal';\n\n/**\n * EventEmitterProxy utility. It's responsible for linking two EventEmitter\n * instances together, emitting events from the first emitter through the\n * second one. That means that listening to a supported event on the target\n * emitter will mean listening to it on the origin emitter as well.\n * @param {EventEmitter} originEmitter Events originated on this emitter\n * will be fired for the target emitter's listeners as well.\n * @param {EventEmitter} targetEmitter Event listeners attached to this emitter\n * will also be triggered when the event is fired by the origin emitter.\n * @param {Object} opt_blacklist Optional blacklist of events that should not be\n * proxied.\n * @constructor\n * @extends {Disposable}\n */\nclass EventEmitterProxy extends Disposable {\n\tconstructor(originEmitter, targetEmitter, opt_blacklist, opt_whitelist) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Map of events that should not be proxied.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.blacklist_ = opt_blacklist || {};\n\n\t\t/**\n\t\t * The origin emitter. This emitter's events will be proxied through the\n\t\t * target emitter.\n\t\t * @type {EventEmitter}\n\t\t * @protected\n\t\t */\n\t\tthis.originEmitter_ = originEmitter;\n\n\t\t/**\n\t\t * A list of events that are pending to be listened by an actual origin\n\t\t * emitter. Events are stored here when the origin doesn't exist, so they\n\t\t * can be set on a new origin when one is set.\n\t\t * @type {!Array}\n\t\t * @protected\n\t\t */\n\t\tthis.pendingEvents_ = [];\n\n\t\t/**\n\t\t * Holds a map of events from the origin emitter that are already being proxied.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.proxiedEvents_ = {};\n\n\t\t/**\n\t\t * The target emitter. This emitter will emit all events that come from\n\t\t * the origin emitter.\n\t\t * @type {EventEmitter}\n\t\t * @protected\n\t\t */\n\t\tthis.targetEmitter_ = targetEmitter;\n\n\t\t/**\n\t\t * Map of events that should be proxied. If whitelist is set blacklist is ignored.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.whitelist_ = opt_whitelist;\n\n\t\tthis.startProxy_();\n\t}\n\n\t/**\n\t * Adds the given listener for the given event.\n\t * @param {string} event\n\t * @param {!function()} listener\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t */\n\taddListener_(event, listener) {\n\t\treturn this.originEmitter_.on(event, listener);\n\t}\n\n\t/**\n\t * Adds the proxy listener for the given event.\n\t * @param {string} event\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t */\n\taddListenerForEvent_(event) {\n\t\treturn this.addListener_(event, this.emitOnTarget_.bind(this, event));\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tthis.removeListeners_();\n\t\tthis.proxiedEvents_ = null;\n\t\tthis.originEmitter_ = null;\n\t\tthis.targetEmitter_ = null;\n\t}\n\n\t/**\n\t * Emits the specified event type on the target emitter.\n\t * @param {string} eventType\n\t * @protected\n\t */\n\temitOnTarget_(eventType) {\n\t\tvar args = [eventType].concat(array.slice(arguments, 1));\n\t\tthis.targetEmitter_.emit.apply(this.targetEmitter_, args);\n\t}\n\n\t/**\n\t * Proxies the given event from the origin to the target emitter.\n\t * @param {string} event\n\t */\n\tproxyEvent(event) {\n\t\tif (this.shouldProxyEvent_(event)) {\n\t\t\tthis.tryToAddListener_(event);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the proxy listener for all events.\n\t * @protected\n\t */\n\tremoveListeners_() {\n\t\tvar events = Object.keys(this.proxiedEvents_);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tthis.proxiedEvents_[events[i]].removeListener();\n\t\t}\n\t\tthis.proxiedEvents_ = {};\n\t\tthis.pendingEvents_ = [];\n\t}\n\n\t/**\n\t * Changes the origin emitter. This automatically detaches any events that\n\t * were already being proxied from the previous emitter, and starts proxying\n\t * them on the new emitter instead.\n\t * @param {!EventEmitter} originEmitter\n\t */\n\tsetOriginEmitter(originEmitter) {\n\t\tvar events = this.originEmitter_ ?\n\t\t\tObject.keys(this.proxiedEvents_) :\n\t\t\tthis.pendingEvents_;\n\t\tthis.removeListeners_();\n\t\tthis.originEmitter_ = originEmitter;\n\t\tevents.forEach(event => this.proxyEvent(event));\n\t}\n\n\t/**\n\t * Checks if the given event should be proxied.\n\t * @param {string} event\n\t * @return {boolean}\n\t * @protected\n\t */\n\tshouldProxyEvent_(event) {\n\t\tif (this.whitelist_ && !this.whitelist_[event]) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.blacklist_[event]) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !this.proxiedEvents_[event];\n\t}\n\n\t/**\n\t * Starts proxying all events from the origin to the target emitter.\n\t * @protected\n\t */\n\tstartProxy_() {\n\t\tthis.targetEmitter_.on('newListener', this.proxyEvent.bind(this));\n\t}\n\n\t/**\n\t * Adds a listener to the origin emitter, if it exists. Otherwise, stores\n\t * the pending listener so it can be used on a future origin emitter.\n\t * @param {string} event\n\t * @protected\n\t */\n\ttryToAddListener_(event) {\n\t\tif (this.originEmitter_) {\n\t\t\tthis.proxiedEvents_[event] = this.addListenerForEvent_(event);\n\t\t} else {\n\t\t\tthis.pendingEvents_.push(event);\n\t\t}\n\t}\n}\n\nexport default EventEmitterProxy;\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/amd/senna/src/app/App.js b/build/amd/senna/src/app/App.js index 5a7b973..8a4f6b5 100644 --- a/build/amd/senna/src/app/App.js +++ b/build/amd/senna/src/app/App.js @@ -475,9 +475,17 @@ define(['exports', 'metal/src/metal', 'metal-debounce/src/debounce', 'metal-dom/ }; App.prototype.handleNavigateError_ = function handleNavigateError_(path, nextScreen, err) { + var _this6 = this; + void 0; if (!_utils2.default.isCurrentBrowserPath(path)) { - this.removeScreen(path); + if (this.pendingNavigate) { + this.pendingNavigate.thenAlways(function () { + return _this6.removeScreen(path); + }, this); + } else { + this.removeScreen(path); + } } }; @@ -620,13 +628,13 @@ define(['exports', 'metal/src/metal', 'metal-debounce/src/debounce', 'metal-dom/ }; App.prototype.onLoad_ = function onLoad_() { - var _this6 = this; + var _this7 = this; this.skipLoadPopstate = true; setTimeout(function () { // The timeout ensures that popstate events will be unblocked right // after the load event occured, but not in the same event-loop cycle. - _this6.skipLoadPopstate = false; + _this7.skipLoadPopstate = false; }, 0); // Try to reposition scroll to the hashed anchor when page loads. this.maybeRepositionScrollToHashedAnchor(); @@ -675,7 +683,7 @@ define(['exports', 'metal/src/metal', 'metal-debounce/src/debounce', 'metal-dom/ }; App.prototype.onStartNavigate_ = function onStartNavigate_(event) { - var _this7 = this; + var _this8 = this; this.maybeDisableNativeScrollRestoration(); this.captureScrollPositionFromScrollEvent = false; @@ -690,19 +698,19 @@ define(['exports', 'metal/src/metal', 'metal-debounce/src/debounce', 'metal-dom/ endNavigatePayload.error = reason; throw reason; }).thenAlways(function () { - if (!_this7.pendingNavigate) { - _dom2.default.removeClasses(_globals2.default.document.documentElement, _this7.loadingCssClass); - _this7.maybeRestoreNativeScrollRestoration(); - _this7.captureScrollPositionFromScrollEvent = true; + if (!_this8.pendingNavigate) { + _dom2.default.removeClasses(_globals2.default.document.documentElement, _this8.loadingCssClass); + _this8.maybeRestoreNativeScrollRestoration(); + _this8.captureScrollPositionFromScrollEvent = true; } - _this7.emit('endNavigate', endNavigatePayload); + _this8.emit('endNavigate', endNavigatePayload); }); this.pendingNavigate.path = event.path; }; App.prototype.prefetch = function prefetch(path) { - var _this8 = this; + var _this9 = this; var route = this.findRoute(path); if (!route) { @@ -714,9 +722,9 @@ define(['exports', 'metal/src/metal', 'metal-debounce/src/debounce', 'metal-dom/ var nextScreen = this.createScreenInstance(path, route); return nextScreen.load(path).then(function () { - return _this8.screens[path] = nextScreen; + return _this9.screens[path] = nextScreen; }).catch(function (reason) { - _this8.handleNavigateError_(path, nextScreen, reason); + _this9.handleNavigateError_(path, nextScreen, reason); throw reason; }); }; @@ -760,12 +768,12 @@ define(['exports', 'metal/src/metal', 'metal-debounce/src/debounce', 'metal-dom/ }; App.prototype.removeScreen = function removeScreen(path) { - var _this9 = this; + var _this10 = this; var screen = this.screens[path]; if (screen) { Object.keys(this.surfaces).forEach(function (surfaceId) { - return _this9.surfaces[surfaceId].remove(screen.getId()); + return _this10.surfaces[surfaceId].remove(screen.getId()); }); screen.dispose(); delete this.screens[path]; @@ -825,7 +833,7 @@ define(['exports', 'metal/src/metal', 'metal-debounce/src/debounce', 'metal-dom/ }; App.prototype.syncScrollPositionSyncThenAsync_ = function syncScrollPositionSyncThenAsync_() { - var _this10 = this; + var _this11 = this; var state = _globals2.default.window.history.state; if (!state) { @@ -836,7 +844,7 @@ define(['exports', 'metal/src/metal', 'metal-debounce/src/debounce', 'metal-dom/ var scrollLeft = state.scrollLeft; var sync = function sync() { - if (_this10.updateScrollPosition) { + if (_this11.updateScrollPosition) { _globals2.default.window.scrollTo(scrollLeft, scrollTop); } }; diff --git a/build/amd/senna/src/app/App.js.map b/build/amd/senna/src/app/App.js.map index 67d446a..53f92fb 100644 --- a/build/amd/senna/src/app/App.js.map +++ b/build/amd/senna/src/app/App.js.map @@ -1 +1 @@ -{"version":3,"sources":["App.js"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAcM,G;;;;;;;;;AAOL,iBAAc;AAAA;;AAAA,gDACb,wBADa;;;;;;;AAQb,SAAK,YAAL,GAAoB,IAApB;;;;;;;AAOA,SAAK,UAAL,GAAkB,IAAlB;;;;;;;;AAQA,SAAK,oBAAL,GAA4B,IAA5B;;;;;;;;AAQA,SAAK,QAAL,GAAgB,EAAhB;;;;;;;;AAQA,SAAK,oCAAL,GAA4C,IAA5C;;;;;;;;AAQA,SAAK,YAAL,GAAoB,kBAAQ,QAAR,CAAiB,KAArC;;;;;;;;AAQA,SAAK,YAAL,GAAoB,2DAApB;;;;;;;;AAQA,SAAK,YAAL,GAAoB,yBAApB;;;;;;;;AAQA,SAAK,eAAL,GAAuB,eAAvB;;;;;;;;;;;;;;;AAeA,SAAK,gCAAL,GAAyC,uBAAuB,kBAAQ,MAAR,CAAe,OAA/E;;;;;;;;AAQA,SAAK,eAAL,GAAuB,IAAvB;;;;;;;;;AASA,SAAK,kBAAL,GAA0B,CAA1B;;;;;;;;;AASA,SAAK,iBAAL,GAAyB,CAAzB;;;;;;;AAOA,SAAK,YAAL,GAAoB,IAApB;;;;;;;;AAQA,SAAK,MAAL,GAAc,EAAd;;;;;;;;AAQA,SAAK,OAAL,GAAe,EAAf;;;;;;;;;;AAUA,SAAK,g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IAJD;;AAMA,UAAO,sBAAuB,UAAC,OAAD;AAAA,WAAa,SAAS,aAAM,QAAN,CAAe;AAAA,YAAM,SAAS,SAAf;AAAA,KAAf,CAAtB;AAAA,IAAvB,CAAP;AACA,G;;gBAUD,c,2BAAe,K,EAAO,I,EAAM,K,EAAO,kB,EAAoB;AACtD,OAAI,kBAAJ,EAAwB;AACvB,sBAAQ,MAAR,CAAe,OAAf,CAAuB,YAAvB,CAAoC,KAApC,EAA2C,KAA3C,EAAkD,IAAlD;AACA,IAFD,MAEO;AACN,sBAAQ,MAAR,CAAe,OAAf,CAAuB,SAAvB,CAAiC,KAAjC,EAAwC,KAAxC,EAA+C,IAA/C;AACA;AACD,qBAAQ,QAAR,CAAiB,KAAjB,GAAyB,KAAzB;AACA,G;;;;;mBAIa,G","file":"src/app/App.js","sourcesContent":["'use strict';\n\nimport { array, async, core } from 'metal';\nimport debounce from 'metal-debounce';\nimport dom from 'metal-dom';\nimport CancellablePromise from 'metal-promise';\nimport { EventEmitter, EventHandler } from 'metal-events';\nimport utils from '../utils/utils';\nimport globals from '../globals/globals';\nimport Route from '../route/Route';\nimport Screen from '../screen/Screen';\nimport Surface from '../surface/Surface';\nimport Uri from 'metal-uri';\n\nclass App extends EventEmitter {\n\n\t/**\n\t * App class that handle routes and screens lifecycle.\n\t * @constructor\n\t * @extends {EventEmitter}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the active screen.\n\t\t * @type {?Screen}\n\t\t * @protected\n\t\t */\n\t\tthis.activeScreen = null;\n\n\t\t/**\n\t\t * Holds the active path containing the query parameters.\n\t\t * @type {?string}\n\t\t * @protected\n\t\t */\n\t\tthis.activePath = null;\n\n\t\t/**\n\t\t * Allows prevent navigate from dom prevented event.\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.allowPreventNavigate = true;\n\n\t\t/**\n\t\t * Holds link base path.\n\t\t * @type {!string}\n\t\t * @default ''\n\t\t * @protected\n\t\t */\n\t\tthis.basePath = '';\n\n\t\t/**\n\t\t * Captures scroll position from scroll event.\n\t\t * @type {!boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.captureScrollPositionFromScrollEvent = true;\n\n\t\t/**\n\t\t * Holds the default page title.\n\t\t * @type {string}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.defaultTitle = globals.document.title;\n\n\t\t/**\n\t\t * Holds the form selector to define forms that are routed.\n\t\t * @type {!string}\n\t\t * @default form[enctype=\"multipart/form-data\"]:not([data-senna-off])\n\t\t * @protected\n\t\t */\n\t\tthis.formSelector = 'form[enctype=\"multipart/form-data\"]:not([data-senna-off])';\n\n\t\t/**\n\t\t * Holds the link selector to define links that are routed.\n\t\t * @type {!string}\n\t\t * @default a:not([data-senna-off])\n\t\t * @protected\n\t\t */\n\t\tthis.linkSelector = 'a:not([data-senna-off])';\n\n\t\t/**\n\t\t * Holds the loading css class.\n\t\t * @type {!string}\n\t\t * @default senna-loading\n\t\t * @protected\n\t\t */\n\t\tthis.loadingCssClass = 'senna-loading';\n\n\t\t/**\n\t\t * Using the History API to manage your URLs is awesome and, as it happens,\n\t\t * a crucial feature of good web apps. One of its downsides, however, is\n\t\t * that scroll positions are stored and then, more importantly, restored\n\t\t * whenever you traverse the history. This often means unsightly jumps as\n\t\t * the scroll position changes automatically, and especially so if your app\n\t\t * does transitions, or changes the contents of the page in any way.\n\t\t * Ultimately this leads to an horrible user experience. The good news is,\n\t\t * however, that there’s a potential fix: history.scrollRestoration.\n\t\t * https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration\n\t\t * @type {boolean}\n\t\t * @protected\n\t\t */\n\t\tthis.nativeScrollRestorationSupported = ('scrollRestoration' in globals.window.history);\n\n\t\t/**\n\t\t * Holds a deferred with the current navigation.\n\t\t * @type {?CancellablePromise}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.pendingNavigate = null;\n\n\t\t/**\n\t\t * Holds the window horizontal scroll position when the navigation using\n\t\t * back or forward happens to be restored after the surfaces are updated.\n\t\t * @type {!Number}\n\t\t * @default 0\n\t\t * @protected\n\t\t */\n\t\tthis.popstateScrollLeft = 0;\n\n\t\t/**\n\t\t * Holds the window vertical scroll position when the navigation using\n\t\t * back or forward happens to be restored after the surfaces are updated.\n\t\t * @type {!Number}\n\t\t * @default 0\n\t\t * @protected\n\t\t */\n\t\tthis.popstateScrollTop = 0;\n\n\t\t/**\n\t\t * Holds the redirect path containing the query parameters.\n\t\t * @type {?string}\n\t\t * @protected\n\t\t */\n\t\tthis.redirectPath = null;\n\n\t\t/**\n\t\t * Holds the screen routes configuration.\n\t\t * @type {?Array}\n\t\t * @default []\n\t\t * @protected\n\t\t */\n\t\tthis.routes = [];\n\n\t\t/**\n\t\t * Maps the screen instances by the url containing the parameters.\n\t\t * @type {?Object}\n\t\t * @default {}\n\t\t * @protected\n\t\t */\n\t\tthis.screens = {};\n\n\t\t/**\n\t\t * When set to true the first erroneous popstate fired on page load will be\n\t\t * ignored, only if globals.window.history.state is also\n\t\t * null.\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t * @protected\n\t\t */\n\t\tthis.skipLoadPopstate = false;\n\n\t\t/**\n\t\t * Maps that index the surfaces instances by the surface id.\n\t\t * @type {?Object}\n\t\t * @default {}\n\t\t * @protected\n\t\t */\n\t\tthis.surfaces = {};\n\n\t\t/**\n\t\t * When set to true, moves the scroll position after popstate, or to the\n\t\t * top of the viewport for new navigation. If false, the browser will\n\t\t * take care of scroll restoration.\n\t\t * @type {!boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.updateScrollPosition = true;\n\n\t\tthis.appEventHandlers_ = new EventHandler();\n\n\t\tthis.appEventHandlers_.add(\n\t\t\tdom.on(globals.window, 'scroll', debounce(this.onScroll_.bind(this), 100)),\n\t\t\tdom.on(globals.window, 'load', this.onLoad_.bind(this)),\n\t\t\tdom.on(globals.window, 'popstate', this.onPopstate_.bind(this))\n\t\t);\n\n\t\tthis.on('startNavigate', this.onStartNavigate_);\n\t\tthis.on('beforeNavigate', this.onBeforeNavigate_);\n\t\tthis.on('beforeNavigate', this.onBeforeNavigateDefault_, true);\n\n\t\tthis.setLinkSelector(this.linkSelector);\n\t\tthis.setFormSelector(this.formSelector);\n\t}\n\n\t/**\n\t * Adds one or more screens to the application.\n\t *\n\t * Example:\n\t *\n\t * \n\t * app.addRoutes({ path: '/foo', handler: FooScreen });\n\t * or\n\t * app.addRoutes([{ path: '/foo', handler: function(route) { return new FooScreen(); } }]);\n\t * \n\t *\n\t * @param {Object} or {Array} routes Single object or an array of object.\n\t * Each object should contain path and screen.\n\t * The path should be a string or a regex that maps the\n\t * navigation route to a screen class definition (not an instance), e.g:\n\t * { path: \"/home:param1\", handler: MyScreen }\n\t * { path: /foo.+/, handler: MyScreen }\n\t * @chainable\n\t */\n\taddRoutes(routes) {\n\t\tif (!Array.isArray(routes)) {\n\t\t\troutes = [routes];\n\t\t}\n\t\troutes.forEach((route) => {\n\t\t\tif (!(route instanceof Route)) {\n\t\t\t\troute = new Route(route.path, route.handler);\n\t\t\t}\n\t\t\tthis.routes.push(route);\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds one or more surfaces to the application.\n\t * @param {Surface|String|Array.} surfaces\n\t * Surface element id or surface instance. You can also pass an Array\n\t * whichcontains surface instances or id. In case of ID, these should be\n\t * the id of surface element.\n\t * @chainable\n\t */\n\taddSurfaces(surfaces) {\n\t\tif (!Array.isArray(surfaces)) {\n\t\t\tsurfaces = [surfaces];\n\t\t}\n\t\tsurfaces.forEach((surface) => {\n\t\t\tif (core.isString(surface)) {\n\t\t\t\tsurface = new Surface(surface);\n\t\t\t}\n\t\t\tthis.surfaces[surface.getId()] = surface;\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns if can navigate to path.\n\t * @param {!string} url\n\t * @return {boolean}\n\t */\n\tcanNavigate(url) {\n\t\tvar path = utils.getUrlPath(url);\n\t\tvar uri = new Uri(url);\n\n\t\tif (!this.isLinkSameOrigin_(uri.getHostname())) {\n\t\t\tconsole.log('Offsite link clicked');\n\t\t\treturn false;\n\t\t}\n\t\tif (!this.isSameBasePath_(path)) {\n\t\t\tconsole.log('Link clicked outside app\\'s base path');\n\t\t\treturn false;\n\t\t}\n\t\tif (!this.findRoute(path)) {\n\t\t\tconsole.log('No route for ' + path);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Clear screens cache.\n\t * @chainable\n\t */\n\tclearScreensCache() {\n\t\tObject.keys(this.screens).forEach((path) => {\n\t\t\tif (path === this.activePath) {\n\t\t\t\tthis.activeScreen.clearCache();\n\t\t\t} else {\n\t\t\t\tthis.removeScreen(path);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves or create a screen instance to a path.\n\t * @param {!string} path Path containing the querystring part.\n\t * @return {Screen}\n\t */\n\tcreateScreenInstance(path, route) {\n\t\tif (!this.pendingNavigate && path === this.activePath) {\n\t\t\tconsole.log('Already at destination, refresh navigation');\n\t\t\treturn this.activeScreen;\n\t\t}\n\t\t/* jshint newcap: false */\n\t\tvar screen = this.screens[path];\n\t\tif (!screen) {\n\t\t\tvar handler = route.getHandler();\n\t\t\tif (handler === Screen || Screen.isImplementedBy(handler.prototype)) {\n\t\t\t\tscreen = new handler();\n\t\t\t} else {\n\t\t\t\tscreen = handler(route) || new Screen();\n\t\t\t}\n\t\t\tconsole.log('Create screen for [' + path + '] [' + screen + ']');\n\t\t}\n\t\treturn screen;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tif (this.activeScreen) {\n\t\t\tthis.removeScreen(this.activePath);\n\t\t}\n\t\tthis.clearScreensCache();\n\t\tthis.formEventHandler_.removeListener();\n\t\tthis.linkEventHandler_.removeListener();\n\t\tthis.appEventHandlers_.removeAllListeners();\n\t\tsuper.disposeInternal();\n\t}\n\n\t/**\n\t * Dispatches to the first route handler that matches the current path, if\n\t * any.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tdispatch() {\n\t\treturn this.navigate(utils.getCurrentBrowserPath(), true);\n\t}\n\n\t/**\n\t * Starts navigation to a path.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tdoNavigate_(path, opt_replaceHistory) {\n\t\tif (this.activeScreen && this.activeScreen.beforeDeactivate()) {\n\t\t\tthis.pendingNavigate = CancellablePromise.reject(new CancellablePromise.CancellationError('Cancelled by active screen'));\n\t\t\treturn this.pendingNavigate;\n\t\t}\n\n\t\tvar route = this.findRoute(path);\n\t\tif (!route) {\n\t\t\tthis.pendingNavigate = CancellablePromise.reject(new CancellablePromise.CancellationError('No route for ' + path));\n\t\t\treturn this.pendingNavigate;\n\t\t}\n\n\t\tconsole.log('Navigate to [' + path + ']');\n\n\t\tthis.stopPendingNavigate_();\n\n\t\tvar nextScreen = this.createScreenInstance(path, route);\n\n\t\treturn nextScreen.load(path)\n\t\t\t.then(() => {\n\t\t\t\tif (this.activeScreen) {\n\t\t\t\t\tthis.activeScreen.deactivate();\n\t\t\t\t}\n\t\t\t\tthis.prepareNavigateHistory_(path, nextScreen, opt_replaceHistory);\n\t\t\t\tthis.prepareNavigateSurfaces_(nextScreen, this.surfaces);\n\t\t\t})\n\t\t\t.then(() => nextScreen.evaluateStyles(this.surfaces))\n\t\t\t.then(() => nextScreen.flip(this.surfaces))\n\t\t\t.then(() => nextScreen.evaluateScripts(this.surfaces))\n\t\t\t.then(() => this.syncScrollPositionSyncThenAsync_())\n\t\t\t.then(() => this.finalizeNavigate_(path, nextScreen))\n\t\t\t.catch((reason) => {\n\t\t\t\tthis.handleNavigateError_(path, nextScreen, reason);\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * Finalizes a screen navigation.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @protected\n\t */\n\tfinalizeNavigate_(path, nextScreen) {\n\t\tnextScreen.activate();\n\n\t\tif (this.activeScreen && !this.activeScreen.isCacheable()) {\n\t\t\tif (this.activeScreen !== nextScreen) {\n\t\t\t\tthis.removeScreen(this.activePath);\n\t\t\t}\n\t\t}\n\n\t\tthis.activePath = path;\n\t\tthis.activeScreen = nextScreen;\n\t\tthis.screens[path] = nextScreen;\n\t\tthis.pendingNavigate = null;\n\t\tglobals.capturedFormElement = null;\n\t\tconsole.log('Navigation done');\n\t}\n\n\t/**\n\t * Finds a route for the test path. Returns true if matches has a route,\n\t * otherwise returns null.\n\t * @param {!string} path Path containing the querystring part.\n\t * @return {?Object} Route handler if match any or null if the\n\t * path is the same as the current url and the path contains a fragment.\n\t */\n\tfindRoute(path) {\n\t\t// Prevents navigation if it's a hash change on the same url.\n\t\tif ((path.lastIndexOf('#') > -1) && utils.isCurrentBrowserPath(path)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tpath = utils.getUrlPathWithoutHash(path);\n\n\t\t// Makes sure that the path substring will be in the expected format\n\t\t// (that is, will end with a \"/\").\n\t\tpath = utils.getUrlPathWithoutHash(path.substr(this.basePath.length));\n\n\t\tfor (var i = 0; i < this.routes.length; i++) {\n\t\t\tvar route = this.routes[i];\n\t\t\tif (route.matchesPath(path)) {\n\t\t\t\treturn route;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets allow prevent navigate.\n\t * @return {boolean}\n\t */\n\tgetAllowPreventNavigate() {\n\t\treturn this.allowPreventNavigate;\n\t}\n\n\t/**\n\t * Gets link base path.\n\t * @return {!string}\n\t */\n\tgetBasePath() {\n\t\treturn this.basePath;\n\t}\n\n\t/**\n\t * Gets the default page title.\n\t * @return {string} defaultTitle\n\t */\n\tgetDefaultTitle() {\n\t\treturn this.defaultTitle;\n\t}\n\n\t/**\n\t * Gets the form selector.\n\t * @return {!string}\n\t */\n\tgetFormSelector() {\n\t\treturn this.formSelector;\n\t}\n\n\t/**\n\t * Gets the link selector.\n\t * @return {!string}\n\t */\n\tgetLinkSelector() {\n\t\treturn this.linkSelector;\n\t}\n\n\t/**\n\t * Gets the loading css class.\n\t * @return {!string}\n\t */\n\tgetLoadingCssClass() {\n\t\treturn this.loadingCssClass;\n\t}\n\n\t/**\n\t * Gets the update scroll position value.\n\t * @return {boolean}\n\t */\n\tgetUpdateScrollPosition() {\n\t\treturn this.updateScrollPosition;\n\t}\n\n\t/**\n\t * Handle navigation error.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @param {!Error} error\n\t * @protected\n\t */\n\thandleNavigateError_(path, nextScreen, err) {\n\t\tconsole.log('Navigation error for [' + nextScreen + '] (' + err + ')');\n\t\tif (!utils.isCurrentBrowserPath(path)) {\n\t\t\tthis.removeScreen(path);\n\t\t}\n\t}\n\n\t/**\n\t * Checks if app has routes.\n\t * @return {boolean}\n\t */\n\thasRoutes() {\n\t\treturn this.routes.length > 0;\n\t}\n\n\t/**\n\t * Tests if hostname is an offsite link.\n\t * @param {!string} hostname Link hostname to compare with\n\t * globals.window.location.hostname.\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisLinkSameOrigin_(hostname) {\n\t\treturn hostname === globals.window.location.hostname;\n\t}\n\n\t/**\n\t * Tests if link element has the same app's base path.\n\t * @param {!string} path Link path containing the querystring part.\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisSameBasePath_(path) {\n\t\treturn path.indexOf(this.basePath) === 0;\n\t}\n\n\t/**\n\t * Lock the document scroll in order to avoid the browser native back and\n\t * forward navigation to change the scroll position. In the end of\n\t * navigation lifecycle scroll is repositioned.\n\t * @protected\n\t */\n\tlockHistoryScrollPosition_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\t\t// Browsers are inconsistent when re-positioning the scroll history on\n\t\t// popstate. At some browsers, history scroll happens before popstate, then\n\t\t// lock the scroll on the last known position as soon as possible after the\n\t\t// current JS execution context and capture the current value. Some others,\n\t\t// history scroll happens after popstate, in this case, we bind an once\n\t\t// scroll event to lock the las known position. Lastly, the previous two\n\t\t// behaviors can happen even on the same browser, hence the race will decide\n\t\t// the winner.\n\t\tvar winner = false;\n\t\tvar switchScrollPositionRace = function() {\n\t\t\tglobals.document.removeEventListener('scroll', switchScrollPositionRace, false);\n\t\t\tif (!winner) {\n\t\t\t\tglobals.window.scrollTo(state.scrollLeft, state.scrollTop);\n\t\t\t\twinner = true;\n\t\t\t}\n\t\t};\n\t\tasync.nextTick(switchScrollPositionRace);\n\t\tglobals.document.addEventListener('scroll', switchScrollPositionRace, false);\n\t}\n\n\t/**\n\t * If supported by the browser, disables native scroll restoration and\n\t * stores current value.\n\t */\n\tmaybeDisableNativeScrollRestoration() {\n\t\tif (this.nativeScrollRestorationSupported) {\n\t\t\tthis.nativeScrollRestoration_ = globals.window.history.scrollRestoration;\n\t\t\tglobals.window.history.scrollRestoration = 'manual';\n\t\t}\n\t}\n\n\t/**\n\t * Maybe navigate to a path.\n\t * @param {string} href Information about the link's href.\n\t * @param {Event} event Dom event that initiated the navigation.\n\t */\n\tmaybeNavigate_(href, event) {\n\t\tif (!this.canNavigate(href)) {\n\t\t\treturn;\n\t\t}\n\n\t\tglobals.capturedFormElement = event.capturedFormElement;\n\n\t\tvar navigateFailed = false;\n\t\ttry {\n\t\t\tthis.navigate(utils.getUrlPath(href));\n\t\t} catch (err) {\n\t\t\t// Do not prevent link navigation in case some synchronous error occurs\n\t\t\tnavigateFailed = true;\n\t\t}\n\n\t\tif (!navigateFailed) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\t/**\n\t * Maybe reposition scroll to hashed anchor.\n\t */\n\tmaybeRepositionScrollToHashedAnchor() {\n\t\tvar hash = globals.window.location.hash;\n\t\tif (hash) {\n\t\t\tvar anchorElement = globals.document.getElementById(hash.substring(1));\n\t\t\tif (anchorElement) {\n\t\t\t\tglobals.window.scrollTo(anchorElement.offsetLeft, anchorElement.offsetTop);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * If supported by the browser, restores native scroll restoration to the\n\t * value captured by `maybeDisableNativeScrollRestoration`.\n\t */\n\tmaybeRestoreNativeScrollRestoration() {\n\t\tif (this.nativeScrollRestorationSupported && this.nativeScrollRestoration_) {\n\t\t\tglobals.window.history.scrollRestoration = this.nativeScrollRestoration_;\n\t\t}\n\t}\n\n\t/**\n\t * Navigates to the specified path if there is a route handler that matches.\n\t * @param {!string} path Path to navigate containing the base path.\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tnavigate(path, opt_replaceHistory) {\n\t\tif (!utils.isHtml5HistorySupported()) {\n\t\t\tthrow new Error('HTML5 History is not supported. Senna will not intercept navigation.');\n\t\t}\n\n\t\t// When reloading the same path do replaceState instead of pushState to\n\t\t// avoid polluting history with states with the same path.\n\t\tif (path === this.activePath) {\n\t\t\topt_replaceHistory = true;\n\t\t}\n\n\t\tthis.emit('beforeNavigate', {\n\t\t\tpath: path,\n\t\t\treplaceHistory: !!opt_replaceHistory\n\t\t});\n\n\t\treturn this.pendingNavigate;\n\t}\n\n\t/**\n\t * Befores navigation to a path.\n\t * @param {!Event} event Event facade containing path and\n\t * replaceHistory.\n\t * @protected\n\t */\n\tonBeforeNavigate_(event) {\n\t\tif (globals.capturedFormElement) {\n\t\t\tevent.form = globals.capturedFormElement;\n\t\t}\n\t}\n\n\t/**\n\t * Befores navigation to a path. Runs after external listeners.\n\t * @param {!Event} event Event facade containing path and\n\t * replaceHistory.\n\t * @protected\n\t */\n\tonBeforeNavigateDefault_(event) {\n\t\tif (this.pendingNavigate) {\n\t\t\tif (this.pendingNavigate.path === event.path) {\n\t\t\t\tconsole.log('Waiting...');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tthis.emit('startNavigate', {\n\t\t\tform: event.form,\n\t\t\tpath: event.path,\n\t\t\treplaceHistory: event.replaceHistory\n\t\t});\n\t}\n\n\t/**\n\t * Intercepts document clicks and test link elements in order to decide\n\t * whether Surface app can navigate.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonDocClickDelegate_(event) {\n\t\tif (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || event.button) {\n\t\t\tconsole.log('Navigate aborted, invalid mouse button or modifier key pressed.');\n\t\t\treturn;\n\t\t}\n\t\tthis.maybeNavigate_(event.delegateTarget.href, event);\n\t}\n\n\t/**\n\t * Intercepts document form submits and test action path in order to decide\n\t * whether Surface app can navigate.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonDocSubmitDelegate_(event) {\n\t\tvar form = event.delegateTarget;\n\t\tif (form.method === 'get') {\n\t\t\tconsole.log('GET method not supported');\n\t\t\treturn;\n\t\t}\n\t\tevent.capturedFormElement = form;\n\t\tthis.maybeNavigate_(form.action, event);\n\t}\n\n\t/**\n\t * Listens to the window's load event in order to avoid issues with some browsers\n\t * that trigger popstate calls on the first load. For more information see\n\t * http://stackoverflow.com/questions/6421769/popstate-on-pages-load-in-chrome.\n\t * @protected\n\t */\n\tonLoad_() {\n\t\tthis.skipLoadPopstate = true;\n\t\tsetTimeout(() => {\n\t\t\t// The timeout ensures that popstate events will be unblocked right\n\t\t\t// after the load event occured, but not in the same event-loop cycle.\n\t\t\tthis.skipLoadPopstate = false;\n\t\t}, 0);\n\t\t// Try to reposition scroll to the hashed anchor when page loads.\n\t\tthis.maybeRepositionScrollToHashedAnchor();\n\t}\n\n\t/**\n\t * Handles browser history changes and fires app's navigation if the state\n\t * belows to us. If we detect a popstate and the state is null,\n\t * assume it is navigating to an external page or to a page we don't have\n\t * route, then globals.window.location.reload() is invoked in order to\n\t * reload the content to the current url.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonPopstate_(event) {\n\t\tif (this.skipLoadPopstate) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar state = event.state;\n\n\t\tif (!state) {\n\t\t\tif (globals.window.location.hash) {\n\t\t\t\t// If senna is on an redirect path and a hash popstate happens\n\t\t\t\t// to a different url, reload the browser. This behavior doesn't\n\t\t\t\t// require senna to route hashed links and is closer to native\n\t\t\t\t// browser behavior.\n\t\t\t\tif (this.redirectPath && !utils.isCurrentBrowserPath(this.redirectPath)) {\n\t\t\t\t\tthis.reloadPage();\n\t\t\t\t}\n\t\t\t\t// Always try to reposition scroll to the hashed anchor when\n\t\t\t\t// hash popstate happens.\n\t\t\t\tthis.maybeRepositionScrollToHashedAnchor();\n\t\t\t} else {\n\t\t\t\tthis.reloadPage();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (state.senna) {\n\t\t\tconsole.log('History navigation to [' + state.path + ']');\n\t\t\tthis.popstateScrollTop = state.scrollTop;\n\t\t\tthis.popstateScrollLeft = state.scrollLeft;\n\t\t\tif (!this.nativeScrollRestorationSupported) {\n\t\t\t\tthis.lockHistoryScrollPosition_();\n\t\t\t}\n\t\t\tthis.navigate(state.path, true);\n\t\t}\n\t}\n\n\t/**\n\t * Listens document scroll changes in order to capture the possible lock\n\t * scroll position for history scrolling.\n\t * @protected\n\t */\n\tonScroll_() {\n\t\tif (this.captureScrollPositionFromScrollEvent) {\n\t\t\tthis.saveHistoryCurrentPageScrollPosition_();\n\t\t}\n\t}\n\n\t/**\n\t * Starts navigation to a path.\n\t * @param {!Event} event Event facade containing path and\n\t * replaceHistory.\n\t * @protected\n\t */\n\tonStartNavigate_(event) {\n\t\tthis.maybeDisableNativeScrollRestoration();\n\t\tthis.captureScrollPositionFromScrollEvent = false;\n\t\tdom.addClasses(globals.document.documentElement, this.loadingCssClass);\n\n\t\tvar endNavigatePayload = {\n\t\t\tform: event.form,\n\t\t\tpath: event.path\n\t\t};\n\n\t\tthis.pendingNavigate = this.doNavigate_(event.path, event.replaceHistory)\n\t\t\t.catch((reason) => {\n\t\t\t\tendNavigatePayload.error = reason;\n\t\t\t\tthrow reason;\n\t\t\t})\n\t\t\t.thenAlways(() => {\n\t\t\t\tif (!this.pendingNavigate) {\n\t\t\t\t\tdom.removeClasses(globals.document.documentElement, this.loadingCssClass);\n\t\t\t\t\tthis.maybeRestoreNativeScrollRestoration();\n\t\t\t\t\tthis.captureScrollPositionFromScrollEvent = true;\n\t\t\t\t}\n\t\t\t\tthis.emit('endNavigate', endNavigatePayload);\n\t\t\t});\n\n\t\tthis.pendingNavigate.path = event.path;\n\t}\n\n\t/**\n\t * Prefetches the specified path if there is a route handler that matches.\n\t * @param {!string} path Path to navigate containing the base path.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tprefetch(path) {\n\t\tvar route = this.findRoute(path);\n\t\tif (!route) {\n\t\t\treturn CancellablePromise.reject(new CancellablePromise.CancellationError('No route for ' + path));\n\t\t}\n\n\t\tconsole.log('Prefetching [' + path + ']');\n\n\t\tvar nextScreen = this.createScreenInstance(path, route);\n\n\t\treturn nextScreen.load(path)\n\t\t\t.then(() => this.screens[path] = nextScreen)\n\t\t\t.catch((reason) => {\n\t\t\t\tthis.handleNavigateError_(path, nextScreen, reason);\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * Prepares screen flip. Updates history state and surfaces content.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t */\n\tprepareNavigateHistory_(path, nextScreen, opt_replaceHistory) {\n\t\tvar title = nextScreen.getTitle();\n\t\tif (!core.isString(title)) {\n\t\t\ttitle = this.getDefaultTitle();\n\t\t}\n\t\tvar redirectPath = nextScreen.beforeUpdateHistoryPath(path);\n\t\tvar historyState = {\n\t\t\tform: core.isDefAndNotNull(globals.capturedFormElement),\n\t\t\tredirectPath: redirectPath,\n\t\t\tpath: path,\n\t\t\tsenna: true,\n\t\t\tscrollTop: 0,\n\t\t\tscrollLeft: 0\n\t\t};\n\t\tif (opt_replaceHistory) {\n\t\t\thistoryState.scrollTop = this.popstateScrollTop;\n\t\t\thistoryState.scrollLeft = this.popstateScrollLeft;\n\t\t}\n\t\tthis.updateHistory_(title, redirectPath, nextScreen.beforeUpdateHistoryState(historyState), opt_replaceHistory);\n\t\tthis.redirectPath = redirectPath;\n\t}\n\n\t/**\n\t * Prepares screen flip. Updates history state and surfaces content.\n\t * @param {!Screen} nextScreen\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t */\n\tprepareNavigateSurfaces_(nextScreen, surfaces) {\n\t\tObject.keys(surfaces).forEach((id) => {\n\t\t\tvar surfaceContent = nextScreen.getSurfaceContent(id);\n\t\t\tsurfaces[id].addContent(nextScreen.getId(), surfaceContent);\n\t\t\tconsole.log('Screen [' + nextScreen.getId() + '] add content to surface ' +\n\t\t\t\t'[' + surfaces[id] + '] [' + (core.isDefAndNotNull(surfaceContent) ? '...' : 'empty') + ']');\n\t\t});\n\t}\n\n\t/**\n\t * Reloads the page by performing `window.location.reload()`.\n\t */\n\treloadPage() {\n\t\tglobals.window.location.reload();\n\t}\n\n\t/**\n\t * Removes route instance from app routes.\n\t * @param {Route} route\n\t * @return {boolean} True if an element was removed.\n\t */\n\tremoveRoute(route) {\n\t\treturn array.remove(this.routes, route);\n\t}\n\n\t/**\n\t * Removes a screen.\n\t * @param {!string} path Path containing the querystring part.\n\t */\n\tremoveScreen(path) {\n\t\tvar screen = this.screens[path];\n\t\tif (screen) {\n\t\t\tObject.keys(this.surfaces).forEach((surfaceId) => this.surfaces[surfaceId].remove(screen.getId()));\n\t\t\tscreen.dispose();\n\t\t\tdelete this.screens[path];\n\t\t}\n\t}\n\n\t/**\n\t * Saves scroll position from page offset into history state.\n\t */\n\tsaveHistoryCurrentPageScrollPosition_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (state && state.senna) {\n\t\t\tstate.scrollTop = globals.window.pageYOffset;\n\t\t\tstate.scrollLeft = globals.window.pageXOffset;\n\t\t\tglobals.window.history.replaceState(state, null, null);\n\t\t}\n\t}\n\n\t/**\n\t * Sets allow prevent navigate.\n\t * @param {boolean} allowPreventNavigate\n\t */\n\tsetAllowPreventNavigate(allowPreventNavigate) {\n\t\tthis.allowPreventNavigate = allowPreventNavigate;\n\t}\n\n\t/**\n\t * Sets link base path.\n\t * @param {!string} path\n\t */\n\tsetBasePath(basePath) {\n\t\tthis.basePath = basePath;\n\t}\n\n\t/**\n\t * Sets the default page title.\n\t * @param {string} defaultTitle\n\t */\n\tsetDefaultTitle(defaultTitle) {\n\t\tthis.defaultTitle = defaultTitle;\n\t}\n\n\t/**\n\t * Sets the form selector.\n\t * @param {!string} formSelector\n\t */\n\tsetFormSelector(formSelector) {\n\t\tthis.formSelector = formSelector;\n\t\tif (this.formEventHandler_) {\n\t\t\tthis.formEventHandler_.removeListener();\n\t\t}\n\t\tthis.formEventHandler_ = dom.delegate(document, 'submit', this.formSelector, this.onDocSubmitDelegate_.bind(this), this.allowPreventNavigate);\n\t}\n\n\t/**\n\t * Sets the link selector.\n\t * @param {!string} linkSelector\n\t */\n\tsetLinkSelector(linkSelector) {\n\t\tthis.linkSelector = linkSelector;\n\t\tif (this.linkEventHandler_) {\n\t\t\tthis.linkEventHandler_.removeListener();\n\t\t}\n\t\tthis.linkEventHandler_ = dom.delegate(document, 'click', this.linkSelector, this.onDocClickDelegate_.bind(this), this.allowPreventNavigate);\n\t}\n\n\t/**\n\t * Sets the loading css class.\n\t * @param {!string} loadingCssClass\n\t */\n\tsetLoadingCssClass(loadingCssClass) {\n\t\tthis.loadingCssClass = loadingCssClass;\n\t}\n\n\t/**\n\t * Sets the update scroll position value.\n\t * @param {boolean} updateScrollPosition\n\t */\n\tsetUpdateScrollPosition(updateScrollPosition) {\n\t\tthis.updateScrollPosition = updateScrollPosition;\n\t}\n\n\t/**\n\t * Cancels pending navigate with Cancel pending navigation error.\n\t * @protected\n\t */\n\tstopPendingNavigate_() {\n\t\tif (this.pendingNavigate) {\n\t\t\tthis.pendingNavigate.cancel('Cancel pending navigation');\n\t\t\tthis.pendingNavigate = null;\n\t\t}\n\t}\n\n\t/**\n\t * Sync document scroll position twice, the first one synchronous and then\n\t * one inside async.nextTick. Relevant to browsers that fires\n\t * scroll restoration asynchronously after popstate.\n\t * @protected\n\t * @return {?CancellablePromise=}\n\t */\n\tsyncScrollPositionSyncThenAsync_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar scrollTop = state.scrollTop;\n\t\tvar scrollLeft = state.scrollLeft;\n\n\t\tvar sync = () => {\n\t\t\tif (this.updateScrollPosition) {\n\t\t\t\tglobals.window.scrollTo(scrollLeft, scrollTop);\n\t\t\t}\n\t\t};\n\n\t\treturn new CancellablePromise((resolve) => sync() & async.nextTick(() => sync() & resolve()));\n\t}\n\n\t/**\n\t * Updates or replace browser history.\n\t * @param {?string} title Document title.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!object} state\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @protected\n\t */\n\tupdateHistory_(title, path, state, opt_replaceHistory) {\n\t\tif (opt_replaceHistory) {\n\t\t\tglobals.window.history.replaceState(state, title, path);\n\t\t} else {\n\t\t\tglobals.window.history.pushState(state, title, path);\n\t\t}\n\t\tglobals.document.title = title;\n\t}\n\n}\n\nexport default App;\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["App.js"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAcM,G;;;;;;;;;AAOL,iBAAc;AAAA;;AAAA,gDACb,wBADa;;;;;;;AAQb,SAAK,YAAL,GAAoB,IAApB;;;;;;;AAOA,SAAK,UAAL,GAAkB,IAAlB;;;;;;;;AAQA,SAAK,oBAAL,GAA4B,IAA5B;;;;;;;;AAQA,SAAK,QAAL,GAAgB,EAAhB;;;;;;;;AAQA,SAAK,oCAAL,GAA4C,IAA5C;;;;;;;;AAQA,SAAK,YAAL,GAAoB,kBAAQ,QAAR,CAAiB,KAArC;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,oBAA7F,CAAzB;AACA,G;;gBAMD,kB,+BAAmB,e,EAAiB;AACnC,QAAK,eAAL,GAAuB,eAAvB;AACA,G;;gBAMD,uB,oCAAwB,oB,EAAsB;AAC7C,QAAK,oBAAL,GAA4B,oBAA5B;AACA,G;;gBAMD,oB,mCAAuB;AACtB,OAAI,KAAK,eAAT,EAA0B;AACzB,SAAK,eAAL,CAAqB,MAArB,CAA4B,2BAA5B;AACA,SAAK,eAAL,GAAuB,IAAvB;AACA;AACD,G;;gBASD,gC,+CAAmC;AAAA;;AAClC,OAAI,QAAQ,kBAAQ,MAAR,CAAe,OAAf,CAAuB,KAAnC;AACA,OAAI,CAAC,KAAL,EAAY;AACX;AACA;;AAED,OAAI,YAAY,MAAM,SAAtB;AACA,OAAI,aAAa,MAAM,UAAvB;;AAEA,OAAI,OAAO,SAAP,IAAO,GAAM;AAChB,QAAI,QAAK,oBAAT,EAA+B;AAC9B,uBAAQ,MAAR,CAAe,QAAf,CAAwB,UAAxB,EAAoC,SAApC;AACA;AACD,IAJD;;AAMA,UAAO,sBAAuB,UAAC,OAAD;AAAA,WAAa,SAAS,aAAM,QAAN,CAAe;AAAA,YAAM,SAAS,SAAf;AAAA,KAAf,CAAtB;AAAA,IAAvB,CAAP;AACA,G;;gBAUD,c,2BAAe,K,EAAO,I,EAAM,K,EAAO,kB,EAAoB;AACtD,OAAI,kBAAJ,EAAwB;AACvB,sBAAQ,MAAR,CAAe,OAAf,CAAuB,YAAvB,CAAoC,KAApC,EAA2C,KAA3C,EAAkD,IAAlD;AACA,IAFD,MAEO;AACN,sBAAQ,MAAR,CAAe,OAAf,CAAuB,SAAvB,CAAiC,KAAjC,EAAwC,KAAxC,EAA+C,IAA/C;AACA;AACD,qBAAQ,QAAR,CAAiB,KAAjB,GAAyB,KAAzB;AACA,G;;;;;mBAIa,G","file":"src/app/App.js","sourcesContent":["'use strict';\n\nimport { array, async, core } from 'metal';\nimport debounce from 'metal-debounce';\nimport dom from 'metal-dom';\nimport CancellablePromise from 'metal-promise';\nimport { EventEmitter, EventHandler } from 'metal-events';\nimport utils from '../utils/utils';\nimport globals from '../globals/globals';\nimport Route from '../route/Route';\nimport Screen from '../screen/Screen';\nimport Surface from '../surface/Surface';\nimport Uri from 'metal-uri';\n\nclass App extends EventEmitter {\n\n\t/**\n\t * App class that handle routes and screens lifecycle.\n\t * @constructor\n\t * @extends {EventEmitter}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the active screen.\n\t\t * @type {?Screen}\n\t\t * @protected\n\t\t */\n\t\tthis.activeScreen = null;\n\n\t\t/**\n\t\t * Holds the active path containing the query parameters.\n\t\t * @type {?string}\n\t\t * @protected\n\t\t */\n\t\tthis.activePath = null;\n\n\t\t/**\n\t\t * Allows prevent navigate from dom prevented event.\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.allowPreventNavigate = true;\n\n\t\t/**\n\t\t * Holds link base path.\n\t\t * @type {!string}\n\t\t * @default ''\n\t\t * @protected\n\t\t */\n\t\tthis.basePath = '';\n\n\t\t/**\n\t\t * Captures scroll position from scroll event.\n\t\t * @type {!boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.captureScrollPositionFromScrollEvent = true;\n\n\t\t/**\n\t\t * Holds the default page title.\n\t\t * @type {string}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.defaultTitle = globals.document.title;\n\n\t\t/**\n\t\t * Holds the form selector to define forms that are routed.\n\t\t * @type {!string}\n\t\t * @default form[enctype=\"multipart/form-data\"]:not([data-senna-off])\n\t\t * @protected\n\t\t */\n\t\tthis.formSelector = 'form[enctype=\"multipart/form-data\"]:not([data-senna-off])';\n\n\t\t/**\n\t\t * Holds the link selector to define links that are routed.\n\t\t * @type {!string}\n\t\t * @default a:not([data-senna-off])\n\t\t * @protected\n\t\t */\n\t\tthis.linkSelector = 'a:not([data-senna-off])';\n\n\t\t/**\n\t\t * Holds the loading css class.\n\t\t * @type {!string}\n\t\t * @default senna-loading\n\t\t * @protected\n\t\t */\n\t\tthis.loadingCssClass = 'senna-loading';\n\n\t\t/**\n\t\t * Using the History API to manage your URLs is awesome and, as it happens,\n\t\t * a crucial feature of good web apps. One of its downsides, however, is\n\t\t * that scroll positions are stored and then, more importantly, restored\n\t\t * whenever you traverse the history. This often means unsightly jumps as\n\t\t * the scroll position changes automatically, and especially so if your app\n\t\t * does transitions, or changes the contents of the page in any way.\n\t\t * Ultimately this leads to an horrible user experience. The good news is,\n\t\t * however, that there’s a potential fix: history.scrollRestoration.\n\t\t * https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration\n\t\t * @type {boolean}\n\t\t * @protected\n\t\t */\n\t\tthis.nativeScrollRestorationSupported = ('scrollRestoration' in globals.window.history);\n\n\t\t/**\n\t\t * Holds a deferred with the current navigation.\n\t\t * @type {?CancellablePromise}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.pendingNavigate = null;\n\n\t\t/**\n\t\t * Holds the window horizontal scroll position when the navigation using\n\t\t * back or forward happens to be restored after the surfaces are updated.\n\t\t * @type {!Number}\n\t\t * @default 0\n\t\t * @protected\n\t\t */\n\t\tthis.popstateScrollLeft = 0;\n\n\t\t/**\n\t\t * Holds the window vertical scroll position when the navigation using\n\t\t * back or forward happens to be restored after the surfaces are updated.\n\t\t * @type {!Number}\n\t\t * @default 0\n\t\t * @protected\n\t\t */\n\t\tthis.popstateScrollTop = 0;\n\n\t\t/**\n\t\t * Holds the redirect path containing the query parameters.\n\t\t * @type {?string}\n\t\t * @protected\n\t\t */\n\t\tthis.redirectPath = null;\n\n\t\t/**\n\t\t * Holds the screen routes configuration.\n\t\t * @type {?Array}\n\t\t * @default []\n\t\t * @protected\n\t\t */\n\t\tthis.routes = [];\n\n\t\t/**\n\t\t * Maps the screen instances by the url containing the parameters.\n\t\t * @type {?Object}\n\t\t * @default {}\n\t\t * @protected\n\t\t */\n\t\tthis.screens = {};\n\n\t\t/**\n\t\t * When set to true the first erroneous popstate fired on page load will be\n\t\t * ignored, only if globals.window.history.state is also\n\t\t * null.\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t * @protected\n\t\t */\n\t\tthis.skipLoadPopstate = false;\n\n\t\t/**\n\t\t * Maps that index the surfaces instances by the surface id.\n\t\t * @type {?Object}\n\t\t * @default {}\n\t\t * @protected\n\t\t */\n\t\tthis.surfaces = {};\n\n\t\t/**\n\t\t * When set to true, moves the scroll position after popstate, or to the\n\t\t * top of the viewport for new navigation. If false, the browser will\n\t\t * take care of scroll restoration.\n\t\t * @type {!boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.updateScrollPosition = true;\n\n\t\tthis.appEventHandlers_ = new EventHandler();\n\n\t\tthis.appEventHandlers_.add(\n\t\t\tdom.on(globals.window, 'scroll', debounce(this.onScroll_.bind(this), 100)),\n\t\t\tdom.on(globals.window, 'load', this.onLoad_.bind(this)),\n\t\t\tdom.on(globals.window, 'popstate', this.onPopstate_.bind(this))\n\t\t);\n\n\t\tthis.on('startNavigate', this.onStartNavigate_);\n\t\tthis.on('beforeNavigate', this.onBeforeNavigate_);\n\t\tthis.on('beforeNavigate', this.onBeforeNavigateDefault_, true);\n\n\t\tthis.setLinkSelector(this.linkSelector);\n\t\tthis.setFormSelector(this.formSelector);\n\t}\n\n\t/**\n\t * Adds one or more screens to the application.\n\t *\n\t * Example:\n\t *\n\t * \n\t * app.addRoutes({ path: '/foo', handler: FooScreen });\n\t * or\n\t * app.addRoutes([{ path: '/foo', handler: function(route) { return new FooScreen(); } }]);\n\t * \n\t *\n\t * @param {Object} or {Array} routes Single object or an array of object.\n\t * Each object should contain path and screen.\n\t * The path should be a string or a regex that maps the\n\t * navigation route to a screen class definition (not an instance), e.g:\n\t * { path: \"/home:param1\", handler: MyScreen }\n\t * { path: /foo.+/, handler: MyScreen }\n\t * @chainable\n\t */\n\taddRoutes(routes) {\n\t\tif (!Array.isArray(routes)) {\n\t\t\troutes = [routes];\n\t\t}\n\t\troutes.forEach((route) => {\n\t\t\tif (!(route instanceof Route)) {\n\t\t\t\troute = new Route(route.path, route.handler);\n\t\t\t}\n\t\t\tthis.routes.push(route);\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds one or more surfaces to the application.\n\t * @param {Surface|String|Array.} surfaces\n\t * Surface element id or surface instance. You can also pass an Array\n\t * whichcontains surface instances or id. In case of ID, these should be\n\t * the id of surface element.\n\t * @chainable\n\t */\n\taddSurfaces(surfaces) {\n\t\tif (!Array.isArray(surfaces)) {\n\t\t\tsurfaces = [surfaces];\n\t\t}\n\t\tsurfaces.forEach((surface) => {\n\t\t\tif (core.isString(surface)) {\n\t\t\t\tsurface = new Surface(surface);\n\t\t\t}\n\t\t\tthis.surfaces[surface.getId()] = surface;\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns if can navigate to path.\n\t * @param {!string} url\n\t * @return {boolean}\n\t */\n\tcanNavigate(url) {\n\t\tvar path = utils.getUrlPath(url);\n\t\tvar uri = new Uri(url);\n\n\t\tif (!this.isLinkSameOrigin_(uri.getHostname())) {\n\t\t\tconsole.log('Offsite link clicked');\n\t\t\treturn false;\n\t\t}\n\t\tif (!this.isSameBasePath_(path)) {\n\t\t\tconsole.log('Link clicked outside app\\'s base path');\n\t\t\treturn false;\n\t\t}\n\t\tif (!this.findRoute(path)) {\n\t\t\tconsole.log('No route for ' + path);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Clear screens cache.\n\t * @chainable\n\t */\n\tclearScreensCache() {\n\t\tObject.keys(this.screens).forEach((path) => {\n\t\t\tif (path === this.activePath) {\n\t\t\t\tthis.activeScreen.clearCache();\n\t\t\t} else {\n\t\t\t\tthis.removeScreen(path);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves or create a screen instance to a path.\n\t * @param {!string} path Path containing the querystring part.\n\t * @return {Screen}\n\t */\n\tcreateScreenInstance(path, route) {\n\t\tif (!this.pendingNavigate && path === this.activePath) {\n\t\t\tconsole.log('Already at destination, refresh navigation');\n\t\t\treturn this.activeScreen;\n\t\t}\n\t\t/* jshint newcap: false */\n\t\tvar screen = this.screens[path];\n\t\tif (!screen) {\n\t\t\tvar handler = route.getHandler();\n\t\t\tif (handler === Screen || Screen.isImplementedBy(handler.prototype)) {\n\t\t\t\tscreen = new handler();\n\t\t\t} else {\n\t\t\t\tscreen = handler(route) || new Screen();\n\t\t\t}\n\t\t\tconsole.log('Create screen for [' + path + '] [' + screen + ']');\n\t\t}\n\t\treturn screen;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tif (this.activeScreen) {\n\t\t\tthis.removeScreen(this.activePath);\n\t\t}\n\t\tthis.clearScreensCache();\n\t\tthis.formEventHandler_.removeListener();\n\t\tthis.linkEventHandler_.removeListener();\n\t\tthis.appEventHandlers_.removeAllListeners();\n\t\tsuper.disposeInternal();\n\t}\n\n\t/**\n\t * Dispatches to the first route handler that matches the current path, if\n\t * any.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tdispatch() {\n\t\treturn this.navigate(utils.getCurrentBrowserPath(), true);\n\t}\n\n\t/**\n\t * Starts navigation to a path.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tdoNavigate_(path, opt_replaceHistory) {\n\t\tif (this.activeScreen && this.activeScreen.beforeDeactivate()) {\n\t\t\tthis.pendingNavigate = CancellablePromise.reject(new CancellablePromise.CancellationError('Cancelled by active screen'));\n\t\t\treturn this.pendingNavigate;\n\t\t}\n\n\t\tvar route = this.findRoute(path);\n\t\tif (!route) {\n\t\t\tthis.pendingNavigate = CancellablePromise.reject(new CancellablePromise.CancellationError('No route for ' + path));\n\t\t\treturn this.pendingNavigate;\n\t\t}\n\n\t\tconsole.log('Navigate to [' + path + ']');\n\n\t\tthis.stopPendingNavigate_();\n\n\t\tvar nextScreen = this.createScreenInstance(path, route);\n\n\t\treturn nextScreen.load(path)\n\t\t\t.then(() => {\n\t\t\t\tif (this.activeScreen) {\n\t\t\t\t\tthis.activeScreen.deactivate();\n\t\t\t\t}\n\t\t\t\tthis.prepareNavigateHistory_(path, nextScreen, opt_replaceHistory);\n\t\t\t\tthis.prepareNavigateSurfaces_(nextScreen, this.surfaces);\n\t\t\t})\n\t\t\t.then(() => nextScreen.evaluateStyles(this.surfaces))\n\t\t\t.then(() => nextScreen.flip(this.surfaces))\n\t\t\t.then(() => nextScreen.evaluateScripts(this.surfaces))\n\t\t\t.then(() => this.syncScrollPositionSyncThenAsync_())\n\t\t\t.then(() => this.finalizeNavigate_(path, nextScreen))\n\t\t\t.catch((reason) => {\n\t\t\t\tthis.handleNavigateError_(path, nextScreen, reason);\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * Finalizes a screen navigation.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @protected\n\t */\n\tfinalizeNavigate_(path, nextScreen) {\n\t\tnextScreen.activate();\n\n\t\tif (this.activeScreen && !this.activeScreen.isCacheable()) {\n\t\t\tif (this.activeScreen !== nextScreen) {\n\t\t\t\tthis.removeScreen(this.activePath);\n\t\t\t}\n\t\t}\n\n\t\tthis.activePath = path;\n\t\tthis.activeScreen = nextScreen;\n\t\tthis.screens[path] = nextScreen;\n\t\tthis.pendingNavigate = null;\n\t\tglobals.capturedFormElement = null;\n\t\tconsole.log('Navigation done');\n\t}\n\n\t/**\n\t * Finds a route for the test path. Returns true if matches has a route,\n\t * otherwise returns null.\n\t * @param {!string} path Path containing the querystring part.\n\t * @return {?Object} Route handler if match any or null if the\n\t * path is the same as the current url and the path contains a fragment.\n\t */\n\tfindRoute(path) {\n\t\t// Prevents navigation if it's a hash change on the same url.\n\t\tif ((path.lastIndexOf('#') > -1) && utils.isCurrentBrowserPath(path)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tpath = utils.getUrlPathWithoutHash(path);\n\n\t\t// Makes sure that the path substring will be in the expected format\n\t\t// (that is, will end with a \"/\").\n\t\tpath = utils.getUrlPathWithoutHash(path.substr(this.basePath.length));\n\n\t\tfor (var i = 0; i < this.routes.length; i++) {\n\t\t\tvar route = this.routes[i];\n\t\t\tif (route.matchesPath(path)) {\n\t\t\t\treturn route;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets allow prevent navigate.\n\t * @return {boolean}\n\t */\n\tgetAllowPreventNavigate() {\n\t\treturn this.allowPreventNavigate;\n\t}\n\n\t/**\n\t * Gets link base path.\n\t * @return {!string}\n\t */\n\tgetBasePath() {\n\t\treturn this.basePath;\n\t}\n\n\t/**\n\t * Gets the default page title.\n\t * @return {string} defaultTitle\n\t */\n\tgetDefaultTitle() {\n\t\treturn this.defaultTitle;\n\t}\n\n\t/**\n\t * Gets the form selector.\n\t * @return {!string}\n\t */\n\tgetFormSelector() {\n\t\treturn this.formSelector;\n\t}\n\n\t/**\n\t * Gets the link selector.\n\t * @return {!string}\n\t */\n\tgetLinkSelector() {\n\t\treturn this.linkSelector;\n\t}\n\n\t/**\n\t * Gets the loading css class.\n\t * @return {!string}\n\t */\n\tgetLoadingCssClass() {\n\t\treturn this.loadingCssClass;\n\t}\n\n\t/**\n\t * Gets the update scroll position value.\n\t * @return {boolean}\n\t */\n\tgetUpdateScrollPosition() {\n\t\treturn this.updateScrollPosition;\n\t}\n\n\t/**\n\t * Handle navigation error.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @param {!Error} error\n\t * @protected\n\t */\n\thandleNavigateError_(path, nextScreen, err) {\n\t\tconsole.log('Navigation error for [' + nextScreen + '] (' + err + ')');\n\t\tif (!utils.isCurrentBrowserPath(path)) {\n\t\t\t if (this.pendingNavigate) {\n\t\t\t \tthis.pendingNavigate.thenAlways(() => this.removeScreen(path), this);\n\t\t \t}\n\t\t \telse {\n\t\t \t\tthis.removeScreen(path);\n\t\t \t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if app has routes.\n\t * @return {boolean}\n\t */\n\thasRoutes() {\n\t\treturn this.routes.length > 0;\n\t}\n\n\t/**\n\t * Tests if hostname is an offsite link.\n\t * @param {!string} hostname Link hostname to compare with\n\t * globals.window.location.hostname.\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisLinkSameOrigin_(hostname) {\n\t\treturn hostname === globals.window.location.hostname;\n\t}\n\n\t/**\n\t * Tests if link element has the same app's base path.\n\t * @param {!string} path Link path containing the querystring part.\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisSameBasePath_(path) {\n\t\treturn path.indexOf(this.basePath) === 0;\n\t}\n\n\t/**\n\t * Lock the document scroll in order to avoid the browser native back and\n\t * forward navigation to change the scroll position. In the end of\n\t * navigation lifecycle scroll is repositioned.\n\t * @protected\n\t */\n\tlockHistoryScrollPosition_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\t\t// Browsers are inconsistent when re-positioning the scroll history on\n\t\t// popstate. At some browsers, history scroll happens before popstate, then\n\t\t// lock the scroll on the last known position as soon as possible after the\n\t\t// current JS execution context and capture the current value. Some others,\n\t\t// history scroll happens after popstate, in this case, we bind an once\n\t\t// scroll event to lock the las known position. Lastly, the previous two\n\t\t// behaviors can happen even on the same browser, hence the race will decide\n\t\t// the winner.\n\t\tvar winner = false;\n\t\tvar switchScrollPositionRace = function() {\n\t\t\tglobals.document.removeEventListener('scroll', switchScrollPositionRace, false);\n\t\t\tif (!winner) {\n\t\t\t\tglobals.window.scrollTo(state.scrollLeft, state.scrollTop);\n\t\t\t\twinner = true;\n\t\t\t}\n\t\t};\n\t\tasync.nextTick(switchScrollPositionRace);\n\t\tglobals.document.addEventListener('scroll', switchScrollPositionRace, false);\n\t}\n\n\t/**\n\t * If supported by the browser, disables native scroll restoration and\n\t * stores current value.\n\t */\n\tmaybeDisableNativeScrollRestoration() {\n\t\tif (this.nativeScrollRestorationSupported) {\n\t\t\tthis.nativeScrollRestoration_ = globals.window.history.scrollRestoration;\n\t\t\tglobals.window.history.scrollRestoration = 'manual';\n\t\t}\n\t}\n\n\t/**\n\t * Maybe navigate to a path.\n\t * @param {string} href Information about the link's href.\n\t * @param {Event} event Dom event that initiated the navigation.\n\t */\n\tmaybeNavigate_(href, event) {\n\t\tif (!this.canNavigate(href)) {\n\t\t\treturn;\n\t\t}\n\n\t\tglobals.capturedFormElement = event.capturedFormElement;\n\n\t\tvar navigateFailed = false;\n\t\ttry {\n\t\t\tthis.navigate(utils.getUrlPath(href));\n\t\t} catch (err) {\n\t\t\t// Do not prevent link navigation in case some synchronous error occurs\n\t\t\tnavigateFailed = true;\n\t\t}\n\n\t\tif (!navigateFailed) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\t/**\n\t * Maybe reposition scroll to hashed anchor.\n\t */\n\tmaybeRepositionScrollToHashedAnchor() {\n\t\tvar hash = globals.window.location.hash;\n\t\tif (hash) {\n\t\t\tvar anchorElement = globals.document.getElementById(hash.substring(1));\n\t\t\tif (anchorElement) {\n\t\t\t\tglobals.window.scrollTo(anchorElement.offsetLeft, anchorElement.offsetTop);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * If supported by the browser, restores native scroll restoration to the\n\t * value captured by `maybeDisableNativeScrollRestoration`.\n\t */\n\tmaybeRestoreNativeScrollRestoration() {\n\t\tif (this.nativeScrollRestorationSupported && this.nativeScrollRestoration_) {\n\t\t\tglobals.window.history.scrollRestoration = this.nativeScrollRestoration_;\n\t\t}\n\t}\n\n\t/**\n\t * Navigates to the specified path if there is a route handler that matches.\n\t * @param {!string} path Path to navigate containing the base path.\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tnavigate(path, opt_replaceHistory) {\n\t\tif (!utils.isHtml5HistorySupported()) {\n\t\t\tthrow new Error('HTML5 History is not supported. Senna will not intercept navigation.');\n\t\t}\n\n\t\t// When reloading the same path do replaceState instead of pushState to\n\t\t// avoid polluting history with states with the same path.\n\t\tif (path === this.activePath) {\n\t\t\topt_replaceHistory = true;\n\t\t}\n\n\t\tthis.emit('beforeNavigate', {\n\t\t\tpath: path,\n\t\t\treplaceHistory: !!opt_replaceHistory\n\t\t});\n\n\t\treturn this.pendingNavigate;\n\t}\n\n\t/**\n\t * Befores navigation to a path.\n\t * @param {!Event} event Event facade containing path and\n\t * replaceHistory.\n\t * @protected\n\t */\n\tonBeforeNavigate_(event) {\n\t\tif (globals.capturedFormElement) {\n\t\t\tevent.form = globals.capturedFormElement;\n\t\t}\n\t}\n\n\t/**\n\t * Befores navigation to a path. Runs after external listeners.\n\t * @param {!Event} event Event facade containing path and\n\t * replaceHistory.\n\t * @protected\n\t */\n\tonBeforeNavigateDefault_(event) {\n\t\tif (this.pendingNavigate) {\n\t\t\tif (this.pendingNavigate.path === event.path) {\n\t\t\t\tconsole.log('Waiting...');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tthis.emit('startNavigate', {\n\t\t\tform: event.form,\n\t\t\tpath: event.path,\n\t\t\treplaceHistory: event.replaceHistory\n\t\t});\n\t}\n\n\t/**\n\t * Intercepts document clicks and test link elements in order to decide\n\t * whether Surface app can navigate.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonDocClickDelegate_(event) {\n\t\tif (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || event.button) {\n\t\t\tconsole.log('Navigate aborted, invalid mouse button or modifier key pressed.');\n\t\t\treturn;\n\t\t}\n\t\tthis.maybeNavigate_(event.delegateTarget.href, event);\n\t}\n\n\t/**\n\t * Intercepts document form submits and test action path in order to decide\n\t * whether Surface app can navigate.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonDocSubmitDelegate_(event) {\n\t\tvar form = event.delegateTarget;\n\t\tif (form.method === 'get') {\n\t\t\tconsole.log('GET method not supported');\n\t\t\treturn;\n\t\t}\n\t\tevent.capturedFormElement = form;\n\t\tthis.maybeNavigate_(form.action, event);\n\t}\n\n\t/**\n\t * Listens to the window's load event in order to avoid issues with some browsers\n\t * that trigger popstate calls on the first load. For more information see\n\t * http://stackoverflow.com/questions/6421769/popstate-on-pages-load-in-chrome.\n\t * @protected\n\t */\n\tonLoad_() {\n\t\tthis.skipLoadPopstate = true;\n\t\tsetTimeout(() => {\n\t\t\t// The timeout ensures that popstate events will be unblocked right\n\t\t\t// after the load event occured, but not in the same event-loop cycle.\n\t\t\tthis.skipLoadPopstate = false;\n\t\t}, 0);\n\t\t// Try to reposition scroll to the hashed anchor when page loads.\n\t\tthis.maybeRepositionScrollToHashedAnchor();\n\t}\n\n\t/**\n\t * Handles browser history changes and fires app's navigation if the state\n\t * belows to us. If we detect a popstate and the state is null,\n\t * assume it is navigating to an external page or to a page we don't have\n\t * route, then globals.window.location.reload() is invoked in order to\n\t * reload the content to the current url.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonPopstate_(event) {\n\t\tif (this.skipLoadPopstate) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar state = event.state;\n\n\t\tif (!state) {\n\t\t\tif (globals.window.location.hash) {\n\t\t\t\t// If senna is on an redirect path and a hash popstate happens\n\t\t\t\t// to a different url, reload the browser. This behavior doesn't\n\t\t\t\t// require senna to route hashed links and is closer to native\n\t\t\t\t// browser behavior.\n\t\t\t\tif (this.redirectPath && !utils.isCurrentBrowserPath(this.redirectPath)) {\n\t\t\t\t\tthis.reloadPage();\n\t\t\t\t}\n\t\t\t\t// Always try to reposition scroll to the hashed anchor when\n\t\t\t\t// hash popstate happens.\n\t\t\t\tthis.maybeRepositionScrollToHashedAnchor();\n\t\t\t} else {\n\t\t\t\tthis.reloadPage();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (state.senna) {\n\t\t\tconsole.log('History navigation to [' + state.path + ']');\n\t\t\tthis.popstateScrollTop = state.scrollTop;\n\t\t\tthis.popstateScrollLeft = state.scrollLeft;\n\t\t\tif (!this.nativeScrollRestorationSupported) {\n\t\t\t\tthis.lockHistoryScrollPosition_();\n\t\t\t}\n\t\t\tthis.navigate(state.path, true);\n\t\t}\n\t}\n\n\t/**\n\t * Listens document scroll changes in order to capture the possible lock\n\t * scroll position for history scrolling.\n\t * @protected\n\t */\n\tonScroll_() {\n\t\tif (this.captureScrollPositionFromScrollEvent) {\n\t\t\tthis.saveHistoryCurrentPageScrollPosition_();\n\t\t}\n\t}\n\n\t/**\n\t * Starts navigation to a path.\n\t * @param {!Event} event Event facade containing path and\n\t * replaceHistory.\n\t * @protected\n\t */\n\tonStartNavigate_(event) {\n\t\tthis.maybeDisableNativeScrollRestoration();\n\t\tthis.captureScrollPositionFromScrollEvent = false;\n\t\tdom.addClasses(globals.document.documentElement, this.loadingCssClass);\n\n\t\tvar endNavigatePayload = {\n\t\t\tform: event.form,\n\t\t\tpath: event.path\n\t\t};\n\n\t\tthis.pendingNavigate = this.doNavigate_(event.path, event.replaceHistory)\n\t\t\t.catch((reason) => {\n\t\t\t\tendNavigatePayload.error = reason;\n\t\t\t\tthrow reason;\n\t\t\t})\n\t\t\t.thenAlways(() => {\n\t\t\t\tif (!this.pendingNavigate) {\n\t\t\t\t\tdom.removeClasses(globals.document.documentElement, this.loadingCssClass);\n\t\t\t\t\tthis.maybeRestoreNativeScrollRestoration();\n\t\t\t\t\tthis.captureScrollPositionFromScrollEvent = true;\n\t\t\t\t}\n\t\t\t\tthis.emit('endNavigate', endNavigatePayload);\n\t\t\t});\n\n\t\tthis.pendingNavigate.path = event.path;\n\t}\n\n\t/**\n\t * Prefetches the specified path if there is a route handler that matches.\n\t * @param {!string} path Path to navigate containing the base path.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tprefetch(path) {\n\t\tvar route = this.findRoute(path);\n\t\tif (!route) {\n\t\t\treturn CancellablePromise.reject(new CancellablePromise.CancellationError('No route for ' + path));\n\t\t}\n\n\t\tconsole.log('Prefetching [' + path + ']');\n\n\t\tvar nextScreen = this.createScreenInstance(path, route);\n\n\t\treturn nextScreen.load(path)\n\t\t\t.then(() => this.screens[path] = nextScreen)\n\t\t\t.catch((reason) => {\n\t\t\t\tthis.handleNavigateError_(path, nextScreen, reason);\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * Prepares screen flip. Updates history state and surfaces content.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t */\n\tprepareNavigateHistory_(path, nextScreen, opt_replaceHistory) {\n\t\tvar title = nextScreen.getTitle();\n\t\tif (!core.isString(title)) {\n\t\t\ttitle = this.getDefaultTitle();\n\t\t}\n\t\tvar redirectPath = nextScreen.beforeUpdateHistoryPath(path);\n\t\tvar historyState = {\n\t\t\tform: core.isDefAndNotNull(globals.capturedFormElement),\n\t\t\tredirectPath: redirectPath,\n\t\t\tpath: path,\n\t\t\tsenna: true,\n\t\t\tscrollTop: 0,\n\t\t\tscrollLeft: 0\n\t\t};\n\t\tif (opt_replaceHistory) {\n\t\t\thistoryState.scrollTop = this.popstateScrollTop;\n\t\t\thistoryState.scrollLeft = this.popstateScrollLeft;\n\t\t}\n\t\tthis.updateHistory_(title, redirectPath, nextScreen.beforeUpdateHistoryState(historyState), opt_replaceHistory);\n\t\tthis.redirectPath = redirectPath;\n\t}\n\n\t/**\n\t * Prepares screen flip. Updates history state and surfaces content.\n\t * @param {!Screen} nextScreen\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t */\n\tprepareNavigateSurfaces_(nextScreen, surfaces) {\n\t\tObject.keys(surfaces).forEach((id) => {\n\t\t\tvar surfaceContent = nextScreen.getSurfaceContent(id);\n\t\t\tsurfaces[id].addContent(nextScreen.getId(), surfaceContent);\n\t\t\tconsole.log('Screen [' + nextScreen.getId() + '] add content to surface ' +\n\t\t\t\t'[' + surfaces[id] + '] [' + (core.isDefAndNotNull(surfaceContent) ? '...' : 'empty') + ']');\n\t\t});\n\t}\n\n\t/**\n\t * Reloads the page by performing `window.location.reload()`.\n\t */\n\treloadPage() {\n\t\tglobals.window.location.reload();\n\t}\n\n\t/**\n\t * Removes route instance from app routes.\n\t * @param {Route} route\n\t * @return {boolean} True if an element was removed.\n\t */\n\tremoveRoute(route) {\n\t\treturn array.remove(this.routes, route);\n\t}\n\n\t/**\n\t * Removes a screen.\n\t * @param {!string} path Path containing the querystring part.\n\t */\n\tremoveScreen(path) {\n\t\tvar screen = this.screens[path];\n\t\tif (screen) {\n\t\t\tObject.keys(this.surfaces).forEach((surfaceId) => this.surfaces[surfaceId].remove(screen.getId()));\n\t\t\tscreen.dispose();\n\t\t\tdelete this.screens[path];\n\t\t}\n\t}\n\n\t/**\n\t * Saves scroll position from page offset into history state.\n\t */\n\tsaveHistoryCurrentPageScrollPosition_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (state && state.senna) {\n\t\t\tstate.scrollTop = globals.window.pageYOffset;\n\t\t\tstate.scrollLeft = globals.window.pageXOffset;\n\t\t\tglobals.window.history.replaceState(state, null, null);\n\t\t}\n\t}\n\n\t/**\n\t * Sets allow prevent navigate.\n\t * @param {boolean} allowPreventNavigate\n\t */\n\tsetAllowPreventNavigate(allowPreventNavigate) {\n\t\tthis.allowPreventNavigate = allowPreventNavigate;\n\t}\n\n\t/**\n\t * Sets link base path.\n\t * @param {!string} path\n\t */\n\tsetBasePath(basePath) {\n\t\tthis.basePath = basePath;\n\t}\n\n\t/**\n\t * Sets the default page title.\n\t * @param {string} defaultTitle\n\t */\n\tsetDefaultTitle(defaultTitle) {\n\t\tthis.defaultTitle = defaultTitle;\n\t}\n\n\t/**\n\t * Sets the form selector.\n\t * @param {!string} formSelector\n\t */\n\tsetFormSelector(formSelector) {\n\t\tthis.formSelector = formSelector;\n\t\tif (this.formEventHandler_) {\n\t\t\tthis.formEventHandler_.removeListener();\n\t\t}\n\t\tthis.formEventHandler_ = dom.delegate(document, 'submit', this.formSelector, this.onDocSubmitDelegate_.bind(this), this.allowPreventNavigate);\n\t}\n\n\t/**\n\t * Sets the link selector.\n\t * @param {!string} linkSelector\n\t */\n\tsetLinkSelector(linkSelector) {\n\t\tthis.linkSelector = linkSelector;\n\t\tif (this.linkEventHandler_) {\n\t\t\tthis.linkEventHandler_.removeListener();\n\t\t}\n\t\tthis.linkEventHandler_ = dom.delegate(document, 'click', this.linkSelector, this.onDocClickDelegate_.bind(this), this.allowPreventNavigate);\n\t}\n\n\t/**\n\t * Sets the loading css class.\n\t * @param {!string} loadingCssClass\n\t */\n\tsetLoadingCssClass(loadingCssClass) {\n\t\tthis.loadingCssClass = loadingCssClass;\n\t}\n\n\t/**\n\t * Sets the update scroll position value.\n\t * @param {boolean} updateScrollPosition\n\t */\n\tsetUpdateScrollPosition(updateScrollPosition) {\n\t\tthis.updateScrollPosition = updateScrollPosition;\n\t}\n\n\t/**\n\t * Cancels pending navigate with Cancel pending navigation error.\n\t * @protected\n\t */\n\tstopPendingNavigate_() {\n\t\tif (this.pendingNavigate) {\n\t\t\tthis.pendingNavigate.cancel('Cancel pending navigation');\n\t\t\tthis.pendingNavigate = null;\n\t\t}\n\t}\n\n\t/**\n\t * Sync document scroll position twice, the first one synchronous and then\n\t * one inside async.nextTick. Relevant to browsers that fires\n\t * scroll restoration asynchronously after popstate.\n\t * @protected\n\t * @return {?CancellablePromise=}\n\t */\n\tsyncScrollPositionSyncThenAsync_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar scrollTop = state.scrollTop;\n\t\tvar scrollLeft = state.scrollLeft;\n\n\t\tvar sync = () => {\n\t\t\tif (this.updateScrollPosition) {\n\t\t\t\tglobals.window.scrollTo(scrollLeft, scrollTop);\n\t\t\t}\n\t\t};\n\n\t\treturn new CancellablePromise((resolve) => sync() & async.nextTick(() => sync() & resolve()));\n\t}\n\n\t/**\n\t * Updates or replace browser history.\n\t * @param {?string} title Document title.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!object} state\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @protected\n\t */\n\tupdateHistory_(title, path, state, opt_replaceHistory) {\n\t\tif (opt_replaceHistory) {\n\t\t\tglobals.window.history.replaceState(state, title, path);\n\t\t} else {\n\t\t\tglobals.window.history.pushState(state, title, path);\n\t\t}\n\t\tglobals.document.title = title;\n\t}\n\n}\n\nexport default App;\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/globals/senna-debug.js b/build/globals/senna-debug.js index b149a41..39cabd8 100644 --- a/build/globals/senna-debug.js +++ b/build/globals/senna-debug.js @@ -1,7 +1,7 @@ /** * Senna.js - A blazing-fast Single Page Application engine * @author Liferay, Inc. - * @version v1.5.1 + * @version v1.5.2 * @link http://sennajs.com * @license BSD-3-Clause */ @@ -6502,9 +6502,17 @@ babelHelpers; App.prototype.handleNavigateError_ = function handleNavigateError_(path, nextScreen, err) { + var _this6 = this; + console.log('Navigation error for [' + nextScreen + '] (' + err + ')'); if (!utils.isCurrentBrowserPath(path)) { - this.removeScreen(path); + if (this.pendingNavigate) { + this.pendingNavigate.thenAlways(function () { + return _this6.removeScreen(path); + }, this); + } else { + this.removeScreen(path); + } } }; @@ -6750,13 +6758,13 @@ babelHelpers; App.prototype.onLoad_ = function onLoad_() { - var _this6 = this; + var _this7 = this; this.skipLoadPopstate = true; setTimeout(function () { // The timeout ensures that popstate events will be unblocked right // after the load event occured, but not in the same event-loop cycle. - _this6.skipLoadPopstate = false; + _this7.skipLoadPopstate = false; }, 0); // Try to reposition scroll to the hashed anchor when page loads. this.maybeRepositionScrollToHashedAnchor(); @@ -6831,7 +6839,7 @@ babelHelpers; App.prototype.onStartNavigate_ = function onStartNavigate_(event) { - var _this7 = this; + var _this8 = this; this.maybeDisableNativeScrollRestoration(); this.captureScrollPositionFromScrollEvent = false; @@ -6846,12 +6854,12 @@ babelHelpers; endNavigatePayload.error = reason; throw reason; }).thenAlways(function () { - if (!_this7.pendingNavigate) { - dom.removeClasses(globals.document.documentElement, _this7.loadingCssClass); - _this7.maybeRestoreNativeScrollRestoration(); - _this7.captureScrollPositionFromScrollEvent = true; + if (!_this8.pendingNavigate) { + dom.removeClasses(globals.document.documentElement, _this8.loadingCssClass); + _this8.maybeRestoreNativeScrollRestoration(); + _this8.captureScrollPositionFromScrollEvent = true; } - _this7.emit('endNavigate', endNavigatePayload); + _this8.emit('endNavigate', endNavigatePayload); }); this.pendingNavigate.path = event.path; @@ -6865,7 +6873,7 @@ babelHelpers; App.prototype.prefetch = function prefetch(path) { - var _this8 = this; + var _this9 = this; var route = this.findRoute(path); if (!route) { @@ -6877,9 +6885,9 @@ babelHelpers; var nextScreen = this.createScreenInstance(path, route); return nextScreen.load(path).then(function () { - return _this8.screens[path] = nextScreen; + return _this9.screens[path] = nextScreen; }).catch(function (reason) { - _this8.handleNavigateError_(path, nextScreen, reason); + _this9.handleNavigateError_(path, nextScreen, reason); throw reason; }); }; @@ -6956,12 +6964,12 @@ babelHelpers; App.prototype.removeScreen = function removeScreen(path) { - var _this9 = this; + var _this10 = this; var screen = this.screens[path]; if (screen) { Object.keys(this.surfaces).forEach(function (surfaceId) { - return _this9.surfaces[surfaceId].remove(screen.getId()); + return _this10.surfaces[surfaceId].remove(screen.getId()); }); screen.dispose(); delete this.screens[path]; @@ -7083,7 +7091,7 @@ babelHelpers; App.prototype.syncScrollPositionSyncThenAsync_ = function syncScrollPositionSyncThenAsync_() { - var _this10 = this; + var _this11 = this; var state = globals.window.history.state; if (!state) { @@ -7094,7 +7102,7 @@ babelHelpers; var scrollLeft = state.scrollLeft; var sync = function sync() { - if (_this10.updateScrollPosition) { + if (_this11.updateScrollPosition) { globals.window.scrollTo(scrollLeft, scrollTop); } }; diff --git a/build/globals/senna-min.js b/build/globals/senna-min.js index aec29e2..0edec20 100644 --- a/build/globals/senna-min.js +++ b/build/globals/senna-min.js @@ -1,10 +1,10 @@ /** * Senna.js - A blazing-fast Single Page Application engine * @author Liferay, Inc. - * @version v1.5.1 + * @version v1.5.2 * @link http://sennajs.com * @license BSD-3-Clause */ (function(){this.senna=this.senna||{},this.sennaNamed=this.sennaNamed||{};var t={};t["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},t.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.inherits=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},t.possibleConstructorReturn=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},t.slicedToArray=function(){function t(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(l){i=!0,o=l}finally{try{!r&&s["return"]&&s["return"]()}finally{if(i)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),function(){var e=function(){function e(){t.classCallCheck(this,e)}return e.abstractMethod=function(){throw Error("Unimplemented abstract method")},e.collectSuperClassesProperty=function(t,e){for(var n=[t[e]];t.__proto__&&!t.__proto__.isPrototypeOf(Function);)t=t.__proto__,n.push(t[e]);return n},e.getFunctionName=function(t){if(!t.name){var e=t.toString();t.name=e.substring(9,e.indexOf("("))}return t.name},e.getUid=function(t,n){if(t){var r=t[e.UID_PROPERTY];return n&&!t.hasOwnProperty(e.UID_PROPERTY)&&(r=null),r||(t[e.UID_PROPERTY]=e.uniqueIdCounter_++)}return e.uniqueIdCounter_++},e.identityFunction=function(t){return t},e.isBoolean=function(t){return"boolean"==typeof t},e.isDef=function(t){return void 0!==t},e.isDefAndNotNull=function(t){return e.isDef(t)&&!e.isNull(t)},e.isDocument=function(e){return e&&"object"===("undefined"==typeof e?"undefined":t["typeof"](e))&&9===e.nodeType},e.isElement=function(e){return e&&"object"===("undefined"==typeof e?"undefined":t["typeof"](e))&&1===e.nodeType},e.isFunction=function(t){return"function"==typeof t},e.isNull=function(t){return null===t},e.isNumber=function(t){return"number"==typeof t},e.isWindow=function(t){return null!==t&&t===t.window},e.isObject=function(e){var n="undefined"==typeof e?"undefined":t["typeof"](e);return"object"===n&&null!==e||"function"===n},e.isPromise=function(e){return e&&"object"===("undefined"==typeof e?"undefined":t["typeof"](e))&&"function"==typeof e.then},e.isString=function(t){return"string"==typeof t},e.mergeSuperClassesProperty=function(t,n,r){var i=n+"_MERGED";if(t.hasOwnProperty(i))return!1;var o=e.collectSuperClassesProperty(t,n);return r&&(o=r(o)),t[i]=o,!0},e.nullFunction=function(){},e}();e.UID_PROPERTY="core_"+(1e9*Math.random()>>>0),e.uniqueIdCounter_=1,this.senna.core=e}.call(this),function(){var e=this.senna.core,n=function(){function n(){t.classCallCheck(this,n)}return n.equal=function(t,e){if(t.length!==e.length)return!1;for(var n=0;n=0)&&n.removeAt(t,i),r},n.removeAt=function(t,e){return 1===Array.prototype.splice.call(t,e,1).length},n.slice=function(t,n,r){for(var i=[],o=e.isDef(r)?r:t.length,a=n;athis.maxListeners_&&!i.warned&&(i.warned=!0)},o.prototype.disposeInternal=function(){this.events_=[]},o.prototype.emit=function(t){var e,r=n.slice(arguments,1),i=(this.events_[t]||[]).concat();this.getShouldUseFacade()&&(e={preventDefault:function(){e.preventedDefault=!0},target:this,type:t},r.push(e));for(var o=[],a=0;a0},o.prototype.getShouldUseFacade=function(){return this.shouldUseFacade_},o.prototype.listeners=function(t){return(this.events_[t]||[]).map(function(t){return t.fn})},o.prototype.many=function(t,e,n){t=this.normalizeEvents_(t);for(var r=0;r=0;n--)this.matchesListener_(t[n],e)&&t.splice(n,1)},o.prototype.removeListener=function(){return this.off.apply(this,arguments)},o.prototype.setMaxListeners=function(t){return this.maxListeners_=t,this},o.prototype.setShouldUseFacade=function(t){return this.shouldUseFacade_=t,this},o.prototype.validateListener_=function(t){if(!e.isFunction(t))throw new TypeError("Listener must be a function")},o}(r);this.senna.EventEmitter=o}.call(this),function(){var e=this.sennaNamed.metal.array,n=this.sennaNamed.metal.Disposable,r=function(n){function r(e,i,o,a){t.classCallCheck(this,r);var s=t.possibleConstructorReturn(this,n.call(this));return s.blacklist_=o||{},s.originEmitter_=e,s.pendingEvents_=[],s.proxiedEvents_={},s.targetEmitter_=i,s.whitelist_=a,s.startProxy_(),s}return t.inherits(r,n),r.prototype.addListener_=function(t,e){return this.originEmitter_.on(t,e)},r.prototype.addListenerForEvent_=function(t){return this.addListener_(t,this.emitOnTarget_.bind(this,t))},r.prototype.disposeInternal=function(){this.removeListeners_(),this.proxiedEvents_=null,this.originEmitter_=null,this.targetEmitter_=null},r.prototype.emitOnTarget_=function(t){var n=[t].concat(e.slice(arguments,1));this.targetEmitter_.emit.apply(this.targetEmitter_,n)},r.prototype.proxyEvent=function(t){this.shouldProxyEvent_(t)&&this.tryToAddListener_(t)},r.prototype.removeListeners_=function(){for(var t=Object.keys(this.proxiedEvents_),e=0;e"+t,e.removeChild(e.firstChild);for(var n=document.createDocumentFragment();e.firstChild;)n.appendChild(e.firstChild);return n},l.contains=function(t,n){return e.isDocument(t)?t.documentElement.contains(n):t.contains(n)},l.delegate=function(t,n,r,o,a){var s=l.customEvents[n];return s&&s.delegate&&(n=s.originalEvent,o=s.handler.bind(s,o)),a&&(o=o.bind(),o.defaultListener_=!0),l.attachDelegateEvent_(t,n),e.isString(r)?l.addSelectorListener_(t,n,r,o):l.addElementListener_(r,n,o),new i(e.isString(r)?t:r,n,o,e.isString(r)?r:null)},l.enterDocument=function(t){t&&l.append(document.body,t)},l.exitDocument=function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},l.handleDelegateEvent_=function(t){l.normalizeDelegateEvent_(t);for(var n=e.isDef(t[a])?t[a]:t.target,r=!0,i=t.currentTarget,o=t.currentTarget.parentNode,s=[];n&&n!==o&&!t.stopped;)t.delegateTarget=n,r&=l.triggerMatchedListeners_(i,n,t,s),n=n.parentNode;for(var c=0;c=0},l.isEmpty=function(t){return 0===t.childNodes.length},l.match=function(t,e){if(!t||1!==t.nodeType)return!1;var n=Element.prototype,r=n.matches||n.webkitMatchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector;return r?r.call(t,e):l.matchFallback_(t,e)},l.matchFallback_=function(t,e){for(var n=document.querySelectorAll(e,t.parentNode),r=0;r0?this.unhandledRejectionId_=0:0===a.UNHANDLED_REJECTION_DELAY&&(this.hadUnhandledRejection_=!1);try{var n=this;t.call(e,function(t){n.resolve_(a.State_.FULFILLED,t)},function(t){n.resolve_(a.State_.REJECTED,t)})}catch(r){this.resolve_(a.State_.REJECTED,r)}};o.UNHANDLED_REJECTION_DELAY=0,o.State_={PENDING:0,BLOCKED:1,FULFILLED:2,REJECTED:3},o.CallbackEntry_=null,o.resolve=function(t){return new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){t.length||e(void 0);for(var r,i=0;r=t[i];i++)r.then(e,n)})},o.all=function(t){return new o(function(e,n){var r=t.length,o=[];if(!r)return void e(o);for(var a,s=function(t,n){r--,o[t]=n,0===r&&e(o)},l=function(t){n(t)},c=0;a=t[c];c++)a.then(i(s,c),l)})},o.firstFulfilled=function(t){return new o(function(e,n){var r=t.length,o=[];if(!r)return void e(void 0);for(var a,s=function(t){e(t)},l=function(t,e){r--,o[t]=e,0===r&&n(o)},c=0;a=t[c];c++)a.then(s,i(l,c))})},o.prototype.then=function(t,n,r){return this.addChildPromise_(e.isFunction(t)?t:null,e.isFunction(n)?n:null,r)},r.addImplementation(o),o.prototype.thenAlways=function(t,e){var n=function(){try{t.call(e)}catch(n){o.handleRejection_.call(null,n)}};return this.addCallbackEntry_({child:null,onRejected:n,onFulfilled:n}),this},o.prototype.thenCatch=function(t,e){return this.addChildPromise_(null,t,e)},o.prototype["catch"]=o.prototype.thenCatch,o.prototype.cancel=function(t){this.state_===o.State_.PENDING&&n.run(function(){var e=new o.CancellationError(t);e.IS_CANCELLATION_ERROR=!0,this.cancelInternal_(e)},this)},o.prototype.cancelInternal_=function(t){this.state_===o.State_.PENDING&&(this.parent_?this.parent_.cancelChild_(this,t):this.resolve_(o.State_.REJECTED,t))},o.prototype.cancelChild_=function(t,e){if(this.callbackEntries_){for(var n,r=0,i=-1,a=0;n=this.callbackEntries_[a];a++){var s=n.child;if(s&&(r++,s===t&&(i=a),i>=0&&r>1))break}if(i>=0)if(this.state_===o.State_.PENDING&&1===r)this.cancelInternal_(e);else{var l=this.callbackEntries_.splice(i,1)[0];this.executeCallback_(l,o.State_.REJECTED,e)}}},o.prototype.addCallbackEntry_=function(t){this.callbackEntries_&&this.callbackEntries_.length||this.state_!==o.State_.FULFILLED&&this.state_!==o.State_.REJECTED||this.scheduleCallbacks_(),this.callbackEntries_||(this.callbackEntries_=[]),this.callbackEntries_.push(t)},o.prototype.addChildPromise_=function(t,n,r){var i={child:null,onFulfilled:null,onRejected:null};return i.child=new o(function(o,a){i.onFulfilled=t?function(e){try{var n=t.call(r,e);o(n)}catch(i){a(i)}}:o,i.onRejected=n?function(t){try{var i=n.call(r,t);!e.isDef(i)&&t.IS_CANCELLATION_ERROR?a(t):o(i)}catch(s){a(s)}}:a}),i.child.parent_=this,this.addCallbackEntry_(i),i.child},o.prototype.unblockAndFulfill_=function(t){if(this.state_!==o.State_.BLOCKED)throw new Error("CancellablePromise is not blocked.");this.state_=o.State_.PENDING,this.resolve_(o.State_.FULFILLED,t)},o.prototype.unblockAndReject_=function(t){if(this.state_!==o.State_.BLOCKED)throw new Error("CancellablePromise is not blocked.");this.state_=o.State_.PENDING,this.resolve_(o.State_.REJECTED,t)},o.prototype.resolve_=function(t,n){if(this.state_===o.State_.PENDING){if(this===n)t=o.State_.REJECTED,n=new TypeError("CancellablePromise cannot resolve to itself");else{if(r.isImplementedBy(n))return n=n,this.state_=o.State_.BLOCKED,void n.then(this.unblockAndFulfill_,this.unblockAndReject_,this);if(e.isObject(n))try{var i=n.then;if(e.isFunction(i))return void this.tryThen_(n,i)}catch(a){t=o.State_.REJECTED,n=a}}this.result_=n,this.state_=t,this.scheduleCallbacks_(),t!==o.State_.REJECTED||n.IS_CANCELLATION_ERROR||o.addUnhandledRejection_(this,n)}},o.prototype.tryThen_=function(t,e){this.state_=o.State_.BLOCKED;var n=this,r=!1,i=function(t){r||(r=!0,n.unblockAndFulfill_(t))},a=function(t){r||(r=!0,n.unblockAndReject_(t))};try{e.call(t,i,a)}catch(s){a(s)}},o.prototype.scheduleCallbacks_=function(){this.executing_||(this.executing_=!0,n.run(this.executeCallbacks_,this))},o.prototype.executeCallbacks_=function(){for(;this.callbackEntries_&&this.callbackEntries_.length;){var t=this.callbackEntries_;this.callbackEntries_=[];for(var e=0;e0)for(t=this;t&&t.unhandledRejectionId_;t=t.parent_)clearTimeout(t.unhandledRejectionId_),t.unhandledRejectionId_=0;else if(0===o.UNHANDLED_REJECTION_DELAY)for(t=this;t&&t.hadUnhandledRejection_;t=t.parent_)t.hadUnhandledRejection_=!1},o.addUnhandledRejection_=function(t,e){o.UNHANDLED_REJECTION_DELAY>0?t.unhandledRejectionId_=setTimeout(function(){o.handleRejection_.call(null,e)},o.UNHANDLED_REJECTION_DELAY):0===o.UNHANDLED_REJECTION_DELAY&&(t.hadUnhandledRejection_=!0, -n.run(function(){t.hadUnhandledRejection_&&o.handleRejection_.call(null,e)}))},o.handleRejection_=n.throwException,o.setUnhandledRejectionHandler=function(t){o.handleRejection_=t},o.CancellationError=function(e){function n(r){t.classCallCheck(this,n);var i=t.possibleConstructorReturn(this,e.call(this,r));return r&&(i.message=r),i}return t.inherits(n,e),n}(Error),o.CancellationError.prototype.name="cancel",this.sennaNamed.Promise=this.sennaNamed.Promise||{},this.sennaNamed.Promise.CancellablePromise=o,this.senna.Promise=o}.call(this),function(){var t={document:document,window:window};this.senna.globals=t}.call(this),function(){function t(t){var e=document.createElement("a");return e.href=t,{hash:e.hash,hostname:e.hostname,password:e.password,pathname:"/"===e.pathname[0]?e.pathname:"/"+e.pathname,port:e.port,protocol:e.protocol,search:e.search,username:e.username}}this.senna.parseFromAnchor=t}.call(this),function(){function t(t){return e.isFunction(URL)&&URL.length?new URL(t):n(t)}var e=this.sennaNamed.metal.core,n=this.senna.parseFromAnchor;this.senna.parse=t}.call(this),function(){var e=this.sennaNamed.metal.Disposable,n=Object.create,r=function(e){function r(){t.classCallCheck(this,r);var i=t.possibleConstructorReturn(this,e.call(this));return i.keys=n(null),i.values=n(null),i}return t.inherits(r,e),r.prototype.add=function(t,e){return this.keys[t.toLowerCase()]=t,this.values[t.toLowerCase()]=this.values[t.toLowerCase()]||[],this.values[t.toLowerCase()].push(e),this},r.prototype.clear=function(){return this.keys=n(null),this.values=n(null),this},r.prototype.contains=function(t){return t.toLowerCase()in this.values},r.prototype.disposeInternal=function(){this.values=null},r.prototype.get=function(t){var e=this.values[t.toLowerCase()];if(e)return e[0]},r.prototype.getAll=function(t){return this.values[t.toLowerCase()]},r.prototype.isEmpty=function(){return 0===this.size()},r.prototype.names=function(){var t=this;return Object.keys(this.values).map(function(e){return t.keys[e]})},r.prototype.remove=function(t){return delete this.keys[t.toLowerCase()],delete this.values[t.toLowerCase()],this},r.prototype.set=function(t,e){return this.keys[t.toLowerCase()]=t,this.values[t.toLowerCase()]=[e],this},r.prototype.size=function(){return this.names().length},r.prototype.toString=function(){return JSON.stringify(this.values)},r}(e);this.senna.MultiMap=r}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.metal.string,r=this.senna.parse,i=this.senna.MultiMap,o=r,a=function(){function r(){var e=arguments.length<=0||void 0===arguments[0]?"":arguments[0];t.classCallCheck(this,r),this.url=r.parse(this.maybeAddProtocolAndHostname_(e))}return r.prototype.addParametersFromMultiMap=function(t){var e=this;return t.names().forEach(function(n){t.getAll(n).forEach(function(t){e.addParameterValue(n,t)})}),this},r.prototype.addParameterValue=function(t,n){return this.ensureQueryInitialized_(),e.isDef(n)&&(n=String(n)),this.query.add(t,n),this},r.prototype.addParameterValues=function(t,e){var n=this;return e.forEach(function(e){return n.addParameterValue(t,e)}),this},r.prototype.ensureQueryInitialized_=function(){var n=this;if(!this.query){this.query=new i;var o=this.url.search;o&&o.substring(1).split("&").forEach(function(i){var o=i.split("="),a=t.slicedToArray(o,2),s=a[0],l=a[1];e.isDef(l)&&(l=r.urlDecode(l)),n.addParameterValue(s,l)})}},r.prototype.getHash=function(){return this.url.hash||""},r.prototype.getHost=function(){var t=this.getHostname();if(t){var e=this.getPort();e&&"80"!==e&&(t+=":"+e)}return t},r.prototype.getHostname=function(){var t=this.url.hostname;return t===r.HOSTNAME_PLACEHOLDER?"":t},r.prototype.getOrigin=function(){var t=this.getHost();return t?this.getProtocol()+"//"+t:""},r.prototype.getParameterValue=function(t){return this.ensureQueryInitialized_(),this.query.get(t)},r.prototype.getParameterValues=function(t){return this.ensureQueryInitialized_(),this.query.getAll(t)},r.prototype.getParameterNames=function(){return this.ensureQueryInitialized_(),this.query.names()},r.getParseFn=function(){return o},r.prototype.getPathname=function(){return this.url.pathname},r.prototype.getPort=function(){return this.url.port},r.prototype.getProtocol=function(){return this.url.protocol},r.prototype.getSearch=function(){var t=this,n="",r="";return this.getParameterNames().forEach(function(n){t.getParameterValues(n).forEach(function(t){r+=n,e.isDef(t)&&(r+="="+encodeURIComponent(t)),r+="&"})}),r=r.slice(0,-1),r&&(n+="?"+r),n},r.prototype.hasParameter=function(t){return this.ensureQueryInitialized_(),this.query.contains(t)},r.prototype.makeUnique=function(){return this.setParameterValue(r.RANDOM_PARAM,n.getRandomString()),this},r.prototype.maybeAddProtocolAndHostname_=function(t){var e=t;if(t.indexOf("://")===-1&&0!==t.indexOf("javascript:"))switch(e=r.DEFAULT_PROTOCOL,"/"===t[0]&&"/"===t[1]||(e+="//"),t.charAt(0)){case".":case"?":case"#":e+=r.HOSTNAME_PLACEHOLDER,e+="/",e+=t;break;case"":case"/":"/"!==t[1]&&(e+=r.HOSTNAME_PLACEHOLDER),e+=t;break;default:e+=t}return e},r.normalizeObject=function(t){var e=t.pathname?t.pathname.length:0;return e>1&&"/"===t.pathname[e-1]&&(t.pathname=t.pathname.substr(0,e-1)),t},r.parse=function(t){return r.normalizeObject(o(t))},r.prototype.removeParameter=function(t){return this.ensureQueryInitialized_(),this.query.remove(t),this},r.prototype.removeUnique=function(){return this.removeParameter(r.RANDOM_PARAM),this},r.prototype.setHash=function(t){return this.url.hash=t,this},r.prototype.setHostname=function(t){return this.url.hostname=t,this},r.prototype.setParameterValue=function(t,e){return this.removeParameter(t),this.addParameterValue(t,e),this},r.prototype.setParameterValues=function(t,e){var n=this;return this.removeParameter(t),e.forEach(function(e){return n.addParameterValue(t,e)}),this},r.prototype.setPathname=function(t){return this.url.pathname=t,this},r.prototype.setPort=function(t){return this.url.port=t,this},r.setParseFn=function(t){o=t},r.prototype.setProtocol=function(t){return this.url.protocol=t,":"!==this.url.protocol[this.url.protocol.length-1]&&(this.url.protocol+=":"),this},r.prototype.toString=function(){var t="",e=this.getHost();return e&&(t+=this.getProtocol()+"//"),t+=e+this.getPathname()+this.getSearch()+this.getHash()},r.joinPaths=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r-1},n}();this.senna.Route=n}.call(this),function(){var e=this.sennaNamed.metal.Disposable,n=function(e){function n(){t.classCallCheck(this,n);var r=t.possibleConstructorReturn(this,e.call(this));return r.cache=null,r.cacheable=!1,r}return t.inherits(n,e),n.prototype.addCache=function(t){return this.cacheable&&(this.cache=t),this},n.prototype.clearCache=function(){return this.cache=null,this},n.prototype.disposeInternal=function(){this.clearCache()},n.prototype.getCache=function(){return this.cache},n.prototype.isCacheable=function(){return this.cacheable},n.prototype.setCacheable=function(t){t||this.clearCache(),this.cacheable=t},n}(e);this.senna.Cacheable=n}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.dom.globalEval,r=this.senna.Cacheable,i=this.senna.Promise,o=function(r){function o(){t.classCallCheck(this,o);var n=t.possibleConstructorReturn(this,r.call(this));return n.id=n.makeId_(e.getUid()),n.title=null,n}return t.inherits(o,r),o.prototype.activate=function(){},o.prototype.beforeDeactivate=function(){},o.prototype.beforeUpdateHistoryPath=function(t){return t},o.prototype.beforeUpdateHistoryState=function(t){return t},o.prototype.deactivate=function(){},o.prototype.disposeInternal=function(){r.prototype.disposeInternal.call(this)},o.prototype.evaluateScripts=function(t){return Object.keys(t).forEach(function(e){t[e].activeChild&&n.runScriptsInElement(t[e].activeChild)}),i.resolve()},o.prototype.evaluateStyles=function(){return i.resolve()},o.prototype.flip=function(t){var e=this,n=[];return Object.keys(t).forEach(function(r){var i=t[r],o=i.show(e.id);n.push(o)}),i.all(n)},o.prototype.getId=function(){return this.id},o.prototype.getSurfaceContent=function(){},o.prototype.getTitle=function(){return this.title},o.prototype.load=function(){return i.resolve()},o.prototype.makeId_=function(t){return"screen_"+t},o.prototype.setId=function(t){this.id=t},o.prototype.setTitle=function(t){this.title=t},o.prototype.toString=function(){return this.id},o}(r);o.isImplementedBy=function(t){return t instanceof o},this.senna.Screen=o}.call(this),function(){var e=this.senna.globals,n=this.sennaNamed.metal.core,r=this.sennaNamed.metal.Disposable,i=this.senna.dom,o=this.senna.Promise,a=function(r){function a(e){t.classCallCheck(this,a);var n=t.possibleConstructorReturn(this,r.call(this));if(!e)throw new Error("Surface element id not specified. A surface element requires a valid id.");return n.activeChild=null,n.defaultChild=null,n.element=null,n.id=e,n.transitionFn=null,n.defaultChild=n.getChild(a.DEFAULT),n.maybeWrapContentAsDefault_(),n.activeChild=n.defaultChild,n}return t.inherits(a,r),a.prototype.addContent=function(t,e){var r=this.defaultChild;n.isDefAndNotNull(e)&&(r=this.getChild(t),r?i.removeChildren(r):(r=this.createChild(t),this.transition(r,null)),i.append(r,e));var o=this.getElement();return o&&r&&i.append(o,r),r},a.prototype.createChild=function(t){var n=e.document.createElement("div");return n.setAttribute("id",this.makeId_(t)),n},a.prototype.getChild=function(t){return e.document.getElementById(this.makeId_(t))},a.prototype.getElement=function(){return this.element?this.element:(this.element=e.document.getElementById(this.id),this.element)},a.prototype.getId=function(){return this.id},a.prototype.getTransitionFn=function(){return this.transitionFn},a.prototype.makeId_=function(t){return this.id+"-"+t},a.prototype.maybeWrapContentAsDefault_=function(){var t=this.getElement();if(t&&!this.defaultChild){for(var n=e.document.createDocumentFragment();t.firstChild;)n.appendChild(t.firstChild);this.defaultChild=this.addContent(a.DEFAULT,n),this.transition(null,this.defaultChild)}},a.prototype.setId=function(t){this.id=t},a.prototype.setTransitionFn=function(t){this.transitionFn=t},a.prototype.show=function(t){var e=this.activeChild,n=this.getChild(t);return n||(n=this.defaultChild),this.activeChild=n,this.transition(e,n).thenAlways(function(){e&&e!==n&&i.exitDocument(e)})},a.prototype.remove=function(t){var e=this.getChild(t);e&&i.exitDocument(e)},a.prototype.toString=function(){return this.id},a.prototype.transition=function(t,e){var n=this.transitionFn||a.defaultTransition;return o.resolve(n.call(this,t,e))},a}(r);a.DEFAULT="default",a.defaultTransition=function(t,e){t&&(t.style.display="none",t.classList.remove("flipped")),e&&(e.style.display="block",e.classList.add("flipped"))},this.senna.Surface=a}.call(this),function(){var e=this.sennaNamed.metal.array,n=this.sennaNamed.metal.async,r=this.sennaNamed.metal.core,i=this.senna.debounce,o=this.senna.dom,a=this.senna.Promise,s=this.sennaNamed.events.EventEmitter,l=this.sennaNamed.events.EventHandler,c=this.senna.utils,u=this.senna.globals,h=this.senna.Route,p=this.senna.Screen,d=this.senna.Surface,f=this.senna.Uri,m=function(s){function m(){t.classCallCheck(this,m);var e=t.possibleConstructorReturn(this,s.call(this));return e.activeScreen=null,e.activePath=null,e.allowPreventNavigate=!0,e.basePath="",e.captureScrollPositionFromScrollEvent=!0,e.defaultTitle=u.document.title,e.formSelector='form[enctype="multipart/form-data"]:not([data-senna-off])',e.linkSelector="a:not([data-senna-off])",e.loadingCssClass="senna-loading",e.nativeScrollRestorationSupported="scrollRestoration"in u.window.history,e.pendingNavigate=null,e.popstateScrollLeft=0,e.popstateScrollTop=0,e.redirectPath=null,e.routes=[],e.screens={},e.skipLoadPopstate=!1,e.surfaces={},e.updateScrollPosition=!0,e.appEventHandlers_=new l,e.appEventHandlers_.add(o.on(u.window,"scroll",i(e.onScroll_.bind(e),100)),o.on(u.window,"load",e.onLoad_.bind(e)),o.on(u.window,"popstate",e.onPopstate_.bind(e))),e.on("startNavigate",e.onStartNavigate_),e.on("beforeNavigate",e.onBeforeNavigate_),e.on("beforeNavigate",e.onBeforeNavigateDefault_,!0),e.setLinkSelector(e.linkSelector),e.setFormSelector(e.formSelector),e}return t.inherits(m,s),m.prototype.addRoutes=function(t){var e=this;return Array.isArray(t)||(t=[t]),t.forEach(function(t){t instanceof h||(t=new h(t.path,t.handler)),e.routes.push(t)}),this},m.prototype.addSurfaces=function(t){var e=this;return Array.isArray(t)||(t=[t]),t.forEach(function(t){r.isString(t)&&(t=new d(t)),e.surfaces[t.getId()]=t}),this},m.prototype.canNavigate=function(t){var e=c.getUrlPath(t),n=new f(t);return!!this.isLinkSameOrigin_(n.getHostname())&&(!!this.isSameBasePath_(e)&&!!this.findRoute(e))},m.prototype.clearScreensCache=function(){var t=this;Object.keys(this.screens).forEach(function(e){e===t.activePath?t.activeScreen.clearCache():t.removeScreen(e)})},m.prototype.createScreenInstance=function(t,e){if(!this.pendingNavigate&&t===this.activePath)return this.activeScreen;var n=this.screens[t];if(!n){var r=e.getHandler();n=r===p||p.isImplementedBy(r.prototype)?new r:r(e)||new p}return n},m.prototype.disposeInternal=function(){this.activeScreen&&this.removeScreen(this.activePath),this.clearScreensCache(),this.formEventHandler_.removeListener(),this.linkEventHandler_.removeListener(),this.appEventHandlers_.removeAllListeners(),s.prototype.disposeInternal.call(this)},m.prototype.dispatch=function(){return this.navigate(c.getCurrentBrowserPath(),!0)},m.prototype.doNavigate_=function(t,e){var n=this;if(this.activeScreen&&this.activeScreen.beforeDeactivate())return this.pendingNavigate=a.reject(new a.CancellationError("Cancelled by active screen")),this.pendingNavigate;var r=this.findRoute(t);if(!r)return this.pendingNavigate=a.reject(new a.CancellationError("No route for "+t)),this.pendingNavigate;this.stopPendingNavigate_();var i=this.createScreenInstance(t,r);return i.load(t).then(function(){n.activeScreen&&n.activeScreen.deactivate(),n.prepareNavigateHistory_(t,i,e),n.prepareNavigateSurfaces_(i,n.surfaces)}).then(function(){return i.evaluateStyles(n.surfaces)}).then(function(){return i.flip(n.surfaces)}).then(function(){return i.evaluateScripts(n.surfaces)}).then(function(){return n.syncScrollPositionSyncThenAsync_()}).then(function(){return n.finalizeNavigate_(t,i)})["catch"](function(e){throw n.handleNavigateError_(t,i,e),e})},m.prototype.finalizeNavigate_=function(t,e){e.activate(),this.activeScreen&&!this.activeScreen.isCacheable()&&this.activeScreen!==e&&this.removeScreen(this.activePath),this.activePath=t,this.activeScreen=e,this.screens[t]=e,this.pendingNavigate=null,u.capturedFormElement=null},m.prototype.findRoute=function(t){if(t.lastIndexOf("#")>-1&&c.isCurrentBrowserPath(t))return null;t=c.getUrlPathWithoutHash(t),t=c.getUrlPathWithoutHash(t.substr(this.basePath.length));for(var e=0;e0},m.prototype.isLinkSameOrigin_=function(t){return t===u.window.location.hostname},m.prototype.isSameBasePath_=function(t){return 0===t.indexOf(this.basePath)},m.prototype.lockHistoryScrollPosition_=function(){var t=u.window.history.state;if(t){var e=!1,r=function i(){u.document.removeEventListener("scroll",i,!1),e||(u.window.scrollTo(t.scrollLeft,t.scrollTop),e=!0)};n.nextTick(r),u.document.addEventListener("scroll",r,!1)}},m.prototype.maybeDisableNativeScrollRestoration=function(){this.nativeScrollRestorationSupported&&(this.nativeScrollRestoration_=u.window.history.scrollRestoration,u.window.history.scrollRestoration="manual")},m.prototype.maybeNavigate_=function(t,e){if(this.canNavigate(t)){u.capturedFormElement=e.capturedFormElement;var n=!1;try{this.navigate(c.getUrlPath(t))}catch(r){n=!0}n||e.preventDefault()}},m.prototype.maybeRepositionScrollToHashedAnchor=function(){var t=u.window.location.hash;if(t){var e=u.document.getElementById(t.substring(1));e&&u.window.scrollTo(e.offsetLeft,e.offsetTop)}},m.prototype.maybeRestoreNativeScrollRestoration=function(){this.nativeScrollRestorationSupported&&this.nativeScrollRestoration_&&(u.window.history.scrollRestoration=this.nativeScrollRestoration_)},m.prototype.navigate=function(t,e){if(!c.isHtml5HistorySupported())throw new Error("HTML5 History is not supported. Senna will not intercept navigation.");return t===this.activePath&&(e=!0),this.emit("beforeNavigate",{path:t,replaceHistory:!!e}),this.pendingNavigate},m.prototype.onBeforeNavigate_=function(t){u.capturedFormElement&&(t.form=u.capturedFormElement)},m.prototype.onBeforeNavigateDefault_=function(t){this.pendingNavigate&&this.pendingNavigate.path===t.path||this.emit("startNavigate",{form:t.form,path:t.path,replaceHistory:t.replaceHistory})},m.prototype.onDocClickDelegate_=function(t){t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||t.button||this.maybeNavigate_(t.delegateTarget.href,t)},m.prototype.onDocSubmitDelegate_=function(t){var e=t.delegateTarget;"get"!==e.method&&(t.capturedFormElement=e,this.maybeNavigate_(e.action,t))},m.prototype.onLoad_=function(){var t=this;this.skipLoadPopstate=!0,setTimeout(function(){t.skipLoadPopstate=!1},0),this.maybeRepositionScrollToHashedAnchor()},m.prototype.onPopstate_=function(t){if(!this.skipLoadPopstate){var e=t.state;return e?void(e.senna&&(this.popstateScrollTop=e.scrollTop,this.popstateScrollLeft=e.scrollLeft,this.nativeScrollRestorationSupported||this.lockHistoryScrollPosition_(),this.navigate(e.path,!0))):void(u.window.location.hash?(this.redirectPath&&!c.isCurrentBrowserPath(this.redirectPath)&&this.reloadPage(),this.maybeRepositionScrollToHashedAnchor()):this.reloadPage())}},m.prototype.onScroll_=function(){this.captureScrollPositionFromScrollEvent&&this.saveHistoryCurrentPageScrollPosition_()},m.prototype.onStartNavigate_=function(t){var e=this;this.maybeDisableNativeScrollRestoration(),this.captureScrollPositionFromScrollEvent=!1,o.addClasses(u.document.documentElement,this.loadingCssClass);var n={form:t.form,path:t.path};this.pendingNavigate=this.doNavigate_(t.path,t.replaceHistory)["catch"](function(t){throw n.error=t,t}).thenAlways(function(){e.pendingNavigate||(o.removeClasses(u.document.documentElement,e.loadingCssClass),e.maybeRestoreNativeScrollRestoration(),e.captureScrollPositionFromScrollEvent=!0),e.emit("endNavigate",n)}),this.pendingNavigate.path=t.path},m.prototype.prefetch=function(t){var e=this,n=this.findRoute(t);if(!n)return a.reject(new a.CancellationError("No route for "+t));var r=this.createScreenInstance(t,n);return r.load(t).then(function(){return e.screens[t]=r})["catch"](function(n){throw e.handleNavigateError_(t,r,n),n})},m.prototype.prepareNavigateHistory_=function(t,e,n){var i=e.getTitle();r.isString(i)||(i=this.getDefaultTitle());var o=e.beforeUpdateHistoryPath(t),a={form:r.isDefAndNotNull(u.capturedFormElement),redirectPath:o,path:t,senna:!0,scrollTop:0,scrollLeft:0};n&&(a.scrollTop=this.popstateScrollTop,a.scrollLeft=this.popstateScrollLeft),this.updateHistory_(i,o,e.beforeUpdateHistoryState(a),n),this.redirectPath=o},m.prototype.prepareNavigateSurfaces_=function(t,e){Object.keys(e).forEach(function(n){var r=t.getSurfaceContent(n);e[n].addContent(t.getId(),r)})},m.prototype.reloadPage=function(){u.window.location.reload()},m.prototype.removeRoute=function(t){return e.remove(this.routes,t)},m.prototype.removeScreen=function(t){var e=this,n=this.screens[t];n&&(Object.keys(this.surfaces).forEach(function(t){return e.surfaces[t].remove(n.getId())}),n.dispose(),delete this.screens[t])},m.prototype.saveHistoryCurrentPageScrollPosition_=function(){var t=u.window.history.state;t&&t.senna&&(t.scrollTop=u.window.pageYOffset,t.scrollLeft=u.window.pageXOffset,u.window.history.replaceState(t,null,null))},m.prototype.setAllowPreventNavigate=function(t){this.allowPreventNavigate=t},m.prototype.setBasePath=function(t){this.basePath=t},m.prototype.setDefaultTitle=function(t){this.defaultTitle=t},m.prototype.setFormSelector=function(t){this.formSelector=t,this.formEventHandler_&&this.formEventHandler_.removeListener(),this.formEventHandler_=o.delegate(document,"submit",this.formSelector,this.onDocSubmitDelegate_.bind(this),this.allowPreventNavigate)},m.prototype.setLinkSelector=function(t){this.linkSelector=t,this.linkEventHandler_&&this.linkEventHandler_.removeListener(),this.linkEventHandler_=o.delegate(document,"click",this.linkSelector,this.onDocClickDelegate_.bind(this),this.allowPreventNavigate)},m.prototype.setLoadingCssClass=function(t){this.loadingCssClass=t},m.prototype.setUpdateScrollPosition=function(t){this.updateScrollPosition=t},m.prototype.stopPendingNavigate_=function(){this.pendingNavigate&&(this.pendingNavigate.cancel("Cancel pending navigation"),this.pendingNavigate=null)},m.prototype.syncScrollPositionSyncThenAsync_=function(){var t=this,e=u.window.history.state;if(e){var r=e.scrollTop,i=e.scrollLeft,o=function(){t.updateScrollPosition&&u.window.scrollTo(i,r)};return new a(function(t){return o()&n.nextTick(function(){return o()&t()})})}},m.prototype.updateHistory_=function(t,e,n,r){r?u.window.history.replaceState(n,t,e):u.window.history.pushState(n,t,e),u.document.title=t},m}(s);this.senna.App=m}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.senna.Uri,r=this.sennaNamed.Promise.CancellablePromise,i=function(){function i(){t.classCallCheck(this,i)}return i.parseResponseHeaders=function(t){var e=[];if(!t)return e;for(var n=t.split("\r\n"),r=0;r0){var o=n[r].substring(0,i),a=n[r].substring(i+2);e.push({name:o,value:a})}}return e},i.request=function o(t,i,a,s,l,c,u,h){var o=new XMLHttpRequest,p=new r(function(t,e){o.onload=function(){return o.aborted?void o.onerror():void t(o)},o.onerror=function(){var t=new Error("Request error");t.request=o,e(t)}}).thenCatch(function(t){throw o.abort(),t}).thenAlways(function(){clearTimeout(d)});if(l&&(t=new n(t).addParametersFromMultiMap(l).toString()),o.open(i,t,!u),h&&(o.withCredentials=!0),s&&s.names().forEach(function(t){o.setRequestHeader(t,s.getAll(t).join(", "))}),o.send(e.isDef(a)?a:null),e.isDefAndNotNull(c))var d=setTimeout(function(){p.cancel("Request timeout")},c);return p},i}();this.senna.Ajax=i}.call(this),function(){var e=function n(){t.classCallCheck(this,n)};e.INVALID_STATUS="Invalid status code",e.REQUEST_ERROR="Request error",e.REQUEST_TIMEOUT="Request timeout",this.senna.errors=e}.call(this),function(){var e=function(){function e(){t.classCallCheck(this,e)}return e.getNativeUserAgent=function(){var t=e.globals.window.navigator;if(t){var n=t.userAgent;if(n)return n}return""},e.matchUserAgent=function(t){return e.userAgent.indexOf(t)!==-1},e.testUserAgent=function(t){e.userAgent=t,e.isOpera=e.matchUserAgent("Opera")||e.matchUserAgent("OPR"),e.isIe=e.matchUserAgent("Trident")||e.matchUserAgent("MSIE"),e.isEdge=e.matchUserAgent("Edge"),e.isIeOrEdge=e.isIe||e.isEdge,e.isChrome=(e.matchUserAgent("Chrome")||e.matchUserAgent("CriOS"))&&!e.isOpera&&!e.isEdge,e.isSafari=e.matchUserAgent("Safari")&&!(e.isChrome||e.isOpera||e.isEdge),e.isFirefox=e.matchUserAgent("Firefox")},e}();e.globals={window:window},e.testUserAgent(e.getNativeUserAgent()),this.senna.UA=e}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.senna.Ajax,r=this.senna.MultiMap,i=this.senna.Promise,o=this.senna.errors,a=this.senna.utils,s=this.senna.globals,l=this.senna.Screen,c=this.senna.Uri,u=this.senna.UA,h=function(l){function h(){t.classCallCheck(this,h);var e=t.possibleConstructorReturn(this,l.call(this));return e.cacheable=!0,e.httpHeaders={"X-PJAX":"true","X-Requested-With":"XMLHttpRequest"},e.httpMethod=h.GET,e.request=null,e.timeout=3e4,e}return t.inherits(h,l),h.prototype.assertValidResponseStatusCode=function(t){if(!this.isValidResponseStatusCode(t)){var e=new Error(o.INVALID_STATUS);throw e.invalidStatus=!0,e}},h.prototype.beforeUpdateHistoryPath=function(t){var e=this.getRequestPath();return e&&e!==t?e:t},h.prototype.beforeUpdateHistoryState=function(t){return t.senna&&t.form&&t.redirectPath===t.path?null:t},h.prototype.formatLoadPath=function(t){var e=new c(t);return e.setHostname(s.window.location.hostname),e.setProtocol(s.window.location.protocol),s.window.location.port&&e.setPort(s.window.location.port),u.isIeOrEdge&&this.httpMethod===h.GET?e.makeUnique().toString():e.toString()},h.prototype.getHttpHeaders=function(){return this.httpHeaders},h.prototype.getHttpMethod=function(){return this.httpMethod},h.prototype.getRequestPath=function(){var t=this.getRequest();if(t){var e=t.requestPath,n=this.maybeExtractResponseUrlFromRequest(t);return n&&(e=n),u.isIeOrEdge&&this.httpMethod===h.GET&&(e=new c(e).removeUnique().toString()),a.getUrlPath(e)}return null},h.prototype.getRequest=function(){return this.request},h.prototype.getTimeout=function(){return this.timeout},h.prototype.isValidResponseStatusCode=function(t){return t>=200&&t<=399},h.prototype.load=function(t){var a=this,l=this.getCache();if(e.isDefAndNotNull(l))return i.resolve(l);var c=null,p=this.httpMethod,d=new r;Object.keys(this.httpHeaders).forEach(function(t){return d.add(t,a.httpHeaders[t])}),s.capturedFormElement&&(c=new FormData(s.capturedFormElement),p=h.POST,u.isIeOrEdge&&d.add("If-None-Match",'"0"'));var f=this.formatLoadPath(t);return n.request(f,p,c,d,null,this.timeout).then(function(t){return a.setRequest(t),a.assertValidResponseStatusCode(t.status),p===h.GET&&a.isCacheable()&&a.addCache(t.responseText),t.requestPath=f,t.responseText})["catch"](function(t){switch(t.message){case o.REQUEST_TIMEOUT:t.timeout=!0;break;case o.REQUEST_ERROR:t.requestError=!0}throw t})},h.prototype.maybeExtractResponseUrlFromRequest=function(t){var e=t.responseURL;return e?e:t.getResponseHeader(h.X_REQUEST_URL_HEADER)},h.prototype.setHttpHeaders=function(t){this.httpHeaders=t},h.prototype.setHttpMethod=function(t){this.httpMethod=t.toLowerCase()},h.prototype.setRequest=function(t){this.request=t},h.prototype.setTimeout=function(t){this.timeout=t},h}(l);h.GET="get",h.POST="post",h.X_REQUEST_URL_HEADER="X-Request-URL",this.senna.RequestScreen=h}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.dom.dom,r=this.sennaNamed.dom.globalEval,i=this.sennaNamed.dom.globalEvalStyles,o=this.senna.Promise,a=this.senna.globals,s=this.senna.RequestScreen,l=this.senna.Surface,c=this.senna.UA,u=this.senna.Uri,h=this.senna.utils,p=function(s){function p(){t.classCallCheck(this,p);var e=t.possibleConstructorReturn(this,s.call(this));return e.titleSelector="title",e}return t.inherits(p,s),p.prototype.activate=function(){s.prototype.activate.call(this),this.releaseVirtualDocument(),this.pendingStyles=null},p.prototype.allocateVirtualDocumentForContent=function(t){this.virtualDocument||(this.virtualDocument=a.document.createElement("html")),this.copyNodeAttributesFromContent_(t,this.virtualDocument),this.virtualDocument.innerHTML=t},p.prototype.appendStyleIntoDocument_=function(t){var e=n.match(t,p.selectors.stylesTemporary);if(e&&this.pendingStyles.push(t),t.id){var r=a.document.getElementById(t.id);if(r)return void r.parentNode.insertBefore(t,r.nextSibling)}a.document.head.appendChild(t)},p.prototype.assertSameBodyIdInVirtualDocument=function(){var t=this.virtualDocument.querySelector("body");a.document.body.id||(a.document.body.id="senna_surface_"+e.getUid()),t&&(t.id=a.document.body.id)},p.prototype.copyNodeAttributesFromContent_=function(t,e){t=t.replace(/[<]\s*html/gi,"/gi,"/senna>"),e.innerHTML=t;var n=e.querySelector("senna");n&&(h.clearNodeAttributes(e),h.copyNodeAttributes(n,e))},p.prototype.disposeInternal=function(){this.disposePendingStyles(),s.prototype.disposeInternal.call(this)},p.prototype.disposePendingStyles=function(){this.pendingStyles&&this.pendingStyles.forEach(function(t){return n.exitDocument(t)})},p.prototype.evaluateScripts=function(t){var e=this,n=this.evaluateTrackedResources_(r.runScriptsInElement,p.selectors.scripts,p.selectors.scriptsTemporary,p.selectors.scriptsPermanent);return n.then(function(){return s.prototype.evaluateScripts.call(e,t)})},p.prototype.evaluateStyles=function(t){var e=this;this.pendingStyles=[];var n=this.evaluateTrackedResources_(i.runStylesInElement,p.selectors.styles,p.selectors.stylesTemporary,p.selectors.stylesPermanent,this.appendStyleIntoDocument_.bind(this));return n.then(function(){return s.prototype.evaluateStyles.call(e,t)})},p.prototype.evaluateTrackedResources_=function(t,e,r,i,a){var s=this,l=this.virtualQuerySelectorAll_(e),c=this.querySelectorAll_(r),u=this.querySelectorAll_(i);u.forEach(function(t){var e=s.getResourceKey_(t);e&&(p.permanentResourcesInDoc[e]=!0)});var h=n.buildFragment();return l.forEach(function(t){var e=s.getResourceKey_(t);p.permanentResourcesInDoc[e]||h.appendChild(t),e&&n.match(t,i)&&(p.permanentResourcesInDoc[e]=!0)}),new o(function(e){t(h,function(){c.forEach(function(t){return n.exitDocument(t)}),e()},a)})},p.prototype.flip=function(t){var e=this;return s.prototype.flip.call(this,t).then(function(){h.clearNodeAttributes(document.documentElement),h.copyNodeAttributes(e.virtualDocument,document.documentElement)})},p.prototype.getResourceKey_=function(t){return t.id||t.href||t.src||""},p.prototype.getSurfaceContent=function(t){var e=this.virtualDocument.querySelector("#"+t);if(e){var n=e.querySelector("#"+t+"-"+l.DEFAULT);return n?n.innerHTML:e.innerHTML}},p.prototype.getTitleSelector=function(){return this.titleSelector},p.prototype.load=function(t){var e=this; -return s.prototype.load.call(this,t).then(function(t){return e.allocateVirtualDocumentForContent(t),e.resolveTitleFromVirtualDocument(),e.assertSameBodyIdInVirtualDocument(),c.isIe&&e.makeTemporaryStylesHrefsUnique_(),t})},p.prototype.makeTemporaryStylesHrefsUnique_=function(){var t=this,e=this.virtualQuerySelectorAll_(p.selectors.stylesTemporary);e.forEach(function(e){return t.replaceStyleAndMakeUnique_(e)})},p.prototype.replaceStyleAndMakeUnique_=function(t){if(t.href){var e=a.document.createElement(t.tagName);t.href=new u(t.href).makeUnique().toString(),h.copyNodeAttributes(t,e),t.parentNode.replaceChild(e,t),t.disabled=!0}},p.prototype.virtualQuerySelectorAll_=function(t){return Array.prototype.slice.call(this.virtualDocument.querySelectorAll(t))},p.prototype.querySelectorAll_=function(t){return Array.prototype.slice.call(a.document.querySelectorAll(t))},p.prototype.releaseVirtualDocument=function(){this.virtualDocument=null},p.prototype.resolveTitleFromVirtualDocument=function(){var t=this.virtualDocument.querySelector(this.titleSelector);t&&this.setTitle(t.innerHTML.trim())},p.prototype.setTitleSelector=function(t){this.titleSelector=t},p}(s);p.selectors={scripts:"script[data-senna-track]",scriptsPermanent:'script[data-senna-track="permanent"]',scriptsTemporary:'script[data-senna-track="temporary"]',styles:"style[data-senna-track],link[data-senna-track]",stylesPermanent:'style[data-senna-track="permanent"],link[data-senna-track="permanent"]',stylesTemporary:'style[data-senna-track="temporary"],link[data-senna-track="temporary"]'},p.permanentResourcesInDoc={},this.senna.HtmlScreen=p}.call(this),function(){var t=this.senna.App,e=this.senna.HtmlScreen,n=this.senna.RequestScreen,r=this.senna.Route,i=this.senna.Screen;this.senna.senna=t,this.sennaNamed.senna=this.sennaNamed.senna||{},this.sennaNamed.senna.App=t,this.sennaNamed.senna.HtmlScreen=e,this.sennaNamed.senna.Route=r,this.sennaNamed.senna.RequestScreen=n,this.sennaNamed.senna.Screen=i}.call(this),function(){this.senna.dataAttributes={basePath:"data-senna-base-path",linkSelector:"data-senna-link-selector",loadingCssClass:"data-senna-loading-css-class",senna:"data-senna",dispatch:"data-senna-dispatch",surface:"data-senna-surface",updateScrollPosition:"data-senna-update-scroll-position"}}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.metal.object,r=this.sennaNamed.metal.Disposable,i=this.senna.dataAttributes,o=this.senna.globals,a=this.senna.App,s=this.senna.HtmlScreen,l=this.senna.Route,c=function(r){function c(){t.classCallCheck(this,c);var e=t.possibleConstructorReturn(this,r.call(this));return e.app=null,e.baseElement=null,e}return t.inherits(c,r),c.prototype.handle=function(){if(!e.isElement(this.baseElement))throw new Error("Senna data attribute handler base element not set or invalid, try setting a valid element that contains a `data-senna` attribute.");if(this.baseElement.hasAttribute(i.senna)){if(this.app)throw new Error("Senna app was already initialized.");this.app=new a,this.maybeAddRoutes_(),this.maybeAddSurfaces_(),this.maybeSetBasePath_(),this.maybeSetLinkSelector_(),this.maybeSetLoadingCssClass_(),this.maybeSetUpdateScrollPosition_(),this.maybeDispatch_()}},c.prototype.disposeInternal=function(){this.app&&this.app.dispose()},c.prototype.getApp=function(){return this.app},c.prototype.getBaseElement=function(){return this.baseElement},c.prototype.maybeAddRoutes_=function(){var t=this,e='link[rel="senna-route"]';this.querySelectorAllAsArray_(e).forEach(function(e){return t.maybeParseLinkRoute_(e)}),this.app.hasRoutes()||this.app.addRoutes(new l(/.*/,s))},c.prototype.maybeAddSurfaces_=function(){var t=this,e="["+i.surface+"]";this.querySelectorAllAsArray_(e).forEach(function(e){t.updateElementIdIfSpecialSurface_(e),t.app.addSurfaces(e.id)})},c.prototype.maybeDispatch_=function(){this.baseElement.hasAttribute(i.dispatch)&&this.app.dispatch()},c.prototype.maybeParseLinkRoute_=function(t){var e=new l(this.maybeParseLinkRoutePath_(t),this.maybeParseLinkRouteHandler_(t));this.app.addRoutes(e)},c.prototype.maybeParseLinkRouteHandler_=function(t){var r=t.getAttribute("type");return e.isDefAndNotNull(r)&&(r=n.getObjectByName(r)),r},c.prototype.maybeParseLinkRoutePath_=function(t){var n=t.getAttribute("href");return e.isDefAndNotNull(n)&&0===n.indexOf("regex:")&&(n=new RegExp(n.substring(6))),n},c.prototype.maybeSetBasePath_=function(){var t=this.baseElement.getAttribute(i.basePath);e.isDefAndNotNull(t)&&this.app.setBasePath(t)},c.prototype.maybeSetLinkSelector_=function(){var t=this.baseElement.getAttribute(i.linkSelector);e.isDefAndNotNull(t)&&this.app.setLinkSelector(t)},c.prototype.maybeSetLoadingCssClass_=function(){var t=this.baseElement.getAttribute(i.loadingCssClass);e.isDefAndNotNull(t)&&this.app.setLoadingCssClass(t)},c.prototype.maybeSetUpdateScrollPosition_=function(){var t=this.baseElement.getAttribute(i.updateScrollPosition);e.isDefAndNotNull(t)&&("false"===t?this.app.setUpdateScrollPosition(!1):this.app.setUpdateScrollPosition(!0))},c.prototype.querySelectorAllAsArray_=function(t){return Array.prototype.slice.call(o.document.querySelectorAll(t))},c.prototype.updateElementIdIfSpecialSurface_=function(t){t.id||t!==o.document.body||(t.id="senna_surface_"+e.getUid())},c.prototype.setBaseElement=function(t){this.baseElement=t},c}(r);this.senna.AppDataAttributeHandler=c}.call(this),function(){var t=this.senna.globals,e=this.senna.AppDataAttributeHandler,n=new e;t.document.addEventListener("DOMContentLoaded",function(){n.setBaseElement(t.document.body),n.handle()}),this.senna.dataAttributeHandler=n}.call(this)}).call(this); \ No newline at end of file +n.run(function(){t.hadUnhandledRejection_&&o.handleRejection_.call(null,e)}))},o.handleRejection_=n.throwException,o.setUnhandledRejectionHandler=function(t){o.handleRejection_=t},o.CancellationError=function(e){function n(r){t.classCallCheck(this,n);var i=t.possibleConstructorReturn(this,e.call(this,r));return r&&(i.message=r),i}return t.inherits(n,e),n}(Error),o.CancellationError.prototype.name="cancel",this.sennaNamed.Promise=this.sennaNamed.Promise||{},this.sennaNamed.Promise.CancellablePromise=o,this.senna.Promise=o}.call(this),function(){var t={document:document,window:window};this.senna.globals=t}.call(this),function(){function t(t){var e=document.createElement("a");return e.href=t,{hash:e.hash,hostname:e.hostname,password:e.password,pathname:"/"===e.pathname[0]?e.pathname:"/"+e.pathname,port:e.port,protocol:e.protocol,search:e.search,username:e.username}}this.senna.parseFromAnchor=t}.call(this),function(){function t(t){return e.isFunction(URL)&&URL.length?new URL(t):n(t)}var e=this.sennaNamed.metal.core,n=this.senna.parseFromAnchor;this.senna.parse=t}.call(this),function(){var e=this.sennaNamed.metal.Disposable,n=Object.create,r=function(e){function r(){t.classCallCheck(this,r);var i=t.possibleConstructorReturn(this,e.call(this));return i.keys=n(null),i.values=n(null),i}return t.inherits(r,e),r.prototype.add=function(t,e){return this.keys[t.toLowerCase()]=t,this.values[t.toLowerCase()]=this.values[t.toLowerCase()]||[],this.values[t.toLowerCase()].push(e),this},r.prototype.clear=function(){return this.keys=n(null),this.values=n(null),this},r.prototype.contains=function(t){return t.toLowerCase()in this.values},r.prototype.disposeInternal=function(){this.values=null},r.prototype.get=function(t){var e=this.values[t.toLowerCase()];if(e)return e[0]},r.prototype.getAll=function(t){return this.values[t.toLowerCase()]},r.prototype.isEmpty=function(){return 0===this.size()},r.prototype.names=function(){var t=this;return Object.keys(this.values).map(function(e){return t.keys[e]})},r.prototype.remove=function(t){return delete this.keys[t.toLowerCase()],delete this.values[t.toLowerCase()],this},r.prototype.set=function(t,e){return this.keys[t.toLowerCase()]=t,this.values[t.toLowerCase()]=[e],this},r.prototype.size=function(){return this.names().length},r.prototype.toString=function(){return JSON.stringify(this.values)},r}(e);this.senna.MultiMap=r}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.metal.string,r=this.senna.parse,i=this.senna.MultiMap,o=r,a=function(){function r(){var e=arguments.length<=0||void 0===arguments[0]?"":arguments[0];t.classCallCheck(this,r),this.url=r.parse(this.maybeAddProtocolAndHostname_(e))}return r.prototype.addParametersFromMultiMap=function(t){var e=this;return t.names().forEach(function(n){t.getAll(n).forEach(function(t){e.addParameterValue(n,t)})}),this},r.prototype.addParameterValue=function(t,n){return this.ensureQueryInitialized_(),e.isDef(n)&&(n=String(n)),this.query.add(t,n),this},r.prototype.addParameterValues=function(t,e){var n=this;return e.forEach(function(e){return n.addParameterValue(t,e)}),this},r.prototype.ensureQueryInitialized_=function(){var n=this;if(!this.query){this.query=new i;var o=this.url.search;o&&o.substring(1).split("&").forEach(function(i){var o=i.split("="),a=t.slicedToArray(o,2),s=a[0],l=a[1];e.isDef(l)&&(l=r.urlDecode(l)),n.addParameterValue(s,l)})}},r.prototype.getHash=function(){return this.url.hash||""},r.prototype.getHost=function(){var t=this.getHostname();if(t){var e=this.getPort();e&&"80"!==e&&(t+=":"+e)}return t},r.prototype.getHostname=function(){var t=this.url.hostname;return t===r.HOSTNAME_PLACEHOLDER?"":t},r.prototype.getOrigin=function(){var t=this.getHost();return t?this.getProtocol()+"//"+t:""},r.prototype.getParameterValue=function(t){return this.ensureQueryInitialized_(),this.query.get(t)},r.prototype.getParameterValues=function(t){return this.ensureQueryInitialized_(),this.query.getAll(t)},r.prototype.getParameterNames=function(){return this.ensureQueryInitialized_(),this.query.names()},r.getParseFn=function(){return o},r.prototype.getPathname=function(){return this.url.pathname},r.prototype.getPort=function(){return this.url.port},r.prototype.getProtocol=function(){return this.url.protocol},r.prototype.getSearch=function(){var t=this,n="",r="";return this.getParameterNames().forEach(function(n){t.getParameterValues(n).forEach(function(t){r+=n,e.isDef(t)&&(r+="="+encodeURIComponent(t)),r+="&"})}),r=r.slice(0,-1),r&&(n+="?"+r),n},r.prototype.hasParameter=function(t){return this.ensureQueryInitialized_(),this.query.contains(t)},r.prototype.makeUnique=function(){return this.setParameterValue(r.RANDOM_PARAM,n.getRandomString()),this},r.prototype.maybeAddProtocolAndHostname_=function(t){var e=t;if(t.indexOf("://")===-1&&0!==t.indexOf("javascript:"))switch(e=r.DEFAULT_PROTOCOL,"/"===t[0]&&"/"===t[1]||(e+="//"),t.charAt(0)){case".":case"?":case"#":e+=r.HOSTNAME_PLACEHOLDER,e+="/",e+=t;break;case"":case"/":"/"!==t[1]&&(e+=r.HOSTNAME_PLACEHOLDER),e+=t;break;default:e+=t}return e},r.normalizeObject=function(t){var e=t.pathname?t.pathname.length:0;return e>1&&"/"===t.pathname[e-1]&&(t.pathname=t.pathname.substr(0,e-1)),t},r.parse=function(t){return r.normalizeObject(o(t))},r.prototype.removeParameter=function(t){return this.ensureQueryInitialized_(),this.query.remove(t),this},r.prototype.removeUnique=function(){return this.removeParameter(r.RANDOM_PARAM),this},r.prototype.setHash=function(t){return this.url.hash=t,this},r.prototype.setHostname=function(t){return this.url.hostname=t,this},r.prototype.setParameterValue=function(t,e){return this.removeParameter(t),this.addParameterValue(t,e),this},r.prototype.setParameterValues=function(t,e){var n=this;return this.removeParameter(t),e.forEach(function(e){return n.addParameterValue(t,e)}),this},r.prototype.setPathname=function(t){return this.url.pathname=t,this},r.prototype.setPort=function(t){return this.url.port=t,this},r.setParseFn=function(t){o=t},r.prototype.setProtocol=function(t){return this.url.protocol=t,":"!==this.url.protocol[this.url.protocol.length-1]&&(this.url.protocol+=":"),this},r.prototype.toString=function(){var t="",e=this.getHost();return e&&(t+=this.getProtocol()+"//"),t+=e+this.getPathname()+this.getSearch()+this.getHash()},r.joinPaths=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r-1},n}();this.senna.Route=n}.call(this),function(){var e=this.sennaNamed.metal.Disposable,n=function(e){function n(){t.classCallCheck(this,n);var r=t.possibleConstructorReturn(this,e.call(this));return r.cache=null,r.cacheable=!1,r}return t.inherits(n,e),n.prototype.addCache=function(t){return this.cacheable&&(this.cache=t),this},n.prototype.clearCache=function(){return this.cache=null,this},n.prototype.disposeInternal=function(){this.clearCache()},n.prototype.getCache=function(){return this.cache},n.prototype.isCacheable=function(){return this.cacheable},n.prototype.setCacheable=function(t){t||this.clearCache(),this.cacheable=t},n}(e);this.senna.Cacheable=n}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.dom.globalEval,r=this.senna.Cacheable,i=this.senna.Promise,o=function(r){function o(){t.classCallCheck(this,o);var n=t.possibleConstructorReturn(this,r.call(this));return n.id=n.makeId_(e.getUid()),n.title=null,n}return t.inherits(o,r),o.prototype.activate=function(){},o.prototype.beforeDeactivate=function(){},o.prototype.beforeUpdateHistoryPath=function(t){return t},o.prototype.beforeUpdateHistoryState=function(t){return t},o.prototype.deactivate=function(){},o.prototype.disposeInternal=function(){r.prototype.disposeInternal.call(this)},o.prototype.evaluateScripts=function(t){return Object.keys(t).forEach(function(e){t[e].activeChild&&n.runScriptsInElement(t[e].activeChild)}),i.resolve()},o.prototype.evaluateStyles=function(){return i.resolve()},o.prototype.flip=function(t){var e=this,n=[];return Object.keys(t).forEach(function(r){var i=t[r],o=i.show(e.id);n.push(o)}),i.all(n)},o.prototype.getId=function(){return this.id},o.prototype.getSurfaceContent=function(){},o.prototype.getTitle=function(){return this.title},o.prototype.load=function(){return i.resolve()},o.prototype.makeId_=function(t){return"screen_"+t},o.prototype.setId=function(t){this.id=t},o.prototype.setTitle=function(t){this.title=t},o.prototype.toString=function(){return this.id},o}(r);o.isImplementedBy=function(t){return t instanceof o},this.senna.Screen=o}.call(this),function(){var e=this.senna.globals,n=this.sennaNamed.metal.core,r=this.sennaNamed.metal.Disposable,i=this.senna.dom,o=this.senna.Promise,a=function(r){function a(e){t.classCallCheck(this,a);var n=t.possibleConstructorReturn(this,r.call(this));if(!e)throw new Error("Surface element id not specified. A surface element requires a valid id.");return n.activeChild=null,n.defaultChild=null,n.element=null,n.id=e,n.transitionFn=null,n.defaultChild=n.getChild(a.DEFAULT),n.maybeWrapContentAsDefault_(),n.activeChild=n.defaultChild,n}return t.inherits(a,r),a.prototype.addContent=function(t,e){var r=this.defaultChild;n.isDefAndNotNull(e)&&(r=this.getChild(t),r?i.removeChildren(r):(r=this.createChild(t),this.transition(r,null)),i.append(r,e));var o=this.getElement();return o&&r&&i.append(o,r),r},a.prototype.createChild=function(t){var n=e.document.createElement("div");return n.setAttribute("id",this.makeId_(t)),n},a.prototype.getChild=function(t){return e.document.getElementById(this.makeId_(t))},a.prototype.getElement=function(){return this.element?this.element:(this.element=e.document.getElementById(this.id),this.element)},a.prototype.getId=function(){return this.id},a.prototype.getTransitionFn=function(){return this.transitionFn},a.prototype.makeId_=function(t){return this.id+"-"+t},a.prototype.maybeWrapContentAsDefault_=function(){var t=this.getElement();if(t&&!this.defaultChild){for(var n=e.document.createDocumentFragment();t.firstChild;)n.appendChild(t.firstChild);this.defaultChild=this.addContent(a.DEFAULT,n),this.transition(null,this.defaultChild)}},a.prototype.setId=function(t){this.id=t},a.prototype.setTransitionFn=function(t){this.transitionFn=t},a.prototype.show=function(t){var e=this.activeChild,n=this.getChild(t);return n||(n=this.defaultChild),this.activeChild=n,this.transition(e,n).thenAlways(function(){e&&e!==n&&i.exitDocument(e)})},a.prototype.remove=function(t){var e=this.getChild(t);e&&i.exitDocument(e)},a.prototype.toString=function(){return this.id},a.prototype.transition=function(t,e){var n=this.transitionFn||a.defaultTransition;return o.resolve(n.call(this,t,e))},a}(r);a.DEFAULT="default",a.defaultTransition=function(t,e){t&&(t.style.display="none",t.classList.remove("flipped")),e&&(e.style.display="block",e.classList.add("flipped"))},this.senna.Surface=a}.call(this),function(){var e=this.sennaNamed.metal.array,n=this.sennaNamed.metal.async,r=this.sennaNamed.metal.core,i=this.senna.debounce,o=this.senna.dom,a=this.senna.Promise,s=this.sennaNamed.events.EventEmitter,l=this.sennaNamed.events.EventHandler,c=this.senna.utils,u=this.senna.globals,h=this.senna.Route,p=this.senna.Screen,d=this.senna.Surface,f=this.senna.Uri,m=function(s){function m(){t.classCallCheck(this,m);var e=t.possibleConstructorReturn(this,s.call(this));return e.activeScreen=null,e.activePath=null,e.allowPreventNavigate=!0,e.basePath="",e.captureScrollPositionFromScrollEvent=!0,e.defaultTitle=u.document.title,e.formSelector='form[enctype="multipart/form-data"]:not([data-senna-off])',e.linkSelector="a:not([data-senna-off])",e.loadingCssClass="senna-loading",e.nativeScrollRestorationSupported="scrollRestoration"in u.window.history,e.pendingNavigate=null,e.popstateScrollLeft=0,e.popstateScrollTop=0,e.redirectPath=null,e.routes=[],e.screens={},e.skipLoadPopstate=!1,e.surfaces={},e.updateScrollPosition=!0,e.appEventHandlers_=new l,e.appEventHandlers_.add(o.on(u.window,"scroll",i(e.onScroll_.bind(e),100)),o.on(u.window,"load",e.onLoad_.bind(e)),o.on(u.window,"popstate",e.onPopstate_.bind(e))),e.on("startNavigate",e.onStartNavigate_),e.on("beforeNavigate",e.onBeforeNavigate_),e.on("beforeNavigate",e.onBeforeNavigateDefault_,!0),e.setLinkSelector(e.linkSelector),e.setFormSelector(e.formSelector),e}return t.inherits(m,s),m.prototype.addRoutes=function(t){var e=this;return Array.isArray(t)||(t=[t]),t.forEach(function(t){t instanceof h||(t=new h(t.path,t.handler)),e.routes.push(t)}),this},m.prototype.addSurfaces=function(t){var e=this;return Array.isArray(t)||(t=[t]),t.forEach(function(t){r.isString(t)&&(t=new d(t)),e.surfaces[t.getId()]=t}),this},m.prototype.canNavigate=function(t){var e=c.getUrlPath(t),n=new f(t);return!!this.isLinkSameOrigin_(n.getHostname())&&(!!this.isSameBasePath_(e)&&!!this.findRoute(e))},m.prototype.clearScreensCache=function(){var t=this;Object.keys(this.screens).forEach(function(e){e===t.activePath?t.activeScreen.clearCache():t.removeScreen(e)})},m.prototype.createScreenInstance=function(t,e){if(!this.pendingNavigate&&t===this.activePath)return this.activeScreen;var n=this.screens[t];if(!n){var r=e.getHandler();n=r===p||p.isImplementedBy(r.prototype)?new r:r(e)||new p}return n},m.prototype.disposeInternal=function(){this.activeScreen&&this.removeScreen(this.activePath),this.clearScreensCache(),this.formEventHandler_.removeListener(),this.linkEventHandler_.removeListener(),this.appEventHandlers_.removeAllListeners(),s.prototype.disposeInternal.call(this)},m.prototype.dispatch=function(){return this.navigate(c.getCurrentBrowserPath(),!0)},m.prototype.doNavigate_=function(t,e){var n=this;if(this.activeScreen&&this.activeScreen.beforeDeactivate())return this.pendingNavigate=a.reject(new a.CancellationError("Cancelled by active screen")),this.pendingNavigate;var r=this.findRoute(t);if(!r)return this.pendingNavigate=a.reject(new a.CancellationError("No route for "+t)),this.pendingNavigate;this.stopPendingNavigate_();var i=this.createScreenInstance(t,r);return i.load(t).then(function(){n.activeScreen&&n.activeScreen.deactivate(),n.prepareNavigateHistory_(t,i,e),n.prepareNavigateSurfaces_(i,n.surfaces)}).then(function(){return i.evaluateStyles(n.surfaces)}).then(function(){return i.flip(n.surfaces)}).then(function(){return i.evaluateScripts(n.surfaces)}).then(function(){return n.syncScrollPositionSyncThenAsync_()}).then(function(){return n.finalizeNavigate_(t,i)})["catch"](function(e){throw n.handleNavigateError_(t,i,e),e})},m.prototype.finalizeNavigate_=function(t,e){e.activate(),this.activeScreen&&!this.activeScreen.isCacheable()&&this.activeScreen!==e&&this.removeScreen(this.activePath),this.activePath=t,this.activeScreen=e,this.screens[t]=e,this.pendingNavigate=null,u.capturedFormElement=null},m.prototype.findRoute=function(t){if(t.lastIndexOf("#")>-1&&c.isCurrentBrowserPath(t))return null;t=c.getUrlPathWithoutHash(t),t=c.getUrlPathWithoutHash(t.substr(this.basePath.length));for(var e=0;e0},m.prototype.isLinkSameOrigin_=function(t){return t===u.window.location.hostname},m.prototype.isSameBasePath_=function(t){return 0===t.indexOf(this.basePath)},m.prototype.lockHistoryScrollPosition_=function(){var t=u.window.history.state;if(t){var e=!1,r=function i(){u.document.removeEventListener("scroll",i,!1),e||(u.window.scrollTo(t.scrollLeft,t.scrollTop),e=!0)};n.nextTick(r),u.document.addEventListener("scroll",r,!1)}},m.prototype.maybeDisableNativeScrollRestoration=function(){this.nativeScrollRestorationSupported&&(this.nativeScrollRestoration_=u.window.history.scrollRestoration,u.window.history.scrollRestoration="manual")},m.prototype.maybeNavigate_=function(t,e){if(this.canNavigate(t)){u.capturedFormElement=e.capturedFormElement;var n=!1;try{this.navigate(c.getUrlPath(t))}catch(r){n=!0}n||e.preventDefault()}},m.prototype.maybeRepositionScrollToHashedAnchor=function(){var t=u.window.location.hash;if(t){var e=u.document.getElementById(t.substring(1));e&&u.window.scrollTo(e.offsetLeft,e.offsetTop)}},m.prototype.maybeRestoreNativeScrollRestoration=function(){this.nativeScrollRestorationSupported&&this.nativeScrollRestoration_&&(u.window.history.scrollRestoration=this.nativeScrollRestoration_)},m.prototype.navigate=function(t,e){if(!c.isHtml5HistorySupported())throw new Error("HTML5 History is not supported. Senna will not intercept navigation.");return t===this.activePath&&(e=!0),this.emit("beforeNavigate",{path:t,replaceHistory:!!e}),this.pendingNavigate},m.prototype.onBeforeNavigate_=function(t){u.capturedFormElement&&(t.form=u.capturedFormElement)},m.prototype.onBeforeNavigateDefault_=function(t){this.pendingNavigate&&this.pendingNavigate.path===t.path||this.emit("startNavigate",{form:t.form,path:t.path,replaceHistory:t.replaceHistory})},m.prototype.onDocClickDelegate_=function(t){t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||t.button||this.maybeNavigate_(t.delegateTarget.href,t)},m.prototype.onDocSubmitDelegate_=function(t){var e=t.delegateTarget;"get"!==e.method&&(t.capturedFormElement=e,this.maybeNavigate_(e.action,t))},m.prototype.onLoad_=function(){var t=this;this.skipLoadPopstate=!0,setTimeout(function(){t.skipLoadPopstate=!1},0),this.maybeRepositionScrollToHashedAnchor()},m.prototype.onPopstate_=function(t){if(!this.skipLoadPopstate){var e=t.state;return e?void(e.senna&&(this.popstateScrollTop=e.scrollTop,this.popstateScrollLeft=e.scrollLeft,this.nativeScrollRestorationSupported||this.lockHistoryScrollPosition_(),this.navigate(e.path,!0))):void(u.window.location.hash?(this.redirectPath&&!c.isCurrentBrowserPath(this.redirectPath)&&this.reloadPage(),this.maybeRepositionScrollToHashedAnchor()):this.reloadPage())}},m.prototype.onScroll_=function(){this.captureScrollPositionFromScrollEvent&&this.saveHistoryCurrentPageScrollPosition_()},m.prototype.onStartNavigate_=function(t){var e=this;this.maybeDisableNativeScrollRestoration(),this.captureScrollPositionFromScrollEvent=!1,o.addClasses(u.document.documentElement,this.loadingCssClass);var n={form:t.form,path:t.path};this.pendingNavigate=this.doNavigate_(t.path,t.replaceHistory)["catch"](function(t){throw n.error=t,t}).thenAlways(function(){e.pendingNavigate||(o.removeClasses(u.document.documentElement,e.loadingCssClass),e.maybeRestoreNativeScrollRestoration(),e.captureScrollPositionFromScrollEvent=!0),e.emit("endNavigate",n)}),this.pendingNavigate.path=t.path},m.prototype.prefetch=function(t){var e=this,n=this.findRoute(t);if(!n)return a.reject(new a.CancellationError("No route for "+t));var r=this.createScreenInstance(t,n);return r.load(t).then(function(){return e.screens[t]=r})["catch"](function(n){throw e.handleNavigateError_(t,r,n),n})},m.prototype.prepareNavigateHistory_=function(t,e,n){var i=e.getTitle();r.isString(i)||(i=this.getDefaultTitle());var o=e.beforeUpdateHistoryPath(t),a={form:r.isDefAndNotNull(u.capturedFormElement),redirectPath:o,path:t,senna:!0,scrollTop:0,scrollLeft:0};n&&(a.scrollTop=this.popstateScrollTop,a.scrollLeft=this.popstateScrollLeft),this.updateHistory_(i,o,e.beforeUpdateHistoryState(a),n),this.redirectPath=o},m.prototype.prepareNavigateSurfaces_=function(t,e){Object.keys(e).forEach(function(n){var r=t.getSurfaceContent(n);e[n].addContent(t.getId(),r)})},m.prototype.reloadPage=function(){u.window.location.reload()},m.prototype.removeRoute=function(t){return e.remove(this.routes,t)},m.prototype.removeScreen=function(t){var e=this,n=this.screens[t];n&&(Object.keys(this.surfaces).forEach(function(t){return e.surfaces[t].remove(n.getId())}),n.dispose(),delete this.screens[t])},m.prototype.saveHistoryCurrentPageScrollPosition_=function(){var t=u.window.history.state;t&&t.senna&&(t.scrollTop=u.window.pageYOffset,t.scrollLeft=u.window.pageXOffset,u.window.history.replaceState(t,null,null))},m.prototype.setAllowPreventNavigate=function(t){this.allowPreventNavigate=t},m.prototype.setBasePath=function(t){this.basePath=t},m.prototype.setDefaultTitle=function(t){this.defaultTitle=t},m.prototype.setFormSelector=function(t){this.formSelector=t,this.formEventHandler_&&this.formEventHandler_.removeListener(),this.formEventHandler_=o.delegate(document,"submit",this.formSelector,this.onDocSubmitDelegate_.bind(this),this.allowPreventNavigate)},m.prototype.setLinkSelector=function(t){this.linkSelector=t,this.linkEventHandler_&&this.linkEventHandler_.removeListener(),this.linkEventHandler_=o.delegate(document,"click",this.linkSelector,this.onDocClickDelegate_.bind(this),this.allowPreventNavigate)},m.prototype.setLoadingCssClass=function(t){this.loadingCssClass=t},m.prototype.setUpdateScrollPosition=function(t){this.updateScrollPosition=t},m.prototype.stopPendingNavigate_=function(){this.pendingNavigate&&(this.pendingNavigate.cancel("Cancel pending navigation"),this.pendingNavigate=null)},m.prototype.syncScrollPositionSyncThenAsync_=function(){var t=this,e=u.window.history.state;if(e){var r=e.scrollTop,i=e.scrollLeft,o=function(){t.updateScrollPosition&&u.window.scrollTo(i,r)};return new a(function(t){return o()&n.nextTick(function(){return o()&t()})})}},m.prototype.updateHistory_=function(t,e,n,r){r?u.window.history.replaceState(n,t,e):u.window.history.pushState(n,t,e),u.document.title=t},m}(s);this.senna.App=m}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.senna.Uri,r=this.sennaNamed.Promise.CancellablePromise,i=function(){function i(){t.classCallCheck(this,i)}return i.parseResponseHeaders=function(t){var e=[];if(!t)return e;for(var n=t.split("\r\n"),r=0;r0){var o=n[r].substring(0,i),a=n[r].substring(i+2);e.push({name:o,value:a})}}return e},i.request=function o(t,i,a,s,l,c,u,h){var o=new XMLHttpRequest,p=new r(function(t,e){o.onload=function(){return o.aborted?void o.onerror():void t(o)},o.onerror=function(){var t=new Error("Request error");t.request=o,e(t)}}).thenCatch(function(t){throw o.abort(),t}).thenAlways(function(){clearTimeout(d)});if(l&&(t=new n(t).addParametersFromMultiMap(l).toString()),o.open(i,t,!u),h&&(o.withCredentials=!0),s&&s.names().forEach(function(t){o.setRequestHeader(t,s.getAll(t).join(", "))}),o.send(e.isDef(a)?a:null),e.isDefAndNotNull(c))var d=setTimeout(function(){p.cancel("Request timeout")},c);return p},i}();this.senna.Ajax=i}.call(this),function(){var e=function n(){t.classCallCheck(this,n)};e.INVALID_STATUS="Invalid status code",e.REQUEST_ERROR="Request error",e.REQUEST_TIMEOUT="Request timeout",this.senna.errors=e}.call(this),function(){var e=function(){function e(){t.classCallCheck(this,e)}return e.getNativeUserAgent=function(){var t=e.globals.window.navigator;if(t){var n=t.userAgent;if(n)return n}return""},e.matchUserAgent=function(t){return e.userAgent.indexOf(t)!==-1},e.testUserAgent=function(t){e.userAgent=t,e.isOpera=e.matchUserAgent("Opera")||e.matchUserAgent("OPR"),e.isIe=e.matchUserAgent("Trident")||e.matchUserAgent("MSIE"),e.isEdge=e.matchUserAgent("Edge"),e.isIeOrEdge=e.isIe||e.isEdge,e.isChrome=(e.matchUserAgent("Chrome")||e.matchUserAgent("CriOS"))&&!e.isOpera&&!e.isEdge,e.isSafari=e.matchUserAgent("Safari")&&!(e.isChrome||e.isOpera||e.isEdge),e.isFirefox=e.matchUserAgent("Firefox")},e}();e.globals={window:window},e.testUserAgent(e.getNativeUserAgent()),this.senna.UA=e}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.senna.Ajax,r=this.senna.MultiMap,i=this.senna.Promise,o=this.senna.errors,a=this.senna.utils,s=this.senna.globals,l=this.senna.Screen,c=this.senna.Uri,u=this.senna.UA,h=function(l){function h(){t.classCallCheck(this,h);var e=t.possibleConstructorReturn(this,l.call(this));return e.cacheable=!0,e.httpHeaders={"X-PJAX":"true","X-Requested-With":"XMLHttpRequest"},e.httpMethod=h.GET,e.request=null,e.timeout=3e4,e}return t.inherits(h,l),h.prototype.assertValidResponseStatusCode=function(t){if(!this.isValidResponseStatusCode(t)){var e=new Error(o.INVALID_STATUS);throw e.invalidStatus=!0,e}},h.prototype.beforeUpdateHistoryPath=function(t){var e=this.getRequestPath();return e&&e!==t?e:t},h.prototype.beforeUpdateHistoryState=function(t){return t.senna&&t.form&&t.redirectPath===t.path?null:t},h.prototype.formatLoadPath=function(t){var e=new c(t);return e.setHostname(s.window.location.hostname),e.setProtocol(s.window.location.protocol),s.window.location.port&&e.setPort(s.window.location.port),u.isIeOrEdge&&this.httpMethod===h.GET?e.makeUnique().toString():e.toString()},h.prototype.getHttpHeaders=function(){return this.httpHeaders},h.prototype.getHttpMethod=function(){return this.httpMethod},h.prototype.getRequestPath=function(){var t=this.getRequest();if(t){var e=t.requestPath,n=this.maybeExtractResponseUrlFromRequest(t);return n&&(e=n),u.isIeOrEdge&&this.httpMethod===h.GET&&(e=new c(e).removeUnique().toString()),a.getUrlPath(e)}return null},h.prototype.getRequest=function(){return this.request},h.prototype.getTimeout=function(){return this.timeout},h.prototype.isValidResponseStatusCode=function(t){return t>=200&&t<=399},h.prototype.load=function(t){var a=this,l=this.getCache();if(e.isDefAndNotNull(l))return i.resolve(l);var c=null,p=this.httpMethod,d=new r;Object.keys(this.httpHeaders).forEach(function(t){return d.add(t,a.httpHeaders[t])}),s.capturedFormElement&&(c=new FormData(s.capturedFormElement),p=h.POST,u.isIeOrEdge&&d.add("If-None-Match",'"0"'));var f=this.formatLoadPath(t);return n.request(f,p,c,d,null,this.timeout).then(function(t){return a.setRequest(t),a.assertValidResponseStatusCode(t.status),p===h.GET&&a.isCacheable()&&a.addCache(t.responseText),t.requestPath=f,t.responseText})["catch"](function(t){switch(t.message){case o.REQUEST_TIMEOUT:t.timeout=!0;break;case o.REQUEST_ERROR:t.requestError=!0}throw t})},h.prototype.maybeExtractResponseUrlFromRequest=function(t){var e=t.responseURL;return e?e:t.getResponseHeader(h.X_REQUEST_URL_HEADER)},h.prototype.setHttpHeaders=function(t){this.httpHeaders=t},h.prototype.setHttpMethod=function(t){this.httpMethod=t.toLowerCase()},h.prototype.setRequest=function(t){this.request=t},h.prototype.setTimeout=function(t){this.timeout=t},h}(l);h.GET="get",h.POST="post",h.X_REQUEST_URL_HEADER="X-Request-URL",this.senna.RequestScreen=h}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.dom.dom,r=this.sennaNamed.dom.globalEval,i=this.sennaNamed.dom.globalEvalStyles,o=this.senna.Promise,a=this.senna.globals,s=this.senna.RequestScreen,l=this.senna.Surface,c=this.senna.UA,u=this.senna.Uri,h=this.senna.utils,p=function(s){function p(){t.classCallCheck(this,p);var e=t.possibleConstructorReturn(this,s.call(this));return e.titleSelector="title",e}return t.inherits(p,s),p.prototype.activate=function(){s.prototype.activate.call(this),this.releaseVirtualDocument(),this.pendingStyles=null},p.prototype.allocateVirtualDocumentForContent=function(t){this.virtualDocument||(this.virtualDocument=a.document.createElement("html")),this.copyNodeAttributesFromContent_(t,this.virtualDocument),this.virtualDocument.innerHTML=t},p.prototype.appendStyleIntoDocument_=function(t){var e=n.match(t,p.selectors.stylesTemporary);if(e&&this.pendingStyles.push(t),t.id){var r=a.document.getElementById(t.id);if(r)return void r.parentNode.insertBefore(t,r.nextSibling)}a.document.head.appendChild(t)},p.prototype.assertSameBodyIdInVirtualDocument=function(){var t=this.virtualDocument.querySelector("body");a.document.body.id||(a.document.body.id="senna_surface_"+e.getUid()),t&&(t.id=a.document.body.id)},p.prototype.copyNodeAttributesFromContent_=function(t,e){t=t.replace(/[<]\s*html/gi,"/gi,"/senna>"),e.innerHTML=t;var n=e.querySelector("senna");n&&(h.clearNodeAttributes(e),h.copyNodeAttributes(n,e))},p.prototype.disposeInternal=function(){this.disposePendingStyles(),s.prototype.disposeInternal.call(this)},p.prototype.disposePendingStyles=function(){this.pendingStyles&&this.pendingStyles.forEach(function(t){return n.exitDocument(t)})},p.prototype.evaluateScripts=function(t){var e=this,n=this.evaluateTrackedResources_(r.runScriptsInElement,p.selectors.scripts,p.selectors.scriptsTemporary,p.selectors.scriptsPermanent);return n.then(function(){return s.prototype.evaluateScripts.call(e,t)})},p.prototype.evaluateStyles=function(t){var e=this;this.pendingStyles=[];var n=this.evaluateTrackedResources_(i.runStylesInElement,p.selectors.styles,p.selectors.stylesTemporary,p.selectors.stylesPermanent,this.appendStyleIntoDocument_.bind(this));return n.then(function(){return s.prototype.evaluateStyles.call(e,t)})},p.prototype.evaluateTrackedResources_=function(t,e,r,i,a){var s=this,l=this.virtualQuerySelectorAll_(e),c=this.querySelectorAll_(r),u=this.querySelectorAll_(i);u.forEach(function(t){var e=s.getResourceKey_(t);e&&(p.permanentResourcesInDoc[e]=!0)});var h=n.buildFragment();return l.forEach(function(t){var e=s.getResourceKey_(t);p.permanentResourcesInDoc[e]||h.appendChild(t),e&&n.match(t,i)&&(p.permanentResourcesInDoc[e]=!0)}),new o(function(e){t(h,function(){c.forEach(function(t){return n.exitDocument(t)}),e()},a)})},p.prototype.flip=function(t){var e=this;return s.prototype.flip.call(this,t).then(function(){h.clearNodeAttributes(document.documentElement),h.copyNodeAttributes(e.virtualDocument,document.documentElement)})},p.prototype.getResourceKey_=function(t){return t.id||t.href||t.src||""},p.prototype.getSurfaceContent=function(t){var e=this.virtualDocument.querySelector("#"+t);if(e){var n=e.querySelector("#"+t+"-"+l.DEFAULT);return n?n.innerHTML:e.innerHTML; +}},p.prototype.getTitleSelector=function(){return this.titleSelector},p.prototype.load=function(t){var e=this;return s.prototype.load.call(this,t).then(function(t){return e.allocateVirtualDocumentForContent(t),e.resolveTitleFromVirtualDocument(),e.assertSameBodyIdInVirtualDocument(),c.isIe&&e.makeTemporaryStylesHrefsUnique_(),t})},p.prototype.makeTemporaryStylesHrefsUnique_=function(){var t=this,e=this.virtualQuerySelectorAll_(p.selectors.stylesTemporary);e.forEach(function(e){return t.replaceStyleAndMakeUnique_(e)})},p.prototype.replaceStyleAndMakeUnique_=function(t){if(t.href){var e=a.document.createElement(t.tagName);t.href=new u(t.href).makeUnique().toString(),h.copyNodeAttributes(t,e),t.parentNode.replaceChild(e,t),t.disabled=!0}},p.prototype.virtualQuerySelectorAll_=function(t){return Array.prototype.slice.call(this.virtualDocument.querySelectorAll(t))},p.prototype.querySelectorAll_=function(t){return Array.prototype.slice.call(a.document.querySelectorAll(t))},p.prototype.releaseVirtualDocument=function(){this.virtualDocument=null},p.prototype.resolveTitleFromVirtualDocument=function(){var t=this.virtualDocument.querySelector(this.titleSelector);t&&this.setTitle(t.innerHTML.trim())},p.prototype.setTitleSelector=function(t){this.titleSelector=t},p}(s);p.selectors={scripts:"script[data-senna-track]",scriptsPermanent:'script[data-senna-track="permanent"]',scriptsTemporary:'script[data-senna-track="temporary"]',styles:"style[data-senna-track],link[data-senna-track]",stylesPermanent:'style[data-senna-track="permanent"],link[data-senna-track="permanent"]',stylesTemporary:'style[data-senna-track="temporary"],link[data-senna-track="temporary"]'},p.permanentResourcesInDoc={},this.senna.HtmlScreen=p}.call(this),function(){var t=this.senna.App,e=this.senna.HtmlScreen,n=this.senna.RequestScreen,r=this.senna.Route,i=this.senna.Screen;this.senna.senna=t,this.sennaNamed.senna=this.sennaNamed.senna||{},this.sennaNamed.senna.App=t,this.sennaNamed.senna.HtmlScreen=e,this.sennaNamed.senna.Route=r,this.sennaNamed.senna.RequestScreen=n,this.sennaNamed.senna.Screen=i}.call(this),function(){this.senna.dataAttributes={basePath:"data-senna-base-path",linkSelector:"data-senna-link-selector",loadingCssClass:"data-senna-loading-css-class",senna:"data-senna",dispatch:"data-senna-dispatch",surface:"data-senna-surface",updateScrollPosition:"data-senna-update-scroll-position"}}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.metal.object,r=this.sennaNamed.metal.Disposable,i=this.senna.dataAttributes,o=this.senna.globals,a=this.senna.App,s=this.senna.HtmlScreen,l=this.senna.Route,c=function(r){function c(){t.classCallCheck(this,c);var e=t.possibleConstructorReturn(this,r.call(this));return e.app=null,e.baseElement=null,e}return t.inherits(c,r),c.prototype.handle=function(){if(!e.isElement(this.baseElement))throw new Error("Senna data attribute handler base element not set or invalid, try setting a valid element that contains a `data-senna` attribute.");if(this.baseElement.hasAttribute(i.senna)){if(this.app)throw new Error("Senna app was already initialized.");this.app=new a,this.maybeAddRoutes_(),this.maybeAddSurfaces_(),this.maybeSetBasePath_(),this.maybeSetLinkSelector_(),this.maybeSetLoadingCssClass_(),this.maybeSetUpdateScrollPosition_(),this.maybeDispatch_()}},c.prototype.disposeInternal=function(){this.app&&this.app.dispose()},c.prototype.getApp=function(){return this.app},c.prototype.getBaseElement=function(){return this.baseElement},c.prototype.maybeAddRoutes_=function(){var t=this,e='link[rel="senna-route"]';this.querySelectorAllAsArray_(e).forEach(function(e){return t.maybeParseLinkRoute_(e)}),this.app.hasRoutes()||this.app.addRoutes(new l(/.*/,s))},c.prototype.maybeAddSurfaces_=function(){var t=this,e="["+i.surface+"]";this.querySelectorAllAsArray_(e).forEach(function(e){t.updateElementIdIfSpecialSurface_(e),t.app.addSurfaces(e.id)})},c.prototype.maybeDispatch_=function(){this.baseElement.hasAttribute(i.dispatch)&&this.app.dispatch()},c.prototype.maybeParseLinkRoute_=function(t){var e=new l(this.maybeParseLinkRoutePath_(t),this.maybeParseLinkRouteHandler_(t));this.app.addRoutes(e)},c.prototype.maybeParseLinkRouteHandler_=function(t){var r=t.getAttribute("type");return e.isDefAndNotNull(r)&&(r=n.getObjectByName(r)),r},c.prototype.maybeParseLinkRoutePath_=function(t){var n=t.getAttribute("href");return e.isDefAndNotNull(n)&&0===n.indexOf("regex:")&&(n=new RegExp(n.substring(6))),n},c.prototype.maybeSetBasePath_=function(){var t=this.baseElement.getAttribute(i.basePath);e.isDefAndNotNull(t)&&this.app.setBasePath(t)},c.prototype.maybeSetLinkSelector_=function(){var t=this.baseElement.getAttribute(i.linkSelector);e.isDefAndNotNull(t)&&this.app.setLinkSelector(t)},c.prototype.maybeSetLoadingCssClass_=function(){var t=this.baseElement.getAttribute(i.loadingCssClass);e.isDefAndNotNull(t)&&this.app.setLoadingCssClass(t)},c.prototype.maybeSetUpdateScrollPosition_=function(){var t=this.baseElement.getAttribute(i.updateScrollPosition);e.isDefAndNotNull(t)&&("false"===t?this.app.setUpdateScrollPosition(!1):this.app.setUpdateScrollPosition(!0))},c.prototype.querySelectorAllAsArray_=function(t){return Array.prototype.slice.call(o.document.querySelectorAll(t))},c.prototype.updateElementIdIfSpecialSurface_=function(t){t.id||t!==o.document.body||(t.id="senna_surface_"+e.getUid())},c.prototype.setBaseElement=function(t){this.baseElement=t},c}(r);this.senna.AppDataAttributeHandler=c}.call(this),function(){var t=this.senna.globals,e=this.senna.AppDataAttributeHandler,n=new e;t.document.addEventListener("DOMContentLoaded",function(){n.setBaseElement(t.document.body),n.handle()}),this.senna.dataAttributeHandler=n}.call(this)}).call(this); \ No newline at end of file diff --git a/build/globals/senna.js b/build/globals/senna.js index ae7ba49..c691ddb 100644 --- a/build/globals/senna.js +++ b/build/globals/senna.js @@ -1,7 +1,7 @@ /** * Senna.js - A blazing-fast Single Page Application engine * @author Liferay, Inc. - * @version v1.5.1 + * @version v1.5.2 * @link http://sennajs.com * @license BSD-3-Clause */ @@ -6502,9 +6502,17 @@ babelHelpers; App.prototype.handleNavigateError_ = function handleNavigateError_(path, nextScreen, err) { + var _this6 = this; + void 0; if (!utils.isCurrentBrowserPath(path)) { - this.removeScreen(path); + if (this.pendingNavigate) { + this.pendingNavigate.thenAlways(function () { + return _this6.removeScreen(path); + }, this); + } else { + this.removeScreen(path); + } } }; @@ -6750,13 +6758,13 @@ babelHelpers; App.prototype.onLoad_ = function onLoad_() { - var _this6 = this; + var _this7 = this; this.skipLoadPopstate = true; setTimeout(function () { // The timeout ensures that popstate events will be unblocked right // after the load event occured, but not in the same event-loop cycle. - _this6.skipLoadPopstate = false; + _this7.skipLoadPopstate = false; }, 0); // Try to reposition scroll to the hashed anchor when page loads. this.maybeRepositionScrollToHashedAnchor(); @@ -6831,7 +6839,7 @@ babelHelpers; App.prototype.onStartNavigate_ = function onStartNavigate_(event) { - var _this7 = this; + var _this8 = this; this.maybeDisableNativeScrollRestoration(); this.captureScrollPositionFromScrollEvent = false; @@ -6846,12 +6854,12 @@ babelHelpers; endNavigatePayload.error = reason; throw reason; }).thenAlways(function () { - if (!_this7.pendingNavigate) { - dom.removeClasses(globals.document.documentElement, _this7.loadingCssClass); - _this7.maybeRestoreNativeScrollRestoration(); - _this7.captureScrollPositionFromScrollEvent = true; + if (!_this8.pendingNavigate) { + dom.removeClasses(globals.document.documentElement, _this8.loadingCssClass); + _this8.maybeRestoreNativeScrollRestoration(); + _this8.captureScrollPositionFromScrollEvent = true; } - _this7.emit('endNavigate', endNavigatePayload); + _this8.emit('endNavigate', endNavigatePayload); }); this.pendingNavigate.path = event.path; @@ -6865,7 +6873,7 @@ babelHelpers; App.prototype.prefetch = function prefetch(path) { - var _this8 = this; + var _this9 = this; var route = this.findRoute(path); if (!route) { @@ -6877,9 +6885,9 @@ babelHelpers; var nextScreen = this.createScreenInstance(path, route); return nextScreen.load(path).then(function () { - return _this8.screens[path] = nextScreen; + return _this9.screens[path] = nextScreen; }).catch(function (reason) { - _this8.handleNavigateError_(path, nextScreen, reason); + _this9.handleNavigateError_(path, nextScreen, reason); throw reason; }); }; @@ -6956,12 +6964,12 @@ babelHelpers; App.prototype.removeScreen = function removeScreen(path) { - var _this9 = this; + var _this10 = this; var screen = this.screens[path]; if (screen) { Object.keys(this.surfaces).forEach(function (surfaceId) { - return _this9.surfaces[surfaceId].remove(screen.getId()); + return _this10.surfaces[surfaceId].remove(screen.getId()); }); screen.dispose(); delete this.screens[path]; @@ -7083,7 +7091,7 @@ babelHelpers; App.prototype.syncScrollPositionSyncThenAsync_ = function syncScrollPositionSyncThenAsync_() { - var _this10 = this; + var _this11 = this; var state = globals.window.history.state; if (!state) { @@ -7094,7 +7102,7 @@ babelHelpers; var scrollLeft = state.scrollLeft; var sync = function sync() { - if (_this10.updateScrollPosition) { + if (_this11.updateScrollPosition) { globals.window.scrollTo(scrollLeft, scrollTop); } }; diff --git a/build/globals/senna.js.map b/build/globals/senna.js.map index efbb02e..b451600 100644 --- a/build/globals/senna.js.map +++ b/build/globals/senna.js.map @@ -1 +1 @@ -{"version":3,"sources":["core.js","array.js","async.js","Disposable.js","object.js","string.js","metal.js","debounce.js","domData.js","EventHandle.js","EventEmitter.js","EventEmitterProxy.js","EventHandler.js","events.js","DomDelegatedEventHandle.js","DomEventHandle.js","dom.js","DomEventEmitterProxy.js","features.js","globalEval.js","globalEvalStyles.js","Promise.js","globals.js","parseFromAnchor.js","parse.js","MultiMap.js","Uri.js","utils.js","Route.js","Cacheable.js","Screen.js","Surface.js","App.js","Ajax.js","errors.js","UA.js","RequestScreen.js","HtmlScreen.js","senna.js","dataAttributes.js","AppDataAttributeHandler.js","dataAttributeHandler.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;KAMM;;;;;;;;;;;;;;;;OAWE,2CAAiB;AACvB,SAAM,MAAM,+BAAN,CAAN;AACA;;;;;;;;;;;;;OAWM,mEAA4B,aAAa,cAAc;AAC7D,OAAI,iBAAiB,CAAC,YAAY,YAAZ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,QAAlC,CAA3B,CAAP;AACA;;;;;;;;;;oCAQD,6EAAiC,SAAS;AACzC,OAAI,CAAC,QAAQ,EAAT,IAAe,YAAY,QAAQ,QAAR,CAAiB,IAAhD,EAAsD;AACrD,YAAQ,EAAR,GAAa,mBAAmB,KAAK,MAAL,EAAhC;AACA;AACD;;;;;;;;oCAMD,yCAAe,aAAa;AAC3B,QAAK,WAAL,GAAmB,WAAnB;AACA;;;GA1OoC;;sCA8OvB;;ACvPf;;;MAEO;MACA;;;;;;;AAMP,MAAI,uBAAuB,IAAI,uBAAJ,EAA3B;;AAEA,UAAQ,QAAR,CAAiB,gBAAjB,CAAkC,kBAAlC,EAAsD,YAAW;AAChE,yBAAqB,cAArB,CAAoC,QAAQ,QAAR,CAAiB,IAArD;AACA,yBAAqB,MAArB;AACA,GAHD;;oCAKe","file":"senna.js","sourcesContent":["'use strict';\n\n/**\n * A collection of core utility functions.\n * @const\n */\nclass core {\n\t/**\n\t * When defining a class Foo with an abstract method bar(), you can do:\n\t * Foo.prototype.bar = core.abstractMethod\n\t *\n\t * Now if a subclass of Foo fails to override bar(), an error will be thrown\n\t * when bar() is invoked.\n\t *\n\t * @type {!Function}\n\t * @throws {Error} when invoked to indicate the method should be overridden.\n\t */\n\tstatic abstractMethod() {\n\t\tthrow Error('Unimplemented abstract method');\n\t}\n\n\t/**\n\t * Loops constructor super classes collecting its properties values. If\n\t * property is not available on the super class `undefined` will be\n\t * collected as value for the class hierarchy position.\n\t * @param {!function()} constructor Class constructor.\n\t * @param {string} propertyName Property name to be collected.\n\t * @return {Array.<*>} Array of collected values.\n\t * TODO(*): Rethink superclass loop.\n\t */\n\tstatic collectSuperClassesProperty(constructor, propertyName) {\n\t\tvar propertyValues = [constructor[propertyName]];\n\t\twhile (constructor.__proto__ && !constructor.__proto__.isPrototypeOf(Function)) {\n\t\t\tconstructor = constructor.__proto__;\n\t\t\tpropertyValues.push(constructor[propertyName]);\n\t\t}\n\t\treturn propertyValues;\n\t}\n\n\t/**\n\t * Gets the name of the given function. If the current browser doesn't\n\t * support the `name` property, this will calculate it from the function's\n\t * content string.\n\t * @param {!function()} fn\n\t * @return {string}\n\t */\n\tstatic getFunctionName(fn) {\n\t\tif (!fn.name) {\n\t\t\tvar str = fn.toString();\n\t\t\tfn.name = str.substring(9, str.indexOf('('));\n\t\t}\n\t\treturn fn.name;\n\t}\n\n\t/**\n\t * Gets an unique id. If `opt_object` argument is passed, the object is\n\t * mutated with an unique id. Consecutive calls with the same object\n\t * reference won't mutate the object again, instead the current object uid\n\t * returns. See {@link core.UID_PROPERTY}.\n\t * @param {Object=} opt_object Optional object to be mutated with the uid. If\n\t * not specified this method only returns the uid.\n\t * @param {boolean=} opt_noInheritance Optional flag indicating if this\n\t * object's uid property can be inherited from parents or not.\n\t * @throws {Error} when invoked to indicate the method should be overridden.\n\t */\n\tstatic getUid(opt_object, opt_noInheritance) {\n\t\tif (opt_object) {\n\t\t\tvar id = opt_object[core.UID_PROPERTY];\n\t\t\tif (opt_noInheritance && !opt_object.hasOwnProperty(core.UID_PROPERTY)) {\n\t\t\t\tid = null;\n\t\t\t}\n\t\t\treturn id || (opt_object[core.UID_PROPERTY] = core.uniqueIdCounter_++);\n\t\t}\n\t\treturn core.uniqueIdCounter_++;\n\t}\n\n\t/**\n\t * The identity function. Returns its first argument.\n\t * @param {*=} opt_returnValue The single value that will be returned.\n\t * @return {?} The first argument.\n\t */\n\tstatic identityFunction(opt_returnValue) {\n\t\treturn opt_returnValue;\n\t}\n\n\t/**\n\t * Returns true if the specified value is a boolean.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is boolean.\n\t */\n\tstatic isBoolean(val) {\n\t\treturn typeof val === 'boolean';\n\t}\n\n\t/**\n\t * Returns true if the specified value is not undefined.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is defined.\n\t */\n\tstatic isDef(val) {\n\t\treturn val !== undefined;\n\t}\n\n\t/**\n\t * Returns true if value is not undefined or null.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isDefAndNotNull(val) {\n\t\treturn core.isDef(val) && !core.isNull(val);\n\t}\n\n\t/**\n\t * Returns true if value is a document.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isDocument(val) {\n\t\treturn val && typeof val === 'object' && val.nodeType === 9;\n\t}\n\n\t/**\n\t * Returns true if value is a dom element.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isElement(val) {\n\t\treturn val && typeof val === 'object' && val.nodeType === 1;\n\t}\n\n\t/**\n\t * Returns true if the specified value is a function.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is a function.\n\t */\n\tstatic isFunction(val) {\n\t\treturn typeof val === 'function';\n\t}\n\n\t/**\n\t * Returns true if value is null.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isNull(val) {\n\t\treturn val === null;\n\t}\n\n\t/**\n\t * Returns true if the specified value is a number.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is a number.\n\t */\n\tstatic isNumber(val) {\n\t\treturn typeof val === 'number';\n\t}\n\n\t/**\n\t * Returns true if value is a window.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isWindow(val) {\n\t\treturn val !== null && val === val.window;\n\t}\n\n\t/**\n\t * Returns true if the specified value is an object. This includes arrays\n\t * and functions.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is an object.\n\t */\n\tstatic isObject(val) {\n\t\tvar type = typeof val;\n\t\treturn type === 'object' && val !== null || type === 'function';\n\t}\n\n\t/**\n\t * Returns true if value is a Promise.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isPromise(val) {\n\t\treturn val && typeof val === 'object' && typeof val.then === 'function';\n\t}\n\n\t/**\n\t * Returns true if value is a string.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isString(val) {\n\t\treturn typeof val === 'string';\n\t}\n\n\t/**\n\t * Merges the values of a static property a class with the values of that\n\t * property for all its super classes, and stores it as a new static\n\t * property of that class. If the static property already existed, it won't\n\t * be recalculated.\n\t * @param {!function()} constructor Class constructor.\n\t * @param {string} propertyName Property name to be collected.\n\t * @param {function(*, *):*=} opt_mergeFn Function that receives an array filled\n\t * with the values of the property for the current class and all its super classes.\n\t * Should return the merged value to be stored on the current class.\n\t * @return {boolean} Returns true if merge happens, false otherwise.\n\t */\n\tstatic mergeSuperClassesProperty(constructor, propertyName, opt_mergeFn) {\n\t\tvar mergedName = propertyName + '_MERGED';\n\t\tif (constructor.hasOwnProperty(mergedName)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tvar merged = core.collectSuperClassesProperty(constructor, propertyName);\n\t\tif (opt_mergeFn) {\n\t\t\tmerged = opt_mergeFn(merged);\n\t\t}\n\t\tconstructor[mergedName] = merged;\n\t\treturn true;\n\t}\n\n\t/**\n\t * Null function used for default values of callbacks, etc.\n\t * @return {void} Nothing.\n\t */\n\tstatic nullFunction() {}\n}\n\n/**\n * Unique id property prefix.\n * @type {String}\n * @protected\n */\ncore.UID_PROPERTY = 'core_' + ((Math.random() * 1e9) >>> 0);\n\n/**\n * Counter for unique id.\n * @type {Number}\n * @private\n */\ncore.uniqueIdCounter_ = 1;\n\nexport default core;\n","'use strict';\n\nimport core from '../core';\n\nclass array {\n\t/**\n\t * Checks if the given arrays have the same content.\n\t * @param {!Array<*>} arr1\n\t * @param {!Array<*>} arr2\n\t * @return {boolean}\n\t */\n\tstatic equal(arr1, arr2) {\n\t\tif (arr1.length !== arr2.length) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (var i = 0; i < arr1.length; i++) {\n\t\t\tif (arr1[i] !== arr2[i]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Returns the first value in the given array that isn't undefined.\n\t * @param {!Array} arr\n\t * @return {*}\n\t */\n\tstatic firstDefinedValue(arr) {\n\t\tfor (var i = 0; i < arr.length; i++) {\n\t\t\tif (arr[i] !== undefined) {\n\t\t\t\treturn arr[i];\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Transforms the input nested array to become flat.\n\t * @param {Array.<*|Array.<*>>} arr Nested array to flatten.\n\t * @param {Array.<*>} opt_output Optional output array.\n\t * @return {Array.<*>} Flat array.\n\t */\n\tstatic flatten(arr, opt_output) {\n\t\tvar output = opt_output || [];\n\t\tfor (var i = 0; i < arr.length; i++) {\n\t\t\tif (Array.isArray(arr[i])) {\n\t\t\t\tarray.flatten(arr[i], output);\n\t\t\t} else {\n\t\t\t\toutput.push(arr[i]);\n\t\t\t}\n\t\t}\n\t\treturn output;\n\t}\n\n\t/**\n\t * Removes the first occurrence of a particular value from an array.\n\t * @param {Array.} arr Array from which to remove value.\n\t * @param {T} obj Object to remove.\n\t * @return {boolean} True if an element was removed.\n\t * @template T\n\t */\n\tstatic remove(arr, obj) {\n\t\tvar i = arr.indexOf(obj);\n\t\tvar rv;\n\t\tif ( (rv = i >= 0) ) {\n\t\t\tarray.removeAt(arr, i);\n\t\t}\n\t\treturn rv;\n\t}\n\n\t/**\n\t * Removes from an array the element at index i\n\t * @param {Array} arr Array or array like object from which to remove value.\n\t * @param {number} i The index to remove.\n\t * @return {boolean} True if an element was removed.\n\t */\n\tstatic removeAt(arr, i) {\n\t\treturn Array.prototype.splice.call(arr, i, 1).length === 1;\n\t}\n\n\t/**\n\t * Slices the given array, just like Array.prototype.slice, but this\n\t * is faster and working on all array-like objects (like arguments).\n\t * @param {!Object} arr Array-like object to slice.\n\t * @param {number} start The index that should start the slice.\n\t * @param {number=} opt_end The index where the slice should end, not\n\t * included in the final array. If not given, all elements after the\n\t * start index will be included.\n\t * @return {!Array}\n\t */\n\tstatic slice(arr, start, opt_end) {\n\t\tvar sliced = [];\n\t\tvar end = core.isDef(opt_end) ? opt_end : arr.length;\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tsliced.push(arr[i]);\n\t\t}\n\t\treturn sliced;\n\t}\n}\n\nexport default array;\n","/*!\n * Polyfill from Google's Closure Library.\n * Copyright 2013 The Closure Library Authors. All Rights Reserved.\n */\n\n'use strict';\n\nvar async = {};\n\n\n/**\n * Throw an item without interrupting the current execution context. For\n * example, if processing a group of items in a loop, sometimes it is useful\n * to report an error while still allowing the rest of the batch to be\n * processed.\n * @param {*} exception\n */\nasync.throwException = function(exception) {\n\t// Each throw needs to be in its own context.\n\tasync.nextTick(function() {\n\t\tthrow exception;\n\t});\n};\n\n\n/**\n * Fires the provided callback just before the current callstack unwinds, or as\n * soon as possible after the current JS execution context.\n * @param {function(this:THIS)} callback\n * @param {THIS=} opt_context Object to use as the \"this value\" when calling\n * the provided function.\n * @template THIS\n */\nasync.run = function(callback, opt_context) {\n\tif (!async.run.workQueueScheduled_) {\n\t\t// Nothing is currently scheduled, schedule it now.\n\t\tasync.nextTick(async.run.processWorkQueue);\n\t\tasync.run.workQueueScheduled_ = true;\n\t}\n\n\tasync.run.workQueue_.push(\n\t\tnew async.run.WorkItem_(callback, opt_context));\n};\n\n\n/** @private {boolean} */\nasync.run.workQueueScheduled_ = false;\n\n\n/** @private {!Array.} */\nasync.run.workQueue_ = [];\n\n/**\n * Run any pending async.run work items. This function is not intended\n * for general use, but for use by entry point handlers to run items ahead of\n * async.nextTick.\n */\nasync.run.processWorkQueue = function() {\n\t// NOTE: additional work queue items may be pushed while processing.\n\twhile (async.run.workQueue_.length) {\n\t\t// Don't let the work queue grow indefinitely.\n\t\tvar workItems = async.run.workQueue_;\n\t\tasync.run.workQueue_ = [];\n\t\tfor (var i = 0; i < workItems.length; i++) {\n\t\t\tvar workItem = workItems[i];\n\t\t\ttry {\n\t\t\t\tworkItem.fn.call(workItem.scope);\n\t\t\t} catch (e) {\n\t\t\t\tasync.throwException(e);\n\t\t\t}\n\t\t}\n\t}\n\n\t// There are no more work items, reset the work queue.\n\tasync.run.workQueueScheduled_ = false;\n};\n\n\n/**\n * @constructor\n * @final\n * @struct\n * @private\n *\n * @param {function()} fn\n * @param {Object|null|undefined} scope\n */\nasync.run.WorkItem_ = function(fn, scope) {\n\t/** @const */\n\tthis.fn = fn;\n\t/** @const */\n\tthis.scope = scope;\n};\n\n\n/**\n * Fires the provided callbacks as soon as possible after the current JS\n * execution context. setTimeout(…, 0) always takes at least 5ms for legacy\n * reasons.\n * @param {function(this:SCOPE)} callback Callback function to fire as soon as\n * possible.\n * @param {SCOPE=} opt_context Object in whose scope to call the listener.\n * @template SCOPE\n */\nasync.nextTick = function(callback, opt_context) {\n\tvar cb = callback;\n\tif (opt_context) {\n\t\tcb = callback.bind(opt_context);\n\t}\n\tcb = async.nextTick.wrapCallback_(cb);\n\t// Introduced and currently only supported by IE10.\n\t// Verify if variable is defined on the current runtime (i.e., node, browser).\n\t// Can't use typeof enclosed in a function (such as core.isFunction) or an\n\t// exception will be thrown when the function is called on an environment\n\t// where the variable is undefined.\n\tif (typeof setImmediate === 'function') {\n\t\tsetImmediate(cb);\n\t\treturn;\n\t}\n\t// Look for and cache the custom fallback version of setImmediate.\n\tif (!async.nextTick.setImmediate_) {\n\t\tasync.nextTick.setImmediate_ = async.nextTick.getSetImmediateEmulator_();\n\t}\n\tasync.nextTick.setImmediate_(cb);\n};\n\n\n/**\n * Cache for the setImmediate implementation.\n * @type {function(function())}\n * @private\n */\nasync.nextTick.setImmediate_ = null;\n\n\n/**\n * Determines the best possible implementation to run a function as soon as\n * the JS event loop is idle.\n * @return {function(function())} The \"setImmediate\" implementation.\n * @private\n */\nasync.nextTick.getSetImmediateEmulator_ = function() {\n\t// Create a private message channel and use it to postMessage empty messages\n\t// to ourselves.\n\tvar Channel;\n\n\t// Verify if variable is defined on the current runtime (i.e., node, browser).\n\t// Can't use typeof enclosed in a function (such as core.isFunction) or an\n\t// exception will be thrown when the function is called on an environment\n\t// where the variable is undefined.\n\tif (typeof MessageChannel === 'function') {\n\t\tChannel = MessageChannel;\n\t}\n\n\t// If MessageChannel is not available and we are in a browser, implement\n\t// an iframe based polyfill in browsers that have postMessage and\n\t// document.addEventListener. The latter excludes IE8 because it has a\n\t// synchronous postMessage implementation.\n\tif (typeof Channel === 'undefined' && typeof window !== 'undefined' &&\n\t\twindow.postMessage && window.addEventListener) {\n\t\t/** @constructor */\n\t\tChannel = function() {\n\t\t\t// Make an empty, invisible iframe.\n\t\t\tvar iframe = document.createElement('iframe');\n\t\t\tiframe.style.display = 'none';\n\t\t\tiframe.src = '';\n\t\t\tdocument.documentElement.appendChild(iframe);\n\t\t\tvar win = iframe.contentWindow;\n\t\t\tvar doc = win.document;\n\t\t\tdoc.open();\n\t\t\tdoc.write('');\n\t\t\tdoc.close();\n\t\t\tvar message = 'callImmediate' + Math.random();\n\t\t\tvar origin = win.location.protocol + '//' + win.location.host;\n\t\t\tvar onmessage = function(e) {\n\t\t\t\t// Validate origin and message to make sure that this message was\n\t\t\t\t// intended for us.\n\t\t\t\tif (e.origin !== origin && e.data !== message) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.port1.onmessage();\n\t\t\t}.bind(this);\n\t\t\twin.addEventListener('message', onmessage, false);\n\t\t\tthis.port1 = {};\n\t\t\tthis.port2 = {\n\t\t\t\tpostMessage: function() {\n\t\t\t\t\twin.postMessage(message, origin);\n\t\t\t\t}\n\t\t\t};\n\t\t};\n\t}\n\tif (typeof Channel !== 'undefined') {\n\t\tvar channel = new Channel();\n\t\t// Use a fifo linked list to call callbacks in the right order.\n\t\tvar head = {};\n\t\tvar tail = head;\n\t\tchannel.port1.onmessage = function() {\n\t\t\thead = head.next;\n\t\t\tvar cb = head.cb;\n\t\t\thead.cb = null;\n\t\t\tcb();\n\t\t};\n\t\treturn function(cb) {\n\t\t\ttail.next = {\n\t\t\t\tcb: cb\n\t\t\t};\n\t\t\ttail = tail.next;\n\t\t\tchannel.port2.postMessage(0);\n\t\t};\n\t}\n\t// Implementation for IE6-8: Script elements fire an asynchronous\n\t// onreadystatechange event when inserted into the DOM.\n\tif (typeof document !== 'undefined' && 'onreadystatechange' in\n\t\tdocument.createElement('script')) {\n\t\treturn function(cb) {\n\t\t\tvar script = document.createElement('script');\n\t\t\tscript.onreadystatechange = function() {\n\t\t\t\t// Clean up and call the callback.\n\t\t\t\tscript.onreadystatechange = null;\n\t\t\t\tscript.parentNode.removeChild(script);\n\t\t\t\tscript = null;\n\t\t\t\tcb();\n\t\t\t\tcb = null;\n\t\t\t};\n\t\t\tdocument.documentElement.appendChild(script);\n\t\t};\n\t}\n\t// Fall back to setTimeout with 0. In browsers this creates a delay of 5ms\n\t// or more.\n\treturn function(cb) {\n\t\tsetTimeout(cb, 0);\n\t};\n};\n\n\n/**\n * Helper function that is overrided to protect callbacks with entry point\n * monitor if the application monitors entry points.\n * @param {function()} callback Callback function to fire as soon as possible.\n * @return {function()} The wrapped callback.\n * @private\n */\nasync.nextTick.wrapCallback_ = function(opt_returnValue) {\n\treturn opt_returnValue;\n};\n\nexport default async;\n","'use strict';\n\n/**\n * Disposable utility. When inherited provides the `dispose` function to its\n * subclass, which is responsible for disposing of any object references\n * when an instance won't be used anymore. Subclasses should override\n * `disposeInternal` to implement any specific disposing logic.\n * @constructor\n */\nclass Disposable {\n\tconstructor() {\n\t\t/**\n\t\t * Flag indicating if this instance has already been disposed.\n\t\t * @type {boolean}\n\t\t * @protected\n\t\t */\n\t\tthis.disposed_ = false;\n\t}\n\n\t/**\n\t * Disposes of this instance's object references. Calls `disposeInternal`.\n\t */\n\tdispose() {\n\t\tif (!this.disposed_) {\n\t\t\tthis.disposeInternal();\n\t\t\tthis.disposed_ = true;\n\t\t}\n\t}\n\n\t/**\n\t * Subclasses should override this method to implement any specific\n\t * disposing logic (like clearing references and calling `dispose` on other\n\t * disposables).\n\t */\n\tdisposeInternal() {}\n\n\t/**\n\t * Checks if this instance has already been disposed.\n\t * @return {boolean}\n\t */\n\tisDisposed() {\n\t\treturn this.disposed_;\n\t}\n}\n\nexport default Disposable;\n","'use strict';\n\nclass object {\n\t/**\n\t * Copies all the members of a source object to a target object.\n\t * @param {Object} target Target object.\n\t * @param {...Object} var_args The objects from which values will be copied.\n\t * @return {Object} Returns the target object reference.\n\t */\n\tstatic mixin(target) {\n\t\tvar key, source;\n\t\tfor (var i = 1; i < arguments.length; i++) {\n\t\t\tsource = arguments[i];\n\t\t\tfor (key in source) {\n\t\t\t\ttarget[key] = source[key];\n\t\t\t}\n\t\t}\n\t\treturn target;\n\t}\n\n\t/**\n\t * Returns an object based on its fully qualified external name.\n\t * @param {string} name The fully qualified name.\n\t * @param {object=} opt_obj The object within which to look; default is\n\t * window.\n\t * @return {?} The value (object or primitive) or, if not found, undefined.\n\t */\n\tstatic getObjectByName(name, opt_obj) {\n\t\tvar scope = opt_obj || window;\n\t\tvar parts = name.split('.');\n\t\treturn parts.reduce((part, key) => part[key], scope);\n\t}\n\n\t/**\n\t * Returns a new object with the same keys as the given one, but with\n\t * their values set to the return values of the specified function.\n\t * @param {!Object} obj\n\t * @param {!function(string, *)} fn\n\t * @return {!Object}\n\t */\n\tstatic map(obj, fn) {\n\t\tvar mappedObj = {};\n\t\tvar keys = Object.keys(obj);\n\t\tfor (var i = 0; i < keys.length; i++) {\n\t\t\tmappedObj[keys[i]] = fn(keys[i], obj[keys[i]]);\n\t\t}\n\t\treturn mappedObj;\n\t}\n\n\t/**\n\t * Checks if the two given objects are equal. This is done via a shallow\n\t * check, including only the keys directly contained by the 2 objects.\n\t * @return {boolean}\n\t */\n\tstatic shallowEqual(obj1, obj2) {\n\t\tif (obj1 === obj2) {\n\t\t\treturn true;\n\t\t}\n\n\t\tvar keys1 = Object.keys(obj1);\n\t\tvar keys2 = Object.keys(obj2);\n\t\tif (keys1.length !== keys2.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (var i = 0; i < keys1.length; i++) {\n\t\t\tif (obj1[keys1[i]] !== obj2[keys1[i]]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n\nexport default object;\n","'use strict';\n\nclass string {\n\t/**\n\t * Removes the breaking spaces from the left and right of the string and\n\t * collapses the sequences of breaking spaces in the middle into single spaces.\n\t * The original and the result strings render the same way in HTML.\n\t * @param {string} str A string in which to collapse spaces.\n\t * @return {string} Copy of the string with normalized breaking spaces.\n\t */\n\tstatic collapseBreakingSpaces(str) {\n\t\treturn str.replace(/[\\t\\r\\n ]+/g, ' ').replace(/^[\\t\\r\\n ]+|[\\t\\r\\n ]+$/g, '');\n\t}\n\n\t/**\n\t* Escapes characters in the string that are not safe to use in a RegExp.\n\t* @param {*} str The string to escape. If not a string, it will be casted\n\t* to one.\n\t* @return {string} A RegExp safe, escaped copy of {@code s}.\n\t*/\n\tstatic escapeRegex(str) {\n\t\treturn String(str)\n\t\t\t.replace(/([-()\\[\\]{}+?*.$\\^|,:#>}\n\t\t * @protected\n\t\t */\n\t\tthis.events_ = [];\n\n\t\t/**\n\t\t * The maximum number of listeners allowed for each event type. If the number\n\t\t * becomes higher than the max, a warning will be issued.\n\t\t * @type {number}\n\t\t * @protected\n\t\t */\n\t\tthis.maxListeners_ = 10;\n\n\t\t/**\n\t\t * Configuration option which determines if an event facade should be sent\n\t\t * as a param of listeners when emitting events. If set to true, the facade\n\t\t * will be passed as the first argument of the listener.\n\t\t * @type {boolean}\n\t\t * @protected\n\t\t */\n\t\tthis.shouldUseFacade_ = false;\n\t}\n\n\t/**\n\t * Adds a listener to the end of the listeners array for the specified events.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @param {boolean} opt_default Flag indicating if this listener is a default\n\t * action for this event. Default actions are run last, and only if no previous\n\t * listener call `preventDefault()` on the received event facade.\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t */\n\taddListener(events, listener, opt_default) {\n\t\tthis.validateListener_(listener);\n\n\t\tevents = this.normalizeEvents_(events);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tthis.addSingleListener_(events[i], listener, opt_default);\n\t\t}\n\n\t\treturn new EventHandle(this, events, listener);\n\t}\n\n\t/**\n\t * Adds a listener to the end of the listeners array for a single event.\n\t * @param {string} event\n\t * @param {!Function} listener\n\t * @param {boolean} opt_default Flag indicating if this listener is a default\n\t * action for this event. Default actions are run last, and only if no previous\n\t * listener call `preventDefault()` on the received event facade.\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t * @param {Function=} opt_origin The original function that was added as a\n\t * listener, if there is any.\n\t * @protected\n\t */\n\taddSingleListener_(event, listener, opt_default, opt_origin) {\n\t\tthis.emit('newListener', event, listener);\n\n\t\tif (!this.events_[event]) {\n\t\t\tthis.events_[event] = [];\n\t\t}\n\t\tthis.events_[event].push({\n\t\t\tdefault: opt_default,\n\t\t\tfn: listener,\n\t\t\torigin: opt_origin\n\t\t});\n\n\t\tvar listeners = this.events_[event];\n\t\tif (listeners.length > this.maxListeners_ && !listeners.warned) {\n\t\t\tconsole.warn(\n\t\t\t\t'Possible EventEmitter memory leak detected. %d listeners added ' +\n\t\t\t\t'for event %s. Use emitter.setMaxListeners() to increase limit.',\n\t\t\t\tlisteners.length,\n\t\t\t\tevent\n\t\t\t);\n\t\t\tlisteners.warned = true;\n\t\t}\n\t}\n\n\t/**\n\t * Disposes of this instance's object references.\n\t * @override\n\t */\n\tdisposeInternal() {\n\t\tthis.events_ = [];\n\t}\n\n\t/**\n\t * Execute each of the listeners in order with the supplied arguments.\n\t * @param {string} event\n\t * @param {*} opt_args [arg1], [arg2], [...]\n\t * @return {boolean} Returns true if event had listeners, false otherwise.\n\t */\n\temit(event) {\n\t\tvar args = array.slice(arguments, 1);\n\t\tvar listeners = (this.events_[event] || []).concat();\n\n\t\tvar facade;\n\t\tif (this.getShouldUseFacade()) {\n\t\t\tfacade = {\n\t\t\t\tpreventDefault: function() {\n\t\t\t\t\tfacade.preventedDefault = true;\n\t\t\t\t},\n\t\t\t\ttarget: this,\n\t\t\t\ttype: event\n\t\t\t};\n\t\t\targs.push(facade);\n\t\t}\n\n\t\tvar defaultListeners = [];\n\t\tfor (var i = 0; i < listeners.length; i++) {\n\t\t\tif (listeners[i].default) {\n\t\t\t\tdefaultListeners.push(listeners[i]);\n\t\t\t} else {\n\t\t\t\tlisteners[i].fn.apply(this, args);\n\t\t\t}\n\t\t}\n\t\tif (!facade || !facade.preventedDefault) {\n\t\t\tfor (var j = 0; j < defaultListeners.length; j++) {\n\t\t\t\tdefaultListeners[j].fn.apply(this, args);\n\t\t\t}\n\t\t}\n\n\n\t\tif (event !== '*') {\n\t\t\tthis.emit.apply(this, ['*', event].concat(args));\n\t\t}\n\n\t\treturn listeners.length > 0;\n\t}\n\n\t/**\n\t * Gets the configuration option which determines if an event facade should\n\t * be sent as a param of listeners when emitting events. If set to true, the\n\t * facade will be passed as the first argument of the listener.\n\t * @return {boolean}\n\t */\n\tgetShouldUseFacade() {\n\t\treturn this.shouldUseFacade_;\n\t}\n\n\t/**\n\t * Returns an array of listeners for the specified event.\n\t * @param {string} event\n\t * @return {Array} Array of listeners.\n\t */\n\tlisteners(event) {\n\t\treturn (this.events_[event] || []).map(listener => listener.fn);\n\t}\n\n\t/**\n\t * Adds a listener that will be invoked a fixed number of times for the\n\t * events. After each event is triggered the specified amount of times, the\n\t * listener is removed for it.\n\t * @param {!(Array|string)} events\n\t * @param {number} amount The amount of times this event should be listened\n\t * to.\n\t * @param {!Function} listener\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t */\n\tmany(events, amount, listener) {\n\t\tevents = this.normalizeEvents_(events);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tthis.many_(events[i], amount, listener);\n\t\t}\n\n\t\treturn new EventHandle(this, events, listener);\n\t}\n\n\t/**\n\t * Adds a listener that will be invoked a fixed number of times for a single\n\t * event. After the event is triggered the specified amount of times, the\n\t * listener is removed.\n\t * @param {string} event\n\t * @param {number} amount The amount of times this event should be listened\n\t * to.\n\t * @param {!Function} listener\n\t * @protected\n\t */\n\tmany_(event, amount, listener) {\n\t\tvar self = this;\n\n\t\tif (amount <= 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction handlerInternal() {\n\t\t\tif (--amount === 0) {\n\t\t\t\tself.removeListener(event, handlerInternal);\n\t\t\t}\n\t\t\tlistener.apply(self, arguments);\n\t\t}\n\n\t\tself.addSingleListener_(event, handlerInternal, false, listener);\n\t}\n\n\t/**\n\t * Checks if a listener object matches the given listener function. To match,\n\t * it needs to either point to that listener or have it as its origin.\n\t * @param {!Object} listenerObj\n\t * @param {!Function} listener\n\t * @return {boolean}\n\t * @protected\n\t */\n\tmatchesListener_(listenerObj, listener) {\n\t\treturn listenerObj.fn === listener ||\n\t\t\t(listenerObj.origin && listenerObj.origin === listener);\n\t}\n\n\t/**\n\t * Converts the parameter to an array if only one event is given.\n\t * @param {!(Array|string)} events\n\t * @return {!Array}\n\t * @protected\n\t */\n\tnormalizeEvents_(events) {\n\t\treturn core.isString(events) ? [events] : events;\n\t}\n\n\t/**\n\t * Removes a listener for the specified events.\n\t * Caution: changes array indices in the listener array behind the listener.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\toff(events, listener) {\n\t\tthis.validateListener_(listener);\n\n\t\tevents = this.normalizeEvents_(events);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tvar listenerObjs = this.events_[events[i]] || [];\n\t\t\tthis.removeMatchingListenerObjs_(listenerObjs, listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener to the end of the listeners array for the specified events.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t */\n\ton() {\n\t\treturn this.addListener.apply(this, arguments);\n\t}\n\n\t/**\n\t * Adds a one time listener for the events. This listener is invoked only the\n\t * next time each event is fired, after which it is removed.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t */\n\tonce(events, listener) {\n\t\treturn this.many(events, 1, listener);\n\t}\n\n\t/**\n\t * Removes all listeners, or those of the specified events. It's not a good\n\t * idea to remove listeners that were added elsewhere in the code,\n\t * especially when it's on an emitter that you didn't create.\n\t * @param {(Array|string)=} opt_events\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\tremoveAllListeners(opt_events) {\n\t\tif (opt_events) {\n\t\t\tvar events = this.normalizeEvents_(opt_events);\n\t\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\t\tthis.events_[events[i]] = null;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.events_ = {};\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes all listener objects from the given array that match the given\n\t * listener function.\n\t * @param {!Array.} listenerObjs\n\t * @param {!Function} listener\n\t * @protected\n\t */\n\tremoveMatchingListenerObjs_(listenerObjs, listener) {\n\t\tfor (var i = listenerObjs.length - 1; i >= 0; i--) {\n\t\t\tif (this.matchesListener_(listenerObjs[i], listener)) {\n\t\t\t\tlistenerObjs.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes a listener for the specified events.\n\t * Caution: changes array indices in the listener array behind the listener.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\tremoveListener() {\n\t\treturn this.off.apply(this, arguments);\n\t}\n\n\t/**\n\t * By default EventEmitters will print a warning if more than 10 listeners\n\t * are added for a particular event. This is a useful default which helps\n\t * finding memory leaks. Obviously not all Emitters should be limited to 10.\n\t * This function allows that to be increased. Set to zero for unlimited.\n\t * @param {number} max The maximum number of listeners.\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\tsetMaxListeners(max) {\n\t\tthis.maxListeners_ = max;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the configuration option which determines if an event facade should\n\t * be sent as a param of listeners when emitting events. If set to true, the\n\t * facade will be passed as the first argument of the listener.\n\t * @param {boolean} shouldUseFacade\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\tsetShouldUseFacade(shouldUseFacade) {\n\t\tthis.shouldUseFacade_ = shouldUseFacade;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Checks if the given listener is valid, throwing an exception when it's not.\n\t * @param {*} listener\n\t * @protected\n\t */\n\tvalidateListener_(listener) {\n\t\tif (!core.isFunction(listener)) {\n\t\t\tthrow new TypeError('Listener must be a function');\n\t\t}\n\t}\n}\n\nexport default EventEmitter;\n","'use strict';\n\nimport { array, Disposable } from 'metal';\n\n/**\n * EventEmitterProxy utility. It's responsible for linking two EventEmitter\n * instances together, emitting events from the first emitter through the\n * second one. That means that listening to a supported event on the target\n * emitter will mean listening to it on the origin emitter as well.\n * @param {EventEmitter} originEmitter Events originated on this emitter\n * will be fired for the target emitter's listeners as well.\n * @param {EventEmitter} targetEmitter Event listeners attached to this emitter\n * will also be triggered when the event is fired by the origin emitter.\n * @param {Object} opt_blacklist Optional blacklist of events that should not be\n * proxied.\n * @constructor\n * @extends {Disposable}\n */\nclass EventEmitterProxy extends Disposable {\n\tconstructor(originEmitter, targetEmitter, opt_blacklist, opt_whitelist) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Map of events that should not be proxied.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.blacklist_ = opt_blacklist || {};\n\n\t\t/**\n\t\t * The origin emitter. This emitter's events will be proxied through the\n\t\t * target emitter.\n\t\t * @type {EventEmitter}\n\t\t * @protected\n\t\t */\n\t\tthis.originEmitter_ = originEmitter;\n\n\t\t/**\n\t\t * A list of events that are pending to be listened by an actual origin\n\t\t * emitter. Events are stored here when the origin doesn't exist, so they\n\t\t * can be set on a new origin when one is set.\n\t\t * @type {!Array}\n\t\t * @protected\n\t\t */\n\t\tthis.pendingEvents_ = [];\n\n\t\t/**\n\t\t * Holds a map of events from the origin emitter that are already being proxied.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.proxiedEvents_ = {};\n\n\t\t/**\n\t\t * The target emitter. This emitter will emit all events that come from\n\t\t * the origin emitter.\n\t\t * @type {EventEmitter}\n\t\t * @protected\n\t\t */\n\t\tthis.targetEmitter_ = targetEmitter;\n\n\t\t/**\n\t\t * Map of events that should be proxied. If whitelist is set blacklist is ignored.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.whitelist_ = opt_whitelist;\n\n\t\tthis.startProxy_();\n\t}\n\n\t/**\n\t * Adds the given listener for the given event.\n\t * @param {string} event\n\t * @param {!function()} listener\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t */\n\taddListener_(event, listener) {\n\t\treturn this.originEmitter_.on(event, listener);\n\t}\n\n\t/**\n\t * Adds the proxy listener for the given event.\n\t * @param {string} event\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t */\n\taddListenerForEvent_(event) {\n\t\treturn this.addListener_(event, this.emitOnTarget_.bind(this, event));\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tthis.removeListeners_();\n\t\tthis.proxiedEvents_ = null;\n\t\tthis.originEmitter_ = null;\n\t\tthis.targetEmitter_ = null;\n\t}\n\n\t/**\n\t * Emits the specified event type on the target emitter.\n\t * @param {string} eventType\n\t * @protected\n\t */\n\temitOnTarget_(eventType) {\n\t\tvar args = [eventType].concat(array.slice(arguments, 1));\n\t\tthis.targetEmitter_.emit.apply(this.targetEmitter_, args);\n\t}\n\n\t/**\n\t * Proxies the given event from the origin to the target emitter.\n\t * @param {string} event\n\t */\n\tproxyEvent(event) {\n\t\tif (this.shouldProxyEvent_(event)) {\n\t\t\tthis.tryToAddListener_(event);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the proxy listener for all events.\n\t * @protected\n\t */\n\tremoveListeners_() {\n\t\tvar events = Object.keys(this.proxiedEvents_);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tthis.proxiedEvents_[events[i]].removeListener();\n\t\t}\n\t\tthis.proxiedEvents_ = {};\n\t\tthis.pendingEvents_ = [];\n\t}\n\n\t/**\n\t * Changes the origin emitter. This automatically detaches any events that\n\t * were already being proxied from the previous emitter, and starts proxying\n\t * them on the new emitter instead.\n\t * @param {!EventEmitter} originEmitter\n\t */\n\tsetOriginEmitter(originEmitter) {\n\t\tvar events = this.originEmitter_?\n\t\t\tObject.keys(this.proxiedEvents_) :\n\t\t\tthis.pendingEvents_;\n\t\tthis.removeListeners_();\n\t\tthis.originEmitter_ = originEmitter;\n\t\tevents.forEach(event => this.proxyEvent(event));\n\t}\n\n\t/**\n\t * Checks if the given event should be proxied.\n\t * @param {string} event\n\t * @return {boolean}\n\t * @protected\n\t */\n\tshouldProxyEvent_(event) {\n\t\tif (this.whitelist_ && !this.whitelist_[event]) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.blacklist_[event]) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !this.proxiedEvents_[event];\n\t}\n\n\t/**\n\t * Starts proxying all events from the origin to the target emitter.\n\t * @protected\n\t */\n\tstartProxy_() {\n\t\tthis.targetEmitter_.on('newListener', this.proxyEvent.bind(this));\n\t}\n\n\t/**\n\t * Adds a listener to the origin emitter, if it exists. Otherwise, stores\n\t * the pending listener so it can be used on a future origin emitter.\n\t * @param {string} event\n\t * @protected\n\t */\n\ttryToAddListener_(event) {\n\t\tif (this.originEmitter_) {\n\t\t\tthis.proxiedEvents_[event] = this.addListenerForEvent_(event);\n\t\t} else {\n\t\t\tthis.pendingEvents_.push(event);\n\t\t}\n\t}\n}\n\nexport default EventEmitterProxy;\n","'use strict';\n\nimport { Disposable } from 'metal';\n\n/**\n * EventHandler utility. It's useful for easily removing a group of\n * listeners from different EventEmitter instances.\n * @constructor\n * @extends {Disposable}\n */\nclass EventHandler extends Disposable {\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * An array that holds the added event handles, so the listeners can be\n\t\t * removed later.\n\t\t * @type {Array.}\n\t\t * @protected\n\t\t */\n\t\tthis.eventHandles_ = [];\n\t}\n\n\t/**\n\t * Adds event handles to be removed later through the `removeAllListeners`\n\t * method.\n\t * @param {...(!EventHandle)} var_args\n\t */\n\tadd() {\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tthis.eventHandles_.push(arguments[i]);\n\t\t}\n\t}\n\n\t/**\n\t * Disposes of this instance's object references.\n\t * @override\n\t */\n\tdisposeInternal() {\n\t\tthis.eventHandles_ = null;\n\t}\n\n\t/**\n\t * Removes all listeners that have been added through the `add` method.\n\t */\n\tremoveAllListeners() {\n\t\tfor (var i = 0; i < this.eventHandles_.length; i++) {\n\t\t\tthis.eventHandles_[i].removeListener();\n\t\t}\n\n\t\tthis.eventHandles_ = [];\n\t}\n}\n\nexport default EventHandler;\n","'use strict';\n\nimport dom from './dom';\nimport features from './features';\n\nvar mouseEventMap = {\n\tmouseenter: 'mouseover',\n\tmouseleave: 'mouseout',\n\tpointerenter: 'pointerover',\n\tpointerleave: 'pointerout'\n};\nObject.keys(mouseEventMap).forEach(function(eventName) {\n\tdom.registerCustomEvent(eventName, {\n\t\tdelegate: true,\n\t\thandler: function(callback, event) {\n\t\t\tvar related = event.relatedTarget;\n\t\t\tvar target = event.delegateTarget;\n\t\t\tif (!related || (related !== target && !target.contains(related))) {\n\t\t\t\tevent.customType = eventName;\n\t\t\t\treturn callback(event);\n\t\t\t}\n\t\t},\n\t\toriginalEvent: mouseEventMap[eventName]\n\t});\n});\n\nvar animationEventMap = {\n\tanimation: 'animationend',\n\ttransition: 'transitionend'\n};\nObject.keys(animationEventMap).forEach(function(eventType) {\n\tvar eventName = animationEventMap[eventType];\n\tdom.registerCustomEvent(eventName, {\n\t\tevent: true,\n\t\tdelegate: true,\n\t\thandler: function(callback, event) {\n\t\t\tevent.customType = eventName;\n\t\t\treturn callback(event);\n\t\t},\n\t\toriginalEvent: features.checkAnimationEventName()[eventType]\n\t});\n});\n","'use strict';\n\nimport { array, core } from 'metal';\nimport domData from './domData';\nimport { EventHandle } from 'metal-events';\n\n/**\n * This is a special EventHandle, that is responsible for dom delegated events\n * (only the ones that receive a target element, not a selector string).\n * @extends {EventHandle}\n */\nclass DomDelegatedEventHandle extends EventHandle {\n\t/**\n\t * The constructor for `DomDelegatedEventHandle`.\n\t * @param {!Event} emitter Element the event was subscribed to.\n\t * @param {string} event The name of the event that was subscribed to.\n\t * @param {!Function} listener The listener subscribed to the event.\n\t * @param {string=} opt_selector An optional selector used when delegating\n\t * the event.\n\t * @constructor\n\t */\n\tconstructor(emitter, event, listener, opt_selector) {\n\t\tsuper(emitter, event, listener);\n\t\tthis.selector_ = opt_selector;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tremoveListener() {\n\t\tvar data = domData.get(this.emitter_);\n\t\tvar selector = this.selector_;\n\t\tvar arr = core.isString(selector) ? data.delegating[this.event_].selectors : data.listeners;\n\t\tvar key = core.isString(selector) ? selector : this.event_;\n\n\t\tarray.remove(arr[key] || [], this.listener_);\n\t\tif (arr[key] && arr[key].length === 0) {\n\t\t\tdelete arr[key];\n\t\t}\n\t}\n}\n\nexport default DomDelegatedEventHandle;\n","'use strict';\n\nimport { EventHandle } from 'metal-events';\n\n/**\n * This is a special EventHandle, that is responsible for dom events, instead\n * of EventEmitter events.\n * @extends {EventHandle}\n */\nclass DomEventHandle extends EventHandle {\n\t/**\n\t * The constructor for `DomEventHandle`.\n\t * @param {!EventEmitter} emitter Emitter the event was subscribed to.\n\t * @param {string} event The name of the event that was subscribed to.\n\t * @param {!Function} listener The listener subscribed to the event.\n\t * @param {boolean} opt_capture Flag indicating if listener should be triggered\n\t * during capture phase, instead of during the bubbling phase. Defaults to false.\n\t * @constructor\n\t */\n\tconstructor(emitter, event, listener, opt_capture) {\n\t\tsuper(emitter, event, listener);\n\t\tthis.capture_ = opt_capture;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tremoveListener() {\n\t\tthis.emitter_.removeEventListener(this.event_, this.listener_, this.capture_);\n\t}\n}\n\nexport default DomEventHandle;\n","'use strict';\n\nimport dom from '../dom';\nimport domData from '../domData';\nimport DomEventEmitterProxy from '../DomEventEmitterProxy';\nimport DomEventHandle from '../DomEventHandle';\nimport features from '../features';\nimport globalEval from '../globalEval';\nimport globalEvalStyles from '../globalEvalStyles';\nimport '../events';\n\nexport default dom;\nexport { dom, domData, DomEventEmitterProxy, DomEventHandle, features, globalEval, globalEvalStyles };\n","'use strict';\n\nimport dom from './dom';\nimport { EventEmitterProxy } from 'metal-events';\n\n/**\n * DomEventEmitterProxy utility. It extends `EventEmitterProxy` to also accept\n * dom elements as origin emitters.\n * @extends {EventEmitterProxy}\n */\nclass DomEventEmitterProxy extends EventEmitterProxy {\n\t/**\n\t * Adds the given listener for the given event.\n\t * @param {string} event.\n\t * @param {!function()} listener\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t * @override\n\t */\n\taddListener_(event, listener) {\n\t\tif (this.originEmitter_.addEventListener) {\n\t\t\tif (this.isDelegateEvent_(event)) {\n\t\t\t\tvar index = event.indexOf(':', 9);\n\t\t\t\tvar eventName = event.substring(9, index);\n\t\t\t\tvar selector = event.substring(index + 1);\n\t\t\t\treturn dom.delegate(this.originEmitter_, eventName, selector, listener);\n\t\t\t} else {\n\t\t\t\treturn dom.on(this.originEmitter_, event, listener);\n\t\t\t}\n\t\t} else {\n\t\t\treturn super.addListener_(event, listener);\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the given event is of the delegate type.\n\t * @param {string} event\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisDelegateEvent_(event) {\n\t\treturn event.substr(0, 9) === 'delegate:';\n\t}\n\n\t/**\n\t * Checks if the given event is supported by the origin element.\n\t * @param {string} event\n\t * @protected\n\t */\n\tisSupportedDomEvent_(event) {\n\t\tif (!this.originEmitter_ || !this.originEmitter_.addEventListener) {\n\t\t\treturn true;\n\t\t}\n\t\treturn (this.isDelegateEvent_(event) && event.indexOf(':', 9) !== -1) ||\n\t\t\tdom.supportsEvent(this.originEmitter_, event);\n\t}\n\n\t/**\n\t * Checks if the given event should be proxied.\n\t * @param {string} event\n\t * @return {boolean}\n\t * @protected\n\t * @override\n\t */\n\tshouldProxyEvent_(event) {\n\t\treturn super.shouldProxyEvent_(event) && this.isSupportedDomEvent_(event);\n\t}\n}\n\nexport default DomEventEmitterProxy;\n","'use strict';\n\nimport dom from './dom';\nimport { string } from 'metal';\n\n/**\n * Class with static methods responsible for doing browser feature checks.\n */\nclass features {\n\t/**\n\t * Some browsers still supports prefixed animation events. This method can\n\t * be used to retrieve the current browser event name for both, animation\n\t * and transition.\n\t * @return {object}\n\t */\n\tstatic checkAnimationEventName() {\n\t\tif (features.animationEventName_ === undefined) {\n\t\t\tfeatures.animationEventName_ = {\n\t\t\t\tanimation: features.checkAnimationEventName_('animation'),\n\t\t\t\ttransition: features.checkAnimationEventName_('transition')\n\t\t\t};\n\t\t}\n\t\treturn features.animationEventName_;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {string} type Type to test: animation, transition.\n\t * @return {string} Browser event name.\n\t */\n\tstatic checkAnimationEventName_(type) {\n\t\tvar prefixes = ['Webkit', 'MS', 'O', ''];\n\t\tvar typeTitleCase = string.replaceInterval(type, 0, 1, type.substring(0, 1).toUpperCase());\n\t\tvar suffixes = [typeTitleCase + 'End', typeTitleCase + 'End', typeTitleCase + 'End', type + 'end'];\n\t\tfor (var i = 0; i < prefixes.length; i++) {\n\t\t\tif (features.animationElement_.style[prefixes[i] + typeTitleCase] !== undefined) {\n\t\t\t\treturn prefixes[i].toLowerCase() + suffixes[i];\n\t\t\t}\n\t\t}\n\t\treturn type + 'end';\n\t}\n\n\t/**\n\t * Some browsers (like IE9) change the order of element attributes, when html\n\t * is rendered. This method can be used to check if this behavior happens on\n\t * the current browser.\n\t * @return {boolean}\n\t */\n\tstatic checkAttrOrderChange() {\n\t\tif (features.attrOrderChange_ === undefined) {\n\t\t\tvar originalContent = '
';\n\t\t\tvar element = document.createElement('div');\n\t\t\tdom.append(element, originalContent);\n\t\t\tfeatures.attrOrderChange_ = originalContent !== element.innerHTML;\n\t\t}\n\t\treturn features.attrOrderChange_;\n\t}\n}\n\nfeatures.animationElement_ = document.createElement('div');\nfeatures.animationEventName_ = undefined;\nfeatures.attrOrderChange_ = undefined;\n\nexport default features;\n","'use strict';\n\nimport { async } from 'metal';\nimport dom from './dom';\n\n/**\n * Utility functions for running javascript code in the global scope.\n */\nclass globalEval {\n\t/**\n\t * Evaluates the given string in the global scope.\n\t * @param {string} text\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} script\n\t */\n\tstatic run(text, opt_appendFn) {\n\t\tvar script = document.createElement('script');\n\t\tscript.text = text;\n\t\tif (opt_appendFn) {\n\t\t\topt_appendFn(script);\n\t\t} else {\n\t\t\tdocument.head.appendChild(script);\n\t\t}\n\t\tdom.exitDocument(script);\n\t\treturn script;\n\t}\n\n\t/**\n\t * Evaluates the given javascript file in the global scope.\n\t * @param {string} src The file's path.\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} script\n\t */\n\tstatic runFile(src, opt_callback, opt_appendFn) {\n\t\tvar script = document.createElement('script');\n\t\tscript.src = src;\n\n\t\tvar callback = function() {\n\t\t\tdom.exitDocument(script);\n\t\t\topt_callback && opt_callback();\n\t\t};\n\t\tdom.once(script, 'load', callback);\n\t\tdom.once(script, 'error', callback);\n\n\t\tif (opt_appendFn) {\n\t\t\topt_appendFn(script);\n\t\t} else {\n\t\t\tdocument.head.appendChild(script);\n\t\t}\n\n\t\treturn script;\n\t}\n\n\t/**\n\t * Evaluates the code referenced by the given script element.\n\t * @param {!Element} script\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} script\n\t */\n\tstatic runScript(script, opt_callback, opt_appendFn) {\n\t\tvar callback = function() {\n\t\t\topt_callback && opt_callback();\n\t\t};\n\t\tif (script.type && script.type !== 'text/javascript') {\n\t\t\tasync.nextTick(callback);\n\t\t\treturn;\n\t\t}\n\t\tdom.exitDocument(script);\n\t\tif (script.src) {\n\t\t\treturn globalEval.runFile(script.src, opt_callback, opt_appendFn);\n\t\t} else {\n\t\t\tasync.nextTick(callback);\n\t\t\treturn globalEval.run(script.text, opt_appendFn);\n\t\t}\n\t}\n\n\t/**\n\t * Evaluates any script tags present in the given element.\n\t * @params {!Element} element\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t */\n\tstatic runScriptsInElement(element, opt_callback, opt_appendFn) {\n\t\tvar scripts = element.querySelectorAll('script');\n\t\tif (scripts.length) {\n\t\t\tglobalEval.runScriptsInOrder(scripts, 0, opt_callback, opt_appendFn);\n\t\t} else if (opt_callback) {\n\t\t\tasync.nextTick(opt_callback);\n\t\t}\n\t}\n\n\t/**\n\t * Runs the given scripts elements in the order that they appear.\n\t * @param {!NodeList} scripts\n\t * @param {number} index\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t */\n\tstatic runScriptsInOrder(scripts, index, opt_callback, opt_appendFn) {\n\t\tglobalEval.runScript(scripts.item(index), function() {\n\t\t\tif (index < scripts.length - 1) {\n\t\t\t\tglobalEval.runScriptsInOrder(scripts, index + 1, opt_callback, opt_appendFn);\n\t\t\t} else if (opt_callback) {\n\t\t\t\tasync.nextTick(opt_callback);\n\t\t\t}\n\t\t}, opt_appendFn);\n\t}\n}\n\nexport default globalEval;\n","'use strict';\n\nimport { async } from 'metal';\nimport dom from './dom';\n\n/**\n * Utility functions for running styles.\n */\nclass globalEvalStyles {\n\t/**\n\t * Evaluates the given style.\n\t * @param {string} text\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} style\n\t */\n\tstatic run(text, opt_appendFn) {\n\t\tvar style = document.createElement('style');\n\t\tstyle.innerHTML = text;\n\t\tif (opt_appendFn) {\n\t\t\topt_appendFn(style);\n\t\t} else {\n\t\t\tdocument.head.appendChild(style);\n\t\t}\n\t\treturn style;\n\t}\n\n\t/**\n\t * Evaluates the given style file.\n\t * @param {string} href The file's path.\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the styles has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} style\n\t */\n\tstatic runFile(href, opt_callback, opt_appendFn) {\n\t\tvar link = document.createElement('link');\n\t\tlink.rel = 'stylesheet';\n\t\tlink.href = href;\n\t\tglobalEvalStyles.runStyle(link, opt_callback, opt_appendFn);\n\t\treturn link;\n\t}\n\n\t/**\n\t * Evaluates the code referenced by the given style/link element.\n\t * @param {!Element} style\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} style\n\t */\n\tstatic runStyle(style, opt_callback, opt_appendFn) {\n\t\tvar callback = function() {\n\t\t\topt_callback && opt_callback();\n\t\t};\n\t\tif (style.rel && style.rel !== 'stylesheet') {\n\t\t\tasync.nextTick(callback);\n\t\t\treturn;\n\t\t}\n\n\t\tif (style.tagName === 'STYLE') {\n\t\t\tasync.nextTick(callback);\n\t\t} else {\n\t\t\tdom.once(style, 'load', callback);\n\t\t\tdom.once(style, 'error', callback);\n\t\t}\n\n\t\tif (opt_appendFn) {\n\t\t\topt_appendFn(style);\n\t\t} else {\n\t\t\tdocument.head.appendChild(style);\n\t\t}\n\n\t\treturn style;\n\t}\n\n\t/**\n\t * Evaluates any style present in the given element.\n\t * @params {!Element} element\n\t * @param {function()=} opt_callback Optional function to be called when the\n\t * style has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t */\n\tstatic runStylesInElement(element, opt_callback, opt_appendFn) {\n\t\tvar styles = element.querySelectorAll('style,link');\n\t\tif (styles.length === 0 && opt_callback) {\n\t\t\tasync.nextTick(opt_callback);\n\t\t\treturn;\n\t\t}\n\n\t\tvar loadCount = 0;\n\t\tvar callback = function() {\n\t\t\tif (opt_callback && ++loadCount === styles.length) {\n\t\t\t\tasync.nextTick(opt_callback);\n\t\t\t}\n\t\t};\n\t\tfor (var i = 0; i < styles.length; i++) {\n\t\t\tglobalEvalStyles.runStyle(styles[i], callback, opt_appendFn);\n\t\t}\n\t}\n}\n\nexport default globalEvalStyles;\n","/*!\n * Promises polyfill from Google's Closure Library.\n *\n * Copyright 2013 The Closure Library Authors. All Rights Reserved.\n *\n * NOTE(eduardo): Promise support is not ready on all supported browsers,\n * therefore core.js is temporarily using Google's promises as polyfill. It\n * supports cancellable promises and has clean and fast implementation.\n */\n\n'use strict';\n\nimport { core } from 'metal';\nimport { async } from 'metal';\n\n/**\n * Provides a more strict interface for Thenables in terms of\n * http://promisesaplus.com for interop with {@see CancellablePromise}.\n *\n * @interface\n * @extends {IThenable.}\n * @template TYPE\n */\nvar Thenable = function() {};\n\n/**\n * Adds callbacks that will operate on the result of the Thenable, returning a\n * new child Promise.\n *\n * If the Thenable is fulfilled, the {@code onFulfilled} callback will be\n * invoked with the fulfillment value as argument, and the child Promise will\n * be fulfilled with the return value of the callback. If the callback throws\n * an exception, the child Promise will be rejected with the thrown value\n * instead.\n *\n * If the Thenable is rejected, the {@code onRejected} callback will be invoked\n * with the rejection reason as argument, and the child Promise will be rejected\n * with the return value of the callback or thrown value.\n *\n * @param {?(function(this:THIS, TYPE):\n * (RESULT|IThenable.|Thenable))=} opt_onFulfilled A\n * function that will be invoked with the fulfillment value if the Promise\n * is fullfilled.\n * @param {?(function(*): *)=} opt_onRejected A function that will be invoked\n * with the rejection reason if the Promise is rejected.\n * @param {THIS=} opt_context An optional context object that will be the\n * execution context for the callbacks. By default, functions are executed\n * with the default this.\n * @return {!CancellablePromise.} A new Promise that will receive the\n * result of the fulfillment or rejection callback.\n * @template RESULT,THIS\n */\nThenable.prototype.then = function() {};\n\n\n/**\n * An expando property to indicate that an object implements\n * {@code Thenable}.\n *\n * {@see addImplementation}.\n *\n * @const\n */\nThenable.IMPLEMENTED_BY_PROP = '$goog_Thenable';\n\n\n/**\n * Marks a given class (constructor) as an implementation of Thenable, so\n * that we can query that fact at runtime. The class must have already\n * implemented the interface.\n * Exports a 'then' method on the constructor prototype, so that the objects\n * also implement the extern {@see Thenable} interface for interop with\n * other Promise implementations.\n * @param {function(new:Thenable,...[?])} ctor The class constructor. The\n * corresponding class must have already implemented the interface.\n */\nThenable.addImplementation = function(ctor) {\n ctor.prototype.then = ctor.prototype.then;\n ctor.prototype.$goog_Thenable = true;\n};\n\n\n/**\n * @param {*} object\n * @return {boolean} Whether a given instance implements {@code Thenable}.\n * The class/superclass of the instance must call {@code addImplementation}.\n */\nThenable.isImplementedBy = function(object) {\n if (!object) {\n return false;\n }\n try {\n return !!object.$goog_Thenable;\n } catch (e) {\n // Property access seems to be forbidden.\n return false;\n }\n};\n\n\n/**\n * Like bind(), except that a 'this object' is not required. Useful when the\n * target function is already bound.\n *\n * Usage:\n * var g = partial(f, arg1, arg2);\n * g(arg3, arg4);\n *\n * @param {Function} fn A function to partially apply.\n * @param {...*} var_args Additional arguments that are partially applied to fn.\n * @return {!Function} A partially-applied form of the function bind() was\n * invoked as a method of.\n */\nvar partial = function(fn) {\n var args = Array.prototype.slice.call(arguments, 1);\n return function() {\n // Clone the array (with slice()) and append additional arguments\n // to the existing arguments.\n var newArgs = args.slice();\n newArgs.push.apply(newArgs, arguments);\n return fn.apply(this, newArgs);\n };\n};\n\n/**\n * Promises provide a result that may be resolved asynchronously. A Promise may\n * be resolved by being fulfilled or rejected with a value, which will be known\n * as the fulfillment value or the rejection reason. Whether fulfilled or\n * rejected, the Promise result is immutable once it is set.\n *\n * Promises may represent results of any type, including undefined. Rejection\n * reasons are typically Errors, but may also be of any type. Closure Promises\n * allow for optional type annotations that enforce that fulfillment values are\n * of the appropriate types at compile time.\n *\n * The result of a Promise is accessible by calling {@code then} and registering\n * {@code onFulfilled} and {@code onRejected} callbacks. Once the Promise\n * resolves, the relevant callbacks are invoked with the fulfillment value or\n * rejection reason as argument. Callbacks are always invoked in the order they\n * were registered, even when additional {@code then} calls are made from inside\n * another callback. A callback is always run asynchronously sometime after the\n * scope containing the registering {@code then} invocation has returned.\n *\n * If a Promise is resolved with another Promise, the first Promise will block\n * until the second is resolved, and then assumes the same result as the second\n * Promise. This allows Promises to depend on the results of other Promises,\n * linking together multiple asynchronous operations.\n *\n * This implementation is compatible with the Promises/A+ specification and\n * passes that specification's conformance test suite. A Closure Promise may be\n * resolved with a Promise instance (or sufficiently compatible Promise-like\n * object) created by other Promise implementations. From the specification,\n * Promise-like objects are known as \"Thenables\".\n *\n * @see http://promisesaplus.com/\n *\n * @param {function(\n * this:RESOLVER_CONTEXT,\n * function((TYPE|IThenable.|Thenable)),\n * function(*)): void} resolver\n * Initialization function that is invoked immediately with {@code resolve}\n * and {@code reject} functions as arguments. The Promise is resolved or\n * rejected with the first argument passed to either function.\n * @param {RESOLVER_CONTEXT=} opt_context An optional context for executing the\n * resolver function. If unspecified, the resolver function will be executed\n * in the default scope.\n * @constructor\n * @struct\n * @final\n * @implements {Thenable.}\n * @template TYPE,RESOLVER_CONTEXT\n */\nvar CancellablePromise = function(resolver, opt_context) {\n /**\n * The internal state of this Promise. Either PENDING, FULFILLED, REJECTED, or\n * BLOCKED.\n * @private {CancellablePromise.State_}\n */\n this.state_ = CancellablePromise.State_.PENDING;\n\n /**\n * The resolved result of the Promise. Immutable once set with either a\n * fulfillment value or rejection reason.\n * @private {*}\n */\n this.result_ = undefined;\n\n /**\n * For Promises created by calling {@code then()}, the originating parent.\n * @private {CancellablePromise}\n */\n this.parent_ = null;\n\n /**\n * The list of {@code onFulfilled} and {@code onRejected} callbacks added to\n * this Promise by calls to {@code then()}.\n * @private {Array.}\n */\n this.callbackEntries_ = null;\n\n /**\n * Whether the Promise is in the queue of Promises to execute.\n * @private {boolean}\n */\n this.executing_ = false;\n\n if (CancellablePromise.UNHANDLED_REJECTION_DELAY > 0) {\n /**\n * A timeout ID used when the {@code UNHANDLED_REJECTION_DELAY} is greater\n * than 0 milliseconds. The ID is set when the Promise is rejected, and\n * cleared only if an {@code onRejected} callback is invoked for the\n * Promise (or one of its descendants) before the delay is exceeded.\n *\n * If the rejection is not handled before the timeout completes, the\n * rejection reason is passed to the unhandled rejection handler.\n * @private {number}\n */\n this.unhandledRejectionId_ = 0;\n } else if (CancellablePromise.UNHANDLED_REJECTION_DELAY === 0) {\n /**\n * When the {@code UNHANDLED_REJECTION_DELAY} is set to 0 milliseconds, a\n * boolean that is set if the Promise is rejected, and reset to false if an\n * {@code onRejected} callback is invoked for the Promise (or one of its\n * descendants). If the rejection is not handled before the next timestep,\n * the rejection reason is passed to the unhandled rejection handler.\n * @private {boolean}\n */\n this.hadUnhandledRejection_ = false;\n }\n\n try {\n var self = this;\n resolver.call(\n opt_context, function(value) {\n self.resolve_(CancellablePromise.State_.FULFILLED, value);\n }, function(reason) {\n self.resolve_(CancellablePromise.State_.REJECTED, reason);\n });\n } catch (e) {\n this.resolve_(CancellablePromise.State_.REJECTED, e);\n }\n};\n\n/**\n * The delay in milliseconds before a rejected Promise's reason is passed to\n * the rejection handler. By default, the rejection handler rethrows the\n * rejection reason so that it appears in the developer console or\n * {@code window.onerror} handler.\n * Rejections are rethrown as quickly as possible by default. A negative value\n * disables rejection handling entirely.\n * @type {number}\n */\nCancellablePromise.UNHANDLED_REJECTION_DELAY = 0;\n\n\n/**\n * The possible internal states for a Promise. These states are not directly\n * observable to external callers.\n * @enum {number}\n * @private\n */\nCancellablePromise.State_ = {\n /** The Promise is waiting for resolution. */\n PENDING: 0,\n\n /** The Promise is blocked waiting for the result of another Thenable. */\n BLOCKED: 1,\n\n /** The Promise has been resolved with a fulfillment value. */\n FULFILLED: 2,\n\n /** The Promise has been resolved with a rejection reason. */\n REJECTED: 3\n};\n\n\n/**\n * Typedef for entries in the callback chain. Each call to {@code then},\n * {@code thenCatch}, or {@code thenAlways} creates an entry containing the\n * functions that may be invoked once the Promise is resolved.\n *\n * @typedef {{\n * child: CancellablePromise,\n * onFulfilled: function(*),\n * onRejected: function(*)\n * }}\n * @private\n */\nCancellablePromise.CallbackEntry_ = null;\n\n\n/**\n * @param {(TYPE|Thenable.|Thenable)=} opt_value\n * @return {!CancellablePromise.} A new Promise that is immediately resolved\n * with the given value.\n * @template TYPE\n */\nCancellablePromise.resolve = function(opt_value) {\n return new CancellablePromise(function(resolve) {\n resolve(opt_value);\n });\n};\n\n\n/**\n * @param {*=} opt_reason\n * @return {!CancellablePromise} A new Promise that is immediately rejected with the\n * given reason.\n */\nCancellablePromise.reject = function(opt_reason) {\n return new CancellablePromise(function(resolve, reject) {\n reject(opt_reason);\n });\n};\n\n\n/**\n * @param {!Array.|Thenable)>} promises\n * @return {!CancellablePromise.} A Promise that receives the result of the\n * first Promise (or Promise-like) input to complete.\n * @template TYPE\n */\nCancellablePromise.race = function(promises) {\n return new CancellablePromise(function(resolve, reject) {\n if (!promises.length) {\n resolve(undefined);\n }\n for (var i = 0, promise; (promise = promises[i]); i++) {\n promise.then(resolve, reject);\n }\n });\n};\n\n\n/**\n * @param {!Array.|Thenable)>} promises\n * @return {!CancellablePromise.>} A Promise that receives a list of\n * every fulfilled value once every input Promise (or Promise-like) is\n * successfully fulfilled, or is rejected by the first rejection result.\n * @template TYPE\n */\nCancellablePromise.all = function(promises) {\n return new CancellablePromise(function(resolve, reject) {\n var toFulfill = promises.length;\n var values = [];\n\n if (!toFulfill) {\n resolve(values);\n return;\n }\n\n var onFulfill = function(index, value) {\n toFulfill--;\n values[index] = value;\n if (toFulfill === 0) {\n resolve(values);\n }\n };\n\n var onReject = function(reason) {\n reject(reason);\n };\n\n for (var i = 0, promise; (promise = promises[i]); i++) {\n promise.then(partial(onFulfill, i), onReject);\n }\n });\n};\n\n\n/**\n * @param {!Array.|Thenable)>} promises\n * @return {!CancellablePromise.} A Promise that receives the value of\n * the first input to be fulfilled, or is rejected with a list of every\n * rejection reason if all inputs are rejected.\n * @template TYPE\n */\nCancellablePromise.firstFulfilled = function(promises) {\n return new CancellablePromise(function(resolve, reject) {\n var toReject = promises.length;\n var reasons = [];\n\n if (!toReject) {\n resolve(undefined);\n return;\n }\n\n var onFulfill = function(value) {\n resolve(value);\n };\n\n var onReject = function(index, reason) {\n toReject--;\n reasons[index] = reason;\n if (toReject === 0) {\n reject(reasons);\n }\n };\n\n for (var i = 0, promise; (promise = promises[i]); i++) {\n promise.then(onFulfill, partial(onReject, i));\n }\n });\n};\n\n\n/**\n * Adds callbacks that will operate on the result of the Promise, returning a\n * new child Promise.\n *\n * If the Promise is fulfilled, the {@code onFulfilled} callback will be invoked\n * with the fulfillment value as argument, and the child Promise will be\n * fulfilled with the return value of the callback. If the callback throws an\n * exception, the child Promise will be rejected with the thrown value instead.\n *\n * If the Promise is rejected, the {@code onRejected} callback will be invoked\n * with the rejection reason as argument, and the child Promise will be rejected\n * with the return value (or thrown value) of the callback.\n *\n * @override\n */\nCancellablePromise.prototype.then = function(opt_onFulfilled, opt_onRejected, opt_context) {\n return this.addChildPromise_(\n core.isFunction(opt_onFulfilled) ? opt_onFulfilled : null,\n core.isFunction(opt_onRejected) ? opt_onRejected : null,\n opt_context);\n};\nThenable.addImplementation(CancellablePromise);\n\n\n/**\n * Adds a callback that will be invoked whether the Promise is fulfilled or\n * rejected. The callback receives no argument, and no new child Promise is\n * created. This is useful for ensuring that cleanup takes place after certain\n * asynchronous operations. Callbacks added with {@code thenAlways} will be\n * executed in the same order with other calls to {@code then},\n * {@code thenAlways}, or {@code thenCatch}.\n *\n * Since it does not produce a new child Promise, cancellation propagation is\n * not prevented by adding callbacks with {@code thenAlways}. A Promise that has\n * a cleanup handler added with {@code thenAlways} will be canceled if all of\n * its children created by {@code then} (or {@code thenCatch}) are canceled.\n *\n * @param {function(this:THIS): void} onResolved A function that will be invoked\n * when the Promise is resolved.\n * @param {THIS=} opt_context An optional context object that will be the\n * execution context for the callbacks. By default, functions are executed\n * in the global scope.\n * @return {!CancellablePromise.} This Promise, for chaining additional calls.\n * @template THIS\n */\nCancellablePromise.prototype.thenAlways = function(onResolved, opt_context) {\n var callback = function() {\n try {\n // Ensure that no arguments are passed to onResolved.\n onResolved.call(opt_context);\n } catch (err) {\n CancellablePromise.handleRejection_.call(null, err);\n }\n };\n\n this.addCallbackEntry_({\n child: null,\n onRejected: callback,\n onFulfilled: callback\n });\n return this;\n};\n\n\n/**\n * Adds a callback that will be invoked only if the Promise is rejected. This\n * is equivalent to {@code then(null, onRejected)}.\n *\n * @param {!function(this:THIS, *): *} onRejected A function that will be\n * invoked with the rejection reason if the Promise is rejected.\n * @param {THIS=} opt_context An optional context object that will be the\n * execution context for the callbacks. By default, functions are executed\n * in the global scope.\n * @return {!CancellablePromise} A new Promise that will receive the result of the\n * callback.\n * @template THIS\n */\nCancellablePromise.prototype.thenCatch = function(onRejected, opt_context) {\n return this.addChildPromise_(null, onRejected, opt_context);\n};\n\n/**\n * Alias of {@link CancellablePromise.prototype.thenCatch}\n */\nCancellablePromise.prototype.catch = CancellablePromise.prototype.thenCatch;\n\n\n/**\n * Cancels the Promise if it is still pending by rejecting it with a cancel\n * Error. No action is performed if the Promise is already resolved.\n *\n * All child Promises of the canceled Promise will be rejected with the same\n * cancel error, as with normal Promise rejection. If the Promise to be canceled\n * is the only child of a pending Promise, the parent Promise will also be\n * canceled. Cancellation may propagate upward through multiple generations.\n *\n * @param {string=} opt_message An optional debugging message for describing the\n * cancellation reason.\n */\nCancellablePromise.prototype.cancel = function(opt_message) {\n if (this.state_ === CancellablePromise.State_.PENDING) {\n async.run(function() {\n var err = new CancellablePromise.CancellationError(opt_message);\n err.IS_CANCELLATION_ERROR = true;\n this.cancelInternal_(err);\n }, this);\n }\n};\n\n\n/**\n * Cancels this Promise with the given error.\n *\n * @param {!Error} err The cancellation error.\n * @private\n */\nCancellablePromise.prototype.cancelInternal_ = function(err) {\n if (this.state_ === CancellablePromise.State_.PENDING) {\n if (this.parent_) {\n // Cancel the Promise and remove it from the parent's child list.\n this.parent_.cancelChild_(this, err);\n } else {\n this.resolve_(CancellablePromise.State_.REJECTED, err);\n }\n }\n};\n\n\n/**\n * Cancels a child Promise from the list of callback entries. If the Promise has\n * not already been resolved, reject it with a cancel error. If there are no\n * other children in the list of callback entries, propagate the cancellation\n * by canceling this Promise as well.\n *\n * @param {!CancellablePromise} childPromise The Promise to cancel.\n * @param {!Error} err The cancel error to use for rejecting the Promise.\n * @private\n */\nCancellablePromise.prototype.cancelChild_ = function(childPromise, err) {\n if (!this.callbackEntries_) {\n return;\n }\n var childCount = 0;\n var childIndex = -1;\n\n // Find the callback entry for the childPromise, and count whether there are\n // additional child Promises.\n for (var i = 0, entry; (entry = this.callbackEntries_[i]); i++) {\n var child = entry.child;\n if (child) {\n childCount++;\n if (child === childPromise) {\n childIndex = i;\n }\n if (childIndex >= 0 && childCount > 1) {\n break;\n }\n }\n }\n\n // If the child Promise was the only child, cancel this Promise as well.\n // Otherwise, reject only the child Promise with the cancel error.\n if (childIndex >= 0) {\n if (this.state_ === CancellablePromise.State_.PENDING && childCount === 1) {\n this.cancelInternal_(err);\n } else {\n var callbackEntry = this.callbackEntries_.splice(childIndex, 1)[0];\n this.executeCallback_(\n callbackEntry, CancellablePromise.State_.REJECTED, err);\n }\n }\n};\n\n\n/**\n * Adds a callback entry to the current Promise, and schedules callback\n * execution if the Promise has already been resolved.\n *\n * @param {CancellablePromise.CallbackEntry_} callbackEntry Record containing\n * {@code onFulfilled} and {@code onRejected} callbacks to execute after\n * the Promise is resolved.\n * @private\n */\nCancellablePromise.prototype.addCallbackEntry_ = function(callbackEntry) {\n if ((!this.callbackEntries_ || !this.callbackEntries_.length) &&\n (this.state_ === CancellablePromise.State_.FULFILLED ||\n this.state_ === CancellablePromise.State_.REJECTED)) {\n this.scheduleCallbacks_();\n }\n if (!this.callbackEntries_) {\n this.callbackEntries_ = [];\n }\n this.callbackEntries_.push(callbackEntry);\n};\n\n\n/**\n * Creates a child Promise and adds it to the callback entry list. The result of\n * the child Promise is determined by the state of the parent Promise and the\n * result of the {@code onFulfilled} or {@code onRejected} callbacks as\n * specified in the Promise resolution procedure.\n *\n * @see http://promisesaplus.com/#the__method\n *\n * @param {?function(this:THIS, TYPE):\n * (RESULT|CancellablePromise.|Thenable)} onFulfilled A callback that\n * will be invoked if the Promise is fullfilled, or null.\n * @param {?function(this:THIS, *): *} onRejected A callback that will be\n * invoked if the Promise is rejected, or null.\n * @param {THIS=} opt_context An optional execution context for the callbacks.\n * in the default calling context.\n * @return {!CancellablePromise} The child Promise.\n * @template RESULT,THIS\n * @private\n */\nCancellablePromise.prototype.addChildPromise_ = function(\nonFulfilled, onRejected, opt_context) {\n\n var callbackEntry = {\n child: null,\n onFulfilled: null,\n onRejected: null\n };\n\n callbackEntry.child = new CancellablePromise(function(resolve, reject) {\n // Invoke onFulfilled, or resolve with the parent's value if absent.\n callbackEntry.onFulfilled = onFulfilled ? function(value) {\n try {\n var result = onFulfilled.call(opt_context, value);\n resolve(result);\n } catch (err) {\n reject(err);\n }\n } : resolve;\n\n // Invoke onRejected, or reject with the parent's reason if absent.\n callbackEntry.onRejected = onRejected ? function(reason) {\n try {\n var result = onRejected.call(opt_context, reason);\n if (!core.isDef(result) && reason.IS_CANCELLATION_ERROR) {\n // Propagate cancellation to children if no other result is returned.\n reject(reason);\n } else {\n resolve(result);\n }\n } catch (err) {\n reject(err);\n }\n } : reject;\n });\n\n callbackEntry.child.parent_ = this;\n this.addCallbackEntry_(\n /** @type {CancellablePromise.CallbackEntry_} */ (callbackEntry));\n return callbackEntry.child;\n};\n\n\n/**\n * Unblocks the Promise and fulfills it with the given value.\n *\n * @param {TYPE} value\n * @private\n */\nCancellablePromise.prototype.unblockAndFulfill_ = function(value) {\n if (this.state_ !== CancellablePromise.State_.BLOCKED) {\n throw new Error('CancellablePromise is not blocked.');\n }\n this.state_ = CancellablePromise.State_.PENDING;\n this.resolve_(CancellablePromise.State_.FULFILLED, value);\n};\n\n\n/**\n * Unblocks the Promise and rejects it with the given rejection reason.\n *\n * @param {*} reason\n * @private\n */\nCancellablePromise.prototype.unblockAndReject_ = function(reason) {\n if (this.state_ !== CancellablePromise.State_.BLOCKED) {\n throw new Error('CancellablePromise is not blocked.');\n }\n this.state_ = CancellablePromise.State_.PENDING;\n this.resolve_(CancellablePromise.State_.REJECTED, reason);\n};\n\n\n/**\n * Attempts to resolve a Promise with a given resolution state and value. This\n * is a no-op if the given Promise has already been resolved.\n *\n * If the given result is a Thenable (such as another Promise), the Promise will\n * be resolved with the same state and result as the Thenable once it is itself\n * resolved.\n *\n * If the given result is not a Thenable, the Promise will be fulfilled or\n * rejected with that result based on the given state.\n *\n * @see http://promisesaplus.com/#the_promise_resolution_procedure\n *\n * @param {CancellablePromise.State_} state\n * @param {*} x The result to apply to the Promise.\n * @private\n */\nCancellablePromise.prototype.resolve_ = function(state, x) {\n if (this.state_ !== CancellablePromise.State_.PENDING) {\n return;\n }\n\n if (this === x) {\n state = CancellablePromise.State_.REJECTED;\n x = new TypeError('CancellablePromise cannot resolve to itself');\n\n } else if (Thenable.isImplementedBy(x)) {\n x = /** @type {!Thenable} */ (x);\n this.state_ = CancellablePromise.State_.BLOCKED;\n x.then(this.unblockAndFulfill_, this.unblockAndReject_, this);\n return;\n\n } else if (core.isObject(x)) {\n try {\n var then = x.then;\n if (core.isFunction(then)) {\n this.tryThen_(x, then);\n return;\n }\n } catch (e) {\n state = CancellablePromise.State_.REJECTED;\n x = e;\n }\n }\n\n this.result_ = x;\n this.state_ = state;\n this.scheduleCallbacks_();\n\n if (state === CancellablePromise.State_.REJECTED && !x.IS_CANCELLATION_ERROR) {\n CancellablePromise.addUnhandledRejection_(this, x);\n }\n};\n\n\n/**\n * Attempts to call the {@code then} method on an object in the hopes that it is\n * a Promise-compatible instance. This allows interoperation between different\n * Promise implementations, however a non-compliant object may cause a Promise\n * to hang indefinitely. If the {@code then} method throws an exception, the\n * dependent Promise will be rejected with the thrown value.\n *\n * @see http://promisesaplus.com/#point-70\n *\n * @param {Thenable} thenable An object with a {@code then} method that may be\n * compatible with the Promise/A+ specification.\n * @param {!Function} then The {@code then} method of the Thenable object.\n * @private\n */\nCancellablePromise.prototype.tryThen_ = function(thenable, then) {\n this.state_ = CancellablePromise.State_.BLOCKED;\n var promise = this;\n var called = false;\n\n var resolve = function(value) {\n if (!called) {\n called = true;\n promise.unblockAndFulfill_(value);\n }\n };\n\n var reject = function(reason) {\n if (!called) {\n called = true;\n promise.unblockAndReject_(reason);\n }\n };\n\n try {\n then.call(thenable, resolve, reject);\n } catch (e) {\n reject(e);\n }\n};\n\n\n/**\n * Executes the pending callbacks of a resolved Promise after a timeout.\n *\n * Section 2.2.4 of the Promises/A+ specification requires that Promise\n * callbacks must only be invoked from a call stack that only contains Promise\n * implementation code, which we accomplish by invoking callback execution after\n * a timeout. If {@code startExecution_} is called multiple times for the same\n * Promise, the callback chain will be evaluated only once. Additional callbacks\n * may be added during the evaluation phase, and will be executed in the same\n * event loop.\n *\n * All Promises added to the waiting list during the same browser event loop\n * will be executed in one batch to avoid using a separate timeout per Promise.\n *\n * @private\n */\nCancellablePromise.prototype.scheduleCallbacks_ = function() {\n if (!this.executing_) {\n this.executing_ = true;\n async.run(this.executeCallbacks_, this);\n }\n};\n\n\n/**\n * Executes all pending callbacks for this Promise.\n *\n * @private\n */\nCancellablePromise.prototype.executeCallbacks_ = function() {\n while (this.callbackEntries_ && this.callbackEntries_.length) {\n var entries = this.callbackEntries_;\n this.callbackEntries_ = [];\n\n for (var i = 0; i < entries.length; i++) {\n this.executeCallback_(entries[i], this.state_, this.result_);\n }\n }\n this.executing_ = false;\n};\n\n\n/**\n * Executes a pending callback for this Promise. Invokes an {@code onFulfilled}\n * or {@code onRejected} callback based on the resolved state of the Promise.\n *\n * @param {!CancellablePromise.CallbackEntry_} callbackEntry An entry containing the\n * onFulfilled and/or onRejected callbacks for this step.\n * @param {CancellablePromise.State_} state The resolution status of the Promise,\n * either FULFILLED or REJECTED.\n * @param {*} result The resolved result of the Promise.\n * @private\n */\nCancellablePromise.prototype.executeCallback_ = function(\ncallbackEntry, state, result) {\n if (state === CancellablePromise.State_.FULFILLED) {\n callbackEntry.onFulfilled(result);\n } else {\n this.removeUnhandledRejection_();\n callbackEntry.onRejected(result);\n }\n};\n\n\n/**\n * Marks this rejected Promise as having being handled. Also marks any parent\n * Promises in the rejected state as handled. The rejection handler will no\n * longer be invoked for this Promise (if it has not been called already).\n *\n * @private\n */\nCancellablePromise.prototype.removeUnhandledRejection_ = function() {\n var p;\n if (CancellablePromise.UNHANDLED_REJECTION_DELAY > 0) {\n for (p = this; p && p.unhandledRejectionId_; p = p.parent_) {\n clearTimeout(p.unhandledRejectionId_);\n p.unhandledRejectionId_ = 0;\n }\n } else if (CancellablePromise.UNHANDLED_REJECTION_DELAY === 0) {\n for (p = this; p && p.hadUnhandledRejection_; p = p.parent_) {\n p.hadUnhandledRejection_ = false;\n }\n }\n};\n\n\n/**\n * Marks this rejected Promise as unhandled. If no {@code onRejected} callback\n * is called for this Promise before the {@code UNHANDLED_REJECTION_DELAY}\n * expires, the reason will be passed to the unhandled rejection handler. The\n * handler typically rethrows the rejection reason so that it becomes visible in\n * the developer console.\n *\n * @param {!CancellablePromise} promise The rejected Promise.\n * @param {*} reason The Promise rejection reason.\n * @private\n */\nCancellablePromise.addUnhandledRejection_ = function(promise, reason) {\n if (CancellablePromise.UNHANDLED_REJECTION_DELAY > 0) {\n promise.unhandledRejectionId_ = setTimeout(function() {\n CancellablePromise.handleRejection_.call(null, reason);\n }, CancellablePromise.UNHANDLED_REJECTION_DELAY);\n\n } else if (CancellablePromise.UNHANDLED_REJECTION_DELAY === 0) {\n promise.hadUnhandledRejection_ = true;\n async.run(function() {\n if (promise.hadUnhandledRejection_) {\n CancellablePromise.handleRejection_.call(null, reason);\n }\n });\n }\n};\n\n\n/**\n * A method that is invoked with the rejection reasons for Promises that are\n * rejected but have no {@code onRejected} callbacks registered yet.\n * @type {function(*)}\n * @private\n */\nCancellablePromise.handleRejection_ = async.throwException;\n\n\n/**\n * Sets a handler that will be called with reasons from unhandled rejected\n * Promises. If the rejected Promise (or one of its descendants) has an\n * {@code onRejected} callback registered, the rejection will be considered\n * handled, and the rejection handler will not be called.\n *\n * By default, unhandled rejections are rethrown so that the error may be\n * captured by the developer console or a {@code window.onerror} handler.\n *\n * @param {function(*)} handler A function that will be called with reasons from\n * rejected Promises. Defaults to {@code async.throwException}.\n */\nCancellablePromise.setUnhandledRejectionHandler = function(handler) {\n CancellablePromise.handleRejection_ = handler;\n};\n\n\n\n/**\n * Error used as a rejection reason for canceled Promises.\n *\n * @param {string=} opt_message\n * @constructor\n * @extends {Error}\n * @final\n */\nCancellablePromise.CancellationError = class extends Error {\n constructor(opt_message) {\n super(opt_message);\n\n if (opt_message) {\n this.message = opt_message;\n }\n }\n};\n\n/** @override */\nCancellablePromise.CancellationError.prototype.name = 'cancel';\n\nexport {CancellablePromise};\nexport default CancellablePromise;\n","var globals = {\n\tdocument: document,\n\twindow: window\n};\n\nexport default globals;","'use strict';\n\n/**\n * Parses the given uri string into an object.\n * @param {*=} opt_uri Optional string URI to parse\n */\nfunction parseFromAnchor(opt_uri) {\n\tvar link = document.createElement('a');\n\tlink.href = opt_uri;\n\treturn {\n\t\thash: link.hash,\n\t\thostname: link.hostname,\n\t\tpassword: link.password,\n\t\tpathname: link.pathname[0] === '/' ? link.pathname : '/' + link.pathname,\n\t\tport: link.port,\n\t\tprotocol: link.protocol,\n\t\tsearch: link.search,\n\t\tusername: link.username\n\t};\n}\n\nexport default parseFromAnchor;\n","'use strict';\n\nimport { core } from 'metal';\nimport parseFromAnchor from './parseFromAnchor';\n\n/**\n * Parses the given uri string into an object. The URL function will be used\n * when present, otherwise we'll fall back to the anchor node element.\n * @param {*=} opt_uri Optional string URI to parse\n */\nfunction parse(opt_uri) {\n\tif (core.isFunction(URL) && URL.length) {\n\t\treturn new URL(opt_uri);\n\t} else {\n\t\treturn parseFromAnchor(opt_uri);\n\t}\n}\n\nexport default parse;\n","'use strict';\n\nimport { Disposable } from 'metal';\n\n/**\n * A cached reference to the create function.\n */\nvar create = Object.create;\n\n/**\n * Case insensitive string Multimap implementation. Allows multiple values for\n * the same key name.\n * @extends {Disposable}\n */\nclass MultiMap extends Disposable {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.keys = create(null);\n\t\tthis.values = create(null);\n\t}\n\n\t/**\n\t * Adds value to a key name.\n\t * @param {string} name\n\t * @param {*} value\n\t * @chainable\n\t */\n\tadd(name, value) {\n\t\tthis.keys[name.toLowerCase()] = name;\n\t\tthis.values[name.toLowerCase()] = this.values[name.toLowerCase()] || [];\n\t\tthis.values[name.toLowerCase()].push(value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Clears map names and values.\n\t * @chainable\n\t */\n\tclear() {\n\t\tthis.keys = create(null);\n\t\tthis.values = create(null);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Checks if map contains a value to the key name.\n\t * @param {string} name\n\t * @return {boolean}\n\t * @chainable\n\t */\n\tcontains(name) {\n\t\treturn name.toLowerCase() in this.values;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tthis.values = null;\n\t}\n\n\t/**\n\t * Gets the first added value from a key name.\n\t * @param {string} name\n\t * @return {*}\n\t * @chainable\n\t */\n\tget(name) {\n\t\tvar values = this.values[name.toLowerCase()];\n\t\tif (values) {\n\t\t\treturn values[0];\n\t\t}\n\t}\n\n\t/**\n\t * Gets all values from a key name.\n\t * @param {string} name\n\t * @return {Array.<*>}\n\t */\n\tgetAll(name) {\n\t\treturn this.values[name.toLowerCase()];\n\t}\n\n\t/**\n\t * Returns true if the map is empty, false otherwise.\n\t * @return {boolean}\n\t */\n\tisEmpty() {\n\t\treturn this.size() === 0;\n\t}\n\n\t/**\n\t * Gets array of key names.\n\t * @return {Array.}\n\t */\n\tnames() {\n\t\treturn Object.keys(this.values).map((key) => this.keys[key]);\n\t}\n\n\t/**\n\t * Removes all values from a key name.\n\t * @param {string} name\n\t * @chainable\n\t */\n\tremove(name) {\n\t\tdelete this.keys[name.toLowerCase()];\n\t\tdelete this.values[name.toLowerCase()];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the value of a key name. Relevant to replace the current values with\n\t * a new one.\n\t * @param {string} name\n\t * @param {*} value\n\t * @chainable\n\t */\n\tset(name, value) {\n\t\tthis.keys[name.toLowerCase()] = name;\n\t\tthis.values[name.toLowerCase()] = [value];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the size of the map key names.\n\t * @return {number}\n\t */\n\tsize() {\n\t\treturn this.names().length;\n\t}\n\n\t/**\n\t * Returns the parsed values as a string.\n\t * @return {string}\n\t */\n\ttoString() {\n\t\treturn JSON.stringify(this.values);\n\t}\n}\n\nexport default MultiMap;\n","'use strict';\n\nimport { core, string } from 'metal';\nimport parse from './parse';\nimport MultiMap from 'metal-multimap';\n\nvar parseFn_ = parse;\n\nclass Uri {\n\n\t/**\n\t * This class contains setters and getters for the parts of the URI.\n\t * The following figure displays an example URIs and their component parts.\n\t *\n\t * path\n\t *\t ┌───┴────┐\n\t *\t abc://example.com:123/path/data?key=value#fragid1\n\t *\t └┬┘ └────┬────┘ └┬┘ └───┬───┘ └──┬──┘\n\t * protocol hostname port search hash\n\t * └──────┬───────┘\n\t * host\n\t *\n\t * @param {*=} opt_uri Optional string URI to parse\n\t * @constructor\n\t */\n\tconstructor(opt_uri = '') {\n\t\tthis.url = Uri.parse(this.maybeAddProtocolAndHostname_(opt_uri));\n\t}\n\n\t/**\n\t * Adds parameters to uri from a MultiMap as source.\n\t * @param {MultiMap} multimap The MultiMap containing the\n\t * parameters.\n\t * @protected\n\t * @chainable\n\t */\n\taddParametersFromMultiMap(multimap) {\n\t\tmultimap.names().forEach((name) => {\n\t\t\tmultimap.getAll(name).forEach((value) => {\n\t\t\t\tthis.addParameterValue(name, value);\n\t\t\t});\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds the value of the named query parameters.\n\t * @param {string} key The parameter to set.\n\t * @param {*} value The new value. Will be explicitly casted to String.\n\t * @chainable\n\t */\n\taddParameterValue(name, value) {\n\t\tthis.ensureQueryInitialized_();\n\t\tif (core.isDef(value)) {\n\t\t\tvalue = String(value);\n\t\t}\n\t\tthis.query.add(name, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds the values of the named query parameter.\n\t * @param {string} key The parameter to set.\n\t * @param {*} value The new value.\n\t * @chainable\n\t */\n\taddParameterValues(name, values) {\n\t\tvalues.forEach((value) => this.addParameterValue(name, value));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Ensures query internal map is initialized and synced with initial value\n\t * extracted from URI search part.\n\t * @protected\n\t */\n\tensureQueryInitialized_() {\n\t\tif (this.query) {\n\t\t\treturn;\n\t\t}\n\t\tthis.query = new MultiMap();\n\t\tvar search = this.url.search;\n\t\tif (search) {\n\t\t\tsearch.substring(1).split('&').forEach((param) => {\n\t\t\t\tvar [key, value] = param.split('=');\n\t\t\t\tif (core.isDef(value)) {\n\t\t\t\t\tvalue = Uri.urlDecode(value);\n\t\t\t\t}\n\t\t\t\tthis.addParameterValue(key, value);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Gets the hash part of uri.\n\t * @return {string}\n\t */\n\tgetHash() {\n\t\treturn this.url.hash || '';\n\t}\n\n\t/**\n\t * Gets the host part of uri. E.g. [hostname]:[port].\n\t * @return {string}\n\t */\n\tgetHost() {\n\t\tvar host = this.getHostname();\n\t\tif (host) {\n\t\t\tvar port = this.getPort();\n\t\t\tif (port && port !== '80') {\n\t\t\t\thost += ':' + port;\n\t\t\t}\n\t\t}\n\t\treturn host;\n\t}\n\n\t/**\n\t * Gets the hostname part of uri without protocol and port.\n\t * @return {string}\n\t */\n\tgetHostname() {\n\t\tvar hostname = this.url.hostname;\n\t\tif (hostname === Uri.HOSTNAME_PLACEHOLDER) {\n\t\t\treturn '';\n\t\t}\n\t\treturn hostname;\n\t}\n\n\t/**\n\t * Gets the origin part of uri. E.g. http://[hostname]:[port].\n\t * @return {string}\n\t */\n\tgetOrigin() {\n\t\tvar host = this.getHost();\n\t\tif (host) {\n\t\t\treturn this.getProtocol() + '//' + host;\n\t\t}\n\t\treturn '';\n\t}\n\n\t/**\n\t * Returns the first value for a given parameter or undefined if the given\n\t * parameter name does not appear in the query string.\n\t * @param {string} paramName Unescaped parameter name.\n\t * @return {string|undefined} The first value for a given parameter or\n\t * undefined if the given parameter name does not appear in the query\n\t * string.\n\t */\n\tgetParameterValue(name) {\n\t\tthis.ensureQueryInitialized_();\n\t\treturn this.query.get(name);\n\t}\n\n\t/**\n\t * Returns the values for a given parameter as a list of decoded\n\t * query parameter values.\n\t * @param {string} name The parameter to get values for.\n\t * @return {!Array} The values for a given parameter as a list of decoded\n\t * query parameter values.\n\t */\n\tgetParameterValues(name) {\n\t\tthis.ensureQueryInitialized_();\n\t\treturn this.query.getAll(name);\n\t}\n\n\t/**\n\t * Returns the names of the parameters.\n\t * @return {!Array} The names for the parameters as a list of\n\t * strings.\n\t */\n\tgetParameterNames() {\n\t\tthis.ensureQueryInitialized_();\n\t\treturn this.query.names();\n\t}\n\n\t/**\n\t * Gets the function currently being used to parse URIs.\n\t * @return {!function()}\n\t */\n\tstatic getParseFn() {\n\t\treturn parseFn_;\n\t}\n\n\t/**\n\t * Gets the pathname part of uri.\n\t * @return {string}\n\t */\n\tgetPathname() {\n\t\treturn this.url.pathname;\n\t}\n\n\t/**\n\t * Gets the port number part of uri as string.\n\t * @return {string}\n\t */\n\tgetPort() {\n\t\treturn this.url.port;\n\t}\n\n\t/**\n\t * Gets the protocol part of uri. E.g. http:.\n\t * @return {string}\n\t */\n\tgetProtocol() {\n\t\treturn this.url.protocol;\n\t}\n\n\t/**\n\t * Gets the search part of uri. Search value is retrieved from query\n\t * parameters.\n\t * @return {string}\n\t */\n\tgetSearch() {\n\t\tvar search = '';\n\t\tvar querystring = '';\n\t\tthis.getParameterNames().forEach((name) => {\n\t\t\tthis.getParameterValues(name).forEach((value) => {\n\t\t\t\tquerystring += name;\n\t\t\t\tif (core.isDef(value)) {\n\t\t\t\t\tquerystring += '=' + encodeURIComponent(value);\n\t\t\t\t}\n\t\t\t\tquerystring += '&';\n\t\t\t});\n\t\t});\n\t\tquerystring = querystring.slice(0, -1);\n\t\tif (querystring) {\n\t\t\tsearch += '?' + querystring;\n\t\t}\n\t\treturn search;\n\t}\n\n\t/**\n\t * Checks if uri contains the parameter.\n\t * @param {string} name\n\t * @return {boolean}\n\t */\n\thasParameter(name) {\n\t\tthis.ensureQueryInitialized_();\n\t\treturn this.query.contains(name);\n\t}\n\n\t/**\n\t * Makes this URL unique by adding a random param to it. Useful for avoiding\n\t * cache.\n\t */\n\tmakeUnique() {\n\t\tthis.setParameterValue(Uri.RANDOM_PARAM, string.getRandomString());\n\t\treturn this;\n\t}\n\n\t/**\n\t * Maybe adds protocol and a hostname placeholder on a parial URI if needed.\n\t * Relevent for compatibility with URL native object.\n\t * @param {string=} opt_uri\n\t * @return {string} URI with protocol and hostname placeholder.\n\t */\n\tmaybeAddProtocolAndHostname_(opt_uri) {\n\t\tvar url = opt_uri;\n\t\tif (opt_uri.indexOf('://') === -1 &&\n\t\t\topt_uri.indexOf('javascript:') !== 0) { // jshint ignore:line\n\n\t\t\turl = Uri.DEFAULT_PROTOCOL;\n\t\t\tif (opt_uri[0] !== '/' || opt_uri[1] !== '/') {\n\t\t\t\turl += '//';\n\t\t\t}\n\n\t\t\tswitch (opt_uri.charAt(0)) {\n\t\t\t\tcase '.':\n\t\t\t\tcase '?':\n\t\t\t\tcase '#':\n\t\t\t\t\turl += Uri.HOSTNAME_PLACEHOLDER;\n\t\t\t\t\turl += '/';\n\t\t\t\t\turl += opt_uri;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '':\n\t\t\t\tcase '/':\n\t\t\t\t\tif (opt_uri[1] !== '/') {\n\t\t\t\t\t\turl += Uri.HOSTNAME_PLACEHOLDER;\n\t\t\t\t\t}\n\t\t\t\t\turl += opt_uri;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\turl += opt_uri;\n\t\t\t}\n\t\t}\n\t\treturn url;\n\t}\n\n\t/**\n\t * Normalizes the parsed object to be in the expected standard.\n\t * @param {!Object}\n\t */\n\tstatic normalizeObject(parsed) {\n\t\tvar length = parsed.pathname ? parsed.pathname.length : 0;\n\t\tif (length > 1 && parsed.pathname[length - 1] === '/') {\n\t\t\tparsed.pathname = parsed.pathname.substr(0, length - 1);\n\t\t}\n\t\treturn parsed;\n\t}\n\n\t/**\n\t * Parses the given uri string into an object.\n\t * @param {*=} opt_uri Optional string URI to parse\n\t */\n\tstatic parse(opt_uri) {\n\t\treturn Uri.normalizeObject(parseFn_(opt_uri));\n\t}\n\n\t/**\n\t * Removes the named query parameter.\n\t * @param {string} name The parameter to remove.\n\t * @chainable\n\t */\n\tremoveParameter(name) {\n\t\tthis.ensureQueryInitialized_();\n\t\tthis.query.remove(name);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes uniqueness parameter of the uri.\n\t * @chainable\n\t */\n\tremoveUnique() {\n\t\tthis.removeParameter(Uri.RANDOM_PARAM);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the hash.\n\t * @param {string} hash\n\t * @chainable\n\t */\n\tsetHash(hash) {\n\t\tthis.url.hash = hash;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the hostname.\n\t * @param {string} hostname\n\t * @chainable\n\t */\n\tsetHostname(hostname) {\n\t\tthis.url.hostname = hostname;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the value of the named query parameters, clearing previous values\n\t * for that key.\n\t * @param {string} key The parameter to set.\n\t * @param {*} value The new value.\n\t * @chainable\n\t */\n\tsetParameterValue(name, value) {\n\t\tthis.removeParameter(name);\n\t\tthis.addParameterValue(name, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the values of the named query parameters, clearing previous values\n\t * for that key.\n\t * @param {string} key The parameter to set.\n\t * @param {*} value The new value.\n\t * @chainable\n\t */\n\tsetParameterValues(name, values) {\n\t\tthis.removeParameter(name);\n\t\tvalues.forEach((value) => this.addParameterValue(name, value));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the pathname.\n\t * @param {string} pathname\n\t * @chainable\n\t */\n\tsetPathname(pathname) {\n\t\tthis.url.pathname = pathname;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the port number.\n\t * @param {*} port Port number.\n\t * @chainable\n\t */\n\tsetPort(port) {\n\t\tthis.url.port = port;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the function that will be used for parsing the original string uri\n\t * into an object.\n\t * @param {!function()} parseFn\n\t */\n\tstatic setParseFn(parseFn) {\n\t\tparseFn_ = parseFn;\n\t}\n\n\t/**\n\t * Sets the protocol. If missing http: is used as default.\n\t * @param {string} protocol\n\t * @chainable\n\t */\n\tsetProtocol(protocol) {\n\t\tthis.url.protocol = protocol;\n\t\tif (this.url.protocol[this.url.protocol.length - 1] !== ':') {\n\t\t\tthis.url.protocol += ':';\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * @return {string} The string form of the url.\n\t * @override\n\t */\n\ttoString() {\n\t\tvar href = '';\n\t\tvar host = this.getHost();\n\t\tif (host) {\n\t\t\thref += this.getProtocol() + '//';\n\t\t}\n\t\thref += host + this.getPathname() + this.getSearch() + this.getHash();\n\t\treturn href;\n\t}\n\n\t/**\n\t * Joins the given paths.\n\t * @param {string} basePath\n\t * @param {...string} ...paths Any number of paths to be joined with the base url.\n\t * @static\n\t */\n\tstatic joinPaths(basePath, ...paths) {\n\t\tif (basePath.charAt(basePath.length - 1) === '/') {\n\t\t\tbasePath = basePath.substring(0, basePath.length - 1);\n\t\t}\n\t\tpaths = paths.map(path => path.charAt(0) === '/' ? path.substring(1) : path);\n\t\treturn [basePath].concat(paths).join('/').replace(/\\/$/, '');\n\t}\n\n\t/**\n\t * URL-decodes the string. We need to specially handle '+'s because\n\t * the javascript library doesn't convert them to spaces.\n\t * @param {string} str The string to url decode.\n\t * @return {string} The decoded {@code str}.\n\t */\n\tstatic urlDecode(str) {\n\t\treturn decodeURIComponent(str.replace(/\\+/g, ' '));\n\t}\n\n}\n\n/**\n * Default protocol value.\n * @type {string}\n * @default http:\n * @static\n */\nUri.DEFAULT_PROTOCOL = 'http:';\n\n/**\n * Hostname placeholder. Relevant to internal usage only.\n * @type {string}\n * @static\n */\nUri.HOSTNAME_PLACEHOLDER = 'hostname' + Date.now();\n\n/**\n * Name used by the param generated by `makeUnique`.\n * @type {string}\n * @static\n */\nUri.RANDOM_PARAM = 'zx';\n\nexport default Uri;\n","'use strict';\n\nimport globals from '../globals/globals';\nimport Uri from 'metal-uri';\n\n/**\n * A collection of static utility functions.\n * @const\n */\nclass utils {\n\n\t/**\n\t * Copies attributes form source node to target node.\n\t * @return {void}\n\t * @static\n\t */\n\tstatic copyNodeAttributes(source, target) {\n\t\tArray.prototype.slice.call(source.attributes).forEach((attribute) => target.setAttribute(attribute.name, attribute.value));\n\t}\n\n\t/**\n\t * Gets the current browser path including hashbang.\n\t * @return {!string}\n\t * @static\n\t */\n\tstatic getCurrentBrowserPath() {\n\t\treturn this.getCurrentBrowserPathWithoutHash() + globals.window.location.hash;\n\t}\n\n\t/**\n\t * Gets the current browser path excluding hashbang.\n\t * @return {!string}\n\t * @static\n\t */\n\tstatic getCurrentBrowserPathWithoutHash() {\n\t\treturn globals.window.location.pathname + globals.window.location.search;\n\t}\n\n\t/**\n\t * Extracts the path part of an url.\n\t * @return {!string}\n\t * @static\n\t */\n\tstatic getUrlPath(url) {\n\t\tvar uri = new Uri(url);\n\t\treturn uri.getPathname() + uri.getSearch() + uri.getHash();\n\t}\n\n\t/**\n\t * Extracts the path part of an url without hashbang.\n\t * @return {!string}\n\t * @static\n\t */\n\tstatic getUrlPathWithoutHash(url) {\n\t\tvar uri = new Uri(url);\n\t\treturn uri.getPathname() + uri.getSearch();\n\t}\n\n\t/**\n\t * Checks if url is in the same browser current url excluding the hashbang.\n\t * @param {!string} url\n\t * @return {boolean}\n\t * @static\n\t */\n\tstatic isCurrentBrowserPath(url) {\n\t\tif (url) {\n\t\t\treturn utils.getUrlPathWithoutHash(url) === this.getCurrentBrowserPathWithoutHash();\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Returns true if HTML5 History api is supported.\n\t * @return {boolean}\n\t * @static\n\t */\n\tstatic isHtml5HistorySupported() {\n\t\treturn !!(globals.window.history && globals.window.history.pushState);\n\t}\n\n\t/**\n\t * Removes all attributes form node.\n\t * @return {void}\n\t * @static\n\t */\n\tstatic clearNodeAttributes(node) {\n\t\tArray.prototype.slice.call(node.attributes).forEach((attribute) => node.removeAttribute(attribute.name));\n\t}\n\n}\n\nexport default utils;","'use strict';\n\nimport { core } from 'metal';\n\nclass Route {\n\n\t/**\n\t * Route class.\n\t * @param {!string|RegExp|Function} path\n\t * @param {!Function} handler\n\t * @constructor\n\t */\n\tconstructor(path, handler) {\n\t\tif (!core.isDefAndNotNull(path)) {\n\t\t\tthrow new Error('Route path not specified.');\n\t\t}\n\t\tif (!core.isFunction(handler)) {\n\t\t\tthrow new Error('Route handler is not a function.');\n\t\t}\n\n\t\t/**\n\t\t * Defines the handler which will execute once a URL in the application\n\t\t * matches the path.\n\t\t * @type {!Function}\n\t\t * @protected\n\t\t */\n\t\tthis.handler = handler;\n\n\t\t/**\n\t\t * Defines the path which will trigger the route handler.\n\t\t * @type {!string|RegExp|Function}\n\t\t * @protected\n\t\t */\n\t\tthis.path = path;\n\t}\n\n\t/**\n\t * Gets the route handler.\n\t * @return {!Function}\n\t */\n\tgetHandler() {\n\t\treturn this.handler;\n\t}\n\n\t/**\n\t * Gets the route path.\n\t * @return {!string|RegExp|Function}\n\t */\n\tgetPath() {\n\t\treturn this.path;\n\t}\n\n\t/**\n\t * Matches if the router can handle the tested path.\n\t * @param {!string} value Path to test and may contains the querystring\n\t * part.\n\t * @return {Boolean} Returns true if matches any route.\n\t */\n\tmatchesPath(value) {\n\t\tvar path = this.path;\n\n\t\tif (core.isString(path)) {\n\t\t\treturn value === path;\n\t\t}\n\t\tif (core.isFunction(path)) {\n\t\t\treturn path(value);\n\t\t}\n\t\tif (path instanceof RegExp) {\n\t\t\treturn value.search(path) > -1;\n\t\t}\n\n\t\treturn false;\n\t}\n\n}\n\nexport default Route;\n","'use strict';\n\nimport { Disposable } from 'metal';\n\nclass Cacheable extends Disposable {\n\n\t/**\n\t * Abstract class for defining cacheable behavior.\n\t * @constructor\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the cached data.\n\t\t * @type {!Object}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.cache = null;\n\n\t\t/**\n\t\t * Holds whether class is cacheable.\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t * @protected\n\t\t */\n\t\tthis.cacheable = false;\n\t}\n\n\t/**\n\t * Adds content to the cache.\n\t * @param {string} content Content to be cached.\n\t * @chainable\n\t */\n\taddCache(content) {\n\t\tif (this.cacheable) {\n\t\t\tthis.cache = content;\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Clears the cache.\n\t * @chainable\n\t */\n\tclearCache() {\n\t\tthis.cache = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Disposes of this instance's object references.\n\t * @override\n\t */\n\tdisposeInternal() {\n\t\tthis.clearCache();\n\t}\n\n\t/**\n\t * Gets the cached content.\n\t * @return {Object} Cached content.\n\t * @protected\n\t */\n\tgetCache() {\n\t\treturn this.cache;\n\t}\n\n\t/**\n\t * Whether the class is cacheable.\n\t * @return {boolean} Returns true when class is cacheable, false otherwise.\n\t */\n\tisCacheable() {\n\t\treturn this.cacheable;\n\t}\n\n\t/**\n\t * Sets whether the class is cacheable.\n\t * @param {boolean} cacheable\n\t */\n\tsetCacheable(cacheable) {\n\t\tif (!cacheable) {\n\t\t\tthis.clearCache();\n\t\t}\n\t\tthis.cacheable = cacheable;\n\t}\n\n}\n\nexport default Cacheable;\n","'use strict';\n\nimport { core } from 'metal';\nimport { globalEval } from 'metal-dom';\nimport Cacheable from '../cacheable/Cacheable';\nimport CancellablePromise from 'metal-promise';\n\nclass Screen extends Cacheable {\n\n\t/**\n\t * Screen class is a special type of route handler that provides helper\n\t * utilities that adds lifecycle and methods to provide content to each\n\t * registered surface.\n\t * @constructor\n\t * @extends {Cacheable}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the screen id.\n\t\t * @type {string}\n\t\t * @protected\n\t\t */\n\t\tthis.id = this.makeId_(core.getUid());\n\n\t\t/**\n\t\t * Holds the screen title. Relevant when the page title should be\n\t\t * upadated when screen is rendered.\n\t\t * @type {?string=}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.title = null;\n\t}\n\n\t/**\n\t * Fires when the screen is active. Allows a screen to perform any setup\n\t * that requires its DOM to be visible. Lifecycle.\n\t */\n\tactivate() {\n\t\tconsole.log('Screen [' + this + '] activate');\n\t}\n\n\t/**\n\t * Gives the Screen a chance to cancel the navigation and stop itself from\n\t * being deactivated. Can be used, for example, if the screen has unsaved\n\t * state. Lifecycle. Clean-up should not be preformed here, since the\n\t * navigation may still be cancelled. Do clean-up in deactivate.\n\t * @return {boolean=} If returns true, the current screen is locked and the\n\t * next nagivation interrupted.\n\t */\n\tbeforeDeactivate() {\n\t\tconsole.log('Screen [' + this + '] beforeDeactivate');\n\t}\n\n\t/**\n\t * Gives the Screen a chance format the path before history update.\n\t * @path {!string} path Navigation path.\n\t * @return {!string} Navigation path to use on history.\n\t */\n\tbeforeUpdateHistoryPath(path) {\n\t\treturn path;\n\t}\n\n\t/**\n\t * Gives the Screen a chance format the state before history update.\n\t * @path {!object} state History state.\n\t * @return {!object} History state to use on history.\n\t */\n\tbeforeUpdateHistoryState(state) {\n\t\treturn state;\n\t}\n\n\t/**\n\t * Allows a screen to do any cleanup necessary after it has been\n\t * deactivated, for example cancelling outstanding requests or stopping\n\t * timers. Lifecycle.\n\t */\n\tdeactivate() {\n\t\tconsole.log('Screen [' + this + '] deactivate');\n\t}\n\n\t/**\n\t * Dispose a screen, either after it is deactivated (in the case of a\n\t * non-cacheable view) or when the App is itself disposed for whatever\n\t * reason. Lifecycle.\n\t */\n\tdisposeInternal() {\n\t\tsuper.disposeInternal();\n\t\tconsole.log('Screen [' + this + '] dispose');\n\t}\n\n\t/**\n\t * Allows a screen to evaluate scripts before the element is made visible.\n\t * Lifecycle.\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t * @return {?CancellablePromise=} This can return a promise, which will\n\t * pause the navigation until it is resolved.\n\t */\n\tevaluateScripts(surfaces) {\n\t\tObject.keys(surfaces).forEach(sId => {\n\t\t\tif (surfaces[sId].activeChild) {\n\t\t\t\tglobalEval.runScriptsInElement(surfaces[sId].activeChild);\n\t\t\t}\n\t\t});\n\t\treturn CancellablePromise.resolve();\n\t}\n\n\t/**\n\t * Allows a screen to evaluate styles before the element is made visible.\n\t * Lifecycle.\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t * @return {?CancellablePromise=} This can return a promise, which will\n\t * pause the navigation until it is resolved.\n\t */\n\tevaluateStyles() {\n\t\treturn CancellablePromise.resolve();\n\t}\n\n\t/**\n\t * Allows a screen to perform any setup immediately before the element is\n\t * made visible. Lifecycle.\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t * @return {?CancellablePromise=} This can return a promise, which will pause the\n\t * navigation until it is resolved.\n\t */\n\tflip(surfaces) {\n\t\tconsole.log('Screen [' + this + '] flip');\n\n\t\tvar transitions = [];\n\n\t\tObject.keys(surfaces).forEach(sId => {\n\t\t\tvar surface = surfaces[sId];\n\t\t\tvar deferred = surface.show(this.id);\n\t\t\ttransitions.push(deferred);\n\t\t});\n\n\t\treturn CancellablePromise.all(transitions);\n\t}\n\n\t/**\n\t * Gets the screen id.\n\t * @return {string}\n\t */\n\tgetId() {\n\t\treturn this.id;\n\t}\n\n\t/**\n\t * Returns the content for the given surface, or null if the surface isn't\n\t * used by this screen. This will be called when a screen is initially\n\t * constructed or, if a screen is non-cacheable, when navigated.\n\t * @param {!string} surfaceId The id of the surface DOM element.\n\t * @return {?string|Element=} This can return a string or node representing\n\t * the content of the surface. If returns falsy values surface default\n\t * content is restored.\n\t */\n\tgetSurfaceContent() {\n\t\tconsole.log('Screen [' + this + '] getSurfaceContent');\n\t}\n\n\t/**\n\t * Gets the screen title.\n\t * @return {?string=}\n\t */\n\tgetTitle() {\n\t\treturn this.title;\n\t}\n\n\t/**\n\t * Returns all contents for the surfaces. This will pass the loaded content\n\t * to Screen.load with all information you\n\t * need to fulfill the surfaces. Lifecycle.\n\t * @param {!string=} path The requested path.\n\t * @return {!CancellablePromise} This can return a string representing the\n\t * contents of the surfaces or a promise, which will pause the navigation\n\t * until it is resolved. This is useful for loading async content.\n\t */\n\tload() {\n\t\tconsole.log('Screen [' + this + '] load');\n\t\treturn CancellablePromise.resolve();\n\t}\n\n\t/**\n\t * Makes the id for the screen.\n\t * @param {!string} id The screen id the content belongs too.\n\t * @return {string}\n\t * @private\n\t */\n\tmakeId_(id) {\n\t\treturn 'screen_' + id;\n\t}\n\n\t/**\n\t * Sets the screen id.\n\t * @param {!string} id\n\t */\n\tsetId(id) {\n\t\tthis.id = id;\n\t}\n\n\t/**\n\t * Sets the screen title.\n\t * @param {?string=} title\n\t */\n\tsetTitle(title) {\n\t\tthis.title = title;\n\t}\n\n\t/**\n\t * @return {string}\n\t */\n\ttoString() {\n\t\treturn this.id;\n\t}\n\n}\n\n/**\n * @param {*} object\n * @return {boolean} Whether a given instance implements\n * Screen.\n */\nScreen.isImplementedBy = function(object) {\n\treturn object instanceof Screen;\n};\n\nexport default Screen;\n","'use strict';\n\nimport globals from '../globals/globals';\nimport { core, Disposable } from 'metal';\nimport dom from 'metal-dom';\nimport CancellablePromise from 'metal-promise';\n\nclass Surface extends Disposable {\n\n\t/**\n\t * Surface class representing the references to elements on the page that\n\t * can potentially be updated by App.\n\t * @param {string} id\n\t * @constructor\n\t */\n\tconstructor(id) {\n\t\tsuper();\n\n\t\tif (!id) {\n\t\t\tthrow new Error('Surface element id not specified. A surface element requires a valid id.');\n\t\t}\n\n\t\t/**\n\t\t * Holds the active child element.\n\t\t * @type {Element}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.activeChild = null;\n\n\t\t/**\n\t\t * Holds the default child element.\n\t\t * @type {Element}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.defaultChild = null;\n\n\t\t/**\n\t\t * Holds the element with the specified surface id, if not found creates a\n\t\t * new element with the specified id.\n\t\t * @type {Element}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.element = null;\n\n\t\t/**\n\t\t * Holds the surface id.\n\t\t * @type {String}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.id = id;\n\n\t\t/**\n\t\t * Holds the default transitionFn for the surfaces.\n\t\t * @param {?Element=} from The visible surface element.\n\t\t * @param {?Element=} to The surface element to be flipped.\n\t\t * @default null\n\t\t */\n\t\tthis.transitionFn = null;\n\n\t\tthis.defaultChild = this.getChild(Surface.DEFAULT);\n\t\tthis.maybeWrapContentAsDefault_();\n\t\tthis.activeChild = this.defaultChild;\n\t}\n\n\t/**\n\t * Adds screen content to a surface. If content hasn't been passed, see if\n\t * an element exists in the DOM that matches the id. By convention, the\n\t * element should already be nested in the right element and should have an\n\t * id that is a concatentation of the surface id + '-' + the screen id.\n\t * @param {!string} screenId The screen id the content belongs too.\n\t * @param {?string|Element=} opt_content The string content or element to\n\t * add be added as surface content.\n\t * @return {Element}\n\t */\n\taddContent(screenId, opt_content) {\n\t\tvar child = this.defaultChild;\n\n\t\tif (core.isDefAndNotNull(opt_content)) {\n\t\t\tchild = this.getChild(screenId);\n\t\t\tif (child) {\n\t\t\t\tdom.removeChildren(child);\n\t\t\t} else {\n\t\t\t\tchild = this.createChild(screenId);\n\t\t\t\tthis.transition(child, null);\n\t\t\t}\n\t\t\tdom.append(child, opt_content);\n\t\t}\n\n\t\tvar element = this.getElement();\n\n\t\tif (element && child) {\n\t\t\tdom.append(element, child);\n\t\t}\n\n\t\treturn child;\n\t}\n\n\t/**\n\t * Creates child node for the surface.\n\t * @param {!string} screenId The screen id.\n\t * @return {Element}\n\t */\n\tcreateChild(screenId) {\n\t\tvar child = globals.document.createElement('div');\n\t\tchild.setAttribute('id', this.makeId_(screenId));\n\t\treturn child;\n\t}\n\n\t/**\n\t * Gets child node of the surface.\n\t * @param {!string} screenId The screen id.\n\t * @return {?Element}\n\t */\n\tgetChild(screenId) {\n\t\treturn globals.document.getElementById(this.makeId_(screenId));\n\t}\n\n\t/**\n\t * Gets the surface element from element, and sets it to the el property of\n\t * the current instance.\n\t * this.element will be used.\n\t * @return {?Element} The current surface element.\n\t */\n\tgetElement() {\n\t\tif (this.element) {\n\t\t\treturn this.element;\n\t\t}\n\t\tthis.element = globals.document.getElementById(this.id);\n\t\treturn this.element;\n\t}\n\n\t/**\n\t * Gets the surface id.\n\t * @return {String}\n\t */\n\tgetId() {\n\t\treturn this.id;\n\t}\n\n\t/**\n\t * Gets the surface transition function.\n\t * See Surface.defaultTransition.\n\t * @return {?Function=} The transition function.\n\t */\n\tgetTransitionFn() {\n\t\treturn this.transitionFn;\n\t}\n\n\t/**\n\t * Makes the id for the element that holds content for a screen.\n\t * @param {!string} screenId The screen id the content belongs too.\n\t * @return {String}\n\t * @private\n\t */\n\tmakeId_(screenId) {\n\t\treturn this.id + '-' + screenId;\n\t}\n\n\t/**\n\t * If default child is missing, wraps surface content as default child. If\n\t * surface have static content, make sure to place a\n\t * surfaceId-default element inside surface, only contents\n\t * inside the default child will be replaced by navigation.\n\t */\n\tmaybeWrapContentAsDefault_() {\n\t\tvar element = this.getElement();\n\t\tif (element && !this.defaultChild) {\n\t\t\tvar fragment = globals.document.createDocumentFragment();\n\t\t\twhile (element.firstChild) {\n\t\t\t\tfragment.appendChild(element.firstChild);\n\t\t\t}\n\t\t\tthis.defaultChild = this.addContent(Surface.DEFAULT, fragment);\n\t\t\tthis.transition(null, this.defaultChild);\n\t\t}\n\t}\n\n\t/**\n\t * Sets the surface id.\n\t * @param {!string} id\n\t */\n\tsetId(id) {\n\t\tthis.id = id;\n\t}\n\n\t/**\n\t * Sets the surface transition function.\n\t * See Surface.defaultTransition.\n\t * @param {?Function=} transitionFn The transition function.\n\t */\n\tsetTransitionFn(transitionFn) {\n\t\tthis.transitionFn = transitionFn;\n\t}\n\n\t/**\n\t * Shows screen content from a surface.\n\t * @param {String} screenId The screen id to show.\n\t * @return {CancellablePromise} Pauses the navigation until it is resolved.\n\t */\n\tshow(screenId) {\n\t\tvar from = this.activeChild;\n\t\tvar to = this.getChild(screenId);\n\t\tif (!to) {\n\t\t\tto = this.defaultChild;\n\t\t}\n\t\tthis.activeChild = to;\n\t\treturn this.transition(from, to).thenAlways(() => {\n\t\t\tif (from && from !== to) {\n\t\t\t\tdom.exitDocument(from);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Removes screen content from a surface.\n\t * @param {!string} screenId The screen id to remove.\n\t */\n\tremove(screenId) {\n\t\tvar child = this.getChild(screenId);\n\t\tif (child) {\n\t\t\tdom.exitDocument(child);\n\t\t}\n\t}\n\n\t/**\n\t * @return {String}\n\t */\n\ttoString() {\n\t\treturn this.id;\n\t}\n\n\t/**\n\t * Invokes the transition function specified on transition attribute.\n\t * @param {?Element=} from\n\t * @param {?Element=} to\n\t * @return {?CancellablePromise=} This can return a promise, which will pause the\n\t * navigation until it is resolved.\n\t */\n\ttransition(from, to) {\n\t\tvar transitionFn = this.transitionFn || Surface.defaultTransition;\n\t\treturn CancellablePromise.resolve(transitionFn.call(this, from, to));\n\t}\n\n}\n\n/**\n * Holds the default surface name. Elements on the page must contain a child\n * element containing the default content, this element must be as following:\n *\n * Example:\n * \n *
\n *
Default surface content.
\n *
\n *
\n *\n * The default content is relevant for the initial page content. When a\n * screen doesn't provide content for the surface the default content is\n * restored into the page.\n *\n * @type {!String}\n * @default default\n * @static\n */\nSurface.DEFAULT = 'default';\n\n/**\n * Holds the default transition for all surfaces. Each surface could have its\n * own transition.\n *\n * Example:\n *\n * \n * surface.setTransitionFn(function(from, to) {\n * if (from) {\n * from.style.display = 'none';\n * from.classList.remove('flipped');\n * }\n * if (to) {\n * to.style.display = 'block';\n * to.classList.add('flipped');\n * }\n * return null;\n * });\n * \n *\n * @param {?Element=} from The visible surface element.\n * @param {?Element=} to The surface element to be flipped.\n * @static\n */\nSurface.defaultTransition = function(from, to) {\n\tif (from) {\n\t\tfrom.style.display = 'none';\n\t\tfrom.classList.remove('flipped');\n\t}\n\tif (to) {\n\t\tto.style.display = 'block';\n\t\tto.classList.add('flipped');\n\t}\n};\n\nexport default Surface;\n","'use strict';\n\nimport { array, async, core } from 'metal';\nimport debounce from 'metal-debounce';\nimport dom from 'metal-dom';\nimport CancellablePromise from 'metal-promise';\nimport { EventEmitter, EventHandler } from 'metal-events';\nimport utils from '../utils/utils';\nimport globals from '../globals/globals';\nimport Route from '../route/Route';\nimport Screen from '../screen/Screen';\nimport Surface from '../surface/Surface';\nimport Uri from 'metal-uri';\n\nclass App extends EventEmitter {\n\n\t/**\n\t * App class that handle routes and screens lifecycle.\n\t * @constructor\n\t * @extends {EventEmitter}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the active screen.\n\t\t * @type {?Screen}\n\t\t * @protected\n\t\t */\n\t\tthis.activeScreen = null;\n\n\t\t/**\n\t\t * Holds the active path containing the query parameters.\n\t\t * @type {?string}\n\t\t * @protected\n\t\t */\n\t\tthis.activePath = null;\n\n\t\t/**\n\t\t * Allows prevent navigate from dom prevented event.\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.allowPreventNavigate = true;\n\n\t\t/**\n\t\t * Holds link base path.\n\t\t * @type {!string}\n\t\t * @default ''\n\t\t * @protected\n\t\t */\n\t\tthis.basePath = '';\n\n\t\t/**\n\t\t * Captures scroll position from scroll event.\n\t\t * @type {!boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.captureScrollPositionFromScrollEvent = true;\n\n\t\t/**\n\t\t * Holds the default page title.\n\t\t * @type {string}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.defaultTitle = globals.document.title;\n\n\t\t/**\n\t\t * Holds the form selector to define forms that are routed.\n\t\t * @type {!string}\n\t\t * @default form[enctype=\"multipart/form-data\"]:not([data-senna-off])\n\t\t * @protected\n\t\t */\n\t\tthis.formSelector = 'form[enctype=\"multipart/form-data\"]:not([data-senna-off])';\n\n\t\t/**\n\t\t * Holds the link selector to define links that are routed.\n\t\t * @type {!string}\n\t\t * @default a:not([data-senna-off])\n\t\t * @protected\n\t\t */\n\t\tthis.linkSelector = 'a:not([data-senna-off])';\n\n\t\t/**\n\t\t * Holds the loading css class.\n\t\t * @type {!string}\n\t\t * @default senna-loading\n\t\t * @protected\n\t\t */\n\t\tthis.loadingCssClass = 'senna-loading';\n\n\t\t/**\n\t\t * Using the History API to manage your URLs is awesome and, as it happens,\n\t\t * a crucial feature of good web apps. One of its downsides, however, is\n\t\t * that scroll positions are stored and then, more importantly, restored\n\t\t * whenever you traverse the history. This often means unsightly jumps as\n\t\t * the scroll position changes automatically, and especially so if your app\n\t\t * does transitions, or changes the contents of the page in any way.\n\t\t * Ultimately this leads to an horrible user experience. The good news is,\n\t\t * however, that there’s a potential fix: history.scrollRestoration.\n\t\t * https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration\n\t\t * @type {boolean}\n\t\t * @protected\n\t\t */\n\t\tthis.nativeScrollRestorationSupported = ('scrollRestoration' in globals.window.history);\n\n\t\t/**\n\t\t * Holds a deferred with the current navigation.\n\t\t * @type {?CancellablePromise}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.pendingNavigate = null;\n\n\t\t/**\n\t\t * Holds the window horizontal scroll position when the navigation using\n\t\t * back or forward happens to be restored after the surfaces are updated.\n\t\t * @type {!Number}\n\t\t * @default 0\n\t\t * @protected\n\t\t */\n\t\tthis.popstateScrollLeft = 0;\n\n\t\t/**\n\t\t * Holds the window vertical scroll position when the navigation using\n\t\t * back or forward happens to be restored after the surfaces are updated.\n\t\t * @type {!Number}\n\t\t * @default 0\n\t\t * @protected\n\t\t */\n\t\tthis.popstateScrollTop = 0;\n\n\t\t/**\n\t\t * Holds the redirect path containing the query parameters.\n\t\t * @type {?string}\n\t\t * @protected\n\t\t */\n\t\tthis.redirectPath = null;\n\n\t\t/**\n\t\t * Holds the screen routes configuration.\n\t\t * @type {?Array}\n\t\t * @default []\n\t\t * @protected\n\t\t */\n\t\tthis.routes = [];\n\n\t\t/**\n\t\t * Maps the screen instances by the url containing the parameters.\n\t\t * @type {?Object}\n\t\t * @default {}\n\t\t * @protected\n\t\t */\n\t\tthis.screens = {};\n\n\t\t/**\n\t\t * When set to true the first erroneous popstate fired on page load will be\n\t\t * ignored, only if globals.window.history.state is also\n\t\t * null.\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t * @protected\n\t\t */\n\t\tthis.skipLoadPopstate = false;\n\n\t\t/**\n\t\t * Maps that index the surfaces instances by the surface id.\n\t\t * @type {?Object}\n\t\t * @default {}\n\t\t * @protected\n\t\t */\n\t\tthis.surfaces = {};\n\n\t\t/**\n\t\t * When set to true, moves the scroll position after popstate, or to the\n\t\t * top of the viewport for new navigation. If false, the browser will\n\t\t * take care of scroll restoration.\n\t\t * @type {!boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.updateScrollPosition = true;\n\n\t\tthis.appEventHandlers_ = new EventHandler();\n\n\t\tthis.appEventHandlers_.add(\n\t\t\tdom.on(globals.window, 'scroll', debounce(this.onScroll_.bind(this), 100)),\n\t\t\tdom.on(globals.window, 'load', this.onLoad_.bind(this)),\n\t\t\tdom.on(globals.window, 'popstate', this.onPopstate_.bind(this))\n\t\t);\n\n\t\tthis.on('startNavigate', this.onStartNavigate_);\n\t\tthis.on('beforeNavigate', this.onBeforeNavigate_);\n\t\tthis.on('beforeNavigate', this.onBeforeNavigateDefault_, true);\n\n\t\tthis.setLinkSelector(this.linkSelector);\n\t\tthis.setFormSelector(this.formSelector);\n\t}\n\n\t/**\n\t * Adds one or more screens to the application.\n\t *\n\t * Example:\n\t *\n\t * \n\t * app.addRoutes({ path: '/foo', handler: FooScreen });\n\t * or\n\t * app.addRoutes([{ path: '/foo', handler: function(route) { return new FooScreen(); } }]);\n\t * \n\t *\n\t * @param {Object} or {Array} routes Single object or an array of object.\n\t * Each object should contain path and screen.\n\t * The path should be a string or a regex that maps the\n\t * navigation route to a screen class definition (not an instance), e.g:\n\t * { path: \"/home:param1\", handler: MyScreen }\n\t * { path: /foo.+/, handler: MyScreen }\n\t * @chainable\n\t */\n\taddRoutes(routes) {\n\t\tif (!Array.isArray(routes)) {\n\t\t\troutes = [routes];\n\t\t}\n\t\troutes.forEach((route) => {\n\t\t\tif (!(route instanceof Route)) {\n\t\t\t\troute = new Route(route.path, route.handler);\n\t\t\t}\n\t\t\tthis.routes.push(route);\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds one or more surfaces to the application.\n\t * @param {Surface|String|Array.} surfaces\n\t * Surface element id or surface instance. You can also pass an Array\n\t * whichcontains surface instances or id. In case of ID, these should be\n\t * the id of surface element.\n\t * @chainable\n\t */\n\taddSurfaces(surfaces) {\n\t\tif (!Array.isArray(surfaces)) {\n\t\t\tsurfaces = [surfaces];\n\t\t}\n\t\tsurfaces.forEach((surface) => {\n\t\t\tif (core.isString(surface)) {\n\t\t\t\tsurface = new Surface(surface);\n\t\t\t}\n\t\t\tthis.surfaces[surface.getId()] = surface;\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns if can navigate to path.\n\t * @param {!string} url\n\t * @return {boolean}\n\t */\n\tcanNavigate(url) {\n\t\tvar path = utils.getUrlPath(url);\n\t\tvar uri = new Uri(url);\n\n\t\tif (!this.isLinkSameOrigin_(uri.getHostname())) {\n\t\t\tconsole.log('Offsite link clicked');\n\t\t\treturn false;\n\t\t}\n\t\tif (!this.isSameBasePath_(path)) {\n\t\t\tconsole.log('Link clicked outside app\\'s base path');\n\t\t\treturn false;\n\t\t}\n\t\tif (!this.findRoute(path)) {\n\t\t\tconsole.log('No route for ' + path);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Clear screens cache.\n\t * @chainable\n\t */\n\tclearScreensCache() {\n\t\tObject.keys(this.screens).forEach((path) => {\n\t\t\tif (path === this.activePath) {\n\t\t\t\tthis.activeScreen.clearCache();\n\t\t\t} else {\n\t\t\t\tthis.removeScreen(path);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves or create a screen instance to a path.\n\t * @param {!string} path Path containing the querystring part.\n\t * @return {Screen}\n\t */\n\tcreateScreenInstance(path, route) {\n\t\tif (!this.pendingNavigate && path === this.activePath) {\n\t\t\tconsole.log('Already at destination, refresh navigation');\n\t\t\treturn this.activeScreen;\n\t\t}\n\t\t/* jshint newcap: false */\n\t\tvar screen = this.screens[path];\n\t\tif (!screen) {\n\t\t\tvar handler = route.getHandler();\n\t\t\tif (handler === Screen || Screen.isImplementedBy(handler.prototype)) {\n\t\t\t\tscreen = new handler();\n\t\t\t} else {\n\t\t\t\tscreen = handler(route) || new Screen();\n\t\t\t}\n\t\t\tconsole.log('Create screen for [' + path + '] [' + screen + ']');\n\t\t}\n\t\treturn screen;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tif (this.activeScreen) {\n\t\t\tthis.removeScreen(this.activePath);\n\t\t}\n\t\tthis.clearScreensCache();\n\t\tthis.formEventHandler_.removeListener();\n\t\tthis.linkEventHandler_.removeListener();\n\t\tthis.appEventHandlers_.removeAllListeners();\n\t\tsuper.disposeInternal();\n\t}\n\n\t/**\n\t * Dispatches to the first route handler that matches the current path, if\n\t * any.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tdispatch() {\n\t\treturn this.navigate(utils.getCurrentBrowserPath(), true);\n\t}\n\n\t/**\n\t * Starts navigation to a path.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tdoNavigate_(path, opt_replaceHistory) {\n\t\tif (this.activeScreen && this.activeScreen.beforeDeactivate()) {\n\t\t\tthis.pendingNavigate = CancellablePromise.reject(new CancellablePromise.CancellationError('Cancelled by active screen'));\n\t\t\treturn this.pendingNavigate;\n\t\t}\n\n\t\tvar route = this.findRoute(path);\n\t\tif (!route) {\n\t\t\tthis.pendingNavigate = CancellablePromise.reject(new CancellablePromise.CancellationError('No route for ' + path));\n\t\t\treturn this.pendingNavigate;\n\t\t}\n\n\t\tconsole.log('Navigate to [' + path + ']');\n\n\t\tthis.stopPendingNavigate_();\n\n\t\tvar nextScreen = this.createScreenInstance(path, route);\n\n\t\treturn nextScreen.load(path)\n\t\t\t.then(() => {\n\t\t\t\tif (this.activeScreen) {\n\t\t\t\t\tthis.activeScreen.deactivate();\n\t\t\t\t}\n\t\t\t\tthis.prepareNavigateHistory_(path, nextScreen, opt_replaceHistory);\n\t\t\t\tthis.prepareNavigateSurfaces_(nextScreen, this.surfaces);\n\t\t\t})\n\t\t\t.then(() => nextScreen.evaluateStyles(this.surfaces))\n\t\t\t.then(() => nextScreen.flip(this.surfaces))\n\t\t\t.then(() => nextScreen.evaluateScripts(this.surfaces))\n\t\t\t.then(() => this.syncScrollPositionSyncThenAsync_())\n\t\t\t.then(() => this.finalizeNavigate_(path, nextScreen))\n\t\t\t.catch((reason) => {\n\t\t\t\tthis.handleNavigateError_(path, nextScreen, reason);\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * Finalizes a screen navigation.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @protected\n\t */\n\tfinalizeNavigate_(path, nextScreen) {\n\t\tnextScreen.activate();\n\n\t\tif (this.activeScreen && !this.activeScreen.isCacheable()) {\n\t\t\tif (this.activeScreen !== nextScreen) {\n\t\t\t\tthis.removeScreen(this.activePath);\n\t\t\t}\n\t\t}\n\n\t\tthis.activePath = path;\n\t\tthis.activeScreen = nextScreen;\n\t\tthis.screens[path] = nextScreen;\n\t\tthis.pendingNavigate = null;\n\t\tglobals.capturedFormElement = null;\n\t\tconsole.log('Navigation done');\n\t}\n\n\t/**\n\t * Finds a route for the test path. Returns true if matches has a route,\n\t * otherwise returns null.\n\t * @param {!string} path Path containing the querystring part.\n\t * @return {?Object} Route handler if match any or null if the\n\t * path is the same as the current url and the path contains a fragment.\n\t */\n\tfindRoute(path) {\n\t\t// Prevents navigation if it's a hash change on the same url.\n\t\tif ((path.lastIndexOf('#') > -1) && utils.isCurrentBrowserPath(path)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tpath = utils.getUrlPathWithoutHash(path);\n\n\t\t// Makes sure that the path substring will be in the expected format\n\t\t// (that is, will end with a \"/\").\n\t\tpath = utils.getUrlPathWithoutHash(path.substr(this.basePath.length));\n\n\t\tfor (var i = 0; i < this.routes.length; i++) {\n\t\t\tvar route = this.routes[i];\n\t\t\tif (route.matchesPath(path)) {\n\t\t\t\treturn route;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets allow prevent navigate.\n\t * @return {boolean}\n\t */\n\tgetAllowPreventNavigate() {\n\t\treturn this.allowPreventNavigate;\n\t}\n\n\t/**\n\t * Gets link base path.\n\t * @return {!string}\n\t */\n\tgetBasePath() {\n\t\treturn this.basePath;\n\t}\n\n\t/**\n\t * Gets the default page title.\n\t * @return {string} defaultTitle\n\t */\n\tgetDefaultTitle() {\n\t\treturn this.defaultTitle;\n\t}\n\n\t/**\n\t * Gets the form selector.\n\t * @return {!string}\n\t */\n\tgetFormSelector() {\n\t\treturn this.formSelector;\n\t}\n\n\t/**\n\t * Gets the link selector.\n\t * @return {!string}\n\t */\n\tgetLinkSelector() {\n\t\treturn this.linkSelector;\n\t}\n\n\t/**\n\t * Gets the loading css class.\n\t * @return {!string}\n\t */\n\tgetLoadingCssClass() {\n\t\treturn this.loadingCssClass;\n\t}\n\n\t/**\n\t * Gets the update scroll position value.\n\t * @return {boolean}\n\t */\n\tgetUpdateScrollPosition() {\n\t\treturn this.updateScrollPosition;\n\t}\n\n\t/**\n\t * Handle navigation error.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @param {!Error} error\n\t * @protected\n\t */\n\thandleNavigateError_(path, nextScreen, err) {\n\t\tconsole.log('Navigation error for [' + nextScreen + '] (' + err + ')');\n\t\tif (!utils.isCurrentBrowserPath(path)) {\n\t\t\tthis.removeScreen(path);\n\t\t}\n\t}\n\n\t/**\n\t * Checks if app has routes.\n\t * @return {boolean}\n\t */\n\thasRoutes() {\n\t\treturn this.routes.length > 0;\n\t}\n\n\t/**\n\t * Tests if hostname is an offsite link.\n\t * @param {!string} hostname Link hostname to compare with\n\t * globals.window.location.hostname.\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisLinkSameOrigin_(hostname) {\n\t\treturn hostname === globals.window.location.hostname;\n\t}\n\n\t/**\n\t * Tests if link element has the same app's base path.\n\t * @param {!string} path Link path containing the querystring part.\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisSameBasePath_(path) {\n\t\treturn path.indexOf(this.basePath) === 0;\n\t}\n\n\t/**\n\t * Lock the document scroll in order to avoid the browser native back and\n\t * forward navigation to change the scroll position. In the end of\n\t * navigation lifecycle scroll is repositioned.\n\t * @protected\n\t */\n\tlockHistoryScrollPosition_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\t\t// Browsers are inconsistent when re-positioning the scroll history on\n\t\t// popstate. At some browsers, history scroll happens before popstate, then\n\t\t// lock the scroll on the last known position as soon as possible after the\n\t\t// current JS execution context and capture the current value. Some others,\n\t\t// history scroll happens after popstate, in this case, we bind an once\n\t\t// scroll event to lock the las known position. Lastly, the previous two\n\t\t// behaviors can happen even on the same browser, hence the race will decide\n\t\t// the winner.\n\t\tvar winner = false;\n\t\tvar switchScrollPositionRace = function() {\n\t\t\tglobals.document.removeEventListener('scroll', switchScrollPositionRace, false);\n\t\t\tif (!winner) {\n\t\t\t\tglobals.window.scrollTo(state.scrollLeft, state.scrollTop);\n\t\t\t\twinner = true;\n\t\t\t}\n\t\t};\n\t\tasync.nextTick(switchScrollPositionRace);\n\t\tglobals.document.addEventListener('scroll', switchScrollPositionRace, false);\n\t}\n\n\t/**\n\t * If supported by the browser, disables native scroll restoration and\n\t * stores current value.\n\t */\n\tmaybeDisableNativeScrollRestoration() {\n\t\tif (this.nativeScrollRestorationSupported) {\n\t\t\tthis.nativeScrollRestoration_ = globals.window.history.scrollRestoration;\n\t\t\tglobals.window.history.scrollRestoration = 'manual';\n\t\t}\n\t}\n\n\t/**\n\t * Maybe navigate to a path.\n\t * @param {string} href Information about the link's href.\n\t * @param {Event} event Dom event that initiated the navigation.\n\t */\n\tmaybeNavigate_(href, event) {\n\t\tif (!this.canNavigate(href)) {\n\t\t\treturn;\n\t\t}\n\n\t\tglobals.capturedFormElement = event.capturedFormElement;\n\n\t\tvar navigateFailed = false;\n\t\ttry {\n\t\t\tthis.navigate(utils.getUrlPath(href));\n\t\t} catch (err) {\n\t\t\t// Do not prevent link navigation in case some synchronous error occurs\n\t\t\tnavigateFailed = true;\n\t\t}\n\n\t\tif (!navigateFailed) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\t/**\n\t * Maybe reposition scroll to hashed anchor.\n\t */\n\tmaybeRepositionScrollToHashedAnchor() {\n\t\tvar hash = globals.window.location.hash;\n\t\tif (hash) {\n\t\t\tvar anchorElement = globals.document.getElementById(hash.substring(1));\n\t\t\tif (anchorElement) {\n\t\t\t\tglobals.window.scrollTo(anchorElement.offsetLeft, anchorElement.offsetTop);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * If supported by the browser, restores native scroll restoration to the\n\t * value captured by `maybeDisableNativeScrollRestoration`.\n\t */\n\tmaybeRestoreNativeScrollRestoration() {\n\t\tif (this.nativeScrollRestorationSupported && this.nativeScrollRestoration_) {\n\t\t\tglobals.window.history.scrollRestoration = this.nativeScrollRestoration_;\n\t\t}\n\t}\n\n\t/**\n\t * Navigates to the specified path if there is a route handler that matches.\n\t * @param {!string} path Path to navigate containing the base path.\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tnavigate(path, opt_replaceHistory) {\n\t\tif (!utils.isHtml5HistorySupported()) {\n\t\t\tthrow new Error('HTML5 History is not supported. Senna will not intercept navigation.');\n\t\t}\n\n\t\t// When reloading the same path do replaceState instead of pushState to\n\t\t// avoid polluting history with states with the same path.\n\t\tif (path === this.activePath) {\n\t\t\topt_replaceHistory = true;\n\t\t}\n\n\t\tthis.emit('beforeNavigate', {\n\t\t\tpath: path,\n\t\t\treplaceHistory: !!opt_replaceHistory\n\t\t});\n\n\t\treturn this.pendingNavigate;\n\t}\n\n\t/**\n\t * Befores navigation to a path.\n\t * @param {!Event} event Event facade containing path and\n\t * replaceHistory.\n\t * @protected\n\t */\n\tonBeforeNavigate_(event) {\n\t\tif (globals.capturedFormElement) {\n\t\t\tevent.form = globals.capturedFormElement;\n\t\t}\n\t}\n\n\t/**\n\t * Befores navigation to a path. Runs after external listeners.\n\t * @param {!Event} event Event facade containing path and\n\t * replaceHistory.\n\t * @protected\n\t */\n\tonBeforeNavigateDefault_(event) {\n\t\tif (this.pendingNavigate) {\n\t\t\tif (this.pendingNavigate.path === event.path) {\n\t\t\t\tconsole.log('Waiting...');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tthis.emit('startNavigate', {\n\t\t\tform: event.form,\n\t\t\tpath: event.path,\n\t\t\treplaceHistory: event.replaceHistory\n\t\t});\n\t}\n\n\t/**\n\t * Intercepts document clicks and test link elements in order to decide\n\t * whether Surface app can navigate.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonDocClickDelegate_(event) {\n\t\tif (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || event.button) {\n\t\t\tconsole.log('Navigate aborted, invalid mouse button or modifier key pressed.');\n\t\t\treturn;\n\t\t}\n\t\tthis.maybeNavigate_(event.delegateTarget.href, event);\n\t}\n\n\t/**\n\t * Intercepts document form submits and test action path in order to decide\n\t * whether Surface app can navigate.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonDocSubmitDelegate_(event) {\n\t\tvar form = event.delegateTarget;\n\t\tif (form.method === 'get') {\n\t\t\tconsole.log('GET method not supported');\n\t\t\treturn;\n\t\t}\n\t\tevent.capturedFormElement = form;\n\t\tthis.maybeNavigate_(form.action, event);\n\t}\n\n\t/**\n\t * Listens to the window's load event in order to avoid issues with some browsers\n\t * that trigger popstate calls on the first load. For more information see\n\t * http://stackoverflow.com/questions/6421769/popstate-on-pages-load-in-chrome.\n\t * @protected\n\t */\n\tonLoad_() {\n\t\tthis.skipLoadPopstate = true;\n\t\tsetTimeout(() => {\n\t\t\t// The timeout ensures that popstate events will be unblocked right\n\t\t\t// after the load event occured, but not in the same event-loop cycle.\n\t\t\tthis.skipLoadPopstate = false;\n\t\t}, 0);\n\t\t// Try to reposition scroll to the hashed anchor when page loads.\n\t\tthis.maybeRepositionScrollToHashedAnchor();\n\t}\n\n\t/**\n\t * Handles browser history changes and fires app's navigation if the state\n\t * belows to us. If we detect a popstate and the state is null,\n\t * assume it is navigating to an external page or to a page we don't have\n\t * route, then globals.window.location.reload() is invoked in order to\n\t * reload the content to the current url.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonPopstate_(event) {\n\t\tif (this.skipLoadPopstate) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar state = event.state;\n\n\t\tif (!state) {\n\t\t\tif (globals.window.location.hash) {\n\t\t\t\t// If senna is on an redirect path and a hash popstate happens\n\t\t\t\t// to a different url, reload the browser. This behavior doesn't\n\t\t\t\t// require senna to route hashed links and is closer to native\n\t\t\t\t// browser behavior.\n\t\t\t\tif (this.redirectPath && !utils.isCurrentBrowserPath(this.redirectPath)) {\n\t\t\t\t\tthis.reloadPage();\n\t\t\t\t}\n\t\t\t\t// Always try to reposition scroll to the hashed anchor when\n\t\t\t\t// hash popstate happens.\n\t\t\t\tthis.maybeRepositionScrollToHashedAnchor();\n\t\t\t} else {\n\t\t\t\tthis.reloadPage();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (state.senna) {\n\t\t\tconsole.log('History navigation to [' + state.path + ']');\n\t\t\tthis.popstateScrollTop = state.scrollTop;\n\t\t\tthis.popstateScrollLeft = state.scrollLeft;\n\t\t\tif (!this.nativeScrollRestorationSupported) {\n\t\t\t\tthis.lockHistoryScrollPosition_();\n\t\t\t}\n\t\t\tthis.navigate(state.path, true);\n\t\t}\n\t}\n\n\t/**\n\t * Listens document scroll changes in order to capture the possible lock\n\t * scroll position for history scrolling.\n\t * @protected\n\t */\n\tonScroll_() {\n\t\tif (this.captureScrollPositionFromScrollEvent) {\n\t\t\tthis.saveHistoryCurrentPageScrollPosition_();\n\t\t}\n\t}\n\n\t/**\n\t * Starts navigation to a path.\n\t * @param {!Event} event Event facade containing path and\n\t * replaceHistory.\n\t * @protected\n\t */\n\tonStartNavigate_(event) {\n\t\tthis.maybeDisableNativeScrollRestoration();\n\t\tthis.captureScrollPositionFromScrollEvent = false;\n\t\tdom.addClasses(globals.document.documentElement, this.loadingCssClass);\n\n\t\tvar endNavigatePayload = {\n\t\t\tform: event.form,\n\t\t\tpath: event.path\n\t\t};\n\n\t\tthis.pendingNavigate = this.doNavigate_(event.path, event.replaceHistory)\n\t\t\t.catch((reason) => {\n\t\t\t\tendNavigatePayload.error = reason;\n\t\t\t\tthrow reason;\n\t\t\t})\n\t\t\t.thenAlways(() => {\n\t\t\t\tif (!this.pendingNavigate) {\n\t\t\t\t\tdom.removeClasses(globals.document.documentElement, this.loadingCssClass);\n\t\t\t\t\tthis.maybeRestoreNativeScrollRestoration();\n\t\t\t\t\tthis.captureScrollPositionFromScrollEvent = true;\n\t\t\t\t}\n\t\t\t\tthis.emit('endNavigate', endNavigatePayload);\n\t\t\t});\n\n\t\tthis.pendingNavigate.path = event.path;\n\t}\n\n\t/**\n\t * Prefetches the specified path if there is a route handler that matches.\n\t * @param {!string} path Path to navigate containing the base path.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tprefetch(path) {\n\t\tvar route = this.findRoute(path);\n\t\tif (!route) {\n\t\t\treturn CancellablePromise.reject(new CancellablePromise.CancellationError('No route for ' + path));\n\t\t}\n\n\t\tconsole.log('Prefetching [' + path + ']');\n\n\t\tvar nextScreen = this.createScreenInstance(path, route);\n\n\t\treturn nextScreen.load(path)\n\t\t\t.then(() => this.screens[path] = nextScreen)\n\t\t\t.catch((reason) => {\n\t\t\t\tthis.handleNavigateError_(path, nextScreen, reason);\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * Prepares screen flip. Updates history state and surfaces content.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t */\n\tprepareNavigateHistory_(path, nextScreen, opt_replaceHistory) {\n\t\tvar title = nextScreen.getTitle();\n\t\tif (!core.isString(title)) {\n\t\t\ttitle = this.getDefaultTitle();\n\t\t}\n\t\tvar redirectPath = nextScreen.beforeUpdateHistoryPath(path);\n\t\tvar historyState = {\n\t\t\tform: core.isDefAndNotNull(globals.capturedFormElement),\n\t\t\tredirectPath: redirectPath,\n\t\t\tpath: path,\n\t\t\tsenna: true,\n\t\t\tscrollTop: 0,\n\t\t\tscrollLeft: 0\n\t\t};\n\t\tif (opt_replaceHistory) {\n\t\t\thistoryState.scrollTop = this.popstateScrollTop;\n\t\t\thistoryState.scrollLeft = this.popstateScrollLeft;\n\t\t}\n\t\tthis.updateHistory_(title, redirectPath, nextScreen.beforeUpdateHistoryState(historyState), opt_replaceHistory);\n\t\tthis.redirectPath = redirectPath;\n\t}\n\n\t/**\n\t * Prepares screen flip. Updates history state and surfaces content.\n\t * @param {!Screen} nextScreen\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t */\n\tprepareNavigateSurfaces_(nextScreen, surfaces) {\n\t\tObject.keys(surfaces).forEach((id) => {\n\t\t\tvar surfaceContent = nextScreen.getSurfaceContent(id);\n\t\t\tsurfaces[id].addContent(nextScreen.getId(), surfaceContent);\n\t\t\tconsole.log('Screen [' + nextScreen.getId() + '] add content to surface ' +\n\t\t\t\t'[' + surfaces[id] + '] [' + (core.isDefAndNotNull(surfaceContent) ? '...' : 'empty') + ']');\n\t\t});\n\t}\n\n\t/**\n\t * Reloads the page by performing `window.location.reload()`.\n\t */\n\treloadPage() {\n\t\tglobals.window.location.reload();\n\t}\n\n\t/**\n\t * Removes route instance from app routes.\n\t * @param {Route} route\n\t * @return {boolean} True if an element was removed.\n\t */\n\tremoveRoute(route) {\n\t\treturn array.remove(this.routes, route);\n\t}\n\n\t/**\n\t * Removes a screen.\n\t * @param {!string} path Path containing the querystring part.\n\t */\n\tremoveScreen(path) {\n\t\tvar screen = this.screens[path];\n\t\tif (screen) {\n\t\t\tObject.keys(this.surfaces).forEach((surfaceId) => this.surfaces[surfaceId].remove(screen.getId()));\n\t\t\tscreen.dispose();\n\t\t\tdelete this.screens[path];\n\t\t}\n\t}\n\n\t/**\n\t * Saves scroll position from page offset into history state.\n\t */\n\tsaveHistoryCurrentPageScrollPosition_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (state && state.senna) {\n\t\t\tstate.scrollTop = globals.window.pageYOffset;\n\t\t\tstate.scrollLeft = globals.window.pageXOffset;\n\t\t\tglobals.window.history.replaceState(state, null, null);\n\t\t}\n\t}\n\n\t/**\n\t * Sets allow prevent navigate.\n\t * @param {boolean} allowPreventNavigate\n\t */\n\tsetAllowPreventNavigate(allowPreventNavigate) {\n\t\tthis.allowPreventNavigate = allowPreventNavigate;\n\t}\n\n\t/**\n\t * Sets link base path.\n\t * @param {!string} path\n\t */\n\tsetBasePath(basePath) {\n\t\tthis.basePath = basePath;\n\t}\n\n\t/**\n\t * Sets the default page title.\n\t * @param {string} defaultTitle\n\t */\n\tsetDefaultTitle(defaultTitle) {\n\t\tthis.defaultTitle = defaultTitle;\n\t}\n\n\t/**\n\t * Sets the form selector.\n\t * @param {!string} formSelector\n\t */\n\tsetFormSelector(formSelector) {\n\t\tthis.formSelector = formSelector;\n\t\tif (this.formEventHandler_) {\n\t\t\tthis.formEventHandler_.removeListener();\n\t\t}\n\t\tthis.formEventHandler_ = dom.delegate(document, 'submit', this.formSelector, this.onDocSubmitDelegate_.bind(this), this.allowPreventNavigate);\n\t}\n\n\t/**\n\t * Sets the link selector.\n\t * @param {!string} linkSelector\n\t */\n\tsetLinkSelector(linkSelector) {\n\t\tthis.linkSelector = linkSelector;\n\t\tif (this.linkEventHandler_) {\n\t\t\tthis.linkEventHandler_.removeListener();\n\t\t}\n\t\tthis.linkEventHandler_ = dom.delegate(document, 'click', this.linkSelector, this.onDocClickDelegate_.bind(this), this.allowPreventNavigate);\n\t}\n\n\t/**\n\t * Sets the loading css class.\n\t * @param {!string} loadingCssClass\n\t */\n\tsetLoadingCssClass(loadingCssClass) {\n\t\tthis.loadingCssClass = loadingCssClass;\n\t}\n\n\t/**\n\t * Sets the update scroll position value.\n\t * @param {boolean} updateScrollPosition\n\t */\n\tsetUpdateScrollPosition(updateScrollPosition) {\n\t\tthis.updateScrollPosition = updateScrollPosition;\n\t}\n\n\t/**\n\t * Cancels pending navigate with Cancel pending navigation error.\n\t * @protected\n\t */\n\tstopPendingNavigate_() {\n\t\tif (this.pendingNavigate) {\n\t\t\tthis.pendingNavigate.cancel('Cancel pending navigation');\n\t\t\tthis.pendingNavigate = null;\n\t\t}\n\t}\n\n\t/**\n\t * Sync document scroll position twice, the first one synchronous and then\n\t * one inside async.nextTick. Relevant to browsers that fires\n\t * scroll restoration asynchronously after popstate.\n\t * @protected\n\t * @return {?CancellablePromise=}\n\t */\n\tsyncScrollPositionSyncThenAsync_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar scrollTop = state.scrollTop;\n\t\tvar scrollLeft = state.scrollLeft;\n\n\t\tvar sync = () => {\n\t\t\tif (this.updateScrollPosition) {\n\t\t\t\tglobals.window.scrollTo(scrollLeft, scrollTop);\n\t\t\t}\n\t\t};\n\n\t\treturn new CancellablePromise((resolve) => sync() & async.nextTick(() => sync() & resolve()));\n\t}\n\n\t/**\n\t * Updates or replace browser history.\n\t * @param {?string} title Document title.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!object} state\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @protected\n\t */\n\tupdateHistory_(title, path, state, opt_replaceHistory) {\n\t\tif (opt_replaceHistory) {\n\t\t\tglobals.window.history.replaceState(state, title, path);\n\t\t} else {\n\t\t\tglobals.window.history.pushState(state, title, path);\n\t\t}\n\t\tglobals.document.title = title;\n\t}\n\n}\n\nexport default App;\n","'use strict';\n\nimport { core } from 'metal';\nimport Uri from 'metal-uri';\nimport { CancellablePromise as Promise } from 'metal-promise';\n\nclass Ajax {\n\n\t/**\n\t * XmlHttpRequest's getAllResponseHeaders() method returns a string of\n\t * response headers according to the format described on the spec:\n\t * {@link http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders-method}.\n\t * This method parses that string into a user-friendly name/value pair\n\t * object.\n\t * @param {string} allHeaders All headers as string.\n\t * @return {!Array.>}\n\t */\n\tstatic parseResponseHeaders(allHeaders) {\n\t\tvar headers = [];\n\t\tif (!allHeaders) {\n\t\t\treturn headers;\n\t\t}\n\t\tvar pairs = allHeaders.split('\\u000d\\u000a');\n\t\tfor (var i = 0; i < pairs.length; i++) {\n\t\t\tvar index = pairs[i].indexOf('\\u003a\\u0020');\n\t\t\tif (index > 0) {\n\t\t\t\tvar name = pairs[i].substring(0, index);\n\t\t\t\tvar value = pairs[i].substring(index + 2);\n\t\t\t\theaders.push({\n\t\t\t\t\tname: name,\n\t\t\t\t\tvalue: value\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn headers;\n\t}\n\n\t/**\n\t * Requests the url using XMLHttpRequest.\n\t * @param {!string} url\n\t * @param {!string} method\n\t * @param {?string} body\n\t * @param {MultiMap=} opt_headers\n\t * @param {MultiMap=} opt_params\n\t * @param {number=} opt_timeout\n\t * @param {boolean=} opt_sync\n\t * @param {boolean=} opt_withCredentials\n\t * @return {Promise} Deferred ajax request.\n\t * @protected\n\t */\n\tstatic request(url, method, body, opt_headers, opt_params, opt_timeout, opt_sync, opt_withCredentials) {\n\t\tvar request = new XMLHttpRequest();\n\n\t\tvar promise = new Promise(function(resolve, reject) {\n\t\t\trequest.onload = function() {\n\t\t\t\tif (request.aborted) {\n\t\t\t\t\trequest.onerror();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tresolve(request);\n\t\t\t};\n\t\t\trequest.onerror = function() {\n\t\t\t\tvar error = new Error('Request error');\n\t\t\t\terror.request = request;\n\t\t\t\treject(error);\n\t\t\t};\n\t\t}).thenCatch(function(reason) {\n\t\t\trequest.abort();\n\t\t\tthrow reason;\n\t\t}).thenAlways(function() {\n\t\t\tclearTimeout(timeout);\n\t\t});\n\n\t\tif (opt_params) {\n\t\t\turl = new Uri(url).addParametersFromMultiMap(opt_params).toString();\n\t\t}\n\n\t\trequest.open(method, url, !opt_sync);\n\n\t\tif (opt_withCredentials) {\n\t\t\trequest.withCredentials = true;\n\t\t}\n\n\t\tif (opt_headers) {\n\t\t\topt_headers.names().forEach(function(name) {\n\t\t\t\trequest.setRequestHeader(name, opt_headers.getAll(name).join(', '));\n\t\t\t});\n\t\t}\n\n\t\trequest.send(core.isDef(body) ? body : null);\n\n\t\tif (core.isDefAndNotNull(opt_timeout)) {\n\t\t\tvar timeout = setTimeout(function() {\n\t\t\t\tpromise.cancel('Request timeout');\n\t\t\t}, opt_timeout);\n\t\t}\n\n\t\treturn promise;\n\t}\n\n}\n\nexport default Ajax;\n","'use strict';\n\n/**\n * Holds value error messages.\n * @const\n */\nclass errors {\n}\n\n/**\n * Invalid status error message.\n * @type {string}\n * @static\n */\nerrors.INVALID_STATUS = 'Invalid status code';\n\n/**\n * Request error message.\n * @type {string}\n * @static\n */\nerrors.REQUEST_ERROR = 'Request error';\n\n/**\n * Request timeout error message.\n * @type {string}\n * @static\n */\nerrors.REQUEST_TIMEOUT = 'Request timeout';\n\nexport default errors;","'use strict';\n\n/**\n * Metal.js browser user agent detection. It's extremely recommended the usage\n * of feature checking over browser user agent sniffing. Unfortunately, in some\n * situations feature checking can be slow or even impossible, therefore use\n * this utility with caution.\n * @see User agent strings.\n */\nclass UA {\n\t/**\n\t * Gets the native userAgent string from navigator if it exists. If\n\t * navigator or navigator.userAgent string is missing, returns an empty\n\t * string.\n\t * @return {string}\n\t * @private\n\t * @static\n\t */\n\tstatic getNativeUserAgent() {\n\t\tvar navigator = UA.globals.window.navigator;\n\t\tif (navigator) {\n\t\t\tvar userAgent = navigator.userAgent;\n\t\t\tif (userAgent) {\n\t\t\t\treturn userAgent;\n\t\t\t}\n\t\t}\n\t\treturn '';\n\t}\n\n\t/**\n\t * Whether the user agent contains the given string, ignoring case.\n\t * @param {string} str\n\t * @return {boolean}\n\t * @private\n\t * @static\n\t*/\n\tstatic matchUserAgent(str) {\n\t\treturn UA.userAgent.indexOf(str) !== -1;\n\t}\n\n\t/**\n\t * Tests the user agent.\n\t * @param {string} userAgent The user agent string.\n\t * @static\n\t */\n\tstatic testUserAgent(userAgent) {\n\t\t/**\n\t\t * Holds the user agent value extracted from browser native user agent.\n\t\t * @type {string}\n\t\t * @static\n\t\t */\n\t\tUA.userAgent = userAgent;\n\n\t\t/**\n\t\t * Whether the user's browser is Opera.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isOpera = UA.matchUserAgent('Opera') || UA.matchUserAgent('OPR');\n\n\t\t/**\n\t\t * Whether the user's browser is IE.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isIe = UA.matchUserAgent('Trident') || UA.matchUserAgent('MSIE');\n\n\t\t/**\n\t\t * Whether the user's browser is Edge.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isEdge = UA.matchUserAgent('Edge');\n\n\t\t/**\n\t\t * Whether the user's browser is IE or Edge.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isIeOrEdge = UA.isIe || UA.isEdge;\n\n\t\t/**\n\t\t * Whether the user's browser is Chrome.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isChrome = (UA.matchUserAgent('Chrome') || UA.matchUserAgent('CriOS')) && !UA.isOpera && !UA.isEdge;\n\n\t\t/**\n\t\t * Whether the user's browser is Safari.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isSafari = UA.matchUserAgent('Safari') && !(UA.isChrome || UA.isOpera || UA.isEdge);\n\n\t\t/**\n\t\t * Whether the user's browser is Firefox.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isFirefox = UA.matchUserAgent('Firefox');\n\t}\n}\n\n/**\n * Exposes global references.\n * @type {object}\n * @static\n */\nUA.globals = {\n\twindow: window\n};\n\nUA.testUserAgent(UA.getNativeUserAgent());\n\nexport default UA;\n","'use strict';\n\nimport { core } from 'metal';\nimport Ajax from 'metal-ajax';\nimport MultiMap from 'metal-multimap';\nimport CancellablePromise from 'metal-promise';\nimport errors from '../errors/errors';\nimport utils from '../utils/utils';\nimport globals from '../globals/globals';\nimport Screen from './Screen';\nimport Uri from 'metal-uri';\nimport UA from 'metal-useragent';\n\nclass RequestScreen extends Screen {\n\n\t/**\n\t * Request screen abstract class to perform io operations on descendant\n\t * screens.\n\t * @constructor\n\t * @extends {Screen}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * @inheritDoc\n\t\t * @default true\n\t\t */\n\t\tthis.cacheable = true;\n\n\t\t/**\n\t\t * Holds default http headers to set on request.\n\t\t * @type {?Object=}\n\t\t * @default {\n\t\t * 'X-PJAX': 'true',\n\t\t * 'X-Requested-With': 'XMLHttpRequest'\n\t\t * }\n\t\t * @protected\n\t\t */\n\t\tthis.httpHeaders = {\n\t\t\t'X-PJAX': 'true',\n\t\t\t'X-Requested-With': 'XMLHttpRequest'\n\t\t};\n\n\t\t/**\n\t\t * Holds default http method to perform the request.\n\t\t * @type {!string}\n\t\t * @default RequestScreen.GET\n\t\t * @protected\n\t\t */\n\t\tthis.httpMethod = RequestScreen.GET;\n\n\t\t/**\n\t\t * Holds the XHR object responsible for the request.\n\t\t * @type {XMLHttpRequest}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.request = null;\n\n\t\t/**\n\t\t * Holds the request timeout in milliseconds.\n\t\t * @type {!number}\n\t\t * @default 30000\n\t\t * @protected\n\t\t */\n\t\tthis.timeout = 30000;\n\t}\n\n\t/**\n\t * Asserts that response status code is valid.\n\t * @param {number} status\n\t * @protected\n\t */\n\tassertValidResponseStatusCode(status) {\n\t\tif (!this.isValidResponseStatusCode(status)) {\n\t\t\tvar error = new Error(errors.INVALID_STATUS);\n\t\t\terror.invalidStatus = true;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tbeforeUpdateHistoryPath(path) {\n\t\tvar redirectPath = this.getRequestPath();\n\t\tif (redirectPath && redirectPath !== path) {\n\t\t\treturn redirectPath;\n\t\t}\n\t\treturn path;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tbeforeUpdateHistoryState(state) {\n\t\t// If state is ours and navigate to post-without-redirect-get set\n\t\t// history state to null, that way Senna will reload the page on\n\t\t// popstate since it cannot predict post data.\n\t\tif (state.senna && state.form && state.redirectPath === state.path) {\n\t\t\treturn null;\n\t\t}\n\t\treturn state;\n\t}\n\n\t/**\n\t * Formats load path before invoking ajax call.\n\t * @param {string} path\n\t * @return {string} Formatted path;\n\t * @protected\n\t */\n\tformatLoadPath(path) {\n\t\tvar uri = new Uri(path);\n\n\t\turi.setHostname(globals.window.location.hostname);\n\t\turi.setProtocol(globals.window.location.protocol);\n\n\t\tif (globals.window.location.port) {\n\t\t\turi.setPort(globals.window.location.port);\n\t\t}\n\n\t\tif (UA.isIeOrEdge && this.httpMethod === RequestScreen.GET) {\n\t\t\treturn uri.makeUnique().toString();\n\t\t}\n\n\t\treturn uri.toString();\n\t}\n\n\t/**\n\t * Gets the http headers.\n\t * @return {?Object=}\n\t */\n\tgetHttpHeaders() {\n\t\treturn this.httpHeaders;\n\t}\n\n\t/**\n\t * Gets the http method.\n\t * @return {!string}\n\t */\n\tgetHttpMethod() {\n\t\treturn this.httpMethod;\n\t}\n\n\t/**\n\t * Gets request path.\n\t * @return {string=}\n\t */\n\tgetRequestPath() {\n\t\tvar request = this.getRequest();\n\t\tif (request) {\n\t\t\tvar requestPath = request.requestPath;\n\t\t\tvar responseUrl = this.maybeExtractResponseUrlFromRequest(request);\n\t\t\tif (responseUrl) {\n\t\t\t\trequestPath = responseUrl;\n\t\t\t}\n\t\t\tif (UA.isIeOrEdge && this.httpMethod === RequestScreen.GET) {\n\t\t\t\trequestPath = new Uri(requestPath).removeUnique().toString();\n\t\t\t}\n\t\t\treturn utils.getUrlPath(requestPath);\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets the request object.\n\t * @return {?Object}\n\t */\n\tgetRequest() {\n\t\treturn this.request;\n\t}\n\n\t/**\n\t * Gets the request timeout.\n\t * @return {!number}\n\t */\n\tgetTimeout() {\n\t\treturn this.timeout;\n\t}\n\n\t/**\n\t * Checks if response succeeded. Any status code 2xx or 3xx is considered\n\t * valid.\n\t * @param {number} statusCode\n\t */\n\tisValidResponseStatusCode(statusCode) {\n\t\treturn statusCode >= 200 && statusCode <= 399;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tload(path) {\n\t\tvar cache = this.getCache();\n\t\tif (core.isDefAndNotNull(cache)) {\n\t\t\treturn CancellablePromise.resolve(cache);\n\t\t}\n\n\t\tvar body = null;\n\t\tvar httpMethod = this.httpMethod;\n\n\t\tvar headers = new MultiMap();\n\t\tObject.keys(this.httpHeaders).forEach(header => headers.add(header, this.httpHeaders[header]));\n\n\t\tif (globals.capturedFormElement) {\n\t\t\tbody = new FormData(globals.capturedFormElement);\n\t\t\thttpMethod = RequestScreen.POST;\n\t\t\tif (UA.isIeOrEdge) {\n\t\t\t\theaders.add('If-None-Match', '\"0\"');\n\t\t\t}\n\t\t}\n\n\t\tvar requestPath = this.formatLoadPath(path);\n\t\treturn Ajax\n\t\t\t.request(requestPath, httpMethod, body, headers, null, this.timeout)\n\t\t\t.then(xhr => {\n\t\t\t\tthis.setRequest(xhr);\n\t\t\t\tthis.assertValidResponseStatusCode(xhr.status);\n\t\t\t\tif (httpMethod === RequestScreen.GET && this.isCacheable()) {\n\t\t\t\t\tthis.addCache(xhr.responseText);\n\t\t\t\t}\n\t\t\t\txhr.requestPath = requestPath;\n\t\t\t\treturn xhr.responseText;\n\t\t\t})\n\t\t\t.catch((reason) => {\n\t\t\t\tswitch (reason.message) {\n\t\t\t\t\tcase errors.REQUEST_TIMEOUT:\n\t\t\t\t\t\treason.timeout = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase errors.REQUEST_ERROR:\n\t\t\t\t\t\treason.requestError = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * The following method tries to extract the response url value by checking\n\t * the custom response header 'X-Request-URL' if proper value is not present\n\t * in XMLHttpRequest. The value of responseURL will be the final URL\n\t * obtained after any redirects. Internet Explorer, Edge and Safari <= 7\n\t * does not yet support the feature. For more information see:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL\n\t * https://xhr.spec.whatwg.org/#the-responseurl-attribute\n\t * @param {XMLHttpRequest} request\n\t * @return {?string} Response url best match.\n\t */\n\tmaybeExtractResponseUrlFromRequest(request) {\n\t\tvar responseUrl = request.responseURL;\n\t\tif (responseUrl) {\n\t\t\treturn responseUrl;\n\t\t}\n\t\treturn request.getResponseHeader(RequestScreen.X_REQUEST_URL_HEADER);\n\t}\n\n\t/**\n\t * Sets the http headers.\n\t * @param {?Object=} httpHeaders\n\t */\n\tsetHttpHeaders(httpHeaders) {\n\t\tthis.httpHeaders = httpHeaders;\n\t}\n\n\t/**\n\t * Sets the http method.\n\t * @param {!string} httpMethod\n\t */\n\tsetHttpMethod(httpMethod) {\n\t\tthis.httpMethod = httpMethod.toLowerCase();\n\t}\n\n\t/**\n\t * Sets the request object.\n\t * @param {?Object} request\n\t */\n\tsetRequest(request) {\n\t\tthis.request = request;\n\t}\n\n\t/**\n\t * Sets the request timeout in milliseconds.\n\t * @param {!number} timeout\n\t */\n\tsetTimeout(timeout) {\n\t\tthis.timeout = timeout;\n\t}\n\n}\n\n/**\n * Holds value for method get.\n * @type {string}\n * @default 'get'\n * @static\n */\nRequestScreen.GET = 'get';\n\n/**\n * Holds value for method post.\n * @type {string}\n * @default 'post'\n * @static\n */\nRequestScreen.POST = 'post';\n\n/**\n * Fallback http header to retrieve response request url.\n * @type {string}\n * @default 'X-Request-URL'\n * @static\n */\nRequestScreen.X_REQUEST_URL_HEADER = 'X-Request-URL';\n\nexport default RequestScreen;\n","'use strict';\n\nimport { core } from 'metal';\nimport { dom, globalEval, globalEvalStyles } from 'metal-dom';\nimport CancellablePromise from 'metal-promise';\nimport globals from '../globals/globals';\nimport RequestScreen from './RequestScreen';\nimport Surface from '../surface/Surface';\nimport UA from 'metal-useragent';\nimport Uri from 'metal-uri';\nimport utils from '../utils/utils';\n\nclass HtmlScreen extends RequestScreen {\n\n\t/**\n\t * Screen class that perform a request and extracts surface contents from\n\t * the response content.\n\t * @constructor\n\t * @extends {RequestScreen}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the title selector. Relevant to extract the </code>\n\t\t * element from request fragments to use as the screen title.\n\t\t * @type {!string}\n\t\t * @default title\n\t\t * @protected\n\t\t */\n\t\tthis.titleSelector = 'title';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tactivate() {\n\t\tsuper.activate();\n\t\tthis.releaseVirtualDocument();\n\t\tthis.pendingStyles = null;\n\t}\n\n\t/**\n\t * Allocates virtual document for content. After allocated virtual document\n\t * can be accessed by <code>this.virtualDocument</code>.\n\t * @param {!string} htmlString\n\t */\n\tallocateVirtualDocumentForContent(htmlString) {\n\t\tif (!this.virtualDocument) {\n\t\t\tthis.virtualDocument = globals.document.createElement('html');\n\t\t}\n\n\t\tthis.copyNodeAttributesFromContent_(htmlString, this.virtualDocument);\n\n\t\tthis.virtualDocument.innerHTML = htmlString;\n\t}\n\n\t/**\n\t * Customizes logic to append styles into document. Relevant to when\n\t * tracking a style by id make sure to re-positions the new style in the\n\t * same dom order.\n\t * @param {Element} newStyle\n\t */\n\tappendStyleIntoDocument_(newStyle) {\n\t\tvar isTemporaryStyle = dom.match(newStyle, HtmlScreen.selectors.stylesTemporary);\n\t\tif (isTemporaryStyle) {\n\t\t\tthis.pendingStyles.push(newStyle);\n\t\t}\n\t\tif (newStyle.id) {\n\t\t\tvar styleInDoc = globals.document.getElementById(newStyle.id);\n\t\t\tif (styleInDoc) {\n\t\t\t\tstyleInDoc.parentNode.insertBefore(newStyle, styleInDoc.nextSibling);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tglobals.document.head.appendChild(newStyle);\n\t}\n\n\t/**\n\t * If body is used as surface forces the requested documents to have same id\n\t * of the initial page.\n\t */\n\tassertSameBodyIdInVirtualDocument() {\n\t\tvar bodySurface = this.virtualDocument.querySelector('body');\n\t\tif (!globals.document.body.id) {\n\t\t\tglobals.document.body.id = 'senna_surface_' + core.getUid();\n\t\t}\n\t\tif (bodySurface) {\n\t\t\tbodySurface.id = globals.document.body.id;\n\t\t}\n\t}\n\n\t/**\n\t * Copies attributes from the <html> tag of content to the given node.\n\t */\n\tcopyNodeAttributesFromContent_(content, node) {\n\t\tcontent = content.replace(/[<]\\s*html/ig, '<senna');\n\t\tcontent = content.replace(/\\/html\\s*\\>/ig, '/senna>');\n\t\tnode.innerHTML = content;\n\t\tvar placeholder = node.querySelector('senna');\n\t\tif (placeholder) {\n\t\t\tutils.clearNodeAttributes(node);\n\t\t\tutils.copyNodeAttributes(placeholder, node);\n\t\t}\n\t}\n\n\t/**\n\t * @Override\n\t */\n\tdisposeInternal() {\n\t\tthis.disposePendingStyles();\n\t\tsuper.disposeInternal();\n\t}\n\n\t/**\n\t * Disposes pending styles if screen get disposed prior to its loading.\n\t */\n\tdisposePendingStyles() {\n\t\tif (this.pendingStyles) {\n\t\t\tthis.pendingStyles.forEach((style) => dom.exitDocument(style));\n\t\t}\n\t}\n\n\t/**\n\t * @Override\n\t */\n\tevaluateScripts(surfaces) {\n\t\tvar evaluateTrackedScripts = this.evaluateTrackedResources_(\n\t\t\tglobalEval.runScriptsInElement, HtmlScreen.selectors.scripts,\n\t\t\tHtmlScreen.selectors.scriptsTemporary, HtmlScreen.selectors.scriptsPermanent);\n\n\t\treturn evaluateTrackedScripts.then(() => super.evaluateScripts(surfaces));\n\t}\n\n\t/**\n\t * @Override\n\t */\n\tevaluateStyles(surfaces) {\n\t\tthis.pendingStyles = [];\n\t\tvar evaluateTrackedStyles = this.evaluateTrackedResources_(\n\t\t\tglobalEvalStyles.runStylesInElement, HtmlScreen.selectors.styles,\n\t\t\tHtmlScreen.selectors.stylesTemporary, HtmlScreen.selectors.stylesPermanent,\n\t\t\tthis.appendStyleIntoDocument_.bind(this));\n\n\t\treturn evaluateTrackedStyles.then(() => super.evaluateStyles(surfaces));\n\t}\n\n\t/**\n\t * Evaluates tracked resources inside incoming fragment and remove existing\n\t * temporary resources.\n\t * @param {?function()} appendFn Function to append the node into document.\n\t * @param {!string} selector Selector used to find resources to track.\n\t * @param {!string} selectorTemporary Selector used to find temporary\n\t * resources to track.\n\t * @param {!string} selectorPermanent Selector used to find permanent\n\t * resources to track.\n\t * @param {!function} opt_appendResourceFn Optional function used to\n\t * evaluate fragment containing resources.\n\t * @return {CancellablePromise} Deferred that waits resources evaluation to\n\t * complete.\n\t * @private\n\t */\n\tevaluateTrackedResources_(evaluatorFn, selector, selectorTemporary, selectorPermanent, opt_appendResourceFn) {\n\t\tvar tracked = this.virtualQuerySelectorAll_(selector);\n\t\tvar temporariesInDoc = this.querySelectorAll_(selectorTemporary);\n\t\tvar permanentsInDoc = this.querySelectorAll_(selectorPermanent);\n\n\t\t// Adds permanent resources in document to cache.\n\t\tpermanentsInDoc.forEach((resource) => {\n\t\t\tvar resourceKey = this.getResourceKey_(resource);\n\t\t\tif (resourceKey) {\n\t\t\t\tHtmlScreen.permanentResourcesInDoc[resourceKey] = true;\n\t\t\t}\n\t\t});\n\n\t\tvar frag = dom.buildFragment();\n\t\ttracked.forEach((resource) => {\n\t\t\tvar resourceKey = this.getResourceKey_(resource);\n\t\t\t// Do not load permanent resources if already in document.\n\t\t\tif (!HtmlScreen.permanentResourcesInDoc[resourceKey]) {\n\t\t\t\tfrag.appendChild(resource);\n\t\t\t}\n\t\t\t// If resource has key and is permanent add to cache.\n\t\t\tif (resourceKey && dom.match(resource, selectorPermanent)) {\n\t\t\t\tHtmlScreen.permanentResourcesInDoc[resourceKey] = true;\n\t\t\t}\n\t\t});\n\n\t\treturn new CancellablePromise((resolve) => {\n\t\t\tevaluatorFn(frag, () => {\n\t\t\t\ttemporariesInDoc.forEach((resource) => dom.exitDocument(resource));\n\t\t\t\tresolve();\n\t\t\t}, opt_appendResourceFn);\n\t\t});\n\t}\n\n\t/**\n\t * @Override\n\t */\n\tflip(surfaces) {\n\t\treturn super.flip(surfaces).then(() => {\n\t\t\tutils.clearNodeAttributes(document.documentElement);\n\t\t\tutils.copyNodeAttributes(this.virtualDocument, document.documentElement);\n\t\t});\n\t}\n\n\t/**\n\t * Extracts a key to identify the resource based on its attributes.\n\t * @param {Element} resource\n\t * @return {string} Extracted key based on resource attributes in order of\n\t * preference: id, href, src.\n\t */\n\tgetResourceKey_(resource) {\n\t\treturn resource.id || resource.href || resource.src || '';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tgetSurfaceContent(surfaceId) {\n\t\tvar surface = this.virtualDocument.querySelector('#' + surfaceId);\n\t\tif (surface) {\n\t\t\tvar defaultChild = surface.querySelector('#' + surfaceId + '-' + Surface.DEFAULT);\n\t\t\tif (defaultChild) {\n\t\t\t\treturn defaultChild.innerHTML;\n\t\t\t}\n\t\t\treturn surface.innerHTML; // If default content not found, use surface content\n\t\t}\n\t}\n\n\t/**\n\t * Gets the title selector.\n\t * @return {!string}\n\t */\n\tgetTitleSelector() {\n\t\treturn this.titleSelector;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tload(path) {\n\t\treturn super.load(path)\n\t\t\t.then(content => {\n\t\t\t\tthis.allocateVirtualDocumentForContent(content);\n\t\t\t\tthis.resolveTitleFromVirtualDocument();\n\t\t\t\tthis.assertSameBodyIdInVirtualDocument();\n\t\t\t\tif (UA.isIe) {\n\t\t\t\t\tthis.makeTemporaryStylesHrefsUnique_();\n\t\t\t\t}\n\t\t\t\treturn content;\n\t\t\t});\n\t}\n\n\t/**\n\t * Queries temporary styles from virtual document, and makes them unique.\n\t * This is necessary for caching and load event firing issues specific to\n\t * IE11. https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7940171/\n\t */\n\tmakeTemporaryStylesHrefsUnique_() {\n\t\tvar temporariesInDoc = this.virtualQuerySelectorAll_(HtmlScreen.selectors.stylesTemporary);\n\t\ttemporariesInDoc.forEach((style) => this.replaceStyleAndMakeUnique_(style));\n\t}\n\n\t/**\n\t * Creates a new element from given, copies attributes, mutates href to be\n\t * unique to prevent caching and more than one load/error event from firing.\n\t */\n\treplaceStyleAndMakeUnique_(style) {\n\t\tif (style.href) {\n\t\t\tvar newStyle = globals.document.createElement(style.tagName);\n\t\t\tstyle.href = new Uri(style.href).makeUnique().toString();\n\t\t\tutils.copyNodeAttributes(style, newStyle);\n\t\t\tstyle.parentNode.replaceChild(newStyle, style);\n\t\t\tstyle.disabled = true;\n\t\t}\n\t}\n\n\t/**\n\t * Queries elements from virtual document and returns an array of elements.\n\t * @param {!string} selector\n\t * @return {array.<Element>}\n\t */\n\tvirtualQuerySelectorAll_(selector) {\n\t\treturn Array.prototype.slice.call(this.virtualDocument.querySelectorAll(selector));\n\t}\n\n\t/**\n\t * Queries elements from document and returns an array of elements.\n\t * @param {!string} selector\n\t * @return {array.<Element>}\n\t */\n\tquerySelectorAll_(selector) {\n\t\treturn Array.prototype.slice.call(globals.document.querySelectorAll(selector));\n\t}\n\n\t/**\n\t * Releases virtual document allocated for content.\n\t */\n\treleaseVirtualDocument() {\n\t\tthis.virtualDocument = null;\n\t}\n\n\t/**\n\t * Resolves title from allocated virtual document.\n\t */\n\tresolveTitleFromVirtualDocument() {\n\t\tvar title = this.virtualDocument.querySelector(this.titleSelector);\n\t\tif (title) {\n\t\t\tthis.setTitle(title.innerHTML.trim());\n\t\t}\n\t}\n\n\t/**\n\t * Sets the title selector.\n\t * @param {!string} titleSelector\n\t */\n\tsetTitleSelector(titleSelector) {\n\t\tthis.titleSelector = titleSelector;\n\t}\n\n}\n\n/**\n * Helper selectors for tracking resources.\n * @type {object}\n * @protected\n * @static\n */\nHtmlScreen.selectors = {\n\tscripts: 'script[data-senna-track]',\n\tscriptsPermanent: 'script[data-senna-track=\"permanent\"]',\n\tscriptsTemporary: 'script[data-senna-track=\"temporary\"]',\n\tstyles: 'style[data-senna-track],link[data-senna-track]',\n\tstylesPermanent: 'style[data-senna-track=\"permanent\"],link[data-senna-track=\"permanent\"]',\n\tstylesTemporary: 'style[data-senna-track=\"temporary\"],link[data-senna-track=\"temporary\"]'\n};\n\n/**\n * Caches permanent resource keys.\n * @type {object}\n * @protected\n * @static\n */\nHtmlScreen.permanentResourcesInDoc = {};\n\nexport default HtmlScreen;\n","'use strict';\n\nimport App from './app/App';\nimport HtmlScreen from './screen/HtmlScreen';\nimport RequestScreen from './screen/RequestScreen';\nimport Route from './route/Route';\nimport Screen from './screen/Screen';\n\nexport default App;\nexport { App, HtmlScreen, Route, RequestScreen, Screen };\n","'use strict';\n\nexport default {\n\tbasePath: 'data-senna-base-path',\n\tlinkSelector: 'data-senna-link-selector',\n\tloadingCssClass: 'data-senna-loading-css-class',\n\tsenna: 'data-senna',\n\tdispatch: 'data-senna-dispatch',\n\tsurface: 'data-senna-surface',\n\tupdateScrollPosition: 'data-senna-update-scroll-position'\n};","'use strict';\n\nimport { core, object, Disposable } from 'metal';\nimport dataAttributes from './dataAttributes';\nimport globals from '../globals/globals';\nimport App from './App';\nimport HtmlScreen from '../screen/HtmlScreen';\nimport Route from '../route/Route';\n\nclass AppDataAttributeHandler extends Disposable {\n\n\t/**\n\t * Initilizes App, register surfaces and routes from data attributes.\n\t * @constructor\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the app reference initialized by data attributes.\n\t\t * @type {App}\n\t\t * @default null\n\t\t */\n\t\tthis.app = null;\n\n\t\t/**\n\t\t * Holds the base element to search initialization data attributes. This\n\t\t * element is the container used to enable initialization based on the\n\t\t * presence of `data-senna` attribute.\n\t\t * @type {Element}\n\t\t * @default null\n\t\t */\n\t\tthis.baseElement = null;\n\t}\n\n\t/**\n\t * Inits application based on information scanned from document.\n\t */\n\thandle() {\n\t\tif (!core.isElement(this.baseElement)) {\n\t\t\tthrow new Error('Senna data attribute handler base element ' +\n\t\t\t\t'not set or invalid, try setting a valid element that ' +\n\t\t\t\t'contains a `data-senna` attribute.');\n\t\t}\n\n\t\tif (!this.baseElement.hasAttribute(dataAttributes.senna)) {\n\t\t\tconsole.log('Senna was not initialized from data attributes. ' +\n\t\t\t\t'In order to enable its usage from data attributes try setting ' +\n\t\t\t\t'in the base element, e.g. `<body data-senna>`.');\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.app) {\n\t\t\tthrow new Error('Senna app was already initialized.');\n\t\t}\n\n\t\tconsole.log('Senna initialized from data attribute.');\n\n\t\tthis.app = new App();\n\t\tthis.maybeAddRoutes_();\n\t\tthis.maybeAddSurfaces_();\n\t\tthis.maybeSetBasePath_();\n\t\tthis.maybeSetLinkSelector_();\n\t\tthis.maybeSetLoadingCssClass_();\n\t\tthis.maybeSetUpdateScrollPosition_();\n\t\tthis.maybeDispatch_();\n\t}\n\n\t/**\n\t * Disposes of this instance's object references.\n\t * @override\n\t */\n\tdisposeInternal() {\n\t\tif (this.app) {\n\t\t\tthis.app.dispose();\n\t\t}\n\t}\n\n\t/**\n\t * Gets the app reference.\n\t * @return {App}\n\t */\n\tgetApp() {\n\t\treturn this.app;\n\t}\n\n\t/**\n\t * Gets the base element.\n\t * @return {Element} baseElement\n\t */\n\tgetBaseElement() {\n\t\treturn this.baseElement;\n\t}\n\n\t/**\n\t * Maybe adds app routes from link elements that are `senna-route`.\n\t */\n\tmaybeAddRoutes_() {\n\t\tvar routesSelector = 'link[rel=\"senna-route\"]';\n\t\tthis.querySelectorAllAsArray_(routesSelector).forEach((link) => this.maybeParseLinkRoute_(link));\n\t\tif (!this.app.hasRoutes()) {\n\t\t\tthis.app.addRoutes(new Route(/.*/, HtmlScreen));\n\t\t\tconsole.log('Senna can\\'t find route elements, adding default.');\n\t\t}\n\t}\n\n\t/**\n\t * Maybe adds app surfaces by scanning `data-senna-surface` data attribute.\n\t */\n\tmaybeAddSurfaces_() {\n\t\tvar surfacesSelector = '[' + dataAttributes.surface + ']';\n\t\tthis.querySelectorAllAsArray_(surfacesSelector).forEach((surfaceElement) => {\n\t\t\tthis.updateElementIdIfSpecialSurface_(surfaceElement);\n\t\t\tthis.app.addSurfaces(surfaceElement.id);\n\t\t});\n\t}\n\n\t/**\n\t * Dispatches app navigation to the current path when initializes.\n\t */\n\tmaybeDispatch_() {\n\t\tif (this.baseElement.hasAttribute(dataAttributes.dispatch)) {\n\t\t\tthis.app.dispatch();\n\t\t}\n\t}\n\n\t/**\n\t * Adds app route by parsing valid link elements. A valid link element is of\n\t * the kind `rel=\"senna-route\"`.\n\t * @param {Element} link\n\t */\n\tmaybeParseLinkRoute_(link) {\n\t\tvar route = new Route(this.maybeParseLinkRoutePath_(link), this.maybeParseLinkRouteHandler_(link));\n\t\tthis.app.addRoutes(route);\n\t\tconsole.log('Senna scanned route ' + route.getPath());\n\t}\n\n\t/**\n\t * Maybe parse link route handler.\n\t * @param {Element} link\n\t * @return {?string}\n\t */\n\tmaybeParseLinkRouteHandler_(link) {\n\t\tvar handler = link.getAttribute('type');\n\t\tif (core.isDefAndNotNull(handler)) {\n\t\t\thandler = object.getObjectByName(handler);\n\t\t}\n\t\treturn handler;\n\t}\n\n\t/**\n\t * Maybe parse link route path.\n\t * @param {Element} link\n\t * @return {?string}\n\t */\n\tmaybeParseLinkRoutePath_(link) {\n\t\tvar path = link.getAttribute('href');\n\t\tif (core.isDefAndNotNull(path)) {\n\t\t\tif (path.indexOf('regex:') === 0) {\n\t\t\t\tpath = new RegExp(path.substring(6));\n\t\t\t}\n\t\t}\n\t\treturn path;\n\t}\n\n\t/**\n\t * Maybe sets app base path from `data-senna-base-path` data attribute.\n\t */\n\tmaybeSetBasePath_() {\n\t\tvar basePath = this.baseElement.getAttribute(dataAttributes.basePath);\n\t\tif (core.isDefAndNotNull(basePath)) {\n\t\t\tthis.app.setBasePath(basePath);\n\t\t\tconsole.log('Senna scanned base path ' + basePath);\n\t\t}\n\t}\n\n\t/**\n\t * Maybe sets app link selector from `data-senna-link-selector` data\n\t * attribute.\n\t */\n\tmaybeSetLinkSelector_() {\n\t\tvar linkSelector = this.baseElement.getAttribute(dataAttributes.linkSelector);\n\t\tif (core.isDefAndNotNull(linkSelector)) {\n\t\t\tthis.app.setLinkSelector(linkSelector);\n\t\t\tconsole.log('Senna scanned link selector ' + linkSelector);\n\t\t}\n\t}\n\n\t/**\n\t * Maybe sets app link loading css class from `data-senna-loading-css-class`\n\t * data attribute.\n\t */\n\tmaybeSetLoadingCssClass_() {\n\t\tvar loadingCssClass = this.baseElement.getAttribute(dataAttributes.loadingCssClass);\n\t\tif (core.isDefAndNotNull(loadingCssClass)) {\n\t\t\tthis.app.setLoadingCssClass(loadingCssClass);\n\t\t\tconsole.log('Senna scanned loading css class ' + loadingCssClass);\n\t\t}\n\t}\n\n\t/**\n\t * Maybe sets app update scroll position from\n\t * `data-senna-update-scroll-position` data attribute.\n\t */\n\tmaybeSetUpdateScrollPosition_() {\n\t\tvar updateScrollPosition = this.baseElement.getAttribute(dataAttributes.updateScrollPosition);\n\t\tif (core.isDefAndNotNull(updateScrollPosition)) {\n\t\t\tif (updateScrollPosition === 'false') {\n\t\t\t\tthis.app.setUpdateScrollPosition(false);\n\t\t\t} else {\n\t\t\t\tthis.app.setUpdateScrollPosition(true);\n\t\t\t}\n\t\t\tconsole.log('Senna scanned update scroll position ' + updateScrollPosition);\n\t\t}\n\t}\n\n\t/**\n\t * Queries elements from document and returns an array of elements.\n\t * @param {!string} selector\n\t * @return {array.<Element>}\n\t */\n\tquerySelectorAllAsArray_(selector) {\n\t\treturn Array.prototype.slice.call(globals.document.querySelectorAll(selector));\n\t}\n\n\t/**\n\t * Updates element id if handled as special surface element. Some surfaces\n\t * are slightly different from others, like when threating <code>body</code>\n\t * as surface.\n\t * @param {Element} element\n\t */\n\tupdateElementIdIfSpecialSurface_(element) {\n\t\tif (!element.id && element === globals.document.body) {\n\t\t\telement.id = 'senna_surface_' + core.getUid();\n\t\t}\n\t}\n\n\t/**\n\t * Sets the base element.\n\t * @param {Element} baseElement\n\t */\n\tsetBaseElement(baseElement) {\n\t\tthis.baseElement = baseElement;\n\t}\n\n}\n\nexport default AppDataAttributeHandler;\n","'use strict';\n\nimport globals from '../globals/globals';\nimport AppDataAttributeHandler from './AppDataAttributeHandler';\n\n/**\n * Data attribute handler.\n * @type {AppDataAttributeHandler}\n */\nvar dataAttributeHandler = new AppDataAttributeHandler();\n\nglobals.document.addEventListener('DOMContentLoaded', function() {\n\tdataAttributeHandler.setBaseElement(globals.document.body);\n\tdataAttributeHandler.handle();\n});\n\nexport default dataAttributeHandler;"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["core.js","array.js","async.js","Disposable.js","object.js","string.js","metal.js","debounce.js","domData.js","EventHandle.js","EventEmitter.js","EventEmitterProxy.js","EventHandler.js","events.js","DomDelegatedEventHandle.js","DomEventHandle.js","dom.js","DomEventEmitterProxy.js","features.js","globalEval.js","globalEvalStyles.js","Promise.js","globals.js","parseFromAnchor.js","parse.js","MultiMap.js","Uri.js","utils.js","Route.js","Cacheable.js","Screen.js","Surface.js","App.js","Ajax.js","errors.js","UA.js","RequestScreen.js","HtmlScreen.js","senna.js","dataAttributes.js","AppDataAttributeHandler.js","dataAttributeHandler.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;KAMM;;;;;;;;;;;;;;;;OAWE,2CAAiB;AACvB,SAAM,MAAM,+BAAN,CAAN;AACA;;;;;;;;;;;;;OAWM,mEAA4B,aAAa,cAAc;AAC7D,OAAI,iBAAiB,CAAC,YAAY,YAAZ,CAAD,CAArB;AACA,UAAO,YAAY,SAAZ,IAAyB,CAAC,YAAY,SAAZ,CAAsB,aAAtB,CAAoC,QAApC,CAAjC,EAAgF;AAC/E,kBAAc,YAAY,SAA1B;AACA,mBAAe,IAAf,CAAoB,YAAY,YAAZ,CAApB;AACA;AACD,UAAO,cAAP;AACA;;;;;;;;;;;OASM,2CAAgB,IAAI;AAC1B,OAAI,CAAC,GAAG,IAAR,EAAc;AACb,QAAI,MAAM,GAAG,QAAH,EAAV;AACA,OAAG,IAAH,GAAU,IAAI,SAAJ,CAAc,CAAd,EAAiB,IAAI,OAAJ,CAAY,GAAZ,CAAjB,CAAV;AACA;AACD,UAAO,GAAG,IAAV;AACA;;;;;;;;;;;;;;;OAaM,yBAAO,YAAY,mBAAmB;AAC5C,OAAI,UAAJ,EAAgB;AACf,QAAI,KAAK,WAAW,KAAK,YAAhB,CAAT;AACA,QAAI,q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AAjB,CAAkC,kBAAlC,EAAsD,YAAW;AAChE,yBAAqB,cAArB,CAAoC,QAAQ,QAAR,CAAiB,IAArD;AACA,yBAAqB,MAArB;AACA,GAHD;;oCAKe","file":"senna.js","sourcesContent":["'use strict';\n\n/**\n * A collection of core utility functions.\n * @const\n */\nclass core {\n\t/**\n\t * When defining a class Foo with an abstract method bar(), you can do:\n\t * Foo.prototype.bar = core.abstractMethod\n\t *\n\t * Now if a subclass of Foo fails to override bar(), an error will be thrown\n\t * when bar() is invoked.\n\t *\n\t * @type {!Function}\n\t * @throws {Error} when invoked to indicate the method should be overridden.\n\t */\n\tstatic abstractMethod() {\n\t\tthrow Error('Unimplemented abstract method');\n\t}\n\n\t/**\n\t * Loops constructor super classes collecting its properties values. If\n\t * property is not available on the super class `undefined` will be\n\t * collected as value for the class hierarchy position.\n\t * @param {!function()} constructor Class constructor.\n\t * @param {string} propertyName Property name to be collected.\n\t * @return {Array.<*>} Array of collected values.\n\t * TODO(*): Rethink superclass loop.\n\t */\n\tstatic collectSuperClassesProperty(constructor, propertyName) {\n\t\tvar propertyValues = [constructor[propertyName]];\n\t\twhile (constructor.__proto__ && !constructor.__proto__.isPrototypeOf(Function)) {\n\t\t\tconstructor = constructor.__proto__;\n\t\t\tpropertyValues.push(constructor[propertyName]);\n\t\t}\n\t\treturn propertyValues;\n\t}\n\n\t/**\n\t * Gets the name of the given function. If the current browser doesn't\n\t * support the `name` property, this will calculate it from the function's\n\t * content string.\n\t * @param {!function()} fn\n\t * @return {string}\n\t */\n\tstatic getFunctionName(fn) {\n\t\tif (!fn.name) {\n\t\t\tvar str = fn.toString();\n\t\t\tfn.name = str.substring(9, str.indexOf('('));\n\t\t}\n\t\treturn fn.name;\n\t}\n\n\t/**\n\t * Gets an unique id. If `opt_object` argument is passed, the object is\n\t * mutated with an unique id. Consecutive calls with the same object\n\t * reference won't mutate the object again, instead the current object uid\n\t * returns. See {@link core.UID_PROPERTY}.\n\t * @param {Object=} opt_object Optional object to be mutated with the uid. If\n\t * not specified this method only returns the uid.\n\t * @param {boolean=} opt_noInheritance Optional flag indicating if this\n\t * object's uid property can be inherited from parents or not.\n\t * @throws {Error} when invoked to indicate the method should be overridden.\n\t */\n\tstatic getUid(opt_object, opt_noInheritance) {\n\t\tif (opt_object) {\n\t\t\tvar id = opt_object[core.UID_PROPERTY];\n\t\t\tif (opt_noInheritance && !opt_object.hasOwnProperty(core.UID_PROPERTY)) {\n\t\t\t\tid = null;\n\t\t\t}\n\t\t\treturn id || (opt_object[core.UID_PROPERTY] = core.uniqueIdCounter_++);\n\t\t}\n\t\treturn core.uniqueIdCounter_++;\n\t}\n\n\t/**\n\t * The identity function. Returns its first argument.\n\t * @param {*=} opt_returnValue The single value that will be returned.\n\t * @return {?} The first argument.\n\t */\n\tstatic identityFunction(opt_returnValue) {\n\t\treturn opt_returnValue;\n\t}\n\n\t/**\n\t * Returns true if the specified value is a boolean.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is boolean.\n\t */\n\tstatic isBoolean(val) {\n\t\treturn typeof val === 'boolean';\n\t}\n\n\t/**\n\t * Returns true if the specified value is not undefined.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is defined.\n\t */\n\tstatic isDef(val) {\n\t\treturn val !== undefined;\n\t}\n\n\t/**\n\t * Returns true if value is not undefined or null.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isDefAndNotNull(val) {\n\t\treturn core.isDef(val) && !core.isNull(val);\n\t}\n\n\t/**\n\t * Returns true if value is a document.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isDocument(val) {\n\t\treturn val && typeof val === 'object' && val.nodeType === 9;\n\t}\n\n\t/**\n\t * Returns true if value is a dom element.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isElement(val) {\n\t\treturn val && typeof val === 'object' && val.nodeType === 1;\n\t}\n\n\t/**\n\t * Returns true if the specified value is a function.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is a function.\n\t */\n\tstatic isFunction(val) {\n\t\treturn typeof val === 'function';\n\t}\n\n\t/**\n\t * Returns true if value is null.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isNull(val) {\n\t\treturn val === null;\n\t}\n\n\t/**\n\t * Returns true if the specified value is a number.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is a number.\n\t */\n\tstatic isNumber(val) {\n\t\treturn typeof val === 'number';\n\t}\n\n\t/**\n\t * Returns true if value is a window.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isWindow(val) {\n\t\treturn val !== null && val === val.window;\n\t}\n\n\t/**\n\t * Returns true if the specified value is an object. This includes arrays\n\t * and functions.\n\t * @param {?} val Variable to test.\n\t * @return {boolean} Whether variable is an object.\n\t */\n\tstatic isObject(val) {\n\t\tvar type = typeof val;\n\t\treturn type === 'object' && val !== null || type === 'function';\n\t}\n\n\t/**\n\t * Returns true if value is a Promise.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isPromise(val) {\n\t\treturn val && typeof val === 'object' && typeof val.then === 'function';\n\t}\n\n\t/**\n\t * Returns true if value is a string.\n\t * @param {*} val\n\t * @return {Boolean}\n\t */\n\tstatic isString(val) {\n\t\treturn typeof val === 'string';\n\t}\n\n\t/**\n\t * Merges the values of a static property a class with the values of that\n\t * property for all its super classes, and stores it as a new static\n\t * property of that class. If the static property already existed, it won't\n\t * be recalculated.\n\t * @param {!function()} constructor Class constructor.\n\t * @param {string} propertyName Property name to be collected.\n\t * @param {function(*, *):*=} opt_mergeFn Function that receives an array filled\n\t * with the values of the property for the current class and all its super classes.\n\t * Should return the merged value to be stored on the current class.\n\t * @return {boolean} Returns true if merge happens, false otherwise.\n\t */\n\tstatic mergeSuperClassesProperty(constructor, propertyName, opt_mergeFn) {\n\t\tvar mergedName = propertyName + '_MERGED';\n\t\tif (constructor.hasOwnProperty(mergedName)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tvar merged = core.collectSuperClassesProperty(constructor, propertyName);\n\t\tif (opt_mergeFn) {\n\t\t\tmerged = opt_mergeFn(merged);\n\t\t}\n\t\tconstructor[mergedName] = merged;\n\t\treturn true;\n\t}\n\n\t/**\n\t * Null function used for default values of callbacks, etc.\n\t * @return {void} Nothing.\n\t */\n\tstatic nullFunction() {}\n}\n\n/**\n * Unique id property prefix.\n * @type {String}\n * @protected\n */\ncore.UID_PROPERTY = 'core_' + ((Math.random() * 1e9) >>> 0);\n\n/**\n * Counter for unique id.\n * @type {Number}\n * @private\n */\ncore.uniqueIdCounter_ = 1;\n\nexport default core;\n","'use strict';\n\nimport core from '../core';\n\nclass array {\n\t/**\n\t * Checks if the given arrays have the same content.\n\t * @param {!Array<*>} arr1\n\t * @param {!Array<*>} arr2\n\t * @return {boolean}\n\t */\n\tstatic equal(arr1, arr2) {\n\t\tif (arr1.length !== arr2.length) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (var i = 0; i < arr1.length; i++) {\n\t\t\tif (arr1[i] !== arr2[i]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Returns the first value in the given array that isn't undefined.\n\t * @param {!Array} arr\n\t * @return {*}\n\t */\n\tstatic firstDefinedValue(arr) {\n\t\tfor (var i = 0; i < arr.length; i++) {\n\t\t\tif (arr[i] !== undefined) {\n\t\t\t\treturn arr[i];\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Transforms the input nested array to become flat.\n\t * @param {Array.<*|Array.<*>>} arr Nested array to flatten.\n\t * @param {Array.<*>} opt_output Optional output array.\n\t * @return {Array.<*>} Flat array.\n\t */\n\tstatic flatten(arr, opt_output) {\n\t\tvar output = opt_output || [];\n\t\tfor (var i = 0; i < arr.length; i++) {\n\t\t\tif (Array.isArray(arr[i])) {\n\t\t\t\tarray.flatten(arr[i], output);\n\t\t\t} else {\n\t\t\t\toutput.push(arr[i]);\n\t\t\t}\n\t\t}\n\t\treturn output;\n\t}\n\n\t/**\n\t * Removes the first occurrence of a particular value from an array.\n\t * @param {Array.<T>} arr Array from which to remove value.\n\t * @param {T} obj Object to remove.\n\t * @return {boolean} True if an element was removed.\n\t * @template T\n\t */\n\tstatic remove(arr, obj) {\n\t\tvar i = arr.indexOf(obj);\n\t\tvar rv;\n\t\tif ( (rv = i >= 0) ) {\n\t\t\tarray.removeAt(arr, i);\n\t\t}\n\t\treturn rv;\n\t}\n\n\t/**\n\t * Removes from an array the element at index i\n\t * @param {Array} arr Array or array like object from which to remove value.\n\t * @param {number} i The index to remove.\n\t * @return {boolean} True if an element was removed.\n\t */\n\tstatic removeAt(arr, i) {\n\t\treturn Array.prototype.splice.call(arr, i, 1).length === 1;\n\t}\n\n\t/**\n\t * Slices the given array, just like Array.prototype.slice, but this\n\t * is faster and working on all array-like objects (like arguments).\n\t * @param {!Object} arr Array-like object to slice.\n\t * @param {number} start The index that should start the slice.\n\t * @param {number=} opt_end The index where the slice should end, not\n\t * included in the final array. If not given, all elements after the\n\t * start index will be included.\n\t * @return {!Array}\n\t */\n\tstatic slice(arr, start, opt_end) {\n\t\tvar sliced = [];\n\t\tvar end = core.isDef(opt_end) ? opt_end : arr.length;\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tsliced.push(arr[i]);\n\t\t}\n\t\treturn sliced;\n\t}\n}\n\nexport default array;\n","/*!\n * Polyfill from Google's Closure Library.\n * Copyright 2013 The Closure Library Authors. All Rights Reserved.\n */\n\n'use strict';\n\nvar async = {};\n\n\n/**\n * Throw an item without interrupting the current execution context. For\n * example, if processing a group of items in a loop, sometimes it is useful\n * to report an error while still allowing the rest of the batch to be\n * processed.\n * @param {*} exception\n */\nasync.throwException = function(exception) {\n\t// Each throw needs to be in its own context.\n\tasync.nextTick(function() {\n\t\tthrow exception;\n\t});\n};\n\n\n/**\n * Fires the provided callback just before the current callstack unwinds, or as\n * soon as possible after the current JS execution context.\n * @param {function(this:THIS)} callback\n * @param {THIS=} opt_context Object to use as the \"this value\" when calling\n * the provided function.\n * @template THIS\n */\nasync.run = function(callback, opt_context) {\n\tif (!async.run.workQueueScheduled_) {\n\t\t// Nothing is currently scheduled, schedule it now.\n\t\tasync.nextTick(async.run.processWorkQueue);\n\t\tasync.run.workQueueScheduled_ = true;\n\t}\n\n\tasync.run.workQueue_.push(\n\t\tnew async.run.WorkItem_(callback, opt_context));\n};\n\n\n/** @private {boolean} */\nasync.run.workQueueScheduled_ = false;\n\n\n/** @private {!Array.<!async.run.WorkItem_>} */\nasync.run.workQueue_ = [];\n\n/**\n * Run any pending async.run work items. This function is not intended\n * for general use, but for use by entry point handlers to run items ahead of\n * async.nextTick.\n */\nasync.run.processWorkQueue = function() {\n\t// NOTE: additional work queue items may be pushed while processing.\n\twhile (async.run.workQueue_.length) {\n\t\t// Don't let the work queue grow indefinitely.\n\t\tvar workItems = async.run.workQueue_;\n\t\tasync.run.workQueue_ = [];\n\t\tfor (var i = 0; i < workItems.length; i++) {\n\t\t\tvar workItem = workItems[i];\n\t\t\ttry {\n\t\t\t\tworkItem.fn.call(workItem.scope);\n\t\t\t} catch (e) {\n\t\t\t\tasync.throwException(e);\n\t\t\t}\n\t\t}\n\t}\n\n\t// There are no more work items, reset the work queue.\n\tasync.run.workQueueScheduled_ = false;\n};\n\n\n/**\n * @constructor\n * @final\n * @struct\n * @private\n *\n * @param {function()} fn\n * @param {Object|null|undefined} scope\n */\nasync.run.WorkItem_ = function(fn, scope) {\n\t/** @const */\n\tthis.fn = fn;\n\t/** @const */\n\tthis.scope = scope;\n};\n\n\n/**\n * Fires the provided callbacks as soon as possible after the current JS\n * execution context. setTimeout(…, 0) always takes at least 5ms for legacy\n * reasons.\n * @param {function(this:SCOPE)} callback Callback function to fire as soon as\n * possible.\n * @param {SCOPE=} opt_context Object in whose scope to call the listener.\n * @template SCOPE\n */\nasync.nextTick = function(callback, opt_context) {\n\tvar cb = callback;\n\tif (opt_context) {\n\t\tcb = callback.bind(opt_context);\n\t}\n\tcb = async.nextTick.wrapCallback_(cb);\n\t// Introduced and currently only supported by IE10.\n\t// Verify if variable is defined on the current runtime (i.e., node, browser).\n\t// Can't use typeof enclosed in a function (such as core.isFunction) or an\n\t// exception will be thrown when the function is called on an environment\n\t// where the variable is undefined.\n\tif (typeof setImmediate === 'function') {\n\t\tsetImmediate(cb);\n\t\treturn;\n\t}\n\t// Look for and cache the custom fallback version of setImmediate.\n\tif (!async.nextTick.setImmediate_) {\n\t\tasync.nextTick.setImmediate_ = async.nextTick.getSetImmediateEmulator_();\n\t}\n\tasync.nextTick.setImmediate_(cb);\n};\n\n\n/**\n * Cache for the setImmediate implementation.\n * @type {function(function())}\n * @private\n */\nasync.nextTick.setImmediate_ = null;\n\n\n/**\n * Determines the best possible implementation to run a function as soon as\n * the JS event loop is idle.\n * @return {function(function())} The \"setImmediate\" implementation.\n * @private\n */\nasync.nextTick.getSetImmediateEmulator_ = function() {\n\t// Create a private message channel and use it to postMessage empty messages\n\t// to ourselves.\n\tvar Channel;\n\n\t// Verify if variable is defined on the current runtime (i.e., node, browser).\n\t// Can't use typeof enclosed in a function (such as core.isFunction) or an\n\t// exception will be thrown when the function is called on an environment\n\t// where the variable is undefined.\n\tif (typeof MessageChannel === 'function') {\n\t\tChannel = MessageChannel;\n\t}\n\n\t// If MessageChannel is not available and we are in a browser, implement\n\t// an iframe based polyfill in browsers that have postMessage and\n\t// document.addEventListener. The latter excludes IE8 because it has a\n\t// synchronous postMessage implementation.\n\tif (typeof Channel === 'undefined' && typeof window !== 'undefined' &&\n\t\twindow.postMessage && window.addEventListener) {\n\t\t/** @constructor */\n\t\tChannel = function() {\n\t\t\t// Make an empty, invisible iframe.\n\t\t\tvar iframe = document.createElement('iframe');\n\t\t\tiframe.style.display = 'none';\n\t\t\tiframe.src = '';\n\t\t\tdocument.documentElement.appendChild(iframe);\n\t\t\tvar win = iframe.contentWindow;\n\t\t\tvar doc = win.document;\n\t\t\tdoc.open();\n\t\t\tdoc.write('');\n\t\t\tdoc.close();\n\t\t\tvar message = 'callImmediate' + Math.random();\n\t\t\tvar origin = win.location.protocol + '//' + win.location.host;\n\t\t\tvar onmessage = function(e) {\n\t\t\t\t// Validate origin and message to make sure that this message was\n\t\t\t\t// intended for us.\n\t\t\t\tif (e.origin !== origin && e.data !== message) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.port1.onmessage();\n\t\t\t}.bind(this);\n\t\t\twin.addEventListener('message', onmessage, false);\n\t\t\tthis.port1 = {};\n\t\t\tthis.port2 = {\n\t\t\t\tpostMessage: function() {\n\t\t\t\t\twin.postMessage(message, origin);\n\t\t\t\t}\n\t\t\t};\n\t\t};\n\t}\n\tif (typeof Channel !== 'undefined') {\n\t\tvar channel = new Channel();\n\t\t// Use a fifo linked list to call callbacks in the right order.\n\t\tvar head = {};\n\t\tvar tail = head;\n\t\tchannel.port1.onmessage = function() {\n\t\t\thead = head.next;\n\t\t\tvar cb = head.cb;\n\t\t\thead.cb = null;\n\t\t\tcb();\n\t\t};\n\t\treturn function(cb) {\n\t\t\ttail.next = {\n\t\t\t\tcb: cb\n\t\t\t};\n\t\t\ttail = tail.next;\n\t\t\tchannel.port2.postMessage(0);\n\t\t};\n\t}\n\t// Implementation for IE6-8: Script elements fire an asynchronous\n\t// onreadystatechange event when inserted into the DOM.\n\tif (typeof document !== 'undefined' && 'onreadystatechange' in\n\t\tdocument.createElement('script')) {\n\t\treturn function(cb) {\n\t\t\tvar script = document.createElement('script');\n\t\t\tscript.onreadystatechange = function() {\n\t\t\t\t// Clean up and call the callback.\n\t\t\t\tscript.onreadystatechange = null;\n\t\t\t\tscript.parentNode.removeChild(script);\n\t\t\t\tscript = null;\n\t\t\t\tcb();\n\t\t\t\tcb = null;\n\t\t\t};\n\t\t\tdocument.documentElement.appendChild(script);\n\t\t};\n\t}\n\t// Fall back to setTimeout with 0. In browsers this creates a delay of 5ms\n\t// or more.\n\treturn function(cb) {\n\t\tsetTimeout(cb, 0);\n\t};\n};\n\n\n/**\n * Helper function that is overrided to protect callbacks with entry point\n * monitor if the application monitors entry points.\n * @param {function()} callback Callback function to fire as soon as possible.\n * @return {function()} The wrapped callback.\n * @private\n */\nasync.nextTick.wrapCallback_ = function(opt_returnValue) {\n\treturn opt_returnValue;\n};\n\nexport default async;\n","'use strict';\n\n/**\n * Disposable utility. When inherited provides the `dispose` function to its\n * subclass, which is responsible for disposing of any object references\n * when an instance won't be used anymore. Subclasses should override\n * `disposeInternal` to implement any specific disposing logic.\n * @constructor\n */\nclass Disposable {\n\tconstructor() {\n\t\t/**\n\t\t * Flag indicating if this instance has already been disposed.\n\t\t * @type {boolean}\n\t\t * @protected\n\t\t */\n\t\tthis.disposed_ = false;\n\t}\n\n\t/**\n\t * Disposes of this instance's object references. Calls `disposeInternal`.\n\t */\n\tdispose() {\n\t\tif (!this.disposed_) {\n\t\t\tthis.disposeInternal();\n\t\t\tthis.disposed_ = true;\n\t\t}\n\t}\n\n\t/**\n\t * Subclasses should override this method to implement any specific\n\t * disposing logic (like clearing references and calling `dispose` on other\n\t * disposables).\n\t */\n\tdisposeInternal() {}\n\n\t/**\n\t * Checks if this instance has already been disposed.\n\t * @return {boolean}\n\t */\n\tisDisposed() {\n\t\treturn this.disposed_;\n\t}\n}\n\nexport default Disposable;\n","'use strict';\n\nclass object {\n\t/**\n\t * Copies all the members of a source object to a target object.\n\t * @param {Object} target Target object.\n\t * @param {...Object} var_args The objects from which values will be copied.\n\t * @return {Object} Returns the target object reference.\n\t */\n\tstatic mixin(target) {\n\t\tvar key, source;\n\t\tfor (var i = 1; i < arguments.length; i++) {\n\t\t\tsource = arguments[i];\n\t\t\tfor (key in source) {\n\t\t\t\ttarget[key] = source[key];\n\t\t\t}\n\t\t}\n\t\treturn target;\n\t}\n\n\t/**\n\t * Returns an object based on its fully qualified external name.\n\t * @param {string} name The fully qualified name.\n\t * @param {object=} opt_obj The object within which to look; default is\n\t * <code>window</code>.\n\t * @return {?} The value (object or primitive) or, if not found, undefined.\n\t */\n\tstatic getObjectByName(name, opt_obj) {\n\t\tvar scope = opt_obj || window;\n\t\tvar parts = name.split('.');\n\t\treturn parts.reduce((part, key) => part[key], scope);\n\t}\n\n\t/**\n\t * Returns a new object with the same keys as the given one, but with\n\t * their values set to the return values of the specified function.\n\t * @param {!Object} obj\n\t * @param {!function(string, *)} fn\n\t * @return {!Object}\n\t */\n\tstatic map(obj, fn) {\n\t\tvar mappedObj = {};\n\t\tvar keys = Object.keys(obj);\n\t\tfor (var i = 0; i < keys.length; i++) {\n\t\t\tmappedObj[keys[i]] = fn(keys[i], obj[keys[i]]);\n\t\t}\n\t\treturn mappedObj;\n\t}\n\n\t/**\n\t * Checks if the two given objects are equal. This is done via a shallow\n\t * check, including only the keys directly contained by the 2 objects.\n\t * @return {boolean}\n\t */\n\tstatic shallowEqual(obj1, obj2) {\n\t\tif (obj1 === obj2) {\n\t\t\treturn true;\n\t\t}\n\n\t\tvar keys1 = Object.keys(obj1);\n\t\tvar keys2 = Object.keys(obj2);\n\t\tif (keys1.length !== keys2.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (var i = 0; i < keys1.length; i++) {\n\t\t\tif (obj1[keys1[i]] !== obj2[keys1[i]]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n\nexport default object;\n","'use strict';\n\nclass string {\n\t/**\n\t * Removes the breaking spaces from the left and right of the string and\n\t * collapses the sequences of breaking spaces in the middle into single spaces.\n\t * The original and the result strings render the same way in HTML.\n\t * @param {string} str A string in which to collapse spaces.\n\t * @return {string} Copy of the string with normalized breaking spaces.\n\t */\n\tstatic collapseBreakingSpaces(str) {\n\t\treturn str.replace(/[\\t\\r\\n ]+/g, ' ').replace(/^[\\t\\r\\n ]+|[\\t\\r\\n ]+$/g, '');\n\t}\n\n\t/**\n\t* Escapes characters in the string that are not safe to use in a RegExp.\n\t* @param {*} str The string to escape. If not a string, it will be casted\n\t* to one.\n\t* @return {string} A RegExp safe, escaped copy of {@code s}.\n\t*/\n\tstatic escapeRegex(str) {\n\t\treturn String(str)\n\t\t\t.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')\n\t\t\t.replace(/\\x08/g, '\\\\x08');\n\t}\n\n\t/**\n\t* Returns a string with at least 64-bits of randomness.\n\t* @return {string} A random string, e.g. sn1s7vb4gcic.\n\t*/\n\tstatic getRandomString() {\n\t\tvar x = 2147483648;\n\t\treturn Math.floor(Math.random() * x).toString(36) +\n\t\t\tMath.abs(Math.floor(Math.random() * x) ^ Date.now()).toString(36);\n\t}\n\n\t/**\n\t * Calculates the hashcode for a string. The hashcode value is computed by\n\t * the sum algorithm: s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]. A nice\n\t * property of using 31 prime is that the multiplication can be replaced by\n\t * a shift and a subtraction for better performance: 31*i == (i<<5)-i.\n\t * Modern VMs do this sort of optimization automatically.\n\t * @param {String} val Target string.\n\t * @return {Number} Returns the string hashcode.\n\t */\n\tstatic hashCode(val) {\n\t\tvar hash = 0;\n\t\tfor (var i = 0, len = val.length; i < len; i++) {\n\t\t\thash = 31 * hash + val.charCodeAt(i);\n\t\t\thash %= 0x100000000;\n\t\t}\n\t\treturn hash;\n\t}\n\n\t/**\n\t * Replaces interval into the string with specified value, e.g.\n\t * `replaceInterval(\"abcde\", 1, 4, \"\")` returns \"ae\".\n\t * @param {string} str The input string.\n\t * @param {Number} start Start interval position to be replaced.\n\t * @param {Number} end End interval position to be replaced.\n\t * @param {string} value The value that replaces the specified interval.\n\t * @return {string}\n\t */\n\tstatic replaceInterval(str, start, end, value) {\n\t\treturn str.substring(0, start) + value + str.substring(end);\n\t}\n}\n\nexport default string;\n","'use strict';\n\nimport core from './core';\nimport array from './array/array';\nimport async from './async/async';\nimport Disposable from './disposable/Disposable';\nimport object from './object/object';\nimport string from './string/string';\n\nexport default core;\nexport { core, array, async, Disposable, object, string };\n","'use strict';\n\n/**\n * Debounces function execution.\n * @param {!function()} fn\n * @param {number} delay\n * @return {!function()}\n */\nfunction debounce(fn, delay) {\n\treturn function debounced() {\n\t\tvar args = arguments;\n\t\tcancelDebounce(debounced);\n\t\tdebounced.id = setTimeout(function() {\n\t\t\tfn.apply(null, args);\n\t\t}, delay);\n\t};\n}\n\n/**\n * Cancels the scheduled debounced function.\n */\nfunction cancelDebounce(debounced) {\n\tclearTimeout(debounced.id);\n}\n\nexport default debounce;\nexport { cancelDebounce, debounce };\n","'use strict';\n\nconst METAL_DATA = '__metal_data__';\n\nclass domData {\n\t/**\n\t * Gets Metal.js's data for the given element.\n\t * @param {!Element} element\n\t * @return {!Object}\n\t */\n\tstatic get(element) {\n\t\tif (!element[METAL_DATA]) {\n\t\t\telement[METAL_DATA] = {\n\t\t\t\tdelegating: {},\n\t\t\t\tlisteners: {}\n\t\t\t};\n\t\t}\n\t\treturn element[METAL_DATA];\n\t}\n}\n\nexport default domData;\n","'use strict';\n\nimport { Disposable } from 'metal';\n\n/**\n * EventHandle utility. Holds information about an event subscription, and\n * allows removing them easily.\n * EventHandle is a Disposable, but it's important to note that the\n * EventEmitter that created it is not the one responsible for disposing it.\n * That responsibility is for the code that holds a reference to it.\n * @param {!EventEmitter} emitter Emitter the event was subscribed to.\n * @param {string} event The name of the event that was subscribed to.\n * @param {!Function} listener The listener subscribed to the event.\n * @constructor\n * @extends {Disposable}\n */\nclass EventHandle extends Disposable {\n\tconstructor(emitter, event, listener) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The EventEmitter instance that the event was subscribed to.\n\t\t * @type {EventEmitter}\n\t\t * @protected\n\t\t */\n\t\tthis.emitter_ = emitter;\n\n\t\t/**\n\t\t * The name of the event that was subscribed to.\n\t\t * @type {string}\n\t\t * @protected\n\t\t */\n\t\tthis.event_ = event;\n\n\t\t/**\n\t\t * The listener subscribed to the event.\n\t\t * @type {Function}\n\t\t * @protected\n\t\t */\n\t\tthis.listener_ = listener;\n\t}\n\n\t/**\n\t * Disposes of this instance's object references.\n\t * @override\n\t */\n\tdisposeInternal() {\n\t\tthis.removeListener();\n\t\tthis.emitter_ = null;\n\t\tthis.listener_ = null;\n\t}\n\n\t/**\n\t * Removes the listener subscription from the emitter.\n\t */\n\tremoveListener() {\n\t\tif (!this.emitter_.isDisposed()) {\n\t\t\tthis.emitter_.removeListener(this.event_, this.listener_);\n\t\t}\n\t}\n}\n\nexport default EventHandle;\n","'use strict';\n\nimport { core, array, Disposable } from 'metal';\nimport EventHandle from './EventHandle';\n\n/**\n * EventEmitter utility.\n * @constructor\n * @extends {Disposable}\n */\nclass EventEmitter extends Disposable {\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds event listeners scoped by event type.\n\t\t * @type {!Object<string, !Array<!function()>>}\n\t\t * @protected\n\t\t */\n\t\tthis.events_ = [];\n\n\t\t/**\n\t\t * The maximum number of listeners allowed for each event type. If the number\n\t\t * becomes higher than the max, a warning will be issued.\n\t\t * @type {number}\n\t\t * @protected\n\t\t */\n\t\tthis.maxListeners_ = 10;\n\n\t\t/**\n\t\t * Configuration option which determines if an event facade should be sent\n\t\t * as a param of listeners when emitting events. If set to true, the facade\n\t\t * will be passed as the first argument of the listener.\n\t\t * @type {boolean}\n\t\t * @protected\n\t\t */\n\t\tthis.shouldUseFacade_ = false;\n\t}\n\n\t/**\n\t * Adds a listener to the end of the listeners array for the specified events.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @param {boolean} opt_default Flag indicating if this listener is a default\n\t * action for this event. Default actions are run last, and only if no previous\n\t * listener call `preventDefault()` on the received event facade.\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t */\n\taddListener(events, listener, opt_default) {\n\t\tthis.validateListener_(listener);\n\n\t\tevents = this.normalizeEvents_(events);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tthis.addSingleListener_(events[i], listener, opt_default);\n\t\t}\n\n\t\treturn new EventHandle(this, events, listener);\n\t}\n\n\t/**\n\t * Adds a listener to the end of the listeners array for a single event.\n\t * @param {string} event\n\t * @param {!Function} listener\n\t * @param {boolean} opt_default Flag indicating if this listener is a default\n\t * action for this event. Default actions are run last, and only if no previous\n\t * listener call `preventDefault()` on the received event facade.\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t * @param {Function=} opt_origin The original function that was added as a\n\t * listener, if there is any.\n\t * @protected\n\t */\n\taddSingleListener_(event, listener, opt_default, opt_origin) {\n\t\tthis.emit('newListener', event, listener);\n\n\t\tif (!this.events_[event]) {\n\t\t\tthis.events_[event] = [];\n\t\t}\n\t\tthis.events_[event].push({\n\t\t\tdefault: opt_default,\n\t\t\tfn: listener,\n\t\t\torigin: opt_origin\n\t\t});\n\n\t\tvar listeners = this.events_[event];\n\t\tif (listeners.length > this.maxListeners_ && !listeners.warned) {\n\t\t\tconsole.warn(\n\t\t\t\t'Possible EventEmitter memory leak detected. %d listeners added ' +\n\t\t\t\t'for event %s. Use emitter.setMaxListeners() to increase limit.',\n\t\t\t\tlisteners.length,\n\t\t\t\tevent\n\t\t\t);\n\t\t\tlisteners.warned = true;\n\t\t}\n\t}\n\n\t/**\n\t * Disposes of this instance's object references.\n\t * @override\n\t */\n\tdisposeInternal() {\n\t\tthis.events_ = [];\n\t}\n\n\t/**\n\t * Execute each of the listeners in order with the supplied arguments.\n\t * @param {string} event\n\t * @param {*} opt_args [arg1], [arg2], [...]\n\t * @return {boolean} Returns true if event had listeners, false otherwise.\n\t */\n\temit(event) {\n\t\tvar args = array.slice(arguments, 1);\n\t\tvar listeners = (this.events_[event] || []).concat();\n\n\t\tvar facade;\n\t\tif (this.getShouldUseFacade()) {\n\t\t\tfacade = {\n\t\t\t\tpreventDefault: function() {\n\t\t\t\t\tfacade.preventedDefault = true;\n\t\t\t\t},\n\t\t\t\ttarget: this,\n\t\t\t\ttype: event\n\t\t\t};\n\t\t\targs.push(facade);\n\t\t}\n\n\t\tvar defaultListeners = [];\n\t\tfor (var i = 0; i < listeners.length; i++) {\n\t\t\tif (listeners[i].default) {\n\t\t\t\tdefaultListeners.push(listeners[i]);\n\t\t\t} else {\n\t\t\t\tlisteners[i].fn.apply(this, args);\n\t\t\t}\n\t\t}\n\t\tif (!facade || !facade.preventedDefault) {\n\t\t\tfor (var j = 0; j < defaultListeners.length; j++) {\n\t\t\t\tdefaultListeners[j].fn.apply(this, args);\n\t\t\t}\n\t\t}\n\n\n\t\tif (event !== '*') {\n\t\t\tthis.emit.apply(this, ['*', event].concat(args));\n\t\t}\n\n\t\treturn listeners.length > 0;\n\t}\n\n\t/**\n\t * Gets the configuration option which determines if an event facade should\n\t * be sent as a param of listeners when emitting events. If set to true, the\n\t * facade will be passed as the first argument of the listener.\n\t * @return {boolean}\n\t */\n\tgetShouldUseFacade() {\n\t\treturn this.shouldUseFacade_;\n\t}\n\n\t/**\n\t * Returns an array of listeners for the specified event.\n\t * @param {string} event\n\t * @return {Array} Array of listeners.\n\t */\n\tlisteners(event) {\n\t\treturn (this.events_[event] || []).map(listener => listener.fn);\n\t}\n\n\t/**\n\t * Adds a listener that will be invoked a fixed number of times for the\n\t * events. After each event is triggered the specified amount of times, the\n\t * listener is removed for it.\n\t * @param {!(Array|string)} events\n\t * @param {number} amount The amount of times this event should be listened\n\t * to.\n\t * @param {!Function} listener\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t */\n\tmany(events, amount, listener) {\n\t\tevents = this.normalizeEvents_(events);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tthis.many_(events[i], amount, listener);\n\t\t}\n\n\t\treturn new EventHandle(this, events, listener);\n\t}\n\n\t/**\n\t * Adds a listener that will be invoked a fixed number of times for a single\n\t * event. After the event is triggered the specified amount of times, the\n\t * listener is removed.\n\t * @param {string} event\n\t * @param {number} amount The amount of times this event should be listened\n\t * to.\n\t * @param {!Function} listener\n\t * @protected\n\t */\n\tmany_(event, amount, listener) {\n\t\tvar self = this;\n\n\t\tif (amount <= 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction handlerInternal() {\n\t\t\tif (--amount === 0) {\n\t\t\t\tself.removeListener(event, handlerInternal);\n\t\t\t}\n\t\t\tlistener.apply(self, arguments);\n\t\t}\n\n\t\tself.addSingleListener_(event, handlerInternal, false, listener);\n\t}\n\n\t/**\n\t * Checks if a listener object matches the given listener function. To match,\n\t * it needs to either point to that listener or have it as its origin.\n\t * @param {!Object} listenerObj\n\t * @param {!Function} listener\n\t * @return {boolean}\n\t * @protected\n\t */\n\tmatchesListener_(listenerObj, listener) {\n\t\treturn listenerObj.fn === listener ||\n\t\t\t(listenerObj.origin && listenerObj.origin === listener);\n\t}\n\n\t/**\n\t * Converts the parameter to an array if only one event is given.\n\t * @param {!(Array|string)} events\n\t * @return {!Array}\n\t * @protected\n\t */\n\tnormalizeEvents_(events) {\n\t\treturn core.isString(events) ? [events] : events;\n\t}\n\n\t/**\n\t * Removes a listener for the specified events.\n\t * Caution: changes array indices in the listener array behind the listener.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\toff(events, listener) {\n\t\tthis.validateListener_(listener);\n\n\t\tevents = this.normalizeEvents_(events);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tvar listenerObjs = this.events_[events[i]] || [];\n\t\t\tthis.removeMatchingListenerObjs_(listenerObjs, listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener to the end of the listeners array for the specified events.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t */\n\ton() {\n\t\treturn this.addListener.apply(this, arguments);\n\t}\n\n\t/**\n\t * Adds a one time listener for the events. This listener is invoked only the\n\t * next time each event is fired, after which it is removed.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @return {!EventHandle} Can be used to remove the listener.\n\t */\n\tonce(events, listener) {\n\t\treturn this.many(events, 1, listener);\n\t}\n\n\t/**\n\t * Removes all listeners, or those of the specified events. It's not a good\n\t * idea to remove listeners that were added elsewhere in the code,\n\t * especially when it's on an emitter that you didn't create.\n\t * @param {(Array|string)=} opt_events\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\tremoveAllListeners(opt_events) {\n\t\tif (opt_events) {\n\t\t\tvar events = this.normalizeEvents_(opt_events);\n\t\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\t\tthis.events_[events[i]] = null;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.events_ = {};\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes all listener objects from the given array that match the given\n\t * listener function.\n\t * @param {!Array.<Object>} listenerObjs\n\t * @param {!Function} listener\n\t * @protected\n\t */\n\tremoveMatchingListenerObjs_(listenerObjs, listener) {\n\t\tfor (var i = listenerObjs.length - 1; i >= 0; i--) {\n\t\t\tif (this.matchesListener_(listenerObjs[i], listener)) {\n\t\t\t\tlistenerObjs.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes a listener for the specified events.\n\t * Caution: changes array indices in the listener array behind the listener.\n\t * @param {!(Array|string)} events\n\t * @param {!Function} listener\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\tremoveListener() {\n\t\treturn this.off.apply(this, arguments);\n\t}\n\n\t/**\n\t * By default EventEmitters will print a warning if more than 10 listeners\n\t * are added for a particular event. This is a useful default which helps\n\t * finding memory leaks. Obviously not all Emitters should be limited to 10.\n\t * This function allows that to be increased. Set to zero for unlimited.\n\t * @param {number} max The maximum number of listeners.\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\tsetMaxListeners(max) {\n\t\tthis.maxListeners_ = max;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the configuration option which determines if an event facade should\n\t * be sent as a param of listeners when emitting events. If set to true, the\n\t * facade will be passed as the first argument of the listener.\n\t * @param {boolean} shouldUseFacade\n\t * @return {!Object} Returns emitter, so calls can be chained.\n\t */\n\tsetShouldUseFacade(shouldUseFacade) {\n\t\tthis.shouldUseFacade_ = shouldUseFacade;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Checks if the given listener is valid, throwing an exception when it's not.\n\t * @param {*} listener\n\t * @protected\n\t */\n\tvalidateListener_(listener) {\n\t\tif (!core.isFunction(listener)) {\n\t\t\tthrow new TypeError('Listener must be a function');\n\t\t}\n\t}\n}\n\nexport default EventEmitter;\n","'use strict';\n\nimport { array, Disposable } from 'metal';\n\n/**\n * EventEmitterProxy utility. It's responsible for linking two EventEmitter\n * instances together, emitting events from the first emitter through the\n * second one. That means that listening to a supported event on the target\n * emitter will mean listening to it on the origin emitter as well.\n * @param {EventEmitter} originEmitter Events originated on this emitter\n * will be fired for the target emitter's listeners as well.\n * @param {EventEmitter} targetEmitter Event listeners attached to this emitter\n * will also be triggered when the event is fired by the origin emitter.\n * @param {Object} opt_blacklist Optional blacklist of events that should not be\n * proxied.\n * @constructor\n * @extends {Disposable}\n */\nclass EventEmitterProxy extends Disposable {\n\tconstructor(originEmitter, targetEmitter, opt_blacklist, opt_whitelist) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Map of events that should not be proxied.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.blacklist_ = opt_blacklist || {};\n\n\t\t/**\n\t\t * The origin emitter. This emitter's events will be proxied through the\n\t\t * target emitter.\n\t\t * @type {EventEmitter}\n\t\t * @protected\n\t\t */\n\t\tthis.originEmitter_ = originEmitter;\n\n\t\t/**\n\t\t * A list of events that are pending to be listened by an actual origin\n\t\t * emitter. Events are stored here when the origin doesn't exist, so they\n\t\t * can be set on a new origin when one is set.\n\t\t * @type {!Array}\n\t\t * @protected\n\t\t */\n\t\tthis.pendingEvents_ = [];\n\n\t\t/**\n\t\t * Holds a map of events from the origin emitter that are already being proxied.\n\t\t * @type {Object<string, !EventHandle>}\n\t\t * @protected\n\t\t */\n\t\tthis.proxiedEvents_ = {};\n\n\t\t/**\n\t\t * The target emitter. This emitter will emit all events that come from\n\t\t * the origin emitter.\n\t\t * @type {EventEmitter}\n\t\t * @protected\n\t\t */\n\t\tthis.targetEmitter_ = targetEmitter;\n\n\t\t/**\n\t\t * Map of events that should be proxied. If whitelist is set blacklist is ignored.\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis.whitelist_ = opt_whitelist;\n\n\t\tthis.startProxy_();\n\t}\n\n\t/**\n\t * Adds the given listener for the given event.\n\t * @param {string} event\n\t * @param {!function()} listener\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t */\n\taddListener_(event, listener) {\n\t\treturn this.originEmitter_.on(event, listener);\n\t}\n\n\t/**\n\t * Adds the proxy listener for the given event.\n\t * @param {string} event\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t */\n\taddListenerForEvent_(event) {\n\t\treturn this.addListener_(event, this.emitOnTarget_.bind(this, event));\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tthis.removeListeners_();\n\t\tthis.proxiedEvents_ = null;\n\t\tthis.originEmitter_ = null;\n\t\tthis.targetEmitter_ = null;\n\t}\n\n\t/**\n\t * Emits the specified event type on the target emitter.\n\t * @param {string} eventType\n\t * @protected\n\t */\n\temitOnTarget_(eventType) {\n\t\tvar args = [eventType].concat(array.slice(arguments, 1));\n\t\tthis.targetEmitter_.emit.apply(this.targetEmitter_, args);\n\t}\n\n\t/**\n\t * Proxies the given event from the origin to the target emitter.\n\t * @param {string} event\n\t */\n\tproxyEvent(event) {\n\t\tif (this.shouldProxyEvent_(event)) {\n\t\t\tthis.tryToAddListener_(event);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the proxy listener for all events.\n\t * @protected\n\t */\n\tremoveListeners_() {\n\t\tvar events = Object.keys(this.proxiedEvents_);\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tthis.proxiedEvents_[events[i]].removeListener();\n\t\t}\n\t\tthis.proxiedEvents_ = {};\n\t\tthis.pendingEvents_ = [];\n\t}\n\n\t/**\n\t * Changes the origin emitter. This automatically detaches any events that\n\t * were already being proxied from the previous emitter, and starts proxying\n\t * them on the new emitter instead.\n\t * @param {!EventEmitter} originEmitter\n\t */\n\tsetOriginEmitter(originEmitter) {\n\t\tvar events = this.originEmitter_ ?\n\t\t\tObject.keys(this.proxiedEvents_) :\n\t\t\tthis.pendingEvents_;\n\t\tthis.removeListeners_();\n\t\tthis.originEmitter_ = originEmitter;\n\t\tevents.forEach(event => this.proxyEvent(event));\n\t}\n\n\t/**\n\t * Checks if the given event should be proxied.\n\t * @param {string} event\n\t * @return {boolean}\n\t * @protected\n\t */\n\tshouldProxyEvent_(event) {\n\t\tif (this.whitelist_ && !this.whitelist_[event]) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.blacklist_[event]) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !this.proxiedEvents_[event];\n\t}\n\n\t/**\n\t * Starts proxying all events from the origin to the target emitter.\n\t * @protected\n\t */\n\tstartProxy_() {\n\t\tthis.targetEmitter_.on('newListener', this.proxyEvent.bind(this));\n\t}\n\n\t/**\n\t * Adds a listener to the origin emitter, if it exists. Otherwise, stores\n\t * the pending listener so it can be used on a future origin emitter.\n\t * @param {string} event\n\t * @protected\n\t */\n\ttryToAddListener_(event) {\n\t\tif (this.originEmitter_) {\n\t\t\tthis.proxiedEvents_[event] = this.addListenerForEvent_(event);\n\t\t} else {\n\t\t\tthis.pendingEvents_.push(event);\n\t\t}\n\t}\n}\n\nexport default EventEmitterProxy;\n","'use strict';\n\nimport { Disposable } from 'metal';\n\n/**\n * EventHandler utility. It's useful for easily removing a group of\n * listeners from different EventEmitter instances.\n * @constructor\n * @extends {Disposable}\n */\nclass EventHandler extends Disposable {\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * An array that holds the added event handles, so the listeners can be\n\t\t * removed later.\n\t\t * @type {Array.<EventHandle>}\n\t\t * @protected\n\t\t */\n\t\tthis.eventHandles_ = [];\n\t}\n\n\t/**\n\t * Adds event handles to be removed later through the `removeAllListeners`\n\t * method.\n\t * @param {...(!EventHandle)} var_args\n\t */\n\tadd() {\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tthis.eventHandles_.push(arguments[i]);\n\t\t}\n\t}\n\n\t/**\n\t * Disposes of this instance's object references.\n\t * @override\n\t */\n\tdisposeInternal() {\n\t\tthis.eventHandles_ = null;\n\t}\n\n\t/**\n\t * Removes all listeners that have been added through the `add` method.\n\t */\n\tremoveAllListeners() {\n\t\tfor (var i = 0; i < this.eventHandles_.length; i++) {\n\t\t\tthis.eventHandles_[i].removeListener();\n\t\t}\n\n\t\tthis.eventHandles_ = [];\n\t}\n}\n\nexport default EventHandler;\n","'use strict';\n\nimport dom from './dom';\nimport features from './features';\n\nvar mouseEventMap = {\n\tmouseenter: 'mouseover',\n\tmouseleave: 'mouseout',\n\tpointerenter: 'pointerover',\n\tpointerleave: 'pointerout'\n};\nObject.keys(mouseEventMap).forEach(function(eventName) {\n\tdom.registerCustomEvent(eventName, {\n\t\tdelegate: true,\n\t\thandler: function(callback, event) {\n\t\t\tvar related = event.relatedTarget;\n\t\t\tvar target = event.delegateTarget;\n\t\t\tif (!related || (related !== target && !target.contains(related))) {\n\t\t\t\tevent.customType = eventName;\n\t\t\t\treturn callback(event);\n\t\t\t}\n\t\t},\n\t\toriginalEvent: mouseEventMap[eventName]\n\t});\n});\n\nvar animationEventMap = {\n\tanimation: 'animationend',\n\ttransition: 'transitionend'\n};\nObject.keys(animationEventMap).forEach(function(eventType) {\n\tvar eventName = animationEventMap[eventType];\n\tdom.registerCustomEvent(eventName, {\n\t\tevent: true,\n\t\tdelegate: true,\n\t\thandler: function(callback, event) {\n\t\t\tevent.customType = eventName;\n\t\t\treturn callback(event);\n\t\t},\n\t\toriginalEvent: features.checkAnimationEventName()[eventType]\n\t});\n});\n","'use strict';\n\nimport { array, core } from 'metal';\nimport domData from './domData';\nimport { EventHandle } from 'metal-events';\n\n/**\n * This is a special EventHandle, that is responsible for dom delegated events\n * (only the ones that receive a target element, not a selector string).\n * @extends {EventHandle}\n */\nclass DomDelegatedEventHandle extends EventHandle {\n\t/**\n\t * The constructor for `DomDelegatedEventHandle`.\n\t * @param {!Event} emitter Element the event was subscribed to.\n\t * @param {string} event The name of the event that was subscribed to.\n\t * @param {!Function} listener The listener subscribed to the event.\n\t * @param {string=} opt_selector An optional selector used when delegating\n\t * the event.\n\t * @constructor\n\t */\n\tconstructor(emitter, event, listener, opt_selector) {\n\t\tsuper(emitter, event, listener);\n\t\tthis.selector_ = opt_selector;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tremoveListener() {\n\t\tvar data = domData.get(this.emitter_);\n\t\tvar selector = this.selector_;\n\t\tvar arr = core.isString(selector) ? data.delegating[this.event_].selectors : data.listeners;\n\t\tvar key = core.isString(selector) ? selector : this.event_;\n\n\t\tarray.remove(arr[key] || [], this.listener_);\n\t\tif (arr[key] && arr[key].length === 0) {\n\t\t\tdelete arr[key];\n\t\t}\n\t}\n}\n\nexport default DomDelegatedEventHandle;\n","'use strict';\n\nimport { EventHandle } from 'metal-events';\n\n/**\n * This is a special EventHandle, that is responsible for dom events, instead\n * of EventEmitter events.\n * @extends {EventHandle}\n */\nclass DomEventHandle extends EventHandle {\n\t/**\n\t * The constructor for `DomEventHandle`.\n\t * @param {!EventEmitter} emitter Emitter the event was subscribed to.\n\t * @param {string} event The name of the event that was subscribed to.\n\t * @param {!Function} listener The listener subscribed to the event.\n\t * @param {boolean} opt_capture Flag indicating if listener should be triggered\n\t * during capture phase, instead of during the bubbling phase. Defaults to false.\n\t * @constructor\n\t */\n\tconstructor(emitter, event, listener, opt_capture) {\n\t\tsuper(emitter, event, listener);\n\t\tthis.capture_ = opt_capture;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tremoveListener() {\n\t\tthis.emitter_.removeEventListener(this.event_, this.listener_, this.capture_);\n\t}\n}\n\nexport default DomEventHandle;\n","'use strict';\n\nimport dom from '../dom';\nimport domData from '../domData';\nimport DomEventEmitterProxy from '../DomEventEmitterProxy';\nimport DomEventHandle from '../DomEventHandle';\nimport features from '../features';\nimport globalEval from '../globalEval';\nimport globalEvalStyles from '../globalEvalStyles';\nimport '../events';\n\nexport default dom;\nexport { dom, domData, DomEventEmitterProxy, DomEventHandle, features, globalEval, globalEvalStyles };\n","'use strict';\n\nimport dom from './dom';\nimport { EventEmitterProxy } from 'metal-events';\n\n/**\n * DomEventEmitterProxy utility. It extends `EventEmitterProxy` to also accept\n * dom elements as origin emitters.\n * @extends {EventEmitterProxy}\n */\nclass DomEventEmitterProxy extends EventEmitterProxy {\n\t/**\n\t * Adds the given listener for the given event.\n\t * @param {string} event.\n\t * @param {!function()} listener\n\t * @return {!EventHandle} The listened event's handle.\n\t * @protected\n\t * @override\n\t */\n\taddListener_(event, listener) {\n\t\tif (this.originEmitter_.addEventListener) {\n\t\t\tif (this.isDelegateEvent_(event)) {\n\t\t\t\tvar index = event.indexOf(':', 9);\n\t\t\t\tvar eventName = event.substring(9, index);\n\t\t\t\tvar selector = event.substring(index + 1);\n\t\t\t\treturn dom.delegate(this.originEmitter_, eventName, selector, listener);\n\t\t\t} else {\n\t\t\t\treturn dom.on(this.originEmitter_, event, listener);\n\t\t\t}\n\t\t} else {\n\t\t\treturn super.addListener_(event, listener);\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the given event is of the delegate type.\n\t * @param {string} event\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisDelegateEvent_(event) {\n\t\treturn event.substr(0, 9) === 'delegate:';\n\t}\n\n\t/**\n\t * Checks if the given event is supported by the origin element.\n\t * @param {string} event\n\t * @protected\n\t */\n\tisSupportedDomEvent_(event) {\n\t\tif (!this.originEmitter_ || !this.originEmitter_.addEventListener) {\n\t\t\treturn true;\n\t\t}\n\t\treturn (this.isDelegateEvent_(event) && event.indexOf(':', 9) !== -1) ||\n\t\t\tdom.supportsEvent(this.originEmitter_, event);\n\t}\n\n\t/**\n\t * Checks if the given event should be proxied.\n\t * @param {string} event\n\t * @return {boolean}\n\t * @protected\n\t * @override\n\t */\n\tshouldProxyEvent_(event) {\n\t\treturn super.shouldProxyEvent_(event) && this.isSupportedDomEvent_(event);\n\t}\n}\n\nexport default DomEventEmitterProxy;\n","'use strict';\n\nimport dom from './dom';\nimport { string } from 'metal';\n\n/**\n * Class with static methods responsible for doing browser feature checks.\n */\nclass features {\n\t/**\n\t * Some browsers still supports prefixed animation events. This method can\n\t * be used to retrieve the current browser event name for both, animation\n\t * and transition.\n\t * @return {object}\n\t */\n\tstatic checkAnimationEventName() {\n\t\tif (features.animationEventName_ === undefined) {\n\t\t\tfeatures.animationEventName_ = {\n\t\t\t\tanimation: features.checkAnimationEventName_('animation'),\n\t\t\t\ttransition: features.checkAnimationEventName_('transition')\n\t\t\t};\n\t\t}\n\t\treturn features.animationEventName_;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {string} type Type to test: animation, transition.\n\t * @return {string} Browser event name.\n\t */\n\tstatic checkAnimationEventName_(type) {\n\t\tvar prefixes = ['Webkit', 'MS', 'O', ''];\n\t\tvar typeTitleCase = string.replaceInterval(type, 0, 1, type.substring(0, 1).toUpperCase());\n\t\tvar suffixes = [typeTitleCase + 'End', typeTitleCase + 'End', typeTitleCase + 'End', type + 'end'];\n\t\tfor (var i = 0; i < prefixes.length; i++) {\n\t\t\tif (features.animationElement_.style[prefixes[i] + typeTitleCase] !== undefined) {\n\t\t\t\treturn prefixes[i].toLowerCase() + suffixes[i];\n\t\t\t}\n\t\t}\n\t\treturn type + 'end';\n\t}\n\n\t/**\n\t * Some browsers (like IE9) change the order of element attributes, when html\n\t * is rendered. This method can be used to check if this behavior happens on\n\t * the current browser.\n\t * @return {boolean}\n\t */\n\tstatic checkAttrOrderChange() {\n\t\tif (features.attrOrderChange_ === undefined) {\n\t\t\tvar originalContent = '<div data-component=\"\" data-ref=\"\"></div>';\n\t\t\tvar element = document.createElement('div');\n\t\t\tdom.append(element, originalContent);\n\t\t\tfeatures.attrOrderChange_ = originalContent !== element.innerHTML;\n\t\t}\n\t\treturn features.attrOrderChange_;\n\t}\n}\n\nfeatures.animationElement_ = document.createElement('div');\nfeatures.animationEventName_ = undefined;\nfeatures.attrOrderChange_ = undefined;\n\nexport default features;\n","'use strict';\n\nimport { async } from 'metal';\nimport dom from './dom';\n\n/**\n * Utility functions for running javascript code in the global scope.\n */\nclass globalEval {\n\t/**\n\t * Evaluates the given string in the global scope.\n\t * @param {string} text\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} script\n\t */\n\tstatic run(text, opt_appendFn) {\n\t\tvar script = document.createElement('script');\n\t\tscript.text = text;\n\t\tif (opt_appendFn) {\n\t\t\topt_appendFn(script);\n\t\t} else {\n\t\t\tdocument.head.appendChild(script);\n\t\t}\n\t\tdom.exitDocument(script);\n\t\treturn script;\n\t}\n\n\t/**\n\t * Evaluates the given javascript file in the global scope.\n\t * @param {string} src The file's path.\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} script\n\t */\n\tstatic runFile(src, opt_callback, opt_appendFn) {\n\t\tvar script = document.createElement('script');\n\t\tscript.src = src;\n\n\t\tvar callback = function() {\n\t\t\tdom.exitDocument(script);\n\t\t\topt_callback && opt_callback();\n\t\t};\n\t\tdom.once(script, 'load', callback);\n\t\tdom.once(script, 'error', callback);\n\n\t\tif (opt_appendFn) {\n\t\t\topt_appendFn(script);\n\t\t} else {\n\t\t\tdocument.head.appendChild(script);\n\t\t}\n\n\t\treturn script;\n\t}\n\n\t/**\n\t * Evaluates the code referenced by the given script element.\n\t * @param {!Element} script\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} script\n\t */\n\tstatic runScript(script, opt_callback, opt_appendFn) {\n\t\tvar callback = function() {\n\t\t\topt_callback && opt_callback();\n\t\t};\n\t\tif (script.type && script.type !== 'text/javascript') {\n\t\t\tasync.nextTick(callback);\n\t\t\treturn;\n\t\t}\n\t\tdom.exitDocument(script);\n\t\tif (script.src) {\n\t\t\treturn globalEval.runFile(script.src, opt_callback, opt_appendFn);\n\t\t} else {\n\t\t\tasync.nextTick(callback);\n\t\t\treturn globalEval.run(script.text, opt_appendFn);\n\t\t}\n\t}\n\n\t/**\n\t * Evaluates any script tags present in the given element.\n\t * @params {!Element} element\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t */\n\tstatic runScriptsInElement(element, opt_callback, opt_appendFn) {\n\t\tvar scripts = element.querySelectorAll('script');\n\t\tif (scripts.length) {\n\t\t\tglobalEval.runScriptsInOrder(scripts, 0, opt_callback, opt_appendFn);\n\t\t} else if (opt_callback) {\n\t\t\tasync.nextTick(opt_callback);\n\t\t}\n\t}\n\n\t/**\n\t * Runs the given scripts elements in the order that they appear.\n\t * @param {!NodeList} scripts\n\t * @param {number} index\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t */\n\tstatic runScriptsInOrder(scripts, index, opt_callback, opt_appendFn) {\n\t\tglobalEval.runScript(scripts.item(index), function() {\n\t\t\tif (index < scripts.length - 1) {\n\t\t\t\tglobalEval.runScriptsInOrder(scripts, index + 1, opt_callback, opt_appendFn);\n\t\t\t} else if (opt_callback) {\n\t\t\t\tasync.nextTick(opt_callback);\n\t\t\t}\n\t\t}, opt_appendFn);\n\t}\n}\n\nexport default globalEval;\n","'use strict';\n\nimport { async } from 'metal';\nimport dom from './dom';\n\n/**\n * Utility functions for running styles.\n */\nclass globalEvalStyles {\n\t/**\n\t * Evaluates the given style.\n\t * @param {string} text\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} style\n\t */\n\tstatic run(text, opt_appendFn) {\n\t\tvar style = document.createElement('style');\n\t\tstyle.innerHTML = text;\n\t\tif (opt_appendFn) {\n\t\t\topt_appendFn(style);\n\t\t} else {\n\t\t\tdocument.head.appendChild(style);\n\t\t}\n\t\treturn style;\n\t}\n\n\t/**\n\t * Evaluates the given style file.\n\t * @param {string} href The file's path.\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the styles has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} style\n\t */\n\tstatic runFile(href, opt_callback, opt_appendFn) {\n\t\tvar link = document.createElement('link');\n\t\tlink.rel = 'stylesheet';\n\t\tlink.href = href;\n\t\tglobalEvalStyles.runStyle(link, opt_callback, opt_appendFn);\n\t\treturn link;\n\t}\n\n\t/**\n\t * Evaluates the code referenced by the given style/link element.\n\t * @param {!Element} style\n\t * @param {function()=} opt_callback Optional function to be called\n\t * when the script has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t * @return {Element} style\n\t */\n\tstatic runStyle(style, opt_callback, opt_appendFn) {\n\t\tvar callback = function() {\n\t\t\topt_callback && opt_callback();\n\t\t};\n\t\tif (style.rel && style.rel !== 'stylesheet') {\n\t\t\tasync.nextTick(callback);\n\t\t\treturn;\n\t\t}\n\n\t\tif (style.tagName === 'STYLE') {\n\t\t\tasync.nextTick(callback);\n\t\t} else {\n\t\t\tdom.once(style, 'load', callback);\n\t\t\tdom.once(style, 'error', callback);\n\t\t}\n\n\t\tif (opt_appendFn) {\n\t\t\topt_appendFn(style);\n\t\t} else {\n\t\t\tdocument.head.appendChild(style);\n\t\t}\n\n\t\treturn style;\n\t}\n\n\t/**\n\t * Evaluates any style present in the given element.\n\t * @params {!Element} element\n\t * @param {function()=} opt_callback Optional function to be called when the\n\t * style has been run.\n\t * @param {function()=} opt_appendFn Optional function to append the node\n\t * into document.\n\t */\n\tstatic runStylesInElement(element, opt_callback, opt_appendFn) {\n\t\tvar styles = element.querySelectorAll('style,link');\n\t\tif (styles.length === 0 && opt_callback) {\n\t\t\tasync.nextTick(opt_callback);\n\t\t\treturn;\n\t\t}\n\n\t\tvar loadCount = 0;\n\t\tvar callback = function() {\n\t\t\tif (opt_callback && ++loadCount === styles.length) {\n\t\t\t\tasync.nextTick(opt_callback);\n\t\t\t}\n\t\t};\n\t\tfor (var i = 0; i < styles.length; i++) {\n\t\t\tglobalEvalStyles.runStyle(styles[i], callback, opt_appendFn);\n\t\t}\n\t}\n}\n\nexport default globalEvalStyles;\n","/*!\n * Promises polyfill from Google's Closure Library.\n *\n * Copyright 2013 The Closure Library Authors. All Rights Reserved.\n *\n * NOTE(eduardo): Promise support is not ready on all supported browsers,\n * therefore core.js is temporarily using Google's promises as polyfill. It\n * supports cancellable promises and has clean and fast implementation.\n */\n\n'use strict';\n\nimport { core } from 'metal';\nimport { async } from 'metal';\n\n/**\n * Provides a more strict interface for Thenables in terms of\n * http://promisesaplus.com for interop with {@see CancellablePromise}.\n *\n * @interface\n * @extends {IThenable.<TYPE>}\n * @template TYPE\n */\nvar Thenable = function() {};\n\n/**\n * Adds callbacks that will operate on the result of the Thenable, returning a\n * new child Promise.\n *\n * If the Thenable is fulfilled, the {@code onFulfilled} callback will be\n * invoked with the fulfillment value as argument, and the child Promise will\n * be fulfilled with the return value of the callback. If the callback throws\n * an exception, the child Promise will be rejected with the thrown value\n * instead.\n *\n * If the Thenable is rejected, the {@code onRejected} callback will be invoked\n * with the rejection reason as argument, and the child Promise will be rejected\n * with the return value of the callback or thrown value.\n *\n * @param {?(function(this:THIS, TYPE):\n * (RESULT|IThenable.<RESULT>|Thenable))=} opt_onFulfilled A\n * function that will be invoked with the fulfillment value if the Promise\n * is fullfilled.\n * @param {?(function(*): *)=} opt_onRejected A function that will be invoked\n * with the rejection reason if the Promise is rejected.\n * @param {THIS=} opt_context An optional context object that will be the\n * execution context for the callbacks. By default, functions are executed\n * with the default this.\n * @return {!CancellablePromise.<RESULT>} A new Promise that will receive the\n * result of the fulfillment or rejection callback.\n * @template RESULT,THIS\n */\nThenable.prototype.then = function() {};\n\n\n/**\n * An expando property to indicate that an object implements\n * {@code Thenable}.\n *\n * {@see addImplementation}.\n *\n * @const\n */\nThenable.IMPLEMENTED_BY_PROP = '$goog_Thenable';\n\n\n/**\n * Marks a given class (constructor) as an implementation of Thenable, so\n * that we can query that fact at runtime. The class must have already\n * implemented the interface.\n * Exports a 'then' method on the constructor prototype, so that the objects\n * also implement the extern {@see Thenable} interface for interop with\n * other Promise implementations.\n * @param {function(new:Thenable,...[?])} ctor The class constructor. The\n * corresponding class must have already implemented the interface.\n */\nThenable.addImplementation = function(ctor) {\n ctor.prototype.then = ctor.prototype.then;\n ctor.prototype.$goog_Thenable = true;\n};\n\n\n/**\n * @param {*} object\n * @return {boolean} Whether a given instance implements {@code Thenable}.\n * The class/superclass of the instance must call {@code addImplementation}.\n */\nThenable.isImplementedBy = function(object) {\n if (!object) {\n return false;\n }\n try {\n return !!object.$goog_Thenable;\n } catch (e) {\n // Property access seems to be forbidden.\n return false;\n }\n};\n\n\n/**\n * Like bind(), except that a 'this object' is not required. Useful when the\n * target function is already bound.\n *\n * Usage:\n * var g = partial(f, arg1, arg2);\n * g(arg3, arg4);\n *\n * @param {Function} fn A function to partially apply.\n * @param {...*} var_args Additional arguments that are partially applied to fn.\n * @return {!Function} A partially-applied form of the function bind() was\n * invoked as a method of.\n */\nvar partial = function(fn) {\n var args = Array.prototype.slice.call(arguments, 1);\n return function() {\n // Clone the array (with slice()) and append additional arguments\n // to the existing arguments.\n var newArgs = args.slice();\n newArgs.push.apply(newArgs, arguments);\n return fn.apply(this, newArgs);\n };\n};\n\n/**\n * Promises provide a result that may be resolved asynchronously. A Promise may\n * be resolved by being fulfilled or rejected with a value, which will be known\n * as the fulfillment value or the rejection reason. Whether fulfilled or\n * rejected, the Promise result is immutable once it is set.\n *\n * Promises may represent results of any type, including undefined. Rejection\n * reasons are typically Errors, but may also be of any type. Closure Promises\n * allow for optional type annotations that enforce that fulfillment values are\n * of the appropriate types at compile time.\n *\n * The result of a Promise is accessible by calling {@code then} and registering\n * {@code onFulfilled} and {@code onRejected} callbacks. Once the Promise\n * resolves, the relevant callbacks are invoked with the fulfillment value or\n * rejection reason as argument. Callbacks are always invoked in the order they\n * were registered, even when additional {@code then} calls are made from inside\n * another callback. A callback is always run asynchronously sometime after the\n * scope containing the registering {@code then} invocation has returned.\n *\n * If a Promise is resolved with another Promise, the first Promise will block\n * until the second is resolved, and then assumes the same result as the second\n * Promise. This allows Promises to depend on the results of other Promises,\n * linking together multiple asynchronous operations.\n *\n * This implementation is compatible with the Promises/A+ specification and\n * passes that specification's conformance test suite. A Closure Promise may be\n * resolved with a Promise instance (or sufficiently compatible Promise-like\n * object) created by other Promise implementations. From the specification,\n * Promise-like objects are known as \"Thenables\".\n *\n * @see http://promisesaplus.com/\n *\n * @param {function(\n * this:RESOLVER_CONTEXT,\n * function((TYPE|IThenable.<TYPE>|Thenable)),\n * function(*)): void} resolver\n * Initialization function that is invoked immediately with {@code resolve}\n * and {@code reject} functions as arguments. The Promise is resolved or\n * rejected with the first argument passed to either function.\n * @param {RESOLVER_CONTEXT=} opt_context An optional context for executing the\n * resolver function. If unspecified, the resolver function will be executed\n * in the default scope.\n * @constructor\n * @struct\n * @final\n * @implements {Thenable.<TYPE>}\n * @template TYPE,RESOLVER_CONTEXT\n */\nvar CancellablePromise = function(resolver, opt_context) {\n /**\n * The internal state of this Promise. Either PENDING, FULFILLED, REJECTED, or\n * BLOCKED.\n * @private {CancellablePromise.State_}\n */\n this.state_ = CancellablePromise.State_.PENDING;\n\n /**\n * The resolved result of the Promise. Immutable once set with either a\n * fulfillment value or rejection reason.\n * @private {*}\n */\n this.result_ = undefined;\n\n /**\n * For Promises created by calling {@code then()}, the originating parent.\n * @private {CancellablePromise}\n */\n this.parent_ = null;\n\n /**\n * The list of {@code onFulfilled} and {@code onRejected} callbacks added to\n * this Promise by calls to {@code then()}.\n * @private {Array.<CancellablePromise.CallbackEntry_>}\n */\n this.callbackEntries_ = null;\n\n /**\n * Whether the Promise is in the queue of Promises to execute.\n * @private {boolean}\n */\n this.executing_ = false;\n\n if (CancellablePromise.UNHANDLED_REJECTION_DELAY > 0) {\n /**\n * A timeout ID used when the {@code UNHANDLED_REJECTION_DELAY} is greater\n * than 0 milliseconds. The ID is set when the Promise is rejected, and\n * cleared only if an {@code onRejected} callback is invoked for the\n * Promise (or one of its descendants) before the delay is exceeded.\n *\n * If the rejection is not handled before the timeout completes, the\n * rejection reason is passed to the unhandled rejection handler.\n * @private {number}\n */\n this.unhandledRejectionId_ = 0;\n } else if (CancellablePromise.UNHANDLED_REJECTION_DELAY === 0) {\n /**\n * When the {@code UNHANDLED_REJECTION_DELAY} is set to 0 milliseconds, a\n * boolean that is set if the Promise is rejected, and reset to false if an\n * {@code onRejected} callback is invoked for the Promise (or one of its\n * descendants). If the rejection is not handled before the next timestep,\n * the rejection reason is passed to the unhandled rejection handler.\n * @private {boolean}\n */\n this.hadUnhandledRejection_ = false;\n }\n\n try {\n var self = this;\n resolver.call(\n opt_context, function(value) {\n self.resolve_(CancellablePromise.State_.FULFILLED, value);\n }, function(reason) {\n self.resolve_(CancellablePromise.State_.REJECTED, reason);\n });\n } catch (e) {\n this.resolve_(CancellablePromise.State_.REJECTED, e);\n }\n};\n\n/**\n * The delay in milliseconds before a rejected Promise's reason is passed to\n * the rejection handler. By default, the rejection handler rethrows the\n * rejection reason so that it appears in the developer console or\n * {@code window.onerror} handler.\n * Rejections are rethrown as quickly as possible by default. A negative value\n * disables rejection handling entirely.\n * @type {number}\n */\nCancellablePromise.UNHANDLED_REJECTION_DELAY = 0;\n\n\n/**\n * The possible internal states for a Promise. These states are not directly\n * observable to external callers.\n * @enum {number}\n * @private\n */\nCancellablePromise.State_ = {\n /** The Promise is waiting for resolution. */\n PENDING: 0,\n\n /** The Promise is blocked waiting for the result of another Thenable. */\n BLOCKED: 1,\n\n /** The Promise has been resolved with a fulfillment value. */\n FULFILLED: 2,\n\n /** The Promise has been resolved with a rejection reason. */\n REJECTED: 3\n};\n\n\n/**\n * Typedef for entries in the callback chain. Each call to {@code then},\n * {@code thenCatch}, or {@code thenAlways} creates an entry containing the\n * functions that may be invoked once the Promise is resolved.\n *\n * @typedef {{\n * child: CancellablePromise,\n * onFulfilled: function(*),\n * onRejected: function(*)\n * }}\n * @private\n */\nCancellablePromise.CallbackEntry_ = null;\n\n\n/**\n * @param {(TYPE|Thenable.<TYPE>|Thenable)=} opt_value\n * @return {!CancellablePromise.<TYPE>} A new Promise that is immediately resolved\n * with the given value.\n * @template TYPE\n */\nCancellablePromise.resolve = function(opt_value) {\n return new CancellablePromise(function(resolve) {\n resolve(opt_value);\n });\n};\n\n\n/**\n * @param {*=} opt_reason\n * @return {!CancellablePromise} A new Promise that is immediately rejected with the\n * given reason.\n */\nCancellablePromise.reject = function(opt_reason) {\n return new CancellablePromise(function(resolve, reject) {\n reject(opt_reason);\n });\n};\n\n\n/**\n * @param {!Array.<!(Thenable.<TYPE>|Thenable)>} promises\n * @return {!CancellablePromise.<TYPE>} A Promise that receives the result of the\n * first Promise (or Promise-like) input to complete.\n * @template TYPE\n */\nCancellablePromise.race = function(promises) {\n return new CancellablePromise(function(resolve, reject) {\n if (!promises.length) {\n resolve(undefined);\n }\n for (var i = 0, promise; (promise = promises[i]); i++) {\n promise.then(resolve, reject);\n }\n });\n};\n\n\n/**\n * @param {!Array.<!(Thenable.<TYPE>|Thenable)>} promises\n * @return {!CancellablePromise.<!Array.<TYPE>>} A Promise that receives a list of\n * every fulfilled value once every input Promise (or Promise-like) is\n * successfully fulfilled, or is rejected by the first rejection result.\n * @template TYPE\n */\nCancellablePromise.all = function(promises) {\n return new CancellablePromise(function(resolve, reject) {\n var toFulfill = promises.length;\n var values = [];\n\n if (!toFulfill) {\n resolve(values);\n return;\n }\n\n var onFulfill = function(index, value) {\n toFulfill--;\n values[index] = value;\n if (toFulfill === 0) {\n resolve(values);\n }\n };\n\n var onReject = function(reason) {\n reject(reason);\n };\n\n for (var i = 0, promise; (promise = promises[i]); i++) {\n promise.then(partial(onFulfill, i), onReject);\n }\n });\n};\n\n\n/**\n * @param {!Array.<!(Thenable.<TYPE>|Thenable)>} promises\n * @return {!CancellablePromise.<TYPE>} A Promise that receives the value of\n * the first input to be fulfilled, or is rejected with a list of every\n * rejection reason if all inputs are rejected.\n * @template TYPE\n */\nCancellablePromise.firstFulfilled = function(promises) {\n return new CancellablePromise(function(resolve, reject) {\n var toReject = promises.length;\n var reasons = [];\n\n if (!toReject) {\n resolve(undefined);\n return;\n }\n\n var onFulfill = function(value) {\n resolve(value);\n };\n\n var onReject = function(index, reason) {\n toReject--;\n reasons[index] = reason;\n if (toReject === 0) {\n reject(reasons);\n }\n };\n\n for (var i = 0, promise; (promise = promises[i]); i++) {\n promise.then(onFulfill, partial(onReject, i));\n }\n });\n};\n\n\n/**\n * Adds callbacks that will operate on the result of the Promise, returning a\n * new child Promise.\n *\n * If the Promise is fulfilled, the {@code onFulfilled} callback will be invoked\n * with the fulfillment value as argument, and the child Promise will be\n * fulfilled with the return value of the callback. If the callback throws an\n * exception, the child Promise will be rejected with the thrown value instead.\n *\n * If the Promise is rejected, the {@code onRejected} callback will be invoked\n * with the rejection reason as argument, and the child Promise will be rejected\n * with the return value (or thrown value) of the callback.\n *\n * @override\n */\nCancellablePromise.prototype.then = function(opt_onFulfilled, opt_onRejected, opt_context) {\n return this.addChildPromise_(\n core.isFunction(opt_onFulfilled) ? opt_onFulfilled : null,\n core.isFunction(opt_onRejected) ? opt_onRejected : null,\n opt_context);\n};\nThenable.addImplementation(CancellablePromise);\n\n\n/**\n * Adds a callback that will be invoked whether the Promise is fulfilled or\n * rejected. The callback receives no argument, and no new child Promise is\n * created. This is useful for ensuring that cleanup takes place after certain\n * asynchronous operations. Callbacks added with {@code thenAlways} will be\n * executed in the same order with other calls to {@code then},\n * {@code thenAlways}, or {@code thenCatch}.\n *\n * Since it does not produce a new child Promise, cancellation propagation is\n * not prevented by adding callbacks with {@code thenAlways}. A Promise that has\n * a cleanup handler added with {@code thenAlways} will be canceled if all of\n * its children created by {@code then} (or {@code thenCatch}) are canceled.\n *\n * @param {function(this:THIS): void} onResolved A function that will be invoked\n * when the Promise is resolved.\n * @param {THIS=} opt_context An optional context object that will be the\n * execution context for the callbacks. By default, functions are executed\n * in the global scope.\n * @return {!CancellablePromise.<TYPE>} This Promise, for chaining additional calls.\n * @template THIS\n */\nCancellablePromise.prototype.thenAlways = function(onResolved, opt_context) {\n var callback = function() {\n try {\n // Ensure that no arguments are passed to onResolved.\n onResolved.call(opt_context);\n } catch (err) {\n CancellablePromise.handleRejection_.call(null, err);\n }\n };\n\n this.addCallbackEntry_({\n child: null,\n onRejected: callback,\n onFulfilled: callback\n });\n return this;\n};\n\n\n/**\n * Adds a callback that will be invoked only if the Promise is rejected. This\n * is equivalent to {@code then(null, onRejected)}.\n *\n * @param {!function(this:THIS, *): *} onRejected A function that will be\n * invoked with the rejection reason if the Promise is rejected.\n * @param {THIS=} opt_context An optional context object that will be the\n * execution context for the callbacks. By default, functions are executed\n * in the global scope.\n * @return {!CancellablePromise} A new Promise that will receive the result of the\n * callback.\n * @template THIS\n */\nCancellablePromise.prototype.thenCatch = function(onRejected, opt_context) {\n return this.addChildPromise_(null, onRejected, opt_context);\n};\n\n/**\n * Alias of {@link CancellablePromise.prototype.thenCatch}\n */\nCancellablePromise.prototype.catch = CancellablePromise.prototype.thenCatch;\n\n\n/**\n * Cancels the Promise if it is still pending by rejecting it with a cancel\n * Error. No action is performed if the Promise is already resolved.\n *\n * All child Promises of the canceled Promise will be rejected with the same\n * cancel error, as with normal Promise rejection. If the Promise to be canceled\n * is the only child of a pending Promise, the parent Promise will also be\n * canceled. Cancellation may propagate upward through multiple generations.\n *\n * @param {string=} opt_message An optional debugging message for describing the\n * cancellation reason.\n */\nCancellablePromise.prototype.cancel = function(opt_message) {\n if (this.state_ === CancellablePromise.State_.PENDING) {\n async.run(function() {\n var err = new CancellablePromise.CancellationError(opt_message);\n err.IS_CANCELLATION_ERROR = true;\n this.cancelInternal_(err);\n }, this);\n }\n};\n\n\n/**\n * Cancels this Promise with the given error.\n *\n * @param {!Error} err The cancellation error.\n * @private\n */\nCancellablePromise.prototype.cancelInternal_ = function(err) {\n if (this.state_ === CancellablePromise.State_.PENDING) {\n if (this.parent_) {\n // Cancel the Promise and remove it from the parent's child list.\n this.parent_.cancelChild_(this, err);\n } else {\n this.resolve_(CancellablePromise.State_.REJECTED, err);\n }\n }\n};\n\n\n/**\n * Cancels a child Promise from the list of callback entries. If the Promise has\n * not already been resolved, reject it with a cancel error. If there are no\n * other children in the list of callback entries, propagate the cancellation\n * by canceling this Promise as well.\n *\n * @param {!CancellablePromise} childPromise The Promise to cancel.\n * @param {!Error} err The cancel error to use for rejecting the Promise.\n * @private\n */\nCancellablePromise.prototype.cancelChild_ = function(childPromise, err) {\n if (!this.callbackEntries_) {\n return;\n }\n var childCount = 0;\n var childIndex = -1;\n\n // Find the callback entry for the childPromise, and count whether there are\n // additional child Promises.\n for (var i = 0, entry; (entry = this.callbackEntries_[i]); i++) {\n var child = entry.child;\n if (child) {\n childCount++;\n if (child === childPromise) {\n childIndex = i;\n }\n if (childIndex >= 0 && childCount > 1) {\n break;\n }\n }\n }\n\n // If the child Promise was the only child, cancel this Promise as well.\n // Otherwise, reject only the child Promise with the cancel error.\n if (childIndex >= 0) {\n if (this.state_ === CancellablePromise.State_.PENDING && childCount === 1) {\n this.cancelInternal_(err);\n } else {\n var callbackEntry = this.callbackEntries_.splice(childIndex, 1)[0];\n this.executeCallback_(\n callbackEntry, CancellablePromise.State_.REJECTED, err);\n }\n }\n};\n\n\n/**\n * Adds a callback entry to the current Promise, and schedules callback\n * execution if the Promise has already been resolved.\n *\n * @param {CancellablePromise.CallbackEntry_} callbackEntry Record containing\n * {@code onFulfilled} and {@code onRejected} callbacks to execute after\n * the Promise is resolved.\n * @private\n */\nCancellablePromise.prototype.addCallbackEntry_ = function(callbackEntry) {\n if ((!this.callbackEntries_ || !this.callbackEntries_.length) &&\n (this.state_ === CancellablePromise.State_.FULFILLED ||\n this.state_ === CancellablePromise.State_.REJECTED)) {\n this.scheduleCallbacks_();\n }\n if (!this.callbackEntries_) {\n this.callbackEntries_ = [];\n }\n this.callbackEntries_.push(callbackEntry);\n};\n\n\n/**\n * Creates a child Promise and adds it to the callback entry list. The result of\n * the child Promise is determined by the state of the parent Promise and the\n * result of the {@code onFulfilled} or {@code onRejected} callbacks as\n * specified in the Promise resolution procedure.\n *\n * @see http://promisesaplus.com/#the__method\n *\n * @param {?function(this:THIS, TYPE):\n * (RESULT|CancellablePromise.<RESULT>|Thenable)} onFulfilled A callback that\n * will be invoked if the Promise is fullfilled, or null.\n * @param {?function(this:THIS, *): *} onRejected A callback that will be\n * invoked if the Promise is rejected, or null.\n * @param {THIS=} opt_context An optional execution context for the callbacks.\n * in the default calling context.\n * @return {!CancellablePromise} The child Promise.\n * @template RESULT,THIS\n * @private\n */\nCancellablePromise.prototype.addChildPromise_ = function(\nonFulfilled, onRejected, opt_context) {\n\n var callbackEntry = {\n child: null,\n onFulfilled: null,\n onRejected: null\n };\n\n callbackEntry.child = new CancellablePromise(function(resolve, reject) {\n // Invoke onFulfilled, or resolve with the parent's value if absent.\n callbackEntry.onFulfilled = onFulfilled ? function(value) {\n try {\n var result = onFulfilled.call(opt_context, value);\n resolve(result);\n } catch (err) {\n reject(err);\n }\n } : resolve;\n\n // Invoke onRejected, or reject with the parent's reason if absent.\n callbackEntry.onRejected = onRejected ? function(reason) {\n try {\n var result = onRejected.call(opt_context, reason);\n if (!core.isDef(result) && reason.IS_CANCELLATION_ERROR) {\n // Propagate cancellation to children if no other result is returned.\n reject(reason);\n } else {\n resolve(result);\n }\n } catch (err) {\n reject(err);\n }\n } : reject;\n });\n\n callbackEntry.child.parent_ = this;\n this.addCallbackEntry_(\n /** @type {CancellablePromise.CallbackEntry_} */ (callbackEntry));\n return callbackEntry.child;\n};\n\n\n/**\n * Unblocks the Promise and fulfills it with the given value.\n *\n * @param {TYPE} value\n * @private\n */\nCancellablePromise.prototype.unblockAndFulfill_ = function(value) {\n if (this.state_ !== CancellablePromise.State_.BLOCKED) {\n throw new Error('CancellablePromise is not blocked.');\n }\n this.state_ = CancellablePromise.State_.PENDING;\n this.resolve_(CancellablePromise.State_.FULFILLED, value);\n};\n\n\n/**\n * Unblocks the Promise and rejects it with the given rejection reason.\n *\n * @param {*} reason\n * @private\n */\nCancellablePromise.prototype.unblockAndReject_ = function(reason) {\n if (this.state_ !== CancellablePromise.State_.BLOCKED) {\n throw new Error('CancellablePromise is not blocked.');\n }\n this.state_ = CancellablePromise.State_.PENDING;\n this.resolve_(CancellablePromise.State_.REJECTED, reason);\n};\n\n\n/**\n * Attempts to resolve a Promise with a given resolution state and value. This\n * is a no-op if the given Promise has already been resolved.\n *\n * If the given result is a Thenable (such as another Promise), the Promise will\n * be resolved with the same state and result as the Thenable once it is itself\n * resolved.\n *\n * If the given result is not a Thenable, the Promise will be fulfilled or\n * rejected with that result based on the given state.\n *\n * @see http://promisesaplus.com/#the_promise_resolution_procedure\n *\n * @param {CancellablePromise.State_} state\n * @param {*} x The result to apply to the Promise.\n * @private\n */\nCancellablePromise.prototype.resolve_ = function(state, x) {\n if (this.state_ !== CancellablePromise.State_.PENDING) {\n return;\n }\n\n if (this === x) {\n state = CancellablePromise.State_.REJECTED;\n x = new TypeError('CancellablePromise cannot resolve to itself');\n\n } else if (Thenable.isImplementedBy(x)) {\n x = /** @type {!Thenable} */ (x);\n this.state_ = CancellablePromise.State_.BLOCKED;\n x.then(this.unblockAndFulfill_, this.unblockAndReject_, this);\n return;\n\n } else if (core.isObject(x)) {\n try {\n var then = x.then;\n if (core.isFunction(then)) {\n this.tryThen_(x, then);\n return;\n }\n } catch (e) {\n state = CancellablePromise.State_.REJECTED;\n x = e;\n }\n }\n\n this.result_ = x;\n this.state_ = state;\n this.scheduleCallbacks_();\n\n if (state === CancellablePromise.State_.REJECTED && !x.IS_CANCELLATION_ERROR) {\n CancellablePromise.addUnhandledRejection_(this, x);\n }\n};\n\n\n/**\n * Attempts to call the {@code then} method on an object in the hopes that it is\n * a Promise-compatible instance. This allows interoperation between different\n * Promise implementations, however a non-compliant object may cause a Promise\n * to hang indefinitely. If the {@code then} method throws an exception, the\n * dependent Promise will be rejected with the thrown value.\n *\n * @see http://promisesaplus.com/#point-70\n *\n * @param {Thenable} thenable An object with a {@code then} method that may be\n * compatible with the Promise/A+ specification.\n * @param {!Function} then The {@code then} method of the Thenable object.\n * @private\n */\nCancellablePromise.prototype.tryThen_ = function(thenable, then) {\n this.state_ = CancellablePromise.State_.BLOCKED;\n var promise = this;\n var called = false;\n\n var resolve = function(value) {\n if (!called) {\n called = true;\n promise.unblockAndFulfill_(value);\n }\n };\n\n var reject = function(reason) {\n if (!called) {\n called = true;\n promise.unblockAndReject_(reason);\n }\n };\n\n try {\n then.call(thenable, resolve, reject);\n } catch (e) {\n reject(e);\n }\n};\n\n\n/**\n * Executes the pending callbacks of a resolved Promise after a timeout.\n *\n * Section 2.2.4 of the Promises/A+ specification requires that Promise\n * callbacks must only be invoked from a call stack that only contains Promise\n * implementation code, which we accomplish by invoking callback execution after\n * a timeout. If {@code startExecution_} is called multiple times for the same\n * Promise, the callback chain will be evaluated only once. Additional callbacks\n * may be added during the evaluation phase, and will be executed in the same\n * event loop.\n *\n * All Promises added to the waiting list during the same browser event loop\n * will be executed in one batch to avoid using a separate timeout per Promise.\n *\n * @private\n */\nCancellablePromise.prototype.scheduleCallbacks_ = function() {\n if (!this.executing_) {\n this.executing_ = true;\n async.run(this.executeCallbacks_, this);\n }\n};\n\n\n/**\n * Executes all pending callbacks for this Promise.\n *\n * @private\n */\nCancellablePromise.prototype.executeCallbacks_ = function() {\n while (this.callbackEntries_ && this.callbackEntries_.length) {\n var entries = this.callbackEntries_;\n this.callbackEntries_ = [];\n\n for (var i = 0; i < entries.length; i++) {\n this.executeCallback_(entries[i], this.state_, this.result_);\n }\n }\n this.executing_ = false;\n};\n\n\n/**\n * Executes a pending callback for this Promise. Invokes an {@code onFulfilled}\n * or {@code onRejected} callback based on the resolved state of the Promise.\n *\n * @param {!CancellablePromise.CallbackEntry_} callbackEntry An entry containing the\n * onFulfilled and/or onRejected callbacks for this step.\n * @param {CancellablePromise.State_} state The resolution status of the Promise,\n * either FULFILLED or REJECTED.\n * @param {*} result The resolved result of the Promise.\n * @private\n */\nCancellablePromise.prototype.executeCallback_ = function(\ncallbackEntry, state, result) {\n if (state === CancellablePromise.State_.FULFILLED) {\n callbackEntry.onFulfilled(result);\n } else {\n this.removeUnhandledRejection_();\n callbackEntry.onRejected(result);\n }\n};\n\n\n/**\n * Marks this rejected Promise as having being handled. Also marks any parent\n * Promises in the rejected state as handled. The rejection handler will no\n * longer be invoked for this Promise (if it has not been called already).\n *\n * @private\n */\nCancellablePromise.prototype.removeUnhandledRejection_ = function() {\n var p;\n if (CancellablePromise.UNHANDLED_REJECTION_DELAY > 0) {\n for (p = this; p && p.unhandledRejectionId_; p = p.parent_) {\n clearTimeout(p.unhandledRejectionId_);\n p.unhandledRejectionId_ = 0;\n }\n } else if (CancellablePromise.UNHANDLED_REJECTION_DELAY === 0) {\n for (p = this; p && p.hadUnhandledRejection_; p = p.parent_) {\n p.hadUnhandledRejection_ = false;\n }\n }\n};\n\n\n/**\n * Marks this rejected Promise as unhandled. If no {@code onRejected} callback\n * is called for this Promise before the {@code UNHANDLED_REJECTION_DELAY}\n * expires, the reason will be passed to the unhandled rejection handler. The\n * handler typically rethrows the rejection reason so that it becomes visible in\n * the developer console.\n *\n * @param {!CancellablePromise} promise The rejected Promise.\n * @param {*} reason The Promise rejection reason.\n * @private\n */\nCancellablePromise.addUnhandledRejection_ = function(promise, reason) {\n if (CancellablePromise.UNHANDLED_REJECTION_DELAY > 0) {\n promise.unhandledRejectionId_ = setTimeout(function() {\n CancellablePromise.handleRejection_.call(null, reason);\n }, CancellablePromise.UNHANDLED_REJECTION_DELAY);\n\n } else if (CancellablePromise.UNHANDLED_REJECTION_DELAY === 0) {\n promise.hadUnhandledRejection_ = true;\n async.run(function() {\n if (promise.hadUnhandledRejection_) {\n CancellablePromise.handleRejection_.call(null, reason);\n }\n });\n }\n};\n\n\n/**\n * A method that is invoked with the rejection reasons for Promises that are\n * rejected but have no {@code onRejected} callbacks registered yet.\n * @type {function(*)}\n * @private\n */\nCancellablePromise.handleRejection_ = async.throwException;\n\n\n/**\n * Sets a handler that will be called with reasons from unhandled rejected\n * Promises. If the rejected Promise (or one of its descendants) has an\n * {@code onRejected} callback registered, the rejection will be considered\n * handled, and the rejection handler will not be called.\n *\n * By default, unhandled rejections are rethrown so that the error may be\n * captured by the developer console or a {@code window.onerror} handler.\n *\n * @param {function(*)} handler A function that will be called with reasons from\n * rejected Promises. Defaults to {@code async.throwException}.\n */\nCancellablePromise.setUnhandledRejectionHandler = function(handler) {\n CancellablePromise.handleRejection_ = handler;\n};\n\n\n\n/**\n * Error used as a rejection reason for canceled Promises.\n *\n * @param {string=} opt_message\n * @constructor\n * @extends {Error}\n * @final\n */\nCancellablePromise.CancellationError = class extends Error {\n constructor(opt_message) {\n super(opt_message);\n\n if (opt_message) {\n this.message = opt_message;\n }\n }\n};\n\n/** @override */\nCancellablePromise.CancellationError.prototype.name = 'cancel';\n\nexport {CancellablePromise};\nexport default CancellablePromise;\n","var globals = {\n\tdocument: document,\n\twindow: window\n};\n\nexport default globals;","'use strict';\n\n/**\n * Parses the given uri string into an object.\n * @param {*=} opt_uri Optional string URI to parse\n */\nfunction parseFromAnchor(opt_uri) {\n\tvar link = document.createElement('a');\n\tlink.href = opt_uri;\n\treturn {\n\t\thash: link.hash,\n\t\thostname: link.hostname,\n\t\tpassword: link.password,\n\t\tpathname: link.pathname[0] === '/' ? link.pathname : '/' + link.pathname,\n\t\tport: link.port,\n\t\tprotocol: link.protocol,\n\t\tsearch: link.search,\n\t\tusername: link.username\n\t};\n}\n\nexport default parseFromAnchor;\n","'use strict';\n\nimport { core } from 'metal';\nimport parseFromAnchor from './parseFromAnchor';\n\n/**\n * Parses the given uri string into an object. The URL function will be used\n * when present, otherwise we'll fall back to the anchor node element.\n * @param {*=} opt_uri Optional string URI to parse\n */\nfunction parse(opt_uri) {\n\tif (core.isFunction(URL) && URL.length) {\n\t\treturn new URL(opt_uri);\n\t} else {\n\t\treturn parseFromAnchor(opt_uri);\n\t}\n}\n\nexport default parse;\n","'use strict';\n\nimport { Disposable } from 'metal';\n\n/**\n * A cached reference to the create function.\n */\nvar create = Object.create;\n\n/**\n * Case insensitive string Multimap implementation. Allows multiple values for\n * the same key name.\n * @extends {Disposable}\n */\nclass MultiMap extends Disposable {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.keys = create(null);\n\t\tthis.values = create(null);\n\t}\n\n\t/**\n\t * Adds value to a key name.\n\t * @param {string} name\n\t * @param {*} value\n\t * @chainable\n\t */\n\tadd(name, value) {\n\t\tthis.keys[name.toLowerCase()] = name;\n\t\tthis.values[name.toLowerCase()] = this.values[name.toLowerCase()] || [];\n\t\tthis.values[name.toLowerCase()].push(value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Clears map names and values.\n\t * @chainable\n\t */\n\tclear() {\n\t\tthis.keys = create(null);\n\t\tthis.values = create(null);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Checks if map contains a value to the key name.\n\t * @param {string} name\n\t * @return {boolean}\n\t * @chainable\n\t */\n\tcontains(name) {\n\t\treturn name.toLowerCase() in this.values;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tthis.values = null;\n\t}\n\n\t/**\n\t * Gets the first added value from a key name.\n\t * @param {string} name\n\t * @return {*}\n\t * @chainable\n\t */\n\tget(name) {\n\t\tvar values = this.values[name.toLowerCase()];\n\t\tif (values) {\n\t\t\treturn values[0];\n\t\t}\n\t}\n\n\t/**\n\t * Gets all values from a key name.\n\t * @param {string} name\n\t * @return {Array.<*>}\n\t */\n\tgetAll(name) {\n\t\treturn this.values[name.toLowerCase()];\n\t}\n\n\t/**\n\t * Returns true if the map is empty, false otherwise.\n\t * @return {boolean}\n\t */\n\tisEmpty() {\n\t\treturn this.size() === 0;\n\t}\n\n\t/**\n\t * Gets array of key names.\n\t * @return {Array.<string>}\n\t */\n\tnames() {\n\t\treturn Object.keys(this.values).map((key) => this.keys[key]);\n\t}\n\n\t/**\n\t * Removes all values from a key name.\n\t * @param {string} name\n\t * @chainable\n\t */\n\tremove(name) {\n\t\tdelete this.keys[name.toLowerCase()];\n\t\tdelete this.values[name.toLowerCase()];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the value of a key name. Relevant to replace the current values with\n\t * a new one.\n\t * @param {string} name\n\t * @param {*} value\n\t * @chainable\n\t */\n\tset(name, value) {\n\t\tthis.keys[name.toLowerCase()] = name;\n\t\tthis.values[name.toLowerCase()] = [value];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the size of the map key names.\n\t * @return {number}\n\t */\n\tsize() {\n\t\treturn this.names().length;\n\t}\n\n\t/**\n\t * Returns the parsed values as a string.\n\t * @return {string}\n\t */\n\ttoString() {\n\t\treturn JSON.stringify(this.values);\n\t}\n}\n\nexport default MultiMap;\n","'use strict';\n\nimport { core, string } from 'metal';\nimport parse from './parse';\nimport MultiMap from 'metal-multimap';\n\nvar parseFn_ = parse;\n\nclass Uri {\n\n\t/**\n\t * This class contains setters and getters for the parts of the URI.\n\t * The following figure displays an example URIs and their component parts.\n\t *\n\t * path\n\t *\t ┌───┴────┐\n\t *\t abc://example.com:123/path/data?key=value#fragid1\n\t *\t └┬┘ └────┬────┘ └┬┘ └───┬───┘ └──┬──┘\n\t * protocol hostname port search hash\n\t * └──────┬───────┘\n\t * host\n\t *\n\t * @param {*=} opt_uri Optional string URI to parse\n\t * @constructor\n\t */\n\tconstructor(opt_uri = '') {\n\t\tthis.url = Uri.parse(this.maybeAddProtocolAndHostname_(opt_uri));\n\t}\n\n\t/**\n\t * Adds parameters to uri from a <code>MultiMap</code> as source.\n\t * @param {MultiMap} multimap The <code>MultiMap</code> containing the\n\t * parameters.\n\t * @protected\n\t * @chainable\n\t */\n\taddParametersFromMultiMap(multimap) {\n\t\tmultimap.names().forEach((name) => {\n\t\t\tmultimap.getAll(name).forEach((value) => {\n\t\t\t\tthis.addParameterValue(name, value);\n\t\t\t});\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds the value of the named query parameters.\n\t * @param {string} key The parameter to set.\n\t * @param {*} value The new value. Will be explicitly casted to String.\n\t * @chainable\n\t */\n\taddParameterValue(name, value) {\n\t\tthis.ensureQueryInitialized_();\n\t\tif (core.isDef(value)) {\n\t\t\tvalue = String(value);\n\t\t}\n\t\tthis.query.add(name, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds the values of the named query parameter.\n\t * @param {string} key The parameter to set.\n\t * @param {*} value The new value.\n\t * @chainable\n\t */\n\taddParameterValues(name, values) {\n\t\tvalues.forEach((value) => this.addParameterValue(name, value));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Ensures query internal map is initialized and synced with initial value\n\t * extracted from URI search part.\n\t * @protected\n\t */\n\tensureQueryInitialized_() {\n\t\tif (this.query) {\n\t\t\treturn;\n\t\t}\n\t\tthis.query = new MultiMap();\n\t\tvar search = this.url.search;\n\t\tif (search) {\n\t\t\tsearch.substring(1).split('&').forEach((param) => {\n\t\t\t\tvar [key, value] = param.split('=');\n\t\t\t\tif (core.isDef(value)) {\n\t\t\t\t\tvalue = Uri.urlDecode(value);\n\t\t\t\t}\n\t\t\t\tthis.addParameterValue(key, value);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Gets the hash part of uri.\n\t * @return {string}\n\t */\n\tgetHash() {\n\t\treturn this.url.hash || '';\n\t}\n\n\t/**\n\t * Gets the host part of uri. E.g. <code>[hostname]:[port]</code>.\n\t * @return {string}\n\t */\n\tgetHost() {\n\t\tvar host = this.getHostname();\n\t\tif (host) {\n\t\t\tvar port = this.getPort();\n\t\t\tif (port && port !== '80') {\n\t\t\t\thost += ':' + port;\n\t\t\t}\n\t\t}\n\t\treturn host;\n\t}\n\n\t/**\n\t * Gets the hostname part of uri without protocol and port.\n\t * @return {string}\n\t */\n\tgetHostname() {\n\t\tvar hostname = this.url.hostname;\n\t\tif (hostname === Uri.HOSTNAME_PLACEHOLDER) {\n\t\t\treturn '';\n\t\t}\n\t\treturn hostname;\n\t}\n\n\t/**\n\t * Gets the origin part of uri. E.g. <code>http://[hostname]:[port]</code>.\n\t * @return {string}\n\t */\n\tgetOrigin() {\n\t\tvar host = this.getHost();\n\t\tif (host) {\n\t\t\treturn this.getProtocol() + '//' + host;\n\t\t}\n\t\treturn '';\n\t}\n\n\t/**\n\t * Returns the first value for a given parameter or undefined if the given\n\t * parameter name does not appear in the query string.\n\t * @param {string} paramName Unescaped parameter name.\n\t * @return {string|undefined} The first value for a given parameter or\n\t * undefined if the given parameter name does not appear in the query\n\t * string.\n\t */\n\tgetParameterValue(name) {\n\t\tthis.ensureQueryInitialized_();\n\t\treturn this.query.get(name);\n\t}\n\n\t/**\n\t * Returns the value<b>s</b> for a given parameter as a list of decoded\n\t * query parameter values.\n\t * @param {string} name The parameter to get values for.\n\t * @return {!Array<?>} The values for a given parameter as a list of decoded\n\t * query parameter values.\n\t */\n\tgetParameterValues(name) {\n\t\tthis.ensureQueryInitialized_();\n\t\treturn this.query.getAll(name);\n\t}\n\n\t/**\n\t * Returns the name<b>s</b> of the parameters.\n\t * @return {!Array<string>} The names for the parameters as a list of\n\t * strings.\n\t */\n\tgetParameterNames() {\n\t\tthis.ensureQueryInitialized_();\n\t\treturn this.query.names();\n\t}\n\n\t/**\n\t * Gets the function currently being used to parse URIs.\n\t * @return {!function()}\n\t */\n\tstatic getParseFn() {\n\t\treturn parseFn_;\n\t}\n\n\t/**\n\t * Gets the pathname part of uri.\n\t * @return {string}\n\t */\n\tgetPathname() {\n\t\treturn this.url.pathname;\n\t}\n\n\t/**\n\t * Gets the port number part of uri as string.\n\t * @return {string}\n\t */\n\tgetPort() {\n\t\treturn this.url.port;\n\t}\n\n\t/**\n\t * Gets the protocol part of uri. E.g. <code>http:</code>.\n\t * @return {string}\n\t */\n\tgetProtocol() {\n\t\treturn this.url.protocol;\n\t}\n\n\t/**\n\t * Gets the search part of uri. Search value is retrieved from query\n\t * parameters.\n\t * @return {string}\n\t */\n\tgetSearch() {\n\t\tvar search = '';\n\t\tvar querystring = '';\n\t\tthis.getParameterNames().forEach((name) => {\n\t\t\tthis.getParameterValues(name).forEach((value) => {\n\t\t\t\tquerystring += name;\n\t\t\t\tif (core.isDef(value)) {\n\t\t\t\t\tquerystring += '=' + encodeURIComponent(value);\n\t\t\t\t}\n\t\t\t\tquerystring += '&';\n\t\t\t});\n\t\t});\n\t\tquerystring = querystring.slice(0, -1);\n\t\tif (querystring) {\n\t\t\tsearch += '?' + querystring;\n\t\t}\n\t\treturn search;\n\t}\n\n\t/**\n\t * Checks if uri contains the parameter.\n\t * @param {string} name\n\t * @return {boolean}\n\t */\n\thasParameter(name) {\n\t\tthis.ensureQueryInitialized_();\n\t\treturn this.query.contains(name);\n\t}\n\n\t/**\n\t * Makes this URL unique by adding a random param to it. Useful for avoiding\n\t * cache.\n\t */\n\tmakeUnique() {\n\t\tthis.setParameterValue(Uri.RANDOM_PARAM, string.getRandomString());\n\t\treturn this;\n\t}\n\n\t/**\n\t * Maybe adds protocol and a hostname placeholder on a parial URI if needed.\n\t * Relevent for compatibility with <code>URL</code> native object.\n\t * @param {string=} opt_uri\n\t * @return {string} URI with protocol and hostname placeholder.\n\t */\n\tmaybeAddProtocolAndHostname_(opt_uri) {\n\t\tvar url = opt_uri;\n\t\tif (opt_uri.indexOf('://') === -1 &&\n\t\t\topt_uri.indexOf('javascript:') !== 0) { // jshint ignore:line\n\n\t\t\turl = Uri.DEFAULT_PROTOCOL;\n\t\t\tif (opt_uri[0] !== '/' || opt_uri[1] !== '/') {\n\t\t\t\turl += '//';\n\t\t\t}\n\n\t\t\tswitch (opt_uri.charAt(0)) {\n\t\t\t\tcase '.':\n\t\t\t\tcase '?':\n\t\t\t\tcase '#':\n\t\t\t\t\turl += Uri.HOSTNAME_PLACEHOLDER;\n\t\t\t\t\turl += '/';\n\t\t\t\t\turl += opt_uri;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '':\n\t\t\t\tcase '/':\n\t\t\t\t\tif (opt_uri[1] !== '/') {\n\t\t\t\t\t\turl += Uri.HOSTNAME_PLACEHOLDER;\n\t\t\t\t\t}\n\t\t\t\t\turl += opt_uri;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\turl += opt_uri;\n\t\t\t}\n\t\t}\n\t\treturn url;\n\t}\n\n\t/**\n\t * Normalizes the parsed object to be in the expected standard.\n\t * @param {!Object}\n\t */\n\tstatic normalizeObject(parsed) {\n\t\tvar length = parsed.pathname ? parsed.pathname.length : 0;\n\t\tif (length > 1 && parsed.pathname[length - 1] === '/') {\n\t\t\tparsed.pathname = parsed.pathname.substr(0, length - 1);\n\t\t}\n\t\treturn parsed;\n\t}\n\n\t/**\n\t * Parses the given uri string into an object.\n\t * @param {*=} opt_uri Optional string URI to parse\n\t */\n\tstatic parse(opt_uri) {\n\t\treturn Uri.normalizeObject(parseFn_(opt_uri));\n\t}\n\n\t/**\n\t * Removes the named query parameter.\n\t * @param {string} name The parameter to remove.\n\t * @chainable\n\t */\n\tremoveParameter(name) {\n\t\tthis.ensureQueryInitialized_();\n\t\tthis.query.remove(name);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes uniqueness parameter of the uri.\n\t * @chainable\n\t */\n\tremoveUnique() {\n\t\tthis.removeParameter(Uri.RANDOM_PARAM);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the hash.\n\t * @param {string} hash\n\t * @chainable\n\t */\n\tsetHash(hash) {\n\t\tthis.url.hash = hash;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the hostname.\n\t * @param {string} hostname\n\t * @chainable\n\t */\n\tsetHostname(hostname) {\n\t\tthis.url.hostname = hostname;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the value of the named query parameters, clearing previous values\n\t * for that key.\n\t * @param {string} key The parameter to set.\n\t * @param {*} value The new value.\n\t * @chainable\n\t */\n\tsetParameterValue(name, value) {\n\t\tthis.removeParameter(name);\n\t\tthis.addParameterValue(name, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the values of the named query parameters, clearing previous values\n\t * for that key.\n\t * @param {string} key The parameter to set.\n\t * @param {*} value The new value.\n\t * @chainable\n\t */\n\tsetParameterValues(name, values) {\n\t\tthis.removeParameter(name);\n\t\tvalues.forEach((value) => this.addParameterValue(name, value));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the pathname.\n\t * @param {string} pathname\n\t * @chainable\n\t */\n\tsetPathname(pathname) {\n\t\tthis.url.pathname = pathname;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the port number.\n\t * @param {*} port Port number.\n\t * @chainable\n\t */\n\tsetPort(port) {\n\t\tthis.url.port = port;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the function that will be used for parsing the original string uri\n\t * into an object.\n\t * @param {!function()} parseFn\n\t */\n\tstatic setParseFn(parseFn) {\n\t\tparseFn_ = parseFn;\n\t}\n\n\t/**\n\t * Sets the protocol. If missing <code>http:</code> is used as default.\n\t * @param {string} protocol\n\t * @chainable\n\t */\n\tsetProtocol(protocol) {\n\t\tthis.url.protocol = protocol;\n\t\tif (this.url.protocol[this.url.protocol.length - 1] !== ':') {\n\t\t\tthis.url.protocol += ':';\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * @return {string} The string form of the url.\n\t * @override\n\t */\n\ttoString() {\n\t\tvar href = '';\n\t\tvar host = this.getHost();\n\t\tif (host) {\n\t\t\thref += this.getProtocol() + '//';\n\t\t}\n\t\thref += host + this.getPathname() + this.getSearch() + this.getHash();\n\t\treturn href;\n\t}\n\n\t/**\n\t * Joins the given paths.\n\t * @param {string} basePath\n\t * @param {...string} ...paths Any number of paths to be joined with the base url.\n\t * @static\n\t */\n\tstatic joinPaths(basePath, ...paths) {\n\t\tif (basePath.charAt(basePath.length - 1) === '/') {\n\t\t\tbasePath = basePath.substring(0, basePath.length - 1);\n\t\t}\n\t\tpaths = paths.map(path => path.charAt(0) === '/' ? path.substring(1) : path);\n\t\treturn [basePath].concat(paths).join('/').replace(/\\/$/, '');\n\t}\n\n\t/**\n\t * URL-decodes the string. We need to specially handle '+'s because\n\t * the javascript library doesn't convert them to spaces.\n\t * @param {string} str The string to url decode.\n\t * @return {string} The decoded {@code str}.\n\t */\n\tstatic urlDecode(str) {\n\t\treturn decodeURIComponent(str.replace(/\\+/g, ' '));\n\t}\n\n}\n\n/**\n * Default protocol value.\n * @type {string}\n * @default http:\n * @static\n */\nUri.DEFAULT_PROTOCOL = 'http:';\n\n/**\n * Hostname placeholder. Relevant to internal usage only.\n * @type {string}\n * @static\n */\nUri.HOSTNAME_PLACEHOLDER = 'hostname' + Date.now();\n\n/**\n * Name used by the param generated by `makeUnique`.\n * @type {string}\n * @static\n */\nUri.RANDOM_PARAM = 'zx';\n\nexport default Uri;\n","'use strict';\n\nimport globals from '../globals/globals';\nimport Uri from 'metal-uri';\n\n/**\n * A collection of static utility functions.\n * @const\n */\nclass utils {\n\n\t/**\n\t * Copies attributes form source node to target node.\n\t * @return {void}\n\t * @static\n\t */\n\tstatic copyNodeAttributes(source, target) {\n\t\tArray.prototype.slice.call(source.attributes).forEach((attribute) => target.setAttribute(attribute.name, attribute.value));\n\t}\n\n\t/**\n\t * Gets the current browser path including hashbang.\n\t * @return {!string}\n\t * @static\n\t */\n\tstatic getCurrentBrowserPath() {\n\t\treturn this.getCurrentBrowserPathWithoutHash() + globals.window.location.hash;\n\t}\n\n\t/**\n\t * Gets the current browser path excluding hashbang.\n\t * @return {!string}\n\t * @static\n\t */\n\tstatic getCurrentBrowserPathWithoutHash() {\n\t\treturn globals.window.location.pathname + globals.window.location.search;\n\t}\n\n\t/**\n\t * Extracts the path part of an url.\n\t * @return {!string}\n\t * @static\n\t */\n\tstatic getUrlPath(url) {\n\t\tvar uri = new Uri(url);\n\t\treturn uri.getPathname() + uri.getSearch() + uri.getHash();\n\t}\n\n\t/**\n\t * Extracts the path part of an url without hashbang.\n\t * @return {!string}\n\t * @static\n\t */\n\tstatic getUrlPathWithoutHash(url) {\n\t\tvar uri = new Uri(url);\n\t\treturn uri.getPathname() + uri.getSearch();\n\t}\n\n\t/**\n\t * Checks if url is in the same browser current url excluding the hashbang.\n\t * @param {!string} url\n\t * @return {boolean}\n\t * @static\n\t */\n\tstatic isCurrentBrowserPath(url) {\n\t\tif (url) {\n\t\t\treturn utils.getUrlPathWithoutHash(url) === this.getCurrentBrowserPathWithoutHash();\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Returns true if HTML5 History api is supported.\n\t * @return {boolean}\n\t * @static\n\t */\n\tstatic isHtml5HistorySupported() {\n\t\treturn !!(globals.window.history && globals.window.history.pushState);\n\t}\n\n\t/**\n\t * Removes all attributes form node.\n\t * @return {void}\n\t * @static\n\t */\n\tstatic clearNodeAttributes(node) {\n\t\tArray.prototype.slice.call(node.attributes).forEach((attribute) => node.removeAttribute(attribute.name));\n\t}\n\n}\n\nexport default utils;","'use strict';\n\nimport { core } from 'metal';\n\nclass Route {\n\n\t/**\n\t * Route class.\n\t * @param {!string|RegExp|Function} path\n\t * @param {!Function} handler\n\t * @constructor\n\t */\n\tconstructor(path, handler) {\n\t\tif (!core.isDefAndNotNull(path)) {\n\t\t\tthrow new Error('Route path not specified.');\n\t\t}\n\t\tif (!core.isFunction(handler)) {\n\t\t\tthrow new Error('Route handler is not a function.');\n\t\t}\n\n\t\t/**\n\t\t * Defines the handler which will execute once a URL in the application\n\t\t * matches the path.\n\t\t * @type {!Function}\n\t\t * @protected\n\t\t */\n\t\tthis.handler = handler;\n\n\t\t/**\n\t\t * Defines the path which will trigger the route handler.\n\t\t * @type {!string|RegExp|Function}\n\t\t * @protected\n\t\t */\n\t\tthis.path = path;\n\t}\n\n\t/**\n\t * Gets the route handler.\n\t * @return {!Function}\n\t */\n\tgetHandler() {\n\t\treturn this.handler;\n\t}\n\n\t/**\n\t * Gets the route path.\n\t * @return {!string|RegExp|Function}\n\t */\n\tgetPath() {\n\t\treturn this.path;\n\t}\n\n\t/**\n\t * Matches if the router can handle the tested path.\n\t * @param {!string} value Path to test and may contains the querystring\n\t * part.\n\t * @return {Boolean} Returns true if matches any route.\n\t */\n\tmatchesPath(value) {\n\t\tvar path = this.path;\n\n\t\tif (core.isString(path)) {\n\t\t\treturn value === path;\n\t\t}\n\t\tif (core.isFunction(path)) {\n\t\t\treturn path(value);\n\t\t}\n\t\tif (path instanceof RegExp) {\n\t\t\treturn value.search(path) > -1;\n\t\t}\n\n\t\treturn false;\n\t}\n\n}\n\nexport default Route;\n","'use strict';\n\nimport { Disposable } from 'metal';\n\nclass Cacheable extends Disposable {\n\n\t/**\n\t * Abstract class for defining cacheable behavior.\n\t * @constructor\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the cached data.\n\t\t * @type {!Object}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.cache = null;\n\n\t\t/**\n\t\t * Holds whether class is cacheable.\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t * @protected\n\t\t */\n\t\tthis.cacheable = false;\n\t}\n\n\t/**\n\t * Adds content to the cache.\n\t * @param {string} content Content to be cached.\n\t * @chainable\n\t */\n\taddCache(content) {\n\t\tif (this.cacheable) {\n\t\t\tthis.cache = content;\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Clears the cache.\n\t * @chainable\n\t */\n\tclearCache() {\n\t\tthis.cache = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Disposes of this instance's object references.\n\t * @override\n\t */\n\tdisposeInternal() {\n\t\tthis.clearCache();\n\t}\n\n\t/**\n\t * Gets the cached content.\n\t * @return {Object} Cached content.\n\t * @protected\n\t */\n\tgetCache() {\n\t\treturn this.cache;\n\t}\n\n\t/**\n\t * Whether the class is cacheable.\n\t * @return {boolean} Returns true when class is cacheable, false otherwise.\n\t */\n\tisCacheable() {\n\t\treturn this.cacheable;\n\t}\n\n\t/**\n\t * Sets whether the class is cacheable.\n\t * @param {boolean} cacheable\n\t */\n\tsetCacheable(cacheable) {\n\t\tif (!cacheable) {\n\t\t\tthis.clearCache();\n\t\t}\n\t\tthis.cacheable = cacheable;\n\t}\n\n}\n\nexport default Cacheable;\n","'use strict';\n\nimport { core } from 'metal';\nimport { globalEval } from 'metal-dom';\nimport Cacheable from '../cacheable/Cacheable';\nimport CancellablePromise from 'metal-promise';\n\nclass Screen extends Cacheable {\n\n\t/**\n\t * Screen class is a special type of route handler that provides helper\n\t * utilities that adds lifecycle and methods to provide content to each\n\t * registered surface.\n\t * @constructor\n\t * @extends {Cacheable}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the screen id.\n\t\t * @type {string}\n\t\t * @protected\n\t\t */\n\t\tthis.id = this.makeId_(core.getUid());\n\n\t\t/**\n\t\t * Holds the screen title. Relevant when the page title should be\n\t\t * upadated when screen is rendered.\n\t\t * @type {?string=}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.title = null;\n\t}\n\n\t/**\n\t * Fires when the screen is active. Allows a screen to perform any setup\n\t * that requires its DOM to be visible. Lifecycle.\n\t */\n\tactivate() {\n\t\tconsole.log('Screen [' + this + '] activate');\n\t}\n\n\t/**\n\t * Gives the Screen a chance to cancel the navigation and stop itself from\n\t * being deactivated. Can be used, for example, if the screen has unsaved\n\t * state. Lifecycle. Clean-up should not be preformed here, since the\n\t * navigation may still be cancelled. Do clean-up in deactivate.\n\t * @return {boolean=} If returns true, the current screen is locked and the\n\t * next nagivation interrupted.\n\t */\n\tbeforeDeactivate() {\n\t\tconsole.log('Screen [' + this + '] beforeDeactivate');\n\t}\n\n\t/**\n\t * Gives the Screen a chance format the path before history update.\n\t * @path {!string} path Navigation path.\n\t * @return {!string} Navigation path to use on history.\n\t */\n\tbeforeUpdateHistoryPath(path) {\n\t\treturn path;\n\t}\n\n\t/**\n\t * Gives the Screen a chance format the state before history update.\n\t * @path {!object} state History state.\n\t * @return {!object} History state to use on history.\n\t */\n\tbeforeUpdateHistoryState(state) {\n\t\treturn state;\n\t}\n\n\t/**\n\t * Allows a screen to do any cleanup necessary after it has been\n\t * deactivated, for example cancelling outstanding requests or stopping\n\t * timers. Lifecycle.\n\t */\n\tdeactivate() {\n\t\tconsole.log('Screen [' + this + '] deactivate');\n\t}\n\n\t/**\n\t * Dispose a screen, either after it is deactivated (in the case of a\n\t * non-cacheable view) or when the App is itself disposed for whatever\n\t * reason. Lifecycle.\n\t */\n\tdisposeInternal() {\n\t\tsuper.disposeInternal();\n\t\tconsole.log('Screen [' + this + '] dispose');\n\t}\n\n\t/**\n\t * Allows a screen to evaluate scripts before the element is made visible.\n\t * Lifecycle.\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t * @return {?CancellablePromise=} This can return a promise, which will\n\t * pause the navigation until it is resolved.\n\t */\n\tevaluateScripts(surfaces) {\n\t\tObject.keys(surfaces).forEach(sId => {\n\t\t\tif (surfaces[sId].activeChild) {\n\t\t\t\tglobalEval.runScriptsInElement(surfaces[sId].activeChild);\n\t\t\t}\n\t\t});\n\t\treturn CancellablePromise.resolve();\n\t}\n\n\t/**\n\t * Allows a screen to evaluate styles before the element is made visible.\n\t * Lifecycle.\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t * @return {?CancellablePromise=} This can return a promise, which will\n\t * pause the navigation until it is resolved.\n\t */\n\tevaluateStyles() {\n\t\treturn CancellablePromise.resolve();\n\t}\n\n\t/**\n\t * Allows a screen to perform any setup immediately before the element is\n\t * made visible. Lifecycle.\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t * @return {?CancellablePromise=} This can return a promise, which will pause the\n\t * navigation until it is resolved.\n\t */\n\tflip(surfaces) {\n\t\tconsole.log('Screen [' + this + '] flip');\n\n\t\tvar transitions = [];\n\n\t\tObject.keys(surfaces).forEach(sId => {\n\t\t\tvar surface = surfaces[sId];\n\t\t\tvar deferred = surface.show(this.id);\n\t\t\ttransitions.push(deferred);\n\t\t});\n\n\t\treturn CancellablePromise.all(transitions);\n\t}\n\n\t/**\n\t * Gets the screen id.\n\t * @return {string}\n\t */\n\tgetId() {\n\t\treturn this.id;\n\t}\n\n\t/**\n\t * Returns the content for the given surface, or null if the surface isn't\n\t * used by this screen. This will be called when a screen is initially\n\t * constructed or, if a screen is non-cacheable, when navigated.\n\t * @param {!string} surfaceId The id of the surface DOM element.\n\t * @return {?string|Element=} This can return a string or node representing\n\t * the content of the surface. If returns falsy values surface default\n\t * content is restored.\n\t */\n\tgetSurfaceContent() {\n\t\tconsole.log('Screen [' + this + '] getSurfaceContent');\n\t}\n\n\t/**\n\t * Gets the screen title.\n\t * @return {?string=}\n\t */\n\tgetTitle() {\n\t\treturn this.title;\n\t}\n\n\t/**\n\t * Returns all contents for the surfaces. This will pass the loaded content\n\t * to <code>Screen.load</code> with all information you\n\t * need to fulfill the surfaces. Lifecycle.\n\t * @param {!string=} path The requested path.\n\t * @return {!CancellablePromise} This can return a string representing the\n\t * contents of the surfaces or a promise, which will pause the navigation\n\t * until it is resolved. This is useful for loading async content.\n\t */\n\tload() {\n\t\tconsole.log('Screen [' + this + '] load');\n\t\treturn CancellablePromise.resolve();\n\t}\n\n\t/**\n\t * Makes the id for the screen.\n\t * @param {!string} id The screen id the content belongs too.\n\t * @return {string}\n\t * @private\n\t */\n\tmakeId_(id) {\n\t\treturn 'screen_' + id;\n\t}\n\n\t/**\n\t * Sets the screen id.\n\t * @param {!string} id\n\t */\n\tsetId(id) {\n\t\tthis.id = id;\n\t}\n\n\t/**\n\t * Sets the screen title.\n\t * @param {?string=} title\n\t */\n\tsetTitle(title) {\n\t\tthis.title = title;\n\t}\n\n\t/**\n\t * @return {string}\n\t */\n\ttoString() {\n\t\treturn this.id;\n\t}\n\n}\n\n/**\n * @param {*} object\n * @return {boolean} Whether a given instance implements\n * <code>Screen</code>.\n */\nScreen.isImplementedBy = function(object) {\n\treturn object instanceof Screen;\n};\n\nexport default Screen;\n","'use strict';\n\nimport globals from '../globals/globals';\nimport { core, Disposable } from 'metal';\nimport dom from 'metal-dom';\nimport CancellablePromise from 'metal-promise';\n\nclass Surface extends Disposable {\n\n\t/**\n\t * Surface class representing the references to elements on the page that\n\t * can potentially be updated by <code>App</code>.\n\t * @param {string} id\n\t * @constructor\n\t */\n\tconstructor(id) {\n\t\tsuper();\n\n\t\tif (!id) {\n\t\t\tthrow new Error('Surface element id not specified. A surface element requires a valid id.');\n\t\t}\n\n\t\t/**\n\t\t * Holds the active child element.\n\t\t * @type {Element}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.activeChild = null;\n\n\t\t/**\n\t\t * Holds the default child element.\n\t\t * @type {Element}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.defaultChild = null;\n\n\t\t/**\n\t\t * Holds the element with the specified surface id, if not found creates a\n\t\t * new element with the specified id.\n\t\t * @type {Element}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.element = null;\n\n\t\t/**\n\t\t * Holds the surface id.\n\t\t * @type {String}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.id = id;\n\n\t\t/**\n\t\t * Holds the default transitionFn for the surfaces.\n\t\t * @param {?Element=} from The visible surface element.\n\t\t * @param {?Element=} to The surface element to be flipped.\n\t\t * @default null\n\t\t */\n\t\tthis.transitionFn = null;\n\n\t\tthis.defaultChild = this.getChild(Surface.DEFAULT);\n\t\tthis.maybeWrapContentAsDefault_();\n\t\tthis.activeChild = this.defaultChild;\n\t}\n\n\t/**\n\t * Adds screen content to a surface. If content hasn't been passed, see if\n\t * an element exists in the DOM that matches the id. By convention, the\n\t * element should already be nested in the right element and should have an\n\t * id that is a concatentation of the surface id + '-' + the screen id.\n\t * @param {!string} screenId The screen id the content belongs too.\n\t * @param {?string|Element=} opt_content The string content or element to\n\t * add be added as surface content.\n\t * @return {Element}\n\t */\n\taddContent(screenId, opt_content) {\n\t\tvar child = this.defaultChild;\n\n\t\tif (core.isDefAndNotNull(opt_content)) {\n\t\t\tchild = this.getChild(screenId);\n\t\t\tif (child) {\n\t\t\t\tdom.removeChildren(child);\n\t\t\t} else {\n\t\t\t\tchild = this.createChild(screenId);\n\t\t\t\tthis.transition(child, null);\n\t\t\t}\n\t\t\tdom.append(child, opt_content);\n\t\t}\n\n\t\tvar element = this.getElement();\n\n\t\tif (element && child) {\n\t\t\tdom.append(element, child);\n\t\t}\n\n\t\treturn child;\n\t}\n\n\t/**\n\t * Creates child node for the surface.\n\t * @param {!string} screenId The screen id.\n\t * @return {Element}\n\t */\n\tcreateChild(screenId) {\n\t\tvar child = globals.document.createElement('div');\n\t\tchild.setAttribute('id', this.makeId_(screenId));\n\t\treturn child;\n\t}\n\n\t/**\n\t * Gets child node of the surface.\n\t * @param {!string} screenId The screen id.\n\t * @return {?Element}\n\t */\n\tgetChild(screenId) {\n\t\treturn globals.document.getElementById(this.makeId_(screenId));\n\t}\n\n\t/**\n\t * Gets the surface element from element, and sets it to the el property of\n\t * the current instance.\n\t * <code>this.element</code> will be used.\n\t * @return {?Element} The current surface element.\n\t */\n\tgetElement() {\n\t\tif (this.element) {\n\t\t\treturn this.element;\n\t\t}\n\t\tthis.element = globals.document.getElementById(this.id);\n\t\treturn this.element;\n\t}\n\n\t/**\n\t * Gets the surface id.\n\t * @return {String}\n\t */\n\tgetId() {\n\t\treturn this.id;\n\t}\n\n\t/**\n\t * Gets the surface transition function.\n\t * See <code>Surface.defaultTransition</code>.\n\t * @return {?Function=} The transition function.\n\t */\n\tgetTransitionFn() {\n\t\treturn this.transitionFn;\n\t}\n\n\t/**\n\t * Makes the id for the element that holds content for a screen.\n\t * @param {!string} screenId The screen id the content belongs too.\n\t * @return {String}\n\t * @private\n\t */\n\tmakeId_(screenId) {\n\t\treturn this.id + '-' + screenId;\n\t}\n\n\t/**\n\t * If default child is missing, wraps surface content as default child. If\n\t * surface have static content, make sure to place a\n\t * <code>surfaceId-default</code> element inside surface, only contents\n\t * inside the default child will be replaced by navigation.\n\t */\n\tmaybeWrapContentAsDefault_() {\n\t\tvar element = this.getElement();\n\t\tif (element && !this.defaultChild) {\n\t\t\tvar fragment = globals.document.createDocumentFragment();\n\t\t\twhile (element.firstChild) {\n\t\t\t\tfragment.appendChild(element.firstChild);\n\t\t\t}\n\t\t\tthis.defaultChild = this.addContent(Surface.DEFAULT, fragment);\n\t\t\tthis.transition(null, this.defaultChild);\n\t\t}\n\t}\n\n\t/**\n\t * Sets the surface id.\n\t * @param {!string} id\n\t */\n\tsetId(id) {\n\t\tthis.id = id;\n\t}\n\n\t/**\n\t * Sets the surface transition function.\n\t * See <code>Surface.defaultTransition</code>.\n\t * @param {?Function=} transitionFn The transition function.\n\t */\n\tsetTransitionFn(transitionFn) {\n\t\tthis.transitionFn = transitionFn;\n\t}\n\n\t/**\n\t * Shows screen content from a surface.\n\t * @param {String} screenId The screen id to show.\n\t * @return {CancellablePromise} Pauses the navigation until it is resolved.\n\t */\n\tshow(screenId) {\n\t\tvar from = this.activeChild;\n\t\tvar to = this.getChild(screenId);\n\t\tif (!to) {\n\t\t\tto = this.defaultChild;\n\t\t}\n\t\tthis.activeChild = to;\n\t\treturn this.transition(from, to).thenAlways(() => {\n\t\t\tif (from && from !== to) {\n\t\t\t\tdom.exitDocument(from);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Removes screen content from a surface.\n\t * @param {!string} screenId The screen id to remove.\n\t */\n\tremove(screenId) {\n\t\tvar child = this.getChild(screenId);\n\t\tif (child) {\n\t\t\tdom.exitDocument(child);\n\t\t}\n\t}\n\n\t/**\n\t * @return {String}\n\t */\n\ttoString() {\n\t\treturn this.id;\n\t}\n\n\t/**\n\t * Invokes the transition function specified on <code>transition</code> attribute.\n\t * @param {?Element=} from\n\t * @param {?Element=} to\n\t * @return {?CancellablePromise=} This can return a promise, which will pause the\n\t * navigation until it is resolved.\n\t */\n\ttransition(from, to) {\n\t\tvar transitionFn = this.transitionFn || Surface.defaultTransition;\n\t\treturn CancellablePromise.resolve(transitionFn.call(this, from, to));\n\t}\n\n}\n\n/**\n * Holds the default surface name. Elements on the page must contain a child\n * element containing the default content, this element must be as following:\n *\n * Example:\n * <code>\n * <div id=\"mysurface\">\n * <div id=\"mysurface-default\">Default surface content.</div>\n * </div>\n * </code>\n *\n * The default content is relevant for the initial page content. When a\n * screen doesn't provide content for the surface the default content is\n * restored into the page.\n *\n * @type {!String}\n * @default default\n * @static\n */\nSurface.DEFAULT = 'default';\n\n/**\n * Holds the default transition for all surfaces. Each surface could have its\n * own transition.\n *\n * Example:\n *\n * <code>\n * surface.setTransitionFn(function(from, to) {\n * if (from) {\n * from.style.display = 'none';\n * from.classList.remove('flipped');\n * }\n * if (to) {\n * to.style.display = 'block';\n * to.classList.add('flipped');\n * }\n * return null;\n * });\n * </code>\n *\n * @param {?Element=} from The visible surface element.\n * @param {?Element=} to The surface element to be flipped.\n * @static\n */\nSurface.defaultTransition = function(from, to) {\n\tif (from) {\n\t\tfrom.style.display = 'none';\n\t\tfrom.classList.remove('flipped');\n\t}\n\tif (to) {\n\t\tto.style.display = 'block';\n\t\tto.classList.add('flipped');\n\t}\n};\n\nexport default Surface;\n","'use strict';\n\nimport { array, async, core } from 'metal';\nimport debounce from 'metal-debounce';\nimport dom from 'metal-dom';\nimport CancellablePromise from 'metal-promise';\nimport { EventEmitter, EventHandler } from 'metal-events';\nimport utils from '../utils/utils';\nimport globals from '../globals/globals';\nimport Route from '../route/Route';\nimport Screen from '../screen/Screen';\nimport Surface from '../surface/Surface';\nimport Uri from 'metal-uri';\n\nclass App extends EventEmitter {\n\n\t/**\n\t * App class that handle routes and screens lifecycle.\n\t * @constructor\n\t * @extends {EventEmitter}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the active screen.\n\t\t * @type {?Screen}\n\t\t * @protected\n\t\t */\n\t\tthis.activeScreen = null;\n\n\t\t/**\n\t\t * Holds the active path containing the query parameters.\n\t\t * @type {?string}\n\t\t * @protected\n\t\t */\n\t\tthis.activePath = null;\n\n\t\t/**\n\t\t * Allows prevent navigate from dom prevented event.\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.allowPreventNavigate = true;\n\n\t\t/**\n\t\t * Holds link base path.\n\t\t * @type {!string}\n\t\t * @default ''\n\t\t * @protected\n\t\t */\n\t\tthis.basePath = '';\n\n\t\t/**\n\t\t * Captures scroll position from scroll event.\n\t\t * @type {!boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.captureScrollPositionFromScrollEvent = true;\n\n\t\t/**\n\t\t * Holds the default page title.\n\t\t * @type {string}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.defaultTitle = globals.document.title;\n\n\t\t/**\n\t\t * Holds the form selector to define forms that are routed.\n\t\t * @type {!string}\n\t\t * @default form[enctype=\"multipart/form-data\"]:not([data-senna-off])\n\t\t * @protected\n\t\t */\n\t\tthis.formSelector = 'form[enctype=\"multipart/form-data\"]:not([data-senna-off])';\n\n\t\t/**\n\t\t * Holds the link selector to define links that are routed.\n\t\t * @type {!string}\n\t\t * @default a:not([data-senna-off])\n\t\t * @protected\n\t\t */\n\t\tthis.linkSelector = 'a:not([data-senna-off])';\n\n\t\t/**\n\t\t * Holds the loading css class.\n\t\t * @type {!string}\n\t\t * @default senna-loading\n\t\t * @protected\n\t\t */\n\t\tthis.loadingCssClass = 'senna-loading';\n\n\t\t/**\n\t\t * Using the History API to manage your URLs is awesome and, as it happens,\n\t\t * a crucial feature of good web apps. One of its downsides, however, is\n\t\t * that scroll positions are stored and then, more importantly, restored\n\t\t * whenever you traverse the history. This often means unsightly jumps as\n\t\t * the scroll position changes automatically, and especially so if your app\n\t\t * does transitions, or changes the contents of the page in any way.\n\t\t * Ultimately this leads to an horrible user experience. The good news is,\n\t\t * however, that there’s a potential fix: history.scrollRestoration.\n\t\t * https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration\n\t\t * @type {boolean}\n\t\t * @protected\n\t\t */\n\t\tthis.nativeScrollRestorationSupported = ('scrollRestoration' in globals.window.history);\n\n\t\t/**\n\t\t * Holds a deferred with the current navigation.\n\t\t * @type {?CancellablePromise}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.pendingNavigate = null;\n\n\t\t/**\n\t\t * Holds the window horizontal scroll position when the navigation using\n\t\t * back or forward happens to be restored after the surfaces are updated.\n\t\t * @type {!Number}\n\t\t * @default 0\n\t\t * @protected\n\t\t */\n\t\tthis.popstateScrollLeft = 0;\n\n\t\t/**\n\t\t * Holds the window vertical scroll position when the navigation using\n\t\t * back or forward happens to be restored after the surfaces are updated.\n\t\t * @type {!Number}\n\t\t * @default 0\n\t\t * @protected\n\t\t */\n\t\tthis.popstateScrollTop = 0;\n\n\t\t/**\n\t\t * Holds the redirect path containing the query parameters.\n\t\t * @type {?string}\n\t\t * @protected\n\t\t */\n\t\tthis.redirectPath = null;\n\n\t\t/**\n\t\t * Holds the screen routes configuration.\n\t\t * @type {?Array}\n\t\t * @default []\n\t\t * @protected\n\t\t */\n\t\tthis.routes = [];\n\n\t\t/**\n\t\t * Maps the screen instances by the url containing the parameters.\n\t\t * @type {?Object}\n\t\t * @default {}\n\t\t * @protected\n\t\t */\n\t\tthis.screens = {};\n\n\t\t/**\n\t\t * When set to true the first erroneous popstate fired on page load will be\n\t\t * ignored, only if <code>globals.window.history.state</code> is also\n\t\t * <code>null</code>.\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t * @protected\n\t\t */\n\t\tthis.skipLoadPopstate = false;\n\n\t\t/**\n\t\t * Maps that index the surfaces instances by the surface id.\n\t\t * @type {?Object}\n\t\t * @default {}\n\t\t * @protected\n\t\t */\n\t\tthis.surfaces = {};\n\n\t\t/**\n\t\t * When set to true, moves the scroll position after popstate, or to the\n\t\t * top of the viewport for new navigation. If false, the browser will\n\t\t * take care of scroll restoration.\n\t\t * @type {!boolean}\n\t\t * @default true\n\t\t * @protected\n\t\t */\n\t\tthis.updateScrollPosition = true;\n\n\t\tthis.appEventHandlers_ = new EventHandler();\n\n\t\tthis.appEventHandlers_.add(\n\t\t\tdom.on(globals.window, 'scroll', debounce(this.onScroll_.bind(this), 100)),\n\t\t\tdom.on(globals.window, 'load', this.onLoad_.bind(this)),\n\t\t\tdom.on(globals.window, 'popstate', this.onPopstate_.bind(this))\n\t\t);\n\n\t\tthis.on('startNavigate', this.onStartNavigate_);\n\t\tthis.on('beforeNavigate', this.onBeforeNavigate_);\n\t\tthis.on('beforeNavigate', this.onBeforeNavigateDefault_, true);\n\n\t\tthis.setLinkSelector(this.linkSelector);\n\t\tthis.setFormSelector(this.formSelector);\n\t}\n\n\t/**\n\t * Adds one or more screens to the application.\n\t *\n\t * Example:\n\t *\n\t * <code>\n\t * app.addRoutes({ path: '/foo', handler: FooScreen });\n\t * or\n\t * app.addRoutes([{ path: '/foo', handler: function(route) { return new FooScreen(); } }]);\n\t * </code>\n\t *\n\t * @param {Object} or {Array} routes Single object or an array of object.\n\t * Each object should contain <code>path</code> and <code>screen</code>.\n\t * The <code>path</code> should be a string or a regex that maps the\n\t * navigation route to a screen class definition (not an instance), e.g:\n\t * <code>{ path: \"/home:param1\", handler: MyScreen }</code>\n\t * <code>{ path: /foo.+/, handler: MyScreen }</code>\n\t * @chainable\n\t */\n\taddRoutes(routes) {\n\t\tif (!Array.isArray(routes)) {\n\t\t\troutes = [routes];\n\t\t}\n\t\troutes.forEach((route) => {\n\t\t\tif (!(route instanceof Route)) {\n\t\t\t\troute = new Route(route.path, route.handler);\n\t\t\t}\n\t\t\tthis.routes.push(route);\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds one or more surfaces to the application.\n\t * @param {Surface|String|Array.<Surface|String>} surfaces\n\t * Surface element id or surface instance. You can also pass an Array\n\t * whichcontains surface instances or id. In case of ID, these should be\n\t * the id of surface element.\n\t * @chainable\n\t */\n\taddSurfaces(surfaces) {\n\t\tif (!Array.isArray(surfaces)) {\n\t\t\tsurfaces = [surfaces];\n\t\t}\n\t\tsurfaces.forEach((surface) => {\n\t\t\tif (core.isString(surface)) {\n\t\t\t\tsurface = new Surface(surface);\n\t\t\t}\n\t\t\tthis.surfaces[surface.getId()] = surface;\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns if can navigate to path.\n\t * @param {!string} url\n\t * @return {boolean}\n\t */\n\tcanNavigate(url) {\n\t\tvar path = utils.getUrlPath(url);\n\t\tvar uri = new Uri(url);\n\n\t\tif (!this.isLinkSameOrigin_(uri.getHostname())) {\n\t\t\tconsole.log('Offsite link clicked');\n\t\t\treturn false;\n\t\t}\n\t\tif (!this.isSameBasePath_(path)) {\n\t\t\tconsole.log('Link clicked outside app\\'s base path');\n\t\t\treturn false;\n\t\t}\n\t\tif (!this.findRoute(path)) {\n\t\t\tconsole.log('No route for ' + path);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Clear screens cache.\n\t * @chainable\n\t */\n\tclearScreensCache() {\n\t\tObject.keys(this.screens).forEach((path) => {\n\t\t\tif (path === this.activePath) {\n\t\t\t\tthis.activeScreen.clearCache();\n\t\t\t} else {\n\t\t\t\tthis.removeScreen(path);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves or create a screen instance to a path.\n\t * @param {!string} path Path containing the querystring part.\n\t * @return {Screen}\n\t */\n\tcreateScreenInstance(path, route) {\n\t\tif (!this.pendingNavigate && path === this.activePath) {\n\t\t\tconsole.log('Already at destination, refresh navigation');\n\t\t\treturn this.activeScreen;\n\t\t}\n\t\t/* jshint newcap: false */\n\t\tvar screen = this.screens[path];\n\t\tif (!screen) {\n\t\t\tvar handler = route.getHandler();\n\t\t\tif (handler === Screen || Screen.isImplementedBy(handler.prototype)) {\n\t\t\t\tscreen = new handler();\n\t\t\t} else {\n\t\t\t\tscreen = handler(route) || new Screen();\n\t\t\t}\n\t\t\tconsole.log('Create screen for [' + path + '] [' + screen + ']');\n\t\t}\n\t\treturn screen;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdisposeInternal() {\n\t\tif (this.activeScreen) {\n\t\t\tthis.removeScreen(this.activePath);\n\t\t}\n\t\tthis.clearScreensCache();\n\t\tthis.formEventHandler_.removeListener();\n\t\tthis.linkEventHandler_.removeListener();\n\t\tthis.appEventHandlers_.removeAllListeners();\n\t\tsuper.disposeInternal();\n\t}\n\n\t/**\n\t * Dispatches to the first route handler that matches the current path, if\n\t * any.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tdispatch() {\n\t\treturn this.navigate(utils.getCurrentBrowserPath(), true);\n\t}\n\n\t/**\n\t * Starts navigation to a path.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tdoNavigate_(path, opt_replaceHistory) {\n\t\tif (this.activeScreen && this.activeScreen.beforeDeactivate()) {\n\t\t\tthis.pendingNavigate = CancellablePromise.reject(new CancellablePromise.CancellationError('Cancelled by active screen'));\n\t\t\treturn this.pendingNavigate;\n\t\t}\n\n\t\tvar route = this.findRoute(path);\n\t\tif (!route) {\n\t\t\tthis.pendingNavigate = CancellablePromise.reject(new CancellablePromise.CancellationError('No route for ' + path));\n\t\t\treturn this.pendingNavigate;\n\t\t}\n\n\t\tconsole.log('Navigate to [' + path + ']');\n\n\t\tthis.stopPendingNavigate_();\n\n\t\tvar nextScreen = this.createScreenInstance(path, route);\n\n\t\treturn nextScreen.load(path)\n\t\t\t.then(() => {\n\t\t\t\tif (this.activeScreen) {\n\t\t\t\t\tthis.activeScreen.deactivate();\n\t\t\t\t}\n\t\t\t\tthis.prepareNavigateHistory_(path, nextScreen, opt_replaceHistory);\n\t\t\t\tthis.prepareNavigateSurfaces_(nextScreen, this.surfaces);\n\t\t\t})\n\t\t\t.then(() => nextScreen.evaluateStyles(this.surfaces))\n\t\t\t.then(() => nextScreen.flip(this.surfaces))\n\t\t\t.then(() => nextScreen.evaluateScripts(this.surfaces))\n\t\t\t.then(() => this.syncScrollPositionSyncThenAsync_())\n\t\t\t.then(() => this.finalizeNavigate_(path, nextScreen))\n\t\t\t.catch((reason) => {\n\t\t\t\tthis.handleNavigateError_(path, nextScreen, reason);\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * Finalizes a screen navigation.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @protected\n\t */\n\tfinalizeNavigate_(path, nextScreen) {\n\t\tnextScreen.activate();\n\n\t\tif (this.activeScreen && !this.activeScreen.isCacheable()) {\n\t\t\tif (this.activeScreen !== nextScreen) {\n\t\t\t\tthis.removeScreen(this.activePath);\n\t\t\t}\n\t\t}\n\n\t\tthis.activePath = path;\n\t\tthis.activeScreen = nextScreen;\n\t\tthis.screens[path] = nextScreen;\n\t\tthis.pendingNavigate = null;\n\t\tglobals.capturedFormElement = null;\n\t\tconsole.log('Navigation done');\n\t}\n\n\t/**\n\t * Finds a route for the test path. Returns true if matches has a route,\n\t * otherwise returns null.\n\t * @param {!string} path Path containing the querystring part.\n\t * @return {?Object} Route handler if match any or <code>null</code> if the\n\t * path is the same as the current url and the path contains a fragment.\n\t */\n\tfindRoute(path) {\n\t\t// Prevents navigation if it's a hash change on the same url.\n\t\tif ((path.lastIndexOf('#') > -1) && utils.isCurrentBrowserPath(path)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tpath = utils.getUrlPathWithoutHash(path);\n\n\t\t// Makes sure that the path substring will be in the expected format\n\t\t// (that is, will end with a \"/\").\n\t\tpath = utils.getUrlPathWithoutHash(path.substr(this.basePath.length));\n\n\t\tfor (var i = 0; i < this.routes.length; i++) {\n\t\t\tvar route = this.routes[i];\n\t\t\tif (route.matchesPath(path)) {\n\t\t\t\treturn route;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets allow prevent navigate.\n\t * @return {boolean}\n\t */\n\tgetAllowPreventNavigate() {\n\t\treturn this.allowPreventNavigate;\n\t}\n\n\t/**\n\t * Gets link base path.\n\t * @return {!string}\n\t */\n\tgetBasePath() {\n\t\treturn this.basePath;\n\t}\n\n\t/**\n\t * Gets the default page title.\n\t * @return {string} defaultTitle\n\t */\n\tgetDefaultTitle() {\n\t\treturn this.defaultTitle;\n\t}\n\n\t/**\n\t * Gets the form selector.\n\t * @return {!string}\n\t */\n\tgetFormSelector() {\n\t\treturn this.formSelector;\n\t}\n\n\t/**\n\t * Gets the link selector.\n\t * @return {!string}\n\t */\n\tgetLinkSelector() {\n\t\treturn this.linkSelector;\n\t}\n\n\t/**\n\t * Gets the loading css class.\n\t * @return {!string}\n\t */\n\tgetLoadingCssClass() {\n\t\treturn this.loadingCssClass;\n\t}\n\n\t/**\n\t * Gets the update scroll position value.\n\t * @return {boolean}\n\t */\n\tgetUpdateScrollPosition() {\n\t\treturn this.updateScrollPosition;\n\t}\n\n\t/**\n\t * Handle navigation error.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @param {!Error} error\n\t * @protected\n\t */\n\thandleNavigateError_(path, nextScreen, err) {\n\t\tconsole.log('Navigation error for [' + nextScreen + '] (' + err + ')');\n\t\tif (!utils.isCurrentBrowserPath(path)) {\n\t\t\t if (this.pendingNavigate) {\n\t\t\t \tthis.pendingNavigate.thenAlways(() => this.removeScreen(path), this);\n\t\t \t}\n\t\t \telse {\n\t\t \t\tthis.removeScreen(path);\n\t\t \t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if app has routes.\n\t * @return {boolean}\n\t */\n\thasRoutes() {\n\t\treturn this.routes.length > 0;\n\t}\n\n\t/**\n\t * Tests if hostname is an offsite link.\n\t * @param {!string} hostname Link hostname to compare with\n\t * <code>globals.window.location.hostname</code>.\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisLinkSameOrigin_(hostname) {\n\t\treturn hostname === globals.window.location.hostname;\n\t}\n\n\t/**\n\t * Tests if link element has the same app's base path.\n\t * @param {!string} path Link path containing the querystring part.\n\t * @return {boolean}\n\t * @protected\n\t */\n\tisSameBasePath_(path) {\n\t\treturn path.indexOf(this.basePath) === 0;\n\t}\n\n\t/**\n\t * Lock the document scroll in order to avoid the browser native back and\n\t * forward navigation to change the scroll position. In the end of\n\t * navigation lifecycle scroll is repositioned.\n\t * @protected\n\t */\n\tlockHistoryScrollPosition_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\t\t// Browsers are inconsistent when re-positioning the scroll history on\n\t\t// popstate. At some browsers, history scroll happens before popstate, then\n\t\t// lock the scroll on the last known position as soon as possible after the\n\t\t// current JS execution context and capture the current value. Some others,\n\t\t// history scroll happens after popstate, in this case, we bind an once\n\t\t// scroll event to lock the las known position. Lastly, the previous two\n\t\t// behaviors can happen even on the same browser, hence the race will decide\n\t\t// the winner.\n\t\tvar winner = false;\n\t\tvar switchScrollPositionRace = function() {\n\t\t\tglobals.document.removeEventListener('scroll', switchScrollPositionRace, false);\n\t\t\tif (!winner) {\n\t\t\t\tglobals.window.scrollTo(state.scrollLeft, state.scrollTop);\n\t\t\t\twinner = true;\n\t\t\t}\n\t\t};\n\t\tasync.nextTick(switchScrollPositionRace);\n\t\tglobals.document.addEventListener('scroll', switchScrollPositionRace, false);\n\t}\n\n\t/**\n\t * If supported by the browser, disables native scroll restoration and\n\t * stores current value.\n\t */\n\tmaybeDisableNativeScrollRestoration() {\n\t\tif (this.nativeScrollRestorationSupported) {\n\t\t\tthis.nativeScrollRestoration_ = globals.window.history.scrollRestoration;\n\t\t\tglobals.window.history.scrollRestoration = 'manual';\n\t\t}\n\t}\n\n\t/**\n\t * Maybe navigate to a path.\n\t * @param {string} href Information about the link's href.\n\t * @param {Event} event Dom event that initiated the navigation.\n\t */\n\tmaybeNavigate_(href, event) {\n\t\tif (!this.canNavigate(href)) {\n\t\t\treturn;\n\t\t}\n\n\t\tglobals.capturedFormElement = event.capturedFormElement;\n\n\t\tvar navigateFailed = false;\n\t\ttry {\n\t\t\tthis.navigate(utils.getUrlPath(href));\n\t\t} catch (err) {\n\t\t\t// Do not prevent link navigation in case some synchronous error occurs\n\t\t\tnavigateFailed = true;\n\t\t}\n\n\t\tif (!navigateFailed) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\t/**\n\t * Maybe reposition scroll to hashed anchor.\n\t */\n\tmaybeRepositionScrollToHashedAnchor() {\n\t\tvar hash = globals.window.location.hash;\n\t\tif (hash) {\n\t\t\tvar anchorElement = globals.document.getElementById(hash.substring(1));\n\t\t\tif (anchorElement) {\n\t\t\t\tglobals.window.scrollTo(anchorElement.offsetLeft, anchorElement.offsetTop);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * If supported by the browser, restores native scroll restoration to the\n\t * value captured by `maybeDisableNativeScrollRestoration`.\n\t */\n\tmaybeRestoreNativeScrollRestoration() {\n\t\tif (this.nativeScrollRestorationSupported && this.nativeScrollRestoration_) {\n\t\t\tglobals.window.history.scrollRestoration = this.nativeScrollRestoration_;\n\t\t}\n\t}\n\n\t/**\n\t * Navigates to the specified path if there is a route handler that matches.\n\t * @param {!string} path Path to navigate containing the base path.\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tnavigate(path, opt_replaceHistory) {\n\t\tif (!utils.isHtml5HistorySupported()) {\n\t\t\tthrow new Error('HTML5 History is not supported. Senna will not intercept navigation.');\n\t\t}\n\n\t\t// When reloading the same path do replaceState instead of pushState to\n\t\t// avoid polluting history with states with the same path.\n\t\tif (path === this.activePath) {\n\t\t\topt_replaceHistory = true;\n\t\t}\n\n\t\tthis.emit('beforeNavigate', {\n\t\t\tpath: path,\n\t\t\treplaceHistory: !!opt_replaceHistory\n\t\t});\n\n\t\treturn this.pendingNavigate;\n\t}\n\n\t/**\n\t * Befores navigation to a path.\n\t * @param {!Event} event Event facade containing <code>path</code> and\n\t * <code>replaceHistory</code>.\n\t * @protected\n\t */\n\tonBeforeNavigate_(event) {\n\t\tif (globals.capturedFormElement) {\n\t\t\tevent.form = globals.capturedFormElement;\n\t\t}\n\t}\n\n\t/**\n\t * Befores navigation to a path. Runs after external listeners.\n\t * @param {!Event} event Event facade containing <code>path</code> and\n\t * <code>replaceHistory</code>.\n\t * @protected\n\t */\n\tonBeforeNavigateDefault_(event) {\n\t\tif (this.pendingNavigate) {\n\t\t\tif (this.pendingNavigate.path === event.path) {\n\t\t\t\tconsole.log('Waiting...');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tthis.emit('startNavigate', {\n\t\t\tform: event.form,\n\t\t\tpath: event.path,\n\t\t\treplaceHistory: event.replaceHistory\n\t\t});\n\t}\n\n\t/**\n\t * Intercepts document clicks and test link elements in order to decide\n\t * whether Surface app can navigate.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonDocClickDelegate_(event) {\n\t\tif (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || event.button) {\n\t\t\tconsole.log('Navigate aborted, invalid mouse button or modifier key pressed.');\n\t\t\treturn;\n\t\t}\n\t\tthis.maybeNavigate_(event.delegateTarget.href, event);\n\t}\n\n\t/**\n\t * Intercepts document form submits and test action path in order to decide\n\t * whether Surface app can navigate.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonDocSubmitDelegate_(event) {\n\t\tvar form = event.delegateTarget;\n\t\tif (form.method === 'get') {\n\t\t\tconsole.log('GET method not supported');\n\t\t\treturn;\n\t\t}\n\t\tevent.capturedFormElement = form;\n\t\tthis.maybeNavigate_(form.action, event);\n\t}\n\n\t/**\n\t * Listens to the window's load event in order to avoid issues with some browsers\n\t * that trigger popstate calls on the first load. For more information see\n\t * http://stackoverflow.com/questions/6421769/popstate-on-pages-load-in-chrome.\n\t * @protected\n\t */\n\tonLoad_() {\n\t\tthis.skipLoadPopstate = true;\n\t\tsetTimeout(() => {\n\t\t\t// The timeout ensures that popstate events will be unblocked right\n\t\t\t// after the load event occured, but not in the same event-loop cycle.\n\t\t\tthis.skipLoadPopstate = false;\n\t\t}, 0);\n\t\t// Try to reposition scroll to the hashed anchor when page loads.\n\t\tthis.maybeRepositionScrollToHashedAnchor();\n\t}\n\n\t/**\n\t * Handles browser history changes and fires app's navigation if the state\n\t * belows to us. If we detect a popstate and the state is <code>null</code>,\n\t * assume it is navigating to an external page or to a page we don't have\n\t * route, then <code>globals.window.location.reload()</code> is invoked in order to\n\t * reload the content to the current url.\n\t * @param {!Event} event Event facade\n\t * @protected\n\t */\n\tonPopstate_(event) {\n\t\tif (this.skipLoadPopstate) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar state = event.state;\n\n\t\tif (!state) {\n\t\t\tif (globals.window.location.hash) {\n\t\t\t\t// If senna is on an redirect path and a hash popstate happens\n\t\t\t\t// to a different url, reload the browser. This behavior doesn't\n\t\t\t\t// require senna to route hashed links and is closer to native\n\t\t\t\t// browser behavior.\n\t\t\t\tif (this.redirectPath && !utils.isCurrentBrowserPath(this.redirectPath)) {\n\t\t\t\t\tthis.reloadPage();\n\t\t\t\t}\n\t\t\t\t// Always try to reposition scroll to the hashed anchor when\n\t\t\t\t// hash popstate happens.\n\t\t\t\tthis.maybeRepositionScrollToHashedAnchor();\n\t\t\t} else {\n\t\t\t\tthis.reloadPage();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (state.senna) {\n\t\t\tconsole.log('History navigation to [' + state.path + ']');\n\t\t\tthis.popstateScrollTop = state.scrollTop;\n\t\t\tthis.popstateScrollLeft = state.scrollLeft;\n\t\t\tif (!this.nativeScrollRestorationSupported) {\n\t\t\t\tthis.lockHistoryScrollPosition_();\n\t\t\t}\n\t\t\tthis.navigate(state.path, true);\n\t\t}\n\t}\n\n\t/**\n\t * Listens document scroll changes in order to capture the possible lock\n\t * scroll position for history scrolling.\n\t * @protected\n\t */\n\tonScroll_() {\n\t\tif (this.captureScrollPositionFromScrollEvent) {\n\t\t\tthis.saveHistoryCurrentPageScrollPosition_();\n\t\t}\n\t}\n\n\t/**\n\t * Starts navigation to a path.\n\t * @param {!Event} event Event facade containing <code>path</code> and\n\t * <code>replaceHistory</code>.\n\t * @protected\n\t */\n\tonStartNavigate_(event) {\n\t\tthis.maybeDisableNativeScrollRestoration();\n\t\tthis.captureScrollPositionFromScrollEvent = false;\n\t\tdom.addClasses(globals.document.documentElement, this.loadingCssClass);\n\n\t\tvar endNavigatePayload = {\n\t\t\tform: event.form,\n\t\t\tpath: event.path\n\t\t};\n\n\t\tthis.pendingNavigate = this.doNavigate_(event.path, event.replaceHistory)\n\t\t\t.catch((reason) => {\n\t\t\t\tendNavigatePayload.error = reason;\n\t\t\t\tthrow reason;\n\t\t\t})\n\t\t\t.thenAlways(() => {\n\t\t\t\tif (!this.pendingNavigate) {\n\t\t\t\t\tdom.removeClasses(globals.document.documentElement, this.loadingCssClass);\n\t\t\t\t\tthis.maybeRestoreNativeScrollRestoration();\n\t\t\t\t\tthis.captureScrollPositionFromScrollEvent = true;\n\t\t\t\t}\n\t\t\t\tthis.emit('endNavigate', endNavigatePayload);\n\t\t\t});\n\n\t\tthis.pendingNavigate.path = event.path;\n\t}\n\n\t/**\n\t * Prefetches the specified path if there is a route handler that matches.\n\t * @param {!string} path Path to navigate containing the base path.\n\t * @return {CancellablePromise} Returns a pending request cancellable promise.\n\t */\n\tprefetch(path) {\n\t\tvar route = this.findRoute(path);\n\t\tif (!route) {\n\t\t\treturn CancellablePromise.reject(new CancellablePromise.CancellationError('No route for ' + path));\n\t\t}\n\n\t\tconsole.log('Prefetching [' + path + ']');\n\n\t\tvar nextScreen = this.createScreenInstance(path, route);\n\n\t\treturn nextScreen.load(path)\n\t\t\t.then(() => this.screens[path] = nextScreen)\n\t\t\t.catch((reason) => {\n\t\t\t\tthis.handleNavigateError_(path, nextScreen, reason);\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * Prepares screen flip. Updates history state and surfaces content.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!Screen} nextScreen\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t */\n\tprepareNavigateHistory_(path, nextScreen, opt_replaceHistory) {\n\t\tvar title = nextScreen.getTitle();\n\t\tif (!core.isString(title)) {\n\t\t\ttitle = this.getDefaultTitle();\n\t\t}\n\t\tvar redirectPath = nextScreen.beforeUpdateHistoryPath(path);\n\t\tvar historyState = {\n\t\t\tform: core.isDefAndNotNull(globals.capturedFormElement),\n\t\t\tredirectPath: redirectPath,\n\t\t\tpath: path,\n\t\t\tsenna: true,\n\t\t\tscrollTop: 0,\n\t\t\tscrollLeft: 0\n\t\t};\n\t\tif (opt_replaceHistory) {\n\t\t\thistoryState.scrollTop = this.popstateScrollTop;\n\t\t\thistoryState.scrollLeft = this.popstateScrollLeft;\n\t\t}\n\t\tthis.updateHistory_(title, redirectPath, nextScreen.beforeUpdateHistoryState(historyState), opt_replaceHistory);\n\t\tthis.redirectPath = redirectPath;\n\t}\n\n\t/**\n\t * Prepares screen flip. Updates history state and surfaces content.\n\t * @param {!Screen} nextScreen\n\t * @param {!object} surfaces Map of surfaces to flip keyed by surface id.\n\t */\n\tprepareNavigateSurfaces_(nextScreen, surfaces) {\n\t\tObject.keys(surfaces).forEach((id) => {\n\t\t\tvar surfaceContent = nextScreen.getSurfaceContent(id);\n\t\t\tsurfaces[id].addContent(nextScreen.getId(), surfaceContent);\n\t\t\tconsole.log('Screen [' + nextScreen.getId() + '] add content to surface ' +\n\t\t\t\t'[' + surfaces[id] + '] [' + (core.isDefAndNotNull(surfaceContent) ? '...' : 'empty') + ']');\n\t\t});\n\t}\n\n\t/**\n\t * Reloads the page by performing `window.location.reload()`.\n\t */\n\treloadPage() {\n\t\tglobals.window.location.reload();\n\t}\n\n\t/**\n\t * Removes route instance from app routes.\n\t * @param {Route} route\n\t * @return {boolean} True if an element was removed.\n\t */\n\tremoveRoute(route) {\n\t\treturn array.remove(this.routes, route);\n\t}\n\n\t/**\n\t * Removes a screen.\n\t * @param {!string} path Path containing the querystring part.\n\t */\n\tremoveScreen(path) {\n\t\tvar screen = this.screens[path];\n\t\tif (screen) {\n\t\t\tObject.keys(this.surfaces).forEach((surfaceId) => this.surfaces[surfaceId].remove(screen.getId()));\n\t\t\tscreen.dispose();\n\t\t\tdelete this.screens[path];\n\t\t}\n\t}\n\n\t/**\n\t * Saves scroll position from page offset into history state.\n\t */\n\tsaveHistoryCurrentPageScrollPosition_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (state && state.senna) {\n\t\t\tstate.scrollTop = globals.window.pageYOffset;\n\t\t\tstate.scrollLeft = globals.window.pageXOffset;\n\t\t\tglobals.window.history.replaceState(state, null, null);\n\t\t}\n\t}\n\n\t/**\n\t * Sets allow prevent navigate.\n\t * @param {boolean} allowPreventNavigate\n\t */\n\tsetAllowPreventNavigate(allowPreventNavigate) {\n\t\tthis.allowPreventNavigate = allowPreventNavigate;\n\t}\n\n\t/**\n\t * Sets link base path.\n\t * @param {!string} path\n\t */\n\tsetBasePath(basePath) {\n\t\tthis.basePath = basePath;\n\t}\n\n\t/**\n\t * Sets the default page title.\n\t * @param {string} defaultTitle\n\t */\n\tsetDefaultTitle(defaultTitle) {\n\t\tthis.defaultTitle = defaultTitle;\n\t}\n\n\t/**\n\t * Sets the form selector.\n\t * @param {!string} formSelector\n\t */\n\tsetFormSelector(formSelector) {\n\t\tthis.formSelector = formSelector;\n\t\tif (this.formEventHandler_) {\n\t\t\tthis.formEventHandler_.removeListener();\n\t\t}\n\t\tthis.formEventHandler_ = dom.delegate(document, 'submit', this.formSelector, this.onDocSubmitDelegate_.bind(this), this.allowPreventNavigate);\n\t}\n\n\t/**\n\t * Sets the link selector.\n\t * @param {!string} linkSelector\n\t */\n\tsetLinkSelector(linkSelector) {\n\t\tthis.linkSelector = linkSelector;\n\t\tif (this.linkEventHandler_) {\n\t\t\tthis.linkEventHandler_.removeListener();\n\t\t}\n\t\tthis.linkEventHandler_ = dom.delegate(document, 'click', this.linkSelector, this.onDocClickDelegate_.bind(this), this.allowPreventNavigate);\n\t}\n\n\t/**\n\t * Sets the loading css class.\n\t * @param {!string} loadingCssClass\n\t */\n\tsetLoadingCssClass(loadingCssClass) {\n\t\tthis.loadingCssClass = loadingCssClass;\n\t}\n\n\t/**\n\t * Sets the update scroll position value.\n\t * @param {boolean} updateScrollPosition\n\t */\n\tsetUpdateScrollPosition(updateScrollPosition) {\n\t\tthis.updateScrollPosition = updateScrollPosition;\n\t}\n\n\t/**\n\t * Cancels pending navigate with <code>Cancel pending navigation</code> error.\n\t * @protected\n\t */\n\tstopPendingNavigate_() {\n\t\tif (this.pendingNavigate) {\n\t\t\tthis.pendingNavigate.cancel('Cancel pending navigation');\n\t\t\tthis.pendingNavigate = null;\n\t\t}\n\t}\n\n\t/**\n\t * Sync document scroll position twice, the first one synchronous and then\n\t * one inside <code>async.nextTick</code>. Relevant to browsers that fires\n\t * scroll restoration asynchronously after popstate.\n\t * @protected\n\t * @return {?CancellablePromise=}\n\t */\n\tsyncScrollPositionSyncThenAsync_() {\n\t\tvar state = globals.window.history.state;\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar scrollTop = state.scrollTop;\n\t\tvar scrollLeft = state.scrollLeft;\n\n\t\tvar sync = () => {\n\t\t\tif (this.updateScrollPosition) {\n\t\t\t\tglobals.window.scrollTo(scrollLeft, scrollTop);\n\t\t\t}\n\t\t};\n\n\t\treturn new CancellablePromise((resolve) => sync() & async.nextTick(() => sync() & resolve()));\n\t}\n\n\t/**\n\t * Updates or replace browser history.\n\t * @param {?string} title Document title.\n\t * @param {!string} path Path containing the querystring part.\n\t * @param {!object} state\n\t * @param {boolean=} opt_replaceHistory Replaces browser history.\n\t * @protected\n\t */\n\tupdateHistory_(title, path, state, opt_replaceHistory) {\n\t\tif (opt_replaceHistory) {\n\t\t\tglobals.window.history.replaceState(state, title, path);\n\t\t} else {\n\t\t\tglobals.window.history.pushState(state, title, path);\n\t\t}\n\t\tglobals.document.title = title;\n\t}\n\n}\n\nexport default App;\n","'use strict';\n\nimport { core } from 'metal';\nimport Uri from 'metal-uri';\nimport { CancellablePromise as Promise } from 'metal-promise';\n\nclass Ajax {\n\n\t/**\n\t * XmlHttpRequest's getAllResponseHeaders() method returns a string of\n\t * response headers according to the format described on the spec:\n\t * {@link http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders-method}.\n\t * This method parses that string into a user-friendly name/value pair\n\t * object.\n\t * @param {string} allHeaders All headers as string.\n\t * @return {!Array.<Object<string, string>>}\n\t */\n\tstatic parseResponseHeaders(allHeaders) {\n\t\tvar headers = [];\n\t\tif (!allHeaders) {\n\t\t\treturn headers;\n\t\t}\n\t\tvar pairs = allHeaders.split('\\u000d\\u000a');\n\t\tfor (var i = 0; i < pairs.length; i++) {\n\t\t\tvar index = pairs[i].indexOf('\\u003a\\u0020');\n\t\t\tif (index > 0) {\n\t\t\t\tvar name = pairs[i].substring(0, index);\n\t\t\t\tvar value = pairs[i].substring(index + 2);\n\t\t\t\theaders.push({\n\t\t\t\t\tname: name,\n\t\t\t\t\tvalue: value\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn headers;\n\t}\n\n\t/**\n\t * Requests the url using XMLHttpRequest.\n\t * @param {!string} url\n\t * @param {!string} method\n\t * @param {?string} body\n\t * @param {MultiMap=} opt_headers\n\t * @param {MultiMap=} opt_params\n\t * @param {number=} opt_timeout\n\t * @param {boolean=} opt_sync\n\t * @param {boolean=} opt_withCredentials\n\t * @return {Promise} Deferred ajax request.\n\t * @protected\n\t */\n\tstatic request(url, method, body, opt_headers, opt_params, opt_timeout, opt_sync, opt_withCredentials) {\n\t\tvar request = new XMLHttpRequest();\n\n\t\tvar promise = new Promise(function(resolve, reject) {\n\t\t\trequest.onload = function() {\n\t\t\t\tif (request.aborted) {\n\t\t\t\t\trequest.onerror();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tresolve(request);\n\t\t\t};\n\t\t\trequest.onerror = function() {\n\t\t\t\tvar error = new Error('Request error');\n\t\t\t\terror.request = request;\n\t\t\t\treject(error);\n\t\t\t};\n\t\t}).thenCatch(function(reason) {\n\t\t\trequest.abort();\n\t\t\tthrow reason;\n\t\t}).thenAlways(function() {\n\t\t\tclearTimeout(timeout);\n\t\t});\n\n\t\tif (opt_params) {\n\t\t\turl = new Uri(url).addParametersFromMultiMap(opt_params).toString();\n\t\t}\n\n\t\trequest.open(method, url, !opt_sync);\n\n\t\tif (opt_withCredentials) {\n\t\t\trequest.withCredentials = true;\n\t\t}\n\n\t\tif (opt_headers) {\n\t\t\topt_headers.names().forEach(function(name) {\n\t\t\t\trequest.setRequestHeader(name, opt_headers.getAll(name).join(', '));\n\t\t\t});\n\t\t}\n\n\t\trequest.send(core.isDef(body) ? body : null);\n\n\t\tif (core.isDefAndNotNull(opt_timeout)) {\n\t\t\tvar timeout = setTimeout(function() {\n\t\t\t\tpromise.cancel('Request timeout');\n\t\t\t}, opt_timeout);\n\t\t}\n\n\t\treturn promise;\n\t}\n\n}\n\nexport default Ajax;\n","'use strict';\n\n/**\n * Holds value error messages.\n * @const\n */\nclass errors {\n}\n\n/**\n * Invalid status error message.\n * @type {string}\n * @static\n */\nerrors.INVALID_STATUS = 'Invalid status code';\n\n/**\n * Request error message.\n * @type {string}\n * @static\n */\nerrors.REQUEST_ERROR = 'Request error';\n\n/**\n * Request timeout error message.\n * @type {string}\n * @static\n */\nerrors.REQUEST_TIMEOUT = 'Request timeout';\n\nexport default errors;","'use strict';\n\n/**\n * Metal.js browser user agent detection. It's extremely recommended the usage\n * of feature checking over browser user agent sniffing. Unfortunately, in some\n * situations feature checking can be slow or even impossible, therefore use\n * this utility with caution.\n * @see <a href=\"http://www.useragentstring.com/\">User agent strings</a>.\n */\nclass UA {\n\t/**\n\t * Gets the native userAgent string from navigator if it exists. If\n\t * navigator or navigator.userAgent string is missing, returns an empty\n\t * string.\n\t * @return {string}\n\t * @private\n\t * @static\n\t */\n\tstatic getNativeUserAgent() {\n\t\tvar navigator = UA.globals.window.navigator;\n\t\tif (navigator) {\n\t\t\tvar userAgent = navigator.userAgent;\n\t\t\tif (userAgent) {\n\t\t\t\treturn userAgent;\n\t\t\t}\n\t\t}\n\t\treturn '';\n\t}\n\n\t/**\n\t * Whether the user agent contains the given string, ignoring case.\n\t * @param {string} str\n\t * @return {boolean}\n\t * @private\n\t * @static\n\t*/\n\tstatic matchUserAgent(str) {\n\t\treturn UA.userAgent.indexOf(str) !== -1;\n\t}\n\n\t/**\n\t * Tests the user agent.\n\t * @param {string} userAgent The user agent string.\n\t * @static\n\t */\n\tstatic testUserAgent(userAgent) {\n\t\t/**\n\t\t * Holds the user agent value extracted from browser native user agent.\n\t\t * @type {string}\n\t\t * @static\n\t\t */\n\t\tUA.userAgent = userAgent;\n\n\t\t/**\n\t\t * Whether the user's browser is Opera.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isOpera = UA.matchUserAgent('Opera') || UA.matchUserAgent('OPR');\n\n\t\t/**\n\t\t * Whether the user's browser is IE.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isIe = UA.matchUserAgent('Trident') || UA.matchUserAgent('MSIE');\n\n\t\t/**\n\t\t * Whether the user's browser is Edge.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isEdge = UA.matchUserAgent('Edge');\n\n\t\t/**\n\t\t * Whether the user's browser is IE or Edge.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isIeOrEdge = UA.isIe || UA.isEdge;\n\n\t\t/**\n\t\t * Whether the user's browser is Chrome.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isChrome = (UA.matchUserAgent('Chrome') || UA.matchUserAgent('CriOS')) && !UA.isOpera && !UA.isEdge;\n\n\t\t/**\n\t\t * Whether the user's browser is Safari.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isSafari = UA.matchUserAgent('Safari') && !(UA.isChrome || UA.isOpera || UA.isEdge);\n\n\t\t/**\n\t\t * Whether the user's browser is Firefox.\n\t\t * @type {boolean}\n\t\t * @static\n\t\t */\n\t\tUA.isFirefox = UA.matchUserAgent('Firefox');\n\t}\n}\n\n/**\n * Exposes global references.\n * @type {object}\n * @static\n */\nUA.globals = {\n\twindow: window\n};\n\nUA.testUserAgent(UA.getNativeUserAgent());\n\nexport default UA;\n","'use strict';\n\nimport { core } from 'metal';\nimport Ajax from 'metal-ajax';\nimport MultiMap from 'metal-multimap';\nimport CancellablePromise from 'metal-promise';\nimport errors from '../errors/errors';\nimport utils from '../utils/utils';\nimport globals from '../globals/globals';\nimport Screen from './Screen';\nimport Uri from 'metal-uri';\nimport UA from 'metal-useragent';\n\nclass RequestScreen extends Screen {\n\n\t/**\n\t * Request screen abstract class to perform io operations on descendant\n\t * screens.\n\t * @constructor\n\t * @extends {Screen}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * @inheritDoc\n\t\t * @default true\n\t\t */\n\t\tthis.cacheable = true;\n\n\t\t/**\n\t\t * Holds default http headers to set on request.\n\t\t * @type {?Object=}\n\t\t * @default {\n\t\t * 'X-PJAX': 'true',\n\t\t * 'X-Requested-With': 'XMLHttpRequest'\n\t\t * }\n\t\t * @protected\n\t\t */\n\t\tthis.httpHeaders = {\n\t\t\t'X-PJAX': 'true',\n\t\t\t'X-Requested-With': 'XMLHttpRequest'\n\t\t};\n\n\t\t/**\n\t\t * Holds default http method to perform the request.\n\t\t * @type {!string}\n\t\t * @default RequestScreen.GET\n\t\t * @protected\n\t\t */\n\t\tthis.httpMethod = RequestScreen.GET;\n\n\t\t/**\n\t\t * Holds the XHR object responsible for the request.\n\t\t * @type {XMLHttpRequest}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis.request = null;\n\n\t\t/**\n\t\t * Holds the request timeout in milliseconds.\n\t\t * @type {!number}\n\t\t * @default 30000\n\t\t * @protected\n\t\t */\n\t\tthis.timeout = 30000;\n\t}\n\n\t/**\n\t * Asserts that response status code is valid.\n\t * @param {number} status\n\t * @protected\n\t */\n\tassertValidResponseStatusCode(status) {\n\t\tif (!this.isValidResponseStatusCode(status)) {\n\t\t\tvar error = new Error(errors.INVALID_STATUS);\n\t\t\terror.invalidStatus = true;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tbeforeUpdateHistoryPath(path) {\n\t\tvar redirectPath = this.getRequestPath();\n\t\tif (redirectPath && redirectPath !== path) {\n\t\t\treturn redirectPath;\n\t\t}\n\t\treturn path;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tbeforeUpdateHistoryState(state) {\n\t\t// If state is ours and navigate to post-without-redirect-get set\n\t\t// history state to null, that way Senna will reload the page on\n\t\t// popstate since it cannot predict post data.\n\t\tif (state.senna && state.form && state.redirectPath === state.path) {\n\t\t\treturn null;\n\t\t}\n\t\treturn state;\n\t}\n\n\t/**\n\t * Formats load path before invoking ajax call.\n\t * @param {string} path\n\t * @return {string} Formatted path;\n\t * @protected\n\t */\n\tformatLoadPath(path) {\n\t\tvar uri = new Uri(path);\n\n\t\turi.setHostname(globals.window.location.hostname);\n\t\turi.setProtocol(globals.window.location.protocol);\n\n\t\tif (globals.window.location.port) {\n\t\t\turi.setPort(globals.window.location.port);\n\t\t}\n\n\t\tif (UA.isIeOrEdge && this.httpMethod === RequestScreen.GET) {\n\t\t\treturn uri.makeUnique().toString();\n\t\t}\n\n\t\treturn uri.toString();\n\t}\n\n\t/**\n\t * Gets the http headers.\n\t * @return {?Object=}\n\t */\n\tgetHttpHeaders() {\n\t\treturn this.httpHeaders;\n\t}\n\n\t/**\n\t * Gets the http method.\n\t * @return {!string}\n\t */\n\tgetHttpMethod() {\n\t\treturn this.httpMethod;\n\t}\n\n\t/**\n\t * Gets request path.\n\t * @return {string=}\n\t */\n\tgetRequestPath() {\n\t\tvar request = this.getRequest();\n\t\tif (request) {\n\t\t\tvar requestPath = request.requestPath;\n\t\t\tvar responseUrl = this.maybeExtractResponseUrlFromRequest(request);\n\t\t\tif (responseUrl) {\n\t\t\t\trequestPath = responseUrl;\n\t\t\t}\n\t\t\tif (UA.isIeOrEdge && this.httpMethod === RequestScreen.GET) {\n\t\t\t\trequestPath = new Uri(requestPath).removeUnique().toString();\n\t\t\t}\n\t\t\treturn utils.getUrlPath(requestPath);\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets the request object.\n\t * @return {?Object}\n\t */\n\tgetRequest() {\n\t\treturn this.request;\n\t}\n\n\t/**\n\t * Gets the request timeout.\n\t * @return {!number}\n\t */\n\tgetTimeout() {\n\t\treturn this.timeout;\n\t}\n\n\t/**\n\t * Checks if response succeeded. Any status code 2xx or 3xx is considered\n\t * valid.\n\t * @param {number} statusCode\n\t */\n\tisValidResponseStatusCode(statusCode) {\n\t\treturn statusCode >= 200 && statusCode <= 399;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tload(path) {\n\t\tvar cache = this.getCache();\n\t\tif (core.isDefAndNotNull(cache)) {\n\t\t\treturn CancellablePromise.resolve(cache);\n\t\t}\n\n\t\tvar body = null;\n\t\tvar httpMethod = this.httpMethod;\n\n\t\tvar headers = new MultiMap();\n\t\tObject.keys(this.httpHeaders).forEach(header => headers.add(header, this.httpHeaders[header]));\n\n\t\tif (globals.capturedFormElement) {\n\t\t\tbody = new FormData(globals.capturedFormElement);\n\t\t\thttpMethod = RequestScreen.POST;\n\t\t\tif (UA.isIeOrEdge) {\n\t\t\t\theaders.add('If-None-Match', '\"0\"');\n\t\t\t}\n\t\t}\n\n\t\tvar requestPath = this.formatLoadPath(path);\n\t\treturn Ajax\n\t\t\t.request(requestPath, httpMethod, body, headers, null, this.timeout)\n\t\t\t.then(xhr => {\n\t\t\t\tthis.setRequest(xhr);\n\t\t\t\tthis.assertValidResponseStatusCode(xhr.status);\n\t\t\t\tif (httpMethod === RequestScreen.GET && this.isCacheable()) {\n\t\t\t\t\tthis.addCache(xhr.responseText);\n\t\t\t\t}\n\t\t\t\txhr.requestPath = requestPath;\n\t\t\t\treturn xhr.responseText;\n\t\t\t})\n\t\t\t.catch((reason) => {\n\t\t\t\tswitch (reason.message) {\n\t\t\t\t\tcase errors.REQUEST_TIMEOUT:\n\t\t\t\t\t\treason.timeout = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase errors.REQUEST_ERROR:\n\t\t\t\t\t\treason.requestError = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthrow reason;\n\t\t\t});\n\t}\n\n\t/**\n\t * The following method tries to extract the response url value by checking\n\t * the custom response header 'X-Request-URL' if proper value is not present\n\t * in XMLHttpRequest. The value of responseURL will be the final URL\n\t * obtained after any redirects. Internet Explorer, Edge and Safari <= 7\n\t * does not yet support the feature. For more information see:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL\n\t * https://xhr.spec.whatwg.org/#the-responseurl-attribute\n\t * @param {XMLHttpRequest} request\n\t * @return {?string} Response url best match.\n\t */\n\tmaybeExtractResponseUrlFromRequest(request) {\n\t\tvar responseUrl = request.responseURL;\n\t\tif (responseUrl) {\n\t\t\treturn responseUrl;\n\t\t}\n\t\treturn request.getResponseHeader(RequestScreen.X_REQUEST_URL_HEADER);\n\t}\n\n\t/**\n\t * Sets the http headers.\n\t * @param {?Object=} httpHeaders\n\t */\n\tsetHttpHeaders(httpHeaders) {\n\t\tthis.httpHeaders = httpHeaders;\n\t}\n\n\t/**\n\t * Sets the http method.\n\t * @param {!string} httpMethod\n\t */\n\tsetHttpMethod(httpMethod) {\n\t\tthis.httpMethod = httpMethod.toLowerCase();\n\t}\n\n\t/**\n\t * Sets the request object.\n\t * @param {?Object} request\n\t */\n\tsetRequest(request) {\n\t\tthis.request = request;\n\t}\n\n\t/**\n\t * Sets the request timeout in milliseconds.\n\t * @param {!number} timeout\n\t */\n\tsetTimeout(timeout) {\n\t\tthis.timeout = timeout;\n\t}\n\n}\n\n/**\n * Holds value for method get.\n * @type {string}\n * @default 'get'\n * @static\n */\nRequestScreen.GET = 'get';\n\n/**\n * Holds value for method post.\n * @type {string}\n * @default 'post'\n * @static\n */\nRequestScreen.POST = 'post';\n\n/**\n * Fallback http header to retrieve response request url.\n * @type {string}\n * @default 'X-Request-URL'\n * @static\n */\nRequestScreen.X_REQUEST_URL_HEADER = 'X-Request-URL';\n\nexport default RequestScreen;\n","'use strict';\n\nimport { core } from 'metal';\nimport { dom, globalEval, globalEvalStyles } from 'metal-dom';\nimport CancellablePromise from 'metal-promise';\nimport globals from '../globals/globals';\nimport RequestScreen from './RequestScreen';\nimport Surface from '../surface/Surface';\nimport UA from 'metal-useragent';\nimport Uri from 'metal-uri';\nimport utils from '../utils/utils';\n\nclass HtmlScreen extends RequestScreen {\n\n\t/**\n\t * Screen class that perform a request and extracts surface contents from\n\t * the response content.\n\t * @constructor\n\t * @extends {RequestScreen}\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the title selector. Relevant to extract the <code><title></code>\n\t\t * element from request fragments to use as the screen title.\n\t\t * @type {!string}\n\t\t * @default title\n\t\t * @protected\n\t\t */\n\t\tthis.titleSelector = 'title';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tactivate() {\n\t\tsuper.activate();\n\t\tthis.releaseVirtualDocument();\n\t\tthis.pendingStyles = null;\n\t}\n\n\t/**\n\t * Allocates virtual document for content. After allocated virtual document\n\t * can be accessed by <code>this.virtualDocument</code>.\n\t * @param {!string} htmlString\n\t */\n\tallocateVirtualDocumentForContent(htmlString) {\n\t\tif (!this.virtualDocument) {\n\t\t\tthis.virtualDocument = globals.document.createElement('html');\n\t\t}\n\n\t\tthis.copyNodeAttributesFromContent_(htmlString, this.virtualDocument);\n\n\t\tthis.virtualDocument.innerHTML = htmlString;\n\t}\n\n\t/**\n\t * Customizes logic to append styles into document. Relevant to when\n\t * tracking a style by id make sure to re-positions the new style in the\n\t * same dom order.\n\t * @param {Element} newStyle\n\t */\n\tappendStyleIntoDocument_(newStyle) {\n\t\tvar isTemporaryStyle = dom.match(newStyle, HtmlScreen.selectors.stylesTemporary);\n\t\tif (isTemporaryStyle) {\n\t\t\tthis.pendingStyles.push(newStyle);\n\t\t}\n\t\tif (newStyle.id) {\n\t\t\tvar styleInDoc = globals.document.getElementById(newStyle.id);\n\t\t\tif (styleInDoc) {\n\t\t\t\tstyleInDoc.parentNode.insertBefore(newStyle, styleInDoc.nextSibling);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tglobals.document.head.appendChild(newStyle);\n\t}\n\n\t/**\n\t * If body is used as surface forces the requested documents to have same id\n\t * of the initial page.\n\t */\n\tassertSameBodyIdInVirtualDocument() {\n\t\tvar bodySurface = this.virtualDocument.querySelector('body');\n\t\tif (!globals.document.body.id) {\n\t\t\tglobals.document.body.id = 'senna_surface_' + core.getUid();\n\t\t}\n\t\tif (bodySurface) {\n\t\t\tbodySurface.id = globals.document.body.id;\n\t\t}\n\t}\n\n\t/**\n\t * Copies attributes from the <html> tag of content to the given node.\n\t */\n\tcopyNodeAttributesFromContent_(content, node) {\n\t\tcontent = content.replace(/[<]\\s*html/ig, '<senna');\n\t\tcontent = content.replace(/\\/html\\s*\\>/ig, '/senna>');\n\t\tnode.innerHTML = content;\n\t\tvar placeholder = node.querySelector('senna');\n\t\tif (placeholder) {\n\t\t\tutils.clearNodeAttributes(node);\n\t\t\tutils.copyNodeAttributes(placeholder, node);\n\t\t}\n\t}\n\n\t/**\n\t * @Override\n\t */\n\tdisposeInternal() {\n\t\tthis.disposePendingStyles();\n\t\tsuper.disposeInternal();\n\t}\n\n\t/**\n\t * Disposes pending styles if screen get disposed prior to its loading.\n\t */\n\tdisposePendingStyles() {\n\t\tif (this.pendingStyles) {\n\t\t\tthis.pendingStyles.forEach((style) => dom.exitDocument(style));\n\t\t}\n\t}\n\n\t/**\n\t * @Override\n\t */\n\tevaluateScripts(surfaces) {\n\t\tvar evaluateTrackedScripts = this.evaluateTrackedResources_(\n\t\t\tglobalEval.runScriptsInElement, HtmlScreen.selectors.scripts,\n\t\t\tHtmlScreen.selectors.scriptsTemporary, HtmlScreen.selectors.scriptsPermanent);\n\n\t\treturn evaluateTrackedScripts.then(() => super.evaluateScripts(surfaces));\n\t}\n\n\t/**\n\t * @Override\n\t */\n\tevaluateStyles(surfaces) {\n\t\tthis.pendingStyles = [];\n\t\tvar evaluateTrackedStyles = this.evaluateTrackedResources_(\n\t\t\tglobalEvalStyles.runStylesInElement, HtmlScreen.selectors.styles,\n\t\t\tHtmlScreen.selectors.stylesTemporary, HtmlScreen.selectors.stylesPermanent,\n\t\t\tthis.appendStyleIntoDocument_.bind(this));\n\n\t\treturn evaluateTrackedStyles.then(() => super.evaluateStyles(surfaces));\n\t}\n\n\t/**\n\t * Evaluates tracked resources inside incoming fragment and remove existing\n\t * temporary resources.\n\t * @param {?function()} appendFn Function to append the node into document.\n\t * @param {!string} selector Selector used to find resources to track.\n\t * @param {!string} selectorTemporary Selector used to find temporary\n\t * resources to track.\n\t * @param {!string} selectorPermanent Selector used to find permanent\n\t * resources to track.\n\t * @param {!function} opt_appendResourceFn Optional function used to\n\t * evaluate fragment containing resources.\n\t * @return {CancellablePromise} Deferred that waits resources evaluation to\n\t * complete.\n\t * @private\n\t */\n\tevaluateTrackedResources_(evaluatorFn, selector, selectorTemporary, selectorPermanent, opt_appendResourceFn) {\n\t\tvar tracked = this.virtualQuerySelectorAll_(selector);\n\t\tvar temporariesInDoc = this.querySelectorAll_(selectorTemporary);\n\t\tvar permanentsInDoc = this.querySelectorAll_(selectorPermanent);\n\n\t\t// Adds permanent resources in document to cache.\n\t\tpermanentsInDoc.forEach((resource) => {\n\t\t\tvar resourceKey = this.getResourceKey_(resource);\n\t\t\tif (resourceKey) {\n\t\t\t\tHtmlScreen.permanentResourcesInDoc[resourceKey] = true;\n\t\t\t}\n\t\t});\n\n\t\tvar frag = dom.buildFragment();\n\t\ttracked.forEach((resource) => {\n\t\t\tvar resourceKey = this.getResourceKey_(resource);\n\t\t\t// Do not load permanent resources if already in document.\n\t\t\tif (!HtmlScreen.permanentResourcesInDoc[resourceKey]) {\n\t\t\t\tfrag.appendChild(resource);\n\t\t\t}\n\t\t\t// If resource has key and is permanent add to cache.\n\t\t\tif (resourceKey && dom.match(resource, selectorPermanent)) {\n\t\t\t\tHtmlScreen.permanentResourcesInDoc[resourceKey] = true;\n\t\t\t}\n\t\t});\n\n\t\treturn new CancellablePromise((resolve) => {\n\t\t\tevaluatorFn(frag, () => {\n\t\t\t\ttemporariesInDoc.forEach((resource) => dom.exitDocument(resource));\n\t\t\t\tresolve();\n\t\t\t}, opt_appendResourceFn);\n\t\t});\n\t}\n\n\t/**\n\t * @Override\n\t */\n\tflip(surfaces) {\n\t\treturn super.flip(surfaces).then(() => {\n\t\t\tutils.clearNodeAttributes(document.documentElement);\n\t\t\tutils.copyNodeAttributes(this.virtualDocument, document.documentElement);\n\t\t});\n\t}\n\n\t/**\n\t * Extracts a key to identify the resource based on its attributes.\n\t * @param {Element} resource\n\t * @return {string} Extracted key based on resource attributes in order of\n\t * preference: id, href, src.\n\t */\n\tgetResourceKey_(resource) {\n\t\treturn resource.id || resource.href || resource.src || '';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tgetSurfaceContent(surfaceId) {\n\t\tvar surface = this.virtualDocument.querySelector('#' + surfaceId);\n\t\tif (surface) {\n\t\t\tvar defaultChild = surface.querySelector('#' + surfaceId + '-' + Surface.DEFAULT);\n\t\t\tif (defaultChild) {\n\t\t\t\treturn defaultChild.innerHTML;\n\t\t\t}\n\t\t\treturn surface.innerHTML; // If default content not found, use surface content\n\t\t}\n\t}\n\n\t/**\n\t * Gets the title selector.\n\t * @return {!string}\n\t */\n\tgetTitleSelector() {\n\t\treturn this.titleSelector;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tload(path) {\n\t\treturn super.load(path)\n\t\t\t.then(content => {\n\t\t\t\tthis.allocateVirtualDocumentForContent(content);\n\t\t\t\tthis.resolveTitleFromVirtualDocument();\n\t\t\t\tthis.assertSameBodyIdInVirtualDocument();\n\t\t\t\tif (UA.isIe) {\n\t\t\t\t\tthis.makeTemporaryStylesHrefsUnique_();\n\t\t\t\t}\n\t\t\t\treturn content;\n\t\t\t});\n\t}\n\n\t/**\n\t * Queries temporary styles from virtual document, and makes them unique.\n\t * This is necessary for caching and load event firing issues specific to\n\t * IE11. https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7940171/\n\t */\n\tmakeTemporaryStylesHrefsUnique_() {\n\t\tvar temporariesInDoc = this.virtualQuerySelectorAll_(HtmlScreen.selectors.stylesTemporary);\n\t\ttemporariesInDoc.forEach((style) => this.replaceStyleAndMakeUnique_(style));\n\t}\n\n\t/**\n\t * Creates a new element from given, copies attributes, mutates href to be\n\t * unique to prevent caching and more than one load/error event from firing.\n\t */\n\treplaceStyleAndMakeUnique_(style) {\n\t\tif (style.href) {\n\t\t\tvar newStyle = globals.document.createElement(style.tagName);\n\t\t\tstyle.href = new Uri(style.href).makeUnique().toString();\n\t\t\tutils.copyNodeAttributes(style, newStyle);\n\t\t\tstyle.parentNode.replaceChild(newStyle, style);\n\t\t\tstyle.disabled = true;\n\t\t}\n\t}\n\n\t/**\n\t * Queries elements from virtual document and returns an array of elements.\n\t * @param {!string} selector\n\t * @return {array.<Element>}\n\t */\n\tvirtualQuerySelectorAll_(selector) {\n\t\treturn Array.prototype.slice.call(this.virtualDocument.querySelectorAll(selector));\n\t}\n\n\t/**\n\t * Queries elements from document and returns an array of elements.\n\t * @param {!string} selector\n\t * @return {array.<Element>}\n\t */\n\tquerySelectorAll_(selector) {\n\t\treturn Array.prototype.slice.call(globals.document.querySelectorAll(selector));\n\t}\n\n\t/**\n\t * Releases virtual document allocated for content.\n\t */\n\treleaseVirtualDocument() {\n\t\tthis.virtualDocument = null;\n\t}\n\n\t/**\n\t * Resolves title from allocated virtual document.\n\t */\n\tresolveTitleFromVirtualDocument() {\n\t\tvar title = this.virtualDocument.querySelector(this.titleSelector);\n\t\tif (title) {\n\t\t\tthis.setTitle(title.innerHTML.trim());\n\t\t}\n\t}\n\n\t/**\n\t * Sets the title selector.\n\t * @param {!string} titleSelector\n\t */\n\tsetTitleSelector(titleSelector) {\n\t\tthis.titleSelector = titleSelector;\n\t}\n\n}\n\n/**\n * Helper selectors for tracking resources.\n * @type {object}\n * @protected\n * @static\n */\nHtmlScreen.selectors = {\n\tscripts: 'script[data-senna-track]',\n\tscriptsPermanent: 'script[data-senna-track=\"permanent\"]',\n\tscriptsTemporary: 'script[data-senna-track=\"temporary\"]',\n\tstyles: 'style[data-senna-track],link[data-senna-track]',\n\tstylesPermanent: 'style[data-senna-track=\"permanent\"],link[data-senna-track=\"permanent\"]',\n\tstylesTemporary: 'style[data-senna-track=\"temporary\"],link[data-senna-track=\"temporary\"]'\n};\n\n/**\n * Caches permanent resource keys.\n * @type {object}\n * @protected\n * @static\n */\nHtmlScreen.permanentResourcesInDoc = {};\n\nexport default HtmlScreen;\n","'use strict';\n\nimport App from './app/App';\nimport HtmlScreen from './screen/HtmlScreen';\nimport RequestScreen from './screen/RequestScreen';\nimport Route from './route/Route';\nimport Screen from './screen/Screen';\n\nexport default App;\nexport { App, HtmlScreen, Route, RequestScreen, Screen };\n","'use strict';\n\nexport default {\n\tbasePath: 'data-senna-base-path',\n\tlinkSelector: 'data-senna-link-selector',\n\tloadingCssClass: 'data-senna-loading-css-class',\n\tsenna: 'data-senna',\n\tdispatch: 'data-senna-dispatch',\n\tsurface: 'data-senna-surface',\n\tupdateScrollPosition: 'data-senna-update-scroll-position'\n};","'use strict';\n\nimport { core, object, Disposable } from 'metal';\nimport dataAttributes from './dataAttributes';\nimport globals from '../globals/globals';\nimport App from './App';\nimport HtmlScreen from '../screen/HtmlScreen';\nimport Route from '../route/Route';\n\nclass AppDataAttributeHandler extends Disposable {\n\n\t/**\n\t * Initilizes App, register surfaces and routes from data attributes.\n\t * @constructor\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t/**\n\t\t * Holds the app reference initialized by data attributes.\n\t\t * @type {App}\n\t\t * @default null\n\t\t */\n\t\tthis.app = null;\n\n\t\t/**\n\t\t * Holds the base element to search initialization data attributes. This\n\t\t * element is the container used to enable initialization based on the\n\t\t * presence of `data-senna` attribute.\n\t\t * @type {Element}\n\t\t * @default null\n\t\t */\n\t\tthis.baseElement = null;\n\t}\n\n\t/**\n\t * Inits application based on information scanned from document.\n\t */\n\thandle() {\n\t\tif (!core.isElement(this.baseElement)) {\n\t\t\tthrow new Error('Senna data attribute handler base element ' +\n\t\t\t\t'not set or invalid, try setting a valid element that ' +\n\t\t\t\t'contains a `data-senna` attribute.');\n\t\t}\n\n\t\tif (!this.baseElement.hasAttribute(dataAttributes.senna)) {\n\t\t\tconsole.log('Senna was not initialized from data attributes. ' +\n\t\t\t\t'In order to enable its usage from data attributes try setting ' +\n\t\t\t\t'in the base element, e.g. `<body data-senna>`.');\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.app) {\n\t\t\tthrow new Error('Senna app was already initialized.');\n\t\t}\n\n\t\tconsole.log('Senna initialized from data attribute.');\n\n\t\tthis.app = new App();\n\t\tthis.maybeAddRoutes_();\n\t\tthis.maybeAddSurfaces_();\n\t\tthis.maybeSetBasePath_();\n\t\tthis.maybeSetLinkSelector_();\n\t\tthis.maybeSetLoadingCssClass_();\n\t\tthis.maybeSetUpdateScrollPosition_();\n\t\tthis.maybeDispatch_();\n\t}\n\n\t/**\n\t * Disposes of this instance's object references.\n\t * @override\n\t */\n\tdisposeInternal() {\n\t\tif (this.app) {\n\t\t\tthis.app.dispose();\n\t\t}\n\t}\n\n\t/**\n\t * Gets the app reference.\n\t * @return {App}\n\t */\n\tgetApp() {\n\t\treturn this.app;\n\t}\n\n\t/**\n\t * Gets the base element.\n\t * @return {Element} baseElement\n\t */\n\tgetBaseElement() {\n\t\treturn this.baseElement;\n\t}\n\n\t/**\n\t * Maybe adds app routes from link elements that are `senna-route`.\n\t */\n\tmaybeAddRoutes_() {\n\t\tvar routesSelector = 'link[rel=\"senna-route\"]';\n\t\tthis.querySelectorAllAsArray_(routesSelector).forEach((link) => this.maybeParseLinkRoute_(link));\n\t\tif (!this.app.hasRoutes()) {\n\t\t\tthis.app.addRoutes(new Route(/.*/, HtmlScreen));\n\t\t\tconsole.log('Senna can\\'t find route elements, adding default.');\n\t\t}\n\t}\n\n\t/**\n\t * Maybe adds app surfaces by scanning `data-senna-surface` data attribute.\n\t */\n\tmaybeAddSurfaces_() {\n\t\tvar surfacesSelector = '[' + dataAttributes.surface + ']';\n\t\tthis.querySelectorAllAsArray_(surfacesSelector).forEach((surfaceElement) => {\n\t\t\tthis.updateElementIdIfSpecialSurface_(surfaceElement);\n\t\t\tthis.app.addSurfaces(surfaceElement.id);\n\t\t});\n\t}\n\n\t/**\n\t * Dispatches app navigation to the current path when initializes.\n\t */\n\tmaybeDispatch_() {\n\t\tif (this.baseElement.hasAttribute(dataAttributes.dispatch)) {\n\t\t\tthis.app.dispatch();\n\t\t}\n\t}\n\n\t/**\n\t * Adds app route by parsing valid link elements. A valid link element is of\n\t * the kind `rel=\"senna-route\"`.\n\t * @param {Element} link\n\t */\n\tmaybeParseLinkRoute_(link) {\n\t\tvar route = new Route(this.maybeParseLinkRoutePath_(link), this.maybeParseLinkRouteHandler_(link));\n\t\tthis.app.addRoutes(route);\n\t\tconsole.log('Senna scanned route ' + route.getPath());\n\t}\n\n\t/**\n\t * Maybe parse link route handler.\n\t * @param {Element} link\n\t * @return {?string}\n\t */\n\tmaybeParseLinkRouteHandler_(link) {\n\t\tvar handler = link.getAttribute('type');\n\t\tif (core.isDefAndNotNull(handler)) {\n\t\t\thandler = object.getObjectByName(handler);\n\t\t}\n\t\treturn handler;\n\t}\n\n\t/**\n\t * Maybe parse link route path.\n\t * @param {Element} link\n\t * @return {?string}\n\t */\n\tmaybeParseLinkRoutePath_(link) {\n\t\tvar path = link.getAttribute('href');\n\t\tif (core.isDefAndNotNull(path)) {\n\t\t\tif (path.indexOf('regex:') === 0) {\n\t\t\t\tpath = new RegExp(path.substring(6));\n\t\t\t}\n\t\t}\n\t\treturn path;\n\t}\n\n\t/**\n\t * Maybe sets app base path from `data-senna-base-path` data attribute.\n\t */\n\tmaybeSetBasePath_() {\n\t\tvar basePath = this.baseElement.getAttribute(dataAttributes.basePath);\n\t\tif (core.isDefAndNotNull(basePath)) {\n\t\t\tthis.app.setBasePath(basePath);\n\t\t\tconsole.log('Senna scanned base path ' + basePath);\n\t\t}\n\t}\n\n\t/**\n\t * Maybe sets app link selector from `data-senna-link-selector` data\n\t * attribute.\n\t */\n\tmaybeSetLinkSelector_() {\n\t\tvar linkSelector = this.baseElement.getAttribute(dataAttributes.linkSelector);\n\t\tif (core.isDefAndNotNull(linkSelector)) {\n\t\t\tthis.app.setLinkSelector(linkSelector);\n\t\t\tconsole.log('Senna scanned link selector ' + linkSelector);\n\t\t}\n\t}\n\n\t/**\n\t * Maybe sets app link loading css class from `data-senna-loading-css-class`\n\t * data attribute.\n\t */\n\tmaybeSetLoadingCssClass_() {\n\t\tvar loadingCssClass = this.baseElement.getAttribute(dataAttributes.loadingCssClass);\n\t\tif (core.isDefAndNotNull(loadingCssClass)) {\n\t\t\tthis.app.setLoadingCssClass(loadingCssClass);\n\t\t\tconsole.log('Senna scanned loading css class ' + loadingCssClass);\n\t\t}\n\t}\n\n\t/**\n\t * Maybe sets app update scroll position from\n\t * `data-senna-update-scroll-position` data attribute.\n\t */\n\tmaybeSetUpdateScrollPosition_() {\n\t\tvar updateScrollPosition = this.baseElement.getAttribute(dataAttributes.updateScrollPosition);\n\t\tif (core.isDefAndNotNull(updateScrollPosition)) {\n\t\t\tif (updateScrollPosition === 'false') {\n\t\t\t\tthis.app.setUpdateScrollPosition(false);\n\t\t\t} else {\n\t\t\t\tthis.app.setUpdateScrollPosition(true);\n\t\t\t}\n\t\t\tconsole.log('Senna scanned update scroll position ' + updateScrollPosition);\n\t\t}\n\t}\n\n\t/**\n\t * Queries elements from document and returns an array of elements.\n\t * @param {!string} selector\n\t * @return {array.<Element>}\n\t */\n\tquerySelectorAllAsArray_(selector) {\n\t\treturn Array.prototype.slice.call(globals.document.querySelectorAll(selector));\n\t}\n\n\t/**\n\t * Updates element id if handled as special surface element. Some surfaces\n\t * are slightly different from others, like when threating <code>body</code>\n\t * as surface.\n\t * @param {Element} element\n\t */\n\tupdateElementIdIfSpecialSurface_(element) {\n\t\tif (!element.id && element === globals.document.body) {\n\t\t\telement.id = 'senna_surface_' + core.getUid();\n\t\t}\n\t}\n\n\t/**\n\t * Sets the base element.\n\t * @param {Element} baseElement\n\t */\n\tsetBaseElement(baseElement) {\n\t\tthis.baseElement = baseElement;\n\t}\n\n}\n\nexport default AppDataAttributeHandler;\n","'use strict';\n\nimport globals from '../globals/globals';\nimport AppDataAttributeHandler from './AppDataAttributeHandler';\n\n/**\n * Data attribute handler.\n * @type {AppDataAttributeHandler}\n */\nvar dataAttributeHandler = new AppDataAttributeHandler();\n\nglobals.document.addEventListener('DOMContentLoaded', function() {\n\tdataAttributeHandler.setBaseElement(globals.document.body);\n\tdataAttributeHandler.handle();\n});\n\nexport default dataAttributeHandler;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/package.json b/package.json index 817ffab..db22cd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "senna", - "version": "1.5.1", + "version": "1.5.2", "description": "A blazing-fast Single Page Application engine", "license": "BSD-3-Clause", "repository": "liferay/senna.js",