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