-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsenna-min.js
10 lines (10 loc) · 67.3 KB
/
senna-min.js
1
2
3
4
5
6
7
8
9
10
/**
* Senna.js - A blazing-fast Single Page Application engine
* @author Eduardo Lundgren <[email protected]>
* @version v1.3.0
* @link https://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<t.length;n++)if(t[n]!==e[n])return!1;return!0},n.firstDefinedValue=function(t){for(var e=0;e<t.length;e++)if(void 0!==t[e])return t[e]},n.flatten=function(t,e){for(var r=e||[],i=0;i<t.length;i++)Array.isArray(t[i])?n.flatten(t[i],r):r.push(t[i]);return r},n.remove=function(t,e){var r,i=t.indexOf(e);return(r=i>=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;o>a;a++)i.push(t[a]);return i},n}();this.senna.array=n}.call(this),function(){var t={};t.throwException=function(e){t.nextTick(function(){throw e})},t.run=function(e,n){t.run.workQueueScheduled_||(t.nextTick(t.run.processWorkQueue),t.run.workQueueScheduled_=!0),t.run.workQueue_.push(new t.run.WorkItem_(e,n))},t.run.workQueueScheduled_=!1,t.run.workQueue_=[],t.run.processWorkQueue=function(){for(;t.run.workQueue_.length;){var e=t.run.workQueue_;t.run.workQueue_=[];for(var n=0;n<e.length;n++){var r=e[n];try{r.fn.call(r.scope)}catch(i){t.throwException(i)}}}t.run.workQueueScheduled_=!1},t.run.WorkItem_=function(t,e){this.fn=t,this.scope=e},t.nextTick=function(e,n){var r=e;return n&&(r=e.bind(n)),r=t.nextTick.wrapCallback_(r),"function"==typeof setImmediate?void setImmediate(r):(t.nextTick.setImmediate_||(t.nextTick.setImmediate_=t.nextTick.getSetImmediateEmulator_()),void t.nextTick.setImmediate_(r))},t.nextTick.setImmediate_=null,t.nextTick.getSetImmediateEmulator_=function(){var t;if("function"==typeof MessageChannel&&(t=MessageChannel),"undefined"==typeof t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&(t=function(){var t=document.createElement("iframe");t.style.display="none",t.src="",document.documentElement.appendChild(t);var e=t.contentWindow,n=e.document;n.open(),n.write(""),n.close();var r="callImmediate"+Math.random(),i=e.location.protocol+"//"+e.location.host,o=function(t){t.origin!==i&&t.data!==r||this.port1.onmessage()}.bind(this);e.addEventListener("message",o,!1),this.port1={},this.port2={postMessage:function(){e.postMessage(r,i)}}}),"undefined"!=typeof t){var e=new t,n={},r=n;return e.port1.onmessage=function(){n=n.next;var t=n.cb;n.cb=null,t()},function(t){r.next={cb:t},r=r.next,e.port2.postMessage(0)}}return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("script")?function(t){var e=document.createElement("script");e.onreadystatechange=function(){e.onreadystatechange=null,e.parentNode.removeChild(e),e=null,t(),t=null},document.documentElement.appendChild(e)}:function(t){setTimeout(t,0)}},t.nextTick.wrapCallback_=function(t){return t},this.senna.async=t}.call(this),function(){var e=function(){function e(){t.classCallCheck(this,e),this.disposed_=!1}return e.prototype.dispose=function(){this.disposed_||(this.disposeInternal(),this.disposed_=!0)},e.prototype.disposeInternal=function(){},e.prototype.isDisposed=function(){return this.disposed_},e}();this.senna.Disposable=e}.call(this),function(){var e=function(){function e(){t.classCallCheck(this,e)}return e.mixin=function(t){for(var e,n,r=1;r<arguments.length;r++){n=arguments[r];for(e in n)t[e]=n[e]}return t},e.getObjectByName=function(t,e){var n=e||window,r=t.split(".");return r.reduce(function(t,e){return t[e]},n)},e.map=function(t,e){for(var n={},r=Object.keys(t),i=0;i<r.length;i++)n[r[i]]=e(r[i],t[r[i]]);return n},e.shallowEqual=function(t,e){if(t===e)return!0;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var i=0;i<n.length;i++)if(t[n[i]]!==e[n[i]])return!1;return!0},e}();this.senna.object=e}.call(this),function(){var e=function(){function e(){t.classCallCheck(this,e)}return e.collapseBreakingSpaces=function(t){return t.replace(/[\t\r\n ]+/g," ").replace(/^[\t\r\n ]+|[\t\r\n ]+$/g,"")},e.escapeRegex=function(t){return String(t).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08")},e.getRandomString=function(){var t=2147483648;return Math.floor(Math.random()*t).toString(36)+Math.abs(Math.floor(Math.random()*t)^Date.now()).toString(36)},e.hashCode=function(t){for(var e=0,n=0,r=t.length;r>n;n++)e=31*e+t.charCodeAt(n),e%=4294967296;return e},e.replaceInterval=function(t,e,n,r){return t.substring(0,e)+r+t.substring(n)},e}();this.senna.string=e}.call(this),function(){var t=this.senna.core,e=this.senna.array,n=this.senna.async,r=this.senna.Disposable,i=this.senna.object,o=this.senna.string;this.senna.metal=t,this.sennaNamed.metal=this.sennaNamed.metal||{},this.sennaNamed.metal.core=t,this.sennaNamed.metal.array=e,this.sennaNamed.metal.async=n,this.sennaNamed.metal.Disposable=r,this.sennaNamed.metal.object=i,this.sennaNamed.metal.string=o}.call(this),function(){var e="__metal_data__";this.senna.metalData=function(){function n(){t.classCallCheck(this,n)}return n.get=function(t){return t[e]||(t[e]={delegating:{},listeners:{}}),t[e]},n}()}.call(this),function(){var e=this.sennaNamed.metal.Disposable,n=function(e){function n(r,i,o){t.classCallCheck(this,n);var a=t.possibleConstructorReturn(this,e.call(this));return a.emitter_=r,a.event_=i,a.listener_=o,a}return t.inherits(n,e),n.prototype.disposeInternal=function(){this.removeListener(),this.emitter_=null,this.listener_=null},n.prototype.removeListener=function(){this.emitter_.isDisposed()||this.emitter_.removeListener(this.event_,this.listener_)},n}(e);this.senna.EventHandle=n}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.metal.array,r=this.sennaNamed.metal.Disposable,i=this.senna.EventHandle,o=function(r){function o(){t.classCallCheck(this,o);var e=t.possibleConstructorReturn(this,r.call(this));return e.events_=[],e.maxListeners_=10,e.shouldUseFacade_=!1,e}return t.inherits(o,r),o.prototype.addListener=function(t,e,n){this.validateListener_(e),t=this.normalizeEvents_(t);for(var r=0;r<t.length;r++)this.addSingleListener_(t[r],e,n);return new i(this,t,e)},o.prototype.addSingleListener_=function(t,e,n,r){this.emit("newListener",t,e),this.events_[t]||(this.events_[t]=[]),this.events_[t].push({"default":n,fn:e,origin:r});var i=this.events_[t];i.length>this.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;a<i.length;a++)i[a]["default"]?o.push(i[a]):i[a].fn.apply(this,r);if(!e||!e.preventedDefault)for(var s=0;s<o.length;s++)o[s].fn.apply(this,r);return"*"!==t&&this.emit.apply(this,["*",t].concat(r)),i.length>0},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<t.length;r++)this.many_(t[r],e,n);return new i(this,t,n)},o.prototype.many_=function(t,e,n){function r(){0===--e&&i.removeListener(t,r),n.apply(i,arguments)}var i=this;0>=e||i.addSingleListener_(t,r,!1,n)},o.prototype.matchesListener_=function(t,e){return t.fn===e||t.origin&&t.origin===e},o.prototype.normalizeEvents_=function(t){return e.isString(t)?[t]:t},o.prototype.off=function(t,e){this.validateListener_(e),t=this.normalizeEvents_(t);for(var n=0;n<t.length;n++){var r=this.events_[t[n]]||[];this.removeMatchingListenerObjs_(r,e)}return this},o.prototype.on=function(){return this.addListener.apply(this,arguments)},o.prototype.once=function(t,e){return this.many(t,1,e)},o.prototype.removeAllListeners=function(t){if(t)for(var e=this.normalizeEvents_(t),n=0;n<e.length;n++)this.events_[e[n]]=null;else this.events_={};return this},o.prototype.removeMatchingListenerObjs_=function(t,e){for(var n=t.length-1;n>=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.length;e++)this.proxiedEvents_[t[e]].removeListener();this.proxiedEvents_={},this.pendingEvents_=[]},r.prototype.setOriginEmitter=function(t){var e=this,n=this.originEmitter_?Object.keys(this.proxiedEvents_):this.pendingEvents_;this.removeListeners_(),this.originEmitter_=t,n.forEach(function(t){return e.proxyEvent(t)})},r.prototype.shouldProxyEvent_=function(t){return this.whitelist_&&!this.whitelist_[t]?!1:this.blacklist_[t]?!1:!this.proxiedEvents_[t]},r.prototype.startProxy_=function(){this.targetEmitter_.on("newListener",this.proxyEvent.bind(this))},r.prototype.tryToAddListener_=function(t){this.originEmitter_?this.proxiedEvents_[t]=this.addListenerForEvent_(t):this.pendingEvents_.push(t)},r}(n);this.senna.EventEmitterProxy=r}.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.eventHandles_=[],r}return t.inherits(n,e),n.prototype.add=function(){for(var t=0;t<arguments.length;t++)this.eventHandles_.push(arguments[t])},n.prototype.disposeInternal=function(){this.eventHandles_=null},n.prototype.removeAllListeners=function(){for(var t=0;t<this.eventHandles_.length;t++)this.eventHandles_[t].removeListener();this.eventHandles_=[]},n}(e);this.senna.EventHandler=n}.call(this),function(){var t=this.senna.EventEmitter,e=this.senna.EventEmitterProxy,n=this.senna.EventHandle,r=this.senna.EventHandler;this.senna.events=t,this.sennaNamed.events=this.sennaNamed.events||{},this.sennaNamed.events.EventEmitter=t,this.sennaNamed.events.EventEmitterProxy=e,this.sennaNamed.events.EventHandle=n,this.sennaNamed.events.EventHandler=r}.call(this),function(){var e=this.sennaNamed.metal.array,n=this.sennaNamed.metal.core,r=this.senna.metalData,i=this.sennaNamed.events.EventHandle,o=function(i){function o(e,n,r,a){t.classCallCheck(this,o);var s=t.possibleConstructorReturn(this,i.call(this,e,n,r));return s.selector_=a,s}return t.inherits(o,i),o.prototype.removeListener=function(){var t=r.get(this.emitter_),i=this.selector_,o=n.isString(i)?t.delegating[this.event_].selectors:t.listeners,a=n.isString(i)?i:this.event_;e.remove(o[a]||[],this.listener_),o[a]&&0===o[a].length&&delete o[a]},o}(i);this.senna.DomDelegatedEventHandle=o}.call(this),function(){var e=this.sennaNamed.events.EventHandle,n=function(e){function n(r,i,o,a){t.classCallCheck(this,n);var s=t.possibleConstructorReturn(this,e.call(this,r,i,o));return s.capture_=a,s}return t.inherits(n,e),n.prototype.removeListener=function(){this.emitter_.removeEventListener(this.event_,this.listener_,this.capture_)},n}(e);this.senna.DomEventHandle=n}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.metal.object,r=this.senna.metalData,i=this.senna.DomDelegatedEventHandle,o=this.senna.DomEventHandle,a="__metal_next_target__",s={blur:!0,focus:!0,scroll:!0},l=function(){function l(){t.classCallCheck(this,l)}return l.addClasses=function(t,n){e.isObject(t)&&e.isString(n)&&("classList"in t?l.addClassesWithNative_(t,n):l.addClassesWithoutNative_(t,n))},l.addClassesWithNative_=function(t,e){e.split(" ").forEach(function(e){e&&t.classList.add(e)})},l.addClassesWithoutNative_=function(t,e){var n=" "+t.className+" ",r="";e=e.split(" ");for(var i=0;i<e.length;i++){var o=e[i];-1===n.indexOf(" "+o+" ")&&(r+=" "+o)}r&&(t.className=t.className+r)},l.addElementListener_=function(t,e,n){var i=r.get(t);l.addToArr_(i.listeners,e,n)},l.addSelectorListener_=function(t,e,n,i){var o=r.get(t);l.addToArr_(o.delegating[e].selectors,n,i)},l.addToArr_=function(t,e,n){t[e]||(t[e]=[]),t[e].push(n)},l.attachDelegateEvent_=function(t,e){var n=r.get(t);n.delegating[e]||(n.delegating[e]={handle:l.on(t,e,l.handleDelegateEvent_,!!s[e]),selectors:{}})},l.closest=function(t,e){for(;t&&!l.match(t,e);)t=t.parentNode;return t},l.append=function(t,n){if(e.isString(n)&&(n=l.buildFragment(n)),n instanceof NodeList)for(var r=Array.prototype.slice.call(n),i=0;i<r.length;i++)t.appendChild(r[i]);else t.appendChild(n);return n},l.buildFragment=function(t){var e=document.createElement("div");e.innerHTML="<br>"+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<s.length&&!t.defaultPrevented;c++)t.delegateTarget=s[c].element,r&=s[c].fn(t);return t.delegateTarget=null,t[a]=o,r},l.hasClass=function(t,e){return"classList"in t?l.hasClassWithNative_(t,e):l.hasClassWithoutNative_(t,e)},l.hasClassWithNative_=function(t,e){return t.classList.contains(e)},l.hasClassWithoutNative_=function(t,e){return(" "+t.className+" ").indexOf(" "+e+" ")>=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;r<n.length;++r)if(n[r]===t)return!0;return!1},l.next=function(t,e){do if(t=t.nextSibling,t&&l.match(t,e))return t;while(t);return null},l.normalizeDelegateEvent_=function(t){t.stopPropagation=l.stopPropagation_,t.stopImmediatePropagation=l.stopImmediatePropagation_},l.on=function(t,n,r,i){if(e.isString(t))return l.delegate(document,n,t,r);var a=l.customEvents[n];return a&&a.event&&(n=a.originalEvent,r=a.handler.bind(a,r)),t.addEventListener(n,r,i),new o(t,n,r,i)},l.once=function(t,e,n){var r=this.on(t,e,function(){return r.removeListener(),n.apply(this,arguments)});return r},l.parent=function(t,e){return l.closest(t.parentNode,e)},l.registerCustomEvent=function(t,e){l.customEvents[t]=e},l.removeChildren=function(t){for(var e;e=t.firstChild;)t.removeChild(e)},l.removeClasses=function(t,n){e.isObject(t)&&e.isString(n)&&("classList"in t?l.removeClassesWithNative_(t,n):l.removeClassesWithoutNative_(t,n))},l.removeClassesWithNative_=function(t,e){e.split(" ").forEach(function(e){e&&t.classList.remove(e)})},l.removeClassesWithoutNative_=function(t,e){var n=" "+t.className+" ";e=e.split(" ");for(var r=0;r<e.length;r++)n=n.replace(" "+e[r]+" "," ");t.className=n.trim()},l.replace=function(t,e){t&&e&&t!==e&&t.parentNode&&(t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t))},l.stopImmediatePropagation_=function(){this.stopped=!0,this.stoppedImmediate=!0,Event.prototype.stopImmediatePropagation.call(this)},l.stopPropagation_=function(){this.stopped=!0,Event.prototype.stopPropagation.call(this)},l.supportsEvent=function(t,n){return l.customEvents[n]?!0:(e.isString(t)&&(c[t]||(c[t]=document.createElement(t)),t=c[t]),"on"+n in t)},l.toElement=function(t){return e.isElement(t)||e.isDocument(t)?t:e.isString(t)?"#"===t[0]&&-1===t.indexOf(" ")?document.getElementById(t.substr(1)):document.querySelector(t):null},l.toggleClasses=function(t,n){e.isObject(t)&&e.isString(n)&&("classList"in t?l.toggleClassesWithNative_(t,n):l.toggleClassesWithoutNative_(t,n))},l.toggleClassesWithNative_=function(t,e){e.split(" ").forEach(function(e){t.classList.toggle(e)})},l.toggleClassesWithoutNative_=function(t,e){var n=" "+t.className+" ";e=e.split(" ");for(var r=0;r<e.length;r++){var i=" "+e[r]+" ",o=n.indexOf(i);n=-1===o?n+e[r]+" ":n.substring(0,o)+" "+n.substring(o+i.length)}t.className=n.trim()},l.triggerEvent=function(t,e,r){var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!0),n.mixin(i,r),t.dispatchEvent(i)},l.triggerListeners_=function(t,e,n,r){var i=!0;t=t||[];for(var o=0;o<t.length&&!e.stoppedImmediate;o++)t[o].defaultListener_?r.push({element:n,fn:t[o]}):i&=t[o](e);return i},l.triggerMatchedListeners_=function(t,e,n,i){for(var o=r.get(e),a=o.listeners[n.type],s=l.triggerListeners_(a,n,e,i),c=r.get(t).delegating[n.type].selectors,u=Object.keys(c),h=0;h<u.length&&!n.stoppedImmediate;h++)l.match(e,u[h])&&(a=c[u[h]],s&=l.triggerListeners_(a,n,e,i));return s},l}(),c={};l.customEvents={},this.senna.dom=l}.call(this),function(){var e=this.senna.dom,n=this.sennaNamed.events.EventEmitterProxy,r=function(n){function r(){return t.classCallCheck(this,r),t.possibleConstructorReturn(this,n.apply(this,arguments))}return t.inherits(r,n),r.prototype.addListener_=function(t,r){if(this.originEmitter_.addEventListener){if(this.isDelegateEvent_(t)){var i=t.indexOf(":",9),o=t.substring(9,i),a=t.substring(i+1);return e.delegate(this.originEmitter_,o,a,r)}return e.on(this.originEmitter_,t,r)}return n.prototype.addListener_.call(this,t,r)},r.prototype.isDelegateEvent_=function(t){return"delegate:"===t.substr(0,9)},r.prototype.isSupportedDomEvent_=function(t){return this.originEmitter_&&this.originEmitter_.addEventListener?this.isDelegateEvent_(t)&&-1!==t.indexOf(":",9)||e.supportsEvent(this.originEmitter_,t):!0},r.prototype.shouldProxyEvent_=function(t){return n.prototype.shouldProxyEvent_.call(this,t)&&this.isSupportedDomEvent_(t)},r}(n);this.senna.DomEventEmitterProxy=r}.call(this),function(){var e=this.senna.dom,n=this.sennaNamed.metal.string,r=function(){function r(){t.classCallCheck(this,r)}return r.checkAnimationEventName=function(){return void 0===r.animationEventName_&&(r.animationEventName_={animation:r.checkAnimationEventName_("animation"),transition:r.checkAnimationEventName_("transition")}),r.animationEventName_},r.checkAnimationEventName_=function(t){for(var e=["Webkit","MS","O",""],i=n.replaceInterval(t,0,1,t.substring(0,1).toUpperCase()),o=[i+"End",i+"End",i+"End",t+"end"],a=0;a<e.length;a++)if(void 0!==r.animationElement_.style[e[a]+i])return e[a].toLowerCase()+o[a];return t+"end"},r.checkAttrOrderChange=function(){if(void 0===r.attrOrderChange_){var t='<div data-component="" data-ref=""></div>',n=document.createElement("div");e.append(n,t),r.attrOrderChange_=t!==n.innerHTML}return r.attrOrderChange_},r}();r.animationElement_=document.createElement("div"),r.animationEventName_=void 0,r.attrOrderChange_=void 0,this.senna.features=r}.call(this),function(){var e=this.sennaNamed.metal.async,n=this.senna.dom,r=function(){function r(){t.classCallCheck(this,r)}return r.run=function(t,e){var r=document.createElement("script");return r.text=t,e?e(r):document.head.appendChild(r),n.exitDocument(r),r},r.runFile=function(t,e,r){var i=document.createElement("script");i.src=t;var o=function(){n.exitDocument(i),e&&e()};return n.once(i,"load",o),n.once(i,"error",o),r?r(i):document.head.appendChild(i),i},r.runScript=function(t,i,o){var a=function(){i&&i()};return t.type&&"text/javascript"!==t.type?void e.nextTick(a):(n.exitDocument(t),t.src?r.runFile(t.src,i,o):(e.nextTick(a),r.run(t.text,o)))},r.runScriptsInElement=function(t,n,i){var o=t.querySelectorAll("script");o.length?r.runScriptsInOrder(o,0,n,i):n&&e.nextTick(n)},r.runScriptsInOrder=function(t,n,i,o){r.runScript(t.item(n),function(){n<t.length-1?r.runScriptsInOrder(t,n+1,i,o):i&&e.nextTick(i)},o)},r}();this.senna.globalEval=r}.call(this),function(){var e=this.sennaNamed.metal.async,n=this.senna.dom,r=function(){function r(){t.classCallCheck(this,r)}return r.run=function(t,e){var n=document.createElement("style");return n.innerHTML=t,e?e(n):document.head.appendChild(n),n},r.runFile=function(t,e,n){var i=document.createElement("link");return i.rel="stylesheet",i.href=t,r.runStyle(i,e,n),i},r.runStyle=function(t,r,i){var o=function(){r&&r()};return t.rel&&"stylesheet"!==t.rel?void e.nextTick(o):("STYLE"===t.tagName?e.nextTick(o):(n.once(t,"load",o),n.once(t,"error",o)),i?i(t):document.head.appendChild(t),t)},r.runStylesInElement=function(t,n,i){var o=t.querySelectorAll("style,link");if(0===o.length&&n)return void e.nextTick(n);for(var a=0,s=function(){n&&++a===o.length&&e.nextTick(n)},l=0;l<o.length;l++)r.runStyle(o[l],s,i)},r}();this.senna.globalEvalStyles=r}.call(this),function(){var t=this.senna.dom,e=this.senna.features,n={mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"};Object.keys(n).forEach(function(e){t.registerCustomEvent(e,{delegate:!0,handler:function(t,n){var r=n.relatedTarget,i=n.delegateTarget;return!r||r!==i&&!i.contains(r)?(n.customType=e,t(n)):void 0},originalEvent:n[e]})});var r={animation:"animationend",transition:"transitionend"};Object.keys(r).forEach(function(n){var i=r[n];t.registerCustomEvent(i,{event:!0,delegate:!0,handler:function(t,e){return e.customType=i,t(e)},originalEvent:e.checkAnimationEventName()[n]})})}.call(this),function(){var t=this.senna.dom,e=this.senna.DomEventEmitterProxy,n=this.senna.DomEventHandle,r=this.senna.features,i=this.senna.globalEval,o=this.senna.globalEvalStyles;this.senna.dom=t,this.sennaNamed.dom=this.sennaNamed.dom||{},this.sennaNamed.dom.dom=t,this.sennaNamed.dom.DomEventEmitterProxy=e,this.sennaNamed.dom.DomEventHandle=n,this.sennaNamed.dom.features=r,this.sennaNamed.dom.globalEval=i,this.sennaNamed.dom.globalEvalStyles=o}.call(this),function(){var e=this.sennaNamed.metal.core,n=this.sennaNamed.metal.async,r=function(){};r.prototype.then=function(){},r.IMPLEMENTED_BY_PROP="$goog_Thenable",r.addImplementation=function(t){t.prototype.then=t.prototype.then,t.prototype.$goog_Thenable=!0},r.isImplementedBy=function(t){if(!t)return!1;try{return!!t.$goog_Thenable}catch(e){return!1}};var i=function(t){var e=Array.prototype.slice.call(arguments,1);return function(){var n=e.slice();return n.push.apply(n,arguments),t.apply(this,n)}},o=function a(t,e){this.state_=a.State_.PENDING,this.result_=void 0,this.parent_=null,this.callbackEntries_=null,this.executing_=!1,a.UNHANDLED_REJECTION_DELAY>0?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;e<t.length;e++)this.executeCallback_(t[e],this.state_,this.result_)}this.executing_=!1},o.prototype.executeCallback_=function(t,e,n){e===o.State_.FULFILLED?t.onFulfilled(n):(this.removeUnhandledRejection_(),t.onRejected(n))},o.prototype.removeUnhandledRejection_=function(){var t;if(o.UNHANDLED_REJECTION_DELAY>0)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()];return e?e[0]:void 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(-1===t.indexOf("://")&&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;e>r;r++)n[r-1]=arguments[r];return"/"===t.charAt(t.length-1)&&(t=t.substring(0,t.length-1)),n=n.map(function(t){return"/"===t.charAt(0)?t.substring(1):t}),[t].concat(n).join("/").replace(/\/$/,"")},r.urlDecode=function(t){return decodeURIComponent(t.replace(/\+/g," "))},r}();a.DEFAULT_PROTOCOL="http:",a.HOSTNAME_PLACEHOLDER="hostname"+Date.now(),a.RANDOM_PARAM="zx",this.senna.Uri=a}.call(this),function(){var e=this.senna.globals,n=this.senna.Uri,r=function(){function r(){t.classCallCheck(this,r)}return r.copyNodeAttributes=function(t,e){Array.prototype.slice.call(t.attributes).forEach(function(t){return e.setAttribute(t.name,t.value)})},r.getCurrentBrowserPath=function(){return this.getCurrentBrowserPathWithoutHash()+e.window.location.hash},r.getCurrentBrowserPathWithoutHash=function(){return e.window.location.pathname+e.window.location.search},r.getUrlPath=function(t){var e=new n(t);return e.getPathname()+e.getSearch()+e.getHash()},r.getUrlPathWithoutHash=function(t){var e=new n(t);return e.getPathname()+e.getSearch()},r.isCurrentBrowserPath=function(t){return t?r.getUrlPathWithoutHash(t)===this.getCurrentBrowserPathWithoutHash():!1},r.isHtml5HistorySupported=function(){return!(!e.window.history||!e.window.history.pushState)},r.clearNodeAttributes=function(t){Array.prototype.slice.call(t.attributes).forEach(function(e){return t.removeAttribute(e.name)})},r}();this.senna.utils=r}.call(this),function(){var e=this.sennaNamed.metal.core,n=function(){function n(r,i){if(t.classCallCheck(this,n),!e.isDefAndNotNull(r))throw new Error("Route path not specified.");if(!e.isFunction(i))throw new Error("Route handler is not a function.");this.handler=i,this.path=r}return n.prototype.getHandler=function(){return this.handler},n.prototype.getPath=function(){return this.path},n.prototype.matchesPath=function(t){var n=this.path;return e.isString(n)?t===n:e.isFunction(n)?n(t):n instanceof RegExp?t.search(n)>-1:!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.dom,o=this.senna.Promise,a=this.sennaNamed.events.EventEmitter,s=this.sennaNamed.events.EventHandler,l=this.senna.utils,c=this.senna.globals,u=this.senna.Route,h=this.senna.Screen,p=this.senna.Surface,d=this.senna.Uri,f=function(a){function f(){t.classCallCheck(this,f);var e=t.possibleConstructorReturn(this,a.call(this));return e.activeScreen=null,e.activePath=null,e.allowPreventNavigate=!0,e.basePath="",e.captureScrollPositionFromScrollEvent=!0,e.defaultTitle=c.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 c.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 s,e.appEventHandlers_.add(i.on(c.window,"scroll",e.onScroll_.bind(e)),i.on(c.window,"load",e.onLoad_.bind(e)),i.on(c.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(f,a),f.prototype.addRoutes=function(t){var e=this;return Array.isArray(t)||(t=[t]),t.forEach(function(t){t instanceof u||(t=new u(t.path,t.handler)),e.routes.push(t)}),this},f.prototype.addSurfaces=function(t){var e=this;return Array.isArray(t)||(t=[t]),t.forEach(function(t){r.isString(t)&&(t=new p(t)),e.surfaces[t.getId()]=t}),this},f.prototype.canNavigate=function(t){var e=l.getUrlPath(t),n=new d(t);return this.isLinkSameOrigin_(n.getHostname())&&this.isSameBasePath_(e)?!!this.findRoute(e):!1},f.prototype.clearScreensCache=function(){var t=this;Object.keys(this.screens).forEach(function(e){e===t.activePath?t.activeScreen.clearCache():t.removeScreen(e)})},f.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===h||h.isImplementedBy(r.prototype)?new r:r(e)||new h}return n},f.prototype.disposeInternal=function(){this.activeScreen&&this.removeScreen(this.activePath),this.clearScreensCache(),this.formEventHandler_.removeListener(),this.linkEventHandler_.removeListener(),this.appEventHandlers_.removeAllListeners(),a.prototype.disposeInternal.call(this)},f.prototype.dispatch=function(){return this.navigate(l.getCurrentBrowserPath(),!0)},f.prototype.doNavigate_=function(t,e){var n=this;if(this.activeScreen&&this.activeScreen.beforeDeactivate())return this.pendingNavigate=o.reject(new o.CancellationError("Cancelled by active screen")),this.pendingNavigate;var r=this.findRoute(t);if(!r)return this.pendingNavigate=o.reject(new o.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})},f.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,c.capturedFormElement=null},f.prototype.findRoute=function(t){if(t.lastIndexOf("#")>-1&&l.isCurrentBrowserPath(t))return null;t=l.getUrlPathWithoutHash(t),t=l.getUrlPathWithoutHash(t.substr(this.basePath.length));for(var e=0;e<this.routes.length;e++){var n=this.routes[e];if(n.matchesPath(t))return n}return null},f.prototype.getAllowPreventNavigate=function(){return this.allowPreventNavigate},f.prototype.getBasePath=function(){return this.basePath},f.prototype.getDefaultTitle=function(){return this.defaultTitle},f.prototype.getFormSelector=function(){return this.formSelector},f.prototype.getLinkSelector=function(){return this.linkSelector},f.prototype.getLoadingCssClass=function(){return this.loadingCssClass},f.prototype.getUpdateScrollPosition=function(){return this.updateScrollPosition},f.prototype.handleNavigateError_=function(t,e,n){l.isCurrentBrowserPath(t)||this.removeScreen(t)},f.prototype.hasRoutes=function(){return this.routes.length>0},f.prototype.isLinkSameOrigin_=function(t){return t===c.window.location.hostname},f.prototype.isSameBasePath_=function(t){return 0===t.indexOf(this.basePath)},f.prototype.lockHistoryScrollPosition_=function(){var t=c.window.history.state;if(t){var e=!1,r=function i(){c.document.removeEventListener("scroll",i,!1),e||(c.window.scrollTo(t.scrollLeft,t.scrollTop),e=!0)};n.nextTick(r),c.document.addEventListener("scroll",r,!1)}},f.prototype.maybeDisableNativeScrollRestoration=function(){this.nativeScrollRestorationSupported&&(this.nativeScrollRestoration_=c.window.history.scrollRestoration,c.window.history.scrollRestoration="manual")},f.prototype.maybeNavigate_=function(t,e){if(this.canNavigate(t)){c.capturedFormElement=e.capturedFormElement;var n=!1;try{this.navigate(l.getUrlPath(t))}catch(r){n=!0}n||e.preventDefault()}},f.prototype.maybeRepositionScrollToHashedAnchor=function(){var t=c.window.location.hash;if(t){var e=c.document.getElementById(t.substring(1));e&&c.window.scrollTo(e.offsetLeft,e.offsetTop)}},f.prototype.maybeRestoreNativeScrollRestoration=function(){this.nativeScrollRestorationSupported&&this.nativeScrollRestoration_&&(c.window.history.scrollRestoration=this.nativeScrollRestoration_)},f.prototype.navigate=function(t,e){if(!l.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},f.prototype.onBeforeNavigate_=function(t){c.capturedFormElement&&(t.form=c.capturedFormElement)},f.prototype.onBeforeNavigateDefault_=function(t){this.pendingNavigate&&this.pendingNavigate.path===t.path||this.emit("startNavigate",{form:t.form,path:t.path,replaceHistory:t.replaceHistory})},f.prototype.onDocClickDelegate_=function(t){t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||t.button||this.maybeNavigate_(t.delegateTarget.href,t)},f.prototype.onDocSubmitDelegate_=function(t){var e=t.delegateTarget;"get"!==e.method&&(t.capturedFormElement=e,this.maybeNavigate_(e.action,t))},f.prototype.onLoad_=function(){var t=this;this.skipLoadPopstate=!0,setTimeout(function(){t.skipLoadPopstate=!1},0),this.maybeRepositionScrollToHashedAnchor()},f.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(c.window.location.hash?(this.redirectPath&&!l.isCurrentBrowserPath(this.redirectPath)&&this.reloadPage(),this.maybeRepositionScrollToHashedAnchor()):this.reloadPage())}},f.prototype.onScroll_=function(){this.captureScrollPositionFromScrollEvent&&this.saveHistoryCurrentPageScrollPosition_()},f.prototype.onStartNavigate_=function(t){var e=this;this.maybeDisableNativeScrollRestoration(),this.captureScrollPositionFromScrollEvent=!1,i.addClasses(c.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||(i.removeClasses(c.document.documentElement,e.loadingCssClass),e.maybeRestoreNativeScrollRestoration(),e.captureScrollPositionFromScrollEvent=!0),e.emit("endNavigate",n)}),this.pendingNavigate.path=t.path},f.prototype.prefetch=function(t){var e=this,n=this.findRoute(t);if(!n)return o.reject(new o.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})},f.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(c.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},f.prototype.prepareNavigateSurfaces_=function(t,e){Object.keys(e).forEach(function(n){var r=t.getSurfaceContent(n);e[n].addContent(t.getId(),r)})},f.prototype.reloadPage=function(){c.window.location.reload()},f.prototype.removeRoute=function(t){return e.remove(this.routes,t)},f.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])},f.prototype.saveHistoryCurrentPageScrollPosition_=function(){var t=c.window.history.state;t&&t.senna&&(t.scrollTop=c.window.pageYOffset,t.scrollLeft=c.window.pageXOffset,c.window.history.replaceState(t,null,null))},f.prototype.setAllowPreventNavigate=function(t){this.allowPreventNavigate=t},f.prototype.setBasePath=function(t){this.basePath=t},f.prototype.setDefaultTitle=function(t){this.defaultTitle=t},f.prototype.setFormSelector=function(t){this.formSelector=t,this.formEventHandler_&&this.formEventHandler_.removeListener(),this.formEventHandler_=i.delegate(document,"submit",this.formSelector,this.onDocSubmitDelegate_.bind(this),this.allowPreventNavigate)},f.prototype.setLinkSelector=function(t){this.linkSelector=t,this.linkEventHandler_&&this.linkEventHandler_.removeListener(),this.linkEventHandler_=i.delegate(document,"click",this.linkSelector,this.onDocClickDelegate_.bind(this),this.allowPreventNavigate)},f.prototype.setLoadingCssClass=function(t){this.loadingCssClass=t},f.prototype.setUpdateScrollPosition=function(t){this.updateScrollPosition=t},f.prototype.stopPendingNavigate_=function(){this.pendingNavigate&&(this.pendingNavigate.cancel("Cancel pending navigation"),this.pendingNavigate=null)},f.prototype.syncScrollPositionSyncThenAsync_=function(){var t=this,e=c.window.history.state;if(e){var r=e.scrollTop,i=e.scrollLeft,a=function(){t.updateScrollPosition&&c.window.scrollTo(i,r)};return new o(function(t){return a()&n.nextTick(function(){return a()&t()})})}},f.prototype.updateHistory_=function(t,e,n,r){r?c.window.history.replaceState(n,t,e):c.window.history.pushState(n,t,e),c.document.title=t},f}(a);this.senna.App=f}.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;r<n.length;r++){var i=n[r].indexOf(": ");if(i>0){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-1!==e.userAgent.indexOf(t)},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){return u.isIeOrEdge&&this.httpMethod===h.GET?new c(t).makeUnique().toString():t},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&&399>=t},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),c.isIe&&t.href&&(t.href=new u(t.href).makeUnique().toString())),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,"<senna"),t=t.replace(/\/html\s*\>/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(),t})},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);