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