Bundled output for commit ae27c0ff18 [skip ci]

This commit is contained in:
Gandalf-the-Bot 2017-10-04 22:02:02 +00:00
parent ae27c0ff18
commit 77378af232
3 changed files with 83 additions and 63 deletions

View file

@ -18,7 +18,7 @@ mithril.js [![NPM Version](https://img.shields.io/npm/v/mithril.svg)](https://ww
## What is Mithril?
A modern client-side Javascript framework for building Single Page Applications. It's small (<!-- size -->8.43 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box.
A modern client-side Javascript framework for building Single Page Applications. It's small (<!-- size -->8.42 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box.
Mithril is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍.

View file

@ -1,7 +1,7 @@
;(function() {
"use strict"
function Vnode(tag, key, attrs0, children, text, dom) {
return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: undefined, _state: undefined, events: undefined, instance: undefined, skip: false}
return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined, skip: false}
}
Vnode.normalize = function(node) {
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
@ -398,6 +398,22 @@ var coreRenderer = function($window) {
function getNameSpace(vnode) {
return vnode.attrs && vnode.attrs.xmlns || nameSpace[vnode.tag]
}
//sanity check to discourage people from doing `vnode.state = ...`
function checkState(vnode, original) {
if (vnode.state !== original) throw new Error("`vnode.state` must not be modified")
}
//Note: the hook is passed as the `this` argument to allow proxying the
//arguments without requiring a full array allocation to do so. It also
//takes advantage of the fact the current `vnode` is the first argument in
//all lifecycle methods.
function callHook(vnode) {
var original = vnode.state
try {
return this.apply(original, arguments)
} finally {
checkState(vnode, original)
}
}
//create
function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {
for (var i = start; i < end; i++) {
@ -495,10 +511,9 @@ var coreRenderer = function($window) {
sentinel.$$reentrantLock$$ = true
vnode.state = (vnode.tag.prototype != null && typeof vnode.tag.prototype.view === "function") ? new vnode.tag(vnode) : vnode.tag(vnode)
}
vnode._state = vnode.state
if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)
initLifecycle(vnode._state, vnode, hooks)
vnode.instance = Vnode.normalize(vnode._state.view.call(vnode.state, vnode))
initLifecycle(vnode.state, vnode, hooks)
vnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))
if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as argument")
sentinel.$$reentrantLock$$ = null
}
@ -612,7 +627,6 @@ var coreRenderer = function($window) {
var oldTag = old.tag, tag = vnode.tag
if (oldTag === tag) {
vnode.state = old.state
vnode._state = old._state
vnode.events = old.events
if (!recycling && shouldNotUpdate(vnode, old)) return
if (typeof oldTag === "string") {
@ -692,10 +706,10 @@ var coreRenderer = function($window) {
if (recycling) {
initComponent(vnode, hooks)
} else {
vnode.instance = Vnode.normalize(vnode._state.view.call(vnode.state, vnode))
vnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))
if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as argument")
if (vnode.attrs != null) updateLifecycle(vnode.attrs, vnode, hooks)
updateLifecycle(vnode._state, vnode, hooks)
updateLifecycle(vnode.state, vnode, hooks)
}
if (vnode.instance != null) {
if (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling)
@ -778,15 +792,16 @@ var coreRenderer = function($window) {
}
function removeNode(vnode, context) {
var expected = 1, called = 0
var original = vnode.state
if (vnode.attrs && typeof vnode.attrs.onbeforeremove === "function") {
var result = vnode.attrs.onbeforeremove.call(vnode.state, vnode)
var result = callHook.call(vnode.attrs.onbeforeremove, vnode)
if (result != null && typeof result.then === "function") {
expected++
result.then(continuation, continuation)
}
}
if (typeof vnode.tag !== "string" && typeof vnode._state.onbeforeremove === "function") {
var result = vnode._state.onbeforeremove.call(vnode.state, vnode)
if (typeof vnode.tag !== "string" && typeof vnode.state.onbeforeremove === "function") {
var result = callHook.call(vnode.state.onbeforeremove, vnode)
if (result != null && typeof result.then === "function") {
expected++
result.then(continuation, continuation)
@ -795,6 +810,7 @@ var coreRenderer = function($window) {
continuation()
function continuation() {
if (++called === expected) {
checkState(vnode, original)
onremove(vnode)
if (vnode.dom) {
var count0 = vnode.domSize || 1
@ -818,9 +834,9 @@ var coreRenderer = function($window) {
if (parent != null) parent.removeChild(node)
}
function onremove(vnode) {
if (vnode.attrs && typeof vnode.attrs.onremove === "function") vnode.attrs.onremove.call(vnode.state, vnode)
if (vnode.attrs && typeof vnode.attrs.onremove === "function") callHook.call(vnode.attrs.onremove, vnode)
if (typeof vnode.tag !== "string") {
if (typeof vnode._state.onremove === "function") vnode._state.onremove.call(vnode.state, vnode)
if (typeof vnode.state.onremove === "function") callHook.call(vnode.state.onremove, vnode)
if (vnode.instance != null) onremove(vnode.instance)
} else {
var children = vnode.children
@ -974,16 +990,20 @@ var coreRenderer = function($window) {
}
//lifecycle
function initLifecycle(source, vnode, hooks) {
if (typeof source.oninit === "function") source.oninit.call(vnode.state, vnode)
if (typeof source.oncreate === "function") hooks.push(source.oncreate.bind(vnode.state, vnode))
if (typeof source.oninit === "function") callHook.call(source.oninit, vnode)
if (typeof source.oncreate === "function") hooks.push(callHook.bind(source.oncreate, vnode))
}
function updateLifecycle(source, vnode, hooks) {
if (typeof source.onupdate === "function") hooks.push(source.onupdate.bind(vnode.state, vnode))
if (typeof source.onupdate === "function") hooks.push(callHook.bind(source.onupdate, vnode))
}
function shouldNotUpdate(vnode, old) {
var forceVnodeUpdate, forceComponentUpdate
if (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === "function") forceVnodeUpdate = vnode.attrs.onbeforeupdate.call(vnode.state, vnode, old)
if (typeof vnode.tag !== "string" && typeof vnode._state.onbeforeupdate === "function") forceComponentUpdate = vnode._state.onbeforeupdate.call(vnode.state, vnode, old)
if (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === "function") {
forceVnodeUpdate = callHook.call(vnode.attrs.onbeforeupdate, vnode, old)
}
if (typeof vnode.tag !== "string" && typeof vnode.state.onbeforeupdate === "function") {
forceComponentUpdate = callHook.call(vnode.state.onbeforeupdate, vnode, old)
}
if (!(forceVnodeUpdate === undefined && forceComponentUpdate === undefined) && !forceVnodeUpdate && !forceComponentUpdate) {
vnode.dom = old.dom
vnode.domSize = old.domSize

90
mithril.min.js vendored
View file

@ -1,45 +1,45 @@
(function(){function y(b,d,h,k,q,m){return{tag:b,key:d,attrs:h,children:k,text:q,dom:m,domSize:void 0,state:void 0,_state:void 0,events:void 0,instance:void 0,skip:!1}}function O(b){for(var d in b)if(G.call(b,d))return!1;return!0}function A(b){var d=arguments[1],h=2;if(null==b||"string"!==typeof b&&"function"!==typeof b&&"function"!==typeof b.view)throw Error("The selector must be either a string or a component.");if("string"===typeof b){var k;if(!(k=P[b])){var q="div";for(var m=[],l={};k=R.exec(b);){var r=
k[1],f=k[2];""===r&&""!==f?q=f:"#"===r?l.id=f:"."===r?m.push(f):"["===k[3][0]&&((r=k[6])&&(r=r.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===k[4]?m.push(r):l[k[4]]=""===r?r:r||!0)}0<m.length&&(l.className=m.join(" "));k=P[b]={tag:q,attrs:l}}}if(null==d)d={};else if("object"!==typeof d||null!=d.tag||Array.isArray(d))d={},h=1;if(arguments.length===h+1)q=arguments[h],Array.isArray(q)||(q=[q]);else for(q=[];h<arguments.length;)q.push(arguments[h++]);h=y.normalizeChildren(q);if("string"===
typeof b){q=!1;var n,p;m=d.className||d["class"];if(!O(k.attrs)&&!O(d)){l={};for(var a in d)G.call(d,a)&&(l[a]=d[a]);d=l}for(a in k.attrs)G.call(k.attrs,a)&&(d[a]=k.attrs[a]);void 0!==m&&(void 0!==d["class"]&&(d["class"]=void 0,d.className=m),null!=k.attrs.className&&(d.className=k.attrs.className+" "+m));for(a in d)if(G.call(d,a)&&"key"!==a){q=!0;break}Array.isArray(h)&&1===h.length&&null!=h[0]&&"#"===h[0].tag?p=h[0].children:n=h;return y(k.tag,d.key,q?d:void 0,n,p)}return y(b,d.key,d,h)}function S(b){var d=
0,h=null,k="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var q=Date.now()-d;null===h&&(h=k(function(){h=null;b();d=Date.now()},16-q))}}y.normalize=function(b){return Array.isArray(b)?y("[",void 0,void 0,y.normalizeChildren(b),void 0,void 0):null!=b&&"object"!==typeof b?y("#",void 0,void 0,!1===b?"":b,void 0,void 0):b};y.normalizeChildren=function(b){for(var d=0;d<b.length;d++)b[d]=y.normalize(b[d]);return b};var R=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,
P={},G={}.hasOwnProperty;A.trust=function(b){null==b&&(b="");return y("<",void 0,void 0,b,void 0,void 0)};A.fragment=function(b,d){return y("[",b.key,b,y.normalizeChildren(d),void 0,void 0)};var w=function(b){function d(b,a){return function D(d){var l;try{if(!a||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(l=d.then))n(function(){a||0!==b.length||console.error("Possible unhandled promise rejection:",d);for(var h=0;h<b.length;h++)b[h](d);q.length=0;m.length=0;f.state=a;f.retry=
function(){D(d)}});else{if(d===k)throw new TypeError("Promise can't be resolved w/ itself");h(l.bind(d))}}catch(H){r(H)}}}function h(b){function a(a){return function(b){0<d++||a(b)}}var d=0,f=a(r);try{b(a(l),f)}catch(D){f(D)}}if(!(this instanceof w))throw Error("Promise must be called with `new`");if("function"!==typeof b)throw new TypeError("executor must be a function");var k=this,q=[],m=[],l=d(q,!0),r=d(m,!1),f=k._instance={resolvers:q,rejectors:m},n="function"===typeof setImmediate?setImmediate:
setTimeout;h(b)};w.prototype.then=function(b,d){function h(b,d,h,l){d.push(function(a){if("function"!==typeof b)h(a);else try{q(b(a))}catch(v){m&&m(v)}});"function"===typeof k.retry&&l===k.state&&k.retry()}var k=this._instance,q,m,l=new w(function(b,d){q=b;m=d});h(b,k.resolvers,q,!0);h(d,k.rejectors,m,!1);return l};w.prototype["catch"]=function(b){return this.then(null,b)};w.resolve=function(b){return b instanceof w?b:new w(function(d){d(b)})};w.reject=function(b){return new w(function(d,h){h(b)})};
w.all=function(b){return new w(function(d,h){var k=b.length,q=0,m=[];if(0===b.length)d([]);else for(var l=0;l<b.length;l++)(function(l){function f(b){q++;m[l]=b;q===k&&d(m)}null==b[l]||"object"!==typeof b[l]&&"function"!==typeof b[l]||"function"!==typeof b[l].then?f(b[l]):b[l].then(f,h)})(l)})};w.race=function(b){return new w(function(d,h){for(var k=0;k<b.length;k++)b[k].then(d,h)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=w),w=window.Promise):"undefined"!==
typeof global&&("undefined"===typeof global.Promise&&(global.Promise=w),w=global.Promise);var E=function(b){function d(b,k){if(Array.isArray(k))for(var l=0;l<k.length;l++)d(b+"["+l+"]",k[l]);else if("[object Object]"===Object.prototype.toString.call(k))for(l in k)d(b+"["+l+"]",k[l]);else h.push(encodeURIComponent(b)+(null!=k&&""!==k?"="+encodeURIComponent(k):""))}if("[object Object]"!==Object.prototype.toString.call(b))return"";var h=[],k;for(k in b)d(k,b[k]);return h.join("&")},U=/^file:\/\//i,M=
function(b,d){function h(){function a(){0===--b&&"function"===typeof p&&p()}var b=0;return function T(d){var f=d.then;d.then=function(){b++;var h=f.apply(d,arguments);h.then(a,function(d){a();if(0===b)throw d;});return T(h)};return d}}function k(a,b){if("string"===typeof a){var d=a;a=b||{};null==a.url&&(a.url=d)}return a}function q(a,b){if(null==b)return a;for(var d=a.match(/:[^\/]+/gi)||[],f=0;f<d.length;f++){var h=d[f].slice(1);null!=b[h]&&(a=a.replace(d[f],b[h]))}return a}function m(a,b){var d=
E(b);if(""!==d){var f=0>a.indexOf("?")?"?":"&";a+=f+d}return a}function l(a){try{return""!==a?JSON.parse(a):null}catch(v){throw Error(a);}}function r(a){return a.responseText}function f(a,b){if("function"===typeof a)if(Array.isArray(b))for(var d=0;d<b.length;d++)b[d]=new a(b[d]);else return new a(b);return b}var n=0,p;return{request:function(a,n){var p=h();a=k(a,n);var v=new d(function(d,h){null==a.method&&(a.method="GET");a.method=a.method.toUpperCase();var k="GET"===a.method||"TRACE"===a.method?
!1:"boolean"===typeof a.useBody?a.useBody:!0;"function"!==typeof a.serialize&&(a.serialize="undefined"!==typeof FormData&&a.data instanceof FormData?function(a){return a}:JSON.stringify);"function"!==typeof a.deserialize&&(a.deserialize=l);"function"!==typeof a.extract&&(a.extract=r);a.url=q(a.url,a.data);k?a.data=a.serialize(a.data):a.url=m(a.url,a.data);var n=new b.XMLHttpRequest,p=!1,v=n.abort;n.abort=function(){p=!0;v.call(n)};n.open(a.method,a.url,"boolean"===typeof a.async?a.async:!0,"string"===
typeof a.user?a.user:void 0,"string"===typeof a.password?a.password:void 0);a.serialize!==JSON.stringify||!k||a.headers&&a.headers.hasOwnProperty("Content-Type")||n.setRequestHeader("Content-Type","application/json; charset=utf-8");a.deserialize!==l||a.headers&&a.headers.hasOwnProperty("Accept")||n.setRequestHeader("Accept","application/json, text/*");a.withCredentials&&(n.withCredentials=a.withCredentials);for(var u in a.headers)({}).hasOwnProperty.call(a.headers,u)&&n.setRequestHeader(u,a.headers[u]);
"function"===typeof a.config&&(n=a.config(n,a)||n);n.onreadystatechange=function(){if(!p&&4===n.readyState)try{var b=a.extract!==r?a.extract(n,a):a.deserialize(a.extract(n,a));if(200<=n.status&&300>n.status||304===n.status||U.test(a.url))d(f(a.type,b));else{var k=Error(n.responseText);k.code=n.status;k.response=b;h(k)}}catch(g){h(g)}};k&&null!=a.data?n.send(a.data):n.send()});return!0===a.background?v:p(v)},jsonp:function(a,l){var r=h();a=k(a,l);var p=new d(function(d,h){var k=a.callbackName||"_mithril_"+
Math.round(1E16*Math.random())+"_"+n++,l=b.document.createElement("script");b[k]=function(h){l.parentNode.removeChild(l);d(f(a.type,h));delete b[k]};l.onerror=function(){l.parentNode.removeChild(l);h(Error("JSONP request failed"));delete b[k]};null==a.data&&(a.data={});a.url=q(a.url,a.data);a.data[a.callbackKey||"callback"]=k;l.src=m(a.url,a.data);b.document.documentElement.appendChild(l)});return!0===a.background?p:r(p)},setCompletionCallback:function(a){p=a}}}(window,w),Q=function(b){function d(g,
c,e,a,b,d,k){for(;e<a;e++){var f=c[e];null!=f&&h(g,f,b,k,d)}}function h(g,c,e,a,b){var f=c.tag;if("string"===typeof f)switch(c.state={},null!=c.attrs&&I(c.attrs,c,e),f){case "#":return c.dom=t.createTextNode(c.children),n(g,c.dom,b),c.dom;case "<":return k(g,c,b);case "[":var l=t.createDocumentFragment();null!=c.children&&(f=c.children,d(l,f,0,f.length,e,null,a));c.dom=l.firstChild;c.domSize=l.childNodes.length;n(g,l,b);return l;default:var x=c.tag,m=(f=c.attrs)&&f.is;x=(a=c.attrs&&c.attrs.xmlns||
G[c.tag]||a)?m?t.createElementNS(a,x,{is:m}):t.createElementNS(a,x):m?t.createElement(x,{is:m}):t.createElement(x);c.dom=x;if(null!=f)for(l in m=a,f)D(c,l,null,f[l],m);n(g,x,b);null!=c.attrs&&null!=c.attrs.contenteditable?p(c):(null!=c.text&&(""!==c.text?x.textContent=c.text:c.children=[y("#",void 0,void 0,c.text,void 0,void 0)]),null!=c.children&&(g=c.children,d(x,g,0,g.length,e,null,a),g=c.attrs,"select"===c.tag&&null!=g&&("value"in g&&D(c,"value",null,g.value,void 0),"selectedIndex"in g&&D(c,"selectedIndex",
null,g.selectedIndex,void 0))));return x}else return q(c,e),null!=c.instance?(e=h(g,c.instance,e,a,b),c.dom=c.instance.dom,c.domSize=null!=c.dom?c.instance.domSize:0,n(g,e,b),c=e):(c.domSize=0,c=L),c}function k(g,c,a){var e={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[(c.children.match(/^\s*?<(\w+)/im)||[])[1]]||"div";e=t.createElement(e);e.innerHTML=c.children;c.dom=e.firstChild;c.domSize=e.childNodes.length;c=t.createDocumentFragment();
for(var b;b=e.firstChild;)c.appendChild(b);n(g,c,a);return c}function q(g,c){if("function"===typeof g.tag.view){g.state=Object.create(g.tag);var e=g.state.view;if(null!=e.$$reentrantLock$$)return L;e.$$reentrantLock$$=!0}else{g.state=void 0;e=g.tag;if(null!=e.$$reentrantLock$$)return L;e.$$reentrantLock$$=!0;g.state=null!=g.tag.prototype&&"function"===typeof g.tag.prototype.view?new g.tag(g):g.tag(g)}g._state=g.state;null!=g.attrs&&I(g.attrs,g,c);I(g._state,g,c);g.instance=y.normalize(g._state.view.call(g.state,
g));if(g.instance===g)throw Error("A view cannot return the vnode it received as argument");e.$$reentrantLock$$=null}function m(g,c,e,b,k,m,q){if(c!==e&&(null!=c||null!=e))if(null==c)d(g,e,0,e.length,k,m,q);else if(null==e)a(c,0,c.length,e);else{if(c.length===e.length){for(var x=!1,p=0;p<e.length;p++)if(null!=e[p]&&null!=c[p]){x=null==e[p].key&&null==c[p].key;break}if(x){for(p=0;p<c.length;p++)c[p]!==e[p]&&(null==c[p]&&null!=e[p]?h(g,e[p],k,q,f(c,p+1,m)):null==e[p]?a(c,p,p+1,e):l(g,c[p],e[p],k,f(c,
p+1,m),b,q));return}}if(!b)a:{if(null!=c.pool&&Math.abs(c.pool.length-e.length)<=Math.abs(c.length-e.length)&&(b=e[0]&&e[0].children&&e[0].children.length||0,Math.abs((c.pool[0]&&c.pool[0].children&&c.pool[0].children.length||0)-b)<=Math.abs((c[0]&&c[0].children&&c[0].children.length||0)-b))){b=!0;break a}b=!1}if(b){var C=c.pool;c=c.concat(c.pool)}p=x=0;for(var v=c.length-1,F=e.length-1,u;v>=x&&F>=p;){var z=c[x],t=e[p];if(z!==t||b)if(null==z)x++;else if(null==t)p++;else if(z.key===t.key){var B=null!=
C&&x>=c.length-C.length||null==C&&b;x++;p++;l(g,z,t,k,f(c,x,m),B,q);b&&z.tag===t.tag&&n(g,r(z),m)}else if(z=c[v],z!==t||b)if(null==z)v--;else if(null==t)p++;else if(z.key===t.key)B=null!=C&&v>=c.length-C.length||null==C&&b,l(g,z,t,k,f(c,v+1,m),B,q),(b||p<F)&&n(g,r(z),f(c,x,m)),v--,p++;else break;else v--,p++;else x++,p++}for(;v>=x&&F>=p;){z=c[v];t=e[F];if(z!==t||b)if(null==z)v--;else{if(null!=t)if(z.key===t.key)B=null!=C&&v>=c.length-C.length||null==C&&b,l(g,z,t,k,f(c,v+1,m),B,q),b&&z.tag===t.tag&&
n(g,r(z),m),null!=z.dom&&(m=z.dom),v--;else{if(!u){u=c;z=v;B={};var w;for(w=0;w<z;w++){var y=u[w];null!=y&&(y=y.key,null!=y&&(B[y]=w))}u=B}null!=t&&(z=u[t.key],null!=z?(B=c[z],l(g,B,t,k,f(c,v+1,m),b,q),n(g,r(B),m),c[z].skip=!0,null!=B.dom&&(m=B.dom)):m=h(g,t,k,q,m))}F--}else v--,F--;if(F<p)break}d(g,e,p,F+1,k,m,q);a(c,x,v+1,e)}}function l(g,c,e,a,b,d,f){var n=c.tag;if(n===e.tag){e.state=c.state;e._state=c._state;e.events=c.events;var x;if(x=!d){var t,C;null!=e.attrs&&"function"===typeof e.attrs.onbeforeupdate&&
(t=e.attrs.onbeforeupdate.call(e.state,e,c));"string"!==typeof e.tag&&"function"===typeof e._state.onbeforeupdate&&(C=e._state.onbeforeupdate.call(e.state,e,c));void 0===t&&void 0===C||t||C?x=!1:(e.dom=c.dom,e.domSize=c.domSize,e.instance=c.instance,x=!0)}if(!x)if("string"===typeof n)switch(null!=e.attrs&&(d?(e.state={},I(e.attrs,e,a)):K(e.attrs,e,a)),n){case "#":c.children.toString()!==e.children.toString()&&(c.dom.nodeValue=e.children);e.dom=c.dom;break;case "<":c.children!==e.children?(r(c),k(g,
e,b)):(e.dom=c.dom,e.domSize=c.domSize);break;case "[":m(g,c.children,e.children,d,a,b,f);c=0;a=e.children;e.dom=null;if(null!=a){for(d=0;d<a.length;d++){var u=a[d];null!=u&&null!=u.dom&&(null==e.dom&&(e.dom=u.dom),c+=u.domSize||1)}1!==c&&(e.domSize=c)}break;default:g=e.dom=c.dom;f=e.attrs&&e.attrs.xmlns||G[e.tag]||f;"textarea"===e.tag&&(null==e.attrs&&(e.attrs={}),null!=e.text&&(e.attrs.value=e.text,e.text=void 0));b=c.attrs;n=e.attrs;x=f;if(null!=n)for(u in n)D(e,u,b&&b[u],n[u],x);if(null!=b)for(u in b)null!=
n&&u in n||("className"===u&&(u="class"),"o"!==u[0]||"n"!==u[1]||w(u)?"key"!==u&&e.dom.removeAttribute(u):A(e,u,void 0));null!=e.attrs&&null!=e.attrs.contenteditable?p(e):null!=c.text&&null!=e.text&&""!==e.text?c.text.toString()!==e.text.toString()&&(c.dom.firstChild.nodeValue=e.text):(null!=c.text&&(c.children=[y("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=e.text&&(e.children=[y("#",void 0,void 0,e.text,void 0,void 0)]),m(g,c.children,e.children,d,a,null,f))}else{if(d)q(e,a);else{e.instance=
y.normalize(e._state.view.call(e.state,e));if(e.instance===e)throw Error("A view cannot return the vnode it received as argument");null!=e.attrs&&K(e.attrs,e,a);K(e._state,e,a)}null!=e.instance?(null==c.instance?h(g,e.instance,a,f,b):l(g,c.instance,e.instance,a,b,d,f),e.dom=e.instance.dom,e.domSize=e.instance.domSize):null!=c.instance?(v(c.instance,null),e.dom=void 0,e.domSize=0):(e.dom=c.dom,e.domSize=c.domSize)}}else v(c,null),h(g,e,a,f,b)}function r(g){var c=g.domSize;if(null!=c||null==g.dom){var a=
t.createDocumentFragment();if(0<c){for(g=g.dom;--c;)a.appendChild(g.nextSibling);a.insertBefore(g,a.firstChild)}return a}return g.dom}function f(g,c,a){for(;c<g.length;c++)if(null!=g[c]&&null!=g[c].dom)return g[c].dom;return a}function n(g,c,a){a&&a.parentNode?g.insertBefore(c,a):g.appendChild(c)}function p(a){var c=a.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,a.dom.innerHTML!==c&&(a.dom.innerHTML=c);else if(null!=a.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");
}function a(a,c,b,d){for(;c<b;c++){var g=a[c];null!=g&&(g.skip?g.skip=!1:v(g,d))}}function v(a,c){function b(){if(++d===g&&(u(a),a.dom)){var b=a.domSize||1;if(1<b)for(var e=a.dom;--b;){var f=e.nextSibling,k=f.parentNode;null!=k&&k.removeChild(f)}b=a.dom;e=b.parentNode;null!=e&&e.removeChild(b);if(b=null!=c&&null==a.domSize)b=a.attrs,b=!(null!=b&&(b.oncreate||b.onupdate||b.onbeforeremove||b.onremove));b&&"string"===typeof a.tag&&(c.pool?c.pool.push(a):c.pool=[a])}}var g=1,d=0;if(a.attrs&&"function"===
typeof a.attrs.onbeforeremove){var f=a.attrs.onbeforeremove.call(a.state,a);null!=f&&"function"===typeof f.then&&(g++,f.then(b,b))}"string"!==typeof a.tag&&"function"===typeof a._state.onbeforeremove&&(f=a._state.onbeforeremove.call(a.state,a),null!=f&&"function"===typeof f.then&&(g++,f.then(b,b)));b()}function u(a){a.attrs&&"function"===typeof a.attrs.onremove&&a.attrs.onremove.call(a.state,a);if("string"!==typeof a.tag)"function"===typeof a._state.onremove&&a._state.onremove.call(a.state,a),null!=
a.instance&&u(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&u(b)}}function D(a,c,b,d,f){if("key"!==c&&"is"!==c&&!w(c)){if("o"===c[0]&&"n"===c[1])return A(a,c,d);if((b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===t.activeElement||"object"===typeof d)&&void 0!==d){var e=a.dom;if("xlink:"===c.slice(0,6))e.setAttributeNS("http://www.w3.org/1999/xlink",c,d);else if("style"===c)if(a=b,null!=a&&null!=d&&"object"===typeof a&&
"object"===typeof d&&d!==a){for(var g in d)d[g]!==a[g]&&(e.style[g]=d[g]);for(g in a)g in d||(e.style[g]="")}else if(a===d&&(e.style.cssText="",a=null),null==d)e.style.cssText="";else if("string"===typeof d)e.style.cssText=d;else for(g in"string"===typeof a&&(e.style.cssText=""),d)e.style[g]=d[g];else if(c in e&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===f&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===c){g=""+d;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===
g&&a.dom===t.activeElement)return;if("select"===a.tag)if(null===d){if(-1===a.dom.selectedIndex&&a.dom===t.activeElement)return}else if(null!==b&&a.dom.value===g&&a.dom===t.activeElement)return;if("option"===a.tag&&null!=b&&a.dom.value===g)return}"input"===a.tag&&"type"===c?e.setAttribute(c,d):e[c]=d}else"boolean"===typeof d?d?e.setAttribute(c,""):e.removeAttribute(c):e.setAttribute("className"===c?"class":c,d)}}}function w(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===
a||"onbeforeupdate"===a}function H(){}function A(a,c,b){null!=a.events?a.events[c]!==b&&(null==b||"function"!==typeof b&&"object"!==typeof b?(null!=a.events[c]&&a.dom.removeEventListener(c.slice(2),a.events,!1),a.events[c]=void 0):(null==a.events[c]&&a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)):null==b||"function"!==typeof b&&"object"!==typeof b||(a.events=new H,a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)}function I(a,c,b){"function"===typeof a.oninit&&a.oninit.call(c.state,
c);"function"===typeof a.oncreate&&b.push(a.oncreate.bind(c.state,c))}function K(a,c,b){"function"===typeof a.onupdate&&b.push(a.onupdate.bind(c.state,c))}var t=b.document,L=t.createDocumentFragment(),G={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},E;H.prototype=Object.create(null);H.prototype.handleEvent=function(a){var c=this["on"+a.type];"function"===typeof c?c.call(a.target,a):"function"===typeof c.handleEvent&&c.handleEvent(a);"function"===typeof E&&E.call(a.target,
a)};return{render:function(a,c){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],d=t.activeElement,f=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(c)||(c=[c]);m(a,a.vnodes,y.normalizeChildren(c),!1,b,null,"http://www.w3.org/1999/xhtml"===f?void 0:f);a.vnodes=c;for(f=0;f<b.length;f++)b[f]();null!=d&&t.activeElement!==d&&d.focus()},setEventCallback:function(a){return E=a}}},J=function(b,d){function h(b){b=m.indexOf(b);
-1<b&&m.splice(b,2)}function k(){if(l)throw Error("Nested m.redraw.sync() call");l=!0;for(var b=1;b<m.length;b+=2)try{m[b]()}catch(n){"undefined"!==typeof console&&console.error(n)}l=!1}var q=Q(b);q.setEventCallback(function(b){!1===b.redraw?b.redraw=void 0:r()});var m=[],l=!1,r=(d||S)(k);r.sync=k;return{subscribe:function(b,d){h(b);m.push(b,d)},unsubscribe:h,redraw:r,render:q.render}}(window);M.setCompletionCallback(J.redraw);A.mount=function(b){return function(d,h){if(null===h)b.render(d,[]),b.unsubscribe(d);
else{if(null==h.view&&"function"!==typeof h)throw Error("m.mount(element, component) expects a component, not a vnode");var k=function(){b.render(d,y(h))};b.subscribe(d,k);k()}}}(J);var V=w,N=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var d={},h={},k=0;k<b.length;k++){var q=b[k].split("="),m=decodeURIComponent(q[0]);q=2===q.length?decodeURIComponent(q[1]):"";"true"===q?q=!0:"false"===q&&(q=!1);var l=m.split(/\]\[?|\[/),r=d;-1<m.indexOf("[")&&l.pop();
for(var f=0;f<l.length;f++){m=l[f];var n=l[f+1];n=""==n||!isNaN(parseInt(n,10));var p=f===l.length-1;""===m&&(m=l.slice(0,f).join(),null==h[m]&&(h[m]=0),m=h[m]++);null==r[m]&&(r[m]=p?q:n?[]:{});r=r[m]}}return d},W=function(b){function d(d){var f=b.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==f[0]&&(f="/"+f);return f}function h(b){return function(){null==l&&(l=m(function(){l=null;b()}))}}function k(b,d,k){var a=b.indexOf("?"),f=b.indexOf("#"),h=-1<a?a:-1<
f?f:b.length;if(-1<a){a=N(b.slice(a+1,-1<f?f:b.length));for(var l in a)d[l]=a[l]}if(-1<f)for(l in d=N(b.slice(f+1)),d)k[l]=d[l];return b.slice(0,h)}var q="function"===typeof b.history.pushState,m="function"===typeof setImmediate?setImmediate:setTimeout,l,r={prefix:"#!",getPath:function(){switch(r.prefix.charAt(0)){case "#":return d("hash").slice(r.prefix.length);case "?":return d("search").slice(r.prefix.length)+d("hash");default:return d("pathname").slice(r.prefix.length)+d("search")+d("hash")}},
setPath:function(d,l,h){var a={},f={};d=k(d,a,f);if(null!=l){for(var m in l)a[m]=l[m];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return l[d]})}(m=E(a))&&(d+="?"+m);(f=E(f))&&(d+="#"+f);q?(f=h?h.state:null,m=h?h.title:null,b.onpopstate(),h&&h.replace?b.history.replaceState(f,m,r.prefix+d):b.history.pushState(f,m,r.prefix+d)):b.location.href=r.prefix+d},defineRoutes:function(d,l,m){function a(){var a=r.getPath(),f={},h=k(a,f,f),p=b.history.state;if(null!=p)for(var n in p)f[n]=p[n];for(var q in d)if(p=
new RegExp("^"+q.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),p.test(h)){h.replace(p,function(){for(var b=q.match(/:[^\/]+/g)||[],k=[].slice.call(arguments,1,-2),h=0;h<b.length;h++)f[b[h].replace(/:|\./g,"")]=decodeURIComponent(k[h]);l(d[q],f,a,q)});return}m(a,f)}q?b.onpopstate=h(a):"#"===r.prefix.charAt(0)&&(b.onhashchange=a);a()}};return r};A.route=function(b,d){var h=W(b),k=function(b){return b},q,m,l,r,f,n=function(b,a,n){function p(){null!=q&&d.render(b,q(y(m,l.key,
l)))}if(null==b)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var v=function(){p();v=d.redraw};d.subscribe(b,p);var w=function(b){if(b!==a)h.setPath(a,null,{replace:!0});else throw Error("Could not resolve default route "+a);};h.defineRoutes(n,function(a,b,d){var h=f=function(a,p){h===f&&(m=null==p||"function"!==typeof p.view&&"function"!==typeof p?"div":p,l=b,r=d,f=null,q=(a.render||k).bind(a),v())};a.view||"function"===typeof a?h({},a):a.onmatch?V.resolve(a.onmatch(b,
d)).then(function(b){h(a,b)},w):h(a,"div")},w)};n.set=function(b,a,d){null!=f&&(d=d||{},d.replace=!0);f=null;h.setPath(b,a,d)};n.get=function(){return r};n.prefix=function(b){h.prefix=b};n.link=function(b){b.dom.setAttribute("href",h.prefix+b.attrs.href);b.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(h.prefix)&&(a=a.slice(h.prefix.length)),n.set(a,void 0,void 0))}};n.param=function(b){return"undefined"!==
typeof l&&"undefined"!==typeof b?l[b]:l};return n}(window,J);A.withAttr=function(b,d,h){return function(k){d.call(h||this,b in k.currentTarget?k.currentTarget[b]:k.currentTarget.getAttribute(b))}};var X=Q(window);A.render=X.render;A.redraw=J.redraw;A.request=M.request;A.jsonp=M.jsonp;A.parseQueryString=N;A.buildQueryString=E;A.version="1.1.3";A.vnode=y;"undefined"!==typeof module?module.exports=A:window.m=A})();
(function(){function w(a,c,e,f,n,k){return{tag:a,key:c,attrs:e,children:f,text:n,dom:k,domSize:void 0,state:void 0,events:void 0,instance:void 0,skip:!1}}function O(a){for(var c in a)if(D.call(a,c))return!1;return!0}function A(a){var c=arguments[1],e=2;if(null==a||"string"!==typeof a&&"function"!==typeof a&&"function"!==typeof a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a){var f;if(!(f=P[a])){var n="div";for(var k=[],g={};f=S.exec(a);){var q=f[1],
m=f[2];""===q&&""!==m?n=m:"#"===q?g.id=m:"."===q?k.push(m):"["===f[3][0]&&((q=f[6])&&(q=q.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===f[4]?k.push(q):g[f[4]]=""===q?q:q||!0)}0<k.length&&(g.className=k.join(" "));f=P[a]={tag:n,attrs:g}}}if(null==c)c={};else if("object"!==typeof c||null!=c.tag||Array.isArray(c))c={},e=1;if(arguments.length===e+1)n=arguments[e],Array.isArray(n)||(n=[n]);else for(n=[];e<arguments.length;)n.push(arguments[e++]);e=w.normalizeChildren(n);if("string"===typeof a){n=
!1;var l,t;k=c.className||c["class"];if(!O(f.attrs)&&!O(c)){g={};for(var b in c)D.call(c,b)&&(g[b]=c[b]);c=g}for(b in f.attrs)D.call(f.attrs,b)&&(c[b]=f.attrs[b]);void 0!==k&&(void 0!==c["class"]&&(c["class"]=void 0,c.className=k),null!=f.attrs.className&&(c.className=f.attrs.className+" "+k));for(b in c)if(D.call(c,b)&&"key"!==b){n=!0;break}Array.isArray(e)&&1===e.length&&null!=e[0]&&"#"===e[0].tag?t=e[0].children:l=e;return w(f.tag,c.key,n?c:void 0,l,t)}return w(a,c.key,c,e)}function T(a){var c=
0,e=null,f="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var n=Date.now()-c;null===e&&(e=f(function(){e=null;a();c=Date.now()},16-n))}}w.normalize=function(a){return Array.isArray(a)?w("[",void 0,void 0,w.normalizeChildren(a),void 0,void 0):null!=a&&"object"!==typeof a?w("#",void 0,void 0,!1===a?"":a,void 0,void 0):a};w.normalizeChildren=function(a){for(var c=0;c<a.length;c++)a[c]=w.normalize(a[c]);return a};var S=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,
P={},D={}.hasOwnProperty;A.trust=function(a){null==a&&(a="");return w("<",void 0,void 0,a,void 0,void 0)};A.fragment=function(a,c){return w("[",a.key,a,w.normalizeChildren(c),void 0,void 0)};var r=function(a){function c(a,b){return function C(c){var g;try{if(!b||null==c||"object"!==typeof c&&"function"!==typeof c||"function"!==typeof(g=c.then))l(function(){b||0!==a.length||console.error("Possible unhandled promise rejection:",c);for(var e=0;e<a.length;e++)a[e](c);n.length=0;k.length=0;m.state=b;m.retry=
function(){C(c)}});else{if(c===f)throw new TypeError("Promise can't be resolved w/ itself");e(g.bind(c))}}catch(H){q(H)}}}function e(a){function b(b){return function(a){0<c++||b(a)}}var c=0,m=b(q);try{a(b(g),m)}catch(C){m(C)}}if(!(this instanceof r))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var f=this,n=[],k=[],g=c(n,!0),q=c(k,!1),m=f._instance={resolvers:n,rejectors:k},l="function"===typeof setImmediate?setImmediate:
setTimeout;e(a)};r.prototype.then=function(a,c){function e(a,c,e,g){c.push(function(b){if("function"!==typeof a)e(b);else try{n(a(b))}catch(v){k&&k(v)}});"function"===typeof f.retry&&g===f.state&&f.retry()}var f=this._instance,n,k,g=new r(function(a,c){n=a;k=c});e(a,f.resolvers,n,!0);e(c,f.rejectors,k,!1);return g};r.prototype["catch"]=function(a){return this.then(null,a)};r.resolve=function(a){return a instanceof r?a:new r(function(c){c(a)})};r.reject=function(a){return new r(function(c,e){e(a)})};
r.all=function(a){return new r(function(c,e){var f=a.length,n=0,k=[];if(0===a.length)c([]);else for(var g=0;g<a.length;g++)(function(g){function m(a){n++;k[g]=a;n===f&&c(k)}null==a[g]||"object"!==typeof a[g]&&"function"!==typeof a[g]||"function"!==typeof a[g].then?m(a[g]):a[g].then(m,e)})(g)})};r.race=function(a){return new r(function(c,e){for(var f=0;f<a.length;f++)a[f].then(c,e)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=r),r=window.Promise):"undefined"!==
typeof global&&("undefined"===typeof global.Promise&&(global.Promise=r),r=global.Promise);var G=function(a){function c(a,f){if(Array.isArray(f))for(var g=0;g<f.length;g++)c(a+"["+g+"]",f[g]);else if("[object Object]"===Object.prototype.toString.call(f))for(g in f)c(a+"["+g+"]",f[g]);else e.push(encodeURIComponent(a)+(null!=f&&""!==f?"="+encodeURIComponent(f):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var e=[],f;for(f in a)c(f,a[f]);return e.join("&")},V=/^file:\/\//i,M=
function(a,c){function e(){function b(){0===--a&&"function"===typeof t&&t()}var a=0;return function U(c){var e=c.then;c.then=function(){a++;var m=e.apply(c,arguments);m.then(b,function(c){b();if(0===a)throw c;});return U(m)};return c}}function f(b,a){if("string"===typeof b){var c=b;b=a||{};null==b.url&&(b.url=c)}return b}function n(b,a){if(null==a)return b;for(var c=b.match(/:[^\/]+/gi)||[],e=0;e<c.length;e++){var m=c[e].slice(1);null!=a[m]&&(b=b.replace(c[e],a[m]))}return b}function k(b,a){var c=
G(a);if(""!==c){var e=0>b.indexOf("?")?"?":"&";b+=e+c}return b}function g(b){try{return""!==b?JSON.parse(b):null}catch(v){throw Error(b);}}function q(b){return b.responseText}function m(b,a){if("function"===typeof b)if(Array.isArray(a))for(var c=0;c<a.length;c++)a[c]=new b(a[c]);else return new b(a);return a}var l=0,t;return{request:function(b,l){var t=e();b=f(b,l);var v=new c(function(c,e){null==b.method&&(b.method="GET");b.method=b.method.toUpperCase();var f="GET"===b.method||"TRACE"===b.method?
!1:"boolean"===typeof b.useBody?b.useBody:!0;"function"!==typeof b.serialize&&(b.serialize="undefined"!==typeof FormData&&b.data instanceof FormData?function(b){return b}:JSON.stringify);"function"!==typeof b.deserialize&&(b.deserialize=g);"function"!==typeof b.extract&&(b.extract=q);b.url=n(b.url,b.data);f?b.data=b.serialize(b.data):b.url=k(b.url,b.data);var l=new a.XMLHttpRequest,t=!1,v=l.abort;l.abort=function(){t=!0;v.call(l)};l.open(b.method,b.url,"boolean"===typeof b.async?b.async:!0,"string"===
typeof b.user?b.user:void 0,"string"===typeof b.password?b.password:void 0);b.serialize!==JSON.stringify||!f||b.headers&&b.headers.hasOwnProperty("Content-Type")||l.setRequestHeader("Content-Type","application/json; charset=utf-8");b.deserialize!==g||b.headers&&b.headers.hasOwnProperty("Accept")||l.setRequestHeader("Accept","application/json, text/*");b.withCredentials&&(l.withCredentials=b.withCredentials);for(var F in b.headers)({}).hasOwnProperty.call(b.headers,F)&&l.setRequestHeader(F,b.headers[F]);
"function"===typeof b.config&&(l=b.config(l,b)||l);l.onreadystatechange=function(){if(!t&&4===l.readyState)try{var a=b.extract!==q?b.extract(l,b):b.deserialize(b.extract(l,b));if(200<=l.status&&300>l.status||304===l.status||V.test(b.url))c(m(b.type,a));else{var f=Error(l.responseText);f.code=l.status;f.response=a;e(f)}}catch(W){e(W)}};f&&null!=b.data?l.send(b.data):l.send()});return!0===b.background?v:t(v)},jsonp:function(b,g){var t=e();b=f(b,g);var q=new c(function(c,e){var f=b.callbackName||"_mithril_"+
Math.round(1E16*Math.random())+"_"+l++,g=a.document.createElement("script");a[f]=function(e){g.parentNode.removeChild(g);c(m(b.type,e));delete a[f]};g.onerror=function(){g.parentNode.removeChild(g);e(Error("JSONP request failed"));delete a[f]};null==b.data&&(b.data={});b.url=n(b.url,b.data);b.data[b.callbackKey||"callback"]=f;g.src=k(b.url,b.data);a.document.documentElement.appendChild(g)});return!0===b.background?q:t(q)},setCompletionCallback:function(b){t=b}}}(window,r),R=function(a){function c(h,
d){if(h.state!==d)throw Error("`vnode.state` must not be modified");}function e(h){var d=h.state;try{return this.apply(d,arguments)}finally{c(h,d)}}function f(h,d,b,a,c,e,f){for(;b<a;b++){var u=d[b];null!=u&&n(h,u,c,f,e)}}function n(h,d,u,a,c){var e=d.tag;if("string"===typeof e)switch(d.state={},null!=d.attrs&&J(d.attrs,d,u),e){case "#":return d.dom=B.createTextNode(d.children),b(h,d.dom,c),d.dom;case "<":return k(h,d,c);case "[":var m=B.createDocumentFragment();null!=d.children&&(e=d.children,f(m,
e,0,e.length,u,null,a));d.dom=m.firstChild;d.domSize=m.childNodes.length;b(h,m,c);return m;default:var p=d.tag,l=(e=d.attrs)&&e.is;p=(a=d.attrs&&d.attrs.xmlns||G[d.tag]||a)?l?B.createElementNS(a,p,{is:l}):B.createElementNS(a,p):l?B.createElement(p,{is:l}):B.createElement(p);d.dom=p;if(null!=e)for(m in l=a,e)H(d,m,null,e[m],l);b(h,p,c);null!=d.attrs&&null!=d.attrs.contenteditable?v(d):(null!=d.text&&(""!==d.text?p.textContent=d.text:d.children=[w("#",void 0,void 0,d.text,void 0,void 0)]),null!=d.children&&
(h=d.children,f(p,h,0,h.length,u,null,a),h=d.attrs,"select"===d.tag&&null!=h&&("value"in h&&H(d,"value",null,h.value,void 0),"selectedIndex"in h&&H(d,"selectedIndex",null,h.selectedIndex,void 0))));return p}else return g(d,u),null!=d.instance?(u=n(h,d.instance,u,a,c),d.dom=d.instance.dom,d.domSize=null!=d.dom?d.instance.domSize:0,b(h,u,c),d=u):(d.domSize=0,d=D),d}function k(h,d,u){var a={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[(d.children.match(/^\s*?<(\w+)/im)||
[])[1]]||"div";a=B.createElement(a);a.innerHTML=d.children;d.dom=a.firstChild;d.domSize=a.childNodes.length;d=B.createDocumentFragment();for(var c;c=a.firstChild;)d.appendChild(c);b(h,d,u);return d}function g(h,d){if("function"===typeof h.tag.view){h.state=Object.create(h.tag);var b=h.state.view;if(null!=b.$$reentrantLock$$)return D;b.$$reentrantLock$$=!0}else{h.state=void 0;b=h.tag;if(null!=b.$$reentrantLock$$)return D;b.$$reentrantLock$$=!0;h.state=null!=h.tag.prototype&&"function"===typeof h.tag.prototype.view?
new h.tag(h):h.tag(h)}null!=h.attrs&&J(h.attrs,h,d);J(h.state,h,d);h.instance=w.normalize(e.call(h.state.view,h));if(h.instance===h)throw Error("A view cannot return the vnode it received as argument");b.$$reentrantLock$$=null}function q(h,d,a,c,e,g,k){if(d!==a&&(null!=d||null!=a))if(null==d)f(h,a,0,a.length,e,g,k);else if(null==a)F(d,0,d.length,a);else{if(d.length===a.length){for(var u=!1,p=0;p<a.length;p++)if(null!=a[p]&&null!=d[p]){u=null==a[p].key&&null==d[p].key;break}if(u){for(p=0;p<d.length;p++)d[p]!==
a[p]&&(null==d[p]&&null!=a[p]?n(h,a[p],e,k,t(d,p+1,g)):null==a[p]?F(d,p,p+1,a):m(h,d[p],a[p],e,t(d,p+1,g),c,k));return}}if(!c)a:{if(null!=d.pool&&Math.abs(d.pool.length-a.length)<=Math.abs(d.length-a.length)&&(c=a[0]&&a[0].children&&a[0].children.length||0,Math.abs((d.pool[0]&&d.pool[0].children&&d.pool[0].children.length||0)-c)<=Math.abs((d[0]&&d[0].children&&d[0].children.length||0)-c))){c=!0;break a}c=!1}if(c){var q=d.pool;d=d.concat(d.pool)}p=u=0;for(var v=d.length-1,x=a.length-1,I;v>=u&&x>=p;){var y=
d[u],z=a[p];if(y!==z||c)if(null==y)u++;else if(null==z)p++;else if(y.key===z.key){var r=null!=q&&u>=d.length-q.length||null==q&&c;u++;p++;m(h,y,z,e,t(d,u,g),r,k);c&&y.tag===z.tag&&b(h,l(y),g)}else if(y=d[v],y!==z||c)if(null==y)v--;else if(null==z)p++;else if(y.key===z.key)r=null!=q&&v>=d.length-q.length||null==q&&c,m(h,y,z,e,t(d,v+1,g),r,k),(c||p<x)&&b(h,l(y),t(d,u,g)),v--,p++;else break;else v--,p++;else u++,p++}for(;v>=u&&x>=p;){y=d[v];z=a[x];if(y!==z||c)if(null==y)v--;else{if(null!=z)if(y.key===
z.key)r=null!=q&&v>=d.length-q.length||null==q&&c,m(h,y,z,e,t(d,v+1,g),r,k),c&&y.tag===z.tag&&b(h,l(y),g),null!=y.dom&&(g=y.dom),v--;else{if(!I){I=d;y=v;r={};var w;for(w=0;w<y;w++){var C=I[w];null!=C&&(C=C.key,null!=C&&(r[C]=w))}I=r}null!=z&&(y=I[z.key],null!=y?(r=d[y],m(h,r,z,e,t(d,v+1,g),c,k),b(h,l(r),g),d[y].skip=!0,null!=r.dom&&(g=r.dom)):g=n(h,z,e,k,g))}x--}else v--,x--;if(x<p)break}f(h,a,p,x+1,e,g,k);F(d,u,v+1,a)}}function m(h,d,a,b,c,f,t){var p=d.tag;if(p===a.tag){a.state=d.state;a.events=
d.events;var u;if(u=!f){var r,z;null!=a.attrs&&"function"===typeof a.attrs.onbeforeupdate&&(r=e.call(a.attrs.onbeforeupdate,a,d));"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeupdate&&(z=e.call(a.state.onbeforeupdate,a,d));void 0===r&&void 0===z||r||z?u=!1:(a.dom=d.dom,a.domSize=d.domSize,a.instance=d.instance,u=!0)}if(!u)if("string"===typeof p)switch(null!=a.attrs&&(f?(a.state={},J(a.attrs,a,b)):L(a.attrs,a,b)),p){case "#":d.children.toString()!==a.children.toString()&&(d.dom.nodeValue=
a.children);a.dom=d.dom;break;case "<":d.children!==a.children?(l(d),k(h,a,c)):(a.dom=d.dom,a.domSize=d.domSize);break;case "[":q(h,d.children,a.children,f,b,c,t);d=0;b=a.children;a.dom=null;if(null!=b){for(f=0;f<b.length;f++){var x=b[f];null!=x&&null!=x.dom&&(null==a.dom&&(a.dom=x.dom),d+=x.domSize||1)}1!==d&&(a.domSize=d)}break;default:h=a.dom=d.dom;t=a.attrs&&a.attrs.xmlns||G[a.tag]||t;"textarea"===a.tag&&(null==a.attrs&&(a.attrs={}),null!=a.text&&(a.attrs.value=a.text,a.text=void 0));c=d.attrs;
p=a.attrs;u=t;if(null!=p)for(x in p)H(a,x,c&&c[x],p[x],u);if(null!=c)for(x in c)null!=p&&x in p||("className"===x&&(x="class"),"o"!==x[0]||"n"!==x[1]||A(x)?"key"!==x&&a.dom.removeAttribute(x):Q(a,x,void 0));null!=a.attrs&&null!=a.attrs.contenteditable?v(a):null!=d.text&&null!=a.text&&""!==a.text?d.text.toString()!==a.text.toString()&&(d.dom.firstChild.nodeValue=a.text):(null!=d.text&&(d.children=[w("#",void 0,void 0,d.text,void 0,d.dom.firstChild)]),null!=a.text&&(a.children=[w("#",void 0,void 0,
a.text,void 0,void 0)]),q(h,d.children,a.children,f,b,null,t))}else{if(f)g(a,b);else{a.instance=w.normalize(e.call(a.state.view,a));if(a.instance===a)throw Error("A view cannot return the vnode it received as argument");null!=a.attrs&&L(a.attrs,a,b);L(a.state,a,b)}null!=a.instance?(null==d.instance?n(h,a.instance,b,t,c):m(h,d.instance,a.instance,b,c,f,t),a.dom=a.instance.dom,a.domSize=a.instance.domSize):null!=d.instance?(C(d.instance,null),a.dom=void 0,a.domSize=0):(a.dom=d.dom,a.domSize=d.domSize)}}else C(d,
null),n(h,a,b,t,c)}function l(a){var d=a.domSize;if(null!=d||null==a.dom){var b=B.createDocumentFragment();if(0<d){for(a=a.dom;--d;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function t(a,d,b){for(;d<a.length;d++)if(null!=a[d]&&null!=a[d].dom)return a[d].dom;return b}function b(a,d,b){b&&b.parentNode?a.insertBefore(d,b):a.appendChild(d)}function v(a){var d=a.children;if(null!=d&&1===d.length&&"<"===d[0].tag)d=d[0].children,a.dom.innerHTML!==d&&(a.dom.innerHTML=
d);else if(null!=a.text||null!=d&&0!==d.length)throw Error("Child node of a contenteditable must be trusted");}function F(a,d,b,c){for(;d<b;d++){var h=a[d];null!=h&&(h.skip?h.skip=!1:C(h,c))}}function C(a,d){function b(){if(++f===h&&(c(a,m),r(a),a.dom)){var b=a.domSize||1;if(1<b)for(var e=a.dom;--b;){var g=e.nextSibling,p=g.parentNode;null!=p&&p.removeChild(g)}b=a.dom;e=b.parentNode;null!=e&&e.removeChild(b);if(b=null!=d&&null==a.domSize)b=a.attrs,b=!(null!=b&&(b.oncreate||b.onupdate||b.onbeforeremove||
b.onremove));b&&"string"===typeof a.tag&&(d.pool?d.pool.push(a):d.pool=[a])}}var h=1,f=0,m=a.state;if(a.attrs&&"function"===typeof a.attrs.onbeforeremove){var g=e.call(a.attrs.onbeforeremove,a);null!=g&&"function"===typeof g.then&&(h++,g.then(b,b))}"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeremove&&(g=e.call(a.state.onbeforeremove,a),null!=g&&"function"===typeof g.then&&(h++,g.then(b,b)));b()}function r(a){a.attrs&&"function"===typeof a.attrs.onremove&&e.call(a.attrs.onremove,a);
if("string"!==typeof a.tag)"function"===typeof a.state.onremove&&e.call(a.state.onremove,a),null!=a.instance&&r(a.instance);else if(a=a.children,Array.isArray(a))for(var d=0;d<a.length;d++){var b=a[d];null!=b&&r(b)}}function H(a,b,c,e,f){if("key"!==b&&"is"!==b&&!A(b)){if("o"===b[0]&&"n"===b[1])return Q(a,b,e);if((c!==e||"value"===b||"checked"===b||"selectedIndex"===b||"selected"===b&&a.dom===B.activeElement||"object"===typeof e)&&void 0!==e){var d=a.dom;if("xlink:"===b.slice(0,6))d.setAttributeNS("http://www.w3.org/1999/xlink",
b,e);else if("style"===b)if(a=c,null!=a&&null!=e&&"object"===typeof a&&"object"===typeof e&&e!==a){for(var h in e)e[h]!==a[h]&&(d.style[h]=e[h]);for(h in a)h in e||(d.style[h]="")}else if(a===e&&(d.style.cssText="",a=null),null==e)d.style.cssText="";else if("string"===typeof e)d.style.cssText=e;else for(h in"string"===typeof a&&(d.style.cssText=""),e)d.style[h]=e[h];else if(b in d&&"href"!==b&&"list"!==b&&"form"!==b&&"width"!==b&&"height"!==b&&void 0===f&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===
b){h=""+e;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===h&&a.dom===B.activeElement)return;if("select"===a.tag)if(null===e){if(-1===a.dom.selectedIndex&&a.dom===B.activeElement)return}else if(null!==c&&a.dom.value===h&&a.dom===B.activeElement)return;if("option"===a.tag&&null!=c&&a.dom.value===h)return}"input"===a.tag&&"type"===b?d.setAttribute(b,e):d[b]=e}else"boolean"===typeof e?e?d.setAttribute(b,""):d.removeAttribute(b):d.setAttribute("className"===b?"class":b,e)}}}function A(a){return"oninit"===
a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function K(){}function Q(a,b,c){null!=a.events?a.events[b]!==c&&(null==c||"function"!==typeof c&&"object"!==typeof c?(null!=a.events[b]&&a.dom.removeEventListener(b.slice(2),a.events,!1),a.events[b]=void 0):(null==a.events[b]&&a.dom.addEventListener(b.slice(2),a.events,!1),a.events[b]=c)):null==c||"function"!==typeof c&&"object"!==typeof c||(a.events=new K,a.dom.addEventListener(b.slice(2),a.events,!1),a.events[b]=
c)}function J(a,b,c){"function"===typeof a.oninit&&e.call(a.oninit,b);"function"===typeof a.oncreate&&c.push(e.bind(a.oncreate,b))}function L(a,b,c){"function"===typeof a.onupdate&&c.push(e.bind(a.onupdate,b))}var B=a.document,D=B.createDocumentFragment(),G={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},E;K.prototype=Object.create(null);K.prototype.handleEvent=function(a){var b=this["on"+a.type];"function"===typeof b?b.call(a.target,a):"function"===typeof b.handleEvent&&
b.handleEvent(a);"function"===typeof E&&E.call(a.target,a)};return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var d=[],c=B.activeElement,e=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);q(a,a.vnodes,w.normalizeChildren(b),!1,d,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=b;for(e=0;e<d.length;e++)d[e]();null!=c&&B.activeElement!==c&&c.focus()},setEventCallback:function(a){return E=
a}}},E=function(a,c){function e(a){a=k.indexOf(a);-1<a&&k.splice(a,2)}function f(){if(g)throw Error("Nested m.redraw.sync() call");g=!0;for(var a=1;a<k.length;a+=2)try{k[a]()}catch(l){"undefined"!==typeof console&&console.error(l)}g=!1}var n=R(a);n.setEventCallback(function(a){!1===a.redraw?a.redraw=void 0:q()});var k=[],g=!1,q=(c||T)(f);q.sync=f;return{subscribe:function(a,c){e(a);k.push(a,c)},unsubscribe:e,redraw:q,render:n.render}}(window);M.setCompletionCallback(E.redraw);A.mount=function(a){return function(c,
e){if(null===e)a.render(c,[]),a.unsubscribe(c);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var f=function(){a.render(c,w(e))};a.subscribe(c,f);f()}}}(E);var X=r,N=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var c={},e={},f=0;f<a.length;f++){var n=a[f].split("="),k=decodeURIComponent(n[0]);n=2===n.length?decodeURIComponent(n[1]):"";"true"===n?n=!0:"false"===n&&(n=!1);var g=k.split(/\]\[?|\[/),
q=c;-1<k.indexOf("[")&&g.pop();for(var m=0;m<g.length;m++){k=g[m];var l=g[m+1];l=""==l||!isNaN(parseInt(l,10));var t=m===g.length-1;""===k&&(k=g.slice(0,m).join(),null==e[k]&&(e[k]=0),k=e[k]++);null==q[k]&&(q[k]=t?n:l?[]:{});q=q[k]}}return c},Y=function(a){function c(c){var e=a.location[c].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===c&&"/"!==e[0]&&(e="/"+e);return e}function e(a){return function(){null==g&&(g=k(function(){g=null;a()}))}}function f(a,c,e){var b=a.indexOf("?"),
f=a.indexOf("#"),g=-1<b?b:-1<f?f:a.length;if(-1<b){b=N(a.slice(b+1,-1<f?f:a.length));for(var m in b)c[m]=b[m]}if(-1<f)for(m in c=N(a.slice(f+1)),c)e[m]=c[m];return a.slice(0,g)}var n="function"===typeof a.history.pushState,k="function"===typeof setImmediate?setImmediate:setTimeout,g,q={prefix:"#!",getPath:function(){switch(q.prefix.charAt(0)){case "#":return c("hash").slice(q.prefix.length);case "?":return c("search").slice(q.prefix.length)+c("hash");default:return c("pathname").slice(q.prefix.length)+
c("search")+c("hash")}},setPath:function(c,e,g){var b={},k={};c=f(c,b,k);if(null!=e){for(var m in e)b[m]=e[m];c=c.replace(/:([^\/]+)/g,function(a,c){delete b[c];return e[c]})}(m=G(b))&&(c+="?"+m);(k=G(k))&&(c+="#"+k);n?(k=g?g.state:null,m=g?g.title:null,a.onpopstate(),g&&g.replace?a.history.replaceState(k,m,q.prefix+c):a.history.pushState(k,m,q.prefix+c)):a.location.href=q.prefix+c},defineRoutes:function(c,g,k){function b(){var b=q.getPath(),e={},m=f(b,e,e),l=a.history.state;if(null!=l)for(var n in l)e[n]=
l[n];for(var t in c)if(l=new RegExp("^"+t.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),l.test(m)){m.replace(l,function(){for(var a=t.match(/:[^\/]+/g)||[],f=[].slice.call(arguments,1,-2),k=0;k<a.length;k++)e[a[k].replace(/:|\./g,"")]=decodeURIComponent(f[k]);g(c[t],e,b,t)});return}k(b,e)}n?a.onpopstate=e(b):"#"===q.prefix.charAt(0)&&(a.onhashchange=b);b()}};return q};A.route=function(a,c){var e=Y(a),f=function(a){return a},n,k,g,q,m,l=function(a,b,l){function t(){null!=
n&&c.render(a,n(w(k,g.key,g)))}if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var r=function(){t();r=c.redraw};c.subscribe(a,t);var v=function(a){if(a!==b)e.setPath(b,null,{replace:!0});else throw Error("Could not resolve default route "+b);};e.defineRoutes(l,function(a,b,c){var e=m=function(a,l){e===m&&(k=null==l||"function"!==typeof l.view&&"function"!==typeof l?"div":l,g=b,q=c,m=null,n=(a.render||f).bind(a),r())};a.view||"function"===typeof a?e({},
a):a.onmatch?X.resolve(a.onmatch(b,c)).then(function(b){e(a,b)},v):e(a,"div")},v)};l.set=function(a,b,c){null!=m&&(c=c||{},c.replace=!0);m=null;e.setPath(a,b,c)};l.get=function(){return q};l.prefix=function(a){e.prefix=a};l.link=function(a){a.dom.setAttribute("href",e.prefix+a.attrs.href);a.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(e.prefix)&&(a=a.slice(e.prefix.length)),l.set(a,void 0,void 0))}};
l.param=function(a){return"undefined"!==typeof g&&"undefined"!==typeof a?g[a]:g};return l}(window,E);A.withAttr=function(a,c,e){return function(f){c.call(e||this,a in f.currentTarget?f.currentTarget[a]:f.currentTarget.getAttribute(a))}};var Z=R(window);A.render=Z.render;A.redraw=E.redraw;A.request=M.request;A.jsonp=M.jsonp;A.parseQueryString=N;A.buildQueryString=G;A.version="1.1.3";A.vnode=w;"undefined"!==typeof module?module.exports=A:window.m=A})();